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