@moneko/core 3.24.5 → 3.24.6
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 +1 -1
- package/lib/common.mjs +1 -1
- package/lib/config.mjs +1 -1
- package/lib/dev.mjs +1 -1
- package/lib/loader/ts-doc.cjs +1 -1
- package/lib/paths.d.mts +0 -1
- package/lib/paths.mjs +1 -1
- package/lib/plugin/virtual-module.mjs +1 -1
- package/lib/utils/parse-module-meta.d.mts +8 -0
- package/lib/utils/parse-module-meta.mjs +1 -0
- package/lib/utils/setup-env.d.mts +5 -2
- package/lib/utils/setup-env.mjs +1 -1
- package/lib/vm/docs.d.mts +3 -1
- package/lib/vm/docs.mjs +1 -1
- package/lib/vm/example.mjs +1 -1
- package/lib/vm/locales.d.mts +2 -2
- package/lib/vm/locales.mjs +2 -2
- package/lib/vm/modules.mjs +1 -1
- package/lib/vm/routes.d.mts +4 -2
- package/lib/vm/routes.mjs +1 -1
- package/package.json +1 -2
package/lib/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"webpack";import{merge as r}from"webpack-merge";import t from"./build/common.mjs";import i from"./build/server.mjs";import{CONFIG as m}from"./config.mjs";import e from"./module.config.mjs";import s from"./plugin/done.mjs";import{SSR as n}from"./process-env.mjs";import l from"./utils/print.mjs";import p from"./utils/seo.mjs";import a from"./utils/progress.mjs";import f from"chalk";import{empty as u}from"./utils/index.mjs";let{ProgressPlugin:g}=o,c
|
|
1
|
+
import o from"webpack";import{merge as r}from"webpack-merge";import t from"./build/common.mjs";import i from"./build/server.mjs";import{CONFIG as m}from"./config.mjs";import e from"./module.config.mjs";import s from"./plugin/done.mjs";import{SSR as n}from"./process-env.mjs";import l from"./utils/print.mjs";import p from"./utils/seo.mjs";import a from"./utils/progress.mjs";import f from"chalk";import{empty as u}from"./utils/index.mjs";let{ProgressPlugin:g}=o,c=r(t,{module:e(!1),plugins:[m.done&&new s({done:m.done}),!!m.bar&&new g({handler(o,r,...t){let i=m.bar;a({showBar:!0,percentage:o,title:i.name||"Build",color:i.color,info:t.length?`[${r}] ${t.join(" ")}`:"",output:c.output?.path})}})].filter(Boolean)}),h=[c];n&&h.push(r(t,i));let d=o(h);async function w(){await new Promise(o=>{d.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++)l(f.yellowBright(r.compilation.warnings[o].message));for(let o=0,t=r.compilation.errors.length;o<t;o++)l(f.redBright(r.compilation.errors[o].message))}o(r)})}),m.seo&&p()}await w(),process.on("exit",u);
|
package/lib/common.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CONFIG as e,PUBLICPATH as t}from"./config.mjs";import o,{CUSTOMCONFIG as a}from"./paths.mjs";import s from"./plugin/override-resolve.mjs";import n from"./plugins.config.mjs";import{
|
|
1
|
+
import{CONFIG as e,PUBLICPATH as t}from"./config.mjs";import o,{CUSTOMCONFIG as a}from"./paths.mjs";import s from"./plugin/override-resolve.mjs";import n from"./plugins.config.mjs";import{NODE_ENV as i,PACKAGENAME as r,PACKAGEVERSION as l,isDev as m,isLibrary as p}from"./process-env.mjs";import{isObject as c,node_modules as u,resolveProgram as h}from"./utils/index.mjs";import{join as d,resolve as f,extname as g}from"path";import{exampleModuleName as y}from"./vm/example.mjs";import b from"./vm/info.mjs";export const outputConfig={path:h(p?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${m?"name":"contenthash"}].js`,assetModuleFilename:e=>{let t=g(e.filename||"").substring(1);return`assets/${t?`${t}/`:""}[name]${"js"===t?"":"[hash]"}[ext]`},library:{name:`${b.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${r}`,pathinfo:m,clean:!0,publicPath:t,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"],hotUpdateChunkFilename:"[id].[fullhash].hot.js",hotUpdateMainFilename:"[runtime].[fullhash].hot.json"};let j={main:[e.polyfill&&d(o.corePath,"./polyfills/replace-children.mjs"),u("@app/entry")].filter(Boolean)};e.entry&&("string"==typeof e.entry?j={main:[e.entry]}:Object.keys(e.entry)&&(j=Object.assign(j,e.entry))),"string"==typeof j.main&&(j.main=[j.main]),e.output&&("string"==typeof e.output?outputConfig.path=e.output:Object.keys(e.output)&&Object.assign(outputConfig,e.output));let v={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:o.webpackCachePath,memoryCacheUnaffected:!0,name:`.${[a,i].filter(Boolean).join("-")}`,version:`${l}`};!1===e.cache?v=!1:c(e.cache)&&(v=Object.assign(v,e.cache));let C=Object.assign({original:e.alias["@"],override:a&&h(a)},e.overrideResolve);export const commonConfig={name:"client",target:"web",devtool:e.devtool,entry:j,mode:m?"development":"production",stats:"errors-only",cache:v,infrastructureLogging:{level:"error"},performance:e.performance,externalsPresets:e.externalsPresets,plugins:n,node:{global:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:e.lazyCompilation&&m&&{imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(u(y))||t.startsWith(u("@app/comment"))||t.startsWith(o.pagesPath)||t.startsWith(o.componentsPath)))}},buildHttp:c(e.buildHttp)?{allowedUris:[],lockfileLocation:f(o.httpCachePath,"http.lock"),cacheLocation:f(o.httpCachePath,"data"),upgrade:!0,...e.buildHttp}:e.buildHttp,backCompat:!0,futureDefaults:!0,css:!1,outputModule:!1},resolve:{extensions:["...",".jsx",".ts",".tsx"],alias:e.alias,modules:[o.nodeModules,o.pnpmNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:[e.overrideResolve&&new s(C),...e.resolvePlugins].filter(Boolean),fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},externals:e.externals,output:outputConfig};
|
package/lib/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{merge as e}from"webpack-merge";import o from"./options/jsx-dom-expressions.mjs";import t from"./options/split-chunk.mjs";import s from"./paths.mjs";import{APPTYPE as n,FRAMEWORK as i,NODE_ENV as r,PACKAGENAME as
|
|
1
|
+
import{merge as e}from"webpack-merge";import o from"./options/jsx-dom-expressions.mjs";import t from"./options/split-chunk.mjs";import s from"./paths.mjs";import{APPTYPE as n,FRAMEWORK as i,NODE_ENV as r,PACKAGENAME as a,isDev as l,isLibrary as m,isMobile as p,jsxImportSource as u,mainDirectory as c}from"./process-env.mjs";import{isFunction as d,resolveProgram as f}from"./utils/index.mjs";import h from"./utils/setup-env.mjs";import{fileExists as g}from"@moneko/utils";import x from"./utils/require.mjs";let v=["@app","@moneko","neko-ui",".cache/http/data","@ant-design","@element-plus","ant-design-vue","antd","antd-mini","antd-mobile","antd-mobile-icons","element-plus","element-ui","ng-zorro-antd","@antv","@mui","@du","ahooks","rc-queue-anim","umi","@fontsource","@fortawesome","font-pingfang-sc","font-pingfang-tc","katex","react-markdown-editor-lite","react-photo-view","schema-design"],P={devtool:l?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,mode:"csr",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:""},env:await h(r,n,i),basename:"/",publicPath:"/",rem:{designSize:p?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":f(c)},moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{},proxy:{},devServer:{host:"localhost",port:3e3},htmlPluginOption:{},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:t,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:v,js:v,media:v,font:v,wasm:[]},mdx:{jsx:!1,development:l,jsxImportSource:u,providerImportSource:`@moneko/${i}/mdx`},jsxDomExpressions:o,bar:{name:"Client",color:"#6f42c1"},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:{maxAssetSize:256e3,maxEntrypointSize:256e3,assetFilter:e=>!e.endsWith(".map")&&!e.endsWith("ce28377f3a428346.js")},refresh:!0};function j(e){if(g(e)){let o=x(e).default;return d(o)?o(process):o}return{}}m&&(P.alias=Object.assign(P.alias,{"@pkg":s.componentsPath,[a]:s.componentsPath}));let w=P;(!1===(w=e(w,j(s.configPath),j(s.customConfigPath))).devtool||!1===w.sourceMap)&&(w.sourceMap=!1,w.devtool=!1),w.fixBrowserRouter&&w.htmlPluginOption&&(w.htmlPluginOption.tags||(w.htmlPluginOption.tags=[]),w.htmlPluginOption.tags.push({textContent:"(function(l) {if (l.search[1] === '/' ) {var decoded = l.search.slice(1).split('&').map(function(s) {return s.replace(/~and~/g, '&')}).join('?');window.history.replaceState(null, null,l.pathname.slice(0, -1) + decoded + l.hash);}}(window.location))"}));export const CONFIG=w;export const PUBLICPATH=CONFIG.publicPath;
|
package/lib/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e;import t from"express";import o from"https";import
|
|
1
|
+
let e;import t from"express";import o from"https";import r from"multer";import i from"webpack";import s from"webpack-dev-middleware";import l from"webpack-hot-middleware";import{merge as n}from"webpack-merge";import m from"./build/server.mjs";import{commonConfig as a}from"./common.mjs";import{CONFIG as c,PUBLICPATH as p}from"./config.mjs";import{PORT as u,devLog as d}from"./dev/config.mjs";import f from"./dev/mock.mjs";import h from"./dev/proxy.mjs";import g from"./module.config.mjs";import w,{CUSTOMCONFIG as v}from"./paths.mjs";import{SSR as x,isLibrary as $,isReact as j,refresh as k}from"./process-env.mjs";import y from"./utils/has-pkg.mjs";import{empty as b,resolveProgram as P}from"./utils/index.mjs";import S from"./utils/progress.mjs";import C from"./utils/sigint-exit.mjs";import A from"./options/reslove.mjs";import{watchFile as T}from"fs";import{join as B}from"path";import{spawn as M,exec as O}from"child_process";import _ from"./utils/print.mjs";import D from"chalk";import{directoryExists as E,loadFile as I,loadFileSync as U}from"@moneko/utils";let{HotModuleReplacementPlugin:G,ProgressPlugin:H,WatchIgnorePlugin:L}=i,R=y("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,q=y("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,F=j&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,N=["js","jsx","ts","tsx","json","html","vue"],W=N.join(","),X=["css","scss","sass","less","ts","tsx","js","jsx"],z=X.join(","),K=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],J=`${p.endsWith("/")?"":"/"}__hmr__`,Q=new URLSearchParams({name:"client",path:J,dynamicPublicPath:!0,timeout:2e3,reload:!k,quiet:!0,noInfo:!0,overlay:!0}).toString(),V=a.output.path;x&&(V=P(`${$?"docs":"dist"}/client`));let Y=n(a,{entry:{main:[`${A.hotMiddlewareClient}?${Q}`]},output:{path:V},module:g(!1),plugins:[new G,new L({paths:[/\.d\.ts$/]}),F&&new F,q&&new q({fix:!0,threads:!0,files:[`${c.alias["@"]}/**/*.{${W}}`,$&&`${c.alias["@pkg"]}/**/*.{${W}}`].filter(Boolean),extensions:N,exclude:K,cache:!0,cacheLocation:`${w.lineCachePath}/.eslintcache`,lintDirtyModulesOnly:!0,overrideConfigFile:P("eslint.config.mjs"),configType:"flat"}),R&&new R({fix:!0,threads:!0,files:[`${c.alias["@"]}/**/*.{${z}}`,$&&`${c.alias["@pkg"]}/**/*.{${z}}`].filter(Boolean),extensions:X,exclude:K,cache:!0,cacheLocation:`${w.lineCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),!!c.bar&&new H({handler(e,t,...o){let r=c.bar;S({showBar:!0,percentage:e,title:r.name||"Build",color:r.color,info:o.length?`[${t}] ${o.join(" ")}`:"",output:Y.output?.path})}})].filter(Boolean)}),Z=[Y];x&&Z.push(n(a,m));let ee=i(Z);ee.compilers[0].hooks.done.tap("client-log",e=>{d(null,e)});let et=t(),eo=r(),er=s(ee,{writeToDisk:!1,index:"index.html",headers:e=>({"Access-Control-Allow-Origin":e.headers.origin||"*","Access-Control-Allow-Credentials":"true","Access-Control-Allow-Headers":"DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization","Access-Control-Allow-Methods":"GET, POST, OPTIONS, DELETE, PATCH, PUT",...c.devServer.headers}),serverSideRender:x,lastModified:!0,publicPath:Y.output?.publicPath}),ei=l(ee,{log:!1,path:J,heartbeat:2e3});et.use(t.static(B(w.programPath,"./public"))).use(er).use(ei),E(w.mockPath)&&et.use(f(w.mockPath)),c.proxy&&h(et,c.proxy);let es=`${Y.output.path}/index.html`;if(et.all("/*foo",eo.any(),function(e,t,o){if("GET"!==e.method)return o();{let r=e.get("Accept");if(r?.includes("text/html")){let e=er.context.outputFileSystem,o=e?.readFileSync?.(es);t.end(o)}else if("text/event-stream"===r&&e.url.endsWith(J))return e.url=J,ei(e,t,o);else return o()}}),c.devServer.https){let[t,r]=await Promise.all([I(c.devServer.https.key),I(c.devServer.https.cert)]);t||(_(D.redBright(`无法加载私钥。请检查路径和文件是否存在,并确保路径正确:${c.devServer.https.key}`)),process.exit(1)),r||(_(D.redBright(`无法加载证书。请检查路径和文件是否存在,并确保路径正确:${c.devServer.https.cert}`)),process.exit(1)),e=o.createServer({key:t,cert:r},et)}let el=(e||et).listen(u,"0.0.0.0",()=>{});function en(){process.exit(0)}function em(e,t){let o=U(e);t&&null!==o&&T(e,async function(){let r=U(e);o.trim().replace(/^\s*[\r\n]/gm,"")!==r?.trim().replace(/^\s*[\r\n]/gm,"")?(_(D.yellow(`检测到工程配置${D.blue(`[${t}]`)}变更, 程序即将重启...`)),O("win32"===process.platform?`netstat -ano | findstr :${u}`:`lsof -i :${u}`,(e,t)=>{let o=ea?t.split(/\s+/).pop():t.split("\n")[1]?.split(/\s+/)[1];o?process.kill(Number(o),"SIGHUP"):_(`未找到占用端口 ${u} 的进程`)})):_(D.gray(`未变更`))})}em(w.configPath,"index"),em(w.customConfigPath,v);let ea="win32"===process.platform;process.on("SIGHUP",function(){er.close(b),el.close(b),el.closeAllConnections(),function(){let e=M(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",en)}()}),process.on("exit",function(){er.close(b),el.close(b),el.closeAllConnections()}),C(en);
|
package/lib/loader/ts-doc.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return i}});const e=require("fs"),t=s(require("../utils/log.mjs")),r=s(require("../utils/parse-module-meta.mjs"));function s(e){return e&&e.__esModule?e:{default:e}}const u={};function i(s){let i=this.resourcePath,{comment:n,generateDoc:a,getCommentPath:l}=this.getOptions();try{let t=(0,e.statSync)(i).mtime.getTime();if(u[i]!==t){Object.assign(u,{[i]:t});let{file:e,pkg:o,meta:c}=(0,r.default)(l(i));n.setData(e,a(s,i)),n.setData(o,c)}}catch(e){(0,t.default)(e)}return s}
|
package/lib/paths.d.mts
CHANGED
package/lib/paths.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"url";import{dirname as o,resolve as t}from"path";let a=JSON.parse(process.env.npm_config_argv||'{"original":[]}').original;export const __filename=e.fileURLToPath(import.meta.url);export const __dirname=o(__filename);export const yarnArgv={};for(let e=0,o=a.length;e<o;e++){let o=a[e].split("=");Object.assign(yarnArgv,{[o[0]]:o[1]||!0})}export const CUSTOMCONFIG=process.env.npm_config_config||yarnArgv.config;let c=process.cwd(),n=t(c,"./node_modules"),r={__dirname,__filename,nodeModules:n,pnpmNodeModules:t(n,"./.pnpm/node_modules"),corePath:e.fileURLToPath(new URL(".",import.meta.url)),programPath:c,webpackCachePath:t(n,"./.
|
|
1
|
+
import e from"url";import{dirname as o,resolve as t}from"path";let a=JSON.parse(process.env.npm_config_argv||'{"original":[]}').original;export const __filename=e.fileURLToPath(import.meta.url);export const __dirname=o(__filename);export const yarnArgv={};for(let e=0,o=a.length;e<o;e++){let o=a[e].split("=");Object.assign(yarnArgv,{[o[0]]:o[1]||!0})}export const CUSTOMCONFIG=process.env.npm_config_config||yarnArgv.config;let c=process.cwd(),n=t(c,"./node_modules"),r={__dirname,__filename,nodeModules:n,pnpmNodeModules:t(n,"./.pnpm/node_modules"),corePath:e.fileURLToPath(new URL(".",import.meta.url)),programPath:c,webpackCachePath:t(n,"./.cache"),lineCachePath:t(n,"./.cache"),httpCachePath:t(n,"./.cache/http"),swcCachePath:t(n,"./.cache/.swc"),configPath:t(c,"./config/index.ts"),customConfigPath:t(c,`./config/${CUSTOMCONFIG}.ts`),coveragePath:t(c,"./coverage/clover.xml"),pagesPath:t(c,"./src/pages"),componentsPath:t(c,"./components"),mockPath:t(c,"./mock")};export const routeDir="library"===process.env.APPTYPE?r.componentsPath:r.pagesPath;export default r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"webpack-virtual-modules";import{isLibrary as o}from"../process-env.mjs";import{node_modules as i}from"../utils/index.mjs";import{comment as
|
|
1
|
+
import t from"webpack-virtual-modules";import{isLibrary as o}from"../process-env.mjs";import{node_modules as i}from"../utils/index.mjs";import e from"../utils/parse-module-meta.mjs";import{comment as s,docs as r}from"../vm/docs.mjs";import{examples as l}from"../vm/example.mjs";import{locales as m}from"../vm/locales.mjs";import p from"../vm/modules.mjs";import{route as n}from"../vm/routes.mjs";import a from"../paths.mjs";let f={};for(let t in p)if(Object.prototype.hasOwnProperty.call(p,t)){let{file:o,pkg:i,meta:s}=e(t);f[i]=s,f[o]=p[t]}export class VirtualModuleWebpackPlugin{constructor(o={}){this.virtualModules=new t(f),this.options={},this.init=!1;let i={};for(let t in o)if(Object.prototype.hasOwnProperty.call(o,t)){let{file:s,pkg:r,meta:l}=e(t),m=o[t],p=m;p=s.endsWith("json")?"string"==typeof m?m:JSON.stringify(m):"string"==typeof m?m:`export default ${JSON.stringify(m)}`,Object.assign(i,{[s]:p,[r]:l})}this.options=i}modify(t,o,e){let s=e||"",r=o.startsWith(a.nodeModules)?o:i(o),l=t;for(;l&&l._inputFileSystem;)l=l._inputFileSystem;let m=l?._virtualFiles?.[r];m&&m.contents===s||this.virtualModules.writeModule(r,s)}apply(t){this.virtualModules.apply(t);let i=(o,i)=>{this.modify(t.inputFileSystem,o,i)};n.on("change",i),m.on("change",i),o&&(l.on("change",i),r.on("change",i),s.on("change",i)),t.hooks.beforeCompile.tap("VirtualModuleWebpackPlugin",()=>{if(!this.init){for(let t in this.init=!0,this.options)Object.prototype.hasOwnProperty.call(this.options,t)&&i(t,this.options[t]);for(let t of l)i(t[0],t[1]);for(let t of r)i(t[0],t[1]);for(let t of s)i(t[0],t[1])}})}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve as e}from"path";import n from"../paths.mjs";export default function(t,a=1){let i=t.replace(/^\/|\/$/g,""),o=i,m="index.ts",d=i.match(/(.+)\/index\.([^/]+)$/),r=i.match(/(.+)\.([^/]+)$/);return d?(o=d[1],m=`index.${d[2]}`):r&&(o=r[1],m=`index.${r[2]}`),{name:o,main:m,pkg:e(n.nodeModules,o,"package.json"),file:e(n.nodeModules,o,m),meta:`{"name":"${o}","main":"${m}","version":"0.0.${a}","description": ""}`}}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare function setupEnv(mode: string, type: string, framework: string): Promise<{
|
|
2
|
+
NODE_ENV: string;
|
|
3
|
+
APPTYPE: string;
|
|
4
|
+
FRAMEWORK: string;
|
|
5
|
+
}>;
|
|
3
6
|
export default setupEnv;
|
package/lib/utils/setup-env.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{loadFile as e}from"@moneko/utils";async function t(t,r,n){let i=[".env",".env/.env",`.env/.${"production"===t?"prod":"dev"}.env`],o={NODE_ENV:t,APPTYPE:r,FRAMEWORK:n};return(await Promise.all(i.map(e))).forEach(e=>{e&&Object.assign(o,e.split("\n").reduce((e,t)=>{if(!t||t.trim().startsWith("#"))return e;let[r,...n]=t.split("=");if(!r)return e;let i=n.join("=").trim();return e[r.trim()]=i.replace(/^["']|["']$/g,""),e},{}))}),Object.keys(o).forEach(e=>{let t=o[e];process.env[e]!==t&&(process.env[e]=o[e])}),o}export default t;
|
package/lib/vm/docs.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import ReactiveObject from '../utils/reactive-object.mjs';
|
|
2
|
-
export declare const docsModuleName
|
|
2
|
+
export declare const docsModuleName: string;
|
|
3
|
+
export declare const docsModulePkgJson: string;
|
|
4
|
+
export declare const docsModuleMeta: string;
|
|
3
5
|
export declare const docs: ReactiveObject<Record<string, string>>;
|
|
4
6
|
export declare const comment: ReactiveObject<Record<string, string>>;
|
|
5
7
|
export declare const getCommentPath: (file: string) => string;
|
package/lib/vm/docs.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"./generate-doc.mjs";import{CONFIG as t}from"../config.mjs";import{FRAMEWORK as o,isLibrary as
|
|
1
|
+
import e from"./generate-doc.mjs";import{CONFIG as t}from"../config.mjs";import{FRAMEWORK as o,isLibrary as r,isReact as a,isSolid as n}from"../process-env.mjs";import m from"../utils/reactive-object.mjs";import s from"../rule.mjs";import{loadFile as l,scanFolderSync as p}from"@moneko/utils";import c from"../utils/parse-module-meta.mjs";let i={react:"createElement",solid:"createComponent"}[o],{file:d,pkg:f,meta:u}=c("@app/docs");export const docsModuleName=d;export const docsModulePkgJson=f;export const docsModuleMeta=u;export const docs=new m({[d]:"export default {}",[f]:u});export const comment=new m({});export const getCommentPath=function(){let e=/^\/?(.+?)\.tsx?$/,o=t.alias["@pkg"]?.length;return t=>t.substring(o).replace(e,"@app/comment/$1.md")}();if(r&&!1!==t.htmlPluginOption){let r={},m=`import { ${i}${n?",Dynamic":""} } from "${{react:"react",solid:"solid-js"}[o]}${n?"/web":""}";import SuspenseComp from "@app/suspense";function call_then(res) {return {default: ${a?"() =>":""}${i}(${n?"Dynamic":"'div'"}, {${n?"innerHTML: res.default, component: 'div', class: 'n-md-box' ":"dangerouslySetInnerHTML: {__html:res.default}, className: 'n-md-box'"} })};}`,f=(e,t)=>{let o=e.replace(/^@app\/comment\//,"").split("/"),a=o.pop(),n=o.join("/");r[n]||(r[n]={}),t?r[n][a]&&delete r[n][a]:r[n][a]=`rr(() => ${i}(SuspenseComp, { comp: () => import(/* webpackChunkName: '${e}' */ '${e}?raw').then(call_then)}))rr`;let l={};for(let e in r)Object.prototype.hasOwnProperty.call(r,e)&&(l[e]=Object.values(r[e]));docs.setData(d,`${m}export default ${JSON.stringify(l).replace(s.extract_func,"$1")}`)};comment.on("change",(e,t)=>{f(e,t?.length<0)});let u=p(t.alias["@pkg"],["\\.tsx?$"]).filter(e=>!/(^|\/)\.[^\\/\\.]|\.test\./i.test(e));await Promise.all(u.map(async e=>({data:await l(e),file:e}))).then(t=>{for(let o=0;o<t.length;o++){let r=t[o];if(r.data){let{file:t,pkg:o,meta:a}=c(getCommentPath(r.file));comment.setData(t,e(r.data,r.file)),comment.setData(o,a)}}})}
|
package/lib/vm/example.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{generateExample as e}from"@moneko/mdx";import{watchFiles as t}from"./utils.mjs";import o from"../paths.mjs";import{isDev as r,isLibrary as m}from"../process-env.mjs";import p from"../utils/reactive-object.mjs";import
|
|
1
|
+
import{generateExample as e}from"@moneko/mdx";import{watchFiles as t}from"./utils.mjs";import o from"../paths.mjs";import{isDev as r,isLibrary as m}from"../process-env.mjs";import p from"../utils/reactive-object.mjs";import l from"../rule.mjs";import{CONFIG as a}from"../config.mjs";import n from"../utils/parse-module-meta.mjs";export const exampleModuleName="@app/example";function s(){if(!m||!1===a.htmlPluginOption)return{};let t=JSON.parse(e(o.componentsPath,`${exampleModuleName}/`)),r={};for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&Object.assign(r,{[e]:`rr(() => import('${e}'))rr`});let p={...t,[exampleModuleName]:`export default ${JSON.stringify(r).replace(l.extract_func,"$1")}`},s={};for(let e in p)if(Object.prototype.hasOwnProperty.call(p,e)){let{file:t,pkg:o,meta:r}=n(e);s[o]=r,s[t]=p[e]}return s}export const examples=new p(s());export function generatorExample(){let e=s();for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&examples.setData(t,e[t])}m&&r&&!1!==a.htmlPluginOption&&t(o.componentsPath,/(?<!\/examples\/(.+)\.md)$/,generatorExample);
|
package/lib/vm/locales.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ReactiveObject from '../utils/reactive-object.mjs';
|
|
2
|
-
export declare const localesModuleName
|
|
2
|
+
export declare const localesModuleName: string;
|
|
3
3
|
export declare const locales: ReactiveObject<{
|
|
4
|
-
|
|
4
|
+
[x: string]: string;
|
|
5
5
|
}>;
|
package/lib/vm/locales.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{basename as e,join as t}from"path";import{watch as o}from"chokidar";import{CONFIG as a}from"../config.mjs";import{FRAMEWORK as l,isDev as r}from"../process-env.mjs";import n from"../utils/reactive-object.mjs";import s from"../utils/sigint-exit.mjs";import{directoryExists as c,scanFolderSync as i}from"@moneko/utils";import g from"../utils/require.mjs";let
|
|
2
|
-
export function template(r,n){return r.replace(/\\\${\\w+}/g,function(r){var t=r.slice(2,-1);var e=n[t];return e!==void 0?e.toString():""})}function deepFreeze(o) { const p = Reflect.ownKeys(o);for (const k of p) {const v = o[k];if ((v && typeof v === "object") || typeof v === "function") {deepFreeze(v);}}return Object.freeze(o);}export const locales = ${JSON.stringify(e)};const _res = ${JSON.stringify(t)};const resources = deepFreeze(_res);${
|
|
1
|
+
import{basename as e,join as t}from"path";import{watch as o}from"chokidar";import{CONFIG as a}from"../config.mjs";import{FRAMEWORK as l,isDev as r}from"../process-env.mjs";import n from"../utils/reactive-object.mjs";import s from"../utils/sigint-exit.mjs";import{directoryExists as c,scanFolderSync as i}from"@moneko/utils";import g from"../utils/require.mjs";import u from"../utils/parse-module-meta.mjs";let f={react:'import sso from "shared-store-object";',solid:'import { createEffect, createRoot, getOwner } from "solid-js";import { createStore } from "solid-js/store";'},p={react:'let storageKey="localizable.language",language=localStorage.getItem(storageKey)||"zh_CN",{translation:a,...defaultLocale}=Object.assign({title:"简体中文",language:"zh_CN",translation:{}},resources[language]||resources.zh_CN),localizable=sso({lang:defaultLocale,t:a});export function setLang(a){let{translation:e,...l}=resources[a]||{};e&&(localizable.lang=l,localizable.t=e,localStorage.setItem(storageKey,l.language))}export default localizable;',solid:'let locale=createRoot(()=>{let e="localizable.language",a=localStorage.getItem(e)||"zh_CN",{translation:l,...o}=Object.assign({title:"简体中文",language:"zh_CN",translation:{}},resources[a]||resources.zh_CN),[n,c]=createStore({lang:o,t:l});return createEffect(()=>{let a=resources[n.lang.language]?.translation;a&&(c("t",a),localStorage.setItem(e,n.lang.language))}),{localizable:n,setLocalizable:c,setLang:function(e){let{translation:a,...l}=resources[e]||{};a&&c("lang",l)}}},getOwner());export const setLocalizable=locale.setLocalizable;export const t=locale.localizable.t;export const lang=locale.localizable.lang;export const setLang=locale.setLang;'}[l];function m(e,t){return`${f[l]}
|
|
2
|
+
export function template(r,n){return r.replace(/\\\${\\w+}/g,function(r){var t=r.slice(2,-1);var e=n[t];return e!==void 0?e.toString():""})}function deepFreeze(o) { const p = Reflect.ownKeys(o);for (const k of p) {const v = o[k];if ((v && typeof v === "object") || typeof v === "function") {deepFreeze(v);}}return Object.freeze(o);}export const locales = ${JSON.stringify(e)};const _res = ${JSON.stringify(t)};const resources = deepFreeze(_res);${p}`}let{file:d,pkg:z,meta:b}=u("@app/locales");export const localesModuleName=d;export const locales=new n({[d]:m([],{}),[z]:b});let h={};async function j(t,o){let a=e(t).replace(/\.[^.]+$/,"");"deleted"===o?delete h[a]:(delete g.cache[t],Object.assign(h,{[a]:g(t).default}));let l=[],r={};for(let e in h)if(Object.prototype.hasOwnProperty.call(h,e)){let{language:t=a,title:o=t,icon:n,translation:s={}}=h[e];l.push({language:t,title:o,icon:n}),r[t]={language:t,title:o,icon:n,translation:s}}locales.setData(d,m(l,r)),locales.setData(z,b)}let y=t(a.alias["@"],"./locales");if(c(y)&&!1!==a.htmlPluginOption){let e=i(y,[".ts$"]).filter(e=>!/^\..*|\.d\.ts$/.test(e));await Promise.all(e.map(e=>j(e,"added"))),r&&function(e,t){let a=o(e,{ignored:t,persistent:!0,ignoreInitial:!0});function l(){a.unwatch(e),a.close()}a.on("add",e=>{j(e,"added")}),a.on("change",e=>{j(e,"change")}),a.on("unlink",e=>{j(e,"deleted")}),a.once("ready",()=>{r||l()}),s(l)}(y,[/^\..*/,/!\.ts$/,/\.d\.ts$/])}
|
package/lib/vm/modules.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as t}from"path";import{getAppEntry as
|
|
1
|
+
import{join as t}from"path";import{getAppEntry as p,getAppFallback as e,getAppMdxScope as o,getAppMergeRouter as r,getAppNormalizeCss as m,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as i}from"@moneko/mdx";import l from"./coverage.mjs";import{docs as f,docsModuleName as n}from"./docs.mjs";import d from"./info.mjs";import{locales as u,localesModuleName as x}from"./locales.mjs";import{route as c,routesModuleName as j}from"./routes.mjs";import{CONFIG as g}from"../config.mjs";import v from"../paths.mjs";import{APPTYPE as y,FRAMEWORK as h}from"../process-env.mjs";import{node_modules as k}from"../utils/index.mjs";import{generateDeclaration as O}from"../utils/dts.mjs";import S from"../utils/has-pkg.mjs";import{updateFileSync as b}from"@moneko/utils";import z from"../plugin/module-federation.mjs";import D from"../utils/create-types.mjs";import J from"../rule.mjs";import N from"../utils/parse-module-meta.mjs";let $=S(t(g.alias["@"],"./mdx-scope.tsx"))||S(t(g.alias["@"],"./mdx-scope.ts")),C={"@app/env.ts":`export default ${JSON.stringify(g.env)}`,"@app/info.ts":`export default ${JSON.stringify(d)}`,"@app/entry.ts":p(t(g.alias["@"],"./index.ts"),!!z.length,!!g.rem,!!g.normalizeCss,y,h),"@app/rem":a(g.rem?.designSize||1680),"@app/fallback":e(g.fallbackCompPath),"@app/coverage":l(v.coveragePath),"@app/merge-router":r(),"@app/prefix-router":s(),"@app/normalize/index.css":m(),"@app/suspense/index.tsx":i(y,h),"@app/mdx-scope.tsx":$?o($):"export default {}","@app/routes":c.getData(j),"@app/locales":u.getData(x),"@app/docs":f.getData(n)};b(k("@types/@app/index.d.ts"),["@app/env.ts","@app/info.ts","@app/entry.ts","@app/mdx-scope.tsx"].map(t=>D(t.replace(J.js,""),O(C[t],t))).join("\n")),b(k("@types/@vm/index.d.ts"),Object.keys(g.virtualModule).map(t=>{let p=g.virtualModule[t],{file:e}=N(t);return D(t,O("string"==typeof p?p:`export default ${JSON.stringify(p)}`,e))}).join("\n"));export default C;
|
package/lib/vm/routes.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import ReactiveObject from '../utils/reactive-object.mjs';
|
|
2
|
-
export declare const routesModuleName
|
|
2
|
+
export declare const routesModuleName: string;
|
|
3
|
+
export declare const routesModulePkgJson: string;
|
|
4
|
+
export declare const routesModuleMeta: string;
|
|
3
5
|
export declare const route: ReactiveObject<{
|
|
4
|
-
|
|
6
|
+
[x: string]: string;
|
|
5
7
|
}>;
|
|
6
8
|
export declare function generatorRouter(): void;
|
package/lib/vm/routes.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{generateRouter as o}from"@moneko/mdx";import{watchFiles as t}from"./utils.mjs";import{CONFIG as e}from"../config.mjs";import{routeDir as r}from"../paths.mjs";import{FRAMEWORK as m,isDev as s,isLibrary as
|
|
1
|
+
import{generateRouter as o}from"@moneko/mdx";import{watchFiles as t}from"./utils.mjs";import{CONFIG as e}from"../config.mjs";import{routeDir as r}from"../paths.mjs";import{FRAMEWORK as m,isDev as s,isLibrary as n}from"../process-env.mjs";import p from"../utils/reactive-object.mjs";import u from"../utils/parse-module-meta.mjs";let i=n?"@pkg":"@/pages",{file:a,pkg:l,meta:c}=u("@app/routes");export const routesModuleName=a;export const routesModulePkgJson=l;export const routesModuleMeta=c;function f(){return!1===e.htmlPluginOption?"":o(r,`${e.alias["@"]}/router/index.ts`,m,i,n)}export const route=new p({[a]:f(),[l]:c});export function generatorRouter(){route.setData(a,f())}s&&t(r,n?/(?<!README\.mdx?)$/:/(?<!index\.tsx?)$/,generatorRouter);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.24.
|
|
3
|
+
"version": "3.24.6",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"core-js": "3.39.0",
|
|
26
26
|
"core-js-compat": "3.39.0",
|
|
27
27
|
"css-loader": "7.1.2",
|
|
28
|
-
"dotenv": "16.4.5",
|
|
29
28
|
"express": "5.0.1",
|
|
30
29
|
"html-webpack-plugin": "5.6.3",
|
|
31
30
|
"http-proxy-middleware": "3.0.3",
|