heliumts 0.9.6 → 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.
- package/README.md +3 -3
- package/dist/bin/helium.js +4 -0
- package/dist/bin/helium.js.map +1 -1
- package/dist/client/callMethod.d.ts +13 -0
- package/dist/client/callMethod.d.ts.map +1 -0
- package/dist/client/callMethod.js +10 -0
- package/dist/client/callMethod.js.map +1 -0
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/rpcClient.d.ts +7 -3
- package/dist/client/rpcClient.d.ts.map +1 -1
- package/dist/client/rpcClient.js +10 -7
- package/dist/client/rpcClient.js.map +1 -1
- package/dist/server/devServer.d.ts.map +1 -1
- package/dist/server/devServer.js +8 -23
- package/dist/server/devServer.js.map +1 -1
- package/dist/server/httpCompression.d.ts +8 -0
- package/dist/server/httpCompression.d.ts.map +1 -0
- package/dist/server/httpCompression.js +58 -0
- package/dist/server/httpCompression.js.map +1 -0
- package/dist/server/prodServer.d.ts.map +1 -1
- package/dist/server/prodServer.js +8 -23
- package/dist/server/prodServer.js.map +1 -1
- package/dist/server/rpcRegistry.d.ts +4 -0
- package/dist/server/rpcRegistry.d.ts.map +1 -1
- package/dist/server/rpcRegistry.js +14 -9
- package/dist/server/rpcRegistry.js.map +1 -1
- package/dist/server/serializer.js +12 -6
- package/dist/server/serializer.js.map +1 -1
- package/dist/vite/heliumPlugin.d.ts.map +1 -1
- package/dist/vite/heliumPlugin.js +4 -0
- package/dist/vite/heliumPlugin.js.map +1 -1
- package/dist/vite/ssg.d.ts.map +1 -1
- package/dist/vite/ssg.js +4 -0
- package/dist/vite/ssg.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heliumPlugin.js","sourceRoot":"","sources":["../../src/vite/heliumPlugin.ts"],"names":[],"mappings":"AAAA,OAA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,EAAE,CAAC;YAC9B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,EAAE,CAAC,UAAU,CAAC,YAAY,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACL,6EAA6E;IACjF,CAAC;AACL,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport type { Plugin } from \"vite\";\n\nimport { clearConfigCache, getRpcClientConfig, getRpcConfig, loadConfig } from \"../server/config.js\";\nimport { attachToDevServer } from \"../server/devServer.js\";\nimport { injectEnvToProcess, loadEnvFiles } from \"../utils/envLoader.js\";\nimport { log } from \"../utils/logger.js\";\nimport {\n RESOLVED_VIRTUAL_CLIENT_MODULE_ID,\n RESOLVED_VIRTUAL_ENTRY_MODULE_ID,\n RESOLVED_VIRTUAL_SERVER_MANIFEST_ID,\n SERVER_DIR,\n VIRTUAL_CLIENT_MODULE_ID,\n VIRTUAL_ENTRY_MODULE_ID,\n VIRTUAL_SERVER_MANIFEST_ID,\n} from \"./paths.js\";\nimport { checkRouteCollisions, scanAppShell, scanPageRoutePatterns, scanServerExports, scanSSRPages } from \"./scanner.js\";\nimport { generateClientModule, generateEntryModule, generateServerManifest, generateTypeDefinitions } from \"./virtualServerModule.js\";\n\nexport default function helium(): Plugin {\n let root = process.cwd();\n const serverDir = normalizeToPosix(SERVER_DIR);\n const RESOLVED_VIRTUAL_SSR_SERVER_MODULE_ID = \"\\0heliumts:ssr-server\";\n const RESOLVED_VIRTUAL_SSR_CLIENT_MODULE_ID = \"\\0heliumts:ssr-client\";\n const RESOLVED_VIRTUAL_SSR_TRANSITIONS_MODULE_ID = \"\\0heliumts:ssr-transitions\";\n const RESOLVED_VIRTUAL_SSR_PREFETCH_MODULE_ID = \"\\0heliumts:ssr-prefetch\";\n\n return {\n name: \"vite-plugin-helium\",\n enforce: \"pre\",\n configResolved(config) {\n root = config.root;\n },\n transformIndexHtml: {\n order: \"pre\",\n handler(html, _ctx) {\n // Check if HTML already has a script tag for entry\n if (/<script\\b[^>]*\\bsrc\\s*=\\s*[\"'][^\"']*src\\/main\\.[jt]sx?(?:[?#][^\"']*)?[\"']/i.test(html)) {\n return html; // User has their own entry, don't modify\n }\n\n // Ensure root div exists\n let modifiedHtml = html;\n if (!/<[a-z][^>]*\\sid\\s*=\\s*[\"']root[\"']/i.test(modifiedHtml)) {\n modifiedHtml = modifiedHtml.replace(/<body\\b[^>]*>/i, (body) => `${body}\\n <div id=\"root\"></div>`);\n }\n\n // Generate physical entry file\n const heliumDir = path.join(root, \"node_modules\", \".heliumts\");\n if (!fs.existsSync(heliumDir)) {\n fs.mkdirSync(heliumDir, { recursive: true });\n }\n const entryPath = path.join(heliumDir, \"entry.tsx\");\n fs.writeFileSync(entryPath, generateEntryModule(scanAppShell(root)));\n\n // Return with tags to inject the entry (runtime config is fetched by the client)\n return {\n html: modifiedHtml,\n tags: [\n {\n tag: \"script\",\n attrs: {\n type: \"module\",\n src: \"/node_modules/.heliumts/entry.tsx\",\n },\n injectTo: \"body\",\n },\n ],\n };\n },\n },\n async config(config, env) {\n // configResolved runs after this hook; honor an explicit Vite root now.\n root = path.resolve(config.root || process.cwd());\n const mode = env.mode;\n const envVars = loadEnvFiles({ root, mode });\n\n // Inject env vars into process.env so server-side code can access them\n // consistently in both development and production.\n injectEnvToProcess(envVars);\n\n // Load helium config to get client-side RPC transport settings\n const heliumConfig = await loadConfig(root);\n const rpcClientConfig = getRpcClientConfig(heliumConfig);\n\n // Provide default index.html if none exists\n return {\n appType: config.appType ?? \"spa\",\n optimizeDeps: {\n include: [\"react-dom/client\"],\n // Exclude helium from pre-bundling since it's the framework itself\n // This ensures changes to helium are picked up immediately\n exclude: [\"heliumts\", \"heliumts/client\", \"heliumts/server\", \"heliumts/vite\"],\n },\n // SSR configuration to properly isolate server-only code\n ssr: {\n // Externalize Node.js built-in modules - these should never be bundled\n external: [\"util\", \"zlib\", \"http\", \"https\", \"http2\", \"fs\", \"path\", \"crypto\", \"stream\", \"os\", \"url\", \"net\", \"tls\", \"child_process\", \"worker_threads\"],\n // Don't externalize heliumts - let the plugin handle the client/server split\n noExternal: [\"heliumts\"],\n },\n // Ensure Node.js built-ins are not bundled for client\n build: {\n rollupOptions: {\n external: [\n // Node.js built-in modules should never be in client bundle\n /^node:/,\n \"util\",\n \"zlib\",\n \"http\",\n \"https\",\n \"http2\",\n \"fs\",\n \"path\",\n \"crypto\",\n \"stream\",\n \"os\",\n \"url\",\n \"net\",\n \"tls\",\n \"child_process\",\n \"worker_threads\",\n ],\n },\n },\n define: {\n __HELIUM_DEV__: JSON.stringify(env.command === \"serve\"),\n __HELIUM_RPC_TRANSPORT__: JSON.stringify(rpcClientConfig.transport),\n __HELIUM_RPC_AUTO_HTTP_ON_MOBILE__: JSON.stringify(rpcClientConfig.autoHttpOnMobile),\n __HELIUM_RPC_TOKEN_VALIDITY_MS__: JSON.stringify(rpcClientConfig.tokenValidityMs),\n __HELIUM_RPC_MAX_BATCH_SIZE__: JSON.stringify(getRpcConfig(heliumConfig).maxBatchSize),\n },\n };\n },\n resolveId(id, importer, options) {\n if (options?.ssr && id === \"heliumts/client\") {\n return RESOLVED_VIRTUAL_SSR_CLIENT_MODULE_ID;\n }\n if (options?.ssr && id === \"heliumts/client/transitions\") {\n return RESOLVED_VIRTUAL_SSR_TRANSITIONS_MODULE_ID;\n }\n if (options?.ssr && id === \"heliumts/client/prefetch\") {\n return RESOLVED_VIRTUAL_SSR_PREFETCH_MODULE_ID;\n }\n if (id === VIRTUAL_CLIENT_MODULE_ID) {\n if (importer === RESOLVED_VIRTUAL_SSR_SERVER_MODULE_ID || isServerModule(importer, root, serverDir) || /\\.server\\.[cm]?[jt]sx?(?:\\?|$)/.test(importer || \"\")) {\n return null;\n }\n return options?.ssr ? RESOLVED_VIRTUAL_SSR_SERVER_MODULE_ID : RESOLVED_VIRTUAL_CLIENT_MODULE_ID;\n }\n if (id === VIRTUAL_SERVER_MANIFEST_ID) {\n return RESOLVED_VIRTUAL_SERVER_MANIFEST_ID;\n }\n if (id === VIRTUAL_ENTRY_MODULE_ID) {\n // Add .tsx extension so Vite knows it contains JSX\n return RESOLVED_VIRTUAL_ENTRY_MODULE_ID + \".tsx\";\n }\n return null;\n },\n transform(code, id, options) {\n if (!options?.ssr && isServerModule(id, root, serverDir)) {\n throw new Error(`Server-only module cannot be imported by client code: ${id}. Import RPC method stubs from 'heliumts/server' instead.`);\n }\n // Prevent .server.ts/.server.js sidecar files from being bundled in client code.\n // These files contain server-only logic (e.g. DB queries) and must never run in the browser.\n if (!options?.ssr && /\\.server\\.(ts|js|tsx|jsx|mts|mjs)$/.test(id.split(\"?\")[0])) {\n return { code: \"export default null;\", map: null };\n }\n },\n load(id) {\n if (id === RESOLVED_VIRTUAL_SSR_SERVER_MODULE_ID) {\n const { methods } = scanServerExports(root);\n return `export * from 'heliumts/server';\\n${generateClientModule(methods)}`;\n }\n if (id === RESOLVED_VIRTUAL_SSR_CLIENT_MODULE_ID) {\n return generateSSRClientStubModule();\n }\n if (id === RESOLVED_VIRTUAL_SSR_TRANSITIONS_MODULE_ID) {\n return generateSSRTransitionsStubModule();\n }\n if (id === RESOLVED_VIRTUAL_SSR_PREFETCH_MODULE_ID) {\n return generateSSRPrefetchStubModule();\n }\n if (id === RESOLVED_VIRTUAL_CLIENT_MODULE_ID) {\n const { methods } = scanServerExports(root);\n return generateClientModule(methods);\n }\n if (id === RESOLVED_VIRTUAL_SERVER_MANIFEST_ID) {\n const { methods, httpHandlers, seoMetadata, middleware, workers } = scanServerExports(root);\n const pageRoutePatterns = scanPageRoutePatterns(root);\n const ssrPages = scanSSRPages(root);\n const appShell = scanAppShell(root);\n return generateServerManifest(methods, httpHandlers, seoMetadata, pageRoutePatterns, ssrPages, appShell, middleware, workers);\n }\n if (id === RESOLVED_VIRTUAL_ENTRY_MODULE_ID + \".tsx\") {\n return generateEntryModule(scanAppShell(root));\n }\n },\n buildStart() {\n const { methods } = scanServerExports(root);\n const dts = generateTypeDefinitions(methods, root);\n const typesDir = path.join(root, \"src\", \"types\");\n const dtsPath = path.join(typesDir, \"heliumts-server.d.ts\");\n\n // Ensure src/types exists\n if (!fs.existsSync(typesDir)) {\n fs.mkdirSync(typesDir, { recursive: true });\n }\n\n // At build start we always allow writing the canonical set.\n // Only skip if content is identical to avoid needless TS invalidation.\n if (!fs.existsSync(dtsPath) || fs.readFileSync(dtsPath, \"utf-8\") !== dts) {\n fs.writeFileSync(dtsPath, dts);\n touchTsConfig(root);\n }\n\n // Check for route collisions in pages directory\n checkRouteCollisions(root);\n },\n configureServer(server) {\n // Vite's SPA fallback runs after static/public assets and preserves request URLs.\n /**\n * Write type definitions only if content has changed.\n * This prevents unnecessary TypeScript recompilation.\n *\n * When `allowFewer` is false (default) the file will NOT be\n * overwritten if the new content has fewer method declarations\n * than the existing file — this guards against writing a\n * degraded .d.ts while the user's file is only partially saved.\n */\n const writeTypesIfChanged = (dts: string, allowFewer = false): boolean => {\n const typesDir = path.join(root, \"src\", \"types\");\n const dtsPath = path.join(typesDir, \"heliumts-server.d.ts\");\n\n if (!fs.existsSync(typesDir)) {\n fs.mkdirSync(typesDir, { recursive: true });\n }\n\n // Check if file exists and content is the same\n if (fs.existsSync(dtsPath)) {\n const existing = fs.readFileSync(dtsPath, \"utf-8\");\n if (existing === dts) {\n return false; // No change needed\n }\n\n // Guard: don't overwrite with fewer methods unless explicitly allowed\n // (e.g. on unlink). This prevents losing types during partial saves.\n if (!allowFewer) {\n const countExports = (s: string) => (s.match(/export const \\w+:/g) || []).length;\n const existingCount = countExports(existing);\n const newCount = countExports(dts);\n if (newCount < existingCount) {\n log(\"info\", `Skipping type generation: found ${newCount} methods, existing has ${existingCount} (likely partial save)`);\n return false;\n }\n }\n }\n\n fs.writeFileSync(dtsPath, dts);\n\n // Touch tsconfig.json to force the TypeScript language server\n // to reload the project. Without this, TS may cache stale\n // module augmentations and autocomplete won't reflect the\n // new methods until a manual restart.\n touchTsConfig(root);\n\n return true; // File was written\n };\n\n const regenerateTypes = (allowFewer = false): boolean => {\n try {\n const { methods } = scanServerExports(root);\n const dts = generateTypeDefinitions(methods, root);\n return writeTypesIfChanged(dts, allowFewer);\n } catch (e) {\n log(\"error\", \"Failed to regenerate types\", e);\n return false;\n }\n };\n\n // Debounce timer for file changes\n let debounceTimer: ReturnType<typeof setTimeout> | null = null;\n const DEBOUNCE_DELAY = 300; // ms — long enough for format-on-save to finish\n\n const handleServerFileChange = async (allowFewer = false) => {\n // Regenerate type definitions\n regenerateTypes(allowFewer);\n\n // Invalidate the virtual modules so they get regenerated\n const clientModule = server.environments.client?.moduleGraph.getModuleById(RESOLVED_VIRTUAL_CLIENT_MODULE_ID);\n const serverModule = server.environments.ssr?.moduleGraph.getModuleById(RESOLVED_VIRTUAL_SERVER_MANIFEST_ID);\n const ssrRpcModule = server.environments.ssr?.moduleGraph.getModuleById(RESOLVED_VIRTUAL_SSR_SERVER_MODULE_ID);\n\n if (clientModule) {\n server.environments.client?.moduleGraph.invalidateModule(clientModule);\n }\n if (serverModule) {\n server.environments.ssr?.moduleGraph.invalidateModule(serverModule);\n }\n\n if (ssrRpcModule) {\n server.environments.ssr?.moduleGraph.invalidateModule(ssrRpcModule);\n }\n\n // Reload the server manifest and re-register methods\n try {\n // Clear config cache to ensure fresh config is loaded\n clearConfigCache();\n const config = await loadConfig(root);\n const mod = await server.ssrLoadModule(VIRTUAL_SERVER_MANIFEST_ID);\n const registerAll = mod.registerAll;\n const httpHandlers = mod.httpHandlers || [];\n const seoMetadataHandlers = mod.seoMetadataHandlers || [];\n const pageRoutePatterns = mod.pageRoutePatterns || [];\n const middlewareHandler = mod.middlewareHandler || null;\n const workers = mod.workers || [];\n const ssrPages = mod.ssrPages || [];\n const appShell = mod.appShell || null;\n\n // Update the dev server registry with new methods and HTTP handlers\n if (server.httpServer) {\n attachToDevServer(\n server.httpServer,\n (registry, httpRouter, seoRouter) => {\n registerAll(registry);\n httpRouter.registerRoutes(httpHandlers);\n seoRouter.registerRoutes(seoMetadataHandlers);\n seoRouter.setPageRoutePatterns(pageRoutePatterns);\n if (middlewareHandler) {\n registry.setMiddleware(middlewareHandler);\n httpRouter.setMiddleware(middlewareHandler);\n }\n },\n config,\n workers,\n ssrPages,\n appShell\n );\n }\n } catch (e) {\n log(\"error\", \"Failed to reload Helium server manifest\", e);\n }\n\n // Trigger HMR for any client code that imports heliumts/server\n server.ws.send({\n type: \"full-reload\",\n path: \"*\",\n });\n };\n\n // Watch server and page directories: new SSR pages and sidecars change the manifest too.\n server.watcher.add([path.join(root, serverDir), path.join(root, \"src\", \"pages\")]);\n\n // Watch config files for changes\n const configFiles = [\"helium.config.ts\", \"helium.config.js\", \"helium.config.mjs\"];\n for (const configFile of configFiles) {\n const configPath = path.join(root, configFile);\n if (fs.existsSync(configPath)) {\n server.watcher.add(configPath);\n }\n }\n\n /**\n * Debounced handler for server file changes.\n * This prevents multiple rapid regenerations during file saves.\n * @param allowFewer - pass true when files are deleted, so the\n * method count is allowed to decrease.\n */\n let pendingAllowFewer = false;\n const debouncedHandleServerFileChange = (allowFewer = false) => {\n // If any event in the batch is an unlink, honour it\n if (allowFewer) {\n pendingAllowFewer = true;\n }\n if (debounceTimer) {\n clearTimeout(debounceTimer);\n }\n debounceTimer = setTimeout(() => {\n debounceTimer = null;\n const shouldAllowFewer = pendingAllowFewer;\n pendingAllowFewer = false;\n handleServerFileChange(shouldAllowFewer);\n }, DEBOUNCE_DELAY);\n };\n\n const affectsManifest = (file: string): boolean => {\n const normalized = normalizeToPosix(path.relative(root, file));\n return (\n normalized.startsWith(`${serverDir}/`) || normalized.startsWith(\"src/pages/\") || /^src\\/[Aa]pp\\.[jt]sx?$/.test(normalized) || configFiles.includes(normalized)\n );\n };\n\n server.watcher.on(\"change\", (file) => {\n if (affectsManifest(file)) {\n debouncedHandleServerFileChange(true);\n }\n });\n\n server.watcher.on(\"add\", (file) => {\n if (affectsManifest(file)) {\n debouncedHandleServerFileChange();\n }\n });\n\n server.watcher.on(\"unlink\", (file) => {\n if (affectsManifest(file)) {\n debouncedHandleServerFileChange(true);\n }\n });\n\n server.httpServer?.once(\"close\", () => {\n if (debounceTimer) {\n clearTimeout(debounceTimer);\n }\n });\n\n // We hook into the server start to attach our RPC server\n server.httpServer?.on(\"listening\", async () => {\n try {\n // Load config\n const config = await loadConfig(root);\n\n // Load the manifest using Vite's SSR loader\n // This allows us to load TS files directly and handle dependencies\n const mod = await server.ssrLoadModule(VIRTUAL_SERVER_MANIFEST_ID);\n const registerAll = mod.registerAll;\n const httpHandlers = mod.httpHandlers || [];\n const seoMetadataHandlers = mod.seoMetadataHandlers || [];\n const pageRoutePatterns = mod.pageRoutePatterns || [];\n const middlewareHandler = mod.middlewareHandler || null;\n const workers = mod.workers || [];\n const ssrPages = mod.ssrPages || [];\n const appShell = mod.appShell || null;\n\n if (server.httpServer) {\n attachToDevServer(\n server.httpServer,\n (registry, httpRouter, seoRouter) => {\n registerAll(registry);\n httpRouter.registerRoutes(httpHandlers);\n seoRouter.registerRoutes(seoMetadataHandlers);\n seoRouter.setPageRoutePatterns(pageRoutePatterns);\n if (middlewareHandler) {\n registry.setMiddleware(middlewareHandler);\n httpRouter.setMiddleware(middlewareHandler);\n }\n },\n config,\n workers,\n ssrPages,\n appShell\n );\n }\n } catch (e) {\n log(\"error\", \"Failed to attach Helium RPC server\", e);\n }\n });\n },\n };\n}\n\nfunction generateSSRClientStubModule(): string {\n return `\nimport React from 'react';\n\nexport const RouterContext = React.createContext(null);\n\nfunction getSSRRouterSnapshot() {\n const snapshot = globalThis.__HELIUM_SSR_ROUTER__;\n if (!snapshot || typeof snapshot !== 'object') {\n return {\n path: '/',\n params: {},\n search: '',\n };\n }\n\n return {\n path: typeof snapshot.path === 'string' ? snapshot.path : '/',\n params: snapshot.params && typeof snapshot.params === 'object' ? snapshot.params : {},\n search: typeof snapshot.search === 'string' ? snapshot.search : '',\n };\n}\n\nexport function useRouter() {\n const snapshot = getSSRRouterSnapshot();\n return {\n path: snapshot.path,\n params: snapshot.params,\n searchParams: new URLSearchParams(snapshot.search),\n push: () => {},\n replace: () => {},\n on: () => () => {},\n status: 200,\n isNavigating: false,\n isPending: false,\n };\n}\n\nexport function Link(props) {\n const { href = '#', children, prefetch, ...rest } = props || {};\n return React.createElement('a', { href, ...rest }, children);\n}\n\nexport function Redirect() {\n return null;\n}\n\nexport function AppRouter() {\n return null;\n}\n\nexport function useCall() {\n return {\n call: async () => null,\n isCalling: false,\n error: null,\n };\n}\n\nexport function useFetch() {\n return {\n data: null,\n isLoading: false,\n error: null,\n refetch: async () => undefined,\n };\n}\n\nexport class RpcError extends Error {}\n\nexport function getPublicEnv() {\n return Object.fromEntries(Object.entries(process.env).filter(([key, value]) => key.startsWith('HELIUM_PUBLIC_') && typeof value === 'string'));\n}\n\nexport function getPublicEnvValue(key) {\n return getPublicEnv()[key];\n}\n\nexport function isDevEnvironment() {\n return false;\n}\n\nexport function getRpcTransport() {\n return 'websocket';\n}\n\nexport function isAutoHttpOnMobileEnabled() {\n return false;\n}\n\nexport function preconnect() {}\n\nexport function isSSR() {\n return true;\n}\n`;\n}\n\nfunction generateSSRTransitionsStubModule(): string {\n return `\nimport React from 'react';\nimport { useRouter } from 'heliumts/client';\n\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\nfunction generateSSRPrefetchStubModule(): string {\n return `\nexport function prefetchRoute() {}\nexport function clearPrefetchCache() {}\n`;\n}\n\n/**\n * Convert file path to POSIX format\n * @internal Exported for testing\n */\nexport function normalizeToPosix(filePath: string): string {\n return filePath.split(path.sep).join(\"/\");\n}\n\n/**\n * Check if an importer is a server module\n * @internal Exported for testing\n */\nexport function isServerModule(importer: string | undefined, root: string, serverDir: string): boolean {\n if (!importer || importer.startsWith(\"\\0\")) {\n return false;\n }\n\n const [importerPath] = importer.split(\"?\");\n if (!importerPath) {\n return false;\n }\n\n const relative = path.relative(root, importerPath);\n if (!relative || relative.startsWith(\"..\")) {\n return false;\n }\n\n const normalized = normalizeToPosix(relative);\n return normalized === serverDir || normalized.startsWith(`${serverDir}/`);\n}\n\n/**\n * Touch the project's tsconfig.json to force the TypeScript language server\n * to reload the project and pick up changed module augmentations.\n *\n * TS language server watches tsconfig.json for changes. When a `.d.ts` file\n * with `declare module` augmentations is regenerated, TS doesn't always\n * detect the new content — leading to stale autocomplete. By updating\n * tsconfig.json's mtime we trigger a full project reload.\n *\n * The file content is NOT modified; only the filesystem timestamp changes.\n *\n * @internal Exported for testing\n */\nexport function touchTsConfig(root: string): void {\n const tsconfigPath = path.join(root, \"tsconfig.json\");\n try {\n if (fs.existsSync(tsconfigPath)) {\n const now = new Date();\n fs.utimesSync(tsconfigPath, now, now);\n }\n } catch {\n // Non-critical: if we can't touch the file, TS may just need a manual reload\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"heliumPlugin.js","sourceRoot":"","sources":["../../src/vite/heliumPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EACH,iCAAiC,EACjC,gCAAgC,EAChC,mCAAmC,EACnC,UAAU,EACV,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,GAC7B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAA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C;QACzC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,CAAC,YAAY,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACnD,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACzC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC9C,OAAO,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACtC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IACtD,IAAI,CAAC;QACD,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC9B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,EAAE,CAAC,UAAU,CAAC,YAAY,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACL,6EAA6E;IACjF,CAAC;AACL,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport type { Plugin } from \"vite\";\n\nimport { clearConfigCache, getRpcClientConfig, getRpcConfig, loadConfig } from \"../server/config.js\";\nimport { attachToDevServer } from \"../server/devServer.js\";\nimport { injectEnvToProcess, loadEnvFiles } from \"../utils/envLoader.js\";\nimport { log } from \"../utils/logger.js\";\nimport {\n RESOLVED_VIRTUAL_CLIENT_MODULE_ID,\n RESOLVED_VIRTUAL_ENTRY_MODULE_ID,\n RESOLVED_VIRTUAL_SERVER_MANIFEST_ID,\n SERVER_DIR,\n VIRTUAL_CLIENT_MODULE_ID,\n VIRTUAL_ENTRY_MODULE_ID,\n VIRTUAL_SERVER_MANIFEST_ID,\n} from \"./paths.js\";\nimport { checkRouteCollisions, scanAppShell, scanPageRoutePatterns, scanServerExports, scanSSRPages } from \"./scanner.js\";\nimport { generateClientModule, generateEntryModule, generateServerManifest, generateTypeDefinitions } from \"./virtualServerModule.js\";\n\nexport default function helium(): Plugin {\n let root = process.cwd();\n const serverDir = normalizeToPosix(SERVER_DIR);\n const RESOLVED_VIRTUAL_SSR_SERVER_MODULE_ID = \"\\0heliumts:ssr-server\";\n const RESOLVED_VIRTUAL_SSR_CLIENT_MODULE_ID = \"\\0heliumts:ssr-client\";\n const RESOLVED_VIRTUAL_SSR_TRANSITIONS_MODULE_ID = \"\\0heliumts:ssr-transitions\";\n const RESOLVED_VIRTUAL_SSR_PREFETCH_MODULE_ID = \"\\0heliumts:ssr-prefetch\";\n\n return {\n name: \"vite-plugin-helium\",\n enforce: \"pre\",\n configResolved(config) {\n root = config.root;\n },\n transformIndexHtml: {\n order: \"pre\",\n handler(html, _ctx) {\n // Check if HTML already has a script tag for entry\n if (/<script\\b[^>]*\\bsrc\\s*=\\s*[\"'][^\"']*src\\/main\\.[jt]sx?(?:[?#][^\"']*)?[\"']/i.test(html)) {\n return html; // User has their own entry, don't modify\n }\n\n // Ensure root div exists\n let modifiedHtml = html;\n if (!/<[a-z][^>]*\\sid\\s*=\\s*[\"']root[\"']/i.test(modifiedHtml)) {\n modifiedHtml = modifiedHtml.replace(/<body\\b[^>]*>/i, (body) => `${body}\\n <div id=\"root\"></div>`);\n }\n\n // Generate physical entry file\n const heliumDir = path.join(root, \"node_modules\", \".heliumts\");\n if (!fs.existsSync(heliumDir)) {\n fs.mkdirSync(heliumDir, { recursive: true });\n }\n const entryPath = path.join(heliumDir, \"entry.tsx\");\n fs.writeFileSync(entryPath, generateEntryModule(scanAppShell(root)));\n\n // Return with tags to inject the entry (runtime config is fetched by the client)\n return {\n html: modifiedHtml,\n tags: [\n {\n tag: \"script\",\n attrs: {\n type: \"module\",\n src: \"/node_modules/.heliumts/entry.tsx\",\n },\n injectTo: \"body\",\n },\n ],\n };\n },\n },\n async config(config, env) {\n // configResolved runs after this hook; honor an explicit Vite root now.\n root = path.resolve(config.root || process.cwd());\n const mode = env.mode;\n const envVars = loadEnvFiles({ root, mode });\n\n // Inject env vars into process.env so server-side code can access them\n // consistently in both development and production.\n injectEnvToProcess(envVars);\n\n // Load helium config to get client-side RPC transport settings\n const heliumConfig = await loadConfig(root);\n const rpcClientConfig = getRpcClientConfig(heliumConfig);\n\n // Provide default index.html if none exists\n return {\n appType: config.appType ?? \"spa\",\n optimizeDeps: {\n include: [\"react-dom/client\"],\n // Exclude helium from pre-bundling since it's the framework itself\n // This ensures changes to helium are picked up immediately\n exclude: [\"heliumts\", \"heliumts/client\", \"heliumts/server\", \"heliumts/vite\"],\n },\n // SSR configuration to properly isolate server-only code\n ssr: {\n // Externalize Node.js built-in modules - these should never be bundled\n external: [\"util\", \"zlib\", \"http\", \"https\", \"http2\", \"fs\", \"path\", \"crypto\", \"stream\", \"os\", \"url\", \"net\", \"tls\", \"child_process\", \"worker_threads\"],\n // Don't externalize heliumts - let the plugin handle the client/server split\n noExternal: [\"heliumts\"],\n },\n // Ensure Node.js built-ins are not bundled for client\n build: {\n rollupOptions: {\n external: [\n // Node.js built-in modules should never be in client bundle\n /^node:/,\n \"util\",\n \"zlib\",\n \"http\",\n \"https\",\n \"http2\",\n \"fs\",\n \"path\",\n \"crypto\",\n \"stream\",\n \"os\",\n \"url\",\n \"net\",\n \"tls\",\n \"child_process\",\n \"worker_threads\",\n ],\n },\n },\n define: {\n __HELIUM_DEV__: JSON.stringify(env.command === \"serve\"),\n __HELIUM_RPC_TRANSPORT__: JSON.stringify(rpcClientConfig.transport),\n __HELIUM_RPC_AUTO_HTTP_ON_MOBILE__: JSON.stringify(rpcClientConfig.autoHttpOnMobile),\n __HELIUM_RPC_TOKEN_VALIDITY_MS__: JSON.stringify(rpcClientConfig.tokenValidityMs),\n __HELIUM_RPC_MAX_BATCH_SIZE__: JSON.stringify(getRpcConfig(heliumConfig).maxBatchSize),\n },\n };\n },\n resolveId(id, importer, options) {\n if (options?.ssr && id === \"heliumts/client\") {\n return RESOLVED_VIRTUAL_SSR_CLIENT_MODULE_ID;\n }\n if (options?.ssr && id === \"heliumts/client/transitions\") {\n return RESOLVED_VIRTUAL_SSR_TRANSITIONS_MODULE_ID;\n }\n if (options?.ssr && id === \"heliumts/client/prefetch\") {\n return RESOLVED_VIRTUAL_SSR_PREFETCH_MODULE_ID;\n }\n if (id === VIRTUAL_CLIENT_MODULE_ID) {\n if (importer === RESOLVED_VIRTUAL_SSR_SERVER_MODULE_ID || isServerModule(importer, root, serverDir) || /\\.server\\.[cm]?[jt]sx?(?:\\?|$)/.test(importer || \"\")) {\n return null;\n }\n return options?.ssr ? RESOLVED_VIRTUAL_SSR_SERVER_MODULE_ID : RESOLVED_VIRTUAL_CLIENT_MODULE_ID;\n }\n if (id === VIRTUAL_SERVER_MANIFEST_ID) {\n return RESOLVED_VIRTUAL_SERVER_MANIFEST_ID;\n }\n if (id === VIRTUAL_ENTRY_MODULE_ID) {\n // Add .tsx extension so Vite knows it contains JSX\n return RESOLVED_VIRTUAL_ENTRY_MODULE_ID + \".tsx\";\n }\n return null;\n },\n transform(code, id, options) {\n if (!options?.ssr && isServerModule(id, root, serverDir)) {\n throw new Error(`Server-only module cannot be imported by client code: ${id}. Import RPC method stubs from 'heliumts/server' instead.`);\n }\n // Prevent .server.ts/.server.js sidecar files from being bundled in client code.\n // These files contain server-only logic (e.g. DB queries) and must never run in the browser.\n if (!options?.ssr && /\\.server\\.(ts|js|tsx|jsx|mts|mjs)$/.test(id.split(\"?\")[0])) {\n return { code: \"export default null;\", map: null };\n }\n },\n load(id) {\n if (id === RESOLVED_VIRTUAL_SSR_SERVER_MODULE_ID) {\n const { methods } = scanServerExports(root);\n return `export * from 'heliumts/server';\\n${generateClientModule(methods)}`;\n }\n if (id === RESOLVED_VIRTUAL_SSR_CLIENT_MODULE_ID) {\n return generateSSRClientStubModule();\n }\n if (id === RESOLVED_VIRTUAL_SSR_TRANSITIONS_MODULE_ID) {\n return generateSSRTransitionsStubModule();\n }\n if (id === RESOLVED_VIRTUAL_SSR_PREFETCH_MODULE_ID) {\n return generateSSRPrefetchStubModule();\n }\n if (id === RESOLVED_VIRTUAL_CLIENT_MODULE_ID) {\n const { methods } = scanServerExports(root);\n return generateClientModule(methods);\n }\n if (id === RESOLVED_VIRTUAL_SERVER_MANIFEST_ID) {\n const { methods, httpHandlers, seoMetadata, middleware, workers } = scanServerExports(root);\n const pageRoutePatterns = scanPageRoutePatterns(root);\n const ssrPages = scanSSRPages(root);\n const appShell = scanAppShell(root);\n return generateServerManifest(methods, httpHandlers, seoMetadata, pageRoutePatterns, ssrPages, appShell, middleware, workers);\n }\n if (id === RESOLVED_VIRTUAL_ENTRY_MODULE_ID + \".tsx\") {\n return generateEntryModule(scanAppShell(root));\n }\n },\n buildStart() {\n const { methods } = scanServerExports(root);\n const dts = generateTypeDefinitions(methods, root);\n const typesDir = path.join(root, \"src\", \"types\");\n const dtsPath = path.join(typesDir, \"heliumts-server.d.ts\");\n\n // Ensure src/types exists\n if (!fs.existsSync(typesDir)) {\n fs.mkdirSync(typesDir, { recursive: true });\n }\n\n // At build start we always allow writing the canonical set.\n // Only skip if content is identical to avoid needless TS invalidation.\n if (!fs.existsSync(dtsPath) || fs.readFileSync(dtsPath, \"utf-8\") !== dts) {\n fs.writeFileSync(dtsPath, dts);\n touchTsConfig(root);\n }\n\n // Check for route collisions in pages directory\n checkRouteCollisions(root);\n },\n configureServer(server) {\n // Vite's SPA fallback runs after static/public assets and preserves request URLs.\n /**\n * Write type definitions only if content has changed.\n * This prevents unnecessary TypeScript recompilation.\n *\n * When `allowFewer` is false (default) the file will NOT be\n * overwritten if the new content has fewer method declarations\n * than the existing file — this guards against writing a\n * degraded .d.ts while the user's file is only partially saved.\n */\n const writeTypesIfChanged = (dts: string, allowFewer = false): boolean => {\n const typesDir = path.join(root, \"src\", \"types\");\n const dtsPath = path.join(typesDir, \"heliumts-server.d.ts\");\n\n if (!fs.existsSync(typesDir)) {\n fs.mkdirSync(typesDir, { recursive: true });\n }\n\n // Check if file exists and content is the same\n if (fs.existsSync(dtsPath)) {\n const existing = fs.readFileSync(dtsPath, \"utf-8\");\n if (existing === dts) {\n return false; // No change needed\n }\n\n // Guard: don't overwrite with fewer methods unless explicitly allowed\n // (e.g. on unlink). This prevents losing types during partial saves.\n if (!allowFewer) {\n const countExports = (s: string) => (s.match(/export const \\w+:/g) || []).length;\n const existingCount = countExports(existing);\n const newCount = countExports(dts);\n if (newCount < existingCount) {\n log(\"info\", `Skipping type generation: found ${newCount} methods, existing has ${existingCount} (likely partial save)`);\n return false;\n }\n }\n }\n\n fs.writeFileSync(dtsPath, dts);\n\n // Touch tsconfig.json to force the TypeScript language server\n // to reload the project. Without this, TS may cache stale\n // module augmentations and autocomplete won't reflect the\n // new methods until a manual restart.\n touchTsConfig(root);\n\n return true; // File was written\n };\n\n const regenerateTypes = (allowFewer = false): boolean => {\n try {\n const { methods } = scanServerExports(root);\n const dts = generateTypeDefinitions(methods, root);\n return writeTypesIfChanged(dts, allowFewer);\n } catch (e) {\n log(\"error\", \"Failed to regenerate types\", e);\n return false;\n }\n };\n\n // Debounce timer for file changes\n let debounceTimer: ReturnType<typeof setTimeout> | null = null;\n const DEBOUNCE_DELAY = 300; // ms — long enough for format-on-save to finish\n\n const handleServerFileChange = async (allowFewer = false) => {\n // Regenerate type definitions\n regenerateTypes(allowFewer);\n\n // Invalidate the virtual modules so they get regenerated\n const clientModule = server.environments.client?.moduleGraph.getModuleById(RESOLVED_VIRTUAL_CLIENT_MODULE_ID);\n const serverModule = server.environments.ssr?.moduleGraph.getModuleById(RESOLVED_VIRTUAL_SERVER_MANIFEST_ID);\n const ssrRpcModule = server.environments.ssr?.moduleGraph.getModuleById(RESOLVED_VIRTUAL_SSR_SERVER_MODULE_ID);\n\n if (clientModule) {\n server.environments.client?.moduleGraph.invalidateModule(clientModule);\n }\n if (serverModule) {\n server.environments.ssr?.moduleGraph.invalidateModule(serverModule);\n }\n\n if (ssrRpcModule) {\n server.environments.ssr?.moduleGraph.invalidateModule(ssrRpcModule);\n }\n\n // Reload the server manifest and re-register methods\n try {\n // Clear config cache to ensure fresh config is loaded\n clearConfigCache();\n const config = await loadConfig(root);\n const mod = await server.ssrLoadModule(VIRTUAL_SERVER_MANIFEST_ID);\n const registerAll = mod.registerAll;\n const httpHandlers = mod.httpHandlers || [];\n const seoMetadataHandlers = mod.seoMetadataHandlers || [];\n const pageRoutePatterns = mod.pageRoutePatterns || [];\n const middlewareHandler = mod.middlewareHandler || null;\n const workers = mod.workers || [];\n const ssrPages = mod.ssrPages || [];\n const appShell = mod.appShell || null;\n\n // Update the dev server registry with new methods and HTTP handlers\n if (server.httpServer) {\n attachToDevServer(\n server.httpServer,\n (registry, httpRouter, seoRouter) => {\n registerAll(registry);\n httpRouter.registerRoutes(httpHandlers);\n seoRouter.registerRoutes(seoMetadataHandlers);\n seoRouter.setPageRoutePatterns(pageRoutePatterns);\n if (middlewareHandler) {\n registry.setMiddleware(middlewareHandler);\n httpRouter.setMiddleware(middlewareHandler);\n }\n },\n config,\n workers,\n ssrPages,\n appShell\n );\n }\n } catch (e) {\n log(\"error\", \"Failed to reload Helium server manifest\", e);\n }\n\n // Trigger HMR for any client code that imports heliumts/server\n server.ws.send({\n type: \"full-reload\",\n path: \"*\",\n });\n };\n\n // Watch server and page directories: new SSR pages and sidecars change the manifest too.\n server.watcher.add([path.join(root, serverDir), path.join(root, \"src\", \"pages\")]);\n\n // Watch config files for changes\n const configFiles = [\"helium.config.ts\", \"helium.config.js\", \"helium.config.mjs\"];\n for (const configFile of configFiles) {\n const configPath = path.join(root, configFile);\n if (fs.existsSync(configPath)) {\n server.watcher.add(configPath);\n }\n }\n\n /**\n * Debounced handler for server file changes.\n * This prevents multiple rapid regenerations during file saves.\n * @param allowFewer - pass true when files are deleted, so the\n * method count is allowed to decrease.\n */\n let pendingAllowFewer = false;\n const debouncedHandleServerFileChange = (allowFewer = false) => {\n // If any event in the batch is an unlink, honour it\n if (allowFewer) {\n pendingAllowFewer = true;\n }\n if (debounceTimer) {\n clearTimeout(debounceTimer);\n }\n debounceTimer = setTimeout(() => {\n debounceTimer = null;\n const shouldAllowFewer = pendingAllowFewer;\n pendingAllowFewer = false;\n handleServerFileChange(shouldAllowFewer);\n }, DEBOUNCE_DELAY);\n };\n\n const affectsManifest = (file: string): boolean => {\n const normalized = normalizeToPosix(path.relative(root, file));\n return (\n normalized.startsWith(`${serverDir}/`) || normalized.startsWith(\"src/pages/\") || /^src\\/[Aa]pp\\.[jt]sx?$/.test(normalized) || configFiles.includes(normalized)\n );\n };\n\n server.watcher.on(\"change\", (file) => {\n if (affectsManifest(file)) {\n debouncedHandleServerFileChange(true);\n }\n });\n\n server.watcher.on(\"add\", (file) => {\n if (affectsManifest(file)) {\n debouncedHandleServerFileChange();\n }\n });\n\n server.watcher.on(\"unlink\", (file) => {\n if (affectsManifest(file)) {\n debouncedHandleServerFileChange(true);\n }\n });\n\n server.httpServer?.once(\"close\", () => {\n if (debounceTimer) {\n clearTimeout(debounceTimer);\n }\n });\n\n // We hook into the server start to attach our RPC server\n server.httpServer?.on(\"listening\", async () => {\n try {\n // Load config\n const config = await loadConfig(root);\n\n // Load the manifest using Vite's SSR loader\n // This allows us to load TS files directly and handle dependencies\n const mod = await server.ssrLoadModule(VIRTUAL_SERVER_MANIFEST_ID);\n const registerAll = mod.registerAll;\n const httpHandlers = mod.httpHandlers || [];\n const seoMetadataHandlers = mod.seoMetadataHandlers || [];\n const pageRoutePatterns = mod.pageRoutePatterns || [];\n const middlewareHandler = mod.middlewareHandler || null;\n const workers = mod.workers || [];\n const ssrPages = mod.ssrPages || [];\n const appShell = mod.appShell || null;\n\n if (server.httpServer) {\n attachToDevServer(\n server.httpServer,\n (registry, httpRouter, seoRouter) => {\n registerAll(registry);\n httpRouter.registerRoutes(httpHandlers);\n seoRouter.registerRoutes(seoMetadataHandlers);\n seoRouter.setPageRoutePatterns(pageRoutePatterns);\n if (middlewareHandler) {\n registry.setMiddleware(middlewareHandler);\n httpRouter.setMiddleware(middlewareHandler);\n }\n },\n config,\n workers,\n ssrPages,\n appShell\n );\n }\n } catch (e) {\n log(\"error\", \"Failed to attach Helium RPC server\", e);\n }\n });\n },\n };\n}\n\nfunction generateSSRClientStubModule(): string {\n return `\nimport React from 'react';\n\nexport const RouterContext = React.createContext(null);\n\nfunction getSSRRouterSnapshot() {\n const snapshot = globalThis.__HELIUM_SSR_ROUTER__;\n if (!snapshot || typeof snapshot !== 'object') {\n return {\n path: '/',\n params: {},\n search: '',\n };\n }\n\n return {\n path: typeof snapshot.path === 'string' ? snapshot.path : '/',\n params: snapshot.params && typeof snapshot.params === 'object' ? snapshot.params : {},\n search: typeof snapshot.search === 'string' ? snapshot.search : '',\n };\n}\n\nexport function useRouter() {\n const snapshot = getSSRRouterSnapshot();\n return {\n path: snapshot.path,\n params: snapshot.params,\n searchParams: new URLSearchParams(snapshot.search),\n push: () => {},\n replace: () => {},\n on: () => () => {},\n status: 200,\n isNavigating: false,\n isPending: false,\n };\n}\n\nexport function Link(props) {\n const { href = '#', children, prefetch, ...rest } = props || {};\n return React.createElement('a', { href, ...rest }, children);\n}\n\nexport function Redirect() {\n return null;\n}\n\nexport function AppRouter() {\n return null;\n}\n\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() {\n return {\n call: async () => null,\n isCalling: false,\n error: null,\n };\n}\n\nexport function useFetch() {\n return {\n data: null,\n isLoading: false,\n error: null,\n refetch: async () => undefined,\n };\n}\n\nexport class RpcError extends Error {}\n\nexport function getPublicEnv() {\n return Object.fromEntries(Object.entries(process.env).filter(([key, value]) => key.startsWith('HELIUM_PUBLIC_') && typeof value === 'string'));\n}\n\nexport function getPublicEnvValue(key) {\n return getPublicEnv()[key];\n}\n\nexport function isDevEnvironment() {\n return false;\n}\n\nexport function getRpcTransport() {\n return 'websocket';\n}\n\nexport function isAutoHttpOnMobileEnabled() {\n return false;\n}\n\nexport function preconnect() {}\n\nexport function isSSR() {\n return true;\n}\n`;\n}\n\nfunction generateSSRTransitionsStubModule(): string {\n return `\nimport React from 'react';\nimport { useRouter } from 'heliumts/client';\n\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\nfunction generateSSRPrefetchStubModule(): string {\n return `\nexport function prefetchRoute() {}\nexport function clearPrefetchCache() {}\n`;\n}\n\n/**\n * Convert file path to POSIX format\n * @internal Exported for testing\n */\nexport function normalizeToPosix(filePath: string): string {\n return filePath.split(path.sep).join(\"/\");\n}\n\n/**\n * Check if an importer is a server module\n * @internal Exported for testing\n */\nexport function isServerModule(importer: string | undefined, root: string, serverDir: string): boolean {\n if (!importer || importer.startsWith(\"\\0\")) {\n return false;\n }\n\n const [importerPath] = importer.split(\"?\");\n if (!importerPath) {\n return false;\n }\n\n const relative = path.relative(root, importerPath);\n if (!relative || relative.startsWith(\"..\")) {\n return false;\n }\n\n const normalized = normalizeToPosix(relative);\n return normalized === serverDir || normalized.startsWith(`${serverDir}/`);\n}\n\n/**\n * Touch the project's tsconfig.json to force the TypeScript language server\n * to reload the project and pick up changed module augmentations.\n *\n * TS language server watches tsconfig.json for changes. When a `.d.ts` file\n * with `declare module` augmentations is regenerated, TS doesn't always\n * detect the new content — leading to stale autocomplete. By updating\n * tsconfig.json's mtime we trigger a full project reload.\n *\n * The file content is NOT modified; only the filesystem timestamp changes.\n *\n * @internal Exported for testing\n */\nexport function touchTsConfig(root: string): void {\n const tsconfigPath = path.join(root, \"tsconfig.json\");\n try {\n if (fs.existsSync(tsconfigPath)) {\n const now = new Date();\n fs.utimesSync(tsconfigPath, now, now);\n }\n } catch {\n // Non-critical: if we can't touch the file, TS may just need a manual reload\n }\n}\n"]}
|
package/dist/vite/ssg.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssg.d.ts","sourceRoot":"","sources":["../../src/vite/ssg.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AAEH,UAAU,OAAO;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,UAAU,aAAa;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAkB3D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAoC/D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,CAwDpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CA2B9D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ3D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAoB/E;AAwBD;;GAEG;AACH,wBAA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;AAwBD;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,GAAE,MAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAkFnJ;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,iBAqT1G"}
|
package/dist/vite/ssg.js
CHANGED
|
@@ -354,6 +354,10 @@ export function Redirect({ to, replace }) {
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
// Mock useCall hook
|
|
357
|
+
export async function callMethod() {
|
|
358
|
+
throw new Error('callMethod is only available in the browser. Load server data with getServerSideProps instead.');
|
|
359
|
+
}
|
|
360
|
+
|
|
357
361
|
export function useCall(serverFn) {
|
|
358
362
|
return { call: async () => null, isCalling: false, error: null };
|
|
359
363
|
}
|
package/dist/vite/ssg.js.map
CHANGED
|
@@ -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,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,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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 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"]}
|
|
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;;;;G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C/B,EAAE,CAAC,UAAU,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;YAC/C,CAAC;YAED,gDAAgD;YAChD,MAAM,cAAc,GAAG,uBAAuB,CAAC,YAAY,EAAE,EAAE,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;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"]}
|