@refrakt-md/runes 0.14.4 → 0.15.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 (64) hide show
  1. package/dist/config.d.ts +40 -4
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +154 -88
  4. package/dist/config.js.map +1 -1
  5. package/dist/drawer-pipeline.d.ts +33 -0
  6. package/dist/drawer-pipeline.d.ts.map +1 -0
  7. package/dist/drawer-pipeline.js +206 -0
  8. package/dist/drawer-pipeline.js.map +1 -0
  9. package/dist/expand-pipeline.d.ts +51 -0
  10. package/dist/expand-pipeline.d.ts.map +1 -0
  11. package/dist/expand-pipeline.js +305 -0
  12. package/dist/expand-pipeline.js.map +1 -0
  13. package/dist/index.d.ts +9 -3
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +32 -3
  16. package/dist/index.js.map +1 -1
  17. package/dist/lang-map.d.ts +32 -0
  18. package/dist/lang-map.d.ts.map +1 -0
  19. package/dist/lang-map.js +76 -0
  20. package/dist/lang-map.js.map +1 -0
  21. package/dist/lib/read-file.d.ts +78 -0
  22. package/dist/lib/read-file.d.ts.map +1 -0
  23. package/dist/lib/read-file.js +166 -0
  24. package/dist/lib/read-file.js.map +1 -0
  25. package/dist/nodes.d.ts.map +1 -1
  26. package/dist/nodes.js +12 -1
  27. package/dist/nodes.js.map +1 -1
  28. package/dist/outline-scope.d.ts +29 -0
  29. package/dist/outline-scope.d.ts.map +1 -0
  30. package/dist/outline-scope.js +149 -0
  31. package/dist/outline-scope.js.map +1 -0
  32. package/dist/plugins.d.ts +13 -0
  33. package/dist/plugins.d.ts.map +1 -1
  34. package/dist/plugins.js +65 -1
  35. package/dist/plugins.js.map +1 -1
  36. package/dist/snippet-pipeline.d.ts +42 -0
  37. package/dist/snippet-pipeline.d.ts.map +1 -0
  38. package/dist/snippet-pipeline.js +219 -0
  39. package/dist/snippet-pipeline.js.map +1 -0
  40. package/dist/tags/drawer.d.ts +26 -0
  41. package/dist/tags/drawer.d.ts.map +1 -0
  42. package/dist/tags/drawer.js +134 -0
  43. package/dist/tags/drawer.js.map +1 -0
  44. package/dist/tags/expand.d.ts +22 -0
  45. package/dist/tags/expand.d.ts.map +1 -0
  46. package/dist/tags/expand.js +76 -0
  47. package/dist/tags/expand.js.map +1 -0
  48. package/dist/tags/snippet.d.ts +19 -0
  49. package/dist/tags/snippet.d.ts.map +1 -0
  50. package/dist/tags/snippet.js +49 -0
  51. package/dist/tags/snippet.js.map +1 -0
  52. package/dist/util.d.ts +11 -0
  53. package/dist/util.d.ts.map +1 -1
  54. package/dist/util.js +35 -0
  55. package/dist/util.js.map +1 -1
  56. package/dist/xref-patterns.d.ts +57 -0
  57. package/dist/xref-patterns.d.ts.map +1 -0
  58. package/dist/xref-patterns.js +140 -0
  59. package/dist/xref-patterns.js.map +1 -0
  60. package/dist/xref-resolve.d.ts +22 -5
  61. package/dist/xref-resolve.d.ts.map +1 -1
  62. package/dist/xref-resolve.js +203 -79
  63. package/dist/xref-resolve.js.map +1 -1
  64. package/package.json +3 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snippet-pipeline.js","sourceRoot":"","sources":["../src/snippet-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAGvC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAE7B;;;;sEAIsE;AACtE,SAAS,qBAAqB,CAAC,KAAc,EAAE,SAA8C;IAC5F,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IA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QACxC,IAAI,CAAC,KAAK,CAAC;YAAE,OAAO,GAAG,IAAI,CAAC;QAC5B,OAAO,CAAC,CAAC;IACV,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,OAAO;QAAE,OAAO,GAAG,CAAC;IAEzB,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,UAAU,EAAE,WAAoB,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,eAAe,CAAC,MAAgC;IACxD,MAAM,KAAK,GAAG,MAAM,CAAC,UAAqC,CAAC;IAC3D,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,KAAK,CAAC,oBAAoB,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE9G,MAAM,WAAW,GAA4B;QAC5C,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,SAAS;QACtB,kBAAkB,EAAE,MAAM;KAC1B,CAAC;IACF,IAAI,SAAS;QAAE,WAAW,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;IAErD,OAAO,IAAI,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC,MAAM,CAAU,CAAC,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Drawer rune (SPEC-060).
3
+ *
4
+ * Body-only modal panel: declares an addressable region by id and renders
5
+ * its body as a visible in-flow `<section>` at the authored position. With
6
+ * JS (WORK-258 behaviors), the section is enhanced into a `<dialog>` and
7
+ * xref clicks open it via `showModal()`. Without JS, the body is visible
8
+ * inline and xref clicks scroll to it via fragment navigation.
9
+ *
10
+ * Triggers are not part of this rune — any `{% ref "drawer-id" /%}` on
11
+ * the same page resolves to `<a href="#drawer-{id}" data-target-type="drawer">`
12
+ * (via SPEC-065's `data-target-type` propagation, WORK-253). The
13
+ * progressive-enhancement layer queries that marker.
14
+ *
15
+ * Title heading level: `headingLevel="3"` etc. sets the level explicitly.
16
+ * Without an explicit level, the schema emits a sentinel `data-drawer-title-auto`
17
+ * marker; the corePipelineHooks.postProcess walk replaces it with an
18
+ * `h{n}` element one level deeper than the nearest preceding heading on
19
+ * the page (clamped to 1-6, default h2 when no preceding heading exists).
20
+ */
21
+ import Markdoc from '@markdoc/markdoc';
22
+ /** Marker attribute placed on the title heading when `headingLevel` is omitted.
23
+ * The core postProcess walk replaces the tag with `h{n}` based on outline depth. */
24
+ export declare const DRAWER_TITLE_AUTO_MARKER = "data-drawer-title-auto";
25
+ export declare const drawer: Markdoc.Schema;
26
+ //# sourceMappingURL=drawer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../src/tags/drawer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAMvC;qFACqF;AACrF,eAAO,MAAM,wBAAwB,2BAA2B,CAAC;AAKjE,eAAO,MAAM,MAAM,gBAgHjB,CAAC"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Drawer rune (SPEC-060).
3
+ *
4
+ * Body-only modal panel: declares an addressable region by id and renders
5
+ * its body as a visible in-flow `<section>` at the authored position. With
6
+ * JS (WORK-258 behaviors), the section is enhanced into a `<dialog>` and
7
+ * xref clicks open it via `showModal()`. Without JS, the body is visible
8
+ * inline and xref clicks scroll to it via fragment navigation.
9
+ *
10
+ * Triggers are not part of this rune — any `{% ref "drawer-id" /%}` on
11
+ * the same page resolves to `<a href="#drawer-{id}" data-target-type="drawer">`
12
+ * (via SPEC-065's `data-target-type` propagation, WORK-253). The
13
+ * progressive-enhancement layer queries that marker.
14
+ *
15
+ * Title heading level: `headingLevel="3"` etc. sets the level explicitly.
16
+ * Without an explicit level, the schema emits a sentinel `data-drawer-title-auto`
17
+ * marker; the corePipelineHooks.postProcess walk replaces it with an
18
+ * `h{n}` element one level deeper than the nearest preceding heading on
19
+ * the page (clamped to 1-6, default h2 when no preceding heading exists).
20
+ */
21
+ import Markdoc from '@markdoc/markdoc';
22
+ const { Tag } = Markdoc;
23
+ import { createContentModelSchema, createComponentRenderable, asNodes } from '../lib/index.js';
24
+ import { RenderableNodeCursor } from '../lib/renderable.js';
25
+ /** Marker attribute placed on the title heading when `headingLevel` is omitted.
26
+ * The core postProcess walk replaces the tag with `h{n}` based on outline depth. */
27
+ export const DRAWER_TITLE_AUTO_MARKER = 'data-drawer-title-auto';
28
+ const drawerSides = ['right', 'left', 'top', 'bottom'];
29
+ const drawerSizes = ['sm', 'md', 'lg'];
30
+ export const drawer = createContentModelSchema({
31
+ attributes: {
32
+ id: {
33
+ type: String,
34
+ required: true,
35
+ description: 'Stable id for the drawer. Used in entity registration and as the `id="drawer-{value}"` on the rendered element so xref triggers can target it via fragment.',
36
+ },
37
+ title: {
38
+ type: String,
39
+ required: false,
40
+ description: 'Panel heading text. Rendered in the drawer header (or as a heading in the no-JS in-flow rendering).',
41
+ },
42
+ headingLevel: {
43
+ type: Number,
44
+ required: false,
45
+ description: 'Heading level (1-6) for the title. When omitted, the level is auto-detected from outline position (one deeper than the nearest preceding heading). Out-of-range values are clamped to the 1-6 range.',
46
+ },
47
+ shortcut: {
48
+ type: String,
49
+ required: false,
50
+ description: 'Keyboard shortcut that opens the drawer when behaviors are loaded (e.g. ".", "cmd+k"). Surfaces as `data-shortcut`; the progressive-enhancement layer wires the listener.',
51
+ },
52
+ side: {
53
+ type: String,
54
+ required: false,
55
+ matches: drawerSides.slice(),
56
+ description: 'Edge the panel slides from when enhanced. Defaults to "right".',
57
+ },
58
+ size: {
59
+ type: String,
60
+ required: false,
61
+ matches: drawerSizes.slice(),
62
+ description: 'Panel size. "sm" / "md" (default) / "lg" — width for left/right sides, height for top/bottom.',
63
+ },
64
+ },
65
+ contentModel: {
66
+ type: 'sequence',
67
+ fields: [
68
+ { name: 'body', match: 'any', optional: true, greedy: true },
69
+ ],
70
+ },
71
+ transform(resolved, attrs, config) {
72
+ const drawerId = attrs.id;
73
+ const titleText = attrs.title;
74
+ const side = attrs.side ?? 'right';
75
+ const size = attrs.size ?? 'md';
76
+ // Title heading: explicit level → `h{n}`, otherwise emit a sentinel
77
+ // `h3` placeholder marked with `data-drawer-title-auto`. The core
78
+ // postProcess walk inspects outline depth and rewrites the tag name.
79
+ // We pick `h3` as the sentinel because it's the no-postProcess
80
+ // fallback (most drawers live under an h2 page section).
81
+ const clampedLevel = typeof attrs.headingLevel === 'number'
82
+ ? Math.min(6, Math.max(1, Math.trunc(attrs.headingLevel)))
83
+ : undefined;
84
+ const titleTag = titleText
85
+ ? (clampedLevel
86
+ ? new Tag(`h${clampedLevel}`, {}, [titleText])
87
+ : new Tag('h3', { [DRAWER_TITLE_AUTO_MARKER]: 'true' }, [titleText]))
88
+ : undefined;
89
+ const closeButton = new Tag('button', {
90
+ type: 'button',
91
+ 'aria-label': 'Close',
92
+ hidden: true,
93
+ }, ['×']);
94
+ const headerChildren = [];
95
+ if (titleTag)
96
+ headerChildren.push(titleTag);
97
+ headerChildren.push(closeButton);
98
+ const header = new Tag('header', {}, headerChildren);
99
+ const body = new RenderableNodeCursor(Markdoc.transform(asNodes(resolved.body), config)).wrap('div');
100
+ // Property meta tags drive engine modifier-from-meta + data-attribute
101
+ // derivation. We always emit `side` and `size` so the engine applies
102
+ // the BEM modifier even when the author didn't specify them (the
103
+ // default "right"/"md" still need their data-attribute on the wrapper).
104
+ // `shortcut` is only emitted when set — its absence shouldn't appear
105
+ // as `data-shortcut=""` on the wrapper.
106
+ const properties = {
107
+ side: new Tag('meta', { content: side }),
108
+ size: new Tag('meta', { content: size }),
109
+ };
110
+ if (attrs.shortcut) {
111
+ properties.shortcut = new Tag('meta', { content: attrs.shortcut });
112
+ }
113
+ const renderable = createComponentRenderable({
114
+ rune: 'drawer',
115
+ tag: 'section',
116
+ id: `drawer-${drawerId}`,
117
+ properties,
118
+ refs: {
119
+ header,
120
+ ...(titleTag ? { title: titleTag } : {}),
121
+ close: closeButton,
122
+ body: body.tag('div'),
123
+ },
124
+ children: [...Object.values(properties), header, body.next()],
125
+ });
126
+ // `data-drawer-id` carries the author-supplied id (before the
127
+ // `drawer-` prefix) for register-hook consumption. The register
128
+ // scan reads this to know what id the entity should have without
129
+ // re-parsing the html id.
130
+ renderable.attributes['data-drawer-id'] = drawerId;
131
+ return renderable;
132
+ },
133
+ });
134
+ //# sourceMappingURL=drawer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawer.js","sourceRoot":"","sources":["../../src/tags/drawer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAEvC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D;qFACqF;AACrF,MAAM,CAAC,MAAM,wBAAwB,GAAG,wBAAwB,CAAC;AAEjE,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAU,CAAC;AAChE,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAEhD,MAAM,CAAC,MAAM,MAAM,GAAG,wBAAwB,CAAC;IAC9C,UAAU,EAAE;QACX,EAAE,EAAE;YACH,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,6JAA6J;SAC1K;QACD,KAAK,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,qGAAqG;SAClH;QACD,YAAY,EAAE;YACb,IAAI,EAAE,MAAM;YACZ,QAAQ,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G,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QACpE,CAAC;QAED,MAAM,UAAU,GAAG,yBAAyB,CAAC;YAC5C,IAAI,EAAE,QAAQ;YACd,GAAG,EAAE,SAAS;YACd,EAAE,EAAE,UAAU,QAAQ,EAAE;YACxB,UAAU;YACV,IAAI,EAAE;gBACL,MAAM;gBACN,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxC,KAAK,EAAE,WAAW;gBAClB,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;aACrB;YACD,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;SAC7D,CAAC,CAAC;QAEH,8DAA8D;QAC9D,gEAAgE;QAChE,iEAAiE;QACjE,0BAA0B;QACzB,UAAU,CAAC,UAAsC,CAAC,gBAAgB,CAAC,GAAG,QAAQ,CAAC;QAEhF,OAAO,UAAU,CAAC;IACnB,CAAC;CACD,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Expand rune (SPEC-066, WORK-260).
3
+ *
4
+ * Inline-substitution counterpart to `{% ref %}`: same registry lookup
5
+ * chain, different output mode (inline content instead of an anchor).
6
+ * Schema is self-closing and emits a placeholder; the postProcess hook
7
+ * (`expand-pipeline.ts`) walks for placeholders, resolves the entity
8
+ * from the registry, reads its `sourceFile`, calls the plugin's
9
+ * `extract()` to get the embeddable subtree, processes headings, and
10
+ * substitutes the content inline. The wrapper is a `<section
11
+ * data-rune="expand">` with `data-outline-scope` set so the WORK-259
12
+ * walkers automatically TOC-isolate the embed and namespace its
13
+ * heading IDs.
14
+ */
15
+ import type { Schema } from '@markdoc/markdoc';
16
+ /** Sentinel attribute value used to identify expand placeholders in the
17
+ * renderable tree. PostProcess queries for `data-rune="expand-pending"`
18
+ * to find tags awaiting resolution. After substitution the wrapper
19
+ * carries `data-rune="expand"`. */
20
+ export declare const EXPAND_PLACEHOLDER_MARKER = "expand-pending";
21
+ export declare const expand: Schema;
22
+ //# sourceMappingURL=expand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../src/tags/expand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAgB,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG7D;;;oCAGoC;AACpC,eAAO,MAAM,yBAAyB,mBAAmB,CAAC;AAE1D,eAAO,MAAM,MAAM,EAAE,MAmDpB,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Expand rune (SPEC-066, WORK-260).
3
+ *
4
+ * Inline-substitution counterpart to `{% ref %}`: same registry lookup
5
+ * chain, different output mode (inline content instead of an anchor).
6
+ * Schema is self-closing and emits a placeholder; the postProcess hook
7
+ * (`expand-pipeline.ts`) walks for placeholders, resolves the entity
8
+ * from the registry, reads its `sourceFile`, calls the plugin's
9
+ * `extract()` to get the embeddable subtree, processes headings, and
10
+ * substitutes the content inline. The wrapper is a `<section
11
+ * data-rune="expand">` with `data-outline-scope` set so the WORK-259
12
+ * walkers automatically TOC-isolate the embed and namespace its
13
+ * heading IDs.
14
+ */
15
+ import Markdoc from '@markdoc/markdoc';
16
+ const { Tag } = Markdoc;
17
+ /** Sentinel attribute value used to identify expand placeholders in the
18
+ * renderable tree. PostProcess queries for `data-rune="expand-pending"`
19
+ * to find tags awaiting resolution. After substitution the wrapper
20
+ * carries `data-rune="expand"`. */
21
+ export const EXPAND_PLACEHOLDER_MARKER = 'expand-pending';
22
+ export const expand = {
23
+ selfClosing: true,
24
+ attributes: {
25
+ primary: {
26
+ type: String,
27
+ required: true,
28
+ description: 'Entity ID or name to substitute inline. Same lookup chain as xref.',
29
+ },
30
+ level: {
31
+ type: Number,
32
+ required: false,
33
+ description: 'Optional heading-demotion opt-in. When set, embedded headings shift by `N - 1` and the embed joins the host outline instead of staying TOC-isolated.',
34
+ },
35
+ type: {
36
+ type: String,
37
+ required: false,
38
+ description: 'Entity type hint for disambiguation when the same ID/name lives in multiple registries.',
39
+ },
40
+ canonical: {
41
+ type: Boolean,
42
+ required: false,
43
+ description: 'When true, append a visible "View canonical" link pointing at the entity\'s canonical URL.',
44
+ },
45
+ label: {
46
+ type: String,
47
+ required: false,
48
+ description: 'Custom label for the canonical link (only meaningful when `canonical=true`).',
49
+ },
50
+ },
51
+ transform(node, _config) {
52
+ const id = node.attributes.primary;
53
+ const level = node.attributes.level;
54
+ const typeHint = node.attributes.type;
55
+ const canonical = node.attributes.canonical === true;
56
+ const label = node.attributes.label;
57
+ const attrs = {
58
+ 'data-rune': EXPAND_PLACEHOLDER_MARKER,
59
+ 'data-expand-id': id,
60
+ };
61
+ if (typeof level === 'number')
62
+ attrs['data-expand-level'] = String(level);
63
+ if (typeHint)
64
+ attrs['data-expand-type'] = typeHint;
65
+ if (canonical)
66
+ attrs['data-expand-canonical'] = 'true';
67
+ if (label)
68
+ attrs['data-expand-label'] = label;
69
+ // The placeholder is a `<div>` rather than a `<span>` because the
70
+ // substituted content is block-level (the embedded rune's `<section>`).
71
+ // A `<span>` parent would produce invalid block-in-inline HTML once
72
+ // the postProcess substitutes content.
73
+ return new Tag('div', attrs, []);
74
+ },
75
+ };
76
+ //# sourceMappingURL=expand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expand.js","sourceRoot":"","sources":["../../src/tags/expand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAEvC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAExB;;;oCAGoC;AACpC,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAC;AAE1D,MAAM,CAAC,MAAM,MAAM,GAAW;IAC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,KAAK;YAAE,KAAK,CAAC,mBAAmB,CAAC,GAAG,KAAK,CAAC;QAE9C,kEAAkE;QAClE,wEAAwE;QACxE,oEAAoE;QACpE,uCAAuC;QACvC,OAAO,IAAI,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;IAClC,CAAC;CACD,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The `snippet` rune — embed a file's contents as a syntax-highlighted code
3
+ * block (SPEC-062).
4
+ *
5
+ * Implementation note: snippet is implemented as an **AST preprocessor**
6
+ * rather than a transform-time rune. Every `{% snippet %}` tag is replaced
7
+ * by a Markdoc `fence` node before the schema-driven transform runs (see
8
+ * `corePipelineHooks.preprocess` in `../config.ts`). By the time the transform
9
+ * reaches the AST, no snippet tags exist — only fences. So this schema's
10
+ * `transform` function is **unreachable in normal operation**.
11
+ *
12
+ * The schema still exists for tooling: `refrakt inspect snippet`, the
13
+ * contracts generator, attribute validation, and the rune-catalog docs all
14
+ * read from it. If the transform ever does execute (e.g., the core preprocess
15
+ * hook isn't registered for some reason), it throws a clear error pointing
16
+ * the user at the registration site.
17
+ */
18
+ export declare const snippet: import("@markdoc/markdoc").Schema;
19
+ //# sourceMappingURL=snippet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snippet.d.ts","sourceRoot":"","sources":["../../src/tags/snippet.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,OAAO,mCA+BlB,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { createContentModelSchema } from '../lib/index.js';
2
+ /**
3
+ * The `snippet` rune — embed a file's contents as a syntax-highlighted code
4
+ * block (SPEC-062).
5
+ *
6
+ * Implementation note: snippet is implemented as an **AST preprocessor**
7
+ * rather than a transform-time rune. Every `{% snippet %}` tag is replaced
8
+ * by a Markdoc `fence` node before the schema-driven transform runs (see
9
+ * `corePipelineHooks.preprocess` in `../config.ts`). By the time the transform
10
+ * reaches the AST, no snippet tags exist — only fences. So this schema's
11
+ * `transform` function is **unreachable in normal operation**.
12
+ *
13
+ * The schema still exists for tooling: `refrakt inspect snippet`, the
14
+ * contracts generator, attribute validation, and the rune-catalog docs all
15
+ * read from it. If the transform ever does execute (e.g., the core preprocess
16
+ * hook isn't registered for some reason), it throws a clear error pointing
17
+ * the user at the registration site.
18
+ */
19
+ export const snippet = createContentModelSchema({
20
+ attributes: {
21
+ path: {
22
+ type: String,
23
+ required: true,
24
+ description: 'Path to the source file, relative to the project root. Rejected if it escapes the root.',
25
+ },
26
+ lines: {
27
+ type: String,
28
+ required: false,
29
+ description: 'Line range. Formats: "10-25", "10-" (to EOF), "-20" (from start), "10" (single line). 1-indexed, inclusive.',
30
+ },
31
+ lang: {
32
+ type: String,
33
+ required: false,
34
+ description: 'Syntax-highlighting language hint. Overrides the extension-based inference.',
35
+ },
36
+ },
37
+ contentModel: { type: 'sequence', fields: [] },
38
+ transform(_resolved, _attrs) {
39
+ // Unreachable in normal operation — corePipelineHooks.preprocess
40
+ // replaces snippet tags with fence nodes before the transform runs.
41
+ // If you see this error, ensure your content pipeline runs the
42
+ // preprocess phase (call sites: packages/content/src/site.ts and the
43
+ // hook set assembled via createCorePipelineHooks).
44
+ throw new Error('snippet rune reached the transform phase — its preprocess hook was not wired through. ' +
45
+ 'Ensure the content pipeline runs registered `preprocess` hooks before `Markdoc.transform` ' +
46
+ '(snippet pre-resolves to a Markdoc `fence` node; see SPEC-062 § Composition).');
47
+ },
48
+ });
49
+ //# sourceMappingURL=snippet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snippet.js","sourceRoot":"","sources":["../../src/tags/snippet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,wBAAwB,CAAC;IAC/C,UAAU,EAAE;QACX,IAAI,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,yFAAyF;SACtG;QACD,KAAK,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,6GAA6G;SAC1H;QACD,IAAI,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,6EAA6E;SAC1F;KACD;IACD,YAAY,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE;IAC9C,SAAS,CAAC,SAAS,EAAE,MAAM;QAC1B,iEAAiE;QACjE,oEAAoE;QACpE,+DAA+D;QAC/D,qEAAqE;QACrE,mDAAmD;QACnD,MAAM,IAAI,KAAK,CACd,wFAAwF;YACxF,4FAA4F;YAC5F,+EAA+E,CAC/E,CAAC;IACH,CAAC;CACD,CAAC,CAAC"}
package/dist/util.d.ts CHANGED
@@ -19,5 +19,16 @@ export interface HeadingInfo {
19
19
  * IDs using the same algorithm as nodes.ts heading transform.
20
20
  */
21
21
  export declare function extractHeadings(node: Node): HeadingInfo[];
22
+ /**
23
+ * Find the text content of the first H1 heading in an AST.
24
+ *
25
+ * Walks depth-first, descending into both regular nodes and tag (rune)
26
+ * children. The first `heading` node with `level: 1` wins. Used by the
27
+ * content pipeline to derive `$page.title` when frontmatter doesn't set
28
+ * one — matches the author mental model of "the page's title is the H1
29
+ * the reader sees," including the common case where an H1 is wrapped in
30
+ * a layout rune (hero etc.).
31
+ */
32
+ export declare function firstH1(node: Node): string | undefined;
22
33
  export declare function headingsToList(options?: HeadingsToListOptions): (nodes: Node[]) => Markdoc.Node[];
23
34
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,kB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AW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW,EAAE,CA+BzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAyBtD;AAED,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,IAIpD,OAAO,IAAI,EAAE,oBAkCtB"}
package/dist/util.js CHANGED
@@ -62,6 +62,41 @@ export function extractHeadings(node) {
62
62
  walk(node);
63
63
  return headings;
64
64
  }
65
+ /**
66
+ * Find the text content of the first H1 heading in an AST.
67
+ *
68
+ * Walks depth-first, descending into both regular nodes and tag (rune)
69
+ * children. The first `heading` node with `level: 1` wins. Used by the
70
+ * content pipeline to derive `$page.title` when frontmatter doesn't set
71
+ * one — matches the author mental model of "the page's title is the H1
72
+ * the reader sees," including the common case where an H1 is wrapped in
73
+ * a layout rune (hero etc.).
74
+ */
75
+ export function firstH1(node) {
76
+ let found;
77
+ function walk(n) {
78
+ if (n.type === 'heading' && n.attributes.level === 1) {
79
+ const textParts = [];
80
+ for (const child of n.walk()) {
81
+ if (child.type === 'text' && child.attributes.content) {
82
+ textParts.push(child.attributes.content);
83
+ }
84
+ }
85
+ // Text nodes already carry their own surrounding whitespace, so joining
86
+ // with `''` (rather than `' '`) avoids doubling spaces when a heading
87
+ // contains inline formatting like `# Hello **strong** world`.
88
+ found = textParts.join('');
89
+ return true;
90
+ }
91
+ for (const child of n.children) {
92
+ if (walk(child))
93
+ return true;
94
+ }
95
+ return false;
96
+ }
97
+ walk(node);
98
+ return found;
99
+ }
65
100
  export function headingsToList(options) {
66
101
  const explicitLevel = options?.level;
67
102
  const include = options?.include;
package/dist/util.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CAAC;YAClB,CAAC;iBAAM,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;gBAC9E,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtC,IAAI,QAAQ,EAAE,CAAC;oBACb,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACtB,MAAM;YACR,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,CAAC,GAAG,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;IAClC,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Cross-reference pattern compilation.
3
+ *
4
+ * Compiles user-authored `XrefPattern` config entries from `refrakt.config.json`
5
+ * into validated, ready-to-use `CompiledXrefPattern` objects. The runtime
6
+ * resolver (in `xref-resolve.ts`) consumes the compiled forms to turn
7
+ * unresolved xref IDs into URLs.
8
+ *
9
+ * Validation rules (per SPEC-065):
10
+ * - `match` must compile as a JavaScript regex; anchored to whole-string match
11
+ * by default (`^` and `$` auto-applied unless explicit anchors are present
12
+ * at the start/end of the pattern).
13
+ * - `template` placeholders must each be `id` or a named group of the regex.
14
+ * - `type` defaults to `"external"`. The value `"unresolved"` is reserved.
15
+ * - `label` defaults to `"{id}"` and uses the same placeholder syntax as
16
+ * `template`.
17
+ * - Duplicate `match` strings across entries are flagged as a warning (not an
18
+ * error; first-wins ordering still produces deterministic behaviour).
19
+ */
20
+ import type { XrefPattern } from '@refrakt-md/types';
21
+ /** A pattern entry compiled and ready to be matched against an xref ID at
22
+ * resolve time. Authored {@link XrefPattern}s in `refrakt.config.json` are
23
+ * turned into this shape once per build via {@link compileXrefPatterns}. */
24
+ export interface CompiledXrefPattern {
25
+ /** The compiled regex (already wrapped in whole-string anchors if needed). */
26
+ match: RegExp;
27
+ /** URL template — same string the author wrote, ready for placeholder
28
+ * substitution by the resolver. */
29
+ template: string;
30
+ /** CSS modifier class value. Defaulted to `"external"` if the author
31
+ * omitted it. */
32
+ type: string;
33
+ /** Link-text template. Defaulted to `"{id}"` if the author omitted it. */
34
+ label: string;
35
+ /** Named groups declared in the regex, in declaration order. The resolver
36
+ * uses these (plus the implicit `{id}`) to validate template placeholders
37
+ * at match time. */
38
+ groupNames: string[];
39
+ }
40
+ /** Diagnostics produced by {@link compileXrefPatterns}. Compilation never
41
+ * throws — fatal cases (invalid regex, unknown placeholder, reserved type)
42
+ * are surfaced via `errors`; soft diagnostics (duplicate `match`) via
43
+ * `warnings`. Adapters decide how to render them. */
44
+ export interface CompiledXrefPatternsResult {
45
+ patterns: CompiledXrefPattern[];
46
+ errors: string[];
47
+ warnings: string[];
48
+ }
49
+ /**
50
+ * Compile a list of authored xref patterns into runtime-ready form.
51
+ *
52
+ * Returns the compiled patterns alongside errors and warnings — callers
53
+ * (typically the content-loader bootstrap) decide whether errors should
54
+ * throw, log, or be passed back to the user.
55
+ */
56
+ export declare function compileXrefPatterns(patterns: XrefPattern[] | undefined): CompiledXrefPatternsResult;
57
+ //# sourceMappingURL=xref-patterns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xref-patterns.d.ts","sourceRoot":"","sources":["../src/xref-patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;6EAE6E;AAC7E,MAAM,WAAW,mBAAmB;IACnC,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd;wCACoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB;sBACkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd;;yBAEqB;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;sDAGsD;AACtD,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACnB;AA+CD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAClC,QAAQ,EAAE,WAAW,EAAE,GAAG,SAAS,GACjC,0BAA0B,CA8E5B"}