@open-pioneer/runtime 3.0.0 → 3.1.0-dev-rich-text.20250408112706

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/CHANGELOG.md CHANGED
@@ -1,5 +1,69 @@
1
1
  # @open-pioneer/runtime
2
2
 
3
+ ## 3.1.0-dev-rich-text.20250408112706
4
+
5
+ ### Minor Changes
6
+
7
+ - 5d758c7: Add support for rich text formatting using the `intl` object.
8
+ In addition to primitive values, rich text formatting supports react values and custom react tags.
9
+ It always returns a react node, so can only be used in combination with react components.
10
+
11
+ _Example with react node as value:_
12
+
13
+ ```tsx
14
+ function Example() {
15
+ const intl = useIntl();
16
+ // Given i18n message "Hello, {name}!"
17
+ // replaces 'name' with the given react node:
18
+ const message = intl.formatRichMessage(
19
+ { id: "foo" },
20
+ {
21
+ name: <FancyUserName />
22
+ }
23
+ );
24
+ return <Box>{message}</Box>;
25
+ }
26
+ ```
27
+
28
+ _Example with basic formatting:_
29
+
30
+ ```tsx
31
+ function Example() {
32
+ const intl = useIntl();
33
+ // Given i18n message "Hello, <strong>{name}</strong>!"
34
+ // renders with actual <strong> html node:
35
+ return <Box>{intl.formatRichMessage({ id: "foo" }, { name: "User" })}</Box>;
36
+ }
37
+ ```
38
+
39
+ Note that only a few basic formatting tags are predefined ("b", "strong", "i", "em", "code", "br").
40
+ If you need more advanced tags, you can define your own, see below.
41
+ _Example with custom tag:_
42
+
43
+ ```tsx
44
+ function Example() {
45
+ const intl = useIntl();
46
+ // Given i18n message "Open <foo>the door</foo>!",
47
+ // renders 'foo' using the formatter function below:
48
+ const message = intl.formatRichMessage(
49
+ { id: "foo" },
50
+ {
51
+ foo: (parts) => <FancyTag>{parts}</FancyTag>
52
+ }
53
+ );
54
+ return <Box>{message}</Box>;
55
+ }
56
+ ```
57
+
58
+ The TypeScript signature for the `intl.formatMessage()` function has been made a little bit stricter compared with FormatJS: only primitive values are allowed for the `values` argument (this should not affect users in practice).
59
+
60
+ ### Patch Changes
61
+
62
+ - @open-pioneer/runtime-react-support@3.1.0-dev-rich-text.20250408112706
63
+ - @open-pioneer/base-theme@3.1.0-dev-rich-text.20250408112706
64
+ - @open-pioneer/chakra-integration@3.1.0-dev-rich-text.20250408112706
65
+ - @open-pioneer/core@3.1.0-dev-rich-text.20250408112706
66
+
3
67
  ## 3.0.0
4
68
 
5
69
  ### Major Changes
package/CustomElement.js CHANGED
@@ -5,8 +5,10 @@ import { createPackages } from './service-layer/PackageRepr.js';
5
5
  import { ServiceLayer } from './service-layer/ServiceLayer.js';
6
6
  import { ReactIntegration } from './react-integration/ReactIntegration.js';
7
7
  import { createBuiltinPackage, RUNTIME_API_SERVICE, RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE, RUNTIME_AUTO_START } from './builtin-services/index.js';
8
- import { initI18n, getBrowserLocales, I18nConfig, createPackageIntl } from './i18n.js';
9
- import { ErrorScreen, MESSAGES_BY_LOCALE } from './ErrorScreen.js';
8
+ import { initI18n } from './i18n/AppIntl.js';
9
+ import { createPackageIntl } from './i18n/PackageIntl.js';
10
+ import { getBrowserLocales, I18nConfig } from './i18n/pick.js';
11
+ import { MESSAGES_BY_LOCALE, ErrorScreen } from './ErrorScreen.js';
10
12
 
11
13
  const LOG = createLogger("runtime:CustomElement");
12
14
  function createCustomElement(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"CustomElement.js","sources":["CustomElement.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ComponentType, createElement } from \"react\";\nimport {\n createAbortError,\n createLogger,\n createManualPromise,\n destroyResource,\n Error,\n ManualPromise,\n Resource,\n throwAbortError\n} from \"@open-pioneer/core\";\nimport { ErrorId } from \"./errors\";\nimport { ApplicationMetadata, PackageMetadata } from \"./metadata\";\nimport { PackageRepr, createPackages } from \"./service-layer/PackageRepr\";\nimport { ServiceLayer } from \"./service-layer/ServiceLayer\";\nimport { getErrorChain } from \"@open-pioneer/core\";\nimport { ReactIntegration } from \"./react-integration/ReactIntegration\";\nimport { ApiMethods, ApiService } from \"./api\";\nimport {\n createBuiltinPackage,\n RUNTIME_API_SERVICE,\n RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE,\n RUNTIME_AUTO_START\n} from \"./builtin-services\";\nimport { ReferenceSpec } from \"./service-layer/InterfaceSpec\";\nimport { AppI18n, createPackageIntl, getBrowserLocales, I18nConfig, initI18n } from \"./i18n\";\nimport { ApplicationLifecycleEventService } from \"./builtin-services/ApplicationLifecycleEventService\";\nimport { ErrorScreen, MESSAGES_BY_LOCALE } from \"./ErrorScreen\";\nconst LOG = createLogger(\"runtime:CustomElement\");\n\n/**\n * Options for the {@link createCustomElement} function.\n */\nexport interface CustomElementOptions {\n /**\n * Rendered UI component.\n */\n component?: ComponentType<Record<string, string>>;\n\n /**\n * Application metadata (packages, services etc.).\n * This is usually autogenerated by importing the virtual `\"open-pioneer:app\"` module.\n */\n appMetadata?: ApplicationMetadata;\n\n /**\n * Application defined configuration.\n *\n * This option can be used to override default properties of the application's packages.\n *\n * All instances of the web component will share this static configuration.\n */\n config?: ApplicationConfig;\n\n /**\n * Function to provide additional application defined configuration parameters.\n *\n * Compared to {@link config}, this function receives a context object\n * that allows the developer to provide dynamic properties on a per-application instance basis.\n *\n * Parameters returned by this function take precedence over the ones defined by {@link config}.\n */\n resolveConfig?(ctx: ConfigContext): Promise<ApplicationConfig | undefined>;\n\n /**\n * Chakra theming object.\n */\n theme?: Record<string, unknown>;\n}\n\n/**\n * A context object that is passed to the `resolveProperties` function.\n */\nexport interface ConfigContext {\n /**\n * The application's host element.\n */\n hostElement: HTMLElement;\n\n /**\n * Returns an attribute from the application's root node.\n */\n getAttribute(name: string): string | undefined;\n}\n\n/**\n * Runtime application configuration.\n */\nexport interface ApplicationConfig {\n /**\n * Set this value to a locale string (e.g. \"en\") to for the application's locale.\n * The default behavior is to choose an appropriate locale for the current user based\n * on the browser's settings.\n *\n * The locale must be supported by the application.\n */\n locale?: string | undefined;\n\n /**\n * Properties specified here will override default properties of the application's packages.\n */\n properties?: ApplicationProperties | undefined;\n}\n\n/**\n * Allows the application to override default properties in all packages.\n *\n * Properties are typed when the package contains type definitions for them.\n */\nexport interface ApplicationProperties {\n /**\n * Key: the name of the package.\n * Value: A record of configuration properties (key/value pairs).\n *\n * Properties will override default property values in the package.\n */\n [packageName: string]: Record<string, unknown>;\n}\n\n/**\n * The interface implemented by web components produced via {@link createCustomElement}.\n */\nexport interface ApplicationElement extends HTMLElement {\n /** Resolves to the element's API when the application has started. */\n when(): Promise<ApiMethods>;\n}\n\n/**\n * The class returned by a call to {@link createCustomElement}.\n */\nexport interface ApplicationElementConstructor {\n new (): ApplicationElement;\n}\n\n/**\n * Creates a new custom element class (web component) that can be registered within a DOM.\n *\n * @example\n * ```ts\n * import * as appMetadata from \"open-pioneer:app\";\n *\n * const CustomElementClazz = createCustomElement({\n * component: <div>Hello World!</div>,\n * appMetadata\n * });\n * customElements.define(\"sample-element\", CustomElementClazz);\n * ```\n */\nexport function createCustomElement(options: CustomElementOptions): ApplicationElementConstructor {\n class PioneerApplication extends HTMLElement implements ApplicationElement {\n #shadowRoot: ShadowRoot;\n #instance: ApplicationInstance | undefined;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n #deferredRestart: any; // A Timer\n\n static get observedAttributes(): string[] {\n return [];\n }\n\n constructor() {\n super();\n\n this.#shadowRoot = this.attachShadow({\n mode: \"open\"\n });\n\n if (import.meta.env.DEV) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this as any).$inspectElementState = () => this.#instance;\n }\n }\n\n connectedCallback() {\n LOG.debug(\"Launching application\");\n\n if (this.#instance) {\n this.#instance.destroy();\n }\n\n this.#instance = this.#createApplicationInstance();\n this.#instance.start();\n }\n\n disconnectedCallback() {\n LOG.debug(\"Shutting down application\");\n\n if (this.#deferredRestart) {\n clearTimeout(this.#deferredRestart);\n }\n this.#instance?.destroy();\n this.#instance = undefined;\n\n LOG.debug(\"Application destroyed\");\n }\n\n when() {\n if (!this.#instance) {\n return Promise.reject(\n new Error(\n ErrorId.NOT_MOUNTED,\n \"Cannot use the application's API because the HTML element has not yet been mounted into the DOM.\"\n )\n );\n }\n\n return this.#instance.whenAPI();\n }\n\n #triggerReload(overrides?: ApplicationOverrides) {\n // Defer the restart operation a tiny bit so calling code does not get surprised by the application's destruction.\n if (this.#deferredRestart) {\n clearTimeout(this.#deferredRestart);\n }\n this.#deferredRestart = setTimeout(() => {\n if (!this.#instance) {\n // disconnectedCallback was called in the meantime\n return;\n }\n\n LOG.debug(\"Restarting application with new options\", overrides);\n this.#instance.destroy();\n this.#instance = this.#createApplicationInstance(overrides);\n this.#instance.start();\n }, 1);\n }\n\n #createApplicationInstance(overrides?: ApplicationOverrides) {\n return new ApplicationInstance({\n hostElement: this,\n shadowRoot: this.#shadowRoot,\n elementOptions: options,\n overrides: overrides,\n restart: this.#triggerReload.bind(this)\n });\n }\n }\n return PioneerApplication;\n}\n\ninterface InstanceOptions {\n /** The HTML element that embeds the application. */\n hostElement: HTMLElement;\n\n /** The shadow root inside the host element that contains the rest of the application. */\n shadowRoot: ShadowRoot;\n\n /** Trails options for the application. */\n elementOptions: CustomElementOptions;\n\n /** These have higher priority than the options in `elementOptions`. */\n overrides: ApplicationOverrides | undefined;\n\n /**\n * A callback to restart the application with new options.\n * Currently only used for reloading with a certain locale.\n */\n restart: (overrides?: ApplicationOverrides) => void;\n}\n\ninterface ApplicationOverrides {\n locale?: string;\n}\n\ntype ApplicationState = \"not-started\" | \"starting\" | \"started\" | \"destroyed\" | \"error\";\n\nclass ApplicationInstance {\n private options: InstanceOptions;\n\n // Public API\n private apiPromise: ManualPromise<ApiMethods> | undefined; // Present when callers are waiting for the API\n private api: ApiMethods | undefined; // Present once started\n\n private state: ApplicationState = \"not-started\";\n private container: HTMLDivElement | undefined;\n private config: ApplicationConfig | undefined;\n private serviceLayer: ServiceLayer | undefined;\n private lifecycleEvents: ApplicationLifecycleEventService | undefined;\n private reactIntegration: ReactIntegration | undefined;\n private stylesWatch: Resource | undefined;\n\n constructor(options: InstanceOptions) {\n this.options = options;\n }\n\n start() {\n if (this.state !== \"not-started\") {\n throw new Error(ErrorId.INTERNAL, `Cannot start element in state '${this.state}'`);\n }\n\n this.state = \"starting\";\n this.startImpl().catch((e) => {\n if (this.state === \"destroyed\") return;\n\n logError(e);\n this.reset();\n this.state = \"error\";\n this.showErrorScreen(e);\n });\n }\n\n destroy() {\n if (this.state === \"destroyed\") {\n return;\n }\n\n // Only call event listener when 'started' was also signalled.\n if (this.state === \"started\") {\n try {\n this.triggerApplicationLifecycleEvent(\"before-stop\");\n } catch (e) {\n void e; // Ignored\n }\n }\n this.state = \"destroyed\";\n this.reset();\n }\n\n private reset() {\n this.apiPromise?.reject(createAbortError());\n this.reactIntegration = destroyResource(this.reactIntegration);\n this.options.shadowRoot.replaceChildren();\n this.container = undefined;\n this.lifecycleEvents = undefined;\n this.serviceLayer = destroyResource(this.serviceLayer);\n this.stylesWatch = destroyResource(this.stylesWatch);\n }\n\n whenAPI(): Promise<ApiMethods> {\n if (this.api) {\n return Promise.resolve(this.api);\n }\n\n const apiPromise = (this.apiPromise ??= createManualPromise());\n return apiPromise.promise;\n }\n\n private async startImpl() {\n const { shadowRoot, hostElement, elementOptions, overrides } = this.options;\n\n // Resolve custom application config\n const config = (this.config = await gatherConfig(hostElement, elementOptions, overrides));\n this.checkAbort();\n LOG.debug(\"Application config is\", config);\n\n // Decide on locale and load i18n messages (if any).\n const i18n = await initI18n(elementOptions.appMetadata, config.locale);\n this.checkAbort();\n\n // Setup application root node in the shadow dom\n const container = (this.container = createContainer(i18n.locale));\n const styles = this.initStyles();\n shadowRoot.replaceChildren(container, ...styles);\n\n // Launch the service layer\n const { serviceLayer, packages } = this.initServiceLayer({\n container,\n properties: config.properties,\n i18n\n });\n this.lifecycleEvents = getInternalService<ApplicationLifecycleEventService>(\n serviceLayer,\n RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE\n );\n\n await this.initAPI(serviceLayer);\n this.checkAbort();\n\n // Launch react\n this.reactIntegration = ReactIntegration.createForApp({\n rootNode: container,\n container: shadowRoot,\n theme: elementOptions.theme,\n serviceLayer,\n packages\n });\n const component = this.options.elementOptions.component ?? emptyComponent;\n this.reactIntegration.render(createElement(component));\n this.state = \"started\";\n\n this.triggerApplicationLifecycleEvent(\"after-start\");\n LOG.debug(\"Application started\");\n }\n\n private initStyles() {\n // Prevent inheritance of certain css values and normalize to display: block by default.\n // See https://open-wc.org/guides/knowledge/styling/styles-piercing-shadow-dom/\n const builtinStyles = \":host { all: initial; display: block; }\";\n const builtinStylesNode = document.createElement(\"style\");\n applyStyles(builtinStylesNode, { value: builtinStyles });\n\n const appStyles = this.options.elementOptions.appMetadata?.styles;\n const appStylesNode = document.createElement(\"style\");\n applyStyles(appStylesNode, appStyles);\n if (import.meta.hot) {\n this.stylesWatch = appStyles?.on?.(\"changed\", () => {\n LOG.debug(\"Application styles changed\");\n applyStyles(appStylesNode, appStyles);\n });\n }\n return [builtinStylesNode, appStylesNode];\n }\n\n private initServiceLayer(config: {\n container: HTMLDivElement;\n properties: ApplicationProperties;\n i18n: AppI18n;\n }) {\n const { hostElement, shadowRoot, elementOptions, restart } = this.options;\n const { container, properties, i18n } = config;\n const packageMetadata = elementOptions.appMetadata?.packages ?? {};\n const builtinPackage = createBuiltinPackage({\n host: hostElement,\n shadowRoot: shadowRoot,\n container: container,\n locale: i18n.locale,\n supportedLocales: i18n.supportedMessageLocales,\n changeLocale(locale) {\n const supported = i18n.supportedMessageLocales;\n if (locale != null && !i18n.supportsLocale(locale)) {\n throw new Error(\n ErrorId.UNSUPPORTED_LOCALE,\n `Unsupported locale '${locale}' (supported locales: ${supported.join(\n \", \"\n )}).`\n );\n }\n restart({ locale });\n }\n });\n const { serviceLayer, packages } = createServiceLayer({\n packageMetadata,\n builtinPackage,\n properties,\n i18n\n });\n this.serviceLayer = serviceLayer;\n\n if (LOG.isDebug()) {\n LOG.debug(\"Launching service layer with packages\", Object.fromEntries(packages));\n }\n serviceLayer.start();\n return { serviceLayer, packages };\n }\n\n private async initAPI(serviceLayer: ServiceLayer) {\n const apiService = getInternalService<ApiService>(serviceLayer, RUNTIME_API_SERVICE);\n try {\n const api = (this.api = await apiService.getApi());\n LOG.debug(\"Application API initialized to\", api);\n this.apiPromise?.resolve(api);\n } catch (e) {\n throw new Error(ErrorId.INTERNAL, \"Failed to gather the application's API methods.\", {\n cause: e\n });\n }\n }\n\n private triggerApplicationLifecycleEvent(event: \"after-start\" | \"before-stop\") {\n this.lifecycleEvents?.emitLifecycleEvent(event);\n }\n\n private checkAbort() {\n if (this.state === \"destroyed\") {\n throwAbortError();\n }\n }\n\n private showErrorScreen(error: globalThis.Error) {\n const { shadowRoot, elementOptions } = this.options;\n\n const userLocales = getBrowserLocales();\n const i18nConfig = new I18nConfig(Object.keys(MESSAGES_BY_LOCALE));\n const { locale, messageLocale } = i18nConfig.pickSupportedLocale(undefined, userLocales);\n\n const container = (this.container = createContainer(locale));\n container.classList.add(\"pioneer-root-error-screen\");\n\n const messages =\n MESSAGES_BY_LOCALE[messageLocale as keyof typeof MESSAGES_BY_LOCALE] ??\n MESSAGES_BY_LOCALE[\"en\"];\n const intl = createPackageIntl(locale, messages);\n this.reactIntegration = ReactIntegration.createForErrorScreen({\n rootNode: container,\n container: shadowRoot,\n theme: elementOptions.theme\n });\n this.reactIntegration.render(createElement(ErrorScreen, { intl, error }));\n\n shadowRoot.replaceChildren(container);\n }\n}\n\nfunction createContainer(locale: string) {\n // Setup application root node in the shadow dom\n const container = document.createElement(\"div\");\n container.classList.add(\"pioneer-root\");\n container.style.minHeight = \"100%\";\n container.style.height = \"100%\";\n if (locale) {\n container.lang = locale;\n }\n return container;\n}\n\nfunction createServiceLayer(config: {\n packageMetadata: Record<string, PackageMetadata> | undefined;\n properties: ApplicationProperties;\n builtinPackage: PackageRepr;\n i18n: AppI18n;\n}) {\n const { packageMetadata, properties, builtinPackage, i18n } = config;\n\n let packages: PackageRepr[];\n try {\n packages = createPackages(packageMetadata ?? {}, i18n, properties);\n } catch (e) {\n throw new Error(ErrorId.INVALID_METADATA, \"Failed to parse package metadata.\", {\n cause: e\n });\n }\n\n // Add builtin services defined within this package.\n {\n const index = packages.findIndex((pkg) => pkg.name === builtinPackage.name);\n if (index >= 0) {\n packages.splice(index, 1);\n }\n packages.push(builtinPackage);\n }\n\n // Automatically required references (-> forces services to start)\n const forcedReferences: ReferenceSpec[] = [\n {\n interfaceName: RUNTIME_API_SERVICE\n },\n {\n interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE\n },\n {\n interfaceName: RUNTIME_AUTO_START,\n all: true\n }\n ];\n const serviceLayer = new ServiceLayer(packages, forcedReferences);\n return {\n packages: new Map(packages.map((pkg) => [pkg.name, pkg])),\n serviceLayer: serviceLayer\n };\n}\n\nfunction getInternalService<T = unknown>(serviceLayer: ServiceLayer, interfaceName: string) {\n const result = serviceLayer.getService(\n \"@open-pioneer/runtime\",\n {\n interfaceName\n },\n { ignoreDeclarationCheck: true }\n );\n if (result.type !== \"found\") {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find instance of '${interfaceName}' (result type '${result.type}').` +\n ` This is a builtin service that must be present exactly once.`\n );\n }\n\n return result.value.getInstanceOrThrow() as T;\n}\n\n/**\n * Gathers application properties by reading them from the options object\n * and by (optionally) invoking the `resolveProperties` hook.\n */\nasync function gatherConfig(\n hostElement: HTMLElement,\n options: CustomElementOptions,\n overrides?: ApplicationOverrides\n) {\n let configs: ApplicationConfig[];\n try {\n const staticConfig = options.config ?? {};\n const dynamicConfig =\n (await options.resolveConfig?.({\n hostElement,\n getAttribute(name) {\n return hostElement.getAttribute(name) ?? undefined;\n }\n })) ?? {};\n\n configs = [staticConfig, dynamicConfig];\n } catch (e) {\n throw new Error(\n ErrorId.CONFIG_RESOLUTION_FAILED,\n \"Failed to resolve application properties.\",\n {\n cause: e\n }\n );\n }\n\n const merged = mergeConfigs(configs);\n if (overrides?.locale) {\n merged.locale = overrides.locale;\n }\n return merged;\n}\n\n/**\n * Merges application configurations into a single object.\n * Properties / config parameters at a later position overwrite properties from earlier ones.\n */\nfunction mergeConfigs(configs: ApplicationConfig[]): Required<ApplicationConfig> {\n // Merge simple values by assigning them in order\n const mergedConfig: Required<ApplicationConfig> = Object.assign(\n {\n locale: undefined,\n properties: {}\n } satisfies ApplicationConfig,\n ...configs\n );\n\n // Deep merge for application properties\n const mergedProperties: ApplicationProperties = (mergedConfig.properties = {});\n for (const config of configs) {\n for (const [packageName, packageProperties] of Object.entries(config.properties ?? {})) {\n const mergedPackageProps = (mergedProperties[packageName] ??= {});\n Object.assign(mergedPackageProps, packageProperties);\n }\n }\n\n return mergedConfig;\n}\n\n// Applies application styles to the given style node.\n// Can be called multiple times in development mode to implement hot reloading.\nfunction applyStyles(styleNode: HTMLStyleElement, styles: { value: string } | undefined) {\n let cssValue = styles?.value ?? \"\";\n // Remove sourcemaps from inline css.\n // This currently does not work because a) the 'importer' (the index.html file) does not\n // match the actual path the source map would exist and b) vite refuses to generate it anyway, probably\n // because of our virtual modules.\n // TODO: both should be fixed once we can refer to actual `.css` files\n // and don't have to embed inline css anymore.\n cssValue = cssValue.replace(/\\/\\*# sourceMappingURL=.*$/, \"\");\n const cssNode = document.createTextNode(cssValue);\n styleNode.replaceChildren(cssNode);\n}\n\nfunction logError(e: unknown) {\n if (e instanceof Error) {\n const chain = getErrorChain(e).reverse();\n if (chain.length === 1) {\n console.error(e);\n return;\n }\n\n let n = 1;\n for (const error of chain) {\n console.error(`#${n}`, error);\n ++n;\n }\n } else {\n console.error(\"Unexpected error\", e);\n }\n}\n\nfunction emptyComponent() {\n return null;\n}\n"],"names":[],"mappings":";;;;;;;;;;AA8BA,MAAM,GAAA,GAAM,aAAa,uBAAuB,CAAA;AAwHzC,SAAS,oBAAoB,OAA8D,EAAA;AAAA,EAC9F,MAAM,2BA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AA,QAAA,GAAW,QAAQ,KAAS,IAAA,EAAA;AAOhC,EAAW,QAAA,GAAA,QAAA,CAAS,OAAQ,CAAA,4BAAA,EAA8B,EAAE,CAAA;AAC5D,EAAM,MAAA,OAAA,GAAU,QAAS,CAAA,cAAA,CAAe,QAAQ,CAAA;AAChD,EAAA,SAAA,CAAU,gBAAgB,OAAO,CAAA;AACrC;AAEA,SAAS,SAAS,CAAY,EAAA;AAC1B,EAAA,IAAI,aAAa,KAAO,EAAA;AACpB,IAAA,MAAM,KAAQ,GAAA,aAAA,CAAc,CAAC,CAAA,CAAE,OAAQ,EAAA;AACvC,IAAI,IAAA,KAAA,CAAM,WAAW,CAAG,EAAA;AACpB,MAAA,OAAA,CAAQ,MAAM,CAAC,CAAA;AACf,MAAA;AAAA;AAGJ,IAAA,IAAI,CAAI,GAAA,CAAA;AACR,IAAA,KAAA,MAAW,SAAS,KAAO,EAAA;AACvB,MAAA,OAAA,CAAQ,KAAM,CAAA,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,EAAI,KAAK,CAAA;AAC5B,MAAE,EAAA,CAAA;AAAA;AACN,GACG,MAAA;AACH,IAAQ,OAAA,CAAA,KAAA,CAAM,oBAAoB,CAAC,CAAA;AAAA;AAE3C;AAEA,SAAS,cAAiB,GAAA;AACtB,EAAO,OAAA,IAAA;AACX;;;;"}
1
+ {"version":3,"file":"CustomElement.js","sources":["CustomElement.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ComponentType, createElement } from \"react\";\nimport {\n createAbortError,\n createLogger,\n createManualPromise,\n destroyResource,\n Error,\n ManualPromise,\n Resource,\n throwAbortError\n} from \"@open-pioneer/core\";\nimport { ErrorId } from \"./errors\";\nimport { ApplicationMetadata, PackageMetadata } from \"./metadata\";\nimport { PackageRepr, createPackages } from \"./service-layer/PackageRepr\";\nimport { ServiceLayer } from \"./service-layer/ServiceLayer\";\nimport { getErrorChain } from \"@open-pioneer/core\";\nimport { ReactIntegration } from \"./react-integration/ReactIntegration\";\nimport { ApiMethods, ApiService } from \"./api\";\nimport {\n createBuiltinPackage,\n RUNTIME_API_SERVICE,\n RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE,\n RUNTIME_AUTO_START\n} from \"./builtin-services\";\nimport { ReferenceSpec } from \"./service-layer/InterfaceSpec\";\nimport { AppIntl, createPackageIntl, getBrowserLocales, I18nConfig, initI18n } from \"./i18n\";\nimport { ApplicationLifecycleEventService } from \"./builtin-services/ApplicationLifecycleEventService\";\nimport { ErrorScreen, MESSAGES_BY_LOCALE } from \"./ErrorScreen\";\nconst LOG = createLogger(\"runtime:CustomElement\");\n\n/**\n * Options for the {@link createCustomElement} function.\n */\nexport interface CustomElementOptions {\n /**\n * Rendered UI component.\n */\n component?: ComponentType<Record<string, string>>;\n\n /**\n * Application metadata (packages, services etc.).\n * This is usually autogenerated by importing the virtual `\"open-pioneer:app\"` module.\n */\n appMetadata?: ApplicationMetadata;\n\n /**\n * Application defined configuration.\n *\n * This option can be used to override default properties of the application's packages.\n *\n * All instances of the web component will share this static configuration.\n */\n config?: ApplicationConfig;\n\n /**\n * Function to provide additional application defined configuration parameters.\n *\n * Compared to {@link config}, this function receives a context object\n * that allows the developer to provide dynamic properties on a per-application instance basis.\n *\n * Parameters returned by this function take precedence over the ones defined by {@link config}.\n */\n resolveConfig?(ctx: ConfigContext): Promise<ApplicationConfig | undefined>;\n\n /**\n * Chakra theming object.\n */\n theme?: Record<string, unknown>;\n}\n\n/**\n * A context object that is passed to the `resolveProperties` function.\n */\nexport interface ConfigContext {\n /**\n * The application's host element.\n */\n hostElement: HTMLElement;\n\n /**\n * Returns an attribute from the application's root node.\n */\n getAttribute(name: string): string | undefined;\n}\n\n/**\n * Runtime application configuration.\n */\nexport interface ApplicationConfig {\n /**\n * Set this value to a locale string (e.g. \"en\") to for the application's locale.\n * The default behavior is to choose an appropriate locale for the current user based\n * on the browser's settings.\n *\n * The locale must be supported by the application.\n */\n locale?: string | undefined;\n\n /**\n * Properties specified here will override default properties of the application's packages.\n */\n properties?: ApplicationProperties | undefined;\n}\n\n/**\n * Allows the application to override default properties in all packages.\n *\n * Properties are typed when the package contains type definitions for them.\n */\nexport interface ApplicationProperties {\n /**\n * Key: the name of the package.\n * Value: A record of configuration properties (key/value pairs).\n *\n * Properties will override default property values in the package.\n */\n [packageName: string]: Record<string, unknown>;\n}\n\n/**\n * The interface implemented by web components produced via {@link createCustomElement}.\n */\nexport interface ApplicationElement extends HTMLElement {\n /** Resolves to the element's API when the application has started. */\n when(): Promise<ApiMethods>;\n}\n\n/**\n * The class returned by a call to {@link createCustomElement}.\n */\nexport interface ApplicationElementConstructor {\n new (): ApplicationElement;\n}\n\n/**\n * Creates a new custom element class (web component) that can be registered within a DOM.\n *\n * @example\n * ```ts\n * import * as appMetadata from \"open-pioneer:app\";\n *\n * const CustomElementClazz = createCustomElement({\n * component: <div>Hello World!</div>,\n * appMetadata\n * });\n * customElements.define(\"sample-element\", CustomElementClazz);\n * ```\n */\nexport function createCustomElement(options: CustomElementOptions): ApplicationElementConstructor {\n class PioneerApplication extends HTMLElement implements ApplicationElement {\n #shadowRoot: ShadowRoot;\n #instance: ApplicationInstance | undefined;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n #deferredRestart: any; // A Timer\n\n static get observedAttributes(): string[] {\n return [];\n }\n\n constructor() {\n super();\n\n this.#shadowRoot = this.attachShadow({\n mode: \"open\"\n });\n\n if (import.meta.env.DEV) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this as any).$inspectElementState = () => this.#instance;\n }\n }\n\n connectedCallback() {\n LOG.debug(\"Launching application\");\n\n if (this.#instance) {\n this.#instance.destroy();\n }\n\n this.#instance = this.#createApplicationInstance();\n this.#instance.start();\n }\n\n disconnectedCallback() {\n LOG.debug(\"Shutting down application\");\n\n if (this.#deferredRestart) {\n clearTimeout(this.#deferredRestart);\n }\n this.#instance?.destroy();\n this.#instance = undefined;\n\n LOG.debug(\"Application destroyed\");\n }\n\n when() {\n if (!this.#instance) {\n return Promise.reject(\n new Error(\n ErrorId.NOT_MOUNTED,\n \"Cannot use the application's API because the HTML element has not yet been mounted into the DOM.\"\n )\n );\n }\n\n return this.#instance.whenAPI();\n }\n\n #triggerReload(overrides?: ApplicationOverrides) {\n // Defer the restart operation a tiny bit so calling code does not get surprised by the application's destruction.\n if (this.#deferredRestart) {\n clearTimeout(this.#deferredRestart);\n }\n this.#deferredRestart = setTimeout(() => {\n if (!this.#instance) {\n // disconnectedCallback was called in the meantime\n return;\n }\n\n LOG.debug(\"Restarting application with new options\", overrides);\n this.#instance.destroy();\n this.#instance = this.#createApplicationInstance(overrides);\n this.#instance.start();\n }, 1);\n }\n\n #createApplicationInstance(overrides?: ApplicationOverrides) {\n return new ApplicationInstance({\n hostElement: this,\n shadowRoot: this.#shadowRoot,\n elementOptions: options,\n overrides: overrides,\n restart: this.#triggerReload.bind(this)\n });\n }\n }\n return PioneerApplication;\n}\n\ninterface InstanceOptions {\n /** The HTML element that embeds the application. */\n hostElement: HTMLElement;\n\n /** The shadow root inside the host element that contains the rest of the application. */\n shadowRoot: ShadowRoot;\n\n /** Trails options for the application. */\n elementOptions: CustomElementOptions;\n\n /** These have higher priority than the options in `elementOptions`. */\n overrides: ApplicationOverrides | undefined;\n\n /**\n * A callback to restart the application with new options.\n * Currently only used for reloading with a certain locale.\n */\n restart: (overrides?: ApplicationOverrides) => void;\n}\n\ninterface ApplicationOverrides {\n locale?: string;\n}\n\ntype ApplicationState = \"not-started\" | \"starting\" | \"started\" | \"destroyed\" | \"error\";\n\nclass ApplicationInstance {\n private options: InstanceOptions;\n\n // Public API\n private apiPromise: ManualPromise<ApiMethods> | undefined; // Present when callers are waiting for the API\n private api: ApiMethods | undefined; // Present once started\n\n private state: ApplicationState = \"not-started\";\n private container: HTMLDivElement | undefined;\n private config: ApplicationConfig | undefined;\n private serviceLayer: ServiceLayer | undefined;\n private lifecycleEvents: ApplicationLifecycleEventService | undefined;\n private reactIntegration: ReactIntegration | undefined;\n private stylesWatch: Resource | undefined;\n\n constructor(options: InstanceOptions) {\n this.options = options;\n }\n\n start() {\n if (this.state !== \"not-started\") {\n throw new Error(ErrorId.INTERNAL, `Cannot start element in state '${this.state}'`);\n }\n\n this.state = \"starting\";\n this.startImpl().catch((e) => {\n if (this.state === \"destroyed\") return;\n\n logError(e);\n this.reset();\n this.state = \"error\";\n this.showErrorScreen(e);\n });\n }\n\n destroy() {\n if (this.state === \"destroyed\") {\n return;\n }\n\n // Only call event listener when 'started' was also signalled.\n if (this.state === \"started\") {\n try {\n this.triggerApplicationLifecycleEvent(\"before-stop\");\n } catch (e) {\n void e; // Ignored\n }\n }\n this.state = \"destroyed\";\n this.reset();\n }\n\n private reset() {\n this.apiPromise?.reject(createAbortError());\n this.reactIntegration = destroyResource(this.reactIntegration);\n this.options.shadowRoot.replaceChildren();\n this.container = undefined;\n this.lifecycleEvents = undefined;\n this.serviceLayer = destroyResource(this.serviceLayer);\n this.stylesWatch = destroyResource(this.stylesWatch);\n }\n\n whenAPI(): Promise<ApiMethods> {\n if (this.api) {\n return Promise.resolve(this.api);\n }\n\n const apiPromise = (this.apiPromise ??= createManualPromise());\n return apiPromise.promise;\n }\n\n private async startImpl() {\n const { shadowRoot, hostElement, elementOptions, overrides } = this.options;\n\n // Resolve custom application config\n const config = (this.config = await gatherConfig(hostElement, elementOptions, overrides));\n this.checkAbort();\n LOG.debug(\"Application config is\", config);\n\n // Decide on locale and load i18n messages (if any).\n const i18n = await initI18n(elementOptions.appMetadata, config.locale);\n this.checkAbort();\n\n // Setup application root node in the shadow dom\n const container = (this.container = createContainer(i18n.locale));\n const styles = this.initStyles();\n shadowRoot.replaceChildren(container, ...styles);\n\n // Launch the service layer\n const { serviceLayer, packages } = this.initServiceLayer({\n container,\n properties: config.properties,\n i18n\n });\n this.lifecycleEvents = getInternalService<ApplicationLifecycleEventService>(\n serviceLayer,\n RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE\n );\n\n await this.initAPI(serviceLayer);\n this.checkAbort();\n\n // Launch react\n this.reactIntegration = ReactIntegration.createForApp({\n rootNode: container,\n container: shadowRoot,\n theme: elementOptions.theme,\n serviceLayer,\n packages\n });\n const component = this.options.elementOptions.component ?? emptyComponent;\n this.reactIntegration.render(createElement(component));\n this.state = \"started\";\n\n this.triggerApplicationLifecycleEvent(\"after-start\");\n LOG.debug(\"Application started\");\n }\n\n private initStyles() {\n // Prevent inheritance of certain css values and normalize to display: block by default.\n // See https://open-wc.org/guides/knowledge/styling/styles-piercing-shadow-dom/\n const builtinStyles = \":host { all: initial; display: block; }\";\n const builtinStylesNode = document.createElement(\"style\");\n applyStyles(builtinStylesNode, { value: builtinStyles });\n\n const appStyles = this.options.elementOptions.appMetadata?.styles;\n const appStylesNode = document.createElement(\"style\");\n applyStyles(appStylesNode, appStyles);\n if (import.meta.hot) {\n this.stylesWatch = appStyles?.on?.(\"changed\", () => {\n LOG.debug(\"Application styles changed\");\n applyStyles(appStylesNode, appStyles);\n });\n }\n return [builtinStylesNode, appStylesNode];\n }\n\n private initServiceLayer(config: {\n container: HTMLDivElement;\n properties: ApplicationProperties;\n i18n: AppIntl;\n }) {\n const { hostElement, shadowRoot, elementOptions, restart } = this.options;\n const { container, properties, i18n } = config;\n const packageMetadata = elementOptions.appMetadata?.packages ?? {};\n const builtinPackage = createBuiltinPackage({\n host: hostElement,\n shadowRoot: shadowRoot,\n container: container,\n locale: i18n.locale,\n supportedLocales: i18n.supportedMessageLocales,\n changeLocale(locale) {\n const supported = i18n.supportedMessageLocales;\n if (locale != null && !i18n.supportsLocale(locale)) {\n throw new Error(\n ErrorId.UNSUPPORTED_LOCALE,\n `Unsupported locale '${locale}' (supported locales: ${supported.join(\n \", \"\n )}).`\n );\n }\n restart({ locale });\n }\n });\n const { serviceLayer, packages } = createServiceLayer({\n packageMetadata,\n builtinPackage,\n properties,\n i18n\n });\n this.serviceLayer = serviceLayer;\n\n if (LOG.isDebug()) {\n LOG.debug(\"Launching service layer with packages\", Object.fromEntries(packages));\n }\n serviceLayer.start();\n return { serviceLayer, packages };\n }\n\n private async initAPI(serviceLayer: ServiceLayer) {\n const apiService = getInternalService<ApiService>(serviceLayer, RUNTIME_API_SERVICE);\n try {\n const api = (this.api = await apiService.getApi());\n LOG.debug(\"Application API initialized to\", api);\n this.apiPromise?.resolve(api);\n } catch (e) {\n throw new Error(ErrorId.INTERNAL, \"Failed to gather the application's API methods.\", {\n cause: e\n });\n }\n }\n\n private triggerApplicationLifecycleEvent(event: \"after-start\" | \"before-stop\") {\n this.lifecycleEvents?.emitLifecycleEvent(event);\n }\n\n private checkAbort() {\n if (this.state === \"destroyed\") {\n throwAbortError();\n }\n }\n\n private showErrorScreen(error: globalThis.Error) {\n const { shadowRoot, elementOptions } = this.options;\n\n const userLocales = getBrowserLocales();\n const i18nConfig = new I18nConfig(Object.keys(MESSAGES_BY_LOCALE));\n const { locale, messageLocale } = i18nConfig.pickSupportedLocale(undefined, userLocales);\n\n const container = (this.container = createContainer(locale));\n container.classList.add(\"pioneer-root-error-screen\");\n\n const messages =\n MESSAGES_BY_LOCALE[messageLocale as keyof typeof MESSAGES_BY_LOCALE] ??\n MESSAGES_BY_LOCALE[\"en\"];\n const intl = createPackageIntl(locale, messages);\n this.reactIntegration = ReactIntegration.createForErrorScreen({\n rootNode: container,\n container: shadowRoot,\n theme: elementOptions.theme\n });\n this.reactIntegration.render(createElement(ErrorScreen, { intl, error }));\n\n shadowRoot.replaceChildren(container);\n }\n}\n\nfunction createContainer(locale: string) {\n // Setup application root node in the shadow dom\n const container = document.createElement(\"div\");\n container.classList.add(\"pioneer-root\");\n container.style.minHeight = \"100%\";\n container.style.height = \"100%\";\n if (locale) {\n container.lang = locale;\n }\n return container;\n}\n\nfunction createServiceLayer(config: {\n packageMetadata: Record<string, PackageMetadata> | undefined;\n properties: ApplicationProperties;\n builtinPackage: PackageRepr;\n i18n: AppIntl;\n}) {\n const { packageMetadata, properties, builtinPackage, i18n } = config;\n\n let packages: PackageRepr[];\n try {\n packages = createPackages(packageMetadata ?? {}, i18n, properties);\n } catch (e) {\n throw new Error(ErrorId.INVALID_METADATA, \"Failed to parse package metadata.\", {\n cause: e\n });\n }\n\n // Add builtin services defined within this package.\n {\n const index = packages.findIndex((pkg) => pkg.name === builtinPackage.name);\n if (index >= 0) {\n packages.splice(index, 1);\n }\n packages.push(builtinPackage);\n }\n\n // Automatically required references (-> forces services to start)\n const forcedReferences: ReferenceSpec[] = [\n {\n interfaceName: RUNTIME_API_SERVICE\n },\n {\n interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE\n },\n {\n interfaceName: RUNTIME_AUTO_START,\n all: true\n }\n ];\n const serviceLayer = new ServiceLayer(packages, forcedReferences);\n return {\n packages: new Map(packages.map((pkg) => [pkg.name, pkg])),\n serviceLayer: serviceLayer\n };\n}\n\nfunction getInternalService<T = unknown>(serviceLayer: ServiceLayer, interfaceName: string) {\n const result = serviceLayer.getService(\n \"@open-pioneer/runtime\",\n {\n interfaceName\n },\n { ignoreDeclarationCheck: true }\n );\n if (result.type !== \"found\") {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find instance of '${interfaceName}' (result type '${result.type}').` +\n ` This is a builtin service that must be present exactly once.`\n );\n }\n\n return result.value.getInstanceOrThrow() as T;\n}\n\n/**\n * Gathers application properties by reading them from the options object\n * and by (optionally) invoking the `resolveProperties` hook.\n */\nasync function gatherConfig(\n hostElement: HTMLElement,\n options: CustomElementOptions,\n overrides?: ApplicationOverrides\n) {\n let configs: ApplicationConfig[];\n try {\n const staticConfig = options.config ?? {};\n const dynamicConfig =\n (await options.resolveConfig?.({\n hostElement,\n getAttribute(name) {\n return hostElement.getAttribute(name) ?? undefined;\n }\n })) ?? {};\n\n configs = [staticConfig, dynamicConfig];\n } catch (e) {\n throw new Error(\n ErrorId.CONFIG_RESOLUTION_FAILED,\n \"Failed to resolve application properties.\",\n {\n cause: e\n }\n );\n }\n\n const merged = mergeConfigs(configs);\n if (overrides?.locale) {\n merged.locale = overrides.locale;\n }\n return merged;\n}\n\n/**\n * Merges application configurations into a single object.\n * Properties / config parameters at a later position overwrite properties from earlier ones.\n */\nfunction mergeConfigs(configs: ApplicationConfig[]): Required<ApplicationConfig> {\n // Merge simple values by assigning them in order\n const mergedConfig: Required<ApplicationConfig> = Object.assign(\n {\n locale: undefined,\n properties: {}\n } satisfies ApplicationConfig,\n ...configs\n );\n\n // Deep merge for application properties\n const mergedProperties: ApplicationProperties = (mergedConfig.properties = {});\n for (const config of configs) {\n for (const [packageName, packageProperties] of Object.entries(config.properties ?? {})) {\n const mergedPackageProps = (mergedProperties[packageName] ??= {});\n Object.assign(mergedPackageProps, packageProperties);\n }\n }\n\n return mergedConfig;\n}\n\n// Applies application styles to the given style node.\n// Can be called multiple times in development mode to implement hot reloading.\nfunction applyStyles(styleNode: HTMLStyleElement, styles: { value: string } | undefined) {\n let cssValue = styles?.value ?? \"\";\n // Remove sourcemaps from inline css.\n // This currently does not work because a) the 'importer' (the index.html file) does not\n // match the actual path the source map would exist and b) vite refuses to generate it anyway, probably\n // because of our virtual modules.\n // TODO: both should be fixed once we can refer to actual `.css` files\n // and don't have to embed inline css anymore.\n cssValue = cssValue.replace(/\\/\\*# sourceMappingURL=.*$/, \"\");\n const cssNode = document.createTextNode(cssValue);\n styleNode.replaceChildren(cssNode);\n}\n\nfunction logError(e: unknown) {\n if (e instanceof Error) {\n const chain = getErrorChain(e).reverse();\n if (chain.length === 1) {\n console.error(e);\n return;\n }\n\n let n = 1;\n for (const error of chain) {\n console.error(`#${n}`, error);\n ++n;\n }\n } else {\n console.error(\"Unexpected error\", e);\n }\n}\n\nfunction emptyComponent() {\n return null;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AA8BA,MAAM,GAAA,GAAM,aAAa,uBAAuB,CAAA;AAwHzC,SAAS,oBAAoB,OAA8D,EAAA;AAAA,EAC9F,MAAM,2BAA2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,QAAA,GAAW,QAAQ,KAAS,IAAA,EAAA;AAOhC,EAAW,QAAA,GAAA,QAAA,CAAS,OAAQ,CAAA,4BAAA,EAA8B,EAAE,CAAA;AAC5D,EAAM,MAAA,OAAA,GAAU,QAAS,CAAA,cAAA,CAAe,QAAQ,CAAA;AAChD,EAAA,SAAA,CAAU,gBAAgB,OAAO,CAAA;AACrC;AAEA,SAAS,SAAS,CAAY,EAAA;AAC1B,EAAA,IAAI,aAAa,KAAO,EAAA;AACpB,IAAA,MAAM,KAAQ,GAAA,aAAA,CAAc,CAAC,CAAA,CAAE,OAAQ,EAAA;AACvC,IAAI,IAAA,KAAA,CAAM,WAAW,CAAG,EAAA;AACpB,MAAA,OAAA,CAAQ,MAAM,CAAC,CAAA;AACf,MAAA;AAAA;AAGJ,IAAA,IAAI,CAAI,GAAA,CAAA;AACR,IAAA,KAAA,MAAW,SAAS,KAAO,EAAA;AACvB,MAAA,OAAA,CAAQ,KAAM,CAAA,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,EAAI,KAAK,CAAA;AAC5B,MAAE,EAAA,CAAA;AAAA;AACN,GACG,MAAA;AACH,IAAQ,OAAA,CAAA,KAAA,CAAM,oBAAoB,CAAC,CAAA;AAAA;AAE3C;AAEA,SAAS,cAAiB,GAAA;AACtB,EAAO,OAAA,IAAA;AACX;;;;"}
@@ -1,4 +1,6 @@
1
- import { createEmptyI18n } from '../i18n.js';
1
+ import '../i18n/AppIntl.js';
2
+ import { createEmptyPackageIntl } from '../i18n/PackageIntl.js';
3
+ import '../i18n/pick.js';
2
4
  import { PackageRepr } from '../service-layer/PackageRepr.js';
3
5
  import { ServiceRepr, createConstructorFactory, createFunctionFactory } from '../service-layer/ServiceRepr.js';
4
6
  import { ApiServiceImpl } from './ApiServiceImpl.js';
@@ -14,7 +16,7 @@ const RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE = "runtime.ApplicationLifecycl
14
16
  const RUNTIME_NUMBER_PARSER_SERVICE = "runtime.NumberParserService";
15
17
  const RUNTIME_AUTO_START = "runtime.AutoStart";
16
18
  function createBuiltinPackage(properties) {
17
- const i18n = createEmptyI18n();
19
+ const i18n = createEmptyPackageIntl();
18
20
  const apiService = new ServiceRepr({
19
21
  name: "ApiServiceImpl",
20
22
  packageName: RUNTIME_PACKAGE_NAME,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createEmptyI18n } from \"../i18n\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport {\n createConstructorFactory,\n createFunctionFactory,\n ServiceRepr\n} from \"../service-layer/ServiceRepr\";\nimport { ApiServiceImpl } from \"./ApiServiceImpl\";\nimport { ApplicationContextImpl, ApplicationContextProperties } from \"./ApplicationContextImpl\";\nimport { ApplicationLifecycleEventService } from \"./ApplicationLifecycleEventService\";\nimport { NumberParserServiceImpl } from \"./NumberParserServiceImpl\";\n\nexport const RUNTIME_PACKAGE_NAME = \"@open-pioneer/runtime\";\nexport const RUNTIME_API_EXTENSION = \"integration.ApiExtension\";\nexport const RUNTIME_API_SERVICE = \"runtime.ApiService\";\nexport const RUNTIME_APPLICATION_CONTEXT = \"runtime.ApplicationContext\";\nexport const RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE =\n \"runtime.ApplicationLifecycleEventService\";\nexport const RUNTIME_NUMBER_PARSER_SERVICE = \"runtime.NumberParserService\";\nexport const RUNTIME_AUTO_START = \"runtime.AutoStart\";\n\nexport type BuiltinPackageProperties = ApplicationContextProperties;\n\n/**\n * Creates the builtin package containing the builtin services.\n *\n * The runtime package should not use services in the `build.config.mjs`\n * for a clean bootstrapping procedure (it will be instantiated without\n * generated application metadata in tests).\n *\n * This function is called as part of the service layer startup.\n * The package produced here is always part of the application.\n */\nexport function createBuiltinPackage(properties: BuiltinPackageProperties): PackageRepr {\n const i18n = createEmptyI18n();\n const apiService = new ServiceRepr({\n name: \"ApiServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApiServiceImpl),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_API_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"providers\",\n interfaceName: RUNTIME_API_EXTENSION,\n all: true\n }\n ]\n });\n const appContext = new ServiceRepr({\n name: \"ApplicationContextImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(\n (options) => new ApplicationContextImpl(options, properties)\n ),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_CONTEXT,\n qualifier: \"builtin\"\n }\n ]\n });\n const lifecycleEventService = new ServiceRepr({\n name: \"ApplicationLifecycleEventServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApplicationLifecycleEventService),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"listeners\",\n interfaceName: \"runtime.ApplicationLifecycleListener\",\n all: true\n }\n ]\n });\n const numberParserService = new ServiceRepr({\n name: \"NumberParserServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(\n (options) => new NumberParserServiceImpl(options, properties.locale)\n ),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_NUMBER_PARSER_SERVICE,\n qualifier: \"builtin\"\n }\n ]\n });\n\n return new PackageRepr({\n name: RUNTIME_PACKAGE_NAME,\n services: [apiService, appContext, lifecycleEventService, numberParserService],\n intl: i18n\n });\n}\n"],"names":[],"mappings":";;;;;;;;AAcO,MAAM,oBAAuB,GAAA;AAC7B,MAAM,qBAAwB,GAAA;AAC9B,MAAM,mBAAsB,GAAA;AAC5B,MAAM,2BAA8B,GAAA;AACpC,MAAM,2CACT,GAA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AA,MACV;AAAA,QACI,aAAe,EAAA,WAAA;AAAA,QACf,aAAe,EAAA,sCAAA;AAAA,QACf,GAAK,EAAA;AAAA;AACT;AACJ,GACH,CAAA;AACD,EAAM,MAAA,mBAAA,GAAsB,IAAI,WAAY,CAAA;AAAA,IACxC,IAAM,EAAA,yBAAA;AAAA,IACN,WAAa,EAAA,oBAAA;AAAA,IACb,OAAS,EAAA,qBAAA;AAAA,MACL,CAAC,OAAY,KAAA,IAAI,uBAAwB,CAAA,OAAA,EAAS,WAAW,MAAM;AAAA,KACvE;AAAA,IACA,IAAM,EAAA,IAAA;AAAA,IACN,UAAY,EAAA;AAAA,MACR;AAAA,QACI,aAAe,EAAA,6BAAA;AAAA,QACf,SAAW,EAAA;AAAA;AACf;AACJ,GACH,CAAA;AAED,EAAA,OAAO,IAAI,WAAY,CAAA;AAAA,IACnB,IAAM,EAAA,oBAAA;AAAA,IACN,QAAU,EAAA,CAAC,UAAY,EAAA,UAAA,EAAY,uBAAuB,mBAAmB,CAAA;AAAA,IAC7E,IAAM,EAAA;AAAA,GACT,CAAA;AACL;;;;"}
1
+ {"version":3,"file":"index.js","sources":["index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createEmptyPackageIntl } from \"../i18n\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport {\n createConstructorFactory,\n createFunctionFactory,\n ServiceRepr\n} from \"../service-layer/ServiceRepr\";\nimport { ApiServiceImpl } from \"./ApiServiceImpl\";\nimport { ApplicationContextImpl, ApplicationContextProperties } from \"./ApplicationContextImpl\";\nimport { ApplicationLifecycleEventService } from \"./ApplicationLifecycleEventService\";\nimport { NumberParserServiceImpl } from \"./NumberParserServiceImpl\";\n\nexport const RUNTIME_PACKAGE_NAME = \"@open-pioneer/runtime\";\nexport const RUNTIME_API_EXTENSION = \"integration.ApiExtension\";\nexport const RUNTIME_API_SERVICE = \"runtime.ApiService\";\nexport const RUNTIME_APPLICATION_CONTEXT = \"runtime.ApplicationContext\";\nexport const RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE =\n \"runtime.ApplicationLifecycleEventService\";\nexport const RUNTIME_NUMBER_PARSER_SERVICE = \"runtime.NumberParserService\";\nexport const RUNTIME_AUTO_START = \"runtime.AutoStart\";\n\nexport type BuiltinPackageProperties = ApplicationContextProperties;\n\n/**\n * Creates the builtin package containing the builtin services.\n *\n * The runtime package should not use services in the `build.config.mjs`\n * for a clean bootstrapping procedure (it will be instantiated without\n * generated application metadata in tests).\n *\n * This function is called as part of the service layer startup.\n * The package produced here is always part of the application.\n */\nexport function createBuiltinPackage(properties: BuiltinPackageProperties): PackageRepr {\n const i18n = createEmptyPackageIntl();\n const apiService = new ServiceRepr({\n name: \"ApiServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApiServiceImpl),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_API_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"providers\",\n interfaceName: RUNTIME_API_EXTENSION,\n all: true\n }\n ]\n });\n const appContext = new ServiceRepr({\n name: \"ApplicationContextImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(\n (options) => new ApplicationContextImpl(options, properties)\n ),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_CONTEXT,\n qualifier: \"builtin\"\n }\n ]\n });\n const lifecycleEventService = new ServiceRepr({\n name: \"ApplicationLifecycleEventServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApplicationLifecycleEventService),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"listeners\",\n interfaceName: \"runtime.ApplicationLifecycleListener\",\n all: true\n }\n ]\n });\n const numberParserService = new ServiceRepr({\n name: \"NumberParserServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(\n (options) => new NumberParserServiceImpl(options, properties.locale)\n ),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_NUMBER_PARSER_SERVICE,\n qualifier: \"builtin\"\n }\n ]\n });\n\n return new PackageRepr({\n name: RUNTIME_PACKAGE_NAME,\n services: [apiService, appContext, lifecycleEventService, numberParserService],\n intl: i18n\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;AAcO,MAAM,oBAAuB,GAAA;AAC7B,MAAM,qBAAwB,GAAA;AAC9B,MAAM,mBAAsB,GAAA;AAC5B,MAAM,2BAA8B,GAAA;AACpC,MAAM,2CACT,GAAA;AACG,MAAM,6BAAgC,GAAA;AACtC,MAAM,kBAAqB,GAAA;AAc3B,SAAS,qBAAqB,UAAmD,EAAA;AACpF,EAAA,MAAM,OAAO,sBAAuB,EAAA;AACpC,EAAM,MAAA,UAAA,GAAa,IAAI,WAAY,CAAA;AAAA,IAC/B,IAAM,EAAA,gBAAA;AAAA,IACN,WAAa,EAAA,oBAAA;AAAA,IACb,OAAA,EAAS,yBAAyB,cAAc,CAAA;AAAA,IAChD,IAAM,EAAA,IAAA;AAAA,IACN,UAAY,EAAA;AAAA,MACR;AAAA,QACI,aAAe,EAAA,mBAAA;AAAA,QACf,SAAW,EAAA;AAAA;AACf,KACJ;AAAA,IACA,YAAc,EAAA;AAAA,MACV;AAAA,QACI,aAAe,EAAA,WAAA;AAAA,QACf,aAAe,EAAA,qBAAA;AAAA,QACf,GAAK,EAAA;AAAA;AACT;AACJ,GACH,CAAA;AACD,EAAM,MAAA,UAAA,GAAa,IAAI,WAAY,CAAA;AAAA,IAC/B,IAAM,EAAA,wBAAA;AAAA,IACN,WAAa,EAAA,oBAAA;AAAA,IACb,OAAS,EAAA,qBAAA;AAAA,MACL,CAAC,OAAA,KAAY,IAAI,sBAAA,CAAuB,SAAS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ackageIntl";
3
+ /**
4
+ * Represents i18n info for the entire application.
5
+ * Currently not exposed to user code.
6
+ */
7
+ export interface AppIntl {
8
+ /** Chosen locale */
9
+ readonly locale: string;
10
+ /** Supported locales from app metadata. */
11
+ readonly supportedMessageLocales: string[];
12
+ /** True if the locale can be used in this application (i.e. if there are any messages). */
13
+ supportsLocale(locale: string): boolean;
14
+ /** Given the package name, constructs a package i18n instance. */
15
+ createPackageI18n(packageName: string): PackageIntl;
16
+ }
17
+ /**
18
+ * Initializes the application's locale and fetches the appropriate i18n messages.
19
+ */
20
+ export declare function initI18n(appMetadata: ApplicationMetadata | undefined, forcedLocale: string | undefined): Promise<AppIntl>;
@@ -0,0 +1,52 @@
1
+ import { createLogger, Error } from '@open-pioneer/core';
2
+ import { ErrorId } from '../errors.js';
3
+ import { createPackageIntl } from './PackageIntl.js';
4
+ import { getBrowserLocales, I18nConfig } from './pick.js';
5
+
6
+ const LOG = createLogger("runtime:i18n");
7
+ async function initI18n(appMetadata, forcedLocale) {
8
+ const messageLocales = appMetadata?.locales ?? [];
9
+ const userLocales = getBrowserLocales();
10
+ if (LOG.isDebug()) {
11
+ LOG.debug(
12
+ `Attempting to pick locale for user (locales: ${userLocales.join(
13
+ ", "
14
+ )}) from app (supported locales: ${messageLocales.join(
15
+ ", "
16
+ )}) [forcedLocale=${forcedLocale}].`
17
+ );
18
+ }
19
+ const i18nConfig = new I18nConfig(messageLocales);
20
+ const { locale, messageLocale } = i18nConfig.pickSupportedLocale(forcedLocale, userLocales);
21
+ if (LOG.isDebug()) {
22
+ LOG.debug(`Using locale '${locale}' with messages from locale '${messageLocale}'.`);
23
+ }
24
+ let messages;
25
+ if (messageLocales.includes(messageLocale)) {
26
+ try {
27
+ messages = await appMetadata?.loadMessages?.(messageLocale) ?? {};
28
+ } catch (e) {
29
+ throw new Error(
30
+ ErrorId.INTERNAL,
31
+ `Failed to load messages for locale '${messageLocale}'.`,
32
+ {
33
+ cause: e
34
+ }
35
+ );
36
+ }
37
+ }
38
+ return {
39
+ locale,
40
+ supportedMessageLocales: messageLocales,
41
+ supportsLocale(locale2) {
42
+ return i18nConfig.supportsLocale(locale2);
43
+ },
44
+ createPackageI18n(packageName) {
45
+ const packageMessage = messages?.[packageName] ?? {};
46
+ return createPackageIntl(locale, packageMessage);
47
+ }
48
+ };
49
+ }
50
+
51
+ export { initI18n };
52
+ //# sourceMappingURL=AppIntl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppIntl.js","sources":["AppIntl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger, Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\nimport { ApplicationMetadata } from \"../metadata\";\nimport { createPackageIntl, PackageIntl } from \"./PackageIntl\";\nimport { getBrowserLocales, I18nConfig } from \"./pick\";\nconst LOG = createLogger(\"runtime:i18n\");\n\n/**\n * Represents i18n info for the entire application.\n * Currently not exposed to user code.\n */\nexport interface AppIntl {\n /** Chosen locale */\n readonly locale: string;\n\n /** Supported locales from app metadata. */\n readonly supportedMessageLocales: string[];\n\n /** True if the locale can be used in this application (i.e. if there are any messages). */\n supportsLocale(locale: string): boolean;\n\n /** Given the package name, constructs a package i18n instance. */\n createPackageI18n(packageName: string): PackageIntl;\n}\n\n/**\n * Initializes the application's locale and fetches the appropriate i18n messages.\n */\nexport async function initI18n(\n appMetadata: ApplicationMetadata | undefined,\n forcedLocale: string | undefined\n): Promise<AppIntl> {\n const messageLocales = appMetadata?.locales ?? [];\n const userLocales = getBrowserLocales();\n if (LOG.isDebug()) {\n LOG.debug(\n `Attempting to pick locale for user (locales: ${userLocales.join(\n \", \"\n )}) from app (supported locales: ${messageLocales.join(\n \", \"\n )}) [forcedLocale=${forcedLocale}].`\n );\n }\n\n const i18nConfig = new I18nConfig(messageLocales);\n const { locale, messageLocale } = i18nConfig.pickSupportedLocale(forcedLocale, userLocales);\n\n if (LOG.isDebug()) {\n LOG.debug(`Using locale '${locale}' with messages from locale '${messageLocale}'.`);\n }\n\n let messages: Record<string, Record<string, string>>;\n if (messageLocales.includes(messageLocale)) {\n try {\n messages = (await appMetadata?.loadMessages?.(messageLocale)) ?? {};\n } catch (e) {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to load messages for locale '${messageLocale}'.`,\n {\n cause: e\n }\n );\n }\n }\n return {\n locale,\n supportedMessageLocales: messageLocales,\n supportsLocale(locale) {\n return i18nConfig.supportsLocale(locale);\n },\n createPackageI18n(packageName) {\n const packageMessage = messages?.[packageName] ?? {};\n return createPackageIntl(locale, packageMessage);\n }\n };\n}\n"],"names":["locale"],"mappings":";;;;;AAOA,MAAM,GAAA,GAAM,aAAa,cAAc,CAAA;AAuBjB,eAAA,QAAA,CAClB,aACA,YACgB,EAAA;AAChB,EAAM,MAAA,cAAA,GAAiB,WAAa,EAAA,OAAA,IAAW,EAAC;AAChD,EAAA,MAAM,cAAc,iBAAkB,EAAA;AACtC,EAAI,IAAA,GAAA,CAAI,SAAW,EAAA;AACf,IAAI,GAAA,CAAA,KAAA;AAAA,MACA,gDAAgD,WAAY,CAAA,IAAA;AAAA,QACxD;AAAA,OACH,kCAAkC,cAAe,CAAA,IAAA;AAAA,QAC9C;AAAA,OACH,mBAAmB,YAAY,CAAA,EAAA;AAAA,KACpC;AAAA;AAGJ,EAAM,MAAA,UAAA,GAAa,IAAI,UAAA,CAAW,cAAc,CAAA;AAChD,EAAA,MAAM,EAAE,MAAQ,EAAA,aAAA,KAAkB,UAAW,CAAA,mBAAA,CAAoB,cAAc,WAAW,CAAA;AAE1F,EAAI,IAAA,GAAA,CAAI,SAAW,EAAA;AACf,IAAA,GAAA,CAAI,KAAM,CAAA,CAAA,cAAA,EAAiB,MAAM,CAAA,6BAAA,EAAgC,aAAa,CAAI,EAAA,CAAA,CAAA;AAAA;AAGtF,EAAI,IAAA,QAAA;AACJ,EAAI,IAAA,cAAA,CAAe,QAAS,CAAA,aAAa,CAAG,EAAA;AACxC,IAAI,IAAA;AACA,MAAA,QAAA,GAAY,MAAM,WAAA,EAAa,YAAe,GAAA,aAAa,KAAM,EAAC;AAAA,aAC7D,CAAG,EAAA;AACR,MAAA,MAAM,IAAI,KAAA;AAAA,QACN,OAAQ,CAAA,QAAA;AAAA,QACR,uCAAuC,aAAa,CAAA,EAAA,CAAA;AAAA,QACpD;AAAA,UACI,KAAO,EAAA;AAAA;AACX,OACJ;AAAA;AACJ;AAEJ,EAAO,OAAA;AAAA,IACH,MAAA;AAAA,IACA,uBAAyB,EAAA,cAAA;AAAA,IACzB,eAAeA,OAAQ,EAAA;AACnB,MAAO,OAAA,UAAA,CAAW,eAAeA,OAAM,CAAA;AAAA,KAC3C;AAAA,IACA,kBAAkB,WAAa,EAAA;AAC3B,MAAA,MAAM,cAAiB,GAAA,QAAA,GAAW,WAAW,CAAA,IAAK,EAAC;AACnD,MAAO,OAAA,iBAAA,CAAkB,QAAQ,cAAc,CAAA;AAAA;AACnD,GACJ;AACJ;;;;"}
@@ -0,0 +1,99 @@
1
+ import { IntlFormatters, IntlShape, MessageDescriptor } from "@formatjs/intl";
2
+ import { type FormatXMLElementFn, type Options as IntlMessageFormatOptions, type PrimitiveType } from "intl-messageformat";
3
+ import { ReactNode } from "react";
4
+ type BaseIntl = Pick<IntlShape, "locale" | "timeZone"> & Omit<IntlFormatters<string>, "formatMessage">;
5
+ /**
6
+ * Gives access to the package's i18n messages for the current locale.
7
+ *
8
+ * See also https://formatjs.io/docs/intl
9
+ */
10
+ export type PackageIntl = BaseIntl & PackageIntlExtensions;
11
+ /**
12
+ * Trails specific extensions to FormatJS' intl API.
13
+ */
14
+ export interface PackageIntlExtensions {
15
+ /**
16
+ * Formats a message with the given descriptor and values.
17
+ *
18
+ * This is a method directly implemented by FormatJS see
19
+ * - [Documentation](<https://formatjs.github.io/docs/intl/#formatmessage>)
20
+ * - {@link IntlShape.formatMessage | Base Implementation}
21
+ *
22
+ * The typings here make the signature a little bit stricter: only primitive values
23
+ * are allowed for formatting.
24
+ *
25
+ * If you need rich text (react) formatting, see {@link PackageIntlExtensions.formatRichMessage}.
26
+ */
27
+ formatMessage(this: void, descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: IntlMessageFormatOptions): string;
28
+ /**
29
+ * Similar to `formatMessage()`, but supports _rich text formatting_.
30
+ *
31
+ * React nodes are supported as input values, and custom tags can be implemented as react components.
32
+ * Note that the output is always a single react node.
33
+ *
34
+ * *Example with react node as value:*
35
+ *
36
+ * ```tsx
37
+ * function Example() {
38
+ * const intl = useIntl();
39
+ * // Given i18n message "Hello, {name}!"
40
+ * // replaces 'name' with the given react node:
41
+ * const message = intl.formatRichMessage({ id: "foo"}, {
42
+ * name: <FancyUserName />
43
+ * });
44
+ * return <Box>{message}</Box>;
45
+ * }
46
+ * ```
47
+ *
48
+ * *Example with basic formatting:*
49
+ *
50
+ * ```tsx
51
+ * function Example() {
52
+ * const intl = useIntl();
53
+ * // Given i18n message "Hello, <strong>{name}</strong>!"
54
+ * // renders with actual <strong> html node:
55
+ * return <Box>{intl.formatRichMessage({ id: "foo"}, { name: "User" })}</Box>;
56
+ * }
57
+ * ```
58
+ *
59
+ * Note that only a few basic formatting tags are predefined ("b", "strong", "i", "em", "code", "br").
60
+ * If you need more advanced tags, you can define your own, see below.
61
+ *
62
+ * *Example with custom tag:*
63
+ *
64
+ * ```tsx
65
+ * function Example() {
66
+ * const intl = useIntl();
67
+ * // Given i18n message "Open <foo>the door</foo>!",
68
+ * // renders 'foo' using the formatter function below:
69
+ * const message = intl.formatRichMessage({ id: "foo"}, {
70
+ * foo: (parts) => <FancyTag>{parts}</FancyTag>
71
+ * });
72
+ * return <Box>{message}</Box>;
73
+ * }
74
+ * ```
75
+ */
76
+ formatRichMessage: (descriptor: MessageDescriptor, values?: Record<string, RichTextValue>, opts?: IntlMessageFormatOptions) => ReactNode;
77
+ }
78
+ /**
79
+ * Value types supported when rendering rich text messages.
80
+ * Primitive values (or single react nodes) are used for normal values.
81
+ * Functions are used to define how tags should be rendered.
82
+ *
83
+ * See {@link PackageIntlExtensions.formatRichMessage}
84
+ */
85
+ export type RichTextValue = PrimitiveType | ReactNode | FormatXMLElementFn<ReactNode>;
86
+ /**
87
+ * Creates a package intl instance with the given locale and messages.
88
+ *
89
+ * @internal
90
+ */
91
+ export declare function createPackageIntl(locale: string, messages: Record<string, string>, options?: {
92
+ /** Used during testing to suppress console messages. */
93
+ suppressNotFoundError?: boolean;
94
+ /** Also used during testing */
95
+ defaultLocale?: string;
96
+ }): PackageIntl;
97
+ /** Creates an empty i18n instance, e.g. for tests. */
98
+ export declare function createEmptyPackageIntl(locale?: string): PackageIntl;
99
+ export {};
@@ -0,0 +1,69 @@
1
+ import { createIntlCache, createIntl, IntlErrorCode } from '@formatjs/intl';
2
+ import { createElement, Fragment, Children } from 'react';
3
+
4
+ function createPackageIntl(locale, messages, options) {
5
+ const cache = createIntlCache();
6
+ const config = {
7
+ locale,
8
+ messages
9
+ };
10
+ if (options?.suppressNotFoundError) {
11
+ config.onError = ignoreMissingTranslationError;
12
+ }
13
+ if (options?.defaultLocale) {
14
+ config.defaultLocale = options.defaultLocale;
15
+ }
16
+ const intl = createIntl(config, cache);
17
+ intl.formatRichMessage = formatRichMessage.bind(void 0, intl);
18
+ return intl;
19
+ }
20
+ function createEmptyPackageIntl(locale = "en") {
21
+ return createPackageIntl(locale, {});
22
+ }
23
+ const RICH_TEXT_TAGS = Object.freeze({
24
+ "b": renderTag("b"),
25
+ "strong": renderTag("strong"),
26
+ "i": renderTag("i"),
27
+ "em": renderTag("em"),
28
+ "code": renderTag("code"),
29
+ "br": renderTag("br")
30
+ });
31
+ function formatRichMessage(intl, descriptor, values, opts) {
32
+ values = {
33
+ ...RICH_TEXT_TAGS,
34
+ ...values
35
+ };
36
+ const formatResult = intl.formatMessage(descriptor, preprocessValues(values), opts);
37
+ return createElement(Fragment, void 0, ...formatResult);
38
+ }
39
+ function preprocessValues(values) {
40
+ if (!values) {
41
+ return void 0;
42
+ }
43
+ const fixedValues = {};
44
+ for (const [key, valueOrFn] of Object.entries(values)) {
45
+ let fixedValue = valueOrFn;
46
+ if (typeof valueOrFn === "function") {
47
+ fixedValue = (parts) => toKeyedChildren(valueOrFn(parts));
48
+ }
49
+ fixedValues[key] = fixedValue;
50
+ }
51
+ return fixedValues;
52
+ }
53
+ function renderTag(tag) {
54
+ return function renderRichTag(parts) {
55
+ return createElement(tag, void 0, ...parts);
56
+ };
57
+ }
58
+ function toKeyedChildren(children) {
59
+ return Children.toArray(children);
60
+ }
61
+ const ignoreMissingTranslationError = (err) => {
62
+ if (err.code === IntlErrorCode.MISSING_TRANSLATION) {
63
+ return;
64
+ }
65
+ console.error(err);
66
+ };
67
+
68
+ export { createEmptyPackageIntl, createPackageIntl };
69
+ //# sourceMappingURL=PackageIntl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageIntl.js","sources":["PackageIntl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n createIntl,\n createIntlCache,\n IntlConfig,\n IntlErrorCode,\n IntlFormatters,\n IntlShape,\n MessageDescriptor,\n OnErrorFn\n} from \"@formatjs/intl\";\nimport {\n type FormatXMLElementFn,\n type Options as IntlMessageFormatOptions,\n type PrimitiveType\n} from \"intl-messageformat\"; // not a dependency, this is a dependency of formatjs\nimport { createElement, Fragment, ReactNode, Children } from \"react\";\n\ntype BaseIntl = Pick<IntlShape, \"locale\" | \"timeZone\"> &\n Omit<IntlFormatters<string>, \"formatMessage\">;\n\n/**\n * Gives access to the package's i18n messages for the current locale.\n *\n * See also https://formatjs.io/docs/intl\n */\nexport type PackageIntl = BaseIntl & PackageIntlExtensions;\n\n/**\n * Trails specific extensions to FormatJS' intl API.\n */\nexport interface PackageIntlExtensions {\n /**\n * Formats a message with the given descriptor and values.\n *\n * This is a method directly implemented by FormatJS see\n * - [Documentation](<https://formatjs.github.io/docs/intl/#formatmessage>)\n * - {@link IntlShape.formatMessage | Base Implementation}\n *\n * The typings here make the signature a little bit stricter: only primitive values\n * are allowed for formatting.\n *\n * If you need rich text (react) formatting, see {@link PackageIntlExtensions.formatRichMessage}.\n */\n formatMessage(\n this: void,\n descriptor: MessageDescriptor,\n values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>,\n opts?: IntlMessageFormatOptions\n ): string;\n\n /**\n * Similar to `formatMessage()`, but supports _rich text formatting_.\n *\n * React nodes are supported as input values, and custom tags can be implemented as react components.\n * Note that the output is always a single react node.\n *\n * *Example with react node as value:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Hello, {name}!\"\n * // replaces 'name' with the given react node:\n * const message = intl.formatRichMessage({ id: \"foo\"}, {\n * name: <FancyUserName />\n * });\n * return <Box>{message}</Box>;\n * }\n * ```\n *\n * *Example with basic formatting:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Hello, <strong>{name}</strong>!\"\n * // renders with actual <strong> html node:\n * return <Box>{intl.formatRichMessage({ id: \"foo\"}, { name: \"User\" })}</Box>;\n * }\n * ```\n *\n * Note that only a few basic formatting tags are predefined (\"b\", \"strong\", \"i\", \"em\", \"code\", \"br\").\n * If you need more advanced tags, you can define your own, see below.\n *\n * *Example with custom tag:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Open <foo>the door</foo>!\",\n * // renders 'foo' using the formatter function below:\n * const message = intl.formatRichMessage({ id: \"foo\"}, {\n * foo: (parts) => <FancyTag>{parts}</FancyTag>\n * });\n * return <Box>{message}</Box>;\n * }\n * ```\n */\n formatRichMessage: (\n descriptor: MessageDescriptor,\n values?: Record<string, RichTextValue>,\n opts?: IntlMessageFormatOptions\n ) => ReactNode;\n}\n\n/**\n * Value types supported when rendering rich text messages.\n * Primitive values (or single react nodes) are used for normal values.\n * Functions are used to define how tags should be rendered.\n *\n * See {@link PackageIntlExtensions.formatRichMessage}\n */\nexport type RichTextValue = PrimitiveType | ReactNode | FormatXMLElementFn<ReactNode>;\n\n/**\n * Creates a package intl instance with the given locale and messages.\n *\n * @internal\n */\nexport function createPackageIntl(\n locale: string,\n messages: Record<string, string>,\n options?: {\n /** Used during testing to suppress console messages. */\n suppressNotFoundError?: boolean;\n\n /** Also used during testing */\n defaultLocale?: string;\n }\n): PackageIntl {\n const cache = createIntlCache();\n const config: IntlConfig = {\n locale,\n messages\n };\n if (options?.suppressNotFoundError) {\n config.onError = ignoreMissingTranslationError;\n }\n if (options?.defaultLocale) {\n config.defaultLocale = options.defaultLocale;\n }\n\n const intl = createIntl(config, cache) as unknown as PackageIntl;\n intl.formatRichMessage = formatRichMessage.bind(undefined, intl);\n return intl;\n}\n\n/** Creates an empty i18n instance, e.g. for tests. */\nexport function createEmptyPackageIntl(locale = \"en\"): PackageIntl {\n return createPackageIntl(locale, {});\n}\n\nconst RICH_TEXT_TAGS = Object.freeze({\n \"b\": renderTag(\"b\"),\n \"strong\": renderTag(\"strong\"),\n \"i\": renderTag(\"i\"),\n \"em\": renderTag(\"em\"),\n \"code\": renderTag(\"code\"),\n \"br\": renderTag(\"br\")\n});\n\nfunction formatRichMessage(\n intl: PackageIntl,\n descriptor: MessageDescriptor,\n values: Record<string, RichTextValue> | undefined,\n opts: IntlMessageFormatOptions | undefined\n): ReactNode {\n values = {\n ...RICH_TEXT_TAGS,\n ...values\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const formatResult: any = intl.formatMessage(descriptor, preprocessValues(values) as any, opts);\n return createElement(Fragment, undefined, ...formatResult);\n}\n\nfunction preprocessValues(values: Record<string, RichTextValue> | undefined) {\n if (!values) {\n return undefined;\n }\n\n const fixedValues: Record<string, RichTextValue> = {};\n for (const [key, valueOrFn] of Object.entries(values)) {\n let fixedValue = valueOrFn;\n if (typeof valueOrFn === \"function\") {\n fixedValue = (parts) => toKeyedChildren(valueOrFn(parts));\n }\n fixedValues[key] = fixedValue;\n }\n return fixedValues;\n}\n\nfunction renderTag(tag: string): FormatXMLElementFn<ReactNode> {\n return function renderRichTag(parts) {\n return createElement(tag, undefined, ...parts);\n };\n}\n\n// Seems to be necessary to avoid \"Each child in a list should have a unique \"key\" prop.\" error\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction toKeyedChildren(children: any) {\n return Children.toArray(children);\n}\n\n/** Hides missing translation errors during tests */\nconst ignoreMissingTranslationError: OnErrorFn = (err) => {\n if (err.code === IntlErrorCode.MISSING_TRANSLATION) {\n return;\n }\n\n console.error(err);\n};\n"],"names":[],"mappings":";;;AAyHgB,SAAA,iBAAA,CACZ,MACA,EAAA,QAAA,EACA,OAOW,EAAA;AACX,EAAA,MAAM,QAAQ,eAAgB,EAAA;AAC9B,EAAA,MAAM,MAAqB,GAAA;AAAA,IACvB,MAAA;AAAA,IACA;AAAA,GACJ;AACA,EAAA,IAAI,SAAS,qBAAuB,EAAA;AAChC,IAAA,MAAA,CAAO,OAAU,GAAA,6BAAA;AAAA;AAErB,EAAA,IAAI,SAAS,aAAe,EAAA;AACxB,IAAA,MAAA,CAAO,gBAAgB,OAAQ,CAAA,aAAA;AAAA;AAGnC,EAAM,MAAA,IAAA,GAAO,UAAW,CAAA,MAAA,EAAQ,KAAK,CAAA;AACrC,EAAA,IAAA,CAAK,iBAAoB,GAAA,iBAAA,CAAkB,IAAK,CAAA,MAAA,EAAW,IAAI,CAAA;AAC/D,EAAO,OAAA,IAAA;AACX;AAGgB,SAAA,sBAAA,CAAuB,SAAS,IAAmB,EAAA;AAC/D,EAAO,OAAA,iBAAA,CAAkB,MAAQ,EAAA,EAAE,CAAA;AACvC;AAEA,MAAM,cAAA,GAAiB,OAAO,MAAO,CAAA;AAAA,EACjC,GAAA,EAAK,UAAU,GAAG,CAAA;AAAA,EAClB,QAAA,EAAU,UAAU,QAAQ,CAAA;AAAA,EAC5B,GAAA,EAAK,UAAU,GAAG,CAAA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KAAA;AACtD,EAAI,IAAA,GAAA,CAAI,IAAS,KAAA,aAAA,CAAc,mBAAqB,EAAA;AAChD,IAAA;AAAA;AAGJ,EAAA,OAAA,CAAQ,MAAM,GAAG,CAAA;AACrB,CAAA;;;;"}
@@ -0,0 +1,3 @@
1
+ export { type AppIntl, initI18n } from "./AppIntl";
2
+ export { type PackageIntl, type PackageIntlExtensions, type RichTextValue, createPackageIntl, createEmptyPackageIntl } from "./PackageIntl";
3
+ export { type LocalePickResult, I18nConfig, getBrowserLocales } from "./pick";
package/i18n/pick.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ export interface LocalePickResult {
2
+ /**
3
+ * The actual locale (e.g. en-US) for number and date formatting etc.
4
+ */
5
+ locale: string;
6
+ /**
7
+ * The locale identifier to load messages for. E.g. "en".
8
+ */
9
+ messageLocale: string;
10
+ }
11
+ /**
12
+ * Picks a locale for the app.
13
+ */
14
+ export declare class I18nConfig {
15
+ private appLocales;
16
+ /**
17
+ * @param appLocales Locales the app has i18n messages for (e.g. "en", "de")
18
+ */
19
+ constructor(appLocales: string[]);
20
+ /**
21
+ * @param forcedLocale Optional forced locale (must be satisfied)
22
+ * @param userLocales Locales requested by the user's browser
23
+ */
24
+ pickSupportedLocale(forcedLocale: string | undefined, userLocales: string[]): LocalePickResult;
25
+ supportsLocale(locale: string): boolean;
26
+ private pickImpl;
27
+ }
28
+ /**
29
+ * Returns locales supported by the browser, in order of preference (preferred first).
30
+ *
31
+ * See also https://developer.mozilla.org/en-US/docs/Web/API/Navigator/languages
32
+ */
33
+ export declare function getBrowserLocales(): string[];
@@ -1,64 +1,7 @@
1
- import { createIntlCache, createIntl } from '@formatjs/intl';
2
- import { ErrorId } from './errors.js';
3
1
  import { createLogger, Error } from '@open-pioneer/core';
2
+ import { ErrorId } from '../errors.js';
4
3
 
5
4
  const LOG = createLogger("runtime:i18n");
6
- function createPackageIntl(locale, messages) {
7
- const cache = createIntlCache();
8
- return createIntl(
9
- {
10
- locale,
11
- messages
12
- },
13
- cache
14
- );
15
- }
16
- async function initI18n(appMetadata, forcedLocale) {
17
- const messageLocales = appMetadata?.locales ?? [];
18
- const userLocales = getBrowserLocales();
19
- if (LOG.isDebug()) {
20
- LOG.debug(
21
- `Attempting to pick locale for user (locales: ${userLocales.join(
22
- ", "
23
- )}) from app (supported locales: ${messageLocales.join(
24
- ", "
25
- )}) [forcedLocale=${forcedLocale}].`
26
- );
27
- }
28
- const i18nConfig = new I18nConfig(messageLocales);
29
- const { locale, messageLocale } = i18nConfig.pickSupportedLocale(forcedLocale, userLocales);
30
- if (LOG.isDebug()) {
31
- LOG.debug(`Using locale '${locale}' with messages from locale '${messageLocale}'.`);
32
- }
33
- let messages;
34
- if (messageLocales.includes(messageLocale)) {
35
- try {
36
- messages = await appMetadata?.loadMessages?.(messageLocale) ?? {};
37
- } catch (e) {
38
- throw new Error(
39
- ErrorId.INTERNAL,
40
- `Failed to load messages for locale '${messageLocale}'.`,
41
- {
42
- cause: e
43
- }
44
- );
45
- }
46
- }
47
- return {
48
- locale,
49
- supportedMessageLocales: messageLocales,
50
- supportsLocale(locale2) {
51
- return i18nConfig.supportsLocale(locale2);
52
- },
53
- createPackageI18n(packageName) {
54
- const packageMessage = messages?.[packageName] ?? {};
55
- return createPackageIntl(locale, packageMessage);
56
- }
57
- };
58
- }
59
- function createEmptyI18n(locale = "en") {
60
- return createPackageIntl(locale, {});
61
- }
62
5
  class I18nConfig {
63
6
  appLocales;
64
7
  /**
@@ -122,5 +65,5 @@ function getBrowserLocales() {
122
65
  return [window.navigator.language];
123
66
  }
124
67
 
125
- export { I18nConfig, createEmptyI18n, createPackageIntl, getBrowserLocales, initI18n };
126
- //# sourceMappingURL=i18n.js.map
68
+ export { I18nConfig, getBrowserLocales };
69
+ //# sourceMappingURL=pick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pick.js","sources":["pick.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger, Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\nconst LOG = createLogger(\"runtime:i18n\");\n\nexport interface LocalePickResult {\n /**\n * The actual locale (e.g. en-US) for number and date formatting etc.\n */\n locale: string;\n\n /**\n * The locale identifier to load messages for. E.g. \"en\".\n */\n messageLocale: string;\n}\n\n/**\n * Picks a locale for the app.\n */\nexport class I18nConfig {\n private appLocales: string[];\n\n /**\n * @param appLocales Locales the app has i18n messages for (e.g. \"en\", \"de\")\n */\n constructor(appLocales: string[]) {\n this.appLocales = appLocales;\n }\n\n /**\n * @param forcedLocale Optional forced locale (must be satisfied)\n * @param userLocales Locales requested by the user's browser\n */\n pickSupportedLocale(forcedLocale: string | undefined, userLocales: string[]): LocalePickResult {\n const { appLocales } = this;\n // Attempt to satisfy forced locale\n if (forcedLocale) {\n const result = this.pickImpl([forcedLocale]);\n if (!result) {\n const localesList = appLocales.join(\", \");\n throw new Error(\n ErrorId.UNSUPPORTED_LOCALE,\n `Locale '${forcedLocale}' cannot be forced because it is not supported by the application.` +\n ` Supported locales are ${localesList}.`\n );\n }\n if (result.locale !== result.messageLocale) {\n LOG.warn(\n `Non-exact match for forced locale '${forcedLocale}': using messages from '${result.messageLocale}'.`\n );\n }\n return result;\n }\n\n // Match preferred locale\n const supportedLocale = this.pickImpl(userLocales);\n if (supportedLocale) {\n return supportedLocale;\n }\n\n // Fallback: Most preferred locale (for dates etc.), but some of our messages\n return {\n locale: userLocales[0] ?? \"en\",\n messageLocale: appLocales[0] ?? \"en\"\n };\n }\n\n supportsLocale(locale: string): boolean {\n return this.pickImpl([locale]) != null;\n }\n\n private pickImpl(requestedLocales: string[]) {\n const appLocales = this.appLocales;\n for (const requestedLocale of requestedLocales) {\n // try exact match\n if (appLocales.includes(requestedLocale)) {\n return { messageLocale: requestedLocale, locale: requestedLocale };\n }\n\n // try plain language tag (e.g. \"en\") as fallback\n const plainLanguage = requestedLocale.match(/^([a-z]+)/i)?.[1];\n if (plainLanguage && appLocales.includes(plainLanguage)) {\n return { messageLocale: plainLanguage, locale: requestedLocale };\n }\n }\n return undefined;\n }\n}\n\n/**\n * Returns locales supported by the browser, in order of preference (preferred first).\n *\n * See also https://developer.mozilla.org/en-US/docs/Web/API/Navigator/languages\n */\nexport function getBrowserLocales(): string[] {\n if (window.navigator.languages && window.navigator.languages.length) {\n return Array.from(window.navigator.languages);\n }\n return [window.navigator.language];\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,GAAA,GAAM,aAAa,cAAc,CAAA;AAiBhC,MAAM,UAAW,CAAA;AAAA,EACZ,UAAA;AAAA;AAAA;AAAA;AAAA,EAKR,YAAY,UAAsB,EAAA;AAC9B,IAAA,IAAA,CAAK,UAAa,GAAA,UAAA;AAAA;AACtB;AAAA;AAAA;AAAA;AAAA,EAMA,mBAAA,CAAoB,cAAkC,WAAyC,EAAA;AAC3F,IAAM,MAAA,EAAE,YAAe,GAAA,IAAA;AAEvB,IAAA,IAAI,YAAc,EAAA;AACd,MAAA,MAAM,MAAS,GAAA,IAAA,CAAK,QAAS,CAAA,CAAC,YAAY,CAAC,CAAA;AAC3C,MAAA,IAAI,CAAC,MAAQ,EAAA;AACT,QAAM,MAAA,WAAA,GAAc,UAAW,CAAA,IAAA,CAAK,IAAI,CAAA;AACxC,QAAA,MAAM,IAAI,KAAA;AAAA,UACN,OAAQ,CAAA,kBAAA;AAAA,UACR,CAAA,QAAA,EAAW,YAAY,CAAA,yFAAA,EACO,WAAW,CAAA,CAAA;AAAA,SAC7C;AAAA;AAEJ,MAAI,IAAA,MAAA,CAAO,MAAW,KAAA,MAAA,CAAO,aAAe,EAAA;AACxC,QAAI,GAAA,CAAA,IAAA;AAAA,UACA,CAAsC,mCAAA,EAAA,YAAY,CAA2B,wBAAA,EAAA,MAAA,CAAO,aAAa,CAAA,EAAA;AAAA,SACrG;AAAA;AAEJ,MAAO,OAAA,MAAA;AAAA;AAIX,IAAM,MAAA,eAAA,GAAkB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  export * from "./api";
2
- export { type PackageIntl } from "./i18n";
2
+ export { type PackageIntl, type PackageIntlExtensions, type RichTextValue } from "./i18n";
3
3
  export { type ApplicationElement, type ApplicationElementConstructor, type ApplicationProperties, type ApplicationConfig, type CustomElementOptions, type ConfigContext, createCustomElement } from "./CustomElement";
4
4
  export * from "./Service";
5
5
  export { type DeclaredService, type AssociatedInterfaceName, type InterfaceNameForServiceType, DECLARE_SERVICE_INTERFACE } from "./DeclaredService";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/runtime",
4
- "version": "3.0.0",
4
+ "version": "3.1.0-dev-rich-text.20250408112706",
5
5
  "description": "Implements the runtime environment for Open Pioneer Trails apps.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -17,10 +17,10 @@
17
17
  "@formatjs/intl": "^3.1.4",
18
18
  "react": "^19.0.0",
19
19
  "react-dom": "^19.0.0",
20
- "@open-pioneer/base-theme": "^3.0.0",
21
- "@open-pioneer/core": "^3.0.0",
22
- "@open-pioneer/chakra-integration": "^3.0.0",
23
- "@open-pioneer/runtime-react-support": "^3.0.0"
20
+ "@open-pioneer/core": "^3.1.0-dev-rich-text.20250408112706",
21
+ "@open-pioneer/base-theme": "^3.1.0-dev-rich-text.20250408112706",
22
+ "@open-pioneer/runtime-react-support": "^3.1.0-dev-rich-text.20250408112706",
23
+ "@open-pioneer/chakra-integration": "^3.1.0-dev-rich-text.20250408112706"
24
24
  },
25
25
  "exports": {
26
26
  "./package.json": "./package.json",
@@ -35,6 +35,10 @@
35
35
  "./react-integration": {
36
36
  "import": "./react-integration/index.js",
37
37
  "types": "./react-integration/index.d.ts"
38
+ },
39
+ "./test-support": {
40
+ "import": "./test-support/index.js",
41
+ "types": "./test-support/index.d.ts"
38
42
  }
39
43
  },
40
44
  "openPioneerFramework": {
@@ -1,5 +1,5 @@
1
1
  import { ApplicationProperties } from "../CustomElement";
2
- import { PackageIntl, AppI18n } from "../i18n";
2
+ import { PackageIntl, AppIntl } from "../i18n";
3
3
  import { PackageMetadata } from "../metadata";
4
4
  import { ReferenceSpec } from "./InterfaceSpec";
5
5
  import { ServiceRepr } from "./ServiceRepr";
@@ -24,4 +24,4 @@ export declare class PackageRepr {
24
24
  readonly intl: PackageIntl;
25
25
  constructor(options: PackageReprOptions);
26
26
  }
27
- export declare function createPackages(packages: Record<string, PackageMetadata>, i18n: AppI18n, customProperties?: ApplicationProperties): PackageRepr[];
27
+ export declare function createPackages(packages: Record<string, PackageMetadata>, i18n: AppIntl, customProperties?: ApplicationProperties): PackageRepr[];
@@ -1 +1 @@
1
- {"version":3,"file":"PackageRepr.js","sources":["PackageRepr.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Error } from \"@open-pioneer/core\";\nimport { ApplicationProperties } from \"../CustomElement\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl, AppI18n } from \"../i18n\";\nimport { PackageMetadata, PropertyMetadata } from \"../metadata\";\nimport { parseReferenceSpec, ReferenceSpec } from \"./InterfaceSpec\";\nimport { ServiceRepr } from \"./ServiceRepr\";\n\nexport interface PackageReprOptions {\n name: string;\n intl: PackageIntl;\n services?: ServiceRepr[];\n uiReferences?: ReferenceSpec[];\n properties?: Record<string, unknown>;\n}\n\nexport class PackageRepr {\n static create(\n data: PackageMetadata,\n i18n: PackageIntl,\n customProperties?: Record<string, unknown>\n ): PackageRepr {\n const name = data.name;\n const properties = data.properties ?? {};\n const finalProperties = customizeProperties(name, properties, customProperties);\n const services = Object.entries(data.services ?? {}).map<ServiceRepr>(\n ([name, serviceData]) => {\n if (name !== serviceData.name) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n \"Invalid metadata: service name mismatch.\"\n );\n }\n return ServiceRepr.create(data.name, serviceData, i18n, finalProperties);\n }\n );\n const uiReferences = data.ui?.references?.map((ref) => parseReferenceSpec(ref)) ?? [];\n return new PackageRepr({\n name,\n services,\n uiReferences,\n properties: finalProperties,\n intl: i18n\n });\n }\n\n /** Package name */\n readonly name: string;\n\n /** Services defined by the package */\n readonly services: readonly ServiceRepr[];\n\n /** Interfaces required by UI components. */\n readonly uiReferences: readonly Readonly<ReferenceSpec>[];\n\n /** Resolved (perhaps customized) package properties. */\n readonly properties: Readonly<Record<string, unknown>>;\n\n /** Locale-dependant i18n messages. */\n readonly intl: PackageIntl;\n\n constructor(options: PackageReprOptions) {\n const name = options.name;\n if (!isValidPackageName(name)) {\n throw new Error(ErrorId.INTERNAL, `Invalid package name: '${name}'.`);\n }\n\n this.name = name;\n this.services = options.services ?? [];\n this.uiReferences = options.uiReferences ?? [];\n this.properties = options.properties ?? {};\n this.intl = options.intl;\n }\n}\n\nexport function createPackages(\n packages: Record<string, PackageMetadata>,\n i18n: AppI18n,\n customProperties?: ApplicationProperties\n) {\n return Object.entries(packages).map<PackageRepr>(([name, packageMetadata]) => {\n if (name !== packageMetadata.name) {\n throw new Error(ErrorId.INVALID_METADATA, \"Invalid metadata: package name mismatch.\");\n }\n\n const packageI18n = i18n.createPackageI18n(name);\n return PackageRepr.create(packageMetadata, packageI18n, customProperties?.[name]);\n });\n}\n\n/**\n * Merges the declared properties of the package with the application-defined\n * custom properties.\n */\nfunction customizeProperties(\n packageName: string,\n properties: Record<string, PropertyMetadata>,\n customProperties: Record<string, unknown> = {}\n) {\n const merged: Record<string, unknown> = {};\n const required: string[] = [];\n for (const [key, propertyMetadata] of Object.entries(properties)) {\n merged[key] = propertyMetadata.value;\n if (propertyMetadata.required) {\n required.push(key);\n }\n }\n\n for (const [key, value] of Object.entries(customProperties)) {\n if (!hasProperty(merged, key)) {\n throw new Error(\n ErrorId.INVALID_PROPERTY_NAME,\n `Unexpected property name '${key}' for package '${packageName}': the property does not exist.`\n );\n }\n merged[key] = value;\n }\n\n for (const key of required) {\n const value = merged[key];\n if (value == null) {\n throw new Error(\n ErrorId.REQUIRED_PROPERTY,\n `Package '${packageName}' requires the property '${key}' to be initialized to a non-null value.`\n );\n }\n }\n\n return merged;\n}\n\nconst HAS_PROP = Object.prototype.hasOwnProperty;\n\nfunction hasProperty(object: unknown, key: string) {\n return HAS_PROP.call(object, key);\n}\n\n// http://json.schemastore.org/package\nconst NAME_REGEX = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/;\n\nfunction isValidPackageName(name: string): boolean {\n return NAME_REGEX.test(name);\n}\n"],"names":["name"],"mappings":";;;;;AAkBO,MAAM,WAAY,CAAA;AAAA,EACrB,OAAO,MAAA,CACH,IACA,EAAA,IAAA,EACA,gBACW,EAAA;AACX,IAAA,MAAM,OAAO,IAAK,CAAA,IAAA;AAClB,IAAM,MAAA,UAAA,GAAa,IAAK,CAAA,UAAA,IAAc,EAAC;AACvC,IAAA,MAAM,eAAkB,GAAA,mBAAA,CAAoB,IAAM,EAAA,UAAA,EAAY,gBAAgB,CAAA;AAC9E,IAAA,MAAM,WAAW,MAAO,CAAA,OAAA,CAAQ,KAAK,QAAY,IAAA,EAAE,CAAE,CAAA,GAAA;AAAA,MACjD,CAAC,CAACA,KAAM,EAAA,WAAW,CAAM,KAAA;AACrB,QAAIA,IAAAA,KAAAA,KAAS,YAAY,IAAM,EAAA;AAC3B,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAQ,CAAA,gBAAA;AAAA,YACR;AAAA,WACJ;AAAA;AAEJ,QAAA,OAAO,YAAY,MAAO,CAAA,IAAA,CAAK,IAAM,EAAA,WAAA,EAAa,MAAM,eAAe,CAAA;AAAA;AAC3E,KACJ;AACA,IAAM,MAAA,YAAA,GAAe,IAAK,CAAA,EAAA,EAAI,UAAY,EAAA,GAAA,CAAI,CAAC,GAAA,KAAQ,kBAAmB,CAAA,GAAG,CAAC,CAAA,IAAK,EAAC;AACpF,IAAA,OAAO,IAAI,WAAY,CAAA;AAAA,MACnB,IAAA;AAAA,MACA,QAAA;AAAA,MACA,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,CAAA,MAAA,EAAQ,GAAG,CAAA;AACpC;AAGA,MAAM,UAAa,GAAA,4DAAA;AAEnB,SAAS,mBAAmB,IAAuB,EAAA;AAC/C,EAAO,OAAA,UAAA,CAAW,KAAK,IAAI,CAAA;AAC/B;;;;"}
1
+ {"version":3,"file":"PackageRepr.js","sources":["PackageRepr.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Error } from \"@open-pioneer/core\";\nimport { ApplicationProperties } from \"../CustomElement\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl, AppIntl } from \"../i18n\";\nimport { PackageMetadata, PropertyMetadata } from \"../metadata\";\nimport { parseReferenceSpec, ReferenceSpec } from \"./InterfaceSpec\";\nimport { ServiceRepr } from \"./ServiceRepr\";\n\nexport interface PackageReprOptions {\n name: string;\n intl: PackageIntl;\n services?: ServiceRepr[];\n uiReferences?: ReferenceSpec[];\n properties?: Record<string, unknown>;\n}\n\nexport class PackageRepr {\n static create(\n data: PackageMetadata,\n i18n: PackageIntl,\n customProperties?: Record<string, unknown>\n ): PackageRepr {\n const name = data.name;\n const properties = data.properties ?? {};\n const finalProperties = customizeProperties(name, properties, customProperties);\n const services = Object.entries(data.services ?? {}).map<ServiceRepr>(\n ([name, serviceData]) => {\n if (name !== serviceData.name) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n \"Invalid metadata: service name mismatch.\"\n );\n }\n return ServiceRepr.create(data.name, serviceData, i18n, finalProperties);\n }\n );\n const uiReferences = data.ui?.references?.map((ref) => parseReferenceSpec(ref)) ?? [];\n return new PackageRepr({\n name,\n services,\n uiReferences,\n properties: finalProperties,\n intl: i18n\n });\n }\n\n /** Package name */\n readonly name: string;\n\n /** Services defined by the package */\n readonly services: readonly ServiceRepr[];\n\n /** Interfaces required by UI components. */\n readonly uiReferences: readonly Readonly<ReferenceSpec>[];\n\n /** Resolved (perhaps customized) package properties. */\n readonly properties: Readonly<Record<string, unknown>>;\n\n /** Locale-dependant i18n messages. */\n readonly intl: PackageIntl;\n\n constructor(options: PackageReprOptions) {\n const name = options.name;\n if (!isValidPackageName(name)) {\n throw new Error(ErrorId.INTERNAL, `Invalid package name: '${name}'.`);\n }\n\n this.name = name;\n this.services = options.services ?? [];\n this.uiReferences = options.uiReferences ?? [];\n this.properties = options.properties ?? {};\n this.intl = options.intl;\n }\n}\n\nexport function createPackages(\n packages: Record<string, PackageMetadata>,\n i18n: AppIntl,\n customProperties?: ApplicationProperties\n) {\n return Object.entries(packages).map<PackageRepr>(([name, packageMetadata]) => {\n if (name !== packageMetadata.name) {\n throw new Error(ErrorId.INVALID_METADATA, \"Invalid metadata: package name mismatch.\");\n }\n\n const packageI18n = i18n.createPackageI18n(name);\n return PackageRepr.create(packageMetadata, packageI18n, customProperties?.[name]);\n });\n}\n\n/**\n * Merges the declared properties of the package with the application-defined\n * custom properties.\n */\nfunction customizeProperties(\n packageName: string,\n properties: Record<string, PropertyMetadata>,\n customProperties: Record<string, unknown> = {}\n) {\n const merged: Record<string, unknown> = {};\n const required: string[] = [];\n for (const [key, propertyMetadata] of Object.entries(properties)) {\n merged[key] = propertyMetadata.value;\n if (propertyMetadata.required) {\n required.push(key);\n }\n }\n\n for (const [key, value] of Object.entries(customProperties)) {\n if (!hasProperty(merged, key)) {\n throw new Error(\n ErrorId.INVALID_PROPERTY_NAME,\n `Unexpected property name '${key}' for package '${packageName}': the property does not exist.`\n );\n }\n merged[key] = value;\n }\n\n for (const key of required) {\n const value = merged[key];\n if (value == null) {\n throw new Error(\n ErrorId.REQUIRED_PROPERTY,\n `Package '${packageName}' requires the property '${key}' to be initialized to a non-null value.`\n );\n }\n }\n\n return merged;\n}\n\nconst HAS_PROP = Object.prototype.hasOwnProperty;\n\nfunction hasProperty(object: unknown, key: string) {\n return HAS_PROP.call(object, key);\n}\n\n// http://json.schemastore.org/package\nconst NAME_REGEX = /^(?:@[a-z0-9-*~][a-z0-9-*._~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1,4 @@
1
+ import '../i18n/AppIntl.js';
2
+ export { createPackageIntl } from '../i18n/PackageIntl.js';
3
+ import '../i18n/pick.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
package/i18n.d.ts DELETED
@@ -1,62 +0,0 @@
1
- import { IntlFormatters, IntlShape } from "@formatjs/intl";
2
- import { ApplicationMetadata } from "./metadata";
3
- /**
4
- * Represents i18n info for the entire application.
5
- * Currently not exposed to user code.
6
- */
7
- export interface AppI18n {
8
- /** Chosen locale */
9
- readonly locale: string;
10
- /** Supported locales from app metadata. */
11
- readonly supportedMessageLocales: string[];
12
- /** True if the locale can be used in this application (i.e. if there are any messages). */
13
- supportsLocale(locale: string): boolean;
14
- /** Given the package name, constructs a package i18n instance. */
15
- createPackageI18n(packageName: string): PackageIntl;
16
- }
17
- /**
18
- * Gives access to the package's i18n messages for the current locale.
19
- *
20
- * See also https://formatjs.io/docs/intl
21
- */
22
- export type PackageIntl = Pick<IntlShape, "locale" | "timeZone"> & IntlFormatters<string>;
23
- export declare function createPackageIntl(locale: string, messages: Record<string, string>): IntlShape<string>;
24
- /**
25
- * Initializes the application's locale and fetches the appropriate i18n messages.
26
- */
27
- export declare function initI18n(appMetadata: ApplicationMetadata | undefined, forcedLocale: string | undefined): Promise<AppI18n>;
28
- /** Creates an empty i18n instance, e.g. for tests. */
29
- export declare function createEmptyI18n(locale?: string): PackageIntl;
30
- export interface LocalePickResult {
31
- /**
32
- * The actual locale (e.g. en-US) for number and date formatting etc.
33
- */
34
- locale: string;
35
- /**
36
- * The locale identifier to load messages for. E.g. "en".
37
- */
38
- messageLocale: string;
39
- }
40
- /**
41
- * Picks a locale for the app. Exported for tests.
42
- */
43
- export declare class I18nConfig {
44
- private appLocales;
45
- /**
46
- * @param appLocales Locales the app has i18n messages for (e.g. "en", "de")
47
- */
48
- constructor(appLocales: string[]);
49
- /**
50
- * @param forcedLocale Optional forced locale (must be satisfied)
51
- * @param userLocales Locales requested by the user's browser
52
- */
53
- pickSupportedLocale(forcedLocale: string | undefined, userLocales: string[]): LocalePickResult;
54
- supportsLocale(locale: string): boolean;
55
- private pickImpl;
56
- }
57
- /**
58
- * Returns locales supported by the browser, in order of preference (preferred first).
59
- *
60
- * See also https://developer.mozilla.org/en-US/docs/Web/API/Navigator/languages
61
- */
62
- export declare function getBrowserLocales(): string[];
package/i18n.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"i18n.js","sources":["i18n.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createIntl, createIntlCache, IntlFormatters, IntlShape } from \"@formatjs/intl\";\nimport { ErrorId } from \"./errors\";\nimport { createLogger, Error } from \"@open-pioneer/core\";\nimport { ApplicationMetadata } from \"./metadata\";\nconst LOG = createLogger(\"runtime:i18n\");\n\n/**\n * Represents i18n info for the entire application.\n * Currently not exposed to user code.\n */\nexport interface AppI18n {\n /** Chosen locale */\n readonly locale: string;\n\n /** Supported locales from app metadata. */\n readonly supportedMessageLocales: string[];\n\n /** True if the locale can be used in this application (i.e. if there are any messages). */\n supportsLocale(locale: string): boolean;\n\n /** Given the package name, constructs a package i18n instance. */\n createPackageI18n(packageName: string): PackageIntl;\n}\n\n/**\n * Gives access to the package's i18n messages for the current locale.\n *\n * See also https://formatjs.io/docs/intl\n */\nexport type PackageIntl = Pick<IntlShape, \"locale\" | \"timeZone\"> & IntlFormatters<string>;\n\nexport function createPackageIntl(locale: string, messages: Record<string, string>) {\n const cache = createIntlCache();\n return createIntl(\n {\n locale,\n messages\n },\n cache\n );\n}\n\n/**\n * Initializes the application's locale and fetches the appropriate i18n messages.\n */\nexport async function initI18n(\n appMetadata: ApplicationMetadata | undefined,\n forcedLocale: string | undefined\n): Promise<AppI18n> {\n const messageLocales = appMetadata?.locales ?? [];\n const userLocales = getBrowserLocales();\n if (LOG.isDebug()) {\n LOG.debug(\n `Attempting to pick locale for user (locales: ${userLocales.join(\n \", \"\n )}) from app (supported locales: ${messageLocales.join(\n \", \"\n )}) [forcedLocale=${forcedLocale}].`\n );\n }\n\n const i18nConfig = new I18nConfig(messageLocales);\n const { locale, messageLocale } = i18nConfig.pickSupportedLocale(forcedLocale, userLocales);\n\n if (LOG.isDebug()) {\n LOG.debug(`Using locale '${locale}' with messages from locale '${messageLocale}'.`);\n }\n\n let messages: Record<string, Record<string, string>>;\n if (messageLocales.includes(messageLocale)) {\n try {\n messages = (await appMetadata?.loadMessages?.(messageLocale)) ?? {};\n } catch (e) {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to load messages for locale '${messageLocale}'.`,\n {\n cause: e\n }\n );\n }\n }\n return {\n locale,\n supportedMessageLocales: messageLocales,\n supportsLocale(locale) {\n return i18nConfig.supportsLocale(locale);\n },\n createPackageI18n(packageName) {\n const packageMessage = messages?.[packageName] ?? {};\n return createPackageIntl(locale, packageMessage);\n }\n };\n}\n\n/** Creates an empty i18n instance, e.g. for tests. */\nexport function createEmptyI18n(locale = \"en\"): PackageIntl {\n return createPackageIntl(locale, {});\n}\n\nexport interface LocalePickResult {\n /**\n * The actual locale (e.g. en-US) for number and date formatting etc.\n */\n locale: string;\n\n /**\n * The locale identifier to load messages for. E.g. \"en\".\n */\n messageLocale: string;\n}\n\n/**\n * Picks a locale for the app. Exported for tests.\n */\nexport class I18nConfig {\n private appLocales: string[];\n\n /**\n * @param appLocales Locales the app has i18n messages for (e.g. \"en\", \"de\")\n */\n constructor(appLocales: string[]) {\n this.appLocales = appLocales;\n }\n\n /**\n * @param forcedLocale Optional forced locale (must be satisfied)\n * @param userLocales Locales requested by the user's browser\n */\n pickSupportedLocale(forcedLocale: string | undefined, userLocales: string[]): LocalePickResult {\n const { appLocales } = this;\n // Attempt to satisfy forced locale\n if (forcedLocale) {\n const result = this.pickImpl([forcedLocale]);\n if (!result) {\n const localesList = appLocales.join(\", \");\n throw new Error(\n ErrorId.UNSUPPORTED_LOCALE,\n `Locale '${forcedLocale}' cannot be forced because it is not supported by the application.` +\n ` Supported locales are ${localesList}.`\n );\n }\n if (result.locale !== result.messageLocale) {\n LOG.warn(\n `Non-exact match for forced locale '${forcedLocale}': using messages from '${result.messageLocale}'.`\n );\n }\n return result;\n }\n\n // Match preferred locale\n const supportedLocale = this.pickImpl(userLocales);\n if (supportedLocale) {\n return supportedLocale;\n }\n\n // Fallback: Most preferred locale (for dates etc.), but some of our messages\n return {\n locale: userLocales[0] ?? \"en\",\n messageLocale: appLocales[0] ?? \"en\"\n };\n }\n\n supportsLocale(locale: string): boolean {\n return this.pickImpl([locale]) != null;\n }\n\n private pickImpl(requestedLocales: string[]) {\n const appLocales = this.appLocales;\n for (const requestedLocale of requestedLocales) {\n // try exact match\n if (appLocales.includes(requestedLocale)) {\n return { messageLocale: requestedLocale, locale: requestedLocale };\n }\n\n // try plain language tag (e.g. \"en\") as fallback\n const plainLanguage = requestedLocale.match(/^([a-z]+)/i)?.[1];\n if (plainLanguage && appLocales.includes(plainLanguage)) {\n return { messageLocale: plainLanguage, locale: requestedLocale };\n }\n }\n return undefined;\n }\n}\n\n/**\n * Returns locales supported by the browser, in order of preference (preferred first).\n *\n * See also https://developer.mozilla.org/en-US/docs/Web/API/Navigator/languages\n */\nexport function getBrowserLocales(): string[] {\n if (window.navigator.languages && window.navigator.languages.length) {\n return Array.from(window.navigator.languages);\n }\n return [window.navigator.language];\n}\n"],"names":["locale"],"mappings":";;;;AAMA,MAAM,GAAA,GAAM,aAAa,cAAc,CAAA;AA2BvB,SAAA,iBAAA,CAAkB,QAAgB,QAAkC,EAAA;AAChF,EAAA,MAAM,QAAQ,eAAgB,EAAA;AAC9B,EAAO,OAAA,UAAA;AAAA,IACH;AAAA,MACI,MAAA;AAAA,MACA;AAAA,KACJ;AAAA,IACA;AAAA,GACJ;AACJ;AAKsB,eAAA,QAAA,CAClB,aACA,YACgB,EAAA;AAChB,EAAM,MA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