@moneko/core 3.47.4 → 3.47.5

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.
@@ -33,9 +33,11 @@ export interface ManifestPluginOption {
33
33
  content_assets?: string[];
34
34
  [key: string]: unknown;
35
35
  }
36
+ declare const base: ManifestPluginOption;
37
+ export declare function generateManifest(override: Partial<ManifestPluginOption>, hash?: string, content_assets?: string[]);
36
38
  export declare class ManifestPlugin {
37
39
  private name: string;
38
40
  private options: ManifestPluginOption;
39
- constructor(options?: ManifestPluginOption);
41
+ constructor(options?: Partial<ManifestPluginOption>);
40
42
  apply(compiler: Compiler);
41
43
  }
@@ -1 +1 @@
1
- import{packageJson as s}from"../process-env.mjs";export class ManifestPlugin{constructor(o){this.name="ManifestPlugin",this.options=Object.assign({filename:"manifest.json",name:s.name,short_name:s.shortName,description:s.description,start_url:s.startUrl??"/?source=pwa",display:s.display??"standalone",background_color:s.backgroundColor??"#fff",theme_color:s.themeColor,icons:[{src:"/favicon.ico",sizes:"48x48",type:"image/x-icon"}]},o??{})}apply(o){let e=this.name,{filename:t,...a}=this.options;o.hooks.thisCompilation.tap(e,i=>{i.hooks.processAssets.tap({name:e,stage:o.webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE},e=>{i.emitAsset(t,new o.webpack.sources.RawSource(JSON.stringify({...a,version:`${s.version}-${i.hash}`,hash:i.fullHash,content_assets:Object.keys(e)})),{javascriptModule:!1})})})}}
1
+ import{packageJson as s}from"../process-env.mjs";let e={filename:"manifest.json",name:s.name,short_name:s.shortName,description:s.description,start_url:s.startUrl??"/?source=pwa",display:s.display??"standalone",background_color:s.backgroundColor??"#fff",theme_color:s.themeColor,icons:[{src:"/favicon.ico",sizes:"48x48",type:"image/x-icon"}]};export function generateManifest(t,o,a){return Object.assign({},e,t,{version:`${s.version}-${o}`,hash:o,content_assets:a})}export class ManifestPlugin{constructor(s){this.name="ManifestPlugin",this.options=Object.assign({},e,s??{})}apply(s){let e=this.name,{filename:t,...o}=this.options;s.hooks.thisCompilation.tap(e,a=>{a.hooks.processAssets.tap({name:e,stage:s.webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE},e=>{a.emitAsset(t,new s.webpack.sources.RawSource(JSON.stringify(generateManifest(o,a.fullHash,Object.keys(e)))),{javascriptModule:!1})})})}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.47.4",
3
+ "version": "3.47.5",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
package/lib/dev.d.mts DELETED
@@ -1,46 +0,0 @@
1
- import { exec, spawn } from 'node:child_process';
2
- import { watchFile } from 'node:fs';
3
- import { relative } from 'node:path';
4
- import process from 'node:process';
5
- import { URL } from 'node:url';
6
- import { ink, print, println, progressBar } from '@moneko/utils';
7
- import webpack, { type Compiler, type OutputFileSystem, type Watching, type WebpackPluginInstance } from 'webpack';
8
- import hotMiddleware, { type ClientOptions } from 'webpack-hot-middleware';
9
- import { merge } from 'webpack-merge';
10
- import { diffObject } from './commom/diff-object.mjs';
11
- import paths, { config_files } from './commom/paths.mjs';
12
- import sigintExit from './commom/sigint-exit.mjs';
13
- import { devLog, PORT } from './dev/config.mjs';
14
- import generateProgressHtml, { type CompliationProcess } from './dev/generate-progress-html.mjs';
15
- import server, { type FileSystem, type Server } from './dev/server.mjs';
16
- import reslove from './options/reslove.mjs';
17
- import { ESLintPlugin } from './plugin/eslint.mjs';
18
- import { StylelintPlugin } from './plugin/stylelint.mjs';
19
- import { empty } from './utils/index.mjs';
20
- import { commonConfig } from './common.mjs';
21
- import { CONFIG, getConfig } from './config.mjs';
22
- import { outputFileSystem } from './file-system.mjs';
23
- import type { ConfigType } from './index.mjs';
24
- import moduleConfig from './module.config.mjs';
25
- import { isLibrary, isReact, refresh } from './process-env.mjs';
26
- type WebpackPlugin = new(opt?: object) => WebpackPluginInstance;
27
- declare let isInitialBuildDone: boolean;
28
- declare const progressApi: string;
29
- declare const compilationProgress: CompliationProcess;
30
- declare const hmrPath: string;
31
- declare const clientParams: ClientOptions;
32
- declare const hotParams: string;
33
- declare const clientOption: webpack.Configuration;
34
- declare function getLintFiles(exts: string[]);
35
- declare const compiler: Compiler;
36
- declare const watching: Watching;
37
- declare const hotUrl: string;
38
- declare const hot: ReturnType<typeof hotMiddleware>;
39
- declare const app: Server;
40
- declare function exit();
41
- declare const _prev: ConfigType[];
42
- declare let prev: ConfigType;
43
- declare function watchConfig(filepath: string);
44
- declare function restart();
45
- declare const isWindow: boolean;
46
- declare function killPort(port: number);
package/lib/dev.mjs DELETED
@@ -1,2 +0,0 @@
1
- import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{relative as r}from"node:path";import i from"node:process";import{URL as n}from"node:url";import{ink as s,print as m,println as a,progressBar as l}from"@moneko/utils";import p from"webpack";import c from"webpack-hot-middleware";import{merge as h}from"webpack-merge";import{diffObject as f}from"./commom/diff-object.mjs";import u,{config_files as d}from"./commom/paths.mjs";import g from"./commom/sigint-exit.mjs";import{devLog as w,PORT as y}from"./dev/config.mjs";import $ from"./dev/generate-progress-html.mjs";import j from"./dev/server.mjs";import v from"./options/reslove.mjs";import{ESLintPlugin as b}from"./plugin/eslint.mjs";import{StylelintPlugin as x}from"./plugin/stylelint.mjs";import{empty as C}from"./utils/index.mjs";import{commonConfig as P}from"./common.mjs";import{CONFIG as _,getConfig as S}from"./config.mjs";import{outputFileSystem as k}from"./file-system.mjs";import H from"./module.config.mjs";import{isLibrary as B,isReact as I,refresh as O}from"./process-env.mjs";let T=!1,q="/____progress____",G={percentage:0,info:""},L="/__hmr__",R=new URLSearchParams({name:"client",path:L.substring(1),dynamicPublicPath:!0,timeout:2e3,reload:!O,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),U=h(P,{watchOptions:{stdin:!0,aggregateTimeout:300,ignored:/node_modules\/(?!(@app)\/)/},entry:{main:[`${v.hotMiddlewareClient}?${R}`]},module:H(!1),plugins:[new p.HotModuleReplacementPlugin,new p.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app)\/)/,/\.d\.ts$/]}),new p.ProgressPlugin({handler(e,t,...o){let r=o.length?`[${t}] ${o.join(" ")}`:" ";T||(G.info=r,G.percentage=e,T=1===e);let n=_.bar;if(n){let t=n.name||"Build";n.quiet?i.stdout.write(`${r}
2
- `):(l(e||0,1,{msg:r,name:t,barColor:n.barColor,nameColor:n.nameColor,barBgColor:n.barBgColor,msgColor:n.msgColor}),1===e&&i.stdout.write("\r\x1b[2K"))}}})]});if(I){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;U.plugins.push(new e({overlay:!1}))}function E(e){let t=e.join(","),o=[r(u.programPath,`${_.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return B&&o.push(r(u.programPath,`${_.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}_.eslint&&U.plugins.push(new b({fix:!0,cache:!0,cacheLocation:`${u.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:E(["js","jsx","ts","tsx","json","html","vue"]),..._.eslint})),_.stylelint&&U.plugins.push(new x({fix:!0,cache:!0,cacheLocation:`${u.lintCachePath}/.stylelintcache`,files:E(["css","scss","sass","less","ts","tsx","js","jsx"]),..._.stylelint}));let F=p(U);F.outputFileSystem=k;let M=F.watch(F.options.watchOptions,w);F.hooks.done.tap("client-log",e=>{w(null,e)});let N=`${_.publicPath}/${L}`.replace(/\/+/g,"/"),J=c(F,{log:!1,path:N,heartbeat:2e3}),K=await j({port:y,root_dir:F.options.output.path,fileSystem:F.outputFileSystem,headers:_.devServer.headers,https:_.devServer.https,host:_.devServer.host,open:_.devServer.open,basename:_.basename,onRequest(e,t){let o=new n(`${_.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if("GET"===e.method){if(o.pathname===q)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(G)),!0;if(!T)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end($(q,G)),!0;if(o.pathname===N&&"text/event-stream"===e.headers.accept)return J(e,t,C),!0}return!1}});function W(){i.exit(0)}K.on("close",()=>{M.close(C),J.close()});let z=await Promise.all(d.map(S)),A=h(z[0]||{},z[1]||{});d.forEach(function(t){o(t,async function(){let[o,r]=await Promise.all(d.map(S)),n=h(o||{},r||{}),l=f(A,n);1===Object.keys(l).length&&"proxy"in l?(m(s(`代理更新中...`,"yellow"),!0),m(s(`代理更新完成...`,"green"),!0),_.proxy=n.proxy,A.proxy=n.proxy,A=n):(A=n,a(s(`检测到工程配置${s(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),e(D?`netstat -ano | findstr :${y}`:`lsof -i :${y} -t`,(e,t)=>{if(e){a(s(`查找端口 ${y} 时发生错误: ${e.message}`,"red")),a(s("请尝试手动重启程序","yellow"));return}let o=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),r=D?o[0]?.split(/\s+/).pop()?.trim():o[0]?.trim();if(!r){a(s(`未找到占用端口 ${y} 的进程, 请尝试手动重启程序`,"yellow"));return}try{i.kill(Number(r),"SIGHUP")}catch(e){a(s(`终止进程 ${r} 时发生错误: ${e.message}`,"red"))}}))})});let D="win32"===i.platform;i.on("SIGHUP",function(){K.close(C),function(){let e=t(i.argv[0],i.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",W)}()}),i.on("exit",function(){K.close(C)}),g(W);