heliumts 0.9.1 → 0.9.2
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/dist/bin/helium.js
CHANGED
|
@@ -223,6 +223,14 @@ export function useFetch() {
|
|
|
223
223
|
|
|
224
224
|
export class RpcError extends Error {}
|
|
225
225
|
|
|
226
|
+
export function getPublicEnv() {
|
|
227
|
+
return {};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export function getPublicEnvValue() {
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
|
|
226
234
|
export function getRpcTransport() {
|
|
227
235
|
return 'websocket';
|
|
228
236
|
}
|
package/dist/bin/helium.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helium.js","sourceRoot":"","sources":["../../src/bin/helium.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1G,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEvH,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAE3B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G,CAAC,IAAI,EAAE,CAAC;AACX,GAAG,CAAC,KAAK,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { cac } from \"cac\";\nimport { spawn } from \"child_process\";\nimport { build as esbuild } from \"esbuild\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { build as viteBuild } from \"vite\";\n\nimport { log } from \"../utils/logger.js\";\nimport { scanAppShell, scanPageRoutePatterns, scanServerExports, scanSSRPages } from \"../vite/scanner.js\";\nimport { generateStaticPages } from \"../vite/ssg.js\";\nimport { generateClientModule, generateServerManifest, generateTypeDefinitions } from \"../vite/virtualServerModule.js\";\n\nconst cli = cac(\"helium\");\nconst root = process.cwd();\n\ncli.command(\"dev\", \"Start development server\").action(async () => {\n const vite = spawn(\"vite\", [], { stdio: \"inherit\", shell: true });\n vite.on(\"close\", (code) => {\n process.exit(code || 0);\n });\n});\n\ncli.command(\"build\", \"Build for production\").action(async () => {\n // Generate type definitions before building so TypeScript can resolve\n // server method types even if the dev server was never started.\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 if (!fs.existsSync(typesDir)) {\n fs.mkdirSync(typesDir, { recursive: true });\n }\n\n if (!fs.existsSync(dtsPath) || fs.readFileSync(dtsPath, \"utf-8\") !== dts) {\n fs.writeFileSync(dtsPath, dts);\n log(\"info\", `Generated type definitions for ${methods.length} method(s)`);\n }\n\n log(\"info\", \"--------------------------------\");\n log(\"info\", \"Building client...\");\n\n try {\n const result = await viteBuild({\n root,\n logLevel: \"silent\",\n build: {\n outDir: \"dist\",\n },\n });\n\n // Display build output\n if (result && \"output\" in result) {\n const outputs = result.output;\n const zlib = await import(\"zlib\");\n\n for (const chunk of outputs) {\n if (chunk.type === \"asset\" || chunk.type === \"chunk\") {\n const fileName = chunk.fileName;\n const content = \"code\" in chunk ? chunk.code : chunk.source;\n const size = Buffer.byteLength(content, \"utf-8\");\n const sizeKB = (size / 1024).toFixed(2);\n\n // Calculate gzipped size\n const gzipped = zlib.gzipSync(content);\n const gzipSizeKB = (gzipped.length / 1024).toFixed(2);\n\n log(\"info\", ` ${fileName.padEnd(35)} ${sizeKB.padStart(8)} kB │ gzip: ${gzipSizeKB.padStart(7)} kB`);\n }\n }\n }\n\n log(\"info\", \"Client build complete.\");\n\n // Generate static pages for SSG\n log(\"info\", \"--------------------------------\");\n try {\n // Read the generated index.html as a template for SSG\n const distDir = path.join(root, \"dist\");\n const htmlPath = path.join(distDir, \"index.html\");\n\n if (fs.existsSync(htmlPath)) {\n let htmlTemplate = fs.readFileSync(htmlPath, \"utf-8\");\n\n // Clean up the template for SSG:\n // 1. Remove the build-time HELIUM_CONNECTION_TOKEN (SSG pages don't need it)\n htmlTemplate = htmlTemplate.replace(/<script>window\\.HELIUM_CONNECTION_TOKEN = \"build-time-placeholder\";<\\/script>/g, \"\");\n\n // 2. Clear any existing content in root div from SPA build\n htmlTemplate = htmlTemplate.replace(/<div\\s+id=\"root\"[^>]*>.*?<\\/div>/s, '<div id=\"root\"></div>');\n\n await generateStaticPages(null, root, htmlTemplate, distDir);\n } else {\n log(\"warn\", \"index.html not found in dist, skipping SSG\");\n }\n } catch (e) {\n log(\"warn\", \"SSG generation failed:\", e);\n // Don't fail the build if SSG fails\n }\n log(\"info\", \"--------------------------------\");\n } catch (e) {\n log(\"error\", \"Client build failed:\", e);\n process.exit(1);\n }\n\n log(\"info\", \"Building server...\");\n // Generate server entry\n const serverExports = scanServerExports(root);\n const pageRoutePatterns = scanPageRoutePatterns(root);\n const ssrPages = scanSSRPages(root);\n const appShell = scanAppShell(root);\n const manifestCode = generateServerManifest(\n serverExports.methods,\n serverExports.httpHandlers,\n serverExports.seoMetadata,\n pageRoutePatterns,\n ssrPages,\n appShell,\n serverExports.middleware,\n serverExports.workers\n );\n\n // Create the main server module that will be imported after env is loaded\n const serverModuleCode = `\nimport { startProdServer, loadConfig } from 'heliumts/server';\n${manifestCode}\n\nexport async function start() {\n const config = await loadConfig();\n\n startProdServer({\n config,\n registerHandlers: (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 ssrPages,\n appShell,\n workers\n });\n}\n`;\n\n // Create the entry loader that loads env first, then imports the server module\n const entryCode = `\n// Load environment variables FIRST, before any other imports\nimport './env-loader.js';\n// Now import and start the server (this ensures handlers load after env)\nimport { start } from './server-module.js';\nawait start();\n`;\n\n const envLoaderCode = `\nimport { loadEnvFiles, injectEnvToProcess, log } from 'heliumts/server';\nconst envRoot = process.cwd();\nlog('info', \\`Loading .env files from: \\${envRoot}\\`);\nconst envVars = loadEnvFiles({ mode: 'production' });\ninjectEnvToProcess(envVars);\nif (Object.keys(envVars).length > 0) {\n log('info', \\`Loaded \\${Object.keys(envVars).length} environment variable(s) from .env files\\`);\n} else {\n log('info', 'No .env files found (using platform environment variables if available)');\n}\n`;\n\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, \"server-entry.ts\");\n const envLoaderPath = path.join(heliumDir, \"env-loader.ts\");\n const serverModuleSrcPath = path.join(heliumDir, \"server-module.ts\");\n const ssrClientStubPath = path.join(heliumDir, \"ssr-client-stub.ts\");\n const ssrTransitionsStubPath = path.join(heliumDir, \"ssr-transitions-stub.ts\");\n const ssrPrefetchStubPath = path.join(heliumDir, \"ssr-prefetch-stub.ts\");\n\n const ssrClientStubCode = `\nimport React from 'react';\n\nexport const RouterContext = React.createContext(null);\n\nfunction getSSRRouterSnapshot() {\n const snapshot = globalThis.__HELIUM_SSR_ROUTER__ as\n | { path?: string; params?: Record<string, string | string[]>; search?: string }\n | undefined;\n\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: { href?: string; children?: React.ReactNode } & Record<string, unknown>) {\n const { href = '#', children, ...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 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 const ssrTransitionsStubCode = `\nimport React from 'react';\n\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 }: { children?: React.ReactNode }) {\n return React.createElement(React.Fragment, null, children);\n}\n`;\n\n const ssrPrefetchStubCode = `\nexport function prefetchRoute() {}\nexport function clearPrefetchCache() {}\n`;\n\n fs.writeFileSync(entryPath, entryCode);\n fs.writeFileSync(envLoaderPath, envLoaderCode);\n fs.writeFileSync(serverModuleSrcPath, serverModuleCode);\n // Generate a client-side stub for heliumts/server that provides method stubs\n // (e.g. { __id: 'subscribeWaitlist' }) so client components that import\n // user-defined methods from 'heliumts/server' resolve correctly during\n // the esbuild server bundle (mirroring the Vite plugin's virtual module).\n const rpcClientStubPath = path.join(heliumDir, \"rpc-client-stub.ts\");\n const rpcClientStubCode = generateClientModule(serverExports.methods);\n fs.writeFileSync(rpcClientStubPath, rpcClientStubCode);\n\n fs.writeFileSync(ssrClientStubPath, ssrClientStubCode);\n fs.writeFileSync(ssrTransitionsStubPath, ssrTransitionsStubCode);\n fs.writeFileSync(ssrPrefetchStubPath, ssrPrefetchStubCode);\n\n // Bundle with esbuild\n try {\n await esbuild({\n entryPoints: [entryPath],\n outfile: path.join(root, \"dist\", \"server.js\"),\n bundle: true,\n platform: \"node\",\n format: \"esm\",\n jsx: \"automatic\",\n jsxImportSource: \"react\",\n plugins: [\n {\n name: \"helium-ssr-client-alias\",\n setup(build) {\n build.onResolve({ filter: /^heliumts\\/client$/ }, () => ({ path: ssrClientStubPath }));\n build.onResolve({ filter: /^heliumts\\/client\\/transitions$/ }, () => ({ path: ssrTransitionsStubPath }));\n build.onResolve({ filter: /^heliumts\\/client\\/prefetch$/ }, () => ({ path: ssrPrefetchStubPath }));\n // Intercept heliumts/server imports from client code\n // and redirect to the RPC stub module (method stubs).\n // Server-side files and generated server-module resolve normally.\n const serverDirAbs = path.join(root, \"src\", \"server\");\n build.onResolve({ filter: /^heliumts\\/server$/ }, (args) => {\n const importer = args.importer;\n // Allow the generated server-module and env-loader to\n // import the real heliumts/server framework exports.\n if (importer.startsWith(heliumDir) || importer.startsWith(serverDirAbs)) {\n return undefined; // let esbuild resolve normally\n }\n return { path: rpcClientStubPath };\n });\n },\n },\n ],\n external: [\n // External common database and heavy dependencies\n \"mongodb\",\n \"mongoose\",\n \"pg\",\n \"mysql\",\n \"mysql2\",\n \"sqlite3\",\n \"better-sqlite3\",\n \"redis\",\n // Node.js built-ins are automatically external, but let's be explicit\n \"crypto\",\n \"fs\",\n \"path\",\n \"http\",\n \"https\",\n \"stream\",\n \"zlib\",\n \"util\",\n ],\n target: \"node18\",\n metafile: true,\n banner: {\n js: \"import { createRequire } from 'module'; const require = createRequire(import.meta.url);\",\n },\n });\n\n // Display server build output\n const serverOutputPath = path.relative(root, path.join(root, \"dist\", \"server.js\"));\n const serverStats = fs.statSync(path.join(root, \"dist\", \"server.js\"));\n const serverSizeKB = (serverStats.size / 1024).toFixed(2);\n log(\"info\", ` ${serverOutputPath.padEnd(35)} ${serverSizeKB.padStart(8)} kB`);\n\n log(\"info\", \"Server build complete.\");\n\n // Transpile helium.config.ts to helium.config.js if it exists\n const configTsPath = path.join(root, \"helium.config.ts\");\n if (fs.existsSync(configTsPath)) {\n log(\"info\", \"Transpiling helium.config.ts...\");\n try {\n await esbuild({\n entryPoints: [configTsPath],\n outfile: path.join(root, \"dist\", \"helium.config.js\"),\n bundle: false,\n platform: \"node\",\n format: \"esm\",\n target: \"node18\",\n });\n log(\"info\", \"Config file transpiled to dist/helium.config.js\");\n } catch (e) {\n log(\"warn\", \"Failed to transpile config file:\", e);\n log(\"warn\", \"You may need to manually rename helium.config.ts to helium.config.js\");\n }\n } else {\n // Check if .js or .mjs config exists and copy it to dist\n const configJsPath = path.join(root, \"helium.config.js\");\n const configMjsPath = path.join(root, \"helium.config.mjs\");\n\n if (fs.existsSync(configJsPath)) {\n fs.copyFileSync(configJsPath, path.join(root, \"dist\", \"helium.config.js\"));\n log(\"info\", \"Copied helium.config.js to dist/\");\n } else if (fs.existsSync(configMjsPath)) {\n fs.copyFileSync(configMjsPath, path.join(root, \"dist\", \"helium.config.mjs\"));\n log(\"info\", \"Copied helium.config.mjs to dist/\");\n }\n }\n\n log(\"info\", \"--------------------------------\");\n log(\"info\", \"✓ Build finished successfully.\");\n log(\"info\", \"▶ Run 'helium start' to start the production server.\");\n\n // Exit cleanly after build completes\n process.exit(0);\n } catch (e) {\n log(\"error\", \"Server build failed:\", e);\n process.exit(1);\n }\n});\n\ncli.command(\"start\", \"Start production server\").action(async () => {\n const serverPath = path.join(root, \"dist\", \"server.js\");\n if (!fs.existsSync(serverPath)) {\n log(\"error\", 'Server build not found. Run \"helium build\" first.');\n process.exit(1);\n }\n\n // When running in production, look for config in dist directory first\n // This allows the transpiled config to be found\n const server = spawn(\"node\", [serverPath], {\n stdio: \"inherit\",\n shell: true,\n env: { ...process.env, HELIUM_CONFIG_DIR: path.join(root, \"dist\") },\n });\n server.on(\"close\", (code) => {\n process.exit(code || 0);\n });\n});\n\ncli.help();\ncli.parse();\n"]}
|
|
1
|
+
{"version":3,"file":"helium.js","sourceRoot":"","sources":["../../src/bin/helium.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1G,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEvH,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC1B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAE3B,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,0BAA0B,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;IAC7D,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE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C,CAAC,CAAC,CAAC;IACpB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,GAAG,CAAC,OAAO,EAAE,sBAAsB,EAAE,CAAC,CAAC,CAAC;QACxC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;IAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IACxD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7B,GAAG,CAAC,OAAO,EAAE,mDAAmD,CAAC,CAAC;QAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,sEAAsE;IACtE,gDAAgD;IAChD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE;QACvC,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,IAAI;QACX,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE;KACtE,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QACxB,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,IAAI,EAAE,CAAC;AACX,GAAG,CAAC,KAAK,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { cac } from \"cac\";\nimport { spawn } from \"child_process\";\nimport { build as esbuild } from \"esbuild\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { build as viteBuild } from \"vite\";\n\nimport { log } from \"../utils/logger.js\";\nimport { scanAppShell, scanPageRoutePatterns, scanServerExports, scanSSRPages } from \"../vite/scanner.js\";\nimport { generateStaticPages } from \"../vite/ssg.js\";\nimport { generateClientModule, generateServerManifest, generateTypeDefinitions } from \"../vite/virtualServerModule.js\";\n\nconst cli = cac(\"helium\");\nconst root = process.cwd();\n\ncli.command(\"dev\", \"Start development server\").action(async () => {\n const vite = spawn(\"vite\", [], { stdio: \"inherit\", shell: true });\n vite.on(\"close\", (code) => {\n process.exit(code || 0);\n });\n});\n\ncli.command(\"build\", \"Build for production\").action(async () => {\n // Generate type definitions before building so TypeScript can resolve\n // server method types even if the dev server was never started.\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 if (!fs.existsSync(typesDir)) {\n fs.mkdirSync(typesDir, { recursive: true });\n }\n\n if (!fs.existsSync(dtsPath) || fs.readFileSync(dtsPath, \"utf-8\") !== dts) {\n fs.writeFileSync(dtsPath, dts);\n log(\"info\", `Generated type definitions for ${methods.length} method(s)`);\n }\n\n log(\"info\", \"--------------------------------\");\n log(\"info\", \"Building client...\");\n\n try {\n const result = await viteBuild({\n root,\n logLevel: \"silent\",\n build: {\n outDir: \"dist\",\n },\n });\n\n // Display build output\n if (result && \"output\" in result) {\n const outputs = result.output;\n const zlib = await import(\"zlib\");\n\n for (const chunk of outputs) {\n if (chunk.type === \"asset\" || chunk.type === \"chunk\") {\n const fileName = chunk.fileName;\n const content = \"code\" in chunk ? chunk.code : chunk.source;\n const size = Buffer.byteLength(content, \"utf-8\");\n const sizeKB = (size / 1024).toFixed(2);\n\n // Calculate gzipped size\n const gzipped = zlib.gzipSync(content);\n const gzipSizeKB = (gzipped.length / 1024).toFixed(2);\n\n log(\"info\", ` ${fileName.padEnd(35)} ${sizeKB.padStart(8)} kB │ gzip: ${gzipSizeKB.padStart(7)} kB`);\n }\n }\n }\n\n log(\"info\", \"Client build complete.\");\n\n // Generate static pages for SSG\n log(\"info\", \"--------------------------------\");\n try {\n // Read the generated index.html as a template for SSG\n const distDir = path.join(root, \"dist\");\n const htmlPath = path.join(distDir, \"index.html\");\n\n if (fs.existsSync(htmlPath)) {\n let htmlTemplate = fs.readFileSync(htmlPath, \"utf-8\");\n\n // Clean up the template for SSG:\n // 1. Remove the build-time HELIUM_CONNECTION_TOKEN (SSG pages don't need it)\n htmlTemplate = htmlTemplate.replace(/<script>window\\.HELIUM_CONNECTION_TOKEN = \"build-time-placeholder\";<\\/script>/g, \"\");\n\n // 2. Clear any existing content in root div from SPA build\n htmlTemplate = htmlTemplate.replace(/<div\\s+id=\"root\"[^>]*>.*?<\\/div>/s, '<div id=\"root\"></div>');\n\n await generateStaticPages(null, root, htmlTemplate, distDir);\n } else {\n log(\"warn\", \"index.html not found in dist, skipping SSG\");\n }\n } catch (e) {\n log(\"warn\", \"SSG generation failed:\", e);\n // Don't fail the build if SSG fails\n }\n log(\"info\", \"--------------------------------\");\n } catch (e) {\n log(\"error\", \"Client build failed:\", e);\n process.exit(1);\n }\n\n log(\"info\", \"Building server...\");\n // Generate server entry\n const serverExports = scanServerExports(root);\n const pageRoutePatterns = scanPageRoutePatterns(root);\n const ssrPages = scanSSRPages(root);\n const appShell = scanAppShell(root);\n const manifestCode = generateServerManifest(\n serverExports.methods,\n serverExports.httpHandlers,\n serverExports.seoMetadata,\n pageRoutePatterns,\n ssrPages,\n appShell,\n serverExports.middleware,\n serverExports.workers\n );\n\n // Create the main server module that will be imported after env is loaded\n const serverModuleCode = `\nimport { startProdServer, loadConfig } from 'heliumts/server';\n${manifestCode}\n\nexport async function start() {\n const config = await loadConfig();\n\n startProdServer({\n config,\n registerHandlers: (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 ssrPages,\n appShell,\n workers\n });\n}\n`;\n\n // Create the entry loader that loads env first, then imports the server module\n const entryCode = `\n// Load environment variables FIRST, before any other imports\nimport './env-loader.js';\n// Now import and start the server (this ensures handlers load after env)\nimport { start } from './server-module.js';\nawait start();\n`;\n\n const envLoaderCode = `\nimport { loadEnvFiles, injectEnvToProcess, log } from 'heliumts/server';\nconst envRoot = process.cwd();\nlog('info', \\`Loading .env files from: \\${envRoot}\\`);\nconst envVars = loadEnvFiles({ mode: 'production' });\ninjectEnvToProcess(envVars);\nif (Object.keys(envVars).length > 0) {\n log('info', \\`Loaded \\${Object.keys(envVars).length} environment variable(s) from .env files\\`);\n} else {\n log('info', 'No .env files found (using platform environment variables if available)');\n}\n`;\n\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, \"server-entry.ts\");\n const envLoaderPath = path.join(heliumDir, \"env-loader.ts\");\n const serverModuleSrcPath = path.join(heliumDir, \"server-module.ts\");\n const ssrClientStubPath = path.join(heliumDir, \"ssr-client-stub.ts\");\n const ssrTransitionsStubPath = path.join(heliumDir, \"ssr-transitions-stub.ts\");\n const ssrPrefetchStubPath = path.join(heliumDir, \"ssr-prefetch-stub.ts\");\n\n const ssrClientStubCode = `\nimport React from 'react';\n\nexport const RouterContext = React.createContext(null);\n\nfunction getSSRRouterSnapshot() {\n const snapshot = globalThis.__HELIUM_SSR_ROUTER__ as\n | { path?: string; params?: Record<string, string | string[]>; search?: string }\n | undefined;\n\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: { href?: string; children?: React.ReactNode } & Record<string, unknown>) {\n const { href = '#', children, ...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 {};\n}\n\nexport function getPublicEnvValue() {\n return undefined;\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 const ssrTransitionsStubCode = `\nimport React from 'react';\n\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 }: { children?: React.ReactNode }) {\n return React.createElement(React.Fragment, null, children);\n}\n`;\n\n const ssrPrefetchStubCode = `\nexport function prefetchRoute() {}\nexport function clearPrefetchCache() {}\n`;\n\n fs.writeFileSync(entryPath, entryCode);\n fs.writeFileSync(envLoaderPath, envLoaderCode);\n fs.writeFileSync(serverModuleSrcPath, serverModuleCode);\n // Generate a client-side stub for heliumts/server that provides method stubs\n // (e.g. { __id: 'subscribeWaitlist' }) so client components that import\n // user-defined methods from 'heliumts/server' resolve correctly during\n // the esbuild server bundle (mirroring the Vite plugin's virtual module).\n const rpcClientStubPath = path.join(heliumDir, \"rpc-client-stub.ts\");\n const rpcClientStubCode = generateClientModule(serverExports.methods);\n fs.writeFileSync(rpcClientStubPath, rpcClientStubCode);\n\n fs.writeFileSync(ssrClientStubPath, ssrClientStubCode);\n fs.writeFileSync(ssrTransitionsStubPath, ssrTransitionsStubCode);\n fs.writeFileSync(ssrPrefetchStubPath, ssrPrefetchStubCode);\n\n // Bundle with esbuild\n try {\n await esbuild({\n entryPoints: [entryPath],\n outfile: path.join(root, \"dist\", \"server.js\"),\n bundle: true,\n platform: \"node\",\n format: \"esm\",\n jsx: \"automatic\",\n jsxImportSource: \"react\",\n plugins: [\n {\n name: \"helium-ssr-client-alias\",\n setup(build) {\n build.onResolve({ filter: /^heliumts\\/client$/ }, () => ({ path: ssrClientStubPath }));\n build.onResolve({ filter: /^heliumts\\/client\\/transitions$/ }, () => ({ path: ssrTransitionsStubPath }));\n build.onResolve({ filter: /^heliumts\\/client\\/prefetch$/ }, () => ({ path: ssrPrefetchStubPath }));\n // Intercept heliumts/server imports from client code\n // and redirect to the RPC stub module (method stubs).\n // Server-side files and generated server-module resolve normally.\n const serverDirAbs = path.join(root, \"src\", \"server\");\n build.onResolve({ filter: /^heliumts\\/server$/ }, (args) => {\n const importer = args.importer;\n // Allow the generated server-module and env-loader to\n // import the real heliumts/server framework exports.\n if (importer.startsWith(heliumDir) || importer.startsWith(serverDirAbs)) {\n return undefined; // let esbuild resolve normally\n }\n return { path: rpcClientStubPath };\n });\n },\n },\n ],\n external: [\n // External common database and heavy dependencies\n \"mongodb\",\n \"mongoose\",\n \"pg\",\n \"mysql\",\n \"mysql2\",\n \"sqlite3\",\n \"better-sqlite3\",\n \"redis\",\n // Node.js built-ins are automatically external, but let's be explicit\n \"crypto\",\n \"fs\",\n \"path\",\n \"http\",\n \"https\",\n \"stream\",\n \"zlib\",\n \"util\",\n ],\n target: \"node18\",\n metafile: true,\n banner: {\n js: \"import { createRequire } from 'module'; const require = createRequire(import.meta.url);\",\n },\n });\n\n // Display server build output\n const serverOutputPath = path.relative(root, path.join(root, \"dist\", \"server.js\"));\n const serverStats = fs.statSync(path.join(root, \"dist\", \"server.js\"));\n const serverSizeKB = (serverStats.size / 1024).toFixed(2);\n log(\"info\", ` ${serverOutputPath.padEnd(35)} ${serverSizeKB.padStart(8)} kB`);\n\n log(\"info\", \"Server build complete.\");\n\n // Transpile helium.config.ts to helium.config.js if it exists\n const configTsPath = path.join(root, \"helium.config.ts\");\n if (fs.existsSync(configTsPath)) {\n log(\"info\", \"Transpiling helium.config.ts...\");\n try {\n await esbuild({\n entryPoints: [configTsPath],\n outfile: path.join(root, \"dist\", \"helium.config.js\"),\n bundle: false,\n platform: \"node\",\n format: \"esm\",\n target: \"node18\",\n });\n log(\"info\", \"Config file transpiled to dist/helium.config.js\");\n } catch (e) {\n log(\"warn\", \"Failed to transpile config file:\", e);\n log(\"warn\", \"You may need to manually rename helium.config.ts to helium.config.js\");\n }\n } else {\n // Check if .js or .mjs config exists and copy it to dist\n const configJsPath = path.join(root, \"helium.config.js\");\n const configMjsPath = path.join(root, \"helium.config.mjs\");\n\n if (fs.existsSync(configJsPath)) {\n fs.copyFileSync(configJsPath, path.join(root, \"dist\", \"helium.config.js\"));\n log(\"info\", \"Copied helium.config.js to dist/\");\n } else if (fs.existsSync(configMjsPath)) {\n fs.copyFileSync(configMjsPath, path.join(root, \"dist\", \"helium.config.mjs\"));\n log(\"info\", \"Copied helium.config.mjs to dist/\");\n }\n }\n\n log(\"info\", \"--------------------------------\");\n log(\"info\", \"✓ Build finished successfully.\");\n log(\"info\", \"▶ Run 'helium start' to start the production server.\");\n\n // Exit cleanly after build completes\n process.exit(0);\n } catch (e) {\n log(\"error\", \"Server build failed:\", e);\n process.exit(1);\n }\n});\n\ncli.command(\"start\", \"Start production server\").action(async () => {\n const serverPath = path.join(root, \"dist\", \"server.js\");\n if (!fs.existsSync(serverPath)) {\n log(\"error\", 'Server build not found. Run \"helium build\" first.');\n process.exit(1);\n }\n\n // When running in production, look for config in dist directory first\n // This allows the transpiled config to be found\n const server = spawn(\"node\", [serverPath], {\n stdio: \"inherit\",\n shell: true,\n env: { ...process.env, HELIUM_CONFIG_DIR: path.join(root, \"dist\") },\n });\n server.on(\"close\", (code) => {\n process.exit(code || 0);\n });\n});\n\ncli.help();\ncli.parse();\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heliumPlugin.d.ts","sourceRoot":"","sources":["../../src/vite/heliumPlugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAkBnC,MAAM,CAAC,OAAO,UAAU,MAAM,IAAI,MAAM,CAgdvC;
|
|
1
|
+
{"version":3,"file":"heliumPlugin.d.ts","sourceRoot":"","sources":["../../src/vite/heliumPlugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAkBnC,MAAM,CAAC,OAAO,UAAU,MAAM,IAAI,MAAM,CAgdvC;AA2HD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAiBrG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAUhD"}
|
|
@@ -489,6 +489,14 @@ export function useFetch() {
|
|
|
489
489
|
|
|
490
490
|
export class RpcError extends Error {}
|
|
491
491
|
|
|
492
|
+
export function getPublicEnv() {
|
|
493
|
+
return {};
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export function getPublicEnvValue() {
|
|
497
|
+
return undefined;
|
|
498
|
+
}
|
|
499
|
+
|
|
492
500
|
export function getRpcTransport() {
|
|
493
501
|
return 'websocket';
|
|
494
502
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heliumPlugin.js","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tD,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, 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_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 (html.includes(\"src/main.tsx\") || html.includes(\"src/main.ts\")) {\n return html; // User has their own entry, don't modify\n }\n\n // Ensure root div exists\n let modifiedHtml = html;\n if (!modifiedHtml.includes('id=\"root\"')) {\n modifiedHtml = modifiedHtml.replace(\"<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());\n\n // Return with tags to inject the entry (runtime config is fetched by the client)\n return [\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 async config(config) {\n // Load environment variables before config is finalized\n const mode = config.mode || \"development\";\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: \"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(mode !== \"production\"),\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 },\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 (isServerModule(importer, root, serverDir)) {\n return null;\n }\n return 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 // Intercept heliumts/server imports from client code\n if (id === \"heliumts/server\") {\n // If imported from server code, let it resolve normally\n if (isServerModule(importer, root, serverDir)) {\n return null;\n }\n // For client code, redirect to virtual client module\n return RESOLVED_VIRTUAL_CLIENT_MODULE_ID;\n }\n return null;\n },\n transform(code, id, options) {\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)) {\n return { code: \"export default null;\", map: null };\n }\n },\n load(id) {\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();\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 // Add middleware to handle HTML fallback for nested routes\n // This ensures that routes like /docs/guides/auth properly serve index.html\n // so the client-side router can handle them\n server.middlewares.use((req, res, next) => {\n const url = req.url || \"\";\n const cleanUrl = url.split(\"?\")[0];\n\n // Skip if:\n // - Has file extension (asset request)\n // - Is an API/special endpoint\n // - Is a dev server endpoint\n if (\n path.extname(cleanUrl) !== \"\" ||\n cleanUrl.startsWith(\"/api\") ||\n cleanUrl.startsWith(\"/webhooks\") ||\n cleanUrl.startsWith(\"/auth\") ||\n cleanUrl.startsWith(\"/@\") ||\n cleanUrl.startsWith(\"/__helium__\")\n ) {\n return next();\n }\n\n // For all other routes (including nested paths like /docs/guides/auth),\n // rewrite to index.html so Vite serves it and the client-side router handles routing\n req.url = \"/index.html\";\n next();\n });\n\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\n if (clientModule) {\n server.environments.client?.moduleGraph.invalidateModule(clientModule);\n }\n if (serverModule) {\n server.environments.ssr?.moduleGraph.invalidateModule(serverModule);\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 directory for changes\n const serverPath = path.join(root, serverDir);\n server.watcher.add(serverPath);\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 server.watcher.on(\"change\", (file) => {\n const relative = path.relative(root, file);\n const normalized = normalizeToPosix(relative);\n\n // If a server file changed, regenerate everything\n if (normalized.startsWith(`${serverDir}/`)) {\n debouncedHandleServerFileChange();\n }\n\n // If config file changed, reload config and regenerate\n if (configFiles.some((cf) => normalized === cf)) {\n log(\"info\", `Config file changed: ${normalized}`);\n debouncedHandleServerFileChange();\n }\n });\n\n server.watcher.on(\"add\", (file) => {\n const relative = path.relative(root, file);\n const normalized = normalizeToPosix(relative);\n\n // If a server file was added, regenerate everything\n if (normalized.startsWith(`${serverDir}/`)) {\n debouncedHandleServerFileChange();\n }\n });\n\n server.watcher.on(\"unlink\", (file) => {\n const relative = path.relative(root, file);\n const normalized = normalizeToPosix(relative);\n\n // If a server file was removed, regenerate (allow fewer methods)\n if (normalized.startsWith(`${serverDir}/`)) {\n debouncedHandleServerFileChange(true);\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, ...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 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';\n\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 }) {\n return React.createElement(React.Fragment, null, 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,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACvF,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,EAAE,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1H,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEtI,MAAM,CAAC,OAAO,UAAU,MAAM;IAC1B,IAAI,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IACzB,MAAM,SAAS,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC/C,MAAM,qCAAqC,GAAG,uBAAuB,CAAC;IACtE,MAAM,0CAA0C,GAAG,4BAA4B,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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, 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_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 (html.includes(\"src/main.tsx\") || html.includes(\"src/main.ts\")) {\n return html; // User has their own entry, don't modify\n }\n\n // Ensure root div exists\n let modifiedHtml = html;\n if (!modifiedHtml.includes('id=\"root\"')) {\n modifiedHtml = modifiedHtml.replace(\"<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());\n\n // Return with tags to inject the entry (runtime config is fetched by the client)\n return [\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 async config(config) {\n // Load environment variables before config is finalized\n const mode = config.mode || \"development\";\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: \"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(mode !== \"production\"),\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 },\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 (isServerModule(importer, root, serverDir)) {\n return null;\n }\n return 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 // Intercept heliumts/server imports from client code\n if (id === \"heliumts/server\") {\n // If imported from server code, let it resolve normally\n if (isServerModule(importer, root, serverDir)) {\n return null;\n }\n // For client code, redirect to virtual client module\n return RESOLVED_VIRTUAL_CLIENT_MODULE_ID;\n }\n return null;\n },\n transform(code, id, options) {\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)) {\n return { code: \"export default null;\", map: null };\n }\n },\n load(id) {\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();\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 // Add middleware to handle HTML fallback for nested routes\n // This ensures that routes like /docs/guides/auth properly serve index.html\n // so the client-side router can handle them\n server.middlewares.use((req, res, next) => {\n const url = req.url || \"\";\n const cleanUrl = url.split(\"?\")[0];\n\n // Skip if:\n // - Has file extension (asset request)\n // - Is an API/special endpoint\n // - Is a dev server endpoint\n if (\n path.extname(cleanUrl) !== \"\" ||\n cleanUrl.startsWith(\"/api\") ||\n cleanUrl.startsWith(\"/webhooks\") ||\n cleanUrl.startsWith(\"/auth\") ||\n cleanUrl.startsWith(\"/@\") ||\n cleanUrl.startsWith(\"/__helium__\")\n ) {\n return next();\n }\n\n // For all other routes (including nested paths like /docs/guides/auth),\n // rewrite to index.html so Vite serves it and the client-side router handles routing\n req.url = \"/index.html\";\n next();\n });\n\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\n if (clientModule) {\n server.environments.client?.moduleGraph.invalidateModule(clientModule);\n }\n if (serverModule) {\n server.environments.ssr?.moduleGraph.invalidateModule(serverModule);\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 directory for changes\n const serverPath = path.join(root, serverDir);\n server.watcher.add(serverPath);\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 server.watcher.on(\"change\", (file) => {\n const relative = path.relative(root, file);\n const normalized = normalizeToPosix(relative);\n\n // If a server file changed, regenerate everything\n if (normalized.startsWith(`${serverDir}/`)) {\n debouncedHandleServerFileChange();\n }\n\n // If config file changed, reload config and regenerate\n if (configFiles.some((cf) => normalized === cf)) {\n log(\"info\", `Config file changed: ${normalized}`);\n debouncedHandleServerFileChange();\n }\n });\n\n server.watcher.on(\"add\", (file) => {\n const relative = path.relative(root, file);\n const normalized = normalizeToPosix(relative);\n\n // If a server file was added, regenerate everything\n if (normalized.startsWith(`${serverDir}/`)) {\n debouncedHandleServerFileChange();\n }\n });\n\n server.watcher.on(\"unlink\", (file) => {\n const relative = path.relative(root, file);\n const normalized = normalizeToPosix(relative);\n\n // If a server file was removed, regenerate (allow fewer methods)\n if (normalized.startsWith(`${serverDir}/`)) {\n debouncedHandleServerFileChange(true);\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, ...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 {};\n}\n\nexport function getPublicEnvValue() {\n return undefined;\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';\n\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 }) {\n return React.createElement(React.Fragment, null, 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"]}
|