@open-pioneer/runtime 4.5.0-dev.20260225121659 → 4.5.0-dev.20260303103629

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,9 +1,16 @@
1
1
  # @open-pioneer/runtime
2
2
 
3
- ## 4.5.0-dev.20260225121659
3
+ ## 4.5.0-dev.20260303103629
4
4
 
5
5
  ### Minor Changes
6
6
 
7
+ - 89d743b: Provide `runtime.ThemeService`:
8
+ - Supports switching between color modes `light` and `dark`.
9
+ - Supports changing the chakra theme ("systemConfig") at runtime.
10
+ - Supports reactive access to the preferred (system) color mode.
11
+
12
+ - 89d743b: Support for color modes (light and dark).
13
+ The default color mode remains `light` for backwards compatibility.
7
14
  - 94b0cca: API initialization does no longer block rendering of the user interface.
8
15
  - 4e76893: Update Chakra UI to 3.32.0
9
16
  - c866e13: createCustomElement: Add support for configuration of `chakraSystemConfig` in `config` and `resolveConfig`.
@@ -11,10 +18,11 @@
11
18
 
12
19
  ### Patch Changes
13
20
 
21
+ - Updated dependencies [89d743b]
14
22
  - Updated dependencies [4e76893]
15
- - @open-pioneer/base-theme@4.5.0-dev.20260225121659
16
- - @open-pioneer/core@4.5.0-dev.20260225121659
17
- - @open-pioneer/reactivity@4.5.0-dev.20260225121659
23
+ - @open-pioneer/base-theme@4.5.0-dev.20260303103629
24
+ - @open-pioneer/core@4.5.0-dev.20260303103629
25
+ - @open-pioneer/reactivity@4.5.0-dev.20260303103629
18
26
 
19
27
  ## 4.4.0
20
28
 
@@ -1,6 +1,6 @@
1
1
  import { SystemConfig as ChakraSystemConfig } from "@chakra-ui/react";
2
2
  import { ComponentType } from "react";
3
- import { ApiMethods } from "./api";
3
+ import { type ApiMethods, type ColorModeValue } from "./api";
4
4
  import { ApplicationMetadata } from "./metadata";
5
5
  /**
6
6
  * Options for the {@link createCustomElement} function.
@@ -70,6 +70,14 @@ export interface ApplicationOverrides {
70
70
  * The new application locale.
71
71
  */
72
72
  locale?: string;
73
+ /**
74
+ * The new color mode.
75
+ */
76
+ colorMode?: ColorModeValue | "system";
77
+ /**
78
+ * The new used chakra system config.
79
+ */
80
+ chakraSystemConfig?: ChakraSystemConfig;
73
81
  }
74
82
  /**
75
83
  * Runtime application configuration.
@@ -83,6 +91,14 @@ export interface ApplicationConfig {
83
91
  * The locale must be supported by the application.
84
92
  */
85
93
  locale?: string | undefined;
94
+ /**
95
+ * Configures the application's initial color mode.
96
+ *
97
+ * Use `system` to use the user's preferred color mode, derived from the browser or operating system.
98
+ *
99
+ * Default: `light`.
100
+ */
101
+ colorMode?: ColorModeValue | "system";
86
102
  /**
87
103
  * Properties specified here will override default properties of the application's packages.
88
104
  */
package/CustomElement.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createLogger, Error } from '@open-pioneer/core';
2
- import { sourceId } from './_virtual/source-info.js';
2
+ import { sourceId$6 as sourceId } from './_virtual/source-info.js';
3
3
  import { AppInstance } from './app/AppInstance.js';
4
4
  import { ErrorId } from './errors.js';
5
5
 
@@ -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 { sourceId } from \"open-pioneer:source-info\";\nimport { ComponentType } from \"react\";\nimport { ApiMethods, type ApiExtension } from \"./api\";\nimport { AppInstance } from \"./app\";\nimport { ErrorId } from \"./errors\";\nimport { ApplicationMetadata } from \"./metadata\";\n\nconst LOG = createLogger(sourceId);\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 * Defined when the application forcefully restarts with new options.\n */\n overrides: ApplicationOverrides | undefined;\n\n /**\n * Returns an attribute from the application's root node.\n */\n getAttribute(name: string): string | undefined;\n}\n\n/**\n * Application overrides are defined when the is explicitly being restarted with new options.\n *\n * Options set through overrides cannot be overwritten by the `resolveConfig` hook.\n */\nexport interface ApplicationOverrides {\n /**\n * The new application locale.\n */\n locale?: string;\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 * Chakra styled system object.\n *\n * Used to configure chakra's theme.\n *\n * NOTE: This setting has priority over {@link CustomElementOptions.chakraSystemConfig}.\n */\n chakraSystemConfig?: ChakraSystemConfig;\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?: ApplicationOverrides) {\n // Defer the restart operation a tiny bit so calling code does not get surprised by the application's destruction.\n if (this.#deferredRestart) {\n clearTimeout(this.#deferredRestart);\n }\n this.#deferredRestart = setTimeout(() => {\n if (!this.#instance) {\n // disconnectedCallback was called in the meantime\n return;\n }\n\n LOG.debug(\"Restarting application with new options\", overrides);\n this.#instance.destroy();\n this.#instance = this.#createApplicationInstance(overrides);\n this.#instance.start();\n }, 1);\n }\n\n #createApplicationInstance(overrides?: ApplicationOverrides) {\n return new 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":";;;;;AAWA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAsL1B,SAAS,oBAAoB,OAAA,EAA8D;AAAA,EAC9F,MAAM,2BAA2B,WAAA,CAA0C;AA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AAI,CAAC,KAAK,SAAA,EAAW;AACjB,QAAA,OAAO,OAAA,CAAQ,MAAA;AAAA,UACX,IAAI,KAAA;AAAA,YACA,OAAA,CAAQ,WAAA;AAAA,YACR;AAAA;AACJ,SACJ;AAAA,MACJ;AAEA,MAAA,OAAO,IAAA,CAAK,UAAU,OAAA,EAAQ;AAAA,IAClC;AAAA,IAEA,eAAe,SAAA,EAAkC;AAE7C,MAAA,IAAI,KAAK,gBAAA,EAAkB;AACvB,QAAA,YAAA,CAAa,KAAK,gBAAgB,CAAA;AAAA,MACtC;AACA,MAAA,IAAA,CAAK,gBAAA,GAAmB,WAAW,MAAM;AACrC,QAAA,IAAI,CAAC,KAAK,SAAA,EAAW;AAEjB,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,EAAkC;AACzD,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;;;;"}
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 { sourceId } from \"open-pioneer:source-info\";\nimport { ComponentType } from \"react\";\nimport { type ApiMethods, type ColorModeValue, type ApiExtension } from \"./api\";\nimport { AppInstance } from \"./app\";\nimport { ErrorId } from \"./errors\";\nimport { ApplicationMetadata } from \"./metadata\";\n\nconst LOG = createLogger(sourceId);\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 * Defined when the application forcefully restarts with new options.\n */\n overrides: ApplicationOverrides | undefined;\n\n /**\n * Returns an attribute from the application's root node.\n */\n getAttribute(name: string): string | undefined;\n}\n\n/**\n * Application overrides are defined when the is explicitly being restarted with new options.\n *\n * Options set through overrides cannot be overwritten by the `resolveConfig` hook.\n */\nexport interface ApplicationOverrides {\n /**\n * The new application locale.\n */\n locale?: string;\n\n /**\n * The new color mode.\n */\n colorMode?: ColorModeValue | \"system\";\n\n /**\n * The new used chakra system config.\n */\n chakraSystemConfig?: ChakraSystemConfig;\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 * Configures the application's initial color mode.\n *\n * Use `system` to use the user's preferred color mode, derived from the browser or operating system.\n *\n * Default: `light`.\n */\n colorMode?: ColorModeValue | \"system\";\n\n /**\n * Properties specified here will override default properties of the application's packages.\n */\n properties?: ApplicationProperties | undefined;\n\n /**\n * Chakra styled system object.\n *\n * Used to configure chakra's theme.\n *\n * NOTE: This setting has priority over {@link CustomElementOptions.chakraSystemConfig}.\n */\n chakraSystemConfig?: ChakraSystemConfig;\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?: ApplicationOverrides) {\n // Defer the restart operation a tiny bit so calling code does not get surprised by the application's destruction.\n if (this.#deferredRestart) {\n clearTimeout(this.#deferredRestart);\n }\n this.#deferredRestart = setTimeout(() => {\n if (!this.#instance) {\n // disconnectedCallback was called in the meantime\n return;\n }\n\n LOG.debug(\"Restarting application with new options\", overrides);\n this.#instance.destroy();\n this.#instance = this.#createApplicationInstance(overrides);\n this.#instance.start();\n }, 1);\n }\n\n #createApplicationInstance(overrides?: ApplicationOverrides) {\n return new 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":";;;;;AAWA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAyM1B,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,iDAAiD,CAAA;AAAA,MAC/D;AAEA,MAAA,IAAI,MAAA,CAAA,IAAA,CAAY,IAAI,GAAA,EAAK;AAErB,QAAC,IAAA,CAAa,oBAAA,GAAuB,MAAM,IAAA,CAAK,SAAA;AAAA,MACpD;AAAA,IACJ;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K,0BAAA,CAA2B,SAAS,CAAA;AAC1D,QAAA,IAAA,CAAK,UAAU,KAAA,EAAM;AAAA,MACzB,GAAG,CAAC,CAAA;AAAA,IACR;AAAA,IAEA,2BAA2B,SAAA,EAAkC;AACzD,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;;;;"}
@@ -12,5 +12,5 @@ const sourceId$1 = "@open-pioneer/runtime/builtin-services/NumberParserServiceIm
12
12
 
13
13
  const sourceId = "@open-pioneer/runtime/service-layer/ServiceLayer";
14
14
 
15
- export { sourceId$6 as sourceId, sourceId$5 as sourceId$1, sourceId$2, sourceId$1 as sourceId$3, sourceId$4, sourceId$3 as sourceId$5, sourceId as sourceId$6 };
15
+ export { sourceId$3 as sourceId, sourceId$4 as sourceId$1, sourceId$2, sourceId$1 as sourceId$3, sourceId as sourceId$4, sourceId$5, sourceId$6 };
16
16
  //# sourceMappingURL=source-info.js.map
package/api.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { DeclaredService } from "./DeclaredService";
1
+ import { type SystemConfig as ChakraSystemConfig } from "@chakra-ui/react";
2
+ import { type DeclaredService } from "./DeclaredService";
2
3
  export type ApiMethod = (...args: any[]) => any;
3
4
  /**
4
5
  * A record of exposed functions.
@@ -116,3 +117,51 @@ export interface NumberParserService extends DeclaredService<"runtime.NumberPars
116
117
  */
117
118
  parseNumber(numberString: string): number;
118
119
  }
120
+ /**
121
+ * A color mode value, either "light" or "dark".
122
+ */
123
+ export type ColorModeValue = "light" | "dark";
124
+ /**
125
+ * A function that returns a ColorModeValue.
126
+ * If it uses a reactive value internally, the ThemeService will react to changes of the color mode.
127
+ */
128
+ export type ColorModeValueSupplier = () => ColorModeValue;
129
+ /**
130
+ * A function that returns a SystemConfig.
131
+ * If it uses a reactive value internally, the ThemeService will react to changes of the system config.
132
+ */
133
+ export type ChakraSystemConfigSupplier = () => ChakraSystemConfig | undefined;
134
+ /**
135
+ * A Theme Service that provides methods to interact with the chakra theme.
136
+ *
137
+ * e.g. change the color mode of the application.
138
+ * or update the system config of the application.
139
+ */
140
+ export interface ThemeService extends DeclaredService<"runtime.ThemeService"> {
141
+ /**
142
+ * The color mode preferred by the system (browser or operating system).
143
+ */
144
+ readonly systemColorMode: ColorModeValue;
145
+ /**
146
+ * The currently active color mode.
147
+ * It is reactive.
148
+ * Defaults to `"light".
149
+ */
150
+ readonly colorMode: ColorModeValue;
151
+ /**
152
+ * Updates the color mode of the application.
153
+ * Can be called with a direct value or a function that returns a value.
154
+ * The function form allows the use of reactive values, which will automatically trigger a color mode update.
155
+ */
156
+ setColorMode(value: ColorModeValue | ColorModeValueSupplier): void;
157
+ /**
158
+ * The currently active system config.
159
+ */
160
+ readonly systemConfig: ChakraSystemConfig | undefined;
161
+ /**
162
+ * Updates the system config of the application.
163
+ * Can be called with a direct value or a function that returns a value.
164
+ * The function form allows the use of reactive values, which will automatically trigger a system config update.
165
+ */
166
+ setSystemConfig(value: ChakraSystemConfig | ChakraSystemConfigSupplier | undefined): void;
167
+ }
@@ -28,6 +28,7 @@ export declare class AppInstance {
28
28
  private config;
29
29
  private serviceLayer;
30
30
  private lifecycleEvents;
31
+ private themeService;
31
32
  private reactIntegration;
32
33
  private stylesWatch;
33
34
  constructor(options: AppOptions);
@@ -1,8 +1,9 @@
1
- import { reactive, effect } from '@conterra/reactivity-core';
1
+ import { computed, reactive, effect } from '@conterra/reactivity-core';
2
2
  import { createLogger, Error, createAbortError, destroyResource, createManualPromise, throwAbortError } from '@open-pioneer/core';
3
- import { sourceId$1 as sourceId } from '../_virtual/source-info.js';
3
+ import { sourceId$5 as sourceId } from '../_virtual/source-info.js';
4
4
  import { createElement } from 'react';
5
- import { createBuiltinPackage, RUNTIME_API_SERVICE, RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE, RUNTIME_AUTO_START } from '../builtin-services/index.js';
5
+ import { createBuiltinPackage, RUNTIME_THEME_SERVICE, RUNTIME_API_SERVICE, RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE, RUNTIME_AUTO_START } from '../builtin-services/index.js';
6
+ import { DEFAULT_INITIAL_COLOR_MODE } from '../builtin-services/ThemeServiceImpl.js';
6
7
  import { isShadowRoot, createAppRoot } from '../dom/index.js';
7
8
  import { ErrorId } from '../errors.js';
8
9
  import { initI18n } from '../i18n/AppIntl.js';
@@ -32,6 +33,7 @@ class AppInstance {
32
33
  config;
33
34
  serviceLayer;
34
35
  lifecycleEvents;
36
+ themeService;
35
37
  reactIntegration;
36
38
  stylesWatch;
37
39
  constructor(options) {
@@ -71,6 +73,7 @@ class AppInstance {
71
73
  this.container.replaceChildren();
72
74
  this.appRoot = void 0;
73
75
  this.lifecycleEvents = void 0;
76
+ this.themeService = void 0;
74
77
  this.serviceLayer = destroyResource(this.serviceLayer);
75
78
  this.stylesWatch = destroyResource(this.stylesWatch);
76
79
  }
@@ -95,15 +98,20 @@ class AppInstance {
95
98
  const { serviceLayer, packages } = this.initServiceLayer({
96
99
  container: appRoot,
97
100
  properties: config.properties,
98
- i18n
101
+ i18n,
102
+ initialColorMode: config.colorMode,
103
+ initialSystemConfig: config.chakraSystemConfig
99
104
  });
100
105
  this.lifecycleEvents = getInternalService(
101
106
  serviceLayer,
102
107
  RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE
103
108
  );
109
+ const themeService = this.themeService = getInternalService(
110
+ serviceLayer,
111
+ RUNTIME_THEME_SERVICE
112
+ );
104
113
  const apiPromise = this.initAPI(serviceLayer);
105
114
  this.checkAbort();
106
- const chakraSystemConfig = config.chakraSystemConfig ?? elementOptions.chakraSystemConfig;
107
115
  this.reactIntegration = ReactIntegration.createForApp({
108
116
  rootNode: root,
109
117
  hostNode: hostElement,
@@ -111,8 +119,9 @@ class AppInstance {
111
119
  serviceLayer,
112
120
  packages,
113
121
  locale: i18n.locale,
114
- config: chakraSystemConfig,
115
- styles
122
+ config: computed(() => themeService.systemConfig),
123
+ styles,
124
+ colorMode: computed(() => themeService.colorMode)
116
125
  });
117
126
  const component = this.options.elementOptions.component ?? EmptyComponent;
118
127
  this.reactIntegration.render(createElement(component));
@@ -146,25 +155,29 @@ class AppInstance {
146
155
  }
147
156
  initServiceLayer(config) {
148
157
  const { hostElement, rootNode: shadowRoot, elementOptions, restart } = this.options;
149
- const { container, properties, i18n } = config;
158
+ const { container, properties, i18n, initialColorMode, initialSystemConfig } = config;
150
159
  const packageMetadata = elementOptions.appMetadata?.packages ?? {};
151
160
  const builtinPackage = createBuiltinPackage({
152
161
  host: hostElement,
153
162
  rootNode: shadowRoot,
154
163
  container,
164
+ initialColorMode,
165
+ initialSystemConfig,
155
166
  locale: i18n.locale,
156
167
  supportedLocales: i18n.supportedMessageLocales,
157
- changeLocale(locale) {
168
+ changeLocale: (locale) => {
158
169
  const supported = i18n.supportedMessageLocales;
159
170
  if (locale != null && !i18n.supportsLocale(locale)) {
171
+ const supportedLocales = supported.join(", ");
160
172
  throw new Error(
161
173
  ErrorId.UNSUPPORTED_LOCALE,
162
- `Unsupported locale '${locale}' (supported locales: ${supported.join(
163
- ", "
164
- )}).`
174
+ `Unsupported locale '${locale}' (supported locales: ${supportedLocales}).`
165
175
  );
166
176
  }
167
- restart({ locale });
177
+ const themeService = this.themeService;
178
+ const colorMode = themeService?.colorMode;
179
+ const chakraSystemConfig = themeService?.systemConfig;
180
+ restart({ locale, colorMode, chakraSystemConfig });
168
181
  }
169
182
  });
170
183
  const { serviceLayer, packages } = createServiceLayer({
@@ -228,8 +241,9 @@ class AppInstance {
228
241
  hostNode: this.options.hostElement,
229
242
  appRoot,
230
243
  locale,
231
- config: this.options.elementOptions.chakraSystemConfig,
232
- styles
244
+ config: reactive(this.options.elementOptions.chakraSystemConfig),
245
+ styles,
246
+ colorMode: reactive(DEFAULT_INITIAL_COLOR_MODE)
233
247
  });
234
248
  this.reactIntegration.render(createElement(ErrorScreen, { intl, error }));
235
249
  }
@@ -258,6 +272,9 @@ function createServiceLayer(config) {
258
272
  {
259
273
  interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE
260
274
  },
275
+ {
276
+ interfaceName: RUNTIME_THEME_SERVICE
277
+ },
261
278
  {
262
279
  interfaceName: RUNTIME_AUTO_START,
263
280
  all: true
@@ -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 { effect, 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 { sourceId } from \"open-pioneer:source-info\";\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 {\n ApplicationConfig,\n ApplicationOverrides,\n ApplicationProperties,\n CustomElementOptions\n} 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(sourceId);\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: ApplicationOverrides | undefined;\n\n /**\n * A callback to restart the application with new options.\n * Currently only used for reloading with a certain locale.\n */\n restart: (overrides?: ApplicationOverrides) => void;\n}\n\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 // init api, but do not wait for it\n const apiPromise = this.initAPI(serviceLayer);\n this.checkAbort();\n\n // Launch react\n const chakraSystemConfig = config.chakraSystemConfig ?? elementOptions.chakraSystemConfig;\n this.reactIntegration = ReactIntegration.createForApp({\n rootNode: root,\n hostNode: hostElement,\n appRoot: appRoot,\n serviceLayer,\n packages,\n locale: i18n.locale,\n config: chakraSystemConfig,\n styles\n });\n const component = this.options.elementOptions.component ?? EmptyComponent;\n this.reactIntegration.render(createElement(component));\n\n // wait for api, to ensure that the \"started\" state is only reached after the API is available.\n // but do not block the react rendering, to allow for a fast Time to Interactive and to show potential errors in the UI even if the API fails.\n await apiPromise;\n this.checkAbort();\n\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 = effect(\n () => {\n signal.value = stylesBox.value;\n LOG.debug(\"Application styles changed\");\n },\n { dispatch: \"sync\" }\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 = await apiService.getApi();\n this.checkAbort();\n this.api = api;\n LOG.debug(\"Application API initialized to\", api);\n this.apiPromise?.resolve(api);\n } catch (e) {\n const ex = new Error(\n ErrorId.INTERNAL,\n \"Failed to gather the application's API methods.\",\n {\n cause: e\n }\n );\n if (!this.apiPromise) {\n // no one is waiting yet.\n // keep the error for when they do\n this.apiPromise = createManualPromise();\n // prevent unhandled rejection if no one is waiting for the API\n this.apiPromise.promise.catch(() => {});\n }\n this.apiPromise.reject(ex);\n throw ex;\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":";;;;;;;;;;;;;;;;;AAyCA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAwB1B,MAAM,WAAA,CAAY;AAAA,EACb,OAAA;AAAA;AAAA,EAGA,UAAA;AAAA;AAAA,EACA,GAAA;AAAA;AAAA,EAEA,KAAA,GAAkB,aAAA;AAAA,EAClB,QAAA;AAAA,EACA,SAAA;AAAA;AAAA,EACA,OAAA;AAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EAEA,WAAA;AAAA,EAER,YAAY,OAAA,EAAqB;AAC7B,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AACf,IAAA,IAAA,CAAK,YAAY,YAAA,CAAa,OAAA,CAAQ,QAAQ,CAAA,GAAI,OAAA,CAAQ,WAAW,OA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AAA,CAAgC,cAA4B,aAAA,EAAuB;AACxF,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;;;;"}
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 { computed, effect, 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 { sourceId } from \"open-pioneer:source-info\";\nimport { createElement } from \"react\";\nimport { ApiMethods, ApiService, ColorModeValue, ThemeService } from \"../api\";\nimport {\n createBuiltinPackage,\n RUNTIME_API_SERVICE,\n RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE,\n RUNTIME_AUTO_START,\n RUNTIME_THEME_SERVICE\n} from \"../builtin-services\";\nimport { ApplicationLifecycleEventService } from \"../builtin-services/ApplicationLifecycleEventService\";\nimport { DEFAULT_INITIAL_COLOR_MODE } from \"../builtin-services/ThemeServiceImpl\";\nimport {\n ApplicationConfig,\n ApplicationOverrides,\n ApplicationProperties,\n CustomElementOptions\n} 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\";\n\nimport { SystemConfig } from \"@chakra-ui/react\";\nimport { logError } from \"./logErrors\";\n\nconst LOG = createLogger(sourceId);\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: ApplicationOverrides | undefined;\n\n /**\n * A callback to restart the application with new options.\n * Currently only used for reloading with a certain locale.\n */\n restart: (overrides?: ApplicationOverrides) => void;\n}\n\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 themeService: ThemeService | 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.themeService = 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 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 initialColorMode: config.colorMode,\n initialSystemConfig: config.chakraSystemConfig\n });\n this.lifecycleEvents = getInternalService<ApplicationLifecycleEventService>(\n serviceLayer,\n RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE\n );\n const themeService = (this.themeService = getInternalService<ThemeService>(\n serviceLayer,\n RUNTIME_THEME_SERVICE\n ));\n\n // init api, but do not wait for it\n const apiPromise = 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: computed(() => themeService.systemConfig),\n styles,\n colorMode: computed(() => themeService.colorMode)\n });\n const component = this.options.elementOptions.component ?? EmptyComponent;\n this.reactIntegration.render(createElement(component));\n\n // wait for api, to ensure that the \"started\" state is only reached after the API is available.\n // but do not block the react rendering, to allow for a fast Time to Interactive and to show potential errors in the UI even if the API fails.\n await apiPromise;\n this.checkAbort();\n\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 = effect(\n () => {\n signal.value = stylesBox.value;\n LOG.debug(\"Application styles changed\");\n },\n { dispatch: \"sync\" }\n );\n }\n return signal;\n }\n\n private initServiceLayer(config: {\n container: HTMLDivElement;\n properties: ApplicationProperties;\n i18n: AppIntl;\n initialColorMode: ColorModeValue | \"system\" | undefined;\n initialSystemConfig: SystemConfig | undefined;\n }) {\n const { hostElement, rootNode: shadowRoot, elementOptions, restart } = this.options;\n\n const { container, properties, i18n, initialColorMode, initialSystemConfig } = config;\n const packageMetadata = elementOptions.appMetadata?.packages ?? {};\n const builtinPackage = createBuiltinPackage({\n host: hostElement,\n rootNode: shadowRoot,\n container: container,\n initialColorMode,\n initialSystemConfig,\n locale: i18n.locale,\n supportedLocales: i18n.supportedMessageLocales,\n changeLocale: (locale) => {\n const supported = i18n.supportedMessageLocales;\n if (locale != null && !i18n.supportsLocale(locale)) {\n const supportedLocales = supported.join(\", \");\n throw new Error(\n ErrorId.UNSUPPORTED_LOCALE,\n `Unsupported locale '${locale}' (supported locales: ${supportedLocales}).`\n );\n }\n\n const themeService = this.themeService;\n const colorMode = themeService?.colorMode;\n const chakraSystemConfig = themeService?.systemConfig;\n restart({ locale, colorMode, chakraSystemConfig });\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 = await apiService.getApi();\n this.checkAbort();\n this.api = api;\n LOG.debug(\"Application API initialized to\", api);\n this.apiPromise?.resolve(api);\n } catch (e) {\n const ex = new Error(\n ErrorId.INTERNAL,\n \"Failed to gather the application's API methods.\",\n {\n cause: e\n }\n );\n if (!this.apiPromise) {\n // no one is waiting yet.\n // keep the error for when they do\n this.apiPromise = createManualPromise();\n // prevent unhandled rejection if no one is waiting for the API\n this.apiPromise.promise.catch(() => {});\n }\n this.apiPromise.reject(ex);\n throw ex;\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: reactive(this.options.elementOptions.chakraSystemConfig),\n styles,\n colorMode: reactive(DEFAULT_INITIAL_COLOR_MODE)\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_THEME_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":";;;;;;;;;;;;;;;;;;AA6CA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAwB1B,MAAM,WAAA,CAAY;AAAA,EACb,OAAA;AAAA;AAAA,EAGA,UAAA;AAAA;AAAA,EACA,GAAA;AAAA;AAAA,EAEA,KAAA,GAAkB,aAAA;AAAA,EAClB,QAAA;AAAA,EACA,SAAA;AAAA;AAAA,EACA,OAAA;AAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EACA,gBAAA;AAAA,EAEA,WAAA;AAAA,EAER,YAAY,OAAA,EAAqB;AAC7B,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AACf,IAAA,IAAA,CAAK,YAAY,YAAA,CAAa,OAAA,CAAQ,QAAQ,CAAA,GAAI,OAAA,CAAQ,WAAW,OAAA,CAAQ,WAAA;AAC7E,IAAA,IAAA,CAAK,WAAW,OAAA,CAAQ,QAAA;AAAA,EAC5B;AAAA,EAEA,KAAA,GAAQ;AACJ,IAAA,IAAI,IAAA,CAAK,UAAU,aAAA,EAAe;AAC9B,MAAA,MAAM,IAAI,KAAA,CAAM,OAAA,CAAQ,UAAU,CAAA,+BAAA,EAAkC,IAAA,CAAK,KAAK,CAAA,CAAA,CAAG,CAAA;AAAA,IACrF;AAEA,IAAA,IAAA,CAAK,KAAA,GAAQ,UAAA;AACb,IAAA,IAAA,CAAK,SAAA,EAAU,CAAE,KAAA,CAAM,CAAC,CAAA,KAAM;AAC1B,MAAA,IAAI,IAAA,CAAK,UAAU,WAAA,EAAa;AAEhC,MAAA,QAAA,CAAS,CAAC,CAAA;AACV,MAAA,IAAA,CAAK,KAAA,EAAM;AACX,MAAA,IAAA,CAAK,KAAA,GAAQ,OAAA;AACb,MAAA,IAAA,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,IACxD;AAAA,GACJ;AACJ;AAEA,SAAS,kBAAA,CAAgC,cAA4B,aAAA,EAAuB;AACxF,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;;;;"}
@@ -12,7 +12,13 @@ async function gatherConfig(hostElement, options, overrides) {
12
12
  },
13
13
  overrides
14
14
  }) ?? {};
15
- configs = [staticConfig, dynamicConfig];
15
+ configs = [
16
+ {
17
+ chakraSystemConfig: options.chakraSystemConfig
18
+ },
19
+ staticConfig,
20
+ dynamicConfig
21
+ ];
16
22
  } catch (e) {
17
23
  throw new Error(
18
24
  ErrorId.CONFIG_RESOLUTION_FAILED,
@@ -23,8 +29,16 @@ async function gatherConfig(hostElement, options, overrides) {
23
29
  );
24
30
  }
25
31
  const merged = mergeConfigs(configs);
26
- if (overrides?.locale) {
27
- merged.locale = overrides.locale;
32
+ if (overrides) {
33
+ if (overrides.locale) {
34
+ merged.locale = overrides.locale;
35
+ }
36
+ if (overrides.colorMode) {
37
+ merged.colorMode = overrides.colorMode;
38
+ }
39
+ if (overrides.chakraSystemConfig) {
40
+ merged.chakraSystemConfig = overrides.chakraSystemConfig;
41
+ }
28
42
  }
29
43
  return merged;
30
44
  }
@@ -33,6 +47,7 @@ function mergeConfigs(configs) {
33
47
  {
34
48
  locale: void 0,
35
49
  chakraSystemConfig: void 0,
50
+ colorMode: void 0,
36
51
  properties: {}
37
52
  },
38
53
  ...configs
@@ -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 {\n ApplicationConfig,\n ApplicationOverrides,\n ApplicationProperties,\n CustomElementOptions\n} from \"../CustomElement\";\nimport { ErrorId } from \"../errors\";\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?: ApplicationOverrides\n): Promise<Required<ApplicationConfig>> {\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 overrides\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 chakraSystemConfig: 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":";;;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F,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;;;;"}
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 {\n ApplicationConfig,\n ApplicationOverrides,\n ApplicationProperties,\n CustomElementOptions\n} from \"../CustomElement\";\nimport { ErrorId } from \"../errors\";\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?: ApplicationOverrides\n): Promise<Required<ApplicationConfig>> {\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 overrides\n })) ?? {};\n\n configs = [\n {\n chakraSystemConfig: options.chakraSystemConfig\n },\n staticConfig,\n dynamicConfig\n ];\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) {\n if (overrides.locale) {\n merged.locale = overrides.locale;\n }\n if (overrides.colorMode) {\n merged.colorMode = overrides.colorMode;\n }\n if (overrides.chakraSystemConfig) {\n merged.chakraSystemConfig = overrides.chakraSystemConfig;\n }\n }\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 chakraSystemConfig: undefined,\n colorMode: 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":";;;AAeA,eAAsB,YAAA,CAClB,WAAA,EACA,OAAA,EACA,SAAA,EACoC;AACpC,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,CAAA;AAAA,MACA;AAAA,KACH,KAAM,EAAC;AAEZ,IAAA,OAAA,GAAU;AAAA,MACN;AAAA,QACI,oBAAoB,OAAA,CAAQ;AAAA,OAChC;AAAA,MACA,YAAA;AAAA,MACA;AAAA,KACJ;AAAA,EACJ,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,SAAA,EAAW;AACX,IAAA,IAAI,UAAU,MAAA,EAAQ;AAClB,MAAA,MAAA,CAAO,SAAS,SAAA,CAAU,MAAA;AAAA,IAC9B;AACA,IAAA,IAAI,UAAU,SAAA,EAAW;AACrB,MAAA,MAAA,CAAO,YAAY,SAAA,CAAU,SAAA;AAAA,IACjC;AACA,IAAA,IAAI,UAAU,kBAAA,EAAoB;AAC9B,MAAA,MAAA,CAAO,qBAAqB,SAAA,CAAU,kBAAA;AAAA,IAC1C;AAAA,EACJ;AAEA,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,kBAAA,EAAoB,MAAA;AAAA,MACpB,SAAA,EAAW,MAAA;AAAA,MACX,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;;;;"}
@@ -0,0 +1,16 @@
1
+ import { type SystemConfig as ChakraSystemConfig } from "@chakra-ui/react";
2
+ import { type ChakraSystemConfigSupplier, type ColorModeValue, type ColorModeValueSupplier, type ThemeService } from "../api";
3
+ export declare const DEFAULT_INITIAL_COLOR_MODE: ColorModeValue;
4
+ export interface ThemeServiceProperties {
5
+ initialColorMode?: ColorModeValue | "system";
6
+ initialSystemConfig?: ChakraSystemConfig;
7
+ }
8
+ export declare class ThemeServiceImpl implements ThemeService {
9
+ #private;
10
+ constructor({ initialSystemConfig, initialColorMode }: ThemeServiceProperties);
11
+ get systemColorMode(): ColorModeValue;
12
+ get colorMode(): ColorModeValue;
13
+ setColorMode(value: ColorModeValue | ColorModeValueSupplier): void;
14
+ get systemConfig(): ChakraSystemConfig | undefined;
15
+ setSystemConfig(value: ChakraSystemConfig | ChakraSystemConfigSupplier | undefined): void;
16
+ }
@@ -0,0 +1,64 @@
1
+ import { reactive, computed, synchronized } from '@conterra/reactivity-core';
2
+
3
+ const DEFAULT_INITIAL_COLOR_MODE = "light";
4
+ class ThemeServiceImpl {
5
+ #systemColorMode = reactiveSystemColorMode();
6
+ #colorModeSource = reactive(() => DEFAULT_INITIAL_COLOR_MODE);
7
+ #colorMode = computed(
8
+ () => this.#colorModeSource.value() ?? DEFAULT_INITIAL_COLOR_MODE
9
+ );
10
+ #systemConfigSource = reactive(() => void 0);
11
+ #systemConfig = computed(
12
+ () => this.#systemConfigSource.value() ?? void 0
13
+ );
14
+ constructor({ initialSystemConfig, initialColorMode }) {
15
+ if (initialColorMode === "system") {
16
+ this.setColorMode(() => this.#systemColorMode.value);
17
+ } else {
18
+ this.setColorMode(initialColorMode ?? DEFAULT_INITIAL_COLOR_MODE);
19
+ }
20
+ if (initialSystemConfig) {
21
+ this.setSystemConfig(initialSystemConfig);
22
+ }
23
+ }
24
+ get systemColorMode() {
25
+ return this.#systemColorMode.value;
26
+ }
27
+ get colorMode() {
28
+ return this.#colorMode.value;
29
+ }
30
+ setColorMode(value) {
31
+ if (typeof value === "function") {
32
+ this.#colorModeSource.value = value;
33
+ } else {
34
+ this.#colorModeSource.value = () => value;
35
+ }
36
+ }
37
+ get systemConfig() {
38
+ return this.#systemConfig.value;
39
+ }
40
+ setSystemConfig(value) {
41
+ if (typeof value === "function") {
42
+ this.#systemConfigSource.value = value;
43
+ } else {
44
+ this.#systemConfigSource.value = () => value;
45
+ }
46
+ }
47
+ }
48
+ function reactiveSystemColorMode() {
49
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
50
+ return reactive("light");
51
+ }
52
+ const query = window.matchMedia("(prefers-color-scheme: dark)");
53
+ return synchronized(
54
+ () => query.matches ? "dark" : "light",
55
+ (onChange) => {
56
+ const listener = () => onChange();
57
+ query.addEventListener("change", listener);
58
+ return () => query.removeEventListener("change", listener);
59
+ }
60
+ );
61
+ }
62
+
63
+ export { DEFAULT_INITIAL_COLOR_MODE, ThemeServiceImpl };
64
+ //# sourceMappingURL=ThemeServiceImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeServiceImpl.js","sources":["ThemeServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { type SystemConfig as ChakraSystemConfig } from \"@chakra-ui/react\";\nimport { computed, reactive, ReadonlyReactive, synchronized } from \"@conterra/reactivity-core\";\nimport {\n type ChakraSystemConfigSupplier,\n type ColorModeValue,\n type ColorModeValueSupplier,\n type ThemeService\n} from \"../api\";\n\nexport const DEFAULT_INITIAL_COLOR_MODE: ColorModeValue = \"light\";\n\nexport interface ThemeServiceProperties {\n initialColorMode?: ColorModeValue | \"system\";\n initialSystemConfig?: ChakraSystemConfig;\n}\n\nexport class ThemeServiceImpl implements ThemeService {\n #systemColorMode = reactiveSystemColorMode();\n\n #colorModeSource = reactive<ColorModeValueSupplier>(() => DEFAULT_INITIAL_COLOR_MODE);\n #colorMode = computed<ColorModeValue>(\n () => this.#colorModeSource.value() ?? DEFAULT_INITIAL_COLOR_MODE\n );\n\n #systemConfigSource = reactive<ChakraSystemConfigSupplier>(() => undefined);\n #systemConfig = computed<ChakraSystemConfig | undefined>(\n () => this.#systemConfigSource.value() ?? undefined\n );\n\n constructor({ initialSystemConfig, initialColorMode }: ThemeServiceProperties) {\n if (initialColorMode === \"system\") {\n this.setColorMode(() => this.#systemColorMode.value);\n } else {\n this.setColorMode(initialColorMode ?? DEFAULT_INITIAL_COLOR_MODE);\n }\n if (initialSystemConfig) {\n this.setSystemConfig(initialSystemConfig);\n }\n }\n\n get systemColorMode(): ColorModeValue {\n return this.#systemColorMode.value;\n }\n\n get colorMode(): ColorModeValue {\n return this.#colorMode.value;\n }\n\n setColorMode(value: ColorModeValue | ColorModeValueSupplier): void {\n if (typeof value === \"function\") {\n this.#colorModeSource.value = value;\n } else {\n this.#colorModeSource.value = () => value;\n }\n }\n\n get systemConfig(): ChakraSystemConfig | undefined {\n return this.#systemConfig.value;\n }\n\n setSystemConfig(value: ChakraSystemConfig | ChakraSystemConfigSupplier | undefined): void {\n if (typeof value === \"function\") {\n this.#systemConfigSource.value = value;\n } else {\n this.#systemConfigSource.value = () => value;\n }\n }\n}\n\nfunction reactiveSystemColorMode(): ReadonlyReactive<ColorModeValue> {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") {\n return reactive(\"light\");\n }\n\n const query = window.matchMedia(\"(prefers-color-scheme: dark)\");\n return synchronized(\n () => (query.matches ? \"dark\" : \"light\"),\n (onChange) => {\n const listener = () => onChange();\n query.addEventListener(\"change\", listener);\n return () => query.removeEventListener(\"change\", listener);\n }\n );\n}\n"],"names":[],"mappings":";;AAWO,MAAM,0BAAA,GAA6C;AAOnD,MAAM,gBAAA,CAAyC;AAAA,EAClD,mBAAmB,uBAAA,EAAwB;AAAA,EAE3C,gBAAA,GAAmB,QAAA,CAAiC,MAAM,0BAA0B,CAAA;AAAA,EACpF,UAAA,GAAa,QAAA;AAAA,IACT,MAAM,IAAA,CAAK,gBAAA,CAAiB,KAAA,EAAM,IAAK;AAAA,GAC3C;AAAA,EAEA,mBAAA,GAAsB,QAAA,CAAqC,MAAM,MAAS,CAAA;AAAA,EAC1E,aAAA,GAAgB,QAAA;AAAA,IACZ,MAAM,IAAA,CAAK,mBAAA,CAAoB,KAAA,EAAM,IAAK;AAAA,GAC9C;AAAA,EAEA,WAAA,CAAY,EAAE,mBAAA,EAAqB,gBAAA,EAAiB,EAA2B;AAC3E,IAAA,IAAI,qBAAqB,QAAA,EAAU;AAC/B,MAAA,IAAA,CAAK,YA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OAAO,YAAA;AAAA,IACH,MAAO,KAAA,CAAM,OAAA,GAAU,MAAA,GAAS,OAAA;AAAA,IAChC,CAAC,QAAA,KAAa;AACV,MAAA,MAAM,QAAA,GAAW,MAAM,QAAA,EAAS;AAChC,MAAA,KAAA,CAAM,gBAAA,CAAiB,UAAU,QAAQ,CAAA;AACzC,MAAA,OAAO,MAAM,KAAA,CAAM,mBAAA,CAAoB,QAAA,EAAU,QAAQ,CAAA;AAAA,IAC7D;AAAA,GACJ;AACJ;;;;"}
@@ -1,5 +1,6 @@
1
1
  import { PackageRepr } from "../service-layer/PackageRepr";
2
2
  import { ApplicationContextProperties } from "./ApplicationContextImpl";
3
+ import { ThemeServiceProperties } from "./ThemeServiceImpl";
3
4
  export declare const RUNTIME_PACKAGE_NAME = "@open-pioneer/runtime";
4
5
  export declare const RUNTIME_API_EXTENSION = "integration.ApiExtension";
5
6
  export declare const RUNTIME_API_SERVICE = "runtime.ApiService";
@@ -7,7 +8,8 @@ export declare const RUNTIME_APPLICATION_CONTEXT = "runtime.ApplicationContext";
7
8
  export declare const RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE = "runtime.ApplicationLifecycleEventService";
8
9
  export declare const RUNTIME_NUMBER_PARSER_SERVICE = "runtime.NumberParserService";
9
10
  export declare const RUNTIME_AUTO_START = "runtime.AutoStart";
10
- export type BuiltinPackageProperties = ApplicationContextProperties;
11
+ export declare const RUNTIME_THEME_SERVICE = "runtime.ThemeService";
12
+ export type BuiltinPackageProperties = ApplicationContextProperties & ThemeServiceProperties;
11
13
  /**
12
14
  * Creates the builtin package containing the builtin services.
13
15
  *
@@ -7,6 +7,7 @@ import { ApiServiceImpl } from './ApiServiceImpl.js';
7
7
  import { ApplicationContextImpl } from './ApplicationContextImpl.js';
8
8
  import { ApplicationLifecycleEventService } from './ApplicationLifecycleEventService.js';
9
9
  import { NumberParserServiceImpl } from './NumberParserServiceImpl.js';
10
+ import { ThemeServiceImpl } from './ThemeServiceImpl.js';
10
11
 
11
12
  const RUNTIME_PACKAGE_NAME = "@open-pioneer/runtime";
12
13
  const RUNTIME_API_EXTENSION = "integration.ApiExtension";
@@ -15,6 +16,7 @@ const RUNTIME_APPLICATION_CONTEXT = "runtime.ApplicationContext";
15
16
  const RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE = "runtime.ApplicationLifecycleEventService";
16
17
  const RUNTIME_NUMBER_PARSER_SERVICE = "runtime.NumberParserService";
17
18
  const RUNTIME_AUTO_START = "runtime.AutoStart";
19
+ const RUNTIME_THEME_SERVICE = "runtime.ThemeService";
18
20
  function createBuiltinPackage(properties) {
19
21
  const i18n = createEmptyPackageIntl();
20
22
  const apiService = new ServiceRepr({
@@ -83,12 +85,37 @@ function createBuiltinPackage(properties) {
83
85
  }
84
86
  ]
85
87
  });
88
+ const themeService = new ServiceRepr({
89
+ name: "ThemeServiceImpl",
90
+ packageName: RUNTIME_PACKAGE_NAME,
91
+ factory: createFunctionFactory(() => new ThemeServiceImpl(properties)),
92
+ intl: i18n,
93
+ interfaces: [
94
+ {
95
+ interfaceName: RUNTIME_THEME_SERVICE,
96
+ qualifier: "builtin"
97
+ }
98
+ ],
99
+ dependencies: [
100
+ {
101
+ referenceName: "applicationContext",
102
+ interfaceName: RUNTIME_APPLICATION_CONTEXT,
103
+ qualifier: "builtin"
104
+ }
105
+ ]
106
+ });
86
107
  return new PackageRepr({
87
108
  name: RUNTIME_PACKAGE_NAME,
88
- services: [apiService, appContext, lifecycleEventService, numberParserService],
109
+ services: [
110
+ apiService,
111
+ appContext,
112
+ lifecycleEventService,
113
+ numberParserService,
114
+ themeService
115
+ ],
89
116
  intl: i18n
90
117
  });
91
118
  }
92
119
 
93
- export { RUNTIME_API_SERVICE, RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE, RUNTIME_AUTO_START, RUNTIME_PACKAGE_NAME, createBuiltinPackage };
120
+ export { RUNTIME_API_SERVICE, RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE, RUNTIME_AUTO_START, RUNTIME_PACKAGE_NAME, RUNTIME_THEME_SERVICE, createBuiltinPackage };
94
121
  //# sourceMappingURL=index.js.map
@@ -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,oBAAA,GAAuB;AAC7B,MAAM,qBAAA,GAAwB,0BAAA;AAC9B,MAAM,mBAAA,GAAsB;AAC5B,MAAM,2BAAA,GAA8B,4BAAA;AACpC,MAAM,2CAAA,GACT;AACG,MAAM,6BAAA,GAAgC,6BAAA;AACtC,MAAM,kBAAA,GAAqB;AAc3B,SAAS,qBAAqB,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f,GAAA,EAAK;AAAA;AACT;AACJ,GACH,CAAA;AACD,EAAA,MAAM,mBAAA,GAAsB,IAAI,WAAA,CAAY;AAAA,IACxC,IAAA,EAAM,yBAAA;AAAA,IACN,WAAA,EAAa,oBAAA;AAAA,IACb,OAAA,EAAS,qBAAA;AAAA,MACL,CAAC,OAAA,KAAY,IAAI,uBAAA,CAAwB,OAAA,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;;;;"}
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\";\nimport { ThemeServiceImpl, ThemeServiceProperties } from \"./ThemeServiceImpl\";\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\";\nexport const RUNTIME_THEME_SERVICE = \"runtime.ThemeService\";\n\nexport type BuiltinPackageProperties = ApplicationContextProperties & ThemeServiceProperties;\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 const themeService = new ServiceRepr({\n name: \"ThemeServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(() => new ThemeServiceImpl(properties)),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_THEME_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"applicationContext\",\n interfaceName: RUNTIME_APPLICATION_CONTEXT,\n qualifier: \"builtin\"\n }\n ]\n });\n\n return new PackageRepr({\n name: RUNTIME_PACKAGE_NAME,\n services: [\n apiService,\n appContext,\n lifecycleEventService,\n numberParserService,\n themeService\n ],\n intl: i18n\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAeO,MAAM,oBAAA,GAAuB;AAC7B,MAAM,qBAAA,GAAwB,0BAAA;AAC9B,MAAM,mBAAA,GAAsB;AAC5B,MAAM,2BAAA,GAA8B,4BAAA;AACpC,MAAM,2CAAA,GACT;AACG,MAAM,6BAAA,GAAgC,6BAAA;AACtC,MAAM,kBAAA,GAAqB;AAC3B,MAAM,qBAAA,GAAwB;AAc9B,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,IAAA;AAAA,IACN,UAAA,EAAY;AAAA,MACR;AAAA,QACI,aAAA,E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AM,IAAA;AAAA,IACN,UAAA,EAAY;AAAA,MACR;AAAA,QACI,aAAA,EAAe,6BAAA;AAAA,QACf,SAAA,EAAW;AAAA;AACf;AACJ,GACH,CAAA;AAED,EAAA,MAAM,YAAA,GAAe,IAAI,WAAA,CAAY;AAAA,IACjC,IAAA,EAAM,kBAAA;AAAA,IACN,WAAA,EAAa,oBAAA;AAAA,IACb,SAAS,qBAAA,CAAsB,MAAM,IAAI,gBAAA,CAAiB,UAAU,CAAC,CAAA;AAAA,IACrE,IAAA,EAAM,IAAA;AAAA,IACN,UAAA,EAAY;AAAA,MACR;AAAA,QACI,aAAA,EAAe,qBAAA;AAAA,QACf,SAAA,EAAW;AAAA;AACf,KACJ;AAAA,IACA,YAAA,EAAc;AAAA,MACV;AAAA,QACI,aAAA,EAAe,oBAAA;AAAA,QACf,aAAA,EAAe,2BAAA;AAAA,QACf,SAAA,EAAW;AAAA;AACf;AACJ,GACH,CAAA;AAED,EAAA,OAAO,IAAI,WAAA,CAAY;AAAA,IACnB,IAAA,EAAM,oBAAA;AAAA,IACN,QAAA,EAAU;AAAA,MACN,UAAA;AAAA,MACA,UAAA;AAAA,MACA,qBAAA;AAAA,MACA,mBAAA;AAAA,MACA;AAAA,KACJ;AAAA,IACA,IAAA,EAAM;AAAA,GACT,CAAA;AACL;;;;"}
package/i18n/AppIntl.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createLogger, Error } from '@open-pioneer/core';
2
- import { sourceId$4 as sourceId } from '../_virtual/source-info.js';
2
+ import { sourceId$1 as sourceId } from '../_virtual/source-info.js';
3
3
  import { ErrorId } from '../errors.js';
4
4
  import { createPackageIntl } from './PackageIntl.js';
5
5
  import { getBrowserLocales, I18nConfig } from './pick.js';
package/i18n/pick.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createLogger, Error } from '@open-pioneer/core';
2
- import { sourceId$5 as sourceId } from '../_virtual/source-info.js';
2
+ import { sourceId } from '../_virtual/source-info.js';
3
3
  import { ErrorId } from '../errors.js';
4
4
 
5
5
  const LOG = createLogger(sourceId);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/runtime",
4
- "version": "4.5.0-dev.20260225121659",
4
+ "version": "4.5.0-dev.20260303103629",
5
5
  "description": "Implements the runtime environment for Open Pioneer Trails apps.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -21,9 +21,9 @@
21
21
  "@emotion/react": "^11.14.0",
22
22
  "react": "^19.2.4",
23
23
  "react-dom": "^19.2.4",
24
- "@open-pioneer/core": "4.5.0-dev.20260225121659",
25
- "@open-pioneer/base-theme": "4.5.0-dev.20260225121659",
26
- "@open-pioneer/reactivity": "4.5.0-dev.20260225121659"
24
+ "@open-pioneer/base-theme": "4.5.0-dev.20260303103629",
25
+ "@open-pioneer/core": "4.5.0-dev.20260303103629",
26
+ "@open-pioneer/reactivity": "4.5.0-dev.20260303103629"
27
27
  },
28
28
  "exports": {
29
29
  "./package.json": "./package.json",
@@ -2,6 +2,7 @@ import { SystemConfig } from "@chakra-ui/react";
2
2
  import { ReadonlyReactive } from "@conterra/reactivity-core";
3
3
  import { FC, PropsWithChildren } from "react";
4
4
  import { RootNode } from "../dom";
5
+ import { ColorModeValue } from "../api";
5
6
  /** @internal */
6
7
  export type CustomChakraProviderProps = PropsWithChildren<{
7
8
  /**
@@ -21,11 +22,15 @@ export type CustomChakraProviderProps = PropsWithChildren<{
21
22
  /**
22
23
  * Chakra system config (can be used to provide custom theme).
23
24
  */
24
- config?: SystemConfig;
25
+ config?: ReadonlyReactive<SystemConfig | undefined>;
25
26
  /**
26
27
  * Application locale for chakra's `LocaleProvider`.
27
28
  */
28
29
  locale?: string;
30
+ /**
31
+ * Custom color mode value.
32
+ */
33
+ colorMode: ReadonlyReactive<ColorModeValue>;
29
34
  /**
30
35
  * Custom CSS used by the application.
31
36
  */
@@ -5,7 +5,7 @@ import { CacheProvider, Global } from '@emotion/react';
5
5
  import { config } from '@open-pioneer/base-theme';
6
6
  import { Error } from '@open-pioneer/core';
7
7
  import { useReactiveSnapshot } from '@open-pioneer/reactivity';
8
- import { useMemo, useEffect, useState } from 'react';
8
+ import { useMemo, useLayoutEffect, useState, useEffect } from 'react';
9
9
  import { APP_ROOT_CLASS, getStylesRoot, getBuiltinStyles } from '../dom/index.js';
10
10
  import { ErrorId } from '../errors.js';
11
11
 
@@ -15,12 +15,14 @@ const CustomChakraProvider = ({
15
15
  appRoot,
16
16
  hostNode,
17
17
  children,
18
- config: config$1 = config,
18
+ config: config$1,
19
19
  locale = "en-US",
20
+ colorMode,
20
21
  styles
21
22
  }) => {
23
+ const systemConfig = useReactiveSnapshot(() => config$1?.value ?? config, [config$1]);
22
24
  const system = useMemo(() => {
23
- const mergedConfig = mergeConfigs(defaultConfig, config$1);
25
+ const mergedConfig = mergeConfigs(defaultConfig, systemConfig);
24
26
  return createSystem(
25
27
  mergedConfig,
26
28
  // https://www.chakra-ui.com/docs/get-started/environments/shadow-dom
@@ -33,15 +35,13 @@ const CustomChakraProvider = ({
33
35
  globalCss: redirectHtmlProps(mergedConfig.globalCss)
34
36
  })
35
37
  );
36
- }, [config$1]);
37
- useEffect(() => {
38
+ }, [systemConfig]);
39
+ const effectiveColorMode = useReactiveSnapshot(() => colorMode.value, [colorMode]);
40
+ useLayoutEffect(() => {
38
41
  const classes = appRoot.classList;
39
- const colorMode = "light";
40
- classes.add(colorMode);
41
- return () => {
42
- classes.remove(colorMode);
43
- };
44
- }, [appRoot]);
42
+ classes.toggle("light", effectiveColorMode === "light");
43
+ classes.toggle("dark", effectiveColorMode === "dark");
44
+ }, [appRoot, effectiveColorMode]);
45
45
  const cache = useEmotionCache(rootNode);
46
46
  return cache && /* @__PURE__ */ jsx(CacheProvider, { value: cache, children: /* @__PURE__ */ jsx(
47
47
  EnvironmentProvider,
@@ -1 +1 @@
1
- {"version":3,"file":"ChakraProvider.js","sources":["ChakraProvider.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n ChakraProvider,\n createSystem,\n defaultConfig,\n defineConfig,\n EnvironmentProvider,\n LocaleProvider,\n mergeConfigs,\n SystemConfig,\n SystemStyleObject\n} from \"@chakra-ui/react\";\nimport { ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport createCache, { EmotionCache } from \"@emotion/cache\";\nimport { CacheProvider, Global } from \"@emotion/react\";\nimport { config as defaultTrailsConfig } from \"@open-pioneer/base-theme\";\nimport { Error } from \"@open-pioneer/core\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport { FC, PropsWithChildren, useEffect, useMemo, useState } from \"react\";\nimport { APP_ROOT_CLASS, getBuiltinStyles, getStylesRoot, RootNode } from \"../dom\";\nimport { ErrorId } from \"../errors\";\n\n/** @internal */\nexport type CustomChakraProviderProps = PropsWithChildren<{\n /**\n * Document root node.\n */\n rootNode: RootNode;\n\n /**\n * Web component root.\n *\n * NOTE: undefined for test support only.\n */\n hostNode?: HTMLElement;\n\n /**\n * Application container (react's render target).\n */\n appRoot: HTMLElement;\n\n /**\n * Chakra system config (can be used to provide custom theme).\n */\n config?: SystemConfig;\n\n /**\n * Application locale for chakra's `LocaleProvider`.\n */\n locale?: string;\n\n /**\n * Custom CSS used by the application.\n */\n styles?: ReadonlyReactive<string>;\n}>;\n\nconst APP_ROOT_CSS = `.${APP_ROOT_CLASS}`;\n\n/**\n * Wraps the entire react application and configures chakra-ui (styling etc.).\n *\n * Exported so it can be used from the test-utils package.\n *\n * @internal\n */\nexport const CustomChakraProvider: FC<CustomChakraProviderProps> = ({\n rootNode,\n appRoot,\n hostNode,\n children,\n config = defaultTrailsConfig,\n locale = \"en-US\",\n styles\n}) => {\n /*\n Setup chakra integration:\n\n 1. Mount styles into the shadow root via emotion\n 2. Use chakra's EnvironmentProvider to tell it about the shadow root context\n 3. Setup global styles correctly (selectors etc.) via chakra's system object\n 4. Render the rest of the application\n */\n\n const system = useMemo(() => {\n const mergedConfig = mergeConfigs(defaultConfig, config);\n return createSystem(\n mergedConfig,\n\n // https://www.chakra-ui.com/docs/get-started/environments/shadow-dom\n defineConfig({\n preflight: {\n scope: APP_ROOT_CSS\n },\n cssVarsRoot: APP_ROOT_CSS,\n conditions: redirectLightCondition(mergedConfig.conditions),\n globalCss: redirectHtmlProps(mergedConfig.globalCss)\n })\n );\n }, [config]);\n\n useEffect(() => {\n const classes = appRoot.classList;\n const colorMode = \"light\"; // \"light\" | \"dark\"\n classes.add(colorMode);\n return () => {\n classes.remove(colorMode);\n };\n }, [appRoot]);\n\n const cache = useEmotionCache(rootNode);\n return (\n cache && (\n <CacheProvider value={cache}>\n <EnvironmentProvider\n value={rootNode}\n // Patched property\n portalNode={appRoot}\n >\n <LocaleProvider locale={locale}>\n <ChakraProvider value={system}>\n <GlobalStyles rootNode={rootNode} hostNode={hostNode} styles={styles} />\n {children}\n </ChakraProvider>\n </LocaleProvider>\n </EnvironmentProvider>\n </CacheProvider>\n )\n );\n};\n\nfunction GlobalStyles(props: {\n rootNode: RootNode;\n hostNode: HTMLElement | undefined;\n styles: ReadonlyReactive<string> | undefined;\n}) {\n const { rootNode, hostNode, styles } = props;\n const builtinStyles = useMemo(() => {\n const css = getBuiltinStyles(rootNode, hostNode);\n return <Global styles={css} />;\n }, [rootNode, hostNode]);\n const appStyles = useReactiveSnapshot(() => {\n const css = styles?.value;\n return css && <Global styles={css} />;\n }, [styles]);\n return (\n <>\n {builtinStyles}\n {appStyles}\n </>\n );\n}\n\nfunction redirectHtmlProps(\n css: Record<string, SystemStyleObject> | undefined\n): Record<string, SystemStyleObject> {\n const { html, ...rest } = css ?? {};\n if (!html) {\n throw new Error(ErrorId.INTERNAL, \"Expected global rules on html element.\");\n }\n // Take default html styles and apply them to the host element instead\n return {\n ...rest,\n [APP_ROOT_CSS]: html\n };\n}\n\nfunction redirectLightCondition(\n conditions: Record<string, unknown> | undefined\n): Record<string, unknown> {\n // Make sure light mode tokens are applied\n return {\n ...conditions,\n // Before: \":root &, .light &\"\n light: `${APP_ROOT_CSS} &, .light &`\n };\n}\n\nfunction useEmotionCache(rootNode: RootNode): EmotionCache | undefined {\n const stylesRoot = useMemo(() => getStylesRoot(rootNode), [rootNode]);\n\n const [cache, setCache] = useState<EmotionCache | undefined>();\n useEffect(() => {\n const cache = createCache({\n key: \"css\",\n container: stylesRoot\n });\n\n // Disable useless warnings like `The pseudo class \":nth-child\" is potentially unsafe when doing server-side rendering. Try changing it to \":nth-of-type\".`\n // See: https://github.com/emotion-js/emotion/issues/1105#issuecomment-557726922\n cache.compat = true;\n\n setCache(cache);\n return () => {\n setCache(undefined);\n for (const tag of cache.sheet.tags) {\n tag.remove();\n }\n };\n }, [stylesRoot]);\n return cache;\n}\n"],"names":["config","defaultTrailsConfig","cache"],"mappings":";;;;;;;;;;;AA0DA,MAAM,YAAA,GAAe,IAAI,cAAc,CAAA,CAAA;AAShC,MAAM,uBAAsD,CAAC;AAAA,EAChE,QAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,UACAA,QAAA,GAASC,MAAA;AAAA,EACT,MAAA,GAAS,OAAA;AAAA,EACT;AACJ,CAAA,KAAM;AAUF,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAM;AACzB,IAAA,MAAM,YAAA,GAAe,YAAA,CAAa,aAAA,EAAeD,QAAM,CAAA;AACvD,IAAA,OAAO,YAAA;AAAA,MACH,YAAA;AAAA;AAAA,MAGA,YAAA,CAAa;AAAA,QACT,SAAA,EAAW;AAAA,UACP,KAAA,EAAO;AAAA,SACX;AAAA,QACA,WAAA,EAAa,YAAA;AAAA,QACb,UAAA,EAAY,sBAAA,CAAuB,YAAA,CAAa,UAAU,CAAA;AAAA,QAC1D,SAAA,EAAW,iBAAA,CAAkB,YAAA,CAAa,SAAS;AAAA,OACtD;AAAA,KACL;AAAA,EACJ,CAAA,EAAG,CAACA,QAAM,CAAC,CAAA;AAEX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KAAA,MAAW,GAAA,IAAOA,MAAAA,CAAM,KAAA,CAAM,IAAA,EAAM;AAChC,QAAA,GAAA,CAAI,MAAA,EAAO;AAAA,MACf;AAAA,IACJ,CAAA;AAAA,EACJ,CAAA,EAAG,CAAC,UAAU,CAAC,CAAA;AACf,EAAA,OAAO,KAAA;AACX;;;;"}
1
+ {"version":3,"file":"ChakraProvider.js","sources":["ChakraProvider.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n ChakraProvider,\n createSystem,\n defaultConfig,\n defineConfig,\n EnvironmentProvider,\n LocaleProvider,\n mergeConfigs,\n SystemConfig,\n SystemStyleObject\n} from \"@chakra-ui/react\";\nimport { ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport createCache, { EmotionCache } from \"@emotion/cache\";\nimport { CacheProvider, Global } from \"@emotion/react\";\nimport { config as defaultTrailsConfig } from \"@open-pioneer/base-theme\";\nimport { Error } from \"@open-pioneer/core\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport { FC, PropsWithChildren, useEffect, useLayoutEffect, useMemo, useState } from \"react\";\nimport { APP_ROOT_CLASS, getBuiltinStyles, getStylesRoot, RootNode } from \"../dom\";\nimport { ErrorId } from \"../errors\";\nimport { ColorModeValue } from \"../api\";\n\n/** @internal */\nexport type CustomChakraProviderProps = PropsWithChildren<{\n /**\n * Document root node.\n */\n rootNode: RootNode;\n\n /**\n * Web component root.\n *\n * NOTE: undefined for test support only.\n */\n hostNode?: HTMLElement;\n\n /**\n * Application container (react's render target).\n */\n appRoot: HTMLElement;\n\n /**\n * Chakra system config (can be used to provide custom theme).\n */\n config?: ReadonlyReactive<SystemConfig | undefined>;\n\n /**\n * Application locale for chakra's `LocaleProvider`.\n */\n locale?: string;\n\n /**\n * Custom color mode value.\n */\n colorMode: ReadonlyReactive<ColorModeValue>;\n\n /**\n * Custom CSS used by the application.\n */\n styles?: ReadonlyReactive<string>;\n}>;\n\nconst APP_ROOT_CSS = `.${APP_ROOT_CLASS}`;\n\n/**\n * Wraps the entire react application and configures chakra-ui (styling etc.).\n *\n * Exported so it can be used from the test-utils package.\n *\n * @internal\n */\nexport const CustomChakraProvider: FC<CustomChakraProviderProps> = ({\n rootNode,\n appRoot,\n hostNode,\n children,\n config,\n locale = \"en-US\",\n colorMode,\n styles\n}) => {\n /*\n Setup chakra integration:\n\n 1. Mount styles into the shadow root via emotion\n 2. Use chakra's EnvironmentProvider to tell it about the shadow root context\n 3. Setup global styles correctly (selectors etc.) via chakra's system object\n 4. Render the rest of the application\n */\n\n const systemConfig = useReactiveSnapshot(() => config?.value ?? defaultTrailsConfig, [config]);\n\n const system = useMemo(() => {\n const mergedConfig = mergeConfigs(defaultConfig, systemConfig);\n return createSystem(\n mergedConfig,\n\n // https://www.chakra-ui.com/docs/get-started/environments/shadow-dom\n defineConfig({\n preflight: {\n scope: APP_ROOT_CSS\n },\n cssVarsRoot: APP_ROOT_CSS,\n conditions: redirectLightCondition(mergedConfig.conditions),\n globalCss: redirectHtmlProps(mergedConfig.globalCss)\n })\n );\n }, [systemConfig]);\n\n const effectiveColorMode = useReactiveSnapshot(() => colorMode.value, [colorMode]);\n\n useLayoutEffect(() => {\n const classes = appRoot.classList;\n classes.toggle(\"light\", effectiveColorMode === \"light\");\n classes.toggle(\"dark\", effectiveColorMode === \"dark\");\n }, [appRoot, effectiveColorMode]);\n\n const cache = useEmotionCache(rootNode);\n return (\n cache && (\n <CacheProvider value={cache}>\n <EnvironmentProvider\n value={rootNode}\n // Patched property\n portalNode={appRoot}\n >\n <LocaleProvider locale={locale}>\n <ChakraProvider value={system}>\n <GlobalStyles rootNode={rootNode} hostNode={hostNode} styles={styles} />\n {children}\n </ChakraProvider>\n </LocaleProvider>\n </EnvironmentProvider>\n </CacheProvider>\n )\n );\n};\n\nfunction GlobalStyles(props: {\n rootNode: RootNode;\n hostNode: HTMLElement | undefined;\n styles: ReadonlyReactive<string> | undefined;\n}) {\n const { rootNode, hostNode, styles } = props;\n const builtinStyles = useMemo(() => {\n const css = getBuiltinStyles(rootNode, hostNode);\n return <Global styles={css} />;\n }, [rootNode, hostNode]);\n const appStyles = useReactiveSnapshot(() => {\n const css = styles?.value;\n return css && <Global styles={css} />;\n }, [styles]);\n return (\n <>\n {builtinStyles}\n {appStyles}\n </>\n );\n}\n\nfunction redirectHtmlProps(\n css: Record<string, SystemStyleObject> | undefined\n): Record<string, SystemStyleObject> {\n const { html, ...rest } = css ?? {};\n if (!html) {\n throw new Error(ErrorId.INTERNAL, \"Expected global rules on html element.\");\n }\n // Take default html styles and apply them to the host element instead\n return {\n ...rest,\n [APP_ROOT_CSS]: html\n };\n}\n\nfunction redirectLightCondition(\n conditions: Record<string, unknown> | undefined\n): Record<string, unknown> {\n // Make sure light mode tokens are applied\n return {\n ...conditions,\n // Before: \":root &, .light &\"\n light: `${APP_ROOT_CSS} &, .light &`\n };\n}\n\nfunction useEmotionCache(rootNode: RootNode): EmotionCache | undefined {\n const stylesRoot = useMemo(() => getStylesRoot(rootNode), [rootNode]);\n\n const [cache, setCache] = useState<EmotionCache | undefined>();\n useEffect(() => {\n const cache = createCache({\n key: \"css\",\n container: stylesRoot\n });\n\n // Disable useless warnings like `The pseudo class \":nth-child\" is potentially unsafe when doing server-side rendering. Try changing it to \":nth-of-type\".`\n // See: https://github.com/emotion-js/emotion/issues/1105#issuecomment-557726922\n cache.compat = true;\n\n setCache(cache);\n return () => {\n setCache(undefined);\n for (const tag of cache.sheet.tags) {\n tag.remove();\n }\n };\n }, [stylesRoot]);\n return cache;\n}\n"],"names":["config","defaultTrailsConfig","cache"],"mappings":";;;;;;;;;;;AAgEA,MAAM,YAAA,GAAe,IAAI,cAAc,CAAA,CAAA;AAShC,MAAM,uBAAsD,CAAC;AAAA,EAChE,QAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,UACAA,QAAA;AAAA,EACA,MAA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9E;AAEA,EAAA,OAAO;AAAA,IACH,GAAG,IAAA;AAAA,IACH,CAAC,YAAY,GAAG;AAAA,GACpB;AACJ;AAEA,SAAS,uBACL,UAAA,EACuB;AAEvB,EAAA,OAAO;AAAA,IACH,GAAG,UAAA;AAAA;AAAA,IAEH,KAAA,EAAO,GAAG,YAAY,CAAA,YAAA;AAAA,GAC1B;AACJ;AAEA,SAAS,gBAAgB,QAAA,EAA8C;AACnE,EAAA,MAAM,UAAA,GAAa,QAAQ,MAAM,aAAA,CAAc,QAAQ,CAAA,EAAG,CAAC,QAAQ,CAAC,CAAA;AAEpE,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,QAAA,EAAmC;AAC7D,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,MAAME,SAAQ,WAAA,CAAY;AAAA,MACtB,GAAA,EAAK,KAAA;AAAA,MACL,SAAA,EAAW;AAAA,KACd,CAAA;AAID,IAAAA,OAAM,MAAA,GAAS,IAAA;AAEf,IAAA,QAAA,CAASA,MAAK,CAAA;AACd,IAAA,OAAO,MAAM;AACT,MAAA,QAAA,CAAS,MAAS,CAAA;AAClB,MAAA,KAAA,MAAW,GAAA,IAAOA,MAAAA,CAAM,KAAA,CAAM,IAAA,EAAM;AAChC,QAAA,GAAA,CAAI,MAAA,EAAO;AAAA,MACf;AAAA,IACJ,CAAA;AAAA,EACJ,CAAA,EAAG,CAAC,UAAU,CAAC,CAAA;AACf,EAAA,OAAO,KAAA;AACX;;;;"}
@@ -4,6 +4,7 @@ import { ReactNode } from "react";
4
4
  import { RootNode } from "../dom";
5
5
  import { PackageRepr } from "../service-layer/PackageRepr";
6
6
  import { ServiceLayer } from "../service-layer/ServiceLayer";
7
+ import { ColorModeValue } from "../api";
7
8
  export interface ReactIntegrationOptions {
8
9
  rootNode: RootNode;
9
10
  hostNode: HTMLElement;
@@ -11,8 +12,9 @@ export interface ReactIntegrationOptions {
11
12
  packages: Map<string, PackageRepr>;
12
13
  serviceLayer: ServiceLayer;
13
14
  locale: string;
14
- config: SystemConfig | undefined;
15
+ config?: ReadonlyReactive<SystemConfig | undefined>;
15
16
  styles: ReadonlyReactive<string>;
17
+ colorMode: ReadonlyReactive<ColorModeValue>;
16
18
  }
17
19
  export declare class ReactIntegration {
18
20
  private rootNode;
@@ -21,8 +23,9 @@ export declare class ReactIntegration {
21
23
  private reactRoot;
22
24
  private packageContext;
23
25
  private locale;
24
- private chakraConfig;
26
+ private chakraConfig?;
25
27
  private styles;
28
+ private colorMode;
26
29
  static createForApp(options: ReactIntegrationOptions): ReactIntegration;
27
30
  static createForErrorScreen(options: Omit<ReactIntegrationOptions, "serviceLayer" | "packages">): ReactIntegration;
28
31
  private constructor();
@@ -17,6 +17,7 @@ class ReactIntegration {
17
17
  locale;
18
18
  chakraConfig;
19
19
  styles;
20
+ colorMode;
20
21
  static createForApp(options) {
21
22
  const { serviceLayer, packages } = options;
22
23
  const packageContext = createPackageContext(serviceLayer, packages);
@@ -43,6 +44,7 @@ class ReactIntegration {
43
44
  this.packageContext = options.packageContext;
44
45
  this.locale = options.locale;
45
46
  this.styles = options.styles;
47
+ this.colorMode = options.colorMode;
46
48
  }
47
49
  render(contentNode) {
48
50
  this.reactRoot.render(
@@ -55,6 +57,7 @@ class ReactIntegration {
55
57
  config: this.chakraConfig,
56
58
  locale: this.locale,
57
59
  styles: this.styles,
60
+ colorMode: this.colorMode,
58
61
  children: /* @__PURE__ */ jsx(PackageContext.Provider, { value: this.packageContext, children: contentNode })
59
62
  }
60
63
  ) })
@@ -1 +1 @@
1
- {"version":3,"file":"ReactIntegration.js","sources":["ReactIntegration.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { SystemConfig } from \"@chakra-ui/react\";\nimport { ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ReactNode, StrictMode } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport { RootNode } from \"../dom\";\nimport { ErrorId } from \"../errors\";\nimport { InterfaceSpec, renderInterfaceSpec } from \"../service-layer/InterfaceSpec\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport { ServiceLayer } from \"../service-layer/ServiceLayer\";\nimport { renderAmbiguousServiceChoices } from \"../service-layer/ServiceLookup\";\nimport { CustomChakraProvider } from \"./ChakraProvider\";\nimport { PackageContext, PackageContextMethods } from \"./PackageContext\";\n\nexport interface ReactIntegrationOptions {\n rootNode: RootNode;\n hostNode: HTMLElement;\n appRoot: HTMLDivElement;\n packages: Map<string, PackageRepr>;\n serviceLayer: ServiceLayer;\n\n locale: string;\n config: SystemConfig | undefined;\n styles: ReadonlyReactive<string>;\n}\n\nexport class ReactIntegration {\n private rootNode: RootNode;\n private hostNode: HTMLElement;\n private appRoot: HTMLDivElement;\n private reactRoot: Root;\n private packageContext: PackageContextMethods;\n private locale: string;\n private chakraConfig: SystemConfig | undefined;\n private styles: ReadonlyReactive<string>;\n\n static createForApp(options: ReactIntegrationOptions): ReactIntegration {\n const { serviceLayer, packages } = options;\n const packageContext = createPackageContext(serviceLayer, packages);\n return new ReactIntegration({ ...options, packageContext });\n }\n\n static createForErrorScreen(\n options: Omit<ReactIntegrationOptions, \"serviceLayer\" | \"packages\">\n ) {\n const throwError = () => {\n throw new Error(ErrorId.INVALID_STATE, \"Hook cannot be used within the error screen.\");\n };\n const packageContext: PackageContextMethods = {\n getIntl: throwError,\n getProperties: throwError,\n getService: throwError,\n getServices: throwError\n };\n return new ReactIntegration({ ...options, packageContext });\n }\n\n private constructor(\n options: Omit<ReactIntegrationOptions, \"serviceLayer\" | \"packages\"> & {\n packageContext: PackageContextMethods;\n }\n ) {\n this.rootNode = options.rootNode;\n this.hostNode = options.hostNode;\n this.appRoot = options.appRoot;\n this.reactRoot = createRoot(options.appRoot);\n this.chakraConfig = options.config;\n this.packageContext = options.packageContext;\n this.locale = options.locale;\n this.styles = options.styles;\n }\n\n render(contentNode: ReactNode) {\n this.reactRoot.render(\n <StrictMode>\n <CustomChakraProvider\n rootNode={this.rootNode}\n hostNode={this.hostNode}\n appRoot={this.appRoot}\n config={this.chakraConfig}\n locale={this.locale}\n styles={this.styles}\n >\n <PackageContext.Provider value={this.packageContext}>\n {contentNode}\n </PackageContext.Provider>\n </CustomChakraProvider>\n </StrictMode>\n );\n }\n\n destroy() {\n this.reactRoot.unmount();\n }\n}\n\nexport function EmptyComponent(): ReactNode {\n return null;\n}\n\nfunction createPackageContext(\n serviceLayer: ServiceLayer,\n packages: Map<string, PackageRepr>\n): PackageContextMethods {\n const getPackage = (packageName: string): PackageRepr => {\n const pkg = packages.get(packageName);\n if (!pkg) {\n throw new Error(\n ErrorId.INTERNAL,\n `Package '${packageName}' was not found in application.`\n );\n }\n return pkg;\n };\n\n const packageContext: PackageContextMethods = {\n getService: (packageName, interfaceName, options) => {\n const spec: InterfaceSpec = { interfaceName, ...options };\n const result = serviceLayer.getService(packageName, spec);\n if (result.type === \"found\") {\n return result.value.getInstanceOrThrow();\n }\n\n const renderedSpec = renderInterfaceSpec(spec);\n switch (result.type) {\n case \"unimplemented\":\n throw new Error(\n ErrorId.INTERFACE_NOT_FOUND,\n `The UI of package '${packageName}' requested the unimplemented interface ${renderedSpec}.`\n );\n case \"undeclared\":\n throw new Error(\n ErrorId.UNDECLARED_DEPENDENCY,\n `Package '${packageName}' did not declare an UI dependency on interface ${renderedSpec}.` +\n ` Add the dependency to the package configuration or remove the usage.`\n );\n case \"ambiguous\": {\n const renderedChoices = renderAmbiguousServiceChoices(result.choices);\n throw new Error(\n ErrorId.AMBIGUOUS_DEPENDENCY,\n `The UI of package '${packageName}' requires the ambiguous interface ${renderedSpec}.` +\n ` Possible choices are: ${renderedChoices}.`\n );\n }\n case \"unknown-package\":\n throw new Error(\n ErrorId.MISSING_PACKAGE,\n missingPackageMessage(packageName, interfaceName)\n );\n }\n },\n getServices: (packageName, interfaceName) => {\n const result = serviceLayer.getServices(packageName, interfaceName);\n if (result.type === \"found\") {\n return result.value.map((serviceRepr) => serviceRepr.getInstanceOrThrow());\n }\n\n switch (result.type) {\n case \"undeclared\":\n throw new Error(\n ErrorId.UNDECLARED_DEPENDENCY,\n `Package '${packageName}' did not declare an UI dependency on all services implementing interface '${interfaceName}'.` +\n ` Add the dependency (\"all\": true) to the package configuration or remove the usage.`\n );\n case \"unknown-package\":\n throw new Error(\n ErrorId.MISSING_PACKAGE,\n missingPackageMessage(packageName, interfaceName)\n );\n }\n },\n getProperties: (packageName) => {\n return getPackage(packageName).properties;\n },\n getIntl: (packageName) => {\n return getPackage(packageName).intl;\n }\n };\n return packageContext;\n}\n\nfunction missingPackageMessage(packageName: string, interfaceName: string) {\n return (\n `Package '${packageName}' was not found in the application's metadata while it attempted to reference the interface '${interfaceName}'. ` +\n `Check that the dependency is declared correctly in the packages that use '${packageName}'.`\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AA4BO,MAAM,gBAAA,CAAiB;AAAA,EAClB,QAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACA,MAAA;AAAA,EAER,OAAO,aAAa,OAAA,EAAoD;AACpE,IAAA,MAAM,EAAE,YAAA,EAAc,QAAA,EAAS,GAAI,OAAA;AACnC,IAAA,MAAM,cAAA,GAAiB,oBAAA,CAAqB,YAAA,EAAc,QAAQ,CAAA;AAClE,IAAA,OAAO,IAAI,gBAAA,CAAiB,EAAE,GAAG,OAAA,EAAS,gBAAgB,CAAA;AAAA,EAC9D;AAAA,EAEA,OAAO,qBACH,OAAA,EACF;AACE,IAAA,MAAM,aAAa,MAAM;AACrB,MAAA,MAAM,IAAI,KAAA,CAAM,OAAA,CAAQ,aAAA,EAAe,8CAA8C,CAAA;AAAA,IACzF,CAAA;AACA,IAAA,MAAM,cAAA,GAAwC;AAAA,MAC1C,OAAA,EAAS,UAAA;A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O,UAAA,CAAW,WAAW,CAAA,CAAE,IAAA;AAAA,IACnC;AAAA,GACJ;AACA,EAAA,OAAO,cAAA;AACX;AAEA,SAAS,qBAAA,CAAsB,aAAqB,aAAA,EAAuB;AACvE,EAAA,OACI,CAAA,SAAA,EAAY,WAAW,CAAA,6FAAA,EAAgG,aAAa,gFACvD,WAAW,CAAA,EAAA,CAAA;AAEhG;;;;"}
1
+ {"version":3,"file":"ReactIntegration.js","sources":["ReactIntegration.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { SystemConfig } from \"@chakra-ui/react\";\nimport { ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ReactNode, StrictMode } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport { RootNode } from \"../dom\";\nimport { ErrorId } from \"../errors\";\nimport { InterfaceSpec, renderInterfaceSpec } from \"../service-layer/InterfaceSpec\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport { ServiceLayer } from \"../service-layer/ServiceLayer\";\nimport { renderAmbiguousServiceChoices } from \"../service-layer/ServiceLookup\";\nimport { CustomChakraProvider } from \"./ChakraProvider\";\nimport { PackageContext, PackageContextMethods } from \"./PackageContext\";\nimport { ColorModeValue } from \"../api\";\n\nexport interface ReactIntegrationOptions {\n rootNode: RootNode;\n hostNode: HTMLElement;\n appRoot: HTMLDivElement;\n packages: Map<string, PackageRepr>;\n serviceLayer: ServiceLayer;\n\n locale: string;\n config?: ReadonlyReactive<SystemConfig | undefined>;\n styles: ReadonlyReactive<string>;\n colorMode: ReadonlyReactive<ColorModeValue>;\n}\n\nexport class ReactIntegration {\n private rootNode: RootNode;\n private hostNode: HTMLElement;\n private appRoot: HTMLDivElement;\n private reactRoot: Root;\n private packageContext: PackageContextMethods;\n private locale: string;\n private chakraConfig?: ReadonlyReactive<SystemConfig | undefined>;\n private styles: ReadonlyReactive<string>;\n private colorMode: ReadonlyReactive<ColorModeValue>;\n\n static createForApp(options: ReactIntegrationOptions): ReactIntegration {\n const { serviceLayer, packages } = options;\n const packageContext = createPackageContext(serviceLayer, packages);\n return new ReactIntegration({ ...options, packageContext });\n }\n\n static createForErrorScreen(\n options: Omit<ReactIntegrationOptions, \"serviceLayer\" | \"packages\">\n ) {\n const throwError = () => {\n throw new Error(ErrorId.INVALID_STATE, \"Hook cannot be used within the error screen.\");\n };\n const packageContext: PackageContextMethods = {\n getIntl: throwError,\n getProperties: throwError,\n getService: throwError,\n getServices: throwError\n };\n return new ReactIntegration({ ...options, packageContext });\n }\n\n private constructor(\n options: Omit<ReactIntegrationOptions, \"serviceLayer\" | \"packages\"> & {\n packageContext: PackageContextMethods;\n }\n ) {\n this.rootNode = options.rootNode;\n this.hostNode = options.hostNode;\n this.appRoot = options.appRoot;\n this.reactRoot = createRoot(options.appRoot);\n this.chakraConfig = options.config;\n this.packageContext = options.packageContext;\n this.locale = options.locale;\n this.styles = options.styles;\n this.colorMode = options.colorMode;\n }\n\n render(contentNode: ReactNode) {\n this.reactRoot.render(\n <StrictMode>\n <CustomChakraProvider\n rootNode={this.rootNode}\n hostNode={this.hostNode}\n appRoot={this.appRoot}\n config={this.chakraConfig}\n locale={this.locale}\n styles={this.styles}\n colorMode={this.colorMode}\n >\n <PackageContext.Provider value={this.packageContext}>\n {contentNode}\n </PackageContext.Provider>\n </CustomChakraProvider>\n </StrictMode>\n );\n }\n\n destroy() {\n this.reactRoot.unmount();\n }\n}\n\nexport function EmptyComponent(): ReactNode {\n return null;\n}\n\nfunction createPackageContext(\n serviceLayer: ServiceLayer,\n packages: Map<string, PackageRepr>\n): PackageContextMethods {\n const getPackage = (packageName: string): PackageRepr => {\n const pkg = packages.get(packageName);\n if (!pkg) {\n throw new Error(\n ErrorId.INTERNAL,\n `Package '${packageName}' was not found in application.`\n );\n }\n return pkg;\n };\n\n const packageContext: PackageContextMethods = {\n getService: (packageName, interfaceName, options) => {\n const spec: InterfaceSpec = { interfaceName, ...options };\n const result = serviceLayer.getService(packageName, spec);\n if (result.type === \"found\") {\n return result.value.getInstanceOrThrow();\n }\n\n const renderedSpec = renderInterfaceSpec(spec);\n switch (result.type) {\n case \"unimplemented\":\n throw new Error(\n ErrorId.INTERFACE_NOT_FOUND,\n `The UI of package '${packageName}' requested the unimplemented interface ${renderedSpec}.`\n );\n case \"undeclared\":\n throw new Error(\n ErrorId.UNDECLARED_DEPENDENCY,\n `Package '${packageName}' did not declare an UI dependency on interface ${renderedSpec}.` +\n ` Add the dependency to the package configuration or remove the usage.`\n );\n case \"ambiguous\": {\n const renderedChoices = renderAmbiguousServiceChoices(result.choices);\n throw new Error(\n ErrorId.AMBIGUOUS_DEPENDENCY,\n `The UI of package '${packageName}' requires the ambiguous interface ${renderedSpec}.` +\n ` Possible choices are: ${renderedChoices}.`\n );\n }\n case \"unknown-package\":\n throw new Error(\n ErrorId.MISSING_PACKAGE,\n missingPackageMessage(packageName, interfaceName)\n );\n }\n },\n getServices: (packageName, interfaceName) => {\n const result = serviceLayer.getServices(packageName, interfaceName);\n if (result.type === \"found\") {\n return result.value.map((serviceRepr) => serviceRepr.getInstanceOrThrow());\n }\n\n switch (result.type) {\n case \"undeclared\":\n throw new Error(\n ErrorId.UNDECLARED_DEPENDENCY,\n `Package '${packageName}' did not declare an UI dependency on all services implementing interface '${interfaceName}'.` +\n ` Add the dependency (\"all\": true) to the package configuration or remove the usage.`\n );\n case \"unknown-package\":\n throw new Error(\n ErrorId.MISSING_PACKAGE,\n missingPackageMessage(packageName, interfaceName)\n );\n }\n },\n getProperties: (packageName) => {\n return getPackage(packageName).properties;\n },\n getIntl: (packageName) => {\n return getPackage(packageName).intl;\n }\n };\n return packageContext;\n}\n\nfunction missingPackageMessage(packageName: string, interfaceName: string) {\n return (\n `Package '${packageName}' was not found in the application's metadata while it attempted to reference the interface '${interfaceName}'. ` +\n `Check that the dependency is declared correctly in the packages that use '${packageName}'.`\n );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A,KAAkB;AACzC,MAAA,MAAM,MAAA,GAAS,YAAA,CAAa,WAAA,CAAY,WAAA,EAAa,aAAa,CAAA;AAClE,MAAA,IAAI,MAAA,CAAO,SAAS,OAAA,EAAS;AACzB,QAAA,OAAO,OAAO,KAAA,CAAM,GAAA,CAAI,CAAC,WAAA,KAAgB,WAAA,CAAY,oBAAoB,CAAA;AAAA,MAC7E;AAEA,MAAA,QAAQ,OAAO,IAAA;AAAM,QACjB,KAAK,YAAA;AACD,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAA,CAAQ,qBAAA;AAAA,YACR,CAAA,SAAA,EAAY,WAAW,CAAA,2EAAA,EAA8E,aAAa,CAAA,qFAAA;AAAA,WAEtH;AAAA,QACJ,KAAK,iBAAA;AACD,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAA,CAAQ,eAAA;AAAA,YACR,qBAAA,CAAsB,aAAa,aAAa;AAAA,WACpD;AAAA;AACR,IACJ,CAAA;AAAA,IACA,aAAA,EAAe,CAAC,WAAA,KAAgB;AAC5B,MAAA,OAAO,UAAA,CAAW,WAAW,CAAA,CAAE,UAAA;AAAA,IACnC,CAAA;AAAA,IACA,OAAA,EAAS,CAAC,WAAA,KAAgB;AACtB,MAAA,OAAO,UAAA,CAAW,WAAW,CAAA,CAAE,IAAA;AAAA,IACnC;AAAA,GACJ;AACA,EAAA,OAAO,cAAA;AACX;AAEA,SAAS,qBAAA,CAAsB,aAAqB,aAAA,EAAuB;AACvE,EAAA,OACI,CAAA,SAAA,EAAY,WAAW,CAAA,6FAAA,EAAgG,aAAa,gFACvD,WAAW,CAAA,EAAA,CAAA;AAEhG;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { createLogger, Error } from '@open-pioneer/core';
2
- import { sourceId$6 as sourceId } from '../_virtual/source-info.js';
2
+ import { sourceId$4 as sourceId } from '../_virtual/source-info.js';
3
3
  import { RUNTIME_PACKAGE_NAME } from '../builtin-services/index.js';
4
4
  import { ErrorId } from '../errors.js';
5
5
  import { isSingleImplementationSpec, renderInterfaceSpec, isAllImplementationsSpec } from './InterfaceSpec.js';