@open-pioneer/runtime 4.6.0-dev.20260417092303 → 4.6.0-dev.20260421085858
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 +5 -1
- package/Service.d.ts +45 -0
- package/Service.js +7 -0
- package/Service.js.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/metadata/index.d.ts +2 -2
- package/package.json +7 -7
- package/service-layer/ServiceRepr.d.ts +8 -12
- package/service-layer/ServiceRepr.js +49 -16
- package/service-layer/ServiceRepr.js.map +1 -1
package/CHANGELOG.md
CHANGED
package/Service.d.ts
CHANGED
|
@@ -61,3 +61,48 @@ export type ServiceOptions<References extends {} = {}> = {
|
|
|
61
61
|
export type ServiceConstructor<References extends {} = {}, Interface extends {} = {}> = {
|
|
62
62
|
new (options: ServiceOptions<References>): Service<Interface>;
|
|
63
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* A service factory is an object that has a method to create a service instance.
|
|
66
|
+
* The service factory itself can also implement lifecycle hooks, which will be called by the runtime
|
|
67
|
+
* when the factory is destroyed.
|
|
68
|
+
*/
|
|
69
|
+
export type ServiceFactory<Interface extends {} = {}> = {
|
|
70
|
+
/**
|
|
71
|
+
* Method to create a service instance.
|
|
72
|
+
* It is directly called by the runtime after constructing the factory.
|
|
73
|
+
* NOTE: the service.destroy lifecycle hook is not called by the runtime.
|
|
74
|
+
*/
|
|
75
|
+
createService(): Interface;
|
|
76
|
+
/**
|
|
77
|
+
* Optional method to destroy a service instance created by this factory.
|
|
78
|
+
* If provided, this method will be called by the runtime when the service instance is destroyed.
|
|
79
|
+
* A factory instance exists per service, this method invocation means that the factory is no longer used by the runtime.
|
|
80
|
+
*/
|
|
81
|
+
destroyService?(service: Interface): void;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* A constructor type for a service factory.
|
|
85
|
+
* The service factory is an object that has a method to create a service instance,
|
|
86
|
+
* this allows for more flexibility in service construction.
|
|
87
|
+
*/
|
|
88
|
+
export type ServiceFactoryConstructor<References extends {} = {}, Interface extends {} = {}> = {
|
|
89
|
+
new (options: ServiceOptions<References>): ServiceFactory<Interface>;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Symbol used to detect if a constructor function is a service factory constructor.
|
|
93
|
+
*/
|
|
94
|
+
declare const IS_SERVICE_FACTORY: unique symbol;
|
|
95
|
+
export { IS_SERVICE_FACTORY };
|
|
96
|
+
/**
|
|
97
|
+
* A service factory constructor must be marked
|
|
98
|
+
* with the `IS_SERVICE_FACTORY` symbol to be recognized by the runtime as such.
|
|
99
|
+
*/
|
|
100
|
+
export type MarkedServiceFactoryConstructor<References extends {} = {}, Interface extends {} = {}> = ServiceFactoryConstructor<References, Interface> & {
|
|
101
|
+
[IS_SERVICE_FACTORY]: true;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Utility function to mark a constructor as a service factory constructor.
|
|
105
|
+
* @param ctr normal constructor function for a service factory.
|
|
106
|
+
* @returns the same constructor function, but marked with the `IS_SERVICE_FACTORY` symbol so that the runtime recognizes it as a service factory constructor.
|
|
107
|
+
*/
|
|
108
|
+
export declare function defineServiceFactory(ctr: ServiceFactoryConstructor): MarkedServiceFactoryConstructor;
|
package/Service.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
const IS_SERVICE_FACTORY = /* @__PURE__ */ Symbol("runtime.IS_SERVICE_FACTORY");
|
|
2
|
+
function defineServiceFactory(ctr) {
|
|
3
|
+
const markedCtr = ctr;
|
|
4
|
+
markedCtr[IS_SERVICE_FACTORY] = true;
|
|
5
|
+
return markedCtr;
|
|
6
|
+
}
|
|
1
7
|
|
|
8
|
+
export { IS_SERVICE_FACTORY, defineServiceFactory };
|
|
2
9
|
//# sourceMappingURL=Service.js.map
|
package/Service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Service.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Service.js","sources":["Service.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { PackageIntl } from \"./i18n\";\n\n/** Lifecycle hooks supported by the service interface. */\nexport interface ServiceLifecycleHooks {\n /**\n * Destroys the component.\n * Should clean up all resources used by the component.\n */\n destroy?(): void;\n\n /*\n * Just used so that this interface is not empty.\n * TypeScript would otherwise throw an 'no common properties' error\n * if one tries to implement this interface without providing any\n * lifecycle hooks.\n */\n toString(): string;\n}\n\nexport type Service<Interface extends {} = {}> = ServiceLifecycleHooks & Interface;\n\n/**\n * Represents metadata for an injected reference.\n */\nexport interface ReferenceMeta {\n /**\n * The unique service id of the injected service.\n */\n serviceId: string;\n}\n\n/**\n * Contains metadata about injected references.\n * The key for the reference metadata is the reference's name.\n */\nexport type ReferencesMeta<References extends {}> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [referenceName in keyof References]: References[referenceName] extends any[]\n ? ReferenceMeta[]\n : ReferenceMeta;\n};\n\n/**\n * Options passed to a service's constructor.\n */\nexport type ServiceOptions<References extends {} = {}> = {\n /**\n * References to other services.\n * These are injected by the runtime and match the declared references of the service.\n */\n references: References;\n\n /**\n * Metadata about the injected references.\n * The object contains one entry for every reference injected via `references` (under the same key).\n *\n * If a single service has been injected, `referencesMeta[key]` will be of type {@link ReferenceMeta}.\n * If multiple services have been injected, an array of {@link ReferenceMeta} will be provided instead,\n * where the indices match the order in the injected references array.\n */\n referencesMeta: ReferencesMeta<References>;\n\n /**\n * Configuration properties.\n *\n * Default values are taken from the package's configuration, but these can be overridden\n * by the application.\n */\n properties: Record<string, unknown>;\n\n /**\n * A reference to the shared i18n object of the current package.\n */\n intl: PackageIntl;\n};\n\n/**\n * A service constructor returns a service instance when calling `new`.\n */\nexport type ServiceConstructor<References extends {} = {}, Interface extends {} = {}> = {\n new (options: ServiceOptions<References>): Service<Interface>;\n};\n\n/**\n * A service factory is an object that has a method to create a service instance.\n * The service factory itself can also implement lifecycle hooks, which will be called by the runtime\n * when the factory is destroyed.\n */\nexport type ServiceFactory<Interface extends {} = {}> = {\n /**\n * Method to create a service instance.\n * It is directly called by the runtime after constructing the factory.\n * NOTE: the service.destroy lifecycle hook is not called by the runtime.\n */\n createService(): Interface;\n /**\n * Optional method to destroy a service instance created by this factory.\n * If provided, this method will be called by the runtime when the service instance is destroyed.\n * A factory instance exists per service, this method invocation means that the factory is no longer used by the runtime.\n */\n destroyService?(service: Interface): void;\n};\n\n/**\n * A constructor type for a service factory.\n * The service factory is an object that has a method to create a service instance,\n * this allows for more flexibility in service construction.\n */\nexport type ServiceFactoryConstructor<References extends {} = {}, Interface extends {} = {}> = {\n new (options: ServiceOptions<References>): ServiceFactory<Interface>;\n};\n\n/**\n * Symbol used to detect if a constructor function is a service factory constructor.\n */\nconst IS_SERVICE_FACTORY = Symbol(\"runtime.IS_SERVICE_FACTORY\");\nexport { IS_SERVICE_FACTORY };\n\n/**\n * A service factory constructor must be marked\n * with the `IS_SERVICE_FACTORY` symbol to be recognized by the runtime as such.\n */\nexport type MarkedServiceFactoryConstructor<\n References extends {} = {},\n Interface extends {} = {}\n> = ServiceFactoryConstructor<References, Interface> & {\n [IS_SERVICE_FACTORY]: true;\n};\n\n/**\n * Utility function to mark a constructor as a service factory constructor.\n * @param ctr normal constructor function for a service factory.\n * @returns the same constructor function, but marked with the `IS_SERVICE_FACTORY` symbol so that the runtime recognizes it as a service factory constructor.\n */\nexport function defineServiceFactory(\n ctr: ServiceFactoryConstructor\n): MarkedServiceFactoryConstructor {\n const markedCtr = ctr as MarkedServiceFactoryConstructor;\n markedCtr[IS_SERVICE_FACTORY] = true;\n return markedCtr;\n}\n"],"names":[],"mappings":"AAqHA,MAAM,kBAAA,0BAA4B,4BAA4B;AAmBvD,SAAS,qBACZ,GAAA,EAC+B;AAC/B,EAAA,MAAM,SAAA,GAAY,GAAA;AAClB,EAAA,SAAA,CAAU,kBAAkB,CAAA,GAAI,IAAA;AAChC,EAAA,OAAO,SAAA;AACX;;;;"}
|
package/index.js
CHANGED
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/metadata/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ServiceConstructor } from "../Service";
|
|
1
|
+
import { MarkedServiceFactoryConstructor, ServiceConstructor } from "../Service";
|
|
2
2
|
import { ObservableBox } from "./ObservableBox";
|
|
3
3
|
/**
|
|
4
4
|
* Application metadata.
|
|
@@ -57,7 +57,7 @@ export interface ServiceMetadata {
|
|
|
57
57
|
/** The unique name of the service in its package. */
|
|
58
58
|
name: string;
|
|
59
59
|
/** Service constructor responsible for creating a new instance. */
|
|
60
|
-
clazz: ServiceConstructor<any>;
|
|
60
|
+
clazz: ServiceConstructor<any> | MarkedServiceFactoryConstructor<any>;
|
|
61
61
|
/**
|
|
62
62
|
* Collection of references to other services.
|
|
63
63
|
* The runtime will inject the required services when possible
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/runtime",
|
|
4
|
-
"version": "4.6.0-dev.
|
|
4
|
+
"version": "4.6.0-dev.20260421085858",
|
|
5
5
|
"description": "Implements the runtime environment for Open Pioneer Trails apps.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@conterra/reactivity-core": "^0.8.2",
|
|
18
|
-
"@formatjs/intl": "^4.1.
|
|
18
|
+
"@formatjs/intl": "^4.1.6",
|
|
19
19
|
"@chakra-ui/react": "^3.34.0",
|
|
20
20
|
"@emotion/cache": "^11.14.0",
|
|
21
21
|
"@emotion/react": "^11.14.0",
|
|
22
|
-
"react": "^19.2.
|
|
23
|
-
"react-dom": "^19.2.
|
|
24
|
-
"@open-pioneer/core": "4.6.0-dev.
|
|
25
|
-
"@open-pioneer/base-theme": "4.6.0-dev.
|
|
26
|
-
"@open-pioneer/reactivity": "4.6.0-dev.
|
|
22
|
+
"react": "^19.2.5",
|
|
23
|
+
"react-dom": "^19.2.5",
|
|
24
|
+
"@open-pioneer/core": "4.6.0-dev.20260421085858",
|
|
25
|
+
"@open-pioneer/base-theme": "4.6.0-dev.20260421085858",
|
|
26
|
+
"@open-pioneer/reactivity": "4.6.0-dev.20260421085858"
|
|
27
27
|
},
|
|
28
28
|
"exports": {
|
|
29
29
|
"./package.json": "./package.json",
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import { ServiceMetadata } from "../metadata";
|
|
2
|
-
import { Service, ServiceConstructor, ServiceOptions } from "../Service";
|
|
2
|
+
import { Service, ServiceConstructor, ServiceOptions, MarkedServiceFactoryConstructor } from "../Service";
|
|
3
3
|
import { InterfaceSpec, ReferenceSpec } from "./InterfaceSpec";
|
|
4
4
|
import { PackageIntl } from "../i18n";
|
|
5
5
|
export type ServiceState = "not-constructed" | "constructing" | "constructed" | "destroyed";
|
|
6
6
|
export type ServiceDependency = ReferenceSpec & {
|
|
7
7
|
referenceName: string;
|
|
8
8
|
};
|
|
9
|
-
export interface
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
export interface ServiceInstanceFactory {
|
|
10
|
+
create(options: ServiceOptions): Service;
|
|
11
|
+
destroy(srv: Service): void;
|
|
12
12
|
}
|
|
13
|
-
export interface FunctionFactory {
|
|
14
|
-
type: "function";
|
|
15
|
-
create: (options: ServiceOptions) => Service;
|
|
16
|
-
}
|
|
17
|
-
export type ServiceFactory = ConstructorFactory | FunctionFactory;
|
|
18
13
|
export interface ServiceReprOptions {
|
|
19
14
|
name: string;
|
|
20
15
|
packageName: string;
|
|
21
|
-
factory:
|
|
16
|
+
factory: ServiceInstanceFactory;
|
|
22
17
|
intl: PackageIntl;
|
|
23
18
|
dependencies?: ServiceDependency[];
|
|
24
19
|
interfaces?: InterfaceSpec[];
|
|
@@ -90,5 +85,6 @@ export declare class ServiceRepr {
|
|
|
90
85
|
*/
|
|
91
86
|
removeRef(): number;
|
|
92
87
|
}
|
|
93
|
-
export declare function createConstructorFactory<T extends {}>(clazz: ServiceConstructor<T>):
|
|
94
|
-
export declare function
|
|
88
|
+
export declare function createConstructorFactory<T extends {}>(clazz: ServiceConstructor<T> | MarkedServiceFactoryConstructor<T>): ServiceInstanceFactory;
|
|
89
|
+
export declare function createFactoryForServiceFactory<T extends {}>(facClazz: MarkedServiceFactoryConstructor<T>): ServiceInstanceFactory;
|
|
90
|
+
export declare function createFunctionFactory(create: (options: ServiceOptions) => Service): ServiceInstanceFactory;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ErrorId } from '../errors.js';
|
|
2
|
+
import { IS_SERVICE_FACTORY } from '../Service.js';
|
|
2
3
|
import { Error } from '@open-pioneer/core';
|
|
3
4
|
import { parseReferenceSpec } from './InterfaceSpec.js';
|
|
4
5
|
|
|
@@ -20,10 +21,7 @@ class ServiceRepr {
|
|
|
20
21
|
qualifier: i.qualifier
|
|
21
22
|
};
|
|
22
23
|
});
|
|
23
|
-
const factory =
|
|
24
|
-
type: "class",
|
|
25
|
-
clazz
|
|
26
|
-
};
|
|
24
|
+
const factory = createConstructorFactory(clazz);
|
|
27
25
|
return new ServiceRepr({
|
|
28
26
|
name,
|
|
29
27
|
packageName,
|
|
@@ -131,7 +129,7 @@ class ServiceRepr {
|
|
|
131
129
|
);
|
|
132
130
|
}
|
|
133
131
|
try {
|
|
134
|
-
this._instance =
|
|
132
|
+
this._instance = this.factory.create({
|
|
135
133
|
...options,
|
|
136
134
|
properties: this.properties,
|
|
137
135
|
intl: this.intl
|
|
@@ -150,7 +148,7 @@ class ServiceRepr {
|
|
|
150
148
|
destroy() {
|
|
151
149
|
if (this._instance) {
|
|
152
150
|
try {
|
|
153
|
-
this.
|
|
151
|
+
this.factory.destroy(this._instance);
|
|
154
152
|
} catch (e) {
|
|
155
153
|
throw new Error(
|
|
156
154
|
ErrorId.SERVICE_DESTRUCTION_FAILED,
|
|
@@ -178,23 +176,58 @@ class ServiceRepr {
|
|
|
178
176
|
}
|
|
179
177
|
}
|
|
180
178
|
function createConstructorFactory(clazz) {
|
|
181
|
-
|
|
179
|
+
if (IS_SERVICE_FACTORY in clazz) {
|
|
180
|
+
return createFactoryForServiceFactory(clazz);
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
create(options) {
|
|
184
|
+
return new clazz(options);
|
|
185
|
+
},
|
|
186
|
+
destroy(instance) {
|
|
187
|
+
instance.destroy?.();
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function createFactoryForServiceFactory(facClazz) {
|
|
192
|
+
return new ServiceFactoryInstanceFactory(facClazz);
|
|
193
|
+
}
|
|
194
|
+
class ServiceFactoryInstanceFactory {
|
|
195
|
+
constructor(_facClazz) {
|
|
196
|
+
this._facClazz = _facClazz;
|
|
197
|
+
}
|
|
198
|
+
_fac = void 0;
|
|
199
|
+
create(options) {
|
|
200
|
+
const fac = new this._facClazz(options);
|
|
201
|
+
const instance = fac.createService();
|
|
202
|
+
this._fac = fac;
|
|
203
|
+
return instance;
|
|
204
|
+
}
|
|
205
|
+
destroy(srv) {
|
|
206
|
+
if (!this._fac) {
|
|
207
|
+
throw new Error(
|
|
208
|
+
ErrorId.INTERNAL,
|
|
209
|
+
"Inconsistent state: service factory instance is not present."
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
this._fac.destroyService?.(srv);
|
|
214
|
+
} finally {
|
|
215
|
+
this._fac = void 0;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
182
218
|
}
|
|
183
219
|
function createFunctionFactory(create) {
|
|
184
|
-
return {
|
|
220
|
+
return {
|
|
221
|
+
create,
|
|
222
|
+
destroy(srv) {
|
|
223
|
+
srv.destroy?.();
|
|
224
|
+
}
|
|
225
|
+
};
|
|
185
226
|
}
|
|
186
227
|
const SERVICE_NAME_REGEX = /^[a-z0-9_-]+$/i;
|
|
187
228
|
function isValidServiceName(name) {
|
|
188
229
|
return SERVICE_NAME_REGEX.test(name);
|
|
189
230
|
}
|
|
190
|
-
function createService(factory, options) {
|
|
191
|
-
switch (factory.type) {
|
|
192
|
-
case "class":
|
|
193
|
-
return new factory.clazz(options);
|
|
194
|
-
case "function":
|
|
195
|
-
return factory.create(options);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
231
|
|
|
199
232
|
export { ServiceRepr, createConstructorFactory, createFunctionFactory };
|
|
200
233
|
//# sourceMappingURL=ServiceRepr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceRepr.js","sources":["ServiceRepr.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ErrorId } from \"../errors\";\nimport { ServiceMetadata } from \"../metadata\";\nimport { Service, ServiceConstructor, ServiceOptions } from \"../Service\";\nimport { Error } from \"@open-pioneer/core\";\nimport { InterfaceSpec, parseReferenceSpec, ReferenceSpec } from \"./InterfaceSpec\";\nimport { PackageIntl } from \"../i18n\";\n\nexport type ServiceState = \"not-constructed\" | \"constructing\" | \"constructed\" | \"destroyed\";\n\nexport type ServiceDependency = ReferenceSpec & { referenceName: string };\n\nexport interface ConstructorFactory {\n type: \"class\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n clazz: ServiceConstructor<any>;\n}\n\nexport interface FunctionFactory {\n type: \"function\";\n create: (options: ServiceOptions) => Service;\n}\n\nexport type ServiceFactory = ConstructorFactory | FunctionFactory;\n\nexport interface ServiceReprOptions {\n name: string;\n packageName: string;\n factory: ServiceFactory;\n intl: PackageIntl;\n dependencies?: ServiceDependency[];\n interfaces?: InterfaceSpec[];\n properties?: Record<string, unknown>;\n}\n\n/**\n * Represents metadata and state of a service in the runtime.\n * `this.instance` is the actual service instance (when constructed).\n */\nexport class ServiceRepr {\n static create(\n packageName: string,\n data: ServiceMetadata,\n intl: PackageIntl,\n properties?: Record<string, unknown>\n ): ServiceRepr {\n const clazz = data.clazz;\n const name = data.name;\n const dependencies = Object.entries(data.references ?? {}).map(\n ([name, referenceMetadata]) => {\n return {\n referenceName: name,\n ...parseReferenceSpec(referenceMetadata)\n };\n }\n );\n const interfaces = data.provides?.map<InterfaceSpec>((i) => {\n return {\n interfaceName: i.name,\n qualifier: i.qualifier\n };\n });\n const factory: ConstructorFactory = {\n type: \"class\",\n clazz\n };\n return new ServiceRepr({\n name,\n packageName,\n factory,\n intl,\n dependencies,\n interfaces,\n properties\n });\n }\n\n /** Unique id of this service. Contains the package name and the service name. */\n readonly id: string;\n\n /** Name of this service in it's package. */\n readonly name: string;\n\n /** Name of the parent package. */\n readonly packageName: string;\n\n /** Locale-dependant i18n messages. */\n readonly intl: PackageIntl;\n\n /** Service properties made available via the service's constructor. */\n readonly properties: Readonly<Record<string, unknown>>;\n\n /** Dependencies required by the service constructor. */\n readonly dependencies: readonly ServiceDependency[];\n\n /** Interfaces provided by the service. */\n readonly interfaces: readonly Readonly<InterfaceSpec>[];\n\n /** Number of references to this service. */\n private _useCount = 0;\n\n /** Service factory to construct an instance. */\n private factory: ServiceFactory;\n\n /** Current state of this service. \"constructed\" -> instance is available. */\n private _state: ServiceState = \"not-constructed\";\n\n /** Service instance, once constructed. */\n private _instance: Service | undefined = undefined;\n\n constructor(options: ServiceReprOptions) {\n const {\n name,\n packageName,\n factory,\n intl,\n dependencies = [],\n interfaces = [],\n properties = {}\n } = options;\n if (!isValidServiceName(name)) {\n throw new Error(ErrorId.INTERNAL, `Invalid service name: '${name}'.`);\n }\n\n this.id = `${packageName}::${name}`;\n this.name = name;\n this.packageName = packageName;\n this.factory = factory;\n this.intl = intl;\n this.dependencies = dependencies;\n this.interfaces = interfaces;\n this.properties = properties;\n }\n\n /** Returns the current service instance or undefined if the service has not been constructed. */\n get instance(): Service | undefined {\n return this._instance;\n }\n\n /** Returns the current state of the service. */\n get state() {\n return this._state;\n }\n\n /** Returns the current reference count. */\n get useCount() {\n return this._useCount;\n }\n\n /**\n * Same as `instance`, but throws when the instance has not been constructed.\n */\n getInstanceOrThrow() {\n const instance = this._instance;\n if (!instance) {\n throw new Error(ErrorId.INTERNAL, \"Expected service instance to be present.\");\n }\n return instance;\n }\n\n /**\n * Called before `create()` to place the service into the `constructing` state,\n * which is currently used to detect cycles.\n */\n beforeCreate() {\n if (this._state === \"not-constructed\") {\n this._state = \"constructing\";\n } else {\n throw new Error(\n ErrorId.INTERNAL,\n \"Inconsistent state: service is already under construction.\"\n );\n }\n }\n\n /**\n * Instantiates the service by invoking the service constructor\n * with the given `options`.\n *\n * The service's use count is initialized to `1`, so every `create()`\n * should be paired with a `removeRef()`.\n *\n * `destroy()` can be invoked once the final `removeRef()` has returned zero.\n */\n create(options: Pick<ServiceOptions, \"references\" | \"referencesMeta\">) {\n if (this._state !== \"constructing\" || this.instance !== undefined) {\n throw new Error(\n ErrorId.INTERNAL,\n \"Inconsistent state: service is not being constructed.\"\n );\n }\n try {\n this._instance = createService(this.factory, {\n ...options,\n properties: this.properties,\n intl: this.intl\n });\n this._state = \"constructed\";\n this._useCount = 1;\n return this._instance;\n } catch (e) {\n throw new Error(\n ErrorId.SERVICE_CONSTRUCTION_FAILED,\n `Failed to create service instance '${this.id}'.`,\n { cause: e }\n );\n }\n }\n\n destroy() {\n if (this._instance) {\n try {\n this._instance.destroy?.();\n } catch (e) {\n throw new Error(\n ErrorId.SERVICE_DESTRUCTION_FAILED,\n `Failed to destroy service instance '${this.id}'.`,\n { cause: e }\n );\n }\n }\n this._instance = undefined;\n this._state = \"destroyed\";\n }\n\n /**\n * Adds a use to the service's use count.\n * References to a service are tracked: it should only be destroyed when it is no longer being used.\n */\n addRef() {\n return (this._useCount += 1);\n }\n\n /**\n * Removes a use from the service's use count.\n * Returns the new use count.\n */\n removeRef() {\n return (this._useCount -= 1);\n }\n}\n\nexport function createConstructorFactory<T extends {}>(\n clazz: ServiceConstructor<T>\n): ConstructorFactory {\n return { type: \"class\", clazz };\n}\n\nexport function createFunctionFactory(\n create: (options: ServiceOptions) => Service\n): FunctionFactory {\n return { type: \"function\", create };\n}\n\nconst SERVICE_NAME_REGEX = /^[a-z0-9_-]+$/i;\n\nfunction isValidServiceName(name: string) {\n return SERVICE_NAME_REGEX.test(name);\n}\n\nfunction createService(factory: ServiceFactory, options: ServiceOptions) {\n switch (factory.type) {\n case \"class\":\n return new factory.clazz(options);\n case \"function\":\n return factory.create(options);\n }\n}\n"],"names":["name"],"mappings":";;;;AAwCO,MAAM,WAAA,CAAY;AAAA,EACrB,OAAO,MAAA,CACH,WAAA,EACA,IAAA,EACA,MACA,UAAA,EACW;AACX,IAAA,MAAM,QAAQ,IAAA,CAAK,KAAA;AACnB,IAAA,MAAM,OAAO,IAAA,CAAK,IAAA;AAClB,IAAA,MAAM,eAAe,MAAA,CAAO,OAAA,CAAQ,KAAK,UAAA,IAAc,EAAE,CAAA,CAAE,GAAA;AAAA,MACvD,CAAC,CAACA,KAAAA,EAAM,iBAAiB,CAAA,KAAM;AAC3B,QAAA,OAAO;AAAA,UACH,aAAA,EAAeA,KAAAA;AAAA,UACf,GAAG,mBAAmB,iBAAiB;AAAA,SAC3C;AAAA,MACJ;AAAA,KACJ;AACA,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,QAAA,EAAU,GAAA,CAAmB,CAAC,CAAA,KAAM;AACxD,MAAA,OAAO;AAAA,QACH,eAAe,CAAA,CAAE,IAAA;AAAA,QACjB,WAAW,CAAA,CAAE;AAAA,OACjB;AAAA,IACJ,CAAC,CAAA;AACD,IAAA,MAAM,OAAA,GAA8B;AAAA,MAChC,IAAA,EAAM,OAAA;AAAA,MACN;AAAA,KACJ;AAC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AAE3B,SAAS,mBAAmB,IAAA,EAAc;AACtC,EAAA,OAAO,kBAAA,CAAmB,KAAK,IAAI,CAAA;AACvC;AAEA,SAAS,aAAA,CAAc,SAAyB,OAAA,EAAyB;AACrE,EAAA,QAAQ,QAAQ,IAAA;AAAM,IAClB,KAAK,OAAA;AACD,MAAA,OAAO,IAAI,OAAA,CAAQ,KAAA,CAAM,OAAO,CAAA;AAAA,IACpC,KAAK,UAAA;AACD,MAAA,OAAO,OAAA,CAAQ,OAAO,OAAO,CAAA;AAAA;AAEzC;;;;"}
|
|
1
|
+
{"version":3,"file":"ServiceRepr.js","sources":["ServiceRepr.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ErrorId } from \"../errors\";\nimport { ServiceMetadata } from \"../metadata\";\nimport {\n Service,\n ServiceConstructor,\n ServiceOptions,\n IS_SERVICE_FACTORY,\n ServiceFactory,\n MarkedServiceFactoryConstructor\n} from \"../Service\";\nimport { Error } from \"@open-pioneer/core\";\nimport { InterfaceSpec, parseReferenceSpec, ReferenceSpec } from \"./InterfaceSpec\";\nimport { PackageIntl } from \"../i18n\";\n\nexport type ServiceState = \"not-constructed\" | \"constructing\" | \"constructed\" | \"destroyed\";\n\nexport type ServiceDependency = ReferenceSpec & { referenceName: string };\n\nexport interface 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: PackageIntl;\n dependencies?: ServiceDependency[];\n interfaces?: InterfaceSpec[];\n properties?: Record<string, unknown>;\n}\n\n/**\n * Represents metadata and state of a service in the runtime.\n * `this.instance` is the actual service instance (when constructed).\n */\nexport class ServiceRepr {\n static create(\n packageName: string,\n data: ServiceMetadata,\n intl: PackageIntl,\n properties?: Record<string, unknown>\n ): ServiceRepr {\n const clazz = data.clazz;\n const name = data.name;\n const dependencies = Object.entries(data.references ?? {}).map(\n ([name, referenceMetadata]) => {\n return {\n referenceName: name,\n ...parseReferenceSpec(referenceMetadata)\n };\n }\n );\n const interfaces = data.provides?.map<InterfaceSpec>((i) => {\n return {\n interfaceName: i.name,\n qualifier: i.qualifier\n };\n });\n const factory = 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: 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 constructor(options: ServiceReprOptions) {\n const {\n name,\n packageName,\n factory,\n intl,\n dependencies = [],\n interfaces = [],\n properties = {}\n } = options;\n if (!isValidServiceName(name)) {\n throw new Error(ErrorId.INTERNAL, `Invalid service name: '${name}'.`);\n }\n\n this.id = `${packageName}::${name}`;\n this.name = name;\n this.packageName = packageName;\n this.factory = factory;\n this.intl = intl;\n this.dependencies = dependencies;\n this.interfaces = interfaces;\n this.properties = properties;\n }\n\n /** Returns the current service instance or undefined if the service has not been constructed. */\n get instance(): Service | undefined {\n return this._instance;\n }\n\n /** Returns the current state of the service. */\n get state() {\n return this._state;\n }\n\n /** Returns the current reference count. */\n get useCount() {\n return this._useCount;\n }\n\n /**\n * Same as `instance`, but throws when the instance has not been constructed.\n */\n getInstanceOrThrow() {\n const instance = this._instance;\n if (!instance) {\n throw new Error(ErrorId.INTERNAL, \"Expected service instance to be present.\");\n }\n return instance;\n }\n\n /**\n * Called before `create()` to place the service into the `constructing` state,\n * which is currently used to detect cycles.\n */\n beforeCreate() {\n if (this._state === \"not-constructed\") {\n this._state = \"constructing\";\n } else {\n throw new Error(\n ErrorId.INTERNAL,\n \"Inconsistent state: service is already under construction.\"\n );\n }\n }\n\n /**\n * Instantiates the service by invoking the service constructor\n * with the given `options`.\n *\n * The service's use count is initialized to `1`, so every `create()`\n * should be paired with a `removeRef()`.\n *\n * `destroy()` can be invoked once the final `removeRef()` has returned zero.\n */\n create(options: Pick<ServiceOptions, \"references\" | \"referencesMeta\">) {\n if (this._state !== \"constructing\" || this.instance !== undefined) {\n throw new Error(\n ErrorId.INTERNAL,\n \"Inconsistent state: service is not being constructed.\"\n );\n }\n try {\n this._instance = this.factory.create({\n ...options,\n properties: this.properties,\n intl: this.intl\n });\n this._state = \"constructed\";\n this._useCount = 1;\n return this._instance;\n } catch (e) {\n throw new Error(\n ErrorId.SERVICE_CONSTRUCTION_FAILED,\n `Failed to create service instance '${this.id}'.`,\n { cause: e }\n );\n }\n }\n\n destroy() {\n if (this._instance) {\n try {\n this.factory.destroy(this._instance);\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\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":";;;;;AAuCO,MAAM,WAAA,CAAY;AAAA,EACrB,OAAO,MAAA,CACH,WAAA,EACA,IAAA,EACA,MACA,UAAA,EACW;AACX,IAAA,MAAM,QAAQ,IAAA,CAAK,KAAA;AACnB,IAAA,MAAM,OAAO,IAAA,CAAK,IAAA;AAClB,IAAA,MAAM,eAAe,MAAA,CAAO,OAAA,CAAQ,KAAK,UAAA,IAAc,EAAE,CAAA,CAAE,GAAA;AAAA,MACvD,CAAC,CAACA,KAAAA,EAAM,iBAAiB,CAAA,KAAM;AAC3B,QAAA,OAAO;AAAA,UACH,aAAA,EAAeA,KAAAA;AAAA,UACf,GAAG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