@ngrok/app-server 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,201 @@
1
+ import { c as streamingCompress, d as requestId, f as accessLog, i as defaultPlugins, l as assets, m as jsonSink, o as tcp, r as createServer, s as shutdownSignal, t as createEntry, u as prerendered } from "./entry-2XXp2Ukh.js";
2
+
3
+ // src/event-stream.ts
4
+ function formatEvent({ data, event, id }) {
5
+ if (/[\r\n]/.test(`${event ?? ""}${id ?? ""}`)) throw new TypeError("An event's `event` and `id` cannot contain a line break.");
6
+ return `${[
7
+ ...event == null ? [] : [`event: ${event}`],
8
+ ...id == null ? [] : [`id: ${id}`],
9
+ ...data.split(/\r\n|\r|\n/).map((line) => `data: ${line}`)
10
+ ].join("\n")}\n\n`;
11
+ }
12
+ /**
13
+ * A `text/event-stream` response that stays correct for its whole life: it
14
+ * sends a heartbeat comment, it stops when the client disconnects, and it
15
+ * closes at server shutdown so the drain does not wait for the deadline. The
16
+ * stream closes when `produce` resolves.
17
+ *
18
+ * @example
19
+ * export async function loader({ request }: Route.LoaderArgs) {
20
+ * return eventStream({ signal: request.signal }, async ({ send, signal }) => {
21
+ * for await (const update of watchUpdates({ signal })) {
22
+ * send({ event: "update", data: JSON.stringify(update) });
23
+ * }
24
+ * });
25
+ * }
26
+ */
27
+ function eventStream({ signal, heartbeatMs = 15e3, headers }, produce) {
28
+ const encoder = new TextEncoder();
29
+ const stopped = new AbortController();
30
+ const stopSignal = AbortSignal.any([
31
+ stopped.signal,
32
+ shutdownSignal(),
33
+ ...signal == null ? [] : [signal]
34
+ ]);
35
+ let heartbeat;
36
+ let closed = false;
37
+ const body = new ReadableStream({
38
+ start(controller) {
39
+ const close = () => {
40
+ if (closed) return;
41
+ closed = true;
42
+ clearInterval(heartbeat);
43
+ stopSignal.removeEventListener("abort", close);
44
+ controller.close();
45
+ };
46
+ const write = (text) => {
47
+ if (!closed) controller.enqueue(encoder.encode(text));
48
+ };
49
+ heartbeat = setInterval(() => {
50
+ write(": ping\n\n");
51
+ }, heartbeatMs);
52
+ stopSignal.addEventListener("abort", close, { once: true });
53
+ if (stopSignal.aborted) {
54
+ close();
55
+ return;
56
+ }
57
+ Promise.resolve().then(() => produce({
58
+ send: (event) => write(formatEvent(event)),
59
+ signal: stopSignal
60
+ })).then(close, (error) => {
61
+ closed = true;
62
+ clearInterval(heartbeat);
63
+ stopSignal.removeEventListener("abort", close);
64
+ controller.error(error);
65
+ });
66
+ },
67
+ cancel() {
68
+ closed = true;
69
+ clearInterval(heartbeat);
70
+ stopped.abort();
71
+ }
72
+ });
73
+ const responseHeaders = new Headers(headers);
74
+ responseHeaders.set("Content-Type", "text/event-stream; charset=utf-8");
75
+ responseHeaders.set("Cache-Control", "no-cache");
76
+ return new Response(body, { headers: responseHeaders });
77
+ }
78
+
79
+ // src/plugins/build-id.ts
80
+ /**
81
+ * Sets a build ID header on documents and React Router `.data` responses, so
82
+ * a client can see that a deploy happened under it.
83
+ *
84
+ * @example
85
+ * buildId({ value: env.values.PUBLIC_APP_VERSION });
86
+ */
87
+ function buildId({ header = "X-Build-Id", value }) {
88
+ return {
89
+ name: "build-id",
90
+ etagPart: () => value,
91
+ middleware: async (context, next) => {
92
+ await next();
93
+ if ((context.res.headers.get("Content-Type")?.startsWith("text/html") ?? false) || context.req.path.endsWith(".data")) context.header(header, value);
94
+ }
95
+ };
96
+ }
97
+
98
+ // src/plugins/runtime-env.ts
99
+ /** The `id` of the JSON `<script>` that carries the public values into each HTML document. */
100
+ const PUBLIC_ENV_SCRIPT_ID = "app-server-public-env";
101
+ /** Stops the search for `</head>` after this many characters, so a page with none still streams. */
102
+ const HEAD_SEARCH_LIMIT = 1048576;
103
+ function formatIssue(issue) {
104
+ const path = (issue.path ?? []).map((segment) => String(typeof segment === "object" ? segment.key : segment)).join(".");
105
+ return ` ${path === "" ? "(root)" : path}: ${issue.message}`;
106
+ }
107
+ /** A JSON data block. Escaping `<` keeps a value from closing the `<script>`. */
108
+ function publicEnvScript(values) {
109
+ const json = JSON.stringify(values).replaceAll("<", "\\u003c");
110
+ return `<script id="${PUBLIC_ENV_SCRIPT_ID}" type="application/json">${json}<\/script>`;
111
+ }
112
+ /** Inserts `html` before the first `</head>` of a streamed document. The rest streams as is. */
113
+ function injectBeforeHeadEnd(body, html) {
114
+ const decoder = new TextDecoder();
115
+ const encoder = new TextEncoder();
116
+ let pending = "";
117
+ return body.pipeThrough(new TransformStream({
118
+ transform(chunk, controller) {
119
+ const text = decoder.decode(chunk, { stream: true });
120
+ if (pending == null) {
121
+ controller.enqueue(encoder.encode(text));
122
+ return;
123
+ }
124
+ pending += text;
125
+ const index = pending.search(/<\/head>/i);
126
+ if (index !== -1) {
127
+ controller.enqueue(encoder.encode(`${pending.slice(0, index)}${html}${pending.slice(index)}`));
128
+ pending = void 0;
129
+ } else if (pending.length > HEAD_SEARCH_LIMIT) {
130
+ controller.enqueue(encoder.encode(pending));
131
+ pending = void 0;
132
+ }
133
+ },
134
+ flush(controller) {
135
+ const rest = `${pending ?? ""}${decoder.decode()}`;
136
+ if (rest !== "") controller.enqueue(encoder.encode(rest));
137
+ }
138
+ }));
139
+ }
140
+ /**
141
+ * Validates the environment once, at startup, against a schema. A missing or
142
+ * bad value stops the server with a message that names it. The typed values
143
+ * are on `.values`.
144
+ *
145
+ * The values whose names start with `PUBLIC_` go into each HTML document,
146
+ * prerendered or rendered, as a JSON `<script id="app-server-public-env">`.
147
+ * So one image serves every environment, and a prerendered page never keeps
148
+ * the values of the build. Put this plugin before the static stages, so it
149
+ * sees the prerendered pages.
150
+ *
151
+ * @example
152
+ * export const env = runtimeEnv(
153
+ * z.object({ PUBLIC_API_URL: z.url(), SESSION_KEY: z.string().min(32) }),
154
+ * );
155
+ * env.values.SESSION_KEY; // => string
156
+ *
157
+ * // In the browser:
158
+ * const publicEnv = JSON.parse(document.getElementById("app-server-public-env")?.textContent ?? "{}");
159
+ */
160
+ function runtimeEnv(schema, { source = process.env, publicPrefix = "PUBLIC_" } = {}) {
161
+ let parsed;
162
+ const parse = () => {
163
+ if (parsed != null) return parsed;
164
+ const result = schema["~standard"].validate({ ...source });
165
+ if (result instanceof Promise) throw new TypeError("runtimeEnv needs a schema that validates synchronously.");
166
+ if (result.issues != null) throw new Error(`The environment is not valid:\n${result.issues.map(formatIssue).join("\n")}`);
167
+ const values = result.value;
168
+ const publicValues = typeof values === "object" && values != null ? Object.fromEntries(Object.entries(values).filter(([name]) => name.startsWith(publicPrefix))) : {};
169
+ parsed = {
170
+ values,
171
+ publicValues,
172
+ script: Object.keys(publicValues).length > 0 ? publicEnvScript(publicValues) : void 0
173
+ };
174
+ return parsed;
175
+ };
176
+ return {
177
+ name: "runtime-env",
178
+ get values() {
179
+ return parse().values;
180
+ },
181
+ get publicValues() {
182
+ return parse().publicValues;
183
+ },
184
+ setup: () => {
185
+ parse();
186
+ },
187
+ etagPart: () => parse().script,
188
+ middleware: async (context, next) => {
189
+ await next();
190
+ const { script } = parse();
191
+ const response = context.res;
192
+ if (script == null || response.headers.has("Content-Encoding") || response.headers.has("Content-Range") || !(response.headers.get("Content-Type")?.startsWith("text/html") ?? false)) return;
193
+ if (response.body != null) context.res = new Response(injectBeforeHeadEnd(response.body, script), response);
194
+ context.header("Content-Length", void 0);
195
+ context.header("ETag", void 0);
196
+ }
197
+ };
198
+ }
199
+
200
+ export { PUBLIC_ENV_SCRIPT_ID, accessLog, assets, buildId, createEntry, createServer, defaultPlugins, eventStream, jsonSink, prerendered, requestId, runtimeEnv, shutdownSignal, streamingCompress, tcp };
201
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/event-stream.ts","../src/plugins/build-id.ts","../src/plugins/runtime-env.ts"],"sourcesContent":["import { shutdownSignal } from \"./shutdown.js\";\n\n/** One server-sent event. */\nexport type ServerSentEvent = {\n\tdata: string;\n\tevent?: string;\n\tid?: string;\n};\n\n/** What {@link eventStream} passes to its producer. */\nexport type EventStreamSink = {\n\tsend: (event: ServerSentEvent) => void;\n\t/** Aborts when the client disconnects or the server shuts down. Stop the work on it. */\n\tsignal: AbortSignal;\n};\n\n/** Options for {@link eventStream}. */\nexport type EventStreamOptions = {\n\t/** The request's signal, so a client disconnect stops the stream. */\n\tsignal?: AbortSignal;\n\t/**\n\t * How often a `: ping` comment goes out, so that a proxy keeps a quiet stream open.\n\t * @default 15000\n\t */\n\theartbeatMs?: number;\n\t/** Extra response headers. */\n\theaders?: HeadersInit;\n};\n\nfunction formatEvent({ data, event, id }: ServerSentEvent): string {\n\t// Why: a line break in `event` or `id` would start another field or event.\n\tif (/[\\r\\n]/.test(`${event ?? \"\"}${id ?? \"\"}`)) {\n\t\tthrow new TypeError(\"An event's `event` and `id` cannot contain a line break.\");\n\t}\n\tconst lines = [\n\t\t...(event == null ? [] : [`event: ${event}`]),\n\t\t...(id == null ? [] : [`id: ${id}`]),\n\t\t// Why `\\r` too: a client reads a lone carriage return as a line end.\n\t\t...data.split(/\\r\\n|\\r|\\n/).map((line) => `data: ${line}`),\n\t];\n\treturn `${lines.join(\"\\n\")}\\n\\n`;\n}\n\n/**\n * A `text/event-stream` response that stays correct for its whole life: it\n * sends a heartbeat comment, it stops when the client disconnects, and it\n * closes at server shutdown so the drain does not wait for the deadline. The\n * stream closes when `produce` resolves.\n *\n * @example\n * export async function loader({ request }: Route.LoaderArgs) {\n * \treturn eventStream({ signal: request.signal }, async ({ send, signal }) => {\n * \t\tfor await (const update of watchUpdates({ signal })) {\n * \t\t\tsend({ event: \"update\", data: JSON.stringify(update) });\n * \t\t}\n * \t});\n * }\n */\nexport function eventStream(\n\t{ signal, heartbeatMs = 15_000, headers }: EventStreamOptions,\n\tproduce: (sink: EventStreamSink) => void | Promise<void>,\n): Response {\n\tconst encoder = new TextEncoder();\n\tconst stopped = new AbortController();\n\tconst stopSignal = AbortSignal.any([\n\t\tstopped.signal,\n\t\tshutdownSignal(),\n\t\t...(signal == null ? [] : [signal]),\n\t]);\n\tlet heartbeat: ReturnType<typeof setInterval> | undefined;\n\tlet closed = false;\n\n\tconst body = new ReadableStream<Uint8Array>({\n\t\tstart(controller) {\n\t\t\tconst close = () => {\n\t\t\t\tif (closed) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tclosed = true;\n\t\t\t\tclearInterval(heartbeat);\n\t\t\t\t// Why: the listener lives on `shutdownSignal()`, which lasts the life of the process.\n\t\t\t\tstopSignal.removeEventListener(\"abort\", close);\n\t\t\t\tcontroller.close();\n\t\t\t};\n\t\t\tconst write = (text: string) => {\n\t\t\t\tif (!closed) {\n\t\t\t\t\tcontroller.enqueue(encoder.encode(text));\n\t\t\t\t}\n\t\t\t};\n\t\t\theartbeat = setInterval(() => {\n\t\t\t\twrite(\": ping\\n\\n\");\n\t\t\t}, heartbeatMs);\n\t\t\tstopSignal.addEventListener(\"abort\", close, { once: true });\n\t\t\tif (stopSignal.aborted) {\n\t\t\t\tclose();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tPromise.resolve()\n\t\t\t\t.then(() => produce({ send: (event) => write(formatEvent(event)), signal: stopSignal }))\n\t\t\t\t.then(close, (error: unknown) => {\n\t\t\t\t\tclosed = true;\n\t\t\t\t\tclearInterval(heartbeat);\n\t\t\t\t\tstopSignal.removeEventListener(\"abort\", close);\n\t\t\t\t\tcontroller.error(error);\n\t\t\t\t});\n\t\t},\n\t\tcancel() {\n\t\t\tclosed = true;\n\t\t\tclearInterval(heartbeat);\n\t\t\tstopped.abort();\n\t\t},\n\t});\n\n\tconst responseHeaders = new Headers(headers);\n\tresponseHeaders.set(\"Content-Type\", \"text/event-stream; charset=utf-8\");\n\tresponseHeaders.set(\"Cache-Control\", \"no-cache\");\n\treturn new Response(body, { headers: responseHeaders });\n}\n","import type { Plugin } from \"../types.js\";\n\n/** Options for {@link buildId}. */\nexport type BuildIdOptions = {\n\t/** @default \"X-Build-Id\" */\n\theader?: string;\n\t/** The deployed build, such as the image tag. Read it from the runtime env, not the build. */\n\tvalue: string;\n};\n\n/**\n * Sets a build ID header on documents and React Router `.data` responses, so\n * a client can see that a deploy happened under it.\n *\n * @example\n * buildId({ value: env.values.PUBLIC_APP_VERSION });\n */\nexport function buildId({ header = \"X-Build-Id\", value }: BuildIdOptions): Plugin {\n\treturn {\n\t\tname: \"build-id\",\n\t\t// Why: a 304 has no `Content-Type`, so a document that did not change on disk must still\n\t\t// answer 200 when the build ID changes.\n\t\tetagPart: () => value,\n\t\tmiddleware: async (context, next) => {\n\t\t\tawait next();\n\t\t\tconst isDocument = context.res.headers.get(\"Content-Type\")?.startsWith(\"text/html\") ?? false;\n\t\t\tif (isDocument || context.req.path.endsWith(\".data\")) {\n\t\t\t\tcontext.header(header, value);\n\t\t\t}\n\t\t},\n\t};\n}\n","import type { Plugin } from \"../types.js\";\n\n// The Standard Schema interface (https://standardschema.dev), copied as its spec asks, so that\n// zod, valibot, and arktype schemas all work with no dependency on any of them.\ntype StandardIssue = {\n\treadonly message: string;\n\treadonly path?: ReadonlyArray<PropertyKey | { readonly key: PropertyKey }> | undefined;\n};\ntype StandardResult<Output> =\n\t| { readonly value: Output; readonly issues?: undefined }\n\t| { readonly issues: ReadonlyArray<StandardIssue> };\n\n/** A schema that follows the Standard Schema interface, such as a zod object. */\nexport type StandardSchemaV1<Input = unknown, Output = Input> = {\n\treadonly \"~standard\": {\n\t\treadonly version: 1;\n\t\treadonly vendor: string;\n\t\treadonly validate: (value: unknown) => StandardResult<Output> | Promise<StandardResult<Output>>;\n\t\treadonly types?: { readonly input: Input; readonly output: Output } | undefined;\n\t};\n};\n\n/** The parsed type of a Standard Schema. */\nexport type InferOutput<Schema extends StandardSchemaV1> = NonNullable<\n\tSchema[\"~standard\"][\"types\"]\n>[\"output\"];\n\n/** The `id` of the JSON `<script>` that carries the public values into each HTML document. */\nexport const PUBLIC_ENV_SCRIPT_ID = \"app-server-public-env\";\n\n/** Stops the search for `</head>` after this many characters, so a page with none still streams. */\nconst HEAD_SEARCH_LIMIT = 1_048_576;\n\n/** Options for {@link runtimeEnv}. */\nexport type RuntimeEnvOptions = {\n\t/** @default process.env */\n\tsource?: Readonly<Record<string, string | undefined>>;\n\t/**\n\t * Values whose names start with this prefix reach the browser.\n\t * @default \"PUBLIC_\"\n\t */\n\tpublicPrefix?: string;\n};\n\n/** The plugin that {@link runtimeEnv} returns, with the parsed values. */\nexport type RuntimeEnv<Values> = Plugin & {\n\t/** The parsed values. The first read parses, and a bad value throws. */\n\treadonly values: Values;\n\t/** The parsed values whose names start with the public prefix. */\n\treadonly publicValues: Readonly<Record<string, unknown>>;\n};\n\nfunction formatIssue(issue: StandardIssue): string {\n\tconst path = (issue.path ?? [])\n\t\t.map((segment) => String(typeof segment === \"object\" ? segment.key : segment))\n\t\t.join(\".\");\n\treturn ` ${path === \"\" ? \"(root)\" : path}: ${issue.message}`;\n}\n\n/** A JSON data block. Escaping `<` keeps a value from closing the `<script>`. */\nfunction publicEnvScript(values: Readonly<Record<string, unknown>>): string {\n\tconst json = JSON.stringify(values).replaceAll(\"<\", \"\\\\u003c\");\n\treturn `<script id=\"${PUBLIC_ENV_SCRIPT_ID}\" type=\"application/json\">${json}</script>`;\n}\n\n/** Inserts `html` before the first `</head>` of a streamed document. The rest streams as is. */\nfunction injectBeforeHeadEnd(\n\tbody: ReadableStream<Uint8Array>,\n\thtml: string,\n): ReadableStream<Uint8Array> {\n\t// Why decode every chunk: a chunk can end inside a multi-byte character.\n\tconst decoder = new TextDecoder();\n\tconst encoder = new TextEncoder();\n\tlet pending: string | undefined = \"\";\n\treturn body.pipeThrough(\n\t\tnew TransformStream<Uint8Array, Uint8Array>({\n\t\t\ttransform(chunk, controller) {\n\t\t\t\tconst text = decoder.decode(chunk, { stream: true });\n\t\t\t\tif (pending == null) {\n\t\t\t\t\tcontroller.enqueue(encoder.encode(text));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tpending += text;\n\t\t\t\tconst index = pending.search(/<\\/head>/i);\n\t\t\t\tif (index !== -1) {\n\t\t\t\t\tcontroller.enqueue(\n\t\t\t\t\t\tencoder.encode(`${pending.slice(0, index)}${html}${pending.slice(index)}`),\n\t\t\t\t\t);\n\t\t\t\t\tpending = undefined;\n\t\t\t\t} else if (pending.length > HEAD_SEARCH_LIMIT) {\n\t\t\t\t\tcontroller.enqueue(encoder.encode(pending));\n\t\t\t\t\tpending = undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t\tflush(controller) {\n\t\t\t\tconst rest = `${pending ?? \"\"}${decoder.decode()}`;\n\t\t\t\tif (rest !== \"\") {\n\t\t\t\t\tcontroller.enqueue(encoder.encode(rest));\n\t\t\t\t}\n\t\t\t},\n\t\t}),\n\t);\n}\n\n/**\n * Validates the environment once, at startup, against a schema. A missing or\n * bad value stops the server with a message that names it. The typed values\n * are on `.values`.\n *\n * The values whose names start with `PUBLIC_` go into each HTML document,\n * prerendered or rendered, as a JSON `<script id=\"app-server-public-env\">`.\n * So one image serves every environment, and a prerendered page never keeps\n * the values of the build. Put this plugin before the static stages, so it\n * sees the prerendered pages.\n *\n * @example\n * export const env = runtimeEnv(\n * \tz.object({ PUBLIC_API_URL: z.url(), SESSION_KEY: z.string().min(32) }),\n * );\n * env.values.SESSION_KEY; // => string\n *\n * // In the browser:\n * const publicEnv = JSON.parse(document.getElementById(\"app-server-public-env\")?.textContent ?? \"{}\");\n */\nexport function runtimeEnv<Schema extends StandardSchemaV1>(\n\tschema: Schema,\n\t{ source = process.env, publicPrefix = \"PUBLIC_\" }: RuntimeEnvOptions = {},\n): RuntimeEnv<InferOutput<Schema>> {\n\tlet parsed:\n\t\t| {\n\t\t\t\tvalues: InferOutput<Schema>;\n\t\t\t\tpublicValues: Readonly<Record<string, unknown>>;\n\t\t\t\tscript: string | undefined;\n\t\t }\n\t\t| undefined;\n\n\tconst parse = () => {\n\t\tif (parsed != null) {\n\t\t\treturn parsed;\n\t\t}\n\t\tconst result = schema[\"~standard\"].validate({ ...source });\n\t\tif (result instanceof Promise) {\n\t\t\tthrow new TypeError(\"runtimeEnv needs a schema that validates synchronously.\");\n\t\t}\n\t\tif (result.issues != null) {\n\t\t\tthrow new Error(\n\t\t\t\t`The environment is not valid:\\n${result.issues.map(formatIssue).join(\"\\n\")}`,\n\t\t\t);\n\t\t}\n\t\tconst values: InferOutput<Schema> = result.value;\n\t\tconst publicValues =\n\t\t\ttypeof values === \"object\" && values != null\n\t\t\t\t? Object.fromEntries(\n\t\t\t\t\t\tObject.entries(values).filter(([name]) => name.startsWith(publicPrefix)),\n\t\t\t\t\t)\n\t\t\t\t: {};\n\t\tparsed = {\n\t\t\tvalues,\n\t\t\tpublicValues,\n\t\t\tscript: Object.keys(publicValues).length > 0 ? publicEnvScript(publicValues) : undefined,\n\t\t};\n\t\treturn parsed;\n\t};\n\n\treturn {\n\t\tname: \"runtime-env\",\n\t\tget values() {\n\t\t\treturn parse().values;\n\t\t},\n\t\tget publicValues() {\n\t\t\treturn parse().publicValues;\n\t\t},\n\t\tsetup: () => {\n\t\t\tparse();\n\t\t},\n\t\tetagPart: () => parse().script,\n\t\tmiddleware: async (context, next) => {\n\t\t\tawait next();\n\t\t\tconst { script } = parse();\n\t\t\tconst response = context.res;\n\t\t\tif (\n\t\t\t\tscript == null ||\n\t\t\t\tresponse.headers.has(\"Content-Encoding\") ||\n\t\t\t\t// Why: the script changes the bytes, so a `Content-Range` would no longer match them.\n\t\t\t\tresponse.headers.has(\"Content-Range\") ||\n\t\t\t\t!(response.headers.get(\"Content-Type\")?.startsWith(\"text/html\") ?? false)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (response.body != null) {\n\t\t\t\tcontext.res = new Response(injectBeforeHeadEnd(response.body, script), response);\n\t\t\t}\n\t\t\t// Why for HEAD too: it gets the headers that GET gets. The script changes the length, and a\n\t\t\t// rendered document's ETag does not cover the values, so a 304 could keep old ones.\n\t\t\tcontext.header(\"Content-Length\", undefined);\n\t\t\tcontext.header(\"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GACA,QAAQ,OAAO,KAAK,YAAY,CAAC,CAAC,SAAS,IAAI,gBAAgB,YAAY,IAAI;EAChF;EACA,OAAO;CACR;CAEA,OAAO;EACN,MAAM;EACN,IAAI,SAAS;GACZ,OAAO,MAAM,CAAC,CAAC;EAChB;EACA,IAAI,eAAe;GAClB,OAAO,MAAM,CAAC,CAAC;EAChB;EACA,aAAa;GACZ,MAAM;EACP;EACA,gBAAgB,MAAM,CAAC,CAAC;EACxB,YAAY,OAAO,SAAS,SAAS;GACpC,MAAM,KAAK;GACX,MAAM,EAAE,WAAW,MAAM;GACzB,MAAM,WAAW,QAAQ;GACzB,IACC,UAAU,QACV,SAAS,QAAQ,IAAI,kBAAkB,KAEvC,SAAS,QAAQ,IAAI,eAAe,KACpC,EAAE,SAAS,QAAQ,IAAI,cAAc,CAAC,EAAE,WAAW,WAAW,KAAK,QAEnE;GAED,IAAI,SAAS,QAAQ,MACpB,QAAQ,MAAM,IAAI,SAAS,oBAAoB,SAAS,MAAM,MAAM,GAAG,QAAQ;GAIhF,QAAQ,OAAO,kBAAkB,MAAS;GAC1C,QAAQ,OAAO,QAAQ,MAAS;EACjC;CACD;AACD"}
@@ -0,0 +1,15 @@
1
+ // src/runtimes/listen-options.ts
2
+ /**
3
+ * The URL a listener answers on. A wildcard bind reads as `localhost`.
4
+ *
5
+ * @example
6
+ * listenerUrl("0.0.0.0", 3000); // => "http://localhost:3000/"
7
+ * listenerUrl("::1", 3000); // => "http://[::1]:3000/"
8
+ */
9
+ function listenerUrl(hostname, port) {
10
+ if (hostname == null || hostname === "" || hostname === "0.0.0.0" || hostname === "::") return `http://localhost:${port}/`;
11
+ return hostname.includes(":") ? `http://[${hostname}]:${port}/` : `http://${hostname}:${port}/`;
12
+ }
13
+
14
+ export { listenerUrl as t };
15
+ //# sourceMappingURL=listen-options-DHWmSWGi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listen-options-DHWmSWGi.js","names":[],"sources":["../src/runtimes/listen-options.ts"],"sourcesContent":["/** What every runtime listener takes. */\nexport type ListenOptions = {\n\tport: number;\n\t/** The interface to bind. When omitted, the listener binds every interface. */\n\thostname: string | undefined;\n\t/** How long an idle keep-alive connection stays open. */\n\tidleTimeoutMs: number;\n};\n\n/**\n * The URL a listener answers on. A wildcard bind reads as `localhost`.\n *\n * @example\n * listenerUrl(\"0.0.0.0\", 3000); // => \"http://localhost:3000/\"\n * listenerUrl(\"::1\", 3000); // => \"http://[::1]:3000/\"\n */\nexport function listenerUrl(hostname: string | undefined, port: number): string {\n\tif (hostname == null || hostname === \"\" || hostname === \"0.0.0.0\" || hostname === \"::\") {\n\t\treturn `http://localhost:${port}/`;\n\t}\n\treturn hostname.includes(\":\") ? `http://[${hostname}]:${port}/` : `http://${hostname}:${port}/`;\n}\n"],"mappings":";;;;;;;;AAgBA,SAAgB,YAAY,UAA8B,MAAsB;CAC/E,IAAI,YAAY,QAAQ,aAAa,MAAM,aAAa,aAAa,aAAa,MACjF,OAAO,oBAAoB,KAAK;CAEjC,OAAO,SAAS,SAAS,GAAG,IAAI,WAAW,SAAS,IAAI,KAAK,KAAK,UAAU,SAAS,GAAG,KAAK;AAC9F"}
@@ -0,0 +1,3 @@
1
+ import { n as listen, t as cancelIfClosed } from "./node-79my3Uix.js";
2
+
3
+ export { listen };
@@ -0,0 +1,58 @@
1
+ import { t as listenerUrl } from "./listen-options-DHWmSWGi.js";
2
+ import { IncomingMessage, ServerResponse } from "node:http";
3
+ import { createAdaptorServer } from "@hono/node-server";
4
+
5
+ // src/runtimes/node.ts
6
+ /**
7
+ * Cancels the body of a response whose socket closed first, and returns the
8
+ * response. `@hono/node-server` drops such a body with no cancel, and its
9
+ * producer runs on.
10
+ */
11
+ async function cancelIfClosed(response, outgoing) {
12
+ if (outgoing.destroyed) await response.body?.cancel();
13
+ return response;
14
+ }
15
+ /** Listens with `node:http` through `@hono/node-server`. */
16
+ async function listen(fetch, options) {
17
+ const server = createAdaptorServer({
18
+ fetch: async (request, { incoming, outgoing }) => {
19
+ return cancelIfClosed(await fetch(request, {
20
+ remoteAddress: incoming.socket.remoteAddress,
21
+ ...incoming instanceof IncomingMessage && outgoing instanceof ServerResponse ? {
22
+ incoming,
23
+ outgoing
24
+ } : {}
25
+ }), outgoing);
26
+ },
27
+ serverOptions: {
28
+ keepAliveTimeout: options.idleTimeoutMs,
29
+ headersTimeout: options.idleTimeoutMs + 1e3
30
+ }
31
+ });
32
+ await new Promise((resolve, reject) => {
33
+ server.once("error", reject);
34
+ server.listen(options.port, options.hostname, () => {
35
+ server.off("error", reject);
36
+ resolve();
37
+ });
38
+ });
39
+ const address = server.address();
40
+ const port = typeof address === "object" && address != null ? address.port : options.port;
41
+ return {
42
+ url: listenerUrl(options.hostname, port),
43
+ stop: ({ deadlineMs }) => new Promise((resolve, reject) => {
44
+ const deadline = setTimeout(() => {
45
+ if ("closeAllConnections" in server) server.closeAllConnections();
46
+ }, deadlineMs);
47
+ server.close((error) => {
48
+ clearTimeout(deadline);
49
+ if (error == null) resolve();
50
+ else reject(error);
51
+ });
52
+ if ("closeIdleConnections" in server) server.closeIdleConnections();
53
+ })
54
+ };
55
+ }
56
+
57
+ export { listen as n, cancelIfClosed as t };
58
+ //# sourceMappingURL=node-79my3Uix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-79my3Uix.js","names":[],"sources":["../src/runtimes/node.ts"],"sourcesContent":["import { IncomingMessage, ServerResponse } from \"node:http\";\nimport { createAdaptorServer } from \"@hono/node-server\";\nimport type { FetchHandler, StartedListener } from \"../types.js\";\nimport { listenerUrl, type ListenOptions } from \"./listen-options.js\";\n\n/**\n * Cancels the body of a response whose socket closed first, and returns the\n * response. `@hono/node-server` drops such a body with no cancel, and its\n * producer runs on.\n */\nexport async function cancelIfClosed(\n\tresponse: Response,\n\toutgoing: { destroyed: boolean },\n): Promise<Response> {\n\tif (outgoing.destroyed) {\n\t\tawait response.body?.cancel();\n\t}\n\treturn response;\n}\n\n/** Listens with `node:http` through `@hono/node-server`. */\nexport async function listen(\n\tfetch: FetchHandler,\n\toptions: ListenOptions,\n): Promise<StartedListener> {\n\tconst server = createAdaptorServer({\n\t\tfetch: async (request, { incoming, outgoing }) => {\n\t\t\tconst response = await fetch(request, {\n\t\t\t\tremoteAddress: incoming.socket.remoteAddress,\n\t\t\t\t...(incoming instanceof IncomingMessage && outgoing instanceof ServerResponse\n\t\t\t\t\t? { incoming, outgoing }\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\t\treturn cancelIfClosed(response, outgoing);\n\t\t},\n\t\tserverOptions: {\n\t\t\tkeepAliveTimeout: options.idleTimeoutMs,\n\t\t\t// Why above the keep-alive timeout: Node closes a socket that is between requests when its\n\t\t\t// headers timer runs out first.\n\t\t\theadersTimeout: options.idleTimeoutMs + 1_000,\n\t\t},\n\t});\n\tawait new Promise<void>((resolve, reject) => {\n\t\tserver.once(\"error\", reject);\n\t\tserver.listen(options.port, options.hostname, () => {\n\t\t\tserver.off(\"error\", reject);\n\t\t\tresolve();\n\t\t});\n\t});\n\tconst address = server.address();\n\tconst port = typeof address === \"object\" && address != null ? address.port : options.port;\n\treturn {\n\t\turl: listenerUrl(options.hostname, port),\n\t\tstop: ({ deadlineMs }) =>\n\t\t\tnew Promise<void>((resolve, reject) => {\n\t\t\t\tconst deadline = setTimeout(() => {\n\t\t\t\t\tif (\"closeAllConnections\" in server) {\n\t\t\t\t\t\tserver.closeAllConnections();\n\t\t\t\t\t}\n\t\t\t\t}, deadlineMs);\n\t\t\t\tserver.close((error) => {\n\t\t\t\t\tclearTimeout(deadline);\n\t\t\t\t\tif (error == null) {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t} else {\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tif (\"closeIdleConnections\" in server) {\n\t\t\t\t\tserver.closeIdleConnections();\n\t\t\t\t}\n\t\t\t}),\n\t};\n}\n"],"mappings":";;;;;;;;;;AAUA,eAAsB,eACrB,UACA,UACoB;CACpB,IAAI,SAAS,WACZ,MAAM,SAAS,MAAM,OAAO;CAE7B,OAAO;AACR;;AAGA,eAAsB,OACrB,OACA,SAC2B;CAC3B,MAAM,SAAS,oBAAoB;EAClC,OAAO,OAAO,SAAS,EAAE,UAAU,eAAe;GAOjD,OAAO,eAAe,MANC,MAAM,SAAS;IACrC,eAAe,SAAS,OAAO;IAC/B,GAAI,oBAAoB,mBAAmB,oBAAoB,iBAC5D;KAAE;KAAU;IAAS,IACrB,CAAC;GACL,CAAC,GAC+B,QAAQ;EACzC;EACA,eAAe;GACd,kBAAkB,QAAQ;GAG1B,gBAAgB,QAAQ,gBAAgB;EACzC;CACD,CAAC;CACD,MAAM,IAAI,SAAe,SAAS,WAAW;EAC5C,OAAO,KAAK,SAAS,MAAM;EAC3B,OAAO,OAAO,QAAQ,MAAM,QAAQ,gBAAgB;GACnD,OAAO,IAAI,SAAS,MAAM;GAC1B,QAAQ;EACT,CAAC;CACF,CAAC;CACD,MAAM,UAAU,OAAO,QAAQ;CAC/B,MAAM,OAAO,OAAO,YAAY,YAAY,WAAW,OAAO,QAAQ,OAAO,QAAQ;CACrF,OAAO;EACN,KAAK,YAAY,QAAQ,UAAU,IAAI;EACvC,OAAO,EAAE,iBACR,IAAI,SAAe,SAAS,WAAW;GACtC,MAAM,WAAW,iBAAiB;IACjC,IAAI,yBAAyB,QAC5B,OAAO,oBAAoB;GAE7B,GAAG,UAAU;GACb,OAAO,OAAO,UAAU;IACvB,aAAa,QAAQ;IACrB,IAAI,SAAS,MACZ,QAAQ;SAER,OAAO,KAAK;GAEd,CAAC;GACD,IAAI,0BAA0B,QAC7B,OAAO,qBAAqB;EAE9B,CAAC;CACH;AACD"}
@@ -0,0 +1,47 @@
1
+ import { D as SetupInfo, T as RequestLogger, r as AppServer, t as AppServerEntry, v as FrameworkAdapter } from "./entry-CIpwaayZ.js";
2
+ import { ServerBuild } from "react-router";
3
+ /** What the server puts in React Router's context for each request. */
4
+ export type AppServerContext = {
5
+ /** The request ID, when the `requestId` plugin runs. */
6
+ requestId: string | undefined;
7
+ /** The request's logger. Its lines carry the request ID. */
8
+ logger: RequestLogger;
9
+ };
10
+ /**
11
+ * The React Router context key for {@link AppServerContext}. Outside a server
12
+ * request, such as in React Router's prerender pass, it holds no request ID
13
+ * and a logger that writes to `jsonSink()`.
14
+ *
15
+ * @example
16
+ * export async function loader({ context }: Route.LoaderArgs) {
17
+ * context.get(appServerContext).logger.info("loading the dashboard");
18
+ * }
19
+ */
20
+ export declare const appServerContext: import("react-router").RouterContext<AppServerContext>;
21
+ /**
22
+ * Whether a module is a React Router server build.
23
+ *
24
+ * @example
25
+ * isServerBuild(await import("./build/server/index.js")); // => true
26
+ */
27
+ export declare function isServerBuild(value: unknown): value is ServerBuild;
28
+ /**
29
+ * The framework adapter for a React Router server build. Each request gets a
30
+ * `RouterContextProvider` that holds {@link appServerContext}.
31
+ *
32
+ * @example
33
+ * const framework = createAdapter(build, { mode: "production" });
34
+ */
35
+ export declare function createAdapter(build: ServerBuild, { mode }: {
36
+ mode: SetupInfo["mode"];
37
+ }): FrameworkAdapter;
38
+ /**
39
+ * The `appServer` export of a React Router server build. The `serverEntry`
40
+ * Vite plugin adds it, so the copy of this package in the build runs the
41
+ * server. With no `app`, the server has the default plugins.
42
+ *
43
+ * @example
44
+ * export const appServer = appServerEntry(build, app);
45
+ */
46
+ export declare function appServerEntry(build: ServerBuild, app?: AppServer): AppServerEntry;
47
+ //# sourceMappingURL=react-router.d.ts.map
@@ -0,0 +1,68 @@
1
+ import { h as sinkLogger, m as jsonSink, r as createServer, t as createEntry } from "./entry-2XXp2Ukh.js";
2
+ import { resolve } from "node:path";
3
+ import { RouterContextProvider, createContext, createRequestHandler } from "react-router";
4
+
5
+ // src/react-router.ts
6
+ /**
7
+ * The React Router context key for {@link AppServerContext}. Outside a server
8
+ * request, such as in React Router's prerender pass, it holds no request ID
9
+ * and a logger that writes to `jsonSink()`.
10
+ *
11
+ * @example
12
+ * export async function loader({ context }: Route.LoaderArgs) {
13
+ * context.get(appServerContext).logger.info("loading the dashboard");
14
+ * }
15
+ */
16
+ const appServerContext = createContext({
17
+ requestId: void 0,
18
+ logger: sinkLogger(jsonSink())
19
+ });
20
+ /**
21
+ * Whether a module is a React Router server build.
22
+ *
23
+ * @example
24
+ * isServerBuild(await import("./build/server/index.js")); // => true
25
+ */
26
+ function isServerBuild(value) {
27
+ return typeof value === "object" && value != null && "routes" in value && "entry" in value && "assetsBuildDirectory" in value && typeof value.assetsBuildDirectory === "string";
28
+ }
29
+ /**
30
+ * The framework adapter for a React Router server build. Each request gets a
31
+ * `RouterContextProvider` that holds {@link appServerContext}.
32
+ *
33
+ * @example
34
+ * const framework = createAdapter(build, { mode: "production" });
35
+ */
36
+ function createAdapter(build, { mode }) {
37
+ if (build.publicPath !== "/") throw new Error(`@ngrok/app-server serves a build at "/" only, and this build has the publicPath "${build.publicPath}".`);
38
+ const handler = createRequestHandler(build, mode);
39
+ return {
40
+ clientDirectory: resolve(build.assetsBuildDirectory),
41
+ prerenderedPaths: build.prerender,
42
+ fetch: (request, context) => {
43
+ const routerContext = new RouterContextProvider();
44
+ routerContext.set(appServerContext, {
45
+ requestId: context.var.requestId,
46
+ logger: context.var.logger
47
+ });
48
+ return handler(request, routerContext);
49
+ }
50
+ };
51
+ }
52
+ /**
53
+ * The `appServer` export of a React Router server build. The `serverEntry`
54
+ * Vite plugin adds it, so the copy of this package in the build runs the
55
+ * server. With no `app`, the server has the default plugins.
56
+ *
57
+ * @example
58
+ * export const appServer = appServerEntry(build, app);
59
+ */
60
+ function appServerEntry(build, app = createServer({ trustForwardedProto: process.env.TRUST_FORWARDED_PROTO === "1" })) {
61
+ return createEntry({
62
+ app,
63
+ framework: (mode) => createAdapter(build, { mode })
64
+ });
65
+ }
66
+
67
+ export { appServerContext, appServerEntry, createAdapter, isServerBuild };
68
+ //# sourceMappingURL=react-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-router.js","names":[],"sources":["../src/react-router.ts"],"sourcesContent":["import { resolve } from \"node:path\";\nimport {\n\t//,\n\tcreateContext,\n\tcreateRequestHandler,\n\tRouterContextProvider,\n\ttype ServerBuild,\n} from \"react-router\";\nimport { createServer, type AppServer } from \"./create-server.js\";\nimport { createEntry, type AppServerEntry } from \"./entry.js\";\nimport { jsonSink, sinkLogger } from \"./log.js\";\nimport type { FrameworkAdapter, RequestLogger, SetupInfo } from \"./types.js\";\n\n/** What the server puts in React Router's context for each request. */\nexport type AppServerContext = {\n\t/** The request ID, when the `requestId` plugin runs. */\n\trequestId: string | undefined;\n\t/** The request's logger. Its lines carry the request ID. */\n\tlogger: RequestLogger;\n};\n\n/**\n * The React Router context key for {@link AppServerContext}. Outside a server\n * request, such as in React Router's prerender pass, it holds no request ID\n * and a logger that writes to `jsonSink()`.\n *\n * @example\n * export async function loader({ context }: Route.LoaderArgs) {\n * \tcontext.get(appServerContext).logger.info(\"loading the dashboard\");\n * }\n */\nexport const appServerContext = createContext<AppServerContext>({\n\trequestId: undefined,\n\tlogger: sinkLogger(jsonSink()),\n});\n\n/**\n * Whether a module is a React Router server build.\n *\n * @example\n * isServerBuild(await import(\"./build/server/index.js\")); // => true\n */\nexport function isServerBuild(value: unknown): value is ServerBuild {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue != null &&\n\t\t\"routes\" in value &&\n\t\t\"entry\" in value &&\n\t\t\"assetsBuildDirectory\" in value &&\n\t\ttypeof value.assetsBuildDirectory === \"string\"\n\t);\n}\n\n/**\n * The framework adapter for a React Router server build. Each request gets a\n * `RouterContextProvider` that holds {@link appServerContext}.\n *\n * @example\n * const framework = createAdapter(build, { mode: \"production\" });\n */\nexport function createAdapter(\n\tbuild: ServerBuild,\n\t{ mode }: { mode: SetupInfo[\"mode\"] },\n): FrameworkAdapter {\n\tif (build.publicPath !== \"/\") {\n\t\tthrow new Error(\n\t\t\t`@ngrok/app-server serves a build at \"/\" only, and this build has the publicPath \"${build.publicPath}\".`,\n\t\t);\n\t}\n\tconst handler = createRequestHandler(build, mode);\n\treturn {\n\t\tclientDirectory: resolve(build.assetsBuildDirectory),\n\t\tprerenderedPaths: build.prerender,\n\t\tfetch: (request, context) => {\n\t\t\tconst routerContext = new RouterContextProvider();\n\t\t\trouterContext.set(appServerContext, {\n\t\t\t\trequestId: context.var.requestId,\n\t\t\t\tlogger: context.var.logger,\n\t\t\t});\n\t\t\treturn handler(request, routerContext);\n\t\t},\n\t};\n}\n\n/**\n * The `appServer` export of a React Router server build. The `serverEntry`\n * Vite plugin adds it, so the copy of this package in the build runs the\n * server. With no `app`, the server has the default plugins.\n *\n * @example\n * export const appServer = appServerEntry(build, app);\n */\nexport function appServerEntry(\n\tbuild: ServerBuild,\n\tapp: AppServer = createServer({ trustForwardedProto: process.env.TRUST_FORWARDED_PROTO === \"1\" }),\n): AppServerEntry {\n\treturn createEntry({ app, framework: (mode) => createAdapter(build, { mode }) });\n}\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,MAAa,mBAAmB,cAAgC;CAC/D,WAAW;CACX,QAAQ,WAAW,SAAS,CAAC;AAC9B,CAAC;;;;;;;AAQD,SAAgB,cAAc,OAAsC;CACnE,OACC,OAAO,UAAU,YACjB,SAAS,QACT,YAAY,SACZ,WAAW,SACX,0BAA0B,SAC1B,OAAO,MAAM,yBAAyB;AAExC;;;;;;;;AASA,SAAgB,cACf,OACA,EAAE,QACiB;CACnB,IAAI,MAAM,eAAe,KACxB,MAAM,IAAI,MACT,oFAAoF,MAAM,WAAW,GACtG;CAED,MAAM,UAAU,qBAAqB,OAAO,IAAI;CAChD,OAAO;EACN,iBAAiB,QAAQ,MAAM,oBAAoB;EACnD,kBAAkB,MAAM;EACxB,QAAQ,SAAS,YAAY;GAC5B,MAAM,gBAAgB,IAAI,sBAAsB;GAChD,cAAc,IAAI,kBAAkB;IACnC,WAAW,QAAQ,IAAI;IACvB,QAAQ,QAAQ,IAAI;GACrB,CAAC;GACD,OAAO,QAAQ,SAAS,aAAa;EACtC;CACD;AACD;;;;;;;;;AAUA,SAAgB,eACf,OACA,MAAiB,aAAa,EAAE,qBAAqB,QAAQ,IAAI,0BAA0B,IAAI,CAAC,GAC/E;CACjB,OAAO,YAAY;EAAE;EAAK,YAAY,SAAS,cAAc,OAAO,EAAE,KAAK,CAAC;CAAE,CAAC;AAChF"}
@@ -0,0 +1,16 @@
1
+ import { n as loadEntry } from "./entry-2XXp2Ukh.js";
2
+ import { resolve } from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+
5
+ // src/start.ts
6
+ /**
7
+ * Loads a production server build and starts it. The copy of this package in
8
+ * the build runs the server when the build has one: see `loadEntry`.
9
+ */
10
+ async function start({ buildPath }) {
11
+ const build = await import(pathToFileURL(resolve(buildPath)).href);
12
+ await (await loadEntry(build)).start();
13
+ }
14
+
15
+ export { start };
16
+ //# sourceMappingURL=start-kxw_NM4q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-kxw_NM4q.js","names":[],"sources":["../src/start.ts"],"sourcesContent":["import { resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { loadEntry } from \"./entry.js\";\n\n/**\n * Loads a production server build and starts it. The copy of this package in\n * the build runs the server when the build has one: see `loadEntry`.\n */\nexport async function start({ buildPath }: { buildPath: string }): Promise<void> {\n\tconst build: unknown = await import(pathToFileURL(resolve(buildPath)).href);\n\tawait (await loadEntry(build)).start();\n}\n"],"mappings":";;;;;;;;;AAQA,eAAsB,MAAM,EAAE,aAAmD;CAChF,MAAM,QAAiB,MAAM,OAAO,cAAc,QAAQ,SAAS,CAAC,CAAC,CAAC;CACtE,OAAO,MAAM,UAAU,KAAK,EAAC,CAAE,MAAM;AACtC"}
@@ -0,0 +1,102 @@
1
+ import { n as capturedHeadersKey, t as CAPTURED_HEADERS_FILE } from "./captured-headers-ewL_t3MQ.js";
2
+ import { join, resolve } from "node:path";
3
+ import { writeFileSync } from "node:fs";
4
+
5
+ // src/vite.ts
6
+ /** The module ID of the server build entry that {@link serverEntry} generates. */
7
+ const SERVER_ENTRY_ID = "virtual:@ngrok/app-server/entry";
8
+ const RESOLVED_SERVER_ENTRY_ID = `\0${SERVER_ENTRY_ID}`;
9
+ /** The header that turns on Node's header store for a response, so `finish` can read every header. */
10
+ const CAPTURE_MARKER = "x-app-server-capture";
11
+ /**
12
+ * Headers that describe one transfer, not the resource. The server sets its
13
+ * own, and a cookie must never replay to every visitor. `Vary` is left out
14
+ * because the preview server adds `Vary: Origin` to every response.
15
+ */
16
+ const UNCAPTURED_HEADERS = /* @__PURE__ */ new Set([
17
+ CAPTURE_MARKER,
18
+ "connection",
19
+ "content-encoding",
20
+ "content-length",
21
+ "date",
22
+ "etag",
23
+ "keep-alive",
24
+ "last-modified",
25
+ "set-cookie",
26
+ "transfer-encoding",
27
+ "vary"
28
+ ]);
29
+ /** The source of the server build entry. */
30
+ function serverEntrySource(appModule) {
31
+ return [
32
+ `export * from "virtual:react-router/server-build";`,
33
+ `import * as build from "virtual:react-router/server-build";`,
34
+ `import { appServerEntry } from "@ngrok/app-server/react-router";`,
35
+ ...appModule == null ? [`export const appServer = appServerEntry(build);`] : [`import app from ${JSON.stringify(appModule)};`, `export const appServer = appServerEntry(build, app);`]
36
+ ].join("\n");
37
+ }
38
+ /**
39
+ * Records the headers of each non-document prerender response while React
40
+ * Router's prerender pass runs, and writes them to `.headers.json` in the client build
41
+ * when the preview server closes.
42
+ */
43
+ function captureHeaders(server) {
44
+ const { config } = server;
45
+ const clientDirectory = resolve(config.root, config.environments.client?.build.outDir ?? config.build.outDir);
46
+ const captured = {};
47
+ server.middlewares.use((request, response, next) => {
48
+ const { pathname } = new URL(request.url ?? "/", "http://localhost");
49
+ response.setHeader(CAPTURE_MARKER, "1");
50
+ response.once("finish", () => {
51
+ const contentType = String(response.getHeader("content-type") ?? "");
52
+ if (response.statusCode < 200 || response.statusCode >= 300 || contentType.startsWith("text/html")) return;
53
+ const headers = {};
54
+ for (const [name, value] of Object.entries(response.getHeaders())) if (!UNCAPTURED_HEADERS.has(name) && value != null) headers[name] = Array.isArray(value) ? value.join(", ") : String(value);
55
+ captured[capturedHeadersKey(pathname)] = headers;
56
+ });
57
+ next();
58
+ });
59
+ server.httpServer.once("close", () => {
60
+ const sorted = Object.fromEntries(Object.entries(captured).toSorted(([first], [second]) => first.localeCompare(second)));
61
+ writeFileSync(join(clientDirectory, CAPTURED_HEADERS_FILE), `${JSON.stringify(sorted, null, " ")}\n`);
62
+ });
63
+ }
64
+ /**
65
+ * The Vite plugin for `@ngrok/app-server`. Put it next to `reactRouter()`.
66
+ *
67
+ * - It makes `build/server/index.js` export the app's server (the default
68
+ * export of `appModule`) next to the React Router build, so the server is
69
+ * bundled with the app, its path aliases, and its one copy of `react-router`.
70
+ * The file stays a valid server build.
71
+ * - During React Router's prerender pass, it records the headers of each
72
+ * prerendered file that is not an HTML document (resource routes and `.data`
73
+ * files) into `build/client/.headers.json`. The `prerendered` plugin replays
74
+ * them. A document's headers depend on its request, so they are not recorded.
75
+ *
76
+ * It does not support React Router `serverBundles`.
77
+ *
78
+ * @param appModule - The module whose default export is the app from `createServer`, relative to the Vite root. When omitted, the server uses its default plugins.
79
+ *
80
+ * @example
81
+ * // vite.config.ts
82
+ * export default defineConfig({ plugins: [reactRouter(), serverEntry("./server.ts")] });
83
+ */
84
+ function serverEntry(appModule) {
85
+ let root = process.cwd();
86
+ return {
87
+ name: "@ngrok/app-server",
88
+ enforce: "pre",
89
+ config: (_config, { command }) => command === "build" ? { environments: { ssr: { build: { rolldownOptions: { input: SERVER_ENTRY_ID } } } } } : void 0,
90
+ configResolved: (config) => {
91
+ root = config.root;
92
+ },
93
+ resolveId: (id) => id === "virtual:@ngrok/app-server/entry" ? RESOLVED_SERVER_ENTRY_ID : void 0,
94
+ load: (id) => id === RESOLVED_SERVER_ENTRY_ID ? serverEntrySource(appModule == null ? void 0 : resolve(root, appModule)) : void 0,
95
+ configurePreviewServer: (server) => {
96
+ if (process.env.IS_RR_BUILD_REQUEST === "yes") captureHeaders(server);
97
+ }
98
+ };
99
+ }
100
+
101
+ export { serverEntry as n, serverEntrySource as r, SERVER_ENTRY_ID as t };
102
+ //# sourceMappingURL=vite-CrNqpoeK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-CrNqpoeK.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import { writeFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type { Plugin, PreviewServer } from \"vite\";\nimport {\n\t//,\n\tCAPTURED_HEADERS_FILE,\n\tcapturedHeadersKey,\n\ttype CapturedHeaders,\n} from \"./captured-headers.js\";\n\n/** The module ID of the server build entry that {@link serverEntry} generates. */\nexport const SERVER_ENTRY_ID = \"virtual:@ngrok/app-server/entry\";\nconst RESOLVED_SERVER_ENTRY_ID = `\\0${SERVER_ENTRY_ID}`;\n\n/** The header that turns on Node's header store for a response, so `finish` can read every header. */\nconst CAPTURE_MARKER = \"x-app-server-capture\";\n\n/**\n * Headers that describe one transfer, not the resource. The server sets its\n * own, and a cookie must never replay to every visitor. `Vary` is left out\n * because the preview server adds `Vary: Origin` to every response.\n */\nconst UNCAPTURED_HEADERS = new Set([\n\tCAPTURE_MARKER,\n\t\"connection\",\n\t\"content-encoding\",\n\t\"content-length\",\n\t\"date\",\n\t\"etag\",\n\t\"keep-alive\",\n\t\"last-modified\",\n\t\"set-cookie\",\n\t\"transfer-encoding\",\n\t\"vary\",\n]);\n\n/** The source of the server build entry. */\nexport function serverEntrySource(appModule: string | undefined): string {\n\treturn [\n\t\t`export * from \"virtual:react-router/server-build\";`,\n\t\t`import * as build from \"virtual:react-router/server-build\";`,\n\t\t// Why from the bundle: the CLI calls this export, so the server runs on the bundle's copy of\n\t\t// this package and of `react-router`, the same copies as the app and the routes.\n\t\t`import { appServerEntry } from \"@ngrok/app-server/react-router\";`,\n\t\t...(appModule == null\n\t\t\t? [`export const appServer = appServerEntry(build);`]\n\t\t\t: [\n\t\t\t\t\t`import app from ${JSON.stringify(appModule)};`,\n\t\t\t\t\t`export const appServer = appServerEntry(build, app);`,\n\t\t\t\t]),\n\t].join(\"\\n\");\n}\n\n/**\n * Records the headers of each non-document prerender response while React\n * Router's prerender pass runs, and writes them to `.headers.json` in the client build\n * when the preview server closes.\n */\nfunction captureHeaders(server: PreviewServer): void {\n\tconst { config } = server;\n\tconst clientDirectory = resolve(\n\t\tconfig.root,\n\t\tconfig.environments.client?.build.outDir ?? config.build.outDir,\n\t);\n\tconst captured: CapturedHeaders = {};\n\tserver.middlewares.use((request, response, next) => {\n\t\tconst { pathname } = new URL(request.url ?? \"/\", \"http://localhost\");\n\t\t// Why: Node keeps the headers that `writeHead` gets readable only when a header was set first.\n\t\tresponse.setHeader(CAPTURE_MARKER, \"1\");\n\t\tresponse.once(\"finish\", () => {\n\t\t\t// Why skip documents: `entry.server` sets their headers for each request (a nonce, the\n\t\t\t// host), so the headers of the build's request are wrong for every other one.\n\t\t\tconst contentType = String(response.getHeader(\"content-type\") ?? \"\");\n\t\t\tif (\n\t\t\t\tresponse.statusCode < 200 ||\n\t\t\t\tresponse.statusCode >= 300 ||\n\t\t\t\tcontentType.startsWith(\"text/html\")\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst headers: Record<string, string> = {};\n\t\t\tfor (const [name, value] of Object.entries(response.getHeaders())) {\n\t\t\t\tif (!UNCAPTURED_HEADERS.has(name) && value != null) {\n\t\t\t\t\theaders[name] = Array.isArray(value) ? value.join(\", \") : String(value);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcaptured[capturedHeadersKey(pathname)] = headers;\n\t\t});\n\t\tnext();\n\t});\n\tserver.httpServer.once(\"close\", () => {\n\t\tconst sorted = Object.fromEntries(\n\t\t\tObject.entries(captured).toSorted(([first], [second]) => first.localeCompare(second)),\n\t\t);\n\t\twriteFileSync(\n\t\t\tjoin(clientDirectory, CAPTURED_HEADERS_FILE),\n\t\t\t`${JSON.stringify(sorted, null, \"\\t\")}\\n`,\n\t\t);\n\t});\n}\n\n/**\n * The Vite plugin for `@ngrok/app-server`. Put it next to `reactRouter()`.\n *\n * - It makes `build/server/index.js` export the app's server (the default\n * export of `appModule`) next to the React Router build, so the server is\n * bundled with the app, its path aliases, and its one copy of `react-router`.\n * The file stays a valid server build.\n * - During React Router's prerender pass, it records the headers of each\n * prerendered file that is not an HTML document (resource routes and `.data`\n * files) into `build/client/.headers.json`. The `prerendered` plugin replays\n * them. A document's headers depend on its request, so they are not recorded.\n *\n * It does not support React Router `serverBundles`.\n *\n * @param appModule - The module whose default export is the app from `createServer`, relative to the Vite root. When omitted, the server uses its default plugins.\n *\n * @example\n * // vite.config.ts\n * export default defineConfig({ plugins: [reactRouter(), serverEntry(\"./server.ts\")] });\n */\nexport function serverEntry(appModule?: string): Plugin {\n\tlet root = process.cwd();\n\treturn {\n\t\tname: \"@ngrok/app-server\",\n\t\t// Why `pre`: React Router reads the SSR input from the config that the plugins before it return.\n\t\tenforce: \"pre\",\n\t\tconfig: (_config, { command }) =>\n\t\t\tcommand === \"build\"\n\t\t\t\t? { environments: { ssr: { build: { rolldownOptions: { input: SERVER_ENTRY_ID } } } } }\n\t\t\t\t: undefined,\n\t\tconfigResolved: (config) => {\n\t\t\troot = config.root;\n\t\t},\n\t\tresolveId: (id) => (id === SERVER_ENTRY_ID ? RESOLVED_SERVER_ENTRY_ID : undefined),\n\t\tload: (id) =>\n\t\t\tid === RESOLVED_SERVER_ENTRY_ID\n\t\t\t\t? serverEntrySource(appModule == null ? undefined : resolve(root, appModule))\n\t\t\t\t: undefined,\n\t\tconfigurePreviewServer: (server) => {\n\t\t\t// Why this flag: React Router sets it for the preview server of its prerender pass only.\n\t\t\tif (process.env.IS_RR_BUILD_REQUEST === \"yes\") {\n\t\t\t\tcaptureHeaders(server);\n\t\t\t}\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;AAWA,MAAa,kBAAkB;AAC/B,MAAM,2BAA2B,KAAK;;AAGtC,MAAM,iBAAiB;;;;;;AAOvB,MAAM,qCAAqB,IAAI,IAAI;CAClC;CACA;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ACvC;CACD,CAAC;AACF;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,YAAY,WAA4B;CACvD,IAAI,OAAO,QAAQ,IAAI;CACvB,OAAO;EACN,MAAM;EAEN,SAAS;EACT,SAAS,SAAS,EAAE,cACnB,YAAY,UACT,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,gBAAgB,EAAE,EAAE,EAAE,EAAE,IACpF;EACJ,iBAAiB,WAAW;GAC3B,OAAO,OAAO;EACf;EACA,YAAY,OAAQ,2CAAyB,2BAA2B;EACxE,OAAO,OACN,OAAO,2BACJ,kBAAkB,aAAa,OAAO,SAAY,QAAQ,MAAM,SAAS,CAAC,IAC1E;EACJ,yBAAyB,WAAW;GAEnC,IAAI,QAAQ,IAAI,wBAAwB,OACvC,eAAe,MAAM;EAEvB;CACD;AACD"}
package/dist/vite.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import { Plugin } from "vite";
2
+ /** The module ID of the server build entry that {@link serverEntry} generates. */
3
+ export declare const SERVER_ENTRY_ID = "virtual:@ngrok/app-server/entry";
4
+ /** The source of the server build entry. */
5
+ export declare function serverEntrySource(appModule: string | undefined): string;
6
+ /**
7
+ * The Vite plugin for `@ngrok/app-server`. Put it next to `reactRouter()`.
8
+ *
9
+ * - It makes `build/server/index.js` export the app's server (the default
10
+ * export of `appModule`) next to the React Router build, so the server is
11
+ * bundled with the app, its path aliases, and its one copy of `react-router`.
12
+ * The file stays a valid server build.
13
+ * - During React Router's prerender pass, it records the headers of each
14
+ * prerendered file that is not an HTML document (resource routes and `.data`
15
+ * files) into `build/client/.headers.json`. The `prerendered` plugin replays
16
+ * them. A document's headers depend on its request, so they are not recorded.
17
+ *
18
+ * It does not support React Router `serverBundles`.
19
+ *
20
+ * @param appModule - The module whose default export is the app from `createServer`, relative to the Vite root. When omitted, the server uses its default plugins.
21
+ *
22
+ * @example
23
+ * // vite.config.ts
24
+ * export default defineConfig({ plugins: [reactRouter(), serverEntry("./server.ts")] });
25
+ */
26
+ export declare function serverEntry(appModule?: string): Plugin;
27
+ //# sourceMappingURL=vite.d.ts.map
package/dist/vite.js ADDED
@@ -0,0 +1,3 @@
1
+ import { n as serverEntry, r as serverEntrySource, t as SERVER_ENTRY_ID } from "./vite-CrNqpoeK.js";
2
+
3
+ export { SERVER_ENTRY_ID, serverEntry, serverEntrySource };