@phis/ui 0.6.10 → 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 (115) 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/controls/phi-padding-control.js +18 -5
  10. package/components/layouts/layout-definitions.d.ts +8 -0
  11. package/components/regions/presets/phi-base-page-column.js +1 -2
  12. package/components/regions/presets/phi-header-top-actions-layout.d.ts +2 -2
  13. package/components/regions/presets/phi-header-top-actions-layout.js +2 -4
  14. package/components/regions/presets/phi-settings-page-shell-tree.js +0 -2
  15. package/components/widgets/label-sets/padding.js +2 -0
  16. package/components/widgets/label-sets/region.js +2 -0
  17. package/components/widgets/label-types/padding.d.ts +2 -0
  18. package/components/widgets/label-types/padding.js +1 -0
  19. package/components/widgets/label-types/region.d.ts +2 -0
  20. package/components/widgets/label-types/region.js +1 -0
  21. package/components/widgets/label-types/revisions.js +2 -2
  22. package/components/workspace/catalog-state.d.ts +17 -1
  23. package/components/workspace/catalog-store.js +1 -0
  24. package/gateway/dashboard-cards-route.js +4 -9
  25. package/gateway/form-handler-resolution.js +10 -34
  26. package/gateway/navigation-target-route.js +4 -10
  27. package/gateway/page-references-route.js +3 -8
  28. package/gateway/site-area.d.ts +43 -6
  29. package/gateway/site-area.js +70 -17
  30. package/helpers/cms-area-config.d.ts +36 -14
  31. package/helpers/cms-area-config.js +72 -26
  32. package/helpers/cms-dialog.d.ts +0 -1
  33. package/helpers/cms-dialog.js +0 -1
  34. package/helpers/cms-layout-defaults.d.ts +4 -0
  35. package/helpers/cms-layout-defaults.js +14 -17
  36. package/helpers/cms-region-keys.d.ts +1 -1
  37. package/helpers/page-layout-check.js +4 -1
  38. package/next/seo-routes.js +24 -28
  39. package/package.json +2 -2
  40. package/plugins/runtime-modules/accounting/presets.d.ts +0 -1
  41. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-area-preset-tree.js +0 -2
  42. package/plugins/runtime-modules/admin/presets.d.ts +0 -1
  43. package/plugins/runtime-modules/admin/trees/phi-default-admin-area-preset-tree.js +0 -2
  44. package/plugins/runtime-modules/app/presets.d.ts +0 -1
  45. package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.js +0 -2
  46. package/plugins/runtime-modules/area-definitions.d.ts +17 -0
  47. package/plugins/runtime-modules/area-definitions.js +6 -0
  48. package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +0 -2
  49. package/plugins/runtime-modules/builder/area-shell-presets.server.d.ts +21 -5
  50. package/plugins/runtime-modules/builder/area-shell-presets.server.js +171 -63
  51. package/plugins/runtime-modules/builder/clients/shells-workspace.js +12 -1
  52. package/plugins/runtime-modules/builder/controller/client.js +2 -0
  53. package/plugins/runtime-modules/builder/controller/definition.d.ts +1 -0
  54. package/plugins/runtime-modules/builder/controller/draft-command-controller.d.ts +2 -3
  55. package/plugins/runtime-modules/builder/controller/draft-command-controller.js +56 -25
  56. package/plugins/runtime-modules/builder/controller/draft-status-controller.js +13 -7
  57. package/plugins/runtime-modules/builder/controller/server-definition.d.ts +1 -0
  58. package/plugins/runtime-modules/builder/controller/server-definition.js +7 -4
  59. package/plugins/runtime-modules/builder/controller/workspace-controller.d.ts +2 -1
  60. package/plugins/runtime-modules/builder/controller/workspace-controller.js +9 -3
  61. package/plugins/runtime-modules/builder/data-providers.d.ts +1 -1
  62. package/plugins/runtime-modules/builder/definition.d.ts +1 -1
  63. package/plugins/runtime-modules/builder/developer-workspace-store.js +1 -0
  64. package/plugins/runtime-modules/builder/page-preset-catalog.server.d.ts +0 -2
  65. package/plugins/runtime-modules/builder/page-preset-catalog.server.js +0 -16
  66. package/plugins/runtime-modules/builder/persistence.d.ts +20 -25
  67. package/plugins/runtime-modules/builder/persistence.js +67 -75
  68. package/plugins/runtime-modules/builder/services/runtime-modules-table.d.ts +17 -0
  69. package/plugins/runtime-modules/builder/services/runtime-modules-table.js +79 -2
  70. package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +0 -1
  71. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.d.ts +0 -1
  72. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +1 -10
  73. package/plugins/runtime-modules/builder/workspace-catalog-actions.d.ts +2 -1
  74. package/plugins/runtime-modules/builder/workspace-catalog-actions.js +3 -1
  75. package/plugins/runtime-modules/core/widgets/cascader/authoring.d.ts +1 -1
  76. package/plugins/runtime-modules/descriptor-compiler.d.ts +16 -2
  77. package/plugins/runtime-modules/descriptor-compiler.js +69 -13
  78. package/plugins/runtime-modules/editor/services/releases-table.js +26 -14
  79. package/plugins/runtime-modules/editor/trees/phi-default-editor-area-preset-tree.js +0 -2
  80. package/plugins/runtime-modules/groups/definition.d.ts +1 -1
  81. package/plugins/runtime-modules/localization/trees/phi-default-admin-locales-page-tree.js +0 -2
  82. package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +0 -4
  83. package/plugins/runtime-modules/revisions/controller/client.js +13 -7
  84. package/plugins/runtime-modules/revisions/services/table.js +10 -3
  85. package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +0 -1
  86. package/plugins/runtime-modules/shell-tree-composition.d.ts +0 -2
  87. package/plugins/runtime-modules/shell-tree-composition.js +0 -3
  88. package/plugins/runtime-modules/theme/trees/phi-default-builder-theme-page-tree.js +0 -6
  89. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +17 -1
  90. package/server-helpers/area-root-door-warmup.d.ts +5 -2
  91. package/server-helpers/area-root-door-warmup.js +2 -10
  92. package/server-helpers/cms-area.d.ts +9 -1
  93. package/server-helpers/cms-area.js +16 -11
  94. package/server-helpers/cms-lookup.js +1 -1
  95. package/server-helpers/cms-request.d.ts +58 -13
  96. package/server-helpers/cms-request.js +103 -33
  97. package/server-helpers/cms-root.d.ts +4 -0
  98. package/server-helpers/cms-root.js +48 -35
  99. package/server-helpers/cms.d.ts +5 -5
  100. package/server-helpers/public-login-route.js +4 -9
  101. package/server-helpers/search-index.js +9 -14
  102. package/styles/shell.css +12 -0
  103. package/theme/antd-css-var-contract.d.ts +6 -0
  104. package/theme/antd-css-var-contract.js +6 -0
  105. package/theme/phi-theme-tokens.d.ts +3 -2
  106. package/theme/phi-theme-tokens.js +11 -1
  107. package/theme/phi-theme.d.ts +2 -0
  108. package/theme/phi-theme.js +2 -0
  109. package/theme/phi-tokens.d.ts +1 -0
  110. package/theme/phi-tokens.js +7 -0
  111. package/theme.d.ts +1 -1
  112. package/theme.js +1 -1
  113. package/types/cms-module-descriptors.d.ts +26 -1
  114. package/types/cms-plugins.d.ts +3 -0
  115. package/types/cms.d.ts +10 -3
@@ -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;
@@ -2,12 +2,53 @@ import { isPhiRecord } from "../helpers/is-record";
2
2
  import { definePhiRequestMemo } from "../server-helpers/request-memo";
3
3
  import "server-only";
4
4
  import { fetchPhiSiteApi } from "./site-api-request";
5
+ function readAreaModulesSelection(value, context) {
6
+ if (value === null || value === undefined) {
7
+ return null;
8
+ }
9
+ if (!isPhiRecord(value) ||
10
+ !Number.isSafeInteger(value.revisionId) ||
11
+ value.revisionId <= 0 ||
12
+ !isPhiRecord(value.config)) {
13
+ throw new Error(`Invalid Area Module selection in ${context}.`);
14
+ }
15
+ return { revisionId: value.revisionId, config: value.config };
16
+ }
17
+ function readAreaStructure(areaMask, sourcePreset, preset, context) {
18
+ if (preset === null || preset === undefined) {
19
+ return null;
20
+ }
21
+ if (!isPhiRecord(preset) || !isPhiRecord(preset.preset) || !isPhiRecord(sourcePreset)) {
22
+ throw new Error(`Missing CMS area structure in ${context}.`);
23
+ }
24
+ return {
25
+ areaMask,
26
+ sourcePreset: sourcePreset,
27
+ preset: preset,
28
+ };
29
+ }
30
+ function readSiteAreaRead(body, context) {
31
+ if (!isPhiRecord(body) || !Number.isSafeInteger(body.areaMask)) {
32
+ throw new Error(`Missing CMS area payload in ${context}.`);
33
+ }
34
+ const areaMask = body.areaMask;
35
+ return {
36
+ areaMask,
37
+ modules: readAreaModulesSelection(body.modules, context),
38
+ structure: readAreaStructure(areaMask, body.sourcePreset, body.preset, context),
39
+ ...(Number.isSafeInteger(body.revisionId) ? { revisionId: body.revisionId } : {}),
40
+ };
41
+ }
42
+ /**
43
+ * The Area read (`GET /api/v1/site/area`). Live it always answers; a revision or review read answers
44
+ * `null` for a revision that is not there -- or, for a structure revision, not under the identity named.
45
+ */
5
46
  export const getExactSiteArea = definePhiRequestMemo(async function getExactSiteArea({ apiBaseUrl, internalToken, siteKey, path, locale, revision, review, cookieHeader, sourcePreset, }) {
6
- const searchParams = new URLSearchParams({
7
- path,
8
- ownerModuleId: sourcePreset.ownerModuleId,
9
- presetKey: sourcePreset.presetKey,
10
- });
47
+ const searchParams = new URLSearchParams({ path });
48
+ if (sourcePreset) {
49
+ searchParams.set("ownerModuleId", sourcePreset.ownerModuleId);
50
+ searchParams.set("presetKey", sourcePreset.presetKey);
51
+ }
11
52
  if (Number.isInteger(revision) && revision > 0) {
12
53
  searchParams.set("revision", String(revision));
13
54
  }
@@ -27,13 +68,7 @@ export const getExactSiteArea = definePhiRequestMemo(async function getExactSite
27
68
  failure: "Failed to fetch exact CMS area",
28
69
  notFoundIsNull: true,
29
70
  });
30
- if (payload === null) {
31
- return null;
32
- }
33
- if (!payload?.preset?.preset) {
34
- throw new Error("Missing CMS area payload.");
35
- }
36
- return payload;
71
+ return payload === null ? null : readSiteAreaRead(payload, "getExactSiteArea");
37
72
  });
38
73
  function readPublishedPage(entry) {
39
74
  if (!isPhiRecord(entry)) {
@@ -65,7 +100,7 @@ function readPublishedPage(entry) {
65
100
  * anonymous only, so no cookie is sent and no draft can be asked for. Core answers it for the Public
66
101
  * and the App Area, the two anything indexes (SEARCH.md).
67
102
  */
68
- export async function getSiteAreaWithPublishedPages({ apiBaseUrl, internalToken, siteKey, locale, sourcePreset, area = "public", }) {
103
+ export async function getSiteAreaWithPublishedPages({ apiBaseUrl, internalToken, siteKey, locale, area = "public", }) {
69
104
  const payload = await fetchPhiSiteApi({
70
105
  context: "getSiteAreaWithPublishedPages",
71
106
  apiBaseUrl,
@@ -75,22 +110,37 @@ export async function getSiteAreaWithPublishedPages({ apiBaseUrl, internalToken,
75
110
  searchParams: {
76
111
  // Core reads the Area off the path's first segment; Public has none.
77
112
  path: area === "public" ? "/" : `/${area}`,
78
- ownerModuleId: sourcePreset.ownerModuleId,
79
- presetKey: sourcePreset.presetKey,
80
113
  include: "publishedPages",
81
114
  },
82
115
  locale,
83
116
  failure: `Failed to fetch the ${area} Area with its Pages`,
84
117
  userAgent: "phis-ui-sitemap/1.0",
85
118
  });
86
- if (!payload || !Array.isArray(payload.publishedPages)) {
119
+ if (!isPhiRecord(payload) || !Array.isArray(payload.publishedPages)) {
87
120
  throw new Error("Missing published Page projection.");
88
121
  }
89
122
  return {
90
- area: payload.preset ? payload : null,
123
+ area: readSiteAreaRead(payload, "getSiteAreaWithPublishedPages"),
91
124
  publishedPages: payload.publishedPages.map(readPublishedPage),
92
125
  };
93
126
  }
127
+ function readAreaModulesStructure(value, area) {
128
+ if (!isPhiRecord(value)) {
129
+ throw new Error(`Missing CMS area Module selection for "${area}".`);
130
+ }
131
+ const context = `the structures read of "${area}"`;
132
+ const draft = readAreaModulesSelection(value.draft ?? null, context);
133
+ const draftRecord = isPhiRecord(value.draft) ? value.draft : null;
134
+ if (draft && (!Number.isSafeInteger(draftRecord?.version) || !Number.isSafeInteger(draftRecord?.nextNodeSequence))) {
135
+ throw new Error(`Invalid Area Module draft in ${context}.`);
136
+ }
137
+ return {
138
+ draft: draft
139
+ ? { ...draft, version: draftRecord.version, nextNodeSequence: draftRecord.nextNodeSequence }
140
+ : null,
141
+ published: draft ? null : readAreaModulesSelection(value.published ?? null, context),
142
+ };
143
+ }
94
144
  function readAreaStructurePayload(value, area, kind) {
95
145
  if (value === null) {
96
146
  return null;
@@ -104,6 +154,8 @@ function readAreaStructurePayload(value, area, kind) {
104
154
  * What several Areas store about their structure, in one request: per Area its open draft, else what is
105
155
  * published, else nothing -- for each the answer of the draft read (`GET /api/site/cms/area/draft`) or of
106
156
  * `getExactSiteArea`, without a request per Area and read (phis-server `POST /api/site/cms/area/structures`).
157
+ * Each entry also carries the Area's Module selection, which names no identity. An Area may be asked more
158
+ * than once, under each shell identity it could stand on: the structure answers only under its own.
107
159
  */
108
160
  export const getSiteAreaStructures = definePhiRequestMemo(async function getSiteAreaStructures({ apiBaseUrl, internalToken, siteKey, locale, cookieHeader, areas, }) {
109
161
  const payload = await fetchPhiSiteApi({
@@ -131,6 +183,7 @@ export const getSiteAreaStructures = definePhiRequestMemo(async function getSite
131
183
  area: request.area,
132
184
  draft: readAreaStructurePayload(answer.draft ?? null, request.area, "draft"),
133
185
  published: readAreaStructurePayload(answer.published ?? null, request.area, "published"),
186
+ modules: readAreaModulesStructure(answer.modules, request.area),
134
187
  };
135
188
  });
136
189
  });
@@ -1,15 +1,15 @@
1
1
  import type { PhiBuilderAreaKey } from "../constants/cms-areas";
2
2
  import type { PhiRuntimeModuleId } from "../types";
3
- import type { PhiResolvedCmsAreaPresetTree } from "../types/cms";
3
+ import type { PhiCmsAreaModulesSelection } from "../types/cms";
4
4
  import type { PhiCmsInstanceId } from "../types/cms-instance-id";
5
5
  import { type PhiPageReference } from "../types/references";
6
6
  /**
7
7
  * The two halves of an Area preset config, expressed as a path rather than as a list of field names.
8
8
  *
9
9
  * An Area is edited from two workspaces that own different things: its structure on `/builder/shells`,
10
- * its Module selection on `/builder/modules`. Which one may write a given value used to be a convention
11
- * kept by the client and a comment in the server's publish merge; naming the halves makes it a path,
12
- * and the write routes reject a payload that carries the other one.
10
+ * its Module selection on `/builder/modules`. The two are stored apart: `config.shell` in the structure
11
+ * revisions, `config.modules` in the Modules revisions, and each write route rejects a payload that
12
+ * carries the other one.
13
13
  *
14
14
  * A Shell Background is not in here, and that is not an oversight: it belongs to a Region and travels
15
15
  * in the structure tree. What lives under `shell` is what the Shell states about itself rather than
@@ -18,19 +18,17 @@ import { type PhiPageReference } from "../types/references";
18
18
  export declare const PHI_AREA_CONFIG_SHELL_NAMESPACE: "shell";
19
19
  export declare const PHI_AREA_CONFIG_MODULES_NAMESPACE: "modules";
20
20
  /**
21
- * The Modules an Area preset actually activates.
21
+ * The Modules an Area's selection activates.
22
22
  *
23
- * Absent and empty are different answers and are read as different answers: nothing stated is an Area
24
- * that was never asked, and it gets the selection its preset ships with; `[]` is a Builder who
25
- * switched everything off, and it gets nothing.
23
+ * The selection is stored apart from the structure (`PhiCmsAreaModulesSelection`, one Modules revision
24
+ * whose config is `{ modules }`), because the shell an Area takes depends on it and so it has to be read
25
+ * before the shell is known. A structure tree never carries it.
26
26
  *
27
- * The distinction is load-bearing rather than pedantic. A stored Area preset need not carry the
28
- * Modules namespace at all -- the structure draft owns `config.shell` and writes only that -- so
29
- * reading an absent selection as an empty one would let the first structure save of an Area whose
30
- * Modules were never published turn every optional Module off, silently, and take the Pages they carry
31
- * with them.
27
+ * Absent and empty are different answers and are read as different answers: no selection stored is an
28
+ * Area that was never asked, and it gets the default list (`createPhiDefaultAreaRuntimeModuleIds`); `[]`
29
+ * is a Builder who switched everything off, and it gets nothing.
32
30
  */
33
- export declare function readPhiAreaPresetRuntimeModuleIds(tree: Pick<PhiResolvedCmsAreaPresetTree, "runtimeModuleIds" | "preset"> | null | undefined, area: PhiBuilderAreaKey): PhiRuntimeModuleId[];
31
+ export declare function readPhiAreaSelectionRuntimeModuleIds(selection: Pick<PhiCmsAreaModulesSelection, "config"> | null | undefined, area: PhiBuilderAreaKey): PhiRuntimeModuleId[];
34
32
  export declare const PHI_AREA_ROOT_ROUTE_KEY: "rootRoute";
35
33
  /**
36
34
  * What an Area's `/` resolves to.
@@ -189,6 +187,30 @@ export declare const PHI_AREA_META_PUBLIC_DEFAULTS: {
189
187
  */
190
188
  export declare const PHI_AREA_TITLE_TEMPLATE_PLACEHOLDER: "%s";
191
189
  export declare function readPhiAreaMeta(config: Record<string, unknown> | null | undefined): PhiAreaMeta | null;
190
+ /**
191
+ * What an Area shell preset may propose for the Area's settings (`PhiCmsAreaShellPresetDescriptor`),
192
+ * under the keys a Builder save stores them under in `config.shell`.
193
+ */
194
+ export type PhiAreaShellSettings = {
195
+ meta?: PhiAreaMeta;
196
+ rootRoute?: PhiAreaRootRoute;
197
+ };
198
+ /**
199
+ * A shell preset's proposal as the Area config it stands for, read by the same readers as a stored one.
200
+ *
201
+ * Empty for a shell that proposes nothing, which is phis-ui's defaults answering. The answer of an Area
202
+ * that stores a structure on its shell, never this, wherever that structure exists: a Site that saved
203
+ * once has answered, even where it answered with what was proposed.
204
+ */
205
+ export declare function buildPhiAreaShellPresetConfig(settings: PhiAreaShellSettings | null | undefined): Record<string, unknown>;
206
+ /**
207
+ * Why a shell preset's proposal cannot be read as it is written, or null when it can.
208
+ *
209
+ * Strict on purpose (a wrong type is an error, never a silent default): what a package declares here is
210
+ * what every Site that switches it on is served until it saves, so a key the readers drop would be a
211
+ * setting the package believes it made.
212
+ */
213
+ export declare function describePhiAreaShellSettingsError(settings: unknown): string | null;
192
214
  export declare const PHI_AREA_PUBLIC_ROUTE_PATHS_KEY: "publicRoutePaths";
193
215
  /**
194
216
  * A Public address a Module route was given instead of the one it declared.
@@ -6,9 +6,9 @@ import { createPhiPresetCmsPageId, readPhiLinkTarget, readPhiPageReference, } fr
6
6
  * The two halves of an Area preset config, expressed as a path rather than as a list of field names.
7
7
  *
8
8
  * An Area is edited from two workspaces that own different things: its structure on `/builder/shells`,
9
- * its Module selection on `/builder/modules`. Which one may write a given value used to be a convention
10
- * kept by the client and a comment in the server's publish merge; naming the halves makes it a path,
11
- * and the write routes reject a payload that carries the other one.
9
+ * its Module selection on `/builder/modules`. The two are stored apart: `config.shell` in the structure
10
+ * revisions, `config.modules` in the Modules revisions, and each write route rejects a payload that
11
+ * carries the other one.
12
12
  *
13
13
  * A Shell Background is not in here, and that is not an oversight: it belongs to a Region and travels
14
14
  * in the structure tree. What lives under `shell` is what the Shell states about itself rather than
@@ -23,32 +23,18 @@ function readPhiAreaConfigNamespace(config, namespace) {
23
23
  : undefined;
24
24
  }
25
25
  /**
26
- * The Module selection an Area preset carries.
26
+ * The Modules an Area's selection activates.
27
27
  *
28
- * `runtimeModuleIds` is the resolved field the payload already carries when it has one; the stored
29
- * config is what a Site that persisted its Area falls back to. Both readings sit here so the namespace
30
- * appears once rather than at every call site that needs the selection.
31
- */
32
- function readPhiAreaPresetRuntimeModules(tree) {
33
- return tree?.runtimeModuleIds
34
- ?? readPhiAreaConfigNamespace(tree?.preset.config, PHI_AREA_CONFIG_MODULES_NAMESPACE)?.runtimeModules;
35
- }
36
- /**
37
- * The Modules an Area preset actually activates.
38
- *
39
- * Absent and empty are different answers and are read as different answers: nothing stated is an Area
40
- * that was never asked, and it gets the selection its preset ships with; `[]` is a Builder who
41
- * switched everything off, and it gets nothing.
28
+ * The selection is stored apart from the structure (`PhiCmsAreaModulesSelection`, one Modules revision
29
+ * whose config is `{ modules }`), because the shell an Area takes depends on it and so it has to be read
30
+ * before the shell is known. A structure tree never carries it.
42
31
  *
43
- * The distinction is load-bearing rather than pedantic. A stored Area preset need not carry the
44
- * Modules namespace at all -- the structure draft owns `config.shell` and writes only that -- so
45
- * reading an absent selection as an empty one would let the first structure save of an Area whose
46
- * Modules were never published turn every optional Module off, silently, and take the Pages they carry
47
- * with them.
32
+ * Absent and empty are different answers and are read as different answers: no selection stored is an
33
+ * Area that was never asked, and it gets the default list (`createPhiDefaultAreaRuntimeModuleIds`); `[]`
34
+ * is a Builder who switched everything off, and it gets nothing.
48
35
  */
49
- export function readPhiAreaPresetRuntimeModuleIds(tree, area) {
50
- return readPhiRuntimeModuleIds(readPhiAreaPresetRuntimeModules(tree))
51
- ?? createPhiDefaultAreaRuntimeModuleIds(area);
36
+ export function readPhiAreaSelectionRuntimeModuleIds(selection, area) {
37
+ return readPhiRuntimeModuleIds(readPhiAreaConfigNamespace(selection?.config, PHI_AREA_CONFIG_MODULES_NAMESPACE)?.runtimeModules) ?? createPhiDefaultAreaRuntimeModuleIds(area);
52
38
  }
53
39
  export const PHI_AREA_ROOT_ROUTE_KEY = "rootRoute";
54
40
  export function readPhiAreaRootRoute(config) {
@@ -179,6 +165,66 @@ export function readPhiAreaMeta(config) {
179
165
  ...(typeof record.defaultTitle === "string" ? { defaultTitle: record.defaultTitle } : {}),
180
166
  };
181
167
  }
168
+ /**
169
+ * A shell preset's proposal as the Area config it stands for, read by the same readers as a stored one.
170
+ *
171
+ * Empty for a shell that proposes nothing, which is phis-ui's defaults answering. The answer of an Area
172
+ * that stores a structure on its shell, never this, wherever that structure exists: a Site that saved
173
+ * once has answered, even where it answered with what was proposed.
174
+ */
175
+ export function buildPhiAreaShellPresetConfig(settings) {
176
+ if (!settings || (settings.meta === undefined && settings.rootRoute === undefined)) {
177
+ return {};
178
+ }
179
+ return {
180
+ [PHI_AREA_CONFIG_SHELL_NAMESPACE]: {
181
+ ...(settings.meta !== undefined ? { [PHI_AREA_META_KEY]: settings.meta } : {}),
182
+ ...(settings.rootRoute !== undefined ? { [PHI_AREA_ROOT_ROUTE_KEY]: settings.rootRoute } : {}),
183
+ },
184
+ };
185
+ }
186
+ /**
187
+ * Why a shell preset's proposal cannot be read as it is written, or null when it can.
188
+ *
189
+ * Strict on purpose (a wrong type is an error, never a silent default): what a package declares here is
190
+ * what every Site that switches it on is served until it saves, so a key the readers drop would be a
191
+ * setting the package believes it made.
192
+ */
193
+ export function describePhiAreaShellSettingsError(settings) {
194
+ if (settings === undefined) {
195
+ return null;
196
+ }
197
+ if (!isPhiRecord(settings)) {
198
+ return "settings must be an object";
199
+ }
200
+ const unknownKey = Object.keys(settings).find((key) => key !== PHI_AREA_META_KEY && key !== PHI_AREA_ROOT_ROUTE_KEY);
201
+ if (unknownKey) {
202
+ return `settings.${unknownKey} is not an Area setting (meta, rootRoute)`;
203
+ }
204
+ const config = buildPhiAreaShellPresetConfig(settings);
205
+ if (settings.meta !== undefined) {
206
+ if (!isPhiRecord(settings.meta)) {
207
+ return "settings.meta must be an object";
208
+ }
209
+ const read = readPhiAreaMeta(config) ?? {};
210
+ const dropped = Object.keys(settings.meta).find((key) => read[key] !== settings.meta[key]);
211
+ if (dropped) {
212
+ return `settings.meta.${dropped} is not a readable Area meta value`;
213
+ }
214
+ if (read.titleTemplate !== undefined && !read.titleTemplate.includes(PHI_AREA_TITLE_TEMPLATE_PLACEHOLDER)) {
215
+ return `settings.meta.titleTemplate must hold "${PHI_AREA_TITLE_TEMPLATE_PLACEHOLDER}"`;
216
+ }
217
+ }
218
+ if (settings.rootRoute !== undefined) {
219
+ const read = readPhiAreaRootRoute(config);
220
+ const written = settings.rootRoute;
221
+ // A landing reads even with an unreadable target (as none), so the target is checked on its own.
222
+ if (!read || read.mode !== written.mode || (read.mode === "landing" && written.target !== undefined && !read.target)) {
223
+ return "settings.rootRoute is not a readable root route";
224
+ }
225
+ }
226
+ return null;
227
+ }
182
228
  export const PHI_AREA_PUBLIC_ROUTE_PATHS_KEY = "publicRoutePaths";
183
229
  const PHI_PUBLIC_ROUTE_PATH_SEGMENT_PATTERN = /^[\p{L}\p{N}][\p{L}\p{N}._~-]*$/u;
184
230
  /**
@@ -1,7 +1,6 @@
1
1
  import { type PhiFormDescriptor } from "@phis/contracts/forms";
2
2
  /** The body Layout's config: a vertical Flex with the `panel` creation preset under it. */
3
3
  export declare const PHI_DIALOG_BODY_CONFIG: {
4
- readonly gap: "var(--phi-padding-sm)";
5
4
  readonly margin: 0;
6
5
  readonly padding: "var(--phi-padding)";
7
6
  readonly surface: {
@@ -25,7 +25,6 @@ import { PHI_LAYOUT } from "../theme/phi-tokens";
25
25
  */
26
26
  /** The body Layout's config: a vertical Flex with the `panel` creation preset under it. */
27
27
  export const PHI_DIALOG_BODY_CONFIG = {
28
- gap: PHI_SPACE.sm,
29
28
  margin: 0,
30
29
  padding: PHI_SPACE.base,
31
30
  surface: PHI_SURFACE_WASH,
@@ -4,6 +4,10 @@ export type PhiLayoutDefaults = JsonRecord;
4
4
  export type PhiLayoutCreationPreset = "panel" | "overlay-actions" | "page-base";
5
5
  export declare const PHI_SPLIT_CARD_LAYOUT_DEFAULTS: PhiLayoutDefaults;
6
6
  export declare const PHI_SPLIT_CARD_LAYOUT_CREATION_CONFIG: {
7
+ readonly anchor: {
8
+ readonly horizontal: "center";
9
+ readonly vertical: "middle";
10
+ };
7
11
  readonly surface: {
8
12
  readonly background: {
9
13
  readonly base: {
@@ -1,4 +1,4 @@
1
- import { PHI_SPACE } from "../theme/antd-css-var-contract";
1
+ import { PHI_LAYOUT_GAP, PHI_SPACE } from "../theme/antd-css-var-contract";
2
2
  import { PHI_RENDERABLE_BLOCK_DEFAULT_ANCHOR } from "./renderable-block-defaults";
3
3
  import { isPhiRecord } from "./is-record";
4
4
  import { PHI_SEQUENCE_DEFAULT_DURATION_MS, PHI_SEQUENCE_DEFAULT_EASING } from "./motion";
@@ -8,7 +8,10 @@ import { PHI_MASONRY_LAYOUT_DEFAULT_COLUMNS } from "../components/layouts/phi-ma
8
8
  /*
9
9
  * What a Layout states when its node states nothing.
10
10
  *
11
- * Every gap is the small step (`sm`): one rhythm between children, whatever arranges them. The padding
11
+ * Every gap is the Theme's Layout gap (`PHI_LAYOUT_GAP`, `sm` unless the Theme says otherwise): one rhythm
12
+ * between children, whatever arranges them, and one the Site changes in its Theme. A creation preset
13
+ * therefore states no gap -- what it wrote would be the day's number, not the Theme's -- and a node that
14
+ * states one keeps it; only an Overlay's action row is closer on purpose (`xs`). The padding
12
15
  * follows what the Layout is for. A Layout that only arranges its children -- Content, Flex, the
13
16
  * vertical Flex, Stack, Carousel, Collapsible, Split Card -- has none, so nesting one in another adds
14
17
  * nothing. A Layout that shows a field of tiles -- Grid, Masonry -- keeps them off its edge by the base
@@ -28,9 +31,9 @@ const PHI_CONTENT_LAYOUT_PANEL_PRESET = {
28
31
  };
29
32
  const PHI_FLEX_LAYOUT_DEFAULTS = {
30
33
  distribution: "anchor",
31
- // A fresh row starts left-aligned and vertically centred, its children one small step apart.
34
+ // A fresh row starts left-aligned and vertically centred, its children the Theme's gap apart.
32
35
  anchor: { horizontal: "left", vertical: "middle" },
33
- gap: PHI_SPACE.sm,
36
+ gap: PHI_LAYOUT_GAP,
34
37
  verticalSeparators: false,
35
38
  separatorBeforeFirst: false,
36
39
  separatorSpan: "75%",
@@ -38,7 +41,6 @@ const PHI_FLEX_LAYOUT_DEFAULTS = {
38
41
  };
39
42
  const PHI_FLEX_LAYOUT_PANEL_PRESET = {
40
43
  distribution: "anchor",
41
- gap: PHI_SPACE.sm,
42
44
  verticalSeparators: false,
43
45
  separatorBeforeFirst: false,
44
46
  separatorSpan: "75%",
@@ -63,10 +65,9 @@ const PHI_FLEX_LAYOUT_OVERLAY_ACTIONS_PRESET = {
63
65
  width: "100%",
64
66
  };
65
67
  const PHI_FLEX_VERTICAL_LAYOUT_DEFAULTS = {
66
- gap: PHI_SPACE.sm,
68
+ gap: PHI_LAYOUT_GAP,
67
69
  };
68
70
  const PHI_FLEX_VERTICAL_LAYOUT_PANEL_PRESET = {
69
- gap: PHI_SPACE.sm,
70
71
  padding: PHI_SPACE.base,
71
72
  };
72
73
  /**
@@ -75,7 +76,6 @@ const PHI_FLEX_VERTICAL_LAYOUT_PANEL_PRESET = {
75
76
  * touching this config -- the preset tree contract rejects a deviating copy.
76
77
  */
77
78
  const PHI_FLEX_VERTICAL_LAYOUT_PAGE_BASE_PRESET = {
78
- gap: PHI_SPACE.sm,
79
79
  /*
80
80
  * None: the distance from the screen's edge is the content Region's, the Theme's Page padding in Public
81
81
  * and App (`buildPhiBasePageContentScaffold`). The scaffold only holds its slots together.
@@ -89,22 +89,20 @@ const PHI_FLEX_VERTICAL_LAYOUT_PAGE_BASE_PRESET = {
89
89
  width: "100%",
90
90
  };
91
91
  const PHI_GRID_LAYOUT_DEFAULTS = {
92
- gap: PHI_SPACE.sm,
92
+ gap: PHI_LAYOUT_GAP,
93
93
  padding: PHI_SPACE.base,
94
94
  columns: { ...PHI_GRID_LAYOUT_DEFAULT_COLUMNS },
95
95
  };
96
96
  const PHI_GRID_LAYOUT_PANEL_PRESET = {
97
- gap: PHI_SPACE.sm,
98
97
  padding: PHI_SPACE.base,
99
98
  };
100
99
  const PHI_MASONRY_LAYOUT_DEFAULTS = {
101
100
  columns: { ...PHI_MASONRY_LAYOUT_DEFAULT_COLUMNS },
102
- gap: PHI_SPACE.sm,
101
+ gap: PHI_LAYOUT_GAP,
103
102
  padding: PHI_SPACE.base,
104
103
  };
105
104
  const PHI_MASONRY_LAYOUT_PANEL_PRESET = {
106
105
  columns: { ...PHI_MASONRY_LAYOUT_DEFAULT_COLUMNS },
107
- gap: PHI_SPACE.sm,
108
106
  padding: PHI_SPACE.base,
109
107
  };
110
108
  const PHI_STACK_LAYOUT_DEFAULTS = {
@@ -181,13 +179,13 @@ const PHI_COLLAPSIBLE_LAYOUT_PANEL_PRESET = {
181
179
  /** A split card centres what stands in its cards, on both axes, unless it says otherwise. */
182
180
  const PHI_SPLIT_CARD_LAYOUT_DEFAULT_ANCHOR = { horizontal: "center", vertical: "middle" };
183
181
  /*
184
- * The two cards stand the small step apart. Their padding -- the distance from a card's edge to what
182
+ * The two cards stand the Theme's Layout gap apart. Their padding -- the distance from a card's edge to what
185
183
  * stands in it, as every Layout's padding is the distance from its own edge to its slots -- is none
186
184
  * until somebody states one.
187
185
  */
188
186
  export const PHI_SPLIT_CARD_LAYOUT_DEFAULTS = {
189
187
  anchor: PHI_SPLIT_CARD_LAYOUT_DEFAULT_ANCHOR,
190
- gap: PHI_SPACE.sm,
188
+ gap: PHI_LAYOUT_GAP,
191
189
  };
192
190
  /*
193
191
  * What a Split Card is created with: spaced, and its two halves drawn as cards. The Surface is the
@@ -195,20 +193,19 @@ export const PHI_SPLIT_CARD_LAYOUT_DEFAULTS = {
195
193
  * Card whose author took the cards away would have them back on the next render.
196
194
  */
197
195
  export const PHI_SPLIT_CARD_LAYOUT_CREATION_CONFIG = {
198
- ...PHI_SPLIT_CARD_LAYOUT_DEFAULTS,
196
+ anchor: PHI_SPLIT_CARD_LAYOUT_DEFAULT_ANCHOR,
199
197
  surface: PHI_SURFACE_CARD,
200
198
  };
201
199
  const PHI_SPLIT_CARD_LAYOUT_PANEL_PRESET = PHI_SPLIT_CARD_LAYOUT_CREATION_CONFIG;
202
200
  const PHI_THREE_COLUMN_LAYOUT_DEFAULTS = {
203
201
  balancedSides: true,
204
- gap: PHI_SPACE.sm,
202
+ gap: PHI_LAYOUT_GAP,
205
203
  wrap: false,
206
204
  paddingLeft: PHI_SPACE.base,
207
205
  paddingRight: PHI_SPACE.base,
208
206
  };
209
207
  const PHI_THREE_COLUMN_LAYOUT_PANEL_PRESET = {
210
208
  balancedSides: true,
211
- gap: PHI_SPACE.sm,
212
209
  wrap: false,
213
210
  paddingTop: 0,
214
211
  paddingBottom: 0,
@@ -32,5 +32,5 @@ export type PhiCmsRegionOwnership = "shell" | "page";
32
32
  * know is not a placement anybody chose -- refusing it would hide Widgets over a typo.
33
33
  */
34
34
  export declare function phiCmsRegionAcceptsWidget(regionKey: string | null | undefined, required: PhiCmsRegionOwnership | null | undefined): boolean;
35
- export declare function resolvePhiCmsRegionType(regionKey: string | null | undefined): 11 | 10 | 12 | 40 | 50 | 20 | 21 | 25 | 30 | 39 | 41;
35
+ export declare function resolvePhiCmsRegionType(regionKey: string | null | undefined): 11 | 10 | 12 | 50 | 40 | 20 | 21 | 25 | 30 | 39 | 41;
36
36
  export declare function resolvePhiCmsRegionKey(regionType: number | null | undefined): "content" | "header_top" | "header_main" | "header_bottom" | "sider_left" | "sider_right" | "hero" | "footer_top" | "footer_main" | "footer_bottom" | "drawer_right" | undefined;
@@ -1,5 +1,5 @@
1
1
  import { PhiCmsRegionType } from "../constants/phi-cms";
2
- import { PHI_PAGE, PHI_SPACE } from "../theme/antd-css-var-contract";
2
+ import { PHI_LAYOUT_GAP, PHI_PAGE, PHI_SPACE } from "../theme/antd-css-var-contract";
3
3
  import { resolvePhiPageInset } from "./page-inset";
4
4
  import { parsePhiCmsCarouselLayoutConfig, parsePhiCmsCollapsibleLayoutConfig, parsePhiCmsContentLayoutConfig, parsePhiCmsFlexLayoutConfig, parsePhiCmsFlexVerticalLayoutConfig, parsePhiCmsGridLayoutConfig, parsePhiCmsMasonryLayoutConfig, parsePhiCmsSplitCardLayoutConfig, parsePhiCmsStackLayoutConfig, parsePhiCmsThreeColumnLayoutConfig, } from "../types/cms-config";
5
5
  import { readPhiSurface } from "../types/surface";
@@ -34,6 +34,9 @@ function stepOf(value) {
34
34
  return "none";
35
35
  if (PAGE_INSET_REFERENCES.has(value))
36
36
  return "page";
37
+ // The Theme's Layout gap, what a Layout without a gap of its own takes (`PHI_LAYOUT_GAP`).
38
+ if (value === PHI_LAYOUT_GAP)
39
+ return "layout-gap";
37
40
  for (const [step, reference] of Object.entries(PHI_SPACE)) {
38
41
  if (value === reference)
39
42
  return step;