@navios/di-react 0.1.1 → 0.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/CHANGELOG.md +39 -0
- package/README.md +609 -28
- package/lib/index.d.mts +297 -18
- package/lib/index.d.mts.map +1 -0
- package/lib/index.d.ts +297 -18
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +536 -335
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +533 -334
- package/lib/index.mjs.map +1 -1
- package/package.json +3 -3
- package/project.json +2 -2
- package/src/hooks/__tests__/use-service.spec.mts +1 -1
- package/src/hooks/index.mts +8 -2
- package/src/hooks/use-container.mts +47 -2
- package/src/hooks/use-invalidate.mts +3 -3
- package/src/hooks/use-optional-service.mts +59 -34
- package/src/hooks/use-scope.mts +66 -5
- package/src/hooks/use-service.mts +44 -18
- package/src/hooks/use-suspense-service.mts +48 -29
- package/src/providers/__tests__/scope-provider.spec.mts +84 -1
- package/src/providers/context.mts +11 -1
- package/src/providers/index.mts +2 -2
- package/src/providers/scope-provider.mts +34 -22
- package/{tsup.config.mts → tsdown.config.mts} +4 -3
- package/lib/_tsup-dts-rollup.d.mts +0 -304
- package/lib/_tsup-dts-rollup.d.ts +0 -304
package/lib/index.d.mts
CHANGED
|
@@ -1,18 +1,297 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import * as react1 from "react";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { BoundInjectionToken, ClassType, Container, Factorable, FactoryInjectionToken, IContainer, InjectionToken, InjectionTokenSchemaType, ScopedContainer } from "@navios/di";
|
|
4
|
+
import { ZodType, z } from "zod/v4";
|
|
5
|
+
|
|
6
|
+
//#region src/providers/context.d.mts
|
|
7
|
+
/**
|
|
8
|
+
* Context for the root Container.
|
|
9
|
+
* This is set by ContainerProvider and provides the base container.
|
|
10
|
+
*/
|
|
11
|
+
declare const ContainerContext: react1.Context<Container | null>;
|
|
12
|
+
/**
|
|
13
|
+
* Context for the current ScopedContainer (if inside a ScopeProvider).
|
|
14
|
+
* This allows nested components to access request-scoped services.
|
|
15
|
+
*/
|
|
16
|
+
declare const ScopedContainerContext: react1.Context<ScopedContainer | null>;
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/providers/container-provider.d.mts
|
|
19
|
+
interface ContainerProviderProps {
|
|
20
|
+
container: Container;
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
declare function ContainerProvider({
|
|
24
|
+
container,
|
|
25
|
+
children
|
|
26
|
+
}: ContainerProviderProps): react1.ReactElement<unknown, string | react1.JSXElementConstructor<any>>;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/providers/scope-provider.d.mts
|
|
29
|
+
interface ScopeProviderProps {
|
|
30
|
+
/**
|
|
31
|
+
* Optional explicit scope ID. If not provided, a unique ID will be generated.
|
|
32
|
+
* Useful when you need to reference the scope externally.
|
|
33
|
+
*/
|
|
34
|
+
scopeId?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Optional metadata to attach to the request context.
|
|
37
|
+
* Can be used to pass data like user info, request headers, etc.
|
|
38
|
+
*/
|
|
39
|
+
metadata?: Record<string, unknown>;
|
|
40
|
+
/**
|
|
41
|
+
* Priority for service resolution. Higher priority scopes take precedence.
|
|
42
|
+
* @default 100
|
|
43
|
+
*/
|
|
44
|
+
priority?: number;
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* ScopeProvider creates a new request scope for dependency injection.
|
|
49
|
+
*
|
|
50
|
+
* Services with `scope: 'Request'` will be instantiated once per ScopeProvider
|
|
51
|
+
* and shared among all components within that provider.
|
|
52
|
+
*
|
|
53
|
+
* This is useful for:
|
|
54
|
+
* - Table rows that need isolated state
|
|
55
|
+
* - Modal dialogs with their own service instances
|
|
56
|
+
* - Multi-tenant scenarios
|
|
57
|
+
* - Any case where you need isolated service instances
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* // Each row gets its own RowStateService instance
|
|
62
|
+
* {rows.map(row => (
|
|
63
|
+
* <ScopeProvider key={row.id} scopeId={row.id} metadata={{ rowData: row }}>
|
|
64
|
+
* <TableRow />
|
|
65
|
+
* </ScopeProvider>
|
|
66
|
+
* ))}
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
declare function ScopeProvider({
|
|
70
|
+
scopeId,
|
|
71
|
+
metadata,
|
|
72
|
+
priority,
|
|
73
|
+
children
|
|
74
|
+
}: ScopeProviderProps): react1.ReactElement<unknown, string | react1.JSXElementConstructor<any>> | null;
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/hooks/use-container.d.mts
|
|
77
|
+
/**
|
|
78
|
+
* Hook to get the current container (ScopedContainer if inside ScopeProvider, otherwise Container).
|
|
79
|
+
*
|
|
80
|
+
* This is the primary hook for accessing the DI container. It automatically
|
|
81
|
+
* returns the correct container based on context:
|
|
82
|
+
* - Inside a ScopeProvider: returns the ScopedContainer for request-scoped services
|
|
83
|
+
* - Outside a ScopeProvider: returns the root Container
|
|
84
|
+
*
|
|
85
|
+
* @returns The current container (ScopedContainer or Container)
|
|
86
|
+
*/
|
|
87
|
+
declare function useContainer(): IContainer;
|
|
88
|
+
/**
|
|
89
|
+
* Hook to get the root Container, regardless of whether we're inside a ScopeProvider.
|
|
90
|
+
*
|
|
91
|
+
* Use this when you need access to the root container specifically,
|
|
92
|
+
* for example to create new request scopes programmatically.
|
|
93
|
+
*
|
|
94
|
+
* @returns The root Container
|
|
95
|
+
*/
|
|
96
|
+
declare function useRootContainer(): Container;
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/types.d.mts
|
|
99
|
+
type UnionToArray<T> = UnionToArrayImpl<T, never>;
|
|
100
|
+
type UnionToArrayImpl<T, L extends any[]> = T extends any ? UnionToArrayImpl<Exclude<T, T>, [...L, T]> : L;
|
|
101
|
+
type Join<T extends any[], Delimiter extends string> = T extends [] ? '' : T extends [infer First extends string | number | symbol] ? First extends string | number ? `${First}` : never : T extends [infer First extends string | number | symbol, ...infer Rest extends any[]] ? First extends string | number ? `${First}${Delimiter}${Join<Rest, Delimiter>}` : never : '';
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/hooks/use-service.d.mts
|
|
104
|
+
interface UseServiceResult<T> {
|
|
105
|
+
data: T | undefined;
|
|
106
|
+
error: Error | undefined;
|
|
107
|
+
isLoading: boolean;
|
|
108
|
+
isSuccess: boolean;
|
|
109
|
+
isError: boolean;
|
|
110
|
+
refetch: () => void;
|
|
111
|
+
}
|
|
112
|
+
declare function useService<T extends ClassType>(token: T): UseServiceResult<InstanceType<T> extends Factorable<infer R> ? R : InstanceType<T>>;
|
|
113
|
+
declare function useService<T, S extends InjectionTokenSchemaType>(token: InjectionToken<T, S>, args: z.input<S>): UseServiceResult<T>;
|
|
114
|
+
declare function useService<T, S extends InjectionTokenSchemaType, R extends boolean>(token: InjectionToken<T, S, R>): R extends false ? UseServiceResult<T> : S extends ZodType<infer Type> ? `Error: Your token requires args: ${Join<UnionToArray<keyof Type>, ', '>}` : 'Error: Your token requires args';
|
|
115
|
+
declare function useService<T>(token: InjectionToken<T, undefined>): UseServiceResult<T>;
|
|
116
|
+
declare function useService<T>(token: BoundInjectionToken<T, any>): UseServiceResult<T>;
|
|
117
|
+
declare function useService<T>(token: FactoryInjectionToken<T, any>): UseServiceResult<T>;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/hooks/use-suspense-service.d.mts
|
|
120
|
+
declare function useSuspenseService<T extends ClassType>(token: T): InstanceType<T> extends Factorable<infer R> ? R : InstanceType<T>;
|
|
121
|
+
declare function useSuspenseService<T, S extends InjectionTokenSchemaType>(token: InjectionToken<T, S>, args: z.input<S>): T;
|
|
122
|
+
declare function useSuspenseService<T, S extends InjectionTokenSchemaType, R extends boolean>(token: InjectionToken<T, S, R>): R extends false ? T : S extends ZodType<infer Type> ? `Error: Your token requires args: ${Join<UnionToArray<keyof Type>, ', '>}` : 'Error: Your token requires args';
|
|
123
|
+
declare function useSuspenseService<T>(token: InjectionToken<T, undefined>): T;
|
|
124
|
+
declare function useSuspenseService<T>(token: BoundInjectionToken<T, any>): T;
|
|
125
|
+
declare function useSuspenseService<T>(token: FactoryInjectionToken<T, any>): T;
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/hooks/use-optional-service.d.mts
|
|
128
|
+
interface UseOptionalServiceResult<T> {
|
|
129
|
+
/**
|
|
130
|
+
* The service instance if found and loaded successfully, otherwise undefined.
|
|
131
|
+
*/
|
|
132
|
+
data: T | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* Error that occurred during loading (excludes "not found" which is not an error).
|
|
135
|
+
*/
|
|
136
|
+
error: Error | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* True while the service is being loaded.
|
|
139
|
+
*/
|
|
140
|
+
isLoading: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* True if the service was loaded successfully.
|
|
143
|
+
*/
|
|
144
|
+
isSuccess: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* True if the service was not found (not registered in the container).
|
|
147
|
+
*/
|
|
148
|
+
isNotFound: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* True if an error occurred during loading.
|
|
151
|
+
*/
|
|
152
|
+
isError: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Function to manually re-fetch the service.
|
|
155
|
+
*/
|
|
156
|
+
refetch: () => void;
|
|
157
|
+
}
|
|
158
|
+
declare function useOptionalService<T extends ClassType>(token: T): UseOptionalServiceResult<InstanceType<T> extends Factorable<infer R> ? R : InstanceType<T>>;
|
|
159
|
+
declare function useOptionalService<T, S extends InjectionTokenSchemaType>(token: InjectionToken<T, S>, args: z.input<S>): UseOptionalServiceResult<T>;
|
|
160
|
+
declare function useOptionalService<T, S extends InjectionTokenSchemaType, R extends boolean>(token: InjectionToken<T, S, R>): R extends false ? UseOptionalServiceResult<T> : S extends ZodType<infer Type> ? `Error: Your token requires args: ${Join<UnionToArray<keyof Type>, ', '>}` : 'Error: Your token requires args';
|
|
161
|
+
declare function useOptionalService<T>(token: InjectionToken<T, undefined>): UseOptionalServiceResult<T>;
|
|
162
|
+
declare function useOptionalService<T>(token: BoundInjectionToken<T, any>): UseOptionalServiceResult<T>;
|
|
163
|
+
declare function useOptionalService<T>(token: FactoryInjectionToken<T, any>): UseOptionalServiceResult<T>;
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/hooks/use-invalidate.d.mts
|
|
166
|
+
type InvalidatableToken = ClassType | InjectionToken<any, any> | BoundInjectionToken<any, any> | FactoryInjectionToken<any, any>;
|
|
167
|
+
/**
|
|
168
|
+
* Hook that returns a function to invalidate a service by its token.
|
|
169
|
+
*
|
|
170
|
+
* When called, this will:
|
|
171
|
+
* 1. Destroy the current service instance
|
|
172
|
+
* 2. Trigger re-fetch in all components using useService/useSuspenseService for that token
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```tsx
|
|
176
|
+
* function UserProfile() {
|
|
177
|
+
* const { data: user } = useService(UserService)
|
|
178
|
+
* const invalidateUser = useInvalidate(UserService)
|
|
179
|
+
*
|
|
180
|
+
* const handleRefresh = () => {
|
|
181
|
+
* invalidateUser() // All components using UserService will re-fetch
|
|
182
|
+
* }
|
|
183
|
+
*
|
|
184
|
+
* return (
|
|
185
|
+
* <div>
|
|
186
|
+
* <span>{user?.name}</span>
|
|
187
|
+
* <button onClick={handleRefresh}>Refresh</button>
|
|
188
|
+
* </div>
|
|
189
|
+
* )
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
declare function useInvalidate<T extends InvalidatableToken>(token: T): () => Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* Hook that returns a function to invalidate a service by its token with args.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```tsx
|
|
199
|
+
* function UserProfile({ userId }: { userId: string }) {
|
|
200
|
+
* const args = useMemo(() => ({ userId }), [userId])
|
|
201
|
+
* const { data: user } = useService(UserToken, args)
|
|
202
|
+
* const invalidateUser = useInvalidate(UserToken, args)
|
|
203
|
+
*
|
|
204
|
+
* return (
|
|
205
|
+
* <div>
|
|
206
|
+
* <span>{user?.name}</span>
|
|
207
|
+
* <button onClick={() => invalidateUser()}>Refresh</button>
|
|
208
|
+
* </div>
|
|
209
|
+
* )
|
|
210
|
+
* }
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
declare function useInvalidate<T, S extends InjectionTokenSchemaType>(token: InjectionToken<T, S>, args: S extends undefined ? never : unknown): () => Promise<void>;
|
|
214
|
+
/**
|
|
215
|
+
* Hook that returns a function to invalidate a service instance directly.
|
|
216
|
+
*
|
|
217
|
+
* This is useful when you have the service instance and want to invalidate it
|
|
218
|
+
* without knowing its token.
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```tsx
|
|
222
|
+
* function UserProfile() {
|
|
223
|
+
* const { data: user } = useService(UserService)
|
|
224
|
+
* const invalidateInstance = useInvalidateInstance()
|
|
225
|
+
*
|
|
226
|
+
* const handleRefresh = () => {
|
|
227
|
+
* if (user) {
|
|
228
|
+
* invalidateInstance(user)
|
|
229
|
+
* }
|
|
230
|
+
* }
|
|
231
|
+
*
|
|
232
|
+
* return (
|
|
233
|
+
* <div>
|
|
234
|
+
* <span>{user?.name}</span>
|
|
235
|
+
* <button onClick={handleRefresh}>Refresh</button>
|
|
236
|
+
* </div>
|
|
237
|
+
* )
|
|
238
|
+
* }
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
declare function useInvalidateInstance(): (instance: unknown) => Promise<void>;
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/hooks/use-scope.d.mts
|
|
244
|
+
/**
|
|
245
|
+
* Hook to get the current scope ID.
|
|
246
|
+
* Returns null if not inside a ScopeProvider.
|
|
247
|
+
*/
|
|
248
|
+
declare function useScope(): string | null;
|
|
249
|
+
/**
|
|
250
|
+
* Hook to get the current scope ID, throwing if not inside a ScopeProvider.
|
|
251
|
+
* Use this when your component requires a scope to function correctly.
|
|
252
|
+
*/
|
|
253
|
+
declare function useScopeOrThrow(): string;
|
|
254
|
+
/**
|
|
255
|
+
* Hook to get the current ScopedContainer.
|
|
256
|
+
* Returns null if not inside a ScopeProvider.
|
|
257
|
+
*
|
|
258
|
+
* Use this to access scope metadata or other ScopedContainer methods.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```tsx
|
|
262
|
+
* function TableRow() {
|
|
263
|
+
* const scope = useScopedContainer()
|
|
264
|
+
* const rowData = scope?.getMetadata('rowData')
|
|
265
|
+
* // ...
|
|
266
|
+
* }
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
declare function useScopedContainer(): ScopedContainer | null;
|
|
270
|
+
/**
|
|
271
|
+
* Hook to get the current ScopedContainer, throwing if not inside a ScopeProvider.
|
|
272
|
+
* Use this when your component requires a scope to function correctly.
|
|
273
|
+
*/
|
|
274
|
+
declare function useScopedContainerOrThrow(): ScopedContainer;
|
|
275
|
+
/**
|
|
276
|
+
* Hook to get metadata from the current scope.
|
|
277
|
+
* Returns undefined if not inside a ScopeProvider or if the key doesn't exist.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```tsx
|
|
281
|
+
* // In parent component:
|
|
282
|
+
* <ScopeProvider metadata={{ userId: '123', theme: 'dark' }}>
|
|
283
|
+
* <ChildComponent />
|
|
284
|
+
* </ScopeProvider>
|
|
285
|
+
*
|
|
286
|
+
* // In child component:
|
|
287
|
+
* function ChildComponent() {
|
|
288
|
+
* const userId = useScopeMetadata<string>('userId')
|
|
289
|
+
* const theme = useScopeMetadata<'light' | 'dark'>('theme')
|
|
290
|
+
* // ...
|
|
291
|
+
* }
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
declare function useScopeMetadata<T = unknown>(key: string): T | undefined;
|
|
295
|
+
//#endregion
|
|
296
|
+
export { ContainerContext, ContainerProvider, type ContainerProviderProps, Join, ScopeProvider, type ScopeProviderProps, ScopedContainerContext, UnionToArray, type UseOptionalServiceResult, type UseServiceResult, useContainer, useInvalidate, useInvalidateInstance, useOptionalService, useRootContainer, useScope, useScopeMetadata, useScopeOrThrow, useScopedContainer, useScopedContainerOrThrow, useService, useSuspenseService };
|
|
297
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/providers/context.mts","../src/providers/container-provider.mts","../src/providers/scope-provider.mts","../src/hooks/use-container.mts","../src/types.mts","../src/hooks/use-service.mts","../src/hooks/use-suspense-service.mts","../src/hooks/use-optional-service.mts","../src/hooks/use-invalidate.mts","../src/hooks/use-scope.mts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAQa,kBAAgB,MAAA,CAAA,QAAA;AAA7B;AAMA;;;cAAa,wBAAsB,MAAA,CAAA,QAAA;;;UCPlB,sBAAA;aACJ;YACD;;ADDC,iBCIG,iBAAA,CDJa;EAAA,SAAA;EAAA;AAAA,CAAA,ECO1B,sBDP0B,CAAA,ECOJ,MAAA,CAAA,YDPI,CAAA,OAAA,EAAA,MAAA,GCOJ,MAAA,CAAA,qBDPI,CAAA,GAAA,CAAA,CAAA;;;UEAZ,kBAAA;;;;;EFAJ,OAAA,CAAA,EAAA,MAAA;EAMA;;;;ECPI,QAAA,CAAA,ECWJ,MDXI,CAAA,MAAA,EAAsB,OAAA,CAAA;EAKvB;;;;EAGS,QAAA,CAAA,EAAA,MAAA;EAAA,QAAA,ECSb,SDTa;;;;;ACPzB;AAyCA;;;;;;;;;;;;ACjCA;AAwBA;;;;ACtCA;A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,aJ/DZ,CAAA,CAAA,EAAA,UI+DuC,wBJ/DvC,CAAA,CAAA,KAAA,EIgEK,cJhEL,CIgEoB,CJhEpB,EIgEuB,CJhEvB,CAAA,EAAA,IAAA,EIiEI,CJjEJ,SAAA,SAAA,GAAA,KAAA,GAAA,OAAA,CAAA,EAAA,GAAA,GIkEK,OJlEL,CAAA,IAAA,CAAA;;;AAGJ;;;;;;;;;;;;;;ACwCA;AAUA;;;;;;;;;;AAOgB,iBGgDA,qBAAA,CAAA,CHhDU,EAAA,CAAA,QAAA,EAAA,OAAA,EAAA,GGgDsC,OHhDtC,CAAA,IAAA,CAAA;;;;;;;iBItDV,QAAA,CAAA;ATFhB;AAMA;;;iBSKgB,eAAA,CAAA;ARZhB;AAKA;;;;;;;;;;ACJA;AAyCA;;;AAGE,iBOPc,kBAAA,CAAA,CPOd,EOPoC,ePOpC,GAAA,IAAA;;;;;AAEmB,iBODL,yBAAA,CAAA,CPCK,EODwB,ePCxB;;;;ACtCrB;AAwBA;;;;ACtCA;AAAwD;;;;;;;;;;AAK5C,iBK4EI,gBL5EA,CAAA,IAAA,OAAA,CAAA,CAAA,GAAA,EAAA,MAAA,CAAA,EK4E4C,CL5E5C,GAAA,SAAA"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,18 +1,297 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import * as react3 from "react";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { BoundInjectionToken, ClassType, Container, Factorable, FactoryInjectionToken, IContainer, InjectionToken, InjectionTokenSchemaType, ScopedContainer } from "@navios/di";
|
|
4
|
+
import { ZodType, z } from "zod/v4";
|
|
5
|
+
|
|
6
|
+
//#region src/providers/context.d.mts
|
|
7
|
+
/**
|
|
8
|
+
* Context for the root Container.
|
|
9
|
+
* This is set by ContainerProvider and provides the base container.
|
|
10
|
+
*/
|
|
11
|
+
declare const ContainerContext: react3.Context<Container | null>;
|
|
12
|
+
/**
|
|
13
|
+
* Context for the current ScopedContainer (if inside a ScopeProvider).
|
|
14
|
+
* This allows nested components to access request-scoped services.
|
|
15
|
+
*/
|
|
16
|
+
declare const ScopedContainerContext: react3.Context<ScopedContainer | null>;
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/providers/container-provider.d.mts
|
|
19
|
+
interface ContainerProviderProps {
|
|
20
|
+
container: Container;
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
declare function ContainerProvider({
|
|
24
|
+
container,
|
|
25
|
+
children
|
|
26
|
+
}: ContainerProviderProps): react3.ReactElement<unknown, string | react3.JSXElementConstructor<any>>;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/providers/scope-provider.d.mts
|
|
29
|
+
interface ScopeProviderProps {
|
|
30
|
+
/**
|
|
31
|
+
* Optional explicit scope ID. If not provided, a unique ID will be generated.
|
|
32
|
+
* Useful when you need to reference the scope externally.
|
|
33
|
+
*/
|
|
34
|
+
scopeId?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Optional metadata to attach to the request context.
|
|
37
|
+
* Can be used to pass data like user info, request headers, etc.
|
|
38
|
+
*/
|
|
39
|
+
metadata?: Record<string, unknown>;
|
|
40
|
+
/**
|
|
41
|
+
* Priority for service resolution. Higher priority scopes take precedence.
|
|
42
|
+
* @default 100
|
|
43
|
+
*/
|
|
44
|
+
priority?: number;
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* ScopeProvider creates a new request scope for dependency injection.
|
|
49
|
+
*
|
|
50
|
+
* Services with `scope: 'Request'` will be instantiated once per ScopeProvider
|
|
51
|
+
* and shared among all components within that provider.
|
|
52
|
+
*
|
|
53
|
+
* This is useful for:
|
|
54
|
+
* - Table rows that need isolated state
|
|
55
|
+
* - Modal dialogs with their own service instances
|
|
56
|
+
* - Multi-tenant scenarios
|
|
57
|
+
* - Any case where you need isolated service instances
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* // Each row gets its own RowStateService instance
|
|
62
|
+
* {rows.map(row => (
|
|
63
|
+
* <ScopeProvider key={row.id} scopeId={row.id} metadata={{ rowData: row }}>
|
|
64
|
+
* <TableRow />
|
|
65
|
+
* </ScopeProvider>
|
|
66
|
+
* ))}
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
declare function ScopeProvider({
|
|
70
|
+
scopeId,
|
|
71
|
+
metadata,
|
|
72
|
+
priority,
|
|
73
|
+
children
|
|
74
|
+
}: ScopeProviderProps): react3.ReactElement<unknown, string | react3.JSXElementConstructor<any>> | null;
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/hooks/use-container.d.mts
|
|
77
|
+
/**
|
|
78
|
+
* Hook to get the current container (ScopedContainer if inside ScopeProvider, otherwise Container).
|
|
79
|
+
*
|
|
80
|
+
* This is the primary hook for accessing the DI container. It automatically
|
|
81
|
+
* returns the correct container based on context:
|
|
82
|
+
* - Inside a ScopeProvider: returns the ScopedContainer for request-scoped services
|
|
83
|
+
* - Outside a ScopeProvider: returns the root Container
|
|
84
|
+
*
|
|
85
|
+
* @returns The current container (ScopedContainer or Container)
|
|
86
|
+
*/
|
|
87
|
+
declare function useContainer(): IContainer;
|
|
88
|
+
/**
|
|
89
|
+
* Hook to get the root Container, regardless of whether we're inside a ScopeProvider.
|
|
90
|
+
*
|
|
91
|
+
* Use this when you need access to the root container specifically,
|
|
92
|
+
* for example to create new request scopes programmatically.
|
|
93
|
+
*
|
|
94
|
+
* @returns The root Container
|
|
95
|
+
*/
|
|
96
|
+
declare function useRootContainer(): Container;
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/types.d.mts
|
|
99
|
+
type UnionToArray<T> = UnionToArrayImpl<T, never>;
|
|
100
|
+
type UnionToArrayImpl<T, L extends any[]> = T extends any ? UnionToArrayImpl<Exclude<T, T>, [...L, T]> : L;
|
|
101
|
+
type Join<T extends any[], Delimiter extends string> = T extends [] ? '' : T extends [infer First extends string | number | symbol] ? First extends string | number ? `${First}` : never : T extends [infer First extends string | number | symbol, ...infer Rest extends any[]] ? First extends string | number ? `${First}${Delimiter}${Join<Rest, Delimiter>}` : never : '';
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/hooks/use-service.d.mts
|
|
104
|
+
interface UseServiceResult<T> {
|
|
105
|
+
data: T | undefined;
|
|
106
|
+
error: Error | undefined;
|
|
107
|
+
isLoading: boolean;
|
|
108
|
+
isSuccess: boolean;
|
|
109
|
+
isError: boolean;
|
|
110
|
+
refetch: () => void;
|
|
111
|
+
}
|
|
112
|
+
declare function useService<T extends ClassType>(token: T): UseServiceResult<InstanceType<T> extends Factorable<infer R> ? R : InstanceType<T>>;
|
|
113
|
+
declare function useService<T, S extends InjectionTokenSchemaType>(token: InjectionToken<T, S>, args: z.input<S>): UseServiceResult<T>;
|
|
114
|
+
declare function useService<T, S extends InjectionTokenSchemaType, R extends boolean>(token: InjectionToken<T, S, R>): R extends false ? UseServiceResult<T> : S extends ZodType<infer Type> ? `Error: Your token requires args: ${Join<UnionToArray<keyof Type>, ', '>}` : 'Error: Your token requires args';
|
|
115
|
+
declare function useService<T>(token: InjectionToken<T, undefined>): UseServiceResult<T>;
|
|
116
|
+
declare function useService<T>(token: BoundInjectionToken<T, any>): UseServiceResult<T>;
|
|
117
|
+
declare function useService<T>(token: FactoryInjectionToken<T, any>): UseServiceResult<T>;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/hooks/use-suspense-service.d.mts
|
|
120
|
+
declare function useSuspenseService<T extends ClassType>(token: T): InstanceType<T> extends Factorable<infer R> ? R : InstanceType<T>;
|
|
121
|
+
declare function useSuspenseService<T, S extends InjectionTokenSchemaType>(token: InjectionToken<T, S>, args: z.input<S>): T;
|
|
122
|
+
declare function useSuspenseService<T, S extends InjectionTokenSchemaType, R extends boolean>(token: InjectionToken<T, S, R>): R extends false ? T : S extends ZodType<infer Type> ? `Error: Your token requires args: ${Join<UnionToArray<keyof Type>, ', '>}` : 'Error: Your token requires args';
|
|
123
|
+
declare function useSuspenseService<T>(token: InjectionToken<T, undefined>): T;
|
|
124
|
+
declare function useSuspenseService<T>(token: BoundInjectionToken<T, any>): T;
|
|
125
|
+
declare function useSuspenseService<T>(token: FactoryInjectionToken<T, any>): T;
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/hooks/use-optional-service.d.mts
|
|
128
|
+
interface UseOptionalServiceResult<T> {
|
|
129
|
+
/**
|
|
130
|
+
* The service instance if found and loaded successfully, otherwise undefined.
|
|
131
|
+
*/
|
|
132
|
+
data: T | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* Error that occurred during loading (excludes "not found" which is not an error).
|
|
135
|
+
*/
|
|
136
|
+
error: Error | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* True while the service is being loaded.
|
|
139
|
+
*/
|
|
140
|
+
isLoading: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* True if the service was loaded successfully.
|
|
143
|
+
*/
|
|
144
|
+
isSuccess: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* True if the service was not found (not registered in the container).
|
|
147
|
+
*/
|
|
148
|
+
isNotFound: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* True if an error occurred during loading.
|
|
151
|
+
*/
|
|
152
|
+
isError: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Function to manually re-fetch the service.
|
|
155
|
+
*/
|
|
156
|
+
refetch: () => void;
|
|
157
|
+
}
|
|
158
|
+
declare function useOptionalService<T extends ClassType>(token: T): UseOptionalServiceResult<InstanceType<T> extends Factorable<infer R> ? R : InstanceType<T>>;
|
|
159
|
+
declare function useOptionalService<T, S extends InjectionTokenSchemaType>(token: InjectionToken<T, S>, args: z.input<S>): UseOptionalServiceResult<T>;
|
|
160
|
+
declare function useOptionalService<T, S extends InjectionTokenSchemaType, R extends boolean>(token: InjectionToken<T, S, R>): R extends false ? UseOptionalServiceResult<T> : S extends ZodType<infer Type> ? `Error: Your token requires args: ${Join<UnionToArray<keyof Type>, ', '>}` : 'Error: Your token requires args';
|
|
161
|
+
declare function useOptionalService<T>(token: InjectionToken<T, undefined>): UseOptionalServiceResult<T>;
|
|
162
|
+
declare function useOptionalService<T>(token: BoundInjectionToken<T, any>): UseOptionalServiceResult<T>;
|
|
163
|
+
declare function useOptionalService<T>(token: FactoryInjectionToken<T, any>): UseOptionalServiceResult<T>;
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/hooks/use-invalidate.d.mts
|
|
166
|
+
type InvalidatableToken = ClassType | InjectionToken<any, any> | BoundInjectionToken<any, any> | FactoryInjectionToken<any, any>;
|
|
167
|
+
/**
|
|
168
|
+
* Hook that returns a function to invalidate a service by its token.
|
|
169
|
+
*
|
|
170
|
+
* When called, this will:
|
|
171
|
+
* 1. Destroy the current service instance
|
|
172
|
+
* 2. Trigger re-fetch in all components using useService/useSuspenseService for that token
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```tsx
|
|
176
|
+
* function UserProfile() {
|
|
177
|
+
* const { data: user } = useService(UserService)
|
|
178
|
+
* const invalidateUser = useInvalidate(UserService)
|
|
179
|
+
*
|
|
180
|
+
* const handleRefresh = () => {
|
|
181
|
+
* invalidateUser() // All components using UserService will re-fetch
|
|
182
|
+
* }
|
|
183
|
+
*
|
|
184
|
+
* return (
|
|
185
|
+
* <div>
|
|
186
|
+
* <span>{user?.name}</span>
|
|
187
|
+
* <button onClick={handleRefresh}>Refresh</button>
|
|
188
|
+
* </div>
|
|
189
|
+
* )
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
declare function useInvalidate<T extends InvalidatableToken>(token: T): () => Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* Hook that returns a function to invalidate a service by its token with args.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```tsx
|
|
199
|
+
* function UserProfile({ userId }: { userId: string }) {
|
|
200
|
+
* const args = useMemo(() => ({ userId }), [userId])
|
|
201
|
+
* const { data: user } = useService(UserToken, args)
|
|
202
|
+
* const invalidateUser = useInvalidate(UserToken, args)
|
|
203
|
+
*
|
|
204
|
+
* return (
|
|
205
|
+
* <div>
|
|
206
|
+
* <span>{user?.name}</span>
|
|
207
|
+
* <button onClick={() => invalidateUser()}>Refresh</button>
|
|
208
|
+
* </div>
|
|
209
|
+
* )
|
|
210
|
+
* }
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
declare function useInvalidate<T, S extends InjectionTokenSchemaType>(token: InjectionToken<T, S>, args: S extends undefined ? never : unknown): () => Promise<void>;
|
|
214
|
+
/**
|
|
215
|
+
* Hook that returns a function to invalidate a service instance directly.
|
|
216
|
+
*
|
|
217
|
+
* This is useful when you have the service instance and want to invalidate it
|
|
218
|
+
* without knowing its token.
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```tsx
|
|
222
|
+
* function UserProfile() {
|
|
223
|
+
* const { data: user } = useService(UserService)
|
|
224
|
+
* const invalidateInstance = useInvalidateInstance()
|
|
225
|
+
*
|
|
226
|
+
* const handleRefresh = () => {
|
|
227
|
+
* if (user) {
|
|
228
|
+
* invalidateInstance(user)
|
|
229
|
+
* }
|
|
230
|
+
* }
|
|
231
|
+
*
|
|
232
|
+
* return (
|
|
233
|
+
* <div>
|
|
234
|
+
* <span>{user?.name}</span>
|
|
235
|
+
* <button onClick={handleRefresh}>Refresh</button>
|
|
236
|
+
* </div>
|
|
237
|
+
* )
|
|
238
|
+
* }
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
declare function useInvalidateInstance(): (instance: unknown) => Promise<void>;
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/hooks/use-scope.d.mts
|
|
244
|
+
/**
|
|
245
|
+
* Hook to get the current scope ID.
|
|
246
|
+
* Returns null if not inside a ScopeProvider.
|
|
247
|
+
*/
|
|
248
|
+
declare function useScope(): string | null;
|
|
249
|
+
/**
|
|
250
|
+
* Hook to get the current scope ID, throwing if not inside a ScopeProvider.
|
|
251
|
+
* Use this when your component requires a scope to function correctly.
|
|
252
|
+
*/
|
|
253
|
+
declare function useScopeOrThrow(): string;
|
|
254
|
+
/**
|
|
255
|
+
* Hook to get the current ScopedContainer.
|
|
256
|
+
* Returns null if not inside a ScopeProvider.
|
|
257
|
+
*
|
|
258
|
+
* Use this to access scope metadata or other ScopedContainer methods.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```tsx
|
|
262
|
+
* function TableRow() {
|
|
263
|
+
* const scope = useScopedContainer()
|
|
264
|
+
* const rowData = scope?.getMetadata('rowData')
|
|
265
|
+
* // ...
|
|
266
|
+
* }
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
declare function useScopedContainer(): ScopedContainer | null;
|
|
270
|
+
/**
|
|
271
|
+
* Hook to get the current ScopedContainer, throwing if not inside a ScopeProvider.
|
|
272
|
+
* Use this when your component requires a scope to function correctly.
|
|
273
|
+
*/
|
|
274
|
+
declare function useScopedContainerOrThrow(): ScopedContainer;
|
|
275
|
+
/**
|
|
276
|
+
* Hook to get metadata from the current scope.
|
|
277
|
+
* Returns undefined if not inside a ScopeProvider or if the key doesn't exist.
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```tsx
|
|
281
|
+
* // In parent component:
|
|
282
|
+
* <ScopeProvider metadata={{ userId: '123', theme: 'dark' }}>
|
|
283
|
+
* <ChildComponent />
|
|
284
|
+
* </ScopeProvider>
|
|
285
|
+
*
|
|
286
|
+
* // In child component:
|
|
287
|
+
* function ChildComponent() {
|
|
288
|
+
* const userId = useScopeMetadata<string>('userId')
|
|
289
|
+
* const theme = useScopeMetadata<'light' | 'dark'>('theme')
|
|
290
|
+
* // ...
|
|
291
|
+
* }
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
declare function useScopeMetadata<T = unknown>(key: string): T | undefined;
|
|
295
|
+
//#endregion
|
|
296
|
+
export { ContainerContext, ContainerProvider, type ContainerProviderProps, Join, ScopeProvider, type ScopeProviderProps, ScopedContainerContext, UnionToArray, type UseOptionalServiceResult, type UseServiceResult, useContainer, useInvalidate, useInvalidateInstance, useOptionalService, useRootContainer, useScope, useScopeMetadata, useScopeOrThrow, useScopedContainer, useScopedContainerOrThrow, useService, useSuspenseService };
|
|
297
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/providers/context.mts","../src/providers/container-provider.mts","../src/providers/scope-provider.mts","../src/hooks/use-container.mts","../src/types.mts","../src/hooks/use-service.mts","../src/hooks/use-suspense-service.mts","../src/hooks/use-optional-service.mts","../src/hooks/use-invalidate.mts","../src/hooks/use-scope.mts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAQa,kBAAgB,MAAA,CAAA,QAAA;AAA7B;AAMA;;;cAAa,wBAAsB,MAAA,CAAA,QAAA;;;UCPlB,sBAAA;aACJ;YACD;;ADDC,iBCIG,iBAAA,CDJa;EAAA,SAAA;EAAA;AAAA,CAAA,ECO1B,sBDP0B,CAAA,ECOJ,MAAA,CAAA,YDPI,CAAA,OAAA,EAAA,MAAA,GCOJ,MAAA,CAAA,qBDPI,CAAA,GAAA,CAAA,CAAA;;;UEAZ,kBAAA;;;;;EFAJ,OAAA,CAAA,EAAA,MAAA;EAMA;;;;ECPI,QAAA,CAAA,ECWJ,MDXI,CAAA,MAAA,EAAsB,OAAA,CAAA;EAKvB;;;;EAGS,QAAA,CAAA,EAAA,MAAA;EAAA,QAAA,ECSb,SDTa;;;;;ACPzB;AAyCA;;;;;;;;;;;;ACjCA;AAwBA;;;;ACtCA;AACK,iBF8CW,aAA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