xshell 0.0.65 → 0.0.67
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 +36 -33
- package/file.js +76 -72
- package/file.js.map +1 -1
- package/i18n/README.md +5 -5
- package/i18n/dict.json +188 -0
- package/i18n/index.d.ts +1 -1
- package/i18n/index.js +14 -18
- package/i18n/index.js.map +1 -1
- package/i18n/instance.d.ts +9 -0
- package/i18n/instance.js +6 -0
- package/i18n/instance.js.map +1 -0
- package/i18n/scanner/parser.js +1 -1
- package/i18n/scanner/parser.js.map +1 -1
- package/net.browser.d.ts +1 -0
- package/net.browser.js +8 -6
- package/net.browser.js.map +1 -1
- package/net.d.ts +8 -8
- package/net.js +12 -12
- package/net.js.map +1 -1
- package/package.json +1 -1
- package/process.d.ts +63 -29
- package/process.js +63 -16
- package/process.js.map +1 -1
- package/prototype.browser.js +9 -8
- package/prototype.browser.js.map +1 -1
- package/prototype.js +9 -8
- package/prototype.js.map +1 -1
- package/repl.js +9 -8
- package/repl.js.map +1 -1
- package/utils.browser.d.ts +1 -1
- package/utils.browser.js +2 -1
- package/utils.browser.js.map +1 -1
- package/utils.d.ts +1 -1
- package/utils.js +2 -1
- package/utils.js.map +1 -1
package/process.d.ts
CHANGED
|
@@ -10,20 +10,20 @@ export declare const exe_node: string;
|
|
|
10
10
|
interface StartOptions {
|
|
11
11
|
/** `'d:/'` */
|
|
12
12
|
cwd?: string;
|
|
13
|
-
/** `process.env` overwrite/add to process.env */
|
|
13
|
+
/** `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env */
|
|
14
14
|
env?: Record<string, string>;
|
|
15
|
-
/** `'utf-8'` child output encoding */
|
|
15
|
+
/** `'utf-8'` 子进程输出编码 child output encoding */
|
|
16
16
|
encoding?: Encoding;
|
|
17
|
-
/** `true` print option (with details) */
|
|
17
|
+
/** `true` print 选项,支持设置细项 print option (with details) */
|
|
18
18
|
print?: boolean | {
|
|
19
19
|
stdout: boolean;
|
|
20
20
|
stderr: boolean;
|
|
21
21
|
command: boolean;
|
|
22
22
|
code: boolean;
|
|
23
23
|
};
|
|
24
|
-
/** `'pipe'` when 'ignore' then ignore stdio processing */
|
|
24
|
+
/** `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing */
|
|
25
25
|
stdio?: 'pipe' | 'ignore' | ['pipe' | 'ignore' | 'inherit', 'pipe' | 'ignore' | 'inherit', 'pipe' | 'ignore' | 'inherit'];
|
|
26
|
-
/** `false` whether to break the connection with child (ignore stdio, unref) */
|
|
26
|
+
/** `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref) */
|
|
27
27
|
detached?: boolean;
|
|
28
28
|
/** 为 true 时会设置 UV_PROCESS_WINDOWS_HIDE
|
|
29
29
|
然后设置启动进程的参数 CREATE_NO_WINDOW, 和 SW_HIDE
|
|
@@ -39,15 +39,15 @@ interface StartOptions {
|
|
|
39
39
|
window?: boolean;
|
|
40
40
|
}
|
|
41
41
|
/** start process
|
|
42
|
-
- exe: .exe path or filename (full path is recommanded to skip path searching for better perf)
|
|
43
|
-
- args: `[]` arguments list
|
|
42
|
+
- exe: .exe 路径或文件名 (建议使用完整路径,跳过 path 搜索,性能更高) path or filename (full path is recommanded to skip path searching for better perf)
|
|
43
|
+
- args: `[]` 参数列表 arguments list
|
|
44
44
|
- options
|
|
45
45
|
- cwd?: `fp_root`
|
|
46
|
-
- env?: `process.env` overwrite/add to process.env
|
|
47
|
-
- encoding?: `'utf-8'` child output encoding
|
|
48
|
-
- print?: `true` print option (with details)
|
|
49
|
-
- stdio?: `'pipe'` when 'ignore' then ignore stdio processing
|
|
50
|
-
- detached?: `false` whether to break the connection with child (ignore stdio, unref)
|
|
46
|
+
- env?: `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env
|
|
47
|
+
- encoding?: `'utf-8'` 子进程输出编码 child output encoding
|
|
48
|
+
- print?: `true` print 选项,支持设置细项 print option (with details)
|
|
49
|
+
- stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing
|
|
50
|
+
- detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref)
|
|
51
51
|
*/
|
|
52
52
|
export declare function start(exe: string, args?: string[], { cwd, encoding, print, stdio, detached, env, window: _window, }?: StartOptions): Promise<ChildProcess>;
|
|
53
53
|
export interface CallOptions extends StartOptions {
|
|
@@ -64,17 +64,17 @@ export interface CallResult<T = string> {
|
|
|
64
64
|
[inspect.custom](): string;
|
|
65
65
|
}
|
|
66
66
|
/** call process for result
|
|
67
|
-
- exe: .exe path or filename (full path is recommanded to skip path searching for better perf)
|
|
68
|
-
- args: `[]` arguments list
|
|
67
|
+
- exe: .exe 路径或文件名 (建议使用路径,跳过 path 搜索,性能更高) path or filename (full path is recommanded to skip path searching for better perf)
|
|
68
|
+
- args: `[]` 参数列表 arguments list
|
|
69
69
|
- options?:
|
|
70
70
|
- cwd?: `'d:/'`
|
|
71
|
-
- env?: `process.env` overwrite/add to process.env
|
|
72
|
-
- encoding?: `'utf-8'` child output encoding
|
|
73
|
-
- print?: `true` print option (with details)
|
|
74
|
-
- stdio?: `'pipe'` when 'ignore' then ignore stdio processing
|
|
75
|
-
- input?: string
|
|
76
|
-
- detached?: `false` whether to break the connection with child (ignore stdio, unref)
|
|
77
|
-
- throw_code?: `true` whether to throw Error when code is not 0
|
|
71
|
+
- env?: `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env
|
|
72
|
+
- encoding?: `'utf-8'` 子进程输出编码 child output encoding
|
|
73
|
+
- print?: `true` print 选项,支持设置细项 print option (with details)
|
|
74
|
+
- stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing
|
|
75
|
+
- input?: string, start 子进程之后写入到子进程 stdin 中的内容 After starting the sub-process, write to the content of the sub-process STDIN
|
|
76
|
+
- detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref)
|
|
77
|
+
- throw_code?: `true` code 不为 0 时是否抛出异常 whether to throw Error when code is not 0
|
|
78
78
|
*/
|
|
79
79
|
export declare function call(exe: string, args?: string[]): Promise<CallResult<string>>;
|
|
80
80
|
export declare function call(exe: string, args?: string[], options?: CallOptions & {
|
|
@@ -84,18 +84,52 @@ export declare function call(exe: string, args?: string[], options?: CallOptions
|
|
|
84
84
|
encoding: 'binary';
|
|
85
85
|
}): Promise<CallResult<Buffer>>;
|
|
86
86
|
/** call node <js> for result
|
|
87
|
-
- js: .js path (relative path will resolve based on cwd)
|
|
88
|
-
- args: `[]` arguments list
|
|
87
|
+
- js: .js 路径 (相对路径根据 cwd 解析) path (relative path will resolve based on cwd)
|
|
88
|
+
- args: `[]` 参数列表 arguments list
|
|
89
89
|
- options
|
|
90
90
|
- cwd?: `'d:/'`
|
|
91
|
-
- env?: `process.env` overwrite/add to process.env
|
|
92
|
-
- encoding?: `'utf-8'` child process output encoding
|
|
93
|
-
- print?: `true` print option (with details)
|
|
94
|
-
- stdio?: `'pipe'` when 'ignore' then ignore stdio processing
|
|
95
|
-
- detached?: `false` whether to break the connection with child (ignore stdio, unref)
|
|
96
|
-
- throw_code?: `true` whether to throw Error when code is not 0
|
|
91
|
+
- env?: `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env
|
|
92
|
+
- encoding?: `'utf-8'` 子进程输出编码 child process output encoding
|
|
93
|
+
- print?: `true` print 选项,支持设置细项 print option (with details)
|
|
94
|
+
- stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing
|
|
95
|
+
- detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref)
|
|
96
|
+
- throw_code?: `true` code 不为 0 时是否抛出异常 whether to throw Error when code is not 0
|
|
97
97
|
*/
|
|
98
98
|
export declare function call_node(js: string, args?: string[], options?: CallOptions & {
|
|
99
99
|
encoding?: 'utf-8' | 'gb18030';
|
|
100
100
|
}): Promise<CallResult<string>>;
|
|
101
|
+
interface TermOptions {
|
|
102
|
+
/** `d:/` */
|
|
103
|
+
cwd?: string;
|
|
104
|
+
/** `false` 打印参数 print parameter */
|
|
105
|
+
print?: boolean;
|
|
106
|
+
title?: string;
|
|
107
|
+
/** (暂不支持,传入时忽略该选项) `false` 在 WinTerm 中后台创建标签页,而非创建并切换到该标签页
|
|
108
|
+
(No support for the time being, ignore the option when passing in) `False` Create a tab in the background in Winterm instead of creating and switching to the tab */
|
|
109
|
+
background?: boolean;
|
|
110
|
+
/** (暂不支持,传入时忽略该选项)
|
|
111
|
+
(No support for the time being, ignore this option when passing in) */
|
|
112
|
+
icon?: string;
|
|
113
|
+
}
|
|
114
|
+
export declare const exe_winterm: string;
|
|
115
|
+
/** 新建 terminal 窗口执行进程 New Terminal window execution process
|
|
116
|
+
- exe: exe 文件路径 exe file path
|
|
117
|
+
- args: 调用参数 call parameter
|
|
118
|
+
- options?: WinTermOptions
|
|
119
|
+
*/
|
|
120
|
+
export declare function term(exe: string, args?: string[], { cwd, print, title, }?: TermOptions): Promise<ChildProcess>;
|
|
121
|
+
export interface TermNodeOptions extends TermOptions {
|
|
122
|
+
/** nodejs debugger port */
|
|
123
|
+
inspect?: number;
|
|
124
|
+
/** break at first line */
|
|
125
|
+
break?: boolean;
|
|
126
|
+
/** 使用 ts-node 直接运行 use ts-node to run directly */
|
|
127
|
+
tsnode?: boolean;
|
|
128
|
+
/** `false` --experimental-specifier-resolution=node */
|
|
129
|
+
resolve?: boolean;
|
|
130
|
+
/** `false` --trace-warnings */
|
|
131
|
+
trace_warnings?: boolean;
|
|
132
|
+
}
|
|
133
|
+
/** 在 term tab 中创建 node.exe 进程 create the node.exe process in term tab */
|
|
134
|
+
export declare function term_node(fp_js: string, args?: string[], { title, inspect, tsnode, break: _break, resolve, trace_warnings, ..._options }?: TermNodeOptions): Promise<ChildProcess>;
|
|
101
135
|
export {};
|
package/process.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
|
+
import { userInfo } from 'os';
|
|
3
4
|
import iconv from 'iconv-lite';
|
|
4
5
|
import path from 'upath';
|
|
5
6
|
import './prototype.js';
|
|
@@ -7,15 +8,15 @@ import { inspect } from './utils.js';
|
|
|
7
8
|
export const fpd_root = `${path.dirname(fileURLToPath(import.meta.url))}/`;
|
|
8
9
|
export const exe_node = process.execPath.to_slash();
|
|
9
10
|
/** start process
|
|
10
|
-
- exe: .exe path or filename (full path is recommanded to skip path searching for better perf)
|
|
11
|
-
- args: `[]` arguments list
|
|
11
|
+
- exe: .exe 路径或文件名 (建议使用完整路径,跳过 path 搜索,性能更高) path or filename (full path is recommanded to skip path searching for better perf)
|
|
12
|
+
- args: `[]` 参数列表 arguments list
|
|
12
13
|
- options
|
|
13
14
|
- cwd?: `fp_root`
|
|
14
|
-
- env?: `process.env` overwrite/add to process.env
|
|
15
|
-
- encoding?: `'utf-8'` child output encoding
|
|
16
|
-
- print?: `true` print option (with details)
|
|
17
|
-
- stdio?: `'pipe'` when 'ignore' then ignore stdio processing
|
|
18
|
-
- detached?: `false` whether to break the connection with child (ignore stdio, unref)
|
|
15
|
+
- env?: `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env
|
|
16
|
+
- encoding?: `'utf-8'` 子进程输出编码 child output encoding
|
|
17
|
+
- print?: `true` print 选项,支持设置细项 print option (with details)
|
|
18
|
+
- stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing
|
|
19
|
+
- detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref)
|
|
19
20
|
*/
|
|
20
21
|
export async function start(exe, args = [], { cwd = fpd_root, encoding = 'utf-8', print = true, stdio = 'pipe', detached = false, env, window: _window = true, } = {}) {
|
|
21
22
|
const options = {
|
|
@@ -37,7 +38,11 @@ export async function start(exe, args = [], { cwd = fpd_root, encoding = 'utf-8'
|
|
|
37
38
|
if (typeof stdio === 'string')
|
|
38
39
|
stdio = [stdio, stdio, stdio];
|
|
39
40
|
if (print.command)
|
|
40
|
-
console.log(
|
|
41
|
+
console.log(((exe === exe_winterm ? 'term.exe' : exe) + ' ' +
|
|
42
|
+
(args.filter(arg => arg !== '--suppressApplicationTitle').map(arg => arg.includes(' ') ?
|
|
43
|
+
arg.quote()
|
|
44
|
+
:
|
|
45
|
+
arg).join(' '))).blue);
|
|
41
46
|
if (detached) {
|
|
42
47
|
let child = spawn(exe, args, {
|
|
43
48
|
...options,
|
|
@@ -154,18 +159,60 @@ export async function call(exe, args = [], options = {}) {
|
|
|
154
159
|
return result;
|
|
155
160
|
}
|
|
156
161
|
/** call node <js> for result
|
|
157
|
-
- js: .js path (relative path will resolve based on cwd)
|
|
158
|
-
- args: `[]` arguments list
|
|
162
|
+
- js: .js 路径 (相对路径根据 cwd 解析) path (relative path will resolve based on cwd)
|
|
163
|
+
- args: `[]` 参数列表 arguments list
|
|
159
164
|
- options
|
|
160
165
|
- cwd?: `'d:/'`
|
|
161
|
-
- env?: `process.env` overwrite/add to process.env
|
|
162
|
-
- encoding?: `'utf-8'` child process output encoding
|
|
163
|
-
- print?: `true` print option (with details)
|
|
164
|
-
- stdio?: `'pipe'` when 'ignore' then ignore stdio processing
|
|
165
|
-
- detached?: `false` whether to break the connection with child (ignore stdio, unref)
|
|
166
|
-
- throw_code?: `true` whether to throw Error when code is not 0
|
|
166
|
+
- env?: `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env
|
|
167
|
+
- encoding?: `'utf-8'` 子进程输出编码 child process output encoding
|
|
168
|
+
- print?: `true` print 选项,支持设置细项 print option (with details)
|
|
169
|
+
- stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing
|
|
170
|
+
- detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref)
|
|
171
|
+
- throw_code?: `true` code 不为 0 时是否抛出异常 whether to throw Error when code is not 0
|
|
167
172
|
*/
|
|
168
173
|
export async function call_node(js, args = [], options) {
|
|
169
174
|
return call(exe_node, [js, ...args], options);
|
|
170
175
|
}
|
|
176
|
+
export const exe_winterm = `C:/Users/${userInfo().username}/AppData/Local/Microsoft/WindowsApps/wt.exe`;
|
|
177
|
+
/** 新建 terminal 窗口执行进程 New Terminal window execution process
|
|
178
|
+
- exe: exe 文件路径 exe file path
|
|
179
|
+
- args: 调用参数 call parameter
|
|
180
|
+
- options?: WinTermOptions
|
|
181
|
+
*/
|
|
182
|
+
export function term(exe, args = [], { cwd = 'd:/t/', print = true, title,
|
|
183
|
+
// env
|
|
184
|
+
} = {}) {
|
|
185
|
+
return start(exe_winterm, [
|
|
186
|
+
'new-tab',
|
|
187
|
+
'-d', cwd,
|
|
188
|
+
...title ? ['--suppressApplicationTitle', '--title', title] : [],
|
|
189
|
+
exe,
|
|
190
|
+
...args.map(arg => arg.replaceAll(';', '\\;')),
|
|
191
|
+
], {
|
|
192
|
+
print,
|
|
193
|
+
detached: true,
|
|
194
|
+
cwd,
|
|
195
|
+
// env
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/** 在 term tab 中创建 node.exe 进程 create the node.exe process in term tab */
|
|
199
|
+
export async function term_node(fp_js, args = [], { title, inspect, tsnode = false, break: _break, resolve = false, trace_warnings = false, ..._options } = {}) {
|
|
200
|
+
return term(exe_node, [
|
|
201
|
+
...trace_warnings ? ['--trace-warnings'] : [],
|
|
202
|
+
...resolve ? ['--experimental-specifier-resolution=node'] : [],
|
|
203
|
+
...title ? [`--title=${title}`] : [],
|
|
204
|
+
...inspect ? [
|
|
205
|
+
_break ? `--inspect-brk=0.0.0.0:${inspect}` : `--inspect=0.0.0.0:${inspect}`
|
|
206
|
+
] : [],
|
|
207
|
+
...tsnode ? [
|
|
208
|
+
'--loader=ts-node/esm',
|
|
209
|
+
'--experimental-specifier-resolution=node'
|
|
210
|
+
] : [],
|
|
211
|
+
fp_js,
|
|
212
|
+
...args
|
|
213
|
+
], {
|
|
214
|
+
title,
|
|
215
|
+
..._options,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
171
218
|
//# sourceMappingURL=process.js.map
|
package/process.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.js","sourceRoot":"","sources":["process.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EAGR,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,OAAO,KAAK,MAAM,YAAY,CAAA;AAC9B,OAAO,IAAI,MAAM,OAAO,CAAA;AAExB,OAAO,gBAAgB,CAAA;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAA;AAE1E,MAAM,CAAC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAA;AA0CnD;;;;;;;;;;EAUE;AACF,MAAM,CAAC,KAAK,UAAU,KAAK,CAAE,GAAW,EAAE,OAAiB,EAAG,EAAE,EAC5D,GAAG,GAAG,QAAQ,EAEd,QAAQ,GAAG,OAAO,EAElB,KAAK,GAAG,IAAI,EAEZ,KAAK,GAAG,MAAM,EAEd,QAAQ,GAAG,KAAK,EAEhB,GAAG,EAEH,MAAM,EAAE,OAAO,GAAG,IAAI,MACR,EAAG;IACjB,MAAM,OAAO,GAAiB;QAC1B,GAAG;QACH,KAAK,EAAE,KAAK;QACZ,WAAW,EAAE,CAAC,OAAO;QACrB,KAAK;QACL,GAAI,GAAG,CAAC,CAAC,CAAC;YACN,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EA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,MAAM,GAAG;QACX,GAAG,EAAE,KAAK,CAAC,GAAG;QAEd,MAAM,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC;YAC3B,MAAM,CAAC,MAAM,CAAC,OAAmB,CAAC;YACtC,CAAC;gBACI,OAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;QAElC,MAAM,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC;YAC3B,MAAM,CAAC,MAAM,CAAC,OAAmB,CAAC;YACtC,CAAC;gBACI,OAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;QAElC,IAAI;QAEJ,MAAM;QAEN,KAAK;QAEL,CAAC,OAAO,CAAC,MAAM,CAAC;YACZ,OAAO,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAC7C,CAAC;KACJ,CAAA;IAED,IAAI,IAAI,IAAI,UAAU;QAClB,MAAM,MAAM,CAAC,MAAM,CACf,IAAI,KAAK,CAAC,OAAO,CAAC,EAClB,MAAM,CACT,CAAA;IAEL,OAAO,MAAM,CAAA;AACjB,CAAC;AAGD;;;;;;;;;;;EAWE;AACF,MAAM,CAAC,KAAK,UAAU,SAAS,CAAE,EAAU,EAAE,OAAiB,EAAE,EAAE,OAA0D;IACxH,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;AACjD,CAAC","sourcesContent":["import {\n spawn,\n type SpawnOptions,\n type ChildProcess\n} from 'child_process'\nimport { Readable } from 'stream'\nimport { fileURLToPath } from 'url'\n\nimport iconv from 'iconv-lite'\nimport path from 'upath'\n\nimport './prototype.js'\nimport { Encoding } from './file.js'\nimport { inspect } from './utils.js'\n\nexport const fpd_root = `${path.dirname(fileURLToPath(import.meta.url))}/`\n\nexport const exe_node = process.execPath.to_slash()\n\n\n// ------------------------------------ start & call\ninterface StartOptions {\n /** `'d:/'` */\n cwd?: string\n \n /** `process.env` overwrite/add to process.env */\n env?: Record<string, string>\n \n /** `'utf-8'` child output encoding */\n encoding?: Encoding\n \n /** `true` print option (with details) */\n print?: boolean | {\n stdout: boolean\n stderr: boolean\n command: boolean\n code: boolean\n }\n \n /** `'pipe'` when 'ignore' then ignore stdio processing */\n stdio?: 'pipe' | 'ignore' | ['pipe' | 'ignore' | 'inherit', 'pipe' | 'ignore' | 'inherit', 'pipe' | 'ignore' | 'inherit']\n \n /** `false` whether to break the connection with child (ignore stdio, unref) */\n detached?: boolean\n \n /** 为 true 时会设置 UV_PROCESS_WINDOWS_HIDE \n 然后设置启动进程的参数 CREATE_NO_WINDOW, 和 SW_HIDE \n d:/0/libuv/src/win/process.c \n CREATE_NO_WINDOW:\n The process is a console application that is being run without a console window. \n Therefore, the console handle for the application is not set.\n This flag is ignored if the application is not a console application, or \n if it is used with either CREATE_NEW_CONSOLE or DETACHED_PROCESS.\n \n 具体有什么用还不清楚\n */\n window?: boolean\n}\n\n/** start process \n - exe: .exe path or filename (full path is recommanded to skip path searching for better perf)\n - args: `[]` arguments list\n - options\n - cwd?: `fp_root`\n - env?: `process.env` overwrite/add to process.env\n - encoding?: `'utf-8'` child output encoding\n - print?: `true` print option (with details)\n - stdio?: `'pipe'` when 'ignore' then ignore stdio processing\n - detached?: `false` whether to break the connection with child (ignore stdio, unref)\n*/\nexport async function start (exe: string, args: string[] = [ ], {\n cwd = fpd_root,\n \n encoding = 'utf-8',\n \n print = true,\n \n stdio = 'pipe',\n \n detached = false,\n \n env,\n \n window: _window = true,\n}: StartOptions = { }): Promise<ChildProcess> {\n const options: SpawnOptions = {\n cwd,\n shell: false,\n windowsHide: !_window,\n stdio,\n ... env ? {\n env: { ...process.env, ...env }\n } : { },\n }\n \n if (typeof print === 'boolean')\n print = {\n stdout: print,\n stderr: print,\n command: print,\n code: print,\n }\n \n if (typeof stdio === 'string')\n stdio = [stdio, stdio, stdio]\n \n if (print.command)\n console.log(`${exe} ${ args.map(arg => arg.includes(' ') ? arg.quote() : arg).join(' ') }`.blue)\n \n if (detached) {\n let child = spawn(exe, args, {\n ...options,\n stdio: 'ignore',\n detached: true,\n })\n \n child.unref()\n return child\n }\n \n let child = spawn(exe, args, options)\n \n // 防止 child spawn 失败时 crash nodejs 进程\n child.on('error', error => {\n console.error(error)\n })\n \n if (stdio[0] === 'pipe')\n child.stdin.setDefaultEncoding('utf8')\n \n if (\n stdio.every(s => \n s === 'ignore')\n )\n return child\n \n if (encoding !== 'binary') {\n if (stdio[1] === 'pipe') {\n if (encoding === 'utf-8')\n child.stdout.setEncoding('utf-8')\n else\n child.stdout = child.stdout.pipe(\n iconv.decodeStream(encoding)\n ) as any as Readable\n \n if (print.stdout)\n child.stdout.pipe(process.stdout, { end: false })\n }\n \n if (stdio[2] === 'pipe') {\n if (encoding === 'utf-8')\n child.stderr.setEncoding('utf-8')\n else\n child.stderr = child.stderr.pipe(\n iconv.decodeStream(encoding)\n ) as any as Readable\n \n if (print.stderr)\n child.stderr.pipe(process.stderr, { end: false })\n }\n }\n \n return child\n}\n\n\nexport interface CallOptions extends StartOptions {\n throw_code?: boolean\n input?: string\n}\n\nexport interface CallResult <T = string> {\n pid: number\n stdout: T\n stderr: T\n code: number | null\n signal: NodeJS.Signals | null\n child: ChildProcess\n [inspect.custom] (): string\n}\n\n\n/** call process for result\n - exe: .exe path or filename (full path is recommanded to skip path searching for better perf)\n - args: `[]` arguments list\n - options?:\n - cwd?: `'d:/'`\n - env?: `process.env` overwrite/add to process.env\n - encoding?: `'utf-8'` child output encoding\n - print?: `true` print option (with details)\n - stdio?: `'pipe'` when 'ignore' then ignore stdio processing\n - input?: string\n - detached?: `false` whether to break the connection with child (ignore stdio, unref)\n - throw_code?: `true` whether to throw Error when code is not 0\n*/\nexport async function call (exe: string, args?: string[]): Promise<CallResult<string>>\nexport async function call (exe: string, args?: string[], options?: CallOptions & { encoding?: 'utf-8' | 'gb18030' }): Promise<CallResult<string>>\nexport async function call (exe: string, args?: string[], options?: CallOptions & { encoding: 'binary' }): Promise<CallResult<Buffer>>\nexport async function call (exe: string, args: string[] = [ ], options: CallOptions = { }): Promise<CallResult<string | Buffer>> {\n const {\n encoding = 'utf-8', \n throw_code = true,\n input,\n } = options\n \n let {\n stdio = 'pipe',\n print = true\n } = options\n \n if (typeof print === 'boolean')\n print = {\n command: print,\n stdout: print,\n stderr: print,\n code: print,\n }\n \n if (typeof stdio === 'string')\n stdio = [stdio, stdio, stdio]\n \n const cmd = \n (exe.includes(' ') ? exe.quote() : exe) + \n (args.length ? (\n ' ' + args.map(arg => \n arg.includes(' ') ? arg.quote() : arg\n ).join(' '))\n :\n '')\n \n if (print.command)\n console.log(cmd.blue)\n \n let child = await start(exe, args, {\n ...options,\n print: false,\n })\n \n if (input)\n child.stdin.write(input)\n \n // --- collect output\n let stdouts: (string | Buffer)[] = [ ]\n let stderrs: (string | Buffer)[] = [ ]\n \n let code: number | null, \n signal: NodeJS.Signals\n \n await Promise.all([\n new Promise<void>(resolve => {\n child.once('exit', (_code, _signal) => {\n code = _code\n signal = _signal\n resolve()\n })\n }),\n (async () => {\n if (stdio[1] === 'pipe')\n for await (const chunk of child.stdout as AsyncIterable<string | Buffer>) {\n if (encoding !== 'binary' && print.stdout)\n process.stdout.write(chunk)\n stdouts.push(chunk)\n }\n })(),\n (async () => {\n if (stdio[2] === 'pipe')\n for await (const chunk of child.stderr as AsyncIterable<string | Buffer>) {\n if (encoding !== 'binary' && print.stderr)\n process.stderr.write(chunk)\n stderrs.push(chunk)\n }\n })()\n ])\n \n const message = `process (${child.pid}) (${cmd}) exited ${code}${ signal ? `, by signal ${ signal }` : '' }.`\n \n if (print.code || code || signal)\n console.log(message[code || signal ? 'red' : 'blue'])\n \n const result = {\n pid: child.pid,\n \n stdout: encoding === 'binary' ?\n Buffer.concat(stdouts as Buffer[])\n :\n (stdouts as string[]).join(''),\n \n stderr: encoding === 'binary' ?\n Buffer.concat(stderrs as Buffer[])\n :\n (stderrs as string[]).join(''),\n \n code,\n \n signal,\n \n child,\n \n [inspect.custom] () {\n return inspect(this, { omit: ['child'] })\n }\n }\n \n if (code && throw_code)\n throw Object.assign(\n new Error(message), \n result\n )\n \n return result\n}\n\n\n/** call node <js> for result\n - js: .js path (relative path will resolve based on cwd)\n - args: `[]` arguments list\n - options\n - cwd?: `'d:/'`\n - env?: `process.env` overwrite/add to process.env\n - encoding?: `'utf-8'` child process output encoding\n - print?: `true` print option (with details)\n - stdio?: `'pipe'` when 'ignore' then ignore stdio processing\n - detached?: `false` whether to break the connection with child (ignore stdio, unref)\n - throw_code?: `true` whether to throw Error when code is not 0\n*/\nexport async function call_node (js: string, args: string[] = [], options?: CallOptions & { encoding?: 'utf-8' | 'gb18030' }) {\n return call(exe_node, [js, ...args], options)\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["process.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EAGR,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAA;AAE7B,OAAO,KAAK,MAAM,YAAY,CAAA;AAC9B,OAAO,IAAI,MAAM,OAAO,CAAA;AAExB,OAAO,gBAAgB,CAAA;AAEvB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAA;AAE1E,MAAM,CAAC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAA;AA0CnD;;;;;;;;;;EAUE;AACF,MAAM,CAAC,KAAK,UAAU,KAAK,CAAE,GAAW,EAAE,OAAiB,EAAG,EAAE,EAC5D,GAAG,GAAG,QAAQ,EAEd,QAAQ,GAAG,OAAO,EAElB,KAAK,GAAG,IAAI,EAEZ,KAAK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AAW,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,EAAG;QACtC,GAAI,OAAO,CAAC,CAAC,CAAC;YACV,MAAM,CAAC,CAAC,CAAC,yBAAyB,OAAO,EAAE,CAAC,CAAC,CAAC,qBAAqB,OAAO,EAAE;SAC/E,CAAC,CAAC,CAAC,EAAG;QACP,GAAI,MAAM,CAAC,CAAC,CAAC;YACT,sBAAsB;YACtB,0CAA0C;SAC7C,CAAC,CAAC,CAAC,EAAG;QACP,KAAK;QACL,GAAI,IAAI;KACX,EAAE;QACC,KAAK;QACL,GAAG,QAAQ;KACd,CAAC,CAAA;AACN,CAAC","sourcesContent":["import {\n spawn,\n type SpawnOptions,\n type ChildProcess\n} from 'child_process'\nimport { Readable } from 'stream'\nimport { fileURLToPath } from 'url'\nimport { userInfo } from 'os'\n\nimport iconv from 'iconv-lite'\nimport path from 'upath'\n\nimport './prototype.js'\nimport { Encoding } from './file.js'\nimport { inspect } from './utils.js'\n\nexport const fpd_root = `${path.dirname(fileURLToPath(import.meta.url))}/`\n\nexport const exe_node = process.execPath.to_slash()\n\n\n// ------------------------------------ start & call\ninterface StartOptions {\n /** `'d:/'` */\n cwd?: string\n \n /** `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env */\n env?: Record<string, string>\n \n /** `'utf-8'` 子进程输出编码 child output encoding */\n encoding?: Encoding\n \n /** `true` print 选项,支持设置细项 print option (with details) */\n print?: boolean | {\n stdout: boolean\n stderr: boolean\n command: boolean\n code: boolean\n }\n \n /** `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing */\n stdio?: 'pipe' | 'ignore' | ['pipe' | 'ignore' | 'inherit', 'pipe' | 'ignore' | 'inherit', 'pipe' | 'ignore' | 'inherit']\n \n /** `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref) */\n detached?: boolean\n \n /** 为 true 时会设置 UV_PROCESS_WINDOWS_HIDE \n 然后设置启动进程的参数 CREATE_NO_WINDOW, 和 SW_HIDE \n d:/0/libuv/src/win/process.c \n CREATE_NO_WINDOW:\n The process is a console application that is being run without a console window. \n Therefore, the console handle for the application is not set.\n This flag is ignored if the application is not a console application, or \n if it is used with either CREATE_NEW_CONSOLE or DETACHED_PROCESS.\n \n 具体有什么用还不清楚\n */\n window?: boolean\n}\n\n/** start process \n - exe: .exe 路径或文件名 (建议使用完整路径,跳过 path 搜索,性能更高) path or filename (full path is recommanded to skip path searching for better perf)\n - args: `[]` 参数列表 arguments list\n - options\n - cwd?: `fp_root`\n - env?: `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env\n - encoding?: `'utf-8'` 子进程输出编码 child output encoding\n - print?: `true` print 选项,支持设置细项 print option (with details)\n - stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing\n - detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref)\n*/\nexport async function start (exe: string, args: string[] = [ ], {\n cwd = fpd_root,\n \n encoding = 'utf-8',\n \n print = true,\n \n stdio = 'pipe',\n \n detached = false,\n \n env,\n \n window: _window = true,\n}: StartOptions = { }): Promise<ChildProcess> {\n const options: SpawnOptions = {\n cwd,\n shell: false,\n windowsHide: !_window,\n stdio,\n ... env ? {\n env: { ...process.env, ...env }\n } : { },\n }\n \n if (typeof print === 'boolean')\n print = {\n stdout: print,\n stderr: print,\n command: print,\n code: print,\n }\n \n if (typeof stdio === 'string')\n stdio = [stdio, stdio, stdio]\n \n if (print.command)\n console.log((\n (exe === exe_winterm ? 'term.exe' : exe) + ' ' +\n (args.filter(arg => \n arg !== '--suppressApplicationTitle'\n ).map(arg =>\n arg.includes(' ') ? \n arg.quote()\n :\n arg\n ).join(' ')\n )\n ).blue)\n \n if (detached) {\n let child = spawn(exe, args, {\n ...options,\n stdio: 'ignore',\n detached: true,\n })\n \n child.unref()\n return child\n }\n \n let child = spawn(exe, args, options)\n \n // 防止 child spawn 失败时 crash nodejs 进程\n child.on('error', error => {\n console.error(error)\n })\n \n if (stdio[0] === 'pipe')\n child.stdin.setDefaultEncoding('utf8')\n \n if (\n stdio.every(s => \n s === 'ignore')\n )\n return child\n \n if (encoding !== 'binary') {\n if (stdio[1] === 'pipe') {\n if (encoding === 'utf-8')\n child.stdout.setEncoding('utf-8')\n else\n child.stdout = child.stdout.pipe(\n iconv.decodeStream(encoding)\n ) as any as Readable\n \n if (print.stdout)\n child.stdout.pipe(process.stdout, { end: false })\n }\n \n if (stdio[2] === 'pipe') {\n if (encoding === 'utf-8')\n child.stderr.setEncoding('utf-8')\n else\n child.stderr = child.stderr.pipe(\n iconv.decodeStream(encoding)\n ) as any as Readable\n \n if (print.stderr)\n child.stderr.pipe(process.stderr, { end: false })\n }\n }\n \n return child\n}\n\n\nexport interface CallOptions extends StartOptions {\n throw_code?: boolean\n input?: string\n}\n\nexport interface CallResult <T = string> {\n pid: number\n stdout: T\n stderr: T\n code: number | null\n signal: NodeJS.Signals | null\n child: ChildProcess\n [inspect.custom] (): string\n}\n\n\n/** call process for result\n - exe: .exe 路径或文件名 (建议使用路径,跳过 path 搜索,性能更高) path or filename (full path is recommanded to skip path searching for better perf)\n - args: `[]` 参数列表 arguments list\n - options?:\n - cwd?: `'d:/'`\n - env?: `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env\n - encoding?: `'utf-8'` 子进程输出编码 child output encoding\n - print?: `true` print 选项,支持设置细项 print option (with details)\n - stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing\n - input?: string, start 子进程之后写入到子进程 stdin 中的内容 After starting the sub-process, write to the content of the sub-process STDIN\n - detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref)\n - throw_code?: `true` code 不为 0 时是否抛出异常 whether to throw Error when code is not 0\n*/\nexport async function call (exe: string, args?: string[]): Promise<CallResult<string>>\nexport async function call (exe: string, args?: string[], options?: CallOptions & { encoding?: 'utf-8' | 'gb18030' }): Promise<CallResult<string>>\nexport async function call (exe: string, args?: string[], options?: CallOptions & { encoding: 'binary' }): Promise<CallResult<Buffer>>\nexport async function call (exe: string, args: string[] = [ ], options: CallOptions = { }): Promise<CallResult<string | Buffer>> {\n const {\n encoding = 'utf-8', \n throw_code = true,\n input,\n } = options\n \n let {\n stdio = 'pipe',\n print = true\n } = options\n \n if (typeof print === 'boolean')\n print = {\n command: print,\n stdout: print,\n stderr: print,\n code: print,\n }\n \n if (typeof stdio === 'string')\n stdio = [stdio, stdio, stdio]\n \n const cmd = \n (exe.includes(' ') ? exe.quote() : exe) + \n (args.length ? (\n ' ' + args.map(arg => \n arg.includes(' ') ? arg.quote() : arg\n ).join(' '))\n :\n '')\n \n if (print.command)\n console.log(cmd.blue)\n \n let child = await start(exe, args, {\n ...options,\n print: false,\n })\n \n if (input)\n child.stdin.write(input)\n \n // --- collect output\n let stdouts: (string | Buffer)[] = [ ]\n let stderrs: (string | Buffer)[] = [ ]\n \n let code: number | null, \n signal: NodeJS.Signals\n \n await Promise.all([\n new Promise<void>(resolve => {\n child.once('exit', (_code, _signal) => {\n code = _code\n signal = _signal\n resolve()\n })\n }),\n (async () => {\n if (stdio[1] === 'pipe')\n for await (const chunk of child.stdout as AsyncIterable<string | Buffer>) {\n if (encoding !== 'binary' && print.stdout)\n process.stdout.write(chunk)\n stdouts.push(chunk)\n }\n })(),\n (async () => {\n if (stdio[2] === 'pipe')\n for await (const chunk of child.stderr as AsyncIterable<string | Buffer>) {\n if (encoding !== 'binary' && print.stderr)\n process.stderr.write(chunk)\n stderrs.push(chunk)\n }\n })()\n ])\n \n const message = `process (${child.pid}) (${cmd}) exited ${code}${ signal ? `, by signal ${ signal }` : '' }.`\n \n if (print.code || code || signal)\n console.log(message[code || signal ? 'red' : 'blue'])\n \n const result = {\n pid: child.pid,\n \n stdout: encoding === 'binary' ?\n Buffer.concat(stdouts as Buffer[])\n :\n (stdouts as string[]).join(''),\n \n stderr: encoding === 'binary' ?\n Buffer.concat(stderrs as Buffer[])\n :\n (stderrs as string[]).join(''),\n \n code,\n \n signal,\n \n child,\n \n [inspect.custom] () {\n return inspect(this, { omit: ['child'] })\n }\n }\n \n if (code && throw_code)\n throw Object.assign(\n new Error(message), \n result\n )\n \n return result\n}\n\n\n/** call node <js> for result\n - js: .js 路径 (相对路径根据 cwd 解析) path (relative path will resolve based on cwd)\n - args: `[]` 参数列表 arguments list\n - options\n - cwd?: `'d:/'`\n - env?: `process.env` 覆盖/添加到 process.env 的环境变量 overwrite/add to process.env\n - encoding?: `'utf-8'` 子进程输出编码 child process output encoding\n - print?: `true` print 选项,支持设置细项 print option (with details)\n - stdio?: `'pipe'` 设置为 'ignore' 时忽略 stdio 处理 when 'ignore' then ignore stdio processing\n - detached?: `false` 是否断开和 child 的关系 (ignore stdio, unref) whether to break the connection with child (ignore stdio, unref)\n - throw_code?: `true` code 不为 0 时是否抛出异常 whether to throw Error when code is not 0\n*/\nexport async function call_node (js: string, args: string[] = [], options?: CallOptions & { encoding?: 'utf-8' | 'gb18030' }) {\n return call(exe_node, [js, ...args], options)\n}\n\n\n// ------------------------------------ term\ninterface TermOptions {\n /** `d:/` */\n cwd?: string\n \n /** `false` 打印参数 print parameter */\n print?: boolean\n \n title?: string\n \n /** (暂不支持,传入时忽略该选项) `false` 在 WinTerm 中后台创建标签页,而非创建并切换到该标签页 \n (No support for the time being, ignore the option when passing in) `False` Create a tab in the background in Winterm instead of creating and switching to the tab */\n background?: boolean\n \n /** (暂不支持,传入时忽略该选项) \n (No support for the time being, ignore this option when passing in) */\n icon?: string\n \n /** 暂不支持传入 env, WindowsTerminal 在调用 CreateProcess API 时没有传入 env \n Not supported by ENV, Windowsterminal did not pass in ENV when calling the CreateProcess API */\n // env?: never\n}\n\nexport const exe_winterm = `C:/Users/${userInfo().username}/AppData/Local/Microsoft/WindowsApps/wt.exe`\n\n/** 新建 terminal 窗口执行进程 New Terminal window execution process\n - exe: exe 文件路径 exe file path\n - args: 调用参数 call parameter\n - options?: WinTermOptions\n*/\nexport function term (exe: string, args: string[] = [], {\n cwd = 'd:/t/',\n \n print = true,\n \n title,\n \n // env\n}: TermOptions = { }) {\n \n \n return start(\n exe_winterm,\n [\n 'new-tab',\n \n '-d', cwd,\n \n ... title ? ['--suppressApplicationTitle', '--title', title] : [ ],\n \n exe,\n \n ...args.map(arg => \n arg.replaceAll(';', '\\\\;')), \n ],\n {\n print,\n detached: true,\n cwd,\n // env\n }\n )\n}\n\n\nexport interface TermNodeOptions extends TermOptions {\n /** nodejs debugger port */\n inspect?: number\n \n /** break at first line */\n break?: boolean\n \n /** 使用 ts-node 直接运行 use ts-node to run directly */\n tsnode?: boolean\n \n /** `false` --experimental-specifier-resolution=node */\n resolve?: boolean\n \n /** `false` --trace-warnings */\n trace_warnings?: boolean\n}\n\n\n/** 在 term tab 中创建 node.exe 进程 create the node.exe process in term tab */\nexport async function term_node (\n fp_js: string, \n args: string[] = [ ],\n {\n title, \n inspect, \n tsnode = false,\n break: _break,\n resolve = false,\n trace_warnings = false,\n ..._options\n }: TermNodeOptions = { }\n) {\n return term(exe_node, [\n ... trace_warnings ? ['--trace-warnings'] : [ ],\n ... resolve ? ['--experimental-specifier-resolution=node'] : [ ],\n ... title ? [`--title=${title}`] : [ ],\n ... inspect ? [\n _break ? `--inspect-brk=0.0.0.0:${inspect}` : `--inspect=0.0.0.0:${inspect}`\n ] : [ ],\n ... tsnode ? [\n '--loader=ts-node/esm',\n '--experimental-specifier-resolution=node'\n ] : [ ],\n fp_js,\n ... args\n ], {\n title,\n ..._options,\n })\n}\n\n\n\n"]}
|
package/prototype.browser.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** 在浏览器端修改 prototype,需要更加小心 */
|
|
2
2
|
import byte_size from 'byte-size';
|
|
3
3
|
import EmojiRegex from 'emoji-regex';
|
|
4
|
+
import { t } from './i18n/instance.js';
|
|
4
5
|
export const emoji_regex = EmojiRegex();
|
|
5
6
|
export function to_method_property_descriptors(methods) {
|
|
6
7
|
return Object.fromEntries(Object.entries(methods)
|
|
@@ -290,21 +291,21 @@ Object.defineProperties(Date.prototype, to_method_property_descriptors({
|
|
|
290
291
|
const [ampm, hour] = (() => {
|
|
291
292
|
let hour = this.getHours();
|
|
292
293
|
if (hour <= 6)
|
|
293
|
-
return ['凌晨', hour];
|
|
294
|
+
return [t('凌晨'), hour];
|
|
294
295
|
if (hour <= 8)
|
|
295
|
-
return ['清晨', hour];
|
|
296
|
+
return [t('清晨'), hour];
|
|
296
297
|
if (hour <= 9)
|
|
297
|
-
return ['早上', hour];
|
|
298
|
+
return [t('早上'), hour];
|
|
298
299
|
if (hour <= 10)
|
|
299
|
-
return ['上午', hour];
|
|
300
|
+
return [t('上午'), hour];
|
|
300
301
|
if (hour <= 12)
|
|
301
|
-
return ['中午', hour];
|
|
302
|
+
return [t('中午'), hour];
|
|
302
303
|
hour -= 12;
|
|
303
304
|
if (hour <= 5)
|
|
304
|
-
return ['下午', hour];
|
|
305
|
+
return [t('下午'), hour];
|
|
305
306
|
if (hour <= 10)
|
|
306
|
-
return ['晚上', hour];
|
|
307
|
-
return ['深夜', hour];
|
|
307
|
+
return [t('晚上'), hour];
|
|
308
|
+
return [t('深夜'), hour];
|
|
308
309
|
})();
|
|
309
310
|
const zero_padding = { character: '0', position: 'left' };
|
|
310
311
|
return '' +
|
package/prototype.browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prototype.browser.js","sourceRoot":"","sources":["prototype.browser.ts"],"names":[],"mappings":"AAAA,+BAA+B;AA+K/B,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,UAAU,MAAM,aAAa,CAAA;AAEpC,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,EAAE,CAAA;AAGvC,MAAM,UAAU,8BAA8B,CAAE,OAAqC;IACjF,OAAO,MAAM,CAAC,WAAW,CACrB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;SAClB,GAAG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S,IAAI,SAAS,IAAI,MAAM,CAAC;YAE5C,kBAAkB;YAClB,CAAC,OAAO,IAAI,SAAS,IAAI,SAAS,IAAI,OAAO,CAAC;YAE9C,kCAAkC;YAClC,CAAC,OAAO,IAAI,SAAS,IAAI,SAAS,IAAI,OAAO,CAAC;YAE9C,mEAAmE;YACnE,CAAC,OAAO,IAAI,SAAS,IAAI,SAAS,IAAI,OAAO,CAAC,CACjD,CACJ,CAAA;AACL,CAAC","sourcesContent":["/** 在浏览器端修改 prototype,需要更加小心 */\n\ndeclare global {\n interface String {\n readonly width: number\n \n // --- 工具方法\n /** 截取字符串不超过 width 显示宽度的部分,并保留颜色 \n 找到并记录能容纳 字符串 + … 的最后一个字符的位置 i_fitted \n 若完整的字符串长度超过 width,返回 slice(0, i_fitted + 1) + … \n 否则 返回 this \n */\n truncate (this: string, width: number): string\n \n /** pad string to `<width>` \n - character?: `' '`\n - position?: `'right'`\n */\n pad (this: string, width: number, { character, position }?: { character?: string, position?: 'left' | 'right'}): string\n \n limit (this: string, width: number, { character, position }?: { character?: string, position?: 'left' | 'right'}): string\n \n to_regexp (this: string, preservations?: string, flags?: string): RegExp\n \n to_bool (this: string): boolean\n \n /** 字符串模式替换 \n - pattern: 匹配部分的格式\n - pattern_: 替换后的格式\n - preservations?: `''` 保留的正则表达式字符\n - flags?: `''` 正则匹配选项\n - transformer?: `(name, matched) => matched || ''` placeholder transformer\n - pattern_placeholder?: `/\\{.*?\\}/g`\n \n ```ts\n 'g:/acgn/海贼王/[Skytree][海贼王][One_Piece][893][GB_BIG5_JP][X264_AAC][1080P][CRRIP][天空树双语字幕组].mkv'.refmt( \n '{dirp}/[Skytree][海贼王][{ en_name: \\\\w+ }][{ episode: \\\\d+ }][GB_BIG5_JP][{encoding}_AAC][1080P][CRRIP][天空树双语字幕组].{format}', \n 'g:/acgn/海贼王/{episode} {encoding}.{format}', \n '\\\\+', \n 'i', \n (name, value) => name === 'episode' ? String(+value + 1) : value.toLowerCase() \n )\n ```\n */\n refmt ( this: string,\n pattern: string,\n \n pattern_: string,\n \n preservations?: string,\n \n flags?: string,\n \n transformer?: (name: string, value: string, placeholders: { [name: string]: string }) => string,\n \n pattern_placeholder?: RegExp\n \n ): string\n \n \n /** 字符串模式搜索\n ```ts\n 'git+https://github.com/tamino-martinius/node-ts-dedent-123.git'.find(\n '^{protocol:[\\\\w+]+}://{hostname:[\\\\w\\\\.]+}/{username}/{project}-{index:\\\\d+}.{suffix}', '^', 'i'\n )\n {\n protocol: 'git+https',\n hostname: 'github.com',\n ...\n }\n ```\n \n - preservations?: `''` 保留的正则表达式字符\n - flags?: `''` 正则匹配选项\n - pattern_placeholder?: `/\\{.*?\\}/g`\n */\n find (this: string,\n \n pattern: string, \n \n preservations?: string, \n \n flags?: string, \n \n pattern_placeholder?: RegExp\n \n ): Record<string, string>\n \n \n /** - type?: `'single'` */\n quote (this: string, type?: keyof typeof quotes | 'psh'): string\n \n /** - shape?: `'parenthesis'` */\n bracket (this: string, shape?: keyof typeof brackets): string\n \n surround (this: string, left: string, right?: string): string\n \n surround_tag (this: string, tag_name: string): string\n \n to_lf (this: string): string\n \n to_crlf (this: string): string\n \n /** 'xxx'.replace(/pattern/g, '') \n 如果 pattern 是 string 则在创建 RegExp 时自动加上 flags (默认 'g'), 否则忽略 flags\n */\n rm (this: string, pattern: string | RegExp, flags?: string): string\n \n \n // --- 文本处理\n /** 将 string 划分为行,并去掉最后一个 \\n 之后的 '' */\n split_lines (this: string): string[]\n \n trim_doc_comment (this: string): string\n \n split_indent (this: string): { indent: number, text: string }\n \n \n space (this: string): string\n \n to_slash (this: string): string\n \n to_backslash (this: string): string\n }\n \n \n interface Date {\n /** - ms?: `false` 显示到 ms */\n to_str (this: Date, ms?: boolean): string\n \n to_date_str (this: Date): string\n \n /** - ms?: `false` 显示到 ms */\n to_time_str (this: Date, ms?: boolean): string\n }\n \n \n interface Number {\n /** 12.4 KB (1 KB = 1024 B) */\n to_fsize_str (this: number, units?: 'iec' | 'metric'): string\n \n \n to_bin_str (this: number): string\n \n to_hex_str (this: number, length?: number): string\n \n to_oct_str (this: number): string\n }\n \n \n interface Array<T> {\n indent (this: string[], width: number, c?: string): string[]\n \n // --- 文本处理\n /**\n - trim_line?: `true`\n - rm_empty_lines?: `true`\n - rm_last_empty_lines?: `false`\n */\n trim_lines (this: string[], { trim_line, rm_empty_lines, rm_last_empty_lines }?: { trim_line?: boolean, rm_empty_lines?: boolean, rm_last_empty_lines?: boolean }): string[]\n \n join_lines (): string\n }\n \n \n interface BigInt {\n toJSON (this: bigint): string\n }\n \n \n interface Error {\n toJSON (this: Error): string\n }\n}\n\nimport byte_size from 'byte-size'\nimport EmojiRegex from 'emoji-regex'\n\nexport const emoji_regex = EmojiRegex()\n\n\nexport function to_method_property_descriptors (methods: { [name: string]: Function }): PropertyDescriptorMap {\n return Object.fromEntries(\n Object.entries(methods)\n .map(([name, value]) => ([name, {\n configurable: true,\n writable: true,\n enumerable: false,\n value,\n } as PropertyDescriptor])\n ))\n}\n\n\nexport function to_getter_property_descriptors (getters: { [name: string]: Function }): PropertyDescriptorMap {\n return Object.fromEntries(\n Object.entries(getters)\n .map(([name, get]) => ([name, {\n configurable: true,\n enumerable: false,\n get,\n } as PropertyDescriptor])\n ))\n}\n\n\nexport const cjk = '([\\u2e80-\\u9fff\\uf900-\\ufaff])'\n\nexport const quotes = {\n single: \"'\",\n double: '\"',\n backtick: '`',\n}\n\nexport const brackets = {\n round: ['(', ')'],\n square: ['[', ']'],\n curly: ['{', '}'],\n pointy: ['<', '>'],\n corner: ['「', '」'],\n fat: ['【', '】'],\n tortoise_shell: ['〔', '〕'],\n} as const\n\n\n\n// ------------------------------------ String.prototype\nObject.defineProperties(String.prototype, {\n ... to_getter_property_descriptors({\n width (this: string) {\n const s = this.replace(emoji_regex, ' ')\n let width = 0\n for (let i = 0; i < s.length; i++) {\n const code = s.codePointAt(i)\n \n if (\n (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) || // ignore control characters\n code >= 0x300 && code <= 0x36f // ignore combining characters\n ) continue\n \n // surrogates\n if (code > 0xffff)\n i++\n \n width += is_codepoint_fullwidth(code) ? 2 : 1\n }\n return width\n }\n }),\n \n \n \n // ------------ 文本处理工具方法\n ... to_method_property_descriptors({\n /** 截取字符串不超过 width 显示宽度的部分,并保留颜色 \n 找到并记录能容纳 字符串 + … 的最后一个字符的位置 i_fitted \n - 若完整的字符串长度超过 width,返回 slice(0, i_fitted + 1) + … \n - 否则 返回 this \n */\n truncate (this: string, width: number) {\n const color_bak = this.startsWith('\\u001b') ? this.slice(0, 5) : ''\n if (width <= 2) return this.slice(0, width)\n let i_fitted = 0\n let fitted_width = 0\n let cur_width = 0\n for (let i = 0; i < this.length; i++) {\n const code = this.codePointAt(i)\n \n if (\n (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) || // Ignore control characters\n code >= 0x300 && code <= 0x36F // Ignore combining characters\n ) continue\n \n // surrogates (codepoint 需要用两个 utf-16 编码单位表示,因此这里跳过第二个编码单位,防止重复计算显示宽度)\n if (code > 0xFFFF)\n i++\n \n const w = is_codepoint_fullwidth(code) ? 2 : 1\n \n if (cur_width + w + 2 <= width) {\n i_fitted = i\n fitted_width += w\n }\n \n cur_width += w\n \n if (cur_width > width) {\n const i_fitted_next = i_fitted + 1\n const t = this.slice(0, i_fitted_next) + ' '.repeat(width - 2 - fitted_width) + '…' \n return color_bak ? color_bak + t + '\\u001b[39m' : t\n }\n }\n return this\n },\n \n \n pad (this: string, width: number, { character = ' ', position = 'right' }: { character?: string, position?: 'left' | 'right'} = { }) {\n const _width = this.width\n if (_width >= width) return this\n if (position === 'right') return this + character.repeat( (width - _width) / character.width )\n return character.repeat(width - _width) + this\n },\n \n \n limit (this: string, width: number, { character = ' ', position = 'right' }: { character?: string, position?: 'left' | 'right'} = { }) {\n return this.pad(width, { character, position }).truncate(width)\n },\n \n \n to_regexp (this: string, preservations: string, flags = ''): RegExp {\n const preserved_chars = new Set(preservations)\n const replace_chars: string = Array.prototype.filter.call('|\\\\{}()[]^$+*?.-', (c: string) => !preserved_chars.has(c))\n .map((c: string) =>\n c === ']' ? '\\\\]' : c\n ).join('')\n \n return new RegExp(\n this.replace(\n new RegExp(`[${replace_chars}]`, 'g'),\n '\\\\$&'\n ), \n flags\n )\n },\n \n \n to_bool (this: string) {\n return this.length && this !== '0' && this.toLowerCase() !== 'false'\n },\n \n refmt (this: string, \n pattern : string,\n pattern_: string,\n preservations: string = '',\n flags = '',\n transformer: (name: string, value: string, placeholders: { [name: string]: string }) => string = (name, value) => value || '',\n pattern_placeholder = /\\{.*?\\}/g,\n ): string {\n // --- 转换 pattern 为 pattern_regx\n let last_end = 0\n \n // placeholder matched group indexes\n let $placeholders: Record<string, number> = { }\n \n let regx_parts = [ ]\n \n function add_part (left: number, right?: number) {\n const part = pattern.slice(left, right)\n if (part)\n regx_parts.push(\n part.to_regexp(preservations).source.bracket()\n )\n }\n \n pattern.replace(pattern_placeholder, ($0, offset) => {\n add_part(last_end, offset)\n last_end = offset + $0.length\n \n const placeholder = $0.slice(1, -1)\n let [placeholder_name, placeholder_pattern] = placeholder.split(':').map(s => s.trim())\n let optional = false\n if (placeholder_name.endsWith('?')) {\n placeholder_name = placeholder_name.slice(0, -1)\n optional = true\n }\n $placeholders[placeholder_name] = regx_parts.push(\n placeholder_pattern ? \n `${placeholder_pattern.bracket()}${optional ? '?' : ''}`\n :\n '(.*?)'\n )\n return ''\n })\n \n add_part(last_end)\n \n // 最后一个 (.*?) 改为贪心匹配,满足 .{suffix} 的需要\n regx_parts = regx_parts.filter(part => part)\n if (regx_parts.last === '(.*?)')\n regx_parts[regx_parts.length - 1] = '(.*)'\n \n const pattern_regx = new RegExp(regx_parts.join(''), flags)\n \n \n // --- 根据 pattern_regx 去匹配原有字符串,获取匹配结果,生成 placeholders 词典\n const matches = pattern_regx.exec(this)\n \n if (!matches) return this\n \n const placeholders = Object.fromEntries(\n Object.entries($placeholders)\n .map(([name, $i]) => [\n [name, matches[$i]],\n [`${name}.before`, matches[$i - 1] || ''],\n [`${name}.after`, matches[$i + 1] || ''],\n ])\n .flat()\n )\n \n \n // --- 转换 pattern_ 为 replacement_str,如果有 transformer 则在遇到 placeholder 时应用\n last_end = 0\n let replacement_parts = [ ]\n \n pattern_.replace(pattern_placeholder, ($0, offset) => {\n replacement_parts.push(\n pattern_.slice(last_end, offset)\n )\n last_end = offset + $0.length\n \n const placeholder_name = $0.slice(1, -1)\n \n replacement_parts.push(\n transformer(placeholder_name, placeholders[placeholder_name], placeholders)\n )\n \n return ''\n })\n replacement_parts.push(\n pattern_.slice(last_end)\n )\n \n return this.replace(pattern_regx, replacement_parts.join(''))\n },\n \n \n find (this: string,\n pattern: string, \n preservations: string = '', \n flags = '', \n pattern_placeholder = /\\{.*?\\}/g\n ): Record<string, string> {\n // --- 转换 pattern 为 pattern_regx\n let last_end = 0\n \n // placeholder matched group index\n let $placeholders: Record<string, number> = { }\n \n let regx_parts = [ ]\n \n function add_part (left: number, right?: number) {\n const part = pattern.slice(left, right)\n if (part)\n regx_parts.push(\n part.to_regexp(preservations).source.bracket()\n )\n }\n \n pattern.replace(pattern_placeholder, ($0, offset) => {\n add_part(last_end, offset)\n last_end = offset + $0.length\n \n const placeholder = $0.slice(1, -1)\n let [placeholder_name, placeholder_pattern] = placeholder.split(':').map(s => s.trim())\n let optional = false\n if (placeholder_name.endsWith('?')) {\n placeholder_name = placeholder_name.slice(0, -1)\n optional = true\n }\n \n $placeholders[placeholder_name] = regx_parts.push(\n placeholder_pattern ? \n `${placeholder_pattern.bracket()}${optional ? '?' : ''}`\n :\n '(.*?)'\n )\n return ''\n })\n \n add_part(last_end)\n \n // 最后一个 (.*?) 改为贪心匹配,满足 .{suffix} 的需要\n regx_parts = regx_parts.filter(part => part)\n if (regx_parts[regx_parts.length - 1] === '(.*?)')\n regx_parts[regx_parts.length - 1] = '(.*)'\n \n const pattern_regx = new RegExp(regx_parts.join(''), flags)\n \n \n // --- 根据 pattern_regx 去匹配原有字符串,获取匹配结果,生成 placeholders 词典\n const matches = pattern_regx.exec(this)\n \n if (!matches) return { }\n \n return Object.fromEntries(\n Object.entries($placeholders)\n .map(([name, $i]) => \n [name, matches[$i] || '']\n )\n )\n },\n \n quote (this: string, type: keyof typeof quotes | 'psh' = 'single') {\n if (type === 'psh')\n return `& ${this.quote()}`\n return this.surround(quotes[type])\n },\n \n \n bracket (this: string, shape: keyof typeof brackets = 'round') {\n return this.surround(...brackets[shape] as [string, string])\n },\n \n \n surround (this: string, left: string, right?: string) {\n return left + this + (right || left)\n },\n \n surround_tag (this: string, tag_name: string): string {\n return '<' + tag_name + '>' + this + '</' + tag_name + '>'\n },\n \n \n to_lf (this: string) {\n return this.replace(/\\r\\n/g, '\\n')\n },\n \n \n to_crlf (this: string) {\n return this.replace(/\\n/g, '\\r\\n')\n },\n \n \n rm (this: string, pattern: string | RegExp, flags: string = 'g') {\n if (typeof pattern === 'string')\n pattern = new RegExp(pattern, flags)\n \n return this.replace(pattern, '')\n },\n \n \n split_lines (this: string, delimiter: string | RegExp = /\\r?\\n/) {\n let lines = this.split(delimiter)\n if (lines.last === '')\n lines.pop()\n return lines\n },\n \n \n split_indent (this: string): { indent: number, text: string } {\n let i = 0\n let indent = 0\n for (; i < this.length; i++)\n if (this[i] === ' ')\n indent += 1\n else if (this[i] === '\\t')\n indent += 4\n else\n break\n \n return {\n indent,\n text: this.slice(i)\n }\n },\n \n \n space (this: string) {\n if (!this) return this\n let text_: string\n text_ = this\n .replace(new RegExp(cjk + `(['\"])`, 'g'), '$1 $2')\n .replace(new RegExp(`(['\"])` + cjk, 'g'), '$1 $2')\n \n .replace(/([\"']+)\\s*(.+?)\\s*([\"']+)/g, '$1$2$3')\n \n .replace(new RegExp(cjk + '([\\\\+\\\\-\\\\*\\\\/=&\\\\\\\\\\\\|<>])([A-Za-z0-9])', 'g'), '$1 $2 $3')\n .replace(new RegExp('([A-Za-z0-9])([\\\\+\\\\-\\\\*\\\\/=&\\\\\\\\\\\\|<>])' + cjk, 'g'), '$1 $2 $3')\n \n const textBak = text_\n \n text_ = text_.replace(new RegExp(cjk + '([\\\\(\\\\[\\\\{<\\u201c]+(.*?)[\\\\)\\\\]\\\\}>\\u201d]+)' + cjk, 'g'), '$1 $2 $4')\n \n if (text_ === textBak)\n text_ = text_\n .replace(new RegExp(cjk + '([\\\\(\\\\[\\\\{<\\u201c>])', 'g'), '$1 $2')\n .replace(new RegExp('([\\\\)\\\\]\\\\}>\\u201d<])' + cjk, 'g'), '$1 $2')\n \n return text_\n .replace(/([\\(\\[\\{<\\u201c]+)(\\s*)(.+?)(\\s*)([\\)\\]\\}>\\u201d]+)/g, '$1$3$5')\n .replace(new RegExp(cjk + '([~!;:,\\\\.\\\\?\\u2026])([A-Za-z0-9])', 'g'), '$1$2 $3')\n .replace(new RegExp(cjk + '([A-Za-z0-9`\\\\$%\\\\^&\\\\*\\\\-=\\\\+\\\\\\\\\\\\|\\\\/@\\u00a1-\\u00ff\\u2022\\u2027\\u2150-\\u218f])', 'g'), '$1 $2')\n .replace(new RegExp('([A-Za-z0-9`\\\\$%\\\\^&\\\\*\\\\-=\\\\+\\\\\\\\\\\\|\\\\/@\\u00a1-\\u00ff\\u2022\\u2027\\u2150-\\u218f])' + cjk, 'g'), '$1 $2')\n },\n \n to_slash (this: string) {\n return this.replaceAll('\\\\', '/')\n },\n \n to_backslash (this: string) {\n return this.replaceAll('/', '\\\\')\n },\n })\n})\n\n\n// ------------------------------------ Date.prototype\nObject.defineProperties(Date.prototype, to_method_property_descriptors({\n to_str (this: Date, ms?: boolean) {\n const [ampm, hour] = (() => {\n let hour = this.getHours()\n if (hour <= 6)\n return ['凌晨', hour]\n \n if (hour <= 8)\n return ['清晨', hour]\n \n if (hour <= 9)\n return ['早上', hour]\n \n if (hour <= 10)\n return ['上午', hour]\n \n if (hour <= 12)\n return ['中午', hour]\n \n hour -= 12\n \n if (hour <= 5)\n return ['下午', hour]\n \n if (hour <= 10)\n return ['晚上', hour]\n \n return ['深夜', hour]\n })()\n \n const zero_padding = { character: '0', position: 'left' } as const\n \n return '' +\n // year.month.date\n this.getFullYear() + '.' + \n String(this.getMonth() + 1).pad(2, zero_padding) + '.' + \n String(this.getDate()).pad(2, zero_padding) + ' ' +\n \n // 上午\n ampm + ' ' +\n \n // 10:03:02\n String(hour).pad(2, zero_padding) + ':' +\n String(this.getMinutes()).pad(2, zero_padding) + ':' +\n String(this.getSeconds()).pad(2, zero_padding) + \n \n (ms ?\n '.' + String(this.getMilliseconds()).pad(3, zero_padding)\n :\n ''\n )\n },\n \n to_date_str (this: Date) {\n return this.to_str().split(' ')[0]\n },\n \n to_time_str (this: Date, ms?: boolean) {\n const [, ampm, time ] = this.to_str(ms).split(' ')\n return `${ampm} ${time}`\n },\n}))\n\n\n\n// ------------------------------------ Number.prototype\nObject.defineProperties(Number.prototype, to_method_property_descriptors({\n to_fsize_str (this: number, units: 'iec' | 'metric' = 'iec') {\n const { value, unit } = byte_size(this, { units })\n return `${value} ${unit.replace('i', '')}`\n },\n \n to_bin_str (this: number) {\n return `0b${this.toString(2)}`\n },\n \n to_hex_str (this: number, length?: number) {\n const s = this.toString(16)\n // 长度自动对齐到 4 的倍数\n if (!length)\n length = Math.ceil(s.length / 4) * 4\n return `0x${'0'.repeat(length - s.length)}${s}`\n },\n \n to_oct_str (this: number) {\n return `0o${this.toString(8)}`\n },\n}))\n\n\n\n// ------------------------------------ Array.prototype\nObject.defineProperties(Array.prototype, {\n // --- 文本处理工具方法\n ... to_method_property_descriptors({\n trim_lines (this: string[], { trim_line = true, rm_empty_lines = true, rm_last_empty_lines = false }: { trim_line?: boolean, rm_empty_lines?: boolean, rm_last_empty_lines?: boolean } = { }) {\n if (!this.length)\n return this\n let lines = this\n \n if (trim_line)\n lines = lines.map(line => line.trim())\n \n if (rm_empty_lines)\n return lines.filter( line => line )\n \n if (rm_last_empty_lines) {\n lines.reverse()\n const i_not_empty = lines.findIndex( line => line )\n if (i_not_empty !== -1)\n lines = lines.slice(i_not_empty)\n lines.reverse()\n return lines\n }\n \n return lines\n },\n \n \n indent (this: string[], width?: number, character: string = ' ') {\n return this.map(line => \n character.repeat(width) + line\n )\n },\n \n \n join_lines (this: string[], append = true) {\n return `${this.join('\\n')}${append ? '\\n' : ''}`\n }\n })\n})\n\n\nObject.defineProperties(BigInt.prototype, to_method_property_descriptors({\n toJSON (this: bigint) {\n return this.toString()\n }\n}))\n\nObject.defineProperties(Error.prototype, to_method_property_descriptors({\n toJSON (this: Error) {\n return Object.fromEntries(\n Object.getOwnPropertyNames(this)\n .map(name => \n [name, this[name]])\n )\n }\n}))\n\n\n\nexport function to_json (obj: any, replacer?: any) {\n return JSON.stringify(obj, replacer, 4) + '\\n'\n}\n\nexport function is_codepoint_fullwidth (codepoint: number) {\n // code points are derived from:\n // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt\n return (\n !Number.isNaN(codepoint) &&\n codepoint >= 0x1100 &&\n (\n codepoint <= 0x115f || // hangul jamo\n \n codepoint === 0x201c || codepoint === 0x201d || // \n codepoint === 0x2026 || // …\n codepoint === 0x203b || // ※\n \n // arrows\n (0x2190 <= codepoint && codepoint <= 0x21FF) ||\n \n codepoint === 0x2329 || // left-pointing angle bracket\n codepoint === 0x232a || // right-pointing angle bracket\n \n // ①\n (0x2460 <= codepoint && codepoint <= 0x24ff) ||\n \n // box drawing\n (0x2500 <= codepoint && codepoint <= 0x257f) ||\n \n // shapes, symbols, …\n (0x2580 <= codepoint && codepoint <= 0x2bef) ||\n \n // cjk radicals supplement .. enclosed cjk letters and months\n (0x2e80 <= codepoint && codepoint <= 0x3247 && codepoint !== 0x303f) ||\n \n // enclosed cjk letters and months .. cjk unified ideographs extension a\n (0x3250 <= codepoint && codepoint <= 0x4dbf) ||\n \n // cjk unified ideographs .. yi radicals\n (0x4E00 <= codepoint && codepoint <= 0xA4C6) ||\n \n // hangul jamo extended-a\n (0xa960 <= codepoint && codepoint <= 0xa97c) ||\n \n // hangul syllables\n (0xac00 <= codepoint && codepoint <= 0xd7a3) ||\n \n // cjk compatibility ideographs\n (0xf900 <= codepoint && codepoint <= 0xfaff) ||\n \n // vertical forms\n (0xfe10 <= codepoint && codepoint <= 0xfe19) ||\n \n // cjk compatibility forms .. small form variants\n (0xfe30 <= codepoint && codepoint <= 0xfe6b) ||\n \n // halfwidth and fullwidth forms\n (0xff01 <= codepoint && codepoint <= 0xff60) ||\n (0xffe0 <= codepoint && codepoint <= 0xffe6) ||\n \n // kana supplement\n (0x1b000 <= codepoint && codepoint <= 0x1b001) ||\n \n // enclosed ideographic supplement\n (0x1f200 <= codepoint && codepoint <= 0x1f251) ||\n \n // cjk unified ideographs extension b .. tertiary ideographic plane\n (0x20000 <= codepoint && codepoint <= 0x3fffd)\n )\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"prototype.browser.js","sourceRoot":"","sources":["prototype.browser.ts"],"names":[],"mappings":"AAAA,+BAA+B;AA+K/B,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,UAAU,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AAEtC,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,EAAE,CAAA;AAGvC,MAAM,UAAU,8BAA8B,CAAE,OAAqC;IACjF,OAAO,MAAM,CAAC,WAAW,CACrB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;SAClB,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE;YAC5B,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,KAAK;YACjB,KAAK;SACc,CAAC,CAAC,CAC5B,CAAC,CAAA;AACV,CAAC;AAGD,MAAM,UAAU,8BAA8B,CAAE,OAAqC;IACjF,OAAO,MAAM,CAAC,WAAW,CACrB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;SAClB,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAA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SAAS,IAAI,OAAO,CAAC,CACjD,CACJ,CAAA;AACL,CAAC","sourcesContent":["/** 在浏览器端修改 prototype,需要更加小心 */\n\ndeclare global {\n interface String {\n readonly width: number\n \n // --- 工具方法\n /** 截取字符串不超过 width 显示宽度的部分,并保留颜色 \n 找到并记录能容纳 字符串 + … 的最后一个字符的位置 i_fitted \n 若完整的字符串长度超过 width,返回 slice(0, i_fitted + 1) + … \n 否则 返回 this \n */\n truncate (this: string, width: number): string\n \n /** pad string to `<width>` \n - character?: `' '`\n - position?: `'right'`\n */\n pad (this: string, width: number, { character, position }?: { character?: string, position?: 'left' | 'right'}): string\n \n limit (this: string, width: number, { character, position }?: { character?: string, position?: 'left' | 'right'}): string\n \n to_regexp (this: string, preservations?: string, flags?: string): RegExp\n \n to_bool (this: string): boolean\n \n /** 字符串模式替换 \n - pattern: 匹配部分的格式\n - pattern_: 替换后的格式\n - preservations?: `''` 保留的正则表达式字符\n - flags?: `''` 正则匹配选项\n - transformer?: `(name, matched) => matched || ''` placeholder transformer\n - pattern_placeholder?: `/\\{.*?\\}/g`\n \n ```ts\n 'g:/acgn/海贼王/[Skytree][海贼王][One_Piece][893][GB_BIG5_JP][X264_AAC][1080P][CRRIP][天空树双语字幕组].mkv'.refmt( \n '{dirp}/[Skytree][海贼王][{ en_name: \\\\w+ }][{ episode: \\\\d+ }][GB_BIG5_JP][{encoding}_AAC][1080P][CRRIP][天空树双语字幕组].{format}', \n 'g:/acgn/海贼王/{episode} {encoding}.{format}', \n '\\\\+', \n 'i', \n (name, value) => name === 'episode' ? String(+value + 1) : value.toLowerCase() \n )\n ```\n */\n refmt ( this: string,\n pattern: string,\n \n pattern_: string,\n \n preservations?: string,\n \n flags?: string,\n \n transformer?: (name: string, value: string, placeholders: { [name: string]: string }) => string,\n \n pattern_placeholder?: RegExp\n \n ): string\n \n \n /** 字符串模式搜索\n ```ts\n 'git+https://github.com/tamino-martinius/node-ts-dedent-123.git'.find(\n '^{protocol:[\\\\w+]+}://{hostname:[\\\\w\\\\.]+}/{username}/{project}-{index:\\\\d+}.{suffix}', '^', 'i'\n )\n {\n protocol: 'git+https',\n hostname: 'github.com',\n ...\n }\n ```\n \n - preservations?: `''` 保留的正则表达式字符\n - flags?: `''` 正则匹配选项\n - pattern_placeholder?: `/\\{.*?\\}/g`\n */\n find (this: string,\n \n pattern: string, \n \n preservations?: string, \n \n flags?: string, \n \n pattern_placeholder?: RegExp\n \n ): Record<string, string>\n \n \n /** - type?: `'single'` */\n quote (this: string, type?: keyof typeof quotes | 'psh'): string\n \n /** - shape?: `'parenthesis'` */\n bracket (this: string, shape?: keyof typeof brackets): string\n \n surround (this: string, left: string, right?: string): string\n \n surround_tag (this: string, tag_name: string): string\n \n to_lf (this: string): string\n \n to_crlf (this: string): string\n \n /** 'xxx'.replace(/pattern/g, '') \n 如果 pattern 是 string 则在创建 RegExp 时自动加上 flags (默认 'g'), 否则忽略 flags\n */\n rm (this: string, pattern: string | RegExp, flags?: string): string\n \n \n // --- 文本处理\n /** 将 string 划分为行,并去掉最后一个 \\n 之后的 '' */\n split_lines (this: string): string[]\n \n trim_doc_comment (this: string): string\n \n split_indent (this: string): { indent: number, text: string }\n \n \n space (this: string): string\n \n to_slash (this: string): string\n \n to_backslash (this: string): string\n }\n \n \n interface Date {\n /** - ms?: `false` 显示到 ms */\n to_str (this: Date, ms?: boolean): string\n \n to_date_str (this: Date): string\n \n /** - ms?: `false` 显示到 ms */\n to_time_str (this: Date, ms?: boolean): string\n }\n \n \n interface Number {\n /** 12.4 KB (1 KB = 1024 B) */\n to_fsize_str (this: number, units?: 'iec' | 'metric'): string\n \n \n to_bin_str (this: number): string\n \n to_hex_str (this: number, length?: number): string\n \n to_oct_str (this: number): string\n }\n \n \n interface Array<T> {\n indent (this: string[], width: number, c?: string): string[]\n \n // --- 文本处理\n /**\n - trim_line?: `true`\n - rm_empty_lines?: `true`\n - rm_last_empty_lines?: `false`\n */\n trim_lines (this: string[], { trim_line, rm_empty_lines, rm_last_empty_lines }?: { trim_line?: boolean, rm_empty_lines?: boolean, rm_last_empty_lines?: boolean }): string[]\n \n join_lines (): string\n }\n \n \n interface BigInt {\n toJSON (this: bigint): string\n }\n \n \n interface Error {\n toJSON (this: Error): string\n }\n}\n\nimport byte_size from 'byte-size'\nimport EmojiRegex from 'emoji-regex'\n\nimport { t } from './i18n/instance.js'\n\nexport const emoji_regex = EmojiRegex()\n\n\nexport function to_method_property_descriptors (methods: { [name: string]: Function }): PropertyDescriptorMap {\n return Object.fromEntries(\n Object.entries(methods)\n .map(([name, value]) => ([name, {\n configurable: true,\n writable: true,\n enumerable: false,\n value,\n } as PropertyDescriptor])\n ))\n}\n\n\nexport function to_getter_property_descriptors (getters: { [name: string]: Function }): PropertyDescriptorMap {\n return Object.fromEntries(\n Object.entries(getters)\n .map(([name, get]) => ([name, {\n configurable: true,\n enumerable: false,\n get,\n } as PropertyDescriptor])\n ))\n}\n\n\nexport const cjk = '([\\u2e80-\\u9fff\\uf900-\\ufaff])'\n\nexport const quotes = {\n single: \"'\",\n double: '\"',\n backtick: '`',\n}\n\nexport const brackets = {\n round: ['(', ')'],\n square: ['[', ']'],\n curly: ['{', '}'],\n pointy: ['<', '>'],\n corner: ['「', '」'],\n fat: ['【', '】'],\n tortoise_shell: ['〔', '〕'],\n} as const\n\n\n\n// ------------------------------------ String.prototype\nObject.defineProperties(String.prototype, {\n ... to_getter_property_descriptors({\n width (this: string) {\n const s = this.replace(emoji_regex, ' ')\n let width = 0\n for (let i = 0; i < s.length; i++) {\n const code = s.codePointAt(i)\n \n if (\n (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) || // ignore control characters\n code >= 0x300 && code <= 0x36f // ignore combining characters\n ) continue\n \n // surrogates\n if (code > 0xffff)\n i++\n \n width += is_codepoint_fullwidth(code) ? 2 : 1\n }\n return width\n }\n }),\n \n \n \n // ------------ 文本处理工具方法\n ... to_method_property_descriptors({\n /** 截取字符串不超过 width 显示宽度的部分,并保留颜色 \n 找到并记录能容纳 字符串 + … 的最后一个字符的位置 i_fitted \n - 若完整的字符串长度超过 width,返回 slice(0, i_fitted + 1) + … \n - 否则 返回 this \n */\n truncate (this: string, width: number) {\n const color_bak = this.startsWith('\\u001b') ? this.slice(0, 5) : ''\n if (width <= 2) return this.slice(0, width)\n let i_fitted = 0\n let fitted_width = 0\n let cur_width = 0\n for (let i = 0; i < this.length; i++) {\n const code = this.codePointAt(i)\n \n if (\n (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) || // Ignore control characters\n code >= 0x300 && code <= 0x36F // Ignore combining characters\n ) continue\n \n // surrogates (codepoint 需要用两个 utf-16 编码单位表示,因此这里跳过第二个编码单位,防止重复计算显示宽度)\n if (code > 0xFFFF)\n i++\n \n const w = is_codepoint_fullwidth(code) ? 2 : 1\n \n if (cur_width + w + 2 <= width) {\n i_fitted = i\n fitted_width += w\n }\n \n cur_width += w\n \n if (cur_width > width) {\n const i_fitted_next = i_fitted + 1\n const t = this.slice(0, i_fitted_next) + ' '.repeat(width - 2 - fitted_width) + '…' \n return color_bak ? color_bak + t + '\\u001b[39m' : t\n }\n }\n return this\n },\n \n \n pad (this: string, width: number, { character = ' ', position = 'right' }: { character?: string, position?: 'left' | 'right'} = { }) {\n const _width = this.width\n if (_width >= width) return this\n if (position === 'right') return this + character.repeat( (width - _width) / character.width )\n return character.repeat(width - _width) + this\n },\n \n \n limit (this: string, width: number, { character = ' ', position = 'right' }: { character?: string, position?: 'left' | 'right'} = { }) {\n return this.pad(width, { character, position }).truncate(width)\n },\n \n \n to_regexp (this: string, preservations: string, flags = ''): RegExp {\n const preserved_chars = new Set(preservations)\n const replace_chars: string = Array.prototype.filter.call('|\\\\{}()[]^$+*?.-', (c: string) => !preserved_chars.has(c))\n .map((c: string) =>\n c === ']' ? '\\\\]' : c\n ).join('')\n \n return new RegExp(\n this.replace(\n new RegExp(`[${replace_chars}]`, 'g'),\n '\\\\$&'\n ), \n flags\n )\n },\n \n \n to_bool (this: string) {\n return this.length && this !== '0' && this.toLowerCase() !== 'false'\n },\n \n refmt (this: string, \n pattern : string,\n pattern_: string,\n preservations: string = '',\n flags = '',\n transformer: (name: string, value: string, placeholders: { [name: string]: string }) => string = (name, value) => value || '',\n pattern_placeholder = /\\{.*?\\}/g,\n ): string {\n // --- 转换 pattern 为 pattern_regx\n let last_end = 0\n \n // placeholder matched group indexes\n let $placeholders: Record<string, number> = { }\n \n let regx_parts = [ ]\n \n function add_part (left: number, right?: number) {\n const part = pattern.slice(left, right)\n if (part)\n regx_parts.push(\n part.to_regexp(preservations).source.bracket()\n )\n }\n \n pattern.replace(pattern_placeholder, ($0, offset) => {\n add_part(last_end, offset)\n last_end = offset + $0.length\n \n const placeholder = $0.slice(1, -1)\n let [placeholder_name, placeholder_pattern] = placeholder.split(':').map(s => s.trim())\n let optional = false\n if (placeholder_name.endsWith('?')) {\n placeholder_name = placeholder_name.slice(0, -1)\n optional = true\n }\n $placeholders[placeholder_name] = regx_parts.push(\n placeholder_pattern ? \n `${placeholder_pattern.bracket()}${optional ? '?' : ''}`\n :\n '(.*?)'\n )\n return ''\n })\n \n add_part(last_end)\n \n // 最后一个 (.*?) 改为贪心匹配,满足 .{suffix} 的需要\n regx_parts = regx_parts.filter(part => part)\n if (regx_parts.last === '(.*?)')\n regx_parts[regx_parts.length - 1] = '(.*)'\n \n const pattern_regx = new RegExp(regx_parts.join(''), flags)\n \n \n // --- 根据 pattern_regx 去匹配原有字符串,获取匹配结果,生成 placeholders 词典\n const matches = pattern_regx.exec(this)\n \n if (!matches) return this\n \n const placeholders = Object.fromEntries(\n Object.entries($placeholders)\n .map(([name, $i]) => [\n [name, matches[$i]],\n [`${name}.before`, matches[$i - 1] || ''],\n [`${name}.after`, matches[$i + 1] || ''],\n ])\n .flat()\n )\n \n \n // --- 转换 pattern_ 为 replacement_str,如果有 transformer 则在遇到 placeholder 时应用\n last_end = 0\n let replacement_parts = [ ]\n \n pattern_.replace(pattern_placeholder, ($0, offset) => {\n replacement_parts.push(\n pattern_.slice(last_end, offset)\n )\n last_end = offset + $0.length\n \n const placeholder_name = $0.slice(1, -1)\n \n replacement_parts.push(\n transformer(placeholder_name, placeholders[placeholder_name], placeholders)\n )\n \n return ''\n })\n replacement_parts.push(\n pattern_.slice(last_end)\n )\n \n return this.replace(pattern_regx, replacement_parts.join(''))\n },\n \n \n find (this: string,\n pattern: string, \n preservations: string = '', \n flags = '', \n pattern_placeholder = /\\{.*?\\}/g\n ): Record<string, string> {\n // --- 转换 pattern 为 pattern_regx\n let last_end = 0\n \n // placeholder matched group index\n let $placeholders: Record<string, number> = { }\n \n let regx_parts = [ ]\n \n function add_part (left: number, right?: number) {\n const part = pattern.slice(left, right)\n if (part)\n regx_parts.push(\n part.to_regexp(preservations).source.bracket()\n )\n }\n \n pattern.replace(pattern_placeholder, ($0, offset) => {\n add_part(last_end, offset)\n last_end = offset + $0.length\n \n const placeholder = $0.slice(1, -1)\n let [placeholder_name, placeholder_pattern] = placeholder.split(':').map(s => s.trim())\n let optional = false\n if (placeholder_name.endsWith('?')) {\n placeholder_name = placeholder_name.slice(0, -1)\n optional = true\n }\n \n $placeholders[placeholder_name] = regx_parts.push(\n placeholder_pattern ? \n `${placeholder_pattern.bracket()}${optional ? '?' : ''}`\n :\n '(.*?)'\n )\n return ''\n })\n \n add_part(last_end)\n \n // 最后一个 (.*?) 改为贪心匹配,满足 .{suffix} 的需要\n regx_parts = regx_parts.filter(part => part)\n if (regx_parts[regx_parts.length - 1] === '(.*?)')\n regx_parts[regx_parts.length - 1] = '(.*)'\n \n const pattern_regx = new RegExp(regx_parts.join(''), flags)\n \n \n // --- 根据 pattern_regx 去匹配原有字符串,获取匹配结果,生成 placeholders 词典\n const matches = pattern_regx.exec(this)\n \n if (!matches) return { }\n \n return Object.fromEntries(\n Object.entries($placeholders)\n .map(([name, $i]) => \n [name, matches[$i] || '']\n )\n )\n },\n \n quote (this: string, type: keyof typeof quotes | 'psh' = 'single') {\n if (type === 'psh')\n return `& ${this.quote()}`\n return this.surround(quotes[type])\n },\n \n \n bracket (this: string, shape: keyof typeof brackets = 'round') {\n return this.surround(...brackets[shape] as [string, string])\n },\n \n \n surround (this: string, left: string, right?: string) {\n return left + this + (right || left)\n },\n \n surround_tag (this: string, tag_name: string): string {\n return '<' + tag_name + '>' + this + '</' + tag_name + '>'\n },\n \n \n to_lf (this: string) {\n return this.replace(/\\r\\n/g, '\\n')\n },\n \n \n to_crlf (this: string) {\n return this.replace(/\\n/g, '\\r\\n')\n },\n \n \n rm (this: string, pattern: string | RegExp, flags: string = 'g') {\n if (typeof pattern === 'string')\n pattern = new RegExp(pattern, flags)\n \n return this.replace(pattern, '')\n },\n \n \n split_lines (this: string, delimiter: string | RegExp = /\\r?\\n/) {\n let lines = this.split(delimiter)\n if (lines.last === '')\n lines.pop()\n return lines\n },\n \n \n split_indent (this: string): { indent: number, text: string } {\n let i = 0\n let indent = 0\n for (; i < this.length; i++)\n if (this[i] === ' ')\n indent += 1\n else if (this[i] === '\\t')\n indent += 4\n else\n break\n \n return {\n indent,\n text: this.slice(i)\n }\n },\n \n \n space (this: string) {\n if (!this) return this\n let text_: string\n text_ = this\n .replace(new RegExp(cjk + `(['\"])`, 'g'), '$1 $2')\n .replace(new RegExp(`(['\"])` + cjk, 'g'), '$1 $2')\n \n .replace(/([\"']+)\\s*(.+?)\\s*([\"']+)/g, '$1$2$3')\n \n .replace(new RegExp(cjk + '([\\\\+\\\\-\\\\*\\\\/=&\\\\\\\\\\\\|<>])([A-Za-z0-9])', 'g'), '$1 $2 $3')\n .replace(new RegExp('([A-Za-z0-9])([\\\\+\\\\-\\\\*\\\\/=&\\\\\\\\\\\\|<>])' + cjk, 'g'), '$1 $2 $3')\n \n const textBak = text_\n \n text_ = text_.replace(new RegExp(cjk + '([\\\\(\\\\[\\\\{<\\u201c]+(.*?)[\\\\)\\\\]\\\\}>\\u201d]+)' + cjk, 'g'), '$1 $2 $4')\n \n if (text_ === textBak)\n text_ = text_\n .replace(new RegExp(cjk + '([\\\\(\\\\[\\\\{<\\u201c>])', 'g'), '$1 $2')\n .replace(new RegExp('([\\\\)\\\\]\\\\}>\\u201d<])' + cjk, 'g'), '$1 $2')\n \n return text_\n .replace(/([\\(\\[\\{<\\u201c]+)(\\s*)(.+?)(\\s*)([\\)\\]\\}>\\u201d]+)/g, '$1$3$5')\n .replace(new RegExp(cjk + '([~!;:,\\\\.\\\\?\\u2026])([A-Za-z0-9])', 'g'), '$1$2 $3')\n .replace(new RegExp(cjk + '([A-Za-z0-9`\\\\$%\\\\^&\\\\*\\\\-=\\\\+\\\\\\\\\\\\|\\\\/@\\u00a1-\\u00ff\\u2022\\u2027\\u2150-\\u218f])', 'g'), '$1 $2')\n .replace(new RegExp('([A-Za-z0-9`\\\\$%\\\\^&\\\\*\\\\-=\\\\+\\\\\\\\\\\\|\\\\/@\\u00a1-\\u00ff\\u2022\\u2027\\u2150-\\u218f])' + cjk, 'g'), '$1 $2')\n },\n \n to_slash (this: string) {\n return this.replaceAll('\\\\', '/')\n },\n \n to_backslash (this: string) {\n return this.replaceAll('/', '\\\\')\n },\n })\n})\n\n\n// ------------------------------------ Date.prototype\nObject.defineProperties(Date.prototype, to_method_property_descriptors({\n to_str (this: Date, ms?: boolean) {\n const [ampm, hour] = (() => {\n let hour = this.getHours()\n if (hour <= 6)\n return [t('凌晨'), hour]\n \n if (hour <= 8)\n return [t('清晨'), hour]\n \n if (hour <= 9)\n return [t('早上'), hour]\n \n if (hour <= 10)\n return [t('上午'), hour]\n \n if (hour <= 12)\n return [t('中午'), hour]\n \n hour -= 12\n \n if (hour <= 5)\n return [t('下午'), hour]\n \n if (hour <= 10)\n return [t('晚上'), hour]\n \n return [t('深夜'), hour]\n })()\n \n const zero_padding = { character: '0', position: 'left' } as const\n \n return '' +\n // year.month.date\n this.getFullYear() + '.' + \n String(this.getMonth() + 1).pad(2, zero_padding) + '.' + \n String(this.getDate()).pad(2, zero_padding) + ' ' +\n \n // 上午\n ampm + ' ' +\n \n // 10:03:02\n String(hour).pad(2, zero_padding) + ':' +\n String(this.getMinutes()).pad(2, zero_padding) + ':' +\n String(this.getSeconds()).pad(2, zero_padding) + \n \n (ms ?\n '.' + String(this.getMilliseconds()).pad(3, zero_padding)\n :\n ''\n )\n },\n \n to_date_str (this: Date) {\n return this.to_str().split(' ')[0]\n },\n \n to_time_str (this: Date, ms?: boolean) {\n const [, ampm, time ] = this.to_str(ms).split(' ')\n return `${ampm} ${time}`\n },\n}))\n\n\n\n// ------------------------------------ Number.prototype\nObject.defineProperties(Number.prototype, to_method_property_descriptors({\n to_fsize_str (this: number, units: 'iec' | 'metric' = 'iec') {\n const { value, unit } = byte_size(this, { units })\n return `${value} ${unit.replace('i', '')}`\n },\n \n to_bin_str (this: number) {\n return `0b${this.toString(2)}`\n },\n \n to_hex_str (this: number, length?: number) {\n const s = this.toString(16)\n // 长度自动对齐到 4 的倍数\n if (!length)\n length = Math.ceil(s.length / 4) * 4\n return `0x${'0'.repeat(length - s.length)}${s}`\n },\n \n to_oct_str (this: number) {\n return `0o${this.toString(8)}`\n },\n}))\n\n\n\n// ------------------------------------ Array.prototype\nObject.defineProperties(Array.prototype, {\n // --- 文本处理工具方法\n ... to_method_property_descriptors({\n trim_lines (this: string[], { trim_line = true, rm_empty_lines = true, rm_last_empty_lines = false }: { trim_line?: boolean, rm_empty_lines?: boolean, rm_last_empty_lines?: boolean } = { }) {\n if (!this.length)\n return this\n let lines = this\n \n if (trim_line)\n lines = lines.map(line => line.trim())\n \n if (rm_empty_lines)\n return lines.filter( line => line )\n \n if (rm_last_empty_lines) {\n lines.reverse()\n const i_not_empty = lines.findIndex( line => line )\n if (i_not_empty !== -1)\n lines = lines.slice(i_not_empty)\n lines.reverse()\n return lines\n }\n \n return lines\n },\n \n \n indent (this: string[], width?: number, character: string = ' ') {\n return this.map(line => \n character.repeat(width) + line\n )\n },\n \n \n join_lines (this: string[], append = true) {\n return `${this.join('\\n')}${append ? '\\n' : ''}`\n }\n })\n})\n\n\nObject.defineProperties(BigInt.prototype, to_method_property_descriptors({\n toJSON (this: bigint) {\n return this.toString()\n }\n}))\n\nObject.defineProperties(Error.prototype, to_method_property_descriptors({\n toJSON (this: Error) {\n return Object.fromEntries(\n Object.getOwnPropertyNames(this)\n .map(name => \n [name, this[name]])\n )\n }\n}))\n\n\n\nexport function to_json (obj: any, replacer?: any) {\n return JSON.stringify(obj, replacer, 4) + '\\n'\n}\n\nexport function is_codepoint_fullwidth (codepoint: number) {\n // code points are derived from:\n // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt\n return (\n !Number.isNaN(codepoint) &&\n codepoint >= 0x1100 &&\n (\n codepoint <= 0x115f || // hangul jamo\n \n codepoint === 0x201c || codepoint === 0x201d || // \n codepoint === 0x2026 || // …\n codepoint === 0x203b || // ※\n \n // arrows\n (0x2190 <= codepoint && codepoint <= 0x21FF) ||\n \n codepoint === 0x2329 || // left-pointing angle bracket\n codepoint === 0x232a || // right-pointing angle bracket\n \n // ①\n (0x2460 <= codepoint && codepoint <= 0x24ff) ||\n \n // box drawing\n (0x2500 <= codepoint && codepoint <= 0x257f) ||\n \n // shapes, symbols, …\n (0x2580 <= codepoint && codepoint <= 0x2bef) ||\n \n // cjk radicals supplement .. enclosed cjk letters and months\n (0x2e80 <= codepoint && codepoint <= 0x3247 && codepoint !== 0x303f) ||\n \n // enclosed cjk letters and months .. cjk unified ideographs extension a\n (0x3250 <= codepoint && codepoint <= 0x4dbf) ||\n \n // cjk unified ideographs .. yi radicals\n (0x4E00 <= codepoint && codepoint <= 0xA4C6) ||\n \n // hangul jamo extended-a\n (0xa960 <= codepoint && codepoint <= 0xa97c) ||\n \n // hangul syllables\n (0xac00 <= codepoint && codepoint <= 0xd7a3) ||\n \n // cjk compatibility ideographs\n (0xf900 <= codepoint && codepoint <= 0xfaff) ||\n \n // vertical forms\n (0xfe10 <= codepoint && codepoint <= 0xfe19) ||\n \n // cjk compatibility forms .. small form variants\n (0xfe30 <= codepoint && codepoint <= 0xfe6b) ||\n \n // halfwidth and fullwidth forms\n (0xff01 <= codepoint && codepoint <= 0xff60) ||\n (0xffe0 <= codepoint && codepoint <= 0xffe6) ||\n \n // kana supplement\n (0x1b000 <= codepoint && codepoint <= 0x1b001) ||\n \n // enclosed ideographic supplement\n (0x1f200 <= codepoint && codepoint <= 0x1f251) ||\n \n // cjk unified ideographs extension b .. tertiary ideographic plane\n (0x20000 <= codepoint && codepoint <= 0x3fffd)\n )\n )\n}\n"]}
|