@adimm/x-injection-reactjs 0.3.1 → 1.0.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,69 +1,60 @@
1
- import * as React from 'react';
2
- import React__default from 'react';
3
- import { ProviderModuleOptions, IProviderModule, IProviderModuleNaked, DependencyProvider, ProviderToken, ProviderModuleGetManyParam, ProviderModuleGetManySignature, ProviderModule } from '@adimm/x-injection';
4
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
+ import react__default from 'react';
3
+ import * as _adimm_x_injection from '@adimm/x-injection';
4
+ import { IProviderModule, ProviderToken, ProviderModuleGetManyParam, ProviderIdentifier, ModuleOrBlueprint, DependencyProvider } from '@adimm/x-injection';
5
5
 
6
- interface ComponentProviderModuleOptions extends ProviderModuleOptions {
7
- /**
8
- * When set to `true`, it'll automatically `contextualize` all the `imports` array.
9
- *
10
- * **Note:** _This is required when you have a parent component which renders one or more children
11
- * and does also need to control their providers._
12
- * _If not set to `true`, then the children providers would be resolved from their original `module`, therefore_
13
- * _if your parent component has multiple instances of itself, all its children will actually share_
14
- * _the same providers, especially when their module injection scope is set to `Singleton` (by default)._
15
- *
16
- * **Note2:** _If a module has {@link ProviderModuleOptions.markAsGlobal | markAsGlobal} set to `true`,_
17
- * _this will automatically default to `false`._
18
- *
19
- * Defaults to `true`.
20
- */
21
- contextualizeImports?: boolean;
22
- }
6
+ declare const REACT_X_INJECTION_PROVIDER_MODULE_CONTEXT: react.Context<IProviderModule>;
23
7
 
24
- interface IComponentProviderModuleNaked extends IComponentProviderModule {
25
- /**
26
- * The original `id` which was assigned to this module.
27
- *
28
- * **Note:** _The module initial {@link ComponentProviderModuleOptions.identifier | id} will be suffixed with `Contextualized`._
29
- */
30
- originalIdentifier: symbol;
31
- /** See {@link ComponentProviderModuleOptions.contextualizeImports}. */
32
- hasContextualizedImports: ComponentProviderModuleOptions['contextualizeImports'];
33
- /** Indicates if this module has been initialized by a React Component or not. */
34
- initializedFromComponent: boolean;
35
- /**
36
- * It is used internally by the `ProviderModule` to create a new cloned
37
- * module which will be consumed only by that specific component instance.
38
- */
39
- _createContextualizedComponentInstance(parentIdentifier?: symbol): IComponentProviderModule;
40
- }
41
-
42
- interface IComponentProviderModule extends IProviderModule {
8
+ /**
9
+ * Low-level hook which can be used to resolve a single dependency.
10
+ *
11
+ * **Note:** _In order to better modularize your code-base, you should strive to create custom hooks by using the_
12
+ * _`hookFactory` method to compose a custom hook._
13
+ *
14
+ * @param provider The {@link ProviderToken}.
15
+ * @param options See {@link UseInjectOptions}.
16
+ * @returns The resolved {@link T | dependency}.
17
+ */
18
+ declare function useInject<T, IsOptional extends boolean | undefined = undefined, AsList extends boolean | undefined = undefined>(provider: ProviderToken<T>, options?: UseInjectOptions<IsOptional, AsList>): _adimm_x_injection.ProviderModuleGetReturn<T, IsOptional, AsList>;
19
+ type UseInjectOptions<IsOptional extends boolean | undefined = undefined, AsList extends boolean | undefined = undefined> = {
43
20
  /**
44
- * Casts the current module type to the {@link IComponentProviderModuleNaked} type.
21
+ * When set to `false` an exception will be thrown when the supplied `ProviderToken` isn't bound.
45
22
  *
46
- * **Internally used and for testing purposes!**
23
+ * Defaults to `false`.
47
24
  */
48
- toNaked(): IComponentProviderModuleNaked & IProviderModuleNaked;
25
+ isOptional?: IsOptional;
49
26
  /**
50
- * Should be invoked only when the component is not needed anymore.
27
+ * Set to `true` if you need to retrieve _all_ the bound identifiers of the supplied `ProviderToken`.
51
28
  *
52
- * _eg: When changing page, removable components and so on._
29
+ * Defaults to `false`.
53
30
  */
54
- dispose(): Promise<void>;
55
- }
31
+ asList?: AsList;
32
+ };
33
+
34
+ /**
35
+ * Low-level hook which can be used to resolve multiple dependencies at once.
36
+ *
37
+ * **Note:** _In order to better modularize your code-base, you should strive to create custom hooks by using the_
38
+ * _`hookFactory` method to compose a custom hook._
39
+ *
40
+ * @param deps Either one or more {@link ProviderToken}.
41
+ * @returns Tuple containing the {@link D | dependencies}.
42
+ */
43
+ declare function useInjectMany<D extends (ProviderModuleGetManyParam<any> | ProviderToken | ProviderIdentifier)[]>(...deps: D): _adimm_x_injection.ProviderModuleGetManyReturn<D>;
44
+
45
+ /** Can be used to retrieve the {@link IProviderModule | Module} from the current context. */
46
+ declare function useComponentModule(): IProviderModule;
56
47
 
57
48
  type PropsWithModule<P extends Record<string, any>> = P & {
58
49
  /**
59
- * The {@link IComponentProviderModule | Module} which this component should consume.
50
+ * The {@link ModuleOrBlueprint} which this component should consume.
60
51
  *
61
52
  * **Note:** _Can be used to easily mock an entire module._
62
53
  *
63
54
  * example:
64
55
  * ```tsx
65
- * const CarModule = new ComponentProviderMdule({
66
- * identifier: Symbol('CarModule'),
56
+ * const CarModuleBp = ProviderModule.blueprint({
57
+ * id: 'CarModule',
67
58
  * imports: [CarEngineModule, CarDashboardModule],
68
59
  * providers: [CarService],
69
60
  * exports: [CarService],
@@ -71,7 +62,7 @@ type PropsWithModule<P extends Record<string, any>> = P & {
71
62
  *
72
63
  * const cbMock = jest.fn();
73
64
  *
74
- * const CarModuleMocked = CarModule.clone({
65
+ * const CarModulBpeMocked = CarModuleBp.clone().updateDefinition({
75
66
  * providers: [
76
67
  * {
77
68
  * provide: CarService, useValue: { startEngine: cbMock }
@@ -79,21 +70,18 @@ type PropsWithModule<P extends Record<string, any>> = P & {
79
70
  * ]
80
71
  * });
81
72
  *
82
- * await act(async () => render(<CarComponent module={CarModuleMocked} />));
73
+ * await act(async () => render(<CarComponent module={CarModuleBpMocked} />));
83
74
  *
84
75
  * await waitFor(async () => {
85
76
  * expect(cbMock).toHaveBeenCalled();
86
77
  * });
87
78
  * ```
88
79
  */
89
- module?: IComponentProviderModule;
80
+ module?: ModuleOrBlueprint;
90
81
  /**
91
82
  * Can be used to control the dependencies consumed by this component.
92
83
  * This is useful when you want to provide an already resolved instance of a dependency down the component tree.
93
84
  *
94
- * **Note:** _It'll throw when attempting to provide the `inject` prop to a component using a module_
95
- * _marked as global!_
96
- *
97
85
  * eg:
98
86
  * ```tsx
99
87
  * class InputboxService {
@@ -125,58 +113,10 @@ type PropsWithModule<P extends Record<string, any>> = P & {
125
113
  inject?: DependencyProvider[];
126
114
  };
127
115
 
128
- declare const REACT_X_INJECTION_PROVIDER_MODULE_CONTEXT: React.Context<IComponentProviderModule>;
129
-
130
116
  /**
131
- * Low-level hook which can be used to resolve a single dependency from the current
132
- * context module.
117
+ * Can be used to easily provide a {@link module} to a component.
133
118
  *
134
- * **Note:** _In order to better modularize your code-base, you should strive to create custom hooks by using the_
135
- * _`hookFactory` method to compose a custom hook._
136
- *
137
- * @param provider The {@link ProviderToken}.
138
- * @param options See {@link UseInjectOptions}.
139
- * @returns The resolved {@link T | dependency}.
140
- */
141
- declare function useInject<T>(provider: ProviderToken<T>, options?: UseInjectOptions): T;
142
- type UseInjectOptions = {
143
- /** When set to `false` _(default)_ an exception will be thrown when the `providerOrIdentifier` isn't bound. */
144
- isOptional?: boolean;
145
- };
146
-
147
- /**
148
- * Low-level hook which can be used to resolve multiple dependencies at once from the current
149
- * context module.
150
- *
151
- * **Note:** _In order to better modularize your code-base, you should strive to create custom hooks by using the_
152
- * _`hookFactory` method to compose a custom hook._
153
- *
154
- * @param deps Either one or more {@link ProviderToken}.
155
- * @returns Tuple containing the {@link D | dependencies}.
156
- */
157
- declare function useInjectMany<D extends (ProviderModuleGetManyParam<any> | ProviderToken)[]>(...deps: D | unknown[]): ProviderModuleGetManySignature<D>;
158
-
159
- /** Can be used to retrieve the {@link IComponentProviderModule} from the current context. */
160
- declare function useComponentModule(): IComponentProviderModule;
161
-
162
- /** A superset of the {@link ProviderModule} used to integrate within a `React` component. */
163
- declare class ComponentProviderModule extends ProviderModule implements IComponentProviderModule {
164
- protected readonly originalIdentifier: symbol;
165
- protected readonly hasContextualizedImports: IComponentProviderModuleNaked['hasContextualizedImports'];
166
- protected readonly initializedFromComponent: IComponentProviderModuleNaked['initializedFromComponent'];
167
- constructor(options: ComponentProviderModuleOptions);
168
- toNaked(): IComponentProviderModuleNaked & IProviderModuleNaked;
169
- clone(options?: Partial<ComponentProviderModuleOptions>): IComponentProviderModule;
170
- /**
171
- * **Publicly visible when the instance is casted to {@link IComponentProviderModuleNaked}.**
172
- *
173
- * See {@link IComponentProviderModuleNaked._createContextualizedComponentInstance}.
174
- */
175
- protected _createContextualizedComponentInstance(parentIdentifier?: symbol): IComponentProviderModule;
176
- }
177
-
178
- /**
179
- * Can be used to easily provide a {@link module} to any component.
119
+ * **Note:** _An error will be thrown if a `global` module is provided._
180
120
  *
181
121
  * @example
182
122
  * ```tsx
@@ -199,57 +139,21 @@ declare class ComponentProviderModule extends ProviderModule implements ICompone
199
139
  * }
200
140
  * ```
201
141
  *
202
- * @param module The {@link IComponentProviderModule | Module} which should be consumed by the {@link component}.
142
+ * @param module The {@link ModuleOrBlueprint} which should be consumed by the {@link component}.
203
143
  * @returns The provided {@link toComponent | Component}.
204
144
  */
205
- declare function provideModuleToComponent<P extends Record<string, any>, C extends ReactElementWithProviderModule<P> = ReactElementWithProviderModule<P>>(module: IComponentProviderModule, component: ReactElementWithProviderModule<P>): C;
206
- type ReactElementWithProviderModule<P extends Record<string, any>> = (p: PropsWithModule<P>) => React__default.ReactNode;
207
-
208
- /**
209
- * Can be used to easily provide a {@link module} to any component.
210
- *
211
- * @example
212
- * ```tsx
213
- * interface MyComponentProps {
214
- * firstName: string;
215
- * lastName: string;
216
- * }
217
- *
218
- * function MyComponent({ firstName, lastName }: MyComponentProps) {
219
- * const service = useInject(MyComponentService);
220
- *
221
- * return <h1>Hello {service.computeUserName(firstName, lastName)}!</h1>
222
- * }
223
- *
224
- * function App() {
225
- * return (
226
- * <ProvideModule module={MyComponentModule}>
227
- * <MyComponent firstName={'John'} lastName={'Doe'} />
228
- * </ProvideModule>
229
- * );
230
- * }
231
- * ```
232
- *
233
- * @param param0 See {@link ProvideModuleFunctionParams}.
234
- * @returns The provided {@link toComponent | Component}.
235
- */
236
- declare function ProvideModule({ module, children }: ProvideModuleFunctionParams): react_jsx_runtime.JSX.Element;
237
- interface ProvideModuleFunctionParams {
238
- /** The {@link IComponentProviderModule | Module} which should be consumed by the {@link children | component}. */
239
- module: IComponentProviderModule;
240
- children: React__default.ReactElement;
241
- }
145
+ declare function provideModuleToComponent<P extends Record<string, any>, C extends ReactElementWithProviderModule<P> = ReactElementWithProviderModule<P>>(module: ModuleOrBlueprint, component: ReactElementWithProviderModule<P>): C;
146
+ type ReactElementWithProviderModule<P extends Record<string, any>> = (p: PropsWithModule<P>) => react__default.ReactNode;
242
147
 
243
148
  declare function hookFactory<P extends HookParams, D extends any[], T>({ use: hook, inject, }: HookFactoryParams<P, D, T>): (p: P) => T;
244
149
  interface HookFactoryParams<P extends HookParams, D extends any[], T> {
245
- use: HookWithProviderModuleDependencies<P, D, T>;
150
+ use: (p: HookWithDeps<P, D>) => T;
246
151
  inject: ProviderToken[];
247
152
  }
248
- type HookWithProviderModuleDependencies<P extends HookParams, D extends any[], T> = (p: HookWithDeps<P, D>) => T;
249
153
  type HookWithDeps<P extends HookParams, D extends any[]> = P & {
250
- /** Array containing the resolved dependencies from the component context. */
154
+ /** Array containing the resolved dependencies. */
251
155
  deps: D;
252
156
  };
253
157
  type HookParams = Record<string, any> | void;
254
158
 
255
- export { ComponentProviderModule, type ComponentProviderModuleOptions, type HookFactoryParams, type HookWithDeps, type HookWithProviderModuleDependencies, type IComponentProviderModule, type IComponentProviderModuleNaked, type PropsWithModule, ProvideModule, type ProvideModuleFunctionParams, REACT_X_INJECTION_PROVIDER_MODULE_CONTEXT, type ReactElementWithProviderModule, type UseInjectOptions, hookFactory, provideModuleToComponent, useComponentModule, useInject, useInjectMany };
159
+ export { type HookFactoryParams, type HookWithDeps, type PropsWithModule, REACT_X_INJECTION_PROVIDER_MODULE_CONTEXT, type ReactElementWithProviderModule, type UseInjectOptions, hookFactory, provideModuleToComponent, useComponentModule, useInject, useInjectMany };
package/dist/index.d.ts CHANGED
@@ -1,69 +1,60 @@
1
- import * as React from 'react';
2
- import React__default from 'react';
3
- import { ProviderModuleOptions, IProviderModule, IProviderModuleNaked, DependencyProvider, ProviderToken, ProviderModuleGetManyParam, ProviderModuleGetManySignature, ProviderModule } from '@adimm/x-injection';
4
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
+ import react__default from 'react';
3
+ import * as _adimm_x_injection from '@adimm/x-injection';
4
+ import { IProviderModule, ProviderToken, ProviderModuleGetManyParam, ProviderIdentifier, ModuleOrBlueprint, DependencyProvider } from '@adimm/x-injection';
5
5
 
6
- interface ComponentProviderModuleOptions extends ProviderModuleOptions {
7
- /**
8
- * When set to `true`, it'll automatically `contextualize` all the `imports` array.
9
- *
10
- * **Note:** _This is required when you have a parent component which renders one or more children
11
- * and does also need to control their providers._
12
- * _If not set to `true`, then the children providers would be resolved from their original `module`, therefore_
13
- * _if your parent component has multiple instances of itself, all its children will actually share_
14
- * _the same providers, especially when their module injection scope is set to `Singleton` (by default)._
15
- *
16
- * **Note2:** _If a module has {@link ProviderModuleOptions.markAsGlobal | markAsGlobal} set to `true`,_
17
- * _this will automatically default to `false`._
18
- *
19
- * Defaults to `true`.
20
- */
21
- contextualizeImports?: boolean;
22
- }
6
+ declare const REACT_X_INJECTION_PROVIDER_MODULE_CONTEXT: react.Context<IProviderModule>;
23
7
 
24
- interface IComponentProviderModuleNaked extends IComponentProviderModule {
25
- /**
26
- * The original `id` which was assigned to this module.
27
- *
28
- * **Note:** _The module initial {@link ComponentProviderModuleOptions.identifier | id} will be suffixed with `Contextualized`._
29
- */
30
- originalIdentifier: symbol;
31
- /** See {@link ComponentProviderModuleOptions.contextualizeImports}. */
32
- hasContextualizedImports: ComponentProviderModuleOptions['contextualizeImports'];
33
- /** Indicates if this module has been initialized by a React Component or not. */
34
- initializedFromComponent: boolean;
35
- /**
36
- * It is used internally by the `ProviderModule` to create a new cloned
37
- * module which will be consumed only by that specific component instance.
38
- */
39
- _createContextualizedComponentInstance(parentIdentifier?: symbol): IComponentProviderModule;
40
- }
41
-
42
- interface IComponentProviderModule extends IProviderModule {
8
+ /**
9
+ * Low-level hook which can be used to resolve a single dependency.
10
+ *
11
+ * **Note:** _In order to better modularize your code-base, you should strive to create custom hooks by using the_
12
+ * _`hookFactory` method to compose a custom hook._
13
+ *
14
+ * @param provider The {@link ProviderToken}.
15
+ * @param options See {@link UseInjectOptions}.
16
+ * @returns The resolved {@link T | dependency}.
17
+ */
18
+ declare function useInject<T, IsOptional extends boolean | undefined = undefined, AsList extends boolean | undefined = undefined>(provider: ProviderToken<T>, options?: UseInjectOptions<IsOptional, AsList>): _adimm_x_injection.ProviderModuleGetReturn<T, IsOptional, AsList>;
19
+ type UseInjectOptions<IsOptional extends boolean | undefined = undefined, AsList extends boolean | undefined = undefined> = {
43
20
  /**
44
- * Casts the current module type to the {@link IComponentProviderModuleNaked} type.
21
+ * When set to `false` an exception will be thrown when the supplied `ProviderToken` isn't bound.
45
22
  *
46
- * **Internally used and for testing purposes!**
23
+ * Defaults to `false`.
47
24
  */
48
- toNaked(): IComponentProviderModuleNaked & IProviderModuleNaked;
25
+ isOptional?: IsOptional;
49
26
  /**
50
- * Should be invoked only when the component is not needed anymore.
27
+ * Set to `true` if you need to retrieve _all_ the bound identifiers of the supplied `ProviderToken`.
51
28
  *
52
- * _eg: When changing page, removable components and so on._
29
+ * Defaults to `false`.
53
30
  */
54
- dispose(): Promise<void>;
55
- }
31
+ asList?: AsList;
32
+ };
33
+
34
+ /**
35
+ * Low-level hook which can be used to resolve multiple dependencies at once.
36
+ *
37
+ * **Note:** _In order to better modularize your code-base, you should strive to create custom hooks by using the_
38
+ * _`hookFactory` method to compose a custom hook._
39
+ *
40
+ * @param deps Either one or more {@link ProviderToken}.
41
+ * @returns Tuple containing the {@link D | dependencies}.
42
+ */
43
+ declare function useInjectMany<D extends (ProviderModuleGetManyParam<any> | ProviderToken | ProviderIdentifier)[]>(...deps: D): _adimm_x_injection.ProviderModuleGetManyReturn<D>;
44
+
45
+ /** Can be used to retrieve the {@link IProviderModule | Module} from the current context. */
46
+ declare function useComponentModule(): IProviderModule;
56
47
 
57
48
  type PropsWithModule<P extends Record<string, any>> = P & {
58
49
  /**
59
- * The {@link IComponentProviderModule | Module} which this component should consume.
50
+ * The {@link ModuleOrBlueprint} which this component should consume.
60
51
  *
61
52
  * **Note:** _Can be used to easily mock an entire module._
62
53
  *
63
54
  * example:
64
55
  * ```tsx
65
- * const CarModule = new ComponentProviderMdule({
66
- * identifier: Symbol('CarModule'),
56
+ * const CarModuleBp = ProviderModule.blueprint({
57
+ * id: 'CarModule',
67
58
  * imports: [CarEngineModule, CarDashboardModule],
68
59
  * providers: [CarService],
69
60
  * exports: [CarService],
@@ -71,7 +62,7 @@ type PropsWithModule<P extends Record<string, any>> = P & {
71
62
  *
72
63
  * const cbMock = jest.fn();
73
64
  *
74
- * const CarModuleMocked = CarModule.clone({
65
+ * const CarModulBpeMocked = CarModuleBp.clone().updateDefinition({
75
66
  * providers: [
76
67
  * {
77
68
  * provide: CarService, useValue: { startEngine: cbMock }
@@ -79,21 +70,18 @@ type PropsWithModule<P extends Record<string, any>> = P & {
79
70
  * ]
80
71
  * });
81
72
  *
82
- * await act(async () => render(<CarComponent module={CarModuleMocked} />));
73
+ * await act(async () => render(<CarComponent module={CarModuleBpMocked} />));
83
74
  *
84
75
  * await waitFor(async () => {
85
76
  * expect(cbMock).toHaveBeenCalled();
86
77
  * });
87
78
  * ```
88
79
  */
89
- module?: IComponentProviderModule;
80
+ module?: ModuleOrBlueprint;
90
81
  /**
91
82
  * Can be used to control the dependencies consumed by this component.
92
83
  * This is useful when you want to provide an already resolved instance of a dependency down the component tree.
93
84
  *
94
- * **Note:** _It'll throw when attempting to provide the `inject` prop to a component using a module_
95
- * _marked as global!_
96
- *
97
85
  * eg:
98
86
  * ```tsx
99
87
  * class InputboxService {
@@ -125,58 +113,10 @@ type PropsWithModule<P extends Record<string, any>> = P & {
125
113
  inject?: DependencyProvider[];
126
114
  };
127
115
 
128
- declare const REACT_X_INJECTION_PROVIDER_MODULE_CONTEXT: React.Context<IComponentProviderModule>;
129
-
130
116
  /**
131
- * Low-level hook which can be used to resolve a single dependency from the current
132
- * context module.
117
+ * Can be used to easily provide a {@link module} to a component.
133
118
  *
134
- * **Note:** _In order to better modularize your code-base, you should strive to create custom hooks by using the_
135
- * _`hookFactory` method to compose a custom hook._
136
- *
137
- * @param provider The {@link ProviderToken}.
138
- * @param options See {@link UseInjectOptions}.
139
- * @returns The resolved {@link T | dependency}.
140
- */
141
- declare function useInject<T>(provider: ProviderToken<T>, options?: UseInjectOptions): T;
142
- type UseInjectOptions = {
143
- /** When set to `false` _(default)_ an exception will be thrown when the `providerOrIdentifier` isn't bound. */
144
- isOptional?: boolean;
145
- };
146
-
147
- /**
148
- * Low-level hook which can be used to resolve multiple dependencies at once from the current
149
- * context module.
150
- *
151
- * **Note:** _In order to better modularize your code-base, you should strive to create custom hooks by using the_
152
- * _`hookFactory` method to compose a custom hook._
153
- *
154
- * @param deps Either one or more {@link ProviderToken}.
155
- * @returns Tuple containing the {@link D | dependencies}.
156
- */
157
- declare function useInjectMany<D extends (ProviderModuleGetManyParam<any> | ProviderToken)[]>(...deps: D | unknown[]): ProviderModuleGetManySignature<D>;
158
-
159
- /** Can be used to retrieve the {@link IComponentProviderModule} from the current context. */
160
- declare function useComponentModule(): IComponentProviderModule;
161
-
162
- /** A superset of the {@link ProviderModule} used to integrate within a `React` component. */
163
- declare class ComponentProviderModule extends ProviderModule implements IComponentProviderModule {
164
- protected readonly originalIdentifier: symbol;
165
- protected readonly hasContextualizedImports: IComponentProviderModuleNaked['hasContextualizedImports'];
166
- protected readonly initializedFromComponent: IComponentProviderModuleNaked['initializedFromComponent'];
167
- constructor(options: ComponentProviderModuleOptions);
168
- toNaked(): IComponentProviderModuleNaked & IProviderModuleNaked;
169
- clone(options?: Partial<ComponentProviderModuleOptions>): IComponentProviderModule;
170
- /**
171
- * **Publicly visible when the instance is casted to {@link IComponentProviderModuleNaked}.**
172
- *
173
- * See {@link IComponentProviderModuleNaked._createContextualizedComponentInstance}.
174
- */
175
- protected _createContextualizedComponentInstance(parentIdentifier?: symbol): IComponentProviderModule;
176
- }
177
-
178
- /**
179
- * Can be used to easily provide a {@link module} to any component.
119
+ * **Note:** _An error will be thrown if a `global` module is provided._
180
120
  *
181
121
  * @example
182
122
  * ```tsx
@@ -199,57 +139,21 @@ declare class ComponentProviderModule extends ProviderModule implements ICompone
199
139
  * }
200
140
  * ```
201
141
  *
202
- * @param module The {@link IComponentProviderModule | Module} which should be consumed by the {@link component}.
142
+ * @param module The {@link ModuleOrBlueprint} which should be consumed by the {@link component}.
203
143
  * @returns The provided {@link toComponent | Component}.
204
144
  */
205
- declare function provideModuleToComponent<P extends Record<string, any>, C extends ReactElementWithProviderModule<P> = ReactElementWithProviderModule<P>>(module: IComponentProviderModule, component: ReactElementWithProviderModule<P>): C;
206
- type ReactElementWithProviderModule<P extends Record<string, any>> = (p: PropsWithModule<P>) => React__default.ReactNode;
207
-
208
- /**
209
- * Can be used to easily provide a {@link module} to any component.
210
- *
211
- * @example
212
- * ```tsx
213
- * interface MyComponentProps {
214
- * firstName: string;
215
- * lastName: string;
216
- * }
217
- *
218
- * function MyComponent({ firstName, lastName }: MyComponentProps) {
219
- * const service = useInject(MyComponentService);
220
- *
221
- * return <h1>Hello {service.computeUserName(firstName, lastName)}!</h1>
222
- * }
223
- *
224
- * function App() {
225
- * return (
226
- * <ProvideModule module={MyComponentModule}>
227
- * <MyComponent firstName={'John'} lastName={'Doe'} />
228
- * </ProvideModule>
229
- * );
230
- * }
231
- * ```
232
- *
233
- * @param param0 See {@link ProvideModuleFunctionParams}.
234
- * @returns The provided {@link toComponent | Component}.
235
- */
236
- declare function ProvideModule({ module, children }: ProvideModuleFunctionParams): react_jsx_runtime.JSX.Element;
237
- interface ProvideModuleFunctionParams {
238
- /** The {@link IComponentProviderModule | Module} which should be consumed by the {@link children | component}. */
239
- module: IComponentProviderModule;
240
- children: React__default.ReactElement;
241
- }
145
+ declare function provideModuleToComponent<P extends Record<string, any>, C extends ReactElementWithProviderModule<P> = ReactElementWithProviderModule<P>>(module: ModuleOrBlueprint, component: ReactElementWithProviderModule<P>): C;
146
+ type ReactElementWithProviderModule<P extends Record<string, any>> = (p: PropsWithModule<P>) => react__default.ReactNode;
242
147
 
243
148
  declare function hookFactory<P extends HookParams, D extends any[], T>({ use: hook, inject, }: HookFactoryParams<P, D, T>): (p: P) => T;
244
149
  interface HookFactoryParams<P extends HookParams, D extends any[], T> {
245
- use: HookWithProviderModuleDependencies<P, D, T>;
150
+ use: (p: HookWithDeps<P, D>) => T;
246
151
  inject: ProviderToken[];
247
152
  }
248
- type HookWithProviderModuleDependencies<P extends HookParams, D extends any[], T> = (p: HookWithDeps<P, D>) => T;
249
153
  type HookWithDeps<P extends HookParams, D extends any[]> = P & {
250
- /** Array containing the resolved dependencies from the component context. */
154
+ /** Array containing the resolved dependencies. */
251
155
  deps: D;
252
156
  };
253
157
  type HookParams = Record<string, any> | void;
254
158
 
255
- export { ComponentProviderModule, type ComponentProviderModuleOptions, type HookFactoryParams, type HookWithDeps, type HookWithProviderModuleDependencies, type IComponentProviderModule, type IComponentProviderModuleNaked, type PropsWithModule, ProvideModule, type ProvideModuleFunctionParams, REACT_X_INJECTION_PROVIDER_MODULE_CONTEXT, type ReactElementWithProviderModule, type UseInjectOptions, hookFactory, provideModuleToComponent, useComponentModule, useInject, useInjectMany };
159
+ export { type HookFactoryParams, type HookWithDeps, type PropsWithModule, REACT_X_INJECTION_PROVIDER_MODULE_CONTEXT, type ReactElementWithProviderModule, type UseInjectOptions, hookFactory, provideModuleToComponent, useComponentModule, useInject, useInjectMany };