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