@drincs/pixi-vn-ink 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/parser.d.cts CHANGED
@@ -1,5 +1,6 @@
1
- import { C as CompileSharedType, I as IssueType, a as InkHashtagCommandInfo, H as HashtagCommandOccurrence, D as DivertOccurrence } from './types-B7f5EzP5.cjs';
2
- export { b as InkValidationInfo } from './types-B7f5EzP5.cjs';
1
+ import { C as CompileSharedType, I as IssueType, a as InkHashtagCommandInfo, H as HashtagCommandOccurrence, D as DivertOccurrence, S as SchemaValidationIssue } from './types-C31N1m1a.cjs';
2
+ export { b as InkValidationInfo } from './types-C31N1m1a.cjs';
3
+ import { ValidateFunction } from 'ajv';
3
4
  import 'inkjs/engine/Error';
4
5
 
5
6
  declare namespace InkCompiler {
@@ -44,6 +45,38 @@ declare namespace InkCompiler {
44
45
  * target is reported only once.
45
46
  */
46
47
  function getUnknownDivertTargets(source: string, knownLabels: readonly string[]): DivertOccurrence[];
48
+ /**
49
+ * Compiles a JSON Schema object into a reusable Ajv validator. Fetching the schema (from a
50
+ * URL, a bundled file, ...) and caching the result across calls is entirely up to the caller
51
+ * (e.g. `vitePluginInk` fetches by the document's own `$schema` URL and caches per URL; a VS
52
+ * Code extension might instead cache to disk or bundle a schema offline) — this function only
53
+ * ever compiles the schema object it's given.
54
+ *
55
+ * @param schema JSON Schema object to compile.
56
+ * @returns A compiled Ajv validator, reusable across many {@link validateAgainstJsonSchema} calls.
57
+ */
58
+ function getSchemaValidator(schema: object): ValidateFunction;
59
+ /**
60
+ * Validates a document against a JSON Schema, returning any mismatch as a structured
61
+ * {@link SchemaValidationIssue} — never throws on a validation mismatch, so a schema drift
62
+ * never has to block a caller's build/compile step. Mismatches on an exported `PixiVNJson`
63
+ * payload are expected to mostly land inside `operations` (e.g. a custom hashtag-command
64
+ * handler returning a slightly malformed operation), so each issue includes the nearest
65
+ * `$origin` — the original `# ...` ink source line — when one can be traced, to make it
66
+ * findable.
67
+ *
68
+ * Returns plain data rather than logging/warning itself: it's up to the caller (a Vite plugin,
69
+ * a VS Code extension, ...) to decide how each issue is surfaced (console warning, editor
70
+ * diagnostic with a squiggly under `element`, ...).
71
+ *
72
+ * @param data The document to validate.
73
+ * @param schema Either a JSON Schema object (compiled on the fly via
74
+ * {@link getSchemaValidator}) or an already-compiled validator — pass a
75
+ * precompiled one when validating many documents against the same schema to
76
+ * avoid recompiling every time.
77
+ * @returns Array of {@link SchemaValidationIssue}, empty when the document is valid.
78
+ */
79
+ function validateAgainstJsonSchema(data: unknown, schema: object | ValidateFunction): SchemaValidationIssue[];
47
80
  }
48
81
 
49
- export { DivertOccurrence, HashtagCommandOccurrence, InkCompiler, InkHashtagCommandInfo };
82
+ export { DivertOccurrence, HashtagCommandOccurrence, InkCompiler, InkHashtagCommandInfo, SchemaValidationIssue };
package/dist/parser.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { C as CompileSharedType, I as IssueType, a as InkHashtagCommandInfo, H as HashtagCommandOccurrence, D as DivertOccurrence } from './types-B7f5EzP5.js';
2
- export { b as InkValidationInfo } from './types-B7f5EzP5.js';
1
+ import { C as CompileSharedType, I as IssueType, a as InkHashtagCommandInfo, H as HashtagCommandOccurrence, D as DivertOccurrence, S as SchemaValidationIssue } from './types-C31N1m1a.js';
2
+ export { b as InkValidationInfo } from './types-C31N1m1a.js';
3
+ import { ValidateFunction } from 'ajv';
3
4
  import 'inkjs/engine/Error';
4
5
 
5
6
  declare namespace InkCompiler {
@@ -44,6 +45,38 @@ declare namespace InkCompiler {
44
45
  * target is reported only once.
45
46
  */
46
47
  function getUnknownDivertTargets(source: string, knownLabels: readonly string[]): DivertOccurrence[];
48
+ /**
49
+ * Compiles a JSON Schema object into a reusable Ajv validator. Fetching the schema (from a
50
+ * URL, a bundled file, ...) and caching the result across calls is entirely up to the caller
51
+ * (e.g. `vitePluginInk` fetches by the document's own `$schema` URL and caches per URL; a VS
52
+ * Code extension might instead cache to disk or bundle a schema offline) — this function only
53
+ * ever compiles the schema object it's given.
54
+ *
55
+ * @param schema JSON Schema object to compile.
56
+ * @returns A compiled Ajv validator, reusable across many {@link validateAgainstJsonSchema} calls.
57
+ */
58
+ function getSchemaValidator(schema: object): ValidateFunction;
59
+ /**
60
+ * Validates a document against a JSON Schema, returning any mismatch as a structured
61
+ * {@link SchemaValidationIssue} — never throws on a validation mismatch, so a schema drift
62
+ * never has to block a caller's build/compile step. Mismatches on an exported `PixiVNJson`
63
+ * payload are expected to mostly land inside `operations` (e.g. a custom hashtag-command
64
+ * handler returning a slightly malformed operation), so each issue includes the nearest
65
+ * `$origin` — the original `# ...` ink source line — when one can be traced, to make it
66
+ * findable.
67
+ *
68
+ * Returns plain data rather than logging/warning itself: it's up to the caller (a Vite plugin,
69
+ * a VS Code extension, ...) to decide how each issue is surfaced (console warning, editor
70
+ * diagnostic with a squiggly under `element`, ...).
71
+ *
72
+ * @param data The document to validate.
73
+ * @param schema Either a JSON Schema object (compiled on the fly via
74
+ * {@link getSchemaValidator}) or an already-compiled validator — pass a
75
+ * precompiled one when validating many documents against the same schema to
76
+ * avoid recompiling every time.
77
+ * @returns Array of {@link SchemaValidationIssue}, empty when the document is valid.
78
+ */
79
+ function validateAgainstJsonSchema(data: unknown, schema: object | ValidateFunction): SchemaValidationIssue[];
47
80
  }
48
81
 
49
- export { DivertOccurrence, HashtagCommandOccurrence, InkCompiler, InkHashtagCommandInfo };
82
+ export { DivertOccurrence, HashtagCommandOccurrence, InkCompiler, InkHashtagCommandInfo, SchemaValidationIssue };