heliumts 0.9.5 → 0.9.7

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 (110) hide show
  1. package/README.md +7 -3
  2. package/dist/bin/helium.js +61 -53
  3. package/dist/bin/helium.js.map +1 -1
  4. package/dist/client/Router.d.ts +2 -2
  5. package/dist/client/Router.d.ts.map +1 -1
  6. package/dist/client/Router.js +32 -29
  7. package/dist/client/Router.js.map +1 -1
  8. package/dist/client/cache.d.ts.map +1 -1
  9. package/dist/client/cache.js +13 -13
  10. package/dist/client/cache.js.map +1 -1
  11. package/dist/client/callMethod.d.ts +13 -0
  12. package/dist/client/callMethod.d.ts.map +1 -0
  13. package/dist/client/callMethod.js +10 -0
  14. package/dist/client/callMethod.js.map +1 -0
  15. package/dist/client/env.js.map +1 -1
  16. package/dist/client/index.d.ts +2 -1
  17. package/dist/client/index.d.ts.map +1 -1
  18. package/dist/client/index.js +1 -0
  19. package/dist/client/index.js.map +1 -1
  20. package/dist/client/routerManifest.d.ts.map +1 -1
  21. package/dist/client/routerManifest.js +18 -29
  22. package/dist/client/routerManifest.js.map +1 -1
  23. package/dist/client/rpcClient.d.ts +7 -3
  24. package/dist/client/rpcClient.d.ts.map +1 -1
  25. package/dist/client/rpcClient.js +80 -78
  26. package/dist/client/rpcClient.js.map +1 -1
  27. package/dist/client/transitions.d.ts +1 -1
  28. package/dist/client/transitions.d.ts.map +1 -1
  29. package/dist/client/useCall.d.ts.map +1 -1
  30. package/dist/client/useCall.js +4 -1
  31. package/dist/client/useCall.js.map +1 -1
  32. package/dist/client/useFetch.d.ts.map +1 -1
  33. package/dist/client/useFetch.js +48 -92
  34. package/dist/client/useFetch.js.map +1 -1
  35. package/dist/runtime/routeOrder.d.ts +3 -0
  36. package/dist/runtime/routeOrder.d.ts.map +1 -0
  37. package/dist/runtime/routeOrder.js +15 -0
  38. package/dist/runtime/routeOrder.js.map +1 -0
  39. package/dist/server/config.d.ts.map +1 -1
  40. package/dist/server/config.js +51 -26
  41. package/dist/server/config.js.map +1 -1
  42. package/dist/server/defineHTTPRequest.d.ts +1 -1
  43. package/dist/server/defineHTTPRequest.d.ts.map +1 -1
  44. package/dist/server/defineHTTPRequest.js.map +1 -1
  45. package/dist/server/defineWorker.d.ts.map +1 -1
  46. package/dist/server/defineWorker.js +68 -37
  47. package/dist/server/defineWorker.js.map +1 -1
  48. package/dist/server/devServer.d.ts.map +1 -1
  49. package/dist/server/devServer.js +70 -40
  50. package/dist/server/devServer.js.map +1 -1
  51. package/dist/server/httpCompression.d.ts +8 -0
  52. package/dist/server/httpCompression.d.ts.map +1 -0
  53. package/dist/server/httpCompression.js +58 -0
  54. package/dist/server/httpCompression.js.map +1 -0
  55. package/dist/server/httpRouter.d.ts.map +1 -1
  56. package/dist/server/httpRouter.js +138 -43
  57. package/dist/server/httpRouter.js.map +1 -1
  58. package/dist/server/meta.d.ts.map +1 -1
  59. package/dist/server/meta.js +23 -15
  60. package/dist/server/meta.js.map +1 -1
  61. package/dist/server/prodServer.d.ts.map +1 -1
  62. package/dist/server/prodServer.js +87 -46
  63. package/dist/server/prodServer.js.map +1 -1
  64. package/dist/server/rateLimiter.d.ts +9 -0
  65. package/dist/server/rateLimiter.d.ts.map +1 -1
  66. package/dist/server/rateLimiter.js +46 -0
  67. package/dist/server/rateLimiter.js.map +1 -1
  68. package/dist/server/requestHandler.d.ts +4 -0
  69. package/dist/server/requestHandler.d.ts.map +1 -0
  70. package/dist/server/requestHandler.js +20 -0
  71. package/dist/server/requestHandler.js.map +1 -0
  72. package/dist/server/rpcRegistry.d.ts +4 -0
  73. package/dist/server/rpcRegistry.d.ts.map +1 -1
  74. package/dist/server/rpcRegistry.js +60 -15
  75. package/dist/server/rpcRegistry.js.map +1 -1
  76. package/dist/server/security.d.ts.map +1 -1
  77. package/dist/server/security.js +3 -2
  78. package/dist/server/security.js.map +1 -1
  79. package/dist/server/serializer.js +17 -6
  80. package/dist/server/serializer.js.map +1 -1
  81. package/dist/server/ssr.d.ts +2 -1
  82. package/dist/server/ssr.d.ts.map +1 -1
  83. package/dist/server/ssr.js +29 -32
  84. package/dist/server/ssr.js.map +1 -1
  85. package/dist/utils/envLoader.js +1 -1
  86. package/dist/utils/envLoader.js.map +1 -1
  87. package/dist/utils/html.d.ts +7 -0
  88. package/dist/utils/html.d.ts.map +1 -0
  89. package/dist/utils/html.js +197 -0
  90. package/dist/utils/html.js.map +1 -0
  91. package/dist/utils/ipExtractor.d.ts +6 -52
  92. package/dist/utils/ipExtractor.d.ts.map +1 -1
  93. package/dist/utils/ipExtractor.js +21 -118
  94. package/dist/utils/ipExtractor.js.map +1 -1
  95. package/dist/vite/heliumPlugin.d.ts.map +1 -1
  96. package/dist/vite/heliumPlugin.js +75 -83
  97. package/dist/vite/heliumPlugin.js.map +1 -1
  98. package/dist/vite/scanner.d.ts +3 -0
  99. package/dist/vite/scanner.d.ts.map +1 -1
  100. package/dist/vite/scanner.js +89 -18
  101. package/dist/vite/scanner.js.map +1 -1
  102. package/dist/vite/ssg.d.ts +4 -0
  103. package/dist/vite/ssg.d.ts.map +1 -1
  104. package/dist/vite/ssg.js +66 -39
  105. package/dist/vite/ssg.js.map +1 -1
  106. package/dist/vite/virtualServerModule.d.ts +1 -1
  107. package/dist/vite/virtualServerModule.d.ts.map +1 -1
  108. package/dist/vite/virtualServerModule.js +28 -16
  109. package/dist/vite/virtualServerModule.js.map +1 -1
  110. package/package.json +12 -7
@@ -1 +1 @@
1
- {"version":3,"file":"ssg.js","sourceRoot":"","sources":["../../src/vite/ssg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAuBhE;;;;GAIG;AACH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AE,CAAC;YACnB,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAChB,GAAG,CAAC,MAAM,EAAE,sBAAsB,YAAY,oBAAoB,YAAY,cAAc,CAAC,CAAC;QAClG,CAAC;IACL,CAAC;YAAS,CAAC;QACP,yDAAyD;QACzD,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;AACL,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\n\nimport { log } from \"../utils/logger.js\";\nimport { scanServerExports } from \"./scanner.js\";\nimport { generateClientModule } from \"./virtualServerModule.js\";\n\n/**\n * SSG (Static Site Generation) implementation for Helium\n *\n * Scans pages directory for files with \"use ssg\"; directive and generates\n * static HTML for them at build time.\n */\n\ninterface SSGPage {\n filePath: string;\n urlPath: string;\n relativePath: string;\n warnings: string[];\n}\n\ninterface SSGValidation {\n hasHooks: boolean;\n hasClientImports: boolean;\n hasServerImports: boolean;\n warnings: string[];\n}\n\n/**\n * Remove string literals from content to avoid false positives when checking for patterns\n * This removes template literals, single-quoted strings, and double-quoted strings\n * @internal Exported for testing\n */\nexport function stripStringLiterals(content: string): string {\n // Remove template literals (backtick strings) - handle nested expressions\n let result = content;\n\n // Remove template literals with their content (simplified - doesn't handle all edge cases but good enough)\n result = result.replace(/`(?:[^`\\\\]|\\\\.)*`/g, '\"\"');\n\n // Remove double-quoted strings\n result = result.replace(/\"(?:[^\"\\\\]|\\\\.)*\"/g, '\"\"');\n\n // Remove single-quoted strings\n result = result.replace(/'(?:[^'\\\\]|\\\\.)*'/g, \"''\");\n\n // Also remove JSX text content between tags (but not the tags themselves)\n // This helps with cases like <code>useState</code>\n result = result.replace(/>([^<]+)</g, \"><\");\n\n return result;\n}\n\n/**\n * Validate if a page file can be truly statically generated\n * Checks for React hooks and helium imports that would prevent static generation\n * @internal Exported for testing\n */\nexport function validateSSGPage(filePath: string): SSGValidation {\n const rawContent = fs.readFileSync(filePath, \"utf-8\");\n const warnings: string[] = [];\n\n // Strip string literals and JSX text to avoid false positives\n const content = stripStringLiterals(rawContent);\n\n // Check for React hooks (common ones)\n const hookPatterns = [\n /\\buse(State|Effect|Context|Reducer|Callback|Memo|Ref|ImperativeHandle|LayoutEffect|DebugValue)\\s*\\(/,\n /\\buse[A-Z]\\w+\\s*\\(/, // Custom hooks (useXxx) - must be followed by ( to be a call\n ];\n\n const hasHooks = hookPatterns.some((pattern) => pattern.test(content));\n if (hasHooks) {\n warnings.push(\"Page uses React hooks which may cause hydration issues\");\n }\n\n // Check for heliumts/client imports - use raw content since imports should be at top level\n const hasClientImports = /^import\\s+.*from\\s+['\"]heliumts\\/client['\"]/m.test(rawContent);\n if (hasClientImports) {\n warnings.push(\"Page imports from 'heliumts/client' which requires client-side execution\");\n }\n\n // Check for heliumts/server imports - use raw content since imports should be at top level\n const hasServerImports = /^import\\s+.*from\\s+['\"]heliumts\\/server['\"]/m.test(rawContent);\n if (hasServerImports) {\n warnings.push(\"Page imports from 'heliumts/server' which may cause runtime issues\");\n }\n\n return {\n hasHooks,\n hasClientImports,\n hasServerImports,\n warnings,\n };\n}\n\n/**\n * Scan pages directory and find all pages with \"use ssg\" directive\n */\nexport function scanSSGPages(root: string): SSGPage[] {\n const pagesDir = path.join(root, \"src\", \"pages\");\n\n if (!fs.existsSync(pagesDir)) {\n return [];\n }\n\n const ssgPages: SSGPage[] = [];\n\n function walkDirectory(dir: string) {\n const items = fs.readdirSync(dir);\n\n for (const item of items) {\n const fullPath = path.join(dir, item);\n const stat = fs.statSync(fullPath);\n\n if (stat.isDirectory()) {\n walkDirectory(fullPath);\n } else if (/\\.(tsx|jsx|ts|js)$/.test(item)) {\n const content = fs.readFileSync(fullPath, \"utf-8\");\n\n // Check for \"use ssg\"; directive at the top of the file\n if (/^\\s*[\"']use ssg[\"']\\s*;/m.test(content)) {\n const relativePath = path.relative(path.join(root, \"src\"), fullPath);\n const urlPath = filePathToUrlPath(relativePath);\n\n // Validate the page for SSG compatibility\n const validation = validateSSGPage(fullPath);\n const warnings = [...validation.warnings];\n\n // Also check all layouts for this page\n const layoutPaths = findLayoutPathsForPage(fullPath, root);\n for (const layoutPath of layoutPaths) {\n const layoutValidation = validateSSGPage(layoutPath);\n if (layoutValidation.warnings.length > 0) {\n const layoutRelative = path.relative(path.join(root, \"src\"), layoutPath);\n warnings.push(`Layout ${layoutRelative} has issues:`);\n for (const warning of layoutValidation.warnings) {\n warnings.push(` └─ ${warning}`);\n }\n }\n }\n\n ssgPages.push({\n filePath: fullPath,\n urlPath,\n relativePath,\n warnings,\n });\n }\n }\n }\n }\n\n walkDirectory(pagesDir);\n return ssgPages;\n}\n\n/**\n * Convert file path to URL path\n * pages/index.tsx -> /\n * pages/about.tsx -> /about\n * pages/blog/post.tsx -> /blog/post\n * pages/(website)/contact.tsx -> /contact\n * pages/(portal)/dashboard.tsx -> /dashboard\n * @internal Exported for testing\n */\nexport function filePathToUrlPath(relativePath: string): string {\n // Remove 'pages/' prefix and file extension\n let urlPath = relativePath.replace(/^pages\\//, \"\").replace(/\\.(tsx|jsx|ts|js)$/, \"\");\n\n // Remove route groups (folders in parentheses)\n // E.g., (website)/contact -> /contact\n urlPath = urlPath.replace(/\\([^)]+\\)\\//g, \"\");\n\n // Handle index files\n if (urlPath.endsWith(\"/index\") || urlPath === \"index\") {\n urlPath = urlPath.replace(/\\/index$/, \"\").replace(/^index$/, \"\");\n }\n\n // Ensure leading slash\n if (!urlPath.startsWith(\"/\")) {\n urlPath = \"/\" + urlPath;\n }\n\n // Root path\n if (urlPath === \"/\") {\n return \"/\";\n }\n\n return urlPath;\n}\n\n/**\n * Convert URL path to output file path\n * / -> __index.html (special case - renamed later to prevent conflicts)\n * /about -> about.html\n * /blog/post -> blog/post.html\n * @internal Exported for testing\n */\nexport function urlPathToOutputPath(urlPath: string): string {\n if (urlPath === \"/\") {\n return \"__index.html\";\n }\n\n // Remove leading slash and add .html extension\n const cleanPath = urlPath.replace(/^\\//, \"\");\n return `${cleanPath}.html`;\n}\n\n/**\n * Find all layout file paths for a given page path (from root to leaf)\n * @internal Exported for testing\n */\nexport function findLayoutPathsForPage(pagePath: string, root: string): string[] {\n const pagesDir = path.join(root, \"src\", \"pages\");\n const relativePath = path.relative(pagesDir, pagePath);\n const pathParts = path\n .dirname(relativePath)\n .split(path.sep)\n .filter((p) => p !== \".\");\n\n const layoutPaths: string[] = [];\n\n // Check for _layout.tsx from root to leaf (maintains nesting order)\n // Start with root layout\n const rootLayoutPath = path.join(pagesDir, \"_layout.tsx\");\n if (fs.existsSync(rootLayoutPath)) {\n layoutPaths.push(rootLayoutPath);\n }\n\n // Then check nested layouts\n for (let i = 1; i <= pathParts.length; i++) {\n const dirPath = path.join(pagesDir, ...pathParts.slice(0, i));\n const layoutPath = path.join(dirPath, \"_layout.tsx\");\n\n if (fs.existsSync(layoutPath)) {\n layoutPaths.push(layoutPath);\n }\n }\n\n return layoutPaths;\n}\n\n/**\n * Find all layout components for a given page path (from root to leaf)\n * Note: Layouts cannot use routing features during SSG since they're pre-rendered\n */\nasync function findLayoutsForPage(pagePath: string, root: string, viteServer: any): Promise<any[]> {\n const layoutPaths = findLayoutPathsForPage(pagePath, root);\n const layouts = [];\n\n for (const layoutPath of layoutPaths) {\n try {\n const layoutModule = await viteServer.ssrLoadModule(layoutPath);\n if (layoutModule.default) {\n layouts.push(layoutModule.default);\n }\n } catch (error) {\n log(\"warn\", `Could not load layout at ${layoutPath}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n return layouts;\n}\n\n/**\n * Render a page component to static HTML using Vite SSR with timeout\n */\nasync function renderPageToHTML(page: SSGPage, root: string, htmlTemplate: string, viteServer: any, timeout: number = 10000): Promise<string> {\n // Create timeout promise\n const timeoutPromise = new Promise<string>((_, reject) => {\n setTimeout(() => {\n reject(new Error(`Rendering timeout after ${timeout}ms - page may contain hooks or async operations`));\n }, timeout);\n });\n\n // Create render promise\n const renderPromise = (async () => {\n try {\n // Dynamically import React and ReactDOMServer\n const React = (await import(\"react\")).default;\n const ReactDOMServer = await import(\"react-dom/server\");\n\n // Use Vite's SSR loader to load the page component\n const pageModule = await viteServer.ssrLoadModule(page.filePath);\n const PageComponent = pageModule.default;\n\n if (!PageComponent) {\n throw new Error(`No default export found in ${page.relativePath}`);\n }\n\n // Find all layouts (from root to leaf)\n const layouts = await findLayoutsForPage(page.filePath, root, viteServer);\n\n // Build the component tree: layouts wrap the page, innermost to outermost\n let element: any = React.createElement(PageComponent);\n\n // Wrap with layouts from innermost to outermost (reverse order)\n for (let i = layouts.length - 1; i >= 0; i--) {\n element = React.createElement(layouts[i], { children: element } as any);\n }\n\n // Load RouterContext from our stub\n const heliumClient = await viteServer.ssrLoadModule(\"heliumts/client\");\n const RouterContext = heliumClient.RouterContext;\n\n // Mock Router Context with the page's URL\n const routerValue = {\n path: page.urlPath,\n params: {},\n searchParams: new URLSearchParams(),\n push: () => {},\n replace: () => {},\n on: () => () => {},\n status: 200,\n };\n\n // Wrap with RouterContext\n if (RouterContext) {\n element = React.createElement(RouterContext.Provider, { value: routerValue }, element);\n }\n\n // Render to static HTML\n const markup = ReactDOMServer.renderToString(element);\n\n // Inject the markup into the HTML template with the SSG marker\n const finalHtml = htmlTemplate.replace(/<div\\s+id=\"root\"[^>]*>(.*?)<\\/div>/s, `<div id=\"root\" data-ssg-page=\"${page.urlPath}\">${markup}</div>`);\n\n return finalHtml;\n } catch (error) {\n log(\"error\", `Failed to render ${page.relativePath}:`, error);\n throw error; // Don't fallback, let the caller handle the error\n }\n })();\n\n // Race between timeout and render\n return Promise.race([renderPromise, timeoutPromise]);\n}\n\n/**\n * Generate static HTML files for all SSG pages\n */\nexport async function generateStaticPages(context: any, root: string, htmlTemplate: string, distDir: string) {\n // Scan for SSG pages\n const ssgPages = scanSSGPages(root);\n\n if (ssgPages.length === 0) {\n return;\n }\n\n log(\"info\", `Generating ${ssgPages.length} static page(s) for SSG...`);\n\n // Check for dynamic routes (not supported yet)\n const dynamicPages = ssgPages.filter((p) => p.relativePath.includes(\"[\"));\n if (dynamicPages.length > 0) {\n log(\"warn\", `Skipping ${dynamicPages.length} dynamic route(s) - not yet supported:\\n` + dynamicPages.map((p) => ` - ${p.relativePath}`).join(\"\\n\"));\n }\n\n // Filter out dynamic routes\n const staticPages = ssgPages.filter((p) => !p.relativePath.includes(\"[\"));\n\n // Precompute RPC client stubs for SSG (mirrors helium Vite plugin)\n const { methods } = scanServerExports(root);\n const serverStubCode = `// Auto-generated SSG RPC stub\\n${generateClientModule(methods)}\\n`;\n\n // Create a stub for heliumts/client that provides mock Router and hooks\n const clientStubCode = `\n// Auto-generated SSG client stub\nimport React from 'react';\n\n// Mock RouterContext\nexport const RouterContext = React.createContext({\n path: '/',\n params: {},\n searchParams: new URLSearchParams(),\n push: () => {},\n replace: () => {},\n on: () => () => {},\n status: 200,\n isNavigating: false,\n isPending: false,\n});\n\n// Mock useRouter hook\nexport function useRouter() {\n const ctx = React.useContext(RouterContext);\n if (!ctx) {\n console.warn('useRouter called outside RouterContext during SSG');\n return {\n path: '/',\n params: {},\n searchParams: new URLSearchParams(),\n push: () => {},\n replace: () => {},\n on: () => () => {},\n status: 200,\n isNavigating: false,\n isPending: false,\n };\n }\n return ctx;\n}\n\n// Mock AppRouter component (alias for Router)\nexport function AppRouter({ children }) {\n return React.createElement(React.Fragment, null, children);\n}\n\n// Mock Router component\nexport function Router({ children }) {\n return React.createElement(React.Fragment, null, children);\n}\n\n// Mock Link component\nexport function Link({ href, children, prefetch, ...props }) {\n return React.createElement('a', { href, ...props }, children);\n}\n\n// Mock Redirect component\nexport function Redirect({ to, replace }) {\n return null;\n}\n\n// Mock useCall hook\nexport function useCall(serverFn) {\n return async (...args) => {\n console.warn('useCall called during SSG - this will not execute');\n return null;\n };\n}\n\n// Mock useFetch hook\nexport function useFetch(serverFn, ...args) {\n console.warn('useFetch called during SSG - returning null');\n return { data: null, loading: false, error: null, refetch: async () => {} };\n}\n\n// Re-export cache (mock)\nexport const cache = {\n get: () => null,\n set: () => {},\n delete: () => {},\n clear: () => {},\n};\n\n// Mock PageTransition and useDeferredNavigation (also available from heliumts/client/transitions)\nexport function useDeferredNavigation() {\n return {\n path: '/',\n deferredPath: '/',\n isStale: false,\n isPending: false,\n isTransitioning: false,\n };\n}\n\nexport function PageTransition({ children, loadingClassName, loadingStyle, fallback }) {\n return React.createElement('div', null, children);\n}\n`;\n\n // Create a stub for heliumts/client/transitions\n const transitionsStubCode = `\n// Auto-generated SSG transitions stub\nimport React from 'react';\n\n// Mock useDeferredNavigation hook - returns static values for SSG\nexport function useDeferredNavigation() {\n return {\n path: '/',\n deferredPath: '/',\n isStale: false,\n isPending: false,\n isTransitioning: false,\n };\n}\n\n// Mock PageTransition component - renders children without transition logic\nexport function PageTransition({ children, loadingClassName, loadingStyle, fallback }) {\n // During SSG, just render the children without any transition logic\n return React.createElement('div', null, children);\n}\n\nexport default {\n useDeferredNavigation,\n PageTransition,\n};\n`;\n\n // Create a stub for heliumts/client/prefetch\n const prefetchStubCode = `\n// Auto-generated SSG prefetch stub\nexport function prefetchRoute() {\n // No-op during SSG\n}\n\nexport function clearPrefetchCache() {\n // No-op during SSG\n}\n`;\n\n // Write stub files to node_modules/.heliumts\n const heliumInternalDir = path.join(root, \"node_modules\", \".heliumts\");\n if (!fs.existsSync(heliumInternalDir)) {\n fs.mkdirSync(heliumInternalDir, { recursive: true });\n }\n const ssgServerStubPath = path.join(heliumInternalDir, \"ssg-server-stub.mjs\");\n const ssgClientStubPath = path.join(heliumInternalDir, \"ssg-client-stub.mjs\");\n const ssgTransitionsStubPath = path.join(heliumInternalDir, \"ssg-transitions-stub.mjs\");\n const ssgPrefetchStubPath = path.join(heliumInternalDir, \"ssg-prefetch-stub.mjs\");\n fs.writeFileSync(ssgServerStubPath, serverStubCode, \"utf-8\");\n fs.writeFileSync(ssgClientStubPath, clientStubCode, \"utf-8\");\n fs.writeFileSync(ssgTransitionsStubPath, transitionsStubCode, \"utf-8\");\n fs.writeFileSync(ssgPrefetchStubPath, prefetchStubCode, \"utf-8\");\n\n // Create a temporary Vite server for SSR rendering\n const { createServer } = await import(\"vite\");\n const heliumPlugin = (await import(\"./heliumPlugin.js\")).default;\n\n const viteServer = await createServer({\n root,\n server: { middlewareMode: true },\n appType: \"custom\",\n logLevel: \"error\",\n plugins: [heliumPlugin()],\n resolve: {\n alias: [\n // Most specific aliases first - heliumts/client/transitions and heliumts/client/prefetch\n { find: /^heliumts\\/client\\/transitions$/, replacement: ssgTransitionsStubPath },\n { find: /^heliumts\\/client\\/prefetch$/, replacement: ssgPrefetchStubPath },\n // Then heliumts/client and heliumts/server\n { find: /^heliumts\\/client$/, replacement: ssgClientStubPath },\n { find: /^heliumts\\/server$/, replacement: ssgServerStubPath },\n ],\n },\n ssr: {\n external: [\"react\", \"react-dom\"],\n // Don't externalize heliumts packages - we want to use our stubs\n noExternal: [\"heliumts\"],\n },\n });\n\n try {\n // Generate HTML for each static page\n const zlib = await import(\"zlib\");\n let successCount = 0;\n let failureCount = 0;\n let hasIndexSSG = false;\n\n // Calculate max path length for proper alignment (min 35, max 80)\n const maxPathLength = Math.min(80, Math.max(35, ...staticPages.map((p) => urlPathToOutputPath(p.urlPath).length)));\n\n for (const page of staticPages) {\n try {\n // Render the page component to static HTML using Vite SSR with 10s timeout\n const html = await renderPageToHTML(page, root, htmlTemplate, viteServer, 10000);\n const outputPath = urlPathToOutputPath(page.urlPath);\n const fullOutputPath = path.join(distDir, outputPath);\n\n // Track if the root page (/) has SSG\n if (page.urlPath === \"/\") {\n hasIndexSSG = true;\n }\n\n // Ensure directory exists\n const outputDir = path.dirname(fullOutputPath);\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n // Write the HTML file\n fs.writeFileSync(fullOutputPath, html, \"utf-8\");\n\n // Calculate file size and gzipped size\n const size = Buffer.byteLength(html, \"utf-8\");\n const sizeKB = (size / 1024).toFixed(2);\n\n // Calculate gzipped size\n const gzipped = zlib.gzipSync(html);\n const gzipSizeKB = (gzipped.length / 1024).toFixed(2);\n\n log(\"info\", ` ${outputPath.padEnd(maxPathLength)} ${sizeKB.padStart(8)} kB │ gzip: ${gzipSizeKB.padStart(7)} kB`);\n successCount++;\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : String(error);\n if (errorMsg.includes(\"timeout\")) {\n log(\"error\", ` ✗ ${page.relativePath} - ${errorMsg}`);\n } else {\n log(\"error\", ` ✗ ${page.relativePath} - Failed to generate:`, error);\n }\n\n // Write a fallback HTML file with empty root div (client will hydrate)\n const outputPath = urlPathToOutputPath(page.urlPath);\n const fullOutputPath = path.join(distDir, outputPath);\n const outputDir = path.dirname(fullOutputPath);\n\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n const fallbackHtml = htmlTemplate.replace(/<div\\s+id=\"root\"[^>]*>.*?<\\/div>/s, `<div id=\"root\" data-ssg-failed=\"${page.urlPath}\"></div>`);\n fs.writeFileSync(fullOutputPath, fallbackHtml, \"utf-8\");\n\n failureCount++;\n }\n }\n\n // If index page has SSG, we need to handle it specially:\n // 1. Rename __index.html to index.ssg.html (the SSG version)\n // 2. Create a clean blank index.html as fallback for non-root routes\n if (hasIndexSSG) {\n const tempIndexPath = path.join(distDir, \"__index.html\");\n const ssgIndexPath = path.join(distDir, \"index.ssg.html\");\n const indexPath = path.join(distDir, \"index.html\");\n\n // Move __index.html to index.ssg.html\n if (fs.existsSync(tempIndexPath)) {\n fs.renameSync(tempIndexPath, ssgIndexPath);\n }\n\n // Create a blank index.html as the SPA fallback\n const blankIndexHtml = htmlTemplate.replace(/<div\\s+id=\"root\"[^>]*>.*?<\\/div>/s, '<div id=\"root\"></div>');\n fs.writeFileSync(indexPath, blankIndexHtml, \"utf-8\");\n\n log(\"info\", ` ${\"index.ssg.html\".padEnd(maxPathLength)} (SSG root page)`);\n log(\"info\", ` ${\"index.html\".padEnd(maxPathLength)} (blank SPA fallback)`);\n }\n\n // Summary\n if (failureCount > 0) {\n log(\"warn\", \"\");\n log(\"warn\", `SSG completed with ${successCount} success(es) and ${failureCount} failure(s).`);\n }\n } finally {\n // Always close the Vite server, even if generation fails\n await viteServer.close();\n }\n}\n"]}
1
+ {"version":3,"file":"ssg.js","sourceRoot":"","sources":["../../src/vite/ssg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAuBhE;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IAC/C,0EAA0E;IAC1E,IAAI,MAAM,GAAG,OAAO,CAAC;IAErB,2GAA2G;IAC3G,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC;IAEpD,+BAA+B;IAC/B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC;IAEpD,+BAA+B;IAC/B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC;IAEpD,0EAA0E;IAC1E,mDAAmD;IACnD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAE5C,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC5C,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,8DAA8D;IAC9D,MAAM,OAAO,GAAG,mBAAmB,CAAC,UA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YACrH,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;YAErD,GAAG,CAAC,MAAM,EAAE,KAAK,gBAAgB,CAAC,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;YAC3E,GAAG,CAAC,MAAM,EAAE,KAAK,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;QAChF,CAAC;QAED,UAAU;QACV,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACnB,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAChB,GAAG,CAAC,MAAM,EAAE,sBAAsB,YAAY,oBAAoB,YAAY,cAAc,CAAC,CAAC;QAClG,CAAC;IACL,CAAC;YAAS,CAAC;QACP,yDAAyD;QACzD,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;AACL,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\n\nimport { replaceHtmlRootContents } from \"../utils/html.js\";\nimport { log } from \"../utils/logger.js\";\nimport { hasPageDirective, isPageFile, scanAppShell, scanServerExports } from \"./scanner.js\";\nimport { generateClientModule } from \"./virtualServerModule.js\";\n\n/**\n * SSG (Static Site Generation) implementation for Helium\n *\n * Scans pages directory for files with \"use ssg\"; directive and generates\n * static HTML for them at build time.\n */\n\ninterface SSGPage {\n filePath: string;\n urlPath: string;\n relativePath: string;\n warnings: string[];\n}\n\ninterface SSGValidation {\n hasHooks: boolean;\n hasClientImports: boolean;\n hasServerImports: boolean;\n warnings: string[];\n}\n\n/**\n * Remove string literals from content to avoid false positives when checking for patterns\n * This removes template literals, single-quoted strings, and double-quoted strings\n * @internal Exported for testing\n */\nexport function stripStringLiterals(content: string): string {\n // Remove template literals (backtick strings) - handle nested expressions\n let result = content;\n\n // Remove template literals with their content (simplified - doesn't handle all edge cases but good enough)\n result = result.replace(/`(?:[^`\\\\]|\\\\.)*`/g, '\"\"');\n\n // Remove double-quoted strings\n result = result.replace(/\"(?:[^\"\\\\]|\\\\.)*\"/g, '\"\"');\n\n // Remove single-quoted strings\n result = result.replace(/'(?:[^'\\\\]|\\\\.)*'/g, \"''\");\n\n // Also remove JSX text content between tags (but not the tags themselves)\n // This helps with cases like <code>useState</code>\n result = result.replace(/>([^<]+)</g, \"><\");\n\n return result;\n}\n\n/**\n * Validate if a page file can be truly statically generated\n * Checks for React hooks and helium imports that would prevent static generation\n * @internal Exported for testing\n */\nexport function validateSSGPage(filePath: string): SSGValidation {\n const rawContent = fs.readFileSync(filePath, \"utf-8\");\n const warnings: string[] = [];\n\n // Strip string literals and JSX text to avoid false positives\n const content = stripStringLiterals(rawContent);\n\n // Check for React hooks (common ones)\n const hookPatterns = [\n /\\buse(State|Effect|Context|Reducer|Callback|Memo|Ref|ImperativeHandle|LayoutEffect|DebugValue)\\s*\\(/,\n /\\buse[A-Z]\\w+\\s*\\(/, // Custom hooks (useXxx) - must be followed by ( to be a call\n ];\n\n const hasHooks = hookPatterns.some((pattern) => pattern.test(content));\n if (hasHooks) {\n warnings.push(\"Page uses React hooks which may cause hydration issues\");\n }\n\n // Check for heliumts/client imports - use raw content since imports should be at top level\n const hasClientImports = /^import\\s+.*from\\s+['\"]heliumts\\/client['\"]/m.test(rawContent);\n if (hasClientImports) {\n warnings.push(\"Page imports from 'heliumts/client' which requires client-side execution\");\n }\n\n // Check for heliumts/server imports - use raw content since imports should be at top level\n const hasServerImports = /^import\\s+.*from\\s+['\"]heliumts\\/server['\"]/m.test(rawContent);\n if (hasServerImports) {\n warnings.push(\"Page imports from 'heliumts/server' which may cause runtime issues\");\n }\n\n return {\n hasHooks,\n hasClientImports,\n hasServerImports,\n warnings,\n };\n}\n\n/**\n * Scan pages directory and find all pages with \"use ssg\" directive\n */\nexport function scanSSGPages(root: string): SSGPage[] {\n const pagesDir = path.join(root, \"src\", \"pages\");\n\n if (!fs.existsSync(pagesDir)) {\n return [];\n }\n\n const ssgPages: SSGPage[] = [];\n\n function walkDirectory(dir: string) {\n const items = fs.readdirSync(dir);\n\n for (const item of items) {\n const fullPath = path.join(dir, item);\n const stat = fs.statSync(fullPath);\n\n if (stat.isDirectory()) {\n walkDirectory(fullPath);\n } else if (isPageFile(item)) {\n const content = fs.readFileSync(fullPath, \"utf-8\");\n\n // Check for \"use ssg\"; directive at the top of the file\n if (hasPageDirective(content, \"use ssg\")) {\n const relativePath = path.relative(path.join(root, \"src\"), fullPath);\n const urlPath = filePathToUrlPath(relativePath);\n\n // Validate the page for SSG compatibility\n const validation = validateSSGPage(fullPath);\n const warnings = [...validation.warnings];\n\n // Also check all layouts for this page\n const layoutPaths = findLayoutPathsForPage(fullPath, root);\n for (const layoutPath of layoutPaths) {\n const layoutValidation = validateSSGPage(layoutPath);\n if (layoutValidation.warnings.length > 0) {\n const layoutRelative = path.relative(path.join(root, \"src\"), layoutPath);\n warnings.push(`Layout ${layoutRelative} has issues:`);\n for (const warning of layoutValidation.warnings) {\n warnings.push(` └─ ${warning}`);\n }\n }\n }\n\n ssgPages.push({\n filePath: fullPath,\n urlPath,\n relativePath,\n warnings,\n });\n }\n }\n }\n }\n\n walkDirectory(pagesDir);\n return ssgPages;\n}\n\n/**\n * Convert file path to URL path\n * pages/index.tsx -> /\n * pages/about.tsx -> /about\n * pages/blog/post.tsx -> /blog/post\n * pages/(website)/contact.tsx -> /contact\n * pages/(portal)/dashboard.tsx -> /dashboard\n * @internal Exported for testing\n */\nexport function filePathToUrlPath(relativePath: string): string {\n // Remove 'pages/' prefix and file extension\n let urlPath = relativePath\n .replace(/\\\\/g, \"/\")\n .replace(/^pages\\//, \"\")\n .replace(/\\.(tsx|jsx|ts|js)$/, \"\");\n\n // Remove route groups (folders in parentheses)\n // E.g., (website)/contact -> /contact\n urlPath = urlPath.replace(/\\([^)]+\\)\\//g, \"\");\n\n // Handle index files\n if (urlPath.endsWith(\"/index\") || urlPath === \"index\") {\n urlPath = urlPath.replace(/\\/index$/, \"\").replace(/^index$/, \"\");\n }\n\n // Ensure leading slash\n if (!urlPath.startsWith(\"/\")) {\n urlPath = \"/\" + urlPath;\n }\n\n // Root path\n if (urlPath === \"/\") {\n return \"/\";\n }\n\n return urlPath;\n}\n\n/**\n * Convert URL path to output file path\n * / -> __index.html (special case - renamed later to prevent conflicts)\n * /about -> about.html\n * /blog/post -> blog/post.html\n * @internal Exported for testing\n */\nexport function urlPathToOutputPath(urlPath: string): string {\n if (urlPath === \"/\") {\n return \"__index.html\";\n }\n\n // Remove leading slash and add .html extension\n const cleanPath = urlPath.replace(/^\\//, \"\");\n return `${cleanPath}.html`;\n}\n\n/**\n * Find all layout file paths for a given page path (from root to leaf)\n * @internal Exported for testing\n */\nexport function findLayoutPathsForPage(pagePath: string, root: string): string[] {\n const pagesDir = path.join(root, \"src\", \"pages\");\n const relativePath = path.relative(pagesDir, pagePath);\n const pathParts = path\n .dirname(relativePath)\n .split(path.sep)\n .filter((p) => p !== \".\");\n\n const layoutPaths: string[] = [];\n\n const layoutNames = [\"_layout.tsx\", \"_layout.jsx\", \"_layout.ts\", \"_layout.js\"];\n for (let i = 0; i <= pathParts.length; i++) {\n const dirPath = path.join(pagesDir, ...pathParts.slice(0, i));\n const layoutPath = layoutNames.map((name) => path.join(dirPath, name)).find((candidate) => fs.existsSync(candidate));\n if (layoutPath) {\n layoutPaths.push(layoutPath);\n }\n }\n\n return layoutPaths;\n}\n\n/**\n * Find all layout components for a given page path (from root to leaf)\n * Note: Layouts cannot use routing features during SSG since they're pre-rendered\n */\nasync function findLayoutsForPage(pagePath: string, root: string, viteServer: any): Promise<any[]> {\n const layoutPaths = findLayoutPathsForPage(pagePath, root);\n const layouts = [];\n\n for (const layoutPath of layoutPaths) {\n try {\n const layoutModule = await viteServer.ssrLoadModule(layoutPath);\n if (layoutModule.default) {\n layouts.push(layoutModule.default);\n }\n } catch (error) {\n log(\"warn\", `Could not load layout at ${layoutPath}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n return layouts;\n}\n\n/**\n * Render a page component to static HTML using Vite SSR with timeout\n */\nexport async function renderPageToHTML(page: SSGPage, root: string, htmlTemplate: string, viteServer: any, timeout: number = 10000): Promise<string> {\n // Create timeout promise\n let timeoutId: ReturnType<typeof setTimeout>;\n const timeoutPromise = new Promise<string>((_, reject) => {\n timeoutId = setTimeout(() => {\n reject(new Error(`Rendering timeout after ${timeout}ms - page may contain hooks or async operations`));\n }, timeout);\n });\n\n // Create render promise\n const renderPromise = (async () => {\n try {\n // Dynamically import React and ReactDOMServer\n const React = (await import(\"react\")).default;\n const ReactDOMServer = await import(\"react-dom/server\");\n\n // Use Vite's SSR loader to load the page component\n const pageModule = await viteServer.ssrLoadModule(page.filePath);\n const PageComponent = pageModule.default;\n\n if (!PageComponent) {\n throw new Error(`No default export found in ${page.relativePath}`);\n }\n\n // Find all layouts (from root to leaf)\n const layouts = await findLayoutsForPage(page.filePath, root, viteServer);\n\n // Build the component tree: layouts wrap the page, innermost to outermost\n const pageProps = { params: {}, searchParams: new URLSearchParams() };\n const WrappedPage = () => {\n let content: any = React.createElement(PageComponent, pageProps);\n for (let i = layouts.length - 1; i >= 0; i--) {\n content = React.createElement(layouts[i], { children: content });\n }\n return content;\n };\n const appShellPath = scanAppShell(root);\n const appShellModule = appShellPath ? await viteServer.ssrLoadModule(appShellPath) : null;\n const AppShell = appShellModule ? (appShellModule.default ?? appShellModule.App ?? appShellModule.app) : null;\n let element: any = AppShell\n ? React.createElement(AppShell, { Component: WrappedPage, pageProps, children: React.createElement(WrappedPage) })\n : React.createElement(WrappedPage);\n\n // Load RouterContext from our stub\n const heliumClient = await viteServer.ssrLoadModule(\"heliumts/client\");\n const RouterContext = heliumClient.RouterContext;\n\n // Mock Router Context with the page's URL\n const routerValue = {\n path: page.urlPath,\n params: {},\n searchParams: new URLSearchParams(),\n push: () => {},\n replace: () => {},\n on: () => () => {},\n status: 200,\n };\n\n // Wrap with RouterContext\n if (RouterContext) {\n element = React.createElement(RouterContext.Provider, { value: routerValue }, element);\n }\n\n // Render to static HTML\n const markup = ReactDOMServer.renderToString(element);\n\n // Inject the markup into the HTML template with the SSG marker\n const finalHtml = replaceHtmlRootContents(htmlTemplate, markup, { \"data-ssg-page\": page.urlPath, \"data-ssg-failed\": null });\n\n return finalHtml;\n } catch (error) {\n log(\"error\", `Failed to render ${page.relativePath}:`, error);\n throw error; // Don't fallback, let the caller handle the error\n }\n })();\n\n // Race between timeout and render\n try {\n return await Promise.race([renderPromise, timeoutPromise]);\n } finally {\n clearTimeout(timeoutId!);\n }\n}\n\n/**\n * Generate static HTML files for all SSG pages\n */\nexport async function generateStaticPages(context: any, root: string, htmlTemplate: string, distDir: string) {\n // Scan for SSG pages\n const ssgPages = scanSSGPages(root);\n\n if (ssgPages.length === 0) {\n return;\n }\n\n log(\"info\", `Generating ${ssgPages.length} static page(s) for SSG...`);\n\n // Check for dynamic routes (not supported yet)\n const dynamicPages = ssgPages.filter((p) => p.relativePath.includes(\"[\"));\n if (dynamicPages.length > 0) {\n log(\"warn\", `Skipping ${dynamicPages.length} dynamic route(s) - not yet supported:\\n` + dynamicPages.map((p) => ` - ${p.relativePath}`).join(\"\\n\"));\n }\n\n // Filter out dynamic routes\n const staticPages = ssgPages.filter((p) => !p.relativePath.includes(\"[\"));\n\n // Precompute RPC client stubs for SSG (mirrors helium Vite plugin)\n const { methods } = scanServerExports(root);\n const serverStubCode = `// Auto-generated SSG RPC stub\\n${generateClientModule(methods)}\\n`;\n\n // Create a stub for heliumts/client that provides mock Router and hooks\n const clientStubCode = `\n// Auto-generated SSG client stub\nimport React from 'react';\n\n// Mock RouterContext\nexport const RouterContext = React.createContext({\n path: '/',\n params: {},\n searchParams: new URLSearchParams(),\n push: () => {},\n replace: () => {},\n on: () => () => {},\n status: 200,\n isNavigating: false,\n isPending: false,\n});\n\n// Mock useRouter hook\nexport function useRouter() {\n const ctx = React.useContext(RouterContext);\n if (!ctx) {\n console.warn('useRouter called outside RouterContext during SSG');\n return {\n path: '/',\n params: {},\n searchParams: new URLSearchParams(),\n push: () => {},\n replace: () => {},\n on: () => () => {},\n status: 200,\n isNavigating: false,\n isPending: false,\n };\n }\n return ctx;\n}\n\n// Mock AppRouter component (alias for Router)\nexport function AppRouter({ children }) {\n return React.createElement(React.Fragment, null, children);\n}\n\n// Mock Router component\nexport function Router({ children }) {\n return React.createElement(React.Fragment, null, children);\n}\n\n// Mock Link component\nexport function Link({ href, children, prefetch, ...props }) {\n return React.createElement('a', { href, ...props }, children);\n}\n\n// Mock Redirect component\nexport function Redirect({ to, replace }) {\n return null;\n}\n\n// Mock useCall hook\nexport async function callMethod() {\n throw new Error('callMethod is only available in the browser. Load server data with getServerSideProps instead.');\n}\n\nexport function useCall(serverFn) {\n return { call: async () => null, isCalling: false, error: null };\n}\n\n// Mock useFetch hook\nexport function useFetch(serverFn, ...args) {\n console.warn('useFetch called during SSG - returning null');\n return { data: null, isLoading: false, error: null, refetch: async () => {} };\n}\n\nexport function isSSR() { return true; }\nexport function getPublicEnv() {\n return Object.fromEntries(Object.entries(process.env).filter(([key, value]) => key.startsWith('HELIUM_PUBLIC_') && typeof value === 'string'));\n}\nexport function getPublicEnvValue(key) { return getPublicEnv()[key]; }\nexport function isDevEnvironment() { return false; }\nexport class RpcError extends Error {}\n\n// Re-export cache (mock)\nexport const cache = {\n get: () => null,\n set: () => {},\n delete: () => {},\n clear: () => {},\n};\n\n// Mock PageTransition and useDeferredNavigation (also available from heliumts/client/transitions)\nexport function useDeferredNavigation() {\n const { path } = useRouter();\n return {\n path,\n deferredPath: path,\n isStale: false,\n isPending: false,\n isTransitioning: false,\n };\n}\n\nexport function PageTransition({ children, fallback = null }) {\n return React.createElement('div', { style: { opacity: 1, transition: 'opacity 150ms ease' } },\n React.createElement(React.Suspense, { fallback }, children));\n}\n`;\n\n // Create a stub for heliumts/client/transitions\n const transitionsStubCode = `\n// Auto-generated SSG transitions stub\nimport React from 'react';\nimport { useRouter } from 'heliumts/client';\n\n// Mock useDeferredNavigation hook - returns static values for SSG\nexport function useDeferredNavigation() {\n const { path } = useRouter();\n return {\n path,\n deferredPath: path,\n isStale: false,\n isPending: false,\n isTransitioning: false,\n };\n}\n\n// Mock PageTransition component - renders children without transition logic\nexport function PageTransition({ children, fallback = null }) {\n return React.createElement('div', { style: { opacity: 1, transition: 'opacity 150ms ease' } },\n React.createElement(React.Suspense, { fallback }, children));\n}\n\nexport default {\n useDeferredNavigation,\n PageTransition,\n};\n`;\n\n // Create a stub for heliumts/client/prefetch\n const prefetchStubCode = `\n// Auto-generated SSG prefetch stub\nexport function prefetchRoute() {\n // No-op during SSG\n}\n\nexport function clearPrefetchCache() {\n // No-op during SSG\n}\n`;\n\n // Write stub files to node_modules/.heliumts\n const heliumInternalDir = path.join(root, \"node_modules\", \".heliumts\");\n if (!fs.existsSync(heliumInternalDir)) {\n fs.mkdirSync(heliumInternalDir, { recursive: true });\n }\n const ssgServerStubPath = path.join(heliumInternalDir, \"ssg-server-stub.mjs\");\n const ssgClientStubPath = path.join(heliumInternalDir, \"ssg-client-stub.mjs\");\n const ssgTransitionsStubPath = path.join(heliumInternalDir, \"ssg-transitions-stub.mjs\");\n const ssgPrefetchStubPath = path.join(heliumInternalDir, \"ssg-prefetch-stub.mjs\");\n fs.writeFileSync(ssgServerStubPath, serverStubCode, \"utf-8\");\n fs.writeFileSync(ssgClientStubPath, clientStubCode, \"utf-8\");\n fs.writeFileSync(ssgTransitionsStubPath, transitionsStubCode, \"utf-8\");\n fs.writeFileSync(ssgPrefetchStubPath, prefetchStubCode, \"utf-8\");\n\n // Create a temporary Vite server for SSR rendering\n const { createServer } = await import(\"vite\");\n const heliumPlugin = (await import(\"./heliumPlugin.js\")).default;\n\n const viteServer = await createServer({\n root,\n mode: \"production\",\n server: { middlewareMode: true },\n appType: \"custom\",\n logLevel: \"error\",\n plugins: [heliumPlugin()],\n resolve: {\n alias: [\n // Most specific aliases first - heliumts/client/transitions and heliumts/client/prefetch\n { find: /^heliumts\\/client\\/transitions$/, replacement: ssgTransitionsStubPath },\n { find: /^heliumts\\/client\\/prefetch$/, replacement: ssgPrefetchStubPath },\n // Then heliumts/client and heliumts/server\n { find: /^heliumts\\/client$/, replacement: ssgClientStubPath },\n { find: /^heliumts\\/server$/, replacement: ssgServerStubPath },\n ],\n },\n ssr: {\n external: [\"react\", \"react-dom\"],\n // Don't externalize heliumts packages - we want to use our stubs\n noExternal: [\"heliumts\"],\n },\n });\n\n try {\n // Generate HTML for each static page\n const zlib = await import(\"zlib\");\n let successCount = 0;\n let failureCount = 0;\n let hasIndexSSG = false;\n\n // Calculate max path length for proper alignment (min 35, max 80)\n const maxPathLength = Math.min(80, Math.max(35, ...staticPages.map((p) => urlPathToOutputPath(p.urlPath).length)));\n\n for (const page of staticPages) {\n try {\n // Render the page component to static HTML using Vite SSR with 10s timeout\n const html = await renderPageToHTML(page, root, htmlTemplate, viteServer, 10000);\n const outputPath = urlPathToOutputPath(page.urlPath);\n const fullOutputPath = path.join(distDir, outputPath);\n\n // Track if the root page (/) has SSG\n if (page.urlPath === \"/\") {\n hasIndexSSG = true;\n }\n\n // Ensure directory exists\n const outputDir = path.dirname(fullOutputPath);\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n // Write the HTML file\n fs.writeFileSync(fullOutputPath, html, \"utf-8\");\n\n // Calculate file size and gzipped size\n const size = Buffer.byteLength(html, \"utf-8\");\n const sizeKB = (size / 1024).toFixed(2);\n\n // Calculate gzipped size\n const gzipped = zlib.gzipSync(html);\n const gzipSizeKB = (gzipped.length / 1024).toFixed(2);\n\n log(\"info\", ` ${outputPath.padEnd(maxPathLength)} ${sizeKB.padStart(8)} kB │ gzip: ${gzipSizeKB.padStart(7)} kB`);\n successCount++;\n } catch (error) {\n const errorMsg = error instanceof Error ? error.message : String(error);\n if (errorMsg.includes(\"timeout\")) {\n log(\"error\", ` ✗ ${page.relativePath} - ${errorMsg}`);\n } else {\n log(\"error\", ` ✗ ${page.relativePath} - Failed to generate:`, error);\n }\n\n // Write a fallback HTML file with empty root div (client will hydrate)\n const outputPath = urlPathToOutputPath(page.urlPath);\n const fullOutputPath = path.join(distDir, outputPath);\n const outputDir = path.dirname(fullOutputPath);\n\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n const fallbackHtml = replaceHtmlRootContents(htmlTemplate, \"\", { \"data-ssg-page\": null, \"data-ssg-failed\": page.urlPath });\n fs.writeFileSync(fullOutputPath, fallbackHtml, \"utf-8\");\n\n failureCount++;\n }\n }\n\n // If index page has SSG, we need to handle it specially:\n // 1. Rename __index.html to index.ssg.html (the SSG version)\n // 2. Create a clean blank index.html as fallback for non-root routes\n if (hasIndexSSG) {\n const tempIndexPath = path.join(distDir, \"__index.html\");\n const ssgIndexPath = path.join(distDir, \"index.ssg.html\");\n const indexPath = path.join(distDir, \"index.html\");\n\n // Move __index.html to index.ssg.html\n if (fs.existsSync(tempIndexPath)) {\n fs.renameSync(tempIndexPath, ssgIndexPath);\n }\n\n // Create a blank index.html as the SPA fallback\n const blankIndexHtml = replaceHtmlRootContents(htmlTemplate, \"\", { \"data-ssg-page\": null, \"data-ssg-failed\": null });\n fs.writeFileSync(indexPath, blankIndexHtml, \"utf-8\");\n\n log(\"info\", ` ${\"index.ssg.html\".padEnd(maxPathLength)} (SSG root page)`);\n log(\"info\", ` ${\"index.html\".padEnd(maxPathLength)} (blank SPA fallback)`);\n }\n\n // Summary\n if (failureCount > 0) {\n log(\"warn\", \"\");\n log(\"warn\", `SSG completed with ${successCount} success(es) and ${failureCount} failure(s).`);\n }\n } finally {\n // Always close the Vite server, even if generation fails\n await viteServer.close();\n }\n}\n"]}
@@ -2,5 +2,5 @@ import { HTTPHandlerExport, MethodExport, MiddlewareExport, SEOMetadataExport, S
2
2
  export declare function generateServerManifest(methods: MethodExport[], httpHandlers: HTTPHandlerExport[], seoMetadata?: SEOMetadataExport[], pageRoutePatterns?: string[], ssrPages?: SSRPageExport[], appShellFilePath?: string | null, middleware?: MiddlewareExport, workers?: WorkerExport[]): string;
3
3
  export declare function generateClientModule(methods: MethodExport[]): string;
4
4
  export declare function generateTypeDefinitions(methods: MethodExport[], root: string): string;
5
- export declare function generateEntryModule(): string;
5
+ export declare function generateEntryModule(appShellFilePath?: string | null): string;
6
6
  //# sourceMappingURL=virtualServerModule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"virtualServerModule.d.ts","sourceRoot":"","sources":["../../src/vite/virtualServerModule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjI,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,YAAY,EAAE,EACvB,YAAY,EAAE,iBAAiB,EAAE,EACjC,WAAW,GAAE,iBAAiB,EAAO,EACrC,iBAAiB,GAAE,MAAM,EAAO,EAChC,QAAQ,GAAE,aAAa,EAAO,EAC9B,gBAAgB,GAAE,MAAM,GAAG,IAAW,EACtC,UAAU,CAAC,EAAE,gBAAgB,EAC7B,OAAO,GAAE,YAAY,EAAO,GAC7B,MAAM,CAmGR;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,CAIpE;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAiErF;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAwB5C"}
1
+ {"version":3,"file":"virtualServerModule.d.ts","sourceRoot":"","sources":["../../src/vite/virtualServerModule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAajI,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,YAAY,EAAE,EACvB,YAAY,EAAE,iBAAiB,EAAE,EACjC,WAAW,GAAE,iBAAiB,EAAO,EACrC,iBAAiB,GAAE,MAAM,EAAO,EAChC,QAAQ,GAAE,aAAa,EAAO,EAC9B,gBAAgB,GAAE,MAAM,GAAG,IAAW,EACtC,UAAU,CAAC,EAAE,gBAAgB,EAC7B,OAAO,GAAE,YAAY,EAAO,GAC7B,MAAM,CAqGR;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,CAIpE;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAiErF;AAED,wBAAgB,mBAAmB,CAAC,gBAAgB,GAAE,MAAM,GAAG,IAAiB,GAAG,MAAM,CAwBxF"}
@@ -1,19 +1,31 @@
1
1
  import path from "path";
2
+ function moduleSpecifier(filePath) {
3
+ // Vite expects POSIX import paths, including on Windows.
4
+ return `'${filePath
5
+ .replace(/\\/g, "/")
6
+ .replace(/'/g, "\\'")
7
+ .replace(/\r/g, "\\r")
8
+ .replace(/\n/g, "\\n")
9
+ .replace(/\u2028/g, "\\u2028")
10
+ .replace(/\u2029/g, "\\u2029")}'`;
11
+ }
2
12
  export function generateServerManifest(methods, httpHandlers, seoMetadata = [], pageRoutePatterns = [], ssrPages = [], appShellFilePath = null, middleware, workers = []) {
3
- const methodImports = methods.map((m, i) => `import { ${m.name} as method_${i} } from '${m.filePath}';`).join("\n");
4
- const httpImports = httpHandlers.map((h, i) => `import { ${h.name} as http_${i} } from '${h.filePath}';`).join("\n");
5
- const seoImports = seoMetadata.map((s, i) => `import { ${s.name} as seo_${i} } from '${s.filePath}';`).join("\n");
6
- const workerImports = workers.map((w, i) => `import { ${w.name} as worker_${i} } from '${w.filePath}';`).join("\n");
7
- const middlewareImport = middleware ? `import ${middleware.name === "default" ? "middleware" : `{ ${middleware.name} as middleware }`} from '${middleware.filePath}';` : "";
13
+ const methodImports = methods.map((m, i) => `import { ${m.name} as method_${i} } from ${moduleSpecifier(m.filePath)};`).join("\n");
14
+ const httpImports = httpHandlers.map((h, i) => `import { ${h.name} as http_${i} } from ${moduleSpecifier(h.filePath)};`).join("\n");
15
+ const seoImports = seoMetadata.map((s, i) => `import { ${s.name} as seo_${i} } from ${moduleSpecifier(s.filePath)};`).join("\n");
16
+ const workerImports = workers.map((w, i) => `import { ${w.name} as worker_${i} } from ${moduleSpecifier(w.filePath)};`).join("\n");
17
+ const middlewareImport = middleware
18
+ ? `import ${middleware.name === "default" ? "middleware" : `{ ${middleware.name} as middleware }`} from ${moduleSpecifier(middleware.filePath)};`
19
+ : "";
8
20
  const methodRegistrations = methods.map((m, i) => ` registry.register('${m.name}', method_${i});`).join("\n");
9
21
  const httpExports = httpHandlers.map((h, i) => ` { name: '${h.name}', handler: http_${i} },`).join("\n");
10
22
  const seoExports = seoMetadata.map((s, i) => ` { name: '${s.name}', handler: seo_${i} },`).join("\n");
11
23
  const workerExports = workers.map((w, i) => ` { name: '${w.name}', worker: worker_${i} },`).join("\n");
12
24
  const ssrPageExports = ssrPages
13
- .map((s, i) => {
25
+ .map((s) => {
14
26
  const loadLayoutsBody = s.layoutFilePaths
15
27
  .map((layoutPath, layoutIndex) => ` {
16
- const mod_${layoutIndex} = await import('${layoutPath}');
28
+ const mod_${layoutIndex} = await import(${moduleSpecifier(layoutPath)});
17
29
  if (mod_${layoutIndex}.default) {
18
30
  layouts.push(mod_${layoutIndex}.default);
19
31
  }
@@ -21,7 +33,7 @@ export function generateServerManifest(methods, httpHandlers, seoMetadata = [],
21
33
  .join("\n");
22
34
  const sidecarCheck = s.serverFilePath
23
35
  ? ` {
24
- const sidecar = await import('${s.serverFilePath}');
36
+ const sidecar = await import(${moduleSpecifier(s.serverFilePath)});
25
37
  if (typeof sidecar.getServerSideProps === 'function') {
26
38
  return sidecar.getServerSideProps(req, ctx);
27
39
  }
@@ -29,9 +41,9 @@ export function generateServerManifest(methods, httpHandlers, seoMetadata = [],
29
41
  `
30
42
  : "";
31
43
  return ` {
32
- pathPattern: '${s.pathPattern}',
44
+ pathPattern: ${JSON.stringify(s.pathPattern)},
33
45
  loadComponent: async () => {
34
- const page = await import('${s.pageFilePath}');
46
+ const page = await import(${moduleSpecifier(s.pageFilePath)});
35
47
  return page.default;
36
48
  },
37
49
  loadLayouts: async () => {
@@ -40,7 +52,7 @@ ${loadLayoutsBody}
40
52
  return layouts;
41
53
  },
42
54
  getServerSideProps: async (req, ctx) => {
43
- ${sidecarCheck} const page = await import('${s.pageFilePath}');
55
+ ${sidecarCheck} const page = await import(${moduleSpecifier(s.pageFilePath)});
44
56
  if (typeof page.getServerSideProps === 'function') {
45
57
  return page.getServerSideProps(req, ctx);
46
58
  }
@@ -76,7 +88,7 @@ ${ssrPageExports}
76
88
 
77
89
  export const appShell = ${appShellFilePath
78
90
  ? `async () => {
79
- const mod = await import('${appShellFilePath}');
91
+ const mod = await import(${moduleSpecifier(appShellFilePath)});
80
92
  return mod.default ?? mod.App ?? mod.app ?? null;
81
93
  }`
82
94
  : "null"};
@@ -109,7 +121,7 @@ export function generateTypeDefinitions(methods, root) {
109
121
  });
110
122
  const imports = methodsWithRelativePath
111
123
  .map((m, index) => {
112
- return `import type { ${m.name} as __helium_method_${index} } from '${m.relPath}';`;
124
+ return `import type { ${m.name} as __helium_method_${index} } from ${moduleSpecifier(m.relPath)};`;
113
125
  })
114
126
  .join("\n");
115
127
  const methodExports = methodsWithRelativePath
@@ -152,12 +164,12 @@ ${methodExports}
152
164
  }
153
165
  `;
154
166
  }
155
- export function generateEntryModule() {
167
+ export function generateEntryModule(appShellFilePath = "/src/App") {
156
168
  return `
157
169
  import React from 'react';
158
170
  import { createRoot, hydrateRoot } from 'react-dom/client';
159
171
  import { AppRouter } from 'heliumts/client';
160
- import App from '/src/App';
172
+ ${appShellFilePath ? `import App from ${moduleSpecifier(appShellFilePath)};` : ""}
161
173
 
162
174
  const rootEl = document.getElementById('root');
163
175
  if (!rootEl) {
@@ -166,7 +178,7 @@ if (!rootEl) {
166
178
 
167
179
  const app = (
168
180
  <React.StrictMode>
169
- <AppRouter AppShell={App} />
181
+ <AppRouter${appShellFilePath ? " AppShell={App}" : ""} />
170
182
  </React.StrictMode>
171
183
  );
172
184
 
@@ -1 +1 @@
1
- {"version":3,"file":"virtualServerModule.js","sourceRoot":"","sources":["../../src/vite/virtualServerModule.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,MAAM,UAAU,sBAAsB,CAClC,OAAuB,EACvB,YAAiC,EACjC,cAAmC,EAAE,EACrC,oBAA8B,EAAE,EAChC,WAA4B,EAAE,EAC9B,mBAAkC,IAAI,EACtC,UAA6B,EAC7B,UAA0B,EAAE;IAE5B,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,IAAI,cAAc,CAAC,YAAY,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpH,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrH,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,IAAI,WAAW,CAAC,YAAY,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClH,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,IAAI,cAAc,CAAC,YAAY,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpH,MAAM,gBAAgB,GAAG,UAAU,CAAC,CAAC,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F,CAAC;AAED,MAAM,UAAU,mBAAmB;IAC/B,OAAO;;;;;;;;;;;;;;;;;;;;;;CAsBV,CAAC;AACF,CAAC","sourcesContent":["import path from \"path\";\n\nimport { HTTPHandlerExport, MethodExport, MiddlewareExport, SEOMetadataExport, SSRPageExport, WorkerExport } from \"./scanner.js\";\n\nexport function generateServerManifest(\n methods: MethodExport[],\n httpHandlers: HTTPHandlerExport[],\n seoMetadata: SEOMetadataExport[] = [],\n pageRoutePatterns: string[] = [],\n ssrPages: SSRPageExport[] = [],\n appShellFilePath: string | null = null,\n middleware?: MiddlewareExport,\n workers: WorkerExport[] = []\n): string {\n const methodImports = methods.map((m, i) => `import { ${m.name} as method_${i} } from '${m.filePath}';`).join(\"\\n\");\n const httpImports = httpHandlers.map((h, i) => `import { ${h.name} as http_${i} } from '${h.filePath}';`).join(\"\\n\");\n const seoImports = seoMetadata.map((s, i) => `import { ${s.name} as seo_${i} } from '${s.filePath}';`).join(\"\\n\");\n const workerImports = workers.map((w, i) => `import { ${w.name} as worker_${i} } from '${w.filePath}';`).join(\"\\n\");\n const middlewareImport = middleware ? `import ${middleware.name === \"default\" ? \"middleware\" : `{ ${middleware.name} as middleware }`} from '${middleware.filePath}';` : \"\";\n\n const methodRegistrations = methods.map((m, i) => ` registry.register('${m.name}', method_${i});`).join(\"\\n\");\n\n const httpExports = httpHandlers.map((h, i) => ` { name: '${h.name}', handler: http_${i} },`).join(\"\\n\");\n const seoExports = seoMetadata.map((s, i) => ` { name: '${s.name}', handler: seo_${i} },`).join(\"\\n\");\n\n const workerExports = workers.map((w, i) => ` { name: '${w.name}', worker: worker_${i} },`).join(\"\\n\");\n\n const ssrPageExports = ssrPages\n .map((s, i) => {\n const loadLayoutsBody = s.layoutFilePaths\n .map(\n (layoutPath, layoutIndex) => ` {\n const mod_${layoutIndex} = await import('${layoutPath}');\n if (mod_${layoutIndex}.default) {\n layouts.push(mod_${layoutIndex}.default);\n }\n }`\n )\n .join(\"\\n\");\n\n const sidecarCheck = s.serverFilePath\n ? ` {\n const sidecar = await import('${s.serverFilePath}');\n if (typeof sidecar.getServerSideProps === 'function') {\n return sidecar.getServerSideProps(req, ctx);\n }\n }\n`\n : \"\";\n\n return ` {\n pathPattern: '${s.pathPattern}',\n loadComponent: async () => {\n const page = await import('${s.pageFilePath}');\n return page.default;\n },\n loadLayouts: async () => {\n const layouts = [];\n${loadLayoutsBody}\n return layouts;\n },\n getServerSideProps: async (req, ctx) => {\n${sidecarCheck} const page = await import('${s.pageFilePath}');\n if (typeof page.getServerSideProps === 'function') {\n return page.getServerSideProps(req, ctx);\n }\n return null;\n }\n },`;\n })\n .join(\"\\n\");\n\n return `\n${methodImports}\n${httpImports}\n${seoImports}\n${workerImports}\n${middlewareImport}\n\nexport function registerAll(registry) {\n${methodRegistrations}\n}\n\nexport const httpHandlers = [\n${httpExports}\n];\n\nexport const seoMetadataHandlers = [\n${seoExports}\n];\n\nexport const pageRoutePatterns = ${JSON.stringify(pageRoutePatterns)};\n\nexport const ssrPages = [\n${ssrPageExports}\n];\n\nexport const appShell = ${\n appShellFilePath\n ? `async () => {\n const mod = await import('${appShellFilePath}');\n return mod.default ?? mod.App ?? mod.app ?? null;\n}`\n : \"null\"\n };\n\nexport const workers = [\n${workerExports}\n];\n\nexport const middlewareHandler = ${middleware ? \"middleware\" : \"null\"};\n`;\n}\n\nexport function generateClientModule(methods: MethodExport[]): string {\n const exports = methods.map((m) => `export const ${m.name} = { __id: '${m.name}' };`).join(\"\\n\");\n\n return exports;\n}\n\nexport function generateTypeDefinitions(methods: MethodExport[], root: string): string {\n // Sort methods by name for a stable output regardless of file-system walk order\n const sorted = [...methods].sort((a, b) => a.name.localeCompare(b.name));\n\n const methodsWithRelativePath = sorted.map((m) => {\n let relPath = path.relative(path.join(root, \"src\"), m.filePath);\n if (!relPath.startsWith(\".\")) {\n relPath = \"../\" + relPath;\n }\n // Normalize to posix separators for import paths\n relPath = relPath.replace(/\\\\/g, \"/\").replace(/\\.ts$/, \"\");\n return {\n ...m,\n relPath,\n };\n });\n\n const imports = methodsWithRelativePath\n .map((m, index) => {\n return `import type { ${m.name} as __helium_method_${index} } from '${m.relPath}';`;\n })\n .join(\"\\n\");\n\n const methodExports = methodsWithRelativePath\n .map((m, index) => {\n return ` export const ${m.name}: import('heliumts/client').MethodStub<\n Parameters<typeof __helium_method_${index}['handler']>[0],\n Awaited<ReturnType<typeof __helium_method_${index}['handler']>>\n >;`;\n })\n .join(\"\\n\");\n\n // If there are no methods, we don't need to generate any augmentation\n // This prevents shadowing the actual heliumts/server exports\n if (methods.length === 0) {\n return `/* eslint-disable */\n/**\n* Auto generated file - DO NOT EDIT!\n* # Helium Server Type Definitions\n* \n* This file is empty because no methods have been defined yet.\n* Once you create a method using defineMethod(), type stubs will be generated here.\n*\n* @helium-methods (none)\n**/\nexport {};\n`;\n }\n\n const methodSignature = methodsWithRelativePath.map((m) => m.name).join(\", \");\n\n return `/* eslint-disable */\n/**\n* Auto generated file - DO NOT EDIT!\n* # Helium Server Type Definitions\n*\n* @helium-methods ${methodSignature}\n**/\n${imports}\n\ndeclare module 'heliumts/server' {\n // Method stubs for client-side type inference\n${methodExports}\n}\n`;\n}\n\nexport function generateEntryModule(): string {\n return `\nimport React from 'react';\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { AppRouter } from 'heliumts/client';\nimport App from '/src/App';\n\nconst rootEl = document.getElementById('root');\nif (!rootEl) {\n throw new Error('Root element not found. Helium requires a <div id=\"root\"></div> in your HTML.');\n}\n\nconst app = (\n <React.StrictMode>\n <AppRouter AppShell={App} />\n </React.StrictMode>\n);\n\nif (rootEl.hasChildNodes()) {\n hydrateRoot(rootEl, app);\n} else {\n createRoot(rootEl).render(app);\n}\n`;\n}\n"]}
1
+ {"version":3,"file":"virtualServerModule.js","sourceRoot":"","sources":["../../src/vite/virtualServerModule.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,SAAS,eAAe,CAAC,QAAgB;IACrC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I,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO;;;;;;;;;;;CAWd,CAAC;IACE,CAAC;IAED,MAAM,eAAe,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE9E,OAAO;;;;;oBAKS,eAAe;;EAEjC,OAAO;;;;EAIP,aAAa;;CAEd,CAAC;AACF,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,mBAAkC,UAAU;IAC5E,OAAO;;;;EAIT,gBAAgB,CAAC,CAAC,CAAC,mBAAmB,eAAe,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;;;;;;;;;oBAS7D,gBAAgB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE;;;;;;;;;CAS5D,CAAC;AACF,CAAC","sourcesContent":["import path from \"path\";\n\nimport { HTTPHandlerExport, MethodExport, MiddlewareExport, SEOMetadataExport, SSRPageExport, WorkerExport } from \"./scanner.js\";\n\nfunction moduleSpecifier(filePath: string): string {\n // Vite expects POSIX import paths, including on Windows.\n return `'${filePath\n .replace(/\\\\/g, \"/\")\n .replace(/'/g, \"\\\\'\")\n .replace(/\\r/g, \"\\\\r\")\n .replace(/\\n/g, \"\\\\n\")\n .replace(/\\u2028/g, \"\\\\u2028\")\n .replace(/\\u2029/g, \"\\\\u2029\")}'`;\n}\n\nexport function generateServerManifest(\n methods: MethodExport[],\n httpHandlers: HTTPHandlerExport[],\n seoMetadata: SEOMetadataExport[] = [],\n pageRoutePatterns: string[] = [],\n ssrPages: SSRPageExport[] = [],\n appShellFilePath: string | null = null,\n middleware?: MiddlewareExport,\n workers: WorkerExport[] = []\n): string {\n const methodImports = methods.map((m, i) => `import { ${m.name} as method_${i} } from ${moduleSpecifier(m.filePath)};`).join(\"\\n\");\n const httpImports = httpHandlers.map((h, i) => `import { ${h.name} as http_${i} } from ${moduleSpecifier(h.filePath)};`).join(\"\\n\");\n const seoImports = seoMetadata.map((s, i) => `import { ${s.name} as seo_${i} } from ${moduleSpecifier(s.filePath)};`).join(\"\\n\");\n const workerImports = workers.map((w, i) => `import { ${w.name} as worker_${i} } from ${moduleSpecifier(w.filePath)};`).join(\"\\n\");\n const middlewareImport = middleware\n ? `import ${middleware.name === \"default\" ? \"middleware\" : `{ ${middleware.name} as middleware }`} from ${moduleSpecifier(middleware.filePath)};`\n : \"\";\n\n const methodRegistrations = methods.map((m, i) => ` registry.register('${m.name}', method_${i});`).join(\"\\n\");\n\n const httpExports = httpHandlers.map((h, i) => ` { name: '${h.name}', handler: http_${i} },`).join(\"\\n\");\n const seoExports = seoMetadata.map((s, i) => ` { name: '${s.name}', handler: seo_${i} },`).join(\"\\n\");\n\n const workerExports = workers.map((w, i) => ` { name: '${w.name}', worker: worker_${i} },`).join(\"\\n\");\n\n const ssrPageExports = ssrPages\n .map((s) => {\n const loadLayoutsBody = s.layoutFilePaths\n .map(\n (layoutPath, layoutIndex) => ` {\n const mod_${layoutIndex} = await import(${moduleSpecifier(layoutPath)});\n if (mod_${layoutIndex}.default) {\n layouts.push(mod_${layoutIndex}.default);\n }\n }`\n )\n .join(\"\\n\");\n\n const sidecarCheck = s.serverFilePath\n ? ` {\n const sidecar = await import(${moduleSpecifier(s.serverFilePath)});\n if (typeof sidecar.getServerSideProps === 'function') {\n return sidecar.getServerSideProps(req, ctx);\n }\n }\n`\n : \"\";\n\n return ` {\n pathPattern: ${JSON.stringify(s.pathPattern)},\n loadComponent: async () => {\n const page = await import(${moduleSpecifier(s.pageFilePath)});\n return page.default;\n },\n loadLayouts: async () => {\n const layouts = [];\n${loadLayoutsBody}\n return layouts;\n },\n getServerSideProps: async (req, ctx) => {\n${sidecarCheck} const page = await import(${moduleSpecifier(s.pageFilePath)});\n if (typeof page.getServerSideProps === 'function') {\n return page.getServerSideProps(req, ctx);\n }\n return null;\n }\n },`;\n })\n .join(\"\\n\");\n\n return `\n${methodImports}\n${httpImports}\n${seoImports}\n${workerImports}\n${middlewareImport}\n\nexport function registerAll(registry) {\n${methodRegistrations}\n}\n\nexport const httpHandlers = [\n${httpExports}\n];\n\nexport const seoMetadataHandlers = [\n${seoExports}\n];\n\nexport const pageRoutePatterns = ${JSON.stringify(pageRoutePatterns)};\n\nexport const ssrPages = [\n${ssrPageExports}\n];\n\nexport const appShell = ${\n appShellFilePath\n ? `async () => {\n const mod = await import(${moduleSpecifier(appShellFilePath)});\n return mod.default ?? mod.App ?? mod.app ?? null;\n}`\n : \"null\"\n };\n\nexport const workers = [\n${workerExports}\n];\n\nexport const middlewareHandler = ${middleware ? \"middleware\" : \"null\"};\n`;\n}\n\nexport function generateClientModule(methods: MethodExport[]): string {\n const exports = methods.map((m) => `export const ${m.name} = { __id: '${m.name}' };`).join(\"\\n\");\n\n return exports;\n}\n\nexport function generateTypeDefinitions(methods: MethodExport[], root: string): string {\n // Sort methods by name for a stable output regardless of file-system walk order\n const sorted = [...methods].sort((a, b) => a.name.localeCompare(b.name));\n\n const methodsWithRelativePath = sorted.map((m) => {\n let relPath = path.relative(path.join(root, \"src\"), m.filePath);\n if (!relPath.startsWith(\".\")) {\n relPath = \"../\" + relPath;\n }\n // Normalize to posix separators for import paths\n relPath = relPath.replace(/\\\\/g, \"/\").replace(/\\.ts$/, \"\");\n return {\n ...m,\n relPath,\n };\n });\n\n const imports = methodsWithRelativePath\n .map((m, index) => {\n return `import type { ${m.name} as __helium_method_${index} } from ${moduleSpecifier(m.relPath)};`;\n })\n .join(\"\\n\");\n\n const methodExports = methodsWithRelativePath\n .map((m, index) => {\n return ` export const ${m.name}: import('heliumts/client').MethodStub<\n Parameters<typeof __helium_method_${index}['handler']>[0],\n Awaited<ReturnType<typeof __helium_method_${index}['handler']>>\n >;`;\n })\n .join(\"\\n\");\n\n // If there are no methods, we don't need to generate any augmentation\n // This prevents shadowing the actual heliumts/server exports\n if (methods.length === 0) {\n return `/* eslint-disable */\n/**\n* Auto generated file - DO NOT EDIT!\n* # Helium Server Type Definitions\n* \n* This file is empty because no methods have been defined yet.\n* Once you create a method using defineMethod(), type stubs will be generated here.\n*\n* @helium-methods (none)\n**/\nexport {};\n`;\n }\n\n const methodSignature = methodsWithRelativePath.map((m) => m.name).join(\", \");\n\n return `/* eslint-disable */\n/**\n* Auto generated file - DO NOT EDIT!\n* # Helium Server Type Definitions\n*\n* @helium-methods ${methodSignature}\n**/\n${imports}\n\ndeclare module 'heliumts/server' {\n // Method stubs for client-side type inference\n${methodExports}\n}\n`;\n}\n\nexport function generateEntryModule(appShellFilePath: string | null = \"/src/App\"): string {\n return `\nimport React from 'react';\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { AppRouter } from 'heliumts/client';\n${appShellFilePath ? `import App from ${moduleSpecifier(appShellFilePath)};` : \"\"}\n\nconst rootEl = document.getElementById('root');\nif (!rootEl) {\n throw new Error('Root element not found. Helium requires a <div id=\"root\"></div> in your HTML.');\n}\n\nconst app = (\n <React.StrictMode>\n <AppRouter${appShellFilePath ? \" AppShell={App}\" : \"\"} />\n </React.StrictMode>\n);\n\nif (rootEl.hasChildNodes()) {\n hydrateRoot(rootEl, app);\n} else {\n createRoot(rootEl).render(app);\n}\n`;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heliumts",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
4
4
  "description": "A lightweight full-stack React framework with file-based routing, RPC, and SSG support",
5
5
  "keywords": [
6
6
  "react",
@@ -75,19 +75,21 @@
75
75
  "lint:fix": "eslint --ext .ts,.tsx src --fix",
76
76
  "test": "vitest run",
77
77
  "test:watch": "vitest",
78
- "test:coverage": "vitest run --coverage"
78
+ "test:coverage": "vitest run --coverage",
79
+ "typecheck": "tsc -p tsconfig.test.json --noEmit",
80
+ "test:smoke": "node scripts/smoke.mjs"
79
81
  },
80
82
  "peerDependencies": {
81
83
  "cac": "^6.7.14",
82
84
  "esbuild": "^0.27.0",
83
85
  "react": "^18.0.0 || ^19.0.0",
84
86
  "react-dom": "^18.0.0 || ^19.0.0",
85
- "vite": "^7.0.0"
87
+ "vite": "^7.3.7"
86
88
  },
87
89
  "dependencies": {
88
90
  "@msgpack/msgpack": "^3.1.2",
89
91
  "dotenv": "^17.2.3",
90
- "ws": "^8.18.3"
92
+ "ws": "^8.22.1"
91
93
  },
92
94
  "files": [
93
95
  "dist"
@@ -101,7 +103,7 @@
101
103
  "@types/ws": "^8.18.1",
102
104
  "@typescript-eslint/eslint-plugin": "^8.47.0",
103
105
  "@typescript-eslint/parser": "^8.47.0",
104
- "@vitest/coverage-v8": "^4.0.15",
106
+ "@vitest/coverage-v8": "^4.1.12",
105
107
  "eslint": "^9.39.1",
106
108
  "eslint-config-prettier": "^10.1.8",
107
109
  "eslint-plugin-import": "^2.32.0",
@@ -111,7 +113,10 @@
111
113
  "jsdom": "^27.2.0",
112
114
  "prettier": "^3.6.2",
113
115
  "typescript": "^5.9.3",
114
- "vite": "^7.2.4",
115
- "vitest": "^4.0.15"
116
+ "vite": "^7.3.7",
117
+ "vitest": "^4.1.12"
118
+ },
119
+ "engines": {
120
+ "node": "^20.19.0 || >=22.12.0"
116
121
  }
117
122
  }