@adimm/x-injection 0.6.5 → 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/README.md +0 -6
- package/dist/index.cjs +150 -147
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -80
- package/dist/index.d.ts +53 -80
- package/dist/index.js +136 -130
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -48,36 +48,36 @@ function h(e) {
|
|
|
48
48
|
return "function" == typeof e;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
function
|
|
51
|
+
function f(e) {
|
|
52
52
|
return "function" == typeof e && !Function.prototype.toString.call(e).startsWith("class ");
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
function
|
|
55
|
+
function l(e) {
|
|
56
56
|
return "[object Object]" === Object.prototype.toString.call(e);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
function
|
|
60
|
-
if (!1 ===
|
|
59
|
+
function p(e) {
|
|
60
|
+
if (!1 === l(e)) return !1;
|
|
61
61
|
const i = e.constructor;
|
|
62
62
|
if (void 0 === i) return !0;
|
|
63
63
|
const t = i.prototype;
|
|
64
|
-
return !1 !==
|
|
64
|
+
return !1 !== l(t) && !1 !== t.hasOwnProperty("isPrototypeOf");
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
function v(e) {
|
|
68
68
|
return void 0 === e ? n() : n(d(e));
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
i(u, "isClass"), i(h, "isClassOrFunction"), i(
|
|
72
|
-
i(
|
|
71
|
+
i(u, "isClass"), i(h, "isClassOrFunction"), i(f, "isFunction"), i(l, "isObject"),
|
|
72
|
+
i(p, "isPlainObject"), function(e) {
|
|
73
73
|
function t(e) {
|
|
74
|
-
return
|
|
74
|
+
return b(e) && "useClass" in e;
|
|
75
75
|
}
|
|
76
76
|
function n(e) {
|
|
77
|
-
return
|
|
77
|
+
return b(e) && "useValue" in e;
|
|
78
78
|
}
|
|
79
79
|
function o(e) {
|
|
80
|
-
return
|
|
80
|
+
return b(e) && "useFactory" in e;
|
|
81
81
|
}
|
|
82
82
|
function r(e) {
|
|
83
83
|
return "string" == typeof e || "symbol" == typeof e || h(e);
|
|
@@ -88,12 +88,12 @@ i(f, "isPlainObject"), function(e) {
|
|
|
88
88
|
function d(e) {
|
|
89
89
|
return e.map((e => s(e)));
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function l(e, i) {
|
|
92
92
|
return u(e) ? {
|
|
93
93
|
...i,
|
|
94
94
|
provide: i?.provide ?? e,
|
|
95
95
|
useClass: i?.useClass ?? e
|
|
96
|
-
} :
|
|
96
|
+
} : f(e) ? {
|
|
97
97
|
...i,
|
|
98
98
|
provide: i?.provide ?? e,
|
|
99
99
|
useFactory: i?.useFactory ?? e
|
|
@@ -103,13 +103,13 @@ i(f, "isPlainObject"), function(e) {
|
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
function v(e, i) {
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
function m(e) {
|
|
109
|
-
if (y(e)) return e;
|
|
106
|
+
return m(e) ?? S(e) ?? i;
|
|
110
107
|
}
|
|
111
108
|
function g(e) {
|
|
112
|
-
|
|
109
|
+
if (b(e)) return e;
|
|
110
|
+
}
|
|
111
|
+
function m(e) {
|
|
112
|
+
const i = g(e);
|
|
113
113
|
if (i) return i.scope;
|
|
114
114
|
}
|
|
115
115
|
function S(e) {
|
|
@@ -118,16 +118,16 @@ i(f, "isPlainObject"), function(e) {
|
|
|
118
118
|
const t = c(i)?.scope;
|
|
119
119
|
return t ? a(t) : void 0;
|
|
120
120
|
}
|
|
121
|
-
function
|
|
122
|
-
return
|
|
121
|
+
function b(e) {
|
|
122
|
+
return p(e) && "object" == typeof e && "provide" in e;
|
|
123
123
|
}
|
|
124
124
|
i(t, "isClassToken"), e.isClassToken = t, i(n, "isValueToken"), e.isValueToken = n,
|
|
125
125
|
i(o, "isFactoryToken"), e.isFactoryToken = o, i(r, "isProviderIdentifier"), e.isProviderIdentifier = r,
|
|
126
126
|
i(s, "toServiceIdentifier"), e.toServiceIdentifier = s, i(d, "toServiceIdentifiers"),
|
|
127
|
-
e.toServiceIdentifiers = d, i(
|
|
128
|
-
i(v, "getInjectionScopeByPriority"), e.getInjectionScopeByPriority = v, i(
|
|
129
|
-
e.tryGetProviderOptions =
|
|
130
|
-
i(S, "tryGetDecoratorScopeFromClass"), e.tryGetDecoratorScopeFromClass = S, i(
|
|
127
|
+
e.toServiceIdentifiers = d, i(l, "toDependencyProviderWithOptions"), e.toDependencyProviderWithOptions = l,
|
|
128
|
+
i(v, "getInjectionScopeByPriority"), e.getInjectionScopeByPriority = v, i(g, "tryGetProviderOptions"),
|
|
129
|
+
e.tryGetProviderOptions = g, i(m, "tryGetScopeFromProvider"), e.tryGetScopeFromProvider = m,
|
|
130
|
+
i(S, "tryGetDecoratorScopeFromClass"), e.tryGetDecoratorScopeFromClass = S, i(b, "hasProvideProperty");
|
|
131
131
|
}(o || (o = {})), function(e) {
|
|
132
132
|
function t(e) {
|
|
133
133
|
return e;
|
|
@@ -139,26 +139,26 @@ i(f, "isPlainObject"), function(e) {
|
|
|
139
139
|
e.isDynamicExport = n;
|
|
140
140
|
}(r || (r = {})), i(v, "Injectable");
|
|
141
141
|
|
|
142
|
-
import { inject as
|
|
142
|
+
import { inject as g } from "inversify";
|
|
143
143
|
|
|
144
|
-
function
|
|
145
|
-
return
|
|
144
|
+
function m(e) {
|
|
145
|
+
return g(o.toServiceIdentifier(e));
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
i(
|
|
148
|
+
i(m, "Inject");
|
|
149
149
|
|
|
150
150
|
import { multiInject as S } from "inversify";
|
|
151
151
|
|
|
152
|
-
function
|
|
152
|
+
function b(e) {
|
|
153
153
|
return S(o.toServiceIdentifier(e));
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
i(
|
|
156
|
+
i(b, "MultiInject");
|
|
157
157
|
|
|
158
|
-
import { injectFromBase as
|
|
158
|
+
import { injectFromBase as y } from "inversify";
|
|
159
159
|
|
|
160
160
|
function I(e) {
|
|
161
|
-
return
|
|
161
|
+
return y(e);
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
i(I, "InjectFromBase");
|
|
@@ -179,44 +179,28 @@ function k() {
|
|
|
179
179
|
|
|
180
180
|
i(k, "Optional");
|
|
181
181
|
|
|
182
|
-
import {
|
|
182
|
+
import { tagged as w } from "inversify";
|
|
183
183
|
|
|
184
|
-
function _() {
|
|
185
|
-
return w();
|
|
184
|
+
function _(e, i) {
|
|
185
|
+
return w(e, i);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
i(_, "
|
|
188
|
+
i(_, "Tagged");
|
|
189
189
|
|
|
190
|
-
import {
|
|
190
|
+
import { unmanaged as P } from "inversify";
|
|
191
191
|
|
|
192
|
-
function
|
|
193
|
-
return
|
|
192
|
+
function B() {
|
|
193
|
+
return P();
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
i(
|
|
196
|
+
i(B, "Unmanaged");
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
function A(e, i) {
|
|
201
|
-
return P(e, i);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
i(A, "Tagged");
|
|
205
|
-
|
|
206
|
-
import { unmanaged as C } from "inversify";
|
|
207
|
-
|
|
208
|
-
function x() {
|
|
209
|
-
return C();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
i(x, "Unmanaged");
|
|
213
|
-
|
|
214
|
-
var R = class e extends Error {
|
|
198
|
+
var A = class e extends Error {
|
|
215
199
|
static {
|
|
216
200
|
i(this, "InjectionError");
|
|
217
201
|
}
|
|
218
202
|
name=e.name;
|
|
219
|
-
},
|
|
203
|
+
}, D = class e extends Error {
|
|
220
204
|
static {
|
|
221
205
|
i(this, "InjectionProviderModuleError");
|
|
222
206
|
}
|
|
@@ -224,7 +208,7 @@ var R = class e extends Error {
|
|
|
224
208
|
constructor(e, i) {
|
|
225
209
|
super(`{ProviderModule.${e.toString()}} => ${i}`);
|
|
226
210
|
}
|
|
227
|
-
},
|
|
211
|
+
}, C = class e extends D {
|
|
228
212
|
static {
|
|
229
213
|
i(this, "InjectionProviderModuleDisposedError");
|
|
230
214
|
}
|
|
@@ -232,15 +216,7 @@ var R = class e extends Error {
|
|
|
232
216
|
constructor(e) {
|
|
233
217
|
super(e, "Has been disposed! You can re-initialize it by using the `_lazyInit` method.");
|
|
234
218
|
}
|
|
235
|
-
},
|
|
236
|
-
static {
|
|
237
|
-
i(this, "InjectionDynamicExportsOutOfRange");
|
|
238
|
-
}
|
|
239
|
-
name=e.name;
|
|
240
|
-
constructor(e) {
|
|
241
|
-
super(e, `The 'ProviderModule.${e.toString()}' is trying to dynamically export providers/modules out of the declared range of the static exports!`);
|
|
242
|
-
}
|
|
243
|
-
}, O = class e extends j {
|
|
219
|
+
}, R = class e extends D {
|
|
244
220
|
static {
|
|
245
221
|
i(this, "InjectionProviderModuleMissingIdentifierError");
|
|
246
222
|
}
|
|
@@ -248,7 +224,7 @@ var R = class e extends Error {
|
|
|
248
224
|
constructor(e) {
|
|
249
225
|
super(e, "An `identifier` must be supplied!");
|
|
250
226
|
}
|
|
251
|
-
},
|
|
227
|
+
}, j = class e extends D {
|
|
252
228
|
static {
|
|
253
229
|
i(this, "InjectionProviderModuleGlobalMarkError");
|
|
254
230
|
}
|
|
@@ -258,15 +234,15 @@ var R = class e extends Error {
|
|
|
258
234
|
}
|
|
259
235
|
};
|
|
260
236
|
|
|
261
|
-
import { Container as
|
|
237
|
+
import { Container as x } from "inversify";
|
|
262
238
|
|
|
263
|
-
var
|
|
239
|
+
var G = new x({
|
|
264
240
|
defaultScope: "Singleton"
|
|
265
241
|
});
|
|
266
242
|
|
|
267
|
-
import { Container as
|
|
243
|
+
import { Container as F } from "inversify";
|
|
268
244
|
|
|
269
|
-
var
|
|
245
|
+
var O = class {
|
|
270
246
|
static {
|
|
271
247
|
i(this, "ProviderModuleUtils");
|
|
272
248
|
}
|
|
@@ -275,7 +251,7 @@ var q = class {
|
|
|
275
251
|
}
|
|
276
252
|
module;
|
|
277
253
|
moduleNaked;
|
|
278
|
-
appModule=
|
|
254
|
+
appModule=q;
|
|
279
255
|
constructor(e, i) {
|
|
280
256
|
this.module = e, this.moduleNaked = e.toNaked(), this.appModule = i.appModule?.() ?? this.appModule,
|
|
281
257
|
this.checkIfShouldBeAddedToTheGlobalRegister();
|
|
@@ -284,7 +260,7 @@ var q = class {
|
|
|
284
260
|
return o.isProviderIdentifier(e) ? this.bindSelfTokenToContainer(e, i) : o.isClassToken(e) ? this.bindClassTokenToContainer(e, i) : o.isValueToken(e) ? this.bindValueTokenToContainer(e) : !!o.isFactoryToken(e) && this.bindFactoryTokenToContainer(e, i);
|
|
285
261
|
}
|
|
286
262
|
checkIfShouldBeAddedToTheGlobalRegister() {
|
|
287
|
-
!this.moduleNaked.isAppModule && this.module.isMarkedAsGlobal &&
|
|
263
|
+
!this.moduleNaked.isAppModule && this.module.isMarkedAsGlobal && N.add(this.module);
|
|
288
264
|
}
|
|
289
265
|
bindSelfTokenToContainer(e, i) {
|
|
290
266
|
return this.setBindingScope(e, this.container.bind(o.toServiceIdentifier(e)).toSelf(), i),
|
|
@@ -325,7 +301,7 @@ var q = class {
|
|
|
325
301
|
const t = e;
|
|
326
302
|
t.onEvent?.activation && i.onActivation(t.onEvent.activation), t.onEvent?.deactivation && i.onDeactivation(t.onEvent.deactivation);
|
|
327
303
|
}
|
|
328
|
-
},
|
|
304
|
+
}, U = class e {
|
|
329
305
|
static {
|
|
330
306
|
i(this, "ProviderModule");
|
|
331
307
|
}
|
|
@@ -344,7 +320,7 @@ var q = class {
|
|
|
344
320
|
providers;
|
|
345
321
|
importedProviders;
|
|
346
322
|
exports;
|
|
347
|
-
|
|
323
|
+
registeredSideEffects;
|
|
348
324
|
constructor({identifier: e, imports: i, providers: t, exports: n, defaultScope: o, markAsGlobal: r, dynamicExports: s, onReady: d, onDispose: a, ...c}) {
|
|
349
325
|
const u = c;
|
|
350
326
|
this.identifier = this.setIdentifier(e), this.isDisposed = u.isDisposed ?? !1, this.isAppModule = u.isAppModule ?? !1,
|
|
@@ -367,22 +343,15 @@ var q = class {
|
|
|
367
343
|
}
|
|
368
344
|
getMany(...e) {
|
|
369
345
|
return e.map((e => {
|
|
370
|
-
const i =
|
|
346
|
+
const i = p(e) && "provider" in e;
|
|
371
347
|
return this.get(i ? e.provider : e, !!i && e.isOptional);
|
|
372
348
|
}));
|
|
373
349
|
}
|
|
374
|
-
onActivationEvent(e, i) {
|
|
375
|
-
this.shouldThrowIfDisposed(), this.container.onActivation(o.toServiceIdentifier(e), i);
|
|
376
|
-
}
|
|
377
|
-
onDeactivationEvent(e, i) {
|
|
378
|
-
this.shouldThrowIfDisposed(), this.container.onDeactivation(o.toServiceIdentifier(e), i);
|
|
379
|
-
}
|
|
380
350
|
toNaked() {
|
|
381
351
|
return this;
|
|
382
352
|
}
|
|
383
353
|
clone(i) {
|
|
384
|
-
|
|
385
|
-
return i?.providersMap && (t = t.map((e => i.providersMap(e, this)))), new e(r.buildInternalConstructorParams({
|
|
354
|
+
const t = i, n = new e(r.buildInternalConstructorParams({
|
|
386
355
|
isAppModule: this.isAppModule,
|
|
387
356
|
markAsGlobal: this.isMarkedAsGlobal,
|
|
388
357
|
identifier: this.identifier,
|
|
@@ -390,76 +359,107 @@ var q = class {
|
|
|
390
359
|
dynamicExports: this.dynamicExports,
|
|
391
360
|
onReady: this.onReady,
|
|
392
361
|
onDispose: this.onDispose,
|
|
393
|
-
importedProvidersMap:
|
|
362
|
+
importedProvidersMap: this.importedProvidersMap,
|
|
394
363
|
imports: [ ...this.imports ],
|
|
395
|
-
providers:
|
|
396
|
-
exports: [ ...this.exports ]
|
|
364
|
+
providers: [ ...this.providers ],
|
|
365
|
+
exports: [ ...this.exports ],
|
|
366
|
+
...t
|
|
397
367
|
}));
|
|
368
|
+
return n.registeredSideEffects = new Map(this.registeredSideEffects), n;
|
|
369
|
+
}
|
|
370
|
+
async dispose() {
|
|
371
|
+
await (this.onDispose?.(this)), await this.__unbindAll(), this.container = null,
|
|
372
|
+
this.imports = null, this.providers = null, this.importedProviders = null, this.exports = null,
|
|
373
|
+
this.dynamicExports = null, this.registeredSideEffects = null, this.isDisposed = !0;
|
|
398
374
|
}
|
|
399
375
|
toString() {
|
|
400
376
|
return this.identifier?.description ?? "Unknown";
|
|
401
377
|
}
|
|
402
378
|
setIdentifier(e) {
|
|
403
|
-
if (!e) throw new
|
|
379
|
+
if (!e) throw new R(this);
|
|
404
380
|
return e;
|
|
405
381
|
}
|
|
406
382
|
prepareContainer(e) {
|
|
407
|
-
return this.isAppModule ? e.container?.() ??
|
|
408
|
-
e.container()) : new
|
|
409
|
-
parent:
|
|
383
|
+
return this.isAppModule ? e.container?.() ?? G : e.container ? (console.warn(`[xInjection]: The '${this.toString()}' module is using a dynamic container!`),
|
|
384
|
+
e.container()) : new F({
|
|
385
|
+
parent: G,
|
|
410
386
|
defaultScope: this.defaultScope.inversify
|
|
411
387
|
});
|
|
412
388
|
}
|
|
413
389
|
injectImportedModules(t) {
|
|
414
390
|
t && 0 !== t.length && t.forEach((t => {
|
|
415
|
-
if ("GlobalAppModule" === t.toString()) throw new
|
|
416
|
-
const n = t._getExportableModulesAndProviders(), r = t.dynamicExports?.(this, n);
|
|
417
|
-
void 0 !== r && this.shouldThrowWhenModuleDynamicExportsDontMatchTheStaticExports(t, n, r),
|
|
391
|
+
if ("GlobalAppModule" === t.toString()) throw new D(this, "The 'GlobalAppModule' can't be imported!");
|
|
392
|
+
const n = (t = "function" == typeof t ? t() : t)._getExportableModulesAndProviders(), r = t.dynamicExports?.(this, n);
|
|
418
393
|
(r ?? n).forEach((n => {
|
|
419
394
|
if (n instanceof e) {
|
|
420
395
|
const e = n.toNaked();
|
|
421
396
|
return void this.injectImportedModules([ e ]);
|
|
422
397
|
}
|
|
423
|
-
const r = n, s = this.importedProvidersMap({
|
|
398
|
+
const r = n, s = o.toServiceIdentifier(r), d = this.importedProvidersMap({
|
|
424
399
|
scope: o.getInjectionScopeByPriority(r, t.defaultScope.native),
|
|
425
|
-
provide:
|
|
400
|
+
provide: s,
|
|
426
401
|
useFactory: i((() => t.get(r)), "useFactory")
|
|
427
402
|
}, r, t);
|
|
428
|
-
this.importedProviders.set(t, [ ...this.importedProviders.get(t) ?? [],
|
|
429
|
-
|
|
403
|
+
this.importedProviders.set(t, [ ...this.importedProviders.get(t) ?? [], d ]), this.moduleUtils.bindToContainer(d, t.defaultScope.native);
|
|
404
|
+
const a = t;
|
|
405
|
+
a.onUnbindInternal(r, this.identifier, (() => this.__unbind(d))), this._onUnbind(d, (() => {
|
|
406
|
+
this.removeOnUnbindEffectsFromImportedModule(s, a);
|
|
407
|
+
}));
|
|
430
408
|
}));
|
|
431
409
|
}));
|
|
432
410
|
}
|
|
433
411
|
injectProviders() {
|
|
434
412
|
this.providers.forEach((e => this.moduleUtils.bindToContainer(e, this.defaultScope.native)));
|
|
435
413
|
}
|
|
436
|
-
|
|
437
|
-
this.
|
|
414
|
+
onUnbindInternal(e, i, t) {
|
|
415
|
+
this.shouldThrowIfDisposed(), this.registerBindingSideEffect(e, "unbind", t, {
|
|
416
|
+
registerModule: i
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
registerBindingSideEffect(e, i, t, n) {
|
|
420
|
+
const r = o.toServiceIdentifier(e);
|
|
421
|
+
this.registeredSideEffects.has(r) || this.registeredSideEffects.set(r, {
|
|
438
422
|
onBindEffects: [],
|
|
423
|
+
onGetEffects: [],
|
|
439
424
|
onRebindEffects: [],
|
|
440
425
|
onUnbindEffects: []
|
|
441
426
|
});
|
|
442
|
-
const
|
|
443
|
-
"bind" === i ?
|
|
427
|
+
const s = this.registeredSideEffects.get(r);
|
|
428
|
+
"bind" === i ? s.onBindEffects.push(t) : "get" === i ? s.onGetEffects.push({
|
|
429
|
+
once: n.once,
|
|
430
|
+
invoked: !1,
|
|
431
|
+
cb: t
|
|
432
|
+
}) : "rebind" === i ? s.onRebindEffects.push(t) : "unbind" === i && s.onUnbindEffects.push({
|
|
433
|
+
registerModule: n?.registerModule,
|
|
434
|
+
cb: t
|
|
435
|
+
});
|
|
444
436
|
}
|
|
445
437
|
invokeRegisteredBindingSideEffects(e, i) {
|
|
446
|
-
const t = this.
|
|
447
|
-
|
|
438
|
+
const t = o.toServiceIdentifier(e), n = this.registeredSideEffects.get(t);
|
|
439
|
+
n && n[`${i}Effects`].forEach((e => {
|
|
440
|
+
if ("function" == typeof e) return e();
|
|
441
|
+
if ("onGet" === i) {
|
|
442
|
+
const i = e;
|
|
443
|
+
if (i.invoked && i.once) return;
|
|
444
|
+
i.invoked = !0;
|
|
445
|
+
}
|
|
446
|
+
e.cb();
|
|
447
|
+
}));
|
|
448
448
|
}
|
|
449
449
|
removeRegisteredBindingSideEffects(e) {
|
|
450
|
-
|
|
451
|
-
|
|
450
|
+
if (!this.registeredSideEffects) return;
|
|
451
|
+
if ("all" === e) return this.registeredSideEffects.forEach((({onUnbindEffects: e}) => e.forEach((e => e.cb())))),
|
|
452
|
+
void this.registeredSideEffects.clear();
|
|
453
|
+
const i = o.toServiceIdentifier(e);
|
|
454
|
+
this.registeredSideEffects.has(i) && (this.registeredSideEffects.get(i)?.onUnbindEffects.forEach((e => e.cb())),
|
|
455
|
+
this.registeredSideEffects.delete(i));
|
|
452
456
|
}
|
|
453
|
-
|
|
454
|
-
|
|
457
|
+
removeOnUnbindEffectsFromImportedModule(e, i) {
|
|
458
|
+
const t = i.registeredSideEffects.get(e);
|
|
459
|
+
t && (t.onUnbindEffects = t.onUnbindEffects.filter((e => e.registerModule !== this.identifier)));
|
|
455
460
|
}
|
|
456
461
|
shouldThrowIfDisposed() {
|
|
457
|
-
if (null === this.container) throw new
|
|
458
|
-
}
|
|
459
|
-
async _dispose() {
|
|
460
|
-
await (this.onDispose?.(this)), await this.__unbindAll(), this.container = null,
|
|
461
|
-
this.imports = null, this.providers = null, this.importedProviders = null, this.exports = null,
|
|
462
|
-
this.dynamicExports = null, this.registeredBindingSideEffects = null, this.isDisposed = !0;
|
|
462
|
+
if (null === this.container) throw new C(this);
|
|
463
463
|
}
|
|
464
464
|
_lazyInit({markAsGlobal: e, imports: i = [], providers: t = [], exports: n = [], defaultScope: o = s.Singleton, dynamicExports: r, onReady: a, onDispose: c, ...u}) {
|
|
465
465
|
return this.isMarkedAsGlobal = e ?? !1, this.isDisposed = !1, this.imports = i,
|
|
@@ -470,9 +470,8 @@ var q = class {
|
|
|
470
470
|
}, this.dynamicExports = r, this.onReady = a, this.onDispose = c, this.importedProvidersMap = u.importedProvidersMap ?? (e => e),
|
|
471
471
|
this.container = this.prepareContainer({
|
|
472
472
|
...u
|
|
473
|
-
}), this.moduleUtils = new
|
|
474
|
-
this.
|
|
475
|
-
this.onReady?.(this), this;
|
|
473
|
+
}), this.moduleUtils = new O(this, u), this.registeredSideEffects = new Map, this.injectImportedModules(this._getImportedModules()),
|
|
474
|
+
this.injectProviders(), this.onReady?.(this), this;
|
|
476
475
|
}
|
|
477
476
|
_getImportedModules() {
|
|
478
477
|
return this.shouldThrowIfDisposed(), this.imports;
|
|
@@ -486,6 +485,12 @@ var q = class {
|
|
|
486
485
|
_onBind(e, i) {
|
|
487
486
|
this.shouldThrowIfDisposed(), this.registerBindingSideEffect(e, "bind", i);
|
|
488
487
|
}
|
|
488
|
+
_onGet(e, i, t) {
|
|
489
|
+
if (this.shouldThrowIfDisposed(), "boolean" != typeof i) throw new D(this, `The 'once' parameter is required when using the '${this._onGet.name}' method!`);
|
|
490
|
+
this.registerBindingSideEffect(e, "get", t, {
|
|
491
|
+
once: i
|
|
492
|
+
});
|
|
493
|
+
}
|
|
489
494
|
_onRebind(e, i) {
|
|
490
495
|
this.shouldThrowIfDisposed(), this.registerBindingSideEffect(e, "rebind", i);
|
|
491
496
|
}
|
|
@@ -501,7 +506,8 @@ var q = class {
|
|
|
501
506
|
return this.invokeRegisteredBindingSideEffects(e, "onBind"), i;
|
|
502
507
|
}
|
|
503
508
|
__get(e, i) {
|
|
504
|
-
return this.shouldThrowIfDisposed(), this.
|
|
509
|
+
return this.shouldThrowIfDisposed(), this.invokeRegisteredBindingSideEffects(e, "onGet"),
|
|
510
|
+
this.container.get(o.toServiceIdentifier(e), i);
|
|
505
511
|
}
|
|
506
512
|
async __getAsync(e, i) {
|
|
507
513
|
return this.shouldThrowIfDisposed(), this.container.getAsync(o.toServiceIdentifier(e), i);
|
|
@@ -545,7 +551,7 @@ var q = class {
|
|
|
545
551
|
async __unbindAll() {
|
|
546
552
|
this.shouldThrowIfDisposed(), await this.container.unbindAll(), this.removeRegisteredBindingSideEffects("all");
|
|
547
553
|
}
|
|
548
|
-
},
|
|
554
|
+
}, N = new Set, V = class extends U {
|
|
549
555
|
static {
|
|
550
556
|
i(this, "GlobalAppModule");
|
|
551
557
|
}
|
|
@@ -558,26 +564,26 @@ var q = class {
|
|
|
558
564
|
}));
|
|
559
565
|
}
|
|
560
566
|
register(e) {
|
|
561
|
-
if (this.isLoaded) throw new
|
|
567
|
+
if (this.isLoaded) throw new A(`The '${this.toString()}' has already been registered!`);
|
|
562
568
|
return this.nakedModule._lazyInit(e), this.checkIfRegisteredModulesHaveGlobalMark(this.toNaked(), this.imports),
|
|
563
569
|
this.isLoaded = !0, this;
|
|
564
570
|
}
|
|
565
571
|
toNaked() {
|
|
566
572
|
return super.toNaked();
|
|
567
573
|
}
|
|
568
|
-
async
|
|
569
|
-
this.isLoaded = !1, super.
|
|
574
|
+
async dispose() {
|
|
575
|
+
this.isLoaded = !1, super.dispose();
|
|
570
576
|
}
|
|
571
577
|
checkIfRegisteredModulesHaveGlobalMark(e, i, t = !1) {
|
|
572
578
|
i.forEach((i => {
|
|
573
|
-
if (i instanceof
|
|
574
|
-
if (i.isMarkedAsGlobal) return
|
|
575
|
-
throw new
|
|
579
|
+
if (i instanceof U) {
|
|
580
|
+
if (i.isMarkedAsGlobal) return N.delete(i), void (i.exports && this.checkIfRegisteredModulesHaveGlobalMark(i, i.exports, !0));
|
|
581
|
+
throw new j(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`!");
|
|
576
582
|
}
|
|
577
|
-
})), t ||
|
|
578
|
-
throw new
|
|
583
|
+
})), t || N.forEach((e => {
|
|
584
|
+
throw new j(e, "Is marked as 'global' and has not been imported into the 'AppModule'!");
|
|
579
585
|
}));
|
|
580
586
|
}
|
|
581
|
-
},
|
|
587
|
+
}, q = new V;
|
|
582
588
|
|
|
583
|
-
export {
|
|
589
|
+
export { q as AppModule, t as GLOBAL_APP_MODULE_ID, V as GlobalAppModule, G as GlobalContainer, m as Inject, I as InjectFromBase, v as Injectable, A as InjectionError, C as InjectionProviderModuleDisposedError, D as InjectionProviderModuleError, j as InjectionProviderModuleGlobalMarkError, R as InjectionProviderModuleMissingIdentifierError, s as InjectionScope, b as MultiInject, T as Named, k as Optional, U as ProviderModule, r as ProviderModuleHelpers, o as ProviderTokenHelpers, _ as Tagged, B as Unmanaged, a as bindingScopeToInjectionScope, d as injectionScopeToBindingScope, u as isClass, h as isClassOrFunction, f as isFunction, p as isPlainObject };//# sourceMappingURL=index.js.map
|