xshell 1.2.41 → 1.2.43

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
@@ -5,7 +5,7 @@ export declare let npm: {
5
5
  /** node.exe E:/sdk/nodejs/node_modules/corepack/dist/pnpm.js install
6
6
  - cwd
7
7
  - pkgs?: `[ ]` */
8
- install(cwd: string, pkgs?: string[], { save_dev, save_peer, legacy, force, break: _break, }?: {
8
+ install(fpd: string, pkgs?: string[], { save_dev, save_peer, legacy, force, break: _break, }?: {
9
9
  save_dev?: boolean;
10
10
  save_peer?: boolean;
11
11
  legacy?: boolean;
package/apps.js CHANGED
@@ -8,7 +8,7 @@ export let npm = {
8
8
  /** node.exe E:/sdk/nodejs/node_modules/corepack/dist/pnpm.js install
9
9
  - cwd
10
10
  - pkgs?: `[ ]` */
11
- async install(cwd, pkgs = [], { save_dev = false, save_peer = false, legacy = false, force = false, break: _break = false, } = {}) {
11
+ async install(fpd, pkgs = [], { save_dev = false, save_peer = false, legacy = false, force = false, break: _break = false, } = {}) {
12
12
  const args = [
13
13
  'install',
14
14
  ...util.inspect.defaultOptions.colors ? ['--color'] : [],
@@ -18,7 +18,7 @@ export let npm = {
18
18
  ...save_peer ? ['--save-peer'] : [],
19
19
  ...pkgs || []
20
20
  ];
21
- await this.call(cwd, this.bin, args);
21
+ await this.call(fpd, this.bin, args);
22
22
  }
23
23
  };
24
24
  //# sourceMappingURL=apps.js.map
package/builder.d.ts CHANGED
@@ -48,10 +48,6 @@ export interface HtmlOptions {
48
48
  heads?: string[];
49
49
  notice?: boolean;
50
50
  }
51
- export interface SingleJsConfig {
52
- js: string;
53
- entry: string;
54
- }
55
51
  interface AssetOption {
56
52
  /** 相对 fpd_root 的路径,或者绝对路径 */
57
53
  src: string;
@@ -68,7 +64,6 @@ export interface BundlerOptions {
68
64
  production?: boolean;
69
65
  external_dayjs?: boolean;
70
66
  externals?: Record<string, string | string[]>;
71
- sass?: typeof import('sass');
72
67
  dynamic_import?: boolean;
73
68
  commonjs2?: boolean;
74
69
  expose?: boolean;
@@ -95,24 +90,37 @@ export interface BundlerOptions {
95
90
  }
96
91
  export declare class Bundler {
97
92
  name: string;
98
- fpd_root: string;
99
93
  target: 'nodejs' | 'web';
100
- production: boolean;
94
+ fpd_root: string;
101
95
  fpd_out: string;
102
- source_map: BundlerOptions['source_map'];
96
+ fpdt_cache: string;
97
+ entry: Record<string, string>;
98
+ production: boolean;
103
99
  dependencies: DependencyId[];
104
- analyzer: boolean;
105
- config: Webpack.Configuration;
106
- htmls?: Record<string, HtmlOptions>;
100
+ source_map: boolean;
101
+ globals?: BundlerOptions['globals'];
102
+ external_dayjs: boolean;
103
+ externals: BundlerOptions['externals'];
104
+ htmls?: BundlerOptions['htmls'];
107
105
  assets?: Assets;
108
106
  assets_root: string;
109
107
  template: boolean;
110
108
  single_js?: BundlerOptions['single_js'];
111
- globals?: BundlerOptions['globals'];
109
+ commonjs2: boolean;
110
+ expose: boolean;
111
+ single_chunk: boolean;
112
+ dynamic_import: boolean;
113
+ resolve_alias?: BundlerOptions['resolve_alias'];
114
+ resolve_fallback?: BundlerOptions['resolve_fallback'];
115
+ assets_stats: boolean;
116
+ analyzer: boolean;
117
+ dts: boolean;
112
118
  exclude_modules?: BundlerOptions['exclude_modules'];
119
+ cache_version?: string;
113
120
  plugins?: BundlerOptions['plugins'];
114
121
  license?: boolean;
115
122
  polyfill_node_sea?: boolean;
123
+ config: Webpack.Configuration;
116
124
  lcompiler: Lock<Webpack.Compiler>;
117
125
  /** 通过 webpack 从入口文件打包所有依赖生成单个 index.{mjs,cjs} 文件
118
126
  - name: 项目名称
@@ -122,6 +130,8 @@ export declare class Bundler {
122
130
  - fpd_cache: webpack 缓存目录
123
131
  - entry: 入口文件
124
132
  - options?: 打包配置, 按常用顺序排列
133
+ - production?: `true` webpack mode 设置为 'production'
134
+ - dependencies?: DependencyId[], 决定 bundler 在 build_all (copy_files) 时需要复制到 fpd_out 的资源
125
135
  - source_map?: `true` 启用源码映射 .map 文件
126
136
  - globals?: 全局变量定义
127
137
  - external_dayjs?: `false` 配置 dayjs 为 external 来配合 antd 使用, 减小一点体积
@@ -130,14 +140,13 @@ export declare class Bundler {
130
140
  - assets?: 项目中需要直接复制到输出目录的资源,有 productions 但无 devs 时 (是同一套),
131
141
  在 dev 模式下会用 productions 中的资源,如果不需要 productions 资源, devs 可以设置为 [ ],
132
142
  每一项是 string 或者 { src: '...', out: '...' },路径相对于 fpd_root 和 fpd_out
133
- - assets_root?: `'/'` 生成的 html 中是否使用 / 开头的绝对路径,以支持 browser router 路由能力
134
- 启用后 assets, html 中的 icon, scripts 路径直接在前面添加 assets_root 来生成最终 html href
143
+ - assets_root?: `'/'` 生成的 html 中替换 {root} 作为部署路径,以支持 browser router 路由能力
144
+ assets, html 中的 icon, scripts 路径直接在前面添加 assets_root 来生成最终 html href
135
145
  未启用时使用相对 html 路径来生成最终 html href
136
146
  - template?: `false` 除了生成对应的 html 之外,还生成所有路径为 `{root}/...` 的模板 html 文件, 方便后续 server 替换渲染
137
147
  - single_js?: 设置生成的单个 js 入口文件,无其他依赖,通过 script module 作为入口加载,含有 import 加载其他 externals 和某个 entry,类似 htmls 配置要生成的 html
138
148
  - js: js 入口文件名
139
149
  - entry: 使用的 entry
140
- - local_loaders?: `true` true 时使用项目 node_modules/ 中的 loader; false 时使用 D:/0/ 下面的
141
150
  - commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
142
151
  - expose?: `false` 入口模块所有导出的属性赋值到全局对象 globalThis 上
143
152
  - single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
@@ -149,12 +158,10 @@ export declare class Bundler {
149
158
  - dts?: `false` 生成 .d.ts 文件
150
159
  - exclude_modules?: 传入正则表达式 ,匹配时使用 IgnorePlugin 强制不打包这个模块,但是一旦导入就会报错
151
160
  - cache_version?: webpack cache version, 用于区分同一个 name 的不同版本
152
- - production?: `true` webpack mode 设置为 'production'
153
- - sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
154
161
  - plugins?: 可选传入的额外的 webpack 插件
155
162
  - license?: 使用 license-webpack-plugin 构建 ThirdPartyNotice.txt
156
163
  - polyfill_node_sea?: 避免依赖 node:sea 模块以兼容旧版本 node.js */
157
- 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, single_js, commonjs2, expose, single_chunk, dynamic_import, resolve_alias, resolve_fallback, assets_stats, analyzer, dts, exclude_modules, cache_version, production, sass, dependencies, plugins, license, polyfill_node_sea }?: BundlerOptions);
164
+ constructor(name: string, target: 'web' | 'nodejs', fpd_root: string, fpd_out: string, fpdt_cache: string, entry: Record<string, string>, options?: BundlerOptions);
158
165
  build(print?: boolean): Promise<void>;
159
166
  close(): Promise<void>;
160
167
  build_all(print?: boolean): Promise<void>;
package/builder.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { fileURLToPath } from 'url';
2
2
  import { not_empty } from "./prototype.js";
3
3
  import { noprint } from "./process.js";
4
- import { Lock, check, filter_values } from "./utils.js";
4
+ import { Lock, filter_values } from "./utils.js";
5
5
  import { fcopy, fmkdir, fwrite, fread } from "./file.js";
6
6
  import { path } from "./path.js";
7
7
  const monaco_files = [
@@ -125,24 +125,39 @@ function get_vendor_asset_out(asset) {
125
125
  }
126
126
  export class Bundler {
127
127
  name;
128
- fpd_root;
129
128
  target;
130
- production;
129
+ fpd_root;
131
130
  fpd_out;
132
- source_map;
131
+ fpdt_cache;
132
+ entry;
133
+ // --- BundlerOptions 开始
134
+ production = true;
133
135
  dependencies = [];
134
- analyzer;
135
- config;
136
+ source_map = true;
137
+ globals;
138
+ external_dayjs = false;
139
+ externals;
136
140
  htmls;
137
141
  assets;
138
- assets_root;
139
- template;
142
+ assets_root = '/';
143
+ template = false;
140
144
  single_js;
141
- globals;
145
+ commonjs2 = false;
146
+ expose = false;
147
+ single_chunk = true;
148
+ dynamic_import = true;
149
+ resolve_alias;
150
+ resolve_fallback;
151
+ assets_stats = true;
152
+ analyzer = false;
153
+ dts = false;
142
154
  exclude_modules;
155
+ cache_version;
143
156
  plugins;
144
157
  license;
145
158
  polyfill_node_sea;
159
+ // --- BundlerOptions 结束
160
+ config;
146
161
  lcompiler;
147
162
  /** 通过 webpack 从入口文件打包所有依赖生成单个 index.{mjs,cjs} 文件
148
163
  - name: 项目名称
@@ -152,6 +167,8 @@ export class Bundler {
152
167
  - fpd_cache: webpack 缓存目录
153
168
  - entry: 入口文件
154
169
  - options?: 打包配置, 按常用顺序排列
170
+ - production?: `true` webpack mode 设置为 'production'
171
+ - dependencies?: DependencyId[], 决定 bundler 在 build_all (copy_files) 时需要复制到 fpd_out 的资源
155
172
  - source_map?: `true` 启用源码映射 .map 文件
156
173
  - globals?: 全局变量定义
157
174
  - external_dayjs?: `false` 配置 dayjs 为 external 来配合 antd 使用, 减小一点体积
@@ -160,14 +177,13 @@ export class Bundler {
160
177
  - assets?: 项目中需要直接复制到输出目录的资源,有 productions 但无 devs 时 (是同一套),
161
178
  在 dev 模式下会用 productions 中的资源,如果不需要 productions 资源, devs 可以设置为 [ ],
162
179
  每一项是 string 或者 { src: '...', out: '...' },路径相对于 fpd_root 和 fpd_out
163
- - assets_root?: `'/'` 生成的 html 中是否使用 / 开头的绝对路径,以支持 browser router 路由能力
164
- 启用后 assets, html 中的 icon, scripts 路径直接在前面添加 assets_root 来生成最终 html href
180
+ - assets_root?: `'/'` 生成的 html 中替换 {root} 作为部署路径,以支持 browser router 路由能力
181
+ assets, html 中的 icon, scripts 路径直接在前面添加 assets_root 来生成最终 html href
165
182
  未启用时使用相对 html 路径来生成最终 html href
166
183
  - template?: `false` 除了生成对应的 html 之外,还生成所有路径为 `{root}/...` 的模板 html 文件, 方便后续 server 替换渲染
167
184
  - single_js?: 设置生成的单个 js 入口文件,无其他依赖,通过 script module 作为入口加载,含有 import 加载其他 externals 和某个 entry,类似 htmls 配置要生成的 html
168
185
  - js: js 入口文件名
169
186
  - entry: 使用的 entry
170
- - local_loaders?: `true` true 时使用项目 node_modules/ 中的 loader; false 时使用 D:/0/ 下面的
171
187
  - commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
172
188
  - expose?: `false` 入口模块所有导出的属性赋值到全局对象 globalThis 上
173
189
  - single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
@@ -179,330 +195,320 @@ export class Bundler {
179
195
  - dts?: `false` 生成 .d.ts 文件
180
196
  - exclude_modules?: 传入正则表达式 ,匹配时使用 IgnorePlugin 强制不打包这个模块,但是一旦导入就会报错
181
197
  - cache_version?: webpack cache version, 用于区分同一个 name 的不同版本
182
- - production?: `true` webpack mode 设置为 'production'
183
- - sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
184
198
  - plugins?: 可选传入的额外的 webpack 插件
185
199
  - license?: 使用 license-webpack-plugin 构建 ThirdPartyNotice.txt
186
200
  - polyfill_node_sea?: 避免依赖 node:sea 模块以兼容旧版本 node.js */
187
- constructor(name, target, fpd_root, fpd_out, fpdt_cache, entry, { source_map = true, globals, external_dayjs = false, externals, htmls, assets, assets_root = '/', template = false, single_js, commonjs2 = false, expose = 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, plugins, license, polyfill_node_sea = false } = {}) {
201
+ constructor(name, target, fpd_root, fpd_out, fpdt_cache, entry, options = {}) {
188
202
  this.name = name;
189
- this.analyzer = analyzer;
190
- this.production = production;
191
203
  this.target = target;
192
204
  this.fpd_root = fpd_root;
193
205
  this.fpd_out = fpd_out;
194
- this.source_map = source_map;
195
- this.htmls = htmls;
196
- this.assets = assets;
197
- this.assets_root = assets_root;
198
- this.template = template;
199
- this.single_js = single_js;
200
- this.globals = globals;
201
- this.exclude_modules = exclude_modules;
202
- this.plugins = plugins;
203
- if (dependencies) {
204
- check(target === 'web');
205
- this.dependencies = dependencies;
206
- }
207
- if (expose && commonjs2)
206
+ this.fpdt_cache = fpdt_cache;
207
+ this.entry = entry;
208
+ Object.assign(this, options);
209
+ if (options.dependencies?.length && target !== 'web')
210
+ throw new Error('仅 target === web 时才需要配置 dependencies');
211
+ if (this.expose && this.commonjs2)
208
212
  throw new Error('expose 和 commonjs2 不能同时启用');
209
- const output_module = !commonjs2 && !expose;
210
- this.license = license;
211
- this.polyfill_node_sea = polyfill_node_sea;
212
- // let smp = new SpeedMeasurePlugin()
213
- // const config: Webpack.Configuration = smp.wrap({
214
- let resolve_cache = {};
215
- const get_loader = (name) => resolve_cache[name] ??= fileURLToPath(import.meta.resolve(`${name}/package.json`)).fdir;
216
- this.config = {
217
- name,
218
- mode: production ? 'production' : 'development',
219
- devtool: source_map ? 'source-map' : false,
220
- context: fpd_root,
221
- entry,
222
- experiments: {
223
- outputModule: output_module,
224
- },
225
- output: {
226
- path: fpd_out,
227
- filename: '[name]',
228
- publicPath: '/',
229
- pathinfo: true,
230
- globalObject: 'globalThis',
231
- module: output_module,
232
- // 在 bundle 中导出 entry 文件的 export
233
- library: {
234
- type: commonjs2 ? 'commonjs2' : expose ? 'global' : 'module',
235
- },
236
- ...single_chunk ? {
237
- chunkLoading: false
238
- } : {},
239
- },
240
- target: [target === 'web' ? 'web' : 'node23', 'es2024'],
241
- // 结合 output.globalObject, 会生成 globalThis['React'] 这样的引用
242
- externalsType: target === 'nodejs' ? 'commonjs2' : 'global',
243
- // 以 react: 'React', 为例,含义为
244
- // 取全局变量 window.React 的值作为 import { useState } from 'react' 中 { ... } 这部分的结果,再解构里面的 useState 属性
245
- externals: filter_values({
246
- react: 'React',
247
- 'react/jsx-runtime': 'ReactJSX',
248
- 'react-dom': 'ReactDOM',
249
- 'react-dom/client': 'ReactDOMClient',
250
- jquery: '$',
251
- ...target === 'web' ? {
252
- lodash: '_',
253
- } : {
254
- vscode: 'commonjs2 vscode'
255
- },
256
- // import { Terminal } from 'xterm'
257
- // 实际上 Terminal 直接暴露在了 window 上,而不是 window.Terminal.Terminal
258
- '@xterm/xterm': 'window',
259
- swiper: 'Swiper',
260
- ...external_dayjs ? { dayjs: 'dayjs' } : {},
261
- antd: 'antd',
262
- '@ant-design/icons': 'icons',
263
- '@ant-design/plots': 'Plots',
264
- echarts: 'echarts',
265
- ...externals
266
- }),
267
- resolve: {
268
- symlinks: true,
269
- extensions: ['.js'],
270
- extensionAlias: {
271
- '.js': ['.js', '.ts', '.tsx']
272
- },
273
- ...resolve_alias ? { alias: resolve_alias } : {},
274
- // modules: [
275
- // '',
276
- // ],
277
- ...resolve_fallback ? { fallback: resolve_fallback } : {},
278
- // fallback: {
279
- // os: false,
280
- // }
281
- },
282
- ...sass ? {
283
- loader: { sass }
284
- } : {},
285
- module: {
286
- ...dynamic_import === false ? {
287
- parser: {
288
- javascript: {
289
- // 保留 await import() 这样的引用
290
- import: false,
291
- // dynamicImportMode: 'weak',
292
- }
213
+ }
214
+ async build(print = true) {
215
+ if (!this.lcompiler)
216
+ await (this.lcompiler = new Lock()).request(async () => {
217
+ const { default: Webpack } = await import('webpack');
218
+ const output_module = !this.commonjs2 && !this.expose;
219
+ // let smp = new SpeedMeasurePlugin()
220
+ // const config: Webpack.Configuration = smp.wrap({
221
+ let resolve_cache = {};
222
+ const get_loader = (name) => resolve_cache[name] ??= fileURLToPath(import.meta.resolve(`${name}/package.json`)).fdir;
223
+ const sass = this.target === 'web' ? await import('sass') : undefined;
224
+ this.lcompiler.resource = Webpack(this.config = {
225
+ name: this.name,
226
+ mode: this.production ? 'production' : 'development',
227
+ devtool: this.source_map ? 'source-map' : false,
228
+ context: this.fpd_root,
229
+ entry: this.entry,
230
+ experiments: {
231
+ outputModule: output_module,
293
232
  },
294
- } : {},
295
- rules: [
296
- ...source_map ? [
297
- {
298
- test: /\.js$/,
299
- enforce: 'pre',
300
- use: [get_loader('source-map-loader')],
233
+ output: {
234
+ path: this.fpd_out,
235
+ filename: '[name]',
236
+ publicPath: '/',
237
+ pathinfo: true,
238
+ globalObject: 'globalThis',
239
+ module: output_module,
240
+ // 在 bundle 中导出 entry 文件的 export
241
+ library: {
242
+ type: this.commonjs2 ? 'commonjs2' : this.expose ? 'global' : 'module',
301
243
  },
302
- ] : [],
303
- {
304
- test: target === 'nodejs' ? /\.ts$/ : /\.tsx?$/,
305
- exclude: /node_modules/,
306
- loader: get_loader('ts-loader'),
307
- // https://github.com/TypeStrong/ts-loader
308
- options: {
309
- configFile: `${fpd_root}tsconfig.json`,
310
- onlyCompileBundledFiles: true,
311
- transpileOnly: !dts,
312
- compilerOptions: {
313
- module: 'ESNext',
314
- moduleResolution: 'Bundler',
315
- declaration: dts,
316
- noEmit: false,
317
- allowImportingTsExtensions: false,
318
- ...commonjs2 ? {
319
- // 编译为 commonjs 后 import 的依赖是通过 require 引入的,所以需要 interop 去生成 default
320
- // nodejs 默认的 import 会自动加上 default,所以不需要 interop
321
- esModuleInterop: true
322
- } : {},
323
- }
324
- }
244
+ ...this.single_chunk ? {
245
+ chunkLoading: false
246
+ } : {},
247
+ },
248
+ target: [this.target === 'web' ? 'web' : 'node23', 'es2024'],
249
+ // 结合 output.globalObject, 会生成 globalThis['React'] 这样的引用
250
+ externalsType: this.target === 'nodejs' ? 'commonjs2' : 'global',
251
+ // 以 react: 'React', 为例,含义为
252
+ // 取全局变量 window.React 的值作为 import { useState } from 'react' 中 { ... } 这部分的结果,再解构里面的 useState 属性
253
+ externals: filter_values({
254
+ react: 'React',
255
+ 'react/jsx-runtime': 'ReactJSX',
256
+ 'react-dom': 'ReactDOM',
257
+ 'react-dom/client': 'ReactDOMClient',
258
+ jquery: '$',
259
+ ...this.target === 'web' ? {
260
+ lodash: '_',
261
+ } : {
262
+ vscode: 'commonjs2 vscode'
263
+ },
264
+ // import { Terminal } from 'xterm'
265
+ // 实际上 Terminal 直接暴露在了 window 上,而不是 window.Terminal.Terminal
266
+ '@xterm/xterm': 'window',
267
+ swiper: 'Swiper',
268
+ ...this.external_dayjs ? { dayjs: 'dayjs' } : {},
269
+ antd: 'antd',
270
+ '@ant-design/icons': 'icons',
271
+ '@ant-design/plots': 'Plots',
272
+ echarts: 'echarts',
273
+ ...this.externals
274
+ }),
275
+ resolve: {
276
+ symlinks: true,
277
+ extensions: ['.js'],
278
+ extensionAlias: {
279
+ '.js': ['.js', '.ts', '.tsx']
280
+ },
281
+ ...this.resolve_alias ? { alias: this.resolve_alias } : {},
282
+ // modules: [
283
+ // '',
284
+ // ],
285
+ ...this.resolve_fallback ? { fallback: this.resolve_fallback } : {},
286
+ // fallback: {
287
+ // os: false,
288
+ // }
325
289
  },
326
- ...target === 'web' ? [
327
- {
328
- test: /\.s[ac]ss$/,
329
- use: [
330
- get_loader('style-loader'),
290
+ module: {
291
+ ...this.dynamic_import === false ? {
292
+ parser: {
293
+ javascript: {
294
+ // 保留 await import() 这样的引用
295
+ import: false,
296
+ // dynamicImportMode: 'weak',
297
+ }
298
+ },
299
+ } : {},
300
+ rules: [
301
+ ...this.source_map ? [
331
302
  {
332
- // https://github.com/webpack-contrib/css-loader
333
- loader: get_loader('css-loader'),
334
- options: {
335
- url: false,
336
- }
303
+ test: /\.js$/,
304
+ enforce: 'pre',
305
+ use: [get_loader('source-map-loader')],
337
306
  },
338
- {
339
- // https://webpack.js.org/loaders/sass-loader
340
- loader: get_loader('sass-loader'),
341
- options: {
342
- api: 'modern-compiler',
343
- ...sass ? {
344
- implementation: sass
307
+ ] : [],
308
+ {
309
+ test: this.target === 'nodejs' ? /\.ts$/ : /\.tsx?$/,
310
+ exclude: /node_modules/,
311
+ loader: get_loader('ts-loader'),
312
+ // https://github.com/TypeStrong/ts-loader
313
+ options: {
314
+ configFile: `${this.fpd_root}tsconfig.json`,
315
+ onlyCompileBundledFiles: true,
316
+ transpileOnly: !this.dts,
317
+ compilerOptions: {
318
+ module: 'ESNext',
319
+ moduleResolution: 'Bundler',
320
+ declaration: this.dts,
321
+ noEmit: false,
322
+ allowImportingTsExtensions: false,
323
+ ...this.commonjs2 ? {
324
+ // 编译为 commonjs 后 import 的依赖是通过 require 引入的,所以需要 interop 去生成 default
325
+ // nodejs 默认的 import 会自动加上 default,所以不需要 interop
326
+ esModuleInterop: true
345
327
  } : {},
346
- // 解决 url(search.png) 打包出错的问题
347
- webpackImporter: false,
348
- sassOptions: {
349
- indentWidth: 4,
350
- }
351
328
  }
352
- },
353
- ]
354
- },
355
- {
356
- test: /\.css$/,
357
- use: [get_loader('style-loader'), get_loader('css-loader')]
358
- },
359
- {
360
- oneOf: [
329
+ }
330
+ },
331
+ ...this.target === 'web' ? [
361
332
  {
362
- test: /\.icon\.svg$/,
363
- issuer: /\.[jt]sx?$/,
364
- loader: get_loader('@svgr/webpack'),
365
- options: { icon: true }
333
+ test: /\.s[ac]ss$/,
334
+ use: [
335
+ get_loader('style-loader'),
336
+ {
337
+ // https://github.com/webpack-contrib/css-loader
338
+ loader: get_loader('css-loader'),
339
+ options: {
340
+ url: false,
341
+ }
342
+ },
343
+ {
344
+ // https://webpack.js.org/loaders/sass-loader
345
+ loader: get_loader('sass-loader'),
346
+ options: {
347
+ api: 'modern-compiler',
348
+ ...sass ? {
349
+ implementation: sass
350
+ } : {},
351
+ // 解决 url(search.png) 打包出错的问题
352
+ webpackImporter: false,
353
+ sassOptions: {
354
+ indentWidth: 4,
355
+ }
356
+ }
357
+ },
358
+ ]
366
359
  },
367
360
  {
368
- test: /\.raw\.svg$/,
369
- type: 'asset/source',
361
+ test: /\.css$/,
362
+ use: [get_loader('style-loader'), get_loader('css-loader')]
370
363
  },
371
364
  {
372
- test: /\.(svg|ico|png|jpe?g|gif|woff2?|ttf|eot|otf|mp4|webm|ogg|mp3|wav|flac|aac)$/,
373
- type: 'asset/inline',
365
+ oneOf: [
366
+ {
367
+ test: /\.icon\.svg$/,
368
+ issuer: /\.[jt]sx?$/,
369
+ loader: get_loader('@svgr/webpack'),
370
+ options: { icon: true }
371
+ },
372
+ {
373
+ test: /\.raw\.svg$/,
374
+ type: 'asset/source',
375
+ },
376
+ {
377
+ test: /\.(svg|ico|png|jpe?g|gif|woff2?|ttf|eot|otf|mp4|webm|ogg|mp3|wav|flac|aac)$/,
378
+ type: 'asset/inline',
379
+ },
380
+ ]
374
381
  },
375
- ]
382
+ ] : [],
383
+ {
384
+ test: /\.(txt|csv|dos)$/,
385
+ type: 'asset/source',
386
+ }
387
+ ]
388
+ },
389
+ ...sass ? {
390
+ loader: {
391
+ sass
376
392
  },
377
- ] : [],
378
- {
379
- test: /\.(txt|csv|dos)$/,
380
- type: 'asset/source',
381
- }
382
- ]
383
- },
384
- optimization: {
385
- minimize: false
386
- },
387
- cache: {
388
- type: 'filesystem',
389
- compression: false,
390
- cacheDirectory: fpdt_cache,
391
- ...cache_version ? {
392
- version: cache_version
393
- } : {}
394
- },
395
- ignoreWarnings: [
396
- ...source_map ? [/Failed to parse source map/] : [],
397
- ...this.license ? [
398
- /** LicenseWebpackPlugin 会添加过时的 string 类型的 warning,无法被正则表达式的逻辑匹配,这里只能手动用函数过滤 */
399
- (warning) => typeof warning === 'string' && warning.startsWith('license-webpack-plugin: could not find any license ')
400
- ] : [],
401
- ...target === 'nodejs' ? [
402
- /Can't resolve '(bufferutil|utf-8-validate)'/,
403
- // 打包 ali-oss 时可能的报错
404
- (warning) => {
405
- if (!warning)
406
- return false;
407
- const { message, module } = warning;
408
- if (!message)
409
- return false;
410
- const fp = module?.context?.fp || '';
411
- if (message.includes('the request of a dependency is an expression'))
412
- return fp.endsWith('any-promise') ||
413
- fp.includes('/@sqltools/base-driver/');
414
- else if (message.includes('require function is used in a way in which dependencies cannot be statically extracted'))
415
- return fp.includes('/vscode-languageserver-types/');
416
- else
417
- return false;
418
- }
419
- ] : [],
420
- ],
421
- performance: {
422
- hints: false,
423
- },
424
- stats: {
425
- colors: true,
426
- context: fpd_root,
427
- entrypoints: false,
428
- errors: true,
429
- errorDetails: true,
430
- hash: false,
431
- version: false,
432
- timings: true,
433
- children: true,
434
- assets: assets_stats,
435
- assetsSpace: 20,
436
- modules: false,
437
- modulesSpace: 20,
438
- cachedAssets: false,
439
- cachedModules: false,
440
- chunks: false,
441
- // logging: 'info',
442
- }
443
- };
444
- }
445
- async build(print = true) {
446
- if (!this.lcompiler) {
447
- const { default: Webpack } = await import('webpack');
448
- this.config.plugins = [
449
- ...this.globals ? [
450
- new Webpack.DefinePlugin({
451
- ...this.globals
452
- // process: { env: { }, argv: [] }
453
- })
454
- ] : [],
455
- // 使用 IgnorePlugin 能够不打包,但是一旦导入就会报错
456
- ...this.exclude_modules ? [
457
- new Webpack.IgnorePlugin({
458
- resourceRegExp: this.exclude_modules,
459
- // checkResource: (resource, context) =>
460
- // resource.startsWith('./vendors/') && !context.fp.startsWith(fpd_node_modules) ,
461
- })
462
- ] : [],
463
- ...this.analyzer ? await (async () => {
464
- const { BundleAnalyzerPlugin } = await import('webpack-bundle-analyzer');
465
- return [
466
- new BundleAnalyzerPlugin({
467
- analyzerPort: 8880,
468
- openAnalyzer: false,
469
- })
470
- ];
471
- })() : [],
472
- ...this.license ? await (async () => {
473
- const { LicenseWebpackPlugin } = await import('license-webpack-plugin');
474
- return [
475
- new LicenseWebpackPlugin({
476
- perChunkOutput: false,
477
- outputFilename: 'ThirdPartyNotice.txt',
478
- })
479
- ];
480
- })() : [],
481
- ...this.polyfill_node_sea ? [{
482
- apply(compiler) {
483
- const external_polyfill_plugin_name = 'MyNodejsBuiltinModuleReplacementPlugin';
484
- const builtin_module = 'node:sea';
485
- const fp_polyfill = `${import.meta.dirname.fpd}node-sea.polyfill.js`;
486
- compiler.hooks.normalModuleFactory.tap(external_polyfill_plugin_name, factory => {
487
- factory.hooks.beforeResolve.tap(external_polyfill_plugin_name, data => {
488
- if (data.request === builtin_module) {
489
- data.request = fp_polyfill;
490
- // 一定要改 dependencies,否则会创建 ExternalModule,不走 NormalModule 的 resolve 过程
491
- data.dependencies.forEach(dep => {
492
- if (dep.request === builtin_module) {
493
- dep.request = fp_polyfill;
494
- dep.userRequest = fp_polyfill;
393
+ } : {},
394
+ optimization: {
395
+ minimize: false
396
+ },
397
+ cache: {
398
+ type: 'filesystem',
399
+ compression: false,
400
+ cacheDirectory: this.fpdt_cache,
401
+ ...this.cache_version ? {
402
+ version: this.cache_version
403
+ } : {}
404
+ },
405
+ ignoreWarnings: [
406
+ ...this.source_map ? [/Failed to parse source map/] : [],
407
+ ...this.license ? [
408
+ /** LicenseWebpackPlugin 会添加过时的 string 类型的 warning,无法被正则表达式的逻辑匹配,这里只能手动用函数过滤 */
409
+ (warning) => typeof warning === 'string' && warning.startsWith('license-webpack-plugin: could not find any license ')
410
+ ] : [],
411
+ ...this.target === 'nodejs' ? [
412
+ /Can't resolve '(bufferutil|utf-8-validate)'/,
413
+ // 打包 ali-oss 时可能的报错
414
+ (warning) => {
415
+ if (!warning)
416
+ return false;
417
+ const { message, module } = warning;
418
+ if (!message)
419
+ return false;
420
+ const fp = module?.context?.fp || '';
421
+ if (message.includes('the request of a dependency is an expression'))
422
+ return fp.endsWith('any-promise') ||
423
+ fp.includes('/@sqltools/base-driver/');
424
+ else if (message.includes('require function is used in a way in which dependencies cannot be statically extracted'))
425
+ return fp.includes('/vscode-languageserver-types/');
426
+ else
427
+ return false;
428
+ }
429
+ ] : [],
430
+ ...this.name === 'react' ? [/export '(createRoot|hydrateRoot)' \(imported as 'ReactDOM'\) was not found in 'react-dom'/] : []
431
+ ],
432
+ performance: {
433
+ hints: false,
434
+ },
435
+ stats: {
436
+ colors: true,
437
+ context: this.fpd_root,
438
+ entrypoints: false,
439
+ errors: true,
440
+ errorDetails: true,
441
+ hash: false,
442
+ version: false,
443
+ timings: true,
444
+ children: true,
445
+ assets: this.assets_stats,
446
+ assetsSpace: 20,
447
+ modules: false,
448
+ modulesSpace: 20,
449
+ cachedAssets: false,
450
+ cachedModules: false,
451
+ chunks: false,
452
+ // logging: 'info',
453
+ },
454
+ plugins: [
455
+ ...this.globals ? [
456
+ new Webpack.DefinePlugin({
457
+ ...this.globals
458
+ // process: { env: { }, argv: [] }
459
+ })
460
+ ] : [],
461
+ // 使用 IgnorePlugin 能够不打包,但是一旦导入就会报错
462
+ ...this.exclude_modules ? [
463
+ new Webpack.IgnorePlugin({
464
+ resourceRegExp: this.exclude_modules,
465
+ // checkResource: (resource, context) =>
466
+ // resource.startsWith('./vendors/') && !context.fp.startsWith(fpd_node_modules) ,
467
+ })
468
+ ] : [],
469
+ ...this.analyzer ? await (async () => {
470
+ const { BundleAnalyzerPlugin } = await import('webpack-bundle-analyzer');
471
+ return [
472
+ new BundleAnalyzerPlugin({
473
+ analyzerPort: 8880,
474
+ openAnalyzer: false,
475
+ })
476
+ ];
477
+ })() : [],
478
+ ...this.license ? await (async () => {
479
+ const { LicenseWebpackPlugin } = await import('license-webpack-plugin');
480
+ return [
481
+ new LicenseWebpackPlugin({
482
+ perChunkOutput: false,
483
+ outputFilename: 'ThirdPartyNotice.txt',
484
+ })
485
+ ];
486
+ })() : [],
487
+ ...this.polyfill_node_sea ? [{
488
+ apply(compiler) {
489
+ const external_polyfill_plugin_name = 'MyNodejsBuiltinModuleReplacementPlugin';
490
+ const builtin_module = 'node:sea';
491
+ const fp_polyfill = `${import.meta.dirname.fpd}node-sea.polyfill.js`;
492
+ compiler.hooks.normalModuleFactory.tap(external_polyfill_plugin_name, factory => {
493
+ factory.hooks.beforeResolve.tap(external_polyfill_plugin_name, data => {
494
+ if (data.request === builtin_module) {
495
+ data.request = fp_polyfill;
496
+ // 一定要改 dependencies,否则会创建 ExternalModule,不走 NormalModule 的 resolve 过程
497
+ data.dependencies.forEach(dep => {
498
+ if (dep.request === builtin_module) {
499
+ dep.request = fp_polyfill;
500
+ dep.userRequest = fp_polyfill;
501
+ }
502
+ });
495
503
  }
496
504
  });
497
- }
498
- });
499
- });
500
- }
501
- }] : [],
502
- ...this.plugins || [],
503
- ];
504
- this.lcompiler = new Lock(Webpack(this.config));
505
- }
505
+ });
506
+ }
507
+ }] : [],
508
+ ...this.plugins || [],
509
+ ]
510
+ });
511
+ });
506
512
  const stats = await this.lcompiler.request(async (compiler) => new Promise((resolve, reject) => {
507
513
  compiler.run((error, stats) => {
508
514
  if (error)
package/net.js CHANGED
@@ -108,7 +108,7 @@ export async function request(url, options = {}) {
108
108
  let headers = {
109
109
  'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja-JP;q=0.6,ja;q=0.5',
110
110
  'accept-encoding': 'gzip, deflate, br',
111
- 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
111
+ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36',
112
112
  'sec-ch-ua-platform': '"Windows"',
113
113
  'sec-ch-ua-platform-version': '"15.0.0"',
114
114
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.2.41",
3
+ "version": "1.2.43",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -64,15 +64,15 @@
64
64
  "chalk": "^5.4.1",
65
65
  "cli-table3": "^0.6.5",
66
66
  "cli-truncate": "^4.0.0",
67
- "commander": "^13.1.0",
67
+ "commander": "^14.0.0",
68
68
  "css-loader": "^7.1.2",
69
69
  "emoji-regex": "^10.4.0",
70
- "eslint": "^9.26.0",
70
+ "eslint": "^9.27.0",
71
71
  "eslint-plugin-import": "^2.31.0",
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": "^25.1.3",
75
+ "i18next": "^25.2.0",
76
76
  "i18next-scanner": "^4.6.0",
77
77
  "koa": "^3.0.0",
78
78
  "koa-compress": "^5.1.1",
@@ -84,7 +84,7 @@
84
84
  "react-i18next": "^15.5.1",
85
85
  "react-object-model": "^1.2.24",
86
86
  "resolve-path": "^1.4.0",
87
- "sass": "^1.88.0",
87
+ "sass": "^1.89.0",
88
88
  "sass-loader": "^16.0.5",
89
89
  "source-map-loader": "^5.0.0",
90
90
  "strip-ansi": "^7.1.0",
@@ -112,7 +112,7 @@
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.15.18",
115
+ "@types/node": "^22.15.19",
116
116
  "@types/react": "^19.1.4",
117
117
  "@types/through2": "^2.0.41",
118
118
  "@types/tough-cookie": "^4.0.5",
package/process.js CHANGED
@@ -47,7 +47,7 @@ input, stdin = Boolean(input), stdout = !detached, stderr = stdout, print = true
47
47
  ...proxy ? {
48
48
  http_proxy: proxy,
49
49
  https_proxy: proxy,
50
- no_proxy: '127.0.0.1,::1,localhost,192.168.0.0/20,192.168.100.0/24'
50
+ no_proxy: 'localhost,127.0.0.1'
51
51
  } : {},
52
52
  ...envs
53
53
  });