@navios/di-react 1.0.0-alpha.3 → 2.0.0-alpha.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 +21 -0
- package/README.md +45 -665
- package/lib/{index.js → index.cjs} +249 -255
- package/lib/index.cjs.map +1 -0
- package/lib/{index.d.ts → index.d.cts} +94 -123
- package/lib/index.d.cts.map +1 -0
- package/lib/index.d.mts +93 -122
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +248 -255
- package/lib/index.mjs.map +1 -1
- package/package.json +32 -18
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -270
- package/coverage/coverage-final.json +0 -10
- package/coverage/favicon.png +0 -0
- package/coverage/hooks/index.html +0 -191
- package/coverage/hooks/use-container.mts.html +0 -268
- package/coverage/hooks/use-invalidate.mts.html +0 -208
- package/coverage/hooks/use-optional-service.mts.html +0 -910
- package/coverage/hooks/use-scope.mts.html +0 -346
- package/coverage/hooks/use-service.mts.html +0 -760
- package/coverage/hooks/use-suspense-service.mts.html +0 -784
- package/coverage/index.html +0 -131
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/providers/container-provider.mts.html +0 -139
- package/coverage/providers/context.mts.html +0 -130
- package/coverage/providers/index.html +0 -146
- package/coverage/providers/scope-provider.mts.html +0 -355
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/project.json +0 -61
- package/src/hooks/__tests__/use-container.spec.mts +0 -143
- package/src/hooks/__tests__/use-invalidate.spec.mts +0 -80
- package/src/hooks/__tests__/use-optional-service.spec.mts +0 -233
- package/src/hooks/__tests__/use-scope.spec.mts +0 -293
- package/src/hooks/__tests__/use-service.spec.mts +0 -212
- package/src/hooks/__tests__/use-suspense-service.spec.mts +0 -286
- package/src/hooks/index.mts +0 -14
- package/src/hooks/use-container.mts +0 -61
- package/src/hooks/use-invalidate.mts +0 -41
- package/src/hooks/use-optional-service.mts +0 -275
- package/src/hooks/use-scope.mts +0 -87
- package/src/hooks/use-service.mts +0 -225
- package/src/hooks/use-suspense-service.mts +0 -233
- package/src/index.mts +0 -8
- package/src/providers/__tests__/scope-provider.spec.mts +0 -366
- package/src/providers/container-provider.mts +0 -18
- package/src/providers/context.mts +0 -15
- package/src/providers/index.mts +0 -5
- package/src/providers/scope-provider.mts +0 -90
- package/src/types.mts +0 -21
- package/tsconfig.json +0 -13
- package/tsdown.config.mts +0 -14
- package/vitest.config.mts +0 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["createContext","jsx","useContext","useContext","useId","useRef","useReducer","useEffect","jsx","useContext","useMemo","useRef","useReducer","useState","useEffect","useCallback","useRef","useCallback","useSyncExternalStore","useEffect","useMemo","useRef","useReducer","useCallback","DIError","DIErrorCode","useEffect","useCallback"],"sources":["../src/container/context.mts","../src/container/container-provider.mts","../src/container/use-container.mts","../src/scope/scope-provider.mts","../src/scope/use-scope.mts","../src/service/args-key.mts","../src/service/use-service.mts","../src/service/use-suspense-service.mts","../src/service/use-optional-service.mts","../src/service/use-invalidate-instance.mts"],"sourcesContent":["import { createContext } from 'react'\n\nimport type { Container, ScopedContainer } from '@navios/di'\n\n/**\n * Context for the root Container.\n * This is set by ContainerProvider and provides the base container.\n */\nexport const ContainerContext = createContext<Container | null>(null)\n\n/**\n * Context for the current ScopedContainer (if inside a ScopeProvider).\n * This allows nested components to access request-scoped services.\n */\nexport const ScopedContainerContext = createContext<ScopedContainer | null>(null)\n","import { jsx } from 'react/jsx-runtime'\n\nimport type { Container } from '@navios/di'\nimport type { ReactNode } from 'react'\n\nimport { ContainerContext } from './context.mjs'\n\nexport interface ContainerProviderProps {\n container: Container\n children: ReactNode\n}\n\nexport function ContainerProvider({ container, children }: ContainerProviderProps) {\n return jsx(ContainerContext.Provider, { value: container, children })\n}\n","import { useContext } from 'react'\n\nimport type { Container, ScopedContainer } from '@navios/di'\n\nimport { ContainerContext, ScopedContainerContext } from './context.mjs'\n\n/**\n * Hook to get the current container (ScopedContainer if inside ScopeProvider, otherwise Container).\n *\n * This is the primary hook for accessing the DI container. It automatically\n * returns the correct container based on context:\n * - Inside a ScopeProvider: returns the ScopedContainer for request-scoped services\n * - Outside a ScopeProvider: returns the root Container\n *\n * @returns The current container (ScopedContainer or Container)\n */\nexport function useContainer(): Container | ScopedContainer {\n const scopedContainer = useContext(ScopedContainerContext)\n const container = useContext(ContainerContext)\n\n // Prefer scoped container if available (we're inside a ScopeProvider)\n if (scopedContainer) {\n return scopedContainer\n }\n\n if (!container) {\n throw new Error('useContainer must be used within a ContainerProvider')\n }\n\n return container\n}\n\n/**\n * Hook to get the root Container, regardless of whether we're inside a ScopeProvider.\n *\n * Use this when you need access to the root container specifically,\n * for example to create new request scopes programmatically.\n *\n * @returns The root Container\n */\nexport function useRootContainer(): Container {\n const container = useContext(ContainerContext)\n\n if (!container) {\n throw new Error('useRootContainer must be used within a ContainerProvider')\n }\n\n return container\n}\n","import { useContext, useEffect, useId, useReducer, useRef } from 'react'\nimport { jsx } from 'react/jsx-runtime'\n\nimport type { ScopedContainer } from '@navios/di'\nimport type { ReactNode } from 'react'\n\nimport { ContainerContext, ScopedContainerContext } from '../container/context.mjs'\n\nexport interface ScopeProviderProps {\n /**\n * Optional explicit scope ID. If not provided, a unique ID will be generated.\n * Useful when you need to reference the scope externally.\n */\n scopeId?: string\n /**\n * Optional metadata to attach to the scope.\n * The key `scopeId` is reserved: it always holds the effective scope ID.\n * Can be used to pass data like user info, request headers, etc.\n */\n metadata?: Record<string, unknown>\n children: ReactNode\n}\n\n/**\n * ScopeProvider creates a new request scope for dependency injection.\n *\n * Services with `scope: 'Request'` will be instantiated once per ScopeProvider\n * and shared among all components within that provider.\n *\n * This is useful for:\n * - Table rows that need isolated state\n * - Modal dialogs with their own service instances\n * - Multi-tenant scenarios\n * - Any case where you need isolated service instances\n *\n * @example\n * ```tsx\n * // Each row gets its own RowStateService instance\n * {rows.map(row => (\n * <ScopeProvider key={row.id} scopeId={row.id} metadata={{ rowData: row }}>\n * <TableRow />\n * </ScopeProvider>\n * ))}\n * ```\n */\nexport function ScopeProvider({ scopeId, metadata, children }: ScopeProviderProps) {\n const container = useContext(ContainerContext)\n if (!container) {\n throw new Error('ScopeProvider must be used within a ContainerProvider')\n }\n\n const generatedId = useId()\n const effectiveScopeId = scopeId ?? generatedId\n const scopedContainerRef = useRef<ScopedContainer | null>(null)\n // True between an effect setup and its cleanup.\n const isMountedRef = useRef(false)\n // True once the scope in the ref has been disposed.\n const isDisposedRef = useRef(false)\n const [, rerender] = useReducer((count: number) => count + 1, 0)\n\n // DI scopes have no ids, so the effective scope id lives in the scope's\n // metadata under `scopeId`.\n const createScope = () => container.createScope({ ...metadata, scopeId: effectiveScopeId })\n const createScopeRef = useRef(createScope)\n createScopeRef.current = createScope\n\n // Create the ScopedContainer once per mounted provider.\n // The ref keeps it stable across re-renders.\n if (!scopedContainerRef.current) {\n scopedContainerRef.current = createScope()\n }\n\n useEffect(() => {\n isMountedRef.current = true\n // React re-ran the effect after the scope was disposed (an `<Activity>`\n // shown again): the old scope is gone for good, so start a new one.\n if (isDisposedRef.current) {\n isDisposedRef.current = false\n scopedContainerRef.current = createScopeRef.current()\n rerender()\n }\n return () => {\n isMountedRef.current = false\n // Disposal waits one microtask. StrictMode's simulated unmount is\n // followed by a re-mount in the same commit, which sets the flag again\n // and keeps the scope; a real unmount leaves it unset.\n queueMicrotask(() => {\n if (isMountedRef.current || isDisposedRef.current) {\n return\n }\n isDisposedRef.current = true\n void scopedContainerRef.current?.dispose()\n })\n }\n }, [])\n\n return jsx(ScopedContainerContext.Provider, {\n value: scopedContainerRef.current,\n children,\n })\n}\n","import { useContext } from 'react'\n\nimport type { ScopedContainer } from '@navios/di'\n\nimport { ScopedContainerContext } from '../container/context.mjs'\n\n/**\n * Hook to get the current scope ID.\n * Returns null if not inside a ScopeProvider.\n */\nexport function useScope(): string | null {\n const scopedContainer = useContext(ScopedContainerContext)\n return (scopedContainer?.getMetadata('scopeId') as string | undefined) ?? null\n}\n\n/**\n * Hook to get the current scope ID, throwing if not inside a ScopeProvider.\n * Use this when your component requires a scope to function correctly.\n */\nexport function useScopeOrThrow(): string {\n const scopeId = useScope()\n if (scopeId === null) {\n throw new Error(\n 'useScopeOrThrow must be used within a ScopeProvider. ' +\n 'Wrap your component tree with <ScopeProvider> to create a request scope.',\n )\n }\n return scopeId\n}\n\n/**\n * Hook to get the current ScopedContainer.\n * Returns null if not inside a ScopeProvider.\n *\n * Use this to access scope metadata or other ScopedContainer methods.\n *\n * @example\n * ```tsx\n * function TableRow() {\n * const scope = useScopedContainer()\n * const rowData = scope?.getMetadata('rowData')\n * // ...\n * }\n * ```\n */\nexport function useScopedContainer(): ScopedContainer | null {\n return useContext(ScopedContainerContext)\n}\n\n/**\n * Hook to get the current ScopedContainer, throwing if not inside a ScopeProvider.\n * Use this when your component requires a scope to function correctly.\n */\nexport function useScopedContainerOrThrow(): ScopedContainer {\n const scopedContainer = useScopedContainer()\n if (scopedContainer === null) {\n throw new Error(\n 'useScopedContainerOrThrow must be used within a ScopeProvider. ' +\n 'Wrap your component tree with <ScopeProvider> to create a request scope.',\n )\n }\n return scopedContainer\n}\n\n/**\n * Hook to get metadata from the current scope.\n * Returns undefined if not inside a ScopeProvider or if the key doesn't exist.\n *\n * @example\n * ```tsx\n * // In parent component:\n * <ScopeProvider metadata={{ userId: '123', theme: 'dark' }}>\n * <ChildComponent />\n * </ScopeProvider>\n *\n * // In child component:\n * function ChildComponent() {\n * const userId = useScopeMetadata<string>('userId')\n * const theme = useScopeMetadata<'light' | 'dark'>('theme')\n * // ...\n * }\n * ```\n */\nexport function useScopeMetadata<T = unknown>(key: string): T | undefined {\n const scopedContainer = useContext(ScopedContainerContext)\n return scopedContainer?.getMetadata(key) as T | undefined\n}\n","let nextId = 0\nconst objectIds = new WeakMap<object, number>()\n\n/** What the container compares by value, and JSON would leave out. */\nfunction replacer(_key: string, value: unknown): unknown {\n if (typeof value === 'bigint' || value instanceof RegExp) {\n return { [typeof value]: String(value) }\n }\n if (value instanceof Map || value instanceof Set) {\n return { [value.constructor.name]: Array.from(value as Iterable<unknown>) }\n }\n return value\n}\n\n/**\n * Key that identifies the args of a hook call. Args that serialize to the same\n * JSON share a key, so an object literal written in the call, or a function in\n * it, does not count as a change on every render.\n *\n * Args JSON cannot serialize, which contain themselves, are keyed by identity.\n */\nexport function getArgsKey(args: unknown): string {\n try {\n return JSON.stringify(args, replacer) ?? ''\n } catch {\n const object = args as object\n let id = objectIds.get(object)\n if (id === undefined) {\n id = ++nextId\n objectIds.set(object, id)\n }\n return `#${id}`\n }\n}\n","import { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react'\n\nimport type {\n AnyInjectableType,\n BoundInjectionToken,\n ClassType,\n FactoryInjectionToken,\n InferInput,\n InjectionToken,\n MissingArgsError,\n ResolvedInstance,\n StandardSchemaV1,\n} from '@navios/di'\n\nimport { useContainer } from '../container/use-container.mjs'\n\nimport { getArgsKey } from './args-key.mjs'\n\nimport type { InitialSync } from './initial-sync.mjs'\n\ntype ServiceState<T> =\n | { status: 'idle' }\n | { status: 'loading' }\n | { status: 'success'; data: T }\n | { status: 'error'; error: Error }\n\ntype ServiceAction<T> =\n | { type: 'loading' }\n | { type: 'success'; data: T }\n | { type: 'error'; error: Error }\n | { type: 'reset' }\n\nfunction serviceReducer<T>(state: ServiceState<T>, action: ServiceAction<T>): ServiceState<T> {\n switch (action.type) {\n case 'loading':\n return { status: 'loading' }\n case 'success':\n return { status: 'success', data: action.data }\n case 'error':\n return { status: 'error', error: action.error }\n case 'reset':\n return { status: 'idle' }\n default:\n return state\n }\n}\n\nexport interface UseServiceResult<T> {\n data: T | undefined\n error: Error | undefined\n isLoading: boolean\n isSuccess: boolean\n isError: boolean\n refetch: () => void\n}\n\n// #1 Simple class\nexport function useService<T extends ClassType>(token: T): UseServiceResult<ResolvedInstance<T>>\n\n// #2 Token with required Schema\nexport function useService<T, S extends StandardSchemaV1>(\n token: InjectionToken<T, S>,\n args: InferInput<S>,\n): UseServiceResult<T>\n\n// #3 Token with optional Schema\nexport function useService<T, S extends StandardSchemaV1, R extends boolean>(\n token: InjectionToken<T, S, R>,\n): R extends false ? UseServiceResult<T> : MissingArgsError<S>\n\n// #4 Token with no Schema\nexport function useService<T>(token: InjectionToken<T, unknown>): UseServiceResult<T>\n\nexport function useService<T>(token: BoundInjectionToken<T, any>): UseServiceResult<T>\n\nexport function useService<T>(token: FactoryInjectionToken<T, any>): UseServiceResult<T>\n\nexport function useService(\n token:\n | ClassType\n | InjectionToken<any, any>\n | BoundInjectionToken<any, any>\n | FactoryInjectionToken<any, any>,\n args?: unknown,\n): UseServiceResult<any> {\n // useContainer returns ScopedContainer if inside ScopeProvider, otherwise Container\n // This automatically handles request-scoped services correctly\n const container = useContainer()\n\n // Args that serialize the same are the same args: an object literal in the\n // call must not restart the hook on every render.\n const argsKey = getArgsKey(args)\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n const stableArgs = useMemo(() => args, [argsKey])\n\n // Try to get the instance synchronously first for better performance\n // This avoids the async loading state when the instance is already cached\n // The ref remembers what it was read for, so the shortcut is only taken for\n // that container, token and args.\n const initialSyncRef = useRef<InitialSync | null | undefined>(undefined)\n\n if (initialSyncRef.current === undefined) {\n const instance = container.peek(token as InjectionToken<any, any>, args)\n initialSyncRef.current = instance === null ? null : { container, token, argsKey, instance }\n }\n\n const initialState: ServiceState<any> =\n initialSyncRef.current !== null\n ? { status: 'success', data: initialSyncRef.current.instance }\n : { status: 'idle' }\n\n const [state, dispatch] = useReducer(serviceReducer, initialState)\n const [refetchCounter, setRefetchCounter] = useState(0)\n\n // Subscribe to invalidation events\n useEffect(() => {\n let unsubscribe: (() => void) | undefined\n let isMounted = true\n\n // The container routes the listener to the store that owns the instance\n // (the root store for singletons, the scope's store for request-scoped).\n const subscribe = () => {\n if (unsubscribe) return\n unsubscribe = container.onInvalidate(token, stableArgs, () => {\n // Re-fetch when the service is invalidated\n if (!isMounted) return\n dispatch({ type: 'loading' })\n // Listeners run once the invalidation has finished, so resolving here\n // builds the service once. The microtask only keeps the resolution out\n // of the container's notification loop.\n queueMicrotask(() => {\n if (isMounted) {\n void fetchAndSubscribe()\n }\n })\n })\n }\n\n // Fetch the service and set up subscription\n const fetchAndSubscribe = async () => {\n try {\n // The container (either ScopedContainer or Container) handles resolution correctly\n const instance = await container.get(\n // @ts-expect-error - token is valid\n token as AnyInjectableType,\n stableArgs as any,\n )\n\n if (!isMounted) return\n\n dispatch({ type: 'success', data: instance })\n\n // Set up subscription after we have the instance\n subscribe()\n } catch (error) {\n if (isMounted) {\n dispatch({ type: 'error', error: error as Error })\n }\n }\n }\n\n // If the instance read during the first render is still the one asked\n // for, just set up the subscription. Otherwise, fetch async.\n const initial = initialSyncRef.current\n if (\n initial != null &&\n initial.container === container &&\n initial.token === token &&\n initial.argsKey === argsKey &&\n refetchCounter === 0\n ) {\n subscribe()\n } else {\n initialSyncRef.current = null\n dispatch({ type: 'loading' })\n void fetchAndSubscribe()\n }\n\n return () => {\n isMounted = false\n unsubscribe?.()\n }\n }, [container, token, stableArgs, argsKey, refetchCounter])\n\n const refetch = useCallback(() => {\n setRefetchCounter((c) => c + 1)\n }, [])\n\n return {\n data: state.status === 'success' ? state.data : undefined,\n error: state.status === 'error' ? state.error : undefined,\n isLoading: state.status === 'loading',\n isSuccess: state.status === 'success',\n isError: state.status === 'error',\n refetch,\n }\n}\n","import { useCallback, useEffect, useRef, useSyncExternalStore } from 'react'\n\nimport type {\n BoundInjectionToken,\n ClassType,\n Container,\n FactoryInjectionToken,\n InferInput,\n InjectionToken,\n MissingArgsError,\n ResolvedInstance,\n ScopedContainer,\n StandardSchemaV1,\n} from '@navios/di'\n\nimport { useContainer } from '../container/use-container.mjs'\n\nimport { getArgsKey } from './args-key.mjs'\n\n// Cache entry for suspense\ninterface CacheEntry<T> {\n promise: Promise<T> | null\n result: T | undefined\n error: Error | undefined\n status: 'pending' | 'resolved' | 'rejected'\n version: number // Increment on each fetch to track changes\n subscribers: Set<() => void>\n unsubscribe: (() => void) | undefined\n}\n\ntype AnyContainer = Container | ScopedContainer\ntype AnyToken =\n | ClassType\n | InjectionToken<any, any>\n | BoundInjectionToken<any, any>\n | FactoryInjectionToken<any, any>\n\n// Global cache for service instances: container -> token object -> args key.\n// Tokens have no ids, so the token object itself (class, token, or the\n// Bound/Factory wrapper) is the identity.\nconst cacheMap = new WeakMap<object, WeakMap<object, Map<string, CacheEntry<any>>>>()\n\nfunction getCache(container: object, token: object): Map<string, CacheEntry<any>> {\n let byToken = cacheMap.get(container)\n if (!byToken) {\n byToken = new WeakMap()\n cacheMap.set(container, byToken)\n }\n let cache = byToken.get(token)\n if (!cache) {\n cache = new Map()\n byToken.set(token, cache)\n }\n return cache\n}\n\n/**\n * Sets up invalidation subscription for a cache entry if not already subscribed.\n * When the service is destroyed, clears the cache and notifies subscribers.\n */\nfunction setupInvalidationSubscription(\n entry: CacheEntry<any>,\n container: AnyContainer,\n token: AnyToken,\n args: unknown,\n): void {\n if (entry.unsubscribe) return\n\n entry.unsubscribe = container.onInvalidate(token, args, () => {\n // Clear cache and notify subscribers to re-fetch\n entry.result = undefined\n entry.error = undefined\n entry.status = 'pending'\n entry.promise = null\n // Notify all subscribers\n entry.subscribers.forEach((callback) => callback())\n })\n}\n\n// #1 Simple class\nexport function useSuspenseService<T extends ClassType>(token: T): ResolvedInstance<T>\n\n// #2 Token with required Schema\nexport function useSuspenseService<T, S extends StandardSchemaV1>(\n token: InjectionToken<T, S>,\n args: InferInput<S>,\n): T\n\n// #3 Token with optional Schema\nexport function useSuspenseService<T, S extends StandardSchemaV1, R extends boolean>(\n token: InjectionToken<T, S, R>,\n): R extends false ? T : MissingArgsError<S>\n\n// #4 Token with no Schema\nexport function useSuspenseService<T>(token: InjectionToken<T, unknown>): T\n\nexport function useSuspenseService<T>(token: BoundInjectionToken<T, any>): T\n\nexport function useSuspenseService<T>(token: FactoryInjectionToken<T, any>): T\n\nexport function useSuspenseService(\n token:\n | ClassType\n | InjectionToken<any, any>\n | BoundInjectionToken<any, any>\n | FactoryInjectionToken<any, any>,\n args?: unknown,\n): any {\n // useContainer returns ScopedContainer if inside ScopeProvider, otherwise Container\n const container = useContainer()\n const cache = getCache(container, token)\n const cacheKey = getArgsKey(args)\n const entryRef = useRef<CacheEntry<any> | null>(null)\n\n // Initialize or get cache entry\n if (!cache.has(cacheKey)) {\n // Try to get the instance synchronously first for better performance\n // This avoids suspense when the instance is already cached\n const syncInstance = container.peek(token as InjectionToken<any, any>, args)\n\n const entry: CacheEntry<any> = {\n promise: null,\n result: syncInstance !== null ? syncInstance : undefined,\n error: undefined,\n status: syncInstance !== null ? 'resolved' : 'pending',\n version: 0,\n subscribers: new Set(),\n unsubscribe: undefined,\n }\n cache.set(cacheKey, entry)\n }\n\n const entry = cache.get(cacheKey)!\n entryRef.current = entry\n\n // Function to fetch the service\n const fetchService = useCallback(() => {\n const currentEntry = entryRef.current\n if (!currentEntry) return\n\n currentEntry.status = 'pending'\n currentEntry.version++ // Increment version to signal change to useSyncExternalStore\n currentEntry.promise = (container.get as any)(token, args)\n .then((instance: any) => {\n currentEntry.result = instance\n currentEntry.status = 'resolved'\n\n // Subscribe to invalidation events if not already subscribed\n setupInvalidationSubscription(currentEntry, container, token, args)\n\n // Notify subscribers\n currentEntry.subscribers.forEach((callback) => callback())\n return instance\n })\n .catch((error: Error) => {\n currentEntry.error = error\n currentEntry.status = 'rejected'\n throw error\n })\n\n return currentEntry.promise\n }, [container, token, args])\n\n // Subscribe to cache changes\n const subscribe = useCallback(\n (callback: () => void) => {\n entry.subscribers.add(callback)\n return () => {\n entry.subscribers.delete(callback)\n }\n },\n [entry],\n )\n\n // Get snapshot of current state - include version to detect invalidation\n const getSnapshot = useCallback(() => {\n return `${entry.status}:${entry.version}`\n }, [entry])\n\n // Use sync external store to track cache state\n useSyncExternalStore(subscribe, getSnapshot, getSnapshot)\n\n // Set up subscription for sync instances that don't have one yet\n useEffect(() => {\n const currentEntry = entryRef.current\n if (currentEntry && currentEntry.status === 'resolved' && !currentEntry.unsubscribe) {\n setupInvalidationSubscription(currentEntry, container, token, args)\n }\n }, [container, token, args, entry])\n\n // Start fetching if not already\n if (entry.status === 'pending' && !entry.promise) {\n fetchService()\n }\n\n // Suspense behavior\n if (entry.status === 'pending') {\n throw entry.promise\n }\n\n if (entry.status === 'rejected') {\n throw entry.error\n }\n\n return entry.result\n}\n","import { DIError, DIErrorCode } from '@navios/di'\nimport { useCallback, useEffect, useMemo, useReducer, useRef } from 'react'\n\nimport type {\n AnyInjectableType,\n BoundInjectionToken,\n ClassType,\n FactoryInjectionToken,\n InferInput,\n InjectionToken,\n MissingArgsError,\n ResolvedInstance,\n StandardSchemaV1,\n} from '@navios/di'\n\nimport { useContainer } from '../container/use-container.mjs'\n\nimport { getArgsKey } from './args-key.mjs'\n\nimport type { InitialSync } from './initial-sync.mjs'\n\ntype OptionalServiceState<T> =\n | { status: 'idle' }\n | { status: 'loading' }\n | { status: 'success'; data: T }\n | { status: 'not-found' }\n | { status: 'error'; error: Error }\n\ntype OptionalServiceAction<T> =\n | { type: 'loading' }\n | { type: 'success'; data: T }\n | { type: 'not-found' }\n | { type: 'error'; error: Error }\n | { type: 'reset' }\n\nfunction optionalServiceReducer<T>(\n state: OptionalServiceState<T>,\n action: OptionalServiceAction<T>,\n): OptionalServiceState<T> {\n switch (action.type) {\n case 'loading':\n return { status: 'loading' }\n case 'success':\n return { status: 'success', data: action.data }\n case 'not-found':\n return { status: 'not-found' }\n case 'error':\n return { status: 'error', error: action.error }\n case 'reset':\n return { status: 'idle' }\n default:\n return state\n }\n}\n\nexport interface UseOptionalServiceResult<T> {\n /**\n * The service instance if found and loaded successfully, otherwise undefined.\n */\n data: T | undefined\n /**\n * Error that occurred during loading (excludes \"not found\" which is not an error).\n */\n error: Error | undefined\n /**\n * True while the service is being loaded.\n */\n isLoading: boolean\n /**\n * True if the service was loaded successfully.\n */\n isSuccess: boolean\n /**\n * True if the service was not found (not registered in the container).\n */\n isNotFound: boolean\n /**\n * True if an error occurred during loading.\n */\n isError: boolean\n /**\n * Function to manually re-fetch the service.\n */\n refetch: () => void\n}\n\n// #1 Simple class\nexport function useOptionalService<T extends ClassType>(\n token: T,\n): UseOptionalServiceResult<ResolvedInstance<T>>\n\n// #2 Token with required Schema\nexport function useOptionalService<T, S extends StandardSchemaV1>(\n token: InjectionToken<T, S>,\n args: InferInput<S>,\n): UseOptionalServiceResult<T>\n\n// #3 Token with optional Schema\nexport function useOptionalService<T, S extends StandardSchemaV1, R extends boolean>(\n token: InjectionToken<T, S, R>,\n): R extends false ? UseOptionalServiceResult<T> : MissingArgsError<S>\n\n// #4 Token with no Schema\nexport function useOptionalService<T>(\n token: InjectionToken<T, unknown>,\n): UseOptionalServiceResult<T>\n\nexport function useOptionalService<T>(\n token: BoundInjectionToken<T, any>,\n): UseOptionalServiceResult<T>\n\nexport function useOptionalService<T>(\n token: FactoryInjectionToken<T, any>,\n): UseOptionalServiceResult<T>\n\n/**\n * Hook to optionally load a service from the DI container.\n *\n * Unlike useService, this hook does NOT throw an error if the service is not registered.\n * Instead, it returns `isNotFound: true` when the service doesn't exist.\n *\n * This is useful for:\n * - Optional dependencies that may or may not be configured\n * - Feature flags where a service might not be available\n * - Plugins or extensions that are conditionally registered\n *\n * @example\n * ```tsx\n * function Analytics() {\n * const { data: analytics, isNotFound } = useOptionalService(AnalyticsService)\n *\n * if (isNotFound) {\n * // Analytics service not configured, skip tracking\n * return null\n * }\n *\n * return <AnalyticsTracker service={analytics} />\n * }\n * ```\n */\nexport function useOptionalService(\n token:\n | ClassType\n | InjectionToken<any, any>\n | BoundInjectionToken<any, any>\n | FactoryInjectionToken<any, any>,\n args?: unknown,\n): UseOptionalServiceResult<any> {\n // useContainer returns ScopedContainer if inside ScopeProvider, otherwise Container\n const container = useContainer()\n\n // Args that serialize the same are the same args: an object literal in the\n // call must not restart the hook on every render.\n const argsKey = getArgsKey(args)\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n const stableArgs = useMemo(() => args, [argsKey])\n\n // Try to get the instance synchronously first for better performance\n // This avoids the async loading state when the instance is already cached\n // The ref remembers what it was read for, so the shortcut is only taken for\n // that container, token and args.\n const initialSyncRef = useRef<InitialSync | null | undefined>(undefined)\n\n if (initialSyncRef.current === undefined) {\n let instance: unknown = null\n try {\n instance = container.peek(token as InjectionToken<any, any>, args)\n } catch {\n // Service not registered, leave as null\n }\n initialSyncRef.current = instance === null ? null : { container, token, argsKey, instance }\n }\n\n const initialState: OptionalServiceState<any> =\n initialSyncRef.current !== null\n ? { status: 'success', data: initialSyncRef.current.instance }\n : { status: 'idle' }\n\n const [state, dispatch] = useReducer(optionalServiceReducer, initialState)\n\n // Resolves to true when the service was loaded\n const fetchService = useCallback(async (): Promise<boolean> => {\n dispatch({ type: 'loading' })\n try {\n // Use the container (ScopedContainer or Container) for resolution\n const instance = await container.get(\n // @ts-expect-error - token is valid\n token as AnyInjectableType,\n stableArgs as any,\n )\n dispatch({ type: 'success', data: instance })\n return true\n } catch (error) {\n if (\n error instanceof DIError &&\n error.code === DIErrorCode.ProviderNotFound &&\n // It may be something the service depends on.\n !container.isRegistered(token)\n ) {\n dispatch({ type: 'not-found' })\n } else {\n dispatch({ type: 'error', error: error as Error })\n }\n return false\n }\n }, [container, token, stableArgs])\n\n // Subscribe to invalidation events\n useEffect(() => {\n let unsubscribe: (() => void) | undefined\n let isMounted = true\n\n const subscribe = () => {\n if (unsubscribe || !isMounted) return\n unsubscribe = container.onInvalidate(token, stableArgs, () => {\n // Re-fetch when the service is invalidated\n dispatch({ type: 'loading' })\n // Listeners run once the invalidation has finished, so resolving here\n // builds the service once. The microtask only keeps the resolution out\n // of the container's notification loop.\n queueMicrotask(() => {\n if (isMounted) {\n void fetchService()\n }\n })\n })\n }\n\n // If the instance read during the first render is still the one asked\n // for, just set up the subscription. Otherwise, fetch async.\n const initial = initialSyncRef.current\n if (\n initial != null &&\n initial.container === container &&\n initial.token === token &&\n initial.argsKey === argsKey\n ) {\n subscribe()\n } else {\n initialSyncRef.current = null\n void fetchService().then((loaded) => {\n if (loaded) {\n subscribe()\n }\n })\n }\n\n return () => {\n isMounted = false\n unsubscribe?.()\n }\n }, [fetchService, container, token, stableArgs, argsKey])\n\n return {\n data: state.status === 'success' ? state.data : undefined,\n error: state.status === 'error' ? state.error : undefined,\n isLoading: state.status === 'loading',\n isSuccess: state.status === 'success',\n isNotFound: state.status === 'not-found',\n isError: state.status === 'error',\n refetch: fetchService,\n }\n}\n","import { useCallback } from 'react'\n\nimport { useContainer } from '../container/use-container.mjs'\n\n/**\n * Hook that returns a function to invalidate a service instance directly.\n *\n * This is useful when you have the service instance and want to invalidate it\n * without knowing its token.\n *\n * @example\n * ```tsx\n * function UserProfile() {\n * const { data: user } = useService(UserService)\n * const invalidateInstance = useInvalidateInstance()\n *\n * const handleRefresh = () => {\n * if (user) {\n * invalidateInstance(user)\n * }\n * }\n *\n * return (\n * <div>\n * <span>{user?.name}</span>\n * <button onClick={handleRefresh}>Refresh</button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useInvalidateInstance(): (instance: unknown) => Promise<void> {\n const container = useContainer()\n\n return useCallback(\n async (instance: unknown) => {\n await container.invalidate(instance)\n },\n [container],\n )\n}\n"],"mappings":";;;;;;;;;AAQA,MAAa,oBAAA,GAAmBA,MAAAA,cAAAA,CAAgC,IAAI;;;;;AAMpE,MAAa,0BAAA,GAAyBA,MAAAA,cAAAA,CAAsC,IAAI;;ACFhF,SAAgB,kBAAkB,EAAE,WAAW,YAAoC;CACjF,QAAA,GAAOC,kBAAAA,IAAAA,CAAI,iBAAiB,UAAU;EAAE,OAAO;EAAW;CAAS,CAAC;AACtE;;;;;;;;;;;;ACEA,SAAgB,eAA4C;CAC1D,MAAM,mBAAA,GAAkBC,MAAAA,WAAAA,CAAW,sBAAsB;CACzD,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M,UAAU,eAAe;EAC/B,IACE,WAAW,QACX,QAAQ,cAAc,aACtB,QAAQ,UAAU,SAClB,QAAQ,YAAY,SAEpB,UAAU;OACL;GACL,eAAe,UAAU;GACpB,aAAa,CAAC,CAAC,MAAM,WAAW;IACnC,IAAI,QACF,UAAU;GAEd,CAAC;EACH;EAEA,aAAa;GACX,YAAY;GACZ,cAAc;EAChB;CACF,GAAG;EAAC;EAAc;EAAW;EAAO;EAAY;CAAO,CAAC;CAExD,OAAO;EACL,MAAM,MAAM,WAAW,YAAY,MAAM,OAAO,KAAA;EAChD,OAAO,MAAM,WAAW,UAAU,MAAM,QAAQ,KAAA;EAChD,WAAW,MAAM,WAAW;EAC5B,WAAW,MAAM,WAAW;EAC5B,YAAY,MAAM,WAAW;EAC7B,SAAS,MAAM,WAAW;EAC1B,SAAS;CACX;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACvOA,SAAgB,wBAA8D;CAC5E,MAAM,YAAY,aAAa;CAE/B,QAAA,GAAOC,MAAAA,YAAAA,CACL,OAAO,aAAsB;EAC3B,MAAM,UAAU,WAAW,QAAQ;CACrC,GACA,CAAC,SAAS,CACZ;AACF"}
|
|
@@ -1,31 +1,40 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BoundInjectionToken, ClassType, Container, FactoryInjectionToken, InferInput, InjectionToken, MissingArgsError, ResolvedInstance, ScopedContainer, StandardSchemaV1 } from "@navios/di";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
|
-
import { BoundInjectionToken, ClassType, Container, Factorable, FactoryInjectionToken, InjectionToken, InjectionTokenSchemaType, ScopedContainer } from "@navios/di";
|
|
4
|
-
import { ZodType, z } from "zod/v4";
|
|
5
|
-
|
|
6
|
-
//#region src/providers/context.d.mts
|
|
7
3
|
/**
|
|
8
4
|
* Context for the root Container.
|
|
9
5
|
* This is set by ContainerProvider and provides the base container.
|
|
10
6
|
*/
|
|
11
|
-
declare const ContainerContext:
|
|
7
|
+
export declare const ContainerContext: import("react").Context<Container | null>;
|
|
12
8
|
/**
|
|
13
9
|
* Context for the current ScopedContainer (if inside a ScopeProvider).
|
|
14
10
|
* This allows nested components to access request-scoped services.
|
|
15
11
|
*/
|
|
16
|
-
declare const ScopedContainerContext:
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/providers/container-provider.d.mts
|
|
12
|
+
export declare const ScopedContainerContext: import("react").Context<ScopedContainer | null>;
|
|
19
13
|
interface ContainerProviderProps {
|
|
20
14
|
container: Container;
|
|
21
15
|
children: ReactNode;
|
|
22
16
|
}
|
|
23
|
-
declare function ContainerProvider({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
export declare function ContainerProvider({ container, children }: ContainerProviderProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
18
|
+
/**
|
|
19
|
+
* Hook to get the current container (ScopedContainer if inside ScopeProvider, otherwise Container).
|
|
20
|
+
*
|
|
21
|
+
* This is the primary hook for accessing the DI container. It automatically
|
|
22
|
+
* returns the correct container based on context:
|
|
23
|
+
* - Inside a ScopeProvider: returns the ScopedContainer for request-scoped services
|
|
24
|
+
* - Outside a ScopeProvider: returns the root Container
|
|
25
|
+
*
|
|
26
|
+
* @returns The current container (ScopedContainer or Container)
|
|
27
|
+
*/
|
|
28
|
+
export declare function useContainer(): Container | ScopedContainer;
|
|
29
|
+
/**
|
|
30
|
+
* Hook to get the root Container, regardless of whether we're inside a ScopeProvider.
|
|
31
|
+
*
|
|
32
|
+
* Use this when you need access to the root container specifically,
|
|
33
|
+
* for example to create new request scopes programmatically.
|
|
34
|
+
*
|
|
35
|
+
* @returns The root Container
|
|
36
|
+
*/
|
|
37
|
+
export declare function useRootContainer(): Container;
|
|
29
38
|
interface ScopeProviderProps {
|
|
30
39
|
/**
|
|
31
40
|
* Optional explicit scope ID. If not provided, a unique ID will be generated.
|
|
@@ -33,7 +42,8 @@ interface ScopeProviderProps {
|
|
|
33
42
|
*/
|
|
34
43
|
scopeId?: string;
|
|
35
44
|
/**
|
|
36
|
-
* Optional metadata to attach to the
|
|
45
|
+
* Optional metadata to attach to the scope.
|
|
46
|
+
* The key `scopeId` is reserved: it always holds the effective scope ID.
|
|
37
47
|
* Can be used to pass data like user info, request headers, etc.
|
|
38
48
|
*/
|
|
39
49
|
metadata?: Record<string, unknown>;
|
|
@@ -61,40 +71,58 @@ interface ScopeProviderProps {
|
|
|
61
71
|
* ))}
|
|
62
72
|
* ```
|
|
63
73
|
*/
|
|
64
|
-
declare function ScopeProvider({
|
|
65
|
-
scopeId,
|
|
66
|
-
metadata,
|
|
67
|
-
children
|
|
68
|
-
}: ScopeProviderProps): react1.ReactElement<unknown, string | react1.JSXElementConstructor<any>> | null;
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/hooks/use-container.d.mts
|
|
74
|
+
export declare function ScopeProvider({ scopeId, metadata, children }: ScopeProviderProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
71
75
|
/**
|
|
72
|
-
* Hook to get the current
|
|
76
|
+
* Hook to get the current scope ID.
|
|
77
|
+
* Returns null if not inside a ScopeProvider.
|
|
78
|
+
*/
|
|
79
|
+
export declare function useScope(): string | null;
|
|
80
|
+
/**
|
|
81
|
+
* Hook to get the current scope ID, throwing if not inside a ScopeProvider.
|
|
82
|
+
* Use this when your component requires a scope to function correctly.
|
|
83
|
+
*/
|
|
84
|
+
export declare function useScopeOrThrow(): string;
|
|
85
|
+
/**
|
|
86
|
+
* Hook to get the current ScopedContainer.
|
|
87
|
+
* Returns null if not inside a ScopeProvider.
|
|
73
88
|
*
|
|
74
|
-
*
|
|
75
|
-
* returns the correct container based on context:
|
|
76
|
-
* - Inside a ScopeProvider: returns the ScopedContainer for request-scoped services
|
|
77
|
-
* - Outside a ScopeProvider: returns the root Container
|
|
89
|
+
* Use this to access scope metadata or other ScopedContainer methods.
|
|
78
90
|
*
|
|
79
|
-
* @
|
|
91
|
+
* @example
|
|
92
|
+
* ```tsx
|
|
93
|
+
* function TableRow() {
|
|
94
|
+
* const scope = useScopedContainer()
|
|
95
|
+
* const rowData = scope?.getMetadata('rowData')
|
|
96
|
+
* // ...
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
80
99
|
*/
|
|
81
|
-
declare function
|
|
100
|
+
export declare function useScopedContainer(): ScopedContainer | null;
|
|
82
101
|
/**
|
|
83
|
-
* Hook to get the
|
|
102
|
+
* Hook to get the current ScopedContainer, throwing if not inside a ScopeProvider.
|
|
103
|
+
* Use this when your component requires a scope to function correctly.
|
|
104
|
+
*/
|
|
105
|
+
export declare function useScopedContainerOrThrow(): ScopedContainer;
|
|
106
|
+
/**
|
|
107
|
+
* Hook to get metadata from the current scope.
|
|
108
|
+
* Returns undefined if not inside a ScopeProvider or if the key doesn't exist.
|
|
84
109
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```tsx
|
|
112
|
+
* // In parent component:
|
|
113
|
+
* <ScopeProvider metadata={{ userId: '123', theme: 'dark' }}>
|
|
114
|
+
* <ChildComponent />
|
|
115
|
+
* </ScopeProvider>
|
|
87
116
|
*
|
|
88
|
-
*
|
|
117
|
+
* // In child component:
|
|
118
|
+
* function ChildComponent() {
|
|
119
|
+
* const userId = useScopeMetadata<string>('userId')
|
|
120
|
+
* const theme = useScopeMetadata<'light' | 'dark'>('theme')
|
|
121
|
+
* // ...
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
89
124
|
*/
|
|
90
|
-
declare function
|
|
91
|
-
//#endregion
|
|
92
|
-
//#region src/types.d.mts
|
|
93
|
-
type UnionToArray<T> = UnionToArrayImpl<T, never>;
|
|
94
|
-
type UnionToArrayImpl<T, L extends any[]> = T extends any ? UnionToArrayImpl<Exclude<T, T>, [...L, T]> : L;
|
|
95
|
-
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 : '';
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/hooks/use-service.d.mts
|
|
125
|
+
export declare function useScopeMetadata<T = unknown>(key: string): T | undefined;
|
|
98
126
|
interface UseServiceResult<T> {
|
|
99
127
|
data: T | undefined;
|
|
100
128
|
error: Error | undefined;
|
|
@@ -103,22 +131,18 @@ interface UseServiceResult<T> {
|
|
|
103
131
|
isError: boolean;
|
|
104
132
|
refetch: () => void;
|
|
105
133
|
}
|
|
106
|
-
declare function useService<T extends ClassType>(token: T): UseServiceResult<
|
|
107
|
-
declare function useService<T, S extends
|
|
108
|
-
declare function useService<T, S extends
|
|
109
|
-
declare function useService<T>(token: InjectionToken<T,
|
|
110
|
-
declare function useService<T>(token: BoundInjectionToken<T, any>): UseServiceResult<T>;
|
|
111
|
-
declare function useService<T>(token: FactoryInjectionToken<T, any>): UseServiceResult<T>;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
declare function useSuspenseService<T extends
|
|
115
|
-
declare function useSuspenseService<T
|
|
116
|
-
declare function useSuspenseService<T
|
|
117
|
-
declare function useSuspenseService<T>(token:
|
|
118
|
-
declare function useSuspenseService<T>(token: BoundInjectionToken<T, any>): T;
|
|
119
|
-
declare function useSuspenseService<T>(token: FactoryInjectionToken<T, any>): T;
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/hooks/use-optional-service.d.mts
|
|
134
|
+
export declare function useService<T extends ClassType>(token: T): UseServiceResult<ResolvedInstance<T>>;
|
|
135
|
+
export declare function useService<T, S extends StandardSchemaV1>(token: InjectionToken<T, S>, args: InferInput<S>): UseServiceResult<T>;
|
|
136
|
+
export declare function useService<T, S extends StandardSchemaV1, R extends boolean>(token: InjectionToken<T, S, R>): R extends false ? UseServiceResult<T> : MissingArgsError<S>;
|
|
137
|
+
export declare function useService<T>(token: InjectionToken<T, unknown>): UseServiceResult<T>;
|
|
138
|
+
export declare function useService<T>(token: BoundInjectionToken<T, any>): UseServiceResult<T>;
|
|
139
|
+
export declare function useService<T>(token: FactoryInjectionToken<T, any>): UseServiceResult<T>;
|
|
140
|
+
export declare function useSuspenseService<T extends ClassType>(token: T): ResolvedInstance<T>;
|
|
141
|
+
export declare function useSuspenseService<T, S extends StandardSchemaV1>(token: InjectionToken<T, S>, args: InferInput<S>): T;
|
|
142
|
+
export declare function useSuspenseService<T, S extends StandardSchemaV1, R extends boolean>(token: InjectionToken<T, S, R>): R extends false ? T : MissingArgsError<S>;
|
|
143
|
+
export declare function useSuspenseService<T>(token: InjectionToken<T, unknown>): T;
|
|
144
|
+
export declare function useSuspenseService<T>(token: BoundInjectionToken<T, any>): T;
|
|
145
|
+
export declare function useSuspenseService<T>(token: FactoryInjectionToken<T, any>): T;
|
|
122
146
|
interface UseOptionalServiceResult<T> {
|
|
123
147
|
/**
|
|
124
148
|
* The service instance if found and loaded successfully, otherwise undefined.
|
|
@@ -149,14 +173,12 @@ interface UseOptionalServiceResult<T> {
|
|
|
149
173
|
*/
|
|
150
174
|
refetch: () => void;
|
|
151
175
|
}
|
|
152
|
-
declare function useOptionalService<T extends ClassType>(token: T): UseOptionalServiceResult<
|
|
153
|
-
declare function useOptionalService<T, S extends
|
|
154
|
-
declare function useOptionalService<T, S extends
|
|
155
|
-
declare function useOptionalService<T>(token: InjectionToken<T,
|
|
156
|
-
declare function useOptionalService<T>(token: BoundInjectionToken<T, any>): UseOptionalServiceResult<T>;
|
|
157
|
-
declare function useOptionalService<T>(token: FactoryInjectionToken<T, any>): UseOptionalServiceResult<T>;
|
|
158
|
-
//#endregion
|
|
159
|
-
//#region src/hooks/use-invalidate.d.mts
|
|
176
|
+
export declare function useOptionalService<T extends ClassType>(token: T): UseOptionalServiceResult<ResolvedInstance<T>>;
|
|
177
|
+
export declare function useOptionalService<T, S extends StandardSchemaV1>(token: InjectionToken<T, S>, args: InferInput<S>): UseOptionalServiceResult<T>;
|
|
178
|
+
export declare function useOptionalService<T, S extends StandardSchemaV1, R extends boolean>(token: InjectionToken<T, S, R>): R extends false ? UseOptionalServiceResult<T> : MissingArgsError<S>;
|
|
179
|
+
export declare function useOptionalService<T>(token: InjectionToken<T, unknown>): UseOptionalServiceResult<T>;
|
|
180
|
+
export declare function useOptionalService<T>(token: BoundInjectionToken<T, any>): UseOptionalServiceResult<T>;
|
|
181
|
+
export declare function useOptionalService<T>(token: FactoryInjectionToken<T, any>): UseOptionalServiceResult<T>;
|
|
160
182
|
/**
|
|
161
183
|
* Hook that returns a function to invalidate a service instance directly.
|
|
162
184
|
*
|
|
@@ -184,60 +206,9 @@ declare function useOptionalService<T>(token: FactoryInjectionToken<T, any>): Us
|
|
|
184
206
|
* }
|
|
185
207
|
* ```
|
|
186
208
|
*/
|
|
187
|
-
declare function useInvalidateInstance(): (instance: unknown) => Promise<void>;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
*/
|
|
194
|
-
declare function useScope(): string | null;
|
|
195
|
-
/**
|
|
196
|
-
* Hook to get the current scope ID, throwing if not inside a ScopeProvider.
|
|
197
|
-
* Use this when your component requires a scope to function correctly.
|
|
198
|
-
*/
|
|
199
|
-
declare function useScopeOrThrow(): string;
|
|
200
|
-
/**
|
|
201
|
-
* Hook to get the current ScopedContainer.
|
|
202
|
-
* Returns null if not inside a ScopeProvider.
|
|
203
|
-
*
|
|
204
|
-
* Use this to access scope metadata or other ScopedContainer methods.
|
|
205
|
-
*
|
|
206
|
-
* @example
|
|
207
|
-
* ```tsx
|
|
208
|
-
* function TableRow() {
|
|
209
|
-
* const scope = useScopedContainer()
|
|
210
|
-
* const rowData = scope?.getMetadata('rowData')
|
|
211
|
-
* // ...
|
|
212
|
-
* }
|
|
213
|
-
* ```
|
|
214
|
-
*/
|
|
215
|
-
declare function useScopedContainer(): ScopedContainer | null;
|
|
216
|
-
/**
|
|
217
|
-
* Hook to get the current ScopedContainer, throwing if not inside a ScopeProvider.
|
|
218
|
-
* Use this when your component requires a scope to function correctly.
|
|
219
|
-
*/
|
|
220
|
-
declare function useScopedContainerOrThrow(): ScopedContainer;
|
|
221
|
-
/**
|
|
222
|
-
* Hook to get metadata from the current scope.
|
|
223
|
-
* Returns undefined if not inside a ScopeProvider or if the key doesn't exist.
|
|
224
|
-
*
|
|
225
|
-
* @example
|
|
226
|
-
* ```tsx
|
|
227
|
-
* // In parent component:
|
|
228
|
-
* <ScopeProvider metadata={{ userId: '123', theme: 'dark' }}>
|
|
229
|
-
* <ChildComponent />
|
|
230
|
-
* </ScopeProvider>
|
|
231
|
-
*
|
|
232
|
-
* // In child component:
|
|
233
|
-
* function ChildComponent() {
|
|
234
|
-
* const userId = useScopeMetadata<string>('userId')
|
|
235
|
-
* const theme = useScopeMetadata<'light' | 'dark'>('theme')
|
|
236
|
-
* // ...
|
|
237
|
-
* }
|
|
238
|
-
* ```
|
|
239
|
-
*/
|
|
240
|
-
declare function useScopeMetadata<T = unknown>(key: string): T | undefined;
|
|
241
|
-
//#endregion
|
|
242
|
-
export { ContainerContext, ContainerProvider, type ContainerProviderProps, Join, ScopeProvider, type ScopeProviderProps, ScopedContainerContext, UnionToArray, type UseOptionalServiceResult, type UseServiceResult, useContainer, useInvalidateInstance, useOptionalService, useRootContainer, useScope, useScopeMetadata, useScopeOrThrow, useScopedContainer, useScopedContainerOrThrow, useService, useSuspenseService };
|
|
243
|
-
//# sourceMappingURL=index.d.ts.map
|
|
209
|
+
export declare function useInvalidateInstance(): (instance: unknown) => Promise<void>;
|
|
210
|
+
type UnionToArray<T> = UnionToArrayImpl<T, never>;
|
|
211
|
+
type UnionToArrayImpl<T, L extends any[]> = T extends any ? UnionToArrayImpl<Exclude<T, T>, [...L, T]> : L;
|
|
212
|
+
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 : '';
|
|
213
|
+
export type { ContainerProviderProps, Join, ScopeProviderProps, UnionToArray, UseOptionalServiceResult, UseServiceResult };
|
|
214
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/container/context.mts","../src/container/container-provider.mts","../src/container/use-container.mts","../src/scope/scope-provider.mts","../src/scope/use-scope.mts","../src/service/use-service.mts","../src/service/use-suspense-service.mts","../src/service/use-optional-service.mts","../src/service/use-invalidate-instance.mts","../src/union-to-array.mts"],"mappings":";;;;;;qBAQa,kCAAgB,QAAA;;;;;qBAMhB,wCAAsB,QAAA;UCPlB;EACf,WAAW;EACX,UAAU;;wBAGI,oBAAoB,WAAW,YAAY,yCAAsB,+CAAA;;;;;;;;;;;wBCIjE,gBAAgB,YAAY;;;;;;;;;wBAwB5B,oBAAoB;UChCnB;;;;;EAKf;;;;;;EAMA,WAAW;EACX,UAAU;;;;;;;;;;;;;;;;;;;;;;;;wBAyBI,gBAAgB,SAAS,UAAU,YAAY,qCAAkB,+CAAA;;;;;wBCnCjE;;;;;wBASA;;;;;;;;;;;;;;;;wBA0BA,sBAAsB;;;;;wBAQtB,6BAA6B;;;;;;;;;;;;;;;;;;;;wBA8B7B,iBAAiB,aAAa,cAAc;UCpC3C,iBAAiB;EAChC,MAAM;EACN,OAAO;EACP;EACA;EACA;EACA;;wBAIc,WAAW,UAAU,WAAW,OAAO,IAAI,iBAAiB,iBAAiB;wBAG7E,WAAW,GAAG,UAAU,kBACtC,OAAO,eAAe,GAAG,IACzB,MAAM,WAAW,KAChB,iBAAiB;wBAGJ,WAAW,GAAG,UAAU,kBAAkB,mBACxD,OAAO,eAAe,GAAG,GAAG,KAC3B,kBAAkB,iBAAiB,KAAK,iBAAiB;wBAG5C,WAAW,GAAG,OAAO,eAAe,cAAc,iBAAiB;wBAEnE,WAAW,GAAG,OAAO,oBAAoB,UAAU,iBAAiB;w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