xshell 1.2.67 → 1.2.68

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/file.d.ts CHANGED
@@ -20,6 +20,9 @@ export declare const print_info_options: {
20
20
  readonly files: false;
21
21
  };
22
22
  };
23
+ export declare const binary_encoding: {
24
+ readonly encoding: "binary";
25
+ };
23
26
  export declare const ramdisk: boolean;
24
27
  /** fp 所指向的 文件/ 文件夹 是否存在
25
28
  Does the file/folder pointed to by fp exist? */
package/file.js CHANGED
@@ -11,6 +11,7 @@ export const encodings = ['utf-8', 'gb18030', 'shift-jis', 'utf-16le'];
11
11
  export const print_files = { info: true, files: true };
12
12
  export const print_info = { info: true, files: false };
13
13
  export const print_info_options = { print: print_info };
14
+ export const binary_encoding = { encoding: 'binary' };
14
15
  export const ramdisk = fexists('T:/TEMP/', noprint);
15
16
  /** fp 所指向的 文件/ 文件夹 是否存在
16
17
  Does the file/folder pointed to by fp exist? */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.2.67",
3
+ "version": "1.2.68",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -105,7 +105,7 @@
105
105
  "@types/koa-compress": "^4.0.6",
106
106
  "@types/mime-types": "^3.0.1",
107
107
  "@types/node": "^24.0.12",
108
- "@types/react": "^19.1.8",
108
+ "@types/react": "^19.1.9",
109
109
  "@types/tough-cookie": "^4.0.5",
110
110
  "@types/ua-parser-js": "^0.7.39",
111
111
  "@types/vscode": "^1.102.0",
@@ -20,3 +20,6 @@ export declare function concat(arrays: ArrayBufferView[]): Uint8Array<ArrayBuffe
20
20
  action 返回 trusy 值时认为成功,返回 action 的结果
21
21
  如果次数用尽仍然失败,返回 null */
22
22
  export declare function poll<TResult>(duration: number, times: number, action: (breaker: () => void) => Promise<TResult>): Promise<TResult>;
23
+ /** 比较两个 buffer 内容是否相同,第二个可以传入 string 自动编码转换后比较,
24
+ 高频调用时建议提前编码 right 并缓存 */
25
+ export declare function buffer_equals(left: Uint8Array, right: Uint8Array | string): boolean;
package/utils.browser.js CHANGED
@@ -109,4 +109,16 @@ export async function poll(duration, times, action) {
109
109
  }
110
110
  return null;
111
111
  }
112
+ /** 比较两个 buffer 内容是否相同,第二个可以传入 string 自动编码转换后比较,
113
+ 高频调用时建议提前编码 right 并缓存 */
114
+ export function buffer_equals(left, right) {
115
+ if (typeof right === 'string')
116
+ right = encode(right);
117
+ if (left.length !== right.length)
118
+ return false;
119
+ for (let i = 0; i < left.length; i++)
120
+ if (left[i] !== right[i])
121
+ return false;
122
+ return true;
123
+ }
112
124
  //# sourceMappingURL=utils.browser.js.map
package/utils.d.ts CHANGED
@@ -90,3 +90,6 @@ export declare function decode_buffer_hex_string(str: string): string;
90
90
  action 返回 trusy 值时认为成功,返回 action 的结果
91
91
  如果次数用尽仍然失败,返回 null */
92
92
  export declare function poll<TResult>(duration: number, times: number, action: (breaker: () => void) => Promise<TResult>): Promise<TResult>;
93
+ /** 比较两个 buffer 内容是否相同,第二个可以传入 string 自动编码转换后比较,
94
+ 高频调用时建议提前编码 right 并缓存 */
95
+ export declare function buffer_equals(left: Uint8Array, right: Uint8Array | string): boolean;
package/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Stream, Writable, Transform } from 'stream';
2
2
  import util from 'util';
3
- import crypto from 'crypto';
3
+ import ncrypto from 'crypto';
4
4
  import timers from 'timers/promises';
5
5
  import "./prototype.js";
6
6
  import { assert, decode, defer, TimeoutError } from "./utils.common.js";
@@ -119,10 +119,10 @@ export async function timeout(milliseconds, action, on_timeout, print = true) {
119
119
  });
120
120
  }
121
121
  export function sha256(data) {
122
- return crypto.hash('sha256', data);
122
+ return ncrypto.hash('sha256', data);
123
123
  }
124
124
  export function sha1(data) {
125
- return crypto.hash('sha1', data);
125
+ return ncrypto.hash('sha1', data);
126
126
  }
127
127
  /** 将字符串简单的编码为 utf-8 的 buffer (Uint8Array)。高频使用或者在流式处理时,考虑使用 TextEncoder 的 encodeInto 方法 */
128
128
  export function encode(str) {
@@ -395,4 +395,16 @@ export async function poll(duration, times, action) {
395
395
  }
396
396
  return null;
397
397
  }
398
+ /** 比较两个 buffer 内容是否相同,第二个可以传入 string 自动编码转换后比较,
399
+ 高频调用时建议提前编码 right 并缓存 */
400
+ export function buffer_equals(left, right) {
401
+ if (typeof right === 'string')
402
+ right = encode(right);
403
+ if (left.length !== right.length)
404
+ return false;
405
+ for (let i = 0; i < left.length; i++)
406
+ if (left[i] !== right[i])
407
+ return false;
408
+ return true;
409
+ }
398
410
  //# sourceMappingURL=utils.js.map