vike-lite 1.13.0 → 1.13.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/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region src/index.d.ts
2
- type PageContextBase = {
2
+ type PageContextBase<Data = unknown> = {
3
3
  routeParams: Record<string, string>;
4
4
  urlOriginal: string;
5
5
  urlPathname: string;
@@ -8,19 +8,19 @@ type PageContextBase = {
8
8
  is404?: boolean;
9
9
  is500?: boolean;
10
10
  errorMessage?: string;
11
- };
12
- type PageContext<Data = unknown> = PageContextBase & (unknown extends Data ? {
11
+ } & (unknown extends Data ? {
13
12
  data?: Data;
14
13
  } : {
15
14
  data: Data;
16
15
  });
17
- type PageContextServer<Data = unknown> = PageContext<Data> & {
16
+ type PageContextServer<Data = unknown> = PageContextBase<Data> & {
18
17
  isClientSide: false;
19
18
  nonce?: string;
20
19
  };
21
- type PageContextClient = PageContextBase & {
20
+ type PageContextClient<Data = unknown> = PageContextBase<Data> & {
22
21
  isClientSide: true;
23
22
  isHydration?: boolean;
24
23
  };
24
+ type PageContext<Data = unknown> = PageContextServer<Data> | PageContextClient<Data>;
25
25
  //#endregion
26
26
  export { PageContext, PageContextClient, PageContextServer };
package/dist/vite.mjs CHANGED
@@ -207,7 +207,7 @@ function routerPlugin({ pagesDir = "pages", serverEntry = "server/index", apiPre
207
207
  };
208
208
  },
209
209
  configResolved(config) {
210
- if (!config.plugins.some((plugin) => plugin.name?.startsWith("vike-lite-") && SUPPORTED_RENDERERS.includes(plugin.name.replace("vike-lite-", "")))) throw new Error(`No UI renderer plugin found in 'vite.config': please install and configure one of ${SUPPORTED_RENDERERS.map((r) => `vike-lite-${r}`).join(", ")}`);
210
+ if (!config.plugins.some((plugin) => plugin.name?.startsWith("vike-lite-") && SUPPORTED_RENDERERS.includes(plugin.name.replace("vike-lite-", "")))) throw new Error(`[vike-lite] No UI renderer plugin found in 'vite.config': please install and configure one of ${SUPPORTED_RENDERERS.map((r) => `vike-lite-${r}`).join(", ")}`);
211
211
  },
212
212
  resolveId(id) {
213
213
  if (VIRTUAL_VALUES.has(id)) return "\0" + id;
@@ -260,7 +260,7 @@ function routerPlugin({ pagesDir = "pages", serverEntry = "server/index", apiPre
260
260
  serverEntryPath = (basePath + ext).replaceAll("\\", "/");
261
261
  break;
262
262
  }
263
- if (!serverEntryPath) throw new Error(`[vike-lite] serverEntry ${serverEntry} file not found!`);
263
+ if (!serverEntryPath) throw new Error(`[vike-lite] serverEntry ${serverEntry} file not found`);
264
264
  return `import '${VIRTUAL.setup}';export * from'${serverEntryPath}';export{default}from'${serverEntryPath}';`;
265
265
  }
266
266
  return `import '${VIRTUAL.setup}';import{renderPage}from'vike-lite/server';
@@ -386,29 +386,29 @@ if (process.env.NODE_ENV === 'production') {
386
386
  }
387
387
  }
388
388
  if (urlsToPrerender.size === 0) return;
389
- console.log("\n\x1B[36m📦 Starting Static Site Generation (SSG)...\x1B[0m");
389
+ console.log("[vike-lite] 📦 Starting Static Site Generation (SSG)");
390
390
  const { BASE_URL } = import.meta.env;
391
391
  const baseNoSlash = BASE_URL.endsWith("/") ? BASE_URL.slice(0, -1) : BASE_URL;
392
392
  let generatedCount = 0;
393
393
  const clientDir = path.resolve(viteConfigRoot, outDir, "client");
394
394
  for (const urlPath of urlsToPrerender) {
395
395
  const htmlRes = await renderPage(new Request(`http://localhost${baseNoSlash}${urlPath}`));
396
- if (htmlRes && htmlRes.ok && htmlRes.headers.get("content-type")?.includes("text/html")) {
396
+ if (htmlRes?.ok && htmlRes.headers.get("content-type")?.includes("text/html")) {
397
397
  const outDirRoute = path.join(clientDir, urlPath === "/" ? "" : urlPath);
398
398
  fs.mkdirSync(outDirRoute, { recursive: true });
399
399
  fs.writeFileSync(path.join(outDirRoute, "index.html"), await htmlRes.text());
400
- } else throw new Error(`\u{1B}[31m✖ SSG HTML Error for ${urlPath}\u{1B}[0m`);
400
+ } else throw new Error(`[vike-lite] SSG HTML Error for "${urlPath}"`);
401
401
  const jsonTarget = urlPath === "/" ? "/index" : urlPath;
402
402
  const jsonRes = await renderPage(new Request(`http://localhost${baseNoSlash}${jsonTarget}.pageContext.json`));
403
- if (jsonRes && jsonRes.ok) {
403
+ if (jsonRes?.ok) {
404
404
  const jsonOutPath = path.join(clientDir, `${jsonTarget}.pageContext.json`);
405
405
  fs.mkdirSync(path.dirname(jsonOutPath), { recursive: true });
406
406
  fs.writeFileSync(jsonOutPath, await jsonRes.text());
407
- } else throw new Error(`\u{1B}[31m✖ SSG JSON Error for ${jsonTarget}\u{1B}[0m`);
408
- console.log(`\u{1B}[32m✓\u{1B}[0m Pre-rendered: ${urlPath}`);
407
+ } else throw new Error(`[vike-lite] SSG JSON Error for "${jsonTarget}"`);
408
+ console.log(` └─ ${urlPath}`);
409
409
  generatedCount++;
410
410
  }
411
- console.log(`\n\u{1B}[32m✨ SSG Completed! Generated ${generatedCount} static routes.\u{1B}[0m\n`);
411
+ console.log(`[vike-lite] ✨ SSG Completed! Generated ${generatedCount} static routes`);
412
412
  },
413
413
  configureServer(server) {
414
414
  return () => {
@@ -435,14 +435,14 @@ if (process.env.NODE_ENV === 'production') {
435
435
  headers
436
436
  };
437
437
  if (req.url.startsWith(apiPrefix)) {
438
- server.config.logger.info(`API request: ${req.method} ${req.url}`, { timestamp: true });
438
+ server.config.logger.info(`⚡ API: ${req.method} ${req.url}`, { timestamp: true });
439
439
  requestInit.body = Readable.toWeb(req);
440
440
  requestInit.duplex = "half";
441
- } else if (req.url.endsWith(".pageContext.json")) server.config.logger.info(`SPA Navigation request: ${req.url}`, { timestamp: true });
441
+ } else if (req.url.endsWith(".pageContext.json")) server.config.logger.info(`🔄 SPA Navigation: ${req.url}`, { timestamp: true });
442
442
  const response = await app.fetch(new Request(`http://${req.headers.host}${req.url}`, requestInit));
443
443
  res.statusCode = response.status;
444
444
  if (response.headers.get("content-type")?.includes("text/html")) {
445
- server.config.logger.info(`Page request: ${req.url}`, { timestamp: true });
445
+ server.config.logger.info(`📄 Page: ${req.url}`, { timestamp: true });
446
446
  let html = await response.text();
447
447
  html = await injectFOUCStyles(server, html);
448
448
  html = await server.transformIndexHtml(req.url, html);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike-lite",
3
- "version": "1.13.0",
3
+ "version": "1.13.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/node": "^26.1.1",
54
- "tsdown": "^0.22.4",
54
+ "tsdown": "^0.22.5",
55
55
  "vite": "^8.1.4"
56
56
  },
57
57
  "peerDependencies": {