xshell 1.3.54 → 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.
- package/net.d.ts +1 -1
- package/package.json +10 -10
- package/utils.common.d.ts +4 -4
- package/utils.common.js +16 -8
- package/utils.d.ts +2 -0
- package/utils.js +18 -1
package/net.d.ts
CHANGED
|
@@ -116,7 +116,7 @@ export declare function request(url: string | URL, options: RequestOptions & {
|
|
|
116
116
|
}): Promise<Buffer>;
|
|
117
117
|
export declare function request(url: string | URL, options: RequestOptions): Promise<string>;
|
|
118
118
|
/** 发起 http 请求并将响应体作为 json 解析 */
|
|
119
|
-
export declare function request_json<
|
|
119
|
+
export declare function request_json<TReturn = any>(url: string | URL, options?: RequestOptions): Promise<TReturn>;
|
|
120
120
|
export interface ConnectOptions {
|
|
121
121
|
local_port?: number;
|
|
122
122
|
timeout?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xshell",
|
|
3
|
-
"version": "1.3.
|
|
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.
|
|
59
|
-
"@typescript-eslint/parser": "^8.58.
|
|
60
|
-
"@typescript-eslint/utils": "^8.58.
|
|
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",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"license-webpack-plugin": "^4.0.2",
|
|
74
74
|
"mime-types": "^3.0.2",
|
|
75
75
|
"p-map": "^7.0.4",
|
|
76
|
-
"react": "^19.2.
|
|
77
|
-
"react-i18next": "^17.0.
|
|
76
|
+
"react": "^19.2.5",
|
|
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,8 +85,8 @@
|
|
|
85
85
|
"ts-loader": "^9.5.7",
|
|
86
86
|
"tslib": "^2.8.1",
|
|
87
87
|
"typescript": "^6.0.2",
|
|
88
|
-
"undici": "^8.0
|
|
89
|
-
"webpack": "^5.
|
|
88
|
+
"undici": "^8.1.0",
|
|
89
|
+
"webpack": "^5.106.1",
|
|
90
90
|
"webpack-bundle-analyzer": "^5.3.0",
|
|
91
91
|
"ws": "^8.20.0"
|
|
92
92
|
},
|
|
@@ -99,10 +99,10 @@
|
|
|
99
99
|
"@types/koa": "^3.0.2",
|
|
100
100
|
"@types/koa-compress": "^4.0.7",
|
|
101
101
|
"@types/mime-types": "^3.0.1",
|
|
102
|
-
"@types/node": "^25.
|
|
102
|
+
"@types/node": "^25.6.0",
|
|
103
103
|
"@types/react": "^19.2.14",
|
|
104
104
|
"@types/tough-cookie": "^4.0.5",
|
|
105
|
-
"@types/vscode": "^1.
|
|
105
|
+
"@types/vscode": "^1.115.0",
|
|
106
106
|
"@types/webpack-bundle-analyzer": "^4.7.0",
|
|
107
107
|
"@types/ws": "^8.18.1"
|
|
108
108
|
}
|
package/utils.common.d.ts
CHANGED
|
@@ -30,11 +30,11 @@ export declare function sort_keys<TObj>(obj: TObj): TObj;
|
|
|
30
30
|
export declare function vercmp(l: string, r: string, loose?: boolean): number;
|
|
31
31
|
/** 将 keys, values 数组按对应的顺序组合成一个对象 */
|
|
32
32
|
export declare function zip_object<TValue>(keys: (string | number)[], values: TValue[]): Record<string, TValue>;
|
|
33
|
-
/**
|
|
34
|
-
- obj:
|
|
33
|
+
/** 映射数据对象 (或数组) 中的 keys, 返回新对象 (或数组)
|
|
34
|
+
- obj: 数据对象, 数据对象数组
|
|
35
35
|
- mapper?: `to_snake_case` (key: string) => string 或者 Record<string, string> 一对一映射键
|
|
36
|
-
- overrider?:
|
|
37
|
-
export declare function map_keys<TReturn>(obj: any, mapper?: ((key: string) => string) | Record<string, string>, overrider?: (mapped: any) => Partial<TReturn
|
|
36
|
+
- overrider?: 添加一些键到返回的新对象上,只对顶层有效 */
|
|
37
|
+
export declare function map_keys<TReturn = any>(obj: any, mapper?: ((key: string) => string) | Record<string, string>, overrider?: (mapped: any) => Partial<TReturn>, recursive?: boolean): TReturn;
|
|
38
38
|
/** 返回一个映射对象 keys 的函数,通常和 .map 函数一起使用 */
|
|
39
39
|
export declare function get_key_mapper<TReturn>(mapper?: ((key: string) => string) | Record<string, string>, overrider?: (mapped: any) => Partial<TReturn>): (obj: any) => TReturn;
|
|
40
40
|
/** 映射对象中的 values, 返回新对象 */
|
package/utils.common.js
CHANGED
|
@@ -98,16 +98,24 @@ export function zip_object(keys, values) {
|
|
|
98
98
|
return obj;
|
|
99
99
|
}, {});
|
|
100
100
|
}
|
|
101
|
-
/**
|
|
102
|
-
- obj:
|
|
101
|
+
/** 映射数据对象 (或数组) 中的 keys, 返回新对象 (或数组)
|
|
102
|
+
- obj: 数据对象, 数据对象数组
|
|
103
103
|
- mapper?: `to_snake_case` (key: string) => string 或者 Record<string, string> 一对一映射键
|
|
104
|
-
- overrider?:
|
|
105
|
-
export function map_keys(obj, mapper = to_snake_case, overrider) {
|
|
106
|
-
|
|
107
|
-
.map(
|
|
108
|
-
|
|
104
|
+
- overrider?: 添加一些键到返回的新对象上,只对顶层有效 */
|
|
105
|
+
export function map_keys(obj, mapper = to_snake_case, overrider, recursive = false) {
|
|
106
|
+
if (Array.isArray(obj))
|
|
107
|
+
return obj.map(v => map_keys(v, mapper, overrider, recursive));
|
|
108
|
+
if (!obj || Object.prototype.toString.call(obj) !== '[object Object]')
|
|
109
|
+
return obj;
|
|
110
|
+
const map_key = typeof mapper === 'function' ?
|
|
111
|
+
mapper
|
|
109
112
|
:
|
|
110
|
-
(
|
|
113
|
+
(key) => mapper[key] || key;
|
|
114
|
+
const obj_ = Object.fromEntries(Object.entries(obj)
|
|
115
|
+
.map(([key, value]) => [
|
|
116
|
+
map_key(key),
|
|
117
|
+
recursive ? map_keys(value, mapper, undefined, recursive) : value
|
|
118
|
+
]));
|
|
111
119
|
return (overrider ? { ...obj_, ...overrider(obj_) } : obj_);
|
|
112
120
|
}
|
|
113
121
|
/** 返回一个映射对象 keys 的函数,通常和 .map 函数一起使用 */
|
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 内从后往前生成 */
|