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