@quicktvui/web-cli 2.4.0 → 2.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.
File without changes
package/lib/DevServer.js CHANGED
@@ -377,7 +377,8 @@ class DevServer {
377
377
  relativePath = relativePath.replace('bundles-dev/', '')
378
378
  }
379
379
  const filePath = path.join(this.distDir, relativePath)
380
- this._serveStaticFile(res, filePath, this.distDir)
380
+ const isVendor = /^vendor\./.test(path.basename(relativePath))
381
+ this._serveStaticFile(res, filePath, this.distDir, isVendor)
381
382
  return
382
383
  }
383
384
 
@@ -393,7 +394,8 @@ class DevServer {
393
394
  if (pathname.startsWith('/bundles-dev/')) {
394
395
  const relativePath = pathname.replace('/bundles-dev/', '')
395
396
  const filePath = path.join(this.distDir, relativePath)
396
- this._serveStaticFile(res, filePath, this.distDir)
397
+ const isVendor = /^vendor\./.test(path.basename(relativePath))
398
+ this._serveStaticFile(res, filePath, this.distDir, isVendor)
397
399
  return
398
400
  }
399
401
 
@@ -462,7 +464,7 @@ class DevServer {
462
464
  * @param {string} filePath - 文件绝对路径
463
465
  * @param {string} allowedDir - 允许的根目录(安全检查)
464
466
  */
465
- _serveStaticFile(res, filePath, allowedDir) {
467
+ _serveStaticFile(res, filePath, allowedDir, optional = false) {
466
468
  // 安全检查:防止路径遍历
467
469
  const resolvedPath = path.resolve(filePath)
468
470
  const allowedRoot = path.resolve(allowedDir || this.distDir)
@@ -473,6 +475,11 @@ class DevServer {
473
475
  }
474
476
 
475
477
  if (!fs.existsSync(resolvedPath)) {
478
+ if (optional) {
479
+ res.writeHead(204)
480
+ res.end()
481
+ return
482
+ }
476
483
  res.writeHead(404, { 'Content-Type': 'text/plain' })
477
484
  res.end('Not Found')
478
485
  return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quicktvui/web-cli",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "CLI tool for QuickTVUI web development v2 - delegate build & bundle loading",
5
5
  "author": "QuickTVUI Team",
6
6
  "license": "Apache-2.0",
@@ -8,10 +8,6 @@
8
8
  "qt-web-cli": "./bin/qt-web-cli.js"
9
9
  },
10
10
  "main": "lib/index.js",
11
- "scripts": {
12
- "sync-runtime": "rm -rf runtime/*.js && cp ../web-runtime/dist/web-runtime.*.js runtime/",
13
- "prepublishOnly": "npm run sync-runtime"
14
- },
15
11
  "files": [
16
12
  "bin",
17
13
  "lib",
@@ -86,5 +82,8 @@
86
82
  },
87
83
  "engines": {
88
84
  "node": ">=16.0.0"
85
+ },
86
+ "scripts": {
87
+ "sync-runtime": "rm -rf runtime/*.js && cp ../web-runtime/dist/web-runtime.*.js runtime/"
89
88
  }
90
- }
89
+ }