@peripheries/renderer 0.22.0 → 0.23.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.
Files changed (103) hide show
  1. package/README.md +125 -23
  2. package/dist/catalog.js +2 -6
  3. package/dist/chunks/forms-DxA9WzCt.js +336 -0
  4. package/dist/chunks/{load-CjPvISzH.js → load-b38vUiZM.js} +0 -4
  5. package/dist/chunks/{page-bundles-DLRIBP8g.js → page-bundles-CPj_vx-J.js} +1 -5
  6. package/dist/chunks/{persistence-DCMakM9H.js → persistence-hurkUUQ0.js} +0 -6
  7. package/dist/chunks/{projection-yvYKzMOS.js → projection-zhu32_KJ.js} +1 -15
  8. package/dist/chunks/{query-BPuCJC1C.js → query-D6xQbTFK.js} +166 -12
  9. package/dist/chunks/{refs-BLUokra5.js → refs-Csgh6rXq.js} +0 -4
  10. package/dist/chunks/{structure-o9pYoDjD.js → structure-CKBtQHJq.js} +1 -7
  11. package/dist/chunks/{validate-4LgH8QMJ.js → validate-BcB_PA1k.js} +20 -13
  12. package/dist/core.js +138 -47
  13. package/dist/forms.js +2 -0
  14. package/dist/print.js +0 -24
  15. package/dist/react.js +352 -22
  16. package/dist/runtime.js +2 -12
  17. package/dist/styles.css +9 -15
  18. package/dist/testing.js +214 -19
  19. package/dist/theme.js +0 -10
  20. package/dist/types/catalog/check.d.ts +0 -13
  21. package/dist/types/core/actions.d.ts +0 -24
  22. package/dist/types/core/bundles/load.d.ts +0 -23
  23. package/dist/types/core/bundles/page-bundles.d.ts +0 -9
  24. package/dist/types/core/bundles/refs.d.ts +1 -28
  25. package/dist/types/core/bundles/resolve.d.ts +0 -10
  26. package/dist/types/core/cell-props.d.ts +0 -20
  27. package/dist/types/core/cells.d.ts +0 -21
  28. package/dist/types/core/data-context.d.ts +4 -21
  29. package/dist/types/core/diagnostics.d.ts +20 -6
  30. package/dist/types/core/graph.d.ts +6 -44
  31. package/dist/types/core/index.d.ts +4 -3
  32. package/dist/types/core/layout.d.ts +0 -9
  33. package/dist/types/core/load-page.d.ts +30 -88
  34. package/dist/types/core/query.d.ts +6 -52
  35. package/dist/types/core/references.d.ts +0 -21
  36. package/dist/types/core/release.d.ts +11 -0
  37. package/dist/types/core/rules.d.ts +0 -1
  38. package/dist/types/core/selected.d.ts +0 -5
  39. package/dist/types/core/sources.d.ts +10 -63
  40. package/dist/types/core/store/create-store.d.ts +0 -6
  41. package/dist/types/core/store/persistence.d.ts +0 -1
  42. package/dist/types/core/store/projection.d.ts +0 -5
  43. package/dist/types/core/store/scope-keys.d.ts +0 -1
  44. package/dist/types/core/store/types.d.ts +0 -6
  45. package/dist/types/core/structure.d.ts +0 -33
  46. package/dist/types/core/types.d.ts +2 -13
  47. package/dist/types/core/validate.d.ts +0 -12
  48. package/dist/types/core/values.d.ts +0 -6
  49. package/dist/types/forms/conditions.d.ts +18 -0
  50. package/dist/types/forms/index.d.ts +3 -0
  51. package/dist/types/forms/model.d.ts +90 -0
  52. package/dist/types/forms/port.d.ts +47 -0
  53. package/dist/types/print/document-bindings.d.ts +0 -61
  54. package/dist/types/print/document-profile.d.ts +0 -137
  55. package/dist/types/print/map-staleness.d.ts +0 -66
  56. package/dist/types/print/page-map.d.ts +1 -334
  57. package/dist/types/print/paginate.d.ts +0 -190
  58. package/dist/types/print/print-layout.d.ts +0 -161
  59. package/dist/types/print/print-lint.d.ts +0 -109
  60. package/dist/types/print/print-policy.d.ts +0 -184
  61. package/dist/types/print/print-stylesheet.d.ts +0 -135
  62. package/dist/types/print/running-header.d.ts +0 -86
  63. package/dist/types/print/structure-print.d.ts +1 -243
  64. package/dist/types/react/cell-states.d.ts +0 -2
  65. package/dist/types/react/cell-view.d.ts +1 -15
  66. package/dist/types/react/index.d.ts +1 -0
  67. package/dist/types/react/page-renderer.d.ts +1 -33
  68. package/dist/types/react/structure-view.d.ts +0 -12
  69. package/dist/types/react/use-cell-store.d.ts +0 -5
  70. package/dist/types/react/use-container-size.d.ts +0 -5
  71. package/dist/types/react/use-forms-runtime.d.ts +147 -0
  72. package/dist/types/react/use-paging.d.ts +0 -9
  73. package/dist/types/runtime/boot.d.ts +0 -11
  74. package/dist/types/runtime/install.d.ts +0 -15
  75. package/dist/types/runtime/shims.d.ts +0 -8
  76. package/dist/types/runtime/store-export.d.ts +0 -7
  77. package/dist/types/testing/base-props.d.ts +0 -1
  78. package/dist/types/testing/components.d.ts +0 -8
  79. package/dist/types/testing/form-workbook.d.ts +103 -0
  80. package/dist/types/testing/golden.d.ts +0 -16
  81. package/dist/types/testing/ids.d.ts +0 -2
  82. package/dist/types/testing/index.d.ts +1 -0
  83. package/dist/types/testing/sources.d.ts +0 -7
  84. package/dist/types/theme/check.d.ts +0 -2
  85. package/dist/types/theme/color.d.ts +0 -12
  86. package/dist/types/theme/derive.d.ts +0 -12
  87. package/dist/types/theme/parse.d.ts +0 -7
  88. package/package.json +6 -2
  89. package/dist/catalog.js.map +0 -1
  90. package/dist/chunks/load-CjPvISzH.js.map +0 -1
  91. package/dist/chunks/page-bundles-DLRIBP8g.js.map +0 -1
  92. package/dist/chunks/persistence-DCMakM9H.js.map +0 -1
  93. package/dist/chunks/projection-yvYKzMOS.js.map +0 -1
  94. package/dist/chunks/query-BPuCJC1C.js.map +0 -1
  95. package/dist/chunks/refs-BLUokra5.js.map +0 -1
  96. package/dist/chunks/structure-o9pYoDjD.js.map +0 -1
  97. package/dist/chunks/validate-4LgH8QMJ.js.map +0 -1
  98. package/dist/core.js.map +0 -1
  99. package/dist/print.js.map +0 -1
  100. package/dist/react.js.map +0 -1
  101. package/dist/runtime.js.map +0 -1
  102. package/dist/testing.js.map +0 -1
  103. package/dist/theme.js.map +0 -1
package/dist/core.js CHANGED
@@ -1,13 +1,12 @@
1
- import { C as normalizeCell, S as hasRef, T as rootCells, a as projectSelections, b as HYDRATED_CELL_FIELDS, c as pageScopeKey, d as resolveComponent, f as cellAttributes, g as assembleCellProps, h as pageContainerStyle, i as projectLive, l as projectScopeKey, n as attachViewStateSetters, o as projectViewState, p as cellPlacementStyle, r as collectScopeIds, s as shallowEqualBundle, t as attachSelectionSetters, u as resolveScopeId, v as projectCellData, w as resolveCell, x as STORE_FIELDS, y as CONTENT_FIELDS } from "./chunks/projection-yvYKzMOS.js";
2
- import { C as resolveReferences, S as passesConditions, _ as EACH_DEFAULT_AS, a as descriptorShape, b as isEach, c as prepareDocument, d as selectionShape, f as shapeAt, g as EACH, h as variableReferences, i as VARIABLE_NAMESPACES, l as queryKey, m as variableLabels, n as RENDER_FUNCTIONS, o as orderByVariable, p as validateDescriptor, r as UnsafeDocumentError, s as pageVariables, t as PAGING_VARIABLES, u as resolveDescriptorVariables, v as cellContext, w as settled, x as pageContext, y as cellResolutionContext } from "./chunks/query-BPuCJC1C.js";
3
- import { _ as stateValue, a as nearestNames, b as walkRequest, c as selectionIssues, d as needsWalk, f as readField, g as stateNames, h as resolveWalkStart, i as eachFormProblems, l as RESERVED_LABELS, m as referencedLabels, n as STORE_SCOPES, o as validateCell, p as readWalk, r as WALK_DIRECTIONS, s as validatePage, t as RESPONSIVE_BUCKETS, u as mergeStates, v as systemsFromProcess, y as walkKey } from "./chunks/validate-4LgH8QMJ.js";
4
- import { C as resolveAction, S as projectCellActions, _ as actionBindingKey, a as deriveSectionReferences, b as declaredActions, c as nodePrintStyle, d as referencesFor, f as sectionAnchor, g as usesStructureLayout, h as tableOfContents, i as deriveSectionNumbering, l as normalizeStructure, m as structureIssues, n as SECTION_KINDS, r as deriveElementReferences, s as mergeSectionReferences, t as PAGE_DOCUMENT, u as numberingFor, v as actionProblems, x as normalizeActionDeclaration, y as actionReferences } from "./chunks/structure-o9pYoDjD.js";
5
- import { a as loadBundlesSettled, i as loadBundles, n as isComponentExport, o as projectModule, r as loadBundle, s as runtimeReady, t as _clearBundleCache } from "./chunks/load-CjPvISzH.js";
6
- import { a as normalizeRef, i as bundleScope, n as MAIN, o as refKey, r as PUBLIC, t as CORE_SPECIFIER } from "./chunks/refs-BLUokra5.js";
7
- import { n as pageBundles, t as pageBundleRefs } from "./chunks/page-bundles-DLRIBP8g.js";
8
- import { a as createStackStore, i as saveScope, n as clearScope, r as loadScope } from "./chunks/persistence-DCMakM9H.js";
9
- import { ACTION_KINDS, QUERY_DESCRIPTOR_KEY, SECTION_KINDS as SECTION_KINDS$1, STATE_ROLES, STATE_TIERS, WALK_DEFAULTS, isDescriptorBinding, isLiveQueryState } from "@peripheries/runtime";
10
- //#region packages/renderer/src/core/data-context.ts
1
+ import { C as normalizeCell, S as hasRef, T as rootCells, a as projectSelections, b as HYDRATED_CELL_FIELDS, c as pageScopeKey, d as resolveComponent, f as cellAttributes, g as assembleCellProps, h as pageContainerStyle, i as projectLive, l as projectScopeKey, n as attachViewStateSetters, o as projectViewState, p as cellPlacementStyle, r as collectScopeIds, s as shallowEqualBundle, t as attachSelectionSetters, u as resolveScopeId, v as projectCellData, w as resolveCell, x as STORE_FIELDS, y as CONTENT_FIELDS } from "./chunks/projection-zhu32_KJ.js";
2
+ import { C as passesConditions, S as pageContext, T as settled, _ as EACH, a as VARIABLE_NAMESPACES, b as cellResolutionContext, c as pageVariables, d as resolveDescriptorVariables, f as selectionShape, g as variableReferences, h as variableLabels, i as UnsafeDocumentError, l as prepareDocument, m as validateDescriptor, n as RENDER_FUNCTIONS, o as descriptorShape, p as shapeAt, r as RENDER_FUNCTIONS_AHEAD, s as orderByVariable, t as PAGING_VARIABLES, u as queryKey, v as EACH_DEFAULT_AS, w as resolveReferences, x as isEach, y as cellContext } from "./chunks/query-D6xQbTFK.js";
3
+ import { _ as stateValue, a as nearestNames, b as walkKey, c as selectionIssues, d as needsWalk, f as readField, g as stateNames, h as resolveWalkStart, i as eachFormProblems, l as RESERVED_LABELS, m as referencedLabels, n as STORE_SCOPES, o as validateCell, p as readWalk, r as WALK_DIRECTIONS, s as validatePage, t as RESPONSIVE_BUCKETS, u as mergeStates, v as systemsFromGraphs, x as walkRequest, y as systemsFromProcess } from "./chunks/validate-BcB_PA1k.js";
4
+ import { C as resolveAction, S as projectCellActions, _ as actionBindingKey, a as deriveSectionReferences, b as declaredActions, c as nodePrintStyle, d as referencesFor, f as sectionAnchor, g as usesStructureLayout, h as tableOfContents, i as deriveSectionNumbering, l as normalizeStructure, m as structureIssues, n as SECTION_KINDS, r as deriveElementReferences, s as mergeSectionReferences, t as PAGE_DOCUMENT, u as numberingFor, v as actionProblems, x as normalizeActionDeclaration, y as actionReferences } from "./chunks/structure-CKBtQHJq.js";
5
+ import { a as loadBundlesSettled, i as loadBundles, n as isComponentExport, o as projectModule, r as loadBundle, s as runtimeReady, t as _clearBundleCache } from "./chunks/load-b38vUiZM.js";
6
+ import { a as normalizeRef, i as bundleScope, n as MAIN, o as refKey, r as PUBLIC, t as CORE_SPECIFIER } from "./chunks/refs-Csgh6rXq.js";
7
+ import { n as pageBundles, t as pageBundleRefs } from "./chunks/page-bundles-CPj_vx-J.js";
8
+ import { a as createStackStore, i as saveScope, n as clearScope, r as loadScope } from "./chunks/persistence-hurkUUQ0.js";
9
+ import { ACTION_KINDS, QUERY_DESCRIPTOR_KEY, SECTION_KINDS as SECTION_KINDS$1, STATE_ROLES, STATE_TIERS, WALK_DEFAULTS, isDescriptorBinding, isLiveQueryState, isReadOnlyVersion } from "@peripheries/runtime";
11
10
  function resolveDeclarations(queries, systems, diagnostics = [], cellId) {
12
11
  const out = {};
13
12
  for (const [label, raw] of Object.entries(queries ?? {})) {
@@ -79,7 +78,8 @@ function buildDataContext(input) {
79
78
  reads: decl.reads.map((r) => ({
80
79
  systemId: r.systemId,
81
80
  ...r.name ? { name: r.name } : {},
82
- stateId: input.stateIds?.get(`${r.systemId}/${decl.graph_node_id}`) ?? null
81
+ stateId: input.stateIds?.get(`${r.systemId}/${decl.graph_node_id}`) ?? null,
82
+ ...input.stateVersions?.get(`${r.systemId}/${decl.graph_node_id}`)
83
83
  })),
84
84
  at: decl.field ? decl.field.split(".") : []
85
85
  };
@@ -90,13 +90,10 @@ function buildDataContext(input) {
90
90
  }
91
91
  return ctx;
92
92
  }
93
- //#endregion
94
- //#region packages/renderer/src/core/load-page.ts
95
93
  async function resolveSystems(source, page) {
96
- const systems = page.process_id ? systemsFromProcess(await source.processSystems(page.process_id)) : {};
94
+ const systems = !page.process_id ? {} : source.graphSystems ? systemsFromGraphs(await source.graphSystems(page.process_id)) : systemsFromProcess(await source.processSystems?.(page.process_id));
97
95
  if (!systems.eng_data) {
98
- const meta = page.metadata ?? {};
99
- const fallback = meta.pageProcess?.eng_data_system_id ?? meta.systemGraph?.system_id;
96
+ const fallback = (page.metadata?.systemGraph)?.system_id;
100
97
  if (fallback) systems.eng_data = fallback;
101
98
  }
102
99
  return systems;
@@ -116,10 +113,31 @@ function unresolvedEntry(missing, data) {
116
113
  ...upstreamFailed ? {} : { unresolved: missing }
117
114
  };
118
115
  }
116
+ function mainSystemFilter(source, diagnostics) {
117
+ const known = new Map();
118
+ return async (ids) => {
119
+ if (!source.mainSystems) return () => true;
120
+ const ask = [...new Set(ids)].filter((id) => !known.has(id));
121
+ if (ask.length) {
122
+ const main = await source.mainSystems(ask);
123
+ for (const id of ask) {
124
+ known.set(id, main.has(id));
125
+ if (!main.has(id)) diagnostics.push({
126
+ severity: "warning",
127
+ code: "SYSTEM_NOT_MAIN",
128
+ message: `the system ${id} isn't a main system the viewer can read; a page reads main systems only, so it reads as absent`
129
+ });
130
+ }
131
+ }
132
+ return (id) => known.get(id) === true;
133
+ };
134
+ }
119
135
  async function loadPageData(page, source, scope = {}) {
120
136
  const diagnostics = validatePage(page);
121
137
  const systems = await resolveSystems(source, page);
122
138
  const engDataSystemId = systems.eng_data ?? null;
139
+ const mainOnly = mainSystemFilter(source, diagnostics);
140
+ const readAt = scope.version?.versionId ? [{ versionId: scope.version.versionId }] : [];
123
141
  const entries = (page.content?.cells ?? []).map((c) => normalizeCell(c).cell);
124
142
  const refsBySystem = new Map();
125
143
  for (const c of entries) {
@@ -128,8 +146,9 @@ async function loadPageData(page, source, scope = {}) {
128
146
  if (system) refsBySystem.set(system, [...refsBySystem.get(system) ?? [], c.ref.graph_node_id]);
129
147
  }
130
148
  const configs = new Map();
131
- await Promise.all([...refsBySystem].map(async ([system, ids]) => {
132
- const found = await source.cellConfigs(system, ids);
149
+ const refMain = await mainOnly(refsBySystem.keys());
150
+ await Promise.all([...refsBySystem].filter(([system]) => refMain(system)).map(async ([system, ids]) => {
151
+ const found = await source.cellConfigs(system, ids, ...readAt);
133
152
  for (const [id, config] of Object.entries(found)) configs.set(`${system}/${id}`, config);
134
153
  }));
135
154
  const cells = entries.map((c) => {
@@ -182,6 +201,11 @@ async function loadPageData(page, source, scope = {}) {
182
201
  request
183
202
  });
184
203
  }
204
+ const isMain = await mainOnly([...walking.flatMap(({ request }) => request.states.map((st) => st.systemId)), ...[declared, ...cellDecls.values()].flatMap((decls) => Object.values(decls).flatMap((d) => d.reads.map((r) => r.systemId)))]);
205
+ for (const w of walking) w.request = {
206
+ ...w.request,
207
+ states: w.request.states.filter((st) => isMain(st.systemId))
208
+ };
185
209
  const requests = new Map(walking.map(({ request }) => [walkKey(request), request]));
186
210
  const bySystem = new Map();
187
211
  const recordIds = new Set();
@@ -190,10 +214,10 @@ async function loadPageData(page, source, scope = {}) {
190
214
  for (const decls of allDecls) for (const d of Object.values(decls)) {
191
215
  if (d.as === "record") {
192
216
  recordIds.add(d.graph_node_id);
193
- for (const r of d.reads) recordSystems.add(r.systemId);
217
+ for (const r of d.reads) if (isMain(r.systemId)) recordSystems.add(r.systemId);
194
218
  continue;
195
219
  }
196
- for (const r of d.reads) bySystem.set(r.systemId, (bySystem.get(r.systemId) ?? new Set()).add(d.graph_node_id));
220
+ for (const r of d.reads) if (isMain(r.systemId)) bySystem.set(r.systemId, (bySystem.get(r.systemId) ?? new Set()).add(d.graph_node_id));
197
221
  }
198
222
  const runs = new Map();
199
223
  const runQuery = (d, ctx, at) => {
@@ -244,7 +268,13 @@ async function loadPageData(page, source, scope = {}) {
244
268
  return entry;
245
269
  });
246
270
  };
247
- const base = pageContext(scope.context, page);
271
+ const base = {
272
+ ...pageContext(scope.context, page),
273
+ ...scope.version?.versionId ? {
274
+ version: scope.version.versionId,
275
+ versionKind: scope.version.versionKind
276
+ } : {}
277
+ };
248
278
  const who = (ctx) => ({
249
279
  viewer: scope.viewer,
250
280
  context: ctx
@@ -267,6 +297,7 @@ async function loadPageData(page, source, scope = {}) {
267
297
  };
268
298
  const states = new Map();
269
299
  const stateIds = new Map();
300
+ const stateVersions = new Map();
270
301
  const walks = new Map();
271
302
  let records = {};
272
303
  const pageEntries = {};
@@ -305,19 +336,23 @@ async function loadPageData(page, source, scope = {}) {
305
336
  await Promise.all([
306
337
  ...[...bySystem].map(async ([systemId, ids]) => {
307
338
  if (source.latestStateRows) {
308
- const rows = await source.latestStateRows(systemId, [...ids]);
339
+ const rows = await source.latestStateRows(systemId, [...ids], ...readAt);
309
340
  for (const [nodeId, row] of Object.entries(rows)) {
310
341
  states.set(`${systemId}/${nodeId}`, row.data);
311
342
  stateIds.set(`${systemId}/${nodeId}`, row.id);
343
+ if (readAt.length) stateVersions.set(`${systemId}/${nodeId}`, {
344
+ versionId: row.versionId ?? null,
345
+ outOfScope: row.outOfScope ?? false
346
+ });
312
347
  }
313
348
  return;
314
349
  }
315
- const found = await source.latestStates(systemId, [...ids]);
350
+ const found = await source.latestStates(systemId, [...ids], ...readAt);
316
351
  for (const [nodeId, state] of Object.entries(found)) states.set(`${systemId}/${nodeId}`, state);
317
352
  }),
318
353
  ...[...requests].map(async ([key, request]) => {
319
354
  try {
320
- walks.set(key, await source.walk(request));
355
+ walks.set(key, await source.walk(request, ...readAt));
321
356
  } catch (e) {
322
357
  diagnostics.push({
323
358
  severity: "error",
@@ -327,7 +362,7 @@ async function loadPageData(page, source, scope = {}) {
327
362
  }
328
363
  }),
329
364
  recordIds.size ? (async () => {
330
- records = recordsByName(await source.nodeRecords([...recordIds], [...recordSystems]), allDecls);
365
+ records = recordsByName(await source.nodeRecords([...recordIds], [...recordSystems], ...readAt), allDecls);
331
366
  })() : null,
332
367
  ...early
333
368
  ]);
@@ -372,7 +407,8 @@ async function loadPageData(page, source, scope = {}) {
372
407
  declared: decls,
373
408
  states,
374
409
  records,
375
- stateIds
410
+ stateIds,
411
+ stateVersions
376
412
  });
377
413
  if (cell.data?.static && Object.keys(cell.data.static).length) entry(cell.id).static = buildDataContext({
378
414
  static: cell.data.static,
@@ -408,7 +444,8 @@ async function loadPageData(page, source, scope = {}) {
408
444
  declared,
409
445
  states,
410
446
  records,
411
- stateIds
447
+ stateIds,
448
+ stateVersions
412
449
  });
413
450
  const pageVars = {
414
451
  data: {
@@ -485,6 +522,7 @@ async function loadPageData(page, source, scope = {}) {
485
522
  if (n.cellId ? cell.id !== n.cellId : !cell.component || cell.data?.queries?.[n.label]) continue;
486
523
  diagnostics.push(...selectionIssues(cell, { [n.label]: n.descriptor }, `cell ${cell.id}`));
487
524
  }
525
+ const readVersionIds = [...new Set([...stateVersions.values()].filter((v) => !v.outOfScope && v.versionId).map((v) => v.versionId))].sort();
488
526
  const embeds = {};
489
527
  await Promise.all(cells.filter((c) => c.embed).map(async (c) => {
490
528
  if (scope.embedded) {
@@ -501,7 +539,7 @@ async function loadPageData(page, source, scope = {}) {
501
539
  ...selector,
502
540
  project_id: selector.project_id ?? page.project_id ?? void 0
503
541
  };
504
- const target = source.page && (wanted.page_id || wanted.page_type && wanted.project_id) ? await source.page(wanted).catch(() => null) : null;
542
+ const target = source.page && (wanted.page_id || wanted.page_type && wanted.project_id) ? await source.page(wanted, ...readAt).catch(() => null) : null;
505
543
  if (!target || target.id === page.id) {
506
544
  diagnostics.push({
507
545
  severity: "warning",
@@ -512,14 +550,25 @@ async function loadPageData(page, source, scope = {}) {
512
550
  embeds[c.id] = null;
513
551
  return;
514
552
  }
515
- embeds[c.id] = await loadPageData(target, source, {
553
+ const recorded = scope.recordedEmbeds?.find((e) => e.graph_node_id === target.graph_node_id);
554
+ const version = recorded ? {
555
+ versionId: recorded.release_id,
556
+ versionKind: "release"
557
+ } : scope.version;
558
+ const loaded = await loadPageData(target, source, {
516
559
  ...scope,
517
560
  params: {
518
561
  ...scope.params,
519
562
  pageId: target.id
520
563
  },
521
- embedded: true
564
+ embedded: true,
565
+ version,
566
+ recordedEmbeds: void 0
522
567
  });
568
+ embeds[c.id] = {
569
+ ...loaded,
570
+ embedVersion: recorded ? "recorded" : "context"
571
+ };
523
572
  }));
524
573
  const graphNodeIds = new Set([
525
574
  ...Object.values(embeds).flatMap((e) => e?.graphNodeIds ?? []),
@@ -538,6 +587,8 @@ async function loadPageData(page, source, scope = {}) {
538
587
  systems,
539
588
  engDataSystemId,
540
589
  graphNodeIds: [...graphNodeIds].sort(),
590
+ ...scope.version?.versionId ? { version: scope.version } : {},
591
+ ...readVersionIds.length ? { readVersionIds } : {},
541
592
  ...Object.keys(embeds).length ? { embeds } : {},
542
593
  diagnostics: dedupe(diagnostics)
543
594
  };
@@ -566,8 +617,6 @@ function recordsByName(found, declarations) {
566
617
  }
567
618
  return out;
568
619
  }
569
- //#endregion
570
- //#region packages/renderer/src/core/sources.ts
571
620
  var TOOL_OWNED_KEYS = ["content_index", "ref_index"];
572
621
  var STRUCTURE_FIELDS = [
573
622
  "title",
@@ -576,11 +625,27 @@ var STRUCTURE_FIELDS = [
576
625
  "directed",
577
626
  "status"
578
627
  ];
579
- function editTarget(source, cell) {
628
+ function editTarget(source, cell, version) {
580
629
  if (source.kind === "derived") return {
581
630
  fn: null,
582
631
  reason: "DERIVED"
583
632
  };
633
+ if (isReadOnlyVersion(version)) return {
634
+ fn: null,
635
+ reason: "VERSION_IS_RELEASE"
636
+ };
637
+ const target = editAtMain(source, cell);
638
+ if (target.fn === null) return target;
639
+ if (source.kind === "state" && source.reads.some((r) => r.outOfScope && r.versionId)) return {
640
+ fn: null,
641
+ reason: "VERSION_IS_RELEASE"
642
+ };
643
+ return version?.versionKind === "branch" && version.versionId ? {
644
+ ...target,
645
+ versionId: version.versionId
646
+ } : target;
647
+ }
648
+ function editAtMain(source, cell) {
584
649
  if (source.kind === "static") {
585
650
  if (source.scope === "page") return {
586
651
  fn: "page_edit_data",
@@ -671,8 +736,6 @@ function cellPropSources(runtime, cell, env = {}) {
671
736
  }))
672
737
  };
673
738
  }
674
- //#endregion
675
- //#region packages/renderer/src/core/diagnostics.ts
676
739
  var DIAGNOSTICS = {
677
740
  PAGE_INVALID: {
678
741
  meaning: "`content.cells` is not a list.",
@@ -780,14 +843,14 @@ var DIAGNOSTICS = {
780
843
  },
781
844
  UNSUPPORTED_REGISTRY_BINDING: {
782
845
  meaning: "A binding names a registry query (`{ registry: \"x.y\" }`) from the retired host contract.",
783
- fix: "Copy the matching recipe’s descriptor into `{ descriptor }` (the component’s pattern pack has it), or bind the graph node that produces the data. docs/plan/host-contract-verdicts.md maps every id."
846
+ fix: "Copy the matching recipe’s descriptor into `{ descriptor }` (the component’s pattern pack has it), or bind the graph node that produces the data."
784
847
  },
785
848
  STATE_UNKNOWN_NAME: {
786
- meaning: "A state name is not one of the twelve systems.",
787
- fix: "Use `<tier>_<role>`: tier meta, eng or ops; role data, process, model or appraisal (default `eng_data`)."
849
+ meaning: "A state name is not `<tier>_<role>`.",
850
+ fix: "Use `<tier>_<role>`: tier meta, eng or ops; role a registered layer’s role (data, process, model, appraisal, or another such as answer); default `eng_data`."
788
851
  },
789
852
  STATE_UNKNOWN_SYSTEM: {
790
- meaning: "The page’s process has no system of that name.",
853
+ meaning: "The page’s process has no main system of that name on its graphs.",
791
854
  fix: "Read a system the process has, usually `eng_data`."
792
855
  },
793
856
  LABEL_RESERVED: {
@@ -802,6 +865,14 @@ var DIAGNOSTICS = {
802
865
  meaning: "The document isn’t one query operation that reads only tables, views and the render functions.",
803
866
  fix: "Write one `query`, whose root fields are `<table>Collection`, `<table>ByPk`, `node` or a render function such as `walk_graph`; no mutations, RPCs or introspection."
804
867
  },
868
+ DESCRIPTOR_VERSION_FILTER: {
869
+ meaning: "The document filters `systemCollection`, `graph_nodeCollection` or `graph_edgeCollection` on `version`, or passes their whole filter as a variable. A page reads main systems and placements only, and the host adds that filter itself.",
870
+ fix: "Drop the `version` filter and write the filter in the document; a branch is read through a version context."
871
+ },
872
+ DESCRIPTOR_STATE_UNSCOPED: {
873
+ meaning: "The document reads states, runs or a latest-state view by node or with no filter, so it would read every system’s rows, a branch’s included.",
874
+ fix: "Read them under a `systemCollection`, or filter `system_id` (or the id, or the run) with `eq` or `in`; for the latest state across systems, use a render function."
875
+ },
805
876
  DESCRIPTOR_VARIABLE_MISSING: {
806
877
  meaning: "The document requires a variable that `variables` doesn’t give.",
807
878
  fix: "Give it in `variables`, as a literal or a reference (`@params.clientId`, `@viewer.userId`, `@budget.graph_node_id`); `$orderBy` comes from `order_by`."
@@ -818,6 +889,10 @@ var DIAGNOSTICS = {
818
889
  meaning: "`order_by` is set, but the document declares no `$orderBy`, so it is ignored.",
819
890
  fix: "Declare `$orderBy: [<table>OrderBy!]` and pass `orderBy: $orderBy`, or remove `order_by`."
820
891
  },
892
+ DESCRIPTOR_ALIAS_JSON_ROOT: {
893
+ meaning: "A render function that returns JSON is aliased at the root; its JSON is decoded by the field’s name, so under an alias it stays a string.",
894
+ fix: "Name the field without an alias (`form_answers(...)`, not `answers: form_answers(...)`) and point `result.path` at it."
895
+ },
821
896
  DESCRIPTOR_RESULT_PATH: {
822
897
  meaning: "`result.path` names a part of the result the document doesn’t select.",
823
898
  fix: "Point it at a selected field (its alias, if it has one), e.g. `clientCollection`."
@@ -874,6 +949,10 @@ var DIAGNOSTICS = {
874
949
  meaning: "`nodeTypes: []` filters nothing.",
875
950
  fix: "Leave `nodeTypes` out, or name the types the walk may enter."
876
951
  },
952
+ SYSTEM_NOT_MAIN: {
953
+ meaning: "A ref, a declaration or a walk names a system that isn’t a main system (a branch’s, or one the viewer can’t read); a page reads main systems only, so its states read as absent.",
954
+ fix: "Name the process’s main system (or none, for the page’s DSNS); a branch is read through a version context, not a system id."
955
+ },
877
956
  WALK_NO_START: {
878
957
  meaning: "A cell has a traversal, but neither it nor the page has a graph node to start from.",
879
958
  fix: "Publish the page with its graph node, or give the cell a node."
@@ -935,8 +1014,6 @@ var DIAGNOSTICS = {
935
1014
  fix: "Fix the snippet; it is copied far more faithfully than any rule."
936
1015
  }
937
1016
  };
938
- //#endregion
939
- //#region packages/renderer/src/core/rules.ts
940
1017
  var LAYOUT_TYPES = [
941
1018
  "stack",
942
1019
  "grid",
@@ -983,8 +1060,6 @@ The host's rules for every page. Components, kits and patterns are in the catalo
983
1060
  ## When a check fails
984
1061
  Every page write is validated; each diagnostic names its code, place and fix.
985
1062
  `;
986
- //#endregion
987
- //#region packages/renderer/src/core/values.ts
988
1063
  var isTraversal = (v) => !!v && typeof v === "object" && Array.isArray(v.nodes);
989
1064
  function pageRuntimeFromValues(page, { values = {}, traversal } = {}) {
990
1065
  const cells = (page.content?.cells ?? []).map((c) => resolveCell(normalizeCell(c).cell, null));
@@ -1022,7 +1097,23 @@ function pageRuntimeFromValues(page, { values = {}, traversal } = {}) {
1022
1097
  diagnostics: validatePage(page)
1023
1098
  };
1024
1099
  }
1025
- //#endregion
1026
- export { CONTENT_FIELDS, CORE_SPECIFIER, DIAGNOSTICS, EACH, EACH_DEFAULT_AS, HYDRATED_CELL_FIELDS, LAYOUT_TYPES, MAIN, PAGE_DOCUMENT, PAGE_RULES, PAGING_VARIABLES, PUBLIC, RENDER_FUNCTIONS, RESERVED_LABELS, RESPONSIVE_BUCKETS, SECTION_KINDS, STORE_FIELDS, STORE_SCOPES, STRUCTURE_FIELDS, TOOL_OWNED_KEYS, UnsafeDocumentError, VARIABLE_NAMESPACES, WALK_DIRECTIONS, _clearBundleCache, actionBindingKey, actionProblems, actionReferences, assembleCellProps, attachSelectionSetters, attachViewStateSetters, buildDataContext, bundleScope, cellAttributes, cellContext, cellPlacementStyle, cellPropSources, cellResolutionContext, clearScope, collectDeclarations, collectDescriptors, collectScopeIds, collectStatic, createStackStore, declaredActions, deriveElementReferences, deriveSectionNumbering, deriveSectionReferences, descriptorShape, eachFormProblems, editTarget, hasRef, isComponentExport, isEach, loadBundle, loadBundles, loadBundlesSettled, loadPageData, loadScope, mergeSectionReferences, mergeStates, nearestNames, needsWalk, nodePrintStyle, normalizeActionDeclaration, normalizeCell, normalizeRef, normalizeStructure, numberingFor, orderByVariable, pageBundleRefs, pageBundles, pageContainerStyle, pageContext, pageRuntimeFromValues, pageScopeKey, pageVariables, passesConditions, patchAt, prepareDocument, projectCellActions, projectCellData, projectLive, projectModule, projectScopeKey, projectSelections, projectViewState, queryKey, readField, readWalk, refKey, referencedLabels, referencesFor, resolveAction, resolveCell, resolveComponent, resolveDataSystem, resolveDeclarations, resolveDescriptorVariables, resolveReferences, resolveScopeId, resolveSystems, resolveWalkStart, rootCells, runtimeReady, saveScope, sectionAnchor, selectionIssues, selectionShape, settled, shallowEqualBundle, shapeAt, stateNames, stateValue, structureIssues, systemsFromProcess, tableOfContents, usesStructureLayout, validateCell, validateDescriptor, validatePage, variableLabels, variableReferences, walkKey, walkRequest };
1027
-
1028
- //# sourceMappingURL=core.js.map
1100
+ function validateManifest(pages, catalog) {
1101
+ return pages.flatMap(({ graphNodeId, page }) => validatePage(page, catalog).filter((d) => d.severity === "error").map((d) => ({
1102
+ graph_node_id: graphNodeId,
1103
+ code: d.code,
1104
+ ...d.cellId ? { cell_id: d.cellId } : {},
1105
+ ...d.path ? { path: d.path } : {}
1106
+ })));
1107
+ }
1108
+ function manifestPageFrom(graphNodeId, data) {
1109
+ const { layout, is_template, ...content } = data && typeof data === "object" && !Array.isArray(data) ? data : {};
1110
+ return {
1111
+ graphNodeId,
1112
+ page: {
1113
+ content,
1114
+ layout: layout && typeof layout === "object" ? layout : null,
1115
+ ...typeof is_template === "boolean" ? { is_template } : {}
1116
+ }
1117
+ };
1118
+ }
1119
+ export { CONTENT_FIELDS, CORE_SPECIFIER, DIAGNOSTICS, EACH, EACH_DEFAULT_AS, HYDRATED_CELL_FIELDS, LAYOUT_TYPES, MAIN, PAGE_DOCUMENT, PAGE_RULES, PAGING_VARIABLES, PUBLIC, RENDER_FUNCTIONS, RENDER_FUNCTIONS_AHEAD, RESERVED_LABELS, RESPONSIVE_BUCKETS, SECTION_KINDS, STORE_FIELDS, STORE_SCOPES, STRUCTURE_FIELDS, TOOL_OWNED_KEYS, UnsafeDocumentError, VARIABLE_NAMESPACES, WALK_DIRECTIONS, _clearBundleCache, actionBindingKey, actionProblems, actionReferences, assembleCellProps, attachSelectionSetters, attachViewStateSetters, buildDataContext, bundleScope, cellAttributes, cellContext, cellPlacementStyle, cellPropSources, cellResolutionContext, clearScope, collectDeclarations, collectDescriptors, collectScopeIds, collectStatic, createStackStore, declaredActions, deriveElementReferences, deriveSectionNumbering, deriveSectionReferences, descriptorShape, eachFormProblems, editTarget, hasRef, isComponentExport, isEach, loadBundle, loadBundles, loadBundlesSettled, loadPageData, loadScope, manifestPageFrom, mergeSectionReferences, mergeStates, nearestNames, needsWalk, nodePrintStyle, normalizeActionDeclaration, normalizeCell, normalizeRef, normalizeStructure, numberingFor, orderByVariable, pageBundleRefs, pageBundles, pageContainerStyle, pageContext, pageRuntimeFromValues, pageScopeKey, pageVariables, passesConditions, patchAt, prepareDocument, projectCellActions, projectCellData, projectLive, projectModule, projectScopeKey, projectSelections, projectViewState, queryKey, readField, readWalk, refKey, referencedLabels, referencesFor, resolveAction, resolveCell, resolveComponent, resolveDataSystem, resolveDeclarations, resolveDescriptorVariables, resolveReferences, resolveScopeId, resolveSystems, resolveWalkStart, rootCells, runtimeReady, saveScope, sectionAnchor, selectionIssues, selectionShape, settled, shallowEqualBundle, shapeAt, stateNames, stateValue, structureIssues, systemsFromGraphs, systemsFromProcess, tableOfContents, usesStructureLayout, validateCell, validateDescriptor, validateManifest, validatePage, variableLabels, variableReferences, walkKey, walkRequest };
package/dist/forms.js ADDED
@@ -0,0 +1,2 @@
1
+ import { _ as CONDITION_OPS, a as goToQuestion, b as normalizeCondition, c as missing, d as positionsOf, f as progress, g as visibleSteps, h as stepKind, i as goTo, l as move, m as settle, n as enterAdvances, o as isReadOnlyStatus, p as questionsOf, r as fromPageSteps, s as linkTo, t as defaultMode, u as positionFromLink, v as evaluateCondition, x as normalizeOperator, y as isConditionOp } from "./chunks/forms-DxA9WzCt.js";
2
+ export { CONDITION_OPS, defaultMode, enterAdvances, evaluateCondition, fromPageSteps, goTo, goToQuestion, isConditionOp, isReadOnlyStatus, linkTo, missing, move, normalizeCondition, normalizeOperator, positionFromLink, positionsOf, progress, questionsOf, settle, stepKind, visibleSteps };
package/dist/print.js CHANGED
@@ -1,4 +1,3 @@
1
- //#region packages/renderer/src/print/document-profile.ts
2
1
  var bundleName = (bundle) => bundle.label ?? bundle.key ?? "(unkeyed)";
3
2
  var DEFAULTS = {
4
3
  profile: null,
@@ -73,8 +72,6 @@ function readMaxDepth(profile, bundleKey) {
73
72
  }
74
73
  return max;
75
74
  }
76
- //#endregion
77
- //#region packages/renderer/src/print/document-bindings.ts
78
75
  function asRecord(value) {
79
76
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
80
77
  }
@@ -101,8 +98,6 @@ function resolveProfileId(page) {
101
98
  if (fromMetadata !== void 0 && fromMetadata !== fromLayout) console.warn(`[document-bindings] page declares layout.profile=${JSON.stringify(fromLayout)} and metadata.profile=${JSON.stringify(fromMetadata)}. **layout wins.** These are two copies of one fact and only one is read — delete metadata.profile rather than keeping them in step by hand.`);
102
99
  return fromLayout;
103
100
  }
104
- //#endregion
105
- //#region packages/renderer/src/print/print-policy.ts
106
101
  var BREAK_INSIDE = new Set(["avoid", "auto"]);
107
102
  function toCount(value) {
108
103
  if (!/^[1-9][0-9]*$/.test(value)) return void 0;
@@ -221,8 +216,6 @@ function deserializeConstraints(value) {
221
216
  const { constraints } = parsePrintPolicy(raw);
222
217
  return Object.keys(constraints).length > 0 ? constraints : void 0;
223
218
  }
224
- //#endregion
225
- //#region packages/renderer/src/print/page-map.ts
226
219
  function collectBlocks(root, printWidthPx, { measureRect, readConstraints, boxFor = defaultBoxFor, selector = "[data-cell-id]", sectionStart, blankBefore }) {
227
220
  if (!root) return {
228
221
  blocks: [],
@@ -444,8 +437,6 @@ function paperGeometryPx(sheet, margins, columns) {
444
437
  columnsReconcile: railPx === 0 || printWidthPx + gutterPx + railPx === pageBoxWidthPx
445
438
  };
446
439
  }
447
- //#endregion
448
- //#region packages/renderer/src/print/paginate.ts
449
440
  function mayNotSplit(c) {
450
441
  if (!c) return true;
451
442
  if (c.atomic) return true;
@@ -663,8 +654,6 @@ function paginate(blocks, { textBlockPx, keepWithNextScaleFloor = .6, sectionFil
663
654
  idealPages: textBlockPx > 0 ? Number((total / textBlockPx).toFixed(2)) : 0
664
655
  };
665
656
  }
666
- //#endregion
667
- //#region packages/renderer/src/print/running-header.ts
668
657
  function resolveRunningValues(map, bands, markers) {
669
658
  const markerByCell = new Map(markers.map((m) => [m.cellId, m]));
670
659
  const cellsOfBand = new Map(bands.map((b) => [b.id, b.members]));
@@ -711,8 +700,6 @@ function runningSlotValues(values, { continuedSuffix = " (continued)" } = {}) {
711
700
  "section-title-continued": values.continued ? `${values.sectionTitle}${continuedSuffix}` : values.sectionTitle
712
701
  };
713
702
  }
714
- //#endregion
715
- //#region packages/renderer/src/print/print-stylesheet.ts
716
703
  var warned = new Set();
717
704
  function warnOnce(key, message) {
718
705
  if (warned.has(key)) return;
@@ -862,8 +849,6 @@ function buildPageVariables(profile) {
862
849
  }
863
850
  return decls.length > 0 ? `:root {\n${decls.join("\n")}\n}` : "";
864
851
  }
865
- //#endregion
866
- //#region packages/renderer/src/print/print-layout.ts
867
852
  var SEPARATOR_MARGIN_PX = 48;
868
853
  var SEPARATOR_PADDING_PX = 16;
869
854
  var SEPARATOR_BORDER_PX = 2;
@@ -1048,8 +1033,6 @@ function round2(n) {
1048
1033
  function round4(n) {
1049
1034
  return Math.round(n * 1e4) / 1e4;
1050
1035
  }
1051
- //#endregion
1052
- //#region packages/renderer/src/print/map-staleness.ts
1053
1036
  function expectedHeightAfterTypesetting(measuredContainerPx, layout) {
1054
1037
  return measuredContainerPx - layout.scaled.reduce((sum, r) => sum + (r.heightPx - r.scaledHeightPx), 0) + layout.screenExtraPx;
1055
1038
  }
@@ -1065,8 +1048,6 @@ function mapStaleness(liveHeightPx, expectedPx, textBlockPx) {
1065
1048
  tolerancePx
1066
1049
  };
1067
1050
  }
1068
- //#endregion
1069
- //#region packages/renderer/src/print/print-lint.ts
1070
1051
  var VIEWPORT_UNIT = /(?<![\w-])(\d*\.?\d+)(v[hw]|vmin|vmax|[sld]v[hwbi]|vb|vi)(?![\w-])/gi;
1071
1052
  var IGNORED_PROPERTIES = new Set(["container-type"]);
1072
1053
  function viewportUnitsIn(cssText, where) {
@@ -1121,8 +1102,6 @@ function describe(el) {
1121
1102
  if (cls) return `${el.tagName.toLowerCase()}.${cls.trim().split(/\s+/).slice(0, 2).join(".")}`;
1122
1103
  return el.tagName.toLowerCase();
1123
1104
  }
1124
- //#endregion
1125
- //#region packages/renderer/src/print/structure-print.ts
1126
1105
  function setRowPageIntent(structure, cellId, intent) {
1127
1106
  if (!structure || !cellId) return {
1128
1107
  structure: structure ?? [],
@@ -1385,7 +1364,4 @@ function splitMarginalia(page, marginaliaCellId, hasReservedTrack) {
1385
1364
  reason: null
1386
1365
  };
1387
1366
  }
1388
- //#endregion
1389
1367
  export { BLANK_PAGE_SEPARATOR_PX, DEFAULT_MARGINS, DEFAULT_SHEET, MissingRequiredBindingError, PRINT_POLICY_ATTR, RUNNING_SLOTS, SEPARATOR_TOTAL_PX, __clearDocumentProfileWarnings, __clearPrintStylesheetWarnings, applyRowPrint, auditPrintLint, buildPageStylesheet, buildPageVariables, buildPrintLayout, checkPaginatorBindings, collectBlocks, composeConstraints, constraintsFromBox, constraintsFromComputedStyle, constraintsResolver, cssLengthToPx, cssString, cssValue, deserializeConstraints, diffRowPrint, expectedHeightAfterTypesetting, findSlottedCellIds, forcedBreaksWithin, intentOfPrintBlock, isRunningSlot, mapStaleness, mediaReachesPrint, nodePrintConstraints, paginate, paperGeometryPx, parsePrintPolicy, printBlockForIntent, printByCellId, printPolicyToStyle, resolveDocumentProfile, resolvePlacement, resolveProfileId, resolveRegionBindings, resolveRunningValues, rowHasBlankPage, rowPageIntent, runningSlotValues, serializeConstraints, setRowBlankPage, setRowPageIntent, splitMarginalia, stalenessTolerancePx, viewportUnitsIn, withForcedBreaks };
1390
-
1391
- //# sourceMappingURL=print.js.map