@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.
Files changed (84) hide show
  1. package/components/controls/phi-form-control.d.ts +6 -0
  2. package/components/controls/phi-form-control.js +23 -7
  3. package/components/controls/phi-media-picker-control.d.ts +3 -1
  4. package/components/controls/phi-media-picker-control.js +2 -2
  5. package/components/forms/form-descriptor-runtime-client.d.ts +3 -1
  6. package/components/forms/form-descriptor-runtime-client.js +2 -2
  7. package/components/forms/form-field-provider-modules.d.ts +23 -0
  8. package/components/forms/form-field-provider-modules.js +28 -0
  9. package/components/forms/form-provider-contract.d.ts +7 -0
  10. package/components/forms/form-provider-contract.js +7 -0
  11. package/components/forms/lazy-form-field-control.d.ts +14 -0
  12. package/components/forms/lazy-form-field-control.js +35 -0
  13. package/components/forms/phi-form-widget.d.ts +3 -2
  14. package/components/forms/phi-form-widget.js +21 -3
  15. package/components/forms/shared-form-provider-registry.js +1 -33
  16. package/components/media/phi-area-upload-widget.js +6 -58
  17. package/components/media/phi-media-picker-binding.d.ts +16 -1
  18. package/components/media/phi-media-picker-binding.js +3 -2
  19. package/components/media/phi-media-upload.d.ts +12 -0
  20. package/components/media/phi-media-upload.js +22 -0
  21. package/components/media/phi-upload-drop-area.d.ts +22 -0
  22. package/components/media/phi-upload-drop-area.js +49 -0
  23. package/components/widgets/helpers/semantic-html-translation.d.ts +4 -1
  24. package/components/widgets/helpers/semantic-html-translation.js +4 -2
  25. package/components/widgets/label-sets/admin-users.d.ts +9 -1
  26. package/components/widgets/label-sets/admin-users.js +14 -2
  27. package/components/widgets/label-sets/slot-upload.js +6 -3
  28. package/components/widgets/label-types/slot-upload.d.ts +7 -1
  29. package/components/widgets/label-types/slot-upload.js +2 -1
  30. package/components/widgets/shared/markdown-render.js +6 -6
  31. package/constants/media-library-provider-keys.d.ts +9 -0
  32. package/constants/media-library-provider-keys.js +9 -0
  33. package/constants/runtime-module-ownership.js +2 -0
  34. package/controls.d.ts +2 -0
  35. package/controls.js +1 -0
  36. package/gateway/signet-route.js +11 -6
  37. package/helpers/phi-signet-head.d.ts +4 -3
  38. package/helpers/phi-signet-head.js +17 -5
  39. package/helpers/phi-signet.d.ts +12 -0
  40. package/helpers/phi-signet.js +11 -0
  41. package/net/phi-next-proxy.d.ts +10 -8
  42. package/net/phi-next-proxy.js +27 -84
  43. package/next/proxy-runtime.js +15 -0
  44. package/next/site-proxy.js +5 -0
  45. package/package.json +1 -1
  46. package/plugins/runtime-modules/asset/definition.d.ts +44 -2
  47. package/plugins/runtime-modules/asset/definition.js +5 -2
  48. package/plugins/runtime-modules/asset/form-providers.d.ts +63 -0
  49. package/plugins/runtime-modules/asset/form-providers.js +54 -0
  50. package/plugins/runtime-modules/asset/form-ui-provider.js +13 -3
  51. package/plugins/runtime-modules/asset/media-asset-field.d.ts +20 -0
  52. package/plugins/runtime-modules/asset/media-asset-field.js +33 -0
  53. package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +21 -0
  54. package/plugins/runtime-modules/asset/media-asset-form-control.js +74 -0
  55. package/plugins/runtime-modules/core/widgets/html/server.js +1 -1
  56. package/plugins/runtime-modules/core/widgets/slot-upload/client.js +28 -23
  57. package/plugins/runtime-modules/core/widgets/slot-upload/slot.d.ts +19 -0
  58. package/plugins/runtime-modules/core/widgets/slot-upload/slot.js +16 -0
  59. package/plugins/runtime-modules/resolver.js +38 -4
  60. package/plugins/runtime-modules/user-management/addon-roles.d.ts +35 -0
  61. package/plugins/runtime-modules/user-management/addon-roles.js +76 -0
  62. package/plugins/runtime-modules/user-management/cards.js +1 -1
  63. package/plugins/runtime-modules/user-management/client-data-providers.js +6 -0
  64. package/plugins/runtime-modules/user-management/data-providers.d.ts +11 -2
  65. package/plugins/runtime-modules/user-management/data-providers.js +12 -1
  66. package/plugins/runtime-modules/user-management/definition.d.ts +11 -2
  67. package/plugins/runtime-modules/user-management/ids.d.ts +1 -0
  68. package/plugins/runtime-modules/user-management/ids.js +1 -0
  69. package/plugins/runtime-modules/user-management/services/options.d.ts +8 -0
  70. package/plugins/runtime-modules/user-management/services/options.js +25 -0
  71. package/plugins/runtime-modules/user-management/services/table.js +9 -1
  72. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +20 -2
  73. package/server-helpers/cms-widget-texts.js +1 -1
  74. package/server-helpers/search-index.js +22 -13
  75. package/server-helpers/search-text.d.ts +3 -2
  76. package/server-helpers/search-text.js +6 -5
  77. package/server-helpers/translate.d.ts +13 -2
  78. package/server-helpers/translate.js +10 -6
  79. package/theme/phi-theme-signet.d.ts +6 -0
  80. package/theme/phi-theme-signet.js +37 -1
  81. package/theme/phi-tokens.d.ts +1 -1
  82. package/theme/phi-tokens.js +5 -1
  83. package/types/cms-plugins.d.ts +10 -1
  84. package/types/site-theme.d.ts +14 -2
@@ -1,4 +1,5 @@
1
1
  import type { PhiMediaKindValue } from "../../types/media";
2
+ import type { PhiAreaUploadWidgetLabels } from "./media-widget-labels";
2
3
  import { type PhiMediaUploadSessionRunner, type PhiMediaUploadInitOptions } from "./media-upload-flow";
3
4
  /**
4
5
  * What a surface accepts, stated by the Module that offers it.
@@ -39,6 +40,17 @@ export type PhiMediaUploadLabels = {
39
40
  * plane message into an interface is what these replace.
40
41
  */
41
42
  export declare const PHI_MEDIA_UPLOAD_DEFAULT_LABELS: PhiMediaUploadLabels;
43
+ /**
44
+ * The wording of every refusal on a Media upload surface that has the Media label set: the Widget's own
45
+ * duplicate, failure and storage texts, and the shared ones for the rest -- so no control plane string
46
+ * reaches a person. The Media folder's upload Widget and an Add-on's slot upload read it the same way.
47
+ */
48
+ export declare function resolvePhiAreaUploadLabels(labels: PhiAreaUploadWidgetLabels): PhiMediaUploadLabels;
49
+ /** What an item of an upload says of its state: the percentage on its way, "Failed", or "Done". */
50
+ export declare function resolvePhiUploadStatusLabel(item: {
51
+ status: "uploading" | "done" | "error";
52
+ progress: number;
53
+ }, labels: Pick<PhiAreaUploadWidgetLabels, "failedLabel" | "doneLabel">): string;
42
54
  /** The `accept` attribute a file dialog should carry, derived rather than written out by each caller. */
43
55
  export declare function resolvePhiMediaUploadAccept(acceptance: PhiMediaUploadAcceptance | undefined): string;
44
56
  /** Why this file cannot be sent, or `null` when it can. */
@@ -21,6 +21,28 @@ export const PHI_MEDIA_UPLOAD_DEFAULT_LABELS = {
21
21
  errorStorageUnreachable: "The file storage could not be reached.",
22
22
  errorFolderLocked: "This folder is locked. Nothing can be uploaded into it until it is unlocked.",
23
23
  };
24
+ /**
25
+ * The wording of every refusal on a Media upload surface that has the Media label set: the Widget's own
26
+ * duplicate, failure and storage texts, and the shared ones for the rest -- so no control plane string
27
+ * reaches a person. The Media folder's upload Widget and an Add-on's slot upload read it the same way.
28
+ */
29
+ export function resolvePhiAreaUploadLabels(labels) {
30
+ return {
31
+ ...PHI_MEDIA_UPLOAD_DEFAULT_LABELS,
32
+ errorGeneric: labels.uploadFailedText,
33
+ errorDuplicate: labels.assetExistsLabel,
34
+ errorStorageUnreachable: labels.uploadStorageUnreachableText,
35
+ errorFolderLocked: labels.uploadFolderLockedText,
36
+ };
37
+ }
38
+ /** What an item of an upload says of its state: the percentage on its way, "Failed", or "Done". */
39
+ export function resolvePhiUploadStatusLabel(item, labels) {
40
+ if (item.status === "error")
41
+ return labels.failedLabel;
42
+ if (item.status === "uploading")
43
+ return `${item.progress}%`;
44
+ return labels.doneLabel;
45
+ }
24
46
  /** The `accept` attribute a file dialog should carry, derived rather than written out by each caller. */
25
47
  export function resolvePhiMediaUploadAccept(acceptance) {
26
48
  const types = acceptance?.contentTypes ?? [];
@@ -0,0 +1,22 @@
1
+ export type PhiUploadDropAreaProps = {
2
+ /** What the file dialog offers. The upload's own acceptance check is what refuses. */
3
+ accept?: string;
4
+ multiple?: boolean;
5
+ disabled?: boolean;
6
+ /** The bold line of the area (`PhiAreaUploadWidgetLabels.dropTitle`). */
7
+ title: string;
8
+ /** The quiet line under it (`PhiAreaUploadWidgetLabels.dropHint`). */
9
+ hint: string;
10
+ /** Once per file chosen or dropped. */
11
+ onFile: (file: File) => void;
12
+ };
13
+ /**
14
+ * The area files are dropped on or clicked, as every Media upload surface draws it: the Media folder's
15
+ * upload Widget and an Add-on's slot upload.
16
+ *
17
+ * Shared rather than copied because what it holds is easy to get half right: the highlight while a file
18
+ * is dragged over it, the `data-phi-media-dropzone` mark that `PhiFileDropGuard` lets a drop through
19
+ * for, and that guard itself, which stops a drop beside the area from opening the file in the tab. It
20
+ * transports nothing; the caller hands every file to `usePhiMediaUpload`.
21
+ */
22
+ export declare function PhiUploadDropArea({ accept, multiple, disabled, title, hint, onFile }: PhiUploadDropAreaProps): import("react").JSX.Element;
@@ -0,0 +1,49 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useRef, useState } from "react";
4
+ import { PhiFileDropControl } from "../controls/phi-file-drop-control";
5
+ import { PhiFlexControl } from "../controls/phi-flex-control";
6
+ import { PhiTypographyControl } from "../controls/phi-typography-control";
7
+ import { usePhiConfig } from "../root/phi-config-provider";
8
+ import { PhiIcon } from "../shell/phi-icon";
9
+ import { PhiFileDropGuard } from "./phi-file-drop-guard";
10
+ /**
11
+ * The area files are dropped on or clicked, as every Media upload surface draws it: the Media folder's
12
+ * upload Widget and an Add-on's slot upload.
13
+ *
14
+ * Shared rather than copied because what it holds is easy to get half right: the highlight while a file
15
+ * is dragged over it, the `data-phi-media-dropzone` mark that `PhiFileDropGuard` lets a drop through
16
+ * for, and that guard itself, which stops a drop beside the area from opening the file in the tab. It
17
+ * transports nothing; the caller hands every file to `usePhiMediaUpload`.
18
+ */
19
+ export function PhiUploadDropArea({ accept, multiple, disabled, title, hint, onFile }) {
20
+ const { token } = usePhiConfig();
21
+ const dragDepth = useRef(0);
22
+ const [isDragActive, setIsDragActive] = useState(false);
23
+ return (_jsxs(_Fragment, { children: [_jsx(PhiFileDropGuard, {}), _jsx("div", { "data-phi-media-dropzone": "true", onDragEnter: () => {
24
+ dragDepth.current += 1;
25
+ setIsDragActive(true);
26
+ }, onDragLeave: () => {
27
+ dragDepth.current = Math.max(0, dragDepth.current - 1);
28
+ if (dragDepth.current === 0) {
29
+ setIsDragActive(false);
30
+ }
31
+ }, onDragOver: (event) => {
32
+ event.preventDefault();
33
+ event.dataTransfer.dropEffect = "copy";
34
+ setIsDragActive(true);
35
+ }, onDrop: () => {
36
+ dragDepth.current = 0;
37
+ setIsDragActive(false);
38
+ }, style: { width: "100%" }, children: _jsx(PhiFileDropControl, { dropZone: true, ...(multiple === undefined ? {} : { multiple }), ...(accept === undefined ? {} : { accept }), ...(disabled === undefined ? {} : { disabled }), onFile: onFile, style: {
39
+ padding: 0,
40
+ width: "100%",
41
+ borderColor: isDragActive ? token.colorPrimary : undefined,
42
+ background: isDragActive ? token.colorFillQuaternary : undefined,
43
+ }, children: _jsxs(PhiFlexControl, { vertical: true, align: "center", gap: 4, style: {
44
+ width: "100%",
45
+ minHeight: token.controlHeight * 4,
46
+ justifyContent: "center",
47
+ cursor: isDragActive ? "copy" : "default",
48
+ }, children: [_jsx(PhiIcon, { name: "upload", size: "inherit", style: { fontSize: token.fontSizeHeading3, color: token.colorTextSecondary } }), _jsx(PhiTypographyControl, { strong: true, children: title }), _jsx(PhiTypographyControl, { type: "secondary", children: hint })] }) }) })] }));
49
+ }
@@ -1,4 +1,7 @@
1
1
  import "server-only";
2
+ import type { PhiBlockRuntime } from "../../../types";
2
3
  export declare function translateSemanticHtml(sourceHtml: string, sourceLocale?: string,
3
4
  /** The render's locale. Without it the request's is asked, and a static render has no request. */
4
- locale?: string): Promise<string>;
5
+ locale?: string,
6
+ /** The render's runtime, when the caller holds one: the Site's store is then named, not looked up in the request. */
7
+ runtime?: Pick<PhiBlockRuntime, "site">): Promise<string>;
@@ -51,7 +51,9 @@ function hasVisibleText(html) {
51
51
  }
52
52
  export async function translateSemanticHtml(sourceHtml, sourceLocale,
53
53
  /** The render's locale. Without it the request's is asked, and a static render has no request. */
54
- locale) {
54
+ locale,
55
+ /** The render's runtime, when the caller holds one: the Site's store is then named, not looked up in the request. */
56
+ runtime) {
55
57
  const sanitized = sanitizePhiHtmlWidgetMarkup(sourceHtml);
56
58
  if (!sanitized) {
57
59
  return "";
@@ -68,7 +70,7 @@ locale) {
68
70
  }
69
71
  const msgs = units.map((unit) => unit.html);
70
72
  const translated = locale
71
- ? await trBulkForLocale(locale, msgs, 0, "html", sourceLocale)
73
+ ? await trBulkForLocale(locale, msgs, 0, "html", sourceLocale, runtime)
72
74
  : await trBulk(msgs, 0, "html", sourceLocale);
73
75
  units.forEach((unit, index) => {
74
76
  const fragment = parseDocument(translated[index] ?? unit.html);
@@ -9,10 +9,17 @@ export declare function getPhiAdminUsersTableWidgetLabels(options: PhiGlobalTran
9
9
  footer: string;
10
10
  accountTypes: {
11
11
  all: string;
12
- shop: string;
12
+ external: string;
13
13
  roles: string;
14
14
  auth: string;
15
15
  };
16
+ addonRoles: {
17
+ all: string;
18
+ };
19
+ filters: {
20
+ addonRole: string;
21
+ addonRoleHint: string;
22
+ };
16
23
  enabledOptions: {
17
24
  all: string;
18
25
  enabled: string;
@@ -25,6 +32,7 @@ export declare function getPhiAdminUsersTableWidgetLabels(options: PhiGlobalTran
25
32
  name: string;
26
33
  email: string;
27
34
  roles: string;
35
+ addonRoles: string;
28
36
  userFlags: string;
29
37
  siteFlags: string;
30
38
  lastLogin: string;
@@ -12,7 +12,7 @@ const PHI_ADMIN_USERS_TABLE_WIDGET_LABEL_SET = definePhiLabelSet({
12
12
  add_label: "Add user",
13
13
  footer_count: "%1 users of %2 total",
14
14
  account_type_all: "All",
15
- account_type_shop: "Shop",
15
+ account_type_external: "External",
16
16
  account_type_roles: "Local roles",
17
17
  account_type_auth: "Auth",
18
18
  enabled_all: "All",
@@ -24,6 +24,10 @@ const PHI_ADMIN_USERS_TABLE_WIDGET_LABEL_SET = definePhiLabelSet({
24
24
  column_name: "Name",
25
25
  column_email: "Email",
26
26
  column_roles: "Roles",
27
+ column_addon_roles: "Add-on roles",
28
+ addon_roles_all: "all roles",
29
+ filter_addon_role: "Add-on role",
30
+ filter_addon_role_hint: definePhiMessageLabel("Show users who hold a role of an Add-on, or one role of it. Site Admins hold every role."),
27
31
  column_user_flags: "User flags",
28
32
  column_site_flags: "Site flags",
29
33
  column_last_login: "Last login",
@@ -96,10 +100,17 @@ export async function getPhiAdminUsersTableWidgetLabels(options) {
96
100
  footer: labels.footer_count,
97
101
  accountTypes: {
98
102
  all: labels.account_type_all,
99
- shop: labels.account_type_shop,
103
+ external: labels.account_type_external,
100
104
  roles: labels.account_type_roles,
101
105
  auth: labels.account_type_auth,
102
106
  },
107
+ addonRoles: {
108
+ all: labels.addon_roles_all,
109
+ },
110
+ filters: {
111
+ addonRole: labels.filter_addon_role,
112
+ addonRoleHint: labels.filter_addon_role_hint,
113
+ },
103
114
  enabledOptions: {
104
115
  all: labels.enabled_all,
105
116
  enabled: labels.enabled_enabled,
@@ -112,6 +123,7 @@ export async function getPhiAdminUsersTableWidgetLabels(options) {
112
123
  name: labels.column_name,
113
124
  email: labels.column_email,
114
125
  roles: labels.column_roles,
126
+ addonRoles: labels.column_addon_roles,
115
127
  userFlags: labels.column_user_flags,
116
128
  siteFlags: labels.column_site_flags,
117
129
  lastLogin: labels.column_last_login,
@@ -1,13 +1,13 @@
1
1
  import "server-only";
2
2
  import { definePhiLabelSet, definePhiMessageLabel, getPhiLabelSet } from "../../../gateway/label-set";
3
3
  import { PHI_TR_CTX_WEB_UI_LABEL } from "../../../gateway/tr";
4
+ import { getPhiMediaWidgetLabels } from "../../media/label-sets/media";
4
5
  import { PHI_SLOT_UPLOAD_WIDGET_DEFAULT_LABELS, } from "../label-types/slot-upload";
5
6
  const DEFAULTS = PHI_SLOT_UPLOAD_WIDGET_DEFAULT_LABELS;
6
7
  const PHI_SLOT_UPLOAD_WIDGET_LABEL_SET = definePhiLabelSet({
7
8
  key: "widget:slot-upload",
8
9
  ctx: PHI_TR_CTX_WEB_UI_LABEL,
9
10
  labels: {
10
- choose: DEFAULTS.choose,
11
11
  remove: DEFAULTS.remove,
12
12
  unconfigured: definePhiMessageLabel(DEFAULTS.unconfigured),
13
13
  no_row: definePhiMessageLabel(DEFAULTS.noRow),
@@ -20,11 +20,13 @@ const PHI_SLOT_UPLOAD_WIDGET_LABEL_SET = definePhiLabelSet({
20
20
  },
21
21
  });
22
22
  export async function getPhiSlotUploadWidgetLabels(options) {
23
- const labels = await getPhiLabelSet(options, PHI_SLOT_UPLOAD_WIDGET_LABEL_SET);
23
+ const [labels, media] = await Promise.all([
24
+ getPhiLabelSet(options, PHI_SLOT_UPLOAD_WIDGET_LABEL_SET),
25
+ getPhiMediaWidgetLabels(options),
26
+ ]);
24
27
  return {
25
28
  unconfigured: labels.unconfigured,
26
29
  noRow: labels.no_row,
27
- choose: labels.choose,
28
30
  empty: labels.empty,
29
31
  remove: labels.remove,
30
32
  fileTitle: labels.file_title,
@@ -32,5 +34,6 @@ export async function getPhiSlotUploadWidgetLabels(options) {
32
34
  serverAnswered: labels.server_answered,
33
35
  unreachable: labels.unreachable,
34
36
  removeFailed: labels.remove_failed,
37
+ upload: media.upload,
35
38
  };
36
39
  }
@@ -1,13 +1,17 @@
1
+ import { type PhiAreaUploadWidgetLabels } from "../../media/media-widget-labels";
1
2
  /**
2
3
  * What the slot upload field says. The refusals of the upload it runs are not here: they are the shared
3
4
  * reading of `PHI_MEDIA_UPLOAD_DEFAULT_LABELS`, the same as on every other Media upload surface.
5
+ *
6
+ * The drop area's title and hint, the state of an upload and its retry are not written a second time
7
+ * either: `upload` is the Media folder's own set (`label-sets/media.ts`), so the two surfaces share one
8
+ * wording and one translation key per text.
4
9
  */
5
10
  export type PhiSlotUploadWidgetLabels = {
6
11
  /** The field names no Add-on, table or slot, so there is nowhere to put a file. */
7
12
  unconfigured: string;
8
13
  /** No row has arrived yet, so there is nothing to upload to. */
9
14
  noRow: string;
10
- choose: string;
11
15
  empty: string;
12
16
  remove: string;
13
17
  /** A file of the slot, `%1` its content type and `%2` its size in bytes. */
@@ -18,6 +22,8 @@ export type PhiSlotUploadWidgetLabels = {
18
22
  serverAnswered: string;
19
23
  unreachable: string;
20
24
  removeFailed: string;
25
+ /** The Media folder's upload texts: `dropTitle`, `dropHint`, `retryLabel`, `failedLabel`, and the refusals. */
26
+ upload: PhiAreaUploadWidgetLabels;
21
27
  };
22
28
  export declare const PHI_SLOT_UPLOAD_WIDGET_DEFAULT_LABELS: PhiSlotUploadWidgetLabels;
23
29
  /** Fills `%1`, `%2`, ... of a slot upload template in order. */
@@ -1,7 +1,7 @@
1
+ import { PHI_MEDIA_WIDGET_DEFAULT_LABELS } from "../../media/media-widget-labels";
1
2
  export const PHI_SLOT_UPLOAD_WIDGET_DEFAULT_LABELS = {
2
3
  unconfigured: "This field names no Add-on, table or slot.",
3
4
  noRow: "Nothing selected.",
4
- choose: "Choose a file",
5
5
  empty: "Nothing here yet.",
6
6
  remove: "Remove this file",
7
7
  fileTitle: "%1 — %2 bytes",
@@ -9,6 +9,7 @@ export const PHI_SLOT_UPLOAD_WIDGET_DEFAULT_LABELS = {
9
9
  serverAnswered: "The server answered %1.",
10
10
  unreachable: "Unreachable.",
11
11
  removeFailed: "That file stayed.",
12
+ upload: PHI_MEDIA_WIDGET_DEFAULT_LABELS.upload,
12
13
  };
13
14
  /** Fills `%1`, `%2`, ... of a slot upload template in order. */
14
15
  export function formatPhiSlotUploadWidgetLabel(template, ...values) {
@@ -274,18 +274,18 @@ function collectMarkdownTranslationUnits(node, units) {
274
274
  * locale from the request headers, finds none, and answers in the Site's default -- which left every
275
275
  * static Public page's body in its source language under a translated header.
276
276
  */
277
- function translateUnits(locale, msgs, format, sourceLocale) {
277
+ function translateUnits(locale, msgs, format, sourceLocale, runtime) {
278
278
  return locale
279
- ? trBulkForLocale(locale, msgs, 0, format, sourceLocale)
279
+ ? trBulkForLocale(locale, msgs, 0, format, sourceLocale, runtime)
280
280
  : trBulk(msgs, 0, format, sourceLocale);
281
281
  }
282
- async function buildMarkdownInlineMap(tree, translate, sourceLocale, locale) {
282
+ async function buildMarkdownInlineMap(tree, translate, sourceLocale, locale, runtime) {
283
283
  const units = [];
284
284
  collectMarkdownTranslationUnits(tree, units);
285
285
  const sent = units.filter((entry) => entry.unit.translatable);
286
286
  const translated = new Map();
287
287
  if (translate && sent.length > 0) {
288
- const answers = await translateUnits(locale, sent.map((entry) => entry.unit.html), "html", sourceLocale);
288
+ const answers = await translateUnits(locale, sent.map((entry) => entry.unit.html), "html", sourceLocale, runtime);
289
289
  sent.forEach((entry, index) => translated.set(entry, answers[index] || entry.unit.html));
290
290
  }
291
291
  /*
@@ -298,7 +298,7 @@ async function buildMarkdownInlineMap(tree, translate, sourceLocale, locale) {
298
298
  ? []
299
299
  : ["alt", "title"].flatMap((field) => slot[field].trim() ? [{ slot, field, text: slot[field] }] : [])));
300
300
  if (translate && imageTexts.length > 0) {
301
- const answers = await translateUnits(locale, imageTexts.map((entry) => entry.text), "text", sourceLocale);
301
+ const answers = await translateUnits(locale, imageTexts.map((entry) => entry.text), "text", sourceLocale, runtime);
302
302
  imageTexts.forEach((entry, index) => {
303
303
  entry.slot[entry.field] = answers[index] || entry.text;
304
304
  });
@@ -514,7 +514,7 @@ async function resolveMarkdownRenderDataFromSource(markdown, translate, headingI
514
514
  headingIdPrefix,
515
515
  headingOffset,
516
516
  };
517
- const inlineMap = await buildMarkdownInlineMap(tree, translate, sourceLocale, runtime?.locale.current);
517
+ const inlineMap = await buildMarkdownInlineMap(tree, translate, sourceLocale, runtime?.locale.current, runtime);
518
518
  const blocks = promoteMarkdownFigures(protectMarkdownMail(mapBlockNodes(tree.children, context, inlineMap)), figures, imageDefaults);
519
519
  return { blocks, headings: context.headings };
520
520
  }
@@ -1,3 +1,4 @@
1
+ import type { PhiFormProviderKey } from "../types/form-descriptor";
1
2
  /**
2
3
  * The Media library as a Foundation contract.
3
4
  *
@@ -41,3 +42,11 @@ export declare const PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS: {
41
42
  * Module.
42
43
  */
43
44
  export declare const PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY: `${string}/${string}`;
45
+ /**
46
+ * The `media-asset` Form field type, named on the same terms: one Asset of the Site's Media library,
47
+ * chosen with the library's picker. A Form of any Module cites this key in its `fieldProviderKey`; the
48
+ * Asset Module owns the field type, declares it in its `formProviders` and serves its control, and the
49
+ * Form widget mounts that for the Form where the Module is active (FORMS.md). The Foundation names it and
50
+ * holds no reference to the Module -- the resolver reads it to mount the library Provider the picker needs.
51
+ */
52
+ export declare const PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY: PhiFormProviderKey;
@@ -1,3 +1,4 @@
1
+ import { createPhiModuleScopedKey } from "./runtime-module-ownership";
1
2
  import { createPhiSharedRuntimeDataProviderKey, createPhiSharedRuntimeItemRendererKey, } from "./runtime-data-provider-key";
2
3
  /**
3
4
  * The Media library as a Foundation contract.
@@ -42,3 +43,11 @@ export const PHI_MEDIA_LIBRARY_DATA_PROVIDER_KEYS = {
42
43
  * Module.
43
44
  */
44
45
  export const PHI_MEDIA_LIBRARY_ITEM_RENDERER_KEY = createPhiSharedRuntimeItemRendererKey("media-asset");
46
+ /**
47
+ * The `media-asset` Form field type, named on the same terms: one Asset of the Site's Media library,
48
+ * chosen with the library's picker. A Form of any Module cites this key in its `fieldProviderKey`; the
49
+ * Asset Module owns the field type, declares it in its `formProviders` and serves its control, and the
50
+ * Form widget mounts that for the Form where the Module is active (FORMS.md). The Foundation names it and
51
+ * holds no reference to the Module -- the resolver reads it to mount the library Provider the picker needs.
52
+ */
53
+ export const PHI_MEDIA_ASSET_FORM_FIELD_PROVIDER_KEY = createPhiModuleScopedKey("form-field", "media-asset");
@@ -47,6 +47,7 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
47
47
  "form-field/email": ["core", "email"],
48
48
  "form-field/hidden": ["core", "hidden"],
49
49
  "form-field/honeypot": ["core", "honeypot"],
50
+ "form-field/media-asset": ["asset", "media-asset"],
50
51
  "form-field/money": ["core", "money"],
51
52
  "form-field/multi-select": ["core", "multi-select"],
52
53
  "form-field/number": ["core", "number"],
@@ -168,6 +169,7 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
168
169
  "forms/user-management/edit": ["user-management", "edit"],
169
170
  "options/admin-site-locales": ["localization", "admin-site-locales"],
170
171
  "options/core-site-locales": ["core", "site-locales"],
172
+ "options/user-management-addon-roles": ["user-management", "addon-roles"],
171
173
  "options/builder-area-root-route": ["builder", "area-root-route"],
172
174
  "options/builder-landing-page": ["builder", "landing-page"],
173
175
  "options/builder-collection-item-renderers": ["builder", "collection-item-renderers"],
package/controls.d.ts CHANGED
@@ -11,6 +11,8 @@ export { PhiEntryListControl } from "./components/controls/phi-entry-list-contro
11
11
  export type { PhiEntryListControlProps, PhiEntryListEntry } from "./components/controls/phi-entry-list-control";
12
12
  export { PhiAmountListControl } from "./components/controls/phi-amount-list-control";
13
13
  export type { PhiAmountListControlProps, PhiAmountListItem, PhiAmountListTotal, } from "./components/controls/phi-amount-list-control";
14
+ export { PhiFileDropControl } from "./components/controls/phi-file-drop-control";
15
+ export type { PhiFileDropControlProps } from "./components/controls/phi-file-drop-control";
14
16
  export { PhiPlacementMatrixControl } from "./components/controls/phi-placement-matrix-control";
15
17
  export type { PhiPlacementMatrixControlProps } from "./components/controls/phi-placement-matrix-control";
16
18
  export { PhiNumberControl } from "./components/controls/phi-number-control";
package/controls.js CHANGED
@@ -5,6 +5,7 @@ export { PhiCompactGroupControl } from "./components/controls/phi-compact-group-
5
5
  export { PhiViewportVisibilityControl } from "./components/controls/phi-viewport-visibility-control";
6
6
  export { PhiEntryListControl } from "./components/controls/phi-entry-list-control";
7
7
  export { PhiAmountListControl } from "./components/controls/phi-amount-list-control";
8
+ export { PhiFileDropControl } from "./components/controls/phi-file-drop-control";
8
9
  export { PhiPlacementMatrixControl } from "./components/controls/phi-placement-matrix-control";
9
10
  export { PhiNumberControl } from "./components/controls/phi-number-control";
10
11
  export { PhiPopoverControl } from "./components/controls/phi-popover-control";
@@ -2,14 +2,17 @@ import "server-only";
2
2
  import { NextRequest } from "next/server";
3
3
  import { readPhiThemeSiteSignet } from "../theme/phi-theme-signet";
4
4
  import { PHI_SIGNET_ALIAS_PARAM, PHI_SIGNET_APPLE_MIN_SIZE, PHI_SIGNET_VERSION_PARAM } from "../helpers/phi-signet-paths";
5
- import { buildPhiSignetVersion, decodePhiSignetDataUrl, readPhiPngSize, } from "../helpers/phi-signet";
5
+ import { buildPhiSignetAssetIdentity, buildPhiSignetVersion, decodePhiSignetDataUrl, readPhiPngSize, } from "../helpers/phi-signet";
6
6
  import { getResolvedSiteConfig } from "./site-config";
7
- /** An address that names the picture's own content never changes what it answers: a year, immutable. */
7
+ /**
8
+ * An address that names the picture's own content never changes what it answers: a year, immutable. For a
9
+ * library picture that is the identifier built from the Asset's revision, which moves with the bytes.
10
+ */
8
11
  const PHI_SIGNET_CACHE_IDENTIFIED = "public, max-age=31536000, immutable";
9
12
  /**
10
13
  * Everything else: the browser's own `/favicon.ico` and Apple paths, an address whose identifier is not
11
- * the current one, and a library picture, whose identifier cannot see the bytes. Short, so a changed
12
- * Signet reaches the tab within the hour.
14
+ * the current one, and a library picture whose Core states no revision (an older Core), whose identifier
15
+ * cannot see the bytes. Short, so a changed Signet reaches the tab within the hour.
13
16
  */
14
17
  const PHI_SIGNET_CACHE_SHORT = "public, max-age=3600";
15
18
  const PHI_SIGNET_CACHE_MISSING = "public, max-age=300";
@@ -76,7 +79,7 @@ export function buildPhiSignetRouteHandler({ loadAreaBridge, proxied, }) {
76
79
  }
77
80
  else {
78
81
  image = await readPhiSignetAsset(signet.assetId, request, proxied);
79
- identity = `asset:${signet.assetId}`;
82
+ identity = buildPhiSignetAssetIdentity(signet);
80
83
  }
81
84
  if (!image)
82
85
  return missing();
@@ -94,7 +97,9 @@ export function buildPhiSignetRouteHandler({ loadAreaBridge, proxied, }) {
94
97
  headers: {
95
98
  "content-type": image.contentType,
96
99
  "content-length": String(image.bytes.length),
97
- "cache-control": identified && signet.kind === "data" ? PHI_SIGNET_CACHE_IDENTIFIED : PHI_SIGNET_CACHE_SHORT,
100
+ "cache-control": identified && (signet.kind === "data" || signet.revision != null)
101
+ ? PHI_SIGNET_CACHE_IDENTIFIED
102
+ : PHI_SIGNET_CACHE_SHORT,
98
103
  ...PHI_SIGNET_SECURITY_HEADERS,
99
104
  },
100
105
  });
@@ -18,8 +18,9 @@ export type PhiSignetHead = {
18
18
  * into the Media library is what gives that Site an icon there.
19
19
  *
20
20
  * A data URL that does not decode is not named: pointing the tab at an address that answers 404 would
21
- * be worse than leaving the browser its own `/favicon.ico` request. An Asset is named without a type or
22
- * a size, because the picture is not at hand here -- the response carries its type, and the Apple path
23
- * answers for itself from the bytes.
21
+ * be worse than leaving the browser its own `/favicon.ico` request. An Asset is named by its id and, where
22
+ * the Core states it (0.4.1), its revision, type and size -- the bytes are not at hand here. Without those
23
+ * fields (an older Core, a draft) it is named by the id alone and without a type or a size, and the
24
+ * response carries its type; the Apple path answers for itself from the bytes.
24
25
  */
25
26
  export declare function describePhiSignetHead(signet: PhiThemeSignet | null | undefined): PhiSignetHead | null;
@@ -1,5 +1,5 @@
1
1
  import { PHI_SIGNET_APPLE_MIN_SIZE, PHI_SIGNET_PATH, PHI_SIGNET_VERSION_PARAM } from "./phi-signet-paths";
2
- import { buildPhiSignetVersion, decodePhiSignetDataUrl, readPhiPngSize } from "./phi-signet";
2
+ import { buildPhiSignetAssetIdentity, buildPhiSignetVersion, decodePhiSignetDataUrl, readPhiPngSize } from "./phi-signet";
3
3
  function buildPhiSignetHref(version) {
4
4
  return `${PHI_SIGNET_PATH}?${PHI_SIGNET_VERSION_PARAM}=${version}`;
5
5
  }
@@ -11,9 +11,10 @@ function buildPhiSignetHref(version) {
11
11
  * into the Media library is what gives that Site an icon there.
12
12
  *
13
13
  * A data URL that does not decode is not named: pointing the tab at an address that answers 404 would
14
- * be worse than leaving the browser its own `/favicon.ico` request. An Asset is named without a type or
15
- * a size, because the picture is not at hand here -- the response carries its type, and the Apple path
16
- * answers for itself from the bytes.
14
+ * be worse than leaving the browser its own `/favicon.ico` request. An Asset is named by its id and, where
15
+ * the Core states it (0.4.1), its revision, type and size -- the bytes are not at hand here. Without those
16
+ * fields (an older Core, a draft) it is named by the id alone and without a type or a size, and the
17
+ * response carries its type; the Apple path answers for itself from the bytes.
17
18
  */
18
19
  export function describePhiSignetHead(signet) {
19
20
  if (!signet)
@@ -21,7 +22,18 @@ export function describePhiSignetHead(signet) {
21
22
  if (signet.from === "set")
22
23
  return signet.kind === "data" ? { href: signet.source } : null;
23
24
  if (signet.kind === "asset") {
24
- return { href: buildPhiSignetHref(buildPhiSignetVersion(`asset:${signet.assetId}`)) };
25
+ const href = buildPhiSignetHref(buildPhiSignetVersion(buildPhiSignetAssetIdentity(signet)));
26
+ const sizes = signet.width != null && signet.height != null ? `${signet.width}x${signet.height}` : undefined;
27
+ const apple = signet.contentType === "image/png" && signet.width != null && signet.height != null &&
28
+ signet.width >= PHI_SIGNET_APPLE_MIN_SIZE && signet.height >= PHI_SIGNET_APPLE_MIN_SIZE
29
+ ? { href, type: signet.contentType, sizes: sizes }
30
+ : undefined;
31
+ return {
32
+ href,
33
+ ...(signet.contentType ? { type: signet.contentType } : {}),
34
+ ...(sizes ? { sizes } : {}),
35
+ ...(apple ? { apple } : {}),
36
+ };
25
37
  }
26
38
  const image = decodePhiSignetDataUrl(signet.source);
27
39
  if (!image)
@@ -26,3 +26,15 @@ export declare function readPhiPngSize(bytes: Uint8Array): {
26
26
  * (and is therefore delivered with a short cache, see the route).
27
27
  */
28
28
  export declare function buildPhiSignetVersion(identity: Uint8Array | string): string;
29
+ /**
30
+ * What identifies a library picture in the address the head names, and in the route that answers it.
31
+ *
32
+ * With the Asset's revision where the Core states one (Core 0.4.1), so a picture that is replaced gets a
33
+ * new address at once and the address can be cached for a year. Without it, the id alone: the bytes are
34
+ * not known where the head is written, a replaced picture keeps its address, and the route answers it
35
+ * with a short cache.
36
+ */
37
+ export declare function buildPhiSignetAssetIdentity(asset: {
38
+ assetId: number;
39
+ revision?: number;
40
+ }): string;
@@ -57,3 +57,14 @@ export function readPhiPngSize(bytes) {
57
57
  export function buildPhiSignetVersion(identity) {
58
58
  return createHash("sha256").update(identity).digest("hex").slice(0, 10);
59
59
  }
60
+ /**
61
+ * What identifies a library picture in the address the head names, and in the route that answers it.
62
+ *
63
+ * With the Asset's revision where the Core states one (Core 0.4.1), so a picture that is replaced gets a
64
+ * new address at once and the address can be cached for a year. Without it, the id alone: the bytes are
65
+ * not known where the head is written, a replaced picture keeps its address, and the route answers it
66
+ * with a short cache.
67
+ */
68
+ export function buildPhiSignetAssetIdentity(asset) {
69
+ return asset.revision != null ? `asset:${asset.assetId}:r${asset.revision}` : `asset:${asset.assetId}`;
70
+ }
@@ -46,14 +46,16 @@ export declare class PhiProxyPathError extends Error {
46
46
  /**
47
47
  * The upstream response's headers as the browser may see them.
48
48
  *
49
- * `fetch` hands over a body it has already decoded: undici asks for gzip, deflate and br on its own and
50
- * undoes whatever the Server applied. Passing the Server's `content-encoding` on then tells the browser
51
- * to decode plain bytes a second time (`ERR_CONTENT_DECODING_FAILED`), and its `content-length` counts
52
- * the compressed bytes. Both go for a decoded body; the runtime frames the body it actually sends.
53
- * Asking upstream for `identity` instead would rest on the Server honouring it -- this holds either way.
49
+ * Encoding is each hop's own business. This hop to the Server negotiates for itself -- `fetch` asks for
50
+ * gzip, deflate and br on its own and hands over a body it has already decoded
51
+ * (`buildPhiNextProxyHeaders` does not pass the browser's `accept-encoding` on). Passing the Server's
52
+ * `content-encoding` on then tells the browser to decode plain bytes a second time
53
+ * (`ERR_CONTENT_DECODING_FAILED`), and a runtime that compresses route handler responses itself (Next
54
+ * from 16.4.6) would stack a second layer on a body that still claims the first -- or, from 16.4.5, drop
55
+ * the claim and leave a compressed body unlabelled. The `content-length` counts the compressed bytes.
56
+ * Both go for a decoded body; the runtime frames the body it actually sends and compresses towards the
57
+ * browser itself, as nginx does in front of it.
54
58
  */
55
- export declare function buildPhiProxyResponseHeaders(upstream: Headers, options: {
56
- bodyDecoded: boolean;
57
- }): Headers;
59
+ export declare function buildPhiProxyResponseHeaders(upstream: Headers): Headers;
58
60
  export declare function PhiNextProxy(config: PhiNextProxyConfig): PhiNextProxyHandlers;
59
61
  export {};