xshell 1.0.190 → 1.0.192

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/file.js CHANGED
@@ -384,7 +384,8 @@ export async function flink(fp_real, fp_link, { junction = false, print = true,
384
384
  if (!skip_existing)
385
385
  throw new Error(`存在同名${is_fpd_link ? '文件夹' : '文件'}: ${fp_link},无法创建链接`);
386
386
  else {
387
- console.log('跳过已存在: ', fp_link);
387
+ if (print)
388
+ console.log('跳过已存在:', fp_link);
388
389
  return;
389
390
  }
390
391
  if (print)
package/git.d.ts CHANGED
@@ -5,10 +5,11 @@ export declare class Git {
5
5
  constructor(cwd: string);
6
6
  static init(cwd: string, print?: boolean): Promise<Git>;
7
7
  static clone(repo: string, fpd: string, shallow?: boolean | string): Promise<void>;
8
- call(args?: any[], { color, print, printers }?: {
8
+ call(args?: any[], { color, print, printers, throw_code, }?: {
9
9
  color?: boolean;
10
10
  print?: CallOptions['print'];
11
11
  printers?: CallOptions['printers'];
12
+ throw_code?: CallOptions['throw_code'];
12
13
  }): Promise<import("./process.ts").CallResult<string>>;
13
14
  get_branch(): Promise<string>;
14
15
  /** - print: `true` */
package/git.js CHANGED
@@ -22,7 +22,7 @@ export class Git {
22
22
  '.'
23
23
  ]);
24
24
  }
25
- async call(args = [], { color = true, print, printers } = {}) {
25
+ async call(args = [], { color = true, print, printers, throw_code, } = {}) {
26
26
  return call(Git.exe, [
27
27
  ...color ? [] : [
28
28
  '-c', 'color.status=false',
@@ -34,7 +34,8 @@ export class Git {
34
34
  ], {
35
35
  cwd: this.cwd,
36
36
  print,
37
- printers
37
+ printers,
38
+ throw_code
38
39
  });
39
40
  }
40
41
  async get_branch() {
@@ -89,7 +90,7 @@ export class Git {
89
90
  'fetch',
90
91
  remote || '--all',
91
92
  '--prune'
92
- ], { print: { code: false, command: false, stdout: true, stderr: true } });
93
+ ], print_stdout);
93
94
  if (print)
94
95
  console.log('更新远程分支成功');
95
96
  }
@@ -129,4 +130,5 @@ export class Git {
129
130
  };
130
131
  }
131
132
  }
133
+ const print_stdout = { print: { code: false, command: false, stdout: true, stderr: true } };
132
134
  //# sourceMappingURL=git.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.190",
3
+ "version": "1.0.192",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -57,9 +57,9 @@
57
57
  "@svgr/webpack": "^8.1.0",
58
58
  "@types/sass-loader": "^8.0.9",
59
59
  "@types/ws": "^8.5.12",
60
- "@typescript-eslint/eslint-plugin": "^8.11.0",
61
- "@typescript-eslint/parser": "^8.11.0",
62
- "@typescript-eslint/utils": "^8.11.0",
60
+ "@typescript-eslint/eslint-plugin": "^8.12.2",
61
+ "@typescript-eslint/parser": "^8.12.2",
62
+ "@typescript-eslint/utils": "^8.12.2",
63
63
  "@xterm/addon-fit": "^0.10.0",
64
64
  "@xterm/addon-web-links": "^0.11.0",
65
65
  "@xterm/addon-webgl": "^0.18.0",
@@ -92,9 +92,9 @@
92
92
  "ora": "^8.1.0",
93
93
  "react": "^18.3.1",
94
94
  "react-i18next": "^15.1.0",
95
- "react-object-model": "^1.2.14",
95
+ "react-object-model": "^1.2.15",
96
96
  "resolve-path": "^1.4.0",
97
- "sass": "^1.80.4",
97
+ "sass": "^1.80.5",
98
98
  "sass-loader": "^16.0.2",
99
99
  "source-map-loader": "^5.0.0",
100
100
  "strip-ansi": "^7.1.0",
@@ -124,15 +124,15 @@
124
124
  "@types/gulp-sort": "^2.0.4",
125
125
  "@types/koa": "^2.15.0",
126
126
  "@types/koa-compress": "^4.0.6",
127
- "@types/lodash": "^4.17.12",
127
+ "@types/lodash": "^4.17.13",
128
128
  "@types/mime-types": "^2.1.4",
129
- "@types/node": "^22.8.1",
129
+ "@types/node": "^22.8.4",
130
130
  "@types/react": "^18.3.12",
131
131
  "@types/through2": "^2.0.41",
132
132
  "@types/tough-cookie": "^4.0.5",
133
133
  "@types/ua-parser-js": "^0.7.39",
134
134
  "@types/vinyl-fs": "^3.0.5",
135
- "@types/vscode": "^1.94.0",
135
+ "@types/vscode": "^1.95.0",
136
136
  "@types/webpack-bundle-analyzer": "^4.7.0"
137
137
  },
138
138
  "pnpm": {
@@ -92,7 +92,7 @@ declare global {
92
92
  - include?: `false` 传 true 时包括 search 部分
93
93
  - last?: `false` true 时从最后一次出现的地方开始截取,否则默认从第一次出现的地方开始截取 */
94
94
  slice_from(this: string, search: string, options?: SliceOptions): string;
95
- /** 从 search 字符串最后出现的位置开始截断,去掉尾部
95
+ /** 从 search 字符串出现的位置开始截断,去掉尾部
96
96
  - options?:
97
97
  - include?: `false` 传 true 时包括 search 部分
98
98
  - last?: `false` true 时截取到最后一次出现的地方,否则默认截取到第一次出现的地方 */
package/prototype.d.ts CHANGED
@@ -114,7 +114,7 @@ declare global {
114
114
  - include?: `false` 传 true 时包括 search 部分
115
115
  - last?: `false` true 时从最后一次出现的地方开始截取,否则默认从第一次出现的地方开始截取 */
116
116
  slice_from(this: string, search: string, options?: SliceOptions): string;
117
- /** 从 search 字符串最后出现的位置开始截断,去掉尾部
117
+ /** 从 search 字符串出现的位置开始截断,去掉尾部
118
118
  - options?:
119
119
  - include?: `false` 传 true 时包括 search 部分
120
120
  - last?: `false` true 时截取到最后一次出现的地方,否则默认截取到第一次出现的地方 */
package/server.js CHANGED
@@ -303,8 +303,8 @@ export class Server {
303
303
  if (error.status !== 404)
304
304
  console.error(error);
305
305
  response.status = error.status || 500;
306
+ response.set('content-type', 'text/plain; charset=utf-8');
306
307
  response.body = inspect(error, { colors: false });
307
- response.type = 'text/plain';
308
308
  }
309
309
  }
310
310
  /** 解析 req.body to request.body
@@ -24,7 +24,10 @@ export declare function delay(milliseconds: number, { signal }?: {
24
24
  export declare class TimeoutError extends Error {
25
25
  constructor(message?: string, options?: ErrorOptions);
26
26
  }
27
- export declare function timeout<TReturn>(milliseconds: number, action: () => Promise<TReturn>): Promise<TReturn>;
27
+ /** 在指定的时间 (milliseconds) 内运行某个任务,超时之后
28
+ - 如果传入了 on_timeout 参数: 调用 on_timeout,返回 null
29
+ - 如果没传入 on_timeout 参数: 抛出 TimeoutError */
30
+ export declare function timeout<TReturn>(milliseconds: number, action: () => Promise<TReturn>, on_timeout?: () => void | Promise<void>): Promise<TReturn>;
28
31
  /** https://stackoverflow.com/questions/63297164/how-to-only-accept-arraybuffer-as-parameter */
29
32
  export type StrictArrayBuffer = ArrayBuffer & {
30
33
  buffer?: undefined;
package/utils.browser.js CHANGED
@@ -71,11 +71,51 @@ export class TimeoutError extends Error {
71
71
  this.name = this.constructor.name;
72
72
  }
73
73
  }
74
- export async function timeout(milliseconds, action) {
74
+ /** 在指定的时间 (milliseconds) 内运行某个任务,超时之后
75
+ - 如果传入了 on_timeout 参数: 调用 on_timeout,返回 null
76
+ - 如果没传入 on_timeout 参数: 抛出 TimeoutError */
77
+ export async function timeout(milliseconds, action, on_timeout) {
75
78
  const error = new TimeoutError();
76
79
  return new Promise((resolve, reject) => {
77
- delay(milliseconds).then(() => { reject(error); });
78
- action().then(resolve, reject);
80
+ let done = false;
81
+ let rejected = false;
82
+ (async () => {
83
+ await delay(milliseconds);
84
+ if (!done)
85
+ if (on_timeout)
86
+ try {
87
+ await on_timeout();
88
+ resolve(null);
89
+ }
90
+ catch (error) {
91
+ if (rejected)
92
+ throw error; // 会成为 unhandled rejection
93
+ else {
94
+ rejected = true;
95
+ reject(error);
96
+ }
97
+ }
98
+ else {
99
+ rejected = true;
100
+ reject(error);
101
+ }
102
+ })();
103
+ (async () => {
104
+ try {
105
+ resolve(await action());
106
+ }
107
+ catch (error) {
108
+ if (rejected)
109
+ console.log(`已超时任务的错误: ${error.message}`);
110
+ else {
111
+ rejected = true;
112
+ reject(error);
113
+ }
114
+ }
115
+ finally {
116
+ done = true;
117
+ }
118
+ })();
79
119
  });
80
120
  }
81
121
  /** 创建一个 promise,后续可调用 promise.resolve, promise.reject 方法设置其状态和值
package/utils.d.ts CHANGED
@@ -85,7 +85,10 @@ export declare function delay(milliseconds: number, options?: TimerOptions): Pro
85
85
  export declare class TimeoutError extends Error {
86
86
  constructor(message?: string, options?: ErrorOptions);
87
87
  }
88
- export declare function timeout<TReturn>(milliseconds: number, action: () => Promise<TReturn>): Promise<TReturn>;
88
+ /** 在指定的时间 (milliseconds) 内运行某个任务,超时之后
89
+ - 如果传入了 on_timeout 参数: 调用 on_timeout,返回 null
90
+ - 如果没传入 on_timeout 参数: 抛出 TimeoutError */
91
+ export declare function timeout<TReturn>(milliseconds: number, action: () => Promise<TReturn>, on_timeout?: () => void | Promise<void>): Promise<TReturn>;
89
92
  /** https://stackoverflow.com/questions/63297164/how-to-only-accept-arraybuffer-as-parameter */
90
93
  export type StrictArrayBuffer = ArrayBuffer & {
91
94
  buffer?: undefined;
package/utils.js CHANGED
@@ -242,11 +242,51 @@ export class TimeoutError extends Error {
242
242
  this.name = this.constructor.name;
243
243
  }
244
244
  }
245
- export async function timeout(milliseconds, action) {
245
+ /** 在指定的时间 (milliseconds) 内运行某个任务,超时之后
246
+ - 如果传入了 on_timeout 参数: 调用 on_timeout,返回 null
247
+ - 如果没传入 on_timeout 参数: 抛出 TimeoutError */
248
+ export async function timeout(milliseconds, action, on_timeout) {
246
249
  const error = new TimeoutError();
247
250
  return new Promise((resolve, reject) => {
248
- delay(milliseconds).then(() => { reject(error); });
249
- action().then(resolve, reject);
251
+ let done = false;
252
+ let rejected = false;
253
+ (async () => {
254
+ await delay(milliseconds);
255
+ if (!done)
256
+ if (on_timeout)
257
+ try {
258
+ await on_timeout();
259
+ resolve(null);
260
+ }
261
+ catch (error) {
262
+ if (rejected)
263
+ throw error; // 会成为 unhandled rejection
264
+ else {
265
+ rejected = true;
266
+ reject(error);
267
+ }
268
+ }
269
+ else {
270
+ rejected = true;
271
+ reject(error);
272
+ }
273
+ })();
274
+ (async () => {
275
+ try {
276
+ resolve(await action());
277
+ }
278
+ catch (error) {
279
+ if (rejected)
280
+ console.log(`已超时任务的错误: ${error.message}`);
281
+ else {
282
+ rejected = true;
283
+ reject(error);
284
+ }
285
+ }
286
+ finally {
287
+ done = true;
288
+ }
289
+ })();
250
290
  });
251
291
  }
252
292
  /** 创建一个 promise,后续可调用 promise.resolve, promise.reject 方法设置其状态和值
package/xlint.js CHANGED
@@ -587,7 +587,9 @@ export const xlint_plugin = {
587
587
  },
588
588
  FunctionExpression(node) {
589
589
  stack.push(false);
590
- if (node.parent.type === 'VariableDeclarator')
590
+ if (node.parent.type === 'VariableDeclarator' &&
591
+ // 忽略 let a = 1, b = function () { } 这样的情况
592
+ node.parent.parent.declarations.length === 1)
591
593
  context.report({
592
594
  node: node.parent.parent,
593
595
  message: '函数应该使用 function foo { } 这样来声明而不是 const foo = function () { }',
@@ -607,9 +609,11 @@ export const xlint_plugin = {
607
609
  },
608
610
  'ArrowFunctionExpression:exit'(node) {
609
611
  if (!stack.pop() && // not has this expr
610
- node.parent.type === 'VariableDeclarator' &&
611
- node.body.type === 'BlockStatement' && node.body.body.length // 多条语句才转换
612
- )
612
+ (node.parent.type === 'VariableDeclarator' &&
613
+ // 忽略 let a = 1, b = () => { } 这样的情况
614
+ node.parent.parent.declarations.length === 1) &&
615
+ // 多条语句才转换
616
+ node.body.type === 'BlockStatement' && node.body.body.length)
613
617
  context.report({
614
618
  node: node.parent.parent,
615
619
  message: '多条语句的函数应该使用 function foo { } 这样来声明而不是 const foo = () => { }',