40 lines
1019 B
TypeScript
40 lines
1019 B
TypeScript
/**
|
|
* Completion index — orchestrates all registered completion sources.
|
|
*/
|
|
|
|
import { diceSource } from "./sources/dice.js";
|
|
import { linksSource } from "./sources/links.js";
|
|
import type { ProcessedBlocks } from "./block-processor.js";
|
|
import type { CompletionsPayload } from "./types.js";
|
|
|
|
export type {
|
|
CompletionsPayload,
|
|
DiceCompletion,
|
|
LinkCompletion,
|
|
SparkTableCompletion,
|
|
StatDef,
|
|
StatTemplate,
|
|
StatSheet,
|
|
} from "./types.js";
|
|
|
|
/**
|
|
* Build completions from the content index and pre-collected blocks.
|
|
* Called at server startup and on any file change.
|
|
*/
|
|
export function scanCompletions(
|
|
index: Record<string, string>,
|
|
blocks: ProcessedBlocks,
|
|
): CompletionsPayload {
|
|
const dice = diceSource.scan(index) as CompletionsPayload["dice"];
|
|
const links = linksSource.scan(index) as CompletionsPayload["links"];
|
|
|
|
return {
|
|
dice,
|
|
links,
|
|
sparkTables: blocks.sparkTables,
|
|
stats: blocks.stats,
|
|
statTemplates: blocks.statTemplates,
|
|
statSheets: blocks.statSheets,
|
|
};
|
|
}
|