@peripheries/renderer 0.3.0 → 0.4.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/README.md CHANGED
@@ -7,7 +7,8 @@ page looks the same in each.
7
7
 
8
8
  | Entry | Holds |
9
9
  |---|---|
10
- | `@peripheries/renderer/core` | Framework-free: cells and thin-ref hydration, references and conditions, the data context, walks and state names, cell props, layout, document structure, bundle refs and resolution, the shared store, and `loadPageData(page, source)` |
10
+ | `@peripheries/renderer/core` | Framework-free: cells and thin-ref hydration, references and conditions, the data context, walks and state names, cell props, layout, document structure, bundle refs and resolution, the shared store, `loadPageData(page, source)`, validation, `DIAGNOSTICS` and `PAGE_RULES` |
11
+ | `@peripheries/renderer/catalog` | `checkCatalog`: what a component repo runs on the knowledge it emits (design/catalog.md §5). The only entry with a JSON Schema validator (ajv) |
11
12
  | `@peripheries/renderer/react` | `PageRenderer`, `CellView`, `StructureView`, the cell states, `useContainerSize` |
12
13
  | `@peripheries/renderer/runtime` | What a page boots with: the import map and boot script, the shims, `installRuntime`, the store bundles import |
13
14
  | `@peripheries/renderer/testing` | The golden pages, synthetic fixtures, and sources that serve them |
@@ -48,6 +49,11 @@ sharing the channel reads it.
48
49
 
49
50
  ## Versions
50
51
 
52
+ - **0.4.1:** a card no longer carries a snippet; a component's first snippet is
53
+ its `example` (budget 1,000), shown beside the card in a pattern's pack. The
54
+ card budget drops to 400.
55
+ - **0.4.0:** `DIAGNOSTICS` and `PAGE_RULES`; `/catalog` with `checkCatalog`; the
56
+ knowledge types in `@peripheries/runtime`.
51
57
  - **0.3.0:** `@peripheries/runtime/rank`, sibling order on `graph_node.rank`
52
58
  (`compareRank`, `sortByRank`, `rankBetween` and the rest), so no one
53
59
  vendors it; the `WALK_NODE_TYPES_EMPTY` warning, because `nodeTypes: []`
@@ -67,25 +73,13 @@ catalog (`{ components: { [name]: { props_schema } } }`) it also checks that
67
73
  components exist and required props are given (`schema.required` only). For a
68
74
  node-managed cell those are warnings, since the page's copy is only a fallback.
69
75
 
70
- | Code | Severity | Meaning |
71
- |---|---|---|
72
- | `CELL_NO_ID`, `CELL_DUPLICATE_ID` | error | a cell without an id, or two with one |
73
- | `CELL_NO_COMPONENT` | error | an inline cell names no component |
74
- | `CELL_UNKNOWN_COMPONENT`, `PROP_REQUIRED` | error (warning on a ref cell) | against the catalog |
75
- | `CELL_UNKNOWN_CHILD`, `CELL_CHILD_CYCLE` | error | `children` names a missing cell, or itself |
76
- | `REF_INVALID` | error | a `ref` without a `graph_node_id` |
77
- | `REF_FALLBACK` | warning | the ref's node has no config the viewer can read; the page's copy renders |
78
- | `LEGACY_THIN_REF`, `LEGACY_INLINE_NODE` | legacy | `{ id, graph_node_id }`; an inline cell with a `graph_node_id` |
79
- | `BINDING_INVALID` | error | a declaration that names no node, or a bad `as` |
80
- | `UNSUPPORTED_REGISTRY_BINDING` | warning | a registry binding, which the host no longer runs |
81
- | `STATE_UNKNOWN_NAME`, `STATE_UNKNOWN_SYSTEM` | error | a state name that isn't one, or a system the process lacks |
82
- | `WALK_EDGE_TYPES_REQUIRED`, `WALK_BAD_DIRECTION` | error | a walk that can't run |
83
- | `WALK_MAX_NODES_CLAMPED`, `WALK_TRUNCATED`, `WALK_NO_START` | warning | a walk capped, cut short, or with nowhere to start |
84
- | `WALK_FAILED` | error | the source failed the walk |
85
- | `BINDING_DUPLICATE_KEY` | error | two reached nodes share a `binding_key`; it binds nothing |
86
- | `STORE_INVALID` | error | a store declaration without its channel or key, or a bad scope |
87
- | `LAYOUT_INVALID` | warning | a responsive bucket that isn't narrow, compact or wide |
88
- | `STRUCTURE_INVALID`, `PAGE_INVALID` | error | a structure naming missing cells or unknown kinds; cells not a list |
76
+ Every code is in **`DIAGNOSTICS`** (from `/core`), with what it means and how
77
+ to fix it; `Diagnostic.code` is typed from that table. Tools show the fix with
78
+ the diagnostic, so a writer learns a rule when they break it.
79
+
80
+ **`PAGE_RULES`** (from `/core`) is the host's rules for composing a page, the
81
+ short text a writer reads first (design/catalog.md §3.3). It is built from the
82
+ constants the renderer and validator use, so it changes when they do.
89
83
 
90
84
  `core` imports no React at runtime and never reaches the network, and the
91
85
  package never imports the host (`npm run lint:deps`). Tests sit next to the
@@ -0,0 +1,232 @@
1
+ import { a as validatePage } from "./chunks/validate--WdSPgWe.js";
2
+ import { KNOWLEDGE_BUDGETS, KNOWLEDGE_KEY } from "@peripheries/runtime";
3
+ import Ajv2020 from "ajv/dist/2020.js";
4
+ //#region packages/renderer/src/catalog/check.ts
5
+ var ref = (kind, key) => `${kind}:${key}`;
6
+ var size = (v) => JSON.stringify(v ?? null).length;
7
+ var isReference = (v) => typeof v === "string" && (v.startsWith("@") || v.includes("${"));
8
+ var holdsReference = (v) => isReference(v) || (Array.isArray(v) ? v.some(holdsReference) : typeof v === "object" && v !== null && Object.values(v).some(holdsReference));
9
+ function card(lineage, row, schema) {
10
+ return {
11
+ lineage,
12
+ kind: row.kind,
13
+ key: row.key,
14
+ title: row.title,
15
+ summary: row.summary,
16
+ tags: row.tags ?? [],
17
+ ...schema?.required ? { required: schema.required } : {}
18
+ };
19
+ }
20
+ var exampleOf = (row) => row?.kind === "component" ? row.snippets?.[0] : void 0;
21
+ function checkCatalog(input) {
22
+ const out = [];
23
+ const at = (row, field) => `${ref(row.kind, row.key)}${field ? `.${field}` : ""}`;
24
+ const ajv = new Ajv2020({
25
+ strict: false,
26
+ allErrors: true
27
+ });
28
+ const schemaOf = (name) => (input.registry[name] ?? input.scopeRegistry?.[name])?.props_schema;
29
+ const byRef = new Map();
30
+ for (const row of input.rows) {
31
+ const id = ref(row.kind, row.key);
32
+ if (byRef.has(id)) out.push({
33
+ severity: "error",
34
+ code: "KNOWLEDGE_DUPLICATE",
35
+ path: at(row),
36
+ message: `${id} appears twice`
37
+ });
38
+ byRef.set(id, row);
39
+ if ((row.kind === "kit" || row.kind === "pattern") && !KNOWLEDGE_KEY.test(row.key)) out.push({
40
+ severity: "error",
41
+ code: "KNOWLEDGE_KEY_INVALID",
42
+ path: at(row),
43
+ message: `"${row.key}" isn't a ${row.kind} key`
44
+ });
45
+ if (!row.summary?.trim() || row.summary.length > KNOWLEDGE_BUDGETS.summary) out.push({
46
+ severity: "error",
47
+ code: "KNOWLEDGE_SUMMARY",
48
+ path: at(row, "summary"),
49
+ message: `the summary is ${row.summary?.length ?? 0} characters; it must be 1–${KNOWLEDGE_BUDGETS.summary}`
50
+ });
51
+ }
52
+ if (!input.rows.some((r) => r.kind === "bundle")) out.push({
53
+ severity: "error",
54
+ code: "KNOWLEDGE_NO_BUNDLE_ROW",
55
+ path: "bundle",
56
+ message: `${input.lineage} has no bundle row`
57
+ });
58
+ for (const [name, entry] of Object.entries(input.registry)) {
59
+ const row = byRef.get(ref("component", name));
60
+ if (row?.page_cell === false) continue;
61
+ if (!row) out.push({
62
+ severity: "error",
63
+ code: "KNOWLEDGE_COMPONENT_UNDOCUMENTED",
64
+ path: `component:${name}`,
65
+ message: `${name} is a page cell with no knowledge row`
66
+ });
67
+ else if (!row.snippets?.length) out.push({
68
+ severity: "error",
69
+ code: "KNOWLEDGE_COMPONENT_UNDOCUMENTED",
70
+ path: at(row, "snippets"),
71
+ message: `${name} has no snippet`
72
+ });
73
+ const schema = entry.props_schema;
74
+ if (schema !== void 0 && schema !== null && !ajv.validateSchema(schema)) out.push({
75
+ severity: "error",
76
+ code: "KNOWLEDGE_SCHEMA_INVALID",
77
+ path: `component:${name}.props_schema`,
78
+ message: ajv.errorsText(ajv.errors, { dataVar: "props_schema" })
79
+ });
80
+ }
81
+ for (const row of input.rows) if (row.kind === "component" && !input.registry[row.key]) out.push({
82
+ severity: "error",
83
+ code: "KNOWLEDGE_COMPONENT_UNKNOWN",
84
+ path: at(row),
85
+ message: `${row.key} isn't in the bundle's registry`
86
+ });
87
+ const kits = new Map();
88
+ for (const link of input.links) {
89
+ const from = ref(link.from.kind, link.from.key);
90
+ const path = `${from}.links.${link.relation}`;
91
+ if (!byRef.has(from)) {
92
+ out.push({
93
+ severity: "error",
94
+ code: "KNOWLEDGE_LINK_DANGLING",
95
+ path,
96
+ message: `the link starts at ${from}, which isn't a row`
97
+ });
98
+ continue;
99
+ }
100
+ const target = ref(link.to.kind, link.to.key);
101
+ const own = !link.to.lineage || link.to.lineage === input.lineage;
102
+ if (own && !byRef.has(target)) out.push({
103
+ severity: "error",
104
+ code: "KNOWLEDGE_LINK_DANGLING",
105
+ path,
106
+ message: `${from} links to ${target}, which isn't a row`
107
+ });
108
+ if (!own && input.inScope?.(link.to.lineage, link.to.kind, link.to.key) === false) out.push({
109
+ severity: "warning",
110
+ code: "KNOWLEDGE_LINK_DANGLING",
111
+ path,
112
+ message: `${from} links to ${link.to.lineage} ${target}, which isn't live in scope`
113
+ });
114
+ if (link.relation === "part_of" && link.to.kind === "kit" && link.from.kind === "component") kits.set(from, [...kits.get(from) ?? [], target]);
115
+ }
116
+ for (const [from, list] of kits) if (list.length > 1) out.push({
117
+ severity: "error",
118
+ code: "KNOWLEDGE_KIT_MULTIPLE",
119
+ path: from,
120
+ message: `${from} is part of ${list.join(", ")}`
121
+ });
122
+ const catalog = { components: {} };
123
+ for (const [name, entry] of Object.entries({
124
+ ...input.scopeRegistry,
125
+ ...input.registry
126
+ })) catalog.components[name] = { props_schema: entry.props_schema };
127
+ for (const row of input.rows) (row.snippets ?? []).forEach((snippet, i) => {
128
+ for (const problem of checkSnippet(snippet, catalog, schemaOf, ajv)) out.push({
129
+ ...problem,
130
+ code: "KNOWLEDGE_SNIPPET_INVALID",
131
+ path: `${at(row, `snippets[${i}]`)}${problem.path ? `.${problem.path}` : ""}`
132
+ });
133
+ });
134
+ const cardOf = (row) => card(input.lineage, row, row.kind === "component" ? schemaOf(row.key) : void 0);
135
+ for (const row of input.rows) {
136
+ const n = size(cardOf(row));
137
+ if (n > KNOWLEDGE_BUDGETS.card) out.push({
138
+ severity: "error",
139
+ code: "KNOWLEDGE_BUDGET",
140
+ path: at(row),
141
+ message: `its card is ${n} characters (budget ${KNOWLEDGE_BUDGETS.card}); shorten the summary or tags`
142
+ });
143
+ const example = exampleOf(row);
144
+ if (example && size(example) > KNOWLEDGE_BUDGETS.example) out.push({
145
+ severity: "error",
146
+ code: "KNOWLEDGE_BUDGET",
147
+ path: at(row, "snippets[0]"),
148
+ message: `its example (first snippet) is ${size(example)} characters (budget ${KNOWLEDGE_BUDGETS.example}); make the smallest example minimal, or bind its data`
149
+ });
150
+ }
151
+ for (const row of input.rows.filter((r) => r.kind === "kit" || r.kind === "pattern")) {
152
+ const self = ref(row.kind, row.key);
153
+ const targets = input.links.filter((l) => ref(l.from.kind, l.from.key) === self && !l.to.lineage).map((l) => byRef.get(ref(l.to.kind, l.to.key)));
154
+ const sources = input.links.filter((l) => !l.to.lineage && ref(l.to.kind, l.to.key) === self).map((l) => byRef.get(ref(l.from.kind, l.from.key)));
155
+ const n = size({
156
+ body: row.body,
157
+ snippets: row.snippets,
158
+ attributes: row.attributes
159
+ }) + targets.reduce((sum, r) => sum + (r ? size(cardOf(r)) + size(exampleOf(r)) : 0), 0) + sources.reduce((sum, r) => sum + (r && (r.kind !== "component" || r.page_cell !== false) ? size(cardOf(r)) : 0), 0);
160
+ if (n > KNOWLEDGE_BUDGETS.pack) out.push({
161
+ severity: "error",
162
+ code: "KNOWLEDGE_BUDGET",
163
+ path: at(row),
164
+ message: `its pack is ${n} characters (budget ${KNOWLEDGE_BUDGETS.pack})`
165
+ });
166
+ }
167
+ const bundle = input.rows.find((r) => r.kind === "bundle");
168
+ const orientation = size({
169
+ bundle: bundle && {
170
+ title: bundle.title,
171
+ summary: bundle.summary,
172
+ body: bundle.body,
173
+ attributes: bundle.attributes
174
+ },
175
+ cards: input.rows.filter((r) => r.kind === "kit" || r.kind === "pattern").map(cardOf),
176
+ names: input.rows.filter((r) => r.kind === "component" && r.page_cell !== false).map((r) => r.key)
177
+ });
178
+ if (orientation > KNOWLEDGE_BUDGETS.orientation) out.push({
179
+ severity: "error",
180
+ code: "KNOWLEDGE_BUDGET",
181
+ path: "bundle",
182
+ message: `the orientation is ${orientation} characters (budget ${KNOWLEDGE_BUDGETS.orientation}); shorten the bundle row or the kit and pattern summaries`
183
+ });
184
+ return out;
185
+ }
186
+ function checkSnippet(snippet, catalog, schemaOf, ajv) {
187
+ if (!Array.isArray(snippet?.cells) || snippet.cells.length === 0) return [{
188
+ severity: "error",
189
+ message: "a snippet needs at least one cell"
190
+ }];
191
+ const layout = snippet.layout ?? (snippet.structure ? {
192
+ type: "document",
193
+ structure: snippet.structure
194
+ } : { type: "stack" });
195
+ const page = {
196
+ content: {
197
+ cells: snippet.cells,
198
+ data: snippet.data ? { static: snippet.data } : void 0
199
+ },
200
+ layout
201
+ };
202
+ const out = validatePage(page, catalog).filter((d) => d.severity !== "legacy").map((d) => ({
203
+ severity: d.severity,
204
+ cellId: d.cellId,
205
+ path: d.path,
206
+ message: `${d.code}: ${d.message}`
207
+ }));
208
+ snippet.cells.forEach((cell, i) => {
209
+ const properties = cell.component ? schemaOf(cell.component)?.properties : void 0;
210
+ for (const [prop, value] of Object.entries(cell.props ?? {})) {
211
+ const schema = properties?.[prop];
212
+ if (!schema || typeof schema !== "object" || holdsReference(value)) continue;
213
+ let valid;
214
+ try {
215
+ valid = ajv.validate(schema, value);
216
+ } catch {
217
+ continue;
218
+ }
219
+ if (!valid) out.push({
220
+ severity: "error",
221
+ cellId: cell.id,
222
+ path: `cells[${i}].props.${prop}`,
223
+ message: `${cell.component}.${prop} ${ajv.errorsText(ajv.errors, { dataVar: "" }).replace(/^\s+/, "")}`
224
+ });
225
+ }
226
+ });
227
+ return out;
228
+ }
229
+ //#endregion
230
+ export { checkCatalog };
231
+
232
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","names":[],"sources":["../src/catalog/check.ts"],"mappings":";;;;AA4BA,IAAM,OAAO,MAAc,QAAgB,GAAG,KAAK,GAAG;AACtD,IAAM,QAAQ,MAAe,KAAK,UAAU,KAAK,IAAI,CAAC,CAAC;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QAAQ;IACN;GACF;GACA,IAAI,CAAC,OACH,IAAI,KAAK;IAAE,UAAU;IAAS,QAAQ,KAAK;IAAI,MAAM,SAAS,EAAE,UAAU;IAAQ,SAAS,GAAG,KAAK,UAAU,GAAG,KAAK,GAAG,IAAI,WAAW,IAAI,QAAQ,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC,QAAQ,QAAQ,EAAE;GAAI,CAAC;EAE/L;CACF,CAAC;CACD,OAAO;AACT"}
@@ -1,4 +1,3 @@
1
- import { SECTION_KINDS } from "@peripheries/runtime";
2
1
  //#region packages/renderer/src/core/cells.ts
3
2
  var HYDRATED_CELL_FIELDS = [
4
3
  "component",
@@ -186,215 +185,6 @@ function passesConditions(conditions, ctx) {
186
185
  return true;
187
186
  }
188
187
  //#endregion
189
- //#region packages/renderer/src/core/structure.ts
190
- var PAGE_DOCUMENT = "__page__";
191
- function normalizeStructure(nodes) {
192
- if (!Array.isArray(nodes)) return [];
193
- return nodes.map((n) => typeof n === "string" ? { cellId: n } : {
194
- ...n,
195
- children: n.children ? normalizeStructure(n.children) : void 0
196
- });
197
- }
198
- var sortByOrder = (nodes) => [...nodes].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
199
- var isSectionNode = (n) => typeof n.sectionId === "string" && n.sectionId.length > 0;
200
- var isSectionKind = (v) => typeof v === "string" && SECTION_KINDS.includes(v);
201
- var sectionAnchor = (n) => n.cellId ?? n.sectionId;
202
- function usesStructureLayout(layout) {
203
- const structure = layout?.structure;
204
- if (!Array.isArray(structure)) return false;
205
- if (layout?.type === "document") return true;
206
- return normalizeStructure(structure).some((n) => isSectionNode(n) || (n.children?.length ?? 0) > 0);
207
- }
208
- var EMPTY = Object.freeze({
209
- numbers: {},
210
- levels: {},
211
- authoredLevels: {},
212
- titles: {},
213
- anchors: {}
214
- });
215
- var numberingFor = (numbering, documentId) => numbering?.byDocument[documentId ?? "__page__"] ?? EMPTY;
216
- function deriveSectionNumbering(structure) {
217
- const byDocument = {};
218
- const unknownKinds = [];
219
- const mapsFor = (d) => byDocument[d] ??= {
220
- numbers: {},
221
- levels: {},
222
- authoredLevels: {},
223
- titles: {},
224
- anchors: {}
225
- };
226
- const nodes = normalizeStructure(structure);
227
- const scan = (list, depth, path, inherited) => sortByOrder(list).forEach((node, i) => {
228
- const here = `${path}[${i}]`;
229
- const documentId = node.documentId ?? inherited;
230
- if (node.kind !== void 0 && !isSectionKind(node.kind)) unknownKinds.push({
231
- path: here,
232
- ...node.sectionId ? { sectionId: node.sectionId } : {},
233
- kind: typeof node.kind === "string" ? node.kind : JSON.stringify(node.kind)
234
- });
235
- const section = isSectionNode(node);
236
- if (section) {
237
- const maps = mapsFor(documentId);
238
- maps.levels[node.sectionId] = depth + 1;
239
- if (node.level !== void 0) maps.authoredLevels[node.sectionId] = node.level;
240
- if (typeof node.title === "string" && node.title !== "") maps.titles[node.sectionId] = node.title;
241
- maps.anchors[node.sectionId] = sectionAnchor(node);
242
- }
243
- scan(node.children ?? [], section ? depth + 1 : depth, `${here}.children`, documentId);
244
- });
245
- const articles = (list, inherited) => sortByOrder(list).flatMap((node) => {
246
- const documentId = node.documentId ?? inherited;
247
- return node.kind === "article" && isSectionNode(node) ? [{
248
- node,
249
- documentId
250
- }] : articles(node.children ?? [], documentId);
251
- });
252
- const number = (list, prefix, inherited) => {
253
- const counters = new Map();
254
- for (const { node, documentId } of articles(list, inherited)) {
255
- const next = (counters.get(documentId) ?? 0) + 1;
256
- counters.set(documentId, next);
257
- const trail = [...prefix, next];
258
- mapsFor(documentId).numbers[node.sectionId] = trail;
259
- number(node.children ?? [], trail, documentId);
260
- }
261
- };
262
- scan(nodes, 0, "structure", PAGE_DOCUMENT);
263
- number(nodes, [], PAGE_DOCUMENT);
264
- return {
265
- byDocument,
266
- unknownKinds
267
- };
268
- }
269
- function uniqueDocumentLabels(documentIds, documents) {
270
- const owners = new Map();
271
- for (const id of documentIds) {
272
- const label = documents?.[id]?.label;
273
- if (typeof label === "string" && label !== "") owners.set(label, [...owners.get(label) ?? [], id]);
274
- }
275
- const out = new Map();
276
- for (const [label, ids] of owners) if (ids.length === 1) out.set(label, ids[0]);
277
- else console.warn(`[structure] label "${label}" is shared by ${ids.join(", ")}; references to "${label}:…" resolve to nothing.`);
278
- return out;
279
- }
280
- function deriveSectionReferences(numbering, documents) {
281
- const recordFor = (maps, role) => {
282
- const anchor = maps.anchors[role];
283
- return {
284
- ...maps.numbers[role] ? { number: maps.numbers[role] } : {},
285
- ...maps.titles[role] ? { title: maps.titles[role] } : {},
286
- anchor,
287
- href: `#${anchor}`,
288
- openable: true
289
- };
290
- };
291
- const cross = {};
292
- for (const [label, id] of uniqueDocumentLabels(Object.keys(numbering.byDocument), documents)) {
293
- const maps = numbering.byDocument[id];
294
- for (const role of Object.keys(maps.anchors)) cross[`${label}:${role}`] = recordFor(maps, role);
295
- }
296
- const out = {};
297
- for (const [id, maps] of Object.entries(numbering.byDocument)) {
298
- const own = {};
299
- for (const role of Object.keys(maps.anchors)) own[role] = recordFor(maps, role);
300
- out[id] = {
301
- ...cross,
302
- ...own
303
- };
304
- }
305
- return out;
306
- }
307
- function clauseItemsOf(blocks) {
308
- if (!Array.isArray(blocks)) return [];
309
- return blocks.flatMap((b) => b && typeof b === "object" && b.kind === "clause" && Array.isArray(b.items) ? b.items.filter((i) => i && typeof i === "object") : []);
310
- }
311
- function deriveElementReferences(structure, blocksByCellId, documents) {
312
- const numbering = deriveSectionNumbering(structure);
313
- const sections = [];
314
- const walk = (nodes, inherited) => {
315
- for (const node of sortByOrder(nodes)) {
316
- const documentId = node.documentId ?? inherited;
317
- if (isSectionNode(node)) {
318
- const body = (node.children ?? []).filter((c) => c.cellId && !c.sectionId).map((c) => c.cellId);
319
- sections.push({
320
- documentId,
321
- role: node.sectionId,
322
- cellIds: [...node.cellId ? [node.cellId] : [], ...body]
323
- });
324
- }
325
- walk(node.children ?? [], documentId);
326
- }
327
- };
328
- walk(normalizeStructure(structure), PAGE_DOCUMENT);
329
- const perDocument = {};
330
- for (const { documentId, role, cellIds } of sections) {
331
- const items = cellIds.flatMap((id) => clauseItemsOf(blocksByCellId[id]));
332
- if (!items.some((i) => typeof i.id === "string" && i.id !== "")) continue;
333
- const shape = items.map((i) => ({
334
- ...typeof i.level === "number" ? { level: i.level } : {},
335
- ...typeof i.marker === "string" ? { marker: i.marker } : {}
336
- }));
337
- const maps = numberingFor(numbering, documentId);
338
- const anchor = maps.anchors[role] ?? role;
339
- items.forEach((item, index) => {
340
- if (typeof item.id !== "string" || item.id === "") return;
341
- (perDocument[documentId] ??= {})[`${role}#${item.id}`] = {
342
- ...maps.numbers[role] ? { number: maps.numbers[role] } : {},
343
- ...maps.titles[role] ? { title: maps.titles[role] } : {},
344
- anchor,
345
- href: `#${anchor}`,
346
- openable: true,
347
- element: {
348
- index,
349
- shape
350
- }
351
- };
352
- });
353
- }
354
- const cross = {};
355
- for (const [label, id] of uniqueDocumentLabels(Object.keys(numbering.byDocument), documents)) for (const [key, record] of Object.entries(perDocument[id] ?? {})) cross[`${label}:${key}`] = record;
356
- const out = {};
357
- for (const id of Object.keys(numbering.byDocument)) {
358
- const own = perDocument[id] ?? {};
359
- if (Object.keys(own).length || Object.keys(cross).length) out[id] = {
360
- ...cross,
361
- ...own
362
- };
363
- }
364
- return out;
365
- }
366
- function mergeSectionReferences(samePage, other) {
367
- if (!other || Object.keys(other).length === 0) return samePage;
368
- const out = {};
369
- for (const id of new Set([...Object.keys(samePage), ...Object.keys(other)])) out[id] = {
370
- ...other[id],
371
- ...samePage[id]
372
- };
373
- return out;
374
- }
375
- var referencesFor = (refs, documentId) => refs?.[documentId ?? "__page__"] ?? {};
376
- function structureIssues(structure, cells) {
377
- const ids = new Set(cells.map((c) => c.id));
378
- const issues = [];
379
- const visit = (nodes, path) => nodes.forEach((n, i) => {
380
- if (n.cellId && !ids.has(n.cellId)) issues.push(`${path}[${i}]: cell '${n.cellId}' is not on the page`);
381
- visit(n.children ?? [], `${path}[${i}].children`);
382
- });
383
- visit(normalizeStructure(structure), "structure");
384
- for (const u of deriveSectionNumbering(structure).unknownKinds) issues.push(`${u.path}: unknown section kind '${u.kind}'${u.sectionId ? ` on '${u.sectionId}'` : ""}; expected ${SECTION_KINDS.join(", ")}`);
385
- return issues;
386
- }
387
- function nodePrintStyle(node) {
388
- const p = node.print;
389
- if (!p) return void 0;
390
- const breakBefore = p.breakBefore ? "page" : p.keepWithPrevious ? "avoid" : void 0;
391
- const breakInside = p.breakInside === "avoid" ? "avoid" : void 0;
392
- return breakBefore || breakInside ? {
393
- ...breakBefore ? { breakBefore } : {},
394
- ...breakInside ? { breakInside } : {}
395
- } : void 0;
396
- }
397
- //#endregion
398
188
  //#region packages/renderer/src/core/cell-props.ts
399
189
  function projectCellData(cell, ctx) {
400
190
  if (!cell.data) return null;
@@ -597,6 +387,6 @@ function collectScopeIds(ctx, selections, viewState) {
597
387
  return [...ids];
598
388
  }
599
389
  //#endregion
600
- export { sortByOrder as A, hasRef as B, isSectionNode as C, numberingFor as D, normalizeStructure as E, resolveReferences as F, resolveCell as H, settled as I, CONTENT_FIELDS as L, usesStructureLayout as M, cellResolutionContext as N, referencesFor as O, passesConditions as P, HYDRATED_CELL_FIELDS as R, deriveSectionReferences as S, nodePrintStyle as T, rootCells as U, normalizeCell as V, projectCellData as _, projectSelections as a, deriveElementReferences as b, pageScopeKey as c, nearestThemeProvider as d, resolveComponent as f, assembleCellProps as g, pageContainerStyle as h, projectLive as i, structureIssues as j, sectionAnchor as k, projectScopeKey as l, cellPlacementStyle as m, attachViewStateSetters as n, projectViewState as o, cellAttributes as p, collectScopeIds as r, shallowEqualBundle as s, attachSelectionSetters as t, resolveScopeId as u, PAGE_DOCUMENT as v, mergeSectionReferences as w, deriveSectionNumbering as x, SECTION_KINDS as y, STORE_FIELDS as z };
390
+ export { HYDRATED_CELL_FIELDS as C, resolveCell as D, normalizeCell as E, rootCells as O, CONTENT_FIELDS as S, hasRef as T, projectCellData as _, projectSelections as a, resolveReferences as b, pageScopeKey as c, nearestThemeProvider as d, resolveComponent as f, assembleCellProps as g, pageContainerStyle as h, projectLive as i, projectScopeKey as l, cellPlacementStyle as m, attachViewStateSetters as n, projectViewState as o, cellAttributes as p, collectScopeIds as r, shallowEqualBundle as s, attachSelectionSetters as t, resolveScopeId as u, cellResolutionContext as v, STORE_FIELDS as w, settled as x, passesConditions as y };
601
391
 
602
- //# sourceMappingURL=projection-Dr4a_p56.js.map
392
+ //# sourceMappingURL=projection-DyCzEj7i.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection-DyCzEj7i.js","names":[],"sources":["../../src/core/cells.ts","../../src/core/references.ts","../../src/core/cell-props.ts","../../src/core/layout.ts","../../src/core/bundles/resolve.ts","../../src/core/store/scope-keys.ts","../../src/core/store/projection.ts"],"mappings":";AAQA,IAAa,uBAAuB;CAAC;CAAa;CAAS;CAAU;CAAc;CAAY;CAAa;CAAQ;CAAc;AAAS;AAG3I,IAAa,eAAe;CAAC;CAAc;CAAa;AAAM;AAG9D,IAAa,iBAAiB,CAAC,GAAG,qBAAqB,QAAQ,MAAM,MAAM,QAAQ,GAAG,GAAG,YAAY;AAcrG,SAAgB,cAAc,MAAgB,OAAO,QAAuD;CAC1G,MAAM,cAA4B,CAAC;CACnC,IAAI,KAAK,KAAK,OAAO;EAAE;EAAM;CAAY;CACzC,IAAI,KAAK,iBAAiB,CAAC,KAAK,WAAW;EACzC,YAAY,KAAK;GAAE,UAAU;GAAU,MAAM;GAAmB,QAAQ,KAAK;GAAI;GAAM,SAAS;EAAqF,CAAC;EACtL,OAAO;GAAE,MAAM;IAAE,GAAG;IAAM,KAAK,EAAE,eAAe,KAAK,cAAc;GAAE;GAAG;EAAY;CACtF;CACA,IAAI,KAAK,eACP,YAAY,KAAK;EAAE,UAAU;EAAU,MAAM;EAAsB,QAAQ,KAAK;EAAI;EAAM,SAAS;CAAyH,CAAC;CAE/N,OAAO;EAAE;EAAM;CAAY;AAC7B;AAGA,IAAa,UAAU,SAA6E,QAAQ,KAAK,KAAK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