@peripheries/renderer 0.26.0 → 0.27.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.
package/README.md CHANGED
@@ -83,7 +83,9 @@ bundle's `ThemeProvider` export.
83
83
 
84
84
  ## Versions
85
85
 
86
- - **Unreleased:** `RENDER_FUNCTIONS` adds `pages_awaiting_release(p_project_id)`:
86
+ - **Unreleased:** `RENDER_FUNCTIONS` adds `advisor_add_allowed(p_org_id)`: whether the viewer may
87
+ add advisors (a bare Boolean; bind it with `result.path: 'advisor_add_allowed'`). It also adds
88
+ `pages_awaiting_release(p_project_id)`:
87
89
  a project's pages whose newest main page-state is newer than the one their
88
90
  client channel's release holds, for staff (an empty array for anyone else).
89
91
  - **Removable in the next minor:** `GraphSource.processSystems` (the process's cached system
package/dist/catalog.js CHANGED
@@ -1,5 +1,5 @@
1
- import { x as isEach } from "./chunks/query-CNaB25jE.js";
2
- import { a as eachFormProblems, c as validatePage, i as componentsFor } from "./chunks/validate-DRkCpQaY.js";
1
+ import { x as isEach } from "./chunks/query-DOXxGTO2.js";
2
+ import { a as eachFormProblems, c as validatePage, i as componentsFor } from "./chunks/validate-y5_6ws0s.js";
3
3
  import { KNOWLEDGE_BUDGETS, KNOWLEDGE_KEY } from "@peripheries/runtime";
4
4
  import Ajv2020 from "ajv/dist/2020.js";
5
5
  var ref = (kind, key) => `${kind}:${key}`;
@@ -43,15 +43,51 @@ function loadBundle(row, files) {
43
43
  }
44
44
  return pending;
45
45
  }
46
+ var escapeRe = (v) => v.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
47
+ async function sharedDependencies(rows, files) {
48
+ const get = files.fetch ?? ((u) => fetch(u));
49
+ const bySpecifier = new Map(rows.map((r) => [r.specifier, r.id]));
50
+ const deps = new Map();
51
+ try {
52
+ await Promise.all(rows.map(async (r) => {
53
+ if (r.requires) return void deps.set(r.id, r.requires.map((s) => bySpecifier.get(s)).filter((id) => !!id && id !== r.id));
54
+ const url = files.url(r, "index.js");
55
+ const res = url ? await get(url) : null;
56
+ if (!res?.ok) throw new Error("unreadable");
57
+ const source = await res.text();
58
+ deps.set(r.id, rows.filter((o) => o.id !== r.id && new RegExp(`(?:from|import)\\s*\\(?\\s*(["'\`])${escapeRe(o.specifier)}\\1`).test(source)).map((o) => o.id));
59
+ }));
60
+ } catch {
61
+ return null;
62
+ }
63
+ return deps;
64
+ }
65
+ async function loadWaves(rows, files) {
66
+ const shared = rows.filter((r) => r.specifier);
67
+ const rest = rows.filter((r) => !r.specifier);
68
+ const waves = [];
69
+ const deps = shared.length > 1 ? await sharedDependencies(shared, files) : null;
70
+ if (!deps) return [rows];
71
+ const done = new Set();
72
+ let left = shared;
73
+ while (left.length) {
74
+ const wave = left.filter((r) => (deps.get(r.id) ?? []).every((d) => done.has(d)));
75
+ if (!wave.length) return [rows];
76
+ waves.push(wave);
77
+ wave.forEach((r) => done.add(r.id));
78
+ left = left.filter((r) => !done.has(r.id));
79
+ }
80
+ if (rest.length) waves.push(rest);
81
+ return waves;
82
+ }
46
83
  async function loadBundlesSettled(rows, files) {
47
- const settled = await Promise.allSettled(rows.map((r) => loadBundle(r, files)));
48
84
  const loaded = [];
49
85
  const failed = [];
50
- settled.forEach((s, i) => {
86
+ for (const wave of await loadWaves(rows, files)) (await Promise.allSettled(wave.map((r) => loadBundle(r, files)))).forEach((s, i) => {
51
87
  if (s.status === "fulfilled") loaded.push(s.value);
52
88
  else {
53
- failed.push(rows[i].id);
54
- console.warn(`[bundles] ${rows[i].org_slug}/${rows[i].bundle_name} failed to load:`, s.reason);
89
+ failed.push(wave[i].id);
90
+ console.warn(`[bundles] ${wave[i].org_slug}/${wave[i].bundle_name} failed to load:`, s.reason);
55
91
  }
56
92
  });
57
93
  return {
@@ -417,6 +417,12 @@ var RENDER_FUNCTIONS = {
417
417
  "graph_edge",
418
418
  "graph_node",
419
419
  "node"
420
+ ],
421
+ advisor_add_allowed: [
422
+ "advisor",
423
+ "organization",
424
+ "org_member",
425
+ "client"
420
426
  ]
421
427
  };
422
428
  var RENDER_FUNCTIONS_AHEAD = { form_answers: "SCH M3b" };
@@ -1,4 +1,4 @@
1
- import { T as settled, w as resolveReferences, x as isEach } from "./query-CNaB25jE.js";
1
+ import { T as settled, w as resolveReferences, x as isEach } from "./query-DOXxGTO2.js";
2
2
  import { ACTION_FIELDS, ACTION_KINDS, SECTION_KINDS as SECTION_KINDS$1, isGraphAction } from "@peripheries/runtime";
3
3
  var actionBindingKey = (registry, entityKey) => entityKey ? `${registry}#${entityKey}` : registry;
4
4
  function normalizeActionDeclaration(decl) {
@@ -1,5 +1,5 @@
1
- import { _ as EACH, h as variableLabels, m as validateDescriptor, o as descriptorShape, p as shapeAt, v as EACH_DEFAULT_AS, x as isEach } from "./query-CNaB25jE.js";
2
- import { S as actionProblems, b as isHostRead, g as usesStructureLayout, m as structureIssues, y as hostReadProblem } from "./structure-B3ikc0oD.js";
1
+ import { _ as EACH, h as variableLabels, m as validateDescriptor, o as descriptorShape, p as shapeAt, v as EACH_DEFAULT_AS, x as isEach } from "./query-DOXxGTO2.js";
2
+ import { S as actionProblems, b as isHostRead, g as usesStructureLayout, m as structureIssues, y as hostReadProblem } from "./structure-B1PsD-AJ.js";
3
3
  import { DEFAULT_STATE, STATE_NAMES, WALK_DEFAULTS, isDescriptorBinding, isGraphAction, isStateName } from "@peripheries/runtime";
4
4
  var TIER_OF_GRAPH_TYPE = {
5
5
  "meta-process": "meta",
package/dist/core.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { C as HYDRATED_CELL_FIELDS, D as normalizeCell, E as hasRef, O as resolveCell, S as CONTENT_FIELDS, T as STORE_FIELDS, a as projectSelections, b as isEmptyPropValue, c as pageScopeKey, d as resolveComponent, f as cellAttributes, g as assembleCellProps, h as pageContainerStyle, i as projectLive, k as rootCells, 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 hiddenWhenEmpty, w as RENDER_FIELDS, x as projectCellData, y as hideWhenEmptyProblem } from "./chunks/projection-e8MHn6Bt.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-CNaB25jE.js";
3
- import { S as walkRequest, _ as stateNames, a as eachFormProblems, b as systemsFromProcess, c as validatePage, d as mergeStates, f as needsWalk, g as resolveWalkStart, h as referencedLabels, i as componentsFor, l as selectionIssues, m as readWalk, n as STORE_SCOPES, o as nearestNames, p as readField, r as WALK_DIRECTIONS, s as validateCell, t as RESPONSIVE_BUCKETS, u as RESERVED_LABELS, v as stateValue, x as walkKey, y as systemsFromGraphs } from "./chunks/validate-DRkCpQaY.js";
4
- import { C as actionReferences, D as resolveAction, E as projectCellActions, S as actionProblems, T as normalizeActionDeclaration, _ as HOST_READ_KEY, a as deriveSectionReferences, b as isHostRead, 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 bindHostReads, w as declaredActions, x as actionBindingKey, y as hostReadProblem } from "./chunks/structure-B3ikc0oD.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";
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-DOXxGTO2.js";
3
+ import { S as walkRequest, _ as stateNames, a as eachFormProblems, b as systemsFromProcess, c as validatePage, d as mergeStates, f as needsWalk, g as resolveWalkStart, h as referencedLabels, i as componentsFor, l as selectionIssues, m as readWalk, n as STORE_SCOPES, o as nearestNames, p as readField, r as WALK_DIRECTIONS, s as validateCell, t as RESPONSIVE_BUCKETS, u as RESERVED_LABELS, v as stateValue, x as walkKey, y as systemsFromGraphs } from "./chunks/validate-y5_6ws0s.js";
4
+ import { C as actionReferences, D as resolveAction, E as projectCellActions, S as actionProblems, T as normalizeActionDeclaration, _ as HOST_READ_KEY, a as deriveSectionReferences, b as isHostRead, 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 bindHostReads, w as declaredActions, x as actionBindingKey, y as hostReadProblem } from "./chunks/structure-B1PsD-AJ.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-H7hUCwPc.js";
6
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
7
  import { i as rowsInScope, n as pageBundles, r as rowForCell, t as pageBundleRefs } from "./chunks/page-bundles-_wsGO9WU.js";
8
8
  import { a as createStackStore, i as saveScope, n as clearScope, r as loadScope } from "./chunks/persistence-hurkUUQ0.js";
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { _ as failedLabels, a as projectSelections, d as resolveComponent, f as cellAttributes, g as assembleCellProps, h as pageContainerStyle, i as projectLive, k as rootCells, m as documentProfile, n as attachViewStateSetters, o as projectViewState, p as cellPlacementStyle, s as shallowEqualBundle, t as attachSelectionSetters, u as resolveScopeId, v as hiddenWhenEmpty, x as projectCellData, y as hideWhenEmptyProblem } from "./chunks/projection-e8MHn6Bt.js";
2
- import { C as passesConditions, S as pageContext, T as settled, b as cellResolutionContext, c as pageVariables, v as EACH_DEFAULT_AS, w as resolveReferences, y as cellContext } from "./chunks/query-CNaB25jE.js";
3
- import { a as deriveSectionReferences, c as nodePrintStyle, d as referencesFor, f as sectionAnchor, g as usesStructureLayout, i as deriveSectionNumbering, l as normalizeStructure, m as structureIssues, o as isSectionNode, p as sortByOrder, r as deriveElementReferences, s as mergeSectionReferences, t as PAGE_DOCUMENT, u as numberingFor, v as bindHostReads, w as declaredActions } from "./chunks/structure-B3ikc0oD.js";
2
+ import { C as passesConditions, S as pageContext, T as settled, b as cellResolutionContext, c as pageVariables, v as EACH_DEFAULT_AS, w as resolveReferences, y as cellContext } from "./chunks/query-DOXxGTO2.js";
3
+ import { a as deriveSectionReferences, c as nodePrintStyle, d as referencesFor, f as sectionAnchor, g as usesStructureLayout, i as deriveSectionNumbering, l as normalizeStructure, m as structureIssues, o as isSectionNode, p as sortByOrder, r as deriveElementReferences, s as mergeSectionReferences, t as PAGE_DOCUMENT, u as numberingFor, v as bindHostReads, w as declaredActions } from "./chunks/structure-B1PsD-AJ.js";
4
4
  import { a as goToQuestion, c as missing, 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, s as linkTo, t as defaultMode, u as positionFromLink } from "./chunks/forms-DxA9WzCt.js";
5
5
  import { Component, Fragment, Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
6
6
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -252,6 +252,14 @@ function boundProps(cell, ctx, env, injectedProps) {
252
252
  ...env.cellProps?.(cell)
253
253
  };
254
254
  }
255
+ var reportedMissing = new Set();
256
+ function reportMissing(component) {
257
+ if (!reportedMissing.has(component)) {
258
+ reportedMissing.add(component);
259
+ console.warn(`[render] no bundle holds the component "${component}"`);
260
+ }
261
+ return null;
262
+ }
255
263
  function CellView({ cell, env, nested = false, injectedProps }) {
256
264
  const frame = useRef(null);
257
265
  const store = useCellStore(cell, env.scope, env.store);
@@ -370,7 +378,7 @@ function CellView({ cell, env, nested = false, injectedProps }) {
370
378
  else if (!resolved) body = jsxs(CellNotice, {
371
379
  state: "not-found",
372
380
  component: cell.component,
373
- children: [cell.component, " isn't available here."]
381
+ children: [reportMissing(cell.component), "This section isn't available right now."]
374
382
  });
375
383
  else {
376
384
  const slotted = {};
package/dist/runtime.js CHANGED
@@ -1,4 +1,4 @@
1
- import { s as runtimeReady } from "./chunks/load-b38vUiZM.js";
1
+ import { s as runtimeReady } from "./chunks/load-H7hUCwPc.js";
2
2
  import { a as createStackStore, t as clearAllScopes } from "./chunks/persistence-hurkUUQ0.js";
3
3
  import { PINNED_RUNTIMES, READY_GLOBAL, RESOLVE_GLOBAL, RUNTIME_GLOBAL, buildImportMap } from "@peripheries/runtime";
4
4
  import * as React from "react";
package/dist/testing.js CHANGED
@@ -1,5 +1,5 @@
1
- import { l as prepareDocument } from "./chunks/query-CNaB25jE.js";
2
- import { o as projectModule } from "./chunks/load-b38vUiZM.js";
1
+ import { l as prepareDocument } from "./chunks/query-DOXxGTO2.js";
2
+ import { o as projectModule } from "./chunks/load-H7hUCwPc.js";
3
3
  import { i as bundleScope } from "./chunks/refs-Csgh6rXq.js";
4
4
  import { n as pageBundles, t as pageBundleRefs } from "./chunks/page-bundles-_wsGO9WU.js";
5
5
  import { r as fromPageSteps } from "./chunks/forms-DxA9WzCt.js";
@@ -13,6 +13,7 @@ export type BundleRow = {
13
13
  exposed_export: string | null;
14
14
  }>;
15
15
  specifier?: string | null;
16
+ requires?: readonly string[] | null;
16
17
  };
17
18
  export type LoadedBundle = {
18
19
  id: string;
@@ -36,6 +37,7 @@ export type LoadedBundles = {
36
37
  loaded: LoadedBundle[];
37
38
  failed: string[];
38
39
  };
40
+ export declare function loadWaves(rows: BundleRow[], files: BundleFiles): Promise<BundleRow[][]>;
39
41
  export declare function loadBundlesSettled(rows: BundleRow[], files: BundleFiles): Promise<LoadedBundles>;
40
42
  export declare function loadBundles(rows: BundleRow[], files: BundleFiles): Promise<LoadedBundle[]>;
41
43
  export declare function _clearBundleCache(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peripheries/renderer",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "The one renderer for pages of federated component bundles: a framework-free core, a React renderer, the runtime a page boots with, and golden pages for testing.",
5
5
  "type": "module",
6
6
  "sideEffects": [