@open-pioneer/runtime 4.0.0 → 4.1.0-dev.20250818125237

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/runtime",
4
- "version": "4.0.0",
4
+ "version": "4.1.0-dev.20250818125237",
5
5
  "description": "Implements the runtime environment for Open Pioneer Trails apps.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -16,14 +16,14 @@
16
16
  "dependencies": {
17
17
  "@conterra/reactivity-core": "^0.7.0",
18
18
  "@formatjs/intl": "^3.1.6",
19
- "@chakra-ui/react": "^3.19.2",
19
+ "@chakra-ui/react": "^3.24.2",
20
20
  "@emotion/cache": "^11.14.0",
21
21
  "@emotion/react": "^11.14.0",
22
- "react": "^19.1.0",
23
- "react-dom": "^19.1.0",
24
- "@open-pioneer/core": "^4.0.0",
25
- "@open-pioneer/base-theme": "^4.0.0",
26
- "@open-pioneer/reactivity": "^4.0.0"
22
+ "react": "^19.1.1",
23
+ "react-dom": "^19.1.1",
24
+ "@open-pioneer/core": "4.1.0-dev.20250818125237",
25
+ "@open-pioneer/base-theme": "4.1.0-dev.20250818125237",
26
+ "@open-pioneer/reactivity": "4.1.0-dev.20250818125237"
27
27
  },
28
28
  "exports": {
29
29
  "./package.json": "./package.json",
@@ -1 +1 @@
1
- {"version":3,"file":"ChakraProvider.js","sources":["ChakraProvider.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n ChakraProvider,\n createSystem,\n defaultConfig,\n defineConfig,\n EnvironmentProvider,\n LocaleProvider,\n mergeConfigs,\n SystemConfig,\n SystemStyleObject\n} from \"@chakra-ui/react\";\nimport { ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport createCache, { EmotionCache } from \"@emotion/cache\";\nimport { CacheProvider, Global } from \"@emotion/react\";\nimport { config as defaultTrailsConfig } from \"@open-pioneer/base-theme\";\nimport { Error } from \"@open-pioneer/core\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport { FC, PropsWithChildren, useEffect, useMemo, useState } from \"react\";\nimport { APP_ROOT_CLASS, getBuiltinStyles, getStylesRoot, RootNode } from \"../dom\";\nimport { ErrorId } from \"../errors\";\n\n/** @internal */\nexport type CustomChakraProviderProps = PropsWithChildren<{\n /**\n * Document root node.\n */\n rootNode: RootNode;\n\n /**\n * Web component root.\n *\n * NOTE: undefined for test support only.\n */\n hostNode?: HTMLElement;\n\n /**\n * Application container (react's render target).\n */\n appRoot: HTMLElement;\n\n /**\n * Chakra system config (can be used to provide custom theme).\n */\n config?: SystemConfig;\n\n /**\n * Application locale for chakra's `LocaleProvider`.\n */\n locale?: string;\n\n /**\n * Custom CSS used by the application.\n */\n styles?: ReadonlyReactive<string>;\n}>;\n\nconst APP_ROOT_CSS = `.${APP_ROOT_CLASS}`;\n\n/**\n * Wraps the entire react application and configures chakra-ui (styling etc.).\n *\n * Exported so it can be used from the test-utils package.\n *\n * @internal\n */\nexport const CustomChakraProvider: FC<CustomChakraProviderProps> = ({\n rootNode,\n appRoot,\n hostNode,\n children,\n config = defaultTrailsConfig,\n locale = \"en-US\",\n styles\n}) => {\n /*\n Setup chakra integration:\n\n 1. Mount styles into the shadow root via emotion\n 2. Use chakra's EnvironmentProvider to tell it about the shadow root context\n 3. Setup global styles correctly (selectors etc.) via chakra's system object\n 4. Render the rest of the application\n */\n\n const system = useMemo(() => {\n const mergedConfig = mergeConfigs(defaultConfig, config);\n return createSystem(\n mergedConfig,\n\n // https://www.chakra-ui.com/docs/get-started/environments/shadow-dom\n defineConfig({\n preflight: {\n scope: APP_ROOT_CSS\n },\n cssVarsRoot: APP_ROOT_CSS,\n conditions: redirectLightCondition(mergedConfig.conditions),\n globalCss: redirectHtmlProps(mergedConfig.globalCss)\n })\n );\n }, [config]);\n\n useEffect(() => {\n const classes = appRoot.classList;\n const colorMode = \"light\"; // \"light\" | \"dark\"\n classes.add(colorMode);\n return () => {\n classes.remove(colorMode);\n };\n }, [appRoot]);\n\n const cache = useEmotionCache(rootNode);\n return (\n cache && (\n <CacheProvider value={cache}>\n <EnvironmentProvider\n value={rootNode}\n // Patched property\n portalNode={appRoot}\n >\n <LocaleProvider locale={locale}>\n <ChakraProvider value={system}>\n <GlobalStyles rootNode={rootNode} hostNode={hostNode} styles={styles} />\n {children}\n </ChakraProvider>\n </LocaleProvider>\n </EnvironmentProvider>\n </CacheProvider>\n )\n );\n};\n\nfunction GlobalStyles(props: {\n rootNode: RootNode;\n hostNode: HTMLElement | undefined;\n styles: ReadonlyReactive<string> | undefined;\n}) {\n const { rootNode, hostNode, styles } = props;\n const builtinStyles = useMemo(() => {\n const css = getBuiltinStyles(rootNode, hostNode);\n return <Global styles={css} />;\n }, [rootNode, hostNode]);\n const appStyles = useReactiveSnapshot(() => {\n const css = styles?.value;\n return css && <Global styles={css} />;\n }, [styles]);\n return (\n <>\n {builtinStyles}\n {appStyles}\n </>\n );\n}\n\nfunction redirectHtmlProps(\n css: Record<string, SystemStyleObject> | undefined\n): Record<string, SystemStyleObject> {\n const { html, ...rest } = css ?? {};\n if (!html) {\n throw new Error(ErrorId.INTERNAL, \"Expected global rules on html element.\");\n }\n // Take default html styles and apply them to the host element instead\n return {\n ...rest,\n [APP_ROOT_CSS]: html\n };\n}\n\nfunction redirectLightCondition(\n conditions: Record<string, unknown> | undefined\n): Record<string, unknown> {\n // Make sure light mode tokens are applied\n return {\n ...conditions,\n // Before: \":root &, .light &\"\n light: `${APP_ROOT_CSS} &, .light &`\n };\n}\n\nfunction useEmotionCache(rootNode: RootNode): EmotionCache | undefined {\n const stylesRoot = useMemo(() => getStylesRoot(rootNode), [rootNode]);\n\n const [cache, setCache] = useState<EmotionCache | undefined>();\n useEffect(() => {\n const cache = createCache({\n key: \"css\",\n container: stylesRoot\n });\n setCache(cache);\n return () => {\n setCache(undefined);\n for (const tag of cache.sheet.tags) {\n tag.remove();\n }\n };\n }, [stylesRoot]);\n return cache;\n}\n"],"names":["config","defaultTrailsConfig","cache"],"mappings":";;;;;;;;;;;AA0DA,MAAM,YAAA,GAAe,IAAI,cAAc,CAAA,CAAA;AAShC,MAAM,uBAAsD,CAAC;AAAA,EAChE,QAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,UACAA,QAAS,GAAAC,MAAA;AAAA,EACT,MAAS,GAAA,OAAA;AAAA,EACT;AACJ,CAAM,KAAA;AAUF,EAAM,MAAA,MAAA,GAAS,QAAQ,MAAM;AACzB,IAAM,MAAA,YAAA,GAAe,YAAa,CAAA,aAAA,EAAeD,QAAM,CAAA;AACvD,IAAO,OAAA,YAAA;AAAA,MACH,YAAA;AAAA;AAAA,MAGA,YAAa,CAAA;AAAA,QACT,SAAW,EAAA;AAAA,UACP,KAAO,EAAA;AAAA,SACX;AAAA,QACA,WAAa,EAAA,YAAA;AAAA,QACb,UAAA,EAAY,sBAAuB,CAAA,YAAA,CAAa,UAAU,CAAA;AAAA,QAC1D,SAAA,EAAW,iBAAkB,CAAA,YAAA,CAAa,SAAS;AAAA,OACtD;AAAA,KACL;AAAA,GACJ,EAAG,CAACA,QAAM,CAAC,CAAA;AAEX,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,MAAM,UAAU,OAAQ,CAAA,SAAA;AACxB,IAAA,MAAM,SAAY,GAAA,OAAA;AAClB,IAAA,OAAA,CAAQ,IAAI,SAAS,CAAA;AACrB,IAAA,OAAO,MAAM;AACT,MAAA,OAAA,CAAQ,OAAO,SAAS,CAAA;AAAA,KAC5B;AAAA,GACJ,EAAG,CAAC,OAAO,CAAC,CAAA;AAEZ,EAAM,MAAA,KAAA,GAAQ,gBAAgB,QAAQ,CAAA;AACtC,EAAA,OACI,KACI,oBAAA,GAAA,CAAC,aAAc,EAAA,EAAA,KAAA,EAAO,KAClB,EAAA,Q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,IAAA,MAAM,IAAI,KAAA,CAAM,OAAQ,CAAA,QAAA,EAAU,wCAAwC,CAAA;AAAA;AAG9E,EAAO,OAAA;AAAA,IACH,GAAG,IAAA;AAAA,IACH,CAAC,YAAY,GAAG;AAAA,GACpB;AACJ;AAEA,SAAS,uBACL,UACuB,EAAA;AAEvB,EAAO,OAAA;AAAA,IACH,GAAG,UAAA;AAAA;AAAA,IAEH,KAAA,EAAO,GAAG,YAAY,CAAA,YAAA;AAAA,GAC1B;AACJ;AAEA,SAAS,gBAAgB,QAA8C,EAAA;AACnE,EAAM,MAAA,UAAA,GAAa,QAAQ,MAAM,aAAA,CAAc,QAAQ,CAAG,EAAA,CAAC,QAAQ,CAAC,CAAA;AAEpE,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,QAAmC,EAAA;AAC7D,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,MAAME,SAAQ,WAAY,CAAA;AAAA,MACtB,GAAK,EAAA,KAAA;AAAA,MACL,SAAW,EAAA;AAAA,KACd,CAAA;AACD,IAAA,QAAA,CAASA,MAAK,CAAA;AACd,IAAA,OAAO,MAAM;AACT,MAAA,QAAA,CAAS,MAAS,CAAA;AAClB,MAAW,KAAA,MAAA,GAAA,IAAOA,MAAM,CAAA,KAAA,CAAM,IAAM,EAAA;AAChC,QAAA,GAAA,CAAI,MAAO,EAAA;AAAA;AACf,KACJ;AAAA,GACJ,EAAG,CAAC,UAAU,CAAC,CAAA;AACf,EAAO,OAAA,KAAA;AACX;;;;"}
1
+ {"version":3,"file":"ChakraProvider.js","sources":["ChakraProvider.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n ChakraProvider,\n createSystem,\n defaultConfig,\n defineConfig,\n EnvironmentProvider,\n LocaleProvider,\n mergeConfigs,\n SystemConfig,\n SystemStyleObject\n} from \"@chakra-ui/react\";\nimport { ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport createCache, { EmotionCache } from \"@emotion/cache\";\nimport { CacheProvider, Global } from \"@emotion/react\";\nimport { config as defaultTrailsConfig } from \"@open-pioneer/base-theme\";\nimport { Error } from \"@open-pioneer/core\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport { FC, PropsWithChildren, useEffect, useMemo, useState } from \"react\";\nimport { APP_ROOT_CLASS, getBuiltinStyles, getStylesRoot, RootNode } from \"../dom\";\nimport { ErrorId } from \"../errors\";\n\n/** @internal */\nexport type CustomChakraProviderProps = PropsWithChildren<{\n /**\n * Document root node.\n */\n rootNode: RootNode;\n\n /**\n * Web component root.\n *\n * NOTE: undefined for test support only.\n */\n hostNode?: HTMLElement;\n\n /**\n * Application container (react's render target).\n */\n appRoot: HTMLElement;\n\n /**\n * Chakra system config (can be used to provide custom theme).\n */\n config?: SystemConfig;\n\n /**\n * Application locale for chakra's `LocaleProvider`.\n */\n locale?: string;\n\n /**\n * Custom CSS used by the application.\n */\n styles?: ReadonlyReactive<string>;\n}>;\n\nconst APP_ROOT_CSS = `.${APP_ROOT_CLASS}`;\n\n/**\n * Wraps the entire react application and configures chakra-ui (styling etc.).\n *\n * Exported so it can be used from the test-utils package.\n *\n * @internal\n */\nexport const CustomChakraProvider: FC<CustomChakraProviderProps> = ({\n rootNode,\n appRoot,\n hostNode,\n children,\n config = defaultTrailsConfig,\n locale = \"en-US\",\n styles\n}) => {\n /*\n Setup chakra integration:\n\n 1. Mount styles into the shadow root via emotion\n 2. Use chakra's EnvironmentProvider to tell it about the shadow root context\n 3. Setup global styles correctly (selectors etc.) via chakra's system object\n 4. Render the rest of the application\n */\n\n const system = useMemo(() => {\n const mergedConfig = mergeConfigs(defaultConfig, config);\n return createSystem(\n mergedConfig,\n\n // https://www.chakra-ui.com/docs/get-started/environments/shadow-dom\n defineConfig({\n preflight: {\n scope: APP_ROOT_CSS\n },\n cssVarsRoot: APP_ROOT_CSS,\n conditions: redirectLightCondition(mergedConfig.conditions),\n globalCss: redirectHtmlProps(mergedConfig.globalCss)\n })\n );\n }, [config]);\n\n useEffect(() => {\n const classes = appRoot.classList;\n const colorMode = \"light\"; // \"light\" | \"dark\"\n classes.add(colorMode);\n return () => {\n classes.remove(colorMode);\n };\n }, [appRoot]);\n\n const cache = useEmotionCache(rootNode);\n return (\n cache && (\n <CacheProvider value={cache}>\n <EnvironmentProvider\n value={rootNode}\n // Patched property\n portalNode={appRoot}\n >\n <LocaleProvider locale={locale}>\n <ChakraProvider value={system}>\n <GlobalStyles rootNode={rootNode} hostNode={hostNode} styles={styles} />\n {children}\n </ChakraProvider>\n </LocaleProvider>\n </EnvironmentProvider>\n </CacheProvider>\n )\n );\n};\n\nfunction GlobalStyles(props: {\n rootNode: RootNode;\n hostNode: HTMLElement | undefined;\n styles: ReadonlyReactive<string> | undefined;\n}) {\n const { rootNode, hostNode, styles } = props;\n const builtinStyles = useMemo(() => {\n const css = getBuiltinStyles(rootNode, hostNode);\n return <Global styles={css} />;\n }, [rootNode, hostNode]);\n const appStyles = useReactiveSnapshot(() => {\n const css = styles?.value;\n return css && <Global styles={css} />;\n }, [styles]);\n return (\n <>\n {builtinStyles}\n {appStyles}\n </>\n );\n}\n\nfunction redirectHtmlProps(\n css: Record<string, SystemStyleObject> | undefined\n): Record<string, SystemStyleObject> {\n const { html, ...rest } = css ?? {};\n if (!html) {\n throw new Error(ErrorId.INTERNAL, \"Expected global rules on html element.\");\n }\n // Take default html styles and apply them to the host element instead\n return {\n ...rest,\n [APP_ROOT_CSS]: html\n };\n}\n\nfunction redirectLightCondition(\n conditions: Record<string, unknown> | undefined\n): Record<string, unknown> {\n // Make sure light mode tokens are applied\n return {\n ...conditions,\n // Before: \":root &, .light &\"\n light: `${APP_ROOT_CSS} &, .light &`\n };\n}\n\nfunction useEmotionCache(rootNode: RootNode): EmotionCache | undefined {\n const stylesRoot = useMemo(() => getStylesRoot(rootNode), [rootNode]);\n\n const [cache, setCache] = useState<EmotionCache | undefined>();\n useEffect(() => {\n const cache = createCache({\n key: \"css\",\n container: stylesRoot\n });\n setCache(cache);\n return () => {\n setCache(undefined);\n for (const tag of cache.sheet.tags) {\n tag.remove();\n }\n };\n }, [stylesRoot]);\n return cache;\n}\n"],"names":["config","defaultTrailsConfig","cache"],"mappings":";;;;;;;;;;;AA0DA,MAAM,YAAA,GAAe,IAAI,cAAc,CAAA,CAAA;AAShC,MAAM,uBAAsD,CAAC;AAAA,EAChE,QAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,UACAA,QAAA,GAASC,MAAA;AAAA,EACT,MAAA,GAAS,OAAA;AAAA,EACT;AACJ,CAAA,KAAM;AAUF,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAM;AACzB,IAAA,MAAM,YAAA,GAAe,YAAA,CAAa,aAAA,EAAeD,QAAM,CAAA;AACvD,IAAA,OAAO,YAAA;AAAA,MACH,YAAA;AAAA;AAAA,MAGA,YAAA,CAAa;AAAA,QACT,SAAA,EAAW;AAAA,UACP,KAAA,EAAO;AAAA,SACX;AAAA,QACA,WAAA,EAAa,YAAA;AAAA,QACb,UAAA,EAAY,sBAAA,CAAuB,YAAA,CAAa,UAAU,CAAA;AAAA,QAC1D,SAAA,EAAW,iBAAA,CAAkB,YAAA,CAAa,SAAS;AAAA,OACtD;AAAA,KACL;AAAA,EACJ,CAAA,EAAG,CAACA,QAAM,CAAC,CAAA;AAEX,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,MAAM,UAAU,OAAA,CAAQ,SAAA;AACxB,IAAA,MAAM,SAAA,GAAY,OAAA;AAClB,IAAA,OAAA,CAAQ,IAAI,SAAS,CAAA;AACrB,IAAA,OAAO,MAAM;AACT,MAAA,OAAA,CAAQ,OAAO,SAAS,CAAA;AAAA,IAC5B,CAAA;AAAA,EACJ,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAEZ,EAAA,MAAM,KAAA,GAAQ,gBAAgB,QAAQ,CAAA;AACtC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E,IAAA,EAAM,GAAG,IAAA,EAAK,GAAI,OAAO,EAAC;AAClC,EAAA,IAAI,CAAC,IAAA,EAAM;AACP,IAAA,MAAM,IAAI,KAAA,CAAM,OAAA,CAAQ,QAAA,EAAU,wCAAwC,CAAA;AAAA,EAC9E;AAEA,EAAA,OAAO;AAAA,IACH,GAAG,IAAA;AAAA,IACH,CAAC,YAAY,GAAG;AAAA,GACpB;AACJ;AAEA,SAAS,uBACL,UAAA,EACuB;AAEvB,EAAA,OAAO;AAAA,IACH,GAAG,UAAA;AAAA;AAAA,IAEH,KAAA,EAAO,GAAG,YAAY,CAAA,YAAA;AAAA,GAC1B;AACJ;AAEA,SAAS,gBAAgB,QAAA,EAA8C;AACnE,EAAA,MAAM,UAAA,GAAa,QAAQ,MAAM,aAAA,CAAc,QAAQ,CAAA,EAAG,CAAC,QAAQ,CAAC,CAAA;AAEpE,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,QAAA,EAAmC;AAC7D,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,MAAME,SAAQ,WAAA,CAAY;AAAA,MACtB,GAAA,EAAK,KAAA;AAAA,MACL,SAAA,EAAW;AAAA,KACd,CAAA;AACD,IAAA,QAAA,CAASA,MAAK,CAAA;AACd,IAAA,OAAO,MAAM;AACT,MAAA,QAAA,CAAS,MAAS,CAAA;AAClB,MAAA,KAAA,MAAW,GAAA,IAAOA,MAAAA,CAAM,KAAA,CAAM,IAAA,EAAM;AAChC,QAAA,GAAA,CAAI,MAAA,EAAO;AAAA,MACf;AAAA,IACJ,CAAA;AAAA,EACJ,CAAA,EAAG,CAAC,UAAU,CAAC,CAAA;AACf,EAAA,OAAO,KAAA;AACX;;;;"}
@@ -1 +1 @@
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\nimport { Alert, Box, Heading, Text, VStack } from \"@chakra-ui/react\";\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\nexport function ErrorScreen(props: { intl: PackageIntl; error: Error }) {\n const intl = props.intl;\n return (\n <VStack padding={4} width=\"100%\" height=\"100%\" minWidth=\"350px\" minHeight=\"150px\">\n <Heading>{intl.formatMessage({ id: \"title\" })}</Heading>\n <Alert.Root status=\"error\" size=\"lg\" maxWidth={550} borderRadius=\"4px\" mt={2}>\n <Alert.Indicator />\n <Alert.Content>\n <Alert.Title fontWeight=\"bold\">\n {intl.formatMessage({ id: \"alertTitle\" })}\n </Alert.Title>\n <Alert.Description>\n {intl.formatMessage({ id: \"alertDescription\" })}\n </Alert.Description>\n </Alert.Content>\n </Alert.Root>\n\n {import.meta.env.DEV && (\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 );\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":";;;AAKA,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;AAEO,SAAS,YAAY,KAA4C,EAAA;AACpE,EAAA,MAAM,OAAO,KAAM,CAAA,IAAA;AACnB,EACI,uBAAA,IAAA,CAAC,MAAO,EAAA,EAAA,OAAA,EAAS,CAAG,EAAA,KAAA,EAAM,MAAO,EA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AA,EAAE,EAAI,EAAA,sBAAA,EAA0B,EAAA,EAAE,OAAQ,EAAC,CACnE,EAAA,CAAA;AAAA,IACC;AAAA,GACL,EAAA,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\nimport { Alert, Box, Heading, Text, VStack } from \"@chakra-ui/react\";\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\nexport function ErrorScreen(props: { intl: PackageIntl; error: Error }) {\n const intl = props.intl;\n return (\n <VStack padding={4} width=\"100%\" height=\"100%\" minWidth=\"350px\" minHeight=\"150px\">\n <Heading>{intl.formatMessage({ id: \"title\" })}</Heading>\n <Alert.Root status=\"error\" size=\"lg\" maxWidth={550} borderRadius=\"4px\" mt={2}>\n <Alert.Indicator />\n <Alert.Content>\n <Alert.Title fontWeight=\"bold\">\n {intl.formatMessage({ id: \"alertTitle\" })}\n </Alert.Title>\n <Alert.Description>\n {intl.formatMessage({ id: \"alertDescription\" })}\n </Alert.Description>\n </Alert.Content>\n </Alert.Root>\n\n {import.meta.env.DEV && (\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 );\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":";;;AAKA,MAAM,WAAA,GAAc;AAAA,EAChB,OAAA,EAAS,gCAAA;AAAA,EACT,YAAA,EAAc,QAAA;AAAA,EACd,kBAAA,EAAoB,6DAAA;AAAA,EAEpB,eAAA,EAAiB,eAAA;AAAA,EACjB,iBAAA,EAAmB,iDAAA;AAAA,EACnB,sBAAA,EAAwB;AAC5B,CAAA;AAEA,MAAM,WAAA,GAAc;AAAA,EAChB,OAAA,EAAS,0BAAA;AAAA,EACT,YAAA,EAAc,OAAA;AAAA,EACd,kBAAA,EAAoB,2DAAA;AAAA,EAEpB,eAAA,EAAiB,eAAA;AAAA,EACjB,iBAAA,EAAmB,0CAAA;AAAA,EACnB,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AAA,CAAK,aAAA,CAAc,EAAE,EAAA,EAAI,mBAAmB;AAAA,GAAA,EACjD,CAAA;AAEJ,EAAA,uBACI,IAAA,CAAC,GAAA,EAAA,EAAI,CAAA,EAAG,CAAA,EAAG,WAAW,0BAAA,EAClB,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,IAAA,EAAA,EAAK,SAAA,EAAW,QAAA,EACZ,QAAA,EAAA,IAAA,CAAK,aAAA,CAAc,EAAE,EAAA,EAAI,sBAAA,EAAuB,EAAG,EAAE,OAAA,EAAS,CAAA,EACnE,CAAA;AAAA,IACC;AAAA,GAAA,EACL,CAAA;AAER;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"PackageContext.js","sources":["PackageContext.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createContext } from \"react\";\nimport type { PackageIntl } from \"../i18n\";\nimport type { Service } from \"../Service\";\nimport type { UseServiceOptions } from \"./hooks\";\n\nexport interface PackageContextMethods {\n getService: (packageName: string, interfaceName: string, options: UseServiceOptions) => Service;\n getServices: (packageName: string, interfaceName: string) => Service[];\n getProperties: (packageName: string) => Readonly<Record<string, unknown>>;\n getIntl(packageName: string): PackageIntl;\n}\n\nexport const PackageContext = createContext<PackageContextMethods | null>(null);\n"],"names":[],"mappings":";;AAca,MAAA,cAAA,GAAiB,cAA4C,IAAI;;;;"}
1
+ {"version":3,"file":"PackageContext.js","sources":["PackageContext.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createContext } from \"react\";\nimport type { PackageIntl } from \"../i18n\";\nimport type { Service } from \"../Service\";\nimport type { UseServiceOptions } from \"./hooks\";\n\nexport interface PackageContextMethods {\n getService: (packageName: string, interfaceName: string, options: UseServiceOptions) => Service;\n getServices: (packageName: string, interfaceName: string) => Service[];\n getProperties: (packageName: string) => Readonly<Record<string, unknown>>;\n getIntl(packageName: string): PackageIntl;\n}\n\nexport const PackageContext = createContext<PackageContextMethods | null>(null);\n"],"names":[],"mappings":";;AAcO,MAAM,cAAA,GAAiB,cAA4C,IAAI;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ReactIntegration.js","sources":["ReactIntegration.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { SystemConfig } from \"@chakra-ui/react\";\nimport { ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ReactNode, StrictMode } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport { RootNode } from \"../dom\";\nimport { ErrorId } from \"../errors\";\nimport { InterfaceSpec, renderInterfaceSpec } from \"../service-layer/InterfaceSpec\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport { ServiceLayer } from \"../service-layer/ServiceLayer\";\nimport { renderAmbiguousServiceChoices } from \"../service-layer/ServiceLookup\";\nimport { CustomChakraProvider } from \"./ChakraProvider\";\nimport { PackageContext, PackageContextMethods } from \"./PackageContext\";\n\nexport interface ReactIntegrationOptions {\n rootNode: RootNode;\n hostNode: HTMLElement;\n appRoot: HTMLDivElement;\n packages: Map<string, PackageRepr>;\n serviceLayer: ServiceLayer;\n\n locale: string;\n config: SystemConfig | undefined;\n styles: ReadonlyReactive<string>;\n}\n\nexport class ReactIntegration {\n private rootNode: RootNode;\n private hostNode: HTMLElement;\n private appRoot: HTMLDivElement;\n private reactRoot: Root;\n private packageContext: PackageContextMethods;\n private locale: string;\n private chakraConfig: SystemConfig | undefined;\n private styles: ReadonlyReactive<string>;\n\n static createForApp(options: ReactIntegrationOptions): ReactIntegration {\n const { serviceLayer, packages } = options;\n const packageContext = createPackageContext(serviceLayer, packages);\n return new ReactIntegration({ ...options, packageContext });\n }\n\n static createForErrorScreen(\n options: Omit<ReactIntegrationOptions, \"serviceLayer\" | \"packages\">\n ) {\n const throwError = () => {\n throw new Error(ErrorId.INVALID_STATE, \"Hook cannot be used within the error screen.\");\n };\n const packageContext: PackageContextMethods = {\n getIntl: throwError,\n getProperties: throwError,\n getService: throwError,\n getServices: throwError\n };\n return new ReactIntegration({ ...options, packageContext });\n }\n\n private constructor(\n options: Omit<ReactIntegrationOptions, \"serviceLayer\" | \"packages\"> & {\n packageContext: PackageContextMethods;\n }\n ) {\n this.rootNode = options.rootNode;\n this.hostNode = options.hostNode;\n this.appRoot = options.appRoot;\n this.reactRoot = createRoot(options.appRoot);\n this.chakraConfig = options.config;\n this.packageContext = options.packageContext;\n this.locale = options.locale;\n this.styles = options.styles;\n }\n\n render(contentNode: ReactNode) {\n this.reactRoot.render(\n <StrictMode>\n <CustomChakraProvider\n rootNode={this.rootNode}\n hostNode={this.hostNode}\n appRoot={this.appRoot}\n config={this.chakraConfig}\n locale={this.locale}\n styles={this.styles}\n >\n <PackageContext.Provider value={this.packageContext}>\n {contentNode}\n </PackageContext.Provider>\n </CustomChakraProvider>\n </StrictMode>\n );\n }\n\n destroy() {\n this.reactRoot.unmount();\n }\n}\n\nexport function EmptyComponent(): ReactNode {\n return null;\n}\n\nfunction createPackageContext(\n serviceLayer: ServiceLayer,\n packages: Map<string, PackageRepr>\n): PackageContextMethods {\n const getPackage = (packageName: string): PackageRepr => {\n const pkg = packages.get(packageName);\n if (!pkg) {\n throw new Error(\n ErrorId.INTERNAL,\n `Package '${packageName}' was not found in application.`\n );\n }\n return pkg;\n };\n\n const packageContext: PackageContextMethods = {\n getService: (packageName, interfaceName, options) => {\n const spec: InterfaceSpec = { interfaceName, ...options };\n const result = serviceLayer.getService(packageName, spec);\n if (result.type === \"found\") {\n return result.value.getInstanceOrThrow();\n }\n\n const renderedSpec = renderInterfaceSpec(spec);\n switch (result.type) {\n case \"unimplemented\":\n throw new Error(\n ErrorId.INTERFACE_NOT_FOUND,\n `The UI of package '${packageName}' requested the unimplemented interface ${renderedSpec}.`\n );\n case \"undeclared\":\n throw new Error(\n ErrorId.UNDECLARED_DEPENDENCY,\n `Package '${packageName}' did not declare an UI dependency on interface ${renderedSpec}.` +\n ` Add the dependency to the package configuration or remove the usage.`\n );\n case \"ambiguous\": {\n const renderedChoices = renderAmbiguousServiceChoices(result.choices);\n throw new Error(\n ErrorId.AMBIGUOUS_DEPENDENCY,\n `The UI of package '${packageName}' requires the ambiguous interface ${renderedSpec}.` +\n ` Possible choices are: ${renderedChoices}.`\n );\n }\n case \"unknown-package\":\n throw new Error(\n ErrorId.MISSING_PACKAGE,\n missingPackageMessage(packageName, interfaceName)\n );\n }\n },\n getServices: (packageName, interfaceName) => {\n const result = serviceLayer.getServices(packageName, interfaceName);\n if (result.type === \"found\") {\n return result.value.map((serviceRepr) => serviceRepr.getInstanceOrThrow());\n }\n\n switch (result.type) {\n case \"undeclared\":\n throw new Error(\n ErrorId.UNDECLARED_DEPENDENCY,\n `Package '${packageName}' did not declare an UI dependency on all services implementing interface '${interfaceName}'.` +\n ` Add the dependency (\"all\": true) to the package configuration or remove the usage.`\n );\n case \"unknown-package\":\n throw new Error(\n ErrorId.MISSING_PACKAGE,\n missingPackageMessage(packageName, interfaceName)\n );\n }\n },\n getProperties: (packageName) => {\n return getPackage(packageName).properties;\n },\n getIntl: (packageName) => {\n return getPackage(packageName).intl;\n }\n };\n return packageContext;\n}\n\nfunction missingPackageMessage(packageName: string, interfaceName: string) {\n return (\n `Package '${packageName}' was not found in the application's metadata while it attempted to reference the interface '${interfaceName}'. ` +\n `Check that the dependency is declared correctly in the packages that use '${packageName}'.`\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AA4BO,MAAM,gBAAiB,CAAA;AAAA,EAClB,QAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACA,MAAA;AAAA,EAER,OAAO,aAAa,OAAoD,EAAA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A,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
+ {"version":3,"file":"ReactIntegration.js","sources":["ReactIntegration.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { SystemConfig } from \"@chakra-ui/react\";\nimport { ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ReactNode, StrictMode } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport { RootNode } from \"../dom\";\nimport { ErrorId } from \"../errors\";\nimport { InterfaceSpec, renderInterfaceSpec } from \"../service-layer/InterfaceSpec\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport { ServiceLayer } from \"../service-layer/ServiceLayer\";\nimport { renderAmbiguousServiceChoices } from \"../service-layer/ServiceLookup\";\nimport { CustomChakraProvider } from \"./ChakraProvider\";\nimport { PackageContext, PackageContextMethods } from \"./PackageContext\";\n\nexport interface ReactIntegrationOptions {\n rootNode: RootNode;\n hostNode: HTMLElement;\n appRoot: HTMLDivElement;\n packages: Map<string, PackageRepr>;\n serviceLayer: ServiceLayer;\n\n locale: string;\n config: SystemConfig | undefined;\n styles: ReadonlyReactive<string>;\n}\n\nexport class ReactIntegration {\n private rootNode: RootNode;\n private hostNode: HTMLElement;\n private appRoot: HTMLDivElement;\n private reactRoot: Root;\n private packageContext: PackageContextMethods;\n private locale: string;\n private chakraConfig: SystemConfig | undefined;\n private styles: ReadonlyReactive<string>;\n\n static createForApp(options: ReactIntegrationOptions): ReactIntegration {\n const { serviceLayer, packages } = options;\n const packageContext = createPackageContext(serviceLayer, packages);\n return new ReactIntegration({ ...options, packageContext });\n }\n\n static createForErrorScreen(\n options: Omit<ReactIntegrationOptions, \"serviceLayer\" | \"packages\">\n ) {\n const throwError = () => {\n throw new Error(ErrorId.INVALID_STATE, \"Hook cannot be used within the error screen.\");\n };\n const packageContext: PackageContextMethods = {\n getIntl: throwError,\n getProperties: throwError,\n getService: throwError,\n getServices: throwError\n };\n return new ReactIntegration({ ...options, packageContext });\n }\n\n private constructor(\n options: Omit<ReactIntegrationOptions, \"serviceLayer\" | \"packages\"> & {\n packageContext: PackageContextMethods;\n }\n ) {\n this.rootNode = options.rootNode;\n this.hostNode = options.hostNode;\n this.appRoot = options.appRoot;\n this.reactRoot = createRoot(options.appRoot);\n this.chakraConfig = options.config;\n this.packageContext = options.packageContext;\n this.locale = options.locale;\n this.styles = options.styles;\n }\n\n render(contentNode: ReactNode) {\n this.reactRoot.render(\n <StrictMode>\n <CustomChakraProvider\n rootNode={this.rootNode}\n hostNode={this.hostNode}\n appRoot={this.appRoot}\n config={this.chakraConfig}\n locale={this.locale}\n styles={this.styles}\n >\n <PackageContext.Provider value={this.packageContext}>\n {contentNode}\n </PackageContext.Provider>\n </CustomChakraProvider>\n </StrictMode>\n );\n }\n\n destroy() {\n this.reactRoot.unmount();\n }\n}\n\nexport function EmptyComponent(): ReactNode {\n return null;\n}\n\nfunction createPackageContext(\n serviceLayer: ServiceLayer,\n packages: Map<string, PackageRepr>\n): PackageContextMethods {\n const getPackage = (packageName: string): PackageRepr => {\n const pkg = packages.get(packageName);\n if (!pkg) {\n throw new Error(\n ErrorId.INTERNAL,\n `Package '${packageName}' was not found in application.`\n );\n }\n return pkg;\n };\n\n const packageContext: PackageContextMethods = {\n getService: (packageName, interfaceName, options) => {\n const spec: InterfaceSpec = { interfaceName, ...options };\n const result = serviceLayer.getService(packageName, spec);\n if (result.type === \"found\") {\n return result.value.getInstanceOrThrow();\n }\n\n const renderedSpec = renderInterfaceSpec(spec);\n switch (result.type) {\n case \"unimplemented\":\n throw new Error(\n ErrorId.INTERFACE_NOT_FOUND,\n `The UI of package '${packageName}' requested the unimplemented interface ${renderedSpec}.`\n );\n case \"undeclared\":\n throw new Error(\n ErrorId.UNDECLARED_DEPENDENCY,\n `Package '${packageName}' did not declare an UI dependency on interface ${renderedSpec}.` +\n ` Add the dependency to the package configuration or remove the usage.`\n );\n case \"ambiguous\": {\n const renderedChoices = renderAmbiguousServiceChoices(result.choices);\n throw new Error(\n ErrorId.AMBIGUOUS_DEPENDENCY,\n `The UI of package '${packageName}' requires the ambiguous interface ${renderedSpec}.` +\n ` Possible choices are: ${renderedChoices}.`\n );\n }\n case \"unknown-package\":\n throw new Error(\n ErrorId.MISSING_PACKAGE,\n missingPackageMessage(packageName, interfaceName)\n );\n }\n },\n getServices: (packageName, interfaceName) => {\n const result = serviceLayer.getServices(packageName, interfaceName);\n if (result.type === \"found\") {\n return result.value.map((serviceRepr) => serviceRepr.getInstanceOrThrow());\n }\n\n switch (result.type) {\n case \"undeclared\":\n throw new Error(\n ErrorId.UNDECLARED_DEPENDENCY,\n `Package '${packageName}' did not declare an UI dependency on all services implementing interface '${interfaceName}'.` +\n ` Add the dependency (\"all\": true) to the package configuration or remove the usage.`\n );\n case \"unknown-package\":\n throw new Error(\n ErrorId.MISSING_PACKAGE,\n missingPackageMessage(packageName, interfaceName)\n );\n }\n },\n getProperties: (packageName) => {\n return getPackage(packageName).properties;\n },\n getIntl: (packageName) => {\n return getPackage(packageName).intl;\n }\n };\n return packageContext;\n}\n\nfunction missingPackageMessage(packageName: string, interfaceName: string) {\n return (\n `Package '${packageName}' was not found in the application's metadata while it attempted to reference the interface '${interfaceName}'. ` +\n `Check that the dependency is declared correctly in the packages that use '${packageName}'.`\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AA4BO,MAAM,gBAAA,CAAiB;AAAA,EAClB,QAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACA,MAAA;AAAA,EAER,OAAO,aAAa,OAAA,EAAoD;AACpE,IAAA,MAAM,EAAE,YAAA,EAAc,QAAA,EAAS,GAAI,OAAA;AACnC,IAAA,MAAM,cAAA,GAAiB,oBAAA,CAAqB,YAAA,EAAc,QAAQ,CAAA;AAClE,IAAA,OAAO,IAAI,gBAAA,CAAiB,EAAE,GAAG,OAAA,EAAS,gBAAgB,CAAA;AAAA,EAC9D;AAAA,EAEA,OAAO,qBACH,OAAA,EACF;AACE,IAAA,MAAM,aAAa,MAAM;AACrB,MAAA,MAAM,IAAI,KAAA,CAAM,OAAA,CAAQ,aAAA,EAAe,8CAA8C,CAAA;AAAA,IACzF,CAAA;AACA,IAAA,MAAM,cAAA,GAAwC;AAAA,MAC1C,OAAA,EAAS,UAAA;AAAA,MACT,aAAA,EAAe,UAAA;AAAA,MACf,UAAA,EAAY,UAAA;AAAA,MACZ,WAAA,EAAa;AAAA,KACjB;AACA,IAAA,OAAO,IAAI,gBAAA,CAAiB,EAAE,GAAG,OAAA,EAAS,gBAAgB,CAAA;AAAA,EAC9D;AAAA,EAEQ,YACJ,OAAA,EAGF;AACE,IAAA,IAAA,CAAK,WAAW,OAAA,CAAQ,QAAA;AACxB,IAAA,IAAA,CAAK,WAAW,OAAA,CAAQ,QAAA;AACxB,IAAA,IAAA,CAAK,UAAU,OAAA,CAAQ,OAA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open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Error } from \"@open-pioneer/core\";\nimport { useContext, useMemo } from \"react\";\nimport { InterfaceNameForServiceType } from \"../DeclaredService\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl } from \"../i18n\";\nimport { PackageContext, PackageContextMethods } from \"./PackageContext\";\n\n/*\n\n IMPORTANT\n =========\n\n The functions in this file are part of the public API, although they should not be called directly.\n They are imported by code generated during separate package compilation generation via:\n\n import { hookName } from '@open-pioneer/runtime/react-integration'\n\n They are also imported by the vite plugin during development and when building an application.\n\n The matching exports are in the neighboring `index.ts`.\n The interfaces of these hooks must remain stable so that already published packages can continue to work in the future.\n\n See also the implementation of @open-pioneer/build-package.\n\n*/\n\nexport interface UseServiceOptions {\n /** An additional qualifier to disambiguate service instances that implement the same interface. */\n qualifier?: string;\n}\n\n/**\n * Returns a service that implements the given interface.\n * Receives the package name of the importing package as a string.\n *\n * This is an internal hook that is typically called indirectly via the hook\n * provided from `\"open-pioneer:react-hooks\"`.\n *\n * @private\n */\nexport function useServiceInternal<ServiceType = unknown>(\n packageName: string,\n interfaceName: InterfaceNameForServiceType<ServiceType>,\n options?: UseServiceOptions\n): ServiceType;\nexport function useServiceInternal(\n packageName: string,\n // 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":";;;;;AA+CgB,SAAA,kBAAA,CACZ,WAEA,EAAA,aAAA,EACA,OACO,EAAA;AACP,EAAM,MAAA,OAAA,GAAU,WAAW,cAAc,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;AAAC,KAChB;AAAA,IACJ,CAAC,OAAA,EAAS,WAAa,EAAA,aAAA,EAAe,OAAO;AAAA,GACjD;AACA,EAAO,OAAA,OAAA;AACX;AAiBgB,SAAA,mBAAA,CAAoB,aAAqB,aAA+B,EAAA;AACpF,EAAM,MAAA,OAAA,GAAU,WAAW,cAAc,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;AAAA,GACxC;AACA,EAAO,OAAA,QAAA;AACX;AAUO,SAAS,sBAAsB,WAAwD,EAAA;AAC1F,EAAM,MAAA,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,OAAO,YAAa,CAAA,eAAA,EAAiB,OAAO,CAAA,CAAE,cAAc,WAAW,CAAA;AAC3E;AAUO,SAAS,gBAAgB,WAAkC,EAAA;AAC9D,EAAM,MAAA,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,OAAO,YAAa,CAAA,SAAA,EAAW,OAAO,CAAA,CAAE,QAAQ,WAAW,CAAA;AAC/D;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;AAAA,KACvD;AAAA;AAEJ,EAAO,OAAA,WAAA;AACX;;;;"}
1
+ {"version":3,"file":"hooks.js","sources":["hooks.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Error } from \"@open-pioneer/core\";\nimport { useContext, useMemo } from \"react\";\nimport { InterfaceNameForServiceType } from \"../DeclaredService\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl } from \"../i18n\";\nimport { PackageContext, PackageContextMethods } from \"./PackageContext\";\n\n/*\n\n IMPORTANT\n =========\n\n The functions in this file are part of the public API, although they should not be called directly.\n They are imported by code generated during separate package compilation generation via:\n\n import { hookName } from '@open-pioneer/runtime/react-integration'\n\n They are also imported by the vite plugin during development and when building an application.\n\n The matching exports are in the neighboring `index.ts`.\n The interfaces of these hooks must remain stable so that already published packages can continue to work in the future.\n\n See also the implementation of @open-pioneer/build-package.\n\n*/\n\nexport interface UseServiceOptions {\n /** An additional qualifier to disambiguate service instances that implement the same interface. */\n qualifier?: string;\n}\n\n/**\n * Returns a service that implements the given interface.\n * Receives the package name of the importing package as a string.\n *\n * This is an internal hook that is typically called indirectly via the hook\n * provided from `\"open-pioneer:react-hooks\"`.\n *\n * @private\n */\nexport function useServiceInternal<ServiceType = unknown>(\n packageName: string,\n interfaceName: InterfaceNameForServiceType<ServiceType>,\n options?: UseServiceOptions\n): ServiceType;\nexport function useServiceInternal(\n packageName: string,\n // 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":";;;;;AA+CO,SAAS,kBAAA,CACZ,WAAA,EAEA,aAAA,EACA,OAAA,EACO;AACP,EAAA,MAAM,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,MAAM,OAAA,GAAU,OAAA;AAAA,IACZ,MACI,YAAA,CAAa,YAAA,EAAc,OAAO,CAAA,CAAE,UAAA;AAAA,MAChC,WAAA;AAAA,MACA,aAAA;AAAA,MACA,WAAW;AAAC,KAChB;AAAA,IACJ,CAAC,OAAA,EAAS,WAAA,EAAa,aAAA,EAAe,OAAO;AAAA,GACjD;AACA,EAAA,OAAO,OAAA;AACX;AAiBO,SAAS,mBAAA,CAAoB,aAAqB,aAAA,EAA+B;AACpF,EAAA,MAAM,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,MAAM,QAAA,GAAW,OAAA;AAAA,IACb,MAAM,YAAA,CAAa,aAAA,EAAe,OAAO,CAAA,CAAE,WAAA,CAAY,aAAa,aAAa,CAAA;AAAA,IACjF,CAAC,OAAA,EAAS,WAAA,EAAa,aAAa;AAAA,GACxC;AACA,EAAA,OAAO,QAAA;AACX;AAUO,SAAS,sBAAsB,WAAA,EAAwD;AAC1F,EAAA,MAAM,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,OAAO,YAAA,CAAa,eAAA,EAAiB,OAAO,CAAA,CAAE,cAAc,WAAW,CAAA;AAC3E;AAUO,SAAS,gBAAgB,WAAA,EAAkC;AAC9D,EAAA,MAAM,OAAA,GAAU,WAAW,cAAc,CAAA;AACzC,EAAA,OAAO,YAAA,CAAa,SAAA,EAAW,OAAO,CAAA,CAAE,QAAQ,WAAW,CAAA;AAC/D;AAEA,SAAS,YAAA,CACL,UACA,WAAA,EACqB;AACrB,EAAA,IAAI,CAAC,WAAA,EAAa;AACd,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,OAAA,CAAQ,QAAA;AAAA,MACR,2CAA2C,QAAQ,CAAA,6CAAA;AAAA,KACvD;AAAA,EACJ;AACA,EAAA,OAAO,WAAA;AACX;;;;"}
@@ -1 +1 @@
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
+ {"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,mBAAA,CAAoB,EAAE,aAAA,EAAe,SAAA,EAAU,EAA0B;AACrF,EAAA,OAAO,IAAI,aAAa,CAAA,CAAA,CAAA,IAAO,SAAA,GAAY,CAAA,cAAA,EAAiB,SAAS,CAAA,EAAA,CAAA,GAAO,EAAA,CAAA;AAChF;AAeO,SAAS,mBAAmB,QAAA,EAAqD;AACpF,EAAA,IAAI,CAAC,QAAA,EAAU;AACX,IAAA,MAAM,IAAI,KAAA,CAAM,OAAA,CAAQ,gBAAA,EAAkB,6BAA6B,CAAA;AAAA,EAC3E;AACA,EAAA,IAAI,QAAA,CAAS,GAAA,IAAO,QAAA,CAAS,SAAA,EAAW;AACpC,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,OAAA,CAAQ,gBAAA;AAAA,MACR;AAAA,KACJ;AAAA,EACJ;AACA,EAAA,IAAI,SAAS,GAAA,EAAK;AACd,IAAA,OAAO;AAAA,MACH,GAAA,EAAK,IAAA;AAAA,MACL,eAAe,QAAA,CAAS;AAAA,KAC5B;AAAA,EACJ;AACA,EAAA,OAAO;AAAA,IACH,eAAe,QAAA,CAAS,IAAA;AAAA,IACxB,WAAW,QAAA,CAAS;AAAA,GACxB;AACJ;AAEO,SAAS,2BAA2B,IAAA,EAAuD;AAC9F,EAAA,OAAO,CAAC,IAAA,CAAK,GAAA;AACjB;AAEO,SAAS,yBAAyB,IAAA,EAAqD;AAC1F,EAAA,OAAO,KAAK,GAAA,KAAQ,IAAA;AACxB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"PackageRepr.js","sources":["PackageRepr.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Error } from \"@open-pioneer/core\";\nimport { ApplicationProperties } from \"../CustomElement\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl, AppIntl } 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: AppIntl,\n customProperties?: ApplicationProperties\n) {\n return Object.entries(packages).map<PackageRepr>(([name, packageMetadata]) => {\n if (name !== packageMetadata.name) {\n throw new Error(ErrorId.INVALID_METADATA, \"Invalid metadata: package name mismatch.\");\n }\n\n const packageI18n = i18n.createPackageI18n(name);\n return PackageRepr.create(packageMetadata, packageI18n, customProperties?.[name]);\n });\n}\n\n/**\n * Merges the declared properties of the package with the application-defined\n * custom properties.\n */\nfunction customizeProperties(\n packageName: string,\n properties: Record<string, PropertyMetadata>,\n customProperties: Record<string, unknown> = {}\n) {\n const merged: Record<string, unknown> = {};\n const required: string[] = [];\n for (const [key, propertyMetadata] of Object.entries(properties)) {\n merged[key] = propertyMetadata.value;\n if (propertyMetadata.required) {\n required.push(key);\n }\n }\n\n for (const [key, value] of Object.entries(customProperties)) {\n if (!hasProperty(merged, key)) {\n throw new Error(\n ErrorId.INVALID_PROPERTY_NAME,\n `Unexpected property name '${key}' for package '${packageName}': the property does not exist.`\n );\n }\n merged[key] = value;\n }\n\n for (const key of required) {\n const value = merged[key];\n if (value == null) {\n throw new Error(\n ErrorId.REQUIRED_PROPERTY,\n `Package '${packageName}' requires the property '${key}' to be initialized to a non-null value.`\n );\n }\n }\n\n return merged;\n}\n\nconst HAS_PROP = Object.prototype.hasOwnProperty;\n\nfunction hasProperty(object: unknown, key: string) {\n return HAS_PROP.call(object, key);\n}\n\n// http://json.schemastore.org/package\nconst NAME_REGEX = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/;\n\nfunction isValidPackageName(name: string): boolean {\n return NAME_REGEX.test(name);\n}\n"],"names":["name"],"mappings":";;;;;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,YAA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GAAG,CAAA,wCAAA;AAAA,OAC1D;AAAA;AACJ;AAGJ,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
+ {"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, AppIntl } 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: AppIntl,\n customProperties?: ApplicationProperties\n) {\n return Object.entries(packages).map<PackageRepr>(([name, packageMetadata]) => {\n if (name !== packageMetadata.name) {\n throw new Error(ErrorId.INVALID_METADATA, \"Invalid metadata: package name mismatch.\");\n }\n\n const packageI18n = i18n.createPackageI18n(name);\n return PackageRepr.create(packageMetadata, packageI18n, customProperties?.[name]);\n });\n}\n\n/**\n * Merges the declared properties of the package with the application-defined\n * custom properties.\n */\nfunction customizeProperties(\n packageName: string,\n properties: Record<string, PropertyMetadata>,\n customProperties: Record<string, unknown> = {}\n) {\n const merged: Record<string, unknown> = {};\n const required: string[] = [];\n for (const [key, propertyMetadata] of Object.entries(properties)) {\n merged[key] = propertyMetadata.value;\n if (propertyMetadata.required) {\n required.push(key);\n }\n }\n\n for (const [key, value] of Object.entries(customProperties)) {\n if (!hasProperty(merged, key)) {\n throw new Error(\n ErrorId.INVALID_PROPERTY_NAME,\n `Unexpected property name '${key}' for package '${packageName}': the property does not exist.`\n );\n }\n merged[key] = value;\n }\n\n for (const key of required) {\n const value = merged[key];\n if (value == null) {\n throw new Error(\n ErrorId.REQUIRED_PROPERTY,\n `Package '${packageName}' requires the property '${key}' to be initialized to a non-null value.`\n );\n }\n }\n\n return merged;\n}\n\nconst HAS_PROP = Object.prototype.hasOwnProperty;\n\nfunction hasProperty(object: unknown, key: string) {\n return HAS_PROP.call(object, key);\n}\n\n// http://json.schemastore.org/package\nconst NAME_REGEX = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/;\n\nfunction isValidPackageName(name: string): boolean {\n return NAME_REGEX.test(name);\n}\n"],"names":["name"],"mappings":";;;;;AAkBO,MAAM,WAAA,CAAY;AAAA,EACrB,OAAO,MAAA,CACH,IAAA,EACA,IAAA,EACA,gBAAA,EACW;AACX,IAAA,MAAM,OAAO,IAAA,CAAK,IAAA;AAClB,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,UAAA,IAAc,EAAC;AACvC,IAAA,MAAM,eAAA,GAAkB,mBAAA,CAAoB,IAAA,EAAM,UAAA,EAAY,gBAAgB,CAAA;AAC9E,IAAA,MAAM,WAAW,MAAA,CAAO,OAAA,CAAQ,KAAK,QAAA,IAAY,EAAE,CAAA,CAAE,GAAA;AAAA,MACjD,CAAC,CAACA,KAAAA,EAAM,WAAW,CAAA,KAAM;AACrB,QAAA,IAAIA,KAAAA,KAAS,YAAY,IAAA,EAAM;AAC3B,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAA,CAAQ,gBAAA;AAAA,YACR;AAAA,WACJ;AAAA,QACJ;AACA,QAAA,OAAO,YAAY,MAAA,CAAO,IAAA,CAAK,IAAA,EAAM,WAAA,EAAa,MAAM,eAAe,CAAA;AAAA,MAC3E;AAAA,KACJ;AACA,IAAA,MAAM,YAAA,GAAe,IAAA,CAAK,EAAA,EAAI,UAAA,EAAY,GAAA,CAAI,CAAC,GAAA,KAAQ,kBAAA,CAAmB,GAAG,CAAC,CAAA,IAAK,EAAC;AACpF,IAAA,OAAO,IAAI,WAAA,CAAY;AAAA,MACnB,IAAA;AAAA,MACA,QAAA;AAAA,MACA,YAAA;AAAA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A,EAAa;AAC/C,EAAA,OAAO,QAAA,CAAS,IAAA,CAAK,MAAA,EAAQ,GAAG,CAAA;AACpC;AAGA,MAAM,UAAA,GAAa,4DAAA;AAEnB,SAAS,mBAAmB,IAAA,EAAuB;AAC/C,EAAA,OAAO,UAAA,CAAW,KAAK,IAAI,CAAA;AAC/B;;;;"}
@@ -1 +1 @@
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 index;\n}\n"],"names":["referenceMeta"],"mappings":";;;;;;AAuBA,MAAM,GAAA,GAAM,aAAa,sBAAsB,CAAA;AAkB/C,MAAM,qBAAA,GAAwB,EAAE,IAAA,EAAM,YAAa,EAAA;AACnD,MAAM,eAAA,GAAkB,EAAE,IAAA,EAAM,iBAAkB,EAAA;AAQ3C,MAAM,YAAa,CAAA;AAAA;AAAA,EAEd,WAAA;AAAA;AAAA,EAGA,gBAAA;AAAA,EAEA,aAAA;AAAA;AAAA,EAGA,mBAAA;AAAA;AAAA,EAGA,oBAAA;AAAA,EACA,KAAiD,GAAA,aAAA;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;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;AAAA,SACP;AAAA,OACH;AAAA,MAEJ,IAAK,EAAA;AACV,IAAA,MAAM,kBAAqB,GAAA;AAAA,MACvB,GAAG,gBAAA,CAAiB,GAAyB,CAAA,CAAC,CAAO,MAAA;AAAA,QACjD,IAAM,EAAA,WAAA;AAAA,QACN,GAAG;AAAA,OACL,CAA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AW,GAAI,CAAA,WAAA,CAAY,SAAS,CAAA;AAAA;AACvD,OACG,MAAA;AACH,QAAA,MAAM,IAAI,KAAA,CAAM,OAAQ,CAAA,QAAA,EAAU,CAAiC,+BAAA,CAAA,CAAA;AAAA;AACvE;AAEJ,IAAM,KAAA,CAAA,GAAA,CAAI,aAAa,YAAY,CAAA;AAAA;AAEvC,EAAO,OAAA,KAAA;AACX;;;;"}
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 index;\n}\n"],"names":["referenceMeta"],"mappings":";;;;;;AAuBA,MAAM,GAAA,GAAM,aAAa,sBAAsB,CAAA;AAkB/C,MAAM,qBAAA,GAAwB,EAAE,IAAA,EAAM,YAAA,EAAa;AACnD,MAAM,eAAA,GAAkB,EAAE,IAAA,EAAM,iBAAA,EAAkB;AAQ3C,MAAM,YAAA,CAAa;AAAA;AAAA,EAEd,WAAA;AAAA;AAAA,EAGA,gBAAA;AAAA,EAEA,aAAA;AAAA;AAAA,EAGA,mBAAA;AAAA;AAAA,EAGA,oBAAA;AAAA,EACA,KAAA,GAAiD,aAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASzD,WAAA,CAAY,QAAA,EAAkC,gBAAA,GAAoC,EAAC,EAAG;AAClF,IAAA,MAAM,WAAA,GAAc,SAAS,GAAA,CAAI,CAAC,QAAQ,GAAA,CAAI,QAAQ,EAAE,IAAA,EAAK;AAC7D,IAAA,MAAM,iBAAiB,QAAA,CAClB,GAAA;AAAA,MAAI,CAAC,GAAA,KACF,GAAA,CAAI,YAAA,CAAa,GAAA,CAAkB,CAAC,GAAA,KAAQ;AACxC,QAAA,OAAO;AAAA,UACH,IAAA,EAAM,IAAA;AAAA,UACN,aAAa,GAAA,CAAI,IAAA;AAAA,UACjB,GAAG;AAAA,SACP;AAAA,MACJ,CAAC;AAAA,MAEJ,IAAA,EAAK;AACV,IAAA,MAAM,kBAAA,GAAqB;AAAA,MACvB,GAAG,gBAAA,CAAiB,GAAA,CAAyB,CAAC,CAAA,MAAO;AAAA,QACjD,IAAA,EA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AAI,wBAAA,CAAyB,WAAW,CAAA,EAAG;AACvC,QAAA,cAAA,CAAe,GAAA,GAAM,IAAA;AAAA,MACzB,CAAA,MAAA,IAAW,0BAAA,CAA2B,WAAW,CAAA,EAAG;AAChD,QAAA,IAAI,WAAA,CAAY,aAAa,IAAA,EAAM;AAC/B,UAAA,cAAA,CAAe,WAAA,GAAc,IAAA;AAAA,QACjC,CAAA,MAAO;AACH,UAAA,cAAA,CAAe,UAAA,CAAW,GAAA,CAAI,WAAA,CAAY,SAAS,CAAA;AAAA,QACvD;AAAA,MACJ,CAAA,MAAO;AACH,QAAA,MAAM,IAAI,KAAA,CAAM,OAAA,CAAQ,QAAA,EAAU,CAAA,+BAAA,CAAiC,CAAA;AAAA,MACvE;AAAA,IACJ;AACA,IAAA,KAAA,CAAM,GAAA,CAAI,aAAa,YAAY,CAAA;AAAA,EACvC;AACA,EAAA,OAAO,KAAA;AACX;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceLookup.js","sources":["ServiceLookup.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 { InterfaceSpec, isSingleImplementationSpec, ReferenceSpec } from \"./InterfaceSpec\";\nimport { ServiceRepr } from \"./ServiceRepr\";\n\ninterface Services {\n // The unqualified service implementations (if any).\n unqualified: ServiceRepr[];\n\n // Services indexed by their qualifier (if any).\n byQualifier: Map<string, ServiceRepr>;\n}\n\nexport type ReadonlyServiceLookup = Pick<\n ServiceLookup,\n \"lookup\" | \"lookupOne\" | \"lookupAll\" | \"serviceCount\"\n>;\n\nexport interface Unimplemented {\n type: \"unimplemented\";\n}\n\nexport interface Ambiguous {\n type: \"ambiguous\";\n choices: AmbiguousChoice[];\n}\n\nexport type AmbiguousChoice = [serviceId: string, qualifier: string | undefined];\n\nexport interface Found<T> {\n type: \"found\";\n value: T;\n}\n\nexport type ServiceLookupResult = Unimplemented | Ambiguous | Found<ServiceRepr>;\n\nexport type ServicesLookupResult = Found<ServiceRepr[]>;\n\nexport class ServiceLookup {\n // Service implementations indexed by interface name.\n private services = new Map<string, Services>();\n\n // Total service count\n private _count = 0;\n\n /**\n * Returns the total number of registered services.\n */\n get serviceCount() {\n return this._count;\n }\n\n /**\n * Attempts to register the given service as an implementation of `interfaceName`.\n * Throws if the registration did not complete successfully.\n *\n * All services should be registered before any lookups are attempted.\n */\n register(service: ServiceRepr, { interfaceName, qualifier }: InterfaceSpec): void {\n if (!interfaceName) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n `Service '${service.id}' provides invalid interface '${interfaceName}'.`\n );\n }\n if (qualifier != null && !qualifier) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n `Service '${service.id}' uses an invalid qualifier for interface '${interfaceName}': '${qualifier}'.`\n );\n }\n\n const services = this.ensureInterfaceEntry(interfaceName);\n if (!qualifier) {\n services.unqualified.push(service);\n ++this._count;\n return;\n }\n\n const existingQualified = services.byQualifier.get(qualifier);\n if (existingQualified) {\n throw new Error(\n ErrorId.DUPLICATE_INTERFACE,\n `Cannot register '${service.id}' as interface '${interfaceName}' with qualifier '${qualifier}'.` +\n ` The interface is already provided by service '${existingQualified.id}'.` +\n ` You can choose a different qualifier or remove the service to resolve the collision.`\n );\n }\n services.byQualifier.set(qualifier, service);\n ++this._count;\n }\n\n /**\n * Attempts to find the service(s) required by the given reference spec.\n */\n lookup(ref: ReferenceSpec): ServiceLookupResult | ServicesLookupResult {\n if (isSingleImplementationSpec(ref)) {\n return this.lookupOne(ref);\n } else {\n return this.lookupAll(ref.interfaceName);\n }\n }\n\n /**\n * Attempts to find a service implementing the given interface.\n */\n lookupOne({ interfaceName, qualifier }: InterfaceSpec): ServiceLookupResult {\n if (!interfaceName) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n `Invalid interface name during service lookup: '${interfaceName}'.`\n );\n }\n if (qualifier != null && !qualifier) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n `Invalid qualifier during service lookup of interface '${interfaceName}': '${qualifier}'.`\n );\n }\n\n const services = this.services.get(interfaceName);\n if (!services) {\n return { type: \"unimplemented\" };\n }\n\n if (!qualifier) {\n // Just pick one, but the choice must be unambiguous.\n const count = services.unqualified.length + services.byQualifier.size;\n if (count > 1) {\n // [serviceId, qualifier] tuples\n const choices: AmbiguousChoice[] = [];\n choices.push(\n ...Array.from(services.byQualifier.entries()).map<AmbiguousChoice>(\n ([qualifier, service]) => [service.id, qualifier]\n )\n );\n choices.push(\n ...services.unqualified.map<AmbiguousChoice>((s) => [s.id, undefined])\n );\n return {\n type: \"ambiguous\",\n choices: choices\n };\n }\n\n const service = services.unqualified[0] ?? first(services.byQualifier);\n if (!service) {\n return { type: \"unimplemented\" };\n }\n return { type: \"found\", value: service };\n }\n\n const service = services.byQualifier.get(qualifier);\n if (!service) {\n return { type: \"unimplemented\" };\n }\n return { type: \"found\", value: service };\n }\n\n /**\n * Returns all services implementing the given interface.\n */\n lookupAll(interfaceName: string): ServicesLookupResult {\n if (!interfaceName) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n `Invalid interface name during service lookup: '${interfaceName}'.`\n );\n }\n\n const services = this.services.get(interfaceName);\n if (!services) {\n return { type: \"found\", value: [] };\n }\n\n const deduped = new Set([...services.unqualified, ...services.byQualifier.values()]);\n return {\n type: \"found\",\n value: Array.from(deduped)\n };\n }\n\n private ensureInterfaceEntry(interfaceName: string): Services {\n const services = this.services;\n let entry = services.get(interfaceName);\n if (!entry) {\n entry = {\n unqualified: [],\n byQualifier: new Map()\n };\n services.set(interfaceName, entry);\n }\n return entry;\n }\n}\n\nexport function renderAmbiguousServiceChoices(choices: AmbiguousChoice[], max = 3): string {\n let message = \"\";\n let count = 0;\n for (const [serviceId, qualifier] of choices) {\n if (count) {\n message += \", \";\n }\n\n message += `'${serviceId}'`;\n if (qualifier) {\n message += ` (with qualifier '${qualifier}')`;\n }\n\n if (++count >= max) {\n break;\n }\n }\n\n const remaining = choices.length - count;\n if (remaining > 0) {\n message += ` and ${remaining} more`;\n }\n return message;\n}\n\nfunction first<K, V>(map: Map<K, V>): V | undefined {\n return map.values().next().value;\n}\n"],"names":["qualifier","service"],"mappings":";;;;AAwCO,MAAM,aAAc,CAAA;AAAA;AAAA,EAEf,QAAA,uBAAe,GAAsB,EAAA;AAAA;AAAA,EAGrC,MAAS,GAAA,CAAA;AAAA;AAAA;AAAA;AAAA,EAKjB,IAAI,YAAe,GAAA;AACf,IAAA,OAAO,IAAK,CAAA,MAAA;AAAA;AAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,QAAS,CAAA,OAAA,EAAsB,EAAE,aAAA,EAAe,WAAkC,EAAA;AAC9E,IAAA,IAAI,CAAC,aAAe,EAAA;AAChB,MAAA,MAAM,IAAI,KAAA;AAAA,QACN,OAAQ,CAAA,gBAAA;AAAA,QACR,CAAY,SAAA,EAAA,OAAA,CAAQ,EAAE,CAAA,8BAAA,EAAiC,aAAa,CAAA,EAAA;AAAA,OACxE;AAAA;AAEJ,IAAI,IAAA,SAAA,IAAa,IAAQ,IAAA,CAAC,SAAW,EAAA;AACjC,MAAA,MAAM,IAAI,KAAA;AAAA,QACN,OAAQ,CAAA,gBAAA;AAAA,QACR,YAAY,OAAQ,CAAA,EAAE,CAA8C,2CAAA,EAAA,aAAa,OAAO,SAAS,CAAA,EAAA;AAAA,OACrG;AAAA;AAGJ,IAAM,MAAA,QAAA,GAAW,IAAK,CAAA,oBAAA,CAAqB,aAAa,CAAA;AACxD,IAAA,IAAI,CAAC,SAAW,EAAA;AACZ,MAAS,QAAA,CAAA,WAAA,CAAY,KAAK,OAAO,CAAA;AACjC,MAAA,EAAE,IAAK,CAAA,MAAA;AACP,MAAA;AAAA;AAGJ,IAAA,MAAM,iBAAoB,GAAA,QAAA,CAAS,WAAY,CAAA,GAAA,CAAI,SAAS,CAAA;AAC5D,IAAA,IAAI,iBAAmB,EA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AS,CAAA,CAAA,CAAA;AACxB,IAAA,IAAI,SAAW,EAAA;AACX,MAAA,OAAA,IAAW,qBAAqB,SAAS,CAAA,EAAA,CAAA;AAAA;AAG7C,IAAI,IAAA,EAAE,SAAS,GAAK,EAAA;AAChB,MAAA;AAAA;AACJ;AAGJ,EAAM,MAAA,SAAA,GAAY,QAAQ,MAAS,GAAA,KAAA;AACnC,EAAA,IAAI,YAAY,CAAG,EAAA;AACf,IAAA,OAAA,IAAW,QAAQ,SAAS,CAAA,KAAA,CAAA;AAAA;AAEhC,EAAO,OAAA,OAAA;AACX;AAEA,SAAS,MAAY,GAA+B,EAAA;AAChD,EAAA,OAAO,GAAI,CAAA,MAAA,EAAS,CAAA,IAAA,EAAO,CAAA,KAAA;AAC/B;;;;"}
1
+ {"version":3,"file":"ServiceLookup.js","sources":["ServiceLookup.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 { InterfaceSpec, isSingleImplementationSpec, ReferenceSpec } from \"./InterfaceSpec\";\nimport { ServiceRepr } from \"./ServiceRepr\";\n\ninterface Services {\n // The unqualified service implementations (if any).\n unqualified: ServiceRepr[];\n\n // Services indexed by their qualifier (if any).\n byQualifier: Map<string, ServiceRepr>;\n}\n\nexport type ReadonlyServiceLookup = Pick<\n ServiceLookup,\n \"lookup\" | \"lookupOne\" | \"lookupAll\" | \"serviceCount\"\n>;\n\nexport interface Unimplemented {\n type: \"unimplemented\";\n}\n\nexport interface Ambiguous {\n type: \"ambiguous\";\n choices: AmbiguousChoice[];\n}\n\nexport type AmbiguousChoice = [serviceId: string, qualifier: string | undefined];\n\nexport interface Found<T> {\n type: \"found\";\n value: T;\n}\n\nexport type ServiceLookupResult = Unimplemented | Ambiguous | Found<ServiceRepr>;\n\nexport type ServicesLookupResult = Found<ServiceRepr[]>;\n\nexport class ServiceLookup {\n // Service implementations indexed by interface name.\n private services = new Map<string, Services>();\n\n // Total service count\n private _count = 0;\n\n /**\n * Returns the total number of registered services.\n */\n get serviceCount() {\n return this._count;\n }\n\n /**\n * Attempts to register the given service as an implementation of `interfaceName`.\n * Throws if the registration did not complete successfully.\n *\n * All services should be registered before any lookups are attempted.\n */\n register(service: ServiceRepr, { interfaceName, qualifier }: InterfaceSpec): void {\n if (!interfaceName) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n `Service '${service.id}' provides invalid interface '${interfaceName}'.`\n );\n }\n if (qualifier != null && !qualifier) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n `Service '${service.id}' uses an invalid qualifier for interface '${interfaceName}': '${qualifier}'.`\n );\n }\n\n const services = this.ensureInterfaceEntry(interfaceName);\n if (!qualifier) {\n services.unqualified.push(service);\n ++this._count;\n return;\n }\n\n const existingQualified = services.byQualifier.get(qualifier);\n if (existingQualified) {\n throw new Error(\n ErrorId.DUPLICATE_INTERFACE,\n `Cannot register '${service.id}' as interface '${interfaceName}' with qualifier '${qualifier}'.` +\n ` The interface is already provided by service '${existingQualified.id}'.` +\n ` You can choose a different qualifier or remove the service to resolve the collision.`\n );\n }\n services.byQualifier.set(qualifier, service);\n ++this._count;\n }\n\n /**\n * Attempts to find the service(s) required by the given reference spec.\n */\n lookup(ref: ReferenceSpec): ServiceLookupResult | ServicesLookupResult {\n if (isSingleImplementationSpec(ref)) {\n return this.lookupOne(ref);\n } else {\n return this.lookupAll(ref.interfaceName);\n }\n }\n\n /**\n * Attempts to find a service implementing the given interface.\n */\n lookupOne({ interfaceName, qualifier }: InterfaceSpec): ServiceLookupResult {\n if (!interfaceName) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n `Invalid interface name during service lookup: '${interfaceName}'.`\n );\n }\n if (qualifier != null && !qualifier) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n `Invalid qualifier during service lookup of interface '${interfaceName}': '${qualifier}'.`\n );\n }\n\n const services = this.services.get(interfaceName);\n if (!services) {\n return { type: \"unimplemented\" };\n }\n\n if (!qualifier) {\n // Just pick one, but the choice must be unambiguous.\n const count = services.unqualified.length + services.byQualifier.size;\n if (count > 1) {\n // [serviceId, qualifier] tuples\n const choices: AmbiguousChoice[] = [];\n choices.push(\n ...Array.from(services.byQualifier.entries()).map<AmbiguousChoice>(\n ([qualifier, service]) => [service.id, qualifier]\n )\n );\n choices.push(\n ...services.unqualified.map<AmbiguousChoice>((s) => [s.id, undefined])\n );\n return {\n type: \"ambiguous\",\n choices: choices\n };\n }\n\n const service = services.unqualified[0] ?? first(services.byQualifier);\n if (!service) {\n return { type: \"unimplemented\" };\n }\n return { type: \"found\", value: service };\n }\n\n const service = services.byQualifier.get(qualifier);\n if (!service) {\n return { type: \"unimplemented\" };\n }\n return { type: \"found\", value: service };\n }\n\n /**\n * Returns all services implementing the given interface.\n */\n lookupAll(interfaceName: string): ServicesLookupResult {\n if (!interfaceName) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n `Invalid interface name during service lookup: '${interfaceName}'.`\n );\n }\n\n const services = this.services.get(interfaceName);\n if (!services) {\n return { type: \"found\", value: [] };\n }\n\n const deduped = new Set([...services.unqualified, ...services.byQualifier.values()]);\n return {\n type: \"found\",\n value: Array.from(deduped)\n };\n }\n\n private ensureInterfaceEntry(interfaceName: string): Services {\n const services = this.services;\n let entry = services.get(interfaceName);\n if (!entry) {\n entry = {\n unqualified: [],\n byQualifier: new Map()\n };\n services.set(interfaceName, entry);\n }\n return entry;\n }\n}\n\nexport function renderAmbiguousServiceChoices(choices: AmbiguousChoice[], max = 3): string {\n let message = \"\";\n let count = 0;\n for (const [serviceId, qualifier] of choices) {\n if (count) {\n message += \", \";\n }\n\n message += `'${serviceId}'`;\n if (qualifier) {\n message += ` (with qualifier '${qualifier}')`;\n }\n\n if (++count >= max) {\n break;\n }\n }\n\n const remaining = choices.length - count;\n if (remaining > 0) {\n message += ` and ${remaining} more`;\n }\n return message;\n}\n\nfunction first<K, V>(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W,IAAI,SAAS,CAAA,CAAA,CAAA;AACxB,IAAA,IAAI,SAAA,EAAW;AACX,MAAA,OAAA,IAAW,qBAAqB,SAAS,CAAA,EAAA,CAAA;AAAA,IAC7C;AAEA,IAAA,IAAI,EAAE,SAAS,GAAA,EAAK;AAChB,MAAA;AAAA,IACJ;AAAA,EACJ;AAEA,EAAA,MAAM,SAAA,GAAY,QAAQ,MAAA,GAAS,KAAA;AACnC,EAAA,IAAI,YAAY,CAAA,EAAG;AACf,IAAA,OAAA,IAAW,QAAQ,SAAS,CAAA,KAAA,CAAA;AAAA,EAChC;AACA,EAAA,OAAO,OAAA;AACX;AAEA,SAAS,MAAY,GAAA,EAA+B;AAChD,EAAA,OAAO,GAAA,CAAI,MAAA,EAAO,CAAE,IAAA,EAAK,CAAE,KAAA;AAC/B;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceRepr.js","sources":["ServiceRepr.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ErrorId } from \"../errors\";\nimport { ServiceMetadata } from \"../metadata\";\nimport { Service, ServiceConstructor, ServiceOptions } from \"../Service\";\nimport { Error } from \"@open-pioneer/core\";\nimport { InterfaceSpec, parseReferenceSpec, ReferenceSpec } from \"./InterfaceSpec\";\nimport { PackageIntl } from \"../i18n\";\n\nexport type ServiceState = \"not-constructed\" | \"constructing\" | \"constructed\" | \"destroyed\";\n\nexport type ServiceDependency = ReferenceSpec & { referenceName: string };\n\nexport interface ConstructorFactory {\n type: \"class\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n clazz: ServiceConstructor<any>;\n}\n\nexport interface FunctionFactory {\n type: \"function\";\n create: (options: ServiceOptions) => Service;\n}\n\nexport type ServiceFactory = ConstructorFactory | FunctionFactory;\n\nexport interface ServiceReprOptions {\n name: string;\n packageName: string;\n factory: ServiceFactory;\n intl: PackageIntl;\n dependencies?: ServiceDependency[];\n interfaces?: InterfaceSpec[];\n properties?: Record<string, unknown>;\n}\n\n/**\n * Represents metadata and state of a service in the runtime.\n * `this.instance` is the actual service instance (when constructed).\n */\nexport class ServiceRepr {\n static create(\n packageName: string,\n data: ServiceMetadata,\n intl: PackageIntl,\n properties?: Record<string, unknown>\n ): ServiceRepr {\n const clazz = data.clazz;\n const name = data.name;\n const dependencies = Object.entries(data.references ?? {}).map(\n ([name, referenceMetadata]) => {\n return {\n referenceName: name,\n ...parseReferenceSpec(referenceMetadata)\n };\n }\n );\n const interfaces = data.provides?.map<InterfaceSpec>((i) => {\n return {\n interfaceName: i.name,\n qualifier: i.qualifier\n };\n });\n const factory: ConstructorFactory = {\n type: \"class\",\n clazz\n };\n return new ServiceRepr({\n name,\n packageName,\n factory,\n intl,\n dependencies,\n interfaces,\n properties\n });\n }\n\n /** Unique id of this service. Contains the package name and the service name. */\n readonly id: string;\n\n /** Name of this service in it's package. */\n readonly name: string;\n\n /** Name of the parent package. */\n readonly packageName: string;\n\n /** Locale-dependant i18n messages. */\n readonly intl: PackageIntl;\n\n /** Service properties made available via the service's constructor. */\n readonly properties: Readonly<Record<string, unknown>>;\n\n /** Dependencies required by the service constructor. */\n readonly dependencies: readonly ServiceDependency[];\n\n /** Interfaces provided by the service. */\n readonly interfaces: readonly Readonly<InterfaceSpec>[];\n\n /** Number of references to this service. */\n private _useCount = 0;\n\n /** Service factory to construct an instance. */\n private factory: ServiceFactory;\n\n /** Current state of this service. \"constructed\" -> instance is available. */\n private _state: ServiceState = \"not-constructed\";\n\n /** Service instance, once constructed. */\n private _instance: Service | undefined = undefined;\n\n constructor(options: ServiceReprOptions) {\n const {\n name,\n packageName,\n factory,\n intl,\n dependencies = [],\n interfaces = [],\n properties = {}\n } = options;\n if (!isValidServiceName(name)) {\n throw new Error(ErrorId.INTERNAL, `Invalid service name: '${name}'.`);\n }\n\n this.id = `${packageName}::${name}`;\n this.name = name;\n this.packageName = packageName;\n this.factory = factory;\n this.intl = intl;\n this.dependencies = dependencies;\n this.interfaces = interfaces;\n this.properties = properties;\n }\n\n /** Returns the current service instance or undefined if the service has not been constructed. */\n get instance(): Service | undefined {\n return this._instance;\n }\n\n /** Returns the current state of the service. */\n get state() {\n return this._state;\n }\n\n /** Returns the current reference count. */\n get useCount() {\n return this._useCount;\n }\n\n /**\n * Same as `instance`, but throws when the instance has not been constructed.\n */\n getInstanceOrThrow() {\n const instance = this._instance;\n if (!instance) {\n throw new Error(ErrorId.INTERNAL, \"Expected service instance to be present.\");\n }\n return instance;\n }\n\n /**\n * Called before `create()` to place the service into the `constructing` state,\n * which is currently used to detect cycles.\n */\n beforeCreate() {\n if (this._state === \"not-constructed\") {\n this._state = \"constructing\";\n } else {\n throw new Error(\n ErrorId.INTERNAL,\n \"Inconsistent state: service is already under construction.\"\n );\n }\n }\n\n /**\n * Instantiates the service by invoking the service constructor\n * with the given `options`.\n *\n * The service's use count is initialized to `1`, so every `create()`\n * should be paired with a `removeRef()`.\n *\n * `destroy()` can be invoked once the final `removeRef()` has returned zero.\n */\n create(options: Pick<ServiceOptions, \"references\" | \"referencesMeta\">) {\n if (this._state !== \"constructing\" || this.instance !== undefined) {\n throw new Error(\n ErrorId.INTERNAL,\n \"Inconsistent state: service is not being constructed.\"\n );\n }\n try {\n this._instance = createService(this.factory, {\n ...options,\n properties: this.properties,\n intl: this.intl\n });\n this._state = \"constructed\";\n this._useCount = 1;\n return this._instance;\n } catch (e) {\n throw new Error(\n ErrorId.SERVICE_CONSTRUCTION_FAILED,\n `Failed to create service instance '${this.id}'.`,\n { cause: e }\n );\n }\n }\n\n destroy() {\n if (this._instance) {\n try {\n this._instance.destroy?.();\n } catch (e) {\n throw new Error(\n ErrorId.SERVICE_DESTRUCTION_FAILED,\n `Failed to destroy service instance '${this.id}'.`,\n { cause: e }\n );\n }\n }\n this._instance = undefined;\n this._state = \"destroyed\";\n }\n\n /**\n * Adds a use to the service's use count.\n * References to a service are tracked: it should only be destroyed when it is no longer being used.\n */\n addRef() {\n return (this._useCount += 1);\n }\n\n /**\n * Removes a use from the service's use count.\n * Returns the new use count.\n */\n removeRef() {\n return (this._useCount -= 1);\n }\n}\n\nexport function createConstructorFactory<T extends {}>(\n clazz: ServiceConstructor<T>\n): ConstructorFactory {\n return { type: \"class\", clazz };\n}\n\nexport function createFunctionFactory(\n create: (options: ServiceOptions) => Service\n): FunctionFactory {\n return { type: \"function\", create };\n}\n\nconst SERVICE_NAME_REGEX = /^[a-z0-9_-]+$/i;\n\nfunction isValidServiceName(name: string) {\n return SERVICE_NAME_REGEX.test(name);\n}\n\nfunction createService(factory: ServiceFactory, options: ServiceOptions) {\n switch (factory.type) {\n case \"class\":\n return new factory.clazz(options);\n case \"function\":\n return factory.create(options);\n }\n}\n"],"names":["name"],"mappings":";;;;AAwCO,MAAM,WAAY,CAAA;AAAA,EACrB,OAAO,MAAA,CACH,WACA,EAAA,IAAA,EACA,MACA,UACW,EAAA;AACX,IAAA,MAAM,QAAQ,IAAK,CAAA,KAAA;AACnB,IAAA,MAAM,OAAO,IAAK,CAAA,IAAA;AAClB,IAAA,MAAM,eAAe,MAAO,CAAA,OAAA,CAAQ,KAAK,UAAc,IAAA,EAAE,CAAE,CAAA,GAAA;AAAA,MACvD,CAAC,CAACA,KAAM,EAAA,iBAAiB,CAAM,KAAA;AAC3B,QAAO,OAAA;AAAA,UACH,aAAeA,EAAAA,KAAAA;AAAA,UACf,GAAG,mBAAmB,iBAAiB;AAAA,SAC3C;AAAA;AACJ,KACJ;AACA,IAAA,MAAM,UAAa,GAAA,IAAA,CAAK,QAAU,EAAA,GAAA,CAAmB,CAAC,CAAM,KAAA;AACxD,MAAO,OAAA;AAAA,QACH,eAAe,CAAE,CAAA,IAAA;AAAA,QACjB,WAAW,CAAE,CAAA;AAAA,OACjB;AAAA,KACH,CAAA;AACD,IAAA,MAAM,OAA8B,GAAA;AAAA,MAChC,IAAM,EAAA,OAAA;AAAA,MACN;AAAA,KACJ;AACA,IAAA,OAAO,IAAI,WAAY,CA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,QAAQ,IAAM;AAAA,IAClB,KAAK,OAAA;AACD,MAAO,OAAA,IAAI,OAAQ,CAAA,KAAA,CAAM,OAAO,CAAA;AAAA,IACpC,KAAK,UAAA;AACD,MAAO,OAAA,OAAA,CAAQ,OAAO,OAAO,CAAA;AAAA;AAEzC;;;;"}
1
+ {"version":3,"file":"ServiceRepr.js","sources":["ServiceRepr.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ErrorId } from \"../errors\";\nimport { ServiceMetadata } from \"../metadata\";\nimport { Service, ServiceConstructor, ServiceOptions } from \"../Service\";\nimport { Error } from \"@open-pioneer/core\";\nimport { InterfaceSpec, parseReferenceSpec, ReferenceSpec } from \"./InterfaceSpec\";\nimport { PackageIntl } from \"../i18n\";\n\nexport type ServiceState = \"not-constructed\" | \"constructing\" | \"constructed\" | \"destroyed\";\n\nexport type ServiceDependency = ReferenceSpec & { referenceName: string };\n\nexport interface ConstructorFactory {\n type: \"class\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n clazz: ServiceConstructor<any>;\n}\n\nexport interface FunctionFactory {\n type: \"function\";\n create: (options: ServiceOptions) => Service;\n}\n\nexport type ServiceFactory = ConstructorFactory | FunctionFactory;\n\nexport interface ServiceReprOptions {\n name: string;\n packageName: string;\n factory: ServiceFactory;\n intl: PackageIntl;\n dependencies?: ServiceDependency[];\n interfaces?: InterfaceSpec[];\n properties?: Record<string, unknown>;\n}\n\n/**\n * Represents metadata and state of a service in the runtime.\n * `this.instance` is the actual service instance (when constructed).\n */\nexport class ServiceRepr {\n static create(\n packageName: string,\n data: ServiceMetadata,\n intl: PackageIntl,\n properties?: Record<string, unknown>\n ): ServiceRepr {\n const clazz = data.clazz;\n const name = data.name;\n const dependencies = Object.entries(data.references ?? {}).map(\n ([name, referenceMetadata]) => {\n return {\n referenceName: name,\n ...parseReferenceSpec(referenceMetadata)\n };\n }\n );\n const interfaces = data.provides?.map<InterfaceSpec>((i) => {\n return {\n interfaceName: i.name,\n qualifier: i.qualifier\n };\n });\n const factory: ConstructorFactory = {\n type: \"class\",\n clazz\n };\n return new ServiceRepr({\n name,\n packageName,\n factory,\n intl,\n dependencies,\n interfaces,\n properties\n });\n }\n\n /** Unique id of this service. Contains the package name and the service name. */\n readonly id: string;\n\n /** Name of this service in it's package. */\n readonly name: string;\n\n /** Name of the parent package. */\n readonly packageName: string;\n\n /** Locale-dependant i18n messages. */\n readonly intl: PackageIntl;\n\n /** Service properties made available via the service's constructor. */\n readonly properties: Readonly<Record<string, unknown>>;\n\n /** Dependencies required by the service constructor. */\n readonly dependencies: readonly ServiceDependency[];\n\n /** Interfaces provided by the service. */\n readonly interfaces: readonly Readonly<InterfaceSpec>[];\n\n /** Number of references to this service. */\n private _useCount = 0;\n\n /** Service factory to construct an instance. */\n private factory: ServiceFactory;\n\n /** Current state of this service. \"constructed\" -> instance is available. */\n private _state: ServiceState = \"not-constructed\";\n\n /** Service instance, once constructed. */\n private _instance: Service | undefined = undefined;\n\n constructor(options: ServiceReprOptions) {\n const {\n name,\n packageName,\n factory,\n intl,\n dependencies = [],\n interfaces = [],\n properties = {}\n } = options;\n if (!isValidServiceName(name)) {\n throw new Error(ErrorId.INTERNAL, `Invalid service name: '${name}'.`);\n }\n\n this.id = `${packageName}::${name}`;\n this.name = name;\n this.packageName = packageName;\n this.factory = factory;\n this.intl = intl;\n this.dependencies = dependencies;\n this.interfaces = interfaces;\n this.properties = properties;\n }\n\n /** Returns the current service instance or undefined if the service has not been constructed. */\n get instance(): Service | undefined {\n return this._instance;\n }\n\n /** Returns the current state of the service. */\n get state() {\n return this._state;\n }\n\n /** Returns the current reference count. */\n get useCount() {\n return this._useCount;\n }\n\n /**\n * Same as `instance`, but throws when the instance has not been constructed.\n */\n getInstanceOrThrow() {\n const instance = this._instance;\n if (!instance) {\n throw new Error(ErrorId.INTERNAL, \"Expected service instance to be present.\");\n }\n return instance;\n }\n\n /**\n * Called before `create()` to place the service into the `constructing` state,\n * which is currently used to detect cycles.\n */\n beforeCreate() {\n if (this._state === \"not-constructed\") {\n this._state = \"constructing\";\n } else {\n throw new Error(\n ErrorId.INTERNAL,\n \"Inconsistent state: service is already under construction.\"\n );\n }\n }\n\n /**\n * Instantiates the service by invoking the service constructor\n * with the given `options`.\n *\n * The service's use count is initialized to `1`, so every `create()`\n * should be paired with a `removeRef()`.\n *\n * `destroy()` can be invoked once the final `removeRef()` has returned zero.\n */\n create(options: Pick<ServiceOptions, \"references\" | \"referencesMeta\">) {\n if (this._state !== \"constructing\" || this.instance !== undefined) {\n throw new Error(\n ErrorId.INTERNAL,\n \"Inconsistent state: service is not being constructed.\"\n );\n }\n try {\n this._instance = createService(this.factory, {\n ...options,\n properties: this.properties,\n intl: this.intl\n });\n this._state = \"constructed\";\n this._useCount = 1;\n return this._instance;\n } catch (e) {\n throw new Error(\n ErrorId.SERVICE_CONSTRUCTION_FAILED,\n `Failed to create service instance '${this.id}'.`,\n { cause: e }\n );\n }\n }\n\n destroy() {\n if (this._instance) {\n try {\n this._instance.destroy?.();\n } catch (e) {\n throw new Error(\n ErrorId.SERVICE_DESTRUCTION_FAILED,\n `Failed to destroy service instance '${this.id}'.`,\n { cause: e }\n );\n }\n }\n this._instance = undefined;\n this._state = \"destroyed\";\n }\n\n /**\n * Adds a use to the service's use count.\n * References to a service are tracked: it should only be destroyed when it is no longer being used.\n */\n addRef() {\n return (this._useCount += 1);\n }\n\n /**\n * Removes a use from the service's use count.\n * Returns the new use count.\n */\n removeRef() {\n return (this._useCount -= 1);\n }\n}\n\nexport function createConstructorFactory<T extends {}>(\n clazz: ServiceConstructor<T>\n): ConstructorFactory {\n return { type: \"class\", clazz };\n}\n\nexport function createFunctionFactory(\n create: (options: ServiceOptions) => Service\n): FunctionFactory {\n return { type: \"function\", create };\n}\n\nconst SERVICE_NAME_REGEX = /^[a-z0-9_-]+$/i;\n\nfunction isValidServiceName(name: string) {\n return SERVICE_NAME_REGEX.test(name);\n}\n\nfunction createService(factory: ServiceFactory, options: ServiceOptions) {\n switch (factory.type) {\n case \"class\":\n return new factory.clazz(options);\n case \"function\":\n return factory.create(options);\n }\n}\n"],"names":["name"],"mappings":";;;;AAwCO,MAAM,WAAA,CAAY;AAAA,EACrB,OAAO,MAAA,CACH,WAAA,EACA,IAAA,EACA,MACA,UAAA,EACW;AACX,IAAA,MAAM,QAAQ,IAAA,CAAK,KAAA;AACnB,IAAA,MAAM,OAAO,IAAA,CAAK,IAAA;AAClB,IAAA,MAAM,eAAe,MAAA,CAAO,OAAA,CAAQ,KAAK,UAAA,IAAc,EAAE,CAAA,CAAE,GAAA;AAAA,MACvD,CAAC,CAACA,KAAAA,EAAM,iBAAiB,CAAA,KAAM;AAC3B,QAAA,OAAO;AAAA,UACH,aAAA,EAAeA,KAAAA;AAAA,UACf,GAAG,mBAAmB,iBAAiB;AAAA,SAC3C;AAAA,MACJ;AAAA,KACJ;AACA,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,QAAA,EAAU,GAAA,CAAmB,CAAC,CAAA,KAAM;AACxD,MAAA,OAAO;AAAA,QACH,eAAe,CAAA,CAAE,IAAA;AAAA,QACjB,WAAW,CAAA,CAAE;AAAA,OACjB;AAAA,IACJ,CAAC,CAAA;AACD,IAAA,MAAM,OAAA,GAA8B;AAAA,MAChC,IAAA,EAAM,OAAA;AAAA,MACN;AAAA,KACJ;AACA,IAAA,OAAO,IAAI,WAAA,CAAY;AAAA,MACnB,IAAA;AAAA,MACA,WAAA;AAAA,MACA,OAAA;AAAA,MACA,IAAA;AAAA,MACA,YAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACH,CAAA;AAAA,EACL;AAAA;AAAA,EAGS,EAAA;AAAA;AAAA,EAGA,IAAA;AAAA;AAAA,EAGA,WAAA;AAAA;AAAA,EAGA,IAAA;AAAA;AAAA,EAGA,UAAA;AAAA;AAAA,EAGA,YAAA;AAAA;AAAA,EAGA,UAAA;AAAA;AA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