vike-lite 1.16.1 → 1.16.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.
@@ -6,8 +6,8 @@ import fs from 'node:fs'
6
6
  import fsPromises from 'node:fs/promises'
7
7
  import path from 'node:path'
8
8
  import { fileURLToPath } from 'node:url'
9
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
10
- const clientDir = path.resolve(__dirname, '../client')
9
+ const clientDir = path.resolve(import.meta.dirname, '../client')
10
+ const assetsDir = path.join(clientDir, 'assets')
11
11
  const MIME_TYPES = {
12
12
  '.html': 'text/html; charset=utf-8', '.js': 'text/javascript; charset=utf-8',
13
13
  '.mjs': 'text/javascript; charset=utf-8', '.css': 'text/css; charset=utf-8',
@@ -29,7 +29,8 @@ const server = createServer(async (req, res) => {
29
29
  const { BASE_URL } = import.meta.env
30
30
  if (BASE_URL !== '/' && pathname.startsWith(BASE_URL)) fileUrl = '/' + pathname.slice(BASE_URL.length)
31
31
  if (fileUrl !== '/') {
32
- const filePath = path.resolve(clientDir, '.' + fileUrl)
32
+ const normalizedUrl = path.normalize(fileUrl)
33
+ const filePath = path.resolve(clientDir, '.' + normalizedUrl)
33
34
  if (!filePath.startsWith(clientDir)) {
34
35
  res.statusCode = 403
35
36
  res.end('Forbidden')
@@ -41,10 +42,7 @@ const server = createServer(async (req, res) => {
41
42
  const ext = path.extname(filePath).toLowerCase()
42
43
  const mimeType = MIME_TYPES[ext] || 'application/octet-stream'
43
44
  res.setHeader('Content-Type', mimeType)
44
- res.setHeader(
45
- 'Cache-Control',
46
- fileUrl.startsWith('/assets/') ? 'public, max-age=31536000, immutable' : 'public, max-age=0, must-revalidate'
47
- )
45
+ res.setHeader('Cache-Control', filePath.startsWith(assetsDir) ? 'public, max-age=31536000, immutable' : 'public, max-age=0, must-revalidate')
48
46
  fs.createReadStream(filePath).pipe(res)
49
47
  return
50
48
  }
@@ -27,19 +27,17 @@ declare function createDepsConfigPlugin({ packageName, optimizeDepsInclude }: {
27
27
  *
28
28
  * This centralizes logic that is otherwise identical across every `vike-lite-*` package.
29
29
  */
30
- declare function createFrameworkAdapterPlugin({ packageName, hydration, wrapServerHydration, streaming }: {
30
+ declare function createFrameworkAdapterPlugin({ packageName, hydration, streaming }: {
31
31
  /** The framework adapter's package name, e.g. 'vike-lite-react'. */
32
32
  packageName: string;
33
33
  /** @default true */
34
34
  hydration?: boolean;
35
- /** @default true */
36
- wrapServerHydration?: boolean;
37
35
  /**
38
36
  * Stream the server-rendered app markup via the framework's Web Streams-based
39
37
  * SSR API instead of buffering it into a single string. Threaded through to
40
38
  * `onRenderHtml` the same way `hydration` is. Ignored by adapters whose
41
39
  * `onRenderHtml` doesn't accept a `streaming` option.
42
- * @default false
40
+ * @default true
43
41
  */
44
42
  streaming?: boolean;
45
43
  }): Plugin;
@@ -35,7 +35,7 @@ function createDepsConfigPlugin({ packageName, optimizeDepsInclude }) {
35
35
  *
36
36
  * This centralizes logic that is otherwise identical across every `vike-lite-*` package.
37
37
  */
38
- function createFrameworkAdapterPlugin({ packageName, hydration = true, wrapServerHydration = true, streaming = false }) {
38
+ function createFrameworkAdapterPlugin({ packageName, hydration = true, streaming = true }) {
39
39
  const virtualClientId = "virtual:vike-lite/client";
40
40
  const virtualServerId = "virtual:vike-lite/server";
41
41
  const resolvedVirtualClientId = "\0virtual:vike-lite/client";
@@ -49,7 +49,7 @@ function createFrameworkAdapterPlugin({ packageName, hydration = true, wrapServe
49
49
  },
50
50
  load(id) {
51
51
  if (id === resolvedVirtualClientId) return `export const onRenderClient=async(options)=>(await import("${packageName}/__internal/client/onRenderClient")).onRenderClient({...options,hydration:${hydration}});`;
52
- if (id === resolvedVirtualServerId) return `import { onRenderHtml as _onRenderHtml } from '${packageName}/__internal/server/onRenderHtml';export const onRenderHtml = (ctx) => _onRenderHtml({ ...ctx, ${wrapServerHydration ? `hydration:${hydration},streaming:${streaming}` : `streaming:${streaming}`} });`;
52
+ if (id === resolvedVirtualServerId) return `import{onRenderHtml as _onRenderHtml}from'${packageName}/__internal/server/onRenderHtml';export const onRenderHtml=(ctx)=>_onRenderHtml({...ctx,hydration:${hydration},streaming:${streaming}});`;
53
53
  }
54
54
  };
55
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike-lite",
3
- "version": "1.16.1",
3
+ "version": "1.16.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -82,7 +82,7 @@
82
82
  },
83
83
  "devDependencies": {
84
84
  "@types/node": "^26.1.1",
85
- "tsdown": "^0.22.13",
85
+ "tsdown": "^0.22.14",
86
86
  "vite": "^8.1.5",
87
87
  "vitest": "^4.1.10"
88
88
  },