@zudojs/core 0.0.1 → 1.0.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 (485) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +141 -7
  3. package/dist/application/application.d.ts +43 -2
  4. package/dist/application/application.js +111 -13
  5. package/dist/application/applicationContext.context.d.ts +15 -0
  6. package/dist/application/applicationContext.context.js +12 -0
  7. package/dist/application/createApplication.d.ts +78 -0
  8. package/dist/application/createApplication.js +104 -0
  9. package/dist/application/index.d.ts +2 -1
  10. package/dist/application/index.js +2 -1
  11. package/dist/configuration/configurationManager.manager.d.ts +32 -0
  12. package/dist/configuration/configurationManager.manager.js +86 -7
  13. package/dist/configuration/core/configuration.d.ts +60 -15
  14. package/dist/configuration/core/configuration.js +248 -51
  15. package/dist/configuration/core/configurationKey.key.d.ts +4 -2
  16. package/dist/configuration/core/configurationKey.key.js +2 -13
  17. package/dist/configuration/core/configurationPath.path.d.ts +17 -0
  18. package/dist/configuration/core/configurationPath.path.js +33 -0
  19. package/dist/configuration/core/index.d.ts +7 -1
  20. package/dist/configuration/core/index.js +1 -0
  21. package/dist/configuration/error/configurationError.error.d.ts +11 -0
  22. package/dist/configuration/error/configurationError.error.js +29 -1
  23. package/dist/configuration/error/configurationRedactor.redactor.d.ts +16 -0
  24. package/dist/configuration/error/configurationRedactor.redactor.js +83 -5
  25. package/dist/configuration/error/index.d.ts +2 -1
  26. package/dist/configuration/error/index.js +2 -1
  27. package/dist/configuration/index.d.ts +1 -1
  28. package/dist/configuration/loader/configurationLoader.loader.d.ts +47 -9
  29. package/dist/configuration/loader/configurationLoader.loader.js +107 -26
  30. package/dist/configuration/loader/index.d.ts +1 -1
  31. package/dist/configuration/loader/index.js +1 -1
  32. package/dist/configuration/registry/configurationProvider.provider.d.ts +26 -1
  33. package/dist/configuration/registry/configurationProvider.provider.js +33 -7
  34. package/dist/configuration/registry/configurationRegistry.registry.js +2 -1
  35. package/dist/configuration/schema/configurationSchema.schema.d.ts +0 -4
  36. package/dist/configuration/schema/configurationSchema.schema.js +11 -32
  37. package/dist/configuration/schema/configurationValidation.validator.d.ts +14 -2
  38. package/dist/configuration/schema/configurationValidation.validator.js +55 -7
  39. package/dist/configuration/schema/index.d.ts +1 -1
  40. package/dist/configuration/schema/index.js +1 -1
  41. package/dist/container/container.d.ts +52 -5
  42. package/dist/container/container.js +110 -33
  43. package/dist/container/index.d.ts +1 -1
  44. package/dist/container/index.js +1 -1
  45. package/dist/container/scope.d.ts +7 -6
  46. package/dist/context/core/contextAliases.deprecated.d.ts +32 -0
  47. package/dist/context/core/contextAliases.deprecated.js +6 -0
  48. package/dist/context/core/executionContext.context.d.ts +8 -0
  49. package/dist/context/core/executionContext.context.js +38 -15
  50. package/dist/context/core/index.d.ts +2 -2
  51. package/dist/context/core/index.js +2 -2
  52. package/dist/context/index.d.ts +20 -0
  53. package/dist/context/index.js +20 -0
  54. package/dist/context/provider/contextProvider.provider.d.ts +7 -4
  55. package/dist/context/provider/contextProvider.provider.js +9 -6
  56. package/dist/context/provider/contextStorage.storage.d.ts +47 -7
  57. package/dist/context/provider/contextStorage.storage.js +54 -12
  58. package/dist/context/provider/defaultContextStorage.storage.d.ts +18 -0
  59. package/dist/context/provider/defaultContextStorage.storage.js +20 -0
  60. package/dist/context/provider/index.d.ts +2 -1
  61. package/dist/context/provider/index.js +1 -0
  62. package/dist/errors/exceptions.d.ts +22 -0
  63. package/dist/errors/exceptions.js +38 -1
  64. package/dist/errors/frameworkError.error.d.ts +6 -9
  65. package/dist/errors/index.d.ts +1 -1
  66. package/dist/errors/index.js +1 -1
  67. package/dist/index.d.ts +4 -0
  68. package/dist/index.js +14 -0
  69. package/dist/lifecycle/core/index.d.ts +1 -1
  70. package/dist/lifecycle/core/index.js +1 -1
  71. package/dist/lifecycle/core/lifecycle.d.ts +47 -2
  72. package/dist/lifecycle/core/lifecycle.js +251 -85
  73. package/dist/lifecycle/core/lifecycleRegistry.registry.d.ts +8 -0
  74. package/dist/lifecycle/core/lifecycleRegistry.registry.js +20 -1
  75. package/dist/lifecycle/manager/lifecycleManager.manager.d.ts +21 -2
  76. package/dist/lifecycle/manager/lifecycleManager.manager.js +62 -99
  77. package/dist/lifecycle/scope/lifecycleScope.scope.d.ts +22 -1
  78. package/dist/lifecycle/scope/lifecycleScope.scope.js +85 -17
  79. package/dist/logging/console/consoleLogger.logger.d.ts +20 -1
  80. package/dist/logging/console/consoleLogger.logger.js +77 -11
  81. package/dist/logging/console/loggerFactory.factory.d.ts +6 -5
  82. package/dist/logging/console/loggerFactory.factory.js +1 -7
  83. package/dist/logging/core/index.d.ts +4 -3
  84. package/dist/logging/core/index.js +4 -3
  85. package/dist/logging/core/logEntry.entry.d.ts +41 -3
  86. package/dist/logging/core/logEntry.entry.js +114 -4
  87. package/dist/logging/core/logLevel.level.d.ts +18 -0
  88. package/dist/logging/core/logLevel.level.js +25 -1
  89. package/dist/logging/core/logRedaction.redaction.d.ts +38 -0
  90. package/dist/logging/core/logRedaction.redaction.js +19 -0
  91. package/dist/logging/core/logger.d.ts +14 -11
  92. package/dist/logging/core/logger.js +31 -6
  93. package/dist/logging/core/loggerContext.context.d.ts +12 -0
  94. package/dist/logging/core/loggerContext.context.js +19 -0
  95. package/dist/logging/core/loggerOptions.options.d.ts +17 -0
  96. package/dist/modules/index.d.ts +0 -1
  97. package/dist/modules/index.js +0 -6
  98. package/dist/modules/module.d.ts +7 -1
  99. package/dist/modules/moduleContext.context.d.ts +41 -7
  100. package/dist/modules/moduleContext.context.js +31 -8
  101. package/dist/modules/moduleDefinition.definition.d.ts +11 -7
  102. package/dist/modules/moduleDefinition.definition.js +41 -8
  103. package/dist/modules/moduleDependency/index.d.ts +2 -2
  104. package/dist/modules/moduleDependency/index.js +1 -1
  105. package/dist/modules/moduleDependency/moduleDependency.graph.d.ts +19 -2
  106. package/dist/modules/moduleDependency/moduleDependency.graph.js +122 -8
  107. package/dist/modules/moduleDependency/moduleDependency.ordering.d.ts +8 -0
  108. package/dist/modules/moduleDependency/moduleDependency.ordering.js +85 -57
  109. package/dist/modules/moduleDependency/moduleDependency.type.d.ts +28 -1
  110. package/dist/modules/moduleError/index.d.ts +1 -1
  111. package/dist/modules/moduleError/index.js +1 -1
  112. package/dist/modules/moduleError/moduleError.dependency.d.ts +11 -0
  113. package/dist/modules/moduleError/moduleError.dependency.js +15 -0
  114. package/dist/modules/moduleLifecycle/index.d.ts +5 -2
  115. package/dist/modules/moduleLifecycle/index.js +4 -1
  116. package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.d.ts +44 -6
  117. package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.js +153 -9
  118. package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.d.ts +30 -5
  119. package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.js +130 -10
  120. package/dist/modules/moduleLifecycle/moduleLifecycle.type.d.ts +65 -28
  121. package/dist/modules/moduleLifecycle/moduleLifecycle.type.js +15 -4
  122. package/dist/modules/moduleLoader/moduleLoader.loader.d.ts +39 -5
  123. package/dist/modules/moduleLoader/moduleLoader.loader.js +123 -50
  124. package/dist/modules/moduleLoader/moduleLoader.type.d.ts +4 -2
  125. package/dist/modules/moduleLoader/moduleLoader.type.js +10 -3
  126. package/dist/modules/moduleMetadata.metadata.js +15 -5
  127. package/dist/modules/moduleRegistry/index.d.ts +1 -1
  128. package/dist/modules/moduleRegistry/moduleRegistry.registry.d.ts +2 -2
  129. package/dist/modules/moduleRegistry/moduleRegistry.registry.js +38 -6
  130. package/dist/modules/moduleRegistry/moduleRegistry.type.d.ts +18 -1
  131. package/dist/runtime/index.d.ts +17 -15
  132. package/dist/runtime/index.js +14 -10
  133. package/dist/runtime/runtime.d.ts +135 -33
  134. package/dist/runtime/runtime.js +344 -114
  135. package/dist/runtime/runtimeBootstrap/index.d.ts +2 -1
  136. package/dist/runtime/runtimeBootstrap/index.js +1 -1
  137. package/dist/runtime/runtimeBootstrap/pipeline/index.d.ts +2 -2
  138. package/dist/runtime/runtimeBootstrap/pipeline/index.js +1 -2
  139. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.d.ts +41 -15
  140. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.js +98 -76
  141. package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.d.ts +7 -4
  142. package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.js +87 -59
  143. package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.d.ts +10 -4
  144. package/dist/runtime/runtimeContext/index.d.ts +3 -5
  145. package/dist/runtime/runtimeContext/index.js +2 -4
  146. package/dist/runtime/runtimeContext/runtimeContext.factory.d.ts +10 -4
  147. package/dist/runtime/runtimeContext/runtimeContext.factory.js +30 -7
  148. package/dist/runtime/runtimeContext/runtimeContext.type.d.ts +36 -47
  149. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.d.ts +5 -0
  150. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.js +6 -4
  151. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.d.ts +4 -0
  152. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.js +7 -9
  153. package/dist/runtime/runtimeEnvironment/index.d.ts +2 -2
  154. package/dist/runtime/runtimeEnvironment/index.js +1 -1
  155. package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.d.ts +20 -17
  156. package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.js +20 -13
  157. package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.d.ts +12 -1
  158. package/dist/runtime/runtimeError/index.d.ts +3 -3
  159. package/dist/runtime/runtimeError/index.js +1 -1
  160. package/dist/runtime/runtimeError/runtimeError.base.d.ts +15 -18
  161. package/dist/runtime/runtimeError/runtimeError.base.js +38 -36
  162. package/dist/runtime/runtimeError/runtimeError.lifecycle.d.ts +23 -8
  163. package/dist/runtime/runtimeError/runtimeError.lifecycle.js +31 -7
  164. package/dist/runtime/runtimeError/runtimeError.specialized.d.ts +1 -1
  165. package/dist/runtime/runtimeError/runtimeError.specialized.js +1 -1
  166. package/dist/runtime/runtimeError/runtimeError.type.d.ts +5 -9
  167. package/dist/runtime/runtimeLogger.d.ts +2 -2
  168. package/dist/runtime/runtimeLogger.js +3 -3
  169. package/dist/runtime/runtimeOptions/index.d.ts +1 -1
  170. package/dist/runtime/runtimeOptions/runtimeOptions.defaults.d.ts +1 -1
  171. package/dist/runtime/runtimeOptions/runtimeOptions.defaults.js +2 -0
  172. package/dist/runtime/runtimeOptions/runtimeOptions.resolver.js +5 -2
  173. package/dist/runtime/runtimeOptions/runtimeOptions.type.d.ts +45 -16
  174. package/dist/runtime/runtimeOptions/runtimeOptions.validation.js +0 -1
  175. package/dist/runtime/runtimeShutdown/index.d.ts +3 -2
  176. package/dist/runtime/runtimeShutdown/index.js +2 -2
  177. package/dist/runtime/runtimeShutdown/pipeline/index.d.ts +2 -1
  178. package/dist/runtime/runtimeShutdown/pipeline/index.js +1 -1
  179. package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.d.ts +37 -7
  180. package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.js +77 -51
  181. package/dist/runtime/runtimeShutdown/runtimeShutdown.core.d.ts +8 -16
  182. package/dist/runtime/runtimeShutdown/runtimeShutdown.core.js +85 -87
  183. package/dist/runtime/runtimeShutdown/runtimeShutdown.type.d.ts +9 -5
  184. package/dist/runtime/runtimeSignals/index.d.ts +8 -0
  185. package/dist/runtime/runtimeSignals/index.js +7 -0
  186. package/dist/runtime/runtimeSignals/runtimeSignals.d.ts +93 -0
  187. package/dist/runtime/runtimeSignals/runtimeSignals.js +149 -0
  188. package/dist/runtime/runtimeState.state.d.ts +32 -14
  189. package/dist/runtime/runtimeState.state.js +34 -27
  190. package/dist/runtime/runtimeTimeout.d.ts +40 -0
  191. package/dist/runtime/runtimeTimeout.js +42 -0
  192. package/package.json +21 -15
  193. package/dist/.tsbuildinfo +0 -1
  194. package/dist/application/application.d.ts.map +0 -1
  195. package/dist/application/application.js.map +0 -1
  196. package/dist/application/applicationContext.context.d.ts.map +0 -1
  197. package/dist/application/applicationContext.context.js.map +0 -1
  198. package/dist/application/applicationState.state.d.ts.map +0 -1
  199. package/dist/application/applicationState.state.js.map +0 -1
  200. package/dist/application/index.d.ts.map +0 -1
  201. package/dist/application/index.js.map +0 -1
  202. package/dist/configuration/configurationManager.manager.d.ts.map +0 -1
  203. package/dist/configuration/configurationManager.manager.js.map +0 -1
  204. package/dist/configuration/core/configuration.d.ts.map +0 -1
  205. package/dist/configuration/core/configuration.js.map +0 -1
  206. package/dist/configuration/core/configurationKey.key.d.ts.map +0 -1
  207. package/dist/configuration/core/configurationKey.key.js.map +0 -1
  208. package/dist/configuration/core/configurationSource.source.d.ts.map +0 -1
  209. package/dist/configuration/core/configurationSource.source.js.map +0 -1
  210. package/dist/configuration/core/index.d.ts.map +0 -1
  211. package/dist/configuration/core/index.js.map +0 -1
  212. package/dist/configuration/error/configurationError.error.d.ts.map +0 -1
  213. package/dist/configuration/error/configurationError.error.js.map +0 -1
  214. package/dist/configuration/error/configurationRedactor.redactor.d.ts.map +0 -1
  215. package/dist/configuration/error/configurationRedactor.redactor.js.map +0 -1
  216. package/dist/configuration/error/index.d.ts.map +0 -1
  217. package/dist/configuration/error/index.js.map +0 -1
  218. package/dist/configuration/events/configurationEvents.events.d.ts.map +0 -1
  219. package/dist/configuration/events/configurationEvents.events.js.map +0 -1
  220. package/dist/configuration/events/index.d.ts.map +0 -1
  221. package/dist/configuration/events/index.js.map +0 -1
  222. package/dist/configuration/index.d.ts.map +0 -1
  223. package/dist/configuration/index.js.map +0 -1
  224. package/dist/configuration/loader/configurationLoader.loader.d.ts.map +0 -1
  225. package/dist/configuration/loader/configurationLoader.loader.js.map +0 -1
  226. package/dist/configuration/loader/index.d.ts.map +0 -1
  227. package/dist/configuration/loader/index.js.map +0 -1
  228. package/dist/configuration/registry/configurationProvider.provider.d.ts.map +0 -1
  229. package/dist/configuration/registry/configurationProvider.provider.js.map +0 -1
  230. package/dist/configuration/registry/configurationRegistry.registry.d.ts.map +0 -1
  231. package/dist/configuration/registry/configurationRegistry.registry.js.map +0 -1
  232. package/dist/configuration/registry/index.d.ts.map +0 -1
  233. package/dist/configuration/registry/index.js.map +0 -1
  234. package/dist/configuration/schema/configurationSchema.schema.d.ts.map +0 -1
  235. package/dist/configuration/schema/configurationSchema.schema.js.map +0 -1
  236. package/dist/configuration/schema/configurationValidation.validator.d.ts.map +0 -1
  237. package/dist/configuration/schema/configurationValidation.validator.js.map +0 -1
  238. package/dist/configuration/schema/index.d.ts.map +0 -1
  239. package/dist/configuration/schema/index.js.map +0 -1
  240. package/dist/container/container.d.ts.map +0 -1
  241. package/dist/container/container.js.map +0 -1
  242. package/dist/container/index.d.ts.map +0 -1
  243. package/dist/container/index.js.map +0 -1
  244. package/dist/container/provider.d.ts.map +0 -1
  245. package/dist/container/provider.js.map +0 -1
  246. package/dist/container/scope.d.ts.map +0 -1
  247. package/dist/container/scope.js.map +0 -1
  248. package/dist/container/token.d.ts.map +0 -1
  249. package/dist/container/token.js.map +0 -1
  250. package/dist/context/core/context.d.ts +0 -95
  251. package/dist/context/core/context.d.ts.map +0 -1
  252. package/dist/context/core/context.js +0 -103
  253. package/dist/context/core/context.js.map +0 -1
  254. package/dist/context/core/contextKey.key.d.ts.map +0 -1
  255. package/dist/context/core/contextKey.key.js.map +0 -1
  256. package/dist/context/core/executionContext.context.d.ts.map +0 -1
  257. package/dist/context/core/executionContext.context.js.map +0 -1
  258. package/dist/context/core/index.d.ts.map +0 -1
  259. package/dist/context/core/index.js.map +0 -1
  260. package/dist/context/index.d.ts.map +0 -1
  261. package/dist/context/index.js.map +0 -1
  262. package/dist/context/provider/contextProvider.provider.d.ts.map +0 -1
  263. package/dist/context/provider/contextProvider.provider.js.map +0 -1
  264. package/dist/context/provider/contextStorage.storage.d.ts.map +0 -1
  265. package/dist/context/provider/contextStorage.storage.js.map +0 -1
  266. package/dist/context/provider/index.d.ts.map +0 -1
  267. package/dist/context/provider/index.js.map +0 -1
  268. package/dist/context/snapshot/contextSnapshot.snapshot.d.ts.map +0 -1
  269. package/dist/context/snapshot/contextSnapshot.snapshot.js.map +0 -1
  270. package/dist/context/snapshot/index.d.ts.map +0 -1
  271. package/dist/context/snapshot/index.js.map +0 -1
  272. package/dist/context/values/contextValues.values.d.ts.map +0 -1
  273. package/dist/context/values/contextValues.values.js.map +0 -1
  274. package/dist/context/values/index.d.ts.map +0 -1
  275. package/dist/context/values/index.js.map +0 -1
  276. package/dist/contracts/adapter.d.ts.map +0 -1
  277. package/dist/contracts/adapter.js.map +0 -1
  278. package/dist/contracts/disposable.d.ts.map +0 -1
  279. package/dist/contracts/disposable.js.map +0 -1
  280. package/dist/contracts/handler.d.ts.map +0 -1
  281. package/dist/contracts/handler.js.map +0 -1
  282. package/dist/contracts/index.d.ts.map +0 -1
  283. package/dist/contracts/index.js.map +0 -1
  284. package/dist/errors/errorCode.code.d.ts.map +0 -1
  285. package/dist/errors/errorCode.code.js.map +0 -1
  286. package/dist/errors/exceptions.d.ts.map +0 -1
  287. package/dist/errors/exceptions.js.map +0 -1
  288. package/dist/errors/frameworkError.error.d.ts.map +0 -1
  289. package/dist/errors/frameworkError.error.js.map +0 -1
  290. package/dist/errors/index.d.ts.map +0 -1
  291. package/dist/errors/index.js.map +0 -1
  292. package/dist/index.d.ts.map +0 -1
  293. package/dist/index.js.map +0 -1
  294. package/dist/lifecycle/core/index.d.ts.map +0 -1
  295. package/dist/lifecycle/core/index.js.map +0 -1
  296. package/dist/lifecycle/core/lifecycle.d.ts.map +0 -1
  297. package/dist/lifecycle/core/lifecycle.js.map +0 -1
  298. package/dist/lifecycle/core/lifecycleHook.hook.d.ts.map +0 -1
  299. package/dist/lifecycle/core/lifecycleHook.hook.js.map +0 -1
  300. package/dist/lifecycle/core/lifecycleRegistry.registry.d.ts.map +0 -1
  301. package/dist/lifecycle/core/lifecycleRegistry.registry.js.map +0 -1
  302. package/dist/lifecycle/core/lifecycleState.state.d.ts +0 -2
  303. package/dist/lifecycle/core/lifecycleState.state.d.ts.map +0 -1
  304. package/dist/lifecycle/core/lifecycleState.state.js +0 -2
  305. package/dist/lifecycle/core/lifecycleState.state.js.map +0 -1
  306. package/dist/lifecycle/index.d.ts.map +0 -1
  307. package/dist/lifecycle/index.js.map +0 -1
  308. package/dist/lifecycle/manager/index.d.ts.map +0 -1
  309. package/dist/lifecycle/manager/index.js.map +0 -1
  310. package/dist/lifecycle/manager/lifecycleManager.manager.d.ts.map +0 -1
  311. package/dist/lifecycle/manager/lifecycleManager.manager.js.map +0 -1
  312. package/dist/lifecycle/scope/index.d.ts.map +0 -1
  313. package/dist/lifecycle/scope/index.js.map +0 -1
  314. package/dist/lifecycle/scope/lifecycleScope.scope.d.ts.map +0 -1
  315. package/dist/lifecycle/scope/lifecycleScope.scope.js.map +0 -1
  316. package/dist/logging/console/consoleLogger.logger.d.ts.map +0 -1
  317. package/dist/logging/console/consoleLogger.logger.js.map +0 -1
  318. package/dist/logging/console/index.d.ts.map +0 -1
  319. package/dist/logging/console/index.js.map +0 -1
  320. package/dist/logging/console/loggerFactory.factory.d.ts.map +0 -1
  321. package/dist/logging/console/loggerFactory.factory.js.map +0 -1
  322. package/dist/logging/core/index.d.ts.map +0 -1
  323. package/dist/logging/core/index.js.map +0 -1
  324. package/dist/logging/core/logEntry.entry.d.ts.map +0 -1
  325. package/dist/logging/core/logEntry.entry.js.map +0 -1
  326. package/dist/logging/core/logLevel.level.d.ts.map +0 -1
  327. package/dist/logging/core/logLevel.level.js.map +0 -1
  328. package/dist/logging/core/logger.d.ts.map +0 -1
  329. package/dist/logging/core/logger.js.map +0 -1
  330. package/dist/logging/core/loggerContext.context.d.ts.map +0 -1
  331. package/dist/logging/core/loggerContext.context.js.map +0 -1
  332. package/dist/logging/core/loggerOptions.options.d.ts.map +0 -1
  333. package/dist/logging/core/loggerOptions.options.js.map +0 -1
  334. package/dist/logging/index.d.ts.map +0 -1
  335. package/dist/logging/index.js.map +0 -1
  336. package/dist/modules/index.d.ts.map +0 -1
  337. package/dist/modules/index.js.map +0 -1
  338. package/dist/modules/module.d.ts.map +0 -1
  339. package/dist/modules/module.js.map +0 -1
  340. package/dist/modules/moduleContext.context.d.ts.map +0 -1
  341. package/dist/modules/moduleContext.context.js.map +0 -1
  342. package/dist/modules/moduleDefinition.definition.d.ts.map +0 -1
  343. package/dist/modules/moduleDefinition.definition.js.map +0 -1
  344. package/dist/modules/moduleDependency/index.d.ts.map +0 -1
  345. package/dist/modules/moduleDependency/index.js.map +0 -1
  346. package/dist/modules/moduleDependency/moduleDependency.graph.d.ts.map +0 -1
  347. package/dist/modules/moduleDependency/moduleDependency.graph.js.map +0 -1
  348. package/dist/modules/moduleDependency/moduleDependency.ordering.d.ts.map +0 -1
  349. package/dist/modules/moduleDependency/moduleDependency.ordering.js.map +0 -1
  350. package/dist/modules/moduleDependency/moduleDependency.type.d.ts.map +0 -1
  351. package/dist/modules/moduleDependency/moduleDependency.type.js.map +0 -1
  352. package/dist/modules/moduleError/index.d.ts.map +0 -1
  353. package/dist/modules/moduleError/index.js.map +0 -1
  354. package/dist/modules/moduleError/moduleError.base.d.ts.map +0 -1
  355. package/dist/modules/moduleError/moduleError.base.js.map +0 -1
  356. package/dist/modules/moduleError/moduleError.dependency.d.ts.map +0 -1
  357. package/dist/modules/moduleError/moduleError.dependency.js.map +0 -1
  358. package/dist/modules/moduleError/moduleError.helpers.d.ts.map +0 -1
  359. package/dist/modules/moduleError/moduleError.helpers.js.map +0 -1
  360. package/dist/modules/moduleError/moduleError.lifecycle.d.ts.map +0 -1
  361. package/dist/modules/moduleError/moduleError.lifecycle.js.map +0 -1
  362. package/dist/modules/moduleError/moduleError.registration.d.ts.map +0 -1
  363. package/dist/modules/moduleError/moduleError.registration.js.map +0 -1
  364. package/dist/modules/moduleLifecycle/index.d.ts.map +0 -1
  365. package/dist/modules/moduleLifecycle/index.js.map +0 -1
  366. package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.d.ts.map +0 -1
  367. package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.js.map +0 -1
  368. package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.d.ts.map +0 -1
  369. package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.js.map +0 -1
  370. package/dist/modules/moduleLifecycle/moduleLifecycle.type.d.ts.map +0 -1
  371. package/dist/modules/moduleLifecycle/moduleLifecycle.type.js.map +0 -1
  372. package/dist/modules/moduleLoader/index.d.ts.map +0 -1
  373. package/dist/modules/moduleLoader/index.js.map +0 -1
  374. package/dist/modules/moduleLoader/moduleLoader.loader.d.ts.map +0 -1
  375. package/dist/modules/moduleLoader/moduleLoader.loader.js.map +0 -1
  376. package/dist/modules/moduleLoader/moduleLoader.type.d.ts.map +0 -1
  377. package/dist/modules/moduleLoader/moduleLoader.type.js.map +0 -1
  378. package/dist/modules/moduleMetadata.metadata.d.ts.map +0 -1
  379. package/dist/modules/moduleMetadata.metadata.js.map +0 -1
  380. package/dist/modules/moduleRegistry/index.d.ts.map +0 -1
  381. package/dist/modules/moduleRegistry/index.js.map +0 -1
  382. package/dist/modules/moduleRegistry/moduleRegistry.registry.d.ts.map +0 -1
  383. package/dist/modules/moduleRegistry/moduleRegistry.registry.js.map +0 -1
  384. package/dist/modules/moduleRegistry/moduleRegistry.type.d.ts.map +0 -1
  385. package/dist/modules/moduleRegistry/moduleRegistry.type.js.map +0 -1
  386. package/dist/runtime/index.d.ts.map +0 -1
  387. package/dist/runtime/index.js.map +0 -1
  388. package/dist/runtime/runtime.d.ts.map +0 -1
  389. package/dist/runtime/runtime.js.map +0 -1
  390. package/dist/runtime/runtimeBootstrap/index.d.ts.map +0 -1
  391. package/dist/runtime/runtimeBootstrap/index.js.map +0 -1
  392. package/dist/runtime/runtimeBootstrap/pipeline/index.d.ts.map +0 -1
  393. package/dist/runtime/runtimeBootstrap/pipeline/index.js.map +0 -1
  394. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.d.ts +0 -6
  395. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.d.ts.map +0 -1
  396. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.js +0 -27
  397. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.js.map +0 -1
  398. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.d.ts.map +0 -1
  399. package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.js.map +0 -1
  400. package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.d.ts.map +0 -1
  401. package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.js.map +0 -1
  402. package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.d.ts.map +0 -1
  403. package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.js.map +0 -1
  404. package/dist/runtime/runtimeContext/index.d.ts.map +0 -1
  405. package/dist/runtime/runtimeContext/index.js.map +0 -1
  406. package/dist/runtime/runtimeContext/runtimeContext.core.d.ts +0 -38
  407. package/dist/runtime/runtimeContext/runtimeContext.core.d.ts.map +0 -1
  408. package/dist/runtime/runtimeContext/runtimeContext.core.js +0 -99
  409. package/dist/runtime/runtimeContext/runtimeContext.core.js.map +0 -1
  410. package/dist/runtime/runtimeContext/runtimeContext.factory.d.ts.map +0 -1
  411. package/dist/runtime/runtimeContext/runtimeContext.factory.js.map +0 -1
  412. package/dist/runtime/runtimeContext/runtimeContext.type.d.ts.map +0 -1
  413. package/dist/runtime/runtimeContext/runtimeContext.type.js.map +0 -1
  414. package/dist/runtime/runtimeEnvironment/detection/index.d.ts.map +0 -1
  415. package/dist/runtime/runtimeEnvironment/detection/index.js.map +0 -1
  416. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.detection.d.ts.map +0 -1
  417. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.detection.js.map +0 -1
  418. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.d.ts.map +0 -1
  419. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.js.map +0 -1
  420. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.d.ts.map +0 -1
  421. package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.js.map +0 -1
  422. package/dist/runtime/runtimeEnvironment/index.d.ts.map +0 -1
  423. package/dist/runtime/runtimeEnvironment/index.js.map +0 -1
  424. package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.d.ts.map +0 -1
  425. package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.js.map +0 -1
  426. package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.d.ts.map +0 -1
  427. package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.js.map +0 -1
  428. package/dist/runtime/runtimeError/index.d.ts.map +0 -1
  429. package/dist/runtime/runtimeError/index.js.map +0 -1
  430. package/dist/runtime/runtimeError/runtimeError.base.d.ts.map +0 -1
  431. package/dist/runtime/runtimeError/runtimeError.base.js.map +0 -1
  432. package/dist/runtime/runtimeError/runtimeError.lifecycle.d.ts.map +0 -1
  433. package/dist/runtime/runtimeError/runtimeError.lifecycle.js.map +0 -1
  434. package/dist/runtime/runtimeError/runtimeError.specialized.d.ts.map +0 -1
  435. package/dist/runtime/runtimeError/runtimeError.specialized.js.map +0 -1
  436. package/dist/runtime/runtimeError/runtimeError.type.d.ts.map +0 -1
  437. package/dist/runtime/runtimeError/runtimeError.type.js.map +0 -1
  438. package/dist/runtime/runtimeLogger.d.ts.map +0 -1
  439. package/dist/runtime/runtimeLogger.js.map +0 -1
  440. package/dist/runtime/runtimeManager/index.d.ts +0 -12
  441. package/dist/runtime/runtimeManager/index.d.ts.map +0 -1
  442. package/dist/runtime/runtimeManager/index.js +0 -11
  443. package/dist/runtime/runtimeManager/index.js.map +0 -1
  444. package/dist/runtime/runtimeManager/runtimeManager.core.d.ts +0 -31
  445. package/dist/runtime/runtimeManager/runtimeManager.core.d.ts.map +0 -1
  446. package/dist/runtime/runtimeManager/runtimeManager.core.js +0 -136
  447. package/dist/runtime/runtimeManager/runtimeManager.core.js.map +0 -1
  448. package/dist/runtime/runtimeManager/runtimeManager.error.d.ts +0 -14
  449. package/dist/runtime/runtimeManager/runtimeManager.error.d.ts.map +0 -1
  450. package/dist/runtime/runtimeManager/runtimeManager.error.js +0 -21
  451. package/dist/runtime/runtimeManager/runtimeManager.error.js.map +0 -1
  452. package/dist/runtime/runtimeManager/runtimeManager.factory.d.ts +0 -7
  453. package/dist/runtime/runtimeManager/runtimeManager.factory.d.ts.map +0 -1
  454. package/dist/runtime/runtimeManager/runtimeManager.factory.js +0 -8
  455. package/dist/runtime/runtimeManager/runtimeManager.factory.js.map +0 -1
  456. package/dist/runtime/runtimeManager/runtimeManager.lifecycle.d.ts +0 -16
  457. package/dist/runtime/runtimeManager/runtimeManager.lifecycle.d.ts.map +0 -1
  458. package/dist/runtime/runtimeManager/runtimeManager.lifecycle.js +0 -49
  459. package/dist/runtime/runtimeManager/runtimeManager.lifecycle.js.map +0 -1
  460. package/dist/runtime/runtimeManager/runtimeManager.type.d.ts +0 -54
  461. package/dist/runtime/runtimeManager/runtimeManager.type.d.ts.map +0 -1
  462. package/dist/runtime/runtimeManager/runtimeManager.type.js +0 -2
  463. package/dist/runtime/runtimeManager/runtimeManager.type.js.map +0 -1
  464. package/dist/runtime/runtimeOptions/index.d.ts.map +0 -1
  465. package/dist/runtime/runtimeOptions/index.js.map +0 -1
  466. package/dist/runtime/runtimeOptions/runtimeOptions.defaults.d.ts.map +0 -1
  467. package/dist/runtime/runtimeOptions/runtimeOptions.defaults.js.map +0 -1
  468. package/dist/runtime/runtimeOptions/runtimeOptions.resolver.d.ts.map +0 -1
  469. package/dist/runtime/runtimeOptions/runtimeOptions.resolver.js.map +0 -1
  470. package/dist/runtime/runtimeOptions/runtimeOptions.type.d.ts.map +0 -1
  471. package/dist/runtime/runtimeOptions/runtimeOptions.type.js.map +0 -1
  472. package/dist/runtime/runtimeOptions/runtimeOptions.validation.d.ts.map +0 -1
  473. package/dist/runtime/runtimeOptions/runtimeOptions.validation.js.map +0 -1
  474. package/dist/runtime/runtimeShutdown/index.d.ts.map +0 -1
  475. package/dist/runtime/runtimeShutdown/index.js.map +0 -1
  476. package/dist/runtime/runtimeShutdown/pipeline/index.d.ts.map +0 -1
  477. package/dist/runtime/runtimeShutdown/pipeline/index.js.map +0 -1
  478. package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.d.ts.map +0 -1
  479. package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.js.map +0 -1
  480. package/dist/runtime/runtimeShutdown/runtimeShutdown.core.d.ts.map +0 -1
  481. package/dist/runtime/runtimeShutdown/runtimeShutdown.core.js.map +0 -1
  482. package/dist/runtime/runtimeShutdown/runtimeShutdown.type.d.ts.map +0 -1
  483. package/dist/runtime/runtimeShutdown/runtimeShutdown.type.js.map +0 -1
  484. package/dist/runtime/runtimeState.state.d.ts.map +0 -1
  485. package/dist/runtime/runtimeState.state.js.map +0 -1
@@ -1,44 +1,50 @@
1
- import { validateModuleDependencyGraph } from "./moduleDependency.graph.js";
1
+ import { CircularModuleDependencyError, MissingModuleDependencyError, } from "../moduleError/moduleError.dependency.js";
2
2
  /**
3
3
  * Detects circular dependencies in a module graph.
4
4
  *
5
5
  * Returns the dependency cycle when one exists.
6
+ *
7
+ * This is the single cycle-detection mechanism used by the
8
+ * dependency subsystem. The implementation is iterative so very
9
+ * deep graphs cannot overflow the call stack.
6
10
  */
7
11
  export function findModuleDependencyCycle(graph) {
8
- const visiting = new Set();
9
12
  const visited = new Set();
10
- const path = [];
11
- const visit = (moduleId) => {
12
- if (visiting.has(moduleId)) {
13
- const index = path.indexOf(moduleId);
14
- if (index >= 0) {
15
- return [...path.slice(index), moduleId];
16
- }
17
- return [moduleId];
18
- }
19
- if (visited.has(moduleId)) {
20
- return undefined;
21
- }
22
- visiting.add(moduleId);
23
- path.push(moduleId);
24
- for (const dependency of graph.getDependencies(moduleId)) {
25
- if (!graph.hasModule(dependency.id)) {
13
+ for (const startId of graph.nodes.keys()) {
14
+ if (visited.has(startId))
15
+ continue;
16
+ /*
17
+ * Iterative DFS. Each stack frame tracks the module and the
18
+ * index of the next dependency to visit.
19
+ */
20
+ const stack = [
21
+ { id: startId, nextDependency: 0 },
22
+ ];
23
+ const inPath = new Set([startId]);
24
+ const path = [startId];
25
+ while (stack.length > 0) {
26
+ const frame = stack[stack.length - 1];
27
+ const dependencies = graph.getDependencies(frame.id);
28
+ if (frame.nextDependency >= dependencies.length) {
29
+ stack.pop();
30
+ path.pop();
31
+ inPath.delete(frame.id);
32
+ visited.add(frame.id);
26
33
  continue;
27
34
  }
28
- const cycle = visit(dependency.id);
29
- if (cycle) {
30
- return cycle;
35
+ const dependency = dependencies[frame.nextDependency];
36
+ frame.nextDependency += 1;
37
+ if (!graph.hasModule(dependency.id))
38
+ continue;
39
+ if (inPath.has(dependency.id)) {
40
+ const index = path.indexOf(dependency.id);
41
+ return [...path.slice(index), dependency.id];
31
42
  }
32
- }
33
- path.pop();
34
- visiting.delete(moduleId);
35
- visited.add(moduleId);
36
- return undefined;
37
- };
38
- for (const moduleId of graph.nodes.keys()) {
39
- const cycle = visit(moduleId);
40
- if (cycle) {
41
- return cycle;
43
+ if (visited.has(dependency.id))
44
+ continue;
45
+ stack.push({ id: dependency.id, nextDependency: 0 });
46
+ inPath.add(dependency.id);
47
+ path.push(dependency.id);
42
48
  }
43
49
  }
44
50
  return undefined;
@@ -65,38 +71,60 @@ export function hasModuleDependencyCycle(graph) {
65
71
  * produces:
66
72
  *
67
73
  * users → orders → payments
74
+ *
75
+ * The sort is implemented iteratively (Kahn's algorithm). When
76
+ * not every module can be ordered, the cycle is located with
77
+ * findModuleDependencyCycle and reported.
68
78
  */
69
79
  export function resolveModuleStartupOrder(graph) {
70
- const missing = validateModuleDependencyGraph(graph);
71
- if (missing.length > 0) {
72
- throw new Error(`Cannot resolve module startup order. Missing required dependencies: ${missing.join(", ")}`);
80
+ /*
81
+ * Missing required dependencies make the order meaningless,
82
+ * so they are reported first with the requiring module.
83
+ */
84
+ for (const node of graph.nodes.values()) {
85
+ for (const dependency of node.dependencies) {
86
+ if (dependency.optional)
87
+ continue;
88
+ if (!graph.hasModule(dependency.id)) {
89
+ throw new MissingModuleDependencyError(node.id, dependency.id);
90
+ }
91
+ }
92
+ }
93
+ const inDegree = new Map();
94
+ const dependents = new Map();
95
+ for (const node of graph.nodes.values()) {
96
+ let degree = 0;
97
+ for (const dependency of node.dependencies) {
98
+ if (!graph.hasModule(dependency.id))
99
+ continue;
100
+ degree += 1;
101
+ const list = dependents.get(dependency.id);
102
+ if (list)
103
+ list.push(node.id);
104
+ else
105
+ dependents.set(dependency.id, [node.id]);
106
+ }
107
+ inDegree.set(node.id, degree);
73
108
  }
74
- const cycle = findModuleDependencyCycle(graph);
75
- if (cycle) {
76
- throw new Error(`Circular module dependency detected: ${cycle.join(" -> ")}`);
109
+ const queue = [];
110
+ for (const [moduleId, degree] of inDegree) {
111
+ if (degree === 0)
112
+ queue.push(moduleId);
77
113
  }
78
- const temporary = new Set();
79
- const permanent = new Set();
80
114
  const order = [];
81
- const visit = (moduleId) => {
82
- if (permanent.has(moduleId)) {
83
- return;
84
- }
85
- if (temporary.has(moduleId)) {
86
- throw new Error(`Circular module dependency detected involving "${moduleId}".`);
87
- }
88
- temporary.add(moduleId);
89
- for (const dependency of graph.getDependencies(moduleId)) {
90
- if (graph.hasModule(dependency.id)) {
91
- visit(dependency.id);
92
- }
93
- }
94
- temporary.delete(moduleId);
95
- permanent.add(moduleId);
115
+ for (let index = 0; index < queue.length; index++) {
116
+ const moduleId = queue[index];
96
117
  order.push(moduleId);
97
- };
98
- for (const moduleId of graph.nodes.keys()) {
99
- visit(moduleId);
118
+ for (const dependent of dependents.get(moduleId) ?? []) {
119
+ const degree = (inDegree.get(dependent) ?? 0) - 1;
120
+ inDegree.set(dependent, degree);
121
+ if (degree === 0)
122
+ queue.push(dependent);
123
+ }
124
+ }
125
+ if (order.length !== graph.nodes.size) {
126
+ const cycle = findModuleDependencyCycle(graph);
127
+ throw new CircularModuleDependencyError(cycle ?? [...graph.nodes.keys()].filter((id) => !order.includes(id)));
100
128
  }
101
129
  return Object.freeze(order);
102
130
  }
@@ -37,6 +37,13 @@ export interface ModuleDependencyNode {
37
37
  * Dependencies declared by the module.
38
38
  */
39
39
  readonly dependencies: ModuleDependencies;
40
+ /**
41
+ * Semantic version of the module, when known.
42
+ *
43
+ * Used to check dependency version constraints while
44
+ * building the graph.
45
+ */
46
+ readonly version?: string;
40
47
  }
41
48
  /**
42
49
  * Complete module dependency graph.
@@ -62,5 +69,25 @@ export interface ModuleDependencyGraph {
62
69
  /**
63
70
  * A raw dependency declaration accepted by the framework.
64
71
  */
65
- export type ModuleDependencyInput = ModuleId | ModuleDependency;
72
+ export type ModuleDependencyInput = ModuleId | (Pick<ModuleDependency, "id"> & Partial<Omit<ModuleDependency, "id">>);
73
+ /**
74
+ * A raw dependency graph node accepted by `createModuleDependencyGraph`.
75
+ *
76
+ * Dependencies may be declared as plain ids or partial dependency objects;
77
+ * they are normalized while the graph is built.
78
+ */
79
+ export interface ModuleDependencyNodeInput {
80
+ /**
81
+ * Module identifier.
82
+ */
83
+ readonly id: ModuleId;
84
+ /**
85
+ * Dependencies declared by the module.
86
+ */
87
+ readonly dependencies?: readonly ModuleDependencyInput[];
88
+ /**
89
+ * Semantic version of the module, when known.
90
+ */
91
+ readonly version?: string;
92
+ }
66
93
  //# sourceMappingURL=moduleDependency.type.d.ts.map
@@ -5,7 +5,7 @@
5
5
  */
6
6
  export { ModuleErrorCode, type ModuleErrorCode as ModuleErrorCodeType, type ModuleErrorDetails, ModuleError, } from "./moduleError.base.js";
7
7
  export { InvalidModuleDefinitionError, ModuleNotFoundError, DuplicateModuleError, } from "./moduleError.registration.js";
8
- export { MissingModuleDependencyError, CircularModuleDependencyError, ModuleVersionMismatchError, } from "./moduleError.dependency.js";
8
+ export { InvalidModuleDependencyError, MissingModuleDependencyError, CircularModuleDependencyError, ModuleVersionMismatchError, } from "./moduleError.dependency.js";
9
9
  export { getLifecycleErrorCode, ModuleInstantiationError, ModuleOperationError, InvalidModuleInstanceError, InvalidModuleStateError, ModuleOperationInProgressError, } from "./moduleError.lifecycle.js";
10
10
  export { isModuleError, hasModuleErrorCode, toModuleError, } from "./moduleError.helpers.js";
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -5,7 +5,7 @@
5
5
  */
6
6
  export { ModuleErrorCode, ModuleError, } from "./moduleError.base.js";
7
7
  export { InvalidModuleDefinitionError, ModuleNotFoundError, DuplicateModuleError, } from "./moduleError.registration.js";
8
- export { MissingModuleDependencyError, CircularModuleDependencyError, ModuleVersionMismatchError, } from "./moduleError.dependency.js";
8
+ export { InvalidModuleDependencyError, MissingModuleDependencyError, CircularModuleDependencyError, ModuleVersionMismatchError, } from "./moduleError.dependency.js";
9
9
  export { getLifecycleErrorCode, ModuleInstantiationError, ModuleOperationError, InvalidModuleInstanceError, InvalidModuleStateError, ModuleOperationInProgressError, } from "./moduleError.lifecycle.js";
10
10
  export { isModuleError, hasModuleErrorCode, toModuleError, } from "./moduleError.helpers.js";
11
11
  //# sourceMappingURL=index.js.map
@@ -12,6 +12,17 @@ export declare class MissingModuleDependencyError extends ModuleError {
12
12
  export declare class CircularModuleDependencyError extends ModuleError {
13
13
  constructor(cycle: readonly ModuleId[]);
14
14
  }
15
+ /**
16
+ * Error thrown when a dependency declaration is malformed:
17
+ * empty ids, self-dependencies, duplicate declarations, or
18
+ * unsupported version constraints.
19
+ */
20
+ export declare class InvalidModuleDependencyError extends ModuleError {
21
+ constructor(message: string, options?: {
22
+ readonly moduleId?: ModuleId;
23
+ readonly dependencyId?: ModuleId;
24
+ });
25
+ }
15
26
  /**
16
27
  * Error thrown when a module dependency version
17
28
  * cannot be satisfied.
@@ -26,6 +26,21 @@ export class CircularModuleDependencyError extends ModuleError {
26
26
  this.name = "CircularModuleDependencyError";
27
27
  }
28
28
  }
29
+ /**
30
+ * Error thrown when a dependency declaration is malformed:
31
+ * empty ids, self-dependencies, duplicate declarations, or
32
+ * unsupported version constraints.
33
+ */
34
+ export class InvalidModuleDependencyError extends ModuleError {
35
+ constructor(message, options = {}) {
36
+ super(message, {
37
+ code: ModuleErrorCode.INVALID_DEPENDENCY,
38
+ moduleId: options.moduleId,
39
+ dependencyId: options.dependencyId,
40
+ });
41
+ this.name = "InvalidModuleDependencyError";
42
+ }
43
+ }
29
44
  /**
30
45
  * Error thrown when a module dependency version
31
46
  * cannot be satisfied.
@@ -3,8 +3,11 @@
3
3
  *
4
4
  * Manages the lifecycle phases of loaded modules:
5
5
  * initialize → start → stop → destroy.
6
+ *
7
+ * The state-machine plumbing (hook invocation, phase execution,
8
+ * state maps) is internal to this subsystem and intentionally
9
+ * not exported from this barrel.
6
10
  */
7
- export { type ModuleLifecyclePhase, type ModuleLifecycleState, type ModuleLifecycleHooks, type ModuleLifecycleOptions, ModuleLifecycleError, type ModuleLifecycleResult, type LifecycleStateMap, } from "./moduleLifecycle.type.js";
8
- export { ensureStateSynchronized, getLifecycleState, requireLifecycleState, getAllLifecycleStates, isModuleInitialized, isModuleStarted, isModuleDestroyed, invokeLifecycleHook, canModuleEnterPhase, setLifecycleState, executeLifecyclePhase, } from "./moduleLifecycle.stateMachine.js";
11
+ export { type ModuleLifecyclePhase, type ModuleLifecycleState, type ModuleLifecycleHookName, type ModuleLifecycleStep, type ModuleLifecycleHooks, type ModuleLifecycleOptions, ModuleLifecycleError, type ModuleLifecycleResult, type ModuleLifecycleSkip, } from "./moduleLifecycle.type.js";
9
12
  export { ModuleLifecycleManager, createModuleLifecycleManager, } from "./moduleLifecycle.lifecycle.js";
10
13
  //# sourceMappingURL=index.d.ts.map
@@ -3,8 +3,11 @@
3
3
  *
4
4
  * Manages the lifecycle phases of loaded modules:
5
5
  * initialize → start → stop → destroy.
6
+ *
7
+ * The state-machine plumbing (hook invocation, phase execution,
8
+ * state maps) is internal to this subsystem and intentionally
9
+ * not exported from this barrel.
6
10
  */
7
11
  export { ModuleLifecycleError, } from "./moduleLifecycle.type.js";
8
- export { ensureStateSynchronized, getLifecycleState, requireLifecycleState, getAllLifecycleStates, isModuleInitialized, isModuleStarted, isModuleDestroyed, invokeLifecycleHook, canModuleEnterPhase, setLifecycleState, executeLifecyclePhase, } from "./moduleLifecycle.stateMachine.js";
9
12
  export { ModuleLifecycleManager, createModuleLifecycleManager, } from "./moduleLifecycle.lifecycle.js";
10
13
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,8 @@
1
- import type { ModuleId } from "../module.js";
2
- import type { ModuleRegistry } from "../moduleRegistry/index.js";
1
+ import type { Module, ModuleId } from "../module.js";
2
+ import type { ModuleDefinition } from "../moduleDefinition.definition.js";
3
+ import type { ModuleRegistration, ModuleRegistry } from "../moduleRegistry/index.js";
3
4
  import type { ModuleLoader } from "../moduleLoader/index.js";
4
- import type { ModuleLifecycleOptions, ModuleLifecycleResult } from "./moduleLifecycle.type.js";
5
+ import type { ModuleLifecycleOptions, ModuleLifecycleResult, ModuleLifecycleState } from "./moduleLifecycle.type.js";
5
6
  /**
6
7
  * Module lifecycle manager.
7
8
  * Initializes, starts, stops, and destroys modules in dependency order.
@@ -10,6 +11,7 @@ export declare class ModuleLifecycleManager {
10
11
  private readonly registry;
11
12
  private readonly loader;
12
13
  private readonly options;
14
+ private readonly contextStorage;
13
15
  private readonly states;
14
16
  private operation;
15
17
  constructor(registry: ModuleRegistry, loader: ModuleLoader, options?: ModuleLifecycleOptions);
@@ -17,6 +19,42 @@ export declare class ModuleLifecycleManager {
17
19
  start(): Promise<ModuleLifecycleResult>;
18
20
  stop(): Promise<ModuleLifecycleResult>;
19
21
  destroy(): Promise<ModuleLifecycleResult>;
22
+ /**
23
+ * Rolls back modules that completed earlier phases after a
24
+ * startup failure.
25
+ *
26
+ * The rollback is best-effort: the already-completed subset is
27
+ * stopped (when requested) and destroyed in reverse dependency
28
+ * order, and any rollback errors are collected onto the
29
+ * original ModuleLifecycleError instead of masking it.
30
+ */
31
+ private rollbackAfterFailure;
32
+ /**
33
+ * Shuts down and unloads a single module.
34
+ *
35
+ * The module is stopped (when started) and destroyed, its
36
+ * lifecycle state is dropped, and the loader forgets its
37
+ * instance and context. Hook failures never abort the unload;
38
+ * they are reported in the result and on the lifecycle state.
39
+ *
40
+ * A module that other loaded modules still depend on cannot be
41
+ * unloaded; ModuleError (MODULE_OPERATION_NOT_ALLOWED) is thrown.
42
+ */
43
+ unloadModule(moduleId: ModuleId): Promise<ModuleLifecycleResult>;
44
+ /**
45
+ * Replaces a module definition, shutting down the currently
46
+ * loaded instance first.
47
+ *
48
+ * The registry must allow replacement (allowReplacement: true).
49
+ * The new definition is registered but not loaded; call the
50
+ * loader and lifecycle methods afterwards to bring it up.
51
+ */
52
+ replaceModule<TModule extends Module>(definition: ModuleDefinition<TModule>): Promise<ModuleRegistration<TModule>>;
53
+ /**
54
+ * Returns ids of loaded modules that declare a required or
55
+ * optional dependency on the given module.
56
+ */
57
+ private getLoadedDependents;
20
58
  startApplication(): Promise<{
21
59
  readonly initialized: ModuleLifecycleResult;
22
60
  readonly started: ModuleLifecycleResult;
@@ -25,9 +63,9 @@ export declare class ModuleLifecycleManager {
25
63
  readonly stopped: ModuleLifecycleResult;
26
64
  readonly destroyed: ModuleLifecycleResult;
27
65
  }>;
28
- getState(moduleId: ModuleId): import("./moduleLifecycle.type.js").ModuleLifecycleState | undefined;
29
- requireState(moduleId: ModuleId): import("./moduleLifecycle.type.js").ModuleLifecycleState;
30
- getStates(): ReadonlyMap<ModuleId, import("./moduleLifecycle.type.js").ModuleLifecycleState>;
66
+ getState(moduleId: ModuleId): ModuleLifecycleState | undefined;
67
+ requireState(moduleId: ModuleId): ModuleLifecycleState;
68
+ getStates(): ReadonlyMap<ModuleId, ModuleLifecycleState>;
31
69
  isInitialized(moduleId: ModuleId): boolean;
32
70
  isStarted(moduleId: ModuleId): boolean;
33
71
  isDestroyed(moduleId: ModuleId): boolean;
@@ -1,4 +1,7 @@
1
+ import { ModuleError, ModuleErrorCode, } from "../moduleError/moduleError.base.js";
1
2
  import { createModuleDependencyGraph, resolveModuleStartupOrder, resolveModuleShutdownOrder, } from "../moduleDependency/index.js";
3
+ import { ModuleLifecycleError } from "./moduleLifecycle.type.js";
4
+ import { getDefaultContextStorage } from "../../context/provider/defaultContextStorage.storage.js";
2
5
  import { ensureStateSynchronized, getLifecycleState, requireLifecycleState, getAllLifecycleStates, isModuleInitialized, isModuleStarted, isModuleDestroyed, executeLifecyclePhase, } from "./moduleLifecycle.stateMachine.js";
3
6
  /**
4
7
  * Module lifecycle manager.
@@ -8,6 +11,7 @@ export class ModuleLifecycleManager {
8
11
  registry;
9
12
  loader;
10
13
  options;
14
+ contextStorage;
11
15
  states = new Map();
12
16
  operation;
13
17
  constructor(registry, loader, options = {}) {
@@ -19,39 +23,178 @@ export class ModuleLifecycleManager {
19
23
  continueOnStopError: options.continueOnStopError ?? true,
20
24
  continueOnDestroyError: options.continueOnDestroyError ?? true,
21
25
  };
26
+ this.contextStorage = options.contextStorage ?? getDefaultContextStorage();
22
27
  }
23
28
  async initialize() {
24
29
  return this.runExclusive(async () => {
25
30
  ensureStateSynchronized(this.registry, this.states);
26
- return executeLifecyclePhase(this.getStartupOrder(), "initialize", "initializing", "initialized", this.options.continueOnInitializeError, this.registry, this.loader, this.states);
31
+ try {
32
+ return await executeLifecyclePhase(this.getStartupOrder(), "initialize", "initializing", "initialized", this.options.continueOnInitializeError, this.registry, this.loader, this.states, this.contextStorage);
33
+ }
34
+ catch (error) {
35
+ await this.rollbackAfterFailure(error, { stopFirst: false });
36
+ throw error;
37
+ }
27
38
  });
28
39
  }
29
40
  async start() {
30
41
  return this.runExclusive(async () => {
31
42
  ensureStateSynchronized(this.registry, this.states);
32
- return executeLifecyclePhase(this.getStartupOrder(), "start", "starting", "started", this.options.continueOnStartError, this.registry, this.loader, this.states);
43
+ try {
44
+ return await executeLifecyclePhase(this.getStartupOrder(), "start", "starting", "started", this.options.continueOnStartError, this.registry, this.loader, this.states, this.contextStorage);
45
+ }
46
+ catch (error) {
47
+ await this.rollbackAfterFailure(error, { stopFirst: true });
48
+ throw error;
49
+ }
33
50
  });
34
51
  }
35
52
  async stop() {
36
53
  return this.runExclusive(async () => {
37
54
  ensureStateSynchronized(this.registry, this.states);
38
- return executeLifecyclePhase(this.getShutdownOrder(), "stop", "stopping", "stopped", this.options.continueOnStopError, this.registry, this.loader, this.states);
55
+ return executeLifecyclePhase(this.getShutdownOrder(), "stop", "stopping", "stopped", this.options.continueOnStopError, this.registry, this.loader, this.states, this.contextStorage);
39
56
  });
40
57
  }
41
58
  async destroy() {
42
59
  return this.runExclusive(async () => {
43
60
  ensureStateSynchronized(this.registry, this.states);
44
- return executeLifecyclePhase(this.getShutdownOrder(), "destroy", "destroying", "destroyed", this.options.continueOnDestroyError, this.registry, this.loader, this.states);
61
+ return executeLifecyclePhase(this.getShutdownOrder(), "destroy", "destroying", "destroyed", this.options.continueOnDestroyError, this.registry, this.loader, this.states, this.contextStorage);
45
62
  });
46
63
  }
64
+ /**
65
+ * Rolls back modules that completed earlier phases after a
66
+ * startup failure.
67
+ *
68
+ * The rollback is best-effort: the already-completed subset is
69
+ * stopped (when requested) and destroyed in reverse dependency
70
+ * order, and any rollback errors are collected onto the
71
+ * original ModuleLifecycleError instead of masking it.
72
+ */
73
+ async rollbackAfterFailure(error, options) {
74
+ const rollbackErrors = [];
75
+ try {
76
+ /*
77
+ * Only modules that actually entered the startup flow are
78
+ * rolled back; untouched modules keep their "created"
79
+ * state and never see stop/destroy hooks here.
80
+ */
81
+ const touchedPhases = new Set([
82
+ "initialized",
83
+ "starting",
84
+ "started",
85
+ "stopping",
86
+ "stopped",
87
+ "failed",
88
+ ]);
89
+ const shutdownOrder = this.getShutdownOrder().filter((moduleId) => {
90
+ const phase = getLifecycleState(moduleId, this.states)?.phase;
91
+ return phase !== undefined && touchedPhases.has(phase);
92
+ });
93
+ if (options.stopFirst) {
94
+ const stopResult = await executeLifecyclePhase(shutdownOrder, "stop", "stopping", "stopped", true, this.registry, this.loader, this.states, this.contextStorage);
95
+ for (const moduleId of stopResult.failed) {
96
+ rollbackErrors.push(getLifecycleState(moduleId, this.states)?.error ??
97
+ new Error(`Module "${moduleId}" failed to stop during rollback.`));
98
+ }
99
+ }
100
+ const destroyResult = await executeLifecyclePhase(shutdownOrder, "destroy", "destroying", "destroyed", true, this.registry, this.loader, this.states, this.contextStorage);
101
+ for (const moduleId of destroyResult.failed) {
102
+ rollbackErrors.push(getLifecycleState(moduleId, this.states)?.error ??
103
+ new Error(`Module "${moduleId}" failed to destroy during rollback.`));
104
+ }
105
+ }
106
+ catch (rollbackError) {
107
+ rollbackErrors.push(rollbackError);
108
+ }
109
+ if (error instanceof ModuleLifecycleError && rollbackErrors.length > 0) {
110
+ error.rollbackErrors = Object.freeze([...rollbackErrors]);
111
+ }
112
+ }
113
+ /**
114
+ * Shuts down and unloads a single module.
115
+ *
116
+ * The module is stopped (when started) and destroyed, its
117
+ * lifecycle state is dropped, and the loader forgets its
118
+ * instance and context. Hook failures never abort the unload;
119
+ * they are reported in the result and on the lifecycle state.
120
+ *
121
+ * A module that other loaded modules still depend on cannot be
122
+ * unloaded; ModuleError (MODULE_OPERATION_NOT_ALLOWED) is thrown.
123
+ */
124
+ async unloadModule(moduleId) {
125
+ return this.runExclusive(async () => {
126
+ ensureStateSynchronized(this.registry, this.states);
127
+ const registration = this.registry.get(moduleId);
128
+ if (!registration?.instance) {
129
+ this.loader.unload(moduleId);
130
+ this.states.delete(moduleId);
131
+ return { completed: [], failed: [], skipped: [] };
132
+ }
133
+ const dependents = this.getLoadedDependents(moduleId);
134
+ if (dependents.length > 0) {
135
+ throw new ModuleError(`Module "${moduleId}" cannot be unloaded while loaded modules depend on it: ${dependents.join(", ")}.`, {
136
+ code: ModuleErrorCode.OPERATION_NOT_ALLOWED,
137
+ moduleId,
138
+ metadata: { dependents },
139
+ });
140
+ }
141
+ const stopped = await executeLifecyclePhase([moduleId], "stop", "stopping", "stopped", true, this.registry, this.loader, this.states, this.contextStorage);
142
+ const destroyed = await executeLifecyclePhase([moduleId], "destroy", "destroying", "destroyed", true, this.registry, this.loader, this.states, this.contextStorage);
143
+ this.loader.unload(moduleId);
144
+ this.states.delete(moduleId);
145
+ return {
146
+ completed: Object.freeze([
147
+ ...new Set([...stopped.completed, ...destroyed.completed]),
148
+ ]),
149
+ failed: Object.freeze([
150
+ ...new Set([...stopped.failed, ...destroyed.failed]),
151
+ ]),
152
+ skipped: Object.freeze([...stopped.skipped, ...destroyed.skipped]),
153
+ };
154
+ });
155
+ }
156
+ /**
157
+ * Replaces a module definition, shutting down the currently
158
+ * loaded instance first.
159
+ *
160
+ * The registry must allow replacement (allowReplacement: true).
161
+ * The new definition is registered but not loaded; call the
162
+ * loader and lifecycle methods afterwards to bring it up.
163
+ */
164
+ async replaceModule(definition) {
165
+ const existing = this.registry.get(definition.id);
166
+ if (existing?.instance)
167
+ await this.unloadModule(definition.id);
168
+ return this.registry.register(definition);
169
+ }
170
+ /**
171
+ * Returns ids of loaded modules that declare a required or
172
+ * optional dependency on the given module.
173
+ */
174
+ getLoadedDependents(moduleId) {
175
+ const dependents = [];
176
+ for (const registration of this.registry.getAll()) {
177
+ if (registration.definition.id === moduleId)
178
+ continue;
179
+ if (registration.state !== "loaded")
180
+ continue;
181
+ const dependsOnModule = this.registry
182
+ .getDependencies(registration.definition.id)
183
+ .some((dependency) => dependency.id === moduleId);
184
+ if (dependsOnModule)
185
+ dependents.push(registration.definition.id);
186
+ }
187
+ return dependents;
188
+ }
47
189
  async startApplication() {
190
+ /*
191
+ * When continueOn*Error is disabled, phase failures are
192
+ * reported through the thrown (and rolled-back)
193
+ * ModuleLifecycleError from initialize()/start(). That is
194
+ * the single failure path of application startup.
195
+ */
48
196
  const initialized = await this.initialize();
49
- if (initialized.failed.length > 0 &&
50
- !this.options.continueOnInitializeError)
51
- throw new Error("Application startup aborted because module initialization failed.");
52
197
  const started = await this.start();
53
- if (started.failed.length > 0 && !this.options.continueOnStartError)
54
- throw new Error("Application startup aborted because module startup failed.");
55
198
  return { initialized, started };
56
199
  }
57
200
  async stopApplication() {
@@ -81,6 +224,7 @@ export class ModuleLifecycleManager {
81
224
  const nodes = this.registry.getAll().map((r) => ({
82
225
  id: r.definition.id,
83
226
  dependencies: this.registry.getDependencies(r.definition.id),
227
+ version: r.definition.version,
84
228
  }));
85
229
  return createModuleDependencyGraph(nodes);
86
230
  }
@@ -1,9 +1,15 @@
1
1
  import type { Module, ModuleId } from "../module.js";
2
2
  import type { ModuleContext } from "../moduleContext.context.js";
3
- import type { ModuleLifecycleHooks, ModuleLifecyclePhase, ModuleLifecycleState, LifecycleStateMap } from "./moduleLifecycle.type.js";
3
+ import type { ModuleLifecycleStep, ModuleLifecyclePhase, ModuleLifecycleState, ModuleLifecycleSkip, LifecycleStateMap } from "./moduleLifecycle.type.js";
4
4
  import type { ModuleRegistry } from "../moduleRegistry/index.js";
5
5
  import type { ModuleLoader } from "../moduleLoader/index.js";
6
- /** Ensures lifecycle state is synchronized with the registry. */
6
+ import type { ContextStorage } from "../../context/provider/contextStorage.storage.js";
7
+ /**
8
+ * Ensures lifecycle state is synchronized with the registry.
9
+ *
10
+ * Registered modules gain a "created" state; states belonging to
11
+ * modules that are no longer registered are pruned.
12
+ */
7
13
  export declare function ensureStateSynchronized(registry: ModuleRegistry, states: LifecycleStateMap): void;
8
14
  export declare function getLifecycleState(moduleId: ModuleId, states: LifecycleStateMap): ModuleLifecycleState | undefined;
9
15
  export declare function requireLifecycleState(moduleId: ModuleId, states: LifecycleStateMap): ModuleLifecycleState;
@@ -11,11 +17,30 @@ export declare function getAllLifecycleStates(states: LifecycleStateMap): Readon
11
17
  export declare function isModuleInitialized(moduleId: ModuleId, states: LifecycleStateMap): boolean;
12
18
  export declare function isModuleStarted(moduleId: ModuleId, states: LifecycleStateMap): boolean;
13
19
  export declare function isModuleDestroyed(moduleId: ModuleId, states: LifecycleStateMap): boolean;
14
- export declare function invokeLifecycleHook(module: Module, hook: keyof ModuleLifecycleHooks, context: ModuleContext): Promise<void>;
15
- export declare function canModuleEnterPhase(moduleId: ModuleId, hook: keyof ModuleLifecycleHooks, states: LifecycleStateMap): boolean;
20
+ /**
21
+ * Invokes the lifecycle hook for a step on a module.
22
+ *
23
+ * Only the canonical Module contract hooks are invoked:
24
+ *
25
+ * initialize → onInitialize
26
+ * start → onReady
27
+ * stop → onShutdown
28
+ * destroy → onDestroy
29
+ *
30
+ * Modules that do not implement a hook are skipped for that step.
31
+ *
32
+ * When `contextStorage` holds an active execution context (the
33
+ * runtime's, during bootstrap and shutdown), the hook runs inside a
34
+ * context derived from it: `module` is the module id, `operation`
35
+ * is the hook name, and `{ moduleId, phase }` is merged into the
36
+ * metadata. Everything the hook awaits observes that context.
37
+ */
38
+ export declare function invokeLifecycleHook(module: Module, step: ModuleLifecycleStep, context: ModuleContext, contextStorage?: ContextStorage, phase?: ModuleLifecyclePhase): Promise<void>;
39
+ export declare function canModuleEnterPhase(moduleId: ModuleId, hook: ModuleLifecycleStep, states: LifecycleStateMap): boolean;
16
40
  export declare function setLifecycleState(moduleId: ModuleId, phase: ModuleLifecyclePhase, states: LifecycleStateMap, error?: unknown): void;
17
- export declare function executeLifecyclePhase(order: readonly ModuleId[], hook: keyof ModuleLifecycleHooks, activePhase: ModuleLifecyclePhase, completedPhase: ModuleLifecyclePhase, continueOnError: boolean, registry: ModuleRegistry, loader: ModuleLoader, states: LifecycleStateMap): Promise<{
41
+ export declare function executeLifecyclePhase(order: readonly ModuleId[], hook: ModuleLifecycleStep, activePhase: ModuleLifecyclePhase, completedPhase: ModuleLifecyclePhase, continueOnError: boolean, registry: ModuleRegistry, loader: ModuleLoader, states: LifecycleStateMap, contextStorage?: ContextStorage): Promise<{
18
42
  readonly completed: readonly ModuleId[];
19
43
  readonly failed: readonly ModuleId[];
44
+ readonly skipped: readonly ModuleLifecycleSkip[];
20
45
  }>;
21
46
  //# sourceMappingURL=moduleLifecycle.stateMachine.d.ts.map