@adimm/x-injection 1.1.5 → 1.2.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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { BindingActivation, BindingDeactivation, BindingConstraints, Container, BindingScope, BindToFluentSyntax, GetOptions, IsBoundOptions, injectFromBase, MetadataName, MetadataTag, ServiceIdentifier } from 'inversify';
2
- import { Class, Except } from 'type-fest';
1
+ import { BindingActivation, BindingDeactivation, BindingConstraints, Container, BindToFluentSyntax, GetOptions, IsBoundOptions, BindingScope, injectFromBase, MetadataName, MetadataTag, ServiceIdentifier } from 'inversify';
2
+ import { Class, RequireAtLeastOne, Except } from 'type-fest';
3
3
 
4
4
  /** The identifier of the `GlobalAppModule`. */
5
5
  declare const GLOBAL_APP_MODULE_ID = "GlobalAppModule";
@@ -95,254 +95,6 @@ interface ProviderScopeOption {
95
95
  scope?: InjectionScope;
96
96
  }
97
97
 
98
- /**
99
- * Class containing an internal set of `utils`.
100
- *
101
- * Each {@link IProviderModuleNaked.moduleUtils | ProviderModule} instance has its own {@link ProviderModuleUtils} property instance.
102
- */
103
- declare class ProviderModuleUtils {
104
- /** The low-level InversifyJS {@link Container} owned by {@link ProviderModuleUtils.module | module}. */
105
- get container(): Container;
106
- /** The parent {@link IProviderModule | ProviderModule} of `this` instance. */
107
- readonly module: IProviderModule;
108
- readonly moduleNaked: IProviderModuleNaked;
109
- private readonly appModule;
110
- constructor(module: IProviderModule, internalOptions: ProviderModuleOptionsInternal);
111
- /**
112
- * Low-level method which can be used to manually register _(bind)_ a new {@link provider} into the {@link ProviderModuleUtils.module | module} container.
113
- *
114
- * **Note:** _You shouldn't directly use this to register providers as they will not appear_
115
- * _into the module's `imports` and `exports` arrays! Therefore leading to unexpected bugs and confusion!_
116
- *
117
- * @param provider The {@link ProviderToken | provider} to register.
118
- * @param defaultScope Optionally provide the default {@link InjectionScope} to use when applicable.
119
- * @returns `true` when the {@link provider} has been bound otherwhise `false`.
120
- */
121
- bindToContainer<T>(provider: DependencyProvider<T>, defaultScope: InjectionScope): boolean;
122
- private checkIfShouldBeAddedToTheGlobalRegister;
123
- private bindSelfTokenToContainer;
124
- private bindClassTokenToContainer;
125
- private bindValueTokenToContainer;
126
- private bindFactoryTokenToContainer;
127
- /** Sets the {@link InjectionScope} of a bound {@link provider}. */
128
- private setBindingScope;
129
- /** Sets the `when` clause of a bound {@link provider}. */
130
- private setWhenBinding;
131
- /** Sets the `activation` and `deactivation` events of a bound {@link provider}. */
132
- private setBindingOnEvent;
133
- }
134
-
135
- /** Can be used to publicly expose internal properties and methods of an {@link IProviderModule} instance. */
136
- interface IProviderModuleNaked extends IProviderModule {
137
- /** It'll be true when the current module is the global `AppModule`. */
138
- readonly isAppModule: boolean;
139
- /** The low-level `InversifyJS` {@link https://inversify.io/docs/api/container/ | container} instance. */
140
- readonly container: Container;
141
- /** The default injection scope of this module. */
142
- readonly defaultScope: {
143
- /** Scope from `xInjection` {@link InjectionScope} enum. */
144
- native: InjectionScope;
145
- /** Scope from `InversifyJS` {@link BindingScope} string union. */
146
- inversify: BindingScope;
147
- };
148
- /** Instance of the {@link ProviderModuleUtils}. */
149
- readonly moduleUtils: ProviderModuleUtils;
150
- /** The {@link DependencyProvider | providers} resolved by this module. */
151
- readonly providers: DependencyProvider[];
152
- /**
153
- * The imported {@link DependencyProvider | providers} resolved by this module.
154
- *
155
- * _It is a `dictionary` where the key is the {@link IProviderModule | module} and the value an_
156
- * _array containing the imported dependencies from that module_
157
- */
158
- readonly importedProviders: Map<IProviderModuleNaked, DependencyProvider[]>;
159
- /** What is exported from this module. */
160
- readonly exports: StaticExports;
161
- /** What is exported into this module. */
162
- readonly imports: (IProviderModuleNaked | (() => IProviderModuleNaked))[];
163
- /** The module dynamic exports method. */
164
- readonly dynamicExports: DynamicExports | undefined;
165
- /** The registered `callback` which will be invoked when the internal initialization process has been completed. */
166
- readonly onReady: ProviderModuleOptions['onReady'];
167
- /** The registered `callback` which will be invoked when the {@link _dispose} method is invoked. */
168
- readonly onDispose: ProviderModuleOptions['onDispose'];
169
- /** Can be used to override all the _imported_ providers _before_ the binding process. */
170
- readonly importedProvidersMap: ProviderModuleOptionsInternal['importedProvidersMap'];
171
- readonly registeredSideEffects: RegisteredSideEffects;
172
- /** It'll _completely_ re-init the `module` with the provided {@link LazyInitOptions | options}. */
173
- _lazyInit(options: LazyInitOptions): IProviderModule;
174
- /** Can be used to get the list of all the imported modules of this module. */
175
- _getImportedModules(): IProviderModuleNaked[];
176
- /** Can be used to get the list of all the providers of this module. */
177
- _getProviders(): DependencyProvider[];
178
- /** Can be used to get the list of all the exportable modules and providers of this module. */
179
- _getExportableModulesAndProviders(): StaticExports;
180
- /**
181
- * Can be used to execute the provided {@link cb | callback} whenever a _new_ {@link https://inversify.io/docs/fundamentals/binding/ | binding}
182
- * is registered for the {@link provider}.
183
- *
184
- * @param provider The {@link ProviderToken}.
185
- * @param cb The `callback` to be invoked.
186
- */
187
- _onBind<T>(provider: ProviderToken<T>, cb: () => Promise<void> | void): void;
188
- /**
189
- * Can be used to execute the provided {@link cb | callback} whenever the
190
- * {@link IProviderModule.get | get} method is invoked.
191
- *
192
- * @param provider The {@link ProviderToken}.
193
- * @param once When set to `true` it'll invoke the provided {@link cb | callback} only once.
194
- * @param cb The `callback` to be invoked.
195
- */
196
- _onGet<T>(provider: ProviderToken<T>, once: boolean, cb: () => Promise<void> | void): void;
197
- /**
198
- * Can be used to execute the provided {@link cb | callback} whenever an existing {@link https://inversify.io/docs/fundamentals/binding/ | binding}
199
- * is re-registered for the {@link provider}.
200
- *
201
- * @param provider The {@link ProviderToken}.
202
- * @param cb The `callback` to be invoked.
203
- */
204
- _onRebind<T>(provider: ProviderToken<T>, cb: () => Promise<void> | void): void;
205
- /**
206
- * Can be used to execute the provided {@link cb | callback} whenever a {@link provider} is `unbound`.
207
- *
208
- * **Note:** _All the {@link _onBind}, {@link _onGet}, {@link _onRebind} and {@link _onUnbind} registered callbacks will be removed_
209
- *
210
- * @param provider The {@link ProviderToken}.
211
- * @param cb The `callback` to be invoked.
212
- */
213
- _onUnbind<T>(provider: ProviderToken<T>, cb: () => Promise<void> | void): void;
214
- /**
215
- * Internal method which can be used to completely overwrite the module {@link container}
216
- * with the one provided.
217
- *
218
- * @param cb Callback which when invoked must return an instance of the {@link Container}.
219
- */
220
- _overwriteContainer(cb: () => Container): void;
221
- /**
222
- * Binds a {@link ProviderToken | provider}.
223
- *
224
- * See {@link https://inversify.io/docs/api/container/#bind | Container.bind} for more details.
225
- */
226
- __bind<T>(provider: ProviderToken<T>): BindToFluentSyntax<T>;
227
- /**
228
- * Resolves a dependency by its runtime identifier.
229
- * The runtime identifier must be associated with only one binding and the binding must be synchronously resolved,
230
- * otherwise an error is thrown.
231
- *
232
- * @param provider The {@link ProviderToken}.
233
- * @param options The {@link GetOptions}.
234
- * @returns Either the {@link T | dependency} or `undefined` if {@link GetOptions.optional} is set to `true`.
235
- *
236
- * See {@link https://inversify.io/docs/api/container/#get | Container.get} for more details.
237
- */
238
- __get<T>(provider: ProviderToken<T>, options?: GetOptions): T;
239
- /**
240
- * Resolves a dependency by its runtime identifier.
241
- * The runtime identifier must be associated with only one binding,
242
- * otherwise an error is thrown.
243
- *
244
- * @param provider The {@link ProviderToken}.
245
- * @param options The {@link GetOptions}.
246
- * @returns Either the {@link T | dependency} or `undefined` if {@link GetOptions.optional} is set to `true`.
247
- *
248
- * See {@link https://inversify.io/docs/api/container/#getasync | Container.getAsync} for more details.
249
- */
250
- __getAsync<T>(provider: ProviderToken<T>, options?: GetOptions): Promise<T>;
251
- /** See {@link https://inversify.io/docs/api/container/#getall | Container.getAll} for more details. */
252
- __getAll<T>(provider: ProviderToken<T>, options?: GetOptions): T[];
253
- /** See {@link https://inversify.io/docs/api/container/#getallasync | Container.getAllAsync} for more details. */
254
- __getAllAsync<T>(provider: ProviderToken<T>, options?: GetOptions): Promise<T[]>;
255
- /**
256
- * Can be used to check if there are registered bindings for the {@link provider | provider}.
257
- *
258
- * See {@link https://inversify.io/docs/api/container/#isbound | Container.isBound} for more details.
259
- */
260
- __isBound(provider: ProviderToken, options?: IsBoundOptions): boolean;
261
- /**
262
- * Can be useed to check if there are registered bindings for the {@link provider | provider} only in the current container.
263
- *
264
- * See {@link https://inversify.io/docs/api/container/#iscurrentbound | Container.isCurrentBound} for more details.
265
- */
266
- __isCurrentBound(provider: ProviderToken, options?: IsBoundOptions): boolean;
267
- /**
268
- * Save the state of the container to be later restored with the restore method.
269
- *
270
- * See {@link https://inversify.io/docs/api/container/#snapshot | Container.snapshot} for more details.
271
- */
272
- __takeSnapshot(): void;
273
- /**
274
- * Restore container state to last snapshot.
275
- *
276
- * See {@link https://inversify.io/docs/api/container/#restore | Container.restore} for more details.
277
- */
278
- __restoreSnapshot(): void;
279
- /**
280
- * Convenience method that unbinds a {@link ProviderToken | provider} and then creates a new binding for it.
281
- * This is equivalent to calling await `container.unbind` followed by `container.bind`, but in a single method.
282
- *
283
- * @param provider The {@link ProviderToken}.
284
- * @returns A {@link BindToFluentSyntax | binding builder} to continue configuring the new binding.
285
- *
286
- * See {@link https://inversify.io/docs/api/container/#rebind | Container.rebind} for more details.
287
- */
288
- __rebind<T>(provider: ProviderToken<T>): Promise<BindToFluentSyntax<T>>;
289
- /**
290
- * Synchronous version of {@link __rebindProvider}. Unbinds a {@link ProviderToken | provider} synchronously and then creates a new binding for it.
291
- * Will throw an error if the unbind operation would be asynchronous.
292
- *
293
- * @param provider The {@link ProviderToken}.
294
- * @returns A {@link BindToFluentSyntax | binding builder} to continue configuring the new binding.
295
- *
296
- * See {@link https://inversify.io/docs/api/container/#rebindsync | Container.rebindSync} for more details.
297
- */
298
- __rebindSync<T>(provider: ProviderToken<T>): BindToFluentSyntax<T>;
299
- /**
300
- * Removes **all** the associated bindings with the {@link provider} from the container.
301
- *
302
- * This will result in the {@link https://inversify.io/docs/fundamentals/lifecycle/deactivation/ | deactivation process}.
303
- *
304
- * See {@link https://inversify.io/docs/api/container/#unbind | Container.unbind} for more details.
305
- */
306
- __unbind(provider: ProviderToken): Promise<void>;
307
- /**
308
- * Removes **all** the associated bindings with the {@link provider} from the container synchronously.
309
- * This method works like {@link __unbind} but does not return a Promise.
310
- * If the unbinding operation would be asynchronous (e.g. due to deactivation handlers),
311
- * it will throw an error. Use this method when you know the operation won't involve async deactivations.
312
- *
313
- * This will result in the {@link https://inversify.io/docs/fundamentals/lifecycle/deactivation/ | deactivation process}.
314
- *
315
- * See {@link https://inversify.io/docs/api/container/#unbindsync | Container.unbindSync} for more details.
316
- */
317
- __unbindSync(provider: ProviderToken): void;
318
- /**
319
- * Remove all bindings bound in this container.
320
- *
321
- * This will result in the {@link https://inversify.io/docs/fundamentals/lifecycle/deactivation/ | deactivation process}.
322
- *
323
- * See {@link https://inversify.io/docs/api/container/#unbindall | Container.unbindAll} for more details.
324
- */
325
- __unbindAll(): Promise<void>;
326
- }
327
- type LazyInitOptions = Except<ProviderModuleOptions & ProviderModuleOptionsInternal, 'identifier' | 'isAppModule'>;
328
- type RegisteredSideEffects = Map<ProviderToken, {
329
- onBindEffects: OnBindEffects[];
330
- onGetEffects: OnGetEffects[];
331
- onRebindEffects: OnRebindEffects[];
332
- onUnbindEffects: OnUnbindEffects[];
333
- }>;
334
- type OnBindEffects = () => Promise<void> | void;
335
- type OnGetEffects = {
336
- once: boolean;
337
- invoked: boolean;
338
- cb: () => Promise<void> | void;
339
- };
340
- type OnRebindEffects = () => Promise<void> | void;
341
- type OnUnbindEffects = {
342
- registerModule?: symbol;
343
- cb: () => Promise<void> | void;
344
- };
345
-
346
98
  /**
347
99
  * The low-level App Container.
348
100
  *
@@ -356,6 +108,8 @@ declare const GlobalContainer: Container;
356
108
  *
357
109
  * _See {@link ProviderModuleOptions | ProviderModuleOptions}_.
358
110
  *
111
+ * **Note:** _Check also the {@link IProviderModuleDefinition}._
112
+ *
359
113
  * @example
360
114
  * ```ts
361
115
  * const EngineModule = new ProviderModule({
@@ -408,63 +162,41 @@ declare const GlobalContainer: Container;
408
162
  * ```
409
163
  */
410
164
  declare class ProviderModule implements IProviderModule {
411
- readonly identifier: symbol;
412
- readonly isMarkedAsGlobal: boolean;
413
- readonly isDisposed: boolean;
414
- protected readonly isAppModule: boolean;
415
- protected readonly container: Container;
416
- protected readonly defaultScope: IProviderModuleNaked['defaultScope'];
417
- protected readonly dynamicExports: IProviderModuleNaked['dynamicExports'];
418
- protected readonly onReady: IProviderModuleNaked['onReady'];
419
- protected readonly onDispose: IProviderModuleNaked['onDispose'];
420
- protected readonly importedProvidersMap: IProviderModuleNaked['importedProvidersMap'];
421
- protected readonly moduleUtils: IProviderModuleNaked['moduleUtils'];
422
- protected readonly imports: IProviderModuleNaked['imports'];
423
- protected readonly providers: IProviderModuleNaked['providers'];
424
- protected readonly importedProviders: IProviderModuleNaked['importedProviders'];
425
- protected readonly exports: IProviderModuleNaked['exports'];
426
- protected readonly registeredSideEffects: IProviderModuleNaked['registeredSideEffects'];
427
- constructor({ identifier, imports, providers, exports, defaultScope, markAsGlobal, dynamicExports, onReady, onDispose, ..._internalParams }: ProviderModuleOptions);
165
+ isDisposed: boolean;
166
+ readonly identifier: ModuleIdentifier;
167
+ isGlobal: boolean;
168
+ protected isAppModule: IProviderModuleNaked['isAppModule'];
169
+ protected instantiatedFromDefinition: IProviderModuleNaked['instantiatedFromDefinition'];
170
+ protected container: Container;
171
+ protected defaultScope: IProviderModuleNaked['defaultScope'];
172
+ protected onReady: IProviderModuleNaked['onReady'];
173
+ protected onDispose: IProviderModuleNaked['onDispose'];
174
+ protected moduleUtils: IProviderModuleNaked['moduleUtils'];
175
+ protected imports: IProviderModuleNaked['imports'];
176
+ protected providers: IProviderModuleNaked['providers'];
177
+ protected exports: IProviderModuleNaked['exports'];
178
+ protected registeredSideEffects: IProviderModuleNaked['registeredSideEffects'];
179
+ constructor(options: ProviderModuleOptions | IProviderModuleDefinition);
428
180
  get<T>(provider: ProviderToken<T>, isOptional?: boolean): T;
429
181
  getMany<D extends (ProviderModuleGetManyParam<any> | ProviderToken)[]>(...deps: D | unknown[]): ProviderModuleGetManySignature<D>;
182
+ lazyImport(...modules: ProviderModuleOrDefinition[]): void;
430
183
  toNaked(): IProviderModuleNaked;
431
- clone(options?: Partial<ProviderModuleOptions>): IProviderModule;
432
184
  dispose(): Promise<void>;
433
185
  toString(): string;
434
186
  private setIdentifier;
435
187
  private prepareContainer;
436
188
  private injectImportedModules;
437
189
  private injectProviders;
438
- private onUnbindInternal;
439
- private registerBindingSideEffect;
440
- private invokeRegisteredBindingSideEffects;
441
- private removeRegisteredBindingSideEffects;
442
- private removeOnUnbindEffectsFromImportedModule;
190
+ private registerSideEffect;
191
+ private invokeRegisteredSideEffects;
192
+ private removeRegisteredSideEffects;
443
193
  private shouldThrowIfDisposed;
444
194
  /**
445
195
  * **Publicly visible when the instance is casted to {@link IProviderModuleNaked}.**
446
196
  *
447
- * See {@link IProviderModuleNaked._lazyInit}.
448
- */
449
- protected _lazyInit({ markAsGlobal, imports, providers, exports, defaultScope, dynamicExports, onReady, onDispose, ..._internalParams }: LazyInitOptions): IProviderModule;
450
- /**
451
- * **Publicly visible when the instance is casted to {@link IProviderModuleNaked}.**
452
- *
453
- * See {@link IProviderModuleNaked._getImportedModules}.
454
- */
455
- protected _getImportedModules(): (IProviderModuleNaked | (() => IProviderModuleNaked))[];
456
- /**
457
- * **Publicly visible when the instance is casted to {@link IProviderModuleNaked}.**
458
- *
459
- * See {@link IProviderModuleNaked._getProviders}.
460
- */
461
- protected _getProviders(): DependencyProvider[];
462
- /**
463
- * **Publicly visible when the instance is casted to {@link IProviderModuleNaked}.**
464
- *
465
- * See {@link IProviderModuleNaked._getExportableModulesAndProviders}.
197
+ * See {@link IProviderModuleNaked._internalInit}.
466
198
  */
467
- protected _getExportableModulesAndProviders(): StaticExports;
199
+ protected _internalInit(options: InternalInitOptions | IProviderModuleDefinition): IProviderModule;
468
200
  /**
469
201
  * **Publicly visible when the instance is casted to {@link IProviderModuleNaked}.**
470
202
  *
@@ -587,12 +319,16 @@ declare class ProviderModule implements IProviderModule {
587
319
  * **You shouldn't initialize a new instance of this class, please use the {@link AppModule} instance!**
588
320
  */
589
321
  declare class GlobalAppModule extends ProviderModule implements IAppModule {
322
+ _strict: AppModuleOptions['_strict'];
590
323
  private nakedModule;
591
324
  private isLoaded;
592
325
  constructor();
593
326
  register<AsNaked extends boolean = false>(options: AppModuleOptions): AsNaked extends false ? IAppModule : IAppModule & IProviderModuleNaked;
327
+ lazyImport(...modules: ProviderModuleOrDefinition[]): void;
594
328
  toNaked(): IAppModule & IProviderModuleNaked;
595
329
  dispose(): Promise<void>;
330
+ /** **Internally used, do not use!** */
331
+ _importWithoutSecondaryImportCheck(...modules: ProviderModuleOrDefinition[]): void;
596
332
  private checkIfRegisteredModulesHaveGlobalMark;
597
333
  }
598
334
  /**
@@ -612,78 +348,81 @@ declare class GlobalAppModule extends ProviderModule implements IAppModule {
612
348
  */
613
349
  declare const AppModule: GlobalAppModule;
614
350
 
615
- interface ProviderModuleOptions {
616
- /** The module unique ID. */
617
- identifier: symbol;
618
- /** The list of imported {@link IProviderModule | modules} that export the {@link Provider | providers} which are required in this module. */
619
- imports?: (IProviderModule | (() => IProviderModule))[];
620
- /** The {@link DependencyProvider | providers} that will be instantiated by the container and that may be shared at least across this module. */
621
- providers?: DependencyProvider[];
622
- /**
623
- * The subset of {@link ProviderToken | providers} or {@link IProviderModule | modules} that
624
- * are provided by this module and should be available in other modules which import this module.
625
- *
626
- * _Check also the {@link dynamicExports} property._
627
- */
628
- exports?: StaticExports;
629
- /**
630
- * The default {@link InjectionScope} to be used when a {@link ProviderToken} does not have a defined `scope`.
631
- *
632
- * Defaults to {@link InjectionScope.Singleton}.
633
- */
634
- defaultScope?: InjectionScope;
635
- /**
636
- * This option is only a _marker_, per se it doesn't do anything
637
- * apart from marking this module as `global`.
638
- * When a module is marked as `global`, it means that it is expected to be _imported_ into the `AppModule`.
639
- *
640
- * Expect an exception to be thrown:
641
- * - If a `module` marked as global is **not** imported into the `AppModule`.
642
- * - If a `module` **not** marked as global _is_ imported into the `AppModule`
351
+ /**
352
+ * Can be used when you _don't_ want to initialize a `ProviderModule` eagerly as each `ProviderModule` has its own _(InversifyJS)_ container
353
+ * initialized as soon as you do `new ProviderModule({...})`.
354
+ *
355
+ * The {@link ProviderModuleDefinition} allows you to just _define_ the `ProviderModule` options so you can _import_ it later into different modules.
356
+ *
357
+ * You can always edit a property of the definition after instantiation by doing:
358
+ *
359
+ * ```ts
360
+ * const GarageModuleDefinition = new ProviderModuleDefinition({ identifier: 'GarageModuleDefinition' });
361
+ *
362
+ * // Later in your code
363
+ *
364
+ * GarageModuleDefinition.imports = [...GarageModuleDefinition.imports, PorscheModule, FerrariModuleDefinition];
365
+ *
366
+ * // ...
367
+ *
368
+ * const GarageModule = new ProviderModule(GarageModuleDefinition);
369
+ *
370
+ * // or
371
+ *
372
+ * ExistingModule.lazyImport(GarageModuleDefinition);
373
+ * ```
374
+ *
375
+ * **Note:** _This means that you can't expect to be able to inject dependencies from a {@link ProviderModuleDefinition}_
376
+ * _as how you would do with an instance of a `ProviderModule`._
377
+ */
378
+ declare class ProviderModuleDefinition implements IProviderModuleDefinition {
379
+ identifier: IProviderModuleDefinition['identifier'];
380
+ imports: IProviderModuleDefinition['imports'];
381
+ providers: IProviderModuleDefinition['providers'];
382
+ exports: IProviderModuleDefinition['exports'];
383
+ defaultScope: IProviderModuleDefinition['defaultScope'];
384
+ isGlobal: IProviderModuleDefinition['isGlobal'];
385
+ onReady: IProviderModuleDefinition['onReady'];
386
+ onDispose: IProviderModuleDefinition['onDispose'];
387
+ constructor(moduleOptions: ProviderModuleOptions);
388
+ getDefinition(): ProviderModuleOptions;
389
+ clone(definition?: Partial<ProviderModuleOptions>): IProviderModuleDefinition;
390
+ toString(): string;
391
+ private checkIfShouldBeAddedToTheGlobalRegister;
392
+ }
393
+
394
+ interface ProviderModuleOptions {
395
+ /** The module unique `ID`. */
396
+ identifier: symbol | string;
397
+ /** Import additional {@link IProviderModule | modules} into _this_ module. */
398
+ imports?: ProviderModuleOrDefinition[];
399
+ /** The {@link DependencyProvider | providers} that will be instantiated by the container and that may be shared at least across _this_ module. */
400
+ providers?: DependencyProvider[];
401
+ /**
402
+ * The subset of {@link ProviderToken | providers} or {@link IProviderModule | modules} that
403
+ * are provided by _this_ module and should be available in other modules which import _this_ module.
643
404
  *
644
- * Defaults to `false`.
405
+ * **Note:** _Supports lazy exports, see {@link LazyExport}._
645
406
  */
646
- markAsGlobal?: boolean;
407
+ exports?: ExportsList;
647
408
  /**
648
- * When provided, can be used to control which providers from the {@link ProviderModuleOptions.exports | exports}
649
- * array should actually be exported into the importing module.
409
+ * The default {@link InjectionScope} to be used when a {@link ProviderToken} does not have a defined `scope`.
650
410
  *
651
- * **Note:** _Static {@link ProviderModuleOptions.exports | exports} should always be preferred as their static nature implies predictibility._
652
- * _This is for advanced use cases only, and most probably you may never need to use a dynamic export!_
411
+ * Defaults to {@link InjectionScope.Singleton}.
412
+ */
413
+ defaultScope?: InjectionScope;
414
+ /**
415
+ * When a module is marked as `global`, it means that it is expected to be _imported_ into the `AppModule`.
653
416
  *
654
- * @example
655
- * ```ts
656
- * {
657
- * exports: [ConfigModule, UserModule, PaymentService, ReviewService],
658
- * dynamicExports: (importerModule, moduleExports) => {
659
- * const shouldExportOnlyTheServices = true;
660
- *
661
- * if (shouldExportOnlyTheServices === false) return moduleExports;
662
- *
663
- * return moduleExports.flatMap((ex) => {
664
- * // With `flatMap` we can map and filter out elements
665
- * // from the sequence at the same time
666
- * // by returning an empty array.
667
- * return ex instanceof ProviderModule ? [] : ex;
668
- * });
669
- * }
670
- * }
671
- *
672
- * // Or
673
- *
674
- * {
675
- * exports: [ConfigModule, UserModule, PaymentService, ReviewService],
676
- * dynamicExports: (importerModule, moduleExports) => {
677
- * // We export all the providers only when the importer module is not the `BULLIED_MODULE`.
678
- * if (importerModule.toNaked().name !== 'BULLIED_MODULE') return moduleExports;
679
- *
680
- * return [ConfigModule];
681
- * }
682
- * }
417
+ * **Note:** _Importing a `global` module into a `scoped` module will automatically import it into the `AppModule` rather than the scoped module itself!_
683
418
  *
684
- * ```
419
+ * Expect an exception to be thrown:
420
+ * - If a `module` marked as global is **not** imported into the `AppModule`.
421
+ * - If a `module` **not** marked as global _is_ imported into the `AppModule`
422
+ *
423
+ * Defaults to `false`.
685
424
  */
686
- dynamicExports?: DynamicExports;
425
+ isGlobal?: boolean;
687
426
  /**
688
427
  * Callback which will be invoked once the module container has been initialized
689
428
  * and the providers resolved.
@@ -694,42 +433,306 @@ interface ProviderModuleOptions {
694
433
  */
695
434
  onReady?: (module: IProviderModule) => Promise<void>;
696
435
  /**
697
- * Callback which will be invoked whenever the internal module dispose method is invoked.
436
+ * Callback which will be invoked when the module dispose method is invoked.
698
437
  *
699
- * **The method will be invoked right _before_ the clean-up process.**
700
- *
701
- * @param module The instance of the {@link IProviderModule | module}.
438
+ * @returns See {@link OnDisposeOptions}.
702
439
  */
703
- onDispose?: (module: IProviderModule) => Promise<void>;
440
+ onDispose?: () => OnDisposeOptions;
704
441
  }
705
442
  interface ProviderModuleOptionsInternal {
706
443
  isAppModule?: boolean;
444
+ instantiatedFromDefinition?: boolean;
707
445
  isDisposed?: boolean;
708
446
  /** Can be used to manually provide the {@link IAppModule} instance. */
709
447
  appModule?: () => GlobalAppModule;
710
448
  /** Can be used to manually provide a {@link Container} instance. */
711
449
  container?: () => Container;
712
- /** Can be used to override all the _imported_ providers _before_ the binding process. */
713
- importedProvidersMap?: (
714
- /** The current imported {@link DependencyProvider | provider} altered to use the module from where was imported for resolution. */
715
- factorizedProvider: DependencyProvider<any>,
716
- /** The current imported {@link DependencyProvider | provider}. */
717
- provider: DependencyProvider<any>,
718
- /** The {@link IProviderModule | module} from where the {@link DependencyProvider | provider} originated. */
719
- module: IProviderModule) => DependencyProvider<any>;
720
450
  }
721
- type StaticExports = (ProviderToken | IProviderModule)[];
722
- type DynamicExports = (
723
- /** The {@link IProviderModule} which is importing this module. */
724
- importerModule: IProviderModule,
725
- /** The {@link ProviderModuleOptions.exports | exports} array of this module. */
726
- moduleExports: StaticExports) => StaticExports;
451
+ type ExportsList = (StaticExport | LazyExport)[];
452
+ type StaticExport = ProviderToken | ProviderModuleOrDefinition;
453
+ type LazyExport = (
454
+ /** The {@link IProviderModule | module} which is importing _this_ module. */
455
+ importerModule: IProviderModule) => StaticExport | void;
456
+ type OnDisposeOptions = RequireAtLeastOne<{
457
+ /**
458
+ * It'll be invoked _before_ the dispose process starts.
459
+ *
460
+ * @param module The {@link IProviderModule | module} instance.
461
+ */
462
+ before: (module: IProviderModule) => void | Promise<void>;
463
+ /**
464
+ * It'll be invoked _after_ the dispose process ended.
465
+ *
466
+ * **Note:** _At this point the internal container has been destroyed and it'll be `null` when trying to access it._
467
+ *
468
+ * @param module The {@link IProviderModule | module} instance.
469
+ */
470
+ after: (module: IProviderModule) => void | Promise<void>;
471
+ }>;
472
+
473
+ interface IProviderModuleDefinition extends ProviderModuleOptions {
474
+ /** Returns the {@link ProviderModuleOptions | definition}. */
475
+ getDefinition(): ProviderModuleOptions;
476
+ /**
477
+ * Can be used to _clone_ the instance of this {@link IProviderModuleDefinition | ModuleDefinition}.
478
+ *
479
+ * @param definition Optionally you can overwrite the definition of the clone before being returned.
480
+ *
481
+ * ```ts
482
+ * const CarModuleDefinition = new ProviderModuleDefinition({
483
+ * identifier: 'CarModuleDefinition',
484
+ * providers: [CarService],
485
+ * });
486
+ *
487
+ * const CarModuleDefinitionMocked = CarModuleDefinition.clone({
488
+ * identifier: 'CarModuleDefinitionMocked',
489
+ * providers: [{ provide: CarService, useClass: CarServiceMocked }]
490
+ * });
491
+ * ```
492
+ */
493
+ clone(definition?: Partial<ProviderModuleOptions>): IProviderModuleDefinition;
494
+ /** Returns the {@link ProviderModuleOptions.identifier | identifier}. */
495
+ toString(): string;
496
+ }
497
+
498
+ /**
499
+ * Class containing an internal set of `utils`.
500
+ *
501
+ * Each {@link IProviderModuleNaked.moduleUtils | ProviderModule} instance has its own {@link ProviderModuleUtils} property instance.
502
+ */
503
+ declare class ProviderModuleUtils {
504
+ /** The low-level InversifyJS {@link Container} owned by {@link ProviderModuleUtils.module | module}. */
505
+ get container(): Container;
506
+ readonly appModule: GlobalAppModule;
507
+ /** The parent {@link IProviderModule | ProviderModule} of `this` instance. */
508
+ readonly module: IProviderModule;
509
+ readonly moduleNaked: IProviderModuleNaked;
510
+ constructor(module: IProviderModule, internalOptions: ProviderModuleOptionsInternal);
511
+ /**
512
+ * Low-level method which can be used to manually register _(bind)_ a new {@link provider} into the {@link ProviderModuleUtils.module | module} container.
513
+ *
514
+ * **Note:** _You shouldn't directly use this to register providers as they will not appear_
515
+ * _into the module's `imports` and `exports` arrays! Therefore leading to unexpected bugs and confusion!_
516
+ *
517
+ * @param provider The {@link ProviderToken | provider} to register.
518
+ * @param defaultScope Optionally provide the default {@link InjectionScope} to use when applicable.
519
+ * @returns `true` when the {@link provider} has been bound otherwhise `false`.
520
+ */
521
+ bindToContainer<T>(provider: DependencyProvider<T>, defaultScope: InjectionScope): boolean;
522
+ private checkIfShouldBeAddedToTheGlobalRegister;
523
+ private bindSelfTokenToContainer;
524
+ private bindClassTokenToContainer;
525
+ private bindValueTokenToContainer;
526
+ private bindFactoryTokenToContainer;
527
+ /** Sets the {@link InjectionScope} of a bound {@link provider}. */
528
+ private setBindingScope;
529
+ /** Sets the `when` clause of a bound {@link provider}. */
530
+ private setWhenBinding;
531
+ /** Sets the `activation` and `deactivation` events of a bound {@link provider}. */
532
+ private setBindingOnEvent;
533
+ }
534
+
535
+ /** Can be used to publicly expose internal properties and methods of an {@link IProviderModule} instance. */
536
+ interface IProviderModuleNaked extends IProviderModule {
537
+ /** It'll be `true` when the current module is the global `AppModule`. */
538
+ readonly isAppModule: boolean;
539
+ /** It'll be `true` when the `module` has been instantiated from a `ProviderModuleDefinition` instance. */
540
+ readonly instantiatedFromDefinition: boolean;
541
+ /** The low-level `InversifyJS` {@link https://inversify.io/docs/api/container/ | container} instance. */
542
+ readonly container: Container;
543
+ /** The default injection scope of this module. */
544
+ readonly defaultScope: {
545
+ /** Scope from `xInjection` {@link InjectionScope} enum. */
546
+ native: InjectionScope;
547
+ /** Scope from `InversifyJS` {@link BindingScope} string union. */
548
+ inversify: BindingScope;
549
+ };
550
+ /** Instance of the {@link ProviderModuleUtils}. */
551
+ readonly moduleUtils: ProviderModuleUtils;
552
+ /** The {@link DependencyProvider | providers} resolved by this module. */
553
+ readonly providers: DependencyProvider[];
554
+ /** What is exported into this module. */
555
+ readonly imports: ProviderModuleOrDefinition[];
556
+ /** What is exported from this module. */
557
+ readonly exports: ExportsList;
558
+ /** The registered `callback` which will be invoked when the internal initialization process has been completed. */
559
+ readonly onReady: ProviderModuleOptions['onReady'];
560
+ /** The registered `callback` which will be invoked when the {@link _dispose} method is invoked. */
561
+ readonly onDispose: ProviderModuleOptions['onDispose'];
562
+ readonly registeredSideEffects: RegisteredSideEffects;
563
+ /** It'll _completely_ re-init the `module` with the provided {@link InternalInitOptions | options}. */
564
+ _internalInit(options: InternalInitOptions): IProviderModule;
565
+ /**
566
+ * Can be used to execute the provided {@link cb | callback} whenever a _new_ {@link https://inversify.io/docs/fundamentals/binding/ | binding}
567
+ * is registered for the {@link provider}.
568
+ *
569
+ * @param provider The {@link ProviderToken}.
570
+ * @param cb The `callback` to be invoked.
571
+ */
572
+ _onBind<T>(provider: ProviderToken<T>, cb: () => Promise<void> | void): void;
573
+ /**
574
+ * Can be used to execute the provided {@link cb | callback} whenever the
575
+ * {@link IProviderModule.get | get} method is invoked.
576
+ *
577
+ * @param provider The {@link ProviderToken}.
578
+ * @param once When set to `true` it'll invoke the provided {@link cb | callback} only once.
579
+ * @param cb The `callback` to be invoked.
580
+ */
581
+ _onGet<T>(provider: ProviderToken<T>, once: boolean, cb: () => Promise<void> | void): void;
582
+ /**
583
+ * Can be used to execute the provided {@link cb | callback} whenever an existing {@link https://inversify.io/docs/fundamentals/binding/ | binding}
584
+ * is re-registered for the {@link provider}.
585
+ *
586
+ * @param provider The {@link ProviderToken}.
587
+ * @param cb The `callback` to be invoked.
588
+ */
589
+ _onRebind<T>(provider: ProviderToken<T>, cb: () => Promise<void> | void): void;
590
+ /**
591
+ * Can be used to execute the provided {@link cb | callback} whenever a {@link provider} is `unbound`.
592
+ *
593
+ * **Note:** _All the {@link _onBind}, {@link _onGet}, {@link _onRebind} and {@link _onUnbind} registered callbacks will be removed_
594
+ *
595
+ * @param provider The {@link ProviderToken}.
596
+ * @param cb The `callback` to be invoked.
597
+ */
598
+ _onUnbind<T>(provider: ProviderToken<T>, cb: () => Promise<void> | void): void;
599
+ /**
600
+ * Internal method which can be used to completely overwrite the module {@link container}
601
+ * with the one provided.
602
+ *
603
+ * @param cb Callback which when invoked must return an instance of the {@link Container}.
604
+ */
605
+ _overwriteContainer(cb: () => Container): void;
606
+ /**
607
+ * Binds a {@link ProviderToken | provider}.
608
+ *
609
+ * See {@link https://inversify.io/docs/api/container/#bind | Container.bind} for more details.
610
+ */
611
+ __bind<T>(provider: ProviderToken<T>): BindToFluentSyntax<T>;
612
+ /**
613
+ * Resolves a dependency by its runtime identifier.
614
+ * The runtime identifier must be associated with only one binding and the binding must be synchronously resolved,
615
+ * otherwise an error is thrown.
616
+ *
617
+ * @param provider The {@link ProviderToken}.
618
+ * @param options The {@link GetOptions}.
619
+ * @returns Either the {@link T | dependency} or `undefined` if {@link GetOptions.optional} is set to `true`.
620
+ *
621
+ * See {@link https://inversify.io/docs/api/container/#get | Container.get} for more details.
622
+ */
623
+ __get<T>(provider: ProviderToken<T>, options?: GetOptions): T;
624
+ /**
625
+ * Resolves a dependency by its runtime identifier.
626
+ * The runtime identifier must be associated with only one binding,
627
+ * otherwise an error is thrown.
628
+ *
629
+ * @param provider The {@link ProviderToken}.
630
+ * @param options The {@link GetOptions}.
631
+ * @returns Either the {@link T | dependency} or `undefined` if {@link GetOptions.optional} is set to `true`.
632
+ *
633
+ * See {@link https://inversify.io/docs/api/container/#getasync | Container.getAsync} for more details.
634
+ */
635
+ __getAsync<T>(provider: ProviderToken<T>, options?: GetOptions): Promise<T>;
636
+ /** See {@link https://inversify.io/docs/api/container/#getall | Container.getAll} for more details. */
637
+ __getAll<T>(provider: ProviderToken<T>, options?: GetOptions): T[];
638
+ /** See {@link https://inversify.io/docs/api/container/#getallasync | Container.getAllAsync} for more details. */
639
+ __getAllAsync<T>(provider: ProviderToken<T>, options?: GetOptions): Promise<T[]>;
640
+ /**
641
+ * Can be used to check if there are registered bindings for the {@link provider | provider}.
642
+ *
643
+ * See {@link https://inversify.io/docs/api/container/#isbound | Container.isBound} for more details.
644
+ */
645
+ __isBound(provider: ProviderToken, options?: IsBoundOptions): boolean;
646
+ /**
647
+ * Can be useed to check if there are registered bindings for the {@link provider | provider} only in the current container.
648
+ *
649
+ * See {@link https://inversify.io/docs/api/container/#iscurrentbound | Container.isCurrentBound} for more details.
650
+ */
651
+ __isCurrentBound(provider: ProviderToken, options?: IsBoundOptions): boolean;
652
+ /**
653
+ * Save the state of the container to be later restored with the restore method.
654
+ *
655
+ * See {@link https://inversify.io/docs/api/container/#snapshot | Container.snapshot} for more details.
656
+ */
657
+ __takeSnapshot(): void;
658
+ /**
659
+ * Restore container state to last snapshot.
660
+ *
661
+ * See {@link https://inversify.io/docs/api/container/#restore | Container.restore} for more details.
662
+ */
663
+ __restoreSnapshot(): void;
664
+ /**
665
+ * Convenience method that unbinds a {@link ProviderToken | provider} and then creates a new binding for it.
666
+ * This is equivalent to calling await `container.unbind` followed by `container.bind`, but in a single method.
667
+ *
668
+ * @param provider The {@link ProviderToken}.
669
+ * @returns A {@link BindToFluentSyntax | binding builder} to continue configuring the new binding.
670
+ *
671
+ * See {@link https://inversify.io/docs/api/container/#rebind | Container.rebind} for more details.
672
+ */
673
+ __rebind<T>(provider: ProviderToken<T>): Promise<BindToFluentSyntax<T>>;
674
+ /**
675
+ * Synchronous version of {@link __rebindProvider}. Unbinds a {@link ProviderToken | provider} synchronously and then creates a new binding for it.
676
+ * Will throw an error if the unbind operation would be asynchronous.
677
+ *
678
+ * @param provider The {@link ProviderToken}.
679
+ * @returns A {@link BindToFluentSyntax | binding builder} to continue configuring the new binding.
680
+ *
681
+ * See {@link https://inversify.io/docs/api/container/#rebindsync | Container.rebindSync} for more details.
682
+ */
683
+ __rebindSync<T>(provider: ProviderToken<T>): BindToFluentSyntax<T>;
684
+ /**
685
+ * Removes **all** the associated bindings with the {@link provider} from the container.
686
+ *
687
+ * This will result in the {@link https://inversify.io/docs/fundamentals/lifecycle/deactivation/ | deactivation process}.
688
+ *
689
+ * See {@link https://inversify.io/docs/api/container/#unbind | Container.unbind} for more details.
690
+ */
691
+ __unbind(provider: ProviderToken): Promise<void>;
692
+ /**
693
+ * Removes **all** the associated bindings with the {@link provider} from the container synchronously.
694
+ * This method works like {@link __unbind} but does not return a Promise.
695
+ * If the unbinding operation would be asynchronous (e.g. due to deactivation handlers),
696
+ * it will throw an error. Use this method when you know the operation won't involve async deactivations.
697
+ *
698
+ * This will result in the {@link https://inversify.io/docs/fundamentals/lifecycle/deactivation/ | deactivation process}.
699
+ *
700
+ * See {@link https://inversify.io/docs/api/container/#unbindsync | Container.unbindSync} for more details.
701
+ */
702
+ __unbindSync(provider: ProviderToken): void;
703
+ /**
704
+ * Remove all bindings bound in this container.
705
+ *
706
+ * This will result in the {@link https://inversify.io/docs/fundamentals/lifecycle/deactivation/ | deactivation process}.
707
+ *
708
+ * See {@link https://inversify.io/docs/api/container/#unbindall | Container.unbindAll} for more details.
709
+ */
710
+ __unbindAll(): Promise<void>;
711
+ }
712
+ type InternalInitOptions = Except<ProviderModuleOptions & ProviderModuleOptionsInternal, 'identifier' | 'isAppModule'>;
713
+ type RegisteredSideEffects = Map<ProviderToken, {
714
+ onBindEffects: OnBindEffects[];
715
+ onGetEffects: OnGetEffects[];
716
+ onRebindEffects: OnRebindEffects[];
717
+ onUnbindEffects: OnUnbindEffects[];
718
+ }>;
719
+ type OnBindEffects = () => Promise<void> | void;
720
+ type OnGetEffects = {
721
+ once: boolean;
722
+ invoked: boolean;
723
+ cb: () => Promise<void> | void;
724
+ };
725
+ type OnRebindEffects = () => Promise<void> | void;
726
+ type OnUnbindEffects = {
727
+ registerModuleId?: ModuleIdentifier;
728
+ cb: () => Promise<void> | void;
729
+ };
727
730
 
728
731
  interface IProviderModule {
729
732
  /** The module unique ID. */
730
- readonly identifier: symbol;
731
- /** See {@link ProviderModuleOptions.markAsGlobal}. */
732
- readonly isMarkedAsGlobal: boolean;
733
+ readonly identifier: ModuleIdentifier;
734
+ /** See {@link ProviderModuleOptions.isGlobal}. */
735
+ readonly isGlobal: ProviderModuleOptions['isGlobal'];
733
736
  readonly isDisposed: boolean;
734
737
  /**
735
738
  * Can be used to retrieve a resolved `dependency` from the module container.
@@ -762,30 +765,28 @@ interface IProviderModule {
762
765
  */
763
766
  getMany<D extends (ProviderModuleGetManyParam<any> | ProviderToken)[]>(...deps: D | unknown[]): ProviderModuleGetManySignature<D>;
764
767
  /**
765
- * Casts the current module type to the {@link IProviderModuleNaked} type.
768
+ * Can be used to _lazily_ import one or more {@link IProviderModule | modules} into _this_ module.
766
769
  *
767
- * **Internally used and for testing purposes!**
770
+ * @param module The `module` to be imported.
768
771
  */
769
- toNaked(): IProviderModuleNaked;
772
+ lazyImport(...module: ProviderModuleOrDefinition[]): void;
770
773
  /**
771
- * Can be used to create a new instance of the current {@link IProviderModule | module}.
772
- *
773
- * **Note:** _All the providers will be registered again within the new module!_
774
- * _And also the new module will still refrain values by reference to its parent module because of_
775
- * _JS limitation in deeply/truly cloning an instance._
774
+ * Casts the current module type to the {@link IProviderModuleNaked} type.
776
775
  *
777
- * @param options Apply a new set of {@link ProviderModuleOptions | options}.
776
+ * **Internally used and for testing purposes!**
778
777
  */
779
- clone(options?: Partial<ProviderModuleOptions>): IProviderModule;
778
+ toNaked(): IProviderModuleNaked;
780
779
  /**
781
780
  * Removes all the bindings from the {@link IProviderModuleNaked.container | container}.
782
781
  *
783
- * **Note:** The module can be fully re-initialized by invoking the {@link _lazyInit} method.
782
+ * **Note:** The module can be fully re-initialized by invoking the {@link _internalInit} method.
784
783
  */
785
784
  dispose(): Promise<void>;
786
- /** Returns the {@link IProviderModule.identifier} `symbol` description. */
785
+ /** Returns the {@link IProviderModule.identifier}. */
787
786
  toString(): string;
788
787
  }
788
+ type ModuleIdentifier = symbol | string;
789
+ type ProviderModuleOrDefinition = IProviderModule | IProviderModuleDefinition;
789
790
  type ProviderModuleGetManySignature<Tokens extends (ProviderModuleGetManyParam<any> | ProviderToken)[]> = {
790
791
  [K in keyof Tokens]: Tokens[K] extends ProviderModuleGetManyParam<infer U> ? U : Tokens[K] extends ProviderToken<infer T> ? T : Tokens[K] extends ProviderIdentifier<infer I> ? I : never;
791
792
  };
@@ -796,12 +797,26 @@ type ProviderModuleGetManyParam<T> = {
796
797
  isOptional?: boolean;
797
798
  };
798
799
 
799
- interface IAppModule extends Except<IProviderModule, 'isMarkedAsGlobal'> {
800
+ interface IAppModule extends Except<IProviderModule, 'isGlobal'> {
801
+ readonly _strict: AppModuleOptions['_strict'];
800
802
  /** Must be invoked _(only once during the application lifecycle)_ in order to provide the {@link options} to the module. */
801
803
  register<AsNaked extends boolean = false>(options: AppModuleOptions): AsNaked extends false ? IAppModule : IAppModule & IProviderModuleNaked;
802
804
  toNaked(): IAppModule & IProviderModuleNaked;
803
805
  }
804
- type AppModuleOptions = Except<LazyInitOptions, 'exports' | 'dynamicExports'>;
806
+ interface AppModuleOptions extends Except<InternalInitOptions, 'appModule' | 'isGlobal' | 'exports' | 'isDisposed'> {
807
+ /**
808
+ * When set to `true` it'll enforce an opinionated set of rules
809
+ * which _can help_ in avoiding common pitfalls which may otherwise produce
810
+ * undesired side-effects or edge-case bugs.
811
+ *
812
+ * **Note:** _Do not open an `issue` if a bug or edge-case is caused by having the `strict` property disabled!_
813
+ *
814
+ * - `markAsGlobal`: Will not be enforced anymore.
815
+ *
816
+ * Defaults to `true`.
817
+ */
818
+ _strict?: boolean;
819
+ }
805
820
 
806
821
  /** See {@link https://inversify.io/docs/api/decorator/#inject} for more details. */
807
822
  declare function Inject(provider: ProviderToken): MethodDecorator & ParameterDecorator & PropertyDecorator;
@@ -832,25 +847,25 @@ declare class InjectionError extends Error {
832
847
  /** Exception which indicates that there is a generic error with an instance of {@link IProviderModule}. */
833
848
  declare class InjectionProviderModuleError extends Error {
834
849
  name: string;
835
- constructor(module: IProviderModule, message: string);
850
+ constructor(module: ProviderModuleOrDefinition, message: string);
836
851
  }
837
852
 
838
853
  /** Exception which indicates an invokation of a disposed module. */
839
854
  declare class InjectionProviderModuleDisposedError extends InjectionProviderModuleError {
840
855
  name: string;
841
- constructor(module: IProviderModule);
856
+ constructor(module: ProviderModuleOrDefinition);
842
857
  }
843
858
 
844
859
  /** Exception which indicates that a module has been initialized without an `identifier`. */
845
860
  declare class InjectionProviderModuleMissingIdentifierError extends InjectionProviderModuleError {
846
861
  name: string;
847
- constructor(module: IProviderModule);
862
+ constructor(module: ProviderModuleOrDefinition);
848
863
  }
849
864
 
850
- /** Exception which indicates an error with regards to the `markAsGlobal` option. */
865
+ /** Exception which indicates an error with regards to the `isGlobal` option. */
851
866
  declare class InjectionProviderModuleGlobalMarkError extends InjectionProviderModuleError {
852
867
  name: string;
853
- constructor(module: IProviderModule, message: string);
868
+ constructor(module: ProviderModuleOrDefinition, message: string);
854
869
  }
855
870
 
856
871
  declare function injectionScopeToBindingScope(injectionScope: InjectionScope): BindingScope;
@@ -881,7 +896,13 @@ declare namespace ProviderTokenHelpers {
881
896
 
882
897
  declare namespace ProviderModuleHelpers {
883
898
  function buildInternalConstructorParams(params: Partial<ProviderModuleOptions & ProviderModuleOptionsInternal>): ProviderModuleOptions;
884
- function isDynamicExport(exporter: StaticExports | DynamicExports): exporter is DynamicExports;
899
+ function getOptionsOrModuleDefinitionOptions(optionsOrDefinition: ProviderModuleOptions | IProviderModuleDefinition): {
900
+ options: ProviderModuleOptions;
901
+ internalOptions: ProviderModuleOptionsInternal;
902
+ };
903
+ function isModuleDefinition(value: any): value is IProviderModuleDefinition;
904
+ function isLazyExport(exp: any): exp is LazyExport;
905
+ function tryStaticOrLazyExportToStaticExport(module: IProviderModule, exp: StaticExport | LazyExport): StaticExport | void;
885
906
  }
886
907
 
887
908
  declare function isPlainObject(o: any): o is object;
@@ -892,4 +913,4 @@ declare function isFunction(v: any): boolean;
892
913
 
893
914
  declare function isClassOrFunction(value: any): value is Function | Class<any>;
894
915
 
895
- 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, 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 };
916
+ export { AppModule, type AppModuleOptions, type DependencyProvider, type ExportsList, GLOBAL_APP_MODULE_ID, GlobalAppModule, GlobalContainer, type IAppModule, type IProviderModule, type IProviderModuleDefinition, type IProviderModuleNaked, Inject, InjectFromBase, Injectable, InjectionError, InjectionProviderModuleDisposedError, InjectionProviderModuleError, InjectionProviderModuleGlobalMarkError, InjectionProviderModuleMissingIdentifierError, InjectionScope, type InternalInitOptions, MultiInject, Named, type OnEvent, Optional, type ProviderClassToken, type ProviderFactoryToken, type ProviderIdentifier, ProviderModule, ProviderModuleDefinition, type ProviderModuleGetManyParam, type ProviderModuleGetManySignature, ProviderModuleHelpers, type ProviderModuleOptions, type ProviderModuleOptionsInternal, type ProviderModuleOrDefinition, type ProviderOptions, type ProviderScopeOption, type ProviderToken, ProviderTokenHelpers, type ProviderValueToken, Tagged, Unmanaged, bindingScopeToInjectionScope, injectionScopeToBindingScope, isClass, isClassOrFunction, isFunction, isPlainObject };