@illuma/core 1.4.0 → 1.5.1

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/dist/plugins.cjs CHANGED
@@ -22,7 +22,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
22
22
  var plugins_exports = {};
23
23
  __export(plugins_exports, {
24
24
  DiagnosticsDefaultReporter: () => DiagnosticsDefaultReporter,
25
- Illuma: () => Illuma
25
+ Illuma: () => Illuma,
26
+ enableIllumaDiagnostics: () => enableIllumaDiagnostics
26
27
  });
27
28
  module.exports = __toCommonJS(plugins_exports);
28
29
 
@@ -31,7 +32,7 @@ var Illuma = class _Illuma {
31
32
  static {
32
33
  __name(this, "Illuma");
33
34
  }
34
- static _diagnostics = [];
35
+ static _diagnostics = /* @__PURE__ */ new Set();
35
36
  static _scanners = [];
36
37
  static _middlewares = [];
37
38
  /** @internal */
@@ -45,7 +46,7 @@ var Illuma = class _Illuma {
45
46
  * @param m - The diagnostics module instance to add
46
47
  */
47
48
  static extendDiagnostics(m) {
48
- _Illuma._diagnostics.push(m);
49
+ _Illuma._diagnostics.add(m);
49
50
  }
50
51
  /**
51
52
  * Extends the context scanners with a new context scanner.
@@ -73,8 +74,37 @@ var Illuma = class _Illuma {
73
74
  static onReport(report) {
74
75
  for (const diag of _Illuma._diagnostics) diag.onReport(report);
75
76
  }
77
+ /**
78
+ * @internal
79
+ * Check if diagnostics modules are registered
80
+ */
81
+ static hasDiagnostics() {
82
+ return _Illuma._diagnostics.size > 0;
83
+ }
84
+ /**
85
+ * @internal
86
+ * Reset all plugin registrations
87
+ */
88
+ static __resetPlugins() {
89
+ _Illuma._diagnostics.clear();
90
+ _Illuma._scanners.length = 0;
91
+ _Illuma._middlewares.length = 0;
92
+ }
76
93
  };
77
94
 
95
+ // src/lib/plugins/middlewares/diagnostics.middleware.ts
96
+ var performanceDiagnostics = /* @__PURE__ */ __name((params, next) => {
97
+ if (!params.deps.size) {
98
+ return next(params);
99
+ }
100
+ const start = performance.now();
101
+ const instance = next(params);
102
+ const end = performance.now();
103
+ const duration = end - start;
104
+ console.log(`Instantiated ${params.token.name} in ${duration.toFixed(2)} ms`);
105
+ return instance;
106
+ }, "performanceDiagnostics");
107
+
78
108
  // src/lib/plugins/diagnostics/default-impl.ts
79
109
  var DiagnosticsDefaultReporter = class {
80
110
  static {
@@ -87,9 +117,22 @@ var DiagnosticsDefaultReporter = class {
87
117
  for (const node of report.unusedNodes) console.log(` - ${node.toString()}`);
88
118
  }
89
119
  };
120
+
121
+ // src/lib/plugins/diagnostics/built-in.ts
122
+ var state = {
123
+ enabled: false
124
+ };
125
+ function enableIllumaDiagnostics() {
126
+ if (state.enabled) return;
127
+ state.enabled = true;
128
+ Illuma.extendDiagnostics(new DiagnosticsDefaultReporter());
129
+ Illuma.registerGlobalMiddleware(performanceDiagnostics);
130
+ }
131
+ __name(enableIllumaDiagnostics, "enableIllumaDiagnostics");
90
132
  // Annotate the CommonJS export names for ESM import in node:
91
133
  0 && (module.exports = {
92
134
  DiagnosticsDefaultReporter,
93
- Illuma
135
+ Illuma,
136
+ enableIllumaDiagnostics
94
137
  });
95
138
  //# sourceMappingURL=plugins.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugins.ts","../src/lib/plugins/core/plugin-container.ts","../src/lib/plugins/diagnostics/default-impl.ts"],"sourcesContent":["export * from \"./lib/plugins\";\n","import type { iContextScanner } from \"../context\";\nimport type { iDiagnosticsModule, iDiagnosticsReport } from \"../diagnostics/types\";\nimport type { iMiddleware } from \"../middlewares/types\";\n\n/**\n * Global plugin container for managing core plugins such as diagnostics and context scanners.\n */\nexport abstract class Illuma {\n private static readonly _diagnostics = [] as iDiagnosticsModule[];\n private static readonly _scanners = [] as iContextScanner[];\n protected static readonly _middlewares = [] as iMiddleware[];\n\n /** @internal */\n public static get contextScanners(): ReadonlyArray<iContextScanner> {\n return Illuma._scanners;\n }\n\n /**\n * Extends the diagnostics with a new diagnostics module.\n * These will be run on diagnostics reports after container bootstrap.\n *\n * @param m - The diagnostics module instance to add\n */\n public static extendDiagnostics(m: iDiagnosticsModule): void {\n Illuma._diagnostics.push(m);\n }\n\n /**\n * Extends the context scanners with a new context scanner.\n * These will be run in injection context scans to detect additional injections (alongside `nodeInject` calls).\n *\n * @param scanner - The context scanner instance to add\n */\n public static extendContextScanner(scanner: iContextScanner): void {\n Illuma._scanners.push(scanner);\n }\n\n /**\n * Registers a global middleware to be applied during instance creation.\n * Typically used for cross-cutting concerns like logging, profiling, or custom instantiation logic.\n * Function should accept instantiation parameters and a `next` function to proceed with the next middleware or actual instantiation.\n *\n * @param m - The middleware function to register\n */\n public static registerGlobalMiddleware(m: iMiddleware): void {\n Illuma._middlewares.push(m);\n }\n\n protected readonly middlewares = [] as iMiddleware[];\n public registerMiddleware(m: iMiddleware): void {\n this.middlewares.push(m);\n }\n\n protected static onReport(report: iDiagnosticsReport): void {\n for (const diag of Illuma._diagnostics) diag.onReport(report);\n }\n}\n","import type { iDiagnosticsModule, iDiagnosticsReport } from \"./types\";\n\nexport class DiagnosticsDefaultReporter implements iDiagnosticsModule {\n public onReport(report: iDiagnosticsReport): void {\n console.log(\"[Illuma] 🧹 Diagnostics:\");\n console.log(` Total: ${report.totalNodes} node(s)`);\n console.log(` ${report.unusedNodes.length} were not used while bootstrap:`);\n for (const node of report.unusedNodes) console.log(` - ${node.toString()}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;ACOO,IAAeA,SAAf,MAAeA,QAAAA;EAHtB,OAGsBA;;;EACpB,OAAwBC,eAAe,CAAA;EACvC,OAAwBC,YAAY,CAAA;EACpC,OAA0BC,eAAe,CAAA;;EAGzC,WAAkBC,kBAAkD;AAClE,WAAOJ,QAAOE;EAChB;;;;;;;EAQA,OAAcG,kBAAkBC,GAA6B;AAC3DN,YAAOC,aAAaM,KAAKD,CAAAA;EAC3B;;;;;;;EAQA,OAAcE,qBAAqBC,SAAgC;AACjET,YAAOE,UAAUK,KAAKE,OAAAA;EACxB;;;;;;;;EASA,OAAcC,yBAAyBJ,GAAsB;AAC3DN,YAAOG,aAAaI,KAAKD,CAAAA;EAC3B;EAEmBK,cAAc,CAAA;EAC1BC,mBAAmBN,GAAsB;AAC9C,SAAKK,YAAYJ,KAAKD,CAAAA;EACxB;EAEA,OAAiBO,SAASC,QAAkC;AAC1D,eAAWC,QAAQf,QAAOC,aAAcc,MAAKF,SAASC,MAAAA;EACxD;AACF;;;ACtDO,IAAME,6BAAN,MAAMA;EAAb,OAAaA;;;EACJC,SAASC,QAAkC;AAChDC,YAAQC,IAAI,iCAAA;AACZD,YAAQC,IAAI,YAAYF,OAAOG,UAAU,UAAU;AACnDF,YAAQC,IAAI,KAAKF,OAAOI,YAAYC,MAAM,iCAAiC;AAC3E,eAAWC,QAAQN,OAAOI,YAAaH,SAAQC,IAAI,SAASI,KAAKC,SAAQ,CAAA,EAAI;EAC/E;AACF;","names":["Illuma","_diagnostics","_scanners","_middlewares","contextScanners","extendDiagnostics","m","push","extendContextScanner","scanner","registerGlobalMiddleware","middlewares","registerMiddleware","onReport","report","diag","DiagnosticsDefaultReporter","onReport","report","console","log","totalNodes","unusedNodes","length","node","toString"]}
1
+ {"version":3,"sources":["../src/plugins.ts","../src/lib/plugins/core/plugin-container.ts","../src/lib/plugins/middlewares/diagnostics.middleware.ts","../src/lib/plugins/diagnostics/default-impl.ts","../src/lib/plugins/diagnostics/built-in.ts"],"sourcesContent":["export * from \"./lib/plugins\";\n","import type { iContextScanner } from \"../context\";\nimport type { iDiagnosticsModule, iDiagnosticsReport } from \"../diagnostics/types\";\nimport type { iMiddleware } from \"../middlewares/types\";\n\n/**\n * Global plugin container for managing core plugins such as diagnostics and context scanners.\n */\nexport abstract class Illuma {\n private static readonly _diagnostics = new Set<iDiagnosticsModule>();\n private static readonly _scanners = [] as iContextScanner[];\n protected static readonly _middlewares = [] as iMiddleware[];\n\n /** @internal */\n public static get contextScanners(): ReadonlyArray<iContextScanner> {\n return Illuma._scanners;\n }\n\n /**\n * Extends the diagnostics with a new diagnostics module.\n * These will be run on diagnostics reports after container bootstrap.\n *\n * @param m - The diagnostics module instance to add\n */\n public static extendDiagnostics(m: iDiagnosticsModule): void {\n Illuma._diagnostics.add(m);\n }\n\n /**\n * Extends the context scanners with a new context scanner.\n * These will be run in injection context scans to detect additional injections (alongside `nodeInject` calls).\n *\n * @param scanner - The context scanner instance to add\n */\n public static extendContextScanner(scanner: iContextScanner): void {\n Illuma._scanners.push(scanner);\n }\n\n /**\n * Registers a global middleware to be applied during instance creation.\n * Typically used for cross-cutting concerns like logging, profiling, or custom instantiation logic.\n * Function should accept instantiation parameters and a `next` function to proceed with the next middleware or actual instantiation.\n *\n * @param m - The middleware function to register\n */\n public static registerGlobalMiddleware(m: iMiddleware): void {\n Illuma._middlewares.push(m);\n }\n\n protected readonly middlewares = [] as iMiddleware[];\n public registerMiddleware(m: iMiddleware): void {\n this.middlewares.push(m);\n }\n\n protected static onReport(report: iDiagnosticsReport): void {\n for (const diag of Illuma._diagnostics) diag.onReport(report);\n }\n\n /**\n * @internal\n * Check if diagnostics modules are registered\n */\n protected static hasDiagnostics(): boolean {\n return Illuma._diagnostics.size > 0;\n }\n\n /**\n * @internal\n * Reset all plugin registrations\n */\n protected static __resetPlugins(): void {\n Illuma._diagnostics.clear();\n Illuma._scanners.length = 0;\n Illuma._middlewares.length = 0;\n }\n}\n","import type { iMiddleware } from \"./types\";\n\nexport const performanceDiagnostics: iMiddleware = (params, next) => {\n if (!params.deps.size) {\n return next(params);\n }\n\n const start = performance.now();\n const instance = next(params);\n const end = performance.now();\n const duration = end - start;\n\n console.log(`Instantiated ${params.token.name} in ${duration.toFixed(2)} ms`);\n return instance;\n};\n","import type { iDiagnosticsModule, iDiagnosticsReport } from \"./types\";\n\nexport class DiagnosticsDefaultReporter implements iDiagnosticsModule {\n public onReport(report: iDiagnosticsReport): void {\n console.log(\"[Illuma] 🧹 Diagnostics:\");\n console.log(` Total: ${report.totalNodes} node(s)`);\n console.log(` ${report.unusedNodes.length} were not used while bootstrap:`);\n for (const node of report.unusedNodes) console.log(` - ${node.toString()}`);\n }\n}\n","import { Illuma } from \"../core\";\nimport { performanceDiagnostics } from \"../middlewares/diagnostics.middleware\";\nimport { DiagnosticsDefaultReporter } from \"./default-impl\";\n\nconst state = { enabled: false };\n\nexport function enableIllumaDiagnostics() {\n if (state.enabled) return;\n state.enabled = true;\n\n Illuma.extendDiagnostics(new DiagnosticsDefaultReporter());\n Illuma.registerGlobalMiddleware(performanceDiagnostics);\n}\n\n/**\n * @internal\n * Reset diagnostics state (for testing only)\n */\nexport function __resetDiagnosticsState() {\n state.enabled = false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;ACOO,IAAeA,SAAf,MAAeA,QAAAA;EAHtB,OAGsBA;;;EACpB,OAAwBC,eAAe,oBAAIC,IAAAA;EAC3C,OAAwBC,YAAY,CAAA;EACpC,OAA0BC,eAAe,CAAA;;EAGzC,WAAkBC,kBAAkD;AAClE,WAAOL,QAAOG;EAChB;;;;;;;EAQA,OAAcG,kBAAkBC,GAA6B;AAC3DP,YAAOC,aAAaO,IAAID,CAAAA;EAC1B;;;;;;;EAQA,OAAcE,qBAAqBC,SAAgC;AACjEV,YAAOG,UAAUQ,KAAKD,OAAAA;EACxB;;;;;;;;EASA,OAAcE,yBAAyBL,GAAsB;AAC3DP,YAAOI,aAAaO,KAAKJ,CAAAA;EAC3B;EAEmBM,cAAc,CAAA;EAC1BC,mBAAmBP,GAAsB;AAC9C,SAAKM,YAAYF,KAAKJ,CAAAA;EACxB;EAEA,OAAiBQ,SAASC,QAAkC;AAC1D,eAAWC,QAAQjB,QAAOC,aAAcgB,MAAKF,SAASC,MAAAA;EACxD;;;;;EAMA,OAAiBE,iBAA0B;AACzC,WAAOlB,QAAOC,aAAakB,OAAO;EACpC;;;;;EAMA,OAAiBC,iBAAuB;AACtCpB,YAAOC,aAAaoB,MAAK;AACzBrB,YAAOG,UAAUmB,SAAS;AAC1BtB,YAAOI,aAAakB,SAAS;EAC/B;AACF;;;ACxEO,IAAMC,yBAAsC,wBAACC,QAAQC,SAAAA;AAC1D,MAAI,CAACD,OAAOE,KAAKC,MAAM;AACrB,WAAOF,KAAKD,MAAAA;EACd;AAEA,QAAMI,QAAQC,YAAYC,IAAG;AAC7B,QAAMC,WAAWN,KAAKD,MAAAA;AACtB,QAAMQ,MAAMH,YAAYC,IAAG;AAC3B,QAAMG,WAAWD,MAAMJ;AAEvBM,UAAQC,IAAI,gBAAgBX,OAAOY,MAAMC,IAAI,OAAOJ,SAASK,QAAQ,CAAA,CAAA,KAAO;AAC5E,SAAOP;AACT,GAZmD;;;ACA5C,IAAMQ,6BAAN,MAAMA;EAAb,OAAaA;;;EACJC,SAASC,QAAkC;AAChDC,YAAQC,IAAI,iCAAA;AACZD,YAAQC,IAAI,YAAYF,OAAOG,UAAU,UAAU;AACnDF,YAAQC,IAAI,KAAKF,OAAOI,YAAYC,MAAM,iCAAiC;AAC3E,eAAWC,QAAQN,OAAOI,YAAaH,SAAQC,IAAI,SAASI,KAAKC,SAAQ,CAAA,EAAI;EAC/E;AACF;;;ACLA,IAAMC,QAAQ;EAAEC,SAAS;AAAM;AAExB,SAASC,0BAAAA;AACd,MAAIF,MAAMC,QAAS;AACnBD,QAAMC,UAAU;AAEhBE,SAAOC,kBAAkB,IAAIC,2BAAAA,CAAAA;AAC7BF,SAAOG,yBAAyBC,sBAAAA;AAClC;AANgBL;","names":["Illuma","_diagnostics","Set","_scanners","_middlewares","contextScanners","extendDiagnostics","m","add","extendContextScanner","scanner","push","registerGlobalMiddleware","middlewares","registerMiddleware","onReport","report","diag","hasDiagnostics","size","__resetPlugins","clear","length","performanceDiagnostics","params","next","deps","size","start","performance","now","instance","end","duration","console","log","token","name","toFixed","DiagnosticsDefaultReporter","onReport","report","console","log","totalNodes","unusedNodes","length","node","toString","state","enabled","enableIllumaDiagnostics","Illuma","extendDiagnostics","DiagnosticsDefaultReporter","registerGlobalMiddleware","performanceDiagnostics"]}
@@ -1,9 +1,11 @@
1
- import { b as iDiagnosticsModule, c as iDiagnosticsReport } from './plugin-container-CXuie89o.cjs';
2
- export { I as Illuma, d as iContextScanner, e as iInstantiationParams, i as iMiddleware } from './plugin-container-CXuie89o.cjs';
1
+ import { b as iDiagnosticsModule, c as iDiagnosticsReport } from './plugin-container-OWBUHjSf.cjs';
2
+ export { I as Illuma, d as iContextScanner, e as iInstantiationParams, i as iMiddleware } from './plugin-container-OWBUHjSf.cjs';
3
3
  import './types-zryyqrii.cjs';
4
4
 
5
+ declare function enableIllumaDiagnostics(): void;
6
+
5
7
  declare class DiagnosticsDefaultReporter implements iDiagnosticsModule {
6
8
  onReport(report: iDiagnosticsReport): void;
7
9
  }
8
10
 
9
- export { DiagnosticsDefaultReporter, iDiagnosticsModule, iDiagnosticsReport };
11
+ export { DiagnosticsDefaultReporter, enableIllumaDiagnostics, iDiagnosticsModule, iDiagnosticsReport };
package/dist/plugins.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { b as iDiagnosticsModule, c as iDiagnosticsReport } from './plugin-container-CG_kjb35.js';
2
- export { I as Illuma, d as iContextScanner, e as iInstantiationParams, i as iMiddleware } from './plugin-container-CG_kjb35.js';
1
+ import { b as iDiagnosticsModule, c as iDiagnosticsReport } from './plugin-container-DZj4vSLu.js';
2
+ export { I as Illuma, d as iContextScanner, e as iInstantiationParams, i as iMiddleware } from './plugin-container-DZj4vSLu.js';
3
3
  import './types-zryyqrii.js';
4
4
 
5
+ declare function enableIllumaDiagnostics(): void;
6
+
5
7
  declare class DiagnosticsDefaultReporter implements iDiagnosticsModule {
6
8
  onReport(report: iDiagnosticsReport): void;
7
9
  }
8
10
 
9
- export { DiagnosticsDefaultReporter, iDiagnosticsModule, iDiagnosticsReport };
11
+ export { DiagnosticsDefaultReporter, enableIllumaDiagnostics, iDiagnosticsModule, iDiagnosticsReport };
package/dist/plugins.js CHANGED
@@ -6,7 +6,7 @@ var Illuma = class _Illuma {
6
6
  static {
7
7
  __name(this, "Illuma");
8
8
  }
9
- static _diagnostics = [];
9
+ static _diagnostics = /* @__PURE__ */ new Set();
10
10
  static _scanners = [];
11
11
  static _middlewares = [];
12
12
  /** @internal */
@@ -20,7 +20,7 @@ var Illuma = class _Illuma {
20
20
  * @param m - The diagnostics module instance to add
21
21
  */
22
22
  static extendDiagnostics(m) {
23
- _Illuma._diagnostics.push(m);
23
+ _Illuma._diagnostics.add(m);
24
24
  }
25
25
  /**
26
26
  * Extends the context scanners with a new context scanner.
@@ -48,8 +48,37 @@ var Illuma = class _Illuma {
48
48
  static onReport(report) {
49
49
  for (const diag of _Illuma._diagnostics) diag.onReport(report);
50
50
  }
51
+ /**
52
+ * @internal
53
+ * Check if diagnostics modules are registered
54
+ */
55
+ static hasDiagnostics() {
56
+ return _Illuma._diagnostics.size > 0;
57
+ }
58
+ /**
59
+ * @internal
60
+ * Reset all plugin registrations
61
+ */
62
+ static __resetPlugins() {
63
+ _Illuma._diagnostics.clear();
64
+ _Illuma._scanners.length = 0;
65
+ _Illuma._middlewares.length = 0;
66
+ }
51
67
  };
52
68
 
69
+ // src/lib/plugins/middlewares/diagnostics.middleware.ts
70
+ var performanceDiagnostics = /* @__PURE__ */ __name((params, next) => {
71
+ if (!params.deps.size) {
72
+ return next(params);
73
+ }
74
+ const start = performance.now();
75
+ const instance = next(params);
76
+ const end = performance.now();
77
+ const duration = end - start;
78
+ console.log(`Instantiated ${params.token.name} in ${duration.toFixed(2)} ms`);
79
+ return instance;
80
+ }, "performanceDiagnostics");
81
+
53
82
  // src/lib/plugins/diagnostics/default-impl.ts
54
83
  var DiagnosticsDefaultReporter = class {
55
84
  static {
@@ -62,8 +91,21 @@ var DiagnosticsDefaultReporter = class {
62
91
  for (const node of report.unusedNodes) console.log(` - ${node.toString()}`);
63
92
  }
64
93
  };
94
+
95
+ // src/lib/plugins/diagnostics/built-in.ts
96
+ var state = {
97
+ enabled: false
98
+ };
99
+ function enableIllumaDiagnostics() {
100
+ if (state.enabled) return;
101
+ state.enabled = true;
102
+ Illuma.extendDiagnostics(new DiagnosticsDefaultReporter());
103
+ Illuma.registerGlobalMiddleware(performanceDiagnostics);
104
+ }
105
+ __name(enableIllumaDiagnostics, "enableIllumaDiagnostics");
65
106
  export {
66
107
  DiagnosticsDefaultReporter,
67
- Illuma
108
+ Illuma,
109
+ enableIllumaDiagnostics
68
110
  };
69
111
  //# sourceMappingURL=plugins.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/plugins/core/plugin-container.ts","../src/lib/plugins/diagnostics/default-impl.ts"],"sourcesContent":["import type { iContextScanner } from \"../context\";\nimport type { iDiagnosticsModule, iDiagnosticsReport } from \"../diagnostics/types\";\nimport type { iMiddleware } from \"../middlewares/types\";\n\n/**\n * Global plugin container for managing core plugins such as diagnostics and context scanners.\n */\nexport abstract class Illuma {\n private static readonly _diagnostics = [] as iDiagnosticsModule[];\n private static readonly _scanners = [] as iContextScanner[];\n protected static readonly _middlewares = [] as iMiddleware[];\n\n /** @internal */\n public static get contextScanners(): ReadonlyArray<iContextScanner> {\n return Illuma._scanners;\n }\n\n /**\n * Extends the diagnostics with a new diagnostics module.\n * These will be run on diagnostics reports after container bootstrap.\n *\n * @param m - The diagnostics module instance to add\n */\n public static extendDiagnostics(m: iDiagnosticsModule): void {\n Illuma._diagnostics.push(m);\n }\n\n /**\n * Extends the context scanners with a new context scanner.\n * These will be run in injection context scans to detect additional injections (alongside `nodeInject` calls).\n *\n * @param scanner - The context scanner instance to add\n */\n public static extendContextScanner(scanner: iContextScanner): void {\n Illuma._scanners.push(scanner);\n }\n\n /**\n * Registers a global middleware to be applied during instance creation.\n * Typically used for cross-cutting concerns like logging, profiling, or custom instantiation logic.\n * Function should accept instantiation parameters and a `next` function to proceed with the next middleware or actual instantiation.\n *\n * @param m - The middleware function to register\n */\n public static registerGlobalMiddleware(m: iMiddleware): void {\n Illuma._middlewares.push(m);\n }\n\n protected readonly middlewares = [] as iMiddleware[];\n public registerMiddleware(m: iMiddleware): void {\n this.middlewares.push(m);\n }\n\n protected static onReport(report: iDiagnosticsReport): void {\n for (const diag of Illuma._diagnostics) diag.onReport(report);\n }\n}\n","import type { iDiagnosticsModule, iDiagnosticsReport } from \"./types\";\n\nexport class DiagnosticsDefaultReporter implements iDiagnosticsModule {\n public onReport(report: iDiagnosticsReport): void {\n console.log(\"[Illuma] 🧹 Diagnostics:\");\n console.log(` Total: ${report.totalNodes} node(s)`);\n console.log(` ${report.unusedNodes.length} were not used while bootstrap:`);\n for (const node of report.unusedNodes) console.log(` - ${node.toString()}`);\n }\n}\n"],"mappings":";;;;AAOO,IAAeA,SAAf,MAAeA,QAAAA;EAHtB,OAGsBA;;;EACpB,OAAwBC,eAAe,CAAA;EACvC,OAAwBC,YAAY,CAAA;EACpC,OAA0BC,eAAe,CAAA;;EAGzC,WAAkBC,kBAAkD;AAClE,WAAOJ,QAAOE;EAChB;;;;;;;EAQA,OAAcG,kBAAkBC,GAA6B;AAC3DN,YAAOC,aAAaM,KAAKD,CAAAA;EAC3B;;;;;;;EAQA,OAAcE,qBAAqBC,SAAgC;AACjET,YAAOE,UAAUK,KAAKE,OAAAA;EACxB;;;;;;;;EASA,OAAcC,yBAAyBJ,GAAsB;AAC3DN,YAAOG,aAAaI,KAAKD,CAAAA;EAC3B;EAEmBK,cAAc,CAAA;EAC1BC,mBAAmBN,GAAsB;AAC9C,SAAKK,YAAYJ,KAAKD,CAAAA;EACxB;EAEA,OAAiBO,SAASC,QAAkC;AAC1D,eAAWC,QAAQf,QAAOC,aAAcc,MAAKF,SAASC,MAAAA;EACxD;AACF;;;ACtDO,IAAME,6BAAN,MAAMA;EAAb,OAAaA;;;EACJC,SAASC,QAAkC;AAChDC,YAAQC,IAAI,iCAAA;AACZD,YAAQC,IAAI,YAAYF,OAAOG,UAAU,UAAU;AACnDF,YAAQC,IAAI,KAAKF,OAAOI,YAAYC,MAAM,iCAAiC;AAC3E,eAAWC,QAAQN,OAAOI,YAAaH,SAAQC,IAAI,SAASI,KAAKC,SAAQ,CAAA,EAAI;EAC/E;AACF;","names":["Illuma","_diagnostics","_scanners","_middlewares","contextScanners","extendDiagnostics","m","push","extendContextScanner","scanner","registerGlobalMiddleware","middlewares","registerMiddleware","onReport","report","diag","DiagnosticsDefaultReporter","onReport","report","console","log","totalNodes","unusedNodes","length","node","toString"]}
1
+ {"version":3,"sources":["../src/lib/plugins/core/plugin-container.ts","../src/lib/plugins/middlewares/diagnostics.middleware.ts","../src/lib/plugins/diagnostics/default-impl.ts","../src/lib/plugins/diagnostics/built-in.ts"],"sourcesContent":["import type { iContextScanner } from \"../context\";\nimport type { iDiagnosticsModule, iDiagnosticsReport } from \"../diagnostics/types\";\nimport type { iMiddleware } from \"../middlewares/types\";\n\n/**\n * Global plugin container for managing core plugins such as diagnostics and context scanners.\n */\nexport abstract class Illuma {\n private static readonly _diagnostics = new Set<iDiagnosticsModule>();\n private static readonly _scanners = [] as iContextScanner[];\n protected static readonly _middlewares = [] as iMiddleware[];\n\n /** @internal */\n public static get contextScanners(): ReadonlyArray<iContextScanner> {\n return Illuma._scanners;\n }\n\n /**\n * Extends the diagnostics with a new diagnostics module.\n * These will be run on diagnostics reports after container bootstrap.\n *\n * @param m - The diagnostics module instance to add\n */\n public static extendDiagnostics(m: iDiagnosticsModule): void {\n Illuma._diagnostics.add(m);\n }\n\n /**\n * Extends the context scanners with a new context scanner.\n * These will be run in injection context scans to detect additional injections (alongside `nodeInject` calls).\n *\n * @param scanner - The context scanner instance to add\n */\n public static extendContextScanner(scanner: iContextScanner): void {\n Illuma._scanners.push(scanner);\n }\n\n /**\n * Registers a global middleware to be applied during instance creation.\n * Typically used for cross-cutting concerns like logging, profiling, or custom instantiation logic.\n * Function should accept instantiation parameters and a `next` function to proceed with the next middleware or actual instantiation.\n *\n * @param m - The middleware function to register\n */\n public static registerGlobalMiddleware(m: iMiddleware): void {\n Illuma._middlewares.push(m);\n }\n\n protected readonly middlewares = [] as iMiddleware[];\n public registerMiddleware(m: iMiddleware): void {\n this.middlewares.push(m);\n }\n\n protected static onReport(report: iDiagnosticsReport): void {\n for (const diag of Illuma._diagnostics) diag.onReport(report);\n }\n\n /**\n * @internal\n * Check if diagnostics modules are registered\n */\n protected static hasDiagnostics(): boolean {\n return Illuma._diagnostics.size > 0;\n }\n\n /**\n * @internal\n * Reset all plugin registrations\n */\n protected static __resetPlugins(): void {\n Illuma._diagnostics.clear();\n Illuma._scanners.length = 0;\n Illuma._middlewares.length = 0;\n }\n}\n","import type { iMiddleware } from \"./types\";\n\nexport const performanceDiagnostics: iMiddleware = (params, next) => {\n if (!params.deps.size) {\n return next(params);\n }\n\n const start = performance.now();\n const instance = next(params);\n const end = performance.now();\n const duration = end - start;\n\n console.log(`Instantiated ${params.token.name} in ${duration.toFixed(2)} ms`);\n return instance;\n};\n","import type { iDiagnosticsModule, iDiagnosticsReport } from \"./types\";\n\nexport class DiagnosticsDefaultReporter implements iDiagnosticsModule {\n public onReport(report: iDiagnosticsReport): void {\n console.log(\"[Illuma] 🧹 Diagnostics:\");\n console.log(` Total: ${report.totalNodes} node(s)`);\n console.log(` ${report.unusedNodes.length} were not used while bootstrap:`);\n for (const node of report.unusedNodes) console.log(` - ${node.toString()}`);\n }\n}\n","import { Illuma } from \"../core\";\nimport { performanceDiagnostics } from \"../middlewares/diagnostics.middleware\";\nimport { DiagnosticsDefaultReporter } from \"./default-impl\";\n\nconst state = { enabled: false };\n\nexport function enableIllumaDiagnostics() {\n if (state.enabled) return;\n state.enabled = true;\n\n Illuma.extendDiagnostics(new DiagnosticsDefaultReporter());\n Illuma.registerGlobalMiddleware(performanceDiagnostics);\n}\n\n/**\n * @internal\n * Reset diagnostics state (for testing only)\n */\nexport function __resetDiagnosticsState() {\n state.enabled = false;\n}\n"],"mappings":";;;;AAOO,IAAeA,SAAf,MAAeA,QAAAA;EAHtB,OAGsBA;;;EACpB,OAAwBC,eAAe,oBAAIC,IAAAA;EAC3C,OAAwBC,YAAY,CAAA;EACpC,OAA0BC,eAAe,CAAA;;EAGzC,WAAkBC,kBAAkD;AAClE,WAAOL,QAAOG;EAChB;;;;;;;EAQA,OAAcG,kBAAkBC,GAA6B;AAC3DP,YAAOC,aAAaO,IAAID,CAAAA;EAC1B;;;;;;;EAQA,OAAcE,qBAAqBC,SAAgC;AACjEV,YAAOG,UAAUQ,KAAKD,OAAAA;EACxB;;;;;;;;EASA,OAAcE,yBAAyBL,GAAsB;AAC3DP,YAAOI,aAAaO,KAAKJ,CAAAA;EAC3B;EAEmBM,cAAc,CAAA;EAC1BC,mBAAmBP,GAAsB;AAC9C,SAAKM,YAAYF,KAAKJ,CAAAA;EACxB;EAEA,OAAiBQ,SAASC,QAAkC;AAC1D,eAAWC,QAAQjB,QAAOC,aAAcgB,MAAKF,SAASC,MAAAA;EACxD;;;;;EAMA,OAAiBE,iBAA0B;AACzC,WAAOlB,QAAOC,aAAakB,OAAO;EACpC;;;;;EAMA,OAAiBC,iBAAuB;AACtCpB,YAAOC,aAAaoB,MAAK;AACzBrB,YAAOG,UAAUmB,SAAS;AAC1BtB,YAAOI,aAAakB,SAAS;EAC/B;AACF;;;ACxEO,IAAMC,yBAAsC,wBAACC,QAAQC,SAAAA;AAC1D,MAAI,CAACD,OAAOE,KAAKC,MAAM;AACrB,WAAOF,KAAKD,MAAAA;EACd;AAEA,QAAMI,QAAQC,YAAYC,IAAG;AAC7B,QAAMC,WAAWN,KAAKD,MAAAA;AACtB,QAAMQ,MAAMH,YAAYC,IAAG;AAC3B,QAAMG,WAAWD,MAAMJ;AAEvBM,UAAQC,IAAI,gBAAgBX,OAAOY,MAAMC,IAAI,OAAOJ,SAASK,QAAQ,CAAA,CAAA,KAAO;AAC5E,SAAOP;AACT,GAZmD;;;ACA5C,IAAMQ,6BAAN,MAAMA;EAAb,OAAaA;;;EACJC,SAASC,QAAkC;AAChDC,YAAQC,IAAI,iCAAA;AACZD,YAAQC,IAAI,YAAYF,OAAOG,UAAU,UAAU;AACnDF,YAAQC,IAAI,KAAKF,OAAOI,YAAYC,MAAM,iCAAiC;AAC3E,eAAWC,QAAQN,OAAOI,YAAaH,SAAQC,IAAI,SAASI,KAAKC,SAAQ,CAAA,EAAI;EAC/E;AACF;;;ACLA,IAAMC,QAAQ;EAAEC,SAAS;AAAM;AAExB,SAASC,0BAAAA;AACd,MAAIF,MAAMC,QAAS;AACnBD,QAAMC,UAAU;AAEhBE,SAAOC,kBAAkB,IAAIC,2BAAAA,CAAAA;AAC7BF,SAAOG,yBAAyBC,sBAAAA;AAClC;AANgBL;","names":["Illuma","_diagnostics","Set","_scanners","_middlewares","contextScanners","extendDiagnostics","m","add","extendContextScanner","scanner","push","registerGlobalMiddleware","middlewares","registerMiddleware","onReport","report","diag","hasDiagnostics","size","__resetPlugins","clear","length","performanceDiagnostics","params","next","deps","size","start","performance","now","instance","end","duration","console","log","token","name","toFixed","DiagnosticsDefaultReporter","onReport","report","console","log","totalNodes","unusedNodes","length","node","toString","state","enabled","enableIllumaDiagnostics","Illuma","extendDiagnostics","DiagnosticsDefaultReporter","registerGlobalMiddleware","performanceDiagnostics"]}
package/dist/testkit.cjs CHANGED
@@ -4,6 +4,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
7
10
  var __export = (target, all) => {
8
11
  for (var name in all)
9
12
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -18,6 +21,153 @@ var __copyProps = (to, from, except, desc) => {
18
21
  };
19
22
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
23
 
24
+ // src/lib/plugins/core/plugin-container.ts
25
+ var Illuma;
26
+ var init_plugin_container = __esm({
27
+ "src/lib/plugins/core/plugin-container.ts"() {
28
+ "use strict";
29
+ Illuma = class _Illuma {
30
+ static {
31
+ __name(this, "Illuma");
32
+ }
33
+ static _diagnostics = /* @__PURE__ */ new Set();
34
+ static _scanners = [];
35
+ static _middlewares = [];
36
+ /** @internal */
37
+ static get contextScanners() {
38
+ return _Illuma._scanners;
39
+ }
40
+ /**
41
+ * Extends the diagnostics with a new diagnostics module.
42
+ * These will be run on diagnostics reports after container bootstrap.
43
+ *
44
+ * @param m - The diagnostics module instance to add
45
+ */
46
+ static extendDiagnostics(m) {
47
+ _Illuma._diagnostics.add(m);
48
+ }
49
+ /**
50
+ * Extends the context scanners with a new context scanner.
51
+ * These will be run in injection context scans to detect additional injections (alongside `nodeInject` calls).
52
+ *
53
+ * @param scanner - The context scanner instance to add
54
+ */
55
+ static extendContextScanner(scanner) {
56
+ _Illuma._scanners.push(scanner);
57
+ }
58
+ /**
59
+ * Registers a global middleware to be applied during instance creation.
60
+ * Typically used for cross-cutting concerns like logging, profiling, or custom instantiation logic.
61
+ * Function should accept instantiation parameters and a `next` function to proceed with the next middleware or actual instantiation.
62
+ *
63
+ * @param m - The middleware function to register
64
+ */
65
+ static registerGlobalMiddleware(m) {
66
+ _Illuma._middlewares.push(m);
67
+ }
68
+ middlewares = [];
69
+ registerMiddleware(m) {
70
+ this.middlewares.push(m);
71
+ }
72
+ static onReport(report) {
73
+ for (const diag of _Illuma._diagnostics) diag.onReport(report);
74
+ }
75
+ /**
76
+ * @internal
77
+ * Check if diagnostics modules are registered
78
+ */
79
+ static hasDiagnostics() {
80
+ return _Illuma._diagnostics.size > 0;
81
+ }
82
+ /**
83
+ * @internal
84
+ * Reset all plugin registrations
85
+ */
86
+ static __resetPlugins() {
87
+ _Illuma._diagnostics.clear();
88
+ _Illuma._scanners.length = 0;
89
+ _Illuma._middlewares.length = 0;
90
+ }
91
+ };
92
+ }
93
+ });
94
+
95
+ // src/lib/plugins/core/index.ts
96
+ var init_core = __esm({
97
+ "src/lib/plugins/core/index.ts"() {
98
+ "use strict";
99
+ init_plugin_container();
100
+ }
101
+ });
102
+
103
+ // src/lib/plugins/middlewares/diagnostics.middleware.ts
104
+ var performanceDiagnostics;
105
+ var init_diagnostics_middleware = __esm({
106
+ "src/lib/plugins/middlewares/diagnostics.middleware.ts"() {
107
+ "use strict";
108
+ performanceDiagnostics = /* @__PURE__ */ __name((params, next) => {
109
+ if (!params.deps.size) {
110
+ return next(params);
111
+ }
112
+ const start = performance.now();
113
+ const instance = next(params);
114
+ const end = performance.now();
115
+ const duration = end - start;
116
+ console.log(`Instantiated ${params.token.name} in ${duration.toFixed(2)} ms`);
117
+ return instance;
118
+ }, "performanceDiagnostics");
119
+ }
120
+ });
121
+
122
+ // src/lib/plugins/diagnostics/default-impl.ts
123
+ var DiagnosticsDefaultReporter;
124
+ var init_default_impl = __esm({
125
+ "src/lib/plugins/diagnostics/default-impl.ts"() {
126
+ "use strict";
127
+ DiagnosticsDefaultReporter = class {
128
+ static {
129
+ __name(this, "DiagnosticsDefaultReporter");
130
+ }
131
+ onReport(report) {
132
+ console.log("[Illuma] \u{1F9F9} Diagnostics:");
133
+ console.log(` Total: ${report.totalNodes} node(s)`);
134
+ console.log(` ${report.unusedNodes.length} were not used while bootstrap:`);
135
+ for (const node of report.unusedNodes) console.log(` - ${node.toString()}`);
136
+ }
137
+ };
138
+ }
139
+ });
140
+
141
+ // src/lib/plugins/diagnostics/built-in.ts
142
+ var built_in_exports = {};
143
+ __export(built_in_exports, {
144
+ __resetDiagnosticsState: () => __resetDiagnosticsState,
145
+ enableIllumaDiagnostics: () => enableIllumaDiagnostics
146
+ });
147
+ function enableIllumaDiagnostics() {
148
+ if (state.enabled) return;
149
+ state.enabled = true;
150
+ Illuma.extendDiagnostics(new DiagnosticsDefaultReporter());
151
+ Illuma.registerGlobalMiddleware(performanceDiagnostics);
152
+ }
153
+ function __resetDiagnosticsState() {
154
+ state.enabled = false;
155
+ }
156
+ var state;
157
+ var init_built_in = __esm({
158
+ "src/lib/plugins/diagnostics/built-in.ts"() {
159
+ "use strict";
160
+ init_core();
161
+ init_diagnostics_middleware();
162
+ init_default_impl();
163
+ state = {
164
+ enabled: false
165
+ };
166
+ __name(enableIllumaDiagnostics, "enableIllumaDiagnostics");
167
+ __name(__resetDiagnosticsState, "__resetDiagnosticsState");
168
+ }
169
+ });
170
+
21
171
  // src/testkit.ts
22
172
  var testkit_exports = {};
23
173
  __export(testkit_exports, {
@@ -219,56 +369,8 @@ function isConstructor(fn) {
219
369
  }
220
370
  __name(isConstructor, "isConstructor");
221
371
 
222
- // src/lib/plugins/core/plugin-container.ts
223
- var Illuma = class _Illuma {
224
- static {
225
- __name(this, "Illuma");
226
- }
227
- static _diagnostics = [];
228
- static _scanners = [];
229
- static _middlewares = [];
230
- /** @internal */
231
- static get contextScanners() {
232
- return _Illuma._scanners;
233
- }
234
- /**
235
- * Extends the diagnostics with a new diagnostics module.
236
- * These will be run on diagnostics reports after container bootstrap.
237
- *
238
- * @param m - The diagnostics module instance to add
239
- */
240
- static extendDiagnostics(m) {
241
- _Illuma._diagnostics.push(m);
242
- }
243
- /**
244
- * Extends the context scanners with a new context scanner.
245
- * These will be run in injection context scans to detect additional injections (alongside `nodeInject` calls).
246
- *
247
- * @param scanner - The context scanner instance to add
248
- */
249
- static extendContextScanner(scanner) {
250
- _Illuma._scanners.push(scanner);
251
- }
252
- /**
253
- * Registers a global middleware to be applied during instance creation.
254
- * Typically used for cross-cutting concerns like logging, profiling, or custom instantiation logic.
255
- * Function should accept instantiation parameters and a `next` function to proceed with the next middleware or actual instantiation.
256
- *
257
- * @param m - The middleware function to register
258
- */
259
- static registerGlobalMiddleware(m) {
260
- _Illuma._middlewares.push(m);
261
- }
262
- middlewares = [];
263
- registerMiddleware(m) {
264
- this.middlewares.push(m);
265
- }
266
- static onReport(report) {
267
- for (const diag of _Illuma._diagnostics) diag.onReport(report);
268
- }
269
- };
270
-
271
372
  // src/lib/context/context.ts
373
+ init_plugin_container();
272
374
  var InjectionContext = class _InjectionContext {
273
375
  static {
274
376
  __name(this, "InjectionContext");
@@ -368,18 +470,19 @@ function nodeInject(provider, options) {
368
470
  }
369
471
  __name(nodeInject, "nodeInject");
370
472
 
371
- // src/lib/plugins/diagnostics/default-impl.ts
372
- var DiagnosticsDefaultReporter = class {
373
- static {
374
- __name(this, "DiagnosticsDefaultReporter");
375
- }
376
- onReport(report) {
377
- console.log("[Illuma] \u{1F9F9} Diagnostics:");
378
- console.log(` Total: ${report.totalNodes} node(s)`);
379
- console.log(` ${report.unusedNodes.length} were not used while bootstrap:`);
380
- for (const node of report.unusedNodes) console.log(` - ${node.toString()}`);
381
- }
382
- };
473
+ // src/lib/container/container.ts
474
+ init_plugin_container();
475
+
476
+ // src/lib/plugins/middlewares/runner.ts
477
+ function runMiddlewares(middlewares, params) {
478
+ const ms = middlewares;
479
+ const next = /* @__PURE__ */ __name((i, current) => {
480
+ if (i >= ms.length) return current.factory();
481
+ return ms[i](current, (nextParams) => next(i + 1, nextParams));
482
+ }, "next");
483
+ return next(0, params);
484
+ }
485
+ __name(runMiddlewares, "runMiddlewares");
383
486
 
384
487
  // src/lib/provider/extractor.ts
385
488
  function extractProvider(provider) {
@@ -486,24 +589,15 @@ var InjectorImpl = class {
486
589
  var Injector = new NodeToken("Injector");
487
590
 
488
591
  // src/lib/provider/tree-node.ts
489
- function runMiddlewares(middlewares, params) {
490
- const ms = middlewares;
491
- const next = /* @__PURE__ */ __name((i, current) => {
492
- if (i >= ms.length) return current.factory();
493
- return ms[i](current, (nextParams) => next(i + 1, nextParams));
494
- }, "next");
495
- return next(0, params);
496
- }
497
- __name(runMiddlewares, "runMiddlewares");
498
592
  function retrieverFactory(node, deps, transparentDeps) {
499
593
  return (token, optional) => {
500
594
  const depNode = deps.get(token);
501
595
  if (!depNode && !optional) {
502
- const transparent = Array.from(transparentDeps).find((n) => "proto" in n && n.proto.parent.token === token);
596
+ const transparent = transparentDeps.get(token);
503
597
  if (transparent) return transparent.instance;
504
598
  throw InjectionError.untracked(token, node);
505
599
  }
506
- return depNode?.instance ?? null;
600
+ return depNode ? depNode.instance : null;
507
601
  };
508
602
  }
509
603
  __name(retrieverFactory, "retrieverFactory");
@@ -514,7 +608,7 @@ var TreeRootNode = class {
514
608
  instant;
515
609
  middlewares;
516
610
  _deps = /* @__PURE__ */ new Set();
517
- _treePool = /* @__PURE__ */ new WeakMap();
611
+ _treePool = /* @__PURE__ */ new Map();
518
612
  constructor(instant = true, middlewares = []) {
519
613
  this.instant = instant;
520
614
  this.middlewares = middlewares;
@@ -579,13 +673,21 @@ var TreeNodeSingle = class {
579
673
  if (this._resolved) return;
580
674
  for (const node of this._deps.values()) node.instantiate(pool, middlewares);
581
675
  for (const dep of this._transparent) dep.instantiate(pool, middlewares);
582
- const retriever = retrieverFactory(this.proto.token, this._deps, this._transparent);
676
+ const transparentMap = /* @__PURE__ */ new Map();
677
+ for (const tNode of this._transparent) {
678
+ transparentMap.set(tNode.proto.parent.token, tNode);
679
+ }
680
+ const retriever = retrieverFactory(this.proto.token, this._deps, transparentMap);
583
681
  const factory = this.proto.factory ?? this.proto.token.opts?.factory;
584
682
  if (!factory) throw InjectionError.notFound(this.proto.token);
585
683
  const contextFactory = /* @__PURE__ */ __name(() => InjectionContext.instantiate(factory, retriever), "contextFactory");
586
684
  this._instance = runMiddlewares(middlewares, {
587
685
  token: this.proto.token,
588
- factory: contextFactory
686
+ factory: contextFactory,
687
+ deps: /* @__PURE__ */ new Set([
688
+ ...this._deps.keys(),
689
+ ...Array.from(this._transparent).map((n) => n.proto.parent.token)
690
+ ])
589
691
  });
590
692
  this._resolved = true;
591
693
  if (pool) pool.set(this.proto.token, this);
@@ -624,11 +726,19 @@ var TreeNodeTransparent = class _TreeNodeTransparent {
624
726
  if (this._resolved) return;
625
727
  for (const dep of this._transparent) dep.instantiate(pool, middlewares);
626
728
  for (const node of this._deps.values()) node.instantiate(pool, middlewares);
627
- const retriever = retrieverFactory(this.proto.parent.token, this._deps, this._transparent);
729
+ const transparentMap = /* @__PURE__ */ new Map();
730
+ for (const tNode of this._transparent) {
731
+ transparentMap.set(tNode.proto.parent.token, tNode);
732
+ }
733
+ const retriever = retrieverFactory(this.proto.parent.token, this._deps, transparentMap);
628
734
  const refFactory = /* @__PURE__ */ __name(() => InjectionContext.instantiate(this.proto.factory, retriever), "refFactory");
629
735
  this._instance = runMiddlewares(middlewares, {
630
736
  token: this.proto.parent.token,
631
- factory: refFactory
737
+ factory: refFactory,
738
+ deps: /* @__PURE__ */ new Set([
739
+ ...this._deps.keys(),
740
+ ...Array.from(this._transparent).map((n) => n.proto.parent.token)
741
+ ])
632
742
  });
633
743
  this._resolved = true;
634
744
  }
@@ -823,10 +933,13 @@ var NodeContainer = class extends Illuma {
823
933
  _multiProtoNodes = /* @__PURE__ */ new Map();
824
934
  constructor(_opts) {
825
935
  super(), this._opts = _opts;
826
- this._parent = _opts?.parent;
827
936
  if (_opts?.diagnostics) {
828
- Illuma.extendDiagnostics(new DiagnosticsDefaultReporter());
937
+ console.warn("[Illuma] Deprecation Warning: The 'diagnostics' option in iContainerOptions is deprecated and will be removed in future versions. Please use the `enableIllumaDiagnostics` from '@illuma/core/plugins` instead.");
938
+ const m = (init_built_in(), __toCommonJS(built_in_exports));
939
+ if (m.enabled) return;
940
+ m.enableIllumaDiagnostics();
829
941
  }
942
+ this._parent = _opts?.parent;
830
943
  }
831
944
  /**
832
945
  * Registers a provider in the container.
@@ -1001,7 +1114,7 @@ var NodeContainer = class extends Illuma {
1001
1114
  if (this._opts?.measurePerformance) {
1002
1115
  console.log(`[Illuma] \u{1F680} Bootstrapped in ${duration.toFixed(2)} ms`);
1003
1116
  }
1004
- if (this._opts?.diagnostics) {
1117
+ if (this._opts?.diagnostics || Illuma.hasDiagnostics()) {
1005
1118
  const allNodes = this._rootNode.dependencies.size;
1006
1119
  const unusedNodes = Array.from(this._rootNode.dependencies).filter((node) => node.allocations === 0).filter((node) => {
1007
1120
  if (!(node.proto instanceof ProtoNodeSingle)) return true;
@@ -1054,12 +1167,33 @@ var NodeContainer = class extends Illuma {
1054
1167
  if (isConstructor(fn) && !isInjectable(fn)) {
1055
1168
  throw InjectionError.invalidCtor(fn);
1056
1169
  }
1057
- const factory = isInjectable(fn) ? () => new fn() : fn;
1058
- return InjectionContext.instantiate(factory, (t, optional) => {
1059
- if (!this._rootNode) throw InjectionError.notBootstrapped();
1060
- const node = this._rootNode.find(t);
1061
- if (!node && !optional) throw InjectionError.notFound(t);
1170
+ let factory;
1171
+ if (isInjectable(fn)) {
1172
+ const f = getInjectableToken(fn).opts?.factory;
1173
+ if (!f) factory = /* @__PURE__ */ __name(() => new fn(), "factory");
1174
+ else factory = /* @__PURE__ */ __name(() => getInjectableToken(fn).opts?.factory?.(), "factory");
1175
+ } else {
1176
+ factory = fn;
1177
+ }
1178
+ const rootNode = this._rootNode;
1179
+ if (!rootNode) throw InjectionError.notBootstrapped();
1180
+ const retriever = /* @__PURE__ */ __name((token, optional) => {
1181
+ const node = rootNode.find(token);
1182
+ if (!node && !optional) throw InjectionError.notFound(token);
1062
1183
  return node ? node.instance : null;
1184
+ }, "retriever");
1185
+ const deps = InjectionContext.scan(factory);
1186
+ const middlewares = [
1187
+ ...Illuma._middlewares,
1188
+ ...this.collectMiddlewares()
1189
+ ];
1190
+ const contextFactory = /* @__PURE__ */ __name(() => InjectionContext.instantiate(factory, retriever), "contextFactory");
1191
+ return runMiddlewares(middlewares, {
1192
+ token: new NodeToken("ProducedNode"),
1193
+ deps: new Set([
1194
+ ...deps.values()
1195
+ ].map((d) => d.token)),
1196
+ factory: contextFactory
1063
1197
  });
1064
1198
  }
1065
1199
  };