lifecycleion 0.0.14 → 0.0.15
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 +1 -1
- package/dist/lib/lifecycle-manager/index.cjs +26 -4
- package/dist/lib/lifecycle-manager/index.cjs.map +1 -1
- package/dist/lib/lifecycle-manager/index.d.cts +18 -4
- package/dist/lib/lifecycle-manager/index.d.ts +18 -4
- package/dist/lib/lifecycle-manager/index.js +26 -4
- package/dist/lib/lifecycle-manager/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1477,6 +1477,7 @@ var LIFECYCLE_MANAGER_LOG_REQUIRED_COMPONENT_UNEXPECTED_STOP_DURING_STARTUP = "R
|
|
|
1477
1477
|
var LIFECYCLE_MANAGER_MESSAGE_REGISTER_SHUTDOWN_IN_PROGRESS = "Cannot register component while shutdown is in progress (isShuttingDown=true).";
|
|
1478
1478
|
var LIFECYCLE_MANAGER_MESSAGE_REGISTER_REQUIRED_DEPENDENCY_DURING_STARTUP = "Cannot register component during startup when it is a required dependency for other components.";
|
|
1479
1479
|
var LIFECYCLE_MANAGER_MESSAGE_DUPLICATE_COMPONENT_INSTANCE = "Component instance is already registered.";
|
|
1480
|
+
var LIFECYCLE_MANAGER_MESSAGE_DUPLICATE_COMPONENT_INSTANCE_EXTERNAL = "Component instance is already registered with another lifecycle manager.";
|
|
1480
1481
|
|
|
1481
1482
|
// src/lib/process-signal-manager.ts
|
|
1482
1483
|
var import_ulid = require("ulid");
|
|
@@ -2266,6 +2267,7 @@ var LifecycleManager = class extends EventEmitterProtected {
|
|
|
2266
2267
|
}
|
|
2267
2268
|
this.components = this.components.filter((c) => c.getName() !== name);
|
|
2268
2269
|
component._clearUnexpectedStopHandler();
|
|
2270
|
+
component._markUnregistered();
|
|
2269
2271
|
this.componentStates.delete(name);
|
|
2270
2272
|
this.componentTimestamps.delete(name);
|
|
2271
2273
|
this.componentErrors.delete(name);
|
|
@@ -3984,12 +3986,16 @@ var LifecycleManager = class extends EventEmitterProtected {
|
|
|
3984
3986
|
targetFound: void 0
|
|
3985
3987
|
});
|
|
3986
3988
|
}
|
|
3987
|
-
if (
|
|
3988
|
-
this.
|
|
3989
|
+
if (component._isRegisteredWithManager()) {
|
|
3990
|
+
const isRegisteredHere = this.hasComponentInstance(component);
|
|
3991
|
+
const message = isRegisteredHere ? LIFECYCLE_MANAGER_MESSAGE_DUPLICATE_COMPONENT_INSTANCE : LIFECYCLE_MANAGER_MESSAGE_DUPLICATE_COMPONENT_INSTANCE_EXTERNAL;
|
|
3992
|
+
this.logger.entity(componentName).warn(
|
|
3993
|
+
isRegisteredHere ? "Component instance already registered" : "Component instance already registered with another lifecycle manager"
|
|
3994
|
+
);
|
|
3989
3995
|
this.lifecycleEvents.componentRegistrationRejected({
|
|
3990
3996
|
name: componentName,
|
|
3991
3997
|
reason: "duplicate_instance",
|
|
3992
|
-
message
|
|
3998
|
+
message,
|
|
3993
3999
|
registrationIndexBefore,
|
|
3994
4000
|
registrationIndexAfter: registrationIndexBefore,
|
|
3995
4001
|
requestedPosition: isInsertAction ? { position, targetComponentName } : void 0,
|
|
@@ -4001,7 +4007,7 @@ var LifecycleManager = class extends EventEmitterProtected {
|
|
|
4001
4007
|
targetComponentName,
|
|
4002
4008
|
registrationIndexBefore,
|
|
4003
4009
|
code: "duplicate_instance",
|
|
4004
|
-
reason:
|
|
4010
|
+
reason: message,
|
|
4005
4011
|
targetFound: void 0
|
|
4006
4012
|
});
|
|
4007
4013
|
}
|
|
@@ -4114,6 +4120,7 @@ var LifecycleManager = class extends EventEmitterProtected {
|
|
|
4114
4120
|
getValueInternal: (compName, key, from) => this.getValueInternal(compName, key, from)
|
|
4115
4121
|
};
|
|
4116
4122
|
component.lifecycle = new ComponentLifecycle(this, componentName, internalCallbacks);
|
|
4123
|
+
component._markRegistered();
|
|
4117
4124
|
this.componentStates.set(componentName, "registered");
|
|
4118
4125
|
this.componentTimestamps.set(componentName, {
|
|
4119
4126
|
startedAt: null,
|
|
@@ -6390,6 +6397,8 @@ var BaseComponent = class {
|
|
|
6390
6397
|
_unexpectedStopHandler;
|
|
6391
6398
|
/** @internal Incremented whenever the unexpected-stop handler is re-armed or cleared. */
|
|
6392
6399
|
_unexpectedStopGeneration = 0;
|
|
6400
|
+
/** @internal Flag indicating whether this component is currently registered with a LifecycleManager */
|
|
6401
|
+
_isRegistered = false;
|
|
6393
6402
|
/**
|
|
6394
6403
|
* Create a new component
|
|
6395
6404
|
*
|
|
@@ -6442,6 +6451,19 @@ var BaseComponent = class {
|
|
|
6442
6451
|
this._unexpectedStopHandler = void 0;
|
|
6443
6452
|
this.reportUnexpectedStop = () => false;
|
|
6444
6453
|
}
|
|
6454
|
+
/** @internal Called by LifecycleManager when registering the component. */
|
|
6455
|
+
_markRegistered() {
|
|
6456
|
+
this._isRegistered = true;
|
|
6457
|
+
}
|
|
6458
|
+
/** @internal Called by LifecycleManager when unregistering the component. */
|
|
6459
|
+
_markUnregistered() {
|
|
6460
|
+
this._isRegistered = false;
|
|
6461
|
+
this.lifecycle = void 0;
|
|
6462
|
+
}
|
|
6463
|
+
/** @internal Check if the component is registered with any LifecycleManager. */
|
|
6464
|
+
_isRegisteredWithManager() {
|
|
6465
|
+
return this._isRegistered;
|
|
6466
|
+
}
|
|
6445
6467
|
/**
|
|
6446
6468
|
* Get component name
|
|
6447
6469
|
*/
|