xshell 1.0.172 → 1.0.174

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.
Files changed (3) hide show
  1. package/builder.d.ts +6 -1
  2. package/builder.js +21 -17
  3. package/package.json +1 -1
package/builder.d.ts CHANGED
@@ -73,6 +73,7 @@ export interface BundlerOptions {
73
73
  single_chunk?: boolean;
74
74
  exclude_modules?: RegExp;
75
75
  assets?: Assets;
76
+ assets_root?: string;
76
77
  license?: {
77
78
  ignores?: string[];
78
79
  };
@@ -90,6 +91,7 @@ export declare class Bundler {
90
91
  config: Webpack.Configuration;
91
92
  htmls?: Record<string, HtmlOptions>;
92
93
  assets?: Assets;
94
+ assets_root?: string;
93
95
  globals?: BundlerOptions['globals'];
94
96
  exclude_modules?: BundlerOptions['exclude_modules'];
95
97
  license?: {
@@ -112,6 +114,9 @@ export declare class Bundler {
112
114
  - assets?: 项目中需要直接复制到输出目录的资源,有 productions 但无 devs 时 (是同一套),
113
115
  在 dev 模式下会用 productions 中的资源,如果不需要 productions 资源, devs 可以设置为 [ ],
114
116
  每一项是 string 或者 { src: '...', out: '...' },路径相对于 fpd_root 和 fpd_out
117
+ - assets_root?: `''` 生成的 html 中是否使用 / 开头的绝对路径,以支持 browser router 路由能力
118
+ 启用后 assets, html 中的 icon, scripts 路径直接在前面添加 assets_root 来生成最终 html href
119
+ 未启用时使用相对 html 路径来生成最终 html href
115
120
  - local_loaders?: `true` true 时使用项目 node_modules/ 中的 loader; false 时使用 D:/0/ 下面的
116
121
  - commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
117
122
  - single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
@@ -126,7 +131,7 @@ export declare class Bundler {
126
131
  - production?: `true` webpack mode 设置为 'production'
127
132
  - sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
128
133
  - license?: 使用 license-webpack-plugin 构建 ThirdPartyNotice.txt */
129
- 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, resolve_fallback, assets_stats, analyzer, dts, exclude_modules, cache_version, production, sass, dependencies, license, }?: BundlerOptions);
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);
130
135
  build(print?: boolean): Promise<void>;
131
136
  close(): Promise<void>;
132
137
  build_all(print?: boolean): Promise<void>;
package/builder.js CHANGED
@@ -5,15 +5,14 @@ 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',
9
8
  'editor/editor.main.js',
10
9
  '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',
11
13
  'base/worker/workerMain.js',
12
14
  'base/browser/ui/codicons/codicon/codicon.ttf',
13
15
  ...['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',
17
16
  ];
18
17
  const dependencies = {
19
18
  react: {
@@ -84,12 +83,8 @@ const dependencies = {
84
83
  devs: monaco_files.map(fp => `monaco-editor/dev/vs/${fp}`)
85
84
  },
86
85
  maps: {
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
- ],
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`),
93
88
  devs: [
94
89
  'monaco-editor/dev/vs/base/worker/workerMain.js.map',
95
90
  'monaco-editor/dev/vs/editor/editor.main.js.map',
@@ -116,6 +111,7 @@ export class Bundler {
116
111
  config;
117
112
  htmls;
118
113
  assets;
114
+ assets_root;
119
115
  globals;
120
116
  exclude_modules;
121
117
  license;
@@ -136,6 +132,9 @@ export class Bundler {
136
132
  - assets?: 项目中需要直接复制到输出目录的资源,有 productions 但无 devs 时 (是同一套),
137
133
  在 dev 模式下会用 productions 中的资源,如果不需要 productions 资源, devs 可以设置为 [ ],
138
134
  每一项是 string 或者 { src: '...', out: '...' },路径相对于 fpd_root 和 fpd_out
135
+ - assets_root?: `''` 生成的 html 中是否使用 / 开头的绝对路径,以支持 browser router 路由能力
136
+ 启用后 assets, html 中的 icon, scripts 路径直接在前面添加 assets_root 来生成最终 html href
137
+ 未启用时使用相对 html 路径来生成最终 html href
139
138
  - local_loaders?: `true` true 时使用项目 node_modules/ 中的 loader; false 时使用 D:/0/ 下面的
140
139
  - commonjs2?: `false` 打包为 commonjs2 (.cjs) 的文件
141
140
  - single_chunk?: `true` 输出为单个文件,将依赖也打包到其中,不要生成多个 chunk
@@ -150,7 +149,7 @@ export class Bundler {
150
149
  - production?: `true` webpack mode 设置为 'production'
151
150
  - sass?: 传入 sass 实例避免 webpack 重复加载 .cjs 版本
152
151
  - license?: 使用 license-webpack-plugin 构建 ThirdPartyNotice.txt */
153
- constructor(name, target, fpd_root, fpd_out, fpdt_cache, entry, { source_map = true, globals, external_dayjs = false, externals, htmls, assets, 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, } = {}) {
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, } = {}) {
154
153
  this.name = name;
155
154
  this.analyzer = analyzer;
156
155
  this.production = production;
@@ -160,6 +159,7 @@ export class Bundler {
160
159
  this.source_map = source_map;
161
160
  this.htmls = htmls;
162
161
  this.assets = assets;
162
+ this.assets_root = assets_root;
163
163
  this.globals = globals;
164
164
  this.exclude_modules = exclude_modules;
165
165
  if (dependencies) {
@@ -488,7 +488,11 @@ export class Bundler {
488
488
  }
489
489
  async build_htmls(print = { info: true, files: false }) {
490
490
  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, }]) => {
491
- const to_relative = (asset) => path.relative(`${this.fpd_out}${fp_html}`.fdir, `${this.fpd_out}${typeof asset === 'string' ? asset : asset.out}`);
491
+ const fpd_html = `${this.fpd_out}${fp_html}`.fdir;
492
+ const resolve = (asset) => this.assets_root ?
493
+ `${this.assets_root}${typeof asset === 'string' ? asset : asset.out}`
494
+ :
495
+ path.relative(fpd_html, `${this.fpd_out}${typeof asset === 'string' ? asset : asset.out}`);
492
496
  const html = '<!doctype html>\n' +
493
497
  '<html>\n' +
494
498
  ' <head>\n' +
@@ -496,13 +500,13 @@ export class Bundler {
496
500
  " <meta charset='utf-8' />\n" +
497
501
  (heads ? heads.map(head => ` ${head}`).join_lines() : '') +
498
502
  (device_width ? " <meta name='viewport' content='width=device-width, initial-scale=1.0' />\n" : '') +
499
- (icon ? ` <link rel='icon' href='${to_relative(icon)}' />\n` : '') +
500
- (manifest ? ` <link rel='manifest' href='${to_relative(manifest)}' />\n` : '') +
503
+ (icon ? ` <link rel='icon' href='${resolve(icon)}' />\n` : '') +
504
+ (manifest ? ` <link rel='manifest' href='${resolve(manifest)}' />\n` : '') +
501
505
  this.resolve_dependency_files(_dependencies, false, { production: this.production }).map(fp => ` <script src='./vendors/${fp}' defer></script>`).join_lines() +
502
- (scripts?.before ? scripts.before.map(asset => ` <script src='${to_relative(asset)}' defer></script>`).join_lines() : '') +
503
- (mscripts ? mscripts.map(mscript => ` <script src='${to_relative(mscript)}' type='module'></script>`).join_lines() : '') +
506
+ (scripts?.before ? scripts.before.map(asset => ` <script src='${resolve(asset)}' defer></script>`).join_lines() : '') +
507
+ (mscripts ? mscripts.map(mscript => ` <script src='${resolve(mscript)}' type='module'></script>`).join_lines() : '') +
504
508
  ` <script src='${fp_entry}' type='module'></script>\n` +
505
- (scripts?.after ? scripts.after.map(asset => ` <script src='${to_relative(asset)}' defer></script>`).join_lines() : '') +
509
+ (scripts?.after ? scripts.after.map(asset => ` <script src='${resolve(asset)}' defer></script>`).join_lines() : '') +
506
510
  ' </head>\n' +
507
511
  ' <body>\n' +
508
512
  " <div class='root'>\n" +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.172",
3
+ "version": "1.0.174",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {