@open-pioneer/runtime 2.4.0 → 3.0.0

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.
@@ -1 +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;;;;"}
1
+ {"version":3,"file":"DeclaredService.js","sources":["DeclaredService.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\ndeclare const INTERNAL_ASSOCIATED_SERVICE_METADATA: unique symbol;\ndeclare const ERROR: unique symbol;\n\n/**\n * Base interface for services that are associated with a well known interface name.\n *\n * By using this base interface, you can ensure that users of your interface use the correct interface name.\n *\n * Note that this interface is a type level marker only.\n * It has no real associated methods or properties and it is not necessary to implement anything\n * to use this interface in a class.\n *\n * @example\n * ```ts\n * // MyLogger should be referenced via \"my-package.Logger\"\n * export interface MyLogger extends DeclaredService<\"my-package.Logger\"> {\n * log(message: string): void;\n * }\n * ```\n *\n * > Note: TypeScript may list the `INTERNAL_ASSOCIATED_SERVICE_METADATA` property\n * > when generating the implementation for an interface extending this type.\n * > You can simply remove the offending line; it is not required (and not possible)\n * > to implement that attribute - it only exists for the compiler.\n */\nexport interface DeclaredService<InterfaceName extends string> {\n /**\n * Internal type-level service metadata.\n *\n * Note: there is no need to implement this symbol attribute.\n * It is optional and only exists for the compiler, never at runtime.\n *\n * @internal\n */\n [INTERNAL_ASSOCIATED_SERVICE_METADATA]?: ServiceMetadata<InterfaceName>;\n}\n\n/**\n * Helper symbol to declare a service's interface name when not using a separate interface.\n *\n * > NOTE: This symbol does not exist at runtime. Declaring a service interface is compile time only!\n * > It should therefore be imported via `import type` (see example below).\n *\n * @example\n *\n * ```ts\n * import { type DECLARE_SERVICE_INTERFACE} from \"@open-pioneer/runtime\";\n *\n * class MyServiceImpl {\n * // Add this line to your class.\n * // It declares (at compile time) that the service class must be used via the given interface name.\n * // Note that the property is not really present at runtime.\n * declare [DECLARE_SERVICE_INTERFACE]: \"my-package.MyInterface\";\n *\n * method(): void {\n * throw new Error(\"Method not implemented.\");\n * }\n * }\n * ```\n */\nconst DECLARE_SERVICE_INTERFACE = Symbol(\"runtime.DECLARE_SERVICE_INTERFACE\");\nexport { DECLARE_SERVICE_INTERFACE };\n\n/**\n * Given a type implementing {@link DeclaredService} or using {@link DECLARE_SERVICE_INTERFACE},\n * this type will produce the interface name associated with the service type.\n */\nexport type AssociatedInterfaceName<T> =\n T extends DeclaredService<infer InterfaceName>\n ? InterfaceName\n : T extends { [DECLARE_SERVICE_INTERFACE]: string & infer InterfaceName }\n ? InterfaceName\n : never;\n\n/**\n * This helper type produces the expected `interfaceName` (a string parameter) for the given service type.\n *\n * 1. If `ServiceType` is `unknown`, it will produce `string` to allow arbitrary parameters.\n * 2. If `ServiceType` implements {@link DeclaredService}, it will enforce the associated interface name.\n * 3. Otherwise, a compile time error is generated.\n */\nexport type InterfaceNameForServiceType<ServiceType> =\n IsUnknown<ServiceType> extends true\n ? string\n : AssociatedInterfaceName<ServiceType> extends never\n ? {\n [ERROR]: \"TypeScript integration was not set up properly for this service. Make sure the service's TypeScript interface extends 'DeclaredService'.\";\n }\n : AssociatedInterfaceName<ServiceType>;\n\n/**\n * @internal\n */\ninterface ServiceMetadata<InterfaceName> {\n interfaceName: InterfaceName;\n}\n\ntype IsUnknown<T> = unknown extends T ? ([T] extends [null] ? false : true) : false;\n"],"names":[],"mappings":"AA8DM,MAAA,yBAAA,GAA4B,OAAO,mCAAmC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorScreen.js","sources":["ErrorScreen.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n Box,\n VStack,\n Heading,\n AlertIcon,\n AlertTitle,\n AlertDescription,\n Alert,\n Text\n} from \"@open-pioneer/chakra-integration\";\nimport { PackageIntl } from \"./i18n\";\n\nconst MESSAGES_DE = {\n \"title\": \"Anwendungsstart fehlgeschlagen\",\n \"alertTitle\": \"Fehler\",\n \"alertDescription\": \"Leider ist beim Start der Anwendung ein Fehler aufgetreten.\",\n\n \"details.title\": \"Fehlerdetails\",\n \"details.inspect\": \"Konsole öffnen, um weitere Details zu sehen.\",\n \"details.errorMessage\": \"Fehler: {message}\"\n};\n\nconst MESSAGES_EN = {\n \"title\": \"Application start failed\",\n \"alertTitle\": \"Error\",\n \"alertDescription\": \"Unfortunately an error occurred during application start.\",\n\n \"details.title\": \"Error details\",\n \"details.inspect\": \"Inspect the console to see more details.\",\n \"details.errorMessage\": \"Error: {message}\"\n};\n\nexport const MESSAGES_BY_LOCALE: Record<\"en\" | \"de\", Record<string, string>> = {\n \"en\": MESSAGES_EN,\n \"de\": MESSAGES_DE\n};\n\nconst isDev = import.meta.env.DEV;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\nexport function ErrorScreen(props: { intl: PackageIntl; error: Error }) {\n const intl = props.intl;\n return (\n <Box width=\"100%\" height=\"100%\" minWidth=\"350px\" minHeight=\"150px\">\n <VStack padding={4} width=\"100%\" height=\"100%\">\n <Heading size=\"md\">{intl.formatMessage({ id: \"title\" })}</Heading>\n <Alert status=\"error\" maxWidth={550} borderRadius=\"4px\" mt={2}>\n <AlertIcon />\n <AlertTitle>{intl.formatMessage({ id: \"alertTitle\" })}</AlertTitle>\n <AlertDescription>\n {intl.formatMessage({ id: \"alertDescription\" })}\n </AlertDescription>\n </Alert>\n\n {isDev && (\n <Box\n className=\"error-details\"\n mt={4}\n p={2}\n maxWidth=\"100%\"\n border={\"dotted 2px\"}\n borderColor={\"red.600\"}\n borderRadius={\"4px\"}\n >\n <Text color={\"red.600\"} fontWeight={\"bold\"}>\n {intl.formatMessage({ id: \"details.title\" }) + \":\"}\n </Text>\n <ErrorRenderer {...props} />\n </Box>\n )}\n </VStack>\n </Box>\n );\n}\n\n/**\n * Renders a single error instance.\n */\nfunction ErrorRenderer(props: { error: Error; intl: PackageIntl }) {\n const { error, intl } = props;\n const message = error?.message || \"Unknown\";\n const stackTrace = error?.stack;\n const stackTraceDisplay = stackTrace && (\n <>\n <Box\n p=\"2\"\n mt={1}\n mb={3}\n maxHeight=\"500px\"\n whiteSpace=\"pre\"\n wordBreak=\"keep-all\"\n overflow=\"auto\"\n border=\"1px solid grey\"\n borderRadius=\"4px\"\n color=\"gray.700\"\n fontSize=\"12px\"\n fontFamily=\"monospace\"\n >\n {stackTrace}\n </Box>\n {intl.formatMessage({ id: \"details.inspect\" })}\n </>\n );\n return (\n <Box p={2} className={\"error-screen-stack-trace\"}>\n <Text fontStyle={\"italic\"}>\n {intl.formatMessage({ id: \"details.errorMessage\" }, { message })}\n </Text>\n {stackTraceDisplay}\n </Box>\n );\n}\n"],"names":[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A;AAAA,MAAC,GAAA;AAAA,MAAA;AAAA,QACG,CAAE,EAAA,GAAA;AAAA,QACF,EAAI,EAAA,CAAA;AAAA,QACJ,EAAI,EAAA,CAAA;AAAA,QACJ,SAAU,EAAA,OAAA;AAAA,QACV,UAAW,EAAA,KAAA;AAAA,QACX,SAAU,EAAA,UAAA;AAAA,QACV,QAAS,EAAA,MAAA;AAAA,QACT,MAAO,EAAA,gBAAA;AAAA,QACP,YAAa,EAAA,KAAA;AAAA,QACb,KAAM,EAAA,UAAA;AAAA,QACN,QAAS,EAAA,MAAA;AAAA,QACT,UAAW,EAAA,WAAA;AAAA,QAEV,QAAA,EAAA,UAAA;AAAA,OAAA;AAAA,KACL;AAAA,IACC,IAAK,CAAA,aAAA,CAAc,EAAE,EAAA,EAAI,mBAAmB,CAAA;AAAA,GACjD,EAAA,CAAA,CAAA;AAEJ,EAAA,uBACK,IAAA,CAAA,GAAA,EAAA,EAAI,CAAG,EAAA,CAAA,EAAG,WAAW,0BAClB,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,IAAK,EAAA,EAAA,SAAA,EAAW,QACZ,EAAA,QAAA,EAAA,IAAA,CAAK,aAAc,CAAA,EAAE,EAAI,EAAA,sBAAA,EAA0B,EAAA,EAAE,OAAQ,EAAC,CACnE,EAAA,CAAA;AAAA,IACC,iBAAA;AAAA,GACL,EAAA,CAAA,CAAA;AAER;;;;"}
1
+ {"version":3,"file":"ErrorScreen.js","sources":["ErrorScreen.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n Box,\n VStack,\n Heading,\n AlertIcon,\n AlertTitle,\n AlertDescription,\n Alert,\n Text\n} from \"@open-pioneer/chakra-integration\";\nimport { PackageIntl } from \"./i18n\";\n\nconst MESSAGES_DE = {\n \"title\": \"Anwendungsstart fehlgeschlagen\",\n \"alertTitle\": \"Fehler\",\n \"alertDescription\": \"Leider ist beim Start der Anwendung ein Fehler aufgetreten.\",\n\n \"details.title\": \"Fehlerdetails\",\n \"details.inspect\": \"Konsole öffnen, um weitere Details zu sehen.\",\n \"details.errorMessage\": \"Fehler: {message}\"\n};\n\nconst MESSAGES_EN = {\n \"title\": \"Application start failed\",\n \"alertTitle\": \"Error\",\n \"alertDescription\": \"Unfortunately an error occurred during application start.\",\n\n \"details.title\": \"Error details\",\n \"details.inspect\": \"Inspect the console to see more details.\",\n \"details.errorMessage\": \"Error: {message}\"\n};\n\nexport const MESSAGES_BY_LOCALE: Record<\"en\" | \"de\", Record<string, string>> = {\n \"en\": MESSAGES_EN,\n \"de\": MESSAGES_DE\n};\n\nconst isDev = import.meta.env.DEV;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\nexport function ErrorScreen(props: { intl: PackageIntl; error: Error }) {\n const intl = props.intl;\n return (\n <Box width=\"100%\" height=\"100%\" minWidth=\"350px\" minHeight=\"150px\">\n <VStack padding={4} width=\"100%\" height=\"100%\">\n <Heading size=\"md\">{intl.formatMessage({ id: \"title\" })}</Heading>\n <Alert status=\"error\" maxWidth={550} borderRadius=\"4px\" mt={2}>\n <AlertIcon />\n <AlertTitle>{intl.formatMessage({ id: \"alertTitle\" })}</AlertTitle>\n <AlertDescription>\n {intl.formatMessage({ id: \"alertDescription\" })}\n </AlertDescription>\n </Alert>\n\n {isDev && (\n <Box\n className=\"error-details\"\n mt={4}\n p={2}\n maxWidth=\"100%\"\n border={\"dotted 2px\"}\n borderColor={\"red.600\"}\n borderRadius={\"4px\"}\n >\n <Text color={\"red.600\"} fontWeight={\"bold\"}>\n {intl.formatMessage({ id: \"details.title\" }) + \":\"}\n </Text>\n <ErrorRenderer {...props} />\n </Box>\n )}\n </VStack>\n </Box>\n );\n}\n\n/**\n * Renders a single error instance.\n */\nfunction ErrorRenderer(props: { error: Error; intl: PackageIntl }) {\n const { error, intl } = props;\n const message = error?.message || \"Unknown\";\n const stackTrace = error?.stack;\n const stackTraceDisplay = stackTrace && (\n <>\n <Box\n p=\"2\"\n mt={1}\n mb={3}\n maxHeight=\"500px\"\n whiteSpace=\"pre\"\n wordBreak=\"keep-all\"\n overflow=\"auto\"\n border=\"1px solid grey\"\n borderRadius=\"4px\"\n color=\"gray.700\"\n fontSize=\"12px\"\n fontFamily=\"monospace\"\n >\n {stackTrace}\n </Box>\n {intl.formatMessage({ id: \"details.inspect\" })}\n </>\n );\n return (\n <Box p={2} className={\"error-screen-stack-trace\"}>\n <Text fontStyle={\"italic\"}>\n {intl.formatMessage({ id: \"details.errorMessage\" }, { message })}\n </Text>\n {stackTraceDisplay}\n </Box>\n );\n}\n"],"names":[],"mappings":";;;AAeA,MAAM,WAAc,GAAA;AAAA,EAChB,OAAS,EAAA,gCAAA;AAAA,EACT,YAAc,EAAA,QAAA;AAAA,EACd,kBAAoB,EAAA,6DAAA;AAAA,EAEpB,eAAiB,EAAA,eAAA;AAAA,EACjB,iBAAmB,EAAA,iDAAA;AAAA,EACnB,sBAAwB,EAAA;AAC5B,CAAA;AAEA,MAAM,WAAc,GAAA;AAAA,EAChB,OAAS,EAAA,0BAAA;AAAA,EACT,YAAc,EAAA,OAAA;AAAA,EACd,kBAAoB,EAAA,2DAAA;AAAA,EAEpB,eAAiB,EAAA,eAAA;AAAA,EACjB,iBAAmB,EAAA,0CAAA;AAAA,EACnB,sBAAwB,EAAA;AAC5B,CAAA;AAEO,MAAM,kBAAkE,GAAA;AAAA,EAC3E,IAAM,EAAA,WAAA;AAAA,EACN,IAAM,EAAA;AACV;AAEA,MAAM,KAAA,GAAQ,YAAY,GAAI,CAAA,GAAA;AAIvB,SAAS,YAAY,KAA4C,EAAA;AACpE,EAAA,MAAM,OAAO,KAAM,CAAA,IAAA;AACnB,EAAA,2BACK,GAAI,EAAA,EAAA,KAAA,EAAM,MAAO,EAAA,MAAA,EAAO,QAAO,QAAS,EAAA,OAAA,EAAQ,SAAU,EAAA,OAAA,EACvD,+BAAC,MAAO,EAAA,EAAA,OAA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: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ServiceOptions } from \"../Service\";\nimport { ApiExtension, ApiMethod, ApiMethods, ApiService } from \"../api\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\n\ninterface References {\n providers: ApiExtension[];\n}\n\nexport class ApiServiceImpl implements ApiService {\n private readonly providers: [serviceId: string, provider: ApiExtension][];\n\n constructor(options: ServiceOptions<References>) {\n const providers = options.references.providers;\n const meta = options.referencesMeta.providers;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.providers = providers.map((provider, index) => [meta[index]!.serviceId, provider]);\n }\n\n async getApi() {\n interface ProviderResult {\n serviceId: string;\n methods: ApiMethods;\n }\n\n const promises = this.providers.map(async ([serviceId, provider]) => {\n const methods = await provider.getApiMethods();\n const result: ProviderResult = {\n serviceId,\n methods\n };\n return result;\n });\n const providerMethods = await Promise.all(promises);\n\n interface MethodEntry {\n method: ApiMethod;\n serviceId: string;\n }\n\n const methodEntries = new Map<string, MethodEntry>();\n for (const { serviceId, methods } of providerMethods) {\n for (const [methodName, method] of Object.entries(methods)) {\n const existingEntry = methodEntries.get(methodName);\n if (existingEntry) {\n throw new Error(\n ErrorId.DUPLICATE_API_METHODS,\n `Cannot define API method '${methodName}' from '${serviceId}' (method is also defined by '${existingEntry.serviceId}').`\n );\n }\n\n methodEntries.set(methodName, {\n serviceId,\n method\n });\n }\n }\n\n const api: Record<string, ApiMethod> = {};\n for (const [methodName, entry] of methodEntries.entries()) {\n api[methodName] = entry.method;\n }\n return api;\n }\n}\n"],"names":[],"mappings":";;;AAWO,MAAM,cAAqC,CAAA;AAAA,EAC7B,SAAA,CAAA;AAAA,EAEjB,YAAY,OAAqC,EAAA;AAC7C,IAAM,MAAA,SAAA,GAAY,QAAQ,UAAW,CAAA,SAAA,CAAA;AACrC,IAAM,MAAA,IAAA,GAAO,QAAQ,cAAe,CAAA,SAAA,CAAA;AAEpC,IA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EA,IAAA,MAAM,MAAiC,EAAC,CAAA;AACxC,IAAA,KAAA,MAAW,CAAC,UAAY,EAAA,KAAK,CAAK,IAAA,aAAA,CAAc,SAAW,EAAA;AACvD,MAAI,GAAA,CAAA,UAAU,IAAI,KAAM,CAAA,MAAA,CAAA;AAAA,KAC5B;AACA,IAAO,OAAA,GAAA,CAAA;AAAA,GACX;AACJ;;;;"}
1
+ {"version":3,"file":"ApiServiceImpl.js","sources":["ApiServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ServiceOptions } from \"../Service\";\nimport { ApiExtension, ApiMethod, ApiMethods, ApiService } from \"../api\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\n\ninterface References {\n providers: ApiExtension[];\n}\n\nexport class ApiServiceImpl implements ApiService {\n private readonly providers: [serviceId: string, provider: ApiExtension][];\n\n constructor(options: ServiceOptions<References>) {\n const providers = options.references.providers;\n const meta = options.referencesMeta.providers;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.providers = providers.map((provider, index) => [meta[index]!.serviceId, provider]);\n }\n\n async getApi() {\n interface ProviderResult {\n serviceId: string;\n methods: ApiMethods;\n }\n\n const promises = this.providers.map(async ([serviceId, provider]) => {\n const methods = await provider.getApiMethods();\n const result: ProviderResult = {\n serviceId,\n methods\n };\n return result;\n });\n const providerMethods = await Promise.all(promises);\n\n interface MethodEntry {\n method: ApiMethod;\n serviceId: string;\n }\n\n const methodEntries = new Map<string, MethodEntry>();\n for (const { serviceId, methods } of providerMethods) {\n for (const [methodName, method] of Object.entries(methods)) {\n const existingEntry = methodEntries.get(methodName);\n if (existingEntry) {\n throw new Error(\n ErrorId.DUPLICATE_API_METHODS,\n `Cannot define API method '${methodName}' from '${serviceId}' (method is also defined by '${existingEntry.serviceId}').`\n );\n }\n\n methodEntries.set(methodName, {\n serviceId,\n method\n });\n }\n }\n\n const api: Record<string, ApiMethod> = {};\n for (const [methodName, entry] of methodEntries.entries()) {\n api[methodName] = entry.method;\n }\n return api;\n }\n}\n"],"names":[],"mappings":";;;AAWO,MAAM,cAAqC,CAAA;AAAA,EAC7B,SAAA;AAAA,EAEjB,YAAY,OAAqC,EAAA;AAC7C,IAAM,MAAA,SAAA,GAAY,QAAQ,UAAW,CAAA,SAAA;AACrC,IAAM,MAAA,IAAA,GAAO,QAAQ,cAAe,CAAA,SAAA;AAEpC,IAAA,IAAA,CAAK,SAAY,GAAA,SAAA,CAAU,GAAI,CAAA,CAAC,QAAU,EAAA,KAAA,KAAU,CAAC,IAAA,CAAK,KAAK,CAAA,CAAG,SAAW,EAAA,QAAQ,CAAC,CAAA;AAAA;AAC1F,EAEA,MAAM,MAAS,GAAA;AAMX,IAAM,MAAA,QAAA,GAAW,KAAK,SAAU,CAAA,GAAA,CAAI,OAAO,CAAC,SAAA,EAAW,QAAQ,CAAM,KAAA;AACjE,MAAM,MAAA,OAAA,GAAU,MAAM,QAAA,CAAS,aAAc,EAAA;AAC7C,MAAA,MAAM,MAAyB,GAAA;AAAA,QAC3B,SAAA;AAAA,QACA;AAAA,OACJ;AACA,MAAO,OAAA,MAAA;AAAA,KACV,CAAA;AACD,IAAA,MAAM,eAAkB,GAAA,MAAM,OAAQ,CAAA,GAAA,CAAI,QAAQ,CAAA;AAOlD,IAAM,MAAA,aAAA,uBAAoB,GAAyB,EAAA;AACnD,IAAA,KAAA,MAAW,EAAE,SAAA,EAAW,OAAQ,EAAA,IAAK,eAAiB,EAAA;AAClD,MAAA,KAAA,MAAW,CAAC,UAAY,EAAA,MAAM,KAAK,MAAO,CAAA,OAAA,CAAQ,OAAO,CAAG,EAAA;AACxD,QAAM,MAAA,aAAA,GAAgB,aAAc,CAAA,GAAA,CAAI,UAAU,CAAA;AAClD,QAAA,IAAI,aAAe,EAAA;AACf,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAQ,CAAA,qBAAA;AAAA,YACR,6BAA6B,UAAU,CAAA,QAAA,EAAW,SAAS,CAAA,8BAAA,EAAiC,cAAc,SAAS,CAAA,GAAA;AAAA,WACvH;AAAA;AAGJ,QAAA,aAAA,CAAc,IAAI,UAAY,EAAA;AAAA,UAC1B,SAAA;AAAA,UACA;AAAA,SACH,CAAA;AAAA;AACL;AAGJ,IAAA,MAAM,MAAiC,EAAC;AACxC,IAAA,KAAA,MAAW,CAAC,UAAY,EAAA,KAAK,CAAK,IAAA,aAAA,CAAc,SAAW,EAAA;AACvD,MAAI,GAAA,CAAA,UAAU,IAAI,KAAM,CAAA,MAAA;AAAA;AAE5B,IAAO,OAAA,GAAA;AAAA;AAEf;;;;"}
@@ -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 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;;;;"}
1
+ {"version":3,"file":"ApplicationContextImpl.js","sources":["ApplicationContextImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ApplicationContext } from \"../api\";\nimport { 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;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,iBAAA;AAAA,EACA,aAAA;AAAA,EAEA,WAAA,CAAY,SAAyB,UAA0C,EAAA;AAC3E,IAAA,IAAA,CAAK,QAAQ,UAAW,CAAA,IAAA;AACxB,IAAA,IAAA,CAAK,cAAc,UAAW,CAAA,UAAA;AAC9B,IAAA,IAAA,CAAK,aAAa,UAAW,CAAA,SAAA;AAC7B,IAAA,IAAA,CAAK,UAAU,UAAW,CAAA,MAAA;AAC1B,IAAA,IAAA,CAAK,oBAAoB,MAAO,CAAA,MAAA,CAAO,MAAM,IAAK,CAAA,UAAA,CAAW,gBAAgB,CAAC,CAAA;AAC9E,IAAA,IAAA,CAAK,gBAAgB,UAAW,CAAA,YAAA;AAAA;AACpC,EAEA,cAA8B,GAAA;AAC1B,IAAA,OAAO,IAAK,CAAA,KAAA;AAAA;AAChB,EAEA,aAA4B,GAAA;AACxB,IAAA,OAAO,IAAK,CAAA,WAAA;AAAA;AAChB,EAEA,uBAAuC,GAAA;AACnC,IAAA,OAAO,IAAK,CAAA,UAAA;AAAA;AAChB,EAEA,SAAoB,GAAA;AAChB,IAAA,OAAO,IAAK,CAAA,OAAA;AAAA;AAChB,EAEA,UAAU,MAAsB,EAAA;AAG5B,IAAA,IAAA,CAAK,cAAc,MAAM,CAAA;AAAA;AAC7B,EAEA,mBAAyC,GAAA;AACrC,IAAA,OAAO,IAAK,CAAA,iBAAA;AAAA;AAEpB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ApplicationLifecycleEventService.js","sources":["ApplicationLifecycleEventService.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger } from \"@open-pioneer/core\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ServiceOptions } from \"../Service\";\nimport { ApplicationLifecycleListener } from \"../api\";\nimport { ErrorId } from \"../errors\";\n\nconst LOG = createLogger(\"runtime:ApplicationLifecycleEventService\");\n\ninterface References {\n listeners: ApplicationLifecycleListener[];\n}\n\nexport class ApplicationLifecycleEventService {\n #listeners: [serviceId: string, listener: ApplicationLifecycleListener][];\n\n constructor(options: ServiceOptions<References>) {\n const listeners = options.references.listeners;\n const listenersMeta = options.referencesMeta.listeners;\n this.#listeners = listeners.map((listener, index) => [\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n listenersMeta[index]!.serviceId,\n listener\n ]);\n }\n\n /** @internal */\n emitLifecycleEvent(event: \"after-start\" | \"before-stop\"): void {\n const methodName = (() => {\n switch (event) {\n case \"after-start\":\n return \"afterApplicationStart\";\n case \"before-stop\":\n return \"beforeApplicationStop\";\n default:\n throw new Error(ErrorId.INTERNAL, `Invalid event '${event}'`);\n }\n })();\n for (const [serviceId, listener] of this.#listeners) {\n try {\n listener[methodName]?.();\n } catch (e) {\n LOG.error(`Unexpected error from application lifecycle listener ${serviceId}`, e);\n }\n }\n }\n}\n"],"names":[],"mappings":";;;AAQA,MAAM,GAAA,GAAM,aAAa,0CAA0C,CAAA,CAAA;AAM5D,MAAM,gCAAiC,CAAA;AAAA,EAC1C,UAAA,CAAA;AAAA,EAEA,YAAY,OAAqC,EAAA;AAC7C,IAAM,MAAA,SAAA,GAAY,QAAQ,UAAW,CAAA,SAAA,CAAA;AACrC,IAAM,MAAA,aAAA,GAAgB,QAAQ,cAAe,CAAA,SAAA,CAAA;AAC7C,IAAA,IAAA,CAAK,UAAa,GAAA,SAAA,CAAU,GAAI,CAAA,CAAC,UAAU,KAAU,KAAA;AAAA;AAAA,MAEjD,aAAA,CAAc,KAAK,CAAG,CAAA,SAAA;AAAA,MACtB,QAAA;AAAA,KACH,CAAA,CAAA;AAAA,GACL;AAAA;AAAA,EAGA,mBAAmB,KAA4C,EAAA;AAC3D,IAAA,MAAM,cAAc,MAAM;AACtB,MAAA,QAAQ,KAAO;AAAA,QACX,KAAK,aAAA;AACD,UAAO,OAAA,uBAAA,CAAA;AAAA,QACX,KAAK,aAAA;AACD,UAAO,OAAA,uBAAA,CAAA;AAAA,QACX;AACI,UAAA,MAAM,IAAI,KAAM,CAAA,OAAA,CAAQ,QAAU,EAAA,CAAA,eAAA,EAAkB,KAAK,CAAG,CAAA,CAAA,CAAA,CAAA;AAAA,OACpE;AAAA,KACD,GAAA,CAAA;AACH,IAAA,KAAA,MAAW,CAAC,SAAA,EAAW,QAAQ,CAAA,IAAK,KAAK,UAAY,EAAA;AACjD,MAAI,IAAA;AACA,QAAA,QAAA,CAAS,UAAU,CAAI,IAAA,CAAA;AAAA,eAClB,CAAG,EAAA;AACR,QAAA,GAAA,CAAI,KAAM,CAAA,CAAA,qDAAA,EAAwD,SAAS,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA;AAAA,OACpF;AAAA,KACJ;AAAA,GACJ;AACJ;;;;"}
1
+ {"version":3,"file":"ApplicationLifecycleEventService.js","sources":["ApplicationLifecycleEventService.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger } from \"@open-pioneer/core\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ServiceOptions } from \"../Service\";\nimport { ApplicationLifecycleListener } from \"../api\";\nimport { ErrorId } from \"../errors\";\n\nconst LOG = createLogger(\"runtime:ApplicationLifecycleEventService\");\n\ninterface References {\n listeners: ApplicationLifecycleListener[];\n}\n\nexport class ApplicationLifecycleEventService {\n #listeners: [serviceId: string, listener: ApplicationLifecycleListener][];\n\n constructor(options: ServiceOptions<References>) {\n const listeners = options.references.listeners;\n const listenersMeta = options.referencesMeta.listeners;\n this.#listeners = listeners.map((listener, index) => [\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n listenersMeta[index]!.serviceId,\n listener\n ]);\n }\n\n /** @internal */\n emitLifecycleEvent(event: \"after-start\" | \"before-stop\"): void {\n const methodName = (() => {\n switch (event) {\n case \"after-start\":\n return \"afterApplicationStart\";\n case \"before-stop\":\n return \"beforeApplicationStop\";\n default:\n throw new Error(ErrorId.INTERNAL, `Invalid event '${event}'`);\n }\n })();\n for (const [serviceId, listener] of this.#listeners) {\n try {\n listener[methodName]?.();\n } catch (e) {\n LOG.error(`Unexpected error from application lifecycle listener ${serviceId}`, e);\n }\n }\n }\n}\n"],"names":[],"mappings":";;;AAQA,MAAM,GAAA,GAAM,aAAa,0CAA0C,CAAA;AAM5D,MAAM,gCAAiC,CAAA;AAAA,EAC1C,UAAA;AAAA,EAEA,YAAY,OAAqC,EAAA;AAC7C,IAAM,MAAA,SAAA,GAAY,QAAQ,UAAW,CAAA,SAAA;AACrC,IAAM,MAAA,aAAA,GAAgB,QAAQ,cAAe,CAAA,SAAA;AAC7C,IAAA,IAAA,CAAK,UAAa,GAAA,SAAA,CAAU,GAAI,CAAA,CAAC,UAAU,KAAU,KAAA;AAAA;AAAA,MAEjD,aAAA,CAAc,KAAK,CAAG,CAAA,SAAA;AAAA,MACtB;AAAA,KACH,CAAA;AAAA;AACL;AAAA,EAGA,mBAAmB,KAA4C,EAAA;AAC3D,IAAA,MAAM,cAAc,MAAM;AACtB,MAAA,QAAQ,KAAO;AAAA,QACX,KAAK,aAAA;AACD,UAAO,OAAA,uBAAA;AAAA,QACX,KAAK,aAAA;AACD,UAAO,OAAA,uBAAA;AAAA,QACX;AACI,UAAA,MAAM,IAAI,KAAM,CAAA,OAAA,CAAQ,QAAU,EAAA,CAAA,eAAA,EAAkB,KAAK,CAAG,CAAA,CAAA,CAAA;AAAA;AACpE,KACD,GAAA;AACH,IAAA,KAAA,MAAW,CAAC,SAAA,EAAW,QAAQ,CAAA,IAAK,KAAK,UAAY,EAAA;AACjD,MAAI,IAAA;AACA,QAAA,QAAA,CAAS,UAAU,CAAI,IAAA;AAAA,eAClB,CAAG,EAAA;AACR,QAAA,GAAA,CAAI,KAAM,CAAA,CAAA,qDAAA,EAAwD,SAAS,CAAA,CAAA,EAAI,CAAC,CAAA;AAAA;AACpF;AACJ;AAER;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NumberParserServiceImpl.js","sources":["NumberParserServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { NumberParserService } from \"../api\";\nimport { ServiceOptions } from \"../Service\";\nimport { createLogger, NumberParser } from \"@open-pioneer/core\";\n\nconst LOG = createLogger(\"runtime:NumberParserService\");\n\nexport class NumberParserServiceImpl implements NumberParserService {\n private numberParser: NumberParser;\n\n constructor(serviceOptions: ServiceOptions, locale: string) {\n try {\n this.numberParser = new NumberParser(locale);\n } catch (e) {\n LOG.warn(\n \"Failed to create NumberParserImpl with locale. Retrying with default 'en-US' locale.\",\n e\n );\n this.numberParser = new NumberParser(\"en-US\");\n }\n }\n\n parseNumber(numberString: string): number {\n return this.numberParser.parse(numberString);\n }\n}\n"],"names":[],"mappings":";;AAMA,MAAM,GAAA,GAAM,aAAa,6BAA6B,CAAA,CAAA;AAE/C,MAAM,uBAAuD,CAAA;AAAA,EACxD,YAAA,CAAA;AAAA,EAER,WAAA,CAAY,gBAAgC,MAAgB,EAAA;AACxD,IAAI,IAAA;AACA,MAAK,IAAA,CAAA,YAAA,GAAe,IAAI,YAAA,CAAa,MAAM,CAAA,CAAA;AAAA,aACtC,CAAG,EAAA;AACR,MAAI,GAAA,CAAA,IAAA;AAAA,QACA,sFAAA;AAAA,QACA,CAAA;AAAA,OACJ,CAAA;AACA,MAAK,IAAA,CAAA,YAAA,GAAe,IAAI,YAAA,CAAa,OAAO,CAAA,CAAA;AAAA,KAChD;AAAA,GACJ;AAAA,EAEA,YAAY,YAA8B,EAAA;AACtC,IAAO,OAAA,IAAA,CAAK,YAAa,CAAA,KAAA,CAAM,YAAY,CAAA,CAAA;AAAA,GAC/C;AACJ;;;;"}
1
+ {"version":3,"file":"NumberParserServiceImpl.js","sources":["NumberParserServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { NumberParserService } from \"../api\";\nimport { ServiceOptions } from \"../Service\";\nimport { createLogger, NumberParser } from \"@open-pioneer/core\";\n\nconst LOG = createLogger(\"runtime:NumberParserService\");\n\nexport class NumberParserServiceImpl implements NumberParserService {\n private numberParser: NumberParser;\n\n constructor(serviceOptions: ServiceOptions, locale: string) {\n try {\n this.numberParser = new NumberParser(locale);\n } catch (e) {\n LOG.warn(\n \"Failed to create NumberParserImpl with locale. Retrying with default 'en-US' locale.\",\n e\n );\n this.numberParser = new NumberParser(\"en-US\");\n }\n }\n\n parseNumber(numberString: string): number {\n return this.numberParser.parse(numberString);\n }\n}\n"],"names":[],"mappings":";;AAMA,MAAM,GAAA,GAAM,aAAa,6BAA6B,CAAA;AAE/C,MAAM,uBAAuD,CAAA;AAAA,EACxD,YAAA;AAAA,EAER,WAAA,CAAY,gBAAgC,MAAgB,EAAA;AACxD,IAAI,IAAA;AACA,MAAK,IAAA,CAAA,YAAA,GAAe,IAAI,YAAA,CAAa,MAAM,CAAA;AAAA,aACtC,CAAG,EAAA;AACR,MAAI,GAAA,CAAA,IAAA;AAAA,QACA,sFAAA;AAAA,QACA;AAAA,OACJ;AACA,MAAK,IAAA,CAAA,YAAA,GAAe,IAAI,YAAA,CAAa,OAAO,CAAA;AAAA;AAChD;AACJ,EAEA,YAAY,YAA8B,EAAA;AACtC,IAAO,OAAA,IAAA,CAAK,YAAa,CAAA,KAAA,CAAM,YAAY,CAAA;AAAA;AAEnD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createEmptyI18n } from \"../i18n\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport {\n createConstructorFactory,\n createFunctionFactory,\n ServiceRepr\n} from \"../service-layer/ServiceRepr\";\nimport { ApiServiceImpl } from \"./ApiServiceImpl\";\nimport { ApplicationContextImpl, ApplicationContextProperties } from \"./ApplicationContextImpl\";\nimport { ApplicationLifecycleEventService } from \"./ApplicationLifecycleEventService\";\nimport { NumberParserServiceImpl } from \"./NumberParserServiceImpl\";\n\nexport const RUNTIME_PACKAGE_NAME = \"@open-pioneer/runtime\";\nexport const RUNTIME_API_EXTENSION = \"integration.ApiExtension\";\nexport const RUNTIME_API_SERVICE = \"runtime.ApiService\";\nexport const RUNTIME_APPLICATION_CONTEXT = \"runtime.ApplicationContext\";\nexport const RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE =\n \"runtime.ApplicationLifecycleEventService\";\nexport const RUNTIME_NUMBER_PARSER_SERVICE = \"runtime.NumberParserService\";\nexport const RUNTIME_AUTO_START = \"runtime.AutoStart\";\n\nexport type BuiltinPackageProperties = ApplicationContextProperties;\n\n/**\n * Creates the builtin package containing the builtin services.\n *\n * The runtime package should not use services in the `build.config.mjs`\n * for a clean bootstrapping procedure (it will be instantiated without\n * generated application metadata in tests).\n *\n * This function is called as part of the service layer startup.\n * The package produced here is always part of the application.\n */\nexport function createBuiltinPackage(properties: BuiltinPackageProperties): PackageRepr {\n const i18n = createEmptyI18n();\n const apiService = new ServiceRepr({\n name: \"ApiServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApiServiceImpl),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_API_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"providers\",\n interfaceName: RUNTIME_API_EXTENSION,\n all: true\n }\n ]\n });\n const appContext = new ServiceRepr({\n name: \"ApplicationContextImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(\n (options) => new ApplicationContextImpl(options, properties)\n ),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_CONTEXT,\n qualifier: \"builtin\"\n }\n ]\n });\n const lifecycleEventService = new ServiceRepr({\n name: \"ApplicationLifecycleEventServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApplicationLifecycleEventService),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"listeners\",\n interfaceName: \"runtime.ApplicationLifecycleListener\",\n all: true\n }\n ]\n });\n const numberParserService = new ServiceRepr({\n name: \"NumberParserServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(\n (options) => new NumberParserServiceImpl(options, properties.locale)\n ),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_NUMBER_PARSER_SERVICE,\n qualifier: \"builtin\"\n }\n ]\n });\n\n return new PackageRepr({\n name: RUNTIME_PACKAGE_NAME,\n services: [apiService, appContext, lifecycleEventService, numberParserService],\n intl: i18n\n });\n}\n"],"names":[],"mappings":";;;;;;;;AAcO,MAAM,oBAAuB,GAAA,wBAAA;AAC7B,MAAM,qBAAwB,GAAA,2BAAA;AAC9B,MAAM,mBAAsB,GAAA,qBAAA;AAC5B,MAAM,2BAA8B,GAAA,6BAAA;AACpC,MAAM,2CACT,GAAA,2CAAA;AACG,MAAM,6BAAgC,GAAA,8BAAA;AACtC,MAAM,kBAAqB,GAAA,oBAAA;AAc3B,SAAS,qBAAqB,UAAmD,EAAA;AACpF,EAAA,MAAM,OAAO,eAAgB,EAAA,CAAA;AAC7B,EAAM,MAAA,UAAA,GAAa,IAAI,WAAY,CAAA;AAAA,IAC/B,IAAM,EAAA,gBAAA;AAAA,IACN,WAAa,EAAA,oBAAA;AAAA,IACb,OAAA,EAAS,yBAAyB,cAAc,CAAA;AAAA,IAChD,IAAM,EAAA,IAAA;AAAA,IACN,UAAY,EAAA;AAAA,MACR;AAAA,QACI,aAAe,EAAA,mBAAA;AAAA,QACf,SAAW,EAAA,SAAA;AAAA,OACf;AAAA,KACJ;AAAA,IACA,YAAc,EAAA;AAAA,MACV;AAAA,QACI,aAAe,EAAA,WAAA;AAAA,QACf,aAAe,EAAA,qBAAA;AAAA,QACf,GAAK,EAA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AAA;AAAA,QACf,SAAW,EAAA,SAAA;AAAA,OACf;AAAA,KACJ;AAAA,GACH,CAAA,CAAA;AAED,EAAA,OAAO,IAAI,WAAY,CAAA;AAAA,IACnB,IAAM,EAAA,oBAAA;AAAA,IACN,QAAU,EAAA,CAAC,UAAY,EAAA,UAAA,EAAY,uBAAuB,mBAAmB,CAAA;AAAA,IAC7E,IAAM,EAAA,IAAA;AAAA,GACT,CAAA,CAAA;AACL;;;;"}
1
+ {"version":3,"file":"index.js","sources":["index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createEmptyI18n } from \"../i18n\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport {\n createConstructorFactory,\n createFunctionFactory,\n ServiceRepr\n} from \"../service-layer/ServiceRepr\";\nimport { ApiServiceImpl } from \"./ApiServiceImpl\";\nimport { ApplicationContextImpl, ApplicationContextProperties } from \"./ApplicationContextImpl\";\nimport { ApplicationLifecycleEventService } from \"./ApplicationLifecycleEventService\";\nimport { NumberParserServiceImpl } from \"./NumberParserServiceImpl\";\n\nexport const RUNTIME_PACKAGE_NAME = \"@open-pioneer/runtime\";\nexport const RUNTIME_API_EXTENSION = \"integration.ApiExtension\";\nexport const RUNTIME_API_SERVICE = \"runtime.ApiService\";\nexport const RUNTIME_APPLICATION_CONTEXT = \"runtime.ApplicationContext\";\nexport const RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE =\n \"runtime.ApplicationLifecycleEventService\";\nexport const RUNTIME_NUMBER_PARSER_SERVICE = \"runtime.NumberParserService\";\nexport const RUNTIME_AUTO_START = \"runtime.AutoStart\";\n\nexport type BuiltinPackageProperties = ApplicationContextProperties;\n\n/**\n * Creates the builtin package containing the builtin services.\n *\n * The runtime package should not use services in the `build.config.mjs`\n * for a clean bootstrapping procedure (it will be instantiated without\n * generated application metadata in tests).\n *\n * This function is called as part of the service layer startup.\n * The package produced here is always part of the application.\n */\nexport function createBuiltinPackage(properties: BuiltinPackageProperties): PackageRepr {\n const i18n = createEmptyI18n();\n const apiService = new ServiceRepr({\n name: \"ApiServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApiServiceImpl),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_API_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"providers\",\n interfaceName: RUNTIME_API_EXTENSION,\n all: true\n }\n ]\n });\n const appContext = new ServiceRepr({\n name: \"ApplicationContextImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(\n (options) => new ApplicationContextImpl(options, properties)\n ),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_CONTEXT,\n qualifier: \"builtin\"\n }\n ]\n });\n const lifecycleEventService = new ServiceRepr({\n name: \"ApplicationLifecycleEventServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApplicationLifecycleEventService),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"listeners\",\n interfaceName: \"runtime.ApplicationLifecycleListener\",\n all: true\n }\n ]\n });\n const numberParserService = new ServiceRepr({\n name: \"NumberParserServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(\n (options) => new NumberParserServiceImpl(options, properties.locale)\n ),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_NUMBER_PARSER_SERVICE,\n qualifier: \"builtin\"\n }\n ]\n });\n\n return new PackageRepr({\n name: RUNTIME_PACKAGE_NAME,\n services: [apiService, appContext, lifecycleEventService, numberParserService],\n intl: i18n\n });\n}\n"],"names":[],"mappings":";;;;;;;;AAcO,MAAM,oBAAuB,GAAA;AAC7B,MAAM,qBAAwB,GAAA;AA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A,2CAAA;AAAA,QACf,SAAW,EAAA;AAAA;AACf,KACJ;AAAA,IACA,YAAc,EAAA;AAAA,MACV;AAAA,QACI,aAAe,EAAA,WAAA;AAAA,QACf,aAAe,EAAA,sCAAA;AAAA,QACf,GAAK,EAAA;AAAA;AACT;AACJ,GACH,CAAA;AACD,EAAM,MAAA,mBAAA,GAAsB,IAAI,WAAY,CAAA;AAAA,IACxC,IAAM,EAAA,yBAAA;AAAA,IACN,WAAa,EAAA,oBAAA;AAAA,IACb,OAAS,EAAA,qBAAA;AAAA,MACL,CAAC,OAAY,KAAA,IAAI,uBAAwB,CAAA,OAAA,EAAS,WAAW,MAAM;AAAA,KACvE;AAAA,IACA,IAAM,EAAA,IAAA;AAAA,IACN,UAAY,EAAA;AAAA,MACR;AAAA,QACI,aAAe,EAAA,6BAAA;AAAA,QACf,SAAW,EAAA;AAAA;AACf;AACJ,GACH,CAAA;AAED,EAAA,OAAO,IAAI,WAAY,CAAA;AAAA,IACnB,IAAM,EAAA,oBAAA;AAAA,IACN,QAAU,EAAA,CAAC,UAAY,EAAA,UAAA,EAAY,uBAAuB,mBAAmB,CAAA;AAAA,IAC7E,IAAM,EAAA;AAAA,GACT,CAAA;AACL;;;;"}
package/errors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sources":["errors.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nexport enum ErrorId {\n // Problems with application metadata\n INVALID_METADATA = \"runtime:invalid-metadata\",\n INVALID_PROPERTY_NAME = \"runtime:invalid-property-name\",\n REQUIRED_PROPERTY = \"runtime:required-property\",\n\n // Application lifecycle\n NOT_MOUNTED = \"runtime:element-not-mounted\",\n UNSUPPORTED_LOCALE = \"runtime:unsupported-locale\",\n CONFIG_RESOLUTION_FAILED = \"runtime:config-resolution-failed\",\n INVALID_STATE = \"runtime:invalid-state\",\n\n // Service layer\n INTERFACE_NOT_FOUND = \"runtime:interface-not-found\",\n AMBIGUOUS_DEPENDENCY = \"runtime:ambiguous-dependency\",\n UNDECLARED_DEPENDENCY = \"runtime:undeclared-dependency\",\n MISSING_PACKAGE = \"runtime:missing-package\",\n SERVICE_CONSTRUCTION_FAILED = \"runtime:service-construction-failed\",\n SERVICE_DESTRUCTION_FAILED = \"runtime:service-destruction-failed\",\n DUPLICATE_INTERFACE = \"runtime:duplicate-interface\",\n DEPENDENCY_CYCLE = \"runtime:dependency-cycle\",\n\n // Web component API\n DUPLICATE_API_METHODS = \"runtime:duplicate-api-methods\",\n\n // Internal\n INTERNAL = \"runtime:internal-error\"\n}\n"],"names":["ErrorId"],"mappings":"AAEY,IAAA,OAAA,qBAAAA,QAAL,KAAA;AAEH,EAAAA,SAAA,kBAAmB,CAAA,GAAA,0BAAA,CAAA;AACnB,EAAAA,SAAA,uBAAwB,CAAA,GAAA,+BAAA,CAAA;AACxB,EAAAA,SAAA,mBAAoB,CAAA,GAAA,2BAAA,CAAA;AAGpB,EAAAA,SAAA,aAAc,CAAA,GAAA,6BAAA,CAAA;AACd,EAAAA,SAAA,oBAAqB,CAAA,GAAA,4BAAA,CAAA;AACrB,EAAAA,SAAA,0BAA2B,CAAA,GAAA,kCAAA,CAAA;AAC3B,EAAAA,SAAA,eAAgB,CAAA,GAAA,uBAAA,CAAA;AAGhB,EAAAA,SAAA,qBAAsB,CAAA,GAAA,6BAAA,CAAA;AACtB,EAAAA,SAAA,sBAAuB,CAAA,GAAA,8BAAA,CAAA;AACvB,EAAAA,SAAA,uBAAwB,CAAA,GAAA,+BAAA,CAAA;AACxB,EAAAA,SAAA,iBAAkB,CAAA,GAAA,yBAAA,CAAA;AAClB,EAAAA,SAAA,6BAA8B,CAAA,GAAA,qCAAA,CAAA;AAC9B,EAAAA,SAAA,4BAA6B,CAAA,GAAA,oCAAA,CAAA;AAC7B,EAAAA,SAAA,qBAAsB,CAAA,GAAA,6BAAA,CAAA;AACtB,EAAAA,SAAA,kBAAmB,CAAA,GAAA,0BAAA,CAAA;AAGnB,EAAAA,SAAA,uBAAwB,CAAA,GAAA,+BAAA,CAAA;AAGxB,EAAAA,SAAA,UAAW,CAAA,GAAA,wBAAA,CAAA;AA1BH,EAAAA,OAAAA,QAAAA,CAAAA;AAAA,CAAA,EAAA,OAAA,IAAA,EAAA;;;;"}
1
+ {"version":3,"file":"errors.js","sources":["errors.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nexport enum ErrorId {\n // Problems with application metadata\n INVALID_METADATA = \"runtime:invalid-metadata\",\n INVALID_PROPERTY_NAME = \"runtime:invalid-property-name\",\n REQUIRED_PROPERTY = \"runtime:required-property\",\n\n // Application lifecycle\n NOT_MOUNTED = \"runtime:element-not-mounted\",\n UNSUPPORTED_LOCALE = \"runtime:unsupported-locale\",\n CONFIG_RESOLUTION_FAILED = \"runtime:config-resolution-failed\",\n INVALID_STATE = \"runtime:invalid-state\",\n\n // Service layer\n INTERFACE_NOT_FOUND = \"runtime:interface-not-found\",\n AMBIGUOUS_DEPENDENCY = \"runtime:ambiguous-dependency\",\n UNDECLARED_DEPENDENCY = \"runtime:undeclared-dependency\",\n MISSING_PACKAGE = \"runtime:missing-package\",\n SERVICE_CONSTRUCTION_FAILED = \"runtime:service-construction-failed\",\n SERVICE_DESTRUCTION_FAILED = \"runtime:service-destruction-failed\",\n DUPLICATE_INTERFACE = \"runtime:duplicate-interface\",\n DEPENDENCY_CYCLE = \"runtime:dependency-cycle\",\n\n // Web component API\n DUPLICATE_API_METHODS = \"runtime:duplicate-api-methods\",\n\n // Internal\n INTERNAL = \"runtime:internal-error\"\n}\n"],"names":["ErrorId"],"mappings":"AAEY,IAAA,OAAA,qBAAAA,QAAL,KAAA;AAEH,EAAAA,SAAA,kBAAmB,CAAA,GAAA,0BAAA;AACnB,EAAAA,SAAA,uBAAwB,CAAA,GAAA,+BAAA;AACxB,EAAAA,SAAA,mBAAoB,CAAA,GAAA,2BAAA;AAGpB,EAAAA,SAAA,aAAc,CAAA,GAAA,6BAAA;AACd,EAAAA,SAAA,oBAAqB,CAAA,GAAA,4BAAA;AACrB,EAAAA,SAAA,0BAA2B,CAAA,GAAA,kCAAA;AAC3B,EAAAA,SAAA,eAAgB,CAAA,GAAA,uBAAA;AAGhB,EAAAA,SAAA,qBAAsB,CAAA,GAAA,6BAAA;AACtB,EAAAA,SAAA,sBAAuB,CAAA,GAAA,8BAAA;AACvB,EAAAA,SAAA,uBAAwB,CAAA,GAAA,+BAAA;AACxB,EAAAA,SAAA,iBAAkB,CAAA,GAAA,yBAAA;AAClB,EAAAA,SAAA,6BAA8B,CAAA,GAAA,qCAAA;AAC9B,EAAAA,SAAA,4BAA6B,CAAA,GAAA,oCAAA;AAC7B,EAAAA,SAAA,qBAAsB,CAAA,GAAA,6BAAA;AACtB,EAAAA,SAAA,kBAAmB,CAAA,GAAA,0BAAA;AAGnB,EAAAA,SAAA,uBAAwB,CAAA,GAAA,+BAAA;AAGxB,EAAAA,SAAA,UAAW,CAAA,GAAA,wBAAA;AA1BH,EAAAA,OAAAA,QAAAA;AAAA,CAAA,EAAA,OAAA,IAAA,EAAA;;;;"}
package/i18n.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.js","sources":["i18n.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createIntl, createIntlCache, IntlFormatters, IntlShape } from \"@formatjs/intl\";\nimport { ErrorId } from \"./errors\";\nimport { createLogger, Error } from \"@open-pioneer/core\";\nimport { ApplicationMetadata } from \"./metadata\";\nconst LOG = createLogger(\"runtime:i18n\");\n\n/**\n * Represents i18n info for the entire application.\n * Currently not exposed to user code.\n */\nexport interface AppI18n {\n /** Chosen locale */\n readonly locale: string;\n\n /** Supported locales from app metadata. */\n readonly supportedMessageLocales: string[];\n\n /** True if the locale can be used in this application (i.e. if there are any messages). */\n supportsLocale(locale: string): boolean;\n\n /** Given the package name, constructs a package i18n instance. */\n createPackageI18n(packageName: string): PackageIntl;\n}\n\n/**\n * Gives access to the package's i18n messages for the current locale.\n *\n * See also https://formatjs.io/docs/intl\n */\nexport type PackageIntl = Pick<IntlShape, \"locale\" | \"timeZone\"> & IntlFormatters<string>;\n\nexport function createPackageIntl(locale: string, messages: Record<string, string>) {\n const cache = createIntlCache();\n return createIntl(\n {\n locale,\n messages\n },\n cache\n );\n}\n\n/**\n * Initializes the application's locale and fetches the appropriate i18n messages.\n */\nexport async function initI18n(\n appMetadata: ApplicationMetadata | undefined,\n forcedLocale: string | undefined\n): Promise<AppI18n> {\n const messageLocales = appMetadata?.locales ?? [];\n const userLocales = getBrowserLocales();\n if (LOG.isDebug()) {\n LOG.debug(\n `Attempting to pick locale for user (locales: ${userLocales.join(\n \", \"\n )}) from app (supported locales: ${messageLocales.join(\n \", \"\n )}) [forcedLocale=${forcedLocale}].`\n );\n }\n\n const i18nConfig = new I18nConfig(messageLocales);\n const { locale, messageLocale } = i18nConfig.pickSupportedLocale(forcedLocale, userLocales);\n\n if (LOG.isDebug()) {\n LOG.debug(`Using locale '${locale}' with messages from locale '${messageLocale}'.`);\n }\n\n let messages: Record<string, Record<string, string>>;\n if (messageLocales.includes(messageLocale)) {\n try {\n messages = (await appMetadata?.loadMessages?.(messageLocale)) ?? {};\n } catch (e) {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to load messages for locale '${messageLocale}'.`,\n {\n cause: e\n }\n );\n }\n }\n return {\n locale,\n supportedMessageLocales: messageLocales,\n supportsLocale(locale) {\n return i18nConfig.supportsLocale(locale);\n },\n createPackageI18n(packageName) {\n const packageMessage = messages?.[packageName] ?? {};\n return createPackageIntl(locale, packageMessage);\n }\n };\n}\n\n/** Creates an empty i18n instance, e.g. for tests. */\nexport function createEmptyI18n(locale = \"en\"): PackageIntl {\n return createPackageIntl(locale, {});\n}\n\nexport interface LocalePickResult {\n /**\n * The actual locale (e.g. en-US) for number and date formatting etc.\n */\n locale: string;\n\n /**\n * The locale identifier to load messages for. E.g. \"en\".\n */\n messageLocale: string;\n}\n\n/**\n * Picks a locale for the app. Exported for tests.\n */\nexport class I18nConfig {\n private appLocales: string[];\n\n /**\n * @param appLocales Locales the app has i18n messages for (e.g. \"en\", \"de\")\n */\n constructor(appLocales: string[]) {\n this.appLocales = appLocales;\n }\n\n /**\n * @param forcedLocale Optional forced locale (must be satisfied)\n * @param userLocales Locales requested by the user's browser\n */\n pickSupportedLocale(forcedLocale: string | undefined, userLocales: string[]): LocalePickResult {\n const { appLocales } = this;\n // Attempt to satisfy forced locale\n if (forcedLocale) {\n const result = this.pickImpl([forcedLocale]);\n if (!result) {\n const localesList = appLocales.join(\", \");\n throw new Error(\n ErrorId.UNSUPPORTED_LOCALE,\n `Locale '${forcedLocale}' cannot be forced because it is not supported by the application.` +\n ` Supported locales are ${localesList}.`\n );\n }\n if (result.locale !== result.messageLocale) {\n LOG.warn(\n `Non-exact match for forced locale '${forcedLocale}': using messages from '${result.messageLocale}'.`\n );\n }\n return result;\n }\n\n // Match preferred locale\n const supportedLocale = this.pickImpl(userLocales);\n if (supportedLocale) {\n return supportedLocale;\n }\n\n // Fallback: Most preferred locale (for dates etc.), but some of our messages\n return {\n locale: userLocales[0] ?? \"en\",\n messageLocale: appLocales[0] ?? \"en\"\n };\n }\n\n supportsLocale(locale: string): boolean {\n return this.pickImpl([locale]) != null;\n }\n\n private pickImpl(requestedLocales: string[]) {\n const appLocales = this.appLocales;\n for (const requestedLocale of requestedLocales) {\n // try exact match\n if (appLocales.includes(requestedLocale)) {\n return { messageLocale: requestedLocale, locale: requestedLocale };\n }\n\n // try plain language tag (e.g. \"en\") as fallback\n const plainLanguage = requestedLocale.match(/^([a-z]+)/i)?.[1];\n if (plainLanguage && appLocales.includes(plainLanguage)) {\n return { messageLocale: plainLanguage, locale: requestedLocale };\n }\n }\n return undefined;\n }\n}\n\n/**\n * Returns locales supported by the browser, in order of preference (preferred first).\n *\n * See also https://developer.mozilla.org/en-US/docs/Web/API/Navigator/languages\n */\nexport function getBrowserLocales(): string[] {\n if (window.navigator.languages && window.navigator.languages.length) {\n return Array.from(window.navigator.languages);\n }\n return [window.navigator.language];\n}\n"],"names":["locale"],"mappings":";;;;AAMA,MAAM,GAAA,GAAM,aAAa,cAAc,CAAA,CAAA;AA2BvB,SAAA,iBAAA,CAAkB,QAAgB,QAAkC,EAAA;AAChF,EAAA,MAAM,QAAQ,eAAgB,EAAA,CAAA;AAC9B,EAAO,OAAA,UAAA;AAAA,IACH;AAAA,MACI,MAAA;AAAA,MACA,QAAA;AAAA,KACJ;AAAA,IACA,KAAA;AAAA,GACJ,CAAA;AACJ,CAAA;AAKsB,eAAA,QAAA,CAClB,aACA,YACgB,EAAA;AAChB,EAAM,MAAA,cAAA,GAAiB,WAAa,EAAA,OAAA,IAAW,EAAC,CAAA;AAChD,EAAA,MAAM,cAAc,iBAAkB,EAAA,CAAA;AACtC,EAAI,IAAA,GAAA,CAAI,SAAW,EAAA;AACf,IAAI,GAAA,CAAA,KAAA;AAAA,MACA,gDAAgD,WAAY,CAAA,IAAA;AAAA,QACxD,IAAA;AAAA,OACH,kCAAkC,cAAe,CAAA,IAAA;AAAA,QAC9C,IAAA;AAAA,OACH,mBAAmB,YAAY,CAAA,EAAA,CAAA;AAAA,KACpC,CAAA;AAAA,GACJ;AAEA,EAAM,MAAA,UAAA,GAAa,IAAI,UAAA,CAAW,cAAc,CAAA,CAAA;AAChD,EAAA,MAAM,EAAE,MAAQ,EAAA,aAAA,KAAkB,UAAW,CAAA,mBAAA,CAAoB,cAAc,WAAW,CAAA,CAAA;AAE1F,EAAI,IAAA,GAAA,CAAI,SAAW,EAAA;AACf,IAAA,GAAA,CAAI,KAAM,CAAA,CAAA,cAAA,EAAiB,MAAM,CAAA,6BAAA,EAAgC,aAAa,CAAI,EAAA,CAAA,CAAA,CAAA;AAAA,GACtF;AAEA,EAAI,IAAA,Q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EAAE,aAAA,EAAe,eAAiB,EAAA,MAAA,EAAQ,eAAgB,EAAA,CAAA;AAAA,OACrE;AAGA,MAAA,MAAM,aAAgB,GAAA,eAAA,CAAgB,KAAM,CAAA,YAAY,IAAI,CAAC,CAAA,CAAA;AAC7D,MAAA,IAAI,aAAiB,IAAA,UAAA,CAAW,QAAS,CAAA,aAAa,CAAG,EAAA;AACrD,QAAA,OAAO,EAAE,aAAA,EAAe,aAAe,EAAA,MAAA,EAAQ,eAAgB,EAAA,CAAA;AAAA,OACnE;AAAA,KACJ;AACA,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACX;AACJ,CAAA;AAOO,SAAS,iBAA8B,GAAA;AAC1C,EAAA,IAAI,OAAO,SAAU,CAAA,SAAA,IAAa,MAAO,CAAA,SAAA,CAAU,UAAU,MAAQ,EAAA;AACjE,IAAA,OAAO,KAAM,CAAA,IAAA,CAAK,MAAO,CAAA,SAAA,CAAU,SAAS,CAAA,CAAA;AAAA,GAChD;AACA,EAAO,OAAA,CAAC,MAAO,CAAA,SAAA,CAAU,QAAQ,CAAA,CAAA;AACrC;;;;"}
1
+ {"version":3,"file":"i18n.js","sources":["i18n.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createIntl, createIntlCache, IntlFormatters, IntlShape } from \"@formatjs/intl\";\nimport { ErrorId } from \"./errors\";\nimport { createLogger, Error } from \"@open-pioneer/core\";\nimport { ApplicationMetadata } from \"./metadata\";\nconst LOG = createLogger(\"runtime:i18n\");\n\n/**\n * Represents i18n info for the entire application.\n * Currently not exposed to user code.\n */\nexport interface AppI18n {\n /** Chosen locale */\n readonly locale: string;\n\n /** Supported locales from app metadata. */\n readonly supportedMessageLocales: string[];\n\n /** True if the locale can be used in this application (i.e. if there are any messages). */\n supportsLocale(locale: string): boolean;\n\n /** Given the package name, constructs a package i18n instance. */\n createPackageI18n(packageName: string): PackageIntl;\n}\n\n/**\n * Gives access to the package's i18n messages for the current locale.\n *\n * See also https://formatjs.io/docs/intl\n */\nexport type PackageIntl = Pick<IntlShape, \"locale\" | \"timeZone\"> & IntlFormatters<string>;\n\nexport function createPackageIntl(locale: string, messages: Record<string, string>) {\n const cache = createIntlCache();\n return createIntl(\n {\n locale,\n messages\n },\n cache\n );\n}\n\n/**\n * Initializes the application's locale and fetches the appropriate i18n messages.\n */\nexport async function initI18n(\n appMetadata: ApplicationMetadata | undefined,\n forcedLocale: string | undefined\n): Promise<AppI18n> {\n const messageLocales = appMetadata?.locales ?? [];\n const userLocales = getBrowserLocales();\n if (LOG.isDebug()) {\n LOG.debug(\n `Attempting to pick locale for user (locales: ${userLocales.join(\n \", \"\n )}) from app (supported locales: ${messageLocales.join(\n \", \"\n )}) [forcedLocale=${forcedLocale}].`\n );\n }\n\n const i18nConfig = new I18nConfig(messageLocales);\n const { locale, messageLocale } = i18nConfig.pickSupportedLocale(forcedLocale, userLocales);\n\n if (LOG.isDebug()) {\n LOG.debug(`Using locale '${locale}' with messages from locale '${messageLocale}'.`);\n }\n\n let messages: Record<string, Record<string, string>>;\n if (messageLocales.includes(messageLocale)) {\n try {\n messages = (await appMetadata?.loadMessages?.(messageLocale)) ?? {};\n } catch (e) {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to load messages for locale '${messageLocale}'.`,\n {\n cause: e\n }\n );\n }\n }\n return {\n locale,\n supportedMessageLocales: messageLocales,\n supportsLocale(locale) {\n return i18nConfig.supportsLocale(locale);\n },\n createPackageI18n(packageName) {\n const packageMessage = messages?.[packageName] ?? {};\n return createPackageIntl(locale, packageMessage);\n }\n };\n}\n\n/** Creates an empty i18n instance, e.g. for tests. */\nexport function createEmptyI18n(locale = \"en\"): PackageIntl {\n return createPackageIntl(locale, {});\n}\n\nexport interface LocalePickResult {\n /**\n * The actual locale (e.g. en-US) for number and date formatting etc.\n */\n locale: string;\n\n /**\n * The locale identifier to load messages for. E.g. \"en\".\n */\n messageLocale: string;\n}\n\n/**\n * Picks a locale for the app. Exported for tests.\n */\nexport class I18nConfig {\n private appLocales: string[];\n\n /**\n * @param appLocales Locales the app has i18n messages for (e.g. \"en\", \"de\")\n */\n constructor(appLocales: string[]) {\n this.appLocales = appLocales;\n }\n\n /**\n * @param forcedLocale Optional forced locale (must be satisfied)\n * @param userLocales Locales requested by the user's browser\n */\n pickSupportedLocale(forcedLocale: string | undefined, userLocales: string[]): LocalePickResult {\n const { appLocales } = this;\n // Attempt to satisfy forced locale\n if (forcedLocale) {\n const result = this.pickImpl([forcedLocale]);\n if (!result) {\n const localesList = appLocales.join(\", \");\n throw new Error(\n ErrorId.UNSUPPORTED_LOCALE,\n `Locale '${forcedLocale}' cannot be forced because it is not supported by the application.` +\n ` Supported locales are ${localesList}.`\n );\n }\n if (result.locale !== result.messageLocale) {\n LOG.warn(\n `Non-exact match for forced locale '${forcedLocale}': using messages from '${result.messageLocale}'.`\n );\n }\n return result;\n }\n\n // Match preferred locale\n const supportedLocale = this.pickImpl(userLocales);\n if (supportedLocale) {\n return supportedLocale;\n }\n\n // Fallback: Most preferred locale (for dates etc.), but some of our messages\n return {\n locale: userLocales[0] ?? \"en\",\n messageLocale: appLocales[0] ?? \"en\"\n };\n }\n\n supportsLocale(locale: string): boolean {\n return this.pickImpl([locale]) != null;\n }\n\n private pickImpl(requestedLocales: string[]) {\n const appLocales = this.appLocales;\n for (const requestedLocale of requestedLocales) {\n // try exact match\n if (appLocales.includes(requestedLocale)) {\n return { messageLocale: requestedLocale, locale: requestedLocale };\n }\n\n // try plain language tag (e.g. \"en\") as fallback\n const plainLanguage = requestedLocale.match(/^([a-z]+)/i)?.[1];\n if (plainLanguage && appLocales.includes(plainLanguage)) {\n return { messageLocale: plainLanguage, locale: requestedLocale };\n }\n }\n return undefined;\n }\n}\n\n/**\n * Returns locales supported by the browser, in order of preference (preferred first).\n *\n * See also https://developer.mozilla.org/en-US/docs/Web/API/Navigator/languages\n */\nexport function getBrowserLocales(): string[] {\n if (window.navigator.languages && window.navigator.languages.length) {\n return Array.from(window.navigator.languages);\n }\n return [window.navigator.language];\n}\n"],"names":["locale"],"mappings":";;;;AAMA,MAAM,GAAA,GAAM,aAAa,cAAc,CAAA;AA2BvB,SAAA,iBAAA,CAAkB,QAAgB,QAAkC,EAAA;AAChF,EAAA,MAAM,QAAQ,eAAgB,EAAA;AAC9B,EAAO,OAAA,UAAA;AAAA,IACH;AAAA,MACI,MAAA;AAAA,MACA;AAAA,KACJ;AAAA,IACA;AAAA,GACJ;AACJ;AAKsB,eAAA,QAAA,CAClB,aACA,YACgB,EAAA;AAChB,EAAM,MAAA,cAAA,GAAiB,WAAa,EAAA,OAAA,IAAW,EAAC;AAChD,EAAA,MAAM,cAAc,iBAAkB,EAAA;AACtC,EAAI,IAAA,GAAA,CAAI,SAAW,EAAA;AACf,IAAI,GAAA,CAAA,KAAA;AAAA,MACA,gDAAgD,WAAY,CAAA,IAAA;AAAA,QACxD;AAAA,OACH,kCAAkC,cAAe,CAAA,IAAA;AAAA,QAC9C;AAAA,OACH,mBAAmB,YAAY,CAAA,EAAA;AAAA,KACpC;AAAA;AAGJ,EAAM,MAAA,UAAA,GAAa,IAAI,UAAA,CAAW,cAAc,CAAA;AAChD,EAAA,MAAM,EAAE,MAAQ,EAAA,aAAA,KAAkB,UAAW,CAAA,mBAAA,CAAoB,cAAc,WAAW,CAAA;AAE1F,EAAI,IAAA,GAAA,CAAI,SAAW,EAAA;AACf,IAAA,GAAA,CAAI,KAAM,CAAA,CAAA,cAAA,EAAiB,MAAM,CAAA,6BAAA,EAAgC,aAAa,CAAI,EAAA,CAAA,CAAA;AAAA;AAGtF,EAAI,IAAA,QAAA;AACJ,EAAI,IAAA,cAAA,CAAe,QAAS,CAAA,aAAa,CAAG,EAAA;AACxC,IAAI,IAAA;AACA,MAAA,QAAA,GAAY,MAAM,WAAA,EAAa,YAAe,GAAA,aAAa,KAAM,EAAC;AAAA,aAC7D,CAAG,EAAA;AACR,MAAA,MAAM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IAAa,MAAO,CAAA,SAAA,CAAU,UAAU,MAAQ,EAAA;AACjE,IAAA,OAAO,KAAM,CAAA,IAAA,CAAK,MAAO,CAAA,SAAA,CAAU,SAAS,CAAA;AAAA;AAEhD,EAAO,OAAA,CAAC,MAAO,CAAA,SAAA,CAAU,QAAQ,CAAA;AACrC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableBox.js","sources":["ObservableBox.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { EventEmitter, Resource } from \"@open-pioneer/core\";\n\nexport interface ObservableBox<T> {\n /** The current value. */\n readonly value: T;\n\n /**\n * Changes the current value.\n *\n * Note that this function is only present during development to facilitate hot reloading.\n */\n setValue?(value: T): void;\n\n /**\n * Register a listener callback that will be invoked\n * when the value changes.\n *\n * Note that this function is only present during development to facilitate hot reloading.\n */\n on?(event: \"changed\", listener: () => void): Resource;\n}\n\n/**\n * Returns a boxed value.\n * In development node, the box value can be changed and observed.\n */\nexport function createBox<T>(value: T): ObservableBox<T> {\n if (import.meta.env.DEV) {\n return new BoxImpl(value);\n } else {\n return {\n value\n };\n }\n}\n\nclass BoxImpl<T> extends EventEmitter<{ changed: void }> implements Required<ObservableBox<T>> {\n value: T;\n\n constructor(value: T) {\n super();\n this.value = value;\n }\n\n setValue(value: T): void {\n this.value = value;\n this.emit(\"changed\");\n }\n}\n"],"names":[],"mappings":";;AA4BO,SAAS,UAAa,KAA4B,EAAA;AACrD,EAAI,IAAA,MAAA,CAAA,IAAA,CAAY,IAAI,GAAK,EAAA;AACrB,IAAO,OAAA,IAAI,QAAQ,KAAK,CAAA,CAAA;AAAA,GACrB,MAAA;AACH,IAAO,OAAA;AAAA,MACH,KAAA;AAAA,KACJ,CAAA;AAAA,GACJ;AACJ,CAAA;AAEA,MAAM,gBAAmB,YAAsE,CAAA;AAAA,EAC3F,KAAA,CAAA;AAAA,EAEA,YAAY,KAAU,EAAA;AAClB,IAAM,KAAA,EAAA,CAAA;AACN,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AAAA,GACjB;AAAA,EAEA,SAAS,KAAgB,EAAA;AACrB,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,IAAA,CAAK,KAAK,SAAS,CAAA,CAAA;AAAA,GACvB;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\nimport { EventEmitter, Resource } from \"@open-pioneer/core\";\n\nexport interface ObservableBox<T> {\n /** The current value. */\n readonly value: T;\n\n /**\n * Changes the current value.\n *\n * Note that this function is only present during development to facilitate hot reloading.\n */\n setValue?(value: T): void;\n\n /**\n * Register a listener callback that will be invoked\n * when the value changes.\n *\n * Note that this function is only present during development to facilitate hot reloading.\n */\n on?(event: \"changed\", listener: () => void): Resource;\n}\n\n/**\n * Returns a boxed value.\n * In development node, the box value can be changed and observed.\n */\nexport function createBox<T>(value: T): ObservableBox<T> {\n if (import.meta.env.DEV) {\n return new BoxImpl(value);\n } else {\n return {\n value\n };\n }\n}\n\nclass BoxImpl<T> extends EventEmitter<{ changed: void }> implements Required<ObservableBox<T>> {\n value: T;\n\n constructor(value: T) {\n super();\n this.value = value;\n }\n\n setValue(value: T): void {\n this.value = value;\n this.emit(\"changed\");\n }\n}\n"],"names":[],"mappings":";;AA4BO,SAAS,UAAa,KAA4B,EAAA;AACrD,EAAI,IAAA,MAAA,CAAA,IAAA,CAAY,IAAI,GAAK,EAAA;AACrB,IAAO,OAAA,IAAI,QAAQ,KAAK,CAAA;AAAA,GACrB,MAAA;AACH,IAAO,OAAA;AAAA,MACH;AAAA,KACJ;AAAA;AAER;AAEA,MAAM,gBAAmB,YAAsE,CAAA;AAAA,EAC3F,KAAA;AAAA,EAEA,YAAY,KAAU,EAAA;AAClB,IAAM,KAAA,EAAA;AACN,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA;AAAA;AACjB,EAEA,SAAS,KAAgB,EAAA;AACrB,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA;AACb,IAAA,IAAA,CAAK,KAAK,SAAS,CAAA;AAAA;AAE3B;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/runtime",
4
- "version": "2.4.0",
4
+ "version": "3.0.0",
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
  "dependencies": {
17
- "@formatjs/intl": "^2.10.8",
18
- "react": "^18.3.1",
19
- "react-dom": "^18.3.1",
20
- "@open-pioneer/base-theme": "^2.4.0",
21
- "@open-pioneer/chakra-integration": "^2.4.0",
22
- "@open-pioneer/core": "^2.4.0",
23
- "@open-pioneer/runtime-react-support": "^2.4.0"
17
+ "@formatjs/intl": "^3.1.4",
18
+ "react": "^19.0.0",
19
+ "react-dom": "^19.0.0",
20
+ "@open-pioneer/base-theme": "^3.0.0",
21
+ "@open-pioneer/core": "^3.0.0",
22
+ "@open-pioneer/chakra-integration": "^3.0.0",
23
+ "@open-pioneer/runtime-react-support": "^3.0.0"
24
24
  },
25
25
  "exports": {
26
26
  "./package.json": "./package.json",
@@ -1 +1 @@
1
- {"version":3,"file":"ReactIntegration.js","sources":["ReactIntegration.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { theme as defaultTrailsTheme } from \"@open-pioneer/base-theme\";\nimport { CustomChakraProvider } from \"@open-pioneer/chakra-integration\";\nimport { Error } from \"@open-pioneer/core\";\nimport { PackageContext, PackageContextMethods } from \"@open-pioneer/runtime-react-support\";\nimport { ReactNode, StrictMode } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport { ErrorId } from \"../errors\";\nimport { InterfaceSpec, renderInterfaceSpec } from \"../service-layer/InterfaceSpec\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport { ServiceLayer } from \"../service-layer/ServiceLayer\";\nimport { renderAmbiguousServiceChoices } from \"../service-layer/ServiceLookup\";\n\nexport interface ReactIntegrationOptions {\n packages: Map<string, PackageRepr>;\n serviceLayer: ServiceLayer;\n rootNode: HTMLDivElement;\n container: Node;\n theme: Record<string, unknown> | undefined;\n}\n\nexport class ReactIntegration {\n private containerNode: Node;\n private theme: Record<string, unknown> | undefined;\n private root: Root;\n private packageContext: PackageContextMethods;\n\n static createForApp(options: ReactIntegrationOptions): ReactIntegration {\n const { serviceLayer, packages } = options;\n const packageContext = createPackageContext(serviceLayer, packages);\n return new ReactIntegration({ ...options, packageContext });\n }\n\n static createForErrorScreen(\n options: Omit<ReactIntegrationOptions, \"serviceLayer\" | \"packages\">\n ) {\n const throwError = () => {\n throw new Error(ErrorId.INVALID_STATE, \"Hook cannot be used within the error screen.\");\n };\n const packageContext: PackageContextMethods = {\n getIntl: throwError,\n getProperties: throwError,\n getService: throwError,\n getServices: throwError\n };\n return new ReactIntegration({ ...options, packageContext });\n }\n\n private constructor(\n options: Omit<ReactIntegrationOptions, \"serviceLayer\" | \"packages\"> & {\n packageContext: PackageContextMethods;\n }\n ) {\n this.containerNode = options.container;\n this.theme = options.theme;\n this.root = createRoot(options.rootNode);\n this.packageContext = options.packageContext;\n }\n\n render(contentNode: ReactNode) {\n this.root.render(\n <StrictMode>\n <CustomChakraProvider\n container={this.containerNode}\n colorMode=\"light\"\n theme={this.theme ?? defaultTrailsTheme}\n >\n <PackageContext.Provider value={this.packageContext}>\n {contentNode}\n </PackageContext.Provider>\n </CustomChakraProvider>\n </StrictMode>\n );\n }\n\n destroy() {\n this.root.unmount();\n }\n}\n\nfunction createPackageContext(\n serviceLayer: ServiceLayer,\n packages: Map<string, PackageRepr>\n): PackageContextMethods {\n const getPackage = (packageName: string): PackageRepr => {\n const pkg = packages.get(packageName);\n if (!pkg) {\n throw new Error(\n ErrorId.INTERNAL,\n `Package '${packageName}' was not found in application.`\n );\n }\n return pkg;\n };\n\n const packageContext: PackageContextMethods = {\n getService: (packageName, interfaceName, options) => {\n const spec: InterfaceSpec = { interfaceName, ...options };\n const result = serviceLayer.getService(packageName, spec);\n if (result.type === \"found\") {\n return result.value.getInstanceOrThrow();\n }\n\n const renderedSpec = renderInterfaceSpec(spec);\n switch (result.type) {\n case \"unimplemented\":\n throw new Error(\n ErrorId.INTERFACE_NOT_FOUND,\n `The UI of package '${packageName}' requested the unimplemented interface ${renderedSpec}.`\n );\n case \"undeclared\":\n throw new Error(\n ErrorId.UNDECLARED_DEPENDENCY,\n `Package '${packageName}' did not declare an UI dependency on interface ${renderedSpec}.` +\n ` Add the dependency to the package configuration or remove the usage.`\n );\n case \"ambiguous\": {\n const renderedChoices = renderAmbiguousServiceChoices(result.choices);\n throw new Error(\n ErrorId.AMBIGUOUS_DEPENDENCY,\n `The UI of package '${packageName}' requires the ambiguous interface ${renderedSpec}.` +\n ` Possible choices are: ${renderedChoices}.`\n );\n }\n case \"unknown-package\":\n throw new Error(\n ErrorId.MISSING_PACKAGE,\n missingPackageMessage(packageName, interfaceName)\n );\n }\n },\n getServices: (packageName, interfaceName) => {\n const result = serviceLayer.getServices(packageName, interfaceName);\n if (result.type === \"found\") {\n return result.value.map((serviceRepr) => serviceRepr.getInstanceOrThrow());\n }\n\n switch (result.type) {\n case \"undeclared\":\n throw new Error(\n ErrorId.UNDECLARED_DEPENDENCY,\n `Package '${packageName}' did not declare an UI dependency on all services implementing interface '${interfaceName}'.` +\n ` Add the dependency (\"all\": true) to the package configuration or remove the usage.`\n );\n case \"unknown-package\":\n throw new Error(\n ErrorId.MISSING_PACKAGE,\n missingPackageMessage(packageName, interfaceName)\n );\n }\n },\n getProperties: (packageName) => {\n return getPackage(packageName).properties;\n },\n getIntl: (packageName) => {\n return getPackage(packageName).intl;\n }\n };\n return packageContext;\n}\n\nfunction missingPackageMessage(packageName: string, interfaceName: string) {\n return (\n `Package '${packageName}' was not found in the application's metadata while it attempted to reference the interface '${interfaceName}'. ` +\n `Check that the dependency is declared correctly in the packages that use '${packageName}'.`\n );\n}\n"],"names":["defaultTrailsTheme"],"mappings":";;;;;;;;;;;AAsBO,MAAM,gBAAiB,CAAA;AAAA,EAClB,aAAA,CAAA;AAAA,EACA,KAAA,CAAA;AAAA,EACA,IAAA,CAAA;AAAA,EACA,cAAA,CAAA;AAAA,EAER,OAAO,aAAa,OAAoD,EAAA;AACpE,IAAM,MAAA,EAAE,YAAc,EAAA,QAAA,EAAa,GAAA,OAAA,CAAA;AACnC,IAAM,MAAA,cAAA,GAAiB,oBAAqB,CAAA,YAAA,EAAc,QAAQ,CAAA,CAAA;AAClE,IAAA,OAAO,IAAI,gBAAiB,CAAA,EAAE,GAAG,OAAA,EAAS,gBAAgB,CAAA,CAAA;AAAA,GAC9D;AAAA,EAEA,OAAO,qBACH,OACF,EAAA;AACE,IAAA,MAAM,aAAa,MAAM;AACrB,MAAA,MAAM,IAAI,KAAA,CAAM,OAAQ,CAAA,aAAA,EAAe,8CAA8C,CAAA,CAAA;AAAA,KACzF,CAAA;AACA,IAAA,MAAM,cAAwC,GAAA;AAAA,MAC1C,OAAS,EAAA,UAAA;AAAA,MACT,aAAe,EAAA,UAAA;AAAA,MACf,UAAY,EAAA,UAAA;AAAA,MACZ,WAAa,EAAA,UAAA;AAAA,KACjB,CAAA;AACA,IAAA,OAAO,IAAI,gBAAiB,CAAA,EAAE,GAAG,OAAA,EAAS,gBAAgB,CAAA,CAAA;AAAA,GAC9D;AAAA,EAEQ,YACJ,OAGF,EAAA;AACE,IAAA,IAAA,CAAK,gBAAgB,OAAQ,CAAA,SAAA,CAAA;AAC7B,IAAA,IAAA,CAAK,QAAQ,OAAQ,CAAA,KAAA,CAAA;AACrB,IAAK,IAAA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Aa,CAAA,CAAA;AAClE,MAAI,IAAA,MAAA,CAAO,SAAS,OAAS,EAAA;AACzB,QAAA,OAAO,OAAO,KAAM,CAAA,GAAA,CAAI,CAAC,WAAgB,KAAA,WAAA,CAAY,oBAAoB,CAAA,CAAA;AAAA,OAC7E;AAEA,MAAA,QAAQ,OAAO,IAAM;AAAA,QACjB,KAAK,YAAA;AACD,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAQ,CAAA,qBAAA;AAAA,YACR,CAAA,SAAA,EAAY,WAAW,CAAA,2EAAA,EAA8E,aAAa,CAAA,qFAAA,CAAA;AAAA,WAEtH,CAAA;AAAA,QACJ,KAAK,iBAAA;AACD,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAQ,CAAA,eAAA;AAAA,YACR,qBAAA,CAAsB,aAAa,aAAa,CAAA;AAAA,WACpD,CAAA;AAAA,OACR;AAAA,KACJ;AAAA,IACA,aAAA,EAAe,CAAC,WAAgB,KAAA;AAC5B,MAAO,OAAA,UAAA,CAAW,WAAW,CAAE,CAAA,UAAA,CAAA;AAAA,KACnC;AAAA,IACA,OAAA,EAAS,CAAC,WAAgB,KAAA;AACtB,MAAO,OAAA,UAAA,CAAW,WAAW,CAAE,CAAA,IAAA,CAAA;AAAA,KACnC;AAAA,GACJ,CAAA;AACA,EAAO,OAAA,cAAA,CAAA;AACX,CAAA;AAEA,SAAS,qBAAA,CAAsB,aAAqB,aAAuB,EAAA;AACvE,EAAA,OACI,CAAY,SAAA,EAAA,WAAW,CAAgG,6FAAA,EAAA,aAAa,gFACvD,WAAW,CAAA,EAAA,CAAA,CAAA;AAEhG;;;;"}
1
+ {"version":3,"file":"ReactIntegration.js","sources":["ReactIntegration.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { theme as defaultTrailsTheme } from \"@open-pioneer/base-theme\";\nimport { CustomChakraProvider } from \"@open-pioneer/chakra-integration\";\nimport { Error } from \"@open-pioneer/core\";\nimport { PackageContext, PackageContextMethods } from \"@open-pioneer/runtime-react-support\";\nimport { ReactNode, StrictMode } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport { ErrorId } from \"../errors\";\nimport { InterfaceSpec, renderInterfaceSpec } from \"../service-layer/InterfaceSpec\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport { ServiceLayer } from \"../service-layer/ServiceLayer\";\nimport { renderAmbiguousServiceChoices } from \"../service-layer/ServiceLookup\";\n\nexport interface ReactIntegrationOptions {\n packages: Map<string, PackageRepr>;\n serviceLayer: ServiceLayer;\n rootNode: HTMLDivElement;\n container: Node;\n theme: Record<string, unknown> | undefined;\n}\n\nexport class ReactIntegration {\n private containerNode: Node;\n private theme: Record<string, unknown> | undefined;\n private root: Root;\n private packageContext: PackageContextMethods;\n\n static createForApp(options: ReactIntegrationOptions): ReactIntegration {\n const { serviceLayer, packages } = options;\n const packageContext = createPackageContext(serviceLayer, packages);\n return new ReactIntegration({ ...options, packageContext });\n }\n\n static createForErrorScreen(\n options: Omit<ReactIntegrationOptions, \"serviceLayer\" | \"packages\">\n ) {\n const throwError = () => {\n throw new Error(ErrorId.INVALID_STATE, \"Hook cannot be used within the error screen.\");\n };\n const packageContext: PackageContextMethods = {\n getIntl: throwError,\n getProperties: throwError,\n getService: throwError,\n getServices: throwError\n };\n return new ReactIntegration({ ...options, packageContext });\n }\n\n private constructor(\n options: Omit<ReactIntegrationOptions, \"serviceLayer\" | \"packages\"> & {\n packageContext: PackageContextMethods;\n }\n ) {\n this.containerNode = options.container;\n this.theme = options.theme;\n this.root = createRoot(options.rootNode);\n this.packageContext = options.packageContext;\n }\n\n render(contentNode: ReactNode) {\n this.root.render(\n <StrictMode>\n <CustomChakraProvider\n container={this.containerNode}\n colorMode=\"light\"\n theme={this.theme ?? defaultTrailsTheme}\n >\n <PackageContext.Provider value={this.packageContext}>\n {contentNode}\n </PackageContext.Provider>\n </CustomChakraProvider>\n </StrictMode>\n );\n }\n\n destroy() {\n this.root.unmount();\n }\n}\n\nfunction createPackageContext(\n serviceLayer: ServiceLayer,\n packages: Map<string, PackageRepr>\n): PackageContextMethods {\n const getPackage = (packageName: string): PackageRepr => {\n const pkg = packages.get(packageName);\n if (!pkg) {\n throw new Error(\n ErrorId.INTERNAL,\n `Package '${packageName}' was not found in application.`\n );\n }\n return pkg;\n };\n\n const packageContext: PackageContextMethods = {\n getService: (packageName, interfaceName, options) => {\n const spec: InterfaceSpec = { interfaceName, ...options };\n const result = serviceLayer.getService(packageName, spec);\n if (result.type === \"found\") {\n return result.value.getInstanceOrThrow();\n }\n\n const renderedSpec = renderInterfaceSpec(spec);\n switch (result.type) {\n case \"unimplemented\":\n throw new Error(\n ErrorId.INTERFACE_NOT_FOUND,\n `The UI of package '${packageName}' requested the unimplemented interface ${renderedSpec}.`\n );\n case \"undeclared\":\n throw new Error(\n ErrorId.UNDECLARED_DEPENDENCY,\n `Package '${packageName}' did not declare an UI dependency on interface ${renderedSpec}.` +\n ` Add the dependency to the package configuration or remove the usage.`\n );\n case \"ambiguous\": {\n const renderedChoices = renderAmbiguousServiceChoices(result.choices);\n throw new Error(\n ErrorId.AMBIGUOUS_DEPENDENCY,\n `The UI of package '${packageName}' requires the ambiguous interface ${renderedSpec}.` +\n ` Possible choices are: ${renderedChoices}.`\n );\n }\n case \"unknown-package\":\n throw new Error(\n ErrorId.MISSING_PACKAGE,\n missingPackageMessage(packageName, interfaceName)\n );\n }\n },\n getServices: (packageName, interfaceName) => {\n const result = serviceLayer.getServices(packageName, interfaceName);\n if (result.type === \"found\") {\n return result.value.map((serviceRepr) => serviceRepr.getInstanceOrThrow());\n }\n\n switch (result.type) {\n case \"undeclared\":\n throw new Error(\n ErrorId.UNDECLARED_DEPENDENCY,\n `Package '${packageName}' did not declare an UI dependency on all services implementing interface '${interfaceName}'.` +\n ` Add the dependency (\"all\": true) to the package configuration or remove the usage.`\n );\n case \"unknown-package\":\n throw new Error(\n ErrorId.MISSING_PACKAGE,\n missingPackageMessage(packageName, interfaceName)\n );\n }\n },\n getProperties: (packageName) => {\n return getPackage(packageName).properties;\n },\n getIntl: (packageName) => {\n return getPackage(packageName).intl;\n }\n };\n return packageContext;\n}\n\nfunction missingPackageMessage(packageName: string, interfaceName: string) {\n return (\n `Package '${packageName}' was not found in the application's metadata while it attempted to reference the interface '${interfaceName}'. ` +\n `Check that the dependency is declared correctly in the packages that use '${packageName}'.`\n );\n}\n"],"names":["defaultTrailsTheme"],"mappings":";;;;;;;;;;;AAsBO,MAAM,gBAAiB,CAAA;AAAA,EAClB,aAAA;AAAA,EACA,KAAA;AAAA,EACA,IAAA;AAAA,EACA,cAAA;AAAA,EAER,OAAO,aAAa,OAAoD,EAAA;AACpE,IAAM,MAAA,EAAE,YAAc,EAAA,QAAA,EAAa,GAAA,OAAA;AACnC,IAAM,MAAA,cAAA,GAAiB,oBAAqB,CAAA,YAAA,EAAc,QAAQ,CAAA;AAClE,IAAA,OAAO,IAAI,gBAAiB,CAAA,EAAE,GAAG,OAAA,EAAS,gBAAgB,CAAA;AAAA;AAC9D,EAEA,OAAO,qBACH,OACF,EAAA;AACE,IAAA,MAAM,aAAa,MAAM;AACrB,MAAA,MAAM,IAAI,KAAA,CAAM,OAAQ,CAAA,aAAA,EAAe,8CAA8C,CAAA;AAAA,KACzF;AACA,IAAA,MAAM,cAAwC,GAAA;AAAA,MAC1C,OAAS,EAAA,UAAA;AAAA,MACT,aAAe,EAAA,UAAA;AAAA,MACf,UAAY,EAAA,UAAA;AAAA,MACZ,WAAa,EAAA;AAAA,KACjB;AACA,IAAA,OAAO,IAAI,gBAAiB,CAAA,EAAE,GAAG,OAAA,EAAS,gBAAgB,CAAA;AAAA;AAC9D,EAEQ,YACJ,OAGF,EAAA;AACE,IAAA,IAAA,CAAK,gBAAgB,OAAQ,CAAA,SAAA;AAC7B,IAAA,IAAA,CAAK,QAAQ,OAAQ,CAAA,KAAA;AACrB,IAAK,IAAA,CAA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B,KAAK,YAAA;AACD,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAQ,CAAA,qBAAA;AAAA,YACR,CAAA,SAAA,EAAY,WAAW,CAAA,2EAAA,EAA8E,aAAa,CAAA,qFAAA;AAAA,WAEtH;AAAA,QACJ,KAAK,iBAAA;AACD,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAQ,CAAA,eAAA;AAAA,YACR,qBAAA,CAAsB,aAAa,aAAa;AAAA,WACpD;AAAA;AACR,KACJ;AAAA,IACA,aAAA,EAAe,CAAC,WAAgB,KAAA;AAC5B,MAAO,OAAA,UAAA,CAAW,WAAW,CAAE,CAAA,UAAA;AAAA,KACnC;AAAA,IACA,OAAA,EAAS,CAAC,WAAgB,KAAA;AACtB,MAAO,OAAA,UAAA,CAAW,WAAW,CAAE,CAAA,IAAA;AAAA;AACnC,GACJ;AACA,EAAO,OAAA,cAAA;AACX;AAEA,SAAS,qBAAA,CAAsB,aAAqB,aAAuB,EAAA;AACvE,EAAA,OACI,CAAY,SAAA,EAAA,WAAW,CAAgG,6FAAA,EAAA,aAAa,gFACvD,WAAW,CAAA,EAAA,CAAA;AAEhG;;;;"}
@@ -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, 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;;;;"}
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\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 }\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AAA,KACvD;AAAA;AAEJ,EAAO,OAAA,WAAA;AACX;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"InterfaceSpec.js","sources":["InterfaceSpec.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\nimport { InterfaceReferenceMetadata } from \"../metadata\";\n\n/**\n * Describes the implementation of an interface.\n */\nexport interface InterfaceSpec {\n interfaceName: string;\n qualifier?: string | undefined;\n}\n\nexport function renderInterfaceSpec({ interfaceName, qualifier }: InterfaceSpec): string {\n return `'${interfaceName}'` + (qualifier ? ` (qualifier: '${qualifier}')` : \"\");\n}\n\nexport interface SingleImplementationSpec extends InterfaceSpec {\n all?: undefined;\n}\n\nexport interface AllImplementationsSpec extends Pick<InterfaceSpec, \"interfaceName\"> {\n all: true;\n}\n\n/**\n * Describes a reference to one or more implementations of an interface.\n */\nexport type ReferenceSpec = SingleImplementationSpec | AllImplementationsSpec;\n\nexport function parseReferenceSpec(metadata: InterfaceReferenceMetadata): ReferenceSpec {\n if (!metadata) {\n throw new Error(ErrorId.INVALID_METADATA, \"Missing reference metadata.\");\n }\n if (metadata.all && metadata.qualifier) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n \"References can't use 'qualifier' and 'all' properties at the same time.\"\n );\n }\n if (metadata.all) {\n return {\n all: true,\n interfaceName: metadata.name\n };\n }\n return {\n interfaceName: metadata.name,\n qualifier: metadata.qualifier\n };\n}\n\nexport function isSingleImplementationSpec(spec: ReferenceSpec): spec is SingleImplementationSpec {\n return !spec.all;\n}\n\nexport function isAllImplementationsSpec(spec: ReferenceSpec): spec is AllImplementationsSpec {\n return spec.all === true;\n}\n"],"names":[],"mappings":";;;AAcO,SAAS,mBAAoB,CAAA,EAAE,aAAe,EAAA,SAAA,EAAoC,EAAA;AACrF,EAAA,OAAO,IAAI,aAAa,CAAA,CAAA,CAAA,IAAO,SAAY,GAAA,CAAA,cAAA,EAAiB,SAAS,CAAO,EAAA,CAAA,GAAA,EAAA,CAAA,CAAA;AAChF,CAAA;AAeO,SAAS,mBAAmB,QAAqD,EAAA;AACpF,EAAA,IAAI,CAAC,QAAU,EAAA;AACX,IAAA,MAAM,IAAI,KAAA,CAAM,OAAQ,CAAA,gBAAA,EAAkB,6BAA6B,CAAA,CAAA;AAAA,GAC3E;AACA,EAAI,IAAA,QAAA,CAAS,GAAO,IAAA,QAAA,CAAS,SAAW,EAAA;AACpC,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,OAAQ,CAAA,gBAAA;AAAA,MACR,yEAAA;AAAA,KACJ,CAAA;AAAA,GACJ;AACA,EAAA,IAAI,SAAS,GAAK,EAAA;AACd,IAAO,OAAA;AAAA,MACH,GAAK,EAAA,IAAA;AAAA,MACL,eAAe,QAAS,CAAA,IAAA;AAAA,KAC5B,CAAA;AAAA,GACJ;AACA,EAAO,OAAA;AAAA,IACH,eAAe,QAAS,CAAA,IAAA;AAAA,IACxB,WAAW,QAAS,CAAA,SAAA;AAAA,GACxB,CAAA;AACJ,CAAA;AAEO,SAAS,2BAA2B,IAAuD,EAAA;AAC9F,EAAA,OAAO,CAAC,IAAK,CAAA,GAAA,CAAA;AACjB,CAAA;AAEO,SAAS,yBAAyB,IAAqD,EAAA;AAC1F,EAAA,OAAO,KAAK,GAAQ,KAAA,IAAA,CAAA;AACxB;;;;"}
1
+ {"version":3,"file":"InterfaceSpec.js","sources":["InterfaceSpec.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\nimport { InterfaceReferenceMetadata } from \"../metadata\";\n\n/**\n * Describes the implementation of an interface.\n */\nexport interface InterfaceSpec {\n interfaceName: string;\n qualifier?: string | undefined;\n}\n\nexport function renderInterfaceSpec({ interfaceName, qualifier }: InterfaceSpec): string {\n return `'${interfaceName}'` + (qualifier ? ` (qualifier: '${qualifier}')` : \"\");\n}\n\nexport interface SingleImplementationSpec extends InterfaceSpec {\n all?: undefined;\n}\n\nexport interface AllImplementationsSpec extends Pick<InterfaceSpec, \"interfaceName\"> {\n all: true;\n}\n\n/**\n * Describes a reference to one or more implementations of an interface.\n */\nexport type ReferenceSpec = SingleImplementationSpec | AllImplementationsSpec;\n\nexport function parseReferenceSpec(metadata: InterfaceReferenceMetadata): ReferenceSpec {\n if (!metadata) {\n throw new Error(ErrorId.INVALID_METADATA, \"Missing reference metadata.\");\n }\n if (metadata.all && metadata.qualifier) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n \"References can't use 'qualifier' and 'all' properties at the same time.\"\n );\n }\n if (metadata.all) {\n return {\n all: true,\n interfaceName: metadata.name\n };\n }\n return {\n interfaceName: metadata.name,\n qualifier: metadata.qualifier\n };\n}\n\nexport function isSingleImplementationSpec(spec: ReferenceSpec): spec is SingleImplementationSpec {\n return !spec.all;\n}\n\nexport function isAllImplementationsSpec(spec: ReferenceSpec): spec is AllImplementationsSpec {\n return spec.all === true;\n}\n"],"names":[],"mappings":";;;AAcO,SAAS,mBAAoB,CAAA,EAAE,aAAe,EAAA,SAAA,EAAoC,EAAA;AACrF,EAAA,OAAO,IAAI,aAAa,CAAA,CAAA,CAAA,IAAO,SAAY,GAAA,CAAA,cAAA,EAAiB,SAAS,CAAO,EAAA,CAAA,GAAA,EAAA,CAAA;AAChF;AAeO,SAAS,mBAAmB,QAAqD,EAAA;AACpF,EAAA,IAAI,CAAC,QAAU,EAAA;AACX,IAAA,MAAM,IAAI,KAAA,CAAM,OAAQ,CAAA,gBAAA,EAAkB,6BAA6B,CAAA;AAAA;AAE3E,EAAI,IAAA,QAAA,CAAS,GAAO,IAAA,QAAA,CAAS,SAAW,EAAA;AACpC,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,OAAQ,CAAA,gBAAA;AAAA,MACR;AAAA,KACJ;AAAA;AAEJ,EAAA,IAAI,SAAS,GAAK,EAAA;AACd,IAAO,OAAA;AAAA,MACH,GAAK,EAAA,IAAA;AAAA,MACL,eAAe,QAAS,CAAA;AAAA,KAC5B;AAAA;AAEJ,EAAO,OAAA;AAAA,IACH,eAAe,QAAS,CAAA,IAAA;AAAA,IACxB,WAAW,QAAS,CAAA;AAAA,GACxB;AACJ;AAEO,SAAS,2BAA2B,IAAuD,EAAA;AAC9F,EAAA,OAAO,CAAC,IAAK,CAAA,GAAA;AACjB;AAEO,SAAS,yBAAyB,IAAqD,EAAA;AAC1F,EAAA,OAAO,KAAK,GAAQ,KAAA,IAAA;AACxB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"PackageRepr.js","sources":["PackageRepr.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Error } from \"@open-pioneer/core\";\nimport { ApplicationProperties } from \"../CustomElement\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl, AppI18n } from \"../i18n\";\nimport { PackageMetadata, PropertyMetadata } from \"../metadata\";\nimport { parseReferenceSpec, ReferenceSpec } from \"./InterfaceSpec\";\nimport { ServiceRepr } from \"./ServiceRepr\";\n\nexport interface PackageReprOptions {\n name: string;\n intl: PackageIntl;\n services?: ServiceRepr[];\n uiReferences?: ReferenceSpec[];\n properties?: Record<string, unknown>;\n}\n\nexport class PackageRepr {\n static create(\n data: PackageMetadata,\n i18n: PackageIntl,\n customProperties?: Record<string, unknown>\n ): PackageRepr {\n const name = data.name;\n const properties = data.properties ?? {};\n const finalProperties = customizeProperties(name, properties, customProperties);\n const services = Object.entries(data.services ?? {}).map<ServiceRepr>(\n ([name, serviceData]) => {\n if (name !== serviceData.name) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n \"Invalid metadata: service name mismatch.\"\n );\n }\n return ServiceRepr.create(data.name, serviceData, i18n, finalProperties);\n }\n );\n const uiReferences = data.ui?.references?.map((ref) => parseReferenceSpec(ref)) ?? [];\n return new PackageRepr({\n name,\n services,\n uiReferences,\n properties: finalProperties,\n intl: i18n\n });\n }\n\n /** Package name */\n readonly name: string;\n\n /** Services defined by the package */\n readonly services: readonly ServiceRepr[];\n\n /** Interfaces required by UI components. */\n readonly uiReferences: readonly Readonly<ReferenceSpec>[];\n\n /** Resolved (perhaps customized) package properties. */\n readonly properties: Readonly<Record<string, unknown>>;\n\n /** Locale-dependant i18n messages. */\n readonly intl: PackageIntl;\n\n constructor(options: PackageReprOptions) {\n const name = options.name;\n if (!isValidPackageName(name)) {\n throw new Error(ErrorId.INTERNAL, `Invalid package name: '${name}'.`);\n }\n\n this.name = name;\n this.services = options.services ?? [];\n this.uiReferences = options.uiReferences ?? [];\n this.properties = options.properties ?? {};\n this.intl = options.intl;\n }\n}\n\nexport function createPackages(\n packages: Record<string, PackageMetadata>,\n i18n: AppI18n,\n customProperties?: ApplicationProperties\n) {\n return Object.entries(packages).map<PackageRepr>(([name, packageMetadata]) => {\n if (name !== packageMetadata.name) {\n throw new Error(ErrorId.INVALID_METADATA, \"Invalid metadata: package name mismatch.\");\n }\n\n const packageI18n = i18n.createPackageI18n(name);\n return PackageRepr.create(packageMetadata, packageI18n, customProperties?.[name]);\n });\n}\n\n/**\n * Merges the declared properties of the package with the application-defined\n * custom properties.\n */\nfunction customizeProperties(\n packageName: string,\n properties: Record<string, PropertyMetadata>,\n customProperties: Record<string, unknown> = {}\n) {\n const merged: Record<string, unknown> = {};\n const required: string[] = [];\n for (const [key, propertyMetadata] of Object.entries(properties)) {\n merged[key] = propertyMetadata.value;\n if (propertyMetadata.required) {\n required.push(key);\n }\n }\n\n for (const [key, value] of Object.entries(customProperties)) {\n if (!hasProperty(merged, key)) {\n throw new Error(\n ErrorId.INVALID_PROPERTY_NAME,\n `Unexpected property name '${key}' for package '${packageName}': the property does not exist.`\n );\n }\n merged[key] = value;\n }\n\n for (const key of required) {\n const value = merged[key];\n if (value == null) {\n throw new Error(\n ErrorId.REQUIRED_PROPERTY,\n `Package '${packageName}' requires the property '${key}' to be initialized to a non-null value.`\n );\n }\n }\n\n return merged;\n}\n\nconst HAS_PROP = Object.prototype.hasOwnProperty;\n\nfunction hasProperty(object: unknown, key: string) {\n return HAS_PROP.call(object, key);\n}\n\n// http://json.schemastore.org/package\nconst NAME_REGEX = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/;\n\nfunction isValidPackageName(name: string): boolean {\n return NAME_REGEX.test(name);\n}\n"],"names":["name"],"mappings":";;;;;AAkBO,MAAM,WAAY,CAAA;AAAA,EACrB,OAAO,MAAA,CACH,IACA,EAAA,IAAA,EACA,gBACW,EAAA;AACX,IAAA,MAAM,OAAO,IAAK,CAAA,IAAA,CAAA;AAClB,IAAM,MAAA,UAAA,GAAa,IAAK,CAAA,UAAA,IAAc,EAAC,CAAA;AACvC,IAAA,MAAM,eAAkB,GAAA,mBAAA,CAAoB,IAAM,EAAA,UAAA,EAAY,gBAAgB,CAAA,CAAA;AAC9E,IAAA,MAAM,WAAW,MAAO,CAAA,OAAA,CAAQ,KAAK,QAAY,IAAA,EAAE,CAAE,CAAA,GAAA;AAAA,MACjD,CAAC,CAACA,KAAM,EAAA,WAAW,CAAM,KAAA;AACrB,QAAIA,IAAAA,KAAAA,KAAS,YAAY,IAAM,EAAA;AAC3B,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAQ,CAAA,gBAAA;AAAA,YACR,0CAAA;AAAA,WACJ,CAAA;AAAA,SACJ;AACA,QAAA,OAAO,YAAY,MAAO,CAAA,IAAA,CAAK,IAAM,EAAA,WAAA,EAAa,MAAM,eAAe,CAAA,CAAA;AAAA,OAC3E;AAAA,KACJ,CAAA;AACA,IAAM,MAAA,YAAA,GAAe,IAAK,CAAA,EAAA,EAAI,UAAY,EAAA,GAAA,CAAI,CAAC,GAAA,KAAQ,kBAAmB,CAAA,GAAG,CAAC,CAA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AA,MAAM,IAAI,KAAA;AAAA,QACN,OAAQ,CAAA,iBAAA;AAAA,QACR,CAAA,SAAA,EAAY,WAAW,CAAA,yBAAA,EAA4B,GAAG,CAAA,wCAAA,CAAA;AAAA,OAC1D,CAAA;AAAA,KACJ;AAAA,GACJ;AAEA,EAAO,OAAA,MAAA,CAAA;AACX,CAAA;AAEA,MAAM,QAAA,GAAW,OAAO,SAAU,CAAA,cAAA,CAAA;AAElC,SAAS,WAAA,CAAY,QAAiB,GAAa,EAAA;AAC/C,EAAO,OAAA,QAAA,CAAS,IAAK,CAAA,MAAA,EAAQ,GAAG,CAAA,CAAA;AACpC,CAAA;AAGA,MAAM,UAAa,GAAA,4DAAA,CAAA;AAEnB,SAAS,mBAAmB,IAAuB,EAAA;AAC/C,EAAO,OAAA,UAAA,CAAW,KAAK,IAAI,CAAA,CAAA;AAC/B;;;;"}
1
+ {"version":3,"file":"PackageRepr.js","sources":["PackageRepr.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Error } from \"@open-pioneer/core\";\nimport { ApplicationProperties } from \"../CustomElement\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl, AppI18n } from \"../i18n\";\nimport { PackageMetadata, PropertyMetadata } from \"../metadata\";\nimport { parseReferenceSpec, ReferenceSpec } from \"./InterfaceSpec\";\nimport { ServiceRepr } from \"./ServiceRepr\";\n\nexport interface PackageReprOptions {\n name: string;\n intl: PackageIntl;\n services?: ServiceRepr[];\n uiReferences?: ReferenceSpec[];\n properties?: Record<string, unknown>;\n}\n\nexport class PackageRepr {\n static create(\n data: PackageMetadata,\n i18n: PackageIntl,\n customProperties?: Record<string, unknown>\n ): PackageRepr {\n const name = data.name;\n const properties = data.properties ?? {};\n const finalProperties = customizeProperties(name, properties, customProperties);\n const services = Object.entries(data.services ?? {}).map<ServiceRepr>(\n ([name, serviceData]) => {\n if (name !== serviceData.name) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n \"Invalid metadata: service name mismatch.\"\n );\n }\n return ServiceRepr.create(data.name, serviceData, i18n, finalProperties);\n }\n );\n const uiReferences = data.ui?.references?.map((ref) => parseReferenceSpec(ref)) ?? [];\n return new PackageRepr({\n name,\n services,\n uiReferences,\n properties: finalProperties,\n intl: i18n\n });\n }\n\n /** Package name */\n readonly name: string;\n\n /** Services defined by the package */\n readonly services: readonly ServiceRepr[];\n\n /** Interfaces required by UI components. */\n readonly uiReferences: readonly Readonly<ReferenceSpec>[];\n\n /** Resolved (perhaps customized) package properties. */\n readonly properties: Readonly<Record<string, unknown>>;\n\n /** Locale-dependant i18n messages. */\n readonly intl: PackageIntl;\n\n constructor(options: PackageReprOptions) {\n const name = options.name;\n if (!isValidPackageName(name)) {\n throw new Error(ErrorId.INTERNAL, `Invalid package name: '${name}'.`);\n }\n\n this.name = name;\n this.services = options.services ?? [];\n this.uiReferences = options.uiReferences ?? [];\n this.properties = options.properties ?? {};\n this.intl = options.intl;\n }\n}\n\nexport function createPackages(\n packages: Record<string, PackageMetadata>,\n i18n: AppI18n,\n customProperties?: ApplicationProperties\n) {\n return Object.entries(packages).map<PackageRepr>(([name, packageMetadata]) => {\n if (name !== packageMetadata.name) {\n throw new Error(ErrorId.INVALID_METADATA, \"Invalid metadata: package name mismatch.\");\n }\n\n const packageI18n = i18n.createPackageI18n(name);\n return PackageRepr.create(packageMetadata, packageI18n, customProperties?.[name]);\n });\n}\n\n/**\n * Merges the declared properties of the package with the application-defined\n * custom properties.\n */\nfunction customizeProperties(\n packageName: string,\n properties: Record<string, PropertyMetadata>,\n customProperties: Record<string, unknown> = {}\n) {\n const merged: Record<string, unknown> = {};\n const required: string[] = [];\n for (const [key, propertyMetadata] of Object.entries(properties)) {\n merged[key] = propertyMetadata.value;\n if (propertyMetadata.required) {\n required.push(key);\n }\n }\n\n for (const [key, value] of Object.entries(customProperties)) {\n if (!hasProperty(merged, key)) {\n throw new Error(\n ErrorId.INVALID_PROPERTY_NAME,\n `Unexpected property name '${key}' for package '${packageName}': the property does not exist.`\n );\n }\n merged[key] = value;\n }\n\n for (const key of required) {\n const value = merged[key];\n if (value == null) {\n throw new Error(\n ErrorId.REQUIRED_PROPERTY,\n `Package '${packageName}' requires the property '${key}' to be initialized to a non-null value.`\n );\n }\n }\n\n return merged;\n}\n\nconst HAS_PROP = Object.prototype.hasOwnProperty;\n\nfunction hasProperty(object: unknown, key: string) {\n return HAS_PROP.call(object, key);\n}\n\n// http://json.schemastore.org/package\nconst NAME_REGEX = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/;\n\nfunction isValidPackageName(name: string): boolean {\n return NAME_REGEX.test(name);\n}\n"],"names":["name"],"mappings":";;;;;AAkBO,MAAM,WAAY,CAAA;AAAA,EACrB,OAAO,MAAA,CACH,IACA,EAAA,IAAA,EACA,gBACW,EAAA;AACX,IAAA,MAAM,OAAO,IAAK,CAAA,IAAA;AAClB,IAAM,MAAA,UAAA,GAAa,IAAK,CAAA,UAAA,IAAc,EAAC;AACvC,IAAA,MAAM,eAAkB,GAAA,mBAAA,CAAoB,IAAM,EAAA,UAAA,EAAY,gBAAgB,CAAA;AAC9E,IAAA,MAAM,WAAW,MAAO,CAAA,OAAA,CAAQ,KAAK,QAAY,IAAA,EAAE,CAAE,CAAA,GAAA;AAAA,MACjD,CAAC,CAACA,KAAM,EAAA,WAAW,CAAM,KAAA;AACrB,QAAIA,IAAAA,KAAAA,KAAS,YAAY,IAAM,EAAA;AAC3B,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAQ,CAAA,gBAAA;AAAA,YACR;AAAA,WACJ;AAAA;AAEJ,QAAA,OAAO,YAAY,MAAO,CAAA,IAAA,CAAK,IAAM,EAAA,WAAA,EAAa,MAAM,eAAe,CAAA;AAAA;AAC3E,KACJ;AACA,IAAM,MAAA,YAAA,GAAe,IAAK,CAAA,EAAA,EAAI,UAAY,EAAA,GAAA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,EAAO,OAAA,MAAA;AACX;AAEA,MAAM,QAAA,GAAW,OAAO,SAAU,CAAA,cAAA;AAElC,SAAS,WAAA,CAAY,QAAiB,GAAa,EAAA;AAC/C,EAAO,OAAA,QAAA,CAAS,IAAK,CAAA,MAAA,EAAQ,GAAG,CAAA;AACpC;AAGA,MAAM,UAAa,GAAA,4DAAA;AAEnB,SAAS,mBAAmB,IAAuB,EAAA;AAC/C,EAAO,OAAA,UAAA,CAAW,KAAK,IAAI,CAAA;AAC/B;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceLayer.js","sources":["ServiceLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ServiceRepr } from \"./ServiceRepr\";\nimport { createLogger, Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\nimport {\n ComputedServiceDependencies,\n FrameworkDependency,\n UIDependency,\n verifyDependencies\n} from \"./verifyDependencies\";\nimport { PackageRepr } from \"./PackageRepr\";\nimport { ReadonlyServiceLookup, ServiceLookupResult, ServicesLookupResult } from \"./ServiceLookup\";\nimport {\n InterfaceSpec,\n isAllImplementationsSpec,\n isSingleImplementationSpec,\n ReferenceSpec,\n renderInterfaceSpec\n} from \"./InterfaceSpec\";\nimport { ReferenceMeta } from \"../Service\";\nimport { RUNTIME_PACKAGE_NAME } from \"../builtin-services\";\n\nconst LOG = createLogger(\"runtime:ServiceLayer\");\n\nexport type DynamicLookupResult = ServiceLookupResult | UndeclaredDependency;\n\n/**\n * Returned when a dependency is not declared in the package's metadata.\n */\nexport interface UndeclaredDependency {\n type: \"undeclared\";\n}\n\n/**\n * Returned when a package is not found in the application's metadata.\n */\nexport interface UnknownPackage {\n type: \"unknown-package\";\n}\n\nconst UNDECLARED_DEPENDENCY = { type: \"undeclared\" } satisfies UndeclaredDependency;\nconst UNKNOWN_PACKAGE = { type: \"unknown-package\" } satisfies UnknownPackage;\n\ninterface DependencyDeclarations {\n all: boolean;\n unqualified: boolean;\n qualifiers: Set<string>;\n}\n\nexport class ServiceLayer {\n // All services in the application.\n private allServices: ServiceRepr[];\n\n // Set of required services. These services and their dependencies will be started.\n private requiredServices: Set<ServiceRepr>;\n\n private serviceLookup: ReadonlyServiceLookup;\n\n // Service id --> Service dependencies\n private serviceDependencies: Map<string, ComputedServiceDependencies>;\n\n // Package name --> Interface name --> Declarations\n private declaredDependencies;\n private state: \"not-started\" | \"started\" | \"destroyed\" = \"not-started\";\n\n /**\n * Constructs a new service layer instance.\n * Requires the application's set of packages (from which services are taken)\n * and an optional set of forced references (interfaces whose implementing services will be started unconditionally).\n *\n * In its current form, the service layer will start only forced references and references needed by the UI (and their dependencies).\n */\n constructor(packages: readonly PackageRepr[], forcedReferences: ReferenceSpec[] = []) {\n const allServices = packages.map((pkg) => pkg.services).flat();\n const uiDependencies = packages\n .map((pkg) =>\n pkg.uiReferences.map<UIDependency>((dep) => {\n return {\n type: \"ui\",\n packageName: pkg.name,\n ...dep\n };\n })\n )\n .flat();\n const requiredReferences = [\n ...forcedReferences.map<FrameworkDependency>((r) => ({\n type: \"framework\",\n ...r\n })),\n ...uiDependencies\n ];\n const { serviceLookup, serviceDependencies } = verifyDependencies({\n services: allServices,\n requiredReferences: requiredReferences\n });\n\n this.allServices = allServices;\n this.requiredServices = getRequiredServices(requiredReferences, serviceLookup);\n this.serviceLookup = serviceLookup;\n this.serviceDependencies = serviceDependencies;\n this.declaredDependencies = buildDependencyIndex(packages);\n }\n\n destroy() {\n for (const service of this.requiredServices) {\n this.destroyService(service);\n }\n this.state = \"destroyed\";\n }\n\n start() {\n if (this.state !== \"not-started\") {\n throw new Error(ErrorId.INTERNAL, \"Service layer was already started.\");\n }\n\n for (const service of this.requiredServices) {\n this.createService(service);\n }\n this.state = \"started\";\n\n // Give warnings for unneeded services during development.\n if (import.meta.env.DEV) {\n const unneededServices = this.allServices\n .filter(\n (service) =>\n service.packageName !== RUNTIME_PACKAGE_NAME &&\n service.state === \"not-constructed\"\n )\n .map((service) => `'${service.id}'`);\n if (unneededServices.length) {\n const services = unneededServices.join(\", \");\n LOG.warn(\n `The following services are contained in the application but were not started: ${services}.`\n );\n }\n }\n }\n\n /**\n * Returns a service implementing the given interface.\n * Checks that the given package actually declared a dependency on that interface\n * to enforce coding guidelines.\n *\n * @param packageName the name of the package requesting the import\n * @param spec the interface specifier\n * @param options advanced options to customize lookup\n * @throws if the service layer is not in 'started' state or if no service implements the interface.\n */\n getService(\n packageName: string,\n spec: InterfaceSpec,\n options?: { ignoreDeclarationCheck?: boolean }\n ): ServiceLookupResult | UndeclaredDependency | UnknownPackage {\n if (this.state !== \"started\") {\n throw new Error(ErrorId.INTERNAL, \"Service layer is not started.\");\n }\n\n if (!options?.ignoreDeclarationCheck) {\n const checkError = this.checkDependency(packageName, spec);\n if (checkError) {\n return checkError;\n }\n }\n\n return this.serviceLookup.lookupOne(spec);\n }\n\n /**\n * Returns all services implementing the given interface.\n * Requires that the dependency on all implementations has been declared in the package.\n *\n * @param packageName the name of the package requesting the import\n * @param interfaceName the interface name\n *\n * @throws if the service layer is not in 'started'.\n */\n getServices(\n packageName: string,\n interfaceName: string\n ): ServicesLookupResult | UndeclaredDependency | UnknownPackage {\n if (this.state !== \"started\") {\n throw new Error(ErrorId.INTERNAL, \"Service layer is not started.\");\n }\n\n const checkError = this.checkDependency(packageName, { interfaceName, all: true });\n if (checkError) {\n return checkError;\n }\n return this.serviceLookup.lookupAll(interfaceName);\n }\n\n /**\n * Initializes the given service and its dependencies.\n * Dependencies are initialized before the service that requires them.\n */\n private createService(service: ServiceRepr) {\n if (service.state === \"constructed\") {\n const instance = service.getInstanceOrThrow();\n service.addRef();\n return instance;\n }\n if (service.state === \"constructing\") {\n throw new Error(ErrorId.INTERNAL, \"Cycle during service construction.\");\n }\n if (service.state !== \"not-constructed\") {\n throw new Error(ErrorId.INTERNAL, \"Invalid service state.\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const references: Record<string, any> = {};\n const referencesMeta: Record<string, ReferenceMeta | ReferenceMeta[]> = {};\n\n // Sets state to 'constructing' to detect cycles\n service.beforeCreate();\n\n // Initialize dependencies recursively before creating the current service.\n for (const [referenceName, serviceDeps] of Object.entries(this.getServiceDeps(service))) {\n const [referenceValue, referenceMeta] = this.getReference(serviceDeps);\n references[referenceName] = referenceValue;\n referencesMeta[referenceName] = referenceMeta;\n }\n\n // Sets state to 'constructed' to finish the state transition, useCount is 1.\n LOG.debug(`Creating service '${service.id}'.`);\n return service.create({ references, referencesMeta });\n }\n\n /**\n * Destroys the given service and its dependencies.\n * The dependencies are destroyed after the service.\n */\n private destroyService(service: ServiceRepr) {\n if (service.state === \"destroyed\") {\n return;\n }\n\n // Destroy the service before its dependencies (reverse order\n // compared to construction).\n if (service.removeRef() <= 0) {\n LOG.debug(`Destroying service '${service.id}'`);\n service.destroy();\n }\n\n for (const serviceDeps of Object.values(this.getServiceDeps(service))) {\n if (Array.isArray(serviceDeps)) {\n for (const dep of serviceDeps) {\n this.destroyService(dep);\n }\n } else {\n this.destroyService(serviceDeps);\n }\n }\n }\n\n /** Undefined -> everything is okay */\n private checkDependency(\n packageName: string,\n spec: ReferenceSpec\n ): UnknownPackage | UndeclaredDependency | undefined {\n const packageEntry = this.declaredDependencies.get(packageName);\n if (!packageEntry) {\n return UNKNOWN_PACKAGE;\n }\n\n const interfaceEntry = packageEntry.get(spec.interfaceName);\n if (!interfaceEntry) {\n return UNDECLARED_DEPENDENCY;\n }\n\n if (isSingleImplementationSpec(spec)) {\n if (spec.qualifier == null) {\n return interfaceEntry.unqualified ? undefined : UNDECLARED_DEPENDENCY;\n }\n return interfaceEntry.qualifiers.has(spec.qualifier)\n ? undefined\n : UNDECLARED_DEPENDENCY;\n } else {\n return interfaceEntry.all ? undefined : UNDECLARED_DEPENDENCY;\n }\n }\n\n private getReference(ref: ServiceRepr): [unknown, ReferenceMeta];\n private getReference(ref: ServiceRepr[]): [unknown[], ReferenceMeta[]];\n private getReference(\n ref: ServiceRepr | ServiceRepr[]\n ): [unknown, ReferenceMeta] | [unknown[], ReferenceMeta[]];\n private getReference(\n ref: ServiceRepr | ServiceRepr[]\n ): [unknown, ReferenceMeta] | [unknown[], ReferenceMeta[]] {\n if (Array.isArray(ref)) {\n const referenceValues: unknown[] = [];\n const referenceMeta: ReferenceMeta[] = [];\n for (const d of ref) {\n const [value, meta] = this.getReference(d);\n referenceValues.push(value);\n referenceMeta.push(meta);\n }\n return [referenceValues, referenceMeta];\n }\n\n const referenceValue = this.createService(ref);\n const referenceMeta: ReferenceMeta = {\n serviceId: ref.id\n };\n return [referenceValue, referenceMeta];\n }\n\n private getServiceDeps(service: ServiceRepr) {\n const dependencies = this.serviceDependencies.get(service.id);\n if (!dependencies) {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find precomputed service dependencies for '${service.id}'.`\n );\n }\n return dependencies;\n }\n}\n\nfunction getRequiredServices(\n requiredReferences: readonly ReferenceSpec[],\n serviceLookup: ReadonlyServiceLookup\n): Set<ServiceRepr> {\n const requiredServices = new Set<ServiceRepr>();\n for (const referenceSpec of requiredReferences) {\n const result = serviceLookup.lookup(referenceSpec);\n if (result.type !== \"found\") {\n // Should be caught by verifier\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find required reference to ${renderInterfaceSpec(referenceSpec)}.`\n );\n }\n if (Array.isArray(result.value)) {\n for (const service of result.value) {\n requiredServices.add(service);\n }\n } else {\n requiredServices.add(result.value);\n }\n }\n return requiredServices;\n}\n\nfunction buildDependencyIndex(packages: readonly PackageRepr[]) {\n // Register declared UI dependencies.\n // This is needed as a lookup structure to that dynamic service lookups\n // can be validated at runtime.\n const index = new Map<string, Map<string, DependencyDeclarations>>();\n for (const pkg of packages) {\n const packageName = pkg.name;\n const packageEntry = new Map<string, DependencyDeclarations>();\n for (const uiReference of pkg.uiReferences) {\n let interfaceEntry = packageEntry.get(uiReference.interfaceName);\n if (!interfaceEntry) {\n interfaceEntry = {\n all: false,\n unqualified: false,\n qualifiers: new Set<string>()\n };\n packageEntry.set(uiReference.interfaceName, interfaceEntry);\n }\n\n if (isAllImplementationsSpec(uiReference)) {\n interfaceEntry.all = true;\n } else if (isSingleImplementationSpec(uiReference)) {\n if (uiReference.qualifier == null) {\n interfaceEntry.unqualified = true;\n } else {\n interfaceEntry.qualifiers.add(uiReference.qualifier);\n }\n } else {\n throw new Error(ErrorId.INTERNAL, `Unexpected implementation spec.`);\n }\n }\n index.set(packageName, packageEntry);\n }\n return index;\n}\n"],"names":["referenceMeta"],"mappings":";;;;;;AAuBA,MAAM,GAAA,GAAM,aAAa,sBAAsB,CAAA,CAAA;AAkB/C,MAAM,qBAAA,GAAwB,EAAE,IAAA,EAAM,YAAa,EAAA,CAAA;AACnD,MAAM,eAAA,GAAkB,EAAE,IAAA,EAAM,iBAAkB,EAAA,CAAA;AAQ3C,MAAM,YAAa,CAAA;AAAA;AAAA,EAEd,WAAA,CAAA;AAAA;AAAA,EAGA,gBAAA,CAAA;AAAA,EAEA,aAAA,CAAA;AAAA;AAAA,EAGA,mBAAA,CAAA;AAAA;AAAA,EAGA,oBAAA,CAAA;AAAA,EACA,KAAiD,GAAA,aAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASzD,WAAY,CAAA,QAAA,EAAkC,gBAAoC,GAAA,EAAI,EAAA;AAClF,IAAM,MAAA,WAAA,GAAc,SAAS,GAAI,CAAA,CAAC,QAAQ,GAAI,CAAA,QAAQ,EAAE,IAAK,EAAA,CAAA;AAC7D,IAAA,MAAM,iBAAiB,QAClB,CAAA,GAAA;AAAA,MAAI,CAAC,GACF,KAAA,GAAA,CAAI,YAAa,CAAA,GAAA,CAAkB,CAAC,GAAQ,KAAA;AACxC,QAAO,OAAA;AAAA,UACH,IAAM,EAAA,IAAA;AAAA,UACN,aAAa,GAAI,CAAA,IAAA;AAAA,UACjB,GAAG,GAAA;AAAA,SACP,CAAA;AAAA,OACH,CAAA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;;;;"}
1
+ {"version":3,"file":"ServiceLayer.js","sources":["ServiceLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ServiceRepr } from \"./ServiceRepr\";\nimport { createLogger, Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\nimport {\n ComputedServiceDependencies,\n FrameworkDependency,\n UIDependency,\n verifyDependencies\n} from \"./verifyDependencies\";\nimport { PackageRepr } from \"./PackageRepr\";\nimport { ReadonlyServiceLookup, ServiceLookupResult, ServicesLookupResult } from \"./ServiceLookup\";\nimport {\n InterfaceSpec,\n isAllImplementationsSpec,\n isSingleImplementationSpec,\n ReferenceSpec,\n renderInterfaceSpec\n} from \"./InterfaceSpec\";\nimport { ReferenceMeta } from \"../Service\";\nimport { RUNTIME_PACKAGE_NAME } from \"../builtin-services\";\n\nconst LOG = createLogger(\"runtime:ServiceLayer\");\n\nexport type DynamicLookupResult = ServiceLookupResult | UndeclaredDependency;\n\n/**\n * Returned when a dependency is not declared in the package's metadata.\n */\nexport interface UndeclaredDependency {\n type: \"undeclared\";\n}\n\n/**\n * Returned when a package is not found in the application's metadata.\n */\nexport interface UnknownPackage {\n type: \"unknown-package\";\n}\n\nconst UNDECLARED_DEPENDENCY = { type: \"undeclared\" } satisfies UndeclaredDependency;\nconst UNKNOWN_PACKAGE = { type: \"unknown-package\" } satisfies UnknownPackage;\n\ninterface DependencyDeclarations {\n all: boolean;\n unqualified: boolean;\n qualifiers: Set<string>;\n}\n\nexport class ServiceLayer {\n // All services in the application.\n private allServices: ServiceRepr[];\n\n // Set of required services. These services and their dependencies will be started.\n private requiredServices: Set<ServiceRepr>;\n\n private serviceLookup: ReadonlyServiceLookup;\n\n // Service id --> Service dependencies\n private serviceDependencies: Map<string, ComputedServiceDependencies>;\n\n // Package name --> Interface name --> Declarations\n private declaredDependencies;\n private state: \"not-started\" | \"started\" | \"destroyed\" = \"not-started\";\n\n /**\n * Constructs a new service layer instance.\n * Requires the application's set of packages (from which services are taken)\n * and an optional set of forced references (interfaces whose implementing services will be started unconditionally).\n *\n * In its current form, the service layer will start only forced references and references needed by the UI (and their dependencies).\n */\n constructor(packages: readonly PackageRepr[], forcedReferences: ReferenceSpec[] = []) {\n const allServices = packages.map((pkg) => pkg.services).flat();\n const uiDependencies = packages\n .map((pkg) =>\n pkg.uiReferences.map<UIDependency>((dep) => {\n return {\n type: \"ui\",\n packageName: pkg.name,\n ...dep\n };\n })\n )\n .flat();\n const requiredReferences = [\n ...forcedReferences.map<FrameworkDependency>((r) => ({\n type: \"framework\",\n ...r\n })),\n ...uiDependencies\n ];\n const { serviceLookup, serviceDependencies } = verifyDependencies({\n services: allServices,\n requiredReferences: requiredReferences\n });\n\n this.allServices = allServices;\n this.requiredServices = getRequiredServices(requiredReferences, serviceLookup);\n this.serviceLookup = serviceLookup;\n this.serviceDependencies = serviceDependencies;\n this.declaredDependencies = buildDependencyIndex(packages);\n }\n\n destroy() {\n for (const service of this.requiredServices) {\n this.destroyService(service);\n }\n this.state = \"destroyed\";\n }\n\n start() {\n if (this.state !== \"not-started\") {\n throw new Error(ErrorId.INTERNAL, \"Service layer was already started.\");\n }\n\n for (const service of this.requiredServices) {\n this.createService(service);\n }\n this.state = \"started\";\n\n // Give warnings for unneeded services during development.\n if (import.meta.env.DEV) {\n const unneededServices = this.allServices\n .filter(\n (service) =>\n service.packageName !== RUNTIME_PACKAGE_NAME &&\n service.state === \"not-constructed\"\n )\n .map((service) => `'${service.id}'`);\n if (unneededServices.length) {\n const services = unneededServices.join(\", \");\n LOG.warn(\n `The following services are contained in the application but were not started: ${services}.`\n );\n }\n }\n }\n\n /**\n * Returns a service implementing the given interface.\n * Checks that the given package actually declared a dependency on that interface\n * to enforce coding guidelines.\n *\n * @param packageName the name of the package requesting the import\n * @param spec the interface specifier\n * @param options advanced options to customize lookup\n * @throws if the service layer is not in 'started' state or if no service implements the interface.\n */\n getService(\n packageName: string,\n spec: InterfaceSpec,\n options?: { ignoreDeclarationCheck?: boolean }\n ): ServiceLookupResult | UndeclaredDependency | UnknownPackage {\n if (this.state !== \"started\") {\n throw new Error(ErrorId.INTERNAL, \"Service layer is not started.\");\n }\n\n if (!options?.ignoreDeclarationCheck) {\n const checkError = this.checkDependency(packageName, spec);\n if (checkError) {\n return checkError;\n }\n }\n\n return this.serviceLookup.lookupOne(spec);\n }\n\n /**\n * Returns all services implementing the given interface.\n * Requires that the dependency on all implementations has been declared in the package.\n *\n * @param packageName the name of the package requesting the import\n * @param interfaceName the interface name\n *\n * @throws if the service layer is not in 'started'.\n */\n getServices(\n packageName: string,\n interfaceName: string\n ): ServicesLookupResult | UndeclaredDependency | UnknownPackage {\n if (this.state !== \"started\") {\n throw new Error(ErrorId.INTERNAL, \"Service layer is not started.\");\n }\n\n const checkError = this.checkDependency(packageName, { interfaceName, all: true });\n if (checkError) {\n return checkError;\n }\n return this.serviceLookup.lookupAll(interfaceName);\n }\n\n /**\n * Initializes the given service and its dependencies.\n * Dependencies are initialized before the service that requires them.\n */\n private createService(service: ServiceRepr) {\n if (service.state === \"constructed\") {\n const instance = service.getInstanceOrThrow();\n service.addRef();\n return instance;\n }\n if (service.state === \"constructing\") {\n throw new Error(ErrorId.INTERNAL, \"Cycle during service construction.\");\n }\n if (service.state !== \"not-constructed\") {\n throw new Error(ErrorId.INTERNAL, \"Invalid service state.\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const references: Record<string, any> = {};\n const referencesMeta: Record<string, ReferenceMeta | ReferenceMeta[]> = {};\n\n // Sets state to 'constructing' to detect cycles\n service.beforeCreate();\n\n // Initialize dependencies recursively before creating the current service.\n for (const [referenceName, serviceDeps] of Object.entries(this.getServiceDeps(service))) {\n const [referenceValue, referenceMeta] = this.getReference(serviceDeps);\n references[referenceName] = referenceValue;\n referencesMeta[referenceName] = referenceMeta;\n }\n\n // Sets state to 'constructed' to finish the state transition, useCount is 1.\n LOG.debug(`Creating service '${service.id}'.`);\n return service.create({ references, referencesMeta });\n }\n\n /**\n * Destroys the given service and its dependencies.\n * The dependencies are destroyed after the service.\n */\n private destroyService(service: ServiceRepr) {\n if (service.state === \"destroyed\") {\n return;\n }\n\n // Destroy the service before its dependencies (reverse order\n // compared to construction).\n if (service.removeRef() <= 0) {\n LOG.debug(`Destroying service '${service.id}'`);\n service.destroy();\n }\n\n for (const serviceDeps of Object.values(this.getServiceDeps(service))) {\n if (Array.isArray(serviceDeps)) {\n for (const dep of serviceDeps) {\n this.destroyService(dep);\n }\n } else {\n this.destroyService(serviceDeps);\n }\n }\n }\n\n /** Undefined -> everything is okay */\n private checkDependency(\n packageName: string,\n spec: ReferenceSpec\n ): UnknownPackage | UndeclaredDependency | undefined {\n const packageEntry = this.declaredDependencies.get(packageName);\n if (!packageEntry) {\n return UNKNOWN_PACKAGE;\n }\n\n const interfaceEntry = packageEntry.get(spec.interfaceName);\n if (!interfaceEntry) {\n return UNDECLARED_DEPENDENCY;\n }\n\n if (isSingleImplementationSpec(spec)) {\n if (spec.qualifier == null) {\n return interfaceEntry.unqualified ? undefined : UNDECLARED_DEPENDENCY;\n }\n return interfaceEntry.qualifiers.has(spec.qualifier)\n ? undefined\n : UNDECLARED_DEPENDENCY;\n } else {\n return interfaceEntry.all ? undefined : UNDECLARED_DEPENDENCY;\n }\n }\n\n private getReference(ref: ServiceRepr): [unknown, ReferenceMeta];\n private getReference(ref: ServiceRepr[]): [unknown[], ReferenceMeta[]];\n private getReference(\n ref: ServiceRepr | ServiceRepr[]\n ): [unknown, ReferenceMeta] | [unknown[], ReferenceMeta[]];\n private getReference(\n ref: ServiceRepr | ServiceRepr[]\n ): [unknown, ReferenceMeta] | [unknown[], ReferenceMeta[]] {\n if (Array.isArray(ref)) {\n const referenceValues: unknown[] = [];\n const referenceMeta: ReferenceMeta[] = [];\n for (const d of ref) {\n const [value, meta] = this.getReference(d);\n referenceValues.push(value);\n referenceMeta.push(meta);\n }\n return [referenceValues, referenceMeta];\n }\n\n const referenceValue = this.createService(ref);\n const referenceMeta: ReferenceMeta = {\n serviceId: ref.id\n };\n return [referenceValue, referenceMeta];\n }\n\n private getServiceDeps(service: ServiceRepr) {\n const dependencies = this.serviceDependencies.get(service.id);\n if (!dependencies) {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find precomputed service dependencies for '${service.id}'.`\n );\n }\n return dependencies;\n }\n}\n\nfunction getRequiredServices(\n requiredReferences: readonly ReferenceSpec[],\n serviceLookup: ReadonlyServiceLookup\n): Set<ServiceRepr> {\n const requiredServices = new Set<ServiceRepr>();\n for (const referenceSpec of requiredReferences) {\n const result = serviceLookup.lookup(referenceSpec);\n if (result.type !== \"found\") {\n // Should be caught by verifier\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find required reference to ${renderInterfaceSpec(referenceSpec)}.`\n );\n }\n if (Array.isArray(result.value)) {\n for (const service of result.value) {\n requiredServices.add(service);\n }\n } else {\n requiredServices.add(result.value);\n }\n }\n return requiredServices;\n}\n\nfunction buildDependencyIndex(packages: readonly PackageRepr[]) {\n // Register declared UI dependencies.\n // This is needed as a lookup structure to that dynamic service lookups\n // can be validated at runtime.\n const index = new Map<string, Map<string, DependencyDeclarations>>();\n for (const pkg of packages) {\n const packageName = pkg.name;\n const packageEntry = new Map<string, DependencyDeclarations>();\n for (const uiReference of pkg.uiReferences) {\n let interfaceEntry = packageEntry.get(uiReference.interfaceName);\n if (!interfaceEntry) {\n interfaceEntry = {\n all: false,\n unqualified: false,\n qualifiers: new Set<string>()\n };\n packageEntry.set(uiReference.interfaceName, interfaceEntry);\n }\n\n if (isAllImplementationsSpec(uiReference)) {\n interfaceEntry.all = true;\n } else if (isSingleImplementationSpec(uiReference)) {\n if (uiReference.qualifier == null) {\n interfaceEntry.unqualified = true;\n } else {\n interfaceEntry.qualifiers.add(uiReference.qualifier);\n }\n } else {\n throw new Error(ErrorId.INTERNAL, `Unexpected implementation spec.`);\n }\n }\n index.set(packageName, packageEntry);\n }\n return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