@adimm/x-injection 0.7.0 → 0.8.0
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 +139 -124
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -26
- package/dist/index.d.ts +38 -26
- package/dist/index.js +115 -98
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -11,29 +11,27 @@ var e, i = Object.defineProperty, t = Object.getOwnPropertyDescriptor, n = Objec
|
|
|
11
11
|
enumerable: !0
|
|
12
12
|
});
|
|
13
13
|
})(s, {
|
|
14
|
-
AppModule: () =>
|
|
14
|
+
AppModule: () => H,
|
|
15
15
|
GLOBAL_APP_MODULE_ID: () => d,
|
|
16
|
-
GlobalAppModule: () =>
|
|
17
|
-
GlobalContainer: () =>
|
|
16
|
+
GlobalAppModule: () => $,
|
|
17
|
+
GlobalContainer: () => q,
|
|
18
18
|
Inject: () => E,
|
|
19
|
-
InjectFromBase: () =>
|
|
20
|
-
Injectable: () =>
|
|
21
|
-
InjectionError: () =>
|
|
22
|
-
InjectionProviderModuleDisposedError: () =>
|
|
23
|
-
InjectionProviderModuleError: () =>
|
|
24
|
-
InjectionProviderModuleGlobalMarkError: () =>
|
|
25
|
-
InjectionProviderModuleMissingIdentifierError: () =>
|
|
19
|
+
InjectFromBase: () => w,
|
|
20
|
+
Injectable: () => I,
|
|
21
|
+
InjectionError: () => G,
|
|
22
|
+
InjectionProviderModuleDisposedError: () => O,
|
|
23
|
+
InjectionProviderModuleError: () => x,
|
|
24
|
+
InjectionProviderModuleGlobalMarkError: () => U,
|
|
25
|
+
InjectionProviderModuleMissingIdentifierError: () => F,
|
|
26
26
|
InjectionScope: () => c,
|
|
27
|
-
MultiInject: () =>
|
|
28
|
-
Named: () =>
|
|
29
|
-
Optional: () =>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
ProviderModule: () => z,
|
|
33
|
-
ProviderModuleHelpers: () => p,
|
|
27
|
+
MultiInject: () => T,
|
|
28
|
+
Named: () => P,
|
|
29
|
+
Optional: () => B,
|
|
30
|
+
ProviderModule: () => W,
|
|
31
|
+
ProviderModuleHelpers: () => f,
|
|
34
32
|
ProviderTokenHelpers: () => h,
|
|
35
|
-
Tagged: () =>
|
|
36
|
-
Unmanaged: () =>
|
|
33
|
+
Tagged: () => D,
|
|
34
|
+
Unmanaged: () => R,
|
|
37
35
|
bindingScopeToInjectionScope: () => l,
|
|
38
36
|
injectionScopeToBindingScope: () => u,
|
|
39
37
|
isClass: () => v,
|
|
@@ -83,7 +81,7 @@ function l(e) {
|
|
|
83
81
|
|
|
84
82
|
o(u, "injectionScopeToBindingScope"), o(l, "bindingScopeToInjectionScope");
|
|
85
83
|
|
|
86
|
-
var h,
|
|
84
|
+
var h, f, p = require("@inversifyjs/core");
|
|
87
85
|
|
|
88
86
|
function v(e) {
|
|
89
87
|
return "function" == typeof e && Function.prototype.toString.call(e).startsWith("class ");
|
|
@@ -97,32 +95,32 @@ function S(e) {
|
|
|
97
95
|
return "function" == typeof e && !Function.prototype.toString.call(e).startsWith("class ");
|
|
98
96
|
}
|
|
99
97
|
|
|
100
|
-
function
|
|
98
|
+
function b(e) {
|
|
101
99
|
return "[object Object]" === Object.prototype.toString.call(e);
|
|
102
100
|
}
|
|
103
101
|
|
|
104
102
|
function m(e) {
|
|
105
|
-
if (!1 ===
|
|
103
|
+
if (!1 === b(e)) return !1;
|
|
106
104
|
const i = e.constructor;
|
|
107
105
|
if (void 0 === i) return !0;
|
|
108
106
|
const t = i.prototype;
|
|
109
|
-
return !1 !==
|
|
107
|
+
return !1 !== b(t) && !1 !== t.hasOwnProperty("isPrototypeOf");
|
|
110
108
|
}
|
|
111
109
|
|
|
112
|
-
function
|
|
110
|
+
function I(e) {
|
|
113
111
|
return void 0 === e ? (0, a.injectable)() : (0, a.injectable)(u(e));
|
|
114
112
|
}
|
|
115
113
|
|
|
116
|
-
o(v, "isClass"), o(g, "isClassOrFunction"), o(S, "isFunction"), o(
|
|
114
|
+
o(v, "isClass"), o(g, "isClassOrFunction"), o(S, "isFunction"), o(b, "isObject"),
|
|
117
115
|
o(m, "isPlainObject"), function(e) {
|
|
118
116
|
function i(e) {
|
|
119
|
-
return
|
|
117
|
+
return b(e) && "useClass" in e;
|
|
120
118
|
}
|
|
121
119
|
function t(e) {
|
|
122
|
-
return
|
|
120
|
+
return b(e) && "useValue" in e;
|
|
123
121
|
}
|
|
124
122
|
function n(e) {
|
|
125
|
-
return
|
|
123
|
+
return b(e) && "useFactory" in e;
|
|
126
124
|
}
|
|
127
125
|
function r(e) {
|
|
128
126
|
return "string" == typeof e || "symbol" == typeof e || g(e);
|
|
@@ -148,22 +146,22 @@ o(m, "isPlainObject"), function(e) {
|
|
|
148
146
|
};
|
|
149
147
|
}
|
|
150
148
|
function c(e, i) {
|
|
151
|
-
return h(e) ??
|
|
149
|
+
return h(e) ?? f(e) ?? i;
|
|
152
150
|
}
|
|
153
151
|
function u(e) {
|
|
154
|
-
if (
|
|
152
|
+
if (b(e)) return e;
|
|
155
153
|
}
|
|
156
154
|
function h(e) {
|
|
157
155
|
const i = u(e);
|
|
158
156
|
if (i) return i.scope;
|
|
159
157
|
}
|
|
160
|
-
function
|
|
158
|
+
function f(e) {
|
|
161
159
|
const i = s(e);
|
|
162
160
|
if (!v(i)) return;
|
|
163
|
-
const t = (0,
|
|
161
|
+
const t = (0, p.getClassMetadata)(i)?.scope;
|
|
164
162
|
return t ? l(t) : void 0;
|
|
165
163
|
}
|
|
166
|
-
function
|
|
164
|
+
function b(e) {
|
|
167
165
|
return m(e) && "object" == typeof e && "provide" in e;
|
|
168
166
|
}
|
|
169
167
|
o(i, "isClassToken"), e.isClassToken = i, o(t, "isValueToken"), e.isValueToken = t,
|
|
@@ -172,7 +170,7 @@ o(m, "isPlainObject"), function(e) {
|
|
|
172
170
|
e.toServiceIdentifiers = d, o(a, "toDependencyProviderWithOptions"), e.toDependencyProviderWithOptions = a,
|
|
173
171
|
o(c, "getInjectionScopeByPriority"), e.getInjectionScopeByPriority = c, o(u, "tryGetProviderOptions"),
|
|
174
172
|
e.tryGetProviderOptions = u, o(h, "tryGetScopeFromProvider"), e.tryGetScopeFromProvider = h,
|
|
175
|
-
o(
|
|
173
|
+
o(f, "tryGetDecoratorScopeFromClass"), e.tryGetDecoratorScopeFromClass = f, o(b, "hasProvideProperty");
|
|
176
174
|
}(h || (h = {})), function(e) {
|
|
177
175
|
function i(e) {
|
|
178
176
|
return e;
|
|
@@ -182,86 +180,70 @@ o(m, "isPlainObject"), function(e) {
|
|
|
182
180
|
}
|
|
183
181
|
o(i, "buildInternalConstructorParams"), e.buildInternalConstructorParams = i, o(t, "isDynamicExport"),
|
|
184
182
|
e.isDynamicExport = t;
|
|
185
|
-
}(
|
|
183
|
+
}(f || (f = {})), o(I, "Injectable");
|
|
186
184
|
|
|
187
|
-
var
|
|
185
|
+
var y = require("inversify");
|
|
188
186
|
|
|
189
187
|
function E(e) {
|
|
190
|
-
return (0,
|
|
188
|
+
return (0, y.inject)(h.toServiceIdentifier(e));
|
|
191
189
|
}
|
|
192
190
|
|
|
193
191
|
o(E, "Inject");
|
|
194
192
|
|
|
195
|
-
var
|
|
193
|
+
var M = require("inversify");
|
|
196
194
|
|
|
197
|
-
function
|
|
198
|
-
return (0,
|
|
195
|
+
function T(e) {
|
|
196
|
+
return (0, M.multiInject)(h.toServiceIdentifier(e));
|
|
199
197
|
}
|
|
200
198
|
|
|
201
|
-
o(
|
|
199
|
+
o(T, "MultiInject");
|
|
202
200
|
|
|
203
|
-
var
|
|
201
|
+
var k = require("inversify");
|
|
204
202
|
|
|
205
|
-
function
|
|
206
|
-
return (0,
|
|
203
|
+
function w(e) {
|
|
204
|
+
return (0, k.injectFromBase)(e);
|
|
207
205
|
}
|
|
208
206
|
|
|
209
|
-
o(
|
|
207
|
+
o(w, "InjectFromBase");
|
|
210
208
|
|
|
211
209
|
var _ = require("inversify");
|
|
212
210
|
|
|
213
|
-
function
|
|
211
|
+
function P(e) {
|
|
214
212
|
return (0, _.named)(e);
|
|
215
213
|
}
|
|
216
214
|
|
|
217
|
-
o(
|
|
215
|
+
o(P, "Named");
|
|
218
216
|
|
|
219
|
-
var
|
|
217
|
+
var j = require("inversify");
|
|
220
218
|
|
|
221
|
-
function
|
|
222
|
-
return (0,
|
|
219
|
+
function B() {
|
|
220
|
+
return (0, j.optional)();
|
|
223
221
|
}
|
|
224
222
|
|
|
225
|
-
o(
|
|
223
|
+
o(B, "Optional");
|
|
226
224
|
|
|
227
|
-
var
|
|
225
|
+
var A = require("inversify");
|
|
228
226
|
|
|
229
|
-
function
|
|
230
|
-
return (0,
|
|
227
|
+
function D(e, i) {
|
|
228
|
+
return (0, A.tagged)(e, i);
|
|
231
229
|
}
|
|
232
230
|
|
|
233
|
-
o(
|
|
231
|
+
o(D, "Tagged");
|
|
234
232
|
|
|
235
233
|
var C = require("inversify");
|
|
236
234
|
|
|
237
235
|
function R() {
|
|
238
|
-
return (0, C.
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
o(R, "PreDestroy");
|
|
242
|
-
|
|
243
|
-
var x = require("inversify");
|
|
244
|
-
|
|
245
|
-
function G(e, i) {
|
|
246
|
-
return (0, x.tagged)(e, i);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
o(G, "Tagged");
|
|
250
|
-
|
|
251
|
-
var O = require("inversify");
|
|
252
|
-
|
|
253
|
-
function F() {
|
|
254
|
-
return (0, O.unmanaged)();
|
|
236
|
+
return (0, C.unmanaged)();
|
|
255
237
|
}
|
|
256
238
|
|
|
257
|
-
o(
|
|
239
|
+
o(R, "Unmanaged");
|
|
258
240
|
|
|
259
|
-
var
|
|
241
|
+
var G = class e extends Error {
|
|
260
242
|
static {
|
|
261
243
|
o(this, "InjectionError");
|
|
262
244
|
}
|
|
263
245
|
name=e.name;
|
|
264
|
-
},
|
|
246
|
+
}, x = class e extends Error {
|
|
265
247
|
static {
|
|
266
248
|
o(this, "InjectionProviderModuleError");
|
|
267
249
|
}
|
|
@@ -269,7 +251,7 @@ var q = class e extends Error {
|
|
|
269
251
|
constructor(e, i) {
|
|
270
252
|
super(`{ProviderModule.${e.toString()}} => ${i}`);
|
|
271
253
|
}
|
|
272
|
-
},
|
|
254
|
+
}, O = class e extends x {
|
|
273
255
|
static {
|
|
274
256
|
o(this, "InjectionProviderModuleDisposedError");
|
|
275
257
|
}
|
|
@@ -277,7 +259,7 @@ var q = class e extends Error {
|
|
|
277
259
|
constructor(e) {
|
|
278
260
|
super(e, "Has been disposed! You can re-initialize it by using the `_lazyInit` method.");
|
|
279
261
|
}
|
|
280
|
-
},
|
|
262
|
+
}, F = class e extends x {
|
|
281
263
|
static {
|
|
282
264
|
o(this, "InjectionProviderModuleMissingIdentifierError");
|
|
283
265
|
}
|
|
@@ -285,7 +267,7 @@ var q = class e extends Error {
|
|
|
285
267
|
constructor(e) {
|
|
286
268
|
super(e, "An `identifier` must be supplied!");
|
|
287
269
|
}
|
|
288
|
-
},
|
|
270
|
+
}, U = class e extends x {
|
|
289
271
|
static {
|
|
290
272
|
o(this, "InjectionProviderModuleGlobalMarkError");
|
|
291
273
|
}
|
|
@@ -293,9 +275,9 @@ var q = class e extends Error {
|
|
|
293
275
|
constructor(e, i) {
|
|
294
276
|
super(e, i);
|
|
295
277
|
}
|
|
296
|
-
},
|
|
278
|
+
}, q = new (require("inversify").Container)({
|
|
297
279
|
defaultScope: "Singleton"
|
|
298
|
-
}),
|
|
280
|
+
}), N = require("inversify"), V = class {
|
|
299
281
|
static {
|
|
300
282
|
o(this, "ProviderModuleUtils");
|
|
301
283
|
}
|
|
@@ -304,7 +286,7 @@ var q = class e extends Error {
|
|
|
304
286
|
}
|
|
305
287
|
module;
|
|
306
288
|
moduleNaked;
|
|
307
|
-
appModule=
|
|
289
|
+
appModule=H;
|
|
308
290
|
constructor(e, i) {
|
|
309
291
|
this.module = e, this.moduleNaked = e.toNaked(), this.appModule = i.appModule?.() ?? this.appModule,
|
|
310
292
|
this.checkIfShouldBeAddedToTheGlobalRegister();
|
|
@@ -313,7 +295,7 @@ var q = class e extends Error {
|
|
|
313
295
|
return h.isProviderIdentifier(e) ? this.bindSelfTokenToContainer(e, i) : h.isClassToken(e) ? this.bindClassTokenToContainer(e, i) : h.isValueToken(e) ? this.bindValueTokenToContainer(e) : !!h.isFactoryToken(e) && this.bindFactoryTokenToContainer(e, i);
|
|
314
296
|
}
|
|
315
297
|
checkIfShouldBeAddedToTheGlobalRegister() {
|
|
316
|
-
!this.moduleNaked.isAppModule && this.module.isMarkedAsGlobal &&
|
|
298
|
+
!this.moduleNaked.isAppModule && this.module.isMarkedAsGlobal && L.add(this.module);
|
|
317
299
|
}
|
|
318
300
|
bindSelfTokenToContainer(e, i) {
|
|
319
301
|
return this.setBindingScope(e, this.container.bind(h.toServiceIdentifier(e)).toSelf(), i),
|
|
@@ -354,7 +336,7 @@ var q = class e extends Error {
|
|
|
354
336
|
const t = e;
|
|
355
337
|
t.onEvent?.activation && i.onActivation(t.onEvent.activation), t.onEvent?.deactivation && i.onDeactivation(t.onEvent.deactivation);
|
|
356
338
|
}
|
|
357
|
-
},
|
|
339
|
+
}, W = class e {
|
|
358
340
|
static {
|
|
359
341
|
o(this, "ProviderModule");
|
|
360
342
|
}
|
|
@@ -373,7 +355,7 @@ var q = class e extends Error {
|
|
|
373
355
|
providers;
|
|
374
356
|
importedProviders;
|
|
375
357
|
exports;
|
|
376
|
-
|
|
358
|
+
registeredSideEffects;
|
|
377
359
|
constructor({identifier: e, imports: i, providers: t, exports: n, defaultScope: r, markAsGlobal: o, dynamicExports: s, onReady: d, onDispose: a, ...c}) {
|
|
378
360
|
const u = c;
|
|
379
361
|
this.identifier = this.setIdentifier(e), this.isDisposed = u.isDisposed ?? !1, this.isAppModule = u.isAppModule ?? !1,
|
|
@@ -400,18 +382,11 @@ var q = class e extends Error {
|
|
|
400
382
|
return this.get(i ? e.provider : e, !!i && e.isOptional);
|
|
401
383
|
}));
|
|
402
384
|
}
|
|
403
|
-
onActivationEvent(e, i) {
|
|
404
|
-
this.shouldThrowIfDisposed(), this.container.onActivation(h.toServiceIdentifier(e), i);
|
|
405
|
-
}
|
|
406
|
-
onDeactivationEvent(e, i) {
|
|
407
|
-
this.shouldThrowIfDisposed(), this.container.onDeactivation(h.toServiceIdentifier(e), i);
|
|
408
|
-
}
|
|
409
385
|
toNaked() {
|
|
410
386
|
return this;
|
|
411
387
|
}
|
|
412
388
|
clone(i) {
|
|
413
|
-
const t = i
|
|
414
|
-
return new e(p.buildInternalConstructorParams({
|
|
389
|
+
const t = i, n = new e(f.buildInternalConstructorParams({
|
|
415
390
|
isAppModule: this.isAppModule,
|
|
416
391
|
markAsGlobal: this.isMarkedAsGlobal,
|
|
417
392
|
identifier: this.identifier,
|
|
@@ -425,67 +400,101 @@ var q = class e extends Error {
|
|
|
425
400
|
exports: [ ...this.exports ],
|
|
426
401
|
...t
|
|
427
402
|
}));
|
|
403
|
+
return n.registeredSideEffects = new Map(this.registeredSideEffects), n;
|
|
428
404
|
}
|
|
429
405
|
async dispose() {
|
|
430
406
|
await (this.onDispose?.(this)), await this.__unbindAll(), this.container = null,
|
|
431
407
|
this.imports = null, this.providers = null, this.importedProviders = null, this.exports = null,
|
|
432
|
-
this.dynamicExports = null, this.
|
|
408
|
+
this.dynamicExports = null, this.registeredSideEffects = null, this.isDisposed = !0;
|
|
433
409
|
}
|
|
434
410
|
toString() {
|
|
435
411
|
return this.identifier?.description ?? "Unknown";
|
|
436
412
|
}
|
|
437
413
|
setIdentifier(e) {
|
|
438
|
-
if (!e) throw new
|
|
414
|
+
if (!e) throw new F(this);
|
|
439
415
|
return e;
|
|
440
416
|
}
|
|
441
417
|
prepareContainer(e) {
|
|
442
|
-
return this.isAppModule ? e.container?.() ??
|
|
443
|
-
e.container()) : new
|
|
444
|
-
parent:
|
|
418
|
+
return this.isAppModule ? e.container?.() ?? q : e.container ? (console.warn(`[xInjection]: The '${this.toString()}' module is using a dynamic container!`),
|
|
419
|
+
e.container()) : new N.Container({
|
|
420
|
+
parent: q,
|
|
445
421
|
defaultScope: this.defaultScope.inversify
|
|
446
422
|
});
|
|
447
423
|
}
|
|
448
424
|
injectImportedModules(i) {
|
|
449
425
|
i && 0 !== i.length && i.forEach((i => {
|
|
450
|
-
if ("GlobalAppModule" === i.toString()) throw new
|
|
426
|
+
if ("GlobalAppModule" === i.toString()) throw new x(this, "The 'GlobalAppModule' can't be imported!");
|
|
451
427
|
const t = (i = "function" == typeof i ? i() : i)._getExportableModulesAndProviders(), n = i.dynamicExports?.(this, t);
|
|
452
428
|
(n ?? t).forEach((t => {
|
|
453
429
|
if (t instanceof e) {
|
|
454
430
|
const e = t.toNaked();
|
|
455
431
|
return void this.injectImportedModules([ e ]);
|
|
456
432
|
}
|
|
457
|
-
const n = t, r = this.importedProvidersMap({
|
|
433
|
+
const n = t, r = h.toServiceIdentifier(n), s = this.importedProvidersMap({
|
|
458
434
|
scope: h.getInjectionScopeByPriority(n, i.defaultScope.native),
|
|
459
|
-
provide:
|
|
435
|
+
provide: r,
|
|
460
436
|
useFactory: o((() => i.get(n)), "useFactory")
|
|
461
437
|
}, n, i);
|
|
462
|
-
this.importedProviders.set(i, [ ...this.importedProviders.get(i) ?? [],
|
|
463
|
-
|
|
438
|
+
this.importedProviders.set(i, [ ...this.importedProviders.get(i) ?? [], s ]), this.moduleUtils.bindToContainer(s, i.defaultScope.native);
|
|
439
|
+
const d = i;
|
|
440
|
+
d.onUnbindInternal(n, this.identifier, (() => this.__unbind(s))), this._onUnbind(s, (() => {
|
|
441
|
+
this.removeOnUnbindEffectsFromImportedModule(r, d);
|
|
442
|
+
}));
|
|
464
443
|
}));
|
|
465
444
|
}));
|
|
466
445
|
}
|
|
467
446
|
injectProviders() {
|
|
468
447
|
this.providers.forEach((e => this.moduleUtils.bindToContainer(e, this.defaultScope.native)));
|
|
469
448
|
}
|
|
470
|
-
|
|
471
|
-
this.
|
|
449
|
+
onUnbindInternal(e, i, t) {
|
|
450
|
+
this.shouldThrowIfDisposed(), this.registerBindingSideEffect(e, "unbind", t, {
|
|
451
|
+
registerModule: i
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
registerBindingSideEffect(e, i, t, n) {
|
|
455
|
+
const r = h.toServiceIdentifier(e);
|
|
456
|
+
this.registeredSideEffects.has(r) || this.registeredSideEffects.set(r, {
|
|
472
457
|
onBindEffects: [],
|
|
458
|
+
onGetEffects: [],
|
|
473
459
|
onRebindEffects: [],
|
|
474
460
|
onUnbindEffects: []
|
|
475
461
|
});
|
|
476
|
-
const
|
|
477
|
-
"bind" === i ?
|
|
462
|
+
const o = this.registeredSideEffects.get(r);
|
|
463
|
+
"bind" === i ? o.onBindEffects.push(t) : "get" === i ? o.onGetEffects.push({
|
|
464
|
+
once: n.once,
|
|
465
|
+
invoked: !1,
|
|
466
|
+
cb: t
|
|
467
|
+
}) : "rebind" === i ? o.onRebindEffects.push(t) : "unbind" === i && o.onUnbindEffects.push({
|
|
468
|
+
registerModule: n?.registerModule,
|
|
469
|
+
cb: t
|
|
470
|
+
});
|
|
478
471
|
}
|
|
479
472
|
invokeRegisteredBindingSideEffects(e, i) {
|
|
480
|
-
const t = this.
|
|
481
|
-
|
|
473
|
+
const t = h.toServiceIdentifier(e), n = this.registeredSideEffects.get(t);
|
|
474
|
+
n && n[`${i}Effects`].forEach((e => {
|
|
475
|
+
if ("function" == typeof e) return e();
|
|
476
|
+
if ("onGet" === i) {
|
|
477
|
+
const i = e;
|
|
478
|
+
if (i.invoked && i.once) return;
|
|
479
|
+
i.invoked = !0;
|
|
480
|
+
}
|
|
481
|
+
e.cb();
|
|
482
|
+
}));
|
|
482
483
|
}
|
|
483
484
|
removeRegisteredBindingSideEffects(e) {
|
|
484
|
-
|
|
485
|
-
|
|
485
|
+
if (!this.registeredSideEffects) return;
|
|
486
|
+
if ("all" === e) return this.registeredSideEffects.forEach((({onUnbindEffects: e}) => e.forEach((e => e.cb())))),
|
|
487
|
+
void this.registeredSideEffects.clear();
|
|
488
|
+
const i = h.toServiceIdentifier(e);
|
|
489
|
+
this.registeredSideEffects.has(i) && (this.registeredSideEffects.get(i)?.onUnbindEffects.forEach((e => e.cb())),
|
|
490
|
+
this.registeredSideEffects.delete(i));
|
|
491
|
+
}
|
|
492
|
+
removeOnUnbindEffectsFromImportedModule(e, i) {
|
|
493
|
+
const t = i.registeredSideEffects.get(e);
|
|
494
|
+
t && (t.onUnbindEffects = t.onUnbindEffects.filter((e => e.registerModule !== this.identifier)));
|
|
486
495
|
}
|
|
487
496
|
shouldThrowIfDisposed() {
|
|
488
|
-
if (null === this.container) throw new
|
|
497
|
+
if (null === this.container) throw new O(this);
|
|
489
498
|
}
|
|
490
499
|
_lazyInit({markAsGlobal: e, imports: i = [], providers: t = [], exports: n = [], defaultScope: r = c.Singleton, dynamicExports: o, onReady: s, onDispose: d, ...a}) {
|
|
491
500
|
return this.isMarkedAsGlobal = e ?? !1, this.isDisposed = !1, this.imports = i,
|
|
@@ -496,9 +505,8 @@ var q = class e extends Error {
|
|
|
496
505
|
}, this.dynamicExports = o, this.onReady = s, this.onDispose = d, this.importedProvidersMap = a.importedProvidersMap ?? (e => e),
|
|
497
506
|
this.container = this.prepareContainer({
|
|
498
507
|
...a
|
|
499
|
-
}), this.moduleUtils = new
|
|
500
|
-
this.
|
|
501
|
-
this.onReady?.(this), this;
|
|
508
|
+
}), this.moduleUtils = new V(this, a), this.registeredSideEffects = new Map, this.injectImportedModules(this._getImportedModules()),
|
|
509
|
+
this.injectProviders(), this.onReady?.(this), this;
|
|
502
510
|
}
|
|
503
511
|
_getImportedModules() {
|
|
504
512
|
return this.shouldThrowIfDisposed(), this.imports;
|
|
@@ -512,6 +520,12 @@ var q = class e extends Error {
|
|
|
512
520
|
_onBind(e, i) {
|
|
513
521
|
this.shouldThrowIfDisposed(), this.registerBindingSideEffect(e, "bind", i);
|
|
514
522
|
}
|
|
523
|
+
_onGet(e, i, t) {
|
|
524
|
+
if (this.shouldThrowIfDisposed(), "boolean" != typeof i) throw new x(this, `The 'once' parameter is required when using the '${this._onGet.name}' method!`);
|
|
525
|
+
this.registerBindingSideEffect(e, "get", t, {
|
|
526
|
+
once: i
|
|
527
|
+
});
|
|
528
|
+
}
|
|
515
529
|
_onRebind(e, i) {
|
|
516
530
|
this.shouldThrowIfDisposed(), this.registerBindingSideEffect(e, "rebind", i);
|
|
517
531
|
}
|
|
@@ -527,7 +541,8 @@ var q = class e extends Error {
|
|
|
527
541
|
return this.invokeRegisteredBindingSideEffects(e, "onBind"), i;
|
|
528
542
|
}
|
|
529
543
|
__get(e, i) {
|
|
530
|
-
return this.shouldThrowIfDisposed(), this.
|
|
544
|
+
return this.shouldThrowIfDisposed(), this.invokeRegisteredBindingSideEffects(e, "onGet"),
|
|
545
|
+
this.container.get(h.toServiceIdentifier(e), i);
|
|
531
546
|
}
|
|
532
547
|
async __getAsync(e, i) {
|
|
533
548
|
return this.shouldThrowIfDisposed(), this.container.getAsync(h.toServiceIdentifier(e), i);
|
|
@@ -571,20 +586,20 @@ var q = class e extends Error {
|
|
|
571
586
|
async __unbindAll() {
|
|
572
587
|
this.shouldThrowIfDisposed(), await this.container.unbindAll(), this.removeRegisteredBindingSideEffects("all");
|
|
573
588
|
}
|
|
574
|
-
},
|
|
589
|
+
}, L = new Set, $ = class extends W {
|
|
575
590
|
static {
|
|
576
591
|
o(this, "GlobalAppModule");
|
|
577
592
|
}
|
|
578
593
|
nakedModule=this;
|
|
579
594
|
isLoaded=!1;
|
|
580
595
|
constructor() {
|
|
581
|
-
super(
|
|
596
|
+
super(f.buildInternalConstructorParams({
|
|
582
597
|
identifier: Symbol(d),
|
|
583
598
|
isAppModule: !0
|
|
584
599
|
}));
|
|
585
600
|
}
|
|
586
601
|
register(e) {
|
|
587
|
-
if (this.isLoaded) throw new
|
|
602
|
+
if (this.isLoaded) throw new G(`The '${this.toString()}' has already been registered!`);
|
|
588
603
|
return this.nakedModule._lazyInit(e), this.checkIfRegisteredModulesHaveGlobalMark(this.toNaked(), this.imports),
|
|
589
604
|
this.isLoaded = !0, this;
|
|
590
605
|
}
|
|
@@ -596,12 +611,12 @@ var q = class e extends Error {
|
|
|
596
611
|
}
|
|
597
612
|
checkIfRegisteredModulesHaveGlobalMark(e, i, t = !1) {
|
|
598
613
|
i.forEach((i => {
|
|
599
|
-
if (i instanceof
|
|
600
|
-
if (i.isMarkedAsGlobal) return
|
|
601
|
-
throw new
|
|
614
|
+
if (i instanceof W) {
|
|
615
|
+
if (i.isMarkedAsGlobal) return L.delete(i), void (i.exports && this.checkIfRegisteredModulesHaveGlobalMark(i, i.exports, !0));
|
|
616
|
+
throw new U(i, t ? `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`!");
|
|
602
617
|
}
|
|
603
|
-
})), t ||
|
|
604
|
-
throw new
|
|
618
|
+
})), t || L.forEach((e => {
|
|
619
|
+
throw new U(e, "Is marked as 'global' and has not been imported into the 'AppModule'!");
|
|
605
620
|
}));
|
|
606
621
|
}
|
|
607
|
-
},
|
|
622
|
+
}, H = new $;//# sourceMappingURL=index.cjs.map
|