@datarecce/ui 0.1.27 → 0.1.29

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.
Files changed (46) hide show
  1. package/dist/{RecceCheckContext-CiG9fGRW.mjs → RecceCheckContext-PT4-g1bW.mjs} +2 -2
  2. package/dist/{RecceCheckContext-CiG9fGRW.mjs.map → RecceCheckContext-PT4-g1bW.mjs.map} +1 -1
  3. package/dist/{RecceCheckContext-tUxygNmN.js → RecceCheckContext-fAKHgsGz.js} +2 -2
  4. package/dist/{RecceCheckContext-tUxygNmN.js.map → RecceCheckContext-fAKHgsGz.js.map} +1 -1
  5. package/dist/api.d.mts +1 -1
  6. package/dist/api.js +2 -2
  7. package/dist/api.mjs +2 -2
  8. package/dist/{components-Chaffojm.js → components-B9F5oJbK.js} +277 -242
  9. package/dist/components-B9F5oJbK.js.map +1 -0
  10. package/dist/{components-DoLZeY_e.mjs → components-gDC1ucjo.mjs} +277 -242
  11. package/dist/components-gDC1ucjo.mjs.map +1 -0
  12. package/dist/components.d.mts +1 -1
  13. package/dist/components.js +4 -4
  14. package/dist/components.mjs +4 -4
  15. package/dist/hooks-4hRUjy9Q.mjs +34 -0
  16. package/dist/hooks-4hRUjy9Q.mjs.map +1 -0
  17. package/dist/hooks-C2jUJ9EN.js +40 -0
  18. package/dist/hooks-C2jUJ9EN.js.map +1 -0
  19. package/dist/hooks.d.mts +1 -1
  20. package/dist/hooks.js +11 -11
  21. package/dist/hooks.mjs +3 -3
  22. package/dist/{index-BbISJwin.d.mts → index-Bv5R8iLo.d.mts} +70 -70
  23. package/dist/index-Bv5R8iLo.d.mts.map +1 -0
  24. package/dist/index-CUtFlKOo.d.ts.map +1 -1
  25. package/dist/index.d.mts +1 -1
  26. package/dist/index.js +13 -13
  27. package/dist/index.mjs +5 -5
  28. package/dist/{state-DyHCt6IJ.mjs → state-CELzQ0tM.mjs} +183 -20
  29. package/dist/state-CELzQ0tM.mjs.map +1 -0
  30. package/dist/{state-FkYREAs-.js → state-CemiRRon.js} +223 -18
  31. package/dist/state-CemiRRon.js.map +1 -0
  32. package/dist/types.d.mts +1 -1
  33. package/dist/{version-BGNaeW6k.js → version-bWg7XwOu.js} +2 -2
  34. package/dist/{version-BGNaeW6k.js.map → version-bWg7XwOu.js.map} +1 -1
  35. package/dist/{version-Dav28qEz.mjs → version-paZ9esBk.mjs} +2 -2
  36. package/dist/{version-Dav28qEz.mjs.map → version-paZ9esBk.mjs.map} +1 -1
  37. package/package.json +1 -1
  38. package/dist/components-Chaffojm.js.map +0 -1
  39. package/dist/components-DoLZeY_e.mjs.map +0 -1
  40. package/dist/hooks-BxV6qN9q.mjs +0 -233
  41. package/dist/hooks-BxV6qN9q.mjs.map +0 -1
  42. package/dist/hooks-CriUVJO1.js +0 -287
  43. package/dist/hooks-CriUVJO1.js.map +0 -1
  44. package/dist/index-BbISJwin.d.mts.map +0 -1
  45. package/dist/state-DyHCt6IJ.mjs.map +0 -1
  46. package/dist/state-FkYREAs-.js.map +0 -1
@@ -1,233 +0,0 @@
1
- "use client"
2
- import { F as RecceActionContextProvider, _t as RecceInstanceInfoProvider, st as LineageGraphContextProvider } from "./state-DyHCt6IJ.mjs";
3
- import { a as RecceShareStateContextProvider, c as RowCountStateContextProvider, s as RecceQueryContextProvider, t as RecceCheckContextProvider } from "./RecceCheckContext-CiG9fGRW.mjs";
4
- import React, { createContext, useCallback, useContext, useMemo } from "react";
5
- import { jsx } from "react/jsx-runtime";
6
- import { useParams, usePathname as usePathname$1, useRouter, useSearchParams } from "next/navigation";
7
-
8
- //#region recce-source/js/src/lib/hooks/RecceContextProvider.tsx
9
- /**
10
- * Main context provider for Recce application.
11
- *
12
- * For custom API configuration (e.g., recce-cloud), wrap this provider
13
- * with ApiConfigProvider:
14
- *
15
- * ```tsx
16
- * <ApiConfigProvider
17
- * apiPrefix="/api/v2/sessions/abc123"
18
- * authToken="eyJ..."
19
- * >
20
- * <RecceContextProvider>
21
- * {children}
22
- * </RecceContextProvider>
23
- * </ApiConfigProvider>
24
- * ```
25
- *
26
- * When used without ApiConfigProvider (OSS mode), hooks will use
27
- * the default axios client with standard /api/* endpoints.
28
- */
29
- function RecceContextProvider({ children }) {
30
- return /* @__PURE__ */ jsx(RecceInstanceInfoProvider, { children: /* @__PURE__ */ jsx(RecceShareStateContextProvider, { children: /* @__PURE__ */ jsx(RecceQueryContextProvider, { children: /* @__PURE__ */ jsx(LineageGraphContextProvider, { children: /* @__PURE__ */ jsx(RowCountStateContextProvider, { children: /* @__PURE__ */ jsx(RecceActionContextProvider, { children: /* @__PURE__ */ jsx(RecceCheckContextProvider, { children }) }) }) }) }) }) });
31
- }
32
-
33
- //#endregion
34
- //#region src/lib/hooks/RouteConfigContext.ts
35
- const defaultConfig = { basePath: "" };
36
- const RouteConfigContext = createContext(null);
37
- /**
38
- * Provider for route configuration.
39
- *
40
- * Wrap your application (or RecceContextProvider) with this provider
41
- * to configure path prefixes for navigation.
42
- *
43
- * @example
44
- * // In recce-cloud
45
- * <RouteConfigProvider basePath={`/oss/${sessionId}`}>
46
- * <RecceContextProvider>
47
- * {children}
48
- * </RecceContextProvider>
49
- * </RouteConfigProvider>
50
- */
51
- function RouteConfigProvider({ children, basePath = defaultConfig.basePath }) {
52
- const resolvePath = useCallback((path) => {
53
- if (!basePath) return path;
54
- if (path.startsWith(basePath)) return path;
55
- if (path.match(/^https?:\/\//)) return path;
56
- if (path.startsWith("#")) return path;
57
- return `${basePath.endsWith("/") ? basePath.slice(0, -1) : basePath}${path.startsWith("/") ? path : `/${path}`}`;
58
- }, [basePath]);
59
- const contextValue = useMemo(() => ({
60
- basePath,
61
- resolvePath
62
- }), [basePath, resolvePath]);
63
- return React.createElement(RouteConfigContext.Provider, { value: contextValue }, children);
64
- }
65
- const defaultRouteConfigContext = {
66
- basePath: "",
67
- resolvePath: (path) => path
68
- };
69
- /**
70
- * Hook to access route configuration.
71
- *
72
- * When used outside RouteConfigProvider, returns default config
73
- * (for OSS backward compatibility).
74
- *
75
- * @returns RouteConfigContextType with basePath and resolvePath function
76
- */
77
- function useRouteConfig() {
78
- return useContext(RouteConfigContext) ?? defaultRouteConfigContext;
79
- }
80
- /**
81
- * Safe hook that returns null if context not available.
82
- * Useful for components that need to detect if RouteConfigProvider is present.
83
- */
84
- function useRouteConfigSafe() {
85
- return useContext(RouteConfigContext);
86
- }
87
-
88
- //#endregion
89
- //#region src/lib/hooks/useAppRouter.ts
90
- /**
91
- * useAppRouter - Navigation utilities for Next.js App Router with RouteConfig support
92
- *
93
- * This is a custom version that wraps the OSS useAppRouter to add
94
- * RouteConfigContext support for path prefixing in recce-cloud.
95
- *
96
- * The key difference from OSS:
97
- * - setLocation() automatically prefixes paths with the configured basePath
98
- * - This allows OSS components to use setLocation("/query") while
99
- * recce-cloud can configure basePath="/oss/abc123" to get "/oss/abc123/query"
100
- */
101
- /**
102
- * Hook that provides Wouter-compatible location API using Next.js App Router
103
- * with RouteConfigContext support for path prefixing.
104
- *
105
- * NOTE: This returns only the pathname (not search params) to avoid
106
- * triggering Suspense boundaries on every navigation.
107
- *
108
- * @returns [pathname, setLocation] tuple similar to Wouter's useLocation
109
- *
110
- * @example
111
- * const [location, setLocation] = useAppLocation();
112
- * setLocation("/checks?id=123"); // In cloud mode with basePath="/oss/abc123"
113
- * // navigates to "/oss/abc123/checks?id=123"
114
- */
115
- function useAppLocation() {
116
- const router = useRouter();
117
- const pathname = usePathname$1();
118
- const { resolvePath } = useRouteConfig();
119
- return [pathname, useCallback((to, options) => {
120
- const [pathPart, queryPart] = to.split("?");
121
- const resolvedPath = resolvePath(pathPart);
122
- const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;
123
- if (options?.replace) router.replace(fullPath, { scroll: options?.scroll ?? true });
124
- else router.push(fullPath, { scroll: options?.scroll ?? true });
125
- }, [router, resolvePath])];
126
- }
127
- /**
128
- * Hook that includes search params in the location string.
129
- * Also supports RouteConfigContext path prefixing.
130
- *
131
- * WARNING: This hook uses useSearchParams() which triggers Suspense.
132
- * Only use this in components that are wrapped in a <Suspense> boundary,
133
- * or in leaf components where suspension is acceptable.
134
- *
135
- * @returns [fullLocation, setLocation] tuple with search params included
136
- */
137
- function useAppLocationWithSearch() {
138
- const router = useRouter();
139
- const pathname = usePathname$1();
140
- const searchParams = useSearchParams();
141
- const { resolvePath } = useRouteConfig();
142
- return [useMemo(() => {
143
- const search = searchParams?.toString();
144
- return search ? `${pathname}?${search}` : pathname;
145
- }, [pathname, searchParams]), useCallback((to, options) => {
146
- const [pathPart, queryPart] = to.split("?");
147
- const resolvedPath = resolvePath(pathPart);
148
- const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;
149
- if (options?.replace) router.replace(fullPath, { scroll: options?.scroll ?? true });
150
- else router.push(fullPath, { scroll: options?.scroll ?? true });
151
- }, [router, resolvePath])];
152
- }
153
- /**
154
- * Hook to check if current path matches a pattern
155
- * Similar to Wouter's useRoute
156
- *
157
- * @param pattern - The route pattern to match (e.g., "/checks/:checkId")
158
- * @returns [isMatch, params] tuple
159
- *
160
- * @example
161
- * const [isMatch, params] = useAppRoute("/checks/:checkId");
162
- * if (isMatch) {
163
- * console.log(params.checkId); // "abc-123"
164
- * }
165
- */
166
- function useAppRoute(pattern) {
167
- const pathname = usePathname$1();
168
- const params = useParams();
169
- return [useMemo(() => {
170
- const regexPattern = pattern.replace(/:\w+/g, "([^/]+)").replace(/\*/g, ".*");
171
- return (/* @__PURE__ */ new RegExp(`^${regexPattern}$`)).test(pathname);
172
- }, [pattern, pathname]), useMemo(() => {
173
- if (!params) return {};
174
- return Object.fromEntries(Object.entries(params).map(([key, value]) => [key, Array.isArray(value) ? value.join("/") : value]));
175
- }, [params])];
176
- }
177
- /**
178
- * Imperative navigation function for use outside React components
179
- * Use sparingly - prefer useAppLocation hook in components
180
- *
181
- * NOTE: This function does NOT support RouteConfigContext because
182
- * it's used outside of React component tree. If you need path prefixing,
183
- * use useAppLocation hook instead.
184
- *
185
- * @example
186
- * // In an event handler or utility function
187
- * import { navigateTo } from "@/lib/hooks/useAppRouter";
188
- * navigateTo("/checks?id=123");
189
- */
190
- function navigateTo(path, replace = false) {
191
- if (typeof window !== "undefined") {
192
- if (replace) window.history.replaceState(null, "", path);
193
- else window.history.pushState(null, "", path);
194
- window.dispatchEvent(new PopStateEvent("popstate"));
195
- }
196
- }
197
- /**
198
- * Hook for programmatic navigation with more options
199
- * Provides direct access to Next.js router methods with RouteConfigContext support
200
- *
201
- * NOTE: Does not include searchParams to avoid Suspense.
202
- * Use useSearchParams() directly in components that need it.
203
- */
204
- function useAppNavigation() {
205
- const router = useRouter();
206
- const pathname = usePathname$1();
207
- const params = useParams();
208
- const { resolvePath } = useRouteConfig();
209
- return {
210
- pathname,
211
- params,
212
- push: useCallback((href, options) => {
213
- const [pathPart, queryPart] = href.split("?");
214
- const resolvedPath = resolvePath(pathPart);
215
- const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;
216
- router.push(fullPath, options);
217
- }, [router, resolvePath]),
218
- replace: useCallback((href, options) => {
219
- const [pathPart, queryPart] = href.split("?");
220
- const resolvedPath = resolvePath(pathPart);
221
- const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;
222
- router.replace(fullPath, options);
223
- }, [router, resolvePath]),
224
- back: router.back,
225
- forward: router.forward,
226
- refresh: router.refresh,
227
- prefetch: router.prefetch
228
- };
229
- }
230
-
231
- //#endregion
232
- export { useAppRoute as a, useRouteConfigSafe as c, useAppNavigation as i, RecceContextProvider as l, useAppLocation as n, RouteConfigProvider as o, useAppLocationWithSearch as r, useRouteConfig as s, navigateTo as t };
233
- //# sourceMappingURL=hooks-BxV6qN9q.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hooks-BxV6qN9q.mjs","names":["defaultConfig: RouteConfig","contextValue: RouteConfigContextType","defaultRouteConfigContext: RouteConfigContextType","usePathname"],"sources":["../recce-source/js/src/lib/hooks/RecceContextProvider.tsx","../src/lib/hooks/RouteConfigContext.ts","../src/lib/hooks/useAppRouter.ts"],"sourcesContent":["import React from \"react\";\nimport { LineageGraphContextProvider } from \"./LineageGraphContext\";\nimport { RecceActionContextProvider } from \"./RecceActionContext\";\nimport { RecceCheckContextProvider } from \"./RecceCheckContext\";\nimport { RecceInstanceInfoProvider } from \"./RecceInstanceContext\";\nimport {\n RecceQueryContextProvider,\n RowCountStateContextProvider,\n} from \"./RecceQueryContext\";\nimport { RecceShareStateContextProvider } from \"./RecceShareStateContext\";\n\ninterface RecceContextProps {\n children: React.ReactNode;\n}\n\n/**\n * Main context provider for Recce application.\n *\n * For custom API configuration (e.g., recce-cloud), wrap this provider\n * with ApiConfigProvider:\n *\n * ```tsx\n * <ApiConfigProvider\n * apiPrefix=\"/api/v2/sessions/abc123\"\n * authToken=\"eyJ...\"\n * >\n * <RecceContextProvider>\n * {children}\n * </RecceContextProvider>\n * </ApiConfigProvider>\n * ```\n *\n * When used without ApiConfigProvider (OSS mode), hooks will use\n * the default axios client with standard /api/* endpoints.\n */\nexport default function RecceContextProvider({ children }: RecceContextProps) {\n return (\n <RecceInstanceInfoProvider>\n <RecceShareStateContextProvider>\n <RecceQueryContextProvider>\n <LineageGraphContextProvider>\n <RowCountStateContextProvider>\n <RecceActionContextProvider>\n <RecceCheckContextProvider>\n {children}\n </RecceCheckContextProvider>\n </RecceActionContextProvider>\n </RowCountStateContextProvider>\n </LineageGraphContextProvider>\n </RecceQueryContextProvider>\n </RecceShareStateContextProvider>\n </RecceInstanceInfoProvider>\n );\n}\n","\"use client\";\n\nimport React, { createContext, useCallback, useContext, useMemo } from \"react\";\n\n/**\n * Route Configuration for path prefix customization.\n *\n * This context allows recce-cloud to configure a base path prefix\n * for all navigation within OSS components.\n *\n * Default behavior (OSS):\n * - basePath: \"\" (uses absolute paths like /query, /checks)\n *\n * Cloud usage example:\n * - basePath: \"/oss/abc123\" or \"/preview/abc123\"\n * - Navigation to \"/query\" becomes \"/oss/abc123/query\"\n */\n\nexport interface RouteConfig {\n /**\n * Base path prefix for navigation.\n * For OSS: \"\" (empty string, uses absolute paths like /query)\n * For Cloud: \"/oss/<sessionId>\" or \"/preview/<sessionId>\"\n */\n basePath: string;\n}\n\nexport interface RouteConfigContextType extends RouteConfig {\n /**\n * Resolves a path with the base path prefix.\n * @param path - The path to resolve (e.g., \"/query\")\n * @returns The resolved path (e.g., \"/oss/abc123/query\")\n */\n resolvePath: (path: string) => string;\n}\n\nconst defaultConfig: RouteConfig = {\n basePath: \"\",\n};\n\nconst RouteConfigContext = createContext<RouteConfigContextType | null>(null);\n\ninterface RouteConfigProviderProps extends Partial<RouteConfig> {\n children: React.ReactNode;\n}\n\n/**\n * Provider for route configuration.\n *\n * Wrap your application (or RecceContextProvider) with this provider\n * to configure path prefixes for navigation.\n *\n * @example\n * // In recce-cloud\n * <RouteConfigProvider basePath={`/oss/${sessionId}`}>\n * <RecceContextProvider>\n * {children}\n * </RecceContextProvider>\n * </RouteConfigProvider>\n */\nexport function RouteConfigProvider({\n children,\n basePath = defaultConfig.basePath,\n}: RouteConfigProviderProps) {\n const resolvePath = useCallback(\n (path: string): string => {\n // If no basePath configured, return path as-is (OSS mode)\n if (!basePath) {\n return path;\n }\n\n // Handle paths that already start with the basePath (avoid double-prefixing)\n if (path.startsWith(basePath)) {\n return path;\n }\n\n // Handle absolute URLs (http://, https://, etc.) - don't prefix\n if (path.match(/^https?:\\/\\//)) {\n return path;\n }\n\n // Handle hash-only paths - don't prefix\n if (path.startsWith(\"#\")) {\n return path;\n }\n\n // Ensure proper joining (no double slashes)\n const cleanBasePath = basePath.endsWith(\"/\")\n ? basePath.slice(0, -1)\n : basePath;\n const cleanPath = path.startsWith(\"/\") ? path : `/${path}`;\n\n return `${cleanBasePath}${cleanPath}`;\n },\n [basePath],\n );\n\n const contextValue: RouteConfigContextType = useMemo(\n () => ({\n basePath,\n resolvePath,\n }),\n [basePath, resolvePath],\n );\n\n return React.createElement(\n RouteConfigContext.Provider,\n { value: contextValue },\n children,\n );\n}\n\n// Default context for OSS mode (no prefix)\nconst defaultRouteConfigContext: RouteConfigContextType = {\n basePath: \"\",\n resolvePath: (path: string) => path,\n};\n\n/**\n * Hook to access route configuration.\n *\n * When used outside RouteConfigProvider, returns default config\n * (for OSS backward compatibility).\n *\n * @returns RouteConfigContextType with basePath and resolvePath function\n */\nexport function useRouteConfig(): RouteConfigContextType {\n const context = useContext(RouteConfigContext);\n // Return default config if outside provider (OSS mode)\n return context ?? defaultRouteConfigContext;\n}\n\n/**\n * Safe hook that returns null if context not available.\n * Useful for components that need to detect if RouteConfigProvider is present.\n */\nexport function useRouteConfigSafe(): RouteConfigContextType | null {\n return useContext(RouteConfigContext);\n}\n","/**\n * useAppRouter - Navigation utilities for Next.js App Router with RouteConfig support\n *\n * This is a custom version that wraps the OSS useAppRouter to add\n * RouteConfigContext support for path prefixing in recce-cloud.\n *\n * The key difference from OSS:\n * - setLocation() automatically prefixes paths with the configured basePath\n * - This allows OSS components to use setLocation(\"/query\") while\n * recce-cloud can configure basePath=\"/oss/abc123\" to get \"/oss/abc123/query\"\n */\n\n\"use client\";\n\nimport {\n useParams,\n usePathname,\n useRouter,\n useSearchParams,\n} from \"next/navigation\";\nimport { useCallback, useMemo } from \"react\";\nimport { useRouteConfig } from \"./RouteConfigContext\";\n\ninterface NavigateOptions {\n replace?: boolean;\n scroll?: boolean;\n}\n\n/**\n * Hook that provides Wouter-compatible location API using Next.js App Router\n * with RouteConfigContext support for path prefixing.\n *\n * NOTE: This returns only the pathname (not search params) to avoid\n * triggering Suspense boundaries on every navigation.\n *\n * @returns [pathname, setLocation] tuple similar to Wouter's useLocation\n *\n * @example\n * const [location, setLocation] = useAppLocation();\n * setLocation(\"/checks?id=123\"); // In cloud mode with basePath=\"/oss/abc123\"\n * // navigates to \"/oss/abc123/checks?id=123\"\n */\nexport function useAppLocation(): [\n string,\n (to: string, options?: NavigateOptions) => void,\n] {\n const router = useRouter();\n const pathname = usePathname();\n const { resolvePath } = useRouteConfig();\n\n // Navigation function compatible with Wouter's setLocation\n // Automatically applies basePath prefix from RouteConfigContext\n const setLocation = useCallback(\n (to: string, options?: NavigateOptions) => {\n // Separate path and query string for proper handling\n const [pathPart, queryPart] = to.split(\"?\");\n const resolvedPath = resolvePath(pathPart);\n const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;\n\n if (options?.replace) {\n router.replace(fullPath, { scroll: options?.scroll ?? true });\n } else {\n router.push(fullPath, { scroll: options?.scroll ?? true });\n }\n },\n [router, resolvePath],\n );\n\n return [pathname, setLocation];\n}\n\n/**\n * Hook that includes search params in the location string.\n * Also supports RouteConfigContext path prefixing.\n *\n * WARNING: This hook uses useSearchParams() which triggers Suspense.\n * Only use this in components that are wrapped in a <Suspense> boundary,\n * or in leaf components where suspension is acceptable.\n *\n * @returns [fullLocation, setLocation] tuple with search params included\n */\nexport function useAppLocationWithSearch(): [\n string,\n (to: string, options?: NavigateOptions) => void,\n] {\n const router = useRouter();\n const pathname = usePathname();\n const searchParams = useSearchParams();\n const { resolvePath } = useRouteConfig();\n\n // Construct full location string including search params\n const location = useMemo(() => {\n const search = searchParams?.toString();\n return search ? `${pathname}?${search}` : pathname;\n }, [pathname, searchParams]);\n\n // Navigation function with RouteConfigContext support\n const setLocation = useCallback(\n (to: string, options?: NavigateOptions) => {\n const [pathPart, queryPart] = to.split(\"?\");\n const resolvedPath = resolvePath(pathPart);\n const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;\n\n if (options?.replace) {\n router.replace(fullPath, { scroll: options?.scroll ?? true });\n } else {\n router.push(fullPath, { scroll: options?.scroll ?? true });\n }\n },\n [router, resolvePath],\n );\n\n return [location, setLocation];\n}\n\n/**\n * Hook to check if current path matches a pattern\n * Similar to Wouter's useRoute\n *\n * @param pattern - The route pattern to match (e.g., \"/checks/:checkId\")\n * @returns [isMatch, params] tuple\n *\n * @example\n * const [isMatch, params] = useAppRoute(\"/checks/:checkId\");\n * if (isMatch) {\n * console.log(params.checkId); // \"abc-123\"\n * }\n */\nexport function useAppRoute(\n pattern: string,\n): [boolean, Record<string, string>] {\n const pathname = usePathname();\n const params = useParams();\n\n const isMatch = useMemo(() => {\n // Convert Next.js dynamic route pattern to regex\n // /checks/[checkId] -> /checks/:checkId -> /checks/([^/]+)\n const regexPattern = pattern\n .replace(/:\\w+/g, \"([^/]+)\") // :param -> capture group\n .replace(/\\*/g, \".*\"); // * -> wildcard\n\n const regex = new RegExp(`^${regexPattern}$`);\n return regex.test(pathname);\n }, [pattern, pathname]);\n\n // Convert Next.js params to plain object\n const paramsObj = useMemo(() => {\n if (!params) return {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => [\n key,\n Array.isArray(value) ? value.join(\"/\") : value,\n ]),\n );\n }, [params]);\n\n return [isMatch, paramsObj as Record<string, string>];\n}\n\n/**\n * Imperative navigation function for use outside React components\n * Use sparingly - prefer useAppLocation hook in components\n *\n * NOTE: This function does NOT support RouteConfigContext because\n * it's used outside of React component tree. If you need path prefixing,\n * use useAppLocation hook instead.\n *\n * @example\n * // In an event handler or utility function\n * import { navigateTo } from \"@/lib/hooks/useAppRouter\";\n * navigateTo(\"/checks?id=123\");\n */\nexport function navigateTo(path: string, replace = false): void {\n if (typeof window !== \"undefined\") {\n if (replace) {\n window.history.replaceState(null, \"\", path);\n } else {\n window.history.pushState(null, \"\", path);\n }\n // Trigger Next.js to recognize the navigation\n window.dispatchEvent(new PopStateEvent(\"popstate\"));\n }\n}\n\n/**\n * Hook for programmatic navigation with more options\n * Provides direct access to Next.js router methods with RouteConfigContext support\n *\n * NOTE: Does not include searchParams to avoid Suspense.\n * Use useSearchParams() directly in components that need it.\n */\nexport function useAppNavigation() {\n const router = useRouter();\n const pathname = usePathname();\n const params = useParams();\n const { resolvePath } = useRouteConfig();\n\n // Wrap router.push and router.replace with path resolution\n const push = useCallback(\n (href: string, options?: { scroll?: boolean }) => {\n const [pathPart, queryPart] = href.split(\"?\");\n const resolvedPath = resolvePath(pathPart);\n const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;\n router.push(fullPath, options);\n },\n [router, resolvePath],\n );\n\n const replace = useCallback(\n (href: string, options?: { scroll?: boolean }) => {\n const [pathPart, queryPart] = href.split(\"?\");\n const resolvedPath = resolvePath(pathPart);\n const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;\n router.replace(fullPath, options);\n },\n [router, resolvePath],\n );\n\n return {\n /** Current pathname */\n pathname,\n /** Current route params */\n params: params as Record<string, string>,\n /** Navigate to a new path (with RouteConfigContext support) */\n push,\n /** Replace current history entry (with RouteConfigContext support) */\n replace,\n /** Go back in history */\n back: router.back,\n /** Go forward in history */\n forward: router.forward,\n /** Refresh the current route */\n refresh: router.refresh,\n /** Prefetch a route for faster navigation */\n prefetch: router.prefetch,\n };\n}\n\n// Re-export Next.js hooks for convenience\nexport { useRouter, usePathname, useParams, useSearchParams };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAwB,qBAAqB,EAAE,YAA+B;AAC5E,QACE,oBAAC,uCACC,oBAAC,4CACC,oBAAC,uCACC,oBAAC,yCACC,oBAAC,0CACC,oBAAC,wCACC,oBAAC,6BACE,WACyB,GACD,GACA,GACH,GACJ,GACG,GACP;;;;;ACfhC,MAAMA,gBAA6B,EACjC,UAAU,IACX;AAED,MAAM,qBAAqB,cAA6C,KAAK;;;;;;;;;;;;;;;AAoB7E,SAAgB,oBAAoB,EAClC,UACA,WAAW,cAAc,YACE;CAC3B,MAAM,cAAc,aACjB,SAAyB;AAExB,MAAI,CAAC,SACH,QAAO;AAIT,MAAI,KAAK,WAAW,SAAS,CAC3B,QAAO;AAIT,MAAI,KAAK,MAAM,eAAe,CAC5B,QAAO;AAIT,MAAI,KAAK,WAAW,IAAI,CACtB,QAAO;AAST,SAAO,GALe,SAAS,SAAS,IAAI,GACxC,SAAS,MAAM,GAAG,GAAG,GACrB,WACc,KAAK,WAAW,IAAI,GAAG,OAAO,IAAI;IAItD,CAAC,SAAS,C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;GAC1C,MAAM,WAAW,YAAY,GAAG,aAAa,GAAG,cAAc;AAC9D,UAAO,KAAK,UAAU,QAAQ;KAEhC,CAAC,QAAQ,YAAY,CACtB;EAoBC,SAlBc,aACb,MAAc,YAAmC;GAChD,MAAM,CAAC,UAAU,aAAa,KAAK,MAAM,IAAI;GAC7C,MAAM,eAAe,YAAY,SAAS;GAC1C,MAAM,WAAW,YAAY,GAAG,aAAa,GAAG,cAAc;AAC9D,UAAO,QAAQ,UAAU,QAAQ;KAEnC,CAAC,QAAQ,YAAY,CACtB;EAYC,MAAM,OAAO;EAEb,SAAS,OAAO;EAEhB,SAAS,OAAO;EAEhB,UAAU,OAAO;EAClB"}
@@ -1,287 +0,0 @@
1
- "use client"
2
- const require_state = require('./state-FkYREAs-.js');
3
- const require_RecceCheckContext = require('./RecceCheckContext-tUxygNmN.js');
4
- let react = require("react");
5
- react = require_state.__toESM(react);
6
- let react_jsx_runtime = require("react/jsx-runtime");
7
- let next_navigation = require("next/navigation");
8
-
9
- //#region recce-source/js/src/lib/hooks/RecceContextProvider.tsx
10
- /**
11
- * Main context provider for Recce application.
12
- *
13
- * For custom API configuration (e.g., recce-cloud), wrap this provider
14
- * with ApiConfigProvider:
15
- *
16
- * ```tsx
17
- * <ApiConfigProvider
18
- * apiPrefix="/api/v2/sessions/abc123"
19
- * authToken="eyJ..."
20
- * >
21
- * <RecceContextProvider>
22
- * {children}
23
- * </RecceContextProvider>
24
- * </ApiConfigProvider>
25
- * ```
26
- *
27
- * When used without ApiConfigProvider (OSS mode), hooks will use
28
- * the default axios client with standard /api/* endpoints.
29
- */
30
- function RecceContextProvider({ children }) {
31
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_state.RecceInstanceInfoProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_RecceCheckContext.RecceShareStateContextProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_RecceCheckContext.RecceQueryContextProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_state.LineageGraphContextProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_RecceCheckContext.RowCountStateContextProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_state.RecceActionContextProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_RecceCheckContext.RecceCheckContextProvider, { children }) }) }) }) }) }) });
32
- }
33
-
34
- //#endregion
35
- //#region src/lib/hooks/RouteConfigContext.ts
36
- const defaultConfig = { basePath: "" };
37
- const RouteConfigContext = (0, react.createContext)(null);
38
- /**
39
- * Provider for route configuration.
40
- *
41
- * Wrap your application (or RecceContextProvider) with this provider
42
- * to configure path prefixes for navigation.
43
- *
44
- * @example
45
- * // In recce-cloud
46
- * <RouteConfigProvider basePath={`/oss/${sessionId}`}>
47
- * <RecceContextProvider>
48
- * {children}
49
- * </RecceContextProvider>
50
- * </RouteConfigProvider>
51
- */
52
- function RouteConfigProvider({ children, basePath = defaultConfig.basePath }) {
53
- const resolvePath = (0, react.useCallback)((path) => {
54
- if (!basePath) return path;
55
- if (path.startsWith(basePath)) return path;
56
- if (path.match(/^https?:\/\//)) return path;
57
- if (path.startsWith("#")) return path;
58
- return `${basePath.endsWith("/") ? basePath.slice(0, -1) : basePath}${path.startsWith("/") ? path : `/${path}`}`;
59
- }, [basePath]);
60
- const contextValue = (0, react.useMemo)(() => ({
61
- basePath,
62
- resolvePath
63
- }), [basePath, resolvePath]);
64
- return react.default.createElement(RouteConfigContext.Provider, { value: contextValue }, children);
65
- }
66
- const defaultRouteConfigContext = {
67
- basePath: "",
68
- resolvePath: (path) => path
69
- };
70
- /**
71
- * Hook to access route configuration.
72
- *
73
- * When used outside RouteConfigProvider, returns default config
74
- * (for OSS backward compatibility).
75
- *
76
- * @returns RouteConfigContextType with basePath and resolvePath function
77
- */
78
- function useRouteConfig() {
79
- return (0, react.useContext)(RouteConfigContext) ?? defaultRouteConfigContext;
80
- }
81
- /**
82
- * Safe hook that returns null if context not available.
83
- * Useful for components that need to detect if RouteConfigProvider is present.
84
- */
85
- function useRouteConfigSafe() {
86
- return (0, react.useContext)(RouteConfigContext);
87
- }
88
-
89
- //#endregion
90
- //#region src/lib/hooks/useAppRouter.ts
91
- /**
92
- * useAppRouter - Navigation utilities for Next.js App Router with RouteConfig support
93
- *
94
- * This is a custom version that wraps the OSS useAppRouter to add
95
- * RouteConfigContext support for path prefixing in recce-cloud.
96
- *
97
- * The key difference from OSS:
98
- * - setLocation() automatically prefixes paths with the configured basePath
99
- * - This allows OSS components to use setLocation("/query") while
100
- * recce-cloud can configure basePath="/oss/abc123" to get "/oss/abc123/query"
101
- */
102
- /**
103
- * Hook that provides Wouter-compatible location API using Next.js App Router
104
- * with RouteConfigContext support for path prefixing.
105
- *
106
- * NOTE: This returns only the pathname (not search params) to avoid
107
- * triggering Suspense boundaries on every navigation.
108
- *
109
- * @returns [pathname, setLocation] tuple similar to Wouter's useLocation
110
- *
111
- * @example
112
- * const [location, setLocation] = useAppLocation();
113
- * setLocation("/checks?id=123"); // In cloud mode with basePath="/oss/abc123"
114
- * // navigates to "/oss/abc123/checks?id=123"
115
- */
116
- function useAppLocation() {
117
- const router = (0, next_navigation.useRouter)();
118
- const pathname = (0, next_navigation.usePathname)();
119
- const { resolvePath } = useRouteConfig();
120
- return [pathname, (0, react.useCallback)((to, options) => {
121
- const [pathPart, queryPart] = to.split("?");
122
- const resolvedPath = resolvePath(pathPart);
123
- const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;
124
- if (options?.replace) router.replace(fullPath, { scroll: options?.scroll ?? true });
125
- else router.push(fullPath, { scroll: options?.scroll ?? true });
126
- }, [router, resolvePath])];
127
- }
128
- /**
129
- * Hook that includes search params in the location string.
130
- * Also supports RouteConfigContext path prefixing.
131
- *
132
- * WARNING: This hook uses useSearchParams() which triggers Suspense.
133
- * Only use this in components that are wrapped in a <Suspense> boundary,
134
- * or in leaf components where suspension is acceptable.
135
- *
136
- * @returns [fullLocation, setLocation] tuple with search params included
137
- */
138
- function useAppLocationWithSearch() {
139
- const router = (0, next_navigation.useRouter)();
140
- const pathname = (0, next_navigation.usePathname)();
141
- const searchParams = (0, next_navigation.useSearchParams)();
142
- const { resolvePath } = useRouteConfig();
143
- return [(0, react.useMemo)(() => {
144
- const search = searchParams?.toString();
145
- return search ? `${pathname}?${search}` : pathname;
146
- }, [pathname, searchParams]), (0, react.useCallback)((to, options) => {
147
- const [pathPart, queryPart] = to.split("?");
148
- const resolvedPath = resolvePath(pathPart);
149
- const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;
150
- if (options?.replace) router.replace(fullPath, { scroll: options?.scroll ?? true });
151
- else router.push(fullPath, { scroll: options?.scroll ?? true });
152
- }, [router, resolvePath])];
153
- }
154
- /**
155
- * Hook to check if current path matches a pattern
156
- * Similar to Wouter's useRoute
157
- *
158
- * @param pattern - The route pattern to match (e.g., "/checks/:checkId")
159
- * @returns [isMatch, params] tuple
160
- *
161
- * @example
162
- * const [isMatch, params] = useAppRoute("/checks/:checkId");
163
- * if (isMatch) {
164
- * console.log(params.checkId); // "abc-123"
165
- * }
166
- */
167
- function useAppRoute(pattern) {
168
- const pathname = (0, next_navigation.usePathname)();
169
- const params = (0, next_navigation.useParams)();
170
- return [(0, react.useMemo)(() => {
171
- const regexPattern = pattern.replace(/:\w+/g, "([^/]+)").replace(/\*/g, ".*");
172
- return (/* @__PURE__ */ new RegExp(`^${regexPattern}$`)).test(pathname);
173
- }, [pattern, pathname]), (0, react.useMemo)(() => {
174
- if (!params) return {};
175
- return Object.fromEntries(Object.entries(params).map(([key, value]) => [key, Array.isArray(value) ? value.join("/") : value]));
176
- }, [params])];
177
- }
178
- /**
179
- * Imperative navigation function for use outside React components
180
- * Use sparingly - prefer useAppLocation hook in components
181
- *
182
- * NOTE: This function does NOT support RouteConfigContext because
183
- * it's used outside of React component tree. If you need path prefixing,
184
- * use useAppLocation hook instead.
185
- *
186
- * @example
187
- * // In an event handler or utility function
188
- * import { navigateTo } from "@/lib/hooks/useAppRouter";
189
- * navigateTo("/checks?id=123");
190
- */
191
- function navigateTo(path, replace = false) {
192
- if (typeof window !== "undefined") {
193
- if (replace) window.history.replaceState(null, "", path);
194
- else window.history.pushState(null, "", path);
195
- window.dispatchEvent(new PopStateEvent("popstate"));
196
- }
197
- }
198
- /**
199
- * Hook for programmatic navigation with more options
200
- * Provides direct access to Next.js router methods with RouteConfigContext support
201
- *
202
- * NOTE: Does not include searchParams to avoid Suspense.
203
- * Use useSearchParams() directly in components that need it.
204
- */
205
- function useAppNavigation() {
206
- const router = (0, next_navigation.useRouter)();
207
- const pathname = (0, next_navigation.usePathname)();
208
- const params = (0, next_navigation.useParams)();
209
- const { resolvePath } = useRouteConfig();
210
- return {
211
- pathname,
212
- params,
213
- push: (0, react.useCallback)((href, options) => {
214
- const [pathPart, queryPart] = href.split("?");
215
- const resolvedPath = resolvePath(pathPart);
216
- const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;
217
- router.push(fullPath, options);
218
- }, [router, resolvePath]),
219
- replace: (0, react.useCallback)((href, options) => {
220
- const [pathPart, queryPart] = href.split("?");
221
- const resolvedPath = resolvePath(pathPart);
222
- const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;
223
- router.replace(fullPath, options);
224
- }, [router, resolvePath]),
225
- back: router.back,
226
- forward: router.forward,
227
- refresh: router.refresh,
228
- prefetch: router.prefetch
229
- };
230
- }
231
-
232
- //#endregion
233
- Object.defineProperty(exports, 'RecceContextProvider', {
234
- enumerable: true,
235
- get: function () {
236
- return RecceContextProvider;
237
- }
238
- });
239
- Object.defineProperty(exports, 'RouteConfigProvider', {
240
- enumerable: true,
241
- get: function () {
242
- return RouteConfigProvider;
243
- }
244
- });
245
- Object.defineProperty(exports, 'navigateTo', {
246
- enumerable: true,
247
- get: function () {
248
- return navigateTo;
249
- }
250
- });
251
- Object.defineProperty(exports, 'useAppLocation', {
252
- enumerable: true,
253
- get: function () {
254
- return useAppLocation;
255
- }
256
- });
257
- Object.defineProperty(exports, 'useAppLocationWithSearch', {
258
- enumerable: true,
259
- get: function () {
260
- return useAppLocationWithSearch;
261
- }
262
- });
263
- Object.defineProperty(exports, 'useAppNavigation', {
264
- enumerable: true,
265
- get: function () {
266
- return useAppNavigation;
267
- }
268
- });
269
- Object.defineProperty(exports, 'useAppRoute', {
270
- enumerable: true,
271
- get: function () {
272
- return useAppRoute;
273
- }
274
- });
275
- Object.defineProperty(exports, 'useRouteConfig', {
276
- enumerable: true,
277
- get: function () {
278
- return useRouteConfig;
279
- }
280
- });
281
- Object.defineProperty(exports, 'useRouteConfigSafe', {
282
- enumerable: true,
283
- get: function () {
284
- return useRouteConfigSafe;
285
- }
286
- });
287
- //# sourceMappingURL=hooks-CriUVJO1.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hooks-CriUVJO1.js","names":["RecceInstanceInfoProvider","RecceShareStateContextProvider","RecceQueryContextProvider","LineageGraphContextProvider","RowCountStateContextProvider","RecceActionContextProvider","RecceCheckContextProvider","defaultConfig: RouteConfig","contextValue: RouteConfigContextType","React","defaultRouteConfigContext: RouteConfigContextType"],"sources":["../recce-source/js/src/lib/hooks/RecceContextProvider.tsx","../src/lib/hooks/RouteConfigContext.ts","../src/lib/hooks/useAppRouter.ts"],"sourcesContent":["import React from \"react\";\nimport { LineageGraphContextProvider } from \"./LineageGraphContext\";\nimport { RecceActionContextProvider } from \"./RecceActionContext\";\nimport { RecceCheckContextProvider } from \"./RecceCheckContext\";\nimport { RecceInstanceInfoProvider } from \"./RecceInstanceContext\";\nimport {\n RecceQueryContextProvider,\n RowCountStateContextProvider,\n} from \"./RecceQueryContext\";\nimport { RecceShareStateContextProvider } from \"./RecceShareStateContext\";\n\ninterface RecceContextProps {\n children: React.ReactNode;\n}\n\n/**\n * Main context provider for Recce application.\n *\n * For custom API configuration (e.g., recce-cloud), wrap this provider\n * with ApiConfigProvider:\n *\n * ```tsx\n * <ApiConfigProvider\n * apiPrefix=\"/api/v2/sessions/abc123\"\n * authToken=\"eyJ...\"\n * >\n * <RecceContextProvider>\n * {children}\n * </RecceContextProvider>\n * </ApiConfigProvider>\n * ```\n *\n * When used without ApiConfigProvider (OSS mode), hooks will use\n * the default axios client with standard /api/* endpoints.\n */\nexport default function RecceContextProvider({ children }: RecceContextProps) {\n return (\n <RecceInstanceInfoProvider>\n <RecceShareStateContextProvider>\n <RecceQueryContextProvider>\n <LineageGraphContextProvider>\n <RowCountStateContextProvider>\n <RecceActionContextProvider>\n <RecceCheckContextProvider>\n {children}\n </RecceCheckContextProvider>\n </RecceActionContextProvider>\n </RowCountStateContextProvider>\n </LineageGraphContextProvider>\n </RecceQueryContextProvider>\n </RecceShareStateContextProvider>\n </RecceInstanceInfoProvider>\n );\n}\n","\"use client\";\n\nimport React, { createContext, useCallback, useContext, useMemo } from \"react\";\n\n/**\n * Route Configuration for path prefix customization.\n *\n * This context allows recce-cloud to configure a base path prefix\n * for all navigation within OSS components.\n *\n * Default behavior (OSS):\n * - basePath: \"\" (uses absolute paths like /query, /checks)\n *\n * Cloud usage example:\n * - basePath: \"/oss/abc123\" or \"/preview/abc123\"\n * - Navigation to \"/query\" becomes \"/oss/abc123/query\"\n */\n\nexport interface RouteConfig {\n /**\n * Base path prefix for navigation.\n * For OSS: \"\" (empty string, uses absolute paths like /query)\n * For Cloud: \"/oss/<sessionId>\" or \"/preview/<sessionId>\"\n */\n basePath: string;\n}\n\nexport interface RouteConfigContextType extends RouteConfig {\n /**\n * Resolves a path with the base path prefix.\n * @param path - The path to resolve (e.g., \"/query\")\n * @returns The resolved path (e.g., \"/oss/abc123/query\")\n */\n resolvePath: (path: string) => string;\n}\n\nconst defaultConfig: RouteConfig = {\n basePath: \"\",\n};\n\nconst RouteConfigContext = createContext<RouteConfigContextType | null>(null);\n\ninterface RouteConfigProviderProps extends Partial<RouteConfig> {\n children: React.ReactNode;\n}\n\n/**\n * Provider for route configuration.\n *\n * Wrap your application (or RecceContextProvider) with this provider\n * to configure path prefixes for navigation.\n *\n * @example\n * // In recce-cloud\n * <RouteConfigProvider basePath={`/oss/${sessionId}`}>\n * <RecceContextProvider>\n * {children}\n * </RecceContextProvider>\n * </RouteConfigProvider>\n */\nexport function RouteConfigProvider({\n children,\n basePath = defaultConfig.basePath,\n}: RouteConfigProviderProps) {\n const resolvePath = useCallback(\n (path: string): string => {\n // If no basePath configured, return path as-is (OSS mode)\n if (!basePath) {\n return path;\n }\n\n // Handle paths that already start with the basePath (avoid double-prefixing)\n if (path.startsWith(basePath)) {\n return path;\n }\n\n // Handle absolute URLs (http://, https://, etc.) - don't prefix\n if (path.match(/^https?:\\/\\//)) {\n return path;\n }\n\n // Handle hash-only paths - don't prefix\n if (path.startsWith(\"#\")) {\n return path;\n }\n\n // Ensure proper joining (no double slashes)\n const cleanBasePath = basePath.endsWith(\"/\")\n ? basePath.slice(0, -1)\n : basePath;\n const cleanPath = path.startsWith(\"/\") ? path : `/${path}`;\n\n return `${cleanBasePath}${cleanPath}`;\n },\n [basePath],\n );\n\n const contextValue: RouteConfigContextType = useMemo(\n () => ({\n basePath,\n resolvePath,\n }),\n [basePath, resolvePath],\n );\n\n return React.createElement(\n RouteConfigContext.Provider,\n { value: contextValue },\n children,\n );\n}\n\n// Default context for OSS mode (no prefix)\nconst defaultRouteConfigContext: RouteConfigContextType = {\n basePath: \"\",\n resolvePath: (path: string) => path,\n};\n\n/**\n * Hook to access route configuration.\n *\n * When used outside RouteConfigProvider, returns default config\n * (for OSS backward compatibility).\n *\n * @returns RouteConfigContextType with basePath and resolvePath function\n */\nexport function useRouteConfig(): RouteConfigContextType {\n const context = useContext(RouteConfigContext);\n // Return default config if outside provider (OSS mode)\n return context ?? defaultRouteConfigContext;\n}\n\n/**\n * Safe hook that returns null if context not available.\n * Useful for components that need to detect if RouteConfigProvider is present.\n */\nexport function useRouteConfigSafe(): RouteConfigContextType | null {\n return useContext(RouteConfigContext);\n}\n","/**\n * useAppRouter - Navigation utilities for Next.js App Router with RouteConfig support\n *\n * This is a custom version that wraps the OSS useAppRouter to add\n * RouteConfigContext support for path prefixing in recce-cloud.\n *\n * The key difference from OSS:\n * - setLocation() automatically prefixes paths with the configured basePath\n * - This allows OSS components to use setLocation(\"/query\") while\n * recce-cloud can configure basePath=\"/oss/abc123\" to get \"/oss/abc123/query\"\n */\n\n\"use client\";\n\nimport {\n useParams,\n usePathname,\n useRouter,\n useSearchParams,\n} from \"next/navigation\";\nimport { useCallback, useMemo } from \"react\";\nimport { useRouteConfig } from \"./RouteConfigContext\";\n\ninterface NavigateOptions {\n replace?: boolean;\n scroll?: boolean;\n}\n\n/**\n * Hook that provides Wouter-compatible location API using Next.js App Router\n * with RouteConfigContext support for path prefixing.\n *\n * NOTE: This returns only the pathname (not search params) to avoid\n * triggering Suspense boundaries on every navigation.\n *\n * @returns [pathname, setLocation] tuple similar to Wouter's useLocation\n *\n * @example\n * const [location, setLocation] = useAppLocation();\n * setLocation(\"/checks?id=123\"); // In cloud mode with basePath=\"/oss/abc123\"\n * // navigates to \"/oss/abc123/checks?id=123\"\n */\nexport function useAppLocation(): [\n string,\n (to: string, options?: NavigateOptions) => void,\n] {\n const router = useRouter();\n const pathname = usePathname();\n const { resolvePath } = useRouteConfig();\n\n // Navigation function compatible with Wouter's setLocation\n // Automatically applies basePath prefix from RouteConfigContext\n const setLocation = useCallback(\n (to: string, options?: NavigateOptions) => {\n // Separate path and query string for proper handling\n const [pathPart, queryPart] = to.split(\"?\");\n const resolvedPath = resolvePath(pathPart);\n const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;\n\n if (options?.replace) {\n router.replace(fullPath, { scroll: options?.scroll ?? true });\n } else {\n router.push(fullPath, { scroll: options?.scroll ?? true });\n }\n },\n [router, resolvePath],\n );\n\n return [pathname, setLocation];\n}\n\n/**\n * Hook that includes search params in the location string.\n * Also supports RouteConfigContext path prefixing.\n *\n * WARNING: This hook uses useSearchParams() which triggers Suspense.\n * Only use this in components that are wrapped in a <Suspense> boundary,\n * or in leaf components where suspension is acceptable.\n *\n * @returns [fullLocation, setLocation] tuple with search params included\n */\nexport function useAppLocationWithSearch(): [\n string,\n (to: string, options?: NavigateOptions) => void,\n] {\n const router = useRouter();\n const pathname = usePathname();\n const searchParams = useSearchParams();\n const { resolvePath } = useRouteConfig();\n\n // Construct full location string including search params\n const location = useMemo(() => {\n const search = searchParams?.toString();\n return search ? `${pathname}?${search}` : pathname;\n }, [pathname, searchParams]);\n\n // Navigation function with RouteConfigContext support\n const setLocation = useCallback(\n (to: string, options?: NavigateOptions) => {\n const [pathPart, queryPart] = to.split(\"?\");\n const resolvedPath = resolvePath(pathPart);\n const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;\n\n if (options?.replace) {\n router.replace(fullPath, { scroll: options?.scroll ?? true });\n } else {\n router.push(fullPath, { scroll: options?.scroll ?? true });\n }\n },\n [router, resolvePath],\n );\n\n return [location, setLocation];\n}\n\n/**\n * Hook to check if current path matches a pattern\n * Similar to Wouter's useRoute\n *\n * @param pattern - The route pattern to match (e.g., \"/checks/:checkId\")\n * @returns [isMatch, params] tuple\n *\n * @example\n * const [isMatch, params] = useAppRoute(\"/checks/:checkId\");\n * if (isMatch) {\n * console.log(params.checkId); // \"abc-123\"\n * }\n */\nexport function useAppRoute(\n pattern: string,\n): [boolean, Record<string, string>] {\n const pathname = usePathname();\n const params = useParams();\n\n const isMatch = useMemo(() => {\n // Convert Next.js dynamic route pattern to regex\n // /checks/[checkId] -> /checks/:checkId -> /checks/([^/]+)\n const regexPattern = pattern\n .replace(/:\\w+/g, \"([^/]+)\") // :param -> capture group\n .replace(/\\*/g, \".*\"); // * -> wildcard\n\n const regex = new RegExp(`^${regexPattern}$`);\n return regex.test(pathname);\n }, [pattern, pathname]);\n\n // Convert Next.js params to plain object\n const paramsObj = useMemo(() => {\n if (!params) return {};\n return Object.fromEntries(\n Object.entries(params).map(([key, value]) => [\n key,\n Array.isArray(value) ? value.join(\"/\") : value,\n ]),\n );\n }, [params]);\n\n return [isMatch, paramsObj as Record<string, string>];\n}\n\n/**\n * Imperative navigation function for use outside React components\n * Use sparingly - prefer useAppLocation hook in components\n *\n * NOTE: This function does NOT support RouteConfigContext because\n * it's used outside of React component tree. If you need path prefixing,\n * use useAppLocation hook instead.\n *\n * @example\n * // In an event handler or utility function\n * import { navigateTo } from \"@/lib/hooks/useAppRouter\";\n * navigateTo(\"/checks?id=123\");\n */\nexport function navigateTo(path: string, replace = false): void {\n if (typeof window !== \"undefined\") {\n if (replace) {\n window.history.replaceState(null, \"\", path);\n } else {\n window.history.pushState(null, \"\", path);\n }\n // Trigger Next.js to recognize the navigation\n window.dispatchEvent(new PopStateEvent(\"popstate\"));\n }\n}\n\n/**\n * Hook for programmatic navigation with more options\n * Provides direct access to Next.js router methods with RouteConfigContext support\n *\n * NOTE: Does not include searchParams to avoid Suspense.\n * Use useSearchParams() directly in components that need it.\n */\nexport function useAppNavigation() {\n const router = useRouter();\n const pathname = usePathname();\n const params = useParams();\n const { resolvePath } = useRouteConfig();\n\n // Wrap router.push and router.replace with path resolution\n const push = useCallback(\n (href: string, options?: { scroll?: boolean }) => {\n const [pathPart, queryPart] = href.split(\"?\");\n const resolvedPath = resolvePath(pathPart);\n const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;\n router.push(fullPath, options);\n },\n [router, resolvePath],\n );\n\n const replace = useCallback(\n (href: string, options?: { scroll?: boolean }) => {\n const [pathPart, queryPart] = href.split(\"?\");\n const resolvedPath = resolvePath(pathPart);\n const fullPath = queryPart ? `${resolvedPath}?${queryPart}` : resolvedPath;\n router.replace(fullPath, options);\n },\n [router, resolvePath],\n );\n\n return {\n /** Current pathname */\n pathname,\n /** Current route params */\n params: params as Record<string, string>,\n /** Navigate to a new path (with RouteConfigContext support) */\n push,\n /** Replace current history entry (with RouteConfigContext support) */\n replace,\n /** Go back in history */\n back: router.back,\n /** Go forward in history */\n forward: router.forward,\n /** Refresh the current route */\n refresh: router.refresh,\n /** Prefetch a route for faster navigation */\n prefetch: router.prefetch,\n };\n}\n\n// Re-export Next.js hooks for convenience\nexport { useRouter, usePathname, useParams, useSearchParams };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAwB,qBAAqB,EAAE,YAA+B;AAC5E,QACE,2CAACA,qDACC,2CAACC,sEACC,2CAACC,iEACC,2CAACC,uDACC,2CAACC,oEACC,2CAACC,sDACC,2CAACC,uDACE,WACyB,GACD,GACA,GACH,GACJ,GACG,GACP;;;;;ACfhC,MAAMC,gBAA6B,EACjC,UAAU,IACX;AAED,MAAM,8CAAkE,KAAK;;;;;;;;;;;;;;;AAoB7E,SAAgB,oBAAoB,EAClC,UACA,WAAW,cAAc,YACE;CAC3B,MAAM,sCACH,SAAyB;AAExB,MAAI,CAAC,SACH,QAAO;AAIT,MAAI,KAAK,WAAW,SAAS,CAC3B,QAAO;AAIT,MAAI,KAAK,MAAM,eAAe,CAC5B,QAAO;AAIT,MAAI,KAAK,WAAW,IAAI,CACtB,QAAO;AAST,SAAO,GALe,SAAS,SAAS,IAAI,GACxC,SAAS,MAAM,GAAG,GAAG,GACrB,WACc,KAAK,WAAW,IAAI,GAAG,OAAO,IAAI;IAItD,CAAC,SAAS,CACX;CAED,MAAMC,yCACG;EACL;EACA;EACD,GACD,CAAC,UAAU,YAAY,CACxB;AAED,QAAOC,cAAM,cACX,mBAAmB,UACnB,EAAE,OAAO,cAAc,EACvB,SACD;;AAIH,MAAMC,4BAAoD;CACxD,UAAU;CACV,cAAc,SAAiB;CAChC;;;;;;;;;AAUD,SAAgB,iBAAyC;AAGvD,8BAF2B,mBAAmB,IAE5B;;;;;;AAOpB,SAAgB,qBAAoD;AAClE,8BAAkB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC/FvC,SAAgB,iBAGd;CACA,MAAM,yCAAoB;CAC1B,MAAM,6CAAwB;CAC9B,MAAM,EAAE,gBAAgB,gBAAgB;AAoBxC,QAAO,CAAC,kCAfL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