xshell 1.0.96 → 1.0.98
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.browser.js +1 -3
- package/net.js +1 -3
- package/package.json +10 -10
- package/prototype.browser.d.ts +2 -0
- package/prototype.browser.js +5 -0
- package/prototype.d.ts +2 -0
- package/prototype.js +5 -0
- package/utils.browser.d.ts +7 -2
- package/utils.browser.js +19 -4
- package/utils.d.ts +7 -3
- package/utils.js +19 -30
package/net.browser.js
CHANGED
|
@@ -424,10 +424,8 @@ export class Remote {
|
|
|
424
424
|
if (data)
|
|
425
425
|
await this.send({ id, data }, websocket);
|
|
426
426
|
}
|
|
427
|
-
else if (message.error)
|
|
428
|
-
throw message.error;
|
|
429
427
|
else
|
|
430
|
-
throw new Error(`${t('找不到 rpc handler')}: ${func ? `func: ${func.quote()}` : `id: ${id}`}`);
|
|
428
|
+
throw message.error || new Error(`${t('找不到 rpc handler')}: ${func ? `func: ${func.quote()}` : `id: ${id}`}`);
|
|
431
429
|
}
|
|
432
430
|
catch (error) {
|
|
433
431
|
// handler 出错并不意味着 rpc 一定会结束,可能 error 是运行中的正常数据,所以不能清理 handler
|
package/net.js
CHANGED
|
@@ -632,10 +632,8 @@ export class Remote {
|
|
|
632
632
|
if (data)
|
|
633
633
|
await this.send({ id, data }, websocket);
|
|
634
634
|
}
|
|
635
|
-
else if (message.error)
|
|
636
|
-
throw message.error;
|
|
637
635
|
else
|
|
638
|
-
throw new Error(`${t('找不到 rpc handler')}: ${func ? `func: ${func.quote()}` : `id: ${id}`}`);
|
|
636
|
+
throw message.error || new Error(`${t('找不到 rpc handler')}: ${func ? `func: ${func.quote()}` : `id: ${id}`}`);
|
|
639
637
|
}
|
|
640
638
|
catch (error) {
|
|
641
639
|
// handler 出错并不意味着 rpc 一定会结束,可能 error 是运行中的正常数据,所以不能清理 handler
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xshell",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.98",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -71,19 +71,19 @@
|
|
|
71
71
|
"colors": "^1.4.0",
|
|
72
72
|
"commander": "^12.0.0",
|
|
73
73
|
"emoji-regex": "^10.3.0",
|
|
74
|
-
"eslint": "^9.
|
|
74
|
+
"eslint": "^9.2.0",
|
|
75
75
|
"eslint-plugin-import": "^2.29.1",
|
|
76
76
|
"eslint-plugin-react": "^7.34.1",
|
|
77
77
|
"gulp-sort": "^2.0.0",
|
|
78
78
|
"hash-string": "^1.0.0",
|
|
79
79
|
"https-proxy-agent": "^7.0.4",
|
|
80
|
-
"i18next": "^23.11.
|
|
80
|
+
"i18next": "^23.11.4",
|
|
81
81
|
"i18next-scanner": "^4.4.0",
|
|
82
82
|
"js-cookie": "^3.0.5",
|
|
83
83
|
"koa": "^2.15.3",
|
|
84
84
|
"koa-compress": "^5.1.1",
|
|
85
85
|
"lodash": "^4.17.21",
|
|
86
|
-
"map-stream": "0.0.7",
|
|
86
|
+
"map-stream": "^0.0.7",
|
|
87
87
|
"mime-types": "^2.1.35",
|
|
88
88
|
"ora": "^8.0.1",
|
|
89
89
|
"react": "^18.3.1",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"tough-cookie": "^4.1.4",
|
|
96
96
|
"tslib": "^2.6.2",
|
|
97
97
|
"typescript": "^5.4.5",
|
|
98
|
-
"ua-parser-js": "2.0.0-
|
|
99
|
-
"undici": "^6.
|
|
98
|
+
"ua-parser-js": "^2.0.0-beta.2",
|
|
99
|
+
"undici": "^6.16.1",
|
|
100
100
|
"vinyl": "^3.0.0",
|
|
101
101
|
"vinyl-fs": "^4.0.0",
|
|
102
102
|
"ws": "^8.17.0",
|
|
@@ -118,15 +118,15 @@
|
|
|
118
118
|
"@types/js-cookie": "^3.0.6",
|
|
119
119
|
"@types/koa": "^2.15.0",
|
|
120
120
|
"@types/koa-compress": "^4.0.6",
|
|
121
|
-
"@types/lodash": "^4.17.
|
|
121
|
+
"@types/lodash": "^4.17.1",
|
|
122
122
|
"@types/mime-types": "^2.1.4",
|
|
123
|
-
"@types/node": "^20.12.
|
|
124
|
-
"@types/react": "^18.3.
|
|
123
|
+
"@types/node": "^20.12.11",
|
|
124
|
+
"@types/react": "^18.3.2",
|
|
125
125
|
"@types/through2": "^2.0.41",
|
|
126
126
|
"@types/tough-cookie": "^4.0.5",
|
|
127
127
|
"@types/ua-parser-js": "^0.7.39",
|
|
128
128
|
"@types/vinyl-fs": "^3.0.5",
|
|
129
|
-
"@types/vscode": "^1.
|
|
129
|
+
"@types/vscode": "^1.89.0"
|
|
130
130
|
},
|
|
131
131
|
"pnpm": {
|
|
132
132
|
"patchedDependencies": {
|
package/prototype.browser.d.ts
CHANGED
package/prototype.browser.js
CHANGED
|
@@ -406,6 +406,11 @@ Object.defineProperties(Number.prototype, to_method_property_descriptors({
|
|
|
406
406
|
}));
|
|
407
407
|
// ------------------------------------ Array.prototype
|
|
408
408
|
Object.defineProperties(Array.prototype, {
|
|
409
|
+
...to_getter_property_descriptors({
|
|
410
|
+
last() {
|
|
411
|
+
return this.at(-1);
|
|
412
|
+
}
|
|
413
|
+
}),
|
|
409
414
|
// --- 文本处理工具方法
|
|
410
415
|
...to_method_property_descriptors({
|
|
411
416
|
trim_lines({ trim_line = true, rm_empty_lines = true, rm_last_empty_lines = false } = {}) {
|
package/prototype.d.ts
CHANGED
|
@@ -145,6 +145,8 @@ declare global {
|
|
|
145
145
|
to_oct_str(this: number): string;
|
|
146
146
|
}
|
|
147
147
|
interface Array<T> {
|
|
148
|
+
/** 等价于 .at(-1) */
|
|
149
|
+
last: T;
|
|
148
150
|
log(this: string[], limit?: number): void;
|
|
149
151
|
indent(this: string[], width: number, c?: string): string[];
|
|
150
152
|
indent2to4(this: string[]): string[];
|
package/prototype.js
CHANGED
|
@@ -435,6 +435,11 @@ if (!globalThis.my_prototype_defined) {
|
|
|
435
435
|
}));
|
|
436
436
|
// ------------------------------------ Array.prototype
|
|
437
437
|
Object.defineProperties(Array.prototype, {
|
|
438
|
+
...to_getter_property_descriptors({
|
|
439
|
+
last() {
|
|
440
|
+
return this.at(-1);
|
|
441
|
+
}
|
|
442
|
+
}),
|
|
438
443
|
// --- 文本处理工具方法
|
|
439
444
|
...to_method_property_descriptors({
|
|
440
445
|
log(limit = 10000) {
|
package/utils.browser.d.ts
CHANGED
|
@@ -6,8 +6,13 @@ export declare function log<T>(obj: T): T;
|
|
|
6
6
|
/** 生成 0, 1, ..., n - 1 (不包括 n) 的数组,支持传入 generator 函数,通过 index 生成各个元素
|
|
7
7
|
@example seq(10, i => `item-${i}`) */
|
|
8
8
|
export declare function seq<T = number>(n: number, generator?: (index: number) => T): T[];
|
|
9
|
+
/** 将 keys, values 数组按对应的顺序组合成一个对象 */
|
|
10
|
+
export declare function zip_object<TValue>(keys: (string | number)[], values: TValue[]): Record<string, TValue>;
|
|
9
11
|
export declare function delay(milliseconds: number): Promise<void>;
|
|
10
|
-
export declare
|
|
12
|
+
export declare class TimeoutError extends Error {
|
|
13
|
+
constructor(message?: string, options?: ErrorOptions);
|
|
14
|
+
}
|
|
15
|
+
export declare function timeout<TReturn>(milliseconds: number, action: () => Promise<TReturn>): Promise<TReturn>;
|
|
11
16
|
/** https://stackoverflow.com/questions/63297164/how-to-only-accept-arraybuffer-as-parameter */
|
|
12
17
|
export type StrictArrayBuffer = ArrayBuffer & {
|
|
13
18
|
buffer?: undefined;
|
|
@@ -58,7 +63,7 @@ export declare function encode(str: string): Uint8Array;
|
|
|
58
63
|
在流式处理 (buffer 可能不完整) 时,应使用独立的 TextDecoder 实例调用 decode(buffer, { stream: true }) */
|
|
59
64
|
export declare function decode(buffer: Uint8Array): string;
|
|
60
65
|
/** 字符串字典序比较 */
|
|
61
|
-
export declare function strcmp(l: string, r: string):
|
|
66
|
+
export declare function strcmp(l: string, r: string): 0 | 1 | -1;
|
|
62
67
|
/** 比较 1.10.02 这种版本号 */
|
|
63
68
|
export declare function vercmp(l: string, r: string): number;
|
|
64
69
|
export declare function get<TReturn = any>(obj: any, keypath: string): TReturn;
|
package/utils.browser.js
CHANGED
|
@@ -20,15 +20,30 @@ export function seq(n, generator) {
|
|
|
20
20
|
a[i] = generator ? generator(i) : i;
|
|
21
21
|
return a;
|
|
22
22
|
}
|
|
23
|
+
/** 将 keys, values 数组按对应的顺序组合成一个对象 */
|
|
24
|
+
export function zip_object(keys, values) {
|
|
25
|
+
return keys.reduce((obj, key, i) => {
|
|
26
|
+
obj[key] = values[i];
|
|
27
|
+
return obj;
|
|
28
|
+
}, {});
|
|
29
|
+
}
|
|
23
30
|
export async function delay(milliseconds) {
|
|
24
31
|
return new Promise(resolve => {
|
|
25
32
|
setTimeout(resolve, milliseconds);
|
|
26
33
|
});
|
|
27
34
|
}
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
export class TimeoutError extends Error {
|
|
36
|
+
constructor(message, options) {
|
|
37
|
+
super(message, options);
|
|
38
|
+
this.name = this.constructor.name;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export async function timeout(milliseconds, action) {
|
|
42
|
+
const error = new TimeoutError();
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
delay(milliseconds).then(() => { reject(error); });
|
|
45
|
+
action().then(resolve, reject);
|
|
46
|
+
});
|
|
32
47
|
}
|
|
33
48
|
/** 创建一个 promise,后续可调用 promise.resolve, promise.reject 方法设置其状态和值
|
|
34
49
|
- initial?: `undefined` 传入非 undefined 值(包括 null)时直接设置为 resolved 状态
|
package/utils.d.ts
CHANGED
|
@@ -16,13 +16,14 @@ export declare function log<T>(obj: T): T;
|
|
|
16
16
|
/** 生成 0, 1, ..., n - 1 (不包括 n) 的数组,支持传入 generator 函数,通过 index 生成各个元素
|
|
17
17
|
@example seq(10, i => `item-${i}`) */
|
|
18
18
|
export declare function seq<T = number>(n: number, generator?: (index: number) => T): T[];
|
|
19
|
-
export declare function dedent(templ: TemplateStringsArray | string, ...values: any[]): string;
|
|
20
19
|
/** 数组或 iterable 去重(可按 selector 去重)
|
|
21
20
|
- selector?: 可以是 key (string) 或 (obj: any) => any
|
|
22
21
|
*/
|
|
23
22
|
export declare function unique<T>(iterable: T[] | Iterable<T>, selector?: string | ((obj: T) => any)): any[];
|
|
24
23
|
/** 排序对象中 keys 的顺序,返回新的对象 */
|
|
25
24
|
export declare function sort_keys<TObj>(obj: TObj): TObj;
|
|
25
|
+
/** 将 keys, values 数组按对应的顺序组合成一个对象 */
|
|
26
|
+
export declare function zip_object<TValue>(keys: (string | number)[], values: TValue[]): Record<string, TValue>;
|
|
26
27
|
/** 映射对象中的 keys, 返回新对象 */
|
|
27
28
|
export declare function map_keys<TObj>(obj: TObj, mapper: (key: string) => string): TObj;
|
|
28
29
|
/** 映射对象中的 values, 返回新对象 */
|
|
@@ -38,7 +39,7 @@ export declare function filter_values<TObj extends Record<string, any>>(obj: TOb
|
|
|
38
39
|
/** 忽略对象中的 keys, 返回新对象 */
|
|
39
40
|
export declare function omit<TObj>(obj: TObj, omit_keys: string[]): TObj;
|
|
40
41
|
/** 字符串字典序比较 */
|
|
41
|
-
export declare function strcmp(l: string, r: string):
|
|
42
|
+
export declare function strcmp(l: string, r: string): 0 | 1 | -1;
|
|
42
43
|
/** 比较 1.10.02 这种版本号 */
|
|
43
44
|
export declare function vercmp(l: string, r: string): number;
|
|
44
45
|
export declare function get<TReturn = any>(obj: any, keypath: string): TReturn;
|
|
@@ -66,7 +67,10 @@ export declare class Timer {
|
|
|
66
67
|
}
|
|
67
68
|
export declare function log_line(): void;
|
|
68
69
|
export declare function delay(milliseconds: number): Promise<void>;
|
|
69
|
-
export declare
|
|
70
|
+
export declare class TimeoutError extends Error {
|
|
71
|
+
constructor(message?: string, options?: ErrorOptions);
|
|
72
|
+
}
|
|
73
|
+
export declare function timeout<TReturn>(milliseconds: number, action: () => Promise<TReturn>): Promise<TReturn>;
|
|
70
74
|
/** https://stackoverflow.com/questions/63297164/how-to-only-accept-arraybuffer-as-parameter */
|
|
71
75
|
export type StrictArrayBuffer = ArrayBuffer & {
|
|
72
76
|
buffer?: undefined;
|
package/utils.js
CHANGED
|
@@ -41,32 +41,6 @@ export function seq(n, generator) {
|
|
|
41
41
|
a[i] = generator ? generator(i) : i;
|
|
42
42
|
return a;
|
|
43
43
|
}
|
|
44
|
-
export function dedent(templ, ...values) {
|
|
45
|
-
let strings = Array.from(typeof templ === 'string' ? [templ] : templ.raw);
|
|
46
|
-
// 1. remove trailing whitespace
|
|
47
|
-
strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, '');
|
|
48
|
-
// 2. find all line breaks to determine the highest common indentation level
|
|
49
|
-
const indent_lengths = strings.reduce((arr, str) => {
|
|
50
|
-
const matches = str.match(/\n[\t ]+/g);
|
|
51
|
-
if (matches)
|
|
52
|
-
return arr.concat(matches.map(match => match.length - 1));
|
|
53
|
-
return arr;
|
|
54
|
-
}, []);
|
|
55
|
-
// 3. remove the common indentation from all strings
|
|
56
|
-
if (indent_lengths.length) {
|
|
57
|
-
const pattern = new RegExp(`\n[\t ]{${Math.min(...indent_lengths)}}`, 'g');
|
|
58
|
-
strings = strings.map(str => str.replace(pattern, '\n'));
|
|
59
|
-
}
|
|
60
|
-
// 4. remove leading whitespace
|
|
61
|
-
strings[0] = strings[0].replace(/^\r?\n/, '');
|
|
62
|
-
// 5. perform interpolation
|
|
63
|
-
let string = strings[0];
|
|
64
|
-
values.forEach((value, i) => {
|
|
65
|
-
string += value + strings[i + 1];
|
|
66
|
-
});
|
|
67
|
-
string += '\n';
|
|
68
|
-
return string;
|
|
69
|
-
}
|
|
70
44
|
/** 数组或 iterable 去重(可按 selector 去重)
|
|
71
45
|
- selector?: 可以是 key (string) 或 (obj: any) => any
|
|
72
46
|
*/
|
|
@@ -84,6 +58,13 @@ export function sort_keys(obj) {
|
|
|
84
58
|
return Object.fromEntries(Object.entries(obj)
|
|
85
59
|
.sort(([key_l], [key_r]) => strcmp(key_l, key_r)));
|
|
86
60
|
}
|
|
61
|
+
/** 将 keys, values 数组按对应的顺序组合成一个对象 */
|
|
62
|
+
export function zip_object(keys, values) {
|
|
63
|
+
return keys.reduce((obj, key, i) => {
|
|
64
|
+
obj[key] = values[i];
|
|
65
|
+
return obj;
|
|
66
|
+
}, {});
|
|
67
|
+
}
|
|
87
68
|
/** 映射对象中的 keys, 返回新对象 */
|
|
88
69
|
export function map_keys(obj, mapper) {
|
|
89
70
|
return Object.fromEntries(Object.entries(obj)
|
|
@@ -218,10 +199,18 @@ export async function delay(milliseconds) {
|
|
|
218
199
|
setTimeout(resolve, milliseconds);
|
|
219
200
|
});
|
|
220
201
|
}
|
|
221
|
-
export
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
202
|
+
export class TimeoutError extends Error {
|
|
203
|
+
constructor(message, options) {
|
|
204
|
+
super(message, options);
|
|
205
|
+
this.name = this.constructor.name;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
export async function timeout(milliseconds, action) {
|
|
209
|
+
const error = new TimeoutError();
|
|
210
|
+
return new Promise((resolve, reject) => {
|
|
211
|
+
delay(milliseconds).then(() => { reject(error); });
|
|
212
|
+
action().then(resolve, reject);
|
|
213
|
+
});
|
|
225
214
|
}
|
|
226
215
|
/** 创建一个 promise,后续可调用 promise.resolve, promise.reject 方法设置其状态和值
|
|
227
216
|
- initial?: `undefined` 传入非 undefined 值(包括 null)时直接设置为 resolved 状态
|