@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
@@ -36,6 +36,8 @@ export declare function loadPhiCmsAreaRenderScope({ root, path, cmsBridge }: Phi
36
36
  };
37
37
  requestContext: import("../../types/site-request-context").PhiSiteRequestContext;
38
38
  resolvedAreaPreset: import("../../types").PhiResolvedCmsAreaPresetTree | null;
39
+ areaModules: import("../../types/cms").PhiCmsAreaModulesSelection | null;
40
+ routeTable: import("../../types/cms-module-descriptors").PhiCmsActiveRouteTable;
39
41
  resolvedRequest: import("../../types").PhiResolvedCmsRequest | null;
40
42
  };
41
43
  runtime: {
@@ -30,7 +30,7 @@ const loadPhiCmsAreaRenderScopeCached = cache(async function loadPhiCmsAreaRende
30
30
  const runtimeModuleScope = await resolvePhiCmsAreaRuntimeModuleScope({
31
31
  cmsBridge,
32
32
  area: runtime.area,
33
- areaPreset: layoutTree,
33
+ areaModules: rootScope.areaModules,
34
34
  serverCapabilities: rootScope.requestContext.serverCapabilities,
35
35
  });
36
36
  const filteredLayoutTree = layoutTree
@@ -57,7 +57,7 @@ export async function PhiCmsErrorPage({ code, cmsBridge, area, locale: staticLoc
57
57
  const runtimeModuleScope = await resolvePhiCmsAreaRuntimeModuleScope({
58
58
  cmsBridge,
59
59
  area: resolvedRequest.runtime.area,
60
- areaPreset: resolvedRequest.areaPreset,
60
+ areaModules: resolvedRequest.areaModules,
61
61
  serverCapabilities: resolvedRequest.serverCapabilities,
62
62
  });
63
63
  const runtimeRegistry = await resolvePhiCmsTreeRuntimeRegistry({
@@ -26,7 +26,6 @@ export declare function resolvePhiCmsPageRenderScope({ cmsBridge, resolvedReques
26
26
  visualAnchorTargets: import("../../types").PhiVisualAnchorAddress[];
27
27
  page: import("../../types").PhiCmsPageNode;
28
28
  pageMeta?: import("../../types").PhiCmsResolvedPageMeta | null;
29
- runtimeModuleIds?: import("../../types").PhiRuntimeModuleId[] | null;
30
29
  regions: import("../../types").PhiCmsRegionNode[];
31
30
  overlays: import("../../types").PhiCmsOverlayNode[];
32
31
  layoutNodes: import("../../types").PhiCmsLayoutNode[];
@@ -24,7 +24,7 @@ const resolvePhiCmsPageRenderBase = cache(async (cmsBridge, resolvedRequest) =>
24
24
  const runtimeModuleScope = await resolvePhiCmsAreaRuntimeModuleScope({
25
25
  cmsBridge,
26
26
  area: resolvedRequest.runtime.area,
27
- areaPreset: resolvedRequest.areaPreset,
27
+ areaModules: resolvedRequest.areaModules,
28
28
  serverCapabilities: resolvedRequest.serverCapabilities,
29
29
  });
30
30
  /*
@@ -156,6 +156,7 @@ export async function PhiCmsAreaBoundary({ root, cmsBridge, children, path, page
156
156
  await warmPhiAreaRootDoor({
157
157
  area: resolvedRoute.area,
158
158
  config: rootScope.resolvedAreaPreset?.preset.config,
159
+ routeTable: rootScope.routeTable,
159
160
  runtime,
160
161
  catalog: resolvePhiCmsDescriptorCatalog(cmsBridge.runtimeModuleCatalog),
161
162
  activeModuleIds: runtimeModuleScope.moduleSet.activeModuleIds,
@@ -3,7 +3,7 @@ import type { PhiResolvedCmsRenderableTree } from "../../types/cms";
3
3
  import type { PhiCmsSiteBridge, PhiRuntimeModuleCatalog, PhiRuntimeModuleId } from "../../types/cms-plugins";
4
4
  import type { PhiCmsAreaKey } from "../../constants/cms-areas";
5
5
  import type { PhiCapabilitySnapshot } from "../../types/server-capabilities";
6
- import { readPhiAreaPresetRuntimeModuleIds } from "../../helpers/cms-area-config";
6
+ import { readPhiAreaSelectionRuntimeModuleIds } from "../../helpers/cms-area-config";
7
7
  declare function resolvePhiCmsRuntimeModuleScope({ cmsBridge, moduleIds, area, serverCapabilities, }: {
8
8
  cmsBridge: PhiCmsSiteBridge;
9
9
  moduleIds?: readonly PhiRuntimeModuleId[] | null;
@@ -16,15 +16,15 @@ declare function resolvePhiCmsRuntimeModuleScope({ cmsBridge, moduleIds, area, s
16
16
  widgetDefinitionsByType: Map<string, import("../../types").PhiCmsWidgetPluginDefinition<unknown>>;
17
17
  }>;
18
18
  /**
19
- * The Module scope of an Area, from the selection its preset states.
19
+ * The Module scope of an Area, from its Module selection (stored apart from its structure).
20
20
  *
21
21
  * Which Modules this Area runs, and not which ones this person may see. A Module is area-bound and
22
22
  * never switched off for a reader (ACCESS.md); what its Widgets show may still differ per person.
23
23
  */
24
- export declare function resolvePhiCmsAreaRuntimeModuleScope({ cmsBridge, area, areaPreset, serverCapabilities, }: {
24
+ export declare function resolvePhiCmsAreaRuntimeModuleScope({ cmsBridge, area, areaModules, serverCapabilities, }: {
25
25
  cmsBridge: PhiCmsSiteBridge;
26
26
  area: PhiCmsAreaKey;
27
- areaPreset: Parameters<typeof readPhiAreaPresetRuntimeModuleIds>[0];
27
+ areaModules: Parameters<typeof readPhiAreaSelectionRuntimeModuleIds>[0];
28
28
  serverCapabilities: PhiCapabilitySnapshot | null;
29
29
  }): Promise<{
30
30
  catalog: PhiRuntimeModuleCatalog;
@@ -2,7 +2,7 @@ import "server-only";
2
2
  import { cache } from "react";
3
3
  import { resolvePhiRuntimeModuleSet, resolvePhiRuntimeRenderRegistry, } from "../../plugins/runtime-modules/resolver";
4
4
  import { resolvePhiRuntimeModuleIdsForArea } from "../../plugins/runtime-modules/settings";
5
- import { readPhiAreaPresetRuntimeModuleIds } from "../../helpers/cms-area-config";
5
+ import { readPhiAreaSelectionRuntimeModuleIds } from "../../helpers/cms-area-config";
6
6
  const resolvePhiCmsRuntimeModuleScopeForRequest = cache(async (catalog, area, moduleIdsKey, serverCapabilitiesKey) => {
7
7
  const moduleIds = JSON.parse(moduleIdsKey);
8
8
  const serverCapabilities = JSON.parse(serverCapabilitiesKey);
@@ -24,13 +24,13 @@ function resolvePhiCmsRuntimeModuleScope({ cmsBridge, moduleIds, area, serverCap
24
24
  return resolvePhiCmsRuntimeModuleScopeForRequest(cmsBridge.runtimeModuleCatalog, area, JSON.stringify(moduleIds ?? []), JSON.stringify(serverCapabilities));
25
25
  }
26
26
  /**
27
- * The Module scope of an Area, from the selection its preset states.
27
+ * The Module scope of an Area, from its Module selection (stored apart from its structure).
28
28
  *
29
29
  * Which Modules this Area runs, and not which ones this person may see. A Module is area-bound and
30
30
  * never switched off for a reader (ACCESS.md); what its Widgets show may still differ per person.
31
31
  */
32
- export function resolvePhiCmsAreaRuntimeModuleScope({ cmsBridge, area, areaPreset, serverCapabilities, }) {
33
- const moduleIds = resolvePhiRuntimeModuleIdsForArea(area, readPhiAreaPresetRuntimeModuleIds(areaPreset, area), [...cmsBridge.runtimeModuleCatalog.values()].map((entry) => entry.definition));
32
+ export function resolvePhiCmsAreaRuntimeModuleScope({ cmsBridge, area, areaModules, serverCapabilities, }) {
33
+ const moduleIds = resolvePhiRuntimeModuleIdsForArea(area, readPhiAreaSelectionRuntimeModuleIds(areaModules, area), [...cmsBridge.runtimeModuleCatalog.values()].map((entry) => entry.definition));
34
34
  return resolvePhiCmsRuntimeModuleScope({ cmsBridge, moduleIds, area, serverCapabilities });
35
35
  }
36
36
  export function resolvePhiCmsTreeRuntimeRegistry({ moduleScope, trees, }) {
@@ -10,6 +10,7 @@ const PHI_REGION_WIDGET_LABEL_SET = definePhiLabelSet({
10
10
  structure_surface_sider_full_height: PHI_REGION_WIDGET_DEFAULT_LABELS.structure.surface.siderFullHeight,
11
11
  structure_surface_sider_spans_shell: PHI_REGION_WIDGET_DEFAULT_LABELS.structure.surface.siderSpansShell,
12
12
  structure_surface_sider_beside_content: PHI_REGION_WIDGET_DEFAULT_LABELS.structure.surface.siderBesideContent,
13
+ structure_surface_shell_owner: PHI_REGION_WIDGET_DEFAULT_LABELS.structure.surface.shellOwner,
13
14
  structure_surface_selected_page_header_band: PHI_REGION_WIDGET_DEFAULT_LABELS.structure.surface.selectedPageHeaderBand,
14
15
  structure_surface_page_sidebar: PHI_REGION_WIDGET_DEFAULT_LABELS.structure.surface.pageSidebar,
15
16
  structure_surface_content_title: PHI_REGION_WIDGET_DEFAULT_LABELS.structure.surface.contentTitle,
@@ -45,6 +46,7 @@ export async function getPhiRegionWidgetLabels(options) {
45
46
  siderFullHeight: labels.structure_surface_sider_full_height,
46
47
  siderSpansShell: labels.structure_surface_sider_spans_shell,
47
48
  siderBesideContent: labels.structure_surface_sider_beside_content,
49
+ shellOwner: labels.structure_surface_shell_owner,
48
50
  selectedPageHeaderBand: labels.structure_surface_selected_page_header_band,
49
51
  pageSidebar: labels.structure_surface_page_sidebar,
50
52
  contentTitle: labels.structure_surface_content_title,
@@ -11,6 +11,8 @@ export type PhiRegionWidgetLabels = {
11
11
  /** What the left Sider is doing right now, one of the two, under its title on the canvas. */
12
12
  siderSpansShell: string;
13
13
  siderBesideContent: string;
14
+ /** Which Module's shell the Area takes, under the top Region on the canvas; `%1` is its title. */
15
+ shellOwner: string;
14
16
  selectedPageHeaderBand: string;
15
17
  pageSidebar: string;
16
18
  contentTitle: string;
@@ -5,6 +5,7 @@ export const PHI_REGION_WIDGET_DEFAULT_LABELS = {
5
5
  siderFullHeight: "Sider full height",
6
6
  siderSpansShell: "Spans header to footer",
7
7
  siderBesideContent: "Beside the content only",
8
+ shellOwner: "The shell of %1",
8
9
  selectedPageHeaderBand: "Selected page header band",
9
10
  pageSidebar: "Page sidebar beside hero and content",
10
11
  contentTitle: "Page body viewport",
@@ -58,8 +58,8 @@ export const PHI_BUILDER_REVISIONS_WIDGET_DEFAULT_LABELS = {
58
58
  },
59
59
  deleteArea: {
60
60
  title: "Clear this Area back to its preset?",
61
- warning: "Everything this Site stored for the 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.",
62
- survives: "The Area keeps its Pages, its Navigation and its Theme. Its Shell and its Module selection go back to the preset.",
61
+ warning: "The structure this Site stored for the 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.",
62
+ survives: "The Area keeps its Module selection, its Pages, its Navigation and its Theme. Only its Shell goes back to the preset.",
63
63
  field: "Type the Area key to confirm",
64
64
  fieldRequired: "Write the Area key out to confirm.",
65
65
  confirm: "Clear Area",
@@ -1,6 +1,6 @@
1
1
  import type { PhiBuilderAreaKey } from "../../constants/cms-areas";
2
2
  import type { PhiBuilderModulePresetPagesByArea, PhiBuilderPersistedPageCatalogEntry, PhiPresetPageNode } from "../../helpers/cms-page-catalog";
3
- import type { PhiCmsPresetSource, PhiCmsResolvedNavigationSurface } from "../../types/cms-module-descriptors";
3
+ import type { PhiCmsPresetIdentity, PhiCmsPresetSource, PhiCmsResolvedNavigationSurface } from "../../types/cms-module-descriptors";
4
4
  import type { PhiPublicRoutePathAssignment } from "../../helpers/cms-area-config";
5
5
  import type { PhiPublicRouteClaim } from "../../helpers/public-route-claims";
6
6
  import type { PhiRuntimeModuleDefinition, PhiRuntimeModuleId } from "../../types";
@@ -19,6 +19,16 @@ export type PhiWorkspaceServerUnavailableModule = {
19
19
  diagnosticCode: string;
20
20
  missingCapabilities: readonly string[];
21
21
  };
22
+ /** What the Builder knows about an Area's shell beyond the one it takes (`areaPresetSourcesByArea`). */
23
+ export type PhiWorkspaceAreaShellState = {
24
+ /** The installed Modules that bring a shell for the Area, selected or not. At most one may be selected. */
25
+ providerModuleIds: PhiRuntimeModuleId[];
26
+ /**
27
+ * The identity the Area's one stored structure stands on, whatever shell the Area takes now; null when
28
+ * it stores none. A structure of another shell is kept and comes back when that shell applies again.
29
+ */
30
+ storedSource: PhiCmsPresetIdentity | null;
31
+ };
22
32
  export type PhiWorkspaceCatalogState = {
23
33
  /** The Area being worked on. */
24
34
  area: PhiWorkspaceCatalogArea;
@@ -31,7 +41,13 @@ export type PhiWorkspaceCatalogState = {
31
41
  customPages: Partial<Record<PhiWorkspaceCatalogArea, PhiPresetPageNode[]>>;
32
42
  persistedPageCatalogByArea: Partial<Record<PhiWorkspaceCatalogArea, PhiBuilderPersistedPageCatalogEntry[]>>;
33
43
  navigationSurfacesByArea: Partial<Record<PhiWorkspaceCatalogArea, readonly PhiCmsResolvedNavigationSurface[]>>;
44
+ /**
45
+ * The shell each Area takes: the shell of the one selected Module that brings one, else the base
46
+ * Module's. What a structure save, a draft read and a Revisions scope name.
47
+ */
34
48
  areaPresetSourcesByArea: Partial<Record<PhiWorkspaceCatalogArea, PhiCmsPresetSource>>;
49
+ /** Per Area, the Modules that bring a shell for it and the shell its stored structure stands on. */
50
+ areaShellsByArea: Partial<Record<PhiWorkspaceCatalogArea, PhiWorkspaceAreaShellState>>;
35
51
  runtimeModuleDefinitions: PhiRuntimeModuleDefinition[];
36
52
  runtimeModuleIdsByArea: Partial<Record<PhiWorkspaceCatalogArea, PhiRuntimeModuleId[]>>;
37
53
  /**
@@ -17,6 +17,7 @@ function createDefaultWorkspaceCatalogState(scopeKey) {
17
17
  persistedPageCatalogByArea: {},
18
18
  navigationSurfacesByArea: {},
19
19
  areaPresetSourcesByArea: {},
20
+ areaShellsByArea: {},
20
21
  runtimeModuleDefinitions: [],
21
22
  runtimeModuleIdsByArea: {},
22
23
  unresolvedModuleIdsByArea: {},
@@ -3,7 +3,7 @@ import "server-only";
3
3
  import { isPhiCmsAreaKey, resolvePhiCmsAreaMask, } from "../constants/cms-areas";
4
4
  import { canPhiViewerAccess } from "../types/access";
5
5
  import { localizeAreaPath } from "../helpers/locale";
6
- import { compilePhiCmsActiveRouteTable, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
6
+ import { compilePhiCmsActiveRouteTable, resolvePhiCmsAreaBaseShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
7
7
  import { resolvePhiAreaRouteScope } from "../server-helpers/cms-request";
8
8
  import { getPhiExactSiteArea } from "../server-helpers/cms";
9
9
  import { resolveCmsRootRoute } from "../server-helpers/cms-route";
@@ -44,29 +44,24 @@ async function resolveDashboardCardScope({ bridge, area, locale, path, cookieHea
44
44
  const requestContext = await loadPhiSiteRequestContext(siteKey, locale, cookieHeader, apiBaseUrl, internalToken);
45
45
  const catalog = resolvePhiCmsDescriptorCatalog(bridge.runtimeModuleCatalog);
46
46
  const areaDefinition = catalog.areaDefinitions.get(area);
47
- const shellBinding = resolvePhiCmsAreaShellPresetBinding(catalog, area);
48
47
  if (!areaDefinition ||
49
- !shellBinding ||
48
+ !resolvePhiCmsAreaBaseShellPresetBinding(catalog, area) ||
50
49
  !canPhiViewerAccess(requestContext.viewer, areaDefinition.accessPolicy)) {
51
50
  return null;
52
51
  }
53
- const areaPreset = await getPhiExactSiteArea({
52
+ const storedArea = await getPhiExactSiteArea({
54
53
  path,
55
54
  apiBaseUrl,
56
55
  internalToken,
57
56
  siteKey,
58
57
  locale,
59
58
  cookieHeader,
60
- sourcePreset: {
61
- ownerModuleId: shellBinding.descriptor.ownerModuleId,
62
- presetKey: shellBinding.descriptor.presetKey,
63
- },
64
59
  });
65
60
  const { activeModuleIds, routeTable } = resolvePhiAreaRouteScope({
66
61
  runtimeModuleCatalog: bridge.runtimeModuleCatalog,
67
62
  catalog,
68
63
  area,
69
- preset: areaPreset?.preset ?? null,
64
+ read: storedArea,
70
65
  serverCapabilities: requestContext.serverCapabilities,
71
66
  });
72
67
  const cardContext = {
@@ -1,5 +1,5 @@
1
1
  import "server-only";
2
- import { isPhiCmsAreaKey, resolvePhiCmsAreaMask } from "../constants/cms-areas";
2
+ import { isPhiCmsAreaKey } from "../constants/cms-areas";
3
3
  import { canPhiViewerAccess } from "../types/access";
4
4
  import { getResolvedFormDefinition } from "./form-registry";
5
5
  import { getExactSiteArea } from "./site-area";
@@ -7,10 +7,8 @@ import { getPhiCapabilitySnapshot } from "./server-capabilities";
7
7
  import { resolvePhiCmsDescriptorCatalog } from "../plugins/runtime-modules/descriptor-compiler";
8
8
  import { resolvePhiRuntimeModuleSet } from "../plugins/runtime-modules/resolver";
9
9
  import { resolvePhiRuntimeModuleIdsForArea } from "../plugins/runtime-modules/settings";
10
- import { buildPhiLocalCmsAreaPayload } from "../server-helpers/cms-area";
11
- import { buildPhiBlockRuntime, loadPhiSiteRequestContext } from "../server-helpers/runtime";
12
- import { runWithPhiRequestRuntime } from "../server-helpers/request-runtime";
13
- import { readPhiAreaPresetRuntimeModuleIds } from "../helpers/cms-area-config";
10
+ import { loadPhiSiteRequestContext } from "../server-helpers/runtime";
11
+ import { readPhiAreaSelectionRuntimeModuleIds } from "../helpers/cms-area-config";
14
12
  import { fetchResolvedSiteLocale } from "../server-helpers/site-locale";
15
13
  /**
16
14
  * Who the relay knows it is talking to before asking anybody: nobody in particular. An Area this viewer
@@ -50,7 +48,7 @@ export async function resolvePhiServerFormHandler(options) {
50
48
  return null;
51
49
  const locale = await resolveRequestLocale(options.request, options);
52
50
  const cookieHeader = options.request.headers.get("cookie") ?? "";
53
- // Read at most once, and only when something needs the viewer: an admitting Area or a preset fallback.
51
+ // Read at most once, and only when something needs the viewer or the server: an admitting Area, the capabilities.
54
52
  const siteRequest = {
55
53
  context: null,
56
54
  };
@@ -60,7 +58,11 @@ export async function resolvePhiServerFormHandler(options) {
60
58
  !canPhiViewerAccess((await loadSiteRequestContext()).viewer, areaDefinition.accessPolicy)) {
61
59
  return null;
62
60
  }
63
- const areaPayload = await getExactSiteArea({
61
+ /*
62
+ * The Area's Module selection, stored apart from its structure: which Modules may answer is all this
63
+ * needs, and an Area that never stored one runs its default list -- no shell is built to find out.
64
+ */
65
+ const storedArea = await getExactSiteArea({
64
66
  apiBaseUrl: options.upstreamBaseUrl,
65
67
  internalToken: options.internalToken,
66
68
  siteKey: options.siteKey,
@@ -68,34 +70,8 @@ export async function resolvePhiServerFormHandler(options) {
68
70
  path: resolveAreaPath(area),
69
71
  locale,
70
72
  cookieHeader,
71
- sourcePreset: {
72
- ownerModuleId: areaDefinition.baseModuleId,
73
- presetKey: areaDefinition.shellPresetKey,
74
- },
75
73
  });
76
- let tree = areaPayload?.preset ?? null;
77
- if (!tree) {
78
- const requestContext = await loadSiteRequestContext();
79
- const areaMask = resolvePhiCmsAreaMask(area);
80
- const runtime = buildPhiBlockRuntime({
81
- requestContext,
82
- areaMask,
83
- });
84
- // The code-owned preset trees resolve their labels through the request runtime store. The page
85
- // render path populates it in the root layout; this route handler runs outside the React render,
86
- // so the store must be scoped explicitly around the instantiation — otherwise the first label
87
- // lookup after a cold start fails the whole dispatch once the label cache no longer masks it.
88
- tree = (await runWithPhiRequestRuntime(runtime, () => buildPhiLocalCmsAreaPayload({
89
- areaMask,
90
- siteId: requestContext.site.id,
91
- path: resolveAreaPath(area),
92
- runtime,
93
- runtimeModuleCatalog: catalog,
94
- })))?.preset ?? null;
95
- }
96
- if (!tree)
97
- return null;
98
- const optionalModuleIds = resolvePhiRuntimeModuleIdsForArea(area, readPhiAreaPresetRuntimeModuleIds(tree, area), [...catalog.values()].map((entry) => entry.definition));
74
+ const optionalModuleIds = resolvePhiRuntimeModuleIdsForArea(area, readPhiAreaSelectionRuntimeModuleIds(storedArea?.modules, area), [...catalog.values()].map((entry) => entry.definition));
99
75
  const serverCapabilities = siteRequest.context?.serverCapabilities ??
100
76
  await getPhiCapabilitySnapshot({
101
77
  apiBaseUrl: options.upstreamBaseUrl,
@@ -2,7 +2,7 @@ import { jsonResponse, readPhiInternalRequestPath, splitPhiRequestPath } from ".
2
2
  import "server-only";
3
3
  import { isPhiCmsAreaKey, } from "../constants/cms-areas";
4
4
  import { canPhiViewerAccess } from "../types/access";
5
- import { normalizePhiCmsRoutePath, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, resolvePhiCmsRoutePreset, } from "../plugins/runtime-modules/descriptor-compiler";
5
+ import { normalizePhiCmsRoutePath, resolvePhiCmsAreaBaseShellPresetBinding, resolvePhiCmsDescriptorCatalog, resolvePhiCmsRoutePreset, } from "../plugins/runtime-modules/descriptor-compiler";
6
6
  import { resolvePhiAreaRouteScope } from "../server-helpers/cms-request";
7
7
  import { resolvePhiCmsLookup } from "../server-helpers/cms-lookup";
8
8
  import { getPhiCmsPage, getPhiExactSiteArea } from "../server-helpers/cms";
@@ -73,30 +73,24 @@ export function buildPhiNavigationTargetRouteHandler({ loadAreaBridge, }) {
73
73
  const requestContext = await loadPhiSiteRequestContext(bridge.runtime.siteKey, resolvedRoute.locale, cookieHeader, bridge.runtime.apiBaseUrl, bridge.runtime.internalToken);
74
74
  const catalog = resolvePhiCmsDescriptorCatalog(bridge.runtimeModuleCatalog);
75
75
  const areaDefinition = catalog.areaDefinitions.get(area);
76
- const shellBinding = resolvePhiCmsAreaShellPresetBinding(catalog, area);
77
76
  if (!areaDefinition ||
78
- !shellBinding ||
77
+ !resolvePhiCmsAreaBaseShellPresetBinding(catalog, area) ||
79
78
  !canPhiViewerAccess(requestContext.viewer, areaDefinition.accessPolicy)) {
80
79
  return jsonResponse({ available: false });
81
80
  }
82
- const sourcePreset = {
83
- ownerModuleId: shellBinding.descriptor.ownerModuleId,
84
- presetKey: shellBinding.descriptor.presetKey,
85
- };
86
- const areaPreset = await getPhiExactSiteArea({
81
+ const storedArea = await getPhiExactSiteArea({
87
82
  path: resolvedRoute.cmsPath,
88
83
  apiBaseUrl: bridge.runtime.apiBaseUrl,
89
84
  internalToken: bridge.runtime.internalToken,
90
85
  siteKey: bridge.runtime.siteKey,
91
86
  locale: resolvedRoute.locale,
92
87
  cookieHeader,
93
- sourcePreset,
94
88
  });
95
89
  const { routeTable } = resolvePhiAreaRouteScope({
96
90
  runtimeModuleCatalog: bridge.runtimeModuleCatalog,
97
91
  catalog,
98
92
  area,
99
- preset: areaPreset?.preset ?? null,
93
+ read: storedArea,
100
94
  serverCapabilities: requestContext.serverCapabilities,
101
95
  });
102
96
  const storagePath = resolveAreaStoragePath(resolvedRoute.cmsPath, area);
@@ -3,7 +3,7 @@ import "server-only";
3
3
  import { isPhiBuilderAreaKey, isPhiCmsAreaKey } from "../constants/cms-areas";
4
4
  import { canPhiViewerAccess, PHI_VIEWER_ACCESS_CONTENT_EDITING, PHI_VIEWER_ACCESS_STRUCTURE_AUTHORING } from "../types/access";
5
5
  import { resolvePhiBuilderActivePageCatalog } from "../helpers/cms-page-catalog";
6
- import { resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
6
+ import { resolvePhiCmsAreaBaseShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
7
7
  import { buildPhiAreaActivePresetPages } from "../helpers/cms-preset-page-tree";
8
8
  import { buildPhiBuilderPageReferenceTree } from "../helpers/page-reference-tree";
9
9
  import { resolvePhiAreaRouteScope } from "../server-helpers/cms-request";
@@ -43,8 +43,7 @@ export function buildPhiPageReferencesRouteHandler({ loadAreaBridge, }) {
43
43
  }
44
44
  try {
45
45
  const catalog = resolvePhiCmsDescriptorCatalog(bridge.runtimeModuleCatalog);
46
- const shellBinding = resolvePhiCmsAreaShellPresetBinding(catalog, area);
47
- const areaPreset = shellBinding
46
+ const storedArea = resolvePhiCmsAreaBaseShellPresetBinding(catalog, area)
48
47
  ? await getPhiExactSiteArea({
49
48
  path: area === "public" ? "/" : `/${area}`,
50
49
  apiBaseUrl: runtime.apiBaseUrl,
@@ -52,17 +51,13 @@ export function buildPhiPageReferencesRouteHandler({ loadAreaBridge, }) {
52
51
  siteKey: runtime.siteKey,
53
52
  locale,
54
53
  cookieHeader,
55
- sourcePreset: {
56
- ownerModuleId: shellBinding.descriptor.ownerModuleId,
57
- presetKey: shellBinding.descriptor.presetKey,
58
- },
59
54
  })
60
55
  : null;
61
56
  const { routeTable } = resolvePhiAreaRouteScope({
62
57
  runtimeModuleCatalog: bridge.runtimeModuleCatalog,
63
58
  catalog,
64
59
  area,
65
- preset: areaPreset?.preset ?? null,
60
+ read: storedArea,
66
61
  serverCapabilities: requestContext.serverCapabilities,
67
62
  });
68
63
  const persistedPages = await getSiteCmsPageCatalog({
@@ -1,6 +1,6 @@
1
1
  import "server-only";
2
2
  import type { PhiCmsReviewParams } from "../server-helpers/cms-review";
3
- import type { PhiResolvedCmsAreaPresetPayload } from "../types/cms";
3
+ import type { PhiCmsAreaModulesSelection, PhiResolvedCmsAreaPresetPayload } from "../types/cms";
4
4
  import type { PhiCmsPresetIdentity } from "../types/cms-module-descriptors";
5
5
  export type GetExactSiteAreaOptions = {
6
6
  apiBaseUrl: string;
@@ -12,9 +12,36 @@ export type GetExactSiteAreaOptions = {
12
12
  revision?: number | null;
13
13
  review?: PhiCmsReviewParams | null;
14
14
  cookieHeader?: string | null;
15
- sourcePreset: PhiCmsPresetIdentity;
15
+ /**
16
+ * The shell identity the structure is asked for. Without one Core answers the one structure the Area
17
+ * stores, under whatever identity it stands on: what a page view reads, because which shell applies is
18
+ * known only from the selection in the same answer. A revision or review read answers a structure only
19
+ * under the identity it names.
20
+ */
21
+ sourcePreset?: PhiCmsPresetIdentity | null;
16
22
  };
17
- export declare const getExactSiteArea: (options: GetExactSiteAreaOptions) => Promise<PhiResolvedCmsAreaPresetPayload | null>;
23
+ /**
24
+ * What Core stores about an Area, as the live Area read answers it: the Module selection and the
25
+ * structure, each apart from the other (CMS.md, "The Area's Module selection").
26
+ */
27
+ export type PhiSiteAreaRead = {
28
+ areaMask: number;
29
+ /** The Module selection, published or the reviewed one; null when the Area never stored one. */
30
+ modules: PhiCmsAreaModulesSelection | null;
31
+ /**
32
+ * The stored structure under the identity it stands on, `sourcePreset` included; null when none is
33
+ * stored (or none under the identity asked for). Whether it applies is the caller's question: only
34
+ * when its identity is the Area's effective shell.
35
+ */
36
+ structure: PhiResolvedCmsAreaPresetPayload | null;
37
+ /** The revision a preview or review read answered with. */
38
+ revisionId?: number;
39
+ };
40
+ /**
41
+ * The Area read (`GET /api/v1/site/area`). Live it always answers; a revision or review read answers
42
+ * `null` for a revision that is not there -- or, for a structure revision, not under the identity named.
43
+ */
44
+ export declare const getExactSiteArea: (options: GetExactSiteAreaOptions) => Promise<PhiSiteAreaRead | null>;
18
45
  export type PhiPublishedPage = {
19
46
  path: string | null;
20
47
  ownerModuleId: string | null;
@@ -23,8 +50,8 @@ export type PhiPublishedPage = {
23
50
  publishedAt: string;
24
51
  };
25
52
  export type PhiAreaWithPublishedPages = {
26
- /** Null while the Area has never been published; the code-owned preset answers then. */
27
- area: PhiResolvedCmsAreaPresetPayload | null;
53
+ /** The live Area read without an identity: the selection and the stored structure, each or neither. */
54
+ area: PhiSiteAreaRead;
28
55
  publishedPages: PhiPublishedPage[];
29
56
  };
30
57
  /**
@@ -36,7 +63,7 @@ export type PhiAreaWithPublishedPages = {
36
63
  * anonymous only, so no cookie is sent and no draft can be asked for. Core answers it for the Public
37
64
  * and the App Area, the two anything indexes (SEARCH.md).
38
65
  */
39
- export declare function getSiteAreaWithPublishedPages({ apiBaseUrl, internalToken, siteKey, locale, sourcePreset, area, }: Pick<GetExactSiteAreaOptions, "apiBaseUrl" | "internalToken" | "siteKey" | "locale" | "sourcePreset"> & {
66
+ export declare function getSiteAreaWithPublishedPages({ apiBaseUrl, internalToken, siteKey, locale, area, }: Pick<GetExactSiteAreaOptions, "apiBaseUrl" | "internalToken" | "siteKey" | "locale"> & {
40
67
  area?: "public" | "app";
41
68
  }): Promise<PhiAreaWithPublishedPages>;
42
69
  type PhiSiteAreaStructureRequest = {
@@ -49,11 +76,21 @@ type PhiSiteAreaStructure = {
49
76
  /** The open draft; when there is one, `published` is not read. */
50
77
  draft: PhiResolvedCmsAreaPresetPayload | null;
51
78
  published: PhiResolvedCmsAreaPresetPayload | null;
79
+ /** The Area's Module selection, whatever identity was asked: the open Module draft, else what is published. */
80
+ modules: {
81
+ draft: (PhiCmsAreaModulesSelection & {
82
+ version: number;
83
+ nextNodeSequence: number;
84
+ }) | null;
85
+ published: PhiCmsAreaModulesSelection | null;
86
+ };
52
87
  };
53
88
  /**
54
89
  * What several Areas store about their structure, in one request: per Area its open draft, else what is
55
90
  * published, else nothing -- for each the answer of the draft read (`GET /api/site/cms/area/draft`) or of
56
91
  * `getExactSiteArea`, without a request per Area and read (phis-server `POST /api/site/cms/area/structures`).
92
+ * Each entry also carries the Area's Module selection, which names no identity. An Area may be asked more
93
+ * than once, under each shell identity it could stand on: the structure answers only under its own.
57
94
  */
58
95
  export declare const getSiteAreaStructures: (options: {
59
96
  apiBaseUrl: string;