@open-pioneer/runtime 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/CustomElement.d.ts +111 -0
  3. package/CustomElement.js.map +1 -1
  4. package/PropertiesRegistry.d.ts +19 -0
  5. package/Service.d.ts +63 -0
  6. package/ServiceRegistry.d.ts +25 -0
  7. package/api.d.ts +76 -0
  8. package/builtin-services/ApiServiceImpl.d.ts +11 -0
  9. package/builtin-services/ApiServiceImpl.js.map +1 -1
  10. package/builtin-services/ApplicationContextImpl.d.ts +18 -0
  11. package/builtin-services/ApplicationContextImpl.js.map +1 -1
  12. package/builtin-services/ApplicationLifecycleEventService.d.ts +12 -0
  13. package/builtin-services/ApplicationLifecycleEventService.js.map +1 -1
  14. package/builtin-services/index.d.ts +20 -0
  15. package/builtin-services/index.js.map +1 -1
  16. package/errors.d.ts +17 -0
  17. package/errors.js.map +1 -1
  18. package/i18n.d.ts +42 -0
  19. package/i18n.js.map +1 -1
  20. package/index.d.ts +6 -0
  21. package/metadata/ObservableBox.d.ts +23 -0
  22. package/metadata/ObservableBox.js.map +1 -1
  23. package/metadata/index.d.ts +115 -0
  24. package/package.json +9 -6
  25. package/react-integration/PackageContext.d.ts +11 -0
  26. package/react-integration/PackageContext.js.map +1 -1
  27. package/react-integration/ReactIntegration.d.ts +20 -0
  28. package/react-integration/ReactIntegration.js.map +1 -1
  29. package/react-integration/hooks.d.ts +46 -0
  30. package/react-integration/hooks.js.map +1 -1
  31. package/react-integration/index.d.ts +2 -0
  32. package/service-layer/InterfaceSpec.d.ts +22 -0
  33. package/service-layer/InterfaceSpec.js.map +1 -1
  34. package/service-layer/PackageRepr.d.ts +27 -0
  35. package/service-layer/PackageRepr.js.map +1 -1
  36. package/service-layer/ServiceLayer.d.ts +61 -0
  37. package/service-layer/ServiceLayer.js.map +1 -1
  38. package/service-layer/ServiceLookup.d.ts +46 -0
  39. package/service-layer/ServiceLookup.js.map +1 -1
  40. package/service-layer/ServiceRepr.d.ts +94 -0
  41. package/service-layer/ServiceRepr.js.map +1 -1
  42. package/service-layer/verifyDependencies.d.ts +42 -0
  43. package/service-layer/verifyDependencies.js.map +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @open-pioneer/runtime
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - a40f12d: Update build-package tool. TypeScript declaration files should now be available.
8
+ - Updated dependencies [a40f12d]
9
+ - @open-pioneer/chakra-integration@0.1.2
10
+ - @open-pioneer/core@0.1.2
11
+
12
+ ## 0.1.1
13
+
14
+ ### Patch Changes
15
+
16
+ - e1c7295: Compiled with build-package 0.5.2
17
+ - Updated dependencies [e1c7295]
18
+ - @open-pioneer/chakra-integration@0.1.1
19
+ - @open-pioneer/core@0.1.1
20
+
3
21
  ## 0.1.0
4
22
 
5
23
  ### Minor Changes
@@ -0,0 +1,111 @@
1
+ import { ComponentType } from "react";
2
+ import { ApplicationMetadata } from "./metadata";
3
+ import { ApiMethods } from "./api";
4
+ import { PropertiesRegistry } from "./PropertiesRegistry";
5
+ /**
6
+ * Options for the {@link createCustomElement} function.
7
+ */
8
+ export interface CustomElementOptions {
9
+ /**
10
+ * Rendered UI component.
11
+ */
12
+ component?: ComponentType<Record<string, string>>;
13
+ /**
14
+ * Application metadata (packages, services etc.).
15
+ * This is usually autogenerated by importing the virtual `"open-pioneer:app"` module.
16
+ */
17
+ appMetadata?: ApplicationMetadata;
18
+ /**
19
+ * Application defined configuration.
20
+ * All instances of the web component will share this static configuration.
21
+ *
22
+ * These will override default properties of the application's packages.
23
+ */
24
+ config?: ApplicationConfig;
25
+ /**
26
+ * Function to provide additional application defined configuration parameters.
27
+ *
28
+ * Compared to {@link config}, this function receives a context object
29
+ * that allows the developer to provide dynamic properties on a per-application basis.
30
+ *
31
+ * Parameters returned by this function take precedence over the ones defined by {@link config}.
32
+ */
33
+ resolveConfig?(ctx: ConfigContext): Promise<ApplicationConfig | undefined>;
34
+ /**
35
+ * Whether the shadow root element is accessible from the outside.
36
+ * Defaults to `false` in production mode and `true` during development to make testing easier.
37
+ */
38
+ openShadowRoot?: boolean;
39
+ }
40
+ /**
41
+ * A context object that is passed to the `resolveProperties` function.
42
+ */
43
+ export interface ConfigContext {
44
+ /**
45
+ * Returns an attribute from the application's root node.
46
+ */
47
+ getAttribute(name: string): string | undefined;
48
+ }
49
+ /**
50
+ * Runtime application configuration.
51
+ */
52
+ export interface ApplicationConfig {
53
+ /**
54
+ * Set this value to a locale string (e.g. "en") to for the application's locale.
55
+ * The default behavior is to choose an appropriate locale for the current user based
56
+ * on the browser's settings.
57
+ *
58
+ * The locale must be supported by the application.
59
+ */
60
+ locale?: string | undefined;
61
+ /**
62
+ * Properties specified here will override default properties of the application's packages.
63
+ */
64
+ properties?: ApplicationProperties | undefined;
65
+ }
66
+ /**
67
+ * Allows the application to override default properties in all packages.
68
+ */
69
+ export interface RawApplicationProperties {
70
+ /**
71
+ * Key: the name of the package.
72
+ * Value: A record of configuration properties (key/value pairs).
73
+ *
74
+ * Properties will override default property values in the package.
75
+ */
76
+ [packageName: string]: Record<string, unknown>;
77
+ }
78
+ /**
79
+ * Allows the application to override default properties in all packages.
80
+ *
81
+ * Properties are typed when the package contains type definitions for them.
82
+ */
83
+ export type ApplicationProperties = RawApplicationProperties & Partial<PropertiesRegistry>;
84
+ /**
85
+ * The interface implemented by web components produced via {@link createCustomElement}.
86
+ */
87
+ export interface ApplicationElement extends HTMLElement {
88
+ /** Resolves to the element's API when the application has started. */
89
+ when(): Promise<ApiMethods>;
90
+ }
91
+ /**
92
+ * The class returned by a call to {@link createCustomElement}.
93
+ */
94
+ export interface ApplicationElementConstructor {
95
+ new (): ApplicationElement;
96
+ }
97
+ /**
98
+ * Creates a new custom element class (web component) that can be registered within a DOM.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * import * as appMetadata from "open-pioneer:app";
103
+ *
104
+ * const CustomElementClazz = createCustomElement({
105
+ * component: <div>Hello World!</div>,
106
+ * appMetadata
107
+ * });
108
+ * customElements.define("sample-element", CustomElementClazz);
109
+ * ```
110
+ */
111
+ export declare function createCustomElement(options: CustomElementOptions): ApplicationElementConstructor;
@@ -1 +1 @@
1
- {"version":3,"file":"CustomElement.js","sources":["open-pioneer://external-pioneer-packages/@open-pioneer/runtime/CustomElement.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { ComponentType } from \"react\";\nimport {\n createAbortError,\n createLogger,\n createManualPromise,\n destroyResource,\n Error,\n isAbortError,\n ManualPromise,\n Resource,\n throwAbortError\n} from \"@open-pioneer/core\";\nimport { ErrorId } from \"./errors\";\nimport { ApplicationMetadata, PackageMetadata } from \"./metadata\";\nimport { PackageRepr, createPackages } from \"./service-layer/PackageRepr\";\nimport { ServiceLayer } from \"./service-layer/ServiceLayer\";\nimport { getErrorChain } from \"@open-pioneer/core\";\nimport { ReactIntegration } from \"./react-integration/ReactIntegration\";\nimport { ApiMethods, ApiService } from \"./api\";\nimport {\n createBuiltinPackage,\n RUNTIME_API_SERVICE,\n RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE,\n RUNTIME_AUTO_START\n} from \"./builtin-services\";\nimport { ReferenceSpec } from \"./service-layer/InterfaceSpec\";\nimport { PropertiesRegistry } from \"./PropertiesRegistry\";\nimport { AppI18n, initI18n } from \"./i18n\";\nimport { ApplicationLifecycleEventService } from \"./builtin-services/ApplicationLifecycleEventService\";\nconst LOG = createLogger(\"runtime:CustomElement\");\n\n/**\n * Options for the {@link createCustomElement} function.\n */\nexport interface CustomElementOptions {\n /**\n * Rendered UI component.\n */\n component?: ComponentType<Record<string, string>>;\n\n /**\n * Application metadata (packages, services etc.).\n * This is usually autogenerated by importing the virtual `\"open-pioneer:app\"` module.\n */\n appMetadata?: ApplicationMetadata;\n\n /**\n * Application defined configuration.\n * All instances of the web component will share this static configuration.\n *\n * These will override default properties of the application's packages.\n */\n config?: ApplicationConfig;\n\n /**\n * Function to provide additional application defined configuration parameters.\n *\n * Compared to {@link config}, this function receives a context object\n * that allows the developer to provide dynamic properties on a per-application basis.\n *\n * Parameters returned by this function take precedence over the ones defined by {@link config}.\n */\n resolveConfig?(ctx: ConfigContext): Promise<ApplicationConfig | undefined>;\n\n /**\n * Whether the shadow root element is accessible from the outside.\n * Defaults to `false` in production mode and `true` during development to make testing easier.\n */\n openShadowRoot?: boolean;\n}\n\n/**\n * A context object that is passed to the `resolveProperties` function.\n */\nexport interface ConfigContext {\n /**\n * Returns an attribute from the application's root node.\n */\n getAttribute(name: string): string | undefined;\n}\n\n/**\n * Runtime application configuration.\n */\nexport interface ApplicationConfig {\n /**\n * Set this value to a locale string (e.g. \"en\") to for the application's locale.\n * The default behavior is to choose an appropriate locale for the current user based\n * on the browser's settings.\n *\n * The locale must be supported by the application.\n */\n locale?: string | undefined;\n\n /**\n * Properties specified here will override default properties of the application's packages.\n */\n properties?: ApplicationProperties | undefined;\n}\n\n/**\n * Allows the application to override default properties in all packages.\n */\nexport interface RawApplicationProperties {\n /**\n * Key: the name of the package.\n * Value: A record of configuration properties (key/value pairs).\n *\n * Properties will override default property values in the package.\n */\n [packageName: string]: Record<string, unknown>;\n}\n\n/**\n * Allows the application to override default properties in all packages.\n *\n * Properties are typed when the package contains type definitions for them.\n */\nexport type ApplicationProperties = RawApplicationProperties & Partial<PropertiesRegistry>;\n\n/**\n * The interface implemented by web components produced via {@link createCustomElement}.\n */\nexport interface ApplicationElement extends HTMLElement {\n /** Resolves to the element's API when the application has started. */\n when(): Promise<ApiMethods>;\n}\n\n/**\n * The class returned by a call to {@link createCustomElement}.\n */\nexport interface ApplicationElementConstructor {\n new (): ApplicationElement;\n}\n\n/**\n * Creates a new custom element class (web component) that can be registered within a DOM.\n *\n * @example\n * ```ts\n * import * as appMetadata from \"open-pioneer:app\";\n *\n * const CustomElementClazz = createCustomElement({\n * component: <div>Hello World!</div>,\n * appMetadata\n * });\n * customElements.define(\"sample-element\", CustomElementClazz);\n * ```\n */\nexport function createCustomElement(options: CustomElementOptions): ApplicationElementConstructor {\n class PioneerApplication extends HTMLElement implements ApplicationElement {\n #shadowRoot: ShadowRoot;\n #state: ElementState | undefined;\n\n static get observedAttributes(): string[] {\n return [];\n }\n\n constructor() {\n super();\n\n const mode = options.openShadowRoot ?? import.meta.env.DEV ? \"open\" : \"closed\";\n this.#shadowRoot = this.attachShadow({\n mode: mode\n });\n\n if (import.meta.env.DEV) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this as any).$inspectElementState = () => this.#state;\n }\n }\n\n connectedCallback() {\n LOG.debug(\"Launching application\");\n\n if (this.#state) {\n this.#state.destroy();\n }\n\n this.#state = new ElementState(this, this.#shadowRoot, options);\n this.#state.start();\n }\n\n disconnectedCallback() {\n LOG.debug(\"Shutting down application\");\n\n this.#state?.destroy();\n this.#state = undefined;\n\n LOG.debug(\"Application destroyed\");\n }\n\n when() {\n if (!this.#state) {\n return Promise.reject(\n new Error(\n ErrorId.NOT_MOUNTED,\n \"Cannot use the application's API because the HTML element has not yet been mounted into the DOM.\"\n )\n );\n }\n\n return this.#state.whenAPI();\n }\n }\n return PioneerApplication;\n}\n\nclass ElementState {\n private hostElement: HTMLElement;\n private shadowRoot: ShadowRoot;\n private options: CustomElementOptions;\n\n // Public API\n private apiPromise: ManualPromise<ApiMethods> | undefined; // Present when callers are waiting for the API\n private api: ApiMethods | undefined; // Present once started\n\n private state = \"not-started\" as \"not-started\" | \"starting\" | \"started\" | \"destroyed\";\n private locale: string | undefined;\n private container: HTMLDivElement | undefined;\n private config: ApplicationConfig | undefined;\n private serviceLayer: ServiceLayer | undefined;\n private lifecycleEvents: ApplicationLifecycleEventService | undefined;\n private reactIntegration: ReactIntegration | undefined;\n private stylesWatch: Resource | undefined;\n\n constructor(hostElement: HTMLElement, shadowRoot: ShadowRoot, options: CustomElementOptions) {\n this.hostElement = hostElement;\n this.shadowRoot = shadowRoot;\n this.options = options;\n }\n\n start() {\n if (this.state !== \"not-started\") {\n throw new Error(ErrorId.INTERNAL, `Cannot start element in state '${this.state}'`);\n }\n\n this.state = \"starting\";\n this.startImpl().catch((e) => {\n // TODO: Error splash?\n this.destroy();\n if (!isAbortError(e)) {\n logError(e);\n }\n });\n }\n\n destroy() {\n if (this.state === \"destroyed\") {\n return;\n }\n\n // Only call event listener when 'started' was also signalled.\n if (this.state === \"started\") {\n try {\n this.triggerApplicationLifecycleEvent(\"before-stop\");\n } catch (e) {\n void e; // Ignored\n }\n }\n this.state = \"destroyed\";\n this.apiPromise?.reject(createAbortError());\n this.reactIntegration = destroyResource(this.reactIntegration);\n this.shadowRoot.replaceChildren();\n this.container = undefined;\n this.lifecycleEvents = undefined;\n this.serviceLayer = destroyResource(this.serviceLayer);\n this.stylesWatch = destroyResource(this.stylesWatch);\n }\n\n whenAPI(): Promise<ApiMethods> {\n if (this.api) {\n return Promise.resolve(this.api);\n }\n\n const apiPromise = (this.apiPromise ??= createManualPromise());\n return apiPromise.promise;\n }\n\n private async startImpl() {\n const { options, shadowRoot, hostElement } = this;\n\n // Resolve custom application config\n const config = (this.config = await gatherConfig(hostElement, options));\n this.checkAbort();\n LOG.debug(\"Application config is\", config);\n\n // Decide on locale and load i18n messages (if any).\n const i18n = await initI18n(options.appMetadata, config.locale);\n this.checkAbort();\n\n // Setup application root node in the shadow dom\n const container = (this.container = createContainer(i18n.locale));\n const styles = this.initStyles();\n shadowRoot.replaceChildren(container, ...styles);\n\n // Launch the service layer\n const { serviceLayer, packages } = this.initServiceLayer({\n container,\n properties: config.properties,\n i18n\n });\n this.lifecycleEvents = getInternalService<ApplicationLifecycleEventService>(\n serviceLayer,\n RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE\n );\n\n await this.initAPI(serviceLayer);\n this.checkAbort();\n\n // Launch react\n this.reactIntegration = new ReactIntegration({\n rootNode: container,\n container: shadowRoot,\n serviceLayer,\n packages\n });\n this.render();\n this.state = \"started\";\n\n this.triggerApplicationLifecycleEvent(\"after-start\");\n LOG.debug(\"Application started\");\n }\n\n private render() {\n this.reactIntegration?.render(this.options.component ?? emptyComponent, {});\n }\n\n private initStyles() {\n // Prevent inheritance of certain css values and normalize to display: block by default.\n // See https://open-wc.org/guides/knowledge/styling/styles-piercing-shadow-dom/\n const builtinStyles = \":host { all: initial; display: block; }\";\n const builtinStylesNode = document.createElement(\"style\");\n applyStyles(builtinStylesNode, { value: builtinStyles });\n\n const appStyles = this.options.appMetadata?.styles;\n const appStylesNode = document.createElement(\"style\");\n applyStyles(appStylesNode, appStyles);\n if (import.meta.hot) {\n this.stylesWatch = appStyles?.on?.(\"changed\", () => {\n LOG.debug(\"Application styles changed\");\n applyStyles(appStylesNode, appStyles);\n });\n }\n return [builtinStylesNode, appStylesNode];\n }\n\n private initServiceLayer(config: {\n container: HTMLDivElement;\n properties: ApplicationProperties;\n i18n: AppI18n;\n }) {\n const options = this.options;\n const { container, properties, i18n } = config;\n const packageMetadata = options.appMetadata?.packages ?? {};\n const builtinPackage = createBuiltinPackage({\n host: this.hostElement,\n shadowRoot: this.shadowRoot,\n container: container,\n locale: i18n.locale,\n supportedLocales: i18n.supportedLocales\n });\n const { serviceLayer, packages } = createServiceLayer({\n packageMetadata,\n builtinPackage,\n properties,\n i18n\n });\n this.serviceLayer = serviceLayer;\n\n if (LOG.isDebug()) {\n LOG.debug(\"Launching service layer with packages\", Object.fromEntries(packages));\n }\n serviceLayer.start();\n return { serviceLayer, packages };\n }\n\n private async initAPI(serviceLayer: ServiceLayer) {\n const apiService = getInternalService<ApiService>(serviceLayer, RUNTIME_API_SERVICE);\n try {\n const api = (this.api = await apiService.getApi());\n LOG.debug(\"Application API initialized to\", api);\n this.apiPromise?.resolve(api);\n } catch (e) {\n throw new Error(ErrorId.INTERNAL, \"Failed to gather the application's API methods.\", {\n cause: e\n });\n }\n }\n\n private triggerApplicationLifecycleEvent(event: \"after-start\" | \"before-stop\") {\n this.lifecycleEvents?.emitLifecycleEvent(event);\n }\n\n private checkAbort() {\n if (this.state === \"destroyed\") {\n throwAbortError();\n }\n }\n}\n\nfunction createContainer(locale: string) {\n // Setup application root node in the shadow dom\n const container = document.createElement(\"div\");\n container.classList.add(\"pioneer-root\");\n container.style.minHeight = \"100%\";\n container.style.height = \"100%\";\n if (locale) {\n container.lang = locale;\n }\n return container;\n}\n\nfunction createServiceLayer(config: {\n packageMetadata: Record<string, PackageMetadata> | undefined;\n properties: ApplicationProperties;\n builtinPackage: PackageRepr;\n i18n: AppI18n;\n}) {\n const { packageMetadata, properties, builtinPackage, i18n } = config;\n\n let packages: PackageRepr[];\n try {\n packages = createPackages(packageMetadata ?? {}, i18n, properties);\n } catch (e) {\n throw new Error(ErrorId.INVALID_METADATA, \"Failed to parse package metadata.\", {\n cause: e\n });\n }\n\n // Add builtin services defined within this package.\n {\n const index = packages.findIndex((pkg) => pkg.name === builtinPackage.name);\n if (index >= 0) {\n packages.splice(index, 1);\n }\n packages.push(builtinPackage);\n }\n\n // Automatically required references (-> forces services to start)\n const forcedReferences: ReferenceSpec[] = [\n {\n interfaceName: RUNTIME_API_SERVICE\n },\n {\n interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE\n },\n {\n interfaceName: RUNTIME_AUTO_START,\n all: true\n }\n ];\n const serviceLayer = new ServiceLayer(packages, forcedReferences);\n return {\n packages: new Map(packages.map((pkg) => [pkg.name, pkg])),\n serviceLayer: serviceLayer\n };\n}\n\nfunction getInternalService<T = unknown>(serviceLayer: ServiceLayer, interfaceName: string) {\n const result = serviceLayer.getService(\n \"@open-pioneer/runtime\",\n {\n interfaceName\n },\n { ignoreDeclarationCheck: true }\n );\n if (result.type !== \"found\") {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find instance of '${interfaceName}' (result type '${result.type}').` +\n ` This is a builtin service that must be present exactly once.`\n );\n }\n\n return result.value.getInstanceOrThrow() as T;\n}\n\n/**\n * Gathers application properties by reading them from the options object\n * and by (optionally) invoking the `resolveProperties` hook.\n */\nasync function gatherConfig(hostElement: HTMLElement, options: CustomElementOptions) {\n let configs: ApplicationConfig[];\n try {\n const staticConfig = options.config ?? {};\n const dynamicConfig =\n (await options.resolveConfig?.({\n getAttribute(name) {\n return hostElement.getAttribute(name) ?? undefined;\n }\n })) ?? {};\n\n configs = [staticConfig, dynamicConfig];\n } catch (e) {\n throw new Error(\n ErrorId.CONFIG_RESOLUTION_FAILED,\n \"Failed to resolve application properties.\",\n {\n cause: e\n }\n );\n }\n\n return mergeConfigs(configs);\n}\n\n/**\n * Merges application configurations into a single object.\n * Properties / config parameters at a later position overwrite properties from earlier ones.\n */\nfunction mergeConfigs(configs: ApplicationConfig[]): Required<ApplicationConfig> {\n // Merge simple values by assigning them in order\n const mergedConfig: Required<ApplicationConfig> = Object.assign(\n {\n locale: undefined,\n properties: {}\n } satisfies ApplicationConfig,\n ...configs\n );\n\n // Deep merge for application properties\n const mergedProperties: ApplicationProperties = (mergedConfig.properties = {});\n for (const config of configs) {\n for (const [packageName, packageProperties] of Object.entries(config.properties ?? {})) {\n const mergedPackageProps = (mergedProperties[packageName] ??= {});\n Object.assign(mergedPackageProps, packageProperties);\n }\n }\n\n return mergedConfig;\n}\n\n// Applies application styles to the given style node.\n// Can be called multiple times in development mode to implement hot reloading.\nfunction applyStyles(styleNode: HTMLStyleElement, styles: { value: string } | undefined) {\n const cssValue = styles?.value ?? \"\";\n const cssNode = document.createTextNode(cssValue);\n styleNode.replaceChildren(cssNode);\n}\n\nfunction logError(e: unknown) {\n if (e instanceof Error) {\n const chain = getErrorChain(e).reverse();\n if (chain.length === 1) {\n console.error(e);\n return;\n }\n\n let n = 1;\n for (const error of chain) {\n console.error(`#${n}`, error);\n ++n;\n }\n } else {\n console.error(\"Unexpected error\", e);\n }\n}\n\nfunction emptyComponent() {\n return null;\n}\n"],"names":[],"mappings":";;;;;;;;AA+BA,MAAM,GAAA,GAAM,aAAa,uBAAuB,CA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ACvD;AAAA,GACJ;AAEA,EAAO,OAAA,YAAA,CAAA;AACX,CAAA;AAIA,SAAS,WAAA,CAAY,WAA6B,MAAuC,EAAA;AACrF,EAAM,MAAA,QAAA,GAAW,QAAQ,KAAS,IAAA,EAAA,CAAA;AAClC,EAAM,MAAA,OAAA,GAAU,QAAS,CAAA,cAAA,CAAe,QAAQ,CAAA,CAAA;AAChD,EAAA,SAAA,CAAU,gBAAgB,OAAO,CAAA,CAAA;AACrC,CAAA;AAEA,SAAS,SAAS,CAAY,EAAA;AAC1B,EAAA,IAAI,aAAa,KAAO,EAAA;AACpB,IAAA,MAAM,KAAQ,GAAA,aAAA,CAAc,CAAC,CAAA,CAAE,OAAQ,EAAA,CAAA;AACvC,IAAI,IAAA,KAAA,CAAM,WAAW,CAAG,EAAA;AACpB,MAAA,OAAA,CAAQ,MAAM,CAAC,CAAA,CAAA;AACf,MAAA,OAAA;AAAA,KACJ;AAEA,IAAA,IAAI,CAAI,GAAA,CAAA,CAAA;AACR,IAAA,KAAA,MAAW,SAAS,KAAO,EAAA;AACvB,MAAQ,OAAA,CAAA,KAAA,CAAM,CAAI,CAAA,EAAA,CAAA,CAAA,CAAA,EAAK,KAAK,CAAA,CAAA;AAC5B,MAAE,EAAA,CAAA,CAAA;AAAA,KACN;AAAA,GACG,MAAA;AACH,IAAQ,OAAA,CAAA,KAAA,CAAM,oBAAoB,CAAC,CAAA,CAAA;AAAA,GACvC;AACJ,CAAA;AAEA,SAAS,cAAiB,GAAA;AACtB,EAAO,OAAA,IAAA,CAAA;AACX;;;;"}
1
+ {"version":3,"file":"CustomElement.js","sources":["CustomElement.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { ComponentType } from \"react\";\nimport {\n createAbortError,\n createLogger,\n createManualPromise,\n destroyResource,\n Error,\n isAbortError,\n ManualPromise,\n Resource,\n throwAbortError\n} from \"@open-pioneer/core\";\nimport { ErrorId } from \"./errors\";\nimport { ApplicationMetadata, PackageMetadata } from \"./metadata\";\nimport { PackageRepr, createPackages } from \"./service-layer/PackageRepr\";\nimport { ServiceLayer } from \"./service-layer/ServiceLayer\";\nimport { getErrorChain } from \"@open-pioneer/core\";\nimport { ReactIntegration } from \"./react-integration/ReactIntegration\";\nimport { ApiMethods, ApiService } from \"./api\";\nimport {\n createBuiltinPackage,\n RUNTIME_API_SERVICE,\n RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE,\n RUNTIME_AUTO_START\n} from \"./builtin-services\";\nimport { ReferenceSpec } from \"./service-layer/InterfaceSpec\";\nimport { PropertiesRegistry } from \"./PropertiesRegistry\";\nimport { AppI18n, initI18n } from \"./i18n\";\nimport { ApplicationLifecycleEventService } from \"./builtin-services/ApplicationLifecycleEventService\";\nconst LOG = createLogger(\"runtime:CustomElement\");\n\n/**\n * Options for the {@link createCustomElement} function.\n */\nexport interface CustomElementOptions {\n /**\n * Rendered UI component.\n */\n component?: ComponentType<Record<string, string>>;\n\n /**\n * Application metadata (packages, services etc.).\n * This is usually autogenerated by importing the virtual `\"open-pioneer:app\"` module.\n */\n appMetadata?: ApplicationMetadata;\n\n /**\n * Application defined configuration.\n * All instances of the web component will share this static configuration.\n *\n * These will override default properties of the application's packages.\n */\n config?: ApplicationConfig;\n\n /**\n * Function to provide additional application defined configuration parameters.\n *\n * Compared to {@link config}, this function receives a context object\n * that allows the developer to provide dynamic properties on a per-application basis.\n *\n * Parameters returned by this function take precedence over the ones defined by {@link config}.\n */\n resolveConfig?(ctx: ConfigContext): Promise<ApplicationConfig | undefined>;\n\n /**\n * Whether the shadow root element is accessible from the outside.\n * Defaults to `false` in production mode and `true` during development to make testing easier.\n */\n openShadowRoot?: boolean;\n}\n\n/**\n * A context object that is passed to the `resolveProperties` function.\n */\nexport interface ConfigContext {\n /**\n * Returns an attribute from the application's root node.\n */\n getAttribute(name: string): string | undefined;\n}\n\n/**\n * Runtime application configuration.\n */\nexport interface ApplicationConfig {\n /**\n * Set this value to a locale string (e.g. \"en\") to for the application's locale.\n * The default behavior is to choose an appropriate locale for the current user based\n * on the browser's settings.\n *\n * The locale must be supported by the application.\n */\n locale?: string | undefined;\n\n /**\n * Properties specified here will override default properties of the application's packages.\n */\n properties?: ApplicationProperties | undefined;\n}\n\n/**\n * Allows the application to override default properties in all packages.\n */\nexport interface RawApplicationProperties {\n /**\n * Key: the name of the package.\n * Value: A record of configuration properties (key/value pairs).\n *\n * Properties will override default property values in the package.\n */\n [packageName: string]: Record<string, unknown>;\n}\n\n/**\n * Allows the application to override default properties in all packages.\n *\n * Properties are typed when the package contains type definitions for them.\n */\nexport type ApplicationProperties = RawApplicationProperties & Partial<PropertiesRegistry>;\n\n/**\n * The interface implemented by web components produced via {@link createCustomElement}.\n */\nexport interface ApplicationElement extends HTMLElement {\n /** Resolves to the element's API when the application has started. */\n when(): Promise<ApiMethods>;\n}\n\n/**\n * The class returned by a call to {@link createCustomElement}.\n */\nexport interface ApplicationElementConstructor {\n new (): ApplicationElement;\n}\n\n/**\n * Creates a new custom element class (web component) that can be registered within a DOM.\n *\n * @example\n * ```ts\n * import * as appMetadata from \"open-pioneer:app\";\n *\n * const CustomElementClazz = createCustomElement({\n * component: <div>Hello World!</div>,\n * appMetadata\n * });\n * customElements.define(\"sample-element\", CustomElementClazz);\n * ```\n */\nexport function createCustomElement(options: CustomElementOptions): ApplicationElementConstructor {\n class PioneerApplication extends HTMLElement implements ApplicationElement {\n #shadowRoot: ShadowRoot;\n #state: ElementState | undefined;\n\n static get observedAttributes(): string[] {\n return [];\n }\n\n constructor() {\n super();\n\n const mode = options.openShadowRoot ?? import.meta.env.DEV ? \"open\" : \"closed\";\n this.#shadowRoot = this.attachShadow({\n mode: mode\n });\n\n if (import.meta.env.DEV) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this as any).$inspectElementState = () => this.#state;\n }\n }\n\n connectedCallback() {\n LOG.debug(\"Launching application\");\n\n if (this.#state) {\n this.#state.destroy();\n }\n\n this.#state = new ElementState(this, this.#shadowRoot, options);\n this.#state.start();\n }\n\n disconnectedCallback() {\n LOG.debug(\"Shutting down application\");\n\n this.#state?.destroy();\n this.#state = undefined;\n\n LOG.debug(\"Application destroyed\");\n }\n\n when() {\n if (!this.#state) {\n return Promise.reject(\n new Error(\n ErrorId.NOT_MOUNTED,\n \"Cannot use the application's API because the HTML element has not yet been mounted into the DOM.\"\n )\n );\n }\n\n return this.#state.whenAPI();\n }\n }\n return PioneerApplication;\n}\n\nclass ElementState {\n private hostElement: HTMLElement;\n private shadowRoot: ShadowRoot;\n private options: CustomElementOptions;\n\n // Public API\n private apiPromise: ManualPromise<ApiMethods> | undefined; // Present when callers are waiting for the API\n private api: ApiMethods | undefined; // Present once started\n\n private state = \"not-started\" as \"not-started\" | \"starting\" | \"started\" | \"destroyed\";\n private locale: string | undefined;\n private container: HTMLDivElement | undefined;\n private config: ApplicationConfig | undefined;\n private serviceLayer: ServiceLayer | undefined;\n private lifecycleEvents: ApplicationLifecycleEventService | undefined;\n private reactIntegration: ReactIntegration | undefined;\n private stylesWatch: Resource | undefined;\n\n constructor(hostElement: HTMLElement, shadowRoot: ShadowRoot, options: CustomElementOptions) {\n this.hostElement = hostElement;\n this.shadowRoot = shadowRoot;\n this.options = options;\n }\n\n start() {\n if (this.state !== \"not-started\") {\n throw new Error(ErrorId.INTERNAL, `Cannot start element in state '${this.state}'`);\n }\n\n this.state = \"starting\";\n this.startImpl().catch((e) => {\n // TODO: Error splash?\n this.destroy();\n if (!isAbortError(e)) {\n logError(e);\n }\n });\n }\n\n destroy() {\n if (this.state === \"destroyed\") {\n return;\n }\n\n // Only call event listener when 'started' was also signalled.\n if (this.state === \"started\") {\n try {\n this.triggerApplicationLifecycleEvent(\"before-stop\");\n } catch (e) {\n void e; // Ignored\n }\n }\n this.state = \"destroyed\";\n this.apiPromise?.reject(createAbortError());\n this.reactIntegration = destroyResource(this.reactIntegration);\n this.shadowRoot.replaceChildren();\n this.container = undefined;\n this.lifecycleEvents = undefined;\n this.serviceLayer = destroyResource(this.serviceLayer);\n this.stylesWatch = destroyResource(this.stylesWatch);\n }\n\n whenAPI(): Promise<ApiMethods> {\n if (this.api) {\n return Promise.resolve(this.api);\n }\n\n const apiPromise = (this.apiPromise ??= createManualPromise());\n return apiPromise.promise;\n }\n\n private async startImpl() {\n const { options, shadowRoot, hostElement } = this;\n\n // Resolve custom application config\n const config = (this.config = await gatherConfig(hostElement, options));\n this.checkAbort();\n LOG.debug(\"Application config is\", config);\n\n // Decide on locale and load i18n messages (if any).\n const i18n = await initI18n(options.appMetadata, config.locale);\n this.checkAbort();\n\n // Setup application root node in the shadow dom\n const container = (this.container = createContainer(i18n.locale));\n const styles = this.initStyles();\n shadowRoot.replaceChildren(container, ...styles);\n\n // Launch the service layer\n const { serviceLayer, packages } = this.initServiceLayer({\n container,\n properties: config.properties,\n i18n\n });\n this.lifecycleEvents = getInternalService<ApplicationLifecycleEventService>(\n serviceLayer,\n RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE\n );\n\n await this.initAPI(serviceLayer);\n this.checkAbort();\n\n // Launch react\n this.reactIntegration = new ReactIntegration({\n rootNode: container,\n container: shadowRoot,\n serviceLayer,\n packages\n });\n this.render();\n this.state = \"started\";\n\n this.triggerApplicationLifecycleEvent(\"after-start\");\n LOG.debug(\"Application started\");\n }\n\n private render() {\n this.reactIntegration?.render(this.options.component ?? emptyComponent, {});\n }\n\n private initStyles() {\n // Prevent inheritance of certain css values and normalize to display: block by default.\n // See https://open-wc.org/guides/knowledge/styling/styles-piercing-shadow-dom/\n const builtinStyles = \":host { all: initial; display: block; }\";\n const builtinStylesNode = document.createElement(\"style\");\n applyStyles(builtinStylesNode, { value: builtinStyles });\n\n const appStyles = this.options.appMetadata?.styles;\n const appStylesNode = document.createElement(\"style\");\n applyStyles(appStylesNode, appStyles);\n if (import.meta.hot) {\n this.stylesWatch = appStyles?.on?.(\"changed\", () => {\n LOG.debug(\"Application styles changed\");\n applyStyles(appStylesNode, appStyles);\n });\n }\n return [builtinStylesNode, appStylesNode];\n }\n\n private initServiceLayer(config: {\n container: HTMLDivElement;\n properties: ApplicationProperties;\n i18n: AppI18n;\n }) {\n const options = this.options;\n const { container, properties, i18n } = config;\n const packageMetadata = options.appMetadata?.packages ?? {};\n const builtinPackage = createBuiltinPackage({\n host: this.hostElement,\n shadowRoot: this.shadowRoot,\n container: container,\n locale: i18n.locale,\n supportedLocales: i18n.supportedLocales\n });\n const { serviceLayer, packages } = createServiceLayer({\n packageMetadata,\n builtinPackage,\n properties,\n i18n\n });\n this.serviceLayer = serviceLayer;\n\n if (LOG.isDebug()) {\n LOG.debug(\"Launching service layer with packages\", Object.fromEntries(packages));\n }\n serviceLayer.start();\n return { serviceLayer, packages };\n }\n\n private async initAPI(serviceLayer: ServiceLayer) {\n const apiService = getInternalService<ApiService>(serviceLayer, RUNTIME_API_SERVICE);\n try {\n const api = (this.api = await apiService.getApi());\n LOG.debug(\"Application API initialized to\", api);\n this.apiPromise?.resolve(api);\n } catch (e) {\n throw new Error(ErrorId.INTERNAL, \"Failed to gather the application's API methods.\", {\n cause: e\n });\n }\n }\n\n private triggerApplicationLifecycleEvent(event: \"after-start\" | \"before-stop\") {\n this.lifecycleEvents?.emitLifecycleEvent(event);\n }\n\n private checkAbort() {\n if (this.state === \"destroyed\") {\n throwAbortError();\n }\n }\n}\n\nfunction createContainer(locale: string) {\n // Setup application root node in the shadow dom\n const container = document.createElement(\"div\");\n container.classList.add(\"pioneer-root\");\n container.style.minHeight = \"100%\";\n container.style.height = \"100%\";\n if (locale) {\n container.lang = locale;\n }\n return container;\n}\n\nfunction createServiceLayer(config: {\n packageMetadata: Record<string, PackageMetadata> | undefined;\n properties: ApplicationProperties;\n builtinPackage: PackageRepr;\n i18n: AppI18n;\n}) {\n const { packageMetadata, properties, builtinPackage, i18n } = config;\n\n let packages: PackageRepr[];\n try {\n packages = createPackages(packageMetadata ?? {}, i18n, properties);\n } catch (e) {\n throw new Error(ErrorId.INVALID_METADATA, \"Failed to parse package metadata.\", {\n cause: e\n });\n }\n\n // Add builtin services defined within this package.\n {\n const index = packages.findIndex((pkg) => pkg.name === builtinPackage.name);\n if (index >= 0) {\n packages.splice(index, 1);\n }\n packages.push(builtinPackage);\n }\n\n // Automatically required references (-> forces services to start)\n const forcedReferences: ReferenceSpec[] = [\n {\n interfaceName: RUNTIME_API_SERVICE\n },\n {\n interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE\n },\n {\n interfaceName: RUNTIME_AUTO_START,\n all: true\n }\n ];\n const serviceLayer = new ServiceLayer(packages, forcedReferences);\n return {\n packages: new Map(packages.map((pkg) => [pkg.name, pkg])),\n serviceLayer: serviceLayer\n };\n}\n\nfunction getInternalService<T = unknown>(serviceLayer: ServiceLayer, interfaceName: string) {\n const result = serviceLayer.getService(\n \"@open-pioneer/runtime\",\n {\n interfaceName\n },\n { ignoreDeclarationCheck: true }\n );\n if (result.type !== \"found\") {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find instance of '${interfaceName}' (result type '${result.type}').` +\n ` This is a builtin service that must be present exactly once.`\n );\n }\n\n return result.value.getInstanceOrThrow() as T;\n}\n\n/**\n * Gathers application properties by reading them from the options object\n * and by (optionally) invoking the `resolveProperties` hook.\n */\nasync function gatherConfig(hostElement: HTMLElement, options: CustomElementOptions) {\n let configs: ApplicationConfig[];\n try {\n const staticConfig = options.config ?? {};\n const dynamicConfig =\n (await options.resolveConfig?.({\n getAttribute(name) {\n return hostElement.getAttribute(name) ?? undefined;\n }\n })) ?? {};\n\n configs = [staticConfig, dynamicConfig];\n } catch (e) {\n throw new Error(\n ErrorId.CONFIG_RESOLUTION_FAILED,\n \"Failed to resolve application properties.\",\n {\n cause: e\n }\n );\n }\n\n return mergeConfigs(configs);\n}\n\n/**\n * Merges application configurations into a single object.\n * Properties / config parameters at a later position overwrite properties from earlier ones.\n */\nfunction mergeConfigs(configs: ApplicationConfig[]): Required<ApplicationConfig> {\n // Merge simple values by assigning them in order\n const mergedConfig: Required<ApplicationConfig> = Object.assign(\n {\n locale: undefined,\n properties: {}\n } satisfies ApplicationConfig,\n ...configs\n );\n\n // Deep merge for application properties\n const mergedProperties: ApplicationProperties = (mergedConfig.properties = {});\n for (const config of configs) {\n for (const [packageName, packageProperties] of Object.entries(config.properties ?? {})) {\n const mergedPackageProps = (mergedProperties[packageName] ??= {});\n Object.assign(mergedPackageProps, packageProperties);\n }\n }\n\n return mergedConfig;\n}\n\n// Applies application styles to the given style node.\n// Can be called multiple times in development mode to implement hot reloading.\nfunction applyStyles(styleNode: HTMLStyleElement, styles: { value: string } | undefined) {\n const cssValue = styles?.value ?? \"\";\n const cssNode = document.createTextNode(cssValue);\n styleNode.replaceChildren(cssNode);\n}\n\nfunction logError(e: unknown) {\n if (e instanceof Error) {\n const chain = getErrorChain(e).reverse();\n if (chain.length === 1) {\n console.error(e);\n return;\n }\n\n let n = 1;\n for (const error of chain) {\n console.error(`#${n}`, error);\n ++n;\n }\n } else {\n console.error(\"Unexpected error\", e);\n }\n}\n\nfunction emptyComponent() {\n return null;\n}\n"],"names":[],"mappings":";;;;;;;;AA+BA,MAAM,GAAA,GAAM,aAAa,uBAAuB,CAAA,CAAA;AAwHzC,SAAS,oBAAoB,OAA8D,EAAA;AAC9F,EAAA,MAAM,2BAA2B,WAA0C,CAAA;AAAA,IACvE,WAAA,CAAA;AAAA,IACA,MAAA,CAAA;AAAA,IAEA,WAAW,kBAA+B,GAAA;AACtC,MAAA,OAAO,EAAC,CAAA;AAAA,KACZ;AAAA,IAEA,WAAc,GAAA;AACV,MAAM,KAAA,EAAA,CAAA;AAEN,MAAA,MAAM,OAAO,OAAQ,CAAA,cAAA,IAAkB,MAAY,CAAA,IAAA,CAAA,GAAA,CAAI,MAAM,MAAS,GAAA,QAAA,CAAA;AACtE,MAAK,IAAA,CAAA,WAAA,GAAc,KAAK,YAAa,CAAA;AAAA,QACjC,IAAA;AAAA,OACH,CAAA,CAAA;AAED,MAAI,IAAA,MA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AA;AACpB,MAAA,OAAA,CAAQ,MAAM,CAAC,CAAA,CAAA;AACf,MAAA,OAAA;AAAA,KACJ;AAEA,IAAA,IAAI,CAAI,GAAA,CAAA,CAAA;AACR,IAAA,KAAA,MAAW,SAAS,KAAO,EAAA;AACvB,MAAQ,OAAA,CAAA,KAAA,CAAM,CAAI,CAAA,EAAA,CAAA,CAAA,CAAA,EAAK,KAAK,CAAA,CAAA;AAC5B,MAAE,EAAA,CAAA,CAAA;AAAA,KACN;AAAA,GACG,MAAA;AACH,IAAQ,OAAA,CAAA,KAAA,CAAM,oBAAoB,CAAC,CAAA,CAAA;AAAA,GACvC;AACJ,CAAA;AAEA,SAAS,cAAiB,GAAA;AACtB,EAAO,OAAA,IAAA,CAAA;AACX;;;;"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Maps a package name to its supported properties.
3
+ *
4
+ * By default, properties for all packages are untyped (as Record<string, unknown>).
5
+ *
6
+ * @example
7
+ *
8
+ * ```ts
9
+ * declare module "@open-pioneer/runtime" {
10
+ * interface PropertiesRegistry {
11
+ * // Declares that properties for the "logging" package must
12
+ * // conform to the type on the right when overridden by an app.
13
+ * "logging": Partial<LoggingProperties>
14
+ * }
15
+ * }
16
+ * ```
17
+ */
18
+ export interface PropertiesRegistry {
19
+ }
package/Service.d.ts ADDED
@@ -0,0 +1,63 @@
1
+ import { PackageIntl } from "./i18n";
2
+ /** Lifecycle hooks supported by the service interface. */
3
+ export interface ServiceLifecycleHooks {
4
+ /**
5
+ * Destroys the component.
6
+ * Should clean up all resources used by the component.
7
+ */
8
+ destroy?(): void;
9
+ toString(): string;
10
+ }
11
+ export type Service<Interface extends {} = {}> = ServiceLifecycleHooks & Interface;
12
+ /**
13
+ * Represents metadata for an injected reference.
14
+ */
15
+ export interface ReferenceMeta {
16
+ /**
17
+ * The unique service id of the injected service.
18
+ */
19
+ serviceId: string;
20
+ }
21
+ /**
22
+ * Contains metadata about injected references.
23
+ * The key for the reference metadata is the reference's name.
24
+ */
25
+ export type ReferencesMeta<References extends {}> = {
26
+ [referenceName in keyof References]: References[referenceName] extends any[] ? ReferenceMeta[] : ReferenceMeta;
27
+ };
28
+ /**
29
+ * Options passed to a service's constructor.
30
+ */
31
+ export type ServiceOptions<References extends {} = {}> = {
32
+ /**
33
+ * References to other services.
34
+ * These are injected by the runtime and match the declared references of the service.
35
+ */
36
+ references: References;
37
+ /**
38
+ * Metadata about the injected references.
39
+ * The object contains one entry for every reference injected via `references` (under the same key).
40
+ *
41
+ * If a single service has been injected, `referencesMeta[key]` will be of type {@link ReferenceMeta}.
42
+ * If multiple services have been injected, an array of {@link ReferenceMeta} will be provided instead,
43
+ * where the indices match the order in the injected references array.
44
+ */
45
+ referencesMeta: ReferencesMeta<References>;
46
+ /**
47
+ * Configuration properties.
48
+ *
49
+ * Default values are taken from the package's configuration, but these can be overridden
50
+ * by the application.
51
+ */
52
+ properties: Record<string, unknown>;
53
+ /**
54
+ * A reference to the shared i18n object of the current package.
55
+ */
56
+ intl: PackageIntl;
57
+ };
58
+ /**
59
+ * A service constructor returns a service instance when calling `new`.
60
+ */
61
+ export type ServiceConstructor<References extends {} = {}, Interface extends {} = {}> = {
62
+ new (options: ServiceOptions<References>): Service<Interface>;
63
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Maps a registered interface name to a service type.
3
+ * The interface can be reopened by client packages to add additional registrations.
4
+ *
5
+ * @example
6
+ *
7
+ * ```ts
8
+ * declare module "@open-pioneer/runtime" {
9
+ * interface ServiceRegistry {
10
+ * // Associates the interface name with the TypeScript interface
11
+ * "logging.LogService": Logger;
12
+ * }
13
+ * }
14
+ * ```
15
+ */
16
+ export interface ServiceRegistry {
17
+ }
18
+ /**
19
+ * A well known interface name registered with the {@link ServiceRegistry}.
20
+ */
21
+ export type InterfaceName = keyof ServiceRegistry;
22
+ /**
23
+ * Returns the registered service type for the given interface name.
24
+ */
25
+ export type ServiceType<I extends InterfaceName> = ServiceRegistry[I];
package/api.d.ts ADDED
@@ -0,0 +1,76 @@
1
+ export type ApiMethod = (...args: any[]) => any;
2
+ /**
3
+ * A record of exposed functions.
4
+ */
5
+ export type ApiMethods = Record<string, ApiMethod>;
6
+ /**
7
+ * Provides a set of methods to the application's web component API.
8
+ */
9
+ export interface ApiExtension {
10
+ /**
11
+ * Returns a set of methods that will be added to the web component's API.
12
+ */
13
+ getApiMethods(): Promise<ApiMethods>;
14
+ }
15
+ /**
16
+ * A service provided by the system.
17
+ * Used by the runtime to assemble the public facing API.
18
+ */
19
+ export interface ApiService {
20
+ /**
21
+ * Called by the runtime to gather methods that should be available from the web component's API.
22
+ */
23
+ getApi(): Promise<ApiMethods>;
24
+ }
25
+ /**
26
+ * A service provided by the system, useful for accessing values that are global to the application.
27
+ */
28
+ export interface ApplicationContext {
29
+ /**
30
+ * The web component's host element.
31
+ * This dom node can be accessed by the host site.
32
+ */
33
+ getHostElement(): HTMLElement;
34
+ /**
35
+ * The current web component's shadow root.
36
+ */
37
+ getShadowRoot(): ShadowRoot;
38
+ /**
39
+ * The node containing the rest of the application _inside_ the current web component's shadow dom.
40
+ */
41
+ getApplicationContainer(): HTMLElement;
42
+ /**
43
+ * Returns the current locale of the application.
44
+ *
45
+ * E.g. `"de-DE"`
46
+ */
47
+ getLocale(): string;
48
+ /**
49
+ * Returns the locales supported by the application, i.e.
50
+ * the locales that have associated i18n messages.
51
+ *
52
+ * For example: `["de", "en"]`
53
+ */
54
+ getSupportedLocales(): readonly string[];
55
+ }
56
+ /**
57
+ * Implementing this interface allows a service to be notified on certain
58
+ * application-wide lifecycle events.
59
+ */
60
+ export interface ApplicationLifecycleListener {
61
+ /**
62
+ * Called after all services required by the application have been started.
63
+ */
64
+ afterApplicationStart?(): void;
65
+ /**
66
+ * Called during the application shutdown just before services will be destroyed.
67
+ */
68
+ beforeApplicationStop?(): void;
69
+ }
70
+ declare module "./ServiceRegistry" {
71
+ interface ServiceRegistry {
72
+ "runtime.ApiService": ApiService;
73
+ "runtime.ApplicationContext": ApplicationContext;
74
+ "runtime.ApplicationLifecycleListener": ApplicationLifecycleListener;
75
+ }
76
+ }
@@ -0,0 +1,11 @@
1
+ import { ServiceOptions } from "../Service";
2
+ import { ApiExtension, ApiMethod, ApiService } from "../api";
3
+ interface References {
4
+ providers: ApiExtension[];
5
+ }
6
+ export declare class ApiServiceImpl implements ApiService {
7
+ private readonly providers;
8
+ constructor(options: ServiceOptions<References>);
9
+ getApi(): Promise<Record<string, ApiMethod>>;
10
+ }
11
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"ApiServiceImpl.js","sources":["open-pioneer://external-pioneer-packages/@open-pioneer/runtime/builtin-services/ApiServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { ServiceOptions } from \"../Service\";\nimport { ApiExtension, ApiMethod, ApiMethods, ApiService } from \"../api\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\n\ninterface References {\n providers: ApiExtension[];\n}\n\nexport class ApiServiceImpl implements ApiService {\n private readonly providers: [serviceId: string, provider: ApiExtension][];\n\n constructor(options: ServiceOptions<References>) {\n const providers = options.references.providers;\n const meta = options.referencesMeta.providers;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.providers = providers.map((provider, index) => [meta[index]!.serviceId, provider]);\n }\n\n async getApi() {\n interface ProviderResult {\n serviceId: string;\n methods: ApiMethods;\n }\n\n const promises = this.providers.map(async ([serviceId, provider]) => {\n const methods = await provider.getApiMethods();\n const result: ProviderResult = {\n serviceId,\n methods\n };\n return result;\n });\n const providerMethods = await Promise.all(promises);\n\n interface MethodEntry {\n method: ApiMethod;\n serviceId: string;\n }\n\n const methodEntries = new Map<string, MethodEntry>();\n for (const { serviceId, methods } of providerMethods) {\n for (const [methodName, method] of Object.entries(methods)) {\n const existingEntry = methodEntries.get(methodName);\n if (existingEntry) {\n throw new Error(\n ErrorId.DUPLICATE_API_METHODS,\n `Cannot define API method '${methodName}' from '${serviceId}' (method is also defined by '${existingEntry.serviceId}').`\n );\n }\n\n methodEntries.set(methodName, {\n serviceId,\n method\n });\n }\n }\n\n const api: Record<string, ApiMethod> = {};\n for (const [methodName, entry] of methodEntries.entries()) {\n api[methodName] = entry.method;\n }\n return api;\n }\n}\n"],"names":[],"mappings":";;;AAWO,MAAM,cAAqC,CAAA;AAAA,EAC7B,SAAA,CAAA;AAAA,EAEjB,YAAY,OAAqC,EAAA;AAC7C,IAAM,MAAA,SAAA,GAAY,QAAQ,UAAW,CAAA,SAAA,CAAA;AACrC,IAAM,MAAA,IAAA,GAAO,QAAQ,cAAe,CAAA,SAAA,CAAA;AAEpC,IAAA,IAAA,CAAK,SAAY,GAAA,SAAA,CAAU,GAAI,CAAA,CAAC,QAAU,EAAA,KAAA,KAAU,CAAC,IAAA,CAAK,KAAK,CAAA,CAAG,SAAW,EAAA,QAAQ,CAAC,CAAA,CAAA;AAAA,GAC1F;AAAA,EAEA,MAAM,MAAS,GAAA;AAMX,IAAM,MAAA,QAAA,GAAW,KAAK,SAAU,CAAA,GAAA,CAAI,OAAO,CAAC,SAAA,EAAW,QAAQ,CAAM,KAAA;AACjE,MAAM,MAAA,OAAA,GAAU,MAAM,QAAA,CAAS,aAAc,EAAA,CAAA;AAC7C,MAAA,MAAM,MAAyB,GAAA;AAAA,QAC3B,SAAA;AAAA,QACA,OAAA;AAAA,OACJ,CAAA;AACA,MAAO,OAAA,MAAA,CAAA;AAAA,KACV,CAAA,CAAA;AACD,IAAA,MAAM,eAAkB,GAAA,MAAM,OAAQ,CAAA,GAAA,CAAI,QAAQ,CAAA,CAAA;AAOlD,IAAM,MAAA,aAAA,uBAAoB,GAAyB,EAAA,CAAA;AACnD,IAAA,KAAA,MAAW,EAAE,SAAA,EAAW,OAAQ,EAAA,IAAK,eAAiB,EAAA;AAClD,MAAA,KAAA,MAAW,CAAC,UAAY,EAAA,MAAM,KAAK,MAAO,CAAA,OAAA,CAAQ,OAAO,CAAG,EAAA;AACxD,QAAM,MAAA,aAAA,GAAgB,aAAc,CAAA,GAAA,CAAI,UAAU,CAAA,CAAA;AAClD,QAAA,IAAI,aAAe,EAAA;AACf,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAQ,CAAA,qBAAA;AAAA,YACR,CAAA,0BAAA,EAA6B,UAAqB,CAAA,QAAA,EAAA,SAAA,CAAA,8BAAA,EAA0C,aAAc,CAAA,SAAA,CAAA,GAAA,CAAA;AAAA,WAC9G,CAAA;AAAA,SACJ;AAEA,QAAA,aAAA,CAAc,IAAI,UAAY,EAAA;AAAA,UAC1B,SAAA;AAAA,UACA,MAAA;AAAA,SACH,CAAA,CAAA;AAAA,OACL;AAAA,KACJ;AAEA,IAAA,MAAM,MAAiC,EAAC,CAAA;AACxC,IAAA,KAAA,MAAW,CAAC,UAAY,EAAA,KAAK,CAAK,IAAA,aAAA,CAAc,SAAW,EAAA;AACvD,MAAI,GAAA,CAAA,UAAU,IAAI,KAAM,CAAA,MAAA,CAAA;AAAA,KAC5B;AACA,IAAO,OAAA,GAAA,CAAA;AAAA,GACX;AACJ;;;;"}
1
+ {"version":3,"file":"ApiServiceImpl.js","sources":["ApiServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { ServiceOptions } from \"../Service\";\nimport { ApiExtension, ApiMethod, ApiMethods, ApiService } from \"../api\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\n\ninterface References {\n providers: ApiExtension[];\n}\n\nexport class ApiServiceImpl implements ApiService {\n private readonly providers: [serviceId: string, provider: ApiExtension][];\n\n constructor(options: ServiceOptions<References>) {\n const providers = options.references.providers;\n const meta = options.referencesMeta.providers;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.providers = providers.map((provider, index) => [meta[index]!.serviceId, provider]);\n }\n\n async getApi() {\n interface ProviderResult {\n serviceId: string;\n methods: ApiMethods;\n }\n\n const promises = this.providers.map(async ([serviceId, provider]) => {\n const methods = await provider.getApiMethods();\n const result: ProviderResult = {\n serviceId,\n methods\n };\n return result;\n });\n const providerMethods = await Promise.all(promises);\n\n interface MethodEntry {\n method: ApiMethod;\n serviceId: string;\n }\n\n const methodEntries = new Map<string, MethodEntry>();\n for (const { serviceId, methods } of providerMethods) {\n for (const [methodName, method] of Object.entries(methods)) {\n const existingEntry = methodEntries.get(methodName);\n if (existingEntry) {\n throw new Error(\n ErrorId.DUPLICATE_API_METHODS,\n `Cannot define API method '${methodName}' from '${serviceId}' (method is also defined by '${existingEntry.serviceId}').`\n );\n }\n\n methodEntries.set(methodName, {\n serviceId,\n method\n });\n }\n }\n\n const api: Record<string, ApiMethod> = {};\n for (const [methodName, entry] of methodEntries.entries()) {\n api[methodName] = entry.method;\n }\n return api;\n }\n}\n"],"names":[],"mappings":";;;AAWO,MAAM,cAAqC,CAAA;AAAA,EAC7B,SAAA,CAAA;AAAA,EAEjB,YAAY,OAAqC,EAAA;AAC7C,IAAM,MAAA,SAAA,GAAY,QAAQ,UAAW,CAAA,SAAA,CAAA;AACrC,IAAM,MAAA,IAAA,GAAO,QAAQ,cAAe,CAAA,SAAA,CAAA;AAEpC,IAAA,IAAA,CAAK,SAAY,GAAA,SAAA,CAAU,GAAI,CAAA,CAAC,QAAU,EAAA,KAAA,KAAU,CAAC,IAAA,CAAK,KAAK,CAAA,CAAG,SAAW,EAAA,QAAQ,CAAC,CAAA,CAAA;AAAA,GAC1F;AAAA,EAEA,MAAM,MAAS,GAAA;AAMX,IAAM,MAAA,QAAA,GAAW,KAAK,SAAU,CAAA,GAAA,CAAI,OAAO,CAAC,SAAA,EAAW,QAAQ,CAAM,KAAA;AACjE,MAAM,MAAA,OAAA,GAAU,MAAM,QAAA,CAAS,aAAc,EAAA,CAAA;AAC7C,MAAA,MAAM,MAAyB,GAAA;AAAA,QAC3B,SAAA;AAAA,QACA,OAAA;AAAA,OACJ,CAAA;AACA,MAAO,OAAA,MAAA,CAAA;AAAA,KACV,CAAA,CAAA;AACD,IAAA,MAAM,eAAkB,GAAA,MAAM,OAAQ,CAAA,GAAA,CAAI,QAAQ,CAAA,CAAA;AAOlD,IAAM,MAAA,aAAA,uBAAoB,GAAyB,EAAA,CAAA;AACnD,IAAA,KAAA,MAAW,EAAE,SAAA,EAAW,OAAQ,EAAA,IAAK,eAAiB,EAAA;AAClD,MAAA,KAAA,MAAW,CAAC,UAAY,EAAA,MAAM,KAAK,MAAO,CAAA,OAAA,CAAQ,OAAO,CAAG,EAAA;AACxD,QAAM,MAAA,aAAA,GAAgB,aAAc,CAAA,GAAA,CAAI,UAAU,CAAA,CAAA;AAClD,QAAA,IAAI,aAAe,EAAA;AACf,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAQ,CAAA,qBAAA;AAAA,YACR,CAAA,0BAAA,EAA6B,UAAqB,CAAA,QAAA,EAAA,SAAA,CAAA,8BAAA,EAA0C,aAAc,CAAA,SAAA,CAAA,GAAA,CAAA;AAAA,WAC9G,CAAA;AAAA,SACJ;AAEA,QAAA,aAAA,CAAc,IAAI,UAAY,EAAA;AAAA,UAC1B,SAAA;AAAA,UACA,MAAA;AAAA,SACH,CAAA,CAAA;AAAA,OACL;AAAA,KACJ;AAEA,IAAA,MAAM,MAAiC,EAAC,CAAA;AACxC,IAAA,KAAA,MAAW,CAAC,UAAY,EAAA,KAAK,CAAK,IAAA,aAAA,CAAc,SAAW,EAAA;AACvD,MAAI,GAAA,CAAA,UAAU,IAAI,KAAM,CAAA,MAAA,CAAA;AAAA,KAC5B;AACA,IAAO,OAAA,GAAA,CAAA;AAAA,GACX;AACJ;;;;"}
@@ -0,0 +1,18 @@
1
+ import { ApplicationContext } from "../api";
2
+ import { ServiceOptions } from "../Service";
3
+ export interface ApplicationContextProperties {
4
+ host: HTMLElement;
5
+ shadowRoot: ShadowRoot;
6
+ container: HTMLElement;
7
+ locale: string;
8
+ supportedLocales: string[];
9
+ }
10
+ export declare class ApplicationContextImpl implements ApplicationContext {
11
+ #private;
12
+ constructor(options: ServiceOptions, properties: ApplicationContextProperties);
13
+ getHostElement(): HTMLElement;
14
+ getShadowRoot(): ShadowRoot;
15
+ getApplicationContainer(): HTMLElement;
16
+ getLocale(): string;
17
+ getSupportedLocales(): readonly string[];
18
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"ApplicationContextImpl.js","sources":["open-pioneer://external-pioneer-packages/@open-pioneer/runtime/builtin-services/ApplicationContextImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { ApplicationContext } from \"../api\";\nimport { ServiceOptions } from \"../Service\";\n\nexport interface ApplicationContextProperties {\n host: HTMLElement;\n shadowRoot: ShadowRoot;\n container: HTMLElement;\n locale: string;\n supportedLocales: string[];\n}\n\nexport class ApplicationContextImpl implements ApplicationContext {\n #host: HTMLElement;\n #shadowRoot: ShadowRoot;\n #container: HTMLElement;\n #locale: string;\n #supportedLocales: readonly string[];\n\n constructor(options: ServiceOptions, properties: ApplicationContextProperties) {\n this.#host = properties.host;\n this.#shadowRoot = properties.shadowRoot;\n this.#container = properties.container;\n this.#locale = properties.locale;\n this.#supportedLocales = Object.freeze(Array.from(properties.supportedLocales));\n }\n\n getHostElement(): HTMLElement {\n return this.#host;\n }\n\n getShadowRoot(): ShadowRoot {\n return this.#shadowRoot;\n }\n\n getApplicationContainer(): HTMLElement {\n return this.#container;\n }\n\n getLocale(): string {\n return this.#locale;\n }\n\n getSupportedLocales(): readonly string[] {\n return this.#supportedLocales;\n }\n}\n"],"names":[],"mappings":"AAaO,MAAM,sBAAqD,CAAA;AAAA,EAC9D,KAAA,CAAA;AAAA,EACA,WAAA,CAAA;AAAA,EACA,UAAA,CAAA;AAAA,EACA,OAAA,CAAA;AAAA,EACA,iBAAA,CAAA;AAAA,EAEA,WAAA,CAAY,SAAyB,UAA0C,EAAA;AAC3E,IAAA,IAAA,CAAK,QAAQ,UAAW,CAAA,IAAA,CAAA;AACxB,IAAA,IAAA,CAAK,cAAc,UAAW,CAAA,UAAA,CAAA;AAC9B,IAAA,IAAA,CAAK,aAAa,UAAW,CAAA,SAAA,CAAA;AAC7B,IAAA,IAAA,CAAK,UAAU,UAAW,CAAA,MAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,oBAAoB,MAAO,CAAA,MAAA,CAAO,MAAM,IAAK,CAAA,UAAA,CAAW,gBAAgB,CAAC,CAAA,CAAA;AAAA,GAClF;AAAA,EAEA,cAA8B,GAAA;AAC1B,IAAA,OAAO,IAAK,CAAA,KAAA,CAAA;AAAA,GAChB;AAAA,EAEA,aAA4B,GAAA;AACxB,IAAA,OAAO,IAAK,CAAA,WAAA,CAAA;AAAA,GAChB;AAAA,EAEA,uBAAuC,GAAA;AACnC,IAAA,OAAO,IAAK,CAAA,UAAA,CAAA;AAAA,GAChB;AAAA,EAEA,SAAoB,GAAA;AAChB,IAAA,OAAO,IAAK,CAAA,OAAA,CAAA;AAAA,GAChB;AAAA,EAEA,mBAAyC,GAAA;AACrC,IAAA,OAAO,IAAK,CAAA,iBAAA,CAAA;AAAA,GAChB;AACJ;;;;"}
1
+ {"version":3,"file":"ApplicationContextImpl.js","sources":["ApplicationContextImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { ApplicationContext } from \"../api\";\nimport { ServiceOptions } from \"../Service\";\n\nexport interface ApplicationContextProperties {\n host: HTMLElement;\n shadowRoot: ShadowRoot;\n container: HTMLElement;\n locale: string;\n supportedLocales: string[];\n}\n\nexport class ApplicationContextImpl implements ApplicationContext {\n #host: HTMLElement;\n #shadowRoot: ShadowRoot;\n #container: HTMLElement;\n #locale: string;\n #supportedLocales: readonly string[];\n\n constructor(options: ServiceOptions, properties: ApplicationContextProperties) {\n this.#host = properties.host;\n this.#shadowRoot = properties.shadowRoot;\n this.#container = properties.container;\n this.#locale = properties.locale;\n this.#supportedLocales = Object.freeze(Array.from(properties.supportedLocales));\n }\n\n getHostElement(): HTMLElement {\n return this.#host;\n }\n\n getShadowRoot(): ShadowRoot {\n return this.#shadowRoot;\n }\n\n getApplicationContainer(): HTMLElement {\n return this.#container;\n }\n\n getLocale(): string {\n return this.#locale;\n }\n\n getSupportedLocales(): readonly string[] {\n return this.#supportedLocales;\n }\n}\n"],"names":[],"mappings":"AAaO,MAAM,sBAAqD,CAAA;AAAA,EAC9D,KAAA,CAAA;AAAA,EACA,WAAA,CAAA;AAAA,EACA,UAAA,CAAA;AAAA,EACA,OAAA,CAAA;AAAA,EACA,iBAAA,CAAA;AAAA,EAEA,WAAA,CAAY,SAAyB,UAA0C,EAAA;AAC3E,IAAA,IAAA,CAAK,QAAQ,UAAW,CAAA,IAAA,CAAA;AACxB,IAAA,IAAA,CAAK,cAAc,UAAW,CAAA,UAAA,CAAA;AAC9B,IAAA,IAAA,CAAK,aAAa,UAAW,CAAA,SAAA,CAAA;AAC7B,IAAA,IAAA,CAAK,UAAU,UAAW,CAAA,MAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,oBAAoB,MAAO,CAAA,MAAA,CAAO,MAAM,IAAK,CAAA,UAAA,CAAW,gBAAgB,CAAC,CAAA,CAAA;AAAA,GAClF;AAAA,EAEA,cAA8B,GAAA;AAC1B,IAAA,OAAO,IAAK,CAAA,KAAA,CAAA;AAAA,GAChB;AAAA,EAEA,aAA4B,GAAA;AACxB,IAAA,OAAO,IAAK,CAAA,WAAA,CAAA;AAAA,GAChB;AAAA,EAEA,uBAAuC,GAAA;AACnC,IAAA,OAAO,IAAK,CAAA,UAAA,CAAA;AAAA,GAChB;AAAA,EAEA,SAAoB,GAAA;AAChB,IAAA,OAAO,IAAK,CAAA,OAAA,CAAA;AAAA,GAChB;AAAA,EAEA,mBAAyC,GAAA;AACrC,IAAA,OAAO,IAAK,CAAA,iBAAA,CAAA;AAAA,GAChB;AACJ;;;;"}
@@ -0,0 +1,12 @@
1
+ import { ServiceOptions } from "../Service";
2
+ import { ServiceType } from "../ServiceRegistry";
3
+ interface References {
4
+ listeners: ServiceType<"runtime.ApplicationLifecycleListener">[];
5
+ }
6
+ export declare class ApplicationLifecycleEventService {
7
+ #private;
8
+ constructor(options: ServiceOptions<References>);
9
+ /** @internal */
10
+ emitLifecycleEvent(event: "after-start" | "before-stop"): void;
11
+ }
12
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"ApplicationLifecycleEventService.js","sources":["open-pioneer://external-pioneer-packages/@open-pioneer/runtime/builtin-services/ApplicationLifecycleEventService.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { createLogger } from \"@open-pioneer/core\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ServiceOptions } from \"../Service\";\nimport { ServiceType } from \"../ServiceRegistry\";\nimport { ApplicationLifecycleListener } from \"../api\";\nimport { ErrorId } from \"../errors\";\n\nconst LOG = createLogger(\"runtime:ApplicationLifecycleEventService\");\n\ninterface References {\n listeners: ServiceType<\"runtime.ApplicationLifecycleListener\">[];\n}\n\nexport class ApplicationLifecycleEventService {\n #listeners: [serviceId: string, listener: ApplicationLifecycleListener][];\n\n constructor(options: ServiceOptions<References>) {\n const listeners = options.references.listeners;\n const listenersMeta = options.referencesMeta.listeners;\n this.#listeners = listeners.map((listener, index) => [\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n listenersMeta[index]!.serviceId,\n listener\n ]);\n }\n\n /** @internal */\n emitLifecycleEvent(event: \"after-start\" | \"before-stop\"): void {\n const methodName = (() => {\n switch (event) {\n case \"after-start\":\n return \"afterApplicationStart\";\n case \"before-stop\":\n return \"beforeApplicationStop\";\n default:\n throw new Error(ErrorId.INTERNAL, `Invalid event '${event}'`);\n }\n })();\n for (const [serviceId, listener] of this.#listeners) {\n try {\n listener[methodName]?.();\n } catch (e) {\n LOG.error(`Unexpected error from application lifecycle listener ${serviceId}`, e);\n }\n }\n }\n}\n"],"names":[],"mappings":";;;AAUA,MAAM,GAAA,GAAM,aAAa,0CAA0C,CAAA,CAAA;AAM5D,MAAM,gCAAiC,CAAA;AAAA,EAC1C,UAAA,CAAA;AAAA,EAEA,YAAY,OAAqC,EAAA;AAC7C,IAAM,MAAA,SAAA,GAAY,QAAQ,UAAW,CAAA,SAAA,CAAA;AACrC,IAAM,MAAA,aAAA,GAAgB,QAAQ,cAAe,CAAA,SAAA,CAAA;AAC7C,IAAA,IAAA,CAAK,UAAa,GAAA,SAAA,CAAU,GAAI,CAAA,CAAC,UAAU,KAAU,KAAA;AAAA;AAAA,MAEjD,aAAA,CAAc,KAAK,CAAG,CAAA,SAAA;AAAA,MACtB,QAAA;AAAA,KACH,CAAA,CAAA;AAAA,GACL;AAAA;AAAA,EAGA,mBAAmB,KAA4C,EAAA;AAC3D,IAAA,MAAM,cAAc,MAAM;AACtB,MAAA,QAAQ,KAAO;AAAA,QACX,KAAK,aAAA;AACD,UAAO,OAAA,uBAAA,CAAA;AAAA,QACX,KAAK,aAAA;AACD,UAAO,OAAA,uBAAA,CAAA;AAAA,QACX;AACI,UAAA,MAAM,IAAI,KAAA,CAAM,OAAQ,CAAA,QAAA,EAAU,kBAAkB,KAAQ,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,OACpE;AAAA,KACD,GAAA,CAAA;AACH,IAAA,KAAA,MAAW,CAAC,SAAA,EAAW,QAAQ,CAAA,IAAK,KAAK,UAAY,EAAA;AACjD,MAAI,IAAA;AACA,QAAA,QAAA,CAAS,UAAU,CAAI,IAAA,CAAA;AAAA,eAClB,CAAP,EAAA;AACE,QAAI,GAAA,CAAA,KAAA,CAAM,CAAwD,qDAAA,EAAA,SAAA,CAAA,CAAA,EAAa,CAAC,CAAA,CAAA;AAAA,OACpF;AAAA,KACJ;AAAA,GACJ;AACJ;;;;"}
1
+ {"version":3,"file":"ApplicationLifecycleEventService.js","sources":["ApplicationLifecycleEventService.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { createLogger } from \"@open-pioneer/core\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ServiceOptions } from \"../Service\";\nimport { ServiceType } from \"../ServiceRegistry\";\nimport { ApplicationLifecycleListener } from \"../api\";\nimport { ErrorId } from \"../errors\";\n\nconst LOG = createLogger(\"runtime:ApplicationLifecycleEventService\");\n\ninterface References {\n listeners: ServiceType<\"runtime.ApplicationLifecycleListener\">[];\n}\n\nexport class ApplicationLifecycleEventService {\n #listeners: [serviceId: string, listener: ApplicationLifecycleListener][];\n\n constructor(options: ServiceOptions<References>) {\n const listeners = options.references.listeners;\n const listenersMeta = options.referencesMeta.listeners;\n this.#listeners = listeners.map((listener, index) => [\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n listenersMeta[index]!.serviceId,\n listener\n ]);\n }\n\n /** @internal */\n emitLifecycleEvent(event: \"after-start\" | \"before-stop\"): void {\n const methodName = (() => {\n switch (event) {\n case \"after-start\":\n return \"afterApplicationStart\";\n case \"before-stop\":\n return \"beforeApplicationStop\";\n default:\n throw new Error(ErrorId.INTERNAL, `Invalid event '${event}'`);\n }\n })();\n for (const [serviceId, listener] of this.#listeners) {\n try {\n listener[methodName]?.();\n } catch (e) {\n LOG.error(`Unexpected error from application lifecycle listener ${serviceId}`, e);\n }\n }\n }\n}\n"],"names":[],"mappings":";;;AAUA,MAAM,GAAA,GAAM,aAAa,0CAA0C,CAAA,CAAA;AAM5D,MAAM,gCAAiC,CAAA;AAAA,EAC1C,UAAA,CAAA;AAAA,EAEA,YAAY,OAAqC,EAAA;AAC7C,IAAM,MAAA,SAAA,GAAY,QAAQ,UAAW,CAAA,SAAA,CAAA;AACrC,IAAM,MAAA,aAAA,GAAgB,QAAQ,cAAe,CAAA,SAAA,CAAA;AAC7C,IAAA,IAAA,CAAK,UAAa,GAAA,SAAA,CAAU,GAAI,CAAA,CAAC,UAAU,KAAU,KAAA;AAAA;AAAA,MAEjD,aAAA,CAAc,KAAK,CAAG,CAAA,SAAA;AAAA,MACtB,QAAA;AAAA,KACH,CAAA,CAAA;AAAA,GACL;AAAA;AAAA,EAGA,mBAAmB,KAA4C,EAAA;AAC3D,IAAA,MAAM,cAAc,MAAM;AACtB,MAAA,QAAQ,KAAO;AAAA,QACX,KAAK,aAAA;AACD,UAAO,OAAA,uBAAA,CAAA;AAAA,QACX,KAAK,aAAA;AACD,UAAO,OAAA,uBAAA,CAAA;AAAA,QACX;AACI,UAAA,MAAM,IAAI,KAAA,CAAM,OAAQ,CAAA,QAAA,EAAU,kBAAkB,KAAQ,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA,OACpE;AAAA,KACD,GAAA,CAAA;AACH,IAAA,KAAA,MAAW,CAAC,SAAA,EAAW,QAAQ,CAAA,IAAK,KAAK,UAAY,EAAA;AACjD,MAAI,IAAA;AACA,QAAA,QAAA,CAAS,UAAU,CAAI,IAAA,CAAA;AAAA,eAClB,CAAP,EAAA;AACE,QAAI,GAAA,CAAA,KAAA,CAAM,CAAwD,qDAAA,EAAA,SAAA,CAAA,CAAA,EAAa,CAAC,CAAA,CAAA;AAAA,OACpF;AAAA,KACJ;AAAA,GACJ;AACJ;;;;"}
@@ -0,0 +1,20 @@
1
+ import { PackageRepr } from "../service-layer/PackageRepr";
2
+ import { ApplicationContextProperties } from "./ApplicationContextImpl";
3
+ export declare const RUNTIME_PACKAGE_NAME = "@open-pioneer/runtime";
4
+ export declare const RUNTIME_API_EXTENSION = "integration.ApiExtension";
5
+ export declare const RUNTIME_API_SERVICE = "runtime.ApiService";
6
+ export declare const RUNTIME_APPLICATION_CONTEXT = "runtime.ApplicationContext";
7
+ export declare const RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE = "runtime.ApplicationLifecycleEventService";
8
+ export declare const RUNTIME_AUTO_START = "runtime.AutoStart";
9
+ export type BuiltinPackageProperties = ApplicationContextProperties;
10
+ /**
11
+ * Creates the builtin package containing the builtin services.
12
+ *
13
+ * The runtime package should not use services in the `build.config.mjs`
14
+ * for a clean bootstrapping procedure (it will be instantiated without
15
+ * generated application metadata in tests).
16
+ *
17
+ * This function is called as part of the service layer startup.
18
+ * The package produced here is always part of the application.
19
+ */
20
+ export declare function createBuiltinPackage(properties: BuiltinPackageProperties): PackageRepr;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["open-pioneer://external-pioneer-packages/@open-pioneer/runtime/builtin-services/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { createEmptyI18n } from \"../i18n\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport {\n createConstructorFactory,\n createFunctionFactory,\n ServiceRepr\n} from \"../service-layer/ServiceRepr\";\nimport { ApiServiceImpl } from \"./ApiServiceImpl\";\nimport { ApplicationContextImpl, ApplicationContextProperties } from \"./ApplicationContextImpl\";\nimport { ApplicationLifecycleEventService } from \"./ApplicationLifecycleEventService\";\n\nexport const RUNTIME_PACKAGE_NAME = \"@open-pioneer/runtime\";\nexport const RUNTIME_API_EXTENSION = \"integration.ApiExtension\";\nexport const RUNTIME_API_SERVICE = \"runtime.ApiService\";\nexport const RUNTIME_APPLICATION_CONTEXT = \"runtime.ApplicationContext\";\nexport const RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE =\n \"runtime.ApplicationLifecycleEventService\";\nexport const RUNTIME_AUTO_START = \"runtime.AutoStart\";\n\nexport type BuiltinPackageProperties = ApplicationContextProperties;\n\n/**\n * Creates the builtin package containing the builtin services.\n *\n * The runtime package should not use services in the `build.config.mjs`\n * for a clean bootstrapping procedure (it will be instantiated without\n * generated application metadata in tests).\n *\n * This function is called as part of the service layer startup.\n * The package produced here is always part of the application.\n */\nexport function createBuiltinPackage(properties: BuiltinPackageProperties): PackageRepr {\n const i18n = createEmptyI18n();\n const apiService = new ServiceRepr({\n name: \"ApiServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApiServiceImpl),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_API_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"providers\",\n interfaceName: RUNTIME_API_EXTENSION,\n all: true\n }\n ]\n });\n const appContext = new ServiceRepr({\n name: \"ApplicationContextImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(\n (options) => new ApplicationContextImpl(options, properties)\n ),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_CONTEXT,\n qualifier: \"builtin\"\n }\n ]\n });\n const lifecycleEventService = new ServiceRepr({\n name: \"ApplicationLifecycleEventServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApplicationLifecycleEventService),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"listeners\",\n interfaceName: \"runtime.ApplicationLifecycleListener\",\n all: true\n }\n ]\n });\n\n return new PackageRepr({\n name: RUNTIME_PACKAGE_NAME,\n services: [apiService, appContext, lifecycleEventService],\n intl: i18n\n });\n}\n"],"names":[],"mappings":";;;;;;;AAaO,MAAM,oBAAuB,GAAA,wBAAA;AAC7B,MAAM,qBAAwB,GAAA,2BAAA;AAC9B,MAAM,mBAAsB,GAAA,qBAAA;AAC5B,MAAM,2BAA8B,GAAA,6BAAA;AACpC,MAAM,2CACT,GAAA,2CAAA;AACG,MAAM,kBAAqB,GAAA,oBAAA;AAc3B,SAAS,qBAAqB,UAAmD,EAAA;AACpF,EAAA,MAAM,OAAO,eAAgB,EAAA,CAAA;AAC7B,EAAM,MAAA,UAAA,GAAa,IAAI,WAAY,CAAA;AAAA,IAC/B,IAAM,EAAA,gBAAA;AAAA,IACN,WAAa,EAAA,oBAAA;AAAA,IACb,OAAA,EAAS,yBAAyB,cAAc,CAAA;AAAA,IAChD,IAAM,EAAA,IAAA;AAAA,IACN,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AAA,UAAA,EAAY,qBAAqB,CAAA;AAAA,IACxD,IAAM,EAAA,IAAA;AAAA,GACT,CAAA,CAAA;AACL;;;;"}
1
+ {"version":3,"file":"index.js","sources":["index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { createEmptyI18n } from \"../i18n\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport {\n createConstructorFactory,\n createFunctionFactory,\n ServiceRepr\n} from \"../service-layer/ServiceRepr\";\nimport { ApiServiceImpl } from \"./ApiServiceImpl\";\nimport { ApplicationContextImpl, ApplicationContextProperties } from \"./ApplicationContextImpl\";\nimport { ApplicationLifecycleEventService } from \"./ApplicationLifecycleEventService\";\n\nexport const RUNTIME_PACKAGE_NAME = \"@open-pioneer/runtime\";\nexport const RUNTIME_API_EXTENSION = \"integration.ApiExtension\";\nexport const RUNTIME_API_SERVICE = \"runtime.ApiService\";\nexport const RUNTIME_APPLICATION_CONTEXT = \"runtime.ApplicationContext\";\nexport const RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE =\n \"runtime.ApplicationLifecycleEventService\";\nexport const RUNTIME_AUTO_START = \"runtime.AutoStart\";\n\nexport type BuiltinPackageProperties = ApplicationContextProperties;\n\n/**\n * Creates the builtin package containing the builtin services.\n *\n * The runtime package should not use services in the `build.config.mjs`\n * for a clean bootstrapping procedure (it will be instantiated without\n * generated application metadata in tests).\n *\n * This function is called as part of the service layer startup.\n * The package produced here is always part of the application.\n */\nexport function createBuiltinPackage(properties: BuiltinPackageProperties): PackageRepr {\n const i18n = createEmptyI18n();\n const apiService = new ServiceRepr({\n name: \"ApiServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApiServiceImpl),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_API_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"providers\",\n interfaceName: RUNTIME_API_EXTENSION,\n all: true\n }\n ]\n });\n const appContext = new ServiceRepr({\n name: \"ApplicationContextImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createFunctionFactory(\n (options) => new ApplicationContextImpl(options, properties)\n ),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_CONTEXT,\n qualifier: \"builtin\"\n }\n ]\n });\n const lifecycleEventService = new ServiceRepr({\n name: \"ApplicationLifecycleEventServiceImpl\",\n packageName: RUNTIME_PACKAGE_NAME,\n factory: createConstructorFactory(ApplicationLifecycleEventService),\n intl: i18n,\n interfaces: [\n {\n interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE,\n qualifier: \"builtin\"\n }\n ],\n dependencies: [\n {\n referenceName: \"listeners\",\n interfaceName: \"runtime.ApplicationLifecycleListener\",\n all: true\n }\n ]\n });\n\n return new PackageRepr({\n name: RUNTIME_PACKAGE_NAME,\n services: [apiService, appContext, lifecycleEventService],\n intl: i18n\n });\n}\n"],"names":[],"mappings":";;;;;;;AAaO,MAAM,oBAAuB,GAAA,wBAAA;AAC7B,MAAM,qBAAwB,GAAA,2BAAA;AAC9B,MAAM,mBAAsB,GAAA,qBAAA;AAC5B,MAAM,2BAA8B,GAAA,6BAAA;AACpC,MAAM,2CACT,GAAA,2CAAA;AACG,MAAM,kBAAqB,GAAA,oBAAA;AAc3B,SAAS,qBAAqB,UAAmD,EAAA;AACpF,EAAA,MAAM,OAAO,eAAgB,EAAA,CAAA;AAC7B,EAAM,MAAA,UAAA,GAAa,IAAI,WAAY,CAAA;AAAA,IAC/B,IAAM,EAAA,gBAAA;AAAA,IACN,WAAa,EAAA,oBAAA;AAAA,IACb,OAAA,EAAS,yBAAyB,cAAc,CAAA;AAAA,IAChD,IAAM,EAAA,IAAA;AAAA,IACN,UAAY,EAAA;AAAA,MACR;AAAA,QACI,aAAe,EAAA,mBAAA;AAAA,QACf,SAAW,EAAA,SAAA;AAAA,OACf;AAAA,KACJ;AAAA,IAC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@@ -0,0 +1,17 @@
1
+ export declare enum ErrorId {
2
+ INVALID_METADATA = "runtime:invalid-metadata",
3
+ INVALID_PROPERTY_NAME = "runtime:invalid-property-name",
4
+ REQUIRED_PROPERTY = "runtime:required-property",
5
+ NOT_MOUNTED = "runtime:element-not-mounted",
6
+ UNSUPPORTED_LOCALE = "runtime:unsupported-locale",
7
+ CONFIG_RESOLUTION_FAILED = "runtime:config-resolution-failed",
8
+ INTERFACE_NOT_FOUND = "runtime:interface-not-found",
9
+ AMBIGUOUS_DEPENDENCY = "runtime:ambiguous-dependency",
10
+ UNDECLARED_DEPENDENCY = "runtime:undeclared-dependency",
11
+ SERVICE_CONSTRUCTION_FAILED = "runtime:service-construction-failed",
12
+ SERVICE_DESTRUCTION_FAILED = "runtime:service-destruction-failed",
13
+ DUPLICATE_INTERFACE = "runtime:duplicate-interface",
14
+ DEPENDENCY_CYCLE = "runtime:dependency-cycle",
15
+ DUPLICATE_API_METHODS = "runtime:duplicate-api-methods",
16
+ INTERNAL = "runtime:internal-error"
17
+ }