@refrakt-md/runes 0.38.0 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collection-helpers.d.ts +21 -2
- package/dist/collection-helpers.d.ts.map +1 -1
- package/dist/collection-helpers.js +72 -15
- package/dist/collection-helpers.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +73 -40
- package/dist/config.js.map +1 -1
- package/dist/data-pipeline.d.ts +24 -10
- package/dist/data-pipeline.d.ts.map +1 -1
- package/dist/data-pipeline.js +34 -56
- package/dist/data-pipeline.js.map +1 -1
- package/dist/file-ref-resolve.js +9 -13
- package/dist/file-ref-resolve.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +47 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +112 -5
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/preprocess.d.ts +63 -0
- package/dist/lib/preprocess.d.ts.map +1 -0
- package/dist/lib/preprocess.js +71 -0
- package/dist/lib/preprocess.js.map +1 -0
- package/dist/lib/registers.d.ts +132 -0
- package/dist/lib/registers.d.ts.map +1 -0
- package/dist/lib/registers.js +328 -0
- package/dist/lib/registers.js.map +1 -0
- package/dist/lib/resolver.d.ts +9 -1
- package/dist/lib/resolver.d.ts.map +1 -1
- package/dist/lib/resolver.js +16 -0
- package/dist/lib/resolver.js.map +1 -1
- package/dist/lib/schema-table.d.ts +46 -9
- package/dist/lib/schema-table.d.ts.map +1 -1
- package/dist/lib/schema-table.js +111 -22
- package/dist/lib/schema-table.js.map +1 -1
- package/dist/lib/slots.d.ts +99 -0
- package/dist/lib/slots.d.ts.map +1 -0
- package/dist/lib/slots.js +448 -0
- package/dist/lib/slots.js.map +1 -0
- package/dist/reference.d.ts +18 -0
- package/dist/reference.d.ts.map +1 -1
- package/dist/reference.js +34 -1
- package/dist/reference.js.map +1 -1
- package/dist/registers-pipeline.d.ts +50 -0
- package/dist/registers-pipeline.d.ts.map +1 -0
- package/dist/registers-pipeline.js +218 -0
- package/dist/registers-pipeline.js.map +1 -0
- package/dist/schema-row.d.ts +5 -0
- package/dist/schema-row.d.ts.map +1 -1
- package/dist/schema-row.js +1 -0
- package/dist/schema-row.js.map +1 -1
- package/dist/tags/data.d.ts +2 -2
- package/dist/tags/data.d.ts.map +1 -1
- package/dist/tags/data.js +6 -4
- package/dist/tags/data.js.map +1 -1
- package/dist/tags/figure.d.ts +10 -4
- package/dist/tags/figure.d.ts.map +1 -1
- package/dist/tags/figure.js +65 -20
- package/dist/tags/figure.js.map +1 -1
- package/dist/tags/include.d.ts +51 -7
- package/dist/tags/include.d.ts.map +1 -1
- package/dist/tags/include.js +216 -7
- package/dist/tags/include.js.map +1 -1
- package/dist/tags/snippet.d.ts +9 -10
- package/dist/tags/snippet.d.ts.map +1 -1
- package/dist/tags/snippet.js +213 -10
- package/dist/tags/snippet.js.map +1 -1
- package/dist/universal-attributes.d.ts +1 -1
- package/package.json +3 -3
- package/dist/include-pipeline.d.ts +0 -52
- package/dist/include-pipeline.d.ts.map +0 -1
- package/dist/include-pipeline.js +0 -206
- package/dist/include-pipeline.js.map +0 -1
- package/dist/snippet-pipeline.d.ts +0 -44
- package/dist/snippet-pipeline.d.ts.map +0 -1
- package/dist/snippet-pipeline.js +0 -307
- package/dist/snippet-pipeline.js.map +0 -1
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The slot declaration — SPEC-143.
|
|
3
|
+
*
|
|
4
|
+
* A rune whose every output slot comes from exactly one resolved field, wrapped
|
|
5
|
+
* but not restructured (D4), states that as data on `createContentModelSchema`
|
|
6
|
+
* instead of writing a `transform`:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* emits: {
|
|
10
|
+
* rune: 'work',
|
|
11
|
+
* tag: 'article',
|
|
12
|
+
* properties: { id: '', status: 'draft' },
|
|
13
|
+
* slots: {
|
|
14
|
+
* title: { as: 'region', el: 'header' },
|
|
15
|
+
* blurb: { from: 'description', as: 'region', omitWhenEmpty: true },
|
|
16
|
+
* body: { from: 'sections', as: 'region' },
|
|
17
|
+
* },
|
|
18
|
+
* },
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* `makeSlotTransform` turns that into an ordinary transform function — a closure
|
|
22
|
+
* over the declaration, built once when the schema is constructed — and the
|
|
23
|
+
* schema calls it at the same single call site a hand-written transform uses.
|
|
24
|
+
* Nothing downstream can tell the two apart, which is what makes the
|
|
25
|
+
* byte-identical migration gate (D7) a property of the construction rather than
|
|
26
|
+
* a hope.
|
|
27
|
+
*
|
|
28
|
+
* What the declaration may say, and nothing more (D2): a slot's name, the field
|
|
29
|
+
* (or attribute) it comes from, whether it is a single `value` or a `region` of
|
|
30
|
+
* nodes with a boundary element, and whether it is omitted when empty. It
|
|
31
|
+
* cannot nest one slot in another, order slots, or create containers — those
|
|
32
|
+
* belong to the engine's `layout`. Every value is data (D9), so the declaration
|
|
33
|
+
* round-trips through JSON unchanged.
|
|
34
|
+
*/
|
|
35
|
+
import Markdoc from '@markdoc/markdoc';
|
|
36
|
+
import { createComponentRenderable } from './component.js';
|
|
37
|
+
import { fieldMetas } from './field-metas.js';
|
|
38
|
+
import { selectStructuralModel } from './resolver.js';
|
|
39
|
+
const { Tag } = Markdoc;
|
|
40
|
+
/** The closed vocabulary of section roles — mirrors `SectionRole`. */
|
|
41
|
+
const SECTION_ROLES = [
|
|
42
|
+
'header',
|
|
43
|
+
'preamble',
|
|
44
|
+
'title',
|
|
45
|
+
'description',
|
|
46
|
+
'body',
|
|
47
|
+
'footer',
|
|
48
|
+
'media',
|
|
49
|
+
];
|
|
50
|
+
const EMITS_KEYS = new Set(['rune', 'tag', 'property', 'properties', 'slots']);
|
|
51
|
+
const SLOT_KEYS = new Set(['from', 'as', 'el', 'omitWhenEmpty', 'role']);
|
|
52
|
+
/** Keys that would make a slot structural. Named so the refusal can say why (D2). */
|
|
53
|
+
const STRUCTURE_KEYS = new Set([
|
|
54
|
+
'slots',
|
|
55
|
+
'children',
|
|
56
|
+
'nest',
|
|
57
|
+
'nested',
|
|
58
|
+
'into',
|
|
59
|
+
'parent',
|
|
60
|
+
'wrap',
|
|
61
|
+
'wrapper',
|
|
62
|
+
'container',
|
|
63
|
+
'group',
|
|
64
|
+
'order',
|
|
65
|
+
'position',
|
|
66
|
+
'before',
|
|
67
|
+
'after',
|
|
68
|
+
'layout',
|
|
69
|
+
]);
|
|
70
|
+
const ELEMENT = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
71
|
+
const SLOT_NAME = /^[a-z][a-zA-Z0-9]*(-[a-zA-Z0-9]+)*$/;
|
|
72
|
+
const RUNE_NAME = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
73
|
+
/**
|
|
74
|
+
* Reject anything that would not survive `JSON.parse(JSON.stringify(…))`
|
|
75
|
+
* unchanged — a function above all (D9), but also `undefined`, a non-finite
|
|
76
|
+
* number, or a class instance such as a `RegExp`.
|
|
77
|
+
*/
|
|
78
|
+
function assertPlainData(value, path, fail) {
|
|
79
|
+
if (typeof value === 'function') {
|
|
80
|
+
fail(`${path} is a function. The declaration is data only (SPEC-143 D9).`);
|
|
81
|
+
}
|
|
82
|
+
if (value === undefined) {
|
|
83
|
+
fail(`${path} is undefined, which does not survive a JSON round-trip — omit the key.`);
|
|
84
|
+
}
|
|
85
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
86
|
+
return;
|
|
87
|
+
if (typeof value === 'number') {
|
|
88
|
+
if (!Number.isFinite(value))
|
|
89
|
+
fail(`${path} is not a finite number.`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (Array.isArray(value)) {
|
|
93
|
+
value.forEach((v, i) => assertPlainData(v, `${path}[${i}]`, fail));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (typeof value === 'object') {
|
|
97
|
+
const proto = Object.getPrototypeOf(value);
|
|
98
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
99
|
+
fail(`${path} is a ${proto?.constructor?.name ?? 'class'} instance, not plain data.`);
|
|
100
|
+
}
|
|
101
|
+
for (const [k, v] of Object.entries(value)) {
|
|
102
|
+
assertPlainData(v, `${path}.${k}`, fail);
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
fail(`${path} has unsupported type ${typeof value}.`);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Every field the content model can resolve, across conditional branches. A
|
|
110
|
+
* model given as a function of attributes is sampled with no attributes —
|
|
111
|
+
* enough for a model that only varies its details, which is every model this
|
|
112
|
+
* declaration supports.
|
|
113
|
+
*/
|
|
114
|
+
function collectFields(model) {
|
|
115
|
+
const fields = new Map();
|
|
116
|
+
const unsupported = new Set();
|
|
117
|
+
const visit = (m) => {
|
|
118
|
+
if ('when' in m) {
|
|
119
|
+
m.when.forEach((b) => visit(b.model));
|
|
120
|
+
visit(m.default);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const s = m;
|
|
124
|
+
if (s.type === 'sequence' || s.type === 'sections') {
|
|
125
|
+
for (const f of s.fields ?? []) {
|
|
126
|
+
const prev = fields.get(f.name);
|
|
127
|
+
fields.set(f.name, { greedy: !!f.greedy || !!prev?.greedy, sections: false });
|
|
128
|
+
}
|
|
129
|
+
if (s.type === 'sections')
|
|
130
|
+
fields.set('sections', { greedy: true, sections: true });
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
unsupported.add(s.type);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
visit(typeof model === 'function' ? model({}) : model);
|
|
137
|
+
return { fields, unsupported };
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Check a declaration against the rune's content model and normalise it.
|
|
141
|
+
* Throws, naming the rune and the offending slot, rather than applying any part
|
|
142
|
+
* of a declaration it cannot honour.
|
|
143
|
+
*/
|
|
144
|
+
export function validateEmits(emits, contentModel) {
|
|
145
|
+
const runeLabel = emits && typeof emits === 'object' && typeof emits.rune === 'string'
|
|
146
|
+
? `"${emits.rune}"`
|
|
147
|
+
: '(unnamed)';
|
|
148
|
+
const fail = (msg) => {
|
|
149
|
+
throw new Error(`Rune ${runeLabel}: invalid \`emits\` declaration — ${msg}`);
|
|
150
|
+
};
|
|
151
|
+
if (!emits || typeof emits !== 'object' || Array.isArray(emits))
|
|
152
|
+
fail('must be an object.');
|
|
153
|
+
assertPlainData(emits, 'emits', fail);
|
|
154
|
+
for (const key of Object.keys(emits)) {
|
|
155
|
+
if (!EMITS_KEYS.has(key)) {
|
|
156
|
+
fail(STRUCTURE_KEYS.has(key)
|
|
157
|
+
? `\`${key}\` would declare structure. The declaration names slots only; nesting, ordering and containers are \`layout\`'s (SPEC-143 D2).`
|
|
158
|
+
: `unknown key \`${key}\` (expected ${[...EMITS_KEYS].join(', ')}).`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (typeof emits.rune !== 'string' || !RUNE_NAME.test(emits.rune)) {
|
|
162
|
+
fail('`rune` must be the kebab-case rune name.');
|
|
163
|
+
}
|
|
164
|
+
if (typeof emits.tag !== 'string' || !ELEMENT.test(emits.tag)) {
|
|
165
|
+
fail('`tag` must be an element name.');
|
|
166
|
+
}
|
|
167
|
+
if (emits.property !== undefined && typeof emits.property !== 'string') {
|
|
168
|
+
fail('`property` must be a string.');
|
|
169
|
+
}
|
|
170
|
+
const propertyKeys = new Set();
|
|
171
|
+
if (emits.properties !== undefined) {
|
|
172
|
+
if (typeof emits.properties !== 'object' || Array.isArray(emits.properties)) {
|
|
173
|
+
fail('`properties` must be an object.');
|
|
174
|
+
}
|
|
175
|
+
for (const [key, entry] of Object.entries(emits.properties)) {
|
|
176
|
+
propertyKeys.add(key);
|
|
177
|
+
if (typeof entry === 'string')
|
|
178
|
+
continue;
|
|
179
|
+
const ok = entry &&
|
|
180
|
+
typeof entry === 'object' &&
|
|
181
|
+
Array.isArray(entry.from) &&
|
|
182
|
+
entry.from.every((s) => typeof s === 'string' && /^(attrs|file)\.\S+$/.test(s)) &&
|
|
183
|
+
typeof entry.default === 'string' &&
|
|
184
|
+
Object.keys(entry).every((k) => k === 'from' || k === 'default');
|
|
185
|
+
if (!ok) {
|
|
186
|
+
fail(`property \`${key}\` must be a default string or { from: ["attrs.<name>" | "file.<name>", …], default: string }.`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (!emits.slots || typeof emits.slots !== 'object' || Array.isArray(emits.slots)) {
|
|
191
|
+
fail('`slots` must be an object of slot entries.');
|
|
192
|
+
}
|
|
193
|
+
const slotNames = Object.keys(emits.slots);
|
|
194
|
+
if (slotNames.length === 0)
|
|
195
|
+
fail('`slots` declares no slot.');
|
|
196
|
+
const { fields, unsupported } = collectFields(contentModel);
|
|
197
|
+
const normalized = [];
|
|
198
|
+
for (const name of slotNames) {
|
|
199
|
+
const where = `slot \`${name}\``;
|
|
200
|
+
if (!SLOT_NAME.test(name))
|
|
201
|
+
fail(`${where}: not a valid data-name.`);
|
|
202
|
+
if (propertyKeys.has(name)) {
|
|
203
|
+
fail(`${where} is also a property. Properties and slots share one flat namespace (ADR-008), and the two would carry one name on two nodes.`);
|
|
204
|
+
}
|
|
205
|
+
const raw = emits.slots[name];
|
|
206
|
+
const decl = typeof raw === 'string' ? { as: raw } : raw;
|
|
207
|
+
if (!decl || typeof decl !== 'object' || Array.isArray(decl)) {
|
|
208
|
+
fail(`${where} must be "value", "region" or a slot declaration.`);
|
|
209
|
+
}
|
|
210
|
+
for (const key of Object.keys(decl)) {
|
|
211
|
+
if (SLOT_KEYS.has(key))
|
|
212
|
+
continue;
|
|
213
|
+
fail(STRUCTURE_KEYS.has(key)
|
|
214
|
+
? `${where}: \`${key}\` would nest, order or contain slots. A slot is flat — that is \`layout\`'s job (SPEC-143 D2).`
|
|
215
|
+
: `${where}: unknown key \`${key}\` (expected ${[...SLOT_KEYS].join(', ')}).`);
|
|
216
|
+
}
|
|
217
|
+
if (decl.as !== 'value' && decl.as !== 'region') {
|
|
218
|
+
fail(`${where}: \`as\` must be "value" or "region".`);
|
|
219
|
+
}
|
|
220
|
+
if (decl.el !== undefined && (typeof decl.el !== 'string' || !ELEMENT.test(decl.el))) {
|
|
221
|
+
fail(`${where}: \`el\` must be a single element name — a slot has one boundary, never a nested one (SPEC-143 D2).`);
|
|
222
|
+
}
|
|
223
|
+
if (decl.omitWhenEmpty !== undefined && typeof decl.omitWhenEmpty !== 'boolean') {
|
|
224
|
+
fail(`${where}: \`omitWhenEmpty\` must be a boolean.`);
|
|
225
|
+
}
|
|
226
|
+
if (decl.role !== undefined && !SECTION_ROLES.includes(decl.role)) {
|
|
227
|
+
fail(`${where}: \`role\` must be one of ${SECTION_ROLES.join(', ')}.`);
|
|
228
|
+
}
|
|
229
|
+
const from = decl.from ?? name;
|
|
230
|
+
if (typeof from !== 'string' || from === '')
|
|
231
|
+
fail(`${where}: \`from\` must be a string.`);
|
|
232
|
+
const slot = {
|
|
233
|
+
name,
|
|
234
|
+
kind: decl.as,
|
|
235
|
+
el: decl.el,
|
|
236
|
+
omitWhenEmpty: decl.omitWhenEmpty ?? false,
|
|
237
|
+
role: decl.role,
|
|
238
|
+
};
|
|
239
|
+
if (from.startsWith('attrs.')) {
|
|
240
|
+
slot.attr = from.slice('attrs.'.length);
|
|
241
|
+
if (!slot.attr)
|
|
242
|
+
fail(`${where}: \`from\` names no attribute.`);
|
|
243
|
+
if (decl.as !== 'value') {
|
|
244
|
+
fail(`${where}: an attribute is one value; it cannot be a region.`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
if (from.includes('.')) {
|
|
249
|
+
fail(`${where}: \`from\` is a content field name or "attrs.<name>", not "${from}".`);
|
|
250
|
+
}
|
|
251
|
+
const info = fields.get(from);
|
|
252
|
+
if (!info) {
|
|
253
|
+
const known = [...fields.keys()];
|
|
254
|
+
fail(unsupported.size > 0 && known.length === 0
|
|
255
|
+
? `${where}: the content model is ${[...unsupported].join(' / ')}, which the slot declaration does not read. Keep a \`transform\` (SPEC-143 D3).`
|
|
256
|
+
: `${where}: \`from: "${from}"\` names no field of the content model (fields: ${known.join(', ') || 'none'}).`);
|
|
257
|
+
}
|
|
258
|
+
slot.field = from;
|
|
259
|
+
if (decl.as === 'value') {
|
|
260
|
+
if (info.greedy) {
|
|
261
|
+
fail(`${where}: field \`${from}\` can resolve to several nodes, and a value slot names every node it emits — that is two nodes carrying data-name="${name}". Declare it \`as: "region"\`.`);
|
|
262
|
+
}
|
|
263
|
+
if (decl.el !== undefined) {
|
|
264
|
+
fail(`${where}: a value read from a field is already one node; there is nothing to wrap. Declare it \`as: "region"\` to give it a boundary.`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
normalized.push(slot);
|
|
269
|
+
}
|
|
270
|
+
return normalized;
|
|
271
|
+
}
|
|
272
|
+
function isRole(name) {
|
|
273
|
+
return name !== undefined && SECTION_ROLES.includes(name);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The `sections` join table a declaration implies — slot name → section role.
|
|
277
|
+
* A slot's role is the one it states, else its own name when that is a role,
|
|
278
|
+
* else its source field's name when that is one.
|
|
279
|
+
*/
|
|
280
|
+
export function slotSections(emits) {
|
|
281
|
+
const out = {};
|
|
282
|
+
for (const [name, raw] of Object.entries(emits.slots)) {
|
|
283
|
+
const decl = typeof raw === 'string' ? { as: raw } : raw;
|
|
284
|
+
const from = decl.from ?? name;
|
|
285
|
+
const role = decl.role ?? (isRole(name) ? name : isRole(from) ? from : undefined);
|
|
286
|
+
if (role)
|
|
287
|
+
out[name] = role;
|
|
288
|
+
}
|
|
289
|
+
return out;
|
|
290
|
+
}
|
|
291
|
+
function asNodes(value) {
|
|
292
|
+
if (Array.isArray(value))
|
|
293
|
+
return value;
|
|
294
|
+
if (value != null)
|
|
295
|
+
return [value];
|
|
296
|
+
return [];
|
|
297
|
+
}
|
|
298
|
+
function render(value, config) {
|
|
299
|
+
return Markdoc.transform(asNodes(value), config);
|
|
300
|
+
}
|
|
301
|
+
/** Heading text → `data-name` slug, for a section with no canonical slug. */
|
|
302
|
+
function slugify(text) {
|
|
303
|
+
return text
|
|
304
|
+
.toLowerCase()
|
|
305
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
306
|
+
.replace(/^-|-$/g, '');
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* One resolved section entry (a `sections` model without `emitTag`) as a
|
|
310
|
+
* `<section>` named by its slug: its heading, then its resolved fields.
|
|
311
|
+
*
|
|
312
|
+
* The slug is the entry's own identity — the known section's language-stable
|
|
313
|
+
* `$canonicalSlug` (SPEC-035), else the heading text slugified — and a known
|
|
314
|
+
* section's heading carries `data-known-section` so a table of contents can
|
|
315
|
+
* pick the known sections out. A top-level thematic break in the body is the
|
|
316
|
+
* author's separator between thoughts, not content, and is dropped.
|
|
317
|
+
*/
|
|
318
|
+
function renderSectionEntry(entry, config) {
|
|
319
|
+
const heading = entry.$heading ?? '';
|
|
320
|
+
const canonicalName = entry.$canonicalName;
|
|
321
|
+
const slug = entry.$canonicalSlug ?? slugify(heading);
|
|
322
|
+
const children = [];
|
|
323
|
+
const headingNode = entry.$headingNode;
|
|
324
|
+
if (headingNode) {
|
|
325
|
+
const renderedHeading = render([headingNode], config);
|
|
326
|
+
const first = renderedHeading[0];
|
|
327
|
+
if (canonicalName && Tag.isTag(first)) {
|
|
328
|
+
first.attributes['data-known-section'] = canonicalName;
|
|
329
|
+
}
|
|
330
|
+
children.push(...renderedHeading);
|
|
331
|
+
}
|
|
332
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
333
|
+
if (key.startsWith('$'))
|
|
334
|
+
continue;
|
|
335
|
+
children.push(...render(value, config).filter((n) => !(Tag.isTag(n) && n.name === 'hr')));
|
|
336
|
+
}
|
|
337
|
+
return new Tag('section', { 'data-name': slug }, children);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Build the transform a declaration describes. Called once, when the schema is
|
|
341
|
+
* constructed; the closure it returns has the signature of a hand-written
|
|
342
|
+
* transform and is called where one would be.
|
|
343
|
+
*/
|
|
344
|
+
export function makeSlotTransform(emits, contentModel) {
|
|
345
|
+
const slots = validateEmits(emits, contentModel);
|
|
346
|
+
const { rune, tag, property, properties } = emits;
|
|
347
|
+
return (resolved, attrs, config, node) => {
|
|
348
|
+
// D5 — whether sections arrive as resolved entries or as emitted child
|
|
349
|
+
// runes is the content model's `emitTag`; read it, per instance, from the
|
|
350
|
+
// branch the resolver actually took.
|
|
351
|
+
let structural;
|
|
352
|
+
const sectionsEmitTag = () => {
|
|
353
|
+
structural ??= selectStructuralModel(node.children, typeof contentModel === 'function' ? contentModel(attrs) : contentModel, attrs);
|
|
354
|
+
return structural.type === 'sections' ? structural.emitTag : undefined;
|
|
355
|
+
};
|
|
356
|
+
const refs = {};
|
|
357
|
+
const children = [];
|
|
358
|
+
for (const slot of slots) {
|
|
359
|
+
let out;
|
|
360
|
+
if (slot.attr !== undefined) {
|
|
361
|
+
const value = attrs[slot.attr];
|
|
362
|
+
if (slot.omitWhenEmpty && (value == null || value === ''))
|
|
363
|
+
continue;
|
|
364
|
+
out = new Tag(slot.el ?? 'span', {}, [value ?? '']);
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
const field = slot.field;
|
|
368
|
+
let nodes;
|
|
369
|
+
if (field === 'sections' && sectionsEmitTag() === undefined) {
|
|
370
|
+
nodes = asNodes(resolved.sections).map((entry) => renderSectionEntry(entry, config));
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
nodes = render(resolved[field], config);
|
|
374
|
+
}
|
|
375
|
+
if (slot.kind === 'value') {
|
|
376
|
+
if (nodes.length === 0)
|
|
377
|
+
continue;
|
|
378
|
+
const only = nodes[0];
|
|
379
|
+
if (nodes.length > 1 || !Tag.isTag(only)) {
|
|
380
|
+
throw new Error(`Rune "${rune}": value slot \`${slot.name}\` rendered ${nodes.length} node(s), not one element. A value slot names exactly one node.`);
|
|
381
|
+
}
|
|
382
|
+
out = only;
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
if (nodes.length === 0 && slot.omitWhenEmpty)
|
|
386
|
+
continue;
|
|
387
|
+
out = new Tag(slot.el ?? 'div', {}, nodes);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
refs[slot.name] = out;
|
|
391
|
+
children.push(out);
|
|
392
|
+
}
|
|
393
|
+
return createComponentRenderable({
|
|
394
|
+
rune,
|
|
395
|
+
tag: tag,
|
|
396
|
+
property,
|
|
397
|
+
properties: properties ? fieldMetas(attrs, config, properties) : undefined,
|
|
398
|
+
refs,
|
|
399
|
+
children,
|
|
400
|
+
});
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* A declaration with every default made explicit — what the generated transform
|
|
405
|
+
* will actually do, which is the thing a reviewer needs and the declaration's
|
|
406
|
+
* terseness hides.
|
|
407
|
+
*/
|
|
408
|
+
export function describeSlots(emits, contentModel) {
|
|
409
|
+
const roles = slotSections(emits);
|
|
410
|
+
let emitTag;
|
|
411
|
+
if (contentModel) {
|
|
412
|
+
const m = typeof contentModel === 'function' ? contentModel({}) : contentModel;
|
|
413
|
+
const s = 'when' in m ? m.default : m;
|
|
414
|
+
if ('type' in s && s.type === 'sections')
|
|
415
|
+
emitTag = s.emitTag;
|
|
416
|
+
}
|
|
417
|
+
return Object.entries(emits.slots).map(([name, raw]) => {
|
|
418
|
+
const decl = typeof raw === 'string' ? { as: raw } : raw;
|
|
419
|
+
const from = decl.from ?? name;
|
|
420
|
+
const fromAttr = from.startsWith('attrs.');
|
|
421
|
+
const el = decl.as === 'region' ? (decl.el ?? 'div') : fromAttr ? (decl.el ?? 'span') : undefined;
|
|
422
|
+
return {
|
|
423
|
+
name,
|
|
424
|
+
from,
|
|
425
|
+
as: decl.as,
|
|
426
|
+
...(el ? { el } : {}),
|
|
427
|
+
omitWhenEmpty: decl.omitWhenEmpty ?? false,
|
|
428
|
+
...(roles[name] ? { role: roles[name] } : {}),
|
|
429
|
+
...(from === 'sections' && contentModel
|
|
430
|
+
? { sections: emitTag ? 'child runes' : 'entries' }
|
|
431
|
+
: {}),
|
|
432
|
+
};
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
/** One line per slot, for the text surfaces. */
|
|
436
|
+
export function formatSlotLine(slot) {
|
|
437
|
+
const parts = [slot.as];
|
|
438
|
+
if (slot.el)
|
|
439
|
+
parts.push(`<${slot.el}>`);
|
|
440
|
+
if (slot.omitWhenEmpty)
|
|
441
|
+
parts.push('omitted when empty');
|
|
442
|
+
if (slot.role)
|
|
443
|
+
parts.push(`role: ${slot.role}`);
|
|
444
|
+
if (slot.sections)
|
|
445
|
+
parts.push(`sections arrive as ${slot.sections}`);
|
|
446
|
+
return `${slot.name} <- ${slot.from} (${parts.join(', ')})`;
|
|
447
|
+
}
|
|
448
|
+
//# sourceMappingURL=slots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slots.js","sourceRoot":"","sources":["../../src/lib/slots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAGvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAKxB,sEAAsE;AACtE,MAAM,aAAa,GAAG;IACrB,QAAQ;IACR,UAAU;IACV,OAAO;IACP,aAAa;IACb,MAAM;IACN,QAAQ;IACR,OAAO;CACE,CAAC;AAyDX,MAAM,UAAU,GAAG,I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C,aAAa;QAAE,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACzD,IAAI,IAAI,CAAC,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAChD,IAAI,IAAI,CAAC,QAAQ;QAAE,KAAK,CAAC,IAAI,CAAC,sBAAsB,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrE,OAAO,GAAG,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,IAAI,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AAC9D,CAAC"}
|
package/dist/reference.d.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { Schema } from '@markdoc/markdoc';
|
|
8
8
|
import type { ContentModel } from '@refrakt-md/types';
|
|
9
|
+
import type { RegistersDeclaration } from './lib/registers.js';
|
|
10
|
+
import type { DescribedSlot } from './lib/slots.js';
|
|
9
11
|
/**
|
|
10
12
|
* Information about an attribute preset inherited by a rune — the set of
|
|
11
13
|
* attribute names contributed by the preset, plus metadata for display.
|
|
@@ -209,6 +211,8 @@ export interface SerializedSchemaOrg {
|
|
|
209
211
|
type?: string;
|
|
210
212
|
/** The attribute a multi-row table selects on. */
|
|
211
213
|
by?: string;
|
|
214
|
+
/** The field-bag entry a content-dependent table selects on (BUG-028). */
|
|
215
|
+
byField?: string;
|
|
212
216
|
/** Every schema.org property, with the source name that supplies it. */
|
|
213
217
|
properties: Array<{
|
|
214
218
|
property: string;
|
|
@@ -243,6 +247,9 @@ export interface SerializedRune {
|
|
|
243
247
|
* Documenting it *is* the control, which is why it is here.
|
|
244
248
|
*/
|
|
245
249
|
schemaOrg?: SerializedSchemaOrg;
|
|
250
|
+
/** What the rune registers in the cross-page registry — SPEC-144. The
|
|
251
|
+
* declaration verbatim: it is inert JSON by construction (ADR-036). */
|
|
252
|
+
registers?: RegistersDeclaration;
|
|
246
253
|
attributes: {
|
|
247
254
|
own: Record<string, SerializedAttribute>;
|
|
248
255
|
base?: {
|
|
@@ -276,6 +283,17 @@ export interface SerializedRune {
|
|
|
276
283
|
}>;
|
|
277
284
|
};
|
|
278
285
|
contentModel?: SerializedContentModel;
|
|
286
|
+
/**
|
|
287
|
+
* The rune's output, when it is declared rather than built by a transform —
|
|
288
|
+
* SPEC-143. Defaults made explicit, so a consumer need not know them.
|
|
289
|
+
*/
|
|
290
|
+
emits?: {
|
|
291
|
+
rune: string;
|
|
292
|
+
tag: string;
|
|
293
|
+
property?: string;
|
|
294
|
+
properties: string[];
|
|
295
|
+
slots: DescribedSlot[];
|
|
296
|
+
};
|
|
279
297
|
example?: string;
|
|
280
298
|
}
|
|
281
299
|
/** Serialize a hydrated RuneInfo into the stable JSON shape used by the reference command. */
|
package/dist/reference.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../src/reference.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAqC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../src/reference.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAqC,MAAM,mBAAmB,CAAC;AAUzF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAQpD;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAClC,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,0DAA0D;IA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;SAAE,CAAC,CAAC;KACpF,CAAC;IACF,YAAY,CAAC,EAAE,sBAAsB,CAAC;IACtC;;;OAGG;IACH,KAAK,CAAC,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,KAAK,EAAE,aAAa,EAAE,CAAC;KACvB,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAmBD,8FAA8F;AAE9F,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,cAAc,CAgHjF;AAMD,MAAM,WAAW,cAAc;IAC9B,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;CACvE;AAED,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,cAAc,EAAE,CAqBvE;AASD,MAAM,WAAW,sBAAsB;IACtC,sFAAsF;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,gBAAgB,EACrB,OAAO,GAAE,sBAA2B,GAClC,MAAM,CA0GR"}
|
package/dist/reference.js
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
import { RUNE_EXAMPLES } from './examples.js';
|
|
8
8
|
import { UNIVERSAL_ATTRIBUTE_NAMES, lookupAttributePreset, schemaBasePresets, } from './attribute-presets.js';
|
|
9
9
|
import { AXIS_ATTRIBUTES } from './universal-attributes.js';
|
|
10
|
-
import { schemaContentModels, schemaTables } from './lib/index.js';
|
|
10
|
+
import { schemaContentModels, schemaTables, schemaEmits } from './lib/index.js';
|
|
11
|
+
import { describeRegisters, registersFor } from './lib/registers.js';
|
|
12
|
+
import { describeSlots, formatSlotLine } from './lib/slots.js';
|
|
11
13
|
import { describeSchemaRow, bySchemaProperty } from './schema-row.js';
|
|
12
14
|
import { describeSchemaUniversals } from './schema-universals.js';
|
|
13
15
|
/** Runes that are internal or child-only — excluded from generated reference docs */
|
|
@@ -145,6 +147,23 @@ export function describeRune(rune) {
|
|
|
145
147
|
if (rune.contentModel) {
|
|
146
148
|
lines.push(renderContentModel(rune.contentModel));
|
|
147
149
|
}
|
|
150
|
+
// SPEC-143 — a declaratively-labelled rune states its output slots as data,
|
|
151
|
+
// so the reference can say what a hand-written transform never let it: which
|
|
152
|
+
// field becomes which named node.
|
|
153
|
+
const emits = schemaEmits.get(rune.schema);
|
|
154
|
+
if (emits) {
|
|
155
|
+
const slots = describeSlots(emits, schemaContentModels.get(rune.schema));
|
|
156
|
+
lines.push(`Output slots (<${emits.tag} data-rune="${emits.rune}">, in this order):`);
|
|
157
|
+
for (const slot of slots)
|
|
158
|
+
lines.push(` - ${formatSlotLine(slot)}`);
|
|
159
|
+
}
|
|
160
|
+
// SPEC-144 / WORK-611 — what the rune puts in the cross-page registry.
|
|
161
|
+
const registers = registersFor(rune.schema);
|
|
162
|
+
if (registers) {
|
|
163
|
+
lines.push('Registers (cross-page registry):');
|
|
164
|
+
for (const line of describeRegisters(registers, rune.name))
|
|
165
|
+
lines.push(` ${line}`);
|
|
166
|
+
}
|
|
148
167
|
const example = rune.example ?? RUNE_EXAMPLES[rune.name];
|
|
149
168
|
if (example) {
|
|
150
169
|
lines.push('Example:');
|
|
@@ -539,12 +558,14 @@ export function serializeRune(info, pluginName) {
|
|
|
539
558
|
// rather than by authoring order. The review question is "what does this rune
|
|
540
559
|
// claim about its content", which is answered property-first; the authoring
|
|
541
560
|
// view is source-first, and the two need not agree.
|
|
561
|
+
const emits = schemaEmits.get(info.schema);
|
|
542
562
|
const table = schemaTables.get(info.schema);
|
|
543
563
|
const described = table ? describeSchemaRow(table) : undefined;
|
|
544
564
|
const schemaOrg = described
|
|
545
565
|
? {
|
|
546
566
|
...(described.type ? { type: described.type } : {}),
|
|
547
567
|
...(described.by ? { by: described.by } : {}),
|
|
568
|
+
...(described.byField ? { byField: described.byField } : {}),
|
|
548
569
|
properties: bySchemaProperty(described.properties).map((p) => ({
|
|
549
570
|
property: p.property,
|
|
550
571
|
source: p.source,
|
|
@@ -599,6 +620,18 @@ export function serializeRune(info, pluginName) {
|
|
|
599
620
|
...(info.contentModel ? { contentModel: info.contentModel } : {}),
|
|
600
621
|
...(info.example ? { example: info.example } : {}),
|
|
601
622
|
...(schemaOrg ? { schemaOrg } : {}),
|
|
623
|
+
...(emits
|
|
624
|
+
? {
|
|
625
|
+
emits: {
|
|
626
|
+
rune: emits.rune,
|
|
627
|
+
tag: emits.tag,
|
|
628
|
+
...(emits.property ? { property: emits.property } : {}),
|
|
629
|
+
properties: Object.keys(emits.properties ?? {}),
|
|
630
|
+
slots: describeSlots(emits, schemaContentModels.get(info.schema)),
|
|
631
|
+
},
|
|
632
|
+
}
|
|
633
|
+
: {}),
|
|
634
|
+
...(registersFor(info.schema) ? { registers: registersFor(info.schema) } : {}),
|
|
602
635
|
};
|
|
603
636
|
}
|
|
604
637
|
/** Group hydrated rune infos by source plugin, core first then alphabetical. */
|