@phis/ui 0.6.11 → 0.7.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 (84) hide show
  1. package/components/cms/phi-cms-area-render-scope.d.ts +2 -0
  2. package/components/cms/phi-cms-area-render-scope.js +1 -1
  3. package/components/cms/phi-cms-error-page.js +1 -1
  4. package/components/cms/phi-cms-page-render-scope.d.ts +0 -1
  5. package/components/cms/phi-cms-page-render-scope.js +1 -1
  6. package/components/cms/phi-cms-root-layout.js +1 -0
  7. package/components/cms/phi-cms-runtime-registry.d.ts +4 -4
  8. package/components/cms/phi-cms-runtime-registry.js +4 -4
  9. package/components/widgets/label-sets/region.js +2 -0
  10. package/components/widgets/label-types/region.d.ts +2 -0
  11. package/components/widgets/label-types/region.js +1 -0
  12. package/components/widgets/label-types/revisions.js +2 -2
  13. package/components/workspace/catalog-state.d.ts +17 -1
  14. package/components/workspace/catalog-store.js +1 -0
  15. package/gateway/dashboard-cards-route.js +4 -9
  16. package/gateway/form-handler-resolution.js +10 -34
  17. package/gateway/navigation-target-route.js +4 -10
  18. package/gateway/page-references-route.js +3 -8
  19. package/gateway/site-area.d.ts +43 -6
  20. package/gateway/site-area.js +70 -17
  21. package/helpers/cms-area-config.d.ts +36 -14
  22. package/helpers/cms-area-config.js +72 -26
  23. package/next/seo-routes.js +24 -28
  24. package/package.json +2 -2
  25. package/plugins/runtime-modules/accounting/presets.d.ts +0 -1
  26. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-area-preset-tree.js +0 -2
  27. package/plugins/runtime-modules/admin/presets.d.ts +0 -1
  28. package/plugins/runtime-modules/admin/trees/phi-default-admin-area-preset-tree.js +0 -2
  29. package/plugins/runtime-modules/app/presets.d.ts +0 -1
  30. package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.js +0 -2
  31. package/plugins/runtime-modules/area-definitions.d.ts +17 -0
  32. package/plugins/runtime-modules/area-definitions.js +6 -0
  33. package/plugins/runtime-modules/builder/area-shell-presets.server.d.ts +21 -5
  34. package/plugins/runtime-modules/builder/area-shell-presets.server.js +171 -63
  35. package/plugins/runtime-modules/builder/clients/shells-workspace.js +12 -1
  36. package/plugins/runtime-modules/builder/controller/client.js +2 -0
  37. package/plugins/runtime-modules/builder/controller/definition.d.ts +1 -0
  38. package/plugins/runtime-modules/builder/controller/draft-command-controller.d.ts +2 -3
  39. package/plugins/runtime-modules/builder/controller/draft-command-controller.js +56 -25
  40. package/plugins/runtime-modules/builder/controller/draft-status-controller.js +13 -7
  41. package/plugins/runtime-modules/builder/controller/server-definition.d.ts +1 -0
  42. package/plugins/runtime-modules/builder/controller/server-definition.js +7 -4
  43. package/plugins/runtime-modules/builder/controller/workspace-controller.d.ts +2 -1
  44. package/plugins/runtime-modules/builder/controller/workspace-controller.js +9 -3
  45. package/plugins/runtime-modules/builder/data-providers.d.ts +1 -1
  46. package/plugins/runtime-modules/builder/definition.d.ts +1 -1
  47. package/plugins/runtime-modules/builder/developer-workspace-store.js +1 -0
  48. package/plugins/runtime-modules/builder/page-preset-catalog.server.d.ts +0 -2
  49. package/plugins/runtime-modules/builder/page-preset-catalog.server.js +0 -16
  50. package/plugins/runtime-modules/builder/persistence.d.ts +20 -25
  51. package/plugins/runtime-modules/builder/persistence.js +67 -75
  52. package/plugins/runtime-modules/builder/services/runtime-modules-table.d.ts +17 -0
  53. package/plugins/runtime-modules/builder/services/runtime-modules-table.js +79 -2
  54. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.d.ts +0 -1
  55. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +0 -2
  56. package/plugins/runtime-modules/builder/workspace-catalog-actions.d.ts +2 -1
  57. package/plugins/runtime-modules/builder/workspace-catalog-actions.js +3 -1
  58. package/plugins/runtime-modules/core/widgets/cascader/authoring.d.ts +1 -1
  59. package/plugins/runtime-modules/descriptor-compiler.d.ts +16 -2
  60. package/plugins/runtime-modules/descriptor-compiler.js +69 -13
  61. package/plugins/runtime-modules/editor/services/releases-table.js +26 -14
  62. package/plugins/runtime-modules/editor/trees/phi-default-editor-area-preset-tree.js +0 -2
  63. package/plugins/runtime-modules/groups/definition.d.ts +1 -1
  64. package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +0 -2
  65. package/plugins/runtime-modules/revisions/controller/client.js +13 -7
  66. package/plugins/runtime-modules/revisions/services/table.js +10 -3
  67. package/plugins/runtime-modules/shell-tree-composition.d.ts +0 -2
  68. package/plugins/runtime-modules/shell-tree-composition.js +0 -3
  69. package/server-helpers/area-root-door-warmup.d.ts +5 -2
  70. package/server-helpers/area-root-door-warmup.js +2 -10
  71. package/server-helpers/cms-area.d.ts +9 -1
  72. package/server-helpers/cms-area.js +16 -11
  73. package/server-helpers/cms-lookup.js +1 -1
  74. package/server-helpers/cms-request.d.ts +58 -13
  75. package/server-helpers/cms-request.js +103 -33
  76. package/server-helpers/cms-root.d.ts +4 -0
  77. package/server-helpers/cms-root.js +48 -35
  78. package/server-helpers/cms.d.ts +5 -5
  79. package/server-helpers/public-login-route.js +4 -9
  80. package/server-helpers/search-index.js +9 -14
  81. package/styles/shell.css +12 -0
  82. package/types/cms-module-descriptors.d.ts +26 -1
  83. package/types/cms-plugins.d.ts +3 -0
  84. package/types/cms.d.ts +10 -3
@@ -8,7 +8,7 @@ import { canPhiViewerAccess, PHI_VIEWER_ACCESS_ANYONE, } from "../../types/acces
8
8
  import { mergePhiCmsShellTrees, omitPhiCmsShellCompositionNodes, } from "./shell-tree-composition";
9
9
  import { resolvePhiRuntimeModuleAreaRoutePath } from "../../helpers/runtime-module-route-path";
10
10
  import { createPhiPageReference } from "../../types/references";
11
- import { choosePhiAreaRootApplicant, orderPhiAreaPathClaimsByCover, isPhiAssignablePublicRoutePath, } from "../../helpers/cms-area-config";
11
+ import { choosePhiAreaRootApplicant, describePhiAreaShellSettingsError, orderPhiAreaPathClaimsByCover, isPhiAssignablePublicRoutePath, } from "../../helpers/cms-area-config";
12
12
  import { resolvePhiLayoutCreationPreset } from "../../helpers/cms-layout-defaults";
13
13
  import { PHI_DIALOG_BLEED_BODY_CONFIG, PHI_DIALOG_BODY_CONFIG, PHI_DIALOG_COMMANDS_CONFIG, PHI_DIALOG_WIDTH, isPhiFormSingleColumn, } from "../../helpers/cms-dialog";
14
14
  import { PhiCmsWidgetType } from "../../constants/cms-widget-types";
@@ -198,6 +198,13 @@ function assertAreaDefinitions(areaDefinitions, catalog) {
198
198
  throw new Error(`Area "${definition.area}" base owner "${definition.baseModuleId}" must be a module contribution.`);
199
199
  }
200
200
  normalizeRequiredKey(definition.shellPresetKey, `${definition.area} shell preset key`);
201
+ if (definition.shellProviders !== "base" && definition.shellProviders !== "module") {
202
+ throw new Error(`Area "${definition.area}" must say who brings its shell ("base" or "module").`);
203
+ }
204
+ // The Builder repairs a broken shell; a shell a Module brought could lock the Site out of it.
205
+ if (definition.area === "builder" && definition.shellProviders !== "base") {
206
+ throw new Error('Area "builder" takes its shell from its base Module only.');
207
+ }
201
208
  const navKeys = new Set();
202
209
  for (const surface of definition.navigationSurfaces ?? []) {
203
210
  if (surface.navKey !== surface.navKey.trim().toLowerCase()) {
@@ -249,7 +256,8 @@ function assertAreaDefinitions(areaDefinitions, catalog) {
249
256
  }
250
257
  export function compilePhiCmsDescriptorCatalog({ catalog, areaDefinitions, }) {
251
258
  const definitionsByArea = assertAreaDefinitions(areaDefinitions, catalog);
252
- const areaShellByArea = new Map();
259
+ const areaBaseShellByArea = new Map();
260
+ const areaShellProvidersByArea = new Map();
253
261
  const areaShellByIdentity = new Map();
254
262
  const areaOverlaysByArea = new Map();
255
263
  const routeByIdentity = new Map();
@@ -285,6 +293,10 @@ export function compilePhiCmsDescriptorCatalog({ catalog, areaDefinitions, }) {
285
293
  throw new Error(`${moduleId}: shell preset "${descriptor.presetKey}" has a different owner.`);
286
294
  }
287
295
  assertPositiveVersion(descriptor.shellPresetVersion, `${moduleId}/${descriptor.presetKey} shellPresetVersion`);
296
+ const settingsError = describePhiAreaShellSettingsError(descriptor.settings);
297
+ if (settingsError) {
298
+ throw new Error(`${moduleId}/${descriptor.presetKey}: ${settingsError}.`);
299
+ }
288
300
  const areaDefinition = definitionsByArea.get(descriptor.area);
289
301
  if (!areaDefinition) {
290
302
  throw new Error(`${moduleId}/${descriptor.presetKey}: Area "${descriptor.area}" is not declared.`);
@@ -292,16 +304,35 @@ export function compilePhiCmsDescriptorCatalog({ catalog, areaDefinitions, }) {
292
304
  if (!entry.definition.eligibleAreas.includes(descriptor.area)) {
293
305
  throw new Error(`${moduleId}/${descriptor.presetKey}: owner module is not eligible for Area "${descriptor.area}".`);
294
306
  }
295
- if (areaDefinition.baseModuleId !== moduleId ||
296
- areaDefinition.shellPresetKey !== descriptor.presetKey) {
297
- throw new Error(`${moduleId}/${descriptor.presetKey}: shell preset does not match Area "${descriptor.area}" base definition.`);
307
+ if (areaDefinition.baseModuleId === moduleId) {
308
+ if (areaDefinition.shellPresetKey !== descriptor.presetKey) {
309
+ throw new Error(`${moduleId}/${descriptor.presetKey}: shell preset does not match Area "${descriptor.area}" base definition.`);
310
+ }
311
+ const identity = registerIdentity(descriptor.presetKey);
312
+ if (areaBaseShellByArea.has(descriptor.area)) {
313
+ throw new Error(`Area "${descriptor.area}" has more than one shell preset.`);
314
+ }
315
+ const binding = { descriptor };
316
+ areaBaseShellByArea.set(descriptor.area, binding);
317
+ areaShellByIdentity.set(identity, binding);
318
+ continue;
319
+ }
320
+ /*
321
+ * Another Module's shell for the Area: allowed only where the Area's definition takes one, and kept
322
+ * apart from the base shell. It stands in for the base while its Module is active there
323
+ * (`resolvePhiCmsAreaShellPresetBinding`); being installed changes nothing.
324
+ */
325
+ if (areaDefinition.shellProviders !== "module") {
326
+ throw new Error(`${moduleId}/${descriptor.presetKey}: Area "${descriptor.area}" takes its shell from its base Module only.`);
298
327
  }
299
328
  const identity = registerIdentity(descriptor.presetKey);
300
- if (areaShellByArea.has(descriptor.area)) {
301
- throw new Error(`Area "${descriptor.area}" has more than one shell preset.`);
329
+ const providers = areaShellProvidersByArea.get(descriptor.area) ?? new Map();
330
+ if (providers.has(moduleId)) {
331
+ throw new Error(`${moduleId}: more than one shell preset for Area "${descriptor.area}".`);
302
332
  }
303
- const binding = { descriptor };
304
- areaShellByArea.set(descriptor.area, binding);
333
+ const binding = { descriptor, moduleId };
334
+ providers.set(moduleId, binding);
335
+ areaShellProvidersByArea.set(descriptor.area, providers);
305
336
  areaShellByIdentity.set(identity, binding);
306
337
  }
307
338
  for (const descriptor of entry.areaOverlays ?? []) {
@@ -357,7 +388,7 @@ export function compilePhiCmsDescriptorCatalog({ catalog, areaDefinitions, }) {
357
388
  registerPhiCmsThemeDescriptors({ moduleId, themes: entry.themes, themeBlocks: entry.themeBlocks }, registerIdentity, { themeByKey, themeBlockByKey });
358
389
  }
359
390
  for (const [area, definition] of definitionsByArea) {
360
- if (!areaShellByArea.has(area)) {
391
+ if (!areaBaseShellByArea.has(area)) {
361
392
  throw new Error(`Area "${area}" is missing shell preset "${definition.baseModuleId}/${definition.shellPresetKey}".`);
362
393
  }
363
394
  }
@@ -627,7 +658,8 @@ export function compilePhiCmsDescriptorCatalog({ catalog, areaDefinitions, }) {
627
658
  }
628
659
  return {
629
660
  areaDefinitions: definitionsByArea,
630
- areaShellByArea,
661
+ areaBaseShellByArea,
662
+ areaShellProvidersByArea,
631
663
  areaShellByIdentity,
632
664
  areaOverlaysByArea,
633
665
  moduleNavigationByArea,
@@ -1399,8 +1431,32 @@ export function resolvePhiCmsRoutePresetByPageId(table, pageId) {
1399
1431
  const descriptor = table.byPageId.get(pageId);
1400
1432
  return descriptor ? { descriptor, params: {} } : null;
1401
1433
  }
1402
- export function resolvePhiCmsAreaShellPresetBinding(catalog, area) {
1403
- return catalog.areaShellByArea.get(area) ?? null;
1434
+ /** The shell of the Area's base Module, whatever the Area runs: what it takes while no active Module brings one. */
1435
+ export function resolvePhiCmsAreaBaseShellPresetBinding(catalog, area) {
1436
+ return catalog.areaBaseShellByArea.get(area) ?? null;
1437
+ }
1438
+ /** The shells optional Modules bring for the Area, active or not. */
1439
+ export function listPhiCmsAreaShellProviders(catalog, area) {
1440
+ return [...(catalog.areaShellProvidersByArea.get(area)?.values() ?? [])];
1441
+ }
1442
+ /**
1443
+ * The Area's effective shell: the shell of the one active Module that brings one, otherwise the base
1444
+ * shell. The active Modules are the Area's selection as `resolveActivePresetModuleKeys` reads it, so a
1445
+ * provider that is installed but not selected -- or selected but off for want of its server half --
1446
+ * changes nothing.
1447
+ *
1448
+ * Two active providers is a selection the Builder refuses to make (one provider per Area); a stored one
1449
+ * that holds two anyway is refused here rather than settled by catalog order, which would hand the
1450
+ * Area to whichever package happened to be listed first.
1451
+ */
1452
+ export function resolvePhiCmsAreaShellPresetBinding(catalog, area, activeModuleIds) {
1453
+ const active = listPhiCmsAreaShellProviders(catalog, area)
1454
+ .filter((binding) => activeModuleIds.has(binding.moduleId));
1455
+ if (active.length > 1) {
1456
+ throw new Error(`Area "${area}" has more than one active Module that brings its shell: ` +
1457
+ `${active.map((binding) => binding.moduleId).join(", ")}. Switch all but one off.`);
1458
+ }
1459
+ return active[0] ?? resolvePhiCmsAreaBaseShellPresetBinding(catalog, area);
1404
1460
  }
1405
1461
  export function resolvePhiCmsRoutePresetByIdentity(catalog, ownerModuleId, presetKey) {
1406
1462
  return catalog.routeByIdentity.get(buildPhiCmsPresetIdentityKey(ownerModuleId, presetKey)) ?? null;
@@ -91,20 +91,21 @@ function toReleaseRow(item) {
91
91
  reject: null,
92
92
  };
93
93
  }
94
- case "area":
95
- return {
96
- id: `area:${String(item.area)}:${String(item.part)}`,
97
- kind: "area",
98
- what: String(item.part ?? ""),
99
- where: String(item.area ?? ""),
100
- by: readPerson(item.savedBy),
101
- at: item.savedAt,
102
- // The Area's publish names the Shell preset it stands on; a draft without one has nothing to name.
103
- publishable: Boolean(readText(item.ownerModuleId) && readText(item.presetKey)),
104
- rejectable: false,
105
- publish: readText(item.ownerModuleId) && readText(item.presetKey)
94
+ case "area": {
95
+ /*
96
+ * A structure's publish names the Shell preset it stands on; a structure draft without one has
97
+ * nothing to name. A Module selection names no shell and is published by its Area alone.
98
+ */
99
+ const modules = item.part === "modules";
100
+ const publish = modules
101
+ ? {
102
+ path: "/api/site/cms/area/modules/publish",
103
+ method: "POST",
104
+ body: { area: item.area, revisionId: item.revisionId },
105
+ }
106
+ : readText(item.ownerModuleId) && readText(item.presetKey)
106
107
  ? {
107
- path: item.part === "modules" ? "/api/site/cms/area/modules/publish" : "/api/site/cms/area/publish",
108
+ path: "/api/site/cms/area/publish",
108
109
  method: "POST",
109
110
  body: {
110
111
  area: item.area,
@@ -113,9 +114,20 @@ function toReleaseRow(item) {
113
114
  presetKey: item.presetKey,
114
115
  },
115
116
  }
116
- : null,
117
+ : null;
118
+ return {
119
+ id: `area:${String(item.area)}:${String(item.part)}`,
120
+ kind: "area",
121
+ what: String(item.part ?? ""),
122
+ where: String(item.area ?? ""),
123
+ by: readPerson(item.savedBy),
124
+ at: item.savedAt,
125
+ publishable: publish != null,
126
+ rejectable: false,
127
+ publish,
117
128
  reject: null,
118
129
  };
130
+ }
119
131
  default:
120
132
  return null;
121
133
  }
@@ -2,7 +2,6 @@ import { createPhiPresetCmsInstanceIdMap } from "../../../../types/cms-instance-
2
2
  import { PHI_EDITOR_RUNTIME_MODULE_ID } from "../ids";
3
3
  import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
4
4
  import { buildPhiAreaShellHeaderNodes, buildPhiAreaShellSiderLeftNodes, concatPhiAreaShellPresetNodes, } from "../../../../components/regions/presets/phi-area-shell-preset-nodes";
5
- import { createPhiDefaultAreaRuntimeModuleIds } from "../../area-module-defaults";
6
5
  const SYNTHETIC_EDITOR_REGION_IDS = {
7
6
  regionHeaderTop: -140,
8
7
  regionSiderLeft: -150,
@@ -31,7 +30,6 @@ export async function buildPhiDefaultEditorAreaPresetTree({ page, runtime, }) {
31
30
  const ids = { ...SYNTHETIC_EDITOR_REGION_IDS, ...SYNTHETIC_EDITOR_LAYOUT_IDS, ...SYNTHETIC_EDITOR_WIDGET_IDS };
32
31
  return {
33
32
  page,
34
- runtimeModuleIds: createPhiDefaultAreaRuntimeModuleIds("editor"),
35
33
  overlays: [],
36
34
  ...concatPhiAreaShellPresetNodes(buildPhiAreaShellHeaderNodes({ nodes, runtime, labelPrefix: "editor", ids }), buildPhiAreaShellSiderLeftNodes({
37
35
  nodes,
@@ -250,7 +250,7 @@ export declare const PHI_GROUPS_RUNTIME_MODULE_DEFINITION: {
250
250
  iconFamily: string;
251
251
  mediaSpaces: {
252
252
  group: {
253
- kinds: ("image" | "video" | "markdown" | "audio" | "pdf" | "document" | "archive")[];
253
+ kinds: ("image" | "video" | "markdown" | "document" | "audio" | "pdf" | "archive")[];
254
254
  };
255
255
  };
256
256
  threadKinds: ("group" | "crossGroup")[];
@@ -11,7 +11,6 @@ import { createPhiCmsPresetNodes } from "../../helpers/cms-preset-nodes";
11
11
  import { resolvePhiShellHeaderHeight, resolvePhiShellMetric } from "../../helpers/shell-region-style";
12
12
  import { resolvePhiLayoutCreationPreset } from "../../helpers/cms-layout-defaults";
13
13
  import { PHI_DEFAULT_PUB_AREA_PRESET } from "./pub-area-preset";
14
- import { createPhiDefaultAreaRuntimeModuleIds } from "./area-module-defaults";
15
14
  import { PHI_DEFAULT_PUB_AREA_LAYOUT_NODE_KEYS, PHI_DEFAULT_PUB_AREA_WIDGET_NODE_KEYS, } from "./preset-contracts/pub-area";
16
15
  const SYNTHETIC_REGION_IDS = {
17
16
  regionHeaderMain: -2,
@@ -70,7 +69,6 @@ export async function buildPhiDefaultSiteAreaPresetTree({ page, runtime, presetK
70
69
  const nodes = createPhiCmsPresetNodes(page);
71
70
  return {
72
71
  page,
73
- runtimeModuleIds: createPhiDefaultAreaRuntimeModuleIds(runtimeModuleArea),
74
72
  overlays: [],
75
73
  regions: [
76
74
  ...(headerMainRegion
@@ -66,14 +66,20 @@ function PhiRevisionsControllerMount({ address, config, }) {
66
66
  persistedPageCatalogByArea,
67
67
  ]);
68
68
  /*
69
- * Deletes the Area's own shell, then asks the workspace for everything again.
69
+ * Deletes the Area's own structure, then asks the workspace for everything again. Its Module selection
70
+ * is stored apart and stays.
70
71
  *
71
- * What stands afterwards is the Module preset, and this client holds none of it -- not the Regions,
72
- * not the root route, not the SEO answers. Every one of them is now a value only the server knows.
72
+ * What stands afterwards is the preset of the shell the Area takes, and this client holds none of it
73
+ * -- not the Regions, not the root route, not the SEO answers. Every one of them is now a value only the
74
+ * server knows. The identity named is the one the stored structure stands on, which need not be the
75
+ * shell the Area takes now: a structure of the base shell outlives switching on a Module that brings
76
+ * its own.
73
77
  */
74
78
  const deleteAreaShell = useCallback(async (area, correlationId) => {
75
- const source = getPhiWorkspaceCatalogSnapshot()
76
- .areaPresetSourcesByArea?.[area] ?? null;
79
+ const catalog = getPhiWorkspaceCatalogSnapshot();
80
+ const source = catalog.areaShellsByArea?.[area]?.storedSource
81
+ ?? catalog.areaPresetSourcesByArea?.[area]
82
+ ?? null;
77
83
  try {
78
84
  await deleteCmsDraft("/api/site/cms/area/override", {
79
85
  area,
@@ -82,7 +88,7 @@ function PhiRevisionsControllerMount({ address, config, }) {
82
88
  });
83
89
  emitCapability("deleteAreaClose", null, correlationId);
84
90
  emitCapability("historyReload", null, correlationId);
85
- showMessage({ level: "success", content: `Cleared ${area} back to its preset.` });
91
+ showMessage({ level: "success", content: `Cleared the ${area} structure back to its preset. Its Modules are kept.` });
86
92
  router.refresh();
87
93
  }
88
94
  catch (error) {
@@ -115,7 +121,7 @@ function PhiRevisionsControllerMount({ address, config, }) {
115
121
  * pointed at when it is pressed.
116
122
  */
117
123
  const area = getPhiWorkspaceCatalogSnapshot().area;
118
- emitCapability("deleteAreaWarning", `Everything this Site stored for ${area} is cleared -- its Shell and its Module selection, drafts and published alike. What is live changes at once, the Module preset takes the Area back, and no revision is left to restore it from. It cannot be undone.`, signal.correlationId);
124
+ emitCapability("deleteAreaWarning", `The structure this Site stored for ${area} is cleared -- its Shell, drafts and published alike. What is live changes at once, the shell's preset takes the Area back, and no revision is left to restore it from. It cannot be undone. The Module selection is kept.`, signal.correlationId);
119
125
  emitCapability("deleteAreaOpen", null, signal.correlationId);
120
126
  return;
121
127
  }
@@ -346,10 +346,17 @@ function buildRevisionReviewHref(params, row) {
346
346
  }
347
347
  function buildTableData(params, result) {
348
348
  const rows = result.rows.map((row, index) => {
349
- const isPublished = row.isPublished || result.current.publishedRevisionId === row.revisionId;
349
+ /*
350
+ * An Area's history holds its structure revisions and its Modules revisions side by side. A Modules
351
+ * revision names no preset (`sourcePreset` null) and is published or drafted by its own pointers,
352
+ * which the row states; `current` speaks of the structure only, so it says nothing about such a row.
353
+ */
354
+ const isAreaModulesRevision = params.scope.kind === "area" && !row.sourcePreset;
355
+ const isPublished = row.isPublished || (!isAreaModulesRevision && result.current.publishedRevisionId === row.revisionId);
350
356
  const isWorkingDraft = row.isWorkingDraft ||
351
- result.current.workingDraftRevisionId === row.revisionId ||
352
- (result.current.workingDraftRevisionId == null &&
357
+ (!isAreaModulesRevision && result.current.workingDraftRevisionId === row.revisionId) ||
358
+ (!isAreaModulesRevision &&
359
+ result.current.workingDraftRevisionId == null &&
353
360
  index === 0 &&
354
361
  !isPublished);
355
362
  const revisionTags = [
@@ -92,12 +92,10 @@ export declare function omitPhiCmsShellCompositionNodes(tree: PhiResolvedCmsPage
92
92
  resolvedContent?: import("../../types").PhiCmsResolvedContent | null;
93
93
  }[];
94
94
  pageMeta?: import("../../types").PhiCmsResolvedPageMeta | null;
95
- runtimeModuleIds?: import("./contracts").PhiRuntimeModuleId[] | null;
96
95
  controllerSettings?: import("../../types/cms").PhiCmsTreeControllerSettings | null;
97
96
  };
98
97
  export declare function mergePhiCmsShellTrees(base: PhiResolvedCmsPageTree, overlay: PhiResolvedCmsPageTree): {
99
98
  pageMeta: import("../../types").PhiCmsResolvedPageMeta | null | undefined;
100
- runtimeModuleIds: `${string}/${string}`[] | null | undefined;
101
99
  regions: import("../../types").PhiCmsRegionNode[];
102
100
  overlays: import("../../types").PhiCmsOverlayNode[];
103
101
  layoutNodes: import("../../types").PhiCmsLayoutNode[];
@@ -93,9 +93,6 @@ export function mergePhiCmsShellTrees(base, overlay) {
93
93
  ...base,
94
94
  ...overlay,
95
95
  pageMeta: Object.prototype.hasOwnProperty.call(overlay, "pageMeta") ? overlay.pageMeta : base.pageMeta,
96
- runtimeModuleIds: Object.prototype.hasOwnProperty.call(overlay, "runtimeModuleIds")
97
- ? overlay.runtimeModuleIds
98
- : base.runtimeModuleIds,
99
96
  regions: [...base.regions, ...overlay.regions],
100
97
  overlays: [...base.overlays, ...overlay.overlays],
101
98
  layoutNodes: [...base.layoutNodes, ...overlay.layoutNodes],
@@ -1,7 +1,7 @@
1
1
  import "server-only";
2
2
  import type { PhiCmsAreaKey } from "../constants/cms-areas";
3
3
  import type { PhiBlockRuntime } from "../types";
4
- import type { PhiCmsCompiledDescriptorCatalog, PhiRuntimeModuleId } from "../types/cms-module-descriptors";
4
+ import type { PhiCmsActiveRouteTable, PhiCmsCompiledDescriptorCatalog, PhiRuntimeModuleId } from "../types/cms-module-descriptors";
5
5
  /**
6
6
  * Where this Area's root leads, worked out without waiting for somebody to ask for it.
7
7
  *
@@ -26,9 +26,12 @@ import type { PhiCmsCompiledDescriptorCatalog, PhiRuntimeModuleId } from "../typ
26
26
  * Public is left out. Its root is a locale segment and a landing Page rather than a forward, and the
27
27
  * proxy's Area-root branch never sees it.
28
28
  */
29
- export declare function warmPhiAreaRootDoor({ area, config, runtime, catalog, activeModuleIds, }: {
29
+ export declare function warmPhiAreaRootDoor({ area, config, routeTable, runtime, catalog, activeModuleIds, }: {
30
30
  area: PhiCmsAreaKey;
31
+ /** The Area structure's config, where the root route is stated. */
31
32
  config: Record<string, unknown> | null | undefined;
33
+ /** The table the root render compiled, from the Module selection and that structure. */
34
+ routeTable: PhiCmsActiveRouteTable;
32
35
  runtime: PhiBlockRuntime;
33
36
  catalog: PhiCmsCompiledDescriptorCatalog;
34
37
  activeModuleIds: ReadonlySet<PhiRuntimeModuleId>;
@@ -1,10 +1,9 @@
1
1
  import "server-only";
2
2
  import { peekPhiAreaRootDoor, rememberPhiAreaRootDoor } from "../gateway/area-root-door";
3
3
  import { findFirstPhiCmsNavigationLinkPath } from "../components/regions/presets/navigation-redirect";
4
- import { compilePhiCmsActiveRouteTable, resolvePhiCmsActiveNavigationSurfaces, } from "../plugins/runtime-modules/descriptor-compiler";
4
+ import { resolvePhiCmsActiveNavigationSurfaces } from "../plugins/runtime-modules/descriptor-compiler";
5
5
  import { resolvePhiAreaRootRouteNavKey } from "../plugins/runtime-modules/area-root-route";
6
6
  import { resolvePhiAreaRootRouteDecision } from "./area-root-route";
7
- import { readPhiAreaLandingSelection, readPhiAreaPublicRoutePaths, } from "../helpers/cms-area-config";
8
7
  import { localizeAreaPath } from "../helpers/locale";
9
8
  /**
10
9
  * Where this Area's root leads, worked out without waiting for somebody to ask for it.
@@ -30,7 +29,7 @@ import { localizeAreaPath } from "../helpers/locale";
30
29
  * Public is left out. Its root is a locale segment and a landing Page rather than a forward, and the
31
30
  * proxy's Area-root branch never sees it.
32
31
  */
33
- export async function warmPhiAreaRootDoor({ area, config, runtime, catalog, activeModuleIds, }) {
32
+ export async function warmPhiAreaRootDoor({ area, config, routeTable, runtime, catalog, activeModuleIds, }) {
34
33
  if (area === "public") {
35
34
  return;
36
35
  }
@@ -43,13 +42,6 @@ export async function warmPhiAreaRootDoor({ area, config, runtime, catalog, acti
43
42
  * nothing to remember: the proxy stays cold for this Area and the render answers, which is correct
44
43
  * because the render does not forward either.
45
44
  */
46
- const routeTable = compilePhiCmsActiveRouteTable({
47
- catalog,
48
- area,
49
- activeModuleIds,
50
- publicRoutePaths: readPhiAreaPublicRoutePaths(config),
51
- landingSelection: readPhiAreaLandingSelection(config),
52
- });
53
45
  const decision = await resolvePhiAreaRootRouteDecision({
54
46
  config,
55
47
  requestedStoragePath: "/",
@@ -2,7 +2,15 @@ import "server-only";
2
2
  import type { PhiResolvedCmsAreaPresetPayload } from "../types/cms";
3
3
  import type { PhiBlockRuntime } from "../types";
4
4
  import type { PhiRuntimeModuleCatalog } from "../types/cms-plugins";
5
- export declare function buildPhiLocalCmsAreaPayload({ areaMask, siteId, path, runtime, runtimeModuleCatalog, }: {
5
+ import type { PhiCmsAreaShellPresetBinding } from "../types/cms-module-descriptors";
6
+ /**
7
+ * The Area's shell as its preset builds it, for an Area that stores no structure on that shell.
8
+ *
9
+ * `binding` is the Area's effective shell (`resolvePhiAreaRouteScope`): the base Module's, or the one
10
+ * an active Module brings. A stored structure of another shell is not this Area's answer and is not read.
11
+ */
12
+ export declare function buildPhiLocalCmsAreaPayload({ binding, areaMask, siteId, path, runtime, runtimeModuleCatalog, }: {
13
+ binding: PhiCmsAreaShellPresetBinding;
6
14
  areaMask: number;
7
15
  siteId: number;
8
16
  path: string;
@@ -3,8 +3,10 @@ import { resolvePhiCmsAreaKey, resolvePhiCmsAreaMask } from "../constants/cms-ar
3
3
  import { PhiCmsStatus } from "../constants/phi-cms";
4
4
  import { applyPhiPresetTreePublishedContent } from "./cms-bound-content";
5
5
  import { createPhiModuleMediaLoader } from "../gateway/server-module-media";
6
- import { instantiatePhiCmsAreaShellPreset, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
7
- function createSyntheticAreaPreset({ siteId, areaMask, }) {
6
+ import { buildPhiAreaShellPresetConfig } from "../helpers/cms-area-config";
7
+ import { instantiatePhiCmsAreaShellPreset, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
8
+ /** The Area row a shell preset stands for: no stored id, and the config the shell proposes. */
9
+ function createSyntheticAreaPreset({ siteId, areaMask, config, }) {
8
10
  return {
9
11
  id: -(9000 + areaMask),
10
12
  siteId,
@@ -12,10 +14,10 @@ function createSyntheticAreaPreset({ siteId, areaMask, }) {
12
14
  status: PhiCmsStatus.Published,
13
15
  flags: 0,
14
16
  visibilityMask: areaMask,
15
- config: {},
17
+ config,
16
18
  };
17
19
  }
18
- function buildAreaPresetPayloadFromTree({ areaMask, siteId, tree, sourcePreset, }) {
20
+ function buildAreaPresetPayloadFromTree({ areaMask, siteId, tree, sourcePreset, config, }) {
19
21
  return {
20
22
  areaMask,
21
23
  sourcePreset,
@@ -23,27 +25,29 @@ function buildAreaPresetPayloadFromTree({ areaMask, siteId, tree, sourcePreset,
23
25
  preset: createSyntheticAreaPreset({
24
26
  siteId,
25
27
  areaMask,
28
+ config,
26
29
  }),
27
30
  regions: tree.regions,
28
31
  overlays: tree.overlays,
29
32
  layoutNodes: tree.layoutNodes,
30
33
  contentWidgets: tree.contentWidgets,
31
34
  controllerSettings: tree.controllerSettings ?? [],
32
- runtimeModuleIds: tree.runtimeModuleIds ?? null,
33
35
  },
34
36
  };
35
37
  }
36
- export async function buildPhiLocalCmsAreaPayload({ areaMask, siteId, path, runtime, runtimeModuleCatalog, }) {
38
+ /**
39
+ * The Area's shell as its preset builds it, for an Area that stores no structure on that shell.
40
+ *
41
+ * `binding` is the Area's effective shell (`resolvePhiAreaRouteScope`): the base Module's, or the one
42
+ * an active Module brings. A stored structure of another shell is not this Area's answer and is not read.
43
+ */
44
+ export async function buildPhiLocalCmsAreaPayload({ binding, areaMask, siteId, path, runtime, runtimeModuleCatalog, }) {
37
45
  const areaKey = resolvePhiCmsAreaKey(areaMask);
38
46
  const resolvedAreaMask = resolvePhiCmsAreaMask(areaKey);
39
- if (resolvedAreaMask !== areaMask) {
47
+ if (resolvedAreaMask !== areaMask || binding.descriptor.area !== areaKey) {
40
48
  return null;
41
49
  }
42
50
  const catalog = resolvePhiCmsDescriptorCatalog(runtimeModuleCatalog);
43
- const binding = resolvePhiCmsAreaShellPresetBinding(catalog, areaKey);
44
- if (!binding) {
45
- return null;
46
- }
47
51
  const tree = await applyPhiPresetTreePublishedContent(await instantiatePhiCmsAreaShellPreset({
48
52
  binding,
49
53
  catalog,
@@ -61,5 +65,6 @@ export async function buildPhiLocalCmsAreaPayload({ areaMask, siteId, path, runt
61
65
  presetKey: binding.descriptor.presetKey,
62
66
  sourcePresetVersion: binding.descriptor.shellPresetVersion,
63
67
  },
68
+ config: buildPhiAreaShellPresetConfig(binding.descriptor.settings),
64
69
  });
65
70
  }
@@ -34,7 +34,7 @@ export async function resolvePhiCmsLookup({ bridge, area, locale, path, cookieHe
34
34
  requestContext,
35
35
  runtimeModuleCatalog: bridge.runtimeModuleCatalog,
36
36
  purpose: "lookup",
37
- loadExactCmsArea: (requestPath, sourcePreset) => getPhiExactSiteArea({
37
+ loadCmsArea: (requestPath, { sourcePreset }) => getPhiExactSiteArea({
38
38
  path: requestPath,
39
39
  siteKey,
40
40
  apiBaseUrl,
@@ -1,6 +1,8 @@
1
1
  import "server-only";
2
2
  import { type PhiCmsAreaKey } from "../constants/cms-areas";
3
- import type { PhiResolvedCmsAreaPresetPayload, PhiResolvedCmsPagePayload } from "../types/cms";
3
+ import type { PhiCmsAreaModulesSelection, PhiResolvedCmsAreaPresetPayload, PhiResolvedCmsPagePayload } from "../types/cms";
4
+ import type { PhiCmsAreaShellPresetBinding, PhiCmsPresetIdentity } from "../types/cms-module-descriptors";
5
+ import type { PhiSiteAreaRead } from "../gateway/site-area";
4
6
  import type { PhiResolvedCmsRequest, PhiRuntimeModuleCatalog, PhiRuntimeModuleId } from "../types/cms-plugins";
5
7
  import { resolvePhiCmsDescriptorCatalog } from "../plugins/runtime-modules/descriptor-compiler";
6
8
  import type { PhiCapabilitySnapshot } from "../types/server-capabilities";
@@ -9,10 +11,15 @@ type LoadPhiResolvedCmsPage = (path: string, sourcePreset?: {
9
11
  ownerModuleId: PhiRuntimeModuleId;
10
12
  presetKey: string;
11
13
  } | null) => Promise<PhiResolvedCmsPagePayload | null>;
12
- type LoadPhiExactSiteArea = (path: string, sourcePreset: {
13
- ownerModuleId: PhiRuntimeModuleId;
14
- presetKey: string;
15
- }) => Promise<PhiResolvedCmsAreaPresetPayload | null>;
14
+ /**
15
+ * The Area read a resolution makes: `"live"` is what a visitor is served, `"requested"` the revision or
16
+ * review the request names, if it names one of the Area. Without `sourcePreset` the live read answers the
17
+ * selection and the one stored structure together (`PhiSiteAreaRead`).
18
+ */
19
+ type LoadPhiCmsArea = (path: string, request: {
20
+ sourcePreset: PhiCmsPresetIdentity | null;
21
+ stage: "live" | "requested";
22
+ }) => Promise<PhiSiteAreaRead | null>;
16
23
  export type ResolvePhiCmsRequestArgs = {
17
24
  siteKey: string;
18
25
  locale: string;
@@ -24,7 +31,9 @@ export type ResolvePhiCmsRequestArgs = {
24
31
  requestContext?: PhiSiteRequestContext;
25
32
  searchParams?: Record<string, string | undefined>;
26
33
  loadResolvedCmsPage: LoadPhiResolvedCmsPage;
27
- loadExactCmsArea: LoadPhiExactSiteArea;
34
+ loadCmsArea: LoadPhiCmsArea;
35
+ /** Whether the request names a revision or a review of the Area, which the `"requested"` read answers. */
36
+ previewsArea?: boolean;
28
37
  runtimeModuleCatalog: PhiRuntimeModuleCatalog;
29
38
  /**
30
39
  * `"render"` resolves the request being answered: it binds the request-scoped runtime and
@@ -42,25 +51,61 @@ export type ResolvePhiCmsRequestArgs = {
42
51
  */
43
52
  purpose?: "render" | "lookup" | "refusal";
44
53
  };
54
+ /** What an Area stores, as far as answering a request goes: its Module selection and its structure. */
55
+ export type PhiCmsAreaStoredRead = Pick<PhiSiteAreaRead, "modules" | "structure">;
45
56
  /**
46
- * What an Area answers under a preset: the active Module ids and the route table compiled from them.
57
+ * What an Area answers: the active Module ids, the effective shell, the stored structure where it
58
+ * stands on that shell, and the route table compiled from them.
59
+ *
60
+ * In that order, because each step needs the one before. The selection decides the active Modules; the
61
+ * active Modules decide the shell (`resolvePhiCmsAreaShellPresetBinding`: the one active Module that
62
+ * brings one, otherwise the base); and a stored structure applies only when its identity is that
63
+ * shell's -- a Site that stored a base structure and then switched a shell provider on sees the
64
+ * provider's shell, and its own structure again once the provider is off. `structure` is null where
65
+ * the shell's preset answers; the caller builds it (`buildPhiLocalCmsAreaPayload`) only if it needs it.
47
66
  *
48
67
  * Nine readers -- the page request, the root shell, the dashboard cards, the navigation targets, the
49
- * page references, the public login, the search index and two more -- each wrote these two steps out,
50
- * and the two reads of the Area config between them. Stated once, the readers cannot drift in which
51
- * config they compile from.
68
+ * page references, the public login, the search index and two more -- each wrote these steps out.
69
+ * Stated once, the readers cannot drift in which shell and which config they compile from.
52
70
  */
53
71
  export declare function resolvePhiAreaRouteScope(input: {
54
72
  runtimeModuleCatalog: PhiRuntimeModuleCatalog;
55
73
  catalog: ReturnType<typeof resolvePhiCmsDescriptorCatalog>;
56
74
  area: PhiCmsAreaKey;
57
- preset: PhiResolvedCmsAreaPresetPayload["preset"] | null;
75
+ read: PhiCmsAreaStoredRead | null;
58
76
  serverCapabilities: PhiCapabilitySnapshot | null;
59
77
  }): {
60
78
  activeModuleIds: Set<`${string}/${string}`>;
61
79
  routeTable: import("../types/cms-module-descriptors").PhiCmsActiveRouteTable;
80
+ shellBinding: PhiCmsAreaShellPresetBinding;
81
+ structure: PhiResolvedCmsAreaPresetPayload | null;
62
82
  };
63
- export declare function resolveActivePresetModuleKeys(runtimeModuleCatalog: PhiRuntimeModuleCatalog, area: PhiCmsAreaKey, areaPreset: Pick<PhiResolvedCmsAreaPresetPayload, "preset"> | null, serverCapabilities: PhiCapabilitySnapshot | null): Set<`${string}/${string}`>;
64
- export declare function resolvePhiCmsRequest({ siteKey, locale, area, path, cookieHeader, apiBaseUrl, internalToken, requestContext, searchParams, loadResolvedCmsPage, loadExactCmsArea, runtimeModuleCatalog, purpose, }: ResolvePhiCmsRequestArgs): Promise<PhiResolvedCmsRequest | null>;
83
+ /**
84
+ * What the Area stores for a request that may preview or review one of its revisions.
85
+ *
86
+ * A live request is one read without an identity: the selection and the one stored structure come
87
+ * together, and `resolvePhiAreaRouteScope` drops the structure if it stands on another shell. A
88
+ * revision or a review of the Area answers a structure only under the identity it names, and the shell
89
+ * that identity has to be depends on the selection -- which the reviewed revision may itself be. So it
90
+ * reads the live Area first, asks the reviewed revision under the shell the live selection chooses, and
91
+ * takes, under the shell the reviewed selection chooses, the reviewed structure or else the live one.
92
+ * Only previews pay the second read.
93
+ */
94
+ export declare function readPhiCmsAreaForRequest({ loadArea, previewsArea, resolveShellSource, }: {
95
+ loadArea: (request: {
96
+ sourcePreset: PhiCmsPresetIdentity | null;
97
+ stage: "live" | "requested";
98
+ }) => Promise<PhiSiteAreaRead | null>;
99
+ previewsArea: boolean;
100
+ resolveShellSource: (modules: PhiCmsAreaModulesSelection | null) => PhiCmsPresetIdentity | Promise<PhiCmsPresetIdentity>;
101
+ }): Promise<PhiCmsAreaStoredRead>;
102
+ /** The identity of the shell an Area takes under a selection, for `readPhiCmsAreaForRequest`. */
103
+ export declare function resolvePhiCmsAreaShellSource(input: {
104
+ runtimeModuleCatalog: PhiRuntimeModuleCatalog;
105
+ area: PhiCmsAreaKey;
106
+ modules: PhiCmsAreaModulesSelection | null;
107
+ serverCapabilities: PhiCapabilitySnapshot | null;
108
+ }): PhiCmsPresetIdentity;
109
+ export declare function resolvePhiCmsRequest({ siteKey, locale, area, path, cookieHeader, apiBaseUrl, internalToken, requestContext, searchParams, loadResolvedCmsPage, loadCmsArea, previewsArea, runtimeModuleCatalog, purpose, }: ResolvePhiCmsRequestArgs): Promise<PhiResolvedCmsRequest | null>;
65
110
  export declare const loadPhiResolvedCmsRequest: (siteKey: string, locale: string, area: PhiCmsAreaKey, path: string, cookieHeader: string, apiBaseUrl: string | undefined, internalToken: string | undefined, requestContext: PhiSiteRequestContext | undefined, searchParams: Record<string, string | undefined> | undefined, runtimeModuleCatalog: PhiRuntimeModuleCatalog, purpose?: ResolvePhiCmsRequestArgs["purpose"]) => Promise<PhiResolvedCmsRequest | null>;
66
111
  export {};