import { ResourceModule } from "@kiritan/runtime"; //#region ../../node_modules/@types/unist/index.d.ts // ## Interfaces /** * Info associated with nodes by the ecosystem. * * This space is guaranteed to never be specified by unist or specifications * implementing unist. * But you can use it in utilities and plugins to store data. * * This type can be augmented to register custom data. * For example: * * ```ts * declare module 'unist' { * interface Data { * // `someNode.data.myId` is typed as `number | undefined` * myId?: number | undefined * } * } * ``` */ interface Data$1 {} /** * One place in a source file. */ interface Point { /** * Line in a source file (1-indexed integer). */ line: number; /** * Column in a source file (1-indexed integer). */ column: number; /** * Character in a source file (0-indexed integer). */ offset?: number | undefined; } /** * Position of a node in a source document. * * A position is a range between two points. */ interface Position { /** * Place of the first character of the parsed source region. */ start: Point; /** * Place of the first character after the parsed source region. */ end: Point; } /** * Abstract unist node. * * The syntactic unit in unist syntax trees are called nodes. * * This interface is supposed to be extended. * If you can use {@link Literal} or {@link Parent}, you should. * But for example in markdown, a `thematicBreak` (`***`), is neither literal * nor parent, but still a node. */ interface Node$1 { /** * Node type. */ type: string; /** * Info from the ecosystem. */ data?: Data$1 | undefined; /** * Position of a node in a source document. * * Nodes that are generated (not in the original source document) must not * have a position. */ position?: Position | undefined; } //#endregion //#region ../../node_modules/@types/mdast/index.d.ts // ## Enumeration /** * How phrasing content is aligned * ({@link https://drafts.csswg.org/css-text/ | [CSSTEXT]}). * * * `'left'`: See the * {@link https://drafts.csswg.org/css-text/#valdef-text-align-left | left} * value of the `text-align` CSS property * * `'right'`: See the * {@link https://drafts.csswg.org/css-text/#valdef-text-align-right | right} * value of the `text-align` CSS property * * `'center'`: See the * {@link https://drafts.csswg.org/css-text/#valdef-text-align-center | center} * value of the `text-align` CSS property * * `null`: phrasing content is aligned as defined by the host environment * * Used in GFM tables. */ type AlignType = "center" | "left" | "right" | null; /** * Explicitness of a reference. * * `'shortcut'`: the reference is implicit, its identifier inferred from its * content * `'collapsed'`: the reference is explicit, its identifier inferred from its * content * `'full'`: the reference is explicit, its identifier explicitly set */ type ReferenceType = "shortcut" | "collapsed" | "full"; // ## Mixin /** * Node with a fallback. */ interface Alternative { /** * Equivalent content for environments that cannot represent the node as * intended. */ alt?: string | null | undefined; } /** * Internal relation from one node to another. * * Whether the value of `identifier` is expected to be a unique identifier or * not depends on the type of node including the Association. * An example of this is that they should be unique on {@link Definition}, * whereas multiple {@link LinkReference}s can be non-unique to be associated * with one definition. */ interface Association { /** * Relation of association. * * `identifier` is a source value: character escapes and character * references are not parsed. * * It can match another node. * * Its value must be normalized. * To normalize a value, collapse markdown whitespace (`[\t\n\r ]+`) to a space, * trim the optional initial and/or final space, and perform Unicode-aware * case-folding. */ identifier: string; /** * Relation of association, in parsed form. * * `label` is a `string` value: it works just like `title` on {@link Link} * or a `lang` on {@link Code}: character escapes and character references * are parsed. * * It can match another node. */ label?: string | null | undefined; } /** * Marker that is associated to another node. */ interface Reference extends Association { /** * Explicitness of the reference. */ referenceType: ReferenceType; } /** * Reference to resource. */ interface Resource { /** * URL to the referenced resource. */ url: string; /** * Advisory information for the resource, such as would be appropriate for * a tooltip. */ title?: string | null | undefined; } // ## Interfaces /** * Info associated with mdast nodes by the ecosystem. * * This space is guaranteed to never be specified by unist or mdast. * But you can use it in utilities and plugins to store data. * * This type can be augmented to register custom data. * For example: * * ```ts * declare module 'mdast' { * interface Data { * // `someNode.data.myId` is typed as `number | undefined` * myId?: number | undefined * } * } * ``` */ interface Data extends Data$1 {} // ## Content maps /** * Union of registered mdast nodes that can occur where block content is * expected. * * To register custom mdast nodes, add them to {@link BlockContentMap}. * They will be automatically added here. */ type BlockContent = BlockContentMap[keyof BlockContentMap]; /** * Registry of all mdast nodes that can occur where {@link BlockContent} is * expected. * * This interface can be augmented to register custom node types: * * ```ts * declare module 'mdast' { * interface BlockContentMap { * // Allow using MDX ESM nodes defined by `remark-mdx`. * mdxjsEsm: MdxjsEsm; * } * } * ``` * * For a union of all block content, see {@link RootContent}. */ interface BlockContentMap { blockquote: Blockquote; code: Code; heading: Heading; html: Html; list: List; paragraph: Paragraph; table: Table; thematicBreak: ThematicBreak; } /** * Union of registered mdast nodes that can occur where definition content is * expected. * * To register custom mdast nodes, add them to {@link DefinitionContentMap}. * They will be automatically added here. */ type DefinitionContent = DefinitionContentMap[keyof DefinitionContentMap]; /** * Registry of all mdast nodes that can occur where {@link DefinitionContent} * is expected. * * This interface can be augmented to register custom node types: * * ```ts * declare module 'mdast' { * interface DefinitionContentMap { * custom: Custom; * } * } * ``` * * For a union of all definition content, see {@link RootContent}. */ interface DefinitionContentMap { definition: Definition; footnoteDefinition: FootnoteDefinition; } /** * Union of registered mdast nodes that can occur where list content is * expected. * * To register custom mdast nodes, add them to {@link ListContentMap}. * They will be automatically added here. */ type ListContent = ListContentMap[keyof ListContentMap]; /** * Registry of all mdast nodes that can occur where {@link ListContent} * is expected. * * This interface can be augmented to register custom node types: * * ```ts * declare module 'mdast' { * interface ListContentMap { * custom: Custom; * } * } * ``` * * For a union of all list content, see {@link RootContent}. */ interface ListContentMap { listItem: ListItem; } /** * Union of registered mdast nodes that can occur where phrasing content is * expected. * * To register custom mdast nodes, add them to {@link PhrasingContentMap}. * They will be automatically added here. */ type PhrasingContent = PhrasingContentMap[keyof PhrasingContentMap]; /** * Registry of all mdast nodes that can occur where {@link PhrasingContent} * is expected. * * This interface can be augmented to register custom node types: * * ```ts * declare module 'mdast' { * interface PhrasingContentMap { * // Allow using MDX JSX (text) nodes defined by `remark-mdx`. * mdxJsxTextElement: MDXJSXTextElement; * } * } * ``` * * For a union of all phrasing content, see {@link RootContent}. */ interface PhrasingContentMap { break: Break; delete: Delete; emphasis: Emphasis; footnoteReference: FootnoteReference; html: Html; image: Image; imageReference: ImageReference; inlineCode: InlineCode; link: Link; linkReference: LinkReference; strong: Strong; text: Text; } /** * Union of registered mdast nodes that can occur in {@link Root}. * * To register custom mdast nodes, add them to {@link RootContentMap}. * They will be automatically added here. */ type RootContent = RootContentMap[keyof RootContentMap]; /** * Registry of all mdast nodes that can occur as children of {@link Root}. * * > **Note**: {@link Root} does not need to be an entire document. * > it can also be a fragment. * * This interface can be augmented to register custom node types: * * ```ts * declare module 'mdast' { * interface RootContentMap { * // Allow using toml nodes defined by `remark-frontmatter`. * toml: TOML; * } * } * ``` * * For a union of all {@link Root} children, see {@link RootContent}. */ interface RootContentMap { blockquote: Blockquote; break: Break; code: Code; definition: Definition; delete: Delete; emphasis: Emphasis; footnoteDefinition: FootnoteDefinition; footnoteReference: FootnoteReference; heading: Heading; html: Html; image: Image; imageReference: ImageReference; inlineCode: InlineCode; link: Link; linkReference: LinkReference; list: List; listItem: ListItem; paragraph: Paragraph; strong: Strong; table: Table; tableCell: TableCell; tableRow: TableRow; text: Text; thematicBreak: ThematicBreak; yaml: Yaml; } /** * Union of registered mdast nodes that can occur where row content is * expected. * * To register custom mdast nodes, add them to {@link RowContentMap}. * They will be automatically added here. */ type RowContent = RowContentMap[keyof RowContentMap]; /** * Registry of all mdast nodes that can occur where {@link RowContent} * is expected. * * This interface can be augmented to register custom node types: * * ```ts * declare module 'mdast' { * interface RowContentMap { * custom: Custom; * } * } * ``` * * For a union of all row content, see {@link RootContent}. */ interface RowContentMap { tableCell: TableCell; } /** * Union of registered mdast nodes that can occur where table content is * expected. * * To register custom mdast nodes, add them to {@link TableContentMap}. * They will be automatically added here. */ type TableContent = TableContentMap[keyof TableContentMap]; /** * Registry of all mdast nodes that can occur where {@link TableContent} * is expected. * * This interface can be augmented to register custom node types: * * ```ts * declare module 'mdast' { * interface TableContentMap { * custom: Custom; * } * } * ``` * * For a union of all table content, see {@link RootContent}. */ interface TableContentMap { tableRow: TableRow; } // ## Abstract nodes /** * Abstract mdast node that contains the smallest possible value. * * This interface is supposed to be extended if you make custom mdast nodes. * * For a union of all registered mdast literals, see {@link Literals}. */ interface Literal extends Node { /** * Plain-text value. */ value: string; } /** * Abstract mdast node. * * This interface is supposed to be extended. * If you can use {@link Literal} or {@link Parent}, you should. * But for example in markdown, a thematic break (`***`) is neither literal nor * parent, but still a node. * * To register custom mdast nodes, add them to {@link RootContentMap} and other * places where relevant (such as {@link ElementContentMap}). * * For a union of all registered mdast nodes, see {@link Nodes}. */ interface Node extends Node$1 { /** * Info from the ecosystem. */ data?: Data | undefined; } /** * Abstract mdast node that contains other mdast nodes (*children*). * * This interface is supposed to be extended if you make custom mdast nodes. * * For a union of all registered mdast parents, see {@link Parents}. */ interface Parent extends Node { /** * List of children. */ children: RootContent[]; } // ## Concrete nodes /** * Markdown block quote. */ interface Blockquote extends Parent { /** * Node type of mdast block quote. */ type: "blockquote"; /** * Children of block quote. */ children: Array; /** * Data associated with the mdast block quote. */ data?: BlockquoteData | undefined; } /** * Info associated with mdast block quote nodes by the ecosystem. */ interface BlockquoteData extends Data {} /** * Markdown break. */ interface Break extends Node { /** * Node type of mdast break. */ type: "break"; /** * Data associated with the mdast break. */ data?: BreakData | undefined; } /** * Info associated with mdast break nodes by the ecosystem. */ interface BreakData extends Data {} /** * Markdown code (flow) (block). */ interface Code extends Literal { /** * Node type of mdast code (flow). */ type: "code"; /** * Language of computer code being marked up. */ lang?: string | null | undefined; /** * Custom information relating to the node. * * If the lang field is present, a meta field can be present. */ meta?: string | null | undefined; /** * Data associated with the mdast code (flow). */ data?: CodeData | undefined; } /** * Info associated with mdast code (flow) (block) nodes by the ecosystem. */ interface CodeData extends Data {} /** * Markdown definition. */ interface Definition extends Node, Association, Resource { /** * Node type of mdast definition. */ type: "definition"; /** * Data associated with the mdast definition. */ data?: DefinitionData | undefined; } /** * Info associated with mdast definition nodes by the ecosystem. */ interface DefinitionData extends Data {} /** * Markdown GFM delete (strikethrough). */ interface Delete extends Parent { /** * Node type of mdast GFM delete. */ type: "delete"; /** * Children of GFM delete. */ children: PhrasingContent[]; /** * Data associated with the mdast GFM delete. */ data?: DeleteData | undefined; } /** * Info associated with mdast GFM delete nodes by the ecosystem. */ interface DeleteData extends Data {} /** * Markdown emphasis. */ interface Emphasis extends Parent { /** * Node type of mdast emphasis. */ type: "emphasis"; /** * Children of emphasis. */ children: PhrasingContent[]; /** * Data associated with the mdast emphasis. */ data?: EmphasisData | undefined; } /** * Info associated with mdast emphasis nodes by the ecosystem. */ interface EmphasisData extends Data {} /** * Markdown GFM footnote definition. */ interface FootnoteDefinition extends Parent, Association { /** * Node type of mdast GFM footnote definition. */ type: "footnoteDefinition"; /** * Children of GFM footnote definition. */ children: Array; /** * Data associated with the mdast GFM footnote definition. */ data?: FootnoteDefinitionData | undefined; } /** * Info associated with mdast GFM footnote definition nodes by the ecosystem. */ interface FootnoteDefinitionData extends Data {} /** * Markdown GFM footnote reference. */ interface FootnoteReference extends Association, Node { /** * Node type of mdast GFM footnote reference. */ type: "footnoteReference"; /** * Data associated with the mdast GFM footnote reference. */ data?: FootnoteReferenceData | undefined; } /** * Info associated with mdast GFM footnote reference nodes by the ecosystem. */ interface FootnoteReferenceData extends Data {} /** * Markdown heading. */ interface Heading extends Parent { /** * Node type of mdast heading. */ type: "heading"; /** * Heading rank. * * A value of `1` is said to be the highest rank and `6` the lowest. */ depth: 1 | 2 | 3 | 4 | 5 | 6; /** * Children of heading. */ children: PhrasingContent[]; /** * Data associated with the mdast heading. */ data?: HeadingData | undefined; } /** * Info associated with mdast heading nodes by the ecosystem. */ interface HeadingData extends Data {} /** * Markdown HTML. */ interface Html extends Literal { /** * Node type of mdast HTML. */ type: "html"; /** * Data associated with the mdast HTML. */ data?: HtmlData | undefined; } /** * Info associated with mdast HTML nodes by the ecosystem. */ interface HtmlData extends Data {} /** * Markdown image. */ interface Image extends Alternative, Node, Resource { /** * Node type of mdast image. */ type: "image"; /** * Data associated with the mdast image. */ data?: ImageData | undefined; } /** * Info associated with mdast image nodes by the ecosystem. */ interface ImageData extends Data {} /** * Markdown image reference. */ interface ImageReference extends Alternative, Node, Reference { /** * Node type of mdast image reference. */ type: "imageReference"; /** * Data associated with the mdast image reference. */ data?: ImageReferenceData | undefined; } /** * Info associated with mdast image reference nodes by the ecosystem. */ interface ImageReferenceData extends Data {} /** * Markdown code (text) (inline). */ interface InlineCode extends Literal { /** * Node type of mdast code (text). */ type: "inlineCode"; /** * Data associated with the mdast code (text). */ data?: InlineCodeData | undefined; } /** * Info associated with mdast code (text) (inline) nodes by the ecosystem. */ interface InlineCodeData extends Data {} /** * Markdown link. */ interface Link extends Parent, Resource { /** * Node type of mdast link. */ type: "link"; /** * Children of link. */ children: PhrasingContent[]; /** * Data associated with the mdast link. */ data?: LinkData | undefined; } /** * Info associated with mdast link nodes by the ecosystem. */ interface LinkData extends Data {} /** * Markdown link reference. */ interface LinkReference extends Parent, Reference { /** * Node type of mdast link reference. */ type: "linkReference"; /** * Children of link reference. */ children: PhrasingContent[]; /** * Data associated with the mdast link reference. */ data?: LinkReferenceData | undefined; } /** * Info associated with mdast link reference nodes by the ecosystem. */ interface LinkReferenceData extends Data {} /** * Markdown list. */ interface List extends Parent { /** * Node type of mdast list. */ type: "list"; /** * Whether the items have been intentionally ordered (when `true`), or that * the order of items is not important (when `false` or not present). */ ordered?: boolean | null | undefined; /** * The starting number of the list, when the `ordered` field is `true`. */ start?: number | null | undefined; /** * Whether one or more of the children are separated with a blank line from * its siblings (when `true`), or not (when `false` or not present). */ spread?: boolean | null | undefined; /** * Children of list. */ children: ListContent[]; /** * Data associated with the mdast list. */ data?: ListData | undefined; } /** * Info associated with mdast list nodes by the ecosystem. */ interface ListData extends Data {} /** * Markdown list item. */ interface ListItem extends Parent { /** * Node type of mdast list item. */ type: "listItem"; /** * Whether the item is a tasklist item (when `boolean`). * * When `true`, the item is complete. * When `false`, the item is incomplete. */ checked?: boolean | null | undefined; /** * Whether one or more of the children are separated with a blank line from * its siblings (when `true`), or not (when `false` or not present). */ spread?: boolean | null | undefined; /** * Children of list item. */ children: Array; /** * Data associated with the mdast list item. */ data?: ListItemData | undefined; } /** * Info associated with mdast list item nodes by the ecosystem. */ interface ListItemData extends Data {} /** * Markdown paragraph. */ interface Paragraph extends Parent { /** * Node type of mdast paragraph. */ type: "paragraph"; /** * Children of paragraph. */ children: PhrasingContent[]; /** * Data associated with the mdast paragraph. */ data?: ParagraphData | undefined; } /** * Info associated with mdast paragraph nodes by the ecosystem. */ interface ParagraphData extends Data {} /** * Document fragment or a whole document. * * Should be used as the root of a tree and must not be used as a child. */ interface Root extends Parent { /** * Node type of mdast root. */ type: "root"; /** * Data associated with the mdast root. */ data?: RootData | undefined; } /** * Info associated with mdast root nodes by the ecosystem. */ interface RootData extends Data {} /** * Markdown strong. */ interface Strong extends Parent { /** * Node type of mdast strong. */ type: "strong"; /** * Children of strong. */ children: PhrasingContent[]; /** * Data associated with the mdast strong. */ data?: StrongData | undefined; } /** * Info associated with mdast strong nodes by the ecosystem. */ interface StrongData extends Data {} /** * Markdown GFM table. */ interface Table extends Parent { /** * Node type of mdast GFM table. */ type: "table"; /** * How cells in columns are aligned. */ align?: AlignType[] | null | undefined; /** * Children of GFM table. */ children: TableContent[]; /** * Data associated with the mdast GFM table. */ data?: TableData | undefined; } /** * Info associated with mdast GFM table nodes by the ecosystem. */ interface TableData extends Data {} /** * Markdown GFM table row. */ interface TableRow extends Parent { /** * Node type of mdast GFM table row. */ type: "tableRow"; /** * Children of GFM table row. */ children: RowContent[]; /** * Data associated with the mdast GFM table row. */ data?: TableRowData | undefined; } /** * Info associated with mdast GFM table row nodes by the ecosystem. */ interface TableRowData extends Data {} /** * Markdown GFM table cell. */ interface TableCell extends Parent { /** * Node type of mdast GFM table cell. */ type: "tableCell"; /** * Children of GFM table cell. */ children: PhrasingContent[]; /** * Data associated with the mdast GFM table cell. */ data?: TableCellData | undefined; } /** * Info associated with mdast GFM table cell nodes by the ecosystem. */ interface TableCellData extends Data {} /** * Markdown text. */ interface Text extends Literal { /** * Node type of mdast text. */ type: "text"; /** * Data associated with the mdast text. */ data?: TextData | undefined; } /** * Info associated with mdast text nodes by the ecosystem. */ interface TextData extends Data {} /** * Markdown thematic break (horizontal rule). */ interface ThematicBreak extends Node { /** * Node type of mdast thematic break. */ type: "thematicBreak"; /** * Data associated with the mdast thematic break. */ data?: ThematicBreakData | undefined; } /** * Info associated with mdast thematic break nodes by the ecosystem. */ interface ThematicBreakData extends Data {} /** * Markdown YAML. */ interface Yaml extends Literal { /** * Node type of mdast YAML. */ type: "yaml"; /** * Data associated with the mdast YAML. */ data?: YamlData | undefined; } /** * Info associated with mdast YAML nodes by the ecosystem. */ interface YamlData extends Data {} //#endregion //#region src/config/types.d.ts /** * Type contracts from docs/DESIGN.md. */ interface LocalesConfig { default: string; list: string[]; } type NamingPreset = "dot" | "dash" | "prefix" | "folder"; interface NamingConfig { /** Shorthand for a common `template` (docs/DESIGN.md chapter 3.3). */ preset?: NamingPreset; /** Default: "{dir}/{base}.{locale}.{ext}" (overrides `preset` when set). */ template?: string; /** Template used for the default locale only, if it should differ. */ defaultTemplate?: string; /** Default: true. Only applies when `defaultTemplate` is unset. */ omitDefaultLocaleSuffix?: boolean; /** Default: ".base" — how a base file is recognized (e.g. README.base.md). */ baseSuffix?: string; /** Explicit per-locale output path overrides, e.g. `{ ja: "i18n/ja/README.md" }`. */ outputs?: Record; } type OnMissingVariable = "error" | "keep" | "empty"; interface InterpolationConfig { /** Default: ["%{", "}"]. */ delimiters?: [string, string]; variables?: Record> | ((ctx: BuildContext) => Record); /** Default: "error". */ onMissing?: OnMissingVariable; /** Default: true. */ skipCodeBlocks?: boolean; } interface BuildContext { locale: string; defaultLocale: string; } /** docs/DESIGN.md chapter 7. */ interface TranslateContext { text: string; from: string; to: string; source: SourceConfig; segmentId?: string; } type TranslateMiddleware = (ctx: TranslateContext, next: () => Promise) => Promise; interface BatchTranslateMiddleware { batch: true; handle: (ctxs: TranslateContext[], next: () => Promise<(string | null)[]>) => Promise<(string | null)[]>; } interface TranslateConfig { /** Default: []. */ middlewares?: Array; /** Default: false. Auto-translation never runs unless this is true. */ auto?: boolean; } type ResourceStrategy = "colocated" | "split" | "centralized" | "embedded" | string; /** docs/DESIGN.md chapter 9.1. */ interface ResourceSourceConfig { glob: string; strategy: ResourceStrategy; /** Named export to read for the 'embedded' strategy. Default: "i18n". */ exportName?: string; /** Custom namespace override. Not wired into aggregation yet — reserved for `kiritan typegen`. */ namespace?: (filePath: string) => string; } interface RuntimeConfig { sources?: ResourceSourceConfig[]; fallbackLocale?: string; /** * Basename `kiritan typegen` writes its output under (docs/DESIGN.md chapter 9.6). Default: "kiritan.runtime". * Two files are written: ".mjs" (the merged runtime data) and ".d.ts" (its type declaration). */ typegenOutput?: string; } type CheckFailOn = "missing" | "stale" | "machine" | "i18n-key-mismatch"; interface CheckConfig { /** Default: ["missing", "stale", "i18n-key-mismatch"]. */ failOn?: CheckFailOn[]; } type StoreStrategy = "sidecar" | "inline" | "catalog" | string; /** docs/DESIGN.md chapter 4. Not implemented yet — declared for config type-checking. */ interface TranslatedContentFullText { kind: "full-text"; text: string; machine?: boolean; } interface TranslatedContentSegments { kind: "segments"; segments: Record; } type TranslatedContent = TranslatedContentFullText | TranslatedContentSegments; type StoreStatus = "missing" | "partial" | "complete" | "stale"; interface StoreContext { source: SourceConfig; filePath: string; } interface TranslationStore { id: string; read(ctx: StoreContext, locale: string): Promise; write?(ctx: StoreContext, locale: string, content: TranslatedContent): Promise; status(ctx: StoreContext, locale: string): Promise; } /** * docs/DESIGN.md chapter 6. A renderer is one file format's parse/stringify pair over the mdast tree every pipeline stage (directive resolution, interpolation, switcher insertion) already operates on — a non-Markdown format parses into the same `Root` shape, it doesn't get a parallel pipeline. */ interface Renderer { id: string; /** Extensions (lowercase, with the leading dot) this renderer handles when a source doesn't name one via `renderer`. */ extensions?: string[]; /** The built-in strategies (`sidecar`/`inline`/`catalog`) this format can support. A custom `plugins.stores` strategy name isn't checked against this. */ strategies: StoreStrategy[]; /** Whether `:::kiritan{...}` directives and the switcher apply to this format. Default: true. */ supportsDirectives?: boolean; parse(sourceText: string): Root; stringify(tree: Root): string; /** * Wraps text as a comment that's invisible in the rendered output, used for the `kiritan:hash`/`kiritan:untranslated` markers. A format with no such syntax leaves this out, and gets neither marker (so no staleness detection either). */ comment?(text: string): string; } interface SourceConfig { glob: string; strategy: StoreStrategy; /** A renderer id, from `plugins.renderers` or the built-ins. Default: chosen by the file's extension, falling back to `markdown`. */ renderer?: string; /** Overrides the top-level `naming` entirely for this source. */ naming?: NamingConfig; /** Overrides the top-level `translate` entirely for this source. */ translate?: TranslateConfig; /** Overrides the top-level `switcher` entirely for this source. */ switcher?: SwitcherConfig; } interface PluginsConfig { stores?: Record; renderers?: Record; } /** docs/DESIGN.md chapter 6.1. */ interface SwitcherLink { locale: string; label: string; href: string; isCurrent: boolean; } interface SwitcherRenderContext { locale: string; links: SwitcherLink[]; } interface SwitcherConfig { /** Default: true. Only controls automatic insertion when no explicit marker exists. */ enabled?: boolean; /** Default: "after-heading". */ position?: "top" | "after-heading" | "none"; /** Default: " | ". */ separator?: string; /** * Per-locale label overrides. Unset locales fall back to `Intl.DisplayNames`'s autonym (or the locale code itself if that fails). `false` excludes the locale from the switcher entirely. */ labels?: Record; /** Default: false. */ currentLocaleLink?: boolean; /** Fully overrides how the whole line is rendered. */ render?: (ctx: SwitcherRenderContext) => string; } /** Formatting of the Markdown that `kiritan build` writes. */ interface MarkdownConfig { /** * How many trailing spaces to put on the blank continuation lines of GitHub-style alerts (`> [!NOTE]`): `3` writes `>` followed by three spaces instead of a bare `>`. Default: 0 (a bare `>`, which is what the serializer produces and what GitHub itself renders identically). */ alertBlankLineSpaces?: number; } interface KiritanConfig { locales: LocalesConfig; sources: SourceConfig[]; naming?: NamingConfig; interpolation?: InterpolationConfig; translate?: TranslateConfig; runtime?: RuntimeConfig; check?: CheckConfig; switcher?: SwitcherConfig; markdown?: MarkdownConfig; plugins?: PluginsConfig; } /** A `KiritanConfig` as authored: everything except `locales`/`sources` may be omitted. */ type KiritanUserConfig = Partial> & Pick; //#endregion //#region src/config/define-config.d.ts /** Identity helper so `*.kiritanconfig` files get type-checking and IDE completion. */ declare function defineConfig(config: KiritanUserConfig): KiritanUserConfig; //#endregion //#region src/config/locale.d.ts /** * Resolves the locales a command should act on: every configured locale, or just the one requested via `--locale` (docs/DESIGN.md chapter 10). * `build`/`check`/`translate`/`extract` all loop over this instead of `config.locales.list` directly. `kiritan typegen` doesn't use this — it always aggregates every locale into one runtime module, so there's no meaningful way to restrict it to one. */ declare function resolveTargetLocales(config: KiritanConfig, locale: string | undefined): string[]; //#endregion //#region src/config/load.d.ts /** * Resolves the `*.kiritanconfig` cascade for `cwd`/`mode`, lowest priority first: `.kiritanconfig` (base), then `.kiritanconfig` if present, then `local.kiritanconfig`. */ declare function resolveCascadePaths(cwd: string, mode?: string): string[]; /** Loads one `*.kiritanconfig` file's default export (what `defineConfig(...)` returns). */ declare function loadConfigFile(path: string): Promise; /** Fills in the documented defaults (docs/DESIGN.md chapters 3.2/8/9) for whatever a layer left unset. */ declare function applyDefaults(config: KiritanUserConfig): KiritanConfig; interface ResolveConfigOptions { cwd?: string; mode?: string; /** Extra files layered on top, in order (from `--config`/`--overlay`). */ overlays?: string[]; } /** * Discovers and merges the `*.kiritanconfig` cascade for `cwd`/`mode`, applies any * `--config`/`--overlay` files on top, then fills in defaults. */ declare function resolveConfig(options?: ResolveConfigOptions): Promise; //#endregion //#region src/config/merge.d.ts declare const MERGE_ARRAY: unique symbol; interface MergeArrayMarker { [MERGE_ARRAY]: true; values: T[]; } /** * Wraps an array so that, when used as an override in `deepMerge`, it is concatenated onto the base array instead of replacing it (the default). */ declare function mergeArray(values: T[]): MergeArrayMarker; /** * Deep-merges `override` onto `base`. Plain objects are merged key by key; arrays are replaced wholesale unless `override` is wrapped in `mergeArray(...)`, in which case it is concatenated onto the base array. */ declare function deepMerge(base: T, override: unknown): T; /** Merges any number of partial config layers, left to right (later layers win). */ declare function mergeConfigs(...layers: Array | undefined>): Partial; //#endregion //#region src/pipeline/build.d.ts interface BuildOptions { cwd?: string; /** Restricts the build to this locale instead of every locale in `config.locales.list`. */ locale?: string; } interface BuildResult { /** Output paths written, relative to `cwd`. */ written: string[]; } /** One document `build` would write: where, what, and which base file it derives from. */ interface RenderedOutput { /** The base file this was rendered from, relative to `cwd`. */ source: string; locale: string; /** Output path, relative to `cwd`. */ path: string; content: string; } /** Everything up to (not including) the write: discover -> parse -> resolve -> interpolate -> reassemble. `build` writes the result; `verify` compares it against what's on disk. */ declare function renderOutputs(config: KiritanConfig, options?: BuildOptions): Promise; /** `kiritan build` (docs/DESIGN.md chapter 2): render every output, then write it. */ declare function build(config: KiritanConfig, options?: BuildOptions): Promise; //#endregion //#region src/pipeline/check.d.ts type CheckIssueKind = "missing" | "stale" | "machine" | "i18n-key-mismatch"; interface CheckIssue { kind: CheckIssueKind; /** The base file's path, relative to `cwd`. */ source: string; locale: string; detail: string; /** The catalog-strategy segment id this issue is about, if any. */ id?: string; } interface CheckOptions { cwd?: string; /** Restricts the check to this locale instead of every locale in `config.locales.list`. */ locale?: string; } interface CheckResult { issues: CheckIssue[]; /** Whether any issue's kind is in `config.check.failOn` (defaults applied). */ failed: boolean; } /** * The set of `%{name}` variable names `config.interpolation.variables` declares — for the function form, called once with the default locale as a representative context, since variable *names* aren't expected to vary by locale (only their translated values are). Used for undefined-variable detection (editor tooling only; the build pipeline itself resolves values per-locale via `resolveVariables` in pipeline/build.ts). */ declare function resolveInterpolationVariableNames(config: KiritanConfig): string[]; /** * `kiritan check` (docs/DESIGN.md chapter 8): finds missing/stale/machine-translated content across every source, plus `i18n-key-mismatch` for every `runtime.sources` strategy (`colocated`/`split`/`centralized`/`embedded`). * Stale detection compares a hash embedded at translation time (a `` comment for `sidecar`, the catalog entry's `hash` field for `catalog`) against the source's current hash; a file/entry with no hash yet (predating this feature, or hand-authored) is never flagged. * `sidecar` also reports a `machine` issue while a translation still carries its `kiritan:machine` marker comment, and `inline` does for a block still carrying the `machine` attribute; both are signed off by deleting the marker. An `inline` block's `hash` attribute is the hash of the default-locale block it was translated from, and a mismatch is `stale`; a block with no `hash` was written by hand and is never flagged. * A source whose `strategy` matches a `plugins.stores` entry is checked via that store's own `status()` instead (see `checkPluginStore`); one matching neither a built-in strategy nor a registered store throws. */ declare function check(config: KiritanConfig, options?: CheckOptions): Promise; //#endregion //#region src/pipeline/translate.d.ts interface TranslatedEntry { source: string; locale: string; detail: string; } interface TranslateOptions { cwd?: string; /** Restricts translation to this locale instead of every locale in `config.locales.list`. */ locale?: string; } interface TranslateResult { translated: TranslatedEntry[]; /** Sources that have `translate.middlewares` but were skipped because `translate.auto` isn't `true`. */ autoDisabled: string[]; } /** * `kiritan translate` (docs/DESIGN.md chapter 7): fills in missing translations, and re-translates stale ones, via `translate.middlewares`. * A translation only counts as stale once it carries a hash (a `` comment for `sidecar`, the catalog entry's `hash` field for `catalog`) that no longer matches the current source — one written by hand, with no hash yet, is left untouched. * Only runs for sources that actually configure middlewares — the default `middlewares: []` means nothing happens. * `inline` translates into the base file itself (see `translateInline`): new `:::kiritan{locale=...}` blocks are added next to the default-locale one, marked `machine` and carrying its hash. */ declare function translate(config: KiritanConfig, options?: TranslateOptions): Promise; //#endregion //#region src/pipeline/extract.d.ts interface ExtractChange { source: string; locale: string; detail: string; } interface ExtractOptions { cwd?: string; /** Restricts extraction to this locale instead of every locale in `config.locales.list`. */ locale?: string; } interface ExtractResult { changes: ExtractChange[]; } /** * `kiritan extract` (docs/DESIGN.md chapter 4.3): scaffolds each catalog-strategy source's catalog files. * Adds an empty `{ text: "" }` placeholder for every `:::kiritan{#}` not yet in the catalog, ready for a translator to fill in — existing entries (translated or not) are never touched. * Also reports ids present in a catalog file but no longer in the base file, as orphans (left in place; `kiritan check` is what warns about them going forward). */ declare function extract(config: KiritanConfig, options?: ExtractOptions): Promise; //#endregion //#region src/pipeline/typegen.d.ts interface TypegenOptions { cwd?: string; } interface TypegenResult { /** Where the merged runtime data was written, relative to `cwd`. */ dataPath: string; /** Where its type declaration was written, relative to `cwd`. */ typesPath: string; /** How many `"."` entries were written. */ keyCount: number; } /** * `kiritan typegen` (docs/DESIGN.md chapter 9.6): merges every `runtime.sources` entry into one `ResourceModule` keyed by `"."` (the namespace is derived from each file's path, or `ResourceSourceConfig.namespace` when set), then writes it out as a runtime data file plus a `.d.ts` declaring its exact shape. * This is only needed when aggregating multiple files into a single `createT()` call — a directly imported single file already gets full type inference for free (docs/DESIGN.md chapters 9.2/9.5). * If two resources resolve to the same `"."`, the later one (in `runtime.sources` discovery order) silently wins. */ declare function typegen(config: KiritanConfig, options?: TypegenOptions): Promise; //#endregion //#region src/pipeline/init.d.ts interface InitOptions { cwd?: string; /** Overwrite files that already exist instead of leaving them alone. Default: false. */ force?: boolean; } interface InitResult { created: string[]; skipped: string[]; } /** * `kiritan init` (docs/DESIGN.md chapter 10): scaffolds a fresh project's `.kiritanconfig`, `base/README.base.md`, and a `.gitignore` entry for `local.kiritanconfig`. * Every file is left untouched if it already exists, unless `force` is set — this is meant to be safe to run again (e.g. to pick up a newly added scaffold) without clobbering real content. */ declare function init(options?: InitOptions): Promise; //#endregion //#region src/i18n/aggregate.d.ts interface AggregatedResource { /** Identifies one runtime resource: the file path for `colocated`/`embedded`, or the locale-stripped shared path (`groupKey`) for `split`/`centralized`. */ key: string; resource: ResourceModule; /** Files this resource was assembled from, relative to `cwd`. */ files: string[]; /** The source config that produced this resource (the first one, for a `split`/`centralized` group spanning multiple files). */ source: ResourceSourceConfig; } /** * Loads and groups every `runtime.sources` file into per-resource `ResourceModule`s (docs/DESIGN.md chapters 9.1-9.5). * `colocated`/`embedded` files already contain every locale, so each file becomes its own resource. * `split`/`centralized` files hold one locale each, so sibling files (matched via `splitLocaleFromPath`) are merged into one resource. * Files that fail to load, or whose path has no recognizable locale segment (for `split`/`centralized`), are silently skipped. */ declare function aggregateResources(sources: ResourceSourceConfig[], locales: string[], cwd: string): Promise; //#endregion //#region src/renderers/index.d.ts declare const markdownRenderer: Renderer; /** * Picks the renderer for one source file: an explicit `source.renderer` id wins, then an extension match (a `plugins.renderers` entry beats a built-in claiming the same extension), then `markdown` — the only format v1 ever handled, so a file with an unfamiliar extension behaves as it always has. * Throws if the source names an id that isn't registered, or if the chosen renderer can't support the source's built-in `strategy` (a custom `plugins.stores` strategy isn't checked here — its own registration is). */ declare function resolveRenderer(config: KiritanConfig, source: SourceConfig, filePath: string): Renderer; //#endregion //#region src/pipeline/verify.d.ts type VerifyStatus = "ok" | "missing" | "mismatch"; interface VerifyEntry { /** The base file the document is generated from, relative to `cwd`. */ source: string; locale: string; /** The generated document's path, relative to `cwd`. */ path: string; status: VerifyStatus; /** Hash of what `kiritan build` would write today. */ expectedHash: string; /** Hash of what is on disk. Absent when the file is missing. */ actualHash?: string; } interface VerifyOptions { cwd?: string; /** Restricts the check to this locale instead of every locale in `config.locales.list`. */ locale?: string; } interface VerifyResult { entries: VerifyEntry[]; /** Whether any generated document is missing or differs from what `build` would write. */ failed: boolean; } /** * `kiritan verify`: checks that every generated document is exactly what `kiritan build` would write from the current base files and config — i.e. that it's up to date and hasn't been edited by hand. Nothing is written. * Each document is compared by hash (`hashText`, over content with line endings normalized), and both hashes are reported so a mismatch can be told apart at a glance in CI output. * This is a different question from `kiritan check`, which asks whether *translations* are missing or stale: `verify` is about the build output being in sync, whatever produced it. */ declare function verify(config: KiritanConfig, options?: VerifyOptions): Promise; //#endregion export { type AggregatedResource, BatchTranslateMiddleware, BuildContext, type BuildOptions, type BuildResult, CheckConfig, CheckFailOn, type CheckIssue, type CheckIssueKind, type CheckOptions, type CheckResult, type ExtractChange, type ExtractOptions, type ExtractResult, type InitOptions, type InitResult, InterpolationConfig, KiritanConfig, KiritanUserConfig, LocalesConfig, MarkdownConfig, NamingConfig, NamingPreset, OnMissingVariable, PluginsConfig, type RenderedOutput, Renderer, type ResolveConfigOptions, ResourceSourceConfig, ResourceStrategy, RuntimeConfig, SourceConfig, StoreContext, StoreStatus, StoreStrategy, SwitcherConfig, SwitcherLink, SwitcherRenderContext, TranslateConfig, TranslateContext, TranslateMiddleware, type TranslateOptions, type TranslateResult, TranslatedContent, TranslatedContentFullText, TranslatedContentSegments, type TranslatedEntry, TranslationStore, type TypegenOptions, type TypegenResult, type VerifyEntry, type VerifyOptions, type VerifyResult, type VerifyStatus, aggregateResources, applyDefaults, build, check, deepMerge, defineConfig, extract, init, loadConfigFile, markdownRenderer, mergeArray, mergeConfigs, renderOutputs, resolveCascadePaths, resolveConfig, resolveInterpolationVariableNames, resolveRenderer, resolveTargetLocales, translate, typegen, verify };