@refrakt-md/runes 0.37.0 → 0.39.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 (200) hide show
  1. package/dist/collection-helpers.d.ts +21 -2
  2. package/dist/collection-helpers.d.ts.map +1 -1
  3. package/dist/collection-helpers.js +72 -15
  4. package/dist/collection-helpers.js.map +1 -1
  5. package/dist/config.d.ts.map +1 -1
  6. package/dist/config.js +79 -46
  7. package/dist/config.js.map +1 -1
  8. package/dist/data-pipeline.d.ts +24 -10
  9. package/dist/data-pipeline.d.ts.map +1 -1
  10. package/dist/data-pipeline.js +34 -56
  11. package/dist/data-pipeline.js.map +1 -1
  12. package/dist/file-ref-resolve.js +9 -13
  13. package/dist/file-ref-resolve.js.map +1 -1
  14. package/dist/index.d.ts +9 -2
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +7 -4
  17. package/dist/index.js.map +1 -1
  18. package/dist/lib/component.d.ts +8 -11
  19. package/dist/lib/component.d.ts.map +1 -1
  20. package/dist/lib/component.js +17 -52
  21. package/dist/lib/component.js.map +1 -1
  22. package/dist/lib/field-metas.d.ts +34 -0
  23. package/dist/lib/field-metas.d.ts.map +1 -0
  24. package/dist/lib/field-metas.js +45 -0
  25. package/dist/lib/field-metas.js.map +1 -0
  26. package/dist/lib/index.d.ts +64 -1
  27. package/dist/lib/index.d.ts.map +1 -1
  28. package/dist/lib/index.js +134 -5
  29. package/dist/lib/index.js.map +1 -1
  30. package/dist/lib/node.d.ts +22 -0
  31. package/dist/lib/node.d.ts.map +1 -1
  32. package/dist/lib/node.js +32 -0
  33. package/dist/lib/node.js.map +1 -1
  34. package/dist/lib/preprocess.d.ts +63 -0
  35. package/dist/lib/preprocess.d.ts.map +1 -0
  36. package/dist/lib/preprocess.js +71 -0
  37. package/dist/lib/preprocess.js.map +1 -0
  38. package/dist/lib/registers.d.ts +132 -0
  39. package/dist/lib/registers.d.ts.map +1 -0
  40. package/dist/lib/registers.js +328 -0
  41. package/dist/lib/registers.js.map +1 -0
  42. package/dist/lib/resolver.d.ts +9 -1
  43. package/dist/lib/resolver.d.ts.map +1 -1
  44. package/dist/lib/resolver.js +24 -1
  45. package/dist/lib/resolver.js.map +1 -1
  46. package/dist/lib/schema-table.d.ts +46 -9
  47. package/dist/lib/schema-table.d.ts.map +1 -1
  48. package/dist/lib/schema-table.js +111 -22
  49. package/dist/lib/schema-table.js.map +1 -1
  50. package/dist/lib/slots.d.ts +99 -0
  51. package/dist/lib/slots.d.ts.map +1 -0
  52. package/dist/lib/slots.js +448 -0
  53. package/dist/lib/slots.js.map +1 -0
  54. package/dist/props.d.ts +0 -2
  55. package/dist/props.d.ts.map +1 -1
  56. package/dist/reference.d.ts +37 -0
  57. package/dist/reference.d.ts.map +1 -1
  58. package/dist/reference.js +116 -2
  59. package/dist/reference.js.map +1 -1
  60. package/dist/registers-pipeline.d.ts +50 -0
  61. package/dist/registers-pipeline.d.ts.map +1 -0
  62. package/dist/registers-pipeline.js +218 -0
  63. package/dist/registers-pipeline.js.map +1 -0
  64. package/dist/schema-row.d.ts +5 -0
  65. package/dist/schema-row.d.ts.map +1 -1
  66. package/dist/schema-row.js +1 -0
  67. package/dist/schema-row.js.map +1 -1
  68. package/dist/tags/accordion.d.ts.map +1 -1
  69. package/dist/tags/accordion.js +4 -7
  70. package/dist/tags/accordion.js.map +1 -1
  71. package/dist/tags/annotate.d.ts.map +1 -1
  72. package/dist/tags/annotate.js +6 -13
  73. package/dist/tags/annotate.js.map +1 -1
  74. package/dist/tags/bar.d.ts.map +1 -1
  75. package/dist/tags/bar.js +2 -5
  76. package/dist/tags/bar.js.map +1 -1
  77. package/dist/tags/blog.d.ts.map +1 -1
  78. package/dist/tags/blog.js +1 -9
  79. package/dist/tags/blog.js.map +1 -1
  80. package/dist/tags/breadcrumb.d.ts.map +1 -1
  81. package/dist/tags/breadcrumb.js +4 -5
  82. package/dist/tags/breadcrumb.js.map +1 -1
  83. package/dist/tags/budget.d.ts.map +1 -1
  84. package/dist/tags/budget.js +2 -10
  85. package/dist/tags/budget.js.map +1 -1
  86. package/dist/tags/card.d.ts.map +1 -1
  87. package/dist/tags/card.js +7 -14
  88. package/dist/tags/card.js.map +1 -1
  89. package/dist/tags/chart.d.ts.map +1 -1
  90. package/dist/tags/chart.js +5 -8
  91. package/dist/tags/chart.js.map +1 -1
  92. package/dist/tags/codegroup.d.ts.map +1 -1
  93. package/dist/tags/codegroup.js +0 -2
  94. package/dist/tags/codegroup.js.map +1 -1
  95. package/dist/tags/common.d.ts.map +1 -1
  96. package/dist/tags/common.js +2 -5
  97. package/dist/tags/common.js.map +1 -1
  98. package/dist/tags/compare.d.ts.map +1 -1
  99. package/dist/tags/compare.js +4 -8
  100. package/dist/tags/compare.js.map +1 -1
  101. package/dist/tags/conversation.d.ts.map +1 -1
  102. package/dist/tags/conversation.js +4 -7
  103. package/dist/tags/conversation.js.map +1 -1
  104. package/dist/tags/data.d.ts +2 -2
  105. package/dist/tags/data.d.ts.map +1 -1
  106. package/dist/tags/data.js +6 -4
  107. package/dist/tags/data.js.map +1 -1
  108. package/dist/tags/datatable.d.ts.map +1 -1
  109. package/dist/tags/datatable.js +4 -8
  110. package/dist/tags/datatable.js.map +1 -1
  111. package/dist/tags/details.d.ts.map +1 -1
  112. package/dist/tags/details.js +3 -7
  113. package/dist/tags/details.js.map +1 -1
  114. package/dist/tags/diagram.js +2 -2
  115. package/dist/tags/diagram.js.map +1 -1
  116. package/dist/tags/diff.js +1 -1
  117. package/dist/tags/diff.js.map +1 -1
  118. package/dist/tags/drawer.d.ts.map +1 -1
  119. package/dist/tags/drawer.js +4 -12
  120. package/dist/tags/drawer.js.map +1 -1
  121. package/dist/tags/embed.d.ts.map +1 -1
  122. package/dist/tags/embed.js +4 -5
  123. package/dist/tags/embed.js.map +1 -1
  124. package/dist/tags/figure.d.ts +10 -4
  125. package/dist/tags/figure.d.ts.map +1 -1
  126. package/dist/tags/figure.js +70 -33
  127. package/dist/tags/figure.js.map +1 -1
  128. package/dist/tags/form.d.ts.map +1 -1
  129. package/dist/tags/form.js +3 -18
  130. package/dist/tags/form.js.map +1 -1
  131. package/dist/tags/gallery.d.ts.map +1 -1
  132. package/dist/tags/gallery.js +6 -11
  133. package/dist/tags/gallery.js.map +1 -1
  134. package/dist/tags/grid.d.ts.map +1 -1
  135. package/dist/tags/grid.js +7 -17
  136. package/dist/tags/grid.js.map +1 -1
  137. package/dist/tags/hint.d.ts.map +1 -1
  138. package/dist/tags/hint.js +4 -8
  139. package/dist/tags/hint.js.map +1 -1
  140. package/dist/tags/include.d.ts +51 -7
  141. package/dist/tags/include.d.ts.map +1 -1
  142. package/dist/tags/include.js +216 -7
  143. package/dist/tags/include.js.map +1 -1
  144. package/dist/tags/juxtapose.js +2 -2
  145. package/dist/tags/juxtapose.js.map +1 -1
  146. package/dist/tags/layout.d.ts.map +1 -1
  147. package/dist/tags/layout.js +2 -5
  148. package/dist/tags/layout.js.map +1 -1
  149. package/dist/tags/mediatext.d.ts.map +1 -1
  150. package/dist/tags/mediatext.js +5 -13
  151. package/dist/tags/mediatext.js.map +1 -1
  152. package/dist/tags/nav.d.ts.map +1 -1
  153. package/dist/tags/nav.js +2 -5
  154. package/dist/tags/nav.js.map +1 -1
  155. package/dist/tags/progress.d.ts.map +1 -1
  156. package/dist/tags/progress.js +4 -8
  157. package/dist/tags/progress.js.map +1 -1
  158. package/dist/tags/pullquote.d.ts.map +1 -1
  159. package/dist/tags/pullquote.js +8 -15
  160. package/dist/tags/pullquote.js.map +1 -1
  161. package/dist/tags/region.d.ts.map +1 -1
  162. package/dist/tags/region.js +2 -5
  163. package/dist/tags/region.js.map +1 -1
  164. package/dist/tags/reveal.d.ts.map +1 -1
  165. package/dist/tags/reveal.js +4 -7
  166. package/dist/tags/reveal.js.map +1 -1
  167. package/dist/tags/section.d.ts.map +1 -1
  168. package/dist/tags/section.js +3 -3
  169. package/dist/tags/section.js.map +1 -1
  170. package/dist/tags/showcase.d.ts.map +1 -1
  171. package/dist/tags/showcase.js +4 -11
  172. package/dist/tags/showcase.js.map +1 -1
  173. package/dist/tags/sidenote.d.ts.map +1 -1
  174. package/dist/tags/sidenote.js +7 -12
  175. package/dist/tags/sidenote.js.map +1 -1
  176. package/dist/tags/snippet.d.ts +9 -10
  177. package/dist/tags/snippet.d.ts.map +1 -1
  178. package/dist/tags/snippet.js +213 -10
  179. package/dist/tags/snippet.js.map +1 -1
  180. package/dist/tags/tabs.d.ts.map +1 -1
  181. package/dist/tags/tabs.js +3 -6
  182. package/dist/tags/tabs.js.map +1 -1
  183. package/dist/tags/textblock.d.ts.map +1 -1
  184. package/dist/tags/textblock.js +7 -19
  185. package/dist/tags/textblock.js.map +1 -1
  186. package/dist/tags/tint.d.ts.map +1 -1
  187. package/dist/tags/tint.js +17 -29
  188. package/dist/tags/tint.js.map +1 -1
  189. package/dist/tags/toc.js +1 -1
  190. package/dist/tags/toc.js.map +1 -1
  191. package/dist/universal-attributes.d.ts +1 -1
  192. package/package.json +3 -3
  193. package/dist/include-pipeline.d.ts +0 -52
  194. package/dist/include-pipeline.d.ts.map +0 -1
  195. package/dist/include-pipeline.js +0 -206
  196. package/dist/include-pipeline.js.map +0 -1
  197. package/dist/snippet-pipeline.d.ts +0 -44
  198. package/dist/snippet-pipeline.d.ts.map +0 -1
  199. package/dist/snippet-pipeline.js +0 -307
  200. package/dist/snippet-pipeline.js.map +0 -1
@@ -0,0 +1,63 @@
1
+ import type { Node, Schema } from '@markdoc/markdoc';
2
+ import type { PreprocessContext, PreprocessPage } from '@refrakt-md/types';
3
+ /**
4
+ * Per-rune preprocessing (SPEC-141).
5
+ *
6
+ * A rune that resolves itself before the transform — `include`, `snippet`,
7
+ * `data` — declares a `preprocess` hook on its schema, beside `transform`.
8
+ * One walk ({@link preprocessTree}) visits the page AST and dispatches to the
9
+ * hook of whichever tag it meets. The ordering between preprocessors is not
10
+ * stated anywhere: it is tree order.
11
+ *
12
+ * That is a valid order because the producer/consumer graph is acyclic by
13
+ * construction. `include` pastes a file's AST and `data` clones its row
14
+ * template **at their own node**, so anything they produce is below that point
15
+ * and the walk meets it next. Nothing runs the other way: `snippet` resolves to
16
+ * a `fence`, whose content is raw text that is never re-parsed as Markdoc.
17
+ */
18
+ /** The context a rune's `preprocess` hook receives. */
19
+ export interface RunePreprocessContext extends PreprocessContext {
20
+ /**
21
+ * The nodes enclosing the one being preprocessed, outermost first — the
22
+ * page's `document` node is always the first entry, and the direct parent
23
+ * is the last (SPEC-141 D4). A replacement is not an ancestor of what it
24
+ * contains: by the time the walk descends into it, the tag is gone.
25
+ */
26
+ readonly ancestors: readonly Node[];
27
+ }
28
+ /**
29
+ * A rune's preprocess hook (SPEC-141 D1).
30
+ *
31
+ * Receives the rune's own tag node — not the tree. Returning a node replaces
32
+ * the tag with it; returning an array splices those nodes in its place (an
33
+ * empty array removes the tag); returning nothing leaves it alone. The walk
34
+ * then continues into whatever is now at that position, so the hook never has
35
+ * to resolve the tags its own output contains.
36
+ */
37
+ export type RunePreprocess = (node: Node, page: PreprocessPage, ctx: RunePreprocessContext) => Node | Node[] | void;
38
+ /**
39
+ * Schema → its rune's preprocess hook. Recorded by `createContentModelSchema`
40
+ * and kept off the Markdoc schema object, the same shape as
41
+ * `schemaRuneStructures`: Markdoc never reads it, and only {@link preprocessTree}
42
+ * does.
43
+ */
44
+ export declare const schemaPreprocessors: WeakMap<Schema, RunePreprocess>;
45
+ /**
46
+ * Resolve every preprocessing rune in a page AST, in tree order.
47
+ *
48
+ * `schemas` is the page's tag table — the same `tags` the transform will use,
49
+ * core and plugin runes merged — and any of them that declares a `preprocess`
50
+ * hook takes part. Mutates `ast` in place; returns it when anything changed,
51
+ * and nothing otherwise, matching the `PluginPipelineHooks.preprocess` contract.
52
+ *
53
+ * **The walk descends into a replacement** (SPEC-141 D3). After a hook
54
+ * replaces its tag, the walk revisits the same position, so a producer's
55
+ * output is resolved where it lands: a `{% snippet %}` in a `{% data %}` row
56
+ * template is reached after the row is bound (BUG-027), and a subquery `data`
57
+ * per outer row. Termination needs no depth limit: `include` leaves no
58
+ * `include` tags behind (it expands nested ones itself, under its cycle
59
+ * stack), `data`'s output consumes one level of the authored body per pass,
60
+ * and `snippet`'s fence contains no tags at all.
61
+ */
62
+ export declare function preprocessTree(ast: Node, page: PreprocessPage, ctx: PreprocessContext, schemas: Record<string, unknown>): Node | void;
63
+ //# sourceMappingURL=preprocess.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preprocess.d.ts","sourceRoot":"","sources":["../../src/lib/preprocess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE3E;;;;;;;;;;;;;;GAcG;AAEH,uDAAuD;AACvD,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC/D;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,SAAS,IAAI,EAAE,CAAC;CACpC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,CAC5B,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,cAAc,EACpB,GAAG,EAAE,qBAAqB,KACtB,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;AAE1B;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,iCAAwC,CAAC;AAEzE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAC7B,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,cAAc,EACpB,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,IAAI,GAAG,IAAI,CA4Cb"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Schema → its rune's preprocess hook. Recorded by `createContentModelSchema`
3
+ * and kept off the Markdoc schema object, the same shape as
4
+ * `schemaRuneStructures`: Markdoc never reads it, and only {@link preprocessTree}
5
+ * does.
6
+ */
7
+ export const schemaPreprocessors = new WeakMap();
8
+ /**
9
+ * Resolve every preprocessing rune in a page AST, in tree order.
10
+ *
11
+ * `schemas` is the page's tag table — the same `tags` the transform will use,
12
+ * core and plugin runes merged — and any of them that declares a `preprocess`
13
+ * hook takes part. Mutates `ast` in place; returns it when anything changed,
14
+ * and nothing otherwise, matching the `PluginPipelineHooks.preprocess` contract.
15
+ *
16
+ * **The walk descends into a replacement** (SPEC-141 D3). After a hook
17
+ * replaces its tag, the walk revisits the same position, so a producer's
18
+ * output is resolved where it lands: a `{% snippet %}` in a `{% data %}` row
19
+ * template is reached after the row is bound (BUG-027), and a subquery `data`
20
+ * per outer row. Termination needs no depth limit: `include` leaves no
21
+ * `include` tags behind (it expands nested ones itself, under its cycle
22
+ * stack), `data`'s output consumes one level of the authored body per pass,
23
+ * and `snippet`'s fence contains no tags at all.
24
+ */
25
+ export function preprocessTree(ast, page, ctx, schemas) {
26
+ const hooks = new Map();
27
+ for (const [name, schema] of Object.entries(schemas)) {
28
+ if (!schema || typeof schema !== 'object')
29
+ continue;
30
+ const hook = schemaPreprocessors.get(schema);
31
+ if (hook)
32
+ hooks.set(name, hook);
33
+ }
34
+ if (hooks.size === 0)
35
+ return;
36
+ let mutated = false;
37
+ const ancestors = [];
38
+ const walk = (parent) => {
39
+ const children = parent.children;
40
+ if (!children || children.length === 0)
41
+ return;
42
+ ancestors.push(parent);
43
+ for (let i = 0; i < children.length; i++) {
44
+ const child = children[i];
45
+ const hook = child.type === 'tag' && child.tag ? hooks.get(child.tag) : undefined;
46
+ if (hook) {
47
+ // A prototype link rather than a spread, so a context whose
48
+ // diagnostics are methods on a class keeps them.
49
+ const hookCtx = Object.create(ctx, {
50
+ ancestors: { value: [...ancestors], enumerable: true },
51
+ });
52
+ const result = hook(child, page, hookCtx);
53
+ // Returning the node itself is "leave it alone" too — treating it as
54
+ // a replacement would revisit it forever.
55
+ if (result !== undefined && result !== child) {
56
+ const replacement = Array.isArray(result) ? result : [result];
57
+ children.splice(i, 1, ...replacement);
58
+ mutated = true;
59
+ // Revisit this position: the walk descends into the replacement.
60
+ i--;
61
+ continue;
62
+ }
63
+ }
64
+ walk(child);
65
+ }
66
+ ancestors.pop();
67
+ };
68
+ walk(ast);
69
+ return mutated ? ast : undefined;
70
+ }
71
+ //# sourceMappingURL=preprocess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preprocess.js","sourceRoot":"","sources":["../../src/lib/preprocess.ts"],"names":[],"mappings":"AA6CA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAA0B,CAAC;AAEzE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAC7B,GAAS,EACT,IAAoB,EACpB,GAAsB,EACtB,OAAgC;IAEhC,MAAM,KAAK,GAAG,IAAI,GAAG,EAA0B,CAAC;IAChD,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACtD,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;YAAE,SAAS;QACpD,MAAM,IAAI,GAAG,mBAAmB,CAAC,GAAG,CAAC,MAAgB,CAAC,CAAC;QACvD,IAAI,IAAI;YAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO;IAE7B,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,MAAM,SAAS,GAAW,EAAE,CAAC;IAE7B,MAAM,IAAI,GAAG,CAAC,MAAY,EAAQ,EAAE;QACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAC/C,SAAS,CAAC,IAAI,CAAC,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,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAClC,CAAC"}
@@ -0,0 +1,132 @@
1
+ import Markdoc from '@markdoc/markdoc';
2
+ /**
3
+ * Declarative entity and edge registration — SPEC-144 / WORK-611.
4
+ *
5
+ * A rune says *what it registers* — which named source holds the id, which
6
+ * sources to carry into the data bag, which two hold an edge's endpoints — and
7
+ * one core participant (`createRegistersHooks`) does the registering in the
8
+ * existing Phase 2 / Phase 3 slots. Plugins keep `PluginPipelineHooks` for
9
+ * everything else; this is a generic participant beside them.
10
+ *
11
+ * The vocabulary is closed (ADR-036, SPEC-144 D1): every value is a string, a
12
+ * boolean, or a list or record of those. No expression form, no predicate, no
13
+ * function. A domain that needs more writes a plugin hook — the plan plugin is
14
+ * the standing example (D5).
15
+ *
16
+ * **Where a value comes from** (D3, decided in WORK-611). A source is a bare
17
+ * name, resolved the way the hand-written helpers always did: a `refs` entry —
18
+ * a node carrying `data-name=<source>` inside the rune, read as its text — and
19
+ * otherwise the rune's `data-rune-fields` bag. `createComponentRenderable`
20
+ * rejects a rune whose properties and refs share a name (ADR-008), so the two
21
+ * namespaces are disjoint and a bare name cannot mean two things. A name that
22
+ * resolves to neither is a typo, and `validate` reports it with file and line
23
+ * (`registers-source-unresolved`), the same audit a schema-table source gets.
24
+ */
25
+ /** One data-bag entry: `'role'` carries source `role` as key `role`;
26
+ * `{ name: 'title' }` carries source `title` as key `name`. */
27
+ export type RegistersDataEntry = string | Readonly<Record<string, string>>;
28
+ /** The data bag: an ordered field list, or one source holding a JSON object
29
+ * that *is* the bag. Key order follows the declaration. */
30
+ export type RegistersData = readonly RegistersDataEntry[] | {
31
+ readonly json: string;
32
+ };
33
+ export interface RegistersEntity {
34
+ /** Registry type. Defaults to the rune name. */
35
+ type?: string;
36
+ /** The source holding the entity's id. A rune instance whose id is empty
37
+ * registers nothing and warns. */
38
+ idFrom: string;
39
+ /** `'site'` (default) or `'page'` — see `EntityRegistration.scope`. */
40
+ scope?: 'site' | 'page';
41
+ /** What to carry in the entity's data bag. Nothing is added implicitly. */
42
+ data?: RegistersData;
43
+ /** Alternative names, split from a data-bag key. The name index the
44
+ * participant builds in Phase 3 adds each alias after the ids, and an alias
45
+ * already present keeps its first owner. */
46
+ aliases?: {
47
+ readonly from: string;
48
+ readonly separator?: string;
49
+ };
50
+ }
51
+ export interface RegistersEdge {
52
+ /** Registry type of the edge's own entry. Defaults to the rune name. */
53
+ type?: string;
54
+ /** Source holding the source entity's id (or alias). */
55
+ from: string;
56
+ /** Source holding the target entity's id (or alias). */
57
+ to: string;
58
+ /** The relationship-graph edge kind: a literal, or `{ field }` naming a key
59
+ * of the edge's data bag. An empty field value falls back to the type. */
60
+ kind: string | {
61
+ readonly field: string;
62
+ };
63
+ /** Contribute the reverse edge too: a literal, or `{ field }` naming a data
64
+ * key whose value is `'true'`. Default `false`. */
65
+ bidirectional?: boolean | {
66
+ readonly field: string;
67
+ };
68
+ /** Further sources for the edge entry's data bag. */
69
+ data?: readonly RegistersDataEntry[];
70
+ }
71
+ /** A rune's `registers` block: exactly one of `entity` or `edge`. */
72
+ export interface RegistersDeclaration {
73
+ entity?: RegistersEntity;
74
+ edge?: RegistersEdge;
75
+ }
76
+ /** The name index a declaring plugin's aggregate slot receives in Phase 3. */
77
+ export interface RegistersIndex {
78
+ /** Every declared entity by id and by alias. Ids are set in type
79
+ * declaration order, then registry order, so a later id replaces an earlier
80
+ * one; an alias never replaces anything already present. */
81
+ entityByName: Map<string, import('@refrakt-md/types').EntityRegistration>;
82
+ }
83
+ /** Declarations recorded by `createContentModelSchema`, keyed by schema — the
84
+ * same pattern as `schemaTables`, for the same reason: tooling has only the
85
+ * schema to read from. */
86
+ export declare const schemaRegisters: WeakMap<Markdoc.Schema, RegistersDeclaration>;
87
+ /** The `registers` block a rune declares, if it declares one. */
88
+ export declare function registersFor(schema: unknown): RegistersDeclaration | undefined;
89
+ /**
90
+ * Check a declaration against the closed vocabulary, throwing on the first
91
+ * violation. Runs at schema construction, so a malformed block fails the
92
+ * import that defines it rather than a build that happens to use it.
93
+ */
94
+ export declare function validateRegistersDeclaration(decl: unknown, where?: string): void;
95
+ declare function dataEntries(data: readonly RegistersDataEntry[], where?: string): Array<{
96
+ key: string;
97
+ source: string;
98
+ }>;
99
+ /** Every source a declaration reads from the rune's output, with the role it
100
+ * plays — what the validate-time audit and `inspect` check. */
101
+ export declare function registersSources(decl: RegistersDeclaration): Array<{
102
+ source: string;
103
+ role: string;
104
+ }>;
105
+ type AnyTag = {
106
+ name?: string;
107
+ attributes?: Record<string, unknown>;
108
+ children?: unknown[];
109
+ };
110
+ /** Read one source off a rune's tag: a ref's text, else its field-bag value,
111
+ * else `''`. The D3 rule — see the module comment. */
112
+ export declare function readRegistersSource(tag: AnyTag, source: string): string;
113
+ /**
114
+ * Sources a declaration names that the rune does not provide — WORK-611.
115
+ *
116
+ * The same rule `auditSchemaSources` applies to a schema table: a source
117
+ * resolves if a node in the rune's output carries the name, if the field bag
118
+ * has it, or if it is one of the rune's declared attributes (an optional
119
+ * attribute left unset emits nothing, which is "this input did not exercise
120
+ * it", not a typo). What is left resolves to nothing, ever.
121
+ *
122
+ * `tree` is the rune's `Markdoc.transform` output, before the identity
123
+ * transform consumes the bag.
124
+ */
125
+ export declare function auditRegistersSources(decl: RegistersDeclaration, tree: unknown, declaredAttributes?: readonly string[]): Array<{
126
+ source: string;
127
+ role: string;
128
+ }>;
129
+ /** One line per declaration, for `inspect` and the reference. */
130
+ export declare function describeRegisters(decl: RegistersDeclaration, rune: string): string[];
131
+ export { dataEntries as registersDataEntries };
132
+ //# sourceMappingURL=registers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registers.d.ts","sourceRoot":"","sources":["../../src/lib/registers.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAIvC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;gEACgE;AAChE,MAAM,MAAM,kBAAkB,GAAG,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AAE,MAAM,GAAG,MAAM,EAAE,CAmCpF;AAED,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,328 @@
1
+ import Markdoc from '@markdoc/markdoc';
2
+ import { readField } from '@refrakt-md/transform';
3
+ /** Declarations recorded by `createContentModelSchema`, keyed by schema — the
4
+ * same pattern as `schemaTables`, for the same reason: tooling has only the
5
+ * schema to read from. */
6
+ export const schemaRegisters = new WeakMap();
7
+ /** The `registers` block a rune declares, if it declares one. */
8
+ export function registersFor(schema) {
9
+ return schema && typeof schema === 'object' ? schemaRegisters.get(schema) : undefined;
10
+ }
11
+ // ---------------------------------------------------------------------------
12
+ // The closed vocabulary, checked at construction
13
+ // ---------------------------------------------------------------------------
14
+ const ENTITY_KEYS = new Set(['type', 'idFrom', 'scope', 'data', 'aliases']);
15
+ const EDGE_KEYS = new Set(['type', 'from', 'to', 'kind', 'bidirectional', 'data']);
16
+ /**
17
+ * Check a declaration against the closed vocabulary, throwing on the first
18
+ * violation. Runs at schema construction, so a malformed block fails the
19
+ * import that defines it rather than a build that happens to use it.
20
+ */
21
+ export function validateRegistersDeclaration(decl, where = 'registers') {
22
+ assertInert(decl, where);
23
+ const fail = (msg) => {
24
+ throw new Error(`${where}: ${msg}`);
25
+ };
26
+ if (!isRecord(decl))
27
+ fail('must be an object');
28
+ const d = decl;
29
+ const keys = Object.keys(d);
30
+ if (keys.some((k) => k !== 'entity' && k !== 'edge')) {
31
+ fail(`unknown key "${keys.find((k) => k !== 'entity' && k !== 'edge')}"; use "entity" or "edge"`);
32
+ }
33
+ if ((d.entity === undefined) === (d.edge === undefined)) {
34
+ fail('declare exactly one of "entity" or "edge"');
35
+ }
36
+ if (d.entity !== undefined) {
37
+ const e = d.entity;
38
+ if (!isRecord(e))
39
+ fail('entity must be an object');
40
+ checkKeys(e, ENTITY_KEYS, `${where}.entity`);
41
+ optionalName(e.type, `${where}.entity.type`);
42
+ requireName(e.idFrom, `${where}.entity.idFrom`);
43
+ if (e.scope !== undefined && e.scope !== 'site' && e.scope !== 'page') {
44
+ fail(`entity.scope must be "site" or "page"`);
45
+ }
46
+ const dataKeys = checkData(e.data, `${where}.entity.data`, true);
47
+ if (e.aliases !== undefined) {
48
+ const a = e.aliases;
49
+ if (!isRecord(a))
50
+ fail('entity.aliases must be an object');
51
+ checkKeys(a, new Set(['from', 'separator']), `${where}.entity.aliases`);
52
+ requireName(a.from, `${where}.entity.aliases.from`);
53
+ if (a.separator !== undefined && (typeof a.separator !== 'string' || a.separator === '')) {
54
+ fail('entity.aliases.separator must be a non-empty string');
55
+ }
56
+ // Aliases are expanded in Phase 3 from the registered entry, so the
57
+ // value has to be in the bag.
58
+ if (dataKeys !== 'json' && !dataKeys.includes(a.from)) {
59
+ fail(`entity.aliases.from "${a.from}" must name a key of entity.data`);
60
+ }
61
+ }
62
+ }
63
+ if (d.edge !== undefined) {
64
+ const e = d.edge;
65
+ if (!isRecord(e))
66
+ fail('edge must be an object');
67
+ checkKeys(e, EDGE_KEYS, `${where}.edge`);
68
+ optionalName(e.type, `${where}.edge.type`);
69
+ requireName(e.from, `${where}.edge.from`);
70
+ requireName(e.to, `${where}.edge.to`);
71
+ const dataKeys = checkData(e.data, `${where}.edge.data`, false);
72
+ const bagKeys = ['from', 'to', ...dataKeys, 'name'];
73
+ for (const field of ['kind', 'bidirectional']) {
74
+ const v = e[field];
75
+ if (v === undefined && field === 'bidirectional')
76
+ continue;
77
+ if (field === 'kind' && typeof v === 'string') {
78
+ if (v === '')
79
+ fail('edge.kind must not be empty');
80
+ continue;
81
+ }
82
+ if (field === 'bidirectional' && typeof v === 'boolean')
83
+ continue;
84
+ if (!isRecord(v))
85
+ fail(`edge.${field} must be a literal or { field }`);
86
+ checkKeys(v, new Set(['field']), `${where}.edge.${field}`);
87
+ const name = v.field;
88
+ requireName(name, `${where}.edge.${field}.field`);
89
+ if (!bagKeys.includes(name)) {
90
+ fail(`edge.${field}.field "${name}" must name a key of the edge's data bag`);
91
+ }
92
+ }
93
+ }
94
+ }
95
+ function isRecord(v) {
96
+ return !!v && typeof v === 'object' && !Array.isArray(v);
97
+ }
98
+ function checkKeys(rec, allowed, where) {
99
+ for (const k of Object.keys(rec)) {
100
+ if (!allowed.has(k)) {
101
+ throw new Error(`${where}: unknown key "${k}" (allowed: ${[...allowed].join(', ')})`);
102
+ }
103
+ }
104
+ }
105
+ function requireName(v, where) {
106
+ if (typeof v !== 'string' || v === '')
107
+ throw new Error(`${where} must be a non-empty string`);
108
+ }
109
+ function optionalName(v, where) {
110
+ if (v !== undefined)
111
+ requireName(v, where);
112
+ }
113
+ /** Validate a `data` declaration and return the bag keys it produces, or
114
+ * `'json'` for the JSON form (whose keys are not known until build time). */
115
+ function checkData(data, where, allowJson) {
116
+ if (data === undefined)
117
+ return [];
118
+ if (isRecord(data)) {
119
+ if (!allowJson)
120
+ throw new Error(`${where} must be a list`);
121
+ checkKeys(data, new Set(['json']), where);
122
+ requireName(data.json, `${where}.json`);
123
+ return 'json';
124
+ }
125
+ if (!Array.isArray(data))
126
+ throw new Error(`${where} must be a list or { json }`);
127
+ const keys = [];
128
+ for (const entry of dataEntries(data, where)) {
129
+ if (keys.includes(entry.key))
130
+ throw new Error(`${where}: key "${entry.key}" appears twice`);
131
+ keys.push(entry.key);
132
+ }
133
+ return keys;
134
+ }
135
+ function dataEntries(data, where = 'data') {
136
+ return data.map((entry) => {
137
+ if (typeof entry === 'string') {
138
+ requireName(entry, where);
139
+ return { key: entry, source: entry };
140
+ }
141
+ const pairs = isRecord(entry) ? Object.entries(entry) : [];
142
+ if (pairs.length !== 1) {
143
+ throw new Error(`${where}: an entry is a source name or a single { key: source } pair`);
144
+ }
145
+ const [key, source] = pairs[0];
146
+ requireName(key, where);
147
+ requireName(source, `${where}.${key}`);
148
+ return { key, source: source };
149
+ });
150
+ }
151
+ /** No functions, no class instances, nothing `JSON` would drop or reshape:
152
+ * the declaration must round-trip through `JSON.parse(JSON.stringify(…))`. */
153
+ function assertInert(v, where) {
154
+ if (v === null || typeof v === 'string' || typeof v === 'boolean')
155
+ return;
156
+ if (Array.isArray(v)) {
157
+ for (const [i, x] of v.entries())
158
+ assertInert(x, `${where}[${i}]`);
159
+ return;
160
+ }
161
+ if (typeof v === 'object' && Object.getPrototypeOf(v) === Object.prototype) {
162
+ for (const [k, x] of Object.entries(v)) {
163
+ if (x === undefined)
164
+ throw new Error(`${where}.${k}: undefined is not a value; omit the key`);
165
+ assertInert(x, `${where}.${k}`);
166
+ }
167
+ return;
168
+ }
169
+ throw new Error(`${where}: a registers declaration holds only strings, booleans, lists and plain objects ` +
170
+ `(found ${typeof v === 'function' ? 'a function' : typeof v}) — ADR-036`);
171
+ }
172
+ // ---------------------------------------------------------------------------
173
+ // Sources
174
+ // ---------------------------------------------------------------------------
175
+ /** Every source a declaration reads from the rune's output, with the role it
176
+ * plays — what the validate-time audit and `inspect` check. */
177
+ export function registersSources(decl) {
178
+ const out = [];
179
+ if (decl.entity) {
180
+ out.push({ source: decl.entity.idFrom, role: 'idFrom' });
181
+ const data = decl.entity.data;
182
+ if (data && !Array.isArray(data)) {
183
+ out.push({ source: data.json, role: 'data (json)' });
184
+ }
185
+ else if (data) {
186
+ for (const { key, source } of dataEntries(data)) {
187
+ out.push({ source, role: `data.${key}` });
188
+ }
189
+ }
190
+ }
191
+ if (decl.edge) {
192
+ out.push({ source: decl.edge.from, role: 'from' });
193
+ out.push({ source: decl.edge.to, role: 'to' });
194
+ for (const { key, source } of dataEntries(decl.edge.data ?? [])) {
195
+ out.push({ source, role: `data.${key}` });
196
+ }
197
+ }
198
+ return out;
199
+ }
200
+ function isTag(n) {
201
+ return (!!n &&
202
+ typeof n === 'object' &&
203
+ (Markdoc.Tag.isTag(n) || n.$$mdtype === 'Tag'));
204
+ }
205
+ /** The first node inside this rune carrying `data-name=<name>`. Bounded at
206
+ * nested runes: a name is unique per rune, and a `character-section` inside a
207
+ * `character` names its own heading `name` too (see `findAllByName`). */
208
+ function findRef(root, name) {
209
+ for (const c of root.children ?? []) {
210
+ if (!isTag(c))
211
+ continue;
212
+ if (c.attributes?.['data-rune'] !== undefined)
213
+ continue;
214
+ if (c.attributes?.['data-name'] === name)
215
+ return c;
216
+ const hit = findRef(c, name);
217
+ if (hit)
218
+ return hit;
219
+ }
220
+ return undefined;
221
+ }
222
+ function text(node) {
223
+ if (typeof node === 'string')
224
+ return node;
225
+ if (!isTag(node))
226
+ return '';
227
+ return (node.children ?? []).map(text).join('');
228
+ }
229
+ /** Read one source off a rune's tag: a ref's text, else its field-bag value,
230
+ * else `''`. The D3 rule — see the module comment. */
231
+ export function readRegistersSource(tag, source) {
232
+ const ref = findRef(tag, source);
233
+ if (ref)
234
+ return text(ref).trim();
235
+ return readField(tag, source) ?? '';
236
+ }
237
+ /**
238
+ * Sources a declaration names that the rune does not provide — WORK-611.
239
+ *
240
+ * The same rule `auditSchemaSources` applies to a schema table: a source
241
+ * resolves if a node in the rune's output carries the name, if the field bag
242
+ * has it, or if it is one of the rune's declared attributes (an optional
243
+ * attribute left unset emits nothing, which is "this input did not exercise
244
+ * it", not a typo). What is left resolves to nothing, ever.
245
+ *
246
+ * `tree` is the rune's `Markdoc.transform` output, before the identity
247
+ * transform consumes the bag.
248
+ */
249
+ export function auditRegistersSources(decl, tree, declaredAttributes = []) {
250
+ const root = findRuneRoot(tree);
251
+ const bag = root ? parseBag(root) : {};
252
+ const declared = new Set();
253
+ for (const a of declaredAttributes) {
254
+ declared.add(a);
255
+ declared.add(kebab(a));
256
+ }
257
+ return registersSources(decl).filter(({ source }) => !(declared.has(source) ||
258
+ declared.has(kebab(source)) ||
259
+ Object.hasOwn(bag, source) ||
260
+ (root && findRef(root, source))));
261
+ }
262
+ function findRuneRoot(node) {
263
+ if (Array.isArray(node)) {
264
+ for (const c of node) {
265
+ const hit = findRuneRoot(c);
266
+ if (hit)
267
+ return hit;
268
+ }
269
+ return undefined;
270
+ }
271
+ if (!isTag(node))
272
+ return undefined;
273
+ if (node.attributes?.['data-rune'] !== undefined)
274
+ return node;
275
+ return findRuneRoot(node.children ?? []);
276
+ }
277
+ function parseBag(tag) {
278
+ const raw = tag.attributes?.['data-rune-fields'];
279
+ if (typeof raw !== 'string')
280
+ return {};
281
+ try {
282
+ return JSON.parse(raw);
283
+ }
284
+ catch {
285
+ return {};
286
+ }
287
+ }
288
+ const kebab = (s) => s.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
289
+ /** One line per declaration, for `inspect` and the reference. */
290
+ export function describeRegisters(decl, rune) {
291
+ const lines = [];
292
+ const dataLine = (data) => {
293
+ if (!data)
294
+ return '(none)';
295
+ if (!Array.isArray(data))
296
+ return `the JSON object in "${data.json}"`;
297
+ return dataEntries(data)
298
+ .map(({ key, source }) => (key === source ? key : `${key} <- ${source}`))
299
+ .join(', ');
300
+ };
301
+ if (decl.entity) {
302
+ const e = decl.entity;
303
+ lines.push(`entity ${e.type ?? rune} (scope: ${e.scope ?? 'site'})`);
304
+ lines.push(` id <- ${e.idFrom}`);
305
+ lines.push(` data ${dataLine(e.data)}`);
306
+ if (e.aliases) {
307
+ lines.push(` aliases <- ${e.aliases.from}, split on "${e.aliases.separator ?? ','}"`);
308
+ }
309
+ }
310
+ if (decl.edge) {
311
+ const e = decl.edge;
312
+ const kind = typeof e.kind === 'string' ? e.kind : `data.${e.kind.field}`;
313
+ const bidi = e.bidirectional === undefined
314
+ ? 'no'
315
+ : typeof e.bidirectional === 'boolean'
316
+ ? String(e.bidirectional)
317
+ : `data.${e.bidirectional.field}`;
318
+ lines.push(`edge ${e.type ?? rune} (id: from→to)`);
319
+ lines.push(` from <- ${e.from}`);
320
+ lines.push(` to <- ${e.to}`);
321
+ lines.push(` kind ${kind}`);
322
+ lines.push(` both ${bidi}`);
323
+ lines.push(` data from, to, ${e.data?.length ? `${dataLine(e.data)}, ` : ''}name`);
324
+ }
325
+ return lines;
326
+ }
327
+ export { dataEntries as registersDataEntries };
328
+ //# sourceMappingURL=registers.js.map
@@ -0,0 +1 @@
1
+ {"version":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AAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACnC,KAAK,CAAC,IAAI,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * content model, producing named fields without per-rune imperative code.
6
6
  */
7
7
  import type { Node } from '@markdoc/markdoc';
8
- import type { ContentModel, ContentFieldDefinition, DelimitedModel, SectionsModel, ContentModelCondition, ItemModel, ResolvedContent } from '@refrakt-md/types';
8
+ import type { ContentModel, ContentFieldDefinition, DelimitedModel, SectionsModel, ContentModelCondition, ItemModel, ResolvedContent, StructuralContentModel } from '@refrakt-md/types';
9
9
  export interface ResolveResult {
10
10
  /** Resolved content fields. */
11
11
  content: ResolvedContent;
@@ -76,5 +76,13 @@ export declare function resolve(children: Node[], model: ContentModel, attribute
76
76
  * Full resolution entry point: extracts special tags (tint, bg), then
77
77
  * resolves the content model.
78
78
  */
79
+ /**
80
+ * The structural model `resolveContentModel` would resolve these children
81
+ * against: a conditional model's matching branch (followed through nested
82
+ * conditionals), or the model itself. Evaluated over the same filtered children,
83
+ * so a `tint` / `bg` child cannot tip a `hasChild` condition here when it does
84
+ * not there.
85
+ */
86
+ export declare function selectStructuralModel(children: Node[], model: ContentModel, attributes?: Record<string, unknown>): StructuralContentModel;
79
87
  export declare function resolveContentModel(children: Node[], model: ContentModel, attributes?: Record<string, unknown>, locale?: string): ResolveResult;
80
88
  //# sourceMappingURL=resolver.d.ts.map