xshell 1.0.168 → 1.0.170

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 CHANGED
@@ -60,6 +60,7 @@ interface FWriteOptions {
60
60
  /** 写入 data 到 fp 路径所指的文件
61
61
  会在因不存在父文件夹导致写入失败时,自动创建父文件夹,并再次尝试写入
62
62
  最好预先创建父文件夹,减少文件系统操作,提升性能
63
+ 返回写入的文件路径
63
64
  - fp: 目标文件完整路径
64
65
  - data: 支持下面几种类型
65
66
  - string: 写入文本
package/git.d.ts CHANGED
@@ -4,7 +4,7 @@ export declare class Git {
4
4
  cwd: string;
5
5
  constructor(cwd: string);
6
6
  static init(cwd: string, print?: boolean): Promise<Git>;
7
- static clone(repo: string, fpd: string, shallow?: boolean): Promise<void>;
7
+ static clone(repo: string, fpd: string, shallow?: boolean | string): Promise<void>;
8
8
  call(args?: any[], { color, print, printers }?: {
9
9
  color?: boolean;
10
10
  print?: CallOptions['print'];
package/git.js CHANGED
@@ -16,6 +16,7 @@ export class Git {
16
16
  await new this(fpd)
17
17
  .call([
18
18
  'clone',
19
+ ...typeof shallow === 'string' ? ['--branch', shallow, '--single-branch'] : [],
19
20
  ...shallow ? ['--depth', '1'] : [],
20
21
  repo,
21
22
  '.'
@@ -27,6 +28,7 @@ export class Git {
27
28
  '-c', 'color.status=false',
28
29
  '-c', 'color.ui=false',
29
30
  '-c', 'color.branch=false',
31
+ '-c', 'color.diff=false',
30
32
  ],
31
33
  ...args,
32
34
  ], {
package/i18n/i18n-scan.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,144 +1,138 @@
1
1
  {
2
- "name": "xshell",
3
- "version": "1.0.168",
4
- "type": "module",
5
- "main": "./index.js",
6
- "bin": {
7
- "xshell": "xshell.js",
8
- "i18n-scan": "i18n/i18n-scan.js"
9
- },
10
- "description": "xshell is a shell designed to provide a brand new human-computer interaction experience.",
11
- "keywords": [
12
- "shell",
13
- "node",
14
- "repl",
15
- "i18n",
16
- "interactive programming"
2
+ "name": "xshell",
3
+ "version": "1.0.170",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "bin": {
7
+ "xshell": "xshell.js",
8
+ "i18n-scan": "i18n/i18n-scan.js"
9
+ },
10
+ "description": "xshell is a shell designed to provide a brand new human-computer interaction experience.",
11
+ "keywords": [
12
+ "shell",
13
+ "node",
14
+ "repl",
15
+ "i18n",
16
+ "interactive programming"
17
+ ],
18
+ "author": "ShenHongFei <shen.hongfei@outlook.com> (https://github.com/ShenHongFei)",
19
+ "publisher": "ShenHongFei",
20
+ "homepage": "https://www.npmjs.com/package/xshell",
21
+ "icon": "xshell.png",
22
+ "extensionKind": [
23
+ "workspace"
24
+ ],
25
+ "activationEvents": [
26
+ "onStartupFinished"
27
+ ],
28
+ "contributes": {
29
+ "commands": [
30
+ {
31
+ "command": "xshell_repl",
32
+ "title": "xshell_repl"
33
+ }
17
34
  ],
18
- "scripts": {
19
- "start": "node --title=xshell --inspect=0.0.0.0:8420 ./xshell.js",
20
- "typecheck": "tsc --noEmit",
21
- "build": "tsc",
22
- "package": "vsce package",
23
- "publish:npm": "npm publish --access=public",
24
- "publish:extension": "vsce publish"
25
- },
26
- "author": "ShenHongFei <shen.hongfei@outlook.com> (https://github.com/ShenHongFei)",
27
- "publisher": "ShenHongFei",
28
- "homepage": "https://www.npmjs.com/package/xshell",
29
- "icon": "xshell.png",
30
- "extensionKind": [
31
- "workspace"
32
- ],
33
- "activationEvents": [
34
- "onStartupFinished"
35
- ],
36
- "contributes": {
37
- "commands": [
38
- {
39
- "command": "xshell_repl",
40
- "title": "xshell_repl"
41
- }
42
- ],
43
- "keybindings": [
44
- {
45
- "command": "xshell_repl",
46
- "key": "ctrl+enter",
47
- "when": "editorTextFocus && (editorLangId == 'typescript' || editorLangId == 'javascript' || editorLangId == 'typescriptreact' || editorLangId == 'javascriptreact')"
48
- }
49
- ]
50
- },
51
- "dependencies": {
52
- "@babel/core": "^7.25.2",
53
- "@babel/parser": "^7.25.6",
54
- "@babel/traverse": "^7.25.6",
55
- "@koa/cors": "^5.0.0",
56
- "@stylistic/eslint-plugin": "^2.8.0",
57
- "@svgr/webpack": "^8.1.0",
58
- "@types/sass-loader": "^8.0.9",
59
- "@types/ws": "^8.5.12",
60
- "@typescript-eslint/eslint-plugin": "^8.5.0",
61
- "@typescript-eslint/parser": "^8.5.0",
62
- "@typescript-eslint/utils": "^8.5.0",
63
- "@xterm/addon-fit": "^0.10.0",
64
- "@xterm/addon-web-links": "^0.11.0",
65
- "@xterm/addon-webgl": "^0.18.0",
66
- "@xterm/xterm": "^5.5.0",
67
- "ali-oss": "^6.21.0",
68
- "archiver": "^7.0.1",
69
- "byte-size": "^9.0.0",
70
- "chalk": "^5.3.0",
71
- "chardet": "^2.0.0",
72
- "cli-table3": "^0.6.5",
73
- "cli-truncate": "^4.0.0",
74
- "colors": "^1.4.0",
75
- "commander": "^12.1.0",
76
- "css-loader": "^7.1.2",
77
- "emoji-regex": "^10.4.0",
78
- "eslint": "^9.10.0",
79
- "eslint-plugin-import": "^2.30.0",
80
- "eslint-plugin-react": "^7.35.2",
81
- "gulp-sort": "^2.0.0",
82
- "hash-string": "^1.0.0",
83
- "https-proxy-agent": "^7.0.5",
84
- "i18next": "^23.15.1",
85
- "i18next-scanner": "^4.5.0",
86
- "koa": "^2.15.3",
87
- "koa-compress": "^5.1.1",
88
- "license-webpack-plugin": "^4.0.2",
89
- "lodash": "^4.17.21",
90
- "map-stream": "^0.0.7",
91
- "mime-types": "^2.1.35",
92
- "ora": "^8.1.0",
93
- "react": "^18.3.1",
94
- "react-i18next": "^15.0.1",
95
- "react-object-model": "^1.2.13",
96
- "resolve-path": "^1.4.0",
97
- "sass": "^1.78.0",
98
- "sass-loader": "^16.0.1",
99
- "source-map-loader": "^5.0.0",
100
- "strip-ansi": "^7.1.0",
101
- "style-loader": "^4.0.0",
102
- "through2": "^4.0.2",
103
- "tough-cookie": "^5.0.0-rc.4",
104
- "ts-loader": "^9.5.1",
105
- "tslib": "^2.7.0",
106
- "typescript": "^5.6.2",
107
- "ua-parser-js": "^2.0.0-beta.3",
108
- "undici": "^6.19.8",
109
- "vinyl": "^3.0.0",
110
- "vinyl-fs": "^4.0.0",
111
- "webpack": "^5.94.0",
112
- "webpack-bundle-analyzer": "^4.10.2",
113
- "ws": "^8.18.0"
114
- },
115
- "devDependencies": {
116
- "@babel/types": "^7.25.6",
117
- "@types/ali-oss": "^6.16.11",
118
- "@types/archiver": "^6.0.2",
119
- "@types/babel__traverse": "^7.20.6",
120
- "@types/byte-size": "^8.1.2",
121
- "@types/chardet": "^0.8.3",
122
- "@types/eslint": "^9.6.1",
123
- "@types/estree": "^1.0.5",
124
- "@types/gulp-sort": "^2.0.4",
125
- "@types/koa": "^2.15.0",
126
- "@types/koa-compress": "^4.0.6",
127
- "@types/lodash": "^4.17.7",
128
- "@types/mime-types": "^2.1.4",
129
- "@types/node": "^22.5.4",
130
- "@types/react": "^18.3.5",
131
- "@types/through2": "^2.0.41",
132
- "@types/tough-cookie": "^4.0.5",
133
- "@types/ua-parser-js": "^0.7.39",
134
- "@types/vinyl-fs": "^3.0.5",
135
- "@types/vscode": "^1.93.0",
136
- "@types/webpack-bundle-analyzer": "^4.7.0"
137
- },
138
- "pnpm": {
139
- "patchedDependencies": {
140
- "@types/byte-size@8.1.2": "patches/@types__byte-size@8.1.2.patch",
141
- "koa@2.15.3": "patches/koa@2.15.3.patch"
142
- }
143
- }
144
- }
35
+ "keybindings": [
36
+ {
37
+ "command": "xshell_repl",
38
+ "key": "ctrl+enter",
39
+ "when": "editorTextFocus && (editorLangId == 'typescript' || editorLangId == 'javascript' || editorLangId == 'typescriptreact' || editorLangId == 'javascriptreact')"
40
+ }
41
+ ]
42
+ },
43
+ "dependencies": {
44
+ "@babel/core": "^7.25.2",
45
+ "@babel/parser": "^7.25.6",
46
+ "@babel/traverse": "^7.25.6",
47
+ "@koa/cors": "^5.0.0",
48
+ "@stylistic/eslint-plugin": "^2.8.0",
49
+ "@svgr/webpack": "^8.1.0",
50
+ "@types/sass-loader": "^8.0.9",
51
+ "@types/ws": "^8.5.12",
52
+ "@typescript-eslint/eslint-plugin": "^8.6.0",
53
+ "@typescript-eslint/parser": "^8.6.0",
54
+ "@typescript-eslint/utils": "^8.6.0",
55
+ "@xterm/addon-fit": "^0.10.0",
56
+ "@xterm/addon-web-links": "^0.11.0",
57
+ "@xterm/addon-webgl": "^0.18.0",
58
+ "@xterm/xterm": "^5.5.0",
59
+ "ali-oss": "^6.21.0",
60
+ "archiver": "^7.0.1",
61
+ "byte-size": "^9.0.0",
62
+ "chalk": "^5.3.0",
63
+ "chardet": "^2.0.0",
64
+ "cli-table3": "^0.6.5",
65
+ "cli-truncate": "^4.0.0",
66
+ "colors": "^1.4.0",
67
+ "commander": "^12.1.0",
68
+ "css-loader": "^7.1.2",
69
+ "emoji-regex": "^10.4.0",
70
+ "eslint": "^9.10.0",
71
+ "eslint-plugin-import": "^2.30.0",
72
+ "eslint-plugin-react": "^7.36.1",
73
+ "gulp-sort": "^2.0.0",
74
+ "hash-string": "^1.0.0",
75
+ "https-proxy-agent": "^7.0.5",
76
+ "i18next": "^23.15.1",
77
+ "i18next-scanner": "^4.5.0",
78
+ "koa": "^2.15.3",
79
+ "koa-compress": "^5.1.1",
80
+ "license-webpack-plugin": "^4.0.2",
81
+ "lodash": "^4.17.21",
82
+ "map-stream": "^0.0.7",
83
+ "mime-types": "^2.1.35",
84
+ "ora": "^8.1.0",
85
+ "react": "^18.3.1",
86
+ "react-i18next": "^15.0.2",
87
+ "react-object-model": "^1.2.13",
88
+ "resolve-path": "^1.4.0",
89
+ "sass": "^1.79.1",
90
+ "sass-loader": "^16.0.1",
91
+ "source-map-loader": "^5.0.0",
92
+ "strip-ansi": "^7.1.0",
93
+ "style-loader": "^4.0.0",
94
+ "through2": "^4.0.2",
95
+ "tough-cookie": "^5.0.0-rc.4",
96
+ "ts-loader": "^9.5.1",
97
+ "tslib": "^2.7.0",
98
+ "typescript": "^5.6.2",
99
+ "ua-parser-js": "^2.0.0-beta.3",
100
+ "undici": "^6.19.8",
101
+ "vinyl": "^3.0.0",
102
+ "vinyl-fs": "^4.0.0",
103
+ "webpack": "^5.94.0",
104
+ "webpack-bundle-analyzer": "^4.10.2",
105
+ "ws": "^8.18.0"
106
+ },
107
+ "devDependencies": {
108
+ "@babel/types": "^7.25.6",
109
+ "@types/ali-oss": "^6.16.11",
110
+ "@types/archiver": "^6.0.2",
111
+ "@types/babel__traverse": "^7.20.6",
112
+ "@types/byte-size": "^8.1.2",
113
+ "@types/chardet": "^0.8.3",
114
+ "@types/eslint": "^9.6.1",
115
+ "@types/estree": "^1.0.6",
116
+ "@types/gulp-sort": "^2.0.4",
117
+ "@types/koa": "^2.15.0",
118
+ "@types/koa-compress": "^4.0.6",
119
+ "@types/lodash": "^4.17.7",
120
+ "@types/mime-types": "^2.1.4",
121
+ "@types/node": "^22.5.5",
122
+ "@types/react": "^18.3.7",
123
+ "@types/through2": "^2.0.41",
124
+ "@types/tough-cookie": "^4.0.5",
125
+ "@types/ua-parser-js": "^0.7.39",
126
+ "@types/vinyl-fs": "^3.0.5",
127
+ "@types/vscode": "^1.93.0",
128
+ "@types/webpack-bundle-analyzer": "^4.7.0"
129
+ },
130
+ "scripts": {
131
+ "start": "node --title=xshell --inspect=0.0.0.0:8420 ./xshell.js",
132
+ "typecheck": "tsc --noEmit",
133
+ "build": "tsc",
134
+ "package": "vsce package",
135
+ "publish:npm": "npm publish --access=public",
136
+ "publish:extension": "vsce publish"
137
+ }
138
+ }
package/process.js CHANGED
@@ -226,10 +226,10 @@ export async function term(exe, args = [], { cwd = process.cwd().fpd, print = tr
226
226
  });
227
227
  }
228
228
  /** 在 term tab 中创建 node.exe 进程 */
229
- export async function term_nodejs(fp_js, args = [], { title, inspect, tsnode = false, break: _break, resolve = false, trace_warnings = false, ...options } = {}) {
229
+ export async function term_nodejs(fp_js, args = [], { title, inspect, tsnode = false, break: _break, resolve = false, trace_warnings, ...options } = {}) {
230
230
  return term(exe_nodejs, [
231
231
  '--enable-source-maps',
232
- ...trace_warnings ? ['--trace-warnings'] : [],
232
+ ...trace_warnings ?? inspect ? ['--trace-warnings'] : [],
233
233
  ...resolve ? ['--experimental-specifier-resolution=node'] : [],
234
234
  ...title ? [`--title=${title}`] : [],
235
235
  ...inspect ? [`--inspect${_break ? '-brk' : ''}=localhost:${inspect}`] : [],
@@ -2,7 +2,12 @@ export declare const noop: () => void;
2
2
  /** value 不为 null 或 undefined */
3
3
  export declare const not_empty: (value: any) => boolean;
4
4
  export declare function assert(assertion: any, message?: string): never | void;
5
- export declare function log<T>(obj: T): T;
5
+ /** 通过 console.log 打印对象并返回
6
+ @example
7
+ log('label', obj)
8
+ log(obj) */
9
+ export declare function log<TObj>(obj: TObj): TObj;
10
+ export declare function log<TObj>(label: string, obj: TObj): TObj;
6
11
  /** 数组或 iterable 去重(可按 selector 去重),重复值保留最后出现的那个
7
12
  - selector?: 可以是 key (string) 或 (obj: any) => any */
8
13
  export declare function unique<TObj>(iterable: TObj[] | Iterable<TObj>, selector?: string | ((obj: TObj) => any)): TObj[];
@@ -70,7 +75,7 @@ export declare function encode(str: string): Uint8Array;
70
75
  在流式处理 (buffer 可能不完整) 时,应使用独立的 TextDecoder 实例调用 decode(buffer, { stream: true }) */
71
76
  export declare function decode(buffer: Uint8Array): string;
72
77
  /** 字符串字典序比较 */
73
- export declare function strcmp(l: string, r: string): 1 | 0 | -1;
78
+ export declare function strcmp(l: string, r: string): 0 | 1 | -1;
74
79
  /** 比较 1.10.02 这种版本号
75
80
  - l, r: 两个版本号字符串
76
81
  - loose?: 宽松模式,允许两个版本号格式(位数)不一致 */
@@ -84,6 +89,12 @@ export declare function concat(arrays: ArrayBufferView[]): Uint8Array;
84
89
  export declare function delta2str(delta: number): string;
85
90
  /** generate random id */
86
91
  export declare function genid(): number;
92
+ /** 默认日期时间格式 */
93
+ export declare const datetime_format: "YYYY.MM.DD HH:mm:ss";
94
+ /** 默认日期格式 */
95
+ export declare const date_format: "YYYY.MM.DD";
96
+ /** 默认时间格式 */
97
+ export declare const time_format: "HH:mm:ss";
87
98
  export declare class Timer {
88
99
  started: number;
89
100
  ended: number;
package/utils.browser.js CHANGED
@@ -8,9 +8,17 @@ export function assert(assertion, message) {
8
8
  throw Object.assign(new Error(`断言失败: ${message ? `${message}: ` : ''}${assertion}`), { assertion });
9
9
  }
10
10
  }
11
- export function log(obj) {
12
- console.log(obj);
13
- return obj;
11
+ export function log(...args) {
12
+ if (args.length === 2) {
13
+ const [label, obj] = args;
14
+ console.log(`${label}:`, obj);
15
+ return obj;
16
+ }
17
+ else {
18
+ const obj = args[0];
19
+ console.log(obj);
20
+ return obj;
21
+ }
14
22
  }
15
23
  /** 数组或 iterable 去重(可按 selector 去重),重复值保留最后出现的那个
16
24
  - selector?: 可以是 key (string) 或 (obj: any) => any */
@@ -258,6 +266,12 @@ export function delta2str(delta) {
258
266
  export function genid() {
259
267
  return Math.random() * 2 ** 53;
260
268
  }
269
+ /** 默认日期时间格式 */
270
+ export const datetime_format = 'YYYY.MM.DD HH:mm:ss';
271
+ /** 默认日期格式 */
272
+ export const date_format = 'YYYY.MM.DD';
273
+ /** 默认时间格式 */
274
+ export const time_format = 'HH:mm:ss';
261
275
  export class Timer {
262
276
  started = new Date().getTime();
263
277
  ended;
package/utils.d.ts CHANGED
@@ -10,7 +10,12 @@ export declare const not_empty: (value: any) => boolean;
10
10
  export declare const output_width = 230;
11
11
  export declare function set_inspect_options(colors?: boolean): void;
12
12
  export declare function assert(assertion: any, message?: string): never | void;
13
- export declare function log<T>(obj: T): T;
13
+ /** 通过 console.log 打印对象并返回
14
+ @example
15
+ log('label', obj)
16
+ log(obj) */
17
+ export declare function log<TObj>(obj: TObj): TObj;
18
+ export declare function log<TObj>(label: string, obj: TObj): TObj;
14
19
  /** 生成 0, 1, ..., n - 1 (不包括 n) 的数组,支持传入 generator 函数,通过 index 生成各个元素
15
20
  @example seq(10, i => `item-${i}`) */
16
21
  export declare function seq<T = number>(n: number, generator?: (index: number) => T): T[];
@@ -37,7 +42,7 @@ export declare function filter_values<TObj extends Record<string, any>>(obj: TOb
37
42
  /** 忽略对象中的 keys, 返回新对象 */
38
43
  export declare function omit<TObj>(obj: TObj, omit_keys: string[]): TObj;
39
44
  /** 字符串字典序比较 */
40
- export declare function strcmp(l: string, r: string): 1 | 0 | -1;
45
+ export declare function strcmp(l: string, r: string): 0 | 1 | -1;
41
46
  /** 比较 1.10.02 这种版本号
42
47
  - l, r: 两个版本号字符串
43
48
  - loose?: 宽松模式,允许两个版本号格式(位数)不一致 */
@@ -52,6 +57,12 @@ export declare function typed_array_to_buffer(view: ArrayBufferView): Buffer;
52
57
  export declare function delta2str(delta: number): string;
53
58
  /** generate random id */
54
59
  export declare function genid(): number;
60
+ /** 默认日期时间格式 */
61
+ export declare const datetime_format: "YYYY.MM.DD HH:mm:ss";
62
+ /** 默认日期格式 */
63
+ export declare const date_format: "YYYY.MM.DD";
64
+ /** 默认时间格式 */
65
+ export declare const time_format: "HH:mm:ss";
55
66
  export declare class Timer {
56
67
  started: number;
57
68
  ended: number;
package/utils.js CHANGED
@@ -30,9 +30,17 @@ export function assert(assertion, message) {
30
30
  throw Object.assign(new Error(`${t('断言失败')}: ${message ? `${message}: ` : ''}${inspect(assertion, { colors: false, compact: true })}`), { assertion });
31
31
  }
32
32
  }
33
- export function log(obj) {
34
- console.log(obj);
35
- return obj;
33
+ export function log(...args) {
34
+ if (args.length === 2) {
35
+ const [label, obj] = args;
36
+ console.log(`${label}:`, obj);
37
+ return obj;
38
+ }
39
+ else {
40
+ const obj = args[0];
41
+ console.log(obj);
42
+ return obj;
43
+ }
36
44
  }
37
45
  /** 生成 0, 1, ..., n - 1 (不包括 n) 的数组,支持传入 generator 函数,通过 index 生成各个元素
38
46
  @example seq(10, i => `item-${i}`) */
@@ -176,6 +184,12 @@ export function delta2str(delta) {
176
184
  export function genid() {
177
185
  return Math.random() * 2 ** 53;
178
186
  }
187
+ /** 默认日期时间格式 */
188
+ export const datetime_format = 'YYYY.MM.DD HH:mm:ss';
189
+ /** 默认日期格式 */
190
+ export const date_format = 'YYYY.MM.DD';
191
+ /** 默认时间格式 */
192
+ export const time_format = 'HH:mm:ss';
179
193
  export class Timer {
180
194
  started = new Date().getTime();
181
195
  ended;