xshell 1.2.67 → 1.2.69
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 +4 -1
- package/file.js +2 -1
- package/package.json +3 -3
- package/prototype.common.d.ts +10 -4
- package/prototype.common.js +9 -0
- package/utils.browser.d.ts +3 -0
- package/utils.browser.js +12 -0
- package/utils.d.ts +3 -0
- package/utils.js +15 -3
package/file.d.ts
CHANGED
|
@@ -20,9 +20,12 @@ 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
|
+
- print?: `true` */
|
|
26
29
|
export declare function fexists(fp: string, { print }?: {
|
|
27
30
|
print?: boolean;
|
|
28
31
|
}): boolean;
|
package/file.js
CHANGED
|
@@ -11,9 +11,10 @@ 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
|
+
- print?: `true` */
|
|
17
18
|
export function fexists(fp, { print = true } = {}) {
|
|
18
19
|
const exists = fs.existsSync(fp);
|
|
19
20
|
if (print)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xshell",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.69",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -101,11 +101,11 @@
|
|
|
101
101
|
"@types/babel__traverse": "^7.20.7",
|
|
102
102
|
"@types/eslint": "^9.6.1",
|
|
103
103
|
"@types/estree": "^1.0.8",
|
|
104
|
-
"@types/koa": "^
|
|
104
|
+
"@types/koa": "^3.0.0",
|
|
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.
|
|
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/prototype.common.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare global {
|
|
|
23
23
|
}): string;
|
|
24
24
|
to_regexp(this: string, preservations?: string, flags?: string): RegExp;
|
|
25
25
|
to_snake_case(this: string): string;
|
|
26
|
+
to_space_case(this: string): string;
|
|
26
27
|
/** 字符串模式替换
|
|
27
28
|
- pattern: 匹配部分的格式
|
|
28
29
|
- pattern_: 替换后的格式
|
|
@@ -148,13 +149,17 @@ declare global {
|
|
|
148
149
|
/** 格式化为 早上 09:00:00 这样的十二小时制可读友好的时间
|
|
149
150
|
- ms?: `false` 显示到 ms */
|
|
150
151
|
to_time_str(this: Date, ms?: boolean): string;
|
|
151
|
-
/** 格式化为 17.00.00 这样的时间
|
|
152
|
+
/** 格式化为 17.00.00 这样的时间
|
|
153
|
+
- ms?: `false` */
|
|
152
154
|
to_dot_time_str(this: Date, ms?: boolean): string;
|
|
153
|
-
/** 格式化为 2024.01.01 17.00.00 这样的时间
|
|
155
|
+
/** 格式化为 2024.01.01 17.00.00 这样的时间
|
|
156
|
+
- ms?: `false` */
|
|
154
157
|
to_dot_str(this: Date, ms?: boolean): string;
|
|
155
|
-
/** 格式化为 17:00:00 这样的时间
|
|
158
|
+
/** 格式化为 17:00:00 这样的时间
|
|
159
|
+
- ms?: `false` */
|
|
156
160
|
to_formal_time_str(this: Date, ms?: boolean): string;
|
|
157
|
-
/** 格式化为 2024.01.01 17:00:00 这样的时间
|
|
161
|
+
/** 格式化为 2024.01.01 17:00:00 这样的时间
|
|
162
|
+
- ms?: `false` */
|
|
158
163
|
to_formal_str(this: Date, ms?: boolean): string;
|
|
159
164
|
}
|
|
160
165
|
interface Number {
|
|
@@ -228,6 +233,7 @@ export declare const is_key_type: IsKeyType;
|
|
|
228
233
|
type IsKeyType = (key: any) => key is string | number | symbol;
|
|
229
234
|
export declare function rethrow(error: Error): void;
|
|
230
235
|
export declare function to_snake_case(str: string): string;
|
|
236
|
+
export declare function to_space_case(str: string): string;
|
|
231
237
|
export declare function to_method_property_descriptors(methods: {
|
|
232
238
|
[name: string]: Function;
|
|
233
239
|
}): PropertyDescriptorMap;
|
package/prototype.common.js
CHANGED
|
@@ -18,6 +18,12 @@ export function to_snake_case(str) {
|
|
|
18
18
|
.replace('-', '_')
|
|
19
19
|
.strip_if_start('_');
|
|
20
20
|
}
|
|
21
|
+
export function to_space_case(str) {
|
|
22
|
+
return str.replace(/([A-Z])/g, ' $1')
|
|
23
|
+
.toLowerCase()
|
|
24
|
+
.replaceAll('_', ' ')
|
|
25
|
+
.strip_if_start(' ');
|
|
26
|
+
}
|
|
21
27
|
export function to_method_property_descriptors(methods) {
|
|
22
28
|
return Object.fromEntries(Object.entries(methods)
|
|
23
29
|
.map(([name, value]) => ([name, {
|
|
@@ -75,6 +81,9 @@ if (!globalThis.my_prototype_defined) {
|
|
|
75
81
|
to_snake_case() {
|
|
76
82
|
return to_snake_case(this);
|
|
77
83
|
},
|
|
84
|
+
to_space_case() {
|
|
85
|
+
return to_space_case(this);
|
|
86
|
+
},
|
|
78
87
|
refmt(pattern, pattern_, preservations = '', flags = '', transformer = (name, value) => value || '', pattern_placeholder = /\{.*?\}/g) {
|
|
79
88
|
// --- 转换 pattern 为 pattern_regx
|
|
80
89
|
let last_end = 0;
|
package/utils.browser.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
122
|
+
return ncrypto.hash('sha256', data);
|
|
123
123
|
}
|
|
124
124
|
export function sha1(data) {
|
|
125
|
-
return
|
|
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
|