@open-pioneer/runtime 4.7.0-dev.20260624141040 → 4.7.0-dev.20260713101438
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 +14 -1
- package/CustomElement.d.ts +27 -2
- package/CustomElement.js.map +1 -1
- package/_virtual/source-info.js +2 -2
- package/api.d.ts +55 -2
- package/app/AppInstance.d.ts +3 -27
- package/app/AppInstance.js +144 -119
- package/app/AppInstance.js.map +1 -1
- package/app/gatherConfig.js +1 -0
- package/app/gatherConfig.js.map +1 -1
- package/builtin-services/ApiServiceImpl.d.ts +1 -1
- package/builtin-services/ApiServiceImpl.js +3 -3
- package/builtin-services/ApiServiceImpl.js.map +1 -1
- package/builtin-services/ApplicationContextImpl.d.ts +11 -7
- package/builtin-services/ApplicationContextImpl.js +51 -10
- package/builtin-services/ApplicationContextImpl.js.map +1 -1
- package/builtin-services/LocaleServiceImpl.d.ts +18 -0
- package/builtin-services/LocaleServiceImpl.js +29 -0
- package/builtin-services/LocaleServiceImpl.js.map +1 -0
- package/builtin-services/NumberParserServiceImpl.d.ts +8 -3
- package/builtin-services/NumberParserServiceImpl.js +17 -12
- package/builtin-services/NumberParserServiceImpl.js.map +1 -1
- package/builtin-services/index.d.ts +3 -1
- package/builtin-services/index.js +34 -4
- package/builtin-services/index.js.map +1 -1
- package/dom/index.d.ts +1 -1
- package/dom/index.js +1 -4
- package/dom/index.js.map +1 -1
- package/i18n/AppIntl.d.ts +49 -11
- package/i18n/AppIntl.js +205 -87
- package/i18n/AppIntl.js.map +1 -1
- package/i18n/index.d.ts +3 -2
- package/i18n/index.js +2 -1
- package/i18n/index.js.map +1 -1
- package/i18n/intl-locale.d.ts +13 -0
- package/i18n/intl-locale.js +17 -0
- package/i18n/intl-locale.js.map +1 -0
- package/i18n/pick.d.ts +29 -16
- package/i18n/pick.js +78 -51
- package/i18n/pick.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +6 -0
- package/index.js.map +1 -1
- package/package.json +6 -5
- package/react-integration/ChakraProvider.d.ts +1 -1
- package/react-integration/ChakraProvider.js +3 -2
- package/react-integration/ChakraProvider.js.map +1 -1
- package/react-integration/PackageContext.d.ts +1 -1
- package/react-integration/PackageContext.js.map +1 -1
- package/react-integration/ReactIntegration.d.ts +2 -10
- package/react-integration/ReactIntegration.js +28 -28
- package/react-integration/ReactIntegration.js.map +1 -1
- package/react-integration/hooks.js +5 -9
- package/react-integration/hooks.js.map +1 -1
- package/service-layer/ServiceLayer.d.ts +1 -20
- package/service-layer/ServiceLayer.js +39 -39
- package/service-layer/ServiceLayer.js.map +1 -1
- package/service-layer/ServiceLookup.d.ts +1 -3
- package/service-layer/ServiceLookup.js +10 -10
- package/service-layer/ServiceLookup.js.map +1 -1
- package/service-layer/ServiceRepr.d.ts +2 -11
- package/service-layer/ServiceRepr.js +68 -50
- package/service-layer/ServiceRepr.js.map +1 -1
- package/service-layer/verifyDependencies.js +33 -33
- package/service-layer/verifyDependencies.js.map +1 -1
- package/test-support/index.js +2 -1
- package/test-support/index.js.map +1 -1
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { watchValue } from '@conterra/reactivity-core';
|
|
2
|
-
import { createLogger,
|
|
2
|
+
import { createLogger, Error, destroyResource, deprecated } from '@open-pioneer/core';
|
|
3
3
|
import { ErrorId } from '../errors.js';
|
|
4
4
|
import { IS_SERVICE_FACTORY } from '../Service.js';
|
|
5
5
|
import { parseReferenceSpec } from './InterfaceSpec.js';
|
|
6
6
|
|
|
7
7
|
const LOG = createLogger("runtime:ServiceRepr");
|
|
8
|
-
const intlDeprecation = deprecated({
|
|
9
|
-
name: "ServiceOptions.intl",
|
|
10
|
-
packageName: "@open-pioneer/runtime",
|
|
11
|
-
since: "4.5.1",
|
|
12
|
-
alternative: "use currentIntl instead and watch for changes where appropriate"
|
|
13
|
-
});
|
|
14
8
|
class ServiceRepr {
|
|
15
9
|
static create(packageName, data, intl, properties) {
|
|
16
10
|
const clazz = data.clazz;
|
|
@@ -55,15 +49,17 @@ class ServiceRepr {
|
|
|
55
49
|
/** Interfaces provided by the service. */
|
|
56
50
|
interfaces;
|
|
57
51
|
/** Number of references to this service. */
|
|
58
|
-
|
|
52
|
+
#useCount = 0;
|
|
59
53
|
/** Service factory to construct an instance. */
|
|
60
|
-
factory;
|
|
54
|
+
#factory;
|
|
61
55
|
/** Current state of this service. "constructed" -> instance is available. */
|
|
62
|
-
|
|
56
|
+
#state = "not-constructed";
|
|
63
57
|
/** Service instance, once constructed. */
|
|
64
|
-
|
|
58
|
+
#instance = void 0;
|
|
65
59
|
/** Used in dev mode only. */
|
|
66
|
-
|
|
60
|
+
#hmrState = void 0;
|
|
61
|
+
/** Lazily initialized deprecation message for this service. */
|
|
62
|
+
#intlDeprecation = void 0;
|
|
67
63
|
constructor(options) {
|
|
68
64
|
const {
|
|
69
65
|
name,
|
|
@@ -80,7 +76,7 @@ class ServiceRepr {
|
|
|
80
76
|
this.id = `${packageName}::${name}`;
|
|
81
77
|
this.name = name;
|
|
82
78
|
this.packageName = packageName;
|
|
83
|
-
this
|
|
79
|
+
this.#factory = factory;
|
|
84
80
|
this.intl = intl;
|
|
85
81
|
this.dependencies = dependencies;
|
|
86
82
|
this.interfaces = interfaces;
|
|
@@ -88,21 +84,21 @@ class ServiceRepr {
|
|
|
88
84
|
}
|
|
89
85
|
/** Returns the current service instance or undefined if the service has not been constructed. */
|
|
90
86
|
get instance() {
|
|
91
|
-
return this
|
|
87
|
+
return this.#instance;
|
|
92
88
|
}
|
|
93
89
|
/** Returns the current state of the service. */
|
|
94
90
|
get state() {
|
|
95
|
-
return this
|
|
91
|
+
return this.#state;
|
|
96
92
|
}
|
|
97
93
|
/** Returns the current reference count. */
|
|
98
94
|
get useCount() {
|
|
99
|
-
return this
|
|
95
|
+
return this.#useCount;
|
|
100
96
|
}
|
|
101
97
|
/**
|
|
102
98
|
* Same as `instance`, but throws when the instance has not been constructed.
|
|
103
99
|
*/
|
|
104
100
|
getInstanceOrThrow() {
|
|
105
|
-
const instance = this
|
|
101
|
+
const instance = this.#instance;
|
|
106
102
|
if (!instance) {
|
|
107
103
|
throw new Error(ErrorId.INTERNAL, "Expected service instance to be present.");
|
|
108
104
|
}
|
|
@@ -113,8 +109,8 @@ class ServiceRepr {
|
|
|
113
109
|
* which is currently used to detect cycles.
|
|
114
110
|
*/
|
|
115
111
|
beforeCreate() {
|
|
116
|
-
if (this
|
|
117
|
-
this
|
|
112
|
+
if (this.#state === "not-constructed") {
|
|
113
|
+
this.#state = "constructing";
|
|
118
114
|
} else {
|
|
119
115
|
throw new Error(
|
|
120
116
|
ErrorId.INTERNAL,
|
|
@@ -131,31 +127,30 @@ class ServiceRepr {
|
|
|
131
127
|
*
|
|
132
128
|
* `destroy()` can be invoked once the final `removeRef()` has returned zero.
|
|
133
129
|
*/
|
|
134
|
-
create(
|
|
135
|
-
if (this
|
|
130
|
+
create(references) {
|
|
131
|
+
if (this.#state !== "constructing" || this.instance !== void 0) {
|
|
136
132
|
throw new Error(
|
|
137
133
|
ErrorId.INTERNAL,
|
|
138
134
|
"Inconsistent state: service is not being constructed."
|
|
139
135
|
);
|
|
140
136
|
}
|
|
141
137
|
const intl = this.intl;
|
|
142
|
-
const hmrState = this
|
|
138
|
+
const hmrState = this.#hmrState = /* @__PURE__ */ createHmrState(this.id, intl);
|
|
143
139
|
try {
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
const options = createServiceOptions({
|
|
141
|
+
references,
|
|
146
142
|
properties: this.properties,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
return intl.value;
|
|
143
|
+
currentIntl: this.intl,
|
|
144
|
+
intlDeprecation: () => {
|
|
145
|
+
const deprecated2 = this.#intlDeprecation ??= createIntlDeprecation(this.id);
|
|
146
|
+
deprecated2();
|
|
153
147
|
},
|
|
154
|
-
|
|
148
|
+
hmrState
|
|
155
149
|
});
|
|
156
|
-
this
|
|
157
|
-
this
|
|
158
|
-
|
|
150
|
+
this.#instance = this.#factory.create(options);
|
|
151
|
+
this.#state = "constructed";
|
|
152
|
+
this.#useCount = 1;
|
|
153
|
+
return this.#instance;
|
|
159
154
|
} catch (e) {
|
|
160
155
|
throw new Error(
|
|
161
156
|
ErrorId.SERVICE_CONSTRUCTION_FAILED,
|
|
@@ -165,10 +160,10 @@ class ServiceRepr {
|
|
|
165
160
|
}
|
|
166
161
|
}
|
|
167
162
|
destroy() {
|
|
168
|
-
if (this
|
|
163
|
+
if (this.#instance) {
|
|
169
164
|
try {
|
|
170
|
-
this
|
|
171
|
-
this
|
|
165
|
+
this.#factory.destroy(this.#instance);
|
|
166
|
+
this.#hmrState = destroyResource(this.#hmrState);
|
|
172
167
|
} catch (e) {
|
|
173
168
|
throw new Error(
|
|
174
169
|
ErrorId.SERVICE_DESTRUCTION_FAILED,
|
|
@@ -177,22 +172,22 @@ class ServiceRepr {
|
|
|
177
172
|
);
|
|
178
173
|
}
|
|
179
174
|
}
|
|
180
|
-
this
|
|
181
|
-
this
|
|
175
|
+
this.#instance = void 0;
|
|
176
|
+
this.#state = "destroyed";
|
|
182
177
|
}
|
|
183
178
|
/**
|
|
184
179
|
* Adds a use to the service's use count.
|
|
185
180
|
* References to a service are tracked: it should only be destroyed when it is no longer being used.
|
|
186
181
|
*/
|
|
187
182
|
addRef() {
|
|
188
|
-
return this
|
|
183
|
+
return this.#useCount += 1;
|
|
189
184
|
}
|
|
190
185
|
/**
|
|
191
186
|
* Removes a use from the service's use count.
|
|
192
187
|
* Returns the new use count.
|
|
193
188
|
*/
|
|
194
189
|
removeRef() {
|
|
195
|
-
return this
|
|
190
|
+
return this.#useCount -= 1;
|
|
196
191
|
}
|
|
197
192
|
}
|
|
198
193
|
function createConstructorFactory(clazz) {
|
|
@@ -212,28 +207,28 @@ function createFactoryForServiceFactory(facClazz) {
|
|
|
212
207
|
return new ServiceFactoryInstanceFactory(facClazz);
|
|
213
208
|
}
|
|
214
209
|
class ServiceFactoryInstanceFactory {
|
|
215
|
-
|
|
216
|
-
|
|
210
|
+
#fac = void 0;
|
|
211
|
+
#facClazz;
|
|
212
|
+
constructor(facClazz) {
|
|
213
|
+
this.#facClazz = facClazz;
|
|
217
214
|
}
|
|
218
|
-
_facClazz;
|
|
219
|
-
_fac = void 0;
|
|
220
215
|
create(options) {
|
|
221
|
-
const fac = new this
|
|
216
|
+
const fac = new this.#facClazz(options);
|
|
222
217
|
const instance = fac.createService();
|
|
223
|
-
this
|
|
218
|
+
this.#fac = fac;
|
|
224
219
|
return instance;
|
|
225
220
|
}
|
|
226
221
|
destroy(srv) {
|
|
227
|
-
if (!this
|
|
222
|
+
if (!this.#fac) {
|
|
228
223
|
throw new Error(
|
|
229
224
|
ErrorId.INTERNAL,
|
|
230
225
|
"Inconsistent state: service factory instance is not present."
|
|
231
226
|
);
|
|
232
227
|
}
|
|
233
228
|
try {
|
|
234
|
-
this.
|
|
229
|
+
this.#fac.destroyService?.(srv);
|
|
235
230
|
} finally {
|
|
236
|
-
this
|
|
231
|
+
this.#fac = void 0;
|
|
237
232
|
}
|
|
238
233
|
}
|
|
239
234
|
}
|
|
@@ -272,6 +267,29 @@ function createHmrState(serviceId, intl) {
|
|
|
272
267
|
}
|
|
273
268
|
return hmrState;
|
|
274
269
|
}
|
|
270
|
+
function createServiceOptions(options) {
|
|
271
|
+
const { references, properties, currentIntl, intlDeprecation, hmrState } = options;
|
|
272
|
+
return {
|
|
273
|
+
...references,
|
|
274
|
+
properties,
|
|
275
|
+
get intl() {
|
|
276
|
+
intlDeprecation();
|
|
277
|
+
if (import.meta.hot) {
|
|
278
|
+
hmrState?.onIntlUsed();
|
|
279
|
+
}
|
|
280
|
+
return currentIntl.value;
|
|
281
|
+
},
|
|
282
|
+
currentIntl
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function createIntlDeprecation(serviceId) {
|
|
286
|
+
return deprecated({
|
|
287
|
+
name: `ServiceOptions.intl (used by ${serviceId})`,
|
|
288
|
+
packageName: "@open-pioneer/runtime",
|
|
289
|
+
since: "4.6.0",
|
|
290
|
+
alternative: "use currentIntl instead and watch for changes where appropriate"
|
|
291
|
+
});
|
|
292
|
+
}
|
|
275
293
|
const SERVICE_NAME_REGEX = /^[a-z0-9_-]+$/i;
|
|
276
294
|
function isValidServiceName(name) {
|
|
277
295
|
return SERVICE_NAME_REGEX.test(name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceRepr.js","sources":["ServiceRepr.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ReadonlyReactive, watchValue } from \"@conterra/reactivity-core\";\nimport { createLogger, deprecated, destroyResource, Error, Resource } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl } from \"../i18n\";\nimport { ServiceMetadata } from \"../metadata\";\nimport {\n IS_SERVICE_FACTORY,\n MarkedServiceFactoryConstructor,\n Service,\n ServiceConstructor,\n ServiceFactory,\n ServiceOptions\n} from \"../Service\";\nimport { InterfaceSpec, parseReferenceSpec, ReferenceSpec } from \"./InterfaceSpec\";\n\nconst LOG = createLogger(\"runtime:ServiceRepr\");\n\nexport type ServiceState = \"not-constructed\" | \"constructing\" | \"constructed\" | \"destroyed\";\n\nexport type ServiceDependency = ReferenceSpec & { referenceName: string };\n\nexport interface ServiceInstanceFactory {\n create(options: ServiceOptions): Service;\n destroy(srv: Service): void;\n}\n\nexport interface ServiceReprOptions {\n name: string;\n packageName: string;\n factory: ServiceInstanceFactory;\n intl: ReadonlyReactive<PackageIntl>;\n dependencies?: ServiceDependency[];\n interfaces?: InterfaceSpec[];\n properties?: Record<string, unknown>;\n}\n\ninterface HmrState extends Resource {\n /** Called when usage of `serviceOptions.intl` is detected at runtime. */\n onIntlUsed(): void;\n}\n\nconst intlDeprecation = deprecated({\n name: \"ServiceOptions.intl\",\n packageName: \"@open-pioneer/runtime\",\n since: \"4.5.1\",\n alternative: \"use currentIntl instead and watch for changes where appropriate\"\n});\n\n/**\n * Represents metadata and state of a service in the runtime.\n * `this.instance` is the actual service instance (when constructed).\n */\nexport class ServiceRepr {\n static create(\n packageName: string,\n data: ServiceMetadata,\n intl: ReadonlyReactive<PackageIntl>,\n properties?: Record<string, unknown>\n ): ServiceRepr {\n const clazz = data.clazz;\n const name = data.name;\n const dependencies = Object.entries(data.references ?? {}).map(\n ([name, referenceMetadata]) => {\n return {\n referenceName: name,\n ...parseReferenceSpec(referenceMetadata)\n };\n }\n );\n const interfaces = data.provides?.map<InterfaceSpec>((i) => {\n return {\n interfaceName: i.name,\n qualifier: i.qualifier\n };\n });\n const factory = createConstructorFactory(clazz);\n return new ServiceRepr({\n name,\n packageName,\n factory,\n intl,\n dependencies,\n interfaces,\n properties\n });\n }\n\n /** Unique id of this service. Contains the package name and the service name. */\n readonly id: string;\n\n /** Name of this service in it's package. */\n readonly name: string;\n\n /** Name of the parent package. */\n readonly packageName: string;\n\n /** Locale-dependant i18n messages. */\n readonly intl: ReadonlyReactive<PackageIntl>;\n\n /** Service properties made available via the service's constructor. */\n readonly properties: Readonly<Record<string, unknown>>;\n\n /** Dependencies required by the service constructor. */\n readonly dependencies: readonly ServiceDependency[];\n\n /** Interfaces provided by the service. */\n readonly interfaces: readonly Readonly<InterfaceSpec>[];\n\n /** Number of references to this service. */\n private _useCount = 0;\n\n /** Service factory to construct an instance. */\n private factory: ServiceInstanceFactory;\n\n /** Current state of this service. \"constructed\" -> instance is available. */\n private _state: ServiceState = \"not-constructed\";\n\n /** Service instance, once constructed. */\n private _instance: Service | undefined = undefined;\n\n /** Used in dev mode only. */\n private _hmrState: HmrState | undefined = undefined;\n\n constructor(options: ServiceReprOptions) {\n const {\n name,\n packageName,\n factory,\n intl,\n dependencies = [],\n interfaces = [],\n properties = {}\n } = options;\n if (!isValidServiceName(name)) {\n throw new Error(ErrorId.INTERNAL, `Invalid service name: '${name}'.`);\n }\n\n this.id = `${packageName}::${name}`;\n this.name = name;\n this.packageName = packageName;\n this.factory = factory;\n this.intl = intl;\n this.dependencies = dependencies;\n this.interfaces = interfaces;\n this.properties = properties;\n }\n\n /** Returns the current service instance or undefined if the service has not been constructed. */\n get instance(): Service | undefined {\n return this._instance;\n }\n\n /** Returns the current state of the service. */\n get state() {\n return this._state;\n }\n\n /** Returns the current reference count. */\n get useCount() {\n return this._useCount;\n }\n\n /**\n * Same as `instance`, but throws when the instance has not been constructed.\n */\n getInstanceOrThrow() {\n const instance = this._instance;\n if (!instance) {\n throw new Error(ErrorId.INTERNAL, \"Expected service instance to be present.\");\n }\n return instance;\n }\n\n /**\n * Called before `create()` to place the service into the `constructing` state,\n * which is currently used to detect cycles.\n */\n beforeCreate() {\n if (this._state === \"not-constructed\") {\n this._state = \"constructing\";\n } else {\n throw new Error(\n ErrorId.INTERNAL,\n \"Inconsistent state: service is already under construction.\"\n );\n }\n }\n\n /**\n * Instantiates the service by invoking the service constructor\n * with the given `options`.\n *\n * The service's use count is initialized to `1`, so every `create()`\n * should be paired with a `removeRef()`.\n *\n * `destroy()` can be invoked once the final `removeRef()` has returned zero.\n */\n create(options: Pick<ServiceOptions, \"references\" | \"referencesMeta\">) {\n if (this._state !== \"constructing\" || this.instance !== undefined) {\n throw new Error(\n ErrorId.INTERNAL,\n \"Inconsistent state: service is not being constructed.\"\n );\n }\n\n const intl = this.intl;\n const hmrState = (this._hmrState = /*#__PURE__*/ createHmrState(this.id, intl));\n try {\n this._instance = this.factory.create({\n ...options,\n properties: this.properties,\n get intl() {\n intlDeprecation();\n if (import.meta.hot) {\n hmrState?.onIntlUsed();\n }\n return intl.value;\n },\n currentIntl: this.intl\n });\n this._state = \"constructed\";\n this._useCount = 1;\n return this._instance;\n } catch (e) {\n throw new Error(\n ErrorId.SERVICE_CONSTRUCTION_FAILED,\n `Failed to create service instance '${this.id}'.`,\n { cause: e }\n );\n }\n }\n\n destroy() {\n if (this._instance) {\n try {\n this.factory.destroy(this._instance);\n this._hmrState = destroyResource(this._hmrState);\n } catch (e) {\n throw new Error(\n ErrorId.SERVICE_DESTRUCTION_FAILED,\n `Failed to destroy service instance '${this.id}'.`,\n { cause: e }\n );\n }\n }\n this._instance = undefined;\n this._state = \"destroyed\";\n }\n\n /**\n * Adds a use to the service's use count.\n * References to a service are tracked: it should only be destroyed when it is no longer being used.\n */\n addRef() {\n return (this._useCount += 1);\n }\n\n /**\n * Removes a use from the service's use count.\n * Returns the new use count.\n */\n removeRef() {\n return (this._useCount -= 1);\n }\n}\n\nexport function createConstructorFactory<T extends {}>(\n clazz: ServiceConstructor<T> | MarkedServiceFactoryConstructor<T>\n): ServiceInstanceFactory {\n // check if factory is a service factory constructor (has the IS_SERVICE_FACTORY symbol)\n if (IS_SERVICE_FACTORY in clazz) {\n return createFactoryForServiceFactory(clazz);\n }\n // Is a regular service constructor\n return {\n create(options: ServiceOptions<T>) {\n return new clazz(options);\n },\n destroy(instance: Service<T>) {\n instance.destroy?.();\n }\n };\n}\n\nexport function createFactoryForServiceFactory<T extends {}>(\n facClazz: MarkedServiceFactoryConstructor<T>\n): ServiceInstanceFactory {\n return new ServiceFactoryInstanceFactory(facClazz);\n}\n\nclass ServiceFactoryInstanceFactory<T extends {}> implements ServiceInstanceFactory {\n private _fac: ServiceFactory | undefined = undefined;\n\n constructor(private _facClazz: MarkedServiceFactoryConstructor<T>) {}\n\n create(options: ServiceOptions<T>) {\n const fac = new this._facClazz(options);\n const instance = fac.createService();\n this._fac = fac;\n return instance;\n }\n\n destroy(srv: Service) {\n if (!this._fac) {\n throw new Error(\n ErrorId.INTERNAL,\n \"Inconsistent state: service factory instance is not present.\"\n );\n }\n try {\n this._fac.destroyService?.(srv);\n } finally {\n this._fac = undefined;\n }\n }\n}\n\nexport function createFunctionFactory(\n create: (options: ServiceOptions) => Service\n): ServiceInstanceFactory {\n return {\n create,\n destroy(srv) {\n srv.destroy?.();\n }\n };\n}\n\n/**\n * Triggers a full page reload if:\n *\n * - We are in development mode (import.meta.hot) AND\n * - The service uses the deprecated `intl` option AND\n * - The messages changes due to a HMR event\n */\nfunction createHmrState(\n serviceId: string,\n intl: ReadonlyReactive<PackageIntl>\n): HmrState | undefined {\n let hmrState: HmrState | undefined;\n if (import.meta.hot) {\n let intlWatch: Resource | undefined = undefined;\n hmrState = {\n destroy() {\n intlWatch = destroyResource(intlWatch);\n },\n\n onIntlUsed() {\n if (intlWatch) {\n return;\n }\n\n intlWatch = watchValue(\n () => intl.value,\n (_newIntl, _, context) => {\n LOG.warn(\n `Service ${serviceId} has used the deprecated 'intl' option but messages have changed.` +\n ` Hot reloading of intl changes is only implemented ` +\n ` with 'currentIntl'.` +\n ` Triggering full reload.`\n );\n context.destroy();\n\n // TODO: Figure out a cleaner way to force vite to reload the application\n // https://github.com/open-pioneer/trails-core-packages/issues/164\n window.location.reload();\n }\n );\n }\n };\n }\n return hmrState;\n}\n\nconst SERVICE_NAME_REGEX = /^[a-z0-9_-]+$/i;\n\nfunction isValidServiceName(name: string) {\n return SERVICE_NAME_REGEX.test(name);\n}\n"],"names":["name"],"mappings":";;;;;;AAiBA,MAAM,GAAA,GAAM,aAAa,qBAAqB,CAAA;AA0B9C,MAAM,kBAAkB,UAAA,CAAW;AAAA,EAC/B,IAAA,EAAM,qBAAA;AAAA,EACN,WAAA,EAAa,uBAAA;AAAA,EACb,KAAA,EAAO,OAAA;AAAA,EACP,WAAA,EAAa;AACjB,CAAC,CAAA;AAMM,MAAM,WAAA,CAAY;AAAA,EACrB,OAAO,MAAA,CACH,WAAA,EACA,IAAA,EACA,MACA,UAAA,EACW;AACX,IAAA,MAAM,QAAQ,IAAA,CAAK,KAAA;AACnB,IAAA,MAAM,OAAO,IAAA,CAAK,IAAA;AAClB,IAAA,MAAM,eAAe,MAAA,CAAO,OAAA,CAAQ,KAAK,UAAA,IAAc,EAAE,CAAA,CAAE,GAAA;AAAA,MACvD,CAAC,CAACA,KAAAA,EAAM,iBAAiB,CAAA,KAAM;AAC3B,QAAA,OAAO;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A,EAAQ;AAIhB,YAAA,MAAA,CAAO,SAAS,MAAA,EAAO;AAAA,UAC3B;AAAA,SACJ;AAAA,MACJ;AAAA,KACJ;AAAA,EACJ;AACA,EAAA,OAAO,QAAA;AACX;AAEA,MAAM,kBAAA,GAAqB,gBAAA;AAE3B,SAAS,mBAAmB,IAAA,EAAc;AACtC,EAAA,OAAO,kBAAA,CAAmB,KAAK,IAAI,CAAA;AACvC;;;;"}
|
|
1
|
+
{"version":3,"file":"ServiceRepr.js","sources":["ServiceRepr.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ReadonlyReactive, watchValue } from \"@conterra/reactivity-core\";\nimport { createLogger, deprecated, destroyResource, Error, Resource } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\nimport { PackageIntl } from \"../i18n\";\nimport { ServiceMetadata } from \"../metadata\";\nimport {\n IS_SERVICE_FACTORY,\n MarkedServiceFactoryConstructor,\n Service,\n ServiceConstructor,\n ServiceFactory,\n ServiceOptions\n} from \"../Service\";\nimport { InterfaceSpec, parseReferenceSpec, ReferenceSpec } from \"./InterfaceSpec\";\n\nconst LOG = createLogger(\"runtime:ServiceRepr\");\n\nexport type ServiceState = \"not-constructed\" | \"constructing\" | \"constructed\" | \"destroyed\";\n\nexport type ServiceDependency = ReferenceSpec & { referenceName: string };\n\nexport interface ServiceInstanceFactory {\n create(options: ServiceOptions): Service;\n destroy(srv: Service): void;\n}\n\nexport interface ServiceReprOptions {\n name: string;\n packageName: string;\n factory: ServiceInstanceFactory;\n intl: ReadonlyReactive<PackageIntl>;\n dependencies?: ServiceDependency[];\n interfaces?: InterfaceSpec[];\n properties?: Record<string, unknown>;\n}\n\ninterface HmrState extends Resource {\n /** Called when usage of `serviceOptions.intl` is detected at runtime. */\n onIntlUsed(): void;\n}\n\n/**\n * Represents metadata and state of a service in the runtime.\n * `this.instance` is the actual service instance (when constructed).\n */\nexport class ServiceRepr {\n static create(\n packageName: string,\n data: ServiceMetadata,\n intl: ReadonlyReactive<PackageIntl>,\n properties?: Record<string, unknown>\n ): ServiceRepr {\n const clazz = data.clazz;\n const name = data.name;\n const dependencies = Object.entries(data.references ?? {}).map(\n ([name, referenceMetadata]) => {\n return {\n referenceName: name,\n ...parseReferenceSpec(referenceMetadata)\n };\n }\n );\n const interfaces = data.provides?.map<InterfaceSpec>((i) => {\n return {\n interfaceName: i.name,\n qualifier: i.qualifier\n };\n });\n const factory = createConstructorFactory(clazz);\n return new ServiceRepr({\n name,\n packageName,\n factory,\n intl,\n dependencies,\n interfaces,\n properties\n });\n }\n\n /** Unique id of this service. Contains the package name and the service name. */\n readonly id: string;\n\n /** Name of this service in it's package. */\n readonly name: string;\n\n /** Name of the parent package. */\n readonly packageName: string;\n\n /** Locale-dependant i18n messages. */\n readonly intl: ReadonlyReactive<PackageIntl>;\n\n /** Service properties made available via the service's constructor. */\n readonly properties: Readonly<Record<string, unknown>>;\n\n /** Dependencies required by the service constructor. */\n readonly dependencies: readonly ServiceDependency[];\n\n /** Interfaces provided by the service. */\n readonly interfaces: readonly Readonly<InterfaceSpec>[];\n\n /** Number of references to this service. */\n #useCount = 0;\n\n /** Service factory to construct an instance. */\n #factory: ServiceInstanceFactory;\n\n /** Current state of this service. \"constructed\" -> instance is available. */\n #state: ServiceState = \"not-constructed\";\n\n /** Service instance, once constructed. */\n #instance: Service | undefined = undefined;\n\n /** Used in dev mode only. */\n #hmrState: HmrState | undefined = undefined;\n\n /** Lazily initialized deprecation message for this service. */\n #intlDeprecation: (() => void) | undefined = undefined;\n\n constructor(options: ServiceReprOptions) {\n const {\n name,\n packageName,\n factory,\n intl,\n dependencies = [],\n interfaces = [],\n properties = {}\n } = options;\n if (!isValidServiceName(name)) {\n throw new Error(ErrorId.INTERNAL, `Invalid service name: '${name}'.`);\n }\n\n this.id = `${packageName}::${name}`;\n this.name = name;\n this.packageName = packageName;\n this.#factory = factory;\n this.intl = intl;\n this.dependencies = dependencies;\n this.interfaces = interfaces;\n this.properties = properties;\n }\n\n /** Returns the current service instance or undefined if the service has not been constructed. */\n get instance(): Service | undefined {\n return this.#instance;\n }\n\n /** Returns the current state of the service. */\n get state() {\n return this.#state;\n }\n\n /** Returns the current reference count. */\n get useCount() {\n return this.#useCount;\n }\n\n /**\n * Same as `instance`, but throws when the instance has not been constructed.\n */\n getInstanceOrThrow() {\n const instance = this.#instance;\n if (!instance) {\n throw new Error(ErrorId.INTERNAL, \"Expected service instance to be present.\");\n }\n return instance;\n }\n\n /**\n * Called before `create()` to place the service into the `constructing` state,\n * which is currently used to detect cycles.\n */\n beforeCreate() {\n if (this.#state === \"not-constructed\") {\n this.#state = \"constructing\";\n } else {\n throw new Error(\n ErrorId.INTERNAL,\n \"Inconsistent state: service is already under construction.\"\n );\n }\n }\n\n /**\n * Instantiates the service by invoking the service constructor\n * with the given `options`.\n *\n * The service's use count is initialized to `1`, so every `create()`\n * should be paired with a `removeRef()`.\n *\n * `destroy()` can be invoked once the final `removeRef()` has returned zero.\n */\n create(references: Pick<ServiceOptions, \"references\" | \"referencesMeta\">) {\n if (this.#state !== \"constructing\" || this.instance !== undefined) {\n throw new Error(\n ErrorId.INTERNAL,\n \"Inconsistent state: service is not being constructed.\"\n );\n }\n\n const intl = this.intl;\n const hmrState = (this.#hmrState = /*#__PURE__*/ createHmrState(this.id, intl));\n try {\n const options = createServiceOptions({\n references,\n properties: this.properties,\n currentIntl: this.intl,\n intlDeprecation: () => {\n const deprecated = (this.#intlDeprecation ??= createIntlDeprecation(this.id));\n deprecated();\n },\n hmrState\n });\n this.#instance = this.#factory.create(options);\n this.#state = \"constructed\";\n this.#useCount = 1;\n return this.#instance;\n } catch (e) {\n throw new Error(\n ErrorId.SERVICE_CONSTRUCTION_FAILED,\n `Failed to create service instance '${this.id}'.`,\n { cause: e }\n );\n }\n }\n\n destroy() {\n if (this.#instance) {\n try {\n this.#factory.destroy(this.#instance);\n this.#hmrState = destroyResource(this.#hmrState);\n } catch (e) {\n throw new Error(\n ErrorId.SERVICE_DESTRUCTION_FAILED,\n `Failed to destroy service instance '${this.id}'.`,\n { cause: e }\n );\n }\n }\n this.#instance = undefined;\n this.#state = \"destroyed\";\n }\n\n /**\n * Adds a use to the service's use count.\n * References to a service are tracked: it should only be destroyed when it is no longer being used.\n */\n addRef() {\n return (this.#useCount += 1);\n }\n\n /**\n * Removes a use from the service's use count.\n * Returns the new use count.\n */\n removeRef() {\n return (this.#useCount -= 1);\n }\n}\n\nexport function createConstructorFactory<T extends {}>(\n clazz: ServiceConstructor<T> | MarkedServiceFactoryConstructor<T>\n): ServiceInstanceFactory {\n // check if factory is a service factory constructor (has the IS_SERVICE_FACTORY symbol)\n if (IS_SERVICE_FACTORY in clazz) {\n return createFactoryForServiceFactory(clazz);\n }\n // Is a regular service constructor\n return {\n create(options: ServiceOptions<T>) {\n return new clazz(options);\n },\n destroy(instance: Service<T>) {\n instance.destroy?.();\n }\n };\n}\n\nexport function createFactoryForServiceFactory<T extends {}>(\n facClazz: MarkedServiceFactoryConstructor<T>\n): ServiceInstanceFactory {\n return new ServiceFactoryInstanceFactory(facClazz);\n}\n\nclass ServiceFactoryInstanceFactory<T extends {}> implements ServiceInstanceFactory {\n #fac: ServiceFactory | undefined = undefined;\n #facClazz: MarkedServiceFactoryConstructor<T>;\n\n constructor(facClazz: MarkedServiceFactoryConstructor<T>) {\n this.#facClazz = facClazz;\n }\n\n create(options: ServiceOptions<T>) {\n const fac = new this.#facClazz(options);\n const instance = fac.createService();\n this.#fac = fac;\n return instance;\n }\n\n destroy(srv: Service) {\n if (!this.#fac) {\n throw new Error(\n ErrorId.INTERNAL,\n \"Inconsistent state: service factory instance is not present.\"\n );\n }\n try {\n this.#fac.destroyService?.(srv);\n } finally {\n this.#fac = undefined;\n }\n }\n}\n\nexport function createFunctionFactory(\n create: (options: ServiceOptions) => Service\n): ServiceInstanceFactory {\n return {\n create,\n destroy(srv) {\n srv.destroy?.();\n }\n };\n}\n\n/**\n * Triggers a full page reload if:\n *\n * - We are in development mode (import.meta.hot) AND\n * - The service uses the deprecated `intl` option AND\n * - The messages changes due to a HMR event\n */\nfunction createHmrState(\n serviceId: string,\n intl: ReadonlyReactive<PackageIntl>\n): HmrState | undefined {\n let hmrState: HmrState | undefined;\n if (import.meta.hot) {\n let intlWatch: Resource | undefined = undefined;\n hmrState = {\n destroy() {\n intlWatch = destroyResource(intlWatch);\n },\n\n onIntlUsed() {\n if (intlWatch) {\n return;\n }\n\n intlWatch = watchValue(\n () => intl.value,\n (_newIntl, _, context) => {\n LOG.warn(\n `Service ${serviceId} has used the deprecated 'intl' option but messages have changed.` +\n ` Hot reloading of intl changes is only implemented ` +\n ` with 'currentIntl'.` +\n ` Triggering full reload.`\n );\n context.destroy();\n\n // TODO: Figure out a cleaner way to force vite to reload the application\n // https://github.com/open-pioneer/trails-core-packages/issues/164\n window.location.reload();\n }\n );\n }\n };\n }\n return hmrState;\n}\n\nfunction createServiceOptions(options: {\n references: Pick<ServiceOptions, \"references\" | \"referencesMeta\">;\n properties: Record<string, unknown>;\n currentIntl: ReadonlyReactive<PackageIntl>;\n intlDeprecation: () => void;\n hmrState: HmrState | undefined;\n}) {\n const { references, properties, currentIntl, intlDeprecation, hmrState } = options;\n return {\n ...references,\n properties,\n get intl() {\n intlDeprecation();\n if (import.meta.hot) {\n hmrState?.onIntlUsed();\n }\n return currentIntl.value;\n },\n currentIntl\n };\n}\n\nfunction createIntlDeprecation(serviceId: string) {\n return deprecated({\n name: `ServiceOptions.intl (used by ${serviceId})`,\n packageName: \"@open-pioneer/runtime\",\n since: \"4.6.0\",\n alternative: \"use currentIntl instead and watch for changes where appropriate\"\n });\n}\n\nconst SERVICE_NAME_REGEX = /^[a-z0-9_-]+$/i;\n\nfunction isValidServiceName(name: string) {\n return SERVICE_NAME_REGEX.test(name);\n}\n"],"names":["name","deprecated"],"mappings":";;;;;;AAiBA,MAAM,GAAA,GAAM,aAAa,qBAAqB,CAAA;AA8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IAAA,EAAc;AACtC,EAAA,OAAO,kBAAA,CAAmB,KAAK,IAAI,CAAA;AACvC;;;;"}
|
|
@@ -12,16 +12,16 @@ function verifyDependencies(options) {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
class Verifier {
|
|
15
|
-
requiredReferences;
|
|
16
|
-
items;
|
|
17
|
-
serviceLookup = new ServiceLookup();
|
|
18
|
-
serviceToGraphItem = /* @__PURE__ */ new Map();
|
|
15
|
+
#requiredReferences;
|
|
16
|
+
#items;
|
|
17
|
+
#serviceLookup = new ServiceLookup();
|
|
18
|
+
#serviceToGraphItem = /* @__PURE__ */ new Map();
|
|
19
19
|
// Stack of visited nodes
|
|
20
|
-
stack = [];
|
|
20
|
+
#stack = [];
|
|
21
21
|
constructor(options) {
|
|
22
|
-
this
|
|
22
|
+
this.#requiredReferences = options.requiredReferences ?? [];
|
|
23
23
|
const services = options.services ?? [];
|
|
24
|
-
const items = this
|
|
24
|
+
const items = this.#items = services.map((service) => {
|
|
25
25
|
return {
|
|
26
26
|
service,
|
|
27
27
|
state: "not-visited",
|
|
@@ -30,12 +30,12 @@ class Verifier {
|
|
|
30
30
|
});
|
|
31
31
|
for (const item of items) {
|
|
32
32
|
for (const spec of item.service.interfaces) {
|
|
33
|
-
this
|
|
33
|
+
this.#registerService(item, spec);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
verify() {
|
|
38
|
-
for (const ref of this
|
|
38
|
+
for (const ref of this.#requiredReferences) {
|
|
39
39
|
let interfaceRef;
|
|
40
40
|
switch (ref.type) {
|
|
41
41
|
case "framework":
|
|
@@ -49,35 +49,35 @@ class Verifier {
|
|
|
49
49
|
};
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
52
|
-
this
|
|
52
|
+
this.#visitReference(interfaceRef);
|
|
53
53
|
}
|
|
54
|
-
for (const item of this
|
|
55
|
-
this
|
|
54
|
+
for (const item of this.#items) {
|
|
55
|
+
this.#visitItem(item, "root");
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
getServiceLookup() {
|
|
59
|
-
return this
|
|
59
|
+
return this.#serviceLookup;
|
|
60
60
|
}
|
|
61
61
|
getComputedDependencies() {
|
|
62
62
|
return new Map(
|
|
63
|
-
this
|
|
63
|
+
this.#items.map((item) => {
|
|
64
64
|
return [item.service.id, item.dependencies];
|
|
65
65
|
})
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
|
-
visitItem(item, reason) {
|
|
69
|
-
const stack = this
|
|
68
|
+
#visitItem(item, reason) {
|
|
69
|
+
const stack = this.#stack;
|
|
70
70
|
const state = item.state;
|
|
71
71
|
if (state === "done") {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
if (state === "pending") {
|
|
75
|
-
this
|
|
75
|
+
this.#throwCycleError(item, reason);
|
|
76
76
|
}
|
|
77
77
|
stack.push([item, reason]);
|
|
78
78
|
item.state = "pending";
|
|
79
79
|
for (const dep of item.service.dependencies) {
|
|
80
|
-
item.dependencies[dep.referenceName] = this
|
|
80
|
+
item.dependencies[dep.referenceName] = this.#visitReference({
|
|
81
81
|
type: "service-reference",
|
|
82
82
|
service: item.service,
|
|
83
83
|
referenceName: dep.referenceName,
|
|
@@ -87,25 +87,25 @@ class Verifier {
|
|
|
87
87
|
item.state = "done";
|
|
88
88
|
stack.pop();
|
|
89
89
|
}
|
|
90
|
-
visitReference(ref) {
|
|
91
|
-
const itemOrItems = this
|
|
90
|
+
#visitReference(ref) {
|
|
91
|
+
const itemOrItems = this.#findServices(ref);
|
|
92
92
|
if (Array.isArray(itemOrItems)) {
|
|
93
93
|
for (const child of itemOrItems) {
|
|
94
|
-
this
|
|
94
|
+
this.#visitItem(child, ref);
|
|
95
95
|
}
|
|
96
96
|
return itemOrItems.map((item) => item.service);
|
|
97
97
|
} else {
|
|
98
|
-
this
|
|
98
|
+
this.#visitItem(itemOrItems, ref);
|
|
99
99
|
return itemOrItems.service;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
registerService(item, spec) {
|
|
103
|
-
this
|
|
104
|
-
this
|
|
102
|
+
#registerService(item, spec) {
|
|
103
|
+
this.#serviceLookup.register(item.service, spec);
|
|
104
|
+
this.#serviceToGraphItem.set(item.service, item);
|
|
105
105
|
}
|
|
106
|
-
findServices(ref) {
|
|
106
|
+
#findServices(ref) {
|
|
107
107
|
const spec = ref.value;
|
|
108
|
-
const lookupResult = this
|
|
108
|
+
const lookupResult = this.#serviceLookup.lookup(spec);
|
|
109
109
|
switch (lookupResult.type) {
|
|
110
110
|
case "unimplemented": {
|
|
111
111
|
const message = unimplementedInterfaceMessage(ref);
|
|
@@ -118,13 +118,13 @@ class Verifier {
|
|
|
118
118
|
}
|
|
119
119
|
const value = lookupResult.value;
|
|
120
120
|
if (Array.isArray(value)) {
|
|
121
|
-
return value.map((service) => this
|
|
121
|
+
return value.map((service) => this.#getGraphItem(service));
|
|
122
122
|
} else {
|
|
123
|
-
return this
|
|
123
|
+
return this.#getGraphItem(value);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
getGraphItem(service) {
|
|
127
|
-
const graphItem = this
|
|
126
|
+
#getGraphItem(service) {
|
|
127
|
+
const graphItem = this.#serviceToGraphItem.get(service);
|
|
128
128
|
if (!graphItem || graphItem.service !== service) {
|
|
129
129
|
throw new Error(
|
|
130
130
|
ErrorId.INTERNAL,
|
|
@@ -133,8 +133,8 @@ class Verifier {
|
|
|
133
133
|
}
|
|
134
134
|
return graphItem;
|
|
135
135
|
}
|
|
136
|
-
throwCycleError(item, reason) {
|
|
137
|
-
const stack = this
|
|
136
|
+
#throwCycleError(item, reason) {
|
|
137
|
+
const stack = this.#stack;
|
|
138
138
|
const ownIndex = stack.findIndex((entry) => entry[0] === item);
|
|
139
139
|
if (ownIndex === -1) {
|
|
140
140
|
throw new Error(ErrorId.INTERNAL, "Failed to find cycle participant on the stack.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyDependencies.js","sources":["verifyDependencies.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\nimport { InterfaceSpec, ReferenceSpec, renderInterfaceSpec } from \"./InterfaceSpec\";\nimport {\n AmbiguousChoice,\n ReadonlyServiceLookup,\n renderAmbiguousServiceChoices,\n ServiceLookup\n} from \"./ServiceLookup\";\nimport { ServiceRepr } from \"./ServiceRepr\";\n\nexport interface DependencyOptions {\n /**\n * All services known to the service layer.\n */\n services?: readonly ServiceRepr[];\n\n /**\n * References that must be satisfied by the services.\n */\n requiredReferences?: readonly RequiredReference[];\n}\n\nexport type RequiredReference = UIDependency | FrameworkDependency;\n\nexport type UIDependency = { type: \"ui\"; packageName: string } & ReferenceSpec;\n\nexport type FrameworkDependency = { type: \"framework\" } & ReferenceSpec;\n\nexport type ComputedServiceDependencies = Record<string, ServiceRepr | ServiceRepr[]>;\n\nexport interface VerifyDependenciesResult {\n /**\n * Precomputed dependencies for every service.\n *\n * Key: service id.\n */\n serviceDependencies: Map<string, ComputedServiceDependencies>;\n\n /**\n * Index structure mapping interface names to service instances.\n */\n serviceLookup: ReadonlyServiceLookup;\n}\n\n/**\n * Visits all services and ensures that their dependencies can be satisfied by each other without a cycle.\n *\n * Throws an error if a cycle is detected or if a required service is never implemented.\n *\n * @returns an object containing the service index and precomputed dependency information\n */\nexport function verifyDependencies(options: DependencyOptions): VerifyDependenciesResult {\n const verifier = new Verifier(options);\n verifier.verify();\n return {\n serviceLookup: verifier.getServiceLookup(),\n serviceDependencies: verifier.getComputedDependencies()\n };\n}\n\ninterface GraphItem {\n state: ItemState;\n service: ServiceRepr;\n dependencies: ComputedServiceDependencies;\n}\n\ntype ItemState = \"not-visited\" | \"pending\" | \"done\";\n\n/** The reason why a graph node is being visited. */\ntype ItemVisitReason = \"root\" | InterfaceReference;\n\ntype InterfaceReference =\n | {\n type: \"framework-reference\";\n value: ReferenceSpec;\n }\n | {\n type: \"ui-reference\";\n packageName: string;\n value: ReferenceSpec;\n }\n | {\n type: \"service-reference\";\n service: ServiceRepr;\n referenceName: string;\n value: ReferenceSpec;\n };\n\nclass Verifier {\n private requiredReferences: readonly RequiredReference[];\n private items: GraphItem[];\n private serviceLookup = new ServiceLookup();\n private serviceToGraphItem = new Map<ServiceRepr, GraphItem>();\n\n // Stack of visited nodes\n private stack: [item: GraphItem, reason: ItemVisitReason][] = [];\n\n constructor(options: DependencyOptions) {\n this.requiredReferences = options.requiredReferences ?? [];\n const services = options.services ?? [];\n const items = (this.items = services.map<GraphItem>((service) => {\n return {\n service: service,\n state: \"not-visited\",\n dependencies: {}\n };\n }));\n\n for (const item of items) {\n for (const spec of item.service.interfaces) {\n this.registerService(item, spec);\n }\n }\n }\n\n verify() {\n for (const ref of this.requiredReferences) {\n let interfaceRef: InterfaceReference;\n switch (ref.type) {\n case \"framework\":\n interfaceRef = { type: \"framework-reference\", value: ref };\n break;\n case \"ui\":\n interfaceRef = {\n type: \"ui-reference\",\n packageName: ref.packageName,\n value: ref\n };\n break;\n }\n this.visitReference(interfaceRef);\n }\n for (const item of this.items) {\n this.visitItem(item, \"root\");\n }\n }\n\n getServiceLookup() {\n return this.serviceLookup;\n }\n\n getComputedDependencies() {\n return new Map(\n this.items.map<[string, ComputedServiceDependencies]>((item) => {\n return [item.service.id, item.dependencies];\n })\n );\n }\n\n private visitItem(item: GraphItem, reason: ItemVisitReason) {\n const stack = this.stack;\n const state = item.state;\n if (state === \"done\") {\n return; // Item is initialized, cycle impossible\n }\n if (state === \"pending\") {\n this.throwCycleError(item, reason);\n }\n\n stack.push([item, reason]);\n item.state = \"pending\";\n for (const dep of item.service.dependencies) {\n item.dependencies[dep.referenceName] = this.visitReference({\n type: \"service-reference\",\n service: item.service,\n referenceName: dep.referenceName,\n value: dep\n });\n }\n item.state = \"done\";\n stack.pop();\n }\n\n private visitReference(ref: InterfaceReference) {\n const itemOrItems = this.findServices(ref);\n if (Array.isArray(itemOrItems)) {\n for (const child of itemOrItems) {\n this.visitItem(child, ref);\n }\n return itemOrItems.map((item) => item.service);\n } else {\n this.visitItem(itemOrItems, ref);\n return itemOrItems.service;\n }\n }\n\n private registerService(item: GraphItem, spec: InterfaceSpec) {\n this.serviceLookup.register(item.service, spec);\n this.serviceToGraphItem.set(item.service, item);\n }\n\n private findServices(ref: InterfaceReference): GraphItem | GraphItem[] {\n const spec = ref.value;\n const lookupResult = this.serviceLookup.lookup(spec);\n switch (lookupResult.type) {\n case \"unimplemented\": {\n const message = unimplementedInterfaceMessage(ref);\n throw new Error(ErrorId.INTERFACE_NOT_FOUND, message);\n }\n case \"ambiguous\": {\n const message = ambiguousInterfaceMessage(ref, lookupResult.choices);\n throw new Error(ErrorId.AMBIGUOUS_DEPENDENCY, message);\n }\n }\n\n const value = lookupResult.value;\n if (Array.isArray(value)) {\n return value.map((service) => this.getGraphItem(service));\n } else {\n return this.getGraphItem(value);\n }\n }\n\n private getGraphItem(service: ServiceRepr): GraphItem {\n const graphItem = this.serviceToGraphItem.get(service);\n if (!graphItem || graphItem.service !== service) {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find matching graph item for service '${service.id}'.`\n );\n }\n return graphItem;\n }\n\n private throwCycleError(item: GraphItem, reason: ItemVisitReason) {\n // Find the item on the stack (it must be there because we detected a cycle).\n const stack = this.stack;\n const ownIndex = stack.findIndex((entry) => entry[0] === item);\n if (ownIndex === -1) {\n throw new Error(ErrorId.INTERNAL, \"Failed to find cycle participant on the stack.\");\n }\n\n const cycleInfo = stack\n .slice(ownIndex)\n .concat([[item, reason]])\n .map<string>((entry, index) => {\n const item = entry[0];\n const reason = index === 0 ? \"root\" : entry[1]; // info before the cycle does not matter\n\n let message = `'${item.service.id}'`;\n if (typeof reason === \"object\") {\n message += ` (${referenceDetail(reason)})`;\n }\n return message;\n });\n throw new Error(\n ErrorId.DEPENDENCY_CYCLE,\n `Detected dependency cycle: ${cycleInfo.join(\" => \")}.`\n );\n }\n}\n\nfunction unimplementedInterfaceMessage(ref: InterfaceReference): string {\n const interfaceText = renderInterfaceSpec(ref.value);\n switch (ref.type) {\n case \"service-reference\":\n return `Service '${ref.service.id}' requires an unimplemented interface ${interfaceText} as dependency '${ref.referenceName}'.`;\n case \"ui-reference\":\n return `The UI of package '${ref.packageName}' requires an unimplemented interface ${interfaceText}.`;\n case \"framework-reference\":\n return `The framework requires an unimplemented interface ${interfaceText}.`;\n }\n}\n\nfunction ambiguousInterfaceMessage(ref: InterfaceReference, choices: AmbiguousChoice[]): string {\n const interfaceText = renderInterfaceSpec(ref.value);\n const serviceChoices = renderAmbiguousServiceChoices(choices);\n\n let message = \"\";\n switch (ref.type) {\n case \"service-reference\":\n message = `Service '${ref.service.id}' requires the ambiguous interface ${interfaceText} as dependency '${ref.referenceName}'.`;\n break;\n case \"ui-reference\":\n message = `The UI of package '${ref.packageName}' requires the ambiguous interface ${interfaceText}.`;\n break;\n case \"framework-reference\":\n message = `The framework requires the ambiguous interface ${interfaceText}.`;\n break;\n }\n message += ` Possible choices are ${serviceChoices}.`;\n return message;\n}\n\nfunction referenceDetail(reason: InterfaceReference) {\n switch (reason.type) {\n case \"service-reference\":\n return `'${reason.referenceName}' providing '${reason.value.interfaceName}'`;\n case \"ui-reference\":\n return `UI of package '${reason.packageName}' requiring '${reason.value.interfaceName}'`;\n case \"framework-reference\":\n return `framework requiring '${reason.value.interfaceName}'`;\n }\n}\n"],"names":["item","reason"],"mappings":";;;;;AAsDO,SAAS,mBAAmB,OAAA,EAAsD;AACrF,EAAA,MAAM,QAAA,GAAW,IAAI,QAAA,CAAS,OAAO,CAAA;AACrC,EAAA,QAAA,CAAS,MAAA,EAAO;AAChB,EAAA,OAAO;AAAA,IACH,aAAA,EAAe,SAAS,gBAAA,EAAiB;AAAA,IACzC,mBAAA,EAAqB,SAAS,uBAAA;AAAwB,GAC1D;AACJ;AA8BA,MAAM,QAAA,CAAS;AAAA,EACH,kBA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A,QAAQ,IAAI,IAAA;AAAM,IACd,KAAK,mBAAA;AACD,MAAA,OAAA,GAAU,CAAA,SAAA,EAAY,IAAI,OAAA,CAAQ,EAAE,sCAAsC,aAAa,CAAA,gBAAA,EAAmB,IAAI,aAAa,CAAA,EAAA,CAAA;AAC3H,MAAA;AAAA,IACJ,KAAK,cAAA;AACD,MAAA,OAAA,GAAU,CAAA,mBAAA,EAAsB,GAAA,CAAI,WAAW,CAAA,mCAAA,EAAsC,aAAa,CAAA,CAAA,CAAA;AAClG,MAAA;AAAA,IACJ,KAAK,qBAAA;AACD,MAAA,OAAA,GAAU,kDAAkD,aAAa,CAAA,CAAA,CAAA;AACzE,MAAA;AAAA;AAER,EAAA,OAAA,IAAW,yBAAyB,cAAc,CAAA,CAAA,CAAA;AAClD,EAAA,OAAO,OAAA;AACX;AAEA,SAAS,gBAAgB,MAAA,EAA4B;AACjD,EAAA,QAAQ,OAAO,IAAA;AAAM,IACjB,KAAK,mBAAA;AACD,MAAA,OAAO,IAAI,MAAA,CAAO,aAAa,CAAA,aAAA,EAAgB,MAAA,CAAO,MAAM,aAAa,CAAA,CAAA,CAAA;AAAA,IAC7E,KAAK,cAAA;AACD,MAAA,OAAO,kBAAkB,MAAA,CAAO,WAAW,CAAA,aAAA,EAAgB,MAAA,CAAO,MAAM,aAAa,CAAA,CAAA,CAAA;AAAA,IACzF,KAAK,qBAAA;AACD,MAAA,OAAO,CAAA,qBAAA,EAAwB,MAAA,CAAO,KAAA,CAAM,aAAa,CAAA,CAAA,CAAA;AAAA;AAErE;;;;"}
|
|
1
|
+
{"version":3,"file":"verifyDependencies.js","sources":["verifyDependencies.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Error } from \"@open-pioneer/core\";\nimport { ErrorId } from \"../errors\";\nimport { InterfaceSpec, ReferenceSpec, renderInterfaceSpec } from \"./InterfaceSpec\";\nimport {\n AmbiguousChoice,\n ReadonlyServiceLookup,\n renderAmbiguousServiceChoices,\n ServiceLookup\n} from \"./ServiceLookup\";\nimport { ServiceRepr } from \"./ServiceRepr\";\n\nexport interface DependencyOptions {\n /**\n * All services known to the service layer.\n */\n services?: readonly ServiceRepr[];\n\n /**\n * References that must be satisfied by the services.\n */\n requiredReferences?: readonly RequiredReference[];\n}\n\nexport type RequiredReference = UIDependency | FrameworkDependency;\n\nexport type UIDependency = { type: \"ui\"; packageName: string } & ReferenceSpec;\n\nexport type FrameworkDependency = { type: \"framework\" } & ReferenceSpec;\n\nexport type ComputedServiceDependencies = Record<string, ServiceRepr | ServiceRepr[]>;\n\nexport interface VerifyDependenciesResult {\n /**\n * Precomputed dependencies for every service.\n *\n * Key: service id.\n */\n serviceDependencies: Map<string, ComputedServiceDependencies>;\n\n /**\n * Index structure mapping interface names to service instances.\n */\n serviceLookup: ReadonlyServiceLookup;\n}\n\n/**\n * Visits all services and ensures that their dependencies can be satisfied by each other without a cycle.\n *\n * Throws an error if a cycle is detected or if a required service is never implemented.\n *\n * @returns an object containing the service index and precomputed dependency information\n */\nexport function verifyDependencies(options: DependencyOptions): VerifyDependenciesResult {\n const verifier = new Verifier(options);\n verifier.verify();\n return {\n serviceLookup: verifier.getServiceLookup(),\n serviceDependencies: verifier.getComputedDependencies()\n };\n}\n\ninterface GraphItem {\n state: ItemState;\n service: ServiceRepr;\n dependencies: ComputedServiceDependencies;\n}\n\ntype ItemState = \"not-visited\" | \"pending\" | \"done\";\n\n/** The reason why a graph node is being visited. */\ntype ItemVisitReason = \"root\" | InterfaceReference;\n\ntype InterfaceReference =\n | {\n type: \"framework-reference\";\n value: ReferenceSpec;\n }\n | {\n type: \"ui-reference\";\n packageName: string;\n value: ReferenceSpec;\n }\n | {\n type: \"service-reference\";\n service: ServiceRepr;\n referenceName: string;\n value: ReferenceSpec;\n };\n\nclass Verifier {\n #requiredReferences: readonly RequiredReference[];\n #items: GraphItem[];\n #serviceLookup = new ServiceLookup();\n #serviceToGraphItem = new Map<ServiceRepr, GraphItem>();\n\n // Stack of visited nodes\n #stack: [item: GraphItem, reason: ItemVisitReason][] = [];\n\n constructor(options: DependencyOptions) {\n this.#requiredReferences = options.requiredReferences ?? [];\n const services = options.services ?? [];\n const items = (this.#items = services.map<GraphItem>((service) => {\n return {\n service: service,\n state: \"not-visited\",\n dependencies: {}\n };\n }));\n\n for (const item of items) {\n for (const spec of item.service.interfaces) {\n this.#registerService(item, spec);\n }\n }\n }\n\n verify() {\n for (const ref of this.#requiredReferences) {\n let interfaceRef: InterfaceReference;\n switch (ref.type) {\n case \"framework\":\n interfaceRef = { type: \"framework-reference\", value: ref };\n break;\n case \"ui\":\n interfaceRef = {\n type: \"ui-reference\",\n packageName: ref.packageName,\n value: ref\n };\n break;\n }\n this.#visitReference(interfaceRef);\n }\n for (const item of this.#items) {\n this.#visitItem(item, \"root\");\n }\n }\n\n getServiceLookup() {\n return this.#serviceLookup;\n }\n\n getComputedDependencies() {\n return new Map(\n this.#items.map<[string, ComputedServiceDependencies]>((item) => {\n return [item.service.id, item.dependencies];\n })\n );\n }\n\n #visitItem(item: GraphItem, reason: ItemVisitReason) {\n const stack = this.#stack;\n const state = item.state;\n if (state === \"done\") {\n return; // Item is initialized, cycle impossible\n }\n if (state === \"pending\") {\n this.#throwCycleError(item, reason);\n }\n\n stack.push([item, reason]);\n item.state = \"pending\";\n for (const dep of item.service.dependencies) {\n item.dependencies[dep.referenceName] = this.#visitReference({\n type: \"service-reference\",\n service: item.service,\n referenceName: dep.referenceName,\n value: dep\n });\n }\n item.state = \"done\";\n stack.pop();\n }\n\n #visitReference(ref: InterfaceReference) {\n const itemOrItems = this.#findServices(ref);\n if (Array.isArray(itemOrItems)) {\n for (const child of itemOrItems) {\n this.#visitItem(child, ref);\n }\n return itemOrItems.map((item) => item.service);\n } else {\n this.#visitItem(itemOrItems, ref);\n return itemOrItems.service;\n }\n }\n\n #registerService(item: GraphItem, spec: InterfaceSpec) {\n this.#serviceLookup.register(item.service, spec);\n this.#serviceToGraphItem.set(item.service, item);\n }\n\n #findServices(ref: InterfaceReference): GraphItem | GraphItem[] {\n const spec = ref.value;\n const lookupResult = this.#serviceLookup.lookup(spec);\n switch (lookupResult.type) {\n case \"unimplemented\": {\n const message = unimplementedInterfaceMessage(ref);\n throw new Error(ErrorId.INTERFACE_NOT_FOUND, message);\n }\n case \"ambiguous\": {\n const message = ambiguousInterfaceMessage(ref, lookupResult.choices);\n throw new Error(ErrorId.AMBIGUOUS_DEPENDENCY, message);\n }\n }\n\n const value = lookupResult.value;\n if (Array.isArray(value)) {\n return value.map((service) => this.#getGraphItem(service));\n } else {\n return this.#getGraphItem(value);\n }\n }\n\n #getGraphItem(service: ServiceRepr): GraphItem {\n const graphItem = this.#serviceToGraphItem.get(service);\n if (!graphItem || graphItem.service !== service) {\n throw new Error(\n ErrorId.INTERNAL,\n `Failed to find matching graph item for service '${service.id}'.`\n );\n }\n return graphItem;\n }\n\n #throwCycleError(item: GraphItem, reason: ItemVisitReason) {\n // Find the item on the stack (it must be there because we detected a cycle).\n const stack = this.#stack;\n const ownIndex = stack.findIndex((entry) => entry[0] === item);\n if (ownIndex === -1) {\n throw new Error(ErrorId.INTERNAL, \"Failed to find cycle participant on the stack.\");\n }\n\n const cycleInfo = stack\n .slice(ownIndex)\n .concat([[item, reason]])\n .map<string>((entry, index) => {\n const item = entry[0];\n const reason = index === 0 ? \"root\" : entry[1]; // info before the cycle does not matter\n\n let message = `'${item.service.id}'`;\n if (typeof reason === \"object\") {\n message += ` (${referenceDetail(reason)})`;\n }\n return message;\n });\n throw new Error(\n ErrorId.DEPENDENCY_CYCLE,\n `Detected dependency cycle: ${cycleInfo.join(\" => \")}.`\n );\n }\n}\n\nfunction unimplementedInterfaceMessage(ref: InterfaceReference): string {\n const interfaceText = renderInterfaceSpec(ref.value);\n switch (ref.type) {\n case \"service-reference\":\n return `Service '${ref.service.id}' requires an unimplemented interface ${interfaceText} as dependency '${ref.referenceName}'.`;\n case \"ui-reference\":\n return `The UI of package '${ref.packageName}' requires an unimplemented interface ${interfaceText}.`;\n case \"framework-reference\":\n return `The framework requires an unimplemented interface ${interfaceText}.`;\n }\n}\n\nfunction ambiguousInterfaceMessage(ref: InterfaceReference, choices: AmbiguousChoice[]): string {\n const interfaceText = renderInterfaceSpec(ref.value);\n const serviceChoices = renderAmbiguousServiceChoices(choices);\n\n let message = \"\";\n switch (ref.type) {\n case \"service-reference\":\n message = `Service '${ref.service.id}' requires the ambiguous interface ${interfaceText} as dependency '${ref.referenceName}'.`;\n break;\n case \"ui-reference\":\n message = `The UI of package '${ref.packageName}' requires the ambiguous interface ${interfaceText}.`;\n break;\n case \"framework-reference\":\n message = `The framework requires the ambiguous interface ${interfaceText}.`;\n break;\n }\n message += ` Possible choices are ${serviceChoices}.`;\n return message;\n}\n\nfunction referenceDetail(reason: InterfaceReference) {\n switch (reason.type) {\n case \"service-reference\":\n return `'${reason.referenceName}' providing '${reason.value.interfaceName}'`;\n case \"ui-reference\":\n return `UI of package '${reason.packageName}' requiring '${reason.value.interfaceName}'`;\n case \"framework-reference\":\n return `framework requiring '${reason.value.interfaceName}'`;\n }\n}\n"],"names":["item","reason"],"mappings":";;;;;AAsDO,SAAS,mBAAmB,OAAA,EAAsD;AACrF,EAAA,MAAM,QAAA,GAAW,IAAI,QAAA,CAAS,OAAO,CAAA;AACrC,EAAA,QAAA,CAAS,MAAA,EAAO;AAChB,EAAA,OAAO;AAAA,IACH,aAAA,EAAe,SAAS,gBAAA,EAAiB;AAAA,IACzC,mBAAA,EAAqB,SAAS,uBAAA;AAAwB,GAC1D;AACJ;AA8BA,MAAM,QAAA,CAAS;AAAA,EACX,mBAAA;AAAA,EACA,MAAA;AAAA,EACA,cAAA,GAAiB,IAAI,aAAA,EAAc;AAAA,EACnC,mBAAA,uBAA0B,GAAA,EAA4B;AAAA;AAAA,EAGtD,SAAuD,EAAC;AAAA,EAExD,YAAY,OAAA,EAA4B;AACpC,IAAA,IAAA,CAAK,mBA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AA,IACJ,KAAK,cAAA;AACD,MAAA,OAAA,GAAU,CAAA,mBAAA,EAAsB,GAAA,CAAI,WAAW,CAAA,mCAAA,EAAsC,aAAa,CAAA,CAAA,CAAA;AAClG,MAAA;AAAA,IACJ,KAAK,qBAAA;AACD,MAAA,OAAA,GAAU,kDAAkD,aAAa,CAAA,CAAA,CAAA;AACzE,MAAA;AAAA;AAER,EAAA,OAAA,IAAW,yBAAyB,cAAc,CAAA,CAAA,CAAA;AAClD,EAAA,OAAO,OAAA;AACX;AAEA,SAAS,gBAAgB,MAAA,EAA4B;AACjD,EAAA,QAAQ,OAAO,IAAA;AAAM,IACjB,KAAK,mBAAA;AACD,MAAA,OAAO,IAAI,MAAA,CAAO,aAAa,CAAA,aAAA,EAAgB,MAAA,CAAO,MAAM,aAAa,CAAA,CAAA,CAAA;AAAA,IAC7E,KAAK,cAAA;AACD,MAAA,OAAO,kBAAkB,MAAA,CAAO,WAAW,CAAA,aAAA,EAAgB,MAAA,CAAO,MAAM,aAAa,CAAA,CAAA,CAAA;AAAA,IACzF,KAAK,qBAAA;AACD,MAAA,OAAO,CAAA,qBAAA,EAAwB,MAAA,CAAO,KAAA,CAAM,aAAa,CAAA,CAAA,CAAA;AAAA;AAErE;;;;"}
|
package/test-support/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { APP_ROOT_CLASS } from '../dom/index.js';
|
|
2
2
|
import '../i18n/AppIntl.js';
|
|
3
3
|
export { createPackageIntl } from '../i18n/PackageIntl.js';
|
|
4
|
-
import '
|
|
4
|
+
import '@formatjs/intl-localematcher';
|
|
5
|
+
import '@open-pioneer/core';
|
|
5
6
|
export { CustomChakraProvider } from '../react-integration/ChakraProvider.js';
|
|
6
7
|
export { PackageContext } from '../react-integration/PackageContext.js';
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|