xshell 1.2.4 → 1.2.6

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
@@ -28,13 +28,11 @@ export declare function fopen(fp: string, flags?: string | number, { mode, print
28
28
  mode: fs.Mode;
29
29
  }>;
30
30
  export declare function fread(fp: string): Promise<string>;
31
- export declare function fread(fp: string, { dir, encoding, print }?: {
32
- dir?: string;
31
+ export declare function fread(fp: string, options?: {
33
32
  encoding: 'binary';
34
33
  print?: boolean;
35
34
  }): Promise<Buffer>;
36
- export declare function fread(fp: string, { dir, encoding, print }?: {
37
- dir?: string;
35
+ export declare function fread(fp: string, options?: {
38
36
  encoding?: Encoding;
39
37
  print?: boolean;
40
38
  }): Promise<string>;
@@ -49,6 +47,9 @@ export declare function fread_json<T = any>(fp: string, options?: {
49
47
  encoding?: Encoding;
50
48
  print?: boolean;
51
49
  }): Promise<T>;
50
+ export declare function fparse<TReturn>(fp: string, options?: {
51
+ print?: boolean;
52
+ }): Promise<TReturn>;
52
53
  /** 比较两个文件是否一致,遇到任何文件系统错误都返回 false */
53
54
  export declare function fequals(fp_left: string, fp_right: string, { print }?: {
54
55
  print?: boolean;
@@ -70,6 +71,9 @@ interface FWriteOptions {
70
71
  - print?: `true` */
71
72
  export declare function fwrite(fp: string, data: string | Uint8Array | any, options?: FWriteOptions): Promise<string>;
72
73
  export declare function fwrite(fp: FileHandle, data: string | Uint8Array | any, options?: FWriteOptions): Promise<FileHandle>;
74
+ export declare function fwrite(fp: string | FileHandle, data: string | Uint8Array | any, options?: FWriteOptions): Promise<string | FileHandle>;
75
+ export declare function fpack(fp: string, data: any, options?: FWriteOptions): Promise<string>;
76
+ export declare function fpack(fp: FileHandle, data: any, options?: FWriteOptions): Promise<FileHandle>;
73
77
  /** 追加内容到文件末尾,如果文件不存在会自动创建 */
74
78
  export declare function fappend(fp: string, data: string | Uint8Array, { print }?: {
75
79
  print?: boolean;
package/file.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { promises as fsp, default as fs } from 'fs';
2
2
  import { isUint8Array } from 'util/types';
3
- import { path } from "./path.js";
4
3
  import { t } from "./i18n/instance.js";
5
4
  import { to_json } from "./prototype.js";
5
+ import { pack, parse } from "./io.js";
6
+ import { path } from "./path.js";
6
7
  import { check, Lock, WritableMemoryStream, url_width } from "./utils.js";
7
8
  export { fsp };
8
9
  export const encodings = ['utf-8', 'gb18030', 'shift-jis', 'utf-16le'];
@@ -53,6 +54,9 @@ export async function fread_lines(fp, options = {}) {
53
54
  export async function fread_json(fp, options = {}) {
54
55
  return JSON.parse(await fread(fp, options));
55
56
  }
57
+ export async function fparse(fp, options) {
58
+ return parse(await fread(fp, { ...options, encoding: 'binary' }));
59
+ }
56
60
  /** 比较两个文件是否一致,遇到任何文件系统错误都返回 false */
57
61
  export async function fequals(fp_left, fp_right, { print = true } = {}) {
58
62
  if (print)
@@ -97,6 +101,9 @@ export async function fwrite(fp, data, { print = true } = {}) {
97
101
  }
98
102
  return fp;
99
103
  }
104
+ export async function fpack(fp, data, options) {
105
+ return fwrite(fp, pack(data), options);
106
+ }
100
107
  /** 追加内容到文件末尾,如果文件不存在会自动创建 */
101
108
  export async function fappend(fp, data, { print = true } = {}) {
102
109
  check(path.isAbsolute(fp), `${t('fp 必须是绝对路径,当前为:')} ${fp}`);
package/io.browser.js CHANGED
@@ -476,9 +476,12 @@ function _pack(value) {
476
476
  }
477
477
  nkv = 0;
478
478
  for (const key in value) {
479
+ const v = value[key];
480
+ if (typeof v === 'function')
481
+ continue;
479
482
  _pack(key);
480
- _pack(value[key]);
481
- if (nkv++ > 0xffff)
483
+ _pack(v);
484
+ if (++nkv > 0xffff)
482
485
  throw new Error('对象 key 数量大于 65535,无法序列化');
483
486
  }
484
487
  if (nkv >= 16)
package/io.js CHANGED
@@ -476,9 +476,12 @@ function _pack(value) {
476
476
  }
477
477
  nkv = 0;
478
478
  for (const key in value) {
479
+ const v = value[key];
480
+ if (typeof v === 'function')
481
+ continue;
479
482
  _pack(key);
480
- _pack(value[key]);
481
- if (nkv++ > 0xffff)
483
+ _pack(v);
484
+ if (++nkv > 0xffff)
482
485
  throw new Error('对象 key 数量大于 65535,无法序列化');
483
486
  }
484
487
  if (nkv >= 16)
package/net.d.ts CHANGED
@@ -66,10 +66,10 @@ export interface RequestFullOptions extends RequestOptions {
66
66
  export interface RequestRawOptions extends RequestOptions {
67
67
  raw: true;
68
68
  }
69
- export interface RequestError extends Error {
69
+ export interface RequestError<TBody extends string | Buffer = string> extends Error {
70
70
  url: URL;
71
71
  options: RequestOptions | RequestFullOptions | RequestRawOptions;
72
- response?: FullResponse<string>;
72
+ response?: FullResponse<TBody>;
73
73
  [inspect.custom]: Function;
74
74
  }
75
75
  export interface StatusCodeError {
package/net.js CHANGED
@@ -245,7 +245,9 @@ export async function request(url, options = {}) {
245
245
  value: {
246
246
  status: response.status,
247
247
  headers: response.headers,
248
- body: await stream_to_text(response.body),
248
+ body: decode
249
+ ? await stream_to_text(response.body)
250
+ : await stream_to_buffer(response.body),
249
251
  }
250
252
  }
251
253
  } : {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -60,16 +60,10 @@
60
60
  "@typescript-eslint/eslint-plugin": "^8.20.0",
61
61
  "@typescript-eslint/parser": "^8.20.0",
62
62
  "@typescript-eslint/utils": "^8.20.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
63
  "archiver": "^7.0.1",
68
64
  "chalk": "^5.4.1",
69
- "chardet": "^2.0.0",
70
65
  "cli-table3": "^0.6.5",
71
66
  "cli-truncate": "^4.0.0",
72
- "colors": "^1.4.0",
73
67
  "commander": "^13.0.0",
74
68
  "css-loader": "^7.1.2",
75
69
  "emoji-regex": "^10.4.0",
@@ -77,7 +71,6 @@
77
71
  "eslint-plugin-import": "^2.31.0",
78
72
  "eslint-plugin-react": "^7.37.4",
79
73
  "gulp-sort": "^2.0.0",
80
- "hash-string": "^1.0.0",
81
74
  "https-proxy-agent": "^7.0.6",
82
75
  "i18next": "^24.2.1",
83
76
  "i18next-scanner": "^4.6.0",
@@ -103,7 +96,7 @@
103
96
  "tslib": "^2.8.1",
104
97
  "typescript": "^5.7.3",
105
98
  "ua-parser-js": "^2.0.0",
106
- "undici": "^7.2.1",
99
+ "undici": "^7.2.2",
107
100
  "vinyl": "^3.0.0",
108
101
  "vinyl-fs": "^4.0.0",
109
102
  "webpack": "^5.97.1",
@@ -114,7 +107,6 @@
114
107
  "@babel/types": "^7.26.5",
115
108
  "@types/archiver": "^6.0.3",
116
109
  "@types/babel__traverse": "^7.20.6",
117
- "@types/chardet": "^1.0.0",
118
110
  "@types/eslint": "^9.6.1",
119
111
  "@types/estree": "^1.0.6",
120
112
  "@types/gulp-sort": "^2.0.4",
@@ -122,7 +114,7 @@
122
114
  "@types/koa-compress": "^4.0.6",
123
115
  "@types/lodash": "^4.17.14",
124
116
  "@types/mime-types": "^2.1.4",
125
- "@types/node": "^22.10.6",
117
+ "@types/node": "^22.10.7",
126
118
  "@types/react": "^19.0.7",
127
119
  "@types/through2": "^2.0.41",
128
120
  "@types/tough-cookie": "^4.0.5",
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;