@voltx/server 0.3.7 → 0.4.2
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.cjs +24 -12
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +24 -12
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -344,7 +344,9 @@ function registerSSR(app, vite, options = {}) {
|
|
|
344
344
|
render = mod.render;
|
|
345
345
|
} else {
|
|
346
346
|
const envRecord = c.env;
|
|
347
|
-
const
|
|
347
|
+
const incoming = envRecord?.incoming;
|
|
348
|
+
const viteFromSocket = incoming?.socket?.server?._viteDevServer;
|
|
349
|
+
const viteFromEnv = envRecord?.vite ?? envRecord?.VITE_DEV_SERVER ?? viteFromSocket;
|
|
348
350
|
if (viteFromEnv?.ssrLoadModule) {
|
|
349
351
|
const mod = await viteFromEnv.ssrLoadModule(entryServer);
|
|
350
352
|
render = mod.render;
|
|
@@ -353,18 +355,26 @@ function registerSSR(app, vite, options = {}) {
|
|
|
353
355
|
render = mod.render;
|
|
354
356
|
} else {
|
|
355
357
|
try {
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
optimizeDeps: { disabled: true }
|
|
361
|
-
});
|
|
362
|
-
const mod = await devServer.ssrLoadModule(entryServer);
|
|
358
|
+
const mod = await import(
|
|
359
|
+
/* @vite-ignore */
|
|
360
|
+
entryServer
|
|
361
|
+
);
|
|
363
362
|
render = mod.render;
|
|
364
363
|
} catch {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
364
|
+
try {
|
|
365
|
+
const { createServer: createViteServer } = await import("vite");
|
|
366
|
+
const devServer = await createViteServer({
|
|
367
|
+
server: { middlewareMode: true },
|
|
368
|
+
appType: "custom",
|
|
369
|
+
optimizeDeps: { disabled: true }
|
|
370
|
+
});
|
|
371
|
+
const mod = await devServer.ssrLoadModule(entryServer);
|
|
372
|
+
render = mod.render;
|
|
373
|
+
} catch {
|
|
374
|
+
throw new Error(
|
|
375
|
+
`[voltx] Cannot load "${entryServer}" \u2014 Node.js cannot import .tsx files directly. Ensure @hono/vite-dev-server is configured or pass a loadModule/render option to registerSSR().`
|
|
376
|
+
);
|
|
377
|
+
}
|
|
368
378
|
}
|
|
369
379
|
}
|
|
370
380
|
}
|
|
@@ -375,6 +385,8 @@ function registerSSR(app, vite, options = {}) {
|
|
|
375
385
|
const isProd = process.env.NODE_ENV === "production";
|
|
376
386
|
if (!isProd) {
|
|
377
387
|
clientScript = `/${entryClient}`;
|
|
388
|
+
const cssPaths = options.css ? Array.isArray(options.css) ? options.css : [options.css] : ["src/globals.css"];
|
|
389
|
+
cssLinks = cssPaths.map((p) => ` <link rel="stylesheet" href="/${p}" />`).join("\n");
|
|
378
390
|
} else {
|
|
379
391
|
if (!manifest) {
|
|
380
392
|
const manifestPath = (0, import_node_path3.resolve)(process.cwd(), "dist/client/.vite/manifest.json");
|
|
@@ -438,7 +450,7 @@ ${cssLinks}
|
|
|
438
450
|
}
|
|
439
451
|
|
|
440
452
|
// src/index.ts
|
|
441
|
-
var VERSION = "0.
|
|
453
|
+
var VERSION = "0.4.2";
|
|
442
454
|
// Annotate the CommonJS export names for ESM import in node:
|
|
443
455
|
0 && (module.exports = {
|
|
444
456
|
Hono,
|
package/dist/index.d.cts
CHANGED
|
@@ -196,6 +196,17 @@ interface SSROptions {
|
|
|
196
196
|
* entry-server module themselves (e.g. in Vite-processed server.ts).
|
|
197
197
|
*/
|
|
198
198
|
render?: (url: string) => Promise<ReadableStream>;
|
|
199
|
+
/**
|
|
200
|
+
* CSS file path(s) to inject in dev mode `<head>`.
|
|
201
|
+
* In dev, Vite serves source CSS and transforms it on the fly, but the
|
|
202
|
+
* SSR HTML shell has no `<link>` tag — CSS only loads after client JS
|
|
203
|
+
* hydrates, causing a flash of unstyled content (FOUC).
|
|
204
|
+
*
|
|
205
|
+
* Pass a string (e.g. `"src/globals.css"`) or an array of paths.
|
|
206
|
+
* Each path is emitted as `<link rel="stylesheet" href="/path">`.
|
|
207
|
+
* Defaults to `["src/globals.css"]`.
|
|
208
|
+
*/
|
|
209
|
+
css?: string | string[];
|
|
199
210
|
}
|
|
200
211
|
/** Vite dev server shape — minimal interface to avoid hard dep on vite */
|
|
201
212
|
interface ViteDevServer {
|
|
@@ -212,6 +223,6 @@ interface ViteDevServer {
|
|
|
212
223
|
*/
|
|
213
224
|
declare function registerSSR(app: Hono, vite: ViteDevServer | null, options?: SSROptions): void;
|
|
214
225
|
|
|
215
|
-
declare const VERSION = "0.
|
|
226
|
+
declare const VERSION = "0.4.2";
|
|
216
227
|
|
|
217
228
|
export { type CorsConfig, type HttpMethod, type MiddlewareHandler, type RouteEntry, type RouteHandler, type RouteModule, type SSROptions, type ServerConfig, type ServerInfo, VERSION, type ViteDevOptions, type VoltxServer, createCorsMiddleware, createErrorHandler, createLoggerMiddleware, createServer, createViteDevConfig, filePathToUrlPath, registerSSR, registerStaticFiles, scanAndRegisterRoutes };
|
package/dist/index.d.ts
CHANGED
|
@@ -196,6 +196,17 @@ interface SSROptions {
|
|
|
196
196
|
* entry-server module themselves (e.g. in Vite-processed server.ts).
|
|
197
197
|
*/
|
|
198
198
|
render?: (url: string) => Promise<ReadableStream>;
|
|
199
|
+
/**
|
|
200
|
+
* CSS file path(s) to inject in dev mode `<head>`.
|
|
201
|
+
* In dev, Vite serves source CSS and transforms it on the fly, but the
|
|
202
|
+
* SSR HTML shell has no `<link>` tag — CSS only loads after client JS
|
|
203
|
+
* hydrates, causing a flash of unstyled content (FOUC).
|
|
204
|
+
*
|
|
205
|
+
* Pass a string (e.g. `"src/globals.css"`) or an array of paths.
|
|
206
|
+
* Each path is emitted as `<link rel="stylesheet" href="/path">`.
|
|
207
|
+
* Defaults to `["src/globals.css"]`.
|
|
208
|
+
*/
|
|
209
|
+
css?: string | string[];
|
|
199
210
|
}
|
|
200
211
|
/** Vite dev server shape — minimal interface to avoid hard dep on vite */
|
|
201
212
|
interface ViteDevServer {
|
|
@@ -212,6 +223,6 @@ interface ViteDevServer {
|
|
|
212
223
|
*/
|
|
213
224
|
declare function registerSSR(app: Hono, vite: ViteDevServer | null, options?: SSROptions): void;
|
|
214
225
|
|
|
215
|
-
declare const VERSION = "0.
|
|
226
|
+
declare const VERSION = "0.4.2";
|
|
216
227
|
|
|
217
228
|
export { type CorsConfig, type HttpMethod, type MiddlewareHandler, type RouteEntry, type RouteHandler, type RouteModule, type SSROptions, type ServerConfig, type ServerInfo, VERSION, type ViteDevOptions, type VoltxServer, createCorsMiddleware, createErrorHandler, createLoggerMiddleware, createServer, createViteDevConfig, filePathToUrlPath, registerSSR, registerStaticFiles, scanAndRegisterRoutes };
|
package/dist/index.js
CHANGED
|
@@ -298,7 +298,9 @@ function registerSSR(app, vite, options = {}) {
|
|
|
298
298
|
render = mod.render;
|
|
299
299
|
} else {
|
|
300
300
|
const envRecord = c.env;
|
|
301
|
-
const
|
|
301
|
+
const incoming = envRecord?.incoming;
|
|
302
|
+
const viteFromSocket = incoming?.socket?.server?._viteDevServer;
|
|
303
|
+
const viteFromEnv = envRecord?.vite ?? envRecord?.VITE_DEV_SERVER ?? viteFromSocket;
|
|
302
304
|
if (viteFromEnv?.ssrLoadModule) {
|
|
303
305
|
const mod = await viteFromEnv.ssrLoadModule(entryServer);
|
|
304
306
|
render = mod.render;
|
|
@@ -307,18 +309,26 @@ function registerSSR(app, vite, options = {}) {
|
|
|
307
309
|
render = mod.render;
|
|
308
310
|
} else {
|
|
309
311
|
try {
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
optimizeDeps: { disabled: true }
|
|
315
|
-
});
|
|
316
|
-
const mod = await devServer.ssrLoadModule(entryServer);
|
|
312
|
+
const mod = await import(
|
|
313
|
+
/* @vite-ignore */
|
|
314
|
+
entryServer
|
|
315
|
+
);
|
|
317
316
|
render = mod.render;
|
|
318
317
|
} catch {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
318
|
+
try {
|
|
319
|
+
const { createServer: createViteServer } = await import("vite");
|
|
320
|
+
const devServer = await createViteServer({
|
|
321
|
+
server: { middlewareMode: true },
|
|
322
|
+
appType: "custom",
|
|
323
|
+
optimizeDeps: { disabled: true }
|
|
324
|
+
});
|
|
325
|
+
const mod = await devServer.ssrLoadModule(entryServer);
|
|
326
|
+
render = mod.render;
|
|
327
|
+
} catch {
|
|
328
|
+
throw new Error(
|
|
329
|
+
`[voltx] Cannot load "${entryServer}" \u2014 Node.js cannot import .tsx files directly. Ensure @hono/vite-dev-server is configured or pass a loadModule/render option to registerSSR().`
|
|
330
|
+
);
|
|
331
|
+
}
|
|
322
332
|
}
|
|
323
333
|
}
|
|
324
334
|
}
|
|
@@ -329,6 +339,8 @@ function registerSSR(app, vite, options = {}) {
|
|
|
329
339
|
const isProd = process.env.NODE_ENV === "production";
|
|
330
340
|
if (!isProd) {
|
|
331
341
|
clientScript = `/${entryClient}`;
|
|
342
|
+
const cssPaths = options.css ? Array.isArray(options.css) ? options.css : [options.css] : ["src/globals.css"];
|
|
343
|
+
cssLinks = cssPaths.map((p) => ` <link rel="stylesheet" href="/${p}" />`).join("\n");
|
|
332
344
|
} else {
|
|
333
345
|
if (!manifest) {
|
|
334
346
|
const manifestPath = resolve2(process.cwd(), "dist/client/.vite/manifest.json");
|
|
@@ -392,7 +404,7 @@ ${cssLinks}
|
|
|
392
404
|
}
|
|
393
405
|
|
|
394
406
|
// src/index.ts
|
|
395
|
-
var VERSION = "0.
|
|
407
|
+
var VERSION = "0.4.2";
|
|
396
408
|
export {
|
|
397
409
|
Hono2 as Hono,
|
|
398
410
|
VERSION,
|
package/package.json
CHANGED