@peripheries/renderer 0.1.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.
Files changed (57) hide show
  1. package/README.md +65 -0
  2. package/dist/chunks/create-store-CglsI7tw.js +90 -0
  3. package/dist/chunks/create-store-CglsI7tw.js.map +1 -0
  4. package/dist/chunks/load-6zEgvJ6I.js +60 -0
  5. package/dist/chunks/load-6zEgvJ6I.js.map +1 -0
  6. package/dist/chunks/page-bundles-C4VW3dsK.js +87 -0
  7. package/dist/chunks/page-bundles-C4VW3dsK.js.map +1 -0
  8. package/dist/chunks/projection-Dsy9ruj8.js +592 -0
  9. package/dist/chunks/projection-Dsy9ruj8.js.map +1 -0
  10. package/dist/core.js +740 -0
  11. package/dist/core.js.map +1 -0
  12. package/dist/react.js +357 -0
  13. package/dist/react.js.map +1 -0
  14. package/dist/runtime.js +91 -0
  15. package/dist/runtime.js.map +1 -0
  16. package/dist/styles.css +51 -0
  17. package/dist/testing.js +944 -0
  18. package/dist/testing.js.map +1 -0
  19. package/dist/types/core/bundles/load.d.ts +49 -0
  20. package/dist/types/core/bundles/page-bundles.d.ts +17 -0
  21. package/dist/types/core/bundles/refs.d.ts +41 -0
  22. package/dist/types/core/bundles/resolve.d.ts +25 -0
  23. package/dist/types/core/cell-props.d.ts +39 -0
  24. package/dist/types/core/cells.d.ts +39 -0
  25. package/dist/types/core/data-context.d.ts +38 -0
  26. package/dist/types/core/graph.d.ts +95 -0
  27. package/dist/types/core/index.d.ts +19 -0
  28. package/dist/types/core/layout.d.ts +12 -0
  29. package/dist/types/core/load-page.d.ts +72 -0
  30. package/dist/types/core/references.d.ts +43 -0
  31. package/dist/types/core/store/create-store.d.ts +26 -0
  32. package/dist/types/core/store/persistence.d.ts +9 -0
  33. package/dist/types/core/store/projection.d.ts +15 -0
  34. package/dist/types/core/store/scope-keys.d.ts +10 -0
  35. package/dist/types/core/store/types.d.ts +37 -0
  36. package/dist/types/core/structure.d.ts +72 -0
  37. package/dist/types/core/types.d.ts +30 -0
  38. package/dist/types/core/validate.d.ts +14 -0
  39. package/dist/types/react/cell-states.d.ts +25 -0
  40. package/dist/types/react/cell-view.d.ts +31 -0
  41. package/dist/types/react/index.d.ts +6 -0
  42. package/dist/types/react/page-renderer.d.ts +30 -0
  43. package/dist/types/react/structure-view.d.ts +30 -0
  44. package/dist/types/react/use-cell-store.d.ts +13 -0
  45. package/dist/types/react/use-container-size.d.ts +11 -0
  46. package/dist/types/runtime/boot.d.ts +7 -0
  47. package/dist/types/runtime/index.d.ts +4 -0
  48. package/dist/types/runtime/install.d.ts +21 -0
  49. package/dist/types/runtime/shims.d.ts +11 -0
  50. package/dist/types/runtime/store-export.d.ts +18 -0
  51. package/dist/types/testing/base-props.d.ts +3 -0
  52. package/dist/types/testing/components.d.ts +51 -0
  53. package/dist/types/testing/golden.d.ts +51 -0
  54. package/dist/types/testing/ids.d.ts +14 -0
  55. package/dist/types/testing/index.d.ts +5 -0
  56. package/dist/types/testing/sources.d.ts +25 -0
  57. package/package.json +51 -0
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # @peripheries/renderer
2
+
3
+ The one renderer for pages built from federated component bundles
4
+ ([design/renderer.md](../../docs/plan/design/renderer.md)). The host, the
5
+ component repos' harness and the agency's preview all render through it, so a
6
+ page looks the same in each.
7
+
8
+ | Entry | Holds |
9
+ |---|---|
10
+ | `@peripheries/renderer/core` | Framework-free: cells and thin-ref hydration, references and conditions, the data context, walks and state names, cell props, layout, document structure, bundle refs and resolution, the shared store, and `loadPageData(page, source)` |
11
+ | `@peripheries/renderer/react` | `PageRenderer`, `CellView`, `StructureView`, the cell states, `useContainerSize` |
12
+ | `@peripheries/renderer/runtime` | What a page boots with: the import map and boot script, the shims, `installRuntime`, the store bundles import |
13
+ | `@peripheries/renderer/testing` | The golden pages, synthetic fixtures, and sources that serve them |
14
+ | `@peripheries/renderer/styles.css` | Page and cell containers, the responsive buckets, placeholders and notices |
15
+
16
+ **A consumer supplies:**
17
+ - a `GraphSource` for the page's reads (the host's runs GraphQL under the
18
+ viewer's JWT; fixtures in `/testing`);
19
+ - its bundles, as `PageBundles` (`pageBundles(scope, rows, loaded, orgId)`);
20
+ - a `RendererEnvironment`: core components, `navigate`, the store, and where
21
+ diagnostics go.
22
+
23
+ ```tsx
24
+ const runtime = await loadPageData(page, source)
25
+ <PageRenderer runtime={runtime} bundles={bundles} params={params} baseProps={baseProps} context={context} environment={environment} />
26
+ ```
27
+
28
+ ## Validation
29
+
30
+ `validatePage(page, catalog?)` and `validateCell(cell, catalog?)` return
31
+ diagnostics, `{ severity, code, message, path?, cellId?, label? }`, with
32
+ `severity` one of `error`, `warning` or `legacy` (a form still read, on its way
33
+ out). `loadPageData` runs `validatePage` and adds what loading finds. Given a
34
+ catalog (`{ components: { [name]: { props_schema } } }`) it also checks that
35
+ components exist and required props are given (`schema.required` only). For a
36
+ node-managed cell those are warnings, since the page's copy is only a fallback.
37
+
38
+ | Code | Severity | Meaning |
39
+ |---|---|---|
40
+ | `CELL_NO_ID`, `CELL_DUPLICATE_ID` | error | a cell without an id, or two with one |
41
+ | `CELL_NO_COMPONENT` | error | an inline cell names no component |
42
+ | `CELL_UNKNOWN_COMPONENT`, `PROP_REQUIRED` | error (warning on a ref cell) | against the catalog |
43
+ | `CELL_UNKNOWN_CHILD`, `CELL_CHILD_CYCLE` | error | `children` names a missing cell, or itself |
44
+ | `REF_INVALID` | error | a `ref` without a `graph_node_id` |
45
+ | `REF_FALLBACK` | warning | the ref's node has no config the viewer can read; the page's copy renders |
46
+ | `LEGACY_THIN_REF`, `LEGACY_INLINE_NODE` | legacy | `{ id, graph_node_id }`; an inline cell with a `graph_node_id` |
47
+ | `BINDING_INVALID` | error | a declaration that names no node, or a bad `as` |
48
+ | `UNSUPPORTED_REGISTRY_BINDING` | warning | a registry binding, which the host no longer runs |
49
+ | `STATE_UNKNOWN_NAME`, `STATE_UNKNOWN_SYSTEM` | error | a state name that isn't one, or a system the process lacks |
50
+ | `WALK_EDGE_TYPES_REQUIRED`, `WALK_BAD_DIRECTION` | error | a walk that can't run |
51
+ | `WALK_MAX_NODES_CLAMPED`, `WALK_TRUNCATED`, `WALK_NO_START` | warning | a walk capped, cut short, or with nowhere to start |
52
+ | `WALK_FAILED` | error | the source failed the walk |
53
+ | `BINDING_DUPLICATE_KEY` | error | two reached nodes share a `binding_key`; it binds nothing |
54
+ | `STORE_INVALID` | error | a store declaration without its channel or key, or a bad scope |
55
+ | `LAYOUT_INVALID` | warning | a responsive bucket that isn't narrow, compact or wide |
56
+ | `STRUCTURE_INVALID`, `PAGE_INVALID` | error | a structure naming missing cells or unknown kinds; cells not a list |
57
+
58
+ `core` imports no React at runtime and never reaches the network, and the
59
+ package never imports the host (`npm run lint:deps`). Tests sit next to the
60
+ code; the golden pages run over fixture sources in `react/golden-pages.test.tsx`.
61
+
62
+ **Publishing:** `npm run publish:packages` (and `--dry-run`) builds and
63
+ publishes every package whose version isn't on npm yet, built output only;
64
+ `.github/workflows/publish-packages.yml` runs it on `develop`. Bump the version
65
+ here to release (design/renderer.md §11).
@@ -0,0 +1,90 @@
1
+ import { Store } from "@tanstack/store";
2
+ //#region packages/renderer/src/core/store/create-store.ts
3
+ function createStackStore(initial) {
4
+ const store = new Store({
5
+ selections: {},
6
+ viewState: {},
7
+ live: {},
8
+ ...initial
9
+ });
10
+ const actions = {
11
+ setSelection: (scope, channel, value) => store.setState((s) => ({
12
+ ...s,
13
+ selections: {
14
+ ...s.selections,
15
+ [scope]: {
16
+ ...s.selections[scope],
17
+ [channel]: value
18
+ }
19
+ }
20
+ })),
21
+ setViewState: (scope, key, value) => store.setState((s) => ({
22
+ ...s,
23
+ viewState: {
24
+ ...s.viewState,
25
+ [scope]: {
26
+ ...s.viewState[scope],
27
+ [key]: value
28
+ }
29
+ }
30
+ })),
31
+ _setLive: (channel, entry) => store.setState((s) => ({
32
+ ...s,
33
+ live: {
34
+ ...s.live,
35
+ [channel]: entry
36
+ }
37
+ })),
38
+ _hydrateScope: (scope, { selections, viewState }) => store.setState((s) => ({
39
+ ...s,
40
+ selections: selections && Object.keys(selections).length ? {
41
+ ...s.selections,
42
+ [scope]: {
43
+ ...selections,
44
+ ...s.selections[scope]
45
+ }
46
+ } : s.selections,
47
+ viewState: viewState && Object.keys(viewState).length ? {
48
+ ...s.viewState,
49
+ [scope]: {
50
+ ...viewState,
51
+ ...s.viewState[scope]
52
+ }
53
+ } : s.viewState
54
+ })),
55
+ _snapshotScope: (scope) => ({
56
+ selections: store.state.selections[scope] ?? {},
57
+ viewState: store.state.viewState[scope] ?? {}
58
+ }),
59
+ _clearScope: (scope) => store.setState((s) => {
60
+ if (!(scope in s.selections) && !(scope in s.viewState)) return s;
61
+ const { [scope]: _sel, ...selections } = s.selections;
62
+ const { [scope]: _view, ...viewState } = s.viewState;
63
+ return {
64
+ ...s,
65
+ selections,
66
+ viewState
67
+ };
68
+ })
69
+ };
70
+ const withActions = new WeakMap();
71
+ const getState = () => {
72
+ const data = store.state;
73
+ let full = withActions.get(data);
74
+ if (!full) withActions.set(data, full = {
75
+ ...data,
76
+ ...actions
77
+ });
78
+ return full;
79
+ };
80
+ return {
81
+ store,
82
+ ...actions,
83
+ getState,
84
+ subscribe: (listener) => store.subscribe(() => listener(getState()))
85
+ };
86
+ }
87
+ //#endregion
88
+ export { createStackStore as t };
89
+
90
+ //# sourceMappingURL=create-store-CglsI7tw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-store-CglsI7tw.js","names":[],"sources":["../../src/core/store/create-store.ts"],"mappings":";;AAWA,SAAgB,iBAAiB,SAAmC;CAClE,MAAM,QAAQ,IAAI,MAAsB;EAAE,YAAY,CAAC;EAAG,WAAW,CAAC;EAAG,MAAM,CAAC;EAAG,GAAG;CAAQ,CAAC;CAE/F,MAAM,UAA6B;EACjC,eAAe,OAAO,SAAS,UAC7B,MAAM,UAAU,OAAO;GAAE,GAAG;GAAG,YAAY;IAAE,GAAG,EAAE;KAAa,QAAQ;KAAE,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AAI,MAAO,OAAO;GAAE,GAAG;GAAM,GAAG;EAAQ,CAAE;EACjE,OAAO;CACT;CAEA,OAAO;EAEL;EACA,GAAG;EACH;EACA,YAAY,aAA+C,MAAM,gBAAgB,SAAS,SAAS,CAAC,CAAC;CACvG;AACF"}
@@ -0,0 +1,60 @@
1
+ import { READY_GLOBAL } from "@peripheries/runtime";
2
+ //#region packages/renderer/src/core/bundles/load.ts
3
+ function isComponentExport(value) {
4
+ if (typeof value === "function") return true;
5
+ if (!value || typeof value !== "object") return false;
6
+ const tag = value.$$typeof;
7
+ return tag === Symbol.for("react.forward_ref") || tag === Symbol.for("react.memo") || tag === Symbol.for("react.lazy");
8
+ }
9
+ function projectModule(row, mod, contracts = {}) {
10
+ const components = {};
11
+ for (const c of row.components) {
12
+ const exported = mod[c.exposed_export ?? c.component_name ?? ""];
13
+ if (c.component_name && isComponentExport(exported)) components[c.component_name] = exported;
14
+ }
15
+ return {
16
+ id: row.id,
17
+ label: row.bundle_name === "main" ? row.org_slug : `${row.org_slug}/${row.bundle_name}`,
18
+ components,
19
+ contracts,
20
+ ThemeProvider: isComponentExport(mod.ThemeProvider) ? mod.ThemeProvider : void 0,
21
+ documentProfiles: mod.documentProfiles,
22
+ paginatorBindings: mod.PAGINATOR_BINDINGS
23
+ };
24
+ }
25
+ function runtimeReady(g = globalThis) {
26
+ return g[READY_GLOBAL] ?? Promise.resolve();
27
+ }
28
+ var cache = new Map();
29
+ var browserImport = (url) => import(url);
30
+ function loadBundle(row, files) {
31
+ let pending = cache.get(row.id);
32
+ if (!pending) {
33
+ pending = (async () => {
34
+ const url = files.url(row, "index.js");
35
+ if (!url) throw new Error(`[bundles] ${row.org_slug}/${row.bundle_name} has no storage path`);
36
+ await runtimeReady();
37
+ const contractsUrl = files.url(row, "contracts.json");
38
+ const get = files.fetch ?? ((u) => fetch(u));
39
+ const [mod, contracts] = await Promise.all([(files.import ?? browserImport)(url), get(contractsUrl).then((r) => r.ok ? r.json() : null, () => null)]);
40
+ return projectModule(row, mod, contracts?.components ?? {});
41
+ })();
42
+ pending.catch(() => cache.delete(row.id));
43
+ cache.set(row.id, pending);
44
+ }
45
+ return pending;
46
+ }
47
+ async function loadBundles(rows, files) {
48
+ return (await Promise.allSettled(rows.map((r) => loadBundle(r, files)))).flatMap((s, i) => {
49
+ if (s.status === "fulfilled") return [s.value];
50
+ console.warn(`[bundles] ${rows[i].org_slug}/${rows[i].bundle_name} failed to load:`, s.reason);
51
+ return [];
52
+ });
53
+ }
54
+ function _clearBundleCache() {
55
+ cache.clear();
56
+ }
57
+ //#endregion
58
+ export { projectModule as a, loadBundles as i, isComponentExport as n, runtimeReady as o, loadBundle as r, _clearBundleCache as t };
59
+
60
+ //# sourceMappingURL=load-6zEgvJ6I.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-6zEgvJ6I.js","names":[],"sources":["../../src/core/bundles/load.ts"],"mappings":";;AAkCA,SAAgB,kBAAkB,OAAiE;CACjG,IAAI,OAAO,UAAU,YAAY,OAAO;CACxC,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAChD,MAAM,MAAO,MAAgC;CAC7C,OAAO,QAAQ,OAAO,IAAI,mBAAmB,KAAK,QAAQ,OAAO,IAAI,YAAY,KAAK,QAAQ,OAAO,IAAI,YAAY;AACvH;AAGA,SAAgB,cAAc,KAAgB,KAA8B,YAAqC,CAAC,GAAiB;CACjI,MAAM,aAAyC,CAAC;CAChD,KAAK,MAAM,KAAK,IAAI,YAAY;EAC9B,MAAM,WAAW,IAAI,EAAE,kBAAkB,EAAE,kBAAkB;EAC7D,IAAI,EAAE,kBAAkB,kBAAkB,QAAQ,GAAG,WAAW,EAAE,kBAAkB;CACtF;CACA,OAAO;EACL,IAAI,IAAI;EACR,OAAO,IAAI,gBAAgB,SAAS,IAAI,WAAW,GAAG,IAAI,SAAS,GAAG,IAAI;EAC1E;EACA;EACA,eAAe,kBAAkB,IAAI,aAAa,IAAK,IAAI,gBAAkD,KAAA;EAC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F,OAAO,CAAC;CACV,CAAC;AACH;AAGA,SAAgB,oBAAoB;CAClC,MAAM,MAAM;AACd"}
@@ -0,0 +1,87 @@
1
+ //#region packages/renderer/src/core/bundles/refs.ts
2
+ var MAIN = "main";
3
+ var PUBLIC = "public";
4
+ function normalizeRef(ref, pageOrgId) {
5
+ if (typeof ref === "string") return ref ? {
6
+ kind: "lineage",
7
+ orgSlug: ref,
8
+ bundle: MAIN
9
+ } : null;
10
+ if (!ref || typeof ref !== "object") return null;
11
+ const r = ref;
12
+ if (typeof r.bundle_id === "string" && r.bundle_id) return {
13
+ kind: "pinned",
14
+ bundleId: r.bundle_id
15
+ };
16
+ if (typeof r.bundle === "string" && r.bundle) {
17
+ if (typeof r.org_slug === "string" && r.org_slug) return {
18
+ kind: "lineage",
19
+ orgSlug: r.org_slug,
20
+ bundle: r.bundle
21
+ };
22
+ return pageOrgId ? {
23
+ kind: "lineage-in-org",
24
+ orgId: pageOrgId,
25
+ bundle: r.bundle
26
+ } : null;
27
+ }
28
+ return null;
29
+ }
30
+ var refKey = (r) => r.kind === "pinned" ? `id:${r.bundleId}` : r.kind === "lineage" ? `slug:${r.orgSlug}/${r.bundle}` : `org:${r.orgId}/${r.bundle}`;
31
+ function bundleScope(input) {
32
+ const out = [];
33
+ const seen = new Set();
34
+ const push = (r) => {
35
+ if (r && !seen.has(refKey(r))) {
36
+ seen.add(refKey(r));
37
+ out.push(r);
38
+ }
39
+ };
40
+ for (const ref of input.pageRefs ?? []) push(normalizeRef(ref, input.pageOrgId));
41
+ const pt = input.projectTemplate;
42
+ if (pt?.bundleName) push({
43
+ kind: "lineage-in-org",
44
+ orgId: pt.orgId,
45
+ bundle: pt.bundleName
46
+ });
47
+ push(normalizeRef(input.sectionRef, input.pageOrgId));
48
+ for (const org of input.orgs ?? []) push({
49
+ kind: "lineage-in-org",
50
+ orgId: org.id,
51
+ bundle: MAIN
52
+ });
53
+ return out;
54
+ }
55
+ //#endregion
56
+ //#region packages/renderer/src/core/bundles/page-bundles.ts
57
+ function pageBundleRefs(scope, cells, pageOrgId) {
58
+ const out = [...scope];
59
+ const seen = new Set(out.map(refKey));
60
+ for (const c of cells) {
61
+ const r = c.bundle_ref ? normalizeRef(c.bundle_ref, pageOrgId) : null;
62
+ if (r && !seen.has(refKey(r))) {
63
+ seen.add(refKey(r));
64
+ out.push(r);
65
+ }
66
+ }
67
+ return out;
68
+ }
69
+ function rowMatches(ref, row) {
70
+ if (ref.kind === "pinned") return row.id === ref.bundleId;
71
+ return row.bundle_name === ref.bundle && (ref.kind === "lineage" ? row.org_slug === ref.orgSlug : row.org_id === ref.orgId);
72
+ }
73
+ function pageBundles(scope, rows, loaded, pageOrgId) {
74
+ const byRow = new Map((loaded ?? []).map((b) => [b.id, b]));
75
+ return {
76
+ scope: loaded ? rows.filter((row) => scope.some((r) => rowMatches(r, row))).flatMap((row) => byRow.get(row.id) ?? []) : null,
77
+ forCell: (cell) => {
78
+ const ref = normalizeRef(cell.bundle_ref, pageOrgId);
79
+ const row = ref && rows.find((r) => rowMatches(ref, r));
80
+ return (row && byRow.get(row.id)) ?? null;
81
+ }
82
+ };
83
+ }
84
+ //#endregion
85
+ export { bundleScope as a, PUBLIC as i, pageBundles as n, normalizeRef as o, MAIN as r, refKey as s, pageBundleRefs as t };
86
+
87
+ //# sourceMappingURL=page-bundles-C4VW3dsK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-bundles-C4VW3dsK.js","names":[],"sources":["../../src/core/bundles/refs.ts","../../src/core/bundles/page-bundles.ts"],"mappings":";AAYA,IAAa,OAAO;AACpB,IAAa,SAAS;AAOtB,SAAgB,aAAa,KAAc,WAA8C;CACvF,IAAI,OAAO,QAAQ,UAAU,OAAO,MAAM;EAAE,MAAM;EAAW,SAAS;EAAK,QAAQ;CAAK,IAAI;CAC5F,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,OAAO;CAC5C,MAAM,IAAI;CACV,IAAI,OAAO,EAAE,cAAc,YAAY,EAAE,WA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