@phis/ui 0.5.4 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/cms/phi-cms-layout-renderer.js +17 -7
- package/components/controls/phi-anchor-nav-control.js +18 -1
- package/components/layouts/clients/phi-flex-layout-client.js +17 -2
- package/components/layouts/clients/phi-layout-anchored-overlay.d.ts +2 -0
- package/components/layouts/clients/phi-layout-anchored-overlay.js +2 -0
- package/components/regions/presets/content-entry-editor-page-tree.js +2 -0
- package/components/regions/presets/content-entry-public-page-trees.js +2 -0
- package/components/widgets/builder/stack-tabs.d.ts +2 -1
- package/components/widgets/builder/stack-tabs.js +18 -2
- package/components/widgets/config/choice-shared.d.ts +0 -48
- package/components/widgets/config/choice-shared.js +0 -1
- package/components/widgets/config/stack-tabs.js +4 -3
- package/components/widgets/shared/card-body-client.d.ts +6 -2
- package/components/widgets/shared/card-body-client.js +27 -20
- package/components/widgets/shared/card-vocabulary.d.ts +7 -0
- package/components/widgets/shared/card-vocabulary.js +6 -0
- package/components/widgets/shared/markdown-body-client.js +7 -2
- package/constants/module-identity.d.ts +8 -0
- package/constants/module-identity.js +13 -0
- package/gateway/server-module-media.d.ts +12 -0
- package/gateway/server-module-media.js +83 -0
- package/helpers/cms-navigation-catalog.js +4 -1
- package/helpers/cms-page-catalog.d.ts +7 -0
- package/helpers/cms-preset-page-tree.js +16 -1
- package/helpers/config-text-fields.d.ts +49 -0
- package/helpers/config-text-fields.js +122 -0
- package/helpers/module-media-check.d.ts +23 -0
- package/helpers/module-media-check.js +32 -0
- package/helpers/module-media.d.ts +7 -0
- package/helpers/module-media.js +15 -0
- package/helpers/preset-text-source-check.d.ts +22 -0
- package/helpers/preset-text-source-check.js +45 -0
- package/helpers/route-address-check.d.ts +35 -0
- package/helpers/route-address-check.js +28 -0
- package/helpers/text-source.d.ts +14 -5
- package/helpers/text-source.js +16 -3
- package/module-page-check.d.ts +3 -0
- package/module-page-check.js +3 -0
- package/package.json +1 -1
- package/plugins/runtime/phi-slot-child-frame-view.js +1 -1
- package/plugins/runtime/slot-size-policy.d.ts +8 -2
- package/plugins/runtime/slot-size-policy.js +51 -16
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-page-tree.js +2 -0
- package/plugins/runtime-modules/builder/area-shell-presets.server.js +2 -0
- package/plugins/runtime-modules/builder/clients/widget-inspector.js +2 -2
- package/plugins/runtime-modules/builder/navigation-folder-drop.js +2 -1
- package/plugins/runtime-modules/builder/options-providers.js +7 -1
- package/plugins/runtime-modules/builder/page-presets.server.js +2 -0
- package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +3 -0
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +11 -0
- package/plugins/runtime-modules/core/widgets/breadcrumb/server.js +9 -2
- package/plugins/runtime-modules/core/widgets/button/config.d.ts +0 -1
- package/plugins/runtime-modules/core/widgets/button/config.js +0 -1
- package/plugins/runtime-modules/core/widgets/button/plugin.js +6 -25
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +24 -2
- package/plugins/runtime-modules/core/widgets/card/config.js +35 -3
- package/plugins/runtime-modules/core/widgets/card/editor.js +2 -0
- package/plugins/runtime-modules/core/widgets/card/plugin.js +8 -10
- package/plugins/runtime-modules/core/widgets/card/server.d.ts +1 -2
- package/plugins/runtime-modules/core/widgets/card/server.js +18 -28
- package/plugins/runtime-modules/core/widgets/cascader/authoring.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/checkbox-group/config.d.ts +7 -1
- package/plugins/runtime-modules/core/widgets/checkbox-group/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/description/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/entry-list/config.js +0 -1
- package/plugins/runtime-modules/core/widgets/entry-list/plugin.js +1 -3
- package/plugins/runtime-modules/core/widgets/entry-list/server.d.ts +1 -3
- package/plugins/runtime-modules/core/widgets/entry-list/server.js +3 -3
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/image/server.js +5 -9
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/markdown-toc/server.js +3 -5
- package/plugins/runtime-modules/core/widgets/quick-links/plugin.js +2 -4
- package/plugins/runtime-modules/core/widgets/quick-links/server.d.ts +2 -5
- package/plugins/runtime-modules/core/widgets/quick-links/server.js +2 -6
- package/plugins/runtime-modules/core/widgets/result/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/result/config.js +0 -1
- package/plugins/runtime-modules/core/widgets/result/plugin.js +2 -4
- package/plugins/runtime-modules/core/widgets/result/server.d.ts +2 -3
- package/plugins/runtime-modules/core/widgets/result/server.js +11 -33
- package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +1 -0
- package/plugins/runtime-modules/core/widgets/slider/config.d.ts +11 -0
- package/plugins/runtime-modules/core/widgets/slider/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/config.d.ts +0 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/config.js +0 -2
- package/plugins/runtime-modules/core/widgets/slot-upload/plugin.js +2 -4
- package/plugins/runtime-modules/core/widgets/slot-upload/server.d.ts +3 -4
- package/plugins/runtime-modules/core/widgets/slot-upload/server.js +5 -13
- package/plugins/runtime-modules/core/widgets/spacer/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/spacer/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/steps/config.d.ts +7 -2
- package/plugins/runtime-modules/core/widgets/steps/config.js +1 -2
- package/plugins/runtime-modules/core/widgets/steps/plugin.js +6 -30
- package/plugins/runtime-modules/core/widgets/table/config.d.ts +3 -0
- package/plugins/runtime-modules/core/widgets/table/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/timeline/config.d.ts +8 -1
- package/plugins/runtime-modules/core/widgets/timeline/config.js +1 -2
- package/plugins/runtime-modules/core/widgets/timeline/plugin.js +6 -37
- package/plugins/runtime-modules/descriptor-compiler.d.ts +23 -3
- package/plugins/runtime-modules/descriptor-compiler.js +107 -12
- package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +2 -0
- package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -0
- package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +3 -0
- package/plugins/runtime-modules/page-preset-overlays.d.ts +18 -0
- package/plugins/runtime-modules/page-preset-overlays.js +70 -0
- package/plugins/runtime-modules/public/trees/phi-default-pub-welcome-page-tree.js +1 -0
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +3 -0
- package/plugins/runtime-modules/search/widgets/search-box/server.js +3 -5
- package/plugins/runtime-modules/search/widgets/search-results/server.js +3 -5
- package/plugins/runtime-modules/theme/trees/phi-default-builder-theme-page-tree.js +4 -0
- package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +2 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +2 -0
- package/server-helpers/cms-area.js +9 -1
- package/server-helpers/cms-request.js +49 -14
- package/server-helpers/cms-root.js +2 -0
- package/server-helpers/cms-widget-texts.d.ts +14 -0
- package/server-helpers/cms-widget-texts.js +117 -0
- package/server-helpers/module-folder-targets.d.ts +7 -0
- package/server-helpers/module-folder-targets.js +15 -0
- package/server-helpers/search-index.js +12 -3
- package/styles/root.css +6 -2
- package/types/cms-module-descriptors.d.ts +24 -0
- package/types/cms-plugins.d.ts +30 -5
- package/types/core-widget-placements.d.ts +5 -0
- package/types/module-media.d.ts +31 -0
- package/types/module-media.js +11 -0
- package/types/slot-size-policy.d.ts +19 -2
- package/types.d.ts +1 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
|
|
1
2
|
import { PHI_CMS_DEFAULT_SLOT_INDEX } from "../../../../constants/cms-layout-types";
|
|
2
3
|
import { PhiCmsPageType } from "../../../../constants/phi-cms";
|
|
3
4
|
import { PHI_GROUPS_RUNTIME_DATA_PROVIDER_KEYS } from "../ids";
|
|
@@ -85,6 +86,7 @@ export async function buildPhiDefaultAdminGroupsPageTree({ page, runtime, }) {
|
|
|
85
86
|
label: text.submit,
|
|
86
87
|
config: {
|
|
87
88
|
key: `admin-groups-${workflow}-commands`,
|
|
89
|
+
textSource: PHI_TEXT_SOURCE_PRESET,
|
|
88
90
|
buttons: [
|
|
89
91
|
{ key: "cancel", emits: [{ capabilityId: "close", value: null }], label: labels.actions.cancel, icon: "close" },
|
|
90
92
|
{ key: "save", emits: [{ capabilityId: "submit", value: null }], label: text.submit, variant: "primary", icon: "save" },
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
|
|
1
2
|
import { PHI_CMS_DEFAULT_SLOT_INDEX } from "../../../../constants/cms-layout-types";
|
|
2
3
|
import { PhiCmsPageType } from "../../../../constants/phi-cms";
|
|
3
4
|
import { PHI_GROUPS_RUNTIME_DATA_PROVIDER_KEYS } from "../ids";
|
|
@@ -257,6 +258,7 @@ export async function buildPhiDefaultAppGroupsPageTree({ page, runtime, }) {
|
|
|
257
258
|
label: labels.membership.submit,
|
|
258
259
|
config: {
|
|
259
260
|
key: "app-groups-membership-commands",
|
|
261
|
+
textSource: PHI_TEXT_SOURCE_PRESET,
|
|
260
262
|
compact: false,
|
|
261
263
|
wrap: true,
|
|
262
264
|
showLabels: true,
|
package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
|
|
1
2
|
import { PHI_CMS_DEFAULT_SLOT_INDEX, PHI_CMS_SEQUENTIAL_LAYOUT_SLOTS, } from "../../../../constants/cms-layout-types";
|
|
2
3
|
import { PhiCmsPageType } from "../../../../constants/phi-cms";
|
|
3
4
|
import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
|
|
@@ -122,6 +123,7 @@ export async function buildPhiDefaultEditorTranslationsPageTree({ page, runtime,
|
|
|
122
123
|
label: "editor source locale",
|
|
123
124
|
config: {
|
|
124
125
|
text: sourceLocaleText,
|
|
126
|
+
textSource: PHI_TEXT_SOURCE_PRESET,
|
|
125
127
|
placeholder: widgetLabels.sourceLocaleLabel,
|
|
126
128
|
readOnly: true,
|
|
127
129
|
allowClear: false,
|
|
@@ -301,6 +303,7 @@ export async function buildPhiDefaultEditorTranslationsPageTree({ page, runtime,
|
|
|
301
303
|
label: "editor translation commands",
|
|
302
304
|
config: {
|
|
303
305
|
key: "editor-translation-commands",
|
|
306
|
+
textSource: PHI_TEXT_SOURCE_PRESET,
|
|
304
307
|
...PHI_DIALOG_COMMANDS_CONFIG,
|
|
305
308
|
buttons: [
|
|
306
309
|
{ key: "cancel", emits: [{ capabilityId: "command", value: "cancel" }], label: widgetLabels.actions.cancel, icon: "close" },
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PhiResolvedCmsPageTree } from "../../types/cms";
|
|
2
|
+
/**
|
|
3
|
+
* Lays the Overlays of a Page preset over a stored Page that answers for it (OVERLAYS.md, "Page
|
|
4
|
+
* preset Overlays").
|
|
5
|
+
*
|
|
6
|
+
* A stored Page holds no copy of an Overlay its preset declares, so the preset's are taken from
|
|
7
|
+
* `presetTree`, the same preset instantiated beside the stored tree: each Overlay, every Layout reachable
|
|
8
|
+
* from its Header, Body and Footer roots, and every Widget under those Layouts, in the preset's order. A
|
|
9
|
+
* stored Overlay with the id of a preset Overlay wins and its preset subtree is left out. Regions, the
|
|
10
|
+
* Page row, Controller settings and every stored node stay as stored; with nothing to take the stored
|
|
11
|
+
* tree itself is returned.
|
|
12
|
+
*
|
|
13
|
+
* The Area precedent is `composePhiCmsActiveAreaOverlayPresets` (descriptor-compiler.ts).
|
|
14
|
+
*/
|
|
15
|
+
export declare function composePhiCmsPagePresetOverlays({ tree, presetTree, }: {
|
|
16
|
+
tree: PhiResolvedCmsPageTree;
|
|
17
|
+
presetTree: PhiResolvedCmsPageTree;
|
|
18
|
+
}): PhiResolvedCmsPageTree;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lays the Overlays of a Page preset over a stored Page that answers for it (OVERLAYS.md, "Page
|
|
3
|
+
* preset Overlays").
|
|
4
|
+
*
|
|
5
|
+
* A stored Page holds no copy of an Overlay its preset declares, so the preset's are taken from
|
|
6
|
+
* `presetTree`, the same preset instantiated beside the stored tree: each Overlay, every Layout reachable
|
|
7
|
+
* from its Header, Body and Footer roots, and every Widget under those Layouts, in the preset's order. A
|
|
8
|
+
* stored Overlay with the id of a preset Overlay wins and its preset subtree is left out. Regions, the
|
|
9
|
+
* Page row, Controller settings and every stored node stay as stored; with nothing to take the stored
|
|
10
|
+
* tree itself is returned.
|
|
11
|
+
*
|
|
12
|
+
* The Area precedent is `composePhiCmsActiveAreaOverlayPresets` (descriptor-compiler.ts).
|
|
13
|
+
*/
|
|
14
|
+
export function composePhiCmsPagePresetOverlays({ tree, presetTree, }) {
|
|
15
|
+
const storedOverlayIds = new Set(tree.overlays.map((node) => node.id));
|
|
16
|
+
const presetOverlays = presetTree.overlays.filter((overlay) => !storedOverlayIds.has(overlay.id));
|
|
17
|
+
if (presetOverlays.length === 0)
|
|
18
|
+
return tree;
|
|
19
|
+
const childLayoutsByParent = new Map();
|
|
20
|
+
for (const layout of presetTree.layoutNodes) {
|
|
21
|
+
if (layout.parentLayoutNodeId === null)
|
|
22
|
+
continue;
|
|
23
|
+
const siblings = childLayoutsByParent.get(layout.parentLayoutNodeId);
|
|
24
|
+
if (siblings)
|
|
25
|
+
siblings.push(layout);
|
|
26
|
+
else
|
|
27
|
+
childLayoutsByParent.set(layout.parentLayoutNodeId, [layout]);
|
|
28
|
+
}
|
|
29
|
+
const layoutsById = new Map(presetTree.layoutNodes.map((layout) => [layout.id, layout]));
|
|
30
|
+
const takenLayoutIds = new Set();
|
|
31
|
+
const visit = (rootId) => {
|
|
32
|
+
if (rootId === null)
|
|
33
|
+
return;
|
|
34
|
+
const stack = [rootId];
|
|
35
|
+
while (stack.length > 0) {
|
|
36
|
+
const id = stack.pop();
|
|
37
|
+
if (takenLayoutIds.has(id))
|
|
38
|
+
continue;
|
|
39
|
+
const layout = layoutsById.get(id);
|
|
40
|
+
if (!layout)
|
|
41
|
+
continue;
|
|
42
|
+
takenLayoutIds.add(id);
|
|
43
|
+
for (const child of childLayoutsByParent.get(id) ?? [])
|
|
44
|
+
stack.push(child.id);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
for (const overlay of presetOverlays) {
|
|
48
|
+
visit(overlay.headerLayoutNodeId);
|
|
49
|
+
visit(overlay.bodyLayoutNodeId);
|
|
50
|
+
visit(overlay.footerLayoutNodeId);
|
|
51
|
+
}
|
|
52
|
+
const layouts = presetTree.layoutNodes.filter((layout) => takenLayoutIds.has(layout.id));
|
|
53
|
+
const widgets = presetTree.contentWidgets.filter((widget) => takenLayoutIds.has(widget.parentLayoutNodeId));
|
|
54
|
+
const occupiedIds = new Set([
|
|
55
|
+
...tree.layoutNodes.map((node) => node.id),
|
|
56
|
+
...tree.contentWidgets.map((node) => node.id),
|
|
57
|
+
]);
|
|
58
|
+
for (const node of [...presetOverlays, ...layouts, ...widgets]) {
|
|
59
|
+
if (occupiedIds.has(node.id)) {
|
|
60
|
+
throw new Error(`Page preset Overlay composition contains duplicate instance id "${node.id}".`);
|
|
61
|
+
}
|
|
62
|
+
occupiedIds.add(node.id);
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
...tree,
|
|
66
|
+
overlays: [...tree.overlays, ...presetOverlays],
|
|
67
|
+
layoutNodes: [...tree.layoutNodes, ...layouts],
|
|
68
|
+
contentWidgets: [...tree.contentWidgets, ...widgets],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -160,6 +160,7 @@ export async function buildPhiDefaultPubWelcomePageTree({ page, runtime, }) {
|
|
|
160
160
|
label: "pub welcome read more button",
|
|
161
161
|
config: {
|
|
162
162
|
key: "read-more",
|
|
163
|
+
textSource: PHI_TEXT_SOURCE_PRESET,
|
|
163
164
|
label: "Read more...",
|
|
164
165
|
variant: "primary",
|
|
165
166
|
/*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
|
|
1
2
|
import { PHI_CMS_DEFAULT_SLOT_INDEX, PHI_CMS_SEQUENTIAL_LAYOUT_SLOTS, PHI_CMS_THREE_COLUMN_LAYOUT_SLOT_INDEX, } from "../../../../constants/cms-layout-types";
|
|
2
3
|
import { PhiCmsFlags, PhiCmsRegionType, PhiCmsStatus } from "../../../../constants/phi-cms";
|
|
3
4
|
import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
|
|
@@ -227,6 +228,7 @@ export async function buildPhiDefaultBuilderRevisionsPageTree({ page, runtime, }
|
|
|
227
228
|
label: "dev revisions area shell delete",
|
|
228
229
|
config: {
|
|
229
230
|
key: "revisions-area-shell-delete",
|
|
231
|
+
textSource: PHI_TEXT_SOURCE_PRESET,
|
|
230
232
|
controlSize: "small",
|
|
231
233
|
compact: true,
|
|
232
234
|
showLabels: true,
|
|
@@ -350,6 +352,7 @@ export async function buildPhiDefaultBuilderRevisionsPageTree({ page, runtime, }
|
|
|
350
352
|
label: "Builder delete area commands",
|
|
351
353
|
config: {
|
|
352
354
|
key: "delete-area-commands",
|
|
355
|
+
textSource: PHI_TEXT_SOURCE_PRESET,
|
|
353
356
|
...PHI_DIALOG_COMMANDS_CONFIG,
|
|
354
357
|
buttons: [
|
|
355
358
|
{
|
|
@@ -6,7 +6,6 @@ import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
|
6
6
|
import { resolvePhiLinkHref } from "../../../../../helpers/link-target";
|
|
7
7
|
import { resolvePhiLinkTargetReferences } from "../../../../../server-helpers/cms-link-targets";
|
|
8
8
|
import { phiRuntime } from "../../../../../server-helpers/phi-runtime";
|
|
9
|
-
import { trBulkForLocale } from "../../../../../server-helpers/translate";
|
|
10
9
|
import { resolvePhiSearchPageLinkTarget } from "../../page-references";
|
|
11
10
|
/**
|
|
12
11
|
* The search box, resolved on the server: where the form goes, what the box says, what it already holds.
|
|
@@ -30,10 +29,9 @@ export async function PhiSearchBoxWidget({ config, runtime }) {
|
|
|
30
29
|
if (!href) {
|
|
31
30
|
return null;
|
|
32
31
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
]);
|
|
32
|
+
// The placeholder arrives translated (server-helpers/cms-widget-texts.ts).
|
|
33
|
+
const placeholder = config?.placeholder ?? "";
|
|
34
|
+
const labels = await getPhiSearchWidgetLabels({ apiBaseUrl: rt.apiBaseUrl, internalToken: rt.internalToken, locale });
|
|
37
35
|
return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.SearchBox, componentProps: {
|
|
38
36
|
labels,
|
|
39
37
|
config: {
|
|
@@ -8,7 +8,6 @@ import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
|
8
8
|
import { resolvePhiNavHref } from "../../../../../helpers/locale";
|
|
9
9
|
import { fetchPhiSiteSearch } from "../../../../../gateway/site-search";
|
|
10
10
|
import { phiRuntime } from "../../../../../server-helpers/phi-runtime";
|
|
11
|
-
import { trBulkForLocale } from "../../../../../server-helpers/translate";
|
|
12
11
|
import { readPhiRuntimeTreeRenderMode } from "../../../render-mode";
|
|
13
12
|
/** The Areas a reader standing in `area` may search (SEARCH.md): App and Public from the App, else Public. */
|
|
14
13
|
function resolvePhiSearchedAreas(area) {
|
|
@@ -33,10 +32,9 @@ export async function PhiSearchResultsWidget({ config, runtime, widgetId }) {
|
|
|
33
32
|
const rt = phiRuntime(runtime);
|
|
34
33
|
const locale = runtime.locale.current;
|
|
35
34
|
const renderMode = readPhiRuntimeTreeRenderMode(config ?? {});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
]);
|
|
35
|
+
// The heading arrives translated (server-helpers/cms-widget-texts.ts).
|
|
36
|
+
const title = config?.title ?? "";
|
|
37
|
+
const labels = await getPhiSearchResultsWidgetLabels({ apiBaseUrl: rt.apiBaseUrl, internalToken: rt.internalToken, locale });
|
|
40
38
|
const raw = runtime.request?.searchParams?.[PHI_SEARCH_QUERY_PARAM];
|
|
41
39
|
const query = readPhiSearchQuery(raw);
|
|
42
40
|
const base = { title: title || undefined, minLength: PHI_SEARCH_MIN_QUERY_LENGTH };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
|
|
1
2
|
import { PHI_CMS_DEFAULT_SLOT_INDEX, PHI_CMS_SEQUENTIAL_LAYOUT_SLOTS, PHI_CMS_THREE_COLUMN_LAYOUT_SLOT_INDEX, } from "../../../../constants/cms-layout-types";
|
|
2
3
|
import { PhiCmsFlags, PhiCmsRegionType, PhiCmsStatus } from "../../../../constants/phi-cms";
|
|
3
4
|
import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
|
|
@@ -357,6 +358,7 @@ export async function buildPhiDefaultBuilderThemePageTree({ page, runtime, regis
|
|
|
357
358
|
draft: runtime.site.themeRevision?.workingDraftRevisionId != null,
|
|
358
359
|
}),
|
|
359
360
|
key: "brand-theme-preset",
|
|
361
|
+
textSource: PHI_TEXT_SOURCE_PRESET,
|
|
360
362
|
signalRoutes: {
|
|
361
363
|
emits: [
|
|
362
364
|
{
|
|
@@ -428,6 +430,7 @@ export async function buildPhiDefaultBuilderThemePageTree({ page, runtime, regis
|
|
|
428
430
|
checkedLabel: labels.themeSwitch.dark,
|
|
429
431
|
uncheckedLabel: labels.themeSwitch.light,
|
|
430
432
|
key: "brandPreviewThemeMode",
|
|
433
|
+
textSource: PHI_TEXT_SOURCE_PRESET,
|
|
431
434
|
signalRoutes: {
|
|
432
435
|
emits: [
|
|
433
436
|
{
|
|
@@ -453,6 +456,7 @@ export async function buildPhiDefaultBuilderThemePageTree({ page, runtime, regis
|
|
|
453
456
|
config: {
|
|
454
457
|
value: "0",
|
|
455
458
|
valueMode: "stack-slot-index",
|
|
459
|
+
textSource: PHI_TEXT_SOURCE_PRESET,
|
|
456
460
|
key: PHI_THEME_STACK_SIGNAL_KEY,
|
|
457
461
|
signalRoutes: {
|
|
458
462
|
emits: [
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
|
|
1
2
|
import { PHI_CMS_DEFAULT_SLOT_INDEX } from "../../../../constants/cms-layout-types";
|
|
2
3
|
import { PhiCmsFlags, PhiCmsPageType } from "../../../../constants/phi-cms";
|
|
3
4
|
import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
|
|
@@ -643,6 +644,7 @@ export async function buildPhiDefaultThreadsPageTree({ page, runtime, area, }) {
|
|
|
643
644
|
label: labels.openConversationLabel,
|
|
644
645
|
config: {
|
|
645
646
|
key: "app-threads-new-commands",
|
|
647
|
+
textSource: PHI_TEXT_SOURCE_PRESET,
|
|
646
648
|
...PHI_DIALOG_COMMANDS_CONFIG,
|
|
647
649
|
buttons: [
|
|
648
650
|
{ key: "cancel", emits: [{ capabilityId: "command", value: "cancel" }], label: labels.cancelLabel, icon: "close" },
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PHI_TEXT_SOURCE_PRESET } from "../../../../helpers/text-source";
|
|
1
2
|
import { PHI_CMS_DEFAULT_SLOT_INDEX, } from "../../../../constants/cms-layout-types";
|
|
2
3
|
import { PhiCmsPageType } from "../../../../constants/phi-cms";
|
|
3
4
|
import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
|
|
@@ -543,6 +544,7 @@ export async function buildPhiDefaultAdminUsersPageTree({ page, runtime, }) {
|
|
|
543
544
|
label: `admin users ${mode} commands`,
|
|
544
545
|
config: {
|
|
545
546
|
key: `admin-users-${mode}-commands`,
|
|
547
|
+
textSource: PHI_TEXT_SOURCE_PRESET,
|
|
546
548
|
...PHI_DIALOG_COMMANDS_CONFIG,
|
|
547
549
|
buttons: [
|
|
548
550
|
{ key: "cancel", emits: [{ capabilityId: "command", value: "cancel" }], label: widgetLabels.confirm.cancel, icon: "close" },
|
|
@@ -2,6 +2,7 @@ import "server-only";
|
|
|
2
2
|
import { resolvePhiCmsAreaKey, resolvePhiCmsAreaMask } from "../constants/cms-areas";
|
|
3
3
|
import { PhiCmsStatus } from "../constants/phi-cms";
|
|
4
4
|
import { applyPhiPresetTreePublishedContent } from "./cms-bound-content";
|
|
5
|
+
import { createPhiModuleMediaLoader } from "../gateway/server-module-media";
|
|
5
6
|
import { instantiatePhiCmsAreaShellPreset, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
|
|
6
7
|
function createSyntheticAreaPreset({ siteId, areaMask, }) {
|
|
7
8
|
return {
|
|
@@ -43,7 +44,14 @@ export async function buildPhiLocalCmsAreaPayload({ areaMask, siteId, path, runt
|
|
|
43
44
|
if (!binding) {
|
|
44
45
|
return null;
|
|
45
46
|
}
|
|
46
|
-
const tree = await applyPhiPresetTreePublishedContent(await instantiatePhiCmsAreaShellPreset({
|
|
47
|
+
const tree = await applyPhiPresetTreePublishedContent(await instantiatePhiCmsAreaShellPreset({
|
|
48
|
+
binding,
|
|
49
|
+
catalog,
|
|
50
|
+
siteId,
|
|
51
|
+
path,
|
|
52
|
+
runtime,
|
|
53
|
+
loadModuleMedia: createPhiModuleMediaLoader(runtime.site.key),
|
|
54
|
+
}), { runtimeModuleCatalog, siteKey: runtime.site.key, locale: runtime.locale.current });
|
|
47
55
|
return buildAreaPresetPayloadFromTree({
|
|
48
56
|
areaMask: resolvedAreaMask,
|
|
49
57
|
siteId,
|
|
@@ -3,8 +3,9 @@ import { cache } from "react";
|
|
|
3
3
|
import { notFound } from "next/navigation";
|
|
4
4
|
import { resolvePhiCmsAreaKey, resolvePhiCmsAreaMask, } from "../constants/cms-areas";
|
|
5
5
|
import { canPhiViewerAccess } from "../types/access";
|
|
6
|
-
import { compilePhiCmsActiveRouteTable, instantiatePhiCmsRoutePreset, normalizePhiCmsRoutePath, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, resolvePhiCmsRoutePreset, } from "../plugins/runtime-modules/descriptor-compiler";
|
|
6
|
+
import { compilePhiCmsActiveRouteTable, instantiatePhiCmsRoutePreset, normalizePhiCmsRoutePath, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, resolvePhiCmsModuleNavigationFolderTargets, resolvePhiCmsRoutePreset, } from "../plugins/runtime-modules/descriptor-compiler";
|
|
7
7
|
import { resolvePhiRuntimeModuleIdsForArea } from "../plugins/runtime-modules/settings";
|
|
8
|
+
import { composePhiCmsPagePresetOverlays } from "../plugins/runtime-modules/page-preset-overlays";
|
|
8
9
|
import { resolvePhiCmsRoutePage } from "../plugins/runtime-modules/route-page-resolution";
|
|
9
10
|
import { PhiCmsFlags } from "../constants/phi-cms";
|
|
10
11
|
import { hasPhiFlag } from "../helpers/flags";
|
|
@@ -25,6 +26,7 @@ import { buildPhiBlockRuntime, loadPhiSiteRequestContext, } from "./runtime";
|
|
|
25
26
|
import { trForLocale } from "./translate";
|
|
26
27
|
import { readPhiAreaLandingSelection, readPhiAreaPresetRuntimeModuleIds, readPhiAreaPublicRoutePaths, } from "../helpers/cms-area-config";
|
|
27
28
|
import { readPhiServerApiCredentials } from "../helpers/phis-server-credentials";
|
|
29
|
+
import { createPhiModuleMediaLoader } from "../gateway/server-module-media";
|
|
28
30
|
async function instantiatePhiRoutePresetPage({ binding, requestedPath, areaMask, siteId, runtime, runtimeModuleCatalog, activeModuleKeys, }) {
|
|
29
31
|
const catalog = resolvePhiCmsDescriptorCatalog(runtimeModuleCatalog);
|
|
30
32
|
return {
|
|
@@ -42,6 +44,7 @@ async function instantiatePhiRoutePresetPage({ binding, requestedPath, areaMask,
|
|
|
42
44
|
siteId,
|
|
43
45
|
path: requestedPath,
|
|
44
46
|
runtime,
|
|
47
|
+
loadModuleMedia: createPhiModuleMediaLoader(runtime.site.key),
|
|
45
48
|
// The route's title is the owning Module's text, written in that Module's language.
|
|
46
49
|
resolveMissingPageTitle: (sourceTitle) => trForLocale(runtime.locale.current, sourceTitle, 0, 0, "text", catalog.sourceLocaleByModuleId.get(binding.descriptor.ownerModuleId)),
|
|
47
50
|
}), { runtimeModuleCatalog, siteKey: runtime.site.key, locale: runtime.locale.current }),
|
|
@@ -239,20 +242,43 @@ export async function resolvePhiCmsRequest({ siteKey, locale, area, path, cookie
|
|
|
239
242
|
const routeBinding = areaOwnedStoragePath && areaAllowed
|
|
240
243
|
? resolvePhiCmsRoutePreset(routeTable, areaOwnedStoragePath)
|
|
241
244
|
: null;
|
|
242
|
-
const
|
|
245
|
+
const presetOrigin = { instantiated: false };
|
|
246
|
+
const instantiateRoutePreset = (binding) => instantiatePhiRoutePresetPage({
|
|
247
|
+
binding,
|
|
248
|
+
requestedPath: path,
|
|
249
|
+
areaMask,
|
|
250
|
+
siteId,
|
|
251
|
+
runtime: runtimeWithAuthProvider,
|
|
252
|
+
runtimeModuleCatalog,
|
|
253
|
+
activeModuleKeys,
|
|
254
|
+
});
|
|
255
|
+
const routePage = await resolvePhiCmsRoutePage({
|
|
243
256
|
binding: routeBinding,
|
|
244
257
|
requestedPath: path,
|
|
245
258
|
loadPage: loadResolvedCmsPage,
|
|
246
|
-
instantiatePreset: (binding) =>
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
siteId,
|
|
251
|
-
runtime: runtimeWithAuthProvider,
|
|
252
|
-
runtimeModuleCatalog,
|
|
253
|
-
activeModuleKeys,
|
|
254
|
-
}),
|
|
259
|
+
instantiatePreset: (binding) => {
|
|
260
|
+
presetOrigin.instantiated = true;
|
|
261
|
+
return instantiateRoutePreset(binding);
|
|
262
|
+
},
|
|
255
263
|
});
|
|
264
|
+
const routePresetAnswered = routePage?.sourcePreset?.presetKey === routeBinding?.descriptor.presetKey
|
|
265
|
+
&& routePage?.sourcePreset?.ownerModuleId === routeBinding?.descriptor.ownerModuleId;
|
|
266
|
+
/*
|
|
267
|
+
* A stored Page that answers for the route's preset holds no copy of the Overlays the preset declares;
|
|
268
|
+
* they are laid over it here, from the preset instantiated beside it (OVERLAYS.md, "Page preset
|
|
269
|
+
* Overlays"). The instantiated preset already has them, an exact Site Page of a dynamic route is its own
|
|
270
|
+
* Page, and a lookup renders nothing.
|
|
271
|
+
*/
|
|
272
|
+
const presetOverlayPage = purpose !== "lookup" && routePage && routeBinding && routePresetAnswered
|
|
273
|
+
&& !presetOrigin.instantiated
|
|
274
|
+
? await instantiateRoutePreset(routeBinding)
|
|
275
|
+
: null;
|
|
276
|
+
const loadedPage = routePage && presetOverlayPage
|
|
277
|
+
? {
|
|
278
|
+
...routePage,
|
|
279
|
+
page: composePhiCmsPagePresetOverlays({ tree: routePage.page, presetTree: presetOverlayPage.page }),
|
|
280
|
+
}
|
|
281
|
+
: routePage;
|
|
256
282
|
/*
|
|
257
283
|
* The record the Page is about, where its route names one: read once, here, for the Module's own tree
|
|
258
284
|
* and for a stored override of it alike -- the override holds no address, only Widgets bound to the
|
|
@@ -260,8 +286,6 @@ export async function resolvePhiCmsRequest({ siteKey, locale, area, path, cookie
|
|
|
260
286
|
* names no record is no Page: a 404 while rendering, nothing for a lookup.
|
|
261
287
|
*/
|
|
262
288
|
const routeIsParametrised = routeBinding ? Object.keys(routeBinding.params).length > 0 : false;
|
|
263
|
-
const routePresetAnswered = loadedPage?.sourcePreset?.presetKey === routeBinding?.descriptor.presetKey
|
|
264
|
-
&& loadedPage?.sourcePreset?.ownerModuleId === routeBinding?.descriptor.ownerModuleId;
|
|
265
289
|
const pageRecord = loadedPage && routeBinding && routeIsParametrised && routePresetAnswered
|
|
266
290
|
? await resolvePhiCmsPageRecord({
|
|
267
291
|
binding: routeBinding,
|
|
@@ -297,7 +321,8 @@ export async function resolvePhiCmsRequest({ siteKey, locale, area, path, cookie
|
|
|
297
321
|
* a folder whose Navigation container leads to one. The server follows the published Navigations to a
|
|
298
322
|
* Page reference, and the reference is resolved here, where Module routes are known.
|
|
299
323
|
*/
|
|
300
|
-
const
|
|
324
|
+
const folderLookup = !loadedPage && areaAllowed && areaOwnedStoragePath && areaOwnedStoragePath !== "/";
|
|
325
|
+
const siteFolderTargetReference = folderLookup
|
|
301
326
|
? await fetchSiteNavigationFolderTarget({
|
|
302
327
|
apiBaseUrl: readPhiServerApiCredentials().apiBaseUrl,
|
|
303
328
|
internalToken: readPhiServerApiCredentials().internalToken,
|
|
@@ -306,6 +331,16 @@ export async function resolvePhiCmsRequest({ siteKey, locale, area, path, cookie
|
|
|
306
331
|
path: areaOwnedStoragePath,
|
|
307
332
|
})
|
|
308
333
|
: null;
|
|
334
|
+
// Where the Site chose no target, a Module container's own (`folderTarget`) answers.
|
|
335
|
+
const folderTargetReference = siteFolderTargetReference ?? (folderLookup
|
|
336
|
+
? resolvePhiCmsModuleNavigationFolderTargets({
|
|
337
|
+
catalog,
|
|
338
|
+
area: requestedAreaKey,
|
|
339
|
+
activeModuleIds: activeModuleKeys,
|
|
340
|
+
routeTable,
|
|
341
|
+
addresses: [areaOwnedStoragePath],
|
|
342
|
+
}).get(areaOwnedStoragePath) ?? null
|
|
343
|
+
: null);
|
|
309
344
|
const folderTargetPath = folderTargetReference
|
|
310
345
|
? await resolvePhiAreaPageReferencePath({
|
|
311
346
|
runtime: runtimeWithAuthProvider,
|
|
@@ -11,6 +11,7 @@ import { getPhiExactSiteArea } from "./cms";
|
|
|
11
11
|
import { hasPhiCmsAuthorizedPreviewRead, resolvePhiCmsReviewParams, resolvePhiCmsRevisionFromSearchParams, resolvePhiCmsThemeReviewRequestContext, } from "./cms-review";
|
|
12
12
|
import { setPhiRequestNavigationContext, setPhiRequestRuntime, } from "./request-runtime";
|
|
13
13
|
import { buildPhiBlockRuntime, loadPhiSiteRequestContext } from "./runtime";
|
|
14
|
+
import { createPhiModuleMediaLoader } from "../gateway/server-module-media";
|
|
14
15
|
import { composePhiCmsActiveAreaOverlayPresets, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
|
|
15
16
|
import { resolvePhiAuthUiRuntimeProjection } from "./auth-ui-provider";
|
|
16
17
|
import { resolvePhiAreaRouteScope } from "./cms-request";
|
|
@@ -155,6 +156,7 @@ const loadPhiCmsRootScopeCached = cache(async function loadPhiCmsRootScopeCached
|
|
|
155
156
|
area: resolvedRoute.area,
|
|
156
157
|
path: resolvedRoute.cmsPath,
|
|
157
158
|
runtime,
|
|
159
|
+
loadModuleMedia: createPhiModuleMediaLoader(requestContext.site.key),
|
|
158
160
|
})
|
|
159
161
|
: null;
|
|
160
162
|
// The shell Header, Hero, and Footer Backgrounds live in this tree, and it is composed after the
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import type { PhiBlockRuntime } from "../types";
|
|
3
|
+
import type { PhiResolvedCmsRenderableTree } from "../types/cms";
|
|
4
|
+
import type { PhiCmsRuntimeRenderRegistry, PhiCmsWidgetPluginDefinition } from "../types/cms-plugins";
|
|
5
|
+
export type PhiWidgetTextDefinition = Partial<Pick<PhiCmsWidgetPluginDefinition<unknown>, "fields" | "translatesOwnText" | "configTexts">>;
|
|
6
|
+
export type PhiWidgetTextSubject = {
|
|
7
|
+
id: string;
|
|
8
|
+
flags: number;
|
|
9
|
+
config: Record<string, unknown>;
|
|
10
|
+
definition: PhiWidgetTextDefinition | null | undefined;
|
|
11
|
+
};
|
|
12
|
+
/** Each subject's config with its words translated, keyed by id; a subject with none is not in the map. */
|
|
13
|
+
export declare function translatePhiWidgetConfigTexts(subjects: readonly PhiWidgetTextSubject[], runtime: PhiBlockRuntime): Promise<Map<string, Record<string, unknown>>>;
|
|
14
|
+
export declare function translatePhiCmsTreeWidgetTexts<TTree extends PhiResolvedCmsRenderableTree>(tree: TTree, registry: Pick<PhiCmsRuntimeRenderRegistry, "runtimeWidgetPluginsByType" | "previewWidgetPluginsByType">, runtime: PhiBlockRuntime): Promise<TTree>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { PHI_TR_CTX_WEB_UI_LABEL, PHI_TR_CTX_WEB_UI_MESSAGE } from "../gateway/tr";
|
|
3
|
+
import { PhiCmsFlags } from "../constants/phi-cms";
|
|
4
|
+
import { collectPhiConfigTexts, collectPhiDeclaredConfigTexts, writePhiConfigTexts, } from "../helpers/config-text-fields";
|
|
5
|
+
import { hasPhiFlag } from "../helpers/flags";
|
|
6
|
+
import { maskPhiTextPlaceholders, resolvePhiTextPlaceholders } from "../helpers/text-placeholders";
|
|
7
|
+
import { PHI_TEXT_SOURCE_PRESET, readPhiTextSource } from "../helpers/text-source";
|
|
8
|
+
import { trBulkForLocale, trGlobalBulkForLocale } from "./translate";
|
|
9
|
+
/**
|
|
10
|
+
* The words in Widget configs in the reader's language, translated in one pass for a page.
|
|
11
|
+
*
|
|
12
|
+
* Translating is the rule, not something each Widget remembers: which fields are text is answered by
|
|
13
|
+
* their names (`helpers/config-text-fields.ts`), a text no field edits is declared by the Widget
|
|
14
|
+
* (`configTexts`), and every Widget is handed its config with those already in the reader's language. A
|
|
15
|
+
* Widget that `translatesOwnText` is left out -- a Markdown body is parsed into units before it is
|
|
16
|
+
* translated, and its author may want it left as written, which is why only such content Widgets carry
|
|
17
|
+
* the `NoTranslate` switch. A node a Preset flagged `NoTranslate` holds words it read from a Label Set in
|
|
18
|
+
* the reader's language already: nothing of it is sent, its placeholders are only filled in.
|
|
19
|
+
*
|
|
20
|
+
* Every text is masked before it is sent and filled after (`helpers/text-placeholders.ts`): `{site.name}`
|
|
21
|
+
* never reaches a translator, and a list entry's values stand as `%1` onwards, so "Up to %1 users" is
|
|
22
|
+
* translated once for every Site.
|
|
23
|
+
*
|
|
24
|
+
* The store is whose words they are (`helpers/text-source.ts`): a Preset's go to the platform's store,
|
|
25
|
+
* an author's to the Site's. One request per store and register, whatever the number of Widgets. The
|
|
26
|
+
* search index reads a Page's words through the same pass (`server-helpers/search-index.ts`).
|
|
27
|
+
*/
|
|
28
|
+
const CTX_BY_REGISTER = {
|
|
29
|
+
label: PHI_TR_CTX_WEB_UI_LABEL,
|
|
30
|
+
message: PHI_TR_CTX_WEB_UI_MESSAGE,
|
|
31
|
+
};
|
|
32
|
+
function collectSubjectTexts(subject) {
|
|
33
|
+
const { definition } = subject;
|
|
34
|
+
if (!definition || definition.translatesOwnText)
|
|
35
|
+
return [];
|
|
36
|
+
const located = [
|
|
37
|
+
...collectPhiConfigTexts(definition.fields ?? [], subject.config),
|
|
38
|
+
...collectPhiDeclaredConfigTexts(definition.configTexts ?? [], subject.config),
|
|
39
|
+
];
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
return located.filter((location) => {
|
|
42
|
+
const key = location.path.join("\u0000");
|
|
43
|
+
if (seen.has(key))
|
|
44
|
+
return false;
|
|
45
|
+
seen.add(key);
|
|
46
|
+
return true;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** Each subject's config with its words translated, keyed by id; a subject with none is not in the map. */
|
|
50
|
+
export async function translatePhiWidgetConfigTexts(subjects, runtime) {
|
|
51
|
+
const pending = subjects
|
|
52
|
+
.map((subject) => ({
|
|
53
|
+
subject,
|
|
54
|
+
batch: readPhiTextSource(subject.config.textSource) === PHI_TEXT_SOURCE_PRESET ? "global" : "site",
|
|
55
|
+
// Filled in all the same: a value or `{year}` is not a word, and a node left as written still shows it.
|
|
56
|
+
translate: !hasPhiFlag(subject.flags, PhiCmsFlags.NoTranslate),
|
|
57
|
+
locations: collectSubjectTexts(subject).map((location) => ({
|
|
58
|
+
location,
|
|
59
|
+
masked: maskPhiTextPlaceholders(location.text, location.values?.length ?? 0),
|
|
60
|
+
})),
|
|
61
|
+
}))
|
|
62
|
+
.filter((entry) => entry.locations.length > 0);
|
|
63
|
+
const configs = new Map();
|
|
64
|
+
if (pending.length === 0)
|
|
65
|
+
return configs;
|
|
66
|
+
const batches = new Map();
|
|
67
|
+
const positions = pending.map((entry) => entry.locations.map(({ location, masked }) => {
|
|
68
|
+
if (!entry.translate)
|
|
69
|
+
return null;
|
|
70
|
+
const key = `${entry.batch}:${location.register}`;
|
|
71
|
+
let texts = batches.get(key);
|
|
72
|
+
if (!texts) {
|
|
73
|
+
texts = [];
|
|
74
|
+
batches.set(key, texts);
|
|
75
|
+
}
|
|
76
|
+
texts.push(masked.text);
|
|
77
|
+
return { key, index: texts.length - 1 };
|
|
78
|
+
}));
|
|
79
|
+
const locale = runtime.locale.current;
|
|
80
|
+
const answers = new Map(await Promise.all([...batches].map(async ([key, texts]) => {
|
|
81
|
+
const [store, register] = key.split(":");
|
|
82
|
+
const ctx = CTX_BY_REGISTER[register];
|
|
83
|
+
const translated = store === "global"
|
|
84
|
+
? await trGlobalBulkForLocale(locale, texts, ctx)
|
|
85
|
+
: await trBulkForLocale(locale, texts, ctx);
|
|
86
|
+
return [key, translated];
|
|
87
|
+
})));
|
|
88
|
+
pending.forEach((entry, entryIndex) => {
|
|
89
|
+
configs.set(entry.subject.id, writePhiConfigTexts(entry.subject.config, entry.locations.map(({ location, masked }, index) => {
|
|
90
|
+
const position = positions[entryIndex][index];
|
|
91
|
+
const translated = (position && answers.get(position.key)?.[position.index]?.trim()) || masked.text;
|
|
92
|
+
return {
|
|
93
|
+
path: location.path,
|
|
94
|
+
text: resolvePhiTextPlaceholders(translated, masked.names, runtime, location.values ?? []),
|
|
95
|
+
};
|
|
96
|
+
})));
|
|
97
|
+
});
|
|
98
|
+
return configs;
|
|
99
|
+
}
|
|
100
|
+
export async function translatePhiCmsTreeWidgetTexts(tree, registry, runtime) {
|
|
101
|
+
const configs = await translatePhiWidgetConfigTexts(tree.contentWidgets.map((widget) => ({
|
|
102
|
+
id: widget.id,
|
|
103
|
+
flags: widget.flags,
|
|
104
|
+
config: widget.config,
|
|
105
|
+
definition: registry.runtimeWidgetPluginsByType.get(widget.widgetType)
|
|
106
|
+
?? registry.previewWidgetPluginsByType.get(widget.widgetType),
|
|
107
|
+
})), runtime);
|
|
108
|
+
if (configs.size === 0)
|
|
109
|
+
return tree;
|
|
110
|
+
return {
|
|
111
|
+
...tree,
|
|
112
|
+
contentWidgets: tree.contentWidgets.map((widget) => {
|
|
113
|
+
const config = configs.get(widget.id);
|
|
114
|
+
return config ? { ...widget, config } : widget;
|
|
115
|
+
}),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
/**
|
|
3
|
+
* The Pages Module containers' folder addresses lead to in the Area this request serves
|
|
4
|
+
* (`folderTarget`), for the addresses asked; empty where the request set up no Navigation context for
|
|
5
|
+
* the Area -- a render outside a page request -- since nothing then says which Modules answer.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolvePhiRequestModuleFolderTargets(area: unknown, addresses: readonly string[]): Map<string, string>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { isPhiCmsAreaKey } from "../constants/cms-areas";
|
|
3
|
+
import { resolvePhiCmsModuleNavigationFolderTargets } from "../plugins/runtime-modules/descriptor-compiler";
|
|
4
|
+
import { maybeGetPhiRequestNavigationContext } from "./request-runtime";
|
|
5
|
+
/**
|
|
6
|
+
* The Pages Module containers' folder addresses lead to in the Area this request serves
|
|
7
|
+
* (`folderTarget`), for the addresses asked; empty where the request set up no Navigation context for
|
|
8
|
+
* the Area -- a render outside a page request -- since nothing then says which Modules answer.
|
|
9
|
+
*/
|
|
10
|
+
export function resolvePhiRequestModuleFolderTargets(area, addresses) {
|
|
11
|
+
const context = isPhiCmsAreaKey(area) ? maybeGetPhiRequestNavigationContext(area) : null;
|
|
12
|
+
if (!context || !isPhiCmsAreaKey(area))
|
|
13
|
+
return new Map();
|
|
14
|
+
return resolvePhiCmsModuleNavigationFolderTargets({ ...context, area, addresses });
|
|
15
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "server-only";
|
|
2
|
+
import { translatePhiWidgetConfigTexts } from "./cms-widget-texts";
|
|
2
3
|
import { createHash } from "node:crypto";
|
|
3
4
|
import { PHI_SHARED_PACKAGE_NAME } from "../constants/package";
|
|
4
5
|
import { createPhiRuntimeModuleId } from "../constants/module-identity";
|
|
@@ -315,12 +316,20 @@ async function readDocument({ bridge, area, locale, context, path, loadPlugin, a
|
|
|
315
316
|
});
|
|
316
317
|
const lines = await runWithPhiRequestRuntime(resolved.runtime, async () => {
|
|
317
318
|
const collected = [];
|
|
318
|
-
|
|
319
|
-
|
|
319
|
+
const plugins = await Promise.all(visible.contentWidgets.map((widget) => loadPlugin(widget.widgetType)));
|
|
320
|
+
// The words as the render shows them: translated by the same pass (`server-helpers/cms-widget-texts.ts`).
|
|
321
|
+
const translatedConfigs = await translatePhiWidgetConfigTexts(visible.contentWidgets.map((widget, index) => ({
|
|
322
|
+
id: widget.id,
|
|
323
|
+
flags: widget.flags,
|
|
324
|
+
config: widget.config,
|
|
325
|
+
definition: plugins[index]?.searchText ? plugins[index] : null,
|
|
326
|
+
})), resolved.runtime);
|
|
327
|
+
for (const [index, widget] of visible.contentWidgets.entries()) {
|
|
328
|
+
const plugin = plugins[index];
|
|
320
329
|
if (!plugin?.searchText)
|
|
321
330
|
continue;
|
|
322
331
|
try {
|
|
323
|
-
const config = plugin.parseConfig(widget.config);
|
|
332
|
+
const config = plugin.parseConfig(translatedConfigs.get(widget.id) ?? widget.config);
|
|
324
333
|
collected.push(...await plugin.searchText({ widget, config, runtime: resolved.runtime }));
|
|
325
334
|
}
|
|
326
335
|
catch (error) {
|