@moneko/core 3.24.5-beta.1 → 3.24.5-beta.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.mjs +1 -1
- package/lib/common.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/vm/docs.mjs +1 -1
- package/lib/vm/example.mjs +1 -1
- package/lib/vm/locales.d.mts +1 -1
- package/lib/vm/locales.mjs +2 -2
- package/lib/vm/modules.mjs +1 -1
- package/lib/vm/routes.d.mts +1 -1
- package/lib/vm/routes.mjs +1 -1
- package/package.json +1 -1
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/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
|
|
1
|
+
import t from"webpack-virtual-modules";import{isLibrary as o}from"../process-env.mjs";import{node_modules as e}from"../utils/index.mjs";import i 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:e,meta:s}=i(t);f[e]=s,f[o]=p[t]}export class VirtualModuleWebpackPlugin{constructor(o={}){this.virtualModules=new t(f),this.options={},this.init=!1;let e={};for(let t in o)if(Object.prototype.hasOwnProperty.call(o,t)){let{file:s,pkg:r,meta:l}=i(t),m=o[t];Object.assign(e,{[s]:"string"==typeof m?m:`export default ${JSON.stringify(m)}`,[r]:l})}this.options=e}modify(t,o,i){let s=i||"",r=o.startsWith(a.nodeModules)?o:e(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 e=(o,e)=>{this.modify(t.inputFileSystem,o,e)};n.on("change",e),m.on("change",e),o&&(l.on("change",e),r.on("change",e),s.on("change",e)),t.hooks.beforeCompile.tap("VirtualModuleWebpackPlugin",()=>{if(!this.init){for(let t in this.init=!0,this.options)Object.prototype.hasOwnProperty.call(this.options,t)&&e(t,this.options[t]);for(let t of l)e(t[0],t[1]);for(let t of r)e(t[0],t[1]);for(let t of s)e(t[0],t[1])}})}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{join as e}from"path";export default function(n,a=1){let i=n.replace(/^\/|\/$/g,""),t=i,m="index.ts",r=i.match(/(.+)\/index\.([^/]+)$/),$=i.match(/(.+)\.([^/]+)$/);return r?(t=r[1],m=`index.${r[2]}`):$&&(t=$[1],m=`index.${$[2]}`),{name:t,main:m,pkg:e(t,"package.json"),file:e(t,m),meta:`{"name":"${t}","main":"${m}","version":"0.0.${a}","description": ""}`}}
|
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 a,isReact as
|
|
1
|
+
import e from"./generate-doc.mjs";import{CONFIG as t}from"../config.mjs";import{FRAMEWORK as o,isLibrary as a,isReact as m,isSolid as r}from"../process-env.mjs";import n from"../utils/reactive-object.mjs";import s from"../rule.mjs";import{loadFile as l,scanFolderSync as c}from"@moneko/utils";import p from"../utils/parse-module-meta.mjs";let i={react:"createElement",solid:"createComponent"}[o];export const docsModuleName="@app/docs";let{file:d,pkg:f,meta:u}=p(docsModuleName);export const docs=new n({[d]:"export default {}",[f]:u});export const comment=new n({});export const getCommentPath=function(){let e=/^\/?(.+?)\.tsx?$/,o=t.alias["@pkg"]?.length;return t=>t.substring(o).replace(e,"@app/comment/$1.md")}();if(a&&!1!==t.htmlPluginOption){let a={},n=`import { ${i}${r?",Dynamic":""} } from "${{react:"react",solid:"solid-js"}[o]}${r?"/web":""}";import SuspenseComp from "@app/suspense";function call_then(res) {return {default: ${m?"() =>":""}${i}(${r?"Dynamic":"'div'"}, {${r?"innerHTML: res.default, component: 'div', class: 'n-md-box' ":"dangerouslySetInnerHTML: {__html:res.default}, className: 'n-md-box'"} })};}`,d=(e,t)=>{let o=e.replace(/^@app\/comment\//,"").split("/"),m=o.pop(),r=o.join("/");a[r]||(a[r]={}),t?a[r][m]&&delete a[r][m]:a[r][m]=`rr(() => ${i}(SuspenseComp, { comp: () => import(/* webpackChunkName: '${e}' */ '${e}?raw').then(call_then)}))rr`;let l={};for(let e in a)Object.prototype.hasOwnProperty.call(a,e)&&(l[e]=Object.values(a[e]));let{file:c,pkg:d,meta:f}=p(docsModuleName);docs.setData(d,f),docs.setData(c,`${n}export default ${JSON.stringify(l).replace(s.extract_func,"$1")}`)};comment.on("change",(e,t)=>{d(e,t?.length<0)});let f=c(t.alias["@pkg"],["\\.tsx?$"]).filter(e=>!/(^|\/)\.[^\\/\\.]|\.test\./i.test(e));await Promise.all(f.map(async e=>({data:await l(e),file:e}))).then(t=>{for(let o=0;o<t.length;o++){let a=t[o];if(a.data){let{file:t,pkg:o,meta:m}=p(getCommentPath(a.file));comment.setData(t,e(a.data,a.file)),comment.setData(o,m)}}})}
|
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
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
|
|
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 s from"../utils/reactive-object.mjs";import n 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";'},m={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 p(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);${m}`}export const localesModuleName="@app/locales";let{file:d,pkg:z,meta:b}=u(localesModuleName);export const locales=new s({[d]:p([],{}),[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:s,translation:n={}}=h[e];l.push({language:t,title:o,icon:s}),r[t]={language:t,title:o,icon:s,translation:n}}let{file:s,pkg:n,meta:c}=u(localesModuleName);locales.setData(s,p(l,r)),locales.setData(n,c)}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()}),n(l)}(y,[/^\..*/,/!\.ts$/,/\.d\.ts$/])}
|
package/lib/vm/modules.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as
|
|
1
|
+
import{join as e}from"path";import{getAppEntry as t,getAppFallback as p,getAppMdxScope as r,getAppMergeRouter as o,getAppNormalizeCss as m,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as i}from"@moneko/mdx";import n from"./coverage.mjs";import{docs as f,docsModuleName as l}from"./docs.mjs";import d from"./info.mjs";import{locales as u,localesModuleName as x}from"./locales.mjs";import{route as j,routesModuleName as c}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";let N=S(e(g.alias["@"],"./mdx-scope.tsx"))||S(e(g.alias["@"],"./mdx-scope.ts")),$={[k("@app/env")]:`export default ${JSON.stringify(g.env)}`,[k("@app/info")]:`export default ${JSON.stringify(d)}`,[k("@app/entry")]:t(e(g.alias["@"],"./index.ts"),!!z.length,!!g.rem,!!g.normalizeCss,y,h),[k("@app/rem")]:a(g.rem?.designSize||1680),[k("@app/fallback")]:p(g.fallbackCompPath),[k("@app/coverage")]:n(v.coveragePath),[k("@app/merge-router")]:o(),[k("@app/prefix-router")]:s(),[k("@app/normalize/index.css")]:m(),[k("@app/suspense/index.tsx")]:i(y,h),[k("@app/mdx-scope/index.tsx")]:N?r(N):"export default {}",[k(c)]:j.getData(c),[k(x)]:u.getData(x),[k(l)]:f.getData(l)};b(k("@types/@app/index.d.ts"),["@app/env.ts","@app/info.ts","@app/entry.ts","@app/mdx-scope.tsx"].map(e=>{let t=k(e);return D(e.replace(J.js,""),O($[t],t))}).join("\n")),b(k("@types/@vm/index.d.ts"),Object.keys(g.virtualModule).map(e=>{let t=g.virtualModule[e];return D(e.replace(J.js,""),O("string"==typeof t?t:`export default ${JSON.stringify(t)}`,k(e)))}).join("\n"));export default $;
|
package/lib/vm/routes.d.mts
CHANGED
package/lib/vm/routes.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{generateRouter as
|
|
1
|
+
import{generateRouter as t}from"@moneko/mdx";import{watchFiles as o}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 u}from"../process-env.mjs";import i from"../utils/reactive-object.mjs";import p from"../utils/parse-module-meta.mjs";let a=u?"@pkg":"@/pages";export const routesModuleName="@app/routes";function n(){return!1===e.htmlPluginOption?"":t(r,`${e.alias["@"]}/router/index.ts`,m,a,u)}let{file:l,pkg:f,meta:c}=p(routesModuleName);export const route=new i({[l]:n(),[f]:c});export function generatorRouter(){let{file:t,pkg:o,meta:e}=p(routesModuleName);route.setData(t,n()),route.setData(o,e)}s&&o(r,u?/(?<!README\.mdx?)$/:/(?<!index\.tsx?)$/,generatorRouter);
|