@bestagentkits/render 0.1.0

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.
Files changed (140) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +21 -0
  3. package/README.md +166 -0
  4. package/dist/cli.d.ts +18 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +336 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/diagnostics.d.ts +45 -0
  9. package/dist/diagnostics.d.ts.map +1 -0
  10. package/dist/diagnostics.js +57 -0
  11. package/dist/diagnostics.js.map +1 -0
  12. package/dist/diagram/adapter.d.ts +71 -0
  13. package/dist/diagram/adapter.d.ts.map +1 -0
  14. package/dist/diagram/adapter.js +87 -0
  15. package/dist/diagram/adapter.js.map +1 -0
  16. package/dist/errors.d.ts +37 -0
  17. package/dist/errors.d.ts.map +1 -0
  18. package/dist/errors.js +42 -0
  19. package/dist/errors.js.map +1 -0
  20. package/dist/hash.d.ts +14 -0
  21. package/dist/hash.d.ts.map +1 -0
  22. package/dist/hash.js +27 -0
  23. package/dist/hash.js.map +1 -0
  24. package/dist/index.d.ts +43 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +25 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/internal/yaml-error.d.ts +14 -0
  29. package/dist/internal/yaml-error.d.ts.map +1 -0
  30. package/dist/internal/yaml-error.js +12 -0
  31. package/dist/internal/yaml-error.js.map +1 -0
  32. package/dist/ir.d.ts +77 -0
  33. package/dist/ir.d.ts.map +1 -0
  34. package/dist/ir.js +20 -0
  35. package/dist/ir.js.map +1 -0
  36. package/dist/json.d.ts +23 -0
  37. package/dist/json.d.ts.map +1 -0
  38. package/dist/json.js +47 -0
  39. package/dist/json.js.map +1 -0
  40. package/dist/registry/actions.d.ts +48 -0
  41. package/dist/registry/actions.d.ts.map +1 -0
  42. package/dist/registry/actions.js +274 -0
  43. package/dist/registry/actions.js.map +1 -0
  44. package/dist/registry/prop-schema.d.ts +108 -0
  45. package/dist/registry/prop-schema.d.ts.map +1 -0
  46. package/dist/registry/prop-schema.js +400 -0
  47. package/dist/registry/prop-schema.js.map +1 -0
  48. package/dist/registry/registry.d.ts +47 -0
  49. package/dist/registry/registry.d.ts.map +1 -0
  50. package/dist/registry/registry.js +201 -0
  51. package/dist/registry/registry.js.map +1 -0
  52. package/dist/registry/roster.d.ts +53 -0
  53. package/dist/registry/roster.d.ts.map +1 -0
  54. package/dist/registry/roster.js +692 -0
  55. package/dist/registry/roster.js.map +1 -0
  56. package/dist/render/blocks.d.ts +41 -0
  57. package/dist/render/blocks.d.ts.map +1 -0
  58. package/dist/render/blocks.js +749 -0
  59. package/dist/render/blocks.js.map +1 -0
  60. package/dist/render/charts.d.ts +29 -0
  61. package/dist/render/charts.d.ts.map +1 -0
  62. package/dist/render/charts.js +235 -0
  63. package/dist/render/charts.js.map +1 -0
  64. package/dist/render/document.d.ts +40 -0
  65. package/dist/render/document.d.ts.map +1 -0
  66. package/dist/render/document.js +90 -0
  67. package/dist/render/document.js.map +1 -0
  68. package/dist/render/escape.d.ts +46 -0
  69. package/dist/render/escape.d.ts.map +1 -0
  70. package/dist/render/escape.js +108 -0
  71. package/dist/render/escape.js.map +1 -0
  72. package/dist/render/render.d.ts +52 -0
  73. package/dist/render/render.d.ts.map +1 -0
  74. package/dist/render/render.js +216 -0
  75. package/dist/render/render.js.map +1 -0
  76. package/dist/render/runtime.d.ts +25 -0
  77. package/dist/render/runtime.d.ts.map +1 -0
  78. package/dist/render/runtime.js +451 -0
  79. package/dist/render/runtime.js.map +1 -0
  80. package/dist/render/styles.d.ts +15 -0
  81. package/dist/render/styles.d.ts.map +1 -0
  82. package/dist/render/styles.js +163 -0
  83. package/dist/render/styles.js.map +1 -0
  84. package/dist/render/verify.d.ts +25 -0
  85. package/dist/render/verify.d.ts.map +1 -0
  86. package/dist/render/verify.js +168 -0
  87. package/dist/render/verify.js.map +1 -0
  88. package/dist/spec/bindings.d.ts +19 -0
  89. package/dist/spec/bindings.d.ts.map +1 -0
  90. package/dist/spec/bindings.js +51 -0
  91. package/dist/spec/bindings.js.map +1 -0
  92. package/dist/spec/bounds.d.ts +43 -0
  93. package/dist/spec/bounds.d.ts.map +1 -0
  94. package/dist/spec/bounds.js +144 -0
  95. package/dist/spec/bounds.js.map +1 -0
  96. package/dist/spec/forbidden.d.ts +27 -0
  97. package/dist/spec/forbidden.d.ts.map +1 -0
  98. package/dist/spec/forbidden.js +91 -0
  99. package/dist/spec/forbidden.js.map +1 -0
  100. package/dist/spec/migrate.d.ts +33 -0
  101. package/dist/spec/migrate.d.ts.map +1 -0
  102. package/dist/spec/migrate.js +113 -0
  103. package/dist/spec/migrate.js.map +1 -0
  104. package/dist/spec/normalize.d.ts +29 -0
  105. package/dist/spec/normalize.d.ts.map +1 -0
  106. package/dist/spec/normalize.js +649 -0
  107. package/dist/spec/normalize.js.map +1 -0
  108. package/dist/spec/parse.d.ts +22 -0
  109. package/dist/spec/parse.d.ts.map +1 -0
  110. package/dist/spec/parse.js +62 -0
  111. package/dist/spec/parse.js.map +1 -0
  112. package/dist/spec/providers.d.ts +30 -0
  113. package/dist/spec/providers.d.ts.map +1 -0
  114. package/dist/spec/providers.js +64 -0
  115. package/dist/spec/providers.js.map +1 -0
  116. package/dist/spec/validate.d.ts +28 -0
  117. package/dist/spec/validate.d.ts.map +1 -0
  118. package/dist/spec/validate.js +68 -0
  119. package/dist/spec/validate.js.map +1 -0
  120. package/dist/theme/load-theme.d.ts +55 -0
  121. package/dist/theme/load-theme.d.ts.map +1 -0
  122. package/dist/theme/load-theme.js +219 -0
  123. package/dist/theme/load-theme.js.map +1 -0
  124. package/dist/theme/presets.d.ts +50 -0
  125. package/dist/theme/presets.d.ts.map +1 -0
  126. package/dist/theme/presets.js +304 -0
  127. package/dist/theme/presets.js.map +1 -0
  128. package/dist/theme/theme-catalog.d.ts +68 -0
  129. package/dist/theme/theme-catalog.d.ts.map +1 -0
  130. package/dist/theme/theme-catalog.js +198 -0
  131. package/dist/theme/theme-catalog.js.map +1 -0
  132. package/dist/theme/tokens.d.ts +38 -0
  133. package/dist/theme/tokens.d.ts.map +1 -0
  134. package/dist/theme/tokens.js +190 -0
  135. package/dist/theme/tokens.js.map +1 -0
  136. package/dist/version.d.ts +12 -0
  137. package/dist/version.d.ts.map +1 -0
  138. package/dist/version.js +12 -0
  139. package/dist/version.js.map +1 -0
  140. package/package.json +80 -0
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Diagnostics: how the compiler reports everything it found wrong.
3
+ *
4
+ * A diagnostic always carries a JSON path into the author-facing spec, and a
5
+ * node ID when the failure belongs to a node that already has one. Callers
6
+ * branch on `code`; `message` is for humans and may be reworded between
7
+ * releases.
8
+ */
9
+ /** Ordered, de-duplicating collector for diagnostics. */
10
+ export class DiagnosticBag {
11
+ items = [];
12
+ seen = new Set();
13
+ add(input) {
14
+ const key = `${input.code}|${input.path}|${input.message}`;
15
+ if (this.seen.has(key))
16
+ return;
17
+ this.seen.add(key);
18
+ const diagnostic = {
19
+ code: input.code,
20
+ severity: input.severity ?? 'error',
21
+ message: input.message,
22
+ path: input.path,
23
+ };
24
+ if (input.nodeId !== undefined)
25
+ diagnostic.nodeId = input.nodeId;
26
+ if (input.details !== undefined)
27
+ diagnostic.details = input.details;
28
+ this.items.push(diagnostic);
29
+ }
30
+ get size() {
31
+ return this.items.length;
32
+ }
33
+ get errorCount() {
34
+ return this.items.filter((item) => item.severity === 'error').length;
35
+ }
36
+ get hasErrors() {
37
+ return this.errorCount > 0;
38
+ }
39
+ list() {
40
+ return [...this.items];
41
+ }
42
+ errors() {
43
+ return this.items.filter((item) => item.severity === 'error');
44
+ }
45
+ warnings() {
46
+ return this.items.filter((item) => item.severity === 'warning');
47
+ }
48
+ }
49
+ /** Append an index or key to a JSON path. */
50
+ export function pathKey(base, key) {
51
+ return base === '' ? key : `${base}.${key}`;
52
+ }
53
+ /** Append an array index to a JSON path. */
54
+ export function pathIndex(base, index) {
55
+ return `${base}[${index}]`;
56
+ }
57
+ //# sourceMappingURL=diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA0BH,yDAAyD;AACzD,MAAM,OAAO,aAAa;IACP,KAAK,GAAiB,EAAE,CAAC;IACzB,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE1C,GAAG,CAAC,KAAsB;QACxB,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAC3D,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO;QAC/B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnB,MAAM,UAAU,GAAe;YAC7B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,OAAO;YACnC,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC;QACF,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;YAAE,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QACjE,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;YAAE,UAAU,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QACpE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,MAAM,CAAC;IACvE,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI;QACF,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;IAChE,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;IAClE,CAAC;CACF;AAED,6CAA6C;AAC7C,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,GAAW;IAC/C,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC;AAC9C,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,OAAO,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The diagram adapter boundary.
3
+ *
4
+ * AK Render does not implement diagram layout. A host that owns a typed diagram
5
+ * compiler — AgentKit's Engineer installs provide `ak:diagram` — registers an
6
+ * adapter, and the compiler embeds that adapter's output inside the
7
+ * `diagram-panel` block. Everything else keeps the structured semantic fallback.
8
+ *
9
+ * The boundary is deliberately narrow:
10
+ *
11
+ * - The adapter receives the bounded, structurally-opaque diagram spec from the
12
+ * Page Spec plus its title. It never receives the page, the theme, or the
13
+ * surrounding markup, so it cannot influence anything outside its own figure.
14
+ * - Whatever the adapter returns is re-checked here. Output that could execute,
15
+ * navigate, or frame is rejected and the semantic fallback is emitted instead,
16
+ * with a diagnostic. An adapter is trusted code, but "trusted" still means
17
+ * "verified before it reaches the artifact".
18
+ * - The fallback text is always emitted, so the diagram's content is available
19
+ * to assistive technology and to a reader whose adapter is not installed.
20
+ */
21
+ import type { JsonValue } from '../json.js';
22
+ export interface DiagramRenderRequest {
23
+ /** The diagram spec exactly as authored, bounded by the Page Spec limits. */
24
+ readonly spec: JsonValue;
25
+ /** Title from the diagram spec meta or the block, when either declares one. */
26
+ readonly title: string;
27
+ /** Stable node id of the owning block, usable for adapter-side cache keys. */
28
+ readonly nodeId: string;
29
+ /** Version of the adapter contract this request was built against. */
30
+ readonly contractVersion: 1;
31
+ }
32
+ export interface DiagramAdapter {
33
+ /** Stable adapter name, reported in diagnostics. */
34
+ readonly name: string;
35
+ /** Adapter version, reported in diagnostics. */
36
+ readonly version: string;
37
+ /**
38
+ * Return trusted markup (an SVG fragment) for the request, or `undefined` to
39
+ * fall back. Throwing is treated exactly like returning `undefined`: a broken
40
+ * adapter degrades the page instead of failing the compile.
41
+ */
42
+ render(request: DiagramRenderRequest): string | undefined;
43
+ }
44
+ export interface DiagramAdapterResult {
45
+ readonly markup: string;
46
+ readonly adapter: string;
47
+ /** Set when the adapter produced output that the trust boundary rejected. */
48
+ readonly rejected?: string;
49
+ }
50
+ export declare const DIAGRAM_ADAPTER_CONTRACT_VERSION: 1;
51
+ /** Bound on adapter output, so a runaway adapter cannot inflate the artifact. */
52
+ export declare const MAX_DIAGRAM_MARKUP_BYTES: number;
53
+ export interface AdapterMarkupCheck {
54
+ readonly ok: boolean;
55
+ readonly reason?: string;
56
+ }
57
+ /**
58
+ * Verify adapter output before it is embedded.
59
+ *
60
+ * Exported so a host can assert the same contract in its own adapter tests, and
61
+ * so the check has one implementation rather than one per call site.
62
+ */
63
+ export declare function checkAdapterMarkup(markup: string): AdapterMarkupCheck;
64
+ /**
65
+ * Run an adapter and return markup that has passed the trust boundary.
66
+ *
67
+ * A `rejected` reason means the adapter answered but its answer was refused; the
68
+ * caller emits the semantic fallback and records a warning either way.
69
+ */
70
+ export declare function runDiagramAdapter(adapter: DiagramAdapter | undefined, request: Omit<DiagramRenderRequest, 'contractVersion'>): DiagramAdapterResult | undefined;
71
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/diagram/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,QAAQ,CAAC,eAAe,EAAE,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,GAAG,SAAS,CAAC;CAC3D;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,gCAAgC,EAAG,CAAU,CAAC;AAE3D,iFAAiF;AACjF,eAAO,MAAM,wBAAwB,QAAa,CAAC;AAuBnD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAWrE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,GACrD,oBAAoB,GAAG,SAAS,CAclC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * The diagram adapter boundary.
3
+ *
4
+ * AK Render does not implement diagram layout. A host that owns a typed diagram
5
+ * compiler — AgentKit's Engineer installs provide `ak:diagram` — registers an
6
+ * adapter, and the compiler embeds that adapter's output inside the
7
+ * `diagram-panel` block. Everything else keeps the structured semantic fallback.
8
+ *
9
+ * The boundary is deliberately narrow:
10
+ *
11
+ * - The adapter receives the bounded, structurally-opaque diagram spec from the
12
+ * Page Spec plus its title. It never receives the page, the theme, or the
13
+ * surrounding markup, so it cannot influence anything outside its own figure.
14
+ * - Whatever the adapter returns is re-checked here. Output that could execute,
15
+ * navigate, or frame is rejected and the semantic fallback is emitted instead,
16
+ * with a diagnostic. An adapter is trusted code, but "trusted" still means
17
+ * "verified before it reaches the artifact".
18
+ * - The fallback text is always emitted, so the diagram's content is available
19
+ * to assistive technology and to a reader whose adapter is not installed.
20
+ */
21
+ export const DIAGRAM_ADAPTER_CONTRACT_VERSION = 1;
22
+ /** Bound on adapter output, so a runaway adapter cannot inflate the artifact. */
23
+ export const MAX_DIAGRAM_MARKUP_BYTES = 256 * 1024;
24
+ /**
25
+ * Vectors that must never appear in adapter output.
26
+ *
27
+ * This is the same posture the page itself takes: no script, no frame, no
28
+ * plugin, no inline handler, no navigable scheme, and no SVG escape hatch back
29
+ * into HTML.
30
+ */
31
+ const FORBIDDEN_ADAPTER_PATTERNS = [
32
+ { pattern: /<script/iu, reason: 'script element' },
33
+ { pattern: /<iframe/iu, reason: 'iframe element' },
34
+ { pattern: /<object/iu, reason: 'object element' },
35
+ { pattern: /<embed/iu, reason: 'embed element' },
36
+ { pattern: /<foreignObject/iu, reason: 'foreignObject element' },
37
+ { pattern: /<base/iu, reason: 'base element' },
38
+ { pattern: /<form/iu, reason: 'form element' },
39
+ { pattern: /\bsrcdoc\s*=/iu, reason: 'srcdoc attribute' },
40
+ { pattern: /\son[a-z]+\s*=/iu, reason: 'inline event handler' },
41
+ { pattern: /javascript\s*:/iu, reason: 'javascript: URL' },
42
+ { pattern: /\bdata\s*:\s*text\/html/iu, reason: 'data: text/html URL' },
43
+ ];
44
+ /**
45
+ * Verify adapter output before it is embedded.
46
+ *
47
+ * Exported so a host can assert the same contract in its own adapter tests, and
48
+ * so the check has one implementation rather than one per call site.
49
+ */
50
+ export function checkAdapterMarkup(markup) {
51
+ if (typeof markup !== 'string' || markup.trim() === '') {
52
+ return { ok: false, reason: 'empty output' };
53
+ }
54
+ if (markup.length > MAX_DIAGRAM_MARKUP_BYTES) {
55
+ return { ok: false, reason: `output exceeds ${MAX_DIAGRAM_MARKUP_BYTES} bytes` };
56
+ }
57
+ for (const { pattern, reason } of FORBIDDEN_ADAPTER_PATTERNS) {
58
+ if (pattern.test(markup))
59
+ return { ok: false, reason };
60
+ }
61
+ return { ok: true };
62
+ }
63
+ /**
64
+ * Run an adapter and return markup that has passed the trust boundary.
65
+ *
66
+ * A `rejected` reason means the adapter answered but its answer was refused; the
67
+ * caller emits the semantic fallback and records a warning either way.
68
+ */
69
+ export function runDiagramAdapter(adapter, request) {
70
+ if (adapter === undefined)
71
+ return undefined;
72
+ let markup;
73
+ try {
74
+ markup = adapter.render({ ...request, contractVersion: DIAGRAM_ADAPTER_CONTRACT_VERSION });
75
+ }
76
+ catch {
77
+ return { markup: '', adapter: adapter.name, rejected: 'adapter threw' };
78
+ }
79
+ if (markup === undefined)
80
+ return undefined;
81
+ const check = checkAdapterMarkup(markup);
82
+ if (!check.ok) {
83
+ return { markup: '', adapter: adapter.name, rejected: check.reason ?? 'rejected' };
84
+ }
85
+ return { markup, adapter: adapter.name };
86
+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AC,IAAI,EAAE,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Stable error surface for the compiler.
3
+ *
4
+ * Every failure an author can trigger is reported as a `RenderError` with a
5
+ * machine-readable `code` and, where the failure belongs to a spec location,
6
+ * a JSON path and normalized node ID. Callers (CLI, worker, skills) branch on
7
+ * `code`; they must not parse message text.
8
+ */
9
+ export type RenderErrorCode = 'SPEC_PARSE_ERROR' | 'SPEC_VALIDATION_ERROR' | 'SPEC_BOUNDS_ERROR' | 'SPEC_UNKNOWN_BLOCK' | 'POLICY_VIOLATION' | 'INTERNAL_ERROR';
10
+ export interface RenderErrorOptions {
11
+ /** JSON path of the offending value, e.g. `blocks[2].items[0].url`. */
12
+ path?: string | undefined;
13
+ /** Normalized node ID when the failure is attached to a node. */
14
+ nodeId?: string | undefined;
15
+ /** Non-sensitive structured detail for logs and JSON output. */
16
+ details?: Record<string, unknown> | undefined;
17
+ cause?: unknown;
18
+ }
19
+ export declare class RenderError extends Error {
20
+ readonly code: RenderErrorCode;
21
+ readonly path: string | undefined;
22
+ readonly nodeId: string | undefined;
23
+ readonly details: Record<string, unknown> | undefined;
24
+ constructor(code: RenderErrorCode, message: string, options?: RenderErrorOptions);
25
+ /** JSON-safe representation used by `--json` CLI output and the cloud API. */
26
+ toJSON(): {
27
+ name: string;
28
+ code: RenderErrorCode;
29
+ message: string;
30
+ path?: string;
31
+ nodeId?: string;
32
+ details?: Record<string, unknown>;
33
+ };
34
+ }
35
+ /** Narrow an unknown thrown value to a `RenderError`. */
36
+ export declare function isRenderError(value: unknown): value is RenderError;
37
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,eAAe,GACvB,kBAAkB,GAClB,uBAAuB,GACvB,mBAAmB,GACnB,oBAAoB,GACpB,kBAAkB,GAClB,gBAAgB,CAAC;AAErB,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;gBAE1C,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB;IASpF,8EAA8E;IAC9E,MAAM,IAAI;QACR,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,eAAe,CAAC;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC;CAWF;AAED,yDAAyD;AACzD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE"}
package/dist/errors.js ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Stable error surface for the compiler.
3
+ *
4
+ * Every failure an author can trigger is reported as a `RenderError` with a
5
+ * machine-readable `code` and, where the failure belongs to a spec location,
6
+ * a JSON path and normalized node ID. Callers (CLI, worker, skills) branch on
7
+ * `code`; they must not parse message text.
8
+ */
9
+ export class RenderError extends Error {
10
+ code;
11
+ path;
12
+ nodeId;
13
+ details;
14
+ constructor(code, message, options = {}) {
15
+ super(message, options.cause === undefined ? undefined : { cause: options.cause });
16
+ this.name = 'RenderError';
17
+ this.code = code;
18
+ this.path = options.path;
19
+ this.nodeId = options.nodeId;
20
+ this.details = options.details;
21
+ }
22
+ /** JSON-safe representation used by `--json` CLI output and the cloud API. */
23
+ toJSON() {
24
+ const payload = {
25
+ name: this.name,
26
+ code: this.code,
27
+ message: this.message,
28
+ };
29
+ if (this.path !== undefined)
30
+ payload.path = this.path;
31
+ if (this.nodeId !== undefined)
32
+ payload.nodeId = this.nodeId;
33
+ if (this.details !== undefined)
34
+ payload.details = this.details;
35
+ return payload;
36
+ }
37
+ }
38
+ /** Narrow an unknown thrown value to a `RenderError`. */
39
+ export function isRenderError(value) {
40
+ return value instanceof RenderError;
41
+ }
42
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAoBH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,IAAI,CAAkB;IACtB,IAAI,CAAqB;IACzB,MAAM,CAAqB;IAC3B,OAAO,CAAsC;IAEtD,YAAY,IAAqB,EAAE,OAAe,EAAE,UAA8B,EAAE;QAClF,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QACnF,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACjC,CAAC;IAED,8EAA8E;IAC9E,MAAM;QAQJ,MAAM,OAAO,GAAsC;YACjD,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;QACF,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;YAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC5D,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;YAAE,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC/D,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAED,yDAAyD;AACzD,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,KAAK,YAAY,WAAW,CAAC;AACtC,CAAC"}
package/dist/hash.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Deterministic, platform-neutral content hashing.
3
+ *
4
+ * Used to derive stable node IDs. Deliberately not `node:crypto`: the same
5
+ * compiler code runs in a CLI, in a library caller, and inside a Cloudflare
6
+ * Worker, and node IDs only need to be stable and collision-resistant, not
7
+ * cryptographically secure. Output is identical on every platform because the
8
+ * arithmetic is 32-bit integer math.
9
+ */
10
+ /** FNV-1a style 64-bit hash rendered as 14 base36 characters. */
11
+ export declare function stableHash(input: string): string;
12
+ /** A node ID derived from content identity. */
13
+ export declare function derivedNodeId(type: string, path: string): string;
14
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,iEAAiE;AACjE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWhD;AAED,+CAA+C;AAC/C,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhE"}
package/dist/hash.js ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Deterministic, platform-neutral content hashing.
3
+ *
4
+ * Used to derive stable node IDs. Deliberately not `node:crypto`: the same
5
+ * compiler code runs in a CLI, in a library caller, and inside a Cloudflare
6
+ * Worker, and node IDs only need to be stable and collision-resistant, not
7
+ * cryptographically secure. Output is identical on every platform because the
8
+ * arithmetic is 32-bit integer math.
9
+ */
10
+ /** FNV-1a style 64-bit hash rendered as 14 base36 characters. */
11
+ export function stableHash(input) {
12
+ let high = 0x811c9dc5;
13
+ let low = 0x01000193;
14
+ for (let index = 0; index < input.length; index += 1) {
15
+ const code = input.charCodeAt(index);
16
+ high ^= code;
17
+ high = Math.imul(high, 16777619) >>> 0;
18
+ low = (low + code) >>> 0;
19
+ low = Math.imul(low ^ (low >>> 13), 2246822519) >>> 0;
20
+ }
21
+ return `${high.toString(36).padStart(7, '0')}${low.toString(36).padStart(7, '0')}`;
22
+ }
23
+ /** A node ID derived from content identity. */
24
+ export function derivedNodeId(type, path) {
25
+ return `n-${stableHash(`${type}|${path}`).slice(0, 10)}`;
26
+ }
27
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,iEAAiE;AACjE,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,IAAI,IAAI,GAAG,UAAU,CAAC;IACtB,IAAI,GAAG,GAAG,UAAU,CAAC;IACrB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,IAAI,IAAI,CAAC;QACb,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;QACvC,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACrF,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,IAAY;IACtD,OAAO,KAAK,UAAU,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * `@bestagentkits/render` public library surface.
3
+ *
4
+ * Additions here are additive and versioned; see `docs/release-policy.md` for
5
+ * what a minor and a major release promise. Functions that are not implemented
6
+ * yet are not exported — the package never advertises a scaffold.
7
+ */
8
+ export type { Diagnostic, DiagnosticSeverity } from './diagnostics.js';
9
+ export type { AdapterMarkupCheck, DiagramAdapter, DiagramAdapterResult, DiagramRenderRequest, } from './diagram/adapter.js';
10
+ export { checkAdapterMarkup, DIAGRAM_ADAPTER_CONTRACT_VERSION, MAX_DIAGRAM_MARKUP_BYTES, runDiagramAdapter, } from './diagram/adapter.js';
11
+ export type { RenderErrorCode, RenderErrorOptions } from './errors.js';
12
+ export { isRenderError, RenderError } from './errors.js';
13
+ export type { IrDocument, IrNode, IrTheme, NetworkPolicy } from './ir.js';
14
+ export type { JsonValue } from './json.js';
15
+ export type { ActionDefinition, ActionType } from './registry/actions.js';
16
+ export { ACTION_DEFINITIONS, ALLOWED_EVENTS, listActionTypes } from './registry/actions.js';
17
+ export type { Catalog, CatalogEntry } from './registry/registry.js';
18
+ export { blockTypes, buildPageSpecJsonSchema, catalog, describe, getBlockDefinition, SPEC_SCHEMA_VERSION, } from './registry/registry.js';
19
+ export type { BlockDefinition, SizingContract, SlotSpec } from './registry/roster.js';
20
+ export { buildContentSecurityPolicy } from './render/document.js';
21
+ export { escapeAttribute, escapeText, escapeUrl, serializeJsonForScript } from './render/escape.js';
22
+ export type { CompileResult, RenderOptions } from './render/render.js';
23
+ export { compile, render } from './render/render.js';
24
+ export type { BoundsReport } from './spec/bounds.js';
25
+ export { LIMITS } from './spec/bounds.js';
26
+ export { CURRENT_SPEC_VERSION, supportedVersions } from './spec/migrate.js';
27
+ export type { NormalizeResult } from './spec/normalize.js';
28
+ export { normalize, normalizeSpec } from './spec/normalize.js';
29
+ export type { ParseOptions } from './spec/parse.js';
30
+ export { parseSpec } from './spec/parse.js';
31
+ export type { EmbedProvider } from './spec/providers.js';
32
+ export { EMBED_PROVIDER_NAMES, EMBED_PROVIDERS, hostMatchesAnyProvider, hostMatchesProvider, isEmbedProvider, } from './spec/providers.js';
33
+ export type { ValidateResult, ValidateSummary } from './spec/validate.js';
34
+ export { validate, validateOrThrow } from './spec/validate.js';
35
+ export type { LoadThemeOptions, ResolvedTheme, ThemeInput } from './theme/load-theme.js';
36
+ export { loadTheme, resolveTheme, themeDiagnostics, themePresetNames } from './theme/load-theme.js';
37
+ export type { PresetEntry } from './theme/presets.js';
38
+ export type { PresetSource, ThemeCatalog, ThemeCatalogOptions } from './theme/theme-catalog.js';
39
+ export { buildThemeCatalog, builtinThemeCatalog, catalogPresetNames, loadPresetFile, parsePresetDocument, themeSearchDirectories, } from './theme/theme-catalog.js';
40
+ export type { TokenSpec } from './theme/tokens.js';
41
+ export { TOKEN_SPECS, tokenNames } from './theme/tokens.js';
42
+ export { PACKAGE_NAME, VERSION } from './version.js';
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACvE,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,gCAAgC,EAChC,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACzD,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1E,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC5F,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EACL,UAAU,EACV,uBAAuB,EACvB,OAAO,EACP,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACpG,YAAY,EAAE,aA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AAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * `@bestagentkits/render` public library surface.
3
+ *
4
+ * Additions here are additive and versioned; see `docs/release-policy.md` for
5
+ * what a minor and a major release promise. Functions that are not implemented
6
+ * yet are not exported — the package never advertises a scaffold.
7
+ */
8
+ export { checkAdapterMarkup, DIAGRAM_ADAPTER_CONTRACT_VERSION, MAX_DIAGRAM_MARKUP_BYTES, runDiagramAdapter, } from './diagram/adapter.js';
9
+ export { isRenderError, RenderError } from './errors.js';
10
+ export { ACTION_DEFINITIONS, ALLOWED_EVENTS, listActionTypes } from './registry/actions.js';
11
+ export { blockTypes, buildPageSpecJsonSchema, catalog, describe, getBlockDefinition, SPEC_SCHEMA_VERSION, } from './registry/registry.js';
12
+ export { buildContentSecurityPolicy } from './render/document.js';
13
+ export { escapeAttribute, escapeText, escapeUrl, serializeJsonForScript } from './render/escape.js';
14
+ export { compile, render } from './render/render.js';
15
+ export { LIMITS } from './spec/bounds.js';
16
+ export { CURRENT_SPEC_VERSION, supportedVersions } from './spec/migrate.js';
17
+ export { normalize, normalizeSpec } from './spec/normalize.js';
18
+ export { parseSpec } from './spec/parse.js';
19
+ export { EMBED_PROVIDER_NAMES, EMBED_PROVIDERS, hostMatchesAnyProvider, hostMatchesProvider, isEmbedProvider, } from './spec/providers.js';
20
+ export { validate, validateOrThrow } from './spec/validate.js';
21
+ export { loadTheme, resolveTheme, themeDiagnostics, themePresetNames } from './theme/load-theme.js';
22
+ export { buildThemeCatalog, builtinThemeCatalog, catalogPresetNames, loadPresetFile, parsePresetDocument, themeSearchDirectories, } from './theme/theme-catalog.js';
23
+ export { TOKEN_SPECS, tokenNames } from './theme/tokens.js';
24
+ export { PACKAGE_NAME, VERSION } from './version.js';
25
+ //# sour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EACd,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Narrow typing for the `yaml` package's error shape.
3
+ * The package exposes line/column on a `YAMLParseError`; this keeps the
4
+ * dependency's error type out of the public surface.
5
+ */
6
+ export interface YamlErrorLike {
7
+ message: string;
8
+ linePos: {
9
+ line: number;
10
+ col: number;
11
+ }[];
12
+ }
13
+ export declare function isNumberedError(value: unknown): value is YamlErrorLike;
14
+ //# sourceMappingURL=yaml-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml-error.d.ts","sourceRoot":"","sources":["../../src/internal/yaml-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC1C;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAItE"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Narrow typing for the `yaml` package's error shape.
3
+ * The package exposes line/column on a `YAMLParseError`; this keeps the
4
+ * dependency's error type out of the public surface.
5
+ */
6
+ export function isNumberedError(value) {
7
+ if (!(value instanceof Error))
8
+ return false;
9
+ const candidate = value;
10
+ return Array.isArray(candidate.linePos);
11
+ }
12
+ //# sourceMappingURL=yaml-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml-error.js","sourceRoot":"","sources":["../../src/internal/yaml-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,MAAM,SAAS,GAAG,KAAyC,CAAC;IAC5D,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC"}
package/dist/ir.d.ts ADDED
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Internal IR.
3
+ *
4
+ * The IR is what the renderer consumes and what future diff/patch/editor
5
+ * tooling will operate on. It is compiler-versioned, not a public schema:
6
+ * the Page Spec is the compatibility boundary, and the IR may change without a
7
+ * spec migration.
8
+ */
9
+ import type { Diagnostic } from './diagnostics.js';
10
+ import type { JsonValue } from './json.js';
11
+ import type { RuntimeFeature } from './registry/roster.js';
12
+ import type { BindingMap } from './spec/bindings.js';
13
+ export interface IrNode {
14
+ /** Stable node ID: author-provided when present, otherwise content-derived. */
15
+ id: string;
16
+ type: string;
17
+ typeVersion: number;
18
+ kind: 'semantic' | 'primitive';
19
+ /** JSON path of this block in the author-facing spec. */
20
+ path: string;
21
+ parentId: string | null;
22
+ depth: number;
23
+ /** Validated props with defaults applied, verbatim from the spec otherwise. */
24
+ props: Record<string, JsonValue>;
25
+ /** Normalized declarative action bindings, keyed by event. */
26
+ bindings: BindingMap;
27
+ /** Child node IDs, in authored order. */
28
+ children: string[];
29
+ /** Accessibility contract inherited from the block definition. */
30
+ a11y: string;
31
+ runtimeFeatures: RuntimeFeature[];
32
+ assets: string[];
33
+ network: 'none' | 'optional';
34
+ }
35
+ /**
36
+ * `deny` is the default. An allow list opts into named capabilities, and an
37
+ * optional provider list narrows remote media to that provider's own hosts.
38
+ */
39
+ export type NetworkPolicy = 'deny' | {
40
+ allow: string[];
41
+ providers?: string[];
42
+ };
43
+ export interface IrMeta {
44
+ title: string;
45
+ description?: string;
46
+ locale: string;
47
+ slug?: string;
48
+ }
49
+ export interface IrTheme {
50
+ preset: string;
51
+ extends?: string;
52
+ tokens?: JsonValue;
53
+ }
54
+ export interface IrDocument {
55
+ /** Version of the IR shape itself. */
56
+ irVersion: 1;
57
+ /** Page Spec schema version the document was normalized from. */
58
+ specVersion: number;
59
+ /** Compiler version that produced this IR. */
60
+ compilerVersion: string;
61
+ meta: IrMeta;
62
+ theme: IrTheme;
63
+ policy: {
64
+ network: NetworkPolicy;
65
+ };
66
+ state: Record<string, JsonValue>;
67
+ rootId: string;
68
+ /** All nodes in deterministic depth-first pre-order, root first. */
69
+ nodes: IrNode[];
70
+ /** Non-fatal diagnostics (deprecations, skipped heading levels, and similar). */
71
+ warnings: Diagnostic[];
72
+ }
73
+ /** Index nodes by ID for O(1) lookup by the renderer. */
74
+ export declare function indexNodes(ir: IrDocument): Map<string, IrNode>;
75
+ /** Direct children of a node, in authored order. */
76
+ export declare function childrenOf(ir: IrDocument, node: IrNode): IrNode[];
77
+ //# sourceMappingURL=ir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ir.d.ts","sourceRoot":"","sources":["../src/ir.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,MAAM;IACrB,+EAA+E;IAC/E,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,UAAU,GAAG,WAAW,CAAC;IAC/B,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACjC,8DAA8D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MAAM,EAAE,MAAM,CAAC,CAE9D;AAED,oDAAoD;AACpD,wBAAgB,UAAU,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAKjE"}
package/dist/ir.js ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Internal IR.
3
+ *
4
+ * The IR is what the renderer consumes and what future diff/patch/editor
5
+ * tooling will operate on. It is compiler-versioned, not a public schema:
6
+ * the Page Spec is the compatibility boundary, and the IR may change without a
7
+ * spec migration.
8
+ */
9
+ /** Index nodes by ID for O(1) lookup by the renderer. */
10
+ export function indexNodes(ir) {
11
+ return new Map(ir.nodes.map((node) => [node.id, node]));
12
+ }
13
+ /** Direct children of a node, in authored order. */
14
+ export function childrenOf(ir, node) {
15
+ const byId = indexNodes(ir);
16
+ return node.children
17
+ .map((id) => byId.get(id))
18
+ .filter((child) => child !== undefined);
19
+ }
20
+ //# sourceMappingURL=ir.js.map
package/dist/ir.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ir.js","sourceRoot":"","sources":["../src/ir.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmEH,yDAAyD;AACzD,MAAM,UAAU,UAAU,CAAC,EAAc;IACvC,OAAO,IAAI,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,UAAU,CAAC,EAAc,EAAE,IAAY;IACrD,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC,QAAQ;SACjB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;SACzB,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;AAC7D,CAAC"}
package/dist/json.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * JSON value model and canonical serialization.
3
+ *
4
+ * Canonical serialization is a determinism primitive: stable node IDs and
5
+ * determinism hashes are derived from it, so key order must not depend on how a
6
+ * document happened to be written.
7
+ */
8
+ export type JsonPrimitive = string | number | boolean | null;
9
+ export type JsonValue = JsonPrimitive | JsonValue[] | {
10
+ [key: string]: JsonValue;
11
+ };
12
+ /** True for a plain object (not an array, not null). */
13
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
14
+ /** True for any JSON-serializable value. */
15
+ export declare function isJsonValue(value: unknown): value is JsonValue;
16
+ /**
17
+ * Serialize a JSON value with object keys sorted lexicographically.
18
+ *
19
+ * Used for content hashes, never for emitted HTML: emitted output uses the
20
+ * spec's own ordering where ordering is meaningful to a reader.
21
+ */
22
+ export declare function canonicalStringify(value: JsonValue): string;
23
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEnF,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE9E;AAED,4CAA4C;AAC5C,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAQ9D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAc3D"}