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