xshell 1.0.96 → 1.0.97
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/package.json +6 -6
- package/utils.browser.d.ts +3 -1
- package/utils.browser.js +7 -0
- package/utils.d.ts +3 -2
- package/utils.js +7 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xshell",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.97",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -71,7 +71,7 @@
|
|
|
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",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"tslib": "^2.6.2",
|
|
97
97
|
"typescript": "^5.4.5",
|
|
98
98
|
"ua-parser-js": "2.0.0-alpha.2",
|
|
99
|
-
"undici": "^6.
|
|
99
|
+
"undici": "^6.16.0",
|
|
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.
|
|
123
|
+
"@types/node": "^20.12.11",
|
|
124
124
|
"@types/react": "^18.3.1",
|
|
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/utils.browser.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ 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
12
|
export declare function timeout(milliseconds: number): Promise<void>;
|
|
11
13
|
/** https://stackoverflow.com/questions/63297164/how-to-only-accept-arraybuffer-as-parameter */
|
|
@@ -58,7 +60,7 @@ export declare function encode(str: string): Uint8Array;
|
|
|
58
60
|
在流式处理 (buffer 可能不完整) 时,应使用独立的 TextDecoder 实例调用 decode(buffer, { stream: true }) */
|
|
59
61
|
export declare function decode(buffer: Uint8Array): string;
|
|
60
62
|
/** 字符串字典序比较 */
|
|
61
|
-
export declare function strcmp(l: string, r: string):
|
|
63
|
+
export declare function strcmp(l: string, r: string): 0 | 1 | -1;
|
|
62
64
|
/** 比较 1.10.02 这种版本号 */
|
|
63
65
|
export declare function vercmp(l: string, r: string): number;
|
|
64
66
|
export declare function get<TReturn = any>(obj: any, keypath: string): TReturn;
|
package/utils.browser.js
CHANGED
|
@@ -20,6 +20,13 @@ 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);
|
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;
|
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)
|