@phis/ui 0.5.5 → 0.5.7
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/controls/phi-anchor-nav-control.js +18 -1
- package/components/controls/phi-background-control.d.ts +9 -1
- package/components/controls/phi-background-control.js +66 -20
- package/components/widgets/config/background-pattern-live.d.ts +25 -0
- package/components/widgets/config/background-pattern-live.js +50 -0
- 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.d.ts +4 -1
- package/components/widgets/shared/markdown-body-client.js +10 -5
- package/components/widgets/shared/markdown-image-vocabulary.d.ts +19 -6
- package/components/widgets/shared/markdown-image-vocabulary.js +34 -9
- package/components/widgets/shared/markdown-render.d.ts +2 -1
- package/components/widgets/shared/markdown-render.js +4 -1
- 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/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/route-address-check.d.ts +35 -0
- package/helpers/route-address-check.js +28 -0
- package/module-page-check.d.ts +2 -0
- package/module-page-check.js +2 -0
- package/package.json +1 -1
- package/plugins/runtime-modules/builder/area-shell-presets.server.js +2 -0
- package/plugins/runtime-modules/builder/clients/inspector-config-field.d.ts +1 -1
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +8 -0
- 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/core/widgets/breadcrumb/server.js +9 -2
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +17 -1
- package/plugins/runtime-modules/core/widgets/card/config.js +20 -2
- package/plugins/runtime-modules/core/widgets/card/editor.js +2 -0
- package/plugins/runtime-modules/core/widgets/card/server.js +2 -0
- package/plugins/runtime-modules/core/widgets/description/config.d.ts +10 -0
- package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +10 -0
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +10 -0
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +16 -1
- package/plugins/runtime-modules/core/widgets/markdown/config.js +18 -1
- package/plugins/runtime-modules/core/widgets/result/config.d.ts +10 -0
- package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +10 -0
- package/plugins/runtime-modules/core/widgets/table/config.d.ts +34 -0
- package/plugins/runtime-modules/descriptor-compiler.d.ts +23 -3
- package/plugins/runtime-modules/descriptor-compiler.js +107 -12
- package/server-helpers/cms-area.js +9 -1
- package/server-helpers/cms-request.js +15 -2
- package/server-helpers/cms-root.js +2 -0
- package/server-helpers/module-folder-targets.d.ts +7 -0
- package/server-helpers/module-folder-targets.js +15 -0
- package/styles/controls.css +30 -5
- package/types/cms-module-descriptors.d.ts +24 -0
- package/types/cms-plugins.d.ts +8 -0
- package/types/core-widget-placements.d.ts +2 -1
- package/types/module-media.d.ts +31 -0
- package/types/module-media.js +11 -0
- package/types.d.ts +1 -0
|
@@ -7,12 +7,14 @@ import { resolvePhiRuntimeModuleSourceLocale } from "../../types/runtime-module-
|
|
|
7
7
|
import { canPhiViewerAccess, PHI_VIEWER_ACCESS_ANYONE, } from "../../types/access";
|
|
8
8
|
import { mergePhiCmsShellTrees, omitPhiCmsShellCompositionNodes, } from "./shell-tree-composition";
|
|
9
9
|
import { resolvePhiRuntimeModuleAreaRoutePath } from "../../helpers/runtime-module-route-path";
|
|
10
|
+
import { createPhiPageReference } from "../../types/references";
|
|
10
11
|
import { choosePhiAreaRootApplicant, orderPhiAreaPathClaimsByCover, isPhiAssignablePublicRoutePath, } from "../../helpers/cms-area-config";
|
|
11
12
|
import { resolvePhiLayoutCreationPreset } from "../../helpers/cms-layout-defaults";
|
|
12
13
|
import { PHI_DIALOG_BLEED_BODY_CONFIG, PHI_DIALOG_BODY_CONFIG, PHI_DIALOG_COMMANDS_CONFIG, PHI_DIALOG_WIDTH, isPhiFormSingleColumn, } from "../../helpers/cms-dialog";
|
|
13
14
|
import { PhiCmsWidgetType } from "../../constants/cms-widget-types";
|
|
14
15
|
import { buildPhiBasePageLayoutNode, PHI_BASE_PAGE_LAYOUT_NODE_ID, } from "../../components/regions/presets/phi-base-page-layout";
|
|
15
16
|
import { concatPhiCmsTreeControllerSettings } from "../../helpers/cms-tree-controller-settings";
|
|
17
|
+
import { createPhiModuleMediaResolver } from "../../helpers/module-media";
|
|
16
18
|
const PHI_CMS_REGION_TYPE_VALUES = new Set(Object.values(PhiCmsRegionType));
|
|
17
19
|
const PHI_ROUTE_PARAMETER_PATTERN = /^:[A-Za-z][A-Za-z0-9_]*$/;
|
|
18
20
|
const PHI_NAVIGATION_ANCHORS = new Set([
|
|
@@ -468,6 +470,16 @@ export function compilePhiCmsDescriptorCatalog({ catalog, areaDefinitions, }) {
|
|
|
468
470
|
label: `${label}/${item.itemKey}`,
|
|
469
471
|
});
|
|
470
472
|
}
|
|
473
|
+
if (item.folderTarget !== undefined) {
|
|
474
|
+
/*
|
|
475
|
+
* The child's Page answers the folder address. Only a route has one: an Overlay, an external
|
|
476
|
+
* address or a sub-container is no Page to forward to.
|
|
477
|
+
*/
|
|
478
|
+
const child = (item.children ?? []).find((entry) => entry.itemKey === item.folderTarget);
|
|
479
|
+
if (!child?.routePresetKey) {
|
|
480
|
+
throw new Error(`${label}/${item.itemKey}: folderTarget "${item.folderTarget}" names no direct child that goes to a route.`);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
471
483
|
visitNavigationRouteReferences(item.children ?? [], ownerModuleId, area, label);
|
|
472
484
|
}
|
|
473
485
|
};
|
|
@@ -908,10 +920,51 @@ function buildResolvedNavigationNode(catalog, routeTable, navKey, ownerModuleId,
|
|
|
908
920
|
standsLast: "standing" in descriptor && descriptor.standing === "last",
|
|
909
921
|
// An item that named a route and got nothing back. A container never is one: it named nothing.
|
|
910
922
|
isUnrouted: Boolean(descriptor.routePresetKey) && !target,
|
|
923
|
+
folderTargetItemKey: descriptor.folderTarget ?? null,
|
|
911
924
|
intrinsicChildren,
|
|
912
925
|
injection,
|
|
913
926
|
};
|
|
914
927
|
}
|
|
928
|
+
/** The folder a path lies in; `/` is the Area root, a slot and no folder. */
|
|
929
|
+
function parentNavigationFolder(path) {
|
|
930
|
+
const index = path.lastIndexOf("/");
|
|
931
|
+
return index > 0 ? path.slice(0, index) : "/";
|
|
932
|
+
}
|
|
933
|
+
function resolveModuleNavigationFolderAddress(children) {
|
|
934
|
+
const folders = new Set(children.flatMap((child) => {
|
|
935
|
+
const path = child.kind === "container"
|
|
936
|
+
? resolveModuleNavigationFolderAddress(child.children)
|
|
937
|
+
: child.target?.kind === "module" ? child.target.path : null;
|
|
938
|
+
return path ? [parentNavigationFolder(path)] : [];
|
|
939
|
+
}));
|
|
940
|
+
const [address] = folders;
|
|
941
|
+
return folders.size === 1 && address && address !== "/" ? address : null;
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* A Module container's folder, as its `folderTarget` names it: the folder its direct children share --
|
|
945
|
+
* a link by its route's path, a sub-container by its own folder -- and the Page of the child it names.
|
|
946
|
+
* The same rule as a Site's folder (`builder/navigation-folder-address.ts`). None where the children
|
|
947
|
+
* share no folder, or the named child does not answer here: the address then leads nowhere, as a
|
|
948
|
+
* container without a target does.
|
|
949
|
+
*/
|
|
950
|
+
function resolveModuleNavigationFolder(node, children) {
|
|
951
|
+
const address = resolveModuleNavigationFolderAddress(children);
|
|
952
|
+
if (!address) {
|
|
953
|
+
return null;
|
|
954
|
+
}
|
|
955
|
+
const childId = node.intrinsicChildren.find((child) => child.definitionItemKey === node.folderTargetItemKey)?.item.id;
|
|
956
|
+
const target = children.find((child) => child.id === childId)?.target;
|
|
957
|
+
if (target?.kind !== "module") {
|
|
958
|
+
return null;
|
|
959
|
+
}
|
|
960
|
+
return {
|
|
961
|
+
address,
|
|
962
|
+
target: {
|
|
963
|
+
kind: "page",
|
|
964
|
+
reference: createPhiPageReference({ kind: "module", ownerModuleId: target.ownerModuleId, presetKey: target.presetKey }),
|
|
965
|
+
},
|
|
966
|
+
};
|
|
967
|
+
}
|
|
915
968
|
function orderNavigationSiblings(intrinsic, injected, parentItemKey) {
|
|
916
969
|
/*
|
|
917
970
|
* An Area's entries first, the contributed ones after -- except the entries that said they stand
|
|
@@ -1097,10 +1150,13 @@ export function resolvePhiCmsActiveNavigationSurfaces({ catalog, area, activeMod
|
|
|
1097
1150
|
*/
|
|
1098
1151
|
const materialize = (intrinsic, injected, parentItemKey) => orderNavigationSiblings(intrinsic, injected, parentItemKey)
|
|
1099
1152
|
.filter(isNavigationNodeVisible)
|
|
1100
|
-
.map((node) =>
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1153
|
+
.map((node) => {
|
|
1154
|
+
const children = materialize(node.intrinsicChildren, injectedByParent.get(node.definitionItemKey) ?? [], node.definitionItemKey);
|
|
1155
|
+
const folder = node.item.kind === "container" && node.folderTargetItemKey
|
|
1156
|
+
? resolveModuleNavigationFolder(node, children)
|
|
1157
|
+
: null;
|
|
1158
|
+
return { ...node.item, ...(folder ? { folder } : {}), children };
|
|
1159
|
+
})
|
|
1104
1160
|
.filter((item) => item.kind !== "container" || item.children.length > 0);
|
|
1105
1161
|
return {
|
|
1106
1162
|
area,
|
|
@@ -1110,6 +1166,34 @@ export function resolvePhiCmsActiveNavigationSurfaces({ catalog, area, activeMod
|
|
|
1110
1166
|
};
|
|
1111
1167
|
});
|
|
1112
1168
|
}
|
|
1169
|
+
/**
|
|
1170
|
+
* The Pages Module containers' folder addresses lead to by their descriptors (`folderTarget`), keyed by
|
|
1171
|
+
* address; an address no Module container answers is not in the map.
|
|
1172
|
+
*
|
|
1173
|
+
* Asked where the Site's published Navigations name no target for an address -- a request no Page
|
|
1174
|
+
* answers (`server-helpers/cms-request.ts`), a breadcrumb's folders -- so a Site's choice replaces the
|
|
1175
|
+
* Module's, not the reverse. Every surface of the Area is searched once, because a folder address is the
|
|
1176
|
+
* Area's, not one menu's.
|
|
1177
|
+
*/
|
|
1178
|
+
export function resolvePhiCmsModuleNavigationFolderTargets(input) {
|
|
1179
|
+
const wanted = new Set(input.addresses);
|
|
1180
|
+
const found = new Map();
|
|
1181
|
+
const visit = (items) => {
|
|
1182
|
+
for (const item of items) {
|
|
1183
|
+
const address = item.folder?.address;
|
|
1184
|
+
if (address && wanted.has(address) && !found.has(address) && item.folder?.target?.kind === "page") {
|
|
1185
|
+
found.set(address, item.folder.target.reference);
|
|
1186
|
+
}
|
|
1187
|
+
visit(item.children);
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
if (wanted.size === 0)
|
|
1191
|
+
return found;
|
|
1192
|
+
for (const surface of resolvePhiCmsActiveNavigationSurfaces(input)) {
|
|
1193
|
+
visit(surface.items);
|
|
1194
|
+
}
|
|
1195
|
+
return found;
|
|
1196
|
+
}
|
|
1113
1197
|
export function resolvePhiCmsNavigationOverlay(surface, overlay) {
|
|
1114
1198
|
if (!overlay) {
|
|
1115
1199
|
return { surface, diagnostics: [] };
|
|
@@ -1543,7 +1627,7 @@ function assertPhiCmsAreaOverlayTree(descriptor, tree, page, forms) {
|
|
|
1543
1627
|
}
|
|
1544
1628
|
}
|
|
1545
1629
|
}
|
|
1546
|
-
export async function composePhiCmsActiveAreaOverlayPresets({ tree, catalog, activeModuleIds, siteId, area, path, runtime, }) {
|
|
1630
|
+
export async function composePhiCmsActiveAreaOverlayPresets({ tree, catalog, activeModuleIds, siteId, area, path, runtime, loadModuleMedia, }) {
|
|
1547
1631
|
const descriptors = (catalog.areaOverlaysByArea.get(area) ?? [])
|
|
1548
1632
|
.filter((descriptor) => activeModuleIds.has(descriptor.ownerModuleId));
|
|
1549
1633
|
if (descriptors.length === 0)
|
|
@@ -1561,7 +1645,12 @@ export async function composePhiCmsActiveAreaOverlayPresets({ tree, catalog, act
|
|
|
1561
1645
|
// Loaded side by side -- each contribution is a Core round trip of its own -- and merged in
|
|
1562
1646
|
// declaration order, which is what the ids and the controller settings below depend on.
|
|
1563
1647
|
const targetRuntime = resolveTargetRuntime(runtime, area);
|
|
1564
|
-
const contributions = await Promise.all(descriptors.map((descriptor) => descriptor.loadTree({
|
|
1648
|
+
const contributions = await Promise.all(descriptors.map((descriptor) => descriptor.loadTree({
|
|
1649
|
+
page,
|
|
1650
|
+
runtime: targetRuntime,
|
|
1651
|
+
catalog,
|
|
1652
|
+
media: createPhiModuleMediaResolver(descriptor.ownerModuleId, loadModuleMedia),
|
|
1653
|
+
})));
|
|
1565
1654
|
for (const [index, descriptor] of descriptors.entries()) {
|
|
1566
1655
|
const contribution = contributions[index];
|
|
1567
1656
|
assertPhiCmsAreaOverlayTree(descriptor, contribution, page, catalog.formDefinitionsById);
|
|
@@ -1591,27 +1680,32 @@ export async function composePhiCmsActiveAreaOverlayPresets({ tree, catalog, act
|
|
|
1591
1680
|
function resolveTargetRuntime(runtime, area) {
|
|
1592
1681
|
return runtime.area === area ? runtime : { ...runtime, area };
|
|
1593
1682
|
}
|
|
1594
|
-
async function loadShellTree(descriptor, catalog, page, runtime) {
|
|
1683
|
+
async function loadShellTree(descriptor, catalog, page, runtime, loadModuleMedia) {
|
|
1595
1684
|
let composedTree = null;
|
|
1596
1685
|
for (const source of descriptor.composition ?? []) {
|
|
1597
1686
|
const sourceDescriptor = catalog.areaShellByIdentity.get(buildPhiCmsPresetIdentityKey(source.ownerModuleId, source.presetKey))?.descriptor;
|
|
1598
1687
|
if (!sourceDescriptor) {
|
|
1599
1688
|
throw new Error(`${descriptor.ownerModuleId}/${descriptor.presetKey}: unresolved shell composition source.`);
|
|
1600
1689
|
}
|
|
1601
|
-
const sourceTree = omitPhiCmsShellCompositionNodes(await loadShellTree(sourceDescriptor, catalog, page, runtime), sourceDescriptor, source.omitRegionTypes ?? [], source.omitNodeKeys ?? []);
|
|
1690
|
+
const sourceTree = omitPhiCmsShellCompositionNodes(await loadShellTree(sourceDescriptor, catalog, page, runtime, loadModuleMedia), sourceDescriptor, source.omitRegionTypes ?? [], source.omitNodeKeys ?? []);
|
|
1602
1691
|
composedTree = composedTree ? mergePhiCmsShellTrees(composedTree, sourceTree) : sourceTree;
|
|
1603
1692
|
}
|
|
1604
|
-
const ownTree = await descriptor.loadTree({
|
|
1693
|
+
const ownTree = await descriptor.loadTree({
|
|
1694
|
+
page,
|
|
1695
|
+
runtime,
|
|
1696
|
+
catalog,
|
|
1697
|
+
media: createPhiModuleMediaResolver(descriptor.ownerModuleId, loadModuleMedia),
|
|
1698
|
+
});
|
|
1605
1699
|
assertPhiCmsPresetTreeContract(ownTree, page, catalog.formDefinitionsById);
|
|
1606
1700
|
return composedTree ? mergePhiCmsShellTrees(composedTree, ownTree) : ownTree;
|
|
1607
1701
|
}
|
|
1608
|
-
export async function instantiatePhiCmsAreaShellPreset({ binding, catalog, siteId, path, runtime, }) {
|
|
1702
|
+
export async function instantiatePhiCmsAreaShellPreset({ binding, catalog, siteId, path, runtime, loadModuleMedia, }) {
|
|
1609
1703
|
const page = createSyntheticPresetPage({ siteId, area: binding.descriptor.area, path });
|
|
1610
|
-
const tree = await loadShellTree(binding.descriptor, catalog, page, resolveTargetRuntime(runtime, binding.descriptor.area));
|
|
1704
|
+
const tree = await loadShellTree(binding.descriptor, catalog, page, resolveTargetRuntime(runtime, binding.descriptor.area), loadModuleMedia);
|
|
1611
1705
|
assertPhiCmsPresetTreeContract(tree, page, catalog.formDefinitionsById);
|
|
1612
1706
|
return tree;
|
|
1613
1707
|
}
|
|
1614
|
-
export async function instantiatePhiCmsRoutePreset({ binding, catalog, activeModuleIds, siteId, path, runtime, resolveMissingPageTitle, }) {
|
|
1708
|
+
export async function instantiatePhiCmsRoutePreset({ binding, catalog, activeModuleIds, siteId, path, runtime, loadModuleMedia, resolveMissingPageTitle, }) {
|
|
1615
1709
|
const descriptor = binding.descriptor;
|
|
1616
1710
|
const page = createSyntheticPresetPage({
|
|
1617
1711
|
siteId,
|
|
@@ -1625,6 +1719,7 @@ export async function instantiatePhiCmsRoutePreset({ binding, catalog, activeMod
|
|
|
1625
1719
|
catalog,
|
|
1626
1720
|
activeModuleIds,
|
|
1627
1721
|
params: binding.params,
|
|
1722
|
+
media: createPhiModuleMediaResolver(descriptor.ownerModuleId, loadModuleMedia),
|
|
1628
1723
|
});
|
|
1629
1724
|
const tree = loadedTree.pageMeta?.title
|
|
1630
1725
|
? loadedTree
|
|
@@ -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,7 +3,7 @@ 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
8
|
import { composePhiCmsPagePresetOverlays } from "../plugins/runtime-modules/page-preset-overlays";
|
|
9
9
|
import { resolvePhiCmsRoutePage } from "../plugins/runtime-modules/route-page-resolution";
|
|
@@ -26,6 +26,7 @@ import { buildPhiBlockRuntime, loadPhiSiteRequestContext, } from "./runtime";
|
|
|
26
26
|
import { trForLocale } from "./translate";
|
|
27
27
|
import { readPhiAreaLandingSelection, readPhiAreaPresetRuntimeModuleIds, readPhiAreaPublicRoutePaths, } from "../helpers/cms-area-config";
|
|
28
28
|
import { readPhiServerApiCredentials } from "../helpers/phis-server-credentials";
|
|
29
|
+
import { createPhiModuleMediaLoader } from "../gateway/server-module-media";
|
|
29
30
|
async function instantiatePhiRoutePresetPage({ binding, requestedPath, areaMask, siteId, runtime, runtimeModuleCatalog, activeModuleKeys, }) {
|
|
30
31
|
const catalog = resolvePhiCmsDescriptorCatalog(runtimeModuleCatalog);
|
|
31
32
|
return {
|
|
@@ -43,6 +44,7 @@ async function instantiatePhiRoutePresetPage({ binding, requestedPath, areaMask,
|
|
|
43
44
|
siteId,
|
|
44
45
|
path: requestedPath,
|
|
45
46
|
runtime,
|
|
47
|
+
loadModuleMedia: createPhiModuleMediaLoader(runtime.site.key),
|
|
46
48
|
// The route's title is the owning Module's text, written in that Module's language.
|
|
47
49
|
resolveMissingPageTitle: (sourceTitle) => trForLocale(runtime.locale.current, sourceTitle, 0, 0, "text", catalog.sourceLocaleByModuleId.get(binding.descriptor.ownerModuleId)),
|
|
48
50
|
}), { runtimeModuleCatalog, siteKey: runtime.site.key, locale: runtime.locale.current }),
|
|
@@ -319,7 +321,8 @@ export async function resolvePhiCmsRequest({ siteKey, locale, area, path, cookie
|
|
|
319
321
|
* a folder whose Navigation container leads to one. The server follows the published Navigations to a
|
|
320
322
|
* Page reference, and the reference is resolved here, where Module routes are known.
|
|
321
323
|
*/
|
|
322
|
-
const
|
|
324
|
+
const folderLookup = !loadedPage && areaAllowed && areaOwnedStoragePath && areaOwnedStoragePath !== "/";
|
|
325
|
+
const siteFolderTargetReference = folderLookup
|
|
323
326
|
? await fetchSiteNavigationFolderTarget({
|
|
324
327
|
apiBaseUrl: readPhiServerApiCredentials().apiBaseUrl,
|
|
325
328
|
internalToken: readPhiServerApiCredentials().internalToken,
|
|
@@ -328,6 +331,16 @@ export async function resolvePhiCmsRequest({ siteKey, locale, area, path, cookie
|
|
|
328
331
|
path: areaOwnedStoragePath,
|
|
329
332
|
})
|
|
330
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);
|
|
331
344
|
const folderTargetPath = folderTargetReference
|
|
332
345
|
? await resolvePhiAreaPageReferencePath({
|
|
333
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,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
|
+
}
|
package/styles/controls.css
CHANGED
|
@@ -773,7 +773,32 @@ h5.phi-typography, .phi-typography h5 {
|
|
|
773
773
|
.phi-markdown-body {
|
|
774
774
|
/* The gap between picture and text, on the Phi scale (`PHI_SPACE.md`), not Ant Design's margins. */
|
|
775
775
|
--phi-markdown-float-gap: var(--phi-padding-md, 34px);
|
|
776
|
-
|
|
776
|
+
/*
|
|
777
|
+
* The step of the line a floated picture takes (`PHI_MARKDOWN_IMAGE_FLOAT_WIDTHS`): the divisor is a power
|
|
778
|
+
* of φ -- φ⁴, φ³, φ² and φ. Without a word it is φ², the golden share above. The Widget sets it for all
|
|
779
|
+
* its pictures on the body, a figure for itself; the width is written out where it is used, because a
|
|
780
|
+
* custom property holding the whole `calc()` would be settled on the body and never see a figure's step.
|
|
781
|
+
*/
|
|
782
|
+
--phi-markdown-float-divisor: 2.618034;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
.phi-markdown-body--float-width-small,
|
|
786
|
+
.phi-markdown-figure--width-small {
|
|
787
|
+
--phi-markdown-float-divisor: 6.854102;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
.phi-markdown-body--float-width-medium,
|
|
791
|
+
.phi-markdown-figure--width-medium {
|
|
792
|
+
--phi-markdown-float-divisor: 4.236068;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
.phi-markdown-figure--width-large {
|
|
796
|
+
--phi-markdown-float-divisor: 2.618034;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
.phi-markdown-body--float-width-xlarge,
|
|
800
|
+
.phi-markdown-figure--width-xlarge {
|
|
801
|
+
--phi-markdown-float-divisor: 1.618034;
|
|
777
802
|
}
|
|
778
803
|
|
|
779
804
|
.phi-markdown-body :is(img):not(:where(.phi-markdown-figure *)) {
|
|
@@ -789,13 +814,13 @@ h5.phi-typography, .phi-typography h5 {
|
|
|
789
814
|
@container (min-width: 560px) {
|
|
790
815
|
.phi-markdown-body--float-start :is(img):not(:where(.phi-markdown-figure *)) {
|
|
791
816
|
float: inline-start;
|
|
792
|
-
width: var(--phi-markdown-float-
|
|
817
|
+
width: calc((100% - var(--phi-markdown-float-gap)) / var(--phi-markdown-float-divisor));
|
|
793
818
|
margin-inline-end: var(--phi-markdown-float-gap);
|
|
794
819
|
}
|
|
795
820
|
|
|
796
821
|
.phi-markdown-body--float-end :is(img):not(:where(.phi-markdown-figure *)) {
|
|
797
822
|
float: inline-end;
|
|
798
|
-
width: var(--phi-markdown-float-
|
|
823
|
+
width: calc((100% - var(--phi-markdown-float-gap)) / var(--phi-markdown-float-divisor));
|
|
799
824
|
margin-inline-start: var(--phi-markdown-float-gap);
|
|
800
825
|
}
|
|
801
826
|
}
|
|
@@ -819,13 +844,13 @@ h5.phi-typography, .phi-typography h5 {
|
|
|
819
844
|
@container (min-width: 560px) {
|
|
820
845
|
.phi-markdown-figure--float-start {
|
|
821
846
|
float: inline-start;
|
|
822
|
-
width: var(--phi-markdown-float-
|
|
847
|
+
width: calc((100% - var(--phi-markdown-float-gap)) / var(--phi-markdown-float-divisor));
|
|
823
848
|
margin-inline-end: var(--phi-markdown-float-gap);
|
|
824
849
|
}
|
|
825
850
|
|
|
826
851
|
.phi-markdown-figure--float-end {
|
|
827
852
|
float: inline-end;
|
|
828
|
-
width: var(--phi-markdown-float-
|
|
853
|
+
width: calc((100% - var(--phi-markdown-float-gap)) / var(--phi-markdown-float-divisor));
|
|
829
854
|
margin-inline-start: var(--phi-markdown-float-gap);
|
|
830
855
|
}
|
|
831
856
|
}
|
|
@@ -8,6 +8,7 @@ import type { PhiViewerAccessPolicy } from "./access";
|
|
|
8
8
|
import type { PhiSignalRoute } from "./signals";
|
|
9
9
|
import type { PhiCmsInstanceId } from "./cms-instance-id";
|
|
10
10
|
import type { PhiRuntimeModuleFormDefinition } from "../components/forms/form-registry";
|
|
11
|
+
import type { PhiModuleMediaResolver } from "./module-media";
|
|
11
12
|
export type PhiRuntimeModuleId = `${string}/${string}`;
|
|
12
13
|
export type PhiCmsPresetIdentity = {
|
|
13
14
|
ownerModuleId: PhiRuntimeModuleId;
|
|
@@ -31,6 +32,12 @@ export type PhiCmsDescriptorBuildContext = {
|
|
|
31
32
|
page: PhiCmsPageNode;
|
|
32
33
|
runtime: PhiBlockRuntime;
|
|
33
34
|
catalog: PhiCmsCompiledDescriptorCatalog;
|
|
35
|
+
/**
|
|
36
|
+
* The ids the Site's Media library holds for the names the owning Module's own package declares
|
|
37
|
+
* (`phis.media`). Area shell, Area Overlay and route presets get it; a Theme preset or block loader has
|
|
38
|
+
* no context and does not.
|
|
39
|
+
*/
|
|
40
|
+
media: PhiModuleMediaResolver;
|
|
34
41
|
};
|
|
35
42
|
export type PhiCmsAreaShellPresetDescriptor = PhiCmsPresetIdentity & {
|
|
36
43
|
shellPresetVersion: number;
|
|
@@ -174,6 +181,15 @@ export type PhiCmsNavigationBaseItemDescriptor = {
|
|
|
174
181
|
signalRoutes?: {
|
|
175
182
|
emits?: readonly PhiSignalRoute[];
|
|
176
183
|
};
|
|
184
|
+
/**
|
|
185
|
+
* On an entry with children: where its folder address leads -- the itemKey of one direct child that
|
|
186
|
+
* goes to a route of the same Module, usually an overview. The folder address is the folder the
|
|
187
|
+
* children's paths share (`/faq` for `/faq/overview` and `/faq/hosting`); a request for it is
|
|
188
|
+
* forwarded to that child's Page. A Page is never a folder, so the overview is a child like the
|
|
189
|
+
* others and the container has no Page of its own. A Site's own choice in the Builder replaces it
|
|
190
|
+
* (phis-server REFERENCES.md, "Folder addresses"); THIRD_PARTY_MODULES.md, "Addresses and folders".
|
|
191
|
+
*/
|
|
192
|
+
folderTarget?: string;
|
|
177
193
|
children?: readonly PhiCmsNavigationBaseItemDescriptor[];
|
|
178
194
|
};
|
|
179
195
|
/**
|
|
@@ -263,6 +279,8 @@ export type PhiCmsNavigationInjectionItemDescriptor = {
|
|
|
263
279
|
signalRoutes?: {
|
|
264
280
|
emits?: readonly PhiSignalRoute[];
|
|
265
281
|
};
|
|
282
|
+
/** As on an Area's own entry: the direct child the folder address leads to. */
|
|
283
|
+
folderTarget?: string;
|
|
266
284
|
children?: readonly PhiCmsNavigationInjectionItemDescriptor[];
|
|
267
285
|
};
|
|
268
286
|
/**
|
|
@@ -338,6 +356,12 @@ export type PhiCmsResolvedNavigationItem = {
|
|
|
338
356
|
accessPolicy?: PhiViewerAccessPolicy;
|
|
339
357
|
/** The routes this entry sends on when it is chosen, carried through from its descriptor. */
|
|
340
358
|
emits?: readonly PhiSignalRoute[];
|
|
359
|
+
/**
|
|
360
|
+
* A Module container's folder, from its descriptor's `folderTarget`: the address its children share
|
|
361
|
+
* and the Page of the child it names. Absent where the children share no folder. A Site's override
|
|
362
|
+
* for the container replaces it.
|
|
363
|
+
*/
|
|
364
|
+
folder?: PhiCmsNavigationFolder;
|
|
341
365
|
children: readonly PhiCmsResolvedNavigationItem[];
|
|
342
366
|
};
|
|
343
367
|
export type PhiCmsResolvedNavigationSurface = {
|
package/types/cms-plugins.d.ts
CHANGED
|
@@ -315,6 +315,14 @@ export type PhiCmsConfigField = (PhiCmsConfigFieldBase & {
|
|
|
315
315
|
type: "surface";
|
|
316
316
|
/** Whether the mode is offered; left out, it is. */
|
|
317
317
|
tone?: false;
|
|
318
|
+
}) | (PhiCmsConfigFieldBase & {
|
|
319
|
+
/**
|
|
320
|
+
* A Background Overlay (`PhiBackgroundOverlay`, `components/widgets/config/background.ts`) edited
|
|
321
|
+
* alone, for a Widget that draws one over something of its own, such as the Card over its picture.
|
|
322
|
+
* `key` holds the Overlay; absent or `null` is no Overlay, and choosing "none" removes the key.
|
|
323
|
+
* The Inspector shows the Background Control's Overlay section only (`base={false}`).
|
|
324
|
+
*/
|
|
325
|
+
type: "background-overlay";
|
|
318
326
|
}) | (PhiCmsConfigFieldBase & {
|
|
319
327
|
type: "grid-placement" | "column-count";
|
|
320
328
|
section?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PhiBulletListEntry, PhiBulletListStyle } from "../components/widgets/shared/bullet-list-vocabulary";
|
|
2
|
-
import type { PhiMarkdownImageAspectRatio } from "../components/widgets/shared/markdown-image-vocabulary";
|
|
2
|
+
import type { PhiMarkdownImageAspectRatio, PhiMarkdownImageFloatWidth } from "../components/widgets/shared/markdown-image-vocabulary";
|
|
3
3
|
import type { PhiMarkdownFoldSections } from "../components/widgets/shared/markdown-sections";
|
|
4
4
|
import type { PhiLetterSpacingStep, PhiTextTransform } from "../components/widgets/config/text-case-vocabulary";
|
|
5
5
|
import type { PhiRenderableBlockBase } from "./renderable-block";
|
|
@@ -68,6 +68,7 @@ export type PhiMarkdownWidgetPlacement = PhiWidgetPlacementBase & {
|
|
|
68
68
|
revalidateSeconds?: number;
|
|
69
69
|
textAlign?: PhiMarkdownTextAlign;
|
|
70
70
|
imageFloat?: PhiMarkdownImageFloat;
|
|
71
|
+
imageFloatWidth?: PhiMarkdownImageFloatWidth;
|
|
71
72
|
imageAspectRatio?: PhiMarkdownImageAspectRatio;
|
|
72
73
|
foldSections?: PhiMarkdownFoldSections;
|
|
73
74
|
faqStructuredData?: boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pictures a Module's own package declares (`phis.media` in its `package.json`) as the Site's Media
|
|
3
|
+
* library holds them (design/MODULE_MEDIA.md in phis-server; THIRD_PARTY_MODULES.md, "Pictures a Module
|
|
4
|
+
* ships").
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* What a route, Area shell or Area Overlay preset asks for the ids of the names its own package declares.
|
|
8
|
+
*
|
|
9
|
+
* Bound to the package of the preset's owner: a Module cannot ask for another package's names. Each call
|
|
10
|
+
* answers the Asset id (`asset`) or the Media Folder id (`folder`) the Site holds for the name, or `null`
|
|
11
|
+
* where it has none -- the name is not imported yet, or its Asset or folder was deleted. A preset leaves
|
|
12
|
+
* the picture out then. Asynchronous because the Site reads the mapping from Core on first use only: a
|
|
13
|
+
* preset that never asks costs no request.
|
|
14
|
+
*/
|
|
15
|
+
export type PhiModuleMediaResolver = {
|
|
16
|
+
asset(key: string): Promise<number | null>;
|
|
17
|
+
folder(key: string): Promise<number | null>;
|
|
18
|
+
};
|
|
19
|
+
/** Package name -> declared key -> id, as `GET /api/v1/site/module-media` answers it. */
|
|
20
|
+
export type PhiModuleMediaMapping = {
|
|
21
|
+
assets: Readonly<Record<string, Readonly<Record<string, number>>>>;
|
|
22
|
+
folders: Readonly<Record<string, Readonly<Record<string, number>>>>;
|
|
23
|
+
};
|
|
24
|
+
/** Reads the Site's mapping. Called at most once per instantiation, on the first question. */
|
|
25
|
+
export type PhiModuleMediaLoader = () => Promise<PhiModuleMediaMapping>;
|
|
26
|
+
/** The mapping of a Site that holds nothing. */
|
|
27
|
+
export declare const PHI_EMPTY_MODULE_MEDIA_MAPPING: PhiModuleMediaMapping;
|
|
28
|
+
/**
|
|
29
|
+
* For a caller without a Core -- a contract script, a test: every name is answered `null`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const PHI_EMPTY_MODULE_MEDIA_LOADER: PhiModuleMediaLoader;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pictures a Module's own package declares (`phis.media` in its `package.json`) as the Site's Media
|
|
3
|
+
* library holds them (design/MODULE_MEDIA.md in phis-server; THIRD_PARTY_MODULES.md, "Pictures a Module
|
|
4
|
+
* ships").
|
|
5
|
+
*/
|
|
6
|
+
/** The mapping of a Site that holds nothing. */
|
|
7
|
+
export const PHI_EMPTY_MODULE_MEDIA_MAPPING = { assets: {}, folders: {} };
|
|
8
|
+
/**
|
|
9
|
+
* For a caller without a Core -- a contract script, a test: every name is answered `null`.
|
|
10
|
+
*/
|
|
11
|
+
export const PHI_EMPTY_MODULE_MEDIA_LOADER = async () => PHI_EMPTY_MODULE_MEDIA_MAPPING;
|
package/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./types/cms-overlay";
|
|
|
3
3
|
export type * from "./types/cms-container";
|
|
4
4
|
export * from "./types/cms-instance-id";
|
|
5
5
|
export { type PhiCmsAreaDefinition, type PhiCmsAreaOverlayPresetDescriptor, type PhiCmsAreaShellCompositionSource, type PhiCmsAreaShellPresetBinding, type PhiCmsAreaShellPresetDescriptor, type PhiCmsDescriptorBuildContext, type PhiCmsNavigationAnchor, type PhiCmsNavigationAnchoredInjectionDescriptor, type PhiCmsNavigationAnchorPlacement, type PhiCmsNavigationAreaTarget, type PhiCmsNavigationBaseItemDescriptor, type PhiCmsNavigationCustomItem, type PhiCmsNavigationExternalTarget, type PhiCmsNavigationFolder, type PhiCmsNavigationFolderTarget, type PhiCmsNavigationInjectionDescriptor, type PhiCmsNavigationInjectionItemDescriptor, type PhiCmsNavigationItemOverride, type PhiCmsNavigationItemPlacement, type PhiCmsNavigationItemStanding, type PhiCmsNavigationKeyedInjectionDescriptor, type PhiCmsNavigationLabel, type PhiCmsNavigationSurfaceDescriptor, type PhiCmsPresetIdentity, type PhiCmsPresetSource, type PhiCmsRoutePresetBinding, type PhiCmsRoutePresetDescriptor, type PhiCmsThemeBlockBinding, type PhiCmsThemeBlockDescriptor, type PhiCmsThemeBlockKind, type PhiCmsThemeDescriptorContribution, type PhiCmsThemePresetBinding, type PhiCmsThemePresetDescriptor, type PhiRuntimeModuleId, } from "./types/cms-module-descriptors";
|
|
6
|
+
export type { PhiModuleMediaResolver } from "./types/module-media";
|
|
6
7
|
export { expandPhiBorderRadiusConfig, mergePhiBorderWidgetConfig, mergePhiCmsConfigValues, mergePhiPaddingWidgetConfig, normalizePhiPaddingWidgetConfig, } from "./types/cms-config";
|
|
7
8
|
export type { PhiCmsBorderWidgetConfig, PhiCmsPaddingWidgetConfig, PhiCmsPluginConfigBase, PhiCmsRenderableBlockConfigBase, } from "./types/cms-config";
|
|
8
9
|
export { readPhiCmsBorderWidgetConfig } from "./types/cms-border-config";
|