@zudojs/lifecycle 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.
Files changed (70) hide show
  1. package/README.md +44 -15
  2. package/dist/index.d.ts +2 -3
  3. package/dist/index.js +7 -1
  4. package/dist/lifecycleComponent/index.d.ts +0 -1
  5. package/dist/lifecycleComponent/index.js +0 -1
  6. package/dist/lifecycleComponent/lifecycleComponent.type.d.ts +27 -8
  7. package/dist/lifecycleComponent/lifecycleComponent.type.js +0 -1
  8. package/dist/lifecycleContext/index.d.ts +0 -1
  9. package/dist/lifecycleContext/index.js +0 -1
  10. package/dist/lifecycleContext/lifecycleContext.type.d.ts +0 -1
  11. package/dist/lifecycleContext/lifecycleContext.type.js +0 -1
  12. package/dist/lifecycleEvents/index.d.ts +0 -1
  13. package/dist/lifecycleEvents/index.js +0 -1
  14. package/dist/lifecycleEvents/lifecycleEvents.core.d.ts +20 -5
  15. package/dist/lifecycleEvents/lifecycleEvents.core.js +0 -1
  16. package/dist/lifecycleExecutor/index.d.ts +3 -3
  17. package/dist/lifecycleExecutor/index.js +2 -2
  18. package/dist/lifecycleExecutor/lifecycleExecutor.abandoned.d.ts +31 -0
  19. package/dist/lifecycleExecutor/lifecycleExecutor.abandoned.js +75 -0
  20. package/dist/lifecycleExecutor/lifecycleExecutor.core.d.ts +18 -24
  21. package/dist/lifecycleExecutor/lifecycleExecutor.core.js +64 -105
  22. package/dist/lifecycleExecutor/lifecycleExecutor.retry.d.ts +30 -0
  23. package/dist/lifecycleExecutor/lifecycleExecutor.retry.js +66 -0
  24. package/dist/lifecycleExecutor/lifecycleExecutor.type.d.ts +50 -0
  25. package/dist/lifecycleExecutor/lifecycleExecutor.type.js +6 -0
  26. package/dist/lifecycleInternal/asyncUtils.core.d.ts +0 -1
  27. package/dist/lifecycleInternal/asyncUtils.core.js +0 -1
  28. package/dist/lifecycleInternal/dependencyGraph.core.d.ts +34 -7
  29. package/dist/lifecycleInternal/dependencyGraph.core.js +55 -38
  30. package/dist/lifecycleInternal/dependencyGraph.cycle.d.ts +20 -0
  31. package/dist/lifecycleInternal/dependencyGraph.cycle.js +57 -0
  32. package/dist/lifecycleInternal/index.d.ts +1 -1
  33. package/dist/lifecycleInternal/index.js +0 -1
  34. package/dist/lifecycleInternal/timeoutBudget.core.d.ts +0 -1
  35. package/dist/lifecycleInternal/timeoutBudget.core.js +0 -1
  36. package/dist/lifecycleInternal/topologicalSort.core.d.ts +12 -2
  37. package/dist/lifecycleInternal/topologicalSort.core.js +41 -22
  38. package/dist/lifecycleManager/index.d.ts +0 -1
  39. package/dist/lifecycleManager/index.js +0 -1
  40. package/dist/lifecycleManager/lifecycleManager.context.d.ts +15 -7
  41. package/dist/lifecycleManager/lifecycleManager.context.js +0 -1
  42. package/dist/lifecycleManager/lifecycleManager.core.d.ts +12 -2
  43. package/dist/lifecycleManager/lifecycleManager.core.js +30 -3
  44. package/dist/lifecycleManager/lifecycleManager.deadline.d.ts +29 -0
  45. package/dist/lifecycleManager/lifecycleManager.deadline.js +79 -0
  46. package/dist/lifecycleManager/lifecycleManager.shutdown.d.ts +0 -1
  47. package/dist/lifecycleManager/lifecycleManager.shutdown.js +60 -69
  48. package/dist/lifecycleManager/lifecycleManager.startup.d.ts +0 -1
  49. package/dist/lifecycleManager/lifecycleManager.startup.js +12 -4
  50. package/dist/lifecyclePhase/index.d.ts +0 -1
  51. package/dist/lifecyclePhase/index.js +0 -1
  52. package/dist/lifecyclePhase/lifecyclePhase.core.d.ts +0 -1
  53. package/dist/lifecyclePhase/lifecyclePhase.core.js +0 -1
  54. package/dist/lifecyclePlan/index.d.ts +0 -1
  55. package/dist/lifecyclePlan/index.js +0 -1
  56. package/dist/lifecyclePlan/lifecyclePlan.core.d.ts +0 -1
  57. package/dist/lifecyclePlan/lifecyclePlan.core.js +0 -2
  58. package/dist/lifecycleRegistry/index.d.ts +0 -1
  59. package/dist/lifecycleRegistry/index.js +0 -1
  60. package/dist/lifecycleRegistry/lifecycleRegistry.core.d.ts +0 -1
  61. package/dist/lifecycleRegistry/lifecycleRegistry.core.js +3 -2
  62. package/dist/lifecycleSignal/index.d.ts +0 -1
  63. package/dist/lifecycleSignal/index.js +0 -1
  64. package/dist/lifecycleSignal/lifecycleSignal.handler.d.ts +0 -1
  65. package/dist/lifecycleSignal/lifecycleSignal.handler.js +0 -1
  66. package/dist/lifecycleState/index.d.ts +0 -1
  67. package/dist/lifecycleState/index.js +0 -1
  68. package/dist/lifecycleState/lifecycleState.machine.d.ts +0 -1
  69. package/dist/lifecycleState/lifecycleState.machine.js +0 -1
  70. package/package.json +3 -3
@@ -40,7 +40,7 @@ const PHASE_EVENTS = {
40
40
  end: "component:started",
41
41
  },
42
42
  [LifecyclePhase.READY]: {
43
- begin: "component:starting",
43
+ begin: "component:readying",
44
44
  end: "component:ready",
45
45
  },
46
46
  };
@@ -48,7 +48,7 @@ const PHASE_EVENTS = {
48
48
  const PHASE_APPLICATION_EVENT = {
49
49
  [LifecyclePhase.INITIALIZE]: "application:initializing",
50
50
  [LifecyclePhase.START]: "application:starting",
51
- [LifecyclePhase.READY]: "application:starting",
51
+ [LifecyclePhase.READY]: "application:readying",
52
52
  };
53
53
  /**
54
54
  * Performs the full startup sequence: initialize → start → ready.
@@ -189,7 +189,6 @@ async function executePhase(ctx, phase) {
189
189
  continue;
190
190
  transitionComponentBatch(ctx, runnable.map((r) => r.id), EXECUTING_STATE[phase]);
191
191
  for (const reg of runnable) {
192
- markAttempted(ctx, reg.id, phase);
193
192
  ctx.events.emit(events.begin, {
194
193
  component: { componentId: reg.id },
195
194
  });
@@ -205,6 +204,16 @@ async function executePhase(ctx, phase) {
205
204
  }
206
205
  for (const result of results) {
207
206
  recordResult(ctx, result);
207
+ // A phase counts as reached when its hook completed or timed out
208
+ // (still running, outcome unknown). `initialize` counts even when
209
+ // it threw: a half-initialised component may hold resources that
210
+ // only dispose() releases. A thrown start() does NOT count, so
211
+ // stop() is never called on a component that never started.
212
+ if (result.success ||
213
+ result.timedOut === true ||
214
+ phase === LifecyclePhase.INITIALIZE) {
215
+ markAttempted(ctx, result.id, phase);
216
+ }
208
217
  if (!result.success) {
209
218
  transitionComponent(ctx, result.id, LifecycleState.FAILED);
210
219
  emitComponentFailed(ctx, result);
@@ -226,4 +235,3 @@ async function executePhase(ctx, phase) {
226
235
  }
227
236
  return undefined;
228
237
  }
229
- //# sourceMappingURL=lifecycleManager.startup.js.map
@@ -4,4 +4,3 @@
4
4
  * Lifecycle phase ordering and hook name utilities.
5
5
  */
6
6
  export { STARTUP_PHASES, SHUTDOWN_PHASES, getPhaseHookName, getComponentMethod, } from "./lifecyclePhase.core.js";
7
- //# sourceMappingURL=index.d.ts.map
@@ -4,4 +4,3 @@
4
4
  * Lifecycle phase ordering and hook name utilities.
5
5
  */
6
6
  export { STARTUP_PHASES, SHUTDOWN_PHASES, getPhaseHookName, getComponentMethod, } from "./lifecyclePhase.core.js";
7
- //# sourceMappingURL=index.js.map
@@ -22,4 +22,3 @@ export declare function getPhaseHookName(phase: LifecyclePhase): string;
22
22
  * `stop` and `dispose`.
23
23
  */
24
24
  export declare function getComponentMethod(phase: LifecyclePhase): string;
25
- //# sourceMappingURL=lifecyclePhase.core.d.ts.map
@@ -44,4 +44,3 @@ export function getPhaseHookName(phase) {
44
44
  export function getComponentMethod(phase) {
45
45
  return getPhaseHookName(phase);
46
46
  }
47
- //# sourceMappingURL=lifecyclePhase.core.js.map
@@ -5,4 +5,3 @@
5
5
  */
6
6
  export { buildExecutionPlan } from "./lifecyclePlan.core.js";
7
7
  export type { ExecutionStage, ExecutionPlan } from "./lifecyclePlan.core.js";
8
- //# sourceMappingURL=index.d.ts.map
@@ -4,4 +4,3 @@
4
4
  * Lifecycle execution planner for building startup/shutdown stages.
5
5
  */
6
6
  export { buildExecutionPlan } from "./lifecyclePlan.core.js";
7
- //# sourceMappingURL=index.js.map
@@ -23,4 +23,3 @@ export interface ExecutionPlan {
23
23
  * Builds an execution plan for a given lifecycle phase.
24
24
  */
25
25
  export declare function buildExecutionPlan(registrations: readonly LifecycleRegistration[], phase: LifecyclePhase): ExecutionPlan;
26
- //# sourceMappingURL=lifecyclePlan.core.d.ts.map
@@ -35,10 +35,8 @@ function buildGraphForPhase(registrations) {
35
35
  for (const reg of registrations) {
36
36
  graph.addNode(reg.id);
37
37
  for (const dep of reg.dependsOn) {
38
- graph.addNode(dep);
39
38
  graph.addEdge(reg.id, dep);
40
39
  }
41
40
  }
42
41
  return graph;
43
42
  }
44
- //# sourceMappingURL=lifecyclePlan.core.js.map
@@ -4,4 +4,3 @@
4
4
  * Lifecycle component registry with validation and dependency tracking.
5
5
  */
6
6
  export { LifecycleRegistry } from "./lifecycleRegistry.core.js";
7
- //# sourceMappingURL=index.d.ts.map
@@ -4,4 +4,3 @@
4
4
  * Lifecycle component registry with validation and dependency tracking.
5
5
  */
6
6
  export { LifecycleRegistry } from "./lifecycleRegistry.core.js";
7
- //# sourceMappingURL=index.js.map
@@ -32,4 +32,3 @@ export declare class LifecycleRegistry {
32
32
  /** Returns the number of registered components. */
33
33
  get size(): number;
34
34
  }
35
- //# sourceMappingURL=lifecycleRegistry.core.d.ts.map
@@ -45,8 +45,10 @@ export class LifecycleRegistry {
45
45
  };
46
46
  this._registrations.set(id, registration);
47
47
  this._graph.addNode(id);
48
+ // Dependencies are NOT declared here: the graph tracks them as
49
+ // undeclared until the dependency itself registers, so a typo in
50
+ // `dependsOn` is caught by the graph as well as by validate().
48
51
  for (const dep of registration.dependsOn) {
49
- this._graph.addNode(dep);
50
52
  this._graph.addEdge(id, dep);
51
53
  }
52
54
  }
@@ -95,4 +97,3 @@ export class LifecycleRegistry {
95
97
  return this._registrations.size;
96
98
  }
97
99
  }
98
- //# sourceMappingURL=lifecycleRegistry.core.js.map
@@ -5,4 +5,3 @@
5
5
  */
6
6
  export { installSignalHandlers, DEFAULT_SHUTDOWN_SIGNALS, } from "./lifecycleSignal.handler.js";
7
7
  export type { SignalHandlerOptions } from "./lifecycleSignal.handler.js";
8
- //# sourceMappingURL=index.d.ts.map
@@ -4,4 +4,3 @@
4
4
  * Process signal handler for graceful shutdown.
5
5
  */
6
6
  export { installSignalHandlers, DEFAULT_SHUTDOWN_SIGNALS, } from "./lifecycleSignal.handler.js";
7
- //# sourceMappingURL=index.js.map
@@ -26,4 +26,3 @@ export declare const DEFAULT_SHUTDOWN_SIGNALS: readonly NodeJS.Signals[];
26
26
  * Returns a cleanup function to remove the handlers.
27
27
  */
28
28
  export declare function installSignalHandlers(options: SignalHandlerOptions): () => void;
29
- //# sourceMappingURL=lifecycleSignal.handler.d.ts.map
@@ -38,4 +38,3 @@ export function installSignalHandlers(options) {
38
38
  }
39
39
  };
40
40
  }
41
- //# sourceMappingURL=lifecycleSignal.handler.js.map
@@ -4,4 +4,3 @@
4
4
  * Lifecycle state machine for tracking and validating state transitions.
5
5
  */
6
6
  export { LifecycleStateMachine } from "./lifecycleState.machine.js";
7
- //# sourceMappingURL=index.d.ts.map
@@ -4,4 +4,3 @@
4
4
  * Lifecycle state machine for tracking and validating state transitions.
5
5
  */
6
6
  export { LifecycleStateMachine } from "./lifecycleState.machine.js";
7
- //# sourceMappingURL=index.js.map
@@ -33,4 +33,3 @@ export declare class LifecycleStateMachine {
33
33
  */
34
34
  forceState(state: LifecycleState): void;
35
35
  }
36
- //# sourceMappingURL=lifecycleState.machine.d.ts.map
@@ -54,4 +54,3 @@ export class LifecycleStateMachine {
54
54
  this._state = state;
55
55
  }
56
56
  }
57
- //# sourceMappingURL=lifecycleState.machine.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zudojs/lifecycle",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "description": "Application and component lifecycle orchestration with state machine, dependency ordering, graceful shutdown, rollback, and signals.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -24,8 +24,8 @@
24
24
  "!dist/.tsbuildinfo"
25
25
  ],
26
26
  "dependencies": {
27
- "@zudojs/errors": "1.3.2",
28
- "@zudojs/constants": "1.1.4"
27
+ "@zudojs/errors": "1.4.0",
28
+ "@zudojs/constants": "1.2.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^26.6.2",