xshell 1.3.54 → 1.3.55

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.d.ts CHANGED
@@ -116,7 +116,7 @@ export declare function request(url: string | URL, options: RequestOptions & {
116
116
  }): Promise<Buffer>;
117
117
  export declare function request(url: string | URL, options: RequestOptions): Promise<string>;
118
118
  /** 发起 http 请求并将响应体作为 json 解析 */
119
- export declare function request_json<T = any>(url: string | URL, options?: RequestOptions): Promise<T>;
119
+ export declare function request_json<TReturn = any>(url: string | URL, options?: RequestOptions): Promise<TReturn>;
120
120
  export interface ConnectOptions {
121
121
  local_port?: number;
122
122
  timeout?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.3.54",
3
+ "version": "1.3.55",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -73,7 +73,7 @@
73
73
  "license-webpack-plugin": "^4.0.2",
74
74
  "mime-types": "^3.0.2",
75
75
  "p-map": "^7.0.4",
76
- "react": "^19.2.4",
76
+ "react": "^19.2.5",
77
77
  "react-i18next": "^17.0.2",
78
78
  "resolve-path": "^1.4.0",
79
79
  "sass": "^1.99.0",
@@ -85,8 +85,8 @@
85
85
  "ts-loader": "^9.5.7",
86
86
  "tslib": "^2.8.1",
87
87
  "typescript": "^6.0.2",
88
- "undici": "^8.0.2",
89
- "webpack": "^5.105.4",
88
+ "undici": "^8.0.3",
89
+ "webpack": "^5.106.1",
90
90
  "webpack-bundle-analyzer": "^5.3.0",
91
91
  "ws": "^8.20.0"
92
92
  },
@@ -99,10 +99,10 @@
99
99
  "@types/koa": "^3.0.2",
100
100
  "@types/koa-compress": "^4.0.7",
101
101
  "@types/mime-types": "^3.0.1",
102
- "@types/node": "^25.5.2",
102
+ "@types/node": "^25.6.0",
103
103
  "@types/react": "^19.2.14",
104
104
  "@types/tough-cookie": "^4.0.5",
105
- "@types/vscode": "^1.110.0",
105
+ "@types/vscode": "^1.115.0",
106
106
  "@types/webpack-bundle-analyzer": "^4.7.0",
107
107
  "@types/ws": "^8.18.1"
108
108
  }
package/utils.common.d.ts CHANGED
@@ -30,11 +30,11 @@ export declare function sort_keys<TObj>(obj: TObj): TObj;
30
30
  export declare function vercmp(l: string, r: string, loose?: boolean): number;
31
31
  /** 将 keys, values 数组按对应的顺序组合成一个对象 */
32
32
  export declare function zip_object<TValue>(keys: (string | number)[], values: TValue[]): Record<string, TValue>;
33
- /** 映射对象中的 keys, 返回新对象
34
- - obj: 对象
33
+ /** 映射数据对象 (或数组) 中的 keys, 返回新对象 (或数组)
34
+ - obj: 数据对象, 数据对象数组
35
35
  - mapper?: `to_snake_case` (key: string) => string 或者 Record<string, string> 一对一映射键
36
- - overrider?: 添加一些键到返回的新对象上 */
37
- export declare function map_keys<TReturn>(obj: any, mapper?: ((key: string) => string) | Record<string, string>, overrider?: (mapped: any) => Partial<TReturn>): TReturn;
36
+ - overrider?: 添加一些键到返回的新对象上,只对顶层有效 */
37
+ export declare function map_keys<TReturn = any>(obj: any, mapper?: ((key: string) => string) | Record<string, string>, overrider?: (mapped: any) => Partial<TReturn>, recursive?: boolean): TReturn;
38
38
  /** 返回一个映射对象 keys 的函数,通常和 .map 函数一起使用 */
39
39
  export declare function get_key_mapper<TReturn>(mapper?: ((key: string) => string) | Record<string, string>, overrider?: (mapped: any) => Partial<TReturn>): (obj: any) => TReturn;
40
40
  /** 映射对象中的 values, 返回新对象 */
package/utils.common.js CHANGED
@@ -98,16 +98,24 @@ export function zip_object(keys, values) {
98
98
  return obj;
99
99
  }, {});
100
100
  }
101
- /** 映射对象中的 keys, 返回新对象
102
- - obj: 对象
101
+ /** 映射数据对象 (或数组) 中的 keys, 返回新对象 (或数组)
102
+ - obj: 数据对象, 数据对象数组
103
103
  - mapper?: `to_snake_case` (key: string) => string 或者 Record<string, string> 一对一映射键
104
- - overrider?: 添加一些键到返回的新对象上 */
105
- export function map_keys(obj, mapper = to_snake_case, overrider) {
106
- const obj_ = Object.fromEntries(Object.entries(obj)
107
- .map(typeof mapper === 'function' ?
108
- ([key, value]) => [mapper(key), value]
104
+ - overrider?: 添加一些键到返回的新对象上,只对顶层有效 */
105
+ export function map_keys(obj, mapper = to_snake_case, overrider, recursive = false) {
106
+ if (Array.isArray(obj))
107
+ return obj.map(v => map_keys(v, mapper, overrider, recursive));
108
+ if (!obj || Object.prototype.toString.call(obj) !== '[object Object]')
109
+ return obj;
110
+ const map_key = typeof mapper === 'function' ?
111
+ mapper
109
112
  :
110
- ([key, value]) => [mapper[key] || key, value]));
113
+ (key) => mapper[key] || key;
114
+ const obj_ = Object.fromEntries(Object.entries(obj)
115
+ .map(([key, value]) => [
116
+ map_key(key),
117
+ recursive ? map_keys(value, mapper, undefined, recursive) : value
118
+ ]));
111
119
  return (overrider ? { ...obj_, ...overrider(obj_) } : obj_);
112
120
  }
113
121
  /** 返回一个映射对象 keys 的函数,通常和 .map 函数一起使用 */