@lolyjs/core 0.2.0-alpha.12 → 0.2.0-alpha.13

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.
@@ -25,10 +25,16 @@ __export(sockets_exports, {
25
25
  module.exports = __toCommonJS(sockets_exports);
26
26
  var import_socket = require("socket.io-client");
27
27
  var lolySocket = (namespace, opts) => {
28
- const wsBaseUrl = process.env.PUBLIC_WS_BASE_URL;
29
- const baseUrl = wsBaseUrl && wsBaseUrl.trim() !== "" ? wsBaseUrl : window.location.origin;
30
- if (!wsBaseUrl || wsBaseUrl.trim() === "") {
31
- console.warn("[loly:socket] PUBLIC_WS_BASE_URL is not set, using window.location.origin.");
28
+ const wsBaseUrl = process.env?.PUBLIC_WS_BASE_URL;
29
+ let baseUrl;
30
+ if (wsBaseUrl && wsBaseUrl.trim() !== "") {
31
+ baseUrl = wsBaseUrl;
32
+ } else if (typeof window !== "undefined") {
33
+ baseUrl = window.location.origin;
34
+ } else {
35
+ throw new Error(
36
+ "[loly:socket] Cannot determine base URL in server-side context. Either set PUBLIC_WS_BASE_URL in your .env file or ensure lolySocket is only called on the client."
37
+ );
32
38
  }
33
39
  const normalizedNamespace = namespace.startsWith("/") ? namespace : `/${namespace}`;
34
40
  const fullUrl = `${baseUrl}${normalizedNamespace}`;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../modules/react/sockets/index.ts"],"sourcesContent":["import { io, ManagerOptions, Socket, SocketOptions } from \"socket.io-client\";\r\n\r\n/**\r\n * Creates a Socket.IO client connection to a specific namespace.\r\n * \r\n * This helper function simplifies Socket.IO client setup by handling:\r\n * - Namespace normalization (ensures leading slash)\r\n * - Base URL resolution (from environment or current origin)\r\n * - Default Socket.IO configuration (path: '/wss', transports: ['websocket', 'polling'])\r\n * \r\n * @param namespace - The namespace to connect to (e.g., '/chat' or 'chat').\r\n * The namespace will be normalized to always start with '/'.\r\n * Must match the namespace pattern defined in your server's WSS routes.\r\n * @param opts - Optional Socket.IO client options that will override the defaults.\r\n * \r\n * @returns A Socket.IO client instance connected to the specified namespace.\r\n * \r\n * @example\r\n * ```ts\r\n * const socket = lolySocket('/chat');\r\n * socket.on('message', (data) => {\r\n * console.log('Received:', data);\r\n * });\r\n * socket.emit('message', { text: 'Hello' });\r\n * ```\r\n */\r\nexport const lolySocket = (\r\n namespace: string,\r\n opts?: Partial<ManagerOptions & SocketOptions>\r\n): Socket => {\r\n // @ts-ignore - process.env.PUBLIC_WS_BASE_URL is replaced by DefinePlugin at build time with literal value\r\n // DefinePlugin replaces process.env.PUBLIC_WS_BASE_URL with the actual value (or empty string if not set)\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const wsBaseUrl: string | undefined = (process as any).env.PUBLIC_WS_BASE_URL;\r\n const baseUrl = (wsBaseUrl && wsBaseUrl.trim() !== \"\") ? wsBaseUrl : window.location.origin;\r\n\r\n if (!wsBaseUrl || wsBaseUrl.trim() === \"\") {\r\n console.warn(\"[loly:socket] PUBLIC_WS_BASE_URL is not set, using window.location.origin.\");\r\n }\r\n\r\n // Normalize namespace to always start with '/'\r\n const normalizedNamespace = namespace.startsWith(\"/\") ? namespace : `/${namespace}`;\r\n\r\n // In Socket.IO, when using a custom path, the namespace is specified in the URL:\r\n // baseUrl + namespace. The path '/wss' is the HTTP route where Socket.IO listens.\r\n const fullUrl = `${baseUrl}${normalizedNamespace}`;\r\n\r\n const socket = io(fullUrl, {\r\n path: \"/wss\",\r\n transports: [\"websocket\", \"polling\"],\r\n autoConnect: true,\r\n ...opts,\r\n });\r\n\r\n return socket;\r\n};\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0D;AA0BnD,IAAM,aAAa,CACxB,WACA,SACW;AAIX,QAAM,YAAiC,QAAgB,IAAI;AAC3D,QAAM,UAAW,aAAa,UAAU,KAAK,MAAM,KAAM,YAAY,OAAO,SAAS;AAErF,MAAI,CAAC,aAAa,UAAU,KAAK,MAAM,IAAI;AACzC,YAAQ,KAAK,4EAA4E;AAAA,EAC3F;AAGA,QAAM,sBAAsB,UAAU,WAAW,GAAG,IAAI,YAAY,IAAI,SAAS;AAIjF,QAAM,UAAU,GAAG,OAAO,GAAG,mBAAmB;AAEhD,QAAM,aAAS,kBAAG,SAAS;AAAA,IACzB,MAAM;AAAA,IACN,YAAY,CAAC,aAAa,SAAS;AAAA,IACnC,aAAa;AAAA,IACb,GAAG;AAAA,EACL,CAAC;AAED,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../modules/react/sockets/index.ts"],"sourcesContent":["import { io, ManagerOptions, Socket, SocketOptions } from \"socket.io-client\";\r\n\r\n/**\r\n * Creates a Socket.IO client connection to a specific namespace.\r\n * \r\n * This helper function simplifies Socket.IO client setup by handling:\r\n * - Namespace normalization (ensures leading slash)\r\n * - Base URL resolution (from environment or current origin)\r\n * - Default Socket.IO configuration (path: '/wss', transports: ['websocket', 'polling'])\r\n * \r\n * @param namespace - The namespace to connect to (e.g., '/chat' or 'chat').\r\n * The namespace will be normalized to always start with '/'.\r\n * Must match the namespace pattern defined in your server's WSS routes.\r\n * @param opts - Optional Socket.IO client options that will override the defaults.\r\n * \r\n * @returns A Socket.IO client instance connected to the specified namespace.\r\n * \r\n * @example\r\n * ```ts\r\n * const socket = lolySocket('/chat');\r\n * socket.on('message', (data) => {\r\n * console.log('Received:', data);\r\n * });\r\n * socket.emit('message', { text: 'Hello' });\r\n * ```\r\n */\r\nexport const lolySocket = (\r\n namespace: string,\r\n opts?: Partial<ManagerOptions & SocketOptions>\r\n): Socket => {\r\n // @ts-ignore - process.env.PUBLIC_WS_BASE_URL is replaced by DefinePlugin at build time with literal value\r\n // DefinePlugin replaces process.env.PUBLIC_WS_BASE_URL with the actual value (or undefined if not set)\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const wsBaseUrl: string | undefined = (process as any).env?.PUBLIC_WS_BASE_URL;\r\n \r\n // Get base URL: use PUBLIC_WS_BASE_URL if set, otherwise use window.location.origin (client-side only)\r\n // For SSR, if window is not available, we'll need to handle it differently\r\n let baseUrl: string;\r\n if (wsBaseUrl && wsBaseUrl.trim() !== \"\") {\r\n baseUrl = wsBaseUrl;\r\n } else if (typeof window !== \"undefined\") {\r\n // Client-side: use current origin\r\n baseUrl = window.location.origin;\r\n } else {\r\n // Server-side rendering: throw error or use a default\r\n // This should rarely happen as sockets are typically client-only\r\n throw new Error(\r\n \"[loly:socket] Cannot determine base URL in server-side context. \" +\r\n \"Either set PUBLIC_WS_BASE_URL in your .env file or ensure lolySocket is only called on the client.\"\r\n );\r\n }\r\n\r\n // Normalize namespace to always start with '/'\r\n const normalizedNamespace = namespace.startsWith(\"/\") ? namespace : `/${namespace}`;\r\n\r\n // In Socket.IO, when using a custom path, the namespace is specified in the URL:\r\n // baseUrl + namespace. The path '/wss' is the HTTP route where Socket.IO listens.\r\n const fullUrl = `${baseUrl}${normalizedNamespace}`;\r\n\r\n const socket = io(fullUrl, {\r\n path: \"/wss\",\r\n transports: [\"websocket\", \"polling\"],\r\n autoConnect: true,\r\n ...opts,\r\n });\r\n\r\n return socket;\r\n};\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0D;AA0BnD,IAAM,aAAa,CACxB,WACA,SACW;AAIX,QAAM,YAAiC,QAAgB,KAAK;AAI5D,MAAI;AACJ,MAAI,aAAa,UAAU,KAAK,MAAM,IAAI;AACxC,cAAU;AAAA,EACZ,WAAW,OAAO,WAAW,aAAa;AAExC,cAAU,OAAO,SAAS;AAAA,EAC5B,OAAO;AAGL,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AAGA,QAAM,sBAAsB,UAAU,WAAW,GAAG,IAAI,YAAY,IAAI,SAAS;AAIjF,QAAM,UAAU,GAAG,OAAO,GAAG,mBAAmB;AAEhD,QAAM,aAAS,kBAAG,SAAS;AAAA,IACzB,MAAM;AAAA,IACN,YAAY,CAAC,aAAa,SAAS;AAAA,IACnC,aAAa;AAAA,IACb,GAAG;AAAA,EACL,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -1,10 +1,16 @@
1
1
  // modules/react/sockets/index.ts
2
2
  import { io } from "socket.io-client";
3
3
  var lolySocket = (namespace, opts) => {
4
- const wsBaseUrl = process.env.PUBLIC_WS_BASE_URL;
5
- const baseUrl = wsBaseUrl && wsBaseUrl.trim() !== "" ? wsBaseUrl : window.location.origin;
6
- if (!wsBaseUrl || wsBaseUrl.trim() === "") {
7
- console.warn("[loly:socket] PUBLIC_WS_BASE_URL is not set, using window.location.origin.");
4
+ const wsBaseUrl = process.env?.PUBLIC_WS_BASE_URL;
5
+ let baseUrl;
6
+ if (wsBaseUrl && wsBaseUrl.trim() !== "") {
7
+ baseUrl = wsBaseUrl;
8
+ } else if (typeof window !== "undefined") {
9
+ baseUrl = window.location.origin;
10
+ } else {
11
+ throw new Error(
12
+ "[loly:socket] Cannot determine base URL in server-side context. Either set PUBLIC_WS_BASE_URL in your .env file or ensure lolySocket is only called on the client."
13
+ );
8
14
  }
9
15
  const normalizedNamespace = namespace.startsWith("/") ? namespace : `/${namespace}`;
10
16
  const fullUrl = `${baseUrl}${normalizedNamespace}`;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../modules/react/sockets/index.ts"],"sourcesContent":["import { io, ManagerOptions, Socket, SocketOptions } from \"socket.io-client\";\r\n\r\n/**\r\n * Creates a Socket.IO client connection to a specific namespace.\r\n * \r\n * This helper function simplifies Socket.IO client setup by handling:\r\n * - Namespace normalization (ensures leading slash)\r\n * - Base URL resolution (from environment or current origin)\r\n * - Default Socket.IO configuration (path: '/wss', transports: ['websocket', 'polling'])\r\n * \r\n * @param namespace - The namespace to connect to (e.g., '/chat' or 'chat').\r\n * The namespace will be normalized to always start with '/'.\r\n * Must match the namespace pattern defined in your server's WSS routes.\r\n * @param opts - Optional Socket.IO client options that will override the defaults.\r\n * \r\n * @returns A Socket.IO client instance connected to the specified namespace.\r\n * \r\n * @example\r\n * ```ts\r\n * const socket = lolySocket('/chat');\r\n * socket.on('message', (data) => {\r\n * console.log('Received:', data);\r\n * });\r\n * socket.emit('message', { text: 'Hello' });\r\n * ```\r\n */\r\nexport const lolySocket = (\r\n namespace: string,\r\n opts?: Partial<ManagerOptions & SocketOptions>\r\n): Socket => {\r\n // @ts-ignore - process.env.PUBLIC_WS_BASE_URL is replaced by DefinePlugin at build time with literal value\r\n // DefinePlugin replaces process.env.PUBLIC_WS_BASE_URL with the actual value (or empty string if not set)\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const wsBaseUrl: string | undefined = (process as any).env.PUBLIC_WS_BASE_URL;\r\n const baseUrl = (wsBaseUrl && wsBaseUrl.trim() !== \"\") ? wsBaseUrl : window.location.origin;\r\n\r\n if (!wsBaseUrl || wsBaseUrl.trim() === \"\") {\r\n console.warn(\"[loly:socket] PUBLIC_WS_BASE_URL is not set, using window.location.origin.\");\r\n }\r\n\r\n // Normalize namespace to always start with '/'\r\n const normalizedNamespace = namespace.startsWith(\"/\") ? namespace : `/${namespace}`;\r\n\r\n // In Socket.IO, when using a custom path, the namespace is specified in the URL:\r\n // baseUrl + namespace. The path '/wss' is the HTTP route where Socket.IO listens.\r\n const fullUrl = `${baseUrl}${normalizedNamespace}`;\r\n\r\n const socket = io(fullUrl, {\r\n path: \"/wss\",\r\n transports: [\"websocket\", \"polling\"],\r\n autoConnect: true,\r\n ...opts,\r\n });\r\n\r\n return socket;\r\n};\r\n"],"mappings":";AAAA,SAAS,UAAiD;AA0BnD,IAAM,aAAa,CACxB,WACA,SACW;AAIX,QAAM,YAAiC,QAAgB,IAAI;AAC3D,QAAM,UAAW,aAAa,UAAU,KAAK,MAAM,KAAM,YAAY,OAAO,SAAS;AAErF,MAAI,CAAC,aAAa,UAAU,KAAK,MAAM,IAAI;AACzC,YAAQ,KAAK,4EAA4E;AAAA,EAC3F;AAGA,QAAM,sBAAsB,UAAU,WAAW,GAAG,IAAI,YAAY,IAAI,SAAS;AAIjF,QAAM,UAAU,GAAG,OAAO,GAAG,mBAAmB;AAEhD,QAAM,SAAS,GAAG,SAAS;AAAA,IACzB,MAAM;AAAA,IACN,YAAY,CAAC,aAAa,SAAS;AAAA,IACnC,aAAa;AAAA,IACb,GAAG;AAAA,EACL,CAAC;AAED,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../modules/react/sockets/index.ts"],"sourcesContent":["import { io, ManagerOptions, Socket, SocketOptions } from \"socket.io-client\";\r\n\r\n/**\r\n * Creates a Socket.IO client connection to a specific namespace.\r\n * \r\n * This helper function simplifies Socket.IO client setup by handling:\r\n * - Namespace normalization (ensures leading slash)\r\n * - Base URL resolution (from environment or current origin)\r\n * - Default Socket.IO configuration (path: '/wss', transports: ['websocket', 'polling'])\r\n * \r\n * @param namespace - The namespace to connect to (e.g., '/chat' or 'chat').\r\n * The namespace will be normalized to always start with '/'.\r\n * Must match the namespace pattern defined in your server's WSS routes.\r\n * @param opts - Optional Socket.IO client options that will override the defaults.\r\n * \r\n * @returns A Socket.IO client instance connected to the specified namespace.\r\n * \r\n * @example\r\n * ```ts\r\n * const socket = lolySocket('/chat');\r\n * socket.on('message', (data) => {\r\n * console.log('Received:', data);\r\n * });\r\n * socket.emit('message', { text: 'Hello' });\r\n * ```\r\n */\r\nexport const lolySocket = (\r\n namespace: string,\r\n opts?: Partial<ManagerOptions & SocketOptions>\r\n): Socket => {\r\n // @ts-ignore - process.env.PUBLIC_WS_BASE_URL is replaced by DefinePlugin at build time with literal value\r\n // DefinePlugin replaces process.env.PUBLIC_WS_BASE_URL with the actual value (or undefined if not set)\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const wsBaseUrl: string | undefined = (process as any).env?.PUBLIC_WS_BASE_URL;\r\n \r\n // Get base URL: use PUBLIC_WS_BASE_URL if set, otherwise use window.location.origin (client-side only)\r\n // For SSR, if window is not available, we'll need to handle it differently\r\n let baseUrl: string;\r\n if (wsBaseUrl && wsBaseUrl.trim() !== \"\") {\r\n baseUrl = wsBaseUrl;\r\n } else if (typeof window !== \"undefined\") {\r\n // Client-side: use current origin\r\n baseUrl = window.location.origin;\r\n } else {\r\n // Server-side rendering: throw error or use a default\r\n // This should rarely happen as sockets are typically client-only\r\n throw new Error(\r\n \"[loly:socket] Cannot determine base URL in server-side context. \" +\r\n \"Either set PUBLIC_WS_BASE_URL in your .env file or ensure lolySocket is only called on the client.\"\r\n );\r\n }\r\n\r\n // Normalize namespace to always start with '/'\r\n const normalizedNamespace = namespace.startsWith(\"/\") ? namespace : `/${namespace}`;\r\n\r\n // In Socket.IO, when using a custom path, the namespace is specified in the URL:\r\n // baseUrl + namespace. The path '/wss' is the HTTP route where Socket.IO listens.\r\n const fullUrl = `${baseUrl}${normalizedNamespace}`;\r\n\r\n const socket = io(fullUrl, {\r\n path: \"/wss\",\r\n transports: [\"websocket\", \"polling\"],\r\n autoConnect: true,\r\n ...opts,\r\n });\r\n\r\n return socket;\r\n};\r\n"],"mappings":";AAAA,SAAS,UAAiD;AA0BnD,IAAM,aAAa,CACxB,WACA,SACW;AAIX,QAAM,YAAiC,QAAgB,KAAK;AAI5D,MAAI;AACJ,MAAI,aAAa,UAAU,KAAK,MAAM,IAAI;AACxC,cAAU;AAAA,EACZ,WAAW,OAAO,WAAW,aAAa;AAExC,cAAU,OAAO,SAAS;AAAA,EAC5B,OAAO;AAGL,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AAGA,QAAM,sBAAsB,UAAU,WAAW,GAAG,IAAI,YAAY,IAAI,SAAS;AAIjF,QAAM,UAAU,GAAG,OAAO,GAAG,mBAAmB;AAEhD,QAAM,SAAS,GAAG,SAAS;AAAA,IACzB,MAAM;AAAA,IACN,YAAY,CAAC,aAAa,SAAS;AAAA,IACnC,aAAa;AAAA,IACb,GAAG;AAAA,EACL,CAAC;AAED,SAAO;AACT;","names":[]}
package/dist/runtime.cjs CHANGED
@@ -700,7 +700,7 @@ async function loadInitialRoute(initialUrl, initialData, routes, notFoundRoute,
700
700
  };
701
701
  }
702
702
  function setupHotReload() {
703
- const nodeEnv = typeof process !== "undefined" && process?.env?.NODE_ENV || "production";
703
+ const nodeEnv = typeof process !== "undefined" && process.env?.NODE_ENV || "production";
704
704
  const isDev = nodeEnv !== "production";
705
705
  if (!isDev) {
706
706
  return;
@@ -1 +1 @@
1
- {"version":3,"sources":["../modules/runtime/client/index.tsx","../modules/runtime/client/bootstrap.tsx","../modules/runtime/client/constants.ts","../modules/runtime/client/window-data.ts","../modules/runtime/client/route-matcher.ts","../modules/runtime/client/metadata.ts","../modules/runtime/client/AppShell.tsx","../modules/runtime/client/RouterView.tsx","../modules/react/cache/client-data-cache/index.ts","../modules/runtime/client/navigation.ts","../modules/runtime/client/RouterContext.tsx"],"sourcesContent":["// Re-export all public types and functions\r\nexport type {\r\n ClientLoadedComponents,\r\n ClientRouteLoaded,\r\n ClientRouteMatch,\r\n RouteViewState,\r\n InitialData,\r\n} from \"./types\";\r\n\r\nexport { bootstrapClient } from \"./bootstrap\";\r\nexport type { AppShellProps } from \"./AppShell\";\r\n","import { hydrateRoot } from \"react-dom/client\";\r\nimport { APP_CONTAINER_ID } from \"./constants\";\r\nimport { getWindowData, getRouterData, setRouterData } from \"./window-data\";\r\nimport { matchRouteClient } from \"./route-matcher\";\r\nimport { applyMetadata } from \"./metadata\";\r\nimport { AppShell } from \"./AppShell\";\r\nimport type {\r\n InitialData,\r\n ClientRouteLoaded,\r\n RouteViewState,\r\n} from \"./types\";\r\n\r\nexport async function loadInitialRoute(\r\n initialUrl: string,\r\n initialData: InitialData | null,\r\n routes: ClientRouteLoaded[],\r\n notFoundRoute: ClientRouteLoaded | null,\r\n errorRoute: ClientRouteLoaded | null\r\n): Promise<RouteViewState> {\r\n const isInitialNotFound = initialData?.notFound === true;\r\n const isInitialError = initialData?.error === true;\r\n\r\n let initialRoute: ClientRouteLoaded | null = null;\r\n let initialParams: Record<string, string> = {};\r\n let initialComponents = null;\r\n\r\n if (isInitialError && errorRoute) {\r\n initialRoute = errorRoute;\r\n initialParams = initialData?.params ?? {};\r\n initialComponents = await errorRoute.load();\r\n } else if (isInitialNotFound && notFoundRoute) {\r\n initialRoute = notFoundRoute;\r\n initialParams = {};\r\n initialComponents = await notFoundRoute.load();\r\n } else {\r\n const match = matchRouteClient(initialUrl, routes);\r\n if (match) {\r\n initialRoute = match.route;\r\n initialParams = match.params;\r\n initialComponents = await match.route.load();\r\n } else if (notFoundRoute) {\r\n initialRoute = notFoundRoute;\r\n initialParams = {};\r\n initialComponents = await notFoundRoute.load();\r\n } else {\r\n console.warn(\r\n `[client] No route match found for ${initialUrl}. Available routes:`,\r\n routes.map((r) => r.pattern)\r\n );\r\n }\r\n }\r\n\r\n return {\r\n url: initialUrl,\r\n route: initialRoute,\r\n params: initialParams,\r\n components: initialComponents,\r\n props: initialData?.props ?? {},\r\n };\r\n}\r\n\r\n/**\r\n * Sets up hot reload via Server-Sent Events (SSE) in development mode.\r\n * Listens for file changes and reloads the page when needed.\r\n */\r\nfunction setupHotReload(): void {\r\n // Only enable hot reload in development mode\r\n // In production, process.env.NODE_ENV is replaced by DefinePlugin with \"production\"\r\n // @ts-ignore - process.env.NODE_ENV is replaced by DefinePlugin at build time\r\n const nodeEnv: string = (typeof process !== \"undefined\" && process?.env?.NODE_ENV) || \"production\";\r\n const isDev = nodeEnv !== \"production\";\r\n \r\n if (!isDev) {\r\n return; // Skip hot reload in production\r\n }\r\n\r\n try {\r\n console.log(\"[hot-reload] Attempting to connect to /__fw/hot...\");\r\n const eventSource = new EventSource(\"/__fw/hot\");\r\n let reloadTimeout: ReturnType<typeof setTimeout> | null = null;\r\n\r\n eventSource.addEventListener(\"message\", (event) => {\r\n const data = event.data;\r\n if (data && data.startsWith(\"reload:\")) {\r\n const filePath = data.slice(7);\r\n console.log(`[hot-reload] File changed: ${filePath}`);\r\n\r\n // Clear any pending reload\r\n if (reloadTimeout) {\r\n clearTimeout(reloadTimeout);\r\n }\r\n\r\n // Wait a bit for the bundler to finish compiling and files to be written\r\n // Increased timeout to ensure everything is ready\r\n reloadTimeout = setTimeout(() => {\r\n console.log(\"[hot-reload] Reloading page...\");\r\n // Force reload without cache to ensure we get the latest files\r\n window.location.reload();\r\n }, 500);\r\n }\r\n });\r\n\r\n eventSource.addEventListener(\"ping\", () => {\r\n console.log(\"[hot-reload] ✓ Connected to hot reload server\");\r\n });\r\n\r\n eventSource.onopen = () => {\r\n console.log(\"[hot-reload] ✓ SSE connection opened\");\r\n };\r\n\r\n eventSource.onerror = (error) => {\r\n // Log connection state for debugging\r\n const states = [\"CONNECTING\", \"OPEN\", \"CLOSED\"];\r\n const state = states[eventSource.readyState] || \"UNKNOWN\";\r\n \r\n if (eventSource.readyState === EventSource.CONNECTING) {\r\n // Still connecting, might be normal\r\n console.log(\"[hot-reload] Connecting...\");\r\n } else if (eventSource.readyState === EventSource.OPEN) {\r\n console.warn(\"[hot-reload] Connection error (but connection is open):\", error);\r\n } else {\r\n // Connection closed - might be production mode or server not running\r\n console.log(\"[hot-reload] Connection closed (readyState:\", state, \")\");\r\n }\r\n // EventSource automatically reconnects, so we don't need to do anything\r\n };\r\n } catch (error) {\r\n // Fail silently if EventSource is not supported\r\n console.log(\"[hot-reload] EventSource not supported or error:\", error);\r\n }\r\n}\r\n\r\n/**\r\n * Bootstraps the client-side application.\r\n *\r\n * @param routes - Array of client routes\r\n * @param notFoundRoute - Not-found route definition\r\n * @param errorRoute - Error route definition\r\n */\r\nexport function bootstrapClient(\r\n routes: ClientRouteLoaded[],\r\n notFoundRoute: ClientRouteLoaded | null,\r\n errorRoute: ClientRouteLoaded | null = null\r\n): void {\r\n // Set up hot reload in development mode\r\n console.log(\"[client] Bootstrap starting, setting up hot reload...\");\r\n setupHotReload();\r\n\r\n (async function bootstrap() {\r\n const container = document.getElementById(APP_CONTAINER_ID);\r\n const initialData = getWindowData();\r\n\r\n if (!container) {\r\n console.error(`Container #${APP_CONTAINER_ID} not found for hydration`);\r\n return;\r\n }\r\n\r\n const initialUrl = window.location.pathname + window.location.search;\r\n\r\n // Initialize routerData from server if available, otherwise build from URL\r\n let routerData = getRouterData();\r\n if (!routerData) {\r\n const url = new URL(initialUrl, window.location.origin);\r\n routerData = {\r\n pathname: url.pathname,\r\n params: initialData?.params || {},\r\n searchParams: Object.fromEntries(url.searchParams.entries()),\r\n };\r\n setRouterData(routerData);\r\n }\r\n\r\n try {\r\n const initialState = await loadInitialRoute(\r\n initialUrl,\r\n initialData,\r\n routes,\r\n notFoundRoute,\r\n errorRoute\r\n );\r\n\r\n if (initialData?.metadata) {\r\n applyMetadata(initialData.metadata);\r\n }\r\n\r\n hydrateRoot(\r\n container,\r\n <AppShell\r\n initialState={initialState}\r\n routes={routes}\r\n notFoundRoute={notFoundRoute}\r\n errorRoute={errorRoute}\r\n />\r\n );\r\n } catch (error) {\r\n console.error(\r\n \"[client] Error loading initial route components for\",\r\n initialUrl,\r\n error\r\n );\r\n\r\n window.location.reload();\r\n }\r\n })();\r\n}\r\n\r\n","// Client-side constants (hardcoded to avoid alias resolution issues in Rspack)\r\nexport const WINDOW_DATA_KEY = \"__FW_DATA__\";\r\nexport const ROUTER_DATA_KEY = \"__LOLY_ROUTER_DATA__\";\r\nexport const APP_CONTAINER_ID = \"__app\";\r\n// Global key for navigate function fallback (exposed by AppShell for hydration timing issues)\r\nexport const ROUTER_NAVIGATE_KEY = \"__LOLY_ROUTER_NAVIGATE__\";\r\n\r\n","import { WINDOW_DATA_KEY, ROUTER_DATA_KEY } from \"./constants\";\r\nimport type { InitialData, RouterData } from \"./types\";\r\n\r\nexport function getWindowData(): InitialData | null {\r\n if (typeof window === \"undefined\") {\r\n return null;\r\n }\r\n return ((window as any)[WINDOW_DATA_KEY] as InitialData | undefined) ?? null;\r\n}\r\n\r\nexport function getRouterData(): RouterData | null {\r\n if (typeof window === \"undefined\") {\r\n return null;\r\n }\r\n return ((window as any)[ROUTER_DATA_KEY] as RouterData | undefined) ?? null;\r\n}\r\n\r\nexport function setWindowData(data: InitialData): void {\r\n (window as any)[WINDOW_DATA_KEY] = data;\r\n \r\n // Dispatch event for components to listen to (e.g. ThemeProvider)\r\n // This ensures components update when navigating in SPA mode\r\n if (typeof window !== \"undefined\") {\r\n window.dispatchEvent(\r\n new CustomEvent(\"fw-data-refresh\", {\r\n detail: { data },\r\n })\r\n );\r\n }\r\n}\r\n\r\nexport function setRouterData(data: RouterData): void {\r\n (window as any)[ROUTER_DATA_KEY] = data;\r\n \r\n // Dispatch event for router data updates\r\n if (typeof window !== \"undefined\") {\r\n window.dispatchEvent(\r\n new CustomEvent(\"fw-router-data-refresh\", {\r\n detail: { data },\r\n })\r\n );\r\n }\r\n}\r\n\r\nexport function getCurrentTheme(): string | null {\r\n return getWindowData()?.theme ?? null;\r\n}\r\n\r\n","import type { ClientRouteLoaded, ClientRouteMatch } from \"./types\";\r\n\r\nexport function buildClientRegexFromPattern(pattern: string): RegExp {\r\n const segments = pattern.split(\"/\").filter(Boolean);\r\n const regexParts: string[] = [];\r\n\r\n for (let i = 0; i < segments.length; i++) {\r\n const seg = segments[i];\r\n\r\n // catch-all [...slug]\r\n if (seg.startsWith(\"[...\") && seg.endsWith(\"]\")) {\r\n if (i !== segments.length - 1) {\r\n throw new Error(\r\n `Catch-all segment \"${seg}\" in \"${pattern}\" must be the last segment.`\r\n );\r\n }\r\n regexParts.push(\"(.+)\");\r\n continue;\r\n }\r\n\r\n // dynamic [id]\r\n if (seg.startsWith(\"[\") && seg.endsWith(\"]\")) {\r\n regexParts.push(\"([^/]+)\");\r\n continue;\r\n }\r\n\r\n // static segment\r\n const escaped = seg.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\r\n regexParts.push(escaped);\r\n }\r\n\r\n const regexSource = \"^/\" + regexParts.join(\"/\") + \"/?$\";\r\n return new RegExp(regexSource);\r\n}\r\n\r\nexport function matchRouteClient(\r\n pathWithSearch: string,\r\n routes: ClientRouteLoaded[]\r\n): ClientRouteMatch | null {\r\n const [pathname] = pathWithSearch.split(\"?\");\r\n for (const r of routes) {\r\n const regex = buildClientRegexFromPattern(r.pattern);\r\n const match = regex.exec(pathname);\r\n if (!match) continue;\r\n\r\n const params: Record<string, string> = {};\r\n r.paramNames.forEach((name, idx) => {\r\n params[name] = decodeURIComponent(match[idx + 1] || \"\");\r\n });\r\n\r\n return { route: r, params };\r\n }\r\n return null;\r\n}\r\n\r\n","export function applyMetadata(\r\n md?: { title?: string; description?: string } | null\r\n) {\r\n if (!md) return;\r\n\r\n if (md.title) {\r\n document.title = md.title;\r\n }\r\n\r\n if (md.description) {\r\n let meta = document.querySelector(\r\n 'meta[name=\"description\"]'\r\n ) as HTMLMetaElement | null;\r\n\r\n if (!meta) {\r\n meta = document.createElement(\"meta\");\r\n meta.name = \"description\";\r\n document.head.appendChild(meta);\r\n }\r\n\r\n meta.content = md.description;\r\n }\r\n}\r\n\r\n","import { useEffect, useState, useRef, useCallback } from \"react\";\r\nimport { RouterView } from \"./RouterView\";\r\nimport {\r\n navigate,\r\n createClickHandler,\r\n createPopStateHandler,\r\n type NavigationHandlers,\r\n} from \"./navigation\";\r\nimport { RouterContext } from \"./RouterContext\";\r\nimport { ROUTER_NAVIGATE_KEY } from \"./constants\";\r\nimport { applyMetadata } from \"./metadata\";\r\nimport type {\r\n RouteViewState,\r\n ClientRouteLoaded,\r\n} from \"./types\";\r\n\r\nexport interface AppShellProps {\r\n initialState: RouteViewState;\r\n routes: ClientRouteLoaded[];\r\n notFoundRoute: ClientRouteLoaded | null;\r\n errorRoute: ClientRouteLoaded | null;\r\n}\r\n\r\nexport function AppShell({\r\n initialState,\r\n routes,\r\n notFoundRoute,\r\n errorRoute,\r\n}: AppShellProps) {\r\n const [state, setState] = useState<RouteViewState>(initialState);\r\n const handlersRef = useRef<NavigationHandlers>({\r\n setState,\r\n routes,\r\n notFoundRoute,\r\n errorRoute,\r\n });\r\n\r\n useEffect(() => {\r\n handlersRef.current = {\r\n setState,\r\n routes,\r\n notFoundRoute,\r\n errorRoute,\r\n };\r\n }, [routes, notFoundRoute, errorRoute]);\r\n\r\n // Create navigate function for router context\r\n const handleNavigate = useCallback(\r\n async (\r\n nextUrl: string,\r\n options?: { revalidate?: boolean; replace?: boolean }\r\n ) => {\r\n await navigate(nextUrl, handlersRef.current, {\r\n revalidate: options?.revalidate,\r\n });\r\n },\r\n []\r\n );\r\n\r\n /**\r\n * SOLUTION: Expose navigate function globally as fallback\r\n * \r\n * During React hydration, components rendered in layouts may execute before\r\n * RouterContext is fully available. By exposing navigate globally, useRouter\r\n * can access it even when the context isn't ready yet, ensuring SPA navigation\r\n * works correctly from the first render.\r\n * \r\n * This is similar to how window.__FW_DATA__ is used for initial data.\r\n */\r\n useEffect(() => {\r\n if (typeof window !== \"undefined\") {\r\n (window as any)[ROUTER_NAVIGATE_KEY] = handleNavigate;\r\n return () => {\r\n delete (window as any)[ROUTER_NAVIGATE_KEY];\r\n };\r\n }\r\n }, [handleNavigate]);\r\n\r\n useEffect(() => {\r\n let isMounted = true;\r\n\r\n async function handleNavigateInternal(\r\n nextUrl: string,\r\n options?: { revalidate?: boolean }\r\n ) {\r\n if (!isMounted) return;\r\n await navigate(nextUrl, handlersRef.current, options);\r\n }\r\n\r\n const handleClick = createClickHandler(handleNavigateInternal);\r\n const handlePopState = createPopStateHandler(handleNavigateInternal);\r\n\r\n window.addEventListener(\"click\", handleClick, false);\r\n window.addEventListener(\"popstate\", handlePopState, false);\r\n\r\n return () => {\r\n isMounted = false;\r\n window.removeEventListener(\"click\", handleClick, false);\r\n window.removeEventListener(\"popstate\", handlePopState, false);\r\n };\r\n }, []);\r\n\r\n // Listen for data refresh events and update state when current route is revalidated\r\n useEffect(() => {\r\n const handleDataRefresh = () => {\r\n const freshData = (window as any)?.__FW_DATA__;\r\n \r\n if (!freshData) return;\r\n \r\n const currentPathname = window.location.pathname;\r\n const freshPathname = freshData.pathname;\r\n \r\n if (freshPathname === currentPathname) {\r\n if (freshData.metadata !== undefined) {\r\n applyMetadata(freshData.metadata);\r\n }\r\n \r\n setState((prevState) => ({\r\n ...prevState,\r\n props: freshData.props ?? prevState.props,\r\n params: freshData.params ?? prevState.params,\r\n }));\r\n }\r\n };\r\n\r\n window.addEventListener(\"fw-data-refresh\", handleDataRefresh);\r\n\r\n return () => {\r\n window.removeEventListener(\"fw-data-refresh\", handleDataRefresh);\r\n };\r\n }, [state.url]);\r\n\r\n const isError = state.route === errorRoute;\r\n const isNotFound = state.route === notFoundRoute;\r\n const routeType = isError ? \"error\" : isNotFound ? \"notfound\" : \"normal\";\r\n const routeKey = `${state.url}:${routeType}`;\r\n\r\n return (\r\n <RouterContext.Provider value={{ navigate: handleNavigate }}>\r\n <RouterView key={routeKey} state={state} />\r\n </RouterContext.Provider>\r\n );\r\n}\r\n\r\n","import type { RouteViewState } from \"./types\";\r\n\r\nexport function RouterView({ state }: { state: RouteViewState }) {\r\n if (!state.route) {\r\n // Don't show 404 if we're waiting for components to load\r\n if (state.components === null) {\r\n return null;\r\n }\r\n return <h1>404 - Route not found</h1>;\r\n }\r\n\r\n if (!state.components) {\r\n return null;\r\n }\r\n\r\n const { Page, layouts } = state.components;\r\n const { params, props } = state;\r\n\r\n let element = <Page params={params} {...props} />;\r\n\r\n const layoutChain = layouts.slice().reverse();\r\n for (const Layout of layoutChain) {\r\n element = (\r\n <Layout params={params} {...props}>\r\n {element}\r\n </Layout>\r\n );\r\n }\r\n\r\n return element;\r\n}\r\n\r\n","type RouteData = {\n ok: boolean;\n status: number;\n json: any;\n};\n\ntype CacheEntry =\n | { status: \"pending\"; promise: Promise<RouteData> }\n | { status: \"fulfilled\"; value: RouteData }\n | { status: \"rejected\"; error: any };\n\n// Use window to guarantee a single shared cache instance\n// across all bundles/modules\nconst CACHE_KEY = \"__FW_DATA_CACHE__\";\n\n// Maximum number of entries in the cache (LRU)\nconst MAX_CACHE_SIZE = 100;\n\ntype CacheStore = {\n data: Map<string, CacheEntry>;\n index: Map<string, Set<string>>; // pathBase -> Set of keys\n lru: string[]; // Ordered list: most recent at end, oldest at start\n};\n\nfunction getCacheStore(): CacheStore {\n if (typeof window !== \"undefined\") {\n if (!(window as any)[CACHE_KEY]) {\n (window as any)[CACHE_KEY] = {\n data: new Map<string, CacheEntry>(),\n index: new Map<string, Set<string>>(),\n lru: [],\n };\n }\n return (window as any)[CACHE_KEY];\n }\n // Fallback for SSR (though this shouldn't be used on the client)\n return {\n data: new Map<string, CacheEntry>(),\n index: new Map<string, Set<string>>(),\n lru: [],\n };\n}\n\nconst cacheStore = getCacheStore();\nconst dataCache = cacheStore.data;\nconst pathIndex = cacheStore.index;\nconst lru = cacheStore.lru;\n\n// Helper functions for cache management\n\n/**\n * Extract base path from a cache key (removes query params)\n */\nfunction extractPathBase(key: string): string {\n return key.split(\"?\")[0];\n}\n\n/**\n * Add key to path index\n */\nfunction addToIndex(key: string): void {\n const pathBase = extractPathBase(key);\n if (!pathIndex.has(pathBase)) {\n pathIndex.set(pathBase, new Set());\n }\n pathIndex.get(pathBase)!.add(key);\n}\n\n/**\n * Remove key from path index\n */\nfunction removeFromIndex(key: string): void {\n const pathBase = extractPathBase(key);\n const keys = pathIndex.get(pathBase);\n if (keys) {\n keys.delete(key);\n if (keys.size === 0) {\n pathIndex.delete(pathBase);\n }\n }\n}\n\n/**\n * Update LRU order - move key to end (most recent)\n */\nfunction updateLRU(key: string): void {\n const index = lru.indexOf(key);\n if (index !== -1) {\n lru.splice(index, 1);\n }\n lru.push(key);\n}\n\n/**\n * Remove oldest entries if cache exceeds MAX_CACHE_SIZE\n */\nfunction evictOldest(): void {\n while (lru.length >= MAX_CACHE_SIZE && lru.length > 0) {\n const oldestKey = lru.shift()!;\n dataCache.delete(oldestKey);\n removeFromIndex(oldestKey);\n }\n}\n\n/**\n * Set cache entry and maintain indexes\n */\nfunction setCacheEntry(key: string, entry: CacheEntry): void {\n const existingEntry = dataCache.get(key);\n const wasFulfilled = existingEntry?.status === \"fulfilled\";\n \n dataCache.set(key, entry);\n \n // Only track fulfilled entries in LRU and index (not pending/rejected)\n if (entry.status === \"fulfilled\") {\n // Add to index if it wasn't already fulfilled (new entry or transition from pending/rejected)\n if (!wasFulfilled) {\n addToIndex(key);\n }\n updateLRU(key);\n evictOldest();\n } else if (wasFulfilled) {\n // If entry was fulfilled and now isn't (transitioning to pending/rejected), remove from index\n removeFromIndex(key);\n }\n}\n\n/**\n * Delete cache entry and clean up indexes\n */\nfunction deleteCacheEntry(key: string): void {\n if (dataCache.has(key)) {\n dataCache.delete(key);\n removeFromIndex(key);\n const lruIndex = lru.indexOf(key);\n if (lruIndex !== -1) {\n lru.splice(lruIndex, 1);\n }\n }\n}\n\nfunction buildDataUrl(url: string): string {\n return url + (url.includes(\"?\") ? \"&\" : \"?\") + \"__fw_data=1\";\n}\n\nasync function fetchRouteDataOnce(url: string): Promise<RouteData> {\n const dataUrl = buildDataUrl(url);\n\n const res = await fetch(dataUrl, {\n headers: {\n \"x-fw-data\": \"1\",\n Accept: \"application/json\",\n },\n });\n\n let json: any = {};\n\n try {\n const text = await res.text();\n if (text) {\n json = JSON.parse(text);\n }\n } catch (parseError) {\n console.error(\n \"[client][cache] Failed to parse response as JSON:\",\n parseError\n );\n }\n\n const result: RouteData = {\n ok: res.ok,\n status: res.status,\n json,\n };\n\n return result;\n}\n\n/**\n * Revalidates route data by removing it from the cache.\n * The next time you navigate to this route, fresh data will be fetched from the server.\n * This is a client-side function and does not require a server-side revalidation.\n *\n * @param path - The route path to revalidate (e.g., '/posts/1' or '/posts/1?page=2')\n * If query params are not included, revalidates all variants of that route.\n *\n * @example\n * ```ts\n * // After saving something to the DB, revalidate the route\n * await saveToDatabase(data);\n * revalidatePath('/posts');\n * \n * // Revalidate a specific route with query params\n * revalidatePath('/posts?page=2');\n * ```\n */\nexport function revalidatePath(path: string): void {\n // Normalize the base path (without query params)\n const normalizedPath = path.split(\"?\")[0];\n const hasQueryParams = path.includes(\"?\");\n \n // Get all keys for this path base from index (O(1) lookup)\n const keysForPath = pathIndex.get(normalizedPath);\n \n if (!keysForPath || keysForPath.size === 0) {\n return; // No entries to revalidate\n }\n \n // If the path includes specific query params, extract them\n let specificQueryParams: string | undefined;\n if (hasQueryParams) {\n const queryPart = path.split(\"?\")[1];\n // Sort query params for consistent comparison\n specificQueryParams = queryPart\n .split(\"&\")\n .filter((p) => !p.startsWith(\"__fw_data=\"))\n .sort()\n .join(\"&\");\n }\n \n // Iterate only over keys for this path (much smaller set)\n const keysToDelete: string[] = [];\n for (const key of keysForPath) {\n // If specific query params were specified, check if they match\n if (hasQueryParams && specificQueryParams) {\n const [, keyQuery = \"\"] = key.split(\"?\");\n const keyQueryParams = keyQuery\n .split(\"&\")\n .filter((p) => !p.startsWith(\"__fw_data=\"))\n .sort()\n .join(\"&\");\n \n if (keyQueryParams === specificQueryParams) {\n keysToDelete.push(key);\n }\n } else {\n // If no specific query params, revalidate all variants\n keysToDelete.push(key);\n }\n }\n \n // Delete matching entries\n keysToDelete.forEach((key) => {\n deleteCacheEntry(key);\n });\n \n // If the revalidated path matches the current route, automatically refresh data\n if (typeof window !== \"undefined\") {\n const currentPathname = window.location.pathname;\n const currentSearch = window.location.search;\n const matchesCurrentPath = normalizedPath === currentPathname;\n \n if (matchesCurrentPath) {\n if (hasQueryParams && specificQueryParams) {\n const currentQueryParams = currentSearch\n .replace(\"?\", \"\")\n .split(\"&\")\n .filter((p) => !p.startsWith(\"__fw_data=\"))\n .sort()\n .join(\"&\");\n \n if (currentQueryParams === specificQueryParams) {\n revalidate().catch((err) => {\n console.error(\n \"[client][cache] Error revalidating current route:\",\n err\n );\n });\n }\n } else {\n revalidate().catch((err) => {\n console.error(\n \"[client][cache] Error revalidating current route:\",\n err\n );\n });\n }\n }\n }\n}\n\n/**\n * Revalidates and refreshes the current page data.\n * Similar to Next.js's `router.refresh()`.\n * \n * This function:\n * 1. Removes the current route from cache\n * 2. Fetches fresh data from the server\n * 3. Updates window.__FW_DATA__ with the new data\n * 4. Dispatches a 'fw-data-refresh' event for components to listen to\n * \n * @returns Promise that resolves with the fresh route data\n * \n * @example\n * ```ts\n * // Refresh current page data after a mutation\n * await revalidate();\n * ```\n */\nexport async function revalidate(): Promise<RouteData> {\n if (typeof window === \"undefined\") {\n throw new Error(\"revalidate() can only be called on the client\");\n }\n\n const pathname = window.location.pathname + window.location.search;\n \n // Revalidate the path (remove from cache)\n revalidatePath(pathname);\n \n // Fetch fresh data\n const freshData = await getRouteData(pathname, { revalidate: true });\n \n // Update window.__FW_DATA__ if it exists\n if ((window as any).__FW_DATA__ && freshData.ok && freshData.json) {\n const currentData = (window as any).__FW_DATA__;\n (window as any).__FW_DATA__ = {\n ...currentData,\n pathname: pathname.split(\"?\")[0],\n params: freshData.json.params || currentData.params || {},\n props: freshData.json.props || currentData.props || {},\n metadata: freshData.json.metadata ?? currentData.metadata ?? null,\n notFound: freshData.json.notFound ?? false,\n error: freshData.json.error ?? false,\n };\n \n // Dispatch event for components to listen to\n window.dispatchEvent(new CustomEvent(\"fw-data-refresh\", {\n detail: { data: freshData },\n }));\n }\n \n return freshData;\n}\n\n/**\n * @deprecated Use `revalidatePath()` instead. This function is kept for backwards compatibility.\n */\nexport function revalidateRouteData(url: string): void {\n revalidatePath(url);\n}\n\nexport function prefetchRouteData(url: string): void {\n const key = buildDataUrl(url);\n\n const cached = dataCache.get(key);\n\n if (cached && cached.status !== \"rejected\") {\n // Update LRU if it exists and is fulfilled\n if (cached.status === \"fulfilled\") {\n updateLRU(key);\n }\n return;\n }\n\n const promise = fetchRouteDataOnce(url)\n .then((value) => {\n setCacheEntry(key, { status: \"fulfilled\", value });\n return value;\n })\n .catch((error) => {\n console.error(\"[client][cache] Error prefetching route data:\", error);\n dataCache.set(key, { status: \"rejected\", error });\n throw error;\n });\n\n dataCache.set(key, { status: \"pending\", promise });\n}\n\nexport type GetRouteDataOptions = {\n /**\n * If true, forces revalidation of route data,\n * ignoring the cache and fetching fresh data from the server.\n * Similar to Next.js's `router.refresh()` behavior.\n */\n revalidate?: boolean;\n};\n\nexport async function getRouteData(\n url: string,\n options?: GetRouteDataOptions\n): Promise<RouteData> {\n const key = buildDataUrl(url);\n\n // If revalidation is requested, remove the entry from cache\n if (options?.revalidate) {\n deleteCacheEntry(key);\n }\n\n const entry = dataCache.get(key);\n\n if (entry) {\n if (entry.status === \"fulfilled\") {\n // Update LRU: mark as recently used\n updateLRU(key);\n return entry.value;\n }\n if (entry.status === \"pending\") {\n return entry.promise;\n }\n }\n\n // No entry in cache, fetch it\n const promise = fetchRouteDataOnce(url)\n .then((value) => {\n setCacheEntry(key, { status: \"fulfilled\", value });\n return value;\n })\n .catch((error) => {\n console.error(\"[client][cache] Error fetching route data:\", error);\n dataCache.set(key, { status: \"rejected\", error });\n throw error;\n });\n\n dataCache.set(key, { status: \"pending\", promise });\n return promise;\n}\n","import { getRouteData } from \"../../react/cache/index\";\r\nimport { matchRouteClient } from \"./route-matcher\";\r\nimport { applyMetadata } from \"./metadata\";\r\nimport { setWindowData, getCurrentTheme, setRouterData } from \"./window-data\";\r\nimport type {\r\n ClientRouteLoaded,\r\n RouteViewState,\r\n InitialData,\r\n RouterData,\r\n} from \"./types\";\r\n\r\nexport type NavigationHandlers = {\r\n setState: (state: RouteViewState) => void;\r\n routes: ClientRouteLoaded[];\r\n notFoundRoute: ClientRouteLoaded | null;\r\n errorRoute: ClientRouteLoaded | null;\r\n};\r\n\r\nasync function handleErrorRoute(\r\n nextUrl: string,\r\n json: any,\r\n errorRoute: ClientRouteLoaded,\r\n setState: (state: RouteViewState) => void\r\n): Promise<boolean> {\r\n try {\r\n const components = await errorRoute.load();\r\n \r\n // Get theme: prioritize cookie, then server, then window data, then default\r\n let theme: string = \"light\";\r\n if (typeof document !== \"undefined\") {\r\n const cookieMatch = document.cookie.match(/theme=([^;]+)/);\r\n if (cookieMatch) {\r\n theme = cookieMatch[1];\r\n } else if (json.theme) {\r\n theme = json.theme;\r\n } else {\r\n const currentTheme = getCurrentTheme();\r\n if (currentTheme) theme = currentTheme;\r\n }\r\n } else if (json.theme) {\r\n theme = json.theme;\r\n }\r\n \r\n const errorProps = {\r\n ...(json.props || {\r\n error: json.message || \"An error occurred\",\r\n }),\r\n theme,\r\n };\r\n\r\n const windowData: InitialData = {\r\n pathname: nextUrl,\r\n params: json.params || {},\r\n props: errorProps,\r\n metadata: json.metadata ?? null,\r\n theme,\r\n notFound: false,\r\n error: true,\r\n };\r\n\r\n setWindowData(windowData);\r\n\r\n // Update routerData\r\n const url = new URL(nextUrl, typeof window !== \"undefined\" ? window.location.origin : \"http://localhost\");\r\n const routerData: RouterData = {\r\n pathname: url.pathname,\r\n params: json.params || {},\r\n searchParams: Object.fromEntries(url.searchParams.entries()),\r\n };\r\n setRouterData(routerData);\r\n\r\n setState({\r\n url: nextUrl,\r\n route: errorRoute,\r\n params: json.params || {},\r\n components,\r\n props: errorProps,\r\n });\r\n return true;\r\n } catch (loadError) {\r\n console.error(\r\n \"[client] Error loading error route components:\",\r\n loadError\r\n );\r\n window.location.href = nextUrl;\r\n return false;\r\n }\r\n}\r\n\r\nasync function handleNotFoundRoute(\r\n nextUrl: string,\r\n json: any,\r\n notFoundRoute: ClientRouteLoaded | null,\r\n setState: (state: RouteViewState) => void\r\n): Promise<void> {\r\n // Get theme: prioritize cookie, then server, then window data, then default\r\n let theme: string = \"light\";\r\n if (typeof document !== \"undefined\") {\r\n const cookieMatch = document.cookie.match(/theme=([^;]+)/);\r\n if (cookieMatch) {\r\n theme = cookieMatch[1];\r\n } else if (json.theme) {\r\n theme = json.theme;\r\n } else {\r\n const currentTheme = getCurrentTheme();\r\n if (currentTheme) theme = currentTheme;\r\n }\r\n } else if (json.theme) {\r\n theme = json.theme;\r\n }\r\n \r\n const notFoundProps = {\r\n ...(json.props ?? {}),\r\n theme,\r\n };\r\n\r\n const windowData: InitialData = {\r\n pathname: nextUrl,\r\n params: {},\r\n props: notFoundProps,\r\n metadata: json.metadata ?? null,\r\n theme,\r\n notFound: true,\r\n error: false,\r\n };\r\n\r\n setWindowData(windowData);\r\n\r\n // Update routerData\r\n const url = new URL(nextUrl, typeof window !== \"undefined\" ? window.location.origin : \"http://localhost\");\r\n const routerData: RouterData = {\r\n pathname: url.pathname,\r\n params: {},\r\n searchParams: Object.fromEntries(url.searchParams.entries()),\r\n };\r\n setRouterData(routerData);\r\n\r\n if (notFoundRoute) {\r\n const components = await notFoundRoute.load();\r\n setState({\r\n url: nextUrl,\r\n route: notFoundRoute,\r\n params: {},\r\n components,\r\n props: notFoundProps,\r\n });\r\n } else {\r\n setState({\r\n url: nextUrl,\r\n route: null,\r\n params: {},\r\n components: null,\r\n props: {},\r\n });\r\n }\r\n}\r\n\r\nasync function handleNormalRoute(\r\n nextUrl: string,\r\n json: any,\r\n routes: ClientRouteLoaded[],\r\n setState: (state: RouteViewState) => void\r\n): Promise<boolean> {\r\n applyMetadata(json.metadata ?? null);\r\n \r\n // Get theme: prioritize cookie (source of truth), then server response, then window data, then default\r\n // Cookie is the source of truth because it persists across navigation\r\n let theme: string = \"light\"; // Default\r\n if (typeof document !== \"undefined\") {\r\n const cookieMatch = document.cookie.match(/theme=([^;]+)/);\r\n if (cookieMatch) {\r\n theme = cookieMatch[1];\r\n } else if (json.theme) {\r\n theme = json.theme;\r\n } else {\r\n const currentTheme = getCurrentTheme();\r\n if (currentTheme) {\r\n theme = currentTheme;\r\n }\r\n }\r\n } else if (json.theme) {\r\n theme = json.theme;\r\n }\r\n \r\n // Include theme in props so layouts receive it during SPA navigation\r\n const newProps = {\r\n ...(json.props ?? {}),\r\n theme, // Always include theme\r\n };\r\n\r\n const matched = matchRouteClient(nextUrl, routes);\r\n\r\n if (!matched) {\r\n window.location.href = nextUrl;\r\n return false;\r\n }\r\n\r\n const windowData: InitialData = {\r\n pathname: nextUrl,\r\n params: matched.params,\r\n props: newProps,\r\n metadata: json.metadata ?? null,\r\n theme,\r\n notFound: false,\r\n error: false,\r\n };\r\n\r\n setWindowData(windowData);\r\n\r\n // Update routerData\r\n const url = new URL(nextUrl, typeof window !== \"undefined\" ? window.location.origin : \"http://localhost\");\r\n const routerData: RouterData = {\r\n pathname: url.pathname,\r\n params: matched.params,\r\n searchParams: Object.fromEntries(url.searchParams.entries()),\r\n };\r\n setRouterData(routerData);\r\n\r\n const components = await matched.route.load();\r\n\r\n window.scrollTo({\r\n top: 0,\r\n behavior: \"smooth\",\r\n });\r\n\r\n setState({\r\n url: nextUrl,\r\n route: matched.route,\r\n params: matched.params,\r\n components,\r\n props: newProps,\r\n });\r\n\r\n return true;\r\n}\r\n\r\nexport type NavigateOptions = {\r\n /**\r\n * If true, forces revalidation of route data,\r\n * ignoring the cache and fetching fresh data from the server.\r\n * Similar to Next.js's `router.refresh()` behavior.\r\n */\r\n revalidate?: boolean;\r\n};\r\n\r\nexport async function navigate(\r\n nextUrl: string,\r\n handlers: NavigationHandlers,\r\n options?: NavigateOptions\r\n): Promise<void> {\r\n const { setState, routes, notFoundRoute, errorRoute } = handlers;\r\n\r\n try {\r\n const { ok, json } = await getRouteData(nextUrl, {\r\n revalidate: options?.revalidate,\r\n });\r\n\r\n if (json && json.error) {\r\n if (errorRoute) {\r\n const handled = await handleErrorRoute(\r\n nextUrl,\r\n json,\r\n errorRoute,\r\n setState\r\n );\r\n if (handled) return;\r\n } else {\r\n console.warn(\r\n \"[client] Error route not available, reloading page.\",\r\n errorRoute\r\n );\r\n window.location.href = nextUrl;\r\n return;\r\n }\r\n }\r\n\r\n // 🔴 HTTP error (404/500/etc)\r\n if (!ok) {\r\n if (json && (json as any).redirect) {\r\n window.location.href = (json as any).redirect.destination;\r\n return;\r\n }\r\n window.location.href = nextUrl;\r\n return;\r\n }\r\n\r\n // Redirect via JSON\r\n if (json.redirect) {\r\n window.location.href = json.redirect.destination;\r\n return;\r\n }\r\n\r\n // Handle notFound\r\n if (json.notFound) {\r\n await handleNotFoundRoute(nextUrl, json, notFoundRoute, setState);\r\n return;\r\n }\r\n\r\n // Normal route\r\n await handleNormalRoute(nextUrl, json, routes, setState);\r\n } catch (err) {\r\n console.error(\"[client] Error fetching FW data:\", err);\r\n window.location.href = nextUrl;\r\n }\r\n}\r\n\r\nexport function createClickHandler(\r\n navigate: (url: string, options?: NavigateOptions) => void\r\n): (ev: MouseEvent) => void {\r\n return function handleClick(ev: MouseEvent) {\r\n try {\r\n // Exit early if event was already prevented\r\n if (ev.defaultPrevented) return;\r\n \r\n // Verify it's a real mouse event (not synthetic or keyboard)\r\n if (ev.type !== \"click\") return;\r\n if (ev.button !== 0) return;\r\n if (ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey) return;\r\n \r\n // Verify event has valid coordinates (real mouse events have them)\r\n const target = ev.target as HTMLElement | null;\r\n if (ev.clientX === 0 && ev.clientY === 0 && ev.detail === 0) {\r\n // Could be a synthetic event, be more cautious\r\n if (target) {\r\n const tagName = target.tagName.toLowerCase();\r\n if (tagName === \"input\" || tagName === \"textarea\" || tagName === \"button\" || tagName === \"select\") {\r\n return; // It's an input, don't process synthetic events\r\n }\r\n }\r\n }\r\n\r\n if (!target) return;\r\n\r\n // Check FIRST if target is an interactive element (faster)\r\n const tagName = target.tagName.toLowerCase();\r\n if (\r\n tagName === \"input\" ||\r\n tagName === \"textarea\" ||\r\n tagName === \"button\" ||\r\n tagName === \"select\" ||\r\n target.isContentEditable ||\r\n target.getAttribute(\"contenteditable\") === \"true\"\r\n ) {\r\n return; // It's an interactive element, don't process\r\n }\r\n\r\n // Check if it's inside an interactive element using closest (more efficient than composedPath)\r\n const interactiveParent = target.closest(\"input, textarea, button, select, [contenteditable], label\");\r\n if (interactiveParent) {\r\n // If parent is a label, check if it has an associated control\r\n if (interactiveParent.tagName.toLowerCase() === \"label\") {\r\n const label = interactiveParent as HTMLLabelElement;\r\n if (label.control) {\r\n return; // Label has an associated control (input, etc)\r\n }\r\n } else {\r\n return; // It's inside an interactive element\r\n }\r\n }\r\n\r\n // Only search for anchor if it's not an interactive element\r\n const anchor = target.closest(\"a[href]\") as HTMLAnchorElement | null;\r\n if (!anchor) return;\r\n\r\n const href = anchor.getAttribute(\"href\");\r\n if (!href) return;\r\n if (href.startsWith(\"#\")) return;\r\n\r\n const url = new URL(href, window.location.href);\r\n if (url.origin !== window.location.origin) return;\r\n if (anchor.target && anchor.target !== \"_self\") return;\r\n\r\n ev.preventDefault();\r\n\r\n const nextUrl = url.pathname + url.search;\r\n const currentUrl = window.location.pathname + window.location.search;\r\n if (nextUrl === currentUrl) return;\r\n\r\n // Detect if link has data-revalidate to force revalidation\r\n const shouldRevalidate =\r\n anchor.hasAttribute(\"data-revalidate\") &&\r\n anchor.getAttribute(\"data-revalidate\") !== \"false\";\r\n\r\n window.history.pushState({}, \"\", nextUrl);\r\n navigate(nextUrl, shouldRevalidate ? { revalidate: true } : undefined);\r\n } catch (error) {\r\n // Silenciar errores para evitar bloquear el navegador\r\n console.error(\"[navigation] Error in click handler:\", error);\r\n }\r\n };\r\n}\r\n\r\nexport function createPopStateHandler(\r\n navigate: (url: string, options?: NavigateOptions) => void\r\n): () => void {\r\n return function handlePopState() {\r\n const nextUrl = window.location.pathname + window.location.search;\r\n navigate(nextUrl);\r\n };\r\n}\r\n\r\n","import { createContext, useContext } from \"react\";\r\n\r\nexport type NavigateFunction = (\r\n url: string,\r\n options?: { revalidate?: boolean; replace?: boolean }\r\n) => Promise<void>;\r\n\r\nexport interface RouterContextValue {\r\n navigate: NavigateFunction;\r\n}\r\n\r\nexport const RouterContext = createContext<RouterContextValue | null>(null);\r\n\r\nexport function useRouterContext(): RouterContextValue {\r\n const context = useContext(RouterContext);\r\n if (!context) {\r\n throw new Error(\r\n \"useRouter must be used within a RouterProvider. Make sure you're using it inside a Loly app.\"\r\n );\r\n }\r\n return context;\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA4B;;;ACCrB,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AACxB,IAAM,mBAAmB;AAEzB,IAAM,sBAAsB;;;ACF5B,SAAS,gBAAoC;AAClD,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO;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Name","import_jsx_runtime","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../modules/runtime/client/index.tsx","../modules/runtime/client/bootstrap.tsx","../modules/runtime/client/constants.ts","../modules/runtime/client/window-data.ts","../modules/runtime/client/route-matcher.ts","../modules/runtime/client/metadata.ts","../modules/runtime/client/AppShell.tsx","../modules/runtime/client/RouterView.tsx","../modules/react/cache/client-data-cache/index.ts","../modules/runtime/client/navigation.ts","../modules/runtime/client/RouterContext.tsx"],"sourcesContent":["// Re-export all public types and functions\r\nexport type {\r\n ClientLoadedComponents,\r\n ClientRouteLoaded,\r\n ClientRouteMatch,\r\n RouteViewState,\r\n InitialData,\r\n} from \"./types\";\r\n\r\nexport { bootstrapClient } from \"./bootstrap\";\r\nexport type { AppShellProps } from \"./AppShell\";\r\n","import { hydrateRoot } from \"react-dom/client\";\r\nimport { APP_CONTAINER_ID } from \"./constants\";\r\nimport { getWindowData, getRouterData, setRouterData } from \"./window-data\";\r\nimport { matchRouteClient } from \"./route-matcher\";\r\nimport { applyMetadata } from \"./metadata\";\r\nimport { AppShell } from \"./AppShell\";\r\nimport type {\r\n InitialData,\r\n ClientRouteLoaded,\r\n RouteViewState,\r\n} from \"./types\";\r\n\r\nexport async function loadInitialRoute(\r\n initialUrl: string,\r\n initialData: InitialData | null,\r\n routes: ClientRouteLoaded[],\r\n notFoundRoute: ClientRouteLoaded | null,\r\n errorRoute: ClientRouteLoaded | null\r\n): Promise<RouteViewState> {\r\n const isInitialNotFound = initialData?.notFound === true;\r\n const isInitialError = initialData?.error === true;\r\n\r\n let initialRoute: ClientRouteLoaded | null = null;\r\n let initialParams: Record<string, string> = {};\r\n let initialComponents = null;\r\n\r\n if (isInitialError && errorRoute) {\r\n initialRoute = errorRoute;\r\n initialParams = initialData?.params ?? {};\r\n initialComponents = await errorRoute.load();\r\n } else if (isInitialNotFound && notFoundRoute) {\r\n initialRoute = notFoundRoute;\r\n initialParams = {};\r\n initialComponents = await notFoundRoute.load();\r\n } else {\r\n const match = matchRouteClient(initialUrl, routes);\r\n if (match) {\r\n initialRoute = match.route;\r\n initialParams = match.params;\r\n initialComponents = await match.route.load();\r\n } else if (notFoundRoute) {\r\n initialRoute = notFoundRoute;\r\n initialParams = {};\r\n initialComponents = await notFoundRoute.load();\r\n } else {\r\n console.warn(\r\n `[client] No route match found for ${initialUrl}. Available routes:`,\r\n routes.map((r) => r.pattern)\r\n );\r\n }\r\n }\r\n\r\n return {\r\n url: initialUrl,\r\n route: initialRoute,\r\n params: initialParams,\r\n components: initialComponents,\r\n props: initialData?.props ?? {},\r\n };\r\n}\r\n\r\n/**\r\n * Sets up hot reload via Server-Sent Events (SSE) in development mode.\r\n * Listens for file changes and reloads the page when needed.\r\n */\r\nfunction setupHotReload(): void {\r\n // Only enable hot reload in development mode\r\n // In production, process.env.NODE_ENV is replaced by DefinePlugin with \"production\"\r\n // @ts-ignore - process.env.NODE_ENV is replaced by DefinePlugin at build time\r\n // DefinePlugin always defines process.env.NODE_ENV, so this should always be replaced\r\n const nodeEnv: string = (typeof process !== \"undefined\" && (process as any).env?.NODE_ENV) || \"production\";\r\n const isDev = nodeEnv !== \"production\";\r\n \r\n if (!isDev) {\r\n return; // Skip hot reload in production\r\n }\r\n\r\n try {\r\n console.log(\"[hot-reload] Attempting to connect to /__fw/hot...\");\r\n const eventSource = new EventSource(\"/__fw/hot\");\r\n let reloadTimeout: ReturnType<typeof setTimeout> | null = null;\r\n\r\n eventSource.addEventListener(\"message\", (event) => {\r\n const data = event.data;\r\n if (data && data.startsWith(\"reload:\")) {\r\n const filePath = data.slice(7);\r\n console.log(`[hot-reload] File changed: ${filePath}`);\r\n\r\n // Clear any pending reload\r\n if (reloadTimeout) {\r\n clearTimeout(reloadTimeout);\r\n }\r\n\r\n // Wait a bit for the bundler to finish compiling and files to be written\r\n // Increased timeout to ensure everything is ready\r\n reloadTimeout = setTimeout(() => {\r\n console.log(\"[hot-reload] Reloading page...\");\r\n // Force reload without cache to ensure we get the latest files\r\n window.location.reload();\r\n }, 500);\r\n }\r\n });\r\n\r\n eventSource.addEventListener(\"ping\", () => {\r\n console.log(\"[hot-reload] ✓ Connected to hot reload server\");\r\n });\r\n\r\n eventSource.onopen = () => {\r\n console.log(\"[hot-reload] ✓ SSE connection opened\");\r\n };\r\n\r\n eventSource.onerror = (error) => {\r\n // Log connection state for debugging\r\n const states = [\"CONNECTING\", \"OPEN\", \"CLOSED\"];\r\n const state = states[eventSource.readyState] || \"UNKNOWN\";\r\n \r\n if (eventSource.readyState === EventSource.CONNECTING) {\r\n // Still connecting, might be normal\r\n console.log(\"[hot-reload] Connecting...\");\r\n } else if (eventSource.readyState === EventSource.OPEN) {\r\n console.warn(\"[hot-reload] Connection error (but connection is open):\", error);\r\n } else {\r\n // Connection closed - might be production mode or server not running\r\n console.log(\"[hot-reload] Connection closed (readyState:\", state, \")\");\r\n }\r\n // EventSource automatically reconnects, so we don't need to do anything\r\n };\r\n } catch (error) {\r\n // Fail silently if EventSource is not supported\r\n console.log(\"[hot-reload] EventSource not supported or error:\", error);\r\n }\r\n}\r\n\r\n/**\r\n * Bootstraps the client-side application.\r\n *\r\n * @param routes - Array of client routes\r\n * @param notFoundRoute - Not-found route definition\r\n * @param errorRoute - Error route definition\r\n */\r\nexport function bootstrapClient(\r\n routes: ClientRouteLoaded[],\r\n notFoundRoute: ClientRouteLoaded | null,\r\n errorRoute: ClientRouteLoaded | null = null\r\n): void {\r\n // Set up hot reload in development mode\r\n console.log(\"[client] Bootstrap starting, setting up hot reload...\");\r\n setupHotReload();\r\n\r\n (async function bootstrap() {\r\n const container = document.getElementById(APP_CONTAINER_ID);\r\n const initialData = getWindowData();\r\n\r\n if (!container) {\r\n console.error(`Container #${APP_CONTAINER_ID} not found for hydration`);\r\n return;\r\n }\r\n\r\n const initialUrl = window.location.pathname + window.location.search;\r\n\r\n // Initialize routerData from server if available, otherwise build from URL\r\n let routerData = getRouterData();\r\n if (!routerData) {\r\n const url = new URL(initialUrl, window.location.origin);\r\n routerData = {\r\n pathname: url.pathname,\r\n params: initialData?.params || {},\r\n searchParams: Object.fromEntries(url.searchParams.entries()),\r\n };\r\n setRouterData(routerData);\r\n }\r\n\r\n try {\r\n const initialState = await loadInitialRoute(\r\n initialUrl,\r\n initialData,\r\n routes,\r\n notFoundRoute,\r\n errorRoute\r\n );\r\n\r\n if (initialData?.metadata) {\r\n applyMetadata(initialData.metadata);\r\n }\r\n\r\n hydrateRoot(\r\n container,\r\n <AppShell\r\n initialState={initialState}\r\n routes={routes}\r\n notFoundRoute={notFoundRoute}\r\n errorRoute={errorRoute}\r\n />\r\n );\r\n } catch (error) {\r\n console.error(\r\n \"[client] Error loading initial route components for\",\r\n initialUrl,\r\n error\r\n );\r\n\r\n window.location.reload();\r\n }\r\n })();\r\n}\r\n\r\n","// Client-side constants (hardcoded to avoid alias resolution issues in Rspack)\r\nexport const WINDOW_DATA_KEY = \"__FW_DATA__\";\r\nexport const ROUTER_DATA_KEY = \"__LOLY_ROUTER_DATA__\";\r\nexport const APP_CONTAINER_ID = \"__app\";\r\n// Global key for navigate function fallback (exposed by AppShell for hydration timing issues)\r\nexport const ROUTER_NAVIGATE_KEY = \"__LOLY_ROUTER_NAVIGATE__\";\r\n\r\n","import { WINDOW_DATA_KEY, ROUTER_DATA_KEY } from \"./constants\";\r\nimport type { InitialData, RouterData } from \"./types\";\r\n\r\nexport function getWindowData(): InitialData | null {\r\n if (typeof window === \"undefined\") {\r\n return null;\r\n }\r\n return ((window as any)[WINDOW_DATA_KEY] as InitialData | undefined) ?? null;\r\n}\r\n\r\nexport function getRouterData(): RouterData | null {\r\n if (typeof window === \"undefined\") {\r\n return null;\r\n }\r\n return ((window as any)[ROUTER_DATA_KEY] as RouterData | undefined) ?? null;\r\n}\r\n\r\nexport function setWindowData(data: InitialData): void {\r\n (window as any)[WINDOW_DATA_KEY] = data;\r\n \r\n // Dispatch event for components to listen to (e.g. ThemeProvider)\r\n // This ensures components update when navigating in SPA mode\r\n if (typeof window !== \"undefined\") {\r\n window.dispatchEvent(\r\n new CustomEvent(\"fw-data-refresh\", {\r\n detail: { data },\r\n })\r\n );\r\n }\r\n}\r\n\r\nexport function setRouterData(data: RouterData): void {\r\n (window as any)[ROUTER_DATA_KEY] = data;\r\n \r\n // Dispatch event for router data updates\r\n if (typeof window !== \"undefined\") {\r\n window.dispatchEvent(\r\n new CustomEvent(\"fw-router-data-refresh\", {\r\n detail: { data },\r\n })\r\n );\r\n }\r\n}\r\n\r\nexport function getCurrentTheme(): string | null {\r\n return getWindowData()?.theme ?? null;\r\n}\r\n\r\n","import type { ClientRouteLoaded, ClientRouteMatch } from \"./types\";\r\n\r\nexport function buildClientRegexFromPattern(pattern: string): RegExp {\r\n const segments = pattern.split(\"/\").filter(Boolean);\r\n const regexParts: string[] = [];\r\n\r\n for (let i = 0; i < segments.length; i++) {\r\n const seg = segments[i];\r\n\r\n // catch-all [...slug]\r\n if (seg.startsWith(\"[...\") && seg.endsWith(\"]\")) {\r\n if (i !== segments.length - 1) {\r\n throw new Error(\r\n `Catch-all segment \"${seg}\" in \"${pattern}\" must be the last segment.`\r\n );\r\n }\r\n regexParts.push(\"(.+)\");\r\n continue;\r\n }\r\n\r\n // dynamic [id]\r\n if (seg.startsWith(\"[\") && seg.endsWith(\"]\")) {\r\n regexParts.push(\"([^/]+)\");\r\n continue;\r\n }\r\n\r\n // static segment\r\n const escaped = seg.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\r\n regexParts.push(escaped);\r\n }\r\n\r\n const regexSource = \"^/\" + regexParts.join(\"/\") + \"/?$\";\r\n return new RegExp(regexSource);\r\n}\r\n\r\nexport function matchRouteClient(\r\n pathWithSearch: string,\r\n routes: ClientRouteLoaded[]\r\n): ClientRouteMatch | null {\r\n const [pathname] = pathWithSearch.split(\"?\");\r\n for (const r of routes) {\r\n const regex = buildClientRegexFromPattern(r.pattern);\r\n const match = regex.exec(pathname);\r\n if (!match) continue;\r\n\r\n const params: Record<string, string> = {};\r\n r.paramNames.forEach((name, idx) => {\r\n params[name] = decodeURIComponent(match[idx + 1] || \"\");\r\n });\r\n\r\n return { route: r, params };\r\n }\r\n return null;\r\n}\r\n\r\n","export function applyMetadata(\r\n md?: { title?: string; description?: string } | null\r\n) {\r\n if (!md) return;\r\n\r\n if (md.title) {\r\n document.title = md.title;\r\n }\r\n\r\n if (md.description) {\r\n let meta = document.querySelector(\r\n 'meta[name=\"description\"]'\r\n ) as HTMLMetaElement | null;\r\n\r\n if (!meta) {\r\n meta = document.createElement(\"meta\");\r\n meta.name = \"description\";\r\n document.head.appendChild(meta);\r\n }\r\n\r\n meta.content = md.description;\r\n }\r\n}\r\n\r\n","import { useEffect, useState, useRef, useCallback } from \"react\";\r\nimport { RouterView } from \"./RouterView\";\r\nimport {\r\n navigate,\r\n createClickHandler,\r\n createPopStateHandler,\r\n type NavigationHandlers,\r\n} from \"./navigation\";\r\nimport { RouterContext } from \"./RouterContext\";\r\nimport { ROUTER_NAVIGATE_KEY } from \"./constants\";\r\nimport { applyMetadata } from \"./metadata\";\r\nimport type {\r\n RouteViewState,\r\n ClientRouteLoaded,\r\n} from \"./types\";\r\n\r\nexport interface AppShellProps {\r\n initialState: RouteViewState;\r\n routes: ClientRouteLoaded[];\r\n notFoundRoute: ClientRouteLoaded | null;\r\n errorRoute: ClientRouteLoaded | null;\r\n}\r\n\r\nexport function AppShell({\r\n initialState,\r\n routes,\r\n notFoundRoute,\r\n errorRoute,\r\n}: AppShellProps) {\r\n const [state, setState] = useState<RouteViewState>(initialState);\r\n const handlersRef = useRef<NavigationHandlers>({\r\n setState,\r\n routes,\r\n notFoundRoute,\r\n errorRoute,\r\n });\r\n\r\n useEffect(() => {\r\n handlersRef.current = {\r\n setState,\r\n routes,\r\n notFoundRoute,\r\n errorRoute,\r\n };\r\n }, [routes, notFoundRoute, errorRoute]);\r\n\r\n // Create navigate function for router context\r\n const handleNavigate = useCallback(\r\n async (\r\n nextUrl: string,\r\n options?: { revalidate?: boolean; replace?: boolean }\r\n ) => {\r\n await navigate(nextUrl, handlersRef.current, {\r\n revalidate: options?.revalidate,\r\n });\r\n },\r\n []\r\n );\r\n\r\n /**\r\n * SOLUTION: Expose navigate function globally as fallback\r\n * \r\n * During React hydration, components rendered in layouts may execute before\r\n * RouterContext is fully available. By exposing navigate globally, useRouter\r\n * can access it even when the context isn't ready yet, ensuring SPA navigation\r\n * works correctly from the first render.\r\n * \r\n * This is similar to how window.__FW_DATA__ is used for initial data.\r\n */\r\n useEffect(() => {\r\n if (typeof window !== \"undefined\") {\r\n (window as any)[ROUTER_NAVIGATE_KEY] = handleNavigate;\r\n return () => {\r\n delete (window as any)[ROUTER_NAVIGATE_KEY];\r\n };\r\n }\r\n }, [handleNavigate]);\r\n\r\n useEffect(() => {\r\n let isMounted = true;\r\n\r\n async function handleNavigateInternal(\r\n nextUrl: string,\r\n options?: { revalidate?: boolean }\r\n ) {\r\n if (!isMounted) return;\r\n await navigate(nextUrl, handlersRef.current, options);\r\n }\r\n\r\n const handleClick = createClickHandler(handleNavigateInternal);\r\n const handlePopState = createPopStateHandler(handleNavigateInternal);\r\n\r\n window.addEventListener(\"click\", handleClick, false);\r\n window.addEventListener(\"popstate\", handlePopState, false);\r\n\r\n return () => {\r\n isMounted = false;\r\n window.removeEventListener(\"click\", handleClick, false);\r\n window.removeEventListener(\"popstate\", handlePopState, false);\r\n };\r\n }, []);\r\n\r\n // Listen for data refresh events and update state when current route is revalidated\r\n useEffect(() => {\r\n const handleDataRefresh = () => {\r\n const freshData = (window as any)?.__FW_DATA__;\r\n \r\n if (!freshData) return;\r\n \r\n const currentPathname = window.location.pathname;\r\n const freshPathname = freshData.pathname;\r\n \r\n if (freshPathname === currentPathname) {\r\n if (freshData.metadata !== undefined) {\r\n applyMetadata(freshData.metadata);\r\n }\r\n \r\n setState((prevState) => ({\r\n ...prevState,\r\n props: freshData.props ?? prevState.props,\r\n params: freshData.params ?? prevState.params,\r\n }));\r\n }\r\n };\r\n\r\n window.addEventListener(\"fw-data-refresh\", handleDataRefresh);\r\n\r\n return () => {\r\n window.removeEventListener(\"fw-data-refresh\", handleDataRefresh);\r\n };\r\n }, [state.url]);\r\n\r\n const isError = state.route === errorRoute;\r\n const isNotFound = state.route === notFoundRoute;\r\n const routeType = isError ? \"error\" : isNotFound ? \"notfound\" : \"normal\";\r\n const routeKey = `${state.url}:${routeType}`;\r\n\r\n return (\r\n <RouterContext.Provider value={{ navigate: handleNavigate }}>\r\n <RouterView key={routeKey} state={state} />\r\n </RouterContext.Provider>\r\n );\r\n}\r\n\r\n","import type { RouteViewState } from \"./types\";\r\n\r\nexport function RouterView({ state }: { state: RouteViewState }) {\r\n if (!state.route) {\r\n // Don't show 404 if we're waiting for components to load\r\n if (state.components === null) {\r\n return null;\r\n }\r\n return <h1>404 - Route not found</h1>;\r\n }\r\n\r\n if (!state.components) {\r\n return null;\r\n }\r\n\r\n const { Page, layouts } = state.components;\r\n const { params, props } = state;\r\n\r\n let element = <Page params={params} {...props} />;\r\n\r\n const layoutChain = layouts.slice().reverse();\r\n for (const Layout of layoutChain) {\r\n element = (\r\n <Layout params={params} {...props}>\r\n {element}\r\n </Layout>\r\n );\r\n }\r\n\r\n return element;\r\n}\r\n\r\n","type RouteData = {\n ok: boolean;\n status: number;\n json: any;\n};\n\ntype CacheEntry =\n | { status: \"pending\"; promise: Promise<RouteData> }\n | { status: \"fulfilled\"; value: RouteData }\n | { status: \"rejected\"; error: any };\n\n// Use window to guarantee a single shared cache instance\n// across all bundles/modules\nconst CACHE_KEY = \"__FW_DATA_CACHE__\";\n\n// Maximum number of entries in the cache (LRU)\nconst MAX_CACHE_SIZE = 100;\n\ntype CacheStore = {\n data: Map<string, CacheEntry>;\n index: Map<string, Set<string>>; // pathBase -> Set of keys\n lru: string[]; // Ordered list: most recent at end, oldest at start\n};\n\nfunction getCacheStore(): CacheStore {\n if (typeof window !== \"undefined\") {\n if (!(window as any)[CACHE_KEY]) {\n (window as any)[CACHE_KEY] = {\n data: new Map<string, CacheEntry>(),\n index: new Map<string, Set<string>>(),\n lru: [],\n };\n }\n return (window as any)[CACHE_KEY];\n }\n // Fallback for SSR (though this shouldn't be used on the client)\n return {\n data: new Map<string, CacheEntry>(),\n index: new Map<string, Set<string>>(),\n lru: [],\n };\n}\n\nconst cacheStore = getCacheStore();\nconst dataCache = cacheStore.data;\nconst pathIndex = cacheStore.index;\nconst lru = cacheStore.lru;\n\n// Helper functions for cache management\n\n/**\n * Extract base path from a cache key (removes query params)\n */\nfunction extractPathBase(key: string): string {\n return key.split(\"?\")[0];\n}\n\n/**\n * Add key to path index\n */\nfunction addToIndex(key: string): void {\n const pathBase = extractPathBase(key);\n if (!pathIndex.has(pathBase)) {\n pathIndex.set(pathBase, new Set());\n }\n pathIndex.get(pathBase)!.add(key);\n}\n\n/**\n * Remove key from path index\n */\nfunction removeFromIndex(key: string): void {\n const pathBase = extractPathBase(key);\n const keys = pathIndex.get(pathBase);\n if (keys) {\n keys.delete(key);\n if (keys.size === 0) {\n pathIndex.delete(pathBase);\n }\n }\n}\n\n/**\n * Update LRU order - move key to end (most recent)\n */\nfunction updateLRU(key: string): void {\n const index = lru.indexOf(key);\n if (index !== -1) {\n lru.splice(index, 1);\n }\n lru.push(key);\n}\n\n/**\n * Remove oldest entries if cache exceeds MAX_CACHE_SIZE\n */\nfunction evictOldest(): void {\n while (lru.length >= MAX_CACHE_SIZE && lru.length > 0) {\n const oldestKey = lru.shift()!;\n dataCache.delete(oldestKey);\n removeFromIndex(oldestKey);\n }\n}\n\n/**\n * Set cache entry and maintain indexes\n */\nfunction setCacheEntry(key: string, entry: CacheEntry): void {\n const existingEntry = dataCache.get(key);\n const wasFulfilled = existingEntry?.status === \"fulfilled\";\n \n dataCache.set(key, entry);\n \n // Only track fulfilled entries in LRU and index (not pending/rejected)\n if (entry.status === \"fulfilled\") {\n // Add to index if it wasn't already fulfilled (new entry or transition from pending/rejected)\n if (!wasFulfilled) {\n addToIndex(key);\n }\n updateLRU(key);\n evictOldest();\n } else if (wasFulfilled) {\n // If entry was fulfilled and now isn't (transitioning to pending/rejected), remove from index\n removeFromIndex(key);\n }\n}\n\n/**\n * Delete cache entry and clean up indexes\n */\nfunction deleteCacheEntry(key: string): void {\n if (dataCache.has(key)) {\n dataCache.delete(key);\n removeFromIndex(key);\n const lruIndex = lru.indexOf(key);\n if (lruIndex !== -1) {\n lru.splice(lruIndex, 1);\n }\n }\n}\n\nfunction buildDataUrl(url: string): string {\n return url + (url.includes(\"?\") ? \"&\" : \"?\") + \"__fw_data=1\";\n}\n\nasync function fetchRouteDataOnce(url: string): Promise<RouteData> {\n const dataUrl = buildDataUrl(url);\n\n const res = await fetch(dataUrl, {\n headers: {\n \"x-fw-data\": \"1\",\n Accept: \"application/json\",\n },\n });\n\n let json: any = {};\n\n try {\n const text = await res.text();\n if (text) {\n json = JSON.parse(text);\n }\n } catch (parseError) {\n console.error(\n \"[client][cache] Failed to parse response as JSON:\",\n parseError\n );\n }\n\n const result: RouteData = {\n ok: res.ok,\n status: res.status,\n json,\n };\n\n return result;\n}\n\n/**\n * Revalidates route data by removing it from the cache.\n * The next time you navigate to this route, fresh data will be fetched from the server.\n * This is a client-side function and does not require a server-side revalidation.\n *\n * @param path - The route path to revalidate (e.g., '/posts/1' or '/posts/1?page=2')\n * If query params are not included, revalidates all variants of that route.\n *\n * @example\n * ```ts\n * // After saving something to the DB, revalidate the route\n * await saveToDatabase(data);\n * revalidatePath('/posts');\n * \n * // Revalidate a specific route with query params\n * revalidatePath('/posts?page=2');\n * ```\n */\nexport function revalidatePath(path: string): void {\n // Normalize the base path (without query params)\n const normalizedPath = path.split(\"?\")[0];\n const hasQueryParams = path.includes(\"?\");\n \n // Get all keys for this path base from index (O(1) lookup)\n const keysForPath = pathIndex.get(normalizedPath);\n \n if (!keysForPath || keysForPath.size === 0) {\n return; // No entries to revalidate\n }\n \n // If the path includes specific query params, extract them\n let specificQueryParams: string | undefined;\n if (hasQueryParams) {\n const queryPart = path.split(\"?\")[1];\n // Sort query params for consistent comparison\n specificQueryParams = queryPart\n .split(\"&\")\n .filter((p) => !p.startsWith(\"__fw_data=\"))\n .sort()\n .join(\"&\");\n }\n \n // Iterate only over keys for this path (much smaller set)\n const keysToDelete: string[] = [];\n for (const key of keysForPath) {\n // If specific query params were specified, check if they match\n if (hasQueryParams && specificQueryParams) {\n const [, keyQuery = \"\"] = key.split(\"?\");\n const keyQueryParams = keyQuery\n .split(\"&\")\n .filter((p) => !p.startsWith(\"__fw_data=\"))\n .sort()\n .join(\"&\");\n \n if (keyQueryParams === specificQueryParams) {\n keysToDelete.push(key);\n }\n } else {\n // If no specific query params, revalidate all variants\n keysToDelete.push(key);\n }\n }\n \n // Delete matching entries\n keysToDelete.forEach((key) => {\n deleteCacheEntry(key);\n });\n \n // If the revalidated path matches the current route, automatically refresh data\n if (typeof window !== \"undefined\") {\n const currentPathname = window.location.pathname;\n const currentSearch = window.location.search;\n const matchesCurrentPath = normalizedPath === currentPathname;\n \n if (matchesCurrentPath) {\n if (hasQueryParams && specificQueryParams) {\n const currentQueryParams = currentSearch\n .replace(\"?\", \"\")\n .split(\"&\")\n .filter((p) => !p.startsWith(\"__fw_data=\"))\n .sort()\n .join(\"&\");\n \n if (currentQueryParams === specificQueryParams) {\n revalidate().catch((err) => {\n console.error(\n \"[client][cache] Error revalidating current route:\",\n err\n );\n });\n }\n } else {\n revalidate().catch((err) => {\n console.error(\n \"[client][cache] Error revalidating current route:\",\n err\n );\n });\n }\n }\n }\n}\n\n/**\n * Revalidates and refreshes the current page data.\n * Similar to Next.js's `router.refresh()`.\n * \n * This function:\n * 1. Removes the current route from cache\n * 2. Fetches fresh data from the server\n * 3. Updates window.__FW_DATA__ with the new data\n * 4. Dispatches a 'fw-data-refresh' event for components to listen to\n * \n * @returns Promise that resolves with the fresh route data\n * \n * @example\n * ```ts\n * // Refresh current page data after a mutation\n * await revalidate();\n * ```\n */\nexport async function revalidate(): Promise<RouteData> {\n if (typeof window === \"undefined\") {\n throw new Error(\"revalidate() can only be called on the client\");\n }\n\n const pathname = window.location.pathname + window.location.search;\n \n // Revalidate the path (remove from cache)\n revalidatePath(pathname);\n \n // Fetch fresh data\n const freshData = await getRouteData(pathname, { revalidate: true });\n \n // Update window.__FW_DATA__ if it exists\n if ((window as any).__FW_DATA__ && freshData.ok && freshData.json) {\n const currentData = (window as any).__FW_DATA__;\n (window as any).__FW_DATA__ = {\n ...currentData,\n pathname: pathname.split(\"?\")[0],\n params: freshData.json.params || currentData.params || {},\n props: freshData.json.props || currentData.props || {},\n metadata: freshData.json.metadata ?? currentData.metadata ?? null,\n notFound: freshData.json.notFound ?? false,\n error: freshData.json.error ?? false,\n };\n \n // Dispatch event for components to listen to\n window.dispatchEvent(new CustomEvent(\"fw-data-refresh\", {\n detail: { data: freshData },\n }));\n }\n \n return freshData;\n}\n\n/**\n * @deprecated Use `revalidatePath()` instead. This function is kept for backwards compatibility.\n */\nexport function revalidateRouteData(url: string): void {\n revalidatePath(url);\n}\n\nexport function prefetchRouteData(url: string): void {\n const key = buildDataUrl(url);\n\n const cached = dataCache.get(key);\n\n if (cached && cached.status !== \"rejected\") {\n // Update LRU if it exists and is fulfilled\n if (cached.status === \"fulfilled\") {\n updateLRU(key);\n }\n return;\n }\n\n const promise = fetchRouteDataOnce(url)\n .then((value) => {\n setCacheEntry(key, { status: \"fulfilled\", value });\n return value;\n })\n .catch((error) => {\n console.error(\"[client][cache] Error prefetching route data:\", error);\n dataCache.set(key, { status: \"rejected\", error });\n throw error;\n });\n\n dataCache.set(key, { status: \"pending\", promise });\n}\n\nexport type GetRouteDataOptions = {\n /**\n * If true, forces revalidation of route data,\n * ignoring the cache and fetching fresh data from the server.\n * Similar to Next.js's `router.refresh()` behavior.\n */\n revalidate?: boolean;\n};\n\nexport async function getRouteData(\n url: string,\n options?: GetRouteDataOptions\n): Promise<RouteData> {\n const key = buildDataUrl(url);\n\n // If revalidation is requested, remove the entry from cache\n if (options?.revalidate) {\n deleteCacheEntry(key);\n }\n\n const entry = dataCache.get(key);\n\n if (entry) {\n if (entry.status === \"fulfilled\") {\n // Update LRU: mark as recently used\n updateLRU(key);\n return entry.value;\n }\n if (entry.status === \"pending\") {\n return entry.promise;\n }\n }\n\n // No entry in cache, fetch it\n const promise = fetchRouteDataOnce(url)\n .then((value) => {\n setCacheEntry(key, { status: \"fulfilled\", value });\n return value;\n })\n .catch((error) => {\n console.error(\"[client][cache] Error fetching route data:\", error);\n dataCache.set(key, { status: \"rejected\", error });\n throw error;\n });\n\n dataCache.set(key, { status: \"pending\", promise });\n return promise;\n}\n","import { getRouteData } from \"../../react/cache/index\";\r\nimport { matchRouteClient } from \"./route-matcher\";\r\nimport { applyMetadata } from \"./metadata\";\r\nimport { setWindowData, getCurrentTheme, setRouterData } from \"./window-data\";\r\nimport type {\r\n ClientRouteLoaded,\r\n RouteViewState,\r\n InitialData,\r\n RouterData,\r\n} from \"./types\";\r\n\r\nexport type NavigationHandlers = {\r\n setState: (state: RouteViewState) => void;\r\n routes: ClientRouteLoaded[];\r\n notFoundRoute: ClientRouteLoaded | null;\r\n errorRoute: ClientRouteLoaded | null;\r\n};\r\n\r\nasync function handleErrorRoute(\r\n nextUrl: string,\r\n json: any,\r\n errorRoute: ClientRouteLoaded,\r\n setState: (state: RouteViewState) => void\r\n): Promise<boolean> {\r\n try {\r\n const components = await errorRoute.load();\r\n \r\n // Get theme: prioritize cookie, then server, then window data, then default\r\n let theme: string = \"light\";\r\n if (typeof document !== \"undefined\") {\r\n const cookieMatch = document.cookie.match(/theme=([^;]+)/);\r\n if (cookieMatch) {\r\n theme = cookieMatch[1];\r\n } else if (json.theme) {\r\n theme = json.theme;\r\n } else {\r\n const currentTheme = getCurrentTheme();\r\n if (currentTheme) theme = currentTheme;\r\n }\r\n } else if (json.theme) {\r\n theme = json.theme;\r\n }\r\n \r\n const errorProps = {\r\n ...(json.props || {\r\n error: json.message || \"An error occurred\",\r\n }),\r\n theme,\r\n };\r\n\r\n const windowData: InitialData = {\r\n pathname: nextUrl,\r\n params: json.params || {},\r\n props: errorProps,\r\n metadata: json.metadata ?? null,\r\n theme,\r\n notFound: false,\r\n error: true,\r\n };\r\n\r\n setWindowData(windowData);\r\n\r\n // Update routerData\r\n const url = new URL(nextUrl, typeof window !== \"undefined\" ? window.location.origin : \"http://localhost\");\r\n const routerData: RouterData = {\r\n pathname: url.pathname,\r\n params: json.params || {},\r\n searchParams: Object.fromEntries(url.searchParams.entries()),\r\n };\r\n setRouterData(routerData);\r\n\r\n setState({\r\n url: nextUrl,\r\n route: errorRoute,\r\n params: json.params || {},\r\n components,\r\n props: errorProps,\r\n });\r\n return true;\r\n } catch (loadError) {\r\n console.error(\r\n \"[client] Error loading error route components:\",\r\n loadError\r\n );\r\n window.location.href = nextUrl;\r\n return false;\r\n }\r\n}\r\n\r\nasync function handleNotFoundRoute(\r\n nextUrl: string,\r\n json: any,\r\n notFoundRoute: ClientRouteLoaded | null,\r\n setState: (state: RouteViewState) => void\r\n): Promise<void> {\r\n // Get theme: prioritize cookie, then server, then window data, then default\r\n let theme: string = \"light\";\r\n if (typeof document !== \"undefined\") {\r\n const cookieMatch = document.cookie.match(/theme=([^;]+)/);\r\n if (cookieMatch) {\r\n theme = cookieMatch[1];\r\n } else if (json.theme) {\r\n theme = json.theme;\r\n } else {\r\n const currentTheme = getCurrentTheme();\r\n if (currentTheme) theme = currentTheme;\r\n }\r\n } else if (json.theme) {\r\n theme = json.theme;\r\n }\r\n \r\n const notFoundProps = {\r\n ...(json.props ?? {}),\r\n theme,\r\n };\r\n\r\n const windowData: InitialData = {\r\n pathname: nextUrl,\r\n params: {},\r\n props: notFoundProps,\r\n metadata: json.metadata ?? null,\r\n theme,\r\n notFound: true,\r\n error: false,\r\n };\r\n\r\n setWindowData(windowData);\r\n\r\n // Update routerData\r\n const url = new URL(nextUrl, typeof window !== \"undefined\" ? window.location.origin : \"http://localhost\");\r\n const routerData: RouterData = {\r\n pathname: url.pathname,\r\n params: {},\r\n searchParams: Object.fromEntries(url.searchParams.entries()),\r\n };\r\n setRouterData(routerData);\r\n\r\n if (notFoundRoute) {\r\n const components = await notFoundRoute.load();\r\n setState({\r\n url: nextUrl,\r\n route: notFoundRoute,\r\n params: {},\r\n components,\r\n props: notFoundProps,\r\n });\r\n } else {\r\n setState({\r\n url: nextUrl,\r\n route: null,\r\n params: {},\r\n components: null,\r\n props: {},\r\n });\r\n }\r\n}\r\n\r\nasync function handleNormalRoute(\r\n nextUrl: string,\r\n json: any,\r\n routes: ClientRouteLoaded[],\r\n setState: (state: RouteViewState) => void\r\n): Promise<boolean> {\r\n applyMetadata(json.metadata ?? null);\r\n \r\n // Get theme: prioritize cookie (source of truth), then server response, then window data, then default\r\n // Cookie is the source of truth because it persists across navigation\r\n let theme: string = \"light\"; // Default\r\n if (typeof document !== \"undefined\") {\r\n const cookieMatch = document.cookie.match(/theme=([^;]+)/);\r\n if (cookieMatch) {\r\n theme = cookieMatch[1];\r\n } else if (json.theme) {\r\n theme = json.theme;\r\n } else {\r\n const currentTheme = getCurrentTheme();\r\n if (currentTheme) {\r\n theme = currentTheme;\r\n }\r\n }\r\n } else if (json.theme) {\r\n theme = json.theme;\r\n }\r\n \r\n // Include theme in props so layouts receive it during SPA navigation\r\n const newProps = {\r\n ...(json.props ?? {}),\r\n theme, // Always include theme\r\n };\r\n\r\n const matched = matchRouteClient(nextUrl, routes);\r\n\r\n if (!matched) {\r\n window.location.href = nextUrl;\r\n return false;\r\n }\r\n\r\n const windowData: InitialData = {\r\n pathname: nextUrl,\r\n params: matched.params,\r\n props: newProps,\r\n metadata: json.metadata ?? null,\r\n theme,\r\n notFound: false,\r\n error: false,\r\n };\r\n\r\n setWindowData(windowData);\r\n\r\n // Update routerData\r\n const url = new URL(nextUrl, typeof window !== \"undefined\" ? window.location.origin : \"http://localhost\");\r\n const routerData: RouterData = {\r\n pathname: url.pathname,\r\n params: matched.params,\r\n searchParams: Object.fromEntries(url.searchParams.entries()),\r\n };\r\n setRouterData(routerData);\r\n\r\n const components = await matched.route.load();\r\n\r\n window.scrollTo({\r\n top: 0,\r\n behavior: \"smooth\",\r\n });\r\n\r\n setState({\r\n url: nextUrl,\r\n route: matched.route,\r\n params: matched.params,\r\n components,\r\n props: newProps,\r\n });\r\n\r\n return true;\r\n}\r\n\r\nexport type NavigateOptions = {\r\n /**\r\n * If true, forces revalidation of route data,\r\n * ignoring the cache and fetching fresh data from the server.\r\n * Similar to Next.js's `router.refresh()` behavior.\r\n */\r\n revalidate?: boolean;\r\n};\r\n\r\nexport async function navigate(\r\n nextUrl: string,\r\n handlers: NavigationHandlers,\r\n options?: NavigateOptions\r\n): Promise<void> {\r\n const { setState, routes, notFoundRoute, errorRoute } = handlers;\r\n\r\n try {\r\n const { ok, json } = await getRouteData(nextUrl, {\r\n revalidate: options?.revalidate,\r\n });\r\n\r\n if (json && json.error) {\r\n if (errorRoute) {\r\n const handled = await handleErrorRoute(\r\n nextUrl,\r\n json,\r\n errorRoute,\r\n setState\r\n );\r\n if (handled) return;\r\n } else {\r\n console.warn(\r\n \"[client] Error route not available, reloading page.\",\r\n errorRoute\r\n );\r\n window.location.href = nextUrl;\r\n return;\r\n }\r\n }\r\n\r\n // 🔴 HTTP error (404/500/etc)\r\n if (!ok) {\r\n if (json && (json as any).redirect) {\r\n window.location.href = (json as any).redirect.destination;\r\n return;\r\n }\r\n window.location.href = nextUrl;\r\n return;\r\n }\r\n\r\n // Redirect via JSON\r\n if (json.redirect) {\r\n window.location.href = json.redirect.destination;\r\n return;\r\n }\r\n\r\n // Handle notFound\r\n if (json.notFound) {\r\n await handleNotFoundRoute(nextUrl, json, notFoundRoute, setState);\r\n return;\r\n }\r\n\r\n // Normal route\r\n await handleNormalRoute(nextUrl, json, routes, setState);\r\n } catch (err) {\r\n console.error(\"[client] Error fetching FW data:\", err);\r\n window.location.href = nextUrl;\r\n }\r\n}\r\n\r\nexport function createClickHandler(\r\n navigate: (url: string, options?: NavigateOptions) => void\r\n): (ev: MouseEvent) => void {\r\n return function handleClick(ev: MouseEvent) {\r\n try {\r\n // Exit early if event was already prevented\r\n if (ev.defaultPrevented) return;\r\n \r\n // Verify it's a real mouse event (not synthetic or keyboard)\r\n if (ev.type !== \"click\") return;\r\n if (ev.button !== 0) return;\r\n if (ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey) return;\r\n \r\n // Verify event has valid coordinates (real mouse events have them)\r\n const target = ev.target as HTMLElement | null;\r\n if (ev.clientX === 0 && ev.clientY === 0 && ev.detail === 0) {\r\n // Could be a synthetic event, be more cautious\r\n if (target) {\r\n const tagName = target.tagName.toLowerCase();\r\n if (tagName === \"input\" || tagName === \"textarea\" || tagName === \"button\" || tagName === \"select\") {\r\n return; // It's an input, don't process synthetic events\r\n }\r\n }\r\n }\r\n\r\n if (!target) return;\r\n\r\n // Check FIRST if target is an interactive element (faster)\r\n const tagName = target.tagName.toLowerCase();\r\n if (\r\n tagName === \"input\" ||\r\n tagName === \"textarea\" ||\r\n tagName === \"button\" ||\r\n tagName === \"select\" ||\r\n target.isContentEditable ||\r\n target.getAttribute(\"contenteditable\") === \"true\"\r\n ) {\r\n return; // It's an interactive element, don't process\r\n }\r\n\r\n // Check if it's inside an interactive element using closest (more efficient than composedPath)\r\n const interactiveParent = target.closest(\"input, textarea, button, select, [contenteditable], label\");\r\n if (interactiveParent) {\r\n // If parent is a label, check if it has an associated control\r\n if (interactiveParent.tagName.toLowerCase() === \"label\") {\r\n const label = interactiveParent as HTMLLabelElement;\r\n if (label.control) {\r\n return; // Label has an associated control (input, etc)\r\n }\r\n } else {\r\n return; // It's inside an interactive element\r\n }\r\n }\r\n\r\n // Only search for anchor if it's not an interactive element\r\n const anchor = target.closest(\"a[href]\") as HTMLAnchorElement | null;\r\n if (!anchor) return;\r\n\r\n const href = anchor.getAttribute(\"href\");\r\n if (!href) return;\r\n if (href.startsWith(\"#\")) return;\r\n\r\n const url = new URL(href, window.location.href);\r\n if (url.origin !== window.location.origin) return;\r\n if (anchor.target && anchor.target !== \"_self\") return;\r\n\r\n ev.preventDefault();\r\n\r\n const nextUrl = url.pathname + url.search;\r\n const currentUrl = window.location.pathname + window.location.search;\r\n if (nextUrl === currentUrl) return;\r\n\r\n // Detect if link has data-revalidate to force revalidation\r\n const shouldRevalidate =\r\n anchor.hasAttribute(\"data-revalidate\") &&\r\n anchor.getAttribute(\"data-revalidate\") !== \"false\";\r\n\r\n window.history.pushState({}, \"\", nextUrl);\r\n navigate(nextUrl, shouldRevalidate ? { revalidate: true } : undefined);\r\n } catch (error) {\r\n // Silenciar errores para evitar bloquear el navegador\r\n console.error(\"[navigation] Error in click handler:\", error);\r\n }\r\n };\r\n}\r\n\r\nexport function createPopStateHandler(\r\n navigate: (url: string, options?: NavigateOptions) => void\r\n): () => void {\r\n return function handlePopState() {\r\n const nextUrl = window.location.pathname + window.location.search;\r\n navigate(nextUrl);\r\n };\r\n}\r\n\r\n","import { createContext, useContext } from \"react\";\r\n\r\nexport type NavigateFunction = (\r\n url: string,\r\n options?: { revalidate?: boolean; replace?: boolean }\r\n) => Promise<void>;\r\n\r\nexport interface RouterContextValue {\r\n navigate: NavigateFunction;\r\n}\r\n\r\nexport const RouterContext = createContext<RouterContextValue | null>(null);\r\n\r\nexport function useRouterContext(): RouterContextValue {\r\n const context = useContext(RouterContext);\r\n if (!context) {\r\n throw new Error(\r\n \"useRouter must be used within a RouterProvider. Make sure you're using it inside a Loly app.\"\r\n );\r\n }\r\n return context;\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA4B;;;ACCrB,IAAM,kBAAkB;AACxB,IAAM,kBAAkB;AACxB,IAAM,mBAAmB;AAEzB,IAAM,sBAAsB;;;ACF5B,SAAS,gBAAoC;AAClD,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO;AAAA,EACT;AACA,SAAS,OAAe,eAAe,KAAiC;AAC1E;AAEO,SAAS,gBAAmC;AACjD,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO;AAAA,EACT;AACA,SAAS,OAAe,eAAe,KAAgC;AACz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AAA,EACF,SAAS,OAAO;AAEd,YAAQ,IAAI,oDAAoD,KAAK;AAAA,EACvE;AACF;AASO,SAAS,gBACd,QACA,eACA,aAAuC,MACjC;AAEN,UAAQ,IAAI,uDAAuD;AACnE,iBAAe;AAEf,GAAC,eAAe,YAAY;AAC1B,UAAM,YAAY,SAAS,eAAe,gBAAgB;AAC1D,UAAM,cAAc,cAAc;AAElC,QAAI,CAAC,WAAW;AACd,cAAQ,MAAM,cAAc,gBAAgB,0BAA0B;AACtE;AAAA,IACF;AAEA,UAAM,aAAa,OAAO,SAAS,WAAW,OAAO,SAAS;AAG9D,QAAI,aAAa,cAAc;AAC/B,QAAI,CAAC,YAAY;AACf,YAAM,MAAM,IAAI,IAAI,YAAY,OAAO,SAAS,MAAM;AACtD,mBAAa;AAAA,QACX,UAAU,IAAI;AAAA,QACd,QAAQ,aAAa,UAAU,CAAC;AAAA,QAChC,cAAc,OAAO,YAAY,IAAI,aAAa,QAAQ,CAAC;AAAA,MAC7D;AACA,oBAAc,UAAU;AAAA,IAC1B;AAEA,QAAI;AACF,YAAM,eAAe,MAAM;AAAA,QACzB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,UAAI,aAAa,UAAU;AACzB,sBAAc,YAAY,QAAQ;AAAA,MACpC;AAEA;AAAA,QACE;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AACd,cAAQ;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,aAAO,SAAS,OAAO;AAAA,IACzB;AAAA,EACF,GAAG;AACL;","names":["import_react","navigate","tagName","import_jsx_runtime","import_jsx_runtime"]}
package/dist/runtime.js CHANGED
@@ -674,7 +674,7 @@ async function loadInitialRoute(initialUrl, initialData, routes, notFoundRoute,
674
674
  };
675
675
  }
676
676
  function setupHotReload() {
677
- const nodeEnv = typeof process !== "undefined" && process?.env?.NODE_ENV || "production";
677
+ const nodeEnv = typeof process !== "undefined" && process.env?.NODE_ENV || "production";
678
678
  const isDev = nodeEnv !== "production";
679
679
  if (!isDev) {
680
680
  return;