xshell 1.0.176 → 1.0.179

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/builder.d.ts CHANGED
@@ -74,6 +74,7 @@ export interface BundlerOptions {
74
74
  exclude_modules?: RegExp;
75
75
  assets?: Assets;
76
76
  assets_root?: string;
77
+ template?: boolean;
77
78
  license?: {
78
79
  ignores?: string[];
79
80
  };
@@ -91,7 +92,8 @@ export declare class Bundler {
91
92
  config: Webpack.Configuration;
92
93
  htmls?: Record<string, HtmlOptions>;
93
94
  assets?: Assets;
94
- assets_root?: string;
95
+ assets_root: string;
96
+ template: boolean;
95
97
  globals?: BundlerOptions['globals'];
96
98
  exclude_modules?: BundlerOptions['exclude_modules'];
97
99
  license?: {
@@ -114,9 +116,10 @@ export declare class Bundler {
114
116
  - assets?: 项目中需要直接复制到输出目录的资源,有 productions 但无 devs 时 (是同一套),
115
117
  在 dev 模式下会用 productions 中的资源,如果不需要 productions 资源, devs 可以设置为 [ ],
116
118
  每一项是 string 或者 { src: '...', out: '...' },路径相对于 fpd_root 和 fpd_out
117
- - assets_root?: `''` 生成的 html 中是否使用 / 开头的绝对路径,以支持 browser router 路由能力
119
+ - assets_root?: `'/'` 生成的 html 中是否使用 / 开头的绝对路径,以支持 browser router 路由能力
118
120
  启用后 assets, html 中的 icon, scripts 路径直接在前面添加 assets_root 来生成最终 html href
119
121
  未启用时使用相对 html 路径来生成最终 html href
122
+ - template?: `false` 除了生成对应的 html 之外,还生成所有路径为 `{root}/...` 的模板 html 文件, 方便后续 server 替换渲染
120
123
  - local_loaders?: `true` true 时使用项目 node_modules/ 中的 loader; false 时使用 D:/0/ 下面的
121
124
  - commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
122
125
  - single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
@@ -131,7 +134,7 @@ export declare class Bundler {
131
134
  - production?: `true` webpack mode 设置为 'production'
132
135
  - sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
133
136
  - license?: 使用 license-webpack-plugin 构建 ThirdPartyNotice.txt */
134
- constructor(name: string, target: 'web' | 'nodejs', fpd_root: string, fpd_out: string, fpdt_cache: string, entry: Record<string, string>, { source_map, globals, external_dayjs, externals, htmls, assets, assets_root, commonjs2, single_chunk, dynamic_import, resolve_alias, resolve_fallback, assets_stats, analyzer, dts, exclude_modules, cache_version, production, sass, dependencies, license, }?: BundlerOptions);
137
+ constructor(name: string, target: 'web' | 'nodejs', fpd_root: string, fpd_out: string, fpdt_cache: string, entry: Record<string, string>, { source_map, globals, external_dayjs, externals, htmls, assets, assets_root, template, commonjs2, single_chunk, dynamic_import, resolve_alias, resolve_fallback, assets_stats, analyzer, dts, exclude_modules, cache_version, production, sass, dependencies, license, }?: BundlerOptions);
135
138
  build(print?: boolean): Promise<void>;
136
139
  close(): Promise<void>;
137
140
  build_all(print?: boolean): Promise<void>;
package/builder.js CHANGED
@@ -5,14 +5,15 @@ import { fcopy, fmkdir, fwrite } from './file.js';
5
5
  import { path } from './path.js';
6
6
  const monaco_files = [
7
7
  'loader.js',
8
+ 'nls.messages.zh-cn.js',
8
9
  'editor/editor.main.js',
9
10
  'editor/editor.main.css',
10
- 'editor/editor.main.nls.js',
11
- 'editor/editor.main.nls.zh-cn.js',
12
- 'base/common/worker/simpleWorker.nls.js',
13
11
  'base/worker/workerMain.js',
14
12
  'base/browser/ui/codicons/codicon/codicon.ttf',
15
13
  ...['python', 'javascript', 'typescript', 'css', 'html', 'cpp', 'sql', 'scss', 'shell'].map(language => `basic-languages/${language}/${language}.js`),
14
+ // 太大了,先不加
15
+ // 'language/typescript/tsMode.js',
16
+ // 'language/typescript/tsWorker.js',
16
17
  ];
17
18
  const dependencies = {
18
19
  react: {
@@ -83,8 +84,12 @@ const dependencies = {
83
84
  devs: monaco_files.map(fp => `monaco-editor/dev/vs/${fp}`)
84
85
  },
85
86
  maps: {
86
- productions: monaco_files.filter(fp => fp.endsWith('.js') && !fp.startsWith('basic-languages/') && !fp.startsWith('language/'))
87
- .map(fp => `monaco-editor/min-maps/vs/${fp}.map`),
87
+ productions: [
88
+ 'monaco-editor/min-maps/vs/base/worker/workerMain.js.map',
89
+ 'monaco-editor/min-maps/vs/editor/editor.main.js.map',
90
+ 'monaco-editor/min-maps/vs/loader.js.map',
91
+ 'monaco-editor/min-maps/nls.messages.zh-cn.js.map',
92
+ ],
88
93
  devs: [
89
94
  'monaco-editor/dev/vs/base/worker/workerMain.js.map',
90
95
  'monaco-editor/dev/vs/editor/editor.main.js.map',
@@ -112,6 +117,7 @@ export class Bundler {
112
117
  htmls;
113
118
  assets;
114
119
  assets_root;
120
+ template;
115
121
  globals;
116
122
  exclude_modules;
117
123
  license;
@@ -132,9 +138,10 @@ export class Bundler {
132
138
  - assets?: 项目中需要直接复制到输出目录的资源,有 productions 但无 devs 时 (是同一套),
133
139
  在 dev 模式下会用 productions 中的资源,如果不需要 productions 资源, devs 可以设置为 [ ],
134
140
  每一项是 string 或者 { src: '...', out: '...' },路径相对于 fpd_root 和 fpd_out
135
- - assets_root?: `''` 生成的 html 中是否使用 / 开头的绝对路径,以支持 browser router 路由能力
141
+ - assets_root?: `'/'` 生成的 html 中是否使用 / 开头的绝对路径,以支持 browser router 路由能力
136
142
  启用后 assets, html 中的 icon, scripts 路径直接在前面添加 assets_root 来生成最终 html href
137
143
  未启用时使用相对 html 路径来生成最终 html href
144
+ - template?: `false` 除了生成对应的 html 之外,还生成所有路径为 `{root}/...` 的模板 html 文件, 方便后续 server 替换渲染
138
145
  - local_loaders?: `true` true 时使用项目 node_modules/ 中的 loader; false 时使用 D:/0/ 下面的
139
146
  - commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
140
147
  - single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
@@ -149,7 +156,7 @@ export class Bundler {
149
156
  - production?: `true` webpack mode 设置为 'production'
150
157
  - sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
151
158
  - license?: 使用 license-webpack-plugin 构建 ThirdPartyNotice.txt */
152
- constructor(name, target, fpd_root, fpd_out, fpdt_cache, entry, { source_map = true, globals, external_dayjs = false, externals, htmls, assets, assets_root = '', commonjs2 = false, single_chunk = true, dynamic_import = true, resolve_alias, resolve_fallback, assets_stats = true, analyzer = false, dts = false, exclude_modules, cache_version, production = true, sass, dependencies, license, } = {}) {
159
+ constructor(name, target, fpd_root, fpd_out, fpdt_cache, entry, { source_map = true, globals, external_dayjs = false, externals, htmls, assets, assets_root = '/', template = false, commonjs2 = false, single_chunk = true, dynamic_import = true, resolve_alias, resolve_fallback, assets_stats = true, analyzer = false, dts = false, exclude_modules, cache_version, production = true, sass, dependencies, license, } = {}) {
153
160
  this.name = name;
154
161
  this.analyzer = analyzer;
155
162
  this.production = production;
@@ -160,6 +167,7 @@ export class Bundler {
160
167
  this.htmls = htmls;
161
168
  this.assets = assets;
162
169
  this.assets_root = assets_root;
170
+ this.template = template;
163
171
  this.globals = globals;
164
172
  this.exclude_modules = exclude_modules;
165
173
  if (dependencies) {
@@ -170,9 +178,7 @@ export class Bundler {
170
178
  // let smp = new SpeedMeasurePlugin()
171
179
  // const config: Webpack.Configuration = smp.wrap({
172
180
  let resolve_cache = {};
173
- function get_loader(name) {
174
- return resolve_cache[name] ??= fileURLToPath(import.meta.resolve(`${name}/package.json`)).fdir;
175
- }
181
+ const get_loader = (name) => resolve_cache[name] ??= fileURLToPath(import.meta.resolve(`${name}/package.json`)).fdir;
176
182
  this.config = {
177
183
  name,
178
184
  mode: production ? 'production' : 'development',
@@ -487,27 +493,22 @@ export class Bundler {
487
493
  ]);
488
494
  }
489
495
  async build_htmls(print = { info: true, files: false }) {
490
- const root = this.assets_root || './';
491
- await Promise.all(Object.entries(this.htmls).map(async ([fp_html, { fp_entry = `${root}index.js`, device_viewport: device_width = false, icon, manifest, dependencies: _dependencies = this.dependencies, title, scripts, mscripts, notice = false, heads, }]) => {
492
- const fpd_html = `${this.fpd_out}${fp_html}`.fdir;
493
- const resolve = (asset) => this.assets_root ?
494
- `${this.assets_root}${typeof asset === 'string' ? asset : asset.out}`
495
- :
496
- path.relative(fpd_html, `${this.fpd_out}${typeof asset === 'string' ? asset : asset.out}`);
497
- const html = '<!doctype html>\n' +
496
+ await Promise.all(Object.entries(this.htmls).map(async ([fp_html, { fp_entry = 'index.js', device_viewport: device_width = false, icon, manifest, dependencies: _dependencies = this.dependencies, title, scripts, mscripts, notice = false, heads, }]) => {
497
+ const get = (asset) => typeof asset === 'string' ? asset : asset.out;
498
+ const html_template = '<!doctype html>\n' +
498
499
  '<html>\n' +
499
500
  ' <head>\n' +
500
501
  ` <title>${title}</title>\n` +
501
502
  " <meta charset='utf-8' />\n" +
502
503
  (heads ? heads.map(head => ` ${head}`).join_lines() : '') +
503
504
  (device_width ? " <meta name='viewport' content='width=device-width, initial-scale=1.0' />\n" : '') +
504
- (icon ? ` <link rel='icon' href='${resolve(icon)}' />\n` : '') +
505
- (manifest ? ` <link rel='manifest' href='${resolve(manifest)}' />\n` : '') +
506
- this.resolve_dependency_files(_dependencies, false, { production: this.production }).map(fp => ` <script src='${root}vendors/${fp}' defer></script>`).join_lines() +
507
- (scripts?.before ? scripts.before.map(asset => ` <script src='${resolve(asset)}' defer></script>`).join_lines() : '') +
508
- (mscripts ? mscripts.map(mscript => ` <script src='${resolve(mscript)}' type='module'></script>`).join_lines() : '') +
509
- ` <script src='${fp_entry}' type='module'></script>\n` +
510
- (scripts?.after ? scripts.after.map(asset => ` <script src='${resolve(asset)}' defer></script>`).join_lines() : '') +
505
+ (icon ? ` <link rel='icon' href='{root}${icon}' />\n` : '') +
506
+ (manifest ? ` <link rel='manifest' href='{root}${manifest}' />\n` : '') +
507
+ this.resolve_dependency_files(_dependencies, false, { production: this.production }).map(fp => ` <script src='{root}vendors/${fp}' defer></script>`).join_lines() +
508
+ (scripts?.before ? scripts.before.map(asset => ` <script src='{root}${get(asset)}' defer></script>`).join_lines() : '') +
509
+ (mscripts ? mscripts.map(mscript => ` <script src='{root}${get(mscript)}' type='module'></script>`).join_lines() : '') +
510
+ ` <script src='{root}${fp_entry}' type='module'></script>\n` +
511
+ (scripts?.after ? scripts.after.map(asset => ` <script src='{root}${get(asset)}' defer></script>`).join_lines() : '') +
511
512
  ' </head>\n' +
512
513
  ' <body>\n' +
513
514
  " <div class='root'>\n" +
@@ -518,7 +519,10 @@ export class Bundler {
518
519
  ' </div>\n' +
519
520
  ' </body>\n' +
520
521
  '</html>\n';
521
- await fwrite(`${this.fpd_out}${fp_html}`, html, noprint);
522
+ await Promise.all([
523
+ fwrite(`${this.fpd_out}${fp_html}`, html_template.replaceAll('{root}', this.assets_root), noprint),
524
+ this.template && fwrite(`${this.fpd_out}${fp_html.strip_end('.html', true)}.template.html`, html_template, noprint)
525
+ ]);
522
526
  if (print.files)
523
527
  console.log(`已构建 ${fp_html}`);
524
528
  }));
package/file.d.ts CHANGED
@@ -176,12 +176,13 @@ export declare function fmkdir(fpd: string, { print, mode, }?: {
176
176
  /** `0o777` A file mode. If a string is passed, it is parsed as an octal integer. */
177
177
  mode?: string | number;
178
178
  }): Promise<string>;
179
- /** 创建软链接 Create soft links
180
- - fp_real: 现在真实文件/文件夹的路径 current real file/directory path
181
- - fp_link: 目标链接文件/文件夹的路径 target file/directory path */
182
- export declare function flink(fp_real: string, fp_link: string, { junction, print }?: {
179
+ /** 创建软链接
180
+ - fp_real: 现在真实文件/文件夹的路径
181
+ - fp_link: 目标链接文件/文件夹的路径 */
182
+ export declare function flink(fp_real: string, fp_link: string, { junction, print, skip_existing }?: {
183
183
  junction?: boolean;
184
184
  print?: boolean;
185
+ skip_existing?: boolean;
185
186
  }): Promise<void>;
186
187
  export interface ZipOptions {
187
188
  dirname?: string;
package/file.js CHANGED
@@ -372,22 +372,27 @@ export async function fmkdir(fpd, { print = true, mode, } = {}) {
372
372
  console.log(t('已存在文件夹'), fpd);
373
373
  return fpd_;
374
374
  }
375
- /** 创建软链接 Create soft links
376
- - fp_real: 现在真实文件/文件夹的路径 current real file/directory path
377
- - fp_link: 目标链接文件/文件夹的路径 target file/directory path */
378
- export async function flink(fp_real, fp_link, { junction = false, print = true } = {}) {
379
- assert(path.isAbsolute(fp_real) && path.isAbsolute(fp_link), t('fp 必须是绝对路径'));
375
+ /** 创建软链接
376
+ - fp_real: 现在真实文件/文件夹的路径
377
+ - fp_link: 目标链接文件/文件夹的路径 */
378
+ export async function flink(fp_real, fp_link, { junction = false, print = true, skip_existing = false } = {}) {
379
+ assert(path.isAbsolute(fp_real) && path.isAbsolute(fp_link), 'fp 必须是绝对路径');
380
380
  const is_fpd_real = fp_real.isdir;
381
381
  const is_fpd_link = fp_link.isdir;
382
- assert(is_fpd_real === is_fpd_link, t('fp_real 和 fp_link 必须同为文件路径或文件夹路径'));
383
- if (fexists(fp_link))
384
- throw new Error(`${t('存在同名')}${is_fpd_link ? t('文件夹') : t('文件')}: ${fp_link}${t(',无法创建链接')}`);
382
+ assert(is_fpd_real === is_fpd_link, 'fp_real 和 fp_link 必须同为文件路径或文件夹路径');
383
+ if (fexists(fp_link, { print: false }))
384
+ if (!skip_existing)
385
+ throw new Error(`存在同名${is_fpd_link ? '文件夹' : '文件'}: ${fp_link},无法创建链接`);
386
+ else {
387
+ console.log('跳过已存在: ', fp_link);
388
+ return;
389
+ }
385
390
  if (print)
386
- console.log(`${t('已将源文件 ')}${fp_real}${t(' 链接到 ')}${fp_link}`);
391
+ console.log(`已将源文件 ${fp_real} 链接到 ${fp_link}`);
387
392
  if (junction)
388
- fsp.symlink(fp_real, fp_link, 'junction');
393
+ await fsp.symlink(fp_real, fp_link, 'junction');
389
394
  else
390
- fsp.symlink(fp_real, fp_link, is_fpd_real ? 'dir' : 'file');
395
+ await fsp.symlink(fp_real, fp_link, is_fpd_real ? 'dir' : 'file');
391
396
  }
392
397
  /** 将文件夹或文件列表压缩为 zip,返回生成的压缩包路径 (fp_zip)
393
398
  - data:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.176",
3
+ "version": "1.0.179",
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.25.2",
53
- "@babel/parser": "^7.25.6",
54
- "@babel/traverse": "^7.25.6",
52
+ "@babel/core": "^7.25.8",
53
+ "@babel/parser": "^7.25.8",
54
+ "@babel/traverse": "^7.25.7",
55
55
  "@koa/cors": "^5.0.0",
56
- "@stylistic/eslint-plugin": "^2.8.0",
56
+ "@stylistic/eslint-plugin": "^2.9.0",
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.7.0",
61
- "@typescript-eslint/parser": "^8.7.0",
62
- "@typescript-eslint/utils": "^8.7.0",
60
+ "@typescript-eslint/eslint-plugin": "^8.9.0",
61
+ "@typescript-eslint/parser": "^8.9.0",
62
+ "@typescript-eslint/utils": "^8.9.0",
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",
@@ -75,14 +75,14 @@
75
75
  "commander": "^12.1.0",
76
76
  "css-loader": "^7.1.2",
77
77
  "emoji-regex": "^10.4.0",
78
- "eslint": "^9.11.1",
79
- "eslint-plugin-import": "^2.30.0",
80
- "eslint-plugin-react": "^7.37.0",
78
+ "eslint": "^9.12.0",
79
+ "eslint-plugin-import": "^2.31.0",
80
+ "eslint-plugin-react": "^7.37.1",
81
81
  "gulp-sort": "^2.0.0",
82
82
  "hash-string": "^1.0.0",
83
83
  "https-proxy-agent": "^7.0.5",
84
- "i18next": "^23.15.1",
85
- "i18next-scanner": "^4.5.0",
84
+ "i18next": "^23.16.0",
85
+ "i18next-scanner": "^4.6.0",
86
86
  "koa": "^2.15.3",
87
87
  "koa-compress": "^5.1.1",
88
88
  "license-webpack-plugin": "^4.0.2",
@@ -91,10 +91,10 @@
91
91
  "mime-types": "^2.1.35",
92
92
  "ora": "^8.1.0",
93
93
  "react": "^18.3.1",
94
- "react-i18next": "^15.0.2",
94
+ "react-i18next": "^15.0.3",
95
95
  "react-object-model": "^1.2.13",
96
96
  "resolve-path": "^1.4.0",
97
- "sass": "^1.79.4",
97
+ "sass": "^1.79.5",
98
98
  "sass-loader": "^16.0.2",
99
99
  "source-map-loader": "^5.0.0",
100
100
  "strip-ansi": "^7.1.0",
@@ -103,9 +103,9 @@
103
103
  "tough-cookie": "^5.0.0-rc.4",
104
104
  "ts-loader": "^9.5.1",
105
105
  "tslib": "^2.7.0",
106
- "typescript": "^5.6.2",
106
+ "typescript": "^5.6.3",
107
107
  "ua-parser-js": "^2.0.0-beta.3",
108
- "undici": "^6.19.8",
108
+ "undici": "^6.20.1",
109
109
  "vinyl": "^3.0.0",
110
110
  "vinyl-fs": "^4.0.0",
111
111
  "webpack": "^5.95.0",
@@ -113,7 +113,7 @@
113
113
  "ws": "^8.18.0"
114
114
  },
115
115
  "devDependencies": {
116
- "@babel/types": "^7.25.6",
116
+ "@babel/types": "^7.25.8",
117
117
  "@types/ali-oss": "^6.16.11",
118
118
  "@types/archiver": "^6.0.2",
119
119
  "@types/babel__traverse": "^7.20.6",
@@ -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.9",
127
+ "@types/lodash": "^4.17.10",
128
128
  "@types/mime-types": "^2.1.4",
129
- "@types/node": "^22.7.4",
130
- "@types/react": "^18.3.10",
129
+ "@types/node": "^22.7.5",
130
+ "@types/react": "^18.3.11",
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.93.0",
135
+ "@types/vscode": "^1.94.0",
136
136
  "@types/webpack-bundle-analyzer": "^4.7.0"
137
137
  },
138
138
  "pnpm": {
package/path.d.ts CHANGED
@@ -55,7 +55,7 @@ export declare function extname(path: string): string;
55
55
  /** `/` */
56
56
  export declare const sep = "/";
57
57
  /** The platform-specific file delimiter. ';' or ':'. */
58
- export declare const delimiter: ":" | ";";
58
+ export declare const delimiter: ";" | ":";
59
59
  /** Returns an object from a path string - the opposite of format().
60
60
  @param path path to evaluate.
61
61
  @throws {TypeError} if `path` is not a string. */
@@ -83,7 +83,7 @@ export declare let path: {
83
83
  basename: typeof basename;
84
84
  extname: typeof extname;
85
85
  sep: string;
86
- delimiter: ":" | ";";
86
+ delimiter: ";" | ":";
87
87
  parse: typeof parse;
88
88
  format: typeof format;
89
89
  toNamespacedPath: typeof toNamespacedPath;
package/server.d.ts CHANGED
@@ -52,6 +52,7 @@ export declare class Server {
52
52
  stdio_subscribable?: boolean;
53
53
  stdio_subscribers: (((chunk: Uint8Array | string) => Promise<void>) & {
54
54
  id: number;
55
+ closer: (event: any) => void;
55
56
  })[];
56
57
  /** 原始 process.stdout.write 函数 bind 后的备份 */
57
58
  stdout_write: Function;
package/server.js CHANGED
@@ -167,18 +167,27 @@ export class Server {
167
167
  };
168
168
  // 让后续可以通过 unsubscribe_stdio 取消订阅
169
169
  subscriber.id = id;
170
- this.stdio_subscribers.push(subscriber);
171
- websocket.addEventListener('close', () => {
170
+ const closer = subscriber.closer = () => {
172
171
  const length = this.stdio_subscribers.length;
173
172
  const stdio_subscribers_ = this.stdio_subscribers.filter(s => s !== subscriber);
174
173
  if (stdio_subscribers_.length !== length) {
175
- console.log(t('由于 websocket 连接关闭,stdio 订阅被关闭'));
174
+ console.log('由于 websocket 连接关闭,stdio 订阅被关闭');
176
175
  this.stdio_subscribers = stdio_subscribers_;
177
176
  }
178
- }, { once: true });
177
+ };
178
+ this.stdio_subscribers.push(subscriber);
179
+ websocket.addEventListener('close', closer, { once: true });
179
180
  },
181
+ /** 主动取消订阅,需要清理 stdio listener, websocket close lisener */
180
182
  unsubscribe_stdio: ({ data: [id] }, websocket) => {
181
- this.stdio_subscribers = this.stdio_subscribers.filter(s => s.id !== id);
183
+ this.stdio_subscribers = this.stdio_subscribers.filter(s => {
184
+ if (s.id === id) {
185
+ websocket.removeEventListener('close', s.closer);
186
+ return false;
187
+ }
188
+ else
189
+ return true;
190
+ });
182
191
  console.log(t('已取消订阅 stdio'));
183
192
  return [];
184
193
  },
@@ -75,7 +75,7 @@ export declare function encode(str: string): Uint8Array;
75
75
  在流式处理 (buffer 可能不完整) 时,应使用独立的 TextDecoder 实例调用 decode(buffer, { stream: true }) */
76
76
  export declare function decode(buffer: Uint8Array): string;
77
77
  /** 字符串字典序比较 */
78
- export declare function strcmp(l: string, r: string): 0 | 1 | -1;
78
+ export declare function strcmp(l: string, r: string): 1 | 0 | -1;
79
79
  /** 比较 1.10.02 这种版本号
80
80
  - l, r: 两个版本号字符串
81
81
  - loose?: 宽松模式,允许两个版本号格式(位数)不一致 */
package/utils.d.ts CHANGED
@@ -42,7 +42,7 @@ export declare function filter_values<TObj extends Record<string, any>>(obj: TOb
42
42
  /** 忽略对象中的 keys, 返回新对象 */
43
43
  export declare function omit<TObj>(obj: TObj, omit_keys: string[]): TObj;
44
44
  /** 字符串字典序比较 */
45
- export declare function strcmp(l: string, r: string): 0 | 1 | -1;
45
+ export declare function strcmp(l: string, r: string): 1 | 0 | -1;
46
46
  /** 比较 1.10.02 这种版本号
47
47
  - l, r: 两个版本号字符串
48
48
  - loose?: 宽松模式,允许两个版本号格式(位数)不一致 */