@okyrychenko-dev/react-action-guard 0.4.0 → 0.5.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/store/uiBlockingStore.constants.ts","../src/store/uiBlockingStore.utils.ts","../src/store/uiBlockingStore.actions.ts","../src/context/UIBlockingContext.internal.ts","../src/context/UIBlockingContext.tsx","../src/store/uiBlockingStore.config.ts","../src/store/uiBlockingStore.store.ts","../src/context/useResolvedStore.ts","../src/hooks/useAsyncAction/useAsyncAction.ts","../src/hooks/useBlocker/useBlocker.ts","../src/hooks/useBlocker/useBlocker.utils.ts","../src/hooks/useBlockingInfo/useBlockingInfo.ts","../src/hooks/useConfigRef.ts","../src/hooks/useConditionalBlocker/useConditionalBlocker.ts","../src/hooks/useConfirmableBlocker/useConfirmableBlocker.ts","../src/hooks/useIsBlocked/useIsBlocked.ts","../src/hooks/useScheduledBlocker/useScheduledBlocker.utils.ts","../src/hooks/useScheduledBlocker/useScheduledBlocker.ts","../src/middleware/analyticsMiddleware.utils.ts","../src/middleware/analyticsMiddleware.ts","../src/middleware/configureMiddleware.ts","../src/middleware/loggerMiddleware.utils.ts","../src/middleware/loggerMiddleware.ts","../src/middleware/performanceMiddleware.utils.ts","../src/middleware/performanceMiddleware.ts","../src/createTypedHooks.ts"],"names":["createStore","useStore","useShallow","createContext","useRef","useMemo","devtools","useContext","useCallback","useEffect","useState"],"mappings":";;;;;;;;;;;AAOO,IAAM,aAAA,GAAgB,QAAA;AAKtB,IAAM,cAAA,GAAiB,SAAA;AAKvB,IAAM,gBAAA,GAAmB,CAAA;AAKzB,IAAM,qBAAA,GAAwB,EAAA;AAK9B,IAAM,aAAA,GAAgB,YAAA;ACTtB,SAAS,mBAId,YAAA,EAIA;AACA,EAAA,MAAM,QAAA,GAAiCA,oBAAmC,YAAY,CAAA;AAEtF,EAAA,MAAM,cAAA,GAAiB,CAAI,QAAA,KAA0C;AAC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AQ,SAAA,EAAW,eAAe,CAAA;AAAA,IACvE,CAAA,MAAA,IAAW,OAAA,CAAQ,MAAA,KAAW,aAAA,EAAe;AAC3C,MAAA,kBAAA,CAAmB,OAAA,EAAS,eAAA,EAAiB,kBAAA,EAAoB,WAAW,CAAA;AAAA,IAC9E;AAAA,EACF,CAAA;AACF;;;ACWO,SAAS,gBAAA,GAA8D;AAG5E,EAAA,OAAO;AAAA,IACL,UAAA,EAAY,CAAC,SAAA,EAAW,MAAA,EAAQ,QAAA,KAAa;AAG3C,MAAA,UAAA,CAAW,SAAA,EAAW,QAAQ,QAAQ,CAAA;AAAA,IACxC,CAAA;AAAA,IAEA,YAAA,EAAc,CAAC,KAAA,KAAU;AAGvB,MAAA,OAAO,aAAa,KAAK,CAAA;AAAA,IAC3B,CAAA;AAAA,IAEA,cAAA,EAAgB,CACd,QAAA,EACA,KAAA,EACA,OAAA,KACG;AACH,MAAA,OAAO,cAAA,CAAkB,QAAA,EAAU,KAAA,EAAO,OAAO,CAAA;AAAA,IACnD,CAAA;AAAA,IAEA,eAAA,EAAiB,CAAC,KAAA,KAAU,eAAA,CAAgB,KAAK;AAAA,GACnD;AACF","file":"index.cjs","sourcesContent":["/**\n * Default values and constants for UI Blocking Store\n */\n\n/**\n * Default scope for blockers\n */\nexport const DEFAULT_SCOPE = \"global\" as const;\n\n/**\n * Default reason when none is provided\n */\nexport const DEFAULT_REASON = \"Unknown\" as const;\n\n/**\n * Default priority for blockers\n */\nexport const DEFAULT_PRIORITY = 0 as const;\n\n/**\n * Default priority for async actions\n */\nexport const ASYNC_ACTION_PRIORITY = 20 as const;\n\n/**\n * DevTools store name\n */\nexport const DEVTOOLS_NAME = \"UIBlocking\" as const;\n","import { StateCreator, StoreApi, StoreMutators, createStore, useStore } from \"zustand\";\nimport { useShallow } from \"zustand/shallow\";\n\n/**\n * Creates a Zustand store with automatic shallow comparison for all selectors\n *\n * This utility wraps the standard Zustand store creation and automatically applies\n * `useShallow` to all selectors, preventing unnecessary re-renders when selected\n * values haven't changed (shallow equality).\n *\n * @template StoreState - The type of the store state\n * @template TMutators - Array of middleware mutators (e.g., devtools, persist)\n *\n * @param storeCreator - The state creator function for Zustand\n * @returns Object containing the store hook and store API\n *\n * @see https://docs.pmnd.rs/zustand/guides/prevent-rerenders-with-use-shallow\n */\nexport function createShallowStore<\n StoreState,\n TMutators extends Array<[keyof StoreMutators<StoreState, StoreState>, unknown]> = [],\n>(\n storeCreator: StateCreator<StoreState, [], TMutators, StoreState>\n): {\n useStore: <T>(selector: (state: StoreState) => T) => T;\n useStoreApi: StoreApi<StoreState>;\n} {\n const storeApi: StoreApi<StoreState> = createStore<StoreState, TMutators>(storeCreator);\n\n const useScopedStore = <T>(selector: (state: StoreState) => T): T => {\n return useStore(storeApi, useShallow(selector));\n };\n\n return { useStore: useScopedStore, useStoreApi: storeApi };\n}\n\n/**\n * Normalize scope to array format\n *\n * @param scope - Single scope or array of scopes\n * @returns Array of scopes\n *\n * @internal\n */\nexport function normalizeScopeToArray(scope: string | ReadonlyArray<string>): Array<string> {\n if (typeof scope === \"string\") {\n return [scope];\n }\n return Array.from(scope);\n}\n","import { Middleware, MiddlewareContext } from \"../middleware\";\nimport { DEFAULT_PRIORITY, DEFAULT_REASON, DEFAULT_SCOPE } from \"./uiBlockingStore.constants\";\nimport { normalizeScopeToArray } from \"./uiBlockingStore.utils\";\nimport type {\n BlockerConfig,\n BlockerInfo,\n StoredBlocker,\n UIBlockingStore,\n} from \"./uiBlockingStore.types\";\nimport type { StateCreator } from \"zustand\";\n\n/**\n * UI Blocking Store Slice\n *\n * Implements the state and actions for UI blocking management.\n * This slice follows the Zustand slice pattern for better code organization.\n */\nexport const createUIBlockingActions: StateCreator<UIBlockingStore, [], [], UIBlockingStore> = (\n set,\n get\n) => ({\n // State\n activeBlockers: new Map(),\n middlewares: new Map(),\n\n registerMiddleware: (name: string, middleware: Middleware) => {\n set((state) => {\n const newMiddlewares = new Map(state.middlewares);\n newMiddlewares.set(name, middleware);\n return { middlewares: newMiddlewares };\n });\n console.log(`[UIBlocking] Registered middleware: ${name}`);\n },\n\n unregisterMiddleware: (name: string) => {\n set((state) => {\n const newMiddlewares = new Map(state.middlewares);\n newMiddlewares.delete(name);\n return { middlewares: newMiddlewares };\n });\n console.log(`[UIBlocking] Unregistered middleware: ${name}`);\n },\n\n runMiddlewares: async (context: MiddlewareContext) => {\n const { middlewares } = get();\n\n for (const [name, middleware] of middlewares) {\n try {\n await middleware(context);\n } catch (error) {\n console.error(`[UIBlocking] Middleware \"${name}\" error:`, error);\n }\n }\n },\n\n // Actions\n /**\n * Add a blocker to the store\n *\n * @param id - Unique blocker identifier\n * @param config - Optional blocker configuration\n *\n */\n addBlocker: (id: string, config: BlockerConfig = {}): void => {\n // Clear existing timeout if blocker is being overwritten\n const existingBlocker = get().activeBlockers.get(id);\n if (existingBlocker?.timeoutId) {\n clearTimeout(existingBlocker.timeoutId);\n }\n\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n // Set up timeout if specified\n if (config.timeout && config.timeout > 0) {\n timeoutId = setTimeout(() => {\n // Check if blocker still exists\n if (get().activeBlockers.has(id)) {\n // Call onTimeout callback before removing\n config.onTimeout?.(id);\n\n // Run timeout middleware\n void get().runMiddlewares({\n action: \"timeout\",\n blockerId: id,\n config: {\n scope: config.scope,\n reason: config.reason,\n priority: config.priority,\n timeout: config.timeout,\n },\n timestamp: Date.now(),\n });\n\n // Remove the blocker (this will also run \"remove\" middleware)\n get().removeBlocker(id);\n }\n }, config.timeout);\n }\n\n set((state) => {\n const newBlockers = new Map(state.activeBlockers);\n const storedBlocker: StoredBlocker = {\n scope: config.scope ?? DEFAULT_SCOPE,\n reason: config.reason ?? DEFAULT_REASON,\n priority: config.priority ?? DEFAULT_PRIORITY,\n timestamp: config.timestamp ?? Date.now(),\n timeout: config.timeout,\n timeoutId,\n onTimeout: config.onTimeout,\n };\n newBlockers.set(id, storedBlocker);\n\n return { activeBlockers: newBlockers };\n });\n\n void get().runMiddlewares({\n action: \"add\",\n blockerId: id,\n config: {\n scope: config.scope,\n reason: config.reason,\n priority: config.priority,\n timeout: config.timeout,\n },\n timestamp: Date.now(),\n });\n },\n\n /**\n * Remove a blocker from the store\n *\n * @param id - Blocker identifier to remove\n *\n */\n removeBlocker: (id: string): void => {\n const prevBlocker = get().activeBlockers.get(id);\n\n // Clear timeout if it exists\n if (prevBlocker?.timeoutId) {\n clearTimeout(prevBlocker.timeoutId);\n }\n\n set((state) => {\n const newBlockers = new Map(state.activeBlockers);\n newBlockers.delete(id);\n\n return { activeBlockers: newBlockers };\n });\n\n if (prevBlocker) {\n void get().runMiddlewares({\n action: \"remove\",\n blockerId: id,\n config: prevBlocker,\n timestamp: Date.now(),\n prevState: prevBlocker,\n });\n }\n },\n\n /**\n * Check if a scope is currently blocked\n *\n * @param scope - Scope or array of scopes to check (default: \"global\")\n * @returns True if any of the scopes are blocked\n *\n */\n isBlocked: (scope: string | ReadonlyArray<string> = DEFAULT_SCOPE): boolean => {\n const { activeBlockers } = get();\n const scopes = normalizeScopeToArray(scope);\n\n for (const [, blocker] of activeBlockers) {\n // Global blocking blocks everything\n if (blocker.scope === DEFAULT_SCOPE) {\n return true;\n }\n\n // Check scope intersection\n const blockerScopes = normalizeScopeToArray(blocker.scope);\n\n if (scopes.some((s) => blockerScopes.includes(s))) {\n return true;\n }\n }\n\n return false;\n },\n\n /**\n * Get detailed blocking information for a specific scope\n *\n * @param scope - Scope to get blocking information for\n * @returns Array of blockers affecting the scope, sorted by priority (highest first)\n *\n */\n getBlockingInfo: (scope: string): ReadonlyArray<BlockerInfo> => {\n const { activeBlockers } = get();\n const blockers: Array<BlockerInfo> = [];\n\n for (const [id, blocker] of activeBlockers) {\n const blockerScopes = normalizeScopeToArray(blocker.scope);\n\n if (blocker.scope === DEFAULT_SCOPE || blockerScopes.includes(scope)) {\n blockers.push({ id, ...blocker });\n }\n }\n\n return blockers.sort((a, b) => b.priority - a.priority);\n },\n\n /**\n * Clear all blockers from the store\n */\n clearAllBlockers: (): void => {\n // Clear all timeouts before clearing blockers\n const { activeBlockers } = get();\n for (const [, blocker] of activeBlockers) {\n if (blocker.timeoutId) {\n clearTimeout(blocker.timeoutId);\n }\n }\n\n set({ activeBlockers: new Map() });\n },\n\n /**\n * Clear all blockers for a specific scope\n *\n * @param scope - Scope to clear blockers for\n *\n */\n clearBlockersForScope: (scope: string): void => {\n // Clear timeouts for blockers that will be removed\n const { activeBlockers } = get();\n for (const [, blocker] of activeBlockers) {\n const blockerScopes = normalizeScopeToArray(blocker.scope);\n if (blockerScopes.includes(scope) && blocker.timeoutId) {\n clearTimeout(blocker.timeoutId);\n }\n }\n\n set((state) => {\n const newBlockers = new Map();\n\n for (const [id, blocker] of state.activeBlockers) {\n const blockerScopes = normalizeScopeToArray(blocker.scope);\n\n if (!blockerScopes.includes(scope)) {\n newBlockers.set(id, blocker);\n }\n }\n\n return { activeBlockers: newBlockers };\n });\n },\n});\n","import { createContext } from \"react\";\nimport type { UIBlockingStore } from \"../store/uiBlockingStore.types\";\nimport type { StoreApi } from \"zustand\";\n\n/**\n * Internal context - exported separately to avoid circular dependencies\n * Use UIBlockingContext.tsx for the public API\n */\nexport const UIBlockingContext = createContext<StoreApi<UIBlockingStore> | null>(null);\n","import { type ReactNode, useContext, useMemo, useRef } from \"react\";\nimport { type StoreApi, createStore, useStore } from \"zustand\";\nimport { devtools } from \"zustand/middleware\";\nimport { useShallow } from \"zustand/shallow\";\nimport { createUIBlockingActions } from \"../store/uiBlockingStore.actions\";\nimport { UIBlockingContext } from \"./UIBlockingContext.internal\";\nimport type { Middleware } from \"../middleware\";\nimport type { UIBlockingStore } from \"../store/uiBlockingStore.types\";\n\n/**\n * Props for UIBlockingProvider component\n */\nexport interface UIBlockingProviderProps {\n children: ReactNode;\n /** Enable Redux DevTools integration (default: true in development) */\n enableDevtools?: boolean;\n /** Name for Redux DevTools (default: \"UIBlocking\") */\n devtoolsName?: string;\n /** Initial middlewares to register */\n middlewares?: ReadonlyArray<Middleware>;\n}\n\n/**\n * Provider component for isolated UI blocking state\n *\n * Use this to create an isolated store instance for:\n * - Server-side rendering (each request gets its own store)\n * - Testing (no need for beforeEach cleanup)\n * - Micro-frontends (isolated state per app)\n *\n * @example\n * ```tsx\n * // SSR - each request gets its own store\n * function App() {\n * return (\n * <UIBlockingProvider>\n * <MyComponent />\n * </UIBlockingProvider>\n * );\n * }\n *\n * // Testing - isolated store per test\n * function renderWithProvider(ui: ReactElement) {\n * return render(\n * <UIBlockingProvider>{ui}</UIBlockingProvider>\n * );\n * }\n * ```\n */\nexport function UIBlockingProvider({\n children,\n enableDevtools = process.env.NODE_ENV === \"development\",\n devtoolsName = \"UIBlocking\",\n middlewares = [],\n}: UIBlockingProviderProps): ReactNode {\n // Use ref to store middlewares to avoid recreation on every render\n const middlewaresRef = useRef(middlewares);\n\n const store = useMemo(() => {\n // Create store with or without devtools\n const baseStore = enableDevtools\n ? createStore(\n devtools(createUIBlockingActions, {\n name: devtoolsName,\n enabled: enableDevtools,\n })\n )\n : createStore(createUIBlockingActions);\n\n // Register initial middlewares\n middlewaresRef.current.forEach((mw, index) => {\n baseStore.getState().registerMiddleware(`provider-middleware-${index.toString()}`, mw);\n });\n\n return baseStore;\n }, [enableDevtools, devtoolsName]);\n\n return <UIBlockingContext.Provider value={store}>{children}</UIBlockingContext.Provider>;\n}\n\n/**\n * Hook to access the UIBlocking store from context\n *\n * Throws an error if used outside of UIBlockingProvider.\n * Use useUIBlockingStoreFromContext for safe access with fallback.\n *\n * @returns The store API from the nearest UIBlockingProvider\n * @throws Error if used outside of UIBlockingProvider\n */\nexport function useUIBlockingContext(): StoreApi<UIBlockingStore> {\n const store = useContext(UIBlockingContext);\n\n if (!store) {\n throw new Error(\n \"useUIBlockingContext must be used within UIBlockingProvider. \" +\n \"Either wrap your app in <UIBlockingProvider> or use the global store via useUIBlockingStore.\"\n );\n }\n\n return store;\n}\n\n/**\n * Hook to check if we're inside a UIBlockingProvider\n *\n * @returns true if inside UIBlockingProvider, false otherwise\n */\nexport function useIsInsideUIBlockingProvider(): boolean {\n const store = useContext(UIBlockingContext);\n return store !== null;\n}\n\n/**\n * Hook to use the UIBlocking store from context with a selector\n *\n * This is similar to useUIBlockingStore but uses the context store.\n * Automatically applies shallow comparison to prevent unnecessary re-renders.\n *\n * @param selector - Selector function to pick state from the store\n * @returns Selected state value\n * @throws Error if used outside of UIBlockingProvider\n */\nexport function useUIBlockingStoreFromContext<T>(selector: (state: UIBlockingStore) => T): T {\n const store = useUIBlockingContext();\n return useStore(store, useShallow(selector));\n}\n","import { DEVTOOLS_NAME } from \"./uiBlockingStore.constants\";\nimport type { DevtoolsOptions } from \"zustand/middleware\";\n\n/**\n * DevTools configuration for UI Blocking Store\n *\n * Enables Redux DevTools integration only in development mode\n * for better debugging experience without production overhead.\n */\nexport const devtoolsConfig: DevtoolsOptions = {\n name: DEVTOOLS_NAME,\n enabled: process.env.NODE_ENV !== \"production\",\n};\n","import { devtools } from \"zustand/middleware\";\nimport { createUIBlockingActions } from \"./uiBlockingStore.actions\";\nimport { devtoolsConfig } from \"./uiBlockingStore.config\";\nimport { createShallowStore } from \"./uiBlockingStore.utils\";\nimport type { UIBlockingStore } from \"./uiBlockingStore.types\";\n\n/**\n * UI Blocking Store\n *\n * Global Zustand store for managing UI blocking state across the application.\n *\n * Features:\n * - Priority-based blocking system\n * - Scope-based blocking (global, specific areas, or multiple scopes)\n * - Automatic cleanup on unmount (when using hooks)\n * - DevTools integration for debugging\n * - Automatic shallow comparison for selectors\n *\n */\nconst { useStore: useUIBlockingStore, useStoreApi: uiBlockingStoreApi } = createShallowStore<\n UIBlockingStore,\n [[\"zustand/devtools\", never]]\n>(devtools(createUIBlockingActions, devtoolsConfig));\n\nexport { useUIBlockingStore, uiBlockingStoreApi };\n","import { useContext } from \"react\";\nimport { type StoreApi, useStore } from \"zustand\";\nimport { useShallow } from \"zustand/shallow\";\nimport { uiBlockingStoreApi } from \"../store/uiBlockingStore.store\";\nimport { UIBlockingContext } from \"./UIBlockingContext.internal\";\nimport type { UIBlockingStore } from \"../store/uiBlockingStore.types\";\n\n/**\n * Internal context export for useResolvedStore\n * Re-exported to avoid circular dependencies\n */\nexport { UIBlockingContext } from \"./UIBlockingContext.internal\";\n\n/**\n * Hook that resolves to either the context store or global store\n *\n * This hook automatically uses the store from UIBlockingProvider if available,\n * otherwise falls back to the global store. This enables both patterns:\n *\n * 1. Global store (default behavior, no Provider needed)\n * 2. Context store (for SSR, testing, micro-frontends)\n *\n * @returns The resolved store API\n */\nexport function useResolvedStore(): StoreApi<UIBlockingStore> {\n const contextStore = useContext(UIBlockingContext);\n // Return context store if inside Provider, otherwise global store\n return contextStore ?? uiBlockingStoreApi;\n}\n\n/**\n * Hook to use the resolved store with a selector\n *\n * Automatically applies shallow comparison to prevent unnecessary re-renders.\n *\n * @param selector - Selector function to pick state from the store\n * @returns Selected state value\n */\nexport function useResolvedStoreWithSelector<T>(selector: (state: UIBlockingStore) => T): T {\n const store = useResolvedStore();\n return useStore(store, useShallow(selector));\n}\n","import { useCallback } from \"react\";\nimport { useResolvedStoreWithSelector } from \"../../context\";\nimport { ASYNC_ACTION_PRIORITY } from \"../../store\";\n\n/**\n * Options for useAsyncAction hook\n */\nexport interface UseAsyncActionOptions {\n /** Timeout in milliseconds after which the blocker will be automatically removed */\n timeout?: number;\n /** Callback invoked when the blocker is automatically removed due to timeout */\n onTimeout?: (blockerId: string) => void;\n}\n\n/**\n * Hook to wrap async functions with automatic blocking/unblocking\n *\n * Creates a wrapper function that automatically adds a blocker before executing\n * the async function and removes it after completion (success or failure).\n *\n * Supports both global store and context store (via UIBlockingProvider).\n *\n * @template T - The return type of the async function\n * @param actionId - Unique identifier for the action (used in blocker ID and reason)\n * @param scope - Scope(s) to block during execution (default: \"global\")\n * @param options - Optional configuration including timeout\n * @returns Function that wraps async functions with blocking behavior\n *\n */\nexport const useAsyncAction = <T = unknown>(\n actionId: string,\n scope?: string | ReadonlyArray<string>,\n options?: UseAsyncActionOptions\n): ((asyncFn: () => Promise<T>) => Promise<T>) => {\n const { addBlocker, removeBlocker } = useResolvedStoreWithSelector((state) => ({\n addBlocker: state.addBlocker,\n removeBlocker: state.removeBlocker,\n }));\n\n const executeWithBlocking = useCallback(\n async (asyncFn: () => Promise<T>): Promise<T> => {\n const blockerId = `${actionId}-${Date.now().toString()}`;\n\n try {\n addBlocker(blockerId, {\n scope,\n reason: `Executing ${actionId}`,\n priority: ASYNC_ACTION_PRIORITY,\n timeout: options?.timeout,\n onTimeout: options?.onTimeout,\n });\n\n return await asyncFn();\n } finally {\n removeBlocker(blockerId);\n }\n },\n [actionId, scope, options?.timeout, options?.onTimeout, addBlocker, removeBlocker]\n );\n\n return executeWithBlocking;\n};\n","import { useEffect } from \"react\";\nimport { useResolvedStoreWithSelector } from \"../../context\";\nimport type { BlockerConfig } from \"../../store\";\n\n/**\n * Hook to automatically add and remove a blocker based on component lifecycle\n *\n * Automatically adds a blocker when the component mounts (or when activated)\n * and removes it when the component unmounts (or when deactivated).\n *\n * Supports both global store and context store (via UIBlockingProvider).\n *\n * @param blockerId - Unique identifier for the blocker\n * @param config - Blocker configuration (scope, reason, priority)\n * @param isActive - Whether the blocker is currently active (default: true)\n *\n */\nexport const useBlocker = (blockerId: string, config: BlockerConfig, isActive = true): void => {\n const { addBlocker, removeBlocker } = useResolvedStoreWithSelector((state) => ({\n addBlocker: state.addBlocker,\n removeBlocker: state.removeBlocker,\n }));\n\n useEffect(() => {\n if (!isActive || !blockerId) {\n return;\n }\n\n addBlocker(blockerId, config);\n\n return () => {\n removeBlocker(blockerId);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [blockerId, isActive, addBlocker, removeBlocker]);\n};\n","import { BlockerConfig } from \"../../store\";\n\n/**\n * Creates a blocker configuration object from partial config.\n * Filters out undefined values to create a clean BlockerConfig.\n *\n * @param config - Partial blocker configuration\n * @returns Complete BlockerConfig object\n *\n */\nexport function createBlockerConfig(config: {\n scope?: string | ReadonlyArray<string>;\n reason?: string;\n priority?: number;\n}): BlockerConfig {\n return {\n scope: config.scope,\n reason: config.reason,\n priority: config.priority,\n };\n}\n","import { useMemo } from \"react\";\nimport { useStore } from \"zustand\";\nimport { useResolvedStore } from \"../../context\";\nimport { DEFAULT_SCOPE } from \"../../store\";\nimport type { BlockerInfo } from \"../../store\";\n\n/**\n * Hook to get detailed blocking information for a scope\n *\n * Returns an array of blocker information objects for the specified scope,\n * sorted by priority (highest first). Automatically re-renders when blockers change.\n *\n * Uses a stable reference - only re-renders when the actual blocker list changes,\n * not on every store update.\n *\n * Supports both global store and context store (via UIBlockingProvider).\n *\n * @param scope - Scope to get blocking information for (default: \"global\")\n * @returns Array of blocker information objects, sorted by priority\n *\n * ```\n */\nexport const useBlockingInfo = (scope: string = DEFAULT_SCOPE): ReadonlyArray<BlockerInfo> => {\n const store = useResolvedStore();\n\n // Subscribe to the activeBlockers Map to detect changes\n const activeBlockers = useStore(store, (state) => state.activeBlockers);\n\n // Recompute blockers only when activeBlockers or scope changes\n return useMemo(() => {\n return store.getState().getBlockingInfo(scope);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeBlockers, scope, store]);\n};\n","import { RefObject, useEffect, useRef } from \"react\";\n\n/**\n * Keeps a ref updated with the latest config value.\n * Useful for accessing current config in callbacks without stale closures.\n *\n * @param config - Configuration object to track\n * @returns Mutable ref that always contains the latest config\n *\n */\nexport function useConfigRef<T>(config: T): RefObject<T> {\n const configRef = useRef(config);\n\n useEffect(() => {\n configRef.current = config;\n }, [config]);\n\n return configRef;\n}\n","import { useCallback, useEffect, useRef } from \"react\";\nimport { useResolvedStoreWithSelector } from \"../../context\";\nimport { createBlockerConfig } from \"../useBlocker\";\nimport { useConfigRef } from \"../useConfigRef\";\nimport { ConditionalBlockerConfig } from \"./useConditionalBlocker.types\";\n\n/**\n * Hook for conditional blocking based on a condition function.\n *\n * Periodically checks a condition and blocks/unblocks based on the result.\n * The condition is evaluated at the specified interval (default 1000ms).\n *\n * Supports both global store and context store (via UIBlockingProvider).\n *\n * @param blockerId - Unique identifier for this blocker\n * @param config - Configuration including condition function and check interval\n *\n */\nexport const useConditionalBlocker = <TState = unknown>(\n blockerId: string,\n config: ConditionalBlockerConfig<TState>\n): void => {\n const { addBlocker, removeBlocker } = useResolvedStoreWithSelector((state) => ({\n addBlocker: state.addBlocker,\n removeBlocker: state.removeBlocker,\n }));\n const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);\n const isBlockedRef = useRef(false);\n const configRef = useConfigRef(config);\n\n const checkCondition = useCallback(() => {\n const currentConfig = configRef.current;\n const shouldBlock = currentConfig.condition(currentConfig.state);\n\n // No state change needed\n if (shouldBlock === isBlockedRef.current) {\n return;\n }\n\n if (shouldBlock) {\n addBlocker(blockerId, createBlockerConfig(currentConfig));\n } else {\n removeBlocker(blockerId);\n }\n isBlockedRef.current = shouldBlock;\n }, [blockerId, addBlocker, removeBlocker, configRef]);\n\n useEffect(() => {\n checkCondition();\n\n const interval = configRef.current.checkInterval ?? 1000;\n intervalRef.current = setInterval(checkCondition, interval);\n\n return (): void => {\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n intervalRef.current = null;\n }\n if (isBlockedRef.current) {\n removeBlocker(blockerId);\n isBlockedRef.current = false;\n }\n };\n // configRef is stable and doesn't need to be in dependencies\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [checkCondition, blockerId, removeBlocker]);\n};\n","import { useCallback, useState } from \"react\";\nimport { useBlocker } from \"../useBlocker\";\nimport {\n ConfirmableBlockerConfig,\n UseConfirmableBlockerReturn,\n} from \"./useConfirmableBlocker.types\";\n\n/**\n * Hook for creating a confirmable action with blocking UI\n *\n */\nexport const useConfirmableBlocker = (\n blockerId: string,\n config: ConfirmableBlockerConfig\n): UseConfirmableBlockerReturn => {\n const [isDialogOpen, setIsDialogOpen] = useState(false);\n const [isExecuting, setIsExecuting] = useState(false);\n\n useBlocker(\n blockerId,\n {\n ...config,\n reason: config.reason ?? config.confirmMessage,\n },\n isDialogOpen || isExecuting\n );\n\n const execute = useCallback(() => {\n setIsDialogOpen(true);\n }, []);\n\n const onConfirm = useCallback(async () => {\n setIsDialogOpen(false);\n setIsExecuting(true);\n\n try {\n await config.onConfirm();\n } catch (error) {\n console.error(\"[UIBlocking] Confirmable action error:\", error);\n throw error;\n } finally {\n setIsExecuting(false);\n }\n }, [config]);\n\n const onCancel = useCallback(() => {\n setIsDialogOpen(false);\n config.onCancel?.();\n }, [config]);\n\n return {\n execute,\n isDialogOpen,\n isExecuting,\n confirmConfig: {\n title: config.confirmTitle ?? \"Confirm Action\",\n message: config.confirmMessage,\n confirmText: config.confirmButtonText ?? \"Confirm\",\n cancelText: config.cancelButtonText ?? \"Cancel\",\n },\n onConfirm,\n onCancel,\n };\n};\n","import { useResolvedStoreWithSelector } from \"../../context\";\n\n/**\n * Hook to check if a scope is currently blocked\n *\n * Returns a boolean indicating whether the specified scope(s) are blocked.\n * Automatically re-renders when the blocking state changes.\n *\n * Supports both global store and context store (via UIBlockingProvider).\n *\n * @param scope - Scope or array of scopes to check (default: \"global\")\n * @returns True if any of the specified scopes are blocked\n *\n */\nexport const useIsBlocked = (scope?: string | ReadonlyArray<string>): boolean => {\n return useResolvedStoreWithSelector((state) => state.isBlocked(scope));\n};\n","import type { BlockingSchedule } from \"./useScheduledBlocker.types\";\n\n/**\n * Maximum safe timeout value for setTimeout in JavaScript (~24.8 days).\n * Values larger than this will cause setTimeout to trigger immediately.\n */\nexport const MAX_TIMEOUT_MS = 2147483647;\n\n/**\n * Validates a date value and converts it to timestamp.\n *\n * @param date - Date value as string, Date object, or number\n * @returns Timestamp in milliseconds, or NaN if invalid\n */\nexport function parseDate(date: string | Date | number): number {\n return new Date(date).getTime();\n}\n\n/**\n * Validates if a timestamp is valid (not NaN).\n *\n * @param timestamp - Timestamp to validate\n * @returns True if valid, false otherwise\n */\nexport function isValidTimestamp(timestamp: number): boolean {\n return !Number.isNaN(timestamp);\n}\n\n/**\n * Calculates the end time based on schedule configuration.\n * Duration takes precedence over end time if both are provided.\n *\n * @param schedule - Blocking schedule configuration\n * @param startTime - Start time in milliseconds\n * @returns End time in milliseconds, or undefined if not specified\n */\nexport function calculateEndTime(\n schedule: BlockingSchedule,\n startTime: number\n): number | undefined {\n if (schedule.duration) {\n return startTime + schedule.duration;\n }\n\n if (schedule.end) {\n const endTime = parseDate(schedule.end);\n return isValidTimestamp(endTime) ? endTime : undefined;\n }\n\n return undefined;\n}\n\n/**\n * Validates if a delay is within the safe setTimeout range.\n *\n * @param delay - Delay in milliseconds\n * @returns True if delay is safe to use with setTimeout\n */\nexport function isSafeTimeout(delay: number): boolean {\n return delay > 0 && delay <= MAX_TIMEOUT_MS;\n}\n\n/**\n * Determines if the current time is within a blocking schedule.\n *\n * @param startTime - Schedule start time in milliseconds\n * @param endTime - Schedule end time in milliseconds (optional)\n * @param now - Current time in milliseconds\n * @returns True if currently in the blocking period\n */\nexport function isInBlockingPeriod(\n startTime: number,\n endTime: number | undefined,\n now: number\n): boolean {\n if (startTime > now) {\n return false; // Not started yet\n }\n\n if (!endTime) {\n return true; // No end time means block indefinitely\n }\n\n return endTime > now; // Check if end time hasn't passed\n}\n\n/**\n * Checks if a schedule is completely in the past.\n *\n * @param startTime - Schedule start time in milliseconds\n * @param endTime - Schedule end time in milliseconds (optional)\n * @param now - Current time in milliseconds\n * @returns True if the schedule is in the past\n */\nexport function isScheduleInPast(\n startTime: number,\n endTime: number | undefined,\n now: number\n): boolean {\n if (!endTime) {\n return false; // No end time means it can still be active\n }\n\n return endTime <= now && startTime <= now;\n}\n","import { useCallback, useEffect, useRef } from \"react\";\nimport { useResolvedStoreWithSelector } from \"../../context\";\nimport { createBlockerConfig } from \"../useBlocker\";\nimport { useConfigRef } from \"../useConfigRef\";\nimport { ScheduledBlockerConfig } from \"./useScheduledBlocker.types\";\nimport {\n MAX_TIMEOUT_MS,\n calculateEndTime,\n isInBlockingPeriod,\n isSafeTimeout,\n isScheduleInPast,\n isValidTimestamp,\n parseDate,\n} from \"./useScheduledBlocker.utils\";\n\n/**\n * Hook for scheduling UI blocking for a specific time period.\n *\n * Blocks UI during a scheduled maintenance window or time period.\n * Supports start/end times as Date objects, ISO strings, or timestamps.\n * If both duration and end are provided, duration takes precedence.\n *\n * Supports both global store and context store (via UIBlockingProvider).\n *\n * @param blockerId - Unique identifier for this blocker\n * @param config - Configuration including schedule and callbacks\n *\n */\nexport const useScheduledBlocker = (blockerId: string, config: ScheduledBlockerConfig): void => {\n const { addBlocker, removeBlocker } = useResolvedStoreWithSelector((state) => ({\n addBlocker: state.addBlocker,\n removeBlocker: state.removeBlocker,\n }));\n const timeoutsRef = useRef<{\n start?: ReturnType<typeof setTimeout>;\n end?: ReturnType<typeof setTimeout>;\n }>({});\n const configRef = useConfigRef(config);\n\n const cleanup = useCallback(() => {\n if (timeoutsRef.current.start) {\n clearTimeout(timeoutsRef.current.start);\n timeoutsRef.current.start = undefined;\n }\n if (timeoutsRef.current.end) {\n clearTimeout(timeoutsRef.current.end);\n timeoutsRef.current.end = undefined;\n }\n }, []);\n\n useEffect(() => {\n const currentConfig = configRef.current;\n const startTime = parseDate(currentConfig.schedule.start);\n const now = Date.now();\n\n // Validate start time\n if (!isValidTimestamp(startTime)) {\n console.error(`[UIBlocking] Invalid start time for blocker \"${blockerId}\"`);\n return;\n }\n\n const scheduleEnd = (): void => {\n const endTime = calculateEndTime(currentConfig.schedule, startTime);\n if (!endTime) {\n return;\n }\n\n const remainingTime = endTime - Date.now();\n if (remainingTime > 0) {\n timeoutsRef.current.end = setTimeout(() => {\n configRef.current.onScheduleEnd?.();\n removeBlocker(blockerId);\n }, remainingTime);\n }\n };\n\n const startBlocking = (): void => {\n const cfg = configRef.current;\n addBlocker(blockerId, createBlockerConfig(cfg));\n cfg.onScheduleStart?.();\n scheduleEnd();\n };\n\n // If start time hasn't arrived yet\n if (startTime > now) {\n const delay = startTime - now;\n\n if (!isSafeTimeout(delay)) {\n console.warn(\n `[UIBlocking] Schedule delay exceeds maximum timeout (${MAX_TIMEOUT_MS.toString()}ms) for blocker \"${blockerId}\"`\n );\n return;\n }\n\n timeoutsRef.current.start = setTimeout(startBlocking, delay);\n }\n // If already in blocking period or should start immediately\n else {\n const endTime = calculateEndTime(currentConfig.schedule, startTime);\n\n if (isInBlockingPeriod(startTime, endTime, now)) {\n startBlocking();\n } else if (isScheduleInPast(startTime, endTime, now)) {\n console.warn(`[UIBlocking] Schedule is in the past for blocker \"${blockerId}\"`);\n }\n }\n\n return (): void => {\n cleanup();\n removeBlocker(blockerId);\n };\n // configRef is stable and doesn't need to be in dependencies\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [blockerId, addBlocker, removeBlocker, cleanup]);\n};\n","import { AnalyticsEventData } from \"./analyticsMiddleware.types\";\nimport { MiddlewareContext } from \"./middleware.types\";\n\nconst capitalizeFirst = (str: string): string => {\n return str.charAt(0).toUpperCase() + str.slice(1);\n};\n\nexport const buildEventData = (context: MiddlewareContext): AnalyticsEventData => {\n const eventData: AnalyticsEventData = {\n blocker_id: context.blockerId,\n };\n const { scope, reason, priority } = context.config ?? {};\n\n if (scope !== undefined) {\n eventData.scope = Array.isArray(scope) ? scope.join(\",\") : scope;\n }\n\n if (reason !== undefined) {\n eventData.reason = reason;\n }\n\n if (priority !== undefined) {\n eventData.priority = priority;\n }\n\n return eventData;\n};\n\nexport const trackGoogleAnalytics = (action: string, eventData: AnalyticsEventData): void => {\n if (window.gtag) {\n window.gtag(\"event\", `ui_blocking_${action}`, eventData);\n }\n};\n\nexport const trackMixpanel = (action: string, eventData: AnalyticsEventData): void => {\n if (window.mixpanel) {\n const eventName = `UI Blocking ${action.split(\"_\").map(capitalizeFirst).join(\" \")}`;\n\n window.mixpanel.track(eventName, eventData);\n }\n};\n\nexport const trackAmplitude = (action: string, eventData: AnalyticsEventData): void => {\n if (window.amplitude) {\n const eventName = `UI Blocking ${action.split(\"_\").map(capitalizeFirst).join(\" \")}`;\n\n window.amplitude.track(eventName, eventData);\n }\n};\n\nexport const trackCustom = (\n trackFn: (event: string, data: AnalyticsEventData) => void,\n action: string,\n eventData: AnalyticsEventData\n): void => {\n try {\n trackFn(`ui_blocking_${action}`, eventData);\n } catch {\n // Silently ignore errors in custom tracker\n }\n};\n","import { AnalyticsConfig, AnalyticsEventData } from \"./analyticsMiddleware.types\";\nimport {\n buildEventData,\n trackAmplitude,\n trackCustom,\n trackGoogleAnalytics,\n trackMixpanel,\n} from \"./analyticsMiddleware.utils\";\nimport { Middleware, MiddlewareContext } from \"./middleware.types\";\n\nconst trackEvent = (\n config: AnalyticsConfig,\n context: MiddlewareContext,\n eventData: AnalyticsEventData\n): void => {\n if (\"provider\" in config) {\n switch (config.provider) {\n case \"ga\":\n trackGoogleAnalytics(context.action, eventData);\n return;\n case \"mixpanel\":\n trackMixpanel(context.action, eventData);\n return;\n case \"amplitude\":\n trackAmplitude(context.action, eventData);\n return;\n }\n }\n\n if (\"track\" in config) {\n trackCustom(config.track, context.action, eventData);\n }\n};\n\nexport const createAnalyticsMiddleware = (config: AnalyticsConfig): Middleware => {\n return (context) => {\n const eventData = buildEventData(context);\n\n trackEvent(config, context, eventData);\n };\n};\n","import { uiBlockingStoreApi } from \"../store/uiBlockingStore.store\";\nimport type { Middleware } from \"./middleware.types\";\n\n/**\n * Configure middleware for the UI blocking store\n *\n * This is a convenience function that registers multiple middleware at once.\n * Each middleware will be registered with an auto-generated name based on its index.\n *\n * @param middlewares - Array of middleware functions to register\n *\n */\nexport function configureMiddleware(middlewares: ReadonlyArray<Middleware>): void {\n const store = uiBlockingStoreApi.getState();\n\n middlewares.forEach((middleware, index) => {\n // Generate a unique name for each middleware\n const name = `middleware-${index.toString()}`;\n store.registerMiddleware(name, middleware);\n });\n}\n","import { MiddlewareBlockerConfig, MiddlewareContext } from \"./middleware.types\";\n\nexport const getActionEmoji = (action: string): string => {\n switch (action) {\n case \"add\":\n return \"➕\";\n case \"remove\":\n return \"➖\";\n case \"update\":\n return \"🔄\";\n case \"cancel\":\n return \"❌\";\n case \"timeout\":\n return \"⏱️\";\n default:\n return \"❓\";\n }\n};\n\nconst extractConfigDetails = (config?: MiddlewareBlockerConfig): Record<string, unknown> => {\n if (!config) {\n return {};\n }\n\n const { scope, reason, priority } = config;\n\n const details: Record<string, unknown> = {\n scope,\n reason,\n };\n\n if (priority !== undefined) {\n details.priority = priority;\n }\n\n return details;\n};\n\nexport const formatLogData = (context: MiddlewareContext): Record<string, unknown> => {\n const configDetails = extractConfigDetails(context.config);\n\n if (context.prevState) {\n return {\n config: configDetails,\n prevState: extractConfigDetails(context.prevState),\n };\n }\n\n return configDetails;\n};\n","import { formatLogData, getActionEmoji } from \"./loggerMiddleware.utils\";\nimport { Middleware } from \"./middleware.types\";\n\nconst LOG_PREFIX = \"[UIBlocking]\";\n\nexport const loggerMiddleware: Middleware = (context) => {\n const emoji = getActionEmoji(context.action);\n const logData = formatLogData(context);\n\n console.log(LOG_PREFIX, emoji, context.blockerId, logData);\n};\n","export const handleAddAction = (\n blockerId: string,\n timestamp: number,\n blockStartTimes: Map<string, number>\n): void => {\n blockStartTimes.set(blockerId, timestamp);\n};\n","import { Middleware, MiddlewareContext } from \"./middleware.types\";\nimport { PerformanceConfig } from \"./performanceMiddleware.types\";\nimport { handleAddAction } from \"./performanceMiddleware.utils\";\n\nconst DEFAULT_SLOW_BLOCK_THRESHOLD = 3000;\nconst ACTION_ADD = \"add\";\nconst ACTION_REMOVE = \"remove\";\n\nconst handleRemoveAction = (\n context: MiddlewareContext,\n blockStartTimes: Map<string, number>,\n slowBlockThreshold: number,\n onSlowBlock?: (blockerId: string, duration: number) => void\n): void => {\n const startTime = blockStartTimes.get(context.blockerId);\n\n if (startTime === undefined) {\n return;\n }\n\n const duration = context.timestamp - startTime;\n blockStartTimes.delete(context.blockerId);\n\n if (duration >= slowBlockThreshold) {\n console.warn(\n `[UIBlocking] Slow block detected: \"${context.blockerId}\" took ${duration.toString()}ms`\n );\n\n onSlowBlock?.(context.blockerId, duration);\n }\n};\n\nexport const createPerformanceMiddleware = (config: PerformanceConfig = {}): Middleware => {\n const { slowBlockThreshold = DEFAULT_SLOW_BLOCK_THRESHOLD, onSlowBlock } = config;\n const blockStartTimes = new Map<string, number>();\n\n return (context) => {\n if (context.action === ACTION_ADD) {\n handleAddAction(context.blockerId, context.timestamp, blockStartTimes);\n } else if (context.action === ACTION_REMOVE) {\n handleRemoveAction(context, blockStartTimes, slowBlockThreshold, onSlowBlock);\n }\n };\n};\n","import { type UseAsyncActionOptions, useAsyncAction } from \"./hooks/useAsyncAction\";\nimport { useBlocker } from \"./hooks/useBlocker\";\nimport { useBlockingInfo } from \"./hooks/useBlockingInfo\";\nimport { useIsBlocked } from \"./hooks/useIsBlocked\";\nimport type { BlockerConfigTyped, ScopeValue } from \"./types\";\n\n/**\n * Return type for createTypedHooks factory\n */\nexport interface TypedHooks<TScope extends string> {\n /**\n * Type-safe version of useBlocker hook\n */\n useBlocker: (blockerId: string, config: BlockerConfigTyped<TScope>, isActive?: boolean) => void;\n\n /**\n * Type-safe version of useIsBlocked hook\n */\n useIsBlocked: (scope?: ScopeValue<TScope>) => boolean;\n\n /**\n * Type-safe version of useAsyncAction hook\n */\n useAsyncAction: <T = unknown>(\n actionId: string,\n scope?: ScopeValue<TScope>,\n options?: UseAsyncActionOptions\n ) => (asyncFn: () => Promise<T>) => Promise<T>;\n\n /**\n * Type-safe version of useBlockingInfo hook\n */\n useBlockingInfo: (scope: TScope) => ReturnType<typeof useBlockingInfo>;\n}\n\n/**\n * Creates type-safe versions of all blocking hooks with your custom scope types\n *\n * @template TScope - Union type of allowed scope strings\n * @returns Object with type-safe hook functions\n *\n * @example\n * ```typescript\n * // Define your app's scopes\n * type AppScopes = \"global\" | \"form\" | \"navigation\" | \"checkout\";\n *\n * // Create typed hooks\n * const { useBlocker, useIsBlocked, useAsyncAction } = createTypedHooks<AppScopes>();\n *\n * // Now TypeScript will catch typos\n * useBlocker(\"id\", { scope: \"form\" }); // ✓ OK\n * useBlocker(\"id\", { scope: \"typo\" }); // ✗ Type error!\n * ```\n */\nexport function createTypedHooks<TScope extends string>(): TypedHooks<TScope> {\n // TScope extends string, so all typed scopes are assignable to string | ReadonlyArray<string>\n // This allows us to pass typed values directly without casting\n return {\n useBlocker: (blockerId, config, isActive) => {\n // BlockerConfigTyped<TScope> is structurally compatible with BlockerConfig\n // because TScope extends string\n useBlocker(blockerId, config, isActive);\n },\n\n useIsBlocked: (scope) => {\n // ScopeValue<TScope> = TScope | ReadonlyArray<TScope>\n // Since TScope extends string, this is assignable to string | ReadonlyArray<string>\n return useIsBlocked(scope);\n },\n\n useAsyncAction: <T = unknown>(\n actionId: string,\n scope?: ScopeValue<TScope>,\n options?: UseAsyncActionOptions\n ) => {\n return useAsyncAction<T>(actionId, scope, options);\n },\n\n useBlockingInfo: (scope) => useBlockingInfo(scope),\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/store/uiBlockingStore.constants.ts","../src/store/uiBlockingStore.utils.ts","../src/store/uiBlockingStore.actions.ts","../src/context/UIBlockingContext.tsx","../src/store/uiBlockingStore.config.ts","../src/store/uiBlockingStore.store.ts","../src/context/useResolvedStore.ts","../src/hooks/useAsyncAction/useAsyncAction.ts","../src/hooks/useBlocker/useBlocker.ts","../src/hooks/useBlocker/useBlocker.utils.ts","../src/hooks/useBlockingInfo/useBlockingInfo.ts","../src/hooks/useConfigRef.ts","../src/hooks/useConditionalBlocker/useConditionalBlocker.ts","../src/hooks/useConfirmableBlocker/useConfirmableBlocker.ts","../src/hooks/useIsBlocked/useIsBlocked.ts","../src/hooks/useScheduledBlocker/useScheduledBlocker.utils.ts","../src/hooks/useScheduledBlocker/useScheduledBlocker.ts","../src/middleware/analyticsMiddleware.utils.ts","../src/middleware/analyticsMiddleware.ts","../src/middleware/configureMiddleware.ts","../src/middleware/loggerMiddleware.utils.ts","../src/middleware/loggerMiddleware.ts","../src/middleware/performanceMiddleware.utils.ts","../src/middleware/performanceMiddleware.ts","../src/createTypedHooks.ts"],"names":["createStoreProvider","jsx","createShallow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AAAA,IAC3B,CAAA;AAAA,IAEA,cAAA,EAAgB,CACd,QAAA,EACA,KAAA,EACA,OAAA,KACG;AACH,MAAA,OAAO,cAAA,CAAkB,QAAA,EAAU,KAAA,EAAO,OAAO,CAAA;AAAA,IACnD,CAAA;AAAA,IAEA,eAAA,EAAiB,CAAC,KAAA,KAAU,eAAA,CAAgB,KAAK;AAAA,GACnD;AACF","file":"index.cjs","sourcesContent":["/**\n * Default values and constants for UI Blocking Store\n */\n\n/**\n * Default scope for blockers\n */\nexport const DEFAULT_SCOPE = \"global\" as const;\n\n/**\n * Default reason when none is provided\n */\nexport const DEFAULT_REASON = \"Unknown\" as const;\n\n/**\n * Default priority for blockers\n */\nexport const DEFAULT_PRIORITY = 0 as const;\n\n/**\n * Default priority for async actions\n */\nexport const ASYNC_ACTION_PRIORITY = 20 as const;\n\n/**\n * DevTools store name\n */\nexport const DEVTOOLS_NAME = \"UIBlocking\" as const;\n","import { StateCreator, StoreApi, StoreMutators, createStore, useStore } from \"zustand\";\nimport { useShallow } from \"zustand/react/shallow\";\n\nexport interface ShallowStoreBindings<StoreState> {\n useStore: {\n (): StoreState;\n <T>(selector: (state: StoreState) => T): T;\n };\n useStoreApi: StoreApi<StoreState>;\n}\n\n/**\n * Creates a Zustand store with automatic shallow comparison for all selectors\n *\n * This utility wraps the standard Zustand store creation and automatically applies\n * `useShallow` to all selectors, preventing unnecessary re-renders when selected\n * values haven't changed (shallow equality).\n *\n * Supports two usage patterns:\n * - `useStore()` - Returns the entire store state\n * - `useStore(selector)` - Returns the result of the selector function\n *\n * @template StoreState - The type of the store state\n * @template TMutators - Array of middleware mutators (e.g., devtools, persist)\n *\n * @param storeCreator - The state creator function for Zustand\n * @returns Object containing the store hook and store API\n *\n * @see https://docs.pmnd.rs/zustand/guides/prevent-rerenders-with-use-shallow\n */\nexport function createShallowStore<\n StoreState,\n TMutators extends Array<[keyof StoreMutators<StoreState, StoreState>, unknown]> = [],\n>(\n storeCreator: StateCreator<StoreState, [], TMutators, StoreState>\n): ShallowStoreBindings<StoreState> {\n const storeApi: StoreApi<StoreState> = createStore<StoreState, TMutators>(storeCreator);\n\n function useScopedStore(): StoreState;\n function useScopedStore<T>(selector: (state: StoreState) => T): T;\n function useScopedStore<T>(selector?: (state: StoreState) => T): T | StoreState {\n const actualSelector = (state: StoreState): T | StoreState =>\n selector ? selector(state) : state;\n\n return useStore(storeApi, useShallow(actualSelector));\n }\n\n return { useStore: useScopedStore, useStoreApi: storeApi };\n}\n\n/**\n * Normalize scope to array format\n *\n * @param scope - Single scope or array of scopes\n * @returns Array of scopes\n *\n * @internal\n */\nexport function normalizeScopeToArray(scope: string | ReadonlyArray<string>): Array<string> {\n if (typeof scope === \"string\") {\n return [scope];\n }\n return Array.from(scope);\n}\n","import { Middleware, MiddlewareContext } from \"../middleware\";\nimport { DEFAULT_PRIORITY, DEFAULT_REASON, DEFAULT_SCOPE } from \"./uiBlockingStore.constants\";\nimport { normalizeScopeToArray } from \"./uiBlockingStore.utils\";\nimport type {\n BlockerConfig,\n BlockerInfo,\n StoredBlocker,\n UIBlockingStore,\n} from \"./uiBlockingStore.types\";\nimport type { StateCreator } from \"zustand\";\n\n/**\n * UI Blocking Store Slice\n *\n * Implements the state and actions for UI blocking management.\n * This slice follows the Zustand slice pattern for better code organization.\n */\nexport const createUIBlockingActions: StateCreator<UIBlockingStore, [], [], UIBlockingStore> = (\n set,\n get\n) => ({\n // State\n activeBlockers: new Map(),\n middlewares: new Map(),\n\n registerMiddleware: (name: string, middleware: Middleware) => {\n set((state) => {\n const newMiddlewares = new Map(state.middlewares);\n newMiddlewares.set(name, middleware);\n return { middlewares: newMiddlewares };\n });\n console.log(`[UIBlocking] Registered middleware: ${name}`);\n },\n\n unregisterMiddleware: (name: string) => {\n set((state) => {\n const newMiddlewares = new Map(state.middlewares);\n newMiddlewares.delete(name);\n return { middlewares: newMiddlewares };\n });\n console.log(`[UIBlocking] Unregistered middleware: ${name}`);\n },\n\n runMiddlewares: async (context: MiddlewareContext) => {\n const { middlewares } = get();\n\n for (const [name, middleware] of middlewares) {\n try {\n await middleware(context);\n } catch (error) {\n console.error(`[UIBlocking] Middleware \"${name}\" error:`, error);\n }\n }\n },\n\n // Actions\n /**\n * Add a blocker to the store\n *\n * @param id - Unique blocker identifier\n * @param config - Optional blocker configuration\n *\n */\n addBlocker: (id: string, config: BlockerConfig = {}): void => {\n // Clear existing timeout if blocker is being overwritten\n const existingBlocker = get().activeBlockers.get(id);\n if (existingBlocker?.timeoutId) {\n clearTimeout(existingBlocker.timeoutId);\n }\n\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n // Set up timeout if specified\n if (config.timeout && config.timeout > 0) {\n timeoutId = setTimeout(() => {\n // Check if blocker still exists\n if (get().activeBlockers.has(id)) {\n // Call onTimeout callback before removing\n config.onTimeout?.(id);\n\n // Run timeout middleware\n void get().runMiddlewares({\n action: \"timeout\",\n blockerId: id,\n config: {\n scope: config.scope,\n reason: config.reason,\n priority: config.priority,\n timeout: config.timeout,\n },\n timestamp: Date.now(),\n });\n\n // Remove the blocker (this will also run \"remove\" middleware)\n get().removeBlocker(id);\n }\n }, config.timeout);\n }\n\n set((state) => {\n const newBlockers = new Map(state.activeBlockers);\n const storedBlocker: StoredBlocker = {\n scope: config.scope ?? DEFAULT_SCOPE,\n reason: config.reason ?? DEFAULT_REASON,\n priority: config.priority ?? DEFAULT_PRIORITY,\n timestamp: config.timestamp ?? Date.now(),\n timeout: config.timeout,\n timeoutId,\n onTimeout: config.onTimeout,\n };\n newBlockers.set(id, storedBlocker);\n\n return { activeBlockers: newBlockers };\n });\n\n void get().runMiddlewares({\n action: \"add\",\n blockerId: id,\n config: {\n scope: config.scope,\n reason: config.reason,\n priority: config.priority,\n timeout: config.timeout,\n },\n timestamp: Date.now(),\n });\n },\n\n /**\n * Remove a blocker from the store\n *\n * @param id - Blocker identifier to remove\n *\n */\n removeBlocker: (id: string): void => {\n const prevBlocker = get().activeBlockers.get(id);\n\n // Clear timeout if it exists\n if (prevBlocker?.timeoutId) {\n clearTimeout(prevBlocker.timeoutId);\n }\n\n set((state) => {\n const newBlockers = new Map(state.activeBlockers);\n newBlockers.delete(id);\n\n return { activeBlockers: newBlockers };\n });\n\n if (prevBlocker) {\n void get().runMiddlewares({\n action: \"remove\",\n blockerId: id,\n config: prevBlocker,\n timestamp: Date.now(),\n prevState: prevBlocker,\n });\n }\n },\n\n /**\n * Check if a scope is currently blocked\n *\n * @param scope - Scope or array of scopes to check (default: \"global\")\n * @returns True if any of the scopes are blocked\n *\n */\n isBlocked: (scope: string | ReadonlyArray<string> = DEFAULT_SCOPE): boolean => {\n const { activeBlockers } = get();\n const scopes = normalizeScopeToArray(scope);\n\n for (const [, blocker] of activeBlockers) {\n // Global blocking blocks everything\n if (blocker.scope === DEFAULT_SCOPE) {\n return true;\n }\n\n // Check scope intersection\n const blockerScopes = normalizeScopeToArray(blocker.scope);\n\n if (scopes.some((s) => blockerScopes.includes(s))) {\n return true;\n }\n }\n\n return false;\n },\n\n /**\n * Get detailed blocking information for a specific scope\n *\n * @param scope - Scope to get blocking information for\n * @returns Array of blockers affecting the scope, sorted by priority (highest first)\n *\n */\n getBlockingInfo: (scope: string): ReadonlyArray<BlockerInfo> => {\n const { activeBlockers } = get();\n const blockers: Array<BlockerInfo> = [];\n\n for (const [id, blocker] of activeBlockers) {\n const blockerScopes = normalizeScopeToArray(blocker.scope);\n\n if (blocker.scope === DEFAULT_SCOPE || blockerScopes.includes(scope)) {\n blockers.push({ id, ...blocker });\n }\n }\n\n return blockers.sort((a, b) => b.priority - a.priority);\n },\n\n /**\n * Clear all blockers from the store\n */\n clearAllBlockers: (): void => {\n // Clear all timeouts before clearing blockers\n const { activeBlockers } = get();\n for (const [, blocker] of activeBlockers) {\n if (blocker.timeoutId) {\n clearTimeout(blocker.timeoutId);\n }\n }\n\n set({ activeBlockers: new Map() });\n },\n\n /**\n * Clear all blockers for a specific scope\n *\n * @param scope - Scope to clear blockers for\n *\n */\n clearBlockersForScope: (scope: string): void => {\n // Clear timeouts for blockers that will be removed\n const { activeBlockers } = get();\n for (const [, blocker] of activeBlockers) {\n const blockerScopes = normalizeScopeToArray(blocker.scope);\n if (blockerScopes.includes(scope) && blocker.timeoutId) {\n clearTimeout(blocker.timeoutId);\n }\n }\n\n set((state) => {\n const newBlockers = new Map();\n\n for (const [id, blocker] of state.activeBlockers) {\n const blockerScopes = normalizeScopeToArray(blocker.scope);\n\n if (!blockerScopes.includes(scope)) {\n newBlockers.set(id, blocker);\n }\n }\n\n return { activeBlockers: newBlockers };\n });\n },\n});\n","import { createStoreProvider } from \"@okyrychenko-dev/react-zustand-toolkit\";\nimport { type ReactNode } from \"react\";\nimport { type StoreApi } from \"zustand\";\nimport { createUIBlockingActions } from \"../store/uiBlockingStore.actions\";\nimport type { Middleware } from \"../middleware\";\nimport type { UIBlockingStore } from \"../store/uiBlockingStore.types\";\n\n/**\n * Props for UIBlockingProvider component\n */\nexport interface UIBlockingProviderProps {\n children: ReactNode;\n /** Enable Redux DevTools integration (default: true in development) */\n enableDevtools?: boolean;\n /** Name for Redux DevTools (default: \"UIBlocking\") */\n devtoolsName?: string;\n /** Initial middlewares to register */\n middlewares?: ReadonlyArray<Middleware>;\n}\n\n/**\n * Base provider created using toolkit's createStoreProvider\n * This creates isolated store instances for SSR, testing, and micro-frontends\n */\nconst {\n Provider: BaseUIBlockingProvider,\n useContext: useUIBlockingContext,\n useContextStore: useUIBlockingStoreFromContext,\n useIsInsideProvider: useIsInsideUIBlockingProvider,\n useOptionalContext,\n} = createStoreProvider(createUIBlockingActions, \"UIBlocking\");\n\n/**\n * Provider component for isolated UI blocking state\n *\n * Uses toolkit's createStoreProvider with built-in DevTools support\n * and onStoreCreate callback for middleware registration.\n */\nexport function UIBlockingProvider({\n children,\n enableDevtools = process.env.NODE_ENV === \"development\",\n devtoolsName = \"UIBlocking\",\n middlewares = [],\n}: UIBlockingProviderProps): ReactNode {\n const handleStoreCreate = (store: StoreApi<UIBlockingStore>): void => {\n // Register initial middlewares\n middlewares.forEach((mw, index) => {\n store.getState().registerMiddleware(`provider-middleware-${index.toString()}`, mw);\n });\n };\n\n return (\n <BaseUIBlockingProvider\n enableDevtools={enableDevtools}\n devtoolsName={devtoolsName}\n onStoreCreate={handleStoreCreate}\n >\n {children}\n </BaseUIBlockingProvider>\n );\n}\n\n// Export hooks from base provider\nexport {\n useUIBlockingContext,\n useUIBlockingStoreFromContext,\n useIsInsideUIBlockingProvider,\n useOptionalContext,\n};\n","import { DEVTOOLS_NAME } from \"./uiBlockingStore.constants\";\nimport type { DevtoolsOptions } from \"zustand/middleware\";\n\n/**\n * DevTools configuration for UI Blocking Store\n *\n * Enables Redux DevTools integration only in development mode\n * for better debugging experience without production overhead.\n */\nexport const devtoolsConfig: DevtoolsOptions = {\n name: DEVTOOLS_NAME,\n enabled: process.env.NODE_ENV !== \"production\",\n};\n","import { createShallowStore } from \"@okyrychenko-dev/react-zustand-toolkit\";\nimport { devtools } from \"zustand/middleware\";\nimport { createUIBlockingActions } from \"./uiBlockingStore.actions\";\nimport { devtoolsConfig } from \"./uiBlockingStore.config\";\nimport type { UIBlockingStore } from \"./uiBlockingStore.types\";\n\n/**\n * UI Blocking Store\n *\n * Global Zustand store for managing UI blocking state across the application.\n *\n * Features:\n * - Priority-based blocking system\n * - Scope-based blocking (global, specific areas, or multiple scopes)\n * - Automatic cleanup on unmount (when using hooks)\n * - DevTools integration for debugging\n * - Automatic shallow comparison for selectors\n *\n */\nconst { useStore: useUIBlockingStore, useStoreApi: uiBlockingStoreApi } = createShallowStore<\n UIBlockingStore,\n [[\"zustand/devtools\", never]]\n>(devtools(createUIBlockingActions, devtoolsConfig));\n\nexport { useUIBlockingStore, uiBlockingStoreApi };\n","import { type StoreApi, useStore } from \"zustand\";\nimport { useShallow } from \"zustand/shallow\";\nimport { uiBlockingStoreApi } from \"../store/uiBlockingStore.store\";\nimport { useOptionalContext } from \"./UIBlockingContext\";\nimport type { UIBlockingStore } from \"../store/uiBlockingStore.types\";\n\n/**\n * Hook to get the optional context store (returns null if not inside provider)\n * @internal\n */\nfunction useOptionalContextStore(): StoreApi<UIBlockingStore> | null {\n return useOptionalContext();\n}\n\n/**\n * Hook that resolves to either the context store or global store\n *\n * This hook automatically uses the store from UIBlockingProvider if available,\n * otherwise falls back to the global store. This enables both patterns:\n *\n * 1. Global store (default behavior, no Provider needed)\n * 2. Context store (for SSR, testing, micro-frontends)\n *\n * @returns The resolved store API\n */\nexport function useResolvedStore(): StoreApi<UIBlockingStore> {\n const contextStore = useOptionalContextStore();\n // Return context store if inside Provider, otherwise global store\n return contextStore ?? uiBlockingStoreApi;\n}\n\n/**\n * Hook to use the resolved store with a selector\n *\n * Automatically applies shallow comparison to prevent unnecessary re-renders.\n *\n * @param selector - Selector function to pick state from the store\n * @returns Selected state value\n */\nexport function useResolvedStoreWithSelector<T>(selector: (state: UIBlockingStore) => T): T {\n const store = useResolvedStore();\n return useStore(store, useShallow(selector));\n}\n","import { useCallback } from \"react\";\nimport { useResolvedStoreWithSelector } from \"../../context\";\nimport { ASYNC_ACTION_PRIORITY } from \"../../store\";\n\n/**\n * Options for useAsyncAction hook\n */\nexport interface UseAsyncActionOptions {\n /** Timeout in milliseconds after which the blocker will be automatically removed */\n timeout?: number;\n /** Callback invoked when the blocker is automatically removed due to timeout */\n onTimeout?: (blockerId: string) => void;\n}\n\n/**\n * Hook to wrap async functions with automatic blocking/unblocking\n *\n * Creates a wrapper function that automatically adds a blocker before executing\n * the async function and removes it after completion (success or failure).\n *\n * Supports both global store and context store (via UIBlockingProvider).\n *\n * @template T - The return type of the async function\n * @param actionId - Unique identifier for the action (used in blocker ID and reason)\n * @param scope - Scope(s) to block during execution (default: \"global\")\n * @param options - Optional configuration including timeout\n * @returns Function that wraps async functions with blocking behavior\n *\n */\nexport const useAsyncAction = <T = unknown>(\n actionId: string,\n scope?: string | ReadonlyArray<string>,\n options?: UseAsyncActionOptions\n): ((asyncFn: () => Promise<T>) => Promise<T>) => {\n const { addBlocker, removeBlocker } = useResolvedStoreWithSelector((state) => ({\n addBlocker: state.addBlocker,\n removeBlocker: state.removeBlocker,\n }));\n\n const executeWithBlocking = useCallback(\n async (asyncFn: () => Promise<T>): Promise<T> => {\n const blockerId = `${actionId}-${Date.now().toString()}`;\n\n try {\n addBlocker(blockerId, {\n scope,\n reason: `Executing ${actionId}`,\n priority: ASYNC_ACTION_PRIORITY,\n timeout: options?.timeout,\n onTimeout: options?.onTimeout,\n });\n\n return await asyncFn();\n } finally {\n removeBlocker(blockerId);\n }\n },\n [actionId, scope, options?.timeout, options?.onTimeout, addBlocker, removeBlocker]\n );\n\n return executeWithBlocking;\n};\n","import { useEffect } from \"react\";\nimport { useResolvedStoreWithSelector } from \"../../context\";\nimport type { BlockerConfig } from \"../../store\";\n\n/**\n * Hook to automatically add and remove a blocker based on component lifecycle\n *\n * Automatically adds a blocker when the component mounts (or when activated)\n * and removes it when the component unmounts (or when deactivated).\n *\n * Supports both global store and context store (via UIBlockingProvider).\n *\n * @param blockerId - Unique identifier for the blocker\n * @param config - Blocker configuration (scope, reason, priority)\n * @param isActive - Whether the blocker is currently active (default: true)\n *\n */\nexport const useBlocker = (blockerId: string, config: BlockerConfig, isActive = true): void => {\n const { addBlocker, removeBlocker } = useResolvedStoreWithSelector((state) => ({\n addBlocker: state.addBlocker,\n removeBlocker: state.removeBlocker,\n }));\n\n useEffect(() => {\n if (!isActive || !blockerId) {\n return;\n }\n\n addBlocker(blockerId, config);\n\n return () => {\n removeBlocker(blockerId);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [blockerId, isActive, addBlocker, removeBlocker]);\n};\n","import { BlockerConfig } from \"../../store\";\n\n/**\n * Creates a blocker configuration object from partial config.\n * Filters out undefined values to create a clean BlockerConfig.\n *\n * @param config - Partial blocker configuration\n * @returns Complete BlockerConfig object\n *\n */\nexport function createBlockerConfig(config: {\n scope?: string | ReadonlyArray<string>;\n reason?: string;\n priority?: number;\n}): BlockerConfig {\n return {\n scope: config.scope,\n reason: config.reason,\n priority: config.priority,\n };\n}\n","import { useMemo } from \"react\";\nimport { useStore } from \"zustand\";\nimport { useResolvedStore } from \"../../context\";\nimport { DEFAULT_SCOPE } from \"../../store\";\nimport type { BlockerInfo } from \"../../store\";\n\n/**\n * Hook to get detailed blocking information for a scope\n *\n * Returns an array of blocker information objects for the specified scope,\n * sorted by priority (highest first). Automatically re-renders when blockers change.\n *\n * Uses a stable reference - only re-renders when the actual blocker list changes,\n * not on every store update.\n *\n * Supports both global store and context store (via UIBlockingProvider).\n *\n * @param scope - Scope to get blocking information for (default: \"global\")\n * @returns Array of blocker information objects, sorted by priority\n *\n * ```\n */\nexport const useBlockingInfo = (scope: string = DEFAULT_SCOPE): ReadonlyArray<BlockerInfo> => {\n const store = useResolvedStore();\n\n // Subscribe to the activeBlockers Map to detect changes\n const activeBlockers = useStore(store, (state) => state.activeBlockers);\n\n // Recompute blockers only when activeBlockers or scope changes\n return useMemo(() => {\n return store.getState().getBlockingInfo(scope);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeBlockers, scope, store]);\n};\n","import { RefObject, useEffect, useRef } from \"react\";\n\n/**\n * Keeps a ref updated with the latest config value.\n * Useful for accessing current config in callbacks without stale closures.\n *\n * @param config - Configuration object to track\n * @returns Mutable ref that always contains the latest config\n *\n */\nexport function useConfigRef<T>(config: T): RefObject<T> {\n const configRef = useRef(config);\n\n useEffect(() => {\n configRef.current = config;\n }, [config]);\n\n return configRef;\n}\n","import { useCallback, useEffect, useRef } from \"react\";\nimport { useResolvedStoreWithSelector } from \"../../context\";\nimport { createBlockerConfig } from \"../useBlocker\";\nimport { useConfigRef } from \"../useConfigRef\";\nimport { ConditionalBlockerConfig } from \"./useConditionalBlocker.types\";\n\n/**\n * Hook for conditional blocking based on a condition function.\n *\n * Periodically checks a condition and blocks/unblocks based on the result.\n * The condition is evaluated at the specified interval (default 1000ms).\n *\n * Supports both global store and context store (via UIBlockingProvider).\n *\n * @param blockerId - Unique identifier for this blocker\n * @param config - Configuration including condition function and check interval\n *\n */\nexport const useConditionalBlocker = <TState = unknown>(\n blockerId: string,\n config: ConditionalBlockerConfig<TState>\n): void => {\n const { addBlocker, removeBlocker } = useResolvedStoreWithSelector((state) => ({\n addBlocker: state.addBlocker,\n removeBlocker: state.removeBlocker,\n }));\n const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);\n const isBlockedRef = useRef(false);\n const configRef = useConfigRef(config);\n\n const checkCondition = useCallback(() => {\n const currentConfig = configRef.current;\n const shouldBlock = currentConfig.condition(currentConfig.state);\n\n // No state change needed\n if (shouldBlock === isBlockedRef.current) {\n return;\n }\n\n if (shouldBlock) {\n addBlocker(blockerId, createBlockerConfig(currentConfig));\n } else {\n removeBlocker(blockerId);\n }\n isBlockedRef.current = shouldBlock;\n }, [blockerId, addBlocker, removeBlocker, configRef]);\n\n useEffect(() => {\n checkCondition();\n\n const interval = configRef.current.checkInterval ?? 1000;\n intervalRef.current = setInterval(checkCondition, interval);\n\n return (): void => {\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n intervalRef.current = null;\n }\n if (isBlockedRef.current) {\n removeBlocker(blockerId);\n isBlockedRef.current = false;\n }\n };\n // configRef is stable and doesn't need to be in dependencies\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [checkCondition, blockerId, removeBlocker]);\n};\n","import { useCallback, useState } from \"react\";\nimport { useBlocker } from \"../useBlocker\";\nimport {\n ConfirmableBlockerConfig,\n UseConfirmableBlockerReturn,\n} from \"./useConfirmableBlocker.types\";\n\n/**\n * Hook for creating a confirmable action with blocking UI\n *\n */\nexport const useConfirmableBlocker = (\n blockerId: string,\n config: ConfirmableBlockerConfig\n): UseConfirmableBlockerReturn => {\n const [isDialogOpen, setIsDialogOpen] = useState(false);\n const [isExecuting, setIsExecuting] = useState(false);\n\n useBlocker(\n blockerId,\n {\n ...config,\n reason: config.reason ?? config.confirmMessage,\n },\n isDialogOpen || isExecuting\n );\n\n const execute = useCallback(() => {\n setIsDialogOpen(true);\n }, []);\n\n const onConfirm = useCallback(async () => {\n setIsDialogOpen(false);\n setIsExecuting(true);\n\n try {\n await config.onConfirm();\n } catch (error) {\n console.error(\"[UIBlocking] Confirmable action error:\", error);\n throw error;\n } finally {\n setIsExecuting(false);\n }\n }, [config]);\n\n const onCancel = useCallback(() => {\n setIsDialogOpen(false);\n config.onCancel?.();\n }, [config]);\n\n return {\n execute,\n isDialogOpen,\n isExecuting,\n confirmConfig: {\n title: config.confirmTitle ?? \"Confirm Action\",\n message: config.confirmMessage,\n confirmText: config.confirmButtonText ?? \"Confirm\",\n cancelText: config.cancelButtonText ?? \"Cancel\",\n },\n onConfirm,\n onCancel,\n };\n};\n","import { useResolvedStoreWithSelector } from \"../../context\";\n\n/**\n * Hook to check if a scope is currently blocked\n *\n * Returns a boolean indicating whether the specified scope(s) are blocked.\n * Automatically re-renders when the blocking state changes.\n *\n * Supports both global store and context store (via UIBlockingProvider).\n *\n * @param scope - Scope or array of scopes to check (default: \"global\")\n * @returns True if any of the specified scopes are blocked\n *\n */\nexport const useIsBlocked = (scope?: string | ReadonlyArray<string>): boolean => {\n return useResolvedStoreWithSelector((state) => state.isBlocked(scope));\n};\n","import type { BlockingSchedule } from \"./useScheduledBlocker.types\";\n\n/**\n * Maximum safe timeout value for setTimeout in JavaScript (~24.8 days).\n * Values larger than this will cause setTimeout to trigger immediately.\n */\nexport const MAX_TIMEOUT_MS = 2147483647;\n\n/**\n * Validates a date value and converts it to timestamp.\n *\n * @param date - Date value as string, Date object, or number\n * @returns Timestamp in milliseconds, or NaN if invalid\n */\nexport function parseDate(date: string | Date | number): number {\n return new Date(date).getTime();\n}\n\n/**\n * Validates if a timestamp is valid (not NaN).\n *\n * @param timestamp - Timestamp to validate\n * @returns True if valid, false otherwise\n */\nexport function isValidTimestamp(timestamp: number): boolean {\n return !Number.isNaN(timestamp);\n}\n\n/**\n * Calculates the end time based on schedule configuration.\n * Duration takes precedence over end time if both are provided.\n *\n * @param schedule - Blocking schedule configuration\n * @param startTime - Start time in milliseconds\n * @returns End time in milliseconds, or undefined if not specified\n */\nexport function calculateEndTime(\n schedule: BlockingSchedule,\n startTime: number\n): number | undefined {\n if (schedule.duration) {\n return startTime + schedule.duration;\n }\n\n if (schedule.end) {\n const endTime = parseDate(schedule.end);\n return isValidTimestamp(endTime) ? endTime : undefined;\n }\n\n return undefined;\n}\n\n/**\n * Validates if a delay is within the safe setTimeout range.\n *\n * @param delay - Delay in milliseconds\n * @returns True if delay is safe to use with setTimeout\n */\nexport function isSafeTimeout(delay: number): boolean {\n return delay > 0 && delay <= MAX_TIMEOUT_MS;\n}\n\n/**\n * Determines if the current time is within a blocking schedule.\n *\n * @param startTime - Schedule start time in milliseconds\n * @param endTime - Schedule end time in milliseconds (optional)\n * @param now - Current time in milliseconds\n * @returns True if currently in the blocking period\n */\nexport function isInBlockingPeriod(\n startTime: number,\n endTime: number | undefined,\n now: number\n): boolean {\n if (startTime > now) {\n return false; // Not started yet\n }\n\n if (!endTime) {\n return true; // No end time means block indefinitely\n }\n\n return endTime > now; // Check if end time hasn't passed\n}\n\n/**\n * Checks if a schedule is completely in the past.\n *\n * @param startTime - Schedule start time in milliseconds\n * @param endTime - Schedule end time in milliseconds (optional)\n * @param now - Current time in milliseconds\n * @returns True if the schedule is in the past\n */\nexport function isScheduleInPast(\n startTime: number,\n endTime: number | undefined,\n now: number\n): boolean {\n if (!endTime) {\n return false; // No end time means it can still be active\n }\n\n return endTime <= now && startTime <= now;\n}\n","import { useCallback, useEffect, useRef } from \"react\";\nimport { useResolvedStoreWithSelector } from \"../../context\";\nimport { createBlockerConfig } from \"../useBlocker\";\nimport { useConfigRef } from \"../useConfigRef\";\nimport { ScheduledBlockerConfig } from \"./useScheduledBlocker.types\";\nimport {\n MAX_TIMEOUT_MS,\n calculateEndTime,\n isInBlockingPeriod,\n isSafeTimeout,\n isScheduleInPast,\n isValidTimestamp,\n parseDate,\n} from \"./useScheduledBlocker.utils\";\n\n/**\n * Hook for scheduling UI blocking for a specific time period.\n *\n * Blocks UI during a scheduled maintenance window or time period.\n * Supports start/end times as Date objects, ISO strings, or timestamps.\n * If both duration and end are provided, duration takes precedence.\n *\n * Supports both global store and context store (via UIBlockingProvider).\n *\n * @param blockerId - Unique identifier for this blocker\n * @param config - Configuration including schedule and callbacks\n *\n */\nexport const useScheduledBlocker = (blockerId: string, config: ScheduledBlockerConfig): void => {\n const { addBlocker, removeBlocker } = useResolvedStoreWithSelector((state) => ({\n addBlocker: state.addBlocker,\n removeBlocker: state.removeBlocker,\n }));\n const timeoutsRef = useRef<{\n start?: ReturnType<typeof setTimeout>;\n end?: ReturnType<typeof setTimeout>;\n }>({});\n const configRef = useConfigRef(config);\n\n const cleanup = useCallback(() => {\n if (timeoutsRef.current.start) {\n clearTimeout(timeoutsRef.current.start);\n timeoutsRef.current.start = undefined;\n }\n if (timeoutsRef.current.end) {\n clearTimeout(timeoutsRef.current.end);\n timeoutsRef.current.end = undefined;\n }\n }, []);\n\n useEffect(() => {\n const currentConfig = configRef.current;\n const startTime = parseDate(currentConfig.schedule.start);\n const now = Date.now();\n\n // Validate start time\n if (!isValidTimestamp(startTime)) {\n console.error(`[UIBlocking] Invalid start time for blocker \"${blockerId}\"`);\n return;\n }\n\n const scheduleEnd = (): void => {\n const endTime = calculateEndTime(currentConfig.schedule, startTime);\n if (!endTime) {\n return;\n }\n\n const remainingTime = endTime - Date.now();\n if (remainingTime > 0) {\n timeoutsRef.current.end = setTimeout(() => {\n configRef.current.onScheduleEnd?.();\n removeBlocker(blockerId);\n }, remainingTime);\n }\n };\n\n const startBlocking = (): void => {\n const cfg = configRef.current;\n addBlocker(blockerId, createBlockerConfig(cfg));\n cfg.onScheduleStart?.();\n scheduleEnd();\n };\n\n // If start time hasn't arrived yet\n if (startTime > now) {\n const delay = startTime - now;\n\n if (!isSafeTimeout(delay)) {\n console.warn(\n `[UIBlocking] Schedule delay exceeds maximum timeout (${MAX_TIMEOUT_MS.toString()}ms) for blocker \"${blockerId}\"`\n );\n return;\n }\n\n timeoutsRef.current.start = setTimeout(startBlocking, delay);\n }\n // If already in blocking period or should start immediately\n else {\n const endTime = calculateEndTime(currentConfig.schedule, startTime);\n\n if (isInBlockingPeriod(startTime, endTime, now)) {\n startBlocking();\n } else if (isScheduleInPast(startTime, endTime, now)) {\n console.warn(`[UIBlocking] Schedule is in the past for blocker \"${blockerId}\"`);\n }\n }\n\n return (): void => {\n cleanup();\n removeBlocker(blockerId);\n };\n // configRef is stable and doesn't need to be in dependencies\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [blockerId, addBlocker, removeBlocker, cleanup]);\n};\n","import { AnalyticsEventData } from \"./analyticsMiddleware.types\";\nimport { MiddlewareContext } from \"./middleware.types\";\n\nconst capitalizeFirst = (str: string): string => {\n return str.charAt(0).toUpperCase() + str.slice(1);\n};\n\nexport const buildEventData = (context: MiddlewareContext): AnalyticsEventData => {\n const eventData: AnalyticsEventData = {\n blocker_id: context.blockerId,\n };\n const { scope, reason, priority } = context.config ?? {};\n\n if (scope !== undefined) {\n eventData.scope = Array.isArray(scope) ? scope.join(\",\") : scope;\n }\n\n if (reason !== undefined) {\n eventData.reason = reason;\n }\n\n if (priority !== undefined) {\n eventData.priority = priority;\n }\n\n return eventData;\n};\n\nexport const trackGoogleAnalytics = (action: string, eventData: AnalyticsEventData): void => {\n if (window.gtag) {\n window.gtag(\"event\", `ui_blocking_${action}`, eventData);\n }\n};\n\nexport const trackMixpanel = (action: string, eventData: AnalyticsEventData): void => {\n if (window.mixpanel) {\n const eventName = `UI Blocking ${action.split(\"_\").map(capitalizeFirst).join(\" \")}`;\n\n window.mixpanel.track(eventName, eventData);\n }\n};\n\nexport const trackAmplitude = (action: string, eventData: AnalyticsEventData): void => {\n if (window.amplitude) {\n const eventName = `UI Blocking ${action.split(\"_\").map(capitalizeFirst).join(\" \")}`;\n\n window.amplitude.track(eventName, eventData);\n }\n};\n\nexport const trackCustom = (\n trackFn: (event: string, data: AnalyticsEventData) => void,\n action: string,\n eventData: AnalyticsEventData\n): void => {\n try {\n trackFn(`ui_blocking_${action}`, eventData);\n } catch {\n // Silently ignore errors in custom tracker\n }\n};\n","import { AnalyticsConfig, AnalyticsEventData } from \"./analyticsMiddleware.types\";\nimport {\n buildEventData,\n trackAmplitude,\n trackCustom,\n trackGoogleAnalytics,\n trackMixpanel,\n} from \"./analyticsMiddleware.utils\";\nimport { Middleware, MiddlewareContext } from \"./middleware.types\";\n\nconst trackEvent = (\n config: AnalyticsConfig,\n context: MiddlewareContext,\n eventData: AnalyticsEventData\n): void => {\n if (\"provider\" in config) {\n switch (config.provider) {\n case \"ga\":\n trackGoogleAnalytics(context.action, eventData);\n return;\n case \"mixpanel\":\n trackMixpanel(context.action, eventData);\n return;\n case \"amplitude\":\n trackAmplitude(context.action, eventData);\n return;\n }\n }\n\n if (\"track\" in config) {\n trackCustom(config.track, context.action, eventData);\n }\n};\n\nexport const createAnalyticsMiddleware = (config: AnalyticsConfig): Middleware => {\n return (context) => {\n const eventData = buildEventData(context);\n\n trackEvent(config, context, eventData);\n };\n};\n","import { uiBlockingStoreApi } from \"../store/uiBlockingStore.store\";\nimport type { Middleware } from \"./middleware.types\";\n\n/**\n * Configure middleware for the UI blocking store\n *\n * This is a convenience function that registers multiple middleware at once.\n * Each middleware will be registered with an auto-generated name based on its index.\n *\n * @param middlewares - Array of middleware functions to register\n *\n */\nexport function configureMiddleware(middlewares: ReadonlyArray<Middleware>): void {\n const store = uiBlockingStoreApi.getState();\n\n middlewares.forEach((middleware, index) => {\n // Generate a unique name for each middleware\n const name = `middleware-${index.toString()}`;\n store.registerMiddleware(name, middleware);\n });\n}\n","import { MiddlewareBlockerConfig, MiddlewareContext } from \"./middleware.types\";\n\nexport const getActionEmoji = (action: string): string => {\n switch (action) {\n case \"add\":\n return \"➕\";\n case \"remove\":\n return \"➖\";\n case \"update\":\n return \"🔄\";\n case \"cancel\":\n return \"❌\";\n case \"timeout\":\n return \"⏱️\";\n default:\n return \"❓\";\n }\n};\n\nconst extractConfigDetails = (config?: MiddlewareBlockerConfig): Record<string, unknown> => {\n if (!config) {\n return {};\n }\n\n const { scope, reason, priority } = config;\n\n const details: Record<string, unknown> = {\n scope,\n reason,\n };\n\n if (priority !== undefined) {\n details.priority = priority;\n }\n\n return details;\n};\n\nexport const formatLogData = (context: MiddlewareContext): Record<string, unknown> => {\n const configDetails = extractConfigDetails(context.config);\n\n if (context.prevState) {\n return {\n config: configDetails,\n prevState: extractConfigDetails(context.prevState),\n };\n }\n\n return configDetails;\n};\n","import { formatLogData, getActionEmoji } from \"./loggerMiddleware.utils\";\nimport { Middleware } from \"./middleware.types\";\n\nconst LOG_PREFIX = \"[UIBlocking]\";\n\nexport const loggerMiddleware: Middleware = (context) => {\n const emoji = getActionEmoji(context.action);\n const logData = formatLogData(context);\n\n console.log(LOG_PREFIX, emoji, context.blockerId, logData);\n};\n","export const handleAddAction = (\n blockerId: string,\n timestamp: number,\n blockStartTimes: Map<string, number>\n): void => {\n blockStartTimes.set(blockerId, timestamp);\n};\n","import { Middleware, MiddlewareContext } from \"./middleware.types\";\nimport { PerformanceConfig } from \"./performanceMiddleware.types\";\nimport { handleAddAction } from \"./performanceMiddleware.utils\";\n\nconst DEFAULT_SLOW_BLOCK_THRESHOLD = 3000;\nconst ACTION_ADD = \"add\";\nconst ACTION_REMOVE = \"remove\";\n\nconst handleRemoveAction = (\n context: MiddlewareContext,\n blockStartTimes: Map<string, number>,\n slowBlockThreshold: number,\n onSlowBlock?: (blockerId: string, duration: number) => void\n): void => {\n const startTime = blockStartTimes.get(context.blockerId);\n\n if (startTime === undefined) {\n return;\n }\n\n const duration = context.timestamp - startTime;\n blockStartTimes.delete(context.blockerId);\n\n if (duration >= slowBlockThreshold) {\n console.warn(\n `[UIBlocking] Slow block detected: \"${context.blockerId}\" took ${duration.toString()}ms`\n );\n\n onSlowBlock?.(context.blockerId, duration);\n }\n};\n\nexport const createPerformanceMiddleware = (config: PerformanceConfig = {}): Middleware => {\n const { slowBlockThreshold = DEFAULT_SLOW_BLOCK_THRESHOLD, onSlowBlock } = config;\n const blockStartTimes = new Map<string, number>();\n\n return (context) => {\n if (context.action === ACTION_ADD) {\n handleAddAction(context.blockerId, context.timestamp, blockStartTimes);\n } else if (context.action === ACTION_REMOVE) {\n handleRemoveAction(context, blockStartTimes, slowBlockThreshold, onSlowBlock);\n }\n };\n};\n","import { type UseAsyncActionOptions, useAsyncAction } from \"./hooks/useAsyncAction\";\nimport { useBlocker } from \"./hooks/useBlocker\";\nimport { useBlockingInfo } from \"./hooks/useBlockingInfo\";\nimport { useIsBlocked } from \"./hooks/useIsBlocked\";\nimport type { BlockerConfigTyped, ScopeValue } from \"./types\";\n\n/**\n * Return type for createTypedHooks factory\n */\nexport interface TypedHooks<TScope extends string> {\n /**\n * Type-safe version of useBlocker hook\n */\n useBlocker: (blockerId: string, config: BlockerConfigTyped<TScope>, isActive?: boolean) => void;\n\n /**\n * Type-safe version of useIsBlocked hook\n */\n useIsBlocked: (scope?: ScopeValue<TScope>) => boolean;\n\n /**\n * Type-safe version of useAsyncAction hook\n */\n useAsyncAction: <T = unknown>(\n actionId: string,\n scope?: ScopeValue<TScope>,\n options?: UseAsyncActionOptions\n ) => (asyncFn: () => Promise<T>) => Promise<T>;\n\n /**\n * Type-safe version of useBlockingInfo hook\n */\n useBlockingInfo: (scope: TScope) => ReturnType<typeof useBlockingInfo>;\n}\n\n/**\n * Creates type-safe versions of all blocking hooks with your custom scope types\n *\n * @template TScope - Union type of allowed scope strings\n * @returns Object with type-safe hook functions\n *\n * @example\n * ```typescript\n * // Define your app's scopes\n * type AppScopes = \"global\" | \"form\" | \"navigation\" | \"checkout\";\n *\n * // Create typed hooks\n * const { useBlocker, useIsBlocked, useAsyncAction } = createTypedHooks<AppScopes>();\n *\n * // Now TypeScript will catch typos\n * useBlocker(\"id\", { scope: \"form\" }); // ✓ OK\n * useBlocker(\"id\", { scope: \"typo\" }); // ✗ Type error!\n * ```\n */\nexport function createTypedHooks<TScope extends string>(): TypedHooks<TScope> {\n // TScope extends string, so all typed scopes are assignable to string | ReadonlyArray<string>\n // This allows us to pass typed values directly without casting\n return {\n useBlocker: (blockerId, config, isActive) => {\n // BlockerConfigTyped<TScope> is structurally compatible with BlockerConfig\n // because TScope extends string\n useBlocker(blockerId, config, isActive);\n },\n\n useIsBlocked: (scope) => {\n // ScopeValue<TScope> = TScope | ReadonlyArray<TScope>\n // Since TScope extends string, this is assignable to string | ReadonlyArray<string>\n return useIsBlocked(scope);\n },\n\n useAsyncAction: <T = unknown>(\n actionId: string,\n scope?: ScopeValue<TScope>,\n options?: UseAsyncActionOptions\n ) => {\n return useAsyncAction<T>(actionId, scope, options);\n },\n\n useBlockingInfo: (scope) => useBlockingInfo(scope),\n };\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as zustand from 'zustand';
2
2
  import { StoreApi } from 'zustand';
3
+ export { ShallowStoreBindings, createShallowStore } from '@okyrychenko-dev/react-zustand-toolkit';
3
4
  import { ReactNode } from 'react';
4
5
 
5
6
  /**
@@ -150,7 +151,10 @@ type UIBlockingStore = UIBlockingStoreState & UIBlockingStoreActions;
150
151
  * - Automatic shallow comparison for selectors
151
152
  *
152
153
  */
153
- declare const useUIBlockingStore: <T>(selector: (state: UIBlockingStore) => T) => T;
154
+ declare const useUIBlockingStore: {
155
+ (): UIBlockingStore;
156
+ <T>(selector: (state: UIBlockingStore) => T): T;
157
+ };
154
158
  declare const uiBlockingStoreApi: zustand.StoreApi<UIBlockingStore>;
155
159
 
156
160
  /**
@@ -403,59 +407,21 @@ interface UIBlockingProviderProps {
403
407
  middlewares?: ReadonlyArray<Middleware>;
404
408
  }
405
409
  /**
406
- * Provider component for isolated UI blocking state
407
- *
408
- * Use this to create an isolated store instance for:
409
- * - Server-side rendering (each request gets its own store)
410
- * - Testing (no need for beforeEach cleanup)
411
- * - Micro-frontends (isolated state per app)
412
- *
413
- * @example
414
- * ```tsx
415
- * // SSR - each request gets its own store
416
- * function App() {
417
- * return (
418
- * <UIBlockingProvider>
419
- * <MyComponent />
420
- * </UIBlockingProvider>
421
- * );
422
- * }
423
- *
424
- * // Testing - isolated store per test
425
- * function renderWithProvider(ui: ReactElement) {
426
- * return render(
427
- * <UIBlockingProvider>{ui}</UIBlockingProvider>
428
- * );
429
- * }
430
- * ```
431
- */
432
- declare function UIBlockingProvider({ children, enableDevtools, devtoolsName, middlewares, }: UIBlockingProviderProps): ReactNode;
433
- /**
434
- * Hook to access the UIBlocking store from context
435
- *
436
- * Throws an error if used outside of UIBlockingProvider.
437
- * Use useUIBlockingStoreFromContext for safe access with fallback.
438
- *
439
- * @returns The store API from the nearest UIBlockingProvider
440
- * @throws Error if used outside of UIBlockingProvider
441
- */
442
- declare function useUIBlockingContext(): StoreApi<UIBlockingStore>;
443
- /**
444
- * Hook to check if we're inside a UIBlockingProvider
445
- *
446
- * @returns true if inside UIBlockingProvider, false otherwise
410
+ * Base provider created using toolkit's createStoreProvider
411
+ * This creates isolated store instances for SSR, testing, and micro-frontends
447
412
  */
448
- declare function useIsInsideUIBlockingProvider(): boolean;
413
+ declare const useUIBlockingContext: () => StoreApi<UIBlockingStore>;
414
+ declare const useUIBlockingStoreFromContext: {
415
+ (): UIBlockingStore;
416
+ <T>(selector: (state: UIBlockingStore) => T): T;
417
+ };
418
+ declare const useIsInsideUIBlockingProvider: () => boolean;
449
419
  /**
450
- * Hook to use the UIBlocking store from context with a selector
451
- *
452
- * This is similar to useUIBlockingStore but uses the context store.
453
- * Automatically applies shallow comparison to prevent unnecessary re-renders.
420
+ * Provider component for isolated UI blocking state
454
421
  *
455
- * @param selector - Selector function to pick state from the store
456
- * @returns Selected state value
457
- * @throws Error if used outside of UIBlockingProvider
422
+ * Uses toolkit's createStoreProvider with built-in DevTools support
423
+ * and onStoreCreate callback for middleware registration.
458
424
  */
459
- declare function useUIBlockingStoreFromContext<T>(selector: (state: UIBlockingStore) => T): T;
425
+ declare function UIBlockingProvider({ children, enableDevtools, devtoolsName, middlewares, }: UIBlockingProviderProps): ReactNode;
460
426
 
461
427
  export { type AmplitudeConfig, type AnalyticsConfig, type AnalyticsEventData, type AnalyticsProvider, type BlockerConfig, type BlockerConfigTyped, type BlockerInfo, type BlockingAction, type BlockingSchedule, type ConditionalBlockerConfig, type ConfirmDialogConfig, type ConfirmableBlockerConfig, type CustomAnalyticsConfig, type DefaultScopes, type GoogleAnalyticsConfig, type Middleware, type MiddlewareContext, type MixpanelConfig, type PerformanceConfig, type ScheduledBlockerConfig, type ScopeValue, type StoredBlocker, type TypedHooks, UIBlockingProvider, type UIBlockingProviderProps, type UIBlockingStore, type UIBlockingStoreActions, type UIBlockingStoreState, type UseAsyncActionOptions, type UseConfirmableBlockerReturn, configureMiddleware, createAnalyticsMiddleware, createPerformanceMiddleware, createTypedHooks, loggerMiddleware, uiBlockingStoreApi, useAsyncAction, useBlocker, useBlockingInfo, useConditionalBlocker, useConfirmableBlocker, useIsBlocked, useIsInsideUIBlockingProvider, useScheduledBlocker, useUIBlockingContext, useUIBlockingStore, useUIBlockingStoreFromContext };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as zustand from 'zustand';
2
2
  import { StoreApi } from 'zustand';
3
+ export { ShallowStoreBindings, createShallowStore } from '@okyrychenko-dev/react-zustand-toolkit';
3
4
  import { ReactNode } from 'react';
4
5
 
5
6
  /**
@@ -150,7 +151,10 @@ type UIBlockingStore = UIBlockingStoreState & UIBlockingStoreActions;
150
151
  * - Automatic shallow comparison for selectors
151
152
  *
152
153
  */
153
- declare const useUIBlockingStore: <T>(selector: (state: UIBlockingStore) => T) => T;
154
+ declare const useUIBlockingStore: {
155
+ (): UIBlockingStore;
156
+ <T>(selector: (state: UIBlockingStore) => T): T;
157
+ };
154
158
  declare const uiBlockingStoreApi: zustand.StoreApi<UIBlockingStore>;
155
159
 
156
160
  /**
@@ -403,59 +407,21 @@ interface UIBlockingProviderProps {
403
407
  middlewares?: ReadonlyArray<Middleware>;
404
408
  }
405
409
  /**
406
- * Provider component for isolated UI blocking state
407
- *
408
- * Use this to create an isolated store instance for:
409
- * - Server-side rendering (each request gets its own store)
410
- * - Testing (no need for beforeEach cleanup)
411
- * - Micro-frontends (isolated state per app)
412
- *
413
- * @example
414
- * ```tsx
415
- * // SSR - each request gets its own store
416
- * function App() {
417
- * return (
418
- * <UIBlockingProvider>
419
- * <MyComponent />
420
- * </UIBlockingProvider>
421
- * );
422
- * }
423
- *
424
- * // Testing - isolated store per test
425
- * function renderWithProvider(ui: ReactElement) {
426
- * return render(
427
- * <UIBlockingProvider>{ui}</UIBlockingProvider>
428
- * );
429
- * }
430
- * ```
431
- */
432
- declare function UIBlockingProvider({ children, enableDevtools, devtoolsName, middlewares, }: UIBlockingProviderProps): ReactNode;
433
- /**
434
- * Hook to access the UIBlocking store from context
435
- *
436
- * Throws an error if used outside of UIBlockingProvider.
437
- * Use useUIBlockingStoreFromContext for safe access with fallback.
438
- *
439
- * @returns The store API from the nearest UIBlockingProvider
440
- * @throws Error if used outside of UIBlockingProvider
441
- */
442
- declare function useUIBlockingContext(): StoreApi<UIBlockingStore>;
443
- /**
444
- * Hook to check if we're inside a UIBlockingProvider
445
- *
446
- * @returns true if inside UIBlockingProvider, false otherwise
410
+ * Base provider created using toolkit's createStoreProvider
411
+ * This creates isolated store instances for SSR, testing, and micro-frontends
447
412
  */
448
- declare function useIsInsideUIBlockingProvider(): boolean;
413
+ declare const useUIBlockingContext: () => StoreApi<UIBlockingStore>;
414
+ declare const useUIBlockingStoreFromContext: {
415
+ (): UIBlockingStore;
416
+ <T>(selector: (state: UIBlockingStore) => T): T;
417
+ };
418
+ declare const useIsInsideUIBlockingProvider: () => boolean;
449
419
  /**
450
- * Hook to use the UIBlocking store from context with a selector
451
- *
452
- * This is similar to useUIBlockingStore but uses the context store.
453
- * Automatically applies shallow comparison to prevent unnecessary re-renders.
420
+ * Provider component for isolated UI blocking state
454
421
  *
455
- * @param selector - Selector function to pick state from the store
456
- * @returns Selected state value
457
- * @throws Error if used outside of UIBlockingProvider
422
+ * Uses toolkit's createStoreProvider with built-in DevTools support
423
+ * and onStoreCreate callback for middleware registration.
458
424
  */
459
- declare function useUIBlockingStoreFromContext<T>(selector: (state: UIBlockingStore) => T): T;
425
+ declare function UIBlockingProvider({ children, enableDevtools, devtoolsName, middlewares, }: UIBlockingProviderProps): ReactNode;
460
426
 
461
427
  export { type AmplitudeConfig, type AnalyticsConfig, type AnalyticsEventData, type AnalyticsProvider, type BlockerConfig, type BlockerConfigTyped, type BlockerInfo, type BlockingAction, type BlockingSchedule, type ConditionalBlockerConfig, type ConfirmDialogConfig, type ConfirmableBlockerConfig, type CustomAnalyticsConfig, type DefaultScopes, type GoogleAnalyticsConfig, type Middleware, type MiddlewareContext, type MixpanelConfig, type PerformanceConfig, type ScheduledBlockerConfig, type ScopeValue, type StoredBlocker, type TypedHooks, UIBlockingProvider, type UIBlockingProviderProps, type UIBlockingStore, type UIBlockingStoreActions, type UIBlockingStoreState, type UseAsyncActionOptions, type UseConfirmableBlockerReturn, configureMiddleware, createAnalyticsMiddleware, createPerformanceMiddleware, createTypedHooks, loggerMiddleware, uiBlockingStoreApi, useAsyncAction, useBlocker, useBlockingInfo, useConditionalBlocker, useConfirmableBlocker, useIsBlocked, useIsInsideUIBlockingProvider, useScheduledBlocker, useUIBlockingContext, useUIBlockingStore, useUIBlockingStoreFromContext };
package/dist/index.js CHANGED
@@ -1,8 +1,11 @@
1
- import { createContext, useRef, useMemo, useContext, useCallback, useEffect, useState } from 'react';
2
- import { createStore, useStore } from 'zustand';
3
- import { devtools } from 'zustand/middleware';
4
- import { useShallow } from 'zustand/shallow';
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import { createStoreProvider, createShallowStore } from '@okyrychenko-dev/react-zustand-toolkit';
3
+ export { createShallowStore } from '@okyrychenko-dev/react-zustand-toolkit';
4
+ import { useStore } from 'zustand';
5
+ import 'zustand/react/shallow';
5
6
  import { jsx } from 'react/jsx-runtime';
7
+ import { useShallow } from 'zustand/shallow';
8
+ import { devtools } from 'zustand/middleware';
6
9
 
7
10
  // src/hooks/useAsyncAction/useAsyncAction.ts
8
11
 
@@ -12,13 +15,6 @@ var DEFAULT_REASON = "Unknown";
12
15
  var DEFAULT_PRIORITY = 0;
13
16
  var ASYNC_ACTION_PRIORITY = 20;
14
17
  var DEVTOOLS_NAME = "UIBlocking";
15
- function createShallowStore(storeCreator) {
16
- const storeApi = createStore(storeCreator);
17
- const useScopedStore = (selector) => {
18
- return useStore(storeApi, useShallow(selector));
19
- };
20
- return { useStore: useScopedStore, useStoreApi: storeApi };
21
- }
22
18
  function normalizeScopeToArray(scope) {
23
19
  if (typeof scope === "string") {
24
20
  return [scope];
@@ -219,44 +215,33 @@ var createUIBlockingActions = (set, get) => ({
219
215
  });
220
216
  }
221
217
  });
222
- var UIBlockingContext = createContext(null);
218
+ var {
219
+ Provider: BaseUIBlockingProvider,
220
+ useContext: useUIBlockingContext,
221
+ useContextStore: useUIBlockingStoreFromContext,
222
+ useIsInsideProvider: useIsInsideUIBlockingProvider,
223
+ useOptionalContext
224
+ } = createStoreProvider(createUIBlockingActions, "UIBlocking");
223
225
  function UIBlockingProvider({
224
226
  children,
225
227
  enableDevtools = process.env.NODE_ENV === "development",
226
228
  devtoolsName = "UIBlocking",
227
229
  middlewares = []
228
230
  }) {
229
- const middlewaresRef = useRef(middlewares);
230
- const store = useMemo(() => {
231
- const baseStore = enableDevtools ? createStore(
232
- devtools(createUIBlockingActions, {
233
- name: devtoolsName,
234
- enabled: enableDevtools
235
- })
236
- ) : createStore(createUIBlockingActions);
237
- middlewaresRef.current.forEach((mw, index) => {
238
- baseStore.getState().registerMiddleware(`provider-middleware-${index.toString()}`, mw);
231
+ const handleStoreCreate = (store) => {
232
+ middlewares.forEach((mw, index) => {
233
+ store.getState().registerMiddleware(`provider-middleware-${index.toString()}`, mw);
239
234
  });
240
- return baseStore;
241
- }, [enableDevtools, devtoolsName]);
242
- return /* @__PURE__ */ jsx(UIBlockingContext.Provider, { value: store, children });
243
- }
244
- function useUIBlockingContext() {
245
- const store = useContext(UIBlockingContext);
246
- if (!store) {
247
- throw new Error(
248
- "useUIBlockingContext must be used within UIBlockingProvider. Either wrap your app in <UIBlockingProvider> or use the global store via useUIBlockingStore."
249
- );
250
- }
251
- return store;
252
- }
253
- function useIsInsideUIBlockingProvider() {
254
- const store = useContext(UIBlockingContext);
255
- return store !== null;
256
- }
257
- function useUIBlockingStoreFromContext(selector) {
258
- const store = useUIBlockingContext();
259
- return useStore(store, useShallow(selector));
235
+ };
236
+ return /* @__PURE__ */ jsx(
237
+ BaseUIBlockingProvider,
238
+ {
239
+ enableDevtools,
240
+ devtoolsName,
241
+ onStoreCreate: handleStoreCreate,
242
+ children
243
+ }
244
+ );
260
245
  }
261
246
 
262
247
  // src/store/uiBlockingStore.config.ts
@@ -269,8 +254,11 @@ var devtoolsConfig = {
269
254
  var { useStore: useUIBlockingStore, useStoreApi: uiBlockingStoreApi } = createShallowStore(devtools(createUIBlockingActions, devtoolsConfig));
270
255
 
271
256
  // src/context/useResolvedStore.ts
257
+ function useOptionalContextStore() {
258
+ return useOptionalContext();
259
+ }
272
260
  function useResolvedStore() {
273
- const contextStore = useContext(UIBlockingContext);
261
+ const contextStore = useOptionalContextStore();
274
262
  return contextStore ?? uiBlockingStoreApi;
275
263
  }
276
264
  function useResolvedStoreWithSelector(selector) {