frontend-hamroun 1.2.75 → 1.2.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/batch/package.json +16 -0
  2. package/dist/client-router/package.json +16 -0
  3. package/dist/component/package.json +16 -0
  4. package/dist/context/package.json +16 -0
  5. package/dist/event-bus/package.json +16 -0
  6. package/dist/forms/package.json +16 -0
  7. package/dist/hooks/package.json +16 -0
  8. package/dist/jsx-runtime/package.json +16 -0
  9. package/dist/lifecycle-events/package.json +16 -0
  10. package/dist/package.json +71 -0
  11. package/dist/render-component/package.json +16 -0
  12. package/dist/renderer/package.json +16 -0
  13. package/dist/router/package.json +16 -0
  14. package/dist/server/package.json +17 -0
  15. package/dist/server/src/client-router.d.ts +60 -0
  16. package/dist/server/src/client-router.js +210 -0
  17. package/dist/server/src/client-router.js.map +1 -0
  18. package/dist/server/src/component.js +1 -1
  19. package/dist/server/src/event-bus.d.ts +23 -0
  20. package/dist/server/src/event-bus.js +75 -0
  21. package/dist/server/src/event-bus.js.map +1 -0
  22. package/dist/server/src/forms.d.ts +40 -0
  23. package/dist/server/src/forms.js +148 -0
  24. package/dist/server/src/forms.js.map +1 -0
  25. package/dist/server/src/hooks.js +2 -2
  26. package/dist/server/src/index.js +19 -11
  27. package/dist/server/src/lifecycle-events.d.ts +108 -0
  28. package/dist/server/src/lifecycle-events.js +177 -0
  29. package/dist/server/src/lifecycle-events.js.map +1 -0
  30. package/dist/server/src/renderComponent.js +1 -1
  31. package/dist/server/src/renderer.js +3 -3
  32. package/dist/server/src/router.d.ts +55 -0
  33. package/dist/server/src/router.js +166 -0
  34. package/dist/server/src/router.js.map +1 -0
  35. package/dist/server/src/server/index.d.ts +75 -2
  36. package/dist/server/src/server/index.js +224 -8
  37. package/dist/server/src/server/index.js.map +1 -1
  38. package/dist/server/src/server/server.js +1 -1
  39. package/dist/server/src/server/templates.d.ts +28 -0
  40. package/dist/server/src/server/templates.js +204 -0
  41. package/dist/server/src/server/templates.js.map +1 -0
  42. package/dist/server/src/server/utils.d.ts +70 -0
  43. package/dist/server/src/server/utils.js +156 -0
  44. package/dist/server/src/server/utils.js.map +1 -0
  45. package/dist/server/src/server-renderer.js +1 -1
  46. package/dist/server/src/store.d.ts +41 -0
  47. package/dist/server/src/store.js +99 -0
  48. package/dist/server/src/store.js.map +1 -0
  49. package/dist/server/src/utils.d.ts +46 -0
  50. package/dist/server/src/utils.js +144 -0
  51. package/dist/server/src/utils.js.map +1 -0
  52. package/dist/server/tsconfig.server.tsbuildinfo +1 -1
  53. package/dist/server-renderer/package.json +16 -0
  54. package/dist/store/package.json +16 -0
  55. package/dist/types/package.json +16 -0
  56. package/dist/utils/package.json +16 -0
  57. package/dist/vdom/package.json +16 -0
  58. package/dist/wasm/package.json +16 -0
  59. package/package.json +14 -13
  60. package/templates/complete-app/build.js +284 -0
  61. package/templates/complete-app/package.json +40 -0
  62. package/templates/complete-app/public/styles.css +345 -0
  63. package/templates/complete-app/src/api/index.js +31 -0
  64. package/templates/complete-app/src/client.js +93 -0
  65. package/templates/complete-app/src/components/App.js +66 -0
  66. package/templates/complete-app/src/components/Footer.js +19 -0
  67. package/templates/complete-app/src/components/Header.js +38 -0
  68. package/templates/complete-app/src/pages/About.js +59 -0
  69. package/templates/complete-app/src/pages/Home.js +54 -0
  70. package/templates/complete-app/src/pages/WasmDemo.js +136 -0
  71. package/templates/complete-app/src/server.js +186 -0
  72. package/templates/complete-app/src/wasm/build.bat +16 -0
  73. package/templates/complete-app/src/wasm/build.sh +16 -0
  74. package/templates/complete-app/src/wasm/example.go +101 -0
  75. package/templates/fullstack-app/build/main.css +225 -15
  76. package/templates/fullstack-app/build/main.css.map +2 -2
  77. package/templates/fullstack-app/build/main.js +657 -372
  78. package/templates/fullstack-app/build/main.js.map +4 -4
  79. package/templates/fullstack-app/build.ts +3 -4
  80. package/templates/fullstack-app/public/styles.css +222 -15
  81. package/templates/fullstack-app/server.ts +46 -12
  82. package/templates/fullstack-app/src/components/ClientHome.tsx +0 -0
  83. package/templates/fullstack-app/src/components/ErrorBoundary.tsx +36 -0
  84. package/templates/fullstack-app/src/components/Layout.tsx +23 -26
  85. package/templates/fullstack-app/src/components/StateDemo.tsx +207 -0
  86. package/templates/fullstack-app/src/components/UserList.tsx +30 -13
  87. package/templates/fullstack-app/src/data/api.ts +173 -38
  88. package/templates/fullstack-app/src/main.tsx +88 -154
  89. package/templates/fullstack-app/src/middleware.ts +28 -0
  90. package/templates/fullstack-app/src/pages/404.tsx +28 -0
  91. package/templates/fullstack-app/src/pages/[id].tsx +0 -0
  92. package/templates/fullstack-app/src/pages/_app.tsx +11 -0
  93. package/templates/fullstack-app/src/pages/_document.tsx +25 -0
  94. package/templates/fullstack-app/src/pages/_error.tsx +45 -0
  95. package/templates/fullstack-app/src/pages/about.tsx +71 -0
  96. package/templates/fullstack-app/src/pages/api/users/[id].ts +73 -0
  97. package/templates/fullstack-app/src/pages/api/users/index.ts +43 -0
  98. package/templates/fullstack-app/src/pages/index.tsx +97 -20
  99. package/templates/fullstack-app/src/pages/users/[id].tsx +153 -0
  100. package/templates/fullstack-app/src/pages/wasm-demo.tsx +1 -0
  101. package/templates/go/example.go +99 -86
  102. package/templates/go-wasm-app/babel.config.js +8 -2
  103. package/templates/go-wasm-app/build.config.js +62 -0
  104. package/templates/go-wasm-app/build.js +218 -0
  105. package/templates/go-wasm-app/package.json +21 -12
  106. package/templates/go-wasm-app/server.js +59 -510
  107. package/templates/go-wasm-app/src/app.js +173 -0
  108. package/templates/go-wasm-app/vite.config.js +16 -5
  109. package/templates/ssr-template/client.js +54 -26
  110. package/templates/ssr-template/server.js +5 -28
  111. package/templates/ssr-template/vite.config.js +21 -5
  112. package/dist/server/wasm.d.ts +0 -7
  113. package/dist/wasm.d.ts +0 -37
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../node_modules/frontend-hamroun/src/batch.ts", "../node_modules/frontend-hamroun/src/hooks.ts", "../node_modules/frontend-hamroun/src/context.ts", "../node_modules/frontend-hamroun/src/jsx-runtime.ts", "../node_modules/frontend-hamroun/src/renderer.ts", "../node_modules/frontend-hamroun/src/server-renderer.ts", "../node_modules/frontend-hamroun/src/index.client.ts", "../src/config.ts", "../src/components/Layout.tsx", "../src/pages/about/index.tsx", "../src/components/UserList.tsx", "../src/data/api.ts", "../src/pages/index.tsx", "../src/pages/users.tsx", "../src/main.tsx", "../src/router.ts"],
4
- "sourcesContent": ["export let isBatching = false;\r\nconst queue: Function[] = [];\r\n\r\nexport function batchUpdates(fn: Function) {\r\n if (isBatching) {\r\n queue.push(fn);\r\n return;\r\n }\r\n\r\n isBatching = true;\r\n try {\r\n fn();\r\n while (queue.length > 0) {\r\n const nextFn = queue.shift();\r\n nextFn?.();\r\n }\r\n } finally {\r\n isBatching = false;\r\n }\r\n}\r\n\r\nexport function getIsBatching() {\r\n return isBatching;\r\n}\r\n", "import { createElement } from './jsx-runtime';\r\nimport { batchUpdates, isBatching } from './batch';\r\nimport { diff } from './vdom';\r\n\r\nlet currentRender: number = 0;\r\nconst states = new Map<number, any[]>();\r\nconst stateIndices = new Map<number, number>();\r\nconst effects = new Map<number, Effect[]>();\r\nconst memos = new Map<number, { value: any; deps: any[] }[]>();\r\nconst refs = new Map<number, any[]>();\r\n\r\ninterface Effect {\r\n cleanup?: () => void;\r\n deps?: any[];\r\n}\r\n\r\n// Add at the top with other declarations\r\nlet globalRenderCallback: ((element: any, container: HTMLElement) => void) | null = null;\r\nlet globalContainer: HTMLElement | null = null;\r\nlet currentElement: any = null;\r\n\r\nconst isServer = typeof window === 'undefined';\r\nconst serverStates = new Map<number, any>();\r\n\r\nexport function setRenderCallback(\r\n callback: (element: any, container: HTMLElement) => void,\r\n element: any,\r\n container: HTMLElement\r\n) {\r\n globalRenderCallback = callback;\r\n globalContainer = container;\r\n currentElement = element;\r\n}\r\n\r\nexport function prepareRender() {\r\n currentRender++;\r\n stateIndices.set(currentRender, 0);\r\n return currentRender;\r\n}\r\n\r\nexport function finishRender() {\r\n if (isServer) {\r\n serverStates.delete(currentRender);\r\n }\r\n currentRender = 0;\r\n}\r\n\r\nexport function useState<T>(initial: T): [T, (value: T | ((prev: T) => T)) => void] {\r\n if (!currentRender) {\r\n throw new Error('useState must be called within a render');\r\n }\r\n\r\n if (isServer) {\r\n // Server-side state handling\r\n if (!serverStates.has(currentRender)) {\r\n serverStates.set(currentRender, new Map());\r\n }\r\n const componentState = serverStates.get(currentRender)!;\r\n const index = stateIndices.get(currentRender) || 0;\r\n \r\n if (!componentState.has(index)) {\r\n componentState.set(index, initial);\r\n }\r\n\r\n const state = componentState.get(index);\r\n const setState = (newValue: T | ((prev: T) => T)) => {\r\n // No-op for server-side\r\n };\r\n\r\n stateIndices.set(currentRender, index + 1);\r\n return [state, setState];\r\n }\r\n\r\n if (!states.has(currentRender)) {\r\n states.set(currentRender, []);\r\n }\r\n\r\n const componentStates = states.get(currentRender)!;\r\n const index = stateIndices.get(currentRender)!;\r\n \r\n if (index >= componentStates.length) {\r\n componentStates.push(initial);\r\n }\r\n\r\n const state = componentStates[index];\r\n const setState = (newValue: T | ((prev: T) => T)) => {\r\n const nextValue = typeof newValue === 'function' \r\n ? (newValue as Function)(componentStates[index])\r\n : newValue;\r\n\r\n if (componentStates[index] === nextValue) return; // Skip if value hasn't changed\r\n \r\n componentStates[index] = nextValue;\r\n \r\n if (isBatching) {\r\n batchUpdates(() => rerender(currentRender));\r\n } else {\r\n rerender(currentRender);\r\n }\r\n };\r\n\r\n stateIndices.set(currentRender, index + 1);\r\n return [state, setState];\r\n}\r\n\r\nexport function useEffect(callback: () => (() => void) | void, deps?: any[]) {\r\n if (!currentRender) throw new Error('useEffect must be called within a render');\r\n \r\n const effectIndex = stateIndices.get(currentRender)!;\r\n \r\n if (!effects.has(currentRender)) {\r\n effects.set(currentRender, []);\r\n }\r\n\r\n const componentEffects = effects.get(currentRender)!;\r\n const prevEffect = componentEffects[effectIndex];\r\n \r\n // Run effect if deps changed\r\n if (!prevEffect || !deps || !prevEffect.deps || \r\n deps.some((dep, i) => dep !== prevEffect.deps![i])) {\r\n \r\n // Cleanup previous effect\r\n if (prevEffect?.cleanup) {\r\n prevEffect.cleanup();\r\n }\r\n\r\n // Schedule new effect\r\n queueMicrotask(() => {\r\n const cleanup = callback() || undefined;\r\n componentEffects[effectIndex] = { cleanup: cleanup, deps };\r\n });\r\n }\r\n \r\n stateIndices.set(currentRender, effectIndex + 1);\r\n}\r\n\r\nexport function useMemo<T>(factory: () => T, deps: any[]): T {\r\n if (!currentRender) throw new Error('useMemo must be called within a render');\r\n \r\n const memoIndex = stateIndices.get(currentRender)!;\r\n \r\n if (!memos.has(currentRender)) {\r\n memos.set(currentRender, []);\r\n }\r\n\r\n const componentMemos = memos.get(currentRender)!;\r\n const prevMemo = componentMemos[memoIndex];\r\n \r\n if (!prevMemo || (deps && deps.some((dep, i) => !Object.is(dep, prevMemo.deps[i])))) {\r\n const value = factory();\r\n componentMemos[memoIndex] = { value, deps };\r\n stateIndices.set(currentRender, memoIndex + 1);\r\n return value;\r\n }\r\n\r\n stateIndices.set(currentRender, memoIndex + 1);\r\n return prevMemo.value;\r\n}\r\n\r\nexport function useRef<T>(initial: T) {\r\n if (!currentRender) throw new Error('useRef must be called within a render');\r\n \r\n const refIndex = stateIndices.get(currentRender)!;\r\n \r\n if (!refs.has(currentRender)) {\r\n refs.set(currentRender, []);\r\n }\r\n\r\n const componentRefs = refs.get(currentRender)!;\r\n if (refIndex >= componentRefs.length) {\r\n // Initialize with an object that has a current property\r\n const ref = { current: initial };\r\n componentRefs.push(ref);\r\n stateIndices.set(currentRender, refIndex + 1);\r\n return ref;\r\n }\r\n\r\n const ref = componentRefs[refIndex];\r\n stateIndices.set(currentRender, refIndex + 1);\r\n return ref;\r\n}\r\n\r\n// Add a map to track component DOM nodes\r\nconst componentNodes = new Map<Function, Node>();\r\n\r\nasync function rerender(rendererId: number) {\r\n try {\r\n // Clean up effects\r\n const componentEffects = effects.get(rendererId);\r\n if (componentEffects) {\r\n componentEffects.forEach(effect => {\r\n if (effect.cleanup) effect.cleanup();\r\n });\r\n effects.set(rendererId, []);\r\n }\r\n\r\n if (globalRenderCallback && globalContainer && currentElement) {\r\n await globalRenderCallback(currentElement, globalContainer);\r\n }\r\n } catch (error) {\r\n console.error('Error during rerender:', error);\r\n }\r\n}\r\n\r\n// Add new hook for error boundaries\r\nexport function useErrorBoundary(): [Error | null, () => void] {\r\n const [error, setError] = useState<Error | null>(null);\r\n return [error, () => setError(null)];\r\n}\r\n\r\n// Remove withHooks export\r\n", "\r\n\r\nconst contexts = new Map<symbol, any>();\r\nlet currentRender: Function | null = null;\r\n\r\nexport interface Context<T> {\r\n Provider: (props: { value: T; children?: any }) => any;\r\n Consumer: (props: { children: (value: T) => any }) => any;\r\n _id: symbol;\r\n useSelector: <S>(selector: (state: T) => S) => S;\r\n}\r\n\r\nexport function createContext<T>(defaultValue: T): Context<T> {\r\n const context = {\r\n Provider: ({ value, children }: { value: T, children?: any }) => {\r\n return children;\r\n },\r\n Consumer: ({ children }: { children: (value: T) => any }) => {\r\n return children(defaultValue);\r\n },\r\n _id: Symbol(),\r\n useSelector: <S>(selector: (state: T) => S) => {\r\n return selector(defaultValue);\r\n }\r\n };\r\n\r\n return context;\r\n}\r\n\r\nexport function useContext<T>(context: any): T {\r\n return context;\r\n}\r\n", "import type { Component } from './component';\r\n\r\ninterface VNode {\r\n type: string | Function;\r\n props: Record<string, any>;\r\n}\r\n\r\nfunction jsx(type: string | Function, props: any): VNode {\r\n console.log('JSX Transform:', { type, props });\r\n const processedProps = { ...props };\r\n \r\n // Handle children properly\r\n if (arguments.length > 2) {\r\n processedProps.children = Array.prototype.slice.call(arguments, 2);\r\n }\r\n \r\n return { type, props: processedProps };\r\n}\r\n\r\nconst Fragment = ({ children }: { children: any }) => children;\r\n\r\nasync function createElement(vnode: VNode | any): Promise<Node> {\r\n console.log('Creating element from:', vnode);\r\n\r\n // Handle primitives and null\r\n if (vnode == null) {\r\n return document.createTextNode('');\r\n }\r\n \r\n if (typeof vnode === 'boolean') {\r\n return document.createTextNode('');\r\n }\r\n\r\n if (typeof vnode === 'number' || typeof vnode === 'string') {\r\n return document.createTextNode(String(vnode));\r\n }\r\n\r\n // Handle arrays\r\n if (Array.isArray(vnode)) {\r\n const fragment = document.createDocumentFragment();\r\n for (const child of vnode) {\r\n const node = await createElement(child);\r\n fragment.appendChild(node);\r\n }\r\n return fragment;\r\n }\r\n\r\n // Handle VNode\r\n if ('type' in vnode && vnode.props !== undefined) {\r\n const { type, props } = vnode;\r\n \r\n // Handle function components\r\n if (typeof type === 'function') {\r\n try {\r\n const result = await type(props || {});\r\n const node = await createElement(result);\r\n if (node instanceof Element) {\r\n node.setAttribute('data-component-id', type.name || type.toString());\r\n }\r\n return node;\r\n } catch (error) {\r\n console.error('Error rendering component:', error);\r\n return document.createTextNode('');\r\n }\r\n }\r\n\r\n // Create DOM element\r\n const element = document.createElement(type as string);\r\n \r\n // Handle props\r\n for (const [key, value] of Object.entries(props || {})) {\r\n if (key === 'children') continue;\r\n if (key.startsWith('on') && typeof value === 'function') {\r\n const eventName = key.toLowerCase().slice(2);\r\n // Remove existing event listener if any\r\n const existingHandler = (element as any).__events?.[eventName];\r\n if (existingHandler) {\r\n element.removeEventListener(eventName, existingHandler);\r\n }\r\n \r\n // Add new event listener\r\n element.addEventListener(eventName, value as EventListener);\r\n if (!(element as any).__events) {\r\n (element as any).__events = {};\r\n }\r\n (element as any).__events[eventName] = value;\r\n } else if (key === 'style' && typeof value === 'object') {\r\n Object.assign(element.style, value);\r\n } else if (key === 'className') {\r\n element.setAttribute('class', String(value));\r\n } else if (key !== 'key' && key !== 'ref') {\r\n element.setAttribute(key, String(value));\r\n }\r\n }\r\n\r\n // Handle children\r\n const children = props?.children;\r\n if (children != null) {\r\n const childArray = Array.isArray(children) ? children.flat() : [children];\r\n for (const child of childArray) {\r\n const childNode = await createElement(child);\r\n element.appendChild(childNode);\r\n }\r\n }\r\n\r\n return element;\r\n }\r\n\r\n // Handle other objects by converting to string\r\n return document.createTextNode(String(vnode));\r\n}\r\n\r\n// Export named functions and aliases without duplicates\r\nexport {\r\n jsx,\r\n jsx as jsxs,\r\n jsx as jsxDEV,\r\n Fragment,\r\n createElement\r\n};\r\n\r\n// Named exports object\r\nconst jsxRuntime = {\r\n jsx,\r\n jsxs: jsx,\r\n jsxDEV: jsx,\r\n Fragment,\r\n createElement\r\n};\r\n\r\nexport default jsxRuntime;\r\n", "import { createElement } from './jsx-runtime';\r\nimport { prepareRender, finishRender, setRenderCallback } from './hooks';\r\nimport { batchUpdates } from './batch';\r\n\r\nlet isHydrating = false;\r\n\r\nexport async function hydrate(element: any, container: HTMLElement) {\r\n isHydrating = true;\r\n try {\r\n await render(element, container);\r\n } finally {\r\n isHydrating = false;\r\n }\r\n}\r\n\r\nexport async function render(element: any, container: HTMLElement) {\r\n console.log('Rendering to:', container.id);\r\n \r\n batchUpdates(async () => {\r\n const rendererId = prepareRender();\r\n try {\r\n setRenderCallback(render, element, container);\r\n const domNode = await createElement(element);\r\n \r\n if (!isHydrating) {\r\n container.innerHTML = '';\r\n }\r\n container.appendChild(domNode);\r\n \r\n } finally {\r\n finishRender();\r\n }\r\n });\r\n}\r\n", "import { VNode, Component } from './types';\r\nimport { prepareRender, finishRender } from './hooks';\r\n\r\n/**\r\n * Renders a virtual DOM tree to an HTML string\r\n */\r\nexport function renderToString(vnode: VNode): string {\r\n // Reset hook state for this render\r\n prepareRender();\r\n \r\n // Render the tree to HTML\r\n const html = renderNodeToString(vnode);\r\n \r\n // Clean up after rendering\r\n finishRender();\r\n \r\n return html;\r\n}\r\n\r\n/**\r\n * Internal function to convert a virtual node to an HTML string\r\n */\r\nfunction renderNodeToString(vnode: VNode | string | number | boolean | null | undefined): string {\r\n // Handle primitive values\r\n if (vnode === null || vnode === undefined) return '';\r\n if (typeof vnode === 'boolean') return '';\r\n if (typeof vnode === 'number' || typeof vnode === 'string') return escapeHtml(String(vnode));\r\n \r\n // Handle function components\r\n if (typeof vnode.type === 'function') {\r\n const Component = vnode.type as Component;\r\n const renderedNode = Component(vnode.props || {});\r\n return renderNodeToString(renderedNode);\r\n }\r\n \r\n // Handle intrinsic elements (regular HTML tags)\r\n if (typeof vnode.type === 'string') {\r\n const tag = vnode.type;\r\n let attrs = '';\r\n let children = '';\r\n \r\n // Convert props to HTML attributes\r\n if (vnode.props) {\r\n for (const [key, value] of Object.entries(vnode.props)) {\r\n // Skip children prop as we handle it separately\r\n if (key === 'children') continue;\r\n \r\n // Skip event handlers (they start with 'on')\r\n if (key.startsWith('on')) continue;\r\n \r\n // Handle the className prop specially\r\n if (key === 'className') {\r\n attrs += ` class=\"${escapeHtml(value as string)}\"`;\r\n continue;\r\n }\r\n \r\n // Handle other attributes\r\n if (typeof value === 'string' || typeof value === 'number') {\r\n attrs += ` ${key}=\"${escapeHtml(String(value))}\"`;\r\n } else if (value === true) {\r\n // Boolean attributes\r\n attrs += ` ${key}`;\r\n }\r\n }\r\n }\r\n \r\n // Process children\r\n const childrenArray = (vnode.props?.children) \r\n ? Array.isArray(vnode.props.children) \r\n ? vnode.props.children \r\n : [vnode.props.children]\r\n : [];\r\n \r\n for (const child of childrenArray) {\r\n children += renderNodeToString(child);\r\n }\r\n \r\n // Self-closing tags\r\n const selfClosing = [\r\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\r\n 'link', 'meta', 'param', 'source', 'track', 'wbr'\r\n ];\r\n \r\n if (selfClosing.includes(tag)) {\r\n return `<${tag}${attrs}/>`;\r\n }\r\n \r\n // Regular tags with closing\r\n return `<${tag}${attrs}>${children}</${tag}>`;\r\n }\r\n \r\n // Handle fragments\r\n if (vnode.type === Symbol.for('react.fragment')) {\r\n let fragmentOutput = '';\r\n const children = Array.isArray(vnode.props?.children)\r\n ? vnode.props.children\r\n : vnode.props?.children ? [vnode.props.children] : [];\r\n \r\n for (const child of children) {\r\n fragmentOutput += renderNodeToString(child);\r\n }\r\n \r\n return fragmentOutput;\r\n }\r\n \r\n // Fallback for unknown node types\r\n console.warn('Unknown vnode type:', vnode.type);\r\n return '';\r\n}\r\n\r\n/**\r\n * Escape HTML special characters to prevent XSS\r\n */\r\nfunction escapeHtml(text: string): string {\r\n return text\r\n .replace(/&/g, '&amp;')\r\n .replace(/</g, '&lt;')\r\n .replace(/>/g, '&gt;')\r\n .replace(/\"/g, '&quot;')\r\n .replace(/'/g, '&#039;');\r\n}\r\n", "import { createElement } from './jsx-runtime';\r\nimport { prepareRender, finishRender, setRenderCallback } from './hooks';\r\n\r\nexport { \r\n useState, \r\n useEffect, \r\n useMemo, \r\n useRef,\r\n useErrorBoundary \r\n} from './hooks';\r\n\r\nexport { createContext, useContext } from './context';\r\nexport { batchUpdates } from './batch';\r\nexport { jsx, jsxs, Fragment } from './jsx-runtime';\r\nexport { render, hydrate } from './renderer';\r\nexport { renderToString } from './server-renderer';\r\n\r\n// Re-export types for client-side usage\r\nexport type { Context } from './context';\r\nexport type { VNode } from './types';\r\n\r\n// Export a placeholder for server functionality that works in browser environments\r\nexport const server = {\r\n async getServer() {\r\n throw new Error('Server module can only be used in Node.js environment');\r\n }\r\n};\r\n\r\nlet isHydrating = false;\r\n", "// Application configuration\r\n// Modify this file to customize your application without changing core files\r\n\r\nexport const AppConfig = {\r\n // App information\r\n title: 'Frontend Hamroun App',\r\n description: 'A full-stack application built with Frontend Hamroun',\r\n \r\n // Navigation\r\n navigation: [\r\n { path: '/', label: 'Home' },\r\n { path: '/about', label: 'About' },\r\n { path: '/users', label: 'Users' }\r\n ],\r\n \r\n // API endpoints\r\n api: {\r\n baseUrl: '/api',\r\n endpoints: {\r\n users: '/users',\r\n posts: '/posts'\r\n }\r\n },\r\n \r\n // Default meta tags\r\n meta: {\r\n viewport: 'width=device-width, initial-scale=1.0',\r\n charset: 'UTF-8',\r\n author: 'Your Name',\r\n keywords: 'frontend-hamroun, fullstack, template'\r\n },\r\n \r\n // Style customization\r\n theme: {\r\n primaryColor: '#0066cc',\r\n backgroundColor: '#ffffff',\r\n textColor: '#333333',\r\n fontFamily: '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif'\r\n }\r\n};\r\n\r\nexport default AppConfig;\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx } from 'frontend-hamroun';\r\nimport AppConfig from '../config';\r\n\r\nexport interface LayoutProps {\r\n children: any;\r\n title?: string;\r\n showNavigation?: boolean;\r\n}\r\n\r\nexport default function Layout({ children, title = AppConfig.title, showNavigation = true }: LayoutProps) {\r\n const { navigation } = AppConfig;\r\n \r\n return (\r\n <div className=\"container mx-auto px-4 py-8 max-w-5xl\">\r\n <header className=\"mb-8\">\r\n <h1 className=\"text-4xl font-bold text-gray-800 mb-4\">{title}</h1>\r\n \r\n {showNavigation && (\r\n <nav className=\"mb-6\">\r\n <ul className=\"flex space-x-6\">\r\n {navigation.map(item => (\r\n <li key={item.path}>\r\n <a \r\n href={item.path} \r\n className=\"text-blue-600 hover:text-blue-800 hover:underline transition-colors font-medium\"\r\n >\r\n {item.label}\r\n </a>\r\n </li>\r\n ))}\r\n </ul>\r\n </nav>\r\n )}\r\n </header>\r\n \r\n <main className=\"min-h-[50vh]\">\r\n {children}\r\n </main>\r\n \r\n <footer className=\"mt-12 pt-6 border-t border-gray-200 text-gray-600 text-sm\">\r\n <p>{AppConfig.title} &copy; {new Date().getFullYear()}</p>\r\n </footer>\r\n </div>\r\n );\r\n}\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx } from 'frontend-hamroun';\r\nimport Layout from '../../components/Layout';\r\n\r\nconst AboutPage = ({ initialState }) => {\r\n return (\r\n <Layout title=\"About This App\">\r\n <div className=\"max-w-4xl mx-auto bg-white shadow-lg rounded-lg overflow-hidden\">\r\n <div className=\"p-8\">\r\n <p className=\"text-lg text-gray-700 mb-6\">\r\n This is a frontend application built with Frontend Hamroun framework and styled with Tailwind CSS.\r\n </p>\r\n <p className=\"text-gray-600 mb-8\">\r\n It features server-side rendering, client-side navigation, and websocket-based live reloading during development.\r\n </p>\r\n \r\n <div className=\"bg-gray-50 p-6 rounded-lg border border-gray-200 mb-8\">\r\n <h2 className=\"text-xl font-semibold text-gray-800 mb-4\">Key Features</h2>\r\n <ul className=\"space-y-2 text-gray-700\">\r\n <li className=\"flex items-center\">\r\n <svg className=\"w-5 h-5 text-green-500 mr-2\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M5 13l4 4L19 7\"></path>\r\n </svg>\r\n Server-side rendering\r\n </li>\r\n <li className=\"flex items-center\">\r\n <svg className=\"w-5 h-5 text-green-500 mr-2\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M5 13l4 4L19 7\"></path>\r\n </svg>\r\n Client-side navigation\r\n </li>\r\n <li className=\"flex items-center\">\r\n <svg className=\"w-5 h-5 text-green-500 mr-2\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M5 13l4 4L19 7\"></path>\r\n </svg>\r\n Component-based architecture\r\n </li>\r\n <li className=\"flex items-center\">\r\n <svg className=\"w-5 h-5 text-green-500 mr-2\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M5 13l4 4L19 7\"></path>\r\n </svg>\r\n Integrated API backend\r\n </li>\r\n <li className=\"flex items-center\">\r\n <svg className=\"w-5 h-5 text-green-500 mr-2\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M5 13l4 4L19 7\"></path>\r\n </svg>\r\n Live reload during development\r\n </li>\r\n <li className=\"flex items-center\">\r\n <svg className=\"w-5 h-5 text-green-500 mr-2\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M5 13l4 4L19 7\"></path>\r\n </svg>\r\n Tailwind CSS for styling\r\n </li>\r\n </ul>\r\n </div>\r\n \r\n <a href=\"/\" className=\"inline-block px-6 py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors\">\r\n Back to Home\r\n </a>\r\n </div>\r\n </div>\r\n </Layout>\r\n );\r\n};\r\n\r\nexport default AboutPage;\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx } from 'frontend-hamroun';\r\n\r\nconst UserList = ({ users }) => {\r\n if (!users || users.length === 0) {\r\n return (\r\n <div className=\"p-4 bg-gray-50 rounded-lg border border-gray-200 my-4\">\r\n <p className=\"text-gray-500 italic\">No users found or still loading...</p>\r\n </div>\r\n );\r\n }\r\n\r\n return (\r\n <div className=\"rounded-lg overflow-hidden my-4\">\r\n <h3 className=\"text-lg font-medium mb-3\">Users ({users.length})</h3>\r\n <ul className=\"divide-y divide-gray-200 border border-gray-200 rounded-lg overflow-hidden\">\r\n {users.map(user => (\r\n <li key={user.id} className=\"flex justify-between items-center p-4 hover:bg-gray-50\">\r\n <span className=\"font-medium text-gray-800\">{user.name}</span>\r\n <span className=\"text-gray-500 text-sm\">{user.email}</span>\r\n </li>\r\n ))}\r\n </ul>\r\n </div>\r\n );\r\n};\r\n\r\nexport default UserList;\r\n", "// General API utility for data fetching\r\n\r\n/**\r\n * Fetch data from an API endpoint\r\n * @param endpoint The API endpoint to fetch from (without /api prefix)\r\n * @param options Additional fetch options\r\n * @returns The parsed JSON response or null if there was an error\r\n */\r\nexport async function fetchApi(endpoint: string, options = {}) {\r\n const url = endpoint.startsWith('/') ? `/api${endpoint}` : `/api/${endpoint}`;\r\n \r\n try {\r\n console.log(`[API] Fetching data from: ${url}`);\r\n const response = await fetch(url, {\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Accept': 'application/json'\r\n },\r\n ...options\r\n });\r\n \r\n if (!response.ok) {\r\n throw new Error(`API request failed: ${response.status} ${response.statusText}`);\r\n }\r\n \r\n const data = await response.json();\r\n console.log(`[API] Successfully fetched data from: ${url}`);\r\n return data;\r\n } catch (error) {\r\n console.error(`[API] Error fetching from ${url}:`, error);\r\n return null;\r\n }\r\n}\r\n\r\n/**\r\n * User-related API calls\r\n */\r\nexport const UserApi = {\r\n getAll: () => fetchApi('/users'),\r\n getById: (id: number | string) => fetchApi(`/users/${id}`),\r\n create: (data: any) => fetchApi('/users', {\r\n method: 'POST',\r\n body: JSON.stringify(data)\r\n }),\r\n update: (id: number | string, data: any) => fetchApi(`/users/${id}`, {\r\n method: 'PUT',\r\n body: JSON.stringify(data)\r\n }),\r\n delete: (id: number | string) => fetchApi(`/users/${id}`, {\r\n method: 'DELETE'\r\n })\r\n};\r\n\r\n/**\r\n * Post-related API calls\r\n */\r\nexport const PostApi = {\r\n getAll: () => fetchApi('/posts'),\r\n getById: (id: number | string) => fetchApi(`/posts/${id}`),\r\n create: (data: any) => fetchApi('/posts', {\r\n method: 'POST',\r\n body: JSON.stringify(data)\r\n }),\r\n update: (id: number | string, data: any) => fetchApi(`/posts/${id}`, {\r\n method: 'PUT',\r\n body: JSON.stringify(data)\r\n }),\r\n delete: (id: number | string) => fetchApi(`/posts/${id}`, {\r\n method: 'DELETE'\r\n })\r\n};\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx } from 'frontend-hamroun';\r\nimport Layout from '../components/Layout';\r\nimport UserList from '../components/UserList';\r\nimport { UserApi } from '../data/api';\r\n\r\nconst HomePage = ({ initialState }) => (\r\n <Layout title=\"Home\">\r\n <div className=\"max-w-4xl mx-auto py-8\">\r\n <h1 className=\"text-3xl font-bold text-blue-600 mb-6\">Welcome to your Frontend Hamroun application!</h1>\r\n \r\n <div className=\"bg-white shadow-lg rounded-lg p-6 mb-8\">\r\n <h2 className=\"text-xl font-semibold text-gray-800 mb-4\">User List</h2>\r\n <UserList users={initialState.data?.users || []} />\r\n </div>\r\n \r\n <div className=\"bg-gray-50 rounded-lg p-6 border border-gray-200\">\r\n <h3 className=\"text-lg font-medium text-gray-700 mb-3\">Application State</h3>\r\n <pre className=\"overflow-auto p-4 bg-gray-100 rounded-md text-sm text-gray-800\">\r\n {JSON.stringify(initialState, null, 2)}\r\n </pre>\r\n </div>\r\n </div>\r\n </Layout>\r\n);\r\n\r\n// Static method to fetch initial data for this page\r\nHomePage.getInitialData = async () => {\r\n return {\r\n users: await UserApi.getAll()\r\n };\r\n};\r\n\r\nexport default HomePage;\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx } from 'frontend-hamroun';\r\nimport Layout from '../components/Layout';\r\nimport { UserApi } from '../data/api';\r\n\r\nconst UsersPage = ({ initialState }) => {\r\n const users = initialState.data?.users || [];\r\n\r\n return (\r\n <Layout title=\"User Management\">\r\n <div className=\"max-w-4xl mx-auto\">\r\n <div className=\"bg-blue-50 p-6 rounded-lg mb-8 border border-blue-100\">\r\n <h2 className=\"text-xl font-semibold text-blue-800 mb-2\">Data Fetching Demo</h2>\r\n <p className=\"text-blue-700\">This page demonstrates dynamic data fetching with the Users API.</p>\r\n </div>\r\n \r\n <div className=\"bg-white shadow-md rounded-lg overflow-hidden\">\r\n <div className=\"px-6 py-4 border-b border-gray-200\">\r\n <h2 className=\"text-xl font-semibold text-gray-800\">User List</h2>\r\n </div>\r\n \r\n {users.length === 0 ? (\r\n <div className=\"p-6 text-center text-gray-500\">\r\n <p>No users found.</p>\r\n </div>\r\n ) : (\r\n <div className=\"overflow-x-auto\">\r\n <table className=\"w-full\">\r\n <thead>\r\n <tr className=\"bg-gray-50\">\r\n <th className=\"text-left py-3 px-6 font-medium text-gray-600 text-sm uppercase tracking-wider border-b\">ID</th>\r\n <th className=\"text-left py-3 px-6 font-medium text-gray-600 text-sm uppercase tracking-wider border-b\">Name</th>\r\n <th className=\"text-left py-3 px-6 font-medium text-gray-600 text-sm uppercase tracking-wider border-b\">Email</th>\r\n </tr>\r\n </thead>\r\n <tbody className=\"divide-y divide-gray-200\">\r\n {users.map(user => (\r\n <tr key={user.id} className=\"hover:bg-gray-50\">\r\n <td className=\"py-4 px-6 text-sm text-gray-900\">{user.id}</td>\r\n <td className=\"py-4 px-6 text-sm font-medium text-gray-900\">{user.name}</td>\r\n <td className=\"py-4 px-6 text-sm text-gray-500\">{user.email}</td>\r\n </tr>\r\n ))}\r\n </tbody>\r\n </table>\r\n </div>\r\n )}\r\n </div>\r\n </div>\r\n </Layout>\r\n );\r\n};\r\n\r\n// Static method to fetch initial data for this page\r\nUsersPage.getInitialData = async () => {\r\n return {\r\n users: await UserApi.getAll()\r\n };\r\n};\r\n\r\nexport default UsersPage;\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { render, hydrate, jsx } from 'frontend-hamroun';\r\nimport { router } from './router';\r\n// Import Tailwind CSS\r\nimport './styles.css';\r\n\r\n// Import pages directly to ensure they're available\r\nimport HomePage from './pages/index';\r\nimport AboutPage from './pages/about';\r\nimport UsersPage from './pages/users';\r\n\r\n// Create a mutable variable for hydration state\r\nlet isHydrating = document.getElementById('root')?.innerHTML.trim() !== '';\r\n\r\nconsole.log('[Client] Running client-side code. Hydration state:', isHydrating);\r\n\r\n// Get initial state from server\r\nconst initialState = window.__INITIAL_STATE__ || { \r\n route: window.location.pathname,\r\n timestamp: new Date().toISOString(),\r\n serverRendered: false,\r\n data: {\r\n users: null,\r\n posts: null\r\n }\r\n};\r\n\r\nconsole.log('[Client] Initial state:', initialState);\r\n\r\n// Function to fetch data from API\r\nasync function fetchData(path) {\r\n try {\r\n console.log(`[Client] Fetching data from API: ${path}`);\r\n const response = await fetch(`/api${path}`);\r\n if (!response.ok) {\r\n throw new Error(`API request failed: ${response.status}`);\r\n }\r\n const data = await response.json();\r\n console.log(`[Client] Received data:`, data);\r\n return data;\r\n } catch (error) {\r\n console.error(`[Client] Error fetching data from ${path}:`, error);\r\n return null;\r\n }\r\n}\r\n\r\n// Initialize known routes\r\nfunction initializeRouter() {\r\n console.log('[Client] Initializing router with known pages');\r\n router.register('index', HomePage);\r\n router.register('about', AboutPage);\r\n router.register('users', UsersPage);\r\n}\r\n\r\n// Call initialization before rendering\r\ninitializeRouter();\r\n\r\n// Function to determine which page to render based on the route\r\nasync function renderApp() {\r\n try {\r\n // Get current path\r\n const currentPath = window.location.pathname;\r\n \r\n console.log(`[Client] Rendering for path: ${currentPath}`);\r\n \r\n // Find the root element\r\n const rootElement = document.getElementById('root');\r\n if (!rootElement) {\r\n console.error('[Client] Root element not found');\r\n return;\r\n }\r\n \r\n // Fetch data based on the current route\r\n console.log(`[Client] Fetching users data for ${currentPath}`);\r\n const users = await fetchData('/users');\r\n \r\n if (users) {\r\n initialState.data = {\r\n ...initialState.data,\r\n users\r\n };\r\n console.log(`[Client] Updated state with ${users.length} users`);\r\n }\r\n \r\n // Get the component for the current path\r\n let PageComponent = null;\r\n \r\n // Special cases for known routes\r\n if (currentPath === '/about') {\r\n try {\r\n const AboutPage = await import('./pages/about');\r\n PageComponent = AboutPage.default;\r\n } catch (err) {\r\n console.error('[Client] Failed to load about page:', err);\r\n }\r\n } else if (currentPath === '/users') {\r\n try {\r\n const UsersPage = await import('./pages/users');\r\n PageComponent = UsersPage.default;\r\n } catch (err) {\r\n console.error('[Client] Failed to load users page:', err);\r\n }\r\n } else {\r\n // Try the router for other paths\r\n PageComponent = await router.resolve(currentPath);\r\n }\r\n \r\n // If component wasn't found, handle special cases\r\n if (!PageComponent) {\r\n console.warn(`[Client] Page component not found for ${currentPath}, checking special cases`);\r\n \r\n // Special case for /users\r\n if (currentPath === '/users') {\r\n try {\r\n console.log('[Client] Attempting direct import of Users page');\r\n const UsersModule = await import('./pages/users');\r\n if (UsersModule.default) {\r\n PageComponent = UsersModule.default;\r\n }\r\n } catch (err) {\r\n console.error('[Client] Failed to import Users page:', err);\r\n }\r\n }\r\n }\r\n \r\n // Final fallback if still no component\r\n if (!PageComponent) {\r\n // Create a simple fallback component\r\n PageComponent = ({ initialState }) => jsx('div', { \r\n style: 'padding: 20px; max-width: 800px; margin: 0 auto;' \r\n }, [\r\n jsx('h1', {}, ['Page Not Found']),\r\n jsx('p', {}, [`No component found for path: ${initialState.route}`]),\r\n jsx('a', { href: '/', style: 'color: #0066cc;' }, ['Go to Home'])\r\n ]);\r\n }\r\n \r\n // Update state with current route and timestamp\r\n initialState.route = currentPath;\r\n initialState.timestamp = new Date().toISOString();\r\n initialState.serverRendered = false; // This is now a client render\r\n \r\n // Render or hydrate\r\n if (isHydrating) {\r\n console.log('[Client] Hydrating server-rendered content');\r\n hydrate(<PageComponent initialState={initialState} />, rootElement);\r\n // After hydration is complete, set to false for future renders\r\n isHydrating = false;\r\n } else {\r\n console.log('[Client] Rendering client-side');\r\n render(<PageComponent initialState={initialState} />, rootElement);\r\n }\r\n } catch (error) {\r\n console.error('[Client] Error rendering app:', error);\r\n \r\n // Render error message\r\n const rootElement = document.getElementById('root');\r\n if (rootElement) {\r\n rootElement.innerHTML = `\r\n <div style=\"padding: 20px; color: red;\">\r\n <h1>Error</h1>\r\n <p>${error.message}</p>\r\n <pre>${error.stack}</pre>\r\n </div>\r\n `;\r\n }\r\n }\r\n}\r\n\r\n// Initial render/hydrate\r\nrenderApp();\r\n\r\n// Set up client-side navigation\r\ndocument.addEventListener('click', (e) => {\r\n // Find if the clicked element is an anchor or inside an anchor\r\n let target = e.target;\r\n while (target && target.tagName !== 'A') {\r\n target = target.parentElement;\r\n if (!target) break;\r\n }\r\n \r\n // If we found an anchor that's for internal navigation\r\n if (target && \r\n target.tagName === 'A' && \r\n target.getAttribute('href') &&\r\n target.getAttribute('href').startsWith('/') && \r\n !target.getAttribute('href').startsWith('//') &&\r\n !target.getAttribute('target')) {\r\n e.preventDefault();\r\n const href = target.getAttribute('href');\r\n \r\n // Update history\r\n window.history.pushState(null, '', href);\r\n \r\n // Set to false since we're doing client-side navigation now\r\n isHydrating = false;\r\n \r\n // Re-render the app\r\n renderApp();\r\n }\r\n});\r\n\r\n// Handle back/forward navigation\r\nwindow.addEventListener('popstate', () => {\r\n // Not hydrating during history navigation\r\n isHydrating = false;\r\n renderApp();\r\n});\r\n\r\n// Setup live reload for development\r\nif (typeof io !== 'undefined') {\r\n const socket = io();\r\n \r\n socket.on('reload', () => {\r\n console.log('[Dev] Reloading page due to file changes');\r\n window.location.reload();\r\n });\r\n \r\n socket.on('welcome', (data) => {\r\n console.log('[Dev] Connected to development server:', data);\r\n });\r\n}\r\n", "import { jsx } from 'frontend-hamroun';\r\n// Use dynamic import to ensure it's available\r\n// import UsersPage from './pages/users'; \r\n\r\n// Type definitions for page components\r\nexport interface PageProps {\r\n initialState: any;\r\n}\r\n\r\nexport interface PageComponent {\r\n (props: PageProps): any;\r\n getInitialData?: (path: string) => Promise<any>;\r\n}\r\n\r\n// Define router interface for type safety\r\ninterface RouteParams {\r\n [key: string]: string;\r\n}\r\n\r\n// Define router class for handling routes\r\nexport class Router {\r\n private routes: Record<string, PageComponent> = {};\r\n private notFoundComponent: PageComponent | null = null;\r\n \r\n // Register a component for a specific route\r\n register(path: string, component: PageComponent): Router {\r\n const normalizedPath = path === '/' ? 'index' : path.replace(/^\\//, '');\r\n this.routes[normalizedPath] = component;\r\n console.log(`[Router] Registered component for path: ${normalizedPath}`);\r\n return this;\r\n }\r\n \r\n // Set the not found component\r\n setNotFound(component: PageComponent): Router {\r\n this.notFoundComponent = component;\r\n return this;\r\n }\r\n \r\n // Get the not found component\r\n getNotFound(): PageComponent | null {\r\n return this.notFoundComponent;\r\n }\r\n \r\n // Get all registered routes\r\n getAllRoutes(): Record<string, PageComponent> {\r\n return this.routes;\r\n }\r\n \r\n // Find component for a given path\r\n async resolve(path: string): Promise<PageComponent | null> {\r\n const normalizedPath = path === '/' ? 'index' : path.replace(/^\\//, '');\r\n \r\n console.log(`[Router] Resolving component for path: ${normalizedPath}`);\r\n \r\n // Check for exact match first\r\n if (this.routes[normalizedPath]) {\r\n return this.routes[normalizedPath];\r\n }\r\n \r\n // Check for nested routes (e.g., \"users/123\" should match a \"users/[id]\" route)\r\n const pathSegments = normalizedPath.split('/');\r\n const registeredRoutes = Object.keys(this.routes);\r\n \r\n // Try to find dynamic route matches\r\n for (const route of registeredRoutes) {\r\n const routeSegments = route.split('/');\r\n \r\n // Skip routes with different segment count\r\n if (routeSegments.length !== pathSegments.length) continue;\r\n \r\n let isMatch = true;\r\n const params: RouteParams = {};\r\n \r\n // Compare each segment\r\n for (let i = 0; i < routeSegments.length; i++) {\r\n const routeSegment = routeSegments[i];\r\n const pathSegment = pathSegments[i];\r\n \r\n // Handle dynamic segments (e.g., [id])\r\n if (routeSegment.startsWith('[') && routeSegment.endsWith(']')) {\r\n const paramName = routeSegment.slice(1, -1);\r\n params[paramName] = pathSegment;\r\n }\r\n // Regular segment, must match exactly\r\n else if (routeSegment !== pathSegment) {\r\n isMatch = false;\r\n break;\r\n }\r\n }\r\n \r\n if (isMatch) {\r\n console.log(`[Router] Found dynamic route match: ${route}`);\r\n // Return the component with params\r\n return this.routes[route];\r\n }\r\n }\r\n \r\n // If no match found yet, try to dynamically import the component\r\n try {\r\n let component = null;\r\n let resolvedPath = normalizedPath;\r\n \r\n // Next.js-style dynamic route resolution\r\n try {\r\n // First, try direct file match (e.g., ./pages/users.tsx)\r\n // Focus on .tsx since that's what this project uses\r\n try {\r\n console.log(`[Router] Trying direct import: ./pages/${resolvedPath}.tsx`);\r\n const directModule = await import(/* @vite-ignore */ `./pages/${resolvedPath}.tsx`)\r\n .catch(() => null);\r\n \r\n if (directModule) {\r\n component = directModule.default || directModule;\r\n }\r\n } catch (e) {\r\n console.warn(`[Router] Error importing ./pages/${resolvedPath}.tsx:`, e);\r\n }\r\n \r\n // Next, try index file in directory (e.g., ./pages/about/index.tsx)\r\n if (!component && !resolvedPath.endsWith('index')) {\r\n try {\r\n console.log(`[Router] Trying index file: ./pages/${resolvedPath}/index.tsx`);\r\n const indexModule = await import(/* @vite-ignore */ `./pages/${resolvedPath}/index.tsx`)\r\n .catch(() => null);\r\n \r\n if (indexModule) {\r\n component = indexModule.default || indexModule;\r\n }\r\n } catch (e) {\r\n console.warn(`[Router] Error importing ./pages/${resolvedPath}/index.tsx:`, e);\r\n }\r\n }\r\n } catch (routeError) {\r\n console.warn(`[Router] Error resolving Next.js style route:`, routeError);\r\n }\r\n \r\n // Register and return component if found\r\n if (component) {\r\n this.routes[normalizedPath] = component;\r\n return component;\r\n }\r\n } catch (error) {\r\n console.warn(`[Router] Error importing component for ${normalizedPath}:`, error);\r\n }\r\n \r\n // If we reach here, no component was found\r\n console.warn(`[Router] No component found for path: ${normalizedPath}`);\r\n return this.notFoundComponent;\r\n }\r\n\r\n // Auto-discover components in the pages directory\r\n async discoverRoutes(): Promise<Record<string, PageComponent>> {\r\n console.log('[Router] Auto-discovering routes from pages directory...');\r\n \r\n try {\r\n // Use a more conventional approach instead of relying on import.meta.glob\r\n await this.tryLoadCoreRoutes();\r\n \r\n console.log('[Router] Route discovery complete. Available routes:', Object.keys(this.routes));\r\n return this.routes;\r\n } catch (error) {\r\n console.error('[Router] Error discovering routes:', error);\r\n await this.tryLoadCoreRoutes();\r\n return this.routes;\r\n }\r\n }\r\n \r\n // Fallback method to load core routes\r\n async tryLoadCoreRoutes(): Promise<void> {\r\n // First try the auto-discovery approach with dynamic imports\r\n const pageModules = [\r\n { path: './pages/index', route: 'index' },\r\n { path: './pages/about/index', route: 'about' },\r\n { path: './pages/users', route: 'users' }\r\n ];\r\n \r\n // Try importing each module dynamically - focus on .tsx files\r\n for (const { path, route } of pageModules) {\r\n if (!this.routes[route]) {\r\n try {\r\n console.log(`[Router] Attempting to load route: ${route}`);\r\n \r\n // Only try .tsx imports since that's what the project uses\r\n const module = await import(/* @vite-ignore */ `${path}.tsx`)\r\n .catch(() => null);\r\n \r\n if (module && module.default) {\r\n this.routes[route] = module.default;\r\n console.log(`[Router] Registered route: ${route}`);\r\n }\r\n } catch (error) {\r\n console.warn(`[Router] Could not load route: ${route}`, error);\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n// Create and export a router instance\r\nexport const router = new Router();\r\n\r\n// NotFound component as fallback (using jsx function instead of JSX syntax)\r\nexport const NotFound: PageComponent = ({ initialState }) => {\r\n return jsx('div', { className: 'container mx-auto px-4 py-12 max-w-4xl' }, [\r\n jsx('div', { className: 'bg-white shadow-lg rounded-lg overflow-hidden p-8' }, [\r\n jsx('h1', { className: 'text-3xl font-bold text-gray-800 mb-4' }, ['Page Not Found']),\r\n jsx('p', { className: 'text-gray-600 mb-6' }, [`No component found for path: ${initialState?.route || 'unknown'}`]),\r\n jsx('a', { href: '/', className: 'text-blue-600 hover:text-blue-800 hover:underline transition-colors' }, ['Go to Home']),\r\n jsx('div', { className: 'mt-8 p-6 bg-gray-50 rounded-lg border border-gray-200' }, [\r\n jsx('h3', { className: 'text-lg font-medium text-gray-700 mb-3' }, ['Available Routes']),\r\n jsx('ul', { className: 'space-y-2' }, [\r\n jsx('li', {}, [jsx('a', { href: '/', className: 'text-blue-600 hover:text-blue-800 hover:underline' }, ['Home'])]),\r\n jsx('li', {}, [jsx('a', { href: '/about', className: 'text-blue-600 hover:text-blue-800 hover:underline' }, ['About'])]),\r\n jsx('li', {}, [jsx('a', { href: '/users', className: 'text-blue-600 hover:text-blue-800 hover:underline' }, ['Users'])])\r\n ])\r\n ])\r\n ])\r\n ]);\r\n};\r\n\r\n// Set NotFound as the default fallback\r\nrouter.setNotFound(NotFound);\r\n\r\n// Improved router initialization with auto-discovery\r\nexport async function initializeRouter(): Promise<Router> {\r\n try {\r\n console.log('[Router] Initializing router with auto-discovery...');\r\n \r\n // Auto-discover routes\r\n await router.discoverRoutes();\r\n \r\n // Register fallback pages for key routes if they weren't discovered\r\n const routes = router.getAllRoutes();\r\n \r\n if (!routes['index']) {\r\n router.register('index', ({ initialState }: PageProps) => jsx('div', {}, [\r\n jsx('h1', {}, ['Welcome']),\r\n jsx('p', {}, ['This is the home page.'])\r\n ]));\r\n }\r\n \r\n if (!routes['about']) {\r\n router.register('about', ({ initialState }: PageProps) => jsx('div', {}, [\r\n jsx('h1', {}, ['About']),\r\n jsx('p', {}, ['This is the about page.'])\r\n ]));\r\n }\r\n \r\n console.log('[Router] Router initialized with routes:', Object.keys(router.getAllRoutes()));\r\n return router;\r\n } catch (error) {\r\n console.error('[Router] Error initializing router:', error);\r\n return router;\r\n }\r\n}\r\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAGO,SAAS,aAAa,IAAc;AACzC,MAAI,YAAY;AACd,UAAM,KAAK,EAAE;AACb;EACF;AAEa,eAAA;AACT,MAAA;AACC,OAAA;AACI,WAAA,MAAM,SAAS,GAAG;AACjB,YAAA,SAAS,MAAM,MAAA;AACZ,gBAAA,OAAA,SAAA,OAAA;IACX;EAAA,UAAA;AAEa,iBAAA;EACf;AACF;ACKgB,SAAA,kBACd,UACA,SACA,WACA;AACuB,yBAAA;AACL,oBAAA;AACD,mBAAA;AACnB;AAEO,SAAS,gBAAgB;AAC9B;AACa,eAAA,IAAI,eAAe,CAAC;AAC1B,SAAA;AACT;AAEO,SAAS,eAAe;AAC7B,MAAI,UAAU;AACZ,iBAAa,OAAO,aAAa;EACnC;AACgB,kBAAA;AAClB;AEtCA,SAAS,IAAI,MAAyB,OAAmB;AACvD,UAAQ,IAAI,kBAAkB,EAAE,MAAM,MAAO,CAAA;AACvC,QAAA,iBAAiB,EAAE,GAAG,MAAA;AAGxB,MAAA,UAAU,SAAS,GAAG;AACxB,mBAAe,WAAW,MAAM,UAAU,MAAM,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,YAAQ,IAAI,0CAA0C,IAAI;AAAA,EAC5D,CAAC;AACH;",
6
- "names": ["initialState", "initialState", "initialState", "initialState", "isHydrating", "AboutPage", "UsersPage", "initialState"]
3
+ "sources": ["../node_modules/frontend-hamroun/src/batch.ts", "../node_modules/frontend-hamroun/src/hooks.ts", "../node_modules/frontend-hamroun/src/context.ts", "../node_modules/frontend-hamroun/src/jsx-runtime.ts", "../node_modules/frontend-hamroun/src/renderer.ts", "../node_modules/frontend-hamroun/src/server-renderer.ts", "../node_modules/frontend-hamroun/src/index.client.ts", "../src/pages/404.tsx", "../src/pages/[id].tsx", "../src/components/Layout.tsx", "../src/pages/_app.tsx", "../src/pages/_document.tsx", "../src/pages/_error.tsx", "../src/pages/about.tsx", "../src/pages/about/index.tsx", "../src/components/UserList.tsx", "../src/components/StateDemo.tsx", "../src/components/ErrorBoundary.tsx", "../src/data/api.ts", "../src/pages/index.tsx", "../src/pages/users.tsx", "../src/pages/users/[id].tsx", "../src/pages/wasm-demo.tsx", "../src/main.tsx"],
4
+ "sourcesContent": ["export let isBatching = false;\r\nconst queue: Function[] = [];\r\n\r\nexport function batchUpdates(fn: Function) {\r\n if (isBatching) {\r\n queue.push(fn);\r\n return;\r\n }\r\n\r\n isBatching = true;\r\n try {\r\n fn();\r\n while (queue.length > 0) {\r\n const nextFn = queue.shift();\r\n nextFn?.();\r\n }\r\n } finally {\r\n isBatching = false;\r\n }\r\n}\r\n\r\nexport function getIsBatching() {\r\n return isBatching;\r\n}\r\n", "import { createElement } from './jsx-runtime';\r\nimport { batchUpdates, isBatching } from './batch';\r\nimport { diff } from './vdom';\r\n\r\nlet currentRender: number = 0;\r\nconst states = new Map<number, any[]>();\r\nconst stateIndices = new Map<number, number>();\r\nconst effects = new Map<number, Effect[]>();\r\nconst memos = new Map<number, { value: any; deps: any[] }[]>();\r\nconst refs = new Map<number, any[]>();\r\n\r\ninterface Effect {\r\n cleanup?: () => void;\r\n deps?: any[];\r\n}\r\n\r\n// Add at the top with other declarations\r\nlet globalRenderCallback: ((element: any, container: HTMLElement) => void) | null = null;\r\nlet globalContainer: HTMLElement | null = null;\r\nlet currentElement: any = null;\r\n\r\nconst isServer = typeof window === 'undefined';\r\nconst serverStates = new Map<number, any>();\r\n\r\nexport function setRenderCallback(\r\n callback: (element: any, container: HTMLElement) => void,\r\n element: any,\r\n container: HTMLElement\r\n) {\r\n globalRenderCallback = callback;\r\n globalContainer = container;\r\n currentElement = element;\r\n}\r\n\r\nexport function prepareRender() {\r\n currentRender++;\r\n stateIndices.set(currentRender, 0);\r\n return currentRender;\r\n}\r\n\r\nexport function finishRender() {\r\n if (isServer) {\r\n serverStates.delete(currentRender);\r\n }\r\n currentRender = 0;\r\n}\r\n\r\nexport function useState<T>(initial: T): [T, (value: T | ((prev: T) => T)) => void] {\r\n if (!currentRender) {\r\n throw new Error('useState must be called within a render');\r\n }\r\n\r\n if (isServer) {\r\n // Server-side state handling\r\n if (!serverStates.has(currentRender)) {\r\n serverStates.set(currentRender, new Map());\r\n }\r\n const componentState = serverStates.get(currentRender)!;\r\n const index = stateIndices.get(currentRender) || 0;\r\n \r\n if (!componentState.has(index)) {\r\n componentState.set(index, initial);\r\n }\r\n\r\n const state = componentState.get(index);\r\n const setState = (newValue: T | ((prev: T) => T)) => {\r\n // No-op for server-side\r\n };\r\n\r\n stateIndices.set(currentRender, index + 1);\r\n return [state, setState];\r\n }\r\n\r\n if (!states.has(currentRender)) {\r\n states.set(currentRender, []);\r\n }\r\n\r\n const componentStates = states.get(currentRender)!;\r\n const index = stateIndices.get(currentRender)!;\r\n \r\n if (index >= componentStates.length) {\r\n componentStates.push(initial);\r\n }\r\n\r\n const state = componentStates[index];\r\n const setState = (newValue: T | ((prev: T) => T)) => {\r\n const nextValue = typeof newValue === 'function' \r\n ? (newValue as Function)(componentStates[index])\r\n : newValue;\r\n\r\n if (componentStates[index] === nextValue) return; // Skip if value hasn't changed\r\n \r\n componentStates[index] = nextValue;\r\n \r\n if (isBatching) {\r\n batchUpdates(() => rerender(currentRender));\r\n } else {\r\n rerender(currentRender);\r\n }\r\n };\r\n\r\n stateIndices.set(currentRender, index + 1);\r\n return [state, setState];\r\n}\r\n\r\nexport function useEffect(callback: () => (() => void) | void, deps?: any[]) {\r\n if (!currentRender) throw new Error('useEffect must be called within a render');\r\n \r\n const effectIndex = stateIndices.get(currentRender)!;\r\n \r\n if (!effects.has(currentRender)) {\r\n effects.set(currentRender, []);\r\n }\r\n\r\n const componentEffects = effects.get(currentRender)!;\r\n const prevEffect = componentEffects[effectIndex];\r\n \r\n // Run effect if deps changed\r\n if (!prevEffect || !deps || !prevEffect.deps || \r\n deps.some((dep, i) => dep !== prevEffect.deps![i])) {\r\n \r\n // Cleanup previous effect\r\n if (prevEffect?.cleanup) {\r\n prevEffect.cleanup();\r\n }\r\n\r\n // Schedule new effect\r\n queueMicrotask(() => {\r\n const cleanup = callback() || undefined;\r\n componentEffects[effectIndex] = { cleanup: cleanup, deps };\r\n });\r\n }\r\n \r\n stateIndices.set(currentRender, effectIndex + 1);\r\n}\r\n\r\nexport function useMemo<T>(factory: () => T, deps: any[]): T {\r\n if (!currentRender) throw new Error('useMemo must be called within a render');\r\n \r\n const memoIndex = stateIndices.get(currentRender)!;\r\n \r\n if (!memos.has(currentRender)) {\r\n memos.set(currentRender, []);\r\n }\r\n\r\n const componentMemos = memos.get(currentRender)!;\r\n const prevMemo = componentMemos[memoIndex];\r\n \r\n if (!prevMemo || (deps && deps.some((dep, i) => !Object.is(dep, prevMemo.deps[i])))) {\r\n const value = factory();\r\n componentMemos[memoIndex] = { value, deps };\r\n stateIndices.set(currentRender, memoIndex + 1);\r\n return value;\r\n }\r\n\r\n stateIndices.set(currentRender, memoIndex + 1);\r\n return prevMemo.value;\r\n}\r\n\r\nexport function useRef<T>(initial: T) {\r\n if (!currentRender) throw new Error('useRef must be called within a render');\r\n \r\n const refIndex = stateIndices.get(currentRender)!;\r\n \r\n if (!refs.has(currentRender)) {\r\n refs.set(currentRender, []);\r\n }\r\n\r\n const componentRefs = refs.get(currentRender)!;\r\n if (refIndex >= componentRefs.length) {\r\n // Initialize with an object that has a current property\r\n const ref = { current: initial };\r\n componentRefs.push(ref);\r\n stateIndices.set(currentRender, refIndex + 1);\r\n return ref;\r\n }\r\n\r\n const ref = componentRefs[refIndex];\r\n stateIndices.set(currentRender, refIndex + 1);\r\n return ref;\r\n}\r\n\r\n// Add a map to track component DOM nodes\r\nconst componentNodes = new Map<Function, Node>();\r\n\r\nasync function rerender(rendererId: number) {\r\n try {\r\n // Clean up effects\r\n const componentEffects = effects.get(rendererId);\r\n if (componentEffects) {\r\n componentEffects.forEach(effect => {\r\n if (effect.cleanup) effect.cleanup();\r\n });\r\n effects.set(rendererId, []);\r\n }\r\n\r\n if (globalRenderCallback && globalContainer && currentElement) {\r\n await globalRenderCallback(currentElement, globalContainer);\r\n }\r\n } catch (error) {\r\n console.error('Error during rerender:', error);\r\n }\r\n}\r\n\r\n// Add new hook for error boundaries\r\nexport function useErrorBoundary(): [Error | null, () => void] {\r\n const [error, setError] = useState<Error | null>(null);\r\n return [error, () => setError(null)];\r\n}\r\n\r\n// Remove withHooks export\r\n", "\r\n\r\nconst contexts = new Map<symbol, any>();\r\nlet currentRender: Function | null = null;\r\n\r\nexport interface Context<T> {\r\n Provider: (props: { value: T; children?: any }) => any;\r\n Consumer: (props: { children: (value: T) => any }) => any;\r\n _id: symbol;\r\n useSelector: <S>(selector: (state: T) => S) => S;\r\n}\r\n\r\nexport function createContext<T>(defaultValue: T): Context<T> {\r\n const context = {\r\n Provider: ({ value, children }: { value: T, children?: any }) => {\r\n return children;\r\n },\r\n Consumer: ({ children }: { children: (value: T) => any }) => {\r\n return children(defaultValue);\r\n },\r\n _id: Symbol(),\r\n useSelector: <S>(selector: (state: T) => S) => {\r\n return selector(defaultValue);\r\n }\r\n };\r\n\r\n return context;\r\n}\r\n\r\nexport function useContext<T>(context: any): T {\r\n return context;\r\n}\r\n", "import type { Component } from './component';\r\n\r\ninterface VNode {\r\n type: string | Function;\r\n props: Record<string, any>;\r\n}\r\n\r\nfunction jsx(type: string | Function, props: any): VNode {\r\n console.log('JSX Transform:', { type, props });\r\n const processedProps = { ...props };\r\n \r\n // Handle children properly\r\n if (arguments.length > 2) {\r\n processedProps.children = Array.prototype.slice.call(arguments, 2);\r\n }\r\n \r\n return { type, props: processedProps };\r\n}\r\n\r\nconst Fragment = ({ children }: { children: any }) => children;\r\n\r\nasync function createElement(vnode: VNode | any): Promise<Node> {\r\n console.log('Creating element from:', vnode);\r\n\r\n // Handle primitives and null\r\n if (vnode == null) {\r\n return document.createTextNode('');\r\n }\r\n \r\n if (typeof vnode === 'boolean') {\r\n return document.createTextNode('');\r\n }\r\n\r\n if (typeof vnode === 'number' || typeof vnode === 'string') {\r\n return document.createTextNode(String(vnode));\r\n }\r\n\r\n // Handle arrays\r\n if (Array.isArray(vnode)) {\r\n const fragment = document.createDocumentFragment();\r\n for (const child of vnode) {\r\n const node = await createElement(child);\r\n fragment.appendChild(node);\r\n }\r\n return fragment;\r\n }\r\n\r\n // Handle VNode\r\n if ('type' in vnode && vnode.props !== undefined) {\r\n const { type, props } = vnode;\r\n \r\n // Handle function components\r\n if (typeof type === 'function') {\r\n try {\r\n const result = await type(props || {});\r\n const node = await createElement(result);\r\n if (node instanceof Element) {\r\n node.setAttribute('data-component-id', type.name || type.toString());\r\n }\r\n return node;\r\n } catch (error) {\r\n console.error('Error rendering component:', error);\r\n return document.createTextNode('');\r\n }\r\n }\r\n\r\n // Create DOM element\r\n const element = document.createElement(type as string);\r\n \r\n // Handle props\r\n for (const [key, value] of Object.entries(props || {})) {\r\n if (key === 'children') continue;\r\n if (key.startsWith('on') && typeof value === 'function') {\r\n const eventName = key.toLowerCase().slice(2);\r\n // Remove existing event listener if any\r\n const existingHandler = (element as any).__events?.[eventName];\r\n if (existingHandler) {\r\n element.removeEventListener(eventName, existingHandler);\r\n }\r\n \r\n // Add new event listener\r\n element.addEventListener(eventName, value as EventListener);\r\n if (!(element as any).__events) {\r\n (element as any).__events = {};\r\n }\r\n (element as any).__events[eventName] = value;\r\n } else if (key === 'style' && typeof value === 'object') {\r\n Object.assign(element.style, value);\r\n } else if (key === 'className') {\r\n element.setAttribute('class', String(value));\r\n } else if (key !== 'key' && key !== 'ref') {\r\n element.setAttribute(key, String(value));\r\n }\r\n }\r\n\r\n // Handle children\r\n const children = props?.children;\r\n if (children != null) {\r\n const childArray = Array.isArray(children) ? children.flat() : [children];\r\n for (const child of childArray) {\r\n const childNode = await createElement(child);\r\n element.appendChild(childNode);\r\n }\r\n }\r\n\r\n return element;\r\n }\r\n\r\n // Handle other objects by converting to string\r\n return document.createTextNode(String(vnode));\r\n}\r\n\r\n// Export named functions and aliases without duplicates\r\nexport {\r\n jsx,\r\n jsx as jsxs,\r\n jsx as jsxDEV,\r\n Fragment,\r\n createElement\r\n};\r\n\r\n// Named exports object\r\nconst jsxRuntime = {\r\n jsx,\r\n jsxs: jsx,\r\n jsxDEV: jsx,\r\n Fragment,\r\n createElement\r\n};\r\n\r\nexport default jsxRuntime;\r\n", "import { createElement } from './jsx-runtime';\r\nimport { prepareRender, finishRender, setRenderCallback } from './hooks';\r\nimport { batchUpdates } from './batch';\r\n\r\nlet isHydrating = false;\r\n\r\nexport async function hydrate(element: any, container: HTMLElement) {\r\n isHydrating = true;\r\n try {\r\n await render(element, container);\r\n } finally {\r\n isHydrating = false;\r\n }\r\n}\r\n\r\nexport async function render(element: any, container: HTMLElement) {\r\n console.log('Rendering to:', container.id);\r\n \r\n batchUpdates(async () => {\r\n const rendererId = prepareRender();\r\n try {\r\n setRenderCallback(render, element, container);\r\n const domNode = await createElement(element);\r\n \r\n if (!isHydrating) {\r\n container.innerHTML = '';\r\n }\r\n container.appendChild(domNode);\r\n \r\n } finally {\r\n finishRender();\r\n }\r\n });\r\n}\r\n", "import { VNode, Component } from './types';\r\nimport { prepareRender, finishRender } from './hooks';\r\n\r\n/**\r\n * Renders a virtual DOM tree to an HTML string\r\n */\r\nexport function renderToString(vnode: VNode): string {\r\n // Reset hook state for this render\r\n prepareRender();\r\n \r\n // Render the tree to HTML\r\n const html = renderNodeToString(vnode);\r\n \r\n // Clean up after rendering\r\n finishRender();\r\n \r\n return html;\r\n}\r\n\r\n/**\r\n * Internal function to convert a virtual node to an HTML string\r\n */\r\nfunction renderNodeToString(vnode: VNode | string | number | boolean | null | undefined): string {\r\n // Handle primitive values\r\n if (vnode === null || vnode === undefined) return '';\r\n if (typeof vnode === 'boolean') return '';\r\n if (typeof vnode === 'number' || typeof vnode === 'string') return escapeHtml(String(vnode));\r\n \r\n // Handle function components\r\n if (typeof vnode.type === 'function') {\r\n const Component = vnode.type as Component;\r\n const renderedNode = Component(vnode.props || {});\r\n return renderNodeToString(renderedNode);\r\n }\r\n \r\n // Handle intrinsic elements (regular HTML tags)\r\n if (typeof vnode.type === 'string') {\r\n const tag = vnode.type;\r\n let attrs = '';\r\n let children = '';\r\n \r\n // Convert props to HTML attributes\r\n if (vnode.props) {\r\n for (const [key, value] of Object.entries(vnode.props)) {\r\n // Skip children prop as we handle it separately\r\n if (key === 'children') continue;\r\n \r\n // Skip event handlers (they start with 'on')\r\n if (key.startsWith('on')) continue;\r\n \r\n // Handle the className prop specially\r\n if (key === 'className') {\r\n attrs += ` class=\"${escapeHtml(value as string)}\"`;\r\n continue;\r\n }\r\n \r\n // Handle other attributes\r\n if (typeof value === 'string' || typeof value === 'number') {\r\n attrs += ` ${key}=\"${escapeHtml(String(value))}\"`;\r\n } else if (value === true) {\r\n // Boolean attributes\r\n attrs += ` ${key}`;\r\n }\r\n }\r\n }\r\n \r\n // Process children\r\n const childrenArray = (vnode.props?.children) \r\n ? Array.isArray(vnode.props.children) \r\n ? vnode.props.children \r\n : [vnode.props.children]\r\n : [];\r\n \r\n for (const child of childrenArray) {\r\n children += renderNodeToString(child);\r\n }\r\n \r\n // Self-closing tags\r\n const selfClosing = [\r\n 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',\r\n 'link', 'meta', 'param', 'source', 'track', 'wbr'\r\n ];\r\n \r\n if (selfClosing.includes(tag)) {\r\n return `<${tag}${attrs}/>`;\r\n }\r\n \r\n // Regular tags with closing\r\n return `<${tag}${attrs}>${children}</${tag}>`;\r\n }\r\n \r\n // Handle fragments\r\n if (vnode.type === Symbol.for('react.fragment')) {\r\n let fragmentOutput = '';\r\n const children = Array.isArray(vnode.props?.children)\r\n ? vnode.props.children\r\n : vnode.props?.children ? [vnode.props.children] : [];\r\n \r\n for (const child of children) {\r\n fragmentOutput += renderNodeToString(child);\r\n }\r\n \r\n return fragmentOutput;\r\n }\r\n \r\n // Fallback for unknown node types\r\n console.warn('Unknown vnode type:', vnode.type);\r\n return '';\r\n}\r\n\r\n/**\r\n * Escape HTML special characters to prevent XSS\r\n */\r\nfunction escapeHtml(text: string): string {\r\n return text\r\n .replace(/&/g, '&amp;')\r\n .replace(/</g, '&lt;')\r\n .replace(/>/g, '&gt;')\r\n .replace(/\"/g, '&quot;')\r\n .replace(/'/g, '&#039;');\r\n}\r\n", "import { createElement } from './jsx-runtime';\r\nimport { prepareRender, finishRender, setRenderCallback } from './hooks';\r\n\r\nexport { \r\n useState, \r\n useEffect, \r\n useMemo, \r\n useRef,\r\n useErrorBoundary \r\n} from './hooks';\r\n\r\nexport { createContext, useContext } from './context';\r\nexport { batchUpdates } from './batch';\r\nexport { jsx, jsxs, Fragment } from './jsx-runtime';\r\nexport { render, hydrate } from './renderer';\r\nexport { renderToString } from './server-renderer';\r\n\r\n// Re-export types for client-side usage\r\nexport type { Context } from './context';\r\nexport type { VNode } from './types';\r\n\r\n// Export a placeholder for server functionality that works in browser environments\r\nexport const server = {\r\n async getServer() {\r\n throw new Error('Server module can only be used in Node.js environment');\r\n }\r\n};\r\n\r\nlet isHydrating = false;\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx } from 'frontend-hamroun';\r\n\r\nexport default function NotFound({ initialState }) {\r\n return (\r\n <div className=\"not-found-container max-w-4xl mx-auto p-6\">\r\n <div className=\"bg-gray-50 border border-gray-200 rounded-lg p-8 shadow-sm\">\r\n <h1 className=\"text-3xl font-bold text-gray-700 mb-4\">Page Not Found</h1>\r\n \r\n <p className=\"text-lg text-gray-600 mb-4\">\r\n The page you are looking for does not exist or has been moved.\r\n </p>\r\n \r\n <p className=\"text-gray-600 mb-6\">\r\n Path: <code className=\"bg-gray-100 px-2 py-1 rounded\">{initialState?.route || 'unknown'}</code>\r\n </p>\r\n \r\n <div className=\"mt-6\">\r\n <a \r\n href=\"/\"\r\n className=\"inline-block px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700\"\r\n >\r\n Back to Home\r\n </a>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n}\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx } from 'frontend-hamroun';\r\n\r\ninterface LayoutProps {\r\n children: any;\r\n title?: string;\r\n}\r\n\r\nexport default function Layout({ children, title = 'Frontend Hamroun App' }: LayoutProps) {\r\n return (\r\n <div className=\"min-h-screen flex flex-col bg-gray-50\">\r\n <header className=\"bg-blue-600 text-white\">\r\n <div className=\"container mx-auto px-4 py-4 flex justify-between items-center\">\r\n <h1 className=\"text-xl font-bold\">\r\n <a href=\"/\" className=\"hover:text-blue-100\">\r\n {title}\r\n </a>\r\n </h1>\r\n \r\n <nav>\r\n <ul className=\"flex space-x-6\">\r\n <li><a href=\"/\" className=\"hover:text-blue-100\">Home</a></li>\r\n <li><a href=\"/about\" className=\"hover:text-blue-100\">About</a></li>\r\n {/* WASM demo link removed */}\r\n </ul>\r\n </nav>\r\n </div>\r\n </header>\r\n \r\n <main className=\"flex-grow container mx-auto px-4 py-8\">\r\n {children}\r\n </main>\r\n \r\n <footer className=\"bg-gray-800 text-white\">\r\n <div className=\"container mx-auto px-4 py-6\">\r\n <p className=\"text-center text-gray-400\">\r\n &copy; {new Date().getFullYear()} Frontend Hamroun App. All rights reserved.\r\n </p>\r\n </div>\r\n </footer>\r\n </div>\r\n );\r\n}\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx } from 'frontend-hamroun';\r\nimport Layout from '../components/Layout';\r\n\r\n// This is the main App wrapper component similar to Next.js _app.js\r\nexport default function App({ Component, pageProps, initialState }) {\r\n return (\r\n <Layout>\r\n <Component {...pageProps} initialState={initialState} />\r\n </Layout>\r\n );\r\n}\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx } from 'frontend-hamroun';\r\n\r\nexport default function Document({ \r\n title = 'Frontend Hamroun App',\r\n headContent,\r\n bodyContent,\r\n scripts\r\n}) {\r\n return (\r\n <html lang=\"en\">\r\n <head>\r\n <meta charSet=\"UTF-8\" />\r\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\r\n <title>{title}</title>\r\n <link rel=\"stylesheet\" href=\"/styles.css\" />\r\n {headContent}\r\n </head>\r\n <body>\r\n <div id=\"root\">{bodyContent}</div>\r\n <script src=\"/build/main.js\" type=\"module\"></script>\r\n {scripts}\r\n </body>\r\n </html>\r\n );\r\n}\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx, useState, useEffect } from 'frontend-hamroun';\r\n\r\nexport default function ErrorPage({ initialState }) {\r\n const { error } = initialState || {};\r\n const [showDetails, setShowDetails] = useState(false);\r\n const isDev = process.env.NODE_ENV !== 'production';\r\n \r\n return (\r\n <div className=\"error-page-container max-w-4xl mx-auto p-6\">\r\n <div className=\"bg-red-50 border border-red-200 rounded-lg p-8 shadow-sm\">\r\n <h1 className=\"text-3xl font-bold text-red-700 mb-4\">Something went wrong</h1>\r\n \r\n <p className=\"text-lg text-red-600 mb-4\">\r\n {error?.message || \"An unexpected error occurred\"}\r\n </p>\r\n \r\n {isDev && error?.stack && (\r\n <div className=\"mt-6\">\r\n <button\r\n className=\"text-blue-600 underline mb-2\"\r\n onClick={() => setShowDetails(!showDetails)}\r\n >\r\n {showDetails ? \"Hide\" : \"Show\"} technical details\r\n </button>\r\n \r\n {showDetails && (\r\n <pre className=\"bg-gray-100 p-4 rounded-md text-sm overflow-auto max-h-96 text-gray-800\">\r\n {error.stack}\r\n </pre>\r\n )}\r\n </div>\r\n )}\r\n \r\n <div className=\"mt-6\">\r\n <a \r\n href=\"/\"\r\n className=\"inline-block px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700\"\r\n >\r\n Back to Home\r\n </a>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n}\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx } from 'frontend-hamroun';\r\nimport Layout from '../components/Layout';\r\n\r\nexport default function AboutPage({ initialState }) {\r\n return (\r\n <Layout title=\"About - Frontend Hamroun\">\r\n <div className=\"max-w-4xl mx-auto\">\r\n <h1 className=\"text-3xl font-bold text-blue-600 mb-6\">\r\n About Frontend Hamroun\r\n </h1>\r\n \r\n <div className=\"bg-white shadow-lg rounded-lg p-8 mb-8\">\r\n <h2 className=\"text-xl font-semibold text-gray-800 mb-4\">What is Frontend Hamroun?</h2>\r\n <p className=\"text-gray-600 mb-4\">\r\n Frontend Hamroun is a lightweight JavaScript framework for building modern web applications.\r\n It provides a familiar component-based architecture with hooks, JSX support, and \r\n server-side rendering capabilities.\r\n </p>\r\n <p className=\"text-gray-600 mb-4\">\r\n This framework is designed to be simple yet powerful, offering the essential features\r\n needed for web application development without the complexity of larger frameworks.\r\n </p>\r\n \r\n <h3 className=\"text-lg font-medium text-gray-700 mt-6 mb-2\">Key Features:</h3>\r\n <ul className=\"list-disc pl-6 text-gray-600 space-y-2\">\r\n <li>Component-based architecture</li>\r\n <li>JSX support</li>\r\n <li>Hooks for state and effects</li>\r\n <li>Server-side rendering</li>\r\n <li>Minimal API surface</li>\r\n <li>File-based routing</li>\r\n <li>Built-in API routes</li>\r\n </ul>\r\n </div>\r\n \r\n <div className=\"bg-white shadow-lg rounded-lg p-8\">\r\n <h2 className=\"text-xl font-semibold text-gray-800 mb-4\">Getting Started</h2>\r\n <p className=\"text-gray-600 mb-4\">\r\n This application was created using the Frontend Hamroun fullstack template,\r\n which provides a complete setup for building applications with server-side rendering,\r\n API routes, and client-side navigation.\r\n </p>\r\n \r\n <div className=\"bg-gray-50 p-4 rounded-md mt-4\">\r\n <h3 className=\"text-md font-medium text-gray-700 mb-2\">Quick Start:</h3>\r\n <pre className=\"bg-gray-800 text-gray-100 p-4 rounded overflow-x-auto\">\r\n <code>{`# Create a new application\r\nnpx frontend-hamroun create my-app\r\n\r\n# Change directory\r\ncd my-app\r\n\r\n# Start the development server\r\nnpm run dev`}</code>\r\n </pre>\r\n </div>\r\n </div>\r\n </div>\r\n </Layout>\r\n );\r\n}\r\n\r\n// Server-side data fetching\r\nexport async function getServerSideProps() {\r\n return {\r\n props: {\r\n pageTitle: 'About Frontend Hamroun',\r\n description: 'Learn more about the Frontend Hamroun framework'\r\n }\r\n };\r\n}\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx } from 'frontend-hamroun';\r\nimport Layout from '../../components/Layout';\r\n\r\nconst AboutPage = ({ initialState }) => {\r\n return (\r\n <Layout title=\"About This App\">\r\n <div className=\"max-w-4xl mx-auto bg-white shadow-lg rounded-lg overflow-hidden\">\r\n <div className=\"p-8\">\r\n <p className=\"text-lg text-gray-700 mb-6\">\r\n This is a frontend application built with Frontend Hamroun framework and styled with Tailwind CSS.\r\n </p>\r\n <p className=\"text-gray-600 mb-8\">\r\n It features server-side rendering, client-side navigation, and websocket-based live reloading during development.\r\n </p>\r\n \r\n <div className=\"bg-gray-50 p-6 rounded-lg border border-gray-200 mb-8\">\r\n <h2 className=\"text-xl font-semibold text-gray-800 mb-4\">Key Features</h2>\r\n <ul className=\"space-y-2 text-gray-700\">\r\n <li className=\"flex items-center\">\r\n <svg className=\"w-5 h-5 text-green-500 mr-2\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M5 13l4 4L19 7\"></path>\r\n </svg>\r\n Server-side rendering\r\n </li>\r\n <li className=\"flex items-center\">\r\n <svg className=\"w-5 h-5 text-green-500 mr-2\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M5 13l4 4L19 7\"></path>\r\n </svg>\r\n Client-side navigation\r\n </li>\r\n <li className=\"flex items-center\">\r\n <svg className=\"w-5 h-5 text-green-500 mr-2\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M5 13l4 4L19 7\"></path>\r\n </svg>\r\n Component-based architecture\r\n </li>\r\n <li className=\"flex items-center\">\r\n <svg className=\"w-5 h-5 text-green-500 mr-2\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M5 13l4 4L19 7\"></path>\r\n </svg>\r\n Integrated API backend\r\n </li>\r\n <li className=\"flex items-center\">\r\n <svg className=\"w-5 h-5 text-green-500 mr-2\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M5 13l4 4L19 7\"></path>\r\n </svg>\r\n Live reload during development\r\n </li>\r\n <li className=\"flex items-center\">\r\n <svg className=\"w-5 h-5 text-green-500 mr-2\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M5 13l4 4L19 7\"></path>\r\n </svg>\r\n Tailwind CSS for styling\r\n </li>\r\n </ul>\r\n </div>\r\n \r\n <a href=\"/\" className=\"inline-block px-6 py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors\">\r\n Back to Home\r\n </a>\r\n </div>\r\n </div>\r\n </Layout>\r\n );\r\n};\r\n\r\nexport default AboutPage;\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx } from 'frontend-hamroun';\r\n\r\ninterface User {\r\n id: number;\r\n name: string;\r\n email: string;\r\n}\r\n\r\ninterface UserListProps {\r\n users: User[];\r\n}\r\n\r\nexport default function UserList({ users }: UserListProps) {\r\n if (!users || users.length === 0) {\r\n return (\r\n <div className=\"empty-state p-4 text-center bg-gray-50 rounded\">\r\n <p className=\"text-gray-500\">No users available</p>\r\n </div>\r\n );\r\n }\r\n \r\n return (\r\n <div className=\"user-list\">\r\n <ul className=\"divide-y divide-gray-100\">\r\n {users.map(user => (\r\n <li key={user.id} className=\"py-3\">\r\n <div className=\"flex justify-between\">\r\n <div>\r\n <p className=\"font-medium text-gray-900\">{user.name}</p>\r\n <p className=\"text-sm text-gray-500\">{user.email}</p>\r\n </div>\r\n <a \r\n href={`/users/${user.id}`}\r\n className=\"text-blue-600 hover:underline text-sm self-center\"\r\n >\r\n View Profile\r\n </a>\r\n </div>\r\n </li>\r\n ))}\r\n </ul>\r\n </div>\r\n );\r\n}\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx, useState, useEffect, useMemo } from 'frontend-hamroun';\r\n\r\n// Define our state types for better type safety\r\ninterface CounterState {\r\n count: number;\r\n lastUpdated: string | null;\r\n history: number[];\r\n}\r\n\r\nexport default function StateDemo() {\r\n // More comprehensive state with history tracking\r\n const [state, setState] = useState<CounterState>({\r\n count: 0,\r\n lastUpdated: null,\r\n history: []\r\n });\r\n \r\n // Track UI state separately\r\n const [isLoading, setIsLoading] = useState(false);\r\n const [showHistory, setShowHistory] = useState(false);\r\n \r\n // Check for server-side rendering\r\n const isSSR = typeof window === 'undefined';\r\n \r\n // Calculate derived state with useMemo for performance\r\n const stats = useMemo(() => {\r\n // Ensure we have a valid history array\r\n if (isSSR || !state || !state.history || state.history.length === 0) {\r\n return { avg: 0, max: 0, min: 0 };\r\n }\r\n \r\n try {\r\n const sum = state.history.reduce((a, b) => a + b, 0);\r\n return {\r\n avg: parseFloat((sum / state.history.length).toFixed(1)),\r\n max: Math.max(...state.history),\r\n min: Math.min(...state.history)\r\n };\r\n } catch (error) {\r\n console.error('Error calculating stats:', error);\r\n return { avg: 0, max: 0, min: 0 };\r\n }\r\n }, [state?.history]);\r\n \r\n // Handle increment with history tracking\r\n const increment = () => {\r\n if (isSSR) return;\r\n \r\n setIsLoading(true);\r\n \r\n // Simulate async operation\r\n setTimeout(() => {\r\n setState(prevState => ({\r\n count: prevState.count + 1,\r\n lastUpdated: new Date().toLocaleTimeString(),\r\n history: [...(prevState.history || []), prevState.count + 1]\r\n }));\r\n setIsLoading(false);\r\n }, 300);\r\n };\r\n \r\n // Handle decrement with bounds checking\r\n const decrement = () => {\r\n if (isSSR) return;\r\n \r\n setIsLoading(true);\r\n \r\n // Simulate async operation\r\n setTimeout(() => {\r\n setState(prevState => ({\r\n count: Math.max(0, prevState.count - 1),\r\n lastUpdated: new Date().toLocaleTimeString(),\r\n history: prevState.count > 0 ? [...(prevState.history || []), prevState.count - 1] : (prevState.history || [])\r\n }));\r\n setIsLoading(false);\r\n }, 300);\r\n };\r\n \r\n // Reset counter\r\n const reset = () => {\r\n if (isSSR) return;\r\n \r\n setState({\r\n count: 0,\r\n lastUpdated: new Date().toLocaleTimeString(),\r\n history: []\r\n });\r\n };\r\n \r\n // Toggle history visibility\r\n const toggleHistory = () => {\r\n if (isSSR) return;\r\n \r\n setShowHistory(prev => !prev);\r\n };\r\n \r\n // For SSR, return a simpler version of the component\r\n if (isSSR) {\r\n return (\r\n <div className=\"bg-white shadow-lg rounded-lg p-6 mb-8\">\r\n <h2 className=\"text-xl font-semibold text-gray-800 mb-4\">\r\n State Management Demo\r\n </h2>\r\n <div className=\"flex items-center justify-between mb-4\">\r\n <button className=\"px-4 py-2 bg-gray-200 text-gray-800 rounded-lg\">-</button>\r\n <span className=\"text-2xl font-bold mx-4\">0</span>\r\n <button className=\"px-4 py-2 bg-blue-600 text-white rounded-lg\">+</button>\r\n </div>\r\n <p className=\"text-sm text-gray-500\">Interactive counter (client-side only)</p>\r\n </div>\r\n );\r\n }\r\n \r\n // Regular client-side render\r\n return (\r\n <div className=\"bg-white shadow-lg rounded-lg p-6 mb-8\">\r\n <h2 className=\"text-xl font-semibold text-gray-800 mb-4\">\r\n State Management Demo\r\n </h2>\r\n \r\n <div className=\"mb-6\">\r\n <div className=\"flex items-center justify-between mb-4\">\r\n <button \r\n onClick={decrement}\r\n className=\"px-4 py-2 bg-gray-200 text-gray-800 rounded-lg hover:bg-gray-300 disabled:opacity-50\"\r\n disabled={state.count === 0 || isLoading}\r\n >\r\n {isLoading ? '...' : '-'}\r\n </button>\r\n \r\n <span className=\"text-2xl font-bold mx-4\">{state.count}</span>\r\n \r\n <button \r\n onClick={increment}\r\n className=\"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50\"\r\n disabled={isLoading}\r\n >\r\n {isLoading ? '...' : '+'}\r\n </button>\r\n </div>\r\n \r\n <button\r\n onClick={reset}\r\n className=\"text-sm text-gray-600 hover:text-red-600\"\r\n disabled={state.count === 0 && (!state.history || state.history.length === 0)}\r\n >\r\n Reset Counter\r\n </button>\r\n </div>\r\n \r\n {state.lastUpdated && (\r\n <div className=\"mb-4\">\r\n <p className=\"text-sm text-gray-500\">\r\n Last updated: {state.lastUpdated}\r\n </p>\r\n </div>\r\n )}\r\n \r\n {state.history && state.history.length > 0 && (\r\n <div className=\"border-t pt-4 mt-4\">\r\n <div className=\"flex items-center justify-between mb-2\">\r\n <h3 className=\"text-md font-medium text-gray-700\">Statistics</h3>\r\n <button\r\n onClick={toggleHistory}\r\n className=\"text-sm text-blue-600 hover:underline\"\r\n >\r\n {showHistory ? 'Hide History' : 'Show History'}\r\n </button>\r\n </div>\r\n \r\n <div className=\"grid grid-cols-3 gap-2 mb-3\">\r\n <div className=\"bg-blue-50 p-2 rounded text-center\">\r\n <div className=\"text-xs text-gray-500\">Average</div>\r\n <div className=\"font-bold\">{stats.avg}</div>\r\n </div>\r\n <div className=\"bg-green-50 p-2 rounded text-center\">\r\n <div className=\"text-xs text-gray-500\">Maximum</div>\r\n <div className=\"font-bold\">{stats.max}</div>\r\n </div>\r\n <div className=\"bg-red-50 p-2 rounded text-center\">\r\n <div className=\"text-xs text-gray-500\">Minimum</div>\r\n <div className=\"font-bold\">{stats.min}</div>\r\n </div>\r\n </div>\r\n \r\n {showHistory && (\r\n <div className=\"mt-3\">\r\n <h4 className=\"text-sm font-medium text-gray-600 mb-1\">\r\n History ({state.history.length} events)\r\n </h4>\r\n <div className=\"bg-gray-50 p-2 rounded max-h-24 overflow-y-auto text-xs\">\r\n {state.history.map((value, index) => (\r\n <span \r\n key={index} \r\n className=\"inline-block bg-gray-200 rounded px-2 py-1 m-1\"\r\n >\r\n {value}\r\n </span>\r\n ))}\r\n </div>\r\n </div>\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n}\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx, useState, useEffect, useErrorBoundary } from 'frontend-hamroun';\r\n\r\ninterface ErrorBoundaryProps {\r\n children: any;\r\n fallback?: (error: Error, reset: () => void) => any;\r\n}\r\n\r\nexport function ErrorBoundary({ children, fallback }: ErrorBoundaryProps) {\r\n const [error, resetError] = useErrorBoundary();\r\n \r\n if (error) {\r\n if (fallback) {\r\n return fallback(error, resetError);\r\n }\r\n \r\n return (\r\n <div className=\"error-boundary p-4 border border-red-500 rounded bg-red-50\">\r\n <h3 className=\"text-lg font-medium text-red-800 mb-2\">Something went wrong</h3>\r\n <p className=\"text-red-600 mb-2\">{error.message}</p>\r\n <button\r\n onClick={resetError}\r\n className=\"px-3 py-1 bg-red-600 text-white rounded hover:bg-red-700\"\r\n >\r\n Try again\r\n </button>\r\n {process.env.NODE_ENV !== 'production' && (\r\n <pre className=\"mt-3 text-xs overflow-auto p-2 bg-gray-100\">\r\n {error.stack}\r\n </pre>\r\n )}\r\n </div>\r\n );\r\n }\r\n \r\n return children;\r\n}\r\n", "/**\r\n * API utilities for making requests to the backend\r\n */\r\nimport { batchUpdates } from 'frontend-hamroun';\r\n\r\n// Cache for API responses\r\nconst apiCache = new Map<string, { data: any, timestamp: number }>();\r\nconst CACHE_DURATION = 60000; // 1 minute cache\r\n\r\n/**\r\n * Fetch data from the API with caching\r\n */\r\nexport async function fetchApi(\r\n endpoint: string, \r\n options: RequestInit & { \r\n useCache?: boolean,\r\n forceFresh?: boolean \r\n } = {}\r\n): Promise<any> {\r\n const url = endpoint.startsWith('/') ? `/api${endpoint}` : `/api/${endpoint}`;\r\n const { useCache = true, forceFresh = false, ...fetchOptions } = options;\r\n \r\n // Check cache first if enabled\r\n if (useCache && !forceFresh) {\r\n const cached = apiCache.get(url);\r\n if (cached && Date.now() - cached.timestamp < CACHE_DURATION) {\r\n console.log(`[API] Using cached data for: ${url}`);\r\n return cached.data;\r\n }\r\n }\r\n \r\n try {\r\n console.log(`[API] Fetching data from: ${url}`);\r\n const response = await fetch(url, {\r\n headers: {\r\n 'Content-Type': 'application/json',\r\n 'Accept': 'application/json',\r\n },\r\n ...fetchOptions\r\n });\r\n \r\n if (!response.ok) {\r\n throw new Error(`API request failed: ${response.status} ${response.statusText}`);\r\n }\r\n \r\n const data = await response.json();\r\n console.log(`[API] Successfully fetched data from: ${url}`);\r\n \r\n // Cache the response if caching is enabled\r\n if (useCache) {\r\n apiCache.set(url, { data, timestamp: Date.now() });\r\n }\r\n \r\n return data;\r\n } catch (error) {\r\n console.error(`[API] Error fetching from ${url}:`, error);\r\n throw error;\r\n }\r\n}\r\n\r\n/**\r\n * Clear the API cache\r\n */\r\nexport function clearApiCache(endpoint?: string): void {\r\n if (endpoint) {\r\n const url = endpoint.startsWith('/') ? `/api${endpoint}` : `/api/${endpoint}`;\r\n apiCache.delete(url);\r\n } else {\r\n apiCache.clear();\r\n }\r\n}\r\n\r\n// Sample data for development\r\nconst sampleUsers = [\r\n { id: 1, name: 'User 1', email: 'user1@example.com' },\r\n { id: 2, name: 'User 2', email: 'user2@example.com' },\r\n { id: 3, name: 'User 3', email: 'user3@example.com' }\r\n];\r\n\r\nconst samplePosts = [\r\n { id: 1, title: 'Post 1', content: 'Content for post 1', authorId: 1 },\r\n { id: 2, title: 'Post 2', content: 'Content for post 2', authorId: 2 },\r\n { id: 3, title: 'Post 3', content: 'Content for post 3', authorId: 1 }\r\n];\r\n\r\n// Helper to simulate network delay\r\nconst delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));\r\n\r\n// User API client\r\nexport const UserApi = {\r\n // Get all users\r\n async getAll() {\r\n try {\r\n // In a real app, we'd fetch from API\r\n // const response = await fetch('/api/users');\r\n // if (!response.ok) throw new Error('Failed to fetch users');\r\n // return await response.json();\r\n \r\n // Simulate API delay\r\n await delay(300);\r\n return [...sampleUsers]; // Return a copy to avoid mutations\r\n } catch (error) {\r\n console.error('Error fetching users:', error);\r\n return [];\r\n }\r\n },\r\n \r\n // Get user by ID\r\n async getById(id: number | string) {\r\n try {\r\n // In a real app, we'd fetch from API\r\n // const response = await fetch(`/api/users/${id}`);\r\n // if (!response.ok) throw new Error('User not found');\r\n // return await response.json();\r\n \r\n // Convert ID to number if it's a string\r\n const userId = typeof id === 'string' ? parseInt(id, 10) : id;\r\n \r\n // Simulate API delay\r\n await delay(200);\r\n \r\n // Find user\r\n const user = sampleUsers.find(u => u.id === userId);\r\n if (!user) throw new Error('User not found');\r\n \r\n return { ...user }; // Return a copy to avoid mutations\r\n } catch (error) {\r\n console.error(`Error fetching user ${id}:`, error);\r\n return null;\r\n }\r\n },\r\n \r\n // Get posts (all or by author)\r\n async getPosts(authorId?: number | string) {\r\n try {\r\n // In a real app, we'd fetch from API\r\n // const url = authorId ? `/api/posts?authorId=${authorId}` : '/api/posts';\r\n // const response = await fetch(url);\r\n // if (!response.ok) throw new Error('Failed to fetch posts');\r\n // return await response.json();\r\n \r\n // Convert authorId to number if it's a string\r\n const userId = authorId ? (typeof authorId === 'string' ? parseInt(authorId, 10) : authorId) : undefined;\r\n \r\n // Simulate API delay\r\n await delay(400);\r\n \r\n // Filter posts if authorId is provided\r\n const posts = userId\r\n ? samplePosts.filter(p => p.authorId === userId)\r\n : samplePosts;\r\n \r\n return [...posts]; // Return a copy to avoid mutations\r\n } catch (error) {\r\n console.error('Error fetching posts:', error);\r\n return [];\r\n }\r\n }\r\n};\r\n\r\n// WASM API service\r\nexport const WasmApi = {\r\n calculate: (operation: 'add' | 'multiply', a: number, b: number) => \r\n fetchApi(`/wasm/calculate?op=${operation}&a=${a}&b=${b}`),\r\n \r\n processJson: (data: any) => fetchApi('/wasm/process-json', {\r\n method: 'POST',\r\n body: JSON.stringify(data),\r\n useCache: false\r\n })\r\n};\r\n\r\n// Batch multiple API calls for efficiency\r\nexport const batchApiCalls = async <T>(\r\n apiFunctions: Array<() => Promise<T>>\r\n): Promise<T[]> => {\r\n const results: T[] = [];\r\n let errors: Error[] = [];\r\n \r\n // Execute all API calls in parallel\r\n const promises = apiFunctions.map(fn => fn());\r\n \r\n try {\r\n const settledResults = await Promise.allSettled(promises);\r\n \r\n // Process results\r\n batchUpdates(() => {\r\n settledResults.forEach(result => {\r\n if (result.status === 'fulfilled') {\r\n results.push(result.value);\r\n } else {\r\n errors.push(result.reason);\r\n }\r\n });\r\n });\r\n \r\n if (errors.length) {\r\n console.error('[API] Some batch API calls failed:', errors);\r\n }\r\n \r\n return results;\r\n } catch (error) {\r\n console.error('[API] Batch API calls failed:', error);\r\n throw error;\r\n }\r\n};\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx, useState, useEffect, batchUpdates } from 'frontend-hamroun';\r\nimport UserList from '../components/UserList';\r\nimport StateDemo from '../components/StateDemo';\r\nimport { ErrorBoundary } from '../components/ErrorBoundary';\r\nimport { UserApi } from '../data/api';\r\n\r\n// Home Page Component with Server Side Props\r\nexport default function HomePage({ users, posts, initialState }) {\r\n const [state, setState] = useState(initialState || {});\r\n const [refreshTrigger, setRefreshTrigger] = useState(0);\r\n \r\n // Fetch data when refresh is triggered\r\n useEffect(() => {\r\n if (refreshTrigger === 0) return; // Skip initial render\r\n \r\n async function fetchData() {\r\n try {\r\n const [users, posts] = await Promise.all([\r\n UserApi.getAll(),\r\n UserApi.getPosts()\r\n ]);\r\n \r\n // Use batch updates for efficiency\r\n batchUpdates(() => {\r\n setState(prev => ({\r\n ...prev,\r\n data: {\r\n ...prev.data,\r\n users,\r\n posts\r\n },\r\n lastUpdate: new Date().toISOString()\r\n }));\r\n });\r\n } catch (error) {\r\n console.error('Error fetching data:', error);\r\n }\r\n }\r\n \r\n fetchData();\r\n }, [refreshTrigger]);\r\n \r\n const handleRefresh = () => {\r\n setRefreshTrigger(t => t + 1);\r\n };\r\n\r\n return (\r\n <div className=\"max-w-4xl mx-auto py-8\">\r\n <h1 className=\"text-3xl font-bold text-blue-600 mb-6\">\r\n Welcome to your Next-style Frontend Hamroun application!\r\n </h1>\r\n \r\n <div className=\"mb-8\">\r\n <button \r\n className=\"mb-4 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700\"\r\n onClick={handleRefresh}\r\n >\r\n Refresh Data\r\n </button>\r\n \r\n <div className=\"bg-blue-50 p-4 rounded-lg border border-blue-100 mb-6\">\r\n <p className=\"text-blue-700\">\r\n Last updated: {state.lastUpdate || 'Never'} \r\n </p>\r\n </div>\r\n </div>\r\n \r\n <ErrorBoundary>\r\n <div className=\"bg-white shadow-lg rounded-lg p-6 mb-8\">\r\n <h2 className=\"text-xl font-semibold text-gray-800 mb-4\">User List</h2>\r\n <UserList users={users || state.data?.users || []} />\r\n </div>\r\n </ErrorBoundary>\r\n \r\n <ErrorBoundary>\r\n <StateDemo />\r\n </ErrorBoundary>\r\n \r\n <div className=\"bg-gray-50 rounded-lg p-6 border border-gray-200 mt-8\">\r\n <h3 className=\"text-lg font-medium text-gray-700 mb-3\">Application State</h3>\r\n <pre className=\"overflow-auto p-4 bg-gray-100 rounded-md text-sm text-gray-800\">\r\n {JSON.stringify({ users, posts, ...state }, null, 2)}\r\n </pre>\r\n </div>\r\n </div>\r\n );\r\n}\r\n\r\n// Server-side data fetching (Next.js style)\r\nexport async function getServerSideProps() {\r\n try {\r\n const users = await UserApi.getAll();\r\n const posts = await UserApi.getPosts();\r\n \r\n return {\r\n props: {\r\n users,\r\n posts\r\n }\r\n };\r\n } catch (error) {\r\n console.error('Error fetching initial data:', error);\r\n return {\r\n props: {\r\n users: [],\r\n posts: []\r\n }\r\n };\r\n }\r\n}\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx } from 'frontend-hamroun';\r\nimport Layout from '../components/Layout';\r\nimport { UserApi } from '../data/api';\r\n\r\nconst UsersPage = ({ initialState }) => {\r\n const users = initialState.data?.users || [];\r\n\r\n return (\r\n <Layout title=\"User Management\">\r\n <div className=\"max-w-4xl mx-auto\">\r\n <div className=\"bg-blue-50 p-6 rounded-lg mb-8 border border-blue-100\">\r\n <h2 className=\"text-xl font-semibold text-blue-800 mb-2\">Data Fetching Demo</h2>\r\n <p className=\"text-blue-700\">This page demonstrates dynamic data fetching with the Users API.</p>\r\n </div>\r\n \r\n <div className=\"bg-white shadow-md rounded-lg overflow-hidden\">\r\n <div className=\"px-6 py-4 border-b border-gray-200\">\r\n <h2 className=\"text-xl font-semibold text-gray-800\">User List</h2>\r\n </div>\r\n \r\n {users.length === 0 ? (\r\n <div className=\"p-6 text-center text-gray-500\">\r\n <p>No users found.</p>\r\n </div>\r\n ) : (\r\n <div className=\"overflow-x-auto\">\r\n <table className=\"w-full\">\r\n <thead>\r\n <tr className=\"bg-gray-50\">\r\n <th className=\"text-left py-3 px-6 font-medium text-gray-600 text-sm uppercase tracking-wider border-b\">ID</th>\r\n <th className=\"text-left py-3 px-6 font-medium text-gray-600 text-sm uppercase tracking-wider border-b\">Name</th>\r\n <th className=\"text-left py-3 px-6 font-medium text-gray-600 text-sm uppercase tracking-wider border-b\">Email</th>\r\n </tr>\r\n </thead>\r\n <tbody className=\"divide-y divide-gray-200\">\r\n {users.map(user => (\r\n <tr key={user.id} className=\"hover:bg-gray-50\">\r\n <td className=\"py-4 px-6 text-sm text-gray-900\">{user.id}</td>\r\n <td className=\"py-4 px-6 text-sm font-medium text-gray-900\">{user.name}</td>\r\n <td className=\"py-4 px-6 text-sm text-gray-500\">{user.email}</td>\r\n </tr>\r\n ))}\r\n </tbody>\r\n </table>\r\n </div>\r\n )}\r\n </div>\r\n </div>\r\n </Layout>\r\n );\r\n};\r\n\r\n// Static method to fetch initial data for this page\r\nUsersPage.getInitialData = async () => {\r\n return {\r\n users: await UserApi.getAll()\r\n };\r\n};\r\n\r\nexport default UsersPage;\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { jsx, useState, useEffect } from 'frontend-hamroun';\r\nimport { UserApi } from '../../data/api';\r\n\r\nexport default function UserDetail({ user, posts, initialState }) {\r\n // State for client-side data fetching when needed\r\n const [userData, setUserData] = useState(user);\r\n const [userPosts, setUserPosts] = useState(posts || []);\r\n const [loading, setLoading] = useState(false);\r\n const [error, setError] = useState(null);\r\n \r\n // Get user ID from route params\r\n const { id } = initialState?.params || {};\r\n \r\n // Fetch user data if not provided from server\r\n useEffect(() => {\r\n if (!userData && id) {\r\n setLoading(true);\r\n \r\n Promise.all([\r\n UserApi.getById(id),\r\n UserApi.getPosts(id)\r\n ])\r\n .then(([userData, postsData]) => {\r\n setUserData(userData);\r\n setUserPosts(postsData);\r\n setLoading(false);\r\n })\r\n .catch(err => {\r\n console.error('Error fetching user data:', err);\r\n setError(err.message || 'Failed to load user data');\r\n setLoading(false);\r\n });\r\n }\r\n }, [userData, id]);\r\n\r\n if (loading) {\r\n return (\r\n <div className=\"max-w-4xl mx-auto p-4\">\r\n <div className=\"animate-pulse rounded-md bg-gray-100 p-8\">\r\n <div className=\"h-8 bg-gray-200 rounded w-1/4 mb-4\"></div>\r\n <div className=\"h-4 bg-gray-200 rounded w-1/2 mb-2\"></div>\r\n <div className=\"h-4 bg-gray-200 rounded w-3/4 mb-4\"></div>\r\n <div className=\"h-40 bg-gray-200 rounded mb-4\"></div>\r\n </div>\r\n </div>\r\n );\r\n }\r\n\r\n if (error) {\r\n return (\r\n <div className=\"max-w-4xl mx-auto p-4\">\r\n <div className=\"rounded-md bg-red-50 p-4 border border-red-200\">\r\n <h2 className=\"text-lg font-bold text-red-700\">Error Loading User</h2>\r\n <p className=\"text-red-600\">{error}</p>\r\n </div>\r\n </div>\r\n );\r\n }\r\n\r\n if (!userData) {\r\n return (\r\n <div className=\"max-w-4xl mx-auto p-4\">\r\n <div className=\"rounded-md bg-yellow-50 p-4 border border-yellow-200\">\r\n <h2 className=\"text-lg font-bold text-yellow-700\">User Not Found</h2>\r\n <p className=\"text-yellow-600\">Could not find user with ID: {id}</p>\r\n <a href=\"/users\" className=\"text-blue-600 hover:underline mt-2 block\">\r\n Back to Users List\r\n </a>\r\n </div>\r\n </div>\r\n );\r\n }\r\n\r\n return (\r\n <div className=\"max-w-4xl mx-auto p-4\">\r\n <div className=\"bg-white shadow-lg rounded-lg p-6 mb-6\">\r\n <h1 className=\"text-2xl font-bold text-gray-800 mb-4\">{userData.name}</h1>\r\n <div className=\"user-info mb-6\">\r\n <p className=\"text-gray-600\">\r\n <span className=\"font-bold\">ID:</span> {userData.id}\r\n </p>\r\n <p className=\"text-gray-600\">\r\n <span className=\"font-bold\">Email:</span> {userData.email}\r\n </p>\r\n </div>\r\n \r\n <a href=\"/users\" className=\"text-blue-600 hover:underline\">\r\n Back to Users List\r\n </a>\r\n </div>\r\n \r\n {userPosts && userPosts.length > 0 ? (\r\n <div className=\"bg-white shadow-lg rounded-lg p-6\">\r\n <h2 className=\"text-xl font-bold text-gray-800 mb-4\">Posts by {userData.name}</h2>\r\n <div className=\"space-y-4\">\r\n {userPosts.map(post => (\r\n <div key={post.id} className=\"border-b pb-4\">\r\n <h3 className=\"text-lg font-semibold\">{post.title}</h3>\r\n <p className=\"text-gray-600\">{post.content}</p>\r\n </div>\r\n ))}\r\n </div>\r\n </div>\r\n ) : (\r\n <div className=\"bg-white shadow-lg rounded-lg p-6\">\r\n <h2 className=\"text-xl font-bold text-gray-800 mb-4\">Posts by {userData.name}</h2>\r\n <p className=\"text-gray-500 italic\">No posts found for this user.</p>\r\n </div>\r\n )}\r\n </div>\r\n );\r\n}\r\n\r\n// Next.js style server-side data fetching\r\nexport async function getServerSideProps({ params }) {\r\n try {\r\n const userId = params.id;\r\n \r\n // Parallel data fetching\r\n const [user, posts] = await Promise.all([\r\n UserApi.getById(parseInt(userId)),\r\n UserApi.getPosts(parseInt(userId))\r\n ]);\r\n \r\n // Handle user not found\r\n if (!user) {\r\n return {\r\n notFound: true\r\n };\r\n }\r\n \r\n return {\r\n props: {\r\n user,\r\n posts\r\n }\r\n };\r\n } catch (error) {\r\n console.error(`Error fetching user ${params.id}:`, error);\r\n \r\n // Pass the error for client-side handling\r\n return {\r\n props: {\r\n error: {\r\n message: error.message,\r\n status: error.status || 500\r\n },\r\n user: null,\r\n posts: []\r\n }\r\n };\r\n }\r\n}\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\n// This file will be removed as it contains WASM functionality\r\n", "import { jsx, Fragment } from 'frontend-hamroun';\nimport { render, hydrate, jsx } from 'frontend-hamroun';\r\n// Import Tailwind CSS\r\nimport './styles.css';\r\n\r\n// Type declaration for window.__INITIAL_STATE__\r\ndeclare global {\r\n interface Window {\r\n __INITIAL_STATE__?: any;\r\n }\r\n}\r\n\r\n// Get initial state from server\r\nconst initialState = window.__INITIAL_STATE__ || {\r\n route: window.location.pathname,\r\n timestamp: new Date().toISOString(),\r\n serverRendered: false,\r\n data: {\r\n users: null,\r\n posts: null\r\n }\r\n};\r\n\r\nconsole.log('[Client] Initial state:', initialState);\r\n\r\n// Create a mutable variable for hydration state\r\nlet isHydrating = document.getElementById('root')?.innerHTML.trim() !== '';\r\n\r\n// Function to handle navigation\r\nasync function handleRouteChange(path: string, isPushState = true) {\r\n try {\r\n console.log(`[Router] Navigating to: ${path}`);\r\n \r\n // Update URL if needed\r\n if (isPushState) {\r\n window.history.pushState(null, '', path);\r\n }\r\n \r\n // Dynamically load the page component based on the path\r\n const normalizedPath = path === '/' ? 'index' : path.replace(/^\\//, '');\r\n \r\n let Page;\r\n try {\r\n // Dynamic import for the page component\r\n const module = await import(`./pages/${normalizedPath}.tsx`);\r\n Page = module.default;\r\n } catch (error) {\r\n console.warn(`[Router] Could not load page for ${path}, trying index file`);\r\n try {\r\n // Try loading index file in directory\r\n const module = await import(`./pages/${normalizedPath}/index.tsx`);\r\n Page = module.default;\r\n } catch (innerError) {\r\n console.error(`[Router] Failed to load page component for ${path}`);\r\n \r\n // Try to load 404 page\r\n try {\r\n const notFoundModule = await import(`./pages/404.tsx`);\r\n Page = notFoundModule.default;\r\n } catch (notFoundError) {\r\n // If all fails, render a simple not found message\r\n const rootElement = document.getElementById('root');\r\n if (rootElement) {\r\n render(\r\n <div style={{ padding: '20px', maxWidth: '800px', margin: '0 auto' }}>\r\n <h1>Page Not Found</h1>\r\n <p>The page you requested could not be found.</p>\r\n <a href=\"/\" style={{ color: '#0066cc' }}>Go to Home</a>\r\n </div>,\r\n rootElement\r\n );\r\n }\r\n return;\r\n }\r\n }\r\n }\r\n \r\n // Get the current page props\r\n let pageProps = initialState.pageProps || {};\r\n \r\n // If the page defines getServerSideProps, fetch data\r\n if (Page.getServerSideProps) {\r\n try {\r\n const response = await fetch(`/api/__props${path}`);\r\n if (response.ok) {\r\n const data = await response.json();\r\n pageProps = data.props || {};\r\n }\r\n } catch (error) {\r\n console.error('[Router] Error fetching page props:', error);\r\n }\r\n }\r\n \r\n // Update the state with current route\r\n const updatedState = {\r\n ...initialState,\r\n route: path,\r\n pageProps\r\n };\r\n \r\n // Render the page\r\n const rootElement = document.getElementById('root');\r\n if (!rootElement) return;\r\n \r\n if (isHydrating && path === initialState.route) {\r\n console.log('[Client] Hydrating server-rendered content');\r\n hydrate(<Page {...pageProps} initialState={updatedState} />, rootElement);\r\n isHydrating = false;\r\n } else {\r\n console.log('[Client] Rendering client-side');\r\n render(<Page {...pageProps} initialState={updatedState} />, rootElement);\r\n }\r\n } catch (error) {\r\n console.error('[Router] Navigation error:', error);\r\n }\r\n}\r\n\r\n// Handle initial route\r\nhandleRouteChange(window.location.pathname, false);\r\n\r\n// Handle client-side navigation\r\ndocument.addEventListener('click', (e) => {\r\n let target = e.target as HTMLElement | null;\r\n \r\n // Find closest anchor element\r\n while (target && target.tagName !== 'A') {\r\n target = target.parentElement;\r\n if (!target) break;\r\n }\r\n \r\n if (target && \r\n target.tagName === 'A' && \r\n target.getAttribute('href') && \r\n target.getAttribute('href')?.startsWith('/') && \r\n !target.getAttribute('href')?.startsWith('//') && \r\n !target.getAttribute('target')) {\r\n \r\n e.preventDefault();\r\n const href = target.getAttribute('href') || '/';\r\n handleRouteChange(href);\r\n }\r\n});\r\n\r\n// Handle back/forward navigation\r\nwindow.addEventListener('popstate', () => {\r\n handleRouteChange(window.location.pathname, false);\r\n});\r\n\r\n// Set up socket.io for live reload in development\r\nif (typeof io !== 'undefined') {\r\n const socket = io();\r\n socket.on('reload', () => {\r\n console.log('[Dev] Reloading page due to file changes');\r\n window.location.reload();\r\n });\r\n}\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAGO,SAAS,aAAa,IAAc;AACzC,MAAI,YAAY;AACd,UAAM,KAAK,EAAE;AACb;EACF;AAEa,eAAA;AACT,MAAA;AACC,OAAA;AACI,WAAA,MAAM,SAAS,GAAG;AACjB,YAAA,SAAS,MAAM,MAAA;AACZ,gBAAA,OAAA,SAAA,OAAA;IACX;EAAA,UAAA;AAEa,iBAAA;EACf;AACF;ACKgB,SAAA,kBACd,UACA,SACA,WACA;AACuB,yBAAA;AACL,o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AAS,OAAO;AACd,YAAQ,MAAM,8BAA8B,KAAK;AAAA,EACnD;AACF;AAGA,kBAAkB,OAAO,SAAS,UAAU,KAAK;AAGjD,SAAS,iBAAiB,SAAS,CAAC,MAAM;AACxC,MAAI,SAAS,EAAE;AAGf,SAAO,UAAU,OAAO,YAAY,KAAK;AACvC,aAAS,OAAO;AAChB,QAAI,CAAC;AAAQ;AAAA,EACf;AAEA,MAAI,UACA,OAAO,YAAY,OACnB,OAAO,aAAa,MAAM,KAC1B,OAAO,aAAa,MAAM,GAAG,WAAW,GAAG,KAC3C,CAAC,OAAO,aAAa,MAAM,GAAG,WAAW,IAAI,KAC7C,CAAC,OAAO,aAAa,QAAQ,GAAG;AAElC,MAAE,eAAe;AACjB,UAAM,OAAO,OAAO,aAAa,MAAM,KAAK;AAC5C,sBAAkB,IAAI;AAAA,EACxB;AACF,CAAC;AAGD,OAAO,iBAAiB,YAAY,MAAM;AACxC,oBAAkB,OAAO,SAAS,UAAU,KAAK;AACnD,CAAC;AAGD,IAAI,OAAO,OAAO,aAAa;AAC7B,QAAM,SAAS,GAAG;AAClB,SAAO,GAAG,UAAU,MAAM;AACxB,YAAQ,IAAI,0CAA0C;AACtD,WAAO,SAAS,OAAO;AAAA,EACzB,CAAC;AACH;",
6
+ "names": ["index", "state", "setState", "initialState", "initialState", "initialState", "initialState", "about_exports", "AboutPage", "init_about", "initialState", "getServerSideProps", "initialState", "users", "posts", "initialState", "id_exports", "getServerSideProps", "initialState", "userData", "init_id", "isHydrating", "rootElement"]
7
7
  }
@@ -24,7 +24,7 @@ if (!existsSync(outdir)) {
24
24
  // CSS processing plugin for esbuild
25
25
  const cssPlugin = {
26
26
  name: 'css-processor',
27
- setup(build) {
27
+ setup(build: { onLoad: (arg0: { filter: RegExp; }, arg1: (args: any) => Promise<{ contents: string; loader: string; errors?: undefined; } | { errors: { text: string; }[]; loader: string; contents?: undefined; }>) => void; }) {
28
28
  // Handle CSS files
29
29
  build.onLoad({ filter: /\.css$/ }, async (args) => {
30
30
  // Read the CSS file
@@ -45,7 +45,7 @@ const cssPlugin = {
45
45
  contents: result.css,
46
46
  loader: 'css'
47
47
  };
48
- } catch (error) {
48
+ } catch (error: any) {
49
49
  console.error('Error processing CSS:', error);
50
50
  return {
51
51
  errors: [{ text: 'Error processing CSS with PostCSS: ' + error.message }],
@@ -118,8 +118,7 @@ async function buildClient() {
118
118
  return { contents: content, loader: args.path.endsWith('tsx') ? 'tsx' : 'jsx' };
119
119
  });
120
120
  }
121
- },
122
- cssPlugin
121
+ }
123
122
  ],
124
123
  loader: {
125
124
  '.tsx': 'tsx',