@refrakt-md/runes 0.15.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aggregate-resolve.d.ts +4 -0
- package/dist/aggregate-resolve.d.ts.map +1 -0
- package/dist/aggregate-resolve.js +209 -0
- package/dist/aggregate-resolve.js.map +1 -0
- package/dist/collection-helpers.d.ts +101 -0
- package/dist/collection-helpers.d.ts.map +1 -0
- package/dist/collection-helpers.js +206 -0
- package/dist/collection-helpers.js.map +1 -0
- package/dist/collection-resolve.d.ts +5 -0
- package/dist/collection-resolve.d.ts.map +1 -0
- package/dist/collection-resolve.js +209 -0
- package/dist/collection-resolve.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +87 -5
- package/dist/config.js.map +1 -1
- package/dist/deferred-body.d.ts +19 -0
- package/dist/deferred-body.d.ts.map +1 -0
- package/dist/deferred-body.js +70 -0
- package/dist/deferred-body.js.map +1 -0
- package/dist/drawer-pipeline.d.ts +72 -1
- package/dist/drawer-pipeline.d.ts.map +1 -1
- package/dist/drawer-pipeline.js +242 -1
- package/dist/drawer-pipeline.js.map +1 -1
- package/dist/expand-pipeline.js +25 -16
- package/dist/expand-pipeline.js.map +1 -1
- package/dist/field-match.d.ts +43 -0
- package/dist/field-match.d.ts.map +1 -0
- package/dist/field-match.js +121 -0
- package/dist/field-match.js.map +1 -0
- package/dist/file-ref-resolve.d.ts +22 -0
- package/dist/file-ref-resolve.d.ts.map +1 -0
- package/dist/file-ref-resolve.js +233 -0
- package/dist/file-ref-resolve.js.map +1 -0
- package/dist/functions.d.ts +36 -0
- package/dist/functions.d.ts.map +1 -0
- package/dist/functions.js +74 -0
- package/dist/functions.js.map +1 -0
- package/dist/index.d.ts +33 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +80 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +9 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +68 -9
- package/dist/nodes.js.map +1 -1
- package/dist/outline-scope.d.ts +17 -0
- package/dist/outline-scope.d.ts.map +1 -1
- package/dist/outline-scope.js +59 -0
- package/dist/outline-scope.js.map +1 -1
- package/dist/relationships-resolve.d.ts +4 -0
- package/dist/relationships-resolve.d.ts.map +1 -0
- package/dist/relationships-resolve.js +180 -0
- package/dist/relationships-resolve.js.map +1 -0
- package/dist/snippet-pipeline.d.ts +7 -5
- package/dist/snippet-pipeline.d.ts.map +1 -1
- package/dist/snippet-pipeline.js +32 -13
- package/dist/snippet-pipeline.js.map +1 -1
- package/dist/tags/aggregate.d.ts +19 -0
- package/dist/tags/aggregate.d.ts.map +1 -0
- package/dist/tags/aggregate.js +59 -0
- package/dist/tags/aggregate.js.map +1 -0
- package/dist/tags/card.d.ts +25 -0
- package/dist/tags/card.d.ts.map +1 -0
- package/dist/tags/card.js +138 -0
- package/dist/tags/card.js.map +1 -0
- package/dist/tags/codegroup.d.ts.map +1 -1
- package/dist/tags/codegroup.js +37 -1
- package/dist/tags/codegroup.js.map +1 -1
- package/dist/tags/collection.d.ts +10 -0
- package/dist/tags/collection.d.ts.map +1 -0
- package/dist/tags/collection.js +54 -0
- package/dist/tags/collection.js.map +1 -0
- package/dist/tags/conversation.d.ts.map +1 -1
- package/dist/tags/conversation.js +26 -6
- package/dist/tags/conversation.js.map +1 -1
- package/dist/tags/diff.d.ts.map +1 -1
- package/dist/tags/diff.js +85 -18
- package/dist/tags/diff.js.map +1 -1
- package/dist/tags/drawer.d.ts.map +1 -1
- package/dist/tags/drawer.js +32 -2
- package/dist/tags/drawer.js.map +1 -1
- package/dist/tags/file-ref.d.ts +21 -0
- package/dist/tags/file-ref.d.ts.map +1 -0
- package/dist/tags/file-ref.js +88 -0
- package/dist/tags/file-ref.js.map +1 -0
- package/dist/tags/progress.d.ts +9 -0
- package/dist/tags/progress.d.ts.map +1 -0
- package/dist/tags/progress.js +96 -0
- package/dist/tags/progress.js.map +1 -0
- package/dist/tags/relationships.d.ts +12 -0
- package/dist/tags/relationships.d.ts.map +1 -0
- package/dist/tags/relationships.js +62 -0
- package/dist/tags/relationships.js.map +1 -0
- package/dist/tags/snippet.d.ts.map +1 -1
- package/dist/tags/snippet.js +10 -0
- package/dist/tags/snippet.js.map +1 -1
- package/dist/tags/xref.d.ts.map +1 -1
- package/dist/tags/xref.js +9 -0
- package/dist/tags/xref.js.map +1 -1
- package/dist/xref-preview-resolve.d.ts +35 -0
- package/dist/xref-preview-resolve.d.ts.map +1 -0
- package/dist/xref-preview-resolve.js +188 -0
- package/dist/xref-preview-resolve.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import Markdoc from '@markdoc/markdoc';
|
|
2
|
+
const { Tag } = Markdoc;
|
|
3
|
+
import { createContentModelSchema, createComponentRenderable } from '../lib/index.js';
|
|
4
|
+
/** Sentinel `data-field` value the file-ref schema emits. The resolver
|
|
5
|
+
* (file-ref-resolve.ts) walks the postProcess tree, finds these, and
|
|
6
|
+
* binds the inline `<a>` to the GitHub URL plus (when `preview="drawer"`
|
|
7
|
+
* is set) a hoist sentinel for the drawer pipeline to pick up. */
|
|
8
|
+
export const FILE_REF_SENTINEL = '__file-ref-sentinel';
|
|
9
|
+
/**
|
|
10
|
+
* `file-ref` rune — path-based inline reference to a project file
|
|
11
|
+
* (SPEC-078). Renders as an inline `<a>` to the file's canonical GitHub
|
|
12
|
+
* URL (built from `SiteConfig.repoUrl` + `repoBranch`), with an optional
|
|
13
|
+
* `preview="drawer"` mode that hoists a drawer containing the file's
|
|
14
|
+
* snippet and a "View source on GitHub →" footer link.
|
|
15
|
+
*
|
|
16
|
+
* The transform emits a sentinel meta + placeholder `<a>`. The actual
|
|
17
|
+
* link href, the drawer body, and the hoist sentinel are all bound in
|
|
18
|
+
* postProcess by `resolveFileRefs` so that the rune doesn't need
|
|
19
|
+
* site-config access at transform time and so the file content is read
|
|
20
|
+
* once (not per page-with-mention).
|
|
21
|
+
*/
|
|
22
|
+
export const fileRef = createContentModelSchema({
|
|
23
|
+
attributes: {
|
|
24
|
+
path: {
|
|
25
|
+
type: String,
|
|
26
|
+
required: true,
|
|
27
|
+
description: 'Project-root-relative file path. Same sandbox as snippet — absolute paths, traversal escapes, and out-of-root symlinks are rejected.',
|
|
28
|
+
},
|
|
29
|
+
lines: {
|
|
30
|
+
type: String,
|
|
31
|
+
required: false,
|
|
32
|
+
description: 'Line range. `"42-58"` (range), `"42"` (single line). Drives both the GitHub anchor (#L42-L58) and the drawer-body snippet slice when `preview="drawer"`.',
|
|
33
|
+
},
|
|
34
|
+
label: {
|
|
35
|
+
type: String,
|
|
36
|
+
required: false,
|
|
37
|
+
description: 'Display text for the inline link. Defaults to the filename (e.g. `token-contract.ts`). Pass an explicit label when the file-ref refers to a symbol within the file rather than the file itself.',
|
|
38
|
+
},
|
|
39
|
+
preview: {
|
|
40
|
+
type: String,
|
|
41
|
+
required: false,
|
|
42
|
+
matches: ['drawer'],
|
|
43
|
+
description: 'Preview target. `"drawer"` hoists a drawer with the file\'s snippet + a GitHub footer link, leaving an inline link at the call site that opens it. Absent → no preview, just the inline link.',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
selfClosing: true,
|
|
47
|
+
contentModel: { type: 'sequence', fields: [] },
|
|
48
|
+
transform(_resolved, attrs) {
|
|
49
|
+
const path = String(attrs.path ?? '');
|
|
50
|
+
const lines = attrs.lines !== undefined ? String(attrs.lines) : '';
|
|
51
|
+
const label = attrs.label !== undefined ? String(attrs.label) : '';
|
|
52
|
+
const preview = attrs.preview !== undefined ? String(attrs.preview) : '';
|
|
53
|
+
// Default label: the basename of the path. Authors typically want
|
|
54
|
+
// to refer to a symbol inside the file (e.g. "ThemeTokensConfig")
|
|
55
|
+
// and pass an explicit label; this default is the conservative
|
|
56
|
+
// fallback when no label is given.
|
|
57
|
+
const fallbackLabel = defaultLabel(path);
|
|
58
|
+
const meta = (field, content) => new Tag('meta', { 'data-field': field, content });
|
|
59
|
+
const metas = [
|
|
60
|
+
meta('file-ref-path', path),
|
|
61
|
+
meta('file-ref-lines', lines),
|
|
62
|
+
meta('file-ref-label', label),
|
|
63
|
+
meta('file-ref-preview', preview),
|
|
64
|
+
meta(FILE_REF_SENTINEL, 'true'),
|
|
65
|
+
];
|
|
66
|
+
// Placeholder anchor with the fallback label — resolver replaces
|
|
67
|
+
// the href and (when label is empty) keeps the fallback text.
|
|
68
|
+
const placeholder = new Tag('a', {}, [label || fallbackLabel]);
|
|
69
|
+
return createComponentRenderable({
|
|
70
|
+
rune: 'file-ref',
|
|
71
|
+
// Span keeps the rune inline-safe in prose. The resolver later
|
|
72
|
+
// replaces the span's children with the bound anchor + (with
|
|
73
|
+
// preview) a sibling hoist sentinel.
|
|
74
|
+
tag: 'span',
|
|
75
|
+
properties: {},
|
|
76
|
+
refs: { link: placeholder },
|
|
77
|
+
children: [...metas, placeholder],
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
function defaultLabel(path) {
|
|
82
|
+
if (!path)
|
|
83
|
+
return '';
|
|
84
|
+
const trimmed = path.endsWith('/') ? path.slice(0, -1) : path;
|
|
85
|
+
const slash = trimmed.lastIndexOf('/');
|
|
86
|
+
return slash >= 0 ? trimmed.slice(slash + 1) : trimmed;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=file-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-ref.js","sourceRoot":"","sources":["../../src/tags/file-ref.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAEtF;;;mEAGmE;AACnE,MAAM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ACvC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Markdoc from '@markdoc/markdoc';
|
|
2
|
+
/**
|
|
3
|
+
* `progress` — a generic, presentational completion bar (SPEC-072 / WORK-285).
|
|
4
|
+
* Renders a ratio from supplied numbers; computes nothing from the registry.
|
|
5
|
+
* `value`+`max` (primary) or `percent` (alternative, when there's no count);
|
|
6
|
+
* an optional body is the label. Identity-transform only, no resolver.
|
|
7
|
+
*/
|
|
8
|
+
export declare const progress: Markdoc.Schema;
|
|
9
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/tags/progress.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAiBvC;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,gBA6EnB,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import Markdoc from '@markdoc/markdoc';
|
|
2
|
+
const { Tag } = Markdoc;
|
|
3
|
+
import { createContentModelSchema, createComponentRenderable, asNodes } from '../lib/index.js';
|
|
4
|
+
import { RenderableNodeCursor } from '../lib/renderable.js';
|
|
5
|
+
const displayValues = ['fraction', 'percent', 'none'];
|
|
6
|
+
const sentimentValues = ['positive', 'caution', 'negative'];
|
|
7
|
+
/** Best-effort plain-text of a rendered subtree, for the accessible name. */
|
|
8
|
+
function textContent(node) {
|
|
9
|
+
if (typeof node === 'string')
|
|
10
|
+
return node;
|
|
11
|
+
if (Array.isArray(node))
|
|
12
|
+
return node.map(textContent).join('');
|
|
13
|
+
if (Markdoc.Tag.isTag(node))
|
|
14
|
+
return textContent(node.children ?? []);
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* `progress` — a generic, presentational completion bar (SPEC-072 / WORK-285).
|
|
19
|
+
* Renders a ratio from supplied numbers; computes nothing from the registry.
|
|
20
|
+
* `value`+`max` (primary) or `percent` (alternative, when there's no count);
|
|
21
|
+
* an optional body is the label. Identity-transform only, no resolver.
|
|
22
|
+
*/
|
|
23
|
+
export const progress = createContentModelSchema({
|
|
24
|
+
attributes: {
|
|
25
|
+
value: { type: Number, required: false, description: 'Completed amount (paired with `max`).' },
|
|
26
|
+
max: { type: Number, required: false, description: 'Total amount (paired with `value`).' },
|
|
27
|
+
percent: { type: Number, required: false, description: 'Direct percentage 0–100, when there is no count.' },
|
|
28
|
+
display: { type: String, required: false, matches: displayValues.slice(), description: 'Readout: fraction (default with value/max), percent, or none.' },
|
|
29
|
+
sentiment: { type: String, required: false, matches: sentimentValues.slice(), description: 'Tone cue: positive / caution / negative. Absent → the neutral primary fill.' },
|
|
30
|
+
},
|
|
31
|
+
contentModel: {
|
|
32
|
+
type: 'sequence',
|
|
33
|
+
fields: [{ name: 'body', match: 'any', optional: true, greedy: true }],
|
|
34
|
+
},
|
|
35
|
+
transform(resolved, attrs, config) {
|
|
36
|
+
const value = attrs.value != null ? Number(attrs.value) : undefined;
|
|
37
|
+
const max = attrs.max != null ? Number(attrs.max) : undefined;
|
|
38
|
+
const percentAttr = attrs.percent != null ? Number(attrs.percent) : undefined;
|
|
39
|
+
const clamp = (n) => Math.max(0, Math.min(100, n));
|
|
40
|
+
const hasRatio = value != null && max != null && Number.isFinite(value) && Number.isFinite(max) && max > 0;
|
|
41
|
+
const pct = hasRatio
|
|
42
|
+
? clamp(Math.round((value / max) * 100))
|
|
43
|
+
: (percentAttr != null && Number.isFinite(percentAttr) ? clamp(percentAttr) : 0);
|
|
44
|
+
const display = attrs.display || (hasRatio ? 'fraction' : 'percent');
|
|
45
|
+
let readout = '';
|
|
46
|
+
if (display === 'fraction' && hasRatio)
|
|
47
|
+
readout = `${value}/${max}`;
|
|
48
|
+
else if (display === 'percent')
|
|
49
|
+
readout = `${pct}%`;
|
|
50
|
+
const labelNodes = new RenderableNodeCursor(Markdoc.transform(asNodes(resolved.body), config));
|
|
51
|
+
const labelArr = labelNodes.toArray();
|
|
52
|
+
const labelText = textContent(labelArr).trim();
|
|
53
|
+
// Optional tone cue — omit the meta entirely when absent so no modifier
|
|
54
|
+
// class is applied (the bar then uses the neutral primary fill).
|
|
55
|
+
const sentiment = attrs.sentiment;
|
|
56
|
+
const sentimentMeta = sentiment ? new Tag('meta', { content: sentiment }) : undefined;
|
|
57
|
+
const fillTag = new Tag('span', {}, []);
|
|
58
|
+
const trackTag = new Tag('span', {}, [fillTag]);
|
|
59
|
+
const refs = { track: trackTag, fill: fillTag };
|
|
60
|
+
const children = sentimentMeta ? [sentimentMeta] : [];
|
|
61
|
+
if (labelArr.length > 0) {
|
|
62
|
+
const labelTag = new Tag('span', {}, labelArr);
|
|
63
|
+
refs.label = labelTag;
|
|
64
|
+
children.push(labelTag);
|
|
65
|
+
}
|
|
66
|
+
if (readout) {
|
|
67
|
+
const valueTag = new Tag('span', {}, [readout]);
|
|
68
|
+
refs.value = valueTag;
|
|
69
|
+
children.push(valueTag);
|
|
70
|
+
}
|
|
71
|
+
children.push(trackTag);
|
|
72
|
+
const out = createComponentRenderable({
|
|
73
|
+
rune: 'progress',
|
|
74
|
+
tag: 'div',
|
|
75
|
+
properties: sentimentMeta ? { sentiment: sentimentMeta } : {},
|
|
76
|
+
refs,
|
|
77
|
+
children,
|
|
78
|
+
});
|
|
79
|
+
// Per-instance computed root attributes: accessible progressbar + fill width.
|
|
80
|
+
out.attributes.role = 'progressbar';
|
|
81
|
+
out.attributes['aria-valuemin'] = '0';
|
|
82
|
+
if (hasRatio) {
|
|
83
|
+
out.attributes['aria-valuenow'] = String(value);
|
|
84
|
+
out.attributes['aria-valuemax'] = String(max);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
out.attributes['aria-valuenow'] = String(pct);
|
|
88
|
+
out.attributes['aria-valuemax'] = '100';
|
|
89
|
+
}
|
|
90
|
+
if (labelText)
|
|
91
|
+
out.attributes['aria-label'] = labelText;
|
|
92
|
+
out.attributes.style = `--rf-progress: ${pct}%`;
|
|
93
|
+
return out;
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/tags/progress.ts"],"names":[],"mappings":"AAAA,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,MAAM,aAAa,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,MAAM,CAAU,CAAC;AAC/D,MAAM,eAAe,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,UAAU,CAAU,CAAC;AAErE,6EAA6E;AAC7E,SAAS,WAAW,CAAC,IAAa;IACjC,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/D,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAa,CAAC;QAAE,OAAO,WAAW,CAAE,IAAiC,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IAC5G,OAAO,EAAE,CAAC;AACX,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,wBAAwB,CAAC;IAChD,UAAU,EAAE;QACX,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAA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AE,CAAC,CAAC,CAAC,EAAE;YAC7D,IAAI;YACJ,QAAQ;SACR,CAAC,CAAC;QAEH,8EAA8E;QAC9E,GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,aAAa,CAAC;QACpC,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,GAAG,GAAG,CAAC;QACtC,IAAI,QAAQ,EAAE,CAAC;YACd,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YAChD,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACP,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAC9C,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,GAAG,KAAK,CAAC;QACzC,CAAC;QACD,IAAI,SAAS;YAAE,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;QACxD,GAAG,CAAC,UAAU,CAAC,KAAK,GAAG,kBAAkB,GAAG,GAAG,CAAC;QAChD,OAAO,GAAG,CAAC;IACZ,CAAC;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Markdoc from '@markdoc/markdoc';
|
|
2
|
+
export declare const RELATIONSHIPS_SENTINEL = "__relationships-sentinel";
|
|
3
|
+
/**
|
|
4
|
+
* `relationships` (SPEC-072) — render an entity's relationship edges, grouped
|
|
5
|
+
* by kind. The plural-graph counterpart to `collection`: its source set is
|
|
6
|
+
* `registry.getRelated(of)` rather than a type-query. Emits a sentinel filled
|
|
7
|
+
* by the postProcess resolver (`resolveRelationships`). A body, when present,
|
|
8
|
+
* is the per-edge template (deferBody) with `$item` (the related entity) and
|
|
9
|
+
* `$kind` (the edge kind) bound.
|
|
10
|
+
*/
|
|
11
|
+
export declare const relationships: Markdoc.Schema;
|
|
12
|
+
//# sourceMappingURL=relationships.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/tags/relationships.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAKvC,eAAO,MAAM,sBAAsB,6BAA6B,CAAC;AAEjE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,gBAkDxB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import Markdoc from '@markdoc/markdoc';
|
|
2
|
+
const { Tag } = Markdoc;
|
|
3
|
+
import { createContentModelSchema, createComponentRenderable } from '../lib/index.js';
|
|
4
|
+
import { readDeferredBody } from '../deferred-body.js';
|
|
5
|
+
export const RELATIONSHIPS_SENTINEL = '__relationships-sentinel';
|
|
6
|
+
/**
|
|
7
|
+
* `relationships` (SPEC-072) — render an entity's relationship edges, grouped
|
|
8
|
+
* by kind. The plural-graph counterpart to `collection`: its source set is
|
|
9
|
+
* `registry.getRelated(of)` rather than a type-query. Emits a sentinel filled
|
|
10
|
+
* by the postProcess resolver (`resolveRelationships`). A body, when present,
|
|
11
|
+
* is the per-edge template (deferBody) with `$item` (the related entity) and
|
|
12
|
+
* `$kind` (the edge kind) bound.
|
|
13
|
+
*/
|
|
14
|
+
export const relationships = createContentModelSchema({
|
|
15
|
+
attributes: {
|
|
16
|
+
of: { type: String, required: false, default: '', description: 'Entity to describe — an id (e.g. `of=$item.id`) or a bound entity.' },
|
|
17
|
+
kind: { type: String, required: false, default: '', description: 'Edge kinds to include, comma-separated (e.g. "blocks,blocked-by").' },
|
|
18
|
+
type: { type: String, required: false, default: '', description: 'Restrict related entity types, comma-separated.' },
|
|
19
|
+
group: { type: String, required: false, default: 'kind', description: 'Group-by: kind (default) | type | none.' },
|
|
20
|
+
'group-display': { type: String, required: false, default: 'headings', matches: ['headings', 'accordion'], description: 'How groups are presented: headings (default) or accordion (collapsible native <details> panels, styled like the accordion rune, with a per-group count).' },
|
|
21
|
+
sort: { type: String, required: false, default: '', description: 'Sort related entities by a field (prefix - for descending).' },
|
|
22
|
+
limit: { type: String, required: false, default: '', description: 'Max edges.' },
|
|
23
|
+
fields: { type: String, required: false, default: '', description: 'Comma-separated data fields to project in the no-body built-in.' },
|
|
24
|
+
layout: { type: String, required: false, default: 'list', description: 'Arrangement: list (stacked) | grid (multi-column). Item chrome comes from the item — the no-body built-in, or a rune like {% card %} in the body template.' },
|
|
25
|
+
empty: { type: String, required: false, default: '', description: 'Fallback text shown when there are no edges (no-body form; body form uses a fallback zone). Absent → render nothing.' },
|
|
26
|
+
},
|
|
27
|
+
deferBody: true,
|
|
28
|
+
contentModel: { type: 'sequence', fields: [] },
|
|
29
|
+
transform(_resolved, attrs) {
|
|
30
|
+
const meta = (field, content) => new Tag('meta', { 'data-field': field, content });
|
|
31
|
+
const bodySource = readDeferredBody(attrs) ?? '';
|
|
32
|
+
// `of` accepts an id string or a bound entity object ({ id, … }).
|
|
33
|
+
const ofRaw = attrs.of;
|
|
34
|
+
const of = ofRaw && typeof ofRaw === 'object'
|
|
35
|
+
? String(ofRaw.id ?? '')
|
|
36
|
+
: String(ofRaw ?? '');
|
|
37
|
+
const metas = [
|
|
38
|
+
meta('relationships-of', of),
|
|
39
|
+
meta('relationships-kind', String(attrs.kind ?? '')),
|
|
40
|
+
meta('relationships-type', String(attrs.type ?? '')),
|
|
41
|
+
meta('relationships-group', String(attrs.group ?? 'kind')),
|
|
42
|
+
meta('relationships-group-display', String(attrs['group-display'] ?? 'headings')),
|
|
43
|
+
meta('relationships-sort', String(attrs.sort ?? '')),
|
|
44
|
+
meta('relationships-limit', String(attrs.limit ?? '')),
|
|
45
|
+
meta('relationships-fields', String(attrs.fields ?? '')),
|
|
46
|
+
meta('relationships-layout', String(attrs.layout ?? 'list')),
|
|
47
|
+
meta('relationships-empty', String(attrs.empty ?? '')),
|
|
48
|
+
meta(RELATIONSHIPS_SENTINEL, 'true'),
|
|
49
|
+
];
|
|
50
|
+
if (bodySource)
|
|
51
|
+
metas.push(meta('relationships-body', bodySource));
|
|
52
|
+
const placeholder = new Tag('div', { 'data-name': 'items' }, []);
|
|
53
|
+
return createComponentRenderable({
|
|
54
|
+
rune: 'relationships',
|
|
55
|
+
tag: 'section',
|
|
56
|
+
properties: {},
|
|
57
|
+
refs: { items: placeholder },
|
|
58
|
+
children: [...metas, placeholder],
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=relationships.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationships.js","sourceRoot":"","sources":["../../src/tags/relationships.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,wBAAwB,CAAC;IACrD,UAAU,EAAE;QACX,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,oEAAoE,EAAE;QACrI,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,oEAAoE,EAAE;QACvI,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,iDAAiD,EAAE;QACpH,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,W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IAAI,GAAG,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;QAEjE,OAAO,yBAAyB,CAAC;YAChC,IAAI,EAAE,eAAe;YACrB,GAAG,EAAE,SAAS;YACd,UAAU,EAAE,EAAE;YACd,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE;YAC5B,QAAQ,EAAE,CAAC,GAAG,KAAK,EAAE,WAAW,CAAC;SACjC,CAAC,CAAC;IACJ,CAAC;CACD,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snippet.d.ts","sourceRoot":"","sources":["../../src/tags/snippet.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"snippet.d.ts","sourceRoot":"","sources":["../../src/tags/snippet.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,OAAO,mCAyClB,CAAC"}
|
package/dist/tags/snippet.js
CHANGED
|
@@ -33,6 +33,16 @@ export const snippet = createContentModelSchema({
|
|
|
33
33
|
required: false,
|
|
34
34
|
description: 'Syntax-highlighting language hint. Overrides the extension-based inference.',
|
|
35
35
|
},
|
|
36
|
+
linenumbers: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
required: false,
|
|
39
|
+
description: 'Show line numbers in the gutter. Starting number derives from the `lines` range start (e.g. lines="74-125" → first line is 74), so numbers reflect the file\'s real offsets. WORK-304.',
|
|
40
|
+
},
|
|
41
|
+
highlight: {
|
|
42
|
+
type: String,
|
|
43
|
+
required: false,
|
|
44
|
+
description: 'Range(s) to emphasize without cropping — Shiki-style format: "74-78", "74-78,82,90-92". Indices are file coordinates (same frame as `lines=`). Use this when you want full context visible but want to draw the eye to specific lines. WORK-304.',
|
|
45
|
+
},
|
|
36
46
|
},
|
|
37
47
|
contentModel: { type: 'sequence', fields: [] },
|
|
38
48
|
transform(_resolved, _attrs) {
|
package/dist/tags/snippet.js.map
CHANGED
|
@@ -1 +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"}
|
|
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;QACD,WAAW,EAAE;YACZ,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,wLAAwL;SACrM;QACD,SAAS,EAAE;YACV,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,kPAAkP;SAC/P;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/tags/xref.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xref.d.ts","sourceRoot":"","sources":["../../src/tags/xref.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG7D,yFAAyF;AACzF,eAAO,MAAM,gBAAgB,SAAS,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"xref.d.ts","sourceRoot":"","sources":["../../src/tags/xref.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG7D,yFAAyF;AACzF,eAAO,MAAM,gBAAgB,SAAS,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,IAAI,EAAE,MA4ClB,CAAC"}
|
package/dist/tags/xref.js
CHANGED
|
@@ -34,11 +34,18 @@ export const xref = {
|
|
|
34
34
|
required: false,
|
|
35
35
|
description: 'Entity type hint for disambiguation',
|
|
36
36
|
},
|
|
37
|
+
preview: {
|
|
38
|
+
type: String,
|
|
39
|
+
required: false,
|
|
40
|
+
matches: ['drawer'],
|
|
41
|
+
description: 'Preview target. `"drawer"` hoists a drawer containing the entity\'s expanded content + a link to its resolved page URL in the chrome footer, leaving an inline link at the call site that opens it. Absent → today\'s behaviour (just the inline link). SPEC-078.',
|
|
42
|
+
},
|
|
37
43
|
},
|
|
38
44
|
transform(node, config) {
|
|
39
45
|
const id = node.attributes.primary;
|
|
40
46
|
const label = node.attributes.label;
|
|
41
47
|
const type = node.attributes.type;
|
|
48
|
+
const preview = node.attributes.preview;
|
|
42
49
|
const attrs = {
|
|
43
50
|
'data-rune': XREF_RUNE_MARKER,
|
|
44
51
|
'data-xref-id': id,
|
|
@@ -47,6 +54,8 @@ export const xref = {
|
|
|
47
54
|
attrs['data-xref-label'] = label;
|
|
48
55
|
if (type)
|
|
49
56
|
attrs['data-xref-type'] = type;
|
|
57
|
+
if (preview)
|
|
58
|
+
attrs['data-xref-preview'] = preview;
|
|
50
59
|
// Placeholder text: custom label or the raw reference string
|
|
51
60
|
return new Tag('span', attrs, [label || id]);
|
|
52
61
|
},
|
package/dist/tags/xref.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xref.js","sourceRoot":"","sources":["../../src/tags/xref.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAEvC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAExB,yFAAyF;AACzF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,IAAI,GAAW;IAC3B,WAAW,EAAE,IAAI;IACjB,MAAM,EAAE,IAAI;IACZ,UAAU,E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AAK;YACf,OAAO,EAAE,CAAC,QAAQ,CAAC;YACnB,WAAW,EAAE,mQAAmQ;SAChR;KACD;IACD,SAAS,CAAC,IAAU,EAAE,MAAc;QACnC,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,OAAiB,CAAC;QAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,KAA2B,CAAC;QAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAA0B,CAAC;QACxD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,OAA6B,CAAC;QAE9D,MAAM,KAAK,GAA2B;YACrC,WAAW,EAAE,gBAAgB;YAC7B,cAAc,EAAE,EAAE;SAClB,CAAC;QAEF,IAAI,KAAK;YAAE,KAAK,CAAC,iBAAiB,CAAC,GAAG,KAAK,CAAC;QAC5C,IAAI,IAAI;YAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;QACzC,IAAI,OAAO;YAAE,KAAK,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC;QAElD,6DAA6D;QAC7D,OAAO,IAAI,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9C,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* xref `preview="drawer"` resolver (SPEC-078, WORK-302).
|
|
3
|
+
*
|
|
4
|
+
* Runs BEFORE the drawer hoist pass. Walks the page renderable, finds
|
|
5
|
+
* xref placeholders carrying `data-xref-preview="drawer"`, and rewrites
|
|
6
|
+
* each as an inline `<a href="#drawer-{entityId}">` (with aria attrs)
|
|
7
|
+
* accompanied by a `hoist-drawer` sentinel that the drawer pipeline
|
|
8
|
+
* (WORK-300) picks up to render the actual drawer at the page root.
|
|
9
|
+
*
|
|
10
|
+
* Non-preview xref placeholders pass through unchanged — the existing
|
|
11
|
+
* `resolveXrefs` pass (later in the pipeline) handles those.
|
|
12
|
+
*
|
|
13
|
+
* Also registers a hoist builder for the `xref` source. The builder
|
|
14
|
+
* looks up the entity by id and emits a drawer whose body is an
|
|
15
|
+
* `expand-pending` placeholder for the entity — the `resolveExpands`
|
|
16
|
+
* pass that runs *after* the hoist substitutes the placeholder with
|
|
17
|
+
* the entity's actual content, so the drawer body ends up identical
|
|
18
|
+
* to a manual `{% drawer %}{% expand "X" /%}{% /drawer %}`.
|
|
19
|
+
*/
|
|
20
|
+
import type { EntityRegistry, PipelineContext } from '@refrakt-md/types';
|
|
21
|
+
/**
|
|
22
|
+
* Walk a page's renderable. For each xref placeholder with
|
|
23
|
+
* `data-xref-preview="drawer"`:
|
|
24
|
+
*
|
|
25
|
+
* - Replace the placeholder span with `<a href="#drawer-{id}">` carrying
|
|
26
|
+
* `aria-controls`, `aria-expanded="false"`, `data-target-type="drawer"`.
|
|
27
|
+
* - Emit a sibling `<meta data-field="hoist-drawer">` sentinel with
|
|
28
|
+
* `data-source="xref"` + the entity id + the authored label, for the
|
|
29
|
+
* drawer pipeline to consume.
|
|
30
|
+
*
|
|
31
|
+
* Non-preview xref placeholders are left for `resolveXrefs` to handle in
|
|
32
|
+
* its own pass.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveXrefPreviews(renderable: unknown, pageUrl: string, registry: Readonly<EntityRegistry> | undefined, ctx: PipelineContext): unknown;
|
|
35
|
+
//# sourceMappingURL=xref-preview-resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xref-preview-resolve.d.ts","sourceRoot":"","sources":["../src/xref-preview-resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAsB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAgB7F;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAClC,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,SAAS,EAC9C,GAAG,EAAE,eAAe,GAClB,OAAO,CAoCT"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* xref `preview="drawer"` resolver (SPEC-078, WORK-302).
|
|
3
|
+
*
|
|
4
|
+
* Runs BEFORE the drawer hoist pass. Walks the page renderable, finds
|
|
5
|
+
* xref placeholders carrying `data-xref-preview="drawer"`, and rewrites
|
|
6
|
+
* each as an inline `<a href="#drawer-{entityId}">` (with aria attrs)
|
|
7
|
+
* accompanied by a `hoist-drawer` sentinel that the drawer pipeline
|
|
8
|
+
* (WORK-300) picks up to render the actual drawer at the page root.
|
|
9
|
+
*
|
|
10
|
+
* Non-preview xref placeholders pass through unchanged — the existing
|
|
11
|
+
* `resolveXrefs` pass (later in the pipeline) handles those.
|
|
12
|
+
*
|
|
13
|
+
* Also registers a hoist builder for the `xref` source. The builder
|
|
14
|
+
* looks up the entity by id and emits a drawer whose body is an
|
|
15
|
+
* `expand-pending` placeholder for the entity — the `resolveExpands`
|
|
16
|
+
* pass that runs *after* the hoist substitutes the placeholder with
|
|
17
|
+
* the entity's actual content, so the drawer body ends up identical
|
|
18
|
+
* to a manual `{% drawer %}{% expand "X" /%}{% /drawer %}`.
|
|
19
|
+
*/
|
|
20
|
+
import Markdoc from '@markdoc/markdoc';
|
|
21
|
+
import { HOIST_DRAWER_SENTINEL, registerHoistBuilder, } from './drawer-pipeline.js';
|
|
22
|
+
import { XREF_RUNE_MARKER } from './tags/xref.js';
|
|
23
|
+
import { EXPAND_PLACEHOLDER_MARKER } from './tags/expand.js';
|
|
24
|
+
const { Tag } = Markdoc;
|
|
25
|
+
function isTag(node) {
|
|
26
|
+
return Tag.isTag(node);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Walk a page's renderable. For each xref placeholder with
|
|
30
|
+
* `data-xref-preview="drawer"`:
|
|
31
|
+
*
|
|
32
|
+
* - Replace the placeholder span with `<a href="#drawer-{id}">` carrying
|
|
33
|
+
* `aria-controls`, `aria-expanded="false"`, `data-target-type="drawer"`.
|
|
34
|
+
* - Emit a sibling `<meta data-field="hoist-drawer">` sentinel with
|
|
35
|
+
* `data-source="xref"` + the entity id + the authored label, for the
|
|
36
|
+
* drawer pipeline to consume.
|
|
37
|
+
*
|
|
38
|
+
* Non-preview xref placeholders are left for `resolveXrefs` to handle in
|
|
39
|
+
* its own pass.
|
|
40
|
+
*/
|
|
41
|
+
export function resolveXrefPreviews(renderable, pageUrl, registry, ctx) {
|
|
42
|
+
const walk = (node) => {
|
|
43
|
+
if (Array.isArray(node)) {
|
|
44
|
+
let mutated = false;
|
|
45
|
+
const out = [];
|
|
46
|
+
for (const c of node) {
|
|
47
|
+
const w = walk(c);
|
|
48
|
+
if (w !== c)
|
|
49
|
+
mutated = true;
|
|
50
|
+
if (Array.isArray(w))
|
|
51
|
+
out.push(...w);
|
|
52
|
+
else
|
|
53
|
+
out.push(w);
|
|
54
|
+
}
|
|
55
|
+
return mutated ? out : node;
|
|
56
|
+
}
|
|
57
|
+
if (!isTag(node))
|
|
58
|
+
return node;
|
|
59
|
+
const tag = node;
|
|
60
|
+
if (tag.attributes?.['data-rune'] === XREF_RUNE_MARKER
|
|
61
|
+
&& tag.attributes?.['data-xref-preview'] === 'drawer') {
|
|
62
|
+
return resolveOne(tag, registry, ctx, pageUrl);
|
|
63
|
+
}
|
|
64
|
+
if (!tag.children || tag.children.length === 0)
|
|
65
|
+
return tag;
|
|
66
|
+
let mutated = false;
|
|
67
|
+
const next = [];
|
|
68
|
+
for (const c of tag.children) {
|
|
69
|
+
const w = walk(c);
|
|
70
|
+
if (w !== c)
|
|
71
|
+
mutated = true;
|
|
72
|
+
if (Array.isArray(w))
|
|
73
|
+
next.push(...w);
|
|
74
|
+
else
|
|
75
|
+
next.push(w);
|
|
76
|
+
}
|
|
77
|
+
if (!mutated)
|
|
78
|
+
return tag;
|
|
79
|
+
return new Tag(tag.name, tag.attributes, next);
|
|
80
|
+
};
|
|
81
|
+
return walk(renderable);
|
|
82
|
+
}
|
|
83
|
+
function resolveOne(placeholder, registry, ctx, pageUrl) {
|
|
84
|
+
const attrs = placeholder.attributes;
|
|
85
|
+
const id = String(attrs['data-xref-id'] ?? '');
|
|
86
|
+
const authoredLabel = attrs['data-xref-label'];
|
|
87
|
+
if (!id) {
|
|
88
|
+
ctx.warn(`xref preview placeholder on ${pageUrl} has no entity id`, pageUrl);
|
|
89
|
+
return [placeholder];
|
|
90
|
+
}
|
|
91
|
+
// Try to resolve the entity title for the inline link label when the
|
|
92
|
+
// author didn't supply an explicit `label=`. Fall back to the id.
|
|
93
|
+
const entity = registry ? findEntity(registry, id) : undefined;
|
|
94
|
+
const label = authoredLabel
|
|
95
|
+
|| (entity ? entityDisplayLabel(entity) : id);
|
|
96
|
+
const entityTitle = entity ? entityDisplayLabel(entity) : id;
|
|
97
|
+
const slug = id;
|
|
98
|
+
const anchor = new Tag('a', {
|
|
99
|
+
class: 'rf-xref',
|
|
100
|
+
href: `#drawer-${slug}`,
|
|
101
|
+
'aria-controls': `drawer-${slug}`,
|
|
102
|
+
'aria-expanded': 'false',
|
|
103
|
+
'data-target-type': 'drawer',
|
|
104
|
+
'data-xref-id': id,
|
|
105
|
+
}, [label]);
|
|
106
|
+
const sentinel = new Tag('meta', {
|
|
107
|
+
'data-field': HOIST_DRAWER_SENTINEL,
|
|
108
|
+
'data-source': 'xref',
|
|
109
|
+
'data-target-id': slug,
|
|
110
|
+
'data-title': entityTitle,
|
|
111
|
+
'data-entity-id': id,
|
|
112
|
+
});
|
|
113
|
+
return [anchor, sentinel];
|
|
114
|
+
}
|
|
115
|
+
function findEntity(registry, id) {
|
|
116
|
+
const types = registry.getTypes?.() ?? [];
|
|
117
|
+
for (const type of types) {
|
|
118
|
+
const e = registry.getById(type, id);
|
|
119
|
+
if (e)
|
|
120
|
+
return e;
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
function entityDisplayLabel(entity) {
|
|
125
|
+
const data = entity.data;
|
|
126
|
+
return String(data.title ?? data.name ?? entity.id);
|
|
127
|
+
}
|
|
128
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
129
|
+
// Hoist builder for the `xref` source — looks up the entity, builds a
|
|
130
|
+
// drawer with an expand-pending body that `resolveExpands` resolves
|
|
131
|
+
// downstream, and a chrome footer linking to the entity's page URL.
|
|
132
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
133
|
+
function buildXrefHoist(payload, context) {
|
|
134
|
+
const entityId = payload['entity-id'] || payload['target-id'];
|
|
135
|
+
const targetId = payload['target-id'];
|
|
136
|
+
const title = payload.title || entityId;
|
|
137
|
+
if (!entityId || !targetId) {
|
|
138
|
+
context.ctx.warn(`xref hoist payload missing required entity-id or target-id`, context.pageUrl);
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
const entity = context.registry ? findEntity(context.registry, entityId) : undefined;
|
|
142
|
+
// Header — title + close button (same shape author-declared drawers use).
|
|
143
|
+
const titleHeading = new Tag('h3', { 'data-name': 'title', class: 'rf-drawer__title' }, [title]);
|
|
144
|
+
const closeButton = new Tag('button', {
|
|
145
|
+
type: 'button',
|
|
146
|
+
'aria-label': 'Close',
|
|
147
|
+
hidden: true,
|
|
148
|
+
'data-name': 'close',
|
|
149
|
+
class: 'rf-drawer__close',
|
|
150
|
+
}, ['×']);
|
|
151
|
+
const header = new Tag('header', {
|
|
152
|
+
'data-name': 'header',
|
|
153
|
+
class: 'rf-drawer__header',
|
|
154
|
+
}, [titleHeading, closeButton]);
|
|
155
|
+
// Body — an expand-pending placeholder. `resolveExpands` runs after
|
|
156
|
+
// `hoistPreviewDrawers` in the pipeline and substitutes this with the
|
|
157
|
+
// entity's actual content, identical to a hand-authored
|
|
158
|
+
// `{% drawer %}{% expand "X" /%}{% /drawer %}` composition.
|
|
159
|
+
const expandPlaceholder = new Tag('div', {
|
|
160
|
+
'data-rune': EXPAND_PLACEHOLDER_MARKER,
|
|
161
|
+
'data-expand-id': entityId,
|
|
162
|
+
}, []);
|
|
163
|
+
const bodyChildren = [expandPlaceholder];
|
|
164
|
+
const body = new Tag('div', { 'data-name': 'body', class: 'rf-drawer__body' }, bodyChildren);
|
|
165
|
+
// Footer — link to the entity's page URL (when one resolves). Hides
|
|
166
|
+
// silently for entities without a sourceUrl (heading entities,
|
|
167
|
+
// drawer-target entities).
|
|
168
|
+
const footerHref = entity?.sourceUrl ?? '';
|
|
169
|
+
const footer = footerHref
|
|
170
|
+
? new Tag('footer', { 'data-name': 'footer', class: 'rf-drawer__footer' }, [
|
|
171
|
+
new Tag('a', { href: footerHref }, [`View full page →`]),
|
|
172
|
+
])
|
|
173
|
+
: null;
|
|
174
|
+
const drawerChildren = [header, body];
|
|
175
|
+
if (footer)
|
|
176
|
+
drawerChildren.push(footer);
|
|
177
|
+
return new Tag('section', {
|
|
178
|
+
id: `drawer-${targetId}`,
|
|
179
|
+
class: 'rf-drawer',
|
|
180
|
+
'data-rune': 'drawer',
|
|
181
|
+
'data-drawer-id': targetId,
|
|
182
|
+
'data-side': 'right',
|
|
183
|
+
'data-size': 'md',
|
|
184
|
+
}, drawerChildren);
|
|
185
|
+
}
|
|
186
|
+
// Register at module load.
|
|
187
|
+
registerHoistBuilder('xref', buildXrefHoist);
|
|
188
|
+
//# sourceMappingURL=xref-preview-resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xref-preview-resolve.js","sourceRoot":"","sources":["../src/xref-preview-resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAGvC,OAAO,EACN,qBAAqB,EACrB,oBAAoB,GAEpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,EAA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