@phis/ui 0.7.7 → 0.8.0
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-address-control.d.ts +23 -0
- package/components/controls/phi-address-control.js +43 -0
- package/components/controls/phi-color-control.d.ts +3 -1
- package/components/controls/phi-color-control.js +2 -2
- package/components/controls/phi-country-select-control.d.ts +22 -0
- package/components/controls/phi-country-select-control.js +16 -0
- package/components/controls/phi-dialog-control.d.ts +1 -1
- package/components/controls/phi-drawer-control-adapter.d.ts +1 -1
- package/components/controls/phi-drawer-control-adapter.js +5 -3
- package/components/controls/phi-drawer-control.d.ts +7 -5
- package/components/controls/phi-float-button-control.d.ts +8 -1
- package/components/controls/phi-float-button-control.js +19 -3
- package/components/controls/phi-form-control.js +64 -9
- package/components/controls/phi-modal-control-adapter.d.ts +1 -1
- package/components/controls/phi-modal-control-adapter.js +14 -37
- package/components/controls/phi-modal-control.d.ts +5 -5
- package/components/controls/phi-options-provider.d.ts +1 -0
- package/components/controls/phi-options-provider.js +1 -0
- package/components/controls/phi-overlay-control-contract.d.ts +52 -17
- package/components/controls/phi-overlay-control-contract.js +55 -30
- package/components/controls/phi-reveal-once-dialog-control.d.ts +21 -0
- package/components/controls/phi-reveal-once-dialog-control.js +52 -0
- package/components/controls/phi-reveal-once-dialog-labels.d.ts +10 -0
- package/components/controls/phi-reveal-once-dialog-labels.js +5 -0
- package/components/forms/extended-form-field-controls.d.ts +1 -1
- package/components/forms/extended-form-field-controls.js +23 -7
- package/components/forms/flags-field.d.ts +22 -0
- package/components/forms/flags-field.js +58 -0
- package/components/forms/form-option-flags.d.ts +20 -0
- package/components/forms/form-option-flags.js +38 -0
- package/components/forms/form-provider-contract.d.ts +28 -0
- package/components/forms/form-provider-contract.js +45 -2
- package/components/forms/form-provider-registry.d.ts +11 -1
- package/components/forms/money-field-currency-key.d.ts +6 -0
- package/components/forms/money-field-currency-key.js +14 -0
- package/components/forms/money-field.d.ts +26 -3
- package/components/forms/money-field.js +54 -4
- package/components/forms/shared-form-provider-registry.js +13 -0
- package/components/forms/structured-field-labels.d.ts +24 -0
- package/components/forms/structured-field-labels.js +43 -0
- package/components/forms/structured-form-field-controls.d.ts +12 -0
- package/components/forms/structured-form-field-controls.js +65 -0
- package/components/overlays/phi-overlay-container-client.js +2 -2
- package/components/regions/phi-cms-region-shell.js +2 -2
- package/components/regions/presets/content-entry-editor-page-tree.js +12 -3
- package/components/regions/presets/navigation-redirect.d.ts +4 -1
- package/components/regions/presets/navigation-redirect.js +6 -3
- package/components/regions/presets/phi-settings-page-shell-tree.d.ts +6 -2
- package/components/regions/presets/phi-settings-page-shell-tree.js +1 -1
- package/components/root/phi-root-theme-resolver.js +3 -0
- package/components/shell/phi-antd-icon.d.ts +1 -8
- package/components/shell/phi-antd-icon.js +1 -227
- package/components/shell/phi-icon-names.d.ts +19 -0
- package/components/shell/phi-icon-names.js +264 -0
- package/components/shell/phi-icon.d.ts +2 -11
- package/components/shell/phi-icon.js +4 -32
- package/components/widgets/client/shared/phi-command-buttons.d.ts +13 -2
- package/components/widgets/client/shared/phi-command-buttons.js +10 -4
- package/components/widgets/client/shared/phi-rendered-value.js +32 -6
- package/components/widgets/client/shared/phi-table-provider-refusal.d.ts +13 -0
- package/components/widgets/client/shared/phi-table-provider-refusal.js +13 -0
- package/components/widgets/config/background.d.ts +3 -2
- package/components/widgets/config/choice-shared.d.ts +10 -1
- package/components/widgets/config/choice-shared.js +8 -2
- package/components/widgets/label-sets/admin-locales.js +1 -1
- package/components/widgets/label-sets/admin-users.d.ts +2 -5
- package/components/widgets/label-sets/admin-users.js +4 -10
- package/components/widgets/label-sets/effects.js +2 -4
- package/components/widgets/label-sets/profile.d.ts +13 -0
- package/components/widgets/label-sets/profile.js +28 -0
- package/components/widgets/label-sets/search-results.js +2 -4
- package/components/widgets/label-sets/table.js +9 -0
- package/components/widgets/label-types/effects.d.ts +3 -2
- package/components/widgets/label-types/effects.js +1 -2
- package/components/widgets/label-types/search-results.d.ts +2 -2
- package/components/widgets/label-types/search-results.js +1 -2
- package/components/widgets/label-types/table.d.ts +3 -0
- package/components/widgets/label-types/table.js +2 -0
- package/components/widgets/server/builder-chrome.d.ts +4 -1
- package/components/widgets/server/builder-chrome.js +2 -2
- package/components/widgets/shared/markdown-body-client.d.ts +26 -0
- package/components/widgets/shared/markdown-body-client.js +31 -1
- package/components/widgets/shared/markdown-render.d.ts +10 -2
- package/components/widgets/shared/markdown-render.js +35 -13
- package/constants/countries.d.ts +9 -0
- package/constants/countries.js +28 -0
- package/constants/customer-file.d.ts +25 -0
- package/constants/customer-file.js +26 -0
- package/constants/record-field-kinds.d.ts +15 -0
- package/constants/record-field-kinds.js +13 -0
- package/constants/runtime-module-ownership.js +12 -0
- package/constants/runtime-render-client-types.d.ts +5 -0
- package/constants/runtime-render-client-types.js +5 -0
- package/{plugins/runtime-modules/threads/controller/address.js → constants/threads-controller-address.js} +1 -1
- package/constants.d.ts +1 -0
- package/constants.js +2 -0
- package/gateway/form-handler-request.d.ts +22 -0
- package/gateway/form-handler-request.js +40 -0
- package/gateway/label-set.d.ts +15 -2
- package/gateway/label-set.js +60 -22
- package/gateway/site-form-route.js +11 -2
- package/helpers/address-field.d.ts +43 -0
- package/helpers/address-field.js +68 -0
- package/helpers/cms-dialog.d.ts +5 -20
- package/helpers/cms-dialog.js +8 -13
- package/helpers/cms-page-catalog.d.ts +10 -0
- package/helpers/cms-page-catalog.js +19 -0
- package/helpers/cms-preset-nodes.d.ts +4 -4
- package/helpers/cms-preset-nodes.js +1 -1
- package/helpers/cms-region-keys.d.ts +1 -1
- package/helpers/country-names.d.ts +12 -0
- package/helpers/country-names.js +14 -0
- package/helpers/money-amount.d.ts +7 -0
- package/helpers/money-amount.js +15 -0
- package/helpers/phi-metadata.d.ts +33 -1
- package/helpers/phi-metadata.js +62 -1
- package/helpers/preset-table-check.d.ts +34 -0
- package/helpers/preset-table-check.js +124 -0
- package/helpers/preset-text-source-check.d.ts +4 -1
- package/helpers/preset-text-source-check.js +6 -1
- package/helpers/preset-tree-contract-check.d.ts +3 -2
- package/helpers/preset-tree-contract-check.js +30 -5
- package/helpers/public-route-claims.d.ts +9 -1
- package/helpers/public-route-claims.js +23 -3
- package/helpers/record-fields.d.ts +1 -5
- package/helpers/record-fields.js +15 -6
- package/helpers/route-address-check.d.ts +22 -2
- package/helpers/route-address-check.js +29 -8
- package/helpers/site-address-row.d.ts +23 -0
- package/helpers/site-address-row.js +36 -0
- package/helpers/surface-style.d.ts +8 -1
- package/helpers/surface-style.js +12 -2
- package/helpers/thread-inbox-row.d.ts +20 -0
- package/helpers/thread-inbox-row.js +26 -0
- package/helpers/translation-format.d.ts +26 -0
- package/helpers/translation-format.js +31 -0
- package/module-labels.d.ts +1 -1
- package/module-labels.js +1 -1
- package/module-page-check.d.ts +1 -0
- package/module-page-check.js +1 -0
- package/module-records.d.ts +2 -2
- package/module-records.js +1 -0
- package/next/area-route.js +34 -1
- package/next/root-route.js +4 -5
- package/package.json +2 -2
- package/plugins/runtime-modules/accounting/customer-file-access.d.ts +11 -0
- package/plugins/runtime-modules/accounting/customer-file-access.js +12 -0
- package/plugins/runtime-modules/accounting/data-providers.js +1 -1
- package/plugins/runtime-modules/accounting/ids.d.ts +11 -0
- package/plugins/runtime-modules/accounting/ids.js +23 -0
- package/plugins/runtime-modules/accounting/presets.js +32 -5
- package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.d.ts +66 -0
- package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.js +122 -0
- package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.js +2 -2
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.d.ts +26 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.js +381 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.js +4 -0
- package/plugins/runtime-modules/app/client-data-providers.d.ts +7 -0
- package/plugins/runtime-modules/app/client-data-providers.js +9 -0
- package/plugins/runtime-modules/app/data-providers.d.ts +98 -0
- package/plugins/runtime-modules/app/data-providers.js +80 -0
- package/plugins/runtime-modules/app/definition.d.ts +131 -0
- package/plugins/runtime-modules/app/definition.js +2 -0
- package/plugins/runtime-modules/app/forms.d.ts +46 -1
- package/plugins/runtime-modules/app/forms.js +195 -1
- package/plugins/runtime-modules/app/ids.d.ts +7 -0
- package/plugins/runtime-modules/app/ids.js +8 -0
- package/plugins/runtime-modules/app/module.d.ts +131 -0
- package/plugins/runtime-modules/app/presets.js +3 -6
- package/plugins/runtime-modules/app/services/addresses-table.d.ts +135 -0
- package/plugins/runtime-modules/app/services/addresses-table.js +101 -0
- package/plugins/runtime-modules/app/trees/account-addresses-panel.d.ts +17 -0
- package/plugins/runtime-modules/app/trees/account-addresses-panel.js +179 -0
- package/plugins/runtime-modules/app/trees/addresses-label-set.d.ts +62 -0
- package/plugins/runtime-modules/app/trees/addresses-label-set.js +108 -0
- package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.d.ts +3 -6
- package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.js +4 -7
- package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.js +27 -2
- package/plugins/runtime-modules/app/trees/profile-label-set.d.ts +1 -0
- package/plugins/runtime-modules/app/trees/profile-label-set.js +3 -0
- package/plugins/runtime-modules/asset/presets.d.ts +4 -0
- package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +4 -2
- package/plugins/runtime-modules/auth/trees/phi-auth-area-overlay-tree.server.js +4 -2
- package/plugins/runtime-modules/auth/trees/phi-default-admin-auth-settings-page-tree.js +2 -2
- package/plugins/runtime-modules/auth/widgets/logout/client.d.ts +1 -1
- package/plugins/runtime-modules/auth/widgets/logout/client.js +2 -2
- package/plugins/runtime-modules/auth/widgets/security/client.d.ts +5 -1
- package/plugins/runtime-modules/auth/widgets/security/client.js +12 -10
- package/plugins/runtime-modules/avatar/overlay-tree.server.js +1 -1
- package/plugins/runtime-modules/blog/presets.d.ts +4 -0
- package/plugins/runtime-modules/builder/clients/inspector-image-field.d.ts +2 -1
- package/plugins/runtime-modules/builder/clients/inspector-image-field.js +3 -2
- package/plugins/runtime-modules/builder/clients/metadata-table-provider-stand-ins.d.ts +23 -0
- package/plugins/runtime-modules/builder/clients/metadata-table-provider-stand-ins.js +38 -0
- package/plugins/runtime-modules/builder/clients/mode-switch.d.ts +4 -1
- package/plugins/runtime-modules/builder/clients/mode-switch.js +2 -15
- package/plugins/runtime-modules/builder/clients/pages-workspace.js +2 -0
- package/plugins/runtime-modules/builder/clients/runtime-module-authoring-boundary.js +2 -1
- package/plugins/runtime-modules/builder/controller/client.d.ts +5 -5
- package/plugins/runtime-modules/builder/controller/client.js +2 -1
- package/plugins/runtime-modules/builder/controller/definition.d.ts +4 -4
- package/plugins/runtime-modules/builder/controller/definition.js +7 -0
- package/plugins/runtime-modules/builder/controller/draft-command-controller.d.ts +3 -1
- package/plugins/runtime-modules/builder/controller/draft-command-controller.js +2 -1
- package/plugins/runtime-modules/builder/controller/draft-status-controller.js +72 -18
- package/plugins/runtime-modules/builder/controller/server-definition.d.ts +4 -4
- package/plugins/runtime-modules/builder/controller/workspace-controller.d.ts +3 -1
- package/plugins/runtime-modules/builder/controller/workspace-controller.js +8 -10
- package/plugins/runtime-modules/builder/developer-workspace-store.d.ts +10 -0
- package/plugins/runtime-modules/builder/developer-workspace-store.js +35 -1
- package/plugins/runtime-modules/builder/developer-workspace-types.d.ts +5 -0
- package/plugins/runtime-modules/builder/offered-page-catalog.d.ts +6 -0
- package/plugins/runtime-modules/builder/offered-page-catalog.js +35 -6
- package/plugins/runtime-modules/builder/page-presets.server.d.ts +7 -0
- package/plugins/runtime-modules/builder/page-presets.server.js +10 -1
- package/plugins/runtime-modules/builder/persistence.d.ts +4 -1
- package/plugins/runtime-modules/builder/persistence.js +14 -3
- package/plugins/runtime-modules/builder/public-route-collisions.js +8 -3
- package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +3 -1
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +33 -6
- package/plugins/runtime-modules/builder/widgets/chrome/config.d.ts +6 -4
- package/plugins/runtime-modules/builder/widgets/chrome/config.js +11 -1
- package/plugins/runtime-modules/builder/widgets/inspector-header/authoring.d.ts +2 -2
- package/plugins/runtime-modules/builder/widgets/inspector-header/plugin.d.ts +2 -2
- package/plugins/runtime-modules/builder/widgets/mode-switch/plugin.js +1 -1
- package/plugins/runtime-modules/builder/widgets/structure-region/built-in.js +2 -2
- package/plugins/runtime-modules/client-manifests/app.js +3 -0
- package/plugins/runtime-modules/client-manifests/builder.js +10 -0
- package/plugins/runtime-modules/content-entry-routes.d.ts +4 -0
- package/plugins/runtime-modules/contracts.js +31 -1
- package/plugins/runtime-modules/core/definition.d.ts +28 -0
- package/plugins/runtime-modules/core/form-providers.d.ts +28 -0
- package/plugins/runtime-modules/core/messaging/thread-inbox-table.d.ts +0 -17
- package/plugins/runtime-modules/core/messaging/thread-inbox-table.js +2 -23
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +0 -1
- package/plugins/runtime-modules/core/widgets/card/config.js +0 -1
- package/plugins/runtime-modules/core/widgets/card/editor.js +1 -1
- package/plugins/runtime-modules/core/widgets/command-toolbar/client.js +3 -0
- package/plugins/runtime-modules/core/widgets/command-toolbar/config.d.ts +316 -1
- package/plugins/runtime-modules/core/widgets/command-toolbar/config.js +4 -4
- package/plugins/runtime-modules/core/widgets/dimension/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/float-button/client.js +4 -1
- package/plugins/runtime-modules/core/widgets/float-button/config.d.ts +326 -3
- package/plugins/runtime-modules/core/widgets/float-button/config.js +5 -2
- package/plugins/runtime-modules/core/widgets/header-navigation/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/length/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/markdown/plugin.js +20 -7
- package/plugins/runtime-modules/core/widgets/markdown/server.d.ts +6 -2
- package/plugins/runtime-modules/core/widgets/markdown/server.js +2 -2
- package/plugins/runtime-modules/core/widgets/markdown/table-embeds.server.d.ts +12 -0
- package/plugins/runtime-modules/core/widgets/markdown/table-embeds.server.js +68 -0
- package/plugins/runtime-modules/core/widgets/number-input/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +2 -1
- package/plugins/runtime-modules/core/widgets/spacer/client.js +3 -3
- package/plugins/runtime-modules/core/widgets/table/client.js +20 -5
- package/plugins/runtime-modules/core/widgets/table/config.js +6 -0
- package/plugins/runtime-modules/core/widgets/table/reader-query.d.ts +17 -0
- package/plugins/runtime-modules/core/widgets/table/reader-query.js +33 -0
- package/plugins/runtime-modules/dashboard/trees/dashboard-cards-page-tree.js +3 -1
- package/plugins/runtime-modules/descriptor-compiler.d.ts +19 -3
- package/plugins/runtime-modules/descriptor-compiler.js +44 -16
- package/plugins/runtime-modules/editor/presets.d.ts +4 -0
- package/plugins/runtime-modules/editor/trees/phi-default-editor-releases-page-tree.js +3 -1
- package/plugins/runtime-modules/groups/trees/phi-default-admin-groups-page-tree.js +5 -1
- package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +5 -1
- package/plugins/runtime-modules/localization/presets.d.ts +4 -0
- package/plugins/runtime-modules/localization/trees/phi-default-admin-locales-page-tree.js +3 -1
- package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +4 -2
- package/plugins/runtime-modules/news/presets.d.ts +4 -0
- package/plugins/runtime-modules/observability/trees/phi-default-admin-logs-page-tree.js +6 -2
- package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +46 -39
- package/plugins/runtime-modules/preset-contracts/pub-area.d.ts +1 -1
- package/plugins/runtime-modules/preset-contracts/pub-area.js +1 -0
- package/plugins/runtime-modules/resolver.js +17 -0
- package/plugins/runtime-modules/revisions/controller/client.js +50 -46
- package/plugins/runtime-modules/revisions/controller/draft-context-target.d.ts +25 -0
- package/plugins/runtime-modules/revisions/controller/draft-context-target.js +33 -0
- package/plugins/runtime-modules/revisions/presets.d.ts +4 -0
- package/plugins/runtime-modules/revisions/services/table.js +16 -5
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +3 -1
- package/plugins/runtime-modules/search/widgets/search-results/client.js +4 -2
- package/plugins/runtime-modules/theme/presets.d.ts +4 -0
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +76 -4
- package/plugins/runtime-modules/theme/widgets/brand-controls/config.d.ts +3 -2
- package/plugins/runtime-modules/theme/widgets/brand-controls/config.js +2 -2
- package/plugins/runtime-modules/theme/widgets/brand-controls/plugin.js +19 -7
- package/plugins/runtime-modules/threads/client-data-providers.js +5 -0
- package/plugins/runtime-modules/threads/controller/definition.js +1 -1
- package/plugins/runtime-modules/threads/data-providers.d.ts +115 -2
- package/plugins/runtime-modules/threads/data-providers.js +85 -0
- package/plugins/runtime-modules/threads/definition.d.ts +115 -2
- package/plugins/runtime-modules/threads/definition.js +1 -1
- package/plugins/runtime-modules/threads/ids.d.ts +2 -0
- package/plugins/runtime-modules/threads/ids.js +3 -0
- package/plugins/runtime-modules/threads/services/customer-file-table.d.ts +192 -0
- package/plugins/runtime-modules/threads/services/customer-file-table.js +164 -0
- package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +5 -3
- package/plugins/runtime-modules/user-management/client-data-providers.js +5 -0
- package/plugins/runtime-modules/user-management/data-providers.d.ts +159 -0
- package/plugins/runtime-modules/user-management/data-providers.js +101 -3
- package/plugins/runtime-modules/user-management/definition.d.ts +159 -0
- package/plugins/runtime-modules/user-management/ids.d.ts +9 -0
- package/plugins/runtime-modules/user-management/ids.js +9 -0
- package/plugins/runtime-modules/user-management/presets.js +17 -1
- package/plugins/runtime-modules/user-management/services/users-access-table.d.ts +378 -0
- package/plugins/runtime-modules/user-management/services/users-access-table.js +132 -0
- package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.d.ts +86 -0
- package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.js +118 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-access-page-tree.d.ts +20 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-access-page-tree.js +166 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +19 -18
- package/server-helpers/cms-page-record.d.ts +9 -1
- package/server-helpers/cms-page-record.js +11 -1
- package/server-helpers/cms-request.js +8 -5
- package/server-helpers/link-preview-image.d.ts +30 -0
- package/server-helpers/link-preview-image.js +57 -0
- package/server-helpers/search-text.js +3 -0
- package/server-helpers.d.ts +1 -1
- package/server-helpers.js +1 -1
- package/styles/builder-scaffold.css +7 -1
- package/styles/layout-authoring-scaffold.css +27 -0
- package/styles/shell.css +30 -6
- package/theme/phi-theme-composition.js +9 -0
- package/theme/phi-theme-inverse-ground.d.ts +39 -0
- package/theme/phi-theme-inverse-ground.js +103 -0
- package/theme/phi-theme-tokens.d.ts +2 -1
- package/theme/phi-theme-tokens.js +2 -0
- package/types/cms-module-descriptors.d.ts +14 -0
- package/types/cms-overlay.d.ts +13 -6
- package/types/cms-overlay.js +6 -22
- package/types/cms-plugins.d.ts +14 -2
- package/types/cms.d.ts +10 -0
- package/types/core-widget-placements.d.ts +3 -3
- package/types/link-preview.d.ts +19 -0
- package/types/link-preview.js +19 -0
- package/types/record-provider.d.ts +22 -1
- package/types/site-theme.d.ts +27 -0
- package/types/table-embed.d.ts +48 -0
- package/types/table-embed.js +1 -0
- package/types/table-widget.d.ts +14 -0
- package/types/widget-runtime.d.ts +3 -0
- package/types.d.ts +1 -0
- /package/{plugins/runtime-modules/threads/controller/address.d.ts → constants/threads-controller-address.d.ts} +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { PhiBlockRuntime, PhiRenderableBlockRenderMode } from "../../../types";
|
|
2
2
|
import type { PhiCmsResolvedContent } from "../../../types/cms";
|
|
3
3
|
import type { PhiMarkdownTocHeading } from "../../../types/markdown";
|
|
4
|
-
import type { PhiMarkdownBlock } from "./markdown-body-client";
|
|
4
|
+
import type { PhiMarkdownBlock, PhiMarkdownTableEmbed } from "./markdown-body-client";
|
|
5
5
|
import type { PhiMarkdownImageFloat } from "../../../types/core-widget-placements";
|
|
6
6
|
import { type PhiMarkdownImageAspectRatio, type PhiMarkdownImageFloatWidth } from "./markdown-image-vocabulary";
|
|
7
|
+
import type { PhiTableEmbedReference } from "../../../types/table-embed";
|
|
7
8
|
/**
|
|
8
9
|
* Where Markdown comes from and how it is turned into blocks: inline text, a stored content field, or a
|
|
9
10
|
* document fetched by URL, translated or not, with heading ids under a prefix of its own.
|
|
@@ -39,6 +40,11 @@ export type PhiMarkdownSourceConfig = {
|
|
|
39
40
|
imageFloat?: PhiMarkdownImageFloat;
|
|
40
41
|
imageFloatWidth?: PhiMarkdownImageFloatWidth;
|
|
41
42
|
};
|
|
43
|
+
/** Who draws a text's Table embeds (TABLES.md); absent, each is its caption. */
|
|
44
|
+
export type PhiMarkdownTableEmbedResolver = (embeds: readonly {
|
|
45
|
+
caption: string;
|
|
46
|
+
reference: PhiTableEmbedReference;
|
|
47
|
+
}[]) => Promise<readonly PhiMarkdownTableEmbed[]>;
|
|
42
48
|
export type MarkdownRenderData = {
|
|
43
49
|
blocks: PhiMarkdownBlock[];
|
|
44
50
|
headings: PhiMarkdownTocHeading[];
|
|
@@ -51,7 +57,9 @@ type ResolvedMarkdownSource = {
|
|
|
51
57
|
message: string;
|
|
52
58
|
};
|
|
53
59
|
export declare function resolveMarkdownSource(config: PhiMarkdownSourceConfig | undefined, publicUrl: string | null | undefined): Promise<ResolvedMarkdownSource>;
|
|
54
|
-
export declare function resolveMarkdownRenderData(config: PhiMarkdownSourceConfig | undefined, runtime?: Pick<PhiBlockRuntime, "site" | "locale" | "area" | "viewer"
|
|
60
|
+
export declare function resolveMarkdownRenderData(config: PhiMarkdownSourceConfig | undefined, runtime?: Pick<PhiBlockRuntime, "site" | "locale" | "area" | "viewer">, options?: {
|
|
61
|
+
tableEmbeds?: PhiMarkdownTableEmbedResolver;
|
|
62
|
+
}): Promise<MarkdownRenderData | {
|
|
55
63
|
error: string;
|
|
56
64
|
}>;
|
|
57
65
|
export {};
|
|
@@ -113,6 +113,7 @@ async function projectInternalMarkdownNodes(tree, runtime) {
|
|
|
113
113
|
const pageReferences = [];
|
|
114
114
|
const assetIds = [];
|
|
115
115
|
const figures = new Map();
|
|
116
|
+
const embeds = new Map();
|
|
116
117
|
const collect = (nodes) => {
|
|
117
118
|
for (const node of nodes ?? []) {
|
|
118
119
|
if (node.type === "link" || node.type === "image") {
|
|
@@ -127,8 +128,8 @@ async function projectInternalMarkdownNodes(tree, runtime) {
|
|
|
127
128
|
};
|
|
128
129
|
collect(tree.children);
|
|
129
130
|
const resolved = await resolvePhiWidgetInternalReferences({ runtime, pageReferences, assetIds });
|
|
130
|
-
const project = (nodes) => (nodes ?? []).flatMap((node) => {
|
|
131
|
-
const children = project(node.children);
|
|
131
|
+
const project = (nodes, lone = false) => (nodes ?? []).flatMap((node) => {
|
|
132
|
+
const children = project(node.children, node.type === "paragraph" && node.children?.filter((child) => child.value?.trim() !== "").length === 1);
|
|
132
133
|
if (node.type === "link") {
|
|
133
134
|
const reference = readPhiInternalReference(node.url);
|
|
134
135
|
if (reference?.kind === "page") {
|
|
@@ -140,6 +141,15 @@ async function projectInternalMarkdownNodes(tree, runtime) {
|
|
|
140
141
|
return [{ ...node, children }];
|
|
141
142
|
}
|
|
142
143
|
if (node.type === "image") {
|
|
144
|
+
// A Module's Table (TABLES.md): alone in a paragraph it keeps an address, as a figure does; else its caption.
|
|
145
|
+
const table = node.url?.trim().match(/^phis:table\/([^?]*)\??(.*)$/su);
|
|
146
|
+
if (table && !lone)
|
|
147
|
+
return [{ type: "text", value: node.alt ?? "" }];
|
|
148
|
+
if (table) {
|
|
149
|
+
const src = `phi-table-embed:${embeds.size}`;
|
|
150
|
+
embeds.set(src, { embedKey: table[1], params: [...new URLSearchParams(table[2])] });
|
|
151
|
+
return [{ ...node, url: src, children }];
|
|
152
|
+
}
|
|
143
153
|
const address = readPhiMarkdownImageAddress(node.url ?? "");
|
|
144
154
|
const reference = readPhiInternalReference(address.reference);
|
|
145
155
|
if (reference?.kind === "asset") {
|
|
@@ -166,26 +176,32 @@ async function projectInternalMarkdownNodes(tree, runtime) {
|
|
|
166
176
|
return [{ ...node, ...(node.children ? { children } : {}) }];
|
|
167
177
|
});
|
|
168
178
|
tree.children = project(tree.children);
|
|
169
|
-
return figures;
|
|
179
|
+
return { figures, embeds };
|
|
170
180
|
}
|
|
171
181
|
/*
|
|
172
182
|
* A paragraph that is one Media picture and nothing else is a figure: a block of its own, drawn by the
|
|
173
183
|
* house's picture Control -- optimised, sized, its box reserved and its corners the Theme's. A picture in
|
|
174
|
-
* the middle of a sentence, or one on somebody else's server, stays the plain picture it was.
|
|
184
|
+
* the middle of a sentence, or one on somebody else's server, stays the plain picture it was. A lone embed is a Table.
|
|
175
185
|
*/
|
|
176
|
-
function promoteMarkdownFigures(blocks, figures, defaults) {
|
|
177
|
-
if (figures.size === 0)
|
|
186
|
+
function promoteMarkdownFigures(blocks, figures, defaults, embeds, found) {
|
|
187
|
+
if (figures.size + embeds.size === 0)
|
|
178
188
|
return blocks;
|
|
179
189
|
return blocks.map((block) => {
|
|
180
190
|
if (block.kind === "blockquote")
|
|
181
|
-
return { ...block, children: promoteMarkdownFigures(block.children, figures, defaults) };
|
|
191
|
+
return { ...block, children: promoteMarkdownFigures(block.children, figures, defaults, embeds, found) };
|
|
182
192
|
if (block.kind === "list")
|
|
183
|
-
return { ...block, items: block.items.map((item) => promoteMarkdownFigures(item, figures, defaults)) };
|
|
193
|
+
return { ...block, items: block.items.map((item) => promoteMarkdownFigures(item, figures, defaults, embeds, found)) };
|
|
184
194
|
if (block.kind !== "paragraph")
|
|
185
195
|
return block;
|
|
186
196
|
const content = block.inlines.filter((inline) => !(inline.kind === "text" && !inline.text.trim()));
|
|
187
197
|
const only = content.length === 1 ? content[0] : null;
|
|
188
198
|
const source = only?.kind === "image" ? figures.get(only.src) : undefined;
|
|
199
|
+
const reference = only?.kind === "image" ? embeds.get(only.src) : undefined;
|
|
200
|
+
if (only?.kind === "image" && reference) {
|
|
201
|
+
const embed = { kind: "table_embed", caption: only.alt.trim(), table: null, notice: null };
|
|
202
|
+
found.push([embed, reference]);
|
|
203
|
+
return embed;
|
|
204
|
+
}
|
|
189
205
|
if (!only || only.kind !== "image" || !source)
|
|
190
206
|
return block;
|
|
191
207
|
return { kind: "image", image: buildMarkdownFigure(only, source, defaults) };
|
|
@@ -459,7 +475,7 @@ export async function resolveMarkdownSource(config, publicUrl) {
|
|
|
459
475
|
const resolvedMarkdown = config.resolvedContent?.textFields.markdown?.source?.trim() ?? "";
|
|
460
476
|
return { ok: true, markdown: resolvedMarkdown || inlineMarkdown };
|
|
461
477
|
}
|
|
462
|
-
export async function resolveMarkdownRenderData(config, runtime) {
|
|
478
|
+
export async function resolveMarkdownRenderData(config, runtime, options = {}) {
|
|
463
479
|
const resolvedSource = await resolveMarkdownSource(config, runtime?.site.publicUrl);
|
|
464
480
|
if (!resolvedSource.ok) {
|
|
465
481
|
return { error: resolvedSource.message };
|
|
@@ -491,9 +507,9 @@ export async function resolveMarkdownRenderData(config, runtime) {
|
|
|
491
507
|
...(config?.imageAspectRatio ? { aspectRatio: config.imageAspectRatio } : {}),
|
|
492
508
|
...(config?.imageFloat ? { float: config.imageFloat } : {}),
|
|
493
509
|
...(config?.imageFloatWidth ? { floatWidth: config.imageFloatWidth } : {}),
|
|
494
|
-
});
|
|
510
|
+
}, options.tableEmbeds);
|
|
495
511
|
}
|
|
496
|
-
async function resolveMarkdownRenderDataFromSource(markdown, translate, headingIdPrefix, sourceLocale, sourceMode = "inline", sourceUrl = null, runtime, extent = "document", headingOffset = 0, imageDefaults = {}) {
|
|
512
|
+
async function resolveMarkdownRenderDataFromSource(markdown, translate, headingIdPrefix, sourceLocale, sourceMode = "inline", sourceUrl = null, runtime, extent = "document", headingOffset = 0, imageDefaults = {}, tableEmbeds) {
|
|
497
513
|
const tree = parseMarkdown(markdown);
|
|
498
514
|
if (extent === "first-paragraph") {
|
|
499
515
|
// Cut by the parser's own reading, never by blank lines: a fence or a list may hold those too.
|
|
@@ -501,11 +517,12 @@ async function resolveMarkdownRenderDataFromSource(markdown, translate, headingI
|
|
|
501
517
|
tree.children = paragraph ? [paragraph] : [];
|
|
502
518
|
}
|
|
503
519
|
let figures = new Map();
|
|
520
|
+
let embeds = new Map();
|
|
504
521
|
if (sourceMode === "url" && sourceUrl) {
|
|
505
522
|
tree.children = projectExternalMarkdownNodes(tree.children, sourceUrl);
|
|
506
523
|
}
|
|
507
524
|
else if (runtime) {
|
|
508
|
-
figures = await projectInternalMarkdownNodes(tree, runtime);
|
|
525
|
+
({ figures, embeds } = await projectInternalMarkdownNodes(tree, runtime));
|
|
509
526
|
}
|
|
510
527
|
const context = {
|
|
511
528
|
sourceLines: markdown.split(/\r?\n/),
|
|
@@ -515,7 +532,12 @@ async function resolveMarkdownRenderDataFromSource(markdown, translate, headingI
|
|
|
515
532
|
headingOffset,
|
|
516
533
|
};
|
|
517
534
|
const inlineMap = await buildMarkdownInlineMap(tree, translate, sourceLocale, runtime?.locale.current, runtime);
|
|
518
|
-
const
|
|
535
|
+
const found = [];
|
|
536
|
+
const blocks = promoteMarkdownFigures(protectMarkdownMail(mapBlockNodes(tree.children, context, inlineMap)), figures, imageDefaults, embeds, found);
|
|
537
|
+
if (found.length > 0 && tableEmbeds) {
|
|
538
|
+
const answers = await tableEmbeds(found.map(([block, reference]) => ({ caption: block.caption, reference })));
|
|
539
|
+
found.forEach(([block], index) => Object.assign(block, answers[index]));
|
|
540
|
+
}
|
|
519
541
|
return { blocks, headings: context.headings };
|
|
520
542
|
}
|
|
521
543
|
/*
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every country and territory of ISO 3166-1 by its alpha-2 code (249, in code order), as the `country` and
|
|
3
|
+
* `address` Form fields offer them and as phis-server stores an address's country (`PhisSiteAddress.country`).
|
|
4
|
+
* Names are not kept here: a field shows each in the reader's language through `Intl.DisplayNames`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PHI_ISO_3166_ALPHA2_CODES: readonly ["AD", "AE", "AF", "AG", "AI", "AL", "AM", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW"];
|
|
7
|
+
export type PhiCountryCode = (typeof PHI_ISO_3166_ALPHA2_CODES)[number];
|
|
8
|
+
/** The code as stored -- two capital letters of ISO 3166-1 alpha-2 -- or null for anything else. */
|
|
9
|
+
export declare function readPhiCountryCode(value: unknown): PhiCountryCode | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every country and territory of ISO 3166-1 by its alpha-2 code (249, in code order), as the `country` and
|
|
3
|
+
* `address` Form fields offer them and as phis-server stores an address's country (`PhisSiteAddress.country`).
|
|
4
|
+
* Names are not kept here: a field shows each in the reader's language through `Intl.DisplayNames`.
|
|
5
|
+
*/
|
|
6
|
+
export const PHI_ISO_3166_ALPHA2_CODES = [
|
|
7
|
+
"AD", "AE", "AF", "AG", "AI", "AL", "AM", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ",
|
|
8
|
+
"BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS",
|
|
9
|
+
"BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN",
|
|
10
|
+
"CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE",
|
|
11
|
+
"EG", "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF",
|
|
12
|
+
"GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM",
|
|
13
|
+
"HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM",
|
|
14
|
+
"JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC",
|
|
15
|
+
"LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK",
|
|
16
|
+
"ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA",
|
|
17
|
+
"NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG",
|
|
18
|
+
"PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW",
|
|
19
|
+
"SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS",
|
|
20
|
+
"ST", "SV", "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO",
|
|
21
|
+
"TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI",
|
|
22
|
+
"VN", "VU", "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW",
|
|
23
|
+
];
|
|
24
|
+
const PHI_COUNTRY_CODE_SET = new Set(PHI_ISO_3166_ALPHA2_CODES);
|
|
25
|
+
/** The code as stored -- two capital letters of ISO 3166-1 alpha-2 -- or null for anything else. */
|
|
26
|
+
export function readPhiCountryCode(value) {
|
|
27
|
+
return typeof value === "string" && PHI_COUNTRY_CODE_SET.has(value) ? value : null;
|
|
28
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Staff's customer file on one member (phis-server `GET /api/site/members/{userId}/file`) as a Foundation
|
|
3
|
+
* contract, on the terms of `thread-library-provider-keys.ts`: the conversations Module answers the Table
|
|
4
|
+
* Provider (`constants/runtime-module-ownership.ts`), and a Page of another Module binds it by these names
|
|
5
|
+
* without importing the conversations Module -- the Accounting Module's customer file does, and a Module
|
|
6
|
+
* offering its own file over the same Core route (Support's, for a Supporter) does the same. Whether
|
|
7
|
+
* anything answers the key is decided by the installation: the conversations Module must be active in the
|
|
8
|
+
* Area the Page stands in.
|
|
9
|
+
*/
|
|
10
|
+
export declare const PHI_CUSTOMER_FILE_DATA_PROVIDER_KEYS: {
|
|
11
|
+
readonly table: `${string}/${string}`;
|
|
12
|
+
};
|
|
13
|
+
/** The Provider's three resources, each one answer of the same route read for one member. */
|
|
14
|
+
export declare const PHI_CUSTOMER_FILE_RESOURCE_KEYS: {
|
|
15
|
+
readonly person: "person";
|
|
16
|
+
readonly addresses: "addresses";
|
|
17
|
+
readonly threads: "threads";
|
|
18
|
+
};
|
|
19
|
+
/** The binding param a customer file Page writes the file's own subject into, already in the reader's language. */
|
|
20
|
+
export declare const PHI_CUSTOMER_FILE_SUBJECT_PARAM = "fileSubject";
|
|
21
|
+
/**
|
|
22
|
+
* The binding param a customer file Page writes its sentence for the reader's own file into, already in the
|
|
23
|
+
* reader's language: Core refuses that file (`403`), and each Table says this where its rows would be.
|
|
24
|
+
*/
|
|
25
|
+
export declare const PHI_CUSTOMER_FILE_OWN_FILE_PARAM = "ownFileNotice";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createPhiSharedRuntimeDataProviderKey } from "./runtime-data-provider-key";
|
|
2
|
+
/**
|
|
3
|
+
* Staff's customer file on one member (phis-server `GET /api/site/members/{userId}/file`) as a Foundation
|
|
4
|
+
* contract, on the terms of `thread-library-provider-keys.ts`: the conversations Module answers the Table
|
|
5
|
+
* Provider (`constants/runtime-module-ownership.ts`), and a Page of another Module binds it by these names
|
|
6
|
+
* without importing the conversations Module -- the Accounting Module's customer file does, and a Module
|
|
7
|
+
* offering its own file over the same Core route (Support's, for a Supporter) does the same. Whether
|
|
8
|
+
* anything answers the key is decided by the installation: the conversations Module must be active in the
|
|
9
|
+
* Area the Page stands in.
|
|
10
|
+
*/
|
|
11
|
+
export const PHI_CUSTOMER_FILE_DATA_PROVIDER_KEYS = {
|
|
12
|
+
table: createPhiSharedRuntimeDataProviderKey("tables", "threads-customer-file"),
|
|
13
|
+
};
|
|
14
|
+
/** The Provider's three resources, each one answer of the same route read for one member. */
|
|
15
|
+
export const PHI_CUSTOMER_FILE_RESOURCE_KEYS = {
|
|
16
|
+
person: "person",
|
|
17
|
+
addresses: "addresses",
|
|
18
|
+
threads: "threads",
|
|
19
|
+
};
|
|
20
|
+
/** The binding param a customer file Page writes the file's own subject into, already in the reader's language. */
|
|
21
|
+
export const PHI_CUSTOMER_FILE_SUBJECT_PARAM = "fileSubject";
|
|
22
|
+
/**
|
|
23
|
+
* The binding param a customer file Page writes its sentence for the reader's own file into, already in the
|
|
24
|
+
* reader's language: Core refuses that file (`403`), and each Table says this where its rows would be.
|
|
25
|
+
*/
|
|
26
|
+
export const PHI_CUSTOMER_FILE_OWN_FILE_PARAM = "ownFileNotice";
|
|
@@ -4,3 +4,18 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const PHI_RECORD_FIELD_KINDS: readonly ["text", "markdown", "picture", "pictures", "list", "tag", "date", "number", "money", "link"];
|
|
6
6
|
export type PhiRecordFieldKind = (typeof PHI_RECORD_FIELD_KINDS)[number];
|
|
7
|
+
/**
|
|
8
|
+
* The kinds a line of text can show: a text as it is, a number, a date and an amount of money in the
|
|
9
|
+
* page's language (`formatPhiRecordFieldText`, `helpers/record-fields.ts`).
|
|
10
|
+
*/
|
|
11
|
+
export declare const PHI_RECORD_TEXT_FIELD_KINDS: readonly ["text", "number", "date", "money"];
|
|
12
|
+
/**
|
|
13
|
+
* Bits of a `markdown` field's `flags` (`PhiRecordMarkdown`). `Translated`: the text already is in the
|
|
14
|
+
* page's language, a person's translation, and is drawn as written; without it the text is source text in
|
|
15
|
+
* its `sourceLocale`, and the Markdown Widget translates it (TRANSLATIONS.md, "The Markdown unit format").
|
|
16
|
+
*/
|
|
17
|
+
export declare const PhiRecordMarkdownFlag: {
|
|
18
|
+
readonly Translated: number;
|
|
19
|
+
};
|
|
20
|
+
/** Every bit `PhiRecordMarkdownFlag` names; `flags` with any other bit make no markdown field. */
|
|
21
|
+
export declare const PHI_RECORD_MARKDOWN_KNOWN_FLAGS: number;
|
|
@@ -5,3 +5,16 @@
|
|
|
5
5
|
export const PHI_RECORD_FIELD_KINDS = [
|
|
6
6
|
"text", "markdown", "picture", "pictures", "list", "tag", "date", "number", "money", "link",
|
|
7
7
|
];
|
|
8
|
+
/**
|
|
9
|
+
* The kinds a line of text can show: a text as it is, a number, a date and an amount of money in the
|
|
10
|
+
* page's language (`formatPhiRecordFieldText`, `helpers/record-fields.ts`).
|
|
11
|
+
*/
|
|
12
|
+
export const PHI_RECORD_TEXT_FIELD_KINDS = ["text", "number", "date", "money"];
|
|
13
|
+
/**
|
|
14
|
+
* Bits of a `markdown` field's `flags` (`PhiRecordMarkdown`). `Translated`: the text already is in the
|
|
15
|
+
* page's language, a person's translation, and is drawn as written; without it the text is source text in
|
|
16
|
+
* its `sourceLocale`, and the Markdown Widget translates it (TRANSLATIONS.md, "The Markdown unit format").
|
|
17
|
+
*/
|
|
18
|
+
export const PhiRecordMarkdownFlag = { Translated: 1 << 0 };
|
|
19
|
+
/** Every bit `PhiRecordMarkdownFlag` names; `flags` with any other bit make no markdown field. */
|
|
20
|
+
export const PHI_RECORD_MARKDOWN_KNOWN_FLAGS = PhiRecordMarkdownFlag.Translated;
|
|
@@ -50,6 +50,9 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
|
|
|
50
50
|
"form-field/media-asset": ["asset", "media-asset"],
|
|
51
51
|
"form-field/media-assets": ["asset", "media-assets"],
|
|
52
52
|
"form-field/money": ["core", "money"],
|
|
53
|
+
"form-field/country": ["core", "country"],
|
|
54
|
+
"form-field/address": ["core", "address"],
|
|
55
|
+
"form-field/flags": ["core", "flags"],
|
|
53
56
|
"form-field/multi-select": ["core", "multi-select"],
|
|
54
57
|
"form-field/number": ["core", "number"],
|
|
55
58
|
"form-field/password": ["core", "password"],
|
|
@@ -68,6 +71,9 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
|
|
|
68
71
|
"form-field/url": ["core", "url"],
|
|
69
72
|
"form-handler/admin-settings-general": ["admin", "settings-general"],
|
|
70
73
|
"form-handler/app-profile-name": ["app", "profile-name"],
|
|
74
|
+
"form-handler/app-profile-phone": ["app", "profile-phone"],
|
|
75
|
+
"form-handler/app-address-create": ["app", "address-create"],
|
|
76
|
+
"form-handler/app-address-edit": ["app", "address-edit"],
|
|
71
77
|
"form-handler/app-profile-locale": ["app", "profile-locale"],
|
|
72
78
|
"form-handler/app-profile-newsletter": ["app", "profile-newsletter"],
|
|
73
79
|
"form-handler/app-profile-theme": ["app", "profile-theme"],
|
|
@@ -122,6 +128,9 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
|
|
|
122
128
|
"form-validation/url": ["core", "url"],
|
|
123
129
|
"forms/admin/settings-general": ["admin", "settings-general"],
|
|
124
130
|
"forms/app/profile-name": ["app", "profile-name"],
|
|
131
|
+
"forms/app/profile-phone": ["app", "profile-phone"],
|
|
132
|
+
"forms/app/address-create": ["app", "address-create"],
|
|
133
|
+
"forms/app/address-edit": ["app", "address-edit"],
|
|
125
134
|
"forms/app/profile-locale": ["app", "profile-locale"],
|
|
126
135
|
"forms/app/profile-newsletter": ["app", "profile-newsletter"],
|
|
127
136
|
"forms/app/profile-theme": ["app", "profile-theme"],
|
|
@@ -203,6 +212,8 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
|
|
|
203
212
|
"options/theme-presets": ["theme", "presets"],
|
|
204
213
|
"options/translation-contexts": ["localization", "translation-contexts"],
|
|
205
214
|
"tables/auth-installations": ["auth", "installations"],
|
|
215
|
+
"tables/threads-customer-file": ["threads", "customer-file"],
|
|
216
|
+
"tables/app-addresses": ["app", "addresses"],
|
|
206
217
|
"signals/auth-workflow-state": ["auth", "workflow-state"],
|
|
207
218
|
"signals/background-config": ["core", "background-config"],
|
|
208
219
|
"signals/border-config": ["core", "border-config"],
|
|
@@ -276,6 +287,7 @@ const PHI_RUNTIME_MODULE_OWNERSHIP = {
|
|
|
276
287
|
"tables/revisions": ["revisions", "revisions"],
|
|
277
288
|
"tables/thread-inbox": ["core", "thread-inbox"],
|
|
278
289
|
"tables/user-management": ["user-management", "user-management"],
|
|
290
|
+
"tables/user-management-users-access": ["user-management", "users-access"],
|
|
279
291
|
"trees/builder-page-source": ["builder", "page-source"],
|
|
280
292
|
// Video providers the Video Module ships. An add-on contributes its own under its own package.
|
|
281
293
|
"video-providers/vimeo": ["video", "vimeo"],
|
|
@@ -5,6 +5,11 @@ export declare const PhiRuntimeRenderClientType: {
|
|
|
5
5
|
readonly AuthWorkflow: "@phis/ui/modules/auth/controller/default#workflow";
|
|
6
6
|
readonly AccountPreview: `${string}#preview`;
|
|
7
7
|
readonly BuilderModeSwitch: `${string}#builder-mode`;
|
|
8
|
+
readonly BuilderBrandThemeControls: "@phis/ui/modules/theme/widgets/brand-controls#theme";
|
|
9
|
+
readonly BuilderBrandThemePreview: "@phis/ui/modules/theme/widgets/brand-controls#preview";
|
|
10
|
+
readonly BuilderBrandStyleControls: "@phis/ui/modules/theme/widgets/brand-controls#style";
|
|
11
|
+
readonly BuilderBrandBackgroundControls: "@phis/ui/modules/theme/widgets/brand-controls#background";
|
|
12
|
+
readonly BuilderBrandIdentityControls: "@phis/ui/modules/theme/widgets/brand-controls#identity";
|
|
8
13
|
readonly SearchStandalone: "@phis/ui/controls/search";
|
|
9
14
|
readonly SidebarNavigationPreview: `${string}#preview`;
|
|
10
15
|
readonly BaseLayout: "@phis/ui/modules/core/layouts/base#client";
|
|
@@ -7,6 +7,11 @@ export const PhiRuntimeRenderClientType = {
|
|
|
7
7
|
AuthWorkflow: "@phis/ui/modules/auth/controller/default#workflow",
|
|
8
8
|
AccountPreview: `${PhiCmsWidgetType.Account}#preview`,
|
|
9
9
|
BuilderModeSwitch: `${PhiCmsWidgetType.Switch}#builder-mode`,
|
|
10
|
+
BuilderBrandThemeControls: "@phis/ui/modules/theme/widgets/brand-controls#theme",
|
|
11
|
+
BuilderBrandThemePreview: "@phis/ui/modules/theme/widgets/brand-controls#preview",
|
|
12
|
+
BuilderBrandStyleControls: "@phis/ui/modules/theme/widgets/brand-controls#style",
|
|
13
|
+
BuilderBrandBackgroundControls: "@phis/ui/modules/theme/widgets/brand-controls#background",
|
|
14
|
+
BuilderBrandIdentityControls: "@phis/ui/modules/theme/widgets/brand-controls#identity",
|
|
10
15
|
SearchStandalone: "@phis/ui/controls/search",
|
|
11
16
|
SidebarNavigationPreview: `${PhiCmsWidgetType.SidebarNavigation}#preview`,
|
|
12
17
|
BaseLayout: `${PHI_CMS_LAYOUT_PLUGIN_KEYS.core}/base#client`,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PHI_SHARED_PACKAGE_NAME, createPhiControllerSignalAddress } from "
|
|
1
|
+
import { PHI_SHARED_PACKAGE_NAME, createPhiControllerSignalAddress } from "../types/signals";
|
|
2
2
|
export const PHI_THREADS_CONTROLLER_PLUGIN_KEY = `${PHI_SHARED_PACKAGE_NAME}/modules/threads/controller`;
|
|
3
3
|
export const PHI_THREADS_CONTROLLER_KEY = "default";
|
|
4
4
|
export const PHI_THREADS_CONTROLLER_TYPE = `${PHI_THREADS_CONTROLLER_PLUGIN_KEY}/${PHI_THREADS_CONTROLLER_KEY}`;
|
package/constants.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { buildPhiCmsWidgetNamespacedTypeKey, splitPhiCmsWidgetNamespacedTypeKey,
|
|
|
5
5
|
export * from "./constants/cms-plugin-categories";
|
|
6
6
|
export * from "./constants/runtime-module-categories";
|
|
7
7
|
export { PHI_THREAD_LIBRARY_DATA_PROVIDER_KEYS } from "./constants/thread-library-provider-keys";
|
|
8
|
+
export { PHI_CUSTOMER_FILE_DATA_PROVIDER_KEYS, PHI_CUSTOMER_FILE_RESOURCE_KEYS, PHI_CUSTOMER_FILE_SUBJECT_PARAM, } from "./constants/customer-file";
|
|
8
9
|
export { PHIS_AREA_HEADER, PHIS_FORM_RELAY_HEADER, PHIS_REQUEST_PATH_HEADER, PHIS_REQUEST_SEARCH_HEADER, PHIS_SITE_KEY_HEADER, PHIS_TOKEN_HEADER, } from "./constants/http-headers";
|
|
9
10
|
export { buildPhiFontSubsetDeliveryUrl, buildPhiImageAssetVariantDeliveryUrl, buildPhiMediaAssetContentDeliveryUrl, isPhiMediaAssetOriginalOptimizable, isPhiMediaAssetPublic, isPhiMediaSvgContentType, normalizePhiImageAssetVariantKey, normalizePhiMediaKind, PhiImageAssetVariantKey, PhiImageAssetVariantKeyName, type PhiImageAssetVariantSpec, type PhiMediaAssetFlag, PhiMediaAssetFlags, PhiMediaDeliveryPolicy, PhiMediaFolderFlags, PhiMediaKind, PhiMediaLifecycleStatus, resolvePhiImageAssetVariantKeyName, resolvePhiImageAssetVariantSpec, resolvePhiMediaKindFromContentType, } from "./constants/media";
|
|
10
11
|
export * from "./constants/support";
|
package/constants.js
CHANGED
|
@@ -6,6 +6,8 @@ export * from "./constants/cms-plugin-categories";
|
|
|
6
6
|
export * from "./constants/runtime-module-categories";
|
|
7
7
|
// The conversations a viewer is in, for every Module that lists its own kind of them (`fixedFilters`).
|
|
8
8
|
export { PHI_THREAD_LIBRARY_DATA_PROVIDER_KEYS } from "./constants/thread-library-provider-keys";
|
|
9
|
+
// Staff's customer file on one member, for a Module's own file Page over the same Core route (THREADS.md, 10).
|
|
10
|
+
export { PHI_CUSTOMER_FILE_DATA_PROVIDER_KEYS, PHI_CUSTOMER_FILE_RESOURCE_KEYS, PHI_CUSTOMER_FILE_SUBJECT_PARAM, } from "./constants/customer-file";
|
|
9
11
|
export { PHIS_AREA_HEADER, PHIS_FORM_RELAY_HEADER, PHIS_REQUEST_PATH_HEADER, PHIS_REQUEST_SEARCH_HEADER, PHIS_SITE_KEY_HEADER, PHIS_TOKEN_HEADER, } from "./constants/http-headers";
|
|
10
12
|
export { buildPhiFontSubsetDeliveryUrl, buildPhiImageAssetVariantDeliveryUrl, buildPhiMediaAssetContentDeliveryUrl, isPhiMediaAssetOriginalOptimizable, isPhiMediaAssetPublic, isPhiMediaSvgContentType, normalizePhiImageAssetVariantKey, normalizePhiMediaKind, PhiImageAssetVariantKey, PhiImageAssetVariantKeyName, PhiMediaAssetFlags, PhiMediaDeliveryPolicy, PhiMediaFolderFlags, PhiMediaKind, PhiMediaLifecycleStatus, resolvePhiImageAssetVariantKeyName, resolvePhiImageAssetVariantSpec, resolvePhiMediaKindFromContentType, } from "./constants/media";
|
|
11
13
|
export * from "./constants/support";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The field keys a handler's `upstreamPath` names as `{key}` segments, in order. */
|
|
2
|
+
export declare function readPhiFormHandlerPathKeys(upstreamPath: string): string[];
|
|
3
|
+
/**
|
|
4
|
+
* Why a handler's `upstreamPath` cannot be filled, or null: a field named in two `{key}` segments would
|
|
5
|
+
* leave the relay two places for one value.
|
|
6
|
+
*/
|
|
7
|
+
export declare function readPhiFormHandlerPathError(upstreamPath: string | null): string | null;
|
|
8
|
+
/**
|
|
9
|
+
* The request a relayed submit makes (FORMS.md, "Request shape"): the path's `{key}` segments filled with
|
|
10
|
+
* those fields' values, percent-encoded, and those fields left out of the body, which is every other value
|
|
11
|
+
* as the Form holds it. A path value that is empty or no text or number refuses the submit: an address
|
|
12
|
+
* without it is another route.
|
|
13
|
+
*/
|
|
14
|
+
export declare function shapePhiFormHandlerRequest(input: {
|
|
15
|
+
upstreamPath: string;
|
|
16
|
+
values: unknown;
|
|
17
|
+
}): {
|
|
18
|
+
path: string;
|
|
19
|
+
body: Record<string, unknown>;
|
|
20
|
+
} | {
|
|
21
|
+
error: string;
|
|
22
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isPhiRecord } from "../helpers/is-record";
|
|
2
|
+
const PATH_PLACEHOLDER = /\{([A-Za-z][A-Za-z0-9_]*)\}/gu;
|
|
3
|
+
/** The field keys a handler's `upstreamPath` names as `{key}` segments, in order. */
|
|
4
|
+
export function readPhiFormHandlerPathKeys(upstreamPath) {
|
|
5
|
+
return [...upstreamPath.matchAll(PATH_PLACEHOLDER)].map((match) => match[1]);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Why a handler's `upstreamPath` cannot be filled, or null: a field named in two `{key}` segments would
|
|
9
|
+
* leave the relay two places for one value.
|
|
10
|
+
*/
|
|
11
|
+
export function readPhiFormHandlerPathError(upstreamPath) {
|
|
12
|
+
const named = new Set();
|
|
13
|
+
for (const key of upstreamPath ? readPhiFormHandlerPathKeys(upstreamPath) : []) {
|
|
14
|
+
if (named.has(key))
|
|
15
|
+
return `field "${key}" is named more than once`;
|
|
16
|
+
named.add(key);
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The request a relayed submit makes (FORMS.md, "Request shape"): the path's `{key}` segments filled with
|
|
22
|
+
* those fields' values, percent-encoded, and those fields left out of the body, which is every other value
|
|
23
|
+
* as the Form holds it. A path value that is empty or no text or number refuses the submit: an address
|
|
24
|
+
* without it is another route.
|
|
25
|
+
*/
|
|
26
|
+
export function shapePhiFormHandlerRequest(input) {
|
|
27
|
+
const values = isPhiRecord(input.values) ? { ...input.values } : {};
|
|
28
|
+
let missing = null;
|
|
29
|
+
const path = input.upstreamPath.replace(PATH_PLACEHOLDER, (_segment, key) => {
|
|
30
|
+
const value = values[key];
|
|
31
|
+
delete values[key];
|
|
32
|
+
const text = typeof value === "number" && Number.isFinite(value) ? String(value) : typeof value === "string" ? value.trim() : "";
|
|
33
|
+
if (!text)
|
|
34
|
+
missing ??= key;
|
|
35
|
+
return encodeURIComponent(text);
|
|
36
|
+
});
|
|
37
|
+
if (missing)
|
|
38
|
+
return { error: `The form has no value for "${missing}", which the address of its handler needs.` };
|
|
39
|
+
return { path, body: values };
|
|
40
|
+
}
|
package/gateway/label-set.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "server-only";
|
|
2
2
|
import { type PhiGlobalTranslatorOptions } from "./tr";
|
|
3
|
+
import { type PhiCountLabel } from "../helpers/translation-format";
|
|
3
4
|
import type { PhiRuntimeModuleDefinition } from "../types/cms-plugins";
|
|
4
5
|
/**
|
|
5
6
|
* One label, and optionally the register it is written in.
|
|
@@ -12,6 +13,16 @@ import type { PhiRuntimeModuleDefinition } from "../types/cms-plugins";
|
|
|
12
13
|
export type PhiLabelSetEntry = string | {
|
|
13
14
|
text: string;
|
|
14
15
|
ctx: string;
|
|
16
|
+
} | PhiLabelSetCountEntry;
|
|
17
|
+
/**
|
|
18
|
+
* A label that says a count: one template per plural category, `other` required (TRANSLATIONS.md,
|
|
19
|
+
* "Count labels"). It reads back as a `PhiCountLabel` and is formatted with `formatPhiCountLabel`, never
|
|
20
|
+
* by a Widget's own `count === 1` branch. `ctx` names its register as a `{ text, ctx }` entry does;
|
|
21
|
+
* absent, it takes the set's.
|
|
22
|
+
*/
|
|
23
|
+
export type PhiLabelSetCountEntry = {
|
|
24
|
+
count: PhiCountLabel;
|
|
25
|
+
ctx?: string;
|
|
15
26
|
};
|
|
16
27
|
export type PhiLabelSetLabels = Record<string, PhiLabelSetEntry>;
|
|
17
28
|
/**
|
|
@@ -21,9 +32,11 @@ export type PhiLabelSetLabels = Record<string, PhiLabelSetEntry>;
|
|
|
21
32
|
* thing in the width of the text itself. Any other register is still written as the plain object.
|
|
22
33
|
*/
|
|
23
34
|
export declare function definePhiMessageLabel(text: string): PhiLabelSetEntry;
|
|
24
|
-
/**
|
|
35
|
+
/** A count label, `{ one: "%1 page", other: "%1 pages" }`, in the set's register unless `ctx` names another. */
|
|
36
|
+
export declare function definePhiCountLabel(count: PhiCountLabel, ctx?: string): PhiLabelSetCountEntry;
|
|
37
|
+
/** What a set reads as once translated: the same keys, plain text, and a count label for a count label. */
|
|
25
38
|
export type PhiLabelSetTexts<TLabels extends PhiLabelSetLabels> = {
|
|
26
|
-
[K in keyof TLabels]: string;
|
|
39
|
+
[K in keyof TLabels]: TLabels[K] extends PhiLabelSetCountEntry ? PhiCountLabel : string;
|
|
27
40
|
};
|
|
28
41
|
export type PhiLabelSetDefinition<TLabels extends PhiLabelSetLabels> = {
|
|
29
42
|
key: string;
|
package/gateway/label-set.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "server-only";
|
|
2
2
|
import { createGlobalTranslator, PHI_TR_CTX_WEB_UI_MESSAGE, } from "./tr";
|
|
3
3
|
import { PHI_CANONICAL_SOURCE_LOCALE, isPhiLocaleReadableAsSource, resolvePhiTranslationLocale, } from "../helpers/locale";
|
|
4
|
+
import { PHI_PLURAL_CATEGORIES, } from "../helpers/translation-format";
|
|
4
5
|
import { resolvePhiRuntimeModuleSourceLocale } from "../types/runtime-module-locale";
|
|
5
6
|
/**
|
|
6
7
|
* One label that is a sentence rather than a caption, in a set that is otherwise captions.
|
|
@@ -11,10 +12,48 @@ import { resolvePhiRuntimeModuleSourceLocale } from "../types/runtime-module-loc
|
|
|
11
12
|
export function definePhiMessageLabel(text) {
|
|
12
13
|
return { text, ctx: PHI_TR_CTX_WEB_UI_MESSAGE };
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
/** A count label, `{ one: "%1 page", other: "%1 pages" }`, in the set's register unless `ctx` names another. */
|
|
16
|
+
export function definePhiCountLabel(count, ctx) {
|
|
17
|
+
return ctx === undefined ? { count } : { count, ctx };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The register a count label's category is translated in: the label's own, saying which form it is. The
|
|
21
|
+
* category belongs to the translation's identity because English often writes two forms alike -- "%1
|
|
22
|
+
* configured" is `one` and `other` both -- where a translator's language does not; under the bare register
|
|
23
|
+
* they would be one message with one answer. It also tells the translator which form to write.
|
|
24
|
+
*/
|
|
25
|
+
function readCountCategoryContext(ctx, category) {
|
|
26
|
+
return `${ctx}, plural category ${category}`;
|
|
27
|
+
}
|
|
28
|
+
function readLabelSetUnits(key, entry, setContext) {
|
|
29
|
+
if (typeof entry === "string") {
|
|
30
|
+
return [{ key, category: null, text: entry, ctx: setContext }];
|
|
31
|
+
}
|
|
32
|
+
if ("count" in entry) {
|
|
33
|
+
const ctx = entry.ctx ?? setContext;
|
|
34
|
+
return PHI_PLURAL_CATEGORIES.flatMap((category) => {
|
|
35
|
+
const text = entry.count[category];
|
|
36
|
+
return text === undefined
|
|
37
|
+
? []
|
|
38
|
+
: [{ key, category, text, ctx: readCountCategoryContext(ctx, category) }];
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return [{ key, category: null, text: entry.text, ctx: entry.ctx }];
|
|
42
|
+
}
|
|
43
|
+
/** The units read back into the set's shape: a label's text, or a count label's categories. */
|
|
44
|
+
function assembleLabelSetTexts(units, readText) {
|
|
45
|
+
const labels = {};
|
|
46
|
+
units.forEach((unit, index) => {
|
|
47
|
+
const text = readText(unit, index);
|
|
48
|
+
if (unit.category === null) {
|
|
49
|
+
labels[unit.key] = text;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const count = (labels[unit.key] ?? {});
|
|
53
|
+
count[unit.category] = text;
|
|
54
|
+
labels[unit.key] = count;
|
|
55
|
+
});
|
|
56
|
+
return labels;
|
|
18
57
|
}
|
|
19
58
|
export function definePhiLabelSet(definition) {
|
|
20
59
|
return definition;
|
|
@@ -34,34 +73,33 @@ export function definePhiRuntimeModuleLabelSet(moduleDefinition, definition) {
|
|
|
34
73
|
export async function getPhiLabelSet(options, definition) {
|
|
35
74
|
const sourceLocale = resolvePhiTranslationLocale(definition.sourceLocale ?? options.sourceLocale ?? PHI_CANONICAL_SOURCE_LOCALE);
|
|
36
75
|
const targetLocale = resolvePhiTranslationLocale(options.locale);
|
|
37
|
-
const
|
|
38
|
-
.
|
|
76
|
+
const units = Object.entries(definition.labels)
|
|
77
|
+
.flatMap(([key, value]) => readLabelSetUnits(key, value, definition.ctx));
|
|
39
78
|
if (isPhiLocaleReadableAsSource(targetLocale, sourceLocale)) {
|
|
40
|
-
|
|
41
|
-
return labels;
|
|
79
|
+
return assembleLabelSetTexts(units, (unit) => unit.text);
|
|
42
80
|
}
|
|
43
81
|
/*
|
|
44
82
|
* One request per register rather than one per label: a set is nearly all one register, so this is
|
|
45
83
|
* the same single batch it always was plus one more for the handful of entries that are a sentence
|
|
46
|
-
* rather than a caption
|
|
84
|
+
* rather than a caption, and one per plural category a count label states. The batches run together,
|
|
85
|
+
* and each keeps its own translation identity; each answer goes back to its unit by position.
|
|
47
86
|
*/
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const group =
|
|
51
|
-
group.push(
|
|
52
|
-
|
|
53
|
-
}
|
|
87
|
+
const unitsByContext = new Map();
|
|
88
|
+
units.forEach((unit, index) => {
|
|
89
|
+
const group = unitsByContext.get(unit.ctx) ?? [];
|
|
90
|
+
group.push(index);
|
|
91
|
+
unitsByContext.set(unit.ctx, group);
|
|
92
|
+
});
|
|
54
93
|
const translator = createGlobalTranslator({ ...options, sourceLocale });
|
|
55
|
-
const
|
|
56
|
-
await Promise.all([...
|
|
57
|
-
const translated = await translator.trBulk(group.map((
|
|
94
|
+
const translatedByUnit = [];
|
|
95
|
+
await Promise.all([...unitsByContext].map(async ([context, group]) => {
|
|
96
|
+
const translated = await translator.trBulk(group.map((index) => units[index].text), context);
|
|
58
97
|
if (translated.length !== group.length) {
|
|
59
98
|
throw new Error(`Label set length mismatch for "${definition.key}".`);
|
|
60
99
|
}
|
|
61
|
-
group.forEach((
|
|
62
|
-
|
|
100
|
+
group.forEach((unitIndex, index) => {
|
|
101
|
+
translatedByUnit[unitIndex] = translated[index];
|
|
63
102
|
});
|
|
64
103
|
}));
|
|
65
|
-
|
|
66
|
-
return labels;
|
|
104
|
+
return assembleLabelSetTexts(units, (unit, index) => translatedByUnit[index] ?? unit.text);
|
|
67
105
|
}
|