@phis/ui 0.8.1 → 0.8.2

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 (77) hide show
  1. package/README.md +9 -2
  2. package/components/controls/phi-table-control.js +3 -3
  3. package/components/media/media-upload-flow.d.ts +62 -5
  4. package/components/media/media-upload-flow.js +62 -24
  5. package/components/media/phi-area-upload-widget.d.ts +44 -1
  6. package/components/media/phi-area-upload-widget.js +32 -7
  7. package/components/media/phi-media-upload.d.ts +10 -3
  8. package/components/media/phi-media-upload.js +11 -8
  9. package/components/shell/phi-widget-icon.js +1 -0
  10. package/components/widgets/client/html-editor-link-node.d.ts +12 -0
  11. package/components/widgets/client/html-editor-link-node.js +60 -0
  12. package/components/widgets/client/html-editor.js +10 -6
  13. package/components/widgets/client/shared/phi-collection-view-binding.js +33 -26
  14. package/constants/cms-widget-types.d.ts +1 -0
  15. package/constants/cms-widget-types.js +3 -0
  16. package/constants/runtime-module-ownership.js +1 -0
  17. package/gateway/site-proxy.d.ts +12 -0
  18. package/gateway/site-proxy.js +20 -0
  19. package/net/phi-next-proxy.d.ts +7 -0
  20. package/net/phi-next-proxy.js +1 -1
  21. package/package.json +27 -14
  22. package/plugins/runtime-modules/area-contributions/admin.d.ts +1 -1
  23. package/plugins/runtime-modules/area-contributions/admin.js +2 -0
  24. package/plugins/runtime-modules/avatar/addresses.d.ts +1 -1
  25. package/plugins/runtime-modules/cdn/authoring-widgets.d.ts +3 -0
  26. package/plugins/runtime-modules/cdn/authoring-widgets.js +7 -0
  27. package/plugins/runtime-modules/cdn/authoring.d.ts +1 -0
  28. package/plugins/runtime-modules/cdn/authoring.js +8 -0
  29. package/plugins/runtime-modules/cdn/bytes.d.ts +5 -0
  30. package/plugins/runtime-modules/cdn/bytes.js +17 -0
  31. package/plugins/runtime-modules/cdn/client-data-providers.d.ts +7 -0
  32. package/plugins/runtime-modules/cdn/client-data-providers.js +9 -0
  33. package/plugins/runtime-modules/cdn/data-providers.d.ts +134 -0
  34. package/plugins/runtime-modules/cdn/data-providers.js +117 -0
  35. package/plugins/runtime-modules/cdn/definition.d.ts +140 -0
  36. package/plugins/runtime-modules/cdn/definition.js +23 -0
  37. package/plugins/runtime-modules/cdn/ids.d.ts +18 -0
  38. package/plugins/runtime-modules/cdn/ids.js +20 -0
  39. package/plugins/runtime-modules/cdn/module.d.ts +131 -0
  40. package/plugins/runtime-modules/cdn/module.js +4 -0
  41. package/plugins/runtime-modules/cdn/platform.d.ts +25 -0
  42. package/plugins/runtime-modules/cdn/platform.js +73 -0
  43. package/plugins/runtime-modules/cdn/presets.d.ts +2 -0
  44. package/plugins/runtime-modules/cdn/presets.js +20 -0
  45. package/plugins/runtime-modules/cdn/server.d.ts +1 -0
  46. package/plugins/runtime-modules/cdn/server.js +14 -0
  47. package/plugins/runtime-modules/cdn/services/table.d.ts +11 -0
  48. package/plugins/runtime-modules/cdn/services/table.js +296 -0
  49. package/plugins/runtime-modules/cdn/services/upload.d.ts +20 -0
  50. package/plugins/runtime-modules/cdn/services/upload.js +146 -0
  51. package/plugins/runtime-modules/cdn/table-params.d.ts +10 -0
  52. package/plugins/runtime-modules/cdn/table-params.js +10 -0
  53. package/plugins/runtime-modules/cdn/trees/admin-cdn-label-set.d.ts +95 -0
  54. package/plugins/runtime-modules/cdn/trees/admin-cdn-label-set.js +156 -0
  55. package/plugins/runtime-modules/cdn/trees/phi-default-admin-cdn-page-tree.d.ts +18 -0
  56. package/plugins/runtime-modules/cdn/trees/phi-default-admin-cdn-page-tree.js +479 -0
  57. package/plugins/runtime-modules/cdn/widgets/upload/client.d.ts +12 -0
  58. package/plugins/runtime-modules/cdn/widgets/upload/client.js +138 -0
  59. package/plugins/runtime-modules/cdn/widgets/upload/config.d.ts +29 -0
  60. package/plugins/runtime-modules/cdn/widgets/upload/config.js +43 -0
  61. package/plugins/runtime-modules/cdn/widgets/upload/label-types.d.ts +24 -0
  62. package/plugins/runtime-modules/cdn/widgets/upload/label-types.js +1 -0
  63. package/plugins/runtime-modules/cdn/widgets/upload/labels.d.ts +4 -0
  64. package/plugins/runtime-modules/cdn/widgets/upload/labels.js +72 -0
  65. package/plugins/runtime-modules/cdn/widgets/upload/plugin.d.ts +3 -0
  66. package/plugins/runtime-modules/cdn/widgets/upload/plugin.js +7 -0
  67. package/plugins/runtime-modules/cdn/widgets/upload/server.d.ts +8 -0
  68. package/plugins/runtime-modules/cdn/widgets/upload/server.js +17 -0
  69. package/plugins/runtime-modules/cdn/widgets.d.ts +2 -0
  70. package/plugins/runtime-modules/cdn/widgets.js +13 -0
  71. package/plugins/runtime-modules/client-authoring-providers/admin.d.ts +1 -1
  72. package/plugins/runtime-modules/client-authoring-providers/admin.js +6 -0
  73. package/plugins/runtime-modules/client-manifests/admin.js +11 -1
  74. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +1 -1
  75. package/plugins/runtime-modules/core/widgets/collection-view/site-address-binding.js +3 -1
  76. package/plugins/runtime-modules/core/widgets/table/client.js +6 -4
  77. package/types/table-widget.d.ts +2 -2
@@ -0,0 +1,12 @@
1
+ import type { PhiAreaUploadWidgetLabels } from "../../../../../components/media/media-widget-labels";
2
+ import type { PhiCdnUploadWidgetConfig } from "./config";
3
+ import type { PhiCdnUploadWidgetLabels } from "./label-types";
4
+ /** What is wrong with one segment as the person typed it, before Core is asked; null where nothing is. */
5
+ export declare function readPhiCdnSegmentProblem(value: string, kind: "name" | "version" | "fileName", labels: Pick<PhiCdnUploadWidgetLabels, "required" | "invalidSegment" | "invalidVersion" | "reservedName">): string | null;
6
+ export type PhiCdnUploadWidgetClientProps = {
7
+ config?: PhiCdnUploadWidgetConfig;
8
+ labels: PhiCdnUploadWidgetLabels;
9
+ /** The Media upload surface's own words. */
10
+ uploadLabels: PhiAreaUploadWidgetLabels;
11
+ };
12
+ export declare function PhiCdnUploadWidgetClient({ config, labels, uploadLabels }: PhiCdnUploadWidgetClientProps): import("react").JSX.Element;
@@ -0,0 +1,138 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
4
+ import { PHIS_CDN_KEY_SEGMENT_PATTERN, PHIS_CDN_KEY_VERSION_PATTERN, } from "@phis/contracts/addon";
5
+ import { PhiCheckboxGroupControl } from "../../../../../components/controls/phi-checkbox-group-control";
6
+ import { PhiFlexControl } from "../../../../../components/controls/phi-flex-control";
7
+ import { PhiLabeledControl } from "../../../../../components/controls/phi-labeled-control";
8
+ import { PhiSelectControl } from "../../../../../components/controls/phi-select-control";
9
+ import { PhiTextControl } from "../../../../../components/controls/phi-text-control";
10
+ import { PhiAreaUploadBinding, } from "../../../../../components/media/phi-area-upload-widget";
11
+ import { PhiMediaUploadError, runPhiUploadSession, } from "../../../../../components/media/media-upload-flow";
12
+ import { emitPhiSignalCapability, usePhiSignalEmitter, } from "../../../../../components/runtime/runtime-signal-identity";
13
+ import { PHI_CDN_ARCH_KEYS, PHI_CDN_OS_KEYS, guessPhiCdnPlatform, readPhiCdnArchKeys, readPhiCdnOsKeys, writePhiCdnArchBits, writePhiCdnOsBits, } from "../../platform";
14
+ import { PHI_CDN_UPLOAD_DISCARD, createPhiCdnUploadTarget, loadPhiCdnNames, } from "../../services/upload";
15
+ const EMPTY_DRAFT = { name: "", version: "", fileName: "", os: [], arch: [] };
16
+ /** The three text fields as wide as the dialog, the label beside each (`PhiLabeledControl`'s `fill`). */
17
+ const FIELD_STYLE = { width: "100%" };
18
+ /*
19
+ * What a file was last started with, remembered in this browser by the file's name, size and date, so
20
+ * picking the same file after a reload fills the fields it was started with -- the same key, size and
21
+ * digests are what make Core answer with the open session and its parts. A convenience of this browser
22
+ * only; without storage the fields start from the file name as usual.
23
+ */
24
+ const DRAFT_STORAGE_KEY = "phi-cdn-upload-drafts";
25
+ function fileIdentity(file) {
26
+ return `${file.name}:${file.size}:${file.lastModified}`;
27
+ }
28
+ function readStoredDraft(file) {
29
+ try {
30
+ const stored = JSON.parse(window.localStorage.getItem(DRAFT_STORAGE_KEY) ?? "{}");
31
+ return stored[fileIdentity(file)] ?? null;
32
+ }
33
+ catch {
34
+ return null;
35
+ }
36
+ }
37
+ function storeDraft(file, draft) {
38
+ try {
39
+ const stored = JSON.parse(window.localStorage.getItem(DRAFT_STORAGE_KEY) ?? "{}");
40
+ if (draft)
41
+ stored[fileIdentity(file)] = draft;
42
+ else
43
+ delete stored[fileIdentity(file)];
44
+ window.localStorage.setItem(DRAFT_STORAGE_KEY, JSON.stringify(stored));
45
+ }
46
+ catch {
47
+ // Storage refused: nothing is remembered, and the upload is not affected.
48
+ }
49
+ }
50
+ function draftFromFile(file, name) {
51
+ const platform = guessPhiCdnPlatform(file.name);
52
+ return {
53
+ name,
54
+ version: "",
55
+ fileName: file.name,
56
+ os: readPhiCdnOsKeys(platform.os),
57
+ arch: readPhiCdnArchKeys(platform.arch),
58
+ };
59
+ }
60
+ /** What is wrong with one segment as the person typed it, before Core is asked; null where nothing is. */
61
+ export function readPhiCdnSegmentProblem(value, kind, labels) {
62
+ const trimmed = value.trim();
63
+ if (!trimmed)
64
+ return labels.required;
65
+ if (kind === "version")
66
+ return PHIS_CDN_KEY_VERSION_PATTERN.test(trimmed) ? null : labels.invalidVersion;
67
+ if (!PHIS_CDN_KEY_SEGMENT_PATTERN.test(trimmed))
68
+ return labels.invalidSegment;
69
+ return kind === "name" && trimmed === "api" ? labels.reservedName : null;
70
+ }
71
+ export function PhiCdnUploadWidgetClient({ config, labels, uploadLabels }) {
72
+ const emitRoutes = useMemo(() => config?.signalRoutes?.emits ?? [], [config?.signalRoutes?.emits]);
73
+ const emitSignal = usePhiSignalEmitter();
74
+ const [names, setNames] = useState([]);
75
+ const [draft, setDraft] = useState(EMPTY_DRAFT);
76
+ // The draft the runner sends with, read when it starts rather than captured when it was made.
77
+ const draftRef = useRef(draft);
78
+ useEffect(() => {
79
+ draftRef.current = draft;
80
+ }, [draft]);
81
+ useEffect(() => {
82
+ const abort = new AbortController();
83
+ void loadPhiCdnNames(abort.signal).then(setNames, () => undefined);
84
+ return () => abort.abort();
85
+ }, []);
86
+ const problems = {
87
+ name: readPhiCdnSegmentProblem(draft.name, "name", labels),
88
+ version: readPhiCdnSegmentProblem(draft.version, "version", labels),
89
+ fileName: readPhiCdnSegmentProblem(draft.fileName, "fileName", labels),
90
+ };
91
+ const runSession = useCallback(async (file, onProgress, _options, signal, onPhase) => {
92
+ const current = draftRef.current;
93
+ const input = {
94
+ name: current.name.trim(),
95
+ version: current.version.trim(),
96
+ fileName: current.fileName.trim(),
97
+ os: writePhiCdnOsBits(current.os),
98
+ arch: writePhiCdnArchBits(current.arch),
99
+ };
100
+ storeDraft(file, { ...current, name: input.name, version: input.version, fileName: input.fileName });
101
+ try {
102
+ const published = await runPhiUploadSession(createPhiCdnUploadTarget(input), file, {
103
+ ...(onProgress ? { onProgress } : {}),
104
+ ...(onPhase ? { onPhase } : {}),
105
+ ...(signal ? { signal } : {}),
106
+ });
107
+ storeDraft(file, null);
108
+ return { asset: published };
109
+ }
110
+ catch (error) {
111
+ if (signal?.aborted && signal.reason === PHI_CDN_UPLOAD_DISCARD)
112
+ storeDraft(file, null);
113
+ throw error;
114
+ }
115
+ }, []);
116
+ const moduleTarget = useMemo(() => ({
117
+ ready: !problems.name && !problems.version && !problems.fileName,
118
+ startLabel: labels.start,
119
+ cancelLabel: labels.cancel,
120
+ cancelReason: PHI_CDN_UPLOAD_DISCARD,
121
+ phaseLabels: { checksum: labels.steps.checksum, finish: labels.steps.verify },
122
+ runSession,
123
+ readError: (error) => {
124
+ if (error instanceof PhiMediaUploadError && error.code === "checksum-unavailable")
125
+ return labels.checksumUnavailable;
126
+ // Core words its refusals for a person (`{ error, message }`); a transport failure says what failed.
127
+ return error instanceof PhiMediaUploadError && error.message ? error.message : null;
128
+ },
129
+ onFilePicked: (file) => setDraft((previous) => readStoredDraft(file) ?? draftFromFile(file, previous.name)),
130
+ onUploaded: () => {
131
+ setDraft(EMPTY_DRAFT);
132
+ void loadPhiCdnNames().then(setNames, () => undefined);
133
+ emitPhiSignalCapability(emitSignal, emitRoutes, "uploaded", null);
134
+ },
135
+ renderFields: ({ file, uploading }) => (_jsxs(PhiFlexControl, { vertical: true, gap: 12, children: [_jsx(PhiSelectControl, { label: labels.name, description: (file && problems.name) || labels.nameHint, presentation: "autocomplete", allowCustom: true, style: FIELD_STYLE, value: draft.name, options: names.map((name) => ({ value: name, label: name })), disabled: uploading, onChange: (name) => setDraft((previous) => ({ ...previous, name: typeof name === "string" ? name : "" })) }), _jsx(PhiTextControl, { label: labels.version, style: FIELD_STYLE, description: (file && problems.version) || undefined, value: draft.version, disabled: uploading, onChange: (version) => setDraft((previous) => ({ ...previous, version: version ?? "" })) }), _jsx(PhiTextControl, { label: labels.fileFileName, style: FIELD_STYLE, description: (file && problems.fileName) || undefined, value: draft.fileName, disabled: uploading || !file, onChange: (fileName) => setDraft((previous) => ({ ...previous, fileName: fileName ?? "" })) }), _jsx(PhiLabeledControl, { label: labels.os, children: _jsx(PhiCheckboxGroupControl, { value: draft.os, options: PHI_CDN_OS_KEYS.map(([key]) => ({ value: key, label: labels.osNames[key] })), disabled: uploading, onChange: (os) => setDraft((previous) => ({ ...previous, os: [...os] })) }) }), _jsx(PhiLabeledControl, { label: labels.arch, children: _jsx(PhiCheckboxGroupControl, { value: draft.arch, options: PHI_CDN_ARCH_KEYS.map(([key]) => ({ value: key, label: labels.archNames[key] })), disabled: uploading, onChange: (arch) => setDraft((previous) => ({ ...previous, arch: [...arch] })) }) })] })),
136
+ }), [draft, emitRoutes, emitSignal, labels, names, problems.fileName, problems.name, problems.version, runSession]);
137
+ return (_jsx(PhiAreaUploadBinding, { labels: uploadLabels, showFinished: false, config: { allowDelete: false, multiple: false, accept: "*/*" }, moduleTarget: moduleTarget }));
138
+ }
@@ -0,0 +1,29 @@
1
+ import { type PhiSignalRouteSet } from "../../../../../types/signals";
2
+ import { type PhiCmsWidgetConfigBase } from "../../../../../widget-config";
3
+ export declare const PHI_CDN_UPLOAD_WIDGET_TYPE: string;
4
+ export type PhiCdnUploadWidgetConfig = PhiCmsWidgetConfigBase & {
5
+ signalRoutes?: PhiSignalRouteSet | null;
6
+ };
7
+ declare function parsePhiCdnUploadWidgetConfig(config: Record<string, unknown>): PhiCdnUploadWidgetConfig;
8
+ export declare const PHI_CDN_UPLOAD_WIDGET_DEFINITION: {
9
+ kind: "widget";
10
+ pluginKey: string;
11
+ typeKey: string;
12
+ slotSizePolicy: "fill-inline";
13
+ title: string;
14
+ category: "media";
15
+ description: string;
16
+ iconFamily: string;
17
+ fields: never[];
18
+ defaultConfig: {};
19
+ parseConfig: typeof parsePhiCdnUploadWidgetConfig;
20
+ runtimeSignals: {
21
+ emits: {
22
+ id: string;
23
+ action: "activate";
24
+ valueType: "none";
25
+ }[];
26
+ listens: never[];
27
+ };
28
+ };
29
+ export {};
@@ -0,0 +1,43 @@
1
+ import { buildPhiCmsWidgetNamespacedTypeKey, resolvePhiCmsWidgetPluginKey, } from "../../../../../constants/cms-widget-types";
2
+ import { readPhiSignalRouteSet } from "../../../../../types/signals";
3
+ import { readRenderableBlockConfig, } from "../../../../../widget-config";
4
+ /**
5
+ * A file put into the Site's CDN from the browser: its name, version and file name, the platform it is
6
+ * for, and the upload itself -- the parts hashed and sent through Core, resumed where a reload broke
7
+ * them off.
8
+ *
9
+ * A Widget because nothing else can hold it. A Form submits values through a handler on the server
10
+ * (FORMS.md), and this is bytes that exist only on the person's computer, divided, hashed and sent
11
+ * before there is anything to submit; the Media `upload` field sends a file into a Media Space, which
12
+ * the CDN is not. So the dialog of the CDN page holds this, and it says nothing but what an upload
13
+ * needs: no settings, and one announcement, `uploaded`, when a file was published.
14
+ */
15
+ const PHI_CDN_UPLOAD_WIDGET_TYPE_KEY = "cdn-upload";
16
+ const PHI_CDN_UPLOAD_WIDGET_PLUGIN_KEY = resolvePhiCmsWidgetPluginKey(PHI_CDN_UPLOAD_WIDGET_TYPE_KEY);
17
+ export const PHI_CDN_UPLOAD_WIDGET_TYPE = buildPhiCmsWidgetNamespacedTypeKey(PHI_CDN_UPLOAD_WIDGET_PLUGIN_KEY, PHI_CDN_UPLOAD_WIDGET_TYPE_KEY);
18
+ function parsePhiCdnUploadWidgetConfig(config) {
19
+ return {
20
+ ...readRenderableBlockConfig(config),
21
+ signalRoutes: readPhiSignalRouteSet(config.signalRoutes),
22
+ };
23
+ }
24
+ export const PHI_CDN_UPLOAD_WIDGET_DEFINITION = {
25
+ kind: "widget",
26
+ pluginKey: PHI_CDN_UPLOAD_WIDGET_PLUGIN_KEY,
27
+ typeKey: PHI_CDN_UPLOAD_WIDGET_TYPE_KEY,
28
+ slotSizePolicy: "fill-inline",
29
+ title: "CDN upload",
30
+ category: "media",
31
+ description: "Uploads one file into the Site's CDN under a name, a version and a file name.",
32
+ iconFamily: "cdn",
33
+ fields: [],
34
+ defaultConfig: {},
35
+ parseConfig: parsePhiCdnUploadWidgetConfig,
36
+ runtimeSignals: {
37
+ emits: [
38
+ // So the listing can read itself again. Sent once a file is published, never for a refusal.
39
+ { id: "uploaded", action: "activate", valueType: "none" },
40
+ ],
41
+ listens: [],
42
+ },
43
+ };
@@ -0,0 +1,24 @@
1
+ import type { PhiCdnArchKey, PhiCdnOsKey } from "../../platform";
2
+ /** The CDN's own words of its upload, as its server half reads them in the page's language. */
3
+ export type PhiCdnUploadWidgetLabels = {
4
+ name: string;
5
+ nameHint: string;
6
+ version: string;
7
+ fileFileName: string;
8
+ os: string;
9
+ arch: string;
10
+ osNames: Readonly<Record<PhiCdnOsKey, string>>;
11
+ archNames: Readonly<Record<PhiCdnArchKey, string>>;
12
+ /** What the file's tag says while it is hashed and while Core hashes it whole. */
13
+ steps: {
14
+ checksum: string;
15
+ verify: string;
16
+ };
17
+ start: string;
18
+ cancel: string;
19
+ required: string;
20
+ invalidSegment: string;
21
+ invalidVersion: string;
22
+ reservedName: string;
23
+ checksumUnavailable: string;
24
+ };
@@ -0,0 +1,4 @@
1
+ import "server-only";
2
+ import { type PhiGlobalTranslatorOptions } from "../../../../../gateway/tr";
3
+ import type { PhiCdnUploadWidgetLabels } from "./label-types";
4
+ export declare function getPhiCdnUploadWidgetLabels(options: PhiGlobalTranslatorOptions): Promise<PhiCdnUploadWidgetLabels>;
@@ -0,0 +1,72 @@
1
+ import "server-only";
2
+ import { PHI_TR_CTX_WEB_UI_LABEL } from "../../../../../gateway/tr";
3
+ import { definePhiRuntimeModuleLabelSet, definePhiMessageLabel, getPhiLabelSet } from "../../../../../gateway/label-set";
4
+ import { PHI_CDN_RUNTIME_MODULE_IDENTITY } from "../../ids";
5
+ const PHI_CDN_UPLOAD_WIDGET_LABEL_SET = definePhiRuntimeModuleLabelSet(PHI_CDN_RUNTIME_MODULE_IDENTITY, {
6
+ key: "widget:cdn-upload",
7
+ ctx: PHI_TR_CTX_WEB_UI_LABEL,
8
+ labels: {
9
+ name: "Name",
10
+ name_hint: definePhiMessageLabel("What the file belongs to, the first part of its address: pick a name the CDN holds or type a new one."),
11
+ version: "Version",
12
+ file_file_name: "File name",
13
+ os: "Operating systems",
14
+ arch: "Architectures",
15
+ os_linux: "Linux",
16
+ os_windows: "Windows",
17
+ os_macos: "macOS",
18
+ os_android: "Android",
19
+ os_ios: "iOS and iPadOS",
20
+ os_chromeos: "ChromeOS",
21
+ os_other: "Other",
22
+ arch_x64: "x64",
23
+ arch_arm64: "arm64",
24
+ arch_x86: "x86",
25
+ arch_arm32: "arm32",
26
+ arch_riscv64: "RISC-V 64",
27
+ step_checksum: "Computing checksum",
28
+ step_verify: "Verifying",
29
+ start: "Upload",
30
+ cancel: "Cancel",
31
+ required: definePhiMessageLabel("Required."),
32
+ invalid_segment: definePhiMessageLabel("Letters, digits and . _ + ~ - only, no slash, and not starting with a dot or a tilde."),
33
+ invalid_version: definePhiMessageLabel("Letters, digits and . _ + ~ : - only, no slash, and not starting with a dot, a tilde or a colon."),
34
+ reserved_name: definePhiMessageLabel("The name api is reserved."),
35
+ checksum_unavailable: definePhiMessageLabel("This browser cannot compute the file's checksum here; open the page over https."),
36
+ },
37
+ });
38
+ export async function getPhiCdnUploadWidgetLabels(options) {
39
+ const labels = await getPhiLabelSet(options, PHI_CDN_UPLOAD_WIDGET_LABEL_SET);
40
+ return {
41
+ name: labels.name,
42
+ nameHint: labels.name_hint,
43
+ version: labels.version,
44
+ fileFileName: labels.file_file_name,
45
+ os: labels.os,
46
+ arch: labels.arch,
47
+ osNames: {
48
+ linux: labels.os_linux,
49
+ windows: labels.os_windows,
50
+ macos: labels.os_macos,
51
+ android: labels.os_android,
52
+ ios: labels.os_ios,
53
+ chromeos: labels.os_chromeos,
54
+ other: labels.os_other,
55
+ },
56
+ archNames: {
57
+ x64: labels.arch_x64,
58
+ arm64: labels.arch_arm64,
59
+ x86: labels.arch_x86,
60
+ arm32: labels.arch_arm32,
61
+ riscv64: labels.arch_riscv64,
62
+ },
63
+ steps: { checksum: labels.step_checksum, verify: labels.step_verify },
64
+ start: labels.start,
65
+ cancel: labels.cancel,
66
+ required: labels.required,
67
+ invalidSegment: labels.invalid_segment,
68
+ invalidVersion: labels.invalid_version,
69
+ reservedName: labels.reserved_name,
70
+ checksumUnavailable: labels.checksum_unavailable,
71
+ };
72
+ }
@@ -0,0 +1,3 @@
1
+ import type { PhiCmsServerWidgetPlugin } from "../../../../../types";
2
+ import { type PhiCdnUploadWidgetConfig } from "./config";
3
+ export declare const PHI_CDN_UPLOAD_WIDGET_PLUGIN: PhiCmsServerWidgetPlugin<PhiCdnUploadWidgetConfig>;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { PHI_CDN_UPLOAD_WIDGET_DEFINITION } from "./config";
3
+ import { PhiCdnUploadWidget } from "./server";
4
+ export const PHI_CDN_UPLOAD_WIDGET_PLUGIN = {
5
+ ...PHI_CDN_UPLOAD_WIDGET_DEFINITION,
6
+ render: ({ config, runtime }) => _jsx(PhiCdnUploadWidget, { config: config, runtime: runtime }),
7
+ };
@@ -0,0 +1,8 @@
1
+ import "server-only";
2
+ import type { PhiBlockRuntime } from "../../../../../types";
3
+ import { type PhiCdnUploadWidgetConfig } from "./config";
4
+ /** Handed to the Render Client by type, with its words read here in the page's language. */
5
+ export declare function PhiCdnUploadWidget({ config, runtime, }: {
6
+ config?: PhiCdnUploadWidgetConfig;
7
+ runtime: PhiBlockRuntime;
8
+ }): Promise<import("react").JSX.Element>;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import "server-only";
3
+ import { PhiRuntimeModuleRenderClientHost } from "../../../../../runtime-render-client";
4
+ import { buildPhiWidgetLabelTranslatorOptions } from "../../../../../components/widgets/label-sets/runtime-options";
5
+ import { PHI_CDN_UPLOAD_WIDGET_TYPE } from "./config";
6
+ import { getPhiCdnUploadWidgetLabels } from "./labels";
7
+ import { getPhiMediaUploadLabels } from "../../../../../components/media/label-sets/media-upload";
8
+ /** Handed to the Render Client by type, with its words read here in the page's language. */
9
+ export async function PhiCdnUploadWidget({ config, runtime, }) {
10
+ const translator = buildPhiWidgetLabelTranslatorOptions(runtime);
11
+ // The Media upload surface's own words (drop area, progress, refusals) and the CDN's for its fields.
12
+ const [labels, { upload: uploadLabels }] = await Promise.all([
13
+ getPhiCdnUploadWidgetLabels(translator),
14
+ getPhiMediaUploadLabels(translator),
15
+ ]);
16
+ return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PHI_CDN_UPLOAD_WIDGET_TYPE, componentProps: { config, labels, uploadLabels } }));
17
+ }
@@ -0,0 +1,2 @@
1
+ import type { PhiRuntimeModuleWidgetDefinition } from "../contracts";
2
+ export declare const PHI_CDN_RUNTIME_MODULE_WIDGETS: readonly PhiRuntimeModuleWidgetDefinition[];
@@ -0,0 +1,13 @@
1
+ import { definePhiFirstPartyWidget } from "../contracts";
2
+ import { PHI_CDN_RUNTIME_MODULE_ID } from "./ids";
3
+ import { PHI_CDN_UPLOAD_WIDGET_DEFINITION } from "./widgets/upload/config";
4
+ export const PHI_CDN_RUNTIME_MODULE_WIDGETS = [
5
+ definePhiFirstPartyWidget({
6
+ definition: PHI_CDN_UPLOAD_WIDGET_DEFINITION,
7
+ ownerModuleId: PHI_CDN_RUNTIME_MODULE_ID,
8
+ // Nothing to show before a file is chosen: the Builder draws the house placeholder.
9
+ renderPolicies: { runtime: "custom", preview: "visualPlaceholder", authoring: "custom" },
10
+ loadRuntime: () => import("./widgets/upload/plugin").then((module) => module.PHI_CDN_UPLOAD_WIDGET_PLUGIN),
11
+ loadPreview: () => import("./widgets/upload/plugin").then((module) => module.PHI_CDN_UPLOAD_WIDGET_PLUGIN),
12
+ }),
13
+ ];
@@ -1 +1 @@
1
- export declare const PHI_ADMIN_RUNTIME_MODULE_AUTHORING_CLIENT_CONTRIBUTIONS: readonly [import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution];
1
+ export declare const PHI_ADMIN_RUNTIME_MODULE_AUTHORING_CLIENT_CONTRIBUTIONS: readonly [import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution, import("../authoring-contributions-client").PhiRuntimeModuleAuthoringClientContribution];
@@ -2,6 +2,7 @@
2
2
  import { definePhiRuntimeModuleAuthoringClientContribution, } from "../authoring-contributions-client";
3
3
  import { PHI_ADMIN_RUNTIME_MODULE_ID } from "../admin/ids";
4
4
  import { PHI_AUTH_RUNTIME_MODULE_ID } from "../auth/ids";
5
+ import { PHI_CDN_RUNTIME_MODULE_ID } from "../cdn/ids";
5
6
  import { PHI_GROUPS_RUNTIME_MODULE_ID } from "../groups/ids";
6
7
  import { PHI_LOCALIZATION_RUNTIME_MODULE_ID } from "../localization/ids";
7
8
  import { PHI_OBSERVABILITY_RUNTIME_MODULE_ID } from "../observability/ids";
@@ -15,6 +16,11 @@ export const PHI_ADMIN_RUNTIME_MODULE_AUTHORING_CLIENT_CONTRIBUTIONS = [
15
16
  loadAuthoring: () => import("../auth/authoring")
16
17
  .then((module) => module.PhiAuthRuntimeModuleAuthoringClient),
17
18
  }),
19
+ definePhiRuntimeModuleAuthoringClientContribution({
20
+ moduleId: PHI_CDN_RUNTIME_MODULE_ID,
21
+ loadAuthoring: () => import("../cdn/authoring")
22
+ .then((module) => module.PhiCdnRuntimeModuleAuthoringClient),
23
+ }),
18
24
  PHI_DASHBOARD_RUNTIME_MODULE_AUTHORING_CLIENT_CONTRIBUTION,
19
25
  definePhiRuntimeModuleAuthoringClientContribution({
20
26
  moduleId: PHI_GROUPS_RUNTIME_MODULE_ID,
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import dynamic from "next/dynamic";
2
3
  import { createPhiRuntimeModuleControllerClientManifestFromAreaContributions } from "../area-contributions-controller-client";
3
4
  import { PHI_ADMIN_RUNTIME_MODULE_CONTROLLER_CLIENT_AREA_CONTRIBUTIONS } from "../client-area-contributions/admin";
4
5
  import { PHI_COMMON_RUNTIME_MODULE_RENDER_CLIENT_MANIFEST } from "./common";
@@ -9,14 +10,23 @@ import { PHI_DASHBOARD_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS } from "../dashb
9
10
  import { PHI_GROUPS_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS } from "../groups/client-data-providers";
10
11
  import { PHI_LOCALIZATION_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS } from "../localization/client-data-providers";
11
12
  import { PHI_OBSERVABILITY_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS } from "../observability/client-data-providers";
13
+ import { PHI_CDN_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS } from "../cdn/client-data-providers";
14
+ import { definePhiRuntimeModuleRenderClient, extendPhiRuntimeModuleRenderClientManifest, } from "../../../components/runtime/runtime-module-render-client-manifest";
15
+ import { PhiCmsWidgetType } from "../../../constants/cms-widget-types";
12
16
  import { PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS } from "../user-management/client-data-providers";
13
17
  export { PHI_COMMON_RUNTIME_MODULE_CALENDAR_ADAPTER_CLIENT_MANIFEST as PHI_ADMIN_RUNTIME_MODULE_CALENDAR_ADAPTER_CLIENT_MANIFEST } from "./common";
14
18
  export { PHI_COMMON_RUNTIME_MODULE_MEDIA_SOURCE_CLIENT_MANIFEST as PHI_ADMIN_RUNTIME_MODULE_MEDIA_SOURCE_CLIENT_MANIFEST } from "./common";
15
19
  export { PHI_COMMON_RUNTIME_MODULE_UI_PROVIDER_CLIENT_MANIFEST as PHI_ADMIN_RUNTIME_MODULE_UI_PROVIDER_CLIENT_MANIFEST } from "./common";
16
20
  export const PHI_ADMIN_RUNTIME_MODULE_CONTROLLER_CLIENT_MANIFEST = createPhiRuntimeModuleControllerClientManifestFromAreaContributions(PHI_ADMIN_RUNTIME_MODULE_CONTROLLER_CLIENT_AREA_CONTRIBUTIONS);
17
- export const PHI_ADMIN_RUNTIME_MODULE_RENDER_CLIENT_MANIFEST = PHI_COMMON_RUNTIME_MODULE_RENDER_CLIENT_MANIFEST;
21
+ export const PHI_ADMIN_RUNTIME_MODULE_RENDER_CLIENT_MANIFEST = extendPhiRuntimeModuleRenderClientManifest(PHI_COMMON_RUNTIME_MODULE_RENDER_CLIENT_MANIFEST, [
22
+ [
23
+ PhiCmsWidgetType.CdnUpload,
24
+ definePhiRuntimeModuleRenderClient(dynamic(() => import("../cdn/widgets/upload/client").then((module) => module.PhiCdnUploadWidgetClient))),
25
+ ],
26
+ ]);
18
27
  export const PHI_ADMIN_RUNTIME_MODULE_DATA_PROVIDER_CLIENT_MANIFEST = extendPhiRuntimeModuleDataProviderClientManifest(PHI_COMMON_RUNTIME_MODULE_DATA_PROVIDER_CLIENT_MANIFEST, [
19
28
  ...PHI_AUTH_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS,
29
+ ...PHI_CDN_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS,
20
30
  ...PHI_DASHBOARD_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS,
21
31
  ...PHI_GROUPS_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS,
22
32
  ...PHI_LOCALIZATION_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS,
@@ -381,7 +381,7 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
381
381
  pageSize: config.initialQuery?.pageSize ?? features.pagination?.pageSize ?? 20,
382
382
  filters: { ...(config.initialQuery?.filters ?? {}) },
383
383
  }) })) : null, features.tools.reload ? (_jsx(PhiButtonControl, { ariaLabel: labels.tool.reloadLabel, tooltip: labels.tool.reloadLabel, icon: resolvePhiButtonIcon("reload"), size: controlSize, onClick: binding.reload })) : null] })) : null;
384
- const awaitingInitialPayload = binding.data == null && !state.error;
384
+ const awaitingInitialPayload = binding.loading && binding.data == null && !state.error;
385
385
  const body = state.error ? null : awaitingInitialPayload ? (_jsx(PhiMediaAssetCollectionSkeletonControl, { mode: mode, gap: gap, minColumnWidth: minColumnWidth })) : state.assets.length === 0 ? (_jsx(PhiEmptyControl, { description: presentation.emptyDescription ?? labels.grid.emptyDescription })) : undefined;
386
386
  /*
387
387
  * The upload panel: the Media library's wall, into the resolved Folder path where the placement names
@@ -168,6 +168,8 @@ export function PhiSiteAddressCollectionViewBinding({ config, binding, widgetId,
168
168
  const emptyDescription = typeof binding.data?.meta?.emptyDescription === "string" && binding.data.meta.emptyDescription.trim()
169
169
  ? binding.data.meta.emptyDescription
170
170
  : presentation.emptyDescription ?? labels.empty;
171
- const body = binding.data == null ? (binding.error ? null : _jsx(PhiCollectionViewSkeletonControl, { mode: mode, gap: gap, minColumnWidth: minColumnWidth, count: 2 })) : tiles.length === 0 ? (_jsx(PhiEmptyControl, { description: emptyDescription })) : undefined;
171
+ const body = binding.data == null ? (binding.loading && !binding.error
172
+ ? _jsx(PhiCollectionViewSkeletonControl, { mode: mode, gap: gap, minColumnWidth: minColumnWidth, count: 3 })
173
+ : null) : tiles.length === 0 ? (_jsx(PhiEmptyControl, { description: emptyDescription })) : undefined;
172
174
  return (_jsx(PhiCollectionViewControl, { title: presentation.title, description: presentation.description, toolbar: features.tools.mode === "external" ? null : toolbar, diagnostics: binding.error && binding.data != null ? _jsx(PhiAlertControl, { level: "error", title: binding.error }) : null, body: body, items: items, mode: mode, ...(gap ? { gap } : {}), minColumnWidth: minColumnWidth, pagination: null }));
173
175
  }
@@ -685,17 +685,19 @@ export function PhiTableWidgetClient({ config: inputConfig, renderMode, external
685
685
  return pageSize > 0 ? Math.ceil(total / pageSize) : 0;
686
686
  }, [resolvedQuery.page, resolvedQuery.pageSize, rows.length, selectedRowIdentities.length, summary, total]);
687
687
  const footer = useMemo(() => {
688
- if (!presentation.footer)
688
+ if (presentation.header === false || presentation.footerOmitted)
689
689
  return undefined;
690
+ if (!presentation.footer)
691
+ return { content: "" };
690
692
  // The first variant whose value holds says the line instead; see `PhiTableFooterVariant`.
691
693
  const variant = presentation.footer.variants?.find(({ when }) => {
692
694
  const held = Boolean(resolveSummaryValue({ key: "when", value: when.value }));
693
695
  return when.operator === "truthy" ? held : !held;
694
696
  });
695
697
  const template = variant?.template ?? presentation.footer.template;
696
- // A variant with an empty template takes the footer away rather than drawing an empty bar.
698
+ // An empty line keeps the Table's closing bar; only footerOmitted removes it.
697
699
  if (!template.trim())
698
- return undefined;
700
+ return { align: presentation.footer.align, content: "" };
699
701
  const values = variant ? variant.values ?? [] : presentation.footer.values;
700
702
  return {
701
703
  align: presentation.footer.align,
@@ -704,7 +706,7 @@ export function PhiTableWidgetClient({ config: inputConfig, renderMode, external
704
706
  return typeof value === "number" ? value : value == null ? "—" : String(value);
705
707
  })),
706
708
  };
707
- }, [presentation.footer, resolveSummaryValue]);
709
+ }, [presentation.footer, presentation.footerOmitted, presentation.header, resolveSummaryValue]);
708
710
  const tableSummary = useMemo(() => presentation.summary ? {
709
711
  ...presentation.summary,
710
712
  rows: presentation.summary.rows.map((row) => ({
@@ -338,8 +338,8 @@ export type PhiTableFooterValueBinding = {
338
338
  * The template fills placeholders and nothing else, so a sentence that changes with the state -- "3 of 5
339
339
  * left" against "Used up" -- is two templates, not one with a condition inside. The first variant whose
340
340
  * `when` holds replaces `template` and `values`; none holding leaves the footer as declared. A variant
341
- * may name no values: "Used up" has nothing to fill in. An empty template takes the footer away while it
342
- * holds -- a line about a limit has nothing to say where there is none.
341
+ * may name no values: "Used up" has nothing to fill in. An empty template clears the text while
342
+ * retaining the closing bar; only `footerOmitted` explicitly removes that bar.
343
343
  */
344
344
  export type PhiTableFooterVariant = {
345
345
  when: {