xshell 1.2.72 → 1.2.74
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.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/{io.d.ts → io.common.d.ts} +1 -1
- package/{io.browser.js → io.common.js} +12 -12
- package/net.browser.d.ts +1 -1
- package/net.browser.js +58 -58
- package/net.d.ts +2 -2
- package/net.js +55 -55
- package/package.json +10 -10
- package/path.d.ts +2 -2
- package/platform.browser.d.ts +1 -0
- package/platform.browser.js +31 -0
- package/platform.common.d.ts +10 -0
- package/platform.common.js +5 -0
- package/platform.d.ts +1 -0
- package/platform.js +21 -0
- package/prototype.browser.d.ts +1 -0
- package/prototype.browser.js +1 -84
- package/prototype.common.d.ts +1 -0
- package/prototype.common.js +130 -46
- package/prototype.js +29 -112
- package/utils.browser.d.ts +1 -22
- package/utils.browser.js +2 -116
- package/utils.common.d.ts +26 -5
- package/utils.common.js +116 -11
- package/utils.d.ts +1 -21
- package/utils.js +2 -107
- package/xlint.js +1 -1
- package/io.browser.d.ts +0 -22
- package/io.js +0 -540
- package/patches/koa.patch +0 -34
package/file.js
CHANGED
|
@@ -2,7 +2,7 @@ import { promises as fsp, default as fs } from 'fs';
|
|
|
2
2
|
import { isArrayBuffer, isUint8Array } from 'util/types';
|
|
3
3
|
import { t } from "./i18n/instance.js";
|
|
4
4
|
import { noop, to_json } from "./prototype.js";
|
|
5
|
-
import { pack, parse } from "./io.js";
|
|
5
|
+
import { pack, parse } from "./io.common.js";
|
|
6
6
|
import { path } from "./path.js";
|
|
7
7
|
import { check, Lock, WritableMemoryStream, url_width, throttle, decode, strcmp } from "./utils.js";
|
|
8
8
|
import { noprint } from "./process.js";
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./prototype.
|
|
2
|
-
import { decode, encode_into, ceil2, seq } from "./utils.
|
|
1
|
+
import "./prototype.common.js";
|
|
2
|
+
import { decode, encode_into, ceil2, seq } from "./utils.common.js";
|
|
3
3
|
// 类型 | 编码
|
|
4
4
|
// --------------- | -------------------
|
|
5
5
|
// small int + | 0x00 - 0x1f (0 - 31 自然数)
|
|
@@ -51,7 +51,7 @@ let dv = buf.dataview;
|
|
|
51
51
|
let p = 0;
|
|
52
52
|
// --- 编码
|
|
53
53
|
/** 编码缓冲区,持续往里写入,满了就用一个两倍大小的替换,将旧的未写完的部分复制过来 */
|
|
54
|
-
let buffer = new Uint8Array(8 * 2 ** 20);
|
|
54
|
+
let buffer = new Uint8Array(8 * 2 ** 20 /* Buffer.poolSize */);
|
|
55
55
|
/** 编码缓冲区对应的 dataview */
|
|
56
56
|
let dataview = buffer.dataview;
|
|
57
57
|
/** 指针,编码缓冲区可以写入的位置,只增不减,除非换新 buffer */
|
|
@@ -132,7 +132,7 @@ function _parse() {
|
|
|
132
132
|
case 0xcc: {
|
|
133
133
|
const values = _parse();
|
|
134
134
|
let message = {};
|
|
135
|
-
for (let i = 0; i < values.length; i
|
|
135
|
+
for (let i = 0; i < values.length; ++i)
|
|
136
136
|
message[message_keys[i]] = values[i];
|
|
137
137
|
return message;
|
|
138
138
|
}
|
|
@@ -191,19 +191,19 @@ function parse_string(len) {
|
|
|
191
191
|
}
|
|
192
192
|
function parse_array(len) {
|
|
193
193
|
let a = new Array(len);
|
|
194
|
-
for (let i = 0; i < len; i
|
|
194
|
+
for (let i = 0; i < len; ++i)
|
|
195
195
|
a[i] = _parse();
|
|
196
196
|
return a;
|
|
197
197
|
}
|
|
198
198
|
function parse_set(size) {
|
|
199
199
|
let s = new Set();
|
|
200
|
-
for (let i = 0; i < size; i
|
|
200
|
+
for (let i = 0; i < size; ++i)
|
|
201
201
|
s.add(_parse());
|
|
202
202
|
return s;
|
|
203
203
|
}
|
|
204
204
|
function parse_object(nentries) {
|
|
205
205
|
let o = {};
|
|
206
|
-
for (let i = 0; i < nentries; i
|
|
206
|
+
for (let i = 0; i < nentries; ++i) {
|
|
207
207
|
const key = _parse();
|
|
208
208
|
o[key] = _parse();
|
|
209
209
|
}
|
|
@@ -211,7 +211,7 @@ function parse_object(nentries) {
|
|
|
211
211
|
}
|
|
212
212
|
function parse_map(nentries) {
|
|
213
213
|
let map = new Map();
|
|
214
|
-
for (let i = 0; i < nentries; i
|
|
214
|
+
for (let i = 0; i < nentries; ++i)
|
|
215
215
|
map.set(_parse(), _parse());
|
|
216
216
|
return map;
|
|
217
217
|
}
|
|
@@ -357,7 +357,7 @@ function _pack(value) {
|
|
|
357
357
|
dataview.setUint32(q, length, true);
|
|
358
358
|
q += 4;
|
|
359
359
|
}
|
|
360
|
-
for (let i = 0; i < length; i
|
|
360
|
+
for (let i = 0; i < length; ++i)
|
|
361
361
|
_pack(value[i]);
|
|
362
362
|
}
|
|
363
363
|
else if (value instanceof Uint8Array) {
|
|
@@ -509,7 +509,7 @@ function pack_string(value, qstr) {
|
|
|
509
509
|
const { length } = value;
|
|
510
510
|
if (length <= 0x3f) {
|
|
511
511
|
let j = qstr;
|
|
512
|
-
for (let i = 0; i < length; i
|
|
512
|
+
for (let i = 0; i < length; ++i) {
|
|
513
513
|
let c1 = value.charCodeAt(i), c2 = 0;
|
|
514
514
|
if (c1 < 0x80)
|
|
515
515
|
buffer[j++] = c1;
|
|
@@ -519,7 +519,7 @@ function pack_string(value, qstr) {
|
|
|
519
519
|
}
|
|
520
520
|
else if ((c1 & 0xfc00) === 0xd800 && ((c2 = value.charCodeAt(i + 1)) & 0xfc00) === 0xdc00) {
|
|
521
521
|
c1 = 0x10000 + ((c1 & 0x03ff) << 10) + (c2 & 0x03ff);
|
|
522
|
-
i
|
|
522
|
+
++i;
|
|
523
523
|
buffer[j++] = (c1 >> 18) | 0xf0;
|
|
524
524
|
buffer[j++] = ((c1 >> 12) & 0x3f) | 0x80;
|
|
525
525
|
buffer[j++] = ((c1 >> 6) & 0x3f) | 0x80;
|
|
@@ -537,4 +537,4 @@ function pack_string(value, qstr) {
|
|
|
537
537
|
return encode_into(value, buffer.subarray(qstr))
|
|
538
538
|
.written;
|
|
539
539
|
}
|
|
540
|
-
//# sourceMappingURL=io.
|
|
540
|
+
//# sourceMappingURL=io.common.js.map
|
package/net.browser.d.ts
CHANGED
package/net.browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t } from "./i18n/instance.js";
|
|
2
2
|
import { rethrow } from "./prototype.browser.js"; // to_time_str()
|
|
3
|
-
import { message_symbol, pack, parse } from "./io.
|
|
3
|
+
import { message_symbol, pack, parse } from "./io.common.js";
|
|
4
4
|
import { assert, genid, delay, Lock, timeout, check } from "./utils.browser.js";
|
|
5
5
|
import { drop_request_headers } from "./net.common.js";
|
|
6
6
|
export * from "./net.common.js";
|
|
@@ -131,14 +131,14 @@ export async function request(url, options = {}) {
|
|
|
131
131
|
}
|
|
132
132
|
/** 发起 http 请求并将响应体作为 json 解析 */
|
|
133
133
|
export async function request_json(url, options) {
|
|
134
|
-
const
|
|
135
|
-
if (!
|
|
134
|
+
const body = await request(url, options);
|
|
135
|
+
if (!body)
|
|
136
136
|
return;
|
|
137
137
|
try {
|
|
138
|
-
return JSON.parse(
|
|
138
|
+
return JSON.parse(body);
|
|
139
139
|
}
|
|
140
140
|
catch (error) {
|
|
141
|
-
console.error(
|
|
141
|
+
console.error(body);
|
|
142
142
|
throw error;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
@@ -355,62 +355,62 @@ export class Remote {
|
|
|
355
355
|
作为 websocket 连接发起方,不需要传入 websocket
|
|
356
356
|
作为 websocket 连接接收方,需要传入使用的 websocket 连接,确保这个这个连接的状态 */
|
|
357
357
|
async connect(websocket) {
|
|
358
|
-
if (this.initiator)
|
|
359
|
-
if (
|
|
358
|
+
if (!this.initiator)
|
|
359
|
+
if (websocket.readyState !== WebSocket.OPEN)
|
|
360
|
+
throw new Error('传入的 websocket 连接已断开');
|
|
361
|
+
else
|
|
360
362
|
return;
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
reconnected = true;
|
|
380
|
-
}
|
|
381
|
-
catch (error) {
|
|
382
|
-
this._on_error(error);
|
|
383
|
-
throw error;
|
|
384
|
-
}
|
|
363
|
+
if (this.lwebsocket.resource?.readyState === WebSocket.OPEN)
|
|
364
|
+
return;
|
|
365
|
+
if (!this.url)
|
|
366
|
+
throw new Error('创建 Remote 时传入的 websocket 连接已断开');
|
|
367
|
+
let reconnected = false;
|
|
368
|
+
// 假设有多个请求想要并发连接 websocket, 且此时 websocket 是断开的状态
|
|
369
|
+
// 应该排队依次连接,而不是后续的连接直接使用第一次连接的 promise,后续调用还是应该尝试重连(不止连接一次)
|
|
370
|
+
await this.lwebsocket.request(async (websocket) => {
|
|
371
|
+
// 保存的 rpc 状态在 this.handlers, 与 websocket 无关,因此即使断开重连也不影响 rpc 的运行,即
|
|
372
|
+
// 底层连接断开后自动重连对上层应该是无感知的,除非再次连接时失败
|
|
373
|
+
if (websocket?.readyState === WebSocket.OPEN)
|
|
374
|
+
return;
|
|
375
|
+
// 重连
|
|
376
|
+
try {
|
|
377
|
+
this.lwebsocket.resource = await connect_websocket(this.url, {
|
|
378
|
+
on_message: this._on_message,
|
|
379
|
+
on_error: this._on_error,
|
|
380
|
+
print: this.print
|
|
385
381
|
});
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
(async () => {
|
|
392
|
-
for (;;) {
|
|
393
|
-
await delay(heartbeat_interval);
|
|
394
|
-
if (this.disconnected)
|
|
395
|
-
break;
|
|
396
|
-
if (!this.reconnecting)
|
|
397
|
-
try {
|
|
398
|
-
await timeout(1000 * 2, this.call('echo'), undefined, this.print);
|
|
399
|
-
}
|
|
400
|
-
catch (error) {
|
|
401
|
-
if (this.print)
|
|
402
|
-
console.log(error.message);
|
|
403
|
-
this._on_error(error);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
})();
|
|
407
|
-
}
|
|
408
|
-
if (reconnected && func)
|
|
409
|
-
await this.call(func, args);
|
|
410
|
-
}
|
|
382
|
+
reconnected = true;
|
|
383
|
+
}
|
|
384
|
+
catch (error) {
|
|
385
|
+
this._on_error(error);
|
|
386
|
+
throw error;
|
|
411
387
|
}
|
|
412
|
-
|
|
413
|
-
|
|
388
|
+
});
|
|
389
|
+
if (!this.keeper)
|
|
390
|
+
return;
|
|
391
|
+
const { heartbeat_interval, func, args } = this.keeper;
|
|
392
|
+
// 首次连接成功时,开始心跳保活
|
|
393
|
+
if (!this.keeping) {
|
|
394
|
+
this.keeping = true;
|
|
395
|
+
(async () => {
|
|
396
|
+
for (;;) {
|
|
397
|
+
await delay(heartbeat_interval);
|
|
398
|
+
if (this.disconnected)
|
|
399
|
+
break;
|
|
400
|
+
if (!this.reconnecting)
|
|
401
|
+
try {
|
|
402
|
+
await timeout(1000 * 2, this.call('echo'), undefined, this.print);
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
if (this.print)
|
|
406
|
+
console.log(error.message);
|
|
407
|
+
this._on_error(error);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
})();
|
|
411
|
+
}
|
|
412
|
+
if (reconnected && func)
|
|
413
|
+
await this.call(func, args);
|
|
414
414
|
}
|
|
415
415
|
/** 作为 websocket 连接发起方手动关闭到对端的 websocket 连接 */
|
|
416
416
|
disconnect() {
|
package/net.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Readable } from 'stream';
|
|
2
2
|
import type { WebSocket, CloseEvent, ErrorEvent } from 'ws';
|
|
3
3
|
import type { Cookie, CookieJar, MemoryCookieStore } from 'tough-cookie';
|
|
4
|
-
import { type Message } from './io.ts';
|
|
4
|
+
import { type Message } from './io.common.ts';
|
|
5
5
|
import type { Encoding } from './file.ts';
|
|
6
6
|
import { inspect, Lock } from './utils.ts';
|
|
7
7
|
import { type BasicAuth, type BearerAuth, type RemoteKeeperOptions } from './net.common.ts';
|
|
@@ -278,5 +278,5 @@ export declare class RemoteClient {
|
|
|
278
278
|
[inspect.custom](): {
|
|
279
279
|
remote: string;
|
|
280
280
|
websocket: string;
|
|
281
|
-
} & Omit<this,
|
|
281
|
+
} & Omit<this, typeof import("util").inspect.custom | "call" | "websocket" | "remote" | "send">;
|
|
282
282
|
}
|
package/net.js
CHANGED
|
@@ -3,7 +3,7 @@ import { buffer as stream_to_buffer, text as stream_to_text } from 'stream/consu
|
|
|
3
3
|
import { isReadable } from 'stream';
|
|
4
4
|
import { t } from "./i18n/instance.js";
|
|
5
5
|
import { rethrow } from "./prototype.js";
|
|
6
|
-
import { message_symbol, pack, parse } from "./io.js";
|
|
6
|
+
import { message_symbol, pack, parse } from "./io.common.js";
|
|
7
7
|
import { inspect, assert, genid, delay, Lock, pipe_with_error, map_values, unique, timeout, check, colored } from "./utils.js";
|
|
8
8
|
import { drop_request_headers } from "./net.common.js";
|
|
9
9
|
export * from "./net.common.js";
|
|
@@ -100,7 +100,7 @@ export async function request(url, options = {}) {
|
|
|
100
100
|
let headers = {
|
|
101
101
|
'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5',
|
|
102
102
|
'accept-encoding': 'gzip, deflate, br',
|
|
103
|
-
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/
|
|
103
|
+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36',
|
|
104
104
|
'sec-ch-ua-platform': '"Windows"',
|
|
105
105
|
'sec-ch-ua-platform-version': '"19.0.0"',
|
|
106
106
|
};
|
|
@@ -544,62 +544,62 @@ export class Remote {
|
|
|
544
544
|
作为 websocket 连接发起方,不需要传入 websocket
|
|
545
545
|
作为 websocket 连接接收方,需要传入使用的 websocket 连接,确保这个这个连接的状态 */
|
|
546
546
|
async connect(websocket) {
|
|
547
|
-
if (this.initiator)
|
|
548
|
-
if (
|
|
547
|
+
if (!this.initiator)
|
|
548
|
+
if (websocket.readyState !== WebSocketOpen)
|
|
549
|
+
throw new Error('传入的 websocket 连接已断开');
|
|
550
|
+
else
|
|
549
551
|
return;
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
reconnected = true;
|
|
569
|
-
}
|
|
570
|
-
catch (error) {
|
|
571
|
-
this._on_error(error);
|
|
572
|
-
throw error;
|
|
573
|
-
}
|
|
552
|
+
if (this.lwebsocket.resource?.readyState === WebSocketOpen)
|
|
553
|
+
return;
|
|
554
|
+
if (!this.url)
|
|
555
|
+
throw new Error('创建 Remote 时传入的 websocket 连接已断开');
|
|
556
|
+
let reconnected = false;
|
|
557
|
+
// 假设有多个请求想要并发连接 websocket, 且此时 websocket 是断开的状态
|
|
558
|
+
// 应该排队依次连接,而不是后续的连接直接使用第一次连接的 promise,后续调用还是应该尝试重连(不止连接一次)
|
|
559
|
+
await this.lwebsocket.request(async (websocket) => {
|
|
560
|
+
// 保存的 rpc 状态在 this.handlers, 与 websocket 无关,因此即使断开重连也不影响 rpc 的运行,即
|
|
561
|
+
// 底层连接断开后自动重连对上层应该是无感知的,除非再次连接时失败
|
|
562
|
+
if (websocket?.readyState === WebSocketOpen)
|
|
563
|
+
return;
|
|
564
|
+
// 重连
|
|
565
|
+
try {
|
|
566
|
+
this.lwebsocket.resource = await connect_websocket(this.url, {
|
|
567
|
+
on_message: this._on_message,
|
|
568
|
+
on_error: this._on_error,
|
|
569
|
+
print: this.print
|
|
574
570
|
});
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
(async () => {
|
|
581
|
-
for (;;) {
|
|
582
|
-
await delay(heartbeat_interval);
|
|
583
|
-
if (this.disconnected)
|
|
584
|
-
break;
|
|
585
|
-
if (!this.reconnecting)
|
|
586
|
-
try {
|
|
587
|
-
await timeout(1000 * 2, this.call('echo'), undefined, this.print);
|
|
588
|
-
}
|
|
589
|
-
catch (error) {
|
|
590
|
-
if (this.print)
|
|
591
|
-
console.log(error.message);
|
|
592
|
-
this._on_error(error);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
})();
|
|
596
|
-
}
|
|
597
|
-
if (reconnected && func)
|
|
598
|
-
await this.call(func, args);
|
|
599
|
-
}
|
|
571
|
+
reconnected = true;
|
|
572
|
+
}
|
|
573
|
+
catch (error) {
|
|
574
|
+
this._on_error(error);
|
|
575
|
+
throw error;
|
|
600
576
|
}
|
|
601
|
-
|
|
602
|
-
|
|
577
|
+
});
|
|
578
|
+
if (!this.keeper)
|
|
579
|
+
return;
|
|
580
|
+
const { heartbeat_interval, func, args } = this.keeper;
|
|
581
|
+
// 首次连接成功时,开始心跳保活
|
|
582
|
+
if (!this.keeping) {
|
|
583
|
+
this.keeping = true;
|
|
584
|
+
(async () => {
|
|
585
|
+
for (;;) {
|
|
586
|
+
await delay(heartbeat_interval);
|
|
587
|
+
if (this.disconnected)
|
|
588
|
+
break;
|
|
589
|
+
if (!this.reconnecting)
|
|
590
|
+
try {
|
|
591
|
+
await timeout(1000 * 2, this.call('echo'), undefined, this.print);
|
|
592
|
+
}
|
|
593
|
+
catch (error) {
|
|
594
|
+
if (this.print)
|
|
595
|
+
console.log(error.message);
|
|
596
|
+
this._on_error(error);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
})();
|
|
600
|
+
}
|
|
601
|
+
if (reconnected && func)
|
|
602
|
+
await this.call(func, args);
|
|
603
603
|
}
|
|
604
604
|
/** 作为 websocket 连接发起方手动关闭到对端的 websocket 连接 */
|
|
605
605
|
disconnect() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xshell",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.74",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -53,23 +53,23 @@
|
|
|
53
53
|
"@babel/parser": "^7.28.0",
|
|
54
54
|
"@babel/traverse": "^7.28.0",
|
|
55
55
|
"@koa/cors": "^5.0.0",
|
|
56
|
-
"@stylistic/eslint-plugin": "^5.2.
|
|
56
|
+
"@stylistic/eslint-plugin": "^5.2.3",
|
|
57
57
|
"@svgr/webpack": "^8.1.0",
|
|
58
58
|
"@types/sass-loader": "^8.0.9",
|
|
59
59
|
"@types/ws": "^8.18.1",
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
61
|
-
"@typescript-eslint/parser": "^8.
|
|
62
|
-
"@typescript-eslint/utils": "^8.
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^8.39.0",
|
|
61
|
+
"@typescript-eslint/parser": "^8.39.0",
|
|
62
|
+
"@typescript-eslint/utils": "^8.39.0",
|
|
63
63
|
"archiver": "^7.0.1",
|
|
64
|
-
"chalk": "^5.
|
|
64
|
+
"chalk": "^5.5.0",
|
|
65
65
|
"commander": "^14.0.0",
|
|
66
66
|
"css-loader": "^7.1.2",
|
|
67
67
|
"emoji-regex": "^10.4.0",
|
|
68
|
-
"eslint": "^9.
|
|
68
|
+
"eslint": "^9.33.0",
|
|
69
69
|
"eslint-plugin-import": "^2.32.0",
|
|
70
70
|
"eslint-plugin-react": "^7.37.5",
|
|
71
71
|
"https-proxy-agent": "^7.0.6",
|
|
72
|
-
"i18next": "^25.3.
|
|
72
|
+
"i18next": "^25.3.4",
|
|
73
73
|
"i18next-scanner": "^4.6.0",
|
|
74
74
|
"koa": "^3.0.1",
|
|
75
75
|
"koa-compress": "^5.1.1",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"react": "^19.1.1",
|
|
81
81
|
"react-i18next": "^15.6.1",
|
|
82
82
|
"resolve-path": "^1.4.0",
|
|
83
|
-
"sass": "^1.
|
|
83
|
+
"sass": "^1.90.0",
|
|
84
84
|
"sass-loader": "^16.0.5",
|
|
85
85
|
"source-map-loader": "^5.0.0",
|
|
86
86
|
"strip-ansi": "^7.1.0",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"@types/koa": "^3.0.0",
|
|
105
105
|
"@types/koa-compress": "^4.0.6",
|
|
106
106
|
"@types/mime-types": "^3.0.1",
|
|
107
|
-
"@types/node": "^24.
|
|
107
|
+
"@types/node": "^24.2.1",
|
|
108
108
|
"@types/react": "^19.1.9",
|
|
109
109
|
"@types/tough-cookie": "^4.0.5",
|
|
110
110
|
"@types/ua-parser-js": "^0.7.39",
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './platform.common.ts';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { set_platform } from "./platform.common.js";
|
|
2
|
+
import { ident } from "./prototype.common.js";
|
|
3
|
+
import { encoder } from "./utils.common.js";
|
|
4
|
+
export * from "./platform.common.js";
|
|
5
|
+
function get_buffer(length) {
|
|
6
|
+
return new Uint8Array(length);
|
|
7
|
+
}
|
|
8
|
+
function encode(str) {
|
|
9
|
+
return encoder.encode(str);
|
|
10
|
+
}
|
|
11
|
+
async function delay(milliseconds, { signal } = {}) {
|
|
12
|
+
signal?.throwIfAborted();
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
function on_signal_abort() {
|
|
15
|
+
clearTimeout(timeout);
|
|
16
|
+
reject(signal.reason);
|
|
17
|
+
}
|
|
18
|
+
signal?.addEventListener('abort', on_signal_abort);
|
|
19
|
+
let timeout = setTimeout(() => {
|
|
20
|
+
signal?.removeEventListener('abort', on_signal_abort);
|
|
21
|
+
resolve();
|
|
22
|
+
}, milliseconds);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
set_platform({
|
|
26
|
+
get_buffer,
|
|
27
|
+
encode,
|
|
28
|
+
delay,
|
|
29
|
+
strip_ansi: ident
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=platform.browser.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TimerOptions } from 'timers';
|
|
2
|
+
export declare let platform: Platform;
|
|
3
|
+
export declare function set_platform(_platform: Platform): void;
|
|
4
|
+
interface Platform {
|
|
5
|
+
get_buffer(length: number): Uint8Array;
|
|
6
|
+
encode(str: string): Uint8Array;
|
|
7
|
+
delay(milliseconds: number, options?: TimerOptions): Promise<void>;
|
|
8
|
+
strip_ansi(str: string): string;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
package/platform.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './platform.common.ts';
|
package/platform.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import timers from 'timers/promises';
|
|
2
|
+
import strip_ansi from 'strip-ansi';
|
|
3
|
+
import { set_platform } from "./platform.common.js";
|
|
4
|
+
export * from "./platform.common.js";
|
|
5
|
+
function get_buffer(length) {
|
|
6
|
+
return Buffer.allocUnsafe(length);
|
|
7
|
+
}
|
|
8
|
+
function encode(str) {
|
|
9
|
+
// 用 Buffer.from 是因为可以利用 buffer pool,避免 encoder.encode 创建大量小且独立的 array buffer
|
|
10
|
+
return Buffer.from(str);
|
|
11
|
+
}
|
|
12
|
+
async function delay(milliseconds, options) {
|
|
13
|
+
return timers.setTimeout(milliseconds, undefined, options);
|
|
14
|
+
}
|
|
15
|
+
set_platform({
|
|
16
|
+
get_buffer,
|
|
17
|
+
encode,
|
|
18
|
+
delay,
|
|
19
|
+
strip_ansi
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=platform.js.map
|
package/prototype.browser.d.ts
CHANGED