@moneko/core 4.6.0 → 4.6.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/bin/lessc.mjs CHANGED
@@ -1 +1 @@
1
- import{exec as e}from"node:child_process";import{join as o}from"node:path/posix";import{loadFile as s,saveFile as t,scanFolderSync as i}from"@moneko/utils";import l from"../commom/require.mjs";import{runtimePath as r}from"./utils/config.mjs";let m="";function n(s){let t=o(l.resolve("less"),"../bin/lessc");return new Promise((o,i)=>{e(`${r} ${t} --js ${m} ${s} > ${s.replace(/\.less$/g,".css")}`,function(e){if(e)return i(e);o(!0)})})}let a=/\*?\.less/g;async function c(e){let o=await s(e);o&&a.test(o)&&await t(e,o.replace(a,".css"))}export async function lesscCommonjs(){let e=i("lib",["\\.less$"]),o=(await import("../options/modify-vars.mjs")).default;for(let e in o)Object.hasOwnProperty.call(o,e)&&(m+=`--modify-var="${e}=${o[e]}" `);Promise.allSettled(e.map(n)),e.length&&Promise.allSettled(i("lib",["\\.js$"]).map(c))}
1
+ import{exec as e}from"node:child_process";import{join as o}from"node:path";import{loadFile as s,saveFile as t,scanFolderSync as l}from"@moneko/utils";import r from"../commom/require.mjs";import{runtimePath as i}from"./utils/config.mjs";let m="";function n(s){let t=o(r.resolve("less"),"../bin/lessc");return new Promise((o,l)=>{e(`${i} ${t} --js ${m} ${s} > ${s.replace(/\.less$/g,".css")}`,function(e){if(e)return l(e);o(!0)})})}let a=/\*?\.less/g;async function c(e){let o=await s(e);o&&a.test(o)&&await t(e,o.replace(a,".css"))}export async function lesscCommonjs(){let e=l("lib",["\\.less$"]),o=(await import("../options/modify-vars.mjs")).default;for(let e in o)Object.hasOwnProperty.call(o,e)&&(m+=`--modify-var="${e}=${o[e]}" `);Promise.allSettled(e.map(n)),e.length&&Promise.allSettled(l("lib",["\\.js$"]).map(c))}
@@ -1 +1 @@
1
- import{execSync as e}from"node:child_process";import{renameSync as o}from"node:fs";import{posix as n}from"node:path";import{bundleIpa as p,createDir as t,ink as a,print as l}from"@moneko/utils";import r from"../../commom/timer.mjs";let i=n.join;export function bundleApk(n,p,u="-release"){l(a("正在编译 apk...","yellow"),!0),r.start(`bundle apk ${u}`),e(`flutter build apk -${u}`),r.end(`bundle apk ${u}`),t(p),o(i(n,`build/app/outputs/flutter-apk/app${u}.apk`),p),l(`✨ ${a("Apk 编译","cyan")}: ${a("完成","cyan")}`,!0)}export function bundleIOS(n,u,d="-release"){l(a("正在编译 ipa...","yellow"),!0),r.start(`bundle ipa ${d}`);let m=i(u,"Runner/Payload");e(`flutter build ios -${d} --no-codesign`),t(m),o(i(n,"build/ios/iphoneos/Runner.app"),m),p(i(u,"Runner"),u,d),r.end(`bundle ipa ${d}`),l(`✨ ${a("ipa 编译","cyan")}: ${a("完成","cyan")}`,!0)}
1
+ import{execSync as e}from"node:child_process";import{renameSync as o}from"node:fs";import{join as n}from"node:path";import{bundleIpa as p,createDir as t,ink as a,print as r}from"@moneko/utils";import l from"../../commom/timer.mjs";export function bundleApk(p,i,u="-release"){r(a("正在编译 apk...","yellow"),!0),l.start(`bundle apk ${u}`),e(`flutter build apk -${u}`),l.end(`bundle apk ${u}`),t(i),o(n(p,`build/app/outputs/flutter-apk/app${u}.apk`),i),r(`✨ ${a("Apk 编译","cyan")}: ${a("完成","cyan")}`,!0)}export function bundleIOS(i,u,d="-release"){r(a("正在编译 ipa...","yellow"),!0),l.start(`bundle ipa ${d}`);let m=n(u,"Runner/Payload");e(`flutter build ios -${d} --no-codesign`),t(m),o(n(i,"build/ios/iphoneos/Runner.app"),m),p(n(u,"Runner"),u,d),l.end(`bundle ipa ${d}`),r(`✨ ${a("ipa 编译","cyan")}: ${a("完成","cyan")}`,!0)}
@@ -1 +1 @@
1
- import{posix as e}from"node:path";import{cwd as o,execPath as t,platform as c}from"node:process";let{dirname:n,join:r}=e,s="u">typeof Deno?"deno":"u">typeof Bun?"bun":"node",p=n(t);"win32"===c&&p.includes(" ")&&(p=`"${p}"`);export const runtimePath=r(p,s);export const corePkg="@moneko/core";export const cwd=o();export const cachePath=r(cwd,"node_modules/.cache");export const swcCachePath=r(cachePath,".swc");export function parseBraced(e){return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1).split(","):[e]}
1
+ import{dirname as e,join as o}from"node:path";import{cwd as t,execPath as c,platform as n}from"node:process";let r="u">typeof Deno?"deno":"u">typeof Bun?"bun":"node",s=e(c);"win32"===n&&s.includes(" ")&&(s=`"${s}"`);export const runtimePath=o(s,r);export const corePkg="@moneko/core";export const cwd=t();export const cachePath=o(cwd,"node_modules/.cache");export const swcCachePath=o(cachePath,".swc");export function parseBraced(e){return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1).split(","):[e]}
@@ -1,5 +1,4 @@
1
- // import { posix } from 'node:path';
2
- // const { join, sep, extname, normalize } = posix;
1
+ // import { join, sep, extname, normalize } from 'node:path';
3
2
  // import { copyFile, ink, println, scanFolderSync, updateFile } from '@moneko/utils';
4
3
  // import { JsMinifyOptions, type Options, type Output, transformFile } from '@swc/core';
5
4
  // function getOutfilePath(outDir: string, file: string, outFileExtension?: string) {
@@ -1 +1 @@
1
- import{tmpdir as o}from"node:os";import{cwd as t,env as e}from"node:process";import{fileURLToPath as n,URL as a}from"node:url";import{fileExists as c}from"@moneko/utils";import{CUSTOMCONFIG as r}from"./custom-config.mjs";import{resolve as m}from"./posix.mjs";let s=JSON.parse(e.npm_config_argv||'{"original":[]}').original;export const __dirname=n(new a("..",import.meta.url));export const yarnArgv={};for(let o=0,t=s.length;o<t;o++){let t=s[o].split("=");Object.assign(yarnArgv,{[t[0]]:t[1]||!0})}export{CUSTOMCONFIG}from"./custom-config.mjs";let i=t(),p=m(i,"node_modules");export const TMP_DIR=m(o(),"@moneko");let h={nodeModules:p,pnpmNodeModules:m(p,".pnpm/node_modules"),denoNodeModules:m(p,".deno"),corePath:__dirname,programPath:i,CA_DIR:m(TMP_DIR,".ca"),webpackCachePath:m(p,".cache"),lintCachePath:m(p,".cache"),httpCachePath:m(p,".cache/http"),swcCachePath:m(p,".cache/.swc"),configPath:m(i,"config/index.ts"),customConfigPath:m(i,`config/${r}.ts`),coveragePath:m(i,"coverage/clover.xml"),pagesPath:m(i,"src/pages"),componentsPath:m(i,"components"),mockPath:m(i,"mock")};export const config_files=[c(h.configPath)&&h.configPath,c(h.customConfigPath)&&h.customConfigPath].filter(Boolean);export const routeDir="library"===e.APPTYPE?h.componentsPath:h.pagesPath;export default h;
1
+ import{tmpdir as o}from"node:os";import{resolve as t}from"node:path";import{cwd as e,env as n}from"node:process";import{fileURLToPath as a,URL as c}from"node:url";import{fileExists as r}from"@moneko/utils";import{CUSTOMCONFIG as m}from"./custom-config.mjs";let s=JSON.parse(n.npm_config_argv||'{"original":[]}').original;export const __dirname=a(new c("..",import.meta.url));export const yarnArgv={};for(let o=0,t=s.length;o<t;o++){let t=s[o].split("=");Object.assign(yarnArgv,{[t[0]]:t[1]||!0})}export{CUSTOMCONFIG}from"./custom-config.mjs";let i=e(),p=t(i,"node_modules");export const TMP_DIR=t(o(),"@moneko");let h={nodeModules:p,pnpmNodeModules:t(p,".pnpm/node_modules"),denoNodeModules:t(p,".deno"),corePath:__dirname,programPath:i,CA_DIR:t(TMP_DIR,".ca"),webpackCachePath:t(p,".cache"),lintCachePath:t(p,".cache"),httpCachePath:t(p,".cache/http"),swcCachePath:t(p,".cache/.swc"),configPath:t(i,"config/index.ts"),customConfigPath:t(i,`config/${m}.ts`),coveragePath:t(i,"coverage/clover.xml"),pagesPath:t(i,"src/pages"),componentsPath:t(i,"components"),mockPath:t(i,"mock")};export const config_files=[r(h.configPath)&&h.configPath,r(h.customConfigPath)&&h.customConfigPath].filter(Boolean);export const routeDir="library"===n.APPTYPE?h.componentsPath:h.pagesPath;export default h;
@@ -1,2 +1 @@
1
- export { basename, dirname, extname, normalize, parse, relative, resolve, sep } from 'node:path';
2
1
  export declare function join(...segments: string[]): string;
@@ -1 +1 @@
1
- import{join as e}from"node:path";import{URL as r}from"node:url";export{basename,dirname,extname,normalize,parse,relative,resolve,sep}from"node:path";export function join(...t){let o=t[0];if(/^https?:\/\//.test(o)){let e=o;for(let o=1;o<t.length;o++)e=new r(t[o],e).href;return e}return e(...t)}
1
+ import{join as t}from"node:path";import{URL as e}from"node:url";export function join(...r){let o=r[0];if(/^https?:\/\//.test(o)){let t=o;for(let o=1;o<r.length;o++)t=new e(r[o],t).href;return t}return t(...r)}
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 r from"node:process";import{URL as i}from"node:url";import{ink as s,print as n,println as m,progressBar as a}from"@moneko/utils";import l from"webpack";import p from"webpack-hot-middleware";import{merge as c}from"webpack-merge";import{diffObject as f}from"./commom/diff-object.mjs";import h,{config_files as u}from"./commom/paths.mjs";import{relative as d}from"./commom/posix.mjs";import*as g from"./commom/rule.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 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 l.WatchIgnorePlugin({paths:[g.node_modules,/\.d\.ts$/]}),new l.ProgressPlugin({handler(e,t,...o){let i=o.length?`[${t}] ${o.join(" ")}`:" ";I||(T.info=i,T.percentage=e,I=1===e);let s=P.bar;if(s){let t=s.name||"Build";s.quiet?r.stdout.write(`${i}
2
- `):(a(e||0,1,{msg:i,name:t,barColor:s.barColor,nameColor:s.nameColor,barBgColor:s.barBgColor,msgColor:s.msgColor}),1===e&&r.stdout.write("\r\x1b[2K"))}}})]});function U(e){let t=e.join(","),o=[d(h.programPath,`${P.alias["@"]}/**/*.{${t}}`)];return B&&o.push(d(h.programPath,`${P.alias["@pkg"]}/**/*.{${t}}`)),o}P.eslint&&L.plugins.push(new x({fix:!0,cache:!0,cacheLocation:`${h.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:`${h.lintCachePath}/.stylelintcache`,files:U(["css","scss","sass","less","ts","tsx","js","jsx"]),...P.stylelint}));let F=l(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=p(F,{log:!1,path:R,heartbeat:2e3}),K=await v({port:j,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 i(`${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($(O,T)),!0;if(o.pathname===R&&"text/event-stream"===e.headers.accept)return J(e,t,_),!0}return!1}}});function M(){r.exit(0)}K.on("close",()=>{N.close(_),J.close()});let W=await Promise.all(u.map(S)),z=c(W[0]||{},W[1]||{});u.forEach(function(t){o(t,async function(){var o;let[i,a]=await Promise.all(u.map(S)),l=c(i||{},a||{}),p=f(z,l);1===Object.keys(p).length&&"proxy"in p?(n(s("代理更新中...","yellow"),!0),n(s("代理更新完成...","green"),!0),P.proxy=l.proxy,z.proxy=l.proxy,z=l):(z=l,m(s(`检测到工程配置${s(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),o=j,e(A?`netstat -ano | findstr :${o}`:`lsof -i :${o} -t`,(e,t)=>{if(e){m(s(`查找端口 ${o} 时发生错误: ${e.message}`,"red")),m(s("请尝试手动重启程序","yellow"));return}let i=t.trim().replace(/\r\n/g,"\n").split("\n").filter(Boolean),n=A?i[0]?.split(/\s+/).pop()?.trim():i[0]?.trim();if(!n)return void m(s(`未找到占用端口 ${o} 的进程, 请尝试手动重启程序`,"yellow"));try{r.kill(Number(n),"SIGHUP")}catch(e){m(s(`终止进程 ${n} 时发生错误: ${e.message}`,"red"))}}))})});let A="win32"===r.platform;r.on("SIGHUP",function(){let e;K.close(),(e=t(r.argv[0],r.argv.slice(1),{detached:!1,stdio:"inherit"})).unref(),e.on("close",M)}),r.on("exit",function(){K.close()}),w(M);
1
+ import{exec as e,spawn as t}from"node:child_process";import{watchFile as o}from"node:fs";import{relative as r,sep as i}from"node:path";import s from"node:process";import{URL as n}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 d}from"./commom/diff-object.mjs";import u,{config_files as g}from"./commom/paths.mjs";import*as w from"./commom/rule.mjs";import y from"./commom/sigint-exit.mjs";import{devLog as $,PORT as j}from"./dev/config.mjs";import v from"./dev/generate-progress-html.mjs";import b from"./dev/server.mjs";import x from"./options/reslove.mjs";import{ESLintPlugin as C}from"./plugin/eslint.mjs";import{StylelintPlugin as _}from"./plugin/stylelint.mjs";import{empty as P}from"./utils/index.mjs";import{CONFIG as S,getConfig as k}from"./config.mjs";import{createDevelopmentConfiguration as E}from"./create-development-configuration.mjs";import{outputFileSystem as B}from"./file-system.mjs";import{isLibrary as H,refresh as I}from"./process-env.mjs";let O=!1,T="/____progress____",q={percentage:0,info:""},G="/__hmr__",L=new URLSearchParams({name:"client",path:G.substring(1),dynamicPublicPath:!0,timeout:2e3,reload:!I,quiet:!0,noInfo:!0,overlay:!1,autoConnect:!0}).toString(),U=await E({watchOptions:{stdin:!0,aggregateTimeout:300,ignored:w.node_modules},entry:{main:[`${x.hotMiddlewareClient}?${L}`]},plugins:[new c.WatchIgnorePlugin({paths:[w.node_modules,/\.d\.ts$/]}),new c.ProgressPlugin({handler(e,t,...o){let r=o.length?`[${t}] ${o.join(" ")}`:" ";O||(q.info=r,q.percentage=e,O=1===e);let i=S.bar;if(i){let t=i.name||"Build";i.quiet?s.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&&s.stdout.write("\r\x1b[2K"))}}})]});function A(e){let t=e.join(","),o=[r(u.programPath,`${S.alias["@"]}/**/*.{${t}}`).replaceAll(i,"/")];return H&&o.push(r(u.programPath,`${S.alias["@pkg"]}/**/*.{${t}}`).replaceAll(i,"/")),o}S.eslint&&U.plugins.push(new C({fix:!0,cache:!0,cacheLocation:`${u.lintCachePath}/.eslintcache`,cacheStrategy:"metadata",files:A(["js","jsx","ts","tsx","json","html","vue"]),...S.eslint})),S.stylelint&&U.plugins.push(new _({fix:!0,cache:!0,cacheLocation:`${u.lintCachePath}/.stylelintcache`,files:A(["css","scss","sass","less","ts","tsx","js","jsx"]),...S.stylelint}));let F=c(U);if(!F)throw Error("无法创建编译器");F.outputFileSystem=B;let N=F.watch(F.options.watchOptions,$);if(!N)throw Error("无法创建监视器");F.hooks.done.tap("client-log",e=>{$(null,e)});let R=`${S.basename}/${G}`.replace(/\/+/g,"/"),J=f(F,{log:!1,path:R,heartbeat:2e3}),K=await b({port:j,root_dir:F.options.output.path,fileSystem:F.outputFileSystem,headers:S.devServer.headers,https:S.devServer.https,host:S.devServer.host,open:S.devServer.open,basename:S.basename,onRequest(e,t){if(!t.writableEnded){if("GET"===e.method){let o=new n(`${S.devServer.https?"https":"http"}://${e.headers.host}${e.url}`);if(o.pathname===T)return t.writeHead(200,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),t.end(JSON.stringify(q)),!0;if(!O)return t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end(v(T,q)),!0;if(o.pathname===R&&"text/event-stream"===e.headers.accept)return J(e,t,P),!0}return!1}}});function M(){s.exit(0)}K.on("close",()=>{N.close(P),J.close()});let W=await Promise.all(g.map(k)),z=h(W[0]||{},W[1]||{});g.forEach(function(t){o(t,async function(){var o;let[r,i]=await Promise.all(g.map(k)),n=h(r||{},i||{}),p=d(z,n);1===Object.keys(p).length&&"proxy"in p?(m(a("代理更新中...","yellow"),!0),m(a("代理更新完成...","green"),!0),S.proxy=n.proxy,z.proxy=n.proxy,z=n):(z=n,l(a(`检测到工程配置${a(`[${t}]`,"blue")}变更, 程序即将重启...`,"yellow"),!0),o=j,e(D?`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=D?r[0]?.split(/\s+/).pop()?.trim():r[0]?.trim();if(!i)return void l(a(`未找到占用端口 ${o} 的进程, 请尝试手动重启程序`,"yellow"));try{s.kill(Number(i),"SIGHUP")}catch(e){l(a(`终止进程 ${i} 时发生错误: ${e.message}`,"red"))}}))})});let D="win32"===s.platform;s.on("SIGHUP",function(){let e;K.close(),(e=t(s.argv[0],s.argv.slice(1),{detached:!1,stdio:"inherit"})).unref(),e.on("close",M)}),s.on("exit",function(){K.close()}),y(M);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "4.6.0",
3
+ "version": "4.6.2",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",