xshell 1.0.139 → 1.0.141

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
@@ -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
@@ -461,6 +461,7 @@ export class Bundler {
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='${path.relative(`${this.fpd_out}${fp_html}`.fdir, `${this.fpd_out}${typeof icon === 'string' ? icon : icon.out}`)}' />\n` : '') +
472
- (manifest ? ` <link rel='manifest' href='${path.relative(`${this.fpd_out}${fp_html}`.fdir, `${this.fpd_out}${typeof manifest === 'string' ? manifest : manifest.out}`)}' />\n` : '') +
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(fp => ` <script src='${fp}' type='module'></script>`).join_lines() : '') +
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' +
@@ -528,7 +529,7 @@ export class Bundler {
528
529
  src = out = asset;
529
530
  else
530
531
  ({ src, out } = asset);
531
- await fcopy(`${fpd_root}${src}`, `${fpd_out}${out}`, { print: print.files });
532
+ await fcopy(path.resolve_with_slash(fpd_root, src), `${fpd_out}${out}`, { print: print.files });
532
533
  }
533
534
  await Promise.all([
534
535
  ...this.resolve_dependency_files(dependencies, true, { production })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.139",
3
+ "version": "1.0.141",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
package/path.d.ts CHANGED
@@ -21,6 +21,8 @@ export declare function join(...paths: string[]): string;
21
21
  @param paths A sequence of paths or path segments.
22
22
  @throws {TypeError} if any of the arguments is not a string. */
23
23
  export declare function resolve(...paths: string[]): string;
24
+ /** 和 resolve 一样,但是保留最后一个 path 结尾的 / */
25
+ export declare function resolve_with_slash(...paths: string[]): string;
24
26
  /** Determines whether {path} is an absolute path.
25
27
  An absolute path will always resolve to the same location, regardless of the working directory.
26
28
 
@@ -74,6 +76,7 @@ export declare let path: {
74
76
  normalize: typeof normalize;
75
77
  join: typeof join;
76
78
  resolve: typeof resolve;
79
+ resolve_with_slash: typeof resolve_with_slash;
77
80
  isAbsolute: typeof isAbsolute;
78
81
  relative: typeof relative;
79
82
  dirname: typeof dirname;
package/path.js CHANGED
@@ -36,6 +36,13 @@ export function join(...paths) {
36
36
  export function resolve(...paths) {
37
37
  return to_fp(npath.resolve(...paths.map(p => to_fp(p))));
38
38
  }
39
+ /** 和 resolve 一样,但是保留最后一个 path 结尾的 / */
40
+ export function resolve_with_slash(...paths) {
41
+ let fp = path.resolve(...paths);
42
+ if (paths.last.endsWith('/'))
43
+ fp += '/';
44
+ return fp;
45
+ }
39
46
  /** Determines whether {path} is an absolute path.
40
47
  An absolute path will always resolve to the same location, regardless of the working directory.
41
48
 
@@ -105,6 +112,7 @@ export let path = {
105
112
  normalize,
106
113
  join,
107
114
  resolve,
115
+ resolve_with_slash,
108
116
  isAbsolute,
109
117
  relative,
110
118
  dirname,
@@ -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): 0 | 1 | -1;
71
+ export declare function strcmp(l: string, r: string): 1 | 0 | -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
@@ -37,7 +37,7 @@ export declare function filter_values<TObj extends Record<string, any>>(obj: TOb
37
37
  /** 忽略对象中的 keys, 返回新对象 */
38
38
  export declare function omit<TObj>(obj: TObj, omit_keys: string[]): TObj;
39
39
  /** 字符串字典序比较 */
40
- export declare function strcmp(l: string, r: string): 0 | 1 | -1;
40
+ export declare function strcmp(l: string, r: string): 1 | 0 | -1;
41
41
  /** 比较 1.10.02 这种版本号 */
42
42
  export declare function vercmp(l: string, r: string): number;
43
43
  export declare function get<TReturn = any>(obj: any, keypath: string): TReturn;