xshell 1.0.183 → 1.0.184
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 -4
- package/file.js +1 -1
- package/package.json +4 -4
- package/path.d.ts +2 -2
- package/process.d.ts +17 -4
- package/process.js +31 -16
- package/utils.browser.d.ts +1 -1
- package/utils.d.ts +1 -1
package/file.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { promises as fsp, default as fs } from 'fs';
|
|
2
|
-
type FileHandle = fsp.FileHandle & {
|
|
3
|
-
fp: string;
|
|
4
|
-
};
|
|
5
2
|
export { fsp };
|
|
6
3
|
export type Encoding = 'utf-8' | 'gb18030' | 'shift-jis' | 'utf-16le';
|
|
4
|
+
export type FileHandle = fsp.FileHandle & {
|
|
5
|
+
fp: string;
|
|
6
|
+
};
|
|
7
7
|
export declare const encodings: readonly ["utf-8", "gb18030", "shift-jis", "utf-16le"];
|
|
8
8
|
export declare const ramdisk: boolean;
|
|
9
9
|
/** fp 所指向的 文件/ 文件夹 是否存在
|
|
@@ -17,7 +17,7 @@ export declare function fexists(fp: string, { print }?: {
|
|
|
17
17
|
by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains
|
|
18
18
|
a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams).
|
|
19
19
|
|
|
20
|
-
- flags: `'r'`
|
|
20
|
+
- flags: `'r'` https://nodejs.org/docs/latest/api/fs.html#file-system-flags
|
|
21
21
|
- options?:
|
|
22
22
|
- mode?: `'0o666'` Sets the file mode (permission and sticky bits) if the file is created. */
|
|
23
23
|
export declare function fopen(fp: string, flags?: string | number, { mode, print }?: {
|
package/file.js
CHANGED
|
@@ -21,7 +21,7 @@ export function fexists(fp, { print = true } = {}) {
|
|
|
21
21
|
by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains
|
|
22
22
|
a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams).
|
|
23
23
|
|
|
24
|
-
- flags: `'r'`
|
|
24
|
+
- flags: `'r'` https://nodejs.org/docs/latest/api/fs.html#file-system-flags
|
|
25
25
|
- options?:
|
|
26
26
|
- mode?: `'0o666'` Sets the file mode (permission and sticky bits) if the file is created. */
|
|
27
27
|
export async function fopen(fp, flags = 'r', { mode, print } = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xshell",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.184",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"react-i18next": "^15.0.3",
|
|
95
95
|
"react-object-model": "^1.2.13",
|
|
96
96
|
"resolve-path": "^1.4.0",
|
|
97
|
-
"sass": "^1.
|
|
97
|
+
"sass": "^1.80.1",
|
|
98
98
|
"sass-loader": "^16.0.2",
|
|
99
99
|
"source-map-loader": "^5.0.0",
|
|
100
100
|
"strip-ansi": "^7.1.0",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"through2": "^4.0.2",
|
|
103
103
|
"tough-cookie": "^5.0.0-rc.4",
|
|
104
104
|
"ts-loader": "^9.5.1",
|
|
105
|
-
"tslib": "^2.
|
|
105
|
+
"tslib": "^2.8.0",
|
|
106
106
|
"typescript": "^5.6.3",
|
|
107
107
|
"ua-parser-js": "^2.0.0-beta.3",
|
|
108
108
|
"undici": "^6.20.1",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"@types/koa-compress": "^4.0.6",
|
|
127
127
|
"@types/lodash": "^4.17.10",
|
|
128
128
|
"@types/mime-types": "^2.1.4",
|
|
129
|
-
"@types/node": "^22.7.
|
|
129
|
+
"@types/node": "^22.7.6",
|
|
130
130
|
"@types/react": "^18.3.11",
|
|
131
131
|
"@types/through2": "^2.0.41",
|
|
132
132
|
"@types/tough-cookie": "^4.0.5",
|
package/path.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export declare function extname(path: string): string;
|
|
|
55
55
|
/** `/` */
|
|
56
56
|
export declare const sep = "/";
|
|
57
57
|
/** The platform-specific file delimiter. ';' or ':'. */
|
|
58
|
-
export declare const delimiter: "
|
|
58
|
+
export declare const delimiter: ";" | ":";
|
|
59
59
|
/** Returns an object from a path string - the opposite of format().
|
|
60
60
|
@param path path to evaluate.
|
|
61
61
|
@throws {TypeError} if `path` is not a string. */
|
|
@@ -83,7 +83,7 @@ export declare let path: {
|
|
|
83
83
|
basename: typeof basename;
|
|
84
84
|
extname: typeof extname;
|
|
85
85
|
sep: string;
|
|
86
|
-
delimiter: "
|
|
86
|
+
delimiter: ";" | ":";
|
|
87
87
|
parse: typeof parse;
|
|
88
88
|
format: typeof format;
|
|
89
89
|
toNamespacedPath: typeof toNamespacedPath;
|
package/process.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ChildProcess } from 'child_process';
|
|
2
2
|
import './prototype.js';
|
|
3
|
-
import { Encoding } from './file.js';
|
|
3
|
+
import type { Encoding } from './file.js';
|
|
4
4
|
import type { MyProxy } from './net.js';
|
|
5
5
|
import { inspect } from './utils.js';
|
|
6
6
|
export declare const exe_nodejs: string;
|
|
@@ -17,6 +17,7 @@ export declare const print_no_command: {
|
|
|
17
17
|
readonly stderr: true;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
+
type StdioType = 'pipe' | 'ignore' | 'inherit' | number;
|
|
20
21
|
interface StartOptions {
|
|
21
22
|
/** `继承当前工作目录 process.cwd()` 子进程的工作目录 `inherit the cwd` cwd of the child process. */
|
|
22
23
|
cwd?: string;
|
|
@@ -34,8 +35,16 @@ interface StartOptions {
|
|
|
34
35
|
/** 进程执行成功的消息 */
|
|
35
36
|
code: boolean;
|
|
36
37
|
};
|
|
37
|
-
/** `'pipe'` 设置为 'ignore' 时忽略 stdio 处理
|
|
38
|
-
stdio?: 'pipe' | 'ignore' | [
|
|
38
|
+
/** `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 */
|
|
39
|
+
stdio?: 'pipe' | 'ignore' | [StdioType, StdioType, StdioType];
|
|
40
|
+
/** 启动子进程之后写入到子进程 stdin 中的内容,写完后关闭子进程 stdin (pty 不关闭) */
|
|
41
|
+
input?: string;
|
|
42
|
+
/** 使用文件作为标准输入 */
|
|
43
|
+
fp_stdin?: string;
|
|
44
|
+
/** 使用文件作为标准输出 */
|
|
45
|
+
fp_stdout?: string;
|
|
46
|
+
/** 使用文件作为标准错误 */
|
|
47
|
+
fp_stderr?: string;
|
|
39
48
|
/** `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref) */
|
|
40
49
|
detached?: boolean;
|
|
41
50
|
/** 为 true 时会设置 UV_PROCESS_WINDOWS_HIDE
|
|
@@ -59,8 +68,12 @@ interface StartOptions {
|
|
|
59
68
|
- encoding?: `'utf-8'` 子进程输出编码 child output encoding
|
|
60
69
|
- print?: `true` print 选项,支持设置细项 print option (with details)
|
|
61
70
|
- stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing
|
|
71
|
+
- input?: string, 启动子进程之后写入到子进程 stdin 中的内容,写完后关闭子进程 stdin (pty 不关闭)
|
|
72
|
+
- fp_stdin?: 使用文件作为标准输入,设置 stdio 中选项为对应的值
|
|
73
|
+
- fp_stdout?: 使用文件作为标准输出,设置 stdio 中选项为对应的值
|
|
74
|
+
- fp_stderr?: 使用文件作为标准错误,设置 stdio 中选项为对应的值
|
|
62
75
|
- detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref) */
|
|
63
|
-
export declare function start(exe: string, args?: string[],
|
|
76
|
+
export declare function start(exe: string, args?: string[], options?: StartOptions): Promise<ChildProcess>;
|
|
64
77
|
export declare function start_nodejs(js: string, args?: string[], options?: StartOptions): Promise<ChildProcess>;
|
|
65
78
|
export interface CallOptions extends StartOptions {
|
|
66
79
|
throw_code?: boolean;
|
package/process.js
CHANGED
|
@@ -2,7 +2,7 @@ import { spawn } from 'child_process';
|
|
|
2
2
|
import os from 'os';
|
|
3
3
|
import { t } from './i18n/instance.js';
|
|
4
4
|
import './prototype.js';
|
|
5
|
-
import { inspect, DecoderStream, filter_values } from './utils.js';
|
|
5
|
+
import { inspect, DecoderStream, filter_values, assert } 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;
|
|
@@ -17,16 +17,38 @@ export const print_no_command = { print: { command: false, code: false, stdout:
|
|
|
17
17
|
- encoding?: `'utf-8'` 子进程输出编码 child output encoding
|
|
18
18
|
- print?: `true` print 选项,支持设置细项 print option (with details)
|
|
19
19
|
- stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing
|
|
20
|
+
- input?: string, 启动子进程之后写入到子进程 stdin 中的内容,写完后关闭子进程 stdin (pty 不关闭)
|
|
21
|
+
- fp_stdin?: 使用文件作为标准输入,设置 stdio 中选项为对应的值
|
|
22
|
+
- fp_stdout?: 使用文件作为标准输出,设置 stdio 中选项为对应的值
|
|
23
|
+
- fp_stderr?: 使用文件作为标准错误,设置 stdio 中选项为对应的值
|
|
20
24
|
- detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref) */
|
|
21
|
-
export async function start(exe, args = [],
|
|
25
|
+
export async function start(exe, args = [], options = {}) {
|
|
26
|
+
const { cwd, encoding = 'utf-8', detached = false, window: _window = true, envs, input, fp_stdin, fp_stdout, fp_stderr } = options;
|
|
27
|
+
let { print = true, stdio = detached ? 'ignore' : 'pipe', proxy } = options;
|
|
22
28
|
if (proxy === true) {
|
|
23
29
|
const { MyProxy } = await import('./net.js');
|
|
24
30
|
proxy = MyProxy.socks5;
|
|
25
31
|
}
|
|
26
|
-
|
|
32
|
+
if (typeof stdio === 'string')
|
|
33
|
+
stdio = [stdio, stdio, stdio];
|
|
34
|
+
if (input)
|
|
35
|
+
assert(!fp_stdin, 'input 和 fp_stdin 不能同时设置');
|
|
36
|
+
if (fp_stdin || fp_stdout || fp_stderr) {
|
|
37
|
+
const { fopen } = await import('./file.js');
|
|
38
|
+
if (fp_stdin)
|
|
39
|
+
stdio[0] = (await fopen(fp_stdin, 'r')).fd;
|
|
40
|
+
if (fp_stdout)
|
|
41
|
+
stdio[1] = (await fopen(fp_stdout, 'w')).fd;
|
|
42
|
+
if (fp_stderr)
|
|
43
|
+
stdio[2] = fp_stderr === fp_stdout
|
|
44
|
+
? stdio[1]
|
|
45
|
+
: (await fopen(fp_stderr, 'w')).fd;
|
|
46
|
+
}
|
|
47
|
+
const options_ = {
|
|
27
48
|
cwd,
|
|
28
49
|
shell: false,
|
|
29
50
|
windowsHide: !_window,
|
|
51
|
+
detached,
|
|
30
52
|
stdio,
|
|
31
53
|
...envs || proxy ? {
|
|
32
54
|
env: filter_values({
|
|
@@ -47,8 +69,6 @@ export async function start(exe, args = [], { cwd, encoding = 'utf-8', print = t
|
|
|
47
69
|
command: print,
|
|
48
70
|
code: print,
|
|
49
71
|
};
|
|
50
|
-
if (typeof stdio === 'string')
|
|
51
|
-
stdio = [stdio, stdio, stdio];
|
|
52
72
|
if (print.command)
|
|
53
73
|
console.log(((short_exe_names[exe] || exe.quote_if_space()) +
|
|
54
74
|
(args.length ?
|
|
@@ -58,23 +78,18 @@ export async function start(exe, args = [], { cwd, encoding = 'utf-8', print = t
|
|
|
58
78
|
:
|
|
59
79
|
'')).blue);
|
|
60
80
|
if (detached) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
stdio: 'ignore',
|
|
64
|
-
detached: true,
|
|
65
|
-
});
|
|
81
|
+
assert(stdio.every(x => x === 'ignore' || typeof x === 'number'), '调用 start({ detached: true }) 时 stdio 只能是 fd 或者 ignore');
|
|
82
|
+
let child = spawn(exe, args, options_);
|
|
66
83
|
child.unref();
|
|
67
84
|
return child;
|
|
68
85
|
}
|
|
69
|
-
let child = spawn(exe, args,
|
|
86
|
+
let child = spawn(exe, args, options_);
|
|
70
87
|
// 防止 child spawn 失败时 crash nodejs 进程
|
|
71
88
|
child.on('error', error => {
|
|
72
89
|
console.error(error);
|
|
73
90
|
});
|
|
74
91
|
if (stdio[0] === 'pipe')
|
|
75
92
|
child.stdin.setDefaultEncoding('utf8');
|
|
76
|
-
if (stdio.every(s => s === 'ignore'))
|
|
77
|
-
return child;
|
|
78
93
|
if (encoding !== 'binary') {
|
|
79
94
|
if (stdio[1] === 'pipe') {
|
|
80
95
|
if (encoding === 'utf-8')
|
|
@@ -93,13 +108,15 @@ export async function start(exe, args = [], { cwd, encoding = 'utf-8', print = t
|
|
|
93
108
|
child.stderr.pipe(process.stderr, { end: false });
|
|
94
109
|
}
|
|
95
110
|
}
|
|
111
|
+
if (input)
|
|
112
|
+
child.stdin.end(input);
|
|
96
113
|
return child;
|
|
97
114
|
}
|
|
98
115
|
export async function start_nodejs(js, args = [], options) {
|
|
99
116
|
return start(exe_nodejs, [js, ...args], options);
|
|
100
117
|
}
|
|
101
118
|
export async function call(exe, args = [], options = {}) {
|
|
102
|
-
const { encoding = 'utf-8', throw_code = true,
|
|
119
|
+
const { encoding = 'utf-8', throw_code = true, printers } = options;
|
|
103
120
|
let { stdio = 'pipe', print = true } = options;
|
|
104
121
|
if (typeof print === 'boolean')
|
|
105
122
|
print = {
|
|
@@ -121,8 +138,6 @@ export async function call(exe, args = [], options = {}) {
|
|
|
121
138
|
...options,
|
|
122
139
|
print: false,
|
|
123
140
|
});
|
|
124
|
-
if (input)
|
|
125
|
-
child.stdin.end(input);
|
|
126
141
|
// --- collect output
|
|
127
142
|
let stdouts = [];
|
|
128
143
|
let stderrs = [];
|
package/utils.browser.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ export declare function encode(str: string): Uint8Array;
|
|
|
75
75
|
在流式处理 (buffer 可能不完整) 时,应使用独立的 TextDecoder 实例调用 decode(buffer, { stream: true }) */
|
|
76
76
|
export declare function decode(buffer: Uint8Array): string;
|
|
77
77
|
/** 字符串字典序比较 */
|
|
78
|
-
export declare function strcmp(l: string, r: string):
|
|
78
|
+
export declare function strcmp(l: string, r: string): 1 | 0 | -1;
|
|
79
79
|
/** 比较 1.10.02 这种版本号
|
|
80
80
|
- l, r: 两个版本号字符串
|
|
81
81
|
- loose?: 宽松模式,允许两个版本号格式(位数)不一致 */
|
package/utils.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export declare function filter_values<TObj extends Record<string, any>>(obj: TOb
|
|
|
42
42
|
/** 忽略对象中的 keys, 返回新对象 */
|
|
43
43
|
export declare function omit<TObj>(obj: TObj, omit_keys: string[]): TObj;
|
|
44
44
|
/** 字符串字典序比较 */
|
|
45
|
-
export declare function strcmp(l: string, r: string):
|
|
45
|
+
export declare function strcmp(l: string, r: string): 1 | 0 | -1;
|
|
46
46
|
/** 比较 1.10.02 这种版本号
|
|
47
47
|
- l, r: 两个版本号字符串
|
|
48
48
|
- loose?: 宽松模式,允许两个版本号格式(位数)不一致 */
|