eclipsa 0.1.5 → 0.1.6
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/package.json +2 -2
- package/vite/mod.mjs +15 -12
- package/vite/mod.mjs.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eclipsa",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"homepage": "https://github.com/pnsk-lab/eclipsa",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/pnsk-lab/eclipsa/issues"
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@eclipsa/optimizer": "^0.1.
|
|
66
|
+
"@eclipsa/optimizer": "^0.1.6",
|
|
67
67
|
"fast-glob": "^3.3.2",
|
|
68
68
|
"hono": "^4.6.4"
|
|
69
69
|
},
|
package/vite/mod.mjs
CHANGED
|
@@ -3169,19 +3169,22 @@ const createConfig = (options) => async (userConfig) => {
|
|
|
3169
3169
|
preserveEntrySignatures: "allow-extension"
|
|
3170
3170
|
}
|
|
3171
3171
|
} },
|
|
3172
|
-
ssr: {
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3172
|
+
ssr: {
|
|
3173
|
+
resolve: { noExternal: [/^eclipsa(?:\/|$)/] },
|
|
3174
|
+
build: {
|
|
3175
|
+
emptyOutDir: true,
|
|
3176
|
+
outDir: path.join(root, "dist/ssr"),
|
|
3177
|
+
rollupOptions: {
|
|
3178
|
+
input: ssrInput,
|
|
3179
|
+
output: {
|
|
3180
|
+
assetFileNames: "assets/[name]-[hash][extname]",
|
|
3181
|
+
chunkFileNames: "chunks/[name]-[hash].mjs",
|
|
3182
|
+
entryFileNames: "entries/[name].mjs"
|
|
3183
|
+
},
|
|
3184
|
+
preserveEntrySignatures: "allow-extension"
|
|
3185
|
+
}
|
|
3183
3186
|
}
|
|
3184
|
-
}
|
|
3187
|
+
}
|
|
3185
3188
|
},
|
|
3186
3189
|
builder: { async buildApp(builder) {
|
|
3187
3190
|
await build(builder, userConfig, options);
|
package/vite/mod.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.mjs","names":["path","fileExists","path","toIdsByFilePath","getRouteReachableEntryFiles","createRouteServerAccessEntries","path","fileExists","path"],"sources":["../../vite/utils/routing.ts","../../compiler/analyze/mod.ts","../../compiler/client/mod.ts","../../compiler/ssr/mod.ts","../../vite/compiler.ts","../../vite/dev-app/mod.ts","../../utils/node-connect.ts","../../utils/xxhash32.ts","../../vite/build/mod.ts","../../vite/nitro.ts","../../vite/config.ts","../../vite/options.ts","../../vite/mod.ts"],"sourcesContent":["import fg from 'fast-glob'\nimport * as fs from 'node:fs/promises'\nimport path from 'node:path'\nimport type {\n RouteManifest,\n RouteModuleManifest,\n RouteParams,\n RoutePathSegment,\n} from '../../core/router-shared.ts'\n\nexport const normalizeRoutePath = (pathname: string) => {\n const normalizedPath = pathname.trim() || '/'\n const withLeadingSlash = normalizedPath.startsWith('/') ? normalizedPath : `/${normalizedPath}`\n if (withLeadingSlash.length > 1 && withLeadingSlash.endsWith('/')) {\n return withLeadingSlash.slice(0, -1)\n }\n return withLeadingSlash\n}\n\nexport interface RouteEntry {\n error: RouteModuleEntry | null\n layouts: RouteModuleEntry[]\n loading: RouteModuleEntry | null\n middlewares: RouteModuleEntry[]\n notFound: RouteModuleEntry | null\n page: RouteModuleEntry | null\n renderMode?: 'dynamic' | 'static' | null\n routePath: string\n segments: RoutePathSegment[]\n server: RouteModuleEntry | null\n}\n\nexport interface RouteModuleEntry {\n entryName: string\n filePath: string\n}\n\ninterface RouteFileEntry extends RouteModuleEntry {\n breakoutTarget: string | null\n dir: string\n}\n\ninterface RouteDirectoryEntry {\n error: RouteFileEntry | null\n layout: RouteFileEntry | null\n loading: RouteFileEntry | null\n middleware: RouteFileEntry | null\n notFound: RouteFileEntry | null\n page: RouteFileEntry | null\n server: RouteFileEntry | null\n}\n\ninterface RouteMatch<T> {\n params: RouteParams\n route: T\n}\n\nconst createDirectoryEntry = (): RouteDirectoryEntry => ({\n error: null,\n layout: null,\n loading: null,\n middleware: null,\n notFound: null,\n page: null,\n server: null,\n})\n\nconst toEntryName = (relativePath: string) => {\n const normalized = relativePath.replaceAll('\\\\', '/')\n const withoutExt = normalized.replace(/\\.[^.]+$/, '')\n const segments = withoutExt.split('/')\n const fileName = segments.pop() ?? 'index'\n const prefix = fileName.startsWith('+layout')\n ? 'layout'\n : fileName.startsWith('+page')\n ? 'route'\n : fileName.startsWith('+server')\n ? 'server'\n : 'special'\n const mapped = segments\n .map((segment) => segment.replaceAll(/[^a-zA-Z0-9]+/g, '_') || 'index')\n .concat(fileName.replaceAll(/[^a-zA-Z0-9]+/g, '_') || 'index')\n\n return [prefix, ...mapped].join('__')\n}\n\nconst toRouteModuleEntry = (\n appDir: string,\n filePath: string,\n breakoutTarget: string | null,\n): RouteFileEntry => {\n const relativePath = path.relative(appDir, filePath).replaceAll('\\\\', '/')\n return {\n breakoutTarget,\n dir: normalizeRelativeDir(path.posix.dirname(relativePath)),\n entryName: toEntryName(relativePath),\n filePath,\n }\n}\n\nconst normalizeRelativeDir = (relativeDir: string) =>\n relativeDir === '.' || relativeDir === '' ? '' : relativeDir.replaceAll('\\\\', '/')\n\nconst splitRelativeDir = (relativeDir: string) => (relativeDir === '' ? [] : relativeDir.split('/'))\n\nconst ancestorDirs = (relativeDir: string) => {\n const segments = splitRelativeDir(relativeDir)\n return Array.from({ length: segments.length + 1 }, (_, index) =>\n normalizeRelativeDir(segments.slice(0, index).join('/')),\n )\n}\n\nconst getDirBaseName = (relativeDir: string) => {\n const segments = splitRelativeDir(relativeDir)\n return segments.length === 0 ? '' : segments[segments.length - 1]!\n}\n\nconst isGroupSegment = (segment: string) => /^\\(.+\\)$/.test(segment)\n\nconst toRouteSegment = (segment: string): RoutePathSegment | null => {\n if (isGroupSegment(segment)) {\n return null\n }\n const optionalMatch = /^\\[\\[([^\\]]+)\\]\\]$/.exec(segment)\n if (optionalMatch) {\n return {\n kind: 'optional',\n value: optionalMatch[1]!,\n }\n }\n const restMatch = /^\\[\\.\\.\\.([^\\]]+)\\]$/.exec(segment)\n if (restMatch) {\n return {\n kind: 'rest',\n value: restMatch[1]!,\n }\n }\n const requiredMatch = /^\\[([^\\]]+)\\]$/.exec(segment)\n if (requiredMatch) {\n return {\n kind: 'required',\n value: requiredMatch[1]!,\n }\n }\n return {\n kind: 'static',\n value: segment,\n }\n}\n\nconst toRouteSegments = (relativeDir: string) =>\n splitRelativeDir(relativeDir)\n .map((segment) => toRouteSegment(segment))\n .filter((segment): segment is RoutePathSegment => segment !== null)\n\nconst segmentsToRoutePath = (segments: RoutePathSegment[]) => {\n if (segments.length === 0) {\n return '/'\n }\n return normalizeRoutePath(\n segments\n .map((segment) => {\n switch (segment.kind) {\n case 'required':\n return `[${segment.value}]`\n case 'optional':\n return `[[${segment.value}]]`\n case 'rest':\n return `[...${segment.value}]`\n default:\n return segment.value\n }\n })\n .join('/'),\n )\n}\n\nconst resolveAncestorDirs = (relativeDir: string, breakoutTarget: string | null) => {\n const candidates = ancestorDirs(relativeDir)\n if (breakoutTarget === null) {\n return candidates\n }\n if (breakoutTarget === '') {\n return candidates.slice(0, 1)\n }\n for (let index = candidates.length - 1; index >= 0; index -= 1) {\n const baseName = getDirBaseName(candidates[index]!)\n if (baseName === breakoutTarget || baseName === `(${breakoutTarget})`) {\n return candidates.slice(0, index + 1)\n }\n }\n return candidates.slice(0, 1)\n}\n\nconst scoreSegment = (segment: RoutePathSegment | undefined) => {\n if (!segment) {\n return 0\n }\n switch (segment.kind) {\n case 'static':\n return 4\n case 'required':\n return 3\n case 'optional':\n return 2\n case 'rest':\n return 1\n }\n}\n\nconst compareRouteEntries = (left: RouteEntry, right: RouteEntry) => {\n const limit = Math.max(left.segments.length, right.segments.length)\n for (let index = 0; index < limit; index += 1) {\n const scoreDelta = scoreSegment(right.segments[index]) - scoreSegment(left.segments[index])\n if (scoreDelta !== 0) {\n return scoreDelta\n }\n }\n return right.segments.length - left.segments.length\n}\n\nconst matchSegments = (\n segments: RoutePathSegment[],\n pathnameSegments: string[],\n routeIndex = 0,\n pathIndex = 0,\n params: RouteParams = {},\n): RouteParams | null => {\n if (routeIndex >= segments.length) {\n return pathIndex >= pathnameSegments.length ? params : null\n }\n\n const segment = segments[routeIndex]!\n switch (segment.kind) {\n case 'static':\n if (pathnameSegments[pathIndex] !== segment.value) {\n return null\n }\n return matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex + 1, params)\n case 'required':\n if (pathIndex >= pathnameSegments.length) {\n return null\n }\n return matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex + 1, {\n ...params,\n [segment.value]: pathnameSegments[pathIndex],\n })\n case 'optional': {\n const consumed =\n pathIndex < pathnameSegments.length\n ? matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex + 1, {\n ...params,\n [segment.value]: pathnameSegments[pathIndex],\n })\n : null\n if (consumed) {\n return consumed\n }\n return matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex, {\n ...params,\n [segment.value]: undefined,\n })\n }\n case 'rest': {\n const rest = pathnameSegments.slice(pathIndex)\n if (rest.length === 0) {\n return null\n }\n return matchSegments(segments, pathnameSegments, segments.length, pathnameSegments.length, {\n ...params,\n [segment.value]: rest,\n })\n }\n }\n}\n\nconst toMatch = <T extends { segments: RoutePathSegment[] }>(\n route: T,\n pathname: string,\n): RouteMatch<T> | null => {\n const pathnameSegments = normalizeRoutePath(pathname).split('/').filter(Boolean)\n const params = matchSegments(route.segments, pathnameSegments)\n if (!params) {\n return null\n }\n return {\n params,\n route,\n }\n}\n\nconst selectNearestSpecial = (\n directories: Map<string, RouteDirectoryEntry>,\n candidateDirs: string[],\n kind: 'error' | 'loading' | 'notFound',\n) => {\n for (let index = candidateDirs.length - 1; index >= 0; index -= 1) {\n const entry = directories.get(candidateDirs[index]!)?.[kind]\n if (entry) {\n return entry\n }\n }\n return null\n}\n\nconst collectLayouts = (\n directories: Map<string, RouteDirectoryEntry>,\n relativeDir: string,\n breakoutTarget: string | null,\n) => {\n let layouts: RouteFileEntry[] = []\n for (const candidateDir of ancestorDirs(relativeDir)) {\n const layout = directories.get(candidateDir)?.layout\n if (!layout) {\n continue\n }\n if (layout.breakoutTarget !== null) {\n const allowedDirs = new Set(resolveAncestorDirs(candidateDir, layout.breakoutTarget))\n layouts = layouts.filter((entry) => allowedDirs.has(entry.dir))\n }\n layouts.push(layout)\n }\n\n if (breakoutTarget !== null) {\n const allowedDirs = new Set(resolveAncestorDirs(relativeDir, breakoutTarget))\n layouts = layouts.filter((entry) => allowedDirs.has(entry.dir))\n }\n\n return layouts.map(({ entryName, filePath }) => ({ entryName, filePath }))\n}\n\nconst collectMiddlewares = (\n directories: Map<string, RouteDirectoryEntry>,\n candidateDirs: string[],\n) =>\n candidateDirs.flatMap((candidateDir) => {\n const middleware = directories.get(candidateDir)?.middleware\n return middleware ? [{ entryName: middleware.entryName, filePath: middleware.filePath }] : []\n })\n\nconst parseAppFile = (appDir: string, filePath: string) => {\n const relativePath = path.relative(appDir, filePath).replaceAll('\\\\', '/')\n const fileName = path.posix.basename(relativePath)\n const dir = normalizeRelativeDir(path.posix.dirname(relativePath))\n\n const pageMatch = /^\\+page(?:@(.*))?\\.tsx$/.exec(fileName)\n if (pageMatch) {\n return {\n breakoutTarget: pageMatch[1] ?? null,\n dir,\n kind: 'page' as const,\n relativePath,\n }\n }\n\n const layoutMatch = /^\\+layout(?:@(.*))?\\.tsx$/.exec(fileName)\n if (layoutMatch) {\n return {\n breakoutTarget: layoutMatch[1] ?? null,\n dir,\n kind: 'layout' as const,\n relativePath,\n }\n }\n\n if (fileName === '+loading.tsx') {\n return { breakoutTarget: null, dir, kind: 'loading' as const, relativePath }\n }\n if (/^\\+middleware\\.(ts|tsx)$/.test(fileName)) {\n return { breakoutTarget: null, dir, kind: 'middleware' as const, relativePath }\n }\n if (fileName === '+error.tsx') {\n return { breakoutTarget: null, dir, kind: 'error' as const, relativePath }\n }\n if (fileName === '+not-found.tsx') {\n return { breakoutTarget: null, dir, kind: 'notFound' as const, relativePath }\n }\n if (/^\\+server\\.(ts|tsx)$/.test(fileName)) {\n return { breakoutTarget: null, dir, kind: 'server' as const, relativePath }\n }\n return null\n}\n\nconst resolvePageRenderMode = async (filePath: string): Promise<'dynamic' | 'static' | null> => {\n const source = await fs.readFile(filePath, 'utf8')\n const match = source.match(/export\\s+const\\s+render\\s*=\\s*(['\"])([^'\"\\\\]+)\\1(?:\\s+as\\s+const)?/s)\n if (!match) {\n return null\n }\n if (match[2] === 'dynamic' || match[2] === 'static') {\n return match[2]\n }\n throw new Error(\n `Unsupported render mode \"${match[2]}\" in ${filePath}. Expected \"static\" or \"dynamic\".`,\n )\n}\n\nexport const createRoutes = async (root: string): Promise<RouteEntry[]> => {\n const appDir = path.join(root, 'app')\n const filePaths = (await fg(path.join(appDir, '**/*.{ts,tsx}').replaceAll('\\\\', '/'))).sort()\n const directories = new Map<string, RouteDirectoryEntry>()\n\n for (const filePath of filePaths) {\n const parsed = parseAppFile(appDir, filePath)\n if (!parsed) {\n continue\n }\n const directory = directories.get(parsed.dir) ?? createDirectoryEntry()\n directory[parsed.kind] = toRouteModuleEntry(appDir, filePath, parsed.breakoutTarget)\n directories.set(parsed.dir, directory)\n }\n\n const result: RouteEntry[] = []\n const seenRoutePaths = new Map<string, string>()\n\n for (const [relativeDir, directory] of [...directories.entries()].sort(([left], [right]) =>\n left.localeCompare(right),\n )) {\n if (!directory.page && !directory.server) {\n continue\n }\n\n const segments = toRouteSegments(relativeDir)\n const routePath = segmentsToRoutePath(segments)\n const previousDir = seenRoutePaths.get(routePath)\n if (previousDir && previousDir !== relativeDir) {\n throw new Error(`Duplicate route pattern ${routePath} for ${previousDir} and ${relativeDir}.`)\n }\n seenRoutePaths.set(routePath, relativeDir)\n\n const effectiveAncestorDirs = resolveAncestorDirs(\n relativeDir,\n directory.page?.breakoutTarget ?? null,\n )\n result.push({\n error: directory.page\n ? selectNearestSpecial(directories, effectiveAncestorDirs, 'error')\n : null,\n layouts: directory.page\n ? collectLayouts(directories, relativeDir, directory.page?.breakoutTarget ?? null)\n : [],\n loading: directory.page\n ? selectNearestSpecial(directories, effectiveAncestorDirs, 'loading')\n : null,\n middlewares:\n directory.page || directory.server\n ? collectMiddlewares(directories, effectiveAncestorDirs)\n : [],\n notFound: directory.page\n ? selectNearestSpecial(directories, effectiveAncestorDirs, 'notFound')\n : null,\n page: directory.page,\n renderMode: directory.page ? await resolvePageRenderMode(directory.page.filePath) : null,\n routePath,\n segments,\n server: directory.server,\n })\n }\n\n return result.sort(compareRouteEntries)\n}\n\nexport const collectRouteModules = (routes: RouteEntry[]): RouteModuleEntry[] => {\n const modules = new Map<string, RouteModuleEntry>()\n for (const route of routes) {\n for (const entry of [\n route.page,\n ...route.layouts,\n route.loading,\n route.error,\n route.notFound,\n ]) {\n if (!entry) {\n continue\n }\n modules.set(entry.filePath, entry)\n }\n }\n return [...modules.values()]\n}\n\nexport const collectRouteServerModules = (routes: RouteEntry[]): RouteModuleEntry[] => {\n const modules = new Map<string, RouteModuleEntry>()\n for (const route of routes) {\n for (const middleware of route.middlewares) {\n modules.set(middleware.filePath, middleware)\n }\n if (route.server) {\n modules.set(route.server.filePath, route.server)\n }\n }\n return [...modules.values()]\n}\n\nexport const createDevModuleUrl = (root: string, entry: { filePath: string }) =>\n `/${path.relative(root, entry.filePath).replaceAll('\\\\', '/')}`\n\nexport const createBuildModuleUrl = (entry: RouteModuleEntry) => `/entries/${entry.entryName}.js`\n\nexport const createBuildServerModuleUrl = (entry: RouteModuleEntry) =>\n `../ssr/entries/${entry.entryName}.mjs`\n\nexport const createRouteManifest = (\n routes: RouteEntry[],\n resolveUrl: (module: RouteModuleEntry) => string,\n): RouteManifest =>\n routes.map(\n (route) =>\n ({\n error: route.error ? resolveUrl(route.error) : null,\n hasMiddleware: route.middlewares.length > 0,\n layouts: route.layouts.map((layout) => resolveUrl(layout)),\n loading: route.loading ? resolveUrl(route.loading) : null,\n notFound: route.notFound ? resolveUrl(route.notFound) : null,\n page: route.page ? resolveUrl(route.page) : null,\n routePath: route.routePath,\n segments: route.segments,\n server: route.server ? resolveUrl(route.server) : null,\n }) satisfies RouteModuleManifest,\n )\n\nexport const matchRoute = <T extends { routePath: string; segments: RoutePathSegment[] }>(\n routes: T[],\n pathname: string,\n): RouteMatch<T> | null => {\n for (const route of routes) {\n const matched = toMatch(route, pathname)\n if (matched) {\n return matched\n }\n }\n return null\n}\n","import ts from 'typescript'\nimport { runRustAnalyzeCompiler } from '@eclipsa/optimizer'\n\ntype SymbolKind = 'action' | 'component' | 'event' | 'lazy' | 'loader' | 'watch'\n\nexport interface ResumeSymbol {\n captures: string[]\n code: string\n filePath: string\n id: string\n kind: SymbolKind\n}\n\nexport interface ResumeHmrSymbolEntry {\n captures: string[]\n hmrKey: string\n id: string\n kind: SymbolKind\n ownerComponentKey: string | null\n signature: string\n}\n\nexport interface ResumeHmrComponentEntry {\n captures: string[]\n hmrKey: string\n id: string\n localSymbolKeys: string[]\n signature: string\n}\n\nexport interface ResumeHmrManifest {\n components: Map<string, ResumeHmrComponentEntry>\n symbols: Map<string, ResumeHmrSymbolEntry>\n}\n\nexport interface AnalyzedModule {\n actions: Map<string, { filePath: string; id: string }>\n code: string\n hmrManifest: ResumeHmrManifest\n loaders: Map<string, { filePath: string; id: string }>\n symbols: Map<string, ResumeSymbol>\n}\n\nconst isPascalCase = (name: string) =>\n name.includes('.') ||\n (name.length > 0 && (!/[a-z]/.test(name[0]!) || name[0] !== name[0]!.toLowerCase()))\n\nconst unwrapExpression = (expression: ts.Expression): ts.Expression => {\n let current = expression\n while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current)) {\n current = current.expression\n }\n return current\n}\n\nconst getFunctionLikeComponent = (\n node: ts.Node,\n): ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration | null => {\n if (ts.isArrowFunction(node) || ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node)) {\n return node\n }\n if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node)) {\n return getFunctionLikeComponent(node.expression)\n }\n return null\n}\n\nconst containsEarlyReturn = (node: ts.Node) => {\n let found = false\n\n const visit = (current: ts.Node) => {\n if (found) {\n return\n }\n if (\n current !== node &&\n (ts.isArrowFunction(current) ||\n ts.isFunctionDeclaration(current) ||\n ts.isFunctionExpression(current) ||\n ts.isGetAccessorDeclaration(current) ||\n ts.isMethodDeclaration(current) ||\n ts.isSetAccessorDeclaration(current))\n ) {\n return\n }\n if (ts.isReturnStatement(current)) {\n found = true\n return\n }\n ts.forEachChild(current, visit)\n }\n\n ts.forEachChild(node, visit)\n return found\n}\n\nconst validateSingleReturnComponent = (\n fn: ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration,\n label: string,\n) => {\n const body = fn.body\n if (!body || !ts.isBlock(body)) {\n return\n }\n\n const statements = body.statements\n const lastStatement = statements.at(-1)\n if (!lastStatement || !ts.isReturnStatement(lastStatement)) {\n throw new Error(\n `Component \"${label}\" must end with a single final return statement. Early returns are not supported.`,\n )\n }\n\n for (const statement of statements.slice(0, -1)) {\n if (containsEarlyReturn(statement)) {\n throw new Error(\n `Component \"${label}\" must use a single final return statement. Early returns are not supported.`,\n )\n }\n }\n}\n\nconst validateSingleReturnComponents = (source: string, id: string) => {\n const sourceFile = ts.createSourceFile(\n id,\n source,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TSX,\n )\n\n const validateComponentNode = (node: ts.Node, label: string) => {\n const component = getFunctionLikeComponent(node)\n if (component) {\n validateSingleReturnComponent(component, label)\n }\n }\n\n const visit = (node: ts.Node) => {\n if (\n ts.isVariableDeclaration(node) &&\n ts.isIdentifier(node.name) &&\n isPascalCase(node.name.text)\n ) {\n if (node.initializer) {\n validateComponentNode(node.initializer, node.name.text)\n }\n }\n\n if (ts.isFunctionDeclaration(node) && node.name && isPascalCase(node.name.text)) {\n validateSingleReturnComponent(node, node.name.text)\n }\n\n if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken) {\n const left = unwrapExpression(node.left)\n if (ts.isIdentifier(left) && isPascalCase(left.text)) {\n validateComponentNode(node.right, left.text)\n }\n }\n\n if (ts.isExportAssignment(node)) {\n validateComponentNode(node.expression, 'default')\n }\n\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n}\n\nconst annotateOptimizedRootComponents = (source: string, id: string) => {\n const sourceFile = ts.createSourceFile(\n id,\n source,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TSX,\n )\n const insertions: Array<{\n code: string\n index: number\n }> = []\n\n const visit = (node: ts.Node) => {\n if (\n ts.isCallExpression(node) &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === '__eclipsaComponent'\n ) {\n if (node.arguments.length >= 5) {\n return\n }\n const lastArgument = node.arguments.at(-1)\n insertions.push({\n code:\n node.arguments.length >= 4\n ? ', { optimizedRoot: true }'\n : ', undefined, { optimizedRoot: true }',\n index: lastArgument ? lastArgument.end : node.expression.end + 1,\n })\n }\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n\n if (insertions.length === 0) {\n return source\n }\n\n let nextSource = source\n for (const insertion of [...insertions].sort((left, right) => right.index - left.index)) {\n nextSource =\n nextSource.slice(0, insertion.index) + insertion.code + nextSource.slice(insertion.index)\n }\n\n return nextSource\n}\n\nexport const analyzeModule = async (\n source: string,\n id = 'analyze-input.tsx',\n): Promise<AnalyzedModule> => {\n validateSingleReturnComponents(source, id)\n const analyzed = await runRustAnalyzeCompiler(id, source)\n const code = annotateOptimizedRootComponents(analyzed.code, id)\n return {\n actions: new Map(analyzed.actions),\n code,\n hmrManifest: {\n components: new Map(analyzed.hmrManifest.components),\n symbols: new Map(analyzed.hmrManifest.symbols),\n },\n loaders: new Map(analyzed.loaders),\n symbols: new Map(analyzed.symbols),\n }\n}\n","import { runRustCompiler } from '@eclipsa/optimizer'\n\nexport const compileClientModule = async (\n input: string,\n id: string,\n options?: {\n hmr?: boolean\n },\n) => {\n return runRustCompiler({\n hmr: options?.hmr ?? true,\n id,\n source: input,\n target: 'client',\n })\n}\n","import { runRustCompiler } from '@eclipsa/optimizer'\n\nexport const compileSSRModule = async (code: string, id: string): Promise<string> => {\n return runRustCompiler({\n id,\n source: code,\n target: 'ssr',\n })\n}\n","import * as fs from 'node:fs/promises'\nimport * as path from 'node:path'\nimport fg from 'fast-glob'\nimport ts from 'typescript'\nimport {\n analyzeModule,\n compileClientModule,\n compileSSRModule,\n type AnalyzedModule,\n type ResumeHmrComponentEntry,\n type ResumeHmrSymbolEntry,\n type ResumeSymbol,\n} from '../compiler/mod.ts'\nimport type { ResumeHmrUpdatePayload } from '../core/resume-hmr.ts'\n\nconst SYMBOL_QUERY = 'eclipsa-symbol'\nconst SYMBOL_LANG_QUERY = 'lang.js'\n\ninterface AnalyzedEntry {\n analyzed: AnalyzedModule\n previous: {\n analyzed: AnalyzedModule\n source: string\n } | null\n source: string\n}\n\ninterface ResumeHmrResolution {\n isResumable: boolean\n nextEntry: AnalyzedEntry\n normalizedId: string\n update: ResumeHmrUpdatePayload | null\n}\n\nconst cache = new Map<string, AnalyzedEntry>()\nconst servedSources = new Map<string, string>()\n\nexport const resetCompilerCache = () => {\n cache.clear()\n servedSources.clear()\n}\n\nexport const primeCompilerCache = async (filePath: string, source?: string) => {\n const normalizedPath = stripQuery(filePath)\n const normalizedId = normalizeCompilerModuleId(normalizedPath)\n const resolvedSource = source ?? (await fs.readFile(normalizedPath, 'utf8'))\n servedSources.set(normalizedId, resolvedSource)\n await loadAnalyzedModule(normalizedPath, resolvedSource)\n}\n\nconst stripQuery = (id: string) => {\n const queryIndex = id.indexOf('?')\n if (queryIndex < 0) {\n return id\n }\n return id.slice(0, queryIndex)\n}\n\nconst normalizeCompilerModuleId = (id: string) => {\n const normalized = stripQuery(id).replaceAll('\\\\', '/')\n if (normalized.startsWith('/app/')) {\n return normalized\n }\n const appIndex = normalized.lastIndexOf('/app/')\n if (appIndex >= 0) {\n return normalized.slice(appIndex)\n }\n return normalized\n}\n\nconst isAppModuleId = (id: string) => normalizeCompilerModuleId(id).startsWith('/app/')\n\nexport const parseSymbolRequest = (id: string): { filePath: string; symbolId: string } | null => {\n const queryIndex = id.indexOf('?')\n if (queryIndex < 0) {\n return null\n }\n\n const params = new URLSearchParams(id.slice(queryIndex + 1))\n const symbolId = params.get(SYMBOL_QUERY)\n if (!symbolId) {\n return null\n }\n\n return {\n filePath: id.slice(0, queryIndex),\n symbolId,\n }\n}\n\nexport const createSymbolRequestId = (filePath: string, symbolId: string) =>\n `${filePath}?${SYMBOL_QUERY}=${symbolId}&${SYMBOL_LANG_QUERY}`\n\nconst loadAnalyzedModule = async (filePath: string, source?: string) => {\n const normalizedPath = stripQuery(filePath)\n const normalizedId = normalizeCompilerModuleId(normalizedPath)\n const cached = cache.get(normalizedId)\n if (source == null && cached && isAppModuleId(normalizedPath)) {\n return cached.analyzed\n }\n\n const resolvedSource = source ?? (await fs.readFile(normalizedPath, 'utf8'))\n if (cached?.source === resolvedSource) {\n return cached.analyzed\n }\n\n const analyzed = await analyzeModule(resolvedSource, normalizedId)\n if (!analyzed) {\n throw new Error(`Failed to compile ${normalizedId}.`)\n }\n\n const entry = {\n analyzed,\n previous: cached\n ? {\n analyzed: cached.analyzed,\n source: cached.source,\n }\n : null,\n source: resolvedSource,\n } satisfies AnalyzedEntry\n cache.set(normalizedId, entry)\n\n return entry.analyzed\n}\n\nconst createAnalyzedEntry = async (filePath: string, source: string): Promise<AnalyzedEntry> => {\n const analyzed = await analyzeModule(source, normalizeCompilerModuleId(filePath))\n if (!analyzed) {\n throw new Error(`Failed to compile ${filePath}.`)\n }\n\n return {\n analyzed,\n previous: null,\n source,\n }\n}\n\nconst findCachedAnalyzedModuleBySymbolId = (symbolId: string) => {\n for (const entry of cache.values()) {\n if (entry.analyzed.symbols.has(symbolId)) {\n return entry.analyzed\n }\n }\n return null\n}\n\nconst getComponentEntryById = (components: Map<string, ResumeHmrComponentEntry>, id: string) => {\n for (const component of components.values()) {\n if (component.id === id) {\n return component\n }\n }\n return null\n}\n\nconst sameStrings = (left: string[], right: string[]) =>\n left.length === right.length && left.every((value, index) => value === right[index])\n\nconst createDevSourceUrl = (root: string, filePath: string) => {\n const normalizedRoot = root.replaceAll('\\\\', '/').replace(/\\/$/, '')\n const normalizedFilePath = filePath.replaceAll('\\\\', '/')\n if (normalizedFilePath.startsWith('/app/')) {\n return normalizedFilePath\n }\n if (\n normalizedFilePath === normalizedRoot ||\n normalizedFilePath.startsWith(`${normalizedRoot}/`)\n ) {\n return `/${path.relative(root, filePath).replaceAll('\\\\', '/')}`\n }\n return `/@fs/${normalizedFilePath}`\n}\n\nconst findOwnerComponentForSymbol = (\n oldSymbol: ResumeHmrSymbolEntry,\n components: Map<string, ResumeHmrComponentEntry>,\n) => {\n if (oldSymbol.ownerComponentKey) {\n return components.get(oldSymbol.ownerComponentKey) ?? null\n }\n if (oldSymbol.kind === 'component') {\n return getComponentEntryById(components, oldSymbol.id)\n }\n return null\n}\n\nexport const createResumeHmrUpdate = (options: {\n filePath: string\n next: AnalyzedModule\n previous: AnalyzedModule | null\n root: string\n}): ResumeHmrUpdatePayload | null => {\n const { filePath, next, previous, root } = options\n const fileUrl = createDevSourceUrl(root, filePath)\n if (!previous) {\n return next.symbols.size > 0\n ? {\n fileUrl,\n fullReload: true,\n rerenderComponentSymbols: [],\n rerenderOwnerSymbols: [],\n symbolUrlReplacements: {},\n }\n : null\n }\n if (previous.symbols.size === 0 && next.symbols.size === 0) {\n return null\n }\n\n const previousManifest = previous.hmrManifest\n const nextManifest = next.hmrManifest\n const rerenderComponentSymbols = new Set<string>()\n const rerenderOwnerSymbols = new Set<string>()\n const symbolUrlReplacements: Record<string, string> = {}\n let fullReload = previous.symbols.size > 0 && next.symbols.size === 0\n\n const markOwnerRerender = (symbol: ResumeHmrSymbolEntry) => {\n const owner = findOwnerComponentForSymbol(symbol, previousManifest.components)\n if (!owner) {\n fullReload = true\n return\n }\n rerenderOwnerSymbols.add(owner.id)\n }\n\n if (previousManifest.components.size !== nextManifest.components.size) {\n fullReload = true\n }\n\n for (const [hmrKey, previousComponent] of previousManifest.components) {\n const nextComponent = nextManifest.components.get(hmrKey)\n if (!nextComponent) {\n fullReload = true\n continue\n }\n if (!sameStrings(previousComponent.localSymbolKeys, nextComponent.localSymbolKeys)) {\n rerenderOwnerSymbols.add(previousComponent.id)\n }\n if (!sameStrings(previousComponent.captures, nextComponent.captures)) {\n rerenderOwnerSymbols.add(previousComponent.id)\n }\n }\n\n for (const [hmrKey, nextComponent] of nextManifest.components) {\n if (!previousManifest.components.has(hmrKey)) {\n fullReload = true\n if (nextComponent.id) {\n continue\n }\n }\n }\n\n for (const [hmrKey, previousSymbol] of previousManifest.symbols) {\n const nextSymbol = nextManifest.symbols.get(hmrKey)\n if (!nextSymbol || nextSymbol.kind !== previousSymbol.kind) {\n if (previousSymbol.kind === 'component') {\n fullReload = true\n } else {\n markOwnerRerender(previousSymbol)\n }\n continue\n }\n\n if (previousSymbol.id !== nextSymbol.id) {\n symbolUrlReplacements[previousSymbol.id] = createDevSymbolUrl(root, filePath, nextSymbol.id)\n }\n\n if (!sameStrings(previousSymbol.captures, nextSymbol.captures)) {\n markOwnerRerender(previousSymbol)\n continue\n }\n\n if (previousSymbol.kind === 'component') {\n if (previousSymbol.signature !== nextSymbol.signature) {\n rerenderComponentSymbols.add(previousSymbol.id)\n }\n continue\n }\n\n if (previousSymbol.signature === nextSymbol.signature) {\n continue\n }\n\n if (previousSymbol.kind === 'watch') {\n markOwnerRerender(previousSymbol)\n }\n }\n\n for (const [hmrKey, nextSymbol] of nextManifest.symbols) {\n if (previousManifest.symbols.has(hmrKey)) {\n continue\n }\n if (nextSymbol.kind === 'component') {\n fullReload = true\n continue\n }\n symbolUrlReplacements[nextSymbol.id] = createDevSymbolUrl(root, filePath, nextSymbol.id)\n const owner = nextSymbol.ownerComponentKey\n ? previousManifest.components.get(nextSymbol.ownerComponentKey)\n : null\n if (!owner) {\n fullReload = true\n continue\n }\n rerenderOwnerSymbols.add(owner.id)\n }\n\n if (fullReload) {\n return {\n fileUrl,\n fullReload: true,\n rerenderComponentSymbols: [],\n rerenderOwnerSymbols: [],\n symbolUrlReplacements: {},\n }\n }\n\n for (const ownerSymbol of rerenderOwnerSymbols) {\n rerenderComponentSymbols.delete(ownerSymbol)\n }\n\n if (\n rerenderComponentSymbols.size === 0 &&\n rerenderOwnerSymbols.size === 0 &&\n Object.keys(symbolUrlReplacements).length === 0\n ) {\n return {\n fileUrl,\n fullReload: false,\n rerenderComponentSymbols: [],\n rerenderOwnerSymbols: [],\n symbolUrlReplacements: {},\n }\n }\n\n return {\n fileUrl,\n fullReload: false,\n rerenderComponentSymbols: [...rerenderComponentSymbols],\n rerenderOwnerSymbols: [...rerenderOwnerSymbols],\n symbolUrlReplacements,\n }\n}\n\nexport const resolveResumeHmrUpdate = async (options: {\n filePath: string\n root: string\n source: string\n}): Promise<{\n isResumable: boolean\n update: ResumeHmrUpdatePayload | null\n}> => {\n const resolution = await inspectResumeHmrUpdate(options)\n cache.set(resolution.normalizedId, resolution.nextEntry)\n return {\n isResumable: resolution.isResumable,\n update: resolution.update,\n }\n}\n\nexport const inspectResumeHmrUpdate = async (options: {\n filePath: string\n root: string\n source: string\n}): Promise<ResumeHmrResolution> => {\n const normalizedPath = stripQuery(options.filePath)\n const normalizedId = normalizeCompilerModuleId(normalizedPath)\n const cached = cache.get(normalizedId)\n let nextEntry: AnalyzedEntry\n if (cached?.source === options.source) {\n nextEntry = cached\n } else {\n const createdEntry = await createAnalyzedEntry(normalizedPath, options.source)\n nextEntry = {\n ...createdEntry,\n previous: cached\n ? {\n analyzed: cached.analyzed,\n source: cached.source,\n }\n : null,\n }\n }\n let previous =\n cached?.source === options.source\n ? (nextEntry.previous?.analyzed ?? null)\n : (cached?.analyzed ?? null)\n if (!previous) {\n const servedSource = servedSources.get(normalizedId)\n if (servedSource && servedSource !== options.source) {\n const previousEntry = await createAnalyzedEntry(normalizedPath, servedSource)\n previous = previousEntry.analyzed\n if (!nextEntry.previous) {\n nextEntry = {\n ...nextEntry,\n previous: {\n analyzed: previousEntry.analyzed,\n source: servedSource,\n },\n }\n }\n }\n }\n const update = createResumeHmrUpdate({\n filePath: normalizedPath,\n next: nextEntry.analyzed,\n previous,\n root: options.root,\n })\n servedSources.set(normalizedId, nextEntry.source)\n return {\n isResumable: (previous?.symbols.size ?? 0) > 0 || nextEntry.analyzed.symbols.size > 0,\n nextEntry,\n normalizedId,\n update,\n }\n}\n\nexport const compileModuleForClient = async (\n source: string,\n id: string,\n options?: {\n hmr?: boolean\n },\n) => {\n const filePath = stripQuery(id)\n const normalizedId = normalizeCompilerModuleId(filePath)\n const analyzed = await loadAnalyzedModule(filePath, source)\n servedSources.set(normalizedId, servedSources.get(normalizedId) ?? source)\n return compileClientModule(analyzed.code, filePath, {\n hmr: options?.hmr ?? false,\n })\n}\n\nexport const compileModuleForSSR = async (source: string, id: string) => {\n const filePath = stripQuery(id)\n const normalizedId = normalizeCompilerModuleId(filePath)\n const analyzed = await loadAnalyzedModule(filePath, source)\n servedSources.set(normalizedId, servedSources.get(normalizedId) ?? source)\n return compileSSRModule(analyzed.code, filePath)\n}\n\nexport const loadSymbolModuleForClient = async (id: string) => {\n const parsed = parseSymbolRequest(id)\n if (!parsed) {\n return null\n }\n\n let currentAnalyzed = findCachedAnalyzedModuleBySymbolId(parsed.symbolId)\n try {\n const currentSource = await fs.readFile(stripQuery(parsed.filePath), 'utf8')\n currentAnalyzed = await loadAnalyzedModule(parsed.filePath, currentSource)\n } catch (error) {\n const code = (error as NodeJS.ErrnoException | undefined)?.code\n if (code !== 'ENOENT' && code !== 'ENOTDIR') {\n throw error\n }\n currentAnalyzed ??= await loadAnalyzedModule(parsed.filePath)\n }\n const analyzed = currentAnalyzed.symbols.has(parsed.symbolId)\n ? currentAnalyzed\n : (findCachedAnalyzedModuleBySymbolId(parsed.symbolId) ?? currentAnalyzed)\n const symbol = analyzed.symbols.get(parsed.symbolId)\n if (!symbol) {\n throw new Error(`Unknown resume symbol ${parsed.symbolId} for ${parsed.filePath}.`)\n }\n\n return compileClientModule(symbol.code, `${parsed.filePath}?${SYMBOL_QUERY}=${parsed.symbolId}`, {\n hmr: false,\n })\n}\n\nexport const loadSymbolModuleForSSR = async (id: string) => {\n const parsed = parseSymbolRequest(id)\n if (!parsed) {\n return null\n }\n\n let currentAnalyzed = findCachedAnalyzedModuleBySymbolId(parsed.symbolId)\n try {\n const currentSource = await fs.readFile(stripQuery(parsed.filePath), 'utf8')\n currentAnalyzed = await loadAnalyzedModule(parsed.filePath, currentSource)\n } catch (error) {\n const code = (error as NodeJS.ErrnoException | undefined)?.code\n if (code !== 'ENOENT' && code !== 'ENOTDIR') {\n throw error\n }\n currentAnalyzed ??= await loadAnalyzedModule(parsed.filePath)\n }\n const analyzed = currentAnalyzed.symbols.has(parsed.symbolId)\n ? currentAnalyzed\n : (findCachedAnalyzedModuleBySymbolId(parsed.symbolId) ?? currentAnalyzed)\n const symbol = analyzed.symbols.get(parsed.symbolId)\n if (!symbol) {\n throw new Error(`Unknown resume symbol ${parsed.symbolId} for ${parsed.filePath}.`)\n }\n\n return compileSSRModule(symbol.code, `${parsed.filePath}?${SYMBOL_QUERY}=${parsed.symbolId}`)\n}\n\nexport const createDevSymbolUrl = (root: string, filePath: string, symbolId: string) =>\n createSymbolRequestId(createDevSourceUrl(root, filePath), symbolId)\n\nexport const createBuildSymbolUrl = (symbolId: string) => `/entries/symbol__${symbolId}.js`\n\nexport const createBuildServerActionUrl = (actionId: string) =>\n `../ssr/entries/action__${actionId}.mjs`\n\nexport const createBuildServerLoaderUrl = (loaderId: string) =>\n `../ssr/entries/loader__${loaderId}.mjs`\n\nconst ANALYZABLE_SOURCE_EXTENSIONS = new Set([\n '.cjs',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.mts',\n '.ts',\n '.tsx',\n])\n\nconst ANALYZABLE_APP_GLOB = '**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}'\n\nconst moduleResolutionOptions: ts.CompilerOptions = {\n allowImportingTsExtensions: true,\n jsx: ts.JsxEmit.Preserve,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n resolvePackageJsonExports: true,\n resolvePackageJsonImports: true,\n target: ts.ScriptTarget.ESNext,\n}\n\nconst moduleResolutionHost = ts.createCompilerHost(moduleResolutionOptions, true)\n\nconst isAnalyzableSourceFile = (filePath: string) => {\n const ext = path.extname(filePath)\n return ANALYZABLE_SOURCE_EXTENSIONS.has(ext) && !filePath.endsWith('.d.ts')\n}\n\nconst resolveImportedModule = (specifier: string, containingFile: string) =>\n ts.resolveModuleName(specifier, containingFile, moduleResolutionOptions, moduleResolutionHost)\n .resolvedModule?.resolvedFileName ?? null\n\nexport const collectAppSymbols = async (root: string): Promise<ResumeSymbol[]> => {\n const appDir = path.join(root, 'app')\n const entryFiles = await fg(path.join(appDir, ANALYZABLE_APP_GLOB).replaceAll('\\\\', '/'))\n const entryFileSet = new Set(entryFiles)\n const pending = [...entryFiles]\n const visited = new Set<string>()\n const symbols = new Map<string, ResumeSymbol>()\n\n while (pending.length > 0) {\n const next = pending.pop()\n if (!next) {\n continue\n }\n\n const filePath = stripQuery(next)\n if (visited.has(filePath) || !isAnalyzableSourceFile(filePath)) {\n continue\n }\n visited.add(filePath)\n\n let source: string\n try {\n source = await fs.readFile(filePath, 'utf8')\n } catch (error) {\n if (entryFileSet.has(filePath)) {\n throw error\n }\n continue\n }\n\n let analyzed: Awaited<ReturnType<typeof loadAnalyzedModule>>\n try {\n analyzed = await loadAnalyzedModule(filePath, source)\n } catch (error) {\n if (entryFileSet.has(filePath)) {\n throw error\n }\n continue\n }\n for (const symbol of analyzed.symbols.values()) {\n symbols.set(symbol.id, symbol)\n }\n\n const imports = ts.preProcessFile(source, true, true).importedFiles\n for (const imported of imports) {\n const resolvedFilePath = resolveImportedModule(imported.fileName, filePath)\n if (!resolvedFilePath || !isAnalyzableSourceFile(resolvedFilePath)) {\n continue\n }\n pending.push(resolvedFilePath)\n }\n }\n\n return [...symbols.values()]\n}\n\nexport const collectReachableAnalyzableFiles = async (\n entryFiles: readonly string[],\n): Promise<string[]> => {\n const pending = [...entryFiles]\n const visited = new Set<string>()\n const reachable = new Set<string>()\n const entryFileSet = new Set(entryFiles.map((filePath) => stripQuery(filePath)))\n\n while (pending.length > 0) {\n const next = pending.pop()\n if (!next) {\n continue\n }\n\n const filePath = stripQuery(next)\n if (visited.has(filePath) || !isAnalyzableSourceFile(filePath)) {\n continue\n }\n visited.add(filePath)\n\n let source: string\n try {\n source = await fs.readFile(filePath, 'utf8')\n } catch (error) {\n const code = (error as NodeJS.ErrnoException | undefined)?.code\n if (entryFileSet.has(filePath) && code !== 'ENOENT' && code !== 'ENOTDIR') {\n throw error\n }\n continue\n }\n\n try {\n await loadAnalyzedModule(filePath, source)\n } catch (error) {\n if (entryFileSet.has(filePath)) {\n throw error\n }\n continue\n }\n\n reachable.add(filePath)\n\n const imports = ts.preProcessFile(source, true, true).importedFiles\n for (const imported of imports) {\n const resolvedFilePath = resolveImportedModule(imported.fileName, filePath)\n if (!resolvedFilePath || !isAnalyzableSourceFile(resolvedFilePath)) {\n continue\n }\n pending.push(resolvedFilePath)\n }\n }\n\n return [...reachable]\n}\n\nexport const collectAppActions = async (\n root: string,\n): Promise<Array<{ filePath: string; id: string }>> => {\n const appDir = path.join(root, 'app')\n const files = await fg(path.join(appDir, '**/*.{ts,tsx}').replaceAll('\\\\', '/'))\n const result: Array<{ filePath: string; id: string }> = []\n\n for (const filePath of files) {\n const analyzed = await loadAnalyzedModule(filePath)\n result.push(...[...analyzed.actions.values()].map((action) => ({ filePath, id: action.id })))\n }\n\n return result\n}\n\nexport const collectAppLoaders = async (\n root: string,\n): Promise<Array<{ filePath: string; id: string }>> => {\n const appDir = path.join(root, 'app')\n const files = await fg(path.join(appDir, '**/*.{ts,tsx}').replaceAll('\\\\', '/'))\n const result: Array<{ filePath: string; id: string }> = []\n\n for (const filePath of files) {\n const analyzed = await loadAnalyzedModule(filePath)\n result.push(...[...analyzed.loaders.values()].map((loader) => ({ filePath, id: loader.id })))\n }\n\n return result\n}\n","import { Hono, type Context } from 'hono'\nimport type { MiddlewareHandler, Next } from 'hono/types'\nimport type { DevEnvironment, ResolvedConfig, ViteDevServer } from 'vite'\nimport type { ModuleRunner } from 'vite/module-runner'\nimport * as fs from 'node:fs/promises'\nimport {\n ROUTE_DATA_ENDPOINT,\n ROUTE_DATA_REQUEST_HEADER,\n ROUTE_MANIFEST_ELEMENT_ID,\n ROUTE_PREFLIGHT_ENDPOINT,\n ROUTE_PREFLIGHT_REQUEST_HEADER,\n ROUTE_RPC_URL_HEADER,\n type RouteParams,\n} from '../../core/router-shared.ts'\nimport type { SSRRootProps } from '../../core/types.ts'\nimport {\n APP_HOOKS_ELEMENT_ID,\n attachRequestFetch,\n createRequestFetch,\n markPublicError,\n resolveReroute,\n runHandleError,\n type AppContext,\n type AppHooksModule,\n type ServerHooksModule,\n withServerRequestContext,\n} from '../../core/hooks.ts'\nimport { Fragment, jsxDEV } from '../../jsx/jsx-dev-runtime.ts'\nimport {\n composeRouteMetadata,\n renderRouteMetadataHead,\n type RouteMetadataExport,\n} from '../../core/metadata.ts'\nimport { primeLocationState } from '../../core/runtime.ts'\nimport {\n createDevModuleUrl,\n createRouteManifest,\n createRoutes,\n matchRoute,\n normalizeRoutePath,\n type RouteEntry,\n} from '../utils/routing.ts'\nimport * as path from 'node:path'\nimport {\n collectAppActions,\n collectAppLoaders,\n collectAppSymbols,\n collectReachableAnalyzableFiles,\n createDevSymbolUrl,\n primeCompilerCache,\n} from '../compiler.ts'\n\nconst ROUTE_PARAMS_PROP = '__eclipsa_route_params'\nconst ROUTE_ERROR_PROP = '__eclipsa_route_error'\ninterface DevAppDeps {\n collectAppActions(root: string): Promise<{ id: string; filePath: string }[]>\n collectAppLoaders(root: string): Promise<{ id: string; filePath: string }[]>\n collectAppSymbols(root: string): Promise<{ id: string; filePath: string }[]>\n createDevModuleUrl(root: string, entry: { filePath: string }): string\n createDevSymbolUrl(root: string, filePath: string, symbolId: string): string\n createRoutes(root: string): Promise<RouteEntry[]>\n}\n\ninterface DevAppInit {\n deps?: DevAppDeps\n resolvedConfig: ResolvedConfig\n devServer: ViteDevServer\n runner: ModuleRunner\n ssrEnv: DevEnvironment\n}\n\nexport interface DevFetchController {\n fetch(req: Request): Promise<Response | undefined>\n invalidate(): void\n}\n\nconst fileExists = async (filePath: string) => {\n try {\n await fs.access(filePath)\n return true\n } catch {\n return false\n }\n}\n\nconst getRequestUrl = (request: Request) => {\n const url = new URL(request.url)\n const host = request.headers.get('x-forwarded-host') ?? request.headers.get('host')\n const proto = request.headers.get('x-forwarded-proto')\n if (host) {\n url.host = host\n }\n if (proto) {\n url.protocol = `${proto}:`\n }\n return url\n}\n\nconst toAppRelativePath = (root: string, filePath: string) => {\n const relativePath = path.relative(path.join(root, 'app'), filePath)\n if (relativePath.startsWith('..') || path.isAbsolute(relativePath)) {\n return null\n }\n return relativePath.replaceAll('\\\\', '/')\n}\n\nexport const shouldInvalidateDevApp = (\n root: string,\n filePath: string,\n event: 'add' | 'change' | 'unlink',\n) => {\n const relativePath = toAppRelativePath(root, filePath)\n if (!relativePath) {\n return false\n }\n if (relativePath === '+server-entry.ts') {\n return true\n }\n if (relativePath.endsWith('.ts') || relativePath.endsWith('.tsx')) {\n return event === 'add' || event === 'change' || event === 'unlink'\n }\n return false\n}\n\nconst RESUME_PAYLOAD_PLACEHOLDER = '__ECLIPSA_RESUME_PAYLOAD__'\nconst ROUTE_MANIFEST_PLACEHOLDER = '__ECLIPSA_ROUTE_MANIFEST__'\nconst APP_HOOKS_PLACEHOLDER = '__ECLIPSA_APP_HOOKS__'\n\ninterface RouteDataResponse {\n finalHref: string\n finalPathname: string\n kind: 'page' | 'not-found'\n loaders: Record<string, unknown>\n ok: true\n}\n\ninterface RouteServerAccessEntry {\n actionIds: Set<string>\n loaderIds: Set<string>\n route: RouteEntry\n}\n\nconst replaceHeadPlaceholder = (html: string, placeholder: string, value: string) =>\n html.replaceAll(placeholder, value)\n\nconst splitHtmlForStreaming = (html: string) => {\n const bodyCloseIndex = html.lastIndexOf('</body>')\n if (bodyCloseIndex >= 0) {\n return {\n prefix: html.slice(0, bodyCloseIndex),\n suffix: html.slice(bodyCloseIndex),\n }\n }\n const htmlCloseIndex = html.lastIndexOf('</html>')\n if (htmlCloseIndex >= 0) {\n return {\n prefix: html.slice(0, htmlCloseIndex),\n suffix: html.slice(htmlCloseIndex),\n }\n }\n return {\n prefix: html,\n suffix: '',\n }\n}\n\nconst toIdsByFilePath = (entries: ReadonlyArray<{ filePath: string; id: string }>) => {\n const idsByFilePath = new Map<string, string[]>()\n for (const entry of entries) {\n const existing = idsByFilePath.get(entry.filePath)\n if (existing) {\n existing.push(entry.id)\n continue\n }\n idsByFilePath.set(entry.filePath, [entry.id])\n }\n return idsByFilePath\n}\n\nconst getRouteReachableEntryFiles = (route: RouteEntry) =>\n [\n route.error?.filePath,\n ...route.layouts.map((layout) => layout.filePath),\n route.loading?.filePath,\n route.notFound?.filePath,\n route.page?.filePath,\n ].filter((filePath): filePath is string => typeof filePath === 'string')\n\nconst createRouteServerAccessEntries = async (\n routes: readonly RouteEntry[],\n actions: ReadonlyArray<{ filePath: string; id: string }>,\n loaders: ReadonlyArray<{ filePath: string; id: string }>,\n) => {\n const actionIdsByFilePath = toIdsByFilePath(actions)\n const loaderIdsByFilePath = toIdsByFilePath(loaders)\n\n return await Promise.all(\n routes.map(async (route) => {\n const reachableFiles = await collectReachableAnalyzableFiles(\n getRouteReachableEntryFiles(route),\n )\n return {\n actionIds: new Set(\n reachableFiles.flatMap((filePath) => actionIdsByFilePath.get(filePath) ?? []),\n ),\n loaderIds: new Set(\n reachableFiles.flatMap((filePath) => loaderIdsByFilePath.get(filePath) ?? []),\n ),\n route,\n } satisfies RouteServerAccessEntry\n }),\n )\n}\n\nconst ROUTE_SLOT_ROUTE_KEY = Symbol.for('eclipsa.route-slot-route')\n\nconst createRouteSlot = (\n route: {\n error?: unknown\n layouts: Array<{ renderer: (props: unknown) => unknown }>\n page: { renderer: (props: unknown) => unknown }\n params: RouteParams\n pathname: string\n },\n startLayoutIndex: number,\n) => {\n const slot = {\n __eclipsa_type: 'route-slot',\n pathname: route.pathname,\n startLayoutIndex,\n }\n Object.defineProperty(slot, ROUTE_SLOT_ROUTE_KEY, {\n configurable: true,\n enumerable: false,\n value: route,\n writable: true,\n })\n return slot\n}\n\nconst createRouteProps = (params: RouteParams, props: Record<string, unknown>) => {\n const nextProps = {\n ...props,\n }\n Object.defineProperty(nextProps, ROUTE_PARAMS_PROP, {\n configurable: true,\n enumerable: false,\n value: params,\n writable: true,\n })\n return nextProps\n}\n\nconst createRouteElement = (\n pathname: string,\n params: RouteParams,\n Page: (props: unknown) => unknown,\n Layouts: Array<(props: unknown) => unknown>,\n error?: unknown,\n): any => {\n if (Layouts.length === 0) {\n const nextProps = createRouteProps(params, {})\n Object.defineProperty(nextProps, ROUTE_ERROR_PROP, {\n configurable: true,\n enumerable: false,\n value: error,\n writable: true,\n })\n return jsxDEV(Page as any, nextProps, null, false, {})\n }\n\n const route = {\n error,\n layouts: Layouts.map((renderer) => ({\n renderer,\n })),\n page: {\n renderer: Page,\n },\n params,\n pathname,\n }\n let children: unknown = null\n for (let index = Layouts.length - 1; index >= 0; index -= 1) {\n const Layout = Layouts[index]!\n const nextProps = createRouteProps(params, {\n children: createRouteSlot(route, index + 1),\n })\n Object.defineProperty(nextProps, ROUTE_ERROR_PROP, {\n configurable: true,\n enumerable: false,\n value: error,\n writable: true,\n })\n children = jsxDEV(Layout as any, nextProps, null, false, {})\n }\n return children\n}\n\nconst scoreSpecialRoute = (route: RouteEntry, pathname: string) => {\n const pathnameSegments = normalizeRoutePath(pathname).split('/').filter(Boolean)\n let score = 0\n for (\n let index = 0;\n index < route.segments.length && index < pathnameSegments.length;\n index += 1\n ) {\n const segment = route.segments[index]!\n const pathnameSegment = pathnameSegments[index]\n if (segment.kind === 'static') {\n if (segment.value !== pathnameSegment) {\n break\n }\n score += 10\n continue\n }\n score += segment.kind === 'rest' ? 1 : 2\n if (segment.kind === 'rest') {\n break\n }\n }\n return score\n}\n\nconst findSpecialRoute = (\n routes: RouteEntry[],\n pathname: string,\n kind: 'error' | 'notFound',\n): { params: RouteParams; route: RouteEntry } | null => {\n const matched = matchRoute(routes, pathname)\n if (matched?.route[kind]) {\n return matched\n }\n\n let best: { params: RouteParams; route: RouteEntry } | null = null\n let bestScore = -1\n for (const route of routes) {\n if (!route[kind]) {\n continue\n }\n const score = scoreSpecialRoute(route, pathname)\n if (score > bestScore) {\n best = {\n params: {},\n route,\n }\n bestScore = score\n }\n }\n return best\n}\n\nconst applyRequestParams = (c: Context, params: RouteParams) => {\n const req = c.req as any\n req.param = (name?: string) => {\n if (!name) {\n return params\n }\n return params[name]\n }\n}\n\nconst isNotFoundError = (error: unknown) =>\n !!error &&\n typeof error === 'object' &&\n (error as { __eclipsa_not_found__?: boolean }).__eclipsa_not_found__ === true\n\nconst logDevServerError = (devServer: ViteDevServer, error: unknown) => {\n if (error instanceof Error && typeof devServer.ssrFixStacktrace === 'function') {\n devServer.ssrFixStacktrace(error)\n }\n console.error(error)\n}\n\nconst toPublicErrorValue = async (\n devServer: ViteDevServer,\n hooks: ServerHooksModule,\n c: AppContext,\n error: unknown,\n event: Parameters<typeof runHandleError>[1]['event'],\n) => {\n const publicError = await runHandleError(\n {\n handleError: hooks.handleError,\n },\n {\n context: c,\n error,\n event,\n },\n )\n if (!isNotFoundError(error)) {\n logDevServerError(devServer, error)\n }\n return markPublicError(error, publicError)\n}\n\nconst loadOptionalHookModule = async <T extends object>(\n runner: ModuleRunner,\n filePath: string,\n): Promise<Partial<T>> => {\n if (!(await fileExists(filePath))) {\n return {}\n }\n return (await runner.import(filePath)) as Partial<T>\n}\n\nconst isRedirectResponse = (\n response: unknown,\n): response is { headers: { get(name: string): string | null }; status: number } =>\n !!response &&\n typeof response === 'object' &&\n typeof (response as { status?: unknown }).status === 'number' &&\n !!(response as { headers?: { get?: unknown } }).headers &&\n typeof (response as { headers: { get?: unknown } }).headers.get === 'function' &&\n (response as { status: number }).status >= 300 &&\n (response as { status: number }).status < 400 &&\n !!(response as { headers: { get(name: string): string | null } }).headers.get('location')\n\nconst createDevApp = async (init: DevAppInit) => {\n const deps = init.deps ?? {\n collectAppActions,\n collectAppLoaders,\n collectAppSymbols,\n createDevModuleUrl,\n createDevSymbolUrl,\n createRoutes,\n }\n const { default: userApp } = await init.runner.import('/app/+server-entry.ts')\n const app = new Hono()\n app.route('/', userApp)\n const actions = await deps.collectAppActions(init.resolvedConfig.root)\n const loaders = await deps.collectAppLoaders(init.resolvedConfig.root)\n const routes = await deps.createRoutes(init.resolvedConfig.root)\n const allSymbols = await deps.collectAppSymbols(init.resolvedConfig.root)\n const actionModules = new Map(actions.map((action) => [action.id, action.filePath]))\n const loaderModules = new Map(loaders.map((loader) => [loader.id, loader.filePath]))\n const routeServerAccessEntries = await createRouteServerAccessEntries(routes, actions, loaders)\n const routeServerAccessByRoute = new Map(\n routeServerAccessEntries.map((entry) => [entry.route, entry] as const),\n )\n const symbolUrls = Object.fromEntries(\n allSymbols.map((symbol) => [\n symbol.id,\n deps.createDevSymbolUrl(init.resolvedConfig.root, symbol.filePath, symbol.id),\n ]),\n )\n const routeManifest = createRouteManifest(routes, (entry) =>\n deps.createDevModuleUrl(init.resolvedConfig.root, entry),\n )\n const appHooksPath = path.join(init.resolvedConfig.root, 'app/+hooks.ts')\n const serverHooksPath = path.join(init.resolvedConfig.root, 'app/+hooks.server.ts')\n const appHooks = (await loadOptionalHookModule<AppHooksModule>(\n init.runner,\n appHooksPath,\n )) as AppHooksModule\n const serverHooks = (await loadOptionalHookModule<ServerHooksModule>(\n init.runner,\n serverHooksPath,\n )) as ServerHooksModule\n const appHooksManifest = {\n client: (await fileExists(appHooksPath)) ? '/app/+hooks.ts' : null,\n }\n\n await serverHooks.init?.()\n\n const prepareRequestContext = <E extends Context>(c: E) => {\n attachRequestFetch(\n c as unknown as AppContext,\n createRequestFetch(c as unknown as AppContext, serverHooks.handleFetch),\n )\n return c as unknown as AppContext\n }\n\n const reroutePathname = (request: Request | null, pathname: string, baseUrl: string) =>\n normalizeRoutePath(resolveReroute(appHooks.reroute, request, pathname, baseUrl))\n\n const getRouteServerAccess = (route: RouteEntry) =>\n routeServerAccessByRoute.get(route) ?? {\n actionIds: new Set<string>(),\n loaderIds: new Set<string>(),\n route,\n }\n\n const resolveRouteForCurrentUrl = (request: Request | null, currentUrl: URL) => {\n const resolvedPathname = reroutePathname(\n request,\n normalizeRoutePath(currentUrl.pathname),\n currentUrl.href,\n )\n const match = matchRoute(routes, resolvedPathname)\n if (match?.route.page) {\n return match\n }\n const fallback = findSpecialRoute(routes, resolvedPathname, 'notFound')\n if (fallback?.route.notFound) {\n return fallback\n }\n return null\n }\n\n const getRpcCurrentRoute = (requestContext: AppContext) => {\n const requestUrl = getRequestUrl(requestContext.req.raw)\n const routeUrlHeader = requestContext.req.header(ROUTE_RPC_URL_HEADER)\n if (!routeUrlHeader) {\n return null\n }\n let currentUrl: URL\n try {\n currentUrl = new URL(routeUrlHeader, requestUrl)\n } catch {\n return null\n }\n if (currentUrl.origin !== requestUrl.origin) {\n return null\n }\n return resolveRouteForCurrentUrl(requestContext.req.raw, currentUrl)\n }\n\n const resolveRequest = async <E extends Context>(\n c: E,\n handler: (requestContext: AppContext) => Promise<Response>,\n ) => {\n const requestContext = prepareRequestContext(c)\n const execute = (nextContext = requestContext) =>\n withServerRequestContext(\n nextContext,\n {\n handleError: serverHooks.handleError,\n transport: appHooks.transport,\n },\n () => handler(nextContext),\n )\n\n if (!serverHooks.handle) {\n return execute(requestContext)\n }\n\n return withServerRequestContext(\n requestContext,\n {\n handleError: serverHooks.handleError,\n transport: appHooks.transport,\n },\n () =>\n serverHooks.handle!(requestContext, (nextContext) =>\n execute(nextContext ?? requestContext),\n ),\n )\n }\n\n const loadRouteMiddlewares = async (route: RouteEntry): Promise<MiddlewareHandler[]> =>\n await Promise.all(\n route.middlewares.map(async (middleware) => {\n const mod = await init.runner.import(middleware.filePath)\n if (typeof mod.default !== 'function') {\n throw new TypeError(\n `Route middleware \"${middleware.filePath}\" must default export a middleware function.`,\n )\n }\n return mod.default as MiddlewareHandler\n }),\n )\n\n const composeRouteMiddlewares = async <T>(\n route: RouteEntry,\n c: AppContext,\n params: RouteParams,\n handler: () => Promise<T>,\n ): Promise<T | Response> => {\n applyRequestParams(c, params)\n const middlewares = await loadRouteMiddlewares(route)\n let index = -1\n const dispatch = async (nextIndex: number): Promise<T | Response> => {\n if (nextIndex <= index) {\n throw new Error('Route middleware called next() multiple times.')\n }\n index = nextIndex\n const middleware = middlewares[nextIndex]\n if (!middleware) {\n return handler()\n }\n let nextResult: T | Response | undefined = undefined\n const result = await middleware(c, (async () => {\n nextResult = await dispatch(nextIndex + 1)\n }) as Next)\n if (result !== undefined) {\n return result as Response\n }\n return nextResult as T | Response\n }\n return dispatch(0)\n }\n\n const resolvePreflightTarget = (pathname: string) => {\n const match = matchRoute(routes, pathname)\n if (match?.route.page) {\n return match\n }\n if (!match) {\n const fallback = findSpecialRoute(routes, pathname, 'notFound')\n if (fallback?.route.notFound) {\n return fallback\n }\n }\n return null\n }\n\n const invokeRouteServer = async (filePath: string, c: AppContext, params: RouteParams) => {\n applyRequestParams(c, params)\n const mod = await init.runner.import(filePath)\n const methodHandler = mod[c.req.method] as\n | ((context: AppContext) => Response | Promise<Response>)\n | undefined\n if (typeof methodHandler === 'function') {\n return methodHandler(c)\n }\n const serverApp = mod.default as\n | { fetch?: (request: Request, env?: unknown, ctx?: unknown) => Response | Promise<Response> }\n | undefined\n if (serverApp && typeof serverApp.fetch === 'function') {\n return serverApp.fetch(c.req.raw)\n }\n return c.text('Not Found', 404)\n }\n\n const renderRouteResponse = async (\n route: RouteEntry,\n pathname: string,\n params: RouteParams,\n c: AppContext,\n modulePath: string,\n status = 200,\n options?: {\n prepare?: (container: any) => void | Promise<void>\n routeError?: unknown\n },\n ) => {\n const [\n _primedModules,\n modules,\n { default: SSRRoot },\n {\n escapeJSONScriptText,\n getStreamingResumeBootstrapScriptContent,\n renderSSRStream,\n resolvePendingLoaders,\n serializeResumePayload,\n RESUME_FINAL_STATE_ELEMENT_ID,\n },\n ] = await Promise.all([\n Promise.all([\n fileExists(modulePath).then((exists) =>\n exists ? primeCompilerCache(modulePath) : undefined,\n ),\n ...route.layouts.map((layout) =>\n fileExists(layout.filePath).then((exists) =>\n exists ? primeCompilerCache(layout.filePath) : undefined,\n ),\n ),\n ]),\n Promise.all([\n init.runner.import(modulePath),\n ...route.layouts.map((layout) => init.runner.import(layout.filePath)),\n ]),\n init.runner.import('/app/+ssr-root.tsx'),\n init.runner.import('eclipsa'),\n ])\n const [pageModule, ...layoutModules] = modules as Array<{\n default: (props: unknown) => unknown\n metadata?: RouteMetadataExport\n }>\n const { default: Page } = pageModule\n const Layouts = layoutModules.map((module) => module.default)\n const metadata = composeRouteMetadata(\n [...layoutModules.map((module) => module.metadata ?? null), pageModule.metadata ?? null],\n {\n params,\n url: getRequestUrl(c.req.raw),\n },\n )\n\n const document = jsxDEV(\n SSRRoot as any,\n {\n children: createRouteElement(\n pathname,\n params,\n Page,\n Layouts,\n options?.routeError,\n ) as SSRRootProps['children'],\n head: {\n type: Fragment,\n isStatic: true,\n props: {\n children: [\n ...renderRouteMetadataHead(metadata),\n {\n type: 'script',\n isStatic: true,\n props: {\n children: RESUME_PAYLOAD_PLACEHOLDER,\n id: 'eclipsa-resume',\n type: 'application/eclipsa-resume+json',\n },\n },\n {\n type: 'script',\n isStatic: true,\n props: {\n children: ROUTE_MANIFEST_PLACEHOLDER,\n id: ROUTE_MANIFEST_ELEMENT_ID,\n type: 'application/eclipsa-route-manifest+json',\n },\n },\n {\n type: 'script',\n isStatic: true,\n props: {\n children: APP_HOOKS_PLACEHOLDER,\n id: APP_HOOKS_ELEMENT_ID,\n type: 'application/eclipsa-app-hooks+json',\n },\n },\n {\n type: 'script',\n isStatic: true,\n props: {\n dangerouslySetInnerHTML: getStreamingResumeBootstrapScriptContent(),\n },\n },\n {\n type: 'script',\n isStatic: true,\n props: {\n children: 'import(\"/@vite/client\")',\n },\n },\n {\n type: 'script',\n props: {\n src: '/app/+client.dev.tsx',\n type: 'module',\n },\n },\n ],\n },\n },\n } satisfies SSRRootProps,\n null,\n false,\n {},\n )\n\n applyRequestParams(c, params)\n const { html, payload, chunks } = await renderSSRStream(() => document, {\n prepare(container: any) {\n primeLocationState(container, getRequestUrl(c.req.raw))\n return options?.prepare?.(container)\n },\n resolvePendingLoaders: async (container: any) => resolvePendingLoaders(container, c),\n symbols: symbolUrls,\n })\n const shellHtml = replaceHeadPlaceholder(\n replaceHeadPlaceholder(\n replaceHeadPlaceholder(html, RESUME_PAYLOAD_PLACEHOLDER, serializeResumePayload(payload)),\n ROUTE_MANIFEST_PLACEHOLDER,\n escapeJSONScriptText(JSON.stringify(routeManifest)),\n ),\n APP_HOOKS_PLACEHOLDER,\n escapeJSONScriptText(JSON.stringify(appHooksManifest)),\n )\n const { prefix, suffix } = splitHtmlForStreaming(shellHtml)\n const encoder = new TextEncoder()\n\n return new Response(\n new ReadableStream<Uint8Array>({\n start(controller) {\n controller.enqueue(encoder.encode(prefix))\n void (async () => {\n let latestPayload = payload\n\n for await (const chunk of chunks) {\n latestPayload = chunk.payload\n const templateId = `eclipsa-suspense-template-${chunk.boundaryId}`\n const payloadId = `eclipsa-suspense-payload-${chunk.boundaryId}`\n controller.enqueue(\n encoder.encode(\n `<template id=\"${templateId}\">${chunk.html}</template>` +\n `<script id=\"${payloadId}\" type=\"application/eclipsa-resume+json\">${serializeResumePayload(chunk.payload)}</script>` +\n `<script>window.__eclipsa_stream.enqueue({boundaryId:${JSON.stringify(chunk.boundaryId)},payloadScriptId:${JSON.stringify(payloadId)},templateId:${JSON.stringify(templateId)}})</script>`,\n ),\n )\n }\n\n controller.enqueue(\n encoder.encode(\n `<script id=\"${RESUME_FINAL_STATE_ELEMENT_ID}\" type=\"application/eclipsa-resume+json\">${serializeResumePayload(latestPayload)}</script>${suffix}`,\n ),\n )\n controller.close()\n })().catch((error) => {\n controller.error(error)\n })\n },\n }),\n { status, headers: { 'content-type': 'text/html; charset=utf-8' } },\n )\n }\n\n const renderMatchedPage = async (\n match: { params: RouteParams; route: RouteEntry },\n c: AppContext,\n options?: {\n prepare?: (container: any) => void | Promise<void>\n routeError?: unknown\n },\n ) => {\n const requestUrl = getRequestUrl(c.req.raw)\n const requestPathname = normalizeRoutePath(requestUrl.pathname)\n const resolvedPathname = reroutePathname(c.req.raw, requestPathname, requestUrl.href)\n try {\n return await renderRouteResponse(\n match.route,\n requestPathname,\n match.params,\n c,\n match.route.page!.filePath,\n 200,\n options,\n )\n } catch (error) {\n const publicError = await toPublicErrorValue(init.devServer, serverHooks, c, error, 'page')\n const fallback = isNotFoundError(error)\n ? findSpecialRoute(routes, resolvedPathname, 'notFound')\n : findSpecialRoute(routes, resolvedPathname, 'error')\n const module = fallback?.route[isNotFoundError(error) ? 'notFound' : 'error']\n if (!fallback || !module) {\n return c.text(\n isNotFoundError(error) ? 'Not Found' : 'Internal Server Error',\n isNotFoundError(error) ? 404 : 500,\n )\n }\n return renderRouteResponse(\n fallback.route,\n requestPathname,\n fallback.params,\n c,\n module.filePath,\n isNotFoundError(error) ? 404 : 500,\n {\n ...options,\n routeError: publicError,\n },\n )\n }\n }\n\n const renderRouteDataResponse = async (\n route: RouteEntry,\n pathname: string,\n params: RouteParams,\n c: AppContext,\n modulePath: string,\n kind: RouteDataResponse['kind'],\n ) => {\n const [_primedModules, modules, { renderSSRAsync, resolvePendingLoaders }] = await Promise.all([\n Promise.all([\n fileExists(modulePath).then((exists) =>\n exists ? primeCompilerCache(modulePath) : undefined,\n ),\n ...route.layouts.map((layout) =>\n fileExists(layout.filePath).then((exists) =>\n exists ? primeCompilerCache(layout.filePath) : undefined,\n ),\n ),\n ]),\n Promise.all([\n init.runner.import(modulePath),\n ...route.layouts.map((layout) => init.runner.import(layout.filePath)),\n ]),\n init.runner.import('eclipsa'),\n ])\n const [pageModule, ...layoutModules] = modules as Array<{\n default: (props: unknown) => unknown\n }>\n const { default: Page } = pageModule\n const Layouts = layoutModules.map((module) => module.default)\n\n applyRequestParams(c, params)\n const { payload } = await renderSSRAsync(\n () => createRouteElement(pathname, params, Page, Layouts, undefined),\n {\n prepare(container: any) {\n primeLocationState(container, getRequestUrl(c.req.raw))\n },\n resolvePendingLoaders: async (container: any) => resolvePendingLoaders(container, c),\n symbols: symbolUrls,\n },\n )\n\n return c.json({\n finalHref: getRequestUrl(c.req.raw).href,\n finalPathname: pathname,\n kind,\n loaders: payload.loaders,\n ok: true,\n } satisfies RouteDataResponse)\n }\n\n const renderRouteData = async (\n route: RouteEntry,\n pathname: string,\n params: RouteParams,\n c: AppContext,\n modulePath: string,\n kind: RouteDataResponse['kind'],\n ) => {\n const requestUrl = getRequestUrl(c.req.raw)\n const requestPathname = normalizeRoutePath(requestUrl.pathname)\n const resolvedPathname = reroutePathname(c.req.raw, requestPathname, requestUrl.href)\n try {\n return await renderRouteDataResponse(route, pathname, params, c, modulePath, kind)\n } catch (error) {\n if (!isNotFoundError(error)) {\n return c.json({ document: true, ok: false })\n }\n\n const fallback = findSpecialRoute(routes, resolvedPathname, 'notFound')\n if (!fallback?.route.notFound) {\n return c.json({ document: true, ok: false })\n }\n\n try {\n return await renderRouteDataResponse(\n fallback.route,\n requestPathname,\n fallback.params,\n c,\n fallback.route.notFound.filePath,\n 'not-found',\n )\n } catch {\n return c.json({ document: true, ok: false })\n }\n }\n }\n\n const resolveRouteData = async (href: string, c: AppContext) => {\n const requestUrl = getRequestUrl(c.req.raw)\n const targetUrl = new URL(href, requestUrl)\n if (targetUrl.origin !== requestUrl.origin) {\n return c.json({ document: true, ok: false })\n }\n const headers = new Headers(c.req.raw.headers)\n headers.set(ROUTE_DATA_REQUEST_HEADER, '1')\n const response = await app.fetch(\n new Request(targetUrl.href, {\n headers,\n method: 'GET',\n redirect: 'manual',\n }),\n )\n if (response.status >= 200 && response.status < 300) {\n return response\n }\n if (isRedirectResponse(response)) {\n return c.json({\n location: new URL(response.headers.get('location')!, requestUrl).href,\n ok: false,\n })\n }\n return c.json({ document: true, ok: false })\n }\n\n const resolveRoutePreflight = async (href: string, c: AppContext) => {\n const requestUrl = getRequestUrl(c.req.raw)\n const targetUrl = new URL(href, requestUrl)\n if (targetUrl.origin !== requestUrl.origin) {\n return c.json({ document: true, ok: false })\n }\n\n const target = resolvePreflightTarget(\n reroutePathname(\n new Request(targetUrl.href),\n normalizeRoutePath(targetUrl.pathname),\n targetUrl.href,\n ),\n )\n if (!target) {\n return c.json({ ok: true })\n }\n\n const headers = new Headers(c.req.raw.headers)\n headers.set(ROUTE_PREFLIGHT_REQUEST_HEADER, '1')\n let response: Response\n try {\n response = await c.var.fetch(targetUrl.href, {\n headers,\n redirect: 'manual',\n })\n } catch {\n response = await app.fetch(\n new Request(targetUrl.href, {\n headers,\n method: 'GET',\n redirect: 'manual',\n }),\n )\n }\n\n if (response.status >= 200 && response.status < 300) {\n return c.json({ ok: true })\n }\n if (isRedirectResponse(response)) {\n return c.json({\n location: new URL(response.headers.get('location')!, requestUrl).href,\n ok: false,\n })\n }\n return c.json({ document: true, ok: false })\n }\n\n const resolveRequestRoute = (request: Request, url: string) => {\n const requestPathname = normalizeRoutePath(new URL(url).pathname)\n const resolvedPathname = reroutePathname(request, requestPathname, url)\n return {\n match: matchRoute(routes, resolvedPathname),\n requestPathname,\n resolvedPathname,\n }\n }\n\n app.post('/__eclipsa/action/:id', async (c) =>\n resolveRequest(c, async (requestContext) => {\n const { executeAction, hasAction } = await init.runner.import('eclipsa')\n const id = requestContext.req.param('id')\n if (!id) {\n return requestContext.text('Not Found', 404)\n }\n const routeMatch = getRpcCurrentRoute(requestContext)\n if (!routeMatch) {\n return requestContext.text('Bad Request', 400)\n }\n const routeAccess = getRouteServerAccess(routeMatch.route)\n if (!routeAccess.actionIds.has(id)) {\n return requestContext.text('Not Found', 404)\n }\n const modulePath = actionModules.get(id)\n if (!modulePath) {\n return requestContext.text('Not Found', 404)\n }\n if (!hasAction(id)) {\n await init.runner.import(modulePath)\n }\n return composeRouteMiddlewares(\n routeMatch.route,\n requestContext,\n routeMatch.params,\n async () => executeAction(id, requestContext),\n ) as Promise<Response>\n }),\n )\n\n app.get('/__eclipsa/loader/:id', async (c) =>\n resolveRequest(c, async (requestContext) => {\n const { executeLoader, hasLoader } = await init.runner.import('eclipsa')\n const id = requestContext.req.param('id')\n if (!id) {\n return requestContext.text('Not Found', 404)\n }\n const routeMatch = getRpcCurrentRoute(requestContext)\n if (!routeMatch) {\n return requestContext.text('Bad Request', 400)\n }\n const routeAccess = getRouteServerAccess(routeMatch.route)\n if (!routeAccess.loaderIds.has(id)) {\n return requestContext.text('Not Found', 404)\n }\n const modulePath = loaderModules.get(id)\n if (!modulePath) {\n return requestContext.text('Not Found', 404)\n }\n if (!hasLoader(id)) {\n await init.runner.import(modulePath)\n }\n return composeRouteMiddlewares(\n routeMatch.route,\n requestContext,\n routeMatch.params,\n async () => executeLoader(id, requestContext),\n ) as Promise<Response>\n }),\n )\n\n app.get(ROUTE_PREFLIGHT_ENDPOINT, async (c) =>\n resolveRequest(c, async (requestContext) => {\n const href = requestContext.req.query('href')\n if (!href) {\n return requestContext.json({ document: true, ok: false }, 400)\n }\n return resolveRoutePreflight(href, requestContext)\n }),\n )\n\n app.get(ROUTE_DATA_ENDPOINT, async (c) =>\n resolveRequest(c, async (requestContext) => {\n const href = requestContext.req.query('href')\n if (!href) {\n return requestContext.json({ document: true, ok: false }, 400)\n }\n return resolveRouteData(href, requestContext)\n }),\n )\n\n app.all('*', async (c) =>\n resolveRequest(c, async (requestContext) => {\n const { match, requestPathname, resolvedPathname } = resolveRequestRoute(\n requestContext.req.raw,\n requestContext.req.url,\n )\n\n if (!match) {\n const fallback = findSpecialRoute(routes, resolvedPathname, 'notFound')\n if (fallback?.route.notFound) {\n return composeRouteMiddlewares(\n fallback.route,\n requestContext,\n fallback.params,\n async () =>\n requestContext.req.header(ROUTE_PREFLIGHT_REQUEST_HEADER) === '1'\n ? requestContext.body(null, 204)\n : requestContext.req.header(ROUTE_DATA_REQUEST_HEADER) === '1'\n ? renderRouteData(\n fallback.route,\n requestPathname,\n fallback.params,\n requestContext,\n fallback.route.notFound!.filePath,\n 'not-found',\n )\n : renderRouteResponse(\n fallback.route,\n requestPathname,\n fallback.params,\n requestContext,\n fallback.route.notFound!.filePath,\n 404,\n ),\n )\n }\n return requestContext.text('Not Found', 404)\n }\n\n if (\n (requestContext.req.method === 'GET' || requestContext.req.method === 'HEAD') &&\n match.route.page\n ) {\n const page = match.route.page\n return composeRouteMiddlewares(match.route, requestContext, match.params, async () =>\n requestContext.req.header(ROUTE_PREFLIGHT_REQUEST_HEADER) === '1'\n ? requestContext.body(null, 204)\n : requestContext.req.header(ROUTE_DATA_REQUEST_HEADER) === '1'\n ? renderRouteData(\n match.route,\n requestPathname,\n match.params,\n requestContext,\n page.filePath,\n 'page',\n )\n : renderMatchedPage(match, requestContext),\n )\n }\n\n if (requestContext.req.method === 'POST' && match.route.page) {\n return composeRouteMiddlewares(match.route, requestContext, match.params, async () => {\n const {\n ACTION_CONTENT_TYPE,\n deserializePublicValue,\n executeAction,\n getNormalizedActionInput,\n getActionFormSubmissionId,\n hasAction,\n primeActionState,\n } = await init.runner.import('eclipsa')\n const actionId = await getActionFormSubmissionId(requestContext)\n if (!actionId) {\n return match.route.server\n ? invokeRouteServer(match.route.server.filePath, requestContext, match.params)\n : renderMatchedPage(match, requestContext)\n }\n const routeAccess = getRouteServerAccess(match.route)\n if (!routeAccess.actionIds.has(actionId)) {\n return requestContext.text('Not Found', 404)\n }\n const modulePath = actionModules.get(actionId)\n if (!modulePath) {\n return requestContext.text('Not Found', 404)\n }\n if (!hasAction(actionId)) {\n await init.runner.import(modulePath)\n }\n const input = await getNormalizedActionInput(requestContext)\n const response = await executeAction(actionId, requestContext)\n const contentType = response.headers.get('content-type') ?? ''\n if (!contentType.startsWith(ACTION_CONTENT_TYPE)) {\n return response\n }\n const body = (await response.json()) as\n | { error: unknown; ok: false }\n | { ok: true; value: unknown }\n return renderMatchedPage(match, requestContext, {\n prepare(container) {\n primeActionState(container, actionId, {\n error: body.ok ? undefined : deserializePublicValue(body.error as any),\n input,\n result: body.ok ? deserializePublicValue(body.value as any) : undefined,\n })\n },\n })\n })\n }\n\n if (match.route.server) {\n return composeRouteMiddlewares(match.route, requestContext, match.params, async () =>\n invokeRouteServer(match.route.server!.filePath, requestContext, match.params),\n )\n }\n\n if (match.route.page) {\n return composeRouteMiddlewares(match.route, requestContext, match.params, async () =>\n requestContext.req.header(ROUTE_PREFLIGHT_REQUEST_HEADER) === '1'\n ? requestContext.body(null, 204)\n : renderMatchedPage(match, requestContext),\n )\n }\n\n return requestContext.text('Not Found', 404)\n }),\n )\n\n return app\n}\n\nexport const createDevFetch = (init: DevAppInit): DevFetchController => {\n let app: ReturnType<typeof createDevApp> | null = null\n const getApp = () => {\n app ??= createDevApp(init)\n return app\n }\n\n return {\n invalidate() {\n app = null\n },\n async fetch(req) {\n const fetched = await (await getApp()).fetch(req)\n if (fetched.status === 404) {\n return\n }\n return fetched\n },\n }\n}\n","import type { IncomingMessage, ServerResponse } from 'node:http'\n\nexport const incomingMessageToRequest = (incomingMessage: IncomingMessage): Request => {\n const body =\n incomingMessage.method !== 'GET' && incomingMessage.method !== 'HEAD'\n ? new ReadableStream<Uint8Array>({\n start(controller) {\n incomingMessage.on('data', (chunk) => {\n controller.enqueue(new Uint8Array(chunk))\n })\n incomingMessage.on('end', () => {\n controller.close()\n })\n },\n })\n : null\n const headers = new Headers()\n for (const [k, v] of Object.entries(incomingMessage.headers)) {\n if (Array.isArray(v)) {\n for (const value of v) {\n headers.append(k, value)\n }\n } else if (v) {\n headers.append(k, v)\n }\n }\n const init: RequestInit & { duplex?: 'half' } = {\n headers,\n method: incomingMessage.method,\n }\n if (body) {\n init.body = body\n init.duplex = 'half'\n }\n return new Request(new URL(incomingMessage.url ?? '', 'http://localhost'), init)\n}\n\nexport const responseForServerResponse = async (res: Response, serverRes: ServerResponse) => {\n for (const [k, v] of res.headers) {\n serverRes.setHeader(k, v)\n }\n serverRes.statusCode = res.status\n serverRes.statusMessage = res.statusText\n\n const buffer = Buffer.from(await res.arrayBuffer())\n serverRes.end(buffer)\n}\n","/*!\n * MIT License\n * Copyright (c) 2019 Jason Dent\n * https://github.com/Jason3S/xxhash/blob/028d9be1854b44f1afd79539e4da8c55c732ca05/LICENSE\n *\n * Source: https://github.com/Jason3S/xxhash/blob/028d9be1854b44f1afd79539e4da8c55c732ca05/src/xxHash32.ts\n */\nconst PRIME32_1 = 2654435761\nconst PRIME32_2 = 2246822519\nconst PRIME32_3 = 3266489917\nconst PRIME32_4 = 668265263\nconst PRIME32_5 = 374761393\n\nlet encoder: TextEncoder | undefined\n\n/**\n *\n * @param input - byte array or string\n * @param seed - optional seed (32-bit unsigned);\n */\nexport function xxHash32(input: Uint8Array | string, seed = 0): number {\n const buffer = typeof input === 'string' ? (encoder ??= new TextEncoder()).encode(input) : input\n const b = buffer\n\n /*\n Step 1. Initialize internal accumulators\n Each accumulator gets an initial value based on optional seed input. Since the seed is optional, it can be 0.\n\n ```\n u32 acc1 = seed + PRIME32_1 + PRIME32_2;\n u32 acc2 = seed + PRIME32_2;\n u32 acc3 = seed + 0;\n u32 acc4 = seed - PRIME32_1;\n ```\n Special case : input is less than 16 bytes\n When input is too small (< 16 bytes), the algorithm will not process any stripe. Consequently, it will not\n make use of parallel accumulators.\n\n In which case, a simplified initialization is performed, using a single accumulator :\n\n u32 acc = seed + PRIME32_5;\n The algorithm then proceeds directly to step 4.\n */\n\n let acc = (seed + PRIME32_5) & 0xffffffff\n let offset = 0\n\n if (b.length >= 16) {\n const accN = [\n (seed + PRIME32_1 + PRIME32_2) & 0xffffffff,\n (seed + PRIME32_2) & 0xffffffff,\n (seed + 0) & 0xffffffff,\n (seed - PRIME32_1) & 0xffffffff,\n ]\n\n /*\n Step 2. Process stripes\n A stripe is a contiguous segment of 16 bytes. It is evenly divided into 4 lanes, of 4 bytes each.\n The first lane is used to update accumulator 1, the second lane is used to update accumulator 2, and so on.\n\n Each lane read its associated 32-bit value using little-endian convention.\n\n For each {lane, accumulator}, the update process is called a round, and applies the following formula :\n\n ```\n accN = accN + (laneN * PRIME32_2);\n accN = accN <<< 13;\n accN = accN * PRIME32_1;\n ```\n\n This shuffles the bits so that any bit from input lane impacts several bits in output accumulator.\n All operations are performed modulo 2^32.\n\n Input is consumed one full stripe at a time. Step 2 is looped as many times as necessary to consume\n the whole input, except the last remaining bytes which cannot form a stripe (< 16 bytes). When that\n happens, move to step 3.\n */\n\n const b = buffer\n const limit = b.length - 16\n let lane = 0\n for (offset = 0; (offset & 0xfffffff0) <= limit; offset += 4) {\n const i = offset\n const laneN0 = b[i + 0] + (b[i + 1] << 8)\n const laneN1 = b[i + 2] + (b[i + 3] << 8)\n const laneNP = laneN0 * PRIME32_2 + ((laneN1 * PRIME32_2) << 16)\n let acc = (accN[lane] + laneNP) & 0xffffffff\n acc = (acc << 13) | (acc >>> 19)\n const acc0 = acc & 0xffff\n const acc1 = acc >>> 16\n accN[lane] = (acc0 * PRIME32_1 + ((acc1 * PRIME32_1) << 16)) & 0xffffffff\n lane = (lane + 1) & 0x3\n }\n\n /*\n Step 3. Accumulator convergence\n All 4 lane accumulators from previous steps are merged to produce a single remaining accumulator\n of same width (32-bit). The associated formula is as follows :\n\n ```\n acc = (acc1 <<< 1) + (acc2 <<< 7) + (acc3 <<< 12) + (acc4 <<< 18);\n ```\n */\n acc =\n (((accN[0] << 1) | (accN[0] >>> 31)) +\n ((accN[1] << 7) | (accN[1] >>> 25)) +\n ((accN[2] << 12) | (accN[2] >>> 20)) +\n ((accN[3] << 18) | (accN[3] >>> 14))) &\n 0xffffffff\n }\n\n /*\n Step 4. Add input length\n The input total length is presumed known at this stage. This step is just about adding the length to\n accumulator, so that it participates to final mixing.\n\n ```\n acc = acc + (u32)inputLength;\n ```\n */\n acc = (acc + buffer.length) & 0xffffffff\n\n /*\n Step 5. Consume remaining input\n There may be up to 15 bytes remaining to consume from the input. The final stage will digest them according\n to following pseudo-code :\n ```\n while (remainingLength >= 4) {\n lane = read_32bit_little_endian(input_ptr);\n acc = acc + lane * PRIME32_3;\n acc = (acc <<< 17) * PRIME32_4;\n input_ptr += 4; remainingLength -= 4;\n }\n ```\n This process ensures that all input bytes are present in the final mix.\n */\n\n const limit = buffer.length - 4\n for (; offset <= limit; offset += 4) {\n const i = offset\n const laneN0 = b[i + 0] + (b[i + 1] << 8)\n const laneN1 = b[i + 2] + (b[i + 3] << 8)\n const laneP = laneN0 * PRIME32_3 + ((laneN1 * PRIME32_3) << 16)\n acc = (acc + laneP) & 0xffffffff\n acc = (acc << 17) | (acc >>> 15)\n acc = ((acc & 0xffff) * PRIME32_4 + (((acc >>> 16) * PRIME32_4) << 16)) & 0xffffffff\n }\n\n /*\n ```\n while (remainingLength >= 1) {\n lane = read_byte(input_ptr);\n acc = acc + lane * PRIME32_5;\n acc = (acc <<< 11) * PRIME32_1;\n input_ptr += 1; remainingLength -= 1;\n }\n ```\n */\n\n for (; offset < b.length; ++offset) {\n const lane = b[offset]\n acc = acc + lane * PRIME32_5\n acc = (acc << 11) | (acc >>> 21)\n acc = ((acc & 0xffff) * PRIME32_1 + (((acc >>> 16) * PRIME32_1) << 16)) & 0xffffffff\n }\n\n /*\n Step 6. Final mix (avalanche)\n The final mix ensures that all input bits have a chance to impact any bit in the output digest,\n resulting in an unbiased distribution. This is also called avalanche effect.\n ```\n acc = acc xor (acc >> 15);\n acc = acc * PRIME32_2;\n acc = acc xor (acc >> 13);\n acc = acc * PRIME32_3;\n acc = acc xor (acc >> 16);\n ```\n */\n\n acc = acc ^ (acc >>> 15)\n acc = (((acc & 0xffff) * PRIME32_2) & 0xffffffff) + (((acc >>> 16) * PRIME32_2) << 16)\n acc = acc ^ (acc >>> 13)\n acc = (((acc & 0xffff) * PRIME32_3) & 0xffffffff) + (((acc >>> 16) * PRIME32_3) << 16)\n acc = acc ^ (acc >>> 16)\n\n // turn any negatives back into a positive number;\n return acc < 0 ? acc + 4294967296 : acc\n}\n","import { toSSG } from 'hono/ssg'\nimport type { UserConfig, ViteBuilder } from 'vite'\nimport * as fs from 'node:fs/promises'\nimport * as path from 'node:path'\nimport { cwd } from 'node:process'\nimport { pathToFileURL } from 'node:url'\nimport type {\n GetStaticPaths,\n RouteManifest,\n RouteParams,\n RoutePathSegment,\n StaticPath,\n} from '../../core/router-shared.ts'\nimport {\n ROUTE_DATA_ENDPOINT,\n ROUTE_DATA_REQUEST_HEADER,\n ROUTE_MANIFEST_ELEMENT_ID,\n ROUTE_PREFLIGHT_ENDPOINT,\n ROUTE_RPC_URL_HEADER,\n} from '../../core/router-shared.ts'\nimport {\n createBuildModuleUrl,\n createBuildServerModuleUrl,\n createRouteManifest,\n normalizeRoutePath,\n createRoutes,\n} from '../utils/routing.ts'\nimport {\n collectAppActions,\n collectAppLoaders,\n collectAppSymbols,\n collectReachableAnalyzableFiles,\n createBuildServerActionUrl,\n createBuildServerLoaderUrl,\n createBuildSymbolUrl,\n} from '../compiler.ts'\nimport type { ResolvedEclipsaPluginOptions } from '../options.ts'\nimport { xxHash32 } from '../../utils/xxhash32.ts'\n\nconst joinHonoPath = (left: string, right: string) => `${left}/${right}`.replaceAll(/\\/+/g, '/')\nconst CHUNK_CACHE_NAME_PREFIX = 'eclipsa-chunk-cache'\nconst CHUNK_CACHE_SW_URL = '/eclipsa-chunk-cache-sw.js'\nconst CHUNK_CACHEABLE_PATH_PREFIXES = ['/chunks/', '/entries/']\n\nconst toPublicAssetUrl = (root: string, filePath: string) =>\n `/${path.relative(root, filePath).split(path.sep).join('/')}`\n\nconst fileExists = async (filePath: string) => {\n try {\n await fs.access(filePath)\n return true\n } catch {\n return false\n }\n}\n\nconst collectFiles = async (directory: string): Promise<string[]> => {\n const entries = await fs.readdir(directory, { withFileTypes: true })\n const files = await Promise.all(\n entries.map(async (entry) => {\n const entryPath = path.join(directory, entry.name)\n return entry.isDirectory() ? collectFiles(entryPath) : [entryPath]\n }),\n )\n return files.flat()\n}\n\nconst collectClientStylesheetUrls = async (clientDir: string) => {\n try {\n const files = await collectFiles(clientDir)\n return files\n .filter((filePath) => path.extname(filePath) === '.css')\n .sort()\n .map((filePath) => toPublicAssetUrl(clientDir, filePath))\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return []\n }\n throw error\n }\n}\n\ninterface ClientChunkCacheAsset {\n hash: string\n url: string\n}\n\nconst collectClientChunkCacheAssets = async (\n clientDir: string,\n): Promise<ClientChunkCacheAsset[]> => {\n try {\n const files = await collectFiles(clientDir)\n const assetFiles = files\n .filter((filePath) => path.extname(filePath) === '.js')\n .map((filePath) => ({\n filePath,\n url: toPublicAssetUrl(clientDir, filePath),\n }))\n .filter((entry) =>\n CHUNK_CACHEABLE_PATH_PREFIXES.some((prefix) => entry.url.startsWith(prefix)),\n )\n .sort((left, right) => left.url.localeCompare(right.url))\n\n return Promise.all(\n assetFiles.map(async (asset) => ({\n hash: xxHash32(await fs.readFile(asset.filePath))\n .toString(16)\n .padStart(8, '0'),\n url: asset.url,\n })),\n )\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return []\n }\n throw error\n }\n}\n\nconst createClientChunkCacheVersion = (assets: ClientChunkCacheAsset[]) =>\n xxHash32(assets.map((asset) => `${asset.url}:${asset.hash}`).join('\\n'))\n .toString(16)\n .padStart(8, '0')\n\nconst renderChunkCacheServiceWorker = (\n version: string,\n) => `const CACHE_NAME = \"${CHUNK_CACHE_NAME_PREFIX}-${version}\";\nconst CACHE_PREFIX = \"${CHUNK_CACHE_NAME_PREFIX}-\";\nconst PATH_PREFIXES = ${JSON.stringify(CHUNK_CACHEABLE_PATH_PREFIXES)};\nconst PRECACHE_MESSAGE_TYPE = \"eclipsa:chunk-cache-precache\";\nconst pendingPrecacheUrls = new Set();\n\nconst isCacheableRequest = (request) => {\n if (request.method !== \"GET\") {\n return false;\n }\n const url = new URL(request.url);\n return url.origin === self.location.origin && PATH_PREFIXES.some((prefix) => url.pathname.startsWith(prefix));\n};\n\nconst fetchAndCache = async (cache, request) => {\n const response = await fetch(request);\n if (response.ok && (response.type === \"basic\" || response.type === \"cors\")) {\n await cache.put(request, response.clone());\n }\n return response;\n};\n\nconst precacheUrl = async (cache, url) => {\n if (pendingPrecacheUrls.has(url)) {\n return;\n }\n pendingPrecacheUrls.add(url);\n try {\n const request = new Request(new URL(url, self.location.origin).href, {\n credentials: \"same-origin\",\n });\n if (await cache.match(request)) {\n return;\n }\n await fetchAndCache(cache, request);\n } finally {\n pendingPrecacheUrls.delete(url);\n }\n};\n\nconst precacheUrls = async (priorityUrls, urls) => {\n const cache = await caches.open(CACHE_NAME);\n const queue = [...new Set([...priorityUrls, ...urls])].filter((url) =>\n PATH_PREFIXES.some((prefix) => {\n const pathname = new URL(url, self.location.origin).pathname;\n return pathname.startsWith(prefix);\n }),\n );\n for (const url of queue) {\n await precacheUrl(cache, url);\n }\n};\n\nself.addEventListener(\"install\", (event) => {\n event.waitUntil(self.skipWaiting());\n});\n\nself.addEventListener(\"activate\", (event) => {\n event.waitUntil((async () => {\n const names = await caches.keys();\n await Promise.all(\n names\n .filter((name) => name.startsWith(CACHE_PREFIX) && name !== CACHE_NAME)\n .map((name) => caches.delete(name)),\n );\n await self.clients.claim();\n })());\n});\n\nself.addEventListener(\"fetch\", (event) => {\n if (!isCacheableRequest(event.request)) {\n return;\n }\n\n event.respondWith((async () => {\n const cache = await caches.open(CACHE_NAME);\n const cached = await cache.match(event.request);\n if (cached) {\n event.waitUntil(fetchAndCache(cache, event.request).catch(() => undefined));\n return cached;\n }\n\n try {\n return await fetchAndCache(cache, event.request);\n } catch (error) {\n const fallback = await cache.match(event.request);\n if (fallback) {\n return fallback;\n }\n throw error;\n }\n })());\n});\n\nself.addEventListener(\"message\", (event) => {\n const data = event.data;\n if (!data || data.type !== PRECACHE_MESSAGE_TYPE) {\n return;\n }\n\n event.waitUntil(\n precacheUrls(\n Array.isArray(data.priorityUrls) ? data.priorityUrls : [],\n Array.isArray(data.urls) ? data.urls : [],\n ),\n );\n});\n`\n\nconst writeClientChunkCacheServiceWorker = async (\n clientDir: string,\n assets: ClientChunkCacheAsset[],\n) => {\n const version = createClientChunkCacheVersion(assets)\n const serviceWorkerPath = path.join(clientDir, CHUNK_CACHE_SW_URL.slice(1))\n await fs.mkdir(path.dirname(serviceWorkerPath), { recursive: true })\n await fs.writeFile(serviceWorkerPath, renderChunkCacheServiceWorker(version))\n}\n\nconst resolveRouteRenderMode = (\n route: Awaited<ReturnType<typeof createRoutes>>[number],\n output: ResolvedEclipsaPluginOptions['output'],\n) => route.renderMode ?? (output === 'ssg' ? 'static' : 'dynamic')\n\nexport const toHonoRoutePaths = (segments: RoutePathSegment[]) => {\n let paths = ['']\n\n for (const segment of segments) {\n switch (segment.kind) {\n case 'static':\n paths = paths.map((currentPath) => joinHonoPath(currentPath, segment.value))\n break\n case 'required':\n paths = paths.map((currentPath) => joinHonoPath(currentPath, `:${segment.value}`))\n break\n case 'optional':\n paths = paths.flatMap((currentPath) => [\n currentPath,\n joinHonoPath(currentPath, `:${segment.value}`),\n ])\n break\n case 'rest':\n paths = paths.map((currentPath) => joinHonoPath(currentPath, `:${segment.value}{.+}`))\n break\n }\n }\n\n return [...new Set(paths.map((currentPath) => (currentPath === '' ? '/' : currentPath)))]\n}\n\ninterface ResolvedStaticPathInfo {\n concretePath: string\n honoParams: Record<string, string>\n honoPatternPath: string\n}\n\ninterface ResolvedStaticPrerenderTargets {\n concretePaths: Set<string>\n dynamicParamsByPattern: Map<string, Record<string, string>[]>\n}\n\nconst createStaticPathsError = (routePath: string, message: string) =>\n new Error(`Invalid getStaticPaths() for route ${routePath}: ${message}`)\n\nconst validatePathSegmentValue = (\n routePath: string,\n paramName: string,\n value: string,\n kind: 'optional' | 'required' | 'rest',\n) => {\n if (value.length === 0) {\n throw createStaticPathsError(routePath, `${kind} param \"${paramName}\" must not be empty.`)\n }\n if (value.includes('/')) {\n throw createStaticPathsError(routePath, `${kind} param \"${paramName}\" must not contain \"/\".`)\n }\n}\n\nexport const resolveStaticPathInfo = (\n routePath: string,\n segments: RoutePathSegment[],\n params: RouteParams,\n): ResolvedStaticPathInfo => {\n const allowedParams = new Set(\n segments.filter((segment) => segment.kind !== 'static').map((segment) => segment.value),\n )\n\n for (const key of Object.keys(params)) {\n if (!allowedParams.has(key)) {\n throw createStaticPathsError(routePath, `unknown param \"${key}\".`)\n }\n }\n\n const concreteSegments: string[] = []\n const honoPatternSegments: string[] = []\n const honoParams: Record<string, string> = {}\n\n for (const segment of segments) {\n switch (segment.kind) {\n case 'static':\n concreteSegments.push(segment.value)\n honoPatternSegments.push(segment.value)\n break\n case 'required': {\n const value = params[segment.value]\n if (typeof value !== 'string') {\n throw createStaticPathsError(\n routePath,\n `required param \"${segment.value}\" must be a string.`,\n )\n }\n validatePathSegmentValue(routePath, segment.value, value, 'required')\n concreteSegments.push(value)\n honoPatternSegments.push(`:${segment.value}`)\n honoParams[segment.value] = value\n break\n }\n case 'optional': {\n const value = params[segment.value]\n if (value === undefined) {\n break\n }\n if (typeof value !== 'string') {\n throw createStaticPathsError(\n routePath,\n `optional param \"${segment.value}\" must be a string when provided.`,\n )\n }\n validatePathSegmentValue(routePath, segment.value, value, 'optional')\n concreteSegments.push(value)\n honoPatternSegments.push(`:${segment.value}`)\n honoParams[segment.value] = value\n break\n }\n case 'rest': {\n const value = params[segment.value]\n if (!Array.isArray(value)) {\n throw createStaticPathsError(\n routePath,\n `rest param \"${segment.value}\" must be a string array.`,\n )\n }\n if (value.length === 0) {\n throw createStaticPathsError(\n routePath,\n `rest param \"${segment.value}\" must contain at least one segment.`,\n )\n }\n for (const part of value) {\n if (typeof part !== 'string') {\n throw createStaticPathsError(\n routePath,\n `rest param \"${segment.value}\" must only contain strings.`,\n )\n }\n validatePathSegmentValue(routePath, segment.value, part, 'rest')\n }\n concreteSegments.push(...value)\n honoPatternSegments.push(`:${segment.value}{.+}`)\n honoParams[segment.value] = value.join('/')\n break\n }\n }\n }\n\n return {\n concretePath: normalizeRoutePath(concreteSegments.join('/')),\n honoParams,\n honoPatternPath: normalizeRoutePath(honoPatternSegments.join('/')),\n }\n}\n\nconst resolveBuiltPageModulePath = (root: string, entryName: string) =>\n path.join(root, 'dist', 'ssr', 'entries', `${entryName}.mjs`)\n\nconst loadBuiltGetStaticPaths = async (root: string, entryName: string, routePath: string) => {\n const modulePath = resolveBuiltPageModulePath(root, entryName)\n const mod = (await import(`${pathToFileURL(modulePath).href}?t=${Date.now()}`)) as Partial<{\n getStaticPaths: GetStaticPaths\n }>\n if (typeof mod.getStaticPaths !== 'function') {\n throw createStaticPathsError(routePath, 'dynamic static routes must export getStaticPaths().')\n }\n return mod.getStaticPaths\n}\n\nconst validateStaticPathsResult = (routePath: string, value: unknown): StaticPath[] => {\n if (!Array.isArray(value)) {\n throw createStaticPathsError(routePath, 'getStaticPaths() must return an array.')\n }\n return value as StaticPath[]\n}\n\nconst resolveStaticPrerenderTargets = async (\n root: string,\n routes: Array<Awaited<ReturnType<typeof createRoutes>>[number]>,\n): Promise<ResolvedStaticPrerenderTargets> => {\n const concretePaths = new Set<string>()\n const dynamicParamsByPattern = new Map<string, Record<string, string>[]>()\n const ownersByConcretePath = new Map<string, string>()\n\n const registerConcretePath = (routePath: string, concretePath: string) => {\n const existingOwner = ownersByConcretePath.get(concretePath)\n if (existingOwner) {\n throw createStaticPathsError(\n routePath,\n `duplicate concrete path \"${concretePath}\" conflicts with ${existingOwner}.`,\n )\n }\n ownersByConcretePath.set(concretePath, routePath)\n }\n\n for (const route of routes) {\n if (!route.page) {\n continue\n }\n\n const hasDynamicSegment = route.segments.some((segment) => segment.kind !== 'static')\n if (!hasDynamicSegment) {\n registerConcretePath(route.routePath, route.routePath)\n concretePaths.add(route.routePath)\n continue\n }\n\n const getStaticPaths = await loadBuiltGetStaticPaths(\n root,\n route.page.entryName,\n route.routePath,\n )\n const staticPaths = validateStaticPathsResult(route.routePath, await getStaticPaths())\n\n for (const [index, staticPath] of staticPaths.entries()) {\n if (!staticPath || typeof staticPath !== 'object') {\n throw createStaticPathsError(route.routePath, `entry ${index} must be an object.`)\n }\n if (\n !('params' in staticPath) ||\n !staticPath.params ||\n typeof staticPath.params !== 'object' ||\n Array.isArray(staticPath.params)\n ) {\n throw createStaticPathsError(\n route.routePath,\n `entry ${index} must include a params object.`,\n )\n }\n\n const resolved = resolveStaticPathInfo(route.routePath, route.segments, staticPath.params)\n registerConcretePath(route.routePath, resolved.concretePath)\n\n if (resolved.honoPatternPath === resolved.concretePath) {\n concretePaths.add(resolved.concretePath)\n continue\n }\n\n const params = dynamicParamsByPattern.get(resolved.honoPatternPath) ?? []\n params.push(resolved.honoParams)\n dynamicParamsByPattern.set(resolved.honoPatternPath, params)\n }\n }\n\n return {\n concretePaths,\n dynamicParamsByPattern,\n }\n}\n\nconst createSerializedRoutes = (routes: Awaited<ReturnType<typeof createRoutes>>) =>\n JSON.stringify(\n routes.map((route) => ({\n error: route.error ? createBuildServerModuleUrl(route.error) : null,\n layouts: route.layouts.map((layout) => createBuildServerModuleUrl(layout)),\n loading: route.loading ? createBuildServerModuleUrl(route.loading) : null,\n middlewares: route.middlewares.map((middleware) => createBuildServerModuleUrl(middleware)),\n notFound: route.notFound ? createBuildServerModuleUrl(route.notFound) : null,\n page: route.page ? createBuildServerModuleUrl(route.page) : null,\n routePath: route.routePath,\n segments: route.segments,\n server: route.server ? createBuildServerModuleUrl(route.server) : null,\n })),\n )\n\nconst toIdsByFilePath = (entries: ReadonlyArray<{ filePath: string; id: string }>) => {\n const idsByFilePath = new Map<string, string[]>()\n for (const entry of entries) {\n const existing = idsByFilePath.get(entry.filePath)\n if (existing) {\n existing.push(entry.id)\n continue\n }\n idsByFilePath.set(entry.filePath, [entry.id])\n }\n return idsByFilePath\n}\n\nconst getRouteReachableEntryFiles = (route: Awaited<ReturnType<typeof createRoutes>>[number]) =>\n [\n route.error?.filePath,\n ...route.layouts.map((layout) => layout.filePath),\n route.loading?.filePath,\n route.notFound?.filePath,\n route.page?.filePath,\n ].filter((filePath): filePath is string => typeof filePath === 'string')\n\nconst createRouteServerAccessEntries = async (\n routes: Awaited<ReturnType<typeof createRoutes>>,\n actions: ReadonlyArray<{ filePath: string; id: string }>,\n loaders: ReadonlyArray<{ filePath: string; id: string }>,\n) => {\n const actionIdsByFilePath = toIdsByFilePath(actions)\n const loaderIdsByFilePath = toIdsByFilePath(loaders)\n\n return await Promise.all(\n routes.map(async (route) => {\n const reachableFiles = await collectReachableAnalyzableFiles(\n getRouteReachableEntryFiles(route),\n )\n return {\n actionIds: reachableFiles.flatMap((filePath) => actionIdsByFilePath.get(filePath) ?? []),\n loaderIds: reachableFiles.flatMap((filePath) => loaderIdsByFilePath.get(filePath) ?? []),\n }\n }),\n )\n}\n\nconst createActionTable = (actions: Array<{ filePath: string; id: string }>) =>\n actions\n .map(\n (action) =>\n ` ${JSON.stringify(action.id)}: ${JSON.stringify(createBuildServerActionUrl(action.id))},`,\n )\n .join('\\n')\n\nconst createLoaderTable = (loaders: Array<{ filePath: string; id: string }>) =>\n loaders\n .map(\n (loader) =>\n ` ${JSON.stringify(loader.id)}: ${JSON.stringify(createBuildServerLoaderUrl(loader.id))},`,\n )\n .join('\\n')\n\nconst createPageRouteEntries = (routes: Awaited<ReturnType<typeof createRoutes>>) =>\n routes.flatMap((route, routeIndex) =>\n route.page\n ? toHonoRoutePaths(route.segments).map((honoPath) => ({\n path: honoPath,\n routeIndex,\n }))\n : [],\n )\n\nconst renderAppModule = (\n actions: Array<{ filePath: string; id: string }>,\n appHooksClientUrl: string | null,\n appHooksServerUrl: string | null,\n loaders: Array<{ filePath: string; id: string }>,\n routes: Awaited<ReturnType<typeof createRoutes>>,\n routeServerAccessEntries: Array<{ actionIds: string[]; loaderIds: string[] }>,\n routeManifest: RouteManifest,\n serverHooksUrl: string | null,\n symbolUrls: Record<string, string>,\n stylesheetUrls: string[],\n chunkCacheUrls: string[],\n) => {\n const serializedRoutes = createSerializedRoutes(routes)\n const serializedPageRouteEntries = JSON.stringify(createPageRouteEntries(routes))\n const actionTable = createActionTable(actions)\n const loaderTable = createLoaderTable(loaders)\n const serializedAppHooksManifest = JSON.stringify({\n client: appHooksClientUrl,\n })\n const serializedRouteServerAccessEntries = JSON.stringify(routeServerAccessEntries)\n const serializedAppHooksServerUrl = JSON.stringify(appHooksServerUrl)\n const serializedSymbolUrls = JSON.stringify(symbolUrls)\n const serializedRouteManifest = JSON.stringify(routeManifest)\n const serializedServerHooksUrl = JSON.stringify(serverHooksUrl)\n const serializedStylesheetUrls = JSON.stringify(stylesheetUrls)\n const serializedChunkCacheUrls = JSON.stringify(chunkCacheUrls)\n\n return `import userApp from \"./entries/server_entry.mjs\";\nimport SSRRoot from \"./entries/ssr_root.mjs\";\nimport { ACTION_CONTENT_TYPE, APP_HOOKS_ELEMENT_ID, Fragment, RESUME_FINAL_STATE_ELEMENT_ID, attachRequestFetch, composeRouteMetadata, createRequestFetch, deserializePublicValue, escapeInlineScriptText, escapeJSONScriptText, executeAction, executeLoader, getActionFormSubmissionId, getNormalizedActionInput, getStreamingResumeBootstrapScriptContent, hasAction, hasLoader, jsxDEV, markPublicError, primeActionState, primeLocationState, renderRouteMetadataHead, renderSSRAsync, renderSSRStream, resolvePendingLoaders, resolveReroute, runHandleError, serializeResumePayload, withServerRequestContext } from \"./entries/eclipsa_runtime.mjs\";\n\nconst app = userApp;\nconst actions = {\n${actionTable}\n};\nconst loaders = {\n${loaderTable}\n};\nconst routes = ${serializedRoutes};\nconst routeServerAccessEntries = ${serializedRouteServerAccessEntries};\nconst pageRouteEntries = ${serializedPageRouteEntries};\nconst appHooksManifest = ${serializedAppHooksManifest};\nconst appHooksServerUrl = ${serializedAppHooksServerUrl};\nconst routeManifest = ${serializedRouteManifest};\nconst serverHooksUrl = ${serializedServerHooksUrl};\nconst symbolUrls = ${serializedSymbolUrls};\nconst stylesheetUrls = ${serializedStylesheetUrls};\nconst chunkCacheUrls = ${serializedChunkCacheUrls};\nconst RESUME_PAYLOAD_PLACEHOLDER = ${JSON.stringify('__ECLIPSA_RESUME_PAYLOAD__')};\nconst APP_HOOKS_PLACEHOLDER = ${JSON.stringify('__ECLIPSA_APP_HOOKS__')};\nconst CHUNK_CACHE_PLACEHOLDER = ${JSON.stringify('__ECLIPSA_CHUNK_CACHE__')};\nconst ROUTE_MANIFEST_PLACEHOLDER = ${JSON.stringify('__ECLIPSA_ROUTE_MANIFEST__')};\nconst ROUTE_PARAMS_PROP = \"__eclipsa_route_params\";\nconst ROUTE_ERROR_PROP = \"__eclipsa_route_error\";\nconst ROUTE_DATA_REQUEST_HEADER = ${JSON.stringify(ROUTE_DATA_REQUEST_HEADER)};\nconst ROUTE_PREFLIGHT_REQUEST_HEADER = \"x-eclipsa-route-preflight\";\nconst CHUNK_CACHE_MESSAGE_TYPE = \"eclipsa:chunk-cache-precache\";\nconst hooksPromise = (async () => {\n const appHooks = appHooksServerUrl ? await import(appHooksServerUrl) : {};\n const serverHooks = serverHooksUrl ? await import(serverHooksUrl) : {};\n await serverHooks.init?.();\n return { appHooks, serverHooks };\n})();\n\nconst normalizeRoutePath = (pathname) => {\n const normalizedPath = pathname.trim() || \"/\";\n const withLeadingSlash = normalizedPath.startsWith(\"/\") ? normalizedPath : \"/\" + normalizedPath;\n return withLeadingSlash.length > 1 && withLeadingSlash.endsWith(\"/\")\n ? withLeadingSlash.slice(0, -1)\n : withLeadingSlash;\n};\n\nconst getRequestUrl = (request) => {\n const url = new URL(request.url);\n const host = request.headers.get(\"x-forwarded-host\") ?? request.headers.get(\"host\");\n const proto = request.headers.get(\"x-forwarded-proto\");\n if (host) {\n url.host = host;\n }\n if (proto) {\n url.protocol = proto + \":\";\n }\n return url;\n};\n\nconst matchSegments = (segments, pathnameSegments, routeIndex = 0, pathIndex = 0, params = {}) => {\n if (routeIndex >= segments.length) {\n return pathIndex >= pathnameSegments.length ? params : null;\n }\n\n const segment = segments[routeIndex];\n switch (segment.kind) {\n case \"static\":\n if (pathnameSegments[pathIndex] !== segment.value) {\n return null;\n }\n return matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex + 1, params);\n case \"required\":\n if (pathIndex >= pathnameSegments.length) {\n return null;\n }\n return matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex + 1, {\n ...params,\n [segment.value]: pathnameSegments[pathIndex],\n });\n case \"optional\": {\n const consumed =\n pathIndex < pathnameSegments.length\n ? matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex + 1, {\n ...params,\n [segment.value]: pathnameSegments[pathIndex],\n })\n : null;\n if (consumed) {\n return consumed;\n }\n return matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex, {\n ...params,\n [segment.value]: undefined,\n });\n }\n case \"rest\": {\n const rest = pathnameSegments.slice(pathIndex);\n if (rest.length === 0) {\n return null;\n }\n return matchSegments(segments, pathnameSegments, segments.length, pathnameSegments.length, {\n ...params,\n [segment.value]: rest,\n });\n }\n }\n};\n\nconst matchRoute = (pathname) => {\n const pathnameSegments = normalizeRoutePath(pathname).split(\"/\").filter(Boolean);\n for (const route of routes) {\n const params = matchSegments(route.segments, pathnameSegments);\n if (params) {\n return { params, route };\n }\n }\n return null;\n};\n\nconst matchRouteManifestEntry = (pathname) => {\n const pathnameSegments = normalizeRoutePath(pathname).split(\"/\").filter(Boolean);\n for (const entry of routeManifest) {\n const params = matchSegments(entry.segments, pathnameSegments);\n if (params) {\n return { entry, params };\n }\n }\n return null;\n};\n\nconst uniqueChunkCacheUrls = (urls) =>\n [...new Set(urls)].filter(\n (url) =>\n typeof url === \"string\" &&\n (${JSON.stringify(CHUNK_CACHEABLE_PATH_PREFIXES)}).some((prefix) => url.startsWith(prefix)),\n );\n\nconst getChunkCacheUrlPriority = (url) => {\n if (url.startsWith(\"/chunks/\")) {\n return 0;\n }\n if (url.startsWith(\"/entries/\")) {\n return 1;\n }\n return 2;\n};\n\nconst sortChunkCacheUrls = (urls) =>\n [...urls].sort(\n (left, right) =>\n getChunkCacheUrlPriority(left) - getChunkCacheUrlPriority(right) || left.localeCompare(right),\n );\n\nconst createChunkCacheMessage = (pathname, payload) => {\n const matched = matchRouteManifestEntry(pathname);\n const priorityUrls = uniqueChunkCacheUrls([\n \"/entries/client_boot.js\",\n ...(matched\n ? [...matched.entry.layouts, matched.entry.page, matched.entry.notFound, matched.entry.error]\n : []),\n ...Object.values(payload.symbols ?? {}),\n ]);\n const priorityUrlSet = new Set(priorityUrls);\n return {\n priorityUrls,\n type: CHUNK_CACHE_MESSAGE_TYPE,\n urls: sortChunkCacheUrls(chunkCacheUrls.filter((url) => !priorityUrlSet.has(url))),\n };\n};\n\nconst createChunkCacheRegistrationScript = (pathname, payload) => {\n const message = createChunkCacheMessage(pathname, payload);\n return \\`(()=>{const message=\\${JSON.stringify(message)};if(!(\"serviceWorker\" in navigator))return;const key=\"__eclipsa_chunk_cache\";const state=window[key]??={registrationPromise:null,post(nextMessage){const post=(registration)=>{const worker=registration.active??registration.waiting??registration.installing;if(worker){worker.postMessage(nextMessage);}};this.registrationPromise=this.registrationPromise??navigator.serviceWorker.register(${JSON.stringify(CHUNK_CACHE_SW_URL)},{scope:\"/\",updateViaCache:\"none\"}).then(()=>navigator.serviceWorker.ready);void this.registrationPromise.then((registration)=>{post(registration);}).catch((error)=>{console.error(\"Failed to register Eclipsa chunk cache service worker.\",error);});}};state.post(message);})();\\`;\n};\n\nconst scoreSpecialRoute = (route, pathname) => {\n const pathnameSegments = normalizeRoutePath(pathname).split(\"/\").filter(Boolean);\n let score = 0;\n for (let index = 0; index < route.segments.length && index < pathnameSegments.length; index += 1) {\n const segment = route.segments[index];\n const pathnameSegment = pathnameSegments[index];\n if (segment.kind === \"static\") {\n if (segment.value !== pathnameSegment) {\n break;\n }\n score += 10;\n continue;\n }\n score += segment.kind === \"rest\" ? 1 : 2;\n if (segment.kind === \"rest\") {\n break;\n }\n }\n return score;\n};\n\nconst findSpecialRoute = (pathname, kind) => {\n const matched = matchRoute(pathname);\n if (matched?.route[kind]) {\n return matched;\n }\n\n let best = null;\n let bestScore = -1;\n for (const route of routes) {\n if (!route[kind]) {\n continue;\n }\n const score = scoreSpecialRoute(route, pathname);\n if (score > bestScore) {\n best = { params: {}, route };\n bestScore = score;\n }\n }\n return best;\n};\n\nconst applyRequestParams = (c, params) => {\n c.req.param = (name) => {\n if (!name) {\n return params;\n }\n return params[name];\n };\n};\n\nconst isNotFoundError = (error) =>\n !!error && typeof error === \"object\" && error.__eclipsa_not_found__ === true;\n\nconst isRedirectResponse = (response) =>\n !!response &&\n typeof response === \"object\" &&\n typeof response.status === \"number\" &&\n !!response.headers &&\n typeof response.headers.get === \"function\" &&\n response.status >= 300 &&\n response.status < 400 &&\n !!response.headers.get(\"location\");\n\nconst toPublicErrorValue = async (hooks, c, error, event) => {\n const publicError = await runHandleError(\n {\n handleError: hooks.handleError,\n },\n {\n context: c,\n error,\n event,\n },\n );\n return markPublicError(error, publicError);\n};\n\nconst logServerError = (error) => {\n if (error && typeof error === \"object\" && error.__eclipsa_not_found__ === true) {\n return;\n }\n console.error(error);\n};\n\nconst prepareRequestContext = (c, hooks) => {\n attachRequestFetch(c, createRequestFetch(c, hooks.handleFetch));\n return c;\n};\n\nconst reroutePathname = (hooks, request, pathname, baseUrl) =>\n normalizeRoutePath(resolveReroute(hooks.reroute, request, pathname, baseUrl));\n\nconst getRouteServerAccess = (route) => {\n const routeIndex = routes.indexOf(route);\n const entry = routeIndex >= 0 ? routeServerAccessEntries[routeIndex] : null;\n return entry ?? { actionIds: [], loaderIds: [] };\n};\n\nconst resolveRouteForCurrentUrl = (hooks, request, currentUrl) => {\n const resolvedPathname = reroutePathname(hooks, request, normalizeRoutePath(currentUrl.pathname), currentUrl.href);\n const match = matchRoute(resolvedPathname);\n if (match?.route?.page) {\n return match;\n }\n const fallback = findSpecialRoute(resolvedPathname, \"notFound\");\n return fallback?.route?.notFound ? fallback : null;\n};\n\nconst getRpcCurrentRoute = (hooks, c) => {\n const requestUrl = getRequestUrl(c.req.raw);\n const routeUrlHeader = c.req.header(${JSON.stringify(ROUTE_RPC_URL_HEADER)});\n if (!routeUrlHeader) {\n return null;\n }\n let currentUrl;\n try {\n currentUrl = new URL(routeUrlHeader, requestUrl);\n } catch {\n return null;\n }\n if (currentUrl.origin !== requestUrl.origin) {\n return null;\n }\n return resolveRouteForCurrentUrl(hooks, c.req.raw, currentUrl);\n};\n\nconst resolveRequest = async (c, handler) => {\n const { appHooks, serverHooks } = await hooksPromise;\n const requestContext = prepareRequestContext(c, serverHooks);\n const execute = (nextContext = requestContext) =>\n withServerRequestContext(\n nextContext,\n {\n handleError: serverHooks.handleError,\n transport: appHooks.transport,\n },\n () => handler(nextContext, appHooks, serverHooks),\n );\n\n if (!serverHooks.handle) {\n return execute(requestContext);\n }\n\n return withServerRequestContext(\n requestContext,\n {\n handleError: serverHooks.handleError,\n transport: appHooks.transport,\n },\n () => serverHooks.handle(requestContext, (nextContext) => execute(nextContext ?? requestContext)),\n );\n};\n\nconst resolveRequestRoute = (hooks, request, url) => {\n const requestPathname = normalizeRoutePath(new URL(url).pathname);\n const resolvedPathname = reroutePathname(hooks, request, requestPathname, url);\n return {\n match: matchRoute(resolvedPathname),\n requestPathname,\n resolvedPathname,\n };\n};\n\nconst loadRouteMiddlewares = async (route) =>\n Promise.all(\n route.middlewares.map(async (middlewareUrl) => {\n const mod = await import(middlewareUrl);\n if (typeof mod.default !== \"function\") {\n throw new TypeError(\n \\`Route middleware \"\\${middlewareUrl}\" must default export a middleware function.\\`,\n );\n }\n return mod.default;\n }),\n );\n\nconst composeRouteMiddlewares = async (route, c, params, handler) => {\n applyRequestParams(c, params);\n const middlewares = await loadRouteMiddlewares(route);\n let index = -1;\n const dispatch = async (nextIndex) => {\n if (nextIndex <= index) {\n throw new Error(\"Route middleware called next() multiple times.\");\n }\n index = nextIndex;\n const middleware = middlewares[nextIndex];\n if (!middleware) {\n return handler();\n }\n let nextResult;\n const result = await middleware(c, async () => {\n nextResult = await dispatch(nextIndex + 1);\n });\n return result !== undefined ? result : nextResult;\n };\n return dispatch(0);\n};\n\nconst resolvePreflightTarget = (pathname) => {\n const match = matchRoute(pathname);\n if (match?.route?.page) {\n return match;\n }\n if (!match) {\n const fallback = findSpecialRoute(pathname, \"notFound\");\n if (fallback?.route?.notFound) {\n return fallback;\n }\n }\n return null;\n};\n\nconst replaceHeadPlaceholder = (html, placeholder, value) => html.replace(placeholder, value);\nconst splitHtmlForStreaming = (html) => {\n const bodyCloseIndex = html.lastIndexOf(\"</body>\");\n if (bodyCloseIndex >= 0) {\n return {\n prefix: html.slice(0, bodyCloseIndex),\n suffix: html.slice(bodyCloseIndex),\n };\n }\n const htmlCloseIndex = html.lastIndexOf(\"</html>\");\n if (htmlCloseIndex >= 0) {\n return {\n prefix: html.slice(0, htmlCloseIndex),\n suffix: html.slice(htmlCloseIndex),\n };\n }\n return {\n prefix: html,\n suffix: \"\",\n };\n};\n\nconst ROUTE_SLOT_ROUTE_KEY = Symbol.for(\"eclipsa.route-slot-route\");\n\nconst createRouteSlot = (route, startLayoutIndex) => {\n const slot = {\n __eclipsa_type: \"route-slot\",\n pathname: route.pathname,\n startLayoutIndex,\n };\n Object.defineProperty(slot, ROUTE_SLOT_ROUTE_KEY, {\n configurable: true,\n enumerable: false,\n value: route,\n writable: true,\n });\n return slot;\n};\n\nconst createRouteProps = (params, props) => {\n const nextProps = { ...props };\n Object.defineProperty(nextProps, ROUTE_PARAMS_PROP, {\n configurable: true,\n enumerable: false,\n value: params,\n writable: true,\n });\n return nextProps;\n};\n\nconst attachRouteError = (props, error) => {\n Object.defineProperty(props, ROUTE_ERROR_PROP, {\n configurable: true,\n enumerable: false,\n value: error,\n writable: true,\n });\n return props;\n};\n\nconst createRouteElement = (pathname, params, Page, Layouts, error) => {\n if (Layouts.length === 0) {\n return jsxDEV(Page, attachRouteError(createRouteProps(params, {}), error), null, false, {});\n }\n\n const route = {\n error,\n layouts: Layouts.map((renderer) => ({ renderer })),\n page: { renderer: Page },\n params,\n pathname,\n };\n let children = null;\n for (let index = Layouts.length - 1; index >= 0; index -= 1) {\n const Layout = Layouts[index];\n children = jsxDEV(Layout, attachRouteError(createRouteProps(params, { children: createRouteSlot(route, index + 1) }), error), null, false, {});\n }\n return children;\n};\n\nconst invokeRouteServer = async (moduleUrl, c, params) => {\n applyRequestParams(c, params);\n const mod = await import(moduleUrl);\n const methodHandler = mod[c.req.method];\n if (typeof methodHandler === \"function\") {\n return methodHandler(c);\n }\n const serverApp = mod.default;\n if (serverApp && typeof serverApp.fetch === \"function\") {\n return serverApp.fetch(c.req.raw);\n }\n return c.text(\"Not Found\", 404);\n};\n\nconst renderRouteResponse = async (route, pathname, params, c, moduleUrl, status = 200, options) => {\n const [pageModule, ...layoutModules] = await Promise.all([\n import(moduleUrl),\n ...route.layouts.map((layout) => import(layout)),\n ]);\n const Page = pageModule.default;\n const Layouts = layoutModules.map((module) => module.default);\n const metadata = composeRouteMetadata(\n [...layoutModules.map((module) => module.metadata ?? null), pageModule.metadata ?? null],\n {\n params,\n url: getRequestUrl(c.req.raw),\n },\n );\n const document = SSRRoot({\n children: createRouteElement(pathname, params, Page, Layouts, options?.routeError),\n head: {\n type: Fragment,\n isStatic: true,\n props: {\n children: [\n ...renderRouteMetadataHead(metadata),\n ...stylesheetUrls.map((href) => ({\n type: \"link\",\n isStatic: true,\n props: {\n href,\n rel: \"stylesheet\",\n },\n })),\n {\n type: \"script\",\n isStatic: true,\n props: {\n children: RESUME_PAYLOAD_PLACEHOLDER,\n id: \"eclipsa-resume\",\n type: \"application/eclipsa-resume+json\",\n },\n },\n {\n type: \"script\",\n isStatic: true,\n props: {\n children: ROUTE_MANIFEST_PLACEHOLDER,\n id: \"${ROUTE_MANIFEST_ELEMENT_ID}\",\n type: \"application/eclipsa-route-manifest+json\",\n },\n },\n {\n type: \"script\",\n isStatic: true,\n props: {\n children: APP_HOOKS_PLACEHOLDER,\n id: APP_HOOKS_ELEMENT_ID,\n type: \"application/eclipsa-app-hooks+json\",\n },\n },\n {\n type: \"script\",\n isStatic: true,\n props: {\n dangerouslySetInnerHTML: getStreamingResumeBootstrapScriptContent(),\n },\n },\n {\n type: \"script\",\n isStatic: true,\n props: {\n dangerouslySetInnerHTML: CHUNK_CACHE_PLACEHOLDER,\n },\n },\n {\n type: \"script\",\n isStatic: true,\n props: {\n type: \"module\",\n src: \"/entries/client_boot.js\",\n },\n },\n ],\n },\n },\n });\n\n applyRequestParams(c, params);\n const { html, payload, chunks } = await renderSSRStream(() => document, {\n prepare(container) {\n primeLocationState(container, getRequestUrl(c.req.raw));\n return options?.prepare?.(container);\n },\n resolvePendingLoaders: async (container) => resolvePendingLoaders(container, c),\n symbols: symbolUrls,\n });\n const shellHtml = replaceHeadPlaceholder(\n replaceHeadPlaceholder(\n replaceHeadPlaceholder(\n replaceHeadPlaceholder(html, RESUME_PAYLOAD_PLACEHOLDER, serializeResumePayload(payload)),\n CHUNK_CACHE_PLACEHOLDER,\n escapeInlineScriptText(createChunkCacheRegistrationScript(pathname, payload)),\n ),\n ROUTE_MANIFEST_PLACEHOLDER,\n escapeJSONScriptText(JSON.stringify(routeManifest)),\n ),\n APP_HOOKS_PLACEHOLDER,\n escapeJSONScriptText(JSON.stringify(appHooksManifest)),\n );\n const { prefix, suffix } = splitHtmlForStreaming(shellHtml);\n const encoder = new TextEncoder();\n return new Response(\n new ReadableStream({\n start(controller) {\n controller.enqueue(encoder.encode(prefix));\n void (async () => {\n let latestPayload = payload;\n\n for await (const chunk of chunks) {\n latestPayload = chunk.payload;\n const templateId = \"eclipsa-suspense-template-\" + chunk.boundaryId;\n const payloadId = \"eclipsa-suspense-payload-\" + chunk.boundaryId;\n controller.enqueue(\n encoder.encode(\n \"<template id=\\\\\"\" + templateId + \"\\\\\">\" + chunk.html + \"</template>\" +\n \"<script id=\\\\\"\" + payloadId + \"\\\\\" type=\\\\\"application/eclipsa-resume+json\\\\\">\" + serializeResumePayload(chunk.payload) + \"</script>\" +\n \"<script>window.__eclipsa_stream.enqueue({boundaryId:\" + JSON.stringify(chunk.boundaryId) + \",payloadScriptId:\" + JSON.stringify(payloadId) + \",templateId:\" + JSON.stringify(templateId) + \"})</script>\",\n ),\n );\n }\n\n controller.enqueue(\n encoder.encode(\n \"<script id=\\\\\"\" + RESUME_FINAL_STATE_ELEMENT_ID + \"\\\\\" type=\\\\\"application/eclipsa-resume+json\\\\\">\" + serializeResumePayload(latestPayload) + \"</script>\" +\n \"<script>\" + escapeInlineScriptText(createChunkCacheRegistrationScript(pathname, latestPayload)) + \"</script>\" +\n suffix,\n ),\n );\n controller.close();\n })().catch((error) => {\n controller.error(error);\n });\n },\n }),\n {\n headers: {\n \"content-type\": \"text/html; charset=utf-8\",\n },\n status,\n },\n );\n};\n\nconst renderMatchedPage = async (match, c, options) => {\n const { appHooks, serverHooks } = await hooksPromise;\n const requestUrl = getRequestUrl(c.req.raw);\n const pathname = normalizeRoutePath(requestUrl.pathname);\n const resolvedPathname = reroutePathname(appHooks, c.req.raw, pathname, requestUrl.href);\n try {\n return await renderRouteResponse(match.route, pathname, match.params, c, match.route.page, 200, options);\n } catch (error) {\n logServerError(error);\n const publicError = await toPublicErrorValue(serverHooks, c, error, \"page\");\n const fallback = isNotFoundError(error) ? findSpecialRoute(resolvedPathname, \"notFound\") : findSpecialRoute(resolvedPathname, \"error\");\n const kind = isNotFoundError(error) ? \"notFound\" : \"error\";\n const moduleUrl = fallback?.route?.[kind];\n if (!fallback || !moduleUrl) {\n return c.text(isNotFoundError(error) ? \"Not Found\" : \"Internal Server Error\", isNotFoundError(error) ? 404 : 500);\n }\n return renderRouteResponse(fallback.route, pathname, fallback.params, c, moduleUrl, isNotFoundError(error) ? 404 : 500, {\n ...options,\n routeError: publicError,\n });\n }\n};\n\nconst renderRouteDataResponse = async (route, pathname, params, c, moduleUrl, kind) => {\n const [pageModule, ...layoutModules] = await Promise.all([\n import(moduleUrl),\n ...route.layouts.map((layout) => import(layout)),\n ]);\n const Page = pageModule.default;\n const Layouts = layoutModules.map((module) => module.default);\n\n applyRequestParams(c, params);\n const { payload } = await renderSSRAsync(() => createRouteElement(pathname, params, Page, Layouts, undefined), {\n prepare(container) {\n primeLocationState(container, getRequestUrl(c.req.raw));\n },\n resolvePendingLoaders: async (container) => resolvePendingLoaders(container, c),\n symbols: symbolUrls,\n });\n\n return c.json({\n finalHref: getRequestUrl(c.req.raw).href,\n finalPathname: pathname,\n kind,\n loaders: payload.loaders,\n ok: true,\n });\n};\n\nconst renderRouteData = async (route, pathname, params, c, moduleUrl, kind) => {\n const { appHooks } = await hooksPromise;\n const requestUrl = getRequestUrl(c.req.raw);\n const requestPathname = normalizeRoutePath(requestUrl.pathname);\n const resolvedPathname = reroutePathname(appHooks, c.req.raw, requestPathname, requestUrl.href);\n try {\n return await renderRouteDataResponse(route, pathname, params, c, moduleUrl, kind);\n } catch (error) {\n if (!isNotFoundError(error)) {\n return c.json({ document: true, ok: false });\n }\n const fallback = findSpecialRoute(resolvedPathname, \"notFound\");\n if (!fallback?.route?.notFound) {\n return c.json({ document: true, ok: false });\n }\n try {\n return await renderRouteDataResponse(\n fallback.route,\n requestPathname,\n fallback.params,\n c,\n fallback.route.notFound,\n \"not-found\",\n );\n } catch {\n return c.json({ document: true, ok: false });\n }\n }\n};\n\nconst resolveRouteData = async (href, c) => {\n const requestUrl = getRequestUrl(c.req.raw);\n const targetUrl = new URL(href, requestUrl);\n if (targetUrl.origin !== requestUrl.origin) {\n return c.json({ document: true, ok: false });\n }\n const headers = new Headers(c.req.raw.headers);\n headers.set(ROUTE_DATA_REQUEST_HEADER, \"1\");\n const response = await app.fetch(\n new Request(targetUrl.href, {\n headers,\n method: \"GET\",\n redirect: \"manual\",\n }),\n );\n if (response.status >= 200 && response.status < 300) {\n return response;\n }\n if (isRedirectResponse(response)) {\n return c.json({\n location: new URL(response.headers.get(\"location\"), requestUrl).href,\n ok: false,\n });\n }\n return c.json({ document: true, ok: false });\n};\n\nconst resolveRoutePreflight = async (href, c) => {\n const { appHooks } = await hooksPromise;\n const requestUrl = getRequestUrl(c.req.raw);\n const targetUrl = new URL(href, requestUrl);\n if (targetUrl.origin !== requestUrl.origin) {\n return c.json({ document: true, ok: false });\n }\n\n const target = resolvePreflightTarget(reroutePathname(appHooks, new Request(targetUrl.href), normalizeRoutePath(targetUrl.pathname), targetUrl.href));\n if (!target) {\n return c.json({ ok: true });\n }\n\n const headers = new Headers(c.req.raw.headers);\n headers.set(ROUTE_PREFLIGHT_REQUEST_HEADER, \"1\");\n let response;\n try {\n response = await c.var.fetch(targetUrl.href, {\n headers,\n redirect: \"manual\",\n });\n } catch {\n response = await app.fetch(\n new Request(targetUrl.href, {\n headers,\n method: \"GET\",\n redirect: \"manual\",\n }),\n );\n }\n\n if (response.status >= 200 && response.status < 300) {\n return c.json({ ok: true });\n }\n if (isRedirectResponse(response)) {\n return c.json({\n location: new URL(response.headers.get(\"location\"), requestUrl).href,\n ok: false,\n });\n }\n return c.json({ document: true, ok: false });\n};\n\nfor (const pageRouteEntry of pageRouteEntries) {\n app.get(pageRouteEntry.path, async (c) => {\n const pathname = normalizeRoutePath(getRequestUrl(c.req.raw).pathname);\n const match = matchRoute(pathname);\n if (!match || match.route !== routes[pageRouteEntry.routeIndex]) {\n return c.text(\"Not Found\", 404);\n }\n return composeRouteMiddlewares(\n match.route,\n c,\n match.params,\n async () =>\n c.req.header(ROUTE_PREFLIGHT_REQUEST_HEADER) === \"1\"\n ? c.body(null, 204)\n : c.req.header(ROUTE_DATA_REQUEST_HEADER) === \"1\"\n ? renderRouteData(match.route, pathname, match.params, c, match.route.page, \"page\")\n : renderMatchedPage(match, c),\n );\n });\n}\n\napp.post(\"/__eclipsa/action/:id\", async (c) =>\n resolveRequest(c, async (requestContext, appHooks) => {\n const id = requestContext.req.param(\"id\");\n if (!id) {\n return requestContext.text(\"Not Found\", 404);\n }\n const routeMatch = getRpcCurrentRoute(appHooks, requestContext);\n if (!routeMatch) {\n return requestContext.text(\"Bad Request\", 400);\n }\n const routeAccess = getRouteServerAccess(routeMatch.route);\n if (!routeAccess.actionIds.includes(id)) {\n return requestContext.text(\"Not Found\", 404);\n }\n const moduleUrl = actions[id];\n if (!moduleUrl) {\n return requestContext.text(\"Not Found\", 404);\n }\n if (!hasAction(id)) {\n await import(moduleUrl);\n }\n return composeRouteMiddlewares(\n routeMatch.route,\n requestContext,\n routeMatch.params,\n async () => executeAction(id, requestContext),\n );\n }),\n);\n\napp.get(\"/__eclipsa/loader/:id\", async (c) =>\n resolveRequest(c, async (requestContext, appHooks) => {\n const id = requestContext.req.param(\"id\");\n if (!id) {\n return requestContext.text(\"Not Found\", 404);\n }\n const routeMatch = getRpcCurrentRoute(appHooks, requestContext);\n if (!routeMatch) {\n return requestContext.text(\"Bad Request\", 400);\n }\n const routeAccess = getRouteServerAccess(routeMatch.route);\n if (!routeAccess.loaderIds.includes(id)) {\n return requestContext.text(\"Not Found\", 404);\n }\n const moduleUrl = loaders[id];\n if (!moduleUrl) {\n return requestContext.text(\"Not Found\", 404);\n }\n if (!hasLoader(id)) {\n await import(moduleUrl);\n }\n return composeRouteMiddlewares(\n routeMatch.route,\n requestContext,\n routeMatch.params,\n async () => executeLoader(id, requestContext),\n );\n }),\n);\n\napp.get(${JSON.stringify(ROUTE_PREFLIGHT_ENDPOINT)}, async (c) => {\n const href = c.req.query(\"href\");\n if (!href) {\n return c.json({ document: true, ok: false }, 400);\n }\n return resolveRoutePreflight(href, c);\n});\n\napp.get(${JSON.stringify(ROUTE_DATA_ENDPOINT)}, async (c) => {\n const href = c.req.query(\"href\");\n if (!href) {\n return c.json({ document: true, ok: false }, 400);\n }\n return resolveRouteData(href, c);\n});\n\napp.all(\"*\", async (c) => {\n const pathname = normalizeRoutePath(getRequestUrl(c.req.raw).pathname);\n const match = matchRoute(pathname);\n\n if (!match) {\n const fallback = findSpecialRoute(pathname, \"notFound\");\n if (fallback?.route?.notFound) {\n return composeRouteMiddlewares(\n fallback.route,\n c,\n fallback.params,\n async () =>\n c.req.header(ROUTE_PREFLIGHT_REQUEST_HEADER) === \"1\"\n ? c.body(null, 204)\n : c.req.header(ROUTE_DATA_REQUEST_HEADER) === \"1\"\n ? renderRouteData(fallback.route, pathname, fallback.params, c, fallback.route.notFound, \"not-found\")\n : renderRouteResponse(fallback.route, pathname, fallback.params, c, fallback.route.notFound, 404),\n );\n }\n return c.text(\"Not Found\", 404);\n }\n\n if ((c.req.method === \"GET\" || c.req.method === \"HEAD\") && match.route.page) {\n return composeRouteMiddlewares(\n match.route,\n c,\n match.params,\n async () =>\n c.req.header(ROUTE_PREFLIGHT_REQUEST_HEADER) === \"1\"\n ? c.body(null, 204)\n : c.req.header(ROUTE_DATA_REQUEST_HEADER) === \"1\"\n ? renderRouteData(match.route, pathname, match.params, c, match.route.page, \"page\")\n : renderMatchedPage(match, c),\n );\n }\n if (c.req.method === \"POST\" && match.route.page) {\n return composeRouteMiddlewares(\n match.route,\n c,\n match.params,\n async () => {\n const actionId = await getActionFormSubmissionId(c);\n if (!actionId) {\n return match.route.server\n ? invokeRouteServer(match.route.server, c, match.params)\n : renderMatchedPage(match, c);\n }\n const routeAccess = getRouteServerAccess(match.route);\n if (!routeAccess.actionIds.includes(actionId)) {\n return c.text(\"Not Found\", 404);\n }\n const moduleUrl = actions[actionId];\n if (!moduleUrl) {\n return c.text(\"Not Found\", 404);\n }\n if (!hasAction(actionId)) {\n await import(moduleUrl);\n }\n const input = await getNormalizedActionInput(c);\n const response = await executeAction(actionId, c);\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (!contentType.startsWith(ACTION_CONTENT_TYPE)) {\n return response;\n }\n const body = await response.json();\n return renderMatchedPage(match, c, {\n prepare(container) {\n primeActionState(container, actionId, {\n error: body.ok ? undefined : deserializeValue(body.error),\n input,\n result: body.ok ? deserializeValue(body.value) : undefined,\n });\n },\n });\n },\n );\n }\n if (match.route.server) {\n return composeRouteMiddlewares(match.route, c, match.params, async () =>\n invokeRouteServer(match.route.server, c, match.params),\n );\n }\n if (match.route.page) {\n return composeRouteMiddlewares(\n match.route,\n c,\n match.params,\n async () =>\n c.req.header(ROUTE_PREFLIGHT_REQUEST_HEADER) === \"1\"\n ? c.body(null, 204)\n : renderMatchedPage(match, c),\n );\n }\n return c.text(\"Not Found\", 404);\n});\n\nexport const pageRoutePatterns = [...new Set(pageRouteEntries.map((entry) => entry.path))];\nexport default app;\n`\n}\n\nconst renderNodeServer = () => `import app from \"../ssr/eclipsa_app.mjs\";\nimport { createServer } from \"node:http\";\nimport { readFile, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst fileTypes = new Map([\n [\".js\", \"text/javascript; charset=utf-8\"],\n [\".mjs\", \"text/javascript; charset=utf-8\"],\n [\".css\", \"text/css; charset=utf-8\"],\n [\".html\", \"text/html; charset=utf-8\"],\n [\".json\", \"application/json; charset=utf-8\"],\n [\".svg\", \"image/svg+xml\"],\n [\".png\", \"image/png\"],\n [\".jpg\", \"image/jpeg\"],\n [\".jpeg\", \"image/jpeg\"],\n]);\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst clientDir = path.resolve(__dirname, \"../client\");\n\nconst toRequest = (incomingMessage) => {\n const body =\n incomingMessage.method !== \"GET\" && incomingMessage.method !== \"HEAD\"\n ? new ReadableStream({\n start(controller) {\n incomingMessage.on(\"data\", (chunk) => controller.enqueue(new Uint8Array(chunk)));\n incomingMessage.on(\"end\", () => controller.close());\n },\n })\n : null;\n const headers = new Headers();\n for (const [key, value] of Object.entries(incomingMessage.headers)) {\n if (Array.isArray(value)) {\n value.forEach((entry) => headers.append(key, entry));\n } else if (value) {\n headers.append(key, value);\n }\n }\n return new Request(new URL(incomingMessage.url ?? \"/\", \"http://localhost\"), {\n method: incomingMessage.method,\n headers,\n body,\n });\n};\n\nconst sendResponse = async (response, serverResponse) => {\n for (const [key, value] of response.headers) {\n serverResponse.setHeader(key, value);\n }\n serverResponse.statusCode = response.status;\n serverResponse.statusMessage = response.statusText;\n const buffer = Buffer.from(await response.arrayBuffer());\n serverResponse.end(buffer);\n};\n\nconst serveStatic = async (pathname) => {\n const normalized = pathname.replace(/^\\\\/+/, \"\");\n const filePath = path.join(clientDir, normalized);\n if (!filePath.startsWith(clientDir)) {\n return null;\n }\n\n try {\n const info = await stat(filePath);\n if (!info.isFile()) {\n return null;\n }\n return new Response(await readFile(filePath), {\n headers: {\n \"content-type\": fileTypes.get(path.extname(filePath)) ?? \"application/octet-stream\",\n },\n });\n } catch {\n return null;\n }\n};\n\nconst port = Number.parseInt(process.env.PORT ?? \"3000\", 10);\n\ncreateServer(async (req, res) => {\n const url = new URL(req.url ?? \"/\", \"http://localhost\");\n const staticResponse = await serveStatic(url.pathname);\n if (staticResponse) {\n await sendResponse(staticResponse, res);\n return;\n }\n\n const response = await app.fetch(toRequest(req));\n await sendResponse(response, res);\n}).listen(port, () => {\n console.log(\"Eclipsa server listening on http://localhost:\" + port);\n});\n`\n\nexport const build = async (\n builder: ViteBuilder,\n userConfig: UserConfig,\n options: ResolvedEclipsaPluginOptions,\n) => {\n const root = userConfig.root ?? cwd()\n const appHooksPath = path.join(root, 'app/+hooks.ts')\n const serverHooksPath = path.join(root, 'app/+hooks.server.ts')\n const actions = await collectAppActions(root)\n const loaders = await collectAppLoaders(root)\n const routes = await createRoutes(root)\n const routeServerAccessEntries = await createRouteServerAccessEntries(routes, actions, loaders)\n const staticPageRoutes = routes.filter(\n (route) => route.page && resolveRouteRenderMode(route, options.output) === 'static',\n )\n const dynamicPageRoutes = routes.filter(\n (route) => route.page && resolveRouteRenderMode(route, options.output) === 'dynamic',\n )\n if (options.output === 'ssg') {\n const dynamicRoute = dynamicPageRoutes[0]\n if (dynamicRoute) {\n throw new Error(\n `Route ${dynamicRoute.routePath} is marked render = \"dynamic\", which is not supported with output \"ssg\". Switch the app output to \"node\" or mark the route as \"static\".`,\n )\n }\n const routeWithMiddleware = routes.find((route) => route.middlewares.length > 0)\n if (routeWithMiddleware) {\n throw new Error(\n `Route middleware is not supported with output \"ssg\". Remove +middleware.ts from route ${routeWithMiddleware.routePath} or switch to output \"node\".`,\n )\n }\n }\n const routeManifest = createRouteManifest(routes, createBuildModuleUrl)\n const symbols = await collectAppSymbols(root)\n const symbolUrls = Object.fromEntries(\n symbols.map((symbol) => [symbol.id, createBuildSymbolUrl(symbol.id)]),\n )\n\n await builder.build(builder.environments.client)\n await builder.build(builder.environments.ssr)\n\n const appHooksClientUrl = (await fileExists(appHooksPath))\n ? createBuildModuleUrl({ entryName: 'app_hooks', filePath: appHooksPath })\n : null\n const appHooksServerUrl = (await fileExists(appHooksPath))\n ? createBuildServerModuleUrl({ entryName: 'app_hooks', filePath: appHooksPath })\n : null\n const clientDir = path.join(root, 'dist/client')\n const serverHooksUrl = (await fileExists(serverHooksPath))\n ? createBuildServerModuleUrl({ entryName: 'server_hooks', filePath: serverHooksPath })\n : null\n const stylesheetUrls = await collectClientStylesheetUrls(clientDir)\n const chunkCacheAssets = await collectClientChunkCacheAssets(clientDir)\n await writeClientChunkCacheServiceWorker(clientDir, chunkCacheAssets)\n const serverDir = path.join(root, 'dist/server')\n const appModulePath = path.join(root, 'dist/ssr/eclipsa_app.mjs')\n await fs.mkdir(path.dirname(appModulePath), { recursive: true })\n await fs.writeFile(\n appModulePath,\n renderAppModule(\n actions,\n appHooksClientUrl,\n appHooksServerUrl,\n loaders,\n routes,\n routeServerAccessEntries,\n routeManifest,\n serverHooksUrl,\n symbolUrls,\n stylesheetUrls,\n chunkCacheAssets.map((asset) => asset.url),\n ),\n )\n const staticPrerenderTargets = await resolveStaticPrerenderTargets(root, staticPageRoutes)\n\n const prerenderStaticRoutes = async () => {\n if (\n staticPrerenderTargets.concretePaths.size === 0 &&\n staticPrerenderTargets.dynamicParamsByPattern.size === 0\n ) {\n return\n }\n\n const { default: app } = (await import(\n `${pathToFileURL(appModulePath).href}?t=${Date.now()}`\n )) as {\n default: { fetch(request: Request): Promise<Response> }\n }\n const result = await toSSG(app as any, fs, {\n beforeRequestHook(request: Request) {\n const routePath = normalizeRoutePath(decodeURIComponent(new URL(request.url).pathname))\n if (\n routePath === normalizeRoutePath(ROUTE_DATA_ENDPOINT) ||\n routePath === normalizeRoutePath(ROUTE_PREFLIGHT_ENDPOINT) ||\n routePath.startsWith('/__eclipsa/loader/')\n ) {\n return false\n }\n const ssgParams = staticPrerenderTargets.dynamicParamsByPattern.get(routePath)\n if (ssgParams) {\n ;(request as Request & { ssgParams?: Record<string, string>[] }).ssgParams = ssgParams\n return request\n }\n return staticPrerenderTargets.concretePaths.has(routePath) ? request : false\n },\n dir: clientDir,\n })\n\n if (!result.success) {\n throw result.error ?? new Error('Failed to generate static output.')\n }\n }\n\n if (options.output === 'node') {\n await prerenderStaticRoutes()\n await fs.mkdir(serverDir, { recursive: true })\n await fs.writeFile(path.join(serverDir, 'index.mjs'), renderNodeServer())\n return\n }\n\n await fs.rm(serverDir, { force: true, recursive: true })\n await prerenderStaticRoutes()\n}\n","import * as path from 'node:path'\nimport { pathToFileURL } from 'node:url'\n\nconst ECLIPSA_NITRO_ENTRY_ID = '#eclipsa/nitro-entry'\n\ninterface VitePluginLike {\n name?: string\n nitro?: unknown\n}\n\ninterface NitroPublicAsset {\n baseURL?: string\n dir: string\n maxAge?: number\n}\n\ninterface NitroConfigLike {\n entry?: string\n publicAssets?: NitroPublicAsset[]\n virtual?: Record<string, string | (() => string)>\n [key: string]: unknown\n}\n\nconst normalizeAssetBaseURL = (value: string) => {\n const normalized = value.trim() || '/'\n if (normalized === '/') {\n return '/'\n }\n return normalized.startsWith('/') ? normalized : `/${normalized}`\n}\n\nconst flattenPlugins = (plugins: unknown): VitePluginLike[] => {\n if (!Array.isArray(plugins)) {\n return plugins && typeof plugins === 'object' ? [plugins as VitePluginLike] : []\n }\n return plugins.flatMap((entry) => flattenPlugins(entry))\n}\n\nexport const hasNitroPlugin = (plugins: unknown): boolean =>\n flattenPlugins(plugins).some((plugin) => {\n if (!plugin || typeof plugin !== 'object') {\n return false\n }\n if ('nitro' in plugin) {\n return true\n }\n return typeof plugin.name === 'string' && plugin.name.startsWith('nitro:')\n })\n\nexport const createEclipsaNitroEntry = (appModulePath: string) =>\n [\n 'import { defineHandler } from \"nitro\";',\n `import app from ${JSON.stringify(pathToFileURL(appModulePath).href)};`,\n '',\n 'export default defineHandler((event) => app.fetch(event.req));',\n '',\n ].join('\\n')\n\nexport const createEclipsaNitroConfig = (\n root: string,\n nitroConfig: NitroConfigLike | undefined,\n): NitroConfigLike => {\n const clientDir = path.join(root, 'dist/client')\n const appModulePath = path.join(root, 'dist/ssr/eclipsa_app.mjs')\n const nextPublicAssets = [...(nitroConfig?.publicAssets ?? [])]\n const hasClientAssetDir = nextPublicAssets.some(\n (asset) =>\n path.resolve(root, asset.dir) === clientDir &&\n normalizeAssetBaseURL(asset.baseURL ?? '/') === '/',\n )\n\n if (!hasClientAssetDir) {\n nextPublicAssets.push({\n baseURL: '/',\n dir: clientDir,\n })\n }\n\n return {\n ...nitroConfig,\n entry: ECLIPSA_NITRO_ENTRY_ID,\n publicAssets: nextPublicAssets,\n virtual: {\n ...nitroConfig?.virtual,\n [ECLIPSA_NITRO_ENTRY_ID]: createEclipsaNitroEntry(appModulePath),\n },\n }\n}\n","import type { Plugin } from 'vite'\nimport * as fs from 'node:fs/promises'\nimport { cwd } from 'node:process'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { collectRouteModules, collectRouteServerModules, createRoutes } from './utils/routing.ts'\nimport { build } from './build/mod.ts'\nimport {\n collectAppActions,\n collectAppLoaders,\n collectAppSymbols,\n createSymbolRequestId,\n} from './compiler.ts'\nimport type { ResolvedEclipsaPluginOptions } from './options.ts'\nimport { createEclipsaNitroConfig, hasNitroPlugin } from './nitro.ts'\n\nconst ECLIPSA_RUNTIME_ENTRY_PATH = fileURLToPath(import.meta.resolve('eclipsa/vite/build/runtime'))\n\nconst fileExists = async (filePath: string) => {\n try {\n await fs.access(filePath)\n return true\n } catch {\n return false\n }\n}\n\nexport const createConfig =\n (options: ResolvedEclipsaPluginOptions): Plugin['config'] =>\n async (userConfig) => {\n const root = userConfig.root ?? cwd()\n const appHooksPath = path.join(root, 'app/+hooks.ts')\n const serverHooksPath = path.join(root, 'app/+hooks.server.ts')\n const hasAppHooks = await fileExists(appHooksPath)\n const hasServerHooks = await fileExists(serverHooksPath)\n const nitroEnabled = hasNitroPlugin(userConfig.plugins)\n const routes = await createRoutes(root)\n const routeModules = collectRouteModules(routes)\n const routeServerModules = collectRouteServerModules(routes)\n const actions = await collectAppActions(root)\n const loaders = await collectAppLoaders(root)\n const symbols = await collectAppSymbols(root)\n\n const clientInput = Object.fromEntries([\n ['client_boot', path.join(root, 'app/+client.dev.tsx')],\n ...(hasAppHooks ? [['app_hooks', appHooksPath] as const] : []),\n ...symbols.map((symbol) => [\n `symbol__${symbol.id}`,\n createSymbolRequestId(symbol.filePath, symbol.id),\n ]),\n ...routeModules.map((entry) => [entry.entryName, entry.filePath]),\n ])\n\n const ssrInput = Object.fromEntries([\n ['server_entry', path.join(root, 'app/+server-entry.ts')],\n ['ssr_root', path.join(root, 'app/+ssr-root.tsx')],\n ['eclipsa_runtime', ECLIPSA_RUNTIME_ENTRY_PATH],\n ...(hasAppHooks ? [['app_hooks', appHooksPath] as const] : []),\n ...(hasServerHooks ? [['server_hooks', serverHooksPath] as const] : []),\n ...actions.map((action) => [`action__${action.id}`, action.filePath]),\n ...loaders.map((loader) => [`loader__${loader.id}`, loader.filePath]),\n ...routeModules.map((entry) => [entry.entryName, entry.filePath]),\n ...routeServerModules.map((entry) => [entry.entryName, entry.filePath]),\n ])\n\n return {\n oxc: {\n jsx: 'preserve',\n jsxFactory: 'jsx',\n jsxImportSource: 'eclipsa',\n sourcemap: false,\n },\n ...(nitroEnabled\n ? ({\n nitro: createEclipsaNitroConfig(\n root,\n (userConfig as typeof userConfig & { nitro?: Record<string, unknown> }).nitro,\n ),\n } as Record<string, unknown>)\n : {}),\n environments: {\n client: {\n build: {\n emptyOutDir: true,\n outDir: path.join(root, 'dist/client'),\n rollupOptions: {\n input: clientInput,\n output: {\n assetFileNames: 'assets/[name]-[hash][extname]',\n chunkFileNames: 'chunks/[name]-[hash].js',\n entryFileNames: 'entries/[name].js',\n },\n preserveEntrySignatures: 'allow-extension',\n },\n },\n },\n ssr: {\n build: {\n emptyOutDir: true,\n outDir: path.join(root, 'dist/ssr'),\n rollupOptions: {\n input: ssrInput,\n output: {\n assetFileNames: 'assets/[name]-[hash][extname]',\n chunkFileNames: 'chunks/[name]-[hash].mjs',\n entryFileNames: 'entries/[name].mjs',\n },\n preserveEntrySignatures: 'allow-extension',\n },\n },\n },\n },\n builder: {\n async buildApp(builder) {\n await build(builder, userConfig, options)\n },\n },\n }\n }\n","export type EclipsaOutputTarget = 'node' | 'ssg'\n\nexport interface EclipsaPluginOptions {\n output?: EclipsaOutputTarget\n}\n\nexport interface ResolvedEclipsaPluginOptions {\n output: EclipsaOutputTarget\n}\n\nexport const resolveEclipsaPluginOptions = (\n options?: EclipsaPluginOptions,\n): ResolvedEclipsaPluginOptions => ({\n output: options?.output ?? 'node',\n})\n","import {\n createServerModuleRunner,\n transformWithOxc,\n type Plugin,\n type PluginOption,\n type ResolvedConfig,\n} from 'vite'\nimport { createDevFetch, shouldInvalidateDevApp } from './dev-app/mod.ts'\nimport { incomingMessageToRequest, responseForServerResponse } from '../utils/node-connect.ts'\nimport { createConfig } from './config.ts'\nimport { resolveEclipsaPluginOptions, type EclipsaPluginOptions } from './options.ts'\nimport {\n compileModuleForClient,\n compileModuleForSSR,\n inspectResumeHmrUpdate,\n loadSymbolModuleForClient,\n loadSymbolModuleForSSR,\n parseSymbolRequest,\n resolveResumeHmrUpdate,\n} from './compiler.ts'\nimport { RESUME_HMR_EVENT, type ResumeHmrUpdatePayload } from '../core/resume-hmr.ts'\n\nconst ECLIPSA_SOURCE_EXTENSIONS = new Set([\n '.cjs',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.mts',\n '.ts',\n '.tsx',\n])\n\nconst stripRequestQuery = (value: string) => value.replace(/[?#].*$/, '')\n\nconst isTestLikeSourceRequest = (value: string) =>\n /\\.(?:test|spec)\\.[^./]+$/.test(stripRequestQuery(value).replaceAll('\\\\', '/'))\n\nconst isAppSourceRequest = (value: string) =>\n /(^|\\/)app\\//.test(stripRequestQuery(value).replaceAll('\\\\', '/'))\n\nconst isEclipsaSourceRequest = (value: string) => {\n const normalized = stripRequestQuery(value)\n const extensionIndex = normalized.lastIndexOf('.')\n if (extensionIndex < 0) {\n return false\n }\n const extension = normalized.slice(extensionIndex)\n if (!ECLIPSA_SOURCE_EXTENSIONS.has(extension)) {\n return false\n }\n return extension === '.tsx' || isAppSourceRequest(normalized)\n}\n\nconst isCssRequest = (value: string | undefined) => {\n if (!value) {\n return false\n }\n const normalized = stripRequestQuery(value)\n return normalized.endsWith('.css')\n}\n\nconst createHotTargetUrl = (root: string, filePath: string) => {\n const normalizedRoot = root.replaceAll('\\\\', '/').replace(/\\/$/, '')\n const normalizedFilePath = stripRequestQuery(filePath).replaceAll('\\\\', '/')\n if (normalizedFilePath.startsWith('/app/')) {\n return normalizedFilePath\n }\n if (\n normalizedFilePath === normalizedRoot ||\n normalizedFilePath.startsWith(`${normalizedRoot}/`)\n ) {\n return `/${normalizedFilePath.slice(normalizedRoot.length + 1)}`\n }\n return `/@fs/${normalizedFilePath}`\n}\n\nconst preserveCssHotModules = <\n T extends { file?: string; id?: string; type?: string; url?: string },\n>(\n modules: T[],\n) =>\n modules.filter(\n (module) =>\n module.type === 'css' ||\n isCssRequest(module.id) ||\n isCssRequest(module.url) ||\n isCssRequest(module.file),\n )\n\nconst mergeUniqueHotModules = <T extends { file?: string; id?: string; url?: string }>(\n modules: T[],\n) => {\n const seen = new Set<string>()\n return modules.filter((module) => {\n const key = module.id ?? module.file ?? module.url\n if (!key || seen.has(key)) {\n return false\n }\n seen.add(key)\n return true\n })\n}\n\ninterface EclipsaPluginState {\n config?: ResolvedConfig\n pendingSsrUpdates?: Map<string, ResumeHmrUpdatePayload>\n}\n\ninterface HotModule {\n file?: string\n id?: string\n type?: string\n url: string\n}\n\nconst collectCssHotModules = (\n pluginContext: PluginContextWithEnvironment,\n options: HotUpdateContext,\n) =>\n mergeUniqueHotModules([\n ...preserveCssHotModules(options.modules),\n ...preserveCssHotModules([\n ...(pluginContext.environment.moduleGraph?.idToModuleMap?.values() ?? []),\n ]),\n ])\n\nconst sendSsrHotEvent = (\n pluginContext: PluginContextWithEnvironment,\n options: HotUpdateContext,\n event: string,\n payload?: unknown,\n) => {\n if (options.server?.ws) {\n options.server.ws.send(event, payload)\n return\n }\n pluginContext.environment.hot.send(event, payload)\n}\n\nconst hasClientHotModuleForFile = (options: HotUpdateContext) => {\n const clientModules = options.server?.environments?.client?.moduleGraph?.getModulesByFile(\n options.file,\n )\n if (!clientModules) {\n return false\n }\n for (const _module of clientModules) {\n return true\n }\n return false\n}\n\nconst shouldForceFullReloadForWatcherEvent = (\n filePath: string,\n event: 'add' | 'change' | 'unlink',\n) => event !== 'change' && isEclipsaSourceRequest(filePath) && !isTestLikeSourceRequest(filePath)\n\nconst handleHotUpdate = async (\n state: EclipsaPluginState,\n pluginContext: PluginContextWithEnvironment,\n options: HotUpdateContext,\n) => {\n const config = state.config\n if (!config || !isEclipsaSourceRequest(options.file) || isTestLikeSourceRequest(options.file)) {\n return\n }\n const source = await options.read()\n if (pluginContext.environment.name !== 'client') {\n const resumableUpdate = await inspectResumeHmrUpdate({\n filePath: options.file,\n root: config.root,\n source,\n })\n if (resumableUpdate.isResumable) {\n if (resumableUpdate.update) {\n if (hasClientHotModuleForFile(options)) {\n return collectCssHotModules(pluginContext, options)\n }\n const pendingSsrUpdate = state.pendingSsrUpdates?.get(options.file)\n if (\n pendingSsrUpdate &&\n !pendingSsrUpdate.fullReload &&\n resumableUpdate.update.fullReload &&\n pendingSsrUpdate.fileUrl === resumableUpdate.update.fileUrl\n ) {\n return collectCssHotModules(pluginContext, options)\n }\n state.pendingSsrUpdates ??= new Map()\n state.pendingSsrUpdates.set(options.file, resumableUpdate.update)\n sendSsrHotEvent(pluginContext, options, RESUME_HMR_EVENT, resumableUpdate.update)\n }\n return collectCssHotModules(pluginContext, options)\n }\n return\n }\n const resumableUpdate = await resolveResumeHmrUpdate({\n filePath: options.file,\n root: config.root,\n source,\n })\n if (resumableUpdate.isResumable) {\n const pendingSsrUpdate = state.pendingSsrUpdates?.get(options.file)\n if (pendingSsrUpdate) {\n state.pendingSsrUpdates?.delete(options.file)\n } else if (resumableUpdate.update) {\n pluginContext.environment.hot.send(RESUME_HMR_EVENT, resumableUpdate.update)\n }\n return collectCssHotModules(pluginContext, options)\n }\n\n const module =\n options.modules[0] ??\n [...(pluginContext.environment.moduleGraph?.getModulesByFile(options.file) ?? [])][0]\n pluginContext.environment.hot.send('update-client', {\n url: module?.url ?? createHotTargetUrl(config.root, options.file),\n })\n return collectCssHotModules(pluginContext, options)\n}\n\ninterface PluginContextWithEnvironment {\n environment: {\n hot: {\n send(event: string, payload?: unknown): void\n }\n moduleGraph?: {\n idToModuleMap?: Map<string, HotModule>\n getModulesByFile(file: string): Iterable<{ url: string }> | undefined\n }\n name: string\n }\n}\n\ninterface HotUpdateContext {\n file: string\n modules: HotModule[]\n read(): Promise<string> | string\n server?: {\n environments?: {\n client?: {\n moduleGraph?: {\n getModulesByFile(file: string): Iterable<{ url: string }> | undefined\n }\n }\n }\n ws?: {\n send(event: string, payload?: unknown): void\n }\n }\n}\n\nconst eclipsaCore = (state: EclipsaPluginState, options: EclipsaPluginOptions = {}): Plugin => {\n return {\n enforce: 'pre',\n name: 'vite-plugin-eclipsa',\n config: createConfig(resolveEclipsaPluginOptions(options)),\n configResolved(resolvedConfig) {\n state.config = resolvedConfig\n },\n configureServer(server) {\n const config = state.config\n if (!config) {\n throw new Error('Resolved Vite config is unavailable during configureServer().')\n }\n const ssrEnv = server.environments.ssr\n const runner = createServerModuleRunner(ssrEnv, {\n hmr: false,\n })\n const devApp = createDevFetch({\n resolvedConfig: config,\n devServer: server,\n runner,\n ssrEnv,\n })\n const invalidateDevApp = (filePath: string, event: 'add' | 'change' | 'unlink') => {\n if (shouldInvalidateDevApp(config.root, filePath, event)) {\n devApp.invalidate()\n }\n if (shouldForceFullReloadForWatcherEvent(filePath, event)) {\n server.ws.send({\n path: '*',\n type: 'full-reload',\n } as any)\n }\n }\n\n server.watcher.on('add', (filePath) => {\n invalidateDevApp(filePath, 'add')\n })\n server.watcher.on('change', (filePath) => {\n invalidateDevApp(filePath, 'change')\n })\n server.watcher.on('unlink', (filePath) => {\n invalidateDevApp(filePath, 'unlink')\n })\n\n server.middlewares.use(async (req, res, next) => {\n const webReq = incomingMessageToRequest(req)\n const webRes = await devApp.fetch(webReq)\n if (webRes) {\n responseForServerResponse(webRes, res)\n return\n }\n next()\n })\n },\n async load(id) {\n if (!parseSymbolRequest(id)) {\n return null\n }\n return this.environment.name === 'client'\n ? loadSymbolModuleForClient(id)\n : loadSymbolModuleForSSR(id)\n },\n async transform(code, id) {\n if (!isEclipsaSourceRequest(id) || parseSymbolRequest(id)) {\n return\n }\n const config = state.config\n if (!config) {\n throw new Error('Resolved Vite config is unavailable during transform().')\n }\n if (isTestLikeSourceRequest(id)) {\n return transformWithOxc(code, id, {\n jsx: {\n development: !config.isProduction,\n importSource: 'eclipsa',\n runtime: 'automatic',\n },\n })\n }\n const isClient = this.environment.name === 'client'\n return {\n code: isClient\n ? await compileModuleForClient(code, id, {\n hmr: !config.isProduction,\n })\n : await compileModuleForSSR(code, id),\n }\n },\n }\n}\n\nconst eclipsaHot = (state: EclipsaPluginState): Plugin => ({\n enforce: 'post',\n name: 'vite-plugin-eclipsa:hmr',\n async hotUpdate(options) {\n return handleHotUpdate(\n state,\n this as PluginContextWithEnvironment,\n options as unknown as HotUpdateContext,\n ) as any\n },\n})\n\nexport type { EclipsaPluginOptions } from './options.ts'\n\nexport const eclipsa = (options?: EclipsaPluginOptions): PluginOption => {\n const state: EclipsaPluginState = {}\n return [eclipsaCore(state, options), eclipsaHot(state)]\n}\n"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAa,sBAAsB,aAAqB;CACtD,MAAM,iBAAiB,SAAS,MAAM,IAAI;CAC1C,MAAM,mBAAmB,eAAe,WAAW,IAAI,GAAG,iBAAiB,IAAI;AAC/E,KAAI,iBAAiB,SAAS,KAAK,iBAAiB,SAAS,IAAI,CAC/D,QAAO,iBAAiB,MAAM,GAAG,GAAG;AAEtC,QAAO;;AAyCT,MAAM,8BAAmD;CACvD,OAAO;CACP,QAAQ;CACR,SAAS;CACT,YAAY;CACZ,UAAU;CACV,MAAM;CACN,QAAQ;CACT;AAED,MAAM,eAAe,iBAAyB;CAG5C,MAAM,WAFa,aAAa,WAAW,MAAM,IAAI,CACvB,QAAQ,YAAY,GAAG,CACzB,MAAM,IAAI;CACtC,MAAM,WAAW,SAAS,KAAK,IAAI;AAYnC,QAAO,CAXQ,SAAS,WAAW,UAAU,GACzC,WACA,SAAS,WAAW,QAAQ,GAC1B,UACA,SAAS,WAAW,UAAU,GAC5B,WACA,WAKQ,GAJD,SACZ,KAAK,YAAY,QAAQ,WAAW,kBAAkB,IAAI,IAAI,QAAQ,CACtE,OAAO,SAAS,WAAW,kBAAkB,IAAI,IAAI,QAAQ,CAEtC,CAAC,KAAK,KAAK;;AAGvC,MAAM,sBACJ,QACA,UACA,mBACmB;CACnB,MAAM,eAAe,KAAK,SAAS,QAAQ,SAAS,CAAC,WAAW,MAAM,IAAI;AAC1E,QAAO;EACL;EACA,KAAK,qBAAqB,KAAK,MAAM,QAAQ,aAAa,CAAC;EAC3D,WAAW,YAAY,aAAa;EACpC;EAC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Aa,WAAW,YAAiD;CACvE,MAAM,QAA4B,EAAE;AACpC,QAAO,CAAC,YAAY,OAAO,QAAQ,EAAE,WAAW,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.mjs","names":["path","fileExists","path","toIdsByFilePath","getRouteReachableEntryFiles","createRouteServerAccessEntries","path","fileExists","path"],"sources":["../../vite/utils/routing.ts","../../compiler/analyze/mod.ts","../../compiler/client/mod.ts","../../compiler/ssr/mod.ts","../../vite/compiler.ts","../../vite/dev-app/mod.ts","../../utils/node-connect.ts","../../utils/xxhash32.ts","../../vite/build/mod.ts","../../vite/nitro.ts","../../vite/config.ts","../../vite/options.ts","../../vite/mod.ts"],"sourcesContent":["import fg from 'fast-glob'\nimport * as fs from 'node:fs/promises'\nimport path from 'node:path'\nimport type {\n RouteManifest,\n RouteModuleManifest,\n RouteParams,\n RoutePathSegment,\n} from '../../core/router-shared.ts'\n\nexport const normalizeRoutePath = (pathname: string) => {\n const normalizedPath = pathname.trim() || '/'\n const withLeadingSlash = normalizedPath.startsWith('/') ? normalizedPath : `/${normalizedPath}`\n if (withLeadingSlash.length > 1 && withLeadingSlash.endsWith('/')) {\n return withLeadingSlash.slice(0, -1)\n }\n return withLeadingSlash\n}\n\nexport interface RouteEntry {\n error: RouteModuleEntry | null\n layouts: RouteModuleEntry[]\n loading: RouteModuleEntry | null\n middlewares: RouteModuleEntry[]\n notFound: RouteModuleEntry | null\n page: RouteModuleEntry | null\n renderMode?: 'dynamic' | 'static' | null\n routePath: string\n segments: RoutePathSegment[]\n server: RouteModuleEntry | null\n}\n\nexport interface RouteModuleEntry {\n entryName: string\n filePath: string\n}\n\ninterface RouteFileEntry extends RouteModuleEntry {\n breakoutTarget: string | null\n dir: string\n}\n\ninterface RouteDirectoryEntry {\n error: RouteFileEntry | null\n layout: RouteFileEntry | null\n loading: RouteFileEntry | null\n middleware: RouteFileEntry | null\n notFound: RouteFileEntry | null\n page: RouteFileEntry | null\n server: RouteFileEntry | null\n}\n\ninterface RouteMatch<T> {\n params: RouteParams\n route: T\n}\n\nconst createDirectoryEntry = (): RouteDirectoryEntry => ({\n error: null,\n layout: null,\n loading: null,\n middleware: null,\n notFound: null,\n page: null,\n server: null,\n})\n\nconst toEntryName = (relativePath: string) => {\n const normalized = relativePath.replaceAll('\\\\', '/')\n const withoutExt = normalized.replace(/\\.[^.]+$/, '')\n const segments = withoutExt.split('/')\n const fileName = segments.pop() ?? 'index'\n const prefix = fileName.startsWith('+layout')\n ? 'layout'\n : fileName.startsWith('+page')\n ? 'route'\n : fileName.startsWith('+server')\n ? 'server'\n : 'special'\n const mapped = segments\n .map((segment) => segment.replaceAll(/[^a-zA-Z0-9]+/g, '_') || 'index')\n .concat(fileName.replaceAll(/[^a-zA-Z0-9]+/g, '_') || 'index')\n\n return [prefix, ...mapped].join('__')\n}\n\nconst toRouteModuleEntry = (\n appDir: string,\n filePath: string,\n breakoutTarget: string | null,\n): RouteFileEntry => {\n const relativePath = path.relative(appDir, filePath).replaceAll('\\\\', '/')\n return {\n breakoutTarget,\n dir: normalizeRelativeDir(path.posix.dirname(relativePath)),\n entryName: toEntryName(relativePath),\n filePath,\n }\n}\n\nconst normalizeRelativeDir = (relativeDir: string) =>\n relativeDir === '.' || relativeDir === '' ? '' : relativeDir.replaceAll('\\\\', '/')\n\nconst splitRelativeDir = (relativeDir: string) => (relativeDir === '' ? [] : relativeDir.split('/'))\n\nconst ancestorDirs = (relativeDir: string) => {\n const segments = splitRelativeDir(relativeDir)\n return Array.from({ length: segments.length + 1 }, (_, index) =>\n normalizeRelativeDir(segments.slice(0, index).join('/')),\n )\n}\n\nconst getDirBaseName = (relativeDir: string) => {\n const segments = splitRelativeDir(relativeDir)\n return segments.length === 0 ? '' : segments[segments.length - 1]!\n}\n\nconst isGroupSegment = (segment: string) => /^\\(.+\\)$/.test(segment)\n\nconst toRouteSegment = (segment: string): RoutePathSegment | null => {\n if (isGroupSegment(segment)) {\n return null\n }\n const optionalMatch = /^\\[\\[([^\\]]+)\\]\\]$/.exec(segment)\n if (optionalMatch) {\n return {\n kind: 'optional',\n value: optionalMatch[1]!,\n }\n }\n const restMatch = /^\\[\\.\\.\\.([^\\]]+)\\]$/.exec(segment)\n if (restMatch) {\n return {\n kind: 'rest',\n value: restMatch[1]!,\n }\n }\n const requiredMatch = /^\\[([^\\]]+)\\]$/.exec(segment)\n if (requiredMatch) {\n return {\n kind: 'required',\n value: requiredMatch[1]!,\n }\n }\n return {\n kind: 'static',\n value: segment,\n }\n}\n\nconst toRouteSegments = (relativeDir: string) =>\n splitRelativeDir(relativeDir)\n .map((segment) => toRouteSegment(segment))\n .filter((segment): segment is RoutePathSegment => segment !== null)\n\nconst segmentsToRoutePath = (segments: RoutePathSegment[]) => {\n if (segments.length === 0) {\n return '/'\n }\n return normalizeRoutePath(\n segments\n .map((segment) => {\n switch (segment.kind) {\n case 'required':\n return `[${segment.value}]`\n case 'optional':\n return `[[${segment.value}]]`\n case 'rest':\n return `[...${segment.value}]`\n default:\n return segment.value\n }\n })\n .join('/'),\n )\n}\n\nconst resolveAncestorDirs = (relativeDir: string, breakoutTarget: string | null) => {\n const candidates = ancestorDirs(relativeDir)\n if (breakoutTarget === null) {\n return candidates\n }\n if (breakoutTarget === '') {\n return candidates.slice(0, 1)\n }\n for (let index = candidates.length - 1; index >= 0; index -= 1) {\n const baseName = getDirBaseName(candidates[index]!)\n if (baseName === breakoutTarget || baseName === `(${breakoutTarget})`) {\n return candidates.slice(0, index + 1)\n }\n }\n return candidates.slice(0, 1)\n}\n\nconst scoreSegment = (segment: RoutePathSegment | undefined) => {\n if (!segment) {\n return 0\n }\n switch (segment.kind) {\n case 'static':\n return 4\n case 'required':\n return 3\n case 'optional':\n return 2\n case 'rest':\n return 1\n }\n}\n\nconst compareRouteEntries = (left: RouteEntry, right: RouteEntry) => {\n const limit = Math.max(left.segments.length, right.segments.length)\n for (let index = 0; index < limit; index += 1) {\n const scoreDelta = scoreSegment(right.segments[index]) - scoreSegment(left.segments[index])\n if (scoreDelta !== 0) {\n return scoreDelta\n }\n }\n return right.segments.length - left.segments.length\n}\n\nconst matchSegments = (\n segments: RoutePathSegment[],\n pathnameSegments: string[],\n routeIndex = 0,\n pathIndex = 0,\n params: RouteParams = {},\n): RouteParams | null => {\n if (routeIndex >= segments.length) {\n return pathIndex >= pathnameSegments.length ? params : null\n }\n\n const segment = segments[routeIndex]!\n switch (segment.kind) {\n case 'static':\n if (pathnameSegments[pathIndex] !== segment.value) {\n return null\n }\n return matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex + 1, params)\n case 'required':\n if (pathIndex >= pathnameSegments.length) {\n return null\n }\n return matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex + 1, {\n ...params,\n [segment.value]: pathnameSegments[pathIndex],\n })\n case 'optional': {\n const consumed =\n pathIndex < pathnameSegments.length\n ? matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex + 1, {\n ...params,\n [segment.value]: pathnameSegments[pathIndex],\n })\n : null\n if (consumed) {\n return consumed\n }\n return matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex, {\n ...params,\n [segment.value]: undefined,\n })\n }\n case 'rest': {\n const rest = pathnameSegments.slice(pathIndex)\n if (rest.length === 0) {\n return null\n }\n return matchSegments(segments, pathnameSegments, segments.length, pathnameSegments.length, {\n ...params,\n [segment.value]: rest,\n })\n }\n }\n}\n\nconst toMatch = <T extends { segments: RoutePathSegment[] }>(\n route: T,\n pathname: string,\n): RouteMatch<T> | null => {\n const pathnameSegments = normalizeRoutePath(pathname).split('/').filter(Boolean)\n const params = matchSegments(route.segments, pathnameSegments)\n if (!params) {\n return null\n }\n return {\n params,\n route,\n }\n}\n\nconst selectNearestSpecial = (\n directories: Map<string, RouteDirectoryEntry>,\n candidateDirs: string[],\n kind: 'error' | 'loading' | 'notFound',\n) => {\n for (let index = candidateDirs.length - 1; index >= 0; index -= 1) {\n const entry = directories.get(candidateDirs[index]!)?.[kind]\n if (entry) {\n return entry\n }\n }\n return null\n}\n\nconst collectLayouts = (\n directories: Map<string, RouteDirectoryEntry>,\n relativeDir: string,\n breakoutTarget: string | null,\n) => {\n let layouts: RouteFileEntry[] = []\n for (const candidateDir of ancestorDirs(relativeDir)) {\n const layout = directories.get(candidateDir)?.layout\n if (!layout) {\n continue\n }\n if (layout.breakoutTarget !== null) {\n const allowedDirs = new Set(resolveAncestorDirs(candidateDir, layout.breakoutTarget))\n layouts = layouts.filter((entry) => allowedDirs.has(entry.dir))\n }\n layouts.push(layout)\n }\n\n if (breakoutTarget !== null) {\n const allowedDirs = new Set(resolveAncestorDirs(relativeDir, breakoutTarget))\n layouts = layouts.filter((entry) => allowedDirs.has(entry.dir))\n }\n\n return layouts.map(({ entryName, filePath }) => ({ entryName, filePath }))\n}\n\nconst collectMiddlewares = (\n directories: Map<string, RouteDirectoryEntry>,\n candidateDirs: string[],\n) =>\n candidateDirs.flatMap((candidateDir) => {\n const middleware = directories.get(candidateDir)?.middleware\n return middleware ? [{ entryName: middleware.entryName, filePath: middleware.filePath }] : []\n })\n\nconst parseAppFile = (appDir: string, filePath: string) => {\n const relativePath = path.relative(appDir, filePath).replaceAll('\\\\', '/')\n const fileName = path.posix.basename(relativePath)\n const dir = normalizeRelativeDir(path.posix.dirname(relativePath))\n\n const pageMatch = /^\\+page(?:@(.*))?\\.tsx$/.exec(fileName)\n if (pageMatch) {\n return {\n breakoutTarget: pageMatch[1] ?? null,\n dir,\n kind: 'page' as const,\n relativePath,\n }\n }\n\n const layoutMatch = /^\\+layout(?:@(.*))?\\.tsx$/.exec(fileName)\n if (layoutMatch) {\n return {\n breakoutTarget: layoutMatch[1] ?? null,\n dir,\n kind: 'layout' as const,\n relativePath,\n }\n }\n\n if (fileName === '+loading.tsx') {\n return { breakoutTarget: null, dir, kind: 'loading' as const, relativePath }\n }\n if (/^\\+middleware\\.(ts|tsx)$/.test(fileName)) {\n return { breakoutTarget: null, dir, kind: 'middleware' as const, relativePath }\n }\n if (fileName === '+error.tsx') {\n return { breakoutTarget: null, dir, kind: 'error' as const, relativePath }\n }\n if (fileName === '+not-found.tsx') {\n return { breakoutTarget: null, dir, kind: 'notFound' as const, relativePath }\n }\n if (/^\\+server\\.(ts|tsx)$/.test(fileName)) {\n return { breakoutTarget: null, dir, kind: 'server' as const, relativePath }\n }\n return null\n}\n\nconst resolvePageRenderMode = async (filePath: string): Promise<'dynamic' | 'static' | null> => {\n const source = await fs.readFile(filePath, 'utf8')\n const match = source.match(/export\\s+const\\s+render\\s*=\\s*(['\"])([^'\"\\\\]+)\\1(?:\\s+as\\s+const)?/s)\n if (!match) {\n return null\n }\n if (match[2] === 'dynamic' || match[2] === 'static') {\n return match[2]\n }\n throw new Error(\n `Unsupported render mode \"${match[2]}\" in ${filePath}. Expected \"static\" or \"dynamic\".`,\n )\n}\n\nexport const createRoutes = async (root: string): Promise<RouteEntry[]> => {\n const appDir = path.join(root, 'app')\n const filePaths = (await fg(path.join(appDir, '**/*.{ts,tsx}').replaceAll('\\\\', '/'))).sort()\n const directories = new Map<string, RouteDirectoryEntry>()\n\n for (const filePath of filePaths) {\n const parsed = parseAppFile(appDir, filePath)\n if (!parsed) {\n continue\n }\n const directory = directories.get(parsed.dir) ?? createDirectoryEntry()\n directory[parsed.kind] = toRouteModuleEntry(appDir, filePath, parsed.breakoutTarget)\n directories.set(parsed.dir, directory)\n }\n\n const result: RouteEntry[] = []\n const seenRoutePaths = new Map<string, string>()\n\n for (const [relativeDir, directory] of [...directories.entries()].sort(([left], [right]) =>\n left.localeCompare(right),\n )) {\n if (!directory.page && !directory.server) {\n continue\n }\n\n const segments = toRouteSegments(relativeDir)\n const routePath = segmentsToRoutePath(segments)\n const previousDir = seenRoutePaths.get(routePath)\n if (previousDir && previousDir !== relativeDir) {\n throw new Error(`Duplicate route pattern ${routePath} for ${previousDir} and ${relativeDir}.`)\n }\n seenRoutePaths.set(routePath, relativeDir)\n\n const effectiveAncestorDirs = resolveAncestorDirs(\n relativeDir,\n directory.page?.breakoutTarget ?? null,\n )\n result.push({\n error: directory.page\n ? selectNearestSpecial(directories, effectiveAncestorDirs, 'error')\n : null,\n layouts: directory.page\n ? collectLayouts(directories, relativeDir, directory.page?.breakoutTarget ?? null)\n : [],\n loading: directory.page\n ? selectNearestSpecial(directories, effectiveAncestorDirs, 'loading')\n : null,\n middlewares:\n directory.page || directory.server\n ? collectMiddlewares(directories, effectiveAncestorDirs)\n : [],\n notFound: directory.page\n ? selectNearestSpecial(directories, effectiveAncestorDirs, 'notFound')\n : null,\n page: directory.page,\n renderMode: directory.page ? await resolvePageRenderMode(directory.page.filePath) : null,\n routePath,\n segments,\n server: directory.server,\n })\n }\n\n return result.sort(compareRouteEntries)\n}\n\nexport const collectRouteModules = (routes: RouteEntry[]): RouteModuleEntry[] => {\n const modules = new Map<string, RouteModuleEntry>()\n for (const route of routes) {\n for (const entry of [\n route.page,\n ...route.layouts,\n route.loading,\n route.error,\n route.notFound,\n ]) {\n if (!entry) {\n continue\n }\n modules.set(entry.filePath, entry)\n }\n }\n return [...modules.values()]\n}\n\nexport const collectRouteServerModules = (routes: RouteEntry[]): RouteModuleEntry[] => {\n const modules = new Map<string, RouteModuleEntry>()\n for (const route of routes) {\n for (const middleware of route.middlewares) {\n modules.set(middleware.filePath, middleware)\n }\n if (route.server) {\n modules.set(route.server.filePath, route.server)\n }\n }\n return [...modules.values()]\n}\n\nexport const createDevModuleUrl = (root: string, entry: { filePath: string }) =>\n `/${path.relative(root, entry.filePath).replaceAll('\\\\', '/')}`\n\nexport const createBuildModuleUrl = (entry: RouteModuleEntry) => `/entries/${entry.entryName}.js`\n\nexport const createBuildServerModuleUrl = (entry: RouteModuleEntry) =>\n `../ssr/entries/${entry.entryName}.mjs`\n\nexport const createRouteManifest = (\n routes: RouteEntry[],\n resolveUrl: (module: RouteModuleEntry) => string,\n): RouteManifest =>\n routes.map(\n (route) =>\n ({\n error: route.error ? resolveUrl(route.error) : null,\n hasMiddleware: route.middlewares.length > 0,\n layouts: route.layouts.map((layout) => resolveUrl(layout)),\n loading: route.loading ? resolveUrl(route.loading) : null,\n notFound: route.notFound ? resolveUrl(route.notFound) : null,\n page: route.page ? resolveUrl(route.page) : null,\n routePath: route.routePath,\n segments: route.segments,\n server: route.server ? resolveUrl(route.server) : null,\n }) satisfies RouteModuleManifest,\n )\n\nexport const matchRoute = <T extends { routePath: string; segments: RoutePathSegment[] }>(\n routes: T[],\n pathname: string,\n): RouteMatch<T> | null => {\n for (const route of routes) {\n const matched = toMatch(route, pathname)\n if (matched) {\n return matched\n }\n }\n return null\n}\n","import ts from 'typescript'\nimport { runRustAnalyzeCompiler } from '@eclipsa/optimizer'\n\ntype SymbolKind = 'action' | 'component' | 'event' | 'lazy' | 'loader' | 'watch'\n\nexport interface ResumeSymbol {\n captures: string[]\n code: string\n filePath: string\n id: string\n kind: SymbolKind\n}\n\nexport interface ResumeHmrSymbolEntry {\n captures: string[]\n hmrKey: string\n id: string\n kind: SymbolKind\n ownerComponentKey: string | null\n signature: string\n}\n\nexport interface ResumeHmrComponentEntry {\n captures: string[]\n hmrKey: string\n id: string\n localSymbolKeys: string[]\n signature: string\n}\n\nexport interface ResumeHmrManifest {\n components: Map<string, ResumeHmrComponentEntry>\n symbols: Map<string, ResumeHmrSymbolEntry>\n}\n\nexport interface AnalyzedModule {\n actions: Map<string, { filePath: string; id: string }>\n code: string\n hmrManifest: ResumeHmrManifest\n loaders: Map<string, { filePath: string; id: string }>\n symbols: Map<string, ResumeSymbol>\n}\n\nconst isPascalCase = (name: string) =>\n name.includes('.') ||\n (name.length > 0 && (!/[a-z]/.test(name[0]!) || name[0] !== name[0]!.toLowerCase()))\n\nconst unwrapExpression = (expression: ts.Expression): ts.Expression => {\n let current = expression\n while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current)) {\n current = current.expression\n }\n return current\n}\n\nconst getFunctionLikeComponent = (\n node: ts.Node,\n): ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration | null => {\n if (ts.isArrowFunction(node) || ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node)) {\n return node\n }\n if (ts.isParenthesizedExpression(node) || ts.isAsExpression(node)) {\n return getFunctionLikeComponent(node.expression)\n }\n return null\n}\n\nconst containsEarlyReturn = (node: ts.Node) => {\n let found = false\n\n const visit = (current: ts.Node) => {\n if (found) {\n return\n }\n if (\n current !== node &&\n (ts.isArrowFunction(current) ||\n ts.isFunctionDeclaration(current) ||\n ts.isFunctionExpression(current) ||\n ts.isGetAccessorDeclaration(current) ||\n ts.isMethodDeclaration(current) ||\n ts.isSetAccessorDeclaration(current))\n ) {\n return\n }\n if (ts.isReturnStatement(current)) {\n found = true\n return\n }\n ts.forEachChild(current, visit)\n }\n\n ts.forEachChild(node, visit)\n return found\n}\n\nconst validateSingleReturnComponent = (\n fn: ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration,\n label: string,\n) => {\n const body = fn.body\n if (!body || !ts.isBlock(body)) {\n return\n }\n\n const statements = body.statements\n const lastStatement = statements.at(-1)\n if (!lastStatement || !ts.isReturnStatement(lastStatement)) {\n throw new Error(\n `Component \"${label}\" must end with a single final return statement. Early returns are not supported.`,\n )\n }\n\n for (const statement of statements.slice(0, -1)) {\n if (containsEarlyReturn(statement)) {\n throw new Error(\n `Component \"${label}\" must use a single final return statement. Early returns are not supported.`,\n )\n }\n }\n}\n\nconst validateSingleReturnComponents = (source: string, id: string) => {\n const sourceFile = ts.createSourceFile(\n id,\n source,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TSX,\n )\n\n const validateComponentNode = (node: ts.Node, label: string) => {\n const component = getFunctionLikeComponent(node)\n if (component) {\n validateSingleReturnComponent(component, label)\n }\n }\n\n const visit = (node: ts.Node) => {\n if (\n ts.isVariableDeclaration(node) &&\n ts.isIdentifier(node.name) &&\n isPascalCase(node.name.text)\n ) {\n if (node.initializer) {\n validateComponentNode(node.initializer, node.name.text)\n }\n }\n\n if (ts.isFunctionDeclaration(node) && node.name && isPascalCase(node.name.text)) {\n validateSingleReturnComponent(node, node.name.text)\n }\n\n if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken) {\n const left = unwrapExpression(node.left)\n if (ts.isIdentifier(left) && isPascalCase(left.text)) {\n validateComponentNode(node.right, left.text)\n }\n }\n\n if (ts.isExportAssignment(node)) {\n validateComponentNode(node.expression, 'default')\n }\n\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n}\n\nconst annotateOptimizedRootComponents = (source: string, id: string) => {\n const sourceFile = ts.createSourceFile(\n id,\n source,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TSX,\n )\n const insertions: Array<{\n code: string\n index: number\n }> = []\n\n const visit = (node: ts.Node) => {\n if (\n ts.isCallExpression(node) &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === '__eclipsaComponent'\n ) {\n if (node.arguments.length >= 5) {\n return\n }\n const lastArgument = node.arguments.at(-1)\n insertions.push({\n code:\n node.arguments.length >= 4\n ? ', { optimizedRoot: true }'\n : ', undefined, { optimizedRoot: true }',\n index: lastArgument ? lastArgument.end : node.expression.end + 1,\n })\n }\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n\n if (insertions.length === 0) {\n return source\n }\n\n let nextSource = source\n for (const insertion of [...insertions].sort((left, right) => right.index - left.index)) {\n nextSource =\n nextSource.slice(0, insertion.index) + insertion.code + nextSource.slice(insertion.index)\n }\n\n return nextSource\n}\n\nexport const analyzeModule = async (\n source: string,\n id = 'analyze-input.tsx',\n): Promise<AnalyzedModule> => {\n validateSingleReturnComponents(source, id)\n const analyzed = await runRustAnalyzeCompiler(id, source)\n const code = annotateOptimizedRootComponents(analyzed.code, id)\n return {\n actions: new Map(analyzed.actions),\n code,\n hmrManifest: {\n components: new Map(analyzed.hmrManifest.components),\n symbols: new Map(analyzed.hmrManifest.symbols),\n },\n loaders: new Map(analyzed.loaders),\n symbols: new Map(analyzed.symbols),\n }\n}\n","import { runRustCompiler } from '@eclipsa/optimizer'\n\nexport const compileClientModule = async (\n input: string,\n id: string,\n options?: {\n hmr?: boolean\n },\n) => {\n return runRustCompiler({\n hmr: options?.hmr ?? true,\n id,\n source: input,\n target: 'client',\n })\n}\n","import { runRustCompiler } from '@eclipsa/optimizer'\n\nexport const compileSSRModule = async (code: string, id: string): Promise<string> => {\n return runRustCompiler({\n id,\n source: code,\n target: 'ssr',\n })\n}\n","import * as fs from 'node:fs/promises'\nimport * as path from 'node:path'\nimport fg from 'fast-glob'\nimport ts from 'typescript'\nimport {\n analyzeModule,\n compileClientModule,\n compileSSRModule,\n type AnalyzedModule,\n type ResumeHmrComponentEntry,\n type ResumeHmrSymbolEntry,\n type ResumeSymbol,\n} from '../compiler/mod.ts'\nimport type { ResumeHmrUpdatePayload } from '../core/resume-hmr.ts'\n\nconst SYMBOL_QUERY = 'eclipsa-symbol'\nconst SYMBOL_LANG_QUERY = 'lang.js'\n\ninterface AnalyzedEntry {\n analyzed: AnalyzedModule\n previous: {\n analyzed: AnalyzedModule\n source: string\n } | null\n source: string\n}\n\ninterface ResumeHmrResolution {\n isResumable: boolean\n nextEntry: AnalyzedEntry\n normalizedId: string\n update: ResumeHmrUpdatePayload | null\n}\n\nconst cache = new Map<string, AnalyzedEntry>()\nconst servedSources = new Map<string, string>()\n\nexport const resetCompilerCache = () => {\n cache.clear()\n servedSources.clear()\n}\n\nexport const primeCompilerCache = async (filePath: string, source?: string) => {\n const normalizedPath = stripQuery(filePath)\n const normalizedId = normalizeCompilerModuleId(normalizedPath)\n const resolvedSource = source ?? (await fs.readFile(normalizedPath, 'utf8'))\n servedSources.set(normalizedId, resolvedSource)\n await loadAnalyzedModule(normalizedPath, resolvedSource)\n}\n\nconst stripQuery = (id: string) => {\n const queryIndex = id.indexOf('?')\n if (queryIndex < 0) {\n return id\n }\n return id.slice(0, queryIndex)\n}\n\nconst normalizeCompilerModuleId = (id: string) => {\n const normalized = stripQuery(id).replaceAll('\\\\', '/')\n if (normalized.startsWith('/app/')) {\n return normalized\n }\n const appIndex = normalized.lastIndexOf('/app/')\n if (appIndex >= 0) {\n return normalized.slice(appIndex)\n }\n return normalized\n}\n\nconst isAppModuleId = (id: string) => normalizeCompilerModuleId(id).startsWith('/app/')\n\nexport const parseSymbolRequest = (id: string): { filePath: string; symbolId: string } | null => {\n const queryIndex = id.indexOf('?')\n if (queryIndex < 0) {\n return null\n }\n\n const params = new URLSearchParams(id.slice(queryIndex + 1))\n const symbolId = params.get(SYMBOL_QUERY)\n if (!symbolId) {\n return null\n }\n\n return {\n filePath: id.slice(0, queryIndex),\n symbolId,\n }\n}\n\nexport const createSymbolRequestId = (filePath: string, symbolId: string) =>\n `${filePath}?${SYMBOL_QUERY}=${symbolId}&${SYMBOL_LANG_QUERY}`\n\nconst loadAnalyzedModule = async (filePath: string, source?: string) => {\n const normalizedPath = stripQuery(filePath)\n const normalizedId = normalizeCompilerModuleId(normalizedPath)\n const cached = cache.get(normalizedId)\n if (source == null && cached && isAppModuleId(normalizedPath)) {\n return cached.analyzed\n }\n\n const resolvedSource = source ?? (await fs.readFile(normalizedPath, 'utf8'))\n if (cached?.source === resolvedSource) {\n return cached.analyzed\n }\n\n const analyzed = await analyzeModule(resolvedSource, normalizedId)\n if (!analyzed) {\n throw new Error(`Failed to compile ${normalizedId}.`)\n }\n\n const entry = {\n analyzed,\n previous: cached\n ? {\n analyzed: cached.analyzed,\n source: cached.source,\n }\n : null,\n source: resolvedSource,\n } satisfies AnalyzedEntry\n cache.set(normalizedId, entry)\n\n return entry.analyzed\n}\n\nconst createAnalyzedEntry = async (filePath: string, source: string): Promise<AnalyzedEntry> => {\n const analyzed = await analyzeModule(source, normalizeCompilerModuleId(filePath))\n if (!analyzed) {\n throw new Error(`Failed to compile ${filePath}.`)\n }\n\n return {\n analyzed,\n previous: null,\n source,\n }\n}\n\nconst findCachedAnalyzedModuleBySymbolId = (symbolId: string) => {\n for (const entry of cache.values()) {\n if (entry.analyzed.symbols.has(symbolId)) {\n return entry.analyzed\n }\n }\n return null\n}\n\nconst getComponentEntryById = (components: Map<string, ResumeHmrComponentEntry>, id: string) => {\n for (const component of components.values()) {\n if (component.id === id) {\n return component\n }\n }\n return null\n}\n\nconst sameStrings = (left: string[], right: string[]) =>\n left.length === right.length && left.every((value, index) => value === right[index])\n\nconst createDevSourceUrl = (root: string, filePath: string) => {\n const normalizedRoot = root.replaceAll('\\\\', '/').replace(/\\/$/, '')\n const normalizedFilePath = filePath.replaceAll('\\\\', '/')\n if (normalizedFilePath.startsWith('/app/')) {\n return normalizedFilePath\n }\n if (\n normalizedFilePath === normalizedRoot ||\n normalizedFilePath.startsWith(`${normalizedRoot}/`)\n ) {\n return `/${path.relative(root, filePath).replaceAll('\\\\', '/')}`\n }\n return `/@fs/${normalizedFilePath}`\n}\n\nconst findOwnerComponentForSymbol = (\n oldSymbol: ResumeHmrSymbolEntry,\n components: Map<string, ResumeHmrComponentEntry>,\n) => {\n if (oldSymbol.ownerComponentKey) {\n return components.get(oldSymbol.ownerComponentKey) ?? null\n }\n if (oldSymbol.kind === 'component') {\n return getComponentEntryById(components, oldSymbol.id)\n }\n return null\n}\n\nexport const createResumeHmrUpdate = (options: {\n filePath: string\n next: AnalyzedModule\n previous: AnalyzedModule | null\n root: string\n}): ResumeHmrUpdatePayload | null => {\n const { filePath, next, previous, root } = options\n const fileUrl = createDevSourceUrl(root, filePath)\n if (!previous) {\n return next.symbols.size > 0\n ? {\n fileUrl,\n fullReload: true,\n rerenderComponentSymbols: [],\n rerenderOwnerSymbols: [],\n symbolUrlReplacements: {},\n }\n : null\n }\n if (previous.symbols.size === 0 && next.symbols.size === 0) {\n return null\n }\n\n const previousManifest = previous.hmrManifest\n const nextManifest = next.hmrManifest\n const rerenderComponentSymbols = new Set<string>()\n const rerenderOwnerSymbols = new Set<string>()\n const symbolUrlReplacements: Record<string, string> = {}\n let fullReload = previous.symbols.size > 0 && next.symbols.size === 0\n\n const markOwnerRerender = (symbol: ResumeHmrSymbolEntry) => {\n const owner = findOwnerComponentForSymbol(symbol, previousManifest.components)\n if (!owner) {\n fullReload = true\n return\n }\n rerenderOwnerSymbols.add(owner.id)\n }\n\n if (previousManifest.components.size !== nextManifest.components.size) {\n fullReload = true\n }\n\n for (const [hmrKey, previousComponent] of previousManifest.components) {\n const nextComponent = nextManifest.components.get(hmrKey)\n if (!nextComponent) {\n fullReload = true\n continue\n }\n if (!sameStrings(previousComponent.localSymbolKeys, nextComponent.localSymbolKeys)) {\n rerenderOwnerSymbols.add(previousComponent.id)\n }\n if (!sameStrings(previousComponent.captures, nextComponent.captures)) {\n rerenderOwnerSymbols.add(previousComponent.id)\n }\n }\n\n for (const [hmrKey, nextComponent] of nextManifest.components) {\n if (!previousManifest.components.has(hmrKey)) {\n fullReload = true\n if (nextComponent.id) {\n continue\n }\n }\n }\n\n for (const [hmrKey, previousSymbol] of previousManifest.symbols) {\n const nextSymbol = nextManifest.symbols.get(hmrKey)\n if (!nextSymbol || nextSymbol.kind !== previousSymbol.kind) {\n if (previousSymbol.kind === 'component') {\n fullReload = true\n } else {\n markOwnerRerender(previousSymbol)\n }\n continue\n }\n\n if (previousSymbol.id !== nextSymbol.id) {\n symbolUrlReplacements[previousSymbol.id] = createDevSymbolUrl(root, filePath, nextSymbol.id)\n }\n\n if (!sameStrings(previousSymbol.captures, nextSymbol.captures)) {\n markOwnerRerender(previousSymbol)\n continue\n }\n\n if (previousSymbol.kind === 'component') {\n if (previousSymbol.signature !== nextSymbol.signature) {\n rerenderComponentSymbols.add(previousSymbol.id)\n }\n continue\n }\n\n if (previousSymbol.signature === nextSymbol.signature) {\n continue\n }\n\n if (previousSymbol.kind === 'watch') {\n markOwnerRerender(previousSymbol)\n }\n }\n\n for (const [hmrKey, nextSymbol] of nextManifest.symbols) {\n if (previousManifest.symbols.has(hmrKey)) {\n continue\n }\n if (nextSymbol.kind === 'component') {\n fullReload = true\n continue\n }\n symbolUrlReplacements[nextSymbol.id] = createDevSymbolUrl(root, filePath, nextSymbol.id)\n const owner = nextSymbol.ownerComponentKey\n ? previousManifest.components.get(nextSymbol.ownerComponentKey)\n : null\n if (!owner) {\n fullReload = true\n continue\n }\n rerenderOwnerSymbols.add(owner.id)\n }\n\n if (fullReload) {\n return {\n fileUrl,\n fullReload: true,\n rerenderComponentSymbols: [],\n rerenderOwnerSymbols: [],\n symbolUrlReplacements: {},\n }\n }\n\n for (const ownerSymbol of rerenderOwnerSymbols) {\n rerenderComponentSymbols.delete(ownerSymbol)\n }\n\n if (\n rerenderComponentSymbols.size === 0 &&\n rerenderOwnerSymbols.size === 0 &&\n Object.keys(symbolUrlReplacements).length === 0\n ) {\n return {\n fileUrl,\n fullReload: false,\n rerenderComponentSymbols: [],\n rerenderOwnerSymbols: [],\n symbolUrlReplacements: {},\n }\n }\n\n return {\n fileUrl,\n fullReload: false,\n rerenderComponentSymbols: [...rerenderComponentSymbols],\n rerenderOwnerSymbols: [...rerenderOwnerSymbols],\n symbolUrlReplacements,\n }\n}\n\nexport const resolveResumeHmrUpdate = async (options: {\n filePath: string\n root: string\n source: string\n}): Promise<{\n isResumable: boolean\n update: ResumeHmrUpdatePayload | null\n}> => {\n const resolution = await inspectResumeHmrUpdate(options)\n cache.set(resolution.normalizedId, resolution.nextEntry)\n return {\n isResumable: resolution.isResumable,\n update: resolution.update,\n }\n}\n\nexport const inspectResumeHmrUpdate = async (options: {\n filePath: string\n root: string\n source: string\n}): Promise<ResumeHmrResolution> => {\n const normalizedPath = stripQuery(options.filePath)\n const normalizedId = normalizeCompilerModuleId(normalizedPath)\n const cached = cache.get(normalizedId)\n let nextEntry: AnalyzedEntry\n if (cached?.source === options.source) {\n nextEntry = cached\n } else {\n const createdEntry = await createAnalyzedEntry(normalizedPath, options.source)\n nextEntry = {\n ...createdEntry,\n previous: cached\n ? {\n analyzed: cached.analyzed,\n source: cached.source,\n }\n : null,\n }\n }\n let previous =\n cached?.source === options.source\n ? (nextEntry.previous?.analyzed ?? null)\n : (cached?.analyzed ?? null)\n if (!previous) {\n const servedSource = servedSources.get(normalizedId)\n if (servedSource && servedSource !== options.source) {\n const previousEntry = await createAnalyzedEntry(normalizedPath, servedSource)\n previous = previousEntry.analyzed\n if (!nextEntry.previous) {\n nextEntry = {\n ...nextEntry,\n previous: {\n analyzed: previousEntry.analyzed,\n source: servedSource,\n },\n }\n }\n }\n }\n const update = createResumeHmrUpdate({\n filePath: normalizedPath,\n next: nextEntry.analyzed,\n previous,\n root: options.root,\n })\n servedSources.set(normalizedId, nextEntry.source)\n return {\n isResumable: (previous?.symbols.size ?? 0) > 0 || nextEntry.analyzed.symbols.size > 0,\n nextEntry,\n normalizedId,\n update,\n }\n}\n\nexport const compileModuleForClient = async (\n source: string,\n id: string,\n options?: {\n hmr?: boolean\n },\n) => {\n const filePath = stripQuery(id)\n const normalizedId = normalizeCompilerModuleId(filePath)\n const analyzed = await loadAnalyzedModule(filePath, source)\n servedSources.set(normalizedId, servedSources.get(normalizedId) ?? source)\n return compileClientModule(analyzed.code, filePath, {\n hmr: options?.hmr ?? false,\n })\n}\n\nexport const compileModuleForSSR = async (source: string, id: string) => {\n const filePath = stripQuery(id)\n const normalizedId = normalizeCompilerModuleId(filePath)\n const analyzed = await loadAnalyzedModule(filePath, source)\n servedSources.set(normalizedId, servedSources.get(normalizedId) ?? source)\n return compileSSRModule(analyzed.code, filePath)\n}\n\nexport const loadSymbolModuleForClient = async (id: string) => {\n const parsed = parseSymbolRequest(id)\n if (!parsed) {\n return null\n }\n\n let currentAnalyzed = findCachedAnalyzedModuleBySymbolId(parsed.symbolId)\n try {\n const currentSource = await fs.readFile(stripQuery(parsed.filePath), 'utf8')\n currentAnalyzed = await loadAnalyzedModule(parsed.filePath, currentSource)\n } catch (error) {\n const code = (error as NodeJS.ErrnoException | undefined)?.code\n if (code !== 'ENOENT' && code !== 'ENOTDIR') {\n throw error\n }\n currentAnalyzed ??= await loadAnalyzedModule(parsed.filePath)\n }\n const analyzed = currentAnalyzed.symbols.has(parsed.symbolId)\n ? currentAnalyzed\n : (findCachedAnalyzedModuleBySymbolId(parsed.symbolId) ?? currentAnalyzed)\n const symbol = analyzed.symbols.get(parsed.symbolId)\n if (!symbol) {\n throw new Error(`Unknown resume symbol ${parsed.symbolId} for ${parsed.filePath}.`)\n }\n\n return compileClientModule(symbol.code, `${parsed.filePath}?${SYMBOL_QUERY}=${parsed.symbolId}`, {\n hmr: false,\n })\n}\n\nexport const loadSymbolModuleForSSR = async (id: string) => {\n const parsed = parseSymbolRequest(id)\n if (!parsed) {\n return null\n }\n\n let currentAnalyzed = findCachedAnalyzedModuleBySymbolId(parsed.symbolId)\n try {\n const currentSource = await fs.readFile(stripQuery(parsed.filePath), 'utf8')\n currentAnalyzed = await loadAnalyzedModule(parsed.filePath, currentSource)\n } catch (error) {\n const code = (error as NodeJS.ErrnoException | undefined)?.code\n if (code !== 'ENOENT' && code !== 'ENOTDIR') {\n throw error\n }\n currentAnalyzed ??= await loadAnalyzedModule(parsed.filePath)\n }\n const analyzed = currentAnalyzed.symbols.has(parsed.symbolId)\n ? currentAnalyzed\n : (findCachedAnalyzedModuleBySymbolId(parsed.symbolId) ?? currentAnalyzed)\n const symbol = analyzed.symbols.get(parsed.symbolId)\n if (!symbol) {\n throw new Error(`Unknown resume symbol ${parsed.symbolId} for ${parsed.filePath}.`)\n }\n\n return compileSSRModule(symbol.code, `${parsed.filePath}?${SYMBOL_QUERY}=${parsed.symbolId}`)\n}\n\nexport const createDevSymbolUrl = (root: string, filePath: string, symbolId: string) =>\n createSymbolRequestId(createDevSourceUrl(root, filePath), symbolId)\n\nexport const createBuildSymbolUrl = (symbolId: string) => `/entries/symbol__${symbolId}.js`\n\nexport const createBuildServerActionUrl = (actionId: string) =>\n `../ssr/entries/action__${actionId}.mjs`\n\nexport const createBuildServerLoaderUrl = (loaderId: string) =>\n `../ssr/entries/loader__${loaderId}.mjs`\n\nconst ANALYZABLE_SOURCE_EXTENSIONS = new Set([\n '.cjs',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.mts',\n '.ts',\n '.tsx',\n])\n\nconst ANALYZABLE_APP_GLOB = '**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}'\n\nconst moduleResolutionOptions: ts.CompilerOptions = {\n allowImportingTsExtensions: true,\n jsx: ts.JsxEmit.Preserve,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n resolvePackageJsonExports: true,\n resolvePackageJsonImports: true,\n target: ts.ScriptTarget.ESNext,\n}\n\nconst moduleResolutionHost = ts.createCompilerHost(moduleResolutionOptions, true)\n\nconst isAnalyzableSourceFile = (filePath: string) => {\n const ext = path.extname(filePath)\n return ANALYZABLE_SOURCE_EXTENSIONS.has(ext) && !filePath.endsWith('.d.ts')\n}\n\nconst resolveImportedModule = (specifier: string, containingFile: string) =>\n ts.resolveModuleName(specifier, containingFile, moduleResolutionOptions, moduleResolutionHost)\n .resolvedModule?.resolvedFileName ?? null\n\nexport const collectAppSymbols = async (root: string): Promise<ResumeSymbol[]> => {\n const appDir = path.join(root, 'app')\n const entryFiles = await fg(path.join(appDir, ANALYZABLE_APP_GLOB).replaceAll('\\\\', '/'))\n const entryFileSet = new Set(entryFiles)\n const pending = [...entryFiles]\n const visited = new Set<string>()\n const symbols = new Map<string, ResumeSymbol>()\n\n while (pending.length > 0) {\n const next = pending.pop()\n if (!next) {\n continue\n }\n\n const filePath = stripQuery(next)\n if (visited.has(filePath) || !isAnalyzableSourceFile(filePath)) {\n continue\n }\n visited.add(filePath)\n\n let source: string\n try {\n source = await fs.readFile(filePath, 'utf8')\n } catch (error) {\n if (entryFileSet.has(filePath)) {\n throw error\n }\n continue\n }\n\n let analyzed: Awaited<ReturnType<typeof loadAnalyzedModule>>\n try {\n analyzed = await loadAnalyzedModule(filePath, source)\n } catch (error) {\n if (entryFileSet.has(filePath)) {\n throw error\n }\n continue\n }\n for (const symbol of analyzed.symbols.values()) {\n symbols.set(symbol.id, symbol)\n }\n\n const imports = ts.preProcessFile(source, true, true).importedFiles\n for (const imported of imports) {\n const resolvedFilePath = resolveImportedModule(imported.fileName, filePath)\n if (!resolvedFilePath || !isAnalyzableSourceFile(resolvedFilePath)) {\n continue\n }\n pending.push(resolvedFilePath)\n }\n }\n\n return [...symbols.values()]\n}\n\nexport const collectReachableAnalyzableFiles = async (\n entryFiles: readonly string[],\n): Promise<string[]> => {\n const pending = [...entryFiles]\n const visited = new Set<string>()\n const reachable = new Set<string>()\n const entryFileSet = new Set(entryFiles.map((filePath) => stripQuery(filePath)))\n\n while (pending.length > 0) {\n const next = pending.pop()\n if (!next) {\n continue\n }\n\n const filePath = stripQuery(next)\n if (visited.has(filePath) || !isAnalyzableSourceFile(filePath)) {\n continue\n }\n visited.add(filePath)\n\n let source: string\n try {\n source = await fs.readFile(filePath, 'utf8')\n } catch (error) {\n const code = (error as NodeJS.ErrnoException | undefined)?.code\n if (entryFileSet.has(filePath) && code !== 'ENOENT' && code !== 'ENOTDIR') {\n throw error\n }\n continue\n }\n\n try {\n await loadAnalyzedModule(filePath, source)\n } catch (error) {\n if (entryFileSet.has(filePath)) {\n throw error\n }\n continue\n }\n\n reachable.add(filePath)\n\n const imports = ts.preProcessFile(source, true, true).importedFiles\n for (const imported of imports) {\n const resolvedFilePath = resolveImportedModule(imported.fileName, filePath)\n if (!resolvedFilePath || !isAnalyzableSourceFile(resolvedFilePath)) {\n continue\n }\n pending.push(resolvedFilePath)\n }\n }\n\n return [...reachable]\n}\n\nexport const collectAppActions = async (\n root: string,\n): Promise<Array<{ filePath: string; id: string }>> => {\n const appDir = path.join(root, 'app')\n const files = await fg(path.join(appDir, '**/*.{ts,tsx}').replaceAll('\\\\', '/'))\n const result: Array<{ filePath: string; id: string }> = []\n\n for (const filePath of files) {\n const analyzed = await loadAnalyzedModule(filePath)\n result.push(...[...analyzed.actions.values()].map((action) => ({ filePath, id: action.id })))\n }\n\n return result\n}\n\nexport const collectAppLoaders = async (\n root: string,\n): Promise<Array<{ filePath: string; id: string }>> => {\n const appDir = path.join(root, 'app')\n const files = await fg(path.join(appDir, '**/*.{ts,tsx}').replaceAll('\\\\', '/'))\n const result: Array<{ filePath: string; id: string }> = []\n\n for (const filePath of files) {\n const analyzed = await loadAnalyzedModule(filePath)\n result.push(...[...analyzed.loaders.values()].map((loader) => ({ filePath, id: loader.id })))\n }\n\n return result\n}\n","import { Hono, type Context } from 'hono'\nimport type { MiddlewareHandler, Next } from 'hono/types'\nimport type { DevEnvironment, ResolvedConfig, ViteDevServer } from 'vite'\nimport type { ModuleRunner } from 'vite/module-runner'\nimport * as fs from 'node:fs/promises'\nimport {\n ROUTE_DATA_ENDPOINT,\n ROUTE_DATA_REQUEST_HEADER,\n ROUTE_MANIFEST_ELEMENT_ID,\n ROUTE_PREFLIGHT_ENDPOINT,\n ROUTE_PREFLIGHT_REQUEST_HEADER,\n ROUTE_RPC_URL_HEADER,\n type RouteParams,\n} from '../../core/router-shared.ts'\nimport type { SSRRootProps } from '../../core/types.ts'\nimport {\n APP_HOOKS_ELEMENT_ID,\n attachRequestFetch,\n createRequestFetch,\n markPublicError,\n resolveReroute,\n runHandleError,\n type AppContext,\n type AppHooksModule,\n type ServerHooksModule,\n withServerRequestContext,\n} from '../../core/hooks.ts'\nimport { Fragment, jsxDEV } from '../../jsx/jsx-dev-runtime.ts'\nimport {\n composeRouteMetadata,\n renderRouteMetadataHead,\n type RouteMetadataExport,\n} from '../../core/metadata.ts'\nimport { primeLocationState } from '../../core/runtime.ts'\nimport {\n createDevModuleUrl,\n createRouteManifest,\n createRoutes,\n matchRoute,\n normalizeRoutePath,\n type RouteEntry,\n} from '../utils/routing.ts'\nimport * as path from 'node:path'\nimport {\n collectAppActions,\n collectAppLoaders,\n collectAppSymbols,\n collectReachableAnalyzableFiles,\n createDevSymbolUrl,\n primeCompilerCache,\n} from '../compiler.ts'\n\nconst ROUTE_PARAMS_PROP = '__eclipsa_route_params'\nconst ROUTE_ERROR_PROP = '__eclipsa_route_error'\ninterface DevAppDeps {\n collectAppActions(root: string): Promise<{ id: string; filePath: string }[]>\n collectAppLoaders(root: string): Promise<{ id: string; filePath: string }[]>\n collectAppSymbols(root: string): Promise<{ id: string; filePath: string }[]>\n createDevModuleUrl(root: string, entry: { filePath: string }): string\n createDevSymbolUrl(root: string, filePath: string, symbolId: string): string\n createRoutes(root: string): Promise<RouteEntry[]>\n}\n\ninterface DevAppInit {\n deps?: DevAppDeps\n resolvedConfig: ResolvedConfig\n devServer: ViteDevServer\n runner: ModuleRunner\n ssrEnv: DevEnvironment\n}\n\nexport interface DevFetchController {\n fetch(req: Request): Promise<Response | undefined>\n invalidate(): void\n}\n\nconst fileExists = async (filePath: string) => {\n try {\n await fs.access(filePath)\n return true\n } catch {\n return false\n }\n}\n\nconst getRequestUrl = (request: Request) => {\n const url = new URL(request.url)\n const host = request.headers.get('x-forwarded-host') ?? request.headers.get('host')\n const proto = request.headers.get('x-forwarded-proto')\n if (host) {\n url.host = host\n }\n if (proto) {\n url.protocol = `${proto}:`\n }\n return url\n}\n\nconst toAppRelativePath = (root: string, filePath: string) => {\n const relativePath = path.relative(path.join(root, 'app'), filePath)\n if (relativePath.startsWith('..') || path.isAbsolute(relativePath)) {\n return null\n }\n return relativePath.replaceAll('\\\\', '/')\n}\n\nexport const shouldInvalidateDevApp = (\n root: string,\n filePath: string,\n event: 'add' | 'change' | 'unlink',\n) => {\n const relativePath = toAppRelativePath(root, filePath)\n if (!relativePath) {\n return false\n }\n if (relativePath === '+server-entry.ts') {\n return true\n }\n if (relativePath.endsWith('.ts') || relativePath.endsWith('.tsx')) {\n return event === 'add' || event === 'change' || event === 'unlink'\n }\n return false\n}\n\nconst RESUME_PAYLOAD_PLACEHOLDER = '__ECLIPSA_RESUME_PAYLOAD__'\nconst ROUTE_MANIFEST_PLACEHOLDER = '__ECLIPSA_ROUTE_MANIFEST__'\nconst APP_HOOKS_PLACEHOLDER = '__ECLIPSA_APP_HOOKS__'\n\ninterface RouteDataResponse {\n finalHref: string\n finalPathname: string\n kind: 'page' | 'not-found'\n loaders: Record<string, unknown>\n ok: true\n}\n\ninterface RouteServerAccessEntry {\n actionIds: Set<string>\n loaderIds: Set<string>\n route: RouteEntry\n}\n\nconst replaceHeadPlaceholder = (html: string, placeholder: string, value: string) =>\n html.replaceAll(placeholder, value)\n\nconst splitHtmlForStreaming = (html: string) => {\n const bodyCloseIndex = html.lastIndexOf('</body>')\n if (bodyCloseIndex >= 0) {\n return {\n prefix: html.slice(0, bodyCloseIndex),\n suffix: html.slice(bodyCloseIndex),\n }\n }\n const htmlCloseIndex = html.lastIndexOf('</html>')\n if (htmlCloseIndex >= 0) {\n return {\n prefix: html.slice(0, htmlCloseIndex),\n suffix: html.slice(htmlCloseIndex),\n }\n }\n return {\n prefix: html,\n suffix: '',\n }\n}\n\nconst toIdsByFilePath = (entries: ReadonlyArray<{ filePath: string; id: string }>) => {\n const idsByFilePath = new Map<string, string[]>()\n for (const entry of entries) {\n const existing = idsByFilePath.get(entry.filePath)\n if (existing) {\n existing.push(entry.id)\n continue\n }\n idsByFilePath.set(entry.filePath, [entry.id])\n }\n return idsByFilePath\n}\n\nconst getRouteReachableEntryFiles = (route: RouteEntry) =>\n [\n route.error?.filePath,\n ...route.layouts.map((layout) => layout.filePath),\n route.loading?.filePath,\n route.notFound?.filePath,\n route.page?.filePath,\n ].filter((filePath): filePath is string => typeof filePath === 'string')\n\nconst createRouteServerAccessEntries = async (\n routes: readonly RouteEntry[],\n actions: ReadonlyArray<{ filePath: string; id: string }>,\n loaders: ReadonlyArray<{ filePath: string; id: string }>,\n) => {\n const actionIdsByFilePath = toIdsByFilePath(actions)\n const loaderIdsByFilePath = toIdsByFilePath(loaders)\n\n return await Promise.all(\n routes.map(async (route) => {\n const reachableFiles = await collectReachableAnalyzableFiles(\n getRouteReachableEntryFiles(route),\n )\n return {\n actionIds: new Set(\n reachableFiles.flatMap((filePath) => actionIdsByFilePath.get(filePath) ?? []),\n ),\n loaderIds: new Set(\n reachableFiles.flatMap((filePath) => loaderIdsByFilePath.get(filePath) ?? []),\n ),\n route,\n } satisfies RouteServerAccessEntry\n }),\n )\n}\n\nconst ROUTE_SLOT_ROUTE_KEY = Symbol.for('eclipsa.route-slot-route')\n\nconst createRouteSlot = (\n route: {\n error?: unknown\n layouts: Array<{ renderer: (props: unknown) => unknown }>\n page: { renderer: (props: unknown) => unknown }\n params: RouteParams\n pathname: string\n },\n startLayoutIndex: number,\n) => {\n const slot = {\n __eclipsa_type: 'route-slot',\n pathname: route.pathname,\n startLayoutIndex,\n }\n Object.defineProperty(slot, ROUTE_SLOT_ROUTE_KEY, {\n configurable: true,\n enumerable: false,\n value: route,\n writable: true,\n })\n return slot\n}\n\nconst createRouteProps = (params: RouteParams, props: Record<string, unknown>) => {\n const nextProps = {\n ...props,\n }\n Object.defineProperty(nextProps, ROUTE_PARAMS_PROP, {\n configurable: true,\n enumerable: false,\n value: params,\n writable: true,\n })\n return nextProps\n}\n\nconst createRouteElement = (\n pathname: string,\n params: RouteParams,\n Page: (props: unknown) => unknown,\n Layouts: Array<(props: unknown) => unknown>,\n error?: unknown,\n): any => {\n if (Layouts.length === 0) {\n const nextProps = createRouteProps(params, {})\n Object.defineProperty(nextProps, ROUTE_ERROR_PROP, {\n configurable: true,\n enumerable: false,\n value: error,\n writable: true,\n })\n return jsxDEV(Page as any, nextProps, null, false, {})\n }\n\n const route = {\n error,\n layouts: Layouts.map((renderer) => ({\n renderer,\n })),\n page: {\n renderer: Page,\n },\n params,\n pathname,\n }\n let children: unknown = null\n for (let index = Layouts.length - 1; index >= 0; index -= 1) {\n const Layout = Layouts[index]!\n const nextProps = createRouteProps(params, {\n children: createRouteSlot(route, index + 1),\n })\n Object.defineProperty(nextProps, ROUTE_ERROR_PROP, {\n configurable: true,\n enumerable: false,\n value: error,\n writable: true,\n })\n children = jsxDEV(Layout as any, nextProps, null, false, {})\n }\n return children\n}\n\nconst scoreSpecialRoute = (route: RouteEntry, pathname: string) => {\n const pathnameSegments = normalizeRoutePath(pathname).split('/').filter(Boolean)\n let score = 0\n for (\n let index = 0;\n index < route.segments.length && index < pathnameSegments.length;\n index += 1\n ) {\n const segment = route.segments[index]!\n const pathnameSegment = pathnameSegments[index]\n if (segment.kind === 'static') {\n if (segment.value !== pathnameSegment) {\n break\n }\n score += 10\n continue\n }\n score += segment.kind === 'rest' ? 1 : 2\n if (segment.kind === 'rest') {\n break\n }\n }\n return score\n}\n\nconst findSpecialRoute = (\n routes: RouteEntry[],\n pathname: string,\n kind: 'error' | 'notFound',\n): { params: RouteParams; route: RouteEntry } | null => {\n const matched = matchRoute(routes, pathname)\n if (matched?.route[kind]) {\n return matched\n }\n\n let best: { params: RouteParams; route: RouteEntry } | null = null\n let bestScore = -1\n for (const route of routes) {\n if (!route[kind]) {\n continue\n }\n const score = scoreSpecialRoute(route, pathname)\n if (score > bestScore) {\n best = {\n params: {},\n route,\n }\n bestScore = score\n }\n }\n return best\n}\n\nconst applyRequestParams = (c: Context, params: RouteParams) => {\n const req = c.req as any\n req.param = (name?: string) => {\n if (!name) {\n return params\n }\n return params[name]\n }\n}\n\nconst isNotFoundError = (error: unknown) =>\n !!error &&\n typeof error === 'object' &&\n (error as { __eclipsa_not_found__?: boolean }).__eclipsa_not_found__ === true\n\nconst logDevServerError = (devServer: ViteDevServer, error: unknown) => {\n if (error instanceof Error && typeof devServer.ssrFixStacktrace === 'function') {\n devServer.ssrFixStacktrace(error)\n }\n console.error(error)\n}\n\nconst toPublicErrorValue = async (\n devServer: ViteDevServer,\n hooks: ServerHooksModule,\n c: AppContext,\n error: unknown,\n event: Parameters<typeof runHandleError>[1]['event'],\n) => {\n const publicError = await runHandleError(\n {\n handleError: hooks.handleError,\n },\n {\n context: c,\n error,\n event,\n },\n )\n if (!isNotFoundError(error)) {\n logDevServerError(devServer, error)\n }\n return markPublicError(error, publicError)\n}\n\nconst loadOptionalHookModule = async <T extends object>(\n runner: ModuleRunner,\n filePath: string,\n): Promise<Partial<T>> => {\n if (!(await fileExists(filePath))) {\n return {}\n }\n return (await runner.import(filePath)) as Partial<T>\n}\n\nconst isRedirectResponse = (\n response: unknown,\n): response is { headers: { get(name: string): string | null }; status: number } =>\n !!response &&\n typeof response === 'object' &&\n typeof (response as { status?: unknown }).status === 'number' &&\n !!(response as { headers?: { get?: unknown } }).headers &&\n typeof (response as { headers: { get?: unknown } }).headers.get === 'function' &&\n (response as { status: number }).status >= 300 &&\n (response as { status: number }).status < 400 &&\n !!(response as { headers: { get(name: string): string | null } }).headers.get('location')\n\nconst createDevApp = async (init: DevAppInit) => {\n const deps = init.deps ?? {\n collectAppActions,\n collectAppLoaders,\n collectAppSymbols,\n createDevModuleUrl,\n createDevSymbolUrl,\n createRoutes,\n }\n const { default: userApp } = await init.runner.import('/app/+server-entry.ts')\n const app = new Hono()\n app.route('/', userApp)\n const actions = await deps.collectAppActions(init.resolvedConfig.root)\n const loaders = await deps.collectAppLoaders(init.resolvedConfig.root)\n const routes = await deps.createRoutes(init.resolvedConfig.root)\n const allSymbols = await deps.collectAppSymbols(init.resolvedConfig.root)\n const actionModules = new Map(actions.map((action) => [action.id, action.filePath]))\n const loaderModules = new Map(loaders.map((loader) => [loader.id, loader.filePath]))\n const routeServerAccessEntries = await createRouteServerAccessEntries(routes, actions, loaders)\n const routeServerAccessByRoute = new Map(\n routeServerAccessEntries.map((entry) => [entry.route, entry] as const),\n )\n const symbolUrls = Object.fromEntries(\n allSymbols.map((symbol) => [\n symbol.id,\n deps.createDevSymbolUrl(init.resolvedConfig.root, symbol.filePath, symbol.id),\n ]),\n )\n const routeManifest = createRouteManifest(routes, (entry) =>\n deps.createDevModuleUrl(init.resolvedConfig.root, entry),\n )\n const appHooksPath = path.join(init.resolvedConfig.root, 'app/+hooks.ts')\n const serverHooksPath = path.join(init.resolvedConfig.root, 'app/+hooks.server.ts')\n const appHooks = (await loadOptionalHookModule<AppHooksModule>(\n init.runner,\n appHooksPath,\n )) as AppHooksModule\n const serverHooks = (await loadOptionalHookModule<ServerHooksModule>(\n init.runner,\n serverHooksPath,\n )) as ServerHooksModule\n const appHooksManifest = {\n client: (await fileExists(appHooksPath)) ? '/app/+hooks.ts' : null,\n }\n\n await serverHooks.init?.()\n\n const prepareRequestContext = <E extends Context>(c: E) => {\n attachRequestFetch(\n c as unknown as AppContext,\n createRequestFetch(c as unknown as AppContext, serverHooks.handleFetch),\n )\n return c as unknown as AppContext\n }\n\n const reroutePathname = (request: Request | null, pathname: string, baseUrl: string) =>\n normalizeRoutePath(resolveReroute(appHooks.reroute, request, pathname, baseUrl))\n\n const getRouteServerAccess = (route: RouteEntry) =>\n routeServerAccessByRoute.get(route) ?? {\n actionIds: new Set<string>(),\n loaderIds: new Set<string>(),\n route,\n }\n\n const resolveRouteForCurrentUrl = (request: Request | null, currentUrl: URL) => {\n const resolvedPathname = reroutePathname(\n request,\n normalizeRoutePath(currentUrl.pathname),\n currentUrl.href,\n )\n const match = matchRoute(routes, resolvedPathname)\n if (match?.route.page) {\n return match\n }\n const fallback = findSpecialRoute(routes, resolvedPathname, 'notFound')\n if (fallback?.route.notFound) {\n return fallback\n }\n return null\n }\n\n const getRpcCurrentRoute = (requestContext: AppContext) => {\n const requestUrl = getRequestUrl(requestContext.req.raw)\n const routeUrlHeader = requestContext.req.header(ROUTE_RPC_URL_HEADER)\n if (!routeUrlHeader) {\n return null\n }\n let currentUrl: URL\n try {\n currentUrl = new URL(routeUrlHeader, requestUrl)\n } catch {\n return null\n }\n if (currentUrl.origin !== requestUrl.origin) {\n return null\n }\n return resolveRouteForCurrentUrl(requestContext.req.raw, currentUrl)\n }\n\n const resolveRequest = async <E extends Context>(\n c: E,\n handler: (requestContext: AppContext) => Promise<Response>,\n ) => {\n const requestContext = prepareRequestContext(c)\n const execute = (nextContext = requestContext) =>\n withServerRequestContext(\n nextContext,\n {\n handleError: serverHooks.handleError,\n transport: appHooks.transport,\n },\n () => handler(nextContext),\n )\n\n if (!serverHooks.handle) {\n return execute(requestContext)\n }\n\n return withServerRequestContext(\n requestContext,\n {\n handleError: serverHooks.handleError,\n transport: appHooks.transport,\n },\n () =>\n serverHooks.handle!(requestContext, (nextContext) =>\n execute(nextContext ?? requestContext),\n ),\n )\n }\n\n const loadRouteMiddlewares = async (route: RouteEntry): Promise<MiddlewareHandler[]> =>\n await Promise.all(\n route.middlewares.map(async (middleware) => {\n const mod = await init.runner.import(middleware.filePath)\n if (typeof mod.default !== 'function') {\n throw new TypeError(\n `Route middleware \"${middleware.filePath}\" must default export a middleware function.`,\n )\n }\n return mod.default as MiddlewareHandler\n }),\n )\n\n const composeRouteMiddlewares = async <T>(\n route: RouteEntry,\n c: AppContext,\n params: RouteParams,\n handler: () => Promise<T>,\n ): Promise<T | Response> => {\n applyRequestParams(c, params)\n const middlewares = await loadRouteMiddlewares(route)\n let index = -1\n const dispatch = async (nextIndex: number): Promise<T | Response> => {\n if (nextIndex <= index) {\n throw new Error('Route middleware called next() multiple times.')\n }\n index = nextIndex\n const middleware = middlewares[nextIndex]\n if (!middleware) {\n return handler()\n }\n let nextResult: T | Response | undefined = undefined\n const result = await middleware(c, (async () => {\n nextResult = await dispatch(nextIndex + 1)\n }) as Next)\n if (result !== undefined) {\n return result as Response\n }\n return nextResult as T | Response\n }\n return dispatch(0)\n }\n\n const resolvePreflightTarget = (pathname: string) => {\n const match = matchRoute(routes, pathname)\n if (match?.route.page) {\n return match\n }\n if (!match) {\n const fallback = findSpecialRoute(routes, pathname, 'notFound')\n if (fallback?.route.notFound) {\n return fallback\n }\n }\n return null\n }\n\n const invokeRouteServer = async (filePath: string, c: AppContext, params: RouteParams) => {\n applyRequestParams(c, params)\n const mod = await init.runner.import(filePath)\n const methodHandler = mod[c.req.method] as\n | ((context: AppContext) => Response | Promise<Response>)\n | undefined\n if (typeof methodHandler === 'function') {\n return methodHandler(c)\n }\n const serverApp = mod.default as\n | { fetch?: (request: Request, env?: unknown, ctx?: unknown) => Response | Promise<Response> }\n | undefined\n if (serverApp && typeof serverApp.fetch === 'function') {\n return serverApp.fetch(c.req.raw)\n }\n return c.text('Not Found', 404)\n }\n\n const renderRouteResponse = async (\n route: RouteEntry,\n pathname: string,\n params: RouteParams,\n c: AppContext,\n modulePath: string,\n status = 200,\n options?: {\n prepare?: (container: any) => void | Promise<void>\n routeError?: unknown\n },\n ) => {\n const [\n _primedModules,\n modules,\n { default: SSRRoot },\n {\n escapeJSONScriptText,\n getStreamingResumeBootstrapScriptContent,\n renderSSRStream,\n resolvePendingLoaders,\n serializeResumePayload,\n RESUME_FINAL_STATE_ELEMENT_ID,\n },\n ] = await Promise.all([\n Promise.all([\n fileExists(modulePath).then((exists) =>\n exists ? primeCompilerCache(modulePath) : undefined,\n ),\n ...route.layouts.map((layout) =>\n fileExists(layout.filePath).then((exists) =>\n exists ? primeCompilerCache(layout.filePath) : undefined,\n ),\n ),\n ]),\n Promise.all([\n init.runner.import(modulePath),\n ...route.layouts.map((layout) => init.runner.import(layout.filePath)),\n ]),\n init.runner.import('/app/+ssr-root.tsx'),\n init.runner.import('eclipsa'),\n ])\n const [pageModule, ...layoutModules] = modules as Array<{\n default: (props: unknown) => unknown\n metadata?: RouteMetadataExport\n }>\n const { default: Page } = pageModule\n const Layouts = layoutModules.map((module) => module.default)\n const metadata = composeRouteMetadata(\n [...layoutModules.map((module) => module.metadata ?? null), pageModule.metadata ?? null],\n {\n params,\n url: getRequestUrl(c.req.raw),\n },\n )\n\n const document = jsxDEV(\n SSRRoot as any,\n {\n children: createRouteElement(\n pathname,\n params,\n Page,\n Layouts,\n options?.routeError,\n ) as SSRRootProps['children'],\n head: {\n type: Fragment,\n isStatic: true,\n props: {\n children: [\n ...renderRouteMetadataHead(metadata),\n {\n type: 'script',\n isStatic: true,\n props: {\n children: RESUME_PAYLOAD_PLACEHOLDER,\n id: 'eclipsa-resume',\n type: 'application/eclipsa-resume+json',\n },\n },\n {\n type: 'script',\n isStatic: true,\n props: {\n children: ROUTE_MANIFEST_PLACEHOLDER,\n id: ROUTE_MANIFEST_ELEMENT_ID,\n type: 'application/eclipsa-route-manifest+json',\n },\n },\n {\n type: 'script',\n isStatic: true,\n props: {\n children: APP_HOOKS_PLACEHOLDER,\n id: APP_HOOKS_ELEMENT_ID,\n type: 'application/eclipsa-app-hooks+json',\n },\n },\n {\n type: 'script',\n isStatic: true,\n props: {\n dangerouslySetInnerHTML: getStreamingResumeBootstrapScriptContent(),\n },\n },\n {\n type: 'script',\n isStatic: true,\n props: {\n children: 'import(\"/@vite/client\")',\n },\n },\n {\n type: 'script',\n props: {\n src: '/app/+client.dev.tsx',\n type: 'module',\n },\n },\n ],\n },\n },\n } satisfies SSRRootProps,\n null,\n false,\n {},\n )\n\n applyRequestParams(c, params)\n const { html, payload, chunks } = await renderSSRStream(() => document, {\n prepare(container: any) {\n primeLocationState(container, getRequestUrl(c.req.raw))\n return options?.prepare?.(container)\n },\n resolvePendingLoaders: async (container: any) => resolvePendingLoaders(container, c),\n symbols: symbolUrls,\n })\n const shellHtml = replaceHeadPlaceholder(\n replaceHeadPlaceholder(\n replaceHeadPlaceholder(html, RESUME_PAYLOAD_PLACEHOLDER, serializeResumePayload(payload)),\n ROUTE_MANIFEST_PLACEHOLDER,\n escapeJSONScriptText(JSON.stringify(routeManifest)),\n ),\n APP_HOOKS_PLACEHOLDER,\n escapeJSONScriptText(JSON.stringify(appHooksManifest)),\n )\n const { prefix, suffix } = splitHtmlForStreaming(shellHtml)\n const encoder = new TextEncoder()\n\n return new Response(\n new ReadableStream<Uint8Array>({\n start(controller) {\n controller.enqueue(encoder.encode(prefix))\n void (async () => {\n let latestPayload = payload\n\n for await (const chunk of chunks) {\n latestPayload = chunk.payload\n const templateId = `eclipsa-suspense-template-${chunk.boundaryId}`\n const payloadId = `eclipsa-suspense-payload-${chunk.boundaryId}`\n controller.enqueue(\n encoder.encode(\n `<template id=\"${templateId}\">${chunk.html}</template>` +\n `<script id=\"${payloadId}\" type=\"application/eclipsa-resume+json\">${serializeResumePayload(chunk.payload)}</script>` +\n `<script>window.__eclipsa_stream.enqueue({boundaryId:${JSON.stringify(chunk.boundaryId)},payloadScriptId:${JSON.stringify(payloadId)},templateId:${JSON.stringify(templateId)}})</script>`,\n ),\n )\n }\n\n controller.enqueue(\n encoder.encode(\n `<script id=\"${RESUME_FINAL_STATE_ELEMENT_ID}\" type=\"application/eclipsa-resume+json\">${serializeResumePayload(latestPayload)}</script>${suffix}`,\n ),\n )\n controller.close()\n })().catch((error) => {\n controller.error(error)\n })\n },\n }),\n { status, headers: { 'content-type': 'text/html; charset=utf-8' } },\n )\n }\n\n const renderMatchedPage = async (\n match: { params: RouteParams; route: RouteEntry },\n c: AppContext,\n options?: {\n prepare?: (container: any) => void | Promise<void>\n routeError?: unknown\n },\n ) => {\n const requestUrl = getRequestUrl(c.req.raw)\n const requestPathname = normalizeRoutePath(requestUrl.pathname)\n const resolvedPathname = reroutePathname(c.req.raw, requestPathname, requestUrl.href)\n try {\n return await renderRouteResponse(\n match.route,\n requestPathname,\n match.params,\n c,\n match.route.page!.filePath,\n 200,\n options,\n )\n } catch (error) {\n const publicError = await toPublicErrorValue(init.devServer, serverHooks, c, error, 'page')\n const fallback = isNotFoundError(error)\n ? findSpecialRoute(routes, resolvedPathname, 'notFound')\n : findSpecialRoute(routes, resolvedPathname, 'error')\n const module = fallback?.route[isNotFoundError(error) ? 'notFound' : 'error']\n if (!fallback || !module) {\n return c.text(\n isNotFoundError(error) ? 'Not Found' : 'Internal Server Error',\n isNotFoundError(error) ? 404 : 500,\n )\n }\n return renderRouteResponse(\n fallback.route,\n requestPathname,\n fallback.params,\n c,\n module.filePath,\n isNotFoundError(error) ? 404 : 500,\n {\n ...options,\n routeError: publicError,\n },\n )\n }\n }\n\n const renderRouteDataResponse = async (\n route: RouteEntry,\n pathname: string,\n params: RouteParams,\n c: AppContext,\n modulePath: string,\n kind: RouteDataResponse['kind'],\n ) => {\n const [_primedModules, modules, { renderSSRAsync, resolvePendingLoaders }] = await Promise.all([\n Promise.all([\n fileExists(modulePath).then((exists) =>\n exists ? primeCompilerCache(modulePath) : undefined,\n ),\n ...route.layouts.map((layout) =>\n fileExists(layout.filePath).then((exists) =>\n exists ? primeCompilerCache(layout.filePath) : undefined,\n ),\n ),\n ]),\n Promise.all([\n init.runner.import(modulePath),\n ...route.layouts.map((layout) => init.runner.import(layout.filePath)),\n ]),\n init.runner.import('eclipsa'),\n ])\n const [pageModule, ...layoutModules] = modules as Array<{\n default: (props: unknown) => unknown\n }>\n const { default: Page } = pageModule\n const Layouts = layoutModules.map((module) => module.default)\n\n applyRequestParams(c, params)\n const { payload } = await renderSSRAsync(\n () => createRouteElement(pathname, params, Page, Layouts, undefined),\n {\n prepare(container: any) {\n primeLocationState(container, getRequestUrl(c.req.raw))\n },\n resolvePendingLoaders: async (container: any) => resolvePendingLoaders(container, c),\n symbols: symbolUrls,\n },\n )\n\n return c.json({\n finalHref: getRequestUrl(c.req.raw).href,\n finalPathname: pathname,\n kind,\n loaders: payload.loaders,\n ok: true,\n } satisfies RouteDataResponse)\n }\n\n const renderRouteData = async (\n route: RouteEntry,\n pathname: string,\n params: RouteParams,\n c: AppContext,\n modulePath: string,\n kind: RouteDataResponse['kind'],\n ) => {\n const requestUrl = getRequestUrl(c.req.raw)\n const requestPathname = normalizeRoutePath(requestUrl.pathname)\n const resolvedPathname = reroutePathname(c.req.raw, requestPathname, requestUrl.href)\n try {\n return await renderRouteDataResponse(route, pathname, params, c, modulePath, kind)\n } catch (error) {\n if (!isNotFoundError(error)) {\n return c.json({ document: true, ok: false })\n }\n\n const fallback = findSpecialRoute(routes, resolvedPathname, 'notFound')\n if (!fallback?.route.notFound) {\n return c.json({ document: true, ok: false })\n }\n\n try {\n return await renderRouteDataResponse(\n fallback.route,\n requestPathname,\n fallback.params,\n c,\n fallback.route.notFound.filePath,\n 'not-found',\n )\n } catch {\n return c.json({ document: true, ok: false })\n }\n }\n }\n\n const resolveRouteData = async (href: string, c: AppContext) => {\n const requestUrl = getRequestUrl(c.req.raw)\n const targetUrl = new URL(href, requestUrl)\n if (targetUrl.origin !== requestUrl.origin) {\n return c.json({ document: true, ok: false })\n }\n const headers = new Headers(c.req.raw.headers)\n headers.set(ROUTE_DATA_REQUEST_HEADER, '1')\n const response = await app.fetch(\n new Request(targetUrl.href, {\n headers,\n method: 'GET',\n redirect: 'manual',\n }),\n )\n if (response.status >= 200 && response.status < 300) {\n return response\n }\n if (isRedirectResponse(response)) {\n return c.json({\n location: new URL(response.headers.get('location')!, requestUrl).href,\n ok: false,\n })\n }\n return c.json({ document: true, ok: false })\n }\n\n const resolveRoutePreflight = async (href: string, c: AppContext) => {\n const requestUrl = getRequestUrl(c.req.raw)\n const targetUrl = new URL(href, requestUrl)\n if (targetUrl.origin !== requestUrl.origin) {\n return c.json({ document: true, ok: false })\n }\n\n const target = resolvePreflightTarget(\n reroutePathname(\n new Request(targetUrl.href),\n normalizeRoutePath(targetUrl.pathname),\n targetUrl.href,\n ),\n )\n if (!target) {\n return c.json({ ok: true })\n }\n\n const headers = new Headers(c.req.raw.headers)\n headers.set(ROUTE_PREFLIGHT_REQUEST_HEADER, '1')\n let response: Response\n try {\n response = await c.var.fetch(targetUrl.href, {\n headers,\n redirect: 'manual',\n })\n } catch {\n response = await app.fetch(\n new Request(targetUrl.href, {\n headers,\n method: 'GET',\n redirect: 'manual',\n }),\n )\n }\n\n if (response.status >= 200 && response.status < 300) {\n return c.json({ ok: true })\n }\n if (isRedirectResponse(response)) {\n return c.json({\n location: new URL(response.headers.get('location')!, requestUrl).href,\n ok: false,\n })\n }\n return c.json({ document: true, ok: false })\n }\n\n const resolveRequestRoute = (request: Request, url: string) => {\n const requestPathname = normalizeRoutePath(new URL(url).pathname)\n const resolvedPathname = reroutePathname(request, requestPathname, url)\n return {\n match: matchRoute(routes, resolvedPathname),\n requestPathname,\n resolvedPathname,\n }\n }\n\n app.post('/__eclipsa/action/:id', async (c) =>\n resolveRequest(c, async (requestContext) => {\n const { executeAction, hasAction } = await init.runner.import('eclipsa')\n const id = requestContext.req.param('id')\n if (!id) {\n return requestContext.text('Not Found', 404)\n }\n const routeMatch = getRpcCurrentRoute(requestContext)\n if (!routeMatch) {\n return requestContext.text('Bad Request', 400)\n }\n const routeAccess = getRouteServerAccess(routeMatch.route)\n if (!routeAccess.actionIds.has(id)) {\n return requestContext.text('Not Found', 404)\n }\n const modulePath = actionModules.get(id)\n if (!modulePath) {\n return requestContext.text('Not Found', 404)\n }\n if (!hasAction(id)) {\n await init.runner.import(modulePath)\n }\n return composeRouteMiddlewares(\n routeMatch.route,\n requestContext,\n routeMatch.params,\n async () => executeAction(id, requestContext),\n ) as Promise<Response>\n }),\n )\n\n app.get('/__eclipsa/loader/:id', async (c) =>\n resolveRequest(c, async (requestContext) => {\n const { executeLoader, hasLoader } = await init.runner.import('eclipsa')\n const id = requestContext.req.param('id')\n if (!id) {\n return requestContext.text('Not Found', 404)\n }\n const routeMatch = getRpcCurrentRoute(requestContext)\n if (!routeMatch) {\n return requestContext.text('Bad Request', 400)\n }\n const routeAccess = getRouteServerAccess(routeMatch.route)\n if (!routeAccess.loaderIds.has(id)) {\n return requestContext.text('Not Found', 404)\n }\n const modulePath = loaderModules.get(id)\n if (!modulePath) {\n return requestContext.text('Not Found', 404)\n }\n if (!hasLoader(id)) {\n await init.runner.import(modulePath)\n }\n return composeRouteMiddlewares(\n routeMatch.route,\n requestContext,\n routeMatch.params,\n async () => executeLoader(id, requestContext),\n ) as Promise<Response>\n }),\n )\n\n app.get(ROUTE_PREFLIGHT_ENDPOINT, async (c) =>\n resolveRequest(c, async (requestContext) => {\n const href = requestContext.req.query('href')\n if (!href) {\n return requestContext.json({ document: true, ok: false }, 400)\n }\n return resolveRoutePreflight(href, requestContext)\n }),\n )\n\n app.get(ROUTE_DATA_ENDPOINT, async (c) =>\n resolveRequest(c, async (requestContext) => {\n const href = requestContext.req.query('href')\n if (!href) {\n return requestContext.json({ document: true, ok: false }, 400)\n }\n return resolveRouteData(href, requestContext)\n }),\n )\n\n app.all('*', async (c) =>\n resolveRequest(c, async (requestContext) => {\n const { match, requestPathname, resolvedPathname } = resolveRequestRoute(\n requestContext.req.raw,\n requestContext.req.url,\n )\n\n if (!match) {\n const fallback = findSpecialRoute(routes, resolvedPathname, 'notFound')\n if (fallback?.route.notFound) {\n return composeRouteMiddlewares(\n fallback.route,\n requestContext,\n fallback.params,\n async () =>\n requestContext.req.header(ROUTE_PREFLIGHT_REQUEST_HEADER) === '1'\n ? requestContext.body(null, 204)\n : requestContext.req.header(ROUTE_DATA_REQUEST_HEADER) === '1'\n ? renderRouteData(\n fallback.route,\n requestPathname,\n fallback.params,\n requestContext,\n fallback.route.notFound!.filePath,\n 'not-found',\n )\n : renderRouteResponse(\n fallback.route,\n requestPathname,\n fallback.params,\n requestContext,\n fallback.route.notFound!.filePath,\n 404,\n ),\n )\n }\n return requestContext.text('Not Found', 404)\n }\n\n if (\n (requestContext.req.method === 'GET' || requestContext.req.method === 'HEAD') &&\n match.route.page\n ) {\n const page = match.route.page\n return composeRouteMiddlewares(match.route, requestContext, match.params, async () =>\n requestContext.req.header(ROUTE_PREFLIGHT_REQUEST_HEADER) === '1'\n ? requestContext.body(null, 204)\n : requestContext.req.header(ROUTE_DATA_REQUEST_HEADER) === '1'\n ? renderRouteData(\n match.route,\n requestPathname,\n match.params,\n requestContext,\n page.filePath,\n 'page',\n )\n : renderMatchedPage(match, requestContext),\n )\n }\n\n if (requestContext.req.method === 'POST' && match.route.page) {\n return composeRouteMiddlewares(match.route, requestContext, match.params, async () => {\n const {\n ACTION_CONTENT_TYPE,\n deserializePublicValue,\n executeAction,\n getNormalizedActionInput,\n getActionFormSubmissionId,\n hasAction,\n primeActionState,\n } = await init.runner.import('eclipsa')\n const actionId = await getActionFormSubmissionId(requestContext)\n if (!actionId) {\n return match.route.server\n ? invokeRouteServer(match.route.server.filePath, requestContext, match.params)\n : renderMatchedPage(match, requestContext)\n }\n const routeAccess = getRouteServerAccess(match.route)\n if (!routeAccess.actionIds.has(actionId)) {\n return requestContext.text('Not Found', 404)\n }\n const modulePath = actionModules.get(actionId)\n if (!modulePath) {\n return requestContext.text('Not Found', 404)\n }\n if (!hasAction(actionId)) {\n await init.runner.import(modulePath)\n }\n const input = await getNormalizedActionInput(requestContext)\n const response = await executeAction(actionId, requestContext)\n const contentType = response.headers.get('content-type') ?? ''\n if (!contentType.startsWith(ACTION_CONTENT_TYPE)) {\n return response\n }\n const body = (await response.json()) as\n | { error: unknown; ok: false }\n | { ok: true; value: unknown }\n return renderMatchedPage(match, requestContext, {\n prepare(container) {\n primeActionState(container, actionId, {\n error: body.ok ? undefined : deserializePublicValue(body.error as any),\n input,\n result: body.ok ? deserializePublicValue(body.value as any) : undefined,\n })\n },\n })\n })\n }\n\n if (match.route.server) {\n return composeRouteMiddlewares(match.route, requestContext, match.params, async () =>\n invokeRouteServer(match.route.server!.filePath, requestContext, match.params),\n )\n }\n\n if (match.route.page) {\n return composeRouteMiddlewares(match.route, requestContext, match.params, async () =>\n requestContext.req.header(ROUTE_PREFLIGHT_REQUEST_HEADER) === '1'\n ? requestContext.body(null, 204)\n : renderMatchedPage(match, requestContext),\n )\n }\n\n return requestContext.text('Not Found', 404)\n }),\n )\n\n return app\n}\n\nexport const createDevFetch = (init: DevAppInit): DevFetchController => {\n let app: ReturnType<typeof createDevApp> | null = null\n const getApp = () => {\n app ??= createDevApp(init)\n return app\n }\n\n return {\n invalidate() {\n app = null\n },\n async fetch(req) {\n const fetched = await (await getApp()).fetch(req)\n if (fetched.status === 404) {\n return\n }\n return fetched\n },\n }\n}\n","import type { IncomingMessage, ServerResponse } from 'node:http'\n\nexport const incomingMessageToRequest = (incomingMessage: IncomingMessage): Request => {\n const body =\n incomingMessage.method !== 'GET' && incomingMessage.method !== 'HEAD'\n ? new ReadableStream<Uint8Array>({\n start(controller) {\n incomingMessage.on('data', (chunk) => {\n controller.enqueue(new Uint8Array(chunk))\n })\n incomingMessage.on('end', () => {\n controller.close()\n })\n },\n })\n : null\n const headers = new Headers()\n for (const [k, v] of Object.entries(incomingMessage.headers)) {\n if (Array.isArray(v)) {\n for (const value of v) {\n headers.append(k, value)\n }\n } else if (v) {\n headers.append(k, v)\n }\n }\n const init: RequestInit & { duplex?: 'half' } = {\n headers,\n method: incomingMessage.method,\n }\n if (body) {\n init.body = body\n init.duplex = 'half'\n }\n return new Request(new URL(incomingMessage.url ?? '', 'http://localhost'), init)\n}\n\nexport const responseForServerResponse = async (res: Response, serverRes: ServerResponse) => {\n for (const [k, v] of res.headers) {\n serverRes.setHeader(k, v)\n }\n serverRes.statusCode = res.status\n serverRes.statusMessage = res.statusText\n\n const buffer = Buffer.from(await res.arrayBuffer())\n serverRes.end(buffer)\n}\n","/*!\n * MIT License\n * Copyright (c) 2019 Jason Dent\n * https://github.com/Jason3S/xxhash/blob/028d9be1854b44f1afd79539e4da8c55c732ca05/LICENSE\n *\n * Source: https://github.com/Jason3S/xxhash/blob/028d9be1854b44f1afd79539e4da8c55c732ca05/src/xxHash32.ts\n */\nconst PRIME32_1 = 2654435761\nconst PRIME32_2 = 2246822519\nconst PRIME32_3 = 3266489917\nconst PRIME32_4 = 668265263\nconst PRIME32_5 = 374761393\n\nlet encoder: TextEncoder | undefined\n\n/**\n *\n * @param input - byte array or string\n * @param seed - optional seed (32-bit unsigned);\n */\nexport function xxHash32(input: Uint8Array | string, seed = 0): number {\n const buffer = typeof input === 'string' ? (encoder ??= new TextEncoder()).encode(input) : input\n const b = buffer\n\n /*\n Step 1. Initialize internal accumulators\n Each accumulator gets an initial value based on optional seed input. Since the seed is optional, it can be 0.\n\n ```\n u32 acc1 = seed + PRIME32_1 + PRIME32_2;\n u32 acc2 = seed + PRIME32_2;\n u32 acc3 = seed + 0;\n u32 acc4 = seed - PRIME32_1;\n ```\n Special case : input is less than 16 bytes\n When input is too small (< 16 bytes), the algorithm will not process any stripe. Consequently, it will not\n make use of parallel accumulators.\n\n In which case, a simplified initialization is performed, using a single accumulator :\n\n u32 acc = seed + PRIME32_5;\n The algorithm then proceeds directly to step 4.\n */\n\n let acc = (seed + PRIME32_5) & 0xffffffff\n let offset = 0\n\n if (b.length >= 16) {\n const accN = [\n (seed + PRIME32_1 + PRIME32_2) & 0xffffffff,\n (seed + PRIME32_2) & 0xffffffff,\n (seed + 0) & 0xffffffff,\n (seed - PRIME32_1) & 0xffffffff,\n ]\n\n /*\n Step 2. Process stripes\n A stripe is a contiguous segment of 16 bytes. It is evenly divided into 4 lanes, of 4 bytes each.\n The first lane is used to update accumulator 1, the second lane is used to update accumulator 2, and so on.\n\n Each lane read its associated 32-bit value using little-endian convention.\n\n For each {lane, accumulator}, the update process is called a round, and applies the following formula :\n\n ```\n accN = accN + (laneN * PRIME32_2);\n accN = accN <<< 13;\n accN = accN * PRIME32_1;\n ```\n\n This shuffles the bits so that any bit from input lane impacts several bits in output accumulator.\n All operations are performed modulo 2^32.\n\n Input is consumed one full stripe at a time. Step 2 is looped as many times as necessary to consume\n the whole input, except the last remaining bytes which cannot form a stripe (< 16 bytes). When that\n happens, move to step 3.\n */\n\n const b = buffer\n const limit = b.length - 16\n let lane = 0\n for (offset = 0; (offset & 0xfffffff0) <= limit; offset += 4) {\n const i = offset\n const laneN0 = b[i + 0] + (b[i + 1] << 8)\n const laneN1 = b[i + 2] + (b[i + 3] << 8)\n const laneNP = laneN0 * PRIME32_2 + ((laneN1 * PRIME32_2) << 16)\n let acc = (accN[lane] + laneNP) & 0xffffffff\n acc = (acc << 13) | (acc >>> 19)\n const acc0 = acc & 0xffff\n const acc1 = acc >>> 16\n accN[lane] = (acc0 * PRIME32_1 + ((acc1 * PRIME32_1) << 16)) & 0xffffffff\n lane = (lane + 1) & 0x3\n }\n\n /*\n Step 3. Accumulator convergence\n All 4 lane accumulators from previous steps are merged to produce a single remaining accumulator\n of same width (32-bit). The associated formula is as follows :\n\n ```\n acc = (acc1 <<< 1) + (acc2 <<< 7) + (acc3 <<< 12) + (acc4 <<< 18);\n ```\n */\n acc =\n (((accN[0] << 1) | (accN[0] >>> 31)) +\n ((accN[1] << 7) | (accN[1] >>> 25)) +\n ((accN[2] << 12) | (accN[2] >>> 20)) +\n ((accN[3] << 18) | (accN[3] >>> 14))) &\n 0xffffffff\n }\n\n /*\n Step 4. Add input length\n The input total length is presumed known at this stage. This step is just about adding the length to\n accumulator, so that it participates to final mixing.\n\n ```\n acc = acc + (u32)inputLength;\n ```\n */\n acc = (acc + buffer.length) & 0xffffffff\n\n /*\n Step 5. Consume remaining input\n There may be up to 15 bytes remaining to consume from the input. The final stage will digest them according\n to following pseudo-code :\n ```\n while (remainingLength >= 4) {\n lane = read_32bit_little_endian(input_ptr);\n acc = acc + lane * PRIME32_3;\n acc = (acc <<< 17) * PRIME32_4;\n input_ptr += 4; remainingLength -= 4;\n }\n ```\n This process ensures that all input bytes are present in the final mix.\n */\n\n const limit = buffer.length - 4\n for (; offset <= limit; offset += 4) {\n const i = offset\n const laneN0 = b[i + 0] + (b[i + 1] << 8)\n const laneN1 = b[i + 2] + (b[i + 3] << 8)\n const laneP = laneN0 * PRIME32_3 + ((laneN1 * PRIME32_3) << 16)\n acc = (acc + laneP) & 0xffffffff\n acc = (acc << 17) | (acc >>> 15)\n acc = ((acc & 0xffff) * PRIME32_4 + (((acc >>> 16) * PRIME32_4) << 16)) & 0xffffffff\n }\n\n /*\n ```\n while (remainingLength >= 1) {\n lane = read_byte(input_ptr);\n acc = acc + lane * PRIME32_5;\n acc = (acc <<< 11) * PRIME32_1;\n input_ptr += 1; remainingLength -= 1;\n }\n ```\n */\n\n for (; offset < b.length; ++offset) {\n const lane = b[offset]\n acc = acc + lane * PRIME32_5\n acc = (acc << 11) | (acc >>> 21)\n acc = ((acc & 0xffff) * PRIME32_1 + (((acc >>> 16) * PRIME32_1) << 16)) & 0xffffffff\n }\n\n /*\n Step 6. Final mix (avalanche)\n The final mix ensures that all input bits have a chance to impact any bit in the output digest,\n resulting in an unbiased distribution. This is also called avalanche effect.\n ```\n acc = acc xor (acc >> 15);\n acc = acc * PRIME32_2;\n acc = acc xor (acc >> 13);\n acc = acc * PRIME32_3;\n acc = acc xor (acc >> 16);\n ```\n */\n\n acc = acc ^ (acc >>> 15)\n acc = (((acc & 0xffff) * PRIME32_2) & 0xffffffff) + (((acc >>> 16) * PRIME32_2) << 16)\n acc = acc ^ (acc >>> 13)\n acc = (((acc & 0xffff) * PRIME32_3) & 0xffffffff) + (((acc >>> 16) * PRIME32_3) << 16)\n acc = acc ^ (acc >>> 16)\n\n // turn any negatives back into a positive number;\n return acc < 0 ? acc + 4294967296 : acc\n}\n","import { toSSG } from 'hono/ssg'\nimport type { UserConfig, ViteBuilder } from 'vite'\nimport * as fs from 'node:fs/promises'\nimport * as path from 'node:path'\nimport { cwd } from 'node:process'\nimport { pathToFileURL } from 'node:url'\nimport type {\n GetStaticPaths,\n RouteManifest,\n RouteParams,\n RoutePathSegment,\n StaticPath,\n} from '../../core/router-shared.ts'\nimport {\n ROUTE_DATA_ENDPOINT,\n ROUTE_DATA_REQUEST_HEADER,\n ROUTE_MANIFEST_ELEMENT_ID,\n ROUTE_PREFLIGHT_ENDPOINT,\n ROUTE_RPC_URL_HEADER,\n} from '../../core/router-shared.ts'\nimport {\n createBuildModuleUrl,\n createBuildServerModuleUrl,\n createRouteManifest,\n normalizeRoutePath,\n createRoutes,\n} from '../utils/routing.ts'\nimport {\n collectAppActions,\n collectAppLoaders,\n collectAppSymbols,\n collectReachableAnalyzableFiles,\n createBuildServerActionUrl,\n createBuildServerLoaderUrl,\n createBuildSymbolUrl,\n} from '../compiler.ts'\nimport type { ResolvedEclipsaPluginOptions } from '../options.ts'\nimport { xxHash32 } from '../../utils/xxhash32.ts'\n\nconst joinHonoPath = (left: string, right: string) => `${left}/${right}`.replaceAll(/\\/+/g, '/')\nconst CHUNK_CACHE_NAME_PREFIX = 'eclipsa-chunk-cache'\nconst CHUNK_CACHE_SW_URL = '/eclipsa-chunk-cache-sw.js'\nconst CHUNK_CACHEABLE_PATH_PREFIXES = ['/chunks/', '/entries/']\n\nconst toPublicAssetUrl = (root: string, filePath: string) =>\n `/${path.relative(root, filePath).split(path.sep).join('/')}`\n\nconst fileExists = async (filePath: string) => {\n try {\n await fs.access(filePath)\n return true\n } catch {\n return false\n }\n}\n\nconst collectFiles = async (directory: string): Promise<string[]> => {\n const entries = await fs.readdir(directory, { withFileTypes: true })\n const files = await Promise.all(\n entries.map(async (entry) => {\n const entryPath = path.join(directory, entry.name)\n return entry.isDirectory() ? collectFiles(entryPath) : [entryPath]\n }),\n )\n return files.flat()\n}\n\nconst collectClientStylesheetUrls = async (clientDir: string) => {\n try {\n const files = await collectFiles(clientDir)\n return files\n .filter((filePath) => path.extname(filePath) === '.css')\n .sort()\n .map((filePath) => toPublicAssetUrl(clientDir, filePath))\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return []\n }\n throw error\n }\n}\n\ninterface ClientChunkCacheAsset {\n hash: string\n url: string\n}\n\nconst collectClientChunkCacheAssets = async (\n clientDir: string,\n): Promise<ClientChunkCacheAsset[]> => {\n try {\n const files = await collectFiles(clientDir)\n const assetFiles = files\n .filter((filePath) => path.extname(filePath) === '.js')\n .map((filePath) => ({\n filePath,\n url: toPublicAssetUrl(clientDir, filePath),\n }))\n .filter((entry) =>\n CHUNK_CACHEABLE_PATH_PREFIXES.some((prefix) => entry.url.startsWith(prefix)),\n )\n .sort((left, right) => left.url.localeCompare(right.url))\n\n return Promise.all(\n assetFiles.map(async (asset) => ({\n hash: xxHash32(await fs.readFile(asset.filePath))\n .toString(16)\n .padStart(8, '0'),\n url: asset.url,\n })),\n )\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return []\n }\n throw error\n }\n}\n\nconst createClientChunkCacheVersion = (assets: ClientChunkCacheAsset[]) =>\n xxHash32(assets.map((asset) => `${asset.url}:${asset.hash}`).join('\\n'))\n .toString(16)\n .padStart(8, '0')\n\nconst renderChunkCacheServiceWorker = (\n version: string,\n) => `const CACHE_NAME = \"${CHUNK_CACHE_NAME_PREFIX}-${version}\";\nconst CACHE_PREFIX = \"${CHUNK_CACHE_NAME_PREFIX}-\";\nconst PATH_PREFIXES = ${JSON.stringify(CHUNK_CACHEABLE_PATH_PREFIXES)};\nconst PRECACHE_MESSAGE_TYPE = \"eclipsa:chunk-cache-precache\";\nconst pendingPrecacheUrls = new Set();\n\nconst isCacheableRequest = (request) => {\n if (request.method !== \"GET\") {\n return false;\n }\n const url = new URL(request.url);\n return url.origin === self.location.origin && PATH_PREFIXES.some((prefix) => url.pathname.startsWith(prefix));\n};\n\nconst fetchAndCache = async (cache, request) => {\n const response = await fetch(request);\n if (response.ok && (response.type === \"basic\" || response.type === \"cors\")) {\n await cache.put(request, response.clone());\n }\n return response;\n};\n\nconst precacheUrl = async (cache, url) => {\n if (pendingPrecacheUrls.has(url)) {\n return;\n }\n pendingPrecacheUrls.add(url);\n try {\n const request = new Request(new URL(url, self.location.origin).href, {\n credentials: \"same-origin\",\n });\n if (await cache.match(request)) {\n return;\n }\n await fetchAndCache(cache, request);\n } finally {\n pendingPrecacheUrls.delete(url);\n }\n};\n\nconst precacheUrls = async (priorityUrls, urls) => {\n const cache = await caches.open(CACHE_NAME);\n const queue = [...new Set([...priorityUrls, ...urls])].filter((url) =>\n PATH_PREFIXES.some((prefix) => {\n const pathname = new URL(url, self.location.origin).pathname;\n return pathname.startsWith(prefix);\n }),\n );\n for (const url of queue) {\n await precacheUrl(cache, url);\n }\n};\n\nself.addEventListener(\"install\", (event) => {\n event.waitUntil(self.skipWaiting());\n});\n\nself.addEventListener(\"activate\", (event) => {\n event.waitUntil((async () => {\n const names = await caches.keys();\n await Promise.all(\n names\n .filter((name) => name.startsWith(CACHE_PREFIX) && name !== CACHE_NAME)\n .map((name) => caches.delete(name)),\n );\n await self.clients.claim();\n })());\n});\n\nself.addEventListener(\"fetch\", (event) => {\n if (!isCacheableRequest(event.request)) {\n return;\n }\n\n event.respondWith((async () => {\n const cache = await caches.open(CACHE_NAME);\n const cached = await cache.match(event.request);\n if (cached) {\n event.waitUntil(fetchAndCache(cache, event.request).catch(() => undefined));\n return cached;\n }\n\n try {\n return await fetchAndCache(cache, event.request);\n } catch (error) {\n const fallback = await cache.match(event.request);\n if (fallback) {\n return fallback;\n }\n throw error;\n }\n })());\n});\n\nself.addEventListener(\"message\", (event) => {\n const data = event.data;\n if (!data || data.type !== PRECACHE_MESSAGE_TYPE) {\n return;\n }\n\n event.waitUntil(\n precacheUrls(\n Array.isArray(data.priorityUrls) ? data.priorityUrls : [],\n Array.isArray(data.urls) ? data.urls : [],\n ),\n );\n});\n`\n\nconst writeClientChunkCacheServiceWorker = async (\n clientDir: string,\n assets: ClientChunkCacheAsset[],\n) => {\n const version = createClientChunkCacheVersion(assets)\n const serviceWorkerPath = path.join(clientDir, CHUNK_CACHE_SW_URL.slice(1))\n await fs.mkdir(path.dirname(serviceWorkerPath), { recursive: true })\n await fs.writeFile(serviceWorkerPath, renderChunkCacheServiceWorker(version))\n}\n\nconst resolveRouteRenderMode = (\n route: Awaited<ReturnType<typeof createRoutes>>[number],\n output: ResolvedEclipsaPluginOptions['output'],\n) => route.renderMode ?? (output === 'ssg' ? 'static' : 'dynamic')\n\nexport const toHonoRoutePaths = (segments: RoutePathSegment[]) => {\n let paths = ['']\n\n for (const segment of segments) {\n switch (segment.kind) {\n case 'static':\n paths = paths.map((currentPath) => joinHonoPath(currentPath, segment.value))\n break\n case 'required':\n paths = paths.map((currentPath) => joinHonoPath(currentPath, `:${segment.value}`))\n break\n case 'optional':\n paths = paths.flatMap((currentPath) => [\n currentPath,\n joinHonoPath(currentPath, `:${segment.value}`),\n ])\n break\n case 'rest':\n paths = paths.map((currentPath) => joinHonoPath(currentPath, `:${segment.value}{.+}`))\n break\n }\n }\n\n return [...new Set(paths.map((currentPath) => (currentPath === '' ? '/' : currentPath)))]\n}\n\ninterface ResolvedStaticPathInfo {\n concretePath: string\n honoParams: Record<string, string>\n honoPatternPath: string\n}\n\ninterface ResolvedStaticPrerenderTargets {\n concretePaths: Set<string>\n dynamicParamsByPattern: Map<string, Record<string, string>[]>\n}\n\nconst createStaticPathsError = (routePath: string, message: string) =>\n new Error(`Invalid getStaticPaths() for route ${routePath}: ${message}`)\n\nconst validatePathSegmentValue = (\n routePath: string,\n paramName: string,\n value: string,\n kind: 'optional' | 'required' | 'rest',\n) => {\n if (value.length === 0) {\n throw createStaticPathsError(routePath, `${kind} param \"${paramName}\" must not be empty.`)\n }\n if (value.includes('/')) {\n throw createStaticPathsError(routePath, `${kind} param \"${paramName}\" must not contain \"/\".`)\n }\n}\n\nexport const resolveStaticPathInfo = (\n routePath: string,\n segments: RoutePathSegment[],\n params: RouteParams,\n): ResolvedStaticPathInfo => {\n const allowedParams = new Set(\n segments.filter((segment) => segment.kind !== 'static').map((segment) => segment.value),\n )\n\n for (const key of Object.keys(params)) {\n if (!allowedParams.has(key)) {\n throw createStaticPathsError(routePath, `unknown param \"${key}\".`)\n }\n }\n\n const concreteSegments: string[] = []\n const honoPatternSegments: string[] = []\n const honoParams: Record<string, string> = {}\n\n for (const segment of segments) {\n switch (segment.kind) {\n case 'static':\n concreteSegments.push(segment.value)\n honoPatternSegments.push(segment.value)\n break\n case 'required': {\n const value = params[segment.value]\n if (typeof value !== 'string') {\n throw createStaticPathsError(\n routePath,\n `required param \"${segment.value}\" must be a string.`,\n )\n }\n validatePathSegmentValue(routePath, segment.value, value, 'required')\n concreteSegments.push(value)\n honoPatternSegments.push(`:${segment.value}`)\n honoParams[segment.value] = value\n break\n }\n case 'optional': {\n const value = params[segment.value]\n if (value === undefined) {\n break\n }\n if (typeof value !== 'string') {\n throw createStaticPathsError(\n routePath,\n `optional param \"${segment.value}\" must be a string when provided.`,\n )\n }\n validatePathSegmentValue(routePath, segment.value, value, 'optional')\n concreteSegments.push(value)\n honoPatternSegments.push(`:${segment.value}`)\n honoParams[segment.value] = value\n break\n }\n case 'rest': {\n const value = params[segment.value]\n if (!Array.isArray(value)) {\n throw createStaticPathsError(\n routePath,\n `rest param \"${segment.value}\" must be a string array.`,\n )\n }\n if (value.length === 0) {\n throw createStaticPathsError(\n routePath,\n `rest param \"${segment.value}\" must contain at least one segment.`,\n )\n }\n for (const part of value) {\n if (typeof part !== 'string') {\n throw createStaticPathsError(\n routePath,\n `rest param \"${segment.value}\" must only contain strings.`,\n )\n }\n validatePathSegmentValue(routePath, segment.value, part, 'rest')\n }\n concreteSegments.push(...value)\n honoPatternSegments.push(`:${segment.value}{.+}`)\n honoParams[segment.value] = value.join('/')\n break\n }\n }\n }\n\n return {\n concretePath: normalizeRoutePath(concreteSegments.join('/')),\n honoParams,\n honoPatternPath: normalizeRoutePath(honoPatternSegments.join('/')),\n }\n}\n\nconst resolveBuiltPageModulePath = (root: string, entryName: string) =>\n path.join(root, 'dist', 'ssr', 'entries', `${entryName}.mjs`)\n\nconst loadBuiltGetStaticPaths = async (root: string, entryName: string, routePath: string) => {\n const modulePath = resolveBuiltPageModulePath(root, entryName)\n const mod = (await import(`${pathToFileURL(modulePath).href}?t=${Date.now()}`)) as Partial<{\n getStaticPaths: GetStaticPaths\n }>\n if (typeof mod.getStaticPaths !== 'function') {\n throw createStaticPathsError(routePath, 'dynamic static routes must export getStaticPaths().')\n }\n return mod.getStaticPaths\n}\n\nconst validateStaticPathsResult = (routePath: string, value: unknown): StaticPath[] => {\n if (!Array.isArray(value)) {\n throw createStaticPathsError(routePath, 'getStaticPaths() must return an array.')\n }\n return value as StaticPath[]\n}\n\nconst resolveStaticPrerenderTargets = async (\n root: string,\n routes: Array<Awaited<ReturnType<typeof createRoutes>>[number]>,\n): Promise<ResolvedStaticPrerenderTargets> => {\n const concretePaths = new Set<string>()\n const dynamicParamsByPattern = new Map<string, Record<string, string>[]>()\n const ownersByConcretePath = new Map<string, string>()\n\n const registerConcretePath = (routePath: string, concretePath: string) => {\n const existingOwner = ownersByConcretePath.get(concretePath)\n if (existingOwner) {\n throw createStaticPathsError(\n routePath,\n `duplicate concrete path \"${concretePath}\" conflicts with ${existingOwner}.`,\n )\n }\n ownersByConcretePath.set(concretePath, routePath)\n }\n\n for (const route of routes) {\n if (!route.page) {\n continue\n }\n\n const hasDynamicSegment = route.segments.some((segment) => segment.kind !== 'static')\n if (!hasDynamicSegment) {\n registerConcretePath(route.routePath, route.routePath)\n concretePaths.add(route.routePath)\n continue\n }\n\n const getStaticPaths = await loadBuiltGetStaticPaths(\n root,\n route.page.entryName,\n route.routePath,\n )\n const staticPaths = validateStaticPathsResult(route.routePath, await getStaticPaths())\n\n for (const [index, staticPath] of staticPaths.entries()) {\n if (!staticPath || typeof staticPath !== 'object') {\n throw createStaticPathsError(route.routePath, `entry ${index} must be an object.`)\n }\n if (\n !('params' in staticPath) ||\n !staticPath.params ||\n typeof staticPath.params !== 'object' ||\n Array.isArray(staticPath.params)\n ) {\n throw createStaticPathsError(\n route.routePath,\n `entry ${index} must include a params object.`,\n )\n }\n\n const resolved = resolveStaticPathInfo(route.routePath, route.segments, staticPath.params)\n registerConcretePath(route.routePath, resolved.concretePath)\n\n if (resolved.honoPatternPath === resolved.concretePath) {\n concretePaths.add(resolved.concretePath)\n continue\n }\n\n const params = dynamicParamsByPattern.get(resolved.honoPatternPath) ?? []\n params.push(resolved.honoParams)\n dynamicParamsByPattern.set(resolved.honoPatternPath, params)\n }\n }\n\n return {\n concretePaths,\n dynamicParamsByPattern,\n }\n}\n\nconst createSerializedRoutes = (routes: Awaited<ReturnType<typeof createRoutes>>) =>\n JSON.stringify(\n routes.map((route) => ({\n error: route.error ? createBuildServerModuleUrl(route.error) : null,\n layouts: route.layouts.map((layout) => createBuildServerModuleUrl(layout)),\n loading: route.loading ? createBuildServerModuleUrl(route.loading) : null,\n middlewares: route.middlewares.map((middleware) => createBuildServerModuleUrl(middleware)),\n notFound: route.notFound ? createBuildServerModuleUrl(route.notFound) : null,\n page: route.page ? createBuildServerModuleUrl(route.page) : null,\n routePath: route.routePath,\n segments: route.segments,\n server: route.server ? createBuildServerModuleUrl(route.server) : null,\n })),\n )\n\nconst toIdsByFilePath = (entries: ReadonlyArray<{ filePath: string; id: string }>) => {\n const idsByFilePath = new Map<string, string[]>()\n for (const entry of entries) {\n const existing = idsByFilePath.get(entry.filePath)\n if (existing) {\n existing.push(entry.id)\n continue\n }\n idsByFilePath.set(entry.filePath, [entry.id])\n }\n return idsByFilePath\n}\n\nconst getRouteReachableEntryFiles = (route: Awaited<ReturnType<typeof createRoutes>>[number]) =>\n [\n route.error?.filePath,\n ...route.layouts.map((layout) => layout.filePath),\n route.loading?.filePath,\n route.notFound?.filePath,\n route.page?.filePath,\n ].filter((filePath): filePath is string => typeof filePath === 'string')\n\nconst createRouteServerAccessEntries = async (\n routes: Awaited<ReturnType<typeof createRoutes>>,\n actions: ReadonlyArray<{ filePath: string; id: string }>,\n loaders: ReadonlyArray<{ filePath: string; id: string }>,\n) => {\n const actionIdsByFilePath = toIdsByFilePath(actions)\n const loaderIdsByFilePath = toIdsByFilePath(loaders)\n\n return await Promise.all(\n routes.map(async (route) => {\n const reachableFiles = await collectReachableAnalyzableFiles(\n getRouteReachableEntryFiles(route),\n )\n return {\n actionIds: reachableFiles.flatMap((filePath) => actionIdsByFilePath.get(filePath) ?? []),\n loaderIds: reachableFiles.flatMap((filePath) => loaderIdsByFilePath.get(filePath) ?? []),\n }\n }),\n )\n}\n\nconst createActionTable = (actions: Array<{ filePath: string; id: string }>) =>\n actions\n .map(\n (action) =>\n ` ${JSON.stringify(action.id)}: ${JSON.stringify(createBuildServerActionUrl(action.id))},`,\n )\n .join('\\n')\n\nconst createLoaderTable = (loaders: Array<{ filePath: string; id: string }>) =>\n loaders\n .map(\n (loader) =>\n ` ${JSON.stringify(loader.id)}: ${JSON.stringify(createBuildServerLoaderUrl(loader.id))},`,\n )\n .join('\\n')\n\nconst createPageRouteEntries = (routes: Awaited<ReturnType<typeof createRoutes>>) =>\n routes.flatMap((route, routeIndex) =>\n route.page\n ? toHonoRoutePaths(route.segments).map((honoPath) => ({\n path: honoPath,\n routeIndex,\n }))\n : [],\n )\n\nconst renderAppModule = (\n actions: Array<{ filePath: string; id: string }>,\n appHooksClientUrl: string | null,\n appHooksServerUrl: string | null,\n loaders: Array<{ filePath: string; id: string }>,\n routes: Awaited<ReturnType<typeof createRoutes>>,\n routeServerAccessEntries: Array<{ actionIds: string[]; loaderIds: string[] }>,\n routeManifest: RouteManifest,\n serverHooksUrl: string | null,\n symbolUrls: Record<string, string>,\n stylesheetUrls: string[],\n chunkCacheUrls: string[],\n) => {\n const serializedRoutes = createSerializedRoutes(routes)\n const serializedPageRouteEntries = JSON.stringify(createPageRouteEntries(routes))\n const actionTable = createActionTable(actions)\n const loaderTable = createLoaderTable(loaders)\n const serializedAppHooksManifest = JSON.stringify({\n client: appHooksClientUrl,\n })\n const serializedRouteServerAccessEntries = JSON.stringify(routeServerAccessEntries)\n const serializedAppHooksServerUrl = JSON.stringify(appHooksServerUrl)\n const serializedSymbolUrls = JSON.stringify(symbolUrls)\n const serializedRouteManifest = JSON.stringify(routeManifest)\n const serializedServerHooksUrl = JSON.stringify(serverHooksUrl)\n const serializedStylesheetUrls = JSON.stringify(stylesheetUrls)\n const serializedChunkCacheUrls = JSON.stringify(chunkCacheUrls)\n\n return `import userApp from \"./entries/server_entry.mjs\";\nimport SSRRoot from \"./entries/ssr_root.mjs\";\nimport { ACTION_CONTENT_TYPE, APP_HOOKS_ELEMENT_ID, Fragment, RESUME_FINAL_STATE_ELEMENT_ID, attachRequestFetch, composeRouteMetadata, createRequestFetch, deserializePublicValue, escapeInlineScriptText, escapeJSONScriptText, executeAction, executeLoader, getActionFormSubmissionId, getNormalizedActionInput, getStreamingResumeBootstrapScriptContent, hasAction, hasLoader, jsxDEV, markPublicError, primeActionState, primeLocationState, renderRouteMetadataHead, renderSSRAsync, renderSSRStream, resolvePendingLoaders, resolveReroute, runHandleError, serializeResumePayload, withServerRequestContext } from \"./entries/eclipsa_runtime.mjs\";\n\nconst app = userApp;\nconst actions = {\n${actionTable}\n};\nconst loaders = {\n${loaderTable}\n};\nconst routes = ${serializedRoutes};\nconst routeServerAccessEntries = ${serializedRouteServerAccessEntries};\nconst pageRouteEntries = ${serializedPageRouteEntries};\nconst appHooksManifest = ${serializedAppHooksManifest};\nconst appHooksServerUrl = ${serializedAppHooksServerUrl};\nconst routeManifest = ${serializedRouteManifest};\nconst serverHooksUrl = ${serializedServerHooksUrl};\nconst symbolUrls = ${serializedSymbolUrls};\nconst stylesheetUrls = ${serializedStylesheetUrls};\nconst chunkCacheUrls = ${serializedChunkCacheUrls};\nconst RESUME_PAYLOAD_PLACEHOLDER = ${JSON.stringify('__ECLIPSA_RESUME_PAYLOAD__')};\nconst APP_HOOKS_PLACEHOLDER = ${JSON.stringify('__ECLIPSA_APP_HOOKS__')};\nconst CHUNK_CACHE_PLACEHOLDER = ${JSON.stringify('__ECLIPSA_CHUNK_CACHE__')};\nconst ROUTE_MANIFEST_PLACEHOLDER = ${JSON.stringify('__ECLIPSA_ROUTE_MANIFEST__')};\nconst ROUTE_PARAMS_PROP = \"__eclipsa_route_params\";\nconst ROUTE_ERROR_PROP = \"__eclipsa_route_error\";\nconst ROUTE_DATA_REQUEST_HEADER = ${JSON.stringify(ROUTE_DATA_REQUEST_HEADER)};\nconst ROUTE_PREFLIGHT_REQUEST_HEADER = \"x-eclipsa-route-preflight\";\nconst CHUNK_CACHE_MESSAGE_TYPE = \"eclipsa:chunk-cache-precache\";\nconst hooksPromise = (async () => {\n const appHooks = appHooksServerUrl ? await import(appHooksServerUrl) : {};\n const serverHooks = serverHooksUrl ? await import(serverHooksUrl) : {};\n await serverHooks.init?.();\n return { appHooks, serverHooks };\n})();\n\nconst normalizeRoutePath = (pathname) => {\n const normalizedPath = pathname.trim() || \"/\";\n const withLeadingSlash = normalizedPath.startsWith(\"/\") ? normalizedPath : \"/\" + normalizedPath;\n return withLeadingSlash.length > 1 && withLeadingSlash.endsWith(\"/\")\n ? withLeadingSlash.slice(0, -1)\n : withLeadingSlash;\n};\n\nconst getRequestUrl = (request) => {\n const url = new URL(request.url);\n const host = request.headers.get(\"x-forwarded-host\") ?? request.headers.get(\"host\");\n const proto = request.headers.get(\"x-forwarded-proto\");\n if (host) {\n url.host = host;\n }\n if (proto) {\n url.protocol = proto + \":\";\n }\n return url;\n};\n\nconst matchSegments = (segments, pathnameSegments, routeIndex = 0, pathIndex = 0, params = {}) => {\n if (routeIndex >= segments.length) {\n return pathIndex >= pathnameSegments.length ? params : null;\n }\n\n const segment = segments[routeIndex];\n switch (segment.kind) {\n case \"static\":\n if (pathnameSegments[pathIndex] !== segment.value) {\n return null;\n }\n return matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex + 1, params);\n case \"required\":\n if (pathIndex >= pathnameSegments.length) {\n return null;\n }\n return matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex + 1, {\n ...params,\n [segment.value]: pathnameSegments[pathIndex],\n });\n case \"optional\": {\n const consumed =\n pathIndex < pathnameSegments.length\n ? matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex + 1, {\n ...params,\n [segment.value]: pathnameSegments[pathIndex],\n })\n : null;\n if (consumed) {\n return consumed;\n }\n return matchSegments(segments, pathnameSegments, routeIndex + 1, pathIndex, {\n ...params,\n [segment.value]: undefined,\n });\n }\n case \"rest\": {\n const rest = pathnameSegments.slice(pathIndex);\n if (rest.length === 0) {\n return null;\n }\n return matchSegments(segments, pathnameSegments, segments.length, pathnameSegments.length, {\n ...params,\n [segment.value]: rest,\n });\n }\n }\n};\n\nconst matchRoute = (pathname) => {\n const pathnameSegments = normalizeRoutePath(pathname).split(\"/\").filter(Boolean);\n for (const route of routes) {\n const params = matchSegments(route.segments, pathnameSegments);\n if (params) {\n return { params, route };\n }\n }\n return null;\n};\n\nconst matchRouteManifestEntry = (pathname) => {\n const pathnameSegments = normalizeRoutePath(pathname).split(\"/\").filter(Boolean);\n for (const entry of routeManifest) {\n const params = matchSegments(entry.segments, pathnameSegments);\n if (params) {\n return { entry, params };\n }\n }\n return null;\n};\n\nconst uniqueChunkCacheUrls = (urls) =>\n [...new Set(urls)].filter(\n (url) =>\n typeof url === \"string\" &&\n (${JSON.stringify(CHUNK_CACHEABLE_PATH_PREFIXES)}).some((prefix) => url.startsWith(prefix)),\n );\n\nconst getChunkCacheUrlPriority = (url) => {\n if (url.startsWith(\"/chunks/\")) {\n return 0;\n }\n if (url.startsWith(\"/entries/\")) {\n return 1;\n }\n return 2;\n};\n\nconst sortChunkCacheUrls = (urls) =>\n [...urls].sort(\n (left, right) =>\n getChunkCacheUrlPriority(left) - getChunkCacheUrlPriority(right) || left.localeCompare(right),\n );\n\nconst createChunkCacheMessage = (pathname, payload) => {\n const matched = matchRouteManifestEntry(pathname);\n const priorityUrls = uniqueChunkCacheUrls([\n \"/entries/client_boot.js\",\n ...(matched\n ? [...matched.entry.layouts, matched.entry.page, matched.entry.notFound, matched.entry.error]\n : []),\n ...Object.values(payload.symbols ?? {}),\n ]);\n const priorityUrlSet = new Set(priorityUrls);\n return {\n priorityUrls,\n type: CHUNK_CACHE_MESSAGE_TYPE,\n urls: sortChunkCacheUrls(chunkCacheUrls.filter((url) => !priorityUrlSet.has(url))),\n };\n};\n\nconst createChunkCacheRegistrationScript = (pathname, payload) => {\n const message = createChunkCacheMessage(pathname, payload);\n return \\`(()=>{const message=\\${JSON.stringify(message)};if(!(\"serviceWorker\" in navigator))return;const key=\"__eclipsa_chunk_cache\";const state=window[key]??={registrationPromise:null,post(nextMessage){const post=(registration)=>{const worker=registration.active??registration.waiting??registration.installing;if(worker){worker.postMessage(nextMessage);}};this.registrationPromise=this.registrationPromise??navigator.serviceWorker.register(${JSON.stringify(CHUNK_CACHE_SW_URL)},{scope:\"/\",updateViaCache:\"none\"}).then(()=>navigator.serviceWorker.ready);void this.registrationPromise.then((registration)=>{post(registration);}).catch((error)=>{console.error(\"Failed to register Eclipsa chunk cache service worker.\",error);});}};state.post(message);})();\\`;\n};\n\nconst scoreSpecialRoute = (route, pathname) => {\n const pathnameSegments = normalizeRoutePath(pathname).split(\"/\").filter(Boolean);\n let score = 0;\n for (let index = 0; index < route.segments.length && index < pathnameSegments.length; index += 1) {\n const segment = route.segments[index];\n const pathnameSegment = pathnameSegments[index];\n if (segment.kind === \"static\") {\n if (segment.value !== pathnameSegment) {\n break;\n }\n score += 10;\n continue;\n }\n score += segment.kind === \"rest\" ? 1 : 2;\n if (segment.kind === \"rest\") {\n break;\n }\n }\n return score;\n};\n\nconst findSpecialRoute = (pathname, kind) => {\n const matched = matchRoute(pathname);\n if (matched?.route[kind]) {\n return matched;\n }\n\n let best = null;\n let bestScore = -1;\n for (const route of routes) {\n if (!route[kind]) {\n continue;\n }\n const score = scoreSpecialRoute(route, pathname);\n if (score > bestScore) {\n best = { params: {}, route };\n bestScore = score;\n }\n }\n return best;\n};\n\nconst applyRequestParams = (c, params) => {\n c.req.param = (name) => {\n if (!name) {\n return params;\n }\n return params[name];\n };\n};\n\nconst isNotFoundError = (error) =>\n !!error && typeof error === \"object\" && error.__eclipsa_not_found__ === true;\n\nconst isRedirectResponse = (response) =>\n !!response &&\n typeof response === \"object\" &&\n typeof response.status === \"number\" &&\n !!response.headers &&\n typeof response.headers.get === \"function\" &&\n response.status >= 300 &&\n response.status < 400 &&\n !!response.headers.get(\"location\");\n\nconst toPublicErrorValue = async (hooks, c, error, event) => {\n const publicError = await runHandleError(\n {\n handleError: hooks.handleError,\n },\n {\n context: c,\n error,\n event,\n },\n );\n return markPublicError(error, publicError);\n};\n\nconst logServerError = (error) => {\n if (error && typeof error === \"object\" && error.__eclipsa_not_found__ === true) {\n return;\n }\n console.error(error);\n};\n\nconst prepareRequestContext = (c, hooks) => {\n attachRequestFetch(c, createRequestFetch(c, hooks.handleFetch));\n return c;\n};\n\nconst reroutePathname = (hooks, request, pathname, baseUrl) =>\n normalizeRoutePath(resolveReroute(hooks.reroute, request, pathname, baseUrl));\n\nconst getRouteServerAccess = (route) => {\n const routeIndex = routes.indexOf(route);\n const entry = routeIndex >= 0 ? routeServerAccessEntries[routeIndex] : null;\n return entry ?? { actionIds: [], loaderIds: [] };\n};\n\nconst resolveRouteForCurrentUrl = (hooks, request, currentUrl) => {\n const resolvedPathname = reroutePathname(hooks, request, normalizeRoutePath(currentUrl.pathname), currentUrl.href);\n const match = matchRoute(resolvedPathname);\n if (match?.route?.page) {\n return match;\n }\n const fallback = findSpecialRoute(resolvedPathname, \"notFound\");\n return fallback?.route?.notFound ? fallback : null;\n};\n\nconst getRpcCurrentRoute = (hooks, c) => {\n const requestUrl = getRequestUrl(c.req.raw);\n const routeUrlHeader = c.req.header(${JSON.stringify(ROUTE_RPC_URL_HEADER)});\n if (!routeUrlHeader) {\n return null;\n }\n let currentUrl;\n try {\n currentUrl = new URL(routeUrlHeader, requestUrl);\n } catch {\n return null;\n }\n if (currentUrl.origin !== requestUrl.origin) {\n return null;\n }\n return resolveRouteForCurrentUrl(hooks, c.req.raw, currentUrl);\n};\n\nconst resolveRequest = async (c, handler) => {\n const { appHooks, serverHooks } = await hooksPromise;\n const requestContext = prepareRequestContext(c, serverHooks);\n const execute = (nextContext = requestContext) =>\n withServerRequestContext(\n nextContext,\n {\n handleError: serverHooks.handleError,\n transport: appHooks.transport,\n },\n () => handler(nextContext, appHooks, serverHooks),\n );\n\n if (!serverHooks.handle) {\n return execute(requestContext);\n }\n\n return withServerRequestContext(\n requestContext,\n {\n handleError: serverHooks.handleError,\n transport: appHooks.transport,\n },\n () => serverHooks.handle(requestContext, (nextContext) => execute(nextContext ?? requestContext)),\n );\n};\n\nconst resolveRequestRoute = (hooks, request, url) => {\n const requestPathname = normalizeRoutePath(new URL(url).pathname);\n const resolvedPathname = reroutePathname(hooks, request, requestPathname, url);\n return {\n match: matchRoute(resolvedPathname),\n requestPathname,\n resolvedPathname,\n };\n};\n\nconst loadRouteMiddlewares = async (route) =>\n Promise.all(\n route.middlewares.map(async (middlewareUrl) => {\n const mod = await import(middlewareUrl);\n if (typeof mod.default !== \"function\") {\n throw new TypeError(\n \\`Route middleware \"\\${middlewareUrl}\" must default export a middleware function.\\`,\n );\n }\n return mod.default;\n }),\n );\n\nconst composeRouteMiddlewares = async (route, c, params, handler) => {\n applyRequestParams(c, params);\n const middlewares = await loadRouteMiddlewares(route);\n let index = -1;\n const dispatch = async (nextIndex) => {\n if (nextIndex <= index) {\n throw new Error(\"Route middleware called next() multiple times.\");\n }\n index = nextIndex;\n const middleware = middlewares[nextIndex];\n if (!middleware) {\n return handler();\n }\n let nextResult;\n const result = await middleware(c, async () => {\n nextResult = await dispatch(nextIndex + 1);\n });\n return result !== undefined ? result : nextResult;\n };\n return dispatch(0);\n};\n\nconst resolvePreflightTarget = (pathname) => {\n const match = matchRoute(pathname);\n if (match?.route?.page) {\n return match;\n }\n if (!match) {\n const fallback = findSpecialRoute(pathname, \"notFound\");\n if (fallback?.route?.notFound) {\n return fallback;\n }\n }\n return null;\n};\n\nconst replaceHeadPlaceholder = (html, placeholder, value) => html.replace(placeholder, value);\nconst splitHtmlForStreaming = (html) => {\n const bodyCloseIndex = html.lastIndexOf(\"</body>\");\n if (bodyCloseIndex >= 0) {\n return {\n prefix: html.slice(0, bodyCloseIndex),\n suffix: html.slice(bodyCloseIndex),\n };\n }\n const htmlCloseIndex = html.lastIndexOf(\"</html>\");\n if (htmlCloseIndex >= 0) {\n return {\n prefix: html.slice(0, htmlCloseIndex),\n suffix: html.slice(htmlCloseIndex),\n };\n }\n return {\n prefix: html,\n suffix: \"\",\n };\n};\n\nconst ROUTE_SLOT_ROUTE_KEY = Symbol.for(\"eclipsa.route-slot-route\");\n\nconst createRouteSlot = (route, startLayoutIndex) => {\n const slot = {\n __eclipsa_type: \"route-slot\",\n pathname: route.pathname,\n startLayoutIndex,\n };\n Object.defineProperty(slot, ROUTE_SLOT_ROUTE_KEY, {\n configurable: true,\n enumerable: false,\n value: route,\n writable: true,\n });\n return slot;\n};\n\nconst createRouteProps = (params, props) => {\n const nextProps = { ...props };\n Object.defineProperty(nextProps, ROUTE_PARAMS_PROP, {\n configurable: true,\n enumerable: false,\n value: params,\n writable: true,\n });\n return nextProps;\n};\n\nconst attachRouteError = (props, error) => {\n Object.defineProperty(props, ROUTE_ERROR_PROP, {\n configurable: true,\n enumerable: false,\n value: error,\n writable: true,\n });\n return props;\n};\n\nconst createRouteElement = (pathname, params, Page, Layouts, error) => {\n if (Layouts.length === 0) {\n return jsxDEV(Page, attachRouteError(createRouteProps(params, {}), error), null, false, {});\n }\n\n const route = {\n error,\n layouts: Layouts.map((renderer) => ({ renderer })),\n page: { renderer: Page },\n params,\n pathname,\n };\n let children = null;\n for (let index = Layouts.length - 1; index >= 0; index -= 1) {\n const Layout = Layouts[index];\n children = jsxDEV(Layout, attachRouteError(createRouteProps(params, { children: createRouteSlot(route, index + 1) }), error), null, false, {});\n }\n return children;\n};\n\nconst invokeRouteServer = async (moduleUrl, c, params) => {\n applyRequestParams(c, params);\n const mod = await import(moduleUrl);\n const methodHandler = mod[c.req.method];\n if (typeof methodHandler === \"function\") {\n return methodHandler(c);\n }\n const serverApp = mod.default;\n if (serverApp && typeof serverApp.fetch === \"function\") {\n return serverApp.fetch(c.req.raw);\n }\n return c.text(\"Not Found\", 404);\n};\n\nconst renderRouteResponse = async (route, pathname, params, c, moduleUrl, status = 200, options) => {\n const [pageModule, ...layoutModules] = await Promise.all([\n import(moduleUrl),\n ...route.layouts.map((layout) => import(layout)),\n ]);\n const Page = pageModule.default;\n const Layouts = layoutModules.map((module) => module.default);\n const metadata = composeRouteMetadata(\n [...layoutModules.map((module) => module.metadata ?? null), pageModule.metadata ?? null],\n {\n params,\n url: getRequestUrl(c.req.raw),\n },\n );\n const document = SSRRoot({\n children: createRouteElement(pathname, params, Page, Layouts, options?.routeError),\n head: {\n type: Fragment,\n isStatic: true,\n props: {\n children: [\n ...renderRouteMetadataHead(metadata),\n ...stylesheetUrls.map((href) => ({\n type: \"link\",\n isStatic: true,\n props: {\n href,\n rel: \"stylesheet\",\n },\n })),\n {\n type: \"script\",\n isStatic: true,\n props: {\n children: RESUME_PAYLOAD_PLACEHOLDER,\n id: \"eclipsa-resume\",\n type: \"application/eclipsa-resume+json\",\n },\n },\n {\n type: \"script\",\n isStatic: true,\n props: {\n children: ROUTE_MANIFEST_PLACEHOLDER,\n id: \"${ROUTE_MANIFEST_ELEMENT_ID}\",\n type: \"application/eclipsa-route-manifest+json\",\n },\n },\n {\n type: \"script\",\n isStatic: true,\n props: {\n children: APP_HOOKS_PLACEHOLDER,\n id: APP_HOOKS_ELEMENT_ID,\n type: \"application/eclipsa-app-hooks+json\",\n },\n },\n {\n type: \"script\",\n isStatic: true,\n props: {\n dangerouslySetInnerHTML: getStreamingResumeBootstrapScriptContent(),\n },\n },\n {\n type: \"script\",\n isStatic: true,\n props: {\n dangerouslySetInnerHTML: CHUNK_CACHE_PLACEHOLDER,\n },\n },\n {\n type: \"script\",\n isStatic: true,\n props: {\n type: \"module\",\n src: \"/entries/client_boot.js\",\n },\n },\n ],\n },\n },\n });\n\n applyRequestParams(c, params);\n const { html, payload, chunks } = await renderSSRStream(() => document, {\n prepare(container) {\n primeLocationState(container, getRequestUrl(c.req.raw));\n return options?.prepare?.(container);\n },\n resolvePendingLoaders: async (container) => resolvePendingLoaders(container, c),\n symbols: symbolUrls,\n });\n const shellHtml = replaceHeadPlaceholder(\n replaceHeadPlaceholder(\n replaceHeadPlaceholder(\n replaceHeadPlaceholder(html, RESUME_PAYLOAD_PLACEHOLDER, serializeResumePayload(payload)),\n CHUNK_CACHE_PLACEHOLDER,\n escapeInlineScriptText(createChunkCacheRegistrationScript(pathname, payload)),\n ),\n ROUTE_MANIFEST_PLACEHOLDER,\n escapeJSONScriptText(JSON.stringify(routeManifest)),\n ),\n APP_HOOKS_PLACEHOLDER,\n escapeJSONScriptText(JSON.stringify(appHooksManifest)),\n );\n const { prefix, suffix } = splitHtmlForStreaming(shellHtml);\n const encoder = new TextEncoder();\n return new Response(\n new ReadableStream({\n start(controller) {\n controller.enqueue(encoder.encode(prefix));\n void (async () => {\n let latestPayload = payload;\n\n for await (const chunk of chunks) {\n latestPayload = chunk.payload;\n const templateId = \"eclipsa-suspense-template-\" + chunk.boundaryId;\n const payloadId = \"eclipsa-suspense-payload-\" + chunk.boundaryId;\n controller.enqueue(\n encoder.encode(\n \"<template id=\\\\\"\" + templateId + \"\\\\\">\" + chunk.html + \"</template>\" +\n \"<script id=\\\\\"\" + payloadId + \"\\\\\" type=\\\\\"application/eclipsa-resume+json\\\\\">\" + serializeResumePayload(chunk.payload) + \"</script>\" +\n \"<script>window.__eclipsa_stream.enqueue({boundaryId:\" + JSON.stringify(chunk.boundaryId) + \",payloadScriptId:\" + JSON.stringify(payloadId) + \",templateId:\" + JSON.stringify(templateId) + \"})</script>\",\n ),\n );\n }\n\n controller.enqueue(\n encoder.encode(\n \"<script id=\\\\\"\" + RESUME_FINAL_STATE_ELEMENT_ID + \"\\\\\" type=\\\\\"application/eclipsa-resume+json\\\\\">\" + serializeResumePayload(latestPayload) + \"</script>\" +\n \"<script>\" + escapeInlineScriptText(createChunkCacheRegistrationScript(pathname, latestPayload)) + \"</script>\" +\n suffix,\n ),\n );\n controller.close();\n })().catch((error) => {\n controller.error(error);\n });\n },\n }),\n {\n headers: {\n \"content-type\": \"text/html; charset=utf-8\",\n },\n status,\n },\n );\n};\n\nconst renderMatchedPage = async (match, c, options) => {\n const { appHooks, serverHooks } = await hooksPromise;\n const requestUrl = getRequestUrl(c.req.raw);\n const pathname = normalizeRoutePath(requestUrl.pathname);\n const resolvedPathname = reroutePathname(appHooks, c.req.raw, pathname, requestUrl.href);\n try {\n return await renderRouteResponse(match.route, pathname, match.params, c, match.route.page, 200, options);\n } catch (error) {\n logServerError(error);\n const publicError = await toPublicErrorValue(serverHooks, c, error, \"page\");\n const fallback = isNotFoundError(error) ? findSpecialRoute(resolvedPathname, \"notFound\") : findSpecialRoute(resolvedPathname, \"error\");\n const kind = isNotFoundError(error) ? \"notFound\" : \"error\";\n const moduleUrl = fallback?.route?.[kind];\n if (!fallback || !moduleUrl) {\n return c.text(isNotFoundError(error) ? \"Not Found\" : \"Internal Server Error\", isNotFoundError(error) ? 404 : 500);\n }\n return renderRouteResponse(fallback.route, pathname, fallback.params, c, moduleUrl, isNotFoundError(error) ? 404 : 500, {\n ...options,\n routeError: publicError,\n });\n }\n};\n\nconst renderRouteDataResponse = async (route, pathname, params, c, moduleUrl, kind) => {\n const [pageModule, ...layoutModules] = await Promise.all([\n import(moduleUrl),\n ...route.layouts.map((layout) => import(layout)),\n ]);\n const Page = pageModule.default;\n const Layouts = layoutModules.map((module) => module.default);\n\n applyRequestParams(c, params);\n const { payload } = await renderSSRAsync(() => createRouteElement(pathname, params, Page, Layouts, undefined), {\n prepare(container) {\n primeLocationState(container, getRequestUrl(c.req.raw));\n },\n resolvePendingLoaders: async (container) => resolvePendingLoaders(container, c),\n symbols: symbolUrls,\n });\n\n return c.json({\n finalHref: getRequestUrl(c.req.raw).href,\n finalPathname: pathname,\n kind,\n loaders: payload.loaders,\n ok: true,\n });\n};\n\nconst renderRouteData = async (route, pathname, params, c, moduleUrl, kind) => {\n const { appHooks } = await hooksPromise;\n const requestUrl = getRequestUrl(c.req.raw);\n const requestPathname = normalizeRoutePath(requestUrl.pathname);\n const resolvedPathname = reroutePathname(appHooks, c.req.raw, requestPathname, requestUrl.href);\n try {\n return await renderRouteDataResponse(route, pathname, params, c, moduleUrl, kind);\n } catch (error) {\n if (!isNotFoundError(error)) {\n return c.json({ document: true, ok: false });\n }\n const fallback = findSpecialRoute(resolvedPathname, \"notFound\");\n if (!fallback?.route?.notFound) {\n return c.json({ document: true, ok: false });\n }\n try {\n return await renderRouteDataResponse(\n fallback.route,\n requestPathname,\n fallback.params,\n c,\n fallback.route.notFound,\n \"not-found\",\n );\n } catch {\n return c.json({ document: true, ok: false });\n }\n }\n};\n\nconst resolveRouteData = async (href, c) => {\n const requestUrl = getRequestUrl(c.req.raw);\n const targetUrl = new URL(href, requestUrl);\n if (targetUrl.origin !== requestUrl.origin) {\n return c.json({ document: true, ok: false });\n }\n const headers = new Headers(c.req.raw.headers);\n headers.set(ROUTE_DATA_REQUEST_HEADER, \"1\");\n const response = await app.fetch(\n new Request(targetUrl.href, {\n headers,\n method: \"GET\",\n redirect: \"manual\",\n }),\n );\n if (response.status >= 200 && response.status < 300) {\n return response;\n }\n if (isRedirectResponse(response)) {\n return c.json({\n location: new URL(response.headers.get(\"location\"), requestUrl).href,\n ok: false,\n });\n }\n return c.json({ document: true, ok: false });\n};\n\nconst resolveRoutePreflight = async (href, c) => {\n const { appHooks } = await hooksPromise;\n const requestUrl = getRequestUrl(c.req.raw);\n const targetUrl = new URL(href, requestUrl);\n if (targetUrl.origin !== requestUrl.origin) {\n return c.json({ document: true, ok: false });\n }\n\n const target = resolvePreflightTarget(reroutePathname(appHooks, new Request(targetUrl.href), normalizeRoutePath(targetUrl.pathname), targetUrl.href));\n if (!target) {\n return c.json({ ok: true });\n }\n\n const headers = new Headers(c.req.raw.headers);\n headers.set(ROUTE_PREFLIGHT_REQUEST_HEADER, \"1\");\n let response;\n try {\n response = await c.var.fetch(targetUrl.href, {\n headers,\n redirect: \"manual\",\n });\n } catch {\n response = await app.fetch(\n new Request(targetUrl.href, {\n headers,\n method: \"GET\",\n redirect: \"manual\",\n }),\n );\n }\n\n if (response.status >= 200 && response.status < 300) {\n return c.json({ ok: true });\n }\n if (isRedirectResponse(response)) {\n return c.json({\n location: new URL(response.headers.get(\"location\"), requestUrl).href,\n ok: false,\n });\n }\n return c.json({ document: true, ok: false });\n};\n\nfor (const pageRouteEntry of pageRouteEntries) {\n app.get(pageRouteEntry.path, async (c) => {\n const pathname = normalizeRoutePath(getRequestUrl(c.req.raw).pathname);\n const match = matchRoute(pathname);\n if (!match || match.route !== routes[pageRouteEntry.routeIndex]) {\n return c.text(\"Not Found\", 404);\n }\n return composeRouteMiddlewares(\n match.route,\n c,\n match.params,\n async () =>\n c.req.header(ROUTE_PREFLIGHT_REQUEST_HEADER) === \"1\"\n ? c.body(null, 204)\n : c.req.header(ROUTE_DATA_REQUEST_HEADER) === \"1\"\n ? renderRouteData(match.route, pathname, match.params, c, match.route.page, \"page\")\n : renderMatchedPage(match, c),\n );\n });\n}\n\napp.post(\"/__eclipsa/action/:id\", async (c) =>\n resolveRequest(c, async (requestContext, appHooks) => {\n const id = requestContext.req.param(\"id\");\n if (!id) {\n return requestContext.text(\"Not Found\", 404);\n }\n const routeMatch = getRpcCurrentRoute(appHooks, requestContext);\n if (!routeMatch) {\n return requestContext.text(\"Bad Request\", 400);\n }\n const routeAccess = getRouteServerAccess(routeMatch.route);\n if (!routeAccess.actionIds.includes(id)) {\n return requestContext.text(\"Not Found\", 404);\n }\n const moduleUrl = actions[id];\n if (!moduleUrl) {\n return requestContext.text(\"Not Found\", 404);\n }\n if (!hasAction(id)) {\n await import(moduleUrl);\n }\n return composeRouteMiddlewares(\n routeMatch.route,\n requestContext,\n routeMatch.params,\n async () => executeAction(id, requestContext),\n );\n }),\n);\n\napp.get(\"/__eclipsa/loader/:id\", async (c) =>\n resolveRequest(c, async (requestContext, appHooks) => {\n const id = requestContext.req.param(\"id\");\n if (!id) {\n return requestContext.text(\"Not Found\", 404);\n }\n const routeMatch = getRpcCurrentRoute(appHooks, requestContext);\n if (!routeMatch) {\n return requestContext.text(\"Bad Request\", 400);\n }\n const routeAccess = getRouteServerAccess(routeMatch.route);\n if (!routeAccess.loaderIds.includes(id)) {\n return requestContext.text(\"Not Found\", 404);\n }\n const moduleUrl = loaders[id];\n if (!moduleUrl) {\n return requestContext.text(\"Not Found\", 404);\n }\n if (!hasLoader(id)) {\n await import(moduleUrl);\n }\n return composeRouteMiddlewares(\n routeMatch.route,\n requestContext,\n routeMatch.params,\n async () => executeLoader(id, requestContext),\n );\n }),\n);\n\napp.get(${JSON.stringify(ROUTE_PREFLIGHT_ENDPOINT)}, async (c) => {\n const href = c.req.query(\"href\");\n if (!href) {\n return c.json({ document: true, ok: false }, 400);\n }\n return resolveRoutePreflight(href, c);\n});\n\napp.get(${JSON.stringify(ROUTE_DATA_ENDPOINT)}, async (c) => {\n const href = c.req.query(\"href\");\n if (!href) {\n return c.json({ document: true, ok: false }, 400);\n }\n return resolveRouteData(href, c);\n});\n\napp.all(\"*\", async (c) => {\n const pathname = normalizeRoutePath(getRequestUrl(c.req.raw).pathname);\n const match = matchRoute(pathname);\n\n if (!match) {\n const fallback = findSpecialRoute(pathname, \"notFound\");\n if (fallback?.route?.notFound) {\n return composeRouteMiddlewares(\n fallback.route,\n c,\n fallback.params,\n async () =>\n c.req.header(ROUTE_PREFLIGHT_REQUEST_HEADER) === \"1\"\n ? c.body(null, 204)\n : c.req.header(ROUTE_DATA_REQUEST_HEADER) === \"1\"\n ? renderRouteData(fallback.route, pathname, fallback.params, c, fallback.route.notFound, \"not-found\")\n : renderRouteResponse(fallback.route, pathname, fallback.params, c, fallback.route.notFound, 404),\n );\n }\n return c.text(\"Not Found\", 404);\n }\n\n if ((c.req.method === \"GET\" || c.req.method === \"HEAD\") && match.route.page) {\n return composeRouteMiddlewares(\n match.route,\n c,\n match.params,\n async () =>\n c.req.header(ROUTE_PREFLIGHT_REQUEST_HEADER) === \"1\"\n ? c.body(null, 204)\n : c.req.header(ROUTE_DATA_REQUEST_HEADER) === \"1\"\n ? renderRouteData(match.route, pathname, match.params, c, match.route.page, \"page\")\n : renderMatchedPage(match, c),\n );\n }\n if (c.req.method === \"POST\" && match.route.page) {\n return composeRouteMiddlewares(\n match.route,\n c,\n match.params,\n async () => {\n const actionId = await getActionFormSubmissionId(c);\n if (!actionId) {\n return match.route.server\n ? invokeRouteServer(match.route.server, c, match.params)\n : renderMatchedPage(match, c);\n }\n const routeAccess = getRouteServerAccess(match.route);\n if (!routeAccess.actionIds.includes(actionId)) {\n return c.text(\"Not Found\", 404);\n }\n const moduleUrl = actions[actionId];\n if (!moduleUrl) {\n return c.text(\"Not Found\", 404);\n }\n if (!hasAction(actionId)) {\n await import(moduleUrl);\n }\n const input = await getNormalizedActionInput(c);\n const response = await executeAction(actionId, c);\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (!contentType.startsWith(ACTION_CONTENT_TYPE)) {\n return response;\n }\n const body = await response.json();\n return renderMatchedPage(match, c, {\n prepare(container) {\n primeActionState(container, actionId, {\n error: body.ok ? undefined : deserializeValue(body.error),\n input,\n result: body.ok ? deserializeValue(body.value) : undefined,\n });\n },\n });\n },\n );\n }\n if (match.route.server) {\n return composeRouteMiddlewares(match.route, c, match.params, async () =>\n invokeRouteServer(match.route.server, c, match.params),\n );\n }\n if (match.route.page) {\n return composeRouteMiddlewares(\n match.route,\n c,\n match.params,\n async () =>\n c.req.header(ROUTE_PREFLIGHT_REQUEST_HEADER) === \"1\"\n ? c.body(null, 204)\n : renderMatchedPage(match, c),\n );\n }\n return c.text(\"Not Found\", 404);\n});\n\nexport const pageRoutePatterns = [...new Set(pageRouteEntries.map((entry) => entry.path))];\nexport default app;\n`\n}\n\nconst renderNodeServer = () => `import app from \"../ssr/eclipsa_app.mjs\";\nimport { createServer } from \"node:http\";\nimport { readFile, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst fileTypes = new Map([\n [\".js\", \"text/javascript; charset=utf-8\"],\n [\".mjs\", \"text/javascript; charset=utf-8\"],\n [\".css\", \"text/css; charset=utf-8\"],\n [\".html\", \"text/html; charset=utf-8\"],\n [\".json\", \"application/json; charset=utf-8\"],\n [\".svg\", \"image/svg+xml\"],\n [\".png\", \"image/png\"],\n [\".jpg\", \"image/jpeg\"],\n [\".jpeg\", \"image/jpeg\"],\n]);\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\nconst clientDir = path.resolve(__dirname, \"../client\");\n\nconst toRequest = (incomingMessage) => {\n const body =\n incomingMessage.method !== \"GET\" && incomingMessage.method !== \"HEAD\"\n ? new ReadableStream({\n start(controller) {\n incomingMessage.on(\"data\", (chunk) => controller.enqueue(new Uint8Array(chunk)));\n incomingMessage.on(\"end\", () => controller.close());\n },\n })\n : null;\n const headers = new Headers();\n for (const [key, value] of Object.entries(incomingMessage.headers)) {\n if (Array.isArray(value)) {\n value.forEach((entry) => headers.append(key, entry));\n } else if (value) {\n headers.append(key, value);\n }\n }\n return new Request(new URL(incomingMessage.url ?? \"/\", \"http://localhost\"), {\n method: incomingMessage.method,\n headers,\n body,\n });\n};\n\nconst sendResponse = async (response, serverResponse) => {\n for (const [key, value] of response.headers) {\n serverResponse.setHeader(key, value);\n }\n serverResponse.statusCode = response.status;\n serverResponse.statusMessage = response.statusText;\n const buffer = Buffer.from(await response.arrayBuffer());\n serverResponse.end(buffer);\n};\n\nconst serveStatic = async (pathname) => {\n const normalized = pathname.replace(/^\\\\/+/, \"\");\n const filePath = path.join(clientDir, normalized);\n if (!filePath.startsWith(clientDir)) {\n return null;\n }\n\n try {\n const info = await stat(filePath);\n if (!info.isFile()) {\n return null;\n }\n return new Response(await readFile(filePath), {\n headers: {\n \"content-type\": fileTypes.get(path.extname(filePath)) ?? \"application/octet-stream\",\n },\n });\n } catch {\n return null;\n }\n};\n\nconst port = Number.parseInt(process.env.PORT ?? \"3000\", 10);\n\ncreateServer(async (req, res) => {\n const url = new URL(req.url ?? \"/\", \"http://localhost\");\n const staticResponse = await serveStatic(url.pathname);\n if (staticResponse) {\n await sendResponse(staticResponse, res);\n return;\n }\n\n const response = await app.fetch(toRequest(req));\n await sendResponse(response, res);\n}).listen(port, () => {\n console.log(\"Eclipsa server listening on http://localhost:\" + port);\n});\n`\n\nexport const build = async (\n builder: ViteBuilder,\n userConfig: UserConfig,\n options: ResolvedEclipsaPluginOptions,\n) => {\n const root = userConfig.root ?? cwd()\n const appHooksPath = path.join(root, 'app/+hooks.ts')\n const serverHooksPath = path.join(root, 'app/+hooks.server.ts')\n const actions = await collectAppActions(root)\n const loaders = await collectAppLoaders(root)\n const routes = await createRoutes(root)\n const routeServerAccessEntries = await createRouteServerAccessEntries(routes, actions, loaders)\n const staticPageRoutes = routes.filter(\n (route) => route.page && resolveRouteRenderMode(route, options.output) === 'static',\n )\n const dynamicPageRoutes = routes.filter(\n (route) => route.page && resolveRouteRenderMode(route, options.output) === 'dynamic',\n )\n if (options.output === 'ssg') {\n const dynamicRoute = dynamicPageRoutes[0]\n if (dynamicRoute) {\n throw new Error(\n `Route ${dynamicRoute.routePath} is marked render = \"dynamic\", which is not supported with output \"ssg\". Switch the app output to \"node\" or mark the route as \"static\".`,\n )\n }\n const routeWithMiddleware = routes.find((route) => route.middlewares.length > 0)\n if (routeWithMiddleware) {\n throw new Error(\n `Route middleware is not supported with output \"ssg\". Remove +middleware.ts from route ${routeWithMiddleware.routePath} or switch to output \"node\".`,\n )\n }\n }\n const routeManifest = createRouteManifest(routes, createBuildModuleUrl)\n const symbols = await collectAppSymbols(root)\n const symbolUrls = Object.fromEntries(\n symbols.map((symbol) => [symbol.id, createBuildSymbolUrl(symbol.id)]),\n )\n\n await builder.build(builder.environments.client)\n await builder.build(builder.environments.ssr)\n\n const appHooksClientUrl = (await fileExists(appHooksPath))\n ? createBuildModuleUrl({ entryName: 'app_hooks', filePath: appHooksPath })\n : null\n const appHooksServerUrl = (await fileExists(appHooksPath))\n ? createBuildServerModuleUrl({ entryName: 'app_hooks', filePath: appHooksPath })\n : null\n const clientDir = path.join(root, 'dist/client')\n const serverHooksUrl = (await fileExists(serverHooksPath))\n ? createBuildServerModuleUrl({ entryName: 'server_hooks', filePath: serverHooksPath })\n : null\n const stylesheetUrls = await collectClientStylesheetUrls(clientDir)\n const chunkCacheAssets = await collectClientChunkCacheAssets(clientDir)\n await writeClientChunkCacheServiceWorker(clientDir, chunkCacheAssets)\n const serverDir = path.join(root, 'dist/server')\n const appModulePath = path.join(root, 'dist/ssr/eclipsa_app.mjs')\n await fs.mkdir(path.dirname(appModulePath), { recursive: true })\n await fs.writeFile(\n appModulePath,\n renderAppModule(\n actions,\n appHooksClientUrl,\n appHooksServerUrl,\n loaders,\n routes,\n routeServerAccessEntries,\n routeManifest,\n serverHooksUrl,\n symbolUrls,\n stylesheetUrls,\n chunkCacheAssets.map((asset) => asset.url),\n ),\n )\n const staticPrerenderTargets = await resolveStaticPrerenderTargets(root, staticPageRoutes)\n\n const prerenderStaticRoutes = async () => {\n if (\n staticPrerenderTargets.concretePaths.size === 0 &&\n staticPrerenderTargets.dynamicParamsByPattern.size === 0\n ) {\n return\n }\n\n const { default: app } = (await import(\n `${pathToFileURL(appModulePath).href}?t=${Date.now()}`\n )) as {\n default: { fetch(request: Request): Promise<Response> }\n }\n const result = await toSSG(app as any, fs, {\n beforeRequestHook(request: Request) {\n const routePath = normalizeRoutePath(decodeURIComponent(new URL(request.url).pathname))\n if (\n routePath === normalizeRoutePath(ROUTE_DATA_ENDPOINT) ||\n routePath === normalizeRoutePath(ROUTE_PREFLIGHT_ENDPOINT) ||\n routePath.startsWith('/__eclipsa/loader/')\n ) {\n return false\n }\n const ssgParams = staticPrerenderTargets.dynamicParamsByPattern.get(routePath)\n if (ssgParams) {\n ;(request as Request & { ssgParams?: Record<string, string>[] }).ssgParams = ssgParams\n return request\n }\n return staticPrerenderTargets.concretePaths.has(routePath) ? request : false\n },\n dir: clientDir,\n })\n\n if (!result.success) {\n throw result.error ?? new Error('Failed to generate static output.')\n }\n }\n\n if (options.output === 'node') {\n await prerenderStaticRoutes()\n await fs.mkdir(serverDir, { recursive: true })\n await fs.writeFile(path.join(serverDir, 'index.mjs'), renderNodeServer())\n return\n }\n\n await fs.rm(serverDir, { force: true, recursive: true })\n await prerenderStaticRoutes()\n}\n","import * as path from 'node:path'\nimport { pathToFileURL } from 'node:url'\n\nconst ECLIPSA_NITRO_ENTRY_ID = '#eclipsa/nitro-entry'\n\ninterface VitePluginLike {\n name?: string\n nitro?: unknown\n}\n\ninterface NitroPublicAsset {\n baseURL?: string\n dir: string\n maxAge?: number\n}\n\ninterface NitroConfigLike {\n entry?: string\n publicAssets?: NitroPublicAsset[]\n virtual?: Record<string, string | (() => string)>\n [key: string]: unknown\n}\n\nconst normalizeAssetBaseURL = (value: string) => {\n const normalized = value.trim() || '/'\n if (normalized === '/') {\n return '/'\n }\n return normalized.startsWith('/') ? normalized : `/${normalized}`\n}\n\nconst flattenPlugins = (plugins: unknown): VitePluginLike[] => {\n if (!Array.isArray(plugins)) {\n return plugins && typeof plugins === 'object' ? [plugins as VitePluginLike] : []\n }\n return plugins.flatMap((entry) => flattenPlugins(entry))\n}\n\nexport const hasNitroPlugin = (plugins: unknown): boolean =>\n flattenPlugins(plugins).some((plugin) => {\n if (!plugin || typeof plugin !== 'object') {\n return false\n }\n if ('nitro' in plugin) {\n return true\n }\n return typeof plugin.name === 'string' && plugin.name.startsWith('nitro:')\n })\n\nexport const createEclipsaNitroEntry = (appModulePath: string) =>\n [\n 'import { defineHandler } from \"nitro\";',\n `import app from ${JSON.stringify(pathToFileURL(appModulePath).href)};`,\n '',\n 'export default defineHandler((event) => app.fetch(event.req));',\n '',\n ].join('\\n')\n\nexport const createEclipsaNitroConfig = (\n root: string,\n nitroConfig: NitroConfigLike | undefined,\n): NitroConfigLike => {\n const clientDir = path.join(root, 'dist/client')\n const appModulePath = path.join(root, 'dist/ssr/eclipsa_app.mjs')\n const nextPublicAssets = [...(nitroConfig?.publicAssets ?? [])]\n const hasClientAssetDir = nextPublicAssets.some(\n (asset) =>\n path.resolve(root, asset.dir) === clientDir &&\n normalizeAssetBaseURL(asset.baseURL ?? '/') === '/',\n )\n\n if (!hasClientAssetDir) {\n nextPublicAssets.push({\n baseURL: '/',\n dir: clientDir,\n })\n }\n\n return {\n ...nitroConfig,\n entry: ECLIPSA_NITRO_ENTRY_ID,\n publicAssets: nextPublicAssets,\n virtual: {\n ...nitroConfig?.virtual,\n [ECLIPSA_NITRO_ENTRY_ID]: createEclipsaNitroEntry(appModulePath),\n },\n }\n}\n","import type { Plugin } from 'vite'\nimport * as fs from 'node:fs/promises'\nimport { cwd } from 'node:process'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { collectRouteModules, collectRouteServerModules, createRoutes } from './utils/routing.ts'\nimport { build } from './build/mod.ts'\nimport {\n collectAppActions,\n collectAppLoaders,\n collectAppSymbols,\n createSymbolRequestId,\n} from './compiler.ts'\nimport type { ResolvedEclipsaPluginOptions } from './options.ts'\nimport { createEclipsaNitroConfig, hasNitroPlugin } from './nitro.ts'\n\nconst ECLIPSA_RUNTIME_ENTRY_PATH = fileURLToPath(import.meta.resolve('eclipsa/vite/build/runtime'))\n\nconst fileExists = async (filePath: string) => {\n try {\n await fs.access(filePath)\n return true\n } catch {\n return false\n }\n}\n\nexport const createConfig =\n (options: ResolvedEclipsaPluginOptions): Plugin['config'] =>\n async (userConfig) => {\n const root = userConfig.root ?? cwd()\n const appHooksPath = path.join(root, 'app/+hooks.ts')\n const serverHooksPath = path.join(root, 'app/+hooks.server.ts')\n const hasAppHooks = await fileExists(appHooksPath)\n const hasServerHooks = await fileExists(serverHooksPath)\n const nitroEnabled = hasNitroPlugin(userConfig.plugins)\n const routes = await createRoutes(root)\n const routeModules = collectRouteModules(routes)\n const routeServerModules = collectRouteServerModules(routes)\n const actions = await collectAppActions(root)\n const loaders = await collectAppLoaders(root)\n const symbols = await collectAppSymbols(root)\n\n const clientInput = Object.fromEntries([\n ['client_boot', path.join(root, 'app/+client.dev.tsx')],\n ...(hasAppHooks ? [['app_hooks', appHooksPath] as const] : []),\n ...symbols.map((symbol) => [\n `symbol__${symbol.id}`,\n createSymbolRequestId(symbol.filePath, symbol.id),\n ]),\n ...routeModules.map((entry) => [entry.entryName, entry.filePath]),\n ])\n\n const ssrInput = Object.fromEntries([\n ['server_entry', path.join(root, 'app/+server-entry.ts')],\n ['ssr_root', path.join(root, 'app/+ssr-root.tsx')],\n ['eclipsa_runtime', ECLIPSA_RUNTIME_ENTRY_PATH],\n ...(hasAppHooks ? [['app_hooks', appHooksPath] as const] : []),\n ...(hasServerHooks ? [['server_hooks', serverHooksPath] as const] : []),\n ...actions.map((action) => [`action__${action.id}`, action.filePath]),\n ...loaders.map((loader) => [`loader__${loader.id}`, loader.filePath]),\n ...routeModules.map((entry) => [entry.entryName, entry.filePath]),\n ...routeServerModules.map((entry) => [entry.entryName, entry.filePath]),\n ])\n\n return {\n oxc: {\n jsx: 'preserve',\n jsxFactory: 'jsx',\n jsxImportSource: 'eclipsa',\n sourcemap: false,\n },\n ...(nitroEnabled\n ? ({\n nitro: createEclipsaNitroConfig(\n root,\n (userConfig as typeof userConfig & { nitro?: Record<string, unknown> }).nitro,\n ),\n } as Record<string, unknown>)\n : {}),\n environments: {\n client: {\n build: {\n emptyOutDir: true,\n outDir: path.join(root, 'dist/client'),\n rollupOptions: {\n input: clientInput,\n output: {\n assetFileNames: 'assets/[name]-[hash][extname]',\n chunkFileNames: 'chunks/[name]-[hash].js',\n entryFileNames: 'entries/[name].js',\n },\n preserveEntrySignatures: 'allow-extension',\n },\n },\n },\n ssr: {\n resolve: {\n noExternal: [/^eclipsa(?:\\/|$)/],\n },\n build: {\n emptyOutDir: true,\n outDir: path.join(root, 'dist/ssr'),\n rollupOptions: {\n input: ssrInput,\n output: {\n assetFileNames: 'assets/[name]-[hash][extname]',\n chunkFileNames: 'chunks/[name]-[hash].mjs',\n entryFileNames: 'entries/[name].mjs',\n },\n preserveEntrySignatures: 'allow-extension',\n },\n },\n },\n },\n builder: {\n async buildApp(builder) {\n await build(builder, userConfig, options)\n },\n },\n }\n }\n","export type EclipsaOutputTarget = 'node' | 'ssg'\n\nexport interface EclipsaPluginOptions {\n output?: EclipsaOutputTarget\n}\n\nexport interface ResolvedEclipsaPluginOptions {\n output: EclipsaOutputTarget\n}\n\nexport const resolveEclipsaPluginOptions = (\n options?: EclipsaPluginOptions,\n): ResolvedEclipsaPluginOptions => ({\n output: options?.output ?? 'node',\n})\n","import {\n createServerModuleRunner,\n transformWithOxc,\n type Plugin,\n type PluginOption,\n type ResolvedConfig,\n} from 'vite'\nimport { createDevFetch, shouldInvalidateDevApp } from './dev-app/mod.ts'\nimport { incomingMessageToRequest, responseForServerResponse } from '../utils/node-connect.ts'\nimport { createConfig } from './config.ts'\nimport { resolveEclipsaPluginOptions, type EclipsaPluginOptions } from './options.ts'\nimport {\n compileModuleForClient,\n compileModuleForSSR,\n inspectResumeHmrUpdate,\n loadSymbolModuleForClient,\n loadSymbolModuleForSSR,\n parseSymbolRequest,\n resolveResumeHmrUpdate,\n} from './compiler.ts'\nimport { RESUME_HMR_EVENT, type ResumeHmrUpdatePayload } from '../core/resume-hmr.ts'\n\nconst ECLIPSA_SOURCE_EXTENSIONS = new Set([\n '.cjs',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.mts',\n '.ts',\n '.tsx',\n])\n\nconst stripRequestQuery = (value: string) => value.replace(/[?#].*$/, '')\n\nconst isTestLikeSourceRequest = (value: string) =>\n /\\.(?:test|spec)\\.[^./]+$/.test(stripRequestQuery(value).replaceAll('\\\\', '/'))\n\nconst isAppSourceRequest = (value: string) =>\n /(^|\\/)app\\//.test(stripRequestQuery(value).replaceAll('\\\\', '/'))\n\nconst isEclipsaSourceRequest = (value: string) => {\n const normalized = stripRequestQuery(value)\n const extensionIndex = normalized.lastIndexOf('.')\n if (extensionIndex < 0) {\n return false\n }\n const extension = normalized.slice(extensionIndex)\n if (!ECLIPSA_SOURCE_EXTENSIONS.has(extension)) {\n return false\n }\n return extension === '.tsx' || isAppSourceRequest(normalized)\n}\n\nconst isCssRequest = (value: string | undefined) => {\n if (!value) {\n return false\n }\n const normalized = stripRequestQuery(value)\n return normalized.endsWith('.css')\n}\n\nconst createHotTargetUrl = (root: string, filePath: string) => {\n const normalizedRoot = root.replaceAll('\\\\', '/').replace(/\\/$/, '')\n const normalizedFilePath = stripRequestQuery(filePath).replaceAll('\\\\', '/')\n if (normalizedFilePath.startsWith('/app/')) {\n return normalizedFilePath\n }\n if (\n normalizedFilePath === normalizedRoot ||\n normalizedFilePath.startsWith(`${normalizedRoot}/`)\n ) {\n return `/${normalizedFilePath.slice(normalizedRoot.length + 1)}`\n }\n return `/@fs/${normalizedFilePath}`\n}\n\nconst preserveCssHotModules = <\n T extends { file?: string; id?: string; type?: string; url?: string },\n>(\n modules: T[],\n) =>\n modules.filter(\n (module) =>\n module.type === 'css' ||\n isCssRequest(module.id) ||\n isCssRequest(module.url) ||\n isCssRequest(module.file),\n )\n\nconst mergeUniqueHotModules = <T extends { file?: string; id?: string; url?: string }>(\n modules: T[],\n) => {\n const seen = new Set<string>()\n return modules.filter((module) => {\n const key = module.id ?? module.file ?? module.url\n if (!key || seen.has(key)) {\n return false\n }\n seen.add(key)\n return true\n })\n}\n\ninterface EclipsaPluginState {\n config?: ResolvedConfig\n pendingSsrUpdates?: Map<string, ResumeHmrUpdatePayload>\n}\n\ninterface HotModule {\n file?: string\n id?: string\n type?: string\n url: string\n}\n\nconst collectCssHotModules = (\n pluginContext: PluginContextWithEnvironment,\n options: HotUpdateContext,\n) =>\n mergeUniqueHotModules([\n ...preserveCssHotModules(options.modules),\n ...preserveCssHotModules([\n ...(pluginContext.environment.moduleGraph?.idToModuleMap?.values() ?? []),\n ]),\n ])\n\nconst sendSsrHotEvent = (\n pluginContext: PluginContextWithEnvironment,\n options: HotUpdateContext,\n event: string,\n payload?: unknown,\n) => {\n if (options.server?.ws) {\n options.server.ws.send(event, payload)\n return\n }\n pluginContext.environment.hot.send(event, payload)\n}\n\nconst hasClientHotModuleForFile = (options: HotUpdateContext) => {\n const clientModules = options.server?.environments?.client?.moduleGraph?.getModulesByFile(\n options.file,\n )\n if (!clientModules) {\n return false\n }\n for (const _module of clientModules) {\n return true\n }\n return false\n}\n\nconst shouldForceFullReloadForWatcherEvent = (\n filePath: string,\n event: 'add' | 'change' | 'unlink',\n) => event !== 'change' && isEclipsaSourceRequest(filePath) && !isTestLikeSourceRequest(filePath)\n\nconst handleHotUpdate = async (\n state: EclipsaPluginState,\n pluginContext: PluginContextWithEnvironment,\n options: HotUpdateContext,\n) => {\n const config = state.config\n if (!config || !isEclipsaSourceRequest(options.file) || isTestLikeSourceRequest(options.file)) {\n return\n }\n const source = await options.read()\n if (pluginContext.environment.name !== 'client') {\n const resumableUpdate = await inspectResumeHmrUpdate({\n filePath: options.file,\n root: config.root,\n source,\n })\n if (resumableUpdate.isResumable) {\n if (resumableUpdate.update) {\n if (hasClientHotModuleForFile(options)) {\n return collectCssHotModules(pluginContext, options)\n }\n const pendingSsrUpdate = state.pendingSsrUpdates?.get(options.file)\n if (\n pendingSsrUpdate &&\n !pendingSsrUpdate.fullReload &&\n resumableUpdate.update.fullReload &&\n pendingSsrUpdate.fileUrl === resumableUpdate.update.fileUrl\n ) {\n return collectCssHotModules(pluginContext, options)\n }\n state.pendingSsrUpdates ??= new Map()\n state.pendingSsrUpdates.set(options.file, resumableUpdate.update)\n sendSsrHotEvent(pluginContext, options, RESUME_HMR_EVENT, resumableUpdate.update)\n }\n return collectCssHotModules(pluginContext, options)\n }\n return\n }\n const resumableUpdate = await resolveResumeHmrUpdate({\n filePath: options.file,\n root: config.root,\n source,\n })\n if (resumableUpdate.isResumable) {\n const pendingSsrUpdate = state.pendingSsrUpdates?.get(options.file)\n if (pendingSsrUpdate) {\n state.pendingSsrUpdates?.delete(options.file)\n } else if (resumableUpdate.update) {\n pluginContext.environment.hot.send(RESUME_HMR_EVENT, resumableUpdate.update)\n }\n return collectCssHotModules(pluginContext, options)\n }\n\n const module =\n options.modules[0] ??\n [...(pluginContext.environment.moduleGraph?.getModulesByFile(options.file) ?? [])][0]\n pluginContext.environment.hot.send('update-client', {\n url: module?.url ?? createHotTargetUrl(config.root, options.file),\n })\n return collectCssHotModules(pluginContext, options)\n}\n\ninterface PluginContextWithEnvironment {\n environment: {\n hot: {\n send(event: string, payload?: unknown): void\n }\n moduleGraph?: {\n idToModuleMap?: Map<string, HotModule>\n getModulesByFile(file: string): Iterable<{ url: string }> | undefined\n }\n name: string\n }\n}\n\ninterface HotUpdateContext {\n file: string\n modules: HotModule[]\n read(): Promise<string> | string\n server?: {\n environments?: {\n client?: {\n moduleGraph?: {\n getModulesByFile(file: string): Iterable<{ url: string }> | undefined\n }\n }\n }\n ws?: {\n send(event: string, payload?: unknown): void\n }\n }\n}\n\nconst eclipsaCore = (state: EclipsaPluginState, options: EclipsaPluginOptions = {}): Plugin => {\n return {\n enforce: 'pre',\n name: 'vite-plugin-eclipsa',\n config: createConfig(resolveEclipsaPluginOptions(options)),\n configResolved(resolvedConfig) {\n state.config = resolvedConfig\n },\n configureServer(server) {\n const config = state.config\n if (!config) {\n throw new Error('Resolved Vite config is unavailable during configureServer().')\n }\n const ssrEnv = server.environments.ssr\n const runner = createServerModuleRunner(ssrEnv, {\n hmr: false,\n })\n const devApp = createDevFetch({\n resolvedConfig: config,\n devServer: server,\n runner,\n ssrEnv,\n })\n const invalidateDevApp = (filePath: string, event: 'add' | 'change' | 'unlink') => {\n if (shouldInvalidateDevApp(config.root, filePath, event)) {\n devApp.invalidate()\n }\n if (shouldForceFullReloadForWatcherEvent(filePath, event)) {\n server.ws.send({\n path: '*',\n type: 'full-reload',\n } as any)\n }\n }\n\n server.watcher.on('add', (filePath) => {\n invalidateDevApp(filePath, 'add')\n })\n server.watcher.on('change', (filePath) => {\n invalidateDevApp(filePath, 'change')\n })\n server.watcher.on('unlink', (filePath) => {\n invalidateDevApp(filePath, 'unlink')\n })\n\n server.middlewares.use(async (req, res, next) => {\n const webReq = incomingMessageToRequest(req)\n const webRes = await devApp.fetch(webReq)\n if (webRes) {\n responseForServerResponse(webRes, res)\n return\n }\n next()\n })\n },\n async load(id) {\n if (!parseSymbolRequest(id)) {\n return null\n }\n return this.environment.name === 'client'\n ? loadSymbolModuleForClient(id)\n : loadSymbolModuleForSSR(id)\n },\n async transform(code, id) {\n if (!isEclipsaSourceRequest(id) || parseSymbolRequest(id)) {\n return\n }\n const config = state.config\n if (!config) {\n throw new Error('Resolved Vite config is unavailable during transform().')\n }\n if (isTestLikeSourceRequest(id)) {\n return transformWithOxc(code, id, {\n jsx: {\n development: !config.isProduction,\n importSource: 'eclipsa',\n runtime: 'automatic',\n },\n })\n }\n const isClient = this.environment.name === 'client'\n return {\n code: isClient\n ? await compileModuleForClient(code, id, {\n hmr: !config.isProduction,\n })\n : await compileModuleForSSR(code, id),\n }\n },\n }\n}\n\nconst eclipsaHot = (state: EclipsaPluginState): Plugin => ({\n enforce: 'post',\n name: 'vite-plugin-eclipsa:hmr',\n async hotUpdate(options) {\n return handleHotUpdate(\n state,\n this as PluginContextWithEnvironment,\n options as unknown as HotUpdateContext,\n ) as any\n },\n})\n\nexport type { EclipsaPluginOptions } from './options.ts'\n\nexport const eclipsa = (options?: EclipsaPluginOptions): PluginOption => {\n const state: EclipsaPluginState = {}\n return [eclipsaCore(state, options), eclipsaHot(state)]\n}\n"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAa,sBAAsB,aAAqB;CACtD,MAAM,iBAAiB,SAAS,MAAM,IAAI;CAC1C,MAAM,mBAAmB,eAAe,WAAW,IAAI,GAAG,iBAAiB,IAAI;AAC/E,KAAI,iBAAiB,SAAS,KAAK,iBAAiB,SAAS,IAAI,CAC/D,QAAO,iBAAiB,MAAM,GAAG,GAAG;AAEtC,QAAO;;AAyCT,MAAM,8BAAmD;CACvD,OAAO;CACP,QAAQ;CACR,SAAS;CACT,YAAY;CACZ,UAAU;CACV,MAAM;CACN,QAAQ;CACT;AAED,MAAM,eAAe,iBAAyB;CAG5C,MAAM,WAFa,aAAa,WAAW,MAAM,IAAI,CACvB,QAAQ,YAAY,GAAG,CACzB,MAAM,IAAI;CACtC,MAAM,WAAW,SAAS,KAAK,IAAI;AAYnC,QAAO,CAXQ,SAAS,WAAW,UAAU,GACzC,WACA,SAAS,WAAW,QAAQ,GAC1B,UACA,SAAS,WAAW,UAAU,GAC5B,WACA,WAKQ,GAJD,SACZ,KAAK,YAAY,QAAQ,WAAW,kBAAkB,IAAI,IAAI,QAAQ,CACtE,OAAO,SAAS,WAAW,kBAAkB,IAAI,IAAI,QAAQ,CAEtC,CAAC,KAAK,KAAK;;AAGvC,MAAM,sBACJ,QACA,UACA,mBACmB;CACnB,MAAM,eAAe,KAAK,SAAS,QAAQ,SAAS,CAAC,WAAW,MAAM,IAAI;AAC1E,QAAO;EACL;EACA,KAAK,qBAAqB,KAAK,MAAM,QAAQ,aAAa,CAAC;EAC3D,WAAW,YAAY,aAAa;EACpC;EACD;;AAGH,MAAM,wBAAwB,gBAC5B,gBAAgB,OAAO,gBAAgB,KAAK,KAAK,YAAY,WAAW,MAAM,IAAI;AAEpF,MAAM,oBAAoB,gBAAyB,gBAAgB,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