@guren/server 2.10.1 → 2.12.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/{McpServiceProvider-BoAN-UcD.js → McpServiceProvider-D6D9nhgn.js} +1 -1
- package/dist/encryption/index.js +1 -1
- package/dist/{encryption-fOWQaKqX.js → encryption-DJtkkhiw.js} +35 -15
- package/dist/{errors-quJOkkCn.js → errors-BgeOl_DC.js} +1 -1
- package/dist/http/resources/Resource.d.ts +23 -3
- package/dist/http/vite-assets.d.ts +50 -0
- package/dist/http/vite-manifest.d.ts +80 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +174 -9
- package/dist/jsx-dev-runtime.d.ts +6 -0
- package/dist/jsx-dev-runtime.js +2 -0
- package/dist/jsx-runtime.d.ts +12 -0
- package/dist/jsx-runtime.js +8 -0
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +23 -0
- package/dist/mvc/view.d.ts +15 -0
- package/dist/rolldown-runtime-B4FMCO8f.js +28 -0
- package/dist/runtime/index.js +13 -51
- package/dist/storage/drivers/LocalDriver.d.ts +2 -1
- package/dist/storage/drivers/S3Driver.d.ts +17 -2
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.js +1 -1
- package/dist/storage/types.d.ts +61 -1
- package/dist/{storage-tWHMv2H_.js → storage-TLD9t0Q2.js} +101 -24
- package/dist/vite-manifest-BKuV1kfv.js +251 -0
- package/package.json +10 -2
- package/dist/rolldown-runtime-8H4AJuhK.js +0 -14
- package/dist/vite-dev-server-CpCUqmiC.js +0 -131
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { n as trimTrailingSlashes } from "./trim-slashes-ZJ_VsY5s.js";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import figlet from "figlet";
|
|
5
|
+
import standard from "figlet/importable-fonts/Standard.js";
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
//#region src/support/import-map.ts
|
|
8
|
+
/**
|
|
9
|
+
* Parses an import map JSON string into a record of module specifiers.
|
|
10
|
+
* Empty, null, and undefined entries are ignored so callers can safely
|
|
11
|
+
* merge optional overrides without additional filtering.
|
|
12
|
+
*/
|
|
13
|
+
function parseImportMap(value, options = {}) {
|
|
14
|
+
if (!value) return {};
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(value);
|
|
17
|
+
const result = {};
|
|
18
|
+
for (const [key, entry] of Object.entries(parsed)) if (typeof entry === "string" && entry.length > 0) result[key] = entry;
|
|
19
|
+
return result;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
const label = options.context ?? "import map";
|
|
22
|
+
console.warn(`Failed to parse ${label}. Expected JSON object.`, error);
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/support/inertia-defaults.ts
|
|
28
|
+
/**
|
|
29
|
+
* The stylesheet *source* path the dev asset configuration falls back to.
|
|
30
|
+
*
|
|
31
|
+
* Lives in a leaf module because two sides read it and must agree: the dev
|
|
32
|
+
* configuration in `http/inertia-assets.ts` publishes it into
|
|
33
|
+
* `GUREN_INERTIA_STYLES`, and the document renderer in
|
|
34
|
+
* `mvc/inertia/InertiaEngine.ts` drops exactly this path again when a dev
|
|
35
|
+
* server owns the script entry (the compiled CSS then arrives through the
|
|
36
|
+
* module graph). Importing either of those modules from the other would drag
|
|
37
|
+
* runtime-specific dependencies across the Workers/Lambda boundary or create
|
|
38
|
+
* an import cycle.
|
|
39
|
+
*/
|
|
40
|
+
const DEFAULT_DEV_STYLES_ENTRY = "/resources/css/app.css";
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region package.json
|
|
43
|
+
var version = "2.12.0";
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/http/dev-banner.ts
|
|
46
|
+
figlet.parseFont("Standard", standard);
|
|
47
|
+
function generateAsciiArt(text) {
|
|
48
|
+
try {
|
|
49
|
+
return figlet.textSync(text, {
|
|
50
|
+
font: "Standard",
|
|
51
|
+
horizontalLayout: "default",
|
|
52
|
+
verticalLayout: "default"
|
|
53
|
+
});
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error("Failed to generate FIGlet banner, falling back to plain text:", error);
|
|
56
|
+
return text.toUpperCase();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const GUREN_ASCII_ART = chalk.redBright.bold(generateAsciiArt("GUREN"));
|
|
60
|
+
const GUREN_VERSION = version;
|
|
61
|
+
/**
|
|
62
|
+
* A wildcard bind answers on every interface but is not itself dialable on
|
|
63
|
+
* every platform.
|
|
64
|
+
*
|
|
65
|
+
* Lives here rather than beside its other caller because the banner and
|
|
66
|
+
* `Application.listen()`'s returned address are two renderings of one fact,
|
|
67
|
+
* and a platform caveat added to only one of them is the drift this replaces.
|
|
68
|
+
*/
|
|
69
|
+
function isWildcardHost(hostname) {
|
|
70
|
+
return hostname === "0.0.0.0" || hostname === "::";
|
|
71
|
+
}
|
|
72
|
+
/** `host:port`, bracketing an IPv6 literal so the result is dialable. */
|
|
73
|
+
function formatHostPort(hostname, port) {
|
|
74
|
+
return `${hostname.includes(":") ? `[${hostname}]` : hostname}:${port}`;
|
|
75
|
+
}
|
|
76
|
+
function logDevServerBanner({ hostname, port, assetsUrl = "http://localhost:5173" }) {
|
|
77
|
+
const localUrl = `http://localhost:${port}`;
|
|
78
|
+
const boundUrl = `http://${formatHostPort(hostname, port)}`;
|
|
79
|
+
const boundLabel = isWildcardHost(hostname) ? " (all interfaces)" : "";
|
|
80
|
+
const header = [
|
|
81
|
+
GUREN_ASCII_ART,
|
|
82
|
+
chalk.magentaBright.bold(`Guren v${GUREN_VERSION} ignites — burning bright like a crimson lotus.`),
|
|
83
|
+
""
|
|
84
|
+
];
|
|
85
|
+
const detail = (label, value) => `${chalk.magentaBright(" •")} ${chalk.bold(label.padEnd(14))}: ${chalk.cyanBright(value)}`;
|
|
86
|
+
const banner = [
|
|
87
|
+
...header,
|
|
88
|
+
detail("App URL", localUrl),
|
|
89
|
+
detail("Bound address", `${boundUrl}${boundLabel}`),
|
|
90
|
+
detail("Asset server", `${assetsUrl} (Vite)`),
|
|
91
|
+
"",
|
|
92
|
+
chalk.yellowBright("Press Ctrl+C to douse the flames."),
|
|
93
|
+
""
|
|
94
|
+
].join("\n");
|
|
95
|
+
console.log(banner);
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/http/vite-dev-server.ts
|
|
99
|
+
/**
|
|
100
|
+
* Build the inline config the managed dev server starts with.
|
|
101
|
+
*
|
|
102
|
+
* `server.host` is only set when the caller asked for one. Left undefined it
|
|
103
|
+
* is dropped during Vite's config merge, so the project's own `vite.config.ts`
|
|
104
|
+
* decides, falling back to Vite's localhost-only default.
|
|
105
|
+
*/
|
|
106
|
+
function resolveViteDevServerConfig(options = {}) {
|
|
107
|
+
const { root = process.cwd(), config = {}, host, port } = options;
|
|
108
|
+
return {
|
|
109
|
+
clearScreen: false,
|
|
110
|
+
...config,
|
|
111
|
+
root: config.root ?? root,
|
|
112
|
+
server: {
|
|
113
|
+
host,
|
|
114
|
+
port,
|
|
115
|
+
...config.server ?? {}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
async function startViteDevServer(options = {}) {
|
|
120
|
+
const { host, port } = options;
|
|
121
|
+
const { createServer } = await import("vite");
|
|
122
|
+
const server = await createServer(resolveViteDevServerConfig(options));
|
|
123
|
+
await server.listen();
|
|
124
|
+
const resolved = server.resolvedUrls;
|
|
125
|
+
const localUrls = resolved?.local?.length ? resolved.local : [`http://${typeof host === "string" ? host : "localhost"}:${server.config.server.port ?? port ?? 5173}`];
|
|
126
|
+
const networkUrls = resolved?.network ?? [];
|
|
127
|
+
return {
|
|
128
|
+
server,
|
|
129
|
+
localUrl: localUrls[0],
|
|
130
|
+
networkUrls
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/http/vite-manifest.ts
|
|
135
|
+
/**
|
|
136
|
+
* The one rule for how Vite build output is found and addressed, shared
|
|
137
|
+
* between the Inertia asset wiring (`inertia-assets.ts`) and the content-page
|
|
138
|
+
* `viteAsset()` helper (`vite-assets.ts`, RFC 0014): what counts as a
|
|
139
|
+
* manifest, where one may live (a filesystem path, or the build-time
|
|
140
|
+
* `GUREN_VITE_MANIFEST` injection for runtimes without one), which URL prefix
|
|
141
|
+
* serves the hashed files, and what "the dev server is on" means. Factored
|
|
142
|
+
* out so the two consumers cannot drift on any of it.
|
|
143
|
+
*/
|
|
144
|
+
/** Where `configureInertiaAssets` serves hashed build output from. */
|
|
145
|
+
const PUBLIC_ASSETS_URL_PREFIX = "/public/assets/";
|
|
146
|
+
/** The Vite default the framework assumes when no dev-server URL is set. */
|
|
147
|
+
const DEFAULT_DEV_SERVER_URL = "http://localhost:5173";
|
|
148
|
+
/**
|
|
149
|
+
* Production for *asset* purposes: `NODE_ENV` says so and no dev server is
|
|
150
|
+
* configured — a configured dev server means dev asset serving even when
|
|
151
|
+
* `NODE_ENV` is `production` (E2E runs do exactly this).
|
|
152
|
+
*/
|
|
153
|
+
function isViteProduction(devServerUrl = process.env.VITE_DEV_SERVER_URL) {
|
|
154
|
+
return (process.env.NODE_ENV ?? "development") === "production" && typeof devServerUrl !== "string";
|
|
155
|
+
}
|
|
156
|
+
function normalizeDevServerUrl(value) {
|
|
157
|
+
if (!value) return value;
|
|
158
|
+
const trimmed = value.trim();
|
|
159
|
+
if (!trimmed) return trimmed;
|
|
160
|
+
const stripped = trimTrailingSlashes(trimmed);
|
|
161
|
+
return stripped.length > 0 ? stripped : "/";
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Candidate client-manifest locations under a project root, in preference
|
|
165
|
+
* order: `.vite/manifest.json` first, because Vite >= 5 writes it there — a
|
|
166
|
+
* flat `manifest.json` beside it is most likely a stale leftover from an
|
|
167
|
+
* older Vite config. The deploy plugins locate the same pair through
|
|
168
|
+
* `@guren/core`'s deploy-build helpers, and the two orders must agree, or an
|
|
169
|
+
* app with both layouts resolves different asset versions locally than after
|
|
170
|
+
* a serverless deploy; `tests/http/vite-manifest.test.ts` pins the agreement.
|
|
171
|
+
*
|
|
172
|
+
* `baseDir` defaults to the working directory (`viteAsset()`'s anchor); the
|
|
173
|
+
* Inertia wiring passes the root it derives from the app entry module.
|
|
174
|
+
*/
|
|
175
|
+
function clientManifestCandidates(baseDir) {
|
|
176
|
+
const root = baseDir ?? process.cwd();
|
|
177
|
+
return [resolve(root, "public/assets/.vite/manifest.json"), resolve(root, "public/assets/manifest.json")];
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* `__path__` label for a manifest injected through {@link injectedClientManifest},
|
|
181
|
+
* so "entry not in the manifest" errors name the real source instead of a
|
|
182
|
+
* filesystem path that was never read.
|
|
183
|
+
*/
|
|
184
|
+
const INJECTED_CLIENT_MANIFEST_SOURCE = "GUREN_VITE_MANIFEST (injected by the deploy build)";
|
|
185
|
+
const INJECTED_MANIFEST_HINT = "It must hold the Vite client manifest text (deploy plugins inject it at build time), not a path.";
|
|
186
|
+
/**
|
|
187
|
+
* Attach one of the manifest's non-enumerable bookkeeping fields.
|
|
188
|
+
* `enumerable: false` is the invariant both stamping sites must agree on — a
|
|
189
|
+
* stamped field must never leak into `Object.keys` or a re-serialization of
|
|
190
|
+
* the manifest.
|
|
191
|
+
*/
|
|
192
|
+
function defineHidden(manifest, key, value) {
|
|
193
|
+
Object.defineProperty(manifest, key, {
|
|
194
|
+
value,
|
|
195
|
+
enumerable: false
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* The client manifest a deploy build injected for runtimes that do not ship
|
|
200
|
+
* `public/assets/manifest.json`: `GUREN_VITE_MANIFEST` holds the manifest
|
|
201
|
+
* *JSON text* (not a path). The deploy plugins populate it during their build
|
|
202
|
+
* step — Workers and Lambda as an assignment in their generated entry module,
|
|
203
|
+
* Vercel by substituting the read at bundle time.
|
|
204
|
+
*
|
|
205
|
+
* Fails loudly on a value that is set but not a manifest: falling through to
|
|
206
|
+
* the filesystem would end in "run `bunx vite build`", a diagnosis pointing
|
|
207
|
+
* away from the variable that is actually broken.
|
|
208
|
+
*/
|
|
209
|
+
function injectedClientManifest() {
|
|
210
|
+
const raw = process.env.GUREN_VITE_MANIFEST;
|
|
211
|
+
if (typeof raw !== "string" || raw.length === 0) return;
|
|
212
|
+
let parsed;
|
|
213
|
+
try {
|
|
214
|
+
parsed = JSON.parse(raw);
|
|
215
|
+
} catch (error) {
|
|
216
|
+
throw new Error(`GUREN_VITE_MANIFEST is set but is not valid JSON. ${INJECTED_MANIFEST_HINT}`, { cause: error });
|
|
217
|
+
}
|
|
218
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error(`GUREN_VITE_MANIFEST is set but does not hold a manifest object. ${INJECTED_MANIFEST_HINT}`);
|
|
219
|
+
const manifest = parsed;
|
|
220
|
+
defineHidden(manifest, "__path__", INJECTED_CLIENT_MANIFEST_SOURCE);
|
|
221
|
+
return manifest;
|
|
222
|
+
}
|
|
223
|
+
function loadViteManifest(candidatePaths, label, options = {}) {
|
|
224
|
+
const warnOnMissing = options.warnOnMissing ?? true;
|
|
225
|
+
const command = label === "SSR" ? "bunx vite build --ssr" : "bunx vite build";
|
|
226
|
+
for (const manifestPath of candidatePaths) try {
|
|
227
|
+
const raw = readFileSync(manifestPath, "utf8");
|
|
228
|
+
const manifest = JSON.parse(raw);
|
|
229
|
+
defineHidden(manifest, "__path__", manifestPath);
|
|
230
|
+
if (options.includeRaw) defineHidden(manifest, "__raw__", raw);
|
|
231
|
+
return manifest;
|
|
232
|
+
} catch (error) {
|
|
233
|
+
if (error.code !== "ENOENT") {
|
|
234
|
+
console.warn(`Unable to load ${label} Vite manifest at ${manifestPath}.`, error);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (warnOnMissing && candidatePaths.length) console.warn(`Unable to load ${label} Vite manifest. Checked paths:\n${candidatePaths.map((p) => ` - ${p}`).join("\n")}\nRun \`${command}\` before starting in production.`);
|
|
239
|
+
}
|
|
240
|
+
function getManifestFile(entry) {
|
|
241
|
+
if (!entry) return;
|
|
242
|
+
if (Array.isArray(entry)) return entry[0];
|
|
243
|
+
if (typeof entry === "string") return entry;
|
|
244
|
+
if ("file" in entry && typeof entry.file === "string") return entry.file;
|
|
245
|
+
}
|
|
246
|
+
function getManifestCss(entry) {
|
|
247
|
+
if (!entry || Array.isArray(entry) || typeof entry === "string") return;
|
|
248
|
+
return entry.css;
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
export { parseImportMap as _, getManifestCss as a, isViteProduction as c, startViteDevServer as d, GUREN_ASCII_ART as f, DEFAULT_DEV_STYLES_ENTRY as g, logDevServerBanner as h, clientManifestCandidates as i, loadViteManifest as l, isWildcardHost as m, INJECTED_CLIENT_MANIFEST_SOURCE as n, getManifestFile as o, formatHostPort as p, PUBLIC_ASSETS_URL_PREFIX as r, injectedClientManifest as s, DEFAULT_DEV_SERVER_URL as t, normalizeDevServerUrl as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guren/server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -105,6 +105,14 @@
|
|
|
105
105
|
"./support/expiry": {
|
|
106
106
|
"types": "./dist/support/expiry.d.ts",
|
|
107
107
|
"default": "./dist/support/expiry.js"
|
|
108
|
+
},
|
|
109
|
+
"./jsx-runtime": {
|
|
110
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
111
|
+
"default": "./dist/jsx-runtime.js"
|
|
112
|
+
},
|
|
113
|
+
"./jsx-dev-runtime": {
|
|
114
|
+
"types": "./dist/jsx-dev-runtime.d.ts",
|
|
115
|
+
"default": "./dist/jsx-dev-runtime.js"
|
|
108
116
|
}
|
|
109
117
|
},
|
|
110
118
|
"scripts": {
|
|
@@ -119,7 +127,7 @@
|
|
|
119
127
|
"chalk": "^5.3.0",
|
|
120
128
|
"consola": "^3.4.2",
|
|
121
129
|
"figlet": "^1.7.0",
|
|
122
|
-
"hono": "^4.
|
|
130
|
+
"hono": "^4.13.0",
|
|
123
131
|
"ioredis": "^5.11.1",
|
|
124
132
|
"nodemailer": "^9.0.1"
|
|
125
133
|
},
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
//#region \0rolldown/runtime.js
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __exportAll = (all, no_symbols) => {
|
|
5
|
-
let target = {};
|
|
6
|
-
for (var name in all) __defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: true
|
|
9
|
-
});
|
|
10
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
|
-
return target;
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
14
|
-
export { __exportAll as t };
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import figlet from "figlet";
|
|
3
|
-
import standard from "figlet/importable-fonts/Standard.js";
|
|
4
|
-
//#region src/support/import-map.ts
|
|
5
|
-
/**
|
|
6
|
-
* Parses an import map JSON string into a record of module specifiers.
|
|
7
|
-
* Empty, null, and undefined entries are ignored so callers can safely
|
|
8
|
-
* merge optional overrides without additional filtering.
|
|
9
|
-
*/
|
|
10
|
-
function parseImportMap(value, options = {}) {
|
|
11
|
-
if (!value) return {};
|
|
12
|
-
try {
|
|
13
|
-
const parsed = JSON.parse(value);
|
|
14
|
-
const result = {};
|
|
15
|
-
for (const [key, entry] of Object.entries(parsed)) if (typeof entry === "string" && entry.length > 0) result[key] = entry;
|
|
16
|
-
return result;
|
|
17
|
-
} catch (error) {
|
|
18
|
-
const label = options.context ?? "import map";
|
|
19
|
-
console.warn(`Failed to parse ${label}. Expected JSON object.`, error);
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/support/inertia-defaults.ts
|
|
25
|
-
/**
|
|
26
|
-
* The stylesheet *source* path the dev asset configuration falls back to.
|
|
27
|
-
*
|
|
28
|
-
* Lives in a leaf module because two sides read it and must agree: the dev
|
|
29
|
-
* configuration in `http/inertia-assets.ts` publishes it into
|
|
30
|
-
* `GUREN_INERTIA_STYLES`, and the document renderer in
|
|
31
|
-
* `mvc/inertia/InertiaEngine.ts` drops exactly this path again when a dev
|
|
32
|
-
* server owns the script entry (the compiled CSS then arrives through the
|
|
33
|
-
* module graph). Importing either of those modules from the other would drag
|
|
34
|
-
* runtime-specific dependencies across the Workers/Lambda boundary or create
|
|
35
|
-
* an import cycle.
|
|
36
|
-
*/
|
|
37
|
-
const DEFAULT_DEV_STYLES_ENTRY = "/resources/css/app.css";
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region package.json
|
|
40
|
-
var version = "2.10.1";
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/http/dev-banner.ts
|
|
43
|
-
figlet.parseFont("Standard", standard);
|
|
44
|
-
function generateAsciiArt(text) {
|
|
45
|
-
try {
|
|
46
|
-
return figlet.textSync(text, {
|
|
47
|
-
font: "Standard",
|
|
48
|
-
horizontalLayout: "default",
|
|
49
|
-
verticalLayout: "default"
|
|
50
|
-
});
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error("Failed to generate FIGlet banner, falling back to plain text:", error);
|
|
53
|
-
return text.toUpperCase();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const GUREN_ASCII_ART = chalk.redBright.bold(generateAsciiArt("GUREN"));
|
|
57
|
-
const GUREN_VERSION = version;
|
|
58
|
-
/**
|
|
59
|
-
* A wildcard bind answers on every interface but is not itself dialable on
|
|
60
|
-
* every platform.
|
|
61
|
-
*
|
|
62
|
-
* Lives here rather than beside its other caller because the banner and
|
|
63
|
-
* `Application.listen()`'s returned address are two renderings of one fact,
|
|
64
|
-
* and a platform caveat added to only one of them is the drift this replaces.
|
|
65
|
-
*/
|
|
66
|
-
function isWildcardHost(hostname) {
|
|
67
|
-
return hostname === "0.0.0.0" || hostname === "::";
|
|
68
|
-
}
|
|
69
|
-
/** `host:port`, bracketing an IPv6 literal so the result is dialable. */
|
|
70
|
-
function formatHostPort(hostname, port) {
|
|
71
|
-
return `${hostname.includes(":") ? `[${hostname}]` : hostname}:${port}`;
|
|
72
|
-
}
|
|
73
|
-
function logDevServerBanner({ hostname, port, assetsUrl = "http://localhost:5173" }) {
|
|
74
|
-
const localUrl = `http://localhost:${port}`;
|
|
75
|
-
const boundUrl = `http://${formatHostPort(hostname, port)}`;
|
|
76
|
-
const boundLabel = isWildcardHost(hostname) ? " (all interfaces)" : "";
|
|
77
|
-
const header = [
|
|
78
|
-
GUREN_ASCII_ART,
|
|
79
|
-
chalk.magentaBright.bold(`Guren v${GUREN_VERSION} ignites — burning bright like a crimson lotus.`),
|
|
80
|
-
""
|
|
81
|
-
];
|
|
82
|
-
const detail = (label, value) => `${chalk.magentaBright(" •")} ${chalk.bold(label.padEnd(14))}: ${chalk.cyanBright(value)}`;
|
|
83
|
-
const banner = [
|
|
84
|
-
...header,
|
|
85
|
-
detail("App URL", localUrl),
|
|
86
|
-
detail("Bound address", `${boundUrl}${boundLabel}`),
|
|
87
|
-
detail("Asset server", `${assetsUrl} (Vite)`),
|
|
88
|
-
"",
|
|
89
|
-
chalk.yellowBright("Press Ctrl+C to douse the flames."),
|
|
90
|
-
""
|
|
91
|
-
].join("\n");
|
|
92
|
-
console.log(banner);
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/http/vite-dev-server.ts
|
|
96
|
-
/**
|
|
97
|
-
* Build the inline config the managed dev server starts with.
|
|
98
|
-
*
|
|
99
|
-
* `server.host` is only set when the caller asked for one. Left undefined it
|
|
100
|
-
* is dropped during Vite's config merge, so the project's own `vite.config.ts`
|
|
101
|
-
* decides, falling back to Vite's localhost-only default.
|
|
102
|
-
*/
|
|
103
|
-
function resolveViteDevServerConfig(options = {}) {
|
|
104
|
-
const { root = process.cwd(), config = {}, host, port } = options;
|
|
105
|
-
return {
|
|
106
|
-
clearScreen: false,
|
|
107
|
-
...config,
|
|
108
|
-
root: config.root ?? root,
|
|
109
|
-
server: {
|
|
110
|
-
host,
|
|
111
|
-
port,
|
|
112
|
-
...config.server ?? {}
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
async function startViteDevServer(options = {}) {
|
|
117
|
-
const { host, port } = options;
|
|
118
|
-
const { createServer } = await import("vite");
|
|
119
|
-
const server = await createServer(resolveViteDevServerConfig(options));
|
|
120
|
-
await server.listen();
|
|
121
|
-
const resolved = server.resolvedUrls;
|
|
122
|
-
const localUrls = resolved?.local?.length ? resolved.local : [`http://${typeof host === "string" ? host : "localhost"}:${server.config.server.port ?? port ?? 5173}`];
|
|
123
|
-
const networkUrls = resolved?.network ?? [];
|
|
124
|
-
return {
|
|
125
|
-
server,
|
|
126
|
-
localUrl: localUrls[0],
|
|
127
|
-
networkUrls
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
//#endregion
|
|
131
|
-
export { logDevServerBanner as a, isWildcardHost as i, GUREN_ASCII_ART as n, DEFAULT_DEV_STYLES_ENTRY as o, formatHostPort as r, parseImportMap as s, startViteDevServer as t };
|