xshell 1.2.66 → 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.66",
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",
package/path.d.ts CHANGED
@@ -54,7 +54,7 @@ export declare function extname(path: string): string;
54
54
  /** `/` */
55
55
  export declare const sep = "/";
56
56
  /** The platform-specific file delimiter. ';' or ':'. */
57
- export declare const delimiter: ";" | ":";
57
+ export declare const delimiter: ":" | ";";
58
58
  /** Returns an object from a path string - the opposite of format().
59
59
  @param path path to evaluate.
60
60
  @throws {TypeError} if `path` is not a string. */
@@ -81,7 +81,7 @@ export declare let path: {
81
81
  basename: typeof basename;
82
82
  extname: typeof extname;
83
83
  sep: string;
84
- delimiter: ";" | ":";
84
+ delimiter: ":" | ";";
85
85
  parse: typeof parse;
86
86
  format: typeof format;
87
87
  toNamespacedPath: typeof toNamespacedPath;
@@ -23,12 +23,12 @@ if (!globalThis.my_prototype_defined) {
23
23
  }),
24
24
  // ------------ 文本处理工具方法
25
25
  ...to_method_property_descriptors({
26
- /** 截取字符串不超过 width 显示宽度的部分,并保留颜色
27
- 找到并记录能容纳 字符串 + … 的最后一个字符的位置 i_fitted
28
- - 若完整的字符串长度超过 width,返回 slice(0, i_fitted + 1) + …
29
- - 否则 返回 this
30
- */
31
- truncate(width) {
26
+ truncate(width, storage = false) {
27
+ if (storage)
28
+ return this.length <= width ?
29
+ this
30
+ :
31
+ this.slice(0, width - 2) + '··';
32
32
  const color_bak = this.startsWith('\u001b') ? this.slice(0, 5) : '';
33
33
  if (width <= 2)
34
34
  return this.slice(0, width);
@@ -52,7 +52,7 @@ if (!globalThis.my_prototype_defined) {
52
52
  cur_width += w;
53
53
  if (cur_width > width) {
54
54
  const i_fitted_next = i_fitted + 1;
55
- const t = this.slice(0, i_fitted_next) + ' '.repeat(width - 2 - fitted_width) + '';
55
+ const t = this.slice(0, i_fitted_next) + ' '.repeat(width - 2 - fitted_width) + '··';
56
56
  return color_bak ? color_bak + t + '\u001b[39m' : t;
57
57
  }
58
58
  }
@@ -4,11 +4,12 @@ declare global {
4
4
  interface String {
5
5
  readonly width: number;
6
6
  /** 截取字符串不超过 width 显示宽度的部分,并保留颜色
7
- 找到并记录能容纳 字符串 + 的最后一个字符的位置 i_fitted
7
+ 找到并记录能容纳 字符串 + ·· 的最后一个字符的位置 i_fitted
8
8
  若完整的字符串长度超过 width,返回 slice(0, i_fitted + 1) + …
9
9
  否则 返回 this
10
- */
11
- truncate(this: string, width: number): string;
10
+ - width: 显示宽度或者存储长度
11
+ - storage?: 根据存储长度(width 作为 length)来截取 */
12
+ truncate(this: string, width: number, storage?: boolean): string;
12
13
  /** pad string to `<width>`
13
14
  - character?: `' '`
14
15
  - position?: `'right'` */
package/prototype.js CHANGED
@@ -25,12 +25,12 @@ if (!globalThis.my_prototype_defined) {
25
25
  }),
26
26
  // ------------ 文本处理工具方法
27
27
  ...to_method_property_descriptors({
28
- /** 截取字符串不超过 width 显示宽度的部分,并保留颜色
29
- 找到并记录能容纳 字符串 + … 的最后一个字符的位置 i_fitted
30
- - 若完整的字符串长度超过 width,返回 slice(0, i_fitted + 1) + …
31
- - 否则 返回 this
32
- */
33
- truncate(width) {
28
+ truncate(width, storage = false) {
29
+ if (storage)
30
+ return this.length <= width ?
31
+ this
32
+ :
33
+ this.slice(0, width - 2) + '··';
34
34
  const color_bak = this.startsWith('\u001b') ? this.slice(0, 5) : '';
35
35
  const s = strip_ansi(this);
36
36
  if (width <= 2)
@@ -55,7 +55,7 @@ if (!globalThis.my_prototype_defined) {
55
55
  cur_width += w;
56
56
  if (cur_width > width) {
57
57
  const i_fitted_next = i_fitted + 1;
58
- // … 在 winterm 中对不齐,使用 ··· 代替
58
+ // … 在 winterm 中对不齐,使用 ·· 代替
59
59
  const t = s.slice(0, i_fitted_next) + ' '.repeat(width - 2 - fitted_width) + '··';
60
60
  return color_bak ? color_bak + t + '\u001b[39m' : t;
61
61
  }
@@ -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