@open-pioneer/runtime 4.1.0-dev.20250707115222 → 4.1.0-dev.20250818132109
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 +7 -4
- package/CustomElement.js.map +1 -1
- package/DeclaredService.js.map +1 -1
- package/app/AppInstance.js.map +1 -1
- package/app/gatherConfig.js.map +1 -1
- package/app/logErrors.js.map +1 -1
- package/builtin-services/ApiServiceImpl.js.map +1 -1
- package/builtin-services/ApplicationContextImpl.js.map +1 -1
- package/builtin-services/ApplicationLifecycleEventService.js.map +1 -1
- package/builtin-services/NumberParserServiceImpl.js.map +1 -1
- package/builtin-services/index.js.map +1 -1
- package/dom/index.js.map +1 -1
- package/errors.js.map +1 -1
- package/i18n/AppIntl.js.map +1 -1
- package/i18n/PackageIntl.js.map +1 -1
- package/i18n/pick.js.map +1 -1
- package/metadata/ObservableBox.js.map +1 -1
- package/package.json +7 -7
- package/react-integration/ChakraProvider.js.map +1 -1
- package/react-integration/ErrorScreen.js.map +1 -1
- package/react-integration/PackageContext.js.map +1 -1
- package/react-integration/ReactIntegration.js.map +1 -1
- package/react-integration/hooks.js.map +1 -1
- package/service-layer/InterfaceSpec.js.map +1 -1
- package/service-layer/PackageRepr.js.map +1 -1
- package/service-layer/ServiceLayer.js.map +1 -1
- package/service-layer/ServiceLookup.js.map +1 -1
- package/service-layer/ServiceRepr.js.map +1 -1
- package/service-layer/verifyDependencies.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
# @open-pioneer/runtime
|
|
2
2
|
|
|
3
|
-
## 4.1.0-dev.
|
|
3
|
+
## 4.1.0-dev.20250818132109
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- b7a854d: Update dependencies
|
|
8
|
+
- 3881d08: - Update Chakra UI from 3.22.0 to 3.24.2
|
|
9
|
+
- Update to latest Chakra snippets
|
|
8
10
|
- adf277b: Update dependencies
|
|
9
11
|
- Updated dependencies [b7a854d]
|
|
12
|
+
- Updated dependencies [2da02e7]
|
|
10
13
|
- Updated dependencies [adf277b]
|
|
11
|
-
- @open-pioneer/base-theme@4.1.0-dev.
|
|
12
|
-
- @open-pioneer/core@4.1.0-dev.
|
|
13
|
-
- @open-pioneer/reactivity@4.1.0-dev.
|
|
14
|
+
- @open-pioneer/base-theme@4.1.0-dev.20250818132109
|
|
15
|
+
- @open-pioneer/core@4.1.0-dev.20250818132109
|
|
16
|
+
- @open-pioneer/reactivity@4.1.0-dev.20250818132109
|
|
14
17
|
|
|
15
18
|
## 4.0.0
|
|
16
19
|
|
package/CustomElement.js.map
CHANGED
|
@@ -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 { SystemConfig as ChakraSystemConfig } from \"@chakra-ui/react\";\nimport { createLogger, Error } from \"@open-pioneer/core\";\nimport { ComponentType } from \"react\";\nimport { ApiMethods } from \"./api\";\nimport { AppInstance, AppOverrides } from \"./app\";\nimport { ErrorId } from \"./errors\";\nimport { ApplicationMetadata } from \"./metadata\";\n\n// Imported for typedoc link\n// eslint-disable-next-line unused-imports/no-unused-imports\nimport { type ApiExtension } from \"./api\";\n\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 * Chakra styled system object.\n *\n * Used to configure chakra's theme.\n */\n chakraSystemConfig?: ChakraSystemConfig;\n\n /**\n * Advanced configuration that alters the behavior of the custom element.\n */\n advanced?: AdvancedCustomElementOptions;\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/**\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 /**\n * Resolves to the element's API when the application has started.\n *\n * The API exposed by an application can be defined by implementing an {@link ApiExtension}.\n * For more details, open the documentation of the `@open-pioneer/integration` package.\n */\n when(): Promise<ApiMethods>;\n}\n\n/**\n * Advanced configuration that alters the behavior of the custom element.\n *\n * See {@link createCustomElement}.\n */\nexport interface AdvancedCustomElementOptions {\n /**\n * Enables or disables the [shadow root](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot) inside the application's web component.\n *\n * Default: `true`.\n *\n * By default, trails applications use a shadow root to avoid conflicts (e.g. styles) with other parts of the site where the application may be embedded.\n *\n * Applications that use the entire browser viewport may not need this feature, since there may be no \"other\" parts that may conflict with the app.\n * In this case, you can disable the shadow root by setting this property to `false`.\n * In general, UI components used by the app (e.g. from Chakra UI) should work just as well when disabling the shadow root.\n * If you notice any problems, please file an issue.\n *\n * If you are developing UI components that are meant to be used in other applications, you should always use a shadow root to\n * ensure that your components work in that setting.\n */\n enableShadowRoot?: boolean;\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 | undefined;\n #instance: AppInstance | 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 const enableShadowRoot = options.advanced?.enableShadowRoot ?? true;\n if (enableShadowRoot) {\n this.#shadowRoot = this.attachShadow({\n mode: \"open\"\n });\n } else {\n LOG.debug(\"Creating component instance without shadow root\");\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?: AppOverrides) {\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?: AppOverrides) {\n return new AppInstance({\n rootNode: this.#shadowRoot ?? document,\n hostElement: this,\n elementOptions: options,\n overrides: overrides,\n restart: this.#triggerReload.bind(this)\n });\n }\n }\n return PioneerApplication;\n}\n"],"names":[],"mappings":";;;;AAcA,MAAM,GAAA,GAAM,aAAa,uBAAuB,CAAA;AA4JzC,SAAS,oBAAoB,OAA8D,EAAA;AAAA,EAC9F,MAAM,2BAA2B,WAA0C,CAAA;AAAA,IACvE,WAAA;AAAA,IACA,SAAA;AAAA;AAAA,IAGA,gBAAA;AAAA;AAAA,IAEA,WAAW,kBAA+B,GAAA;AACtC,MAAA,OAAO,EAAC;AAAA;AACZ,IAEA,WAAc,GAAA;AACV,MAAM,KAAA,EAAA;AAEN,MAAM,MAAA,gBAAA,GAAmB,OAAQ,CAAA,QAAA,EAAU,gBAAoB,IAAA,IAAA;AAC/D,MAAA,IAAI,gBAAkB,EAAA;AAClB,QAAK,IAAA,CAAA,WAAA,GAAc,KAAK,YAAa,CAAA;AAAA,UACjC,IAAM,EAAA;AAAA,SACT,CAAA;AAAA,OACE,MAAA;AACH,QAAA,GAAA,CAAI,MAAM,iDAAiD,CAAA;AAAA;AAG/D,MAAI,IAAA,MAAA,CAAA,I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U,OAAQ,EAAA;AACvB,QAAK,IAAA,CAAA,SAAA,GAAY,IAAK,CAAA,0BAAA,CAA2B,SAAS,CAAA;AAC1D,QAAA,IAAA,CAAK,UAAU,KAAM,EAAA;AAAA,SACtB,CAAC,CAAA;AAAA;AACR,IAEA,2BAA2B,SAA0B,EAAA;AACjD,MAAA,OAAO,IAAI,WAAY,CAAA;AAAA,QACnB,QAAA,EAAU,KAAK,WAAe,IAAA,QAAA;AAAA,QAC9B,WAAa,EAAA,IAAA;AAAA,QACb,cAAgB,EAAA,OAAA;AAAA,QAChB,SAAA;AAAA,QACA,OAAS,EAAA,IAAA,CAAK,cAAe,CAAA,IAAA,CAAK,IAAI;AAAA,OACzC,CAAA;AAAA;AACL;AAEJ,EAAO,OAAA,kBAAA;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 { SystemConfig as ChakraSystemConfig } from \"@chakra-ui/react\";\nimport { createLogger, Error } from \"@open-pioneer/core\";\nimport { ComponentType } from \"react\";\nimport { ApiMethods } from \"./api\";\nimport { AppInstance, AppOverrides } from \"./app\";\nimport { ErrorId } from \"./errors\";\nimport { ApplicationMetadata } from \"./metadata\";\n\n// Imported for typedoc link\n// eslint-disable-next-line unused-imports/no-unused-imports\nimport { type ApiExtension } from \"./api\";\n\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 * Chakra styled system object.\n *\n * Used to configure chakra's theme.\n */\n chakraSystemConfig?: ChakraSystemConfig;\n\n /**\n * Advanced configuration that alters the behavior of the custom element.\n */\n advanced?: AdvancedCustomElementOptions;\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/**\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 /**\n * Resolves to the element's API when the application has started.\n *\n * The API exposed by an application can be defined by implementing an {@link ApiExtension}.\n * For more details, open the documentation of the `@open-pioneer/integration` package.\n */\n when(): Promise<ApiMethods>;\n}\n\n/**\n * Advanced configuration that alters the behavior of the custom element.\n *\n * See {@link createCustomElement}.\n */\nexport interface AdvancedCustomElementOptions {\n /**\n * Enables or disables the [shadow root](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot) inside the application's web component.\n *\n * Default: `true`.\n *\n * By default, trails applications use a shadow root to avoid conflicts (e.g. styles) with other parts of the site where the application may be embedded.\n *\n * Applications that use the entire browser viewport may not need this feature, since there may be no \"other\" parts that may conflict with the app.\n * In this case, you can disable the shadow root by setting this property to `false`.\n * In general, UI components used by the app (e.g. from Chakra UI) should work just as well when disabling the shadow root.\n * If you notice any problems, please file an issue.\n *\n * If you are developing UI components that are meant to be used in other applications, you should always use a shadow root to\n * ensure that your components work in that setting.\n */\n enableShadowRoot?: boolean;\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 | undefined;\n #instance: AppInstance | 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 const enableShadowRoot = options.advanced?.enableShadowRoot ?? true;\n if (enableShadowRoot) {\n this.#shadowRoot = this.attachShadow({\n mode: \"open\"\n });\n } else {\n LOG.debug(\"Creating component instance without shadow root\");\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?: AppOverrides) {\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?: AppOverrides) {\n return new AppInstance({\n rootNode: this.#shadowRoot ?? document,\n hostElement: this,\n elementOptions: options,\n overrides: overrides,\n restart: this.#triggerReload.bind(this)\n });\n }\n }\n return PioneerApplication;\n}\n"],"names":[],"mappings":";;;;AAcA,MAAM,GAAA,GAAM,aAAa,uBAAuB,CAAA;AA4JzC,SAAS,oBAAoB,OAAA,EAA8D;AAAA,EAC9F,MAAM,2BAA2B,WAAA,CAA0C;AAAA,IACvE,WAAA;AAAA,IACA,SAAA;AAAA;AAAA,IAGA,gBAAA;AAAA;AAAA,IAEA,WAAW,kBAAA,GAA+B;AACtC,MAAA,OAAO,EAAC;AAAA,IACZ;AAAA,IAEA,WAAA,GAAc;AACV,MAAA,KAAA,EAAM;AAEN,MAAA,MAAM,gBAAA,GAAmB,OAAA,CAAQ,QAAA,EAAU,gBAAA,IAAoB,IAAA;AAC/D,MAAA,IAAI,gBAAA,EAAkB;AAClB,QAAA,IAAA,CAAK,WAAA,GAAc,KAAK,YAAA,CAAa;AAAA,UACjC,IAAA,EAAM;AAAA,SACT,CAAA;AAAA,MACL,CAAA,MAAO;AACH,QAAA,GAAA,CAAI,MAAM,iDA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EjB,UAAA;AAAA,QACJ;AAEA,QAAA,GAAA,CAAI,KAAA,CAAM,2CAA2C,SAAS,CAAA;AAC9D,QAAA,IAAA,CAAK,UAAU,OAAA,EAAQ;AACvB,QAAA,IAAA,CAAK,SAAA,GAAY,IAAA,CAAK,0BAAA,CAA2B,SAAS,CAAA;AAC1D,QAAA,IAAA,CAAK,UAAU,KAAA,EAAM;AAAA,MACzB,GAAG,CAAC,CAAA;AAAA,IACR;AAAA,IAEA,2BAA2B,SAAA,EAA0B;AACjD,MAAA,OAAO,IAAI,WAAA,CAAY;AAAA,QACnB,QAAA,EAAU,KAAK,WAAA,IAAe,QAAA;AAAA,QAC9B,WAAA,EAAa,IAAA;AAAA,QACb,cAAA,EAAgB,OAAA;AAAA,QAChB,SAAA;AAAA,QACA,OAAA,EAAS,IAAA,CAAK,cAAA,CAAe,IAAA,CAAK,IAAI;AAAA,OACzC,CAAA;AAAA,IACL;AAAA;AAEJ,EAAA,OAAO,kBAAA;AACX;;;;"}
|
package/DeclaredService.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeclaredService.js","sources":["DeclaredService.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\ndeclare const INTERNAL_ASSOCIATED_SERVICE_METADATA: unique symbol;\ndeclare const ERROR: unique symbol;\n\n/**\n * Base interface for services that are associated with a well known interface name.\n *\n * By using this base interface, you can ensure that users of your interface use the correct interface name.\n *\n * Note that this interface is a type level marker only.\n * It has no real associated methods or properties and it is not necessary to implement anything\n * to use this interface in a class.\n *\n * @example\n * ```ts\n * // MyLogger should be referenced via \"my-package.Logger\"\n * export interface MyLogger extends DeclaredService<\"my-package.Logger\"> {\n * log(message: string): void;\n * }\n * ```\n *\n * > Note: TypeScript may list the `INTERNAL_ASSOCIATED_SERVICE_METADATA` property\n * > when generating the implementation for an interface extending this type.\n * > You can simply remove the offending line; it is not required (and not possible)\n * > to implement that attribute - it only exists for the compiler.\n */\nexport interface DeclaredService<InterfaceName extends string> {\n /**\n * Internal type-level service metadata.\n *\n * Note: there is no need to implement this symbol attribute.\n * It is optional and only exists for the compiler, never at runtime.\n *\n * @internal\n */\n [INTERNAL_ASSOCIATED_SERVICE_METADATA]?: ServiceMetadata<InterfaceName>;\n}\n\n/**\n * Helper symbol to declare a service's interface name when not using a separate interface.\n *\n * > NOTE: This symbol does not exist at runtime. Declaring a service interface is compile time only!\n * > It should therefore be imported via `import type` (see example below).\n *\n * @example\n *\n * ```ts\n * import { type DECLARE_SERVICE_INTERFACE} from \"@open-pioneer/runtime\";\n *\n * class MyServiceImpl {\n * // Add this line to your class.\n * // It declares (at compile time) that the service class must be used via the given interface name.\n * // Note that the property is not really present at runtime.\n * declare [DECLARE_SERVICE_INTERFACE]: \"my-package.MyInterface\";\n *\n * method(): void {\n * throw new Error(\"Method not implemented.\");\n * }\n * }\n * ```\n */\nconst DECLARE_SERVICE_INTERFACE = Symbol(\"runtime.DECLARE_SERVICE_INTERFACE\");\nexport { DECLARE_SERVICE_INTERFACE };\n\n/**\n * Given a type implementing {@link DeclaredService} or using {@link DECLARE_SERVICE_INTERFACE},\n * this type will produce the interface name associated with the service type.\n */\nexport type AssociatedInterfaceName<T> =\n T extends DeclaredService<infer InterfaceName>\n ? InterfaceName\n : T extends { [DECLARE_SERVICE_INTERFACE]: string & infer InterfaceName }\n ? InterfaceName\n : never;\n\n/**\n * This helper type produces the expected `interfaceName` (a string parameter) for the given service type.\n *\n * 1. If `ServiceType` is `unknown`, it will produce `string` to allow arbitrary parameters.\n * 2. If `ServiceType` implements {@link DeclaredService}, it will enforce the associated interface name.\n * 3. Otherwise, a compile time error is generated.\n */\nexport type InterfaceNameForServiceType<ServiceType> =\n IsUnknown<ServiceType> extends true\n ? string\n : AssociatedInterfaceName<ServiceType> extends never\n ? {\n [ERROR]: \"TypeScript integration was not set up properly for this service. Make sure the service's TypeScript interface extends 'DeclaredService'.\";\n }\n : AssociatedInterfaceName<ServiceType>;\n\n/**\n * @internal\n */\ninterface ServiceMetadata<InterfaceName> {\n interfaceName: InterfaceName;\n}\n\ntype IsUnknown<T> = unknown extends T ? ([T] extends [null] ? false : true) : false;\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DeclaredService.js","sources":["DeclaredService.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\ndeclare const INTERNAL_ASSOCIATED_SERVICE_METADATA: unique symbol;\ndeclare const ERROR: unique symbol;\n\n/**\n * Base interface for services that are associated with a well known interface name.\n *\n * By using this base interface, you can ensure that users of your interface use the correct interface name.\n *\n * Note that this interface is a type level marker only.\n * It has no real associated methods or properties and it is not necessary to implement anything\n * to use this interface in a class.\n *\n * @example\n * ```ts\n * // MyLogger should be referenced via \"my-package.Logger\"\n * export interface MyLogger extends DeclaredService<\"my-package.Logger\"> {\n * log(message: string): void;\n * }\n * ```\n *\n * > Note: TypeScript may list the `INTERNAL_ASSOCIATED_SERVICE_METADATA` property\n * > when generating the implementation for an interface extending this type.\n * > You can simply remove the offending line; it is not required (and not possible)\n * > to implement that attribute - it only exists for the compiler.\n */\nexport interface DeclaredService<InterfaceName extends string> {\n /**\n * Internal type-level service metadata.\n *\n * Note: there is no need to implement this symbol attribute.\n * It is optional and only exists for the compiler, never at runtime.\n *\n * @internal\n */\n [INTERNAL_ASSOCIATED_SERVICE_METADATA]?: ServiceMetadata<InterfaceName>;\n}\n\n/**\n * Helper symbol to declare a service's interface name when not using a separate interface.\n *\n * > NOTE: This symbol does not exist at runtime. Declaring a service interface is compile time only!\n * > It should therefore be imported via `import type` (see example below).\n *\n * @example\n *\n * ```ts\n * import { type DECLARE_SERVICE_INTERFACE} from \"@open-pioneer/runtime\";\n *\n * class MyServiceImpl {\n * // Add this line to your class.\n * // It declares (at compile time) that the service class must be used via the given interface name.\n * // Note that the property is not really present at runtime.\n * declare [DECLARE_SERVICE_INTERFACE]: \"my-package.MyInterface\";\n *\n * method(): void {\n * throw new Error(\"Method not implemented.\");\n * }\n * }\n * ```\n */\nconst DECLARE_SERVICE_INTERFACE = Symbol(\"runtime.DECLARE_SERVICE_INTERFACE\");\nexport { DECLARE_SERVICE_INTERFACE };\n\n/**\n * Given a type implementing {@link DeclaredService} or using {@link DECLARE_SERVICE_INTERFACE},\n * this type will produce the interface name associated with the service type.\n */\nexport type AssociatedInterfaceName<T> =\n T extends DeclaredService<infer InterfaceName>\n ? InterfaceName\n : T extends { [DECLARE_SERVICE_INTERFACE]: string & infer InterfaceName }\n ? InterfaceName\n : never;\n\n/**\n * This helper type produces the expected `interfaceName` (a string parameter) for the given service type.\n *\n * 1. If `ServiceType` is `unknown`, it will produce `string` to allow arbitrary parameters.\n * 2. If `ServiceType` implements {@link DeclaredService}, it will enforce the associated interface name.\n * 3. Otherwise, a compile time error is generated.\n */\nexport type InterfaceNameForServiceType<ServiceType> =\n IsUnknown<ServiceType> extends true\n ? string\n : AssociatedInterfaceName<ServiceType> extends never\n ? {\n [ERROR]: \"TypeScript integration was not set up properly for this service. Make sure the service's TypeScript interface extends 'DeclaredService'.\";\n }\n : AssociatedInterfaceName<ServiceType>;\n\n/**\n * @internal\n */\ninterface ServiceMetadata<InterfaceName> {\n interfaceName: InterfaceName;\n}\n\ntype IsUnknown<T> = unknown extends T ? ([T] extends [null] ? false : true) : false;\n"],"names":[],"mappings":"AA8DA,MAAM,yBAAA,GAA4B,OAAO,mCAAmC;;;;"}
|
package/app/AppInstance.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppInstance.js","sources":["AppInstance.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { reactive, ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport {\n createAbortError,\n createLogger,\n createManualPromise,\n destroyResource,\n Error,\n ManualPromise,\n Resource,\n throwAbortError\n} from \"@open-pioneer/core\";\nimport { createElement } from \"react\";\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 { ApplicationLifecycleEventService } from \"../builtin-services/ApplicationLifecycleEventService\";\nimport { ApplicationConfig, ApplicationProperties, CustomElementOptions } from \"../CustomElement\";\nimport { createAppRoot, isShadowRoot, RootNode } from \"../dom\";\nimport { ErrorId } from \"../errors\";\nimport { AppIntl, createPackageIntl, getBrowserLocales, I18nConfig, initI18n } from \"../i18n\";\nimport { PackageMetadata } from \"../metadata\";\nimport { ErrorScreen, MESSAGES_BY_LOCALE } from \"../react-integration/ErrorScreen\";\nimport { EmptyComponent, ReactIntegration } from \"../react-integration/ReactIntegration\";\nimport { ReferenceSpec } from \"../service-layer/InterfaceSpec\";\nimport { createPackages, PackageRepr } from \"../service-layer/PackageRepr\";\nimport { ServiceLayer } from \"../service-layer/ServiceLayer\";\nimport { gatherConfig } from \"./gatherConfig\";\nimport { logError } from \"./logErrors\";\n\nconst LOG = createLogger(\"runtime:AppInstance\");\n\nexport interface AppOptions {\n /** The root node that contains the application. */\n rootNode: RootNode;\n\n /** The HTML element that embeds the application. */\n hostElement: HTMLElement;\n\n /** Trails options for the application. */\n elementOptions: CustomElementOptions;\n\n /** These have higher priority than the options in `elementOptions`. */\n overrides: AppOverrides | 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?: AppOverrides) => void;\n}\n\nexport interface AppOverrides {\n locale?: string;\n}\n\nexport type AppState = \"not-started\" | \"starting\" | \"started\" | \"destroyed\" | \"error\";\n\nexport class AppInstance {\n private options: AppOptions;\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: AppState = \"not-started\";\n private rootNode: RootNode;\n private container: HTMLElement | ShadowRoot; // parent of .pioneer-root\n private appRoot: HTMLDivElement | undefined; // .pioneer-root\n private config: ApplicationConfig | undefined;\n private serviceLayer: ServiceLayer | undefined;\n private lifecycleEvents: ApplicationLifecycleEventService | undefined;\n private reactIntegration: ReactIntegration | undefined;\n\n private stylesWatch: Resource | undefined;\n\n constructor(options: AppOptions) {\n this.options = options;\n this.container = isShadowRoot(options.rootNode) ? options.rootNode : options.hostElement;\n this.rootNode = options.rootNode;\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.container.replaceChildren();\n this.appRoot = 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 { hostElement, elementOptions, overrides } = this.options;\n const root = this.rootNode;\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 appRoot = (this.appRoot = createAppRoot(i18n.locale));\n this.container.appendChild(appRoot);\n\n const styles = this.initStylesSignal();\n\n // Launch the service layer\n const { serviceLayer, packages } = this.initServiceLayer({\n container: appRoot,\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: root,\n hostNode: hostElement,\n appRoot: appRoot,\n serviceLayer,\n packages,\n locale: i18n.locale,\n config: elementOptions.chakraSystemConfig,\n styles\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 /**\n * Returns a signal that contains the application's styles.\n * During development, the signal is updated when the user edits .css files.\n * In production, the signal is static.\n */\n private initStylesSignal(): ReadonlyReactive<string> {\n const stylesBox = this.options.elementOptions.appMetadata?.styles;\n if (!stylesBox) {\n return reactive(\"\");\n }\n\n const signal = reactive(stylesBox.value);\n if (import.meta.hot) {\n this.stylesWatch = stylesBox.on?.(\"changed\", () => {\n LOG.debug(\"Application styles changed\");\n signal.value = stylesBox.value;\n });\n }\n return signal;\n }\n\n private initServiceLayer(config: {\n container: HTMLDivElement;\n properties: ApplicationProperties;\n i18n: AppIntl;\n }) {\n const { hostElement, rootNode: 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 rootNode: 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 userLocales = getBrowserLocales();\n const i18nConfig = new I18nConfig(Object.keys(MESSAGES_BY_LOCALE));\n const { locale, messageLocale } = i18nConfig.pickSupportedLocale(undefined, userLocales);\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\n const appRoot = (this.appRoot = createAppRoot(locale));\n appRoot.classList.add(\"pioneer-root-error-screen\");\n this.container.appendChild(appRoot);\n\n const styles = this.initStylesSignal();\n\n this.reactIntegration = ReactIntegration.createForErrorScreen({\n rootNode: this.rootNode,\n hostNode: this.options.hostElement,\n appRoot: appRoot,\n locale: locale,\n config: this.options.elementOptions.chakraSystemConfig,\n styles\n });\n this.reactIntegration.render(createElement(ErrorScreen, { intl, error }));\n }\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"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAmCA,MAAM,GAAA,GAAM,aAAa,qBAAqB,CAAA;AA4BvC,MAAM,WAAY,CAAA;AAAA,EACb,OAAA;AAAA;AAAA,EAGA,UAAA;AAAA;AAAA,EACA,GAAA;AAAA;AAAA,EAEA,KAAkB,GAAA,aAAA;AAAA,EAClB,QAAA;AAAA,EACA,SAAA;AAAA;AAAA,EACA,OAAA;AAAA;AAAA,EACA,MA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;;;;"}
|
|
1
|
+
{"version":3,"file":"AppInstance.js","sources":["AppInstance.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { reactive, ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport {\n createAbortError,\n createLogger,\n createManualPromise,\n destroyResource,\n Error,\n ManualPromise,\n Resource,\n throwAbortError\n} from \"@open-pioneer/core\";\nimport { createElement } from \"react\";\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 { ApplicationLifecycleEventService } from \"../builtin-services/ApplicationLifecycleEventService\";\nimport { ApplicationConfig, ApplicationProperties, CustomElementOptions } from \"../CustomElement\";\nimport { createAppRoot, isShadowRoot, RootNode } from \"../dom\";\nimport { ErrorId } from \"../errors\";\nimport { AppIntl, createPackageIntl, getBrowserLocales, I18nConfig, initI18n } from \"../i18n\";\nimport { PackageMetadata } from \"../metadata\";\nimport { ErrorScreen, MESSAGES_BY_LOCALE } from \"../react-integration/ErrorScreen\";\nimport { EmptyComponent, ReactIntegration } from \"../react-integration/ReactIntegration\";\nimport { ReferenceSpec } from \"../service-layer/InterfaceSpec\";\nimport { createPackages, PackageRepr } from \"../service-layer/PackageRepr\";\nimport { ServiceLayer } from \"../service-layer/ServiceLayer\";\nimport { gatherConfig } from \"./gatherConfig\";\nimport { logError } from \"./logErrors\";\n\nconst LOG = createLogger(\"runtime:AppInstance\");\n\nexport interface AppOptions {\n /** The root node that contains the application. */\n rootNode: RootNode;\n\n /** The HTML element that embeds the application. */\n hostElement: HTMLElement;\n\n /** Trails options for the application. */\n elementOptions: CustomElementOptions;\n\n /** These have higher priority than the options in `elementOptions`. */\n overrides: AppOverrides | 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?: AppOverrides) => void;\n}\n\nexport interface AppOverrides {\n locale?: string;\n}\n\nexport type AppState = \"not-started\" | \"starting\" | \"started\" | \"destroyed\" | \"error\";\n\nexport class AppInstance {\n private options: AppOptions;\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: AppState = \"not-started\";\n private rootNode: RootNode;\n private container: HTMLElement | ShadowRoot; // parent of .pioneer-root\n private appRoot: HTMLDivElement | undefined; // .pioneer-root\n private config: ApplicationConfig | undefined;\n private serviceLayer: ServiceLayer | undefined;\n private lifecycleEvents: ApplicationLifecycleEventService | undefined;\n private reactIntegration: ReactIntegration | undefined;\n\n private stylesWatch: Resource | undefined;\n\n constructor(options: AppOptions) {\n this.options = options;\n this.container = isShadowRoot(options.rootNode) ? options.rootNode : options.hostElement;\n this.rootNode = options.rootNode;\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.container.replaceChildren();\n this.appRoot = 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 { hostElement, elementOptions, overrides } = this.options;\n const root = this.rootNode;\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 appRoot = (this.appRoot = createAppRoot(i18n.locale));\n this.container.appendChild(appRoot);\n\n const styles = this.initStylesSignal();\n\n // Launch the service layer\n const { serviceLayer, packages } = this.initServiceLayer({\n container: appRoot,\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: root,\n hostNode: hostElement,\n appRoot: appRoot,\n serviceLayer,\n packages,\n locale: i18n.locale,\n config: elementOptions.chakraSystemConfig,\n styles\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 /**\n * Returns a signal that contains the application's styles.\n * During development, the signal is updated when the user edits .css files.\n * In production, the signal is static.\n */\n private initStylesSignal(): ReadonlyReactive<string> {\n const stylesBox = this.options.elementOptions.appMetadata?.styles;\n if (!stylesBox) {\n return reactive(\"\");\n }\n\n const signal = reactive(stylesBox.value);\n if (import.meta.hot) {\n this.stylesWatch = stylesBox.on?.(\"changed\", () => {\n LOG.debug(\"Application styles changed\");\n signal.value = stylesBox.value;\n });\n }\n return signal;\n }\n\n private initServiceLayer(config: {\n container: HTMLDivElement;\n properties: ApplicationProperties;\n i18n: AppIntl;\n }) {\n const { hostElement, rootNode: 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 rootNode: 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 userLocales = getBrowserLocales();\n const i18nConfig = new I18nConfig(Object.keys(MESSAGES_BY_LOCALE));\n const { locale, messageLocale } = i18nConfig.pickSupportedLocale(undefined, userLocales);\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\n const appRoot = (this.appRoot = createAppRoot(locale));\n appRoot.classList.add(\"pioneer-root-error-screen\");\n this.container.appendChild(appRoot);\n\n const styles = this.initStylesSignal();\n\n this.reactIntegration = ReactIntegration.createForErrorScreen({\n rootNode: this.rootNode,\n hostNode: this.options.hostElement,\n appRoot: appRoot,\n locale: locale,\n config: this.options.elementOptions.chakraSystemConfig,\n styles\n });\n this.reactIntegration.render(createElement(ErrorScreen, { intl, error }));\n }\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"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAmCA,MAAM,GAA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F,EAAA,MAAM,SAAS,YAAA,CAAa,UAAA;AAAA,IACxB,uBAAA;AAAA,IACA;AAAA,MACI;AAAA,KACJ;AAAA,IACA,EAAE,wBAAwB,IAAA;AAAK,GACnC;AACA,EAAA,IAAI,MAAA,CAAO,SAAS,OAAA,EAAS;AACzB,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,OAAA,CAAQ,QAAA;AAAA,MACR,CAAA,4BAAA,EAA+B,aAAa,CAAA,gBAAA,EAAmB,MAAA,CAAO,IAAI,CAAA,gEAAA;AAAA,KAE9E;AAAA,EACJ;AAEA,EAAA,OAAO,MAAA,CAAO,MAAM,kBAAA,EAAmB;AAC3C;;;;"}
|
package/app/gatherConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gatherConfig.js","sources":["gatherConfig.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 { ApplicationConfig, ApplicationProperties, CustomElementOptions } from \"../CustomElement\";\nimport { ErrorId } from \"../errors\";\nimport { AppOverrides } from \"./AppInstance\";\n\n/**\n * Gathers application properties by reading them from the options object\n * and by (optionally) invoking the `resolveProperties` hook.\n */\nexport async function gatherConfig(\n hostElement: HTMLElement,\n options: CustomElementOptions,\n overrides?: AppOverrides\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"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"gatherConfig.js","sources":["gatherConfig.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 { ApplicationConfig, ApplicationProperties, CustomElementOptions } from \"../CustomElement\";\nimport { ErrorId } from \"../errors\";\nimport { AppOverrides } from \"./AppInstance\";\n\n/**\n * Gathers application properties by reading them from the options object\n * and by (optionally) invoking the `resolveProperties` hook.\n */\nexport async function gatherConfig(\n hostElement: HTMLElement,\n options: CustomElementOptions,\n overrides?: AppOverrides\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"],"names":[],"mappings":";;;AAWA,eAAsB,YAAA,CAClB,WAAA,EACA,OAAA,EACA,SAAA,EACF;AACE,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI;AACA,IAAA,MAAM,YAAA,GAAe,OAAA,CAAQ,MAAA,IAAU,EAAC;AACxC,IAAA,MAAM,aAAA,GACD,MAAM,OAAA,CAAQ,aAAA,GAAgB;AAAA,MAC3B,WAAA;AAAA,MACA,aAAa,IAAA,EAAM;AACf,QAAA,OAAO,WAAA,CAAY,YAAA,CAAa,IAAI,CAAA,IAAK,KAAA,CAAA;AAAA,MAC7C;AAAA,KACH,KAAM,EAAC;AAEZ,IAAA,OAAA,GAAU,CAAC,cAAc,aAAa,CAAA;AAAA,EAC1C,SAAS,CAAA,EAAG;AACR,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,OAAA,CAAQ,wBAAA;AAAA,MACR,2CAAA;AAAA,MACA;AAAA,QACI,KAAA,EAAO;AAAA;AACX,KACJ;AAAA,EACJ;AAEA,EAAA,MAAM,MAAA,GAAS,aAAa,OAAO,CAAA;AACnC,EAAA,IAAI,WAAW,MAAA,EAAQ;AACnB,IAAA,MAAA,CAAO,SAAS,SAAA,CAAU,MAAA;AAAA,EAC9B;AACA,EAAA,OAAO,MAAA;AACX;AAMA,SAAS,aAAa,OAAA,EAA2D;AAE7E,EAAA,MAAM,eAA4C,MAAA,CAAO,MAAA;AAAA,IACrD;AAAA,MACI,MAAA,EAAQ,MAAA;AAAA,MACR,YAAY;AAAC,KACjB;AAAA,IACA,GAAG;AAAA,GACP;AAGA,EAAA,MAAM,gBAAA,GAA2C,YAAA,CAAa,UAAA,GAAa,EAAC;AAC5E,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC1B,IAAA,KAAA,MAAW,CAAC,WAAA,EAAa,iBAAiB,CAAA,IAAK,MAAA,CAAO,QAAQ,MAAA,CAAO,UAAA,IAAc,EAAE,CAAA,EAAG;AACpF,MAAA,MAAM,kBAAA,GAAsB,gBAAA,CAAiB,WAAW,CAAA,KAAM,EAAC;AAC/D,MAAA,MAAA,CAAO,MAAA,CAAO,oBAAoB,iBAAiB,CAAA;AAAA,IACvD;AAAA,EACJ;AAEA,EAAA,OAAO,YAAA;AACX;;;;"}
|
package/app/logErrors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logErrors.js","sources":["logErrors.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { getErrorChain } from \"@open-pioneer/core\";\n\nexport function 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"],"names":[],"mappings":";;AAIO,SAAS,SAAS,
|
|
1
|
+
{"version":3,"file":"logErrors.js","sources":["logErrors.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { getErrorChain } from \"@open-pioneer/core\";\n\nexport function 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"],"names":[],"mappings":";;AAIO,SAAS,SAAS,CAAA,EAAY;AACjC,EAAA,IAAI,aAAa,KAAA,EAAO;AACpB,IAAA,MAAM,KAAA,GAAQ,aAAA,CAAc,CAAC,CAAA,CAAE,OAAA,EAAQ;AACvC,IAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACpB,MAAA,OAAA,CAAQ,MAAM,CAAC,CAAA;AACf,MAAA;AAAA,IACJ;AAEA,IAAA,IAAI,CAAA,GAAI,CAAA;AACR,IAAA,KAAA,MAAW,SAAS,KAAA,EAAO;AACvB,MAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,EAAI,KAAK,CAAA;AAC5B,MAAA,EAAE,CAAA;AAAA,IACN;AAAA,EACJ,CAAA,MAAO;AACH,IAAA,OAAA,CAAQ,KAAA,CAAM,oBAAoB,CAAC,CAAA;AAAA,EACvC;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiServiceImpl.js","sources":["ApiServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ServiceOptions } from \"../Service\";\nimport { ApiExtension, ApiMethod, ApiMethods, ApiService } from \"../api\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\n\ninterface References {\n providers: ApiExtension[];\n}\n\nexport class ApiServiceImpl implements ApiService {\n private readonly providers: [serviceId: string, provider: ApiExtension][];\n\n constructor(options: ServiceOptions<References>) {\n const providers = options.references.providers;\n const meta = options.referencesMeta.providers;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.providers = providers.map((provider, index) => [meta[index]!.serviceId, provider]);\n }\n\n async getApi() {\n interface ProviderResult {\n serviceId: string;\n methods: ApiMethods;\n }\n\n const promises = this.providers.map(async ([serviceId, provider]) => {\n const methods = await provider.getApiMethods();\n const result: ProviderResult = {\n serviceId,\n methods\n };\n return result;\n });\n const providerMethods = await Promise.all(promises);\n\n interface MethodEntry {\n method: ApiMethod;\n serviceId: string;\n }\n\n const methodEntries = new Map<string, MethodEntry>();\n for (const { serviceId, methods } of providerMethods) {\n for (const [methodName, method] of Object.entries(methods)) {\n const existingEntry = methodEntries.get(methodName);\n if (existingEntry) {\n throw new Error(\n ErrorId.DUPLICATE_API_METHODS,\n `Cannot define API method '${methodName}' from '${serviceId}' (method is also defined by '${existingEntry.serviceId}').`\n );\n }\n\n methodEntries.set(methodName, {\n serviceId,\n method\n });\n }\n }\n\n const api: Record<string, ApiMethod> = {};\n for (const [methodName, entry] of methodEntries.entries()) {\n api[methodName] = entry.method;\n }\n return api;\n }\n}\n"],"names":[],"mappings":";;;AAWO,MAAM,
|
|
1
|
+
{"version":3,"file":"ApiServiceImpl.js","sources":["ApiServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ServiceOptions } from \"../Service\";\nimport { ApiExtension, ApiMethod, ApiMethods, ApiService } from \"../api\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\n\ninterface References {\n providers: ApiExtension[];\n}\n\nexport class ApiServiceImpl implements ApiService {\n private readonly providers: [serviceId: string, provider: ApiExtension][];\n\n constructor(options: ServiceOptions<References>) {\n const providers = options.references.providers;\n const meta = options.referencesMeta.providers;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.providers = providers.map((provider, index) => [meta[index]!.serviceId, provider]);\n }\n\n async getApi() {\n interface ProviderResult {\n serviceId: string;\n methods: ApiMethods;\n }\n\n const promises = this.providers.map(async ([serviceId, provider]) => {\n const methods = await provider.getApiMethods();\n const result: ProviderResult = {\n serviceId,\n methods\n };\n return result;\n });\n const providerMethods = await Promise.all(promises);\n\n interface MethodEntry {\n method: ApiMethod;\n serviceId: string;\n }\n\n const methodEntries = new Map<string, MethodEntry>();\n for (const { serviceId, methods } of providerMethods) {\n for (const [methodName, method] of Object.entries(methods)) {\n const existingEntry = methodEntries.get(methodName);\n if (existingEntry) {\n throw new Error(\n ErrorId.DUPLICATE_API_METHODS,\n `Cannot define API method '${methodName}' from '${serviceId}' (method is also defined by '${existingEntry.serviceId}').`\n );\n }\n\n methodEntries.set(methodName, {\n serviceId,\n method\n });\n }\n }\n\n const api: Record<string, ApiMethod> = {};\n for (const [methodName, entry] of methodEntries.entries()) {\n api[methodName] = entry.method;\n }\n return api;\n }\n}\n"],"names":[],"mappings":";;;AAWO,MAAM,cAAA,CAAqC;AAAA,EAC7B,SAAA;AAAA,EAEjB,YAAY,OAAA,EAAqC;AAC7C,IAAA,MAAM,SAAA,GAAY,QAAQ,UAAA,CAAW,SAAA;AACrC,IAAA,MAAM,IAAA,GAAO,QAAQ,cAAA,CAAe,SAAA;AAEpC,IAAA,IAAA,CAAK,SAAA,GAAY,SAAA,CAAU,GAAA,CAAI,CAAC,QAAA,EAAU,KAAA,KAAU,CAAC,IAAA,CAAK,KAAK,CAAA,CAAG,SAAA,EAAW,QAAQ,CAAC,CAAA;AAAA,EAC1F;AAAA,EAEA,MAAM,MAAA,GAAS;AAMX,IAAA,MAAM,QAAA,GAAW,KAAK,SAAA,CAAU,GAAA,CAAI,OAAO,CAAC,SAAA,EAAW,QAAQ,CAAA,KAAM;AACjE,MAAA,MAAM,OAAA,GAAU,MAAM,QAAA,CAAS,aAAA,EAAc;AAC7C,MAAA,MAAM,MAAA,GAAyB;AAAA,QAC3B,SAAA;AAAA,QACA;AAAA,OACJ;AACA,MAAA,OAAO,MAAA;AAAA,IACX,CAAC,CAAA;AACD,IAAA,MAAM,eAAA,GAAkB,MAAM,OAAA,CAAQ,GAAA,CAAI,QAAQ,CAAA;AAOlD,IAAA,MAAM,aAAA,uBAAoB,GAAA,EAAyB;AACnD,IAAA,KAAA,MAAW,EAAE,SAAA,EAAW,OAAA,EAAQ,IAAK,eAAA,EAAiB;AAClD,MAAA,KAAA,MAAW,CAAC,UAAA,EAAY,MAAM,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AACxD,QAAA,MAAM,aAAA,GAAgB,aAAA,CAAc,GAAA,CAAI,UAAU,CAAA;AAClD,QAAA,IAAI,aAAA,EAAe;AACf,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAA,CAAQ,qBAAA;AAAA,YACR,6BAA6B,UAAU,CAAA,QAAA,EAAW,SAAS,CAAA,8BAAA,EAAiC,cAAc,SAAS,CAAA,GAAA;AAAA,WACvH;AAAA,QACJ;AAEA,QAAA,aAAA,CAAc,IAAI,UAAA,EAAY;AAAA,UAC1B,SAAA;AAAA,UACA;AAAA,SACH,CAAA;AAAA,MACL;AAAA,IACJ;AAEA,IAAA,MAAM,MAAiC,EAAC;AACxC,IAAA,KAAA,MAAW,CAAC,UAAA,EAAY,KAAK,CAAA,IAAK,aAAA,CAAc,SAAQ,EAAG;AACvD,MAAA,GAAA,CAAI,UAAU,IAAI,KAAA,CAAM,MAAA;AAAA,IAC5B;AACA,IAAA,OAAO,GAAA;AAAA,EACX;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationContextImpl.js","sources":["ApplicationContextImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ApplicationContext } from \"../api\";\nimport { isShadowRoot, RootNode } from \"../dom\";\nimport { ServiceOptions } from \"../Service\";\n\nexport interface ApplicationContextProperties {\n host: HTMLElement;\n rootNode: RootNode;\n container: HTMLElement;\n locale: string;\n supportedLocales: string[];\n\n /** A callback to change the application's locale is injected by the runtime. */\n changeLocale(locale: string): void;\n}\n\nexport class ApplicationContextImpl implements ApplicationContext {\n #host: HTMLElement;\n #rootNode: RootNode;\n #container: HTMLElement;\n #locale: string;\n #supportedLocales: readonly string[];\n #changeLocale: (locale: string) => void;\n\n constructor(_options: ServiceOptions, properties: ApplicationContextProperties) {\n this.#host = properties.host;\n this.#rootNode = properties.rootNode;\n this.#container = properties.container;\n this.#locale = properties.locale;\n this.#supportedLocales = Object.freeze(Array.from(properties.supportedLocales));\n this.#changeLocale = properties.changeLocale;\n }\n\n getHostElement(): HTMLElement {\n return this.#host;\n }\n\n getRoot(): RootNode {\n return this.#rootNode;\n }\n\n getShadowRoot(): ShadowRoot | undefined {\n return isShadowRoot(this.#rootNode) ? this.#rootNode : undefined;\n }\n\n getApplicationContainer(): HTMLElement {\n return this.#container;\n }\n\n getLocale(): string {\n return this.#locale;\n }\n\n setLocale(locale: string): void {\n // This restarts the application at the moment, so this.locale will _not_ be updated.\n // Instead, we get a new application with a new application context.\n this.#changeLocale(locale);\n }\n\n getSupportedLocales(): readonly string[] {\n return this.#supportedLocales;\n }\n}\n"],"names":[],"mappings":";;AAiBO,MAAM,
|
|
1
|
+
{"version":3,"file":"ApplicationContextImpl.js","sources":["ApplicationContextImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ApplicationContext } from \"../api\";\nimport { isShadowRoot, RootNode } from \"../dom\";\nimport { ServiceOptions } from \"../Service\";\n\nexport interface ApplicationContextProperties {\n host: HTMLElement;\n rootNode: RootNode;\n container: HTMLElement;\n locale: string;\n supportedLocales: string[];\n\n /** A callback to change the application's locale is injected by the runtime. */\n changeLocale(locale: string): void;\n}\n\nexport class ApplicationContextImpl implements ApplicationContext {\n #host: HTMLElement;\n #rootNode: RootNode;\n #container: HTMLElement;\n #locale: string;\n #supportedLocales: readonly string[];\n #changeLocale: (locale: string) => void;\n\n constructor(_options: ServiceOptions, properties: ApplicationContextProperties) {\n this.#host = properties.host;\n this.#rootNode = properties.rootNode;\n this.#container = properties.container;\n this.#locale = properties.locale;\n this.#supportedLocales = Object.freeze(Array.from(properties.supportedLocales));\n this.#changeLocale = properties.changeLocale;\n }\n\n getHostElement(): HTMLElement {\n return this.#host;\n }\n\n getRoot(): RootNode {\n return this.#rootNode;\n }\n\n getShadowRoot(): ShadowRoot | undefined {\n return isShadowRoot(this.#rootNode) ? this.#rootNode : undefined;\n }\n\n getApplicationContainer(): HTMLElement {\n return this.#container;\n }\n\n getLocale(): string {\n return this.#locale;\n }\n\n setLocale(locale: string): void {\n // This restarts the application at the moment, so this.locale will _not_ be updated.\n // Instead, we get a new application with a new application context.\n this.#changeLocale(locale);\n }\n\n getSupportedLocales(): readonly string[] {\n return this.#supportedLocales;\n }\n}\n"],"names":[],"mappings":";;AAiBO,MAAM,sBAAA,CAAqD;AAAA,EAC9D,KAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,iBAAA;AAAA,EACA,aAAA;AAAA,EAEA,WAAA,CAAY,UAA0B,UAAA,EAA0C;AAC5E,IAAA,IAAA,CAAK,QAAQ,UAAA,CAAW,IAAA;AACxB,IAAA,IAAA,CAAK,YAAY,UAAA,CAAW,QAAA;AAC5B,IAAA,IAAA,CAAK,aAAa,UAAA,CAAW,SAAA;AAC7B,IAAA,IAAA,CAAK,UAAU,UAAA,CAAW,MAAA;AAC1B,IAAA,IAAA,CAAK,oBAAoB,MAAA,CAAO,MAAA,CAAO,MAAM,IAAA,CAAK,UAAA,CAAW,gBAAgB,CAAC,CAAA;AAC9E,IAAA,IAAA,CAAK,gBAAgB,UAAA,CAAW,YAAA;AAAA,EACpC;AAAA,EAEA,cAAA,GAA8B;AAC1B,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EAChB;AAAA,EAEA,OAAA,GAAoB;AAChB,IAAA,OAAO,IAAA,CAAK,SAAA;AAAA,EAChB;AAAA,EAEA,aAAA,GAAwC;AACpC,IAAA,OAAO,YAAA,CAAa,IAAA,CAAK,SAAS,CAAA,GAAI,KAAK,SAAA,GAAY,MAAA;AAAA,EAC3D;AAAA,EAEA,uBAAA,GAAuC;AACnC,IAAA,OAAO,IAAA,CAAK,UAAA;AAAA,EAChB;AAAA,EAEA,SAAA,GAAoB;AAChB,IAAA,OAAO,IAAA,CAAK,OAAA;AAAA,EAChB;AAAA,EAEA,UAAU,MAAA,EAAsB;AAG5B,IAAA,IAAA,CAAK,cAAc,MAAM,CAAA;AAAA,EAC7B;AAAA,EAEA,mBAAA,GAAyC;AACrC,IAAA,OAAO,IAAA,CAAK,iBAAA;AAAA,EAChB;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationLifecycleEventService.js","sources":["ApplicationLifecycleEventService.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger } from \"@open-pioneer/core\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ServiceOptions } from \"../Service\";\nimport { ApplicationLifecycleListener } from \"../api\";\nimport { ErrorId } from \"../errors\";\n\nconst LOG = createLogger(\"runtime:ApplicationLifecycleEventService\");\n\ninterface References {\n listeners: ApplicationLifecycleListener[];\n}\n\nexport class ApplicationLifecycleEventService {\n #listeners: [serviceId: string, listener: ApplicationLifecycleListener][];\n\n constructor(options: ServiceOptions<References>) {\n const listeners = options.references.listeners;\n const listenersMeta = options.referencesMeta.listeners;\n this.#listeners = listeners.map((listener, index) => [\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n listenersMeta[index]!.serviceId,\n listener\n ]);\n }\n\n /** @internal */\n emitLifecycleEvent(event: \"after-start\" | \"before-stop\"): void {\n const methodName = (() => {\n switch (event) {\n case \"after-start\":\n return \"afterApplicationStart\";\n case \"before-stop\":\n return \"beforeApplicationStop\";\n default:\n throw new Error(ErrorId.INTERNAL, `Invalid event '${event}'`);\n }\n })();\n for (const [serviceId, listener] of this.#listeners) {\n try {\n listener[methodName]?.();\n } catch (e) {\n LOG.error(`Unexpected error from application lifecycle listener ${serviceId}`, e);\n }\n }\n }\n}\n"],"names":[],"mappings":";;;AAQA,MAAM,GAAA,GAAM,aAAa,0CAA0C,CAAA;AAM5D,MAAM,
|
|
1
|
+
{"version":3,"file":"ApplicationLifecycleEventService.js","sources":["ApplicationLifecycleEventService.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger } from \"@open-pioneer/core\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ServiceOptions } from \"../Service\";\nimport { ApplicationLifecycleListener } from \"../api\";\nimport { ErrorId } from \"../errors\";\n\nconst LOG = createLogger(\"runtime:ApplicationLifecycleEventService\");\n\ninterface References {\n listeners: ApplicationLifecycleListener[];\n}\n\nexport class ApplicationLifecycleEventService {\n #listeners: [serviceId: string, listener: ApplicationLifecycleListener][];\n\n constructor(options: ServiceOptions<References>) {\n const listeners = options.references.listeners;\n const listenersMeta = options.referencesMeta.listeners;\n this.#listeners = listeners.map((listener, index) => [\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n listenersMeta[index]!.serviceId,\n listener\n ]);\n }\n\n /** @internal */\n emitLifecycleEvent(event: \"after-start\" | \"before-stop\"): void {\n const methodName = (() => {\n switch (event) {\n case \"after-start\":\n return \"afterApplicationStart\";\n case \"before-stop\":\n return \"beforeApplicationStop\";\n default:\n throw new Error(ErrorId.INTERNAL, `Invalid event '${event}'`);\n }\n })();\n for (const [serviceId, listener] of this.#listeners) {\n try {\n listener[methodName]?.();\n } catch (e) {\n LOG.error(`Unexpected error from application lifecycle listener ${serviceId}`, e);\n }\n }\n }\n}\n"],"names":[],"mappings":";;;AAQA,MAAM,GAAA,GAAM,aAAa,0CAA0C,CAAA;AAM5D,MAAM,gCAAA,CAAiC;AAAA,EAC1C,UAAA;AAAA,EAEA,YAAY,OAAA,EAAqC;AAC7C,IAAA,MAAM,SAAA,GAAY,QAAQ,UAAA,CAAW,SAAA;AACrC,IAAA,MAAM,aAAA,GAAgB,QAAQ,cAAA,CAAe,SAAA;AAC7C,IAAA,IAAA,CAAK,UAAA,GAAa,SAAA,CAAU,GAAA,CAAI,CAAC,UAAU,KAAA,KAAU;AAAA;AAAA,MAEjD,aAAA,CAAc,KAAK,CAAA,CAAG,SAAA;AAAA,MACtB;AAAA,KACH,CAAA;AAAA,EACL;AAAA;AAAA,EAGA,mBAAmB,KAAA,EAA4C;AAC3D,IAAA,MAAM,cAAc,MAAM;AACtB,MAAA,QAAQ,KAAA;AAAO,QACX,KAAK,aAAA;AACD,UAAA,OAAO,uBAAA;AAAA,QACX,KAAK,aAAA;AACD,UAAA,OAAO,uBAAA;AAAA,QACX;AACI,UAAA,MAAM,IAAI,KAAA,CAAM,OAAA,CAAQ,QAAA,EAAU,CAAA,eAAA,EAAkB,KAAK,CAAA,CAAA,CAAG,CAAA;AAAA;AACpE,IACJ,CAAA,GAAG;AACH,IAAA,KAAA,MAAW,CAAC,SAAA,EAAW,QAAQ,CAAA,IAAK,KAAK,UAAA,EAAY;AACjD,MAAA,IAAI;AACA,QAAA,QAAA,CAAS,UAAU,CAAA,IAAI;AAAA,MAC3B,SAAS,CAAA,EAAG;AACR,QAAA,GAAA,CAAI,KAAA,CAAM,CAAA,qDAAA,EAAwD,SAAS,CAAA,CAAA,EAAI,CAAC,CAAA;AAAA,MACpF;AAAA,IACJ;AAAA,EACJ;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberParserServiceImpl.js","sources":["NumberParserServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { NumberParserService } from \"../api\";\nimport { ServiceOptions } from \"../Service\";\nimport { createLogger, NumberParser } from \"@open-pioneer/core\";\n\nconst LOG = createLogger(\"runtime:NumberParserService\");\n\nexport class NumberParserServiceImpl implements NumberParserService {\n private numberParser: NumberParser;\n\n constructor(serviceOptions: ServiceOptions, locale: string) {\n try {\n this.numberParser = new NumberParser(locale);\n } catch (e) {\n LOG.warn(\n \"Failed to create NumberParserImpl with locale. Retrying with default 'en-US' locale.\",\n e\n );\n this.numberParser = new NumberParser(\"en-US\");\n }\n }\n\n parseNumber(numberString: string): number {\n return this.numberParser.parse(numberString);\n }\n}\n"],"names":[],"mappings":";;AAMA,MAAM,GAAA,GAAM,aAAa,6BAA6B,CAAA;AAE/C,MAAM,
|
|
1
|
+
{"version":3,"file":"NumberParserServiceImpl.js","sources":["NumberParserServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { NumberParserService } from \"../api\";\nimport { ServiceOptions } from \"../Service\";\nimport { createLogger, NumberParser } from \"@open-pioneer/core\";\n\nconst LOG = createLogger(\"runtime:NumberParserService\");\n\nexport class NumberParserServiceImpl implements NumberParserService {\n private numberParser: NumberParser;\n\n constructor(serviceOptions: ServiceOptions, locale: string) {\n try {\n this.numberParser = new NumberParser(locale);\n } catch (e) {\n LOG.warn(\n \"Failed to create NumberParserImpl with locale. Retrying with default 'en-US' locale.\",\n e\n );\n this.numberParser = new NumberParser(\"en-US\");\n }\n }\n\n parseNumber(numberString: string): number {\n return this.numberParser.parse(numberString);\n }\n}\n"],"names":[],"mappings":";;AAMA,MAAM,GAAA,GAAM,aAAa,6BAA6B,CAAA;AAE/C,MAAM,uBAAA,CAAuD;AAAA,EACxD,YAAA;AAAA,EAER,WAAA,CAAY,gBAAgC,MAAA,EAAgB;AACxD,IAAA,IAAI;AACA,MAAA,IAAA,CAAK,YAAA,GAAe,IAAI,YAAA,CAAa,MAAM,CAAA;AAAA,IAC/C,SAAS,CAAA,EAAG;AACR,MAAA,GAAA,CAAI,IAAA;AAAA,QACA,sFAAA;AAAA,QACA;AAAA,OACJ;AACA,MAAA,IAAA,CAAK,YAAA,GAAe,IAAI,YAAA,CAAa,OAAO,CAAA;AAAA,IAChD;AAAA,EACJ;AAAA,EAEA,YAAY,YAAA,EAA8B;AACtC,IAAA,OAAO,IAAA,CAAK,YAAA,CAAa,KAAA,CAAM,YAAY,CAAA;AAAA,EAC/C;AACJ;;;;"}
|
|
@@ -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 { 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,
|
|
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,oBAAA,GAAuB;AAC7B,MAAM,qBAAA,GAAwB;AAC9B,MAAM,mBAAA,GAAsB;AAC5B,MAAM,2BAAA,GAA8B;AACpC,MAAM,2CAAA,GACT;AACG,MAAM,6BAAA,GAAgC;AACtC,MAAM,kBAAA,GAAqB;AAc3B,SAAS,qBAAqB,UAAA,EAAmD;AACpF,EAAA,MAAM,OAAO,sBAAA,EAAuB;AACpC,EAAA,MAAM,UAAA,GAAa,IAAI,WAAA,CAAY;AAAA,IAC/B,IAAA,EAAM,gBAAA;AAAA,IACN,WAAA,EAAa,oBAAA;AAAA,IACb,OAAA,EAAS,yBAAyB,cAAc,CAAA;AAAA,IAChD,IAAA,EAAM,IAA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AAA,EAAS,WAAW,MAAM;AAAA,KACvE;AAAA,IACA,IAAA,EAAM,IAAA;AAAA,IACN,UAAA,EAAY;AAAA,MACR;AAAA,QACI,aAAA,EAAe,6BAAA;AAAA,QACf,SAAA,EAAW;AAAA;AACf;AACJ,GACH,CAAA;AAED,EAAA,OAAO,IAAI,WAAA,CAAY;AAAA,IACnB,IAAA,EAAM,oBAAA;AAAA,IACN,QAAA,EAAU,CAAC,UAAA,EAAY,UAAA,EAAY,uBAAuB,mBAAmB,CAAA;AAAA,IAC7E,IAAA,EAAM;AAAA,GACT,CAAA;AACL;;;;"}
|
package/dom/index.js.map
CHANGED
|
@@ -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\nexport type RootNode = Document | ShadowRoot;\n\n/**\n * Class of the <div> that contains the entire application.\n */\nexport const APP_ROOT_CLASS = \"pioneer-root\";\n\nexport function isShadowRoot(node: RootNode): node is ShadowRoot {\n return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && \"host\" in node;\n}\n\nexport function isDocument(node: RootNode): node is Document {\n return !isShadowRoot(node);\n}\n\n/**\n * Returns the parent node for <style> elements.\n */\nexport function getStylesRoot(node: RootNode): ShadowRoot | HTMLHeadElement {\n return isShadowRoot(node) ? node : node.head;\n}\n\n/**\n * Creates the node that contains all other application content.\n */\nexport function createAppRoot(locale: string): HTMLDivElement {\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\n/**\n * Returns the styles for host element (the web component node).\n */\nexport function getBuiltinStyles(rootNode: RootNode, hostElement: HTMLElement | undefined) {\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 // NOTE: layer base comes from chakra (used for css resets etc).\n const selector =\n isShadowRoot(rootNode) || !hostElement ? \":host\" : hostElement.tagName.toLowerCase();\n return `@layer base { ${selector} { all: initial; display: block; } }`;\n}\n"],"names":[],"mappings":"AAOO,MAAM,
|
|
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\nexport type RootNode = Document | ShadowRoot;\n\n/**\n * Class of the <div> that contains the entire application.\n */\nexport const APP_ROOT_CLASS = \"pioneer-root\";\n\nexport function isShadowRoot(node: RootNode): node is ShadowRoot {\n return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && \"host\" in node;\n}\n\nexport function isDocument(node: RootNode): node is Document {\n return !isShadowRoot(node);\n}\n\n/**\n * Returns the parent node for <style> elements.\n */\nexport function getStylesRoot(node: RootNode): ShadowRoot | HTMLHeadElement {\n return isShadowRoot(node) ? node : node.head;\n}\n\n/**\n * Creates the node that contains all other application content.\n */\nexport function createAppRoot(locale: string): HTMLDivElement {\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\n/**\n * Returns the styles for host element (the web component node).\n */\nexport function getBuiltinStyles(rootNode: RootNode, hostElement: HTMLElement | undefined) {\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 // NOTE: layer base comes from chakra (used for css resets etc).\n const selector =\n isShadowRoot(rootNode) || !hostElement ? \":host\" : hostElement.tagName.toLowerCase();\n return `@layer base { ${selector} { all: initial; display: block; } }`;\n}\n"],"names":[],"mappings":"AAOO,MAAM,cAAA,GAAiB;AAEvB,SAAS,aAAa,IAAA,EAAoC;AAC7D,EAAA,OAAO,IAAA,CAAK,QAAA,KAAa,IAAA,CAAK,sBAAA,IAA0B,MAAA,IAAU,IAAA;AACtE;AASO,SAAS,cAAc,IAAA,EAA8C;AACxE,EAAA,OAAO,YAAA,CAAa,IAAI,CAAA,GAAI,IAAA,GAAO,IAAA,CAAK,IAAA;AAC5C;AAKO,SAAS,cAAc,MAAA,EAAgC;AAE1D,EAAA,MAAM,SAAA,GAAY,QAAA,CAAS,aAAA,CAAc,KAAK,CAAA;AAC9C,EAAA,SAAA,CAAU,SAAA,CAAU,IAAI,cAAc,CAAA;AACtC,EAAA,SAAA,CAAU,MAAM,SAAA,GAAY,MAAA;AAC5B,EAAA,SAAA,CAAU,MAAM,MAAA,GAAS,MAAA;AACzB,EAAA,IAAI,MAAA,EAAQ;AACR,IAAA,SAAA,CAAU,IAAA,GAAO,MAAA;AAAA,EACrB;AACA,EAAA,OAAO,SAAA;AACX;AAKO,SAAS,gBAAA,CAAiB,UAAoB,WAAA,EAAsC;AAIvF,EAAA,MAAM,QAAA,GACF,aAAa,QAAQ,CAAA,IAAK,CAAC,WAAA,GAAc,OAAA,GAAU,WAAA,CAAY,OAAA,CAAQ,WAAA,EAAY;AACvF,EAAA,OAAO,iBAAiB,QAAQ,CAAA,oCAAA,CAAA;AACpC;;;;"}
|
package/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sources":["errors.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nexport enum ErrorId {\n // Problems with application metadata\n INVALID_METADATA = \"runtime:invalid-metadata\",\n INVALID_PROPERTY_NAME = \"runtime:invalid-property-name\",\n REQUIRED_PROPERTY = \"runtime:required-property\",\n\n // Application lifecycle\n NOT_MOUNTED = \"runtime:element-not-mounted\",\n UNSUPPORTED_LOCALE = \"runtime:unsupported-locale\",\n CONFIG_RESOLUTION_FAILED = \"runtime:config-resolution-failed\",\n INVALID_STATE = \"runtime:invalid-state\",\n\n // Service layer\n INTERFACE_NOT_FOUND = \"runtime:interface-not-found\",\n AMBIGUOUS_DEPENDENCY = \"runtime:ambiguous-dependency\",\n UNDECLARED_DEPENDENCY = \"runtime:undeclared-dependency\",\n MISSING_PACKAGE = \"runtime:missing-package\",\n SERVICE_CONSTRUCTION_FAILED = \"runtime:service-construction-failed\",\n SERVICE_DESTRUCTION_FAILED = \"runtime:service-destruction-failed\",\n DUPLICATE_INTERFACE = \"runtime:duplicate-interface\",\n DEPENDENCY_CYCLE = \"runtime:dependency-cycle\",\n\n // Web component API\n DUPLICATE_API_METHODS = \"runtime:duplicate-api-methods\",\n\n // Internal\n INTERNAL = \"runtime:internal-error\"\n}\n"],"names":["ErrorId"],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sources":["errors.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nexport enum ErrorId {\n // Problems with application metadata\n INVALID_METADATA = \"runtime:invalid-metadata\",\n INVALID_PROPERTY_NAME = \"runtime:invalid-property-name\",\n REQUIRED_PROPERTY = \"runtime:required-property\",\n\n // Application lifecycle\n NOT_MOUNTED = \"runtime:element-not-mounted\",\n UNSUPPORTED_LOCALE = \"runtime:unsupported-locale\",\n CONFIG_RESOLUTION_FAILED = \"runtime:config-resolution-failed\",\n INVALID_STATE = \"runtime:invalid-state\",\n\n // Service layer\n INTERFACE_NOT_FOUND = \"runtime:interface-not-found\",\n AMBIGUOUS_DEPENDENCY = \"runtime:ambiguous-dependency\",\n UNDECLARED_DEPENDENCY = \"runtime:undeclared-dependency\",\n MISSING_PACKAGE = \"runtime:missing-package\",\n SERVICE_CONSTRUCTION_FAILED = \"runtime:service-construction-failed\",\n SERVICE_DESTRUCTION_FAILED = \"runtime:service-destruction-failed\",\n DUPLICATE_INTERFACE = \"runtime:duplicate-interface\",\n DEPENDENCY_CYCLE = \"runtime:dependency-cycle\",\n\n // Web component API\n DUPLICATE_API_METHODS = \"runtime:duplicate-api-methods\",\n\n // Internal\n INTERNAL = \"runtime:internal-error\"\n}\n"],"names":["ErrorId"],"mappings":"AAEO,IAAK,OAAA,qBAAAA,QAAAA,KAAL;AAEH,EAAAA,SAAA,kBAAA,CAAA,GAAmB,0BAAA;AACnB,EAAAA,SAAA,uBAAA,CAAA,GAAwB,+BAAA;AACxB,EAAAA,SAAA,mBAAA,CAAA,GAAoB,2BAAA;AAGpB,EAAAA,SAAA,aAAA,CAAA,GAAc,6BAAA;AACd,EAAAA,SAAA,oBAAA,CAAA,GAAqB,4BAAA;AACrB,EAAAA,SAAA,0BAAA,CAAA,GAA2B,kCAAA;AAC3B,EAAAA,SAAA,eAAA,CAAA,GAAgB,uBAAA;AAGhB,EAAAA,SAAA,qBAAA,CAAA,GAAsB,6BAAA;AACtB,EAAAA,SAAA,sBAAA,CAAA,GAAuB,8BAAA;AACvB,EAAAA,SAAA,uBAAA,CAAA,GAAwB,+BAAA;AACxB,EAAAA,SAAA,iBAAA,CAAA,GAAkB,yBAAA;AAClB,EAAAA,SAAA,6BAAA,CAAA,GAA8B,qCAAA;AAC9B,EAAAA,SAAA,4BAAA,CAAA,GAA6B,oCAAA;AAC7B,EAAAA,SAAA,qBAAA,CAAA,GAAsB,6BAAA;AACtB,EAAAA,SAAA,kBAAA,CAAA,GAAmB,0BAAA;AAGnB,EAAAA,SAAA,uBAAA,CAAA,GAAwB,+BAAA;AAGxB,EAAAA,SAAA,UAAA,CAAA,GAAW,wBAAA;AA1BH,EAAA,OAAAA,QAAAA;AAAA,CAAA,EAAA,OAAA,IAAA,EAAA;;;;"}
|
package/i18n/AppIntl.js.map
CHANGED
|
@@ -1 +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;
|
|
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;AAuBvC,eAAsB,QAAA,CAClB,aACA,YAAA,EACgB;AAChB,EAAA,MAAM,cAAA,GAAiB,WAAA,EAAa,OAAA,IAAW,EAAC;AAChD,EAAA,MAAM,cAAc,iBAAA,EAAkB;AACtC,EAAA,IAAI,GAAA,CAAI,SAAQ,EAAG;AACf,IAAA,GAAA,CAAI,KAAA;AAAA,MACA,gDAAgD,WAAA,CAAY,IAAA;AAAA,QACxD;AAAA,OACH,kCAAkC,cAAA,CAAe,IAAA;AAAA,QAC9C;AAAA,OACH,mBAAmB,YAAY,CAAA,EAAA;AAAA,KACpC;AAAA,EACJ;AAEA,EAAA,MAAM,UAAA,GAAa,IAAI,UAAA,CAAW,cAAc,CAAA;AAChD,EAAA,MAAM,EAAE,MAAA,EAAQ,aAAA,KAAkB,UAAA,CAAW,mBAAA,CAAoB,cAAc,WAAW,CAAA;AAE1F,EAAA,IAAI,GAAA,CAAI,SAAQ,EAAG;AACf,IAAA,GAAA,CAAI,KAAA,CAAM,CAAA,cAAA,EAAiB,MAAM,CAAA,6BAAA,EAAgC,aAAa,CAAA,EAAA,CAAI,CAAA;AAAA,EACtF;AAEA,EAAA,IAAI,QAAA;AACJ,EAAA,IAAI,cAAA,CAAe,QAAA,CAAS,aAAa,CAAA,EAAG;AACxC,IAAA,IAAI;AACA,MAAA,QAAA,GAAY,MAAM,WAAA,EAAa,YAAA,GAAe,aAAa,KAAM,EAAC;AAAA,IACtE,SAAS,CAAA,EAAG;AACR,MAAA,MAAM,IAAI,KAAA;AAAA,QACN,OAAA,CAAQ,QAAA;AAAA,QACR,uCAAuC,aAAa,CAAA,EAAA,CAAA;AAAA,QACpD;AAAA,UACI,KAAA,EAAO;AAAA;AACX,OACJ;AAAA,IACJ;AAAA,EACJ;AACA,EAAA,OAAO;AAAA,IACH,MAAA;AAAA,IACA,uBAAA,EAAyB,cAAA;AAAA,IACzB,eAAeA,OAAAA,EAAQ;AACnB,MAAA,OAAO,UAAA,CAAW,eAAeA,OAAM,CAAA;AAAA,IAC3C,CAAA;AAAA,IACA,kBAAkB,WAAA,EAAa;AAC3B,MAAA,MAAM,cAAA,GAAiB,QAAA,GAAW,WAAW,CAAA,IAAK,EAAC;AACnD,MAAA,OAAO,iBAAA,CAAkB,QAAQ,cAAc,CAAA;AAAA,IACnD;AAAA,GACJ;AACJ;;;;"}
|
package/i18n/PackageIntl.js.map
CHANGED
|
@@ -1 +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 { Children, createElement, Fragment, isValidElement, ReactNode } 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 chunks: any = intl.formatMessage(descriptor, preprocessValues(values) as any, opts);\n const nodes = assignKeys(chunks);\n return createElement(Fragment, undefined, ...nodes);\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) => valueOrFn(assignKeys(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 required to get rid of \"key\" warnings.\n// See https://github.com/formatjs/formatjs/pull/4895/files\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction assignKeys(chunks: any): any[] {\n const nodes = Children.map(chunks, assignKey) ?? [];\n return Children.toArray(nodes);\n}\n\nconst ANY_KEY = { key: 42 };\n\nfunction assignKey(reactNode: React.ReactNode) {\n return isValidElement(reactNode) ? createElement(Fragment, ANY_KEY, reactNode) : reactNode;\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":";;;
|
|
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 { Children, createElement, Fragment, isValidElement, ReactNode } 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 chunks: any = intl.formatMessage(descriptor, preprocessValues(values) as any, opts);\n const nodes = assignKeys(chunks);\n return createElement(Fragment, undefined, ...nodes);\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) => valueOrFn(assignKeys(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 required to get rid of \"key\" warnings.\n// See https://github.com/formatjs/formatjs/pull/4895/files\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction assignKeys(chunks: any): any[] {\n const nodes = Children.map(chunks, assignKey) ?? [];\n return Children.toArray(nodes);\n}\n\nconst ANY_KEY = { key: 42 };\n\nfunction assignKey(reactNode: React.ReactNode) {\n return isValidElement(reactNode) ? createElement(Fragment, ANY_KEY, reactNode) : reactNode;\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":";;;AAyHO,SAAS,iBAAA,CACZ,MAAA,EACA,QAAA,EACA,OAAA,EAOW;AACX,EAAA,MAAM,QAAQ,eAAA,EAAgB;AAC9B,EAAA,MAAM,MAAA,GAAqB;AAAA,IACvB,MAAA;AAAA,IACA;AAAA,GACJ;AACA,EAAA,IAAI,SAAS,qBAAA,EAAuB;AAChC,IAAA,MAAA,CAAO,OAAA,GAAU,6BAAA;AAAA,EACrB;AACA,EAAA,IAAI,SAAS,aAAA,EAAe;AACxB,IAAA,MAAA,CAAO,gBAAgB,OAAA,CAAQ,aAAA;AAAA,EACnC;AAEA,EAAA,MAAM,IAAA,GAAO,UAAA,CAAW,MAAA,EAAQ,KAAK,CAAA;AACrC,EAAA,IAAA,CAAK,iBAAA,GAAoB,iBAAA,CAAkB,IAAA,CAAK,MAAA,EAAW,IAAI,CAAA;AAC/D,EAAA,OAAO,IAAA;AACX;AAGO,SAAS,sBAAA,CAAuB,SAAS,IAAA,EAAmB;AAC/D,EAAA,OAAO,iBAAA,CAAkB,MAAA,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AAA,OAAO,SAAS,cAAc,KAAA,EAAO;AACjC,IAAA,OAAO,aAAA,CAAc,GAAA,EAAK,MAAA,EAAW,GAAG,KAAK,CAAA;AAAA,EACjD,CAAA;AACJ;AAKA,SAAS,WAAW,MAAA,EAAoB;AACpC,EAAA,MAAM,QAAQ,QAAA,CAAS,GAAA,CAAI,MAAA,EAAQ,SAAS,KAAK,EAAC;AAClD,EAAA,OAAO,QAAA,CAAS,QAAQ,KAAK,CAAA;AACjC;AAEA,MAAM,OAAA,GAAU,EAAE,GAAA,EAAK,EAAA,EAAG;AAE1B,SAAS,UAAU,SAAA,EAA4B;AAC3C,EAAA,OAAO,eAAe,SAAS,CAAA,GAAI,cAAc,QAAA,EAAU,OAAA,EAAS,SAAS,CAAA,GAAI,SAAA;AACrF;AAGA,MAAM,6BAAA,GAA2C,CAAC,GAAA,KAAQ;AACtD,EAAA,IAAI,GAAA,CAAI,IAAA,KAAS,aAAA,CAAc,mBAAA,EAAqB;AAChD,IAAA;AAAA,EACJ;AAEA,EAAA,OAAA,CAAQ,MAAM,GAAG,CAAA;AACrB,CAAA;;;;"}
|
package/i18n/pick.js.map
CHANGED
|
@@ -1 +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,
|
|
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,UAAA,CAAW;AAAA,EACZ,UAAA;AAAA;AAAA;AAAA;AAAA,EAKR,YAAY,UAAA,EAAsB;AAC9B,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,mBAAA,CAAoB,cAAkC,WAAA,EAAyC;AAC3F,IAAA,MAAM,EAAE,YAAW,GAAI,IAAA;AAEvB,IAAA,IAAI,YAAA,EAAc;AACd,MAAA,MAAM,MAAA,GAAS,IAAA,CAAK,QAAA,CAAS,CAAC,YAAY,CAAC,CAAA;AAC3C,MAAA,IAAI,CAAC,MAAA,EAAQ;AACT,QAAA,MAAM,WAAA,GAAc,UAAA,CAAW,IAAA,CAAK,IAAI,CAAA;AACxC,QAAA,MAAM,IAAI,KAAA;AAAA,UACN,OAAA,CAAQ,kBAAA;AAAA,UACR,CAAA,QAAA,EAAW,YAAY,CAAA,yFAAA,EACO,WAAW,CAAA,CAAA;AAAA,SAC7C;AAAA,MACJ;AACA,MAAA,IAAI,MAAA,CAAO,MAAA,KAAW,MAAA,CAAO,aAAA,EAAe;AACxC,QAAA,GAAA,CAAI,IAAA;AAAA,UACA,CAAA,mCAAA,EAAsC,YAAY,CAAA,wBAAA,EAA2B,MAAA,CAAO,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,CAAU,SAAS,CAAA;AAAA,EAChD;AACA,EAAA,OAAO,CAAC,MAAA,CAAO,SAAA,CAAU,QAAQ,CAAA;AACrC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableBox.js","sources":["ObservableBox.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { EventEmitter, Resource } from \"@open-pioneer/core\";\n\nexport interface ObservableBox<T> {\n /** The current value. */\n readonly value: T;\n\n /**\n * Changes the current value.\n *\n * Note that this function is only present during development to facilitate hot reloading.\n */\n setValue?(value: T): void;\n\n /**\n * Register a listener callback that will be invoked\n * when the value changes.\n *\n * Note that this function is only present during development to facilitate hot reloading.\n */\n on?(event: \"changed\", listener: () => void): Resource;\n}\n\n/**\n * Returns a boxed value.\n * In development node, the box value can be changed and observed.\n */\nexport function createBox<T>(value: T): ObservableBox<T> {\n if (import.meta.env.DEV) {\n return new BoxImpl(value);\n } else {\n return {\n value\n };\n }\n}\n\nclass BoxImpl<T> extends EventEmitter<{ changed: void }> implements Required<ObservableBox<T>> {\n value: T;\n\n constructor(value: T) {\n super();\n this.value = value;\n }\n\n setValue(value: T): void {\n this.value = value;\n this.emit(\"changed\");\n }\n}\n"],"names":[],"mappings":";;AA4BO,SAAS,UAAa,
|
|
1
|
+
{"version":3,"file":"ObservableBox.js","sources":["ObservableBox.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { EventEmitter, Resource } from \"@open-pioneer/core\";\n\nexport interface ObservableBox<T> {\n /** The current value. */\n readonly value: T;\n\n /**\n * Changes the current value.\n *\n * Note that this function is only present during development to facilitate hot reloading.\n */\n setValue?(value: T): void;\n\n /**\n * Register a listener callback that will be invoked\n * when the value changes.\n *\n * Note that this function is only present during development to facilitate hot reloading.\n */\n on?(event: \"changed\", listener: () => void): Resource;\n}\n\n/**\n * Returns a boxed value.\n * In development node, the box value can be changed and observed.\n */\nexport function createBox<T>(value: T): ObservableBox<T> {\n if (import.meta.env.DEV) {\n return new BoxImpl(value);\n } else {\n return {\n value\n };\n }\n}\n\nclass BoxImpl<T> extends EventEmitter<{ changed: void }> implements Required<ObservableBox<T>> {\n value: T;\n\n constructor(value: T) {\n super();\n this.value = value;\n }\n\n setValue(value: T): void {\n this.value = value;\n this.emit(\"changed\");\n }\n}\n"],"names":[],"mappings":";;AA4BO,SAAS,UAAa,KAAA,EAA4B;AACrD,EAAA,IAAI,MAAA,CAAA,IAAA,CAAY,IAAI,GAAA,EAAK;AACrB,IAAA,OAAO,IAAI,QAAQ,KAAK,CAAA;AAAA,EAC5B,CAAA,MAAO;AACH,IAAA,OAAO;AAAA,MACH;AAAA,KACJ;AAAA,EACJ;AACJ;AAEA,MAAM,gBAAmB,YAAA,CAAsE;AAAA,EAC3F,KAAA;AAAA,EAEA,YAAY,KAAA,EAAU;AAClB,IAAA,KAAA,EAAM;AACN,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACjB;AAAA,EAEA,SAAS,KAAA,EAAgB;AACrB,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AACb,IAAA,IAAA,CAAK,KAAK,SAAS,CAAA;AAAA,EACvB;AACJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/runtime",
|
|
4
|
-
"version": "4.1.0-dev.
|
|
4
|
+
"version": "4.1.0-dev.20250818132109",
|
|
5
5
|
"description": "Implements the runtime environment for Open Pioneer Trails apps.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@conterra/reactivity-core": "^0.7.0",
|
|
18
18
|
"@formatjs/intl": "^3.1.6",
|
|
19
|
-
"@chakra-ui/react": "^3.
|
|
19
|
+
"@chakra-ui/react": "^3.24.2",
|
|
20
20
|
"@emotion/cache": "^11.14.0",
|
|
21
21
|
"@emotion/react": "^11.14.0",
|
|
22
|
-
"react": "^19.1.
|
|
23
|
-
"react-dom": "^19.1.
|
|
24
|
-
"@open-pioneer/
|
|
25
|
-
"@open-pioneer/
|
|
26
|
-
"@open-pioneer/core": "4.1.0-dev.
|
|
22
|
+
"react": "^19.1.1",
|
|
23
|
+
"react-dom": "^19.1.1",
|
|
24
|
+
"@open-pioneer/reactivity": "4.1.0-dev.20250818132109",
|
|
25
|
+
"@open-pioneer/base-theme": "4.1.0-dev.20250818132109",
|
|
26
|
+
"@open-pioneer/core": "4.1.0-dev.20250818132109"
|
|
27
27
|
},
|
|
28
28
|
"exports": {
|
|
29
29
|
"./package.json": "./package.json",
|