@open-pioneer/runtime 2.1.6 → 2.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @open-pioneer/runtime
2
2
 
3
+ ## 2.1.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 58ce24f: Export `DECLARE_SERVICE_INTERFACE` as a value instead of a type only.
8
+ It was previously necessary to import this symbol via `import type` to avoid errors during development.
9
+ The `type` keyword can now be omitted.
10
+ - e0b2fae: Update dependencies
11
+ - 6cc7fcd: Allow synchronous `getApiMethods()` when implementing an `ApiExtension`.
12
+ - Updated dependencies [5c62522]
13
+ - Updated dependencies [50550d3]
14
+ - Updated dependencies [e0b2fae]
15
+ - @open-pioneer/chakra-integration@1.1.4
16
+ - @open-pioneer/core@1.3.0
17
+ - @open-pioneer/base-theme@0.3.3
18
+ - @open-pioneer/runtime-react-support@1.0.2
19
+
3
20
  ## 2.1.6
4
21
 
5
22
  ### Patch Changes
@@ -57,7 +57,7 @@ export interface DeclaredService<InterfaceName extends string> {
57
57
  * ```
58
58
  */
59
59
  declare const DECLARE_SERVICE_INTERFACE: unique symbol;
60
- export { type DECLARE_SERVICE_INTERFACE };
60
+ export { DECLARE_SERVICE_INTERFACE };
61
61
  /**
62
62
  * Given a type implementing {@link DeclaredService} or using {@link DECLARE_SERVICE_INTERFACE},
63
63
  * this type will produce the interface name associated with the service type.
@@ -0,0 +1,4 @@
1
+ const DECLARE_SERVICE_INTERFACE = Symbol("runtime.DECLARE_SERVICE_INTERFACE");
2
+
3
+ export { DECLARE_SERVICE_INTERFACE };
4
+ //# sourceMappingURL=DeclaredService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeclaredService.js","sources":["DeclaredService.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\ndeclare const INTERNAL_ASSOCIATED_SERVICE_METADATA: unique symbol;\ndeclare const ERROR: unique symbol;\n\n/**\n * Base interface for services that are associated with a well known interface name.\n *\n * By using this base interface, you can ensure that users of your interface use the correct interface name.\n *\n * Note that this interface is a type level marker only.\n * It has no real associated methods or properties and it is not necessary to implement anything\n * to use this interface in a class.\n *\n * @example\n * ```ts\n * // MyLogger should be referenced via \"my-package.Logger\"\n * export interface MyLogger extends DeclaredService<\"my-package.Logger\"> {\n * log(message: string): void;\n * }\n * ```\n *\n * > Note: TypeScript may list the `INTERNAL_ASSOCIATED_SERVICE_METADATA` property\n * > when generating the implementation for an interface extending this type.\n * > You can simply remove the offending line; it is not required (and not possible)\n * > to implement that attribute - it only exists for the compiler.\n */\nexport interface DeclaredService<InterfaceName extends string> {\n /**\n * Internal type-level service metadata.\n *\n * Note: there is no need to implement this symbol attribute.\n * It is optional and only exists for the compiler, never at runtime.\n *\n * @internal\n */\n [INTERNAL_ASSOCIATED_SERVICE_METADATA]?: ServiceMetadata<InterfaceName>;\n}\n\n/**\n * Helper symbol to declare a service's interface name when not using a separate interface.\n *\n * > NOTE: This symbol does not exist at runtime. Declaring a service interface is compile time only!\n * > It should therefore be imported via `import type` (see example below).\n *\n * @example\n *\n * ```ts\n * import { type DECLARE_SERVICE_INTERFACE} from \"@open-pioneer/runtime\";\n *\n * class MyServiceImpl {\n * // Add this line to your class.\n * // It declares (at compile time) that the service class must be used via the given interface name.\n * // Note that the property is not really present at runtime.\n * declare [DECLARE_SERVICE_INTERFACE]: \"my-package.MyInterface\";\n *\n * method(): void {\n * throw new Error(\"Method not implemented.\");\n * }\n * }\n * ```\n */\nconst DECLARE_SERVICE_INTERFACE = Symbol(\"runtime.DECLARE_SERVICE_INTERFACE\");\nexport { DECLARE_SERVICE_INTERFACE };\n\n/**\n * Given a type implementing {@link DeclaredService} or using {@link DECLARE_SERVICE_INTERFACE},\n * this type will produce the interface name associated with the service type.\n */\nexport type AssociatedInterfaceName<T> =\n T extends DeclaredService<infer InterfaceName>\n ? InterfaceName\n : T extends { [DECLARE_SERVICE_INTERFACE]: string & infer InterfaceName }\n ? InterfaceName\n : never;\n\n/**\n * This helper type produces the expected `interfaceName` (a string parameter) for the given service type.\n *\n * 1. If `ServiceType` is `unknown`, it will produce `string` to allow arbitrary parameters.\n * 2. If `ServiceType` implements {@link DeclaredService}, it will enforce the associated interface name.\n * 3. Otherwise, a compile time error is generated.\n */\nexport type InterfaceNameForServiceType<ServiceType> =\n IsUnknown<ServiceType> extends true\n ? string\n : AssociatedInterfaceName<ServiceType> extends never\n ? {\n [ERROR]: \"TypeScript integration was not set up properly for this service. Make sure the service's TypeScript interface extends 'DeclaredService'.\";\n }\n : AssociatedInterfaceName<ServiceType>;\n\n/**\n * @internal\n */\ninterface ServiceMetadata<InterfaceName> {\n interfaceName: InterfaceName;\n}\n\ntype IsUnknown<T> = unknown extends T ? ([T] extends [null] ? false : true) : false;\n"],"names":[],"mappings":"AA8DM,MAAA,yBAAA,GAA4B,OAAO,mCAAmC;;;;"}
package/api.d.ts CHANGED
@@ -11,7 +11,7 @@ export interface ApiExtension {
11
11
  /**
12
12
  * Returns a set of methods that will be added to the web component's API.
13
13
  */
14
- getApiMethods(): Promise<ApiMethods>;
14
+ getApiMethods(): Promise<ApiMethods> | ApiMethods;
15
15
  }
16
16
  /**
17
17
  * A service provided by the system.
@@ -1 +1 @@
1
- {"version":3,"file":"ApplicationContextImpl.js","sources":["ApplicationContextImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ApplicationContext } from \"../api\";\nimport { ServiceOptions } from \"../Service\";\n\nexport interface ApplicationContextProperties {\n host: HTMLElement;\n shadowRoot: ShadowRoot;\n container: HTMLElement;\n locale: string;\n supportedLocales: string[];\n\n /** A callback to change the application's locale is injected by the runtime. */\n changeLocale(locale: string): void;\n}\n\nexport class ApplicationContextImpl implements ApplicationContext {\n #host: HTMLElement;\n #shadowRoot: ShadowRoot;\n #container: HTMLElement;\n #locale: string;\n #supportedLocales: readonly string[];\n #changeLocale: (locale: string) => void;\n\n constructor(options: ServiceOptions, properties: ApplicationContextProperties) {\n this.#host = properties.host;\n this.#shadowRoot = properties.shadowRoot;\n this.#container = properties.container;\n this.#locale = properties.locale;\n this.#supportedLocales = Object.freeze(Array.from(properties.supportedLocales));\n this.#changeLocale = properties.changeLocale;\n }\n\n getHostElement(): HTMLElement {\n return this.#host;\n }\n\n getShadowRoot(): ShadowRoot {\n return this.#shadowRoot;\n }\n\n getApplicationContainer(): HTMLElement {\n return this.#container;\n }\n\n getLocale(): string {\n return this.#locale;\n }\n\n setLocale(locale: string): void {\n this.#changeLocale(locale);\n }\n\n getSupportedLocales(): readonly string[] {\n return this.#supportedLocales;\n }\n}\n"],"names":[],"mappings":"AAgBO,MAAM,sBAAqD,CAAA;AAAA,EAC9D,KAAA,CAAA;AAAA,EACA,WAAA,CAAA;AAAA,EACA,UAAA,CAAA;AAAA,EACA,OAAA,CAAA;AAAA,EACA,iBAAA,CAAA;AAAA,EACA,aAAA,CAAA;AAAA,EAEA,WAAA,CAAY,SAAyB,UAA0C,EAAA;AAC3E,IAAA,IAAA,CAAK,QAAQ,UAAW,CAAA,IAAA,CAAA;AACxB,IAAA,IAAA,CAAK,cAAc,UAAW,CAAA,UAAA,CAAA;AAC9B,IAAA,IAAA,CAAK,aAAa,UAAW,CAAA,SAAA,CAAA;AAC7B,IAAA,IAAA,CAAK,UAAU,UAAW,CAAA,MAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,oBAAoB,MAAO,CAAA,MAAA,CAAO,MAAM,IAAK,CAAA,UAAA,CAAW,gBAAgB,CAAC,CAAA,CAAA;AAC9E,IAAA,IAAA,CAAK,gBAAgB,UAAW,CAAA,YAAA,CAAA;AAAA,GACpC;AAAA,EAEA,cAA8B,GAAA;AAC1B,IAAA,OAAO,IAAK,CAAA,KAAA,CAAA;AAAA,GAChB;AAAA,EAEA,aAA4B,GAAA;AACxB,IAAA,OAAO,IAAK,CAAA,WAAA,CAAA;AAAA,GAChB;AAAA,EAEA,uBAAuC,GAAA;AACnC,IAAA,OAAO,IAAK,CAAA,UAAA,CAAA;AAAA,GAChB;AAAA,EAEA,SAAoB,GAAA;AAChB,IAAA,OAAO,IAAK,CAAA,OAAA,CAAA;AAAA,GAChB;AAAA,EAEA,UAAU,MAAsB,EAAA;AAC5B,IAAA,IAAA,CAAK,cAAc,MAAM,CAAA,CAAA;AAAA,GAC7B;AAAA,EAEA,mBAAyC,GAAA;AACrC,IAAA,OAAO,IAAK,CAAA,iBAAA,CAAA;AAAA,GAChB;AACJ;;;;"}
1
+ {"version":3,"file":"ApplicationContextImpl.js","sources":["ApplicationContextImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ApplicationContext } from \"../api\";\nimport { ServiceOptions } from \"../Service\";\n\nexport interface ApplicationContextProperties {\n host: HTMLElement;\n shadowRoot: ShadowRoot;\n container: HTMLElement;\n locale: string;\n supportedLocales: string[];\n\n /** A callback to change the application's locale is injected by the runtime. */\n changeLocale(locale: string): void;\n}\n\nexport class ApplicationContextImpl implements ApplicationContext {\n #host: HTMLElement;\n #shadowRoot: ShadowRoot;\n #container: HTMLElement;\n #locale: string;\n #supportedLocales: readonly string[];\n #changeLocale: (locale: string) => void;\n\n constructor(options: ServiceOptions, properties: ApplicationContextProperties) {\n this.#host = properties.host;\n this.#shadowRoot = properties.shadowRoot;\n this.#container = properties.container;\n this.#locale = properties.locale;\n this.#supportedLocales = Object.freeze(Array.from(properties.supportedLocales));\n this.#changeLocale = properties.changeLocale;\n }\n\n getHostElement(): HTMLElement {\n return this.#host;\n }\n\n getShadowRoot(): ShadowRoot {\n return this.#shadowRoot;\n }\n\n getApplicationContainer(): HTMLElement {\n return this.#container;\n }\n\n getLocale(): string {\n return this.#locale;\n }\n\n setLocale(locale: string): void {\n // This restarts the application at the moment, so this.locale will _not_ be updated.\n // Instead, we get a new application with a new application context.\n this.#changeLocale(locale);\n }\n\n getSupportedLocales(): readonly string[] {\n return this.#supportedLocales;\n }\n}\n"],"names":[],"mappings":"AAgBO,MAAM,sBAAqD,CAAA;AAAA,EAC9D,KAAA,CAAA;AAAA,EACA,WAAA,CAAA;AAAA,EACA,UAAA,CAAA;AAAA,EACA,OAAA,CAAA;AAAA,EACA,iBAAA,CAAA;AAAA,EACA,aAAA,CAAA;AAAA,EAEA,WAAA,CAAY,SAAyB,UAA0C,EAAA;AAC3E,IAAA,IAAA,CAAK,QAAQ,UAAW,CAAA,IAAA,CAAA;AACxB,IAAA,IAAA,CAAK,cAAc,UAAW,CAAA,UAAA,CAAA;AAC9B,IAAA,IAAA,CAAK,aAAa,UAAW,CAAA,SAAA,CAAA;AAC7B,IAAA,IAAA,CAAK,UAAU,UAAW,CAAA,MAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,oBAAoB,MAAO,CAAA,MAAA,CAAO,MAAM,IAAK,CAAA,UAAA,CAAW,gBAAgB,CAAC,CAAA,CAAA;AAC9E,IAAA,IAAA,CAAK,gBAAgB,UAAW,CAAA,YAAA,CAAA;AAAA,GACpC;AAAA,EAEA,cAA8B,GAAA;AAC1B,IAAA,OAAO,IAAK,CAAA,KAAA,CAAA;AAAA,GAChB;AAAA,EAEA,aAA4B,GAAA;AACxB,IAAA,OAAO,IAAK,CAAA,WAAA,CAAA;AAAA,GAChB;AAAA,EAEA,uBAAuC,GAAA;AACnC,IAAA,OAAO,IAAK,CAAA,UAAA,CAAA;AAAA,GAChB;AAAA,EAEA,SAAoB,GAAA;AAChB,IAAA,OAAO,IAAK,CAAA,OAAA,CAAA;AAAA,GAChB;AAAA,EAEA,UAAU,MAAsB,EAAA;AAG5B,IAAA,IAAA,CAAK,cAAc,MAAM,CAAA,CAAA;AAAA,GAC7B;AAAA,EAEA,mBAAyC,GAAA;AACrC,IAAA,OAAO,IAAK,CAAA,iBAAA,CAAA;AAAA,GAChB;AACJ;;;;"}
package/index.d.ts CHANGED
@@ -2,4 +2,4 @@ export * from "./api";
2
2
  export { type PackageIntl } from "./i18n";
3
3
  export { type ApplicationElement, type ApplicationElementConstructor, type ApplicationProperties, type ApplicationConfig, type CustomElementOptions, type ConfigContext, createCustomElement } from "./CustomElement";
4
4
  export * from "./Service";
5
- export { type DeclaredService, type AssociatedInterfaceName, type InterfaceNameForServiceType, type DECLARE_SERVICE_INTERFACE } from "./DeclaredService";
5
+ export { type DeclaredService, type AssociatedInterfaceName, type InterfaceNameForServiceType, DECLARE_SERVICE_INTERFACE } from "./DeclaredService";
package/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { createCustomElement } from './CustomElement.js';
2
+ export { DECLARE_SERVICE_INTERFACE } from './DeclaredService.js';
2
3
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/runtime",
4
- "version": "2.1.6",
4
+ "version": "2.1.7",
5
5
  "description": "Implements the runtime environment for Open Pioneer Trails apps.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -14,13 +14,13 @@
14
14
  "directory": "src/packages/runtime"
15
15
  },
16
16
  "peerDependencies": {
17
- "@formatjs/intl": "^2.9.9",
17
+ "@formatjs/intl": "^2.10.4",
18
18
  "react": "^18.3.1",
19
- "react-dom": "^18.2.0",
20
- "@open-pioneer/base-theme": "^0.3.2",
21
- "@open-pioneer/chakra-integration": "^1.1.3",
19
+ "react-dom": "^18.3.1",
20
+ "@open-pioneer/base-theme": "^0.3.3",
21
+ "@open-pioneer/core": "^1.3.0",
22
22
  "@open-pioneer/runtime-react-support": "^1.0.2",
23
- "@open-pioneer/core": "^1.2.3"
23
+ "@open-pioneer/chakra-integration": "^1.1.4"
24
24
  },
25
25
  "exports": {
26
26
  "./package.json": "./package.json",
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sources":["hooks.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { useContext, useMemo } from \"react\";\nimport { Error } from \"@open-pioneer/core\";\nimport {\n PackageContext as PackageContext,\n PackageContextMethods\n} from \"@open-pioneer/runtime-react-support\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl } from \"../i18n\";\nimport { InterfaceNameForServiceType } from \"../DeclaredService\";\n\n/*\n\n IMPORTANT\n =========\n\n The functions in this file are part of the public API.\n They are imported by code generated during separate package generation via:\n\n import { hookName } from '@open-pioneer/runtime/react-integration'\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 // eslint-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// eslint-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 return checkContext(\"useIntl\", context).getIntl(packageName);\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":";;;;;AAgDgB,SAAA,kBAAA,CACZ,WAEA,EAAA,aAAA,EACA,OACO,EAAA;AACP,EAAM,MAAA,OAAA,GAAU,WAAW,cAAc,CAAA,CAAA;AACzC,EAAA,MAAM,OAAU,GAAA,OAAA;AAAA,IACZ,MACI,YAAA,CAAa,YAAc,EAAA,OAAO,CAAE,CAAA,UAAA;AAAA,MAChC,WAAA;AAAA,MACA,aAAA;AAAA,MACA,WAAW,EAAC;AAAA,KAChB;AAAA,IACJ,CAAC,OAAA,EAAS,WAAa,EAAA,aAAA,EAAe,OAAO,CAAA;AAAA,GACjD,CAAA;AACA,EAAO,OAAA,OAAA,CAAA;AACX,CAAA;AAiBgB,SAAA,mBAAA,CAAoB,aAAqB,aAA+B,EAAA;AACpF,EAAM,MAAA,OAAA,GAAU,WAAW,cAAc,CAAA,CAAA;AACzC,EAAA,MAAM,QAAW,GAAA,OAAA;AAAA,IACb,MAAM,YAAa,CAAA,aAAA,EAAe,OAAO,CAAE,CAAA,WAAA,CAAY,aAAa,aAAa,CAAA;AAAA,IACjF,CAAC,OAAS,EAAA,WAAA,EAAa,aAAa,CAAA;AAAA,GACxC,CAAA;AACA,EAAO,OAAA,QAAA,CAAA;AACX,CAAA;AAUO,SAAS,sBAAsB,WAAwD,EAAA;AAC1F,EAAM,MAAA,OAAA,GAAU,WAAW,cAAc,CAAA,CAAA;AACzC,EAAA,OAAO,YAAa,CAAA,eAAA,EAAiB,OAAO,CAAA,CAAE,cAAc,WAAW,CAAA,CAAA;AAC3E,CAAA;AAUO,SAAS,gBAAgB,WAAkC,EAAA;AAC9D,EAAM,MAAA,OAAA,GAAU,WAAW,cAAc,CAAA,CAAA;AACzC,EAAA,OAAO,YAAa,CAAA,SAAA,EAAW,OAAO,CAAA,CAAE,QAAQ,WAAW,CAAA,CAAA;AAC/D,CAAA;AAEA,SAAS,YAAA,CACL,UACA,WACqB,EAAA;AACrB,EAAA,IAAI,CAAC,WAAa,EAAA;AACd,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,OAAQ,CAAA,QAAA;AAAA,MACR,2CAA2C,QAAQ,CAAA,6CAAA,CAAA;AAAA,KACvD,CAAA;AAAA,GACJ;AACA,EAAO,OAAA,WAAA,CAAA;AACX;;;;"}
1
+ {"version":3,"file":"hooks.js","sources":["hooks.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { useContext, useMemo } from \"react\";\nimport { Error } from \"@open-pioneer/core\";\nimport {\n PackageContext as PackageContext,\n PackageContextMethods\n} from \"@open-pioneer/runtime-react-support\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl } from \"../i18n\";\nimport { InterfaceNameForServiceType } from \"../DeclaredService\";\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 // eslint-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// eslint-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 return checkContext(\"useIntl\", context).getIntl(packageName);\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":";;;;;AAkDgB,SAAA,kBAAA,CACZ,WAEA,EAAA,aAAA,EACA,OACO,EAAA;AACP,EAAM,MAAA,OAAA,GAAU,WAAW,cAAc,CAAA,CAAA;AACzC,EAAA,MAAM,OAAU,GAAA,OAAA;AAAA,IACZ,MACI,YAAA,CAAa,YAAc,EAAA,OAAO,CAAE,CAAA,UAAA;AAAA,MAChC,WAAA;AAAA,MACA,aAAA;AAAA,MACA,WAAW,EAAC;AAAA,KAChB;AAAA,IACJ,CAAC,OAAA,EAAS,WAAa,EAAA,aAAA,EAAe,OAAO,CAAA;AAAA,GACjD,CAAA;AACA,EAAO,OAAA,OAAA,CAAA;AACX,CAAA;AAiBgB,SAAA,mBAAA,CAAoB,aAAqB,aAA+B,EAAA;AACpF,EAAM,MAAA,OAAA,GAAU,WAAW,cAAc,CAAA,CAAA;AACzC,EAAA,MAAM,QAAW,GAAA,OAAA;AAAA,IACb,MAAM,YAAa,CAAA,aAAA,EAAe,OAAO,CAAE,CAAA,WAAA,CAAY,aAAa,aAAa,CAAA;AAAA,IACjF,CAAC,OAAS,EAAA,WAAA,EAAa,aAAa,CAAA;AAAA,GACxC,CAAA;AACA,EAAO,OAAA,QAAA,CAAA;AACX,CAAA;AAUO,SAAS,sBAAsB,WAAwD,EAAA;AAC1F,EAAM,MAAA,OAAA,GAAU,WAAW,cAAc,CAAA,CAAA;AACzC,EAAA,OAAO,YAAa,CAAA,eAAA,EAAiB,OAAO,CAAA,CAAE,cAAc,WAAW,CAAA,CAAA;AAC3E,CAAA;AAUO,SAAS,gBAAgB,WAAkC,EAAA;AAC9D,EAAM,MAAA,OAAA,GAAU,WAAW,cAAc,CAAA,CAAA;AACzC,EAAA,OAAO,YAAa,CAAA,SAAA,EAAW,OAAO,CAAA,CAAE,QAAQ,WAAW,CAAA,CAAA;AAC/D,CAAA;AAEA,SAAS,YAAA,CACL,UACA,WACqB,EAAA;AACrB,EAAA,IAAI,CAAC,WAAa,EAAA;AACd,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,OAAQ,CAAA,QAAA;AAAA,MACR,2CAA2C,QAAQ,CAAA,6CAAA,CAAA;AAAA,KACvD,CAAA;AAAA,GACJ;AACA,EAAO,OAAA,WAAA,CAAA;AACX;;;;"}