@moneko/core 4.0.8-beta.2 → 4.1.0-beta.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/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{relative as r}from"node:path";import i from"node:process";import{URL as n}from"node:url";import{ink as s,print as m,println as a,progressBar as l}from"@moneko/utils";import p from"webpack";import c from"webpack-hot-middleware";import{merge as 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 n=P.bar;if(n){let t=n.name||"Build";n.quiet?i.stdout.write(`${r}
2
- `):(l(e||0,1,{msg:r,name:t,barColor:n.barColor,nameColor:n.nameColor,barBgColor:n.barBgColor,msgColor:n.msgColor}),1===e&&i.stdout.write("\r\x1b[2K"))}}})],optimization:{minimize:!1}});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 z=p(L);if(!z)throw Error("无法创建编译器");z.outputFileSystem=E;let F=z.watch(z.options.watchOptions,y);if(!F)throw Error("无法创建监视器");z.hooks.done.tap("client-log",e=>{y(null,e)});let N=`${P.basename}/${q}`.replace(/\/+/g,"/"),R=c(z,{log:!1,path:N,heartbeat:2e3}),J=await v({port:$,root_dir:z.options.output.path,fileSystem:z.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 n(`${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===N&&"text/event-stream"===e.headers.accept)return R(e,t,_),!0}return!1}}});function K(){i.exit(0)}J.on("close",()=>{F.close(_),R.close()});let M=await Promise.all(u.map(S)),W=f(M[0]||{},M[1]||{});u.forEach(function(t){o(t,async function(){var o;let[r,n]=await Promise.all(u.map(S)),l=f(r||{},n||{}),p=h(W,l);1===Object.keys(p).length&&"proxy"in p?(m(s(`代理更新中...`,"yellow"),!0),m(s(`代理更新完成...`,"green"),!0),P.proxy=l.proxy,W.proxy=l.proxy,W=l):(W=l,a(s(`检测到工程配置${s(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),o=$,e(A?`netstat -ano | findstr :${o}`:`lsof -i :${o} -t`,(e,t)=>{if(e){a(s(`查找端口 ${o} 时发生错误: ${e.message}`,"red")),a(s("请尝试手动重启程序","yellow"));return}let r=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),n=A?r[0]?.split(/\s+/).pop()?.trim():r[0]?.trim();if(!n)return void a(s(`未找到占用端口 ${o} 的进程, 请尝试手动重启程序`,"yellow"));try{i.kill(Number(n),"SIGHUP")}catch(e){a(s(`终止进程 ${n} 时发生错误: ${e.message}`,"red"))}}))})});let A="win32"===i.platform;i.on("SIGHUP",function(){let e;J.close(_),(e=t(i.argv[0],i.argv.slice(1),{detached:!1,stdio:"inherit"})).unref(),e.on("close",K)}),i.on("exit",function(){J.close(_)}),w(K);
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);
package/lib/vm/dts.mjs CHANGED
@@ -1 +1 @@
1
- import{join as e}from"node:path";import{updateFile as t,updateFileSync as o}from"@moneko/utils";import m from"../commom/paths.mjs";import s from"../commom/reactive-object.mjs";import{readJson as r}from"../commom/read-json.mjs";import{app_schema as a,APPTYPE as n,CACHE_NAME as i,FRAMEWORK as d,framework as p,frameworkVersionStr as l,packageJson as f,SSR as v,virtual_schema as u}from"../process-env.mjs";import c from"../utils/create-types.mjs";import{generateDeclaration as j}from"../utils/dts.mjs";import{convertToCamelCase as $,transformModule as y}from"../utils/index.mjs";export const dts_path=e(m.nodeModules,"@types",i,"index.d.ts");export const vm_dts=new s({});vm_dts.on("change",()=>{let e=Object.values(vm_dts.data).join("\n");t(dts_path,e)});export function initDts(t){let s=c(`${a}:env`,j(y(t.env),`${a}:env`));vm_dts.setData(`${a}:env`,s);let _=c(`${a}:info`,j(y({...r(e(m.programPath,"package.json")),projectName:$(f.name),ssr:v,type:n,frameworkVersion:l,framework:p,base:t.basename,routerMode:t.routerMode,prefixCls:t.prefixCls,theme:t.theme}),`${a}:info`));vm_dts.setData(`${a}:info`,_),t.virtualModule&&Object.keys(t.virtualModule).map(e=>{let o=y(t.virtualModule[e]),m=`${u}:${e}`;vm_dts.setData(m,c(m,j(o,m)))});let h=t.moduleFederation?.map(e=>Array.isArray(e.remotes)?e.remotes.map(e=>e.name):[]).flat();o(dts_path,Object.values(vm_dts.data).join("\n")),o(e(m.nodeModules,"@moneko/init.d.json"),JSON.stringify({extends:`@moneko/${d}/base`,compilerOptions:{types:[`@moneko/${d}/env.d.ts`,`@types/${i}/index.d.ts`,...h.map(e=>`@types/${i}/${e}.d.ts`)]}}))}
1
+ import{join as e}from"node:path";import{updateFile as t,updateFileSync as o}from"@moneko/utils";import s from"../commom/paths.mjs";import m from"../commom/reactive-object.mjs";import{readJson as r}from"../commom/read-json.mjs";import{app_schema as a,APPTYPE as n,CACHE_NAME as i,FRAMEWORK as d,framework as p,frameworkVersionStr as l,packageJson as f,SSR as v,virtual_schema as u}from"../process-env.mjs";import c from"../utils/create-types.mjs";import{generateDeclaration as j}from"../utils/dts.mjs";import{convertToCamelCase as $,transformModule as y}from"../utils/index.mjs";export const dts_path=e(s.nodeModules,"@types",i,"index.d.ts");export const vm_dts=new m({});vm_dts.on("change",()=>{let e=Object.values(vm_dts.data).join("\n");t(dts_path,e)});export function initDts(t){let m=c(`${a}:env`,j(y(t.env),`${a}:env`));vm_dts.setData(`${a}:env`,m);let _=c(`${a}:info`,j(y({...r(e(s.programPath,"package.json")),projectName:$(f.name),ssr:v,type:n,frameworkVersion:l,framework:p,base:t.basename,routerMode:t.routerMode,prefixCls:t.prefixCls,theme:t.theme}),`${a}:info`));vm_dts.setData(`${a}:info`,_),t.virtualModule&&Object.keys(t.virtualModule).map(e=>{let o=y(t.virtualModule[e]),s=`${u}:${e}`;vm_dts.setData(s,c(s,j(o,s)))});let h=t.moduleFederation?.flatMap(e=>Array.isArray(e.remotes)?e.remotes.map(e=>e.name):[]).filter(Boolean);o(dts_path,Object.values(vm_dts.data).join("\n")),o(e(s.nodeModules,"@moneko/init.d.json"),JSON.stringify({extends:`@moneko/${d}/base`,compilerOptions:{types:[`@moneko/${d}/env.d.ts`,`@types/${i}/index.d.ts`,...h.map(e=>`@types/${i}/${e}.d.ts`)]}}))}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "4.0.8-beta.2",
3
+ "version": "4.1.0-beta.0",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
@@ -136,10 +136,10 @@
136
136
  "@moneko/stylelint": "1.7.0",
137
137
  "@moneko/transform-imports": "1.3.1",
138
138
  "@moneko/utils": "0.3.3",
139
- "@swc/core": "1.15.2",
139
+ "@swc/core": "1.15.3",
140
140
  "browserslist": "4.28.0",
141
- "core-js": "3.46.0",
142
- "core-js-compat": "3.46.0",
141
+ "core-js": "3.47.0",
142
+ "core-js-compat": "3.47.0",
143
143
  "husky": "9.1.7",
144
144
  "less": "4.4.2",
145
145
  "less-loader": "12.3.0",
@@ -148,7 +148,7 @@
148
148
  "memfs": "4.51.0",
149
149
  "swc-loader": "0.2.6",
150
150
  "typescript": "5.9.3",
151
- "webpack": "5.102.1",
151
+ "webpack": "5.103.0",
152
152
  "webpack-hot-middleware": "2.26.1",
153
153
  "webpack-merge": "6.0.1"
154
154
  },
@@ -158,11 +158,11 @@
158
158
  "@types/stylis": "4.2.7",
159
159
  "@types/webpack-bundle-analyzer": "4.7.0",
160
160
  "@types/webpack-hot-middleware": "2.25.12",
161
- "sass": "1.94.1",
161
+ "sass": "1.94.2",
162
162
  "sass-loader": "16.0.6",
163
163
  "solid-refresh": "0.7.5",
164
164
  "stylis": "4.3.6",
165
- "webpack-bundle-analyzer": "4.10.2"
165
+ "webpack-bundle-analyzer": "5.0.1"
166
166
  },
167
167
  "publishConfig": {
168
168
  "access": "public",
@@ -172,5 +172,5 @@
172
172
  "lib",
173
173
  "typings"
174
174
  ],
175
- "packageManager": "pnpm@10.20.0"
175
+ "packageManager": "pnpm@10.23.0"
176
176
  }