@peripheries/renderer 0.2.0 → 0.4.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.
@@ -0,0 +1,213 @@
1
+ import { SECTION_KINDS as SECTION_KINDS$1 } from "@peripheries/runtime";
2
+ //#region packages/renderer/src/core/structure.ts
3
+ var PAGE_DOCUMENT = "__page__";
4
+ function normalizeStructure(nodes) {
5
+ if (!Array.isArray(nodes)) return [];
6
+ return nodes.map((n) => typeof n === "string" ? { cellId: n } : {
7
+ ...n,
8
+ children: n.children ? normalizeStructure(n.children) : void 0
9
+ });
10
+ }
11
+ var sortByOrder = (nodes) => [...nodes].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
12
+ var isSectionNode = (n) => typeof n.sectionId === "string" && n.sectionId.length > 0;
13
+ var isSectionKind = (v) => typeof v === "string" && SECTION_KINDS$1.includes(v);
14
+ var sectionAnchor = (n) => n.cellId ?? n.sectionId;
15
+ function usesStructureLayout(layout) {
16
+ const structure = layout?.structure;
17
+ if (!Array.isArray(structure)) return false;
18
+ if (layout?.type === "document") return true;
19
+ return normalizeStructure(structure).some((n) => isSectionNode(n) || (n.children?.length ?? 0) > 0);
20
+ }
21
+ var EMPTY = Object.freeze({
22
+ numbers: {},
23
+ levels: {},
24
+ authoredLevels: {},
25
+ titles: {},
26
+ anchors: {}
27
+ });
28
+ var numberingFor = (numbering, documentId) => numbering?.byDocument[documentId ?? "__page__"] ?? EMPTY;
29
+ function deriveSectionNumbering(structure) {
30
+ const byDocument = {};
31
+ const unknownKinds = [];
32
+ const mapsFor = (d) => byDocument[d] ??= {
33
+ numbers: {},
34
+ levels: {},
35
+ authoredLevels: {},
36
+ titles: {},
37
+ anchors: {}
38
+ };
39
+ const nodes = normalizeStructure(structure);
40
+ const scan = (list, depth, path, inherited) => sortByOrder(list).forEach((node, i) => {
41
+ const here = `${path}[${i}]`;
42
+ const documentId = node.documentId ?? inherited;
43
+ if (node.kind !== void 0 && !isSectionKind(node.kind)) unknownKinds.push({
44
+ path: here,
45
+ ...node.sectionId ? { sectionId: node.sectionId } : {},
46
+ kind: typeof node.kind === "string" ? node.kind : JSON.stringify(node.kind)
47
+ });
48
+ const section = isSectionNode(node);
49
+ if (section) {
50
+ const maps = mapsFor(documentId);
51
+ maps.levels[node.sectionId] = depth + 1;
52
+ if (node.level !== void 0) maps.authoredLevels[node.sectionId] = node.level;
53
+ if (typeof node.title === "string" && node.title !== "") maps.titles[node.sectionId] = node.title;
54
+ maps.anchors[node.sectionId] = sectionAnchor(node);
55
+ }
56
+ scan(node.children ?? [], section ? depth + 1 : depth, `${here}.children`, documentId);
57
+ });
58
+ const articles = (list, inherited) => sortByOrder(list).flatMap((node) => {
59
+ const documentId = node.documentId ?? inherited;
60
+ return node.kind === "article" && isSectionNode(node) ? [{
61
+ node,
62
+ documentId
63
+ }] : articles(node.children ?? [], documentId);
64
+ });
65
+ const number = (list, prefix, inherited) => {
66
+ const counters = new Map();
67
+ for (const { node, documentId } of articles(list, inherited)) {
68
+ const next = (counters.get(documentId) ?? 0) + 1;
69
+ counters.set(documentId, next);
70
+ const trail = [...prefix, next];
71
+ mapsFor(documentId).numbers[node.sectionId] = trail;
72
+ number(node.children ?? [], trail, documentId);
73
+ }
74
+ };
75
+ scan(nodes, 0, "structure", PAGE_DOCUMENT);
76
+ number(nodes, [], PAGE_DOCUMENT);
77
+ return {
78
+ byDocument,
79
+ unknownKinds
80
+ };
81
+ }
82
+ function uniqueDocumentLabels(documentIds, documents) {
83
+ const owners = new Map();
84
+ for (const id of documentIds) {
85
+ const label = documents?.[id]?.label;
86
+ if (typeof label === "string" && label !== "") owners.set(label, [...owners.get(label) ?? [], id]);
87
+ }
88
+ const out = new Map();
89
+ for (const [label, ids] of owners) if (ids.length === 1) out.set(label, ids[0]);
90
+ else console.warn(`[structure] label "${label}" is shared by ${ids.join(", ")}; references to "${label}:…" resolve to nothing.`);
91
+ return out;
92
+ }
93
+ function deriveSectionReferences(numbering, documents) {
94
+ const recordFor = (maps, role) => {
95
+ const anchor = maps.anchors[role];
96
+ return {
97
+ ...maps.numbers[role] ? { number: maps.numbers[role] } : {},
98
+ ...maps.titles[role] ? { title: maps.titles[role] } : {},
99
+ anchor,
100
+ href: `#${anchor}`,
101
+ openable: true
102
+ };
103
+ };
104
+ const cross = {};
105
+ for (const [label, id] of uniqueDocumentLabels(Object.keys(numbering.byDocument), documents)) {
106
+ const maps = numbering.byDocument[id];
107
+ for (const role of Object.keys(maps.anchors)) cross[`${label}:${role}`] = recordFor(maps, role);
108
+ }
109
+ const out = {};
110
+ for (const [id, maps] of Object.entries(numbering.byDocument)) {
111
+ const own = {};
112
+ for (const role of Object.keys(maps.anchors)) own[role] = recordFor(maps, role);
113
+ out[id] = {
114
+ ...cross,
115
+ ...own
116
+ };
117
+ }
118
+ return out;
119
+ }
120
+ function clauseItemsOf(blocks) {
121
+ if (!Array.isArray(blocks)) return [];
122
+ return blocks.flatMap((b) => b && typeof b === "object" && b.kind === "clause" && Array.isArray(b.items) ? b.items.filter((i) => i && typeof i === "object") : []);
123
+ }
124
+ function deriveElementReferences(structure, blocksByCellId, documents) {
125
+ const numbering = deriveSectionNumbering(structure);
126
+ const sections = [];
127
+ const walk = (nodes, inherited) => {
128
+ for (const node of sortByOrder(nodes)) {
129
+ const documentId = node.documentId ?? inherited;
130
+ if (isSectionNode(node)) {
131
+ const body = (node.children ?? []).filter((c) => c.cellId && !c.sectionId).map((c) => c.cellId);
132
+ sections.push({
133
+ documentId,
134
+ role: node.sectionId,
135
+ cellIds: [...node.cellId ? [node.cellId] : [], ...body]
136
+ });
137
+ }
138
+ walk(node.children ?? [], documentId);
139
+ }
140
+ };
141
+ walk(normalizeStructure(structure), PAGE_DOCUMENT);
142
+ const perDocument = {};
143
+ for (const { documentId, role, cellIds } of sections) {
144
+ const items = cellIds.flatMap((id) => clauseItemsOf(blocksByCellId[id]));
145
+ if (!items.some((i) => typeof i.id === "string" && i.id !== "")) continue;
146
+ const shape = items.map((i) => ({
147
+ ...typeof i.level === "number" ? { level: i.level } : {},
148
+ ...typeof i.marker === "string" ? { marker: i.marker } : {}
149
+ }));
150
+ const maps = numberingFor(numbering, documentId);
151
+ const anchor = maps.anchors[role] ?? role;
152
+ items.forEach((item, index) => {
153
+ if (typeof item.id !== "string" || item.id === "") return;
154
+ (perDocument[documentId] ??= {})[`${role}#${item.id}`] = {
155
+ ...maps.numbers[role] ? { number: maps.numbers[role] } : {},
156
+ ...maps.titles[role] ? { title: maps.titles[role] } : {},
157
+ anchor,
158
+ href: `#${anchor}`,
159
+ openable: true,
160
+ element: {
161
+ index,
162
+ shape
163
+ }
164
+ };
165
+ });
166
+ }
167
+ const cross = {};
168
+ for (const [label, id] of uniqueDocumentLabels(Object.keys(numbering.byDocument), documents)) for (const [key, record] of Object.entries(perDocument[id] ?? {})) cross[`${label}:${key}`] = record;
169
+ const out = {};
170
+ for (const id of Object.keys(numbering.byDocument)) {
171
+ const own = perDocument[id] ?? {};
172
+ if (Object.keys(own).length || Object.keys(cross).length) out[id] = {
173
+ ...cross,
174
+ ...own
175
+ };
176
+ }
177
+ return out;
178
+ }
179
+ function mergeSectionReferences(samePage, other) {
180
+ if (!other || Object.keys(other).length === 0) return samePage;
181
+ const out = {};
182
+ for (const id of new Set([...Object.keys(samePage), ...Object.keys(other)])) out[id] = {
183
+ ...other[id],
184
+ ...samePage[id]
185
+ };
186
+ return out;
187
+ }
188
+ var referencesFor = (refs, documentId) => refs?.[documentId ?? "__page__"] ?? {};
189
+ function structureIssues(structure, cells) {
190
+ const ids = new Set(cells.map((c) => c.id));
191
+ const issues = [];
192
+ const visit = (nodes, path) => nodes.forEach((n, i) => {
193
+ if (n.cellId && !ids.has(n.cellId)) issues.push(`${path}[${i}]: cell '${n.cellId}' is not on the page`);
194
+ visit(n.children ?? [], `${path}[${i}].children`);
195
+ });
196
+ visit(normalizeStructure(structure), "structure");
197
+ for (const u of deriveSectionNumbering(structure).unknownKinds) issues.push(`${u.path}: unknown section kind '${u.kind}'${u.sectionId ? ` on '${u.sectionId}'` : ""}; expected ${SECTION_KINDS$1.join(", ")}`);
198
+ return issues;
199
+ }
200
+ function nodePrintStyle(node) {
201
+ const p = node.print;
202
+ if (!p) return void 0;
203
+ const breakBefore = p.breakBefore ? "page" : p.keepWithPrevious ? "avoid" : void 0;
204
+ const breakInside = p.breakInside === "avoid" ? "avoid" : void 0;
205
+ return breakBefore || breakInside ? {
206
+ ...breakBefore ? { breakBefore } : {},
207
+ ...breakInside ? { breakInside } : {}
208
+ } : void 0;
209
+ }
210
+ //#endregion
211
+ export { deriveSectionReferences as a, nodePrintStyle as c, referencesFor as d, sectionAnchor as f, usesStructureLayout as h, deriveSectionNumbering as i, normalizeStructure as l, structureIssues as m, SECTION_KINDS$1 as n, isSectionNode as o, sortByOrder as p, deriveElementReferences as r, mergeSectionReferences as s, PAGE_DOCUMENT as t, numberingFor as u };
212
+
213
+ //# sourceMappingURL=structure-OUTX0zxG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structure-OUTX0zxG.js","names":["SECTION_KINDS"],"sources":["../../src/core/structure.ts"],"mappings":";;AAeA,IAAa,gBAAgB;AAG7B,SAAgB,mBAAmB,OAAoF;CACrH,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC;CACnC,OAAO,MAAM,KAAK,MAAO,OAAO,MAAM,WAAW,EAAE,QAAQ,EAAE,IAAI;EAAE,GAAG;EAAG,UAAU,EAAE,WAAW,mBAAmB,EAAE,QAAQ,IAAI,KAAA;CAAU,CAAE;AAC/I;AAGA,IAAa,eAA6C,UAA6B,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,GAAG,OAAO,EAAE,SAAS,MAAM,EAAE,SAAS,EAAE;AAEhJ,IAAa,iBAAiB,MAA0B,OAAO,EAAE,cAAc,YAAY,EAAE,UAAU,SAAS;AAChH,IAAa,iBAAiB,MAAiC,OAAO,MAAM,YAAaA,gBAAoC,SAAS,CAAC;AAGvI,IAAa,i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AAa,iBAAiB,MAAqC,eACjE,OAAO,cAAA,eAAgC,CAAC;AAG1C,SAAgB,gBAAgB,WAAkE,OAA6B;CAC7H,MAAM,MAAM,IAAI,IAAI,MAAM,KAAK,MAAM,EAAE,EAAE,CAAC;CAC1C,MAAM,SAAmB,CAAC;CAC1B,MAAM,SAAS,OAA6B,SAC1C,MAAM,SAAS,GAAG,MAAM;EACtB,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,EAAE,MAAM,GAAG,OAAO,KAAK,GAAG,KAAK,GAAG,EAAE,WAAW,EAAE,OAAO,qBAAqB;EACtG,MAAM,EAAE,YAAY,CAAC,GAAG,GAAG,KAAK,GAAG,EAAE,WAAW;CAClD,CAAC;CACH,MAAM,mBAAmB,SAAS,GAAG,WAAW;CAChD,KAAK,MAAM,KAAK,uBAAuB,SAAS,CAAC,CAAC,cAChD,OAAO,KAAK,GAAG,EAAE,KAAK,0BAA0B,EAAE,KAAK,GAAG,EAAE,YAAY,QAAQ,EAAE,UAAU,KAAK,GAAG,aAAaA,gBAAc,KAAK,IAAI,GAAG;CAE7I,OAAO;AACT;AAQA,SAAgB,eAAe,MAAwG;CACrI,MAAM,IAAI,KAAK;CACf,IAAI,CAAC,GAAG,OAAO,KAAA;CACf,MAAM,cAAc,EAAE,cAAc,SAAS,EAAE,mBAAmB,UAAU,KAAA;CAC5E,MAAM,cAAc,EAAE,gBAAgB,UAAU,UAAU,KAAA;CAC1D,OAAO,eAAe,cAAc;EAAE,GAAI,cAAc,EAAE,YAAY,IAAI,CAAC;EAAI,GAAI,cAAc,EAAE,YAAY,IAAI,CAAC;CAAG,IAAI,KAAA;AAC7H"}
@@ -0,0 +1,275 @@
1
+ import { h as usesStructureLayout, m as structureIssues } from "./structure-OUTX0zxG.js";
2
+ import { STATE_NAMES, isStateName } from "@peripheries/runtime";
3
+ //#region packages/renderer/src/core/validate.ts
4
+ var RESPONSIVE_BUCKETS = [
5
+ "narrow",
6
+ "compact",
7
+ "wide"
8
+ ];
9
+ var STORE_SCOPES = ["page", "project"];
10
+ var WALK_DIRECTIONS = [
11
+ "incoming",
12
+ "outgoing",
13
+ "both"
14
+ ];
15
+ var BUCKETS = RESPONSIVE_BUCKETS;
16
+ var SCOPES = STORE_SCOPES;
17
+ var DIRECTIONS = WALK_DIRECTIONS;
18
+ function checkBindings(queries, path, push, cellId, template = false) {
19
+ if (queries === void 0) return;
20
+ if (!queries || typeof queries !== "object" || Array.isArray(queries)) {
21
+ push({
22
+ severity: "error",
23
+ code: "BINDING_INVALID",
24
+ cellId,
25
+ path,
26
+ message: "data.queries must be an object of label → binding"
27
+ });
28
+ return;
29
+ }
30
+ for (const [label, raw] of Object.entries(queries)) {
31
+ const at = `${path}.${label}`;
32
+ const b = raw;
33
+ if (!b || typeof b !== "object") {
34
+ push({
35
+ severity: "error",
36
+ code: "BINDING_INVALID",
37
+ cellId,
38
+ label,
39
+ path: at,
40
+ message: `"${label}" isn't a binding`
41
+ });
42
+ continue;
43
+ }
44
+ if (typeof b.registry === "string") {
45
+ push({
46
+ severity: "warning",
47
+ code: "UNSUPPORTED_REGISTRY_BINDING",
48
+ cellId,
49
+ label,
50
+ path: at,
51
+ message: `"${label}" names the registry query ${b.registry}, which the host no longer runs (R2 maps or retires it)`
52
+ });
53
+ continue;
54
+ }
55
+ if (typeof b.graph_node_id !== "string" || !b.graph_node_id) {
56
+ if (!template) push({
57
+ severity: "error",
58
+ code: "BINDING_INVALID",
59
+ cellId,
60
+ label,
61
+ path: at,
62
+ message: `"${label}" names no graph_node_id`
63
+ });
64
+ continue;
65
+ }
66
+ if (b.as !== void 0 && b.as !== "value" && b.as !== "record") push({
67
+ severity: "error",
68
+ code: "BINDING_INVALID",
69
+ cellId,
70
+ label,
71
+ path: `${at}.as`,
72
+ message: `"${label}".as is "${String(b.as)}"; expected value or record`
73
+ });
74
+ for (const s of b.state === void 0 ? [] : Array.isArray(b.state) ? b.state : [b.state]) if (!isStateName(s)) push({
75
+ severity: "error",
76
+ code: "STATE_UNKNOWN_NAME",
77
+ cellId,
78
+ label,
79
+ path: `${at}.state`,
80
+ message: `"${label}" names state "${String(s)}"; expected one of ${STATE_NAMES.join(", ")}`
81
+ });
82
+ }
83
+ }
84
+ function checkTraversal(t, path, push, cellId) {
85
+ if (t === void 0) return;
86
+ const w = t;
87
+ if (!Array.isArray(w.edgeTypes) || w.edgeTypes.length === 0) push({
88
+ severity: "error",
89
+ code: "WALK_EDGE_TYPES_REQUIRED",
90
+ cellId,
91
+ path: `${path}.edgeTypes`,
92
+ message: "traversal.edgeTypes is required: without it a walk follows every edge type"
93
+ });
94
+ if (w.direction !== void 0 && !DIRECTIONS.includes(String(w.direction))) push({
95
+ severity: "error",
96
+ code: "WALK_BAD_DIRECTION",
97
+ cellId,
98
+ path: `${path}.direction`,
99
+ message: `traversal.direction "${String(w.direction)}" isn't incoming, outgoing or both`
100
+ });
101
+ if (Array.isArray(w.nodeTypes) && w.nodeTypes.length === 0) push({
102
+ severity: "warning",
103
+ code: "WALK_NODE_TYPES_EMPTY",
104
+ cellId,
105
+ path: `${path}.nodeTypes`,
106
+ message: "traversal.nodeTypes is empty, which filters nothing: leave it out, or name the types the walk may enter"
107
+ });
108
+ if (typeof w.maxNodes === "number" && w.maxNodes > 500) push({
109
+ severity: "warning",
110
+ code: "WALK_MAX_NODES_CLAMPED",
111
+ cellId,
112
+ path: `${path}.maxNodes`,
113
+ message: `traversal.maxNodes ${w.maxNodes} is above 500; clamped`
114
+ });
115
+ for (const s of Array.isArray(w.include_state) ? w.include_state : []) if (!isStateName(s)) push({
116
+ severity: "error",
117
+ code: "STATE_UNKNOWN_NAME",
118
+ cellId,
119
+ path: `${path}.include_state`,
120
+ message: `include_state "${String(s)}" isn't a system name`
121
+ });
122
+ }
123
+ function checkStore(cell, path, push) {
124
+ for (const [kind, key] of [
125
+ ["selections", "channel"],
126
+ ["viewState", "key"],
127
+ ["live", "channel"]
128
+ ]) for (const [name, decl] of Object.entries(cell[kind] ?? {})) {
129
+ const at = `${path}.${kind}.${name}`;
130
+ if (typeof decl?.[key] !== "string" || !decl[key]) push({
131
+ severity: "error",
132
+ code: "STORE_INVALID",
133
+ cellId: cell.id,
134
+ path: at,
135
+ message: `${kind}.${name} names no ${key}`
136
+ });
137
+ if (kind !== "live" && !SCOPES.includes(String(decl?.scope))) push({
138
+ severity: "error",
139
+ code: "STORE_INVALID",
140
+ cellId: cell.id,
141
+ path: `${at}.scope`,
142
+ message: `${kind}.${name}.scope must be page or project`
143
+ });
144
+ }
145
+ }
146
+ function validateCell(cell, catalog, path = "cell", ids, options = {}) {
147
+ const out = [];
148
+ const push = (d) => out.push(d);
149
+ if (typeof cell?.id !== "string" || !cell.id) {
150
+ push({
151
+ severity: "error",
152
+ code: "CELL_NO_ID",
153
+ path,
154
+ message: "a cell needs an id"
155
+ });
156
+ return out;
157
+ }
158
+ const cellId = cell.id;
159
+ const ref = cell.ref;
160
+ if (ref !== void 0 && (typeof ref?.graph_node_id !== "string" || !ref.graph_node_id)) push({
161
+ severity: "error",
162
+ code: "REF_INVALID",
163
+ cellId,
164
+ path: `${path}.ref`,
165
+ message: "ref names no graph_node_id"
166
+ });
167
+ const nodeManaged = Boolean(ref?.graph_node_id) || Boolean(cell.graph_node_id) && !cell.component;
168
+ if (!ref && cell.graph_node_id && !cell.component) push({
169
+ severity: "legacy",
170
+ code: "LEGACY_THIN_REF",
171
+ cellId,
172
+ path,
173
+ message: "a thin ref `{ id, graph_node_id }`: publish it as `{ id, ref: { graph_node_id } }`"
174
+ });
175
+ else if (!ref && cell.graph_node_id) push({
176
+ severity: "legacy",
177
+ code: "LEGACY_INLINE_NODE",
178
+ cellId,
179
+ path,
180
+ message: "an inline cell with a graph_node_id: its node only starts its walk. Give it a `ref` if the node should manage the cell"
181
+ });
182
+ if (!nodeManaged && !cell.component) push({
183
+ severity: "error",
184
+ code: "CELL_NO_COMPONENT",
185
+ cellId,
186
+ path,
187
+ message: "an inline cell needs a component"
188
+ });
189
+ if (cell.component && catalog && !cell.component.startsWith("@core/")) {
190
+ const entry = catalog.components[cell.component];
191
+ if (!entry) push({
192
+ severity: nodeManaged ? "warning" : "error",
193
+ code: "CELL_UNKNOWN_COMPONENT",
194
+ cellId,
195
+ path: `${path}.component`,
196
+ message: `no bundle in scope exports ${cell.component}`
197
+ });
198
+ else for (const prop of entry.props_schema?.required ?? []) if ((prop === "children" ? cell.props?.children ?? (cell.children?.length ? cell.children : void 0) : cell.props?.[prop]) === void 0) push({
199
+ severity: nodeManaged ? "warning" : "error",
200
+ code: "PROP_REQUIRED",
201
+ cellId,
202
+ path: `${path}.props.${prop}`,
203
+ message: `${cell.component} requires ${prop}`
204
+ });
205
+ }
206
+ for (const child of cell.children ?? []) if (child === cellId) push({
207
+ severity: "error",
208
+ code: "CELL_CHILD_CYCLE",
209
+ cellId,
210
+ path: `${path}.children`,
211
+ message: "a cell lists itself as a child"
212
+ });
213
+ else if (ids && !ids.has(child)) push({
214
+ severity: "error",
215
+ code: "CELL_UNKNOWN_CHILD",
216
+ cellId,
217
+ path: `${path}.children`,
218
+ message: `child cell "${child}" is not on the page`
219
+ });
220
+ checkBindings(cell.data?.queries, `${path}.data.queries`, push, cellId, options.template);
221
+ checkTraversal(cell.traversal, `${path}.traversal`, push, cellId);
222
+ checkStore(cell, path, push);
223
+ for (const key of [
224
+ "hideWhen",
225
+ "showWhen",
226
+ "stackWhen",
227
+ "truncateWhen"
228
+ ]) {
229
+ const v = cell.layout?.[key];
230
+ if (v !== void 0 && !BUCKETS.includes(v)) push({
231
+ severity: "warning",
232
+ code: "LAYOUT_INVALID",
233
+ cellId,
234
+ path: `${path}.layout.${key}`,
235
+ message: `layout.${key} "${v}" isn't narrow, compact or wide`
236
+ });
237
+ }
238
+ return out;
239
+ }
240
+ function validatePage(page, catalog) {
241
+ const options = { template: Boolean(page.is_template) };
242
+ const out = [];
243
+ const cells = page.content?.cells;
244
+ if (cells !== void 0 && !Array.isArray(cells)) return [{
245
+ severity: "error",
246
+ code: "PAGE_INVALID",
247
+ path: "content.cells",
248
+ message: "content.cells must be a list"
249
+ }];
250
+ const list = cells ?? [];
251
+ const ids = new Set();
252
+ list.forEach((cell, i) => {
253
+ if (typeof cell?.id === "string" && ids.has(cell.id)) out.push({
254
+ severity: "error",
255
+ code: "CELL_DUPLICATE_ID",
256
+ cellId: cell.id,
257
+ path: `content.cells[${i}].id`,
258
+ message: `two cells share the id "${cell.id}"`
259
+ });
260
+ if (typeof cell?.id === "string") ids.add(cell.id);
261
+ });
262
+ list.forEach((cell, i) => out.push(...validateCell(cell, catalog, `content.cells[${i}]`, ids, options)));
263
+ checkBindings(page.content?.data?.queries, "content.data.queries", (d) => out.push(d), void 0, options.template);
264
+ if (usesStructureLayout(page.layout)) for (const issue of structureIssues(page.layout?.structure, list)) out.push({
265
+ severity: "error",
266
+ code: "STRUCTURE_INVALID",
267
+ path: "layout.structure",
268
+ message: issue
269
+ });
270
+ return out;
271
+ }
272
+ //#endregion
273
+ export { validatePage as a, validateCell as i, STORE_SCOPES as n, WALK_DIRECTIONS as r, RESPONSIVE_BUCKETS as t };
274
+
275
+ //# sourceMappingURL=validate--WdSPgWe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate--WdSPgWe.js","names":[],"sources":["../../src/core/validate.ts"],"mappings":";;;AAgBA,IAAa,qBAAqB;CAAC;CAAU;CAAW;AAAM;AAC9D,IAAa,eAAe,CAAC,QAAQ,SAAS;AAC9C,IAAa,kBAAkB;CAAC;CAAY;CAAY;AAAM;AAC9D,IAAM,UAA6B;AACnC,IAAM,SAA4B;AAClC,IAAM,aAAgC;AAOtC,SAAS,cAAc,SAAkB,MAAc,MAAY,QAAiB,WAAW,OAAO;CACpG,IAAI,YAAY,KAAA,GAAW;CAC3B,IAAI,CAAC,WAAW,OAAO,YAAY,YAAY,MAAM,QAAQ,OAAO,GAAG;EACrE,KAAK;GAAE,UAAU;GAAS,MAAM;GAAmB;GAAQ;GAAM,SAAS;EAAoD,CAAC;EAC/H;CACF;CACA,KAAK,MAA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