@open-pioneer/runtime 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/CustomElement.js +335 -0
- package/CustomElement.js.map +1 -0
- package/LICENSE +202 -0
- package/README.md +37 -0
- package/builtin-services/ApiServiceImpl.js +46 -0
- package/builtin-services/ApiServiceImpl.js.map +1 -0
- package/builtin-services/ApplicationContextImpl.js +32 -0
- package/builtin-services/ApplicationContextImpl.js.map +1 -0
- package/builtin-services/ApplicationLifecycleEventService.js +39 -0
- package/builtin-services/ApplicationLifecycleEventService.js.map +1 -0
- package/builtin-services/index.js +76 -0
- package/builtin-services/index.js.map +1 -0
- package/errors.js +21 -0
- package/errors.js.map +1 -0
- package/i18n.js +105 -0
- package/i18n.js.map +1 -0
- package/index.js +3 -0
- package/index.js.map +1 -0
- package/metadata/ObservableBox.js +25 -0
- package/metadata/ObservableBox.js.map +1 -0
- package/metadata/index.js +2 -0
- package/metadata/index.js.map +1 -0
- package/package.json +36 -0
- package/react-integration/PackageContext.js +6 -0
- package/react-integration/PackageContext.js.map +1 -0
- package/react-integration/ReactIntegration.js +92 -0
- package/react-integration/ReactIntegration.js.map +1 -0
- package/react-integration/hooks.js +45 -0
- package/react-integration/hooks.js.map +1 -0
- package/react-integration/index.js +3 -0
- package/react-integration/index.js.map +1 -0
- package/service-layer/InterfaceSpec.js +36 -0
- package/service-layer/InterfaceSpec.js.map +1 -0
- package/service-layer/PackageRepr.js +101 -0
- package/service-layer/PackageRepr.js.map +1 -0
- package/service-layer/ServiceLayer.js +265 -0
- package/service-layer/ServiceLayer.js.map +1 -0
- package/service-layer/ServiceLookup.js +169 -0
- package/service-layer/ServiceLookup.js.map +1 -0
- package/service-layer/ServiceRepr.js +200 -0
- package/service-layer/ServiceRepr.js.map +1 -0
- package/service-layer/verifyDependencies.js +198 -0
- package/service-layer/verifyDependencies.js.map +1 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Error } from '@open-pioneer/core';
|
|
2
|
+
import { ErrorId } from '../errors.js';
|
|
3
|
+
|
|
4
|
+
class ApiServiceImpl {
|
|
5
|
+
providers;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
const providers = options.references.providers;
|
|
8
|
+
const meta = options.referencesMeta.providers;
|
|
9
|
+
this.providers = providers.map((provider, index) => [meta[index].serviceId, provider]);
|
|
10
|
+
}
|
|
11
|
+
async getApi() {
|
|
12
|
+
const promises = this.providers.map(async ([serviceId, provider]) => {
|
|
13
|
+
const methods = await provider.getApiMethods();
|
|
14
|
+
const result = {
|
|
15
|
+
serviceId,
|
|
16
|
+
methods
|
|
17
|
+
};
|
|
18
|
+
return result;
|
|
19
|
+
});
|
|
20
|
+
const providerMethods = await Promise.all(promises);
|
|
21
|
+
const methodEntries = /* @__PURE__ */ new Map();
|
|
22
|
+
for (const { serviceId, methods } of providerMethods) {
|
|
23
|
+
for (const [methodName, method] of Object.entries(methods)) {
|
|
24
|
+
const existingEntry = methodEntries.get(methodName);
|
|
25
|
+
if (existingEntry) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
ErrorId.DUPLICATE_API_METHODS,
|
|
28
|
+
`Cannot define API method '${methodName}' from '${serviceId}' (method is also defined by '${existingEntry.serviceId}').`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
methodEntries.set(methodName, {
|
|
32
|
+
serviceId,
|
|
33
|
+
method
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const api = {};
|
|
38
|
+
for (const [methodName, entry] of methodEntries.entries()) {
|
|
39
|
+
api[methodName] = entry.method;
|
|
40
|
+
}
|
|
41
|
+
return api;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { ApiServiceImpl };
|
|
46
|
+
//# sourceMappingURL=ApiServiceImpl.js.map
|
|
@@ -0,0 +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;AAC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AAA;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,32 @@
|
|
|
1
|
+
class ApplicationContextImpl {
|
|
2
|
+
#host;
|
|
3
|
+
#shadowRoot;
|
|
4
|
+
#container;
|
|
5
|
+
#locale;
|
|
6
|
+
#supportedLocales;
|
|
7
|
+
constructor(options, properties) {
|
|
8
|
+
this.#host = properties.host;
|
|
9
|
+
this.#shadowRoot = properties.shadowRoot;
|
|
10
|
+
this.#container = properties.container;
|
|
11
|
+
this.#locale = properties.locale;
|
|
12
|
+
this.#supportedLocales = Object.freeze(Array.from(properties.supportedLocales));
|
|
13
|
+
}
|
|
14
|
+
getHostElement() {
|
|
15
|
+
return this.#host;
|
|
16
|
+
}
|
|
17
|
+
getShadowRoot() {
|
|
18
|
+
return this.#shadowRoot;
|
|
19
|
+
}
|
|
20
|
+
getApplicationContainer() {
|
|
21
|
+
return this.#container;
|
|
22
|
+
}
|
|
23
|
+
getLocale() {
|
|
24
|
+
return this.#locale;
|
|
25
|
+
}
|
|
26
|
+
getSupportedLocales() {
|
|
27
|
+
return this.#supportedLocales;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { ApplicationContextImpl };
|
|
32
|
+
//# sourceMappingURL=ApplicationContextImpl.js.map
|
|
@@ -0,0 +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;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createLogger, Error } from '@open-pioneer/core';
|
|
2
|
+
import { ErrorId } from '../errors.js';
|
|
3
|
+
|
|
4
|
+
const LOG = createLogger("runtime:ApplicationLifecycleEventService");
|
|
5
|
+
class ApplicationLifecycleEventService {
|
|
6
|
+
#listeners;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
const listeners = options.references.listeners;
|
|
9
|
+
const listenersMeta = options.referencesMeta.listeners;
|
|
10
|
+
this.#listeners = listeners.map((listener, index) => [
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12
|
+
listenersMeta[index].serviceId,
|
|
13
|
+
listener
|
|
14
|
+
]);
|
|
15
|
+
}
|
|
16
|
+
/** @internal */
|
|
17
|
+
emitLifecycleEvent(event) {
|
|
18
|
+
const methodName = (() => {
|
|
19
|
+
switch (event) {
|
|
20
|
+
case "after-start":
|
|
21
|
+
return "afterApplicationStart";
|
|
22
|
+
case "before-stop":
|
|
23
|
+
return "beforeApplicationStop";
|
|
24
|
+
default:
|
|
25
|
+
throw new Error(ErrorId.INTERNAL, `Invalid event '${event}'`);
|
|
26
|
+
}
|
|
27
|
+
})();
|
|
28
|
+
for (const [serviceId, listener] of this.#listeners) {
|
|
29
|
+
try {
|
|
30
|
+
listener[methodName]?.();
|
|
31
|
+
} catch (e) {
|
|
32
|
+
LOG.error(`Unexpected error from application lifecycle listener ${serviceId}`, e);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { ApplicationLifecycleEventService };
|
|
39
|
+
//# sourceMappingURL=ApplicationLifecycleEventService.js.map
|
|
@@ -0,0 +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 }\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} from '../service-layer/PackageRepr.js';
|
|
3
|
+
import { ServiceRepr, createConstructorFactory, createFunctionFactory } from '../service-layer/ServiceRepr.js';
|
|
4
|
+
import { ApiServiceImpl } from './ApiServiceImpl.js';
|
|
5
|
+
import { ApplicationContextImpl } from './ApplicationContextImpl.js';
|
|
6
|
+
import { ApplicationLifecycleEventService } from './ApplicationLifecycleEventService.js';
|
|
7
|
+
|
|
8
|
+
const RUNTIME_PACKAGE_NAME = "@open-pioneer/runtime";
|
|
9
|
+
const RUNTIME_API_EXTENSION = "integration.ApiExtension";
|
|
10
|
+
const RUNTIME_API_SERVICE = "runtime.ApiService";
|
|
11
|
+
const RUNTIME_APPLICATION_CONTEXT = "runtime.ApplicationContext";
|
|
12
|
+
const RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE = "runtime.ApplicationLifecycleEventService";
|
|
13
|
+
const RUNTIME_AUTO_START = "runtime.AutoStart";
|
|
14
|
+
function createBuiltinPackage(properties) {
|
|
15
|
+
const i18n = createEmptyI18n();
|
|
16
|
+
const apiService = new ServiceRepr({
|
|
17
|
+
name: "ApiServiceImpl",
|
|
18
|
+
packageName: RUNTIME_PACKAGE_NAME,
|
|
19
|
+
factory: createConstructorFactory(ApiServiceImpl),
|
|
20
|
+
intl: i18n,
|
|
21
|
+
interfaces: [
|
|
22
|
+
{
|
|
23
|
+
interfaceName: RUNTIME_API_SERVICE,
|
|
24
|
+
qualifier: "builtin"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
dependencies: [
|
|
28
|
+
{
|
|
29
|
+
referenceName: "providers",
|
|
30
|
+
interfaceName: RUNTIME_API_EXTENSION,
|
|
31
|
+
all: true
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
const appContext = new ServiceRepr({
|
|
36
|
+
name: "ApplicationContextImpl",
|
|
37
|
+
packageName: RUNTIME_PACKAGE_NAME,
|
|
38
|
+
factory: createFunctionFactory(
|
|
39
|
+
(options) => new ApplicationContextImpl(options, properties)
|
|
40
|
+
),
|
|
41
|
+
intl: i18n,
|
|
42
|
+
interfaces: [
|
|
43
|
+
{
|
|
44
|
+
interfaceName: RUNTIME_APPLICATION_CONTEXT,
|
|
45
|
+
qualifier: "builtin"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
const lifecycleEventService = new ServiceRepr({
|
|
50
|
+
name: "ApplicationLifecycleEventServiceImpl",
|
|
51
|
+
packageName: RUNTIME_PACKAGE_NAME,
|
|
52
|
+
factory: createConstructorFactory(ApplicationLifecycleEventService),
|
|
53
|
+
intl: i18n,
|
|
54
|
+
interfaces: [
|
|
55
|
+
{
|
|
56
|
+
interfaceName: RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE,
|
|
57
|
+
qualifier: "builtin"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
dependencies: [
|
|
61
|
+
{
|
|
62
|
+
referenceName: "listeners",
|
|
63
|
+
interfaceName: "runtime.ApplicationLifecycleListener",
|
|
64
|
+
all: true
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
return new PackageRepr({
|
|
69
|
+
name: RUNTIME_PACKAGE_NAME,
|
|
70
|
+
services: [apiService, appContext, lifecycleEventService],
|
|
71
|
+
intl: i18n
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { RUNTIME_API_EXTENSION, RUNTIME_API_SERVICE, RUNTIME_APPLICATION_CONTEXT, RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE, RUNTIME_AUTO_START, RUNTIME_PACKAGE_NAME, createBuiltinPackage };
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,UAAY,EAAA;AAAA,MACR;AAAA,QACI,aAAe,EAAA,mBAAA;AAAA,QACf,SAAW,EAAA,SAAA;AAAA,OACf;AAAA,KACJ;AAAA,IACA,YAAc,EAAA;AAAA,MACV;AAAA,QACI,aAAe,EAAA,WAAA;AAAA,QACf,aAAe,EAAA,qBAAA;AAAA,QACf,GAAK,EAAA,IAAA;AAAA,OACT;AAAA,KACJ;AAAA,GACH,CAAA,CAAA;AACD,EAAM,MAAA,UAAA,GAAa,IAAI,WAAY,CAAA;AAAA,IAC/B,IAAM,EAAA,wBAAA;AAAA,IACN,WAAa,EAAA,oBAAA;AAAA,IACb,OAAS,EAAA,qBAAA;AAAA,MACL,CAAC,OAAA,KAAY,IAAI,sBAAA,CAAuB,SAAS,UAAU,CAAA;AAAA,KAC/D;AAAA,IACA,IAAM,EAAA,IAAA;AAAA,IACN,UAAY,EAAA;AAAA,MACR;AAAA,QACI,aAAe,EAAA,2BAAA;AAAA,QACf,SAAW,EAAA,SAAA;AAAA,OACf;AAAA,KACJ;AAAA,GACH,CAAA,CAAA;AACD,EAAM,MAAA,qBAAA,GAAwB,IAAI,WAAY,CAAA;AAAA,IAC1C,IAAM,EAAA,sCAAA;AAAA,IACN,WAAa,EAAA,oBAAA;AAAA,IACb,OAAA,EAAS,yBAAyB,gCAAgC,CAAA;AAAA,IAClE,IAAM,EAAA,IAAA;AAAA,IACN,UAAY,EAAA;AAAA,MACR;AAAA,QACI,aAAe,EAAA,2CAAA;AAAA,QACf,SAAW,EAAA,SAAA;AAAA,OACf;AAAA,KACJ;AAAA,IACA,YAAc,EAAA;AAAA,MACV;AAAA,QACI,aAAe,EAAA,WAAA;AAAA,QACf,aAAe,EAAA,sCAAA;AAAA,QACf,GAAK,EAAA,IAAA;AAAA,OACT;AAAA,KACJ;AAAA,GACH,CAAA,CAAA;AAED,EAAA,OAAO,IAAI,WAAY,CAAA;AAAA,IACnB,IAAM,EAAA,oBAAA;AAAA,IACN,QAAU,EAAA,CAAC,UAAY,EAAA,UAAA,EAAY,qBAAqB,CAAA;AAAA,IACxD,IAAM,EAAA,IAAA;AAAA,GACT,CAAA,CAAA;AACL;;;;"}
|
package/errors.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var ErrorId = /* @__PURE__ */ ((ErrorId2) => {
|
|
2
|
+
ErrorId2["INVALID_METADATA"] = "runtime:invalid-metadata";
|
|
3
|
+
ErrorId2["INVALID_PROPERTY_NAME"] = "runtime:invalid-property-name";
|
|
4
|
+
ErrorId2["REQUIRED_PROPERTY"] = "runtime:required-property";
|
|
5
|
+
ErrorId2["NOT_MOUNTED"] = "runtime:element-not-mounted";
|
|
6
|
+
ErrorId2["UNSUPPORTED_LOCALE"] = "runtime:unsupported-locale";
|
|
7
|
+
ErrorId2["CONFIG_RESOLUTION_FAILED"] = "runtime:config-resolution-failed";
|
|
8
|
+
ErrorId2["INTERFACE_NOT_FOUND"] = "runtime:interface-not-found";
|
|
9
|
+
ErrorId2["AMBIGUOUS_DEPENDENCY"] = "runtime:ambiguous-dependency";
|
|
10
|
+
ErrorId2["UNDECLARED_DEPENDENCY"] = "runtime:undeclared-dependency";
|
|
11
|
+
ErrorId2["SERVICE_CONSTRUCTION_FAILED"] = "runtime:service-construction-failed";
|
|
12
|
+
ErrorId2["SERVICE_DESTRUCTION_FAILED"] = "runtime:service-destruction-failed";
|
|
13
|
+
ErrorId2["DUPLICATE_INTERFACE"] = "runtime:duplicate-interface";
|
|
14
|
+
ErrorId2["DEPENDENCY_CYCLE"] = "runtime:dependency-cycle";
|
|
15
|
+
ErrorId2["DUPLICATE_API_METHODS"] = "runtime:duplicate-api-methods";
|
|
16
|
+
ErrorId2["INTERNAL"] = "runtime:internal-error";
|
|
17
|
+
return ErrorId2;
|
|
18
|
+
})(ErrorId || {});
|
|
19
|
+
|
|
20
|
+
export { ErrorId };
|
|
21
|
+
//# sourceMappingURL=errors.js.map
|
package/errors.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sources":["open-pioneer://external-pioneer-packages/@open-pioneer/runtime/errors.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nexport enum ErrorId {\n // Problems with application metadata\n INVALID_METADATA = \"runtime:invalid-metadata\",\n INVALID_PROPERTY_NAME = \"runtime:invalid-property-name\",\n REQUIRED_PROPERTY = \"runtime:required-property\",\n\n // Application lifecycle\n NOT_MOUNTED = \"runtime:element-not-mounted\",\n UNSUPPORTED_LOCALE = \"runtime:unsupported-locale\",\n CONFIG_RESOLUTION_FAILED = \"runtime:config-resolution-failed\",\n\n // Service layer\n INTERFACE_NOT_FOUND = \"runtime:interface-not-found\",\n AMBIGUOUS_DEPENDENCY = \"runtime:ambiguous-dependency\",\n UNDECLARED_DEPENDENCY = \"runtime:undeclared-dependency\",\n SERVICE_CONSTRUCTION_FAILED = \"runtime:service-construction-failed\",\n SERVICE_DESTRUCTION_FAILED = \"runtime:service-destruction-failed\",\n DUPLICATE_INTERFACE = \"runtime:duplicate-interface\",\n DEPENDENCY_CYCLE = \"runtime:dependency-cycle\",\n\n // Web component API\n DUPLICATE_API_METHODS = \"runtime:duplicate-api-methods\",\n\n // Internal\n INTERNAL = \"runtime:internal-error\"\n}\n"],"names":["ErrorId"],"mappings":"AAEY,IAAA,OAAA,qBAAAA,QAAL,KAAA;AAEH,EAAAA,SAAA,kBAAmB,CAAA,GAAA,0BAAA,CAAA;AACnB,EAAAA,SAAA,uBAAwB,CAAA,GAAA,+BAAA,CAAA;AACxB,EAAAA,SAAA,mBAAoB,CAAA,GAAA,2BAAA,CAAA;AAGpB,EAAAA,SAAA,aAAc,CAAA,GAAA,6BAAA,CAAA;AACd,EAAAA,SAAA,oBAAqB,CAAA,GAAA,4BAAA,CAAA;AACrB,EAAAA,SAAA,0BAA2B,CAAA,GAAA,kCAAA,CAAA;AAG3B,EAAAA,SAAA,qBAAsB,CAAA,GAAA,6BAAA,CAAA;AACtB,EAAAA,SAAA,sBAAuB,CAAA,GAAA,8BAAA,CAAA;AACvB,EAAAA,SAAA,uBAAwB,CAAA,GAAA,+BAAA,CAAA;AACxB,EAAAA,SAAA,6BAA8B,CAAA,GAAA,qCAAA,CAAA;AAC9B,EAAAA,SAAA,4BAA6B,CAAA,GAAA,oCAAA,CAAA;AAC7B,EAAAA,SAAA,qBAAsB,CAAA,GAAA,6BAAA,CAAA;AACtB,EAAAA,SAAA,kBAAmB,CAAA,GAAA,0BAAA,CAAA;AAGnB,EAAAA,SAAA,uBAAwB,CAAA,GAAA,+BAAA,CAAA;AAGxB,EAAAA,SAAA,UAAW,CAAA,GAAA,wBAAA,CAAA;AAxBH,EAAAA,OAAAA,QAAAA,CAAAA;AAAA,CAAA,EAAA,OAAA,IAAA,EAAA;;;;"}
|
package/i18n.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { createIntlCache, createIntl } from '@formatjs/intl';
|
|
2
|
+
import { ErrorId } from './errors.js';
|
|
3
|
+
import { createLogger, Error } from '@open-pioneer/core';
|
|
4
|
+
|
|
5
|
+
const LOG = createLogger("runtime:i18n");
|
|
6
|
+
function createPackageIntl(locale, messages) {
|
|
7
|
+
const cache = createIntlCache();
|
|
8
|
+
return createIntl(
|
|
9
|
+
{
|
|
10
|
+
locale,
|
|
11
|
+
messages
|
|
12
|
+
},
|
|
13
|
+
cache
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
async function initI18n(appMetadata, forcedLocale) {
|
|
17
|
+
const supportedLocales = appMetadata?.locales ?? [];
|
|
18
|
+
const userLocales = getBrowserLocales();
|
|
19
|
+
if (LOG.isDebug()) {
|
|
20
|
+
LOG.debug(
|
|
21
|
+
`Attempting to pick locale for user (locales: ${userLocales.join(
|
|
22
|
+
", "
|
|
23
|
+
)}) from app (supported locales: ${supportedLocales.join(
|
|
24
|
+
", "
|
|
25
|
+
)}) [forcedLocale=${forcedLocale}].`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
const { locale, messageLocale } = pickLocale(
|
|
29
|
+
forcedLocale,
|
|
30
|
+
supportedLocales,
|
|
31
|
+
getBrowserLocales()
|
|
32
|
+
);
|
|
33
|
+
if (LOG.isDebug()) {
|
|
34
|
+
LOG.debug(`Using locale '${locale}' with messages from locale '${messageLocale}'.`);
|
|
35
|
+
}
|
|
36
|
+
let messages;
|
|
37
|
+
if (supportedLocales.includes(messageLocale)) {
|
|
38
|
+
try {
|
|
39
|
+
messages = await appMetadata?.loadMessages?.(messageLocale) ?? {};
|
|
40
|
+
} catch (e) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
ErrorId.INTERNAL,
|
|
43
|
+
`Failed to load messages for locale '${messageLocale}'.`,
|
|
44
|
+
{
|
|
45
|
+
cause: e
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
locale,
|
|
52
|
+
supportedLocales,
|
|
53
|
+
createPackageI18n(packageName) {
|
|
54
|
+
const packageMessage = messages?.[packageName] ?? {};
|
|
55
|
+
return createPackageIntl(locale, packageMessage);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function createEmptyI18n(locale = "en") {
|
|
60
|
+
return createPackageIntl(locale, {});
|
|
61
|
+
}
|
|
62
|
+
function pickLocale(forcedLocale, appLocales, userLocales) {
|
|
63
|
+
const pickImpl = (requestedLocales) => {
|
|
64
|
+
for (const requestedLocale of requestedLocales) {
|
|
65
|
+
if (appLocales.includes(requestedLocale)) {
|
|
66
|
+
return { messageLocale: requestedLocale, locale: requestedLocale };
|
|
67
|
+
}
|
|
68
|
+
const plainLanguage = requestedLocale.match(/^([a-z]+)/i)?.[1];
|
|
69
|
+
if (plainLanguage && appLocales.includes(plainLanguage)) {
|
|
70
|
+
return { messageLocale: plainLanguage, locale: requestedLocale };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return void 0;
|
|
74
|
+
};
|
|
75
|
+
if (forcedLocale) {
|
|
76
|
+
const result = pickImpl([forcedLocale]);
|
|
77
|
+
if (!result) {
|
|
78
|
+
const localesList = appLocales.join(", ");
|
|
79
|
+
throw new Error(
|
|
80
|
+
ErrorId.UNSUPPORTED_LOCALE,
|
|
81
|
+
`Locale '${forcedLocale}' cannot be forced because it is not supported by the application. Supported locales are ${localesList}.`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
if (result.locale !== result.messageLocale) {
|
|
85
|
+
LOG.warn(
|
|
86
|
+
`Non-exact match for forced locale '${forcedLocale}': using messages from '${result.messageLocale}'.`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
const supportedLocale = pickImpl(userLocales);
|
|
92
|
+
if (supportedLocale) {
|
|
93
|
+
return supportedLocale;
|
|
94
|
+
}
|
|
95
|
+
return { locale: userLocales[0] ?? "en", messageLocale: appLocales[0] ?? "en" };
|
|
96
|
+
}
|
|
97
|
+
function getBrowserLocales() {
|
|
98
|
+
if (window.navigator.languages && window.navigator.languages.length) {
|
|
99
|
+
return Array.from(window.navigator.languages);
|
|
100
|
+
}
|
|
101
|
+
return [window.navigator.language];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { createEmptyI18n, initI18n, pickLocale };
|
|
105
|
+
//# sourceMappingURL=i18n.js.map
|
package/i18n.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sources":["open-pioneer://external-pioneer-packages/@open-pioneer/runtime/i18n.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { createIntl, createIntlCache, IntlFormatters, IntlShape } from \"@formatjs/intl\";\nimport { ErrorId } from \"./errors\";\nimport { createLogger, Error } from \"@open-pioneer/core\";\nimport { ApplicationMetadata } from \"./metadata\";\nconst LOG = createLogger(\"runtime:i18n\");\n\n/**\n * Represents i18n info for the entire application.\n * Currently not exposed to user code.\n */\nexport interface AppI18n {\n /** Chosen locale */\n readonly locale: string;\n\n /** Supported locales from app metadata. */\n readonly supportedLocales: string[];\n\n /** Given the package name, constructs a package i18n instance. */\n createPackageI18n(packageName: string): PackageIntl;\n}\n\n/**\n * Gives access to the package's i18n messages for the current locale.\n *\n * See also https://formatjs.io/docs/intl\n */\nexport type PackageIntl = Pick<IntlShape, \"locale\" | \"timeZone\"> & IntlFormatters<string>;\n\nfunction createPackageIntl(locale: string, messages: Record<string, string>) {\n const cache = createIntlCache();\n return createIntl(\n {\n locale,\n messages\n },\n cache\n );\n}\n\n/**\n * Initializes the application's locale and fetches the appropriate i18n messages.\n */\nexport async function initI18n(\n appMetadata: ApplicationMetadata | undefined,\n forcedLocale: string | undefined\n): Promise<AppI18n> {\n const supportedLocales = appMetadata?.locales ?? [];\n const userLocales = getBrowserLocales();\n if (LOG.isDebug()) {\n LOG.debug(\n `Attempting to pick locale for user (locales: ${userLocales.join(\n \", \"\n )}) from app (supported locales: ${supportedLocales.join(\n \", \"\n )}) [forcedLocale=${forcedLocale}].`\n );\n }\n\n const { locale, messageLocale } = pickLocale(\n forcedLocale,\n supportedLocales,\n getBrowserLocales()\n );\n\n if (LOG.isDebug()) {\n LOG.debug(`Using locale '${locale}' with messages from locale '${messageLocale}'.`);\n }\n\n let messages: Record<string, Record<string, string>>;\n if (supportedLocales.includes(messageLocale)) {\n try {\n messages = (await appMetadata?.loadMessages?.(messageLocale)) ?? {};\n } catch (e) {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to load messages for locale '${messageLocale}'.`,\n {\n cause: e\n }\n );\n }\n }\n return {\n locale,\n supportedLocales,\n createPackageI18n(packageName) {\n const packageMessage = messages?.[packageName] ?? {};\n return createPackageIntl(locale, packageMessage);\n }\n };\n}\n\n/** Creates an empty i18n instance, e.g. for tests. */\nexport function createEmptyI18n(locale = \"en\"): PackageIntl {\n return createPackageIntl(locale, {});\n}\n\nexport interface LocalePickResult {\n /** The actual locale (e.g. en-US) for number and date formatting etc. */\n locale: string;\n\n /**\n * The locale identifier to load messages for. E.g. \"en\".\n */\n messageLocale: string;\n}\n\n/**\n * Picks a locale for the app. Exported for tests.\n *\n * @param forcedLocale Optional forced locale (must be satisfied)\n * @param appLocales Locales the app has i18n messages for (e.g. \"en\", \"de\")\n * @param userLocales Locales requested by the user's browser\n */\nexport function pickLocale(\n forcedLocale: string | undefined,\n appLocales: string[],\n userLocales: string[]\n): LocalePickResult {\n const pickImpl = (requestedLocales: string[]): LocalePickResult | undefined => {\n for (const requestedLocale of requestedLocales) {\n // try exact match\n if (appLocales.includes(requestedLocale)) {\n return { messageLocale: requestedLocale, locale: requestedLocale };\n }\n\n // try plain language tag (e.g. \"en\") as fallback\n const plainLanguage = requestedLocale.match(/^([a-z]+)/i)?.[1];\n if (plainLanguage && appLocales.includes(plainLanguage)) {\n return { messageLocale: plainLanguage, locale: requestedLocale };\n }\n }\n return undefined;\n };\n\n // Attempt to satisfy forced locale\n if (forcedLocale) {\n const result = pickImpl([forcedLocale]);\n if (!result) {\n const localesList = appLocales.join(\", \");\n throw new Error(\n ErrorId.UNSUPPORTED_LOCALE,\n `Locale '${forcedLocale}' cannot be forced because it is not supported by the application.` +\n ` Supported locales are ${localesList}.`\n );\n }\n if (result.locale !== result.messageLocale) {\n LOG.warn(\n `Non-exact match for forced locale '${forcedLocale}': using messages from '${result.messageLocale}'.`\n );\n }\n return result;\n }\n\n // Match preferred locale\n const supportedLocale = pickImpl(userLocales);\n if (supportedLocale) {\n return supportedLocale;\n }\n\n // Fallback: Most preferred locale (for dates etc.), but some of our messages\n return { locale: userLocales[0] ?? \"en\", messageLocale: appLocales[0] ?? \"en\" };\n}\n\n/**\n * Returns locales supported by the browser, in order of preference (preferred first).\n *\n * See also https://developer.mozilla.org/en-US/docs/Web/API/Navigator/languages\n */\nfunction getBrowserLocales(): string[] {\n if (window.navigator.languages && window.navigator.languages.length) {\n return Array.from(window.navigator.languages);\n }\n return [window.navigator.language];\n}\n"],"names":[],"mappings":";;;;AAMA,MAAM,GAAA,GAAM,aAAa,cAAc,CAAA,CAAA;AAwBvC,SAAS,iBAAA,CAAkB,QAAgB,QAAkC,EAAA;AACzE,EAAA,MAAM,QAAQ,eAAgB,EAAA,CAAA;AAC9B,EAAO,OAAA,UAAA;AAAA,IACH;AAAA,MACI,MAAA;AAAA,MACA,QAAA;AAAA,KACJ;AAAA,IACA,KAAA;AAAA,GACJ,CAAA;AACJ,CAAA;AAKsB,eAAA,QAAA,CACl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CAAA,CAAA,CAAA;AAAA,OAClC,CAAA;AAAA,KACJ;AACA,IAAI,IAAA,MAAA,CAAO,MAAW,KAAA,MAAA,CAAO,aAAe,EAAA;AACxC,MAAI,GAAA,CAAA,IAAA;AAAA,QACA,CAAA,mCAAA,EAAsC,uCAAuC,MAAO,CAAA,aAAA,CAAA,EAAA,CAAA;AAAA,OACxF,CAAA;AAAA,KACJ;AACA,IAAO,OAAA,MAAA,CAAA;AAAA,GACX;AAGA,EAAM,MAAA,eAAA,GAAkB,SAAS,WAAW,CAAA,CAAA;AAC5C,EAAA,IAAI,eAAiB,EAAA;AACjB,IAAO,OAAA,eAAA,CAAA;AAAA,GACX;AAGA,EAAO,OAAA,EAAE,MAAQ,EAAA,WAAA,CAAY,CAAC,CAAA,IAAK,MAAM,aAAe,EAAA,UAAA,CAAW,CAAC,CAAA,IAAK,IAAK,EAAA,CAAA;AAClF,CAAA;AAOA,SAAS,iBAA8B,GAAA;AACnC,EAAA,IAAI,OAAO,SAAU,CAAA,SAAA,IAAa,MAAO,CAAA,SAAA,CAAU,UAAU,MAAQ,EAAA;AACjE,IAAA,OAAO,KAAM,CAAA,IAAA,CAAK,MAAO,CAAA,SAAA,CAAU,SAAS,CAAA,CAAA;AAAA,GAChD;AACA,EAAO,OAAA,CAAC,MAAO,CAAA,SAAA,CAAU,QAAQ,CAAA,CAAA;AACrC;;;;"}
|
package/index.js
ADDED
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { EventEmitter } from '@open-pioneer/core';
|
|
2
|
+
|
|
3
|
+
function createBox(value) {
|
|
4
|
+
if (import.meta.env.DEV) {
|
|
5
|
+
return new BoxImpl(value);
|
|
6
|
+
} else {
|
|
7
|
+
return {
|
|
8
|
+
value
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
class BoxImpl extends EventEmitter {
|
|
13
|
+
value;
|
|
14
|
+
constructor(value) {
|
|
15
|
+
super();
|
|
16
|
+
this.value = value;
|
|
17
|
+
}
|
|
18
|
+
setValue(value) {
|
|
19
|
+
this.value = value;
|
|
20
|
+
this.emit("changed");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { createBox };
|
|
25
|
+
//# sourceMappingURL=ObservableBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObservableBox.js","sources":["open-pioneer://external-pioneer-packages/@open-pioneer/runtime/metadata/ObservableBox.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { EventEmitter, Resource } from \"@open-pioneer/core\";\n\nexport interface ObservableBox<T> {\n /** The current value. */\n readonly value: T;\n\n /**\n * Changes the current value.\n *\n * Note that this function is only present during development to facilitate hot reloading.\n */\n setValue?(value: T): void;\n\n /**\n * Register a listener callback that will be invoked\n * when the value changes.\n *\n * Note that this function is only present during development to facilitate hot reloading.\n */\n on?(event: \"changed\", listener: () => void): Resource;\n}\n\n/**\n * Returns a boxed value.\n * In development node, the box value can be changed and observed.\n */\nexport function createBox<T>(value: T): ObservableBox<T> {\n if (import.meta.env.DEV) {\n return new BoxImpl(value);\n } else {\n return {\n value\n };\n }\n}\n\nclass BoxImpl<T> extends EventEmitter<{ changed: void }> implements Required<ObservableBox<T>> {\n value: T;\n\n constructor(value: T) {\n super();\n this.value = value;\n }\n\n setValue(value: T): void {\n this.value = value;\n this.emit(\"changed\");\n }\n}\n"],"names":[],"mappings":";;AA4BO,SAAS,UAAa,KAA4B,EAAA;AACrD,EAAI,IAAA,MAAA,CAAA,IAAA,CAAY,IAAI,GAAK,EAAA;AACrB,IAAO,OAAA,IAAI,QAAQ,KAAK,CAAA,CAAA;AAAA,GACrB,MAAA;AACH,IAAO,OAAA;AAAA,MACH,KAAA;AAAA,KACJ,CAAA;AAAA,GACJ;AACJ,CAAA;AAEA,MAAM,gBAAmB,YAAsE,CAAA;AAAA,EAC3F,KAAA,CAAA;AAAA,EAEA,YAAY,KAAU,EAAA;AAClB,IAAM,KAAA,EAAA,CAAA;AACN,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AAAA,GACjB;AAAA,EAEA,SAAS,KAAgB,EAAA;AACrB,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAA,IAAA,CAAK,KAAK,SAAS,CAAA,CAAA;AAAA,GACvB;AACJ;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "module",
|
|
3
|
+
"name": "@open-pioneer/runtime",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@formatjs/intl": "^2.7.2",
|
|
8
|
+
"react": "^18.2.0",
|
|
9
|
+
"react-dom": "^18.2.0",
|
|
10
|
+
"@open-pioneer/chakra-integration": "^0.1.0",
|
|
11
|
+
"@open-pioneer/core": "^0.1.0"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
"./package.json": "./package.json",
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./index.js"
|
|
17
|
+
},
|
|
18
|
+
"./metadata": {
|
|
19
|
+
"import": "./metadata/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./react-integration": {
|
|
22
|
+
"import": "./react-integration/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"openPioneerFramework": {
|
|
26
|
+
"services": [],
|
|
27
|
+
"i18n": {
|
|
28
|
+
"languages": []
|
|
29
|
+
},
|
|
30
|
+
"ui": {
|
|
31
|
+
"references": []
|
|
32
|
+
},
|
|
33
|
+
"properties": [],
|
|
34
|
+
"packageFormatVersion": "1.0.0"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PackageContext.js","sources":["open-pioneer://external-pioneer-packages/@open-pioneer/runtime/react-integration/PackageContext.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { createContext } from \"react\";\nimport { PackageIntl } from \"../i18n\";\nimport { Service } from \"../Service\";\nimport { 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;;;;"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { StrictMode } from 'react';
|
|
3
|
+
import { createRoot } from 'react-dom/client';
|
|
4
|
+
import { Error } from '@open-pioneer/core';
|
|
5
|
+
import { ErrorId } from '../errors.js';
|
|
6
|
+
import { PackageContext } from './PackageContext.js';
|
|
7
|
+
import { renderInterfaceSpec } from '../service-layer/InterfaceSpec.js';
|
|
8
|
+
import { renderAmbiguousServiceChoices } from '../service-layer/ServiceLookup.js';
|
|
9
|
+
import { CustomChakraProvider } from '@open-pioneer/chakra-integration';
|
|
10
|
+
|
|
11
|
+
class ReactIntegration {
|
|
12
|
+
containerNode;
|
|
13
|
+
packages;
|
|
14
|
+
serviceLayer;
|
|
15
|
+
root;
|
|
16
|
+
packageContext;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.containerNode = options.container;
|
|
19
|
+
this.packages = options.packages;
|
|
20
|
+
this.serviceLayer = options.serviceLayer;
|
|
21
|
+
this.root = createRoot(options.rootNode);
|
|
22
|
+
this.packageContext = {
|
|
23
|
+
getService: (packageName, interfaceName, options2) => {
|
|
24
|
+
const spec = { interfaceName, ...options2 };
|
|
25
|
+
const result = this.serviceLayer.getService(packageName, spec);
|
|
26
|
+
if (result.type === "found") {
|
|
27
|
+
return result.value.getInstanceOrThrow();
|
|
28
|
+
}
|
|
29
|
+
const renderedSpec = renderInterfaceSpec(spec);
|
|
30
|
+
switch (result.type) {
|
|
31
|
+
case "unimplemented":
|
|
32
|
+
throw new Error(
|
|
33
|
+
ErrorId.INTERFACE_NOT_FOUND,
|
|
34
|
+
`The UI of package '${packageName}' requested the unimplemented interface ${renderedSpec}.`
|
|
35
|
+
);
|
|
36
|
+
case "undeclared":
|
|
37
|
+
throw new Error(
|
|
38
|
+
ErrorId.UNDECLARED_DEPENDENCY,
|
|
39
|
+
`Package '${packageName}' did not declare an UI dependency on interface ${renderedSpec}. Add the dependency to the package configuration or remove the usage.`
|
|
40
|
+
);
|
|
41
|
+
case "ambiguous": {
|
|
42
|
+
const renderedChoices = renderAmbiguousServiceChoices(result.choices);
|
|
43
|
+
throw new Error(
|
|
44
|
+
ErrorId.AMBIGUOUS_DEPENDENCY,
|
|
45
|
+
`The UI of package '${packageName}' requires the ambiguous interface ${renderedSpec}. Possible choices are: ${renderedChoices}.`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
getServices: (packageName, interfaceName) => {
|
|
51
|
+
const result = this.serviceLayer.getServices(packageName, interfaceName);
|
|
52
|
+
if (result.type === "found") {
|
|
53
|
+
return result.value.map((serviceRepr) => serviceRepr.getInstanceOrThrow());
|
|
54
|
+
}
|
|
55
|
+
switch (result.type) {
|
|
56
|
+
case "undeclared":
|
|
57
|
+
throw new Error(
|
|
58
|
+
ErrorId.UNDECLARED_DEPENDENCY,
|
|
59
|
+
`Package '${packageName}' did not declare an UI dependency on all services implementing interface '${interfaceName}'. Add the dependency ("all": true) to the package configuration or remove the usage.`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
getProperties: (packageName) => {
|
|
64
|
+
return this.getPackage(packageName).properties;
|
|
65
|
+
},
|
|
66
|
+
getIntl: (packageName) => {
|
|
67
|
+
return this.getPackage(packageName).intl;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
render(Component, props) {
|
|
72
|
+
this.root.render(
|
|
73
|
+
/* @__PURE__ */ jsx(StrictMode, { children: /* @__PURE__ */ jsx(CustomChakraProvider, { container: this.containerNode, colorMode: "light", children: /* @__PURE__ */ jsx(PackageContext.Provider, { value: this.packageContext, children: /* @__PURE__ */ jsx(Component, { ...props }) }) }) })
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
destroy() {
|
|
77
|
+
this.root.unmount();
|
|
78
|
+
}
|
|
79
|
+
getPackage(packageName) {
|
|
80
|
+
const pkg = this.packages.get(packageName);
|
|
81
|
+
if (!pkg) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
ErrorId.INTERNAL,
|
|
84
|
+
`Package '${packageName}' was not found in application.`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
return pkg;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { ReactIntegration };
|
|
92
|
+
//# sourceMappingURL=ReactIntegration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactIntegration.js","sources":["open-pioneer://external-pioneer-packages/@open-pioneer/runtime/react-integration/ReactIntegration.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { ComponentType, StrictMode } from \"react\";\nimport { createRoot, Root } from \"react-dom/client\";\nimport { Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\nimport { ServiceLayer } from \"../service-layer/ServiceLayer\";\nimport { PackageContext, PackageContextMethods } from \"./PackageContext\";\nimport { PackageRepr } from \"../service-layer/PackageRepr\";\nimport { InterfaceSpec, renderInterfaceSpec } from \"../service-layer/InterfaceSpec\";\nimport { renderAmbiguousServiceChoices } from \"../service-layer/ServiceLookup\";\nimport { CustomChakraProvider } from \"@open-pioneer/chakra-integration\";\n\nexport interface ReactIntegrationOptions {\n packages: Map<string, PackageRepr>;\n serviceLayer: ServiceLayer;\n rootNode: HTMLDivElement;\n container: Node;\n}\n\nexport class ReactIntegration {\n private containerNode: Node;\n private packages: Map<string, PackageRepr>;\n private serviceLayer: ServiceLayer;\n private root: Root;\n private packageContext: PackageContextMethods;\n\n constructor(options: ReactIntegrationOptions) {\n this.containerNode = options.container;\n this.packages = options.packages;\n this.serviceLayer = options.serviceLayer;\n this.root = createRoot(options.rootNode);\n this.packageContext = {\n getService: (packageName, interfaceName, options) => {\n const spec: InterfaceSpec = { interfaceName, ...options };\n const result = this.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 }\n },\n getServices: (packageName, interfaceName) => {\n const result = this.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 }\n },\n getProperties: (packageName) => {\n return this.getPackage(packageName).properties;\n },\n getIntl: (packageName) => {\n return this.getPackage(packageName).intl;\n }\n };\n }\n\n render(Component: ComponentType, props: Record<string, unknown>) {\n this.root.render(\n <StrictMode>\n <CustomChakraProvider container={this.containerNode} colorMode=\"light\">\n <PackageContext.Provider value={this.packageContext}>\n <Component {...props} />\n </PackageContext.Provider>\n </CustomChakraProvider>\n </StrictMode>\n );\n }\n\n destroy() {\n this.root.unmount();\n }\n\n private getPackage(packageName: string): PackageRepr {\n const pkg = this.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"],"names":["options"],"mappings":";;;;;;;;;;AAoBO,MAAM,gBAAiB,CAAA;AAAA,EAClB,aAAA,CAAA;AAAA,EACA,QAAA,CAAA;AAAA,EACA,YAAA,CAAA;AAAA,EACA,IAAA,CAAA;AAAA,EACA,cAAA,CAAA;AAAA,EAER,YAAY,OAAkC,EAAA;AAC1C,IAAA,IAAA,CAAK,gBAAgB,OAAQ,CAAA,SAAA,CAAA;AAC7B,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA,CAAA;AACxB,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA,CAAA;AAC5B,IAAK,IAAA,CAAA,IAAA,GAAO,UAAW,CAAA,OAAA,CAAQ,QAAQ,CAAA,CAAA;AACvC,IAAA,IAAA,CAAK,cAAiB,GAAA;AAAA,MAClB,UAAY,EAAA,CAAC,WAAa,EAAA,aAAA,EAAeA,QAAY,KAAA;AACjD,QAAA,MAAM,IAAsB,GAAA,EAAE,aAAe,EAAA,GAAGA,QAAQ,EAAA,CAAA;AACxD,QAAA,MAAM,MAAS,GAAA,IAAA,CAAK,YAAa,CA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