@moonsjs/vite 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-df6b8rqt.js → index-sdm38v1p.js} +84 -4
- package/dist/{index-df6b8rqt.js.map → index-sdm38v1p.js.map} +4 -4
- package/dist/index.js +7 -4
- package/dist/index.js.map +3 -3
- package/dist/plugin.d.ts.map +1 -1
- package/dist/server/bun-server.d.ts.map +1 -1
- package/dist/server/dev.d.ts +2 -0
- package/dist/server/dev.d.ts.map +1 -1
- package/dist/server/index.js +115 -25
- package/dist/server/index.js.map +5 -5
- package/dist/server/node-server.d.ts +2 -0
- package/dist/server/node-server.d.ts.map +1 -1
- package/dist/server/transport.d.ts +16 -0
- package/dist/server/transport.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/plugin.ts +4 -1
- package/src/server/bun-server.ts +67 -9
- package/src/server/dev.ts +27 -2
- package/src/server/node-server.ts +77 -15
- package/src/server/storage.ts +10 -0
- package/src/server/transport.ts +90 -0
package/dist/index.js.map
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/plugin.ts", "../src/api.ts", "../src/leak-check.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { createHash } from \"node:crypto\";\nimport { relative as relativePath, resolve as resolvePath } from \"node:path\";\nimport {\n MOONS_VERSION,\n MoonsError,\n fnRegistryKey,\n generateTypes,\n scanApiMiddlewares,\n scanApiRoutes,\n scanRoutes,\n validateConfig,\n type ApiMiddlewareDefinition,\n type ApiRouteDefinition,\n type RouteDefinition,\n} from \"@moonsjs/core\";\nimport { loadConfigFromFile, type Plugin, type ViteDevServer } from \"vite\";\nimport { assertApiModuleExports, assertMiddlewareExports } from \"./api\";\nimport { findLeak } from \"./leak-check\";\nimport type { PackageJsonInfo } from \"./server-only\";\nimport { renderApiModule, renderRoutesModule, rootSpecifier } from \"./manifest\";\nimport { installDevMiddleware } from \"./server/dev\";\nimport {\n analyzeServerFile,\n checkClientModuleImports,\n checkRouteModuleExports,\n injectServerFnMeta,\n isNonContractServerFile,\n isServerFilePath,\n nonContractServerFileError,\n renderServerFnStub,\n resolveServerSpecifierSync,\n scanServerFiles,\n stripQuery,\n type ServerFileAnalysis,\n} from \"./transform\";\nimport { fromNullPrefixed, VIRTUAL_MODULES } from \"./virtual-modules\";\n\nexport interface MoonsVitePluginOptions {\n /** Default: \"moons.config.ts\". */\n configPath?: string;\n /** Hanya dipakai di CI (M2 §21). */\n leakTest?: { canary?: string };\n /** Default: root Vite. */\n projectRoot?: string;\n}\n\n/**\n * Plugin `@moonsjs/vite` (PRD §9): scan route, typegen, virtual module,\n * dev SSR middleware, build client + server.\n */\nconst CODE_FILE_PATTERN = /\\.(ts|tsx|js|jsx|mjs|cjs|mts|cts)$/;\n\nexport default function moons(options: MoonsVitePluginOptions = {}): Plugin {\n let root = options.projectRoot ?? process.cwd();\n let isSsrBuild = false;\n let configFilePath = \"\";\n let routesDir = \"\";\n let serverOnlyPackages: ReadonlyArray<string> = [];\n // Addendum J.1/J.2: paritas dev & produksi (paritas E7).\n let trustProxy = false;\n let bodyLimitBytes: number | undefined;\n let apiDir = \"\";\n let apiRoutes: ApiRouteDefinition[] = [];\n let apiMiddlewares: ApiMiddlewareDefinition[] = [];\n /** Cache package.json untuk gate Addendum C (dibagi lintas modul). */\n const packageCache = new Map<string, PackageJsonInfo | null>(); let routes: RouteDefinition[] = [];\n let analysisCache = new Map<string, ServerFileAnalysis>();\n const stubTransformed = new Set<string>();\n\n function analyzeFile(absoluteFile: string): ServerFileAnalysis | null {\n const cached = analysisCache.get(absoluteFile);\n if (cached !== undefined) {\n return cached;\n }\n let source: string;\n try {\n source = readFileSync(absoluteFile, \"utf8\");\n } catch {\n return null;\n }\n const analysis = analyzeServerFile(source, absoluteFile, root);\n analysisCache.set(absoluteFile, analysis);\n return analysis;\n }\n\n function refreshServerFns(): void {\n const next = new Map<string, ServerFileAnalysis>();\n const registry: Record<string, string> = {};\n\n for (const file of scanServerFiles(root)) {\n let source: string;\n try {\n source = readFileSync(file, \"utf8\");\n } catch {\n continue;\n }\n const analysis = analyzeServerFile(source, file, root);\n next.set(file, analysis);\n for (const fn of analysis.serverFns) {\n registry[fnRegistryKey(root, file, fn.name)] = fn.hash;\n }\n }\n\n analysisCache = next;\n const outDir = resolvePath(root, \".moons\");\n mkdirSync(outDir, { recursive: true });\n writeFileSync(\n resolvePath(outDir, \"fn-registry.json\"),\n `${JSON.stringify(registry, null, 2)}\\n`,\n \"utf8\",\n );\n }\n\n /** Semua specifier file `.server.ts` yang punya serverFn (untuk eager import di entry server). */\n function serverFnFileSpecifiers(): string[] {\n const specifiers: string[] = [];\n for (const [file, analysis] of analysisCache) {\n if (analysis.serverFns.length > 0) {\n specifiers.push(rootSpecifier(root, file));\n }\n }\n return specifiers.sort();\n }\n\n /** Stub client §12.2 + cache §12.2.5. */\n function transformServerFileClient(code: string, id: string): string {\n const relativePath = id.startsWith(root)\n ? id.slice(root.length).split(\"\\\\\").join(\"/\")\n : id;\n const cacheKey = createHash(\"sha256\").update(`${relativePath}\\0${code}`).digest(\"hex\");\n const cacheFile = resolvePath(root, \".moons/cache\", `${cacheKey}.js`);\n\n if (existsSync(cacheFile)) {\n stubTransformed.add(id);\n return readFileSync(cacheFile, \"utf8\");\n }\n\n const analysis = analyzeFile(id);\n if (analysis === null) {\n throw new MoonsError({\n code: \"E_INTERNAL\",\n file: id,\n message: \"failed to read the server file for transform\",\n details: \"The `.server.ts` file must be readable during transform.\",\n suggestions: [\"Check the path and file permissions\"],\n });\n }\n\n const stub = renderServerFnStub(code, id, analysis, {\n analyzeSpecifier: (sourceFile, specifier) => {\n const resolved = resolveServerSpecifierSync(sourceFile, specifier);\n return resolved === null ? null : analyzeFile(resolved);\n },\n });\n\n mkdirSync(resolvePath(root, \".moons/cache\"), { recursive: true });\n writeFileSync(cacheFile, stub.code, \"utf8\");\n stubTransformed.add(id);\n return stub.code;\n }\n\n return {\n name: \"moons\",\n enforce: \"pre\",\n\n config(_config, env) {\n isSsrBuild = env.isSsrBuild === true;\n const common = {\n appType: \"custom\" as const,\n };\n\n if (isSsrBuild) {\n return {\n ...common,\n build: {\n outDir: \"dist/server\",\n emptyOutDir: true,\n // Entry nyata yang di-generate saat buildStart (Rolldown butuh file,\n // entry virtual tidak di-resolve lewat plugin container).\n // D.5: dua entry — server (index) + prerender runner.\n ssr: true,\n rollupOptions: {\n input: {\n index: \".moons/server-entry.ts\",\n prerender: \".moons/prerender-entry.ts\",\n },\n output: {\n entryFileNames: \"[name].js\",\n chunkFileNames: \"chunks/[name]-[hash].js\",\n },\n },\n },\n ssr: { noExternal: true, target: \"node\" as const },\n };\n }\n\n return {\n ...common,\n build: { outDir: \"dist/client\", emptyOutDir: true },\n // Dev SSR: paket framework WAJIB di-inline ke pipeline Vite. Sejak\n // dipublikasikan, `@moonsjs/*` adalah package node_modules biasa (bukan\n // workspace-link) sehingga default Vite mengeksternalnya; import runtime\n // (bun) menyelesaikannya lewat kondisi `bun` → `src`, sedangkan modul\n // route diselesaikan Vite → `dist` — dua instans React context →\n // \"useLoaderData dipanggil di luar render route\" (temuan eval T4;\n // docs/decisions/0015). Inline → semua konsisten lewat Vite.\n ssr: { noExternal: [/^@moonsjs\\//] },\n };\n },\n\n async configResolved(resolved) {\n root = options.projectRoot ?? resolved.root;\n configFilePath = resolvePath(root, options.configPath ?? \"moons.config.ts\");\n\n if (!existsSync(configFilePath)) {\n throw new MoonsError({\n code: \"E_CONFIG_INVALID\",\n file: configFilePath,\n message: \"`moons.config.ts` not found\",\n details: \"The framework requires a config file at the project root.\",\n suggestions: [\n \"Create `moons.config.ts` with `export default defineConfig({ context: async (req) => ({}) })`\",\n ],\n });\n }\n\n let raw: unknown;\n try {\n const loaded = await loadConfigFromFile(\n { command: resolved.command, mode: resolved.mode },\n configFilePath,\n root,\n );\n raw = loaded?.config;\n } catch (error) {\n if (error instanceof MoonsError) {\n throw error;\n }\n throw new MoonsError({\n code: \"E_CONFIG_INVALID\",\n file: configFilePath,\n message: \"failed to load `moons.config.ts`\",\n details: error instanceof Error ? error.message : String(error),\n suggestions: [\"Check the syntax and imports in `moons.config.ts`\"],\n });\n }\n\n const config = validateConfig(raw, { file: configFilePath, projectRoot: root });\n routesDir = resolvePath(root, config.routesDir);\n serverOnlyPackages = config.security?.serverOnlyPackages ?? [];\n trustProxy = config.security?.trustProxy === true;\n bodyLimitBytes = config.security?.bodyLimitBytes;\n\n // Addendum D.1: scan + validasi statis modul `src/api`.\n apiDir = resolvePath(root, config.apiDir ?? \"src/api\");\n if (existsSync(apiDir)) {\n apiRoutes = scanApiRoutes(apiDir);\n for (const route of apiRoutes) {\n assertApiModuleExports(readFileSync(route.file, \"utf8\"), route.file);\n }\n apiMiddlewares = scanApiMiddlewares(apiDir);\n for (const middleware of apiMiddlewares) {\n assertMiddlewareExports(readFileSync(middleware.file, \"utf8\"), middleware.file);\n }\n } else {\n apiRoutes = [];\n apiMiddlewares = [];\n }\n },\n\n async buildStart() {\n routes = scanRoutes(routesDir);\n // D.3: validasi statis `_middleware.ts` pohon routes.\n for (const middleware of routes.filter((route) => route.kind === \"middleware\")) {\n assertMiddlewareExports(readFileSync(middleware.file, \"utf8\"), middleware.file);\n }\n await generateTypes({\n routesDir,\n configPath: configFilePath,\n outDir: resolvePath(root, \".moons\"),\n });\n refreshServerFns();\n if (isSsrBuild) {\n writeFileSync(\n resolvePath(root, \".moons/server-entry.ts\"),\n renderServerEntryBuild(routesDir, serverFnFileSpecifiers(), options.leakTest?.canary),\n \"utf8\",\n );\n writeFileSync(\n resolvePath(root, \".moons/prerender-entry.ts\"),\n renderPrerenderEntry(routesDir, root, options.leakTest?.canary),\n \"utf8\",\n );\n }\n },\n\n resolveId(id) {\n const clean = id.startsWith(\"\\0\") ? id.slice(1) : id;\n if ((Object.values(VIRTUAL_MODULES) as string[]).includes(clean)) {\n return `\\0${clean}`;\n }\n return undefined;\n },\n\n load(id) {\n const name = fromNullPrefixed(id);\n if (name === null) {\n return undefined;\n }\n switch (name) {\n case VIRTUAL_MODULES.routes:\n return renderRoutesModule(routes, routesDir, root);\n case VIRTUAL_MODULES.api:\n return renderApiModule(apiRoutes, apiMiddlewares, root);\n case VIRTUAL_MODULES.clientEntry:\n return '// Generated by @moons. Do not edit manually.\\nexport { clientManifest, loadRoute } from \"virtual:moons/routes\";\\n';\n case VIRTUAL_MODULES.config:\n return renderConfigModule(root, configFilePath);\n case VIRTUAL_MODULES.serverEntry:\n // Hanya dipakai dev (ssrLoadModule); build memakai .moons/server-entry.ts.\n return renderServerEntryDev(routesDir, serverFnFileSpecifiers());\n }\n },\n\n async transform(code, id) {\n const cleanId = stripQuery(id);\n if (cleanId.startsWith(\"\\0\") || cleanId.includes(\"/node_modules/\")) {\n return undefined;\n }\n\n const environment = environmentName(this);\n\n if (isServerFilePath(cleanId)) {\n if (environment === \"ssr\") {\n const analysis = analysisCache.get(cleanId) ?? analyzeFile(cleanId);\n if (analysis === null || analysis.serverFns.length === 0) {\n return undefined;\n }\n return injectServerFnMeta(code, analysis, root);\n }\n return transformServerFileClient(code, cleanId);\n }\n\n // Audit ronde 2: file server di luar kontrak §12 tidak bisa di-stub —\n // jangan pernah biarkan masuk graph client.\n if (environment !== \"ssr\" && isNonContractServerFile(cleanId)) {\n throw nonContractServerFileError(cleanId, root);\n }\n\n if (environment !== \"ssr\" && CODE_FILE_PATTERN.test(cleanId)) {\n if (cleanId.startsWith(routesDir) && cleanId.endsWith(\".tsx\")) {\n checkRouteModuleExports({\n file: cleanId,\n code,\n routesDir,\n projectRoot: root,\n });\n }\n await checkClientModuleImports({\n file: cleanId,\n code,\n projectRoot: root,\n // Resolusi penuh (alias Vite, tsconfig paths, symlink) — audit ronde 2.\n resolve: async (specifier, importer) => {\n try {\n const resolved = await this.resolve(specifier, importer);\n return resolved === null ? null : stripQuery(resolved.id);\n } catch {\n return null;\n }\n },\n analyze: (absoluteFile) => analysisCache.get(absoluteFile) ?? analyzeFile(absoluteFile),\n apiDir,\n configFile: configFilePath,\n serverDir: resolvePath(root, \"src/server\"),\n serverOnlyPackages,\n packageCache,\n });\n }\n\n return undefined;\n },\n\n generateBundle(_options, bundle) {\n if (environmentName(this) === \"ssr\") {\n return;\n }\n\n const canary = options.leakTest?.canary;\n if (canary !== undefined && canary.length > 0) {\n const leak = findLeak(Object.values(bundle), canary);\n if (leak !== null) {\n throw new MoonsError({\n code: \"E_INTERNAL\",\n message: `canary \\`${canary}\\` found in the client bundle (${leak.fileName})`,\n details:\n \"Leak verification failed: server code leaked into the client output. Build stopped.\",\n suggestions: [\n \"Check the `*.server.ts` transform\",\n \"Run `./scripts/m2/test-leak.sh` to audit\",\n ],\n });\n }\n }\n\n for (const output of Object.values(bundle)) {\n if (output.type !== \"chunk\") {\n continue;\n }\n for (const moduleId of Object.keys(output.modules)) {\n const cleanId = stripQuery(moduleId);\n if (!isServerFilePath(cleanId) || stubTransformed.has(cleanId)) {\n continue;\n }\n throw new MoonsError({\n code: \"E_FORBIDDEN_SERVER_IMPORT\",\n file: cleanId,\n message: \"server module got bundled into the client without passing through the transform\",\n details:\n \"Build verification: every `*.server.ts` in the client bundle must be an RPC stub produced by the transform.\",\n suggestions: [\n \"Make sure the zero-trust transform runs for this module\",\n \"If this repeats, report it as a framework bug\",\n ],\n });\n }\n }\n },\n\n configureServer(server) {\n installDevMiddleware(server, {\n templatePath: resolvePath(root, \"index.html\"),\n // Addendum I.4 (W4): overlay devtools — data segar per request.\n devtools: () => {\n const toRelative = (file: string): string =>\n file.startsWith(root) ? relativePath(root, file).split(\"\\\\\").join(\"/\") : file;\n return {\n routes: [...routes]\n .sort((a, b) => a.path.localeCompare(b.path) || a.kind.localeCompare(b.kind))\n .map((route) => ({ path: route.path, kind: route.kind, file: toRelative(route.file) })),\n apiRoutes: [...apiRoutes]\n .sort((a, b) => a.path.localeCompare(b.path))\n .map((route) => ({ path: route.path, kind: \"api\", file: toRelative(route.file) })),\n serverFns: [...analysisCache.values()]\n .flatMap((analysis) =>\n analysis.serverFns.map((fn) => ({\n file: toRelative(analysis.file),\n name: fn.name,\n hash: fn.hash,\n })),\n )\n .sort((a, b) => a.file.localeCompare(b.file) || a.name.localeCompare(b.name)),\n canary: options.leakTest?.canary !== undefined,\n version: MOONS_VERSION,\n };\n },\n // A1: pemindaian payload SSR hanya di dev (warning), tanpa biaya di production.\n payloadScan: {\n ...(options.leakTest?.canary === undefined ? {} : { canary: options.leakTest.canary }),\n env: process.env,\n },\n // D.1: request ke prefix API (semua method) dirutekan ke runtime.\n ...(apiRoutes.length === 0\n ? {}\n : { apiPrefix: `/${apiDir.split(/[\\\\/]/).filter((part) => part.length > 0).pop() ?? \"api\"}` }),\n trustProxy,\n ...(bodyLimitBytes === undefined ? {} : { bodyLimitBytes }),\n });\n server.config.logger.info(\"[moons] devtools: /__moons/devtools\");\n },\n\n async handleHotUpdate(context) {\n if (isServerFilePath(context.file)) {\n refreshServerFns();\n context.server.ws.send({ type: \"full-reload\" });\n return;\n }\n\n if (context.file.startsWith(apiDir) && existsSync(apiDir)) {\n try {\n apiRoutes = scanApiRoutes(apiDir);\n for (const route of apiRoutes) {\n assertApiModuleExports(readFileSync(route.file, \"utf8\"), route.file);\n }\n apiMiddlewares = scanApiMiddlewares(apiDir);\n for (const middleware of apiMiddlewares) {\n assertMiddlewareExports(readFileSync(middleware.file, \"utf8\"), middleware.file);\n }\n } catch (error) {\n context.server.config.logger.error(String(error));\n return;\n }\n invalidateVirtualModules(context.server);\n context.server.ws.send({ type: \"full-reload\" });\n return;\n }\n\n if (!context.file.startsWith(routesDir)) {\n return;\n }\n\n try {\n routes = scanRoutes(routesDir);\n for (const middleware of routes.filter((route) => route.kind === \"middleware\")) {\n assertMiddlewareExports(readFileSync(middleware.file, \"utf8\"), middleware.file);\n }\n await generateTypes({\n routesDir,\n configPath: configFilePath,\n outDir: resolvePath(root, \".moons\"),\n });\n } catch (error) {\n context.server.config.logger.error(String(error));\n return;\n }\n\n invalidateVirtualModules(context.server);\n context.server.ws.send({ type: \"full-reload\" });\n },\n };\n}\n\nfunction renderConfigModule(root: string, configFilePath: string): string {\n return [\n \"// Generated by @moons. Do not edit manually.\",\n `import raw from ${JSON.stringify(rootSpecifier(root, configFilePath))};`,\n 'import { validateConfig } from \"@moonsjs/core\";',\n `export default validateConfig(raw, { file: ${JSON.stringify(configFilePath)} });`,\n \"\",\n ].join(\"\\n\");\n}\n\nfunction renderServerEntryDev(routesDir: string, eagerImports: string[]): string {\n return [\n \"// Generated by @moons. Do not edit manually.\",\n 'import { createPluginRuntime, createRequestHandler } from \"@moonsjs/vite/server\";',\n 'import { renderToMarkup } from \"@moonsjs/react/ssr\";',\n 'import config from \"virtual:moons/config\";',\n 'import { routes, loadRoute } from \"virtual:moons/routes\";',\n 'import { apiRoutes, apiMiddlewares, loadApi, loadApiMiddleware } from \"virtual:moons/api\";',\n ...eagerImports.map((specifier) => `import ${JSON.stringify(specifier)};`),\n \"\",\n \"export function createDevApp(shell, payloadScan) {\",\n \" const plugins = createPluginRuntime({ config, routes, middlewares: config.middleware ?? [] });\",\n ` const handler = createRequestHandler({ routes, apiRoutes, apiMiddlewares, loadApi, loadApiMiddleware, config, routesDir: ${JSON.stringify(routesDir)}, loadRoute, shell, renderer: async () => renderToMarkup, onContext: (ctx) => plugins.applyExtensions(ctx), ...(payloadScan === undefined ? {} : { payloadScan }) });`,\n \" return { handler, plugins };\",\n \"}\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction renderServerEntryBuild(\n routesDir: string,\n eagerImports: string[],\n canary: string | undefined,\n): string {\n return [\n \"// Generated by @moons. Do not edit manually.\",\n 'import { createFileShell, createPluginRuntime, createRequestHandler, startServer } from \"@moonsjs/vite/server\";',\n 'import { renderToMarkup } from \"@moonsjs/react/ssr\";',\n 'import config from \"virtual:moons/config\";',\n 'import { routes, loadRoute } from \"virtual:moons/routes\";',\n 'import { apiRoutes, apiMiddlewares, loadApi, loadApiMiddleware } from \"virtual:moons/api\";',\n ...eagerImports.map((specifier) => `import ${JSON.stringify(specifier)};`),\n \"\",\n \"const plugins = createPluginRuntime({ config, routes, middlewares: config.middleware ?? [] });\",\n \"const handler = createRequestHandler({\",\n \" routes,\",\n \" apiRoutes,\",\n \" apiMiddlewares,\",\n \" loadApi,\",\n \" loadApiMiddleware,\",\n \" config,\",\n ` routesDir: ${JSON.stringify(routesDir)},`,\n \" loadRoute,\",\n \" shell: createFileShell(),\",\n \" renderer: async () => renderToMarkup,\",\n \" onContext: (ctx) => plugins.applyExtensions(ctx),\",\n \"});\",\n \"\",\n `startServer(handler, { plugins, headers: config.headers, storage: config.isr?.storage, trustProxy: config.security?.trustProxy, bodyLimitBytes: config.security?.bodyLimitBytes, logging: config.logging, trailingSlash: config.trailingSlash${canary === undefined ? \"\" : `, canary: ${JSON.stringify(canary)}`} });`,\n \"\",\n ].join(\"\\n\");\n}\n\ninterface ModuleGraphLike {\n getModulesByFile(file: string): Iterable<{ id?: string | null }> | undefined;\n invalidateModule(module: unknown): void;\n}\n\n/** Entry D.5: runner prerender (dijalankan CLI setelah build server). */\nfunction renderPrerenderEntry(\n routesDir: string,\n projectRoot: string,\n canary: string | undefined,\n): string {\n return [\n \"// Generated by @moons. Do not edit manually.\",\n 'import { createFileShell, createRequestHandler, runPrerender } from \"@moonsjs/vite/server\";',\n 'import { renderToMarkup } from \"@moonsjs/react/ssr\";',\n 'import config from \"virtual:moons/config\";',\n 'import { routes, loadRoute } from \"virtual:moons/routes\";',\n \"\",\n \"const handler = createRequestHandler({\",\n \" routes,\",\n \" config,\",\n ` routesDir: ${JSON.stringify(routesDir)},`,\n \" loadRoute,\",\n \" shell: createFileShell(),\",\n \" renderer: async () => renderToMarkup,\",\n \"});\",\n \"\",\n \"await runPrerender({\",\n \" routes,\",\n ` routesDir: ${JSON.stringify(routesDir)},`,\n \" loadRoute,\",\n \" handler,\",\n \" staticConfig: config,\",\n ` clientDir: ${JSON.stringify(resolvePath(projectRoot, \"dist/client\"))},`,\n ...(canary === undefined ? [] : [` canary: ${JSON.stringify(canary)},`]),\n \"});\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction environmentName(context: unknown): string {\n const environment = (context as { environment?: { name?: string } } | undefined)?.environment;\n return environment?.name ?? \"client\";\n}\n\nfunction invalidateVirtualModules(server: ViteDevServer): void {\n const graphs: ModuleGraphLike[] = [server.moduleGraph as unknown as ModuleGraphLike];\n const environments = (server as unknown as { environments?: Record<string, { moduleGraph?: unknown }> })\n .environments;\n if (environments !== undefined) {\n for (const environment of Object.values(environments)) {\n if (environment.moduleGraph !== undefined) {\n graphs.push(environment.moduleGraph as ModuleGraphLike);\n }\n }\n }\n\n for (const graph of graphs) {\n for (const name of Object.values(VIRTUAL_MODULES)) {\n for (const module of graph.getModulesByFile(`\\0${name}`) ?? []) {\n graph.invalidateModule(module);\n }\n }\n }\n}\n",
|
|
5
|
+
"import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { createHash } from \"node:crypto\";\nimport { relative as relativePath, resolve as resolvePath } from \"node:path\";\nimport {\n MOONS_VERSION,\n MoonsError,\n fnRegistryKey,\n generateTypes,\n scanApiMiddlewares,\n scanApiRoutes,\n scanRoutes,\n validateConfig,\n type ApiMiddlewareDefinition,\n type ApiRouteDefinition,\n type RouteDefinition,\n} from \"@moonsjs/core\";\nimport { loadConfigFromFile, type Plugin, type ViteDevServer } from \"vite\";\nimport { assertApiModuleExports, assertMiddlewareExports } from \"./api\";\nimport { findLeak } from \"./leak-check\";\nimport type { PackageJsonInfo } from \"./server-only\";\nimport { renderApiModule, renderRoutesModule, rootSpecifier } from \"./manifest\";\nimport { installDevMiddleware } from \"./server/dev\";\nimport {\n analyzeServerFile,\n checkClientModuleImports,\n checkRouteModuleExports,\n injectServerFnMeta,\n isNonContractServerFile,\n isServerFilePath,\n nonContractServerFileError,\n renderServerFnStub,\n resolveServerSpecifierSync,\n scanServerFiles,\n stripQuery,\n type ServerFileAnalysis,\n} from \"./transform\";\nimport { fromNullPrefixed, VIRTUAL_MODULES } from \"./virtual-modules\";\n\nexport interface MoonsVitePluginOptions {\n /** Default: \"moons.config.ts\". */\n configPath?: string;\n /** Hanya dipakai di CI (M2 §21). */\n leakTest?: { canary?: string };\n /** Default: root Vite. */\n projectRoot?: string;\n}\n\n/**\n * Plugin `@moonsjs/vite` (PRD §9): scan route, typegen, virtual module,\n * dev SSR middleware, build client + server.\n */\nconst CODE_FILE_PATTERN = /\\.(ts|tsx|js|jsx|mjs|cjs|mts|cts)$/;\n\nexport default function moons(options: MoonsVitePluginOptions = {}): Plugin {\n let root = options.projectRoot ?? process.cwd();\n let isSsrBuild = false;\n let configFilePath = \"\";\n let routesDir = \"\";\n let serverOnlyPackages: ReadonlyArray<string> = [];\n // Addendum J.1/J.2: paritas dev & produksi (paritas E7).\n let trustProxy = false;\n let bodyLimitBytes: number | undefined;\n let requestTimeoutMs: number | undefined;\n let apiDir = \"\";\n let apiRoutes: ApiRouteDefinition[] = [];\n let apiMiddlewares: ApiMiddlewareDefinition[] = [];\n /** Cache package.json untuk gate Addendum C (dibagi lintas modul). */\n const packageCache = new Map<string, PackageJsonInfo | null>(); let routes: RouteDefinition[] = [];\n let analysisCache = new Map<string, ServerFileAnalysis>();\n const stubTransformed = new Set<string>();\n\n function analyzeFile(absoluteFile: string): ServerFileAnalysis | null {\n const cached = analysisCache.get(absoluteFile);\n if (cached !== undefined) {\n return cached;\n }\n let source: string;\n try {\n source = readFileSync(absoluteFile, \"utf8\");\n } catch {\n return null;\n }\n const analysis = analyzeServerFile(source, absoluteFile, root);\n analysisCache.set(absoluteFile, analysis);\n return analysis;\n }\n\n function refreshServerFns(): void {\n const next = new Map<string, ServerFileAnalysis>();\n const registry: Record<string, string> = {};\n\n for (const file of scanServerFiles(root)) {\n let source: string;\n try {\n source = readFileSync(file, \"utf8\");\n } catch {\n continue;\n }\n const analysis = analyzeServerFile(source, file, root);\n next.set(file, analysis);\n for (const fn of analysis.serverFns) {\n registry[fnRegistryKey(root, file, fn.name)] = fn.hash;\n }\n }\n\n analysisCache = next;\n const outDir = resolvePath(root, \".moons\");\n mkdirSync(outDir, { recursive: true });\n writeFileSync(\n resolvePath(outDir, \"fn-registry.json\"),\n `${JSON.stringify(registry, null, 2)}\\n`,\n \"utf8\",\n );\n }\n\n /** Semua specifier file `.server.ts` yang punya serverFn (untuk eager import di entry server). */\n function serverFnFileSpecifiers(): string[] {\n const specifiers: string[] = [];\n for (const [file, analysis] of analysisCache) {\n if (analysis.serverFns.length > 0) {\n specifiers.push(rootSpecifier(root, file));\n }\n }\n return specifiers.sort();\n }\n\n /** Stub client §12.2 + cache §12.2.5. */\n function transformServerFileClient(code: string, id: string): string {\n const relativePath = id.startsWith(root)\n ? id.slice(root.length).split(\"\\\\\").join(\"/\")\n : id;\n const cacheKey = createHash(\"sha256\").update(`${relativePath}\\0${code}`).digest(\"hex\");\n const cacheFile = resolvePath(root, \".moons/cache\", `${cacheKey}.js`);\n\n if (existsSync(cacheFile)) {\n stubTransformed.add(id);\n return readFileSync(cacheFile, \"utf8\");\n }\n\n const analysis = analyzeFile(id);\n if (analysis === null) {\n throw new MoonsError({\n code: \"E_INTERNAL\",\n file: id,\n message: \"failed to read the server file for transform\",\n details: \"The `.server.ts` file must be readable during transform.\",\n suggestions: [\"Check the path and file permissions\"],\n });\n }\n\n const stub = renderServerFnStub(code, id, analysis, {\n analyzeSpecifier: (sourceFile, specifier) => {\n const resolved = resolveServerSpecifierSync(sourceFile, specifier);\n return resolved === null ? null : analyzeFile(resolved);\n },\n });\n\n mkdirSync(resolvePath(root, \".moons/cache\"), { recursive: true });\n writeFileSync(cacheFile, stub.code, \"utf8\");\n stubTransformed.add(id);\n return stub.code;\n }\n\n return {\n name: \"moons\",\n enforce: \"pre\",\n\n config(_config, env) {\n isSsrBuild = env.isSsrBuild === true;\n const common = {\n appType: \"custom\" as const,\n };\n\n if (isSsrBuild) {\n return {\n ...common,\n build: {\n outDir: \"dist/server\",\n emptyOutDir: true,\n // Entry nyata yang di-generate saat buildStart (Rolldown butuh file,\n // entry virtual tidak di-resolve lewat plugin container).\n // D.5: dua entry — server (index) + prerender runner.\n ssr: true,\n rollupOptions: {\n input: {\n index: \".moons/server-entry.ts\",\n prerender: \".moons/prerender-entry.ts\",\n },\n output: {\n entryFileNames: \"[name].js\",\n chunkFileNames: \"chunks/[name]-[hash].js\",\n },\n },\n },\n ssr: { noExternal: true, target: \"node\" as const },\n };\n }\n\n return {\n ...common,\n build: { outDir: \"dist/client\", emptyOutDir: true },\n // Dev SSR: paket framework WAJIB di-inline ke pipeline Vite. Sejak\n // dipublikasikan, `@moonsjs/*` adalah package node_modules biasa (bukan\n // workspace-link) sehingga default Vite mengeksternalnya; import runtime\n // (bun) menyelesaikannya lewat kondisi `bun` → `src`, sedangkan modul\n // route diselesaikan Vite → `dist` — dua instans React context →\n // \"useLoaderData dipanggil di luar render route\" (temuan eval T4;\n // docs/decisions/0015). Inline → semua konsisten lewat Vite.\n ssr: { noExternal: [/^@moonsjs\\//] },\n };\n },\n\n async configResolved(resolved) {\n root = options.projectRoot ?? resolved.root;\n configFilePath = resolvePath(root, options.configPath ?? \"moons.config.ts\");\n\n if (!existsSync(configFilePath)) {\n throw new MoonsError({\n code: \"E_CONFIG_INVALID\",\n file: configFilePath,\n message: \"`moons.config.ts` not found\",\n details: \"The framework requires a config file at the project root.\",\n suggestions: [\n \"Create `moons.config.ts` with `export default defineConfig({ context: async (req) => ({}) })`\",\n ],\n });\n }\n\n let raw: unknown;\n try {\n const loaded = await loadConfigFromFile(\n { command: resolved.command, mode: resolved.mode },\n configFilePath,\n root,\n );\n raw = loaded?.config;\n } catch (error) {\n if (error instanceof MoonsError) {\n throw error;\n }\n throw new MoonsError({\n code: \"E_CONFIG_INVALID\",\n file: configFilePath,\n message: \"failed to load `moons.config.ts`\",\n details: error instanceof Error ? error.message : String(error),\n suggestions: [\"Check the syntax and imports in `moons.config.ts`\"],\n });\n }\n\n const config = validateConfig(raw, { file: configFilePath, projectRoot: root });\n routesDir = resolvePath(root, config.routesDir);\n serverOnlyPackages = config.security?.serverOnlyPackages ?? [];\n trustProxy = config.security?.trustProxy === true;\n bodyLimitBytes = config.security?.bodyLimitBytes;\n requestTimeoutMs = config.requestTimeoutMs;\n\n // Addendum D.1: scan + validasi statis modul `src/api`.\n apiDir = resolvePath(root, config.apiDir ?? \"src/api\");\n if (existsSync(apiDir)) {\n apiRoutes = scanApiRoutes(apiDir);\n for (const route of apiRoutes) {\n assertApiModuleExports(readFileSync(route.file, \"utf8\"), route.file);\n }\n apiMiddlewares = scanApiMiddlewares(apiDir);\n for (const middleware of apiMiddlewares) {\n assertMiddlewareExports(readFileSync(middleware.file, \"utf8\"), middleware.file);\n }\n } else {\n apiRoutes = [];\n apiMiddlewares = [];\n }\n },\n\n async buildStart() {\n routes = scanRoutes(routesDir);\n // D.3: validasi statis `_middleware.ts` pohon routes.\n for (const middleware of routes.filter((route) => route.kind === \"middleware\")) {\n assertMiddlewareExports(readFileSync(middleware.file, \"utf8\"), middleware.file);\n }\n await generateTypes({\n routesDir,\n configPath: configFilePath,\n outDir: resolvePath(root, \".moons\"),\n });\n refreshServerFns();\n if (isSsrBuild) {\n writeFileSync(\n resolvePath(root, \".moons/server-entry.ts\"),\n renderServerEntryBuild(routesDir, serverFnFileSpecifiers(), options.leakTest?.canary),\n \"utf8\",\n );\n writeFileSync(\n resolvePath(root, \".moons/prerender-entry.ts\"),\n renderPrerenderEntry(routesDir, root, options.leakTest?.canary),\n \"utf8\",\n );\n }\n },\n\n resolveId(id) {\n const clean = id.startsWith(\"\\0\") ? id.slice(1) : id;\n if ((Object.values(VIRTUAL_MODULES) as string[]).includes(clean)) {\n return `\\0${clean}`;\n }\n return undefined;\n },\n\n load(id) {\n const name = fromNullPrefixed(id);\n if (name === null) {\n return undefined;\n }\n switch (name) {\n case VIRTUAL_MODULES.routes:\n return renderRoutesModule(routes, routesDir, root);\n case VIRTUAL_MODULES.api:\n return renderApiModule(apiRoutes, apiMiddlewares, root);\n case VIRTUAL_MODULES.clientEntry:\n return '// Generated by @moons. Do not edit manually.\\nexport { clientManifest, loadRoute } from \"virtual:moons/routes\";\\n';\n case VIRTUAL_MODULES.config:\n return renderConfigModule(root, configFilePath);\n case VIRTUAL_MODULES.serverEntry:\n // Hanya dipakai dev (ssrLoadModule); build memakai .moons/server-entry.ts.\n return renderServerEntryDev(routesDir, serverFnFileSpecifiers());\n }\n },\n\n async transform(code, id) {\n const cleanId = stripQuery(id);\n if (cleanId.startsWith(\"\\0\") || cleanId.includes(\"/node_modules/\")) {\n return undefined;\n }\n\n const environment = environmentName(this);\n\n if (isServerFilePath(cleanId)) {\n if (environment === \"ssr\") {\n const analysis = analysisCache.get(cleanId) ?? analyzeFile(cleanId);\n if (analysis === null || analysis.serverFns.length === 0) {\n return undefined;\n }\n return injectServerFnMeta(code, analysis, root);\n }\n return transformServerFileClient(code, cleanId);\n }\n\n // Audit ronde 2: file server di luar kontrak §12 tidak bisa di-stub —\n // jangan pernah biarkan masuk graph client.\n if (environment !== \"ssr\" && isNonContractServerFile(cleanId)) {\n throw nonContractServerFileError(cleanId, root);\n }\n\n if (environment !== \"ssr\" && CODE_FILE_PATTERN.test(cleanId)) {\n if (cleanId.startsWith(routesDir) && cleanId.endsWith(\".tsx\")) {\n checkRouteModuleExports({\n file: cleanId,\n code,\n routesDir,\n projectRoot: root,\n });\n }\n await checkClientModuleImports({\n file: cleanId,\n code,\n projectRoot: root,\n // Resolusi penuh (alias Vite, tsconfig paths, symlink) — audit ronde 2.\n resolve: async (specifier, importer) => {\n try {\n const resolved = await this.resolve(specifier, importer);\n return resolved === null ? null : stripQuery(resolved.id);\n } catch {\n return null;\n }\n },\n analyze: (absoluteFile) => analysisCache.get(absoluteFile) ?? analyzeFile(absoluteFile),\n apiDir,\n configFile: configFilePath,\n serverDir: resolvePath(root, \"src/server\"),\n serverOnlyPackages,\n packageCache,\n });\n }\n\n return undefined;\n },\n\n generateBundle(_options, bundle) {\n if (environmentName(this) === \"ssr\") {\n return;\n }\n\n const canary = options.leakTest?.canary;\n if (canary !== undefined && canary.length > 0) {\n const leak = findLeak(Object.values(bundle), canary);\n if (leak !== null) {\n throw new MoonsError({\n code: \"E_INTERNAL\",\n message: `canary \\`${canary}\\` found in the client bundle (${leak.fileName})`,\n details:\n \"Leak verification failed: server code leaked into the client output. Build stopped.\",\n suggestions: [\n \"Check the `*.server.ts` transform\",\n \"Run `./scripts/m2/test-leak.sh` to audit\",\n ],\n });\n }\n }\n\n for (const output of Object.values(bundle)) {\n if (output.type !== \"chunk\") {\n continue;\n }\n for (const moduleId of Object.keys(output.modules)) {\n const cleanId = stripQuery(moduleId);\n if (!isServerFilePath(cleanId) || stubTransformed.has(cleanId)) {\n continue;\n }\n throw new MoonsError({\n code: \"E_FORBIDDEN_SERVER_IMPORT\",\n file: cleanId,\n message: \"server module got bundled into the client without passing through the transform\",\n details:\n \"Build verification: every `*.server.ts` in the client bundle must be an RPC stub produced by the transform.\",\n suggestions: [\n \"Make sure the zero-trust transform runs for this module\",\n \"If this repeats, report it as a framework bug\",\n ],\n });\n }\n }\n },\n\n configureServer(server) {\n installDevMiddleware(server, {\n templatePath: resolvePath(root, \"index.html\"),\n // Addendum I.4 (W4): overlay devtools — data segar per request.\n devtools: () => {\n const toRelative = (file: string): string =>\n file.startsWith(root) ? relativePath(root, file).split(\"\\\\\").join(\"/\") : file;\n return {\n routes: [...routes]\n .sort((a, b) => a.path.localeCompare(b.path) || a.kind.localeCompare(b.kind))\n .map((route) => ({ path: route.path, kind: route.kind, file: toRelative(route.file) })),\n apiRoutes: [...apiRoutes]\n .sort((a, b) => a.path.localeCompare(b.path))\n .map((route) => ({ path: route.path, kind: \"api\", file: toRelative(route.file) })),\n serverFns: [...analysisCache.values()]\n .flatMap((analysis) =>\n analysis.serverFns.map((fn) => ({\n file: toRelative(analysis.file),\n name: fn.name,\n hash: fn.hash,\n })),\n )\n .sort((a, b) => a.file.localeCompare(b.file) || a.name.localeCompare(b.name)),\n canary: options.leakTest?.canary !== undefined,\n version: MOONS_VERSION,\n };\n },\n // A1: pemindaian payload SSR hanya di dev (warning), tanpa biaya di production.\n payloadScan: {\n ...(options.leakTest?.canary === undefined ? {} : { canary: options.leakTest.canary }),\n env: process.env,\n },\n // D.1: request ke prefix API (semua method) dirutekan ke runtime.\n ...(apiRoutes.length === 0\n ? {}\n : { apiPrefix: `/${apiDir.split(/[\\\\/]/).filter((part) => part.length > 0).pop() ?? \"api\"}` }),\n trustProxy,\n ...(bodyLimitBytes === undefined ? {} : { bodyLimitBytes }),\n ...(requestTimeoutMs === undefined ? {} : { requestTimeoutMs }),\n });\n server.config.logger.info(\"[moons] devtools: /__moons/devtools\");\n },\n\n async handleHotUpdate(context) {\n if (isServerFilePath(context.file)) {\n refreshServerFns();\n context.server.ws.send({ type: \"full-reload\" });\n return;\n }\n\n if (context.file.startsWith(apiDir) && existsSync(apiDir)) {\n try {\n apiRoutes = scanApiRoutes(apiDir);\n for (const route of apiRoutes) {\n assertApiModuleExports(readFileSync(route.file, \"utf8\"), route.file);\n }\n apiMiddlewares = scanApiMiddlewares(apiDir);\n for (const middleware of apiMiddlewares) {\n assertMiddlewareExports(readFileSync(middleware.file, \"utf8\"), middleware.file);\n }\n } catch (error) {\n context.server.config.logger.error(String(error));\n return;\n }\n invalidateVirtualModules(context.server);\n context.server.ws.send({ type: \"full-reload\" });\n return;\n }\n\n if (!context.file.startsWith(routesDir)) {\n return;\n }\n\n try {\n routes = scanRoutes(routesDir);\n for (const middleware of routes.filter((route) => route.kind === \"middleware\")) {\n assertMiddlewareExports(readFileSync(middleware.file, \"utf8\"), middleware.file);\n }\n await generateTypes({\n routesDir,\n configPath: configFilePath,\n outDir: resolvePath(root, \".moons\"),\n });\n } catch (error) {\n context.server.config.logger.error(String(error));\n return;\n }\n\n invalidateVirtualModules(context.server);\n context.server.ws.send({ type: \"full-reload\" });\n },\n };\n}\n\nfunction renderConfigModule(root: string, configFilePath: string): string {\n return [\n \"// Generated by @moons. Do not edit manually.\",\n `import raw from ${JSON.stringify(rootSpecifier(root, configFilePath))};`,\n 'import { validateConfig } from \"@moonsjs/core\";',\n `export default validateConfig(raw, { file: ${JSON.stringify(configFilePath)} });`,\n \"\",\n ].join(\"\\n\");\n}\n\nfunction renderServerEntryDev(routesDir: string, eagerImports: string[]): string {\n return [\n \"// Generated by @moons. Do not edit manually.\",\n 'import { createPluginRuntime, createRequestHandler } from \"@moonsjs/vite/server\";',\n 'import { renderToMarkup } from \"@moonsjs/react/ssr\";',\n 'import config from \"virtual:moons/config\";',\n 'import { routes, loadRoute } from \"virtual:moons/routes\";',\n 'import { apiRoutes, apiMiddlewares, loadApi, loadApiMiddleware } from \"virtual:moons/api\";',\n ...eagerImports.map((specifier) => `import ${JSON.stringify(specifier)};`),\n \"\",\n \"export function createDevApp(shell, payloadScan) {\",\n \" const plugins = createPluginRuntime({ config, routes, middlewares: config.middleware ?? [] });\",\n ` const handler = createRequestHandler({ routes, apiRoutes, apiMiddlewares, loadApi, loadApiMiddleware, config, routesDir: ${JSON.stringify(routesDir)}, loadRoute, shell, renderer: async () => renderToMarkup, onContext: (ctx) => plugins.applyExtensions(ctx), ...(payloadScan === undefined ? {} : { payloadScan }) });`,\n \" return { handler, plugins };\",\n \"}\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction renderServerEntryBuild(\n routesDir: string,\n eagerImports: string[],\n canary: string | undefined,\n): string {\n return [\n \"// Generated by @moons. Do not edit manually.\",\n 'import { createFileShell, createPluginRuntime, createRequestHandler, startServer } from \"@moonsjs/vite/server\";',\n 'import { renderToMarkup } from \"@moonsjs/react/ssr\";',\n 'import config from \"virtual:moons/config\";',\n 'import { routes, loadRoute } from \"virtual:moons/routes\";',\n 'import { apiRoutes, apiMiddlewares, loadApi, loadApiMiddleware } from \"virtual:moons/api\";',\n ...eagerImports.map((specifier) => `import ${JSON.stringify(specifier)};`),\n \"\",\n \"const plugins = createPluginRuntime({ config, routes, middlewares: config.middleware ?? [] });\",\n \"const handler = createRequestHandler({\",\n \" routes,\",\n \" apiRoutes,\",\n \" apiMiddlewares,\",\n \" loadApi,\",\n \" loadApiMiddleware,\",\n \" config,\",\n ` routesDir: ${JSON.stringify(routesDir)},`,\n \" loadRoute,\",\n \" shell: createFileShell(),\",\n \" renderer: async () => renderToMarkup,\",\n \" onContext: (ctx) => plugins.applyExtensions(ctx),\",\n \"});\",\n \"\",\n `startServer(handler, { plugins, headers: config.headers, storage: config.isr?.storage, trustProxy: config.security?.trustProxy, bodyLimitBytes: config.security?.bodyLimitBytes, requestTimeoutMs: config.requestTimeoutMs, logging: config.logging, trailingSlash: config.trailingSlash${canary === undefined ? \"\" : `, canary: ${JSON.stringify(canary)}`} });`,\n \"\",\n ].join(\"\\n\");\n}\n\ninterface ModuleGraphLike {\n getModulesByFile(file: string): Iterable<{ id?: string | null }> | undefined;\n invalidateModule(module: unknown): void;\n}\n\n/** Entry D.5: runner prerender (dijalankan CLI setelah build server). */\nfunction renderPrerenderEntry(\n routesDir: string,\n projectRoot: string,\n canary: string | undefined,\n): string {\n return [\n \"// Generated by @moons. Do not edit manually.\",\n 'import { createFileShell, createRequestHandler, runPrerender } from \"@moonsjs/vite/server\";',\n 'import { renderToMarkup } from \"@moonsjs/react/ssr\";',\n 'import config from \"virtual:moons/config\";',\n 'import { routes, loadRoute } from \"virtual:moons/routes\";',\n \"\",\n \"const handler = createRequestHandler({\",\n \" routes,\",\n \" config,\",\n ` routesDir: ${JSON.stringify(routesDir)},`,\n \" loadRoute,\",\n \" shell: createFileShell(),\",\n \" renderer: async () => renderToMarkup,\",\n \"});\",\n \"\",\n \"await runPrerender({\",\n \" routes,\",\n ` routesDir: ${JSON.stringify(routesDir)},`,\n \" loadRoute,\",\n \" handler,\",\n \" staticConfig: config,\",\n ` clientDir: ${JSON.stringify(resolvePath(projectRoot, \"dist/client\"))},`,\n ...(canary === undefined ? [] : [` canary: ${JSON.stringify(canary)},`]),\n \"});\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction environmentName(context: unknown): string {\n const environment = (context as { environment?: { name?: string } } | undefined)?.environment;\n return environment?.name ?? \"client\";\n}\n\nfunction invalidateVirtualModules(server: ViteDevServer): void {\n const graphs: ModuleGraphLike[] = [server.moduleGraph as unknown as ModuleGraphLike];\n const environments = (server as unknown as { environments?: Record<string, { moduleGraph?: unknown }> })\n .environments;\n if (environments !== undefined) {\n for (const environment of Object.values(environments)) {\n if (environment.moduleGraph !== undefined) {\n graphs.push(environment.moduleGraph as ModuleGraphLike);\n }\n }\n }\n\n for (const graph of graphs) {\n for (const name of Object.values(VIRTUAL_MODULES)) {\n for (const module of graph.getModulesByFile(`\\0${name}`) ?? []) {\n graph.invalidateModule(module);\n }\n }\n }\n}\n",
|
|
6
6
|
"import { parse } from \"@babel/parser\";\nimport { API_METHODS, MoonsError } from \"@moonsjs/core\";\n\n/**\n * Validasi statis export modul `src/api` (PRD Addendum D.1):\n * hanya handler method `GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS` sebagai fungsi;\n * `default`/export lain ditolak → `E_API_HANDLER_INVALID`.\n */\nexport function assertApiModuleExports(code: string, file: string): string[] {\n let ast: unknown;\n try {\n ast = parse(code, {\n sourceType: \"module\",\n plugins: file.endsWith(\".tsx\") ? [\"typescript\", \"jsx\"] : [\"typescript\"],\n });\n } catch {\n return []; // biarkan bundler melaporkan syntax error\n }\n\n const program = (ast as { program?: { body?: Array<Record<string, unknown>> } }).program;\n const body = program?.body ?? [];\n const methods: string[] = [];\n\n for (const statement of body) {\n if (statement[\"type\"] === \"ExportDefaultDeclaration\") {\n throw apiError(\n file,\n \"export `default` is not supported in API modules\",\n \"`src/api` modules only export named method handlers.\",\n [\"Replace it with `export const GET = (args) => …`\", \"Remove the default export\"],\n );\n }\n if (statement[\"type\"] !== \"ExportNamedDeclaration\") {\n continue;\n }\n if (statement[\"source\"] !== undefined) {\n // re-export `export { X } from \"...\"` — nama tetap dicek di bawah.\n }\n const declaration = statement[\"declaration\"] as Record<string, unknown> | undefined;\n if (declaration !== undefined) {\n if (declaration[\"type\"] === \"VariableDeclaration\") {\n for (const declarator of (declaration[\"declarations\"] ?? []) as Array<Record<string, unknown>>) {\n const id = declarator[\"id\"] as Record<string, unknown> | undefined;\n if (id?.[\"type\"] === \"Identifier\") {\n methods.push(id[\"name\"] as string);\n }\n }\n } else if (declaration[\"type\"] === \"FunctionDeclaration\") {\n const id = declaration[\"id\"] as Record<string, unknown> | undefined;\n if (id?.[\"type\"] === \"Identifier\") {\n methods.push(id[\"name\"] as string);\n }\n }\n continue;\n }\n for (const specifier of (statement[\"specifiers\"] ?? []) as Array<Record<string, unknown>>) {\n const exported = specifier[\"exported\"] as Record<string, unknown> | undefined;\n if (exported?.[\"type\"] === \"Identifier\") {\n methods.push(exported[\"name\"] as string);\n }\n }\n }\n\n const illegal = methods.filter((name) => !API_METHODS.includes(name as never));\n if (illegal.length > 0) {\n throw apiError(\n file,\n `export \\`${illegal[0]}\\` is not a recognized method handler`,\n `Legal handlers: ${API_METHODS.join(\", \")}.`,\n [\n \"Rename the export to one of the HTTP methods\",\n \"Move helpers to another module (e.g. `src/server/…`)\",\n ],\n );\n }\n if (methods.length === 0) {\n throw apiError(\n file,\n \"API module has no method handler\",\n `At least one of ${API_METHODS.join(\", \")} is required.`,\n [\"Add `export const GET = (args) => new Response(…)`\"],\n );\n }\n\n return methods;\n}\n\nexport function assertMiddlewareExports(code: string, file: string): void {\n let ast: unknown;\n try {\n ast = parse(code, {\n sourceType: \"module\",\n plugins: file.endsWith(\".tsx\") ? [\"typescript\", \"jsx\"] : [\"typescript\"],\n });\n } catch {\n return;\n }\n const program = (ast as { program?: { body?: Array<Record<string, unknown>> } }).program;\n const hasDefault = (program?.body ?? []).some(\n (statement) => statement[\"type\"] === \"ExportDefaultDeclaration\",\n );\n if (!hasDefault) {\n throw new MoonsError({\n code: \"E_MIDDLEWARE_INVALID\",\n file,\n message: \"`_middleware.ts` without `export default`\",\n details: \"Directory middleware follows the `Middleware` shape: `(args) => Promise<Response>`.\",\n suggestions: [\n \"Add `export default async ({ req, ctx, next }) => await next()`\",\n \"Delete the file if unused\",\n ],\n });\n }\n}\n\nfunction apiError(file: string, message: string, details: string, suggestions: string[]): MoonsError {\n return new MoonsError({\n code: \"E_API_HANDLER_INVALID\",\n file,\n message,\n details,\n suggestions,\n });\n}\n",
|
|
7
7
|
"export interface BundleOutputLike {\n type: string;\n fileName?: string;\n code?: string;\n source?: string | Uint8Array;\n}\n\n/**\n * §9.1 (`leakTest.canary`) / §10.4: cari canary pada output bundle client.\n * Dipakai `generateBundle` plugin — build gagal bila canary ditemukan.\n */\nexport function findLeak(\n outputs: Iterable<BundleOutputLike>,\n canary: string,\n decode: (source: Uint8Array) => string = defaultDecode,\n): { fileName: string } | null {\n for (const output of outputs) {\n const fileName = output.fileName ?? \"(unknown)\";\n let text = \"\";\n if (typeof output.code === \"string\") {\n text = output.code;\n } else if (typeof output.source === \"string\") {\n text = output.source;\n } else if (output.source instanceof Uint8Array) {\n text = decode(output.source);\n }\n if (text.includes(canary)) {\n return { fileName };\n }\n }\n return null;\n}\n\nfunction defaultDecode(bytes: Uint8Array): string {\n return new TextDecoder().decode(bytes);\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA,qBAAS,yBAA0B;AACnC;AAAA;AAAA,gBAEE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWF;;;AChBA;AACA;AAOO,SAAS,sBAAsB,CAAC,MAAc,MAAwB;AAAA,EAC3E,IAAI;AAAA,EACJ,IAAI;AAAA,IACF,MAAM,MAAM,MAAM;AAAA,MAChB,YAAY;AAAA,MACZ,SAAS,KAAK,SAAS,MAAM,IAAI,CAAC,cAAc,KAAK,IAAI,CAAC,YAAY;AAAA,IACxE,CAAC;AAAA,IACD,MAAM;AAAA,IACN,OAAO,CAAC;AAAA;AAAA,EAG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;",
|
|
10
|
+
"debugId": "98E21A7B0433EF9A64756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAsB,KAAK,MAAM,EAAsB,MAAM,MAAM,CAAC;AAsB3E,MAAM,WAAW,sBAAsB;IACrC,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,QAAQ,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAQD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,OAAO,GAAE,sBAA2B,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAsB,KAAK,MAAM,EAAsB,MAAM,MAAM,CAAC;AAsB3E,MAAM,WAAW,sBAAsB;IACrC,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,QAAQ,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAQD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,OAAO,GAAE,sBAA2B,GAAG,MAAM,CAud1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bun-server.d.ts","sourceRoot":"","sources":["../../src/server/bun-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bun-server.d.ts","sourceRoot":"","sources":["../../src/server/bun-server.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGvD;;;;;GAKG;AAEH,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,sBAAsB,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD;AA4ID;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,EAChD,OAAO,GAAE,iBAAsB,GAC9B,eAAe,CA6PjB"}
|
package/dist/server/dev.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export declare function installDevMiddleware(server: ViteDevServer, options: {
|
|
|
13
13
|
/** Addendum J.1: paritas dev dengan produksi (trustProxy/bodyLimitBytes). */
|
|
14
14
|
trustProxy?: boolean;
|
|
15
15
|
bodyLimitBytes?: number;
|
|
16
|
+
/** Addendum R: batas waktu respons (ms); 0/undefined = tanpa batas. */
|
|
17
|
+
requestTimeoutMs?: number;
|
|
16
18
|
/** Addendum I.4: datasource devtools overlay (dipanggil per request). */
|
|
17
19
|
devtools?: () => DevtoolsData;
|
|
18
20
|
}): void;
|
package/dist/server/dev.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/server/dev.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/server/dev.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAkB1D,OAAO,EAAyC,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAcvF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE;IACP,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,YAAY,CAAC;CAC/B,GACA,IAAI,CA4DN"}
|
package/dist/server/index.js
CHANGED
|
@@ -19,6 +19,11 @@ import {
|
|
|
19
19
|
gzipCached,
|
|
20
20
|
acceptsGzipHeader,
|
|
21
21
|
rpcBodyTooLargeText,
|
|
22
|
+
RequestTimeoutError,
|
|
23
|
+
requestTimeoutText,
|
|
24
|
+
runHandlerWithTimeout,
|
|
25
|
+
isAbortLike,
|
|
26
|
+
textResponseWithHeaders,
|
|
22
27
|
applyStaticHeaders,
|
|
23
28
|
readBodyWithLimit,
|
|
24
29
|
resolveStaticFile2,
|
|
@@ -29,7 +34,7 @@ import {
|
|
|
29
34
|
toWebRequest2,
|
|
30
35
|
sendNodeResponse2,
|
|
31
36
|
installDevMiddleware2
|
|
32
|
-
} from "../index-
|
|
37
|
+
} from "../index-sdm38v1p.js";
|
|
33
38
|
|
|
34
39
|
// src/server/handler.ts
|
|
35
40
|
import {
|
|
@@ -559,7 +564,17 @@ var MIME = {
|
|
|
559
564
|
".png": "image/png",
|
|
560
565
|
".webp": "image/webp",
|
|
561
566
|
".woff": "font/woff",
|
|
562
|
-
".woff2": "font/woff2"
|
|
567
|
+
".woff2": "font/woff2",
|
|
568
|
+
".xml": "application/xml; charset=utf-8",
|
|
569
|
+
".csv": "text/csv; charset=utf-8",
|
|
570
|
+
".md": "text/markdown; charset=utf-8",
|
|
571
|
+
".pdf": "application/pdf",
|
|
572
|
+
".mp4": "video/mp4",
|
|
573
|
+
".webm": "video/webm",
|
|
574
|
+
".mp3": "audio/mpeg",
|
|
575
|
+
".wav": "audio/wav",
|
|
576
|
+
".zip": "application/zip",
|
|
577
|
+
".gz": "application/gzip"
|
|
563
578
|
};
|
|
564
579
|
|
|
565
580
|
// src/server/logger.ts
|
|
@@ -682,7 +697,7 @@ function startNodeServer(handler, options = {}) {
|
|
|
682
697
|
} catch (error) {
|
|
683
698
|
if (error instanceof InvalidRequestError) {
|
|
684
699
|
console.warn(`[moons] ${error.message} — 400`);
|
|
685
|
-
|
|
700
|
+
respondText(res, 400, "Bad Request", options.headers);
|
|
686
701
|
return;
|
|
687
702
|
}
|
|
688
703
|
throw error;
|
|
@@ -700,7 +715,17 @@ function startNodeServer(handler, options = {}) {
|
|
|
700
715
|
}
|
|
701
716
|
if (req.method === "GET" || req.method === "HEAD") {
|
|
702
717
|
if (options.storage !== undefined) {
|
|
703
|
-
|
|
718
|
+
let entry = null;
|
|
719
|
+
try {
|
|
720
|
+
entry = await options.storage.read(url.pathname);
|
|
721
|
+
} catch (error) {
|
|
722
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
723
|
+
if (accessLogger !== null) {
|
|
724
|
+
accessLogger({ msg: "isr:storage-read-failed", level: "warn", path: url.pathname, error: message });
|
|
725
|
+
} else {
|
|
726
|
+
console.warn(`[moons] isr storage read failed (${url.pathname}): ${message} — falling back to dist/client`);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
704
729
|
if (entry !== null) {
|
|
705
730
|
scheduleRevalidation({
|
|
706
731
|
pathname: url.pathname,
|
|
@@ -762,9 +787,7 @@ function startNodeServer(handler, options = {}) {
|
|
|
762
787
|
if (isRpc) {
|
|
763
788
|
const contentLength = Number(req.headers["content-length"] ?? "0");
|
|
764
789
|
if (Number.isFinite(contentLength) && contentLength > rpcLimit) {
|
|
765
|
-
res
|
|
766
|
-
res.setHeader("content-type", "text/plain; charset=utf-8");
|
|
767
|
-
res.end(rpcBodyTooLargeText(rpcLimit, contentLength));
|
|
790
|
+
respondText(res, 413, rpcBodyTooLargeText(rpcLimit, contentLength), options.headers);
|
|
768
791
|
res.once("finish", () => req.destroy());
|
|
769
792
|
return;
|
|
770
793
|
}
|
|
@@ -773,21 +796,48 @@ function startNodeServer(handler, options = {}) {
|
|
|
773
796
|
trustProxy: options.trustProxy === true,
|
|
774
797
|
...isRpc ? { maxBodyBytes: rpcLimit } : {}
|
|
775
798
|
});
|
|
776
|
-
const response = await handler
|
|
799
|
+
const response = await runHandlerWithTimeout(handler, request, options.requestTimeoutMs);
|
|
777
800
|
await sendNodeResponse2(res, response);
|
|
778
801
|
} catch (error) {
|
|
779
802
|
if (error instanceof BodyLimitError) {
|
|
780
803
|
const isRpc = url.pathname.startsWith("/_moons/fn/");
|
|
781
|
-
res.
|
|
782
|
-
res.setHeader("content-type", "text/plain; charset=utf-8");
|
|
783
|
-
res.end(isRpc ? rpcBodyTooLargeText(error.limit, null) : "Payload Too Large");
|
|
804
|
+
respondText(res, 413, isRpc ? rpcBodyTooLargeText(error.limit, null) : "Payload Too Large", options.headers);
|
|
784
805
|
res.once("finish", () => req.destroy());
|
|
785
806
|
return;
|
|
786
807
|
}
|
|
808
|
+
if (error instanceof RequestTimeoutError) {
|
|
809
|
+
if (accessLogger !== null) {
|
|
810
|
+
accessLogger({
|
|
811
|
+
msg: "request-timeout",
|
|
812
|
+
level: "warn",
|
|
813
|
+
method: req.method ?? "GET",
|
|
814
|
+
path: url.pathname + url.search,
|
|
815
|
+
limitMs: error.limit
|
|
816
|
+
});
|
|
817
|
+
} else {
|
|
818
|
+
console.warn(`[moons] request timed out after ${error.limit}ms — ${req.method ?? "GET"} ${url.pathname}`);
|
|
819
|
+
}
|
|
820
|
+
respondText(res, 504, requestTimeoutText(error.limit), options.headers);
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
if (isAbortLike(error)) {
|
|
824
|
+
if (accessLogger !== null) {
|
|
825
|
+
accessLogger({
|
|
826
|
+
msg: "request-aborted",
|
|
827
|
+
level: "warn",
|
|
828
|
+
method: req.method ?? "GET",
|
|
829
|
+
path: url.pathname + url.search
|
|
830
|
+
});
|
|
831
|
+
} else {
|
|
832
|
+
console.warn(`[moons] request aborted by the client — ${req.method ?? "GET"} ${url.pathname}`);
|
|
833
|
+
}
|
|
834
|
+
if (!res.headersSent && !res.writableEnded) {
|
|
835
|
+
respondText(res, 499, "Client Closed Request", options.headers);
|
|
836
|
+
}
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
787
839
|
console.error("[moons] server error:", error);
|
|
788
|
-
res
|
|
789
|
-
res.setHeader("content-type", "text/plain; charset=utf-8");
|
|
790
|
-
res.end("Internal Server Error");
|
|
840
|
+
respondText(res, 500, "Internal Server Error", options.headers);
|
|
791
841
|
}
|
|
792
842
|
})();
|
|
793
843
|
});
|
|
@@ -824,16 +874,16 @@ function appendVary(res, value) {
|
|
|
824
874
|
}
|
|
825
875
|
res.setHeader("vary", value);
|
|
826
876
|
}
|
|
827
|
-
function
|
|
828
|
-
res.statusCode =
|
|
877
|
+
function respondText(res, status, text, configured) {
|
|
878
|
+
res.statusCode = status;
|
|
829
879
|
res.setHeader("content-type", "text/plain; charset=utf-8");
|
|
830
|
-
res.
|
|
880
|
+
applyStaticHeaders({ has: (name) => res.hasHeader(name), set: (name, value) => res.setHeader(name, value) }, "/", configured);
|
|
881
|
+
res.end(text);
|
|
831
882
|
}
|
|
832
883
|
// src/server/bun-server.ts
|
|
833
884
|
import { readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
|
|
834
885
|
import { extname as extname3, join as join2, resolve as resolve2 } from "node:path";
|
|
835
886
|
import { CLIENT_IP_HEADER, DEFAULT_BODY_LIMIT_BYTES as DEFAULT_BODY_LIMIT_BYTES2, trailingSlashRedirect as trailingSlashRedirect3 } from "@moonsjs/core";
|
|
836
|
-
var textResponse = (status, text) => new Response(text, { status, headers: { "content-type": "text/plain; charset=utf-8" } });
|
|
837
887
|
function appendVaryHeader(headers, value) {
|
|
838
888
|
const existing = headers.get("vary");
|
|
839
889
|
if (existing !== null && existing.length > 0) {
|
|
@@ -956,13 +1006,25 @@ function startBunServer(handler, options = {}) {
|
|
|
956
1006
|
const clientDir = resolve2(options.clientDir ?? join2(process.cwd(), "dist/client"));
|
|
957
1007
|
const port = options.port ?? Number(process.env["PORT"] ?? 3000);
|
|
958
1008
|
const trustProxy = options.trustProxy === true;
|
|
1009
|
+
const requestTimeoutMs = options.requestTimeoutMs;
|
|
1010
|
+
const idleTimeout = requestTimeoutMs === undefined || requestTimeoutMs <= 0 ? 0 : Math.ceil(requestTimeoutMs / 1000) + 5;
|
|
959
1011
|
const accessLogger = options.logging?.accessLog === true ? createLogger({
|
|
960
1012
|
json: options.logging.json !== false,
|
|
961
1013
|
redact: options.logging.redact ?? []
|
|
962
1014
|
}) : null;
|
|
963
1015
|
const serveStatic = async (request, url) => {
|
|
964
1016
|
if (options.storage !== undefined) {
|
|
965
|
-
|
|
1017
|
+
let entry = null;
|
|
1018
|
+
try {
|
|
1019
|
+
entry = await options.storage.read(url.pathname);
|
|
1020
|
+
} catch (error) {
|
|
1021
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1022
|
+
if (accessLogger !== null) {
|
|
1023
|
+
accessLogger({ msg: "isr:storage-read-failed", level: "warn", path: url.pathname, error: message });
|
|
1024
|
+
} else {
|
|
1025
|
+
console.warn(`[moons] isr storage read failed (${url.pathname}): ${message} — falling back to dist/client`);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
966
1028
|
if (entry !== null) {
|
|
967
1029
|
scheduleRevalidation({
|
|
968
1030
|
pathname: url.pathname,
|
|
@@ -1013,6 +1075,7 @@ function startBunServer(handler, options = {}) {
|
|
|
1013
1075
|
};
|
|
1014
1076
|
const server = Bun.serve({
|
|
1015
1077
|
port,
|
|
1078
|
+
idleTimeout,
|
|
1016
1079
|
fetch: async (request, bunServer) => {
|
|
1017
1080
|
const requestStartedAt = performance.now();
|
|
1018
1081
|
let url;
|
|
@@ -1021,7 +1084,7 @@ function startBunServer(handler, options = {}) {
|
|
|
1021
1084
|
} catch (error) {
|
|
1022
1085
|
if (error instanceof InvalidRequestError) {
|
|
1023
1086
|
console.warn(`[moons] ${error.message} — 400`);
|
|
1024
|
-
return
|
|
1087
|
+
return textResponseWithHeaders(400, "Bad Request", options.headers);
|
|
1025
1088
|
}
|
|
1026
1089
|
throw error;
|
|
1027
1090
|
}
|
|
@@ -1058,22 +1121,49 @@ function startBunServer(handler, options = {}) {
|
|
|
1058
1121
|
if (isRpc) {
|
|
1059
1122
|
const contentLength = Number(request.headers.get("content-length") ?? "0");
|
|
1060
1123
|
if (Number.isFinite(contentLength) && contentLength > rpcLimit) {
|
|
1061
|
-
return finish(
|
|
1124
|
+
return finish(textResponseWithHeaders(413, rpcBodyTooLargeText(rpcLimit, contentLength), options.headers));
|
|
1062
1125
|
}
|
|
1063
1126
|
}
|
|
1064
1127
|
const remoteAddress = bunServer.requestIP(request)?.address ?? null;
|
|
1065
1128
|
clientIp = resolveClientIpValues(request.headers.get("x-forwarded-for") ?? undefined, remoteAddress, trustProxy);
|
|
1066
1129
|
const needsRewrite = clientIp !== null || url.toString() !== request.url;
|
|
1067
1130
|
const webRequest = (request.method === "GET" || request.method === "HEAD") && !needsRewrite ? request : await toBoundedRequest(request, url, clientIp, isRpc ? rpcLimit : MAX_TRANSPORT_BODY_BYTES);
|
|
1068
|
-
const response = await handler
|
|
1131
|
+
const response = await runHandlerWithTimeout(handler, webRequest, requestTimeoutMs);
|
|
1069
1132
|
return finish(withDefaultSecurityHeaders(response));
|
|
1070
1133
|
} catch (error) {
|
|
1071
1134
|
if (error instanceof BodyLimitError) {
|
|
1072
1135
|
const isRpc = url.pathname.startsWith("/_moons/fn/");
|
|
1073
|
-
return finish(
|
|
1136
|
+
return finish(textResponseWithHeaders(413, isRpc ? rpcBodyTooLargeText(error.limit, null) : "Payload Too Large", options.headers));
|
|
1137
|
+
}
|
|
1138
|
+
if (error instanceof RequestTimeoutError) {
|
|
1139
|
+
if (accessLogger !== null) {
|
|
1140
|
+
accessLogger({
|
|
1141
|
+
msg: "request-timeout",
|
|
1142
|
+
level: "warn",
|
|
1143
|
+
method: request.method,
|
|
1144
|
+
path: url.pathname + url.search,
|
|
1145
|
+
limitMs: error.limit
|
|
1146
|
+
});
|
|
1147
|
+
} else {
|
|
1148
|
+
console.warn(`[moons] request timed out after ${error.limit}ms — ${request.method} ${url.pathname}`);
|
|
1149
|
+
}
|
|
1150
|
+
return finish(textResponseWithHeaders(504, requestTimeoutText(error.limit), options.headers));
|
|
1151
|
+
}
|
|
1152
|
+
if (isAbortLike(error)) {
|
|
1153
|
+
if (accessLogger !== null) {
|
|
1154
|
+
accessLogger({
|
|
1155
|
+
msg: "request-aborted",
|
|
1156
|
+
level: "warn",
|
|
1157
|
+
method: request.method,
|
|
1158
|
+
path: url.pathname + url.search
|
|
1159
|
+
});
|
|
1160
|
+
} else {
|
|
1161
|
+
console.warn(`[moons] request aborted by the client — ${request.method} ${url.pathname}`);
|
|
1162
|
+
}
|
|
1163
|
+
return new Response(null, { status: 499 });
|
|
1074
1164
|
}
|
|
1075
1165
|
console.error("[moons] server error:", error);
|
|
1076
|
-
return finish(
|
|
1166
|
+
return finish(textResponseWithHeaders(500, "Internal Server Error", options.headers));
|
|
1077
1167
|
}
|
|
1078
1168
|
}
|
|
1079
1169
|
});
|
|
@@ -1509,4 +1599,4 @@ export {
|
|
|
1509
1599
|
toWebRequest2 as toWebRequest
|
|
1510
1600
|
};
|
|
1511
1601
|
|
|
1512
|
-
//# debugId=
|
|
1602
|
+
//# debugId=C3DF08B69DE9E6D964756E2164756E21
|