@phis/ui 0.6.0 → 0.6.1
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-form-control.d.ts +6 -0
- package/components/controls/phi-form-control.js +23 -7
- package/components/controls/phi-media-picker-control.d.ts +3 -1
- package/components/controls/phi-media-picker-control.js +2 -2
- package/components/forms/form-descriptor-runtime-client.d.ts +3 -1
- package/components/forms/form-descriptor-runtime-client.js +2 -2
- package/components/forms/form-field-provider-modules.d.ts +23 -0
- package/components/forms/form-field-provider-modules.js +28 -0
- package/components/forms/form-provider-contract.d.ts +7 -0
- package/components/forms/form-provider-contract.js +7 -0
- package/components/forms/lazy-form-field-control.d.ts +14 -0
- package/components/forms/lazy-form-field-control.js +35 -0
- package/components/forms/phi-form-widget.d.ts +3 -2
- package/components/forms/phi-form-widget.js +21 -3
- package/components/forms/shared-form-provider-registry.js +1 -33
- package/components/media/phi-area-upload-widget.js +6 -58
- package/components/media/phi-media-picker-binding.d.ts +16 -1
- package/components/media/phi-media-picker-binding.js +3 -2
- package/components/media/phi-media-upload.d.ts +12 -0
- package/components/media/phi-media-upload.js +22 -0
- package/components/media/phi-upload-drop-area.d.ts +22 -0
- package/components/media/phi-upload-drop-area.js +49 -0
- package/components/widgets/helpers/semantic-html-translation.d.ts +4 -1
- package/components/widgets/helpers/semantic-html-translation.js +4 -2
- package/components/widgets/label-sets/admin-users.d.ts +9 -1
- package/components/widgets/label-sets/admin-users.js +14 -2
- package/components/widgets/label-sets/slot-upload.js +6 -3
- package/components/widgets/label-types/slot-upload.d.ts +7 -1
- package/components/widgets/label-types/slot-upload.js +2 -1
- package/components/widgets/shared/markdown-render.js +6 -6
- package/constants/media-library-provider-keys.d.ts +9 -0
- package/constants/media-library-provider-keys.js +9 -0
- package/constants/runtime-module-ownership.js +2 -0
- package/controls.d.ts +2 -0
- package/controls.js +1 -0
- package/gateway/signet-route.js +11 -6
- package/helpers/phi-signet-head.d.ts +4 -3
- package/helpers/phi-signet-head.js +17 -5
- package/helpers/phi-signet.d.ts +12 -0
- package/helpers/phi-signet.js +11 -0
- package/net/phi-next-proxy.d.ts +10 -8
- package/net/phi-next-proxy.js +27 -84
- package/next/proxy-runtime.js +15 -0
- package/next/site-proxy.js +5 -0
- package/package.json +1 -1
- package/plugins/runtime-modules/asset/definition.d.ts +44 -2
- package/plugins/runtime-modules/asset/definition.js +5 -2
- package/plugins/runtime-modules/asset/form-providers.d.ts +63 -0
- package/plugins/runtime-modules/asset/form-providers.js +54 -0
- package/plugins/runtime-modules/asset/form-ui-provider.js +13 -3
- package/plugins/runtime-modules/asset/media-asset-field.d.ts +20 -0
- package/plugins/runtime-modules/asset/media-asset-field.js +33 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +21 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.js +74 -0
- package/plugins/runtime-modules/core/widgets/html/server.js +1 -1
- package/plugins/runtime-modules/core/widgets/slot-upload/client.js +28 -23
- package/plugins/runtime-modules/core/widgets/slot-upload/slot.d.ts +19 -0
- package/plugins/runtime-modules/core/widgets/slot-upload/slot.js +16 -0
- package/plugins/runtime-modules/resolver.js +38 -4
- package/plugins/runtime-modules/user-management/addon-roles.d.ts +35 -0
- package/plugins/runtime-modules/user-management/addon-roles.js +76 -0
- package/plugins/runtime-modules/user-management/cards.js +1 -1
- package/plugins/runtime-modules/user-management/client-data-providers.js +6 -0
- package/plugins/runtime-modules/user-management/data-providers.d.ts +11 -2
- package/plugins/runtime-modules/user-management/data-providers.js +12 -1
- package/plugins/runtime-modules/user-management/definition.d.ts +11 -2
- package/plugins/runtime-modules/user-management/ids.d.ts +1 -0
- package/plugins/runtime-modules/user-management/ids.js +1 -0
- package/plugins/runtime-modules/user-management/services/options.d.ts +8 -0
- package/plugins/runtime-modules/user-management/services/options.js +25 -0
- package/plugins/runtime-modules/user-management/services/table.js +9 -1
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +20 -2
- package/server-helpers/cms-widget-texts.js +1 -1
- package/server-helpers/search-index.js +22 -13
- package/server-helpers/search-text.d.ts +3 -2
- package/server-helpers/search-text.js +6 -5
- package/server-helpers/translate.d.ts +13 -2
- package/server-helpers/translate.js +10 -6
- package/theme/phi-theme-signet.d.ts +6 -0
- package/theme/phi-theme-signet.js +37 -1
- package/theme/phi-tokens.d.ts +1 -1
- package/theme/phi-tokens.js +5 -1
- package/types/cms-plugins.d.ts +10 -1
- package/types/site-theme.d.ts +14 -2
|
@@ -124,6 +124,7 @@ async function indexRegisteredAreas(registry) {
|
|
|
124
124
|
internalToken: bridgeRuntime.internalToken,
|
|
125
125
|
siteKey: bridgeRuntime.siteKey,
|
|
126
126
|
};
|
|
127
|
+
const failures = new Map();
|
|
127
128
|
const held = await fetchPhiSiteSearchIndexStates(credentials);
|
|
128
129
|
const heldFingerprint = (areaMask, locale) => held.find((state) => state.areaMask === areaMask && state.locale === locale)?.fingerprint ?? null;
|
|
129
130
|
for (const area of PHI_SEARCH_INDEX_AREAS) {
|
|
@@ -131,12 +132,15 @@ async function indexRegisteredAreas(registry) {
|
|
|
131
132
|
if (!bridge)
|
|
132
133
|
continue;
|
|
133
134
|
try {
|
|
134
|
-
await indexArea({ area, bridge, credentials, heldFingerprint });
|
|
135
|
+
await indexArea({ area, bridge, credentials, heldFingerprint, failures });
|
|
135
136
|
}
|
|
136
137
|
catch (error) {
|
|
137
138
|
console.error(`[phis-ui] Indexing the ${area} Area for search failed.`, error);
|
|
138
139
|
}
|
|
139
140
|
}
|
|
141
|
+
for (const [widgetType, failure] of failures) {
|
|
142
|
+
console.error(`[phis-ui] The search index could not read the Widget "${widgetType}" on ${failure.pages} page(s) in this run; first on ${failure.first}.`, failure.error);
|
|
143
|
+
}
|
|
140
144
|
}
|
|
141
145
|
/**
|
|
142
146
|
* The reader an Area is indexed as: the Public Area's anonymous visitor, the App's signed-in member who
|
|
@@ -156,7 +160,7 @@ function asIndexingReader(context, area) {
|
|
|
156
160
|
},
|
|
157
161
|
};
|
|
158
162
|
}
|
|
159
|
-
async function indexArea({ area, bridge, credentials, heldFingerprint, }) {
|
|
163
|
+
async function indexArea({ area, bridge, credentials, heldFingerprint, failures, }) {
|
|
160
164
|
const { apiBaseUrl, internalToken, siteKey } = credentials;
|
|
161
165
|
const catalog = resolvePhiCmsDescriptorCatalog(bridge.runtimeModuleCatalog);
|
|
162
166
|
const shellBinding = resolvePhiCmsAreaShellPresetBinding(catalog, area);
|
|
@@ -242,7 +246,7 @@ async function indexArea({ area, bridge, credentials, heldFingerprint, }) {
|
|
|
242
246
|
if (heldFingerprint(areaMask, locale) === fingerprint)
|
|
243
247
|
continue;
|
|
244
248
|
const context = asIndexingReader(await loadPhiSiteRequestContext(siteKey, locale, "", apiBaseUrl, internalToken), area);
|
|
245
|
-
const documents = await readDocuments({ bridge, area, locale, context, candidates, loadPlugin, accessRegistry });
|
|
249
|
+
const documents = await readDocuments({ bridge, area, locale, context, candidates, loadPlugin, accessRegistry, failures });
|
|
246
250
|
const answer = await putPhiSiteSearchIndexSet({
|
|
247
251
|
...credentials,
|
|
248
252
|
area,
|
|
@@ -257,7 +261,7 @@ async function indexArea({ area, bridge, credentials, heldFingerprint, }) {
|
|
|
257
261
|
console.info(`[phis-ui] Search index ${area}/${locale}: ${answer.accepted ? `${answer.state.documentCount} documents written` : "already held"}.`);
|
|
258
262
|
}
|
|
259
263
|
}
|
|
260
|
-
async function readDocuments({ bridge, area, locale, context, candidates, loadPlugin, accessRegistry, }) {
|
|
264
|
+
async function readDocuments({ bridge, area, locale, context, candidates, loadPlugin, accessRegistry, failures, }) {
|
|
261
265
|
const documents = new Array(candidates.length).fill(null);
|
|
262
266
|
let next = 0;
|
|
263
267
|
async function work() {
|
|
@@ -265,7 +269,7 @@ async function readDocuments({ bridge, area, locale, context, candidates, loadPl
|
|
|
265
269
|
const index = next++;
|
|
266
270
|
const path = candidates[index].path;
|
|
267
271
|
try {
|
|
268
|
-
documents[index] = await readDocument({ bridge, area, locale, context, path, loadPlugin, accessRegistry });
|
|
272
|
+
documents[index] = await readDocument({ bridge, area, locale, context, path, loadPlugin, accessRegistry, failures });
|
|
269
273
|
}
|
|
270
274
|
catch (error) {
|
|
271
275
|
console.error(`[phis-ui] The search index could not read ${area}:${path} (${locale}).`, error);
|
|
@@ -284,7 +288,7 @@ async function readDocuments({ bridge, area, locale, context, candidates, loadPl
|
|
|
284
288
|
* -- of the Widgets this reader would see: a Layout or Widget with a narrower policy than the Page's is
|
|
285
289
|
* left out here as the live render leaves it out, so its words never reach a reader it is hidden from.
|
|
286
290
|
*/
|
|
287
|
-
async function readDocument({ bridge, area, locale, context, path, loadPlugin, accessRegistry, }) {
|
|
291
|
+
async function readDocument({ bridge, area, locale, context, path, loadPlugin, accessRegistry, failures, }) {
|
|
288
292
|
const resolved = await resolvePhiCmsLookup({
|
|
289
293
|
bridge,
|
|
290
294
|
area,
|
|
@@ -303,11 +307,12 @@ async function readDocument({ bridge, area, locale, context, path, loadPlugin, a
|
|
|
303
307
|
if (!canPhiViewerAccess(resolved.runtime.viewer, page.accessPolicy))
|
|
304
308
|
return null;
|
|
305
309
|
/*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
* timer after a publish.
|
|
310
|
-
*
|
|
310
|
+
* `searchText` is given the runtime and names it to every helper it reaches (the translation of its
|
|
311
|
+
* texts first of all), so a Widget never depends on a request scope. The scope below is kept for the
|
|
312
|
+
* helpers that still read the request's runtime, since the indexer runs where no request is: at
|
|
313
|
+
* start-up, or on a timer after a publish. A built Site showed this scope not carrying into the
|
|
314
|
+
* Widget's code (the first production index was title and description alone), which is why the
|
|
315
|
+
* runtime is passed and not left to be found.
|
|
311
316
|
*/
|
|
312
317
|
const visible = filterPhiCmsRenderableTreeForViewer({
|
|
313
318
|
tree: resolved.page,
|
|
@@ -333,8 +338,12 @@ async function readDocument({ bridge, area, locale, context, path, loadPlugin, a
|
|
|
333
338
|
collected.push(...await plugin.searchText({ widget, config, runtime: resolved.runtime }));
|
|
334
339
|
}
|
|
335
340
|
catch (error) {
|
|
336
|
-
// One Widget that cannot say its words costs the Page those words, not the Page.
|
|
337
|
-
|
|
341
|
+
// One Widget that cannot say its words costs the Page those words, not the Page; the run names the type once.
|
|
342
|
+
const failure = failures.get(widget.widgetType);
|
|
343
|
+
if (failure)
|
|
344
|
+
failure.pages += 1;
|
|
345
|
+
else
|
|
346
|
+
failures.set(widget.widgetType, { pages: 1, first: `${area}:${path} (${locale})`, error });
|
|
338
347
|
}
|
|
339
348
|
}
|
|
340
349
|
return collected;
|
|
@@ -13,9 +13,10 @@ import type { PhiBlockRuntime } from "../types";
|
|
|
13
13
|
/**
|
|
14
14
|
* The Widget's own words in the reader's language, the way the Widget's render translates them: a
|
|
15
15
|
* Preset's sentence through the platform's store, an author's through the Site's. Empty entries stay
|
|
16
|
-
* in place so the caller can line answers up with what it asked.
|
|
16
|
+
* in place so the caller can line answers up with what it asked. The runtime is the one `searchText`
|
|
17
|
+
* was given and is named to the translation: the index runs where no request scope may be read.
|
|
17
18
|
*/
|
|
18
|
-
export declare function translatePhiSearchTexts(
|
|
19
|
+
export declare function translatePhiSearchTexts(runtime: Pick<PhiBlockRuntime, "site" | "locale">, texts: readonly (string | undefined | null)[], options: {
|
|
19
20
|
translate: boolean;
|
|
20
21
|
textSource?: PhiTextSource;
|
|
21
22
|
}): Promise<string[]>;
|
|
@@ -13,16 +13,17 @@ import { trBulkForLocale, trGlobalBulkForLocale } from "./translate";
|
|
|
13
13
|
/**
|
|
14
14
|
* The Widget's own words in the reader's language, the way the Widget's render translates them: a
|
|
15
15
|
* Preset's sentence through the platform's store, an author's through the Site's. Empty entries stay
|
|
16
|
-
* in place so the caller can line answers up with what it asked.
|
|
16
|
+
* in place so the caller can line answers up with what it asked. The runtime is the one `searchText`
|
|
17
|
+
* was given and is named to the translation: the index runs where no request scope may be read.
|
|
17
18
|
*/
|
|
18
|
-
export async function translatePhiSearchTexts(
|
|
19
|
+
export async function translatePhiSearchTexts(runtime, texts, options) {
|
|
19
20
|
const source = texts.map((text) => (typeof text === "string" ? text.trim() : ""));
|
|
20
21
|
if (!options.translate || !source.some(Boolean)) {
|
|
21
22
|
return source;
|
|
22
23
|
}
|
|
23
24
|
const translated = options.textSource === PHI_TEXT_SOURCE_PRESET
|
|
24
|
-
? await trGlobalBulkForLocale(locale, source)
|
|
25
|
-
: await trBulkForLocale(locale, source);
|
|
25
|
+
? await trGlobalBulkForLocale(runtime.locale.current, source)
|
|
26
|
+
: await trBulkForLocale(runtime.locale.current, source, 0, "text", undefined, runtime);
|
|
26
27
|
return translated.map((text, index) => text || source[index] || "");
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
@@ -35,7 +36,7 @@ export async function translatePhiSearchWidgetTexts(runtime, texts, options) {
|
|
|
35
36
|
if (present.length === 0)
|
|
36
37
|
return [];
|
|
37
38
|
const masked = present.map((text) => maskPhiTextPlaceholders(text, 0));
|
|
38
|
-
const translated = await translatePhiSearchTexts(runtime
|
|
39
|
+
const translated = await translatePhiSearchTexts(runtime, masked.map((entry) => entry.text), options);
|
|
39
40
|
return translated
|
|
40
41
|
.map((text, index) => resolvePhiTextPlaceholders(text, masked[index].names, runtime, []))
|
|
41
42
|
.filter(Boolean);
|
|
@@ -2,8 +2,15 @@ import "server-only";
|
|
|
2
2
|
import { type PhiTranslationParams } from "../helpers/translation-format";
|
|
3
3
|
import { PHI_TR_CTX_WEB_UI_LABEL, type PhiTranslationFormat } from "../gateway/tr";
|
|
4
4
|
import { type PhiTextSource } from "../helpers/text-source";
|
|
5
|
+
import type { PhiBlockRuntime } from "../types";
|
|
5
6
|
export { PHI_TR_CTX_WEB_UI_LABEL };
|
|
6
7
|
export type { PhiTranslationParams } from "../helpers/translation-format";
|
|
8
|
+
/**
|
|
9
|
+
* The part of a runtime a Site's translation needs: whose store answers. A caller that holds the
|
|
10
|
+
* runtime hands it over; one that does not is read from the request scope, which a render has and a
|
|
11
|
+
* background run (the search index) may not.
|
|
12
|
+
*/
|
|
13
|
+
export type PhiTranslationRuntime = Pick<PhiBlockRuntime, "site">;
|
|
7
14
|
export declare function tr(msg: string, params?: PhiTranslationParams, ctx?: string | number, format?: PhiTranslationFormat): Promise<string>;
|
|
8
15
|
export declare function trGlobal(msg: string, params?: PhiTranslationParams, ctx?: string | number, format?: PhiTranslationFormat): Promise<string>;
|
|
9
16
|
/**
|
|
@@ -16,9 +23,13 @@ export declare function trGlobal(msg: string, params?: PhiTranslationParams, ctx
|
|
|
16
23
|
export declare function trWidgetText(locale: string | undefined, msg: string, textSource: PhiTextSource | undefined): Promise<string>;
|
|
17
24
|
export declare function trForLocale(localeInput: string, msg: string, params?: PhiTranslationParams, ctx?: string | number, format?: PhiTranslationFormat,
|
|
18
25
|
/** The language `msg` is written in, when it is not the Site's own -- a Module's text. */
|
|
19
|
-
sourceLocale?: string
|
|
26
|
+
sourceLocale?: string,
|
|
27
|
+
/** The runtime the caller holds; without it the request's is read. */
|
|
28
|
+
runtime?: PhiTranslationRuntime): Promise<string>;
|
|
20
29
|
export declare function trGlobalForLocale(localeInput: string, msg: string, params?: PhiTranslationParams, ctx?: string | number, format?: PhiTranslationFormat): Promise<string>;
|
|
21
30
|
export declare function trBulk(msgs: string[], ctx?: string | number, format?: PhiTranslationFormat, sourceLocale?: string): Promise<string[]>;
|
|
22
|
-
export declare function trBulkForLocale(localeInput: string, msgs: string[], ctx?: string | number, format?: PhiTranslationFormat, sourceLocale?: string
|
|
31
|
+
export declare function trBulkForLocale(localeInput: string, msgs: string[], ctx?: string | number, format?: PhiTranslationFormat, sourceLocale?: string,
|
|
32
|
+
/** The runtime the caller holds; without it the request's is read. */
|
|
33
|
+
runtime?: PhiTranslationRuntime): Promise<string[]>;
|
|
23
34
|
export declare function trGlobalBulk(msgs: string[], ctx?: string | number, format?: PhiTranslationFormat): Promise<string[]>;
|
|
24
35
|
export declare function trGlobalBulkForLocale(localeInput: string, msgs: string[], ctx?: string | number, format?: PhiTranslationFormat): Promise<string[]>;
|
|
@@ -8,8 +8,8 @@ import { resolvePhiRequestLocale } from "./request-locale";
|
|
|
8
8
|
import { readPhiServerApiCredentials } from "../helpers/phis-server-credentials";
|
|
9
9
|
import { PHI_TEXT_SOURCE_PRESET } from "../helpers/text-source";
|
|
10
10
|
export { PHI_TR_CTX_WEB_UI_LABEL };
|
|
11
|
-
function buildTranslatorOptions(locale, sourceLocale) {
|
|
12
|
-
const requestRuntime = getPhiRequestRuntime();
|
|
11
|
+
function buildTranslatorOptions(locale, sourceLocale, runtime) {
|
|
12
|
+
const requestRuntime = runtime ?? getPhiRequestRuntime();
|
|
13
13
|
const resolvedRuntime = resolvePhiRuntimeConfig({
|
|
14
14
|
apiBaseUrl: readPhiServerApiCredentials().apiBaseUrl,
|
|
15
15
|
internalToken: readPhiServerApiCredentials().internalToken,
|
|
@@ -69,13 +69,15 @@ function normalizeMessages(msgs) {
|
|
|
69
69
|
}
|
|
70
70
|
export async function trForLocale(localeInput, msg, params = 0, ctx = 0, format = "text",
|
|
71
71
|
/** The language `msg` is written in, when it is not the Site's own -- a Module's text. */
|
|
72
|
-
sourceLocale
|
|
72
|
+
sourceLocale,
|
|
73
|
+
/** The runtime the caller holds; without it the request's is read. */
|
|
74
|
+
runtime) {
|
|
73
75
|
const normalizedMessage = msg.trim();
|
|
74
76
|
if (!normalizedMessage) {
|
|
75
77
|
return "";
|
|
76
78
|
}
|
|
77
79
|
const locale = resolvePhiTranslationLocale(localeInput);
|
|
78
|
-
const options = buildTranslatorOptions(locale, sourceLocale);
|
|
80
|
+
const options = buildTranslatorOptions(locale, sourceLocale, runtime);
|
|
79
81
|
const translated = await requestInternalTranslation(options, normalizedMessage, undefined, ctx ? String(ctx) : undefined, format);
|
|
80
82
|
return formatPhiTranslation(translated, params);
|
|
81
83
|
}
|
|
@@ -96,13 +98,15 @@ export async function trBulk(msgs, ctx = 0, format = "text", sourceLocale) {
|
|
|
96
98
|
const locale = await resolvePhiRequestLocale();
|
|
97
99
|
return trBulkForLocale(locale, msgs, ctx, format, sourceLocale);
|
|
98
100
|
}
|
|
99
|
-
export async function trBulkForLocale(localeInput, msgs, ctx = 0, format = "text", sourceLocale
|
|
101
|
+
export async function trBulkForLocale(localeInput, msgs, ctx = 0, format = "text", sourceLocale,
|
|
102
|
+
/** The runtime the caller holds; without it the request's is read. */
|
|
103
|
+
runtime) {
|
|
100
104
|
const normalizedMessages = normalizeMessages(msgs);
|
|
101
105
|
if (!normalizedMessages.some(Boolean)) {
|
|
102
106
|
return normalizedMessages;
|
|
103
107
|
}
|
|
104
108
|
const locale = resolvePhiTranslationLocale(localeInput);
|
|
105
|
-
const options = buildTranslatorOptions(locale, sourceLocale);
|
|
109
|
+
const options = buildTranslatorOptions(locale, sourceLocale, runtime);
|
|
106
110
|
return requestInternalTranslationBulk(options, normalizedMessages, ctx ? String(ctx) : undefined, format);
|
|
107
111
|
}
|
|
108
112
|
export async function trGlobalBulk(msgs, ctx = 0, format = "text") {
|
|
@@ -6,6 +6,12 @@ export type PhiThemeSignetPicture = {
|
|
|
6
6
|
} | {
|
|
7
7
|
kind: "asset";
|
|
8
8
|
assetId: number;
|
|
9
|
+
/** The Asset's revision, read from the delivered address the Core resolved (`?r=<revision>`). */
|
|
10
|
+
revision?: number;
|
|
11
|
+
/** The picture's media type and size as the Core states them, where it does. */
|
|
12
|
+
contentType?: string;
|
|
13
|
+
width?: number;
|
|
14
|
+
height?: number;
|
|
9
15
|
};
|
|
10
16
|
/**
|
|
11
17
|
* The Signet a Site wears, and whose it is: `site` where the record states it (a save made it the
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
/** A media type the head may state: an image type as the Core writes it, nothing with parameters. */
|
|
2
|
+
const PHI_SIGNET_CONTENT_TYPE = /^image\/[a-z0-9][a-z0-9.+-]*$/u;
|
|
3
|
+
function isPositiveInteger(value) {
|
|
4
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The revision in the address the Core delivers an Asset at, `/api/site/media/<id>/content?r=<revision>`.
|
|
8
|
+
* Only that address for this Asset counts: anything else (a path elsewhere, another id, a missing or
|
|
9
|
+
* non-numeric `r`) states no revision, and the Signet is named as it was before the Core wrote one.
|
|
10
|
+
*/
|
|
11
|
+
function readPhiSignetAssetRevision(url, assetId) {
|
|
12
|
+
if (typeof url !== "string")
|
|
13
|
+
return null;
|
|
14
|
+
let parsed;
|
|
15
|
+
try {
|
|
16
|
+
parsed = new URL(url, "http://signet.invalid");
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
if (parsed.origin !== "http://signet.invalid" || parsed.pathname !== `/api/site/media/${assetId}/content`)
|
|
22
|
+
return null;
|
|
23
|
+
const revision = parsed.searchParams.get("r");
|
|
24
|
+
return revision !== null && /^\d{1,15}$/u.test(revision) ? Number(revision) : null;
|
|
25
|
+
}
|
|
1
26
|
/**
|
|
2
27
|
* The Signet the record itself states, and nothing else.
|
|
3
28
|
*
|
|
@@ -8,7 +33,18 @@
|
|
|
8
33
|
*/
|
|
9
34
|
export function readPhiThemeSiteSignet(authored) {
|
|
10
35
|
if (authored?.sourceKind === "asset" && Number.isInteger(authored.assetId) && authored.assetId > 0) {
|
|
11
|
-
|
|
36
|
+
const revision = readPhiSignetAssetRevision(authored.url, authored.assetId);
|
|
37
|
+
const contentType = typeof authored.contentType === "string" && PHI_SIGNET_CONTENT_TYPE.test(authored.contentType)
|
|
38
|
+
? authored.contentType
|
|
39
|
+
: null;
|
|
40
|
+
const sized = isPositiveInteger(authored.width) && isPositiveInteger(authored.height);
|
|
41
|
+
return {
|
|
42
|
+
kind: "asset",
|
|
43
|
+
assetId: authored.assetId,
|
|
44
|
+
...(revision != null ? { revision } : {}),
|
|
45
|
+
...(contentType ? { contentType } : {}),
|
|
46
|
+
...(sized ? { width: authored.width, height: authored.height } : {}),
|
|
47
|
+
};
|
|
12
48
|
}
|
|
13
49
|
if (authored?.sourceKind === "url" && typeof authored.sourceUrl === "string" && authored.sourceUrl.startsWith("data:image/")) {
|
|
14
50
|
return { kind: "data", source: authored.sourceUrl };
|
package/theme/phi-tokens.d.ts
CHANGED
package/theme/phi-tokens.js
CHANGED
|
@@ -60,8 +60,12 @@ export const PHI_RADII = {
|
|
|
60
60
|
xl: 55,
|
|
61
61
|
xxl: 89,
|
|
62
62
|
};
|
|
63
|
+
/*
|
|
64
|
+
* The Fibonacci row 21, 34, 55. A single-line field is as high as the Button of its size, so the small 21
|
|
65
|
+
* is the height that carries the small text (13).
|
|
66
|
+
*/
|
|
63
67
|
export const PHI_CONTROL_HEIGHTS = {
|
|
64
|
-
sm:
|
|
68
|
+
sm: 21,
|
|
65
69
|
md: 34,
|
|
66
70
|
lg: 55,
|
|
67
71
|
};
|
package/types/cms-plugins.d.ts
CHANGED
|
@@ -549,7 +549,8 @@ export type PhiCmsWidgetPlugin<TConfig> = {
|
|
|
549
549
|
* answers the text as the reader sees it -- translated for `runtime.locale`, with the Page's values
|
|
550
550
|
* filled in -- and nothing a reader does not see. A Widget without it contributes no text, which is
|
|
551
551
|
* right for a picture, a form or a navigation; a Widget that draws words a visitor would search for
|
|
552
|
-
* says them here, in reading order, one entry per line or paragraph.
|
|
552
|
+
* says them here, in reading order, one entry per line or paragraph. It runs outside a request, so it
|
|
553
|
+
* uses the `runtime` it is given and passes it to what it calls, never the request's scope.
|
|
553
554
|
*/
|
|
554
555
|
searchText?: PhiBivariantCallback<[
|
|
555
556
|
PhiCmsWidgetSearchTextArgs<TConfig>
|
|
@@ -613,6 +614,13 @@ export type PhiCmsRuntimeRenderRegistry = {
|
|
|
613
614
|
ownerModuleIdByLayoutType: ReadonlyMap<string, PhiRuntimeModuleId>;
|
|
614
615
|
/** The used Modules whose catalog entry says they bring a UI provider through their Client half. */
|
|
615
616
|
uiProviderModuleIds: ReadonlySet<PhiRuntimeModuleId>;
|
|
617
|
+
/** The Modules active in this Area. */
|
|
618
|
+
activeModuleIds: ReadonlySet<PhiRuntimeModuleId>;
|
|
619
|
+
/**
|
|
620
|
+
* Which installed Module owns each Form field type, active here or not. A Form widget mounts the field
|
|
621
|
+
* Providers of the active owners its Form uses, and marks the fields of the others as unavailable.
|
|
622
|
+
*/
|
|
623
|
+
ownerModuleIdByFormFieldTypeKey: ReadonlyMap<PhiFormProviderKey, PhiRuntimeModuleId>;
|
|
616
624
|
/**
|
|
617
625
|
* How to ask each active Module for the facts it publishes, by the namespace it publishes them under.
|
|
618
626
|
*
|
|
@@ -1129,6 +1137,7 @@ export type PhiResolvedRuntimeModuleSet = {
|
|
|
1129
1137
|
platformModuleId: PhiRuntimeModuleId;
|
|
1130
1138
|
installedOwnerModuleIdByWidgetType: ReadonlyMap<string, PhiRuntimeModuleId>;
|
|
1131
1139
|
installedOwnerModuleIdByLayoutType: ReadonlyMap<string, PhiRuntimeModuleId>;
|
|
1140
|
+
installedOwnerModuleIdByFormFieldTypeKey: ReadonlyMap<PhiFormProviderKey, PhiRuntimeModuleId>;
|
|
1132
1141
|
ownerModuleIdByControllerType: ReadonlyMap<string, PhiRuntimeModuleId>;
|
|
1133
1142
|
areaControllerSettings: readonly PhiRuntimeControllerSetting[];
|
|
1134
1143
|
};
|
package/types/site-theme.d.ts
CHANGED
|
@@ -113,8 +113,20 @@ export type PhiSiteThemeBrandLogo = {
|
|
|
113
113
|
* Set that has none. `url` is the state before a save takes the picture into the Media library (a data
|
|
114
114
|
* URL, a Set's own Signet); an `asset` is the state after.
|
|
115
115
|
*/
|
|
116
|
-
export type PhiSiteThemeBrandSignet =
|
|
117
|
-
sourceKind: "
|
|
116
|
+
export type PhiSiteThemeBrandSignet = (Extract<PhiSiteThemeBrandLogo, {
|
|
117
|
+
sourceKind: "asset";
|
|
118
|
+
}> & {
|
|
119
|
+
/**
|
|
120
|
+
* What the Core states about the Asset when it resolves the Site config (Core 0.4.1): `url` carries the
|
|
121
|
+
* delivered address with the Asset's revision (`?r=<revision>`), and the type and size of the picture
|
|
122
|
+
* are stated beside it. All absent from a record an older Core resolved, or one a draft carries; the
|
|
123
|
+
* head and the route then fall back to what the id alone says.
|
|
124
|
+
*/
|
|
125
|
+
contentType?: string | null;
|
|
126
|
+
width?: number | null;
|
|
127
|
+
height?: number | null;
|
|
128
|
+
}) | Extract<PhiSiteThemeBrandLogo, {
|
|
129
|
+
sourceKind: "url";
|
|
118
130
|
}>;
|
|
119
131
|
export type PhiSiteThemeBrandLogos = {
|
|
120
132
|
light?: PhiSiteThemeBrandLogo | null;
|