xshell 1.2.12 → 1.2.15

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
@@ -4,7 +4,7 @@ import { t } from "./i18n/instance.js";
4
4
  import { to_json } from "./prototype.js";
5
5
  import { pack, parse } from "./io.js";
6
6
  import { path } from "./path.js";
7
- import { check, Lock, WritableMemoryStream, url_width } from "./utils.js";
7
+ import { check, Lock, WritableMemoryStream, url_width, throttle } from "./utils.js";
8
8
  export { fsp };
9
9
  export const encodings = ['utf-8', 'gb18030', 'shift-jis', 'utf-16le'];
10
10
  export const ramdisk = fexists('T:/TEMP/', { print: false });
@@ -525,8 +525,7 @@ export async function ftail(fp, handler, { print = true } = {}) {
525
525
  let decoder = new TextDecoder();
526
526
  if (print)
527
527
  console.log('开始跟踪追加内容', fp);
528
- const { default: throttle } = await import('lodash/throttle.js');
529
- const onchange_throttled = throttle(async () => {
528
+ const onchange_throttled = throttle(250, async () => {
530
529
  if (lock.locked)
531
530
  return;
532
531
  await lock.request(async (handle) => {
@@ -547,7 +546,7 @@ export async function ftail(fp, handler, { print = true } = {}) {
547
546
  strbuf = chunk.slice(j);
548
547
  await handler(lines);
549
548
  });
550
- }, 250);
549
+ });
551
550
  let watcher = fs.watch(fp, event => {
552
551
  if (event === 'change')
553
552
  onchange_throttled();
@@ -1,6 +1,3 @@
1
- import castArray from 'lodash/castArray.js';
2
- import trim from 'lodash/trim.js';
3
- import _get from 'lodash/get.js';
4
1
  import babel_traverse from '@babel/traverse';
5
2
  // @ts-ignore
6
3
  const { default: traverse } = babel_traverse;
@@ -69,7 +66,7 @@ export function mix_parse_trans_from_string_by_babel(parser) {
69
66
  }
70
67
  return acc;
71
68
  }, {});
72
- const transKey = trim(attr[i18nKey]);
69
+ const transKey = attr[i18nKey].trim();
73
70
  const defaultsString = attr[defaultsKey] || '';
74
71
  if (typeof defaultsString !== 'string')
75
72
  this.log(`defaults value must be a static string, saw ${defaultsString.yellow}`);
@@ -132,7 +129,7 @@ function nodes_to_string(nodes, filepath, onError) {
132
129
  if (t.isStringLiteral(expression))
133
130
  memo += expression.value;
134
131
  else if (t.isObjectExpression(expression) &&
135
- t.isObjectProperty(_get(expression, 'properties[0]')))
132
+ t.isObjectProperty(expression?.properties?.[0]))
136
133
  memo += '{{' + expression.properties[0].key.name + '}}';
137
134
  else
138
135
  onError(() => {
@@ -148,4 +145,7 @@ function nodes_to_string(nodes, filepath, onError) {
148
145
  });
149
146
  return memo;
150
147
  }
148
+ function castArray(value) {
149
+ return Array.isArray(value) ? value : [value];
150
+ }
151
151
  //# sourceMappingURL=parser.js.map
package/net.browser.js CHANGED
@@ -315,9 +315,9 @@ export class Remote {
315
315
  if (keeper) {
316
316
  check(this.initiator && url);
317
317
  this.keeper = {
318
- reconnect_interval: 1000 * 5,
318
+ reconnect_interval: 5000,
319
319
  heartbeat_interval: 1000 * 60,
320
- error_delay: 1000 * 2,
320
+ error_delay: 2000,
321
321
  ...keeper
322
322
  };
323
323
  }
@@ -377,19 +377,20 @@ export class Remote {
377
377
  await this.lwebsocket.request(async (websocket) => {
378
378
  // 保存的 rpc 状态在 this.handlers, 与 websocket 无关,因此即使断开重连也不影响 rpc 的运行,即
379
379
  // 底层连接断开后自动重连对上层应该是无感知的,除非再次连接时失败
380
- if (websocket?.readyState !== WebSocket.OPEN) { // 重连
381
- try {
382
- this.lwebsocket.resource = await connect_websocket(this.url, {
383
- on_message: this._on_message,
384
- on_error: this._on_error,
385
- print: this.print
386
- });
387
- reconnected = true;
388
- }
389
- catch (error) {
390
- this._on_error(error);
391
- throw error;
392
- }
380
+ if (websocket?.readyState === WebSocket.OPEN)
381
+ return;
382
+ // 重连
383
+ try {
384
+ this.lwebsocket.resource = await connect_websocket(this.url, {
385
+ on_message: this._on_message,
386
+ on_error: this._on_error,
387
+ print: this.print
388
+ });
389
+ reconnected = true;
390
+ }
391
+ catch (error) {
392
+ this._on_error(error);
393
+ throw error;
393
394
  }
394
395
  });
395
396
  if (this.keeper) {
@@ -502,8 +503,7 @@ export class Remote {
502
503
  async call(func, args, websocket) {
503
504
  return new Promise(async (resolve, reject) => {
504
505
  const id = genid();
505
- this.handlers.set(id, (message) => {
506
- const { error, data } = message;
506
+ this.handlers.set(id, ({ error, data }) => {
507
507
  if (error)
508
508
  reject(error);
509
509
  else
package/net.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare const WebSocketConnecting = 0;
11
11
  export declare const WebSocketOpen = 1;
12
12
  export declare const WebSocketClosing = 2;
13
13
  export declare const WebSocketClosed = 3;
14
+ export declare const websocket_states: readonly ["connecting", "open", "closing", "closed"];
14
15
  export declare enum MyProxy {
15
16
  socks5 = "http://127.0.0.1:10080",
16
17
  whistle = "http://localhost:8899",
@@ -281,4 +282,8 @@ export declare class RemoteClient {
281
282
  /** 发送 message 到 client
282
283
  发送或连接出错时自动清理 message.id 对应的 handler */
283
284
  send(message: Message): Promise<void>;
285
+ [inspect.custom](): {
286
+ remote: string;
287
+ websocket: string;
288
+ } & Omit<this, "websocket" | typeof import("util").inspect.custom | "call" | "remote" | "send">;
284
289
  }
package/net.js CHANGED
@@ -9,6 +9,7 @@ export const WebSocketConnecting = 0;
9
9
  export const WebSocketOpen = 1;
10
10
  export const WebSocketClosing = 2;
11
11
  export const WebSocketClosed = 3;
12
+ export const websocket_states = ['connecting', 'open', 'closing', 'closed'];
12
13
  export var MyProxy;
13
14
  (function (MyProxy) {
14
15
  MyProxy["socks5"] = "http://127.0.0.1:10080";
@@ -107,7 +108,7 @@ export async function request(url, options = {}) {
107
108
  let headers = {
108
109
  'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5',
109
110
  'accept-encoding': 'gzip, deflate, br',
110
- 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
111
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36',
111
112
  'sec-ch-ua-platform': '"Windows"',
112
113
  'sec-ch-ua-platform-version': '"15.0.0"',
113
114
  };
@@ -502,9 +503,9 @@ export class Remote {
502
503
  if (keeper) {
503
504
  check(this.initiator && url);
504
505
  this.keeper = {
505
- reconnect_interval: 1000 * 5,
506
+ reconnect_interval: 5000,
506
507
  heartbeat_interval: 1000 * 60,
507
- error_delay: 1000 * 2,
508
+ error_delay: 2000,
508
509
  ...keeper
509
510
  };
510
511
  }
@@ -564,19 +565,20 @@ export class Remote {
564
565
  await this.lwebsocket.request(async (websocket) => {
565
566
  // 保存的 rpc 状态在 this.handlers, 与 websocket 无关,因此即使断开重连也不影响 rpc 的运行,即
566
567
  // 底层连接断开后自动重连对上层应该是无感知的,除非再次连接时失败
567
- if (websocket?.readyState !== WebSocketOpen) { // 重连
568
- try {
569
- this.lwebsocket.resource = await connect_websocket(this.url, {
570
- on_message: this._on_message,
571
- on_error: this._on_error,
572
- print: this.print
573
- });
574
- reconnected = true;
575
- }
576
- catch (error) {
577
- this._on_error(error);
578
- throw error;
579
- }
568
+ if (websocket?.readyState === WebSocketOpen)
569
+ return;
570
+ // 重连
571
+ try {
572
+ this.lwebsocket.resource = await connect_websocket(this.url, {
573
+ on_message: this._on_message,
574
+ on_error: this._on_error,
575
+ print: this.print
576
+ });
577
+ reconnected = true;
578
+ }
579
+ catch (error) {
580
+ this._on_error(error);
581
+ throw error;
580
582
  }
581
583
  });
582
584
  if (this.keeper) {
@@ -689,8 +691,7 @@ export class Remote {
689
691
  async call(func, args, websocket) {
690
692
  return new Promise(async (resolve, reject) => {
691
693
  const id = genid();
692
- this.handlers.set(id, (message) => {
693
- const { error, data } = message;
694
+ this.handlers.set(id, ({ error, data }) => {
694
695
  if (error)
695
696
  reject(error);
696
697
  else
@@ -723,5 +724,13 @@ export class RemoteClient {
723
724
  async send(message) {
724
725
  return this.remote.send(message, this.websocket);
725
726
  }
727
+ [inspect.custom]() {
728
+ const { [inspect.custom]: _inspect, websocket, remote, ...others } = this;
729
+ return {
730
+ remote: '<Remote(receiver)>',
731
+ websocket: `<WebSocket(${websocket_states[websocket.readyState]})>`,
732
+ ...others
733
+ };
734
+ }
726
735
  }
727
736
  //# sourceMappingURL=net.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.2.12",
3
+ "version": "1.2.15",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -49,17 +49,17 @@
49
49
  ]
50
50
  },
51
51
  "dependencies": {
52
- "@babel/core": "^7.26.7",
53
- "@babel/parser": "^7.26.7",
54
- "@babel/traverse": "^7.26.7",
52
+ "@babel/core": "^7.26.9",
53
+ "@babel/parser": "^7.26.9",
54
+ "@babel/traverse": "^7.26.9",
55
55
  "@koa/cors": "^5.0.0",
56
- "@stylistic/eslint-plugin": "^3.0.0",
56
+ "@stylistic/eslint-plugin": "^4.0.0",
57
57
  "@svgr/webpack": "^8.1.0",
58
58
  "@types/sass-loader": "^8.0.9",
59
59
  "@types/ws": "^8.5.14",
60
- "@typescript-eslint/eslint-plugin": "^8.21.0",
61
- "@typescript-eslint/parser": "^8.21.0",
62
- "@typescript-eslint/utils": "^8.21.0",
60
+ "@typescript-eslint/eslint-plugin": "^8.24.1",
61
+ "@typescript-eslint/parser": "^8.24.1",
62
+ "@typescript-eslint/utils": "^8.24.1",
63
63
  "archiver": "^7.0.1",
64
64
  "chalk": "^5.4.1",
65
65
  "cli-table3": "^0.6.5",
@@ -67,44 +67,43 @@
67
67
  "commander": "^13.1.0",
68
68
  "css-loader": "^7.1.2",
69
69
  "emoji-regex": "^10.4.0",
70
- "eslint": "^9.19.0",
70
+ "eslint": "^9.20.1",
71
71
  "eslint-plugin-import": "^2.31.0",
72
72
  "eslint-plugin-react": "^7.37.4",
73
73
  "gulp-sort": "^2.0.0",
74
74
  "https-proxy-agent": "^7.0.6",
75
75
  "i18next": "^24.2.2",
76
76
  "i18next-scanner": "^4.6.0",
77
- "koa": "^2.15.3",
77
+ "koa": "^2.15.4",
78
78
  "koa-compress": "^5.1.1",
79
79
  "license-webpack-plugin": "^4.0.2",
80
- "lodash": "^4.17.21",
81
80
  "map-stream": "^0.0.7",
82
81
  "mime-types": "^2.1.35",
83
- "ora": "^8.1.1",
82
+ "ora": "^8.2.0",
84
83
  "react": "^19.0.0",
85
- "react-i18next": "^15.4.0",
86
- "react-object-model": "^1.2.22",
84
+ "react-i18next": "^15.4.1",
85
+ "react-object-model": "^1.2.23",
87
86
  "resolve-path": "^1.4.0",
88
- "sass": "^1.83.4",
89
- "sass-loader": "^16.0.4",
87
+ "sass": "^1.85.0",
88
+ "sass-loader": "^16.0.5",
90
89
  "source-map-loader": "^5.0.0",
91
90
  "strip-ansi": "^7.1.0",
92
91
  "style-loader": "^4.0.0",
93
92
  "through2": "^4.0.2",
94
- "tough-cookie": "^5.1.0",
93
+ "tough-cookie": "^5.1.1",
95
94
  "ts-loader": "^9.5.2",
96
95
  "tslib": "^2.8.1",
97
96
  "typescript": "^5.7.3",
98
- "ua-parser-js": "^2.0.0",
97
+ "ua-parser-js": "^2.0.2",
99
98
  "undici": "^7.3.0",
100
99
  "vinyl": "^3.0.0",
101
100
  "vinyl-fs": "^4.0.0",
102
- "webpack": "^5.97.1",
101
+ "webpack": "^5.98.0",
103
102
  "webpack-bundle-analyzer": "^4.10.2",
104
103
  "ws": "^8.18.0"
105
104
  },
106
105
  "devDependencies": {
107
- "@babel/types": "^7.26.7",
106
+ "@babel/types": "^7.26.9",
108
107
  "@types/archiver": "^6.0.3",
109
108
  "@types/babel__traverse": "^7.20.6",
110
109
  "@types/eslint": "^9.6.1",
@@ -112,20 +111,19 @@
112
111
  "@types/gulp-sort": "^2.0.4",
113
112
  "@types/koa": "^2.15.0",
114
113
  "@types/koa-compress": "^4.0.6",
115
- "@types/lodash": "^4.17.14",
116
114
  "@types/mime-types": "^2.1.4",
117
- "@types/node": "^22.10.10",
118
- "@types/react": "^19.0.8",
115
+ "@types/node": "^22.13.4",
116
+ "@types/react": "^19.0.10",
119
117
  "@types/through2": "^2.0.41",
120
118
  "@types/tough-cookie": "^4.0.5",
121
119
  "@types/ua-parser-js": "^0.7.39",
122
120
  "@types/vinyl-fs": "^3.0.5",
123
- "@types/vscode": "^1.96.0",
121
+ "@types/vscode": "^1.97.0",
124
122
  "@types/webpack-bundle-analyzer": "^4.7.0"
125
123
  },
126
124
  "pnpm": {
127
125
  "patchedDependencies": {
128
- "koa@2.15.3": "patches/koa@2.15.3.patch"
126
+ "koa@2.15.4": "patches/koa@2.15.4.patch"
129
127
  }
130
128
  }
131
129
  }
package/process.js CHANGED
@@ -252,7 +252,7 @@ export async function call(exe, args = [], options = {}) {
252
252
  });
253
253
  });
254
254
  const message = `进程 ${command} ` + (code
255
- ? `${throw_code ? '异常' : ''}结束,退出码: ${code}${signal ? `,信号: ${signal}` : ''}`
255
+ ? `${throw_code ? '异常' : ''}结束,退出码: ${code} (${code.to_hex_str()})${signal ? `,信号: ${signal}` : ''}`
256
256
  : '正常结束');
257
257
  if (print.code && !code)
258
258
  console.log(message.blue);
@@ -20,6 +20,7 @@ declare global {
20
20
  position?: 'left' | 'right';
21
21
  }): string;
22
22
  to_regexp(this: string, preservations?: string, flags?: string): RegExp;
23
+ to_snake_case(this: string): string;
23
24
  /** 字符串模式替换
24
25
  - pattern: 匹配部分的格式
25
26
  - pattern_: 替换后的格式
@@ -116,6 +116,12 @@ Object.defineProperties(String.prototype, {
116
116
  .map((c) => c === ']' ? '\\]' : c).join('');
117
117
  return new RegExp(this.replace(new RegExp(`[${replace_chars}]`, 'g'), '\\$&'), flags);
118
118
  },
119
+ to_snake_case() {
120
+ return this.replace(/([A-Z])/g, '_$1')
121
+ .toLowerCase()
122
+ .replace('-', '_')
123
+ .replace(/^_+/, '');
124
+ },
119
125
  refmt(pattern, pattern_, preservations = '', flags = '', transformer = (name, value) => value || '', pattern_placeholder = /\{.*?\}/g) {
120
126
  // --- 转换 pattern 为 pattern_regx
121
127
  let last_end = 0;
package/prototype.d.ts CHANGED
@@ -20,6 +20,7 @@ declare global {
20
20
  position?: 'left' | 'right';
21
21
  }): string;
22
22
  to_regexp(this: string, preservations?: string, flags?: string): RegExp;
23
+ to_snake_case(this: string): string;
23
24
  /** 字符串模式替换
24
25
  - pattern: 匹配部分的格式
25
26
  - pattern_: 替换后的格式
package/prototype.js CHANGED
@@ -120,6 +120,12 @@ if (!globalThis.my_prototype_defined) {
120
120
  .map((c) => c === ']' ? '\\]' : c).join('');
121
121
  return new RegExp(this.replace(new RegExp(`[${replace_chars}]`, 'g'), '\\$&'), flags);
122
122
  },
123
+ to_snake_case() {
124
+ return this.replace(/([A-Z])/g, '_$1')
125
+ .toLowerCase()
126
+ .replace('-', '_')
127
+ .replace(/^_+/, '');
128
+ },
123
129
  refmt(pattern, pattern_, preservations = '', flags = '', transformer = (name, value) => value || '', pattern_placeholder = /\{.*?\}/g) {
124
130
  // --- 转换 pattern 为 pattern_regx
125
131
  let last_end = 0;