@moneko/core 3.17.41 → 3.17.43
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/mock.mjs +1 -1
- package/lib/dev.mjs +1 -1
- package/lib/paths.d.mts +0 -1
- package/lib/paths.mjs +1 -1
- package/lib/utils/index.d.mts +2 -1
- package/lib/utils/index.mjs +1 -1
- package/lib/utils/vts.d.mts +6 -0
- package/lib/utils/vts.mjs +1 -0
- package/lib/vm/locales.mjs +2 -2
- package/package.json +4 -4
- package/typings/global.d.ts +5 -0
- package/lib/utils/read-conf.d.mts +0 -2
- package/lib/utils/read-conf.mjs +0 -1
- package/lib/utils/tfc.d.mts +0 -2
- package/lib/utils/tfc.mjs +0 -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
|
|
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/log.mjs";import p from"./utils/seo.mjs";import a from"./utils/progress.mjs";import f from"chalk";import{empty as g}from"./utils/index.mjs";let{ProgressPlugin:u}=o,c=!!m.bar,h=r(t,{module:e(!1),plugins:[m.done&&new s({done:m.done}),new u({handler(o,r,...t){let i=m.bar||{};a({showBar:c,percentage:o,title:i.name||"Build",color:i.color,info:t.length?`[${r}] ${t.join(" ")}`:"",output:h.output?.path})}})].filter(Boolean)}),d=[h];n&&d.push(r(t,i));let j=o(d);async function w(){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++)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",g);
|
package/lib/common.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CONFIG as e,PUBLICPATH as t}from"./config.mjs";import o,{CUSTOMCONFIG as s}from"./paths.mjs";import a from"./plugin/override-resolve.mjs";import n from"./plugins.config.mjs";import{PACKAGENAME as i,PACKAGEVERSION as r,isDev as l,isLibrary as p}from"./process-env.mjs";import{isObject as m,node_modules as c,resolveProgram as u}from"./utils/index.mjs";import{join as h,resolve as d,extname as f}from"path";import{exampleModuleName as g}from"./vm/example.mjs";export const outputConfig={path:u(p?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${l?"name":"contenthash"}].js`,assetModuleFilename:e=>{let t=f(e.filename||"").substring(1);return`assets/${t?`${t}/`:""}[name]${"js"===t?"":"[hash]"}[ext]`},library:{name:`${i}`,type:"umd"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${i}`,pathinfo:l,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 y={main:[e.polyfill&&h(o.corePath,"./polyfills/replace-children.mjs"),c("@app/entry")].filter(Boolean)};e.entry&&("string"==typeof e.entry?y={main:[e.entry]}:Object.keys(e.entry)&&(y=Object.assign(y,e.entry))),"string"==typeof y.main&&(y.main=[y.main]),e.output&&("string"==typeof e.output?outputConfig.path=e.output:Object.keys(e.output)&&Object.assign(outputConfig,e.output));let b=!1;m(e.cache)&&(b=Object.assign({type:"filesystem",
|
|
1
|
+
import{CONFIG as e,PUBLICPATH as t}from"./config.mjs";import o,{CUSTOMCONFIG as s}from"./paths.mjs";import a from"./plugin/override-resolve.mjs";import n from"./plugins.config.mjs";import{PACKAGENAME as i,PACKAGEVERSION as r,isDev as l,isLibrary as p}from"./process-env.mjs";import{isObject as m,node_modules as c,resolveProgram as u}from"./utils/index.mjs";import{join as h,resolve as d,extname as f}from"path";import{exampleModuleName as g}from"./vm/example.mjs";export const outputConfig={path:u(p?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${l?"name":"contenthash"}].js`,assetModuleFilename:e=>{let t=f(e.filename||"").substring(1);return`assets/${t?`${t}/`:""}[name]${"js"===t?"":"[hash]"}[ext]`},library:{name:`${i}`,type:"umd"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${i}`,pathinfo:l,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 y={main:[e.polyfill&&h(o.corePath,"./polyfills/replace-children.mjs"),c("@app/entry")].filter(Boolean)};e.entry&&("string"==typeof e.entry?y={main:[e.entry]}:Object.keys(e.entry)&&(y=Object.assign(y,e.entry))),"string"==typeof y.main&&(y.main=[y.main]),e.output&&("string"==typeof e.output?outputConfig.path=e.output:Object.keys(e.output)&&Object.assign(outputConfig,e.output));let b=!1;m(e.cache)&&(b=Object.assign({type:"filesystem",allowCollectingMemory:!0,cacheDirectory:o.webpackCachePath,memoryCacheUnaffected:!0,name:[s,process.env.NODE_ENV].filter(Boolean).join("-"),version:`${r}`},e.cache));let j=Object.assign({original:e.alias["@"],override:s&&u(s)},e.overrideResolve);export const commonConfig={name:"client",target:"web",devtool:e.devtool,entry:y,mode:l?"development":"production",stats:"errors-only",cache:b,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&&l&&{imports:!0,entries:!0,test:e=>{let t=e.nameForCondition();return!!(t&&(t.startsWith(c(g))||t.startsWith(c("@app/comment"))||t.startsWith(o.pagesPath)||t.startsWith(o.componentsPath)))}},buildHttp:m(e.buildHttp)?{allowedUris:[],lockfileLocation:d(o.httpCachePath,"http.lock"),cacheLocation:d(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 a(j),...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,{CUSTOMCONFIG as i}from"./paths.mjs";import{APPTYPE as n,FRAMEWORK as r,NODE_ENV as a,PACKAGENAME as l,isDev as m,isLibrary as p,isMobile as c,jsxImportSource as u,mainDirectory as d}from"./process-env.mjs";import{isFunction as f,resolveProgram as h}from"./utils/index.mjs";import
|
|
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,{CUSTOMCONFIG as i}from"./paths.mjs";import{APPTYPE as n,FRAMEWORK as r,NODE_ENV as a,PACKAGENAME as l,isDev as m,isLibrary as p,isMobile as c,jsxImportSource as u,mainDirectory as d}from"./process-env.mjs";import{isFunction as f,resolveProgram as h}from"./utils/index.mjs";import x from"./utils/setup-env.mjs";import{fileExists as g}from"@moneko/utils";import{vts as v}from"./utils/vts.mjs";let P=["@moneko","neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app",".cache/http/data"],j={devtool:m?"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:x(a,n,r),basename:"/",publicPath:"auto",rem:{designSize:c?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":h(d)},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:P,js:P,media:P,font:P,wasm:[]},mdx:{jsx:!1,development:m,jsxImportSource:u,providerImportSource:`@moneko/${r}/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(".js")}};async function w(e,o){if(o&&g(e)){let o=v(e);return f(o)?o(process):o}return{}}p&&(j.alias=Object.assign(j.alias,{"@pkg":s.componentsPath,[l]:s.componentsPath}));let k=j;(!1===(k=e(k,await w(s.configPath,"index"),await w(s.customConfigPath,i))).devtool||!1===k.sourceMap)&&(k.sourceMap=!1,k.devtool=!1),k.fixBrowserRouter&&k.htmlPluginOption&&(k.htmlPluginOption.tags||(k.htmlPluginOption.tags=[]),k.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=k;export const PUBLICPATH=CONFIG.publicPath||"auto";
|
package/lib/dev/mock.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"http";import{watch as t}from"chokidar";import o from"express";import{mock as r}from"mock-json-schema";import{merge as a}from"webpack-merge";import s from"../utils/log.mjs";import n from"../utils/match-path.mjs";import{vts as i}from"../utils/vts.mjs";function c(e,t,o){if(o[t]){for(let r in o[t])Object.prototype.hasOwnProperty.call(o[t],r)&&delete e[r];o[t]=null,delete o[t]}}export const yApiSchemaMock=(t,o)=>new Promise((s,n)=>{e.get(`${t.host}/api/interface/get?id=${t.id}&token=${t.token}`,e=>{e.setEncoding("utf8");let t="";e.on("data",e=>{t+=e}),e.on("end",()=>{try{let e=JSON.parse(t);if(e?.data?.res_body_is_json_schema){let t=JSON.parse(e.data.res_body),n=r(t);void 0!==o?s(a(n,o)):s(n)}}catch(e){n(e)}})})});export const yApiMock=(t,o)=>new Promise((r,a)=>{let s=new URL(o.host),n={hostname:s.hostname,port:s.port,path:t.path.replace(new RegExp(o.pathRewrite),`/mock/${o.projectId}/`),method:t.method,headers:t.headers,query:t.query},i=e.request(n,e=>{e.setEncoding("utf8");let t="";e.on("data",e=>{t+=e}),e.on("end",()=>{try{r(JSON.parse(t))}catch(e){a(e)}})});i.on("error",e=>{a(e.message)}),i.write(JSON.stringify(t.body)),i.end()});export default(e=>{let r={},a={};return t(e).on("all",async function(e,t){switch(process.stdout.write("update mock..."),e){case"add":case"change":c(a,t,r),r[t]=i(t),a=Object.assign(a,r[t]);break;case"unlink":c(a,t,r)}s("update mock success")}),function(e,t,r){let s=`${e.method} ${e.path}`,i=Object.keys(a).filter(function(e){return RegExp(`^${e.replace(/(:\w*)[^/]/g,"((?!/).)")}*$`).test(s)});if(!a[s]&&(!i||!(i.length>0)))return r();{let c;let p=e.get("Content-Type");switch(p){case"text/plain":c=o.raw({type:"text/plain"});break;case"text/html":c=o.text({type:"text/html"});break;case"application/x-www-form-urlencoded":c=o.urlencoded({extended:!1});break;default:c=o.json()}p?.startsWith("multipart/form-data;")&&(c=o.static("./public")),c(e,t,function(){let o=a[s]||a[i[0]];if("function"==typeof o){let a=n(i[0].split(" ")[1],e.url);a&&Object.assign(e.params,a.params),o(e,t,r)}else t.json(o)})}}});
|
package/lib/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"express";import t from"multer";import o from"webpack";import i from"webpack-dev-middleware";import s from"webpack-hot-middleware";import{merge as l}from"webpack-merge";import r from"./build/server.mjs";import{commonConfig as n}from"./common.mjs";import{CONFIG as m,PUBLICPATH as a}from"./config.mjs";import{PORT as c,devLog as p,headers as u}from"./dev/config.mjs";import f from"./dev/mock.mjs";import d from"./dev/proxy.mjs";import h from"./module.config.mjs";import g,{CUSTOMCONFIG as w}from"./paths.mjs";import{SSR as x,isLibrary as j,isReact as $}from"./process-env.mjs";import k from"./utils/has-pkg.mjs";import{empty as y,resolveProgram as b}from"./utils/index.mjs";import
|
|
1
|
+
import e from"express";import t from"multer";import o from"webpack";import i from"webpack-dev-middleware";import s from"webpack-hot-middleware";import{merge as l}from"webpack-merge";import r from"./build/server.mjs";import{commonConfig as n}from"./common.mjs";import{CONFIG as m,PUBLICPATH as a}from"./config.mjs";import{PORT as c,devLog as p,headers as u}from"./dev/config.mjs";import f from"./dev/mock.mjs";import d from"./dev/proxy.mjs";import h from"./module.config.mjs";import g,{CUSTOMCONFIG as w}from"./paths.mjs";import{SSR as x,isLibrary as j,isReact as $}from"./process-env.mjs";import k from"./utils/has-pkg.mjs";import{empty as y,resolveProgram as b}from"./utils/index.mjs";import v from"./utils/progress.mjs";import A from"./utils/sigint-exit.mjs";import C from"./options/reslove.mjs";import{watchFile as P}from"fs";import{spawn as T,exec as S}from"child_process";import M from"./utils/log.mjs";import O from"chalk";import{directoryExists as _,loadFileSync as D}from"@moneko/utils";let{HotModuleReplacementPlugin:E,ProgressPlugin:I,WatchIgnorePlugin:U}=o,B=k("stylelint-webpack-plugin")&&(await import("stylelint-webpack-plugin")).default,G=k("eslint-webpack-plugin")&&(await import("eslint-webpack-plugin")).default,H=$&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,L=["js","jsx","ts","tsx","json","html","vue"],R=L.join(","),q=["css","scss","sass","less","ts","tsx","js","jsx"],N=q.join(","),W=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],F=k("solid-refresh")||k("react-refresh"),X=`${a.endsWith("/")?"":"/"}__hmr__`,z=new URLSearchParams({name:"client",path:X,dynamicPublicPath:!0,timeout:2e3,reload:!F,quiet:!0,noInfo:!0,overlay:!0}).toString(),K=n.output.path;x&&(K=b(`${j?"docs":"dist"}/client`));let J=!!m.bar,Q=l(n,{entry:{main:[`${C.hotMiddlewareClient}?${z}`]},output:{path:K},module:h(!1),plugins:[new E,new U({paths:[/\.d\.ts$/]}),H&&new H,G&&new G({fix:!0,threads:!0,files:[`${m.alias["@"]}/**/*.{${R}}`,j&&`${m.alias["@pkg"]}/**/*.{${R}}`].filter(Boolean),extensions:L,exclude:W,cache:!0,cacheLocation:`${g.lineCachePath}/.eslintcache`,lintDirtyModulesOnly:!0}),B&&new B({fix:!0,threads:!0,files:[`${m.alias["@"]}/**/*.{${N}}`,j&&`${m.alias["@pkg"]}/**/*.{${N}}`].filter(Boolean),extensions:q,exclude:W,cache:!0,cacheLocation:`${g.lineCachePath}/.stylelintcache`,lintDirtyModulesOnly:!0}),new I({handler(e,t,...o){let i=m.bar||{};v({showBar:J,percentage:e,title:i.name||"Build",color:i.color,info:o.length?`[${t}] ${o.join(" ")}`:"",output:Q.output?.path})}})].filter(Boolean)}),V=[Q];x&&V.push(l(n,r));let Y=o(V);Y.compilers[0].hooks.done.tap("client-log",e=>{p(null,e)});let Z=e(),ee=t(),et=i(Y,{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",...u}),serverSideRender:x,lastModified:!0}),eo=s(Y,{log:!1,path:X,heartbeat:2e3});if(Z.use(et),Z.use(eo),Z.use(e.static(Q.output.path)),m.proxy&&d(Z,m.proxy),_(g.mockPath)){let e=f(g.mockPath);Z.use(e)}let ei=`${Q.output.path}/index.html`;Z.all("/*",ee.any(),function(e,t,o){if("GET"!==e.method)return o();{let i=e.get("Accept");if(i?.includes("text/html")){let e=et.context.outputFileSystem,o=e?.readFileSync?.(ei);t.end(o)}else if("text/event-stream"===i&&e.url.endsWith(X))return e.url=X,eo(e,t,o);else return o()}});let es=Z.listen(c,()=>{});function el(){process.exit(0)}function er(e,t){let o=D(e);t&&null!==o&&P(e,async function(){let i=D(e);o.trim().replace(/^\s*[\r\n]/gm,"")!==i?.trim().replace(/^\s*[\r\n]/gm,"")?(M(O.yellow(`检测到工程配置${O.blue(`[${t}]`)}变更, 程序即将重启...`)),S("win32"===process.platform?`netstat -ano | findstr :${c}`:`lsof -i :${c}`,(e,t,o)=>{let i=en?t.split(/\s+/).pop():t.split("\n")[1]?.split(/\s+/)[1];i?process.kill(Number(i),"SIGHUP"):M(`未找到占用端口 ${c} 的进程`)})):M(O.gray(`未变更`))})}er(g.configPath,"index"),er(g.customConfigPath,w);let en="win32"===process.platform;process.on("SIGHUP",function(){et.close(y),es.close(y),es.closeAllConnections(),function(){let e=T(process.argv[0],process.argv.slice(1),{detached:!1,stdio:"inherit"});e.unref(),e.on("close",el)}()}),process.on("exit",function(){et.close(y),es.close(y),es.closeAllConnections()}),A(el);
|
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,"./.temp_cache"),lineCachePath:t(n,"./.cache"),
|
|
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,"./.temp_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"),vfsDtsPath:t(n,"./@app")};export const routeDir="library"===process.env.APPTYPE?r.componentsPath:r.pagesPath;export default r;
|
package/lib/utils/index.d.mts
CHANGED
|
@@ -12,6 +12,7 @@ export declare function resolveProgram<T extends string>(src: T): ProgramPath<T>
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function node_modules<T extends string>(name: T): `node_modules/${T}`;
|
|
14
14
|
export declare function isObject(target: unknown): target is object;
|
|
15
|
-
|
|
15
|
+
type AnyFunction = (...a: any[]) => any;
|
|
16
|
+
export declare function isFunction<T>(target: T): target is T & AnyFunction;
|
|
16
17
|
export declare function empty(): void;
|
|
17
18
|
export {};
|
package/lib/utils/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolve as t}from"path";import e from"../paths.mjs";export function toCamelCase(t){return t.replace(/-./g,t=>t.charAt(1).toUpperCase())}export function toUpperCaseString(t){return t?.replaceAll(/\b\w/g,t=>t.toUpperCase()).replaceAll(/\./g," ")}export function resolveProgram(o){return t(e.programPath,`./${o}`)}export function node_modules(o){return t(e.nodeModules,`./${o}`)}export function isObject(t){let e=typeof t;return null!==t&&("object"===e||"function"===e)}export function isFunction(t){
|
|
1
|
+
import{resolve as t}from"path";import e from"../paths.mjs";export function toCamelCase(t){return t.replace(/-./g,t=>t.charAt(1).toUpperCase())}export function toUpperCaseString(t){return t?.replaceAll(/\b\w/g,t=>t.toUpperCase()).replaceAll(/\./g," ")}export function resolveProgram(o){return t(e.programPath,`./${o}`)}export function node_modules(o){return t(e.nodeModules,`./${o}`)}export function isObject(t){let e=typeof t;return null!==t&&("object"===e||"function"===e)}export function isFunction(t){return["[object Function]","[object AsyncFunction]","[object GeneratorFunction]","[object Proxy]"].includes(Object.prototype.toString.call(t))}export function empty(){}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{transformFileSync as e}from"@swc/core";import{Script as t,createContext as o}from"vm";let r={inputSourceMap:!1,sourceMaps:!1,module:{type:"commonjs"},jsc:{target:"es2015",parser:{syntax:"typescript"},loose:!1}};export function vts(s,p=!1){let n=new t(e(s,r).code),u={exports:{default:null}};return(o(u),n.runInContext(u),p)?u.exports:u.exports.default}
|
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/
|
|
2
|
-
export function interpolateString(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{vts as g}from"../utils/vts.mjs";let u={react:'import sso from "shared-store-object";',solid:'import { createEffect, createRoot, getOwner } from "solid-js";import { createStore } from "solid-js/store";'},f={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`${u[l]}
|
|
2
|
+
export function interpolateString(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);${f}`}export const localesModuleName="@app/locales";export const locales=new n({[localesModuleName]:p([],{})});let m={};async function d(t,o){let a=e(t).replace(/\.[^.]+$/,"");"deleted"===o?delete m[a]:Object.assign(m,{[a]:g(t)});let l=[],r={};for(let e in m)if(Object.prototype.hasOwnProperty.call(m,e)){let{language:t=a,title:o=t,icon:n,translation:s={}}=m[e];l.push({language:t,title:o,icon:n}),r[t]={language:t,title:o,icon:n,translation:s}}locales.setData(localesModuleName,p(l,r))}let z=t(a.alias["@"],"./locales");if(c(z)&&!1!==a.htmlPluginOption){let e=i(z,[".ts$"]).filter(e=>!/^\..*|\.d\.ts$/.test(e));await Promise.all(e.map(e=>d(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=>{d(e,"added")}),a.on("change",e=>{d(e,"change")}),a.on("unlink",e=>{d(e,"deleted")}),a.once("ready",()=>{r||l()}),s(l)}(z,[/^\..*/,/!\.ts$/,/\.d\.ts$/])}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.17.
|
|
3
|
+
"version": "3.17.43",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@babel/core": "7.24.7",
|
|
15
15
|
"@moneko/mdx": "0.1.39",
|
|
16
|
-
"@moneko/transform-imports": "0.
|
|
17
|
-
"@moneko/utils": "0.1.
|
|
18
|
-
"@swc/core": "1.
|
|
16
|
+
"@moneko/transform-imports": "0.6.0",
|
|
17
|
+
"@moneko/utils": "0.1.5",
|
|
18
|
+
"@swc/core": "1.6.1",
|
|
19
19
|
"@typescript/vfs": "1.5.3",
|
|
20
20
|
"browserslist": "4.23.1",
|
|
21
21
|
"chalk": "5.3.0",
|
package/typings/global.d.ts
CHANGED
|
@@ -372,6 +372,11 @@ export declare type ConfigType = {
|
|
|
372
372
|
* @default false
|
|
373
373
|
*/
|
|
374
374
|
lazyCompilation?: boolean;
|
|
375
|
+
/**
|
|
376
|
+
* 展示性能提示
|
|
377
|
+
* @description 资源(asset)和入口起点超过指定文件限制
|
|
378
|
+
*/
|
|
379
|
+
performance?: Configuration['performance'];
|
|
375
380
|
};
|
|
376
381
|
/**
|
|
377
382
|
* 用于构建 http 资源的选项
|
package/lib/utils/read-conf.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{updateFileSync as t}from"@moneko/utils";import m from"./tfc.mjs";import o from"../paths.mjs";async function r(r,e){let f=`${o.cachePath}/${e}.mjs`;return t(f,m(r)),import(f)}export default r;
|
package/lib/utils/tfc.d.mts
DELETED
package/lib/utils/tfc.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{transformFileSync as e}from"@swc/core";let o={inputSourceMap:!1,sourceMaps:!1,module:{type:"es6"},jsc:{parser:{syntax:"typescript"},loose:!1}};export default function(r){return e(r,o).code||"{}"}
|