@moneko/core 3.55.18-beta.2 → 3.56.0-bate.0

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/lib/common.mjs CHANGED
@@ -1 +1 @@
1
- import{extname as e,join as t,resolve as o}from"node:path";import a,{config_files as s,CUSTOMCONFIG as n,TMP_DIR as i}from"./commom/paths.mjs";import{OverrideResolverPlugin as r}from"./plugin/override-resolve.mjs";import{isObject as l,node_modules as m,resolveProgram as p}from"./utils/index.mjs";import{exampleModuleName as c}from"./vm/example.mjs";import u from"./vm/info.mjs";import{CONFIG as d}from"./config.mjs";import h from"./plugins.config.mjs";import{isCI as f,isDev as g,isLibrary as b,NODE_ENV as y,packageJson as j}from"./process-env.mjs";export const outputConfig={path:p(b?"docs":"dist"),filename:"js/[name].[contenthash].bundle.js",chunkFilename:"js/[contenthash].chunk.js",assetModuleFilename:t=>{let o=e(t.filename||"").substring(1);return`assets/${o}/[hash][ext]`},library:{name:`${u.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"self",chunkLoadingGlobal:`webpackJsonp_${j.name}`,pathinfo:g,clean:!g,publicPath:d.publicPath,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"],uniqueName:`${u.projectName}`};let v={main:[m("@app/entry")]},C=[m("@app/public-path")];if(d.polyfill&&C.push(t(a.corePath,"./polyfills/replace-children.mjs")),d.entry&&("string"==typeof d.entry?v={...v,main:[d.entry]}:Object.keys(d.entry)&&(v=Object.assign(v,d.entry))),"string"==typeof v.main?v.main=[...C,v.main]:Array.isArray(v.main)&&(v.main=[...C,...v.main]),d.output){if("string"==typeof d.output)outputConfig.path=d.output;else if(Object.keys(d.output)){let e=d.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof d.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let P={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:a.webpackCachePath,memoryCacheUnaffected:!0,name:`.${[n,y].filter(Boolean).join("-")}`,version:`${j.version}`,buildDependencies:{config:s},maxMemoryGenerations:1};!1===d.cache?P=!1:l(d.cache)&&(P=Object.assign(P,d.cache)),f&&(void 0===d.cache||d.cache&&!d.cache.cacheDirectory)&&(P.cacheDirectory=o(i,j.name));export const commonConfig={name:"client",target:"web",devtool:d.devtool,entry:v,mode:g?"development":"production",stats:"errors-only",cache:P,snapshot:{immutablePaths:[a.pnpmNodeModules,a.denoNodeModules,/node_modules\/(?!(@app)\/)/],managedPaths:[a.pnpmNodeModules,a.denoNodeModules,/node_modules\/(?!(@app)\/)/],resolveBuildDependencies:{timestamp:!0,hash:!0},resolve:{timestamp:!0,hash:!0},module:{timestamp:!0,hash:!0},buildDependencies:{timestamp:!0,hash:!0}},infrastructureLogging:{level:"error"},externalsPresets:d.externalsPresets,plugins:h,node:{global:!1,__filename:!1,__dirname:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:d.lazyCompilation&&g&&{imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(m(c))||t.startsWith(m("@app/comment"))||t.startsWith(a.pagesPath)||t.startsWith(a.componentsPath)))}},buildHttp:l(d.buildHttp)?{allowedUris:[],lockfileLocation:o(a.httpCachePath,"http.lock"),cacheLocation:o(a.httpCachePath,"data"),upgrade:!0,...d.buildHttp}:d.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:d.alias,modules:[a.nodeModules,a.pnpmNodeModules,a.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:d.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:d.externals,output:outputConfig,recordsPath:d.recordsPath?t(a.programPath,d.recordsPath):t(a.webpackCachePath,"records.json")};d.overrideResolve&&commonConfig.resolve.plugins.push(new r(Object.assign({original:d.alias["@"],override:n&&p(n)},d.overrideResolve)));
1
+ import{extname as e,join as t,resolve as o}from"node:path";import s,{config_files as a,CUSTOMCONFIG as n,TMP_DIR as i}from"./commom/paths.mjs";import{OverrideResolverPlugin as r}from"./plugin/override-resolve.mjs";import{isObject as l,node_modules as m,resolveProgram as p}from"./utils/index.mjs";import{exampleModuleName as c}from"./vm/example.mjs";import u from"./vm/info.mjs";import{CONFIG as d}from"./config.mjs";import h from"./plugins.config.mjs";import{isCI as f,isDev as g,isLibrary as b,NODE_ENV as y,packageJson as j}from"./process-env.mjs";export const outputConfig={path:p(b?"docs":"dist"),filename:"js/[name].[contenthash].bundle.js",chunkFilename:"js/[contenthash].chunk.js",assetModuleFilename:t=>{let o=e(t.filename||"").substring(1);return`assets/${o}/[hash][ext]`},library:{name:`${u.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"self",chunkLoadingGlobal:`webpackJsonp_${j.name}`,pathinfo:g,clean:!g,publicPath:d.publicPath,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"],uniqueName:`${u.projectName}`};let v={main:[m("@app/entry")]},C=[t(s.corePath,"./polyfills/public-path.mjs")];if(d.polyfill&&C.push(t(s.corePath,"./polyfills/replace-children.mjs")),d.entry&&("string"==typeof d.entry?v={...v,main:[d.entry]}:Object.keys(d.entry)&&(v=Object.assign(v,d.entry))),"string"==typeof v.main?v.main=[...C,v.main]:Array.isArray(v.main)&&(v.main=[...C,...v.main]),d.output){if("string"==typeof d.output)outputConfig.path=d.output;else if(Object.keys(d.output)){let e=d.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof d.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let P={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.webpackCachePath,memoryCacheUnaffected:!0,name:`.${[n,y].filter(Boolean).join("-")}`,version:`${j.version}`,buildDependencies:{config:a},maxMemoryGenerations:1};!1===d.cache?P=!1:l(d.cache)&&(P=Object.assign(P,d.cache)),f&&(void 0===d.cache||d.cache&&!d.cache.cacheDirectory)&&(P.cacheDirectory=o(i,j.name));export const commonConfig={name:"client",target:"web",devtool:d.devtool,entry:v,mode:g?"development":"production",stats:"errors-only",cache:P,snapshot:{immutablePaths:[s.pnpmNodeModules,s.denoNodeModules,/node_modules\/(?!(@app)\/)/],managedPaths:[s.pnpmNodeModules,s.denoNodeModules,/node_modules\/(?!(@app)\/)/],resolveBuildDependencies:{timestamp:!0,hash:!0},resolve:{timestamp:!0,hash:!0},module:{timestamp:!0,hash:!0},buildDependencies:{timestamp:!0,hash:!0},contextModule:{timestamp:!0,hash:!0}},infrastructureLogging:{level:"error"},externalsPresets:d.externalsPresets,plugins:h,node:{global:!1,__filename:!1,__dirname:!1},experiments:{asyncWebAssembly:!0,cacheUnaffected:!0,lazyCompilation:d.lazyCompilation&&g&&{imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(m(c))||t.startsWith(m("@app/comment"))||t.startsWith(s.pagesPath)||t.startsWith(s.componentsPath)))}},buildHttp:l(d.buildHttp)?{allowedUris:[],lockfileLocation:o(s.httpCachePath,"http.lock"),cacheLocation:o(s.httpCachePath,"data"),upgrade:!0,...d.buildHttp}:d.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:d.alias,modules:[s.nodeModules,s.pnpmNodeModules,s.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:d.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:d.externals,output:outputConfig,recordsPath:d.recordsPath?t(s.programPath,d.recordsPath):t(s.webpackCachePath,"records.json")};d.overrideResolve&&commonConfig.resolve.plugins.push(new r(Object.assign({original:d.alias["@"],override:n&&p(n)},d.overrideResolve)));
@@ -1 +1 @@
1
- import{createServer as e}from"node:http";import{createServer as t}from"node:https";import{platform as o}from"node:os";import{extname as r,join as n,sep as i}from"node:path";import{env as s}from"node:process";import{ink as a,println as m}from"@moneko/utils";import{CA_ORGANIZATION as p,isCertificateInstalled as c}from"../commom/ca.mjs";import l from"../commom/mime.mjs";import d from"../commom/open.mjs";import C from"../commom/paths.mjs";import{CONFIG as f}from"../config.mjs";import h from"../dev/get-cert.mjs";import{setupProxy as u}from"../dev/proxy.mjs";import y,{cacheBody as A}from"./mock.mjs";let E={"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Headers":"Authorization, Content-Type, Accept, X-Requested-With, Origin, DNT, User-Agent, Cache-Control, X-CSRF-Token, X-API-Key, X-Client-Version, X-Device-ID, Content-Language, Accept-Language, X-Custom-Header, X-Mx-ReqToken, Keep-Alive, If-Modified-Since","Access-Control-Allow-Methods":"GET, DELETE, HEAD, OPTIONS, POST, PUT, PATCH, PURGE, LINK, UNLINK, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, REPORT, SEARCH, CONNECT, TRACE","Access-Control-Allow-Origin":"*","Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0"};async function T(T){let g=n(T.root_dir,"index.html"),w=y({directory:C.mockPath});function O(e,t,o){let n=e.headers["accept-encoding"],i=n?.includes("br"),s=`${o}.${i?"br":"gz"}`,a=T.fileSystem.existsSync(s);a&&t.setHeader("Content-Encoding",i?"br":"gzip");let m=T.fileSystem.createReadStream(a?s:o,{autoClose:!0});m.on("open",()=>{t.writeHead(200,Object.assign({},E,T.headers,{"Access-Control-Allow-Origin":e.headers.origin??"*","Content-Type":l[r(o)]||"application/octet-stream"}))}),m.on("error",e=>{switch(m.destroy(),e.code){case"ENOENT":t.writeHead(301,{Location:"/index.html"}),t.end();break;case"EACCES":t.writeHead(403,{"Content-Type":"text/plain"}),t.end(`Forbidden: ${e.message}`);break;default:t.writeHead(500,{"Content-Type":"text/plain"}),t.end(`Internal Server Error: ${e.message}`)}}),m.pipe(t)}async function x(e,t){if(A(e),!(T.onRequest&&T.onRequest(e,t))){if(!(f.proxy&&await u(e,t,f.proxy)||t.writableEnded||w&&w(e,t))&&!t.writableEnded){if("GET"===e.method){let o="/"===e.url?g:decodeURIComponent(n(T.root_dir,e.url.replace(T.basename??"/","/")));if(T.fileSystem.existsSync(o))return O(e,t,o)}if(e.headers.accept?.includes("text/html"))return O(e,t,g);t.writeHead(404,{"Content-Type":"text/plain"}),t.end("File Not Found")}}}let S=T.https?t(await h(T.host,!0===T.https?{install:!0}:T.https),x):e(x);if(S.listen(T.port),T.https&&!await c(p)&&"darwin"===o()){let e=s.npm_execpath?.split(i).pop()?.split(".").shift()||"npm",t=s.npm_lifecycle_event??"start",o=`> sudo ${e} ${t}`;m(a("⚠️ 未检测到本地 SSL 证书,请通过以下命令重启项目以安装证书: ","yellow")),m(a(o,"yellow")),m("")}return T.open&&d(`${T.https?"https:":"http:"}//${T.host}:${T.port}${"/"===T.basename?"":T.basename}`),S}export default T;
1
+ import{createServer as e}from"node:http";import{createServer as t}from"node:https";import{platform as o}from"node:os";import{extname as r,join as n,sep as i}from"node:path";import{env as s}from"node:process";import{ink as a,println as m}from"@moneko/utils";import{CA_ORGANIZATION as p,isCertificateInstalled as l}from"../commom/ca.mjs";import c from"../commom/mime.mjs";import d from"../commom/open.mjs";import C from"../commom/paths.mjs";import{CONFIG as f}from"../config.mjs";import h from"../dev/get-cert.mjs";import{setupProxy as u}from"../dev/proxy.mjs";import A,{cacheBody as y}from"./mock.mjs";let E={"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Headers":"Authorization, Content-Type, Accept, X-Requested-With, Origin, DNT, User-Agent, Cache-Control, X-CSRF-Token, X-API-Key, X-Client-Version, X-Device-ID, Content-Language, Accept-Language, X-Custom-Header, X-Mx-ReqToken, Keep-Alive, If-Modified-Since","Access-Control-Allow-Methods":"GET, DELETE, HEAD, OPTIONS, POST, PUT, PATCH, PURGE, LINK, UNLINK, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, REPORT, SEARCH, CONNECT, TRACE","Access-Control-Allow-Origin":"*","Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0"};async function T(T){let g=n(T.root_dir,"index.html"),w=A({directory:C.mockPath});function O(e,t,o){let n=e.headers["accept-encoding"],i=n?.includes("br"),s=`${o}.${i?"br":"gz"}`,a=T.fileSystem.existsSync(s);a&&t.setHeader("Content-Encoding",i?"br":"gzip");let m=T.fileSystem.createReadStream(a?s:o,{autoClose:!0});m.on("open",()=>{t.writeHead(200,Object.assign({},E,T.headers,{"Access-Control-Allow-Origin":e.headers.origin??"*","Content-Type":c[r(o)]||"application/octet-stream"}))}),m.on("error",e=>{switch(m.readable=!0,e.code){case"ENOENT":t.writeHead(301,{Location:"/index.html"}),t.end();break;case"EACCES":t.writeHead(403,{"Content-Type":"text/plain"}),t.end(`Forbidden: ${e.message}`);break;default:t.writeHead(500,{"Content-Type":"text/plain"}),t.end(`Internal Server Error: ${e.message}`)}}),m.pipe(t)}async function x(e,t){if(y(e),!(T.onRequest&&T.onRequest(e,t))){if(!(f.proxy&&await u(e,t,f.proxy)||t.writableEnded||w&&w(e,t))&&!t.writableEnded){if("GET"===e.method){let o="/"===e.url?g:decodeURIComponent(n(T.root_dir,e.url.replace(T.basename??"/","/")));if(T.fileSystem.existsSync(o))return O(e,t,o)}if(e.headers.accept?.includes("text/html"))return O(e,t,g);t.writeHead(404,{"Content-Type":"text/plain"}),t.end("File Not Found")}}}let S=T.https?t(await h(T.host,!0===T.https?{install:!0}:T.https),x):e(x);if(S.listen(T.port),T.https&&!await l(p)&&"darwin"===o()){let e=s.npm_execpath?.split(i).pop()?.split(".").shift()||"npm",t=s.npm_lifecycle_event??"start",o=`> sudo ${e} ${t}`;m(a("⚠️ 未检测到本地 SSL 证书,请通过以下命令重启项目以安装证书: ","yellow")),m(a(o,"yellow")),m("")}return T.open&&d(`${T.https?"https:":"http:"}//${T.host}:${T.port}${"/"===T.basename?"":T.basename}`),S}export default T;
package/lib/dev.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{join as r,relative as n}from"node:path";import i from"node:process";import{URL as s}from"node:url";import{ink as a,print as m,println as l,progressBar as p}from"@moneko/utils";import c from"webpack";import f from"webpack-hot-middleware";import{merge as h}from"webpack-merge";import{diffObject as u}from"./commom/diff-object.mjs";import d,{config_files as g}from"./commom/paths.mjs";import w from"./commom/sigint-exit.mjs";import{devLog as y,PORT as j}from"./dev/config.mjs";import $ from"./dev/generate-progress-html.mjs";import v from"./dev/server.mjs";import b from"./options/reslove.mjs";import{ESLintPlugin as C}from"./plugin/eslint.mjs";import{generateManifest as x}from"./plugin/manifest.mjs";import{StylelintPlugin as _}from"./plugin/stylelint.mjs";import{empty as P}from"./utils/index.mjs";import{commonConfig as S}from"./common.mjs";import{CONFIG as k,getConfig as H}from"./config.mjs";import{outputFileSystem as O}from"./file-system.mjs";import T from"./module.config.mjs";import{isLibrary as B,isReact as E,refresh as I}from"./process-env.mjs";let q=!1,G="/____progress____",L={percentage:0,info:""},N="/__hmr__",R=new URLSearchParams({name:"client",path:N.substring(1),dynamicPublicPath:!0,timeout:2e3,reload:!I,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),U=h(S,{watchOptions:{stdin:!0,aggregateTimeout:300,ignored:/node_modules\/(?!(@app)\/)/},entry:{main:[`${b.hotMiddlewareClient}?${R}`]},module:T(!1),plugins:[new c.HotModuleReplacementPlugin,new c.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app)\/)/,/\.d\.ts$/]}),new c.ProgressPlugin({handler(e,t,...o){let r=o.length?`[${t}] ${o.join(" ")}`:" ";q||(L.info=r,L.percentage=e,q=1===e);let n=k.bar;if(n){let t=n.name||"Build";n.quiet?i.stdout.write(`${r}
2
- `):(p(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(E){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;U.plugins.push(new e({overlay:!1}))}function F(e){let t=e.join(","),o=[n(d.programPath,`${k.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return B&&o.push(n(d.programPath,`${k.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}k.eslint&&U.plugins.push(new C({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:F(["js","jsx","ts","tsx","json","html","vue"]),...k.eslint})),k.stylelint&&U.plugins.push(new _({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.stylelintcache`,files:F(["css","scss","sass","less","ts","tsx","js","jsx"]),...k.stylelint}));let J=c(U);if(!J)throw Error("无法创建编译器");J.outputFileSystem=O;let M=J.watch(J.options.watchOptions,y);J.hooks.done.tap("client-log",e=>{y(null,e)});let A=`${k.basename}/${N}`.replace(/\/+/g,"/"),K=f(J,{log:!1,path:A,heartbeat:2e3}),W=!!k.manifest&&r(k.basename,k.manifest.filename).replaceAll(/\\/g,"/"),z=await v({port:j,root_dir:J.options.output.path,fileSystem:J.outputFileSystem,headers:k.devServer.headers,https:k.devServer.https,host:k.devServer.host,open:k.devServer.open,basename:k.basename,onRequest(e,t){if(!t.writableEnded){if("GET"===e.method){let o=new s(`${k.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if(W&&o.pathname===W)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(x({}))),!0;if(o.pathname===G)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(L)),!0;if(!q)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end($(G,L)),!0;if(o.pathname===A&&"text/event-stream"===e.headers.accept)return K(e,t,P),!0}return!1}}});function D(){i.exit(0)}z.on("close",()=>{M.close(P),K.close()});let Q=await Promise.all(g.map(H)),V=h(Q[0]||{},Q[1]||{});g.forEach(function(t){o(t,async function(){var o;let[r,n]=await Promise.all(g.map(H)),s=h(r||{},n||{}),p=u(V,s);1===Object.keys(p).length&&"proxy"in p?(m(a(`代理更新中...`,"yellow"),!0),m(a(`代理更新完成...`,"green"),!0),k.proxy=s.proxy,V.proxy=s.proxy,V=s):(V=s,l(a(`检测到工程配置${a(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),o=j,e(X?`netstat -ano | findstr :${o}`:`lsof -i :${o} -t`,(e,t)=>{if(e){l(a(`查找端口 ${o} 时发生错误: ${e.message}`,"red")),l(a("请尝试手动重启程序","yellow"));return}let r=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),n=X?r[0]?.split(/\s+/).pop()?.trim():r[0]?.trim();if(!n)return void l(a(`未找到占用端口 ${o} 的进程, 请尝试手动重启程序`,"yellow"));try{i.kill(Number(n),"SIGHUP")}catch(e){l(a(`终止进程 ${n} 时发生错误: ${e.message}`,"red"))}}))})});let X="win32"===i.platform;i.on("SIGHUP",function(){z.close(P);let e=t(i.argv[0],i.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",D)}),i.on("exit",function(){z.close(P)}),w(D);
1
+ import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{join as r,relative as i}from"node:path";import n from"node:process";import{URL as s}from"node:url";import{ink as a,print as m,println as l,progressBar as p}from"@moneko/utils";import c from"webpack";import f from"webpack-hot-middleware";import{merge as h}from"webpack-merge";import{diffObject as u}from"./commom/diff-object.mjs";import d,{config_files as g}from"./commom/paths.mjs";import w from"./commom/sigint-exit.mjs";import{devLog as y,PORT as j}from"./dev/config.mjs";import $ from"./dev/generate-progress-html.mjs";import v from"./dev/server.mjs";import b from"./options/reslove.mjs";import{ESLintPlugin as C}from"./plugin/eslint.mjs";import{generateManifest as x}from"./plugin/manifest.mjs";import{StylelintPlugin as _}from"./plugin/stylelint.mjs";import{empty as P}from"./utils/index.mjs";import{commonConfig as S}from"./common.mjs";import{CONFIG as k,getConfig as H}from"./config.mjs";import{outputFileSystem as E}from"./file-system.mjs";import O from"./module.config.mjs";import{isLibrary as T,isReact as B,refresh as I}from"./process-env.mjs";let q=!1,G="/____progress____",L={percentage:0,info:""},N="/__hmr__",R=new URLSearchParams({name:"client",path:N.substring(1),dynamicPublicPath:!0,timeout:2e3,reload:!I,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),U=h(S,{watchOptions:{stdin:!0,aggregateTimeout:300,ignored:/node_modules\/(?!(@app)\/)/},entry:{main:[`${b.hotMiddlewareClient}?${R}`]},module:O(!1),plugins:[new c.HotModuleReplacementPlugin,new c.WatchIgnorePlugin({paths:[/node_modules\/(?!(@app)\/)/,/\.d\.ts$/]}),new c.ProgressPlugin({handler(e,t,...o){let r=o.length?`[${t}] ${o.join(" ")}`:" ";q||(L.info=r,L.percentage=e,q=1===e);let i=k.bar;if(i){let t=i.name||"Build";i.quiet?n.stdout.write(`${r}
2
+ `):(p(e||0,1,{msg:r,name:t,barColor:i.barColor,nameColor:i.nameColor,barBgColor:i.barBgColor,msgColor:i.msgColor}),1===e&&n.stdout.write("\r\x1b[2K"))}}})]});if(B){let e=(await import("@pmmmwh/react-refresh-webpack-plugin")).default;U.plugins.push(new e({overlay:!1}))}function F(e){let t=e.join(","),o=[i(d.programPath,`${k.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return T&&o.push(i(d.programPath,`${k.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}k.eslint&&U.plugins.push(new C({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:F(["js","jsx","ts","tsx","json","html","vue"]),...k.eslint})),k.stylelint&&U.plugins.push(new _({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.stylelintcache`,files:F(["css","scss","sass","less","ts","tsx","js","jsx"]),...k.stylelint}));let J=c(U);if(!J)throw Error("无法创建编译器");J.outputFileSystem=E;let M=J.watch(J.options.watchOptions,y);if(!M)throw Error("无法创建监视器");J.hooks.done.tap("client-log",e=>{y(null,e)});let A=`${k.basename}/${N}`.replace(/\/+/g,"/"),K=f(J,{log:!1,path:A,heartbeat:2e3}),W=!!k.manifest&&r(k.basename,k.manifest.filename).replaceAll(/\\/g,"/"),z=await v({port:j,root_dir:J.options.output.path,fileSystem:J.outputFileSystem,headers:k.devServer.headers,https:k.devServer.https,host:k.devServer.host,open:k.devServer.open,basename:k.basename,onRequest(e,t){if(!t.writableEnded){if("GET"===e.method){let o=new s(`${k.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if(W&&o.pathname===W)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(x({}))),!0;if(o.pathname===G)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(L)),!0;if(!q)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end($(G,L)),!0;if(o.pathname===A&&"text/event-stream"===e.headers.accept)return K(e,t,P),!0}return!1}}});function D(){n.exit(0)}z.on("close",()=>{M.close(P),K.close()});let Q=await Promise.all(g.map(H)),V=h(Q[0]||{},Q[1]||{});g.forEach(function(t){o(t,async function(){var o;let[r,i]=await Promise.all(g.map(H)),s=h(r||{},i||{}),p=u(V,s);1===Object.keys(p).length&&"proxy"in p?(m(a(`代理更新中...`,"yellow"),!0),m(a(`代理更新完成...`,"green"),!0),k.proxy=s.proxy,V.proxy=s.proxy,V=s):(V=s,l(a(`检测到工程配置${a(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),o=j,e(X?`netstat -ano | findstr :${o}`:`lsof -i :${o} -t`,(e,t)=>{if(e){l(a(`查找端口 ${o} 时发生错误: ${e.message}`,"red")),l(a("请尝试手动重启程序","yellow"));return}let r=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),i=X?r[0]?.split(/\s+/).pop()?.trim():r[0]?.trim();if(!i)return void l(a(`未找到占用端口 ${o} 的进程, 请尝试手动重启程序`,"yellow"));try{n.kill(Number(i),"SIGHUP")}catch(e){l(a(`终止进程 ${i} 时发生错误: ${e.message}`,"red"))}}))})});let X="win32"===n.platform;n.on("SIGHUP",function(){z.close(P);let e=t(n.argv[0],n.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",D)}),n.on("exit",function(){z.close(P)}),w(D);
@@ -1,2 +1,2 @@
1
- let e;import{join as s,sep as o}from"node:path";import{saveFileSync as t}from"@moneko/utils";import r,{CUSTOMCONFIG as a}from"./commom/paths.mjs";import n from"./commom/reactive-object.mjs";import i from"./commom/require.mjs";import m from"./commom/rule.mjs";import l from"./options/css-extract.mjs";import c from"./options/modify-vars.mjs";import d from"./options/reslove.mjs";import p from"./options/swcrc.mjs";import{getLightningCssTargets as u}from"./polyfills/targets.mjs";import{node_modules as f,resolveProgram as h,toCamelCase as j}from"./utils/index.mjs";import y from"./utils/svg-to-data-uri.mjs";import{comment as g,getCommentPath as v}from"./vm/docs.mjs";import x from"./vm/generate-doc.mjs";import{outputConfig as w}from"./common.mjs";import{CONFIG as P}from"./config.mjs";import{FRAMEWORK as L,isDev as M,isLibrary as O}from"./process-env.mjs";let _={loader:s(r.corePath,"/loader/lightning-css/loader.cjs"),options:{sourceMap:!!P.sourceMap,targets:u(),rem:!!P.rem,esModule:!0,modules:{auto(e){if(e){if(e.endsWith(".css")&&!e.endsWith("module.css"))return!1;for(let s=0,o=$.length;s<o;s++)if(e.includes($[s]))return m.css_module.test(e)}return m.node_modules_css_module.test(e)},localIdentName:"[hash]_[local]",namedExport:!0,exportLocalsConvention:"dashesOnly",exportOnlyLocals:!1,getJSON:P.cssModuleDefinition?function(e){q.setData(`${e.resourcePath}.d.ts`,`${e.exports.map(({name:e,value:s})=>`export const ${j(e)}: '${s}';`).join("\n")}
2
- `)}:void 0},importLoaders:2}},k={loader:d.lessLoader,options:{sourceMap:!!P.sourceMap,lessOptions:{modifyVars:c,javascriptEnabled:!0}}},C=new Map;function I(e){if(C.has(e))return C.get(e);try{let s,t=i.resolve(e).split(o),r=t.lastIndexOf("node_modules");return s=-1!==r?t.slice(0,r).join(o):t.join(o),C.set(e,[s]),[s]}catch{try{let s=i.resolve(`${e}${o}package.json`).replace(`${o}package.json`,"");C.set(e,[s])}catch{C.set(e,[f(e),f(`.pnpm/${e}`)])}return C.get(e)}}let $=[...P.cssModules,`@moneko/${L}`,"neko-ui"].map(I).flat(),b=["components","example","mock","site","src","server"].map(h);function B(e){return new Promise(s=>{s([...b,r.corePath,...P.rulesInclude?.[e]?.map(I).flat()||[]])})}a&&b.push(h(a)),P.overrideResolve&&P.overrideResolve.override&&b.push(P.overrideResolve.override);let J=await Promise.all([B("css"),B("js"),B("media"),B("wasm"),B("font")]),N=J[0],W=J[1],E=J[2],R=J[3],D=J[4];d.sassLoader&&(e={loader:d.sassLoader,options:{implementation:await import("sass"),sassOptions:{}}});let S=O&&M&&{test:m.tsdoc,include:P.alias["@pkg"],exclude:[/node_modules\/(?!(@app|@moneko)).+/,m.__tests__],enforce:"pre",loader:s(r.corePath,"/loader/ts-doc.cjs"),options:{comment:g,generateDoc:x,getCommentPath:v}},z=w.library?.type==="umd"&&!1===P.htmlPluginOption,Q=[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename(e){let s=e.filename;return s&&s.toLocaleLowerCase().endsWith("wasm?url")?"wasm/[hash][ext]":"assets/[hash][ext]"}}},{test:m.wasm,type:"webassembly/async",include:R},{test:m.txt,type:"asset/source"},{test:m.image,type:"asset",dependency:{not:["url"]},parser:{dataUrlCondition:z?()=>!0:{maxSize:4096}},generator:{filename:e=>e.filename?.toLocaleLowerCase().endsWith(".svg")?"assets/svg/[hash][ext]":"assets/images/[hash][ext]",dataUrl:(e,s)=>s.filename.toLocaleLowerCase().endsWith(".svg")?y(e.toString()):e},include:E},{test:m.video,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[hash][ext]"},include:E},{test:m.font,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[hash][ext]"},include:D}],U=P.prefixJsLoader.filter(Boolean)||[];"react"===L&&P.reactCompiler&&U.unshift({loader:s(r.corePath,"/loader/react-compiler.cjs"),options:{panicThreshold:M?void 0:"NONE",...P.reactCompiler}}),P.cssInJs&&"object"==typeof P.cssInJs.minify&&U.unshift({loader:s(r.corePath,"/loader/css-in-js-minify.cjs"),options:Object.assign({moduleName:"@moneko/css",allowFuncs:["css","injectGlobal"]},P.cssInJs.minify)});let q=new n({});q.on("change",(e,s)=>{t(e,s)});export default(o=>{let t={react:{loader:d.swcLoader,options:p(o)},solid:{loader:s(r.corePath,"/loader/solid.cjs"),options:{jsxOptions:P.jsxDomExpressions,refresh:P.refresh}}}[L];return{parser:{javascript:{commonjsMagicComments:!0,dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,importMeta:!0,importMetaContext:!0}},noParse:P.noParse,rules:[!1!==P.htmlPluginOption&&S,{oneOf:[...Q,{test:m.js,use:[...U,t].filter(Boolean),include:W},{test:m.css,use:[l,_],include:N},e&&{test:m.scss,use:[l,_,e],include:N},{test:m.less,use:[l,_,k],include:N},{test:m.markdown,use:[...U,{loader:s(r.corePath,"/loader/mdx.cjs"),options:P.mdx}].filter(Boolean),exclude:[/node_modules\/(?!(@app|@moneko)).+/]}].filter(Boolean)},...P.moduleRules].filter(Boolean)}});
1
+ let e;import{join as o,sep as s}from"node:path";import{saveFileSync as t}from"@moneko/utils";import r,{CUSTOMCONFIG as a}from"./commom/paths.mjs";import n from"./commom/reactive-object.mjs";import i from"./commom/require.mjs";import m from"./commom/rule.mjs";import l from"./options/css-extract.mjs";import c from"./options/modify-vars.mjs";import p from"./options/reslove.mjs";import d from"./options/swcrc.mjs";import{getLightningCssTargets as u}from"./polyfills/targets.mjs";import{node_modules as f,resolveProgram as h,toCamelCase as j}from"./utils/index.mjs";import x from"./utils/svg-to-data-uri.mjs";import{comment as y,getCommentPath as g}from"./vm/docs.mjs";import v from"./vm/generate-doc.mjs";import{outputConfig as w}from"./common.mjs";import{CONFIG as M}from"./config.mjs";import{FRAMEWORK as P,isDev as L,isLibrary as O}from"./process-env.mjs";let _={loader:o(r.corePath,"/loader/lightning-css/loader.cjs"),options:{sourceMap:!!M.sourceMap,targets:u(),rem:!!M.rem,esModule:!0,modules:{auto(e){if(e){if(e.endsWith(".css")&&!e.endsWith("module.css"))return!1;for(let o=0,s=$.length;o<s;o++)if(e.includes($[o]))return m.css_module.test(e)}return m.node_modules_css_module.test(e)},localIdentName:"[hash]_[local]",namedExport:!0,exportLocalsConvention:"dashesOnly",exportOnlyLocals:!1,getJSON:M.cssModuleDefinition?function(e){q.setData(`${e.resourcePath}.d.ts`,`${e.exports.map(({name:e,value:o})=>`export const ${j(e)}: '${o}';`).join("\n")}
2
+ `)}:void 0},importLoaders:2}},k={loader:p.lessLoader,options:{sourceMap:!!M.sourceMap,lessOptions:{modifyVars:c,javascriptEnabled:!0}}},C=new Map;function I(e){if(C.has(e))return C.get(e);try{let o,t=i.resolve(e).split(s),r=t.lastIndexOf("node_modules");return o=-1!==r?t.slice(0,r).join(s):t.join(s),C.set(e,[o]),[o]}catch{try{let o=i.resolve(`${e}${s}package.json`).replace(`${s}package.json`,"");C.set(e,[o])}catch{C.set(e,[f(e),f(`.pnpm/${e}`)])}return C.get(e)}}let $=[...M.cssModules,`@moneko/${P}`,"neko-ui"].map(I).flat(),b=["components","example","mock","site","src","server"].map(h);function S(e){return new Promise(o=>{o([...b,r.corePath,...M.rulesInclude?.[e]?.map(I).flat()||[]])})}a&&b.push(h(a)),M.overrideResolve&&M.overrideResolve.override&&b.push(M.overrideResolve.override);let B=await Promise.all([S("css"),S("js"),S("media"),S("wasm"),S("font")]),J=B[0],N=B[1],W=B[2],E=B[3],R=B[4];p.sassLoader&&(e={loader:p.sassLoader,options:{implementation:await import("sass"),sassOptions:{}}});let D=O&&L&&{test:m.tsdoc,include:M.alias["@pkg"],exclude:[/node_modules\/(?!(@app|@moneko)).+/,m.__tests__],enforce:"pre",loader:o(r.corePath,"/loader/ts-doc.cjs"),options:{comment:y,generateDoc:v,getCommentPath:g}},z=w.library?.type==="umd"&&!1===M.htmlPluginOption,Q=[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename(e){let o=e.filename;return o&&o.toLocaleLowerCase().endsWith("wasm?url")?"wasm/[hash][ext]":"assets/[hash][ext]"}}},{test:m.wasm,type:"webassembly/async",include:E},{test:m.txt,type:"asset/source"},{test:m.image,type:"asset",dependency:{not:["url"]},parser:{dataUrlCondition:z?()=>!0:{maxSize:4096}},generator:{filename:e=>e.filename?.toLocaleLowerCase().endsWith(".svg")?"assets/svg/[hash][ext]":"assets/images/[hash][ext]",dataUrl:(e,o)=>o.filename.toLocaleLowerCase().endsWith(".svg")?x(e.toString()):e},include:W},{test:m.video,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[hash][ext]"},include:W},{test:m.font,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[hash][ext]"},include:R}],U=M.prefixJsLoader.filter(Boolean)||[];"react"===P&&M.reactCompiler&&U.unshift({loader:o(r.corePath,"/loader/react-compiler.cjs"),options:{panicThreshold:L?void 0:"NONE",...M.reactCompiler}}),M.cssInJs&&"object"==typeof M.cssInJs.minify&&U.unshift({loader:o(r.corePath,"/loader/css-in-js-minify.cjs"),options:Object.assign({moduleName:"@moneko/css",allowFuncs:["css","injectGlobal"]},M.cssInJs.minify)});let q=new n({});q.on("change",(e,o)=>{t(e,o)});export default(s=>{let t={react:{loader:p.swcLoader,options:d(s)},solid:{loader:o(r.corePath,"/loader/solid.cjs"),options:{jsxOptions:M.jsxDomExpressions,refresh:M.refresh}}}[P];return{parser:{javascript:{commonjsMagicComments:!0,dynamicImportMode:"lazy",dynamicImportPrefetch:!1,dynamicImportPreload:!1,importMeta:!0,importMetaContext:!0}},noParse:M.noParse,rules:[!1!==M.htmlPluginOption&&D,{oneOf:[...Q,{test:m.js,use:[...U,t].filter(Boolean),include:N,extractSourceMap:!0},{test:m.css,use:[l,_],include:J,extractSourceMap:!0},e&&{test:m.scss,use:[l,_,e],include:J,extractSourceMap:!0},{test:m.less,use:[l,_,k],include:J,extractSourceMap:!0},{test:m.markdown,use:[...U,{loader:o(r.corePath,"/loader/mdx.cjs"),options:M.mdx}].filter(Boolean),exclude:[/node_modules\/(?!(@app|@moneko)).+/],extractSourceMap:!0}].filter(Boolean)},...M.moduleRules].filter(Boolean)}});
@@ -1 +1 @@
1
- import{join as e,parse as t,resolve as o}from"node:path";import{fileURLToPath as s}from"node:url";import{Worker as i}from"node:worker_threads";import{loadFile as r}from"@moneko/utils";import a from"webpack";import n from"../utils/create-types.mjs";import m from"../vm/public-path.mjs";export class ModuleFederationExposesDeclarationPlugin{constructor(e){this.name="ModuleFederationExposesDeclarationPlugin",this.assetName="module-federation.d.ts",this.dts="",this.option=e,this.worker=new i(s(new URL("../worker/dts.mjs",import.meta.url))),this.worker.setMaxListeners(0),this.worker.postMessage({options:{compilerOptions:{isolatedModules:!1,outFile:this.assetName,verbatimModuleSyntax:!1},include:[...Object.values(e.exposes),"typings/**/*.d.ts"]}}),this.worker.once("message",e=>{this.dts=e,this.worker.terminate()})}apply(s){let{exposes:i}=this.option,p=Object.keys(i).map(e=>{let t=e.replace(/\.tsx?$/i,"");return{key:e,name:t,path:o(`types/${this.option.name}/${t}.d.ts`),originPath:i[e]}});s.hooks.thisCompilation.tap({name:this.name,stage:s.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},o=>{o.hooks.processAssets.tapPromise(this.name,async()=>{let s=p.map(async o=>{if(o.originPath===m.moduleName)return`${n(e(this.option.name,o.name),m.dts)}`;if(null!==await r(o.originPath)){let s=t(o.originPath);return`${n(e(this.option.name,o.name),`export * from '${t(s.dir).name}/${s.name}'`)}`}return""}),i=await Promise.all(s);i.unshift(this.dts),o.emitAsset("module-federation.d.ts",new a.sources.RawSource(i.join("\n")),{javascriptModule:!1})})})}}
1
+ import{join as e,parse as t,resolve as s}from"node:path";import{fileURLToPath as o}from"node:url";import{Worker as i}from"node:worker_threads";import{fileExists as r,loadFile as a}from"@moneko/utils";import n from"webpack";import m from"../utils/create-types.mjs";export class ModuleFederationExposesDeclarationPlugin{constructor(e){this.name="ModuleFederationExposesDeclarationPlugin",this.assetName="module-federation.d.ts",this.dts="",this.option=e,this.worker=new i(o(new URL("../worker/dts.mjs",import.meta.url))),this.worker.setMaxListeners(0),this.worker.postMessage({options:{compilerOptions:{isolatedModules:!1,outFile:this.assetName,verbatimModuleSyntax:!1},include:[...Object.values(e.exposes),"typings/**/*.d.ts"]}}),this.worker.once("message",e=>{this.dts=e,this.worker.terminate()})}apply(o){let{exposes:i}=this.option,p=Object.keys(i).map(e=>{let t=e.replace(/\.tsx?$/i,"");return{key:e,name:t,path:s(`types/${this.option.name}/${t}.d.ts`),originPath:i[e]}});o.hooks.thisCompilation.tap({name:this.name,stage:o.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},s=>{s.hooks.processAssets.tapPromise(this.name,async()=>{let o=p.map(async s=>{if(r(s.originPath)){let o=t(s.originPath),i=`export * from '${t(o.dir).name}/${o.name}'`;if("public-path"===o.name){let e=await a(s.originPath.replace(/\.mjs$/,".d.mts"));e&&(i=e)}return`${m(e(this.option.name,s.name),i)}`}return""}),i=await Promise.all(o);i.unshift(this.dts),s.emitAsset("module-federation.d.ts",new n.sources.RawSource(i.join("\n")),{javascriptModule:!1})})})}}
@@ -1 +1 @@
1
- import e from"webpack";let t=e.sources,r="ExternalRemotesPlugin";export class ExternalRemotesPlugin{apply(e){e.hooks.make.tap(r,e=>{let n=[];e.hooks.buildModule.tap(r,e=>{"ExternalModule"===e.constructor.name&&"script"===e.externalType&&n.push(e)}),e.hooks.afterCodeGeneration.tap(r,function(){n.map(r=>{let n=function(e){let t=e.indexOf("@");if(t<=0||t===e.length-1)throw Error(`Invalid request "${e}"`);return[e.substring(t+1),e.substring(0,t)]}(r.request)[0],o=function(e){let t=[],r=[],n=!1,o=!1;for(let s of e)if("["===s){if(n){o=!0;break}n=!0,r.length&&(t.push(`"${r.join("")}"`),r.length=0)}else if("]"===s){if(!n){o=!0;break}n=!1,r.length&&(t.push(`${r.join("")}`),r.length=0),r.length=0}else r.push(s);if(n||o)throw Error(`Invalid template URL "${e}"`);return r.length&&t.push(`"${r.join("")}"`),t.join(" + ")}(n),s=e.codeGenerationResults.get(r,void 0).sources,l=s.get("javascript")?.source();l&&s.set("javascript",new t.RawSource(l.replace(`"${n}"`,o)))})})})}}
1
+ import e from"webpack";let t=e.sources,r="ExternalRemotesPlugin";export class ExternalRemotesPlugin{apply(e){e.hooks.make.tap(r,e=>{let n=[];e.hooks.buildModule.tap(r,e=>{"ExternalModule"===e.constructor.name&&"script"===e.externalType&&n.push(e)}),e.hooks.afterCodeGeneration.tap(r,function(){n.map(r=>{let n=function(e){let t=e.indexOf("@");if(t<=0||t===e.length-1)throw Error(`Invalid request "${e}"`);return[e.substring(t+1),e.substring(0,t)]}(r.request)[0],o=function(e){let t=[],r=[],n=!1,o=!1;for(let s of e)if("["===s){if(n){o=!0;break}n=!0,r.length&&(t.push(`"${r.join("")}"`),r.length=0)}else if("]"===s){if(!n){o=!0;break}n=!1,r.length&&(t.push(`${r.join("")}`),r.length=0),r.length=0}else r.push(s);if(n||o)throw Error(`Invalid template URL "${e}"`);return r.length&&t.push(`"${r.join("")}"`),t.join(" + ")}(n),s=e.codeGenerationResults?.get(r,void 0).sources,l=s?.get("javascript")?.source();l&&s&&s.set("javascript",new t.RawSource(l.replace(`"${n}"`,o)))})})})}}
@@ -51,7 +51,7 @@ export declare class HtmlPlugin {
51
51
  private cachedMetaTags;
52
52
  private cachedCustomTags;
53
53
  constructor(options?: HtmlPluginOption);
54
- getPublicPath(compilation: Compilation, filename: string): string;
54
+ getPublicPath(compilation: Compilation): string;
55
55
  apply(compiler: Compiler): void;
56
56
  private generateDefaultTemplate;
57
57
  private generateMetaTags;
@@ -1 +1 @@
1
- import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,dirname as i,relative as o,resolve as n,sep as a}from"node:path";import h from"webpack";export class HtmlPlugin{constructor(t={}){this.AddEntry=/(?:.*\/)?main\.[a-zA-Z0-9]+\.bundle\.js$/,this.faviconPath="",this.name="HtmlPlugin",this.cachedMetaTags=null,this.cachedCustomTags=null,this.options={title:"WebApp",filename:"index.html",inject:"head",...t}}getPublicPath(t,e){let s=t.getAssetPath(t.outputOptions.publicPath,{hash:t.hash}),h="auto"!==s?s:o(n(t.options.output.path,i(e)),t.options.output.path).split(a).join("/");return h.length&&!h.endsWith("/")&&(h+="/"),h}apply(i){i.hooks.compilation.tap(this.name,o=>{o.hooks.processAssets.tap({name:this.name,stage:h.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let a;if(this.options.favicon){let a=n(i.context,this.options.favicon);if(t(a)){let t=s(this.options.favicon),i=e(a);o.emitAsset(t,new h.sources.RawSource(i),{javascriptModule:!1});let n=this.getPublicPath(o,t);this.faviconPath=n+t}else o.warnings.push(new h.WebpackError(`Favicon file ${a} does not exist`))}if(a=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(n(i.context,this.options.template),{encoding:"utf-8"}):this.generateDefaultTemplate(),this.options.inject){let t=this.getAssets(o);a=this.injectAssets(a,t,this.options.inject)}let l="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";o.emitAsset(l,new h.sources.RawSource(a),{javascriptModule:!1})})})}generateDefaultTemplate(){let t=this.generateMetaTags();return`<!DOCTYPE html><html><head><meta charset="utf-8">${t}<title>${this.options.title}</title><link rel="icon" type="image/x-icon" href="${this.faviconPath}"></head><body><div id="root"></div></body></html>`}generateMetaTags(){if(null!==this.cachedMetaTags)return this.cachedMetaTags;if(!this.options.meta)return this.cachedMetaTags="","";let t=Object.entries(this.options.meta).map(([t,e])=>{if("string"==typeof e)return`<meta name="${t}" content="${e}">`;if(void 0===e)return"";let s=Object.entries(e).map(([t,e])=>`${t}="${e}"`).join(" ");return`<meta ${s}>`}).join("");return this.cachedMetaTags=t,t}generateCustomTags(){if(null!==this.cachedCustomTags)return this.cachedCustomTags;let t={head:"",body:""};if(!this.options.tags)return this.cachedCustomTags=t,t;let e=[],s=[];return this.options.tags.forEach(t=>{let{tag:i="script",textContent:o="",inject:n=this.options.inject,...a}=t,h=Object.entries(a).filter(([,t])=>null!=t).map(([t,e])=>!0===e?t:`${t}="${e}"`).join(" "),l=`<${i} ${h}>${o}</${i}>`;"head"===n?e.push(l):s.push(l)}),t.head=e.join(""),t.body=s.join(""),this.cachedCustomTags=t,t}getAssets(t){let e={js:[],css:[]};for(let s of t.entrypoints.values())for(let i of s.chunks)for(let s of i.files){let i=this.getPublicPath(t,n(t.options.output.path,s));s.endsWith(".js")?e.js.push(i+s):s.endsWith(".css")&&e.css.push(i+s)}return e}injectAssets(t,e,s){let i=e.css.length?e.css.map(t=>`<link href="${t}" rel="stylesheet" />`).join(""):"",o=e.js.length?e.js.map(t=>`<script defer ${this.AddEntry.test(t)?'entry="true" ':""}src="${t}"></script>`).join(""):"",n=this.generateCustomTags(),a=t.split("</head>");if(2===a.length){let[t,e]=a,h=e.split("</body>");return"head"===s?`${t}${i}${o}${n.head}</head>${h[0]}${n.body}</body>${h[1]||""}`:`${t}${n.head}</head>${h[0]}${i}${o}${n.body}</body>${h[1]||""}`}return t}}
1
+ import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i}from"node:path";import n from"webpack";export class HtmlPlugin{constructor(t={}){this.AddEntry=/(?:.*\/)?main\.[a-zA-Z0-9]+\.bundle\.js$/,this.faviconPath="",this.name="HtmlPlugin",this.cachedMetaTags=null,this.cachedCustomTags=null,this.options={title:"WebApp",filename:"index.html",inject:"head",...t}}getPublicPath(t){let e=t.getAssetPath(t.outputOptions.publicPath,{hash:t.hash}),s="auto"===e?"/":e;return s.length&&!s.endsWith("/")&&(s+="/"),s}apply(o){o.hooks.compilation.tap(this.name,a=>{a.hooks.processAssets.tap({name:this.name,stage:n.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let h;if(this.options.favicon){let h=i(o.context,this.options.favicon);if(t(h)){let t=s(this.options.favicon),i=e(h);a.emitAsset(t,new n.sources.RawSource(i),{javascriptModule:!1});let o=this.getPublicPath(a);this.faviconPath=o+t}else a.warnings.push(new n.WebpackError(`Favicon file ${h} does not exist`))}if(h=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(i(o.context,this.options.template),{encoding:"utf-8"}):this.generateDefaultTemplate(),this.options.inject){let t=this.getAssets(a);h=this.injectAssets(h,t,this.options.inject)}let l="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";a.emitAsset(l,new n.sources.RawSource(h),{javascriptModule:!1})})})}generateDefaultTemplate(){let t=this.generateMetaTags();return`<!DOCTYPE html><html><head><meta charset="utf-8">${t}<title>${this.options.title}</title><link rel="icon" type="image/x-icon" href="${this.faviconPath}"></head><body><div id="root"></div></body></html>`}generateMetaTags(){if(null!==this.cachedMetaTags)return this.cachedMetaTags;if(!this.options.meta)return this.cachedMetaTags="","";let t=Object.entries(this.options.meta).map(([t,e])=>{if("string"==typeof e)return`<meta name="${t}" content="${e}">`;if(void 0===e)return"";let s=Object.entries(e).map(([t,e])=>`${t}="${e}"`).join(" ");return`<meta ${s}>`}).join("");return this.cachedMetaTags=t,t}generateCustomTags(){if(null!==this.cachedCustomTags)return this.cachedCustomTags;let t={head:"",body:""};if(!this.options.tags)return this.cachedCustomTags=t,t;let e=[],s=[];return this.options.tags.forEach(t=>{let{tag:i="script",textContent:n="",inject:o=this.options.inject,...a}=t,h=Object.entries(a).filter(([,t])=>null!=t).map(([t,e])=>!0===e?t:`${t}="${e}"`).join(" "),l=`<${i} ${h}>${n}</${i}>`;"head"===o?e.push(l):s.push(l)}),t.head=e.join(""),t.body=s.join(""),this.cachedCustomTags=t,t}getAssets(t){let e={js:[],css:[]},s=this.getPublicPath(t);for(let i of t.entrypoints.values())for(let t of i.chunks)for(let i of t.files)i.endsWith(".js")?e.js.push(s+i):i.endsWith(".css")&&e.css.push(s+i);return e}injectAssets(t,e,s){let i=e.css.length?e.css.map(t=>`<link href="${t}" rel="stylesheet" />`).join(""):"",n=e.js.length?e.js.map(t=>`<script defer ${this.AddEntry.test(t)?'entry="true" ':""}src="${t}"></script>`).join(""):"",o=this.generateCustomTags(),a=t.split("</head>");if(2===a.length){let[t,e]=a,h=e.split("</body>");return"head"===s?`${t}${i}${n}${o.head}</head>${h[0]}${o.body}</body>${h[1]||""}`:`${t}${o.head}</head>${h[0]}${i}${n}${o.body}</body>${h[1]||""}`}return t}}
@@ -1 +1 @@
1
- import e from"webpack";import t from"../commom/module-resolve.mjs";import{CONFIG as r}from"../config.mjs";import o from"../utils/fetch-module-federation-dts.mjs";import{resolveProgram as s}from"../utils/index.mjs";import{ModuleFederationExposesDeclarationPlugin as m}from"./exposes-declararion.mjs";import{ExternalRemotesPlugin as a}from"./external-remotes.mjs";let l=e.NormalModuleReplacementPlugin,i=e.container.ModuleFederationPlugin,n={},p=[],f=r.moduleFederation?.map(e=>{let r={},a={},l={};if(Array.isArray(e.remotes))for(let t=0,r=e.remotes.length;t<r;t++){let r=e.remotes[t],s=r.alias||r.name,m=r.filename||"remote_entry.js";if(a[s]=`${r.name}@${r.host}/${m}`,Array.isArray(r.library))for(let e=0,t=r.library.length;e<t;e++)n[r.library[e]]=`${s}/${r.library[e]}`;o(r.host,r.name)}if(Array.isArray(e.exposes)){e.exposes.push({name:"public-path",path:"@app/public-path"});for(let o=0,m=e.exposes.length;o<m;o++){let m=e.exposes[o];if("string"==typeof m){let e=m.startsWith(".");r[`./${m}`]=t(e?s(m):m),e&&(l[m]=r[`./${m}`])}else if("[object Object]"===Object.prototype.toString.call(m)){let e=m.path.startsWith(".");r[`./${m.name}`]=t(e?s(m.path):m.path),e&&(l[`./${m.name}`]=r[`./${m.name}`])}}e.exposes?.length&&p.push(new m({exposes:l,name:e.name}))}return new i({filename:"remote_entry.js",...e,remotes:a,exposes:r})});f.length>0&&(f.push(new a),f.push(new l(/(.*)/,e=>{n[e.request]&&(e.request=n[e.request])})),p.forEach(e=>f.push(e))),r.env.injectRemoteReactRefresh=Object.keys(n).includes("react-dom");export default f;
1
+ import{join as e,relative as t}from"node:path";import r from"webpack";import o from"../commom/module-resolve.mjs";import s from"../commom/paths.mjs";import{CONFIG as m}from"../config.mjs";import a from"../utils/fetch-module-federation-dts.mjs";import{resolveProgram as l}from"../utils/index.mjs";import{ModuleFederationExposesDeclarationPlugin as i}from"./exposes-declararion.mjs";import{ExternalRemotesPlugin as n}from"./external-remotes.mjs";let p=r.NormalModuleReplacementPlugin,f=r.container.ModuleFederationPlugin,h={},u=[],c=m.moduleFederation?.map(r=>{let m={},n={},p={};if(Array.isArray(r.remotes))for(let e=0,t=r.remotes.length;e<t;e++){let t=r.remotes[e],o=t.alias||t.name,s=t.filename||"remote_entry.js";if(n[o]=`${t.name}@${t.host}/${s}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)h[t.library[e]]=`${o}/${t.library[e]}`;a(t.host,t.name)}if(Array.isArray(r.exposes)){r.exposes.push({name:"public-path",path:`./${t(s.programPath,e(s.corePath,"./polyfills/public-path.mjs"))}`});for(let e=0,t=r.exposes.length;e<t;e++){let t=r.exposes[e];if("string"==typeof t){let e=t.startsWith(".");m[`./${t}`]=o(e?l(t):t),e&&(p[t]=m[`./${t}`])}else if("[object Object]"===Object.prototype.toString.call(t)){let e=t.path.startsWith(".");m[`./${t.name}`]=o(e?l(t.path):t.path),e&&(p[`./${t.name}`]=m[`./${t.name}`])}}r.exposes?.length&&u.push(new i({exposes:p,name:r.name}))}return new f({filename:"remote_entry.js",...r,remotes:n,exposes:m})});c.length>0&&(c.push(new n),c.push(new p(/(.*)/,e=>{h[e.request]&&(e.request=h[e.request])})),u.forEach(e=>c.push(e))),m.env.injectRemoteReactRefresh=Object.keys(h).includes("react-dom");export default c;
@@ -1 +1 @@
1
- import o from"webpack-virtual-modules";import t from"../commom/parse-module-meta.mjs";import i from"../commom/paths.mjs";import{isLibrary as e}from"../process-env.mjs";import{node_modules as s,transformModule as r}from"../utils/index.mjs";import{comment as m,docs as l}from"../vm/docs.mjs";import{examples as p}from"../vm/example.mjs";import{locales as n}from"../vm/locales.mjs";import a from"../vm/modules.mjs";import{route as f}from"../vm/routes.mjs";let c={};for(let o in a)if(Object.prototype.hasOwnProperty.call(a,o)){let{file:i,pkg:e,meta:s}=t(o);c[e]=s,c[i]=r(a[o])}export class VirtualModuleWebpackPlugin{constructor(i={}){this.options={},this.init=!1,this.virtualModules=new o(c);let e={};for(let o in i)if(Object.prototype.hasOwnProperty.call(i,o)){let{file:s,pkg:m,meta:l}=t(o),p=i[o],n=p;n=s.endsWith("json")?"string"==typeof p?p:JSON.stringify(p):r(p),Object.assign(e,{[s]:n,[m]:l})}this.options=e}modify(o,t,e){let r=t.startsWith(i.nodeModules)?t:s(t);this.virtualModules.writeModule(r,e||"")}apply(o){this.virtualModules.apply(o);let t=(t,i)=>{this.modify(o,t,i)};f.on("change",t),n.on("change",t),e&&(p.on("change",t),l.on("change",t),m.on("change",t)),o.hooks.compilation.tap("VirtualModuleWebpackPlugin",()=>{if(!this.init){for(let o in this.init=!0,this.options)Object.prototype.hasOwnProperty.call(this.options,o)&&t(o,this.options[o]);for(let o of p)t(o[0],o[1]);for(let o of l)t(o[0],o[1]);for(let o of m)t(o[0],o[1])}})}}
1
+ import t from"webpack-virtual-modules";import o from"../commom/parse-module-meta.mjs";import i from"../commom/paths.mjs";import{isLibrary as e}from"../process-env.mjs";import{node_modules as s,transformModule as r}from"../utils/index.mjs";import{comment as l,docs as m}from"../vm/docs.mjs";import{examples as n}from"../vm/example.mjs";import{locales as p}from"../vm/locales.mjs";import a from"../vm/modules.mjs";import{route as f}from"../vm/routes.mjs";let c={};for(let t in a)if(Object.prototype.hasOwnProperty.call(a,t)){let{file:i,pkg:e,meta:s}=o(t);c[e]=s,c[i]=r(a[t])}export class VirtualModuleWebpackPlugin{constructor(i={}){this.options={},this.init=!1,this.virtualModules=new t(c);let e={};for(let t in i)if(Object.prototype.hasOwnProperty.call(i,t)){let{file:s,pkg:l,meta:m}=o(t),n=i[t],p=n;p=s.endsWith("json")?"string"==typeof n?n:JSON.stringify(n):r(n),Object.assign(e,{[s]:p,[l]:m})}this.options=e}modify(t,o,e){let r=e||"",l=o.startsWith(i.nodeModules)?o:s(o),m=t.inputFileSystem;for(;m&&m._inputFileSystem;)m=m._inputFileSystem;let n=m?._virtualFiles?.[l];n&&n.contents===r||(this.virtualModules.writeModule(l,r),t.watching?.invalidate())}apply(t){this.virtualModules.apply(t);let o=(o,i)=>{this.modify(t,o,i)};f.on("change",o),p.on("change",o),e&&(n.on("change",o),m.on("change",o),l.on("change",o)),t.hooks.compilation.tap("VirtualModuleWebpackPlugin",()=>{if(!this.init){for(let t in this.init=!0,this.options)Object.prototype.hasOwnProperty.call(this.options,t)&&o(t,this.options[t]);for(let t of n)o(t[0],t[1]);for(let t of m)o(t[0],t[1]);for(let t of l)o(t[0],t[1])}})}}
@@ -0,0 +1,2 @@
1
+ export declare function set(value: string): void;
2
+ export declare function get(): string;
@@ -0,0 +1 @@
1
+ export function set(_){__webpack_public_path__=_}export function get(){return __webpack_public_path__}
@@ -1 +1 @@
1
- import{join as m}from"node:path";import{getAppEntry as p,getAppFallback as o,getAppMdxScope as e,getAppMergeRouter as t,getAppNormalizeCss as r,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as i}from"@moneko/mdx";import{updateFileSync as n}from"@moneko/utils";import l from"../commom/has-pkg.mjs";import f from"../commom/paths.mjs";import c from"../commom/rule.mjs";import{CONFIG as d}from"../config.mjs";import j from"../plugin/module-federation.mjs";import{APPTYPE as u,FRAMEWORK as x}from"../process-env.mjs";import g from"../utils/create-types.mjs";import{generateDeclaration as v}from"../utils/dts.mjs";import{node_modules as h,transformModule as k}from"../utils/index.mjs";import y from"./coverage.mjs";import{docs as b,docsModuleName as z}from"./docs.mjs";import D from"./info.mjs";import{locales as C,localesModuleName as P}from"./locales.mjs";import M from"./public-path.mjs";import N from"./render-app.mjs";import{route as O,routesModuleName as S}from"./routes.mjs";let q=l(m(d.alias["@"],"./mdx-scope.tsx"))||l(m(d.alias["@"],"./mdx-scope.ts")),w={[M.moduleName]:M.source,"@app/env.ts":d.env,"@app/info.ts":D,"@app/render.tsx":"react"===x?N:"","@app/entry.ts":p(m(d.alias["@"],"./index.ts"),!!j.length,!!d.rem,!!d.normalizeCss,u,x),"@app/rem":a(d.rem?.designSize||1680),"@app/fallback":o(d.fallbackCompPath),"@app/coverage":y(f.coveragePath),"@app/merge-router":t(),"@app/prefix-router":s(),"@app/normalize/index.css":r(),"@app/suspense/index.tsx":i(u,x),"@app/mdx-scope.tsx":q?e(q):"export default {}","@app/routes":O.getData(S),"@app/locales":C.getData(P),"@app/docs":b.getData(z)};n(h("@types/@app/index.d.ts"),["@app/env.ts","@app/info.ts","@app/entry.ts","@app/mdx-scope.tsx"].map(m=>g(m.replace(c.js,""),v(k(w[m]),m))).concat(M.dts).join("\n"));let A=h("@types/@vm/index.d.ts"),B=d.virtualModule||{};n(A,Object.keys(B).map(m=>g(m,v(k(B[m]),m))).join("\n"));export default w;
1
+ import{join as p}from"node:path";import{getAppEntry as m,getAppFallback as o,getAppMdxScope as e,getAppMergeRouter as t,getAppNormalizeCss as r,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as i}from"@moneko/mdx";import{updateFileSync as n}from"@moneko/utils";import f from"../commom/has-pkg.mjs";import l from"../commom/paths.mjs";import d from"../commom/rule.mjs";import{CONFIG as c}from"../config.mjs";import j from"../plugin/module-federation.mjs";import{APPTYPE as x,FRAMEWORK as u}from"../process-env.mjs";import g from"../utils/create-types.mjs";import{generateDeclaration as v}from"../utils/dts.mjs";import{node_modules as h,transformModule as k}from"../utils/index.mjs";import y from"./coverage.mjs";import{docs as b,docsModuleName as z}from"./docs.mjs";import D from"./info.mjs";import{locales as C,localesModuleName as P}from"./locales.mjs";import M from"./render-app.mjs";import{route as O,routesModuleName as S}from"./routes.mjs";let q=f(p(c.alias["@"],"./mdx-scope.tsx"))||f(p(c.alias["@"],"./mdx-scope.ts")),w={"@app/env.ts":c.env,"@app/info.ts":D,"@app/render.tsx":"react"===u?M:"","@app/entry.ts":m(p(c.alias["@"],"./index.ts"),!!j.length,!!c.rem,!!c.normalizeCss,x,u),"@app/rem":a(c.rem?.designSize||1680),"@app/fallback":o(c.fallbackCompPath),"@app/coverage":y(l.coveragePath),"@app/merge-router":t(),"@app/prefix-router":s(),"@app/normalize/index.css":r(),"@app/suspense/index.tsx":i(x,u),"@app/mdx-scope.tsx":q?e(q):"export default {}","@app/routes":O.getData(S),"@app/locales":C.getData(P),"@app/docs":b.getData(z)};n(h("@types/@app/index.d.ts"),["@app/env.ts","@app/info.ts","@app/entry.ts","@app/mdx-scope.tsx"].map(p=>g(p.replace(d.js,""),v(k(w[p]),p))).join("\n"));let A=h("@types/@vm/index.d.ts"),B=c.virtualModule||{};n(A,Object.keys(B).map(p=>g(p,v(k(B[p]),p))).join("\n"));export default w;
@@ -1 +1 @@
1
- import{parentPort as s}from"node:worker_threads";import{compileDts as e}from"../utils/compile-dts.mjs";if(!s)throw Error("This file must be run as a worker");s?.setMaxListeners(0),s.on("message",async({options:r})=>{let o=e(r);s.postMessage(o)});
1
+ import{parentPort as s}from"node:worker_threads";import{compileDts as e}from"../utils/compile-dts.mjs";if(!s)throw Error("This file must be run as a worker");s?.setMaxListeners(0),s.on("message",async({options:r})=>{try{let t=e(r);s.postMessage(t)}catch{s.postMessage("")}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.55.18-beta.2",
3
+ "version": "3.56.0-bate.0",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
@@ -124,14 +124,14 @@
124
124
  "husky": "9.1.7",
125
125
  "less": "4.4.1",
126
126
  "less-loader": "12.3.0",
127
- "lightningcss": "1.30.1",
127
+ "lightningcss": "1.30.2",
128
128
  "marked-completed": "1.2.14",
129
129
  "memfs": "4.47.0",
130
130
  "mini-css-extract-plugin": "2.9.4",
131
131
  "style-loader": "4.0.0",
132
132
  "swc-loader": "0.2.6",
133
133
  "typescript": "5.9.2",
134
- "webpack": "5.101.3",
134
+ "webpack": "5.102.0",
135
135
  "webpack-hot-middleware": "2.26.1",
136
136
  "webpack-merge": "6.0.1",
137
137
  "webpack-virtual-modules": "0.6.2"
@@ -2,6 +2,5 @@ declare module '*?raw';
2
2
  declare module '*.cjs';
3
3
  declare module '@pmmmwh/react-refresh-webpack-plugin';
4
4
  declare module 'package.json';
5
- declare module 'babel-plugin-jsx-dom-expressions';
6
5
 
7
6
  declare let __webpack_public_path__: string;
@@ -1,6 +0,0 @@
1
- declare const _default: {
2
- source: string;
3
- moduleName: string;
4
- dts: string;
5
- };
6
- export default _default;
@@ -1 +0,0 @@
1
- let t="@app/public-path",e=`module '${t}' {export function set(value: string): void;export function get(): string;}`;export default{source:"// __webpack_public_path__ = '../';export function set(value: string) {__webpack_public_path__ = value;};export function get() {return __webpack_public_path__;}",moduleName:t,dts:e};