@adimm/x-injection 0.8.0 → 1.1.6

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/index.cjs CHANGED
@@ -1,50 +1,51 @@
1
1
  "use strict";
2
2
 
3
- var e, i = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Object.getOwnPropertyNames, r = Object.prototype.hasOwnProperty, o = (e, t) => i(e, "name", {
4
- value: t,
3
+ var e, t = Object.defineProperty, i = Object.getOwnPropertyDescriptor, n = Object.getOwnPropertyNames, o = Object.prototype.hasOwnProperty, r = (e, i) => t(e, "name", {
4
+ value: i,
5
5
  configurable: !0
6
6
  }), s = {};
7
7
 
8
- ((e, t) => {
9
- for (var n in t) i(e, n, {
10
- get: t[n],
8
+ ((e, i) => {
9
+ for (var n in i) t(e, n, {
10
+ get: i[n],
11
11
  enumerable: !0
12
12
  });
13
13
  })(s, {
14
14
  AppModule: () => H,
15
15
  GLOBAL_APP_MODULE_ID: () => d,
16
16
  GlobalAppModule: () => $,
17
- GlobalContainer: () => q,
18
- Inject: () => E,
19
- InjectFromBase: () => w,
20
- Injectable: () => I,
21
- InjectionError: () => G,
22
- InjectionProviderModuleDisposedError: () => O,
17
+ GlobalContainer: () => N,
18
+ Inject: () => T,
19
+ InjectFromBase: () => _,
20
+ Injectable: () => m,
21
+ InjectionError: () => B,
22
+ InjectionProviderModuleDisposedError: () => F,
23
23
  InjectionProviderModuleError: () => x,
24
24
  InjectionProviderModuleGlobalMarkError: () => U,
25
- InjectionProviderModuleMissingIdentifierError: () => F,
25
+ InjectionProviderModuleMissingIdentifierError: () => q,
26
26
  InjectionScope: () => c,
27
- MultiInject: () => T,
28
- Named: () => P,
29
- Optional: () => B,
30
- ProviderModule: () => W,
31
- ProviderModuleHelpers: () => f,
32
- ProviderTokenHelpers: () => h,
33
- Tagged: () => D,
34
- Unmanaged: () => R,
27
+ MultiInject: () => k,
28
+ Named: () => j,
29
+ Optional: () => P,
30
+ ProviderModule: () => z,
31
+ ProviderModuleDefinition: () => I,
32
+ ProviderModuleHelpers: () => y,
33
+ ProviderTokenHelpers: () => f,
34
+ Tagged: () => C,
35
+ Unmanaged: () => G,
35
36
  bindingScopeToInjectionScope: () => l,
36
37
  injectionScopeToBindingScope: () => u,
37
- isClass: () => v,
38
- isClassOrFunction: () => g,
38
+ isClass: () => p,
39
+ isClassOrFunction: () => v,
39
40
  isFunction: () => S,
40
- isPlainObject: () => m
41
- }), module.exports = (e = s, ((e, o, s, d) => {
42
- if (o && "object" == typeof o || "function" == typeof o) for (let a of n(o)) r.call(e, a) || a === s || i(e, a, {
43
- get: () => o[a],
44
- enumerable: !(d = t(o, a)) || d.enumerable
41
+ isPlainObject: () => b
42
+ }), module.exports = (e = s, ((e, r, s, d) => {
43
+ if (r && "object" == typeof r || "function" == typeof r) for (let a of n(r)) o.call(e, a) || a === s || t(e, a, {
44
+ get: () => r[a],
45
+ enumerable: !(d = i(r, a)) || d.enumerable
45
46
  });
46
47
  return e;
47
- })(i({}, "__esModule", {
48
+ })(t({}, "__esModule", {
48
49
  value: !0
49
50
  }), e));
50
51
 
@@ -79,15 +80,15 @@ function l(e) {
79
80
  }
80
81
  }
81
82
 
82
- o(u, "injectionScopeToBindingScope"), o(l, "bindingScopeToInjectionScope");
83
+ r(u, "injectionScopeToBindingScope"), r(l, "bindingScopeToInjectionScope");
83
84
 
84
- var h, f, p = require("@inversifyjs/core");
85
+ var f, h = require("@inversifyjs/core");
85
86
 
86
- function v(e) {
87
+ function p(e) {
87
88
  return "function" == typeof e && Function.prototype.toString.call(e).startsWith("class ");
88
89
  }
89
90
 
90
- function g(e) {
91
+ function v(e) {
91
92
  return "function" == typeof e;
92
93
  }
93
94
 
@@ -95,173 +96,237 @@ function S(e) {
95
96
  return "function" == typeof e && !Function.prototype.toString.call(e).startsWith("class ");
96
97
  }
97
98
 
98
- function b(e) {
99
+ function g(e) {
99
100
  return "[object Object]" === Object.prototype.toString.call(e);
100
101
  }
101
102
 
102
- function m(e) {
103
- if (!1 === b(e)) return !1;
104
- const i = e.constructor;
105
- if (void 0 === i) return !0;
106
- const t = i.prototype;
107
- return !1 !== b(t) && !1 !== t.hasOwnProperty("isPrototypeOf");
108
- }
109
-
110
- function I(e) {
111
- return void 0 === e ? (0, a.injectable)() : (0, a.injectable)(u(e));
103
+ function b(e) {
104
+ if (!1 === g(e)) return !1;
105
+ const t = e.constructor;
106
+ if (void 0 === t) return !0;
107
+ const i = t.prototype;
108
+ return !1 !== g(i) && !1 !== i.hasOwnProperty("isPrototypeOf");
112
109
  }
113
110
 
114
- o(v, "isClass"), o(g, "isClassOrFunction"), o(S, "isFunction"), o(b, "isObject"),
115
- o(m, "isPlainObject"), function(e) {
116
- function i(e) {
117
- return b(e) && "useClass" in e;
118
- }
111
+ r(p, "isClass"), r(v, "isClassOrFunction"), r(S, "isFunction"), r(g, "isObject"),
112
+ r(b, "isPlainObject"), function(e) {
119
113
  function t(e) {
120
- return b(e) && "useValue" in e;
114
+ return y(e) && "useClass" in e;
115
+ }
116
+ function i(e) {
117
+ return y(e) && "useValue" in e;
121
118
  }
122
119
  function n(e) {
123
- return b(e) && "useFactory" in e;
120
+ return y(e) && "useFactory" in e;
124
121
  }
125
- function r(e) {
126
- return "string" == typeof e || "symbol" == typeof e || g(e);
122
+ function o(e) {
123
+ return "string" == typeof e || "symbol" == typeof e || v(e);
127
124
  }
128
125
  function s(e) {
129
- return r(e) ? e : e.provide;
126
+ return o(e) ? e : e.provide;
130
127
  }
131
128
  function d(e) {
132
129
  return e.map((e => s(e)));
133
130
  }
134
- function a(e, i) {
135
- return v(e) ? {
136
- ...i,
137
- provide: i?.provide ?? e,
138
- useClass: i?.useClass ?? e
131
+ function a(e, t) {
132
+ return p(e) ? {
133
+ ...t,
134
+ provide: t?.provide ?? e,
135
+ useClass: t?.useClass ?? e
139
136
  } : S(e) ? {
140
- ...i,
141
- provide: i?.provide ?? e,
142
- useFactory: i?.useFactory ?? e
137
+ ...t,
138
+ provide: t?.provide ?? e,
139
+ useFactory: t?.useFactory ?? e
143
140
  } : {
144
141
  ...e,
145
- ...i
142
+ ...t
146
143
  };
147
144
  }
148
- function c(e, i) {
149
- return h(e) ?? f(e) ?? i;
145
+ function c(e, t) {
146
+ return f(e) ?? g(e) ?? t;
150
147
  }
151
148
  function u(e) {
152
- if (b(e)) return e;
153
- }
154
- function h(e) {
155
- const i = u(e);
156
- if (i) return i.scope;
149
+ if (y(e)) return e;
157
150
  }
158
151
  function f(e) {
159
- const i = s(e);
160
- if (!v(i)) return;
161
- const t = (0, p.getClassMetadata)(i)?.scope;
162
- return t ? l(t) : void 0;
163
- }
164
- function b(e) {
165
- return m(e) && "object" == typeof e && "provide" in e;
166
- }
167
- o(i, "isClassToken"), e.isClassToken = i, o(t, "isValueToken"), e.isValueToken = t,
168
- o(n, "isFactoryToken"), e.isFactoryToken = n, o(r, "isProviderIdentifier"), e.isProviderIdentifier = r,
169
- o(s, "toServiceIdentifier"), e.toServiceIdentifier = s, o(d, "toServiceIdentifiers"),
170
- e.toServiceIdentifiers = d, o(a, "toDependencyProviderWithOptions"), e.toDependencyProviderWithOptions = a,
171
- o(c, "getInjectionScopeByPriority"), e.getInjectionScopeByPriority = c, o(u, "tryGetProviderOptions"),
172
- e.tryGetProviderOptions = u, o(h, "tryGetScopeFromProvider"), e.tryGetScopeFromProvider = h,
173
- o(f, "tryGetDecoratorScopeFromClass"), e.tryGetDecoratorScopeFromClass = f, o(b, "hasProvideProperty");
174
- }(h || (h = {})), function(e) {
175
- function i(e) {
176
- return e;
152
+ const t = u(e);
153
+ if (t) return t.scope;
154
+ }
155
+ function g(e) {
156
+ const t = s(e);
157
+ if (!p(t)) return;
158
+ const i = (0, h.getClassMetadata)(t)?.scope;
159
+ return i ? l(i) : void 0;
160
+ }
161
+ function y(e) {
162
+ return b(e) && "object" == typeof e && "provide" in e;
163
+ }
164
+ r(t, "isClassToken"), e.isClassToken = t, r(i, "isValueToken"), e.isValueToken = i,
165
+ r(n, "isFactoryToken"), e.isFactoryToken = n, r(o, "isProviderIdentifier"), e.isProviderIdentifier = o,
166
+ r(s, "toServiceIdentifier"), e.toServiceIdentifier = s, r(d, "toServiceIdentifiers"),
167
+ e.toServiceIdentifiers = d, r(a, "toDependencyProviderWithOptions"), e.toDependencyProviderWithOptions = a,
168
+ r(c, "getInjectionScopeByPriority"), e.getInjectionScopeByPriority = c, r(u, "tryGetProviderOptions"),
169
+ e.tryGetProviderOptions = u, r(f, "tryGetScopeFromProvider"), e.tryGetScopeFromProvider = f,
170
+ r(g, "tryGetDecoratorScopeFromClass"), e.tryGetDecoratorScopeFromClass = g, r(y, "hasProvideProperty");
171
+ }(f || (f = {}));
172
+
173
+ var y, I = class {
174
+ static {
175
+ r(this, "ProviderModuleDefinition");
176
+ }
177
+ identifier;
178
+ imports;
179
+ providers;
180
+ exports;
181
+ defaultScope;
182
+ markAsGlobal;
183
+ onReady;
184
+ onDispose;
185
+ constructor(e) {
186
+ const {identifier: t, imports: i, providers: n, exports: o, defaultScope: r, markAsGlobal: s, onReady: d, onDispose: a} = e;
187
+ this.identifier = t, this.imports = i, this.providers = n, this.exports = o, this.defaultScope = r ?? c.Singleton,
188
+ this.markAsGlobal = s ?? !1, this.onReady = d, this.onDispose = a;
177
189
  }
190
+ getDefinition() {
191
+ return {
192
+ identifier: this.identifier,
193
+ imports: this.imports,
194
+ providers: this.providers,
195
+ exports: this.exports,
196
+ defaultScope: this.defaultScope,
197
+ markAsGlobal: this.markAsGlobal,
198
+ onReady: this.onReady,
199
+ onDispose: this.onDispose
200
+ };
201
+ }
202
+ toString() {
203
+ return ("symbol" == typeof this.identifier ? this.identifier.description : this.identifier) ?? "Unknown";
204
+ }
205
+ };
206
+
207
+ function m(e) {
208
+ return void 0 === e ? (0, a.injectable)() : (0, a.injectable)(u(e));
209
+ }
210
+
211
+ !function(e) {
178
212
  function t(e) {
179
- return !Array.isArray(e) && "function" == typeof e;
213
+ return e;
214
+ }
215
+ function i(e) {
216
+ const {identifier: t, imports: i, providers: o, exports: r, defaultScope: s, markAsGlobal: d, onReady: a, onDispose: c, ...u} = e, l = u;
217
+ if (n(e)) {
218
+ const e = u;
219
+ delete e.getDefinition, delete e.toString;
220
+ }
221
+ return {
222
+ options: {
223
+ identifier: t,
224
+ imports: i,
225
+ providers: o,
226
+ exports: r,
227
+ defaultScope: s,
228
+ markAsGlobal: d,
229
+ onReady: a,
230
+ onDispose: c
231
+ },
232
+ internalOptions: l
233
+ };
180
234
  }
181
- o(i, "buildInternalConstructorParams"), e.buildInternalConstructorParams = i, o(t, "isDynamicExport"),
182
- e.isDynamicExport = t;
183
- }(f || (f = {})), o(I, "Injectable");
235
+ function n(e) {
236
+ return e instanceof I;
237
+ }
238
+ function o(e) {
239
+ return S(e);
240
+ }
241
+ function s(e, t) {
242
+ return o(t) ? t(e) : t;
243
+ }
244
+ r(t, "buildInternalConstructorParams"), e.buildInternalConstructorParams = t, r(i, "getOptionsOrModuleDefinitionOptions"),
245
+ e.getOptionsOrModuleDefinitionOptions = i, r(n, "isModuleDefinition"), e.isModuleDefinition = n,
246
+ r(o, "isLazyExport"), e.isLazyExport = o, r(s, "tryStaticOrLazyExportToStaticExport"),
247
+ e.tryStaticOrLazyExportToStaticExport = s;
248
+ }(y || (y = {})), r(m, "Injectable");
184
249
 
185
- var y = require("inversify");
250
+ var E = require("inversify");
186
251
 
187
- function E(e) {
188
- return (0, y.inject)(h.toServiceIdentifier(e));
252
+ function T(e) {
253
+ return (0, E.inject)(f.toServiceIdentifier(e));
189
254
  }
190
255
 
191
- o(E, "Inject");
256
+ r(T, "Inject");
192
257
 
193
258
  var M = require("inversify");
194
259
 
195
- function T(e) {
196
- return (0, M.multiInject)(h.toServiceIdentifier(e));
260
+ function k(e) {
261
+ return (0, M.multiInject)(f.toServiceIdentifier(e));
197
262
  }
198
263
 
199
- o(T, "MultiInject");
264
+ r(k, "MultiInject");
200
265
 
201
- var k = require("inversify");
266
+ var w = require("inversify");
202
267
 
203
- function w(e) {
204
- return (0, k.injectFromBase)(e);
268
+ function _(e) {
269
+ return (0, w.injectFromBase)(e);
205
270
  }
206
271
 
207
- o(w, "InjectFromBase");
272
+ r(_, "InjectFromBase");
208
273
 
209
- var _ = require("inversify");
274
+ var D = require("inversify");
210
275
 
211
- function P(e) {
212
- return (0, _.named)(e);
276
+ function j(e) {
277
+ return (0, D.named)(e);
213
278
  }
214
279
 
215
- o(P, "Named");
280
+ r(j, "Named");
216
281
 
217
- var j = require("inversify");
282
+ var O = require("inversify");
218
283
 
219
- function B() {
220
- return (0, j.optional)();
284
+ function P() {
285
+ return (0, O.optional)();
221
286
  }
222
287
 
223
- o(B, "Optional");
288
+ r(P, "Optional");
224
289
 
225
290
  var A = require("inversify");
226
291
 
227
- function D(e, i) {
228
- return (0, A.tagged)(e, i);
292
+ function C(e, t) {
293
+ return (0, A.tagged)(e, t);
229
294
  }
230
295
 
231
- o(D, "Tagged");
296
+ r(C, "Tagged");
232
297
 
233
- var C = require("inversify");
298
+ var R = require("inversify");
234
299
 
235
- function R() {
236
- return (0, C.unmanaged)();
300
+ function G() {
301
+ return (0, R.unmanaged)();
237
302
  }
238
303
 
239
- o(R, "Unmanaged");
304
+ r(G, "Unmanaged");
240
305
 
241
- var G = class e extends Error {
306
+ var B = class e extends Error {
242
307
  static {
243
- o(this, "InjectionError");
308
+ r(this, "InjectionError");
244
309
  }
245
310
  name=e.name;
246
311
  }, x = class e extends Error {
247
312
  static {
248
- o(this, "InjectionProviderModuleError");
313
+ r(this, "InjectionProviderModuleError");
249
314
  }
250
315
  name=e.name;
251
- constructor(e, i) {
252
- super(`{ProviderModule.${e.toString()}} => ${i}`);
316
+ constructor(e, t) {
317
+ super(`{ProviderModule.${e.toString()}} => ${t}`);
253
318
  }
254
- }, O = class e extends x {
319
+ }, F = class e extends x {
255
320
  static {
256
- o(this, "InjectionProviderModuleDisposedError");
321
+ r(this, "InjectionProviderModuleDisposedError");
257
322
  }
258
323
  name=e.name;
259
324
  constructor(e) {
260
- super(e, "Has been disposed! You can re-initialize it by using the `_lazyInit` method.");
325
+ super(e, "Has been disposed! You can re-initialize it by using the `_internalInit` method.");
261
326
  }
262
- }, F = class e extends x {
327
+ }, q = class e extends x {
263
328
  static {
264
- o(this, "InjectionProviderModuleMissingIdentifierError");
329
+ r(this, "InjectionProviderModuleMissingIdentifierError");
265
330
  }
266
331
  name=e.name;
267
332
  constructor(e) {
@@ -269,17 +334,17 @@ var G = class e extends Error {
269
334
  }
270
335
  }, U = class e extends x {
271
336
  static {
272
- o(this, "InjectionProviderModuleGlobalMarkError");
337
+ r(this, "InjectionProviderModuleGlobalMarkError");
273
338
  }
274
339
  name=e.name;
275
- constructor(e, i) {
276
- super(e, i);
340
+ constructor(e, t) {
341
+ super(e, t);
277
342
  }
278
- }, q = new (require("inversify").Container)({
343
+ }, N = new (require("inversify").Container)({
279
344
  defaultScope: "Singleton"
280
- }), N = require("inversify"), V = class {
345
+ }), L = require("inversify"), V = class {
281
346
  static {
282
- o(this, "ProviderModuleUtils");
347
+ r(this, "ProviderModuleUtils");
283
348
  }
284
349
  get container() {
285
350
  return this.moduleNaked.container;
@@ -287,158 +352,135 @@ var G = class e extends Error {
287
352
  module;
288
353
  moduleNaked;
289
354
  appModule=H;
290
- constructor(e, i) {
291
- this.module = e, this.moduleNaked = e.toNaked(), this.appModule = i.appModule?.() ?? this.appModule,
355
+ constructor(e, t) {
356
+ this.module = e, this.moduleNaked = e.toNaked(), this.appModule = t.appModule?.() ?? this.appModule,
292
357
  this.checkIfShouldBeAddedToTheGlobalRegister();
293
358
  }
294
- bindToContainer(e, i) {
295
- return h.isProviderIdentifier(e) ? this.bindSelfTokenToContainer(e, i) : h.isClassToken(e) ? this.bindClassTokenToContainer(e, i) : h.isValueToken(e) ? this.bindValueTokenToContainer(e) : !!h.isFactoryToken(e) && this.bindFactoryTokenToContainer(e, i);
359
+ bindToContainer(e, t) {
360
+ return f.isProviderIdentifier(e) ? this.bindSelfTokenToContainer(e, t) : f.isClassToken(e) ? this.bindClassTokenToContainer(e, t) : f.isValueToken(e) ? this.bindValueTokenToContainer(e) : !!f.isFactoryToken(e) && this.bindFactoryTokenToContainer(e, t);
296
361
  }
297
362
  checkIfShouldBeAddedToTheGlobalRegister() {
298
- !this.moduleNaked.isAppModule && this.module.isMarkedAsGlobal && L.add(this.module);
363
+ !this.moduleNaked.isAppModule && this.module.isMarkedAsGlobal && W.add(this.module);
299
364
  }
300
- bindSelfTokenToContainer(e, i) {
301
- return this.setBindingScope(e, this.container.bind(h.toServiceIdentifier(e)).toSelf(), i),
365
+ bindSelfTokenToContainer(e, t) {
366
+ return this.setBindingScope(e, this.container.bind(f.toServiceIdentifier(e)).toSelf(), t),
302
367
  this.moduleNaked.__isCurrentBound(e);
303
368
  }
304
- bindClassTokenToContainer(e, i) {
305
- return this.setBindingOnEvent(e, this.setWhenBinding(e, this.setBindingScope(e, this.container.bind(h.toServiceIdentifier(e)).to(e.useClass), i))),
369
+ bindClassTokenToContainer(e, t) {
370
+ return this.setBindingOnEvent(e, this.setWhenBinding(e, this.setBindingScope(e, this.container.bind(f.toServiceIdentifier(e)).to(e.useClass), t))),
306
371
  this.moduleNaked.__isCurrentBound(e);
307
372
  }
308
373
  bindValueTokenToContainer(e) {
309
- return this.setBindingOnEvent(e, this.setWhenBinding(e, this.container.bind(h.toServiceIdentifier(e)).toConstantValue(e.useValue))),
374
+ return this.setBindingOnEvent(e, this.setWhenBinding(e, this.container.bind(f.toServiceIdentifier(e)).toConstantValue(e.useValue))),
310
375
  this.moduleNaked.__isCurrentBound(e);
311
376
  }
312
- bindFactoryTokenToContainer(e, i) {
313
- return this.setBindingOnEvent(e, this.setWhenBinding(e, this.setBindingScope(e, this.container.bind(h.toServiceIdentifier(e)).toResolvedValue(e.useFactory, h.toServiceIdentifiers(e.inject ?? [])), i))),
377
+ bindFactoryTokenToContainer(e, t) {
378
+ return this.setBindingOnEvent(e, this.setWhenBinding(e, this.setBindingScope(e, this.container.bind(f.toServiceIdentifier(e)).toResolvedValue(e.useFactory, f.toServiceIdentifiers(e.inject ?? [])), t))),
314
379
  this.moduleNaked.__isCurrentBound(e);
315
380
  }
316
- setBindingScope(e, i, t) {
317
- if (h.isValueToken(e)) return i;
318
- switch (h.getInjectionScopeByPriority(e, t)) {
381
+ setBindingScope(e, t, i) {
382
+ if (f.isValueToken(e)) return t;
383
+ switch (f.getInjectionScopeByPriority(e, i)) {
319
384
  case c.Singleton:
320
- return i.inSingletonScope();
385
+ return t.inSingletonScope();
321
386
 
322
387
  case c.Transient:
323
- return i.inTransientScope();
388
+ return t.inTransientScope();
324
389
 
325
390
  case c.Request:
326
- return i.inRequestScope();
391
+ return t.inRequestScope();
327
392
  }
328
393
  }
329
- setWhenBinding(e, i) {
330
- if (h.isProviderIdentifier(e)) return i;
331
- const t = e.when;
332
- return t ? i.when(t) : i;
394
+ setWhenBinding(e, t) {
395
+ if (f.isProviderIdentifier(e)) return t;
396
+ const i = e.when;
397
+ return i ? t.when(i) : t;
333
398
  }
334
- setBindingOnEvent(e, i) {
335
- if (h.isProviderIdentifier(e)) return;
336
- const t = e;
337
- t.onEvent?.activation && i.onActivation(t.onEvent.activation), t.onEvent?.deactivation && i.onDeactivation(t.onEvent.deactivation);
399
+ setBindingOnEvent(e, t) {
400
+ if (f.isProviderIdentifier(e)) return;
401
+ const i = e;
402
+ i.onEvent?.activation && t.onActivation(i.onEvent.activation), i.onEvent?.deactivation && t.onDeactivation(i.onEvent.deactivation);
338
403
  }
339
- }, W = class e {
404
+ }, z = class e {
340
405
  static {
341
- o(this, "ProviderModule");
406
+ r(this, "ProviderModule");
342
407
  }
408
+ isDisposed=!1;
343
409
  identifier;
344
410
  isMarkedAsGlobal=!1;
345
- isDisposed=!1;
346
411
  isAppModule;
347
412
  container;
348
413
  defaultScope;
349
- dynamicExports;
350
414
  onReady;
351
415
  onDispose;
352
- importedProvidersMap;
353
416
  moduleUtils;
354
417
  imports;
355
418
  providers;
356
- importedProviders;
357
419
  exports;
358
420
  registeredSideEffects;
359
- constructor({identifier: e, imports: i, providers: t, exports: n, defaultScope: r, markAsGlobal: o, dynamicExports: s, onReady: d, onDispose: a, ...c}) {
360
- const u = c;
361
- this.identifier = this.setIdentifier(e), this.isDisposed = u.isDisposed ?? !1, this.isAppModule = u.isAppModule ?? !1,
362
- this.isAppModule || this._lazyInit({
363
- markAsGlobal: o,
364
- imports: i,
365
- providers: t,
366
- exports: n,
367
- defaultScope: r,
368
- dynamicExports: s,
369
- onReady: d,
370
- onDispose: a,
371
- ...c
421
+ constructor(e) {
422
+ const {options: t, internalOptions: i} = y.getOptionsOrModuleDefinitionOptions(e);
423
+ this.identifier = this.setIdentifier(t.identifier), this.isDisposed = i.isDisposed ?? !1,
424
+ this.isAppModule = i.isAppModule ?? !1, this.isAppModule || this._internalInit({
425
+ ...t,
426
+ ...i
372
427
  });
373
428
  }
374
- get(e, i) {
429
+ get(e, t) {
375
430
  return this.__get(e, {
376
- optional: i ?? !1
431
+ optional: t ?? !1
377
432
  });
378
433
  }
379
434
  getMany(...e) {
380
435
  return e.map((e => {
381
- const i = m(e) && "provider" in e;
382
- return this.get(i ? e.provider : e, !!i && e.isOptional);
436
+ const t = b(e) && "provider" in e;
437
+ return this.get(t ? e.provider : e, !!t && e.isOptional);
383
438
  }));
384
439
  }
440
+ lazyImport(...e) {
441
+ this.injectImportedModules(e);
442
+ }
385
443
  toNaked() {
386
444
  return this;
387
445
  }
388
- clone(i) {
389
- const t = i, n = new e(f.buildInternalConstructorParams({
390
- isAppModule: this.isAppModule,
391
- markAsGlobal: this.isMarkedAsGlobal,
392
- identifier: this.identifier,
393
- defaultScope: this.defaultScope.native,
394
- dynamicExports: this.dynamicExports,
395
- onReady: this.onReady,
396
- onDispose: this.onDispose,
397
- importedProvidersMap: this.importedProvidersMap,
398
- imports: [ ...this.imports ],
399
- providers: [ ...this.providers ],
400
- exports: [ ...this.exports ],
401
- ...t
402
- }));
403
- return n.registeredSideEffects = new Map(this.registeredSideEffects), n;
404
- }
405
446
  async dispose() {
406
- await (this.onDispose?.(this)), await this.__unbindAll(), this.container = null,
407
- this.imports = null, this.providers = null, this.importedProviders = null, this.exports = null,
408
- this.dynamicExports = null, this.registeredSideEffects = null, this.isDisposed = !0;
447
+ const {before: e, after: t} = this.onDispose?.() ?? {};
448
+ await (e?.(this)), await this.__unbindAll(), this.container = null, this.imports = null,
449
+ this.providers = null, this.exports = null, this.registeredSideEffects = null, this.isDisposed = !0,
450
+ await (t?.(this));
409
451
  }
410
452
  toString() {
411
- return this.identifier?.description ?? "Unknown";
453
+ return ("symbol" == typeof this.identifier ? this.identifier.description : this.identifier) ?? "Unknown";
412
454
  }
413
455
  setIdentifier(e) {
414
- if (!e) throw new F(this);
456
+ if (!e) throw new q(this);
415
457
  return e;
416
458
  }
417
459
  prepareContainer(e) {
418
- return this.isAppModule ? e.container?.() ?? q : e.container ? (console.warn(`[xInjection]: The '${this.toString()}' module is using a dynamic container!`),
419
- e.container()) : new N.Container({
420
- parent: q,
460
+ return this.isAppModule ? e.container?.() ?? N : e.container ? (console.warn(`[xInjection]: The '${this.toString()}' module is overwriting its container!`),
461
+ e.container()) : new L.Container({
462
+ parent: N,
421
463
  defaultScope: this.defaultScope.inversify
422
464
  });
423
465
  }
424
- injectImportedModules(i) {
425
- i && 0 !== i.length && i.forEach((i => {
426
- if ("GlobalAppModule" === i.toString()) throw new x(this, "The 'GlobalAppModule' can't be imported!");
427
- const t = (i = "function" == typeof i ? i() : i)._getExportableModulesAndProviders(), n = i.dynamicExports?.(this, t);
428
- (n ?? t).forEach((t => {
429
- if (t instanceof e) {
430
- const e = t.toNaked();
431
- return void this.injectImportedModules([ e ]);
432
- }
433
- const n = t, r = h.toServiceIdentifier(n), s = this.importedProvidersMap({
434
- scope: h.getInjectionScopeByPriority(n, i.defaultScope.native),
435
- provide: r,
436
- useFactory: o((() => i.get(n)), "useFactory")
437
- }, n, i);
438
- this.importedProviders.set(i, [ ...this.importedProviders.get(i) ?? [], s ]), this.moduleUtils.bindToContainer(s, i.defaultScope.native);
439
- const d = i;
440
- d.onUnbindInternal(n, this.identifier, (() => this.__unbind(s))), this._onUnbind(s, (() => {
441
- this.removeOnUnbindEffectsFromImportedModule(r, d);
466
+ injectImportedModules(t) {
467
+ t && 0 !== t.length && t.forEach((t => {
468
+ if ("GlobalAppModule" === t.toString()) throw new x(this, "The 'GlobalAppModule' can't be imported!");
469
+ const i = y.isModuleDefinition(t) ? new e(t.getDefinition()) : t;
470
+ i.exports.forEach((t => {
471
+ const n = y.tryStaticOrLazyExportToStaticExport(this, t);
472
+ if (!n) return;
473
+ if (n instanceof e) return void this.injectImportedModules([ n ]);
474
+ const o = n, s = f.toServiceIdentifier(o), d = {
475
+ scope: f.getInjectionScopeByPriority(o, i.defaultScope.native),
476
+ provide: s,
477
+ useFactory: r((() => i.get(o)), "useFactory")
478
+ };
479
+ this.moduleUtils.bindToContainer(d, i.defaultScope.native), i.registerSideEffect(o, "unbind", (() => this.__unbind(d)), {
480
+ registerModuleId: this.identifier
481
+ }), this._onUnbind(s, (() => {
482
+ const e = i.registeredSideEffects.get(s);
483
+ e && (e.onUnbindEffects = e.onUnbindEffects.filter((e => e.registerModuleId !== this.identifier)));
442
484
  }));
443
485
  }));
444
486
  }));
@@ -446,118 +488,101 @@ var G = class e extends Error {
446
488
  injectProviders() {
447
489
  this.providers.forEach((e => this.moduleUtils.bindToContainer(e, this.defaultScope.native)));
448
490
  }
449
- onUnbindInternal(e, i, t) {
450
- this.shouldThrowIfDisposed(), this.registerBindingSideEffect(e, "unbind", t, {
451
- registerModule: i
452
- });
453
- }
454
- registerBindingSideEffect(e, i, t, n) {
455
- const r = h.toServiceIdentifier(e);
456
- this.registeredSideEffects.has(r) || this.registeredSideEffects.set(r, {
491
+ registerSideEffect(e, t, i, n) {
492
+ const o = f.toServiceIdentifier(e);
493
+ this.registeredSideEffects.has(o) || this.registeredSideEffects.set(o, {
457
494
  onBindEffects: [],
458
495
  onGetEffects: [],
459
496
  onRebindEffects: [],
460
497
  onUnbindEffects: []
461
498
  });
462
- const o = this.registeredSideEffects.get(r);
463
- "bind" === i ? o.onBindEffects.push(t) : "get" === i ? o.onGetEffects.push({
499
+ const r = this.registeredSideEffects.get(o);
500
+ "bind" === t ? r.onBindEffects.push(i) : "get" === t ? r.onGetEffects.push({
464
501
  once: n.once,
465
502
  invoked: !1,
466
- cb: t
467
- }) : "rebind" === i ? o.onRebindEffects.push(t) : "unbind" === i && o.onUnbindEffects.push({
468
- registerModule: n?.registerModule,
469
- cb: t
503
+ cb: i
504
+ }) : "rebind" === t ? r.onRebindEffects.push(i) : "unbind" === t && r.onUnbindEffects.push({
505
+ registerModuleId: n?.registerModuleId,
506
+ cb: i
470
507
  });
471
508
  }
472
- invokeRegisteredBindingSideEffects(e, i) {
473
- const t = h.toServiceIdentifier(e), n = this.registeredSideEffects.get(t);
474
- n && n[`${i}Effects`].forEach((e => {
509
+ invokeRegisteredSideEffects(e, t) {
510
+ const i = f.toServiceIdentifier(e), n = this.registeredSideEffects.get(i);
511
+ n && n[`${t}Effects`].forEach((e => {
475
512
  if ("function" == typeof e) return e();
476
- if ("onGet" === i) {
477
- const i = e;
478
- if (i.invoked && i.once) return;
479
- i.invoked = !0;
513
+ if ("onGet" === t) {
514
+ const t = e;
515
+ if (t.invoked && t.once) return;
516
+ t.invoked = !0;
480
517
  }
481
518
  e.cb();
482
519
  }));
483
520
  }
484
- removeRegisteredBindingSideEffects(e) {
521
+ async removeRegisteredSideEffects(e) {
485
522
  if (!this.registeredSideEffects) return;
486
523
  if ("all" === e) return this.registeredSideEffects.forEach((({onUnbindEffects: e}) => e.forEach((e => e.cb())))),
487
524
  void this.registeredSideEffects.clear();
488
- const i = h.toServiceIdentifier(e);
489
- this.registeredSideEffects.has(i) && (this.registeredSideEffects.get(i)?.onUnbindEffects.forEach((e => e.cb())),
490
- this.registeredSideEffects.delete(i));
491
- }
492
- removeOnUnbindEffectsFromImportedModule(e, i) {
493
- const t = i.registeredSideEffects.get(e);
494
- t && (t.onUnbindEffects = t.onUnbindEffects.filter((e => e.registerModule !== this.identifier)));
525
+ const t = f.toServiceIdentifier(e);
526
+ if (!this.registeredSideEffects.has(t)) return;
527
+ const i = this.registeredSideEffects.get(t)?.onUnbindEffects ?? [];
528
+ for (const e of i) await e.cb();
529
+ this.registeredSideEffects.delete(t);
495
530
  }
496
531
  shouldThrowIfDisposed() {
497
- if (null === this.container) throw new O(this);
532
+ if (null === this.container) throw new F(this);
498
533
  }
499
- _lazyInit({markAsGlobal: e, imports: i = [], providers: t = [], exports: n = [], defaultScope: r = c.Singleton, dynamicExports: o, onReady: s, onDispose: d, ...a}) {
500
- return this.isMarkedAsGlobal = e ?? !1, this.isDisposed = !1, this.imports = i,
501
- this.providers = t, this.importedProviders = a.importedProviders ?? new Map, this.exports = n,
502
- this.defaultScope = {
534
+ _internalInit(e) {
535
+ const {options: {markAsGlobal: t, imports: i = [], providers: n = [], exports: o = [], defaultScope: r = c.Singleton, onReady: s, onDispose: d}, internalOptions: a} = y.getOptionsOrModuleDefinitionOptions(e);
536
+ return this.isMarkedAsGlobal = t ?? !1, this.isDisposed = !1, this.imports = i,
537
+ this.providers = n, this.exports = o, this.defaultScope = {
503
538
  native: r,
504
539
  inversify: u(r)
505
- }, this.dynamicExports = o, this.onReady = s, this.onDispose = d, this.importedProvidersMap = a.importedProvidersMap ?? (e => e),
506
- this.container = this.prepareContainer({
540
+ }, this.onReady = s, this.onDispose = d, this.container = this.prepareContainer({
507
541
  ...a
508
- }), this.moduleUtils = new V(this, a), this.registeredSideEffects = new Map, this.injectImportedModules(this._getImportedModules()),
542
+ }), this.moduleUtils = new V(this, a), this.registeredSideEffects = new Map, this.injectImportedModules(this.imports),
509
543
  this.injectProviders(), this.onReady?.(this), this;
510
544
  }
511
- _getImportedModules() {
512
- return this.shouldThrowIfDisposed(), this.imports;
513
- }
514
- _getProviders() {
515
- return this.shouldThrowIfDisposed(), this.providers;
545
+ _onBind(e, t) {
546
+ this.shouldThrowIfDisposed(), this.registerSideEffect(e, "bind", t);
516
547
  }
517
- _getExportableModulesAndProviders() {
518
- return this.shouldThrowIfDisposed(), this.exports;
519
- }
520
- _onBind(e, i) {
521
- this.shouldThrowIfDisposed(), this.registerBindingSideEffect(e, "bind", i);
522
- }
523
- _onGet(e, i, t) {
524
- if (this.shouldThrowIfDisposed(), "boolean" != typeof i) throw new x(this, `The 'once' parameter is required when using the '${this._onGet.name}' method!`);
525
- this.registerBindingSideEffect(e, "get", t, {
526
- once: i
548
+ _onGet(e, t, i) {
549
+ if (this.shouldThrowIfDisposed(), "boolean" != typeof t) throw new x(this, `The 'once' parameter is required when using the '${this._onGet.name}' method!`);
550
+ this.registerSideEffect(e, "get", i, {
551
+ once: t
527
552
  });
528
553
  }
529
- _onRebind(e, i) {
530
- this.shouldThrowIfDisposed(), this.registerBindingSideEffect(e, "rebind", i);
554
+ _onRebind(e, t) {
555
+ this.shouldThrowIfDisposed(), this.registerSideEffect(e, "rebind", t);
531
556
  }
532
- _onUnbind(e, i) {
533
- this.shouldThrowIfDisposed(), this.registerBindingSideEffect(e, "unbind", i);
557
+ _onUnbind(e, t) {
558
+ this.shouldThrowIfDisposed(), this.registerSideEffect(e, "unbind", t);
534
559
  }
535
560
  _overwriteContainer(e) {
536
561
  this.container = e();
537
562
  }
538
563
  __bind(e) {
539
564
  this.shouldThrowIfDisposed();
540
- const i = this.container.bind(h.toServiceIdentifier(e));
541
- return this.invokeRegisteredBindingSideEffects(e, "onBind"), i;
565
+ const t = this.container.bind(f.toServiceIdentifier(e));
566
+ return this.invokeRegisteredSideEffects(e, "onBind"), t;
542
567
  }
543
- __get(e, i) {
544
- return this.shouldThrowIfDisposed(), this.invokeRegisteredBindingSideEffects(e, "onGet"),
545
- this.container.get(h.toServiceIdentifier(e), i);
568
+ __get(e, t) {
569
+ return this.shouldThrowIfDisposed(), this.invokeRegisteredSideEffects(e, "onGet"),
570
+ this.container.get(f.toServiceIdentifier(e), t);
546
571
  }
547
- async __getAsync(e, i) {
548
- return this.shouldThrowIfDisposed(), this.container.getAsync(h.toServiceIdentifier(e), i);
572
+ async __getAsync(e, t) {
573
+ return this.shouldThrowIfDisposed(), this.container.getAsync(f.toServiceIdentifier(e), t);
549
574
  }
550
- __getAll(e, i) {
551
- return this.shouldThrowIfDisposed(), this.container.getAll(h.toServiceIdentifier(e), i);
575
+ __getAll(e, t) {
576
+ return this.shouldThrowIfDisposed(), this.container.getAll(f.toServiceIdentifier(e), t);
552
577
  }
553
- async __getAllAsync(e, i) {
554
- return this.shouldThrowIfDisposed(), this.container.getAllAsync(h.toServiceIdentifier(e), i);
578
+ async __getAllAsync(e, t) {
579
+ return this.shouldThrowIfDisposed(), this.container.getAllAsync(f.toServiceIdentifier(e), t);
555
580
  }
556
- __isBound(e, i) {
557
- return this.shouldThrowIfDisposed(), this.container.isBound(h.toServiceIdentifier(e), i);
581
+ __isBound(e, t) {
582
+ return this.shouldThrowIfDisposed(), this.container.isBound(f.toServiceIdentifier(e), t);
558
583
  }
559
- __isCurrentBound(e, i) {
560
- return this.shouldThrowIfDisposed(), this.container.isCurrentBound(h.toServiceIdentifier(e), i);
584
+ __isCurrentBound(e, t) {
585
+ return this.shouldThrowIfDisposed(), this.container.isCurrentBound(f.toServiceIdentifier(e), t);
561
586
  }
562
587
  __takeSnapshot() {
563
588
  this.shouldThrowIfDisposed(), this.container.snapshot();
@@ -567,56 +592,58 @@ var G = class e extends Error {
567
592
  }
568
593
  async __rebind(e) {
569
594
  this.shouldThrowIfDisposed();
570
- const i = await this.container.rebind(h.toServiceIdentifier(e));
571
- return this.invokeRegisteredBindingSideEffects(e, "onRebind"), i;
595
+ const t = await this.container.rebind(f.toServiceIdentifier(e));
596
+ return this.invokeRegisteredSideEffects(e, "onRebind"), t;
572
597
  }
573
598
  __rebindSync(e) {
574
599
  this.shouldThrowIfDisposed();
575
- const i = this.container.rebindSync(h.toServiceIdentifier(e));
576
- return this.invokeRegisteredBindingSideEffects(e, "onRebind"), i;
600
+ const t = this.container.rebindSync(f.toServiceIdentifier(e));
601
+ return this.invokeRegisteredSideEffects(e, "onRebind"), t;
577
602
  }
578
603
  async __unbind(e) {
579
- this.shouldThrowIfDisposed(), await this.container.unbind(h.toServiceIdentifier(e)),
580
- this.removeRegisteredBindingSideEffects(e);
604
+ this.shouldThrowIfDisposed(), await this.container.unbind(f.toServiceIdentifier(e)),
605
+ await this.removeRegisteredSideEffects(e);
581
606
  }
582
607
  __unbindSync(e) {
583
- this.shouldThrowIfDisposed(), this.container.unbindSync(h.toServiceIdentifier(e)),
584
- this.removeRegisteredBindingSideEffects(e);
608
+ this.shouldThrowIfDisposed(), this.container.unbindSync(f.toServiceIdentifier(e)),
609
+ this.removeRegisteredSideEffects(e);
585
610
  }
586
611
  async __unbindAll() {
587
- this.shouldThrowIfDisposed(), await this.container.unbindAll(), this.removeRegisteredBindingSideEffects("all");
612
+ this.shouldThrowIfDisposed(), await this.container.unbindAll(), await this.removeRegisteredSideEffects("all");
588
613
  }
589
- }, L = new Set, $ = class extends W {
614
+ }, W = new Set, $ = class extends z {
590
615
  static {
591
- o(this, "GlobalAppModule");
616
+ r(this, "GlobalAppModule");
592
617
  }
618
+ _strict;
593
619
  nakedModule=this;
594
620
  isLoaded=!1;
595
621
  constructor() {
596
- super(f.buildInternalConstructorParams({
597
- identifier: Symbol(d),
622
+ super(y.buildInternalConstructorParams({
623
+ identifier: d,
598
624
  isAppModule: !0
599
625
  }));
600
626
  }
601
627
  register(e) {
602
- if (this.isLoaded) throw new G(`The '${this.toString()}' has already been registered!`);
603
- return this.nakedModule._lazyInit(e), this.checkIfRegisteredModulesHaveGlobalMark(this.toNaked(), this.imports),
628
+ if (this.isLoaded) throw new B(`The '${this.toString()}' has already been registered!`);
629
+ return this._strict = e._strict ?? !0, this.nakedModule._internalInit(e), this.checkIfRegisteredModulesHaveGlobalMark(this.nakedModule, this.imports),
604
630
  this.isLoaded = !0, this;
605
631
  }
606
632
  toNaked() {
607
633
  return super.toNaked();
608
634
  }
609
635
  async dispose() {
610
- this.isLoaded = !1, super.dispose();
611
- }
612
- checkIfRegisteredModulesHaveGlobalMark(e, i, t = !1) {
613
- i.forEach((i => {
614
- if (i instanceof W) {
615
- if (i.isMarkedAsGlobal) return L.delete(i), void (i.exports && this.checkIfRegisteredModulesHaveGlobalMark(i, i.exports, !0));
616
- throw new U(i, t ? `Is not marked as \`global\` but has been imported into the \`AppModule\`via the \`${e.toString()}\` module!` : "Is not marked as `global` but has been imported into the `AppModule`!");
636
+ this.isLoaded = !1, await super.dispose();
637
+ }
638
+ checkIfRegisteredModulesHaveGlobalMark(e, t, i = !1) {
639
+ this._strict && (t.forEach((t => {
640
+ const n = y.tryStaticOrLazyExportToStaticExport(this, t);
641
+ if (n instanceof z) {
642
+ if (n.isMarkedAsGlobal) return W.delete(n), void (n.exports && this.checkIfRegisteredModulesHaveGlobalMark(n, n.exports, !0));
643
+ throw new U(n, i ? `Is not marked as \`global\` but has been imported into the \`AppModule\` via the \`${e.toString()}\` module!` : "Is not marked as `global` but has been imported into the `AppModule`!");
617
644
  }
618
- })), t || L.forEach((e => {
645
+ })), i || W.forEach((e => {
619
646
  throw new U(e, "Is marked as 'global' and has not been imported into the 'AppModule'!");
620
- }));
647
+ })));
621
648
  }
622
649
  }, H = new $;//# sourceMappingURL=index.cjs.map