xshell 1.1.2 → 1.1.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +4 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
package/server.js CHANGED
@@ -9,7 +9,7 @@ import node_sea from 'node:sea';
9
9
  // --- my libs
10
10
  import { t } from "./i18n/instance.js";
11
11
  import { request as _request, Remote } from "./net.js";
12
- import { inspect, output_width, check, range_to_numbers, encode, filter_keys, filter_values, consume_stream, decode } from "./utils.js";
12
+ import { inspect, output_width, check, range_to_numbers, encode, filter_keys, filter_values, consume_stream } from "./utils.js";
13
13
  import { flist, fread, fstat } from "./file.js";
14
14
  import { exe_nodejs, sea } from "./process.js";
15
15
  // ------------ my server
@@ -594,10 +594,10 @@ export class Server {
594
594
  }
595
595
  // stats, asset
596
596
  let stats;
597
- let asset;
597
+ let asset; // koa 不能理解 Uint8Array 作为 response.body, 只能用 Buffer
598
598
  try {
599
599
  if (_sea)
600
- asset = new Uint8Array(node_sea.getRawAsset(fp));
600
+ asset = Buffer.from(node_sea.getRawAsset(fp));
601
601
  else
602
602
  stats = await fstat(fp);
603
603
  }
@@ -646,7 +646,7 @@ export class Server {
646
646
  if (assets_root) {
647
647
  check(fp.endsWith('.html'), '传入 assets_root 参数时 fp 应该为 .html 文件');
648
648
  response.body = (_sea
649
- ? decode(asset)
649
+ ? asset.toString()
650
650
  : (await fread(fp, { print: false }))).replaceAll('{root}', assets_root);
651
651
  return fp;
652
652
  }