@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.
- package/CHANGELOG.md +18 -0
- package/CustomElement.d.ts +111 -0
- package/CustomElement.js.map +1 -1
- package/PropertiesRegistry.d.ts +19 -0
- package/Service.d.ts +63 -0
- package/ServiceRegistry.d.ts +25 -0
- package/api.d.ts +76 -0
- package/builtin-services/ApiServiceImpl.d.ts +11 -0
- package/builtin-services/ApiServiceImpl.js.map +1 -1
- package/builtin-services/ApplicationContextImpl.d.ts +18 -0
- package/builtin-services/ApplicationContextImpl.js.map +1 -1
- package/builtin-services/ApplicationLifecycleEventService.d.ts +12 -0
- package/builtin-services/ApplicationLifecycleEventService.js.map +1 -1
- package/builtin-services/index.d.ts +20 -0
- package/builtin-services/index.js.map +1 -1
- package/errors.d.ts +17 -0
- package/errors.js.map +1 -1
- package/i18n.d.ts +42 -0
- package/i18n.js.map +1 -1
- package/index.d.ts +6 -0
- package/metadata/ObservableBox.d.ts +23 -0
- package/metadata/ObservableBox.js.map +1 -1
- package/metadata/index.d.ts +115 -0
- package/package.json +9 -6
- package/react-integration/PackageContext.d.ts +11 -0
- package/react-integration/PackageContext.js.map +1 -1
- package/react-integration/ReactIntegration.d.ts +20 -0
- package/react-integration/ReactIntegration.js.map +1 -1
- package/react-integration/hooks.d.ts +46 -0
- package/react-integration/hooks.js.map +1 -1
- package/react-integration/index.d.ts +2 -0
- package/service-layer/InterfaceSpec.d.ts +22 -0
- package/service-layer/InterfaceSpec.js.map +1 -1
- package/service-layer/PackageRepr.d.ts +27 -0
- package/service-layer/PackageRepr.js.map +1 -1
- package/service-layer/ServiceLayer.d.ts +61 -0
- package/service-layer/ServiceLayer.js.map +1 -1
- package/service-layer/ServiceLookup.d.ts +46 -0
- package/service-layer/ServiceLookup.js.map +1 -1
- package/service-layer/ServiceRepr.d.ts +94 -0
- package/service-layer/ServiceRepr.js.map +1 -1
- package/service-layer/verifyDependencies.d.ts +42 -0
- package/service-layer/verifyDependencies.js.map +1 -1
package/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sources":["
|
|
1
|
+
{"version":3,"file":"errors.js","sources":["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.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IntlFormatters, IntlShape } from "@formatjs/intl";
|
|
2
|
+
import { ApplicationMetadata } from "./metadata";
|
|
3
|
+
/**
|
|
4
|
+
* Represents i18n info for the entire application.
|
|
5
|
+
* Currently not exposed to user code.
|
|
6
|
+
*/
|
|
7
|
+
export interface AppI18n {
|
|
8
|
+
/** Chosen locale */
|
|
9
|
+
readonly locale: string;
|
|
10
|
+
/** Supported locales from app metadata. */
|
|
11
|
+
readonly supportedLocales: string[];
|
|
12
|
+
/** Given the package name, constructs a package i18n instance. */
|
|
13
|
+
createPackageI18n(packageName: string): PackageIntl;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Gives access to the package's i18n messages for the current locale.
|
|
17
|
+
*
|
|
18
|
+
* See also https://formatjs.io/docs/intl
|
|
19
|
+
*/
|
|
20
|
+
export type PackageIntl = Pick<IntlShape, "locale" | "timeZone"> & IntlFormatters<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Initializes the application's locale and fetches the appropriate i18n messages.
|
|
23
|
+
*/
|
|
24
|
+
export declare function initI18n(appMetadata: ApplicationMetadata | undefined, forcedLocale: string | undefined): Promise<AppI18n>;
|
|
25
|
+
/** Creates an empty i18n instance, e.g. for tests. */
|
|
26
|
+
export declare function createEmptyI18n(locale?: string): PackageIntl;
|
|
27
|
+
export interface LocalePickResult {
|
|
28
|
+
/** The actual locale (e.g. en-US) for number and date formatting etc. */
|
|
29
|
+
locale: string;
|
|
30
|
+
/**
|
|
31
|
+
* The locale identifier to load messages for. E.g. "en".
|
|
32
|
+
*/
|
|
33
|
+
messageLocale: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Picks a locale for the app. Exported for tests.
|
|
37
|
+
*
|
|
38
|
+
* @param forcedLocale Optional forced locale (must be satisfied)
|
|
39
|
+
* @param appLocales Locales the app has i18n messages for (e.g. "en", "de")
|
|
40
|
+
* @param userLocales Locales requested by the user's browser
|
|
41
|
+
*/
|
|
42
|
+
export declare function pickLocale(forcedLocale: string | undefined, appLocales: string[], userLocales: string[]): LocalePickResult;
|
package/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","sources":["
|
|
1
|
+
{"version":3,"file":"i18n.js","sources":["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,MAA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AACT,MAAM,MAAA,WAAA,GAAc,UAAW,CAAA,IAAA,CAAK,IAAI,CAAA,CAAA;AACxC,MAAA,MAAM,IAAI,KAAA;AAAA,QACN,OAAQ,CAAA,kBAAA;AAAA,QACR,WAAW,YACmB,CAAA,yFAAA,EAAA,WAAA,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.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./api";
|
|
2
|
+
export { type PackageIntl } from "./i18n";
|
|
3
|
+
export { type ApplicationElement, type ApplicationElementConstructor, type ApplicationProperties, type ApplicationConfig, type CustomElementOptions, type ConfigContext, type RawApplicationProperties, createCustomElement } from "./CustomElement";
|
|
4
|
+
export * from "./Service";
|
|
5
|
+
export * from "./ServiceRegistry";
|
|
6
|
+
export * from "./PropertiesRegistry";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Resource } from "@open-pioneer/core";
|
|
2
|
+
export interface ObservableBox<T> {
|
|
3
|
+
/** The current value. */
|
|
4
|
+
readonly value: T;
|
|
5
|
+
/**
|
|
6
|
+
* Changes the current value.
|
|
7
|
+
*
|
|
8
|
+
* Note that this function is only present during development to facilitate hot reloading.
|
|
9
|
+
*/
|
|
10
|
+
setValue?(value: T): void;
|
|
11
|
+
/**
|
|
12
|
+
* Register a listener callback that will be invoked
|
|
13
|
+
* when the value changes.
|
|
14
|
+
*
|
|
15
|
+
* Note that this function is only present during development to facilitate hot reloading.
|
|
16
|
+
*/
|
|
17
|
+
on?(event: "changed", listener: () => void): Resource;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns a boxed value.
|
|
21
|
+
* In development node, the box value can be changed and observed.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createBox<T>(value: T): ObservableBox<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableBox.js","sources":["
|
|
1
|
+
{"version":3,"file":"ObservableBox.js","sources":["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,115 @@
|
|
|
1
|
+
import { ServiceConstructor } from "../Service";
|
|
2
|
+
import { ObservableBox } from "./ObservableBox";
|
|
3
|
+
/**
|
|
4
|
+
* Application metadata.
|
|
5
|
+
* Typically generated by the build system.
|
|
6
|
+
*/
|
|
7
|
+
export interface ApplicationMetadata {
|
|
8
|
+
/**
|
|
9
|
+
* Package metadata.
|
|
10
|
+
* Metadata structures contain information about services
|
|
11
|
+
* that are needed during runtime.
|
|
12
|
+
*
|
|
13
|
+
* Services provided by packages in this attribute will be started
|
|
14
|
+
* as necessary and can be referenced during runtime.
|
|
15
|
+
*/
|
|
16
|
+
packages?: Record<string, PackageMetadata>;
|
|
17
|
+
/**
|
|
18
|
+
* Styles for UI component.
|
|
19
|
+
*/
|
|
20
|
+
styles?: ObservableBox<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Locales supported by the application.
|
|
23
|
+
*/
|
|
24
|
+
locales?: string[];
|
|
25
|
+
/**
|
|
26
|
+
* Loads messages for the given locale.
|
|
27
|
+
* @returns A record of packageName -> (messageId, messageTemplate) entries.
|
|
28
|
+
*/
|
|
29
|
+
loadMessages?: (locale: string) => Promise<Record<string, Record<string, string>>>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Describes a package to the runtime.
|
|
33
|
+
*/
|
|
34
|
+
export interface PackageMetadata {
|
|
35
|
+
/** The globally unique name of the package. */
|
|
36
|
+
name: string;
|
|
37
|
+
/**
|
|
38
|
+
* Collection of services defined in the package.
|
|
39
|
+
*
|
|
40
|
+
* Key: unique service name within the package.
|
|
41
|
+
* Value: service metadata.
|
|
42
|
+
*/
|
|
43
|
+
services?: Record<string, ServiceMetadata>;
|
|
44
|
+
/**
|
|
45
|
+
* Metadata about the UI Components contained in this package.
|
|
46
|
+
*/
|
|
47
|
+
ui?: UiMetadata;
|
|
48
|
+
/**
|
|
49
|
+
* Metadata about properties of this package.
|
|
50
|
+
*/
|
|
51
|
+
properties?: Record<string, PropertyMetadata>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Describes a service to the runtime.
|
|
55
|
+
*/
|
|
56
|
+
export interface ServiceMetadata {
|
|
57
|
+
/** The unique name of the service in its package. */
|
|
58
|
+
name: string;
|
|
59
|
+
/** Service constructor responsible for creating a new instance. */
|
|
60
|
+
clazz: ServiceConstructor<any>;
|
|
61
|
+
/**
|
|
62
|
+
* Collection of references to other services.
|
|
63
|
+
* The runtime will inject the required services when possible
|
|
64
|
+
* or provide a diagnostic if not.
|
|
65
|
+
*
|
|
66
|
+
* Key: reference name.
|
|
67
|
+
* Value: reference metadata.
|
|
68
|
+
*/
|
|
69
|
+
references?: Record<string, InterfaceReferenceMetadata>;
|
|
70
|
+
/**
|
|
71
|
+
* Lists interfaces provided by this service.
|
|
72
|
+
*/
|
|
73
|
+
provides?: ProvidedInterfaceMetadata[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Describes a service reference to the runtime.
|
|
77
|
+
*/
|
|
78
|
+
export interface InterfaceReferenceMetadata {
|
|
79
|
+
/** The name of the referenced interface. */
|
|
80
|
+
name: string;
|
|
81
|
+
/** Additional qualifier to disambiguate interface requirements. */
|
|
82
|
+
qualifier?: string | undefined;
|
|
83
|
+
/** Inject all implementations as an array instead of a specific one. */
|
|
84
|
+
all?: boolean;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Describes a provided interface to the runtime.
|
|
88
|
+
*/
|
|
89
|
+
export interface ProvidedInterfaceMetadata {
|
|
90
|
+
/** The name of the provided interface. */
|
|
91
|
+
name: string;
|
|
92
|
+
/** Additional qualifier for disambiguation of multiple interface implementations. */
|
|
93
|
+
qualifier?: string | undefined;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Describes the UI to the runtime.
|
|
97
|
+
*/
|
|
98
|
+
export interface UiMetadata {
|
|
99
|
+
/**
|
|
100
|
+
* List of interface names required by the UI.
|
|
101
|
+
* Interfaces in this list can be used by calling the `useService` hook
|
|
102
|
+
* from a react component.
|
|
103
|
+
*/
|
|
104
|
+
references?: InterfaceReferenceMetadata[];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Metadata about a single property in a package.
|
|
108
|
+
*/
|
|
109
|
+
export interface PropertyMetadata {
|
|
110
|
+
/** Default json value defined by the package. */
|
|
111
|
+
value: unknown;
|
|
112
|
+
/** Whether the property must be specified by the application. */
|
|
113
|
+
required?: boolean;
|
|
114
|
+
}
|
|
115
|
+
export { type ObservableBox, createBox } from "./ObservableBox";
|
package/package.json
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/runtime",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@formatjs/intl": "^2.7.2",
|
|
8
8
|
"react": "^18.2.0",
|
|
9
9
|
"react-dom": "^18.2.0",
|
|
10
|
-
"@open-pioneer/chakra-integration": "^0.1.
|
|
11
|
-
"@open-pioneer/core": "^0.1.
|
|
10
|
+
"@open-pioneer/chakra-integration": "^0.1.2",
|
|
11
|
+
"@open-pioneer/core": "^0.1.2"
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
|
14
14
|
"./package.json": "./package.json",
|
|
15
15
|
".": {
|
|
16
|
-
"import": "./index.js"
|
|
16
|
+
"import": "./index.js",
|
|
17
|
+
"types": "./index.d.ts"
|
|
17
18
|
},
|
|
18
19
|
"./metadata": {
|
|
19
|
-
"import": "./metadata/index.js"
|
|
20
|
+
"import": "./metadata/index.js",
|
|
21
|
+
"types": "./metadata/index.d.ts"
|
|
20
22
|
},
|
|
21
23
|
"./react-integration": {
|
|
22
|
-
"import": "./react-integration/index.js"
|
|
24
|
+
"import": "./react-integration/index.js",
|
|
25
|
+
"types": "./react-integration/index.d.ts"
|
|
23
26
|
}
|
|
24
27
|
},
|
|
25
28
|
"openPioneerFramework": {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PackageIntl } from "../i18n";
|
|
3
|
+
import { Service } from "../Service";
|
|
4
|
+
import { UseServiceOptions } from "./hooks";
|
|
5
|
+
export interface PackageContextMethods {
|
|
6
|
+
getService: (packageName: string, interfaceName: string, options: UseServiceOptions) => Service;
|
|
7
|
+
getServices: (packageName: string, interfaceName: string) => Service[];
|
|
8
|
+
getProperties: (packageName: string) => Readonly<Record<string, unknown>>;
|
|
9
|
+
getIntl(packageName: string): PackageIntl;
|
|
10
|
+
}
|
|
11
|
+
export declare const PackageContext: import("react").Context<PackageContextMethods | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageContext.js","sources":["
|
|
1
|
+
{"version":3,"file":"PackageContext.js","sources":["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,20 @@
|
|
|
1
|
+
import { ComponentType } from "react";
|
|
2
|
+
import { ServiceLayer } from "../service-layer/ServiceLayer";
|
|
3
|
+
import { PackageRepr } from "../service-layer/PackageRepr";
|
|
4
|
+
export interface ReactIntegrationOptions {
|
|
5
|
+
packages: Map<string, PackageRepr>;
|
|
6
|
+
serviceLayer: ServiceLayer;
|
|
7
|
+
rootNode: HTMLDivElement;
|
|
8
|
+
container: Node;
|
|
9
|
+
}
|
|
10
|
+
export declare class ReactIntegration {
|
|
11
|
+
private containerNode;
|
|
12
|
+
private packages;
|
|
13
|
+
private serviceLayer;
|
|
14
|
+
private root;
|
|
15
|
+
private packageContext;
|
|
16
|
+
constructor(options: ReactIntegrationOptions);
|
|
17
|
+
render(Component: ComponentType, props: Record<string, unknown>): void;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
private getPackage;
|
|
20
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactIntegration.js","sources":["
|
|
1
|
+
{"version":3,"file":"ReactIntegration.js","sources":["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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AW,WAAkC,EAAA;AACjD,IAAA,MAAM,GAAM,GAAA,IAAA,CAAK,QAAS,CAAA,GAAA,CAAI,WAAW,CAAA,CAAA;AACzC,IAAA,IAAI,CAAC,GAAK,EAAA;AACN,MAAA,MAAM,IAAI,KAAA;AAAA,QACN,OAAQ,CAAA,QAAA;AAAA,QACR,CAAY,SAAA,EAAA,WAAA,CAAA,+BAAA,CAAA;AAAA,OAChB,CAAA;AAAA,KACJ;AACA,IAAO,OAAA,GAAA,CAAA;AAAA,GACX;AACJ;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { InterfaceName, ServiceType } from "../ServiceRegistry";
|
|
2
|
+
import { PackageIntl } from "../i18n";
|
|
3
|
+
export interface UseServiceOptions {
|
|
4
|
+
/** An additional qualifier to disambiguate service instances that implement the same interface. */
|
|
5
|
+
qualifier?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns a service that implements the given interface.
|
|
9
|
+
* Receives the package name of the importing package as a string.
|
|
10
|
+
*
|
|
11
|
+
* This is an internal hook that is typically called indirectly via the hook
|
|
12
|
+
* provided from `"open-pioneer:react-hooks"`.
|
|
13
|
+
*
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
export declare function useServiceInternal<Interface extends InterfaceName>(packageName: string, interfaceName: Interface, options?: UseServiceOptions): ServiceType<Interface>;
|
|
17
|
+
export declare function useServiceInternal(packageName: string, interfaceName: string, options?: UseServiceOptions): unknown;
|
|
18
|
+
/**
|
|
19
|
+
* Returns all services that implement the given interface.
|
|
20
|
+
* Receives the package name of the importing package as a string.
|
|
21
|
+
*
|
|
22
|
+
* This is an internal hook that is typically called indirectly via the hook
|
|
23
|
+
* provided from `"open-pioneer:react-hooks"`.
|
|
24
|
+
*
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
export declare function useServicesInternal<Interface extends InterfaceName>(packageName: string, interfaceName: Interface): ServiceType<Interface>[];
|
|
28
|
+
export declare function useServicesInternal(packageName: string, interfaceName: string): unknown[];
|
|
29
|
+
/**
|
|
30
|
+
* Returns the properties for the given package.
|
|
31
|
+
*
|
|
32
|
+
* This is an internal hook that is typically called indirectly via the hook
|
|
33
|
+
* provided from `"open-pioneer:react-hooks"`.
|
|
34
|
+
*
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
export declare function usePropertiesInternal(packageName: string): Readonly<Record<string, unknown>>;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the i18n object for the given package.
|
|
40
|
+
*
|
|
41
|
+
* This is an internal hook that is typically called indirectly via the hook
|
|
42
|
+
* provided from `"open-pioneer:react-hooks"`.
|
|
43
|
+
*
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
export declare function useIntlInternal(packageName: string): PackageIntl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sources":["
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["hooks.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { useContext, useMemo } from \"react\";\nimport { Error } from \"@open-pioneer/core\";\nimport { InterfaceName, ServiceType } from \"../ServiceRegistry\";\nimport { PackageContext as PackageContext, PackageContextMethods } from \"./PackageContext\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl } from \"../i18n\";\n\n/*\n\n IMPORTANT\n =========\n\n The functions in this file are part of the public API.\n They are imported by code generated during separate package generation via:\n\n import { hookName } from '@open-pioneer/runtime/react-integration'\n\n The matching exports are in the neighboring `index.ts`.\n The interfaces of these hooks must remain stable so that already published packages can continue to work in the future.\n\n See also the implementation of @open-pioneer/build-package.\n\n*/\n\nexport interface UseServiceOptions {\n /** An additional qualifier to disambiguate service instances that implement the same interface. */\n qualifier?: string;\n}\n\n/**\n * Returns a service that implements the given interface.\n * Receives the package name of the importing package as a string.\n *\n * This is an internal hook that is typically called indirectly via the hook\n * provided from `\"open-pioneer:react-hooks\"`.\n *\n * @private\n */\nexport function useServiceInternal<Interface extends InterfaceName>(\n packageName: string,\n interfaceName: Interface,\n options?: UseServiceOptions\n): ServiceType<Interface>;\nexport function useServiceInternal(\n packageName: string,\n interfaceName: string,\n options?: UseServiceOptions\n): unknown;\nexport function useServiceInternal(\n packageName: string,\n interfaceName: string,\n options?: UseServiceOptions\n): unknown {\n const context = useContext(PackageContext);\n const service = useMemo(\n () =>\n checkContext(\"useService\", context).getService(\n packageName,\n interfaceName,\n options ?? {}\n ),\n [context, packageName, interfaceName, options]\n );\n return service;\n}\n\n/**\n * Returns all services that implement the given interface.\n * Receives the package name of the importing package as a string.\n *\n * This is an internal hook that is typically called indirectly via the hook\n * provided from `\"open-pioneer:react-hooks\"`.\n *\n * @private\n */\nexport function useServicesInternal<Interface extends InterfaceName>(\n packageName: string,\n interfaceName: Interface\n): ServiceType<Interface>[];\nexport function useServicesInternal(packageName: string, interfaceName: string): unknown[];\nexport function useServicesInternal(packageName: string, interfaceName: string): unknown[] {\n const context = useContext(PackageContext);\n const services = useMemo(\n () => checkContext(\"useServices\", context).getServices(packageName, interfaceName),\n [context, packageName, interfaceName]\n );\n return services;\n}\n\n/**\n * Returns the properties for the given package.\n *\n * This is an internal hook that is typically called indirectly via the hook\n * provided from `\"open-pioneer:react-hooks\"`.\n *\n * @private\n */\nexport function usePropertiesInternal(packageName: string): Readonly<Record<string, unknown>> {\n const context = useContext(PackageContext);\n return checkContext(\"useProperties\", context).getProperties(packageName);\n}\n\n/**\n * Returns the i18n object for the given package.\n *\n * This is an internal hook that is typically called indirectly via the hook\n * provided from `\"open-pioneer:react-hooks\"`.\n *\n * @private\n */\nexport function useIntlInternal(packageName: string): PackageIntl {\n const context = useContext(PackageContext);\n return checkContext(\"useIntl\", context).getIntl(packageName);\n}\n\nfunction checkContext(\n hookName: string,\n contextData: PackageContextMethods | null\n): PackageContextMethods {\n if (!contextData) {\n throw new Error(\n ErrorId.INTERNAL,\n `\"Failed to access package context from '${hookName}': react integration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,CAAC,WAAa,EAAA;AACd,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,OAAQ,CAAA,QAAA;AAAA,MACR,CAA2C,wCAAA,EAAA,QAAA,CAAA,6CAAA,CAAA;AAAA,KAC/C,CAAA;AAAA,GACJ;AACA,EAAO,OAAA,WAAA,CAAA;AACX;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InterfaceReferenceMetadata } from "../metadata";
|
|
2
|
+
/**
|
|
3
|
+
* Describes the implementation of an interface.
|
|
4
|
+
*/
|
|
5
|
+
export interface InterfaceSpec {
|
|
6
|
+
interfaceName: string;
|
|
7
|
+
qualifier?: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare function renderInterfaceSpec({ interfaceName, qualifier }: InterfaceSpec): string;
|
|
10
|
+
export interface SingleImplementationSpec extends InterfaceSpec {
|
|
11
|
+
all?: undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface AllImplementationsSpec extends Pick<InterfaceSpec, "interfaceName"> {
|
|
14
|
+
all: true;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Describes a reference to one or more implementations of an interface.
|
|
18
|
+
*/
|
|
19
|
+
export type ReferenceSpec = SingleImplementationSpec | AllImplementationsSpec;
|
|
20
|
+
export declare function parseReferenceSpec(metadata: InterfaceReferenceMetadata): ReferenceSpec;
|
|
21
|
+
export declare function isSingleImplementationSpec(spec: ReferenceSpec): spec is SingleImplementationSpec;
|
|
22
|
+
export declare function isAllImplementationsSpec(spec: ReferenceSpec): spec is AllImplementationsSpec;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InterfaceSpec.js","sources":["
|
|
1
|
+
{"version":3,"file":"InterfaceSpec.js","sources":["InterfaceSpec.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\nimport { InterfaceReferenceMetadata } from \"../metadata\";\n\n/**\n * Describes the implementation of an interface.\n */\nexport interface InterfaceSpec {\n interfaceName: string;\n qualifier?: string | undefined;\n}\n\nexport function renderInterfaceSpec({ interfaceName, qualifier }: InterfaceSpec): string {\n return `'${interfaceName}'` + (qualifier ? ` (qualifier: '${qualifier}')` : \"\");\n}\n\nexport interface SingleImplementationSpec extends InterfaceSpec {\n all?: undefined;\n}\n\nexport interface AllImplementationsSpec extends Pick<InterfaceSpec, \"interfaceName\"> {\n all: true;\n}\n\n/**\n * Describes a reference to one or more implementations of an interface.\n */\nexport type ReferenceSpec = SingleImplementationSpec | AllImplementationsSpec;\n\nexport function parseReferenceSpec(metadata: InterfaceReferenceMetadata): ReferenceSpec {\n if (!metadata) {\n throw new Error(ErrorId.INVALID_METADATA, \"Missing reference metadata.\");\n }\n if (metadata.all && metadata.qualifier) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n \"References can't use 'qualifier' and 'all' properties at the same time.\"\n );\n }\n if (metadata.all) {\n return {\n all: true,\n interfaceName: metadata.name\n };\n }\n return {\n interfaceName: metadata.name,\n qualifier: metadata.qualifier\n };\n}\n\nexport function isSingleImplementationSpec(spec: ReferenceSpec): spec is SingleImplementationSpec {\n return !spec.all;\n}\n\nexport function isAllImplementationsSpec(spec: ReferenceSpec): spec is AllImplementationsSpec {\n return spec.all === true;\n}\n"],"names":[],"mappings":";;;AAcO,SAAS,mBAAoB,CAAA,EAAE,aAAe,EAAA,SAAA,EAAoC,EAAA;AACrF,EAAA,OAAO,CAAI,CAAA,EAAA,aAAA,CAAA,CAAA,CAAA,IAAoB,SAAY,GAAA,CAAA,cAAA,EAAiB,SAAgB,CAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAA;AAChF,CAAA;AAeO,SAAS,mBAAmB,QAAqD,EAAA;AACpF,EAAA,IAAI,CAAC,QAAU,EAAA;AACX,IAAA,MAAM,IAAI,KAAA,CAAM,OAAQ,CAAA,gBAAA,EAAkB,6BAA6B,CAAA,CAAA;AAAA,GAC3E;AACA,EAAI,IAAA,QAAA,CAAS,GAAO,IAAA,QAAA,CAAS,SAAW,EAAA;AACpC,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,OAAQ,CAAA,gBAAA;AAAA,MACR,yEAAA;AAAA,KACJ,CAAA;AAAA,GACJ;AACA,EAAA,IAAI,SAAS,GAAK,EAAA;AACd,IAAO,OAAA;AAAA,MACH,GAAK,EAAA,IAAA;AAAA,MACL,eAAe,QAAS,CAAA,IAAA;AAAA,KAC5B,CAAA;AAAA,GACJ;AACA,EAAO,OAAA;AAAA,IACH,eAAe,QAAS,CAAA,IAAA;AAAA,IACxB,WAAW,QAAS,CAAA,SAAA;AAAA,GACxB,CAAA;AACJ,CAAA;AAEO,SAAS,2BAA2B,IAAuD,EAAA;AAC9F,EAAA,OAAO,CAAC,IAAK,CAAA,GAAA,CAAA;AACjB,CAAA;AAEO,SAAS,yBAAyB,IAAqD,EAAA;AAC1F,EAAA,OAAO,KAAK,GAAQ,KAAA,IAAA,CAAA;AACxB;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ApplicationProperties } from "../CustomElement";
|
|
2
|
+
import { PackageIntl, AppI18n } from "../i18n";
|
|
3
|
+
import { PackageMetadata } from "../metadata";
|
|
4
|
+
import { ReferenceSpec } from "./InterfaceSpec";
|
|
5
|
+
import { ServiceRepr } from "./ServiceRepr";
|
|
6
|
+
export interface PackageReprOptions {
|
|
7
|
+
name: string;
|
|
8
|
+
intl: PackageIntl;
|
|
9
|
+
services?: ServiceRepr[];
|
|
10
|
+
uiReferences?: ReferenceSpec[];
|
|
11
|
+
properties?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export declare class PackageRepr {
|
|
14
|
+
static create(data: PackageMetadata, i18n: PackageIntl, customProperties?: Record<string, unknown>): PackageRepr;
|
|
15
|
+
/** Package name */
|
|
16
|
+
readonly name: string;
|
|
17
|
+
/** Services defined by the package */
|
|
18
|
+
readonly services: readonly ServiceRepr[];
|
|
19
|
+
/** Interfaces required by UI components. */
|
|
20
|
+
readonly uiReferences: readonly Readonly<ReferenceSpec>[];
|
|
21
|
+
/** Resolved (perhaps customized) package properties. */
|
|
22
|
+
readonly properties: Readonly<Record<string, unknown>>;
|
|
23
|
+
/** Locale-dependant i18n messages. */
|
|
24
|
+
readonly intl: PackageIntl;
|
|
25
|
+
constructor(options: PackageReprOptions);
|
|
26
|
+
}
|
|
27
|
+
export declare function createPackages(packages: Record<string, PackageMetadata>, i18n: AppI18n, customProperties?: ApplicationProperties): PackageRepr[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageRepr.js","sources":["
|
|
1
|
+
{"version":3,"file":"PackageRepr.js","sources":["PackageRepr.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { Error } from \"@open-pioneer/core\";\nimport { ApplicationProperties } from \"../CustomElement\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl, AppI18n } from \"../i18n\";\nimport { PackageMetadata, PropertyMetadata } from \"../metadata\";\nimport { parseReferenceSpec, ReferenceSpec } from \"./InterfaceSpec\";\nimport { ServiceRepr } from \"./ServiceRepr\";\n\nexport interface PackageReprOptions {\n name: string;\n intl: PackageIntl;\n services?: ServiceRepr[];\n uiReferences?: ReferenceSpec[];\n properties?: Record<string, unknown>;\n}\n\nexport class PackageRepr {\n static create(\n data: PackageMetadata,\n i18n: PackageIntl,\n customProperties?: Record<string, unknown>\n ): PackageRepr {\n const name = data.name;\n const properties = data.properties ?? {};\n const finalProperties = customizeProperties(name, properties, customProperties);\n const services = Object.entries(data.services ?? {}).map<ServiceRepr>(\n ([name, serviceData]) => {\n if (name !== serviceData.name) {\n throw new Error(\n ErrorId.INVALID_METADATA,\n \"Invalid metadata: service name mismatch.\"\n );\n }\n return ServiceRepr.create(data.name, serviceData, i18n, finalProperties);\n }\n );\n const uiReferences = data.ui?.references?.map((ref) => parseReferenceSpec(ref)) ?? [];\n return new PackageRepr({\n name,\n services,\n uiReferences,\n properties: finalProperties,\n intl: i18n\n });\n }\n\n /** Package name */\n readonly name: string;\n\n /** Services defined by the package */\n readonly services: readonly ServiceRepr[];\n\n /** Interfaces required by UI components. */\n readonly uiReferences: readonly Readonly<ReferenceSpec>[];\n\n /** Resolved (perhaps customized) package properties. */\n readonly properties: Readonly<Record<string, unknown>>;\n\n /** Locale-dependant i18n messages. */\n readonly intl: PackageIntl;\n\n constructor(options: PackageReprOptions) {\n const name = options.name;\n if (!isValidPackageName(name)) {\n throw new Error(ErrorId.INTERNAL, `Invalid package name: '${name}'.`);\n }\n\n this.name = name;\n this.services = options.services ?? [];\n this.uiReferences = options.uiReferences ?? [];\n this.properties = options.properties ?? {};\n this.intl = options.intl;\n }\n}\n\nexport function createPackages(\n packages: Record<string, PackageMetadata>,\n i18n: AppI18n,\n customProperties?: ApplicationProperties\n) {\n return Object.entries(packages).map<PackageRepr>(([name, packageMetadata]) => {\n if (name !== packageMetadata.name) {\n throw new Error(ErrorId.INVALID_METADATA, \"Invalid metadata: package name mismatch.\");\n }\n\n const packageI18n = i18n.createPackageI18n(name);\n return PackageRepr.create(packageMetadata, packageI18n, customProperties?.[name]);\n });\n}\n\n/**\n * Merges the declared properties of the package with the application-defined\n * custom properties.\n */\nfunction customizeProperties(\n packageName: string,\n properties: Record<string, PropertyMetadata>,\n customProperties: Record<string, unknown> = {}\n) {\n const merged: Record<string, unknown> = {};\n const required: string[] = [];\n for (const [key, propertyMetadata] of Object.entries(properties)) {\n merged[key] = propertyMetadata.value;\n if (propertyMetadata.required) {\n required.push(key);\n }\n }\n\n for (const [key, value] of Object.entries(customProperties)) {\n if (!hasProperty(merged, key)) {\n throw new Error(\n ErrorId.INVALID_PROPERTY_NAME,\n `Unexpected property name '${key}' for package '${packageName}': the property does not exist.`\n );\n }\n merged[key] = value;\n }\n\n for (const key of required) {\n const value = merged[key];\n if (value == null) {\n throw new Error(\n ErrorId.REQUIRED_PROPERTY,\n `Package '${packageName}' requires the property '${key}' to be initialized to a non-null value.`\n );\n }\n }\n\n return merged;\n}\n\nconst HAS_PROP = Object.prototype.hasOwnProperty;\n\nfunction hasProperty(object: unknown, key: string) {\n return HAS_PROP.call(object, key);\n}\n\n// http://json.schemastore.org/package\nconst NAME_REGEX = /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$/;\n\nfunction isValidPackageName(name: string): boolean {\n return NAME_REGEX.test(name);\n}\n"],"names":["name"],"mappings":";;;;;AAkBO,MAAM,WAAY,CAAA;AAAA,EACrB,OAAO,MAAA,CACH,IACA,EAAA,IAAA,EACA,gBACW,EAAA;AACX,IAAA,MAAM,OAAO,IAAK,CAAA,IAAA,CAAA;AAClB,IAAM,MAAA,UAAA,GAAa,IAAK,CAAA,UAAA,IAAc,EAAC,CAAA;AACvC,IAAA,MAAM,eAAkB,GAAA,mBAAA,CAAoB,IAAM,EAAA,UAAA,EAAY,gBAAgB,CAAA,CAAA;AAC9E,IAAA,MAAM,WAAW,MAAO,CAAA,OAAA,CAAQ,KAAK,QAAY,IAAA,EAAE,CAAE,CAAA,GAAA;AAAA,MACjD,CAAC,CAACA,KAAM,EAAA,WAAW,CAAM,KAAA;AACrB,QAAIA,IAAAA,KAAAA,KAAS,YAAY,IAAM,EAAA;AAC3B,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,OAAQ,CAAA,gBAAA;AAAA,YACR,0CAAA;AAAA,WACJ,CAAA;AAAA,SACJ;AACA,QAAA,OAAO,YAAY,MAAO,CAAA,IAAA,CAAK,IAAM,EAAA,WAAA,EAAa,MAAM,eAAe,CAAA,CAAA;AAAA,OAC3E;AAAA,KACJ,CAAA;AACA,IAAM,MAAA,YAAA,GAAe,IAAK,CAAA,EAAA,EAAI,UAAY,EAAA,GAAA,CAAI,CAAC,GAAA,KAAQ,kBAAmB,CAAA,GAAG,CAAC,CAAA,IAAK,EAAC,CAAA;AACpF,IAAA,OAAO,IAA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