@moneko/core 4.1.0 → 4.1.2

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/build-dev.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as e,completedInfo as t,ink as m,println as i,progressBar as n}from"@moneko/utils";import s from"webpack";import a from"./commom/log.mjs";import l from"./commom/paths.mjs";import{empty as p}from"./utils/index.mjs";import{CONFIG as c}from"./config.mjs";import{createDevelopmentConfiguration as g}from"./create-development-configuration.mjs";let u=await g({});if(c.bar){let o=c.bar,e=o.name||"Build";u.plugins.push(new s.ProgressPlugin({handler(t,m,...i){let s=i.length?`[${m}] ${i.join(" ")}`:" ";o.quiet?r.stdout.write(`${s}
2
- `):(n(t||0,1,{msg:s,name:e,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===t&&r.stdout.write("\r\x1b[2K"))}}))}let d=s(u);async function f(){let r=await new Promise((o,r)=>{d?.run((e,t)=>{e&&r(e),t?o(t):r(Error("编译过程中没有生成统计信息"))})});(r.hasErrors()||r.hasWarnings())&&function(o){let{warnings:r,errors:e}=o.compilation,t=[];r.forEach(o=>{o.message.includes("Conflicting order between css ./node_modules/")&&o.message.includes("monaco-editor")?t.push(o.message):i(m(o.message,"178"))}),t.length&&a(t.join("\n")),e.forEach(o=>{i(m(o.message,"red"))})}(r),await new Promise(n=>{r.compilation.compiler.cache.shutdown(s=>{s&&i(m(s.toString(),"red")),e(r.compilation.outputOptions.path,["\\.js$"]),t(~~((r.endTime-r.startTime)/10)/100,o(l.programPath,r.compilation.outputOptions.path)),n()})})}r.on("exit",p),await f();
1
+ import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as e,completedInfo as t,ink as m,println as i,progressBar as a}from"@moneko/utils";import n from"webpack";import s from"./commom/log.mjs";import l from"./commom/paths.mjs";import{CONFIG as p}from"./config.mjs";import{createDevelopmentConfiguration as c}from"./create-development-configuration.mjs";let g=await c({});if(p.bar){let o=p.bar,e=o.name||"Build";g.plugins.push(new n.ProgressPlugin({handler(t,m,...i){let n=i.length?`[${m}] ${i.join(" ")}`:" ";o.quiet?r.stdout.write(`${n}
2
+ `):(a(t||0,1,{msg:n,name:e,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===t&&r.stdout.write("\r\x1b[2K"))}}))}let u=n(g);async function d(){let r=await new Promise((o,r)=>{u?.run((e,t)=>{e&&r(e),t?o(t):r(Error("编译过程中没有生成统计信息"))})});(r.hasErrors()||r.hasWarnings())&&function(o){let{warnings:r,errors:e}=o.compilation,t=[];r.forEach(o=>{o.message.includes("Conflicting order between css ./node_modules/")&&o.message.includes("monaco-editor")?t.push(o.message):i(m(o.message,"178"))}),t.length&&s(t.join("\n")),e.forEach(o=>{i(m(o.message,"red"))})}(r),await new Promise(a=>{r.compilation.compiler.cache.shutdown(n=>{n&&i(m(n.toString(),"red")),e(r.compilation.outputOptions.path,["\\.js$"]),t(~~((r.endTime-r.startTime)/10)/100,o(l.programPath,r.compilation.outputOptions.path)),a()})})}await d();
package/lib/build.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as m,completedInfo as e,ink as i,println as t,progressBar as s}from"@moneko/utils";import n from"webpack";import{merge as a}from"webpack-merge";import l from"./build/common.mjs";import p from"./commom/log.mjs";import u from"./commom/paths.mjs";import{DonePlugin as g}from"./plugin/done.mjs";import{empty as c}from"./utils/index.mjs";import d from"./utils/seo.mjs";import{CONFIG as f}from"./config.mjs";import h from"./module.config.mjs";let w=a(l,{module:h(!1),plugins:[]});if(f.done&&w.plugins.push(new g({done:f.done})),f.bar){let o=f.bar,m=o.name||"Build";w.plugins.push(new n.ProgressPlugin({handler(e,i,...t){let n=t.length?`[${i}] ${t.join(" ")}`:" ";o.quiet?r.stdout.write(`${n}
2
- `):(s(e||0,1,{msg:n,name:m,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===e&&r.stdout.write("\r\x1b[2K"))}}))}let b=n(w);if(!b)throw Error("无法创建编译器");async function j(){let r=await new Promise((o,r)=>{b?.run((m,e)=>{m&&r(m),e?o(e):r(Error("编译过程中没有生成统计信息"))})});(r.hasErrors()||r.hasWarnings())&&function(o){let{warnings:r,errors:m}=o.compilation,e=[];r.forEach(o=>{o.message.includes("Conflicting order between css ./node_modules/")&&o.message.includes("monaco-editor")?e.push(o.message):t(i(o.message,"178"))}),e.length&&p(e.join("\n")),m.forEach(o=>{t(i(o.message,"red"))})}(r),await new Promise(s=>{r.compilation.compiler.cache.shutdown(n=>{n&&t(i(n.toString(),"red")),m(r.compilation.outputOptions.path,["\\.js$"]),e(~~((r.endTime-r.startTime)/10)/100,o(u.programPath,r.compilation.outputOptions.path)),s()})}),f.seo&&d()}r.on("exit",c),await j();
1
+ import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as m,completedInfo as e,ink as t,println as i,progressBar as s}from"@moneko/utils";import n from"webpack";import{merge as a}from"webpack-merge";import l from"./build/common.mjs";import p from"./commom/log.mjs";import u from"./commom/paths.mjs";import{DonePlugin as g}from"./plugin/done.mjs";import c from"./utils/seo.mjs";import{CONFIG as d}from"./config.mjs";import f from"./module.config.mjs";let h=a(l,{module:f(!1),plugins:[]});if(d.done&&h.plugins.push(new g({done:d.done})),d.bar){let o=d.bar,m=o.name||"Build";h.plugins.push(new n.ProgressPlugin({handler(e,t,...i){let n=i.length?`[${t}] ${i.join(" ")}`:" ";o.quiet?r.stdout.write(`${n}
2
+ `):(s(e||0,1,{msg:n,name:m,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===e&&r.stdout.write("\r\x1b[2K"))}}))}let w=n(h);if(!w)throw Error("无法创建编译器");async function b(){let r=await new Promise((o,r)=>{w?.run((m,e)=>{m&&r(m),e?o(e):r(Error("编译过程中没有生成统计信息"))})});(r.hasErrors()||r.hasWarnings())&&function(o){let{warnings:r,errors:m}=o.compilation,e=[];r.forEach(o=>{o.message.includes("Conflicting order between css ./node_modules/")&&o.message.includes("monaco-editor")?e.push(o.message):i(t(o.message,"178"))}),e.length&&p(e.join("\n")),m.forEach(o=>{i(t(o.message,"red"))})}(r),await new Promise(s=>{r.compilation.compiler.cache.shutdown(n=>{n&&i(t(n.toString(),"red")),m(r.compilation.outputOptions.path,["\\.js$"]),e(~~((r.endTime-r.startTime)/10)/100,o(u.programPath,r.compilation.outputOptions.path)),s()})}),d.seo&&c()}await b();
package/lib/common.mjs CHANGED
@@ -1 +1 @@
1
- import{extname as e,join as t,resolve as s}from"node:path";import o,{config_files as a,CUSTOMCONFIG as n,TMP_DIR as i}from"./commom/paths.mjs";import r from"./commom/rule.mjs";import{OverrideResolverPlugin as l}from"./plugin/override-resolve.mjs";import{isObject as m,resolveProgram as c}from"./utils/index.mjs";import{CONFIG as p}from"./config.mjs";import u from"./plugins.config.mjs";import{app_schema as h,CACHE_NAME as d,isCI as f,isDev as g,isLibrary as y,packageJson as b,projectNameCamelCase as j}from"./process-env.mjs";export const outputConfig={path:c(y?"docs":"dist"),filename:e=>e.filename?.includes(".worker")?"worker/[name].js":"js/[name].[contenthash].bundle.js",chunkFilename:"js/[contenthash].chunk.js",cssFilename:"style/[contenthash].css",cssChunkFilename:"style/[contenthash].chunk.css",assetModuleFilename:t=>{let s=e(t.filename||"").substring(1);return`assets/${s}/[hash][ext]`},library:{name:`${j}`,type:"umd",umdNamedDefine:!0},globalObject:"self",chunkLoadingGlobal:`webpackJsonp_${b.name}`,pathinfo:g,clean:!0,publicPath:p.publicPath,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"],uniqueName:`${j}`};let v={main:[`${h}:entry`]},C=[t(o.corePath,"./polyfills/public-path.mjs")];if(g&&p.refresh&&p.env.injectRemoteReactRefresh&&C.push(t(o.corePath,"./polyfills/inject-react-refresh.mjs")),p.polyfill&&C.push(t(o.corePath,"./polyfills/replace-children.mjs")),p.entry&&("string"==typeof p.entry?v={...v,main:[p.entry]}:Object.keys(p.entry)&&(v=Object.assign(v,p.entry))),"string"==typeof v.main?v.main=[...C,v.main]:Array.isArray(v.main)&&(v.main=[...C,...v.main]),p.output){if("string"==typeof p.output)outputConfig.path=p.output;else if(Object.keys(p.output)){let e=p.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof p.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let P={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:o.webpackCachePath,memoryCacheUnaffected:!0,name:d,version:`${b.version}`,buildDependencies:{config:a},maxMemoryGenerations:1};!1===p.cache?P=!1:m(p.cache)&&(P=Object.assign(P,p.cache)),f&&(void 0===p.cache||p.cache&&!p.cache.cacheDirectory)&&(P.cacheDirectory=s(i,b.name));let k={},x={imports:!0,entries:!0,test:e=>{let s=e.nameForCondition();return!!(s&&(/^[a-z][a-z0-9]*:.+$/.test(s)||s?.startsWith(t(o.programPath,"src"))||s?.startsWith(t(o.programPath,"site"))||s?.startsWith(o.componentsPath)))}};p.lazyCompilation&&g&&"true"!==process.env.IS_BUILD?m(p.lazyCompilation)?Object.assign(k,x,p.lazyCompilation):Object.assign(k,x):k=!1;export const commonConfig={name:"client",target:"web",devtool:p.devtool,entry:v,mode:p.mode??"production",cache:P,snapshot:{immutablePaths:[o.pnpmNodeModules,o.denoNodeModules,r.node_modules],managedPaths:[o.pnpmNodeModules,o.denoNodeModules,r.node_modules],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}},stats:"errors-only",infrastructureLogging:{level:"error"},externalsPresets:p.externalsPresets,plugins:u,node:{global:!1,__filename:!1,__dirname:!1},experiments:{asyncWebAssembly:!0,cacheUnaffected:!0,lazyCompilation:k,buildHttp:m(p.buildHttp)?{allowedUris:[],lockfileLocation:s(o.httpCachePath,"http.lock"),cacheLocation:s(o.httpCachePath,"data"),upgrade:!0,...p.buildHttp}:p.buildHttp,backCompat:!0,futureDefaults:!0,css:!0,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:p.alias,modules:[o.nodeModules,o.pnpmNodeModules,o.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:p.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:p.externals,output:outputConfig,recordsPath:p.recordsPath};p.overrideResolve&&commonConfig.resolve.plugins.push(new l(Object.assign({original:p.alias["@"],override:n&&c(n)},p.overrideResolve)));
1
+ import{extname as e,join as t,resolve as s}from"node:path";import{createDir as o}from"@moneko/utils";import a,{config_files as n,CUSTOMCONFIG as i,TMP_DIR as r}from"./commom/paths.mjs";import l from"./commom/rule.mjs";import{OverrideResolverPlugin as m}from"./plugin/override-resolve.mjs";import{isObject as c,resolveProgram as p}from"./utils/index.mjs";import{CONFIG as u}from"./config.mjs";import h from"./plugins.config.mjs";import{app_schema as d,CACHE_NAME as f,isCI as g,isDev as y,isLibrary as b,packageJson as j,projectNameCamelCase as v}from"./process-env.mjs";export const outputConfig={path:p(b?"docs":"dist"),filename:e=>e.filename?.includes(".worker")?"worker/[name].js":"js/[name].[contenthash].bundle.js",chunkFilename:"js/[contenthash].chunk.js",cssFilename:"style/[contenthash].css",cssChunkFilename:"style/[contenthash].chunk.css",assetModuleFilename:t=>{let s=e(t.filename||"").substring(1);return`assets/${s}/[hash][ext]`},library:{name:`${v}`,type:"umd",umdNamedDefine:!0},globalObject:"self",chunkLoadingGlobal:`webpackJsonp_${j.name}`,pathinfo:y,clean:!0,publicPath:u.publicPath,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"],uniqueName:`${v}`};let C={main:[`${d}:entry`]},P=[t(a.corePath,"./polyfills/public-path.mjs")];if(y&&u.refresh&&u.env.injectRemoteReactRefresh&&P.push(t(a.corePath,"./polyfills/inject-react-refresh.mjs")),u.polyfill&&P.push(t(a.corePath,"./polyfills/replace-children.mjs")),u.entry&&("string"==typeof u.entry?C={...C,main:[u.entry]}:Object.keys(u.entry)&&(C=Object.assign(C,u.entry))),"string"==typeof C.main?C.main=[...P,C.main]:Array.isArray(C.main)&&(C.main=[...P,...C.main]),u.output){if("string"==typeof u.output)outputConfig.path=u.output;else if(Object.keys(u.output)){let e=u.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof u.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let k={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:a.webpackCachePath,memoryCacheUnaffected:!0,name:f,version:`${j.version}`,buildDependencies:{config:n},maxMemoryGenerations:1};if(!1===u.cache?k=!1:c(u.cache)&&(k=Object.assign(k,u.cache)),g&&(void 0===u.cache||u.cache&&!u.cache.cacheDirectory)){let e=s(r,j.name);o(e)&&(k.cacheDirectory=e)}let x={},M={imports:!0,entries:!0,test:e=>{let s=e.nameForCondition();return!!(s&&(/^[a-z][a-z0-9]*:.+$/.test(s)||s?.startsWith(t(a.programPath,"src"))||s?.startsWith(t(a.programPath,"site"))||s?.startsWith(a.componentsPath)))}};u.lazyCompilation&&y&&"true"!==process.env.IS_BUILD?c(u.lazyCompilation)?Object.assign(x,M,u.lazyCompilation):Object.assign(x,M):x=!1;export const commonConfig={name:"client",target:"web",devtool:u.devtool,entry:C,mode:u.mode??"production",cache:k,snapshot:{immutablePaths:[a.pnpmNodeModules,a.denoNodeModules,l.node_modules],managedPaths:[a.pnpmNodeModules,a.denoNodeModules,l.node_modules],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}},stats:"errors-only",infrastructureLogging:{level:"error"},externalsPresets:u.externalsPresets,plugins:h,node:{global:!1,__filename:!1,__dirname:!1},experiments:{asyncWebAssembly:!0,cacheUnaffected:!0,lazyCompilation:x,buildHttp:c(u.buildHttp)?{allowedUris:[],lockfileLocation:s(a.httpCachePath,"http.lock"),cacheLocation:s(a.httpCachePath,"data"),upgrade:!0,...u.buildHttp}:u.buildHttp,backCompat:!0,futureDefaults:!0,css:!0,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:u.alias,modules:[a.nodeModules,a.pnpmNodeModules,a.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:u.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:u.externals,output:outputConfig,recordsPath:u.recordsPath};u.overrideResolve&&commonConfig.resolve.plugins.push(new m(Object.assign({original:u.alias["@"],override:i&&p(i)},u.overrideResolve)));
package/lib/dev.mjs CHANGED
@@ -1,2 +1,2 @@
1
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 s}from"node:url";import{ink as n,print as a,println as m,progressBar as l}from"@moneko/utils";import p from"webpack";import c from"webpack-hot-middleware";import{merge as f}from"webpack-merge";import{diffObject as h}from"./commom/diff-object.mjs";import d,{config_files as u}from"./commom/paths.mjs";import g from"./commom/rule.mjs";import w from"./commom/sigint-exit.mjs";import{devLog as y,PORT as $}from"./dev/config.mjs";import j from"./dev/generate-progress-html.mjs";import v from"./dev/server.mjs";import b from"./options/reslove.mjs";import{ESLintPlugin as x}from"./plugin/eslint.mjs";import{StylelintPlugin as C}from"./plugin/stylelint.mjs";import{empty as _}from"./utils/index.mjs";import{CONFIG as P,getConfig as S}from"./config.mjs";import{createDevelopmentConfiguration as k}from"./create-development-configuration.mjs";import{outputFileSystem as E}from"./file-system.mjs";import{isLibrary as B,refresh as H}from"./process-env.mjs";let I=!1,O="/____progress____",T={percentage:0,info:""},q="/__hmr__",G=new URLSearchParams({name:"client",path:q.substring(1),dynamicPublicPath:!0,timeout:2e3,reload:!H,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),L=await k({watchOptions:{stdin:!0,aggregateTimeout:300,ignored:g.node_modules},entry:{main:[`${b.hotMiddlewareClient}?${G}`]},plugins:[new p.WatchIgnorePlugin({paths:[g.node_modules,/\.d\.ts$/]}),new p.ProgressPlugin({handler(e,t,...o){let r=o.length?`[${t}] ${o.join(" ")}`:" ";I||(T.info=r,T.percentage=e,I=1===e);let s=P.bar;if(s){let t=s.name||"Build";s.quiet?i.stdout.write(`${r}
2
- `):(l(e||0,1,{msg:r,name:t,barColor:s.barColor,nameColor:s.nameColor,barBgColor:s.barBgColor,msgColor:s.msgColor}),1===e&&i.stdout.write("\r\x1b[2K"))}}})]});function U(e){let t=e.join(","),o=[r(d.programPath,`${P.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return B&&o.push(r(d.programPath,`${P.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}P.eslint&&L.plugins.push(new x({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:U(["js","jsx","ts","tsx","json","html","vue"]),...P.eslint})),P.stylelint&&L.plugins.push(new C({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.stylelintcache`,files:U(["css","scss","sass","less","ts","tsx","js","jsx"]),...P.stylelint}));let F=p(L);if(!F)throw Error("无法创建编译器");F.outputFileSystem=E;let N=F.watch(F.options.watchOptions,y);if(!N)throw Error("无法创建监视器");F.hooks.done.tap("client-log",e=>{y(null,e)});let R=`${P.basename}/${q}`.replace(/\/+/g,"/"),J=c(F,{log:!1,path:R,heartbeat:2e3}),K=await v({port:$,root_dir:F.options.output.path,fileSystem:F.outputFileSystem,headers:P.devServer.headers,https:P.devServer.https,host:P.devServer.host,open:P.devServer.open,basename:P.basename,onRequest(e,t){if(!t.writableEnded){if("GET"===e.method){let o=new s(`${P.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if(o.pathname===O)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(T)),!0;if(!I)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end(j(O,T)),!0;if(o.pathname===R&&"text/event-stream"===e.headers.accept)return J(e,t,_),!0}return!1}}});function M(){i.exit(0)}K.on("close",()=>{N.close(_),J.close()});let W=await Promise.all(u.map(S)),z=f(W[0]||{},W[1]||{});u.forEach(function(t){o(t,async function(){var o;let[r,s]=await Promise.all(u.map(S)),l=f(r||{},s||{}),p=h(z,l);1===Object.keys(p).length&&"proxy"in p?(a(n(`代理更新中...`,"yellow"),!0),a(n(`代理更新完成...`,"green"),!0),P.proxy=l.proxy,z.proxy=l.proxy,z=l):(z=l,m(n(`检测到工程配置${n(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),o=$,e(A?`netstat -ano | findstr :${o}`:`lsof -i :${o} -t`,(e,t)=>{if(e){m(n(`查找端口 ${o} 时发生错误: ${e.message}`,"red")),m(n("请尝试手动重启程序","yellow"));return}let r=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),s=A?r[0]?.split(/\s+/).pop()?.trim():r[0]?.trim();if(!s)return void m(n(`未找到占用端口 ${o} 的进程, 请尝试手动重启程序`,"yellow"));try{i.kill(Number(s),"SIGHUP")}catch(e){m(n(`终止进程 ${s} 时发生错误: ${e.message}`,"red"))}}))})});let A="win32"===i.platform;i.on("SIGHUP",function(){let e;K.close(_),(e=t(i.argv[0],i.argv.slice(1),{detached:!1,stdio:"inherit"})).unref(),e.on("close",M)}),i.on("exit",function(){K.close(_)}),w(M);
2
+ `):(l(e||0,1,{msg:r,name:t,barColor:s.barColor,nameColor:s.nameColor,barBgColor:s.barBgColor,msgColor:s.msgColor}),1===e&&i.stdout.write("\r\x1b[2K"))}}})]});function U(e){let t=e.join(","),o=[r(d.programPath,`${P.alias["@"]}/**/*.{${t}}`).replace(/\\/g,"/")];return B&&o.push(r(d.programPath,`${P.alias["@pkg"]}/**/*.{${t}}`).replace(/\\/g,"/")),o}P.eslint&&L.plugins.push(new x({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:U(["js","jsx","ts","tsx","json","html","vue"]),...P.eslint})),P.stylelint&&L.plugins.push(new C({fix:!0,cache:!0,cacheLocation:`${d.lintCachePath}/.stylelintcache`,files:U(["css","scss","sass","less","ts","tsx","js","jsx"]),...P.stylelint}));let F=p(L);if(!F)throw Error("无法创建编译器");F.outputFileSystem=E;let N=F.watch(F.options.watchOptions,y);if(!N)throw Error("无法创建监视器");F.hooks.done.tap("client-log",e=>{y(null,e)});let R=`${P.basename}/${q}`.replace(/\/+/g,"/"),J=c(F,{log:!1,path:R,heartbeat:2e3}),K=await v({port:$,root_dir:F.options.output.path,fileSystem:F.outputFileSystem,headers:P.devServer.headers,https:P.devServer.https,host:P.devServer.host,open:P.devServer.open,basename:P.basename,onRequest(e,t){if(!t.writableEnded){if("GET"===e.method){let o=new s(`${P.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if(o.pathname===O)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(T)),!0;if(!I)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end(j(O,T)),!0;if(o.pathname===R&&"text/event-stream"===e.headers.accept)return J(e,t,_),!0}return!1}}});function M(){i.exit(0)}K.on("close",()=>{N.close(_),J.close()});let W=await Promise.all(u.map(S)),z=f(W[0]||{},W[1]||{});u.forEach(function(t){o(t,async function(){var o;let[r,s]=await Promise.all(u.map(S)),l=f(r||{},s||{}),p=h(z,l);1===Object.keys(p).length&&"proxy"in p?(a(n(`代理更新中...`,"yellow"),!0),a(n(`代理更新完成...`,"green"),!0),P.proxy=l.proxy,z.proxy=l.proxy,z=l):(z=l,m(n(`检测到工程配置${n(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),o=$,e(A?`netstat -ano | findstr :${o}`:`lsof -i :${o} -t`,(e,t)=>{if(e){m(n(`查找端口 ${o} 时发生错误: ${e.message}`,"red")),m(n("请尝试手动重启程序","yellow"));return}let r=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),s=A?r[0]?.split(/\s+/).pop()?.trim():r[0]?.trim();if(!s)return void m(n(`未找到占用端口 ${o} 的进程, 请尝试手动重启程序`,"yellow"));try{i.kill(Number(s),"SIGHUP")}catch(e){m(n(`终止进程 ${s} 时发生错误: ${e.message}`,"red"))}}))})});let A="win32"===i.platform;i.on("SIGHUP",function(){let e;K.close(),(e=t(i.argv[0],i.argv.slice(1),{detached:!1,stdio:"inherit"})).unref(),e.on("close",M)}),i.on("exit",function(){K.close()}),w(M);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return t}});let e=require("node:path"),s=new(require("node:worker_threads")).Worker((0,e.join)(__dirname,"../worker/css-in-js-minify.mjs"));async function t(e){this.cacheable&&this.cacheable(),(this._compiler?.options.mode!=="development"||"true"===process.env.IS_BUILD)&&this._compiler?.hooks.done.tap("css-in-js-minify-loader",()=>{s.terminate()});let t=this.async(),r=this.getOptions(),i=this.resourcePath;s.postMessage({options:r,code:e,filename:i}),s.addListener("message",function e(r){i===r[0]&&(t(r[1],r[2]),s.removeListener("message",e))})}s.setMaxListeners(0);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return t}});let e=require("node:path"),s=new(require("node:worker_threads")).Worker((0,e.join)(__dirname,"../worker/css-in-js-minify.mjs"));async function t(e){(this._compiler?.options.mode!=="development"||"true"===process.env.IS_BUILD)&&this._compiler?.hooks.done.tap("css-in-js-minify-loader",()=>{s.terminate()}),this.cacheable&&this.cacheable();let t=this.async(),r=this.getOptions(),i=this.resourcePath;s.postMessage({options:r,code:e,filename:i}),s.addListener("message",function e(r){i===r[0]&&(t(r[1],r[2]),s.removeListener("message",e))})}s.setMaxListeners(0);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=exports,t={get custom(){return i},get default(){return a}};for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(t,r).get});let s=require("node:path"),o=new(require("node:worker_threads")).Worker((0,s.join)(__dirname,"../worker/react-compiler.mjs"));function n(e,t){let r=this.resourcePath,s=this.getOptions();if(r.endsWith(".d.ts")||r.endsWith(".json")||!("annotation"===s.compilationMode?e.includes("use memo")||e.includes("use forget"):e.includes("react")||r.endsWith(".tsx")||r.endsWith(".jsx")))return e;let n=this.async();(this._compiler?.options.mode!=="development"||"true"===process.env.IS_BUILD)&&this._compiler?.hooks.done.tap("react-compiler-loader",()=>{o.terminate()}),this.cacheable&&this.cacheable(),o.postMessage({sourceCode:e,filename:r,inputSourceMap:t,options:s}),o.addListener("message",function e(t){r===t[0]&&(n(t[1],t[2],t[3]),o.removeListener("message",e))})}function i(e,t){return n.bind(this,e,t)}o.setMaxListeners(0);let a=n;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=exports,t={get custom(){return i},get default(){return a}};for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(t,r).get});let s=require("node:path"),o=new(require("node:worker_threads")).Worker((0,s.join)(__dirname,"../worker/react-compiler.mjs"));function n(e,t){(this._compiler?.options.mode!=="development"||"true"===process.env.IS_BUILD)&&this._compiler?.hooks.done.tap("react-compiler-loader",()=>{o.terminate()});let r=this.resourcePath,s=this.getOptions();if(r.endsWith(".d.ts")||r.endsWith(".json")||!("annotation"===s.compilationMode?e.includes("use memo")||e.includes("use forget"):e.includes("react")||r.endsWith(".tsx")||r.endsWith(".jsx")))return e;let n=this.async();this.cacheable&&this.cacheable(),o.postMessage({sourceCode:e,filename:r,inputSourceMap:t,options:s}),o.addListener("message",function e(t){r===t[0]&&(n(t[1],t[2],t[3]),o.removeListener("message",e))})}function i(e,t){return n.bind(this,e,t)}o.setMaxListeners(0);let a=n;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=exports,t={get custom(){return n},get default(){return a}};for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(t,r).get});let s=require("node:path"),o=new(require("node:worker_threads")).Worker((0,s.join)(__dirname,"../worker/solid.mjs"));async function i(e,t){this.cacheable&&this.cacheable(),(this._compiler?.options.mode!=="development"||"true"===process.env.IS_BUILD)&&this._compiler?.hooks.done.tap("solid-loader",()=>{o.terminate()});let r=this.async(),s=this.getOptions(),i=this.resourcePath;o.postMessage({...s,sourceCode:e,filename:i,inputSourceMap:t}),o.addListener("message",function e(t){i===t[0]&&(r(t[1],t[2],t[3]),o.removeListener("message",e))})}function n(e,t){return i.bind(this,e,t)}o.setMaxListeners(0);let a=i;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=exports,t={get custom(){return n},get default(){return a}};for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(t,r).get});let s=require("node:path"),o=new(require("node:worker_threads")).Worker((0,s.join)(__dirname,"../worker/solid.mjs"));async function i(e,t){(this._compiler?.options.mode!=="development"||"true"===process.env.IS_BUILD)&&this._compiler?.hooks.done.tap("solid-loader",()=>{o.terminate()}),this.cacheable&&this.cacheable();let r=this.async(),s=this.getOptions(),i=this.resourcePath;o.postMessage({...s,sourceCode:e,filename:i,inputSourceMap:t}),o.addListener("message",function e(t){i===t[0]&&(r(t[1],t[2],t[3]),o.removeListener("message",e))})}function n(e,t){return i.bind(this,e,t)}o.setMaxListeners(0);let a=i;
@@ -1 +1 @@
1
- import{fileURLToPath as e}from"node:url";import{Worker as s}from"node:worker_threads";export class CompressionPlugin{constructor(t){this.name="CompressionPlugin";let{test:o,algorithm:r="brotli"}=t||{};this.options={test:o,algorithm:r,filename:`[path][base].${"brotli"===r?"br":"gz"}`},this.worker=new s(e(new URL("../worker/compression.mjs",import.meta.url))),this.worker.setMaxListeners(0)}async runCompressionAlgorithm(e,s){return new Promise(t=>{this.worker.postMessage({input:e,filename:s,algorithm:this.options.algorithm}),this.worker.addListener("message",e=>{e[0]===s&&t(Buffer.from(e[1]))})})}async compress(e,s,t){this.worker.removeAllListeners("message");let o=s.getCache(this.name),{RawSource:r}=e.webpack.sources;await Promise.allSettled(Object.keys(t).map(async t=>{let i,a="gzip"===this.options.algorithm?"gzipped":`${this.options.algorithm}ed`,{info:m,source:n}=s.getAsset(t);if(m.compressed||!e.webpack.ModuleFilenameHelpers.matchObject.bind(void 0,this.options)(t)||m.related&&m.related[a])return!1;let p=o.getItemCache(JSON.stringify(`${t}${this.options.algorithm}`),o.getLazyHashedEtag(n)),l=await p.getPromise()||{};if(!l.source){if("function"==typeof n.buffer)i=n.buffer();else{let e=n.source();i=Buffer.isBuffer(e)?e:Buffer.from(e)}if(!l.compressed&&i)try{l.compressed=await this.runCompressionAlgorithm(i,t)}catch(e){s.errors.push(e);return}l.compressed&&(l.source=new r(l.compressed)),await p.storePromise(l)}let h=s.getPath(this.options.filename,{filename:t}),c={compressed:!0};m.immutable&&/(\[name]|\[base]|\[file])/.test(this.options.filename)&&(c.immutable=!0),s.updateAsset(t,n,{related:{[a]:h}}),s.emitAsset(h,l.source,c)}))}apply(e){let s=this.name;e.hooks.thisCompilation.tap(s,t=>{t.hooks.processAssets.tapPromise({name:s,stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER,additionalAssets:!0},s=>this.compress(e,t,s))}),("development"!==e.options.mode||"true"===process.env.IS_BUILD)&&e.hooks.done.tap(this.name,()=>{this.worker.terminate()})}}
1
+ import{fileURLToPath as e}from"node:url";import{Worker as s}from"node:worker_threads";export class CompressionPlugin{constructor(t){this.name="CompressionPlugin";let{test:o,algorithm:r="brotli"}=t||{};this.options={test:o,algorithm:r,filename:`[path][base].${"brotli"===r?"br":"gz"}`},this.worker=new s(e(new URL("../worker/compression.mjs",import.meta.url))),this.worker.setMaxListeners(0)}async runCompressionAlgorithm(e,s){return new Promise(t=>{this.worker.postMessage({input:e,filename:s,algorithm:this.options.algorithm}),this.worker.addListener("message",e=>{e[0]===s&&t(Buffer.from(e[1]))})})}async compress(e,s,t){this.worker.removeAllListeners("message");let o=s.getCache(this.name),{RawSource:r}=e.webpack.sources;await Promise.allSettled(Object.keys(t).map(async t=>{let i,a="gzip"===this.options.algorithm?"gzipped":`${this.options.algorithm}ed`,{info:m,source:n}=s.getAsset(t);if(m.compressed||!e.webpack.ModuleFilenameHelpers.matchObject.bind(void 0,this.options)(t)||m.related&&m.related[a])return!1;let p=o.getItemCache(JSON.stringify(`${t}${this.options.algorithm}`),o.getLazyHashedEtag(n)),l=await p.getPromise()||{};if(!l.source){if("function"==typeof n.buffer)i=n.buffer();else{let e=n.source();i=Buffer.isBuffer(e)?e:Buffer.from(e)}if(!l.compressed&&i)try{l.compressed=await this.runCompressionAlgorithm(i,t)}catch(e){s.errors.push(e);return}l.compressed&&(l.source=new r(l.compressed)),await p.storePromise(l)}let h=s.getPath(this.options.filename,{filename:t}),c={compressed:!0};m.immutable&&/(\[name]|\[base]|\[file])/.test(this.options.filename)&&(c.immutable=!0),s.updateAsset(t,n,{related:{[a]:h}}),s.emitAsset(h,l.source,c)}))}apply(e){let s=this.name;("development"!==e.options.mode||"true"===process.env.IS_BUILD)&&e.hooks.done.tap(this.name,()=>{this.worker.terminate()}),e.hooks.thisCompilation.tap(s,t=>{t.hooks.processAssets.tapPromise({name:s,stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER,additionalAssets:!0},s=>this.compress(e,t,s))})}}
@@ -1 +1 @@
1
- import{fileURLToPath as e}from"node:url";import{Worker as t}from"node:worker_threads";import s from"webpack";class o extends s.WebpackError{constructor(e){super(`[ESLint] ${e}`),this.name="ESLintError",this.stack=""}}export class ESLintPlugin{constructor(s={files:[]}){this.name="ESLintPlugin",this.options=s,this.worker=new t(e(new URL("../worker/eslint.mjs",import.meta.url))),this.worker.setMaxListeners(0)}apply(e){e.hooks.thisCompilation.tap(this.name,t=>{let s=e.modifiedFiles||new Set,o=e=>{this.report(t,e)};this.worker.on("message",o),t.hooks.finishModules.tap(this.name,e=>{let t=this.options;if(this.options?.lintDirtyModulesOnly){let o=[];for(let t of e){let e=t.resource;s.has(e)&&o.push(e)}t.files=o}this.worker.postMessage({options:t})})}),("development"!==e.options.mode||"true"===process.env.IS_BUILD)&&e.hooks.done.tap(this.name,()=>{this.worker.terminate()})}report(e,t){t?.length&&e&&(t[0]?.length&&e.warnings.push(new o(t[0])),t[1]?.length&&e.errors.push(new o(t[1])))}}
1
+ import{fileURLToPath as e}from"node:url";import{Worker as t}from"node:worker_threads";import s from"webpack";class o extends s.WebpackError{constructor(e){super(`[ESLint] ${e}`),this.name="ESLintError",this.stack=""}}export class ESLintPlugin{constructor(s={files:[]}){this.name="ESLintPlugin",this.options=s,this.worker=new t(e(new URL("../worker/eslint.mjs",import.meta.url))),this.worker.setMaxListeners(0)}apply(e){("development"!==e.options.mode||"true"===process.env.IS_BUILD)&&e.hooks.done.tap(this.name,()=>{this.worker.terminate()}),e.hooks.thisCompilation.tap(this.name,t=>{let s=e.modifiedFiles||new Set,o=e=>{this.report(t,e)};this.worker.on("message",o),t.hooks.finishModules.tap(this.name,e=>{let t=this.options;if(this.options?.lintDirtyModulesOnly){let o=[];for(let t of e){let e=t.resource;s.has(e)&&o.push(e)}t.files=o}this.worker.postMessage({options:t})})})}report(e,t){t?.length&&e&&(t[0]?.length&&e.warnings.push(new o(t[0])),t[1]?.length&&e.errors.push(new o(t[1])))}}
@@ -1 +1 @@
1
- import{fileURLToPath as t}from"node:url";import{Worker as e}from"node:worker_threads";import r from"webpack";class s extends r.WebpackError{constructor(t){super(`[Stylelint] ${t}`),this.name="StylelintError",this.stack=""}}export class StylelintPlugin{constructor(r={files:[]}){this.name="StylelintPlugin",this.options=r,this.worker=new e(t(new URL("../worker/stylelint.mjs",import.meta.url))),this.worker.setMaxListeners(0)}apply(t){t.hooks.thisCompilation.tap(this.name,t=>{let e=e=>{this.report(e,t)};this.worker.postMessage({options:this.options}),this.worker.on("message",e)}),("development"!==t.options.mode||"true"===process.env.IS_BUILD)&&t.hooks.done.tap(this.name,()=>{this.worker.terminate()})}report(t,e){t?.length&&e&&(t[0]?.length&&e.warnings.push(new s(t[0])),t[1]?.length&&e.errors.push(new s(t[1])))}}
1
+ import{fileURLToPath as t}from"node:url";import{Worker as e}from"node:worker_threads";import r from"webpack";class s extends r.WebpackError{constructor(t){super(`[Stylelint] ${t}`),this.name="StylelintError",this.stack=""}}export class StylelintPlugin{constructor(r={files:[]}){this.name="StylelintPlugin",this.options=r,this.worker=new e(t(new URL("../worker/stylelint.mjs",import.meta.url))),this.worker.setMaxListeners(0)}apply(t){("development"!==t.options.mode||"true"===process.env.IS_BUILD)&&t.hooks.done.tap(this.name,()=>{this.worker.terminate()}),t.hooks.thisCompilation.tap(this.name,t=>{let e=e=>{this.report(e,t)};this.worker.postMessage({options:this.options}),this.worker.on("message",e)})}report(t,e){t?.length&&e&&(t[0]?.length&&e.warnings.push(new s(t[0])),t[1]?.length&&e.errors.push(new s(t[1])))}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",