@adimm/x-injection 0.6.5 → 0.8.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.
package/README.md CHANGED
@@ -356,12 +356,6 @@ const CatModule = new ProviderModule({
356
356
 
357
357
  Hopefully the provided example shows how powerful the `dynamicExports` property it is, but, there are some things to keep in mind in order to avoid nasty bugs!
358
358
 
359
- 1. You **must always** return only the providers/modules declared into the static `exports` array.
360
- 2. You **can** return _less_ providers/modules as long as they are still part of the static `exports` array.
361
- 3. You **cannot** return _more_ providers/modules than the static `exports` array!
362
-
363
- > When point number `1` and point number `3` are triggered, the library will throw a descriptive error which should help to find the culprit module.
364
-
365
359
  ## Advanced Usage
366
360
 
367
361
  Each `ProviderModule` instance implements the `IProviderModule` interface for simplicity, but can be cast to `IProviderModuleNaked` for advanced operations:
package/dist/index.cjs CHANGED
@@ -11,36 +11,33 @@ var e, i = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Objec
11
11
  enumerable: !0
12
12
  });
13
13
  })(s, {
14
- AppModule: () => Q,
14
+ AppModule: () => H,
15
15
  GLOBAL_APP_MODULE_ID: () => d,
16
- GlobalAppModule: () => K,
17
- GlobalContainer: () => $,
16
+ GlobalAppModule: () => $,
17
+ GlobalContainer: () => q,
18
18
  Inject: () => E,
19
19
  InjectFromBase: () => w,
20
- Injectable: () => b,
21
- InjectionDynamicExportsOutOfRange: () => V,
22
- InjectionError: () => q,
23
- InjectionProviderModuleDisposedError: () => U,
24
- InjectionProviderModuleError: () => N,
25
- InjectionProviderModuleGlobalMarkError: () => L,
26
- InjectionProviderModuleMissingIdentifierError: () => W,
20
+ Injectable: () => I,
21
+ InjectionError: () => G,
22
+ InjectionProviderModuleDisposedError: () => O,
23
+ InjectionProviderModuleError: () => x,
24
+ InjectionProviderModuleGlobalMarkError: () => U,
25
+ InjectionProviderModuleMissingIdentifierError: () => F,
27
26
  InjectionScope: () => c,
28
27
  MultiInject: () => T,
29
- Named: () => k,
30
- Optional: () => D,
31
- PostConstruct: () => A,
32
- PreDestroy: () => x,
33
- ProviderModule: () => Y,
34
- ProviderModuleHelpers: () => p,
28
+ Named: () => P,
29
+ Optional: () => B,
30
+ ProviderModule: () => W,
31
+ ProviderModuleHelpers: () => f,
35
32
  ProviderTokenHelpers: () => h,
36
- Tagged: () => O,
37
- Unmanaged: () => F,
33
+ Tagged: () => D,
34
+ Unmanaged: () => R,
38
35
  bindingScopeToInjectionScope: () => l,
39
36
  injectionScopeToBindingScope: () => u,
40
37
  isClass: () => v,
41
38
  isClassOrFunction: () => g,
42
- isFunction: () => m,
43
- isPlainObject: () => y
39
+ isFunction: () => S,
40
+ isPlainObject: () => m
44
41
  }), module.exports = (e = s, ((e, o, s, d) => {
45
42
  if (o && "object" == typeof o || "function" == typeof o) for (let a of n(o)) r.call(e, a) || a === s || i(e, a, {
46
43
  get: () => o[a],
@@ -84,7 +81,7 @@ function l(e) {
84
81
 
85
82
  o(u, "injectionScopeToBindingScope"), o(l, "bindingScopeToInjectionScope");
86
83
 
87
- var h, p, f = require("@inversifyjs/core");
84
+ var h, f, p = require("@inversifyjs/core");
88
85
 
89
86
  function v(e) {
90
87
  return "function" == typeof e && Function.prototype.toString.call(e).startsWith("class ");
@@ -94,36 +91,36 @@ function g(e) {
94
91
  return "function" == typeof e;
95
92
  }
96
93
 
97
- function m(e) {
94
+ function S(e) {
98
95
  return "function" == typeof e && !Function.prototype.toString.call(e).startsWith("class ");
99
96
  }
100
97
 
101
- function S(e) {
98
+ function b(e) {
102
99
  return "[object Object]" === Object.prototype.toString.call(e);
103
100
  }
104
101
 
105
- function y(e) {
106
- if (!1 === S(e)) return !1;
102
+ function m(e) {
103
+ if (!1 === b(e)) return !1;
107
104
  const i = e.constructor;
108
105
  if (void 0 === i) return !0;
109
106
  const t = i.prototype;
110
- return !1 !== S(t) && !1 !== t.hasOwnProperty("isPrototypeOf");
107
+ return !1 !== b(t) && !1 !== t.hasOwnProperty("isPrototypeOf");
111
108
  }
112
109
 
113
- function b(e) {
110
+ function I(e) {
114
111
  return void 0 === e ? (0, a.injectable)() : (0, a.injectable)(u(e));
115
112
  }
116
113
 
117
- o(v, "isClass"), o(g, "isClassOrFunction"), o(m, "isFunction"), o(S, "isObject"),
118
- o(y, "isPlainObject"), function(e) {
114
+ o(v, "isClass"), o(g, "isClassOrFunction"), o(S, "isFunction"), o(b, "isObject"),
115
+ o(m, "isPlainObject"), function(e) {
119
116
  function i(e) {
120
- return S(e) && "useClass" in e;
117
+ return b(e) && "useClass" in e;
121
118
  }
122
119
  function t(e) {
123
- return S(e) && "useValue" in e;
120
+ return b(e) && "useValue" in e;
124
121
  }
125
122
  function n(e) {
126
- return S(e) && "useFactory" in e;
123
+ return b(e) && "useFactory" in e;
127
124
  }
128
125
  function r(e) {
129
126
  return "string" == typeof e || "symbol" == typeof e || g(e);
@@ -139,7 +136,7 @@ o(y, "isPlainObject"), function(e) {
139
136
  ...i,
140
137
  provide: i?.provide ?? e,
141
138
  useClass: i?.useClass ?? e
142
- } : m(e) ? {
139
+ } : S(e) ? {
143
140
  ...i,
144
141
  provide: i?.provide ?? e,
145
142
  useFactory: i?.useFactory ?? e
@@ -149,23 +146,23 @@ o(y, "isPlainObject"), function(e) {
149
146
  };
150
147
  }
151
148
  function c(e, i) {
152
- return h(e) ?? p(e) ?? i;
149
+ return h(e) ?? f(e) ?? i;
153
150
  }
154
151
  function u(e) {
155
- if (S(e)) return e;
152
+ if (b(e)) return e;
156
153
  }
157
154
  function h(e) {
158
155
  const i = u(e);
159
156
  if (i) return i.scope;
160
157
  }
161
- function p(e) {
158
+ function f(e) {
162
159
  const i = s(e);
163
160
  if (!v(i)) return;
164
- const t = (0, f.getClassMetadata)(i)?.scope;
161
+ const t = (0, p.getClassMetadata)(i)?.scope;
165
162
  return t ? l(t) : void 0;
166
163
  }
167
- function S(e) {
168
- return y(e) && "object" == typeof e && "provide" in e;
164
+ function b(e) {
165
+ return m(e) && "object" == typeof e && "provide" in e;
169
166
  }
170
167
  o(i, "isClassToken"), e.isClassToken = i, o(t, "isValueToken"), e.isValueToken = t,
171
168
  o(n, "isFactoryToken"), e.isFactoryToken = n, o(r, "isProviderIdentifier"), e.isProviderIdentifier = r,
@@ -173,7 +170,7 @@ o(y, "isPlainObject"), function(e) {
173
170
  e.toServiceIdentifiers = d, o(a, "toDependencyProviderWithOptions"), e.toDependencyProviderWithOptions = a,
174
171
  o(c, "getInjectionScopeByPriority"), e.getInjectionScopeByPriority = c, o(u, "tryGetProviderOptions"),
175
172
  e.tryGetProviderOptions = u, o(h, "tryGetScopeFromProvider"), e.tryGetScopeFromProvider = h,
176
- o(p, "tryGetDecoratorScopeFromClass"), e.tryGetDecoratorScopeFromClass = p, o(S, "hasProvideProperty");
173
+ o(f, "tryGetDecoratorScopeFromClass"), e.tryGetDecoratorScopeFromClass = f, o(b, "hasProvideProperty");
177
174
  }(h || (h = {})), function(e) {
178
175
  function i(e) {
179
176
  return e;
@@ -183,12 +180,12 @@ o(y, "isPlainObject"), function(e) {
183
180
  }
184
181
  o(i, "buildInternalConstructorParams"), e.buildInternalConstructorParams = i, o(t, "isDynamicExport"),
185
182
  e.isDynamicExport = t;
186
- }(p || (p = {})), o(b, "Injectable");
183
+ }(f || (f = {})), o(I, "Injectable");
187
184
 
188
- var I = require("inversify");
185
+ var y = require("inversify");
189
186
 
190
187
  function E(e) {
191
- return (0, I.inject)(h.toServiceIdentifier(e));
188
+ return (0, y.inject)(h.toServiceIdentifier(e));
192
189
  }
193
190
 
194
191
  o(E, "Inject");
@@ -201,68 +198,52 @@ function T(e) {
201
198
 
202
199
  o(T, "MultiInject");
203
200
 
204
- var P = require("inversify");
201
+ var k = require("inversify");
205
202
 
206
203
  function w(e) {
207
- return (0, P.injectFromBase)(e);
204
+ return (0, k.injectFromBase)(e);
208
205
  }
209
206
 
210
207
  o(w, "InjectFromBase");
211
208
 
212
209
  var _ = require("inversify");
213
210
 
214
- function k(e) {
211
+ function P(e) {
215
212
  return (0, _.named)(e);
216
213
  }
217
214
 
218
- o(k, "Named");
219
-
220
- var B = require("inversify");
221
-
222
- function D() {
223
- return (0, B.optional)();
224
- }
225
-
226
- o(D, "Optional");
215
+ o(P, "Named");
227
216
 
228
217
  var j = require("inversify");
229
218
 
230
- function A() {
231
- return (0, j.postConstruct)();
219
+ function B() {
220
+ return (0, j.optional)();
232
221
  }
233
222
 
234
- o(A, "PostConstruct");
223
+ o(B, "Optional");
235
224
 
236
- var C = require("inversify");
237
-
238
- function x() {
239
- return (0, C.preDestroy)();
240
- }
241
-
242
- o(x, "PreDestroy");
243
-
244
- var R = require("inversify");
225
+ var A = require("inversify");
245
226
 
246
- function O(e, i) {
247
- return (0, R.tagged)(e, i);
227
+ function D(e, i) {
228
+ return (0, A.tagged)(e, i);
248
229
  }
249
230
 
250
- o(O, "Tagged");
231
+ o(D, "Tagged");
251
232
 
252
- var G = require("inversify");
233
+ var C = require("inversify");
253
234
 
254
- function F() {
255
- return (0, G.unmanaged)();
235
+ function R() {
236
+ return (0, C.unmanaged)();
256
237
  }
257
238
 
258
- o(F, "Unmanaged");
239
+ o(R, "Unmanaged");
259
240
 
260
- var q = class e extends Error {
241
+ var G = class e extends Error {
261
242
  static {
262
243
  o(this, "InjectionError");
263
244
  }
264
245
  name=e.name;
265
- }, N = class e extends Error {
246
+ }, x = class e extends Error {
266
247
  static {
267
248
  o(this, "InjectionProviderModuleError");
268
249
  }
@@ -270,7 +251,7 @@ var q = class e extends Error {
270
251
  constructor(e, i) {
271
252
  super(`{ProviderModule.${e.toString()}} => ${i}`);
272
253
  }
273
- }, U = class e extends N {
254
+ }, O = class e extends x {
274
255
  static {
275
256
  o(this, "InjectionProviderModuleDisposedError");
276
257
  }
@@ -278,15 +259,7 @@ var q = class e extends Error {
278
259
  constructor(e) {
279
260
  super(e, "Has been disposed! You can re-initialize it by using the `_lazyInit` method.");
280
261
  }
281
- }, V = class e extends N {
282
- static {
283
- o(this, "InjectionDynamicExportsOutOfRange");
284
- }
285
- name=e.name;
286
- constructor(e) {
287
- super(e, `The 'ProviderModule.${e.toString()}' is trying to dynamically export providers/modules out of the declared range of the static exports!`);
288
- }
289
- }, W = class e extends N {
262
+ }, F = class e extends x {
290
263
  static {
291
264
  o(this, "InjectionProviderModuleMissingIdentifierError");
292
265
  }
@@ -294,7 +267,7 @@ var q = class e extends Error {
294
267
  constructor(e) {
295
268
  super(e, "An `identifier` must be supplied!");
296
269
  }
297
- }, L = class e extends N {
270
+ }, U = class e extends x {
298
271
  static {
299
272
  o(this, "InjectionProviderModuleGlobalMarkError");
300
273
  }
@@ -302,9 +275,9 @@ var q = class e extends Error {
302
275
  constructor(e, i) {
303
276
  super(e, i);
304
277
  }
305
- }, $ = new (require("inversify").Container)({
278
+ }, q = new (require("inversify").Container)({
306
279
  defaultScope: "Singleton"
307
- }), H = require("inversify"), z = class {
280
+ }), N = require("inversify"), V = class {
308
281
  static {
309
282
  o(this, "ProviderModuleUtils");
310
283
  }
@@ -313,7 +286,7 @@ var q = class e extends Error {
313
286
  }
314
287
  module;
315
288
  moduleNaked;
316
- appModule=Q;
289
+ appModule=H;
317
290
  constructor(e, i) {
318
291
  this.module = e, this.moduleNaked = e.toNaked(), this.appModule = i.appModule?.() ?? this.appModule,
319
292
  this.checkIfShouldBeAddedToTheGlobalRegister();
@@ -322,7 +295,7 @@ var q = class e extends Error {
322
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);
323
296
  }
324
297
  checkIfShouldBeAddedToTheGlobalRegister() {
325
- !this.moduleNaked.isAppModule && this.module.isMarkedAsGlobal && J.add(this.module);
298
+ !this.moduleNaked.isAppModule && this.module.isMarkedAsGlobal && L.add(this.module);
326
299
  }
327
300
  bindSelfTokenToContainer(e, i) {
328
301
  return this.setBindingScope(e, this.container.bind(h.toServiceIdentifier(e)).toSelf(), i),
@@ -363,7 +336,7 @@ var q = class e extends Error {
363
336
  const t = e;
364
337
  t.onEvent?.activation && i.onActivation(t.onEvent.activation), t.onEvent?.deactivation && i.onDeactivation(t.onEvent.deactivation);
365
338
  }
366
- }, Y = class e {
339
+ }, W = class e {
367
340
  static {
368
341
  o(this, "ProviderModule");
369
342
  }
@@ -382,7 +355,7 @@ var q = class e extends Error {
382
355
  providers;
383
356
  importedProviders;
384
357
  exports;
385
- registeredBindingSideEffects;
358
+ registeredSideEffects;
386
359
  constructor({identifier: e, imports: i, providers: t, exports: n, defaultScope: r, markAsGlobal: o, dynamicExports: s, onReady: d, onDispose: a, ...c}) {
387
360
  const u = c;
388
361
  this.identifier = this.setIdentifier(e), this.isDisposed = u.isDisposed ?? !1, this.isAppModule = u.isAppModule ?? !1,
@@ -405,22 +378,15 @@ var q = class e extends Error {
405
378
  }
406
379
  getMany(...e) {
407
380
  return e.map((e => {
408
- const i = y(e) && "provider" in e;
381
+ const i = m(e) && "provider" in e;
409
382
  return this.get(i ? e.provider : e, !!i && e.isOptional);
410
383
  }));
411
384
  }
412
- onActivationEvent(e, i) {
413
- this.shouldThrowIfDisposed(), this.container.onActivation(h.toServiceIdentifier(e), i);
414
- }
415
- onDeactivationEvent(e, i) {
416
- this.shouldThrowIfDisposed(), this.container.onDeactivation(h.toServiceIdentifier(e), i);
417
- }
418
385
  toNaked() {
419
386
  return this;
420
387
  }
421
388
  clone(i) {
422
- let t = [ ...this.providers ];
423
- return i?.providersMap && (t = t.map((e => i.providersMap(e, this)))), new e(p.buildInternalConstructorParams({
389
+ const t = i, n = new e(f.buildInternalConstructorParams({
424
390
  isAppModule: this.isAppModule,
425
391
  markAsGlobal: this.isMarkedAsGlobal,
426
392
  identifier: this.identifier,
@@ -428,76 +394,107 @@ var q = class e extends Error {
428
394
  dynamicExports: this.dynamicExports,
429
395
  onReady: this.onReady,
430
396
  onDispose: this.onDispose,
431
- importedProvidersMap: i?.importedProvidersMap,
397
+ importedProvidersMap: this.importedProvidersMap,
432
398
  imports: [ ...this.imports ],
433
- providers: t,
434
- exports: [ ...this.exports ]
399
+ providers: [ ...this.providers ],
400
+ exports: [ ...this.exports ],
401
+ ...t
435
402
  }));
403
+ return n.registeredSideEffects = new Map(this.registeredSideEffects), n;
404
+ }
405
+ 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;
436
409
  }
437
410
  toString() {
438
411
  return this.identifier?.description ?? "Unknown";
439
412
  }
440
413
  setIdentifier(e) {
441
- if (!e) throw new W(this);
414
+ if (!e) throw new F(this);
442
415
  return e;
443
416
  }
444
417
  prepareContainer(e) {
445
- return this.isAppModule ? e.container?.() ?? $ : e.container ? (console.warn(`[xInjection]: The '${this.toString()}' module is using a dynamic container!`),
446
- e.container()) : new H.Container({
447
- parent: $,
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,
448
421
  defaultScope: this.defaultScope.inversify
449
422
  });
450
423
  }
451
424
  injectImportedModules(i) {
452
425
  i && 0 !== i.length && i.forEach((i => {
453
- if ("GlobalAppModule" === i.toString()) throw new N(this, "The 'GlobalAppModule' can't be imported!");
454
- const t = i._getExportableModulesAndProviders(), n = i.dynamicExports?.(this, t);
455
- void 0 !== n && this.shouldThrowWhenModuleDynamicExportsDontMatchTheStaticExports(i, t, n),
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);
456
428
  (n ?? t).forEach((t => {
457
429
  if (t instanceof e) {
458
430
  const e = t.toNaked();
459
431
  return void this.injectImportedModules([ e ]);
460
432
  }
461
- const n = t, r = this.importedProvidersMap({
433
+ const n = t, r = h.toServiceIdentifier(n), s = this.importedProvidersMap({
462
434
  scope: h.getInjectionScopeByPriority(n, i.defaultScope.native),
463
- provide: h.toServiceIdentifier(n),
435
+ provide: r,
464
436
  useFactory: o((() => i.get(n)), "useFactory")
465
437
  }, n, i);
466
- this.importedProviders.set(i, [ ...this.importedProviders.get(i) ?? [], r ]), this.moduleUtils.bindToContainer(r, i.defaultScope.native),
467
- i._onUnbind(n, (() => this.__unbind(r)));
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);
442
+ }));
468
443
  }));
469
444
  }));
470
445
  }
471
446
  injectProviders() {
472
447
  this.providers.forEach((e => this.moduleUtils.bindToContainer(e, this.defaultScope.native)));
473
448
  }
474
- registerBindingSideEffect(e, i, t) {
475
- this.registeredBindingSideEffects.has(e) || this.registeredBindingSideEffects.set(e, {
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, {
476
457
  onBindEffects: [],
458
+ onGetEffects: [],
477
459
  onRebindEffects: [],
478
460
  onUnbindEffects: []
479
461
  });
480
- const n = this.registeredBindingSideEffects.get(e);
481
- "bind" === i ? n.onBindEffects.push(t) : "rebind" === i ? n.onRebindEffects.push(t) : n.onUnbindEffects.push(t);
462
+ const o = this.registeredSideEffects.get(r);
463
+ "bind" === i ? o.onBindEffects.push(t) : "get" === i ? o.onGetEffects.push({
464
+ once: n.once,
465
+ invoked: !1,
466
+ cb: t
467
+ }) : "rebind" === i ? o.onRebindEffects.push(t) : "unbind" === i && o.onUnbindEffects.push({
468
+ registerModule: n?.registerModule,
469
+ cb: t
470
+ });
482
471
  }
483
472
  invokeRegisteredBindingSideEffects(e, i) {
484
- const t = this.registeredBindingSideEffects.get(e);
485
- t && t[`${i}Effects`].forEach((e => e()));
473
+ const t = h.toServiceIdentifier(e), n = this.registeredSideEffects.get(t);
474
+ n && n[`${i}Effects`].forEach((e => {
475
+ 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;
480
+ }
481
+ e.cb();
482
+ }));
486
483
  }
487
484
  removeRegisteredBindingSideEffects(e) {
488
- this.registeredBindingSideEffects && ("all" !== e ? this.registeredBindingSideEffects.has(e) && (this.registeredBindingSideEffects.get(e)?.onUnbindEffects.forEach((e => e())),
489
- this.registeredBindingSideEffects.delete(e)) : this.registeredBindingSideEffects.forEach((({onUnbindEffects: e}) => e.forEach((e => e())))));
485
+ if (!this.registeredSideEffects) return;
486
+ if ("all" === e) return this.registeredSideEffects.forEach((({onUnbindEffects: e}) => e.forEach((e => e.cb())))),
487
+ 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));
490
491
  }
491
- shouldThrowWhenModuleDynamicExportsDontMatchTheStaticExports(e, i, t) {
492
- if (t.length > i.length || t.some((e => !i.includes(e)))) throw new V(e);
492
+ removeOnUnbindEffectsFromImportedModule(e, i) {
493
+ const t = i.registeredSideEffects.get(e);
494
+ t && (t.onUnbindEffects = t.onUnbindEffects.filter((e => e.registerModule !== this.identifier)));
493
495
  }
494
496
  shouldThrowIfDisposed() {
495
- if (null === this.container) throw new U(this);
496
- }
497
- async _dispose() {
498
- await (this.onDispose?.(this)), await this.__unbindAll(), this.container = null,
499
- this.imports = null, this.providers = null, this.importedProviders = null, this.exports = null,
500
- this.dynamicExports = null, this.registeredBindingSideEffects = null, this.isDisposed = !0;
497
+ if (null === this.container) throw new O(this);
501
498
  }
502
499
  _lazyInit({markAsGlobal: e, imports: i = [], providers: t = [], exports: n = [], defaultScope: r = c.Singleton, dynamicExports: o, onReady: s, onDispose: d, ...a}) {
503
500
  return this.isMarkedAsGlobal = e ?? !1, this.isDisposed = !1, this.imports = i,
@@ -508,9 +505,8 @@ var q = class e extends Error {
508
505
  }, this.dynamicExports = o, this.onReady = s, this.onDispose = d, this.importedProvidersMap = a.importedProvidersMap ?? (e => e),
509
506
  this.container = this.prepareContainer({
510
507
  ...a
511
- }), this.moduleUtils = new z(this, a), this.registeredBindingSideEffects = new Map,
512
- this.injectImportedModules(this._getImportedModules()), this.injectProviders(),
513
- this.onReady?.(this), this;
508
+ }), this.moduleUtils = new V(this, a), this.registeredSideEffects = new Map, this.injectImportedModules(this._getImportedModules()),
509
+ this.injectProviders(), this.onReady?.(this), this;
514
510
  }
515
511
  _getImportedModules() {
516
512
  return this.shouldThrowIfDisposed(), this.imports;
@@ -524,6 +520,12 @@ var q = class e extends Error {
524
520
  _onBind(e, i) {
525
521
  this.shouldThrowIfDisposed(), this.registerBindingSideEffect(e, "bind", i);
526
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
527
+ });
528
+ }
527
529
  _onRebind(e, i) {
528
530
  this.shouldThrowIfDisposed(), this.registerBindingSideEffect(e, "rebind", i);
529
531
  }
@@ -539,7 +541,8 @@ var q = class e extends Error {
539
541
  return this.invokeRegisteredBindingSideEffects(e, "onBind"), i;
540
542
  }
541
543
  __get(e, i) {
542
- return this.shouldThrowIfDisposed(), this.container.get(h.toServiceIdentifier(e), i);
544
+ return this.shouldThrowIfDisposed(), this.invokeRegisteredBindingSideEffects(e, "onGet"),
545
+ this.container.get(h.toServiceIdentifier(e), i);
543
546
  }
544
547
  async __getAsync(e, i) {
545
548
  return this.shouldThrowIfDisposed(), this.container.getAsync(h.toServiceIdentifier(e), i);
@@ -583,37 +586,37 @@ var q = class e extends Error {
583
586
  async __unbindAll() {
584
587
  this.shouldThrowIfDisposed(), await this.container.unbindAll(), this.removeRegisteredBindingSideEffects("all");
585
588
  }
586
- }, J = new Set, K = class extends Y {
589
+ }, L = new Set, $ = class extends W {
587
590
  static {
588
591
  o(this, "GlobalAppModule");
589
592
  }
590
593
  nakedModule=this;
591
594
  isLoaded=!1;
592
595
  constructor() {
593
- super(p.buildInternalConstructorParams({
596
+ super(f.buildInternalConstructorParams({
594
597
  identifier: Symbol(d),
595
598
  isAppModule: !0
596
599
  }));
597
600
  }
598
601
  register(e) {
599
- if (this.isLoaded) throw new q(`The '${this.toString()}' has already been registered!`);
602
+ if (this.isLoaded) throw new G(`The '${this.toString()}' has already been registered!`);
600
603
  return this.nakedModule._lazyInit(e), this.checkIfRegisteredModulesHaveGlobalMark(this.toNaked(), this.imports),
601
604
  this.isLoaded = !0, this;
602
605
  }
603
606
  toNaked() {
604
607
  return super.toNaked();
605
608
  }
606
- async _dispose() {
607
- this.isLoaded = !1, super._dispose();
609
+ async dispose() {
610
+ this.isLoaded = !1, super.dispose();
608
611
  }
609
612
  checkIfRegisteredModulesHaveGlobalMark(e, i, t = !1) {
610
613
  i.forEach((i => {
611
- if (i instanceof Y) {
612
- if (i.isMarkedAsGlobal) return J.delete(i), void (i.exports && this.checkIfRegisteredModulesHaveGlobalMark(i, i.exports, !0));
613
- throw new L(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`!");
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`!");
614
617
  }
615
- })), t || J.forEach((e => {
616
- throw new L(e, "Is marked as 'global' and has not been imported into the 'AppModule'!");
618
+ })), t || L.forEach((e => {
619
+ throw new U(e, "Is marked as 'global' and has not been imported into the 'AppModule'!");
617
620
  }));
618
621
  }
619
- }, Q = new K;//# sourceMappingURL=index.cjs.map
622
+ }, H = new $;//# sourceMappingURL=index.cjs.map