@phis/ui 0.4.8 → 0.4.12

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 (221) hide show
  1. package/components/cms/phi-cms-area-access-guard.js +9 -1
  2. package/components/cms/phi-cms-area-render-scope.d.ts +8 -4
  3. package/components/cms/phi-cms-area-render-scope.js +26 -11
  4. package/components/cms/phi-cms-root-layout.js +4 -2
  5. package/components/cms/phi-cms-runtime-registry.d.ts +2 -1
  6. package/components/cms/phi-cms-runtime-registry.js +1 -1
  7. package/components/controls/phi-color-control.js +2 -1
  8. package/components/controls/phi-drawer-control-adapter.js +2 -3
  9. package/components/controls/phi-drawer-control.js +3 -3
  10. package/components/controls/phi-dropdown-control.js +2 -1
  11. package/components/controls/phi-float-button-control.js +3 -3
  12. package/components/controls/phi-modal-control-adapter.js +2 -2
  13. package/components/controls/phi-modal-control.js +3 -3
  14. package/components/controls/phi-ribbon-wrap-control.js +2 -1
  15. package/components/controls/phi-zoom-image-overlay.js +11 -5
  16. package/components/forms/auth-admin-settings-labels.d.ts +35 -0
  17. package/components/forms/auth-admin-settings-labels.js +27 -0
  18. package/components/forms/content-entry-forms.js +1 -5
  19. package/components/forms/form-descriptor-runtime-client.js +2 -1
  20. package/components/forms/form-descriptor-text.d.ts +17 -0
  21. package/components/forms/form-descriptor-text.js +14 -0
  22. package/components/forms/runtime-form-controller-plugin.d.ts +0 -115
  23. package/components/forms/runtime-form-controller-plugin.js +1 -1
  24. package/components/forms/upload-form-control.d.ts +0 -7
  25. package/components/forms/upload-form-control.js +1 -1
  26. package/components/layouts/clients/phi-collapsible-layout-client.js +2 -1
  27. package/components/layouts/clients/phi-flex-layout-client.js +7 -1
  28. package/components/layouts/clients/phi-sequence-slot-editor.js +2 -1
  29. package/components/layouts/clients/phi-split-card-half.js +2 -1
  30. package/components/layouts/phi-base-layout.js +2 -1
  31. package/components/layouts/phi-layout-surface-box.js +2 -1
  32. package/components/media/phi-media-picker-server.js +3 -11
  33. package/components/navigation/use-phi-protected-mail.js +1 -9
  34. package/components/regions/presets/clients/sider-context.js +4 -2
  35. package/components/root/phi-config-provider.js +2 -1
  36. package/components/root/phi-dayjs-locale.d.ts +4 -1
  37. package/components/root/phi-dayjs-locale.js +2 -2
  38. package/components/root/phi-intl-locale.d.ts +7 -1
  39. package/components/root/phi-intl-locale.js +20 -15
  40. package/components/root/phi-root-layout.js +2 -1
  41. package/components/runtime/core-runtime-controller-plugin.d.ts +0 -84
  42. package/components/runtime/core-runtime-controller-plugin.js +1 -1
  43. package/components/runtime/runtime-controller-server-host.js +20 -9
  44. package/components/runtime/runtime-signal-bus.js +39 -4
  45. package/components/shell/phi-antd-icon.d.ts +3 -0
  46. package/components/shell/phi-antd-icon.js +9 -0
  47. package/components/state/use-phi-hydrated.d.ts +6 -0
  48. package/components/state/use-phi-hydrated.js +11 -0
  49. package/components/tables/phi-plain-table.d.ts +4 -0
  50. package/components/tables/phi-plain-table.js +1 -1
  51. package/components/widgets/client/shared/phi-rendered-value.js +4 -3
  52. package/components/widgets/config/parser-primitives.d.ts +5 -0
  53. package/components/widgets/config/parser-primitives.js +11 -0
  54. package/components/widgets/label-sets/runtime-options.d.ts +1 -1
  55. package/components/widgets/server/builder-chrome.js +2 -6
  56. package/components/widgets/server/search.js +2 -6
  57. package/components/widgets/shared/markdown-body-client.d.ts +7 -0
  58. package/components/widgets/shared/markdown-body-client.js +2 -0
  59. package/components/widgets/shared/markdown-render.js +48 -1
  60. package/controls.d.ts +2 -0
  61. package/controls.js +3 -0
  62. package/gateway/dashboard-cards-route.js +5 -7
  63. package/gateway/navigation-target-route.js +7 -9
  64. package/gateway/page-references-route.js +6 -8
  65. package/gateway/site-config.js +3 -0
  66. package/gateway/site-proxy.js +13 -2
  67. package/helpers/class-names.d.ts +7 -0
  68. package/helpers/class-names.js +10 -0
  69. package/helpers/cms-navigation-catalog.js +4 -2
  70. package/helpers/cms-page-catalog.js +35 -6
  71. package/helpers/cms-region-keys.d.ts +0 -1
  72. package/helpers/cms-region-keys.js +1 -1
  73. package/helpers/format-date-time.d.ts +14 -3
  74. package/helpers/format-date-time.js +27 -11
  75. package/helpers/region-page-scope.d.ts +1 -3
  76. package/helpers/region-page-scope.js +0 -4
  77. package/helpers/translation-format.d.ts +6 -0
  78. package/helpers/translation-format.js +15 -8
  79. package/package.json +2 -2
  80. package/plugins/runtime/phi-slot-child-frame-view.js +2 -1
  81. package/plugins/runtime/phi-slot-child-viewport-effects-observer.js +1 -1
  82. package/plugins/runtime-modules/admin/forms.js +1 -1
  83. package/plugins/runtime-modules/admin/trees/phi-default-admin-settings-page-tree.js +2 -5
  84. package/plugins/runtime-modules/app/forms.js +1 -1
  85. package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.js +2 -6
  86. package/plugins/runtime-modules/asset/metadata-form.js +2 -6
  87. package/plugins/runtime-modules/asset/settings-forms.js +1 -1
  88. package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +2 -5
  89. package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +2 -6
  90. package/plugins/runtime-modules/asset/widgets/area-upload/server.js +2 -6
  91. package/plugins/runtime-modules/asset/widgets/image-inspector/authoring.js +1 -3
  92. package/plugins/runtime-modules/asset/widgets/image-inspector/server.js +2 -6
  93. package/plugins/runtime-modules/asset/widgets.js +5 -7
  94. package/plugins/runtime-modules/auth/admin-settings-forms.js +1 -1
  95. package/plugins/runtime-modules/auth/data-providers.d.ts +5 -0
  96. package/plugins/runtime-modules/auth/data-providers.js +3 -0
  97. package/plugins/runtime-modules/auth/definition.d.ts +5 -0
  98. package/plugins/runtime-modules/auth/ids.d.ts +7 -7
  99. package/plugins/runtime-modules/auth/ids.js +7 -7
  100. package/plugins/runtime-modules/auth/services/installations-table.js +3 -1
  101. package/plugins/runtime-modules/auth/trees/phi-auth-area-overlay-tree.server.js +2 -6
  102. package/plugins/runtime-modules/auth/trees/phi-default-admin-auth-settings-page-tree.js +26 -14
  103. package/plugins/runtime-modules/auth/widgets/security/client.js +5 -1
  104. package/plugins/runtime-modules/auth/widgets.d.ts +1 -2
  105. package/plugins/runtime-modules/auth/widgets.js +5 -7
  106. package/plugins/runtime-modules/avatar/overlay-tree.server.js +2 -6
  107. package/plugins/runtime-modules/avatar/widgets/account-avatar/server.js +2 -6
  108. package/plugins/runtime-modules/avatar/widgets/account-avatar-picker/server.js +2 -6
  109. package/plugins/runtime-modules/avatar/widgets.js +3 -5
  110. package/plugins/runtime-modules/builder/clients/pages-workspace.d.ts +2 -3
  111. package/plugins/runtime-modules/builder/clients/pages-workspace.js +5 -18
  112. package/plugins/runtime-modules/builder/controller/draft-command-controller.js +1 -0
  113. package/plugins/runtime-modules/builder/controller/page-controller.js +1 -1
  114. package/plugins/runtime-modules/builder/controller/server-definition.js +3 -11
  115. package/plugins/runtime-modules/builder/controller/workspace-controller.js +2 -6
  116. package/plugins/runtime-modules/builder/developer-workspace-store.d.ts +2 -8
  117. package/plugins/runtime-modules/builder/developer-workspace-store.js +24 -44
  118. package/plugins/runtime-modules/builder/developer-workspace-types.d.ts +0 -5
  119. package/plugins/runtime-modules/builder/edit-scaffold-drawer.js +2 -1
  120. package/plugins/runtime-modules/builder/inspector-section-widget.js +6 -31
  121. package/plugins/runtime-modules/builder/navigation-persistence.js +12 -3
  122. package/plugins/runtime-modules/builder/page-meta-form.js +4 -12
  123. package/plugins/runtime-modules/builder/page-presets.server.d.ts +0 -1
  124. package/plugins/runtime-modules/builder/page-presets.server.js +0 -24
  125. package/plugins/runtime-modules/builder/pages-workspace.js +6 -16
  126. package/plugins/runtime-modules/builder/persistence.d.ts +6 -4
  127. package/plugins/runtime-modules/builder/persistence.js +6 -7
  128. package/plugins/runtime-modules/builder/render-root-node-scaffold.js +0 -1
  129. package/plugins/runtime-modules/builder/shells-workspace.js +3 -11
  130. package/plugins/runtime-modules/builder/signal-wiring-form.js +3 -7
  131. package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +2 -6
  132. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +6 -26
  133. package/plugins/runtime-modules/builder/trees/phi-default-builder-settings-page-tree.js +2 -6
  134. package/plugins/runtime-modules/builder/widgets/developer-builder-pages-header/plugin.js +2 -6
  135. package/plugins/runtime-modules/builder/widgets/inspector-header/plugin.js +2 -6
  136. package/plugins/runtime-modules/builder/widgets/structure-region/built-in.js +3 -2
  137. package/plugins/runtime-modules/builder/widgets/structure-region/plugin.js +1 -6
  138. package/plugins/runtime-modules/builder/widgets.js +10 -12
  139. package/plugins/runtime-modules/client-authoring-module.js +18 -1
  140. package/plugins/runtime-modules/contracts.d.ts +15 -1
  141. package/plugins/runtime-modules/contracts.js +10 -0
  142. package/plugins/runtime-modules/core/messaging/forms.js +1 -1
  143. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +1 -1
  144. package/plugins/runtime-modules/core/widgets/description/server.js +12 -9
  145. package/plugins/runtime-modules/core/widgets/dimension/plugin.js +2 -6
  146. package/plugins/runtime-modules/core/widgets/draft-status/plugin.js +2 -6
  147. package/plugins/runtime-modules/core/widgets/entry-list/config.js +2 -9
  148. package/plugins/runtime-modules/core/widgets/entry-list/view.server.js +1 -1
  149. package/plugins/runtime-modules/core/widgets/form-preview/client.js +2 -15
  150. package/plugins/runtime-modules/core/widgets/gallery/server.js +2 -6
  151. package/plugins/runtime-modules/core/widgets/image/server.js +2 -6
  152. package/plugins/runtime-modules/core/widgets/length/plugin.js +2 -6
  153. package/plugins/runtime-modules/core/widgets/markdown-toc/plugin.js +2 -6
  154. package/plugins/runtime-modules/core/widgets/page-title/server.js +2 -6
  155. package/plugins/runtime-modules/core/widgets/pagination/config.js +4 -8
  156. package/plugins/runtime-modules/core/widgets/result/config.d.ts +3 -0
  157. package/plugins/runtime-modules/core/widgets/result/config.js +15 -10
  158. package/plugins/runtime-modules/core/widgets/result/server.js +1 -1
  159. package/plugins/runtime-modules/core/widgets/search-results/config.js +2 -8
  160. package/plugins/runtime-modules/core/widgets/sidebar-navigation/server.d.ts +2 -2
  161. package/plugins/runtime-modules/core/widgets/sidebar-navigation/server.js +8 -13
  162. package/plugins/runtime-modules/core/widgets/table/client.js +1 -1
  163. package/plugins/runtime-modules/core/widgets/theme-mode-switch/server.js +2 -6
  164. package/plugins/runtime-modules/core/widgets/thread-conversation/client.js +16 -31
  165. package/plugins/runtime-modules/core/widgets/timeline/client.js +9 -4
  166. package/plugins/runtime-modules/core/widgets/tour-button/server.js +2 -6
  167. package/plugins/runtime-modules/core/widgets/tree/client.js +1 -1
  168. package/plugins/runtime-modules/core/widgets.js +59 -61
  169. package/plugins/runtime-modules/dashboard/clients/dashboard-card-view.js +7 -5
  170. package/plugins/runtime-modules/dashboard/trees/phi-default-admin-dashboard-page-tree.js +2 -6
  171. package/plugins/runtime-modules/dashboard/trees/phi-default-area-dashboard-page-tree.js +2 -6
  172. package/plugins/runtime-modules/dashboard/trees/phi-default-builder-dashboard-page-tree.js +2 -6
  173. package/plugins/runtime-modules/descriptor-compiler.js +6 -6
  174. package/plugins/runtime-modules/groups/controller/client.d.ts +0 -56
  175. package/plugins/runtime-modules/groups/controller/client.js +1 -1
  176. package/plugins/runtime-modules/groups/forms.js +1 -5
  177. package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +2 -6
  178. package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -6
  179. package/plugins/runtime-modules/localization/forms.js +2 -6
  180. package/plugins/runtime-modules/localization/services/options.js +19 -9
  181. package/plugins/runtime-modules/localization/trees/phi-default-admin-locales-page-tree.js +3 -11
  182. package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +3 -11
  183. package/plugins/runtime-modules/observability/trees/phi-default-admin-logs-page-tree.js +3 -11
  184. package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +4 -109
  185. package/plugins/runtime-modules/preset-contracts/pub-area.d.ts +2 -2
  186. package/plugins/runtime-modules/preset-contracts/pub-area.js +0 -4
  187. package/plugins/runtime-modules/pub-area-preset.js +0 -20
  188. package/plugins/runtime-modules/public/trees/phi-default-pub-error-page-tree.js +5 -5
  189. package/plugins/runtime-modules/revisions/forms.js +1 -1
  190. package/plugins/runtime-modules/revisions/services/table.js +6 -2
  191. package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +2 -2
  192. package/plugins/runtime-modules/theme/controller/server-definition.js +2 -6
  193. package/plugins/runtime-modules/theme/trees/phi-default-builder-theme-page-tree.js +2 -6
  194. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +17 -21
  195. package/plugins/runtime-modules/theme/widgets/brand-controls/config.d.ts +0 -2
  196. package/plugins/runtime-modules/theme/widgets/brand-controls/config.js +0 -8
  197. package/plugins/runtime-modules/theme/widgets.js +6 -8
  198. package/plugins/runtime-modules/threads/controller/client.d.ts +0 -78
  199. package/plugins/runtime-modules/threads/controller/client.js +1 -1
  200. package/plugins/runtime-modules/threads/forms.js +1 -1
  201. package/plugins/runtime-modules/threads/ids.d.ts +0 -1
  202. package/plugins/runtime-modules/threads/ids.js +0 -2
  203. package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +8 -6
  204. package/plugins/runtime-modules/user-management/controller/client.d.ts +0 -73
  205. package/plugins/runtime-modules/user-management/controller/client.js +1 -1
  206. package/plugins/runtime-modules/user-management/forms.js +1 -5
  207. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +3 -7
  208. package/plugins/runtime-modules/video/widgets.js +2 -4
  209. package/server-helpers/cms-request.d.ts +19 -0
  210. package/server-helpers/cms-request.js +26 -8
  211. package/server-helpers/cms-root.js +27 -21
  212. package/server-helpers/public-login-route.js +6 -8
  213. package/server-helpers/runtime.js +1 -1
  214. package/server-helpers/search-index.js +34 -14
  215. package/styles/controls.css +11 -0
  216. package/styles/shell.css +11 -1
  217. package/types/length.js +8 -3
  218. package/types/site-config.d.ts +6 -4
  219. package/types/widget-runtime.d.ts +2 -3
  220. package/types.d.ts +5 -3
  221. package/types.js +3 -0
@@ -12,5 +12,5 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
12
  * variants are to be shared with the Table Control once that has them.
13
13
  */
14
14
  export function PhiPlainTable({ columns, rows, }) {
15
- return (_jsx("div", { className: "phi-plain-table__scroll", children: _jsxs("table", { className: "phi-plain-table", children: [_jsx("thead", { children: _jsx("tr", { children: columns.map((column) => (_jsx("th", { scope: "col", style: column.align ? { textAlign: column.align } : undefined, children: column.title }, column.key))) }) }), _jsx("tbody", { children: rows.map((row) => (_jsx("tr", { children: columns.map((column, columnIndex) => (_jsx("td", { style: column.align ? { textAlign: column.align } : undefined, children: row.cells[columnIndex] ?? null }, column.key))) }, row.key))) })] }) }));
15
+ return (_jsx("div", { className: "phi-plain-table__scroll", children: _jsxs("table", { className: "phi-plain-table", children: [columns.some((column) => column.width) ? (_jsx("colgroup", { children: columns.map((column) => (_jsx("col", { style: column.width ? { width: column.width } : undefined }, column.key))) })) : null, _jsx("thead", { children: _jsx("tr", { children: columns.map((column) => (_jsx("th", { scope: "col", className: column.nowrap ? "phi-plain-table__nowrap" : undefined, style: column.align ? { textAlign: column.align } : undefined, children: column.title }, column.key))) }) }), _jsx("tbody", { children: rows.map((row) => (_jsx("tr", { children: columns.map((column, columnIndex) => (_jsx("td", { className: column.nowrap ? "phi-plain-table__nowrap" : undefined, style: column.align ? { textAlign: column.align } : undefined, children: row.cells[columnIndex] ?? null }, column.key))) }, row.key))) })] }) }));
16
16
  }
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { formatPhiDate, formatPhiDateTime } from "../../../../helpers/format-date-time";
4
- import { usePhiIntlLocale } from "../../../root/phi-intl-locale";
4
+ import { usePhiIntlLocale, usePhiIntlTimeZone } from "../../../root/phi-intl-locale";
5
5
  import { PhiFlexControl } from "../../../controls/phi-flex-control";
6
6
  import { PhiTagControl } from "../../../controls/phi-tag-control";
7
7
  import { PhiTypographyControl } from "../../../controls/phi-typography-control";
@@ -33,10 +33,11 @@ function normalizePhiRenderedText(value) {
33
33
  function resolveTagColor(color) {
34
34
  return typeof color === "object" ? color.value : color;
35
35
  }
36
- /** A component rather than a call, because the page's locale is read from context. */
36
+ /** A component rather than a call, because the page's locale and the Site's zone are read from context. */
37
37
  function PhiRenderedDate({ value, withTime }) {
38
38
  const locale = usePhiIntlLocale();
39
- return withTime ? formatPhiDateTime(value, locale) : formatPhiDate(value, locale);
39
+ const timeZone = usePhiIntlTimeZone();
40
+ return withTime ? formatPhiDateTime(value, locale, timeZone) : formatPhiDate(value, locale, timeZone);
40
41
  }
41
42
  export function renderPhiValueContent(value, definition, presentation = "cell") {
42
43
  if (value == null || value === "")
@@ -9,3 +9,8 @@ export declare function readNumberList(value: unknown): number[] | undefined;
9
9
  export declare function readCssSize(value: unknown): string | number | undefined;
10
10
  export declare function readRenderableBlockConfig(config: Record<string, unknown>): PhiRenderableBlockBase;
11
11
  export declare function readNavItems(value: unknown): PhiNavItem[] | undefined;
12
+ /**
13
+ * A positive whole number from a config, `fallback` where there is none or it is not positive, and no
14
+ * more than `max` where one is named. The list Widgets each parsed their page size this way.
15
+ */
16
+ export declare function readClampedPositiveInteger(value: unknown, fallback: number, max?: number): number;
@@ -126,3 +126,14 @@ export function readNavItems(value) {
126
126
  .filter((item) => item !== null);
127
127
  return items.length > 0 ? items : undefined;
128
128
  }
129
+ /**
130
+ * A positive whole number from a config, `fallback` where there is none or it is not positive, and no
131
+ * more than `max` where one is named. The list Widgets each parsed their page size this way.
132
+ */
133
+ export function readClampedPositiveInteger(value, fallback, max) {
134
+ const parsed = readInteger(value);
135
+ if (parsed == null || parsed <= 0) {
136
+ return fallback;
137
+ }
138
+ return max == null ? parsed : Math.min(parsed, max);
139
+ }
@@ -1,3 +1,3 @@
1
1
  import type { PhiBlockRuntime } from "../../../types";
2
2
  import type { PhiGlobalTranslatorOptions } from "../../../gateway/tr";
3
- export declare function buildPhiWidgetLabelTranslatorOptions(runtime: Pick<PhiBlockRuntime, "locale" | "site">): PhiGlobalTranslatorOptions;
3
+ export declare function buildPhiWidgetLabelTranslatorOptions(runtime: Pick<PhiBlockRuntime, "locale">): PhiGlobalTranslatorOptions;
@@ -2,13 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { getPhiBuilderChromeWidgetLabels } from "../label-sets/builder-chrome";
3
3
  import { PhiRuntimeRenderClientType } from "../../../constants/runtime-render-client-types";
4
4
  import { PhiRuntimeModuleRenderClientHost } from "../../runtime/runtime-module-render-client-manifest";
5
- import { readPhiServerApiCredentials } from "../../../helpers/phis-server-credentials";
5
+ import { buildPhiWidgetLabelTranslatorOptions } from "../label-sets/runtime-options";
6
6
  async function getLabels(runtime) {
7
- return getPhiBuilderChromeWidgetLabels({
8
- apiBaseUrl: readPhiServerApiCredentials().apiBaseUrl,
9
- internalToken: readPhiServerApiCredentials().internalToken,
10
- locale: runtime.locale.current,
11
- });
7
+ return getPhiBuilderChromeWidgetLabels(buildPhiWidgetLabelTranslatorOptions(runtime));
12
8
  }
13
9
  export async function PhiBuilderModeSwitchWidget({ runtime, disabled, }) {
14
10
  const labels = await getLabels(runtime);
@@ -2,13 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { getPhiSearchWidgetLabels } from "../label-sets/search";
3
3
  import { PhiRuntimeRenderClientType } from "../../../constants/runtime-render-client-types";
4
4
  import { PhiRuntimeModuleRenderClientHost } from "../../runtime/runtime-module-render-client-manifest";
5
- import { readPhiServerApiCredentials } from "../../../helpers/phis-server-credentials";
5
+ import { buildPhiWidgetLabelTranslatorOptions } from "../label-sets/runtime-options";
6
6
  async function loadPhiSearchWidgetLabels(runtime) {
7
- return getPhiSearchWidgetLabels({
8
- apiBaseUrl: readPhiServerApiCredentials().apiBaseUrl,
9
- internalToken: readPhiServerApiCredentials().internalToken,
10
- locale: runtime.locale.current,
11
- });
7
+ return getPhiSearchWidgetLabels(buildPhiWidgetLabelTranslatorOptions(runtime));
12
8
  }
13
9
  export async function PhiSearchWidgetServer({ runtime, config, query, defaultQuery, disabled, onQueryChange, onQuerySubmit, }) {
14
10
  const labels = await loadPhiSearchWidgetLabels(runtime);
@@ -87,6 +87,13 @@ export type PhiMarkdownBlock = {
87
87
  rows: PhiMarkdownInline[][][];
88
88
  /** One entry per column, from the GFM delimiter row; `null` where the column states none. */
89
89
  align: PhiMarkdownTableAlign[];
90
+ /**
91
+ * Each column's share of the width in percent, from the lengths of the delimiter row's dashes, or
92
+ * `null` when they are all equal and the browser decides.
93
+ */
94
+ widths: number[] | null;
95
+ /** One entry per column: kept on one line because every text in it is short. */
96
+ nowrap: boolean[];
90
97
  } | {
91
98
  kind: "divider";
92
99
  } | {
@@ -143,6 +143,8 @@ function renderBlocks(blocks, token, paragraphStyle, headingStyle, lists, atStar
143
143
  key: `column-${columnIndex}`,
144
144
  title: renderInlineNodes(header),
145
145
  align: block.align[columnIndex] ?? null,
146
+ width: block.widths?.[columnIndex] != null ? `${block.widths[columnIndex]}%` : undefined,
147
+ nowrap: block.nowrap[columnIndex] ?? false,
146
148
  })), rows: block.rows.map((cells, rowIndex) => ({
147
149
  key: `row-${rowIndex}`,
148
150
  cells: cells.map((cell) => renderInlineNodes(cell)),
@@ -516,7 +516,11 @@ function mapBlockNodes(nodes, context, inlineMap) {
516
516
  const cells = tableRows.map((row) => (row.children ?? []).map((cell) => inlineMap.get(cell) ?? mapInlineNodes(cell.children)));
517
517
  const header = cells[0] ?? [];
518
518
  const align = header.map((_, columnIndex) => readMarkdownTableAlign(node.align?.[columnIndex]));
519
- blocks.push({ kind: "table", header, rows: cells.slice(1), align });
519
+ const widths = readMarkdownTableWidths(node, context.sourceLines, header.length);
520
+ const nowrap = widths
521
+ ? header.map(() => false)
522
+ : header.map((_, columnIndex) => isMarkdownTableColumnShort(cells, columnIndex));
523
+ blocks.push({ kind: "table", header, rows: cells.slice(1), align, widths, nowrap });
520
524
  break;
521
525
  }
522
526
  }
@@ -606,6 +610,7 @@ async function resolveMarkdownRenderDataFromSource(markdown, translate, headingI
606
610
  figures = await projectInternalMarkdownNodes(tree, runtime);
607
611
  }
608
612
  const context = {
613
+ sourceLines: markdown.split(/\r?\n/),
609
614
  headings: [],
610
615
  headingIdCounts: new Map(),
611
616
  headingIdPrefix,
@@ -615,6 +620,48 @@ async function resolveMarkdownRenderDataFromSource(markdown, translate, headingI
615
620
  const blocks = promoteMarkdownFigures(protectMarkdownMail(mapBlockNodes(tree.children, context, inlineMap)), figures, imageDefaults);
616
621
  return { blocks, headings: context.headings };
617
622
  }
623
+ /*
624
+ * How wide a table's columns are, when the text says so.
625
+ *
626
+ * Markdown has no syntax for a column's width, and GFM asks only for at least three dashes per cell of
627
+ * the delimiter row. Their number is free, so it carries the width here: `|---|------|` is one part to
628
+ * two, and every other renderer still reads an ordinary table. Equal dashes say nothing -- the way almost
629
+ * every table is written -- and leave the widths to the browser, as before.
630
+ *
631
+ * The tree keeps no dashes, so the row is read from the source: the line after the table's first. A
632
+ * quote's or a list's markers before it are stepped over; a row that does not read as one cell per
633
+ * column gives no widths rather than wrong ones.
634
+ */
635
+ function readMarkdownTableWidths(node, sourceLines, columnCount) {
636
+ const startLine = node.position?.start.line;
637
+ if (!startLine || columnCount < 2)
638
+ return null;
639
+ const line = sourceLines[startLine];
640
+ if (line === undefined)
641
+ return null;
642
+ const row = line.replace(/^\s*(?:>\s*)*(?:(?:[-*+]|\d+[.)])\s+)?/, "").trim().replace(/^\|/, "").replace(/\|$/, "");
643
+ const cells = row.split("|").map((cell) => cell.trim());
644
+ if (cells.length !== columnCount || !cells.every((cell) => /^:?-{3,}:?$/.test(cell)))
645
+ return null;
646
+ const dashes = cells.map((cell) => cell.replace(/:/g, "").length);
647
+ if (dashes.every((count) => count === dashes[0]))
648
+ return null;
649
+ const total = dashes.reduce((sum, count) => sum + count, 0);
650
+ return dashes.map((count) => Math.round((count / total) * 1000) / 10);
651
+ }
652
+ /**
653
+ * The longest text a column may hold and still be kept on one line. Names, versions, commands and short
654
+ * labels fit; a sentence does not, and wraps as before.
655
+ */
656
+ const MARKDOWN_TABLE_SHORT_COLUMN_CHARACTERS = 24;
657
+ /*
658
+ * Whether a column holds only short texts, heading included, so it is set without a line break: it then
659
+ * takes the width of its longest entry and leaves the rest of the row to the columns that need it.
660
+ * Measured on the text as shown, after translation.
661
+ */
662
+ function isMarkdownTableColumnShort(cells, columnIndex) {
663
+ return cells.every((row) => getInlineText(row[columnIndex] ?? []).trim().length <= MARKDOWN_TABLE_SHORT_COLUMN_CHARACTERS);
664
+ }
618
665
  /** remark-gfm states `left`, `center`, `right` or nothing; nothing else can come out of its parser. */
619
666
  function readMarkdownTableAlign(value) {
620
667
  if (value === "left" || value === "center" || value === "right") {
package/controls.d.ts CHANGED
@@ -47,6 +47,8 @@ export { PhiSurfaceControl } from "./components/controls/phi-surface-control";
47
47
  export type { PhiSurfaceControlLabels, PhiSurfaceControlProps } from "./components/controls/phi-surface-control";
48
48
  export { PhiImageControl } from "./components/controls/phi-image-control";
49
49
  export type { PhiImageControlProps, PhiImageControlSource } from "./components/controls/phi-image-control";
50
+ export { resolvePhiImagePresentation } from "./components/media/image-presentation";
51
+ export type { PhiImagePresentation, PhiImagePresentationFit, PhiImagePresentationInput, } from "./components/media/image-presentation";
50
52
  export { PhiGeometryControl } from "./components/controls/phi-geometry-control";
51
53
  export type { PhiGeometryControlProps } from "./components/controls/phi-geometry-control";
52
54
  export { PhiSliderControl } from "./components/controls/phi-slider-control";
package/controls.js CHANGED
@@ -23,6 +23,9 @@ export { PhiPaddingControl } from "./components/controls/phi-padding-control";
23
23
  export { PhiShadowControl } from "./components/controls/phi-shadow-control";
24
24
  export { PhiSurfaceControl } from "./components/controls/phi-surface-control";
25
25
  export { PhiImageControl } from "./components/controls/phi-image-control";
26
+ // The answer `PhiImageControl` draws: a Module showing a picture of its own asks the same resolver the
27
+ // Image and Card Widgets ask, instead of composing an address and a framing of its own.
28
+ export { resolvePhiImagePresentation } from "./components/media/image-presentation";
26
29
  export { PhiGeometryControl } from "./components/controls/phi-geometry-control";
27
30
  export { PhiSliderControl } from "./components/controls/phi-slider-control";
28
31
  export { PhiRateControl } from "./components/controls/phi-rate-control";
@@ -3,9 +3,8 @@ import "server-only";
3
3
  import { isPhiCmsAreaKey, resolvePhiCmsAreaMask, } from "../constants/cms-areas";
4
4
  import { canPhiViewerAccess } from "../types/access";
5
5
  import { localizeAreaPath } from "../helpers/locale";
6
- import { readPhiAreaLandingSelection, readPhiAreaPublicRoutePaths, } from "../helpers/cms-area-config";
7
6
  import { compilePhiCmsActiveRouteTable, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
8
- import { resolveActivePresetModuleKeys } from "../server-helpers/cms-request";
7
+ import { resolvePhiAreaRouteScope } from "../server-helpers/cms-request";
9
8
  import { getPhiExactSiteArea } from "../server-helpers/cms";
10
9
  import { resolveCmsRootRoute } from "../server-helpers/cms-route";
11
10
  import { buildPhiBlockRuntime, loadPhiSiteRequestContext, } from "../server-helpers/runtime";
@@ -63,13 +62,12 @@ async function resolveDashboardCardScope({ bridge, area, locale, path, cookieHea
63
62
  presetKey: shellBinding.descriptor.presetKey,
64
63
  },
65
64
  });
66
- const activeModuleIds = resolveActivePresetModuleKeys(bridge.runtimeModuleCatalog, area, areaPreset ? { preset: areaPreset.preset } : null, requestContext.serverCapabilities);
67
- const routeTable = compilePhiCmsActiveRouteTable({
65
+ const { activeModuleIds, routeTable } = resolvePhiAreaRouteScope({
66
+ runtimeModuleCatalog: bridge.runtimeModuleCatalog,
68
67
  catalog,
69
68
  area,
70
- activeModuleIds,
71
- publicRoutePaths: readPhiAreaPublicRoutePaths(areaPreset?.preset.preset.config),
72
- landingSelection: readPhiAreaLandingSelection(areaPreset?.preset.preset.config),
69
+ preset: areaPreset?.preset ?? null,
70
+ serverCapabilities: requestContext.serverCapabilities,
73
71
  });
74
72
  const cardContext = {
75
73
  apiBaseUrl,
@@ -2,9 +2,8 @@ import { jsonResponse, readPhiInternalRequestPath, splitPhiRequestPath } from ".
2
2
  import "server-only";
3
3
  import { isPhiCmsAreaKey, } from "../constants/cms-areas";
4
4
  import { canPhiViewerAccess } from "../types/access";
5
- import { readPhiAreaLandingSelection, readPhiAreaPublicRoutePaths, } from "../helpers/cms-area-config";
6
- import { compilePhiCmsActiveRouteTable, normalizePhiCmsRoutePath, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, resolvePhiCmsRoutePreset, } from "../plugins/runtime-modules/descriptor-compiler";
7
- import { resolveActivePresetModuleKeys } from "../server-helpers/cms-request";
5
+ import { normalizePhiCmsRoutePath, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, resolvePhiCmsRoutePreset, } from "../plugins/runtime-modules/descriptor-compiler";
6
+ import { resolvePhiAreaRouteScope } from "../server-helpers/cms-request";
8
7
  import { resolvePhiCmsLookup } from "../server-helpers/cms-lookup";
9
8
  import { getPhiCmsPage, getPhiExactSiteArea } from "../server-helpers/cms";
10
9
  import { resolveCmsRootRoute } from "../server-helpers/cms-route";
@@ -93,15 +92,14 @@ export function buildPhiNavigationTargetRouteHandler({ loadAreaBridge, }) {
93
92
  cookieHeader,
94
93
  sourcePreset,
95
94
  });
96
- const activeModuleIds = resolveActivePresetModuleKeys(bridge.runtimeModuleCatalog, area, areaPreset ? { preset: areaPreset.preset } : null, requestContext.serverCapabilities);
97
- const storagePath = resolveAreaStoragePath(resolvedRoute.cmsPath, area);
98
- const routeTable = compilePhiCmsActiveRouteTable({
95
+ const { routeTable } = resolvePhiAreaRouteScope({
96
+ runtimeModuleCatalog: bridge.runtimeModuleCatalog,
99
97
  catalog,
100
98
  area,
101
- activeModuleIds,
102
- publicRoutePaths: readPhiAreaPublicRoutePaths(areaPreset?.preset.preset.config),
103
- landingSelection: readPhiAreaLandingSelection(areaPreset?.preset.preset.config),
99
+ preset: areaPreset?.preset ?? null,
100
+ serverCapabilities: requestContext.serverCapabilities,
104
101
  });
102
+ const storagePath = resolveAreaStoragePath(resolvedRoute.cmsPath, area);
105
103
  const routeBinding = storagePath
106
104
  ? resolvePhiCmsRoutePreset(routeTable, storagePath)
107
105
  : null;
@@ -2,12 +2,11 @@ import { jsonResponse } from "./route-handler-helpers";
2
2
  import "server-only";
3
3
  import { isPhiBuilderAreaKey, isPhiCmsAreaKey } from "../constants/cms-areas";
4
4
  import { canPhiViewerAccess, PHI_VIEWER_ACCESS_CONTENT_EDITING, PHI_VIEWER_ACCESS_STRUCTURE_AUTHORING } from "../types/access";
5
- import { readPhiAreaLandingSelection, readPhiAreaPublicRoutePaths, } from "../helpers/cms-area-config";
6
5
  import { resolvePhiBuilderActivePageCatalog } from "../helpers/cms-page-catalog";
7
- import { compilePhiCmsActiveRouteTable, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
6
+ import { resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
8
7
  import { buildPhiAreaActivePresetPages } from "../helpers/cms-preset-page-tree";
9
8
  import { buildPhiBuilderPageReferenceTree } from "../helpers/page-reference-tree";
10
- import { resolveActivePresetModuleKeys } from "../server-helpers/cms-request";
9
+ import { resolvePhiAreaRouteScope } from "../server-helpers/cms-request";
11
10
  import { getPhiExactSiteArea } from "../server-helpers/cms";
12
11
  import { loadPhiSiteRequestContext } from "../server-helpers/runtime";
13
12
  import { getSiteCmsPageCatalog } from "./site-page";
@@ -59,13 +58,12 @@ export function buildPhiPageReferencesRouteHandler({ loadAreaBridge, }) {
59
58
  },
60
59
  })
61
60
  : null;
62
- const activeModuleIds = resolveActivePresetModuleKeys(bridge.runtimeModuleCatalog, area, areaPreset ? { preset: areaPreset.preset } : null, requestContext.serverCapabilities);
63
- const routeTable = compilePhiCmsActiveRouteTable({
61
+ const { routeTable } = resolvePhiAreaRouteScope({
62
+ runtimeModuleCatalog: bridge.runtimeModuleCatalog,
64
63
  catalog,
65
64
  area,
66
- activeModuleIds,
67
- publicRoutePaths: readPhiAreaPublicRoutePaths(areaPreset?.preset.preset.config),
68
- landingSelection: readPhiAreaLandingSelection(areaPreset?.preset.preset.config),
65
+ preset: areaPreset?.preset ?? null,
66
+ serverCapabilities: requestContext.serverCapabilities,
69
67
  });
70
68
  const persistedPages = await getSiteCmsPageCatalog({
71
69
  apiBaseUrl: runtime.apiBaseUrl,
@@ -58,6 +58,9 @@ async function fetchSiteConfig({ apiBaseUrl, internalToken, siteKey }, cacheKey)
58
58
  if (!payload.site.translationMarkers) {
59
59
  throw new Error("Missing translation markers in site config payload.");
60
60
  }
61
+ if (typeof payload.site.timeZone !== "string" || !payload.site.timeZone.trim()) {
62
+ throw new Error("Missing time zone in site config payload.");
63
+ }
61
64
  // Every fresh answer, cached or not afterwards, is where this process learns a translation changed.
62
65
  syncPhiTranslationChangeMarkers({
63
66
  siteKey,
@@ -59,10 +59,21 @@ async function buildLocallyAnsweredHandlers(answered, { upstreamBaseUrl, timeout
59
59
  const { buildPhiNavigationTargetRouteHandler } = await import("./navigation-target-route");
60
60
  return { GET: buildPhiNavigationTargetRouteHandler({ loadAreaBridge }) };
61
61
  }
62
+ /**
63
+ * Writes that are one person's own and change nothing the read cache holds. The cache keeps the Site's
64
+ * config, Navigation overlays, capabilities and Area doors -- what a publish changes. A Dashboard card
65
+ * dismissed, a message written, an avatar changed are a person's business, and emptying the Site's
66
+ * cache for each of them left it cold for everybody as soon as a few people were signed in.
67
+ */
68
+ const PERSONAL_WRITE_SEGMENTS = new Set(["user-state", "threads", "account"]);
69
+ function isPersonalWrite(path) {
70
+ return path?.[0] !== undefined && PERSONAL_WRITE_SEGMENTS.has(path[0]);
71
+ }
62
72
  /**
63
73
  * A write Core accepted may have changed what this Site process keeps in its read cache. Which writes do
64
74
  * is not worth listing: config and Navigation carry the theme draft, settings, logo revision and Page
65
- * paths, and a list would fall behind the next endpoint. Every accepted write clears it.
75
+ * paths, and a list would fall behind the next endpoint. Every accepted write clears it, except the
76
+ * personal ones named above, which cannot have.
66
77
  *
67
78
  * Translations are not cleared here. The next Site config read carries their change markers, and
68
79
  * helpers/translation-cache.ts empties only a store whose marker moved.
@@ -70,7 +81,7 @@ async function buildLocallyAnsweredHandlers(answered, { upstreamBaseUrl, timeout
70
81
  function clearingReadCacheOnWrite(handler) {
71
82
  return async (request, context) => {
72
83
  const response = await handler(request, context);
73
- if (response.ok) {
84
+ if (response.ok && !isPersonalWrite((await context.params).path)) {
74
85
  clearPhiSiteReadCache();
75
86
  }
76
87
  return response;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The class names that are there, joined by a space; undefined where none is.
3
+ *
4
+ * `[a, b].filter(Boolean).join(" ")` stood in sixteen files, half of them with `|| undefined` after it
5
+ * and half without, so some elements carried `class=""` and some did not. One helper, one answer.
6
+ */
7
+ export declare function joinPhiClassNames(...parts: readonly (string | false | null | undefined)[]): string | undefined;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The class names that are there, joined by a space; undefined where none is.
3
+ *
4
+ * `[a, b].filter(Boolean).join(" ")` stood in sixteen files, half of them with `|| undefined` after it
5
+ * and half without, so some elements carried `class=""` and some did not. One helper, one answer.
6
+ */
7
+ export function joinPhiClassNames(...parts) {
8
+ const joined = parts.filter((part) => typeof part === "string" && part.length > 0).join(" ");
9
+ return joined.length > 0 ? joined : undefined;
10
+ }
@@ -164,7 +164,8 @@ export function resolvePhiBuilderNavigationPageTargets(area, items, pagesForArea
164
164
  byArea.set(targetArea, index);
165
165
  return index;
166
166
  };
167
- return items.map((item) => {
167
+ // One index per Area for the whole tree: the recursion below shares it rather than building its own.
168
+ const resolve = (list) => list.map((item) => {
168
169
  const targetArea = item.targetArea ?? area;
169
170
  const page = item.targetReference ? pageIndex(targetArea).get(item.targetReference) : null;
170
171
  return {
@@ -175,7 +176,8 @@ export function resolvePhiBuilderNavigationPageTargets(area, items, pagesForArea
175
176
  : null,
176
177
  targetDeleted: page == null || page.tombstoned === true,
177
178
  } : {}),
178
- children: resolvePhiBuilderNavigationPageTargets(area, item.children, pagesForArea),
179
+ children: resolve(item.children),
179
180
  };
180
181
  });
182
+ return resolve(items);
181
183
  }
@@ -18,6 +18,35 @@ function findPagePathSegments(pages, targetKey, prefix = []) {
18
18
  }
19
19
  return null;
20
20
  }
21
+ /**
22
+ * Every node's path, indexed by key, once per catalog array.
23
+ *
24
+ * The catalog's own walkers asked `findPhiPageNodePath` for every node they visited, each call a walk
25
+ * of the whole tree with a copy of the array: the Builder's page list, its storage paths and its
26
+ * navigation targets were quadratic in the number of Pages. The index is held on the array it was
27
+ * built from, so a catalog that is handed around is walked once.
28
+ */
29
+ const pageNodePathIndex = new WeakMap();
30
+ function readPhiPageNodePath(pages, targetKey) {
31
+ let index = pageNodePathIndex.get(pages);
32
+ if (!index) {
33
+ index = new Map();
34
+ const collect = (nodes, prefix) => {
35
+ for (const node of nodes) {
36
+ const path = [...prefix, node];
37
+ if (!index.has(node.key)) {
38
+ index.set(node.key, path);
39
+ }
40
+ if (node.children) {
41
+ collect(node.children, path);
42
+ }
43
+ }
44
+ };
45
+ collect(pages, []);
46
+ pageNodePathIndex.set(pages, index);
47
+ }
48
+ return index.get(targetKey) ?? null;
49
+ }
21
50
  export function findPhiPageNodePath(pages, targetKey, prefix = []) {
22
51
  for (const page of pages) {
23
52
  const currentPath = [...prefix, page];
@@ -69,7 +98,7 @@ function findFirstPhiBuilderPageNodeKey(pages) {
69
98
  }
70
99
  export function resolvePhiBuilderActivePageKey(requestedPageKey, pages) {
71
100
  const normalizedPageKey = requestedPageKey?.trim() ?? "";
72
- if (normalizedPageKey && findPhiPageNodePath([...pages], normalizedPageKey)) {
101
+ if (normalizedPageKey && readPhiPageNodePath(pages, normalizedPageKey)) {
73
102
  return normalizedPageKey;
74
103
  }
75
104
  /*
@@ -79,10 +108,10 @@ export function resolvePhiBuilderActivePageKey(requestedPageKey, pages) {
79
108
  return findFirstPhiBuilderPageNodeKey(pages);
80
109
  }
81
110
  export function resolvePhiBuilderPagePresetSource(pageKey, pages) {
82
- return findPhiPageNodePath([...pages], pageKey)?.at(-1)?.sourcePreset ?? null;
111
+ return readPhiPageNodePath(pages, pageKey)?.at(-1)?.sourcePreset ?? null;
83
112
  }
84
113
  export function resolvePhiBuilderPageDefaultFlags(pageKey, pages) {
85
- return findPhiPageNodePath([...pages], pageKey)?.at(-1)?.defaultPageFlags ?? 0;
114
+ return readPhiPageNodePath(pages, pageKey)?.at(-1)?.defaultPageFlags ?? 0;
86
115
  }
87
116
  export function normalizePhiBuilderCmsCatalogPath(value) {
88
117
  const trimmed = value.trim();
@@ -114,7 +143,7 @@ function collectPresetStoragePaths(area, pages) {
114
143
  return storagePaths;
115
144
  }
116
145
  export function resolvePhiBuilderCmsStoragePathForCatalog(area, pageKey, pages) {
117
- const node = findPhiPageNodePath([...pages], pageKey)?.at(-1);
146
+ const node = readPhiPageNodePath(pages, pageKey)?.at(-1);
118
147
  if (!node) {
119
148
  throw new Error(`Page "${area}:${pageKey}" is not present in the active Builder Page catalog.`);
120
149
  }
@@ -133,13 +162,13 @@ export function resolvePhiBuilderCmsStoragePathForCatalog(area, pageKey, pages)
133
162
  * than a fault. Asking the throwing function that question took the Page Select down with it.
134
163
  */
135
164
  export function findPhiBuilderCatalogPathForCatalog(area, pageKey, pages) {
136
- return findPhiPageNodePath([...pages], pageKey)
165
+ return readPhiPageNodePath(pages, pageKey)
137
166
  ? resolvePhiBuilderCatalogPathForCatalog(area, pageKey, pages)
138
167
  : null;
139
168
  }
140
169
  /** Where the Builder shows a Page, which is what its picker offers and its path signal carries. */
141
170
  export function resolvePhiBuilderCatalogPathForCatalog(area, pageKey, pages) {
142
- const node = findPhiPageNodePath([...pages], pageKey)?.at(-1);
171
+ const node = readPhiPageNodePath(pages, pageKey)?.at(-1);
143
172
  if (node?.catalogPath) {
144
173
  return normalizePhiBuilderCmsCatalogPath(node.catalogPath);
145
174
  }
@@ -24,7 +24,6 @@ export declare function isPhiCmsPageOwnedRegion(regionKey: string): regionKey is
24
24
  * can stand: navigation that rebuilds itself on every step is navigation that flickers.
25
25
  */
26
26
  export type PhiCmsRegionOwnership = "shell" | "page";
27
- export declare function resolvePhiCmsRegionOwnership(regionKey: string | null | undefined): PhiCmsRegionOwnership | undefined;
28
27
  /**
29
28
  * Whether a Widget asking for one kind of Region may stand in this one.
30
29
  *
@@ -33,7 +33,7 @@ export function isPhiCmsShellOwnedRegion(regionKey) {
33
33
  export function isPhiCmsPageOwnedRegion(regionKey) {
34
34
  return PHI_CMS_PAGE_OWNED_REGION_KEYS.includes(regionKey);
35
35
  }
36
- export function resolvePhiCmsRegionOwnership(regionKey) {
36
+ function resolvePhiCmsRegionOwnership(regionKey) {
37
37
  if (!regionKey) {
38
38
  return undefined;
39
39
  }
@@ -1,7 +1,18 @@
1
- export declare function formatPhiDate(value: string | null | undefined, locale: string): string;
2
- export declare function formatPhiDateTime(value: string | null | undefined, locale: string): string;
1
+ export declare function formatPhiDate(value: string | null | undefined, locale: string, timeZone: string): string;
2
+ export declare function formatPhiDateTime(value: string | null | undefined, locale: string, timeZone: string): string;
3
+ /**
4
+ * The moment a server render happens, for the Root Layout to hand to `PhiIntlLocaleProvider`.
5
+ *
6
+ * A function and not `Date.now()` in the layout because a render is meant to be pure, and the lint says
7
+ * so; this is the one place the clock is read for a page, and every relative time on it is told this
8
+ * moment rather than its own.
9
+ */
10
+ export declare function readPhiRenderMoment(): number;
3
11
  /**
4
12
  * How long ago or how far ahead, in the locale the caller names: "3 days ago", "in 2 hours". The
5
13
  * largest unit the distance fills, so a moment reads in the words a person would use for it.
14
+ *
15
+ * `now` is the caller's, never read here: a Client component hands over the moment the server rendered
16
+ * the page (`usePhiIntlRenderedAt()`), so the words it hydrates with are the words the server wrote.
6
17
  */
7
- export declare function formatPhiRelativeTime(value: string | null | undefined, locale: string, now?: number): string;
18
+ export declare function formatPhiRelativeTime(value: string | null | undefined, locale: string, now: number): string;
@@ -1,14 +1,17 @@
1
1
  /*
2
- * Formatted in the locale the caller names, never `undefined`: that is the browser's locale in the
3
- * browser and the server's in the server render, and neither is the page's.
2
+ * Formatted in the locale and the time zone the caller names, never `undefined`: that is the browser's
3
+ * in the browser and the server's in the server render, and neither is the page's. The zone is the
4
+ * Site's (`runtime.site.timeZone`, or `usePhiIntlTimeZone()` in a Client component), so that the text
5
+ * the server wrote and the text the browser hydrates it with are one.
4
6
  */
5
7
  const dateFormatters = new Map();
6
8
  const dateTimeFormatters = new Map();
7
- function readFormatter(cache, locale, options) {
8
- let formatter = cache.get(locale);
9
+ function readFormatter(cache, locale, timeZone, options) {
10
+ const key = `${locale}\u0000${timeZone}`;
11
+ let formatter = cache.get(key);
9
12
  if (!formatter) {
10
- formatter = new Intl.DateTimeFormat(locale, options);
11
- cache.set(locale, formatter);
13
+ formatter = new Intl.DateTimeFormat(locale, { ...options, timeZone });
14
+ cache.set(key, formatter);
12
15
  }
13
16
  return formatter;
14
17
  }
@@ -22,16 +25,26 @@ function readPhiDate(value) {
22
25
  }
23
26
  return new Date(timestamp);
24
27
  }
25
- export function formatPhiDate(value, locale) {
28
+ export function formatPhiDate(value, locale, timeZone) {
26
29
  const date = readPhiDate(value);
27
- return date ? readFormatter(dateFormatters, locale, { dateStyle: "medium" }).format(date) : value || "—";
30
+ return date ? readFormatter(dateFormatters, locale, timeZone, { dateStyle: "medium" }).format(date) : value || "—";
28
31
  }
29
- export function formatPhiDateTime(value, locale) {
32
+ export function formatPhiDateTime(value, locale, timeZone) {
30
33
  const date = readPhiDate(value);
31
34
  return date
32
- ? readFormatter(dateTimeFormatters, locale, { dateStyle: "medium", timeStyle: "short" }).format(date)
35
+ ? readFormatter(dateTimeFormatters, locale, timeZone, { dateStyle: "medium", timeStyle: "short" }).format(date)
33
36
  : value || "—";
34
37
  }
38
+ /**
39
+ * The moment a server render happens, for the Root Layout to hand to `PhiIntlLocaleProvider`.
40
+ *
41
+ * A function and not `Date.now()` in the layout because a render is meant to be pure, and the lint says
42
+ * so; this is the one place the clock is read for a page, and every relative time on it is told this
43
+ * moment rather than its own.
44
+ */
45
+ export function readPhiRenderMoment() {
46
+ return Date.now();
47
+ }
35
48
  const relativeFormatters = new Map();
36
49
  const RELATIVE_UNITS = [
37
50
  ["year", 365 * 24 * 60 * 60 * 1000],
@@ -44,8 +57,11 @@ const RELATIVE_UNITS = [
44
57
  /**
45
58
  * How long ago or how far ahead, in the locale the caller names: "3 days ago", "in 2 hours". The
46
59
  * largest unit the distance fills, so a moment reads in the words a person would use for it.
60
+ *
61
+ * `now` is the caller's, never read here: a Client component hands over the moment the server rendered
62
+ * the page (`usePhiIntlRenderedAt()`), so the words it hydrates with are the words the server wrote.
47
63
  */
48
- export function formatPhiRelativeTime(value, locale, now = Date.now()) {
64
+ export function formatPhiRelativeTime(value, locale, now) {
49
65
  const date = readPhiDate(value);
50
66
  if (!date) {
51
67
  return value || "—";
@@ -1,5 +1,5 @@
1
1
  import { type PhiCmsRegionConfig, type PhiCmsRegionKey, type PhiCmsRegionPageScope, type PhiCmsRegionPageScopeEntry, type PhiCmsRegionReveal, type PhiCmsResolvedRegionPageScope } from "../types/cms-presets";
2
- import { type PhiPageReference, type PhiResolvedLinkTargets } from "../types/references";
2
+ import { type PhiResolvedLinkTargets } from "../types/references";
3
3
  /**
4
4
  * The Region's Page scope as stored, or null where it stands on every Page. Only a Shell Region has one:
5
5
  * a Page-owned Region belongs to a single Page already.
@@ -7,8 +7,6 @@ import { type PhiPageReference, type PhiResolvedLinkTargets } from "../types/ref
7
7
  export declare function readPhiCmsRegionPageScope(regionKey: PhiCmsRegionKey, config: PhiCmsRegionConfig | null | undefined): PhiCmsRegionPageScope | null;
8
8
  /** The entries a stored scope names, each read whole; an entry that names nothing is dropped. */
9
9
  export declare function readPhiCmsRegionPageScopeEntries(value: unknown): PhiCmsRegionPageScopeEntry[];
10
- /** The Pages a scope names by reference, for the render that resolves them. */
11
- export declare function collectPhiCmsRegionPageScopeReferences(scope: PhiCmsRegionPageScope | null): PhiPageReference[];
12
10
  /**
13
11
  * The scope as the browser asks it, with every reference turned into the address it leads to now.
14
12
  *
@@ -49,10 +49,6 @@ export function readPhiCmsRegionPageScopeEntries(value) {
49
49
  return folder == null ? [] : [{ folder }];
50
50
  });
51
51
  }
52
- /** The Pages a scope names by reference, for the render that resolves them. */
53
- export function collectPhiCmsRegionPageScopeReferences(scope) {
54
- return (scope?.entries ?? []).flatMap((entry) => "pageLinkTarget" in entry && entry.pageLinkTarget.kind === "page" ? [entry.pageLinkTarget.reference] : []);
55
- }
56
52
  /**
57
53
  * The scope as the browser asks it, with every reference turned into the address it leads to now.
58
54
  *