xshell 1.0.138 → 1.0.140
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 +2 -1
- package/builder.js +5 -4
- package/package.json +1 -1
package/builder.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export interface HtmlOptions {
|
|
|
29
29
|
device_viewport?: boolean;
|
|
30
30
|
/** 也会在 copy_files 中一并被复制,应填写相对于 fpd_root 和 fpd_out 的路径 */
|
|
31
31
|
icon?: string | AssetOption;
|
|
32
|
+
/** 仅用于生成 html 中 script 标签,文件复制由 BundlerOptions['dependencies'] 决定 */
|
|
32
33
|
dependencies?: DependencyId[];
|
|
33
34
|
manifest?: string | AssetOption;
|
|
34
35
|
/** 额外需要加载的脚本 */
|
|
@@ -39,7 +40,7 @@ export interface HtmlOptions {
|
|
|
39
40
|
after?: string[];
|
|
40
41
|
};
|
|
41
42
|
/** 额外需要加载的 module 脚本, 在 index.js 之前 */
|
|
42
|
-
mscripts?: string[];
|
|
43
|
+
mscripts?: (string | AssetOption)[];
|
|
43
44
|
heads?: string[];
|
|
44
45
|
notice?: boolean;
|
|
45
46
|
}
|
package/builder.js
CHANGED
|
@@ -456,11 +456,12 @@ export class Bundler {
|
|
|
456
456
|
await this.close();
|
|
457
457
|
})(),
|
|
458
458
|
this.copy_files({ print: { info: print, files: false } }),
|
|
459
|
-
this.target === 'web' && this.build_htmls({ info: print, files: false })
|
|
459
|
+
this.target === 'web' && this.htmls && this.build_htmls({ info: print, files: false })
|
|
460
460
|
]);
|
|
461
461
|
}
|
|
462
462
|
async build_htmls(print = { info: true, files: false }) {
|
|
463
463
|
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, }]) => {
|
|
464
|
+
const to_relative = (asset) => path.relative(`${this.fpd_out}${fp_html}`.fdir, `${this.fpd_out}${typeof asset === 'string' ? asset : asset.out}`);
|
|
464
465
|
const html = '<!doctype html>\n' +
|
|
465
466
|
'<html>\n' +
|
|
466
467
|
' <head>\n' +
|
|
@@ -468,11 +469,11 @@ export class Bundler {
|
|
|
468
469
|
" <meta charset='utf-8' />\n" +
|
|
469
470
|
(heads ? heads.map(head => ` ${head}`).join_lines() : '') +
|
|
470
471
|
(device_width ? " <meta name='viewport' content='width=device-width, initial-scale=1.0' />\n" : '') +
|
|
471
|
-
(icon ? ` <link rel='icon' href='${
|
|
472
|
-
(manifest ? ` <link rel='manifest' href='${
|
|
472
|
+
(icon ? ` <link rel='icon' href='${to_relative(icon)}' />\n` : '') +
|
|
473
|
+
(manifest ? ` <link rel='manifest' href='${to_relative(manifest)}' />\n` : '') +
|
|
473
474
|
this.resolve_dependency_files(_dependencies, false, { production: this.production }).map(fp => ` <script src='./vendors/${fp}' defer></script>`).join_lines() +
|
|
474
475
|
(scripts?.before ? scripts.before.map(fp => ` <script src='${fp}' defer></script>`).join_lines() : '') +
|
|
475
|
-
(mscripts ? mscripts.map(
|
|
476
|
+
(mscripts ? mscripts.map(mscript => ` <script src='${to_relative(mscript)}' type='module'></script>`).join_lines() : '') +
|
|
476
477
|
` <script src='${fp_entry}' type='module'></script>\n` +
|
|
477
478
|
(scripts?.after ? scripts.after.map(fp => ` <script src='${fp}' defer></script>`).join_lines() : '') +
|
|
478
479
|
' </head>\n' +
|