@moneko/core 3.16.8 → 3.17.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/build.mjs CHANGED
@@ -1 +1 @@
1
- import{removeDirAll as o}from"@moneko/mdx";import r from"webpack";import{merge as m}from"webpack-merge";import t from"./build/common.mjs";import e from"./build/server.mjs";import{CONFIG as i}from"./config.mjs";import s from"./module.config.mjs";import n from"./paths.mjs";import l from"./plugin/done.mjs";import{SSR as a}from"./process-env.mjs";import p from"./utils/log.mjs";import f from"./utils/seo.mjs";import c from"./utils/progress.mjs";import g from"chalk";let{ProgressPlugin:h}=r,u=m(t,{module:s(!1),plugins:[i.done&&new l({done:i.done}),i.bar&&new h({handler(o,r,...m){let t=i.bar;c(o,t.name||"Build",m.length?`[${r}] ${m.join(" ")}`:"",t.color,u.output?.path)}})].filter(Boolean)}),d=[u];a&&d.push(m(t,e));let j=r(d);async function w(){await new Promise(o=>{j.run((r,m)=>{if(r)throw r;if(m&&(m.hasErrors()||m.hasWarnings()))for(let o=0,r=m.stats.length;o<r;o++){let r=m.stats[o];for(let o=0,m=r.compilation.warnings.length;o<m;o++)p(g.yellowBright(r.compilation.warnings[o].message));for(let o=0,m=r.compilation.errors.length;o<m;o++)p(g.redBright(r.compilation.errors[o].message))}o(r)})}),i.seo&&f()}await w(),process.on("exit",function(){o(n.cachePath),o(n.vfsDtsPath)});
1
+ import{removeDirAll as o}from"@moneko/mdx";import r from"webpack";import{merge as t}from"webpack-merge";import m from"./build/common.mjs";import e from"./build/server.mjs";import{CONFIG as i}from"./config.mjs";import s from"./module.config.mjs";import n from"./paths.mjs";import l from"./plugin/done.mjs";import{SSR as a}from"./process-env.mjs";import p from"./utils/log.mjs";import f from"./utils/seo.mjs";import c from"./utils/progress.mjs";import u from"chalk";let{ProgressPlugin:g}=r,h=!!i.bar,d=t(m,{module:s(!1),plugins:[i.done&&new l({done:i.done}),new g({handler(o,r,...t){let m=i.bar||{};c({num:o,title:m.name||"Build",info:t.length?`[${r}] ${t.join(" ")}`:"",color:m.color,output:d.output?.path,showBar:h})}})].filter(Boolean)}),w=[d];a&&w.push(t(m,e));let j=r(w);async function b(){await new Promise(o=>{j.run((r,t)=>{if(r)throw r;if(t&&(t.hasErrors()||t.hasWarnings()))for(let o=0,r=t.stats.length;o<r;o++){let r=t.stats[o];for(let o=0,t=r.compilation.warnings.length;o<t;o++)p(u.yellowBright(r.compilation.warnings[o].message));for(let o=0,t=r.compilation.errors.length;o<t;o++)p(u.redBright(r.compilation.errors[o].message))}o(r)})}),i.seo&&f()}await b(),process.on("exit",function(){o(n.cachePath),o(n.vfsDtsPath)});
package/lib/dev.mjs CHANGED
@@ -1 +1 @@
1
- import{directoryExists as e,fileExists as t,loadFileSync as o,removeDirAll as i}from"@moneko/mdx";import s from"express";import r from"multer";import l from"webpack";import n from"webpack-dev-middleware";import m from"webpack-hot-middleware";import{merge as a}from"webpack-merge";import c from"./build/server.mjs";import{commonConfig as p}from"./common.mjs";import{CONFIG as f}from"./config.mjs";import{PORT as d,devLog as u,headers as h}from"./dev/config.mjs";import g from"./dev/mock.mjs";import w from"./dev/proxy.mjs";import x from"./module.config.mjs";import j,{CUSTOMCONFIG as $}from"./paths.mjs";import{SSR as k,isLibrary as y,isReact as b}from"./process-env.mjs";import v from"./utils/has-pkg.mjs";import{empty as P,resolveProgram as _}from"./utils/index.mjs";import S from"./utils/progress.mjs";import C from"./utils/sigint-exit.mjs";import B from"./options/reslove.mjs";import{watchFile as D}from"fs";import{spawn as M,exec as G}from"child_process";import I from"./utils/log.mjs";import L from"chalk";let{HotModuleReplacementPlugin:U,ProgressPlugin:A,WatchIgnorePlugin:F}=l,H=v("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,O=v("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,R=b&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,T=["js","jsx","ts","tsx","json","html","vue"],q=T.join(","),E=["css","scss","sass","less","ts","tsx","js","jsx"],N=E.join(","),z=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],J=new URLSearchParams({timeout:2e3,reload:!(v("solid-refresh")||v("react-refresh")),quiet:!0,noInfo:!0,overlay:!0,dynamicPublicPath:!0}).toString(),K=p.output.path;k&&(K=_(`${y?"docs":"dist"}/client`));let Q=a(p,{entry:{main:[`${B.hotMiddlewareClient}?name=client&path=//localhost:${d}/__hmr__&${J}`]},output:{path:K},module:x(!1),plugins:[new U,new F({paths:[/\.d\.ts$/]}),R&&new R,O&&new O({fix:!0,threads:!0,files:[`${f.alias["@"]}/**/*.{${q}}`,y&&`${f.alias["@pkg"]}/**/*.{${q}}`].filter(Boolean),extensions:T,exclude:z,cache:!0,cacheLocation:`${j.lineCachePath}/.eslintcache`,lintDirtyModulesOnly:!0}),H&&new H({fix:!0,threads:!0,files:[`${f.alias["@"]}/**/*.{${N}}`,y&&`${f.alias["@pkg"]}/**/*.{${N}}`].filter(Boolean),extensions:E,exclude:z,cache:!0,cacheLocation:`${j.lineCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),f.bar&&new A({handler(e,t,...o){let i=f.bar;S(e,i.name||"Build",o.length?`[${t}] ${o.join(" ")}`:"",i.color)}})].filter(Boolean)}),V=[Q];k&&V.push(a(p,c));let W=l(V);W.compilers[0].hooks.done.tap("client-log",e=>{u(null,e)});let X=s(),Y=r(),Z=n(W,{writeToDisk:!1,index:"index.html",headers:()=>h,serverSideRender:k,lastModified:!0});if(X.use(Z),X.use(m(W,{log:!1,path:"/__hmr__",heartbeat:2e3})),f.proxy&&w(X,f.proxy),e(j.mockPath)){let e=g(j.mockPath);X.use(e)}let ee=`${Q.output.path}/index.html`;X.all("/*",Y.any(),function(e,t,o){if("GET"!==e.method)return o();{let e=Z.context.outputFileSystem,o=e?.readFileSync?.(ee);t.end(o)}});let et=X.listen(d,()=>{});function eo(){process.exit(0)}function ei(e,i){if(i&&t(e)){let t=(o(e)||"").trim().replace(/^\s*[\r\n]/gm,"");D(e,async function(){t!==(o(e)||"").trim().replace(/^\s*[\r\n]/gm,"")?(I(L.yellow(`检测到工程配置${L.blue(`[${i}]`)}变更, 程序即将重启...`)),G("win32"===process.platform?`netstat -ano | findstr :${d}`:`lsof -i :${d}`,(e,t,o)=>{let i=es?t.split(/\s+/).pop():t.split("\n")[1]?.split(/\s+/)[1];i?process.kill(Number(i),"SIGHUP"):I(`未找到占用端口 ${d} 的进程`)})):I(L.gray(`未变更`))})}}ei(j.configPath,"index"),ei(j.customConfigPath,$);let es="win32"===process.platform;process.on("SIGHUP",function(){Z.close(P),et.close(P),et.closeAllConnections(),function(){let e=M(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",eo)}()}),process.on("exit",function(){Z.close(P),et.close(P),et.closeAllConnections(),i(j.cachePath),i(j.vfsDtsPath)}),C(eo);
1
+ import{directoryExists as e,fileExists as t,loadFileSync as o,removeDirAll as i}from"@moneko/mdx";import s from"express";import r from"multer";import l from"webpack";import n from"webpack-dev-middleware";import m from"webpack-hot-middleware";import{merge as a}from"webpack-merge";import c from"./build/server.mjs";import{commonConfig as p}from"./common.mjs";import{CONFIG as f}from"./config.mjs";import{PORT as u,devLog as d,headers as h}from"./dev/config.mjs";import g from"./dev/mock.mjs";import w from"./dev/proxy.mjs";import x from"./module.config.mjs";import j,{CUSTOMCONFIG as $}from"./paths.mjs";import{SSR as k,isLibrary as y,isReact as b}from"./process-env.mjs";import v from"./utils/has-pkg.mjs";import{empty as P,resolveProgram as _}from"./utils/index.mjs";import S from"./utils/progress.mjs";import C from"./utils/sigint-exit.mjs";import B from"./options/reslove.mjs";import{watchFile as D}from"fs";import{spawn as M,exec as G}from"child_process";import I from"./utils/log.mjs";import L from"chalk";let{HotModuleReplacementPlugin:U,ProgressPlugin:A,WatchIgnorePlugin:F}=l,H=v("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,O=v("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,R=b&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,T=["js","jsx","ts","tsx","json","html","vue"],q=T.join(","),E=["css","scss","sass","less","ts","tsx","js","jsx"],N=E.join(","),z=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],J=new URLSearchParams({timeout:2e3,reload:!(v("solid-refresh")||v("react-refresh")),quiet:!0,noInfo:!0,overlay:!0,dynamicPublicPath:!0}).toString(),K=p.output.path;k&&(K=_(`${y?"docs":"dist"}/client`));let Q=!!f.bar,V=a(p,{entry:{main:[`${B.hotMiddlewareClient}?name=client&path=//localhost:${u}/__hmr__&${J}`]},output:{path:K},module:x(!1),plugins:[new U,new F({paths:[/\.d\.ts$/]}),R&&new R,O&&new O({fix:!0,threads:!0,files:[`${f.alias["@"]}/**/*.{${q}}`,y&&`${f.alias["@pkg"]}/**/*.{${q}}`].filter(Boolean),extensions:T,exclude:z,cache:!0,cacheLocation:`${j.lineCachePath}/.eslintcache`,lintDirtyModulesOnly:!0}),H&&new H({fix:!0,threads:!0,files:[`${f.alias["@"]}/**/*.{${N}}`,y&&`${f.alias["@pkg"]}/**/*.{${N}}`].filter(Boolean),extensions:E,exclude:z,cache:!0,cacheLocation:`${j.lineCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),new A({handler(e,t,...o){let i=f.bar||{};S({num:e,title:i.name||"Build",info:o.length?`[${t}] ${o.join(" ")}`:"",color:i.color,output:V.output?.path,showBar:Q})}})].filter(Boolean)}),W=[V];k&&W.push(a(p,c));let X=l(W);X.compilers[0].hooks.done.tap("client-log",e=>{d(null,e)});let Y=s(),Z=r(),ee=n(X,{writeToDisk:!1,index:"index.html",headers:()=>h,serverSideRender:k,lastModified:!0});if(Y.use(ee),Y.use(m(X,{log:!1,path:"/__hmr__",heartbeat:2e3})),f.proxy&&w(Y,f.proxy),e(j.mockPath)){let e=g(j.mockPath);Y.use(e)}let et=`${V.output.path}/index.html`;Y.all("/*",Z.any(),function(e,t,o){if("GET"!==e.method)return o();{let e=ee.context.outputFileSystem,o=e?.readFileSync?.(et);t.end(o)}});let eo=Y.listen(u,()=>{});function ei(){process.exit(0)}function es(e,i){if(i&&t(e)){let t=(o(e)||"").trim().replace(/^\s*[\r\n]/gm,"");D(e,async function(){t!==(o(e)||"").trim().replace(/^\s*[\r\n]/gm,"")?(I(L.yellow(`检测到工程配置${L.blue(`[${i}]`)}变更, 程序即将重启...`)),G("win32"===process.platform?`netstat -ano | findstr :${u}`:`lsof -i :${u}`,(e,t,o)=>{let i=er?t.split(/\s+/).pop():t.split("\n")[1]?.split(/\s+/)[1];i?process.kill(Number(i),"SIGHUP"):I(`未找到占用端口 ${u} 的进程`)})):I(L.gray(`未变更`))})}}es(j.configPath,"index"),es(j.customConfigPath,$);let er="win32"===process.platform;process.on("SIGHUP",function(){ee.close(P),eo.close(P),eo.closeAllConnections(),function(){let e=M(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",ei)}()}),process.on("exit",function(){ee.close(P),eo.close(P),eo.closeAllConnections(),i(j.cachePath),i(j.vfsDtsPath)}),C(ei);
@@ -1,9 +1,9 @@
1
- /**
2
- * 进度条
3
- * @param {Number} num 当前进度 100进制
4
- * @param {String} title 进度条标题(默认:下载中)
5
- * @param {String} info 详细信息
6
- * @constructor
7
- */
8
- declare function progress(num: number | undefined, title: string, info: string, color?: string, output?: string): void;
1
+ declare function progress(opt: {
2
+ num: number;
3
+ title: string;
4
+ info: string;
5
+ color?: string;
6
+ output?: string;
7
+ showBar?: boolean;
8
+ }): void;
9
9
  export default progress;
@@ -1 +1 @@
1
- import{cursorTo as t,clearScreenDown as s}from"readline";import{relative as e}from"path";import o from"chalk";import r from"./log.mjs";import i from"../paths.mjs";import{isDev as p}from"../process-env.mjs";let{blue:d,bgBlue:c,grey:m,green:u,yellow:l,red:f}=o,n={};export default function(a=0,h,$,g,w="dist/"){let x=process.stdout.rows-2,j=Math.fround(24*a),b=g?[o.hex(g),o.bgHex(g)]:[d,c],k=b[0](`${h}:`),v=m(`${(100*a).toFixed()}%`),y=b[1](" ".repeat(j))+b[1].inverse(" ".repeat(24-j));if(0===a&&(n[h]=process.hrtime(),process.stdout.write("\n\n")),t(process.stdout,0,x),s(process.stdout),process.stdout.write(`${k} ${y} ${v}`),process.stdout.write("\n"),process.stdout.write(m($.length>100?`${$.substring(0,100)}...`:$)),1===a){if(!p){let t=process.hrtime(n[h]),s=t[0]+t[1]/1e9,o=u;s<10?o=u:s<20?o=l:s<40&&(o=f),r(["",m(`Build completed ${u("successfully")}!`),m(`Output files are located in the ${d(`${e(i.programPath,w)}/`)} directory.`),m(`Build took ${o(s.toFixed(2))} seconds.`),"",""])}t(process.stdout,0,x),s(process.stdout)}}
1
+ import{cursorTo as t,clearScreenDown as o}from"readline";import{relative as e}from"path";import s from"chalk";import r from"./log.mjs";import i from"../paths.mjs";import{isDev as p}from"../process-env.mjs";let{blue:u,bgBlue:c,grey:m,green:d,yellow:l,red:n}=s,f={};export default function(a){let h=process.stdout.rows-2,$=Math.fround(24*a.num),w=a.color?[s.hex(a.color),s.bgHex(a.color)]:[u,c],g=w[0](`${a.title}:`),x=m(`${(100*a.num).toFixed()}%`),B=w[1](" ".repeat($))+w[1].inverse(" ".repeat(24-$));if(0===a.num&&(f[a.title]=process.hrtime(),a.showBar&&process.stdout.write("\n\n")),a.showBar&&(t(process.stdout,0,h),o(process.stdout),process.stdout.write(`${g} ${B} ${x}`),process.stdout.write("\n"),process.stdout.write(m(a.info.length>80?`${a.info.substring(0,80)}...`:a.info))),1===a.num){if(!p){let t=process.hrtime(f[a.title]),o=t[0]+t[1]/1e9,s=d;o<10?s=d:o<20?s=l:o<40&&(s=n),r(["",m(`Build completed ${d("successfully")}!`),m(`Output files are located in the ${u(`${e(i.programPath,a.output||"dist/")}/`)} directory.`),m(`Build took ${s(o.toFixed(2))} seconds.`),"",""])}t(process.stdout,0,h),o(process.stdout)}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.16.8",
3
+ "version": "3.17.0",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",