@phis/ui 0.4.7 → 0.4.10

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 (183) hide show
  1. package/components/cms/phi-cms-runtime-registry.d.ts +2 -1
  2. package/components/cms/phi-cms-runtime-registry.js +1 -1
  3. package/components/controls/phi-color-control.js +2 -1
  4. package/components/controls/phi-drawer-control-adapter.js +2 -3
  5. package/components/controls/phi-drawer-control.js +3 -3
  6. package/components/controls/phi-dropdown-control.js +2 -1
  7. package/components/controls/phi-float-button-control.js +3 -3
  8. package/components/controls/phi-modal-control-adapter.js +2 -2
  9. package/components/controls/phi-modal-control.js +3 -3
  10. package/components/controls/phi-ribbon-wrap-control.js +2 -1
  11. package/components/controls/phi-zoom-image-overlay.js +11 -5
  12. package/components/forms/content-entry-forms.js +1 -5
  13. package/components/forms/form-descriptor-runtime-client.js +2 -1
  14. package/components/forms/form-descriptor-text.d.ts +17 -0
  15. package/components/forms/form-descriptor-text.js +14 -0
  16. package/components/forms/runtime-form-controller-plugin.d.ts +0 -115
  17. package/components/forms/runtime-form-controller-plugin.js +1 -1
  18. package/components/forms/upload-form-control.d.ts +0 -7
  19. package/components/forms/upload-form-control.js +1 -1
  20. package/components/layouts/clients/phi-collapsible-layout-client.js +2 -1
  21. package/components/layouts/clients/phi-sequence-slot-editor.js +2 -1
  22. package/components/layouts/clients/phi-split-card-half.js +2 -1
  23. package/components/layouts/phi-base-layout.js +2 -1
  24. package/components/layouts/phi-layout-surface-box.js +2 -1
  25. package/components/media/phi-media-picker-server.js +3 -11
  26. package/components/navigation/use-phi-protected-mail.js +1 -9
  27. package/components/regions/presets/clients/sider-context.js +4 -2
  28. package/components/root/phi-config-provider.js +2 -1
  29. package/components/root/phi-dayjs-locale.d.ts +4 -1
  30. package/components/root/phi-dayjs-locale.js +2 -2
  31. package/components/root/phi-intl-locale.d.ts +7 -1
  32. package/components/root/phi-intl-locale.js +20 -15
  33. package/components/root/phi-root-layout.js +2 -1
  34. package/components/runtime/core-runtime-controller-plugin.d.ts +0 -84
  35. package/components/runtime/core-runtime-controller-plugin.js +1 -1
  36. package/components/runtime/runtime-signal-bus.js +39 -4
  37. package/components/state/use-phi-hydrated.d.ts +6 -0
  38. package/components/state/use-phi-hydrated.js +11 -0
  39. package/components/widgets/client/shared/phi-rendered-value.js +4 -3
  40. package/components/widgets/config/parser-primitives.d.ts +5 -0
  41. package/components/widgets/config/parser-primitives.js +11 -0
  42. package/components/widgets/label-sets/runtime-options.d.ts +1 -1
  43. package/components/widgets/server/builder-chrome.js +2 -6
  44. package/components/widgets/server/search.js +2 -6
  45. package/gateway/dashboard-cards-route.js +5 -7
  46. package/gateway/navigation-target-route.js +7 -9
  47. package/gateway/page-references-route.js +6 -8
  48. package/gateway/site-config.js +3 -0
  49. package/gateway/site-proxy.js +13 -2
  50. package/helpers/class-names.d.ts +7 -0
  51. package/helpers/class-names.js +10 -0
  52. package/helpers/cms-navigation-catalog.js +4 -2
  53. package/helpers/cms-page-catalog.js +35 -6
  54. package/helpers/cms-region-keys.d.ts +0 -1
  55. package/helpers/cms-region-keys.js +1 -1
  56. package/helpers/format-date-time.d.ts +14 -3
  57. package/helpers/format-date-time.js +27 -11
  58. package/helpers/region-page-scope.d.ts +1 -3
  59. package/helpers/region-page-scope.js +0 -4
  60. package/helpers/translation-format.d.ts +6 -0
  61. package/helpers/translation-format.js +15 -8
  62. package/package.json +2 -2
  63. package/plugins/runtime/phi-slot-child-frame-view.js +2 -1
  64. package/plugins/runtime/phi-slot-child-viewport-effects-observer.js +1 -1
  65. package/plugins/runtime-modules/admin/forms.js +1 -1
  66. package/plugins/runtime-modules/admin/trees/phi-default-admin-settings-page-tree.js +2 -5
  67. package/plugins/runtime-modules/app/forms.js +1 -1
  68. package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.js +2 -6
  69. package/plugins/runtime-modules/asset/metadata-form.js +2 -6
  70. package/plugins/runtime-modules/asset/settings-forms.js +1 -1
  71. package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +2 -5
  72. package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +2 -6
  73. package/plugins/runtime-modules/asset/widgets/area-upload/server.js +2 -6
  74. package/plugins/runtime-modules/asset/widgets/image-inspector/authoring.js +1 -3
  75. package/plugins/runtime-modules/asset/widgets/image-inspector/server.js +2 -6
  76. package/plugins/runtime-modules/asset/widgets.js +5 -7
  77. package/plugins/runtime-modules/auth/admin-settings-forms.js +1 -1
  78. package/plugins/runtime-modules/auth/ids.d.ts +7 -7
  79. package/plugins/runtime-modules/auth/ids.js +7 -7
  80. package/plugins/runtime-modules/auth/trees/phi-auth-area-overlay-tree.server.js +2 -6
  81. package/plugins/runtime-modules/auth/trees/phi-default-admin-auth-settings-page-tree.js +2 -5
  82. package/plugins/runtime-modules/auth/widgets.d.ts +1 -2
  83. package/plugins/runtime-modules/auth/widgets.js +5 -7
  84. package/plugins/runtime-modules/avatar/overlay-tree.server.js +2 -6
  85. package/plugins/runtime-modules/avatar/widgets/account-avatar/server.js +2 -6
  86. package/plugins/runtime-modules/avatar/widgets/account-avatar-picker/server.js +2 -6
  87. package/plugins/runtime-modules/avatar/widgets.js +3 -5
  88. package/plugins/runtime-modules/builder/clients/pages-workspace.d.ts +2 -3
  89. package/plugins/runtime-modules/builder/clients/pages-workspace.js +5 -18
  90. package/plugins/runtime-modules/builder/controller/draft-command-controller.js +1 -0
  91. package/plugins/runtime-modules/builder/controller/page-controller.js +1 -1
  92. package/plugins/runtime-modules/builder/controller/server-definition.js +3 -11
  93. package/plugins/runtime-modules/builder/controller/workspace-controller.js +2 -6
  94. package/plugins/runtime-modules/builder/developer-workspace-store.d.ts +2 -8
  95. package/plugins/runtime-modules/builder/developer-workspace-store.js +24 -44
  96. package/plugins/runtime-modules/builder/developer-workspace-types.d.ts +0 -5
  97. package/plugins/runtime-modules/builder/edit-scaffold-drawer.js +2 -1
  98. package/plugins/runtime-modules/builder/inspector-section-widget.js +6 -31
  99. package/plugins/runtime-modules/builder/navigation-persistence.js +12 -3
  100. package/plugins/runtime-modules/builder/page-meta-form.js +4 -12
  101. package/plugins/runtime-modules/builder/page-presets.server.d.ts +0 -1
  102. package/plugins/runtime-modules/builder/page-presets.server.js +0 -24
  103. package/plugins/runtime-modules/builder/pages-workspace.js +6 -16
  104. package/plugins/runtime-modules/builder/persistence.d.ts +6 -4
  105. package/plugins/runtime-modules/builder/persistence.js +6 -7
  106. package/plugins/runtime-modules/builder/shells-workspace.js +3 -11
  107. package/plugins/runtime-modules/builder/signal-wiring-form.js +3 -7
  108. package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +2 -6
  109. package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +6 -26
  110. package/plugins/runtime-modules/builder/trees/phi-default-builder-settings-page-tree.js +2 -6
  111. package/plugins/runtime-modules/builder/widgets/developer-builder-pages-header/plugin.js +2 -6
  112. package/plugins/runtime-modules/builder/widgets/inspector-header/plugin.js +2 -6
  113. package/plugins/runtime-modules/builder/widgets/structure-region/built-in.js +3 -2
  114. package/plugins/runtime-modules/builder/widgets/structure-region/plugin.js +1 -6
  115. package/plugins/runtime-modules/builder/widgets.js +10 -12
  116. package/plugins/runtime-modules/contracts.d.ts +15 -1
  117. package/plugins/runtime-modules/contracts.js +10 -0
  118. package/plugins/runtime-modules/core/messaging/forms.js +1 -1
  119. package/plugins/runtime-modules/core/widgets/description/server.js +12 -9
  120. package/plugins/runtime-modules/core/widgets/dimension/plugin.js +2 -6
  121. package/plugins/runtime-modules/core/widgets/draft-status/plugin.js +2 -6
  122. package/plugins/runtime-modules/core/widgets/entry-list/config.js +2 -9
  123. package/plugins/runtime-modules/core/widgets/entry-list/view.server.js +1 -1
  124. package/plugins/runtime-modules/core/widgets/form-preview/client.js +2 -15
  125. package/plugins/runtime-modules/core/widgets/gallery/server.js +2 -6
  126. package/plugins/runtime-modules/core/widgets/image/server.js +2 -6
  127. package/plugins/runtime-modules/core/widgets/length/plugin.js +2 -6
  128. package/plugins/runtime-modules/core/widgets/markdown-toc/plugin.js +2 -6
  129. package/plugins/runtime-modules/core/widgets/page-title/server.js +2 -6
  130. package/plugins/runtime-modules/core/widgets/pagination/config.js +4 -8
  131. package/plugins/runtime-modules/core/widgets/search-results/config.js +2 -8
  132. package/plugins/runtime-modules/core/widgets/sidebar-navigation/server.d.ts +2 -2
  133. package/plugins/runtime-modules/core/widgets/sidebar-navigation/server.js +8 -13
  134. package/plugins/runtime-modules/core/widgets/theme-mode-switch/server.js +2 -6
  135. package/plugins/runtime-modules/core/widgets/thread-conversation/client.js +16 -31
  136. package/plugins/runtime-modules/core/widgets/timeline/client.js +9 -4
  137. package/plugins/runtime-modules/core/widgets/tour-button/server.js +2 -6
  138. package/plugins/runtime-modules/core/widgets.js +59 -61
  139. package/plugins/runtime-modules/dashboard/clients/dashboard-card-view.js +7 -5
  140. package/plugins/runtime-modules/dashboard/trees/phi-default-admin-dashboard-page-tree.js +2 -6
  141. package/plugins/runtime-modules/dashboard/trees/phi-default-area-dashboard-page-tree.js +2 -6
  142. package/plugins/runtime-modules/dashboard/trees/phi-default-builder-dashboard-page-tree.js +2 -6
  143. package/plugins/runtime-modules/descriptor-compiler.js +6 -6
  144. package/plugins/runtime-modules/groups/controller/client.d.ts +0 -56
  145. package/plugins/runtime-modules/groups/controller/client.js +1 -1
  146. package/plugins/runtime-modules/groups/forms.js +1 -5
  147. package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +2 -6
  148. package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -6
  149. package/plugins/runtime-modules/localization/forms.js +2 -6
  150. package/plugins/runtime-modules/localization/services/options.js +19 -9
  151. package/plugins/runtime-modules/localization/trees/phi-default-admin-locales-page-tree.js +3 -11
  152. package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +3 -11
  153. package/plugins/runtime-modules/observability/trees/phi-default-admin-logs-page-tree.js +3 -11
  154. package/plugins/runtime-modules/revisions/forms.js +1 -1
  155. package/plugins/runtime-modules/revisions/services/table.js +6 -2
  156. package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +2 -2
  157. package/plugins/runtime-modules/theme/controller/server-definition.js +2 -6
  158. package/plugins/runtime-modules/theme/trees/phi-default-builder-theme-page-tree.js +2 -6
  159. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +17 -21
  160. package/plugins/runtime-modules/theme/widgets/brand-controls/config.d.ts +0 -2
  161. package/plugins/runtime-modules/theme/widgets/brand-controls/config.js +0 -8
  162. package/plugins/runtime-modules/theme/widgets.js +6 -8
  163. package/plugins/runtime-modules/threads/controller/client.d.ts +0 -78
  164. package/plugins/runtime-modules/threads/controller/client.js +1 -1
  165. package/plugins/runtime-modules/threads/forms.js +1 -1
  166. package/plugins/runtime-modules/threads/ids.d.ts +0 -1
  167. package/plugins/runtime-modules/threads/ids.js +0 -2
  168. package/plugins/runtime-modules/user-management/controller/client.d.ts +0 -73
  169. package/plugins/runtime-modules/user-management/controller/client.js +1 -1
  170. package/plugins/runtime-modules/user-management/forms.js +1 -5
  171. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +2 -6
  172. package/plugins/runtime-modules/video/widgets.js +2 -4
  173. package/server-helpers/cms-request.d.ts +19 -0
  174. package/server-helpers/cms-request.js +26 -8
  175. package/server-helpers/cms-root.js +6 -8
  176. package/server-helpers/public-login-route.js +6 -8
  177. package/server-helpers/runtime.js +1 -0
  178. package/server-helpers/search-index.js +58 -27
  179. package/types/length.js +8 -3
  180. package/types/site-config.d.ts +6 -0
  181. package/types/widget-runtime.d.ts +2 -0
  182. package/types.d.ts +5 -3
  183. package/types.js +3 -0
@@ -3,15 +3,17 @@ import { createHash } from "node:crypto";
3
3
  import { PHI_SEARCH_MAX_DOCUMENTS } from "@phis/contracts/search";
4
4
  import { resolvePhiCmsPageRedirect } from "../components/cms/phi-cms-page-redirect";
5
5
  import { getSiteAreaWithPublishedPages } from "../gateway/site-area";
6
+ import { getResolvedSiteConfig } from "../gateway/site-config";
6
7
  import { onPhiSiteReadMarker } from "../gateway/site-read-marker-listeners";
7
8
  import { fetchPhiSiteSearchIndexStates, putPhiSiteSearchIndexSet } from "../gateway/site-search";
8
- import { readPhiAreaLandingSelection, readPhiAreaPublicRoutePaths } from "../helpers/cms-area-config";
9
+ import { buildPhiRuntimeModuleAccessRegistry, filterPhiCmsRenderableTreeForViewer, } from "../helpers/cms-access-policy";
9
10
  import { collectPhiSitemapCandidates } from "../helpers/phi-seo";
10
- import { compilePhiCmsActiveRouteTable, resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
11
+ import { resolvePhiCmsAreaShellPresetBinding, resolvePhiCmsDescriptorCatalog, } from "../plugins/runtime-modules/descriptor-compiler";
11
12
  import { resolvePhiCmsAreaRuntimeModuleScope } from "../components/cms/phi-cms-runtime-registry";
12
13
  import { canPhiViewerAccess } from "../types/access";
13
14
  import { resolvePhiCmsLookup } from "./cms-lookup";
14
- import { resolveActivePresetModuleKeys } from "./cms-request";
15
+ import { resolvePhiAreaRouteScope } from "./cms-request";
16
+ import { runWithPhiRequestRuntime } from "./request-runtime";
15
17
  import { loadPhiSiteRequestContext } from "./runtime";
16
18
  import { joinPhiSearchText } from "./search-text";
17
19
  /**
@@ -41,7 +43,7 @@ const PHI_SEARCH_INDEX_DEBOUNCE_MS = 2_000;
41
43
  * What the extraction is, named in the fingerprint: a change in how documents are built reindexes every
42
44
  * Site on its next start, which the published revisions alone would not do.
43
45
  */
44
- const PHI_SEARCH_INDEX_FORMAT = 1;
46
+ const PHI_SEARCH_INDEX_FORMAT = 2;
45
47
  const REGISTRY_KEY = Symbol.for("phis-ui.search-index");
46
48
  function readRegistry() {
47
49
  const holder = globalThis;
@@ -161,6 +163,8 @@ async function indexArea({ area, bridge, credentials, heldFingerprint, }) {
161
163
  const areaMask = area === "public" ? 1 : 2;
162
164
  // The Site's languages and its server, read once as the anonymous reader; the locale is per set.
163
165
  const anonymous = await loadPhiSiteRequestContext(siteKey, "", "", apiBaseUrl, internalToken);
166
+ // The Site config's change markers, from the same answer the context above was built from.
167
+ const { readMarker, translationMarkers } = await getResolvedSiteConfig({ apiBaseUrl, internalToken, siteKey });
164
168
  const locales = anonymous.site.availableLocales.map((option) => option.code);
165
169
  const { area: areaPreset, publishedPages } = await getSiteAreaWithPublishedPages({
166
170
  apiBaseUrl,
@@ -170,18 +174,24 @@ async function indexArea({ area, bridge, credentials, heldFingerprint, }) {
170
174
  sourcePreset,
171
175
  area,
172
176
  });
173
- const activeModuleIds = resolveActivePresetModuleKeys(bridge.runtimeModuleCatalog, area, areaPreset ? { preset: areaPreset.preset } : null, anonymous.serverCapabilities);
174
- const routeTable = compilePhiCmsActiveRouteTable({
177
+ const { activeModuleIds, routeTable } = resolvePhiAreaRouteScope({
178
+ runtimeModuleCatalog: bridge.runtimeModuleCatalog,
175
179
  catalog,
176
180
  area,
177
- activeModuleIds,
178
- publicRoutePaths: readPhiAreaPublicRoutePaths(areaPreset?.preset.preset.config),
179
- landingSelection: readPhiAreaLandingSelection(areaPreset?.preset.preset.config),
181
+ preset: areaPreset?.preset ?? null,
182
+ serverCapabilities: anonymous.serverCapabilities,
180
183
  });
181
184
  const candidates = collectPhiSitemapCandidates({
182
185
  moduleRoutes: [...routeTable.exactByPath].map(([path, descriptor]) => [path, descriptor]),
183
186
  publishedPages,
184
187
  });
188
+ /*
189
+ * The read marker and the translation markers are in here because what a Page says is not only its
190
+ * structure: a Widget bound to content reads the content's published version, and every text is
191
+ * translated. Publishing content moves the read marker (the Site's publish triggers), correcting a
192
+ * translation moves a translation marker, and without them here either left the old words in the
193
+ * index. The price is a run per published change, which is what SEARCH.md promises.
194
+ */
185
195
  const fingerprint = createHash("sha256").update(JSON.stringify({
186
196
  format: PHI_SEARCH_INDEX_FORMAT,
187
197
  area,
@@ -189,6 +199,8 @@ async function indexArea({ area, bridge, credentials, heldFingerprint, }) {
189
199
  areaPreset: areaPreset?.preset ?? null,
190
200
  activeModuleIds: [...activeModuleIds].sort(),
191
201
  locales,
202
+ readMarker,
203
+ translationMarkers,
192
204
  })).digest("hex");
193
205
  // The Area's Module scope as the live render resolves it: the preset's selection, the locked ones implied.
194
206
  const { moduleSet } = await resolvePhiCmsAreaRuntimeModuleScope({
@@ -197,6 +209,8 @@ async function indexArea({ area, bridge, credentials, heldFingerprint, }) {
197
209
  areaPreset: areaPreset?.preset ?? null,
198
210
  serverCapabilities: anonymous.serverCapabilities,
199
211
  });
212
+ // The same access registry the live render filters a Page's tree with (phi-cms-page-render-scope.tsx).
213
+ const accessRegistry = buildPhiRuntimeModuleAccessRegistry(moduleSet);
200
214
  const plugins = new Map();
201
215
  const loadPlugin = (type) => {
202
216
  let pending = plugins.get(type);
@@ -218,7 +232,7 @@ async function indexArea({ area, bridge, credentials, heldFingerprint, }) {
218
232
  if (heldFingerprint(areaMask, locale) === fingerprint)
219
233
  continue;
220
234
  const context = asIndexingReader(await loadPhiSiteRequestContext(siteKey, locale, "", apiBaseUrl, internalToken), area);
221
- const documents = await readDocuments({ bridge, area, locale, context, candidates, loadPlugin });
235
+ const documents = await readDocuments({ bridge, area, locale, context, candidates, loadPlugin, accessRegistry });
222
236
  const answer = await putPhiSiteSearchIndexSet({
223
237
  ...credentials,
224
238
  area,
@@ -233,7 +247,7 @@ async function indexArea({ area, bridge, credentials, heldFingerprint, }) {
233
247
  console.info(`[phis-ui] Search index ${area}/${locale}: ${answer.accepted ? `${answer.state.documentCount} documents written` : "already held"}.`);
234
248
  }
235
249
  }
236
- async function readDocuments({ bridge, area, locale, context, candidates, loadPlugin, }) {
250
+ async function readDocuments({ bridge, area, locale, context, candidates, loadPlugin, accessRegistry, }) {
237
251
  const documents = new Array(candidates.length).fill(null);
238
252
  let next = 0;
239
253
  async function work() {
@@ -241,7 +255,7 @@ async function readDocuments({ bridge, area, locale, context, candidates, loadPl
241
255
  const index = next++;
242
256
  const path = candidates[index].path;
243
257
  try {
244
- documents[index] = await readDocument({ bridge, area, locale, context, path, loadPlugin });
258
+ documents[index] = await readDocument({ bridge, area, locale, context, path, loadPlugin, accessRegistry });
245
259
  }
246
260
  catch (error) {
247
261
  console.error(`[phis-ui] The search index could not read ${area}:${path} (${locale}).`, error);
@@ -256,9 +270,11 @@ async function readDocuments({ bridge, area, locale, context, candidates, loadPl
256
270
  /**
257
271
  * One Page as a document, or `null` where a reader of this Area would not get one: nothing resolves
258
272
  * there, it forwards, it asked to stay out of the index, or its access policy is narrower than the
259
- * reader's. The words are the Page's title and description and every Widget's own answer, in tree order.
273
+ * reader's. The words are the Page's title and description and every Widget's own answer, in tree order
274
+ * -- of the Widgets this reader would see: a Layout or Widget with a narrower policy than the Page's is
275
+ * left out here as the live render leaves it out, so its words never reach a reader it is hidden from.
260
276
  */
261
- async function readDocument({ bridge, area, locale, context, path, loadPlugin, }) {
277
+ async function readDocument({ bridge, area, locale, context, path, loadPlugin, accessRegistry, }) {
262
278
  const resolved = await resolvePhiCmsLookup({
263
279
  bridge,
264
280
  area,
@@ -276,20 +292,35 @@ async function readDocument({ bridge, area, locale, context, path, loadPlugin, }
276
292
  return null;
277
293
  if (!canPhiViewerAccess(resolved.runtime.viewer, page.accessPolicy))
278
294
  return null;
279
- const lines = [];
280
- for (const widget of resolved.page.contentWidgets) {
281
- const plugin = await loadPlugin(widget.widgetType);
282
- if (!plugin?.searchText)
283
- continue;
284
- try {
285
- const config = plugin.parseConfig(widget.config);
286
- lines.push(...await plugin.searchText({ widget, config, runtime: resolved.runtime }));
287
- }
288
- catch (error) {
289
- // One Widget that cannot say its words costs the Page those words, not the Page.
290
- console.error(`[phis-ui] The search index could not read the Widget "${widget.widgetType}" on ${area}:${path}.`, error);
295
+ /*
296
+ * The Widgets answer inside a request scope of their own. `searchText` is given the runtime, but the
297
+ * shared server helpers a Widget reaches for -- the translation of its texts first of all -- read the
298
+ * request runtime from the scope, and the indexer runs where no request is: at start-up, or on a
299
+ * timer after a publish. Without this scope every Widget that translates fails and a Page is indexed
300
+ * by title and description alone, which is what the first production index was.
301
+ */
302
+ const visible = filterPhiCmsRenderableTreeForViewer({
303
+ tree: resolved.page,
304
+ viewer: resolved.runtime.viewer,
305
+ registry: accessRegistry,
306
+ });
307
+ const lines = await runWithPhiRequestRuntime(resolved.runtime, async () => {
308
+ const collected = [];
309
+ for (const widget of visible.contentWidgets) {
310
+ const plugin = await loadPlugin(widget.widgetType);
311
+ if (!plugin?.searchText)
312
+ continue;
313
+ try {
314
+ const config = plugin.parseConfig(widget.config);
315
+ collected.push(...await plugin.searchText({ widget, config, runtime: resolved.runtime }));
316
+ }
317
+ catch (error) {
318
+ // One Widget that cannot say its words costs the Page those words, not the Page.
319
+ console.error(`[phis-ui] The search index could not read the Widget "${widget.widgetType}" on ${area}:${path}.`, error);
320
+ }
291
321
  }
292
- }
322
+ return collected;
323
+ });
293
324
  return {
294
325
  path: page.path,
295
326
  title: resolved.runtime.page?.title ?? "",
package/types/length.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export const PHI_CSS_LENGTH_UNITS = ["px", "%", "em", "rem", "vw", "vh"];
2
2
  const CSS_LENGTH_PATTERN = /^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(px|%|em|rem|vw|vh)$/;
3
+ const BARE_NUMBER_PATTERN = /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/;
3
4
  export function readPhiCssLengthPart(value) {
4
5
  if (typeof value === "number") {
5
6
  return Number.isFinite(value) ? { value, unit: "px" } : null;
@@ -8,9 +9,13 @@ export function readPhiCssLengthPart(value) {
8
9
  return null;
9
10
  }
10
11
  const trimmed = value.trim();
11
- const numeric = Number(trimmed);
12
- if (Number.isFinite(numeric)) {
13
- return { value: numeric, unit: "px" };
12
+ // `Number("")` is 0 and `Number("0x1f")` is 31: a field emptied in the Inspector read as "0px", and a
13
+ // hex literal as a length. Only a decimal, with or without a unit, is one.
14
+ if (!trimmed) {
15
+ return null;
16
+ }
17
+ if (BARE_NUMBER_PATTERN.test(trimmed)) {
18
+ return { value: Number(trimmed), unit: "px" };
14
19
  }
15
20
  const match = CSS_LENGTH_PATTERN.exec(trimmed);
16
21
  if (!match) {
@@ -73,6 +73,12 @@ export type PhiSiteConfig = {
73
73
  * language a visitor is shown first, which is `defaultLocale` and may differ.
74
74
  */
75
75
  sourceLocale: string;
76
+ /**
77
+ * The IANA zone every date and time of the Site is shown in (`phis site set --time-zone`). One zone
78
+ * for the server render and the browser: both format the same instant with it, so the text a page
79
+ * is hydrated against is the text the reader sees. Neither the host's zone nor the reader's.
80
+ */
81
+ timeZone: string;
76
82
  availableLocales: PhiSiteLocaleOption[];
77
83
  /** What each served locale means, so a request naming one is resolved without asking Core. */
78
84
  localeCapabilities: PhiLocaleCapability[];
@@ -24,6 +24,8 @@ export type PhiBlockRuntimeSite = {
24
24
  defaultLocale: string;
25
25
  /** The language the Site's own words are written in (`PhiSiteConfig.sourceLocale`). */
26
26
  sourceLocale: string;
27
+ /** The IANA zone the Site's dates and times are shown in (`PhiSiteConfig.timeZone`). */
28
+ timeZone: string;
27
29
  store: {
28
30
  enabled: boolean;
29
31
  };
package/types.d.ts CHANGED
@@ -3,9 +3,11 @@ 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 PhiCmsNavigationBaseItemDescriptor, type PhiCmsNavigationCustomItem, 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 { expandPhiBorderRadiusConfig, mergePhiBorderWidgetConfig, mergePhiCmsConfigValues, mergePhiPaddingWidgetConfig, normalizePhiPaddingWidgetConfig, PhiCmsBorderWidgetConfig, PhiCmsPaddingWidgetConfig, PhiCmsPluginConfigBase, PhiCmsRenderableBlockConfigBase, } from "./types/cms-config";
7
- export type { readPhiCmsBorderWidgetConfig } from "./types/cms-border-config";
8
- export type { PHI_CMS_BORDER_SOURCES, PhiCmsBorderSource, readPhiCmsBorderSource, resolvePhiCmsBorderSource, } from "./types/cms-border-source";
6
+ export { expandPhiBorderRadiusConfig, mergePhiBorderWidgetConfig, mergePhiCmsConfigValues, mergePhiPaddingWidgetConfig, normalizePhiPaddingWidgetConfig, } from "./types/cms-config";
7
+ export type { PhiCmsBorderWidgetConfig, PhiCmsPaddingWidgetConfig, PhiCmsPluginConfigBase, PhiCmsRenderableBlockConfigBase, } from "./types/cms-config";
8
+ export { readPhiCmsBorderWidgetConfig } from "./types/cms-border-config";
9
+ export { PHI_CMS_BORDER_SOURCES, readPhiCmsBorderSource, resolvePhiCmsBorderSource } from "./types/cms-border-source";
10
+ export type { PhiCmsBorderSource } from "./types/cms-border-source";
9
11
  export type * from "./types/renderable-block";
10
12
  export * from "./types/layout-style";
11
13
  export * from "./types/control";
package/types.js CHANGED
@@ -1,6 +1,9 @@
1
1
  export * from "./types/cms-overlay";
2
2
  export * from "./types/cms-instance-id";
3
3
  export {} from "./types/cms-module-descriptors";
4
+ export { expandPhiBorderRadiusConfig, mergePhiBorderWidgetConfig, mergePhiCmsConfigValues, mergePhiPaddingWidgetConfig, normalizePhiPaddingWidgetConfig, } from "./types/cms-config";
5
+ export { readPhiCmsBorderWidgetConfig } from "./types/cms-border-config";
6
+ export { PHI_CMS_BORDER_SOURCES, readPhiCmsBorderSource, resolvePhiCmsBorderSource } from "./types/cms-border-source";
4
7
  export * from "./types/layout-style";
5
8
  export * from "./types/control";
6
9
  export * from "./types/calendar";