@ngrok/app-server 0.1.1 → 0.3.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.
Files changed (105) hide show
  1. package/README.md +659 -70
  2. package/dist/build-id-C6sYO9Yp.js +126 -0
  3. package/dist/build-id-C6sYO9Yp.js.map +1 -0
  4. package/dist/build-manifest-UDNk81Ce.js +63 -0
  5. package/dist/build-manifest-UDNk81Ce.js.map +1 -0
  6. package/dist/{bun-DCGnDEPn.js → bun-BCz6K_Xv.js} +12 -8
  7. package/dist/bun-BCz6K_Xv.js.map +1 -0
  8. package/dist/cli.js +47 -27
  9. package/dist/cli.js.map +1 -1
  10. package/dist/client.d.ts +141 -0
  11. package/dist/client.js +326 -0
  12. package/dist/client.js.map +1 -0
  13. package/dist/compression-7_gToa8R.js +97 -0
  14. package/dist/compression-7_gToa8R.js.map +1 -0
  15. package/dist/create-server-iE1-s6Bi.js +1409 -0
  16. package/dist/create-server-iE1-s6Bi.js.map +1 -0
  17. package/dist/{deno-BnMfk2n1.js → deno-aqhikNMG.js} +5 -5
  18. package/dist/deno-aqhikNMG.js.map +1 -0
  19. package/dist/entry-DZ3qo7qF.js +116 -0
  20. package/dist/entry-DZ3qo7qF.js.map +1 -0
  21. package/dist/entry-DmJEqVfd.d.ts +622 -0
  22. package/dist/gzip-Doi4wqjX.js +294 -0
  23. package/dist/gzip-Doi4wqjX.js.map +1 -0
  24. package/dist/header-hook-Vzw9J9BY.js +159 -0
  25. package/dist/header-hook-Vzw9J9BY.js.map +1 -0
  26. package/dist/index-Bo5G9LuQ.d.ts +127 -0
  27. package/dist/index.d.ts +110 -95
  28. package/dist/index.js +56 -57
  29. package/dist/index.js.map +1 -1
  30. package/dist/{listen-options-DHWmSWGi.js → listen-options-7TaXjyrk.js} +2 -2
  31. package/dist/listen-options-7TaXjyrk.js.map +1 -0
  32. package/dist/load-entry-AfYS_zS9.js +37 -0
  33. package/dist/load-entry-AfYS_zS9.js.map +1 -0
  34. package/dist/log-BP6xXXZl.js +122 -0
  35. package/dist/log-BP6xXXZl.js.map +1 -0
  36. package/dist/node-BFH82eeL.js +333 -0
  37. package/dist/node-BFH82eeL.js.map +1 -0
  38. package/dist/node-tBVQPjQv.js +41 -0
  39. package/dist/node-tBVQPjQv.js.map +1 -0
  40. package/dist/node-vite.d.ts +11 -0
  41. package/dist/node-vite.js +3 -0
  42. package/dist/node.d.ts +86 -0
  43. package/dist/node.js +4 -0
  44. package/dist/react-router-vite.d.ts +10 -0
  45. package/dist/react-router-vite.js +3 -0
  46. package/dist/react-router.d.ts +11 -24
  47. package/dist/react-router.js +21 -30
  48. package/dist/react-router.js.map +1 -1
  49. package/dist/request-context-BtQ87VYb.js +40 -0
  50. package/dist/request-context-BtQ87VYb.js.map +1 -0
  51. package/dist/response-edge-Bc1-C_Cx.js +327 -0
  52. package/dist/response-edge-Bc1-C_Cx.js.map +1 -0
  53. package/dist/response-writer-B7FoJjEE.js +289 -0
  54. package/dist/response-writer-B7FoJjEE.js.map +1 -0
  55. package/dist/script-hashes-hqUk6kG7.js +53 -0
  56. package/dist/script-hashes-hqUk6kG7.js.map +1 -0
  57. package/dist/serve-CDNgThjk.js +29 -0
  58. package/dist/serve-CDNgThjk.js.map +1 -0
  59. package/dist/{start-BVMb8Pyt.js → start-TLIprD74.js} +96 -81
  60. package/dist/start-TLIprD74.js.map +1 -0
  61. package/dist/static-files-Beju9riB.js +302 -0
  62. package/dist/static-files-Beju9riB.js.map +1 -0
  63. package/dist/tanstack-start-vite.d.ts +12 -0
  64. package/dist/tanstack-start-vite.js +3 -0
  65. package/dist/tanstack-start.d.ts +34 -0
  66. package/dist/tanstack-start.js +41 -0
  67. package/dist/tanstack-start.js.map +1 -0
  68. package/dist/{tcp-Dau_IONd.js → tcp-Dd1Mt6sN.js} +8 -7
  69. package/dist/tcp-Dd1Mt6sN.js.map +1 -0
  70. package/dist/trailing-slash-DX7NB88H.d.ts +36 -0
  71. package/dist/types-DLYxYS6M.d.ts +392 -0
  72. package/dist/vercel-vite.d.ts +35 -0
  73. package/dist/vercel-vite.js +142 -0
  74. package/dist/vercel-vite.js.map +1 -0
  75. package/dist/vercel.d.ts +35 -0
  76. package/dist/vercel.js +89 -0
  77. package/dist/vercel.js.map +1 -0
  78. package/dist/vite-B-GfswoH.js +22 -0
  79. package/dist/vite-B-GfswoH.js.map +1 -0
  80. package/dist/vite-D4hfj3ph.js +19 -0
  81. package/dist/vite-D4hfj3ph.js.map +1 -0
  82. package/dist/vite-DyrhyKEr.js +25 -0
  83. package/dist/vite-DyrhyKEr.js.map +1 -0
  84. package/dist/vite-iioAoxSt.js +752 -0
  85. package/dist/vite-iioAoxSt.js.map +1 -0
  86. package/dist/vite.d.ts +2 -27
  87. package/dist/vite.js +2 -2
  88. package/package.json +50 -4
  89. package/dist/bun-DCGnDEPn.js.map +0 -1
  90. package/dist/captured-headers-ewL_t3MQ.js +0 -48
  91. package/dist/captured-headers-ewL_t3MQ.js.map +0 -1
  92. package/dist/deno-BnMfk2n1.js.map +0 -1
  93. package/dist/entry-CIpwaayZ.d.ts +0 -293
  94. package/dist/entry-ChjmFwX5.js +0 -755
  95. package/dist/entry-ChjmFwX5.js.map +0 -1
  96. package/dist/listen-options-DHWmSWGi.js.map +0 -1
  97. package/dist/node-2wWBMFeO.js +0 -3
  98. package/dist/node-79my3Uix.js +0 -58
  99. package/dist/node-79my3Uix.js.map +0 -1
  100. package/dist/serve-ByeedcRB.js +0 -16
  101. package/dist/serve-ByeedcRB.js.map +0 -1
  102. package/dist/start-BVMb8Pyt.js.map +0 -1
  103. package/dist/tcp-Dau_IONd.js.map +0 -1
  104. package/dist/vite-CrNqpoeK.js +0 -102
  105. package/dist/vite-CrNqpoeK.js.map +0 -1
@@ -0,0 +1,142 @@
1
+ import { r as hasDotSegment } from "./static-files-Beju9riB.js";
2
+ import { copyFileSync, cpSync, mkdirSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
3
+ import { basename, dirname, isAbsolute, join, relative, sep } from "node:path";
4
+
5
+ // src/vercel/vite.ts
6
+ /** The hashed files of the client build. Their names change with their content. */
7
+ const ASSETS = "/assets/";
8
+ const IMMUTABLE = "public, max-age=31536000, immutable";
9
+ /** The variable that gives the function the time of the build, in milliseconds. */
10
+ const BUILT_AT = "APP_SERVER_BUILT_AT";
11
+ /** The function's file, next to the server entry. */
12
+ const FUNCTION_FILE = "vercel-function.js";
13
+ /** A path with `/` separators, as Vercel's config reads it. */
14
+ function posix(path) {
15
+ return path.split(sep).join("/");
16
+ }
17
+ /** A regular expression source that matches `text` as it is. */
18
+ function escaped(text) {
19
+ return text.replaceAll(/[$()*+.?[\\\]^{|}]/gu, String.raw`\$&`);
20
+ }
21
+ /** Copies the file at `from` to `to`, and makes the directories of `to`. */
22
+ function copyFile(from, to) {
23
+ mkdirSync(dirname(to), { recursive: true });
24
+ copyFileSync(from, to);
25
+ }
26
+ /**
27
+ * The path of each file under `directory`, relative to it. Why follow links:
28
+ * the CDN and the function each get a copy of the linked file, not a link
29
+ * whose target can be in the other part. Why the inodes of the parents: a
30
+ * link to a parent directory must not make the walk endless.
31
+ */
32
+ function filesUnder(directory, under = "", parents = /* @__PURE__ */ new Set()) {
33
+ const stats = statSync(join(directory, under), { throwIfNoEntry: false });
34
+ if (stats == null) return [];
35
+ if (!stats.isDirectory()) return [under];
36
+ const inode = `${stats.dev}:${stats.ino}`;
37
+ if (parents.has(inode)) return [];
38
+ const inside = new Set(parents).add(inode);
39
+ return readdirSync(join(directory, under)).flatMap((name) => filesUnder(directory, join(under, name), inside));
40
+ }
41
+ /**
42
+ * The `.vercel/output` routes: a CDN file gets its headers, and each other
43
+ * request goes to the function. Why the `hit` phase: a CDN path with no file
44
+ * goes to the function, whose `no-store` 404 must not get the immutable cache.
45
+ */
46
+ function routes(prefixes, cdnHeaders) {
47
+ return [
48
+ { handle: "filesystem" },
49
+ {
50
+ src: "^/(.*)$",
51
+ dest: "/index"
52
+ },
53
+ { handle: "hit" },
54
+ ...prefixes.map((prefix) => ({
55
+ src: `^${escaped(prefix)}.*$`,
56
+ headers: prefix === ASSETS ? {
57
+ ...cdnHeaders,
58
+ "Cache-Control": IMMUTABLE
59
+ } : cdnHeaders,
60
+ continue: true
61
+ }))
62
+ ];
63
+ }
64
+ /** Writes `.vercel/output` (the Build Output API, version 3) for one build. */
65
+ function writeOutput({ root, clientDirectory, entryFile }, { cdnPaths = [], cdnHeaders = {}, regions, memory, maxDuration }) {
66
+ const prefixes = [ASSETS, ...cdnPaths.filter((path) => path !== ASSETS)];
67
+ const output = join(root, ".vercel/output");
68
+ rmSync(output, {
69
+ recursive: true,
70
+ force: true
71
+ });
72
+ const fromRoot = (path) => {
73
+ const inside = relative(root, path);
74
+ if (inside.startsWith("..") || isAbsolute(inside)) throw new Error(`@ngrok/app-server/vercel needs ${path} inside the Vite root ${root}.`);
75
+ return inside;
76
+ };
77
+ const functionDirectory = join(output, "functions/index.func");
78
+ const isCdnFile = (file) => prefixes.some((prefix) => `/${posix(file)}`.startsWith(prefix));
79
+ for (const file of filesUnder(clientDirectory)) {
80
+ const from = join(clientDirectory, file);
81
+ if (!isCdnFile(file)) copyFile(from, join(functionDirectory, fromRoot(from)));
82
+ else if (!hasDotSegment(`/${posix(file)}`)) copyFile(from, join(output, "static", file));
83
+ }
84
+ const serverDirectory = dirname(entryFile);
85
+ const functionFile = join(serverDirectory, FUNCTION_FILE);
86
+ cpSync(serverDirectory, join(functionDirectory, fromRoot(serverDirectory)), {
87
+ recursive: true,
88
+ dereference: true,
89
+ filter: (path) => path !== clientDirectory
90
+ });
91
+ writeFileSync(join(functionDirectory, fromRoot(functionFile)), [
92
+ `import { appServer, hostModule } from ${JSON.stringify(`./${basename(entryFile)}`)};`,
93
+ `export default hostModule.handler(appServer);`,
94
+ ""
95
+ ].join("\n"));
96
+ writeFileSync(join(functionDirectory, ".vc-config.json"), `${JSON.stringify({
97
+ runtime: `nodejs${process.versions.node.split(".")[0]}.x`,
98
+ handler: posix(fromRoot(functionFile)),
99
+ launcherType: "Nodejs",
100
+ supportsResponseStreaming: true,
101
+ environment: { [BUILT_AT]: String(Date.now()) },
102
+ ...regions == null ? {} : { regions },
103
+ ...memory == null ? {} : { memory },
104
+ ...maxDuration == null ? {} : { maxDuration }
105
+ }, null, " ")}\n`);
106
+ writeFileSync(join(output, "config.json"), `${JSON.stringify({
107
+ version: 3,
108
+ routes: routes(prefixes, cdnHeaders)
109
+ }, null, " ")}\n`);
110
+ }
111
+ /** Throws for a CDN path that is not a URL path prefix, so the config fails, not the deploy. */
112
+ function checkCdnPaths(paths) {
113
+ for (const path of paths) if (!path.startsWith("/") || !path.endsWith("/") || path === "/" || path.includes("..")) throw new Error(`Each cdnPaths entry is a URL path prefix that starts and ends with "/", such as "/blog-assets/", not ${JSON.stringify(path)}.`);
114
+ }
115
+ /**
116
+ * The build side of the vercel host. After the build, it writes
117
+ * `.vercel/output` in the Vite root, for `vercel deploy --prebuilt`:
118
+ *
119
+ * - `static/`: the files under `/assets/` and the other `cdnPaths`. The CDN
120
+ * serves them, and each file under `/assets/` gets a one-year immutable
121
+ * cache.
122
+ * - `functions/index.func/`: one Node.js function that runs the pipeline for
123
+ * each other request, with the whole server build and the rest of the
124
+ * client build.
125
+ *
126
+ * @example
127
+ * appServer({ host: vercel() });
128
+ */
129
+ function vercel(options = {}) {
130
+ checkCdnPaths(options.cdnPaths ?? []);
131
+ return {
132
+ name: "vercel",
133
+ runtimeModule: "@ngrok/app-server/vercel",
134
+ entryFileName: "app-server.js",
135
+ output: (build) => {
136
+ writeOutput(build, options);
137
+ }
138
+ };
139
+ }
140
+
141
+ export { vercel };
142
+ //# sourceMappingURL=vercel-vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercel-vite.js","names":[],"sources":["../src/vercel/vite.ts"],"sourcesContent":["import {\n\tcopyFileSync,\n\tcpSync,\n\tmkdirSync,\n\treaddirSync,\n\trmSync,\n\tstatSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { basename, dirname, isAbsolute, join, relative, sep } from \"node:path\";\nimport { hasDotSegment } from \"../core/static-files.js\";\nimport type { HostBuild, HostOutput } from \"../vite/index.js\";\n\n/** Options for {@link vercel}. */\nexport type VercelOptions = {\n\t/**\n\t * More URL path prefixes of the client build that Vercel's CDN serves,\n\t * such as `[\"/blog-assets/\"]`. Each starts and ends with `/`. `/assets/`\n\t * is always one. Their files skip the pipeline, and the function does not\n\t * carry them.\n\t */\n\tcdnPaths?: readonly string[];\n\t/** Headers for each file that the CDN serves, such as CORS headers. */\n\tcdnHeaders?: Readonly<Record<string, string>>;\n\t/** The Vercel regions of the function, such as `[\"iad1\"]`. @default the project's */\n\tregions?: readonly string[];\n\t/** The memory of the function, in MB. @default the project's */\n\tmemory?: number;\n\t/** The longest time that a request runs, in seconds. @default the project's */\n\tmaxDuration?: number;\n};\n\n/** The hashed files of the client build. Their names change with their content. */\nconst ASSETS = \"/assets/\";\n\nconst IMMUTABLE = \"public, max-age=31536000, immutable\";\n\n/** The variable that gives the function the time of the build, in milliseconds. */\nconst BUILT_AT = \"APP_SERVER_BUILT_AT\";\n\n/** The function's file, next to the server entry. */\nconst FUNCTION_FILE = \"vercel-function.js\";\n\n/** A path with `/` separators, as Vercel's config reads it. */\nfunction posix(path: string): string {\n\treturn path.split(sep).join(\"/\");\n}\n\n/** A regular expression source that matches `text` as it is. */\nfunction escaped(text: string): string {\n\treturn text.replaceAll(/[$()*+.?[\\\\\\]^{|}]/gu, String.raw`\\$&`);\n}\n\n/** Copies the file at `from` to `to`, and makes the directories of `to`. */\nfunction copyFile(from: string, to: string): void {\n\tmkdirSync(dirname(to), { recursive: true });\n\tcopyFileSync(from, to);\n}\n\n/**\n * The path of each file under `directory`, relative to it. Why follow links:\n * the CDN and the function each get a copy of the linked file, not a link\n * whose target can be in the other part. Why the inodes of the parents: a\n * link to a parent directory must not make the walk endless.\n */\nfunction filesUnder(\n\tdirectory: string,\n\tunder = \"\",\n\tparents: ReadonlySet<string> = new Set(),\n): string[] {\n\tconst stats = statSync(join(directory, under), { throwIfNoEntry: false });\n\tif (stats == null) {\n\t\treturn [];\n\t}\n\tif (!stats.isDirectory()) {\n\t\treturn [under];\n\t}\n\tconst inode = `${stats.dev}:${stats.ino}`;\n\tif (parents.has(inode)) {\n\t\treturn [];\n\t}\n\tconst inside = new Set(parents).add(inode);\n\treturn readdirSync(join(directory, under)).flatMap((name) =>\n\t\tfilesUnder(directory, join(under, name), inside),\n\t);\n}\n\n/**\n * The `.vercel/output` routes: a CDN file gets its headers, and each other\n * request goes to the function. Why the `hit` phase: a CDN path with no file\n * goes to the function, whose `no-store` 404 must not get the immutable cache.\n */\nfunction routes(prefixes: readonly string[], cdnHeaders: Readonly<Record<string, string>>) {\n\treturn [\n\t\t{ handle: \"filesystem\" },\n\t\t{ src: \"^/(.*)$\", dest: \"/index\" },\n\t\t{ handle: \"hit\" },\n\t\t...prefixes.map((prefix) => ({\n\t\t\t// Why `.*$`: Vercel adds `$` to a pattern that has none.\n\t\t\tsrc: `^${escaped(prefix)}.*$`,\n\t\t\theaders: prefix === ASSETS ? { ...cdnHeaders, \"Cache-Control\": IMMUTABLE } : cdnHeaders,\n\t\t\tcontinue: true,\n\t\t})),\n\t];\n}\n\n/** Writes `.vercel/output` (the Build Output API, version 3) for one build. */\nfunction writeOutput(\n\t{ root, clientDirectory, entryFile }: HostOutput,\n\t{ cdnPaths = [], cdnHeaders = {}, regions, memory, maxDuration }: VercelOptions,\n): void {\n\tconst prefixes = [ASSETS, ...cdnPaths.filter((path) => path !== ASSETS)];\n\tconst output = join(root, \".vercel/output\");\n\trmSync(output, { recursive: true, force: true });\n\tconst fromRoot = (path: string): string => {\n\t\tconst inside = relative(root, path);\n\t\tif (inside.startsWith(\"..\") || isAbsolute(inside)) {\n\t\t\tthrow new Error(`@ngrok/app-server/vercel needs ${path} inside the Vite root ${root}.`);\n\t\t}\n\t\treturn inside;\n\t};\n\tconst functionDirectory = join(output, \"functions/index.func\");\n\tconst isCdnFile = (file: string): boolean =>\n\t\tprefixes.some((prefix) => `/${posix(file)}`.startsWith(prefix));\n\n\tfor (const file of filesUnder(clientDirectory)) {\n\t\tconst from = join(clientDirectory, file);\n\t\tif (!isCdnFile(file)) {\n\t\t\tcopyFile(from, join(functionDirectory, fromRoot(from)));\n\t\t} else if (!hasDotSegment(`/${posix(file)}`)) {\n\t\t\t// Why the static stages' check: the CDN sends each file that it has, and the static stages\n\t\t\t// send no dotfile, such as a compressed copy, and no file in a dot directory.\n\t\t\tcopyFile(from, join(output, \"static\", file));\n\t\t}\n\t}\n\n\t// Why the whole server build: it runs with no install, and it keeps the client build's path.\n\tconst serverDirectory = dirname(entryFile);\n\tconst functionFile = join(serverDirectory, FUNCTION_FILE);\n\tcpSync(serverDirectory, join(functionDirectory, fromRoot(serverDirectory)), {\n\t\trecursive: true,\n\t\t// Why: a link that keeps its target can point at the build machine.\n\t\tdereference: true,\n\t\t// Why: the client build can be inside the server build, and the loop above copied its part.\n\t\tfilter: (path) => path !== clientDirectory,\n\t});\n\twriteFileSync(\n\t\tjoin(functionDirectory, fromRoot(functionFile)),\n\t\t[\n\t\t\t`import { appServer, hostModule } from ${JSON.stringify(`./${basename(entryFile)}`)};`,\n\t\t\t`export default hostModule.handler(appServer);`,\n\t\t\t\"\",\n\t\t].join(\"\\n\"),\n\t);\n\twriteFileSync(\n\t\tjoin(functionDirectory, \".vc-config.json\"),\n\t\t`${JSON.stringify(\n\t\t\t{\n\t\t\t\t// Why the build's Node.js: the server build targets the Node.js that built it.\n\t\t\t\truntime: `nodejs${process.versions.node.split(\".\")[0]}.x`,\n\t\t\t\thandler: posix(fromRoot(functionFile)),\n\t\t\t\tlauncherType: \"Nodejs\",\n\t\t\t\tsupportsResponseStreaming: true,\n\t\t\t\t// Why: the deploy gives each file of the function one fixed time, and the ETag of a file\n\t\t\t\t// reads its time. See `host` in `@ngrok/app-server/vercel`.\n\t\t\t\tenvironment: { [BUILT_AT]: String(Date.now()) },\n\t\t\t\t...(regions == null ? {} : { regions }),\n\t\t\t\t...(memory == null ? {} : { memory }),\n\t\t\t\t...(maxDuration == null ? {} : { maxDuration }),\n\t\t\t},\n\t\t\tnull,\n\t\t\t\"\\t\",\n\t\t)}\\n`,\n\t);\n\twriteFileSync(\n\t\tjoin(output, \"config.json\"),\n\t\t`${JSON.stringify({ version: 3, routes: routes(prefixes, cdnHeaders) }, null, \"\\t\")}\\n`,\n\t);\n}\n\n/** Throws for a CDN path that is not a URL path prefix, so the config fails, not the deploy. */\nfunction checkCdnPaths(paths: readonly string[]): void {\n\tfor (const path of paths) {\n\t\tif (!path.startsWith(\"/\") || !path.endsWith(\"/\") || path === \"/\" || path.includes(\"..\")) {\n\t\t\tthrow new Error(\n\t\t\t\t`Each cdnPaths entry is a URL path prefix that starts and ends with \"/\", such as \"/blog-assets/\", not ${JSON.stringify(path)}.`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * The build side of the vercel host. After the build, it writes\n * `.vercel/output` in the Vite root, for `vercel deploy --prebuilt`:\n *\n * - `static/`: the files under `/assets/` and the other `cdnPaths`. The CDN\n * serves them, and each file under `/assets/` gets a one-year immutable\n * cache.\n * - `functions/index.func/`: one Node.js function that runs the pipeline for\n * each other request, with the whole server build and the rest of the\n * client build.\n *\n * @example\n * appServer({ host: vercel() });\n */\nexport function vercel(options: VercelOptions = {}): HostBuild {\n\tcheckCdnPaths(options.cdnPaths ?? []);\n\treturn {\n\t\tname: \"vercel\",\n\t\truntimeModule: \"@ngrok/app-server/vercel\",\n\t\tentryFileName: \"app-server.js\",\n\t\toutput: (build) => {\n\t\t\twriteOutput(build, options);\n\t\t},\n\t};\n}\n"],"mappings":"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"}
@@ -0,0 +1,35 @@
1
+ import { c as HostRuntime } from "./types-DLYxYS6M.js";
2
+ import { t as AppServerEntry } from "./entry-DmJEqVfd.js";
3
+ import { IncomingMessage, ServerResponse } from "node:http";
4
+ /**
5
+ * The vercel host: one Vercel Function on Node.js. It reads the client build
6
+ * from the function's files and keeps `requestContext()` in
7
+ * `AsyncLocalStorage`, as the node host does. It has no listeners and no
8
+ * lifecycle: Vercel starts and stops the function, and {@link handler} calls
9
+ * the entry's `fetch`.
10
+ *
11
+ * Why no gzip: Vercel's CDN compresses each response, with Brotli when the
12
+ * client accepts it.
13
+ *
14
+ * @example
15
+ * export const appServer = createEntry({ app, host, framework: (mode) => runtime(build, { mode }) });
16
+ */
17
+ export declare const host: HostRuntime;
18
+ /**
19
+ * The function handler for the entry of a server build. The function file
20
+ * that `vercel()` writes exports it.
21
+ *
22
+ * - The scheme comes from `X-Forwarded-Proto`, and the client address from
23
+ * `X-Real-IP`. Why trust them: Vercel sets both headers on each request,
24
+ * and replaces a value that the client sends.
25
+ * - The node response writer sends each response, as the node host's
26
+ * listener does.
27
+ * - The log lines of the request reach stdout before the handler returns.
28
+ * Why: Vercel can freeze the function after the response, before the next
29
+ * turn of the event loop writes them.
30
+ *
31
+ * @example
32
+ * export default hostModule.handler(appServer);
33
+ */
34
+ export declare function handler(entry: AppServerEntry): (incoming: IncomingMessage, outgoing: ServerResponse) => Promise<void>;
35
+ //# sourceMappingURL=vercel.d.ts.map
package/dist/vercel.js ADDED
@@ -0,0 +1,89 @@
1
+ import { n as flushLogs } from "./log-BP6xXXZl.js";
2
+ import { i as withForwardedProto } from "./create-server-iE1-s6Bi.js";
3
+ import { t as host$1 } from "./node-BFH82eeL.js";
4
+ import { t as requestListener } from "./response-writer-B7FoJjEE.js";
5
+
6
+ // src/vercel/index.ts
7
+ /**
8
+ * `files` that give each file and directory the modification time
9
+ * `mtimeMs`. Why: the deploy gives each file of the function one fixed time,
10
+ * so a file that changes and keeps its size would keep its ETag. `vercel()`
11
+ * sets `APP_SERVER_BUILT_AT` to the time of the build.
12
+ */
13
+ function withModifiedTime(files, mtimeMs) {
14
+ const { snapshot } = files;
15
+ return {
16
+ stat: async (path) => {
17
+ const info = await files.stat(path);
18
+ return info == null ? void 0 : {
19
+ ...info,
20
+ mtimeMs
21
+ };
22
+ },
23
+ open: files.open,
24
+ ...snapshot == null ? {} : { snapshot: async () => withModifiedTime(await snapshot(), mtimeMs) }
25
+ };
26
+ }
27
+ /**
28
+ * The vercel host: one Vercel Function on Node.js. It reads the client build
29
+ * from the function's files and keeps `requestContext()` in
30
+ * `AsyncLocalStorage`, as the node host does. It has no listeners and no
31
+ * lifecycle: Vercel starts and stops the function, and {@link handler} calls
32
+ * the entry's `fetch`.
33
+ *
34
+ * Why no gzip: Vercel's CDN compresses each response, with Brotli when the
35
+ * client accepts it.
36
+ *
37
+ * @example
38
+ * export const appServer = createEntry({ app, host, framework: (mode) => runtime(build, { mode }) });
39
+ */
40
+ const host = {
41
+ name: "vercel",
42
+ files: (clientDirectory) => {
43
+ const files = host$1.files(clientDirectory);
44
+ const builtAt = Number(process.env.APP_SERVER_BUILT_AT);
45
+ return Number.isFinite(builtAt) ? withModifiedTime(files, builtAt) : files;
46
+ },
47
+ ...host$1.storage == null ? {} : { storage: host$1.storage }
48
+ };
49
+ /**
50
+ * The function handler for the entry of a server build. The function file
51
+ * that `vercel()` writes exports it.
52
+ *
53
+ * - The scheme comes from `X-Forwarded-Proto`, and the client address from
54
+ * `X-Real-IP`. Why trust them: Vercel sets both headers on each request,
55
+ * and replaces a value that the client sends.
56
+ * - The node response writer sends each response, as the node host's
57
+ * listener does.
58
+ * - The log lines of the request reach stdout before the handler returns.
59
+ * Why: Vercel can freeze the function after the response, before the next
60
+ * turn of the event loop writes them.
61
+ *
62
+ * @example
63
+ * export default hostModule.handler(appServer);
64
+ */
65
+ function handler(entry) {
66
+ const listener = requestListener(async (request, bindings) => {
67
+ const realIp = bindings.incoming?.headers["x-real-ip"];
68
+ return entry.fetch(withForwardedProto(request), {
69
+ ...bindings,
70
+ ...typeof realIp === "string" ? { remoteAddress: realIp } : {}
71
+ });
72
+ }, { trustForwardedProto: true });
73
+ return async (incoming, outgoing) => {
74
+ try {
75
+ await listener(incoming, outgoing);
76
+ if (!outgoing.closed) await new Promise((resolve) => {
77
+ outgoing.once("close", resolve);
78
+ });
79
+ } finally {
80
+ flushLogs();
81
+ if (process.stdout.writableLength > 0) await new Promise((resolve) => {
82
+ process.stdout.write("", resolve);
83
+ });
84
+ }
85
+ };
86
+ }
87
+
88
+ export { handler, host };
89
+ //# sourceMappingURL=vercel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercel.js","names":["nodeHost"],"sources":["../src/vercel/index.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from \"node:http\";\nimport { withForwardedProto } from \"../core/create-server.js\";\nimport type { AppServerEntry } from \"../core/entry.js\";\nimport { flushLogs } from \"../core/log.js\";\nimport type { FileInfo, HostRuntime, StaticFiles } from \"../core/types.js\";\nimport { host as nodeHost } from \"../node/index.js\";\nimport { requestListener } from \"../node/response-writer.js\";\n\n/**\n * `files` that give each file and directory the modification time\n * `mtimeMs`. Why: the deploy gives each file of the function one fixed time,\n * so a file that changes and keeps its size would keep its ETag. `vercel()`\n * sets `APP_SERVER_BUILT_AT` to the time of the build.\n */\nfunction withModifiedTime(files: StaticFiles, mtimeMs: number): StaticFiles {\n\tconst { snapshot } = files;\n\treturn {\n\t\tstat: async (path) => {\n\t\t\tconst info: FileInfo | undefined = await files.stat(path);\n\t\t\treturn info == null ? undefined : { ...info, mtimeMs };\n\t\t},\n\t\topen: files.open,\n\t\t...(snapshot == null\n\t\t\t? {}\n\t\t\t: { snapshot: async () => withModifiedTime(await snapshot(), mtimeMs) }),\n\t};\n}\n\n/**\n * The vercel host: one Vercel Function on Node.js. It reads the client build\n * from the function's files and keeps `requestContext()` in\n * `AsyncLocalStorage`, as the node host does. It has no listeners and no\n * lifecycle: Vercel starts and stops the function, and {@link handler} calls\n * the entry's `fetch`.\n *\n * Why no gzip: Vercel's CDN compresses each response, with Brotli when the\n * client accepts it.\n *\n * @example\n * export const appServer = createEntry({ app, host, framework: (mode) => runtime(build, { mode }) });\n */\nexport const host: HostRuntime = {\n\tname: \"vercel\",\n\tfiles: (clientDirectory) => {\n\t\tconst files = nodeHost.files(clientDirectory);\n\t\tconst builtAt = Number(process.env.APP_SERVER_BUILT_AT);\n\t\treturn Number.isFinite(builtAt) ? withModifiedTime(files, builtAt) : files;\n\t},\n\t...(nodeHost.storage == null ? {} : { storage: nodeHost.storage }),\n};\n\n/**\n * The function handler for the entry of a server build. The function file\n * that `vercel()` writes exports it.\n *\n * - The scheme comes from `X-Forwarded-Proto`, and the client address from\n * `X-Real-IP`. Why trust them: Vercel sets both headers on each request,\n * and replaces a value that the client sends.\n * - The node response writer sends each response, as the node host's\n * listener does.\n * - The log lines of the request reach stdout before the handler returns.\n * Why: Vercel can freeze the function after the response, before the next\n * turn of the event loop writes them.\n *\n * @example\n * export default hostModule.handler(appServer);\n */\nexport function handler(\n\tentry: AppServerEntry,\n): (incoming: IncomingMessage, outgoing: ServerResponse) => Promise<void> {\n\tconst listener = requestListener(\n\t\tasync (request, bindings) => {\n\t\t\tconst realIp = bindings.incoming?.headers[\"x-real-ip\"];\n\t\t\treturn entry.fetch(withForwardedProto(request), {\n\t\t\t\t...bindings,\n\t\t\t\t...(typeof realIp === \"string\" ? { remoteAddress: realIp } : {}),\n\t\t\t});\n\t\t},\n\t\t{ trustForwardedProto: true },\n\t);\n\treturn async (incoming, outgoing) => {\n\t\ttry {\n\t\t\tawait listener(incoming, outgoing);\n\t\t\t// Why wait: the access log writes its line when the response closes, after the listener returns.\n\t\t\tif (!outgoing.closed) {\n\t\t\t\tawait new Promise((resolve) => {\n\t\t\t\t\toutgoing.once(\"close\", resolve);\n\t\t\t\t});\n\t\t\t}\n\t\t} finally {\n\t\t\tflushLogs();\n\t\t\t// Why wait: a full pipe keeps the rest of a write in a queue, and a frozen function does not send it.\n\t\t\tif (process.stdout.writableLength > 0) {\n\t\t\t\tawait new Promise((resolve) => {\n\t\t\t\t\tprocess.stdout.write(\"\", resolve);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;;;;;;;AAcA,SAAS,iBAAiB,OAAoB,SAA8B;CAC3E,MAAM,EAAE,aAAa;CACrB,OAAO;EACN,MAAM,OAAO,SAAS;GACrB,MAAM,OAA6B,MAAM,MAAM,KAAK,IAAI;GACxD,OAAO,QAAQ,OAAO,SAAY;IAAE,GAAG;IAAM;GAAQ;EACtD;EACA,MAAM,MAAM;EACZ,GAAI,YAAY,OACb,CAAC,IACD,EAAE,UAAU,YAAY,iBAAiB,MAAM,SAAS,GAAG,OAAO,EAAE;CACxE;AACD;;;;;;;;;;;;;;AAeA,MAAa,OAAoB;CAChC,MAAM;CACN,QAAQ,oBAAoB;EAC3B,MAAM,QAAQA,OAAS,MAAM,eAAe;EAC5C,MAAM,UAAU,OAAO,QAAQ,IAAI,mBAAmB;EACtD,OAAO,OAAO,SAAS,OAAO,IAAI,iBAAiB,OAAO,OAAO,IAAI;CACtE;CACA,GAAIA,OAAS,WAAW,OAAO,CAAC,IAAI,EAAE,SAASA,OAAS,QAAQ;AACjE;;;;;;;;;;;;;;;;;AAkBA,SAAgB,QACf,OACyE;CACzE,MAAM,WAAW,gBAChB,OAAO,SAAS,aAAa;EAC5B,MAAM,SAAS,SAAS,UAAU,QAAQ;EAC1C,OAAO,MAAM,MAAM,mBAAmB,OAAO,GAAG;GAC/C,GAAG;GACH,GAAI,OAAO,WAAW,WAAW,EAAE,eAAe,OAAO,IAAI,CAAC;EAC/D,CAAC;CACF,GACA,EAAE,qBAAqB,KAAK,CAC7B;CACA,OAAO,OAAO,UAAU,aAAa;EACpC,IAAI;GACH,MAAM,SAAS,UAAU,QAAQ;GAEjC,IAAI,CAAC,SAAS,QACb,MAAM,IAAI,SAAS,YAAY;IAC9B,SAAS,KAAK,SAAS,OAAO;GAC/B,CAAC;EAEH,UAAU;GACT,UAAU;GAEV,IAAI,QAAQ,OAAO,iBAAiB,GACnC,MAAM,IAAI,SAAS,YAAY;IAC9B,QAAQ,OAAO,MAAM,IAAI,OAAO;GACjC,CAAC;EAEH;CACD;AACD"}
@@ -0,0 +1,22 @@
1
+ // src/react-router/vite.ts
2
+ /**
3
+ * The build side of the React Router adapter. `appServer` uses it when the
4
+ * Vite config has the React Router plugin, so pass it only to override that.
5
+ *
6
+ * @example
7
+ * appServer({ framework: reactRouterAdapter() });
8
+ */
9
+ function reactRouterAdapter() {
10
+ return {
11
+ name: "react-router",
12
+ serverModule: "virtual:react-router/server-build",
13
+ runtimeModule: "@ngrok/app-server/react-router",
14
+ isPrerenderPass: () => process.env.IS_RR_BUILD_REQUEST === "yes",
15
+ validate: (config) => {
16
+ if (config.base !== "/") throw new Error(`@ngrok/app-server serves a build at "/" only, and this config has the base "${config.base}".`);
17
+ }
18
+ };
19
+ }
20
+
21
+ export { reactRouterAdapter as t };
22
+ //# sourceMappingURL=vite-B-GfswoH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-B-GfswoH.js","names":[],"sources":["../src/react-router/vite.ts"],"sourcesContent":["import type { FrameworkBuild } from \"../vite/index.js\";\n\n/**\n * The build side of the React Router adapter. `appServer` uses it when the\n * Vite config has the React Router plugin, so pass it only to override that.\n *\n * @example\n * appServer({ framework: reactRouterAdapter() });\n */\nexport function reactRouterAdapter(): FrameworkBuild {\n\treturn {\n\t\tname: \"react-router\",\n\t\tserverModule: \"virtual:react-router/server-build\",\n\t\truntimeModule: \"@ngrok/app-server/react-router\",\n\t\t// Why this flag: React Router sets it for the preview server of its prerender pass only.\n\t\tisPrerenderPass: () => process.env.IS_RR_BUILD_REQUEST === \"yes\",\n\t\tvalidate: (config) => {\n\t\t\tif (config.base !== \"/\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`@ngrok/app-server serves a build at \"/\" only, and this config has the base \"${config.base}\".`,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,qBAAqC;CACpD,OAAO;EACN,MAAM;EACN,cAAc;EACd,eAAe;EAEf,uBAAuB,QAAQ,IAAI,wBAAwB;EAC3D,WAAW,WAAW;GACrB,IAAI,OAAO,SAAS,KACnB,MAAM,IAAI,MACT,+EAA+E,OAAO,KAAK,GAC5F;EAEF;CACD;AACD"}
@@ -0,0 +1,19 @@
1
+ // src/node/vite.ts
2
+ /**
3
+ * The build side of the node host, the default host of `appServer`. The
4
+ * server build gets `server/app-server.js`. Run it with `node`, `bun`, or
5
+ * `deno run`, or load it with `app-server serve`.
6
+ *
7
+ * @example
8
+ * appServer({ host: node() });
9
+ */
10
+ function node() {
11
+ return {
12
+ name: "node",
13
+ runtimeModule: "@ngrok/app-server/node",
14
+ entryFileName: "app-server.js"
15
+ };
16
+ }
17
+
18
+ export { node as t };
19
+ //# sourceMappingURL=vite-D4hfj3ph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-D4hfj3ph.js","names":[],"sources":["../src/node/vite.ts"],"sourcesContent":["import type { HostBuild } from \"../vite/index.js\";\n\n/**\n * The build side of the node host, the default host of `appServer`. The\n * server build gets `server/app-server.js`. Run it with `node`, `bun`, or\n * `deno run`, or load it with `app-server serve`.\n *\n * @example\n * appServer({ host: node() });\n */\nexport function node(): HostBuild {\n\treturn {\n\t\tname: \"node\",\n\t\truntimeModule: \"@ngrok/app-server/node\",\n\t\tentryFileName: \"app-server.js\",\n\t};\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,OAAkB;CACjC,OAAO;EACN,MAAM;EACN,eAAe;EACf,eAAe;CAChB;AACD"}
@@ -0,0 +1,25 @@
1
+ // src/tanstack-start/vite.ts
2
+ /**
3
+ * The build side of the TanStack Start adapter. `appServer` uses it when the
4
+ * Vite config has the TanStack Start plugin, so pass it only to override that.
5
+ * In `app-server start`, Vite runs in middleware mode, so Start skips its own
6
+ * SSR middleware, and the pipeline renders each page.
7
+ *
8
+ * @example
9
+ * appServer({ framework: tanstackStartAdapter() });
10
+ */
11
+ function tanstackStartAdapter() {
12
+ return {
13
+ name: "tanstack-start",
14
+ serverModule: "virtual:tanstack-start-server-entry",
15
+ runtimeModule: "@ngrok/app-server/tanstack-start",
16
+ runtimeOptions: "{ serverFnBase: process.env.TSS_SERVER_FN_BASE }",
17
+ isPrerenderPass: () => process.env.TSS_PRERENDERING === "true",
18
+ validate: (config) => {
19
+ if (config.base !== "/") throw new Error(`@ngrok/app-server serves a build at "/" only, and this config has the base "${config.base}".`);
20
+ }
21
+ };
22
+ }
23
+
24
+ export { tanstackStartAdapter as t };
25
+ //# sourceMappingURL=vite-DyrhyKEr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-DyrhyKEr.js","names":[],"sources":["../src/tanstack-start/vite.ts"],"sourcesContent":["import type { FrameworkBuild } from \"../vite/index.js\";\n\n/**\n * The build side of the TanStack Start adapter. `appServer` uses it when the\n * Vite config has the TanStack Start plugin, so pass it only to override that.\n * In `app-server start`, Vite runs in middleware mode, so Start skips its own\n * SSR middleware, and the pipeline renders each page.\n *\n * @example\n * appServer({ framework: tanstackStartAdapter() });\n */\nexport function tanstackStartAdapter(): FrameworkBuild {\n\treturn {\n\t\tname: \"tanstack-start\",\n\t\tserverModule: \"virtual:tanstack-start-server-entry\",\n\t\truntimeModule: \"@ngrok/app-server/tanstack-start\",\n\t\t// Why in the entry: Start defines `TSS_SERVER_FN_BASE` at build time, so only bundled code sees it.\n\t\truntimeOptions: \"{ serverFnBase: process.env.TSS_SERVER_FN_BASE }\",\n\t\t// Why this flag: Start sets it in the build process before it starts the preview server\n\t\t// of its prerender pass.\n\t\tisPrerenderPass: () => process.env.TSS_PRERENDERING === \"true\",\n\t\tvalidate: (config) => {\n\t\t\tif (config.base !== \"/\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`@ngrok/app-server serves a build at \"/\" only, and this config has the base \"${config.base}\".`,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,uBAAuC;CACtD,OAAO;EACN,MAAM;EACN,cAAc;EACd,eAAe;EAEf,gBAAgB;EAGhB,uBAAuB,QAAQ,IAAI,qBAAqB;EACxD,WAAW,WAAW;GACrB,IAAI,OAAO,SAAS,KACnB,MAAM,IAAI,MACT,+EAA+E,OAAO,KAAK,GAC5F;EAEF;CACD;AACD"}