@adimm/x-injection 0.6.4 → 0.7.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 +85 -95
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -56
- package/dist/index.d.ts +17 -56
- package/dist/index.js +70 -79
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -159,7 +159,7 @@ interface IProviderModuleNaked extends IProviderModule {
|
|
|
159
159
|
/** What is exported from this module. */
|
|
160
160
|
readonly exports: StaticExports;
|
|
161
161
|
/** What is exported into this module. */
|
|
162
|
-
readonly imports: IProviderModuleNaked[];
|
|
162
|
+
readonly imports: (IProviderModuleNaked | (() => IProviderModuleNaked))[];
|
|
163
163
|
/** The module dynamic exports method. */
|
|
164
164
|
readonly dynamicExports: DynamicExports | undefined;
|
|
165
165
|
/** The registered `callback` which will be invoked when the internal initialization process has been completed. */
|
|
@@ -211,19 +211,6 @@ interface IProviderModuleNaked extends IProviderModule {
|
|
|
211
211
|
* @param cb Callback which when invoked must return an instance of the {@link Container}.
|
|
212
212
|
*/
|
|
213
213
|
_overwriteContainer(cb: () => Container): void;
|
|
214
|
-
/**
|
|
215
|
-
* Removes all the bindings from the {@link IProviderModuleNaked.container | container}.
|
|
216
|
-
*
|
|
217
|
-
* Then also sets to `null` these properties:
|
|
218
|
-
* - `container`
|
|
219
|
-
* - `imports`
|
|
220
|
-
* - `providers`
|
|
221
|
-
* - `exports`
|
|
222
|
-
* - `dynamicExports`
|
|
223
|
-
*
|
|
224
|
-
* **Note:** The module can be fully re-initialized by invoking the {@link _lazyInit} method.
|
|
225
|
-
*/
|
|
226
|
-
_dispose(): Promise<void>;
|
|
227
214
|
/**
|
|
228
215
|
* Binds a {@link ProviderToken | provider}.
|
|
229
216
|
*
|
|
@@ -419,7 +406,8 @@ declare class ProviderModule implements IProviderModule {
|
|
|
419
406
|
onActivationEvent<T>(provider: ProviderToken<T>, cb: BindingActivation<T>): void;
|
|
420
407
|
onDeactivationEvent<T>(provider: ProviderToken<T>, cb: BindingDeactivation<T>): void;
|
|
421
408
|
toNaked(): IProviderModuleNaked;
|
|
422
|
-
clone(options?:
|
|
409
|
+
clone(options?: Partial<ProviderModuleOptions>): IProviderModule;
|
|
410
|
+
dispose(): Promise<void>;
|
|
423
411
|
toString(): string;
|
|
424
412
|
private setIdentifier;
|
|
425
413
|
private prepareContainer;
|
|
@@ -428,14 +416,7 @@ declare class ProviderModule implements IProviderModule {
|
|
|
428
416
|
private registerBindingSideEffect;
|
|
429
417
|
private invokeRegisteredBindingSideEffects;
|
|
430
418
|
private removeRegisteredBindingSideEffects;
|
|
431
|
-
private shouldThrowWhenModuleDynamicExportsDontMatchTheStaticExports;
|
|
432
419
|
private shouldThrowIfDisposed;
|
|
433
|
-
/**
|
|
434
|
-
* **Publicly visible when the instance is casted to {@link IProviderModuleNaked}.**
|
|
435
|
-
*
|
|
436
|
-
* See {@link IProviderModuleNaked._dispose}.
|
|
437
|
-
*/
|
|
438
|
-
protected _dispose(): Promise<void>;
|
|
439
420
|
/**
|
|
440
421
|
* **Publicly visible when the instance is casted to {@link IProviderModuleNaked}.**
|
|
441
422
|
*
|
|
@@ -447,7 +428,7 @@ declare class ProviderModule implements IProviderModule {
|
|
|
447
428
|
*
|
|
448
429
|
* See {@link IProviderModuleNaked._getImportedModules}.
|
|
449
430
|
*/
|
|
450
|
-
protected _getImportedModules(): IProviderModuleNaked[];
|
|
431
|
+
protected _getImportedModules(): (IProviderModuleNaked | (() => IProviderModuleNaked))[];
|
|
451
432
|
/**
|
|
452
433
|
* **Publicly visible when the instance is casted to {@link IProviderModuleNaked}.**
|
|
453
434
|
*
|
|
@@ -581,8 +562,8 @@ declare class GlobalAppModule extends ProviderModule implements IAppModule {
|
|
|
581
562
|
constructor();
|
|
582
563
|
register<AsNaked extends boolean = false>(options: AppModuleOptions): AsNaked extends false ? IAppModule : IAppModule & IProviderModuleNaked;
|
|
583
564
|
toNaked(): IAppModule & IProviderModuleNaked;
|
|
584
|
-
|
|
585
|
-
private
|
|
565
|
+
dispose(): Promise<void>;
|
|
566
|
+
private checkIfRegisteredModulesHaveGlobalMark;
|
|
586
567
|
}
|
|
587
568
|
/**
|
|
588
569
|
* Special instance of {@link ProviderModule} which acts as the global module of your application in which you can inject any provider
|
|
@@ -605,7 +586,7 @@ interface ProviderModuleOptions {
|
|
|
605
586
|
/** The module unique ID. */
|
|
606
587
|
identifier: symbol;
|
|
607
588
|
/** The list of imported {@link IProviderModule | modules} that export the {@link Provider | providers} which are required in this module. */
|
|
608
|
-
imports?: IProviderModule[];
|
|
589
|
+
imports?: (IProviderModule | (() => IProviderModule))[];
|
|
609
590
|
/** The {@link DependencyProvider | providers} that will be instantiated by the container and that may be shared at least across this module. */
|
|
610
591
|
providers?: DependencyProvider[];
|
|
611
592
|
/**
|
|
@@ -640,11 +621,6 @@ interface ProviderModuleOptions {
|
|
|
640
621
|
* **Note:** _Static {@link ProviderModuleOptions.exports | exports} should always be preferred as their static nature implies predictibility._
|
|
641
622
|
* _This is for advanced use cases only, and most probably you may never need to use a dynamic export!_
|
|
642
623
|
*
|
|
643
|
-
* To keep in mind in order to avoid nasty bugs:
|
|
644
|
-
* - You **must always** return only the providers/modules declared into the static {@link ProviderModuleOptions.exports | exports} array.
|
|
645
|
-
* - You **can** return _less_ providers/modules as long as they are still part of the static {@link ProviderModuleOptions.exports | exports} array.
|
|
646
|
-
* - You **cannot** return _more_ providers/modules than the static {@link ProviderModuleOptions.exports | exports} array!
|
|
647
|
-
*
|
|
648
624
|
* @example
|
|
649
625
|
* ```ts
|
|
650
626
|
* {
|
|
@@ -780,9 +756,15 @@ interface IProviderModule {
|
|
|
780
756
|
* _And also the new module will still refrain values by reference to its parent module because of_
|
|
781
757
|
* _JS limitation in deeply/truly cloning an instance._
|
|
782
758
|
*
|
|
783
|
-
* @param options
|
|
759
|
+
* @param options Apply a new set of {@link ProviderModuleOptions | options}.
|
|
784
760
|
*/
|
|
785
|
-
clone(options?:
|
|
761
|
+
clone(options?: Partial<ProviderModuleOptions>): IProviderModule;
|
|
762
|
+
/**
|
|
763
|
+
* Removes all the bindings from the {@link IProviderModuleNaked.container | container}.
|
|
764
|
+
*
|
|
765
|
+
* **Note:** The module can be fully re-initialized by invoking the {@link _lazyInit} method.
|
|
766
|
+
*/
|
|
767
|
+
dispose(): Promise<void>;
|
|
786
768
|
/** Returns the {@link IProviderModule.identifier} `symbol` description. */
|
|
787
769
|
toString(): string;
|
|
788
770
|
}
|
|
@@ -795,16 +777,6 @@ type ProviderModuleGetManyParam<T> = {
|
|
|
795
777
|
/** When set to `false` _(default)_ an exception will be thrown when the {@link ProviderModuleGetManyParam.provider | provider} isn't bound. */
|
|
796
778
|
isOptional?: boolean;
|
|
797
779
|
};
|
|
798
|
-
interface CloneParams {
|
|
799
|
-
/** Can be used to override all the providers _before_ the binding process. */
|
|
800
|
-
providersMap?: (
|
|
801
|
-
/** The current {@link DependencyProvider | provider}. */
|
|
802
|
-
provider: DependencyProvider<any>,
|
|
803
|
-
/** The {@link IProviderModule | module} from where the {@link DependencyProvider | provider} originated. */
|
|
804
|
-
module: IProviderModule) => DependencyProvider<any>;
|
|
805
|
-
/** Can be used to override all the _imported_ providers _before_ the binding process. */
|
|
806
|
-
importedProvidersMap?: ProviderModuleOptionsInternal['importedProvidersMap'];
|
|
807
|
-
}
|
|
808
780
|
|
|
809
781
|
interface IAppModule extends Except<IProviderModule, 'isMarkedAsGlobal'> {
|
|
810
782
|
/** Must be invoked _(only once during the application lifecycle)_ in order to provide the {@link options} to the module. */
|
|
@@ -857,17 +829,6 @@ declare class InjectionProviderModuleDisposedError extends InjectionProviderModu
|
|
|
857
829
|
constructor(module: IProviderModule);
|
|
858
830
|
}
|
|
859
831
|
|
|
860
|
-
/**
|
|
861
|
-
* Exception which indicates that an instance of {@link IProviderModule}
|
|
862
|
-
* imports another module which dynamically exports its providers/modules and
|
|
863
|
-
* is trying to dynamically export more or different providers/modules than the
|
|
864
|
-
* ones declared into its static exports.
|
|
865
|
-
*/
|
|
866
|
-
declare class InjectionDynamicExportsOutOfRange extends InjectionProviderModuleError {
|
|
867
|
-
name: string;
|
|
868
|
-
constructor(module: IProviderModule);
|
|
869
|
-
}
|
|
870
|
-
|
|
871
832
|
/** Exception which indicates that a module has been initialized without an `identifier`. */
|
|
872
833
|
declare class InjectionProviderModuleMissingIdentifierError extends InjectionProviderModuleError {
|
|
873
834
|
name: string;
|
|
@@ -907,7 +868,7 @@ declare namespace ProviderTokenHelpers {
|
|
|
907
868
|
}
|
|
908
869
|
|
|
909
870
|
declare namespace ProviderModuleHelpers {
|
|
910
|
-
function buildInternalConstructorParams(params: ProviderModuleOptions & ProviderModuleOptionsInternal): ProviderModuleOptions;
|
|
871
|
+
function buildInternalConstructorParams(params: Partial<ProviderModuleOptions & ProviderModuleOptionsInternal>): ProviderModuleOptions;
|
|
911
872
|
function isDynamicExport(exporter: StaticExports | DynamicExports): exporter is DynamicExports;
|
|
912
873
|
}
|
|
913
874
|
|
|
@@ -919,4 +880,4 @@ declare function isFunction(v: any): boolean;
|
|
|
919
880
|
|
|
920
881
|
declare function isClassOrFunction(value: any): value is Function | Class<any>;
|
|
921
882
|
|
|
922
|
-
export { AppModule, type AppModuleOptions, type
|
|
883
|
+
export { AppModule, type AppModuleOptions, type DependencyProvider, type DynamicExports, GLOBAL_APP_MODULE_ID, GlobalAppModule, GlobalContainer, type IAppModule, type IProviderModule, type IProviderModuleNaked, Inject, InjectFromBase, Injectable, InjectionError, InjectionProviderModuleDisposedError, InjectionProviderModuleError, InjectionProviderModuleGlobalMarkError, InjectionProviderModuleMissingIdentifierError, InjectionScope, type LazyInitOptions, MultiInject, Named, type OnEvent, Optional, PostConstruct, PreDestroy, type ProviderClassToken, type ProviderFactoryToken, type ProviderIdentifier, ProviderModule, type ProviderModuleGetManyParam, type ProviderModuleGetManySignature, ProviderModuleHelpers, type ProviderModuleOptions, type ProviderModuleOptionsInternal, type ProviderOptions, type ProviderScopeOption, type ProviderToken, ProviderTokenHelpers, type ProviderValueToken, type StaticExports, Tagged, Unmanaged, bindingScopeToInjectionScope, injectionScopeToBindingScope, isClass, isClassOrFunction, isFunction, isPlainObject };
|
package/dist/index.js
CHANGED
|
@@ -103,13 +103,13 @@ i(f, "isPlainObject"), function(e) {
|
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
function v(e, i) {
|
|
106
|
-
return
|
|
106
|
+
return m(e) ?? S(e) ?? i;
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function g(e) {
|
|
109
109
|
if (y(e)) return e;
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
const i =
|
|
111
|
+
function m(e) {
|
|
112
|
+
const i = g(e);
|
|
113
113
|
if (i) return i.scope;
|
|
114
114
|
}
|
|
115
115
|
function S(e) {
|
|
@@ -125,8 +125,8 @@ i(f, "isPlainObject"), function(e) {
|
|
|
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
127
|
e.toServiceIdentifiers = d, i(l, "toDependencyProviderWithOptions"), e.toDependencyProviderWithOptions = l,
|
|
128
|
-
i(v, "getInjectionScopeByPriority"), e.getInjectionScopeByPriority = v, i(
|
|
129
|
-
e.tryGetProviderOptions =
|
|
128
|
+
i(v, "getInjectionScopeByPriority"), e.getInjectionScopeByPriority = v, i(g, "tryGetProviderOptions"),
|
|
129
|
+
e.tryGetProviderOptions = g, i(m, "tryGetScopeFromProvider"), e.tryGetScopeFromProvider = m,
|
|
130
130
|
i(S, "tryGetDecoratorScopeFromClass"), e.tryGetDecoratorScopeFromClass = S, i(y, "hasProvideProperty");
|
|
131
131
|
}(o || (o = {})), function(e) {
|
|
132
132
|
function t(e) {
|
|
@@ -139,13 +139,13 @@ 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
|
|
|
@@ -155,13 +155,13 @@ function y(e) {
|
|
|
155
155
|
|
|
156
156
|
i(y, "MultiInject");
|
|
157
157
|
|
|
158
|
-
import { injectFromBase as
|
|
158
|
+
import { injectFromBase as b } from "inversify";
|
|
159
159
|
|
|
160
|
-
function
|
|
161
|
-
return
|
|
160
|
+
function I(e) {
|
|
161
|
+
return b(e);
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
i(
|
|
164
|
+
i(I, "InjectFromBase");
|
|
165
165
|
|
|
166
166
|
import { named as E } from "inversify";
|
|
167
167
|
|
|
@@ -171,52 +171,52 @@ function T(e) {
|
|
|
171
171
|
|
|
172
172
|
i(T, "Named");
|
|
173
173
|
|
|
174
|
-
import { optional as
|
|
174
|
+
import { optional as k } from "inversify";
|
|
175
175
|
|
|
176
176
|
function M() {
|
|
177
|
-
return
|
|
177
|
+
return k();
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
i(M, "Optional");
|
|
181
181
|
|
|
182
|
-
import { postConstruct as
|
|
182
|
+
import { postConstruct as w } from "inversify";
|
|
183
183
|
|
|
184
|
-
function
|
|
185
|
-
return
|
|
184
|
+
function B() {
|
|
185
|
+
return w();
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
i(
|
|
188
|
+
i(B, "PostConstruct");
|
|
189
189
|
|
|
190
|
-
import { preDestroy as
|
|
190
|
+
import { preDestroy as _ } from "inversify";
|
|
191
191
|
|
|
192
|
-
function
|
|
193
|
-
return
|
|
192
|
+
function P() {
|
|
193
|
+
return _();
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
i(
|
|
196
|
+
i(P, "PreDestroy");
|
|
197
197
|
|
|
198
|
-
import { tagged as
|
|
198
|
+
import { tagged as D } from "inversify";
|
|
199
199
|
|
|
200
200
|
function A(e, i) {
|
|
201
|
-
return
|
|
201
|
+
return D(e, i);
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
i(A, "Tagged");
|
|
205
205
|
|
|
206
206
|
import { unmanaged as C } from "inversify";
|
|
207
207
|
|
|
208
|
-
function
|
|
208
|
+
function R() {
|
|
209
209
|
return C();
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
i(
|
|
212
|
+
i(R, "Unmanaged");
|
|
213
213
|
|
|
214
214
|
var j = class e extends Error {
|
|
215
215
|
static {
|
|
216
216
|
i(this, "InjectionError");
|
|
217
217
|
}
|
|
218
218
|
name=e.name;
|
|
219
|
-
},
|
|
219
|
+
}, x = class e extends Error {
|
|
220
220
|
static {
|
|
221
221
|
i(this, "InjectionProviderModuleError");
|
|
222
222
|
}
|
|
@@ -224,7 +224,7 @@ var j = class e extends Error {
|
|
|
224
224
|
constructor(e, i) {
|
|
225
225
|
super(`{ProviderModule.${e.toString()}} => ${i}`);
|
|
226
226
|
}
|
|
227
|
-
}, G = class e extends
|
|
227
|
+
}, G = class e extends x {
|
|
228
228
|
static {
|
|
229
229
|
i(this, "InjectionProviderModuleDisposedError");
|
|
230
230
|
}
|
|
@@ -232,15 +232,7 @@ var j = class e extends Error {
|
|
|
232
232
|
constructor(e) {
|
|
233
233
|
super(e, "Has been disposed! You can re-initialize it by using the `_lazyInit` method.");
|
|
234
234
|
}
|
|
235
|
-
}, F = class e extends
|
|
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 R {
|
|
235
|
+
}, F = class e extends x {
|
|
244
236
|
static {
|
|
245
237
|
i(this, "InjectionProviderModuleMissingIdentifierError");
|
|
246
238
|
}
|
|
@@ -248,7 +240,7 @@ var j = class e extends Error {
|
|
|
248
240
|
constructor(e) {
|
|
249
241
|
super(e, "An `identifier` must be supplied!");
|
|
250
242
|
}
|
|
251
|
-
},
|
|
243
|
+
}, O = class e extends x {
|
|
252
244
|
static {
|
|
253
245
|
i(this, "InjectionProviderModuleGlobalMarkError");
|
|
254
246
|
}
|
|
@@ -258,13 +250,13 @@ var j = class e extends Error {
|
|
|
258
250
|
}
|
|
259
251
|
};
|
|
260
252
|
|
|
261
|
-
import { Container as
|
|
253
|
+
import { Container as N } from "inversify";
|
|
262
254
|
|
|
263
|
-
var
|
|
255
|
+
var U = new N({
|
|
264
256
|
defaultScope: "Singleton"
|
|
265
257
|
});
|
|
266
258
|
|
|
267
|
-
import { Container as
|
|
259
|
+
import { Container as V } from "inversify";
|
|
268
260
|
|
|
269
261
|
var q = class {
|
|
270
262
|
static {
|
|
@@ -284,7 +276,7 @@ var q = class {
|
|
|
284
276
|
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
277
|
}
|
|
286
278
|
checkIfShouldBeAddedToTheGlobalRegister() {
|
|
287
|
-
!this.moduleNaked.isAppModule && this.module.isMarkedAsGlobal &&
|
|
279
|
+
!this.moduleNaked.isAppModule && this.module.isMarkedAsGlobal && $.add(this.module);
|
|
288
280
|
}
|
|
289
281
|
bindSelfTokenToContainer(e, i) {
|
|
290
282
|
return this.setBindingScope(e, this.container.bind(o.toServiceIdentifier(e)).toSelf(), i),
|
|
@@ -325,7 +317,7 @@ var q = class {
|
|
|
325
317
|
const t = e;
|
|
326
318
|
t.onEvent?.activation && i.onActivation(t.onEvent.activation), t.onEvent?.deactivation && i.onDeactivation(t.onEvent.deactivation);
|
|
327
319
|
}
|
|
328
|
-
},
|
|
320
|
+
}, W = class e {
|
|
329
321
|
static {
|
|
330
322
|
i(this, "ProviderModule");
|
|
331
323
|
}
|
|
@@ -381,8 +373,8 @@ var q = class {
|
|
|
381
373
|
return this;
|
|
382
374
|
}
|
|
383
375
|
clone(i) {
|
|
384
|
-
|
|
385
|
-
return
|
|
376
|
+
const t = i;
|
|
377
|
+
return new e(r.buildInternalConstructorParams({
|
|
386
378
|
isAppModule: this.isAppModule,
|
|
387
379
|
markAsGlobal: this.isMarkedAsGlobal,
|
|
388
380
|
identifier: this.identifier,
|
|
@@ -390,31 +382,36 @@ var q = class {
|
|
|
390
382
|
dynamicExports: this.dynamicExports,
|
|
391
383
|
onReady: this.onReady,
|
|
392
384
|
onDispose: this.onDispose,
|
|
393
|
-
importedProvidersMap:
|
|
385
|
+
importedProvidersMap: this.importedProvidersMap,
|
|
394
386
|
imports: [ ...this.imports ],
|
|
395
|
-
providers:
|
|
396
|
-
exports: [ ...this.exports ]
|
|
387
|
+
providers: [ ...this.providers ],
|
|
388
|
+
exports: [ ...this.exports ],
|
|
389
|
+
...t
|
|
397
390
|
}));
|
|
398
391
|
}
|
|
392
|
+
async dispose() {
|
|
393
|
+
await (this.onDispose?.(this)), await this.__unbindAll(), this.container = null,
|
|
394
|
+
this.imports = null, this.providers = null, this.importedProviders = null, this.exports = null,
|
|
395
|
+
this.dynamicExports = null, this.registeredBindingSideEffects = null, this.isDisposed = !0;
|
|
396
|
+
}
|
|
399
397
|
toString() {
|
|
400
398
|
return this.identifier?.description ?? "Unknown";
|
|
401
399
|
}
|
|
402
400
|
setIdentifier(e) {
|
|
403
|
-
if (!e) throw new
|
|
401
|
+
if (!e) throw new F(this);
|
|
404
402
|
return e;
|
|
405
403
|
}
|
|
406
404
|
prepareContainer(e) {
|
|
407
|
-
return this.isAppModule ? e.container?.() ??
|
|
408
|
-
e.container()) : new
|
|
409
|
-
parent:
|
|
405
|
+
return this.isAppModule ? e.container?.() ?? U : e.container ? (console.warn(`[xInjection]: The '${this.toString()}' module is using a dynamic container!`),
|
|
406
|
+
e.container()) : new V({
|
|
407
|
+
parent: U,
|
|
410
408
|
defaultScope: this.defaultScope.inversify
|
|
411
409
|
});
|
|
412
410
|
}
|
|
413
411
|
injectImportedModules(t) {
|
|
414
412
|
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),
|
|
413
|
+
if ("GlobalAppModule" === t.toString()) throw new x(this, "The 'GlobalAppModule' can't be imported!");
|
|
414
|
+
const n = (t = "function" == typeof t ? t() : t)._getExportableModulesAndProviders(), r = t.dynamicExports?.(this, n);
|
|
418
415
|
(r ?? n).forEach((n => {
|
|
419
416
|
if (n instanceof e) {
|
|
420
417
|
const e = n.toNaked();
|
|
@@ -450,17 +447,9 @@ var q = class {
|
|
|
450
447
|
this.registeredBindingSideEffects && ("all" !== e ? this.registeredBindingSideEffects.has(e) && (this.registeredBindingSideEffects.get(e)?.onUnbindEffects.forEach((e => e())),
|
|
451
448
|
this.registeredBindingSideEffects.delete(e)) : this.registeredBindingSideEffects.forEach((({onUnbindEffects: e}) => e.forEach((e => e())))));
|
|
452
449
|
}
|
|
453
|
-
shouldThrowWhenModuleDynamicExportsDontMatchTheStaticExports(e, i, t) {
|
|
454
|
-
if (t.length > i.length || t.some((e => !i.includes(e)))) throw new F(e);
|
|
455
|
-
}
|
|
456
450
|
shouldThrowIfDisposed() {
|
|
457
451
|
if (null === this.container) throw new G(this);
|
|
458
452
|
}
|
|
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;
|
|
463
|
-
}
|
|
464
453
|
_lazyInit({markAsGlobal: e, imports: i = [], providers: t = [], exports: n = [], defaultScope: o = s.Singleton, dynamicExports: r, onReady: a, onDispose: c, ...u}) {
|
|
465
454
|
return this.isMarkedAsGlobal = e ?? !1, this.isDisposed = !1, this.imports = i,
|
|
466
455
|
this.providers = t, this.importedProviders = u.importedProviders ?? new Map, this.exports = n,
|
|
@@ -545,7 +534,7 @@ var q = class {
|
|
|
545
534
|
async __unbindAll() {
|
|
546
535
|
this.shouldThrowIfDisposed(), await this.container.unbindAll(), this.removeRegisteredBindingSideEffects("all");
|
|
547
536
|
}
|
|
548
|
-
},
|
|
537
|
+
}, $ = new Set, z = class extends W {
|
|
549
538
|
static {
|
|
550
539
|
i(this, "GlobalAppModule");
|
|
551
540
|
}
|
|
@@ -559,23 +548,25 @@ var q = class {
|
|
|
559
548
|
}
|
|
560
549
|
register(e) {
|
|
561
550
|
if (this.isLoaded) throw new j(`The '${this.toString()}' has already been registered!`);
|
|
562
|
-
return this.nakedModule._lazyInit(e), this.
|
|
563
|
-
this;
|
|
551
|
+
return this.nakedModule._lazyInit(e), this.checkIfRegisteredModulesHaveGlobalMark(this.toNaked(), this.imports),
|
|
552
|
+
this.isLoaded = !0, this;
|
|
564
553
|
}
|
|
565
554
|
toNaked() {
|
|
566
555
|
return super.toNaked();
|
|
567
556
|
}
|
|
568
|
-
async
|
|
569
|
-
this.isLoaded = !1, super.
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
if (
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
557
|
+
async dispose() {
|
|
558
|
+
this.isLoaded = !1, super.dispose();
|
|
559
|
+
}
|
|
560
|
+
checkIfRegisteredModulesHaveGlobalMark(e, i, t = !1) {
|
|
561
|
+
i.forEach((i => {
|
|
562
|
+
if (i instanceof W) {
|
|
563
|
+
if (i.isMarkedAsGlobal) return $.delete(i), void (i.exports && this.checkIfRegisteredModulesHaveGlobalMark(i, i.exports, !0));
|
|
564
|
+
throw new O(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`!");
|
|
565
|
+
}
|
|
566
|
+
})), t || $.forEach((e => {
|
|
567
|
+
throw new O(e, "Is marked as 'global' and has not been imported into the 'AppModule'!");
|
|
577
568
|
}));
|
|
578
569
|
}
|
|
579
|
-
}, H = new
|
|
570
|
+
}, H = new z;
|
|
580
571
|
|
|
581
|
-
export { H as AppModule, t as GLOBAL_APP_MODULE_ID,
|
|
572
|
+
export { H as AppModule, t as GLOBAL_APP_MODULE_ID, z as GlobalAppModule, U as GlobalContainer, m as Inject, I as InjectFromBase, v as Injectable, j as InjectionError, G as InjectionProviderModuleDisposedError, x as InjectionProviderModuleError, O as InjectionProviderModuleGlobalMarkError, F as InjectionProviderModuleMissingIdentifierError, s as InjectionScope, y as MultiInject, T as Named, M as Optional, B as PostConstruct, P as PreDestroy, W as ProviderModule, r as ProviderModuleHelpers, o as ProviderTokenHelpers, A as Tagged, R as Unmanaged, a as bindingScopeToInjectionScope, d as injectionScopeToBindingScope, u as isClass, h as isClassOrFunction, p as isFunction, f as isPlainObject };//# sourceMappingURL=index.js.map
|