@ngrok/app-server 0.4.1 → 0.5.1
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/README.md +223 -64
- package/dist/brotli-only-BVAagKt3.js +63 -0
- package/dist/build-id-CwMbED1n.js +245 -0
- package/dist/{build-manifest-DBMWe3Lx.js → build-manifest-CoBztw_6.js} +13 -4
- package/dist/bun-BCz6K_Xv.js +1 -2
- package/dist/check-count-DQl5z_qe.js +17 -0
- package/dist/cli.js +9 -6
- package/dist/client-browser.d.ts +2 -3
- package/dist/client-browser.js +1 -1
- package/dist/client.d.ts +5 -4
- package/dist/client.js +9 -6
- package/dist/{compress-Cp5NfXCC.js → compress-2w3jqBh7.js} +2 -3
- package/dist/{compression-CT2mWlKM.js → compression-uJxu0JVb.js} +32 -5
- package/dist/content-types-Le-5BNEC.js +10 -0
- package/dist/{create-server-Bp1yILQk.js → create-server-DVTZun6D.js} +617 -306
- package/dist/create-server-PA0qniaK.js +3 -0
- package/dist/{create-server-X2GR-U6t.d.ts → create-server-UVsHFQyK.d.ts} +116 -54
- package/dist/deno-aqhikNMG.js +1 -2
- package/dist/{entry-BoxCqc6w.js → entry-CMhX3yf8.js} +85 -65
- package/dist/entry-CvZ4U0ia.js +3 -0
- package/dist/{entry-DZTCaL3d.d.ts → entry-DBq_3s8X.d.ts} +10 -36
- package/dist/entry-protocol-C30UPXzy.js +14 -0
- package/dist/entry-source-DSE5NAJu.js +70 -0
- package/dist/entry-source-SHoE-DUP.js +3 -0
- package/dist/exit-Hh-O3gp4.js +83 -0
- package/dist/{header-hook-Vzw9J9BY.js → header-hook-JfqaTt34.js} +69 -23
- package/dist/{index-B8LsM6Mh.d.ts → index-gzGs53Ue.d.ts} +43 -38
- package/dist/index.d.ts +88 -44
- package/dist/index.js +216 -84
- package/dist/listen-options-7TaXjyrk.js +1 -2
- package/dist/{load-entry-CCPWbsrj.js → load-entry-Bgq1_HDV.js} +11 -12
- package/dist/{log-DQAS5gGT.js → log-DfC9D5_T.js} +70 -49
- package/dist/{node-D6m6e6EI.js → node-DQPrMFyc.js} +20 -8
- package/dist/node-DyKDFII0.js +263 -0
- package/dist/node-vite.d.ts +2 -3
- package/dist/node-vite.js +1 -1
- package/dist/node.d.ts +41 -64
- package/dist/node.js +3 -3
- package/dist/react-router-vite.d.ts +2 -3
- package/dist/react-router-vite.js +1 -1
- package/dist/react-router.d.ts +6 -17
- package/dist/react-router.js +9 -14
- package/dist/request-context-Cslbrscf.js +163 -0
- package/dist/{response-edge-CU8ZvL_F.js → response-edge-Ow5Pi5qF.js} +13 -10
- package/dist/{response-writer-D7KHfr8n.js → response-writer-Dd4Ey99f.js} +57 -21
- package/dist/{script-hashes-CU7P9oZU.js → script-hashes-BdvJ0QI_.js} +2 -3
- package/dist/serve-AatMo9k6.js +26 -0
- package/dist/{stale-build-navigation-rg5xxmTr.js → stale-build-navigation-Qf_Lem39.js} +4 -5
- package/dist/{stale-build-navigation-ypV7Ow4o.d.ts → stale-build-navigation-WjhD8zHi.d.ts} +4 -4
- package/dist/start-DYFyGKsM.js +470 -0
- package/dist/static-files-BdTPam5b.js +438 -0
- package/dist/static-pages-6IBHdYQc.d.ts +30 -0
- package/dist/tanstack-start-vite.d.ts +2 -3
- package/dist/tanstack-start-vite.js +1 -1
- package/dist/tanstack-start.d.ts +3 -4
- package/dist/tanstack-start.js +2 -3
- package/dist/tcp-3v4pmnYU.js +58 -0
- package/dist/testing.d.ts +8 -6
- package/dist/testing.js +19 -17
- package/dist/{trailing-slash-D2QWKWEu.d.ts → trailing-slash-C-yBKCib.d.ts} +2 -3
- package/dist/{types-MgFtkNQW.d.ts → types-KsKRDwAv.d.ts} +97 -46
- package/dist/vercel-pages.d.ts +3 -16
- package/dist/vercel-pages.js +1 -2
- package/dist/vercel-vite.d.ts +4 -5
- package/dist/vercel-vite.js +48 -44
- package/dist/vercel.d.ts +13 -10
- package/dist/vercel.js +48 -35
- package/dist/{vite-D4hfj3ph.js → vite-Brb8YR9I.js} +2 -7
- package/dist/{vite-B-GfswoH.js → vite-CHppJWp_.js} +5 -7
- package/dist/{vite-DyrhyKEr.js → vite-DjlHdyTM.js} +2 -7
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +885 -2
- package/package.json +13 -12
- package/dist/brotli-only-DrA29Ecw.js +0 -97
- package/dist/brotli-only-DrA29Ecw.js.map +0 -1
- package/dist/build-id-B0448vZH.js +0 -151
- package/dist/build-id-B0448vZH.js.map +0 -1
- package/dist/build-manifest-DBMWe3Lx.js.map +0 -1
- package/dist/bun-BCz6K_Xv.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/compress-Cp5NfXCC.js.map +0 -1
- package/dist/compression-CT2mWlKM.js.map +0 -1
- package/dist/create-server-Bp1yILQk.js.map +0 -1
- package/dist/deno-aqhikNMG.js.map +0 -1
- package/dist/entry-BoxCqc6w.js.map +0 -1
- package/dist/header-hook-Vzw9J9BY.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/listen-options-7TaXjyrk.js.map +0 -1
- package/dist/load-entry-CCPWbsrj.js.map +0 -1
- package/dist/log-DQAS5gGT.js.map +0 -1
- package/dist/node-CVVdk2N6.js +0 -334
- package/dist/node-CVVdk2N6.js.map +0 -1
- package/dist/node-D6m6e6EI.js.map +0 -1
- package/dist/react-router.js.map +0 -1
- package/dist/request-context-Bxdbk5P1.js +0 -80
- package/dist/request-context-Bxdbk5P1.js.map +0 -1
- package/dist/response-edge-CU8ZvL_F.js.map +0 -1
- package/dist/response-writer-D7KHfr8n.js.map +0 -1
- package/dist/script-hashes-CU7P9oZU.js.map +0 -1
- package/dist/serve-W4WacdOw.js +0 -29
- package/dist/serve-W4WacdOw.js.map +0 -1
- package/dist/stale-build-navigation-rg5xxmTr.js.map +0 -1
- package/dist/start-j0VlxeiI.js +0 -324
- package/dist/start-j0VlxeiI.js.map +0 -1
- package/dist/static-files-C2ea8KQ6.js +0 -310
- package/dist/static-files-C2ea8KQ6.js.map +0 -1
- package/dist/tanstack-start.js.map +0 -1
- package/dist/tcp-BgDXbjOG.js +0 -42
- package/dist/tcp-BgDXbjOG.js.map +0 -1
- package/dist/testing.js.map +0 -1
- package/dist/vercel-pages.js.map +0 -1
- package/dist/vercel-vite.js.map +0 -1
- package/dist/vercel.js.map +0 -1
- package/dist/vite-B-GfswoH.js.map +0 -1
- package/dist/vite-D4hfj3ph.js.map +0 -1
- package/dist/vite-DPiSKHDn.js +0 -870
- package/dist/vite-DPiSKHDn.js.map +0 -1
- package/dist/vite-DyrhyKEr.js.map +0 -1
package/dist/serve-W4WacdOw.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { t as loadEntry } from "./load-entry-CCPWbsrj.js";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
import { pathToFileURL } from "node:url";
|
|
5
|
-
|
|
6
|
-
// src/cli/serve.ts
|
|
7
|
-
/**
|
|
8
|
-
* Where `app-server serve` looks for the server build when no path is given:
|
|
9
|
-
* the node host's entry in the React Router and Vite output layouts, then a
|
|
10
|
-
* plain React Router build.
|
|
11
|
-
*/
|
|
12
|
-
const DEFAULT_BUILD_PATHS = [
|
|
13
|
-
"build/server/app-server.js",
|
|
14
|
-
"dist/server/app-server.js",
|
|
15
|
-
"build/server/index.js"
|
|
16
|
-
];
|
|
17
|
-
/**
|
|
18
|
-
* Loads a production server build and starts it. The copy of this package in
|
|
19
|
-
* the build runs the server when the build has one: see `loadEntry`.
|
|
20
|
-
*/
|
|
21
|
-
async function serve({ buildPath }) {
|
|
22
|
-
const path = buildPath ?? DEFAULT_BUILD_PATHS.find((candidate) => existsSync(candidate));
|
|
23
|
-
if (path == null) throw new Error(`No server build found. Build the app, or pass its path. Looked for: ${DEFAULT_BUILD_PATHS.join(", ")}.`);
|
|
24
|
-
const build = await import(pathToFileURL(resolve(path)).href);
|
|
25
|
-
await (await loadEntry(build)).start();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { serve };
|
|
29
|
-
//# sourceMappingURL=serve-W4WacdOw.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serve-W4WacdOw.js","names":[],"sources":["../src/cli/serve.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { loadEntry } from \"./load-entry.js\";\n\n/**\n * Where `app-server serve` looks for the server build when no path is given:\n * the node host's entry in the React Router and Vite output layouts, then a\n * plain React Router build.\n */\nexport const DEFAULT_BUILD_PATHS = [\n\t\"build/server/app-server.js\",\n\t\"dist/server/app-server.js\",\n\t\"build/server/index.js\",\n];\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 serve({ buildPath }: { buildPath: string | undefined }): Promise<void> {\n\tconst path = buildPath ?? DEFAULT_BUILD_PATHS.find((candidate) => existsSync(candidate));\n\tif (path == null) {\n\t\tthrow new Error(\n\t\t\t`No server build found. Build the app, or pass its path. Looked for: ${DEFAULT_BUILD_PATHS.join(\", \")}.`,\n\t\t);\n\t}\n\tconst build: unknown = await import(pathToFileURL(resolve(path)).href);\n\tawait (await loadEntry(build)).start();\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,sBAAsB;CAClC;CACA;CACA;AACD;;;;;AAMA,eAAsB,MAAM,EAAE,aAA+D;CAC5F,MAAM,OAAO,aAAa,oBAAoB,MAAM,cAAc,WAAW,SAAS,CAAC;CACvF,IAAI,QAAQ,MACX,MAAM,IAAI,MACT,uEAAuE,oBAAoB,KAAK,IAAI,EAAE,EACvG;CAED,MAAM,QAAiB,MAAM,OAAO,cAAc,QAAQ,IAAI,CAAC,CAAC,CAAC;CACjE,OAAO,MAAM,UAAU,KAAK,EAAC,CAAE,MAAM;AACtC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stale-build-navigation-rg5xxmTr.js","names":[],"sources":["../src/client/document-nonce.ts","../src/client/stale-build-navigation.ts"],"sourcesContent":["/**\n * The CSP nonce of the document's first element with a nonce, or `undefined`\n * when it has none. The browser build of `@ngrok/app-server/client` exports it\n * as `cspNonce()`, so the browser bundle holds no server code.\n *\n * @example\n * documentNonce(); // => \"d2hhdCBhIG5vbmNl\"\n */\nexport function documentNonce(): string | undefined {\n\t// Why the property: a browser hides the value of the `nonce` attribute when the page's CSP applies.\n\treturn document.querySelector<HTMLElement>(\"[nonce]\")?.nonce;\n}\n","import {\n\tBUILD_ID_HEADER,\n\tBUILD_ID_METRIC,\n\tisBuildMetric,\n\tserverTimingMetrics,\n} from \"../core/plugins/build-id.js\";\n\n/** Options for {@link staleBuildReactRouter} and {@link staleBuildTanStack}. */\nexport type StaleBuildOptions = {\n\t/**\n\t * The header that `buildId()` sets on data responses.\n\t * @default \"X-Build-Id\"\n\t */\n\theader?: string;\n\t/**\n\t * The build that this document runs. Set it only when the server does not\n\t * send it.\n\t * @default the `build` metric of the document's `Server-Timing`, which `buildId()` sends\n\t */\n\tbuild?: string;\n\t/**\n\t * Runs once, when the tab first sees a response from another build. Use\n\t * it to count stale tabs in the app's RUM tool.\n\t */\n\tonNewBuild?: (served: string) => void;\n};\n\n/** The context that React Router gives `unstable_fetch` with each request. */\nexport type RouterFetchContext = {\n\t/** `\"navigation\"` for the data request of a navigation that the router started. */\n\ttype: string;\n\t/** `\"PUSH\"`, `\"REPLACE\"`, or `\"POP\"` for a navigation. */\n\tnavigationType?: string | null;\n\t/** The fetcher that sends the request, also in a navigation that revalidates it. */\n\tfetcherKey?: string | null;\n};\n\n/** The location in a TanStack Router event. */\ntype EventLocation = { pathname: string; searchStr: string };\n\n/** The part of a TanStack Router that {@link staleBuildTanStack} reads. */\nexport type NavigationEvents = {\n\thistory: { flush: () => void };\n\tclearCache: () => void;\n\tsubscribe: (\n\t\ttype: \"onBeforeNavigate\" | \"onResolved\",\n\t\tlistener: (event: { fromLocation?: EventLocation; toLocation: EventLocation }) => void,\n\t) => () => void;\n};\n\n/** Whether `url` is on the origin of this page. */\nfunction isOwn(url: string): boolean {\n\treturn new URL(url, location.href).origin === location.origin;\n}\n\n/** The build in the `Server-Timing` of the first of `entries` that has one, from this origin only. */\nfunction timingBuild(entries: PerformanceEntryList): string | undefined {\n\treturn (\n\t\tentries\n\t\t\t.filter(\n\t\t\t\t(entry): entry is PerformanceResourceTiming => \"serverTiming\" in entry && isOwn(entry.name),\n\t\t\t)\n\t\t\t// Why: a redirected resource keeps its first URL as its name, and the redirect can end on\n\t\t\t// another origin. A document entry has its final URL.\n\t\t\t.filter((entry) => entry.entryType !== \"resource\" || entry.redirectStart === 0)\n\t\t\t.flatMap((entry) => entry.serverTiming)\n\t\t\t.find((metric) => metric.name === BUILD_ID_METRIC)?.description\n\t);\n}\n\n/** The build in a `Server-Timing` header, as `buildId()` writes it. */\nfunction headerBuild(header: string | null): string | undefined {\n\tconst { quoted, token } =\n\t\tserverTimingMetrics(header)\n\t\t\t.find((metric) => isBuildMetric(metric))\n\t\t\t?.match(/;\\s*desc\\s*=\\s*(?:\"(?<quoted>(?:[^\"\\\\]|\\\\.)*)\"|(?<token>[^;\\s]*))/iu)?.groups ?? {};\n\treturn quoted?.replaceAll(/\\\\(?<char>.)/gu, \"$<char>\") ?? token;\n}\n\n/** The page of `url`: the router renders a new route for a new path or query, not for a new fragment. */\nfunction pageOf(url: string): string {\n\tconst { origin, pathname, search } = new URL(url, location.href);\n\treturn `${origin}${pathname}${search}`;\n}\n\n/** The page of a TanStack Router location, as {@link pageOf} reads a URL. */\nfunction eventPage({ pathname, searchStr }: EventLocation): string {\n\treturn `${pathname}${searchStr}`;\n}\n\n/** The URL of a `fetch` call. */\nfunction urlOf(input: RequestInfo | URL): string {\n\treturn input instanceof Request ? input.url : String(input);\n}\n\n/** The method of a `fetch` call. */\nfunction methodOf(input: RequestInfo | URL, init: RequestInit | undefined): string {\n\treturn (init?.method ?? (input instanceof Request ? input.method : \"GET\")).toUpperCase();\n}\n\n/** The page that a React Router data request loads: `/a.data` loads `/a`, and `/a/_.data` loads `/a/`. */\nfunction targetOf(request: Request): string {\n\tconst url = new URL(request.url);\n\turl.pathname = url.pathname.replace(/\\/_\\.data$/u, \"/\").replace(/\\.data$/u, \"\");\n\turl.searchParams.delete(\"_routes\");\n\treturn url.href;\n}\n\n/**\n * Reloads a document that the back/forward cache shows again. Why: Back can\n * show the document that {@link loadDocument} left, with its router still in a\n * navigation that never ends. Why one function: the browser adds it once.\n */\nfunction reloadIfRestored(event: PageTransitionEvent): void {\n\tif (event.persisted) {\n\t\tlocation.reload();\n\t}\n}\n\n/**\n * Loads `target` as a document, so the old code never gets the new build's\n * data. It returns a promise that never settles, because the page unloads.\n */\nasync function loadDocument(\n\ttarget: string,\n\t{\n\t\tresponse,\n\t\tnavigationType,\n\t}: { response?: Response | undefined; navigationType?: string | null | undefined } = {},\n): Promise<never> {\n\t// Why no wait: the cancel of a cloned body waits for the other branch.\n\tresponse?.body?.cancel().catch(() => undefined);\n\t// Why reload on this page: the router can move history first, and `assign` to the same page\n\t// with a fragment scrolls with no document load. A history step already moved history. Why\n\t// not to remove a fragment: `assign` to a URL with no fragment loads the document.\n\tconst isSamePage = pageOf(target) === pageOf(location.href);\n\tconst removesFragment = new URL(target, location.href).hash === \"\" && location.hash !== \"\";\n\taddEventListener(\"pageshow\", reloadIfRestored, { once: true });\n\tif (navigationType === \"POP\" || (isSamePage && !removesFragment)) {\n\t\tlocation.reload();\n\t} else if (navigationType === \"REPLACE\") {\n\t\tlocation.replace(target);\n\t} else {\n\t\tlocation.assign(target);\n\t}\n\treturn new Promise<never>(() => {});\n}\n\n/**\n * Runs `clear` when `signal` aborts. Why: the router aborts a navigation when a\n * newer one starts, such as after the visitor stays on the page at a leave prompt.\n */\nfunction onAbort(signal: AbortSignal, clear: () => void): void {\n\tsignal.addEventListener(\"abort\", clear, { once: true });\n}\n\n/** Reads the build of each response, and tells when the server runs a new build. */\nfunction watchBuild({ header = BUILD_ID_HEADER, build, onNewBuild }: StaleBuildOptions) {\n\t// Why: on the server, such as in a router factory that runs for each request, there is no tab to move.\n\tif (typeof document === \"undefined\") {\n\t\treturn null;\n\t}\n\tconst current = build ?? timingBuild(performance.getEntriesByType(\"navigation\"));\n\tif (current == null) {\n\t\treturn null;\n\t}\n\tlet stale = false;\n\tconst see = (served: string | null | undefined) => {\n\t\tif (served == null || served === current || stale) {\n\t\t\treturn;\n\t\t}\n\t\tstale = true;\n\t\t// Why a catch: an error in the app's callback must not fail the request that found the build.\n\t\ttry {\n\t\t\tonNewBuild?.(served);\n\t\t} catch (error) {\n\t\t\treportError(error);\n\t\t}\n\t};\n\t// Why resource timing: it shows the build of a response that no script fetched, such as a\n\t// prefetch on hover, so the tab can find a new build before the click. Why buffered: a prefetch\n\t// can finish before this module runs.\n\tconst observer =\n\t\ttypeof PerformanceObserver === \"function\"\n\t\t\t? new PerformanceObserver((list) => {\n\t\t\t\t\t// Why each entry: one delivery can hold the old build first and the new build after it.\n\t\t\t\t\tfor (const entry of list.getEntries()) {\n\t\t\t\t\t\tsee(timingBuild([entry]));\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t: undefined;\n\tobserver?.observe({ type: \"resource\", buffered: true });\n\treturn {\n\t\tisStale: () => stale,\n\t\t/** Whether `response` comes from a new build of this origin. `url` is the URL of the request. */\n\t\tisNew: (response: Response, url: string) => {\n\t\t\t// Why the final URL: a redirect can end on another origin. Why `Server-Timing`: a proxy\n\t\t\t// route of `buildId({ paths })` sends no build header.\n\t\t\tconst served = isOwn(response.url === \"\" ? url : response.url)\n\t\t\t\t? (response.headers.get(header) ?? headerBuild(response.headers.get(\"Server-Timing\")))\n\t\t\t\t: null;\n\t\t\tsee(served);\n\t\t\treturn served != null && served !== current;\n\t\t},\n\t\tstop: () => observer?.disconnect(),\n\t};\n}\n\n/** The `navigate` call of a React Router instrumentation. */\ntype NavigateInfo = { to: string | number; formMethod?: string };\n\n/** The router instrumentations that {@link staleBuildReactRouter} adds. */\ntype RouterInstrumentations = {\n\tnavigate: (handler: () => Promise<unknown>, info: NavigateInfo) => Promise<void>;\n};\n\n/**\n * The arguments of a client middleware call. Why the `unstable_` fields: React\n * Router gives the middleware the arguments of its data strategy, which tell a\n * navigation from a fetcher and give its history action.\n */\ntype MiddlewareArgs = {\n\trequest: Request;\n\tunstable_initiator?: string;\n\tunstable_navigationType?: string | null;\n};\n\n/** The hooks that {@link staleBuildReactRouter} gives to React Router. */\nexport type StaleBuildReactRouter = {\n\t/** Give it to `HydratedRouter` as `unstable_fetch`. */\n\tfetch: (request: Request, context: RouterFetchContext) => Promise<Response>;\n\t/** Give it to `HydratedRouter` in `instrumentations`. */\n\tinstrumentation: {\n\t\trouter: (router: { instrument: (instrumentations: RouterInstrumentations) => void }) => void;\n\t};\n\t/** Export it from `app/root.tsx` in `clientMiddleware`. */\n\tmiddleware: <Result>(args: { request: Request }, next: () => Promise<Result>) => Promise<Result>;\n};\n\n/** The fragment of a `navigate` target, such as `#usage`, or `\"\"`. */\nfunction hashOf(to: string | number): string {\n\treturn typeof to === \"string\" && to.includes(\"#\") ? to.slice(to.indexOf(\"#\")) : \"\";\n}\n\n/**\n * Moves an open React Router tab to a new build at a navigation, so the old\n * client code never renders data from the new server, and the page that the\n * visitor reads never reloads. Create it in a module that the client entry\n * and `app/root.tsx` both import. It reads no browser state until React\n * Router calls it, so the server can import it.\n *\n * - When the data request of a navigation gets a response from a new build,\n * the browser loads the target URL as a document.\n * - When the tab already knows of a new build, a `navigate` call, such as a\n * link click, loads its target as a document before the router renders it\n * or sends a data request. The root middleware does this also for a route\n * with no loader.\n * - A revalidation, a fetcher, an action, and the loaders after an action\n * get their response. They only mark the tab, so the page that the visitor\n * reads never reloads.\n * - The router's blockers run first, and a canceled navigation never loads\n * its target.\n *\n * It sends no request of its own and adds no wait. It needs `buildId()` in\n * the server's pipeline, and it does nothing on a document with no build.\n *\n * @example\n * // app/stale-build.ts\n * export const staleBuild = staleBuildReactRouter();\n *\n * // app/root.tsx\n * export const clientMiddleware = [staleBuild.middleware];\n *\n * // app/entry.client.tsx\n * startTransition(() => {\n * \thydrateRoot(\n * \t\tdocument,\n * \t\t<HydratedRouter\n * \t\t\tunstable_fetch={staleBuild.fetch}\n * \t\t\tinstrumentations={[staleBuild.instrumentation]}\n * \t\t/>,\n * \t);\n * });\n */\nexport function staleBuildReactRouter(options: StaleBuildOptions = {}): StaleBuildReactRouter {\n\t// Why lazy: `app/root.tsx` also runs on the server, which has no tab to watch.\n\tlet watched: { watch: ReturnType<typeof watchBuild> } | undefined;\n\tconst watch = () => {\n\t\twatched ??= { watch: watchBuild(options) };\n\t\treturn watched.watch;\n\t};\n\t/**\n\t * The path of the last action of a navigation, until its loaders run. The\n\t * router revalidates the page with one or more loader requests after it.\n\t * `loading` is true while they run.\n\t */\n\tlet action: { path: string; loading: boolean } | undefined;\n\t/** The target that the tab loads as a document now. */\n\tlet leaving: string | undefined;\n\t/**\n\t * The last `navigate` call. `claimed` is true when its first middleware call\n\t * already ran, or when it is not a page load. `page` is the target page of\n\t * that first call.\n\t */\n\tlet navigating: { hash: string; claimed: boolean; page?: string } | undefined;\n\tconst load = async (\n\t\trequest: Request,\n\t\ttarget: string,\n\t\t{ response, navigationType }: { response?: Response; navigationType?: string | null } = {},\n\t) => {\n\t\tif (leaving === target) {\n\t\t\tvoid response?.body?.cancel().catch(() => undefined);\n\t\t\treturn new Promise<never>(() => {});\n\t\t}\n\t\tleaving = target;\n\t\tonAbort(request.signal, () => {\n\t\t\tif (leaving === target) {\n\t\t\t\tleaving = undefined;\n\t\t\t}\n\t\t});\n\t\treturn loadDocument(target, { response, navigationType });\n\t};\n\treturn {\n\t\tfetch: async (request, context) => {\n\t\t\tconst navigationType =\n\t\t\t\tcontext.type === \"navigation\" && context.fetcherKey == null\n\t\t\t\t\t? context.navigationType\n\t\t\t\t\t: undefined;\n\t\t\t// Why the global at each call: an app can wrap `fetch` after this module, such as for RUM.\n\t\t\tconst send = async () => {\n\t\t\t\tconst response = await globalThis.fetch(request);\n\t\t\t\treturn { response, isNew: watch()?.isNew(response, request.url) === true };\n\t\t\t};\n\t\t\tif (watch() == null || navigationType == null) {\n\t\t\t\treturn (await send()).response;\n\t\t\t}\n\t\t\t// Why the hash of the `navigate` call: the router removes it from the data request. Why\n\t\t\t// its page only: a redirect goes to another page with no `navigate` call.\n\t\t\tconst page = targetOf(request);\n\t\t\tconst hash =\n\t\t\t\tnavigationType !== \"POP\" && navigating?.page === pageOf(page) ? navigating.hash : \"\";\n\t\t\tconst target = page + hash;\n\t\t\tconst path = new URL(target).pathname;\n\t\t\tconst isAfterAction = request.method === \"GET\" && action?.path === path;\n\t\t\t// Why check the signal: a canceled navigation must never load its target.\n\t\t\tconst isNavigation = () =>\n\t\t\t\trequest.method === \"GET\" && !isAfterAction && !request.signal.aborted;\n\t\t\tif (isNavigation() && watch()?.isStale() === true) {\n\t\t\t\treturn load(request, target, { navigationType });\n\t\t\t}\n\t\t\tconst { response, isNew } = await send();\n\t\t\tif (!isNew || !isNavigation()) {\n\t\t\t\treturn response;\n\t\t\t}\n\t\t\treturn load(request, target, { response, navigationType });\n\t\t},\n\t\tinstrumentation: {\n\t\t\trouter: ({ instrument }) => {\n\t\t\t\twatch();\n\t\t\t\tinstrument({\n\t\t\t\t\tnavigate: async (handler, { to, formMethod }) => {\n\t\t\t\t\t\t// Why claimed: a history step and a form submission are not a page load to take over.\n\t\t\t\t\t\tconst current = {\n\t\t\t\t\t\t\thash: hashOf(to),\n\t\t\t\t\t\t\tclaimed: typeof to === \"number\" || (formMethod ?? \"GET\").toUpperCase() !== \"GET\",\n\t\t\t\t\t\t};\n\t\t\t\t\t\tnavigating = current;\n\t\t\t\t\t\tawait handler();\n\t\t\t\t\t\t// Why keep an unclaimed call: a blocker stops it, and `blocker.proceed()` starts it\n\t\t\t\t\t\t// again with no `navigate` call.\n\t\t\t\t\t\tif (navigating === current && current.claimed) {\n\t\t\t\t\t\t\tnavigating = undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t\tmiddleware: async (args, next) => {\n\t\t\tconst {\n\t\t\t\trequest,\n\t\t\t\tunstable_initiator: initiator,\n\t\t\t\tunstable_navigationType: navigationType,\n\t\t\t} = args as MiddlewareArgs;\n\t\t\tconst current = navigating;\n\t\t\tif (initiator === \"navigation\") {\n\t\t\t\t// Why here: a `clientAction` sends no request, and the router runs the middleware once\n\t\t\t\t// for an action and once for all the loaders after it.\n\t\t\t\tconst path = new URL(request.url).pathname;\n\t\t\t\tconst mark = action;\n\t\t\t\tif (navigationType === \"POP\") {\n\t\t\t\t\taction = undefined;\n\t\t\t\t} else if (request.method !== \"GET\") {\n\t\t\t\t\tconst started = { path, loading: false };\n\t\t\t\t\taction = started;\n\t\t\t\t\tonAbort(request.signal, () => {\n\t\t\t\t\t\tif (action === started) {\n\t\t\t\t\t\t\taction = undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\treturn next();\n\t\t\t\t} else if (mark?.path === path) {\n\t\t\t\t\tmark.loading = true;\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn await next();\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tif (action === mark) {\n\t\t\t\t\t\t\taction = undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (mark?.loading === false) {\n\t\t\t\t\t// Why: a redirect after the action goes to another page, and its loaders never run.\n\t\t\t\t\t// Why not while they run: the router revalidates the fetchers next to them.\n\t\t\t\t\taction = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Why no history step: it comes from no `navigate` call, and the fetch hook reloads it.\n\t\t\t// Why the first call only: the router runs the middleware of a navigation before the\n\t\t\t// fetchers that it revalidates, and they have the same initiator.\n\t\t\tif (\n\t\t\t\tinitiator !== \"navigation\" ||\n\t\t\t\tnavigationType == null ||\n\t\t\t\tnavigationType === \"POP\" ||\n\t\t\t\tcurrent == null ||\n\t\t\t\tcurrent.claimed\n\t\t\t) {\n\t\t\t\treturn next();\n\t\t\t}\n\t\t\tcurrent.claimed = true;\n\t\t\tcurrent.page = pageOf(request.url);\n\t\t\tif (\n\t\t\t\trequest.signal.aborted ||\n\t\t\t\twatch()?.isStale() !== true ||\n\t\t\t\tpageOf(request.url) === pageOf(location.href)\n\t\t\t) {\n\t\t\t\treturn next();\n\t\t\t}\n\t\t\treturn load(request, request.url + current.hash, { navigationType });\n\t\t},\n\t};\n}\n\n/**\n * Moves an open TanStack Router tab to a new build at a navigation, so the\n * old client code never renders data from the new server, and the page that\n * the visitor reads never reloads. Call it with the router on the client.\n *\n * - A navigation runs from `onBeforeNavigate` to `onResolved`. The router\n * moves history and runs its blockers before it.\n * - When a GET response from a new build comes back while a navigation\n * runs, such as from a server function in a loader, the browser loads the\n * page as a document.\n * - When the tab already knows of a new build, a navigation to a new path or\n * query clears the router cache and loads the page as a document.\n * - A request outside a navigation gets its response, and only marks the tab.\n *\n * It sends no request of its own and adds no wait. It needs `buildId()` in\n * the server's pipeline, and it does nothing on a document with no build.\n * It returns a function that stops it and gives back `fetch`. If the app\n * wrapped `fetch` after it, the wrapper stays, and each request passes on.\n *\n * @example\n * // src/router.tsx\n * export function getRouter() {\n * \tconst router = createRouter({ routeTree });\n * \tif (!router.isServer) {\n * \t\tstaleBuildTanStack(router);\n * \t}\n * \treturn router;\n * }\n */\nexport function staleBuildTanStack(\n\trouter: NavigationEvents,\n\toptions: StaleBuildOptions = {},\n): () => void {\n\tconst watch = watchBuild(options);\n\tif (watch == null) {\n\t\treturn () => {};\n\t}\n\t/** The navigation that runs now. `leaving` is true when it already loads its page as a document. */\n\tlet navigation: { leaving: boolean } | undefined;\n\tconst reload = async (current: { leaving: boolean }, response?: Response) => {\n\t\tif (current.leaving) {\n\t\t\tvoid response?.body?.cancel().catch(() => undefined);\n\t\t\treturn new Promise<Response>(() => {});\n\t\t}\n\t\tcurrent.leaving = true;\n\t\t// Why flush: the router's history moves the browser's URL in a microtask, after\n\t\t// `onBeforeNavigate`. A reload before that loads the page that the visitor leaves.\n\t\trouter.history.flush();\n\t\treturn loadDocument(location.href, { response });\n\t};\n\tconst unsubscribe = [\n\t\trouter.subscribe(\"onBeforeNavigate\", ({ fromLocation, toLocation }) => {\n\t\t\t// Why clear first: a change to the fragment replaces a navigation that has not ended.\n\t\t\tnavigation = undefined;\n\t\t\tif (fromLocation == null || eventPage(fromLocation) === eventPage(toLocation)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnavigation = { leaving: false };\n\t\t\tif (watch.isStale()) {\n\t\t\t\t// Why clear: the router matches the target after this event, and a preload can hold the\n\t\t\t\t// new build's data. With no cache, each loader fetches again, and `fetch` holds it.\n\t\t\t\trouter.clearCache();\n\t\t\t\tvoid reload(navigation);\n\t\t\t}\n\t\t}),\n\t\trouter.subscribe(\"onResolved\", () => {\n\t\t\tnavigation = undefined;\n\t\t}),\n\t];\n\tconst send = globalThis.fetch;\n\tlet isStopped = false;\n\tconst patched: typeof fetch = async (input, init) => {\n\t\tif (isStopped) {\n\t\t\treturn send.call(globalThis, input, init);\n\t\t}\n\t\tconst isGet = methodOf(input, init) === \"GET\";\n\t\tif (isGet && navigation != null && watch.isStale()) {\n\t\t\treturn reload(navigation);\n\t\t}\n\t\tconst response = await send.call(globalThis, input, init);\n\t\t// Why the navigation at the response: a navigation can take the pending loader of a preload,\n\t\t// or of the navigation that it replaced.\n\t\tif (!watch.isNew(response, urlOf(input)) || !isGet || navigation == null) {\n\t\t\treturn response;\n\t\t}\n\t\treturn reload(navigation, response);\n\t};\n\tglobalThis.fetch = patched;\n\treturn () => {\n\t\tfor (const stop of unsubscribe) {\n\t\t\tstop();\n\t\t}\n\t\twatch.stop();\n\t\tisStopped = true;\n\t\tnavigation = undefined;\n\t\t// Why check: a wrapper that the app adds later still calls this one, and must stay.\n\t\tif (globalThis.fetch === patched) {\n\t\t\tglobalThis.fetch = send;\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;;;;;;AA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a,EAAE,SAAS,MAAM;EAC9B,IAAI,MAAM,QAAQ,GAAG;GAGpB,OAAO,WAAW;GAClB,AAAK,OAAO,UAAU;EACvB;CACD,CAAC,GACD,OAAO,UAAU,oBAAoB;EACpC,aAAa;CACd,CAAC,CACF;CACA,MAAM,OAAO,WAAW;CACxB,IAAI,YAAY;CAChB,MAAM,UAAwB,OAAO,OAAO,SAAS;EACpD,IAAI,WACH,OAAO,KAAK,KAAK,YAAY,OAAO,IAAI;EAEzC,MAAM,QAAQ,SAAS,OAAO,IAAI,MAAM;EACxC,IAAI,SAAS,cAAc,QAAQ,MAAM,QAAQ,GAChD,OAAO,OAAO,UAAU;EAEzB,MAAM,WAAW,MAAM,KAAK,KAAK,YAAY,OAAO,IAAI;EAGxD,IAAI,CAAC,MAAM,MAAM,UAAU,MAAM,KAAK,CAAC,KAAK,CAAC,SAAS,cAAc,MACnE,OAAO;EAER,OAAO,OAAO,YAAY,QAAQ;CACnC;CACA,WAAW,QAAQ;CACnB,aAAa;EACZ,KAAK,MAAM,QAAQ,aAClB,KAAK;EAEN,MAAM,KAAK;EACX,YAAY;EACZ,aAAa;EAEb,IAAI,WAAW,UAAU,SACxB,WAAW,QAAQ;CAErB;AACD"}
|
package/dist/start-j0VlxeiI.js
DELETED
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
import { t as parsePort } from "./tcp-BgDXbjOG.js";
|
|
2
|
-
import { r as hookSink, s as textSink, t as asError } from "./log-DQAS5gGT.js";
|
|
3
|
-
import { i as exitAfterFlush, n as devServerStage } from "./node-CVVdk2N6.js";
|
|
4
|
-
import { t as requestListener } from "./response-writer-D7KHfr8n.js";
|
|
5
|
-
import { t as SERVER_ENTRY_ID } from "./vite-DPiSKHDn.js";
|
|
6
|
-
import { t as loadEntry } from "./load-entry-CCPWbsrj.js";
|
|
7
|
-
import { t as listenerUrl } from "./listen-options-7TaXjyrk.js";
|
|
8
|
-
import { styleText } from "node:util";
|
|
9
|
-
import { createServer } from "node:http";
|
|
10
|
-
import { networkInterfaces } from "node:os";
|
|
11
|
-
import { createServer as createServer$1 } from "node:net";
|
|
12
|
-
|
|
13
|
-
// src/cli/dev-urls.ts
|
|
14
|
-
const wildcardHosts = /* @__PURE__ */ new Set([
|
|
15
|
-
"",
|
|
16
|
-
"0.0.0.0",
|
|
17
|
-
"::"
|
|
18
|
-
]);
|
|
19
|
-
const loopbackHosts = /* @__PURE__ */ new Set([
|
|
20
|
-
"localhost",
|
|
21
|
-
"127.0.0.1",
|
|
22
|
-
"::1"
|
|
23
|
-
]);
|
|
24
|
-
/**
|
|
25
|
-
* The lines that `app-server start` prints when it listens, in the format of `vite dev`. Each URL
|
|
26
|
-
* ends with `base`, Vite's base path. A wildcard host gets a `localhost` line, then one line for
|
|
27
|
-
* each IPv4 (Internet Protocol version 4) interface.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* devUrlLines({ hostname: "localhost", port: 3000, base: "/" }); // => [" ➜ Local: http://localhost:3000/"]
|
|
31
|
-
*/
|
|
32
|
-
function devUrlLines({ hostname, port, base }, interfaces = networkInterfaces()) {
|
|
33
|
-
const urlOf = (host) => `${listenerUrl(host, port).slice(0, -1)}${base}`;
|
|
34
|
-
const addresses = Object.entries(interfaces).flatMap(([name, details = []]) => details.map(({ address, family }) => ({
|
|
35
|
-
name,
|
|
36
|
-
address,
|
|
37
|
-
family
|
|
38
|
-
})));
|
|
39
|
-
const urls = hostname == null || wildcardHosts.has(hostname) ? [{
|
|
40
|
-
local: true,
|
|
41
|
-
url: urlOf("localhost"),
|
|
42
|
-
interfaceName: void 0
|
|
43
|
-
}, ...addresses.filter(({ address, family }) => family === "IPv4" && address !== "127.0.0.1").map(({ name, address }) => ({
|
|
44
|
-
local: false,
|
|
45
|
-
url: urlOf(address),
|
|
46
|
-
interfaceName: name
|
|
47
|
-
}))] : [{
|
|
48
|
-
local: loopbackHosts.has(hostname),
|
|
49
|
-
url: urlOf(hostname),
|
|
50
|
-
interfaceName: addresses.find(({ address }) => address === hostname)?.name
|
|
51
|
-
}];
|
|
52
|
-
const width = Math.max(0, ...urls.filter(({ local }) => !local).map(({ url }) => url.length));
|
|
53
|
-
return urls.map(({ local, url, interfaceName }) => {
|
|
54
|
-
const label = styleText("bold", local ? "Local" : "Network") + (local ? ": " : ": ");
|
|
55
|
-
const link = styleText("cyan", url.replace(`:${port}/`, `:${styleText("bold", String(port))}/`));
|
|
56
|
-
const suffix = local || interfaceName == null ? "" : " ".repeat(width - url.length + 2) + styleText("dim", interfaceName);
|
|
57
|
-
return ` ${styleText("green", "➜")} ${label}${link}${suffix}`;
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// src/cli/served-apps.ts
|
|
62
|
-
/**
|
|
63
|
-
* Tracks the apps that `app-server start` serves. An edit to `server.ts` makes a
|
|
64
|
-
* new app, and the old app's plugins still hold what their `setup` opened.
|
|
65
|
-
* When the last request that the old app took returns, its `onShutdown` hooks
|
|
66
|
-
* run, and the tracker lets go of it. A route edit makes a new entry with the
|
|
67
|
-
* same app, which keeps its plugins.
|
|
68
|
-
*/
|
|
69
|
-
function servedApps() {
|
|
70
|
-
let current;
|
|
71
|
-
const served = /* @__PURE__ */ new Set();
|
|
72
|
-
const retire = async (app) => {
|
|
73
|
-
try {
|
|
74
|
-
await app.entry.stopPlugins();
|
|
75
|
-
} finally {
|
|
76
|
-
served.delete(app);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
return {
|
|
80
|
-
serve: async (entry, handle) => {
|
|
81
|
-
if (current?.entry.app === entry.app) current.entry = entry;
|
|
82
|
-
else {
|
|
83
|
-
if (current != null) {
|
|
84
|
-
current.replaced = true;
|
|
85
|
-
if (current.pending === 0) retire(current);
|
|
86
|
-
}
|
|
87
|
-
current = {
|
|
88
|
-
entry,
|
|
89
|
-
pending: 0,
|
|
90
|
-
replaced: false
|
|
91
|
-
};
|
|
92
|
-
served.add(current);
|
|
93
|
-
}
|
|
94
|
-
const app = current;
|
|
95
|
-
app.pending += 1;
|
|
96
|
-
try {
|
|
97
|
-
return await handle(entry);
|
|
98
|
-
} finally {
|
|
99
|
-
app.pending -= 1;
|
|
100
|
-
if (app.replaced && app.pending === 0) retire(app);
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
stopAll: async () => {
|
|
104
|
-
await Promise.all(Array.from(served, async (app) => {
|
|
105
|
-
app.entry.abortShutdownSignal();
|
|
106
|
-
await retire(app);
|
|
107
|
-
}));
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// src/cli/start-port.ts
|
|
113
|
-
const MAX_PORT = 65535;
|
|
114
|
-
/**
|
|
115
|
-
* Starts `server` on `port`. When the port is in use, it tries each next port
|
|
116
|
-
* up to 65535, like Vite and `react-router-serve` do in development.
|
|
117
|
-
*
|
|
118
|
-
* @returns the port that the server listens on
|
|
119
|
-
*/
|
|
120
|
-
async function listenFromPort(server, { port, hostname, strictPort, onPortInUse, onWildcardInUse }) {
|
|
121
|
-
if (port === 0) {
|
|
122
|
-
await bind(server, port, hostname);
|
|
123
|
-
return boundPort(server, port);
|
|
124
|
-
}
|
|
125
|
-
if (strictPort) {
|
|
126
|
-
const freeOnWildcard = hostname == null || await isFreeOnWildcard(port);
|
|
127
|
-
await bind(server, port, hostname);
|
|
128
|
-
if (!freeOnWildcard) onWildcardInUse?.(port);
|
|
129
|
-
return port;
|
|
130
|
-
}
|
|
131
|
-
for (let candidate = port; candidate <= MAX_PORT; candidate++) {
|
|
132
|
-
if (hostname == null || await isFreeOnWildcard(candidate)) try {
|
|
133
|
-
await bind(server, candidate, hostname);
|
|
134
|
-
return candidate;
|
|
135
|
-
} catch (error) {
|
|
136
|
-
if (!isAddressInUse(error)) throw error;
|
|
137
|
-
}
|
|
138
|
-
onPortInUse?.(candidate);
|
|
139
|
-
}
|
|
140
|
-
throw new Error(`No open port from ${port} to ${MAX_PORT}.`);
|
|
141
|
-
}
|
|
142
|
-
async function bind(server, port, hostname) {
|
|
143
|
-
return new Promise((resolve, reject) => {
|
|
144
|
-
function onError(error) {
|
|
145
|
-
server.off("listening", onListening);
|
|
146
|
-
reject(error);
|
|
147
|
-
}
|
|
148
|
-
function onListening() {
|
|
149
|
-
server.off("error", onError);
|
|
150
|
-
resolve();
|
|
151
|
-
}
|
|
152
|
-
server.once("error", onError);
|
|
153
|
-
server.once("listening", onListening);
|
|
154
|
-
server.listen(port, hostname);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
async function isFreeOnWildcard(port) {
|
|
158
|
-
const probe = createServer$1();
|
|
159
|
-
try {
|
|
160
|
-
await bind(probe, port, void 0);
|
|
161
|
-
} catch (error) {
|
|
162
|
-
if (isAddressInUse(error)) return false;
|
|
163
|
-
throw error;
|
|
164
|
-
}
|
|
165
|
-
await new Promise((resolve) => {
|
|
166
|
-
probe.close(() => {
|
|
167
|
-
resolve();
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
function boundPort(server, fallback) {
|
|
173
|
-
const address = server.address();
|
|
174
|
-
return typeof address === "object" && address != null ? address.port : fallback;
|
|
175
|
-
}
|
|
176
|
-
function isAddressInUse(error) {
|
|
177
|
-
return error instanceof Error && "code" in error && error.code === "EADDRINUSE";
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// src/cli/start.ts
|
|
181
|
-
/**
|
|
182
|
-
* Runs the app in development: the same pipeline as production, with Vite in
|
|
183
|
-
* middleware mode inside it. Each request loads the server entry through
|
|
184
|
-
* Vite's SSR runner, so an edit to a route or to the app's `server.ts` applies
|
|
185
|
-
* at once. HMR shares the port. Vite's plugins get the CLI's HTTP server as
|
|
186
|
-
* `server.httpServer`.
|
|
187
|
-
*
|
|
188
|
-
* The port is `--port`, else `PORT`, else Vite's `server.port`. When that port is in use, the
|
|
189
|
-
* server tries each next port, unless Vite's `server.strictPort` is true. The
|
|
190
|
-
* host is `HOST`, else Vite's `server.host`.
|
|
191
|
-
*/
|
|
192
|
-
async function start() {
|
|
193
|
-
const vite = await import("vite");
|
|
194
|
-
const httpServer = createServer();
|
|
195
|
-
const viteServer = await vite.createServer({
|
|
196
|
-
server: {
|
|
197
|
-
middlewareMode: true,
|
|
198
|
-
ws: { server: httpServer }
|
|
199
|
-
},
|
|
200
|
-
appType: "custom",
|
|
201
|
-
plugins: [shareHttpServer(httpServer)]
|
|
202
|
-
});
|
|
203
|
-
const ssrRunner = () => {
|
|
204
|
-
const { ssr } = viteServer.environments;
|
|
205
|
-
if (ssr == null || !vite.isRunnableDevEnvironment(ssr)) throw new Error("Vite's SSR environment cannot run modules.");
|
|
206
|
-
return ssr.runner;
|
|
207
|
-
};
|
|
208
|
-
ssrRunner();
|
|
209
|
-
if (!viteServer.config.plugins.some((plugin) => plugin.name === "@ngrok/app-server")) {
|
|
210
|
-
await viteServer.close();
|
|
211
|
-
throw new Error("`app-server start` needs the `appServer` plugin from @ngrok/app-server/vite in the Vite config.");
|
|
212
|
-
}
|
|
213
|
-
const devServer = devServerStage(viteServer.middlewares, { publicFiles: () => ({
|
|
214
|
-
directory: viteServer.config.publicDir,
|
|
215
|
-
base: viteServer.config.base
|
|
216
|
-
}) });
|
|
217
|
-
const sink = hookSink(textSink());
|
|
218
|
-
const apps = servedApps();
|
|
219
|
-
const listener = requestListener(async (request, bindings) => {
|
|
220
|
-
try {
|
|
221
|
-
return await apps.serve(await loadEntry(await ssrRunner().import(SERVER_ENTRY_ID)), async (entry) => entry.fetchDev(request, bindings, devServer));
|
|
222
|
-
} catch (error) {
|
|
223
|
-
if (error instanceof Error) viteServer.ssrFixStacktrace(error);
|
|
224
|
-
sink.log({
|
|
225
|
-
level: "error",
|
|
226
|
-
message: "dev request failed",
|
|
227
|
-
attributes: { error: asError(error) }
|
|
228
|
-
});
|
|
229
|
-
return new Response(error instanceof Error ? error.stack ?? error.message : String(error), {
|
|
230
|
-
status: 500,
|
|
231
|
-
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
httpServer.on("request", (request, response) => {
|
|
236
|
-
listener(request, response);
|
|
237
|
-
});
|
|
238
|
-
const port = process.env.PORT == null ? viteServer.config.server.port : parsePort(process.env.PORT);
|
|
239
|
-
const hostname = process.env.HOST || viteHostname(viteServer.config.server.host);
|
|
240
|
-
const boundPort = await listenFromPort(httpServer, {
|
|
241
|
-
port,
|
|
242
|
-
hostname,
|
|
243
|
-
strictPort: viteServer.config.server.strictPort,
|
|
244
|
-
onPortInUse: (inUse) => {
|
|
245
|
-
sink.log({
|
|
246
|
-
level: "info",
|
|
247
|
-
message: "port in use, trying the next port",
|
|
248
|
-
attributes: { "server.port": inUse }
|
|
249
|
-
});
|
|
250
|
-
},
|
|
251
|
-
onWildcardInUse: (inUse) => {
|
|
252
|
-
sink.log({
|
|
253
|
-
level: "warn",
|
|
254
|
-
message: "port in use on a wildcard address",
|
|
255
|
-
attributes: {
|
|
256
|
-
"server.port": inUse,
|
|
257
|
-
"server.address": hostname
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
viteServer.config.logger.info("");
|
|
263
|
-
for (const line of devUrlLines({
|
|
264
|
-
hostname,
|
|
265
|
-
port: boundPort,
|
|
266
|
-
base: viteServer.config.base
|
|
267
|
-
})) viteServer.config.logger.info(line);
|
|
268
|
-
for (const signal of ["SIGTERM", "SIGINT"]) process.once(signal, () => {
|
|
269
|
-
const pluginsStopped = apps.stopAll();
|
|
270
|
-
httpServer.closeAllConnections();
|
|
271
|
-
const httpClosed = new Promise((resolve) => {
|
|
272
|
-
httpServer.close(() => {
|
|
273
|
-
resolve();
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
const viteClosed = viteServer.close().catch((error) => {
|
|
277
|
-
sink.log({
|
|
278
|
-
level: "error",
|
|
279
|
-
message: "Vite close failed",
|
|
280
|
-
attributes: { error: asError(error) }
|
|
281
|
-
});
|
|
282
|
-
process.exitCode = 1;
|
|
283
|
-
});
|
|
284
|
-
Promise.all([
|
|
285
|
-
pluginsStopped,
|
|
286
|
-
httpClosed,
|
|
287
|
-
viteClosed
|
|
288
|
-
]).finally(exitAfterFlush);
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* A Vite plugin that sets `server.httpServer` to the CLI's HTTP server before
|
|
293
|
-
* the `configureServer` hooks of the app's plugins run. Why: in middleware
|
|
294
|
-
* mode, Vite sets it to `null`. Then a plugin that waits for `listening` or
|
|
295
|
-
* `close` on it does nothing, with no error.
|
|
296
|
-
*
|
|
297
|
-
* @example
|
|
298
|
-
* vite.createServer({ plugins: [shareHttpServer(httpServer)] });
|
|
299
|
-
*/
|
|
300
|
-
function shareHttpServer(httpServer) {
|
|
301
|
-
const plugin = {
|
|
302
|
-
name: "@ngrok/app-server:http-server",
|
|
303
|
-
configResolved: (config) => {
|
|
304
|
-
const plugins = config.plugins;
|
|
305
|
-
plugins.splice(plugins.indexOf(plugin), 1);
|
|
306
|
-
plugins.unshift(plugin);
|
|
307
|
-
},
|
|
308
|
-
configureServer: {
|
|
309
|
-
order: "pre",
|
|
310
|
-
handler: (server) => {
|
|
311
|
-
server.httpServer = httpServer;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
return plugin;
|
|
316
|
-
}
|
|
317
|
-
/** The hostname for Vite's `server.host`: `true` is every interface, and no value is `localhost`. */
|
|
318
|
-
function viteHostname(host) {
|
|
319
|
-
if (host === true) return;
|
|
320
|
-
return typeof host === "string" && host !== "" ? host : "localhost";
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
export { start };
|
|
324
|
-
//# sourceMappingURL=start-j0VlxeiI.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"start-j0VlxeiI.js","names":["createServer","createHttpServer"],"sources":["../src/cli/dev-urls.ts","../src/cli/served-apps.ts","../src/cli/start-port.ts","../src/cli/start.ts"],"sourcesContent":["import { networkInterfaces } from \"node:os\";\nimport { styleText } from \"node:util\";\nimport { listenerUrl } from \"../node/runtimes/listen-options.js\";\n\nconst wildcardHosts = new Set([\"\", \"0.0.0.0\", \"::\"]);\nconst loopbackHosts = new Set([\"localhost\", \"127.0.0.1\", \"::1\"]);\n\ntype DevUrl = { local: boolean; url: string; interfaceName: string | undefined };\n\n/**\n * The lines that `app-server start` prints when it listens, in the format of `vite dev`. Each URL\n * ends with `base`, Vite's base path. A wildcard host gets a `localhost` line, then one line for\n * each IPv4 (Internet Protocol version 4) interface.\n *\n * @example\n * devUrlLines({ hostname: \"localhost\", port: 3000, base: \"/\" }); // => [\" ➜ Local: http://localhost:3000/\"]\n */\nexport function devUrlLines(\n\t{ hostname, port, base }: { hostname: string | undefined; port: number; base: string },\n\tinterfaces = networkInterfaces(),\n): string[] {\n\tconst urlOf = (host: string) => `${listenerUrl(host, port).slice(0, -1)}${base}`;\n\tconst addresses = Object.entries(interfaces).flatMap(([name, details = []]) =>\n\t\tdetails.map(({ address, family }) => ({ name, address, family })),\n\t);\n\t// Why a `localhost` line with no lookup: a host with no IPv4 loopback still gets a URL to open.\n\tconst urls: DevUrl[] =\n\t\thostname == null || wildcardHosts.has(hostname)\n\t\t\t? [\n\t\t\t\t\t{ local: true, url: urlOf(\"localhost\"), interfaceName: undefined },\n\t\t\t\t\t...addresses\n\t\t\t\t\t\t.filter(({ address, family }) => family === \"IPv4\" && address !== \"127.0.0.1\")\n\t\t\t\t\t\t.map(({ name, address }) => ({\n\t\t\t\t\t\t\tlocal: false,\n\t\t\t\t\t\t\turl: urlOf(address),\n\t\t\t\t\t\t\tinterfaceName: name,\n\t\t\t\t\t\t})),\n\t\t\t\t]\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlocal: loopbackHosts.has(hostname),\n\t\t\t\t\t\turl: urlOf(hostname),\n\t\t\t\t\t\tinterfaceName: addresses.find(({ address }) => address === hostname)?.name,\n\t\t\t\t\t},\n\t\t\t\t];\n\tconst width = Math.max(0, ...urls.filter(({ local }) => !local).map(({ url }) => url.length));\n\treturn urls.map(({ local, url, interfaceName }) => {\n\t\tconst label = styleText(\"bold\", local ? \"Local\" : \"Network\") + (local ? \": \" : \": \");\n\t\tconst link = styleText(\n\t\t\t\"cyan\",\n\t\t\turl.replace(`:${port}/`, `:${styleText(\"bold\", String(port))}/`),\n\t\t);\n\t\tconst suffix =\n\t\t\tlocal || interfaceName == null\n\t\t\t\t? \"\"\n\t\t\t\t: \" \".repeat(width - url.length + 2) + styleText(\"dim\", interfaceName);\n\t\treturn ` ${styleText(\"green\", \"➜\")} ${label}${link}${suffix}`;\n\t});\n}\n","import type { AppServerEntry } from \"../core/entry.js\";\n\ntype ServedApp = { entry: AppServerEntry; pending: number; replaced: boolean };\n\n/** What {@link servedApps} returns. */\ntype ServedApps = {\n\t/** Runs `handle` for a request that `entry` serves. */\n\tserve: <Result>(\n\t\tentry: AppServerEntry,\n\t\thandle: (entry: AppServerEntry) => Promise<Result>,\n\t) => Promise<Result>;\n\t/**\n\t * At exit: aborts `shutdownSignal()` and runs the `onShutdown` hooks of each\n\t * app still held. Resolves when the hooks finish or pass the deadline.\n\t */\n\tstopAll: () => Promise<void>;\n};\n\n/**\n * Tracks the apps that `app-server start` serves. An edit to `server.ts` makes a\n * new app, and the old app's plugins still hold what their `setup` opened.\n * When the last request that the old app took returns, its `onShutdown` hooks\n * run, and the tracker lets go of it. A route edit makes a new entry with the\n * same app, which keeps its plugins.\n */\nexport function servedApps(): ServedApps {\n\tlet current: ServedApp | undefined;\n\tconst served = new Set<ServedApp>();\n\t// Why keep the app until its hooks settle: `stopAll` must wait for hooks that already run.\n\t// `stopPlugins` runs the hooks once, so a second call only waits.\n\tconst retire = async (app: ServedApp) => {\n\t\ttry {\n\t\t\tawait app.entry.stopPlugins();\n\t\t} finally {\n\t\t\tserved.delete(app);\n\t\t}\n\t};\n\treturn {\n\t\tserve: async (entry, handle) => {\n\t\t\tif (current?.entry.app === entry.app) {\n\t\t\t\tcurrent.entry = entry;\n\t\t\t} else {\n\t\t\t\tif (current != null) {\n\t\t\t\t\tcurrent.replaced = true;\n\t\t\t\t\tif (current.pending === 0) {\n\t\t\t\t\t\tvoid retire(current);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcurrent = { entry, pending: 0, replaced: false };\n\t\t\t\tserved.add(current);\n\t\t\t}\n\t\t\tconst app = current;\n\t\t\tapp.pending += 1;\n\t\t\ttry {\n\t\t\t\treturn await handle(entry);\n\t\t\t} finally {\n\t\t\t\tapp.pending -= 1;\n\t\t\t\tif (app.replaced && app.pending === 0) {\n\t\t\t\t\tvoid retire(app);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tstopAll: async () => {\n\t\t\tawait Promise.all(\n\t\t\t\tArray.from(served, async (app) => {\n\t\t\t\t\tapp.entry.abortShutdownSignal();\n\t\t\t\t\tawait retire(app);\n\t\t\t\t}),\n\t\t\t);\n\t\t},\n\t};\n}\n","import { createServer } from \"node:net\";\nimport type { Server } from \"node:net\";\n\nconst MAX_PORT = 65_535;\n\n/** Options for {@link listenFromPort}. */\nexport type ListenFromPortOptions = {\n\t/** The first port to try. 0 lets the OS pick one. */\n\tport: number;\n\t/** @default every interface */\n\thostname?: string | undefined;\n\t/** When true, a port in use throws and no other port is tried. */\n\tstrictPort: boolean;\n\t/** Runs for each port in use before the next port is tried. */\n\tonPortInUse?: (port: number) => void;\n\t/**\n\t * Runs when `strictPort` is true and the server listens on `hostname`, but\n\t * another server holds the port on a wildcard address.\n\t */\n\tonWildcardInUse?: (port: number) => void;\n};\n\n/**\n * Starts `server` on `port`. When the port is in use, it tries each next port\n * up to 65535, like Vite and `react-router-serve` do in development.\n *\n * @returns the port that the server listens on\n */\nexport async function listenFromPort(\n\tserver: Server,\n\t{ port, hostname, strictPort, onPortInUse, onWildcardInUse }: ListenFromPortOptions,\n): Promise<number> {\n\tif (port === 0) {\n\t\tawait bind(server, port, hostname);\n\t\treturn boundPort(server, port);\n\t}\n\tif (strictPort) {\n\t\t// Why a warning and not an error: a server on one other address also fails the wildcard\n\t\t// check, and that server does not share `hostname`. Vite warns for the same reason.\n\t\tconst freeOnWildcard = hostname == null || (await isFreeOnWildcard(port));\n\t\tawait bind(server, port, hostname);\n\t\tif (!freeOnWildcard) {\n\t\t\tonWildcardInUse?.(port);\n\t\t}\n\t\treturn port;\n\t}\n\tfor (let candidate = port; candidate <= MAX_PORT; candidate++) {\n\t\t// Why the wildcard check: a server on `::` and a server on `localhost` can share a port, and\n\t\t// then the browser can reach the other server.\n\t\tif (hostname == null || (await isFreeOnWildcard(candidate))) {\n\t\t\ttry {\n\t\t\t\tawait bind(server, candidate, hostname);\n\t\t\t\treturn candidate;\n\t\t\t} catch (error) {\n\t\t\t\tif (!isAddressInUse(error)) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tonPortInUse?.(candidate);\n\t}\n\tthrow new Error(`No open port from ${port} to ${MAX_PORT}.`);\n}\n\nasync function bind(server: Server, port: number, hostname: string | undefined): Promise<void> {\n\treturn new Promise<void>((resolve, reject) => {\n\t\tfunction onError(error: Error) {\n\t\t\tserver.off(\"listening\", onListening);\n\t\t\treject(error);\n\t\t}\n\t\tfunction onListening() {\n\t\t\tserver.off(\"error\", onError);\n\t\t\tresolve();\n\t\t}\n\t\tserver.once(\"error\", onError);\n\t\tserver.once(\"listening\", onListening);\n\t\tserver.listen(port, hostname);\n\t});\n}\n\nasync function isFreeOnWildcard(port: number): Promise<boolean> {\n\tconst probe = createServer();\n\ttry {\n\t\tawait bind(probe, port, undefined);\n\t} catch (error) {\n\t\tif (isAddressInUse(error)) {\n\t\t\treturn false;\n\t\t}\n\t\tthrow error;\n\t}\n\tawait new Promise<void>((resolve) => {\n\t\tprobe.close(() => {\n\t\t\tresolve();\n\t\t});\n\t});\n\treturn true;\n}\n\nfunction boundPort(server: Server, fallback: number): number {\n\tconst address = server.address();\n\treturn typeof address === \"object\" && address != null ? address.port : fallback;\n}\n\nfunction isAddressInUse(error: unknown): boolean {\n\treturn error instanceof Error && \"code\" in error && error.code === \"EADDRINUSE\";\n}\n","import { createServer as createHttpServer } from \"node:http\";\nimport type { Server } from \"node:http\";\nimport type { Plugin } from \"vite\";\nimport { asError, hookSink, textSink } from \"../core/log.js\";\nimport { devServerStage } from \"../node/dev-server.js\";\nimport { exitAfterFlush } from \"../node/exit.js\";\nimport { requestListener } from \"../node/response-writer.js\";\nimport { parsePort } from \"../node/tcp.js\";\nimport { SERVER_ENTRY_ID } from \"../vite/index.js\";\nimport { devUrlLines } from \"./dev-urls.js\";\nimport { loadEntry } from \"./load-entry.js\";\nimport { servedApps } from \"./served-apps.js\";\nimport { listenFromPort } from \"./start-port.js\";\n\n/**\n * Runs the app in development: the same pipeline as production, with Vite in\n * middleware mode inside it. Each request loads the server entry through\n * Vite's SSR runner, so an edit to a route or to the app's `server.ts` applies\n * at once. HMR shares the port. Vite's plugins get the CLI's HTTP server as\n * `server.httpServer`.\n *\n * The port is `--port`, else `PORT`, else Vite's `server.port`. When that port is in use, the\n * server tries each next port, unless Vite's `server.strictPort` is true. The\n * host is `HOST`, else Vite's `server.host`.\n */\nexport async function start(): Promise<void> {\n\tconst vite = await import(\"vite\");\n\tconst httpServer = createHttpServer();\n\tconst viteServer = await vite.createServer({\n\t\t// Why `true`, not `{ server }`: Vite then adds a proxy `upgrade` listener to the server, and a\n\t\t// restart does not remove it.\n\t\tserver: { middlewareMode: true, ws: { server: httpServer } },\n\t\tappType: \"custom\",\n\t\tplugins: [shareHttpServer(httpServer)],\n\t});\n\t// Why read it for each request: a Vite restart, such as after a config edit, replaces the environments.\n\tconst ssrRunner = () => {\n\t\tconst { ssr } = viteServer.environments;\n\t\tif (ssr == null || !vite.isRunnableDevEnvironment(ssr)) {\n\t\t\tthrow new Error(\"Vite's SSR environment cannot run modules.\");\n\t\t}\n\t\treturn ssr.runner;\n\t};\n\tssrRunner();\n\tif (!viteServer.config.plugins.some((plugin) => plugin.name === \"@ngrok/app-server\")) {\n\t\tawait viteServer.close();\n\t\tthrow new Error(\n\t\t\t\"`app-server start` needs the `appServer` plugin from @ngrok/app-server/vite in the Vite config.\",\n\t\t);\n\t}\n\tconst devServer = devServerStage(viteServer.middlewares, {\n\t\tpublicFiles: () => ({ directory: viteServer.config.publicDir, base: viteServer.config.base }),\n\t});\n\tconst sink = hookSink(textSink());\n\tconst apps = servedApps();\n\n\tconst listener = requestListener(async (request, bindings) => {\n\t\ttry {\n\t\t\treturn await apps.serve(\n\t\t\t\tawait loadEntry(await ssrRunner().import(SERVER_ENTRY_ID)),\n\t\t\t\tasync (entry) => entry.fetchDev(request, bindings, devServer),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tviteServer.ssrFixStacktrace(error);\n\t\t\t}\n\t\t\tsink.log({\n\t\t\t\tlevel: \"error\",\n\t\t\t\tmessage: \"dev request failed\",\n\t\t\t\tattributes: { error: asError(error) },\n\t\t\t});\n\t\t\treturn new Response(error instanceof Error ? (error.stack ?? error.message) : String(error), {\n\t\t\t\tstatus: 500,\n\t\t\t\theaders: { \"Content-Type\": \"text/plain; charset=utf-8\" },\n\t\t\t});\n\t\t}\n\t});\n\thttpServer.on(\"request\", (request, response) => {\n\t\tvoid listener(request, response);\n\t});\n\n\tconst port =\n\t\tprocess.env.PORT == null ? viteServer.config.server.port : parsePort(process.env.PORT);\n\tconst hostname = process.env.HOST || viteHostname(viteServer.config.server.host);\n\tconst boundPort = await listenFromPort(httpServer, {\n\t\tport,\n\t\thostname,\n\t\tstrictPort: viteServer.config.server.strictPort,\n\t\tonPortInUse: (inUse) => {\n\t\t\tsink.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tmessage: \"port in use, trying the next port\",\n\t\t\t\tattributes: { \"server.port\": inUse },\n\t\t\t});\n\t\t},\n\t\tonWildcardInUse: (inUse) => {\n\t\t\tsink.log({\n\t\t\t\tlevel: \"warn\",\n\t\t\t\tmessage: \"port in use on a wildcard address\",\n\t\t\t\tattributes: {\n\t\t\t\t\t\"server.port\": inUse,\n\t\t\t\t\t\"server.address\": hostname,\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t});\n\t// Why Vite's logger: the lines then follow the app's `logLevel` and `customLogger`, as in `vite dev`.\n\tviteServer.config.logger.info(\"\");\n\tfor (const line of devUrlLines({ hostname, port: boundPort, base: viteServer.config.base })) {\n\t\tviteServer.config.logger.info(line);\n\t}\n\n\tfor (const signal of [\"SIGTERM\", \"SIGINT\"] as const) {\n\t\tprocess.once(signal, () => {\n\t\t\tconst pluginsStopped = apps.stopAll();\n\t\t\thttpServer.closeAllConnections();\n\t\t\tconst httpClosed = new Promise<void>((resolve) => {\n\t\t\t\thttpServer.close(() => {\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst viteClosed = viteServer.close().catch((error: unknown) => {\n\t\t\t\tsink.log({\n\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\tmessage: \"Vite close failed\",\n\t\t\t\t\tattributes: { error: asError(error) },\n\t\t\t\t});\n\t\t\t\tprocess.exitCode = 1;\n\t\t\t});\n\t\t\tvoid Promise.all([pluginsStopped, httpClosed, viteClosed]).finally(exitAfterFlush);\n\t\t});\n\t}\n}\n\n/**\n * A Vite plugin that sets `server.httpServer` to the CLI's HTTP server before\n * the `configureServer` hooks of the app's plugins run. Why: in middleware\n * mode, Vite sets it to `null`. Then a plugin that waits for `listening` or\n * `close` on it does nothing, with no error.\n *\n * @example\n * vite.createServer({ plugins: [shareHttpServer(httpServer)] });\n */\nfunction shareHttpServer(httpServer: Server): Plugin {\n\tconst plugin: Plugin = {\n\t\tname: \"@ngrok/app-server:http-server\",\n\t\t// Why first: Vite puts an inline plugin after the config file's plugins, so an app plugin with\n\t\t// `enforce: \"pre\"` and `order: \"pre\"` runs its `configureServer` before this one.\n\t\tconfigResolved: (config) => {\n\t\t\t// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- Vite sorts each hook from this array later.\n\t\t\tconst plugins = config.plugins as Plugin[];\n\t\t\tplugins.splice(plugins.indexOf(plugin), 1);\n\t\t\tplugins.unshift(plugin);\n\t\t},\n\t\tconfigureServer: {\n\t\t\torder: \"pre\",\n\t\t\thandler: (server) => {\n\t\t\t\tserver.httpServer = httpServer;\n\t\t\t},\n\t\t},\n\t};\n\treturn plugin;\n}\n\n/** The hostname for Vite's `server.host`: `true` is every interface, and no value is `localhost`. */\nfunction viteHostname(host: string | boolean | undefined): string | undefined {\n\tif (host === true) {\n\t\treturn undefined;\n\t}\n\treturn typeof host === \"string\" && host !== \"\" ? host : \"localhost\";\n}\n"],"mappings":";;;;;;;;;;;;;AAIA,MAAM,gCAAgB,IAAI,IAAI;CAAC;CAAI;CAAW;AAAI,CAAC;AACnD,MAAM,gCAAgB,IAAI,IAAI;CAAC;CAAa;CAAa;AAAK,CAAC;;;;;;;;;AAY/D,SAAgB,YACf,EAAE,UAAU,MAAM,QAClB,aAAa,kBAAkB,GACpB;CACX,MAAM,SAAS,SAAiB,GAAG,YAAY,MAAM,IAAI,CAAC,CAAC,MAAM,GAAG,EAAE,IAAI;CAC1E,MAAM,YAAY,OAAO,QAAQ,UAAU,CAAC,CAAC,SAAS,CAAC,MAAM,UAAU,CAAC,OACvE,QAAQ,KAAK,EAAE,SAAS,cAAc;EAAE;EAAM;EAAS;CAAO,EAAE,CACjE;CAEA,MAAM,OACL,YAAY,QAAQ,cAAc,IAAI,QAAQ,IAC3C,CACA;EAAE,OAAO;EAAM,KAAK,MAAM,WAAW;EAAG,eAAe;CAAU,GACjE,GAAG,UACD,QAAQ,EAAE,SAAS,aAAa,WAAW,UAAU,YAAY,WAAW,CAAC,CAC7E,KAAK,EAAE,MAAM,eAAe;EAC5B,OAAO;EACP,KAAK,MAAM,OAAO;EAClB,eAAe;CAChB,EAAE,CACJ,IACC,CACA;EACC,OAAO,cAAc,IAAI,QAAQ;EACjC,KAAK,MAAM,QAAQ;EACnB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