@moneko/core 4.2.2 → 4.2.3

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.
@@ -1 +1 @@
1
- import{existsSync as t,readFileSync as s}from"node:fs";import{basename as e,join as i,resolve as o}from"node:path";import a from"webpack";import{isDev as r,packageJson as n}from"../../process-env.mjs";import{app_basic as c}from"../../vm/basic.mjs";export*from"./types.mjs";export class ManifestPlugin{constructor(t){this.name="ManifestPlugin",this.options={filename:"site.webmanifest",name:n.name,description:n.description,scope:"/",display:"standalone",background_color:"#fff",icons:[{src:"https://h5static.dewucdn.com/node-common/718d5e10-576d-8b14-b0b1-e4c58c3b3f40.webp",type:"image/webp",sizes:"512x512"}]},this.options={...this.options,...t}}getPublicPath(t){if(this.options.publicPath)return this.options.publicPath;let s=t.getAssetPath(t.outputOptions.publicPath,{hash:t.hash}),e="auto"===s?"/":s;return e.length&&!e.endsWith("/")&&(e+="/"),e}addAsset(r,n,c){if(!c)return;let p=this.getPublicPath(n);return c.map(c=>{let h={...c};if(h.src&&!h.src.startsWith("http")){let c=o(r.context,h.src);if(t(c)){let t=e(h.src),o=s(c);n.emitAsset(t,new a.sources.RawSource(o),{javascriptModule:!1}),h.src=i(p,t)}else n.warnings.push(new a.WebpackError(`Asset file ${c} does not exist`))}return h})}apply(t){let s=this.name,{filename:e,start_url:i,icons:o,screenshots:p,...h}=this.options;t.hooks.compilation.tap(s,m=>{m.hooks.processAssets.tap({name:s,stage:a.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE},s=>{let a={...h,start_url:i??this.getPublicPath(m),screenshots:this.addAsset(t,m,p),icons:this.addAsset(t,m,o),version:`${n.version}(${r?"Dev":m.fullHash})`};m.emitAsset(e,new t.webpack.sources.RawSource(JSON.stringify(a)),{javascriptModule:!1}),c.setData("manifest",a),c.setData("resource",Object.keys(s))})})}}
1
+ import{existsSync as t,readFileSync as s}from"node:fs";import{basename as e,join as i,resolve as o}from"node:path";import a from"webpack";import{isDev as r,packageJson as n}from"../../process-env.mjs";import{app_basic as p}from"../../vm/basic.mjs";export*from"./types.mjs";export class ManifestPlugin{constructor(t){this.name="ManifestPlugin",this.options={filename:"site.webmanifest",name:n.name,description:n.description,scope:"/",display:"standalone",background_color:"#fff",icons:[{src:"https://h5static.dewucdn.com/node-common/718d5e10-576d-8b14-b0b1-e4c58c3b3f40.webp",type:"image/webp",sizes:"512x512"}]},this.options={...this.options,...t}}getPublicPath(t){if(this.options.publicPath)return this.options.publicPath;let s=t.getAssetPath(t.outputOptions.publicPath,{hash:t.hash}),e="auto"===s?"/":s;return e.length&&!e.endsWith("/")&&(e+="/"),e}addAsset(r,n,p){if(!p)return;let c=this.getPublicPath(n);return p.map(p=>{let h={...p};if(h.src&&!h.src.startsWith("http")){let p=o(r.context,h.src);if(t(p)){let t=e(h.src),o=s(p);n.emitAsset(t,new a.sources.RawSource(o),{javascriptModule:!1}),h.src=i(c,t)}else n.warnings.push(new a.WebpackError(`Asset file ${p} does not exist`))}return h})}apply(t){let s=this.name,{filename:e,start_url:i,icons:o,screenshots:c,...h}=this.options;t.hooks.thisCompilation.tap(s,m=>{m.hooks.processAssets.tap({name:s,stage:a.Compilation.PROCESS_ASSETS_STAGE_REPORT},()=>{let s={...h,start_url:i??this.getPublicPath(m),screenshots:this.addAsset(t,m,c),icons:this.addAsset(t,m,o),version:`${n.version}(${r?"Dev":m.fullHash})`};m.emitAsset(e,new t.webpack.sources.RawSource(JSON.stringify(s)),{javascriptModule:!1}),p.setData("manifest",s),p.setData("resource",m.getAssets().map(t=>t.name))})})}}
@@ -8,6 +8,6 @@ export declare class ManifestPlugin {
8
8
  getPublicPath(compilation: Compilation): string;
9
9
  addAsset<T extends {
10
10
  src: string;
11
- }>(compiler: Compiler, compilation: Compilation, assets?: T[]): T[] | void;
11
+ }>(compiler: Compiler, compilation: Compilation, assets?: T[]): T[] | undefined;
12
12
  apply(compiler: Compiler): void;
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "4.2.2",
3
+ "version": "4.2.3",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",