xshell 1.2.38 → 1.2.40

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/net.browser.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t } from "./i18n/instance.js";
2
2
  import { rethrow } from "./prototype.browser.js"; // to_time_str()
3
3
  import { message_symbol, pack, parse } from "./io.browser.js";
4
- import { assert, genid, delay, Lock, timeout, check, defer } from "./utils.browser.js";
4
+ import { assert, genid, delay, Lock, timeout, check } from "./utils.browser.js";
5
5
  const drop_request_headers = new Set([
6
6
  // : 开头的 key
7
7
  // sec-*
@@ -526,27 +526,34 @@ export class Remote {
526
526
  - websocket?: 作为 websocket 连接接收方,必传 websocket 参数 */
527
527
  async subscribe(func, on_data, { on_error = rethrow, websocket } = {}) {
528
528
  const id = genid();
529
- let psubscribed = defer();
530
- let first = true;
531
- this.handlers.set(id, ({ error, data }) => {
532
- if (error) {
529
+ let psubscribed = new Promise((resolve, reject) => {
530
+ let first = true;
531
+ this.handlers.set(id, ({ error, data }) => {
532
+ if (error) {
533
+ if (first) {
534
+ first = false;
535
+ this.handlers.delete(id);
536
+ reject(error);
537
+ }
538
+ else
539
+ on_error(error);
540
+ return;
541
+ }
533
542
  if (first) {
534
543
  first = false;
535
- this.handlers.delete(id);
536
- psubscribed.reject(error);
544
+ resolve({ id, data: data });
545
+ return;
537
546
  }
538
- else
539
- on_error(error);
540
- return;
541
- }
542
- if (first) {
543
- first = false;
544
- psubscribed.resolve({ id, data: data });
545
- return;
546
- }
547
- on_data(data);
547
+ on_data(data);
548
+ });
548
549
  });
549
- await this.send({ id, func }, websocket);
550
+ try {
551
+ await this.send({ id, func }, websocket);
552
+ }
553
+ catch (error) {
554
+ this.handlers.delete(id);
555
+ throw error;
556
+ }
550
557
  return psubscribed;
551
558
  }
552
559
  }
package/net.d.ts CHANGED
@@ -298,5 +298,5 @@ export declare class RemoteClient {
298
298
  [inspect.custom](): {
299
299
  remote: string;
300
300
  websocket: string;
301
- } & Omit<this, "websocket" | typeof import("util").inspect.custom | "call" | "remote" | "send">;
301
+ } & Omit<this, "call" | "remote" | "websocket" | typeof import("util").inspect.custom | "send">;
302
302
  }
package/net.js CHANGED
@@ -4,7 +4,7 @@ import { isReadable } from 'stream';
4
4
  import { t } from "./i18n/instance.js";
5
5
  import { rethrow } from "./prototype.js";
6
6
  import { message_symbol, pack, parse } from "./io.js";
7
- import { inspect, assert, genid, delay, Lock, pipe_with_error, map_values, unique, timeout, check, colored, defer } from "./utils.js";
7
+ import { inspect, assert, genid, delay, Lock, pipe_with_error, map_values, unique, timeout, check, colored } from "./utils.js";
8
8
  export const WebSocketConnecting = 0;
9
9
  export const WebSocketOpen = 1;
10
10
  export const WebSocketClosing = 2;
@@ -714,27 +714,34 @@ export class Remote {
714
714
  - websocket?: 作为 websocket 连接接收方,必传 websocket 参数 */
715
715
  async subscribe(func, on_data, { on_error = rethrow, websocket } = {}) {
716
716
  const id = genid();
717
- let psubscribed = defer();
718
- let first = true;
719
- this.handlers.set(id, ({ error, data }) => {
720
- if (error) {
717
+ let psubscribed = new Promise((resolve, reject) => {
718
+ let first = true;
719
+ this.handlers.set(id, ({ error, data }) => {
720
+ if (error) {
721
+ if (first) {
722
+ first = false;
723
+ this.handlers.delete(id);
724
+ reject(error);
725
+ }
726
+ else
727
+ on_error(error);
728
+ return;
729
+ }
721
730
  if (first) {
722
731
  first = false;
723
- this.handlers.delete(id);
724
- psubscribed.reject(error);
732
+ resolve({ id, data: data });
733
+ return;
725
734
  }
726
- else
727
- on_error(error);
728
- return;
729
- }
730
- if (first) {
731
- first = false;
732
- psubscribed.resolve({ id, data: data });
733
- return;
734
- }
735
- on_data(data);
735
+ on_data(data);
736
+ });
736
737
  });
737
- await this.send({ id, func }, websocket);
738
+ try {
739
+ await this.send({ id, func }, websocket);
740
+ }
741
+ catch (error) {
742
+ this.handlers.delete(id);
743
+ throw error;
744
+ }
738
745
  return psubscribed;
739
746
  }
740
747
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.2.38",
3
+ "version": "1.2.40",
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.18.1",
60
- "@typescript-eslint/eslint-plugin": "^8.29.1",
61
- "@typescript-eslint/parser": "^8.29.1",
62
- "@typescript-eslint/utils": "^8.29.1",
60
+ "@typescript-eslint/eslint-plugin": "^8.30.1",
61
+ "@typescript-eslint/parser": "^8.30.1",
62
+ "@typescript-eslint/utils": "^8.30.1",
63
63
  "archiver": "^7.0.1",
64
64
  "chalk": "^5.4.1",
65
65
  "cli-table3": "^0.6.5",
@@ -72,7 +72,7 @@
72
72
  "eslint-plugin-react": "^7.37.5",
73
73
  "gulp-sort": "^2.0.0",
74
74
  "https-proxy-agent": "^7.0.6",
75
- "i18next": "^24.2.3",
75
+ "i18next": "^25.0.0",
76
76
  "i18next-scanner": "^4.6.0",
77
77
  "koa": "^2.16.1",
78
78
  "koa-compress": "^5.1.1",
@@ -82,7 +82,7 @@
82
82
  "ora": "^8.2.0",
83
83
  "react": "^19.1.0",
84
84
  "react-i18next": "^15.4.1",
85
- "react-object-model": "^1.2.23",
85
+ "react-object-model": "^1.2.24",
86
86
  "resolve-path": "^1.4.0",
87
87
  "sass": "^1.86.3",
88
88
  "sass-loader": "^16.0.5",
@@ -112,8 +112,8 @@
112
112
  "@types/koa": "^2.15.0",
113
113
  "@types/koa-compress": "^4.0.6",
114
114
  "@types/mime-types": "^2.1.4",
115
- "@types/node": "^22.14.0",
116
- "@types/react": "^19.1.0",
115
+ "@types/node": "^22.14.1",
116
+ "@types/react": "^19.1.2",
117
117
  "@types/through2": "^2.0.41",
118
118
  "@types/tough-cookie": "^4.0.5",
119
119
  "@types/ua-parser-js": "^0.7.39",
package/path.d.ts CHANGED
@@ -54,7 +54,7 @@ export declare function extname(path: string): string;
54
54
  /** `/` */
55
55
  export declare const sep = "/";
56
56
  /** The platform-specific file delimiter. ';' or ':'. */
57
- export declare const delimiter: ":" | ";";
57
+ export declare const delimiter: ";" | ":";
58
58
  /** Returns an object from a path string - the opposite of format().
59
59
  @param path path to evaluate.
60
60
  @throws {TypeError} if `path` is not a string. */
@@ -81,7 +81,7 @@ export declare let path: {
81
81
  basename: typeof basename;
82
82
  extname: typeof extname;
83
83
  sep: string;
84
- delimiter: ":" | ";";
84
+ delimiter: ";" | ":";
85
85
  parse: typeof parse;
86
86
  format: typeof format;
87
87
  toNamespacedPath: typeof toNamespacedPath;