xshell 1.0.200 → 1.0.202
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/Terminal.d.ts +1 -1
- package/Terminal.js +1 -1
- package/apps.d.ts +1 -1
- package/apps.js +3 -3
- package/builder.d.ts +1 -1
- package/builder.js +4 -4
- package/file.js +4 -4
- package/git.d.ts +2 -2
- package/git.js +5 -4
- package/i18n/dict.d.ts +1 -1
- package/i18n/i18n-scan.js +3 -3
- package/i18n/index.d.ts +1 -1
- package/i18n/index.js +1 -1
- package/i18n/instance.d.ts +1 -1
- package/i18n/instance.js +1 -1
- package/i18n/rwdict.d.ts +3 -3
- package/i18n/rwdict.js +2 -2
- package/i18n/scanner/index.d.ts +1 -1
- package/i18n/scanner/index.js +7 -7
- package/i18n/scanner/parser.d.ts +1 -1
- package/i18n/scanner/parser.js +1 -1
- package/i18n/utils.js +1 -1
- package/index.d.ts +6 -6
- package/index.js +6 -6
- package/net.browser.d.ts +3 -3
- package/net.browser.js +3 -3
- package/net.d.ts +5 -5
- package/net.js +22 -12
- package/package.json +12 -12
- package/process.d.ts +4 -4
- package/process.js +45 -14
- package/prototype.browser.js +1 -1
- package/prototype.js +2 -2
- package/repl.d.ts +1 -1
- package/repl.js +5 -5
- package/server.d.ts +1 -1
- package/server.js +4 -4
- package/toaster.browser.js +1 -1
- package/tsconfig.json +2 -1
- package/utils.browser.d.ts +2 -2
- package/utils.browser.js +1 -1
- package/utils.d.ts +5 -5
- package/utils.js +2 -2
- package/xshell.js +1 -1
package/Terminal.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import '@xterm/xterm/css/xterm.css';
|
|
|
2
2
|
import { Terminal as XTerminal } from '@xterm/xterm';
|
|
3
3
|
import { FitAddon } from '@xterm/addon-fit';
|
|
4
4
|
import { Model } from 'react-object-model';
|
|
5
|
-
import type { Remote } from './net.browser.
|
|
5
|
+
import type { Remote } from './net.browser.ts';
|
|
6
6
|
export declare function Terminal({ font }: {
|
|
7
7
|
font: string;
|
|
8
8
|
}): import("react/jsx-runtime").JSX.Element;
|
package/Terminal.js
CHANGED
|
@@ -8,7 +8,7 @@ import { WebLinksAddon } from '@xterm/addon-web-links';
|
|
|
8
8
|
// 没有 ui
|
|
9
9
|
// import { SearchAddon } from '@xterm/addon-search'
|
|
10
10
|
import { Model } from 'react-object-model';
|
|
11
|
-
import { assert, defer, genid } from
|
|
11
|
+
import { assert, defer, genid } from "./utils.browser.js";
|
|
12
12
|
export function Terminal({ font }) {
|
|
13
13
|
let rterminal = useRef();
|
|
14
14
|
useEffect(() => {
|
package/apps.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Readable } from 'stream';
|
|
2
2
|
import type OSS from 'ali-oss';
|
|
3
|
-
import { type CallOptions } from './process.
|
|
3
|
+
import { type CallOptions } from './process.ts';
|
|
4
4
|
export declare let npm: {
|
|
5
5
|
bin: string;
|
|
6
6
|
call(cwd: string, bin: string, args: string[], options?: CallOptions): Promise<import("./process.ts").CallResult<string>>;
|
package/apps.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import util from 'util';
|
|
2
|
-
import { call_nodejs, platform, username } from
|
|
3
|
-
import { check } from
|
|
4
|
-
import { path } from
|
|
2
|
+
import { call_nodejs, platform, username } from "./process.js";
|
|
3
|
+
import { check } from "./utils.js";
|
|
4
|
+
import { path } from "./path.js";
|
|
5
5
|
export let npm = {
|
|
6
6
|
bin: platform == 'win32' ? `C:/Users/${username}/AppData/Roaming/npm/node_modules/pnpm/bin/pnpm.cjs` : '/usr/bin/pnpm',
|
|
7
7
|
async call(cwd, bin, args, options) {
|
package/builder.d.ts
CHANGED
package/builder.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
|
-
import { noprint } from
|
|
3
|
-
import { Lock, check, filter_values, not_empty } from
|
|
4
|
-
import { fcopy, fmkdir, fwrite } from
|
|
5
|
-
import { path } from
|
|
2
|
+
import { noprint } from "./process.js";
|
|
3
|
+
import { Lock, check, filter_values, not_empty } from "./utils.js";
|
|
4
|
+
import { fcopy, fmkdir, fwrite } from "./file.js";
|
|
5
|
+
import { path } from "./path.js";
|
|
6
6
|
const monaco_files = [
|
|
7
7
|
'loader.js',
|
|
8
8
|
'nls.messages.zh-cn.js',
|
package/file.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { promises as fsp, default as fs } from 'fs';
|
|
2
2
|
import { isUint8Array } from 'util/types';
|
|
3
|
-
import { path } from
|
|
4
|
-
import { t } from
|
|
5
|
-
import { to_json } from
|
|
6
|
-
import { check, Lock, WritableMemoryStream } from
|
|
3
|
+
import { path } from "./path.js";
|
|
4
|
+
import { t } from "./i18n/instance.js";
|
|
5
|
+
import { to_json } from "./prototype.js";
|
|
6
|
+
import { check, Lock, WritableMemoryStream } from "./utils.js";
|
|
7
7
|
export { fsp };
|
|
8
8
|
export const encodings = ['utf-8', 'gb18030', 'shift-jis', 'utf-16le'];
|
|
9
9
|
export const ramdisk = fexists('T:/TEMP/', { print: false });
|
package/git.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type CallOptions } from './process.
|
|
1
|
+
import { type CallOptions } from './process.ts';
|
|
2
2
|
export declare class Git {
|
|
3
3
|
static exe: string;
|
|
4
4
|
cwd: string;
|
|
5
5
|
constructor(cwd: string);
|
|
6
6
|
static init(cwd: string, print?: boolean): Promise<Git>;
|
|
7
|
-
static clone(repo: string, fpd: string, shallow?: boolean | string): Promise<
|
|
7
|
+
static clone(repo: string, fpd: string, shallow?: boolean | string): Promise<Git>;
|
|
8
8
|
call(args?: any[], { color, print, printers, throw_code, }?: {
|
|
9
9
|
color?: boolean;
|
|
10
10
|
print?: CallOptions['print'];
|
package/git.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { call, print_no_command } from
|
|
2
|
-
import { fread, fmkdir } from
|
|
1
|
+
import { call, print_no_command } from "./process.js";
|
|
2
|
+
import { fread, fmkdir } from "./file.js";
|
|
3
3
|
export class Git {
|
|
4
4
|
static exe = 'git';
|
|
5
5
|
cwd;
|
|
@@ -13,14 +13,15 @@ export class Git {
|
|
|
13
13
|
}
|
|
14
14
|
static async clone(repo, fpd, shallow = false) {
|
|
15
15
|
await fmkdir(fpd);
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
let git = new this(fpd);
|
|
17
|
+
await git.call([
|
|
18
18
|
'clone',
|
|
19
19
|
...typeof shallow === 'string' ? ['--branch', shallow, '--single-branch'] : [],
|
|
20
20
|
...shallow ? ['--depth', '1'] : [],
|
|
21
21
|
repo,
|
|
22
22
|
'.'
|
|
23
23
|
]);
|
|
24
|
+
return git;
|
|
24
25
|
}
|
|
25
26
|
async call(args = [], { color = true, print, printers, throw_code, } = {}) {
|
|
26
27
|
return call(Git.exe, [
|
package/i18n/dict.d.ts
CHANGED
package/i18n/i18n-scan.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { program } from 'commander';
|
|
3
|
-
import { path } from
|
|
4
|
-
import { scanner } from
|
|
5
|
-
import { try_load_dict } from
|
|
3
|
+
import { path } from "../path.js";
|
|
4
|
+
import { scanner } from "./scanner/index.js";
|
|
5
|
+
import { try_load_dict } from "./utils.js";
|
|
6
6
|
(async function main() {
|
|
7
7
|
program.name('i18n-scan')
|
|
8
8
|
.option('-r, --rootdir [rootdir]', '根目录:默认为当前工作目录', path.normalize(process.cwd()))
|
package/i18n/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type i18n as I18Next } from 'i18next';
|
|
2
2
|
import type { Trans } from 'react-i18next';
|
|
3
|
-
import { type _Dict, type Item } from './dict.
|
|
3
|
+
import { type _Dict, type Item } from './dict.ts';
|
|
4
4
|
export type Language = 'zh' | 'en' | 'ja' | 'ko';
|
|
5
5
|
export declare const LANGUAGES: readonly ["zh", "en", "ja", "ko"];
|
|
6
6
|
declare global {
|
package/i18n/index.js
CHANGED
package/i18n/instance.d.ts
CHANGED
package/i18n/instance.js
CHANGED
package/i18n/rwdict.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import '../prototype.
|
|
2
|
-
import type { Language } from './index.
|
|
3
|
-
import { Dict, type Item, type _Dict } from './dict.
|
|
1
|
+
import '../prototype.ts';
|
|
2
|
+
import type { Language } from './index.ts';
|
|
3
|
+
import { Dict, type Item, type _Dict } from './dict.ts';
|
|
4
4
|
/** read write Dict for scanner */
|
|
5
5
|
export declare class RWDict extends Dict {
|
|
6
6
|
/** 更新词条 */
|
package/i18n/rwdict.js
CHANGED
package/i18n/scanner/index.d.ts
CHANGED
package/i18n/scanner/index.js
CHANGED
|
@@ -6,13 +6,13 @@ import cli_truncate from 'cli-truncate';
|
|
|
6
6
|
import Vinyl from 'vinyl';
|
|
7
7
|
import through2 from 'through2';
|
|
8
8
|
import CliTable from 'cli-table3';
|
|
9
|
-
import
|
|
10
|
-
import { path } from
|
|
11
|
-
import { map_stream } from
|
|
12
|
-
import { LANGUAGES } from
|
|
13
|
-
import { RWDict } from
|
|
14
|
-
import { try_load_dict } from
|
|
15
|
-
import { mix_parse_trans_from_string_by_babel } from
|
|
9
|
+
import "../../prototype.js";
|
|
10
|
+
import { path } from "../../path.js";
|
|
11
|
+
import { map_stream } from "../../utils.js";
|
|
12
|
+
import { LANGUAGES } from "../index.js";
|
|
13
|
+
import { RWDict } from "../rwdict.js";
|
|
14
|
+
import { try_load_dict } from "../utils.js";
|
|
15
|
+
import { mix_parse_trans_from_string_by_babel } from "./parser.js";
|
|
16
16
|
/** 默认 i18next 扫描配置 */
|
|
17
17
|
const DEFAULT_CONFIG = {
|
|
18
18
|
debug: false,
|
package/i18n/scanner/parser.d.ts
CHANGED
package/i18n/scanner/parser.js
CHANGED
|
@@ -6,7 +6,7 @@ import babel_traverse from '@babel/traverse';
|
|
|
6
6
|
const { default: traverse } = babel_traverse;
|
|
7
7
|
import { parse } from '@babel/parser';
|
|
8
8
|
import t from '@babel/types';
|
|
9
|
-
import
|
|
9
|
+
import "../../prototype.js";
|
|
10
10
|
// import { Checker } from './checker'
|
|
11
11
|
/** file:///D:/0/i18next-scanner/src/parser.js */
|
|
12
12
|
export function mix_parse_trans_from_string_by_babel(parser) {
|
package/i18n/utils.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './path.
|
|
2
|
-
export * from './prototype.
|
|
3
|
-
export * from './utils.
|
|
4
|
-
export * from './file.
|
|
5
|
-
export * from './process.
|
|
6
|
-
export * from './net.
|
|
1
|
+
export * from './path.ts';
|
|
2
|
+
export * from './prototype.ts';
|
|
3
|
+
export * from './utils.ts';
|
|
4
|
+
export * from './file.ts';
|
|
5
|
+
export * from './process.ts';
|
|
6
|
+
export * from './net.ts';
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
1
|
+
export * from "./path.js";
|
|
2
|
+
export * from "./prototype.js";
|
|
3
|
+
export * from "./utils.js";
|
|
4
|
+
export * from "./file.js";
|
|
5
|
+
export * from "./process.js";
|
|
6
|
+
export * from "./net.js";
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/net.browser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import './prototype.browser.
|
|
2
|
-
import { Lock } from './utils.browser.
|
|
1
|
+
import './prototype.browser.ts';
|
|
2
|
+
import { Lock } from './utils.browser.ts';
|
|
3
3
|
export interface FullResponse<TBody extends ArrayBuffer | string> {
|
|
4
4
|
status: number;
|
|
5
5
|
headers: Headers;
|
|
@@ -197,7 +197,7 @@ export declare class Remote {
|
|
|
197
197
|
disconnected: boolean;
|
|
198
198
|
/** 使用 Uint8Array 作为参数更灵活 https://stackoverflow.com/a/74505197/7609214 */
|
|
199
199
|
static parse<TData extends any[] = any[]>(buffer: Uint8Array): Message<TData>;
|
|
200
|
-
static pack({ id, func, data, done, error }: Message): Uint8Array
|
|
200
|
+
static pack({ id, func, data, done, error }: Message): Uint8Array<ArrayBuffer>;
|
|
201
201
|
/** 作为 websocket 连接发起方,传入 url 或 websocket,定义远程 Remote
|
|
202
202
|
作为 websocket 连接接收方,不传 url 和 websocket,定义本地 Remote */
|
|
203
203
|
constructor({ url, funcs, print, verbose, websocket, keeper, on_error, }?: {
|
package/net.browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t } from
|
|
2
|
-
import
|
|
3
|
-
import { assert, concat, genid, delay, Lock, encode, decode, timeout, check } from
|
|
1
|
+
import { t } from "./i18n/instance.js";
|
|
2
|
+
import "./prototype.browser.js"; // to_time_str()
|
|
3
|
+
import { assert, concat, genid, delay, Lock, encode, decode, timeout, check } from "./utils.browser.js";
|
|
4
4
|
const drop_request_headers = new Set([
|
|
5
5
|
// : 开头的 key
|
|
6
6
|
// sec-*
|
package/net.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { type Readable } from 'stream';
|
|
|
2
2
|
import type { FormData } from 'undici';
|
|
3
3
|
import type { WebSocket, CloseEvent, ErrorEvent } from 'ws';
|
|
4
4
|
import type { Cookie, CookieJar, MemoryCookieStore } from 'tough-cookie';
|
|
5
|
-
import './prototype.
|
|
6
|
-
import type { Encoding } from './file.
|
|
7
|
-
import { inspect, Lock } from './utils.
|
|
5
|
+
import './prototype.ts';
|
|
6
|
+
import type { Encoding } from './file.ts';
|
|
7
|
+
import { inspect, Lock } from './utils.ts';
|
|
8
8
|
export type { WebSocket };
|
|
9
9
|
export declare const WebSocketConnecting = 0;
|
|
10
10
|
export declare const WebSocketOpen = 1;
|
|
@@ -52,7 +52,7 @@ export interface RequestOptions {
|
|
|
52
52
|
timeout?: number;
|
|
53
53
|
auth?: BasicAuth | BearerAuth;
|
|
54
54
|
cookies?: Record<string, string>;
|
|
55
|
-
redirect?:
|
|
55
|
+
redirect?: 'follow' | 'manual';
|
|
56
56
|
decode?: boolean;
|
|
57
57
|
}
|
|
58
58
|
export interface RequestFullOptions extends RequestOptions {
|
|
@@ -257,7 +257,7 @@ export declare class Remote {
|
|
|
257
257
|
disconnected: boolean;
|
|
258
258
|
/** 使用 Uint8Array 作为参数更灵活 https://stackoverflow.com/a/74505197/7609214 */
|
|
259
259
|
static parse<TData extends any[] = any[]>(buffer: Uint8Array): Message<TData>;
|
|
260
|
-
static pack({ id, func, data, done, error }: Message): Uint8Array
|
|
260
|
+
static pack({ id, func, data, done, error }: Message): Uint8Array<ArrayBuffer>;
|
|
261
261
|
/** 作为 websocket 连接发起方,传入 url 或 websocket,定义远程 Remote
|
|
262
262
|
作为 websocket 连接接收方,不传 url 和 websocket,定义本地 Remote */
|
|
263
263
|
constructor({ url, funcs, print, verbose, websocket, keeper, on_error, }?: {
|
package/net.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import zlib from 'zlib';
|
|
2
2
|
import { buffer as stream_to_buffer, text as stream_to_text } from 'stream/consumers';
|
|
3
3
|
import { isReadable } from 'stream';
|
|
4
|
-
import { t } from
|
|
5
|
-
import
|
|
6
|
-
import { inspect, concat, assert, genid, delay, Lock, encode, decode, pipe_with_error, map_values, unique, timeout, check } from
|
|
4
|
+
import { t } from "./i18n/instance.js";
|
|
5
|
+
import "./prototype.js";
|
|
6
|
+
import { inspect, concat, assert, genid, delay, Lock, encode, decode, pipe_with_error, map_values, unique, timeout, check } from "./utils.js";
|
|
7
7
|
export const WebSocketConnecting = 0;
|
|
8
8
|
export const WebSocketOpen = 1;
|
|
9
9
|
export const WebSocketClosing = 2;
|
|
@@ -37,7 +37,7 @@ const drop_request_headers = new Set([
|
|
|
37
37
|
'transfer-encoding',
|
|
38
38
|
'upgrade',
|
|
39
39
|
]);
|
|
40
|
-
let
|
|
40
|
+
let agents = {};
|
|
41
41
|
async function request_retry(url, options, _timeout, retries = 0, count = 0) {
|
|
42
42
|
let { default: undici, request: undici_request } = await import('undici');
|
|
43
43
|
undici_request ??= undici.request;
|
|
@@ -45,7 +45,9 @@ async function request_retry(url, options, _timeout, retries = 0, count = 0) {
|
|
|
45
45
|
if (_timeout > 0) {
|
|
46
46
|
// 设置给 undici 设置 timeout, signal 不一定管用,还是得自己兜底
|
|
47
47
|
options.signal = AbortSignal.timeout(_timeout);
|
|
48
|
-
return await timeout(_timeout + 300
|
|
48
|
+
return await timeout(_timeout + 300, // 为 undici 兜底
|
|
49
|
+
async () => undici.request(url, options), undefined, count >= retries // 只打印最后一次超时的错误,避免太多冗余输出
|
|
50
|
+
);
|
|
49
51
|
}
|
|
50
52
|
else
|
|
51
53
|
return await undici.request(url, options);
|
|
@@ -89,7 +91,7 @@ export async function request(url, options = {}) {
|
|
|
89
91
|
let headers = {
|
|
90
92
|
'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',
|
|
91
93
|
'accept-encoding': 'gzip, deflate, br',
|
|
92
|
-
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/
|
|
94
|
+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
|
|
93
95
|
'sec-ch-ua-platform': '"Windows"',
|
|
94
96
|
'sec-ch-ua-platform-version': '"15.0.0"',
|
|
95
97
|
};
|
|
@@ -121,12 +123,20 @@ export async function request(url, options = {}) {
|
|
|
121
123
|
}
|
|
122
124
|
let undici_options = {
|
|
123
125
|
...method ? { method } : {},
|
|
124
|
-
dispatcher: (() => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
dispatcher: await (async () => {
|
|
127
|
+
const { default: {
|
|
128
|
+
// @ts-ignore
|
|
129
|
+
ProxyAgent, Agent, interceptors } } = await import('undici');
|
|
130
|
+
if (proxy === true)
|
|
131
|
+
proxy = MyProxy.socks5;
|
|
132
|
+
return agents[`${proxy || 'direct'}.${redirect}`] ??= (() => {
|
|
133
|
+
let dispatcher = proxy ? new ProxyAgent({ uri: proxy }) : new Agent();
|
|
134
|
+
if (redirect === 'follow')
|
|
135
|
+
dispatcher = dispatcher.compose(
|
|
136
|
+
// todo: 强制手动处理重定向,来正确处理 cookie ?
|
|
137
|
+
interceptors.redirect({ maxRedirections: 5 }));
|
|
138
|
+
return dispatcher;
|
|
139
|
+
})();
|
|
130
140
|
})(),
|
|
131
141
|
// todo: 强制手动处理重定向,来正确处理 cookie ?
|
|
132
142
|
maxRedirections: redirect === 'follow' ? 5 : 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xshell",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.202",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"@svgr/webpack": "^8.1.0",
|
|
58
58
|
"@types/sass-loader": "^8.0.9",
|
|
59
59
|
"@types/ws": "^8.5.13",
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
61
|
-
"@typescript-eslint/parser": "^8.
|
|
62
|
-
"@typescript-eslint/utils": "^8.
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^8.16.0",
|
|
61
|
+
"@typescript-eslint/parser": "^8.16.0",
|
|
62
|
+
"@typescript-eslint/utils": "^8.16.0",
|
|
63
63
|
"@xterm/addon-fit": "^0.10.0",
|
|
64
64
|
"@xterm/addon-web-links": "^0.11.0",
|
|
65
65
|
"@xterm/addon-webgl": "^0.18.0",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"gulp-sort": "^2.0.0",
|
|
82
82
|
"hash-string": "^1.0.0",
|
|
83
83
|
"https-proxy-agent": "^7.0.5",
|
|
84
|
-
"i18next": "^
|
|
84
|
+
"i18next": "^24.0.2",
|
|
85
85
|
"i18next-scanner": "^4.6.0",
|
|
86
86
|
"koa": "^2.15.3",
|
|
87
87
|
"koa-compress": "^5.1.1",
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"mime-types": "^2.1.35",
|
|
92
92
|
"ora": "^8.1.1",
|
|
93
93
|
"react": "^18.3.1",
|
|
94
|
-
"react-i18next": "^15.1.
|
|
95
|
-
"react-object-model": "^1.2.
|
|
94
|
+
"react-i18next": "^15.1.2",
|
|
95
|
+
"react-object-model": "^1.2.18",
|
|
96
96
|
"resolve-path": "^1.4.0",
|
|
97
97
|
"sass": "^1.81.0",
|
|
98
98
|
"sass-loader": "^16.0.3",
|
|
@@ -100,12 +100,12 @@
|
|
|
100
100
|
"strip-ansi": "^7.1.0",
|
|
101
101
|
"style-loader": "^4.0.0",
|
|
102
102
|
"through2": "^4.0.2",
|
|
103
|
-
"tough-cookie": "^5.0.0
|
|
103
|
+
"tough-cookie": "^5.0.0",
|
|
104
104
|
"ts-loader": "^9.5.1",
|
|
105
105
|
"tslib": "^2.8.1",
|
|
106
|
-
"typescript": "^5.
|
|
107
|
-
"ua-parser-js": "^2.0.0
|
|
108
|
-
"undici": "^
|
|
106
|
+
"typescript": "^5.7.2",
|
|
107
|
+
"ua-parser-js": "^2.0.0",
|
|
108
|
+
"undici": "^7.0.0-alpha.7",
|
|
109
109
|
"vinyl": "^3.0.0",
|
|
110
110
|
"vinyl-fs": "^4.0.0",
|
|
111
111
|
"webpack": "^5.96.1",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"@types/koa-compress": "^4.0.6",
|
|
127
127
|
"@types/lodash": "^4.17.13",
|
|
128
128
|
"@types/mime-types": "^2.1.4",
|
|
129
|
-
"@types/node": "^22.
|
|
129
|
+
"@types/node": "^22.10.0",
|
|
130
130
|
"@types/react": "^18.3.12",
|
|
131
131
|
"@types/through2": "^2.0.41",
|
|
132
132
|
"@types/tough-cookie": "^4.0.5",
|
package/process.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type ChildProcess } from 'child_process';
|
|
2
|
-
import './prototype.
|
|
3
|
-
import type { Encoding } from './file.
|
|
4
|
-
import type { MyProxy } from './net.
|
|
5
|
-
import { inspect } from './utils.
|
|
2
|
+
import './prototype.ts';
|
|
3
|
+
import type { Encoding } from './file.ts';
|
|
4
|
+
import type { MyProxy } from './net.ts';
|
|
5
|
+
import { inspect } from './utils.ts';
|
|
6
6
|
export declare const exe_nodejs: string;
|
|
7
7
|
export declare const platform: NodeJS.Platform;
|
|
8
8
|
export declare const username: string;
|
package/process.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
2
|
import os from 'os';
|
|
3
|
-
import { t } from
|
|
4
|
-
import
|
|
5
|
-
import { inspect, DecoderStream, filter_values, assert } from
|
|
3
|
+
import { t } from "./i18n/instance.js";
|
|
4
|
+
import "./prototype.js";
|
|
5
|
+
import { inspect, DecoderStream, filter_values, assert, check } from "./utils.js";
|
|
6
6
|
export const exe_nodejs = process.execPath.fp;
|
|
7
7
|
export const platform = os.platform();
|
|
8
8
|
export const username = os.userInfo().username;
|
|
@@ -26,23 +26,38 @@ export async function start(exe, args = [], options = {}) {
|
|
|
26
26
|
const { cwd, encoding = 'utf-8', detached = false, window: _window = true, envs, input, fp_stdin, fp_stdout, fp_stderr } = options;
|
|
27
27
|
let { print = true, stdio = detached ? 'ignore' : 'pipe', proxy } = options;
|
|
28
28
|
if (proxy === true) {
|
|
29
|
-
const { MyProxy } = await import(
|
|
29
|
+
const { MyProxy } = await import("./net.js");
|
|
30
30
|
proxy = MyProxy.socks5;
|
|
31
31
|
}
|
|
32
32
|
if (typeof stdio === 'string')
|
|
33
33
|
stdio = [stdio, stdio, stdio];
|
|
34
34
|
if (input)
|
|
35
35
|
assert(!fp_stdin, 'input 和 fp_stdin 不能同时设置');
|
|
36
|
+
let opened_handles = [];
|
|
37
|
+
async function close_all_handles() {
|
|
38
|
+
await Promise.all(opened_handles.map(async (handle) => handle.close()));
|
|
39
|
+
}
|
|
36
40
|
if (fp_stdin || fp_stdout || fp_stderr) {
|
|
37
|
-
const { fopen } = await import(
|
|
41
|
+
const { fopen } = await import("./file.js");
|
|
42
|
+
async function open(fp, flags) {
|
|
43
|
+
try {
|
|
44
|
+
const handle = await fopen(fp, flags);
|
|
45
|
+
opened_handles.push(handle);
|
|
46
|
+
return handle.fd;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
await close_all_handles();
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
38
53
|
if (fp_stdin)
|
|
39
|
-
stdio[0] =
|
|
54
|
+
stdio[0] = await open(fp_stdin, 'r');
|
|
40
55
|
if (fp_stdout)
|
|
41
|
-
stdio[1] =
|
|
56
|
+
stdio[1] = await open(fp_stdout, 'w');
|
|
42
57
|
if (fp_stderr)
|
|
43
58
|
stdio[2] = fp_stderr === fp_stdout
|
|
44
59
|
? stdio[1]
|
|
45
|
-
:
|
|
60
|
+
: await open(fp_stderr, 'w');
|
|
46
61
|
}
|
|
47
62
|
const options_ = {
|
|
48
63
|
cwd,
|
|
@@ -78,12 +93,26 @@ export async function start(exe, args = [], options = {}) {
|
|
|
78
93
|
:
|
|
79
94
|
'')).blue);
|
|
80
95
|
if (detached) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
96
|
+
check(stdio.every(x => x === 'ignore' || typeof x === 'number'), '调用 start({ detached: true }) 时 stdio 只能是 fd 或者 ignore');
|
|
97
|
+
try {
|
|
98
|
+
let child = spawn(exe, args, options_);
|
|
99
|
+
child.unref();
|
|
100
|
+
return child;
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
if (opened_handles.length)
|
|
104
|
+
await close_all_handles();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
let child;
|
|
108
|
+
try {
|
|
109
|
+
child = spawn(exe, args, options_);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
if (opened_handles.length)
|
|
113
|
+
await close_all_handles();
|
|
114
|
+
throw error;
|
|
85
115
|
}
|
|
86
|
-
let child = spawn(exe, args, options_);
|
|
87
116
|
// 防止 child spawn 失败时 crash nodejs 进程
|
|
88
117
|
child.on('error', error => {
|
|
89
118
|
console.error(error);
|
|
@@ -110,10 +139,12 @@ export async function start(exe, args = [], options = {}) {
|
|
|
110
139
|
}
|
|
111
140
|
if (input)
|
|
112
141
|
child.stdin.end(input);
|
|
142
|
+
if (opened_handles.length)
|
|
143
|
+
await close_all_handles();
|
|
113
144
|
return child;
|
|
114
145
|
}
|
|
115
146
|
export async function start_nodejs(js, args = [], options) {
|
|
116
|
-
return start(exe_nodejs, [js, ...args], options);
|
|
147
|
+
return start(exe_nodejs, ['--enable-source-maps', js, ...args], options);
|
|
117
148
|
}
|
|
118
149
|
export async function call(exe, args = [], options = {}) {
|
|
119
150
|
const { encoding = 'utf-8', throw_code = true, printers, on_child } = options;
|
package/prototype.browser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** 在浏览器端修改 prototype,需要更加小心 */
|
|
2
2
|
import byte_size from 'byte-size';
|
|
3
3
|
import EmojiRegex from 'emoji-regex';
|
|
4
|
-
import { t } from
|
|
4
|
+
import { t } from "./i18n/instance.js";
|
|
5
5
|
export const emoji_regex = EmojiRegex();
|
|
6
6
|
export function to_method_property_descriptors(methods) {
|
|
7
7
|
return Object.fromEntries(Object.entries(methods)
|
package/prototype.js
CHANGED
|
@@ -2,8 +2,8 @@ import byte_size from 'byte-size';
|
|
|
2
2
|
import EmojiRegex from 'emoji-regex';
|
|
3
3
|
import strip_ansi from 'strip-ansi';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
|
-
import { to_fp, dirname, basename, extname } from
|
|
6
|
-
import { t } from
|
|
5
|
+
import { to_fp, dirname, basename, extname } from "./path.js";
|
|
6
|
+
import { t } from "./i18n/instance.js";
|
|
7
7
|
chalk.level = 2;
|
|
8
8
|
export const emoji_regex = EmojiRegex();
|
|
9
9
|
export { chalk };
|
package/repl.d.ts
CHANGED
package/repl.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import repl from 'repl';
|
|
2
2
|
import process from 'process';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
|
-
import { path } from
|
|
5
|
-
import { t } from
|
|
6
|
-
import
|
|
7
|
-
import { delay, set_inspect_options } from
|
|
4
|
+
import { path } from "./path.js";
|
|
5
|
+
import { t } from "./i18n/instance.js";
|
|
6
|
+
import "./prototype.js";
|
|
7
|
+
import { delay, set_inspect_options } from "./utils.js";
|
|
8
8
|
set_inspect_options();
|
|
9
9
|
let server;
|
|
10
10
|
/** 谨慎使用,webpack 打包后可能会变成 /d:/1/mod/node_modules/xshell/ 这样的编译期路径 */
|
|
@@ -28,7 +28,7 @@ export async function start_repl() {
|
|
|
28
28
|
pollute_global(),
|
|
29
29
|
(async () => {
|
|
30
30
|
// --- http server
|
|
31
|
-
let { Server } = await import('./server.
|
|
31
|
+
let { Server } = await import('./server.ts');
|
|
32
32
|
server = new Server({
|
|
33
33
|
name: 'repl',
|
|
34
34
|
http: true,
|
package/server.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare module 'koa' {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
import type { UAParser } from 'ua-parser-js';
|
|
17
|
-
import { Remote, type RequestOptions, type RawResponse } from './net.
|
|
17
|
+
import { Remote, type RequestOptions, type RawResponse } from './net.ts';
|
|
18
18
|
declare module 'http' {
|
|
19
19
|
interface IncomingMessage {
|
|
20
20
|
body?: Buffer;
|
package/server.js
CHANGED
|
@@ -6,10 +6,10 @@ import fs from 'fs';
|
|
|
6
6
|
import { buffer as stream_to_buffer } from 'stream/consumers';
|
|
7
7
|
import util from 'util';
|
|
8
8
|
// --- my libs
|
|
9
|
-
import { t } from
|
|
10
|
-
import { request as _request, Remote } from
|
|
11
|
-
import { inspect, output_width, check, range_to_numbers, encode, filter_keys, filter_values, consume_stream, assert } from
|
|
12
|
-
import { flist, fread, fstat } from
|
|
9
|
+
import { t } from "./i18n/instance.js";
|
|
10
|
+
import { request as _request, Remote } from "./net.js";
|
|
11
|
+
import { inspect, output_width, check, range_to_numbers, encode, filter_keys, filter_values, consume_stream, assert } from "./utils.js";
|
|
12
|
+
import { flist, fread, fstat } from "./file.js";
|
|
13
13
|
// ------------ my server
|
|
14
14
|
export class Server {
|
|
15
15
|
/** proxy 时需要丢弃的 resposne headers */
|
package/toaster.browser.js
CHANGED
package/tsconfig.json
CHANGED
|
@@ -22,11 +22,12 @@
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
// --- emit
|
|
25
|
-
"noEmit":
|
|
25
|
+
"noEmit": false,
|
|
26
26
|
"declaration": true,
|
|
27
27
|
"emitDeclarationOnly": false,
|
|
28
28
|
"noEmitOnError": false,
|
|
29
29
|
"listEmittedFiles": true,
|
|
30
|
+
"rewriteRelativeImportExtensions": true,
|
|
30
31
|
|
|
31
32
|
// --- source maps
|
|
32
33
|
"sourceMap": true,
|
package/utils.browser.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export declare class Lock<TResource = void> {
|
|
|
76
76
|
}
|
|
77
77
|
export declare function pause(milliseconds?: number): Promise<void>;
|
|
78
78
|
/** 将字符串简单的编码为 utf-8 的 buffer (Uint8Array)。高频使用或者在流式处理时,考虑使用 TextEncoder 的 encodeInto 方法 */
|
|
79
|
-
export declare function encode(str: string): Uint8Array
|
|
79
|
+
export declare function encode(str: string): Uint8Array<ArrayBufferLike>;
|
|
80
80
|
/** 将 utf-8 buffer (Uint8Array) 简单的解码为 string。
|
|
81
81
|
在流式处理 (buffer 可能不完整) 时,应使用独立的 TextDecoder 实例调用 decode(buffer, { stream: true }) */
|
|
82
82
|
export declare function decode(buffer: Uint8Array): string;
|
|
@@ -90,7 +90,7 @@ export declare function get<TReturn = any>(obj: any, keypath: string): TReturn;
|
|
|
90
90
|
export declare function global_get<TReturn = any>(keypath: string): TReturn;
|
|
91
91
|
export declare function invoke<TReturn = any>(obj: any, funcpath: string, args: any[]): TReturn;
|
|
92
92
|
/** 拼接 TypedArrays 生成一个完整的 Uint8Array */
|
|
93
|
-
export declare function concat(arrays: ArrayBufferView[]): Uint8Array
|
|
93
|
+
export declare function concat(arrays: ArrayBufferView[]): Uint8Array<ArrayBuffer>;
|
|
94
94
|
/** 时间间隔 (milliseconds) 格式化 */
|
|
95
95
|
export declare function delta2str(delta: number): string;
|
|
96
96
|
/** generate random id */
|
package/utils.browser.js
CHANGED
package/utils.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Writable, Transform, type Readable, type Duplex, type TransformCallback
|
|
|
2
2
|
import util from 'util';
|
|
3
3
|
import type { TimerOptions } from 'timers';
|
|
4
4
|
import type Vinyl from 'vinyl';
|
|
5
|
-
import './prototype.
|
|
5
|
+
import './prototype.ts';
|
|
6
6
|
export declare const noop: () => void;
|
|
7
7
|
/** value 不为 null 或 undefined */
|
|
8
8
|
export declare const not_empty: (value: any) => boolean;
|
|
@@ -53,8 +53,8 @@ export declare function get<TReturn = any>(obj: any, keypath: string): TReturn;
|
|
|
53
53
|
export declare function global_get<TReturn = any>(keypath: string): TReturn;
|
|
54
54
|
export declare function invoke<TReturn = any>(obj: any, funcpath: string, args: any[]): TReturn;
|
|
55
55
|
/** 拼接 TypedArrays 生成一个完整的 Uint8Array */
|
|
56
|
-
export declare function concat(arrays: ArrayBufferView[]): Uint8Array
|
|
57
|
-
export declare function typed_array_to_buffer(view: ArrayBufferView): Buffer
|
|
56
|
+
export declare function concat(arrays: ArrayBufferView[]): Uint8Array<ArrayBuffer>;
|
|
57
|
+
export declare function typed_array_to_buffer(view: ArrayBufferView): Buffer<ArrayBufferLike>;
|
|
58
58
|
/** 时间间隔 (milliseconds) 格式化 */
|
|
59
59
|
export declare function delta2str(delta: number): string;
|
|
60
60
|
/** generate random id */
|
|
@@ -136,7 +136,7 @@ export declare class Lock<TResource = void> {
|
|
|
136
136
|
request<TResult>(action: LockedAction<TResource, TResult>, signal?: AbortSignal): Promise<TResult>;
|
|
137
137
|
}
|
|
138
138
|
/** 将字符串简单的编码为 utf-8 的 buffer (Uint8Array)。高频使用或者在流式处理时,考虑使用 TextEncoder 的 encodeInto 方法 */
|
|
139
|
-
export declare function encode(str: string): Uint8Array
|
|
139
|
+
export declare function encode(str: string): Uint8Array<ArrayBufferLike>;
|
|
140
140
|
/** 将 utf-8 buffer (Uint8Array) 简单的解码为 string。
|
|
141
141
|
在流式处理 (buffer 可能不完整) 时,应使用独立的 TextDecoder 实例调用 decode(buffer, { stream: true }) */
|
|
142
142
|
export declare function decode(buffer: Uint8Array): string;
|
|
@@ -171,7 +171,7 @@ export declare function stream_to_lines(stream: Readable): AsyncGenerator<string
|
|
|
171
171
|
export declare function pipe_with_error<TWritable extends Writable>(readable: Readable, writable: TWritable): TWritable;
|
|
172
172
|
export declare class WritableMemoryStream extends Writable {
|
|
173
173
|
chunks: Buffer[];
|
|
174
|
-
pbuffer: Deferred<Buffer
|
|
174
|
+
pbuffer: Deferred<Buffer<ArrayBufferLike>>;
|
|
175
175
|
constructor();
|
|
176
176
|
_write(chunk: Buffer, encoding: BufferEncoding, callback: (error?: Error) => void): void;
|
|
177
177
|
_writev(chunks: {
|
package/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Stream, Writable, Transform } from 'stream';
|
|
2
2
|
import util from 'util';
|
|
3
3
|
import timers from 'timers/promises';
|
|
4
|
-
import { t } from
|
|
5
|
-
import
|
|
4
|
+
import { t } from "./i18n/instance.js";
|
|
5
|
+
import "./prototype.js";
|
|
6
6
|
export const noop = () => { };
|
|
7
7
|
/** value 不为 null 或 undefined */
|
|
8
8
|
export const not_empty = (value) => value !== null && value !== undefined;
|
package/xshell.js
CHANGED