@phis/ui 0.4.23 → 0.5.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 (102) hide show
  1. package/components/controls/phi-background-control.js +1 -1
  2. package/components/controls/phi-breadcrumb-control.d.ts +2 -0
  3. package/components/media/media-asset-typed-fields.d.ts +10 -0
  4. package/components/media/media-asset-typed-fields.js +19 -0
  5. package/components/media/media-settings-labels.d.ts +33 -0
  6. package/components/media/media-settings-labels.js +62 -0
  7. package/components/media/media-upload-flow.d.ts +19 -0
  8. package/components/media/media-upload-flow.js +38 -0
  9. package/components/media/phi-asset-focal-rect-widget.js +2 -2
  10. package/components/media/phi-image-inspector-widget.js +1 -1
  11. package/components/media/phi-image-preview-data.js +5 -4
  12. package/components/media/phi-site-font-assets.js +2 -5
  13. package/components/media/use-authoring-asset-details.js +0 -1
  14. package/components/regions/presets/navigation-redirect.d.ts +2 -2
  15. package/components/regions/presets/navigation-redirect.js +3 -3
  16. package/components/regions/presets/phi-area-shell-preset-nodes.js +2 -1
  17. package/components/widgets/helpers/internal-reference-resolver.server.d.ts +1 -1
  18. package/components/widgets/helpers/internal-reference-resolver.server.js +4 -0
  19. package/components/widgets/label-sets/builder-modules.js +6 -0
  20. package/components/widgets/label-types/builder-modules.d.ts +4 -0
  21. package/components/widgets/label-types/builder-modules.js +3 -0
  22. package/constants/runtime-module-ownership.js +4 -0
  23. package/gateway/internal-references.d.ts +5 -0
  24. package/gateway/internal-references.js +12 -12
  25. package/gateway/site-media-settings.d.ts +2 -0
  26. package/gateway/site-media-settings.js +6 -1
  27. package/gateway/site-media-storage-reader.d.ts +19 -0
  28. package/gateway/site-media-storage-reader.js +24 -0
  29. package/helpers/cms-navigation-catalog.d.ts +2 -0
  30. package/helpers/cms-navigation-catalog.js +1 -0
  31. package/helpers/cms-page-catalog.d.ts +12 -0
  32. package/helpers/cms-page-catalog.js +5 -0
  33. package/helpers/phi-seo.d.ts +16 -2
  34. package/helpers/phi-seo.js +54 -11
  35. package/helpers/public-route-claims.d.ts +4 -0
  36. package/helpers/public-route-claims.js +1 -1
  37. package/next/seo-routes.d.ts +1 -1
  38. package/next/seo-routes.js +23 -5
  39. package/package.json +1 -1
  40. package/plugins/runtime-modules/area-definitions.d.ts +75 -6
  41. package/plugins/runtime-modules/area-definitions.js +20 -0
  42. package/plugins/runtime-modules/asset/client-data-providers.js +12 -0
  43. package/plugins/runtime-modules/asset/controller/runtime.js +1 -1
  44. package/plugins/runtime-modules/asset/data-providers.d.ts +27 -2
  45. package/plugins/runtime-modules/asset/data-providers.js +56 -0
  46. package/plugins/runtime-modules/asset/definition.d.ts +38 -2
  47. package/plugins/runtime-modules/asset/definition.js +2 -1
  48. package/plugins/runtime-modules/asset/ids.d.ts +4 -0
  49. package/plugins/runtime-modules/asset/ids.js +4 -0
  50. package/plugins/runtime-modules/asset/server.js +2 -1
  51. package/plugins/runtime-modules/asset/services/options.d.ts +7 -0
  52. package/plugins/runtime-modules/asset/services/options.js +38 -0
  53. package/plugins/runtime-modules/asset/services/storage-spaces-table.d.ts +3 -0
  54. package/plugins/runtime-modules/asset/services/storage-spaces-table.js +89 -0
  55. package/plugins/runtime-modules/asset/settings-forms.d.ts +17 -0
  56. package/plugins/runtime-modules/asset/settings-forms.js +117 -1
  57. package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +94 -1
  58. package/plugins/runtime-modules/builder/area-shell-presets.server.d.ts +8 -0
  59. package/plugins/runtime-modules/builder/area-shell-presets.server.js +13 -0
  60. package/plugins/runtime-modules/builder/controller/page-controller-helpers.js +1 -1
  61. package/plugins/runtime-modules/builder/controller/page-controller.d.ts +1 -1
  62. package/plugins/runtime-modules/builder/controller/page-controller.js +30 -3
  63. package/plugins/runtime-modules/builder/controller/server-definition.d.ts +7 -1
  64. package/plugins/runtime-modules/builder/controller/server-definition.js +8 -3
  65. package/plugins/runtime-modules/builder/data-providers.js +1 -0
  66. package/plugins/runtime-modules/builder/developer-workspace-types.d.ts +2 -0
  67. package/plugins/runtime-modules/builder/navigation-path-context.js +7 -3
  68. package/plugins/runtime-modules/builder/options-providers.js +2 -2
  69. package/plugins/runtime-modules/builder/page-address-rule.d.ts +39 -0
  70. package/plugins/runtime-modules/builder/page-address-rule.js +62 -0
  71. package/plugins/runtime-modules/builder/page-meta-form.js +10 -0
  72. package/plugins/runtime-modules/builder/public-route-collisions.js +7 -2
  73. package/plugins/runtime-modules/builder/services/page-source-tree.js +2 -1
  74. package/plugins/runtime-modules/builder/services/runtime-modules-table.js +49 -1
  75. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +14 -2
  76. package/plugins/runtime-modules/core/widgets/breadcrumb/client.d.ts +14 -2
  77. package/plugins/runtime-modules/core/widgets/breadcrumb/client.js +35 -4
  78. package/plugins/runtime-modules/core/widgets/breadcrumb/server.d.ts +3 -1
  79. package/plugins/runtime-modules/core/widgets/breadcrumb/server.js +37 -2
  80. package/plugins/runtime-modules/core/widgets/card/editor.js +1 -1
  81. package/plugins/runtime-modules/core/widgets/image/client.js +1 -1
  82. package/plugins/runtime-modules/core/widgets/image/editor.js +1 -1
  83. package/plugins/runtime-modules/core/widgets/page-title/authoring.js +3 -1
  84. package/plugins/runtime-modules/core/widgets/page-title/client.d.ts +3 -1
  85. package/plugins/runtime-modules/core/widgets/page-title/client.js +5 -1
  86. package/plugins/runtime-modules/core/widgets/page-title/config.d.ts +25 -3
  87. package/plugins/runtime-modules/core/widgets/page-title/config.js +24 -3
  88. package/plugins/runtime-modules/core/widgets/page-title/plugin.js +1 -1
  89. package/plugins/runtime-modules/core/widgets/page-title/server.d.ts +3 -1
  90. package/plugins/runtime-modules/core/widgets/page-title/server.js +4 -3
  91. package/plugins/runtime-modules/core/widgets/table/client.js +1 -1
  92. package/plugins/runtime-modules/core/widgets/table/config.js +9 -0
  93. package/plugins/runtime-modules/descriptor-compiler.js +33 -8
  94. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +1 -1
  95. package/server-helpers/cms-review-params.d.ts +25 -0
  96. package/server-helpers/cms-review-params.js +54 -0
  97. package/server-helpers/cms-review.d.ts +1 -25
  98. package/server-helpers/cms-review.js +2 -54
  99. package/types/cms-module-descriptors.d.ts +33 -3
  100. package/types/media.d.ts +6 -2
  101. package/types/table-widget.d.ts +11 -0
  102. package/types.d.ts +1 -1
@@ -0,0 +1,19 @@
1
+ /** Where the Site's Spaces write, among the Storage Profiles the operator created. */
2
+ export type PhiSiteMediaStorageSettings = {
3
+ profiles: readonly {
4
+ id: number;
5
+ key: string;
6
+ providerId: string;
7
+ local: boolean;
8
+ disabled: boolean;
9
+ spaces: number;
10
+ }[];
11
+ siteSpaceProfileId: number;
12
+ /** `null` is the Site's Local Profile. */
13
+ defaultUserProfileId: number | null;
14
+ defaultGroupProfileId: number | null;
15
+ /** Empty offers every Profile. */
16
+ allowedProfileIds: readonly number[];
17
+ };
18
+ /** Read, not cast: every field of the storage settings, or a throw naming the one that is wrong. */
19
+ export declare function readPhiSiteMediaStorageSettings(value: unknown, source: string): PhiSiteMediaStorageSettings;
@@ -0,0 +1,24 @@
1
+ import { createPhiResponseReader, requirePhiField } from "../components/widgets/config/strict-config-reader";
2
+ /** Read, not cast: every field of the storage settings, or a throw naming the one that is wrong. */
3
+ export function readPhiSiteMediaStorageSettings(value, source) {
4
+ const reader = createPhiResponseReader(value, source);
5
+ const id = (key) => requirePhiField(reader, key, "a Storage Profile id", reader.integer);
6
+ const nullableId = (key) => (reader.record[key] === null ? null : id(key));
7
+ const ids = (key) => requirePhiField(reader, key, "a list of Storage Profile ids", (field) => reader.value(field, "a list of Storage Profile ids", (value) => Array.isArray(value) && value.every((entry) => Number.isSafeInteger(entry) && entry > 0)
8
+ ? value
9
+ : undefined));
10
+ return {
11
+ profiles: requirePhiField(reader, "profiles", "the Storage Profiles", (key) => reader.list(key, (profile) => ({
12
+ id: requirePhiField(profile, "id", "an id", profile.integer),
13
+ key: requirePhiField(profile, "key", "a key", profile.string),
14
+ providerId: requirePhiField(profile, "providerId", "a provider id", profile.string),
15
+ local: requirePhiField(profile, "local", "true or false", profile.boolean),
16
+ disabled: requirePhiField(profile, "disabled", "true or false", profile.boolean),
17
+ spaces: requirePhiField(profile, "spaces", "a count", profile.integer),
18
+ }))),
19
+ siteSpaceProfileId: id("siteSpaceProfileId"),
20
+ defaultUserProfileId: nullableId("defaultUserProfileId"),
21
+ defaultGroupProfileId: nullableId("defaultGroupProfileId"),
22
+ allowedProfileIds: ids("allowedProfileIds"),
23
+ };
24
+ }
@@ -13,6 +13,8 @@ export type PhiBuilderNavigationItem = {
13
13
  /** The Area the reference resolves in, where it is not this Navigation's own. */
14
14
  targetArea?: PhiCmsAreaKey | null;
15
15
  targetDeleted?: boolean;
16
+ /** Another Area this entry enters at its root; its `href` is that Area's segment, not a path in this one. */
17
+ targetAreaRoot?: PhiCmsAreaKey;
16
18
  icon?: string | null;
17
19
  external?: boolean;
18
20
  newTab?: boolean;
@@ -67,6 +67,7 @@ function materializeNavigationItem(item, tombstones, customItems, overrides) {
67
67
  targetDeleted: customTarget.deleted === true,
68
68
  } : {}),
69
69
  icon: item.icon ?? null,
70
+ ...(item.target?.kind === "area" ? { targetAreaRoot: item.target.area } : {}),
70
71
  ...(item.target?.kind === "module"
71
72
  ? { targetPreset: { ownerModuleId: item.target.ownerModuleId, presetKey: item.target.presetKey } }
72
73
  : {}),
@@ -28,10 +28,20 @@ export type PhiPresetPageNode = {
28
28
  pageScopeId?: number;
29
29
  reference?: PhiPageReference;
30
30
  tombstoned?: boolean;
31
+ /**
32
+ * The address a rename moves the Page to once it is published, or absent while there is none.
33
+ *
34
+ * Until then the Page still answers on its current address, so every place that shows that address shows
35
+ * this beside it (`formatPhiBuilderPagePathWithPending`): an author who renamed a Page and saw the old path
36
+ * in the picker could only conclude the rename had been lost.
37
+ */
38
+ pendingPath?: string | null;
31
39
  pathLocked?: boolean;
32
40
  pathOwnershipReason?: string;
33
41
  children?: PhiPresetPageNode[];
34
42
  };
43
+ /** A Page's address as the Builder shows it: the current one, and where a pending rename moves it. */
44
+ export declare function formatPhiBuilderPagePathWithPending(path: string, pendingPath: string | null | undefined): string;
35
45
  export type PhiBuilderModulePresetPagesByArea = Record<PhiBuilderPageCatalogArea, PhiPresetPageNode[]>;
36
46
  export declare function createEmptyPhiBuilderModulePresetPagesByArea(): PhiBuilderModulePresetPagesByArea;
37
47
  export type PhiBuilderPageCatalogArea = PhiBuilderAreaKey;
@@ -70,6 +80,8 @@ export type PhiBuilderPersistedPageCatalogEntry = {
70
80
  publishedRevisionId?: number | null;
71
81
  workingDraftRevisionId?: number | null;
72
82
  tombstoned: boolean;
83
+ /** Where a pending rename moves the Page when it is published (`draft_path`). */
84
+ pendingPath?: string | null;
73
85
  };
74
86
  /** The page catalog of one Area, with preset, local and persisted pages merged. */
75
87
  export type PhiBuilderActivePageCatalog = ReturnType<typeof resolvePhiBuilderActivePageCatalog>;
@@ -1,5 +1,9 @@
1
1
  import { PHI_BUILDER_AREA_KEYS, resolvePhiBuilderAreaAsCmsArea, } from "../constants/cms-areas";
2
2
  import { createPhiPageReference, readPhiPageReference, } from "../types/references";
3
+ /** A Page's address as the Builder shows it: the current one, and where a pending rename moves it. */
4
+ export function formatPhiBuilderPagePathWithPending(path, pendingPath) {
5
+ return pendingPath && pendingPath !== path ? `${path} → ${pendingPath}` : path;
6
+ }
3
7
  export function createEmptyPhiBuilderModulePresetPagesByArea() {
4
8
  return PHI_BUILDER_AREA_KEYS.reduce((current, area) => ({ ...current, [area]: [] }), {});
5
9
  }
@@ -310,6 +314,7 @@ function mergePhiBuilderPageCatalogWithPersistedPages(area, presetPages, persist
310
314
  pageScopeId: page.id,
311
315
  reference: page.reference,
312
316
  tombstoned: page.tombstoned,
317
+ pendingPath: page.pendingPath ? normalizePhiBuilderCmsCatalogPath(page.pendingPath) : null,
313
318
  pathLocked: false,
314
319
  };
315
320
  if (!annotatePageCatalogNode(merged, (node) => node.storagePath != null && normalizePhiBuilderCmsCatalogPath(node.storagePath) === path, patch)) {
@@ -63,16 +63,30 @@ export declare function collectPhiSitemapCandidates({ moduleRoutes, publishedPag
63
63
  }>;
64
64
  }): PhiSitemapCandidate[];
65
65
  /**
66
- * The sitemap: one `<url>` per Page per locale, each carrying the whole hreflang set.
66
+ * The sitemap as one or more `<urlset>` documents: one `<url>` per Page per locale, each carrying the
67
+ * whole hreflang set.
67
68
  *
68
69
  * Every version lists every other one, itself included, because that is what makes the set
69
- * reciprocal -- and a set that is not reciprocal is ignored without a word.
70
+ * reciprocal -- and a set that is not reciprocal is ignored without a word. A file closes at 50,000
71
+ * URLs or 45 MB, whichever comes first; a Site that needs more than one is listed by a sitemap index
72
+ * (`renderPhiSitemapIndexXml`).
70
73
  */
74
+ export declare function renderPhiSitemapDocuments(pages: ReadonlyArray<PhiSitemapCandidate>, site: {
75
+ publicBase: string;
76
+ availableLocales: readonly string[];
77
+ defaultLocale: string;
78
+ }, limits?: {
79
+ maxUrls?: number;
80
+ maxBytes?: number;
81
+ }): string[];
82
+ /** The sitemap of a Site small enough for one file, which is nearly every Site. */
71
83
  export declare function renderPhiSitemapXml(pages: ReadonlyArray<PhiSitemapCandidate>, site: {
72
84
  publicBase: string;
73
85
  availableLocales: readonly string[];
74
86
  defaultLocale: string;
75
87
  }): string;
88
+ /** A sitemap index naming each part by its address. */
89
+ export declare function renderPhiSitemapIndexXml(partUrls: readonly string[]): string;
76
90
  /**
77
91
  * The robots.txt: everything allowed, and the sitemap named when there is one.
78
92
  *
@@ -90,25 +90,47 @@ function escapePhiXml(value) {
90
90
  .replace(/"/g, "&quot;")
91
91
  .replace(/'/g, "&apos;");
92
92
  }
93
+ /** What one sitemap file may hold (sitemaps.org): 50,000 URLs, and 50 MB uncompressed. */
94
+ const PHI_SITEMAP_MAX_URLS = 50_000;
95
+ /** Below the 50 MB limit, so the closing tag and a rounding of the count never cross it. */
96
+ const PHI_SITEMAP_MAX_BYTES = 45 * 1024 * 1024;
97
+ const PHI_SITEMAP_URLSET_OPEN = [
98
+ '<?xml version="1.0" encoding="UTF-8"?>',
99
+ '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">',
100
+ ].join("\n");
101
+ const PHI_SITEMAP_URLSET_CLOSE = "</urlset>";
102
+ const utf8 = new TextEncoder();
103
+ function utf8Length(value) {
104
+ return utf8.encode(value).length;
105
+ }
93
106
  /**
94
- * The sitemap: one `<url>` per Page per locale, each carrying the whole hreflang set.
107
+ * The sitemap as one or more `<urlset>` documents: one `<url>` per Page per locale, each carrying the
108
+ * whole hreflang set.
95
109
  *
96
110
  * Every version lists every other one, itself included, because that is what makes the set
97
- * reciprocal -- and a set that is not reciprocal is ignored without a word.
111
+ * reciprocal -- and a set that is not reciprocal is ignored without a word. A file closes at 50,000
112
+ * URLs or 45 MB, whichever comes first; a Site that needs more than one is listed by a sitemap index
113
+ * (`renderPhiSitemapIndexXml`).
98
114
  */
99
- export function renderPhiSitemapXml(pages, site) {
100
- const lines = [
101
- '<?xml version="1.0" encoding="UTF-8"?>',
102
- '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">',
103
- ];
115
+ export function renderPhiSitemapDocuments(pages, site, limits = {}) {
116
+ const maxUrls = limits.maxUrls ?? PHI_SITEMAP_MAX_URLS;
117
+ const maxBytes = limits.maxBytes ?? PHI_SITEMAP_MAX_BYTES;
118
+ const overhead = utf8Length(`${PHI_SITEMAP_URLSET_OPEN}\n${PHI_SITEMAP_URLSET_CLOSE}\n`);
119
+ const documents = [];
120
+ let entries = [];
121
+ let bytes = overhead;
122
+ const close = () => {
123
+ documents.push(`${[PHI_SITEMAP_URLSET_OPEN, ...entries, PHI_SITEMAP_URLSET_CLOSE].join("\n")}\n`);
124
+ entries = [];
125
+ bytes = overhead;
126
+ };
104
127
  for (const page of pages) {
105
128
  for (const locale of site.availableLocales) {
106
129
  const alternates = buildPhiPublicPageAlternates({ ...site, path: page.path, locale });
107
130
  if (!alternates) {
108
131
  continue;
109
132
  }
110
- lines.push(" <url>");
111
- lines.push(` <loc>${escapePhiXml(alternates.canonical)}</loc>`);
133
+ const lines = [" <url>", ` <loc>${escapePhiXml(alternates.canonical)}</loc>`];
112
134
  if (page.lastModified) {
113
135
  lines.push(` <lastmod>${escapePhiXml(page.lastModified)}</lastmod>`);
114
136
  }
@@ -116,10 +138,31 @@ export function renderPhiSitemapXml(pages, site) {
116
138
  lines.push(` <xhtml:link rel="alternate" hreflang="${escapePhiXml(hreflang)}" href="${escapePhiXml(href)}"/>`);
117
139
  }
118
140
  lines.push(" </url>");
141
+ const entry = lines.join("\n");
142
+ const entryBytes = utf8Length(entry) + 1;
143
+ if (entries.length > 0 && (entries.length >= maxUrls || bytes + entryBytes > maxBytes)) {
144
+ close();
145
+ }
146
+ entries.push(entry);
147
+ bytes += entryBytes;
119
148
  }
120
149
  }
121
- lines.push("</urlset>");
122
- return `${lines.join("\n")}\n`;
150
+ close();
151
+ return documents;
152
+ }
153
+ /** The sitemap of a Site small enough for one file, which is nearly every Site. */
154
+ export function renderPhiSitemapXml(pages, site) {
155
+ const documents = renderPhiSitemapDocuments(pages, site, { maxUrls: Number.POSITIVE_INFINITY, maxBytes: Number.POSITIVE_INFINITY });
156
+ return documents[0];
157
+ }
158
+ /** A sitemap index naming each part by its address. */
159
+ export function renderPhiSitemapIndexXml(partUrls) {
160
+ return `${[
161
+ '<?xml version="1.0" encoding="UTF-8"?>',
162
+ '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
163
+ ...partUrls.map((url) => ` <sitemap><loc>${escapePhiXml(url)}</loc></sitemap>`),
164
+ "</sitemapindex>",
165
+ ].join("\n")}\n`;
123
166
  }
124
167
  /**
125
168
  * The robots.txt: everything allowed, and the sitemap named when there is one.
@@ -18,6 +18,8 @@ export type PhiPublicRouteClaim = {
18
18
  title: string;
19
19
  /** The address the Module declared. What it actually answers on may have been assigned. */
20
20
  declaredPath: string;
21
+ /** That the Module answers in the published Public Area, not only in the Builder's draft. */
22
+ live?: boolean;
21
23
  };
22
24
  export type PhiPublicRouteAddressHolder = {
23
25
  kind: "module";
@@ -26,6 +28,7 @@ export type PhiPublicRouteAddressHolder = {
26
28
  } | {
27
29
  kind: "page";
28
30
  title: string;
31
+ published: boolean;
29
32
  };
30
33
  export type PhiPublicRoutePathCollision = {
31
34
  claim: PhiPublicRouteClaim;
@@ -55,6 +58,7 @@ export declare function buildPhiPublicRouteAddressMap({ claims, activeModuleIds,
55
58
  sitePages?: readonly {
56
59
  path: string;
57
60
  title: string;
61
+ published: boolean;
58
62
  }[];
59
63
  }): Map<string, PhiPublicRouteAddressHolder>;
60
64
  /**
@@ -23,7 +23,7 @@ export function buildPhiPublicRouteAddressMap({ claims, activeModuleIds, assignm
23
23
  const addresses = new Map();
24
24
  for (const page of sitePages) {
25
25
  if (!addresses.has(page.path)) {
26
- addresses.set(page.path, { kind: "page", title: page.title });
26
+ addresses.set(page.path, { kind: "page", title: page.title, published: page.published });
27
27
  }
28
28
  }
29
29
  for (const claim of claims) {
@@ -12,7 +12,7 @@ import type { PhiCmsSiteBridge } from "../types/cms-plugins";
12
12
  */
13
13
  export declare function buildPhiSitemapRouteHandler({ bridge }: {
14
14
  bridge: PhiCmsSiteBridge;
15
- }): () => Promise<Response>;
15
+ }): (request: Request) => Promise<Response>;
16
16
  /**
17
17
  * `GET /robots.txt`, which allows everything and names the sitemap when there is one.
18
18
  *
@@ -3,7 +3,7 @@ import { createHash } from "node:crypto";
3
3
  import { resolvePhiCmsPageRedirect } from "../components/cms/phi-cms-page-redirect";
4
4
  import { getSiteAreaWithPublishedPages } from "../gateway/site-area";
5
5
  import { PHI_AREA_META_PUBLIC_DEFAULTS, readPhiAreaLandingSelection, readPhiAreaMeta, readPhiAreaPublicRoutePaths, } from "../helpers/cms-area-config";
6
- import { collectPhiSitemapCandidates, renderPhiRobotsTxt, renderPhiSitemapXml, resolvePhiSitePublicBase, } from "../helpers/phi-seo";
6
+ import { collectPhiSitemapCandidates, renderPhiRobotsTxt, renderPhiSitemapDocuments, renderPhiSitemapIndexXml, resolvePhiSitePublicBase, } from "../helpers/phi-seo";
7
7
  import { createPhiFingerprintCache } from "../helpers/phi-sitemap-cache";
8
8
  import { readPhiSiteRuntimeConfigSync } from "../helpers/site-runtime";
9
9
  import { compilePhiCmsActiveRouteTable, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
@@ -101,7 +101,7 @@ async function filterPhiSitemapCandidates(bridge, context, candidates) {
101
101
  await Promise.all(Array.from({ length: PHI_SITEMAP_RESOLVE_CONCURRENCY }, work));
102
102
  return candidates.filter((_candidate, index) => listed[index]);
103
103
  }
104
- async function buildPhiSitemapXml(bridge, context, activeModuleIds) {
104
+ async function buildPhiSitemapDocuments(bridge, context, activeModuleIds) {
105
105
  const { requestContext, areaPreset, publishedPages } = context;
106
106
  const routeTable = compilePhiCmsActiveRouteTable({
107
107
  catalog: resolvePhiCmsDescriptorCatalog(bridge.runtimeModuleCatalog),
@@ -115,7 +115,7 @@ async function buildPhiSitemapXml(bridge, context, activeModuleIds) {
115
115
  publishedPages,
116
116
  });
117
117
  const listed = await filterPhiSitemapCandidates(bridge, context, candidates);
118
- return renderPhiSitemapXml(listed, {
118
+ return renderPhiSitemapDocuments(listed, {
119
119
  publicBase: context.publicBase,
120
120
  availableLocales: requestContext.site.availableLocales.map((option) => option.code),
121
121
  defaultLocale: requestContext.site.defaultLocale,
@@ -152,14 +152,32 @@ function buildPhiSitemapFingerprint(context, activeModuleIds) {
152
152
  */
153
153
  export function buildPhiSitemapRouteHandler({ bridge }) {
154
154
  const cache = createPhiFingerprintCache();
155
- return async function GET() {
155
+ return async function GET(request) {
156
156
  const context = await loadPhiPublicSeoContext(bridge, { withPublishedPages: true });
157
157
  const publicBase = context?.publicBase;
158
158
  if (!context?.sitemapEnabled || !publicBase) {
159
159
  return new Response("Not Found", { status: 404, headers: { "cache-control": "no-store" } });
160
160
  }
161
161
  const activeModuleIds = resolveActivePresetModuleKeys(bridge.runtimeModuleCatalog, "public", context.areaPreset ? { preset: context.areaPreset.preset } : null, context.requestContext.serverCapabilities);
162
- const xml = await cache.resolve(buildPhiSitemapFingerprint(context, activeModuleIds), () => buildPhiSitemapXml(bridge, { ...context, publicBase }, activeModuleIds));
162
+ const documents = await cache.resolve(buildPhiSitemapFingerprint(context, activeModuleIds), () => buildPhiSitemapDocuments(bridge, { ...context, publicBase }, activeModuleIds));
163
+ /*
164
+ * One file answers on its own address. More than one -- above 50,000 URLs or 45 MB -- turns
165
+ * `/sitemap.xml` into an index whose parts are the same route with `?part=<n>`, so the Site needs no
166
+ * route of its own for them.
167
+ */
168
+ const part = new URL(request.url).searchParams.get("part");
169
+ let xml;
170
+ if (part === null) {
171
+ xml = documents.length === 1
172
+ ? documents[0]
173
+ : renderPhiSitemapIndexXml(documents.map((_document, index) => `${publicBase}${PHI_SITEMAP_PATH}?part=${index + 1}`));
174
+ }
175
+ else if (/^[1-9]\d*$/u.test(part)) {
176
+ xml = documents[Number(part) - 1];
177
+ }
178
+ if (xml === undefined) {
179
+ return new Response("Not Found", { status: 404, headers: { "cache-control": "no-store" } });
180
+ }
163
181
  return new Response(xml, {
164
182
  headers: { "content-type": "application/xml; charset=utf-8", "cache-control": "no-store" },
165
183
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phis/ui",
3
- "version": "0.4.23",
3
+ "version": "0.5.0",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -133,7 +133,7 @@ export declare const PHI_ADMIN_RUNTIME_AREA_DEFINITIONS: {
133
133
  label: {
134
134
  defaultMessage: string;
135
135
  };
136
- items: {
136
+ items: ({
137
137
  itemKey: string;
138
138
  label: {
139
139
  defaultMessage: string;
@@ -153,7 +153,20 @@ export declare const PHI_ADMIN_RUNTIME_AREA_DEFINITIONS: {
153
153
  };
154
154
  routePresetKey: string;
155
155
  }[];
156
- }[];
156
+ target?: undefined;
157
+ } | {
158
+ itemKey: string;
159
+ label: {
160
+ defaultMessage: string;
161
+ };
162
+ icon: string;
163
+ standing: "last";
164
+ target: {
165
+ kind: "area";
166
+ area: "builder";
167
+ };
168
+ children?: undefined;
169
+ })[];
157
170
  exportedItemKeys: string[];
158
171
  anchors: Partial<Record<PhiCmsNavigationAnchor, PhiCmsNavigationAnchorPlacement>>;
159
172
  })[];
@@ -307,7 +320,7 @@ export declare const PHI_ALL_RUNTIME_AREA_DEFINITIONS: ({
307
320
  label: {
308
321
  defaultMessage: string;
309
322
  };
310
- items: {
323
+ items: ({
311
324
  itemKey: string;
312
325
  label: {
313
326
  defaultMessage: string;
@@ -327,7 +340,20 @@ export declare const PHI_ALL_RUNTIME_AREA_DEFINITIONS: ({
327
340
  };
328
341
  routePresetKey: string;
329
342
  }[];
330
- }[];
343
+ target?: undefined;
344
+ } | {
345
+ itemKey: string;
346
+ label: {
347
+ defaultMessage: string;
348
+ };
349
+ icon: string;
350
+ standing: "last";
351
+ target: {
352
+ kind: "area";
353
+ area: "builder";
354
+ };
355
+ children?: undefined;
356
+ })[];
331
357
  exportedItemKeys: string[];
332
358
  anchors: Partial<Record<PhiCmsNavigationAnchor, PhiCmsNavigationAnchorPlacement>>;
333
359
  })[];
@@ -372,6 +398,7 @@ export declare const PHI_ALL_RUNTIME_AREA_DEFINITIONS: ({
372
398
  routePresetKey: string;
373
399
  standing?: undefined;
374
400
  children?: undefined;
401
+ target?: undefined;
375
402
  } | {
376
403
  itemKey: string;
377
404
  label: {
@@ -388,6 +415,20 @@ export declare const PHI_ALL_RUNTIME_AREA_DEFINITIONS: ({
388
415
  routePresetKey: string;
389
416
  }[];
390
417
  routePresetKey?: undefined;
418
+ target?: undefined;
419
+ } | {
420
+ itemKey: string;
421
+ label: {
422
+ defaultMessage: string;
423
+ };
424
+ icon: string;
425
+ standing: "last";
426
+ target: {
427
+ kind: "area";
428
+ area: "admin";
429
+ };
430
+ routePresetKey?: undefined;
431
+ children?: undefined;
391
432
  })[];
392
433
  exportedItemKeys: string[];
393
434
  anchors: Partial<Record<PhiCmsNavigationAnchor, PhiCmsNavigationAnchorPlacement>>;
@@ -524,7 +565,7 @@ export declare function resolvePhiRuntimeAreaDefinition(area: PhiCmsAreaDefiniti
524
565
  label: {
525
566
  defaultMessage: string;
526
567
  };
527
- items: {
568
+ items: ({
528
569
  itemKey: string;
529
570
  label: {
530
571
  defaultMessage: string;
@@ -544,7 +585,20 @@ export declare function resolvePhiRuntimeAreaDefinition(area: PhiCmsAreaDefiniti
544
585
  };
545
586
  routePresetKey: string;
546
587
  }[];
547
- }[];
588
+ target?: undefined;
589
+ } | {
590
+ itemKey: string;
591
+ label: {
592
+ defaultMessage: string;
593
+ };
594
+ icon: string;
595
+ standing: "last";
596
+ target: {
597
+ kind: "area";
598
+ area: "builder";
599
+ };
600
+ children?: undefined;
601
+ })[];
548
602
  exportedItemKeys: string[];
549
603
  anchors: Partial<Record<PhiCmsNavigationAnchor, PhiCmsNavigationAnchorPlacement>>;
550
604
  })[];
@@ -589,6 +643,7 @@ export declare function resolvePhiRuntimeAreaDefinition(area: PhiCmsAreaDefiniti
589
643
  routePresetKey: string;
590
644
  standing?: undefined;
591
645
  children?: undefined;
646
+ target?: undefined;
592
647
  } | {
593
648
  itemKey: string;
594
649
  label: {
@@ -605,6 +660,20 @@ export declare function resolvePhiRuntimeAreaDefinition(area: PhiCmsAreaDefiniti
605
660
  routePresetKey: string;
606
661
  }[];
607
662
  routePresetKey?: undefined;
663
+ target?: undefined;
664
+ } | {
665
+ itemKey: string;
666
+ label: {
667
+ defaultMessage: string;
668
+ };
669
+ icon: string;
670
+ standing: "last";
671
+ target: {
672
+ kind: "area";
673
+ area: "admin";
674
+ };
675
+ routePresetKey?: undefined;
676
+ children?: undefined;
608
677
  })[];
609
678
  exportedItemKeys: string[];
610
679
  anchors: Partial<Record<PhiCmsNavigationAnchor, PhiCmsNavigationAnchorPlacement>>;
@@ -270,6 +270,18 @@ export const PHI_ADMIN_RUNTIME_AREA_DEFINITIONS = [
270
270
  routePresetKey: "admin-settings-general-page",
271
271
  }],
272
272
  },
273
+ /*
274
+ * The Builder, one step away: going from configuring the Site to building it is the most
275
+ * common switch out of the Admin. Its root forwards to wherever this viewer lands there, and
276
+ * the entry is shown to whoever the Builder lets in. Last, after Settings, because it leaves.
277
+ */
278
+ {
279
+ itemKey: "@phis/ui/modules/admin/nav/builder",
280
+ label: label("Builder"),
281
+ icon: "antd:build",
282
+ standing: "last",
283
+ target: { kind: "area", area: "builder" },
284
+ },
273
285
  ],
274
286
  exportedItemKeys: [PHI_ADMIN_SETTINGS_NAV_ITEM_KEY],
275
287
  anchors: sidebarAnchors(PHI_ADMIN_SETTINGS_NAV_ITEM_KEY),
@@ -324,6 +336,14 @@ const PHI_BUILDER_RUNTIME_AREA_DEFINITIONS = [
324
336
  routePresetKey: "builder-settings-general-page",
325
337
  }],
326
338
  },
339
+ // The way back into the Admin; see the Admin's Builder entry.
340
+ {
341
+ itemKey: "@phis/ui/builder/nav/admin",
342
+ label: label("Admin"),
343
+ icon: "antd:cluster",
344
+ standing: "last",
345
+ target: { kind: "area", area: "admin" },
346
+ },
327
347
  ],
328
348
  exportedItemKeys: [
329
349
  "@phis/ui/builder/nav/modules",
@@ -14,6 +14,18 @@ export const PHI_ASSET_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS = [
14
14
  loadLive: async () => (await import("./services/options"))
15
15
  .PhiMediaFolderChoicesOptionsProviderClient,
16
16
  },
17
+ {
18
+ key: PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS.mediaStorageProfiles,
19
+ ownerModuleId: PHI_ASSET_RUNTIME_MODULE_ID,
20
+ loadLive: async () => (await import("./services/options"))
21
+ .PhiMediaStorageProfilesOptionsProviderClient,
22
+ },
23
+ {
24
+ key: PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS.mediaStorageSpaces,
25
+ ownerModuleId: PHI_ASSET_RUNTIME_MODULE_ID,
26
+ loadLive: async () => (await import("./services/storage-spaces-table"))
27
+ .PhiMediaStorageSpacesTableProviderClient,
28
+ },
17
29
  {
18
30
  key: PHI_ASSET_RUNTIME_DATA_PROVIDER_KEYS.mediaCollection,
19
31
  ownerModuleId: PHI_ASSET_RUNTIME_MODULE_ID,
@@ -252,7 +252,7 @@ export function usePhiAssetRuntimeController({ address, mountScope, config, }) {
252
252
  title: asset.title ?? "",
253
253
  altText: asset.altText ?? "",
254
254
  presentationFlags: ASSET_FORM_FLAG_VALUES.filter((flag) => (asset.presentationFlags & flag) === flag).map(String),
255
- focalRect: normalizeMediaFocalRect(asset.meta?.focalRect) ?? null,
255
+ focalRect: normalizeMediaFocalRect(asset.focalRect) ?? null,
256
256
  },
257
257
  }, inspectorRequest.correlationId);
258
258
  }, [emitCapability, inspectorRequest, state.assets, state.folders, state.selectedAsset]);
@@ -1,9 +1,23 @@
1
+ import type { PhiTableProviderResourceDescriptor } from "../../../types/table-widget";
1
2
  /** How the Folder's pictures are ordered; the words a record binding's `sort` takes. */
2
3
  export declare const PHI_MEDIA_FOLDER_IMAGES_SORTS: readonly ["name_asc", "created_at_desc"];
3
4
  export declare const PHI_MEDIA_FOLDER_IMAGES_DEFAULT_LIMIT = 50;
4
5
  /** What the server hands out at most (`/api/v1/site/media/folder-images`). */
5
6
  export declare const PHI_MEDIA_FOLDER_IMAGES_MAX_LIMIT = 200;
7
+ /** The existing User and Group Spaces, one resource per kind, for the Admin storage table. */
8
+ export declare const PHI_ASSET_STORAGE_SPACES_RESOURCES: readonly PhiTableProviderResourceDescriptor[];
6
9
  export declare const PHI_ASSET_RUNTIME_DATA_PROVIDER_DESCRIPTORS: ({
10
+ key: `${string}/${string}`;
11
+ ownerModuleId: "@phis/ui/modules/asset";
12
+ kind: "table";
13
+ executionMode: "live";
14
+ authoringMode: "none";
15
+ title: string;
16
+ description: string;
17
+ resources: readonly PhiTableProviderResourceDescriptor[];
18
+ availableToAuthoringChrome?: undefined;
19
+ settingsFields?: undefined;
20
+ } | {
7
21
  key: `${string}/${string}`;
8
22
  ownerModuleId: "@phis/ui/modules/asset";
9
23
  kind: "options";
@@ -11,9 +25,20 @@ export declare const PHI_ASSET_RUNTIME_DATA_PROVIDER_DESCRIPTORS: ({
11
25
  authoringMode: "none";
12
26
  title: string;
13
27
  description: string;
14
- availableToAuthoringChrome: true;
28
+ resources?: undefined;
29
+ availableToAuthoringChrome?: undefined;
15
30
  settingsFields?: undefined;
31
+ } | {
32
+ key: `${string}/${string}`;
33
+ ownerModuleId: "@phis/ui/modules/asset";
34
+ kind: "options";
35
+ executionMode: "live";
36
+ authoringMode: "none";
37
+ title: string;
38
+ description: string;
39
+ availableToAuthoringChrome: true;
16
40
  resources?: undefined;
41
+ settingsFields?: undefined;
17
42
  } | {
18
43
  key: `${string}/${string}`;
19
44
  ownerModuleId: "@phis/ui/modules/asset";
@@ -68,8 +93,8 @@ export declare const PHI_ASSET_RUNTIME_DATA_PROVIDER_DESCRIPTORS: ({
68
93
  description?: undefined;
69
94
  options?: undefined;
70
95
  })[];
71
- availableToAuthoringChrome?: undefined;
72
96
  resources?: undefined;
97
+ availableToAuthoringChrome?: undefined;
73
98
  } | {
74
99
  key: `${string}/${string}`;
75
100
  ownerModuleId: "@phis/ui/modules/asset";