xshell 1.0.133 → 1.0.135

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/apps.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import type { Readable } from 'stream';
3
2
  import type OSS from 'ali-oss';
4
3
  import { type CallOptions } from './process.js';
package/builder.d.ts CHANGED
@@ -21,7 +21,7 @@ export interface Dependency {
21
21
  devs?: string[];
22
22
  };
23
23
  }
24
- type DependencyId = 'react' | 'react-dom' | 'lodash' | 'jquery' | 'xterm' | 'swiper' | 'dayjs' | 'antd' | 'antd-icons' | 'vscode-oniguruma' | 'antd-plots' | 'gridstack' | 'quill' | 'monaco';
24
+ type DependencyId = 'react' | 'react-dom' | 'lodash' | 'jquery' | 'xterm' | 'swiper' | 'dayjs' | 'antd' | 'antd-icons' | 'vscode-oniguruma' | 'antd-plots' | 'gridstack' | 'quill' | 'monaco' | 'echarts';
25
25
  export interface HtmlBuildOptions {
26
26
  title: string;
27
27
  device_viewport?: boolean;
@@ -36,9 +36,21 @@ export interface HtmlBuildOptions {
36
36
  /** 在 index.js 之后加载 */
37
37
  after?: string[];
38
38
  };
39
+ /** 额外需要加载的 module 脚本, 在 index.js 之前 */
40
+ mscripts?: string[];
39
41
  heads?: string[];
40
42
  notice?: boolean;
41
43
  }
44
+ interface AssetOption {
45
+ /** 相对 fpd_root 的路径 */
46
+ src: string;
47
+ /** 默认为 {fpd_out}/ 加上 srcs 中的路径 */
48
+ out?: string;
49
+ }
50
+ type Assets = {
51
+ productions?: (string | AssetOption)[];
52
+ devs?: (string | AssetOption)[];
53
+ };
42
54
  export interface BundlerOptions {
43
55
  dependencies?: DependencyId[];
44
56
  source_map?: boolean;
@@ -56,18 +68,16 @@ export interface BundlerOptions {
56
68
  cache_version?: string;
57
69
  single_chunk?: boolean;
58
70
  exclude_modules?: RegExp;
71
+ assets?: Assets;
59
72
  license?: {
60
73
  ignores?: string[];
61
74
  };
62
- assets?: {
63
- productions?: string[];
64
- devs?: string[];
65
- };
66
75
  htmls?: Record<string, HtmlBuildOptions>;
67
76
  }
68
77
  export declare class Bundler {
69
78
  name: string;
70
79
  fpd_root: string;
80
+ target: 'nodejs' | 'web';
71
81
  production: boolean;
72
82
  fpd_out: string;
73
83
  source_map: boolean;
@@ -75,10 +85,7 @@ export declare class Bundler {
75
85
  analyzer: boolean;
76
86
  config: Webpack.Configuration;
77
87
  htmls?: Record<string, HtmlBuildOptions>;
78
- assets?: {
79
- productions?: string[];
80
- devs?: string[];
81
- };
88
+ assets?: Assets;
82
89
  license?: {
83
90
  ignores?: string[];
84
91
  };
@@ -97,7 +104,9 @@ export declare class Bundler {
97
104
  - externals?: 配置外部模块
98
105
  - htmls?: 配置要生成的 html, 比如 { 'index.html', { title: '文件', ... } }
99
106
  - assets?: 项目中需要直接复制到输出目录的资源,有 productions 但无 devs 时 (是同一套),
100
- 在 dev 模式下会用 productions 中的资源,如果不需要 productions 资源, devs 可以设置为 [ ]
107
+ 在 dev 模式下会用 productions 中的资源,如果不需要 productions 资源, devs 可以设置为 [ ],
108
+ 每一项是 string 或者 { src: '...', out: '...' },路径相对于 fpd_root 和 fpd_out
109
+ - local_loaders?: `true` true 时使用项目 node_modules/ 中的 loader; false 时使用 D:/0/ 下面的
101
110
  - commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
102
111
  - single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
103
112
  - dynamic_import?: `true` 对于 await import('...') 要不要打包外部模块到输出文件中
@@ -113,7 +122,8 @@ export declare class Bundler {
113
122
  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, commonjs2, single_chunk, dynamic_import, resolve_alias, assets_stats, analyzer, dts, exclude_modules, cache_version, production, sass, dependencies, license, }?: BundlerOptions);
114
123
  build(print?: boolean): Promise<void>;
115
124
  close(): Promise<void>;
116
- build_and_close(print?: boolean): Promise<void>;
125
+ build_all(print?: boolean): Promise<void>;
126
+ build_all_and_close(print?: boolean): Promise<void>;
117
127
  build_htmls(print?: {
118
128
  info: boolean;
119
129
  files: boolean;
@@ -129,10 +139,7 @@ export declare class Bundler {
129
139
  copy_files({ dependencies, production, assets, fpd_root, fpd_out, print }?: {
130
140
  dependencies?: DependencyId[];
131
141
  production?: boolean;
132
- assets?: {
133
- productions?: string[];
134
- devs?: string[];
135
- };
142
+ assets?: Assets;
136
143
  fpd_root?: string;
137
144
  fpd_out?: string;
138
145
  print?: {
@@ -144,6 +151,6 @@ export declare class Bundler {
144
151
  resolve_config(config: {
145
152
  productions?: string[];
146
153
  devs?: string[];
147
- }, production: boolean): string[];
154
+ } | Assets | undefined, production: boolean): (string | AssetOption)[];
148
155
  }
149
156
  export {};
package/builder.js CHANGED
@@ -89,11 +89,15 @@ const dependencies = {
89
89
  devs: monaco_files.filter(fp => fp.endsWith('.js') && !fp.startsWith('basic-languages/') && !fp.startsWith('language/'))
90
90
  .map(fp => `monaco-editor/dev/vs/${fp}.map`),
91
91
  }
92
+ },
93
+ echarts: {
94
+ productions: ['echarts/dist/echarts.js']
92
95
  }
93
96
  };
94
97
  export class Bundler {
95
98
  name;
96
99
  fpd_root;
100
+ target;
97
101
  production;
98
102
  fpd_out;
99
103
  source_map;
@@ -118,7 +122,9 @@ export class Bundler {
118
122
  - externals?: 配置外部模块
119
123
  - htmls?: 配置要生成的 html, 比如 { 'index.html', { title: '文件', ... } }
120
124
  - assets?: 项目中需要直接复制到输出目录的资源,有 productions 但无 devs 时 (是同一套),
121
- 在 dev 模式下会用 productions 中的资源,如果不需要 productions 资源, devs 可以设置为 [ ]
125
+ 在 dev 模式下会用 productions 中的资源,如果不需要 productions 资源, devs 可以设置为 [ ],
126
+ 每一项是 string 或者 { src: '...', out: '...' },路径相对于 fpd_root 和 fpd_out
127
+ - local_loaders?: `true` true 时使用项目 node_modules/ 中的 loader; false 时使用 D:/0/ 下面的
122
128
  - commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
123
129
  - single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
124
130
  - dynamic_import?: `true` 对于 await import('...') 要不要打包外部模块到输出文件中
@@ -135,6 +141,7 @@ export class Bundler {
135
141
  this.name = name;
136
142
  this.analyzer = analyzer;
137
143
  this.production = production;
144
+ this.target = target;
138
145
  this.fpd_root = fpd_root;
139
146
  this.fpd_out = fpd_out;
140
147
  this.source_map = source_map;
@@ -435,12 +442,25 @@ export class Bundler {
435
442
  });
436
443
  }));
437
444
  }
438
- async build_and_close(print = true) {
439
- await this.build(print);
440
- await this.close();
445
+ async build_all(print = true) {
446
+ await Promise.all([
447
+ this.build(print),
448
+ this.copy_files({ print: { info: print, files: false } }),
449
+ this.target === 'web' && this.build_htmls({ info: print, files: false })
450
+ ]);
451
+ }
452
+ async build_all_and_close(print = true) {
453
+ await Promise.all([
454
+ (async () => {
455
+ await this.build(print);
456
+ await this.close();
457
+ })(),
458
+ this.copy_files({ print: { info: print, files: false } }),
459
+ this.target === 'web' && this.build_htmls({ info: print, files: false })
460
+ ]);
441
461
  }
442
462
  async build_htmls(print = { info: true, files: false }) {
443
- await Promise.all(Object.entries(this.htmls).map(async ([fp_html, { device_viewport: device_width = false, fp_icon, fp_manifest, dependencies: _dependencies = this.dependencies, title, scripts, notice = false, heads, }]) => {
463
+ await Promise.all(Object.entries(this.htmls).map(async ([fp_html, { device_viewport: device_width = false, fp_icon, fp_manifest, dependencies: _dependencies = this.dependencies, title, scripts, mscripts, notice = false, heads, }]) => {
444
464
  const html = '<!doctype html>\n' +
445
465
  '<html>\n' +
446
466
  ' <head>\n' +
@@ -450,8 +470,9 @@ export class Bundler {
450
470
  (device_width ? " <meta name='viewport' content='width=device-width, initial-scale=1.0' />\n" : '') +
451
471
  (fp_icon ? ` <link rel='icon' href='${fp_icon}' />\n` : '') +
452
472
  (fp_manifest ? ` <link rel='manifest' href='${fp_manifest}' />\n` : '') +
453
- this.resolve_dependency_files(_dependencies, false, { production: this.production }).map(fp => ` <script src='/vendors/${fp}' defer></script>`).join_lines() +
473
+ this.resolve_dependency_files(_dependencies, false, { production: this.production }).map(fp => ` <script src='./vendors/${fp}' defer></script>`).join_lines() +
454
474
  (scripts?.before ? scripts.before.map(fp => ` <script src='${fp}' defer></script>`).join_lines() : '') +
475
+ (mscripts ? mscripts.map(fp => ` <script src='${fp}' type='module'></script>`).join_lines() : '') +
455
476
  " <script src='./index.js' type='module'></script>\n" +
456
477
  (scripts?.after ? scripts.after.map(fp => ` <script src='${fp}' defer></script>`).join_lines() : '') +
457
478
  ' </head>\n' +
@@ -505,9 +526,21 @@ export class Bundler {
505
526
  ...this.resolve_dependency_files(dependencies, true, { production })
506
527
  .map(async (fp) => fcopy(`${fpd_root}node_modules/${fp}`, `${fpd_out}vendors/${fp}`, { print: print.files })),
507
528
  ...this.resolve_config(assets, production)
508
- .map(async (fp) => fcopy(`${fpd_root}${fp}`, `${fpd_out}${fp}`, { print: print.files })),
509
- ...this.htmls ? Object.entries(this.htmls).map(async ([fp_html, { fp_icon, fp_manifest, scripts }]) => Promise.all([fp_icon, fp_manifest, ...(scripts?.before || []), ...(scripts?.after || [])]
510
- .filter(not_empty)
529
+ .map(async (asset) => {
530
+ let src, out;
531
+ if (typeof asset === 'string')
532
+ src = out = asset;
533
+ else
534
+ ({ src, out } = asset);
535
+ fcopy(`${fpd_root}${src}`, `${fpd_out}${out}`, { print: print.files });
536
+ }),
537
+ ...this.htmls ? Object.entries(this.htmls).map(async ([fp_html, { fp_icon, fp_manifest, scripts, mscripts }]) => Promise.all([
538
+ fp_icon,
539
+ fp_manifest,
540
+ ...(scripts?.before || []),
541
+ ...(scripts?.after || []),
542
+ ...(mscripts || [])
543
+ ].filter(not_empty)
511
544
  .map(fp => fcopy(path.resolve(`${fpd_root}${fp_html}`.fdir, fp), path.resolve(`${fpd_out}${fp_html}`.fdir, fp), { print: print.files })))) : []
512
545
  ]);
513
546
  }
package/file.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- /// <reference types="node" resolution-mode="require"/>
4
1
  import { promises as fsp, default as fs } from 'fs';
5
2
  type FileHandle = fsp.FileHandle & {
6
3
  fp: string;
@@ -1,9 +1,9 @@
1
1
  import { I18N } from './index.js';
2
2
  export declare let i18n: I18N;
3
3
  declare const t: (text: string, options?: {
4
- [key: string]: any;
5
4
  language?: import("./index.js").Language;
6
5
  context?: string;
7
6
  count?: number;
7
+ [key: string]: any;
8
8
  }) => string, language: import("./index.js").Language;
9
9
  export { t, language };
@@ -1,3 +1,4 @@
1
+ import { PluginItem } from '@babel/core';
1
2
  export declare let unmarkeds: any[];
2
3
  export declare function Checker({ filepath }: {
3
4
  filepath: any;
@@ -27,7 +27,7 @@ declare const DEFAULT_CONFIG: {
27
27
  context: boolean;
28
28
  contextFallback: boolean;
29
29
  contextSeparator: string;
30
- plural(language: string, ns: string, key: string, options: any /** Config */): boolean;
30
+ plural(language: string, ns: string, key: string, options: any /** Config */): language is "en";
31
31
  pluralFallback: boolean;
32
32
  pluralSeparator: string;
33
33
  interpolation: {
package/net.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
1
  import { type Readable } from 'stream';
4
2
  import type { FormData } from 'undici';
5
3
  import type { WebSocket, CloseEvent, ErrorEvent } from 'ws';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.133",
3
+ "version": "1.0.135",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -102,7 +102,7 @@
102
102
  "tough-cookie": "^4.1.4",
103
103
  "ts-loader": "^9.5.1",
104
104
  "tslib": "^2.6.3",
105
- "typescript": "^5.4.5",
105
+ "typescript": "^5.5.2",
106
106
  "ua-parser-js": "^2.0.0-beta.3",
107
107
  "undici": "^6.19.2",
108
108
  "vinyl": "^3.0.0",
@@ -125,7 +125,7 @@
125
125
  "@types/koa-compress": "^4.0.6",
126
126
  "@types/lodash": "^4.17.5",
127
127
  "@types/mime-types": "^2.1.4",
128
- "@types/node": "^20.14.6",
128
+ "@types/node": "^20.14.7",
129
129
  "@types/react": "^18.3.3",
130
130
  "@types/through2": "^2.0.41",
131
131
  "@types/tough-cookie": "^4.0.5",
package/path.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import { default as npath, type FormatInputPathObject } from 'path';
3
2
  export declare function to_fp(str: string): string;
4
3
  /** Normalize a string path, reducing '..' and '.' parts.
package/process.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- /// <reference types="node" resolution-mode="require"/>
4
1
  import { type ChildProcess } from 'child_process';
5
2
  import './prototype.js';
6
3
  import { Encoding } from './file.js';
package/prototype.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  declare global {
3
2
  var my_prototype_defined: boolean;
4
3
  interface String {
package/server.d.ts CHANGED
@@ -1,7 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- /// <reference types="node" resolution-mode="require"/>
4
- /// <reference types="node" resolution-mode="require"/>
5
1
  import { type Server as HttpServer, type IncomingHttpHeaders, type IncomingMessage } from 'http';
6
2
  import { type Http2SecureServer, type IncomingHttpHeaders as IncomingHttp2Headers } from 'http2';
7
3
  import type { Duplex } from 'stream';
@@ -5,4 +5,4 @@ export declare let toaster: {
5
5
  toast(message: string): Promise<void>;
6
6
  show(): Promise<void>;
7
7
  };
8
- export declare const toast: (message: string) => Promise<void>;
8
+ export declare const toast: (typeof toaster)["toast"];
@@ -68,7 +68,7 @@ export declare function encode(str: string): Uint8Array;
68
68
  在流式处理 (buffer 可能不完整) 时,应使用独立的 TextDecoder 实例调用 decode(buffer, { stream: true }) */
69
69
  export declare function decode(buffer: Uint8Array): string;
70
70
  /** 字符串字典序比较 */
71
- export declare function strcmp(l: string, r: string): 1 | 0 | -1;
71
+ export declare function strcmp(l: string, r: string): 0 | 1 | -1;
72
72
  /** 比较 1.10.02 这种版本号 */
73
73
  export declare function vercmp(l: string, r: string): number;
74
74
  export declare function get<TReturn = any>(obj: any, keypath: string): TReturn;
package/utils.d.ts CHANGED
@@ -1,7 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- /// <reference types="node" resolution-mode="require"/>
4
- /// <reference types="node" resolution-mode="require"/>
5
1
  import { Writable, Transform, type Readable, type Duplex, type TransformCallback } from 'stream';
6
2
  import util from 'util';
7
3
  import type { TimerOptions } from 'timers';
@@ -41,7 +37,7 @@ export declare function filter_values<TObj extends Record<string, any>>(obj: TOb
41
37
  /** 忽略对象中的 keys, 返回新对象 */
42
38
  export declare function omit<TObj>(obj: TObj, omit_keys: string[]): TObj;
43
39
  /** 字符串字典序比较 */
44
- export declare function strcmp(l: string, r: string): 1 | 0 | -1;
40
+ export declare function strcmp(l: string, r: string): 0 | 1 | -1;
45
41
  /** 比较 1.10.02 这种版本号 */
46
42
  export declare function vercmp(l: string, r: string): number;
47
43
  export declare function get<TReturn = any>(obj: any, keypath: string): TReturn;