@zudojs/core 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -2
- package/dist/application/application.d.ts +29 -1
- package/dist/application/application.js +70 -1
- package/dist/application/applicationContext.context.d.ts +0 -1
- package/dist/application/applicationContext.context.js +0 -1
- package/dist/application/applicationState.state.d.ts +0 -1
- package/dist/application/applicationState.state.js +0 -1
- package/dist/application/createApplication.d.ts +0 -1
- package/dist/application/createApplication.js +0 -1
- package/dist/application/index.d.ts +0 -1
- package/dist/application/index.js +0 -1
- package/dist/configuration/configurationManager.manager.d.ts +0 -1
- package/dist/configuration/configurationManager.manager.js +0 -1
- package/dist/configuration/core/configuration.d.ts +0 -1
- package/dist/configuration/core/configuration.js +0 -1
- package/dist/configuration/core/configurationKey.key.d.ts +0 -1
- package/dist/configuration/core/configurationKey.key.js +0 -1
- package/dist/configuration/core/configurationPath.path.d.ts +0 -1
- package/dist/configuration/core/configurationPath.path.js +0 -1
- package/dist/configuration/core/configurationSource.source.d.ts +0 -1
- package/dist/configuration/core/configurationSource.source.js +0 -1
- package/dist/configuration/core/index.d.ts +0 -1
- package/dist/configuration/core/index.js +0 -1
- package/dist/configuration/error/configurationError.error.d.ts +0 -1
- package/dist/configuration/error/configurationError.error.js +0 -1
- package/dist/configuration/error/configurationRedactor.redactor.d.ts +0 -1
- package/dist/configuration/error/configurationRedactor.redactor.js +0 -1
- package/dist/configuration/error/index.d.ts +0 -1
- package/dist/configuration/error/index.js +0 -1
- package/dist/configuration/events/configurationEvents.events.d.ts +0 -1
- package/dist/configuration/events/configurationEvents.events.js +0 -1
- package/dist/configuration/events/index.d.ts +0 -1
- package/dist/configuration/events/index.js +0 -1
- package/dist/configuration/index.d.ts +0 -1
- package/dist/configuration/index.js +0 -1
- package/dist/configuration/loader/configurationLoader.loader.d.ts +0 -1
- package/dist/configuration/loader/configurationLoader.loader.js +0 -1
- package/dist/configuration/loader/index.d.ts +0 -1
- package/dist/configuration/loader/index.js +0 -1
- package/dist/configuration/registry/configurationProvider.provider.d.ts +0 -1
- package/dist/configuration/registry/configurationProvider.provider.js +0 -1
- package/dist/configuration/registry/configurationRegistry.registry.d.ts +0 -1
- package/dist/configuration/registry/configurationRegistry.registry.js +0 -1
- package/dist/configuration/registry/index.d.ts +0 -1
- package/dist/configuration/registry/index.js +0 -1
- package/dist/configuration/schema/configurationSchema.schema.d.ts +0 -1
- package/dist/configuration/schema/configurationSchema.schema.js +0 -1
- package/dist/configuration/schema/configurationValidation.validator.d.ts +0 -1
- package/dist/configuration/schema/configurationValidation.validator.js +0 -1
- package/dist/configuration/schema/index.d.ts +0 -1
- package/dist/configuration/schema/index.js +0 -1
- package/dist/container/container.d.ts +0 -1
- package/dist/container/container.js +0 -1
- package/dist/container/container.lifetime.d.ts +0 -1
- package/dist/container/container.lifetime.js +0 -1
- package/dist/container/index.d.ts +0 -1
- package/dist/container/index.js +0 -1
- package/dist/container/provider.d.ts +0 -1
- package/dist/container/provider.js +0 -1
- package/dist/container/scope.d.ts +0 -1
- package/dist/container/scope.js +0 -1
- package/dist/container/token.d.ts +0 -1
- package/dist/container/token.js +0 -1
- package/dist/context/core/contextAliases.deprecated.d.ts +0 -1
- package/dist/context/core/contextAliases.deprecated.js +0 -1
- package/dist/context/core/contextKey.key.d.ts +0 -1
- package/dist/context/core/contextKey.key.js +4 -3
- package/dist/context/core/executionContext.context.d.ts +0 -1
- package/dist/context/core/executionContext.context.js +0 -1
- package/dist/context/core/index.d.ts +0 -1
- package/dist/context/core/index.js +0 -1
- package/dist/context/index.d.ts +0 -1
- package/dist/context/index.js +0 -1
- package/dist/context/provider/contextProvider.provider.d.ts +0 -1
- package/dist/context/provider/contextProvider.provider.js +0 -1
- package/dist/context/provider/contextStorage.storage.d.ts +0 -1
- package/dist/context/provider/contextStorage.storage.js +0 -1
- package/dist/context/provider/defaultContextStorage.storage.d.ts +0 -1
- package/dist/context/provider/defaultContextStorage.storage.js +0 -1
- package/dist/context/provider/index.d.ts +0 -1
- package/dist/context/provider/index.js +0 -1
- package/dist/context/snapshot/contextSnapshot.snapshot.d.ts +0 -1
- package/dist/context/snapshot/contextSnapshot.snapshot.js +0 -1
- package/dist/context/snapshot/index.d.ts +0 -1
- package/dist/context/snapshot/index.js +0 -1
- package/dist/context/values/contextValues.values.d.ts +0 -1
- package/dist/context/values/contextValues.values.js +0 -1
- package/dist/context/values/index.d.ts +0 -1
- package/dist/context/values/index.js +0 -1
- package/dist/contracts/adapter.d.ts +0 -1
- package/dist/contracts/adapter.js +0 -1
- package/dist/contracts/disposable.d.ts +0 -1
- package/dist/contracts/disposable.js +0 -1
- package/dist/contracts/handler.d.ts +0 -1
- package/dist/contracts/handler.js +0 -1
- package/dist/contracts/index.d.ts +0 -1
- package/dist/contracts/index.js +0 -1
- package/dist/errors/contextValueNotFound.error.d.ts +15 -0
- package/dist/errors/contextValueNotFound.error.js +23 -0
- package/dist/errors/errorCode.code.d.ts +1 -1
- package/dist/errors/errorCode.code.js +1 -1
- package/dist/errors/exceptions.d.ts +0 -1
- package/dist/errors/exceptions.js +0 -1
- package/dist/errors/frameworkError.error.d.ts +0 -1
- package/dist/errors/frameworkError.error.js +0 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +16 -1
- package/dist/lifecycle/core/index.d.ts +0 -1
- package/dist/lifecycle/core/index.js +0 -1
- package/dist/lifecycle/core/lifecycle.d.ts +12 -2
- package/dist/lifecycle/core/lifecycle.js +12 -2
- package/dist/lifecycle/core/lifecycle.rollback.d.ts +0 -1
- package/dist/lifecycle/core/lifecycle.rollback.js +0 -1
- package/dist/lifecycle/core/lifecycleHook.hook.d.ts +0 -1
- package/dist/lifecycle/core/lifecycleHook.hook.js +0 -1
- package/dist/lifecycle/core/lifecycleRegistry.registry.d.ts +0 -1
- package/dist/lifecycle/core/lifecycleRegistry.registry.js +0 -1
- package/dist/lifecycle/index.d.ts +0 -1
- package/dist/lifecycle/index.js +0 -1
- package/dist/lifecycle/manager/index.d.ts +0 -1
- package/dist/lifecycle/manager/index.js +0 -1
- package/dist/lifecycle/manager/lifecycleManager.manager.d.ts +0 -1
- package/dist/lifecycle/manager/lifecycleManager.manager.js +0 -1
- package/dist/lifecycle/scope/index.d.ts +0 -1
- package/dist/lifecycle/scope/index.js +0 -1
- package/dist/lifecycle/scope/lifecycleScope.scope.d.ts +0 -1
- package/dist/lifecycle/scope/lifecycleScope.scope.js +0 -1
- package/dist/logging/console/consoleLogger.logger.d.ts +0 -1
- package/dist/logging/console/consoleLogger.logger.js +6 -2
- package/dist/logging/console/index.d.ts +0 -1
- package/dist/logging/console/index.js +0 -1
- package/dist/logging/console/loggerFactory.factory.d.ts +0 -1
- package/dist/logging/console/loggerFactory.factory.js +0 -1
- package/dist/logging/core/index.d.ts +0 -1
- package/dist/logging/core/index.js +0 -1
- package/dist/logging/core/logEntry.entry.d.ts +0 -1
- package/dist/logging/core/logEntry.entry.js +0 -1
- package/dist/logging/core/logLevel.level.d.ts +0 -1
- package/dist/logging/core/logLevel.level.js +0 -1
- package/dist/logging/core/logRedaction.redaction.d.ts +0 -1
- package/dist/logging/core/logRedaction.redaction.js +0 -1
- package/dist/logging/core/logger.d.ts +7 -2
- package/dist/logging/core/logger.js +22 -3
- package/dist/logging/core/loggerContext.context.d.ts +0 -1
- package/dist/logging/core/loggerContext.context.js +0 -1
- package/dist/logging/core/loggerOptions.options.d.ts +6 -3
- package/dist/logging/core/loggerOptions.options.js +0 -1
- package/dist/logging/index.d.ts +0 -1
- package/dist/logging/index.js +0 -1
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +0 -1
- package/dist/modules/module.d.ts +0 -1
- package/dist/modules/module.js +0 -1
- package/dist/modules/moduleContext.context.d.ts +0 -1
- package/dist/modules/moduleContext.context.js +0 -1
- package/dist/modules/moduleDefinition.definition.d.ts +0 -1
- package/dist/modules/moduleDefinition.definition.js +0 -1
- package/dist/modules/moduleDependency/index.d.ts +0 -1
- package/dist/modules/moduleDependency/index.js +0 -1
- package/dist/modules/moduleDependency/moduleDependency.graph.d.ts +0 -1
- package/dist/modules/moduleDependency/moduleDependency.graph.js +0 -1
- package/dist/modules/moduleDependency/moduleDependency.ordering.d.ts +0 -1
- package/dist/modules/moduleDependency/moduleDependency.ordering.js +0 -1
- package/dist/modules/moduleDependency/moduleDependency.type.d.ts +0 -1
- package/dist/modules/moduleDependency/moduleDependency.type.js +0 -1
- package/dist/modules/moduleError/index.d.ts +0 -1
- package/dist/modules/moduleError/index.js +0 -1
- package/dist/modules/moduleError/moduleError.base.d.ts +0 -1
- package/dist/modules/moduleError/moduleError.base.js +0 -1
- package/dist/modules/moduleError/moduleError.dependency.d.ts +19 -3
- package/dist/modules/moduleError/moduleError.dependency.js +16 -4
- package/dist/modules/moduleError/moduleError.helpers.d.ts +0 -1
- package/dist/modules/moduleError/moduleError.helpers.js +0 -1
- package/dist/modules/moduleError/moduleError.lifecycle.d.ts +0 -1
- package/dist/modules/moduleError/moduleError.lifecycle.js +0 -1
- package/dist/modules/moduleError/moduleError.registration.d.ts +0 -1
- package/dist/modules/moduleError/moduleError.registration.js +0 -1
- package/dist/modules/moduleLifecycle/index.d.ts +0 -1
- package/dist/modules/moduleLifecycle/index.js +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.exclusive.d.ts +25 -0
- package/dist/modules/moduleLifecycle/moduleLifecycle.exclusive.js +63 -0
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.d.ts +20 -2
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.js +52 -20
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.d.ts +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.js +4 -3
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.d.ts +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.js +0 -1
- package/dist/modules/moduleLoader/index.d.ts +0 -1
- package/dist/modules/moduleLoader/index.js +0 -1
- package/dist/modules/moduleLoader/moduleLoader.loader.d.ts +0 -1
- package/dist/modules/moduleLoader/moduleLoader.loader.js +0 -1
- package/dist/modules/moduleLoader/moduleLoader.type.d.ts +0 -1
- package/dist/modules/moduleLoader/moduleLoader.type.js +0 -1
- package/dist/modules/moduleMetadata.metadata.d.ts +0 -1
- package/dist/modules/moduleMetadata.metadata.js +0 -1
- package/dist/modules/moduleRegistry/index.d.ts +0 -1
- package/dist/modules/moduleRegistry/index.js +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.registry.d.ts +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.registry.js +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.type.d.ts +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.type.js +0 -1
- package/dist/runtime/index.d.ts +1 -2
- package/dist/runtime/index.js +0 -1
- package/dist/runtime/runtime.d.ts +18 -2
- package/dist/runtime/runtime.js +23 -1
- package/dist/runtime/runtimeBootstrap/index.d.ts +0 -1
- package/dist/runtime/runtimeBootstrap/index.js +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/index.d.ts +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/index.js +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.d.ts +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.js +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.d.ts +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.js +8 -2
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.d.ts +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.js +0 -1
- package/dist/runtime/runtimeContext/index.d.ts +0 -1
- package/dist/runtime/runtimeContext/index.js +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.factory.d.ts +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.factory.js +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.type.d.ts +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.type.js +0 -1
- package/dist/runtime/runtimeEnvironment/detection/index.d.ts +0 -1
- package/dist/runtime/runtimeEnvironment/detection/index.js +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.detection.d.ts +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.detection.js +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.d.ts +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.js +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.d.ts +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.js +0 -1
- package/dist/runtime/runtimeEnvironment/index.d.ts +0 -1
- package/dist/runtime/runtimeEnvironment/index.js +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.d.ts +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.js +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.d.ts +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.js +0 -1
- package/dist/runtime/runtimeError/index.d.ts +0 -1
- package/dist/runtime/runtimeError/index.js +0 -1
- package/dist/runtime/runtimeError/runtimeError.base.d.ts +0 -1
- package/dist/runtime/runtimeError/runtimeError.base.js +0 -1
- package/dist/runtime/runtimeError/runtimeError.lifecycle.d.ts +0 -1
- package/dist/runtime/runtimeError/runtimeError.lifecycle.js +0 -1
- package/dist/runtime/runtimeError/runtimeError.specialized.d.ts +0 -1
- package/dist/runtime/runtimeError/runtimeError.specialized.js +0 -1
- package/dist/runtime/runtimeError/runtimeError.type.d.ts +0 -1
- package/dist/runtime/runtimeError/runtimeError.type.js +0 -1
- package/dist/runtime/runtimeLogger.d.ts +0 -1
- package/dist/runtime/runtimeLogger.js +5 -2
- package/dist/runtime/runtimeOptions/index.d.ts +0 -1
- package/dist/runtime/runtimeOptions/index.js +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.d.ts +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.js +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.mode.d.ts +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.mode.js +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.resolver.d.ts +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.resolver.js +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.type.d.ts +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.type.js +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.validation.d.ts +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.validation.js +0 -1
- package/dist/runtime/runtimeShutdown/index.d.ts +0 -1
- package/dist/runtime/runtimeShutdown/index.js +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/index.d.ts +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/index.js +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.d.ts +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.js +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.d.ts +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.js +4 -2
- package/dist/runtime/runtimeShutdown/runtimeShutdown.type.d.ts +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.type.js +0 -1
- package/dist/runtime/runtimeSignals/index.d.ts +0 -1
- package/dist/runtime/runtimeSignals/index.js +0 -1
- package/dist/runtime/runtimeSignals/runtimeSignals.d.ts +7 -3
- package/dist/runtime/runtimeSignals/runtimeSignals.fatal.d.ts +0 -1
- package/dist/runtime/runtimeSignals/runtimeSignals.fatal.js +0 -1
- package/dist/runtime/runtimeSignals/runtimeSignals.js +4 -5
- package/dist/runtime/runtimeState.state.d.ts +0 -1
- package/dist/runtime/runtimeState.state.js +0 -1
- package/dist/runtime/runtimeTimeout.d.ts +0 -1
- package/dist/runtime/runtimeTimeout.js +0 -1
- package/package.json +3 -3
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ModuleError, ModuleErrorCode, } from "../moduleError/moduleError.base.js";
|
|
2
2
|
import { createModuleDependencyGraph, resolveModuleStartupOrder, resolveModuleShutdownOrder, } from "../moduleDependency/index.js";
|
|
3
|
+
import { MissingModuleDependencyError } from "../moduleError/moduleError.dependency.js";
|
|
3
4
|
import { ModuleLifecycleError } from "./moduleLifecycle.type.js";
|
|
5
|
+
import { ExclusiveOperations } from "./moduleLifecycle.exclusive.js";
|
|
4
6
|
import { getDefaultContextStorage } from "../../context/provider/defaultContextStorage.storage.js";
|
|
5
7
|
import { ensureStateSynchronized, getLifecycleState, requireLifecycleState, getAllLifecycleStates, isModuleInitialized, isModuleStarted, isModuleDestroyed, executeLifecyclePhase, } from "./moduleLifecycle.stateMachine.js";
|
|
6
8
|
/**
|
|
@@ -13,7 +15,8 @@ export class ModuleLifecycleManager {
|
|
|
13
15
|
options;
|
|
14
16
|
contextStorage;
|
|
15
17
|
states = new Map();
|
|
16
|
-
|
|
18
|
+
exclusive = new ExclusiveOperations();
|
|
19
|
+
tornDown = false;
|
|
17
20
|
constructor(registry, loader, options = {}) {
|
|
18
21
|
this.registry = registry;
|
|
19
22
|
this.loader = loader;
|
|
@@ -27,6 +30,7 @@ export class ModuleLifecycleManager {
|
|
|
27
30
|
}
|
|
28
31
|
async initialize(options = {}) {
|
|
29
32
|
return this.runExclusive(async () => {
|
|
33
|
+
this.tornDown = false;
|
|
30
34
|
ensureStateSynchronized(this.registry, this.states);
|
|
31
35
|
try {
|
|
32
36
|
return await executeLifecyclePhase(this.getStartupOrder(), "initialize", "initializing", "initialized", options.continueOnError ?? this.options.continueOnInitializeError, this.registry, this.loader, this.states, this.contextStorage, options.signal);
|
|
@@ -35,7 +39,7 @@ export class ModuleLifecycleManager {
|
|
|
35
39
|
await this.rollbackAfterFailure(error, { stopFirst: false });
|
|
36
40
|
throw error;
|
|
37
41
|
}
|
|
38
|
-
});
|
|
42
|
+
}, options.signal);
|
|
39
43
|
}
|
|
40
44
|
async start(options = {}) {
|
|
41
45
|
return this.runExclusive(async () => {
|
|
@@ -47,7 +51,7 @@ export class ModuleLifecycleManager {
|
|
|
47
51
|
await this.rollbackAfterFailure(error, { stopFirst: true });
|
|
48
52
|
throw error;
|
|
49
53
|
}
|
|
50
|
-
});
|
|
54
|
+
}, options.signal);
|
|
51
55
|
}
|
|
52
56
|
async stop(options = {}) {
|
|
53
57
|
return this.runExclusive(async () => {
|
|
@@ -58,7 +62,12 @@ export class ModuleLifecycleManager {
|
|
|
58
62
|
async destroy(options = {}) {
|
|
59
63
|
return this.runExclusive(async () => {
|
|
60
64
|
ensureStateSynchronized(this.registry, this.states);
|
|
61
|
-
|
|
65
|
+
try {
|
|
66
|
+
return await executeLifecyclePhase(this.getShutdownOrder(), "destroy", "destroying", "destroyed", options.continueOnError ?? this.options.continueOnDestroyError, this.registry, this.loader, this.states, this.contextStorage);
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
this.tornDown = true;
|
|
70
|
+
}
|
|
62
71
|
});
|
|
63
72
|
}
|
|
64
73
|
/**
|
|
@@ -248,27 +257,51 @@ export class ModuleLifecycleManager {
|
|
|
248
257
|
}));
|
|
249
258
|
return createModuleDependencyGraph(nodes);
|
|
250
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Startup order over the loaded modules. A dependency that is
|
|
262
|
+
* registered but not loaded used to be reported as a "missing
|
|
263
|
+
* module", which sent people looking for a typo; it is now described
|
|
264
|
+
* by its registration state.
|
|
265
|
+
*/
|
|
251
266
|
getStartupOrder() {
|
|
252
|
-
|
|
267
|
+
try {
|
|
268
|
+
return resolveModuleStartupOrder(this.createGraph());
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
if (error instanceof MissingModuleDependencyError &&
|
|
272
|
+
error.moduleId !== undefined &&
|
|
273
|
+
error.dependencyId !== undefined) {
|
|
274
|
+
const registration = this.registry.get(error.dependencyId);
|
|
275
|
+
if (registration !== undefined) {
|
|
276
|
+
throw new MissingModuleDependencyError(error.moduleId, error.dependencyId, { dependencyState: registration.state });
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
throw error;
|
|
280
|
+
}
|
|
253
281
|
}
|
|
254
282
|
getShutdownOrder() {
|
|
255
283
|
return resolveModuleShutdownOrder(this.createGraph());
|
|
256
284
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
285
|
+
/**
|
|
286
|
+
* Serialises operations. One whose `signal` was aborted (a bootstrap
|
|
287
|
+
* abandoned by the startup timeout) is not waited for, so `stop()`
|
|
288
|
+
* and `destroy()` no longer queue behind a hook that may never
|
|
289
|
+
* settle; a module whose hook does settle later is torn down then.
|
|
290
|
+
*/
|
|
291
|
+
runExclusive(operation, signal) {
|
|
292
|
+
return this.exclusive.run(operation, signal, () => {
|
|
293
|
+
this.finalizeLateModules();
|
|
263
294
|
});
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Best-effort teardown for modules an abandoned startup brought up
|
|
298
|
+
* after the runtime had already been shut down. Failures land on the
|
|
299
|
+
* module's lifecycle state as they would for any stop/destroy.
|
|
300
|
+
*/
|
|
301
|
+
finalizeLateModules() {
|
|
302
|
+
if (!this.tornDown)
|
|
303
|
+
return;
|
|
304
|
+
void this.stopApplication().catch(() => undefined);
|
|
272
305
|
}
|
|
273
306
|
}
|
|
274
307
|
/**
|
|
@@ -298,4 +331,3 @@ export function resolveRegistrationDependencies(registry, registration) {
|
|
|
298
331
|
export function createModuleLifecycleManager(registry, loader, options = {}) {
|
|
299
332
|
return new ModuleLifecycleManager(registry, loader, options);
|
|
300
333
|
}
|
|
301
|
-
//# sourceMappingURL=moduleLifecycle.lifecycle.js.map
|
|
@@ -106,9 +106,11 @@ export function canModuleEnterPhase(moduleId, hook, states) {
|
|
|
106
106
|
case "stop":
|
|
107
107
|
return state.phase === "started";
|
|
108
108
|
case "destroy":
|
|
109
|
+
// A module still in "created" never had onInitialize invoked, so
|
|
110
|
+
// there is nothing for onDestroy to release. Rollback used to
|
|
111
|
+
// destroy every module that was never reached.
|
|
109
112
|
return (state.phase === "stopped" ||
|
|
110
113
|
state.phase === "initialized" ||
|
|
111
|
-
state.phase === "created" ||
|
|
112
114
|
state.phase === "started" ||
|
|
113
115
|
state.phase === "failed");
|
|
114
116
|
default:
|
|
@@ -136,7 +138,7 @@ const SATISFIED_PHASES = {
|
|
|
136
138
|
initialize: ["initialized", "starting", "started"],
|
|
137
139
|
start: ["started"],
|
|
138
140
|
stop: ["created", "initialized", "stopped", "destroying", "destroyed"],
|
|
139
|
-
destroy: ["destroyed"],
|
|
141
|
+
destroy: ["created", "destroyed"],
|
|
140
142
|
};
|
|
141
143
|
/**
|
|
142
144
|
* Phases a required dependency must be in before a dependent
|
|
@@ -226,4 +228,3 @@ export async function executeLifecyclePhase(order, hook, activePhase, completedP
|
|
|
226
228
|
skipped: Object.freeze([...skipped]),
|
|
227
229
|
};
|
|
228
230
|
}
|
|
229
|
-
//# sourceMappingURL=moduleLifecycle.stateMachine.js.map
|
|
@@ -33,4 +33,3 @@ export declare function isModuleDeprecated(metadata: ModuleMetadata | undefined)
|
|
|
33
33
|
export declare function isModuleExperimental(metadata: ModuleMetadata | undefined): boolean;
|
|
34
34
|
/** Creates a compact metadata object suitable for diagnostics. */
|
|
35
35
|
export declare function getModuleMetadataSummary(metadata?: ModuleMetadata): Readonly<Record<string, unknown>>;
|
|
36
|
-
//# sourceMappingURL=moduleMetadata.metadata.d.ts.map
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { type ModuleRegistrationState, type ModuleRegistration, type ModuleRegistryOptions, type ModuleRegisterOptions, type ModuleRegistryEventType, type ModuleRegistryEvent, type ModuleRegistryListener, type ModuleRegistry, } from "./moduleRegistry.type.js";
|
|
7
7
|
export { DefaultModuleRegistry, createModuleRegistry, isModuleRegistration, } from "./moduleRegistry.registry.js";
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -32,4 +32,3 @@ export declare class DefaultModuleRegistry implements ModuleRegistry {
|
|
|
32
32
|
export declare function createModuleRegistry(options?: ModuleRegistryOptions): ModuleRegistry;
|
|
33
33
|
/** Type guard for module registrations. */
|
|
34
34
|
export declare function isModuleRegistration(value: unknown): value is ModuleRegistration;
|
|
35
|
-
//# sourceMappingURL=moduleRegistry.registry.d.ts.map
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Public API for the core runtime subsystem.
|
|
5
5
|
*/
|
|
6
6
|
export { DefaultRuntime, createRuntime } from "./runtime.js";
|
|
7
|
-
export type { RuntimeLifecycleState, RuntimeDependencies, RuntimeStatus, Runtime, } from "./runtime.js";
|
|
7
|
+
export type { RuntimeLifecycleState, RuntimeDependencies, RuntimeStateListener, RuntimeStatus, Runtime, } from "./runtime.js";
|
|
8
8
|
export { DEFAULT_RUNTIME_OPTIONS, resolveRuntimeOptions, validateRuntimeOptions, isRuntimeMode, isRuntimeRole, assertRuntimeMode, assertRuntimeRole, } from "./runtimeOptions/index.js";
|
|
9
9
|
export type { RuntimeMode, RuntimeRole, RuntimeOptions, RuntimeStartupOptions, RuntimeShutdownOptions, RuntimeSignalOptions, RuntimeDiagnosticsOptions, RuntimeEnvironmentOverrides, ResolvedRuntimeOptions, } from "./runtimeOptions/index.js";
|
|
10
10
|
export { RuntimeState, TERMINAL_RUNTIME_STATES, STARTABLE_RUNTIME_STATES, STOPPABLE_RUNTIME_STATES, TRANSITIONAL_RUNTIME_STATES, isRuntimeState, isRuntimeReady, isRuntimeFailed, isRuntimeTransitioning, isRuntimeTerminal, canStartRuntime, canStopRuntime, canTransitionRuntime, assertRuntimeState, assertRuntimeTransition, createRuntimeStateSnapshot, createRuntimeStateTransition, getRuntimeStateLabel, getRuntimeStates, getNextRuntimeStates, } from "./runtimeState.state.js";
|
|
@@ -23,4 +23,3 @@ export { withRuntimeTimeout } from "./runtimeTimeout.js";
|
|
|
23
23
|
export type { TimeoutAwareOperation, RuntimeTimeoutOptions, } from "./runtimeTimeout.js";
|
|
24
24
|
export { RuntimeError, RuntimeErrorCode, InvalidRuntimeStateError, InvalidRuntimeTransitionError, RuntimeStartError, RuntimeStopError, RuntimeInitializationError, RuntimeLoadError, RuntimeTimeoutError, RuntimeDependencyError, RuntimeNotReadyError, RuntimeUnsupportedOperationError, RuntimeCancellationError, toRuntimeError, isRuntimeError, hasRuntimeErrorCode, createRuntimeError, } from "./runtimeError/index.js";
|
|
25
25
|
export type { RuntimeOperation, RuntimeErrorPhase, RuntimeErrorMetadata, RuntimeErrorOptions, RuntimeErrorJSON, } from "./runtimeError/index.js";
|
|
26
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/runtime/index.js
CHANGED
|
@@ -43,4 +43,3 @@ export { withRuntimeTimeout } from "./runtimeTimeout.js";
|
|
|
43
43
|
* Runtime errors
|
|
44
44
|
*/
|
|
45
45
|
export { RuntimeError, RuntimeErrorCode, InvalidRuntimeStateError, InvalidRuntimeTransitionError, RuntimeStartError, RuntimeStopError, RuntimeInitializationError, RuntimeLoadError, RuntimeTimeoutError, RuntimeDependencyError, RuntimeNotReadyError, RuntimeUnsupportedOperationError, RuntimeCancellationError, toRuntimeError, isRuntimeError, hasRuntimeErrorCode, createRuntimeError, } from "./runtimeError/index.js";
|
|
46
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -8,7 +8,7 @@ import type { ModuleRegistry } from "../modules/moduleRegistry/index.js";
|
|
|
8
8
|
import type { Disposable } from "../contracts/disposable.js";
|
|
9
9
|
import type { ContextStorage } from "../context/provider/contextStorage.storage.js";
|
|
10
10
|
import { RuntimeState } from "./runtimeState.state.js";
|
|
11
|
-
import type { RuntimeStateSnapshot, RuntimeTiming } from "./runtimeState.state.js";
|
|
11
|
+
import type { RuntimeStateSnapshot, RuntimeStateTransition, RuntimeTiming } from "./runtimeState.state.js";
|
|
12
12
|
import type { RuntimeExecutionContext, RuntimeIdentity } from "./runtimeContext/index.js";
|
|
13
13
|
import type { RuntimeEnvironment } from "./runtimeEnvironment/index.js";
|
|
14
14
|
import type { RuntimeOptions, ResolvedRuntimeOptions } from "./runtimeOptions/index.js";
|
|
@@ -20,6 +20,11 @@ import type { RuntimeSignalTarget } from "./runtimeSignals/runtimeSignals.js";
|
|
|
20
20
|
* RuntimeState enum).
|
|
21
21
|
*/
|
|
22
22
|
export type RuntimeLifecycleState = `${RuntimeState}`;
|
|
23
|
+
/**
|
|
24
|
+
* Receives every runtime state transition, synchronously, after the
|
|
25
|
+
* state has changed.
|
|
26
|
+
*/
|
|
27
|
+
export type RuntimeStateListener = (transition: RuntimeStateTransition) => void;
|
|
23
28
|
/**
|
|
24
29
|
* Dependencies required by the runtime.
|
|
25
30
|
*
|
|
@@ -106,6 +111,16 @@ export interface Runtime extends Disposable {
|
|
|
106
111
|
getModuleLifecycle(): ModuleLifecycleManager;
|
|
107
112
|
getModule(moduleId: string): Module | undefined;
|
|
108
113
|
requireModule(moduleId: string): Module;
|
|
114
|
+
/**
|
|
115
|
+
* Subscribes to state transitions; returns the unsubscribe function.
|
|
116
|
+
*
|
|
117
|
+
* The Application uses this to follow a stop the runtime started on
|
|
118
|
+
* its own (a SIGTERM, a fatal error), so its own state and its
|
|
119
|
+
* lifecycle participants do not stay `running` behind a stopped
|
|
120
|
+
* runtime. Optional on the contract so hand-written runtimes keep
|
|
121
|
+
* compiling; without it the Application cannot follow such stops.
|
|
122
|
+
*/
|
|
123
|
+
onStateChange?(listener: RuntimeStateListener): () => void;
|
|
109
124
|
}
|
|
110
125
|
/**
|
|
111
126
|
* Default runtime implementation.
|
|
@@ -136,6 +151,7 @@ export declare class DefaultRuntime implements Runtime {
|
|
|
136
151
|
private _stopPromise;
|
|
137
152
|
private _unwound;
|
|
138
153
|
private _unwindPromise;
|
|
154
|
+
private readonly _stateListeners;
|
|
139
155
|
constructor(dependencies: RuntimeDependencies, options?: RuntimeOptions);
|
|
140
156
|
get state(): RuntimeState;
|
|
141
157
|
get context(): RuntimeExecutionContext;
|
|
@@ -148,6 +164,7 @@ export declare class DefaultRuntime implements Runtime {
|
|
|
148
164
|
get stopped(): boolean;
|
|
149
165
|
get failed(): boolean;
|
|
150
166
|
get signalHandlersRegistered(): boolean;
|
|
167
|
+
onStateChange(listener: RuntimeStateListener): () => void;
|
|
151
168
|
start(): Promise<void>;
|
|
152
169
|
stop(): Promise<void>;
|
|
153
170
|
fail(error?: unknown): void;
|
|
@@ -190,4 +207,3 @@ export declare class DefaultRuntime implements Runtime {
|
|
|
190
207
|
* Creates a runtime.
|
|
191
208
|
*/
|
|
192
209
|
export declare function createRuntime(dependencies: RuntimeDependencies, options?: RuntimeOptions): Runtime;
|
|
193
|
-
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime/runtime.js
CHANGED
|
@@ -38,6 +38,7 @@ export class DefaultRuntime {
|
|
|
38
38
|
_stopPromise;
|
|
39
39
|
_unwound = false;
|
|
40
40
|
_unwindPromise;
|
|
41
|
+
_stateListeners = new Set();
|
|
41
42
|
constructor(dependencies, options = {}) {
|
|
42
43
|
this._options = resolveRuntimeOptions(options);
|
|
43
44
|
this._application = dependencies.application;
|
|
@@ -122,6 +123,12 @@ export class DefaultRuntime {
|
|
|
122
123
|
get signalHandlersRegistered() {
|
|
123
124
|
return this._signals.registered;
|
|
124
125
|
}
|
|
126
|
+
onStateChange(listener) {
|
|
127
|
+
this._stateListeners.add(listener);
|
|
128
|
+
return () => {
|
|
129
|
+
this._stateListeners.delete(listener);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
125
132
|
async start() {
|
|
126
133
|
if (this._state === RuntimeState.READY)
|
|
127
134
|
return;
|
|
@@ -319,6 +326,22 @@ export class DefaultRuntime {
|
|
|
319
326
|
catch {
|
|
320
327
|
/* Logging must never prevent a lifecycle transition. */
|
|
321
328
|
}
|
|
329
|
+
if (this._stateListeners.size === 0)
|
|
330
|
+
return;
|
|
331
|
+
const transition = Object.freeze({
|
|
332
|
+
from: current,
|
|
333
|
+
to: next,
|
|
334
|
+
timestamp: new Date(),
|
|
335
|
+
reason,
|
|
336
|
+
});
|
|
337
|
+
for (const listener of this._stateListeners) {
|
|
338
|
+
try {
|
|
339
|
+
listener(transition);
|
|
340
|
+
}
|
|
341
|
+
catch {
|
|
342
|
+
/* A listener must never prevent a lifecycle transition. */
|
|
343
|
+
}
|
|
344
|
+
}
|
|
322
345
|
}
|
|
323
346
|
recordTimingForState(state) {
|
|
324
347
|
const now = new Date();
|
|
@@ -417,4 +440,3 @@ export class DefaultRuntime {
|
|
|
417
440
|
export function createRuntime(dependencies, options = {}) {
|
|
418
441
|
return new DefaultRuntime(dependencies, options);
|
|
419
442
|
}
|
|
420
|
-
//# sourceMappingURL=runtime.js.map
|
|
@@ -8,4 +8,3 @@ export { DefaultRuntimeBootstrap } from "./runtimeBootstrap.core.js";
|
|
|
8
8
|
export { executeBootstrapPipeline, createBootstrapPipelineState, createBootstrapResult, } from "./pipeline/index.js";
|
|
9
9
|
export type { BootstrapCounters, BootstrapPipelineServices, BootstrapPipelineState, } from "./pipeline/index.js";
|
|
10
10
|
export type { RuntimeBootstrapDependencies, RuntimeBootstrapOptions, RuntimeBootstrapPhase, RuntimeBootstrapErrorInfo, RuntimeBootstrapResult, RuntimeBootstrap, ResolvedBootstrapOptions, } from "./runtimeBootstrap.type.js";
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { executeBootstrapPipeline, createBootstrapPipelineState, createBootstrapResult, } from "./runtimeBootstrap.pipeline.js";
|
|
7
7
|
export type { BootstrapCounters, BootstrapLogFn, BootstrapPipelineServices, BootstrapPipelineState, } from "./runtimeBootstrap.pipeline.js";
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -44,4 +44,3 @@ export declare function createBootstrapPipelineState(): BootstrapPipelineState;
|
|
|
44
44
|
*/
|
|
45
45
|
export declare function executeBootstrapPipeline(options: ResolvedBootstrapOptions, services: BootstrapPipelineServices, state: BootstrapPipelineState, signal: AbortSignal, setPhase: (phase: RuntimeBootstrapPhase) => void, log: BootstrapLogFn): Promise<void>;
|
|
46
46
|
export declare function createBootstrapResult(success: boolean, phase: RuntimeBootstrapPhase, counters: BootstrapCounters, errors: readonly RuntimeBootstrapErrorInfo[], startedAt: Date, completedAt: Date): RuntimeBootstrapResult;
|
|
47
|
-
//# sourceMappingURL=runtimeBootstrap.pipeline.d.ts.map
|
|
@@ -49,8 +49,15 @@ export class DefaultRuntimeBootstrap {
|
|
|
49
49
|
const diagnostics = this._runtimeOptions.diagnostics;
|
|
50
50
|
try {
|
|
51
51
|
if (diagnostics.startupLogging) {
|
|
52
|
+
// The phase about to run, not the pipeline's resting "created".
|
|
52
53
|
this.log("info", "Runtime bootstrap started.", {
|
|
53
|
-
...(diagnostics.includeState && {
|
|
54
|
+
...(diagnostics.includeState && {
|
|
55
|
+
phase: configuration.loadModules
|
|
56
|
+
? "loading"
|
|
57
|
+
: configuration.initializeModules
|
|
58
|
+
? "initializing"
|
|
59
|
+
: "starting",
|
|
60
|
+
}),
|
|
54
61
|
});
|
|
55
62
|
}
|
|
56
63
|
await withRuntimeTimeout((signal) => executeBootstrapPipeline(configuration, {
|
|
@@ -147,4 +154,3 @@ export class DefaultRuntimeBootstrap {
|
|
|
147
154
|
logRuntimeEvent(this._logger, this._identity, this._environment, level, message, metadata);
|
|
148
155
|
}
|
|
149
156
|
}
|
|
150
|
-
//# sourceMappingURL=runtimeBootstrap.core.js.map
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { createRuntimeId, createRuntimeIdentity, createRuntimeExecutionContext, createRuntimeContext, } from "./runtimeContext.factory.js";
|
|
7
7
|
export type { RuntimeIdentity, RuntimeExecutionMetadata, RuntimeExecutionContext, RuntimeContext, } from "./runtimeContext.type.js";
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -25,4 +25,3 @@ export declare function createRuntimeExecutionContext(identity: RuntimeIdentity,
|
|
|
25
25
|
* @deprecated Use createRuntimeExecutionContext.
|
|
26
26
|
*/
|
|
27
27
|
export declare const createRuntimeContext: typeof createRuntimeExecutionContext;
|
|
28
|
-
//# sourceMappingURL=runtimeContext.factory.d.ts.map
|
|
@@ -6,4 +6,3 @@
|
|
|
6
6
|
export { detectRuntimeEngine, detectPlatform, detectProcessInfo, detectHostInfo, readProcessEnvironment, getProcessObject, } from "./runtimeEnvironment.detection.js";
|
|
7
7
|
export { getNodeOsObject, safeCall } from "./runtimeEnvironment.os.js";
|
|
8
8
|
export { detectCI, detectContainer } from "./runtimeEnvironment.env.js";
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -6,4 +6,3 @@
|
|
|
6
6
|
export { detectRuntimeEngine, detectPlatform, detectProcessInfo, detectHostInfo, readProcessEnvironment, getProcessObject, } from "./runtimeEnvironment.detection.js";
|
|
7
7
|
export { getNodeOsObject, safeCall } from "./runtimeEnvironment.os.js";
|
|
8
8
|
export { detectCI, detectContainer } from "./runtimeEnvironment.env.js";
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -5,4 +5,3 @@ export declare function detectProcessInfo(): RuntimeProcessInfo;
|
|
|
5
5
|
export declare function detectHostInfo(platform: RuntimePlatform): RuntimeHostInfo;
|
|
6
6
|
export declare function readProcessEnvironment(): RuntimeEnvironmentVariables;
|
|
7
7
|
export declare function getProcessObject(): RuntimeProcess | undefined;
|
|
8
|
-
//# sourceMappingURL=runtimeEnvironment.detection.d.ts.map
|
|
@@ -7,4 +7,3 @@
|
|
|
7
7
|
export { DefaultRuntimeEnvironment, MissingEnvironmentVariableError, createRuntimeEnvironment, } from "./runtimeEnvironment.core.js";
|
|
8
8
|
export { detectRuntimeEngine, detectPlatform, detectProcessInfo, detectHostInfo, getNodeOsObject, safeCall, detectCI, detectContainer, } from "./detection/index.js";
|
|
9
9
|
export type { RuntimePlatform, RuntimeEngine, RuntimeEnvironmentVariables, RuntimeProcessInfo, RuntimeHostInfo, RuntimeEngineInfo, RuntimeEnvironmentInfo, RuntimeEnvironmentSummary, RuntimeEnvironment, RuntimeEnvironmentOptions, } from "./runtimeEnvironment.type.js";
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -6,4 +6,3 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { DefaultRuntimeEnvironment, MissingEnvironmentVariableError, createRuntimeEnvironment, } from "./runtimeEnvironment.core.js";
|
|
8
8
|
export { detectRuntimeEngine, detectPlatform, detectProcessInfo, detectHostInfo, getNodeOsObject, safeCall, detectCI, detectContainer, } from "./detection/index.js";
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -26,4 +26,3 @@ export declare function hasRuntimeErrorCode(error: unknown, code: RuntimeErrorCo
|
|
|
26
26
|
* Creates a runtime error with contextual information.
|
|
27
27
|
*/
|
|
28
28
|
export declare function createRuntimeError(message: string, options?: RuntimeErrorOptions): RuntimeErrorType;
|
|
29
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -47,4 +47,3 @@ export declare class RuntimeInitializationError extends RuntimeError {
|
|
|
47
47
|
export declare class RuntimeLoadError extends RuntimeError {
|
|
48
48
|
constructor(message: string, options?: Omit<RuntimeErrorOptions, "operation">);
|
|
49
49
|
}
|
|
50
|
-
//# sourceMappingURL=runtimeError.lifecycle.d.ts.map
|