@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/testing.js CHANGED
@@ -1,9 +1,9 @@
1
- import { c as prepareDocument } from "./chunks/query-BPuCJC1C.js";
2
- import { o as projectModule } from "./chunks/load-CjPvISzH.js";
3
- import { i as bundleScope } from "./chunks/refs-BLUokra5.js";
4
- import { n as pageBundles, t as pageBundleRefs } from "./chunks/page-bundles-DLRIBP8g.js";
1
+ import { l as prepareDocument } from "./chunks/query-D6xQbTFK.js";
2
+ import { o as projectModule } from "./chunks/load-b38vUiZM.js";
3
+ import { i as bundleScope } from "./chunks/refs-Csgh6rXq.js";
4
+ import { n as pageBundles, t as pageBundleRefs } from "./chunks/page-bundles-CPj_vx-J.js";
5
+ import { r as fromPageSteps } from "./chunks/forms-DxA9WzCt.js";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
- //#region \0rolldown/runtime.js
7
7
  var __defProp = Object.defineProperty;
8
8
  var __exportAll = (all, no_symbols) => {
9
9
  let target = {};
@@ -14,8 +14,6 @@ var __exportAll = (all, no_symbols) => {
14
14
  if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
15
15
  return target;
16
16
  };
17
- //#endregion
18
- //#region packages/renderer/src/testing/ids.ts
19
17
  var fixtureId = (n) => `00000000-0000-4000-8000-${String(n).padStart(12, "0")}`;
20
18
  var FIXTURE_ID = /^00000000-0000-4000-8000-\d{12}$/;
21
19
  var FIXTURE_ORG_SLUGS = ["example-client", "example-advisor"];
@@ -28,8 +26,6 @@ var ADVISOR_ORG = {
28
26
  id: fixtureId(2),
29
27
  slug: "example-advisor"
30
28
  };
31
- //#endregion
32
- //#region packages/renderer/src/testing/base-props.ts
33
29
  var FIXTURE_BASE_PROPS = {
34
30
  user: {
35
31
  id: fixtureId(3),
@@ -46,8 +42,6 @@ var FIXTURE_BASE_PROPS = {
46
42
  secondaryColor: "#c8a13a"
47
43
  }
48
44
  };
49
- //#endregion
50
- //#region packages/renderer/src/testing/components.tsx
51
45
  var components_exports = __exportAll({
52
46
  Badge: () => Badge,
53
47
  Boom: () => Boom,
@@ -182,8 +176,6 @@ var advisorKit = {
182
176
  }),
183
177
  Badge
184
178
  };
185
- //#endregion
186
- //#region packages/renderer/src/testing/golden.ts
187
179
  var bundle = (n, org, module, contracts) => ({
188
180
  row: {
189
181
  id: fixtureId(n),
@@ -829,8 +821,6 @@ var GOLDEN_PAGES = [
829
821
  mixedPage,
830
822
  walkPage
831
823
  ];
832
- //#endregion
833
- //#region packages/renderer/src/testing/sources.ts
834
824
  function goldenGraphSource(g) {
835
825
  const calls = [];
836
826
  const pick = (rows, systemId, ids) => (rows ?? []).filter((r) => r.system_id === systemId && ids.includes(r.graph_node_id));
@@ -942,7 +932,212 @@ function goldenBundles(g, cells, { loaded = true } = {}) {
942
932
  const modules = loaded ? rows.map((row) => projectModule(row, all.find((b) => b.row.id === row.id).golden.module, all.find((b) => b.row.id === row.id).golden.contracts)) : null;
943
933
  return pageBundles(scope, rows, modules, g.page.org_id);
944
934
  }
945
- //#endregion
946
- export { ADVISOR_ORG, CLIENT_ORG, FIXTURE_BASE_PROPS, FIXTURE_EMAIL_DOMAIN, FIXTURE_ID, FIXTURE_ORG_SLUGS, GOLDEN_PAGES, dashboardPage, documentPage, components_exports as fixtureComponents, fixtureId, goldenBundleRow, goldenBundles, goldenGraphSource, goldenScope, mixedPage, thinRefPage, walkPage };
947
-
948
- //# sourceMappingURL=testing.js.map
935
+ var form_workbook_page_default = {
936
+ id: "form-workbook",
937
+ name: "Planning workbook",
938
+ org_id: "example-advisor",
939
+ project_id: "example-project",
940
+ process_id: null,
941
+ graph_node_id: null,
942
+ page_type: "planning-workbook",
943
+ status: "published",
944
+ is_template: false,
945
+ metadata: null,
946
+ content: { "cells": [
947
+ {
948
+ "id": "welcome",
949
+ "component": "Prose",
950
+ "props": { "blocks": [{ "text": "This workbook takes about twenty minutes. Your answers save as you go." }] }
951
+ },
952
+ {
953
+ "id": "q-name",
954
+ "component": "ShortText",
955
+ "props": { "question": {
956
+ "key": "full_name",
957
+ "label": "Your full name",
958
+ "type": "text",
959
+ "required": true
960
+ } }
961
+ },
962
+ {
963
+ "id": "q-birth",
964
+ "component": "Date",
965
+ "props": { "question": {
966
+ "key": "birth_date",
967
+ "label": "Date of birth",
968
+ "type": "date",
969
+ "required": true
970
+ } }
971
+ },
972
+ {
973
+ "id": "q-children",
974
+ "component": "Choice",
975
+ "props": { "question": {
976
+ "key": "has_children",
977
+ "label": "Do you have children?",
978
+ "type": "radio",
979
+ "required": true,
980
+ "options": [{
981
+ "value": "yes",
982
+ "label": "Yes"
983
+ }, {
984
+ "value": "no",
985
+ "label": "No"
986
+ }]
987
+ } }
988
+ },
989
+ {
990
+ "id": "q-children-names",
991
+ "component": "LongText",
992
+ "props": { "question": {
993
+ "key": "children_names",
994
+ "label": "Their names",
995
+ "type": "textarea",
996
+ "required": true
997
+ } },
998
+ "when": { "all": [{
999
+ "q": "has_children",
1000
+ "op": "eq",
1001
+ "value": "yes"
1002
+ }] }
1003
+ },
1004
+ {
1005
+ "id": "q-guardians",
1006
+ "component": "LongText",
1007
+ "props": { "question": {
1008
+ "key": "guardians",
1009
+ "label": "Who would look after them?",
1010
+ "type": "textarea",
1011
+ "required": false
1012
+ } },
1013
+ "when": { "all": [{
1014
+ "q": "has_children",
1015
+ "op": "eq",
1016
+ "value": "yes"
1017
+ }] }
1018
+ },
1019
+ {
1020
+ "id": "draft",
1021
+ "component": "Prose",
1022
+ "props": { "blocks": [{ "text": "Read the draft clause before you answer the next questions." }] }
1023
+ },
1024
+ {
1025
+ "id": "q-executor",
1026
+ "component": "ShortText",
1027
+ "props": { "question": {
1028
+ "key": "executor",
1029
+ "label": "Who should be your executor?",
1030
+ "type": "text",
1031
+ "required": true
1032
+ } }
1033
+ },
1034
+ {
1035
+ "id": "upload",
1036
+ "component": "Upload",
1037
+ "props": { "question": {
1038
+ "key": "id_document",
1039
+ "label": "A photo of your ID",
1040
+ "type": "file",
1041
+ "required": false
1042
+ } }
1043
+ },
1044
+ {
1045
+ "id": "review",
1046
+ "component": "Review",
1047
+ "props": {}
1048
+ },
1049
+ {
1050
+ "id": "submit",
1051
+ "component": "SubmitButton",
1052
+ "props": {}
1053
+ }
1054
+ ] },
1055
+ layout: {
1056
+ "type": "flow",
1057
+ "chapters": [{
1058
+ "id": "about-you",
1059
+ "title": "About you"
1060
+ }, {
1061
+ "id": "your-plan",
1062
+ "title": "Your plan"
1063
+ }],
1064
+ "steps": [
1065
+ {
1066
+ "id": "welcome",
1067
+ "title": "Welcome",
1068
+ "chapter": "about-you",
1069
+ "cell_ids": ["welcome"]
1070
+ },
1071
+ {
1072
+ "id": "you",
1073
+ "title": "You",
1074
+ "chapter": "about-you",
1075
+ "cell_ids": ["q-name", "q-birth"]
1076
+ },
1077
+ {
1078
+ "id": "family",
1079
+ "title": "Your family",
1080
+ "chapter": "about-you",
1081
+ "cell_ids": [
1082
+ "q-children",
1083
+ "q-children-names",
1084
+ "q-guardians"
1085
+ ]
1086
+ },
1087
+ {
1088
+ "id": "executor",
1089
+ "title": "Your executor",
1090
+ "chapter": "your-plan",
1091
+ "cell_ids": ["draft", "q-executor"]
1092
+ },
1093
+ {
1094
+ "id": "documents",
1095
+ "title": "Documents",
1096
+ "chapter": "your-plan",
1097
+ "cell_ids": ["upload"]
1098
+ },
1099
+ {
1100
+ "id": "review",
1101
+ "title": "Review and submit",
1102
+ "chapter": "your-plan",
1103
+ "cell_ids": ["review", "submit"]
1104
+ }
1105
+ ],
1106
+ "submit": { "required": "warn" }
1107
+ }
1108
+ };
1109
+ var SINGLE_LINE = new Set([
1110
+ "text",
1111
+ "number",
1112
+ "date",
1113
+ "datetime",
1114
+ "email",
1115
+ "phone"
1116
+ ]);
1117
+ var KIND = {
1118
+ Prose: "content",
1119
+ Review: "review",
1120
+ Upload: "upload",
1121
+ SubmitButton: "other"
1122
+ };
1123
+ var formWorkbookPage = form_workbook_page_default;
1124
+ function formWorkbookItem(cellId) {
1125
+ const cell = form_workbook_page_default.content.cells.find((c) => c.id === cellId);
1126
+ if (!cell) return null;
1127
+ const q = cell.props.question;
1128
+ const kind = KIND[cell.component] ?? (q ? "question" : "other");
1129
+ return {
1130
+ id: cell.id,
1131
+ kind,
1132
+ questions: q ? [{
1133
+ key: q.key,
1134
+ label: q.label,
1135
+ required: q.required,
1136
+ singleLine: SINGLE_LINE.has(q.type),
1137
+ definition: { type: q.type }
1138
+ }] : [],
1139
+ ...cell.when ? { when: cell.when } : {}
1140
+ };
1141
+ }
1142
+ var formWorkbookModel = () => fromPageSteps(form_workbook_page_default, formWorkbookItem);
1143
+ export { ADVISOR_ORG, CLIENT_ORG, FIXTURE_BASE_PROPS, FIXTURE_EMAIL_DOMAIN, FIXTURE_ID, FIXTURE_ORG_SLUGS, GOLDEN_PAGES, dashboardPage, documentPage, components_exports as fixtureComponents, fixtureId, formWorkbookItem, formWorkbookModel, formWorkbookPage, goldenBundleRow, goldenBundles, goldenGraphSource, goldenScope, mixedPage, thinRefPage, walkPage };
package/dist/theme.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { SEMANTIC_TOKENS } from "@peripheries/runtime";
2
- //#region packages/renderer/src/theme/color.ts
3
2
  var NUMBER = /^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i;
4
3
  var clamp01 = (n) => Math.min(1, Math.max(0, n));
5
4
  function hexColor(value) {
@@ -199,8 +198,6 @@ function contrastRatio(foreground, background) {
199
198
  const b = relativeLuminance(bg);
200
199
  return (Math.max(a, b) + .05) / (Math.min(a, b) + .05);
201
200
  }
202
- //#endregion
203
- //#region packages/renderer/src/theme/parse.ts
204
201
  var SEMANTIC = new Set(SEMANTIC_TOKENS);
205
202
  var UNSAFE = /[<>{};\\]|\/\*|\*\/|[\u0000-\u001f\u007f]/;
206
203
  var isSafeCssValue = (value) => value.trim() !== "" && !UNSAFE.test(value);
@@ -381,8 +378,6 @@ function parseTheme(raw) {
381
378
  }
382
379
  return read;
383
380
  }
384
- //#endregion
385
- //#region packages/renderer/src/theme/derive.ts
386
381
  var FALLBACK_BASE = {
387
382
  "color-bg": "#ffffff",
388
383
  "color-text": "#0a0a0a"
@@ -505,8 +500,6 @@ function themeCss(theme, base) {
505
500
  const lines = Object.entries(themeTokens(theme, base)).filter(([name, value]) => /^[a-z0-9-]+$/.test(name) && typeof value === "string" && isSafeCssValue(value)).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([name, value]) => ` --${name}: ${value.trim()};`);
506
501
  return lines.length ? `@layer theme {\n :root {\n${lines.join("\n")}\n }\n}\n` : "";
507
502
  }
508
- //#endregion
509
- //#region packages/renderer/src/theme/check.ts
510
503
  var CONTRAST_PAIRS = [
511
504
  [
512
505
  "color-text",
@@ -603,7 +596,4 @@ function checkTheme(theme, base = {}) {
603
596
  }
604
597
  return diagnostics;
605
598
  }
606
- //#endregion
607
599
  export { CONTRAST_PAIRS, checkTheme, contrastRatio, fromOklch, parseColor, parseTheme, relativeLuminance, themeCss, themeTokens, toHex, toOklch };
608
-
609
- //# sourceMappingURL=theme.js.map
@@ -3,29 +3,16 @@ import type { Diagnostic } from '../core/graph.js';
3
3
  import type { ProjectPage } from '../core/types.js';
4
4
  import { type Catalog } from '../core/validate.js';
5
5
  export type CatalogInput = {
6
- /** `<org_slug>/<bundle_name>` of the bundle being emitted. */
7
6
  lineage: string;
8
7
  rows: KnowledgeRow[];
9
8
  links: KnowledgeLink[];
10
- /** This bundle's registry: every component it exports, with its props contract. */
11
9
  registry: Record<string, {
12
10
  props_schema?: unknown;
13
11
  }>;
14
- /** Components of other lineages in scope, which snippets may use (core, say). */
15
12
  scopeRegistry?: Record<string, {
16
13
  props_schema?: unknown;
17
14
  }>;
18
- /** Whether another lineage's row is live in scope; undefined leaves such links unchecked. */
19
15
  inScope?: (lineage: string, kind: KnowledgeKind, key: string) => boolean | undefined;
20
16
  };
21
17
  export declare function checkCatalog(input: CatalogInput): Diagnostic[];
22
- /**
23
- * PROP_INVALID: each literal prop value of the page's inline cells against its
24
- * prop's schema in the catalog. A value holding a reference is left alone; its
25
- * type is known only once it resolves. An `@each` projection is judged by its
26
- * `map` instead (design/renderer.md §5.4): its keys against the items schema
27
- * (a required key missing is PROP_INVALID, an undeclared one PROP_UNKNOWN),
28
- * and its literal values against theirs. Run it beside validatePage, which
29
- * can't (core holds no JSON Schema validator).
30
- */
31
18
  export declare function validatePageProps(page: Pick<ProjectPage, 'content'>, catalog: Catalog): Diagnostic[];
@@ -5,46 +5,22 @@ export type ActionDeclaration = string | {
5
5
  registry: string;
6
6
  entityKey?: string;
7
7
  };
8
- /** `registry#entityKey` when the action names an entity, else the registry key. */
9
8
  export declare const actionBindingKey: (registry: string, entityKey?: string) => string;
10
- /** A declaration's registry key, entity and binding key; null when it names no registry. */
11
9
  export declare function normalizeActionDeclaration(decl: unknown): {
12
10
  registry: string;
13
11
  entityKey?: string;
14
12
  bindingKey: string;
15
13
  } | null;
16
- /**
17
- * The cell's actions from the page's, by the PWA's lookup order: its binding
18
- * key, then its registry key, then the name the cell uses. Undefined when none match.
19
- */
20
14
  export declare function projectCellActions(declarations: Record<string, unknown> | undefined, pageActions: Record<string, CellAction> | undefined): Record<string, CellAction> | undefined;
21
- /**
22
- * What is wrong with a declared action, as messages: an unknown action, a
23
- * field it requires missing, a field it doesn't take, `append` without
24
- * exactly one of `patch` and `data` (append), `patch` or `name` (edit), a malformed reference, or a projection.
25
- */
26
15
  export declare function actionProblems(decl: GraphActionDeclaration): Array<{
27
16
  field?: string;
28
17
  message: string;
29
18
  }>;
30
- /** The references a declaration reads, by namespace or label (`input`, `period`…). */
31
19
  export declare function actionReferences(decl: GraphActionDeclaration): string[];
32
- /**
33
- * A declaration resolved for one call: the props resolver, with `@input` the
34
- * component's argument. A reference that resolves to nothing in a required
35
- * field makes it `INVALID`, so no write runs with a hole in it.
36
- */
37
20
  export declare function resolveAction(name: string, cellId: string, decl: GraphActionDeclaration, ctx: ResolutionContext, input: unknown): {
38
21
  action: ResolvedAction;
39
22
  } | {
40
23
  result: WriteResult;
41
24
  };
42
- /** Runs a resolved action as the viewer: the host's write path, or a harness's mock. Never throws. */
43
25
  export type RunAction = (action: ResolvedAction) => Promise<WriteResult>;
44
- /**
45
- * A cell's declared actions as the functions its component calls. Each
46
- * resolves its declaration against the cell's context and the call's input,
47
- * then hands it to `runAction`; a call never throws. Registry declarations
48
- * are left to `projectCellActions`.
49
- */
50
26
  export declare function declaredActions(cell: Pick<PageCell, 'id' | 'actions'>, ctx: ResolutionContext, runAction: RunAction | undefined): Record<string, CellAction> | undefined;
@@ -1,5 +1,4 @@
1
1
  import type { ComponentType } from 'react';
2
- /** A bundle row as the loader needs it. RLS decides which rows the viewer sees. */
3
2
  export type BundleRow = {
4
3
  id: string;
5
4
  org_id: string;
@@ -13,52 +12,30 @@ export type BundleRow = {
13
12
  component_name: string | null;
14
13
  exposed_export: string | null;
15
14
  }>;
16
- /** A shared lineage's specifier: the loader imports it by this, never by URL. */
17
15
  specifier?: string | null;
18
16
  };
19
17
  export type LoadedBundle = {
20
18
  id: string;
21
19
  label: string;
22
- /** Set for a shared lineage (`@stack/core`). */
23
20
  specifier?: string;
24
21
  components: Record<string, ComponentType<Record<string, unknown>>>;
25
- /** `contracts.json`: per-component @data / @action / @printPolicy / @size. */
26
22
  contracts: Record<string, unknown>;
27
23
  documentProfiles?: unknown;
28
24
  paginatorBindings?: unknown;
29
25
  };
30
- /** A function, forwardRef, memo or lazy export: something React can render. */
31
26
  export declare function isComponentExport(value: unknown): value is ComponentType<Record<string, unknown>>;
32
- /** Map registry rows (`exposed_export` → `component_name`) onto a module, and lift the bundle-level exports. */
33
27
  export declare function projectModule(row: BundleRow, mod: Record<string, unknown>, contracts?: Record<string, unknown>): LoadedBundle;
34
28
  export type BundleFiles = {
35
- /** A file of the bundle's version, or null when the row has no files. */
36
29
  url: (row: BundleRow, file: string) => string | null;
37
30
  import?: (url: string) => Promise<Record<string, unknown>>;
38
31
  fetch?: (url: string) => Promise<Response>;
39
32
  };
40
- /** Resolves once the host has installed its runtime (`@peripheries/renderer/runtime`'s installRuntime). */
41
33
  export declare function runtimeReady(g?: Record<string, unknown>): Promise<void>;
42
- /**
43
- * Load one bundle, once per bundle id (ids are immutable). Waits for the
44
- * shared runtime first, so the bundle's bare imports resolve to the host's.
45
- * A shared lineage is imported by its specifier, which the page's import map
46
- * points at its live version: dependents that import it get the same module
47
- * instance, and so the same React contexts (design/core-and-tokens.md §4).
48
- */
49
34
  export declare function loadBundle(row: BundleRow, files: BundleFiles): Promise<LoadedBundle>;
50
- /** What loading a page's bundles came to: the ones that imported, and the row ids of those that didn't. */
51
35
  export type LoadedBundles = {
52
36
  loaded: LoadedBundle[];
53
37
  failed: string[];
54
38
  };
55
- /**
56
- * Load every bundle in scope in parallel; a failure drops that bundle, not the
57
- * page, and is reported in `failed` so a host can show it and try again
58
- * rather than keep the partial set (shell audit S1).
59
- */
60
39
  export declare function loadBundlesSettled(rows: BundleRow[], files: BundleFiles): Promise<LoadedBundles>;
61
- /** Load every bundle in scope in parallel; a failure drops that bundle, not the page. */
62
40
  export declare function loadBundles(rows: BundleRow[], files: BundleFiles): Promise<LoadedBundle[]>;
63
- /** Test seam. */
64
41
  export declare function _clearBundleCache(): void;
@@ -1,19 +1,10 @@
1
1
  import type { PageCell } from '../types.js';
2
2
  import type { BundleRow, LoadedBundle } from './load.js';
3
3
  import { type LineageRef } from './refs.js';
4
- /** Every lineage the page and its cells reference: the scope, then any cell's own bundle_ref. */
5
4
  export declare function pageBundleRefs(scope: LineageRef[], cells: PageCell[], pageOrgId: string | null): LineageRef[];
6
- /** The bundles a page renders with: its scope, nearest first, and each cell's own bundle_ref. */
7
5
  export type PageBundles = {
8
- /** null while the bundles load (and always on the server). */
9
6
  scope: LoadedBundle[] | null;
10
7
  forCell: (cell: PageCell) => LoadedBundle | null;
11
- /** The rows couldn't be read, or a bundle didn't import: a cell without its component shows an error and a retry, not "not available". */
12
8
  failed: boolean;
13
9
  };
14
- /**
15
- * Match the loaded bundles to the page's scope and to cells' own refs. `rows`
16
- * are the bundle rows found for `pageBundleRefs(scope, …)`; `loaded` is null
17
- * until they have imported.
18
- */
19
10
  export declare function pageBundles(scope: LineageRef[], rows: BundleRow[], loaded: LoadedBundle[] | null, pageOrgId: string | null, failed?: boolean): PageBundles;
@@ -10,60 +10,33 @@ export type LineageRef = {
10
10
  } | {
11
11
  kind: 'pinned';
12
12
  bundleId: string;
13
- }
14
- /** A shared lineage (design/core-and-tokens.md §4), imported by its specifier. */
15
- | {
13
+ } | {
16
14
  kind: 'shared';
17
15
  specifier: string;
18
16
  orgSlug: string;
19
17
  bundle: string;
20
18
  };
21
- /** A row of `shared_lineage_live`, as the scope needs it. */
22
19
  export type SharedLineage = {
23
20
  specifier: string;
24
21
  org_slug: string;
25
22
  bundle_name: string;
26
23
  };
27
- /** The shared lineage `@core/Name` resolves from first. */
28
24
  export declare const CORE_SPECIFIER = "@stack/core";
29
25
  export declare const MAIN = "main";
30
26
  export declare const PUBLIC = "public";
31
- /**
32
- * Normalise a config ref. An org slug means that org's main lineage. A named
33
- * lineage without `org_slug` belongs to the page's org, so it needs `pageOrgId`;
34
- * without one it is dropped rather than guessed.
35
- */
36
27
  export declare function normalizeRef(ref: unknown, pageOrgId?: string | null): LineageRef | null;
37
28
  export declare const refKey: (r: LineageRef) => string;
38
- /** Where a page's bundles come from, nearest level first (cell refs are per cell). */
39
29
  export type BundleScopeInput = {
40
30
  pageOrgId?: string | null;
41
- /** `project_page.metadata.bundle_refs` */
42
31
  pageRefs?: unknown[] | null;
43
- /** `project_template.{org_id, bundle_name}` */
44
32
  projectTemplate?: {
45
33
  orgId: string;
46
34
  bundleName: string | null;
47
35
  } | null;
48
- /** The section's route entry `bundle_ref` (R3). */
49
36
  sectionRef?: unknown;
50
- /**
51
- * The orgs whose main lineages are fallbacks: the page's own org first, then
52
- * the org template's advisor org. Only the first comes before the shared
53
- * lineages.
54
- */
55
37
  orgs?: Array<{
56
38
  id: string;
57
39
  }>;
58
- /** `shared_lineage_live`: the shared lineages, after the page's own lineages. */
59
40
  shared?: readonly SharedLineage[];
60
41
  };
61
- /**
62
- * The ordered, de-duplicated lineage list for a page: page → project →
63
- * section → the page org's main → shared lineages → the advisor org's main
64
- * (design/core-and-tokens.md §3). The page's own lineages replace a shared
65
- * component by exporting the same name; the advisor's main only fills names
66
- * that neither they nor the shared lineages export, so an advisor org's
67
- * legacy copy of a core component never shadows core on a client's page.
68
- */
69
42
  export declare function bundleScope(input: BundleScopeInput): LineageRef[];
@@ -3,18 +3,8 @@ import type { LoadedBundle } from './load.js';
3
3
  export type CoreRegistry = Record<string, ComponentType<Record<string, unknown>>>;
4
4
  export type ResolvedComponent = {
5
5
  Component: ComponentType<Record<string, unknown>>;
6
- /** Which bundle supplied it, or 'core'. */
7
6
  source: string;
8
7
  };
9
- /**
10
- * One cascade (design/core.md §6, design/bundles.md §2, design/core-and-tokens.md §3):
11
- * - `@core/Name` comes from `stack/core`, then the host's registry;
12
- * - a cell with its own bundle_ref resolves from that bundle, then the host;
13
- * - otherwise the page's bundles, nearest level first (org lineages, then the
14
- * shared ones), then the host.
15
- * The nearest wins on a name collision: that is how an org lineage replaces a
16
- * shared component. `host:Name` is retired (renderer.md §10): no cell used it.
17
- */
18
8
  export declare function resolveComponent(name: string, { cellBundle, scope, core }: {
19
9
  cellBundle?: LoadedBundle | null;
20
10
  scope: LoadedBundle[];
@@ -4,22 +4,10 @@ export type CellStatus = {
4
4
  isError: boolean;
5
5
  errors?: Error[];
6
6
  };
7
- /**
8
- * A cell's own `data` prop (the PWA's projectDataBundle): its static values,
9
- * then each declared key read from the page context. Every declared key is
10
- * present, `undefined` while loading.
11
- */
12
7
  export declare function projectCellData(cell: PageCell, ctx: DataContext): {
13
8
  data: Record<string, unknown>;
14
9
  status: CellStatus;
15
10
  } | null;
16
- /**
17
- * The labels a cell reads whose query failed and left nothing (shell audit
18
- * S1): its declared data keys and the labels its props and conditions refer
19
- * to. A failed read must not render as an empty list. A query that never ran because a
20
- * reference resolved to nothing (a client-scoped read with no client in view, a page with no
21
- * data yet) hasn't failed: the cell renders without it, and the diagnostic says why.
22
- */
23
11
  export declare function failedLabels(cell: PageCell, data: DataContext): string[];
24
12
  export type AssembledInputs = {
25
13
  resolvedProps: Record<string, unknown>;
@@ -27,7 +15,6 @@ export type AssembledInputs = {
27
15
  baseProps: unknown;
28
16
  cellData: ReturnType<typeof projectCellData>;
29
17
  actions: Record<string, unknown> | undefined;
30
- /** Paged labels the cell reads (apps.md §6), each with hasMore and loadMore. */
31
18
  paging?: Record<string, {
32
19
  hasMore: boolean;
33
20
  isLoadingMore: boolean;
@@ -45,11 +32,4 @@ export type AssembledInputs = {
45
32
  context: Record<string, unknown>;
46
33
  renderComponent?: (key: string, props?: Record<string, unknown>) => unknown;
47
34
  };
48
- /**
49
- * The PWA's order (CellRenderer.tsx:973-989), so contract props win over
50
- * `cell.props`: props, children, isLoading / error, baseProps, data / status,
51
- * actions, the store bundles; then what's new here: size, navigate, context
52
- * (design/core.md §4). `isLoading` / `error` come from the cell's own data,
53
- * not, as in the PWA, from whichever page key came first.
54
- */
55
35
  export declare function assembleCellProps(i: AssembledInputs): Record<string, unknown>;
@@ -1,39 +1,18 @@
1
1
  import type { Diagnostic } from './graph.js';
2
2
  import type { PageCell } from './types.js';
3
- /** The config fields a thin ref took from its DSNS (the PWA's HYDRATED_CELL_FIELDS, which the agency's publish mirrors). */
4
3
  export declare const HYDRATED_CELL_FIELDS: readonly ["component", "props", "layout", "conditions", "children", "traversal", "data", "bundle_ref", "actions", "embed"];
5
- /** Also kept, unlike the PWA, whose hydration and publish dropped them (design/core.md §3). */
6
4
  export declare const STORE_FIELDS: readonly ["selections", "viewState", "live"];
7
- /** What a ref's node owns: everything but the cell's placement. A field its config sets wins, as a whole. */
8
5
  export declare const CONTENT_FIELDS: readonly [...("data" | "component" | "props" | "conditions" | "children" | "traversal" | "bundle_ref" | "actions" | "embed")[], "selections", "viewState", "live"];
9
- /** Where a rendered cell's content came from. */
10
6
  export type CellSource = 'inline' | 'node' | 'fallback' | 'pending';
11
- /** A cell as the renderer reads it: its content resolved, `graph_node_id` its own node (if any). */
12
7
  export type ResolvedCell = PageCell & {
13
8
  source: CellSource;
14
9
  };
15
- /**
16
- * The one place the authored forms are read (design/renderer.md §3.1):
17
- * 1 inline; 2 inline with a `ref`; 3 `{ id, graph_node_id }` (legacy thin ref,
18
- * read as 2); 4 inline with a `graph_node_id` (legacy, read as 1, walking
19
- * from that node). Legacy forms are reported, so their use can be counted.
20
- */
21
10
  export declare function normalizeCell(cell: PageCell, path?: string): {
22
11
  cell: PageCell;
23
12
  diagnostics: Diagnostic[];
24
13
  };
25
- /** Whether a (normalized) cell's content is managed by a node. */
26
14
  export declare const hasRef: (cell: PageCell) => cell is PageCell & {
27
15
  ref: NonNullable<PageCell["ref"]>;
28
16
  };
29
- /**
30
- * A normalized cell with its node's `page_cell_config` (design/renderer.md §3.2):
31
- * - the node owns the content (CONTENT_FIELDS): a field the config sets wins;
32
- * - the page owns the placement: `id`, and `layout` when the entry has one;
33
- * - `name` from the entry if it has one; `metadata` merged, entry then config;
34
- * - no config: the entry renders as it is when it names a component
35
- * (`fallback`), else the cell is `pending`.
36
- */
37
17
  export declare function resolveCell(cell: PageCell, config: Record<string, unknown> | null | undefined): ResolvedCell;
38
- /** Cells no other cell lists in `children`: what a flat page renders, in content order. */
39
18
  export declare function rootCells<T extends PageCell>(cells: T[]): T[];