import { C as CompileSharedType, I as IssueType, a as InkHashtagCommandInfo, H as HashtagCommandOccurrence, L as LikelyUnknownHashtagCommandSchemaIssue, D as DivertOccurrence, S as SchemaValidationIssue, K as KeyedSchemaValidationIssue, b as HashtagKeySchemaIssue } from './types-yAwqys0L.cjs'; export { c as InkValidationInfo } from './types-yAwqys0L.cjs'; import { ValidateFunction } from 'ajv'; import 'inkjs/engine/Error'; declare namespace InkCompiler { function compile(text: string, shared?: Omit): { json: string; issues: IssueType[]; } | { issues: IssueType[]; json?: undefined; }; function getErrors(issues: IssueType[], recompile: () => void, shared: CompileSharedType): void | { issues: IssueType[]; }; /** * Returns all hashtag commands in `source` that are not matched by any * entry in `commands`. * * A command is considered "unknown" when none of the registered * {@link InkHashtagCommandInfo} validations match its token list. * * @param source Raw Ink source text to scan. * @param commands List of known command descriptors (e.g. obtained from * `GET /__pixi-vn-ink/hashtag-commands` or registered * directly in a VS Code extension). * @returns Array of unrecognised {@link HashtagCommandOccurrence} * objects, each carrying the 1-based `line`, the raw * `command` string, and the parsed `tokens`. */ function getUnknownHashtagCommands(source: string, commands: InkHashtagCommandInfo[]): HashtagCommandOccurrence[]; /** * Among every hashtag command {@link getUnknownHashtagCommands} would flag as unrecognized, * finds the ones that are a very likely typo of a registered `"zod"`-validated command instead * of something genuinely unknown — a distraction error (`# shwo image bg` for `# show image * bg`) rather than a deliberately custom command a project registers on its own dev * server/app. Purely additive: it never changes what {@link getUnknownHashtagCommands} itself * reports, only adds a second, more specific diagnostic on top for the subset it's confident * about. * * For each unknown occurrence, every registered command's `"zod"` schema is scored (see * {@link scoreZodArrayBranch}) against the command's tokens; only once the best-scoring branch * clears {@link LIKELY_HASHTAG_MATCH_SCORE_THRESHOLD} is the command actually re-validated * against that one schema with `Ajv2020` (see {@link getZodArrayValidator}) to find the * concrete mismatch(es) to report — a `"regexp"`/`"literal"` validation has no JSON Schema to * validate against and is never a candidate here. * * @param source Raw Ink source text to scan. * @param commands List of known command descriptors (e.g. obtained from * `GET /__pixi-vn-ink/hashtag-commands`). * @returns Array of {@link LikelyUnknownHashtagCommandSchemaIssue}, one per concrete Ajv * mismatch found on the closest-matching command, empty when nothing scores high * enough to be worth reporting. */ function getLikelyUnknownHashtagCommandSchemaIssues(source: string, commands: InkHashtagCommandInfo[]): LikelyUnknownHashtagCommandSchemaIssue[]; /** * Returns all `-> target` diverts in `source` whose target cannot be resolved * locally (knots / stitches defined in the same file) and is not present in * `knownLabels` (labels collected from other ink files or from * `vite-plugin-pixi-vn`). * * Built-in ink targets (`DONE`, `END`) are always considered valid. * * @param source Raw Ink source text to scan. * @param knownLabels Flat list of label ids known at build / dev-server time. * @returns Array of {@link DivertOccurrence} objects, each with the * 1-based `line` and the raw `target` string. Each distinct * target is reported only once. */ function getUnknownDivertTargets(source: string, knownLabels: readonly string[]): DivertOccurrence[]; /** * Compiles a JSON Schema object into a reusable Ajv validator. Fetching the schema (from a * URL, a bundled file, ...) and caching the result across calls is entirely up to the caller * (e.g. `vitePluginInk` fetches by the document's own `$schema` URL and caches per URL; a VS * Code extension might instead cache to disk or bundle a schema offline) — this function only * ever compiles the schema object it's given. * * @param schema JSON Schema object to compile. * @returns A compiled Ajv validator, reusable across many {@link validateAgainstJsonSchema} calls. */ function getSchemaValidator(schema: object): ValidateFunction; /** * Validates a document against a JSON Schema, returning any mismatch as a structured * {@link SchemaValidationIssue} — never throws on a validation mismatch, so a schema drift * never has to block a caller's build/compile step. Mismatches on an exported `PixiVNJson` * payload are expected to mostly land inside `operations` (e.g. a custom hashtag-command * handler returning a slightly malformed operation), so each issue includes the nearest * `$origin` — the original `# ...` ink source line — when one can be traced, to make it * findable. * * Returns plain data rather than logging/warning itself: it's up to the caller (a Vite plugin, * a VS Code extension, ...) to decide how each issue is surfaced (console warning, editor * diagnostic with a squiggly under `element`, ...). * * @param data The document to validate. * @param schema Either a JSON Schema object (compiled on the fly via * {@link getSchemaValidator}) or an already-compiled validator — pass a * precompiled one when validating many documents against the same schema to * avoid recompiling every time. * @returns Array of {@link SchemaValidationIssue}, empty when the document is valid. */ function validateAgainstJsonSchema(data: unknown, schema: object | ValidateFunction): SchemaValidationIssue[]; /** * Splits `tokens` into order-independent ` [ ...]` sections, one per * occurrence of any of `keys`, scanning right to left. * * The right-most occurrence of any known key starts a section running to the end of the * still-unprocessed tail (initially the whole array); the scan then continues to its left for * the next key, and so on, until no more keys are found. Tokens before the left-most matched * key (e.g. a command's own fixed arguments, like `show imagecontainer sly`) are ignored, as * are any tokens between two matched keys that aren't themselves a key (they belong to the * section of the key to their left). * * @example * `extractKeyedSections(["show","imagecontainer","sly","props","xAlign","0.2","yAlign","1","movein","direction","right","ease","anticipate"], ["props","movein"])` * returns `[{ key: "props", sectionTokens: ["xAlign","0.2","yAlign","1"] }, { key: "movein", sectionTokens: ["direction","right","ease","anticipate"] }]`. * * @param tokens Full token list to scan (e.g. the output of `convertTagTolist`). * @param keys The keys to look for (typically `Object.keys(keySchemas)`). An element that is * a number, or a string containing only digits (object keys are always strings * at runtime, so `3` and `"3"` are equivalent here), is treated as a *numeric* * key instead of a literal token — see the numeric-key pass below. * @returns One entry per matched key, in left-to-right (original) order — numeric-key sections * first (they only ever occur in the prefix left over after every string key has been * matched), then string-key sections. `sectionTokens` is the (possibly empty) slice of * tokens belonging to that key. * * Numeric keys are resolved by **position**, in a second pass that runs only after every string * key has already claimed its section above. Counting starts at `0` for `tokens[0]` (e.g. the * command's own leading literal, like `"show"`). Numeric keys are processed largest to * smallest, each bounded by `end` — the left edge of whatever the previous match (string or * numeric) already claimed, starting from the left-most string-key match (or `tokens.length` if * none matched): key `N` claims `tokens.slice(N, end)` as its section, then `end` becomes * `N - 1` — dropping `tokens[N - 1]` (e.g. a dynamic alias no literal key could match) along * with it, so the next, smaller numeric key resumes scanning to its left. A numeric key outside * the current `[0, end)` bound (e.g. it collides with an already-claimed region) is skipped. * * @example * For `["show","spine","flowerTop","x","220","y","20","with","dissolve","duration","2"]` with * keys `["with", "dissolve", 3]`: the string-key pass matches `"dissolve"` (section * `["duration","2"]`) then `"with"` (empty section), leaving `end = 7`. The numeric pass then * matches key `3`: section = `tokens.slice(3, 7)` = `["x","220","y","20"]`, and drops * `tokens[2]` (`"flowerTop"`) too. */ function extractKeyedSections(tokens: readonly string[], keys: readonly (string | number)[]): { key: string | number; sectionTokens: string[]; }[]; /** * Validates the order-independent keyed sections of a command's token list (see * {@link extractKeyedSections}) against their JSON Schemas. * * Each section's tokens are converted to an object with the same ` ` pairing logic * as `HashtagCommands.convertListStringToObj`, then validated with * {@link validateAgainstJsonSchema}. A section that can't be paired into ` ` (an * odd number of tokens, or a malformed value) is reported as its own issue instead of throwing. * * @param tokens Full token list to scan (e.g. the output of `convertTagTolist`). * @param keySchemas JSON Schemas keyed by the token that introduces each section — see * `HashtagHandlerOptions.keySchemas`. * @returns One {@link KeyedSchemaValidationIssue} per mismatch, empty when every section is * valid (including when no key is found at all). */ function validateKeyedJsonSchemas(tokens: readonly string[], keySchemas: Record): KeyedSchemaValidationIssue[]; /** * Returns every {@link HashtagKeySchemaIssue} found while scanning `source`'s hashtag * commands: for each command that matches a registered {@link InkHashtagCommandInfo} with a * `keySchemas`, its keyed sections (see {@link extractKeyedSections}) are validated against * that command's schemas. * * Unlike {@link getUnknownHashtagCommands} (which flags a command matching *no* registered * validation), this only runs on commands that already matched one — it is purely additive and * doesn't affect unknown-command detection. A command with no matching entry, or a matching * entry with no `keySchemas`, is simply skipped. * * @param source Raw Ink source text to scan. * @param commands List of known command descriptors (e.g. obtained from * `GET /__pixi-vn-ink/hashtag-commands`). * @returns Array of {@link HashtagKeySchemaIssue}, empty when every keyed section validates. */ function getHashtagKeySchemaIssues(source: string, commands: InkHashtagCommandInfo[]): HashtagKeySchemaIssue[]; } export { DivertOccurrence, HashtagCommandOccurrence, HashtagKeySchemaIssue, InkCompiler, InkHashtagCommandInfo, KeyedSchemaValidationIssue, LikelyUnknownHashtagCommandSchemaIssue, SchemaValidationIssue };