@open-pioneer/runtime 4.8.0 → 4.9.0-dev.20261002130116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +189 -173
  2. package/CustomElement.d.ts +5 -5
  3. package/CustomElement.js +1 -3
  4. package/CustomElement.js.map +1 -1
  5. package/README.md +14 -6
  6. package/Service.d.ts +2 -2
  7. package/Service.js.map +1 -1
  8. package/_virtual/source-info.js +7 -5
  9. package/_virtual/source-info.js.map +1 -1
  10. package/api.d.ts +7 -8
  11. package/app/AppInstance.js +10 -6
  12. package/app/AppInstance.js.map +1 -1
  13. package/app/gatherConfig.d.ts +13 -4
  14. package/app/gatherConfig.js +23 -12
  15. package/app/gatherConfig.js.map +1 -1
  16. package/app/logErrors.js +1 -1
  17. package/builtin-services/ApplicationContextImpl.js +7 -1
  18. package/builtin-services/ApplicationContextImpl.js.map +1 -1
  19. package/builtin-services/{ApplicationLifecycleEventService.d.ts → ApplicationLifecycleEventServiceImpl.d.ts} +1 -1
  20. package/builtin-services/{ApplicationLifecycleEventService.js → ApplicationLifecycleEventServiceImpl.js} +4 -4
  21. package/builtin-services/ApplicationLifecycleEventServiceImpl.js.map +1 -0
  22. package/builtin-services/NumberParserServiceImpl.d.ts +1 -1
  23. package/builtin-services/NumberParserServiceImpl.js +3 -3
  24. package/builtin-services/NumberParserServiceImpl.js.map +1 -1
  25. package/builtin-services/index.js +2 -2
  26. package/builtin-services/index.js.map +1 -1
  27. package/dom/index.d.ts +0 -1
  28. package/dom/index.js +1 -1
  29. package/dom/index.js.map +1 -1
  30. package/i18n/AppIntl.d.ts +1 -1
  31. package/i18n/AppIntl.js +5 -10
  32. package/i18n/AppIntl.js.map +1 -1
  33. package/i18n/PackageIntl.js +2 -5
  34. package/i18n/PackageIntl.js.map +1 -1
  35. package/metadata/ObservableBox.d.ts +1 -1
  36. package/metadata/ObservableBox.js.map +1 -1
  37. package/package.json +6 -6
  38. package/react-integration/PackageContext.d.ts +1 -1
  39. package/react-integration/PackageContext.js.map +1 -1
  40. package/react-integration/hooks.d.ts +4 -4
  41. package/react-integration/hooks.js +6 -7
  42. package/react-integration/hooks.js.map +1 -1
  43. package/service-layer/PackageRepr.d.ts +1 -1
  44. package/service-layer/PackageRepr.js +1 -1
  45. package/service-layer/PackageRepr.js.map +1 -1
  46. package/service-layer/ServiceLayer.d.ts +3 -2
  47. package/service-layer/ServiceLayer.js +4 -3
  48. package/service-layer/ServiceLayer.js.map +1 -1
  49. package/service-layer/ServiceLookup.d.ts +4 -3
  50. package/service-layer/ServiceLookup.js +3 -3
  51. package/service-layer/ServiceLookup.js.map +1 -1
  52. package/service-layer/ServiceRepr.d.ts +2 -2
  53. package/service-layer/ServiceRepr.js +7 -5
  54. package/service-layer/ServiceRepr.js.map +1 -1
  55. package/builtin-services/ApplicationLifecycleEventService.js.map +0 -1
@@ -7,7 +7,7 @@ import { PackageRepr } from '../service-layer/PackageRepr.js';
7
7
  import { ServiceRepr, createFunctionFactory, createConstructorFactory } from '../service-layer/ServiceRepr.js';
8
8
  import { ApiServiceImpl } from './ApiServiceImpl.js';
9
9
  import { ApplicationContextImpl } from './ApplicationContextImpl.js';
10
- import { ApplicationLifecycleEventService } from './ApplicationLifecycleEventService.js';
10
+ import { ApplicationLifecycleEventServiceImpl } from './ApplicationLifecycleEventServiceImpl.js';
11
11
  import { LocaleServiceImpl } from './LocaleServiceImpl.js';
12
12
  import { NumberParserServiceImpl } from './NumberParserServiceImpl.js';
13
13
  import { ThemeServiceImpl } from './ThemeServiceImpl.js';
@@ -78,7 +78,7 @@ function createBuiltinPackage(properties) {
78
78
  const lifecycleEventService = new ServiceRepr({
79
79
  name: "ApplicationLifecycleEventServiceImpl",
80
80
  packageName: RUNTIME_PACKAGE_NAME,
81
- factory: createConstructorFactory(ApplicationLifecycleEventService),
81
+ factory: createConstructorFactory(ApplicationLifecycleEventServiceImpl),
82
82
  intl: constant(intl),
83
83
  interfaces: [
84
84
  {
@@ -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\n\nimport { constant } from \"@conterra/reactivity-core\";\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 {\n ApplicationContextImpl,\n ApplicationContextProperties,\n ApplicationContextServiceOptions\n} from \"./ApplicationContextImpl\";\nimport { ApplicationLifecycleEventService } from \"./ApplicationLifecycleEventService\";\nimport { LocaleServiceImpl, LocaleServiceProperties } from \"./LocaleServiceImpl\";\nimport { NumberParserServiceImpl, NumberParserServiceOptions } 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\";\nexport const RUNTIME_LOCALE_SERVICE = \"runtime.LocaleService\";\n\nexport type BuiltinPackageProperties = ApplicationContextProperties &\n ThemeServiceProperties &\n LocaleServiceProperties;\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 intl = createEmptyPackageIntl();\n\n const localeService = new ServiceRepr({\n name: \"LocaleServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(() => new LocaleServiceImpl(properties)),\n intl: constant(intl),\n interfaces: [\n {\n interfaceName: RUNTIME_LOCALE_SERVICE,\n qualifier: \"builtin\"\n }\n ]\n });\n const apiService = new ServiceRepr({\n name: \"ApiServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApiServiceImpl),\n intl: constant(intl),\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) =>\n new ApplicationContextImpl(options as ApplicationContextServiceOptions, properties)\n ),\n intl: constant(intl),\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_CONTEXT,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"localeService\",\n interfaceName: RUNTIME_LOCALE_SERVICE,\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: constant(intl),\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 as NumberParserServiceOptions)\n ),\n intl: constant(intl),\n interfaces: [\n {\n interfaceName: RUNTIME_NUMBER_PARSER_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"localeService\",\n interfaceName: RUNTIME_LOCALE_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: constant(intl),\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 localeService,\n numberParserService,\n themeService\n ],\n intl: constant(intl)\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAsBO,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,MAAM,sBAAA,GAAyB;AAgB/B,SAAS,qBAAqB,UAAA,EAAmD;AACpF,EAAA,MAAM,OAAO,sBAAA,EAAuB;AAEpC,EAAA,MAAM,aAAA,GAAgB,IAAI,WAAA,CAAY;AAAA,IAClC,IAAA,EAAM,mBAAA;AAAA,IACN,WAAA,EAAa,oBAAA;AAAA,IACb,SAAS,qBAAA,CAAsB,MAAM,IAAI,iBAAA,CAAkB,UA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,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,aAAA;AAAA,MACA,mBAAA;AAAA,MACA;AAAA,KACJ;AAAA,IACA,IAAA,EAAM,SAAS,IAAI;AAAA,GACtB,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\n\nimport { constant } from \"@conterra/reactivity-core\";\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 {\n ApplicationContextImpl,\n ApplicationContextProperties,\n ApplicationContextServiceOptions\n} from \"./ApplicationContextImpl\";\nimport { ApplicationLifecycleEventServiceImpl } from \"./ApplicationLifecycleEventServiceImpl\";\nimport { LocaleServiceImpl, LocaleServiceProperties } from \"./LocaleServiceImpl\";\nimport { NumberParserServiceImpl, NumberParserServiceOptions } 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\";\nexport const RUNTIME_LOCALE_SERVICE = \"runtime.LocaleService\";\n\nexport type BuiltinPackageProperties = ApplicationContextProperties &\n ThemeServiceProperties &\n LocaleServiceProperties;\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 intl = createEmptyPackageIntl();\n\n const localeService = new ServiceRepr({\n name: \"LocaleServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(() => new LocaleServiceImpl(properties)),\n intl: constant(intl),\n interfaces: [\n {\n interfaceName: RUNTIME_LOCALE_SERVICE,\n qualifier: \"builtin\"\n }\n ]\n });\n const apiService = new ServiceRepr({\n name: \"ApiServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApiServiceImpl),\n intl: constant(intl),\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) =>\n new ApplicationContextImpl(options as ApplicationContextServiceOptions, properties)\n ),\n intl: constant(intl),\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_CONTEXT,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"localeService\",\n interfaceName: RUNTIME_LOCALE_SERVICE,\n qualifier: \"builtin\"\n }\n ]\n });\n const lifecycleEventService = new ServiceRepr({\n name: \"ApplicationLifecycleEventServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApplicationLifecycleEventServiceImpl),\n intl: constant(intl),\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 as NumberParserServiceOptions)\n ),\n intl: constant(intl),\n interfaces: [\n {\n interfaceName: RUNTIME_NUMBER_PARSER_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"localeService\",\n interfaceName: RUNTIME_LOCALE_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: constant(intl),\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 localeService,\n numberParserService,\n themeService\n ],\n intl: constant(intl)\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAsBO,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;A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BAAA;AAAA,IACN,WAAA,EAAa,oBAAA;AAAA,IACb,SAAS,qBAAA,CAAsB,MAAM,IAAI,gBAAA,CAAiB,UAAU,CAAC,CAAA;AAAA,IACrE,IAAA,EAAM,SAAS,IAAI,CAAA;AAAA,IACnB,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,aAAA;AAAA,MACA,mBAAA;AAAA,MACA;AAAA,KACJ;AAAA,IACA,IAAA,EAAM,SAAS,IAAI;AAAA,GACtB,CAAA;AACL;;"}
package/dom/index.d.ts CHANGED
@@ -7,7 +7,6 @@ export type RootNode = Document | ShadowRoot;
7
7
  */
8
8
  export declare const APP_ROOT_CLASS = "pioneer-root";
9
9
  export declare function isShadowRoot(node: RootNode): node is ShadowRoot;
10
- export declare function isDocument(node: RootNode): node is Document;
11
10
  /**
12
11
  * Returns the parent node for <style> elements.
13
12
  */
package/dom/index.js CHANGED
@@ -7,7 +7,7 @@ function getStylesRoot(node) {
7
7
  }
8
8
  function createAppRoot() {
9
9
  const container = document.createElement("div");
10
- container.classList.add("pioneer-root");
10
+ container.classList.add(APP_ROOT_CLASS);
11
11
  container.style.minHeight = "100%";
12
12
  container.style.height = "100%";
13
13
  return container;
package/dom/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * The root node of an application.\n */\nexport type RootNode = Document | ShadowRoot;\n\n/**\n * Class of the <div> that contains the entire application.\n */\nexport const APP_ROOT_CLASS = \"pioneer-root\";\n\nexport function isShadowRoot(node: RootNode): node is ShadowRoot {\n return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && \"host\" in node;\n}\n\nexport function isDocument(node: RootNode): node is Document {\n return !isShadowRoot(node);\n}\n\n/**\n * Returns the parent node for <style> elements.\n */\nexport function getStylesRoot(node: RootNode): ShadowRoot | HTMLHeadElement {\n return isShadowRoot(node) ? node : node.head;\n}\n\n/**\n * Creates the node that contains all other application content.\n */\nexport function createAppRoot(): HTMLDivElement {\n // Setup application root node in the shadow dom\n const container = document.createElement(\"div\");\n container.classList.add(\"pioneer-root\");\n container.style.minHeight = \"100%\";\n container.style.height = \"100%\";\n return container;\n}\n\n/**\n * Returns the styles for host element (the web component node).\n */\nexport function getBuiltinStyles(rootNode: RootNode, hostElement: HTMLElement | undefined) {\n // Prevent inheritance of certain css values and normalize to display: block by default.\n // See https://open-wc.org/guides/knowledge/styling/styles-piercing-shadow-dom/\n // NOTE: layer base comes from chakra (used for css resets etc).\n const selector =\n isShadowRoot(rootNode) || !hostElement ? \":host\" : hostElement.tagName.toLowerCase();\n return `@layer base { ${selector} { all: initial; display: block; } }`;\n}\n"],"names":[],"mappings":"AAWO,MAAM,cAAA,GAAiB;AAEvB,SAAS,aAAa,IAAA,EAAoC;AAC7D,EAAA,OAAO,IAAA,CAAK,QAAA,KAAa,IAAA,CAAK,sBAAA,IAA0B,MAAA,IAAU,IAAA;AACtE;AASO,SAAS,cAAc,IAAA,EAA8C;AACxE,EAAA,OAAO,YAAA,CAAa,IAAI,CAAA,GAAI,IAAA,GAAO,IAAA,CAAK,IAAA;AAC5C;AAKO,SAAS,aAAA,GAAgC;AAE5C,EAAA,MAAM,SAAA,GAAY,QAAA,CAAS,aAAA,CAAc,KAAK,CAAA;AAC9C,EAAA,SAAA,CAAU,SAAA,CAAU,IAAI,cAAc,CAAA;AACtC,EAAA,SAAA,CAAU,MAAM,SAAA,GAAY,MAAA;AAC5B,EAAA,SAAA,CAAU,MAAM,MAAA,GAAS,MAAA;AACzB,EAAA,OAAO,SAAA;AACX;AAKO,SAAS,gBAAA,CAAiB,UAAoB,WAAA,EAAsC;AAIvF,EAAA,MAAM,QAAA,GACF,aAAa,QAAQ,CAAA,IAAK,CAAC,WAAA,GAAc,OAAA,GAAU,WAAA,CAAY,OAAA,CAAQ,WAAA,EAAY;AACvF,EAAA,OAAO,iBAAiB,QAAQ,CAAA,oCAAA,CAAA;AACpC;;"}
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\n\n/**\n * The root node of an application.\n */\nexport type RootNode = Document | ShadowRoot;\n\n/**\n * Class of the <div> that contains the entire application.\n */\nexport const APP_ROOT_CLASS = \"pioneer-root\";\n\nexport function isShadowRoot(node: RootNode): node is ShadowRoot {\n return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && \"host\" in node;\n}\n\n/**\n * Returns the parent node for <style> elements.\n */\nexport function getStylesRoot(node: RootNode): ShadowRoot | HTMLHeadElement {\n return isShadowRoot(node) ? node : node.head;\n}\n\n/**\n * Creates the node that contains all other application content.\n */\nexport function createAppRoot(): HTMLDivElement {\n // Setup application root node in the shadow dom\n const container = document.createElement(\"div\");\n container.classList.add(APP_ROOT_CLASS);\n container.style.minHeight = \"100%\";\n container.style.height = \"100%\";\n return container;\n}\n\n/**\n * Returns the styles for host element (the web component node).\n */\nexport function getBuiltinStyles(rootNode: RootNode, hostElement: HTMLElement | undefined) {\n // Prevent inheritance of certain css values and normalize to display: block by default.\n // See https://open-wc.org/guides/knowledge/styling/styles-piercing-shadow-dom/\n // NOTE: layer base comes from chakra (used for css resets etc).\n const selector =\n isShadowRoot(rootNode) || !hostElement ? \":host\" : hostElement.tagName.toLowerCase();\n return `@layer base { ${selector} { all: initial; display: block; } }`;\n}\n"],"names":[],"mappings":"AAWO,MAAM,cAAA,GAAiB;AAEvB,SAAS,aAAa,IAAA,EAAoC;AAC7D,EAAA,OAAO,IAAA,CAAK,QAAA,KAAa,IAAA,CAAK,sBAAA,IAA0B,MAAA,IAAU,IAAA;AACtE;AAKO,SAAS,cAAc,IAAA,EAA8C;AACxE,EAAA,OAAO,YAAA,CAAa,IAAI,CAAA,GAAI,IAAA,GAAO,IAAA,CAAK,IAAA;AAC5C;AAKO,SAAS,aAAA,GAAgC;AAE5C,EAAA,MAAM,SAAA,GAAY,QAAA,CAAS,aAAA,CAAc,KAAK,CAAA;AAC9C,EAAA,SAAA,CAAU,SAAA,CAAU,IAAI,cAAc,CAAA;AACtC,EAAA,SAAA,CAAU,MAAM,SAAA,GAAY,MAAA;AAC5B,EAAA,SAAA,CAAU,MAAM,MAAA,GAAS,MAAA;AACzB,EAAA,OAAO,SAAA;AACX;AAKO,SAAS,gBAAA,CAAiB,UAAoB,WAAA,EAAsC;AAIvF,EAAA,MAAM,QAAA,GACF,aAAa,QAAQ,CAAA,IAAK,CAAC,WAAA,GAAc,OAAA,GAAU,WAAA,CAAY,OAAA,CAAQ,WAAA,EAAY;AACvF,EAAA,OAAO,iBAAiB,QAAQ,CAAA,oCAAA,CAAA;AACpC;;"}
package/i18n/AppIntl.d.ts CHANGED
@@ -45,7 +45,7 @@ export declare class AppIntl {
45
45
  * Always one of {@link supportedMessageLocales}.
46
46
  */
47
47
  get messageLocale(): Intl.Locale;
48
- /** Supported locales from app metadata. */
48
+ /** Message locales the app supports after applying `restrictSupportedLocales`. */
49
49
  get supportedMessageLocales(): Intl.Locale[];
50
50
  /** True if reactive locale switching is enabled. */
51
51
  get supportsLiveChanges(): boolean;
package/i18n/AppIntl.js CHANGED
@@ -100,7 +100,7 @@ class AppIntl {
100
100
  get messageLocale() {
101
101
  return this.#messageLocale.value;
102
102
  }
103
- /** Supported locales from app metadata. */
103
+ /** Message locales the app supports after applying `restrictSupportedLocales`. */
104
104
  get supportedMessageLocales() {
105
105
  return this.#effectiveSupportedLocales;
106
106
  }
@@ -169,19 +169,14 @@ class AppIntl {
169
169
  }
170
170
  }
171
171
  function filterAvailableLocales(messageLocaleStrings, restrictSupportedLocales) {
172
- const isRestricted = restrictSupportedLocales != null;
173
172
  const localesToSupport = new Set(restrictSupportedLocales ?? messageLocaleStrings);
174
173
  const supportedLocales = [];
175
174
  for (const l of localesToSupport) {
176
175
  if (!messageLocaleStrings.includes(l)) {
177
- if (isRestricted) {
178
- throw new Error(
179
- ErrorId.UNSUPPORTED_LOCALE,
180
- `Configured supported locale '${l}' is not one of the application's message locales [${messageLocaleStrings.join(", ")}].`
181
- );
182
- }
183
- LOG.warn(`Locale '${l}' is not included in app metadata locales and will be ignored.`);
184
- continue;
176
+ throw new Error(
177
+ ErrorId.UNSUPPORTED_LOCALE,
178
+ `Configured supported locale '${l}' is not one of the application's message locales [${messageLocaleStrings.join(", ")}].`
179
+ );
185
180
  }
186
181
  const locale = tryParseLocale(l);
187
182
  if (!locale) {
@@ -1 +1 @@
1
- {"version":3,"file":"AppIntl.js","sources":["AppIntl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n batch,\n computed,\n constant,\n reactive,\n Reactive,\n ReadonlyReactive,\n watchValue\n} from \"@conterra/reactivity-core\";\nimport {\n createLogger,\n destroyResource,\n Error,\n Resource,\n shallowEqual,\n throwAbortError\n} from \"@open-pioneer/core\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { ErrorId } from \"../errors\";\nimport { ApplicationMetadata, MessageLoader, MessagesRecord } from \"../metadata\";\nimport { unwrapBox } from \"../metadata/ObservableBox\";\nimport { tryParseLocale } from \"./intl-locale\";\nimport { createPackageIntl, PackageIntl } from \"./PackageIntl\";\nimport { LocalePicker, getBrowserLocales } from \"./pick\";\n\nconst LOG = createLogger(sourceId);\n\n/**\n * Options for {@link AppIntl.create}.\n */\nexport interface I18nOptions {\n // build metadata\n appMetadata: ApplicationMetadata | undefined;\n\n // locale override (e.g. from config or URL param)\n forcedLocale?: string | undefined;\n\n /**\n * Restriction on supported locales.\n * If provided, only these locales are considered for locale picking and switching.\n * If not provided, all locales from app metadata are supported.\n */\n restrictSupportedLocales?: readonly string[];\n\n /**\n * If true, locale switching via {@link AppIntl.changeLocale} is supported and\n * applied in place (locale, messageLocale and PackageIntl instances become reactive).\n *\n * If false (default), {@link AppIntl.changeLocale} triggers an application\n * restart via {@link restartWithLocale}.\n */\n supportsLiveChanges?: boolean;\n\n /** hook given by AppInstance to trigger restart of the application. Called by changeLocale when reactive switching is OFF. */\n restartWithLocale(locale: Intl.Locale | undefined): void;\n}\n\n/**\n * Represents i18n info for the entire application.\n * Not exposed to user code.\n *\n * @internal\n */\nexport class AppIntl {\n /**\n * Initializes the application's locale and fetches the appropriate i18n messages.\n */\n static async create(options: I18nOptions): Promise<AppIntl> {\n const appIntl = new AppIntl(options);\n await appIntl.#loadInitialMessages();\n return appIntl;\n }\n\n readonly #appMetadata: ApplicationMetadata | undefined;\n readonly #effectiveSupportedLocales: Intl.Locale[];\n readonly #userLocales: Intl.Locale[];\n readonly #localePicker: LocalePicker;\n readonly #supportsLiveChanges: boolean;\n readonly #restartWithLocale: (locale: Intl.Locale | undefined) => void;\n\n // Messages are reactive: they can change if the locale changes at runtime\n // or if the developer edits i18n files on disk during development.\n readonly #messages: Reactive<MessagesRecord>;\n\n // Locale and messageLocale support reactive changes if `supportsLiveChanges` is enabled.\n readonly #locale: Reactive<Intl.Locale>;\n readonly #messageLocale: Reactive<Intl.Locale>;\n\n /** During dev: watch for changes of the loadMessage function. */\n #hmrWatch: Resource | undefined;\n\n /** Monotonic counter to discard outdated changeLocale results. */\n #changeLocaleSeq = 0;\n\n private constructor(options: I18nOptions) {\n const {\n appMetadata,\n forcedLocale,\n restrictSupportedLocales,\n supportsLiveChanges = false,\n restartWithLocale\n } = options;\n\n const messageLocaleStrings = appMetadata?.locales ?? [];\n const effectiveSupportedLocales = filterAvailableLocales(\n messageLocaleStrings,\n restrictSupportedLocales\n );\n const userLocales = getBrowserLocales();\n const preferredLocale = tryParseLocale(forcedLocale);\n if (LOG.isDebug()) {\n const userLocalesList = userLocales.map((l) => l.baseName).join(\", \");\n const appLocalesList = messageLocaleStrings.join(\", \");\n const effectiveLocalesList = effectiveSupportedLocales\n .map((l) => l.baseName)\n .join(\", \");\n LOG.debug(\n `Attempting to pick locale for user (locales: ${userLocalesList}) from app (locales: ${appLocalesList}; ` +\n `restricted to ${effectiveLocalesList}) [forcedLocale=${preferredLocale?.baseName}].`\n );\n }\n\n const localePicker = new LocalePicker(effectiveSupportedLocales);\n const { locale: initialLocale, messageLocale: initialMessageLocale } =\n localePicker.pickSupportedLocale(preferredLocale, userLocales);\n\n if (LOG.isDebug()) {\n LOG.debug(\n `Using locale '${initialLocale.baseName}' with messages from locale '${initialMessageLocale.baseName}'.`\n );\n }\n\n this.#appMetadata = appMetadata;\n this.#effectiveSupportedLocales = effectiveSupportedLocales;\n this.#userLocales = userLocales;\n this.#localePicker = localePicker;\n this.#supportsLiveChanges = supportsLiveChanges;\n this.#restartWithLocale = restartWithLocale;\n\n // Initially empty; populated by #loadInitialMessages() before the instance is handed out.\n this.#messages = reactive<MessagesRecord>({});\n this.#locale = reactive(initialLocale);\n this.#messageLocale = reactive(initialMessageLocale);\n\n // During dev: watch for changes of the loadMessage function\n // and fetch new I18N messages if the user edited any i18n file.\n if (import.meta.hot) {\n this.#hmrWatch = watchValue(\n () =>\n this.#appMetadata?.loadMessages\n ? unwrapBox(this.#appMetadata.loadMessages)\n : undefined,\n (loader) => {\n if (!loader) {\n return;\n }\n this.#applyHotUpdate(loader).catch((e) => {\n LOG.error(`Failed to load messages after hot reload`, e);\n });\n }\n );\n }\n }\n\n destroy(): void {\n this.#hmrWatch = destroyResource(this.#hmrWatch);\n }\n\n /** Locale for Intl formatting. */\n get locale(): Intl.Locale {\n return this.#locale.value;\n }\n\n /**\n * The locale of the currently loaded message bundle.\n * Always one of {@link supportedMessageLocales}.\n */\n get messageLocale(): Intl.Locale {\n return this.#messageLocale.value;\n }\n\n /** Supported locales from app metadata. */\n get supportedMessageLocales(): Intl.Locale[] {\n return this.#effectiveSupportedLocales;\n }\n\n /** True if reactive locale switching is enabled. */\n get supportsLiveChanges(): boolean {\n return this.#supportsLiveChanges;\n }\n\n /** True iff `locale` best-fits a supported bundle. */\n supportsLocale(locale: Intl.Locale): boolean {\n return this.#localePicker.supportsLocale(locale);\n }\n\n /**\n * Switches to `locale`. Best-fit match; throws `UNSUPPORTED_LOCALE` on no match.\n */\n async changeLocale(targetLocale: Intl.Locale | undefined): Promise<void> {\n const { locale: nextLocale, messageLocale: nextMessageLocale } =\n this.#localePicker.pickSupportedLocale(targetLocale, this.#userLocales);\n if (!this.#supportsLiveChanges) {\n //NOTE: it is important for restarts to ensure the input value (targetLocale) is passed to restartWithLocale, not the best-fit value (nextLocale).\n this.#restartWithLocale(targetLocale);\n return;\n }\n const seq = ++this.#changeLocaleSeq;\n const newMessages = await loadMessagesSafely(this.#appMetadata, nextMessageLocale);\n if (seq !== this.#changeLocaleSeq) {\n // Superseded by a newer call.\n throwAbortError();\n }\n\n batch(() => {\n this.#messages.value = newMessages;\n this.#locale.value = nextLocale;\n this.#messageLocale.value = nextMessageLocale;\n });\n if (LOG.isDebug()) {\n LOG.debug(\n `Locale switched: locale='${nextLocale.baseName}', messageLocale='${nextMessageLocale.baseName}'.`\n );\n }\n }\n\n /** Given the package name, constructs a package i18n instance. */\n createPackageI18n(packageName: string): ReadonlyReactive<PackageIntl> {\n //NOTE: locale instead of messageLocale is intentional,\n // to ensure that number formatting is still according to the current locale\n const makeIntl = (packageMessages: Record<string, string>) =>\n createPackageIntl(this.#locale.value.baseName, packageMessages);\n\n if (import.meta.hot || this.#supportsLiveChanges) {\n const packageMessages = computed(() => this.#messages.value[packageName] ?? {}, {\n equal: shallowEqual\n });\n\n let firstCall = true;\n return computed(() => {\n if (!firstCall) {\n LOG.info(\"Updating i18n messages of package\", packageName);\n }\n firstCall = false;\n return makeIntl(packageMessages.value);\n });\n }\n return constant(makeIntl(this.#messages.value[packageName] ?? {}));\n }\n\n /** Loads the initial message bundle for the picked locale. Called once, from {@link create}. */\n async #loadInitialMessages(): Promise<void> {\n this.#messages.value = await loadMessagesSafely(\n this.#appMetadata,\n this.#messageLocale.value\n );\n }\n\n async #applyHotUpdate(loader: MessageLoader): Promise<void> {\n const newMessages = (await loader(this.#messageLocale.value.baseName)) ?? {};\n LOG.debug(\"Applying new i18n messages\", newMessages);\n this.#messages.value = newMessages;\n }\n}\n\nfunction filterAvailableLocales(\n // locales from app metadata\n messageLocaleStrings: readonly string[],\n // optional restriction on supported locales, must be subset of messageLocaleStrings\n restrictSupportedLocales: readonly string[] | undefined\n): Intl.Locale[] {\n //NOTE: the set preserves the order of 'restrictSupportedLocales', this is relevant and intentional.\n const isRestricted = restrictSupportedLocales != null;\n const localesToSupport = new Set(restrictSupportedLocales ?? messageLocaleStrings);\n const supportedLocales: Intl.Locale[] = [];\n for (const l of localesToSupport) {\n if (!messageLocaleStrings.includes(l)) {\n // 'supportedLocales' may only restrict the locales defined by the application, not extend them.\n // A value outside the application's message locales is a configuration error.\n if (isRestricted) {\n throw new Error(\n ErrorId.UNSUPPORTED_LOCALE,\n `Configured supported locale '${l}' is not one of the application's message locales [${messageLocaleStrings.join(\", \")}].`\n );\n }\n LOG.warn(`Locale '${l}' is not included in app metadata locales and will be ignored.`);\n continue;\n }\n const locale = tryParseLocale(l);\n if (!locale) {\n LOG.warn(\n `Locale '${l}' from app metadata is not a valid BCP 47 tag and will be ignored.`\n );\n continue;\n }\n supportedLocales.push(locale);\n }\n if (supportedLocales.length === 0) {\n LOG.debug(\n `No valid supported locales found. Locale picking and switching will be unavailable.`\n );\n }\n return supportedLocales;\n}\n\nasync function loadMessagesSafely(\n appMetadata: ApplicationMetadata | undefined,\n messageLocale: Intl.Locale\n): Promise<MessagesRecord> {\n const messageLocales = appMetadata?.locales ?? [];\n if (!appMetadata?.loadMessages || !messageLocales.includes(messageLocale.baseName)) {\n return {};\n }\n\n try {\n const loader = unwrapBox(appMetadata.loadMessages);\n const messagesRecord = (await loader(messageLocale.baseName)) ?? {};\n return messagesRecord;\n } catch (e) {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to load messages for locale '${messageLocale.baseName}'.`,\n {\n cause: e\n }\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AA4BA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAsC1B,MAAM,OAAA,CAAQ;AAAA;AAAA;AAAA;AAAA,EAIjB,aAAa,OAAO,OAAA,EAAwC;AACxD,IAAA,MAAM,OAAA,GAAU,IAAI,OAAA,CAAQ,OAAO,CAAA;AACnC,IAAA,MAAM,QAAQ,oBAAA,EAAqB;AACnC,IAAA,OAAO,OAAA;AAAA,EACX;AAAA,EAES,YAAA;AAAA,EACA,0BAAA;AAAA,EACA,YAAA;AAAA,EACA,aAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA;AAAA;AAAA,EAIA,SAAA;AAAA;AAAA,EAGA,OAAA;AAAA,EACA,cAAA;AAAA;AAAA,EAGT,SAAA;AAAA;AAAA,EAGA,gBAAA,GAAmB,CAAA;AAAA,EAEX,YAAY,OAAA,EAAsB;AACtC,IAAA,MAAM;AAAA,MACF,WAAA;AAAA,MACA,YAAA;AAAA,MACA,wBAAA;AAAA,MACA,mBAAA,GAAsB,KAAA;AAAA,MACtB;AAAA,KACJ,GAAI,OAAA;AAEJ,IAAA,MAAM,oBAAA,GAAuB,WAAA,EAAa,OAAA,IAAW,EAAC;AACtD,IAAA,MAAM,yBAAA,GAA4B,sBAAA;AAAA,MAC9B,oBAAA;AAAA,MACA;AAAA,KACJ;AACA,IAAA,MAAM,cAAc,iBAAA,EAAkB;AACtC,IAAA,MA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,KAAA;AAAA,MACN,OAAA,CAAQ,QAAA;AAAA,MACR,CAAA,oCAAA,EAAuC,cAAc,QAAQ,CAAA,EAAA,CAAA;AAAA,MAC7D;AAAA,QACI,KAAA,EAAO;AAAA;AACX,KACJ;AAAA,EACJ;AACJ;;"}
1
+ {"version":3,"file":"AppIntl.js","sources":["AppIntl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n batch,\n computed,\n constant,\n reactive,\n Reactive,\n ReadonlyReactive,\n watchValue\n} from \"@conterra/reactivity-core\";\nimport {\n createLogger,\n destroyResource,\n Error,\n Resource,\n shallowEqual,\n throwAbortError\n} from \"@open-pioneer/core\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { ErrorId } from \"../errors\";\nimport { ApplicationMetadata, MessageLoader, MessagesRecord } from \"../metadata\";\nimport { unwrapBox } from \"../metadata/ObservableBox\";\nimport { tryParseLocale } from \"./intl-locale\";\nimport { createPackageIntl, PackageIntl } from \"./PackageIntl\";\nimport { LocalePicker, getBrowserLocales } from \"./pick\";\n\nconst LOG = createLogger(sourceId);\n\n/**\n * Options for {@link AppIntl.create}.\n */\nexport interface I18nOptions {\n // build metadata\n appMetadata: ApplicationMetadata | undefined;\n\n // locale override (e.g. from config or URL param)\n forcedLocale?: string | undefined;\n\n /**\n * Restriction on supported locales.\n * If provided, only these locales are considered for locale picking and switching.\n * If not provided, all locales from app metadata are supported.\n */\n restrictSupportedLocales?: readonly string[];\n\n /**\n * If true, locale switching via {@link AppIntl.changeLocale} is supported and\n * applied in place (locale, messageLocale and PackageIntl instances become reactive).\n *\n * If false (default), {@link AppIntl.changeLocale} triggers an application\n * restart via {@link restartWithLocale}.\n */\n supportsLiveChanges?: boolean;\n\n /** hook given by AppInstance to trigger restart of the application. Called by changeLocale when reactive switching is OFF. */\n restartWithLocale(locale: Intl.Locale | undefined): void;\n}\n\n/**\n * Represents i18n info for the entire application.\n * Not exposed to user code.\n *\n * @internal\n */\nexport class AppIntl {\n /**\n * Initializes the application's locale and fetches the appropriate i18n messages.\n */\n static async create(options: I18nOptions): Promise<AppIntl> {\n const appIntl = new AppIntl(options);\n await appIntl.#loadInitialMessages();\n return appIntl;\n }\n\n readonly #appMetadata: ApplicationMetadata | undefined;\n readonly #effectiveSupportedLocales: Intl.Locale[];\n readonly #userLocales: Intl.Locale[];\n readonly #localePicker: LocalePicker;\n readonly #supportsLiveChanges: boolean;\n readonly #restartWithLocale: (locale: Intl.Locale | undefined) => void;\n\n // Messages are reactive: they can change if the locale changes at runtime\n // or if the developer edits i18n files on disk during development.\n readonly #messages: Reactive<MessagesRecord>;\n\n // Locale and messageLocale support reactive changes if `supportsLiveChanges` is enabled.\n readonly #locale: Reactive<Intl.Locale>;\n readonly #messageLocale: Reactive<Intl.Locale>;\n\n /** During dev: watch for changes of the loadMessage function. */\n #hmrWatch: Resource | undefined;\n\n /** Monotonic counter to discard outdated changeLocale results. */\n #changeLocaleSeq = 0;\n\n private constructor(options: I18nOptions) {\n const {\n appMetadata,\n forcedLocale,\n restrictSupportedLocales,\n supportsLiveChanges = false,\n restartWithLocale\n } = options;\n\n const messageLocaleStrings = appMetadata?.locales ?? [];\n const effectiveSupportedLocales = filterAvailableLocales(\n messageLocaleStrings,\n restrictSupportedLocales\n );\n const userLocales = getBrowserLocales();\n const preferredLocale = tryParseLocale(forcedLocale);\n if (LOG.isDebug()) {\n const userLocalesList = userLocales.map((l) => l.baseName).join(\", \");\n const appLocalesList = messageLocaleStrings.join(\", \");\n const effectiveLocalesList = effectiveSupportedLocales\n .map((l) => l.baseName)\n .join(\", \");\n LOG.debug(\n `Attempting to pick locale for user (locales: ${userLocalesList}) from app (locales: ${appLocalesList}; ` +\n `restricted to ${effectiveLocalesList}) [forcedLocale=${preferredLocale?.baseName}].`\n );\n }\n\n const localePicker = new LocalePicker(effectiveSupportedLocales);\n const { locale: initialLocale, messageLocale: initialMessageLocale } =\n localePicker.pickSupportedLocale(preferredLocale, userLocales);\n\n if (LOG.isDebug()) {\n LOG.debug(\n `Using locale '${initialLocale.baseName}' with messages from locale '${initialMessageLocale.baseName}'.`\n );\n }\n\n this.#appMetadata = appMetadata;\n this.#effectiveSupportedLocales = effectiveSupportedLocales;\n this.#userLocales = userLocales;\n this.#localePicker = localePicker;\n this.#supportsLiveChanges = supportsLiveChanges;\n this.#restartWithLocale = restartWithLocale;\n\n // Initially empty; populated by #loadInitialMessages() before the instance is handed out.\n this.#messages = reactive<MessagesRecord>({});\n this.#locale = reactive(initialLocale);\n this.#messageLocale = reactive(initialMessageLocale);\n\n // During dev: watch for changes of the loadMessage function\n // and fetch new I18N messages if the user edited any i18n file.\n if (import.meta.hot) {\n this.#hmrWatch = watchValue(\n () =>\n this.#appMetadata?.loadMessages\n ? unwrapBox(this.#appMetadata.loadMessages)\n : undefined,\n (loader) => {\n if (!loader) {\n return;\n }\n this.#applyHotUpdate(loader).catch((e) => {\n LOG.error(`Failed to load messages after hot reload`, e);\n });\n }\n );\n }\n }\n\n destroy(): void {\n this.#hmrWatch = destroyResource(this.#hmrWatch);\n }\n\n /** Locale for Intl formatting. */\n get locale(): Intl.Locale {\n return this.#locale.value;\n }\n\n /**\n * The locale of the currently loaded message bundle.\n * Always one of {@link supportedMessageLocales}.\n */\n get messageLocale(): Intl.Locale {\n return this.#messageLocale.value;\n }\n\n /** Message locales the app supports after applying `restrictSupportedLocales`. */\n get supportedMessageLocales(): Intl.Locale[] {\n return this.#effectiveSupportedLocales;\n }\n\n /** True if reactive locale switching is enabled. */\n get supportsLiveChanges(): boolean {\n return this.#supportsLiveChanges;\n }\n\n /** True iff `locale` best-fits a supported bundle. */\n supportsLocale(locale: Intl.Locale): boolean {\n return this.#localePicker.supportsLocale(locale);\n }\n\n /**\n * Switches to `locale`. Best-fit match; throws `UNSUPPORTED_LOCALE` on no match.\n */\n async changeLocale(targetLocale: Intl.Locale | undefined): Promise<void> {\n const { locale: nextLocale, messageLocale: nextMessageLocale } =\n this.#localePicker.pickSupportedLocale(targetLocale, this.#userLocales);\n if (!this.#supportsLiveChanges) {\n //NOTE: it is important for restarts to ensure the input value (targetLocale) is passed to restartWithLocale, not the best-fit value (nextLocale).\n this.#restartWithLocale(targetLocale);\n return;\n }\n const seq = ++this.#changeLocaleSeq;\n const newMessages = await loadMessagesSafely(this.#appMetadata, nextMessageLocale);\n if (seq !== this.#changeLocaleSeq) {\n // Superseded by a newer call.\n throwAbortError();\n }\n\n batch(() => {\n this.#messages.value = newMessages;\n this.#locale.value = nextLocale;\n this.#messageLocale.value = nextMessageLocale;\n });\n if (LOG.isDebug()) {\n LOG.debug(\n `Locale switched: locale='${nextLocale.baseName}', messageLocale='${nextMessageLocale.baseName}'.`\n );\n }\n }\n\n /** Given the package name, constructs a package i18n instance. */\n createPackageI18n(packageName: string): ReadonlyReactive<PackageIntl> {\n //NOTE: locale instead of messageLocale is intentional,\n // to ensure that number formatting is still according to the current locale\n const makeIntl = (packageMessages: Record<string, string>) =>\n createPackageIntl(this.#locale.value.baseName, packageMessages);\n\n if (import.meta.hot || this.#supportsLiveChanges) {\n const packageMessages = computed(() => this.#messages.value[packageName] ?? {}, {\n equal: shallowEqual\n });\n\n let firstCall = true;\n return computed(() => {\n if (!firstCall) {\n LOG.info(\"Updating i18n messages of package\", packageName);\n }\n firstCall = false;\n return makeIntl(packageMessages.value);\n });\n }\n return constant(makeIntl(this.#messages.value[packageName] ?? {}));\n }\n\n /** Loads the initial message bundle for the picked locale. Called once, from {@link create}. */\n async #loadInitialMessages(): Promise<void> {\n this.#messages.value = await loadMessagesSafely(\n this.#appMetadata,\n this.#messageLocale.value\n );\n }\n\n async #applyHotUpdate(loader: MessageLoader): Promise<void> {\n const newMessages = (await loader(this.#messageLocale.value.baseName)) ?? {};\n LOG.debug(\"Applying new i18n messages\", newMessages);\n this.#messages.value = newMessages;\n }\n}\n\nfunction filterAvailableLocales(\n // locales from app metadata\n messageLocaleStrings: readonly string[],\n // optional restriction on supported locales, must be subset of messageLocaleStrings\n restrictSupportedLocales: readonly string[] | undefined\n): Intl.Locale[] {\n //NOTE: the set preserves the order of 'restrictSupportedLocales', this is relevant and intentional.\n const localesToSupport = new Set(restrictSupportedLocales ?? messageLocaleStrings);\n const supportedLocales: Intl.Locale[] = [];\n for (const l of localesToSupport) {\n if (!messageLocaleStrings.includes(l)) {\n // 'supportedLocales' may only restrict the locales defined by the application, not extend them.\n // A value outside the application's message locales is a configuration error.\n throw new Error(\n ErrorId.UNSUPPORTED_LOCALE,\n `Configured supported locale '${l}' is not one of the application's message locales [${messageLocaleStrings.join(\", \")}].`\n );\n }\n const locale = tryParseLocale(l);\n if (!locale) {\n LOG.warn(\n `Locale '${l}' from app metadata is not a valid BCP 47 tag and will be ignored.`\n );\n continue;\n }\n supportedLocales.push(locale);\n }\n if (supportedLocales.length === 0) {\n LOG.debug(\n `No valid supported locales found. Locale picking and switching will be unavailable.`\n );\n }\n return supportedLocales;\n}\n\nasync function loadMessagesSafely(\n appMetadata: ApplicationMetadata | undefined,\n messageLocale: Intl.Locale\n): Promise<MessagesRecord> {\n const messageLocales = appMetadata?.locales ?? [];\n if (!appMetadata?.loadMessages || !messageLocales.includes(messageLocale.baseName)) {\n return {};\n }\n\n try {\n const loader = unwrapBox(appMetadata.loadMessages);\n const messagesRecord = (await loader(messageLocale.baseName)) ?? {};\n return messagesRecord;\n } catch (e) {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to load messages for locale '${messageLocale.baseName}'.`,\n {\n cause: e\n }\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AA4BA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAsC1B,MAAM,OAAA,CAAQ;AAAA;AAAA;AAAA;AAAA,EAIjB,aAAa,OAAO,OAAA,EAAwC;AACxD,IAAA,MAAM,OAAA,GAAU,IAAI,OAAA,CAAQ,OAAO,CAAA;AACnC,IAAA,MAAM,QAAQ,oBAAA,EAAqB;AACnC,IAAA,OA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,aAAA,EACuB;AACvB,EAAA,MAAM,cAAA,GAAiB,WAAA,EAAa,OAAA,IAAW,EAAC;AAChD,EAAA,IAAI,CAAC,aAAa,YAAA,IAAgB,CAAC,eAAe,QAAA,CAAS,aAAA,CAAc,QAAQ,CAAA,EAAG;AAChF,IAAA,OAAO,EAAC;AAAA,EACZ;AAEA,EAAA,IAAI;AACA,IAAA,MAAM,MAAA,GAAS,SAAA,CAAU,WAAA,CAAY,YAAY,CAAA;AACjD,IAAA,MAAM,iBAAkB,MAAM,MAAA,CAAO,aAAA,CAAc,QAAQ,KAAM,EAAC;AAClE,IAAA,OAAO,cAAA;AAAA,EACX,SAAS,CAAA,EAAG;AACR,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,OAAA,CAAQ,QAAA;AAAA,MACR,CAAA,oCAAA,EAAuC,cAAc,QAAQ,CAAA,EAAA,CAAA;AAAA,MAC7D;AAAA,QACI,KAAA,EAAO;AAAA;AACX,KACJ;AAAA,EACJ;AACJ;;"}
@@ -29,18 +29,15 @@ const RICH_TEXT_TAGS = Object.freeze({
29
29
  "br": renderTag("br")
30
30
  });
31
31
  function formatRichMessage(intl, descriptor, values, opts) {
32
- values = {
32
+ const allValues = {
33
33
  ...RICH_TEXT_TAGS,
34
34
  ...values
35
35
  };
36
- const chunks = intl.formatMessage(descriptor, preprocessValues(values), opts);
36
+ const chunks = intl.formatMessage(descriptor, preprocessValues(allValues), opts);
37
37
  const nodes = assignKeys(chunks);
38
38
  return createElement(Fragment, void 0, ...nodes);
39
39
  }
40
40
  function preprocessValues(values) {
41
- if (!values) {
42
- return void 0;
43
- }
44
41
  const fixedValues = {};
45
42
  for (const [key, valueOrFn] of Object.entries(values)) {
46
43
  let fixedValue = valueOrFn;
@@ -1 +1 @@
1
- {"version":3,"file":"PackageIntl.js","sources":["PackageIntl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n createIntl,\n createIntlCache,\n IntlConfig,\n IntlErrorCode,\n IntlFormatters,\n IntlShape,\n MessageDescriptor,\n OnErrorFn\n} from \"@formatjs/intl\";\nimport {\n type FormatXMLElementFn,\n type Options as IntlMessageFormatOptions,\n type PrimitiveType\n} from \"intl-messageformat\"; // not a dependency, this is a dependency of formatjs\nimport { Children, createElement, Fragment, isValidElement, ReactNode } from \"react\";\n\ntype BaseIntl = Pick<IntlShape, \"locale\" | \"timeZone\"> &\n Omit<IntlFormatters<string>, \"formatMessage\">;\n\n/**\n * Gives access to the package's i18n messages for the current locale.\n *\n * See also https://formatjs.io/docs/intl\n */\nexport type PackageIntl = BaseIntl & PackageIntlExtensions;\n\n/**\n * Trails specific extensions to FormatJS' intl API.\n */\nexport interface PackageIntlExtensions {\n /**\n * Formats a message with the given descriptor and values.\n *\n * This is a method directly implemented by FormatJS see\n * - [Documentation](<https://formatjs.github.io/docs/intl/#formatmessage>)\n * - {@link IntlShape.formatMessage | Base Implementation}\n *\n * The typings here make the signature a little bit stricter: only primitive values\n * are allowed for formatting.\n *\n * If you need rich text (react) formatting, see {@link PackageIntlExtensions.formatRichMessage}.\n */\n formatMessage(\n this: void,\n descriptor: MessageDescriptor,\n values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>,\n opts?: IntlMessageFormatOptions\n ): string;\n\n /**\n * Similar to `formatMessage()`, but supports _rich text formatting_.\n *\n * React nodes are supported as input values, and custom tags can be implemented as react components.\n * Note that the output is always a single react node.\n *\n * *Example with react node as value:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Hello, {name}!\"\n * // replaces 'name' with the given react node:\n * const message = intl.formatRichMessage({ id: \"foo\"}, {\n * name: <FancyUserName />\n * });\n * return <Box>{message}</Box>;\n * }\n * ```\n *\n * *Example with basic formatting:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Hello, <strong>{name}</strong>!\"\n * // renders with actual <strong> html node:\n * return <Box>{intl.formatRichMessage({ id: \"foo\"}, { name: \"User\" })}</Box>;\n * }\n * ```\n *\n * Note that only a few basic formatting tags are predefined (\"b\", \"strong\", \"i\", \"em\", \"code\", \"br\").\n * If you need more advanced tags, you can define your own, see below.\n *\n * *Example with custom tag:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Open <foo>the door</foo>!\",\n * // renders 'foo' using the formatter function below:\n * const message = intl.formatRichMessage({ id: \"foo\"}, {\n * foo: (parts) => <FancyTag>{parts}</FancyTag>\n * });\n * return <Box>{message}</Box>;\n * }\n * ```\n */\n formatRichMessage: (\n descriptor: MessageDescriptor,\n values?: Record<string, RichTextValue>,\n opts?: IntlMessageFormatOptions\n ) => ReactNode;\n}\n\n/**\n * Value types supported when rendering rich text messages.\n * Primitive values (or single react nodes) are used for normal values.\n * Functions are used to define how tags should be rendered.\n *\n * See {@link PackageIntlExtensions.formatRichMessage}\n */\nexport type RichTextValue = PrimitiveType | ReactNode | FormatXMLElementFn<ReactNode>;\n\n/**\n * Creates a package intl instance with the given locale and messages.\n *\n * @internal\n */\nexport function createPackageIntl(\n locale: string,\n messages: Record<string, string>,\n options?: {\n /** Used during testing to suppress console messages. */\n suppressNotFoundError?: boolean;\n\n /** Also used during testing */\n defaultLocale?: string;\n }\n): PackageIntl {\n const cache = createIntlCache();\n const config: IntlConfig = {\n locale,\n messages\n };\n if (options?.suppressNotFoundError) {\n config.onError = ignoreMissingTranslationError;\n }\n if (options?.defaultLocale) {\n config.defaultLocale = options.defaultLocale;\n }\n\n const intl = createIntl(config, cache) as unknown as PackageIntl;\n intl.formatRichMessage = formatRichMessage.bind(undefined, intl);\n return intl;\n}\n\n/** Creates an empty i18n instance, e.g. for tests. */\nexport function createEmptyPackageIntl(locale = \"en\"): PackageIntl {\n return createPackageIntl(locale, {});\n}\n\nconst RICH_TEXT_TAGS = Object.freeze({\n \"b\": renderTag(\"b\"),\n \"strong\": renderTag(\"strong\"),\n \"i\": renderTag(\"i\"),\n \"em\": renderTag(\"em\"),\n \"code\": renderTag(\"code\"),\n \"br\": renderTag(\"br\")\n});\n\nfunction formatRichMessage(\n intl: PackageIntl,\n descriptor: MessageDescriptor,\n values: Record<string, RichTextValue> | undefined,\n opts: IntlMessageFormatOptions | undefined\n): ReactNode {\n values = {\n ...RICH_TEXT_TAGS,\n ...values\n };\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const chunks: any = intl.formatMessage(descriptor, preprocessValues(values) as any, opts);\n const nodes = assignKeys(chunks);\n return createElement(Fragment, undefined, ...nodes);\n}\n\nfunction preprocessValues(values: Record<string, RichTextValue> | undefined) {\n if (!values) {\n return undefined;\n }\n\n const fixedValues: Record<string, RichTextValue> = {};\n for (const [key, valueOrFn] of Object.entries(values)) {\n let fixedValue = valueOrFn;\n if (typeof valueOrFn === \"function\") {\n fixedValue = (parts) => valueOrFn(assignKeys(parts));\n }\n fixedValues[key] = fixedValue;\n }\n return fixedValues;\n}\n\nfunction renderTag(tag: string): FormatXMLElementFn<ReactNode> {\n return function renderRichTag(parts) {\n return createElement(tag, undefined, ...parts);\n };\n}\n\n// Seems to be required to get rid of \"key\" warnings.\n// See https://github.com/formatjs/formatjs/pull/4895/files\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nfunction assignKeys(chunks: any): any[] {\n const nodes = Children.map(chunks, assignKey) ?? [];\n return Children.toArray(nodes);\n}\n\nconst ANY_KEY = { key: 42 };\n\nfunction assignKey(reactNode: React.ReactNode) {\n return isValidElement(reactNode) ? createElement(Fragment, ANY_KEY, reactNode) : reactNode;\n}\n\n/** Hides missing translation errors during tests */\nconst ignoreMissingTranslationError: OnErrorFn = (err) => {\n if (err.code === IntlErrorCode.MISSING_TRANSLATION) {\n return;\n }\n\n // oxlint-disable-next-line no-console\n console.error(err);\n};\n"],"names":[],"mappings":";;;AA0HO,SAAS,iBAAA,CACZ,MAAA,EACA,QAAA,EACA,OAAA,EAOW;AACX,EAAA,MAAM,QAAQ,eAAA,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
+ {"version":3,"file":"PackageIntl.js","sources":["PackageIntl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n createIntl,\n createIntlCache,\n IntlConfig,\n IntlErrorCode,\n IntlFormatters,\n IntlShape,\n MessageDescriptor,\n OnErrorFn\n} from \"@formatjs/intl\";\nimport {\n type FormatXMLElementFn,\n type Options as IntlMessageFormatOptions,\n type PrimitiveType\n} from \"intl-messageformat\"; // not a dependency, this is a dependency of formatjs\nimport { Children, createElement, Fragment, isValidElement, ReactNode } from \"react\";\n\ntype BaseIntl = Pick<IntlShape, \"locale\" | \"timeZone\"> &\n Omit<IntlFormatters<string>, \"formatMessage\">;\n\n/**\n * Gives access to the package's i18n messages for the current locale.\n *\n * See also https://formatjs.io/docs/intl\n */\nexport type PackageIntl = BaseIntl & PackageIntlExtensions;\n\n/**\n * Trails specific extensions to FormatJS' intl API.\n */\nexport interface PackageIntlExtensions {\n /**\n * Formats a message with the given descriptor and values.\n *\n * This is a method directly implemented by FormatJS see\n * - [Documentation](<https://formatjs.github.io/docs/intl/#formatmessage>)\n * - {@link IntlShape.formatMessage | Base Implementation}\n *\n * The typings here make the signature a little bit stricter: only primitive values\n * are allowed for formatting.\n *\n * If you need rich text (react) formatting, see {@link PackageIntlExtensions.formatRichMessage}.\n */\n formatMessage(\n this: void,\n descriptor: MessageDescriptor,\n values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>,\n opts?: IntlMessageFormatOptions\n ): string;\n\n /**\n * Similar to `formatMessage()`, but supports _rich text formatting_.\n *\n * React nodes are supported as input values, and custom tags can be implemented as react components.\n * Note that the output is always a single react node.\n *\n * *Example with react node as value:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Hello, {name}!\"\n * // replaces 'name' with the given react node:\n * const message = intl.formatRichMessage({ id: \"foo\"}, {\n * name: <FancyUserName />\n * });\n * return <Box>{message}</Box>;\n * }\n * ```\n *\n * *Example with basic formatting:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Hello, <strong>{name}</strong>!\"\n * // renders with actual <strong> html node:\n * return <Box>{intl.formatRichMessage({ id: \"foo\"}, { name: \"User\" })}</Box>;\n * }\n * ```\n *\n * Note that only a few basic formatting tags are predefined (\"b\", \"strong\", \"i\", \"em\", \"code\", \"br\").\n * If you need more advanced tags, you can define your own, see below.\n *\n * *Example with custom tag:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Open <foo>the door</foo>!\",\n * // renders 'foo' using the formatter function below:\n * const message = intl.formatRichMessage({ id: \"foo\"}, {\n * foo: (parts) => <FancyTag>{parts}</FancyTag>\n * });\n * return <Box>{message}</Box>;\n * }\n * ```\n */\n formatRichMessage: (\n descriptor: MessageDescriptor,\n values?: Record<string, RichTextValue>,\n opts?: IntlMessageFormatOptions\n ) => ReactNode;\n}\n\n/**\n * Value types supported when rendering rich text messages.\n * Primitive values (or single react nodes) are used for normal values.\n * Functions are used to define how tags should be rendered.\n *\n * See {@link PackageIntlExtensions.formatRichMessage}\n */\nexport type RichTextValue = PrimitiveType | ReactNode | FormatXMLElementFn<ReactNode>;\n\n/**\n * Creates a package intl instance with the given locale and messages.\n *\n * @internal\n */\nexport function createPackageIntl(\n locale: string,\n messages: Record<string, string>,\n options?: {\n /** Used during testing to suppress console messages. */\n suppressNotFoundError?: boolean;\n\n /** Also used during testing */\n defaultLocale?: string;\n }\n): PackageIntl {\n const cache = createIntlCache();\n const config: IntlConfig = {\n locale,\n messages\n };\n if (options?.suppressNotFoundError) {\n config.onError = ignoreMissingTranslationError;\n }\n if (options?.defaultLocale) {\n config.defaultLocale = options.defaultLocale;\n }\n\n const intl = createIntl(config, cache) as unknown as PackageIntl;\n intl.formatRichMessage = formatRichMessage.bind(undefined, intl);\n return intl;\n}\n\n/** Creates an empty i18n instance, e.g. for tests. */\nexport function createEmptyPackageIntl(locale = \"en\"): PackageIntl {\n return createPackageIntl(locale, {});\n}\n\nconst RICH_TEXT_TAGS = Object.freeze({\n \"b\": renderTag(\"b\"),\n \"strong\": renderTag(\"strong\"),\n \"i\": renderTag(\"i\"),\n \"em\": renderTag(\"em\"),\n \"code\": renderTag(\"code\"),\n \"br\": renderTag(\"br\")\n});\n\nfunction formatRichMessage(\n intl: PackageIntl,\n descriptor: MessageDescriptor,\n values: Record<string, RichTextValue> | undefined,\n opts: IntlMessageFormatOptions | undefined\n): ReactNode {\n const allValues = {\n ...RICH_TEXT_TAGS,\n ...values\n };\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const chunks: any = intl.formatMessage(descriptor, preprocessValues(allValues) as any, opts);\n const nodes = assignKeys(chunks);\n return createElement(Fragment, undefined, ...nodes);\n}\n\nfunction preprocessValues(values: Record<string, RichTextValue>) {\n const fixedValues: Record<string, RichTextValue> = {};\n for (const [key, valueOrFn] of Object.entries(values)) {\n let fixedValue = valueOrFn;\n if (typeof valueOrFn === \"function\") {\n fixedValue = (parts) => valueOrFn(assignKeys(parts));\n }\n fixedValues[key] = fixedValue;\n }\n return fixedValues;\n}\n\nfunction renderTag(tag: string): FormatXMLElementFn<ReactNode> {\n return function renderRichTag(parts) {\n return createElement(tag, undefined, ...parts);\n };\n}\n\n// Seems to be required to get rid of \"key\" warnings.\n// See https://github.com/formatjs/formatjs/pull/4895/files\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nfunction assignKeys(chunks: any): any[] {\n const nodes = Children.map(chunks, assignKey) ?? [];\n return Children.toArray(nodes);\n}\n\nconst ANY_KEY = { key: 42 };\n\nfunction assignKey(reactNode: React.ReactNode) {\n return isValidElement(reactNode) ? createElement(Fragment, ANY_KEY, reactNode) : reactNode;\n}\n\n/** Hides missing translation errors during tests */\nconst ignoreMissingTranslationError: OnErrorFn = (err) => {\n if (err.code === IntlErrorCode.MISSING_TRANSLATION) {\n return;\n }\n\n // Test only, console is fine.\n // oxlint-dis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AA,EACJ;AAIA,EAAA,OAAA,CAAQ,MAAM,GAAG,CAAA;AACrB,CAAA;;"}
@@ -10,7 +10,7 @@ export interface ObservableBox<T> {
10
10
  }
11
11
  /**
12
12
  * Returns a boxed value.
13
- * In development node, the box value can be changed and observed.
13
+ * In development mode, the box value can be changed and observed.
14
14
  */
15
15
  export declare function createBox<T>(value: T): ObservableBox<T>;
16
16
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableBox.js","sources":["ObservableBox.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { reactive, Reactive } from \"@conterra/reactivity-core\";\n\nexport interface ObservableBox<T> {\n /** The current value. Reactive. */\n readonly value: T;\n\n /**\n * Changes the current value.\n *\n * Note that this function is only present during development to facilitate hot reloading.\n */\n setValue?(newValue: T): void;\n}\n\n/**\n * Returns a boxed value.\n * In development node, the box value can be changed and observed.\n */\nexport function createBox<T>(value: T): ObservableBox<T> {\n return new BoxImpl(value);\n}\n\n/** @internal */\nexport function isBox<T>(value: T | ObservableBox<T>): value is ObservableBox<T> {\n return value instanceof BoxImpl;\n}\n\n/** @internal */\nexport function unwrapBox<T>(value: T | ObservableBox<T>): T {\n return isBox(value) ? value.value : value;\n}\n\nclass BoxImpl<T> implements ObservableBox<T> {\n #signal: Reactive<T>;\n\n readonly setValue?: (newValue: T) => void;\n\n constructor(value: T) {\n this.#signal = reactive(value);\n if (import.meta.env.DEV) {\n this.setValue = (newValue) => {\n this.#signal.value = newValue;\n };\n }\n }\n\n get value(): T {\n return this.#signal.value;\n }\n}\n"],"names":[],"mappings":";;AAqBO,SAAS,UAAa,KAAA,EAA4B;AACrD,EAAA,OAAO,IAAI,QAAQ,KAAK,CAAA;AAC5B;AAGO,SAAS,MAAS,KAAA,EAAwD;AAC7E,EAAA,OAAO,KAAA,YAAiB,OAAA;AAC5B;AAGO,SAAS,UAAa,KAAA,EAAgC;AACzD,EAAA,OAAO,KAAA,CAAM,KAAK,CAAA,GAAI,KAAA,CAAM,KAAA,GAAQ,KAAA;AACxC;AAEA,MAAM,OAAA,CAAuC;AAAA,EACzC,OAAA;AAAA,EAES,QAAA;AAAA,EAET,YAAY,KAAA,EAAU;AAClB,IAAA,IAAA,CAAK,OAAA,GAAU,SAAS,KAAK,CAAA;AAC7B,IAAA,IAAI,MAAA,CAAA,IAAA,CAAY,IAAI,GAAA,EAAK;AACrB,MAAA,IAAA,CAAK,QAAA,GAAW,CAAC,QAAA,KAAa;AAC1B,QAAA,IAAA,CAAK,QAAQ,KAAA,GAAQ,QAAA;AAAA,MACzB,CAAA;AAAA,IACJ;AAAA,EACJ;AAAA,EAEA,IAAI,KAAA,GAAW;AACX,IAAA,OAAO,KAAK,OAAA,CAAQ,KAAA;AAAA,EACxB;AACJ;;"}
1
+ {"version":3,"file":"ObservableBox.js","sources":["ObservableBox.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { reactive, Reactive } from \"@conterra/reactivity-core\";\n\nexport interface ObservableBox<T> {\n /** The current value. Reactive. */\n readonly value: T;\n\n /**\n * Changes the current value.\n *\n * Note that this function is only present during development to facilitate hot reloading.\n */\n setValue?(newValue: T): void;\n}\n\n/**\n * Returns a boxed value.\n * In development mode, the box value can be changed and observed.\n */\nexport function createBox<T>(value: T): ObservableBox<T> {\n return new BoxImpl(value);\n}\n\n/** @internal */\nexport function isBox<T>(value: T | ObservableBox<T>): value is ObservableBox<T> {\n return value instanceof BoxImpl;\n}\n\n/** @internal */\nexport function unwrapBox<T>(value: T | ObservableBox<T>): T {\n return isBox(value) ? value.value : value;\n}\n\nclass BoxImpl<T> implements ObservableBox<T> {\n #signal: Reactive<T>;\n\n readonly setValue?: (newValue: T) => void;\n\n constructor(value: T) {\n this.#signal = reactive(value);\n if (import.meta.env.DEV) {\n this.setValue = (newValue) => {\n this.#signal.value = newValue;\n };\n }\n }\n\n get value(): T {\n return this.#signal.value;\n }\n}\n"],"names":[],"mappings":";;AAqBO,SAAS,UAAa,KAAA,EAA4B;AACrD,EAAA,OAAO,IAAI,QAAQ,KAAK,CAAA;AAC5B;AAGO,SAAS,MAAS,KAAA,EAAwD;AAC7E,EAAA,OAAO,KAAA,YAAiB,OAAA;AAC5B;AAGO,SAAS,UAAa,KAAA,EAAgC;AACzD,EAAA,OAAO,KAAA,CAAM,KAAK,CAAA,GAAI,KAAA,CAAM,KAAA,GAAQ,KAAA;AACxC;AAEA,MAAM,OAAA,CAAuC;AAAA,EACzC,OAAA;AAAA,EAES,QAAA;AAAA,EAET,YAAY,KAAA,EAAU;AAClB,IAAA,IAAA,CAAK,OAAA,GAAU,SAAS,KAAK,CAAA;AAC7B,IAAA,IAAI,MAAA,CAAA,IAAA,CAAY,IAAI,GAAA,EAAK;AACrB,MAAA,IAAA,CAAK,QAAA,GAAW,CAAC,QAAA,KAAa;AAC1B,QAAA,IAAA,CAAK,QAAQ,KAAA,GAAQ,QAAA;AAAA,MACzB,CAAA;AAAA,IACJ;AAAA,EACJ;AAAA,EAEA,IAAI,KAAA,GAAW;AACX,IAAA,OAAO,KAAK,OAAA,CAAQ,KAAA;AAAA,EACxB;AACJ;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/runtime",
4
- "version": "4.8.0",
4
+ "version": "4.9.0-dev.20261002130116",
5
5
  "description": "Implements the runtime environment for Open Pioneer Trails apps.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -18,11 +18,11 @@
18
18
  "@conterra/reactivity-core": "^0.8.8",
19
19
  "@emotion/cache": "^11.14.0",
20
20
  "@emotion/react": "^11.14.0",
21
- "@formatjs/intl": "^4.2.0",
22
- "@formatjs/intl-localematcher": "^0.8.13",
23
- "@open-pioneer/base-theme": "4.8.0",
24
- "@open-pioneer/core": "4.8.0",
25
- "@open-pioneer/reactivity": "4.8.0",
21
+ "@formatjs/intl": "^6.1.2",
22
+ "@formatjs/intl-localematcher": "^0.9.0",
23
+ "@open-pioneer/base-theme": "4.9.0-dev.20261002130116",
24
+ "@open-pioneer/core": "4.9.0-dev.20261002130116",
25
+ "@open-pioneer/reactivity": "4.9.0-dev.20261002130116",
26
26
  "react": "^19.3.0",
27
27
  "react-dom": "^19.3.0"
28
28
  },
@@ -6,7 +6,7 @@ export interface PackageContextMethods {
6
6
  getServices: (packageName: string, interfaceName: string) => Service[];
7
7
  getProperties: (packageName: string) => Readonly<Record<string, unknown>>;
8
8
  /**
9
- * NOTE: Reactive for fine grained i18n changes (during dev for i18n HMR) and for live local changes (also in production).
9
+ * NOTE: Reactive for fine grained i18n changes (during dev for i18n HMR) and for live locale changes (also in production).
10
10
  */
11
11
  getIntl(packageName: string): PackageIntl;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PackageContext.js","sources":["PackageContext.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { createContext } from \"react\";\nimport type { PackageIntl } from \"../i18n\";\nimport type { Service } from \"../Service\";\nimport type { UseServiceOptions } from \"./hooks\";\n\nexport interface PackageContextMethods {\n getService: (packageName: string, interfaceName: string, options: UseServiceOptions) => Service;\n getServices: (packageName: string, interfaceName: string) => Service[];\n getProperties: (packageName: string) => Readonly<Record<string, unknown>>;\n\n /**\n * NOTE: Reactive for fine grained i18n changes (during dev for i18n HMR) and for live local changes (also in production).\n */\n getIntl(packageName: string): PackageIntl;\n}\n\nexport const PackageContext = createContext<PackageContextMethods | null>(null);\n"],"names":[],"mappings":";;AAmBO,MAAM,cAAA,GAAiB,cAA4C,IAAI;;"}
1
+ {"version":3,"file":"PackageContext.js","sources":["PackageContext.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { createContext } from \"react\";\nimport type { PackageIntl } from \"../i18n\";\nimport type { Service } from \"../Service\";\nimport type { UseServiceOptions } from \"./hooks\";\n\nexport interface PackageContextMethods {\n getService: (packageName: string, interfaceName: string, options: UseServiceOptions) => Service;\n getServices: (packageName: string, interfaceName: string) => Service[];\n getProperties: (packageName: string) => Readonly<Record<string, unknown>>;\n\n /**\n * NOTE: Reactive for fine grained i18n changes (during dev for i18n HMR) and for live locale changes (also in production).\n */\n getIntl(packageName: string): PackageIntl;\n}\n\nexport const PackageContext = createContext<PackageContextMethods | null>(null);\n"],"names":[],"mappings":";;AAmBO,MAAM,cAAA,GAAiB,cAA4C,IAAI;;"}
@@ -11,7 +11,7 @@ export interface UseServiceOptions {
11
11
  * This is an internal hook that is typically called indirectly via the hook
12
12
  * provided from `"open-pioneer:react-hooks"`.
13
13
  *
14
- * @private
14
+ * @internal
15
15
  */
16
16
  export declare function useServiceInternal<ServiceType = unknown>(packageName: string, interfaceName: InterfaceNameForServiceType<ServiceType>, options?: UseServiceOptions): ServiceType;
17
17
  /**
@@ -21,7 +21,7 @@ export declare function useServiceInternal<ServiceType = unknown>(packageName: s
21
21
  * This is an internal hook that is typically called indirectly via the hook
22
22
  * provided from `"open-pioneer:react-hooks"`.
23
23
  *
24
- * @private
24
+ * @internal
25
25
  */
26
26
  export declare function useServicesInternal<ServiceType = unknown>(packageName: string, interfaceName: InterfaceNameForServiceType<ServiceType>, options?: UseServiceOptions): ServiceType[];
27
27
  /**
@@ -30,7 +30,7 @@ export declare function useServicesInternal<ServiceType = unknown>(packageName:
30
30
  * This is an internal hook that is typically called indirectly via the hook
31
31
  * provided from `"open-pioneer:react-hooks"`.
32
32
  *
33
- * @private
33
+ * @internal
34
34
  */
35
35
  export declare function usePropertiesInternal(packageName: string): Readonly<Record<string, unknown>>;
36
36
  /**
@@ -39,6 +39,6 @@ export declare function usePropertiesInternal(packageName: string): Readonly<Rec
39
39
  * This is an internal hook that is typically called indirectly via the hook
40
40
  * provided from `"open-pioneer:react-hooks"`.
41
41
  *
42
- * @private
42
+ * @internal
43
43
  */
44
44
  export declare function useIntlInternal(packageName: string): PackageIntl;
@@ -6,13 +6,12 @@ import { PackageContext } from './PackageContext.js';
6
6
 
7
7
  function useServiceInternal(packageName, interfaceName, options) {
8
8
  const context = useContext(PackageContext);
9
+ const qualifier = options?.qualifier;
9
10
  const service = useMemo(
10
- () => checkContext("useService", context).getService(
11
- packageName,
12
- interfaceName,
13
- options ?? {}
14
- ),
15
- [context, packageName, interfaceName, options]
11
+ () => checkContext("useService", context).getService(packageName, interfaceName, {
12
+ qualifier
13
+ }),
14
+ [context, packageName, interfaceName, qualifier]
16
15
  );
17
16
  return service;
18
17
  }
@@ -41,7 +40,7 @@ function checkContext(hookName, contextData) {
41
40
  if (!contextData) {
42
41
  throw new Error(
43
42
  ErrorId.INTERNAL,
44
- `"Failed to access package context from '${hookName}': react integration was not set up properly.`
43
+ `Failed to access package context from '${hookName}': react integration was not set up properly.`
45
44
  );
46
45
  }
47
46
  return contextData;
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sources":["hooks.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Error } from \"@open-pioneer/core\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport { useContext, useMemo } from \"react\";\nimport { InterfaceNameForServiceType } from \"../DeclaredService\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl } from \"../i18n\";\nimport { PackageContext, PackageContextMethods } from \"./PackageContext\";\n\n/*\n\n IMPORTANT\n =========\n\n The functions in this file are part of the public API, although they should not be called directly.\n They are imported by code generated during separate package compilation generation via:\n\n import { hookName } from '@open-pioneer/runtime/react-integration'\n\n They are also imported by the vite plugin during development and when building an application.\n\n The matching exports are in the neighboring `index.ts`.\n The interfaces of these hooks must remain stable so that already published packages can continue to work in the future.\n\n See also the implementation of @open-pioneer/build-package.\n\n*/\n\nexport interface UseServiceOptions {\n /** An additional qualifier to disambiguate service instances that implement the same interface. */\n qualifier?: string;\n}\n\n/**\n * Returns a service that implements the given interface.\n * Receives the package name of the importing package as a string.\n *\n * This is an internal hook that is typically called indirectly via the hook\n * provided from `\"open-pioneer:react-hooks\"`.\n *\n * @private\n */\nexport function useServiceInternal<ServiceType = unknown>(\n packageName: string,\n interfaceName: InterfaceNameForServiceType<ServiceType>,\n options?: UseServiceOptions\n): ServiceType;\nexport function useServiceInternal(\n packageName: string,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n interfaceName: any,\n options?: UseServiceOptions\n): unknown {\n const context = useContext(PackageContext);\n const service = useMemo(\n () =>\n checkContext(\"useService\", context).getService(\n packageName,\n interfaceName,\n options ?? {}\n ),\n [context, packageName, interfaceName, options]\n );\n return service;\n}\n\n/**\n * Returns all services that implement the given interface.\n * Receives the package name of the importing package as a string.\n *\n * This is an internal hook that is typically called indirectly via the hook\n * provided from `\"open-pioneer:react-hooks\"`.\n *\n * @private\n */\nexport function useServicesInternal<ServiceType = unknown>(\n packageName: string,\n interfaceName: InterfaceNameForServiceType<ServiceType>,\n options?: UseServiceOptions\n): ServiceType[];\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport function useServicesInternal(packageName: string, interfaceName: any): unknown[] {\n const context = useContext(PackageContext);\n const services = useMemo(\n () => checkContext(\"useServices\", context).getServices(packageName, interfaceName),\n [context, packageName, interfaceName]\n );\n return services;\n}\n\n/**\n * Returns the properties for the given package.\n *\n * This is an internal hook that is typically called indirectly via the hook\n * provided from `\"open-pioneer:react-hooks\"`.\n *\n * @private\n */\nexport function usePropertiesInternal(packageName: string): Readonly<Record<string, unknown>> {\n const context = useContext(PackageContext);\n return checkContext(\"useProperties\", context).getProperties(packageName);\n}\n\n/**\n * Returns the i18n object for the given package.\n *\n * This is an internal hook that is typically called indirectly via the hook\n * provided from `\"open-pioneer:react-hooks\"`.\n *\n * @private\n */\nexport function useIntlInternal(packageName: string): PackageIntl {\n const context = useContext(PackageContext);\n const contextData = checkContext(\"useIntl\", context);\n const intl = useReactiveSnapshot(\n () => contextData.getIntl(packageName),\n [packageName, contextData]\n );\n return intl;\n}\n\nfunction checkContext(\n hookName: string,\n contextData: PackageContextMethods | null\n): PackageContextMethods {\n if (!contextData) {\n throw new Error(\n ErrorId.INTERNAL,\n `\"Failed to access package context from '${hookName}': react integration was not set up properly.`\n );\n }\n return contextData;\n}\n"],"names":[],"mappings":";;;;;;AAiDO,SAAS,kBAAA,CACZ,WAAA,EAEA,aAAA,EACA,OAAA,EACO;AACP,EAAA,MAAM,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,MAAM,OAAA,GAAU,OAAA;AAAA,IACZ,MACI,YAAA,CAAa,YAAA,EAAc,OAAO,CAAA,CAAE,UAAA;AAAA,MAChC,WAAA;AAAA,MACA,aAAA;AAAA,MACA,WAAW;AAAC,KAChB;AAAA,IACJ,CAAC,OAAA,EAAS,WAAA,EAAa,aAAA,EAAe,OAAO;AAAA,GACjD;AACA,EAAA,OAAO,OAAA;AACX;AAiBO,SAAS,mBAAA,CAAoB,aAAqB,aAAA,EAA+B;AACpF,EAAA,MAAM,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,MAAM,QAAA,GAAW,OAAA;AAAA,IACb,MAAM,YAAA,CAAa,aAAA,EAAe,OAAO,CAAA,CAAE,WAAA,CAAY,aAAa,aAAa,CAAA;AAAA,IACjF,CAAC,OAAA,EAAS,WAAA,EAAa,aAAa;AAAA,GACxC;AACA,EAAA,OAAO,QAAA;AACX;AAUO,SAAS,sBAAsB,WAAA,EAAwD;AAC1F,EAAA,MAAM,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,OAAO,YAAA,CAAa,eAAA,EAAiB,OAAO,CAAA,CAAE,cAAc,WAAW,CAAA;AAC3E;AAUO,SAAS,gBAAgB,WAAA,EAAkC;AAC9D,EAAA,MAAM,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,MAAM,WAAA,GAAc,YAAA,CAAa,SAAA,EAAW,OAAO,CAAA;AACnD,EAAA,MAAM,IAAA,GAAO,mBAAA;AAAA,IACT,MAAM,WAAA,CAAY,OAAA,CAAQ,WAAW,CAAA;AAAA,IACrC,CAAC,aAAa,WAAW;AAAA,GAC7B;AACA,EAAA,OAAO,IAAA;AACX;AAEA,SAAS,YAAA,CACL,UACA,WAAA,EACqB;AACrB,EAAA,IAAI,CAAC,WAAA,EAAa;AACd,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,OAAA,CAAQ,QAAA;AAAA,MACR,2CAA2C,QAAQ,CAAA,6CAAA;AAAA,KACvD;AAAA,EACJ;AACA,EAAA,OAAO,WAAA;AACX;;"}
1
+ {"version":3,"file":"hooks.js","sources":["hooks.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Error } from \"@open-pioneer/core\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport { useContext, useMemo } from \"react\";\nimport { InterfaceNameForServiceType } from \"../DeclaredService\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl } from \"../i18n\";\nimport { PackageContext, PackageContextMethods } from \"./PackageContext\";\n\n/*\n The functions in this file are part of the public API, although they should not be called directly.\n They are imported by code generated during separate package compilation generation via:\n\n import { hookName } from '@open-pioneer/runtime/react-integration'\n\n They are also imported by the vite plugin during development and when building an application.\n\n The matching exports are in the neighboring `index.ts`.\n The interfaces of these hooks must remain stable so that already published packages can continue to work in the future.\n\n See also the implementation of @open-pioneer/build-package.\n\n*/\n\nexport interface UseServiceOptions {\n /** An additional qualifier to disambiguate service instances that implement the same interface. */\n qualifier?: string;\n}\n\n/**\n * Returns a service that implements the given interface.\n * Receives the package name of the importing package as a string.\n *\n * This is an internal hook that is typically called indirectly via the hook\n * provided from `\"open-pioneer:react-hooks\"`.\n *\n * @internal\n */\nexport function useServiceInternal<ServiceType = unknown>(\n packageName: string,\n interfaceName: InterfaceNameForServiceType<ServiceType>,\n options?: UseServiceOptions\n): ServiceType;\nexport function useServiceInternal(\n packageName: string,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n interfaceName: any,\n options?: UseServiceOptions\n): unknown {\n const context = useContext(PackageContext);\n const qualifier = options?.qualifier;\n const service = useMemo(\n () =>\n checkContext(\"useService\", context).getService(packageName, interfaceName, {\n qualifier\n }),\n [context, packageName, interfaceName, qualifier]\n );\n return service;\n}\n\n/**\n * Returns all services that implement the given interface.\n * Receives the package name of the importing package as a string.\n *\n * This is an internal hook that is typically called indirectly via the hook\n * provided from `\"open-pioneer:react-hooks\"`.\n *\n * @internal\n */\nexport function useServicesInternal<ServiceType = unknown>(\n packageName: string,\n interfaceName: InterfaceNameForServiceType<ServiceType>,\n options?: UseServiceOptions\n): ServiceType[];\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport function useServicesInternal(packageName: string, interfaceName: any): unknown[] {\n const context = useContext(PackageContext);\n const services = useMemo(\n () => checkContext(\"useServices\", context).getServices(packageName, interfaceName),\n [context, packageName, interfaceName]\n );\n return services;\n}\n\n/**\n * Returns the properties for the given package.\n *\n * This is an internal hook that is typically called indirectly via the hook\n * provided from `\"open-pioneer:react-hooks\"`.\n *\n * @internal\n */\nexport function usePropertiesInternal(packageName: string): Readonly<Record<string, unknown>> {\n const context = useContext(PackageContext);\n return checkContext(\"useProperties\", context).getProperties(packageName);\n}\n\n/**\n * Returns the i18n object for the given package.\n *\n * This is an internal hook that is typically called indirectly via the hook\n * provided from `\"open-pioneer:react-hooks\"`.\n *\n * @internal\n */\nexport function useIntlInternal(packageName: string): PackageIntl {\n const context = useContext(PackageContext);\n const contextData = checkContext(\"useIntl\", context);\n const intl = useReactiveSnapshot(\n () => contextData.getIntl(packageName),\n [packageName, contextData]\n );\n return intl;\n}\n\nfunction checkContext(\n hookName: string,\n contextData: PackageContextMethods | null\n): PackageContextMethods {\n if (!contextData) {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to access package context from '${hookName}': react integration was not set up properly.`\n );\n }\n return contextData;\n}\n"],"names":[],"mappings":";;;;;;AA6CO,SAAS,kBAAA,CACZ,WAAA,EAEA,aAAA,EACA,OAAA,EACO;AACP,EAAA,MAAM,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,MAAM,YAAY,OAAA,EAAS,SAAA;AAC3B,EAAA,MAAM,OAAA,GAAU,OAAA;AAAA,IACZ,MACI,YAAA,CAAa,YAAA,EAAc,OAAO,CAAA,CAAE,UAAA,CAAW,aAAa,aAAA,EAAe;AAAA,MACvE;AAAA,KACH,CAAA;AAAA,IACL,CAAC,OAAA,EAAS,WAAA,EAAa,aAAA,EAAe,SAAS;AAAA,GACnD;AACA,EAAA,OAAO,OAAA;AACX;AAiBO,SAAS,mBAAA,CAAoB,aAAqB,aAAA,EAA+B;AACpF,EAAA,MAAM,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,MAAM,QAAA,GAAW,OAAA;AAAA,IACb,MAAM,YAAA,CAAa,aAAA,EAAe,OAAO,CAAA,CAAE,WAAA,CAAY,aAAa,aAAa,CAAA;AAAA,IACjF,CAAC,OAAA,EAAS,WAAA,EAAa,aAAa;AAAA,GACxC;AACA,EAAA,OAAO,QAAA;AACX;AAUO,SAAS,sBAAsB,WAAA,EAAwD;AAC1F,EAAA,MAAM,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,OAAO,YAAA,CAAa,eAAA,EAAiB,OAAO,CAAA,CAAE,cAAc,WAAW,CAAA;AAC3E;AAUO,SAAS,gBAAgB,WAAA,EAAkC;AAC9D,EAAA,MAAM,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,MAAM,WAAA,GAAc,YAAA,CAAa,SAAA,EAAW,OAAO,CAAA;AACnD,EAAA,MAAM,IAAA,GAAO,mBAAA;AAAA,IACT,MAAM,WAAA,CAAY,OAAA,CAAQ,WAAW,CAAA;AAAA,IACrC,CAAC,aAAa,WAAW;AAAA,GAC7B;AACA,EAAA,OAAO,IAAA;AACX;AAEA,SAAS,YAAA,CACL,UACA,WAAA,EACqB;AACrB,EAAA,IAAI,CAAC,WAAA,EAAa;AACd,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,OAAA,CAAQ,QAAA;AAAA,MACR,0CAA0C,QAAQ,CAAA,6CAAA;AAAA,KACtD;AAAA,EACJ;AACA,EAAA,OAAO,WAAA;AACX;;"}
@@ -21,7 +21,7 @@ export declare class PackageRepr {
21
21
  readonly uiReferences: readonly Readonly<ReferenceSpec>[];
22
22
  /** Resolved (perhaps customized) package properties. */
23
23
  readonly properties: Readonly<Record<string, unknown>>;
24
- /** Locale-dependant i18n messages. */
24
+ /** Locale-dependent i18n messages. */
25
25
  readonly intl: ReadonlyReactive<PackageIntl>;
26
26
  constructor(options: PackageReprOptions);
27
27
  }
@@ -36,7 +36,7 @@ class PackageRepr {
36
36
  uiReferences;
37
37
  /** Resolved (perhaps customized) package properties. */
38
38
  properties;
39
- /** Locale-dependant i18n messages. */
39
+ /** Locale-dependent i18n messages. */
40
40
  intl;
41
41
  constructor(options) {
42
42
  const name = options.name;
@@ -1 +1 @@
1
- {"version":3,"file":"PackageRepr.js","sources":["PackageRepr.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ApplicationProperties } from \"../CustomElement\";\nimport { ErrorId } from \"../errors\";\nimport { AppIntl, PackageIntl } from \"../i18n\";\nimport { PackageMetadata, PropertyMetadata } from \"../metadata\";\nimport { parseReferenceSpec, ReferenceSpec } from \"./InterfaceSpec\";\nimport { ServiceRepr } from \"./ServiceRepr\";\n\nexport interface PackageReprOptions {\n name: string;\n intl: ReadonlyReactive<PackageIntl>;\n services?: ServiceRepr[];\n uiReferences?: ReferenceSpec[];\n properties?: Record<string, unknown>;\n}\n\nexport class PackageRepr {\n static create(\n data: PackageMetadata,\n intl: ReadonlyReactive<PackageIntl>,\n customProperties?: Record<string, unknown>\n ): PackageRepr {\n const name = data.name;\n const properties = data.properties ?? {};\n const finalProperties = customizeProperties(name, properties, customProperties);\n const services = Object.entries(data.services ?? {}).map<ServiceRepr>(\n ([name, serviceData]) => {\n if (name !== serviceData.name) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n \"Invalid metadata: service name mismatch.\"\n );\n }\n return ServiceRepr.create(data.name, serviceData, intl, finalProperties);\n }\n );\n const uiReferences = data.ui?.references?.map((ref) => parseReferenceSpec(ref)) ?? [];\n return new PackageRepr({\n name,\n services,\n uiReferences,\n properties: finalProperties,\n intl: intl\n });\n }\n\n /** Package name */\n readonly name: string;\n\n /** Services defined by the package */\n readonly services: readonly ServiceRepr[];\n\n /** Interfaces required by UI components. */\n readonly uiReferences: readonly Readonly<ReferenceSpec>[];\n\n /** Resolved (perhaps customized) package properties. */\n readonly properties: Readonly<Record<string, unknown>>;\n\n /** Locale-dependant i18n messages. */\n readonly intl: ReadonlyReactive<PackageIntl>;\n\n constructor(options: PackageReprOptions) {\n const name = options.name;\n if (!isValidPackageName(name)) {\n throw new Error(ErrorId.INTERNAL, `Invalid package name: '${name}'.`);\n }\n\n this.name = name;\n this.services = options.services ?? [];\n this.uiReferences = options.uiReferences ?? [];\n this.properties = options.properties ?? {};\n this.intl = options.intl;\n }\n}\n\nexport function createPackages(\n packages: Record<string, PackageMetadata>,\n i18n: AppIntl,\n customProperties?: ApplicationProperties\n) {\n return Object.entries(packages).map<PackageRepr>(([name, packageMetadata]) => {\n if (name !== packageMetadata.name) {\n throw new Error(ErrorId.INVALID_METADATA, \"Invalid metadata: package name mismatch.\");\n }\n\n const packageI18n = i18n.createPackageI18n(name);\n return PackageRepr.create(packageMetadata, packageI18n, customProperties?.[name]);\n });\n}\n\n/**\n * Merges the declared properties of the package with the application-defined\n * custom properties.\n */\nfunction customizeProperties(\n packageName: string,\n properties: Record<string, PropertyMetadata>,\n customProperties: Record<string, unknown> = {}\n) {\n const merged: Record<string, unknown> = {};\n const required: string[] = [];\n for (const [key, propertyMetadata] of Object.entries(properties)) {\n merged[key] = propertyMetadata.value;\n if (propertyMetadata.required) {\n required.push(key);\n }\n }\n\n for (const [key, value] of Object.entries(customProperties)) {\n if (!hasProperty(merged, key)) {\n throw new Error(\n ErrorId.INVALID_PROPERTY_NAME,\n `Unexpected property name '${key}' for package '${packageName}': the property does not exist.`\n );\n }\n merged[key] = value;\n }\n\n for (const key of required) {\n const value = merged[key];\n if (value == null) {\n throw new Error(\n ErrorId.REQUIRED_PROPERTY,\n `Package '${packageName}' requires the property '${key}' to be initialized to a non-null value.`\n );\n }\n }\n\n return merged;\n}\n\nconst HAS_PROP = Object.prototype.hasOwnProperty;\n\nfunction hasProperty(object: unknown, key: string) {\n return HAS_PROP.call(object, key);\n}\n\n// http://json.schemastore.org/package\nconst NAME_REGEX = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/;\n\nfunction isValidPackageName(name: string): boolean {\n return NAME_REGEX.test(name);\n}\n"],"names":["name"],"mappings":";;;;;AAoBO,MAAM,WAAA,CAAY;AAAA,EACrB,OAAO,MAAA,CACH,IAAA,EACA,IAAA,EACA,gBAAA,EACW;AACX,IAAA,MAAM,OAAO,IAAA,CAAK,IAAA;AAClB,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,UAAA,IAAc,EAAC;AACvC,IAAA,MAAM,eAAA,GAAkB,mBAAA,CAAoB,IAAA,EAAM,UAAA,EAAY,gBAAgB,CAAA;AAC9E,IAAA,MAAM,WAAW,MAAA,CAAO,OAAA,CAAQ,KAAK,QAAA,IAAY,EAAE,CAAA,CAAE,GAAA;AAAA,MACjD,CAAC,CAACA,KAAAA,EAAM,WAAW,CAAA,KAAM;AAC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AAA,IACJ;AACA,IAAA,MAAA,CAAO,GAAG,CAAA,GAAI,KAAA;AAAA,EAClB;AAEA,EAAA,KAAA,MAAW,OAAO,QAAA,EAAU;AACxB,IAAA,MAAM,KAAA,GAAQ,OAAO,GAAG,CAAA;AACxB,IAAA,IAAI,SAAS,IAAA,EAAM;AACf,MAAA,MAAM,IAAI,KAAA;AAAA,QACN,OAAA,CAAQ,iBAAA;AAAA,QACR,CAAA,SAAA,EAAY,WAAW,CAAA,yBAAA,EAA4B,GAAG,CAAA,wCAAA;AAAA,OAC1D;AAAA,IACJ;AAAA,EACJ;AAEA,EAAA,OAAO,MAAA;AACX;AAEA,MAAM,QAAA,GAAW,OAAO,SAAA,CAAU,cAAA;AAElC,SAAS,WAAA,CAAY,QAAiB,GAAA,EAAa;AAC/C,EAAA,OAAO,QAAA,CAAS,IAAA,CAAK,MAAA,EAAQ,GAAG,CAAA;AACpC;AAGA,MAAM,UAAA,GAAa,4DAAA;AAEnB,SAAS,mBAAmB,IAAA,EAAuB;AAC/C,EAAA,OAAO,UAAA,CAAW,KAAK,IAAI,CAAA;AAC/B;;"}
1
+ {"version":3,"file":"PackageRepr.js","sources":["PackageRepr.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ApplicationProperties } from \"../CustomElement\";\nimport { ErrorId } from \"../errors\";\nimport { AppIntl, PackageIntl } from \"../i18n\";\nimport { PackageMetadata, PropertyMetadata } from \"../metadata\";\nimport { parseReferenceSpec, ReferenceSpec } from \"./InterfaceSpec\";\nimport { ServiceRepr } from \"./ServiceRepr\";\n\nexport interface PackageReprOptions {\n name: string;\n intl: ReadonlyReactive<PackageIntl>;\n services?: ServiceRepr[];\n uiReferences?: ReferenceSpec[];\n properties?: Record<string, unknown>;\n}\n\nexport class PackageRepr {\n static create(\n data: PackageMetadata,\n intl: ReadonlyReactive<PackageIntl>,\n customProperties?: Record<string, unknown>\n ): PackageRepr {\n const name = data.name;\n const properties = data.properties ?? {};\n const finalProperties = customizeProperties(name, properties, customProperties);\n const services = Object.entries(data.services ?? {}).map<ServiceRepr>(\n ([name, serviceData]) => {\n if (name !== serviceData.name) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n \"Invalid metadata: service name mismatch.\"\n );\n }\n return ServiceRepr.create(data.name, serviceData, intl, finalProperties);\n }\n );\n const uiReferences = data.ui?.references?.map((ref) => parseReferenceSpec(ref)) ?? [];\n return new PackageRepr({\n name,\n services,\n uiReferences,\n properties: finalProperties,\n intl: intl\n });\n }\n\n /** Package name */\n readonly name: string;\n\n /** Services defined by the package */\n readonly services: readonly ServiceRepr[];\n\n /** Interfaces required by UI components. */\n readonly uiReferences: readonly Readonly<ReferenceSpec>[];\n\n /** Resolved (perhaps customized) package properties. */\n readonly properties: Readonly<Record<string, unknown>>;\n\n /** Locale-dependent i18n messages. */\n readonly intl: ReadonlyReactive<PackageIntl>;\n\n constructor(options: PackageReprOptions) {\n const name = options.name;\n if (!isValidPackageName(name)) {\n throw new Error(ErrorId.INTERNAL, `Invalid package name: '${name}'.`);\n }\n\n this.name = name;\n this.services = options.services ?? [];\n this.uiReferences = options.uiReferences ?? [];\n this.properties = options.properties ?? {};\n this.intl = options.intl;\n }\n}\n\nexport function createPackages(\n packages: Record<string, PackageMetadata>,\n i18n: AppIntl,\n customProperties?: ApplicationProperties\n) {\n return Object.entries(packages).map<PackageRepr>(([name, packageMetadata]) => {\n if (name !== packageMetadata.name) {\n throw new Error(ErrorId.INVALID_METADATA, \"Invalid metadata: package name mismatch.\");\n }\n\n const packageI18n = i18n.createPackageI18n(name);\n return PackageRepr.create(packageMetadata, packageI18n, customProperties?.[name]);\n });\n}\n\n/**\n * Merges the declared properties of the package with the application-defined\n * custom properties.\n */\nfunction customizeProperties(\n packageName: string,\n properties: Record<string, PropertyMetadata>,\n customProperties: Record<string, unknown> = {}\n) {\n const merged: Record<string, unknown> = {};\n const required: string[] = [];\n for (const [key, propertyMetadata] of Object.entries(properties)) {\n merged[key] = propertyMetadata.value;\n if (propertyMetadata.required) {\n required.push(key);\n }\n }\n\n for (const [key, value] of Object.entries(customProperties)) {\n if (!hasProperty(merged, key)) {\n throw new Error(\n ErrorId.INVALID_PROPERTY_NAME,\n `Unexpected property name '${key}' for package '${packageName}': the property does not exist.`\n );\n }\n merged[key] = value;\n }\n\n for (const key of required) {\n const value = merged[key];\n if (value == null) {\n throw new Error(\n ErrorId.REQUIRED_PROPERTY,\n `Package '${packageName}' requires the property '${key}' to be initialized to a non-null value.`\n );\n }\n }\n\n return merged;\n}\n\nconst HAS_PROP = Object.prototype.hasOwnProperty;\n\nfunction hasProperty(object: unknown, key: string) {\n return HAS_PROP.call(object, key);\n}\n\n// http://json.schemastore.org/package\nconst NAME_REGEX = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/;\n\nfunction isValidPackageName(name: string): boolean {\n return NAME_REGEX.test(name);\n}\n"],"names":["name"],"mappings":";;;;;AAoBO,MAAM,WAAA,CAAY;AAAA,EACrB,OAAO,MAAA,CACH,IAAA,EACA,IAAA,EACA,gBAAA,EACW;AACX,IAAA,MAAM,OAAO,IAAA,CAAK,IAAA;AAClB,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,UAAA,IAAc,EAAC;AACvC,IAAA,MAAM,eAAA,GAAkB,mBAAA,CAAoB,IAAA,EAAM,UAAA,EAAY,gBAAgB,CAAA;AAC9E,IAAA,MAAM,WAAW,MAAA,CAAO,OAAA,CAAQ,KAAK,QAAA,IAAY,EAAE,CAAA,CAAE,GAAA;AAAA,MACjD,CAAC,CAACA,KAAAA,EAAM,WAAW,CAAA,KAAM;AACrB,QAAA,IAAIA,KAAAA,KAAS,YAAY,IAAA,EAAM;AAC3B,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAA,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AO,QAAA,EAAU;AACxB,IAAA,MAAM,KAAA,GAAQ,OAAO,GAAG,CAAA;AACxB,IAAA,IAAI,SAAS,IAAA,EAAM;AACf,MAAA,MAAM,IAAI,KAAA;AAAA,QACN,OAAA,CAAQ,iBAAA;AAAA,QACR,CAAA,SAAA,EAAY,WAAW,CAAA,yBAAA,EAA4B,GAAG,CAAA,wCAAA;AAAA,OAC1D;AAAA,IACJ;AAAA,EACJ;AAEA,EAAA,OAAO,MAAA;AACX;AAEA,MAAM,QAAA,GAAW,OAAO,SAAA,CAAU,cAAA;AAElC,SAAS,WAAA,CAAY,QAAiB,GAAA,EAAa;AAC/C,EAAA,OAAO,QAAA,CAAS,IAAA,CAAK,MAAA,EAAQ,GAAG,CAAA;AACpC;AAGA,MAAM,UAAA,GAAa,4DAAA;AAEnB,SAAS,mBAAmB,IAAA,EAAuB;AAC/C,EAAA,OAAO,UAAA,CAAW,KAAK,IAAI,CAAA;AAC/B;;"}
@@ -34,7 +34,8 @@ export declare class ServiceLayer {
34
34
  * @param packageName the name of the package requesting the import
35
35
  * @param spec the interface specifier
36
36
  * @param options advanced options to customize lookup
37
- * @throws if the service layer is not in 'started' state or if no service implements the interface.
37
+ * @throws if the service layer is not in 'started' state.
38
+ * Returns `{ type: "unimplemented" }` when no service implements the interface.
38
39
  */
39
40
  getService(packageName: string, spec: InterfaceSpec, options?: {
40
41
  ignoreDeclarationCheck?: boolean;
@@ -46,7 +47,7 @@ export declare class ServiceLayer {
46
47
  * @param packageName the name of the package requesting the import
47
48
  * @param interfaceName the interface name
48
49
  *
49
- * @throws if the service layer is not in 'started'.
50
+ * @throws if the service layer is not in 'started' state.
50
51
  */
51
52
  getServices(packageName: string, interfaceName: string): ServicesLookupResult | UndeclaredDependency | UnknownPackage;
52
53
  }
@@ -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$5 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';
@@ -88,7 +88,8 @@ class ServiceLayer {
88
88
  * @param packageName the name of the package requesting the import
89
89
  * @param spec the interface specifier
90
90
  * @param options advanced options to customize lookup
91
- * @throws if the service layer is not in 'started' state or if no service implements the interface.
91
+ * @throws if the service layer is not in 'started' state.
92
+ * Returns `{ type: "unimplemented" }` when no service implements the interface.
92
93
  */
93
94
  getService(packageName, spec, options) {
94
95
  if (this.#state !== "started") {
@@ -109,7 +110,7 @@ class ServiceLayer {
109
110
  * @param packageName the name of the package requesting the import
110
111
  * @param interfaceName the interface name
111
112
  *
112
- * @throws if the service layer is not in 'started'.
113
+ * @throws if the service layer is not in 'started' state.
113
114
  */
114
115
  getServices(packageName, interfaceName) {
115
116
  if (this.#state !== "started") {