@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,140 @@
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
+ /** Reserved `type` values that cannot be used in pattern entries. */
21
+ const RESERVED_TYPES = new Set(['unresolved']);
22
+ /** Match `(?<name>` declarations in a regex source. Used to enumerate named
23
+ * groups statically (JS `RegExp` instances don't expose group names without
24
+ * a successful match). */
25
+ const NAMED_GROUP_RE = /\(\?<([a-zA-Z_$][a-zA-Z0-9_$]*)>/g;
26
+ /** Match `{name}` placeholders in template / label strings. */
27
+ const PLACEHOLDER_RE = /\{([a-zA-Z_$][a-zA-Z0-9_$]*)\}/g;
28
+ /** Apply whole-string anchoring to the pattern source. If the author already
29
+ * added `^` and `$` (at the very start and end), the source is used as-is.
30
+ * Otherwise the source is wrapped in `^(?:...)$`. Stripping any partial
31
+ * anchors first avoids double-anchoring like `^^...$$`. */
32
+ function anchorPatternSource(source) {
33
+ if (source.startsWith('^') && source.endsWith('$'))
34
+ return source;
35
+ let inner = source;
36
+ if (inner.startsWith('^'))
37
+ inner = inner.slice(1);
38
+ if (inner.endsWith('$'))
39
+ inner = inner.slice(0, -1);
40
+ return `^(?:${inner})$`;
41
+ }
42
+ /** Extract named-group names from a regex source, in declaration order. */
43
+ function extractGroupNames(source) {
44
+ const names = [];
45
+ NAMED_GROUP_RE.lastIndex = 0;
46
+ let match;
47
+ while ((match = NAMED_GROUP_RE.exec(source)) !== null) {
48
+ names.push(match[1]);
49
+ }
50
+ return names;
51
+ }
52
+ /** Find placeholder names used in a template/label string, deduplicated. */
53
+ function extractPlaceholders(template) {
54
+ const seen = new Set();
55
+ PLACEHOLDER_RE.lastIndex = 0;
56
+ let match;
57
+ while ((match = PLACEHOLDER_RE.exec(template)) !== null) {
58
+ seen.add(match[1]);
59
+ }
60
+ return [...seen];
61
+ }
62
+ /**
63
+ * Compile a list of authored xref patterns into runtime-ready form.
64
+ *
65
+ * Returns the compiled patterns alongside errors and warnings — callers
66
+ * (typically the content-loader bootstrap) decide whether errors should
67
+ * throw, log, or be passed back to the user.
68
+ */
69
+ export function compileXrefPatterns(patterns) {
70
+ const result = {
71
+ patterns: [],
72
+ errors: [],
73
+ warnings: [],
74
+ };
75
+ if (!patterns || patterns.length === 0)
76
+ return result;
77
+ const seenMatches = new Set();
78
+ patterns.forEach((entry, idx) => {
79
+ const ref = `xrefs[${idx}]`;
80
+ // Validate required fields up front.
81
+ if (typeof entry?.match !== 'string' || entry.match.length === 0) {
82
+ result.errors.push(`${ref}: \`match\` is required and must be a non-empty string`);
83
+ return;
84
+ }
85
+ if (typeof entry.template !== 'string' || entry.template.length === 0) {
86
+ result.errors.push(`${ref}: \`template\` is required and must be a non-empty string`);
87
+ return;
88
+ }
89
+ // Reserved type rejection.
90
+ const type = entry.type ?? 'external';
91
+ if (RESERVED_TYPES.has(type)) {
92
+ result.errors.push(`${ref}: \`type\` value "${type}" is reserved`);
93
+ return;
94
+ }
95
+ // Duplicate match warning (doesn't fail; first-wins ordering is stable).
96
+ if (seenMatches.has(entry.match)) {
97
+ result.warnings.push(`${ref}: duplicate \`match\` "${entry.match}" — earlier entry wins`);
98
+ }
99
+ else {
100
+ seenMatches.add(entry.match);
101
+ }
102
+ // Compile the regex with whole-string anchoring.
103
+ const sourceAnchored = anchorPatternSource(entry.match);
104
+ let regex;
105
+ try {
106
+ regex = new RegExp(sourceAnchored);
107
+ }
108
+ catch (e) {
109
+ result.errors.push(`${ref}: invalid regex (${e.message})`);
110
+ return;
111
+ }
112
+ // Enumerate named groups so the resolver can validate matches.
113
+ const groupNames = extractGroupNames(entry.match);
114
+ // Validate template + label placeholders against the available names
115
+ // (`id` is implicit; everything else must be a captured group).
116
+ const allowed = new Set(['id', ...groupNames]);
117
+ const label = entry.label ?? '{id}';
118
+ const templatePlaceholders = extractPlaceholders(entry.template);
119
+ const labelPlaceholders = extractPlaceholders(label);
120
+ const unknown = [];
121
+ for (const name of [...templatePlaceholders, ...labelPlaceholders]) {
122
+ if (!allowed.has(name))
123
+ unknown.push(name);
124
+ }
125
+ if (unknown.length > 0) {
126
+ const dedup = [...new Set(unknown)];
127
+ result.errors.push(`${ref}: unknown placeholder${dedup.length === 1 ? '' : 's'} ${dedup.map(n => `{${n}}`).join(', ')} (must be \`{id}\` or a named group of the regex)`);
128
+ return;
129
+ }
130
+ result.patterns.push({
131
+ match: regex,
132
+ template: entry.template,
133
+ type,
134
+ label,
135
+ groupNames,
136
+ });
137
+ });
138
+ return result;
139
+ }
140
+ //# sourceMappingURL=xref-patterns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xref-patterns.js","sourceRoot":"","sources":["../src/xref-patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAkCH,qEAAqE;AACrE,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;AAE/C;;2BAE2B;AAC3B,MAAM,cAAc,GAAG,mCAAmC,CAAC;AAE3D,+DAA+D;AAC/D,MAAM,cAAc,GAAG,iCAAiC,CAAC;AAEzD;;;4DAG4D;AAC5D,SAAS,mBAAmB,CAAC,MAAc;IAC1C,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC;IAClE,IAAI,KAAK,GAAG,MAAM,CAAC;IACnB,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClD,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACpD,OAAO,OAAO,KAAK,IAAI,CAAC;AACzB,CAAC;AAED,2EAA2E;AAC3E,SAAS,iBAAiB,CAAC,MAAc;IACxC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,cAAc,CAAC,SAAS,GAAG,CAAC,CAAC;IAC7B,IAAI,KAA6B,CAAC;IAClC,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC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,UAAU,CAAC,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,MAAM,CAAC;QACpC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACjE,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACrD,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,oBAAoB,EAAE,GAAG,iBAAiB,CAAC,EAAE,CAAC;YACpE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;YACpC,MAAM,CAAC,MAAM,CAAC,IAAI,CACjB,GAAG,GAAG,wBAAwB,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,mDAAmD,CACrJ,CAAC;YACF,OAAO;QACR,CAAC;QAED,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;YACpB,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI;YACJ,KAAK;YACL,UAAU;SACV,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -2,14 +2,31 @@
2
2
  * Xref (cross-reference) resolution utilities.
3
3
  *
4
4
  * Walks a Markdoc renderable tree and converts xref placeholder spans
5
- * (produced by the xref/ref tag transform) into resolved `<a>` links
6
- * using the entity registry.
5
+ * (produced by the xref/ref tag transform) into resolved `<a>` links.
6
+ *
7
+ * Resolution model (SPEC-065):
8
+ *
9
+ * 1. **Entity lookup** — find the entity in the registry (exact ID, then
10
+ * case-insensitive name/title). Captures metadata (label, type) for use
11
+ * in rendering even if the URL ends up coming from a pattern.
12
+ * 2. **URL resolution** — if the matched entity has a usable `sourceUrl`,
13
+ * that's the href (`data-xref-source="registry"`). Otherwise iterate
14
+ * configured patterns (compiled via `compileXrefPatterns`); first regex
15
+ * that matches the ID provides the URL (`data-xref-source="pattern"`).
16
+ * 3. **Unresolved fallback** — if neither the entity nor any pattern produces
17
+ * a URL, render `rf-xref--unresolved` with a build warning.
18
+ *
19
+ * The separation lets entity-lookup and URL-resolution succeed independently.
20
+ * SPEC-064 plan content registered without a `sourceUrl` (because it isn't
21
+ * published to any site) still resolves correctly: the registry provides
22
+ * label and type; user-configured patterns provide the URL.
7
23
  */
8
24
  import type { EntityRegistry, PipelineContext } from '@refrakt-md/types';
25
+ import type { CompiledXrefPattern } from './xref-patterns.js';
9
26
  /**
10
27
  * Walk a Markdoc renderable tree, resolving any xref placeholders into
11
- * clickable links using the entity registry. Unresolved xrefs become
12
- * styled spans with an `rf-xref--unresolved` class.
28
+ * clickable links using the entity registry and configured patterns.
29
+ * Unresolved xrefs become styled spans with an `rf-xref--unresolved` class.
13
30
  */
14
- export declare function resolveXrefs(renderable: unknown, pageUrl: string, registry: Readonly<EntityRegistry>, ctx: PipelineContext): unknown;
31
+ export declare function resolveXrefs(renderable: unknown, pageUrl: string, registry: Readonly<EntityRegistry>, patterns: CompiledXrefPattern[], ctx: PipelineContext): unknown;
15
32
  //# sourceMappingURL=xref-resolve.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"xref-resolve.d.ts","sourceRoot":"","sources":["../src/xref-resolve.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAsB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAsD7F;;;;GAIG;AACH,wBAAgB,YAAY,CAC3B,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,EAClC,GAAG,EAAE,eAAe,GAClB,OAAO,CAqGT"}
1
+ {"version":3,"file":"xref-resolve.d.ts","sourceRoot":"","sources":["../src/xref-resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAsB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE7F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AA+Q9D;;;;GAIG;AACH,wBAAgB,YAAY,CAC3B,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,EAClC,QAAQ,EAAE,mBAAmB,EAAE,EAC/B,GAAG,EAAE,eAAe,GAClB,OAAO,CAGT"}
@@ -2,29 +2,41 @@
2
2
  * Xref (cross-reference) resolution utilities.
3
3
  *
4
4
  * Walks a Markdoc renderable tree and converts xref placeholder spans
5
- * (produced by the xref/ref tag transform) into resolved `<a>` links
6
- * using the entity registry.
5
+ * (produced by the xref/ref tag transform) into resolved `<a>` links.
6
+ *
7
+ * Resolution model (SPEC-065):
8
+ *
9
+ * 1. **Entity lookup** — find the entity in the registry (exact ID, then
10
+ * case-insensitive name/title). Captures metadata (label, type) for use
11
+ * in rendering even if the URL ends up coming from a pattern.
12
+ * 2. **URL resolution** — if the matched entity has a usable `sourceUrl`,
13
+ * that's the href (`data-xref-source="registry"`). Otherwise iterate
14
+ * configured patterns (compiled via `compileXrefPatterns`); first regex
15
+ * that matches the ID provides the URL (`data-xref-source="pattern"`).
16
+ * 3. **Unresolved fallback** — if neither the entity nor any pattern produces
17
+ * a URL, render `rf-xref--unresolved` with a build warning.
18
+ *
19
+ * The separation lets entity-lookup and URL-resolution succeed independently.
20
+ * SPEC-064 plan content registered without a `sourceUrl` (because it isn't
21
+ * published to any site) still resolves correctly: the registry provides
22
+ * label and type; user-configured patterns provide the URL.
7
23
  */
8
24
  import Markdoc from '@markdoc/markdoc';
9
25
  const { Tag } = Markdoc;
10
26
  import { XREF_RUNE_MARKER } from './tags/xref.js';
11
- /**
12
- * Find an entity by exact ID across all types in the registry.
13
- * If typeHint is provided, only search that type.
14
- */
15
- function findEntityById(registry, id, typeHint) {
27
+ /** Find an entity by exact ID across all types in the registry. `pageUrl`
28
+ * scopes the search so page-scoped entries from the resolving page take
29
+ * precedence over site-scoped entries of the same id (SPEC-060). */
30
+ function findEntityById(registry, id, pageUrl, typeHint) {
16
31
  const types = typeHint ? [typeHint] : registry.getTypes();
17
32
  for (const type of types) {
18
- const entity = registry.getById(type, id);
33
+ const entity = registry.getById(type, id, pageUrl);
19
34
  if (entity)
20
- return { entity, ambiguous: false };
35
+ return entity;
21
36
  }
22
37
  return undefined;
23
38
  }
24
- /**
25
- * Find entities by name/title match (case-insensitive) across all types.
26
- * If typeHint is provided, only search that type.
27
- */
39
+ /** Find entities by case-insensitive name/title match. */
28
40
  function findEntitiesByName(registry, name, typeHint) {
29
41
  const nameLower = name.toLowerCase();
30
42
  const types = typeHint ? [typeHint] : registry.getTypes();
@@ -40,31 +52,197 @@ function findEntitiesByName(registry, name, typeHint) {
40
52
  }
41
53
  return matches;
42
54
  }
43
- /** Resolve an entity's URL for use as an href */
55
+ /** Compute the canonical URL for a registry-matched entity, honoring
56
+ * per-entity `data.url` overrides and `data.headingId` fragment hints. */
44
57
  function resolveEntityHref(entity) {
45
58
  const baseUrl = entity.data.url || entity.sourceUrl;
59
+ if (!baseUrl)
60
+ return undefined;
46
61
  const headingId = entity.data.headingId;
47
- if (headingId)
48
- return `${baseUrl}#${headingId}`;
49
- return baseUrl;
62
+ return headingId ? `${baseUrl}#${headingId}` : baseUrl;
63
+ }
64
+ /** Choose the rendered label for a resolved xref. Priority: explicit `label=`
65
+ * attribute > entity `data.title` / `data.name` / `data.text` > the raw ID. */
66
+ function deriveEntityLabel(id, authoredLabel, entity) {
67
+ if (authoredLabel)
68
+ return authoredLabel;
69
+ if (entity) {
70
+ const title = entity.data.title;
71
+ const name = entity.data.name;
72
+ const text = entity.data.text;
73
+ return title || name || text || id;
74
+ }
75
+ return id;
76
+ }
77
+ /** Match `{name}` placeholders in template / label strings. */
78
+ const PLACEHOLDER_RE = /\{([a-zA-Z_$][a-zA-Z0-9_$]*)\}/g;
79
+ /** URL-encode per segment: split on `/`, encode each segment with
80
+ * `encodeURIComponent`, rejoin with `/`. Single-segment values are
81
+ * unaffected (the split is a no-op); multi-segment paths preserve their
82
+ * slash structure. This is what the SPEC-065 "per-segment encoding"
83
+ * contract delivers. */
84
+ function encodePerSegment(value) {
85
+ return value.split('/').map(encodeURIComponent).join('/');
86
+ }
87
+ /** Substitute `{id}` and `{name}` placeholders in a template, with each
88
+ * substituted value encoded per URL segment. */
89
+ function applyTemplate(template, id, groups) {
90
+ return template.replace(PLACEHOLDER_RE, (_match, name) => {
91
+ const value = name === 'id' ? id : (groups[name] ?? '');
92
+ return encodePerSegment(value);
93
+ });
94
+ }
95
+ /** Apply a label template without URL encoding — labels are human-readable
96
+ * text, not URL components. Missing named groups render as empty strings. */
97
+ function applyLabelTemplate(template, id, groups) {
98
+ return template.replace(PLACEHOLDER_RE, (_match, name) => {
99
+ if (name === 'id')
100
+ return id;
101
+ return groups[name] ?? '';
102
+ });
103
+ }
104
+ /** Try each pattern in order; first match wins. Returns the resolved URL
105
+ * along with the pattern's `type` and computed `label`. */
106
+ function tryPatternMatch(id, patterns) {
107
+ for (const p of patterns) {
108
+ const m = p.match.exec(id);
109
+ if (!m)
110
+ continue;
111
+ const groups = (m.groups ?? {});
112
+ return {
113
+ url: applyTemplate(p.template, id, groups),
114
+ label: applyLabelTemplate(p.label, id, groups),
115
+ type: p.type,
116
+ };
117
+ }
118
+ return undefined;
119
+ }
120
+ /** Reduce an absolute href that points at the current page + fragment down
121
+ * to the fragment alone. Handles both URL shapes seen in practice — page
122
+ * URLs that end with a trailing slash and ones that don't. Returns the
123
+ * original href when it doesn't target the current page. */
124
+ function compactSamePageHref(href, pageUrl) {
125
+ const hashIdx = href.indexOf('#');
126
+ if (hashIdx < 0)
127
+ return href;
128
+ const hrefPath = href.slice(0, hashIdx);
129
+ const fragment = href.slice(hashIdx);
130
+ // Normalise trailing slashes for the comparison so `/x/` and `/x` are
131
+ // treated as the same page (different adapters normalise differently).
132
+ const stripTrail = (s) => s.endsWith('/') ? s.slice(0, -1) : s;
133
+ if (stripTrail(hrefPath) === stripTrail(pageUrl))
134
+ return fragment;
135
+ return href;
136
+ }
137
+ /** Resolve a single xref placeholder. Drives the SPEC-065 chain:
138
+ * entity lookup → URL resolution → unresolved fallback. */
139
+ function resolvePlaceholder(id, authoredLabel, typeHint, rc) {
140
+ // Step 1: entity lookup (capture metadata, may or may not yield a URL).
141
+ let entity = findEntityById(rc.registry, id, rc.pageUrl, typeHint);
142
+ if (!entity) {
143
+ const nameMatches = findEntitiesByName(rc.registry, id, typeHint);
144
+ if (nameMatches.length === 1) {
145
+ entity = nameMatches[0];
146
+ }
147
+ else if (nameMatches.length > 1) {
148
+ const matchList = nameMatches
149
+ .map(e => `${e.type} "${e.data.title || e.data.name || e.id}" on ${e.sourceUrl ?? '(no URL)'}`)
150
+ .join(', ');
151
+ rc.ctx.warn(`xref "${id}" on ${rc.pageUrl} — matches ${nameMatches.length} entities (${matchList}). Add type hint to disambiguate.`, rc.pageUrl);
152
+ entity = nameMatches[0];
153
+ }
154
+ }
155
+ const entityHref = entity ? resolveEntityHref(entity) : undefined;
156
+ // Step 2a: URL from the entity, if any.
157
+ let resolved;
158
+ if (entity && entityHref) {
159
+ resolved = {
160
+ href: entityHref,
161
+ label: deriveEntityLabel(id, authoredLabel, entity),
162
+ type: entity.type,
163
+ source: 'registry',
164
+ targetType: entity.type,
165
+ entityId: entity.id,
166
+ };
167
+ }
168
+ else {
169
+ // Step 2b: URL from a pattern. Entity metadata still wins for label/type
170
+ // when present; the pattern only contributes the URL in that case.
171
+ const patternHit = tryPatternMatch(id, rc.patterns);
172
+ if (patternHit) {
173
+ resolved = {
174
+ href: patternHit.url,
175
+ label: deriveEntityLabel(id, authoredLabel, entity) || patternHit.label,
176
+ type: entity?.type ?? patternHit.type,
177
+ source: 'pattern',
178
+ targetType: entity?.type,
179
+ entityId: entity?.id,
180
+ };
181
+ // When no entity is matched, the label has to come from the
182
+ // pattern (or the authored label); `deriveEntityLabel` falls back
183
+ // to the raw ID which is rarely what the author wanted from a
184
+ // pattern. Use the pattern label in that case.
185
+ if (!entity && !authoredLabel) {
186
+ resolved.label = patternHit.label;
187
+ }
188
+ }
189
+ }
190
+ // Step 3: unresolved.
191
+ if (!resolved) {
192
+ rc.ctx.warn(`xref "${id}" on ${rc.pageUrl} — entity not found`, rc.pageUrl);
193
+ return {
194
+ tag: new Tag('span', {
195
+ class: 'rf-xref rf-xref--unresolved',
196
+ 'data-xref-id': id,
197
+ }, [authoredLabel || id]),
198
+ };
199
+ }
200
+ // Self-reference detection on the resolved href (covers both registry and
201
+ // pattern cases — a pattern that produces a same-page URL is still a
202
+ // self-reference).
203
+ if (resolved.href === rc.pageUrl) {
204
+ rc.ctx.info(`xref "${id}" on ${rc.pageUrl} — references itself`, rc.pageUrl);
205
+ }
206
+ // Same-page anchor compaction: when the entity's resolved href is the
207
+ // current page plus a fragment, drop the page URL portion so the link
208
+ // renders as a fragment-only anchor (`#drawer-x`) — matches the SPEC-060
209
+ // drawer-trigger contract and is how authors normally write same-page
210
+ // anchors. Behaves identically to the absolute form for the browser; the
211
+ // progressive-enhancement layer (drawer behaviors) reads the fragment
212
+ // directly without needing to compare against location.pathname.
213
+ const renderedHref = compactSamePageHref(resolved.href, rc.pageUrl);
214
+ const attributes = {
215
+ class: `rf-xref rf-xref--${resolved.type}`,
216
+ href: renderedHref,
217
+ 'data-xref-id': resolved.entityId ?? id,
218
+ 'data-xref-source': resolved.source,
219
+ };
220
+ if (resolved.targetType) {
221
+ attributes['data-target-type'] = resolved.targetType;
222
+ }
223
+ return { tag: new Tag('a', attributes, [resolved.label]) };
50
224
  }
51
225
  /**
52
226
  * Walk a Markdoc renderable tree, resolving any xref placeholders into
53
- * clickable links using the entity registry. Unresolved xrefs become
54
- * styled spans with an `rf-xref--unresolved` class.
227
+ * clickable links using the entity registry and configured patterns.
228
+ * Unresolved xrefs become styled spans with an `rf-xref--unresolved` class.
55
229
  */
56
- export function resolveXrefs(renderable, pageUrl, registry, ctx) {
230
+ export function resolveXrefs(renderable, pageUrl, registry, patterns, ctx) {
231
+ const rc = { pageUrl, registry, patterns, ctx };
232
+ return walk(renderable, rc);
233
+ }
234
+ function walk(renderable, rc) {
57
235
  if (!Tag.isTag(renderable)) {
58
236
  if (Array.isArray(renderable)) {
59
- const newChildren = renderable.map(c => resolveXrefs(c, pageUrl, registry, ctx));
60
- if (newChildren.every((c, i) => c === renderable[i]))
237
+ const arr = renderable;
238
+ const newChildren = arr.map(c => walk(c, rc));
239
+ if (newChildren.every((c, i) => c === arr[i]))
61
240
  return renderable;
62
241
  return newChildren;
63
242
  }
64
243
  return renderable;
65
244
  }
66
245
  const tag = renderable;
67
- // Check if this is an xref placeholder
68
246
  if (tag.attributes?.['data-rune'] === XREF_RUNE_MARKER) {
69
247
  const id = tag.attributes['data-xref-id'];
70
248
  const label = tag.attributes['data-xref-label'];
@@ -74,63 +252,9 @@ export function resolveXrefs(renderable, pageUrl, registry, ctx) {
74
252
  class: 'rf-xref rf-xref--unresolved',
75
253
  }, [label || '?']);
76
254
  }
77
- // Try exact ID match first
78
- const idMatch = findEntityById(registry, id, typeHint);
79
- if (idMatch) {
80
- const entity = idMatch.entity;
81
- const href = resolveEntityHref(entity);
82
- const text = label || entity.data.title || entity.data.name || entity.data.text || id;
83
- if (entity.sourceUrl === pageUrl) {
84
- ctx.info(`xref "${id}" on ${pageUrl} — references itself`, pageUrl);
85
- }
86
- return new Tag('a', {
87
- class: `rf-xref rf-xref--${entity.type}`,
88
- href,
89
- 'data-entity-type': entity.type,
90
- 'data-entity-id': entity.id,
91
- }, [text]);
92
- }
93
- // Try name/title match
94
- const nameMatches = findEntitiesByName(registry, id, typeHint);
95
- if (nameMatches.length === 1) {
96
- const entity = nameMatches[0];
97
- const href = resolveEntityHref(entity);
98
- const text = label || entity.data.title || entity.data.name || entity.data.text || id;
99
- if (entity.sourceUrl === pageUrl) {
100
- ctx.info(`xref "${id}" on ${pageUrl} — references itself`, pageUrl);
101
- }
102
- return new Tag('a', {
103
- class: `rf-xref rf-xref--${entity.type}`,
104
- href,
105
- 'data-entity-type': entity.type,
106
- 'data-entity-id': entity.id,
107
- }, [text]);
108
- }
109
- if (nameMatches.length > 1) {
110
- const matchList = nameMatches
111
- .map(e => `${e.type} "${e.data.title || e.data.name || e.id}" on ${e.sourceUrl}`)
112
- .join(', ');
113
- ctx.warn(`xref "${id}" on ${pageUrl} — matches ${nameMatches.length} entities (${matchList}). Add type hint to disambiguate.`, pageUrl);
114
- // Use first match
115
- const entity = nameMatches[0];
116
- const href = resolveEntityHref(entity);
117
- const text = label || entity.data.title || entity.data.name || entity.data.text || id;
118
- return new Tag('a', {
119
- class: `rf-xref rf-xref--${entity.type}`,
120
- href,
121
- 'data-entity-type': entity.type,
122
- 'data-entity-id': entity.id,
123
- }, [text]);
124
- }
125
- // No match — unresolved
126
- ctx.warn(`xref "${id}" on ${pageUrl} — entity not found`, pageUrl);
127
- return new Tag('span', {
128
- class: 'rf-xref rf-xref--unresolved',
129
- 'data-entity-id': id,
130
- }, [label || id]);
255
+ return resolvePlaceholder(id, label, typeHint, rc).tag;
131
256
  }
132
- // Recurse into children
133
- const newChildren = (tag.children ?? []).map((c) => resolveXrefs(c, pageUrl, registry, ctx));
257
+ const newChildren = (tag.children ?? []).map((c) => walk(c, rc));
134
258
  if (newChildren.every((c, i) => c === tag.children[i]))
135
259
  return tag;
136
260
  return { ...tag, children: newChildren };
@@ -1 +1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GAAG,GAAG,UAAiB,CAAC;IAE9B,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,WAAW,CAAC,KAAK,gBAAgB,EAAE,CAAC;QACxD,MAAM,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,cAAc,CAAuB,CAAC;QAChE,MAAM,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,iBAAiB,CAAuB,CAAC;QACtE,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC,gBAAgB,CAAuB,CAAC;QAExE,IAAI,CAAC,EAAE,EAAE,CAAC;YACT,OAAO,IAAI,GAAG,CAAC,MAAM,EAAE;gBACtB,KAAK,EAAE,6BAA6B;aACpC,EAAE,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC;QACpB,CAAC;QAED,OAAO,kBAAkB,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;IACxD,CAAC;IAED,MAAM,WAAW,GAAG,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAU,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1E,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,CAAU,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC;IACpF,OAAO,EAAE,GAAG,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AAC1C,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@refrakt-md/runes",
3
3
  "description": "Semantic Markdoc runes for refrakt.md",
4
- "version": "0.14.4",
4
+ "version": "0.15.0",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -29,8 +29,8 @@
29
29
  "build": "tsc"
30
30
  },
31
31
  "dependencies": {
32
- "@refrakt-md/types": "0.14.4",
33
- "@refrakt-md/transform": "0.14.4",
32
+ "@refrakt-md/types": "0.15.0",
33
+ "@refrakt-md/transform": "0.15.0",
34
34
  "@markdoc/markdoc": "0.4.0",
35
35
  "reflect-metadata": "^0.2.0",
36
36
  "fast-xml-parser": "4.5.1",