@reckona/mreact-router 0.0.203 → 0.0.205

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/README.md +53 -9
  2. package/dist/actions.d.ts +6 -0
  3. package/dist/actions.d.ts.map +1 -1
  4. package/dist/actions.js +70 -10
  5. package/dist/actions.js.map +1 -1
  6. package/dist/adapters/aws-lambda.d.ts +15 -4
  7. package/dist/adapters/aws-lambda.d.ts.map +1 -1
  8. package/dist/adapters/aws-lambda.js +301 -63
  9. package/dist/adapters/aws-lambda.js.map +1 -1
  10. package/dist/adapters/cloudflare.d.ts +2 -1
  11. package/dist/adapters/cloudflare.d.ts.map +1 -1
  12. package/dist/adapters/cloudflare.js +18 -10
  13. package/dist/adapters/cloudflare.js.map +1 -1
  14. package/dist/adapters/edge.d.ts +1 -1
  15. package/dist/adapters/edge.d.ts.map +1 -1
  16. package/dist/adapters/edge.js.map +1 -1
  17. package/dist/adapters/node.d.ts +5 -3
  18. package/dist/adapters/node.d.ts.map +1 -1
  19. package/dist/adapters/node.js +2 -1
  20. package/dist/adapters/node.js.map +1 -1
  21. package/dist/adapters/static.d.ts.map +1 -1
  22. package/dist/adapters/static.js +24 -2
  23. package/dist/adapters/static.js.map +1 -1
  24. package/dist/build.d.ts +1 -0
  25. package/dist/build.d.ts.map +1 -1
  26. package/dist/build.js +91 -5
  27. package/dist/build.js.map +1 -1
  28. package/dist/built-runtime.d.ts +2 -0
  29. package/dist/built-runtime.d.ts.map +1 -1
  30. package/dist/built-runtime.js +16 -0
  31. package/dist/built-runtime.js.map +1 -1
  32. package/dist/cache.d.ts +3 -1
  33. package/dist/cache.d.ts.map +1 -1
  34. package/dist/cache.js +211 -13
  35. package/dist/cache.js.map +1 -1
  36. package/dist/cli.js +12 -1
  37. package/dist/cli.js.map +1 -1
  38. package/dist/client.d.ts.map +1 -1
  39. package/dist/client.js +32 -1
  40. package/dist/client.js.map +1 -1
  41. package/dist/config.d.ts +3 -0
  42. package/dist/config.d.ts.map +1 -1
  43. package/dist/config.js +21 -2
  44. package/dist/config.js.map +1 -1
  45. package/dist/csp.d.ts +1 -0
  46. package/dist/csp.d.ts.map +1 -1
  47. package/dist/csp.js +11 -6
  48. package/dist/csp.js.map +1 -1
  49. package/dist/dehydrate-policy.d.ts +3 -0
  50. package/dist/dehydrate-policy.d.ts.map +1 -0
  51. package/dist/dehydrate-policy.js +16 -0
  52. package/dist/dehydrate-policy.js.map +1 -0
  53. package/dist/dev-server.d.ts +7 -2
  54. package/dist/dev-server.d.ts.map +1 -1
  55. package/dist/dev-server.js +120 -11
  56. package/dist/dev-server.js.map +1 -1
  57. package/dist/http.d.ts +1 -1
  58. package/dist/http.d.ts.map +1 -1
  59. package/dist/http.js +147 -7
  60. package/dist/http.js.map +1 -1
  61. package/dist/index.d.ts +4 -3
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +1 -0
  64. package/dist/index.js.map +1 -1
  65. package/dist/logger.d.ts +22 -1
  66. package/dist/logger.d.ts.map +1 -1
  67. package/dist/logger.js +22 -8
  68. package/dist/logger.js.map +1 -1
  69. package/dist/metadata.d.ts +8 -0
  70. package/dist/metadata.d.ts.map +1 -1
  71. package/dist/metadata.js +60 -22
  72. package/dist/metadata.js.map +1 -1
  73. package/dist/navigation-marker.d.ts.map +1 -1
  74. package/dist/navigation-marker.js +72 -9
  75. package/dist/navigation-marker.js.map +1 -1
  76. package/dist/navigation.d.ts +1 -0
  77. package/dist/navigation.d.ts.map +1 -1
  78. package/dist/navigation.js +1 -1
  79. package/dist/navigation.js.map +1 -1
  80. package/dist/node-server.d.ts +5 -2
  81. package/dist/node-server.d.ts.map +1 -1
  82. package/dist/node-server.js +75 -6
  83. package/dist/node-server.js.map +1 -1
  84. package/dist/prerender-entry.d.ts +14 -0
  85. package/dist/prerender-entry.d.ts.map +1 -1
  86. package/dist/prerender-entry.js +40 -3
  87. package/dist/prerender-entry.js.map +1 -1
  88. package/dist/render.d.ts +9 -1
  89. package/dist/render.d.ts.map +1 -1
  90. package/dist/render.js +102 -123
  91. package/dist/render.js.map +1 -1
  92. package/dist/serve.d.ts +8 -2
  93. package/dist/serve.d.ts.map +1 -1
  94. package/dist/serve.js +22 -20
  95. package/dist/serve.js.map +1 -1
  96. package/dist/session.d.ts.map +1 -1
  97. package/dist/session.js +52 -19
  98. package/dist/session.js.map +1 -1
  99. package/dist/upgrade.d.ts +59 -2
  100. package/dist/upgrade.d.ts.map +1 -1
  101. package/dist/upgrade.js +282 -1
  102. package/dist/upgrade.js.map +1 -1
  103. package/dist/vite-config.d.ts +2 -0
  104. package/dist/vite-config.d.ts.map +1 -1
  105. package/dist/vite-config.js +2 -0
  106. package/dist/vite-config.js.map +1 -1
  107. package/dist/vite.d.ts +4 -1
  108. package/dist/vite.d.ts.map +1 -1
  109. package/dist/vite.js +117 -6
  110. package/dist/vite.js.map +1 -1
  111. package/package.json +11 -11
  112. package/src/actions.ts +81 -11
  113. package/src/adapters/aws-lambda.ts +426 -115
  114. package/src/adapters/cloudflare.ts +29 -13
  115. package/src/adapters/edge.ts +2 -0
  116. package/src/adapters/node.ts +8 -10
  117. package/src/adapters/static.ts +31 -2
  118. package/src/build.ts +117 -10
  119. package/src/built-runtime.ts +28 -0
  120. package/src/cache.ts +262 -15
  121. package/src/cli.ts +14 -1
  122. package/src/client.ts +32 -1
  123. package/src/config.ts +43 -6
  124. package/src/csp.ts +14 -11
  125. package/src/dehydrate-policy.ts +23 -0
  126. package/src/dev-server.ts +188 -15
  127. package/src/http.ts +172 -6
  128. package/src/index.ts +14 -1
  129. package/src/logger.ts +47 -10
  130. package/src/metadata.ts +125 -60
  131. package/src/navigation-marker.ts +79 -9
  132. package/src/navigation.ts +1 -1
  133. package/src/node-server.ts +128 -22
  134. package/src/prerender-entry.ts +52 -3
  135. package/src/render.ts +807 -753
  136. package/src/serve.ts +49 -56
  137. package/src/session.ts +56 -25
  138. package/src/upgrade.ts +402 -3
  139. package/src/vite-config.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B,KAAc,EACd,OAAqD;IAErD,QAAQ,CAAC,UAAU,GAAG,GAAG,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,2BAA2B,CAAC,CAAC;IAChE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,KAAK,IAAI;QACzC,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QACtD,CAAC,CAAC,uBAAuB,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import { createServer, type Server } from \"node:http\";\nimport type { ServerResponse } from \"node:http\";\nimport { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { createServer as createViteServer, type UserConfig, type ViteDevServer } from \"vite\";\nimport type { AppRouterServerActionOptions } from \"./actions.js\";\nimport { createMemoryRouteCache, type AppRouterCache } from \"./cache.js\";\nimport { resolveAppRouterProjectOptions, type AppRouterProjectOptions } from \"./config.js\";\nimport type { AppRouterImportPolicy } from \"./import-policy.js\";\nimport { createAppRouterVitePlugin } from \"./vite.js\";\nimport {\n loadMreactRouterViteConfigDetails,\n type LoadedMreactRouterViteConfig,\n} from \"./vite-config.js\";\nimport {\n emitRouterLog,\n logDurationMs,\n logNow,\n nodeRequestPath,\n type AppRouterLogger,\n} from \"./logger.js\";\nimport type { HttpUpgradeHandler } from \"./upgrade.js\";\n\n/**\n * Configures the Vite-powered app-router development server.\n */\nexport interface StartDevServerOptions extends AppRouterProjectOptions {\n port?: number | undefined;\n hostname?: string;\n importPolicy?: AppRouterImportPolicy | undefined;\n logger?: AppRouterLogger | undefined;\n routeCache?: AppRouterCache | undefined;\n serverActions?: AppRouterServerActionOptions | undefined;\n verboseErrors?: boolean | undefined;\n viteConfig?: UserConfig | undefined;\n onUpgrade?: HttpUpgradeHandler | undefined;\n}\n\n/**\n * Starts the local app-router development server with Vite middleware and route compilation.\n *\n * The server trusts only the configured host settings, merges declared application packages into the development import policy, and returns a `close()` method that should be awaited by tests and scripts.\n */\nexport async function startDevServer(\n options: StartDevServerOptions,\n): Promise<{ close(): Promise<void>; server: Server; url: string }> {\n const hostname = options.hostname ?? \"127.0.0.1\";\n const resolved = await resolveStartDevServerProject(options);\n const project = resolved.project;\n const userViteConfig = options.viteConfig ?? resolved.viteConfig ?? {};\n const userViteServerConfig =\n typeof userViteConfig.server === \"object\" ? userViteConfig.server : {};\n const userHmrConfig =\n typeof userViteServerConfig.hmr === \"object\" ? userViteServerConfig.hmr : {};\n const port = options.port ?? resolved.serverPort ?? 3001;\n const routeCache = options.routeCache ?? createMemoryRouteCache();\n const declaredPackages = await readDeclaredProjectPackages(project.projectRoot);\n const configImportPolicy = resolved.importPolicy;\n const importPolicy: AppRouterImportPolicy = {\n ...configImportPolicy,\n ...options.importPolicy,\n allowedPackages: [\n ...new Set([\n ...declaredPackages,\n ...(configImportPolicy?.allowedPackages ?? []),\n ...(options.importPolicy?.allowedPackages ?? []),\n ]),\n ],\n };\n let vite: ViteDevServer | undefined;\n const server = createServer((incoming, outgoing) => {\n const logger = options.logger;\n const startedAt = logger === undefined ? undefined : logNow();\n const logFields =\n logger === undefined\n ? undefined\n : {\n method: incoming.method ?? \"GET\",\n path: nodeRequestPath(incoming.url),\n runtime: \"node\" as const,\n };\n\n if (logger !== undefined && logFields !== undefined && startedAt !== undefined) {\n emitRouterLog(logger, \"info\", {\n ...logFields,\n type: \"router:request:start\",\n });\n outgoing.once(\"finish\", () => {\n emitRouterLog(logger, \"info\", {\n ...logFields,\n durationMs: logDurationMs(startedAt),\n status: outgoing.statusCode,\n type: \"router:request:end\",\n });\n });\n }\n\n if (vite === undefined) {\n sendDevServerError(outgoing, new Error(\"Vite dev server is not initialized.\"), options);\n return;\n }\n\n vite.middlewares(incoming, outgoing, (error?: unknown) => {\n if (error !== undefined) {\n if (error instanceof Error) {\n vite?.ssrFixStacktrace(error);\n }\n sendDevServerError(outgoing, error, options);\n return;\n }\n\n outgoing.statusCode = 404;\n outgoing.setHeader(\"content-type\", \"text/plain; charset=utf-8\");\n outgoing.end(\"Not Found\");\n });\n });\n\n if (options.onUpgrade !== undefined) {\n server.on(\"upgrade\", options.onUpgrade);\n }\n\n vite = await createViteServer({\n ...userViteConfig,\n appType: \"custom\",\n configFile: false,\n root: project.projectRoot,\n server: {\n ...userViteServerConfig,\n hmr: { ...userHmrConfig, server },\n middlewareMode: true,\n },\n plugins: [\n ...(userViteConfig.plugins ?? []),\n createAppRouterVitePlugin({\n allowedSourceDirs: project.allowedSourceDirs,\n projectRoot: project.projectRoot,\n publicDir: project.publicDir,\n routesDir: project.routesDir,\n importPolicy,\n logger: options.logger,\n routeCache,\n serverActions: options.serverActions,\n }),\n ],\n });\n\n try {\n await listenDevHttpServer(server, port, hostname);\n } catch (error) {\n await vite.close();\n throw error;\n }\n const address = server.address();\n const actualPort = typeof address === \"object\" && address !== null ? address.port : port;\n\n return {\n server,\n url: `http://${hostname}:${actualPort}`,\n close: async () => {\n await vite?.close();\n await new Promise<void>((resolve, reject) => {\n server.close((error) => (error ? reject(error) : resolve()));\n });\n },\n };\n}\n\nfunction listenDevHttpServer(server: Server, port: number, hostname: string): Promise<void> {\n return new Promise((resolve, reject) => {\n const onError = (error: Error) => {\n server.off(\"listening\", onListening);\n reject(formatDevListenError(error, hostname, port));\n };\n const onListening = () => {\n server.off(\"error\", onError);\n resolve();\n };\n\n server.once(\"error\", onError);\n server.once(\"listening\", onListening);\n server.listen(port, hostname);\n });\n}\n\nfunction formatDevListenError(error: Error, hostname: string, port: number): Error {\n if (isNodeErrorCode(error, \"EADDRINUSE\")) {\n return new Error(\n `mreact dev server could not start because ${hostname}:${port} is already in use. Stop the process using that port or run with PORT=<free-port>.`,\n );\n }\n\n return error;\n}\n\nfunction isNodeErrorCode(error: unknown, code: string): boolean {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"code\" in error &&\n (error as { code?: unknown }).code === code\n );\n}\n\nasync function resolveStartDevServerProject(options: StartDevServerOptions): Promise<{\n project: ReturnType<typeof resolveAppRouterProjectOptions>;\n serverPort?: number | undefined;\n importPolicy?: LoadedMreactRouterViteConfig[\"importPolicy\"];\n viteConfig?: LoadedMreactRouterViteConfig[\"viteConfig\"];\n}> {\n if (options.appDir !== undefined || options.routesDir !== undefined) {\n return { project: resolveAppRouterProjectOptions(options) };\n }\n\n const config = await loadOptionalMreactRouterViteConfig(\n resolve(options.projectRoot ?? process.cwd()),\n );\n\n return {\n ...(config?.importPolicy === undefined ? {} : { importPolicy: config.importPolicy }),\n project: resolveAppRouterProjectOptions({\n ...config?.project,\n ...definedProjectOptions(options),\n }),\n serverPort: config?.serverPort,\n viteConfig: config?.viteConfig,\n };\n}\n\nasync function loadOptionalMreactRouterViteConfig(cwd: string) {\n try {\n return await loadMreactRouterViteConfigDetails({\n command: \"serve\",\n cwd,\n });\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"vite.config.ts is required\")) {\n return undefined;\n }\n\n throw error;\n }\n}\n\nasync function readDeclaredProjectPackages(projectRoot: string): Promise<string[]> {\n try {\n const json = JSON.parse(await readFile(resolve(projectRoot, \"package.json\"), \"utf8\")) as {\n dependencies?: Record<string, unknown> | undefined;\n devDependencies?: Record<string, unknown> | undefined;\n optionalDependencies?: Record<string, unknown> | undefined;\n peerDependencies?: Record<string, unknown> | undefined;\n };\n\n return [\n ...Object.keys(json.dependencies ?? {}),\n ...Object.keys(json.devDependencies ?? {}),\n ...Object.keys(json.optionalDependencies ?? {}),\n ...Object.keys(json.peerDependencies ?? {}),\n ];\n } catch {\n return [];\n }\n}\n\nfunction definedProjectOptions(options: StartDevServerOptions): AppRouterProjectOptions {\n return {\n ...(options.allowedSourceDirs === undefined\n ? {}\n : { allowedSourceDirs: options.allowedSourceDirs }),\n ...(options.appDir === undefined ? {} : { appDir: options.appDir }),\n ...(options.projectRoot === undefined ? {} : { projectRoot: options.projectRoot }),\n ...(options.publicDir === undefined ? {} : { publicDir: options.publicDir }),\n ...(options.routesDir === undefined ? {} : { routesDir: options.routesDir }),\n };\n}\n\nfunction sendDevServerError(\n outgoing: ServerResponse,\n error: unknown,\n options: Pick<StartDevServerOptions, \"verboseErrors\">,\n): void {\n outgoing.statusCode = 500;\n outgoing.setHeader(\"content-type\", \"text/plain; charset=utf-8\");\n outgoing.end(options.verboseErrors === true\n ? error instanceof Error ? error.stack : String(error)\n : \"Internal Server Error\");\n}\n"]}
1
+ {"version":3,"file":"dev-server.js","sourceRoot":"","sources":["../src/dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAuC,MAAM,MAAM,CAAC;AAE7F,OAAO,EAAE,sBAAsB,EAAuB,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,8BAA8B,EAAgC,MAAM,aAAa,CAAC;AAE3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EACL,iCAAiC,GAElC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,aAAa,EACb,aAAa,EACb,MAAM,EACN,eAAe,GAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kCAAkC,EAClC,uBAAuB,EACvB,iCAAiC,EACjC,yBAAyB,GAI1B,MAAM,cAAc,CAAC;AAqBtB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAA8B;IAE9B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,WAAW,CAAC;IACjD,MAAM,QAAQ,GAAG,MAAM,4BAA4B,CAAC,OAAO,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;IAC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nimport { readFile } from \"node:fs/promises\";\nimport { isIP } from \"node:net\";\nimport { posix, resolve } from \"node:path\";\nimport type { DehydrateOptions } from \"@reckona/mreact-query\";\nimport { createServer as createViteServer, type UserConfig, type ViteDevServer } from \"vite\";\nimport type { AppRouterServerActionOptions } from \"./actions.js\";\nimport { createMemoryRouteCache, type AppRouterCache } from \"./cache.js\";\nimport { resolveAppRouterProjectOptions, type AppRouterProjectOptions } from \"./config.js\";\nimport type { AppRouterImportPolicy } from \"./import-policy.js\";\nimport { createAppRouterVitePlugin } from \"./vite.js\";\nimport {\n loadMreactRouterViteConfigDetails,\n type LoadedMreactRouterViteConfig,\n} from \"./vite-config.js\";\nimport {\n emitRouterLog,\n logDurationMs,\n logNow,\n nodeRequestPath,\n type AppRouterLogger,\n} from \"./logger.js\";\nimport {\n assertValidHttpUpgradeOriginPolicy,\n closeServerWithUpgrades,\n createManagedHttpUpgradeLifecycle,\n validateHttpUpgradeOrigin,\n type HttpUpgradeOriginPolicy,\n type HttpUpgradeOriginValidation,\n type ManagedHttpUpgradeHandler,\n} from \"./upgrade.js\";\n\n/**\n * Configures the Vite-powered app-router development server.\n */\nexport interface StartDevServerOptions extends AppRouterProjectOptions {\n dehydrateOptions?: DehydrateOptions | undefined;\n port?: number | undefined;\n hostname?: string;\n importPolicy?: AppRouterImportPolicy | undefined;\n logger?: AppRouterLogger | undefined;\n routeCache?: AppRouterCache | undefined;\n serverActions?: AppRouterServerActionOptions | undefined;\n verboseErrors?: boolean | undefined;\n viteConfig?: UserConfig | undefined;\n onUpgrade?: ManagedHttpUpgradeHandler | undefined;\n upgradeCloseTimeoutMs?: number | undefined;\n upgradeDecisionTimeoutMs?: number | undefined;\n upgradeOriginPolicy?: HttpUpgradeOriginPolicy | undefined;\n}\n\n/**\n * Starts the local app-router development server with Vite middleware and route compilation.\n *\n * The server trusts only the configured host settings, merges declared application packages into the development import policy, and returns a `close()` method that should be awaited by tests and scripts.\n */\nexport async function startDevServer(\n options: StartDevServerOptions,\n): Promise<{ close(): Promise<void>; server: Server; url: string }> {\n const hostname = options.hostname ?? \"127.0.0.1\";\n const resolved = await resolveStartDevServerProject(options);\n const project = resolved.project;\n const userViteConfig = options.viteConfig ?? resolved.viteConfig ?? {};\n const userViteServerConfig =\n typeof userViteConfig.server === \"object\" ? userViteConfig.server : {};\n const userHmrConfig =\n typeof userViteServerConfig.hmr === \"object\" ? userViteServerConfig.hmr : {};\n const port = options.port ?? resolved.serverPort ?? 3001;\n const upgradeCloseTimeoutMs = finiteNonNegativeTimeout(\n options.upgradeCloseTimeoutMs,\n 1_000,\n \"upgradeCloseTimeoutMs\",\n );\n const upgradeDecisionTimeoutMs = finiteNonNegativeTimeout(\n options.upgradeDecisionTimeoutMs,\n 1_000,\n \"upgradeDecisionTimeoutMs\",\n );\n assertValidHttpUpgradeOriginPolicy(options.upgradeOriginPolicy);\n const routeCache = options.routeCache ?? createMemoryRouteCache();\n const declaredPackages = await readDeclaredProjectPackages(project.projectRoot);\n const configImportPolicy = resolved.importPolicy;\n const importPolicy: AppRouterImportPolicy = {\n ...configImportPolicy,\n ...options.importPolicy,\n allowedPackages: [\n ...new Set([\n ...declaredPackages,\n ...(configImportPolicy?.allowedPackages ?? []),\n ...(options.importPolicy?.allowedPackages ?? []),\n ]),\n ],\n };\n let vite: ViteDevServer | undefined;\n let actualPort = port;\n const server = createServer((incoming, outgoing) => {\n const logger = options.logger;\n const startedAt = logger === undefined ? undefined : logNow();\n const logFields =\n logger === undefined\n ? undefined\n : {\n method: incoming.method ?? \"GET\",\n path: nodeRequestPath(incoming.url),\n runtime: \"node\" as const,\n };\n\n if (logger !== undefined && logFields !== undefined && startedAt !== undefined) {\n emitRouterLog(logger, \"info\", {\n ...logFields,\n type: \"router:request:start\",\n });\n outgoing.once(\"finish\", () => {\n emitRouterLog(logger, \"info\", {\n ...logFields,\n durationMs: logDurationMs(startedAt),\n status: outgoing.statusCode,\n type: \"router:request:end\",\n });\n });\n }\n\n if (vite === undefined) {\n sendDevServerError(outgoing, new Error(\"Vite dev server is not initialized.\"), options);\n return;\n }\n\n vite.middlewares(incoming, outgoing, (error?: unknown) => {\n if (error !== undefined) {\n if (error instanceof Error) {\n vite?.ssrFixStacktrace(error);\n }\n sendDevServerError(outgoing, error, options);\n return;\n }\n\n outgoing.statusCode = 404;\n outgoing.setHeader(\"content-type\", \"text/plain; charset=utf-8\");\n outgoing.end(\"Not Found\");\n });\n });\n\n const upgradeLifecycle =\n options.onUpgrade === undefined\n ? undefined\n : createManagedHttpUpgradeLifecycle({\n decisionTimeoutMs: upgradeDecisionTimeoutMs,\n handler: options.onUpgrade,\n isOriginAllowed: (request) =>\n validateDevUpgradeOrigin(\n request,\n options.upgradeOriginPolicy,\n hostname,\n actualPort,\n vite,\n ),\n logger: options.logger,\n shouldBypass: (request) => isViteHmrUpgradeRequest(request, vite),\n });\n if (upgradeLifecycle !== undefined) {\n server.on(\"upgrade\", upgradeLifecycle.handle);\n }\n\n vite = await createViteServer({\n ...userViteConfig,\n appType: \"custom\",\n configFile: false,\n root: project.projectRoot,\n server: {\n ...userViteServerConfig,\n hmr: { ...userHmrConfig, server },\n middlewareMode: true,\n },\n plugins: [\n ...(userViteConfig.plugins ?? []),\n createAppRouterVitePlugin({\n allowedSourceDirs: project.allowedSourceDirs,\n dehydrateOptions: options.dehydrateOptions ?? resolved.dehydrateOptions,\n dehydratePolicyModule: project.dehydratePolicyModule,\n projectRoot: project.projectRoot,\n publicDir: project.publicDir,\n routesDir: project.routesDir,\n importPolicy,\n logger: options.logger,\n routeCache,\n serverActions: options.serverActions,\n }),\n ],\n });\n\n try {\n await listenDevHttpServer(server, port, hostname);\n } catch (error) {\n await vite.close();\n throw error;\n }\n const address = server.address();\n actualPort = typeof address === \"object\" && address !== null ? address.port : port;\n let closePromise: Promise<void> | undefined;\n\n return {\n server,\n url: `http://${formatNodeAuthority(hostname, actualPort)}`,\n close: () => {\n closePromise ??= (async () => {\n upgradeLifecycle?.beginClose();\n const httpClose =\n upgradeLifecycle === undefined\n ? new Promise<void>((resolve, reject) => {\n server.close((error) => (error ? reject(error) : resolve()));\n })\n : closeServerWithUpgrades({\n lifecycle: upgradeLifecycle,\n server,\n timeoutMs: upgradeCloseTimeoutMs,\n });\n const results = await Promise.allSettled([vite?.close(), httpClose]);\n const errors = results.flatMap((result) =>\n result.status === \"rejected\" ? [result.reason] : [],\n );\n if (errors.length > 0) {\n throw new AggregateError(errors, \"Failed to close the mreact development server.\");\n }\n })();\n return closePromise;\n },\n };\n}\n\nfunction validateDevUpgradeOrigin(\n request: import(\"node:http\").IncomingMessage,\n policy: HttpUpgradeOriginPolicy | undefined,\n hostname: string,\n port: number,\n vite: ViteDevServer | undefined,\n): HttpUpgradeOriginValidation {\n if (!isDevUpgradeHostAllowed(request.headers.host, vite?.config.server.allowedHosts)) {\n return { ok: false, reason: \"disallowed-origin\" };\n }\n if (policy === \"unchecked\") {\n return { ok: true, origin: request.headers.origin };\n }\n if (typeof policy === \"object\") {\n return validateHttpUpgradeOrigin(request, policy);\n }\n try {\n return validateHttpUpgradeOrigin(request, {\n allowedOrigins: [`http://${request.headers.host ?? formatNodeAuthority(hostname, port)}`],\n });\n } catch {\n return { ok: false, reason: \"malformed-origin\" };\n }\n}\n\nfunction isDevUpgradeHostAllowed(\n hostHeader: string | undefined,\n allowedHosts: true | string[] | undefined,\n): boolean {\n if (allowedHosts === true || hostHeader === undefined) {\n return true;\n }\n\n const host = hostHeader.trim();\n if (host.startsWith(\"[\")) {\n const closingBracket = host.indexOf(\"]\");\n return closingBracket > 0 && isIP(host.slice(1, closingBracket)) === 6;\n }\n const colon = host.indexOf(\":\");\n const hostname = colon === -1 ? host : host.slice(0, colon);\n if (isIP(hostname) === 4 || hostname === \"localhost\" || hostname.endsWith(\".localhost\")) {\n return true;\n }\n\n return (allowedHosts ?? []).some(\n (allowedHost) =>\n allowedHost === hostname ||\n (allowedHost.startsWith(\".\") &&\n (allowedHost.slice(1) === hostname || hostname.endsWith(allowedHost))),\n );\n}\n\nfunction formatNodeAuthority(hostname: string, port: number): string {\n const host = hostname.includes(\":\") && !hostname.startsWith(\"[\") ? `[${hostname}]` : hostname;\n return `${host}:${port}`;\n}\n\nfunction isViteHmrUpgradeRequest(\n request: import(\"node:http\").IncomingMessage,\n vite: ViteDevServer | undefined,\n): boolean {\n if (vite === undefined) {\n return false;\n }\n const protocol = request.headers[\"sec-websocket-protocol\"];\n if (protocol !== \"vite-hmr\" && protocol !== \"vite-ping\") {\n return false;\n }\n const hmr = vite.config.server.hmr;\n if (hmr === false) {\n return false;\n }\n const hmrPath = typeof hmr === \"object\" ? hmr.path : undefined;\n const expectedPath =\n hmrPath === undefined ? vite.config.base : posix.join(vite.config.base, hmrPath);\n\n try {\n return new URL(request.url ?? \"/\", \"http://mreact.local\").pathname === expectedPath;\n } catch {\n return false;\n }\n}\n\nfunction finiteNonNegativeTimeout(\n value: number | undefined,\n fallback: number,\n name: string,\n): number {\n const timeout = value ?? fallback;\n if (\n !Number.isFinite(timeout) ||\n timeout < 0 ||\n !Number.isSafeInteger(timeout) ||\n timeout > 2_147_483_647\n ) {\n throw new TypeError(\n `${name} must be a finite non-negative safe integer no greater than 2147483647.`,\n );\n }\n return timeout;\n}\n\nfunction listenDevHttpServer(server: Server, port: number, hostname: string): Promise<void> {\n return new Promise((resolve, reject) => {\n const onError = (error: Error) => {\n server.off(\"listening\", onListening);\n reject(formatDevListenError(error, hostname, port));\n };\n const onListening = () => {\n server.off(\"error\", onError);\n resolve();\n };\n\n server.once(\"error\", onError);\n server.once(\"listening\", onListening);\n server.listen(port, hostname);\n });\n}\n\nfunction formatDevListenError(error: Error, hostname: string, port: number): Error {\n if (isNodeErrorCode(error, \"EADDRINUSE\")) {\n return new Error(\n `mreact dev server could not start because ${hostname}:${port} is already in use. Stop the process using that port or run with PORT=<free-port>.`,\n );\n }\n\n return error;\n}\n\nfunction isNodeErrorCode(error: unknown, code: string): boolean {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"code\" in error &&\n (error as { code?: unknown }).code === code\n );\n}\n\nasync function resolveStartDevServerProject(options: StartDevServerOptions): Promise<{\n dehydrateOptions?: LoadedMreactRouterViteConfig[\"dehydrateOptions\"];\n project: ReturnType<typeof resolveAppRouterProjectOptions>;\n serverPort?: number | undefined;\n importPolicy?: LoadedMreactRouterViteConfig[\"importPolicy\"];\n viteConfig?: LoadedMreactRouterViteConfig[\"viteConfig\"];\n}> {\n if (options.appDir !== undefined || options.routesDir !== undefined) {\n return { project: resolveAppRouterProjectOptions(options) };\n }\n\n const config = await loadOptionalMreactRouterViteConfig(\n resolve(options.projectRoot ?? process.cwd()),\n );\n\n return {\n ...(config?.dehydrateOptions === undefined\n ? {}\n : { dehydrateOptions: config.dehydrateOptions }),\n ...(config?.importPolicy === undefined ? {} : { importPolicy: config.importPolicy }),\n project: resolveAppRouterProjectOptions({\n ...config?.project,\n ...definedProjectOptions(options),\n }),\n serverPort: config?.serverPort,\n viteConfig: config?.viteConfig,\n };\n}\n\nasync function loadOptionalMreactRouterViteConfig(cwd: string) {\n try {\n return await loadMreactRouterViteConfigDetails({\n command: \"serve\",\n cwd,\n });\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"vite.config.ts is required\")) {\n return undefined;\n }\n\n throw error;\n }\n}\n\nasync function readDeclaredProjectPackages(projectRoot: string): Promise<string[]> {\n try {\n const json = JSON.parse(await readFile(resolve(projectRoot, \"package.json\"), \"utf8\")) as {\n dependencies?: Record<string, unknown> | undefined;\n devDependencies?: Record<string, unknown> | undefined;\n optionalDependencies?: Record<string, unknown> | undefined;\n peerDependencies?: Record<string, unknown> | undefined;\n };\n\n return [\n ...Object.keys(json.dependencies ?? {}),\n ...Object.keys(json.devDependencies ?? {}),\n ...Object.keys(json.optionalDependencies ?? {}),\n ...Object.keys(json.peerDependencies ?? {}),\n ];\n } catch {\n return [];\n }\n}\n\nfunction definedProjectOptions(options: StartDevServerOptions): AppRouterProjectOptions {\n return {\n ...(options.allowedSourceDirs === undefined\n ? {}\n : { allowedSourceDirs: options.allowedSourceDirs }),\n ...(options.appDir === undefined ? {} : { appDir: options.appDir }),\n ...(options.projectRoot === undefined ? {} : { projectRoot: options.projectRoot }),\n ...(options.publicDir === undefined ? {} : { publicDir: options.publicDir }),\n ...(options.routesDir === undefined ? {} : { routesDir: options.routesDir }),\n };\n}\n\nfunction sendDevServerError(\n outgoing: ServerResponse,\n error: unknown,\n options: Pick<StartDevServerOptions, \"verboseErrors\">,\n): void {\n outgoing.statusCode = 500;\n outgoing.setHeader(\"content-type\", \"text/plain; charset=utf-8\");\n outgoing.end(\n options.verboseErrors === true\n ? error instanceof Error\n ? error.stack\n : String(error)\n : \"Internal Server Error\",\n );\n}\n"]}
package/dist/http.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ServerResponse } from "node:http";
2
2
  import type { IncomingMessage } from "node:http";
3
- export declare function nodeRequestToWebRequest(incoming: IncomingMessage, origin: string): Request;
3
+ export declare function nodeRequestToWebRequest(incoming: IncomingMessage, origin: string, outgoing?: ServerResponse): Request;
4
4
  export declare function rawNodeRequestUrl(request: Request): string | undefined;
5
5
  /**
6
6
  * Constructs a Response whose body is a single string (the common HTML
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAKjD,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,MAAM,GACb,OAAO,CA8BT;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEtE;AAmBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAIxE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAI9E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAE3D;AAED,wBAAsB,YAAY,CAChC,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,IAAI,CAAC,CAgDf"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAKjD,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAmCT;AA+DD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEtE;AAmBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAIxE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,QAAQ,CAI9E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAE3D;AAED,wBAAsB,YAAY,CAChC,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,IAAI,CAAC,CA0Df"}
package/dist/http.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Readable } from "node:stream";
2
2
  const rawUrlByRequest = new WeakMap();
3
- export function nodeRequestToWebRequest(incoming, origin) {
3
+ export function nodeRequestToWebRequest(incoming, origin, outgoing) {
4
4
  const method = incoming.method ?? "GET";
5
+ const rawUrl = incoming.url ?? "/";
5
6
  const headers = new Headers();
6
7
  for (const [name, value] of Object.entries(incoming.headers)) {
7
8
  if (Array.isArray(value)) {
@@ -18,14 +19,71 @@ export function nodeRequestToWebRequest(incoming, origin) {
18
19
  headers,
19
20
  method,
20
21
  };
22
+ if (outgoing !== undefined) {
23
+ init.signal = nodeRequestSignal(incoming, outgoing);
24
+ }
21
25
  if (method !== "GET" && method !== "HEAD") {
22
26
  init.body = Readable.toWeb(incoming);
23
27
  init.duplex = "half";
24
28
  }
25
- const request = new Request(new URL(incoming.url ?? "/", origin), init);
26
- rawUrlByRequest.set(request, incoming.url ?? "/");
29
+ const request = new Request(nodeRequestUrl(rawUrl, origin), init);
30
+ rawUrlByRequest.set(request, rawUrl);
27
31
  return request;
28
32
  }
33
+ function nodeRequestSignal(incoming, outgoing) {
34
+ const controller = new AbortController();
35
+ let disposed = false;
36
+ const dispose = () => {
37
+ if (disposed) {
38
+ return;
39
+ }
40
+ disposed = true;
41
+ incoming.off("aborted", onIncomingAborted);
42
+ outgoing.off("close", onOutgoingClose);
43
+ outgoing.off("error", onOutgoingError);
44
+ outgoing.off("finish", onOutgoingFinish);
45
+ };
46
+ const abort = (reason) => {
47
+ controller.abort(reason);
48
+ dispose();
49
+ };
50
+ const onIncomingAborted = () => {
51
+ abort(new Error("The incoming HTTP request was aborted."));
52
+ };
53
+ const onOutgoingClose = () => {
54
+ if (!outgoing.writableFinished) {
55
+ abort(new Error("The outgoing HTTP response closed before completion."));
56
+ return;
57
+ }
58
+ dispose();
59
+ };
60
+ const onOutgoingError = (error) => {
61
+ abort(error);
62
+ };
63
+ const onOutgoingFinish = () => {
64
+ dispose();
65
+ };
66
+ incoming.once("aborted", onIncomingAborted);
67
+ outgoing.once("close", onOutgoingClose);
68
+ outgoing.once("error", onOutgoingError);
69
+ outgoing.once("finish", onOutgoingFinish);
70
+ if (incoming.aborted) {
71
+ onIncomingAborted();
72
+ }
73
+ else if (outgoing.destroyed && !outgoing.writableFinished) {
74
+ onOutgoingClose();
75
+ }
76
+ return controller.signal;
77
+ }
78
+ function nodeRequestUrl(rawUrl, origin) {
79
+ const validatedOrigin = new URL(origin).origin;
80
+ const rootedPath = rawUrl.startsWith("/") ? rawUrl : `/${rawUrl}`;
81
+ const requestUrl = new URL(`${validatedOrigin}${rootedPath}`);
82
+ if (requestUrl.origin !== validatedOrigin) {
83
+ throw new TypeError("Node request target changed the validated request origin.");
84
+ }
85
+ return requestUrl;
86
+ }
29
87
  export function rawNodeRequestUrl(request) {
30
88
  return rawUrlByRequest.get(request);
31
89
  }
@@ -97,27 +155,109 @@ export async function sendResponse(outgoing, response) {
97
155
  outgoing.end(rawBody);
98
156
  return;
99
157
  }
100
- outgoing.flushHeaders();
101
158
  const reader = response.body.getReader();
159
+ const lifecycle = observeOutgoingFailure(outgoing);
160
+ outgoing.flushHeaders();
102
161
  try {
103
162
  while (true) {
104
- const result = await reader.read();
163
+ const result = await readWithAbort(reader, lifecycle.signal);
105
164
  if (result.done) {
106
165
  outgoing.end();
107
166
  return;
108
167
  }
109
168
  if (!outgoing.write(result.value)) {
110
- await new Promise((resolve) => outgoing.once("drain", resolve));
169
+ await waitForDrain(outgoing, lifecycle.signal);
111
170
  }
112
171
  }
113
172
  }
114
173
  catch (error) {
115
- outgoing.destroy(error instanceof Error ? error : new Error(String(error)));
174
+ const reason = error instanceof Error ? error : new Error(String(error));
175
+ try {
176
+ await reader.cancel(reason);
177
+ }
178
+ catch {
179
+ // The stream may already be errored or cancelled.
180
+ }
181
+ if (!outgoing.destroyed) {
182
+ outgoing.destroy(reason);
183
+ }
116
184
  }
117
185
  finally {
186
+ lifecycle.dispose();
118
187
  reader.releaseLock();
119
188
  }
120
189
  }
190
+ function observeOutgoingFailure(outgoing) {
191
+ const controller = new AbortController();
192
+ let disposed = false;
193
+ const dispose = () => {
194
+ if (disposed) {
195
+ return;
196
+ }
197
+ disposed = true;
198
+ outgoing.off("close", onClose);
199
+ outgoing.off("error", onError);
200
+ };
201
+ const abort = (reason) => {
202
+ controller.abort(reason);
203
+ dispose();
204
+ };
205
+ const onClose = () => {
206
+ abort(new Error("The outgoing HTTP response closed during streaming."));
207
+ };
208
+ const onError = (error) => {
209
+ abort(error);
210
+ };
211
+ outgoing.once("close", onClose);
212
+ outgoing.once("error", onError);
213
+ if (outgoing.destroyed) {
214
+ onClose();
215
+ }
216
+ return { dispose, signal: controller.signal };
217
+ }
218
+ function readWithAbort(reader, signal) {
219
+ if (signal.aborted) {
220
+ return Promise.reject(abortReason(signal));
221
+ }
222
+ return new Promise((resolve, reject) => {
223
+ const onAbort = () => {
224
+ signal.removeEventListener("abort", onAbort);
225
+ reject(abortReason(signal));
226
+ };
227
+ signal.addEventListener("abort", onAbort, { once: true });
228
+ void reader.read().then((result) => {
229
+ signal.removeEventListener("abort", onAbort);
230
+ resolve(result);
231
+ }, (error) => {
232
+ signal.removeEventListener("abort", onAbort);
233
+ reject(error);
234
+ });
235
+ });
236
+ }
237
+ function waitForDrain(outgoing, signal) {
238
+ if (signal.aborted) {
239
+ return Promise.reject(abortReason(signal));
240
+ }
241
+ return new Promise((resolve, reject) => {
242
+ const dispose = () => {
243
+ outgoing.off("drain", onDrain);
244
+ signal.removeEventListener("abort", onAbort);
245
+ };
246
+ const onDrain = () => {
247
+ dispose();
248
+ resolve();
249
+ };
250
+ const onAbort = () => {
251
+ dispose();
252
+ reject(abortReason(signal));
253
+ };
254
+ outgoing.once("drain", onDrain);
255
+ signal.addEventListener("abort", onAbort, { once: true });
256
+ });
257
+ }
258
+ function abortReason(signal) {
259
+ return signal.reason instanceof Error ? signal.reason : new Error("HTTP streaming was aborted.");
260
+ }
121
261
  function responseSetCookieHeaders(headers) {
122
262
  const getSetCookie = headers.getSetCookie;
123
263
  if (typeof getSetCookie === "function") {
package/dist/http.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa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E,CAAC;IACvB,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,OAAgB;IAChD,MAAM,YAAY,GAAI,OAAuD,CAAC,YAAY,CAAC;IAE3F,IAAI,OAAO,YAAY,KAAK,UAAU,EAAE,CAAC;QACvC,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACxC,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { ServerResponse } from \"node:http\";\nimport type { IncomingMessage } from \"node:http\";\nimport { Readable } from \"node:stream\";\n\nconst rawUrlByRequest = new WeakMap<Request, string>();\n\nexport function nodeRequestToWebRequest(\n incoming: IncomingMessage,\n origin: string,\n): Request {\n const method = incoming.method ?? \"GET\";\n const headers = new Headers();\n\n for (const [name, value] of Object.entries(incoming.headers)) {\n if (Array.isArray(value)) {\n for (const item of value) {\n headers.append(name, item);\n }\n continue;\n }\n\n if (value !== undefined) {\n headers.set(name, value);\n }\n }\n\n const init: RequestInit & { duplex?: \"half\" } = {\n headers,\n method,\n };\n\n if (method !== \"GET\" && method !== \"HEAD\") {\n init.body = Readable.toWeb(incoming) as ReadableStream<Uint8Array>;\n init.duplex = \"half\";\n }\n\n const request = new Request(new URL(incoming.url ?? \"/\", origin), init);\n rawUrlByRequest.set(request, incoming.url ?? \"/\");\n return request;\n}\n\nexport function rawNodeRequestUrl(request: Request): string | undefined {\n return rawUrlByRequest.get(request);\n}\n\n/**\n * WeakMap-backed marker holding the underlying body for Response objects\n * that mreact built from a known-shape body (string / Buffer /\n * Uint8Array). When `sendResponse` sees this marker, it bypasses the\n * `ReadableStream → reader.read()` pump and writes the body directly to\n * the Node HTTP socket.\n *\n * A WeakMap is used instead of a Symbol property to avoid forcing a\n * hidden-class transition on the Response — Response is a global host\n * object whose IC chain is shared, and adding own properties slows down\n * subsequent `response.headers` / `response.body` accesses.\n *\n * Measured savings (Node 24 / Linux x64, minimal page bench): ~10-15μs/req\n * vs the stream path. See docs/issues/054.\n */\nconst rawBodyByResponse = new WeakMap<Response, string | Uint8Array>();\n\n/**\n * Constructs a Response whose body is a single string (the common HTML\n * render result). Equivalent to `new Response(html, init)` but tagged so\n * `sendResponse` can take its string fast path.\n */\nexport function htmlResponse(html: string, init?: ResponseInit): Response {\n const response = new Response(html, init);\n rawBodyByResponse.set(response, html);\n return response;\n}\n\n/**\n * Constructs a Response whose body is raw bytes (e.g., pre-rendered HTML\n * already encoded, or static assets). Tagged so `sendResponse` writes the\n * bytes directly without going through the stream reader.\n */\nexport function bytesResponse(bytes: Uint8Array, init?: ResponseInit): Response {\n const response = new Response(bytes as BodyInit, init);\n rawBodyByResponse.set(response, bytes);\n return response;\n}\n\n/**\n * Test-only probe: returns true when the Response was constructed via\n * `htmlResponse` / `bytesResponse` and is therefore eligible for the\n * `sendResponse` raw-body fast path. Not part of the public runtime API.\n */\nexport function hasFastPathBody(response: Response): boolean {\n return rawBodyByResponse.has(response);\n}\n\nexport async function sendResponse(\n outgoing: ServerResponse,\n response: Response,\n): Promise<void> {\n outgoing.statusCode = response.status;\n const setCookieHeaders = responseSetCookieHeaders(response.headers);\n response.headers.forEach((value, key) => {\n if (key.toLowerCase() === \"set-cookie\" && setCookieHeaders.length > 0) {\n return;\n }\n outgoing.setHeader(key, value);\n });\n if (setCookieHeaders.length > 0) {\n outgoing.setHeader(\"set-cookie\", setCookieHeaders);\n }\n\n if (response.body === null) {\n outgoing.end();\n return;\n }\n\n // Fast path: when the Response was constructed via `htmlResponse` /\n // `bytesResponse` (i.e., mreact knows the underlying body shape), skip\n // the Response→ReadableStream→reader pump and write directly.\n const rawBody = rawBodyByResponse.get(response);\n if (rawBody !== undefined) {\n outgoing.end(rawBody);\n return;\n }\n\n outgoing.flushHeaders();\n const reader = response.body.getReader();\n\n try {\n while (true) {\n const result = await reader.read();\n\n if (result.done) {\n outgoing.end();\n return;\n }\n\n if (!outgoing.write(result.value)) {\n await new Promise<void>((resolve) => outgoing.once(\"drain\", resolve));\n }\n }\n } catch (error) {\n outgoing.destroy(error instanceof Error ? error : new Error(String(error)));\n } finally {\n reader.releaseLock();\n }\n}\n\nfunction responseSetCookieHeaders(headers: Headers): string[] {\n const getSetCookie = (headers as Headers & { getSetCookie?: () => string[] }).getSetCookie;\n\n if (typeof getSetCookie === \"function\") {\n return getSetCookie.call(headers);\n }\n\n const value = headers.get(\"set-cookie\");\n return value === null ? [] : [value];\n}\n"]}
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,eAAe,GAAG,IAAI,OAAO,EAAmB,CAAC;AAEvD,MAAM,UAAU,uBAAuB,CACrC,QAAyB,EACzB,MAAc,EACd,QAAyB;IAEzB,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,IAAI,KAAK,CAAC;IACxC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,IAAI,GAAG,CAAC;IACnC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC7B,CAAC;YACD,SAAS;QACX,CAAC;QAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;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CAAC;QACvC,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACxC,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { ServerResponse } from \"node:http\";\nimport type { IncomingMessage } from \"node:http\";\nimport { Readable } from \"node:stream\";\n\nconst rawUrlByRequest = new WeakMap<Request, string>();\n\nexport function nodeRequestToWebRequest(\n incoming: IncomingMessage,\n origin: string,\n outgoing?: ServerResponse,\n): Request {\n const method = incoming.method ?? \"GET\";\n const rawUrl = incoming.url ?? \"/\";\n const headers = new Headers();\n\n for (const [name, value] of Object.entries(incoming.headers)) {\n if (Array.isArray(value)) {\n for (const item of value) {\n headers.append(name, item);\n }\n continue;\n }\n\n if (value !== undefined) {\n headers.set(name, value);\n }\n }\n\n const init: RequestInit & { duplex?: \"half\" } = {\n headers,\n method,\n };\n\n if (outgoing !== undefined) {\n init.signal = nodeRequestSignal(incoming, outgoing);\n }\n\n if (method !== \"GET\" && method !== \"HEAD\") {\n init.body = Readable.toWeb(incoming) as ReadableStream<Uint8Array>;\n init.duplex = \"half\";\n }\n\n const request = new Request(nodeRequestUrl(rawUrl, origin), init);\n rawUrlByRequest.set(request, rawUrl);\n return request;\n}\n\nfunction nodeRequestSignal(incoming: IncomingMessage, outgoing: ServerResponse): AbortSignal {\n const controller = new AbortController();\n let disposed = false;\n\n const dispose = (): void => {\n if (disposed) {\n return;\n }\n disposed = true;\n incoming.off(\"aborted\", onIncomingAborted);\n outgoing.off(\"close\", onOutgoingClose);\n outgoing.off(\"error\", onOutgoingError);\n outgoing.off(\"finish\", onOutgoingFinish);\n };\n const abort = (reason: Error): void => {\n controller.abort(reason);\n dispose();\n };\n const onIncomingAborted = (): void => {\n abort(new Error(\"The incoming HTTP request was aborted.\"));\n };\n const onOutgoingClose = (): void => {\n if (!outgoing.writableFinished) {\n abort(new Error(\"The outgoing HTTP response closed before completion.\"));\n return;\n }\n dispose();\n };\n const onOutgoingError = (error: Error): void => {\n abort(error);\n };\n const onOutgoingFinish = (): void => {\n dispose();\n };\n\n incoming.once(\"aborted\", onIncomingAborted);\n outgoing.once(\"close\", onOutgoingClose);\n outgoing.once(\"error\", onOutgoingError);\n outgoing.once(\"finish\", onOutgoingFinish);\n\n if (incoming.aborted) {\n onIncomingAborted();\n } else if (outgoing.destroyed && !outgoing.writableFinished) {\n onOutgoingClose();\n }\n\n return controller.signal;\n}\n\nfunction nodeRequestUrl(rawUrl: string, origin: string): URL {\n const validatedOrigin = new URL(origin).origin;\n const rootedPath = rawUrl.startsWith(\"/\") ? rawUrl : `/${rawUrl}`;\n const requestUrl = new URL(`${validatedOrigin}${rootedPath}`);\n\n if (requestUrl.origin !== validatedOrigin) {\n throw new TypeError(\"Node request target changed the validated request origin.\");\n }\n\n return requestUrl;\n}\n\nexport function rawNodeRequestUrl(request: Request): string | undefined {\n return rawUrlByRequest.get(request);\n}\n\n/**\n * WeakMap-backed marker holding the underlying body for Response objects\n * that mreact built from a known-shape body (string / Buffer /\n * Uint8Array). When `sendResponse` sees this marker, it bypasses the\n * `ReadableStream → reader.read()` pump and writes the body directly to\n * the Node HTTP socket.\n *\n * A WeakMap is used instead of a Symbol property to avoid forcing a\n * hidden-class transition on the Response — Response is a global host\n * object whose IC chain is shared, and adding own properties slows down\n * subsequent `response.headers` / `response.body` accesses.\n *\n * Measured savings (Node 24 / Linux x64, minimal page bench): ~10-15μs/req\n * vs the stream path. See docs/issues/054.\n */\nconst rawBodyByResponse = new WeakMap<Response, string | Uint8Array>();\n\n/**\n * Constructs a Response whose body is a single string (the common HTML\n * render result). Equivalent to `new Response(html, init)` but tagged so\n * `sendResponse` can take its string fast path.\n */\nexport function htmlResponse(html: string, init?: ResponseInit): Response {\n const response = new Response(html, init);\n rawBodyByResponse.set(response, html);\n return response;\n}\n\n/**\n * Constructs a Response whose body is raw bytes (e.g., pre-rendered HTML\n * already encoded, or static assets). Tagged so `sendResponse` writes the\n * bytes directly without going through the stream reader.\n */\nexport function bytesResponse(bytes: Uint8Array, init?: ResponseInit): Response {\n const response = new Response(bytes as BodyInit, init);\n rawBodyByResponse.set(response, bytes);\n return response;\n}\n\n/**\n * Test-only probe: returns true when the Response was constructed via\n * `htmlResponse` / `bytesResponse` and is therefore eligible for the\n * `sendResponse` raw-body fast path. Not part of the public runtime API.\n */\nexport function hasFastPathBody(response: Response): boolean {\n return rawBodyByResponse.has(response);\n}\n\nexport async function sendResponse(\n outgoing: ServerResponse,\n response: Response,\n): Promise<void> {\n outgoing.statusCode = response.status;\n const setCookieHeaders = responseSetCookieHeaders(response.headers);\n response.headers.forEach((value, key) => {\n if (key.toLowerCase() === \"set-cookie\" && setCookieHeaders.length > 0) {\n return;\n }\n outgoing.setHeader(key, value);\n });\n if (setCookieHeaders.length > 0) {\n outgoing.setHeader(\"set-cookie\", setCookieHeaders);\n }\n\n if (response.body === null) {\n outgoing.end();\n return;\n }\n\n // Fast path: when the Response was constructed via `htmlResponse` /\n // `bytesResponse` (i.e., mreact knows the underlying body shape), skip\n // the Response→ReadableStream→reader pump and write directly.\n const rawBody = rawBodyByResponse.get(response);\n if (rawBody !== undefined) {\n outgoing.end(rawBody);\n return;\n }\n\n const reader = response.body.getReader();\n const lifecycle = observeOutgoingFailure(outgoing);\n outgoing.flushHeaders();\n\n try {\n while (true) {\n const result = await readWithAbort(reader, lifecycle.signal);\n\n if (result.done) {\n outgoing.end();\n return;\n }\n\n if (!outgoing.write(result.value)) {\n await waitForDrain(outgoing, lifecycle.signal);\n }\n }\n } catch (error) {\n const reason = error instanceof Error ? error : new Error(String(error));\n try {\n await reader.cancel(reason);\n } catch {\n // The stream may already be errored or cancelled.\n }\n if (!outgoing.destroyed) {\n outgoing.destroy(reason);\n }\n } finally {\n lifecycle.dispose();\n reader.releaseLock();\n }\n}\n\nfunction observeOutgoingFailure(outgoing: ServerResponse): {\n dispose(): void;\n signal: AbortSignal;\n} {\n const controller = new AbortController();\n let disposed = false;\n\n const dispose = (): void => {\n if (disposed) {\n return;\n }\n disposed = true;\n outgoing.off(\"close\", onClose);\n outgoing.off(\"error\", onError);\n };\n const abort = (reason: Error): void => {\n controller.abort(reason);\n dispose();\n };\n const onClose = (): void => {\n abort(new Error(\"The outgoing HTTP response closed during streaming.\"));\n };\n const onError = (error: Error): void => {\n abort(error);\n };\n\n outgoing.once(\"close\", onClose);\n outgoing.once(\"error\", onError);\n if (outgoing.destroyed) {\n onClose();\n }\n\n return { dispose, signal: controller.signal };\n}\n\nfunction readWithAbort(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n signal: AbortSignal,\n): Promise<ReadableStreamReadResult<Uint8Array>> {\n if (signal.aborted) {\n return Promise.reject(abortReason(signal));\n }\n\n return new Promise((resolve, reject) => {\n const onAbort = (): void => {\n signal.removeEventListener(\"abort\", onAbort);\n reject(abortReason(signal));\n };\n signal.addEventListener(\"abort\", onAbort, { once: true });\n void reader.read().then(\n (result) => {\n signal.removeEventListener(\"abort\", onAbort);\n resolve(result);\n },\n (error: unknown) => {\n signal.removeEventListener(\"abort\", onAbort);\n reject(error);\n },\n );\n });\n}\n\nfunction waitForDrain(outgoing: ServerResponse, signal: AbortSignal): Promise<void> {\n if (signal.aborted) {\n return Promise.reject(abortReason(signal));\n }\n\n return new Promise((resolve, reject) => {\n const dispose = (): void => {\n outgoing.off(\"drain\", onDrain);\n signal.removeEventListener(\"abort\", onAbort);\n };\n const onDrain = (): void => {\n dispose();\n resolve();\n };\n const onAbort = (): void => {\n dispose();\n reject(abortReason(signal));\n };\n outgoing.once(\"drain\", onDrain);\n signal.addEventListener(\"abort\", onAbort, { once: true });\n });\n}\n\nfunction abortReason(signal: AbortSignal): Error {\n return signal.reason instanceof Error ? signal.reason : new Error(\"HTTP streaming was aborted.\");\n}\n\nfunction responseSetCookieHeaders(headers: Headers): string[] {\n const getSetCookie = (headers as Headers & { getSetCookie?: () => string[] }).getSetCookie;\n\n if (typeof getSetCookie === \"function\") {\n return getSetCookie.call(headers);\n }\n\n const value = headers.get(\"set-cookie\");\n return value === null ? [] : [value];\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -15,7 +15,8 @@ export { parseMultipartStream } from "./multipart.js";
15
15
  export type { MultipartFixedLengthStream, MultipartStreamFieldOptions, MultipartStreamParseOptions, MultipartStreamPart, } from "./multipart.js";
16
16
  export { getNavigationState, subscribeNavigationState } from "./navigation-state.js";
17
17
  export { getRouterRuntimeCacheStats } from "./runtime-cache.js";
18
- export type { HttpUpgradeHandler } from "./upgrade.js";
18
+ export { validateHttpUpgradeOrigin } from "./upgrade.js";
19
+ export type { HttpUpgradeContext, HttpUpgradeDisposition, HttpUpgradeHandler, HttpUpgradeOriginFailureReason, HttpUpgradeOriginPolicy, HttpUpgradeOriginValidation, ManagedHttpUpgradeHandler, ValidateHttpUpgradeOriginOptions, } from "./upgrade.js";
19
20
  export { cookies, headers, html, isNotFoundError, isRedirectError, json, next, notFound, parseForm, redirect, redirect303, redirectExternal, rewrite, textError, throwNotFound, } from "./navigation.js";
20
21
  export type { MiddlewareNext, ParseSchema, RedirectOptions, RequestCookies } from "./navigation.js";
21
22
  export { createMemoryPrerenderStore } from "./prerender-store.js";
@@ -68,7 +69,7 @@ export type { AppRouterNavigationState, AppRouterNavigationStateListener, AppRou
68
69
  export type { RouterRuntimeCacheStat } from "./runtime-cache.js";
69
70
  /** Configures the deprecated router memory session store alias. */
70
71
  export type { MemorySessionStoreOptions } from "./session.js";
71
- export type { AppRouterCspInlineNonceWarningLogEvent, AppRouterLogError, AppRouterLogEvent, AppRouterLogger, AppRouterLogLevel, AppRouterRuntime, AppRouterRequestEndLogEvent, AppRouterRequestErrorLogEvent, AppRouterRenderTimingLogEvent, AppRouterRequestStartLogEvent, AppRouterRequestTimingLogEvent, } from "./logger.js";
72
+ export type { AppRouterCspInlineNonceWarningLogEvent, AppRouterLogError, AppRouterLogEvent, AppRouterLogger, AppRouterLogLevel, AppRouterRuntime, AppRouterRequestEndLogEvent, AppRouterRequestErrorLogEvent, AppRouterRenderTimingLogEvent, AppRouterRequestStartLogEvent, AppRouterRequestTimingLogEvent, AppRouterUpgradeErrorLogEvent, AppRouterUpgradeRejectedLogEvent, } from "./logger.js";
72
73
  export type { DetectedLocale, LocaleRoutingOptions, MessageTree } from "./i18n.js";
73
74
  export { createFormCsrfToken, formCsrfCookie, formCsrfFieldName, validateFormCsrf, } from "./csrf.js";
74
75
  export type { AppRouterAllowedServerAction, AppRouterServerActionOptions, PreparedFormActionReference, } from "./actions.js";
@@ -93,7 +94,7 @@ export type { SessionStore } from "./session.js";
93
94
  export { startDevServer } from "./dev-server.js";
94
95
  export type { StartDevServerOptions } from "./dev-server.js";
95
96
  export { renderAppRequest } from "./render.js";
96
- export type { AppRouterRenderPreload, AppRouterResponseHook, AppRouterResponseHookContext, RenderAppRequestOptions, } from "./render.js";
97
+ export type { AppRouterRenderPreload, AppRouterResponseHook, AppRouterResponseHookContext, AppRouterServerRenderArtifactLoader, RenderAppRequestOptions, } from "./render.js";
97
98
  export { parseTraceContext, traceContextFromRequest } from "./trace.js";
98
99
  export type { RouterInstrumentation, RouterMiddlewareEndInstrumentationEvent, RouterMiddlewareInstrumentationEvent, RouterRequestEndInstrumentationEvent, RouterRequestInstrumentationEvent, RouterRouteEndInstrumentationEvent, RouterRouteInstrumentationEvent, RouterTraceContext, } from "./trace.js";
99
100
  export type { FileSystemPrerenderStoreOptions, KeyValuePrerenderStoreAdapter, KeyValuePrerenderStoreOptions, MemoryPrerenderStoreEntry, MemoryPrerenderStoreOptions, } from "./prerender-store.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,EAA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AAY,CAAC;AACpB,YAAY,EACV,+BAA+B,EAC/B,6BAA6B,EAC7B,6BAA6B,EAC7B,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,8BAA8B,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACxF,YAAY,EACV,0BAA0B,EAC1B,uBAAuB,EACvB,8BAA8B,EAC9B,4BAA4B,EAC5B,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EACV,uBAAuB,EACvB,oBAAoB,EACpB,kCAAkC,EAClC,0BAA0B,EAC1B,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACtE,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,WAAW,GACZ,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ export { href } from "./typed-routes.js";
11
11
  export { parseMultipartStream } from "./multipart.js";
12
12
  export { getNavigationState, subscribeNavigationState } from "./navigation-state.js";
13
13
  export { getRouterRuntimeCacheStats } from "./runtime-cache.js";
14
+ export { validateHttpUpgradeOrigin } from "./upgrade.js";
14
15
  export { cookies, headers, html, isNotFoundError, isRedirectError, json, next, notFound, parseForm, redirect, redirect303, redirectExternal, rewrite, textError, throwNotFound, } from "./navigation.js";
15
16
  export { createMemoryPrerenderStore } from "./prerender-store.js";
16
17
  export { getServerRuntimeState } from "./runtime-state.js";
package/dist/index.js.map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nB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAO/C,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAkBxE,OAAO,EAAE,8BAA8B,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAUxF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { buildApp, packageAwsLambdaArtifact, packageCloudflarePagesArtifact } from \"./build.js\";\nexport { assetHref, assetPreloadLinks } from \"./assets.js\";\nexport {\n analyzeAppBoundaries,\n createBoundaryReport,\n formatBoundaryReport,\n formatBoundaryReportJson,\n} from \"./boundaries.js\";\nexport type {\n AnalyzeAppBoundariesOptions,\n BoundaryReport,\n BoundaryReportComponent,\n BoundaryReportRoute,\n BoundaryReportSummary,\n CreateBoundaryReportInput,\n CreateBoundaryReportRouteInput,\n} from \"./boundaries.js\";\nexport { cacheControl, createMemoryRouteCache, revalidatePath } from \"./cache.js\";\nexport { deleteCookie, parseCookieHeader, serializeCookie, setCookie } from \"./cookies.js\";\nexport { defineMessages, detectLocale } from \"./i18n.js\";\nexport { defer, isDeferredLoaderData } from \"./deferred.js\";\nexport type { DeferredLoaderData } from \"./deferred.js\";\nexport { definePage } from \"./types.js\";\nexport { Link, linkProps } from \"./link.js\";\nexport type { LinkSerializableAttribute, LinkSinkChild, LinkSinkProps } from \"./link.js\";\nexport { href } from \"./typed-routes.js\";\nexport { parseMultipartStream } from \"./multipart.js\";\nexport type {\n MultipartFixedLengthStream,\n MultipartStreamFieldOptions,\n MultipartStreamParseOptions,\n MultipartStreamPart,\n} from \"./multipart.js\";\nexport { getNavigationState, subscribeNavigationState } from \"./navigation-state.js\";\nexport { getRouterRuntimeCacheStats } from \"./runtime-cache.js\";\nexport type { HttpUpgradeHandler } from \"./upgrade.js\";\nexport {\n cookies,\n headers,\n html,\n isNotFoundError,\n isRedirectError,\n json,\n next,\n notFound,\n parseForm,\n redirect,\n redirect303,\n redirectExternal,\n rewrite,\n textError,\n throwNotFound,\n} from \"./navigation.js\";\nexport type { MiddlewareNext, ParseSchema, RedirectOptions, RequestCookies } from \"./navigation.js\";\nexport { createMemoryPrerenderStore } from \"./prerender-store.js\";\nexport { getServerRuntimeState } from \"./runtime-state.js\";\nimport {\n createMemorySessionStore as createMemorySessionStoreInternal,\n createSession as createSessionInternal,\n destroySession as destroySessionInternal,\n getSession as getSessionInternal,\n rotateSession as rotateSessionInternal,\n} from \"./session.js\";\nimport type {\n MemorySessionStoreOptions as MemorySessionStoreOptionsInternal,\n SessionCookieOptions as SessionCookieOptionsInternal,\n SessionRecord as SessionRecordInternal,\n SessionStore as SessionStoreInternal,\n} from \"./session.js\";\n\n/**\n * Creates a deprecated process-local session store alias.\n *\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport function createMemorySessionStore<TData = unknown>(\n options: MemorySessionStoreOptionsInternal = {},\n): SessionStoreInternal<TData> {\n return createMemorySessionStoreInternal<TData>(options);\n}\n/**\n * Creates a deprecated session record and cookie alias.\n *\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport async function createSession<TData>(\n response: Response,\n store: SessionStoreInternal<TData>,\n data: TData,\n options: SessionCookieOptionsInternal = {},\n): Promise<SessionRecordInternal<TData>> {\n return createSessionInternal(response, store, data, options);\n}\n/**\n * Destroys a session through a deprecated router session alias.\n *\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport async function destroySession<TData>(\n request: Request,\n response: Response,\n store: SessionStoreInternal<TData>,\n options: SessionCookieOptionsInternal = {},\n): Promise<void> {\n return destroySessionInternal(request, response, store, options);\n}\n/**\n * Reads a session through a deprecated router session alias.\n *\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport async function getSession<TData>(\n request: Request,\n store: SessionStoreInternal<TData>,\n options: SessionCookieOptionsInternal = {},\n): Promise<SessionRecordInternal<TData> | undefined> {\n return getSessionInternal(request, store, options);\n}\n/**\n * Rotates a session through a deprecated router session alias.\n *\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport async function rotateSession<TData>(\n request: Request,\n response: Response,\n store: SessionStoreInternal<TData>,\n options: SessionCookieOptionsInternal = {},\n): Promise<SessionRecordInternal<TData> | undefined> {\n return rotateSessionInternal(request, response, store, options);\n}\nexport type {\n AwsLambdaArtifactManifest,\n AwsLambdaGeneratedHandlerPreloadMode,\n BuildAppPhase,\n BuildAppPhaseTiming,\n BuildAppOptions,\n BuildAppProgressEvent,\n BuildAppResult,\n BuiltImportPolicyArtifact,\n BuiltPrerenderedRoute,\n BuiltRouteSourceAnalysisSummary,\n BuiltServerModuleArtifact,\n BuiltServerModuleOutput,\n CloudflarePagesArtifactManifest,\n PackageAwsLambdaArtifactOptions,\n PackageCloudflarePagesArtifactOptions,\n} from \"./build.js\";\nexport type { AppRouterProjectOptions } from \"./config.js\";\nexport type { ServerActionContext } from \"./actions.js\";\nexport type {\n AppRouteHref,\n AppRouteLinkHref,\n AppRouteLinkHrefSuffix,\n AppRouteLinkPathname,\n AppRouteLinkSegment,\n AppRouteLinkSegments,\n DynamicHrefOptions,\n RouteParamsFor,\n RouteSearchParams,\n RouteSearchValue,\n SegmentRouteParam,\n StaticHrefOptions,\n ExtractRouteParams,\n HasRouteParams,\n Simplify,\n} from \"./typed-routes.js\";\nexport type {\n InferLoaderData,\n InferLoaderParams,\n LayoutProps,\n LoaderContext,\n GenerateMetadataContext,\n ManifestContext,\n ManifestDescriptor,\n MetadataImage,\n MetadataScalar,\n MetadataThemeColor,\n MetadataViewport,\n MReactNode,\n PageProps,\n PageComponent,\n RobotsContext,\n RobotsManifest,\n RobotsRule,\n RouteHeadDescriptor,\n RouteHandlerContext,\n RouteLoader,\n RouteMetadata,\n RouteParams,\n RouteSecurityHeaders,\n RouteStrictTransportSecurity,\n SitemapContext,\n SitemapEntry,\n} from \"./types.js\";\nexport type {\n AppRouterBuildTarget,\n AppRouterClientConsoleMethod,\n AppRouterClientSourceMapMode,\n AppRouterClientSourceMapOption,\n AppRouterProductionOptions,\n} from \"./config.js\";\nexport type {\n AssetHelperOptions,\n AssetLinkDescriptor,\n AssetManifest,\n AssetManifestEntry,\n} from \"./assets.js\";\nexport type {\n AppRouterCache,\n AppRouterCacheEntry,\n CacheControlOptions,\n MemoryRouteCacheOptions,\n RouteCachePolicy,\n} from \"./cache.js\";\nexport type { CookieOptions } from \"./cookies.js\";\nexport type { AppRouterImportPolicy } from \"./import-policy.js\";\n/** Re-exports link types used by the router root entrypoint. */\nexport type {\n AppRouteDeclarations,\n ConcreteLinkHrefGuard,\n LinkChild,\n LinkHref,\n LinkOptions,\n LinkPrefetch,\n LinkProps,\n RegisteredAppRoutePath,\n LinkScroll,\n LinkTransition,\n TrustedLinkHtml,\n} from \"./link.js\";\n/** Re-exports client navigation state types used by the router root entrypoint. */\nexport type {\n AppRouterNavigationState,\n AppRouterNavigationStateListener,\n AppRouterNavigationType,\n} from \"./navigation-state.js\";\nexport type { RouterRuntimeCacheStat } from \"./runtime-cache.js\";\n/** Configures the deprecated router memory session store alias. */\nexport type { MemorySessionStoreOptions } from \"./session.js\";\nexport type {\n AppRouterCspInlineNonceWarningLogEvent,\n AppRouterLogError,\n AppRouterLogEvent,\n AppRouterLogger,\n AppRouterLogLevel,\n AppRouterRuntime,\n AppRouterRequestEndLogEvent,\n AppRouterRequestErrorLogEvent,\n AppRouterRenderTimingLogEvent,\n AppRouterRequestStartLogEvent,\n AppRouterRequestTimingLogEvent,\n} from \"./logger.js\";\nexport type { DetectedLocale, LocaleRoutingOptions, MessageTree } from \"./i18n.js\";\nexport {\n createFormCsrfToken,\n formCsrfCookie,\n formCsrfFieldName,\n validateFormCsrf,\n} from \"./csrf.js\";\nexport type {\n AppRouterAllowedServerAction,\n AppRouterServerActionOptions,\n PreparedFormActionReference,\n} from \"./actions.js\";\n/**\n * Configures the deprecated router session cookie alias.\n *\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type { SessionCookieOptions } from \"./session.js\";\n/**\n * Stores session data through the deprecated router session record alias.\n *\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type { SessionRecord } from \"./session.js\";\n/**\n * Defines session persistence through the deprecated router session store alias.\n *\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type { SessionStore } from \"./session.js\";\nexport { startDevServer } from \"./dev-server.js\";\nexport type { StartDevServerOptions } from \"./dev-server.js\";\nexport { renderAppRequest } from \"./render.js\";\nexport type {\n AppRouterRenderPreload,\n AppRouterResponseHook,\n AppRouterResponseHookContext,\n RenderAppRequestOptions,\n} from \"./render.js\";\nexport { parseTraceContext, traceContextFromRequest } from \"./trace.js\";\nexport type {\n RouterInstrumentation,\n RouterMiddlewareEndInstrumentationEvent,\n RouterMiddlewareInstrumentationEvent,\n RouterRequestEndInstrumentationEvent,\n RouterRequestInstrumentationEvent,\n RouterRouteEndInstrumentationEvent,\n RouterRouteInstrumentationEvent,\n RouterTraceContext,\n} from \"./trace.js\";\nexport type {\n FileSystemPrerenderStoreOptions,\n KeyValuePrerenderStoreAdapter,\n KeyValuePrerenderStoreOptions,\n MemoryPrerenderStoreEntry,\n MemoryPrerenderStoreOptions,\n} from \"./prerender-store.js\";\nexport { createFileSystemPrerenderStore, createKeyValuePrerenderStore } from \"./prerender-store.js\";\nexport { preloadBuiltAppRuntime, renderBuiltAppRequest, startServer } from \"./serve.js\";\nexport type {\n BuiltAppRuntimePreloadMode,\n AppRouterPrerenderStore,\n BuiltAppRuntimePreloadStrategy,\n RenderBuiltAppRequestOptions,\n RequestHostPolicy,\n ResponseSinkStrategy,\n StartServerOptions,\n} from \"./serve.js\";\nexport { matchRoute, scanAppRoutes } from \"./routes.js\";\nexport type {\n CachedClientRouteSource,\n ClientRouteComponent,\n ClientRouteComponentClassification,\n ClientRouteComponentOrigin,\n ClientRouteInferenceCache,\n ClientRouteInferenceDiagnostic,\n} from \"./client.js\";\nexport type { RouteMatcher, ScanAppRoutesOptions } from \"./routes.js\";\nexport type { AppFileConvention } from \"./file-conventions.js\";\nexport type {\n AppAssetRoute,\n AppMetadataRoute,\n AppRoute,\n MatchedRoute,\n PageRoute,\n RouteSegment,\n ServerRoute,\n} from \"./routes.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAOtD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAA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AC,CAAC;AACrD,CAAC;AACD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAgB,EAChB,QAAkB,EAClB,KAAkC,EAClC,OAAO,GAAiC,EAAE;IAE1C,OAAO,qBAAqB,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC;AA8HD,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAwBnB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAQ/C,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAkBxE,OAAO,EAAE,8BAA8B,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAUxF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { buildApp, packageAwsLambdaArtifact, packageCloudflarePagesArtifact } from \"./build.js\";\nexport { assetHref, assetPreloadLinks } from \"./assets.js\";\nexport {\n analyzeAppBoundaries,\n createBoundaryReport,\n formatBoundaryReport,\n formatBoundaryReportJson,\n} from \"./boundaries.js\";\nexport type {\n AnalyzeAppBoundariesOptions,\n BoundaryReport,\n BoundaryReportComponent,\n BoundaryReportRoute,\n BoundaryReportSummary,\n CreateBoundaryReportInput,\n CreateBoundaryReportRouteInput,\n} from \"./boundaries.js\";\nexport { cacheControl, createMemoryRouteCache, revalidatePath } from \"./cache.js\";\nexport { deleteCookie, parseCookieHeader, serializeCookie, setCookie } from \"./cookies.js\";\nexport { defineMessages, detectLocale } from \"./i18n.js\";\nexport { defer, isDeferredLoaderData } from \"./deferred.js\";\nexport type { DeferredLoaderData } from \"./deferred.js\";\nexport { definePage } from \"./types.js\";\nexport { Link, linkProps } from \"./link.js\";\nexport type { LinkSerializableAttribute, LinkSinkChild, LinkSinkProps } from \"./link.js\";\nexport { href } from \"./typed-routes.js\";\nexport { parseMultipartStream } from \"./multipart.js\";\nexport type {\n MultipartFixedLengthStream,\n MultipartStreamFieldOptions,\n MultipartStreamParseOptions,\n MultipartStreamPart,\n} from \"./multipart.js\";\nexport { getNavigationState, subscribeNavigationState } from \"./navigation-state.js\";\nexport { getRouterRuntimeCacheStats } from \"./runtime-cache.js\";\nexport { validateHttpUpgradeOrigin } from \"./upgrade.js\";\nexport type {\n HttpUpgradeContext,\n HttpUpgradeDisposition,\n HttpUpgradeHandler,\n HttpUpgradeOriginFailureReason,\n HttpUpgradeOriginPolicy,\n HttpUpgradeOriginValidation,\n ManagedHttpUpgradeHandler,\n ValidateHttpUpgradeOriginOptions,\n} from \"./upgrade.js\";\nexport {\n cookies,\n headers,\n html,\n isNotFoundError,\n isRedirectError,\n json,\n next,\n notFound,\n parseForm,\n redirect,\n redirect303,\n redirectExternal,\n rewrite,\n textError,\n throwNotFound,\n} from \"./navigation.js\";\nexport type { MiddlewareNext, ParseSchema, RedirectOptions, RequestCookies } from \"./navigation.js\";\nexport { createMemoryPrerenderStore } from \"./prerender-store.js\";\nexport { getServerRuntimeState } from \"./runtime-state.js\";\nimport {\n createMemorySessionStore as createMemorySessionStoreInternal,\n createSession as createSessionInternal,\n destroySession as destroySessionInternal,\n getSession as getSessionInternal,\n rotateSession as rotateSessionInternal,\n} from \"./session.js\";\nimport type {\n MemorySessionStoreOptions as MemorySessionStoreOptionsInternal,\n SessionCookieOptions as SessionCookieOptionsInternal,\n SessionRecord as SessionRecordInternal,\n SessionStore as SessionStoreInternal,\n} from \"./session.js\";\n\n/**\n * Creates a deprecated process-local session store alias.\n *\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport function createMemorySessionStore<TData = unknown>(\n options: MemorySessionStoreOptionsInternal = {},\n): SessionStoreInternal<TData> {\n return createMemorySessionStoreInternal<TData>(options);\n}\n/**\n * Creates a deprecated session record and cookie alias.\n *\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport async function createSession<TData>(\n response: Response,\n store: SessionStoreInternal<TData>,\n data: TData,\n options: SessionCookieOptionsInternal = {},\n): Promise<SessionRecordInternal<TData>> {\n return createSessionInternal(response, store, data, options);\n}\n/**\n * Destroys a session through a deprecated router session alias.\n *\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport async function destroySession<TData>(\n request: Request,\n response: Response,\n store: SessionStoreInternal<TData>,\n options: SessionCookieOptionsInternal = {},\n): Promise<void> {\n return destroySessionInternal(request, response, store, options);\n}\n/**\n * Reads a session through a deprecated router session alias.\n *\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport async function getSession<TData>(\n request: Request,\n store: SessionStoreInternal<TData>,\n options: SessionCookieOptionsInternal = {},\n): Promise<SessionRecordInternal<TData> | undefined> {\n return getSessionInternal(request, store, options);\n}\n/**\n * Rotates a session through a deprecated router session alias.\n *\n * @deprecated Import session helpers from `@reckona/mreact-auth` instead.\n */\nexport async function rotateSession<TData>(\n request: Request,\n response: Response,\n store: SessionStoreInternal<TData>,\n options: SessionCookieOptionsInternal = {},\n): Promise<SessionRecordInternal<TData> | undefined> {\n return rotateSessionInternal(request, response, store, options);\n}\nexport type {\n AwsLambdaArtifactManifest,\n AwsLambdaGeneratedHandlerPreloadMode,\n BuildAppPhase,\n BuildAppPhaseTiming,\n BuildAppOptions,\n BuildAppProgressEvent,\n BuildAppResult,\n BuiltImportPolicyArtifact,\n BuiltPrerenderedRoute,\n BuiltRouteSourceAnalysisSummary,\n BuiltServerModuleArtifact,\n BuiltServerModuleOutput,\n CloudflarePagesArtifactManifest,\n PackageAwsLambdaArtifactOptions,\n PackageCloudflarePagesArtifactOptions,\n} from \"./build.js\";\nexport type { AppRouterProjectOptions } from \"./config.js\";\nexport type { ServerActionContext } from \"./actions.js\";\nexport type {\n AppRouteHref,\n AppRouteLinkHref,\n AppRouteLinkHrefSuffix,\n AppRouteLinkPathname,\n AppRouteLinkSegment,\n AppRouteLinkSegments,\n DynamicHrefOptions,\n RouteParamsFor,\n RouteSearchParams,\n RouteSearchValue,\n SegmentRouteParam,\n StaticHrefOptions,\n ExtractRouteParams,\n HasRouteParams,\n Simplify,\n} from \"./typed-routes.js\";\nexport type {\n InferLoaderData,\n InferLoaderParams,\n LayoutProps,\n LoaderContext,\n GenerateMetadataContext,\n ManifestContext,\n ManifestDescriptor,\n MetadataImage,\n MetadataScalar,\n MetadataThemeColor,\n MetadataViewport,\n MReactNode,\n PageProps,\n PageComponent,\n RobotsContext,\n RobotsManifest,\n RobotsRule,\n RouteHeadDescriptor,\n RouteHandlerContext,\n RouteLoader,\n RouteMetadata,\n RouteParams,\n RouteSecurityHeaders,\n RouteStrictTransportSecurity,\n SitemapContext,\n SitemapEntry,\n} from \"./types.js\";\nexport type {\n AppRouterBuildTarget,\n AppRouterClientConsoleMethod,\n AppRouterClientSourceMapMode,\n AppRouterClientSourceMapOption,\n AppRouterProductionOptions,\n} from \"./config.js\";\nexport type {\n AssetHelperOptions,\n AssetLinkDescriptor,\n AssetManifest,\n AssetManifestEntry,\n} from \"./assets.js\";\nexport type {\n AppRouterCache,\n AppRouterCacheEntry,\n CacheControlOptions,\n MemoryRouteCacheOptions,\n RouteCachePolicy,\n} from \"./cache.js\";\nexport type { CookieOptions } from \"./cookies.js\";\nexport type { AppRouterImportPolicy } from \"./import-policy.js\";\n/** Re-exports link types used by the router root entrypoint. */\nexport type {\n AppRouteDeclarations,\n ConcreteLinkHrefGuard,\n LinkChild,\n LinkHref,\n LinkOptions,\n LinkPrefetch,\n LinkProps,\n RegisteredAppRoutePath,\n LinkScroll,\n LinkTransition,\n TrustedLinkHtml,\n} from \"./link.js\";\n/** Re-exports client navigation state types used by the router root entrypoint. */\nexport type {\n AppRouterNavigationState,\n AppRouterNavigationStateListener,\n AppRouterNavigationType,\n} from \"./navigation-state.js\";\nexport type { RouterRuntimeCacheStat } from \"./runtime-cache.js\";\n/** Configures the deprecated router memory session store alias. */\nexport type { MemorySessionStoreOptions } from \"./session.js\";\nexport type {\n AppRouterCspInlineNonceWarningLogEvent,\n AppRouterLogError,\n AppRouterLogEvent,\n AppRouterLogger,\n AppRouterLogLevel,\n AppRouterRuntime,\n AppRouterRequestEndLogEvent,\n AppRouterRequestErrorLogEvent,\n AppRouterRenderTimingLogEvent,\n AppRouterRequestStartLogEvent,\n AppRouterRequestTimingLogEvent,\n AppRouterUpgradeErrorLogEvent,\n AppRouterUpgradeRejectedLogEvent,\n} from \"./logger.js\";\nexport type { DetectedLocale, LocaleRoutingOptions, MessageTree } from \"./i18n.js\";\nexport {\n createFormCsrfToken,\n formCsrfCookie,\n formCsrfFieldName,\n validateFormCsrf,\n} from \"./csrf.js\";\nexport type {\n AppRouterAllowedServerAction,\n AppRouterServerActionOptions,\n PreparedFormActionReference,\n} from \"./actions.js\";\n/**\n * Configures the deprecated router session cookie alias.\n *\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type { SessionCookieOptions } from \"./session.js\";\n/**\n * Stores session data through the deprecated router session record alias.\n *\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type { SessionRecord } from \"./session.js\";\n/**\n * Defines session persistence through the deprecated router session store alias.\n *\n * @deprecated Import session helpers and types from `@reckona/mreact-auth` instead.\n */\nexport type { SessionStore } from \"./session.js\";\nexport { startDevServer } from \"./dev-server.js\";\nexport type { StartDevServerOptions } from \"./dev-server.js\";\nexport { renderAppRequest } from \"./render.js\";\nexport type {\n AppRouterRenderPreload,\n AppRouterResponseHook,\n AppRouterResponseHookContext,\n AppRouterServerRenderArtifactLoader,\n RenderAppRequestOptions,\n} from \"./render.js\";\nexport { parseTraceContext, traceContextFromRequest } from \"./trace.js\";\nexport type {\n RouterInstrumentation,\n RouterMiddlewareEndInstrumentationEvent,\n RouterMiddlewareInstrumentationEvent,\n RouterRequestEndInstrumentationEvent,\n RouterRequestInstrumentationEvent,\n RouterRouteEndInstrumentationEvent,\n RouterRouteInstrumentationEvent,\n RouterTraceContext,\n} from \"./trace.js\";\nexport type {\n FileSystemPrerenderStoreOptions,\n KeyValuePrerenderStoreAdapter,\n KeyValuePrerenderStoreOptions,\n MemoryPrerenderStoreEntry,\n MemoryPrerenderStoreOptions,\n} from \"./prerender-store.js\";\nexport { createFileSystemPrerenderStore, createKeyValuePrerenderStore } from \"./prerender-store.js\";\nexport { preloadBuiltAppRuntime, renderBuiltAppRequest, startServer } from \"./serve.js\";\nexport type {\n BuiltAppRuntimePreloadMode,\n AppRouterPrerenderStore,\n BuiltAppRuntimePreloadStrategy,\n RenderBuiltAppRequestOptions,\n RequestHostPolicy,\n ResponseSinkStrategy,\n StartServerOptions,\n} from \"./serve.js\";\nexport { matchRoute, scanAppRoutes } from \"./routes.js\";\nexport type {\n CachedClientRouteSource,\n ClientRouteComponent,\n ClientRouteComponentClassification,\n ClientRouteComponentOrigin,\n ClientRouteInferenceCache,\n ClientRouteInferenceDiagnostic,\n} from \"./client.js\";\nexport type { RouteMatcher, ScanAppRoutesOptions } from \"./routes.js\";\nexport type { AppFileConvention } from \"./file-conventions.js\";\nexport type {\n AppAssetRoute,\n AppMetadataRoute,\n AppRoute,\n MatchedRoute,\n PageRoute,\n RouteSegment,\n ServerRoute,\n} from \"./routes.js\";\n"]}
package/dist/logger.d.ts CHANGED
@@ -18,7 +18,7 @@ export interface AppRouterLogger {
18
18
  /**
19
19
  * Represents every structured log event emitted by the app router.
20
20
  */
21
- export type AppRouterLogEvent = AppRouterRequestStartLogEvent | AppRouterRequestEndLogEvent | AppRouterRequestErrorLogEvent | AppRouterRequestTimingLogEvent | AppRouterRenderTimingLogEvent | AppRouterCspInlineNonceWarningLogEvent;
21
+ export type AppRouterLogEvent = AppRouterRequestStartLogEvent | AppRouterRequestEndLogEvent | AppRouterRequestErrorLogEvent | AppRouterRequestTimingLogEvent | AppRouterRenderTimingLogEvent | AppRouterCspInlineNonceWarningLogEvent | AppRouterUpgradeErrorLogEvent | AppRouterUpgradeRejectedLogEvent;
22
22
  /**
23
23
  * Logs the start of an app-router request.
24
24
  */
@@ -50,6 +50,27 @@ export interface AppRouterRequestErrorLogEvent {
50
50
  runtime: AppRouterRuntime;
51
51
  type: "router:request:error";
52
52
  }
53
+ /**
54
+ * Logs a failed or timed-out HTTP upgrade handler.
55
+ */
56
+ export interface AppRouterUpgradeErrorLogEvent {
57
+ durationMs: number;
58
+ error: AppRouterLogError;
59
+ method: string;
60
+ path: string;
61
+ runtime: "node";
62
+ type: "router:upgrade:error";
63
+ }
64
+ /**
65
+ * Logs an HTTP upgrade rejected before application ownership.
66
+ */
67
+ export interface AppRouterUpgradeRejectedLogEvent {
68
+ method: string;
69
+ path: string;
70
+ reason: "disallowed-origin" | "malformed-origin" | "missing-origin" | "opaque-origin";
71
+ runtime: "node";
72
+ type: "router:upgrade:rejected";
73
+ }
53
74
  /**
54
75
  * Logs per-phase timings for a complete app-router request.
55
76
  */
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IACzE,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IACzE,IAAI,CAAC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,CAAC;IACf,IAAI,EAAE,sBAAsB,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,sCAAsC;IACrD,SAAS,EAAE,YAAY,GAAG,WAAW,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC;IACxB,IAAI,EAAE,iCAAiC,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,eAAe,GAAG,SAAS,EACnC,KAAK,EAAE,iBAAiB,EACxB,KAAK,EAAE,iBAAiB,GACvB,IAAI,CAuBN;AAWD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,gBAAgB,GACxB,sBAAsB,CAMxB;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAU/D;AAED,wBAAgB,MAAM,IAAI,MAAM,CAE/B;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAmB1D"}
package/dist/logger.js CHANGED
@@ -1,5 +1,11 @@
1
1
  export function emitRouterLog(logger, level, event) {
2
- const sink = logger?.[level];
2
+ let sink;
3
+ try {
4
+ sink = logger?.[level];
5
+ }
6
+ catch {
7
+ return;
8
+ }
3
9
  if (sink === undefined) {
4
10
  return;
5
11
  }
@@ -46,15 +52,23 @@ export function logDurationMs(startedAt) {
46
52
  return Math.max(0, Math.round((logNow() - startedAt) * 1000) / 1000);
47
53
  }
48
54
  export function logError(error) {
49
- if (error instanceof Error) {
55
+ try {
56
+ if (error instanceof Error) {
57
+ return {
58
+ message: String(error.message),
59
+ name: String(error.name),
60
+ };
61
+ }
50
62
  return {
51
- message: error.message,
52
- name: error.name,
63
+ message: String(error),
64
+ name: "Error",
65
+ };
66
+ }
67
+ catch {
68
+ return {
69
+ message: "Unknown non-coercible error",
70
+ name: "Error",
53
71
  };
54
72
  }
55
- return {
56
- message: String(error),
57
- name: "Error",
58
- };
59
73
  }
60
74
  //# sourceMappingURL=logger.js.map