xshell 1.3.55 → 1.3.56

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 (3) hide show
  1. package/package.json +6 -6
  2. package/utils.d.ts +2 -0
  3. package/utils.js +18 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.3.55",
3
+ "version": "1.3.56",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -55,9 +55,9 @@
55
55
  "@stylistic/eslint-plugin": "^5.10.0",
56
56
  "@svgr/webpack": "^8.1.0",
57
57
  "@types/sass-loader": "^8.0.10",
58
- "@typescript-eslint/eslint-plugin": "^8.58.1",
59
- "@typescript-eslint/parser": "^8.58.1",
60
- "@typescript-eslint/utils": "^8.58.1",
58
+ "@typescript-eslint/eslint-plugin": "^8.58.2",
59
+ "@typescript-eslint/parser": "^8.58.2",
60
+ "@typescript-eslint/utils": "^8.58.2",
61
61
  "archiver": "^7.0.1",
62
62
  "chalk": "^5.6.2",
63
63
  "commander": "^14.0.3",
@@ -74,7 +74,7 @@
74
74
  "mime-types": "^3.0.2",
75
75
  "p-map": "^7.0.4",
76
76
  "react": "^19.2.5",
77
- "react-i18next": "^17.0.2",
77
+ "react-i18next": "^17.0.3",
78
78
  "resolve-path": "^1.4.0",
79
79
  "sass": "^1.99.0",
80
80
  "sass-loader": "^16.0.7",
@@ -85,7 +85,7 @@
85
85
  "ts-loader": "^9.5.7",
86
86
  "tslib": "^2.8.1",
87
87
  "typescript": "^6.0.2",
88
- "undici": "^8.0.3",
88
+ "undici": "^8.1.0",
89
89
  "webpack": "^5.106.1",
90
90
  "webpack-bundle-analyzer": "^5.3.0",
91
91
  "ws": "^8.20.0"
package/utils.d.ts CHANGED
@@ -54,6 +54,8 @@ export declare class DecoderStream extends Transform {
54
54
  _transform(chunk: Uint8Array, encoding: BufferEncoding, callback: TransformCallback): void;
55
55
  _flush(callback: TransformCallback): void;
56
56
  }
57
+ /** 返回一个 transform 流,来截取可读流的前 nbytes 字节 */
58
+ export declare function slice_stream(nbytes: number): Transform;
57
59
  /** 根据 range 生成整数序列 (iterable)
58
60
  - range: 取值为逗号分割的多个可用值或值区间 (不能含有空格),比如:`8321,8322,8300-8310,11000-11999`
59
61
  - reverse?: `false` 在 range 内从后往前生成 */
package/utils.js CHANGED
@@ -3,7 +3,7 @@ import util from 'node:util';
3
3
  import ncrypto from 'node:crypto';
4
4
  import "./prototype.js";
5
5
  import "./platform.js";
6
- import { assert, decode, defer } from "./utils.common.js";
6
+ import { assert, check, decode, defer } from "./utils.common.js";
7
7
  export * from "./utils.common.js";
8
8
  /** `180` 输出字符宽度 */
9
9
  export const output_width = 180;
@@ -137,6 +137,23 @@ export class DecoderStream extends Transform {
137
137
  callback();
138
138
  }
139
139
  }
140
+ /** 返回一个 transform 流,来截取可读流的前 nbytes 字节 */
141
+ export function slice_stream(nbytes) {
142
+ let remaining = nbytes;
143
+ return new Transform({
144
+ transform(chunk, encoding, callback) {
145
+ if (chunk.length < remaining) {
146
+ this.push(chunk);
147
+ remaining -= chunk.length;
148
+ callback();
149
+ return;
150
+ }
151
+ // 最后一块
152
+ check(chunk.length === remaining, '可读流最后一块大小应该不超过 remaining');
153
+ callback(null, chunk);
154
+ }
155
+ });
156
+ }
140
157
  /** 根据 range 生成整数序列 (iterable)
141
158
  - range: 取值为逗号分割的多个可用值或值区间 (不能含有空格),比如:`8321,8322,8300-8310,11000-11999`
142
159
  - reverse?: `false` 在 range 内从后往前生成 */