@adimm/x-injection 2.1.2 → 3.0.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,35 +11,35 @@ var e, t = Object.defineProperty, i = Object.getOwnPropertyDescriptor, o = Objec
11
11
  enumerable: !0
12
12
  });
13
13
  })(s, {
14
- AppModule: () => Z,
15
- DefinitionEventType: () => p,
14
+ AppModule: () => K,
15
+ DefinitionEventType: () => a,
16
16
  Inject: () => V,
17
- InjectFromBase: () => N,
17
+ InjectFromBase: () => L,
18
18
  Injectable: () => q,
19
- InjectionError: () => I,
20
- InjectionProviderModuleDisposedError: () => w,
21
- InjectionProviderModuleError: () => b,
22
- InjectionProviderModuleMissingIdentifierError: () => x,
23
- InjectionProviderModuleMissingProviderError: () => E,
24
- InjectionProviderModuleUnknownProviderError: () => P,
19
+ InjectionError: () => m,
20
+ InjectionProviderModuleDisposedError: () => g,
21
+ InjectionProviderModuleError: () => M,
22
+ InjectionProviderModuleMissingIdentifierError: () => I,
23
+ InjectionProviderModuleMissingProviderError: () => b,
24
+ InjectionProviderModuleUnknownProviderError: () => y,
25
25
  InjectionScope: () => u,
26
- MiddlewareType: () => a,
26
+ MiddlewareType: () => p,
27
27
  MultiInject: () => U,
28
- Named: () => H,
29
- Optional: () => J,
30
- ProviderModule: () => G,
31
- ProviderModuleBlueprint: () => A,
32
- ProviderModuleHelpers: () => g,
28
+ Named: () => W,
29
+ Optional: () => H,
30
+ ProviderModule: () => B,
31
+ ProviderModuleBlueprint: () => T,
32
+ ProviderModuleClass: () => j,
33
+ ProviderModuleHelpers: () => f,
33
34
  ProviderTokenHelpers: () => h,
34
- Tagged: () => Q,
35
- Unmanaged: () => Y,
35
+ Tagged: () => z,
36
+ Unmanaged: () => J,
36
37
  bindingScopeToInjectionScope: () => c,
37
38
  deepClone: () => k,
38
39
  injectionScopeToBindingScope: () => l,
39
- isClass: () => v,
40
- isClassOrFunction: () => m,
41
- isFunction: () => F,
42
- isPlainObject: () => y
40
+ isClass: () => G,
41
+ isClassOrFunction: () => F,
42
+ isPlainObject: () => A
43
43
  }), module.exports = (e = s, ((e, n, s, d) => {
44
44
  if (n && "object" == typeof n || "function" == typeof n) for (let u of o(n)) r.call(e, u) || u === s || t(e, u, {
45
45
  get: () => n[u],
@@ -53,12 +53,12 @@ var e, t = Object.defineProperty, i = Object.getOwnPropertyDescriptor, o = Objec
53
53
  var d = require("inversify"), u = function(e) {
54
54
  return e[e.Singleton = 0] = "Singleton", e[e.Transient = 1] = "Transient", e[e.Request = 2] = "Request",
55
55
  e;
56
- }({}), a = function(e) {
56
+ }({}), p = function(e) {
57
57
  return e[e.BeforeAddImport = 0] = "BeforeAddImport", e[e.BeforeAddProvider = 1] = "BeforeAddProvider",
58
58
  e[e.BeforeGet = 2] = "BeforeGet", e[e.BeforeRemoveImport = 3] = "BeforeRemoveImport",
59
59
  e[e.BeforeRemoveProvider = 4] = "BeforeRemoveProvider", e[e.BeforeRemoveExport = 5] = "BeforeRemoveExport",
60
60
  e[e.OnExportAccess = 6] = "OnExportAccess", e;
61
- }({}), p = function(e) {
61
+ }({}), a = function(e) {
62
62
  return e[e.Noop = 0] = "Noop", e[e.Import = 1] = "Import", e[e.Provider = 2] = "Provider",
63
63
  e[e.GetProvider = 3] = "GetProvider", e[e.Export = 4] = "Export", e[e.ExportModule = 5] = "ExportModule",
64
64
  e[e.ExportProvider = 6] = "ExportProvider", e[e.ImportRemoved = 7] = "ImportRemoved",
@@ -95,94 +95,12 @@ function c(e) {
95
95
 
96
96
  n(l, "injectionScopeToBindingScope"), n(c, "bindingScopeToInjectionScope");
97
97
 
98
- var h, f = require("@inversifyjs/core");
99
-
100
- function v(e) {
101
- return "function" == typeof e && Function.prototype.toString.call(e).startsWith("class ");
102
- }
103
-
104
- function m(e) {
105
- return "function" == typeof e;
106
- }
107
-
108
- function M(e) {
109
- return "[object Object]" === Object.prototype.toString.call(e);
110
- }
111
-
112
- function y(e) {
113
- if (!1 === M(e)) return !1;
114
- const t = e.constructor;
115
- if (void 0 === t) return !0;
116
- const i = t.prototype;
117
- return !1 !== M(i) && !1 !== i.hasOwnProperty("isPrototypeOf");
118
- }
119
-
120
- n(v, "isClass"), n(m, "isClassOrFunction"), n(M, "isObject"), n(y, "isPlainObject"),
121
- function(e) {
122
- function t(e) {
123
- return I(e) && "useClass" in e;
124
- }
125
- function i(e) {
126
- return I(e) && "useValue" in e;
127
- }
128
- function o(e) {
129
- return I(e) && "useFactory" in e;
130
- }
131
- function r(e) {
132
- return "string" == typeof e || "symbol" == typeof e || m(e);
133
- }
134
- function s(e) {
135
- return r(e) ? e : e.provide;
136
- }
137
- function d(e) {
138
- return e.map((e => s(e)));
139
- }
140
- function u(e) {
141
- return "symbol" == typeof e || "string" == typeof e ? e.toString() : e.name;
142
- }
143
- function a(e) {
144
- return u(s(e));
145
- }
146
- function p(e, r) {
147
- if (e === r) return !0;
148
- return s(e) === s(r) && (t(e) && t(r) ? e.useClass === r.useClass : i(e) && i(r) ? e.useValue === r.useValue : !o(e) || !o(r) || e.useFactory === r.useFactory);
149
- }
150
- function l(e, t) {
151
- return M(e) ?? g(e) ?? t;
152
- }
153
- function h(e) {
154
- if (I(e)) return e;
155
- }
156
- function M(e) {
157
- const t = h(e);
158
- if (t) return t.scope;
159
- }
160
- function g(e) {
161
- const t = s(e);
162
- if (!v(t)) return;
163
- const i = (0, f.getClassMetadata)(t)?.scope;
164
- return i ? c(i) : void 0;
165
- }
166
- function I(e) {
167
- return y(e) && "object" == typeof e && "provide" in e;
168
- }
169
- n(t, "isClassToken"), e.isClassToken = t, n(i, "isValueToken"), e.isValueToken = i,
170
- n(o, "isFactoryToken"), e.isFactoryToken = o, n(r, "isProviderIdentifier"), e.isProviderIdentifier = r,
171
- n(s, "toProviderIdentifier"), e.toProviderIdentifier = s, n(d, "toProviderIdentifiers"),
172
- e.toProviderIdentifiers = d, n(u, "providerIdentifierToString"), e.providerIdentifierToString = u,
173
- n(a, "providerTokenToString"), e.providerTokenToString = a, n(p, "providerTokensAreEqual"),
174
- e.providerTokensAreEqual = p, n(l, "getInjectionScopeByPriority"), e.getInjectionScopeByPriority = l,
175
- n(h, "tryGetProviderOptions"), e.tryGetProviderOptions = h, n(M, "tryGetScopeFromProvider"),
176
- e.tryGetScopeFromProvider = M, n(g, "tryGetDecoratorScopeFromClass"), e.tryGetDecoratorScopeFromClass = g,
177
- n(I, "hasProvideProperty");
178
- }(h || (h = {}));
179
-
180
- var g, I = class e extends Error {
98
+ var h, f, v = require("@inversifyjs/core"), m = class e extends Error {
181
99
  static {
182
100
  n(this, "InjectionError");
183
101
  }
184
102
  name=e.name;
185
- }, b = class e extends Error {
103
+ }, M = class e extends Error {
186
104
  static {
187
105
  n(this, "InjectionProviderModuleError");
188
106
  }
@@ -194,7 +112,7 @@ var g, I = class e extends Error {
194
112
  } catch {}
195
113
  super(`{ProviderModule.${i}} => ${t}`);
196
114
  }
197
- }, P = class e extends b {
115
+ }, y = class e extends M {
198
116
  static {
199
117
  n(this, "InjectionProviderModuleUnknownProviderError");
200
118
  }
@@ -202,7 +120,7 @@ var g, I = class e extends Error {
202
120
  constructor(e, t) {
203
121
  super(e, `The [${h.providerTokenToString(t)}] provider is of an unknown type!`);
204
122
  }
205
- }, w = class e extends b {
123
+ }, g = class e extends M {
206
124
  static {
207
125
  n(this, "InjectionProviderModuleDisposedError");
208
126
  }
@@ -210,7 +128,7 @@ var g, I = class e extends Error {
210
128
  constructor(e) {
211
129
  super(e, "Has been disposed!");
212
130
  }
213
- }, x = class e extends b {
131
+ }, I = class e extends M {
214
132
  static {
215
133
  n(this, "InjectionProviderModuleMissingIdentifierError");
216
134
  }
@@ -218,7 +136,7 @@ var g, I = class e extends Error {
218
136
  constructor(e) {
219
137
  super(e, "An `identifier` must be supplied!");
220
138
  }
221
- }, E = class e extends b {
139
+ }, b = class e extends M {
222
140
  static {
223
141
  n(this, "InjectionProviderModuleMissingProviderError");
224
142
  }
@@ -226,9 +144,9 @@ var g, I = class e extends Error {
226
144
  constructor(e, t) {
227
145
  super(e, `The [${h.providerTokenToString(t)}] provider is not bound to this (or any imported) module container, and was not found either in the 'AppModule'!`);
228
146
  }
229
- }, S = require("inversify"), D = new (require("inversify").Container)({
147
+ }, P = require("inversify"), w = new (require("inversify").Container)({
230
148
  defaultScope: "Singleton"
231
- }), C = class {
149
+ }), x = class {
232
150
  static {
233
151
  n(this, "ModuleContainer");
234
152
  }
@@ -237,19 +155,19 @@ var g, I = class e extends Error {
237
155
  constructor(e, t) {
238
156
  this.providerModule = e;
239
157
  const {defaultScope: i = u.Singleton} = e.options;
240
- this.container = "AppModule" === e.id ? D : new S.Container({
158
+ this.container = "AppModule" === e.id ? w : new P.Container({
241
159
  parent: t ?? this.providerModule.appModuleRef.moduleContainer.container,
242
160
  defaultScope: l(i)
243
161
  }), this.providerModule.options.providers?.forEach((e => this.bindToContainer(e)));
244
162
  }
245
163
  get(e, t, i) {
246
- const o = this.providerModule.middlewaresManager.applyMiddlewares(a.BeforeGet, this.getProvider(e, i), e, this.getProvider.bind(this));
164
+ const o = this.providerModule.middlewaresManager.applyMiddlewares(p.BeforeGet, this.getProvider(e, i), e, this.getProvider.bind(this));
247
165
  if (o || null === o) return o;
248
- if (!t) throw new E(this.providerModule, e);
166
+ if (!t) throw new b(this.providerModule, e);
249
167
  }
250
168
  getMany(...e) {
251
169
  return e.map((e => {
252
- const t = y(e) && "provider" in e;
170
+ const t = A(e) && "provider" in e;
253
171
  return this.get(t ? e.provider : e, !!t && e.isOptional, !!t && e.asList);
254
172
  }));
255
173
  }
@@ -270,7 +188,7 @@ var g, I = class e extends Error {
270
188
  return t.useFactory(...i);
271
189
  }))), "bind")
272
190
  } ], {bind: o} = i.find((({providerTypeMatches: t}) => t(e))) ?? {};
273
- if (!o) throw new P(this.providerModule, e);
191
+ if (!o) throw new y(this.providerModule, e);
274
192
  const r = h.isProviderIdentifier(e);
275
193
  let s = o();
276
194
  if (h.isValueToken(e) || r || (s = this.setBindingScope(e, s)), r) return;
@@ -300,7 +218,7 @@ var g, I = class e extends Error {
300
218
  optional: !0
301
219
  });
302
220
  }
303
- }, R = require("inversify"), T = class {
221
+ }, E = require("inversify"), S = class {
304
222
  static {
305
223
  n(this, "ImportedModuleContainer");
306
224
  }
@@ -320,14 +238,14 @@ var g, I = class e extends Error {
320
238
  this.proxyContainerOptions = null;
321
239
  }
322
240
  buildProxyContainer() {
323
- const e = new R.ContainerModule((e => {
241
+ const e = new E.ContainerModule((e => {
324
242
  this.proxyContainerOptions = e, this.traverseExportGraph(((e, t) => {
325
243
  this.proxyProviderIdentifier(e, t);
326
244
  }), this.moduleDef.exports), this.providerModule.dynamicModuleDef.event$.subscribe((({type: e, change: t}) => {
327
- if (e !== p.Export && e !== p.ExportRemoved) return;
328
- if (!g.isModule(t)) return void (e === p.Export ? this.proxyProviderIdentifier(t, this.providerModule) : e === p.ExportRemoved && this.unproxyProviderIdentifier(t));
245
+ if (e !== a.Export && e !== a.ExportRemoved) return;
246
+ if (!f.isModule(t)) return void (e === a.Export ? this.proxyProviderIdentifier(t, this.providerModule) : e === a.ExportRemoved && this.unproxyProviderIdentifier(t));
329
247
  const i = t;
330
- e === p.Export ? this.traverseExportGraph(((e, t) => {
248
+ e === a.Export ? this.traverseExportGraph(((e, t) => {
331
249
  this.proxyProviderIdentifier(e, t);
332
250
  }), i.dynamicModuleDef.moduleDef.exports) : this.traverseExportGraph((e => {
333
251
  this.unproxyProviderIdentifier(e);
@@ -340,7 +258,7 @@ var g, I = class e extends Error {
340
258
  const i = h.toProviderIdentifier(e);
341
259
  if (this.proxyContainerOptions.isBound(i)) return;
342
260
  const o = this.proxyContainerOptions.bind(i).toDynamicValue((() => {
343
- if (!1 !== this.providerModule.middlewaresManager.applyMiddlewares(a.OnExportAccess, this.importedIntoModule, i)) return t.moduleContainer.container.get(i);
261
+ if (!1 !== this.providerModule.middlewaresManager.applyMiddlewares(p.OnExportAccess, this.importedIntoModule, i)) return t.moduleContainer.container.get(i);
344
262
  this.proxyContainerOptions.unbind(i);
345
263
  }));
346
264
  this.providerModule.moduleContainer.setBindingScope(e, o);
@@ -352,14 +270,14 @@ var g, I = class e extends Error {
352
270
  traverseExportGraph(e, t) {
353
271
  const i = [];
354
272
  for (const o of t) {
355
- if (o instanceof G) i.push(o); else {
356
- if (!1 === this.providerModule.middlewaresManager.applyMiddlewares(a.OnExportAccess, this.importedIntoModule, o)) continue;
273
+ if (o instanceof B) i.push(o); else {
274
+ if (!1 === this.providerModule.middlewaresManager.applyMiddlewares(p.OnExportAccess, this.importedIntoModule, o)) continue;
357
275
  e(o, this.providerModule);
358
276
  }
359
277
  }
360
278
  for (const t of i) this.traverseExportGraph(e, t.dynamicModuleDef.moduleDef.exports);
361
279
  }
362
- }, B = class {
280
+ }, D = class {
363
281
  static {
364
282
  n(this, "Signal");
365
283
  }
@@ -380,7 +298,7 @@ var g, I = class e extends Error {
380
298
  dispose() {
381
299
  this.subscribers = null, this.value = null;
382
300
  }
383
- }, j = class {
301
+ }, C = class {
384
302
  static {
385
303
  n(this, "DynamicModuleDefinition");
386
304
  }
@@ -388,12 +306,12 @@ var g, I = class e extends Error {
388
306
  return this.providerModule.moduleContainer;
389
307
  }
390
308
  get subscribe() {
391
- if (null === this.event$) throw new w(this.providerModule);
309
+ if (null === this.event$) throw new g(this.providerModule);
392
310
  return this.event$.subscribe.bind(this.event$);
393
311
  }
394
312
  moduleDef;
395
- event$=new B({
396
- type: p.Noop,
313
+ event$=new D({
314
+ type: a.Noop,
397
315
  change: null
398
316
  });
399
317
  providerModule;
@@ -407,75 +325,65 @@ var g, I = class e extends Error {
407
325
  }, this.buildInitialDefinition(e.options);
408
326
  }
409
327
  addImport(e, t = !1) {
410
- let i = g.tryBlueprintToModule(e);
411
- const o = this.providerModule.middlewaresManager.applyMiddlewares(a.BeforeAddImport, i);
328
+ let i = f.tryBlueprintToModule(e);
329
+ const o = this.applyMiddlewareGuard(p.BeforeAddImport, i);
412
330
  !1 !== o && (i = o, this.moduleDef.imports.add(i), this.createImportedModuleContainer(i),
413
331
  this.subscribeToImportedModuleEvents(i), this.emitEventSafely({
414
- type: p.Export,
332
+ type: a.Export,
415
333
  change: i
416
334
  }), this.emitEventSafely({
417
- type: p.Import,
335
+ type: a.Import,
418
336
  change: i
419
337
  }), t && (this.moduleDef.exports.add(i), this.emitEventSafely({
420
- type: p.ExportModule,
338
+ type: a.ExportModule,
421
339
  change: i
422
340
  })));
423
341
  }
424
- async addImportLazy(e, t) {
425
- const i = await e();
426
- this.addImport(i, t);
427
- }
428
342
  addProvider(e, t = !1) {
429
- const i = this.providerModule.middlewaresManager.applyMiddlewares(a.BeforeAddProvider, e);
343
+ const i = this.applyMiddlewareGuard(p.BeforeAddProvider, e);
430
344
  !1 !== i && (e = i, this.moduleDef.providers.add(e), this.moduleContainer.bindToContainer(e),
431
345
  this.emitEventSafely({
432
- type: p.Provider,
346
+ type: a.Provider,
433
347
  change: e
434
348
  }), t && (this.moduleDef.exports.add(e), this.emitEventSafely({
435
- type: p.Export,
349
+ type: a.Export,
436
350
  change: e
437
351
  }), this.emitEventSafely({
438
- type: p.ExportProvider,
352
+ type: a.ExportProvider,
439
353
  change: e
440
354
  })));
441
355
  }
442
- async addProviderLazy(e, t) {
443
- const i = await e();
444
- this.addProvider(i, t);
445
- }
446
356
  removeImport(e) {
447
- const t = g.isModule(e) ? e : this.getImportedModuleById(e);
357
+ const t = f.isModule(e) ? e : this.getImportedModuleById(e);
448
358
  if (!t) return !1;
449
- if (!1 === this.providerModule.middlewaresManager.applyMiddlewares(a.BeforeRemoveImport, t)) return !1;
359
+ if (!1 === this.applyMiddlewareGuard(p.BeforeRemoveImport, t)) return !1;
450
360
  this.unsubscribeFromImportedModuleEvents(t);
451
361
  return this.providerModule.importedModuleContainers.get(t).dispose(), this.providerModule.importedModuleContainers.delete(t),
452
362
  this.moduleDef.imports.delete(t), this.emitEventSafely({
453
- type: p.ImportRemoved,
363
+ type: a.ImportRemoved,
454
364
  change: t
455
365
  }), this.removeFromExports(t), !0;
456
366
  }
457
367
  removeProvider(e) {
458
368
  const t = h.isProviderIdentifier(e) ? this.getProviderByIdentifier(e) : e;
459
- if (!t) return !1;
460
- return !1 !== this.providerModule.middlewaresManager.applyMiddlewares(a.BeforeRemoveProvider, t) && (this.moduleDef.providers.delete(t),
369
+ return !!t && (!1 !== this.applyMiddlewareGuard(p.BeforeRemoveProvider, t) && (this.moduleDef.providers.delete(t),
461
370
  this.moduleContainer.container.unbindSync(h.toProviderIdentifier(t)), this.emitEventSafely({
462
- type: p.ProviderRemoved,
371
+ type: a.ProviderRemoved,
463
372
  change: t
464
- }), this.removeFromExports(t), !0);
373
+ }), this.removeFromExports(t), !0));
465
374
  }
466
375
  removeFromExports(e) {
467
- if (!this.moduleDef.exports.has(e)) return !1;
468
- return !1 !== this.providerModule.middlewaresManager.applyMiddlewares(a.BeforeRemoveExport, e) && (this.moduleDef.exports.delete(e),
376
+ return !!this.moduleDef.exports.has(e) && (!1 !== this.applyMiddlewareGuard(p.BeforeRemoveExport, e) && (this.moduleDef.exports.delete(e),
469
377
  this.emitEventSafely({
470
- type: p.ExportRemoved,
378
+ type: a.ExportRemoved,
471
379
  change: e
472
- }), g.isModule(e) ? this.emitEventSafely({
473
- type: p.ExportModuleRemoved,
380
+ }), f.isModule(e) ? this.emitEventSafely({
381
+ type: a.ExportModuleRemoved,
474
382
  change: e
475
383
  }) : this.emitEventSafely({
476
- type: p.ExportProviderRemoved,
384
+ type: a.ExportProviderRemoved,
477
385
  change: e
478
- }), !0);
386
+ }), !0));
479
387
  }
480
388
  getImportedModuleById(e) {
481
389
  return this.moduleDef.imports.values().find((t => t.id === e));
@@ -496,27 +404,27 @@ var g, I = class e extends Error {
496
404
  }
497
405
  buildInitialDefinition({imports: e = [], providers: t = [], exports: i = []}) {
498
406
  this.moduleDef.providers = new Set(t), i.forEach((e => {
499
- g.isModuleOrBlueprint(e) || this.moduleDef.exports.add(e);
407
+ f.isModuleOrBlueprint(e) || this.moduleDef.exports.add(e);
500
408
  })), e.forEach((e => {
501
- if (g.isModule(e) ? e.options.isGlobal : e.isGlobal) return;
502
- const t = g.tryBlueprintToModule(e), o = i.some((e => g.isModuleOrBlueprint(e) && e.id === t.id));
409
+ if (f.isModule(e) ? e.options.isGlobal : e.isGlobal) return;
410
+ const t = f.tryBlueprintToModule(e), o = i.some((e => f.isModuleOrBlueprint(e) && e.id === t.id));
503
411
  this.addImport(t, o);
504
412
  }));
505
413
  }
506
414
  createImportedModuleContainer(e) {
507
- if (e.isAppModule) throw new b(this.providerModule, "The 'AppModule' can't be imported!");
508
- this.providerModule.importedModuleContainers.set(e, new T(this.providerModule, e));
415
+ if (e.isAppModule) throw new M(this.providerModule, "The 'AppModule' can't be imported!");
416
+ this.providerModule.importedModuleContainers.set(e, new S(this.providerModule, e));
509
417
  }
510
418
  subscribeToImportedModuleEvents(e) {
511
419
  if (this.importedModuleSubscriptions.has(e)) return;
512
420
  const t = e.dynamicModuleDef.event$.subscribe((({type: e, change: t}) => {
513
421
  switch (e) {
514
- case p.Export:
515
- case p.ExportRemoved:
516
- case p.ExportModule:
517
- case p.ExportModuleRemoved:
518
- case p.ExportProvider:
519
- case p.ExportProviderRemoved:
422
+ case a.Export:
423
+ case a.ExportRemoved:
424
+ case a.ExportModule:
425
+ case a.ExportModuleRemoved:
426
+ case a.ExportProvider:
427
+ case a.ExportProviderRemoved:
520
428
  this.emitEventSafely({
521
429
  type: e,
522
430
  change: t
@@ -529,7 +437,11 @@ var g, I = class e extends Error {
529
437
  const t = this.importedModuleSubscriptions.get(e);
530
438
  t && (t(), this.importedModuleSubscriptions.delete(e));
531
439
  }
532
- }, O = class {
440
+ applyMiddlewareGuard(e, t) {
441
+ const i = this.providerModule.middlewaresManager.applyMiddlewares(e, t);
442
+ return !1 !== i && i;
443
+ }
444
+ }, R = class {
533
445
  static {
534
446
  n(this, "MiddlewaresManager");
535
447
  }
@@ -543,29 +455,38 @@ var g, I = class e extends Error {
543
455
  i ? i.push(t) : this.middlewaresMap.set(e, [ t ]);
544
456
  }
545
457
  applyMiddlewares(e, ...t) {
546
- if (null === this.middlewaresMap) throw new w(this.providerModule);
458
+ if (null === this.middlewaresMap) throw new g(this.providerModule);
547
459
  const i = this.middlewaresMap.get(e);
460
+ if (!i) return t[0];
548
461
  switch (e) {
549
- case a.BeforeAddImport:
550
- case a.BeforeAddProvider:
551
- if (!i) return t[0];
552
- let e = t[0];
553
- for (const t of i) {
554
- const i = t(e);
555
- if (!1 === i) return !1;
556
- !0 !== i && (e = i);
557
- }
558
- return e;
559
-
560
- case a.BeforeGet:
561
- return i ? i.reduce(((e, i) => i(e, t[1], t[2])), t[0]) : t[0];
562
-
563
- case a.BeforeRemoveImport:
564
- case a.BeforeRemoveProvider:
565
- case a.BeforeRemoveExport:
566
- case a.OnExportAccess:
567
- return !i || !i.some((e => !e(t[0], t[1])));
462
+ case p.BeforeAddImport:
463
+ case p.BeforeAddProvider:
464
+ return this.applyChainMiddleware(i, ...t);
465
+
466
+ case p.BeforeGet:
467
+ return this.applyReduceMiddleware(i, ...t);
468
+
469
+ case p.BeforeRemoveImport:
470
+ case p.BeforeRemoveProvider:
471
+ case p.BeforeRemoveExport:
472
+ case p.OnExportAccess:
473
+ return this.applyBooleanMiddleware(i, ...t);
474
+ }
475
+ }
476
+ applyChainMiddleware(e, ...t) {
477
+ let i = t[0];
478
+ for (const t of e) {
479
+ const e = t(i);
480
+ if (!1 === e) return !1;
481
+ !0 !== e && (i = e);
568
482
  }
483
+ return i;
484
+ }
485
+ applyReduceMiddleware(e, ...t) {
486
+ return e.reduce(((e, i) => i(e, t[1], t[2])), t[0]);
487
+ }
488
+ applyBooleanMiddleware(e, ...t) {
489
+ return !e.some((e => !e(t[0], t[1])));
569
490
  }
570
491
  clear() {
571
492
  this.middlewaresMap.clear();
@@ -573,7 +494,7 @@ var g, I = class e extends Error {
573
494
  dispose() {
574
495
  this.middlewaresMap = null;
575
496
  }
576
- }, A = class e {
497
+ }, T = class e {
577
498
  static {
578
499
  n(this, "ProviderModuleBlueprint");
579
500
  }
@@ -616,9 +537,9 @@ var g, I = class e extends Error {
616
537
  });
617
538
  }
618
539
  convertToModuleAndInjectIntoAppModuleIfGlobal() {
619
- this.isGlobal && this.blueprintOptions?.autoImportIntoAppModuleWhenGlobal && G.APP_MODULE_REF.update.addImport(this);
540
+ this.isGlobal && this.blueprintOptions?.autoImportIntoAppModuleWhenGlobal && B.APP_MODULE_REF.update.addImport(this);
620
541
  }
621
- }, G = class e {
542
+ }, B = class e {
622
543
  static {
623
544
  n(this, "ProviderModule");
624
545
  }
@@ -649,21 +570,21 @@ var g, I = class e extends Error {
649
570
  importedModuleContainers=new Map;
650
571
  disposed=!1;
651
572
  constructor({appModuleRef: t = e.APP_MODULE_REF, inversify: i, ...o}) {
652
- this.appModuleRef = t, this.options = o, this.throwIfIdIsMissing(), this.middlewaresManager = new O(this),
653
- this.moduleContainer = new C(this, i?.parentContainer), this.dynamicModuleDef = new j(this),
573
+ this.appModuleRef = t, this.options = o, this.throwIfIdIsMissing(), this.middlewaresManager = new R(this),
574
+ this.moduleContainer = new x(this, i?.parentContainer), this.dynamicModuleDef = new C(this),
654
575
  !this.isAppModule && this.options.isGlobal && this.appModuleRef.update.addImport(this, !0),
655
576
  this.options.onReady?.(this);
656
577
  }
657
578
  static create(t) {
658
- const i = g.isBlueprint(t) ? t.getDefinition() : t;
659
- if ("AppModule" === i.id) throw new I("The 'AppModule' id can't be used as it is already being used by the built-in 'AppModule'");
579
+ const i = f.isBlueprint(t) ? t.getDefinition() : t;
580
+ if ("AppModule" === i.id) throw new m("The 'AppModule' id can't be used as it is already being used by the built-in 'AppModule'");
660
581
  return new e(i);
661
582
  }
662
583
  static blueprint(e, t) {
663
- return new A(e, t);
584
+ return new T(e, t);
664
585
  }
665
586
  isImportingModule(e) {
666
- return this.throwIfDisposed(), g.isModule(e) ? this.importedModuleContainers.has(e) : this.importedModuleContainers.keys().some((t => t.id === e));
587
+ return this.throwIfDisposed(), f.isModule(e) ? this.importedModuleContainers.has(e) : this.importedModuleContainers.keys().some((t => t.id === e));
667
588
  }
668
589
  hasProvider(e) {
669
590
  this.throwIfDisposed();
@@ -674,7 +595,7 @@ var g, I = class e extends Error {
674
595
  this.throwIfDisposed();
675
596
  const o = this.moduleContainer.get(e, t, i);
676
597
  return this.dynamicModuleDef.emitEventSafely({
677
- type: p.GetProvider,
598
+ type: a.GetProvider,
678
599
  change: o
679
600
  }), o;
680
601
  }
@@ -682,12 +603,12 @@ var g, I = class e extends Error {
682
603
  return this.throwIfDisposed(), this.moduleContainer.getMany(...e);
683
604
  }
684
605
  isExportingModule(e) {
685
- return this.throwIfDisposed(), !!this.isImportingModule(e) && (g.isModule(e) ? this.definition.exports.has(e) : this.definition.exports.keys().some((t => g.isModule(t) && t.id === e)));
606
+ return this.throwIfDisposed(), !!this.isImportingModule(e) && (f.isModule(e) ? this.definition.exports.has(e) : this.definition.exports.keys().some((t => f.isModule(t) && t.id === e)));
686
607
  }
687
608
  isExportingProvider(e) {
688
609
  this.throwIfDisposed();
689
610
  let t = this.definition.exports.has(e);
690
- return !t && h.isProviderIdentifier(e) && (t = this.definition.exports.keys().some((t => !g.isModuleOrBlueprint(t) && h.toProviderIdentifier(t) === e))),
611
+ return !t && h.isProviderIdentifier(e) && (t = this.definition.exports.keys().some((t => !f.isModuleOrBlueprint(t) && h.toProviderIdentifier(t) === e))),
691
612
  t;
692
613
  }
693
614
  async reset(e = !0) {
@@ -714,15 +635,39 @@ var g, I = class e extends Error {
714
635
  return this.id.toString();
715
636
  }
716
637
  throwIfIdIsMissing() {
717
- if (!this.options.id || 0 === this.options.id.toString().trim().length) throw new x(this);
638
+ if (!this.options.id || 0 === this.options.id.toString().trim().length) throw new I(this);
718
639
  }
719
640
  throwIfDisposed() {
720
- if (this.isDisposed) throw new w(this);
641
+ if (this.isDisposed) throw new g(this);
642
+ }
643
+ }, j = class {
644
+ static {
645
+ n(this, "ProviderModuleClass");
646
+ }
647
+ module;
648
+ constructor(e) {
649
+ this.module = B.create(e);
721
650
  }
722
651
  };
723
652
 
653
+ function O(e) {
654
+ return "[object Object]" === Object.prototype.toString.call(e);
655
+ }
656
+
657
+ function A(e) {
658
+ if (!1 === O(e)) return !1;
659
+ const t = e.constructor;
660
+ if (void 0 === t) return !0;
661
+ const i = t.prototype;
662
+ return !1 !== O(i) && !1 !== i.hasOwnProperty("isPrototypeOf");
663
+ }
664
+
665
+ function G(e) {
666
+ return "function" == typeof e && Function.prototype.toString.call(e).startsWith("class ");
667
+ }
668
+
724
669
  function F(e) {
725
- return "function" == typeof e && !Function.prototype.toString.call(e).startsWith("class ");
670
+ return "function" == typeof e;
726
671
  }
727
672
 
728
673
  function k(e) {
@@ -738,26 +683,84 @@ function q(e) {
738
683
  return void 0 === e ? (0, d.injectable)() : (0, d.injectable)(l(e));
739
684
  }
740
685
 
741
- !function(e) {
686
+ n(O, "isObject"), n(A, "isPlainObject"), n(G, "isClass"), n(F, "isClassOrFunction"),
687
+ function(e) {
688
+ function t(e) {
689
+ return M(e) && "useClass" in e;
690
+ }
691
+ function i(e) {
692
+ return M(e) && "useValue" in e;
693
+ }
694
+ function o(e) {
695
+ return M(e) && "useFactory" in e;
696
+ }
697
+ function r(e) {
698
+ return "string" == typeof e || "symbol" == typeof e || F(e);
699
+ }
700
+ function s(e) {
701
+ return r(e) ? e : e.provide;
702
+ }
703
+ function d(e) {
704
+ return e.map((e => s(e)));
705
+ }
706
+ function u(e) {
707
+ return "symbol" == typeof e || "string" == typeof e ? e.toString() : e.name;
708
+ }
709
+ function p(e) {
710
+ return u(s(e));
711
+ }
712
+ function a(e, r) {
713
+ if (e === r) return !0;
714
+ return s(e) === s(r) && (t(e) && t(r) ? e.useClass === r.useClass : i(e) && i(r) ? e.useValue === r.useValue : !o(e) || !o(r) || e.useFactory === r.useFactory);
715
+ }
716
+ function l(e, t) {
717
+ return f(e) ?? m(e) ?? t;
718
+ }
719
+ function h(e) {
720
+ if (M(e)) return e;
721
+ }
722
+ function f(e) {
723
+ const t = h(e);
724
+ if (t) return t.scope;
725
+ }
726
+ function m(e) {
727
+ const t = s(e);
728
+ if (!G(t)) return;
729
+ const i = (0, v.getClassMetadata)(t)?.scope;
730
+ return i ? c(i) : void 0;
731
+ }
732
+ function M(e) {
733
+ return A(e) && "object" == typeof e && "provide" in e;
734
+ }
735
+ n(t, "isClassToken"), e.isClassToken = t, n(i, "isValueToken"), e.isValueToken = i,
736
+ n(o, "isFactoryToken"), e.isFactoryToken = o, n(r, "isProviderIdentifier"), e.isProviderIdentifier = r,
737
+ n(s, "toProviderIdentifier"), e.toProviderIdentifier = s, n(d, "toProviderIdentifiers"),
738
+ e.toProviderIdentifiers = d, n(u, "providerIdentifierToString"), e.providerIdentifierToString = u,
739
+ n(p, "providerTokenToString"), e.providerTokenToString = p, n(a, "providerTokensAreEqual"),
740
+ e.providerTokensAreEqual = a, n(l, "getInjectionScopeByPriority"), e.getInjectionScopeByPriority = l,
741
+ n(h, "tryGetProviderOptions"), e.tryGetProviderOptions = h, n(f, "tryGetScopeFromProvider"),
742
+ e.tryGetScopeFromProvider = f, n(m, "tryGetDecoratorScopeFromClass"), e.tryGetDecoratorScopeFromClass = m,
743
+ n(M, "hasProvideProperty");
744
+ }(h || (h = {})), function(e) {
742
745
  function t(e) {
743
- return e instanceof G;
746
+ return e instanceof B;
744
747
  }
745
748
  function i(e) {
746
- return e instanceof A;
749
+ return e instanceof T;
747
750
  }
748
751
  function o(e) {
749
752
  return t(e) || i(e);
750
753
  }
751
754
  function r(e) {
752
- return e instanceof A ? s(e) : e;
755
+ return e instanceof T ? s(e) : e;
753
756
  }
754
757
  function s(e) {
755
- return G.create(e.getDefinition());
758
+ return B.create(e.getDefinition());
756
759
  }
757
760
  n(t, "isModule"), e.isModule = t, n(i, "isBlueprint"), e.isBlueprint = i, n(o, "isModuleOrBlueprint"),
758
761
  e.isModuleOrBlueprint = o, n(r, "tryBlueprintToModule"), e.tryBlueprintToModule = r,
759
762
  n(s, "blueprintToModule"), e.blueprintToModule = s;
760
- }(g || (g = {})), n(F, "isFunction"), n(k, "deepClone"), n(q, "Injectable");
763
+ }(f || (f = {})), n(k, "deepClone"), n(q, "Injectable");
761
764
 
762
765
  var $ = require("inversify");
763
766
 
@@ -775,48 +778,32 @@ function U(e) {
775
778
 
776
779
  n(U, "MultiInject");
777
780
 
778
- var L = require("inversify");
781
+ var N = require("inversify");
779
782
 
780
- function N(e) {
781
- return (0, L.injectFromBase)(e);
783
+ function L(e) {
784
+ return (0, N.injectFromBase)(e);
782
785
  }
783
786
 
784
- n(N, "InjectFromBase");
785
-
786
- var W = require("inversify");
787
-
788
- function H(e) {
789
- return (0, W.named)(e);
787
+ function W(e) {
788
+ return (0, N.named)(e);
790
789
  }
791
790
 
792
- n(H, "Named");
793
-
794
- var z = require("inversify");
795
-
796
- function J() {
797
- return (0, z.optional)();
791
+ function H() {
792
+ return (0, N.optional)();
798
793
  }
799
794
 
800
- n(J, "Optional");
801
-
802
- var K = require("inversify");
803
-
804
- function Q(e, t) {
805
- return (0, K.tagged)(e, t);
795
+ function z(e, t) {
796
+ return (0, N.tagged)(e, t);
806
797
  }
807
798
 
808
- n(Q, "Tagged");
809
-
810
- var X = require("inversify");
811
-
812
- function Y() {
813
- return (0, X.unmanaged)();
799
+ function J() {
800
+ return (0, N.unmanaged)();
814
801
  }
815
802
 
816
- n(Y, "Unmanaged");
803
+ n(L, "InjectFromBase"), n(W, "Named"), n(H, "Optional"), n(z, "Tagged"), n(J, "Unmanaged");
817
804
 
818
- var Z = new G({
805
+ var K = new B({
819
806
  id: "AppModule"
820
807
  });
821
808
 
822
- G.APP_MODULE_REF = Z;
809
+ B.APP_MODULE_REF = K;