@moneko/core 4.0.4 → 4.0.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/bin/pin.mjs +1 -1
- package/lib/bin/tsc.mjs +1 -1
- package/lib/build-dev.mjs +2 -2
- package/lib/build.mjs +2 -2
- package/lib/commom/package-manager.d.mts +8 -0
- package/lib/commom/package-manager.mjs +1 -0
- package/lib/common.mjs +1 -1
- package/lib/config.mjs +1 -1
- package/lib/dev/config.mjs +2 -2
- package/lib/process-env.d.mts +3 -1
- package/lib/process-env.mjs +1 -1
- package/lib/utils/index.mjs +1 -1
- package/lib/vm/app.mjs +1 -1
- package/lib/vm/dts.d.mts +5 -0
- package/lib/vm/dts.mjs +1 -0
- package/lib/vm/virtual.mjs +1 -1
- package/package.json +1 -1
- package/lib/vm/info.d.mts +0 -12
- package/lib/vm/info.mjs +0 -1
package/lib/bin/pin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawn as e}from"node:child_process";import{relative as t}from"node:path";import{
|
|
1
|
+
import{spawn as e}from"node:child_process";import{relative as t}from"node:path";import{ink as a,println as n,progressBar as o,updateFile as r}from"@moneko/utils";import{getPackageManager as l}from"../commom/package-manager.mjs";import s from"../commom/parse-args.mjs";import m from"../commom/paths.mjs";import{readJson as i}from"../commom/read-json.mjs";import c from"../commom/require.mjs";let p=c.resolve(`${m.programPath}/package.json`);async function d(t){return new Promise(a=>{let n=e("npm",["view",t,"version"],{shell:!0}),o="";n.stdout.on("data",e=>{o+=e}),n.stderr.on("data",e=>{let t=e.toString().split("\n").filter(e=>e.includes("GET http")).map(e=>e.split(" - ")[0].trim());t.length&&(o+=`Err: ${t[0]}`.trim())}),n.on("close",async()=>{a(o.trim())})})}async function u(e,t){let a={...e};return o(t.done.length,t.total,{name:"Checking"}),await Promise.allSettled(Object.keys(a).map(async e=>{let n=await d(e);t.done.includes(e)||t.done.push(e),o(t.done.length,t.total,{name:"Checking",msg:`${t.done.length} / ${t.total}`}),a[e]=n})),a}let h={major:"red",minor:"yellow",patch:"cyan",equal:"white"};async function g(e,t,a,n){if(e[t]){var o;let r=await u(e[t],n),l=(o=e[t],Object.keys(r).filter(e=>{let t=$(o[e]);return o[e]!==`${t[0]}${r[e]}`}).map(e=>{var t,a;let n,l,s=$(o[e]),m=r[e].includes("Err:"),i=m?"red":h[t=s[1],a=r[e],n=t.split("."),l=a.split("."),n[0]!==l[0]?"major":n[1]!==l[1]?"minor":n[2]!==l[2]?"patch":"equal"];return{name:e,wanted:o[e],latest:`${s[0]}${r[e].replace("Err:","")}`,color:i,err:m?r[e]:void 0}}));l.length&&(a[t]=l)}}function f(e,t,a){return e.reduce((e,n)=>Math.max(e,t[n].reduce((e,t)=>Math.max(e,t[a]?.length??0),0)),0)}function $(e){let t=e.match(/^([^\d]*)(.*)$/);return t?[t[1],t[2]]:["",e]}async function y(){let e=s(process.argv),o=i(p),c={done:[],total:Object.keys({...o.peerDependencies||{},...o.optionalDependencies||{},...o.devDependencies||{},...o.dependencies||{}}).length},d={};if(n(""),await Promise.allSettled([g(o,"peerDependencies",d,c),g(o,"optionalDependencies",d,c),g(o,"devDependencies",d,c),g(o,"dependencies",d,c)]),n(""),Object.keys(d)?.length>0){let s=l(o.packageManager),i=Object.keys(d),c="".padEnd(3," ");n(""),n(a("⚡ Updates available for:","magenta",{bold:!0})),n("");let u=f(i,d,"name"),h=f(i,d,"latest"),g=f(i,d,"wanted");i.forEach(e=>{n(a(`${e}:`,"145")),d[e].forEach(t=>{n(`${a(t.name.padEnd(u," "),t.color,{bold:!0})}${c}${t.wanted.padStart(g," ")}${c}${a("→",t.color)}${c}${a(t.latest.padStart(h," "),t.color)}`),t.err||(o[e][t.name]=t.latest)}),n("")}),e["-u"]?(await r(p,JSON.stringify(o,null,2)),n(`✅ ${a(t(m.programPath,p),"yellow")} upgrade completed successfully.`),n(`⏳ Run ${a(`${s} install`,"blue")} to install new versions.`)):n(`⏳ Run ${a("mo pin -u","blue")} to upgrade package.json`)}else n(""),n("🎉 All dependencies match the latest package versions");n("")}export default y;
|
package/lib/bin/tsc.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e}from"node:path";import{stdout as t}from"node:process";import
|
|
1
|
+
import{join as e}from"node:path";import{stdout as t}from"node:process";import i from"typescript";import{cwd as o}from"./utils/config.mjs";async function n(n){return new Promise(s=>{let r=i.parseJsonConfigFileContent({extends:e(o,"tsconfig.json"),compilerOptions:{outDir:n,declaration:!0,emitDeclarationOnly:!0,skipLibCheck:!0,skipDefaultLibCheck:!0,noEmitOnError:!1},include:[e(o,"components"),e(o,"typings")],exclude:[e(o,"components/**/examples/*"),e(o,"components/**/__tests__/*"),e(o,"components/**/__mocks__/*")]},i.sys,o);r.options.incremental&&(r.options.tsBuildInfoFile=r.options.tsBuildInfoFile??e(n,".tsbuildinfo"));let a=i.createProgram(r.fileNames,r.options),c=a.emit();i.getPreEmitDiagnostics(a).concat(c.diagnostics).forEach(e=>{if(t.write("\n"),e.file){let{line:o,character:n}=e.file.getLineAndCharacterOfPosition(e.start),s=i.flattenDiagnosticMessageText(e.messageText,"\n");t.write(`${e.file.fileName} (${o+1},${n+1}): ${s}`)}else t.write(i.flattenDiagnosticMessageText(e.messageText,"\n"))}),s(!0)})}export default n;
|
package/lib/build-dev.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as
|
|
2
|
-
`):(n(
|
|
1
|
+
import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as e,completedInfo as t,ink as m,println as i,progressBar as n}from"@moneko/utils";import s from"webpack";import a from"./commom/log.mjs";import l from"./commom/paths.mjs";import{empty as p}from"./utils/index.mjs";import{CONFIG as c}from"./config.mjs";import{createDevelopmentConfiguration as g}from"./create-development-configuration.mjs";let u=await g({});if(c.bar){let o=c.bar,e=o.name||"Build";u.plugins.push(new s.ProgressPlugin({handler(t,m,...i){let s=i.length?`[${m}] ${i.join(" ")}`:" ";o.quiet?r.stdout.write(`${s}
|
|
2
|
+
`):(n(t||0,1,{msg:s,name:e,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===t&&r.stdout.write("\r\x1b[2K"))}}))}let d=s(u);async function f(){let r=await new Promise((o,r)=>{d?.run((e,t)=>{e&&r(e),t?o(t):r(Error("编译过程中没有生成统计信息"))})});(r.hasErrors()||r.hasWarnings())&&function(o){let{warnings:r,errors:e}=o.compilation,t=[];r.forEach(o=>{o.message.includes("Conflicting order between css ./node_modules/")&&o.message.includes("monaco-editor")?t.push(o.message):i(m(o.message,"178"))}),t.length&&a(t.join("\n")),e.forEach(o=>{i(m(o.message,"red"))})}(r),await new Promise(n=>{r.compilation.compiler.cache.shutdown(s=>{s&&i(m(s.toString(),"red")),e(r.compilation.outputOptions.path,["\\.js$"]),t(~~((r.endTime-r.startTime)/10)/100,o(l.programPath,r.compilation.outputOptions.path)),n()})})}r.on("exit",p),await f();
|
package/lib/build.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as m,completedInfo as e,ink as
|
|
2
|
-
`):(
|
|
1
|
+
import{relative as o}from"node:path";import r from"node:process";import{analyzeBundleSize as m,completedInfo as e,ink as i,println as t,progressBar as s}from"@moneko/utils";import n from"webpack";import{merge as a}from"webpack-merge";import l from"./build/common.mjs";import p from"./commom/log.mjs";import u from"./commom/paths.mjs";import{DonePlugin as g}from"./plugin/done.mjs";import{empty as c}from"./utils/index.mjs";import d from"./utils/seo.mjs";import{CONFIG as f}from"./config.mjs";import h from"./module.config.mjs";let w=a(l,{module:h(!1),plugins:[]});if(f.done&&w.plugins.push(new g({done:f.done})),f.bar){let o=f.bar,m=o.name||"Build";w.plugins.push(new n.ProgressPlugin({handler(e,i,...t){let n=t.length?`[${i}] ${t.join(" ")}`:" ";o.quiet?r.stdout.write(`${n}
|
|
2
|
+
`):(s(e||0,1,{msg:n,name:m,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===e&&r.stdout.write("\r\x1b[2K"))}}))}let b=n(w);if(!b)throw Error("无法创建编译器");async function j(){let r=await new Promise((o,r)=>{b?.run((m,e)=>{m&&r(m),e?o(e):r(Error("编译过程中没有生成统计信息"))})});(r.hasErrors()||r.hasWarnings())&&function(o){let{warnings:r,errors:m}=o.compilation,e=[];r.forEach(o=>{o.message.includes("Conflicting order between css ./node_modules/")&&o.message.includes("monaco-editor")?e.push(o.message):t(i(o.message,"178"))}),e.length&&p(e.join("\n")),m.forEach(o=>{t(i(o.message,"red"))})}(r),await new Promise(s=>{r.compilation.compiler.cache.shutdown(n=>{n&&t(i(n.toString(),"red")),m(r.compilation.outputOptions.path,["\\.js$"]),e(~~((r.endTime-r.startTime)/10)/100,o(u.programPath,r.compilation.outputOptions.path)),s()})}),f.seo&&d()}r.on("exit",c),await j();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fileExists as o}from"@moneko/utils";import r from"./paths.mjs";export function getPackageManager(a){return a?a.split("@")[0]:o(`${r.programPath}/pnpm-lock.yaml`)?"pnpm":o(`${r.programPath}/yarn.lock`)?"yarn":o(`${r.programPath}/bun.lockb`)?"bun":o(`${r.programPath}/deno.lock`)?"deno":"npm"}
|
package/lib/common.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extname as e,join as t,resolve as
|
|
1
|
+
import{extname as e,join as t,resolve as s}from"node:path";import o,{config_files as a,CUSTOMCONFIG as n,TMP_DIR as i}from"./commom/paths.mjs";import r from"./commom/rule.mjs";import{OverrideResolverPlugin as l}from"./plugin/override-resolve.mjs";import{isObject as m,resolveProgram as c}from"./utils/index.mjs";import{CONFIG as p}from"./config.mjs";import u from"./plugins.config.mjs";import{app_schema as h,CACHE_NAME as d,isCI as f,isDev as g,isLibrary as y,packageJson as b,projectNameCamelCase as j}from"./process-env.mjs";export const outputConfig={path:c(y?"docs":"dist"),filename:e=>e.filename?.includes(".worker")?"worker/[name].js":"js/[name].[contenthash].bundle.js",chunkFilename:"js/[contenthash].chunk.js",cssFilename:"style/[contenthash].css",cssChunkFilename:"style/[contenthash].chunk.css",assetModuleFilename:t=>{let s=e(t.filename||"").substring(1);return`assets/${s}/[hash][ext]`},library:{name:`${j}`,type:"umd",umdNamedDefine:!0},globalObject:"self",chunkLoadingGlobal:`webpackJsonp_${b.name}`,pathinfo:g,clean:!0,publicPath:p.publicPath,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"],uniqueName:`${j}`};let v={main:[`${h}:entry`]},C=[t(o.corePath,"./polyfills/public-path.mjs")];if(g&&p.refresh&&p.env.injectRemoteReactRefresh&&C.push(t(o.corePath,"./polyfills/inject-react-refresh.mjs")),p.polyfill&&C.push(t(o.corePath,"./polyfills/replace-children.mjs")),p.entry&&("string"==typeof p.entry?v={...v,main:[p.entry]}:Object.keys(p.entry)&&(v=Object.assign(v,p.entry))),"string"==typeof v.main?v.main=[...C,v.main]:Array.isArray(v.main)&&(v.main=[...C,...v.main]),p.output){if("string"==typeof p.output)outputConfig.path=p.output;else if(Object.keys(p.output)){let e=p.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof p.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let P={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:o.webpackCachePath,memoryCacheUnaffected:!g,name:d,version:`${b.version}`,buildDependencies:{config:a},maxMemoryGenerations:1};!1===p.cache?P=!1:m(p.cache)&&(P=Object.assign(P,p.cache)),f&&(void 0===p.cache||p.cache&&!p.cache.cacheDirectory)&&(P.cacheDirectory=s(i,b.name));let k={},x={imports:!0,entries:!0,test:e=>{let s=e.nameForCondition();return!!(s&&(/^[a-z][a-z0-9]*:.+$/.test(s)||s?.startsWith(t(o.programPath,"src"))||s?.startsWith(t(o.programPath,"site"))||s?.startsWith(o.componentsPath)))}};p.lazyCompilation&&g&&"true"!==process.env.IS_BUILD?m(p.lazyCompilation)?Object.assign(k,x,p.lazyCompilation):Object.assign(k,x):k=!1;export const commonConfig={name:"client",target:"web",devtool:p.devtool,entry:v,mode:p.mode??"production",cache:P,snapshot:{immutablePaths:[o.pnpmNodeModules,o.denoNodeModules,r.node_modules],managedPaths:[o.pnpmNodeModules,o.denoNodeModules,r.node_modules],resolveBuildDependencies:{timestamp:!0,hash:!0},resolve:{timestamp:!0,hash:!0},module:{timestamp:!0,hash:!0},buildDependencies:{timestamp:!0,hash:!0},contextModule:{timestamp:!0,hash:!0}},stats:"errors-only",infrastructureLogging:{level:"error"},externalsPresets:p.externalsPresets,plugins:u,node:{global:!1,__filename:!1,__dirname:!1},experiments:{asyncWebAssembly:!0,cacheUnaffected:!g,lazyCompilation:k,buildHttp:m(p.buildHttp)?{allowedUris:[],lockfileLocation:s(o.httpCachePath,"http.lock"),cacheLocation:s(o.httpCachePath,"data"),upgrade:!0,...p.buildHttp}:p.buildHttp,backCompat:!0,futureDefaults:!0,css:!0,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:p.alias,modules:[o.nodeModules,o.pnpmNodeModules,o.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:p.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:p.externals,output:outputConfig,recordsPath:p.recordsPath};p.overrideResolve&&commonConfig.resolve.plugins.push(new l(Object.assign({original:p.alias["@"],override:n&&c(n)},p.overrideResolve)));
|
package/lib/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e,relative as o}from"node:path";import t from"node:process";import{merge as a}from"webpack-merge";import n from"./commom/paths.mjs";import s from"./commom/setup-env.mjs";import r from"./options/jsx-dom-expressions.mjs";import i from"./options/split-chunk.mjs";import{getConfigWithTypescript as l,isFunction as m,node_modules as p,resolveProgram as c}from"./utils/index.mjs";import{APPTYPE as
|
|
1
|
+
import{join as e,relative as o}from"node:path";import t from"node:process";import{merge as a}from"webpack-merge";import n from"./commom/paths.mjs";import s from"./commom/setup-env.mjs";import r from"./options/jsx-dom-expressions.mjs";import i from"./options/split-chunk.mjs";import{getConfigWithTypescript as l,isFunction as m,node_modules as p,resolveProgram as c}from"./utils/index.mjs";import{initDts as u}from"./vm/dts.mjs";import{APPTYPE as d,FRAMEWORK as f,frameworkVersion as h,isCI as g,isDev as v,isLibrary as x,isMobile as P,isReact as C,jsxImportSource as b,mainDirectory as j,NODE_ENV as k,PACKAGENAME as w}from"./process-env.mjs";let I=[/(app|vm|docs|example):[a-zA-Z_0-9]/,"@moneko","neko-ui",".cache/http/data","@element-plus","ant-design-vue","element-plus","element-ui","ng-zorro-antd","@mui","@du","@fontsource","@fortawesome","font-pingfang-sc","font-pingfang-tc","katex","react-markdown-editor-lite","react-photo-view","schema-design","monaco-editor"];export async function getConfig(e){let o=l(e).default;return(m(o)?await o(t):o)??{}}let O=await s(k,d,f,[],"true"===t.env.IS_BUILD),[S,y]=await Promise.all([getConfig(n.configPath),getConfig(n.customConfigPath)]),M={mode:k,strict:!1,devtool:"true"!==t.env.IS_BUILD&&v?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:"",namespace:w,moduleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]",fallbackModuleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]"},env:O,basename:"/",publicPath:"auto",rem:{designSize:P?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":c(j)},C&&h<18?{"react/package.json":p("react/package.json"),"react/jsx-runtime":p("react/jsx-runtime.js"),"react/jsx-dev-runtime":p("react/jsx-dev-runtime.js")}:{}),moduleRules:[],prefixJsLoader:[],cssModules:[],cssModuleDefinition:!0,importOnDemand:{},proxy:{},devServer:{host:"localhost",port:3e3,open:!0},htmlPluginOption:{title:w.toLocaleUpperCase(),favicon:o(n.programPath,`${n.corePath}/options/favicon.ico`)},copy:{},routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:i,runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:I,js:I,media:I,font:I,wasm:[]},mdx:{jsx:!1,development:v,jsxImportSource:b,providerImportSource:`@moneko/${f}/mdx`},jsxDomExpressions:r,bar:{name:"Client",nameColor:"68",msgColor:"242",barBgColor:"15",barColor:"69",quiet:g},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==f,bundleId:"com.moneko.bid",bundles:[],stylelint:{},eslint:{lintDirtyModulesOnly:!1},minChunkSize:1e3,compression:"true"!==t.env.IS_BUILD,manifest:{filename:"site.webmanifest"},corepack:!0,reactJsxRuntime:"automatic"};x&&(M.alias=Object.assign(M.alias,{"@pkg":n.componentsPath,[w]:n.componentsPath}));let D=M;(!1===(D=a(D,S,y)).devtool||!1===D.sourceMap)&&(D.sourceMap=!1,D.devtool=!1),"true"===t.env.CODESPACES&&(D.devServer.https=!1),!1===D.devServer.https&&"darwin"===t.platform&&(D.devServer.open=!1),D.htmlPluginOption&&(D.htmlPluginOption.tags||(D.htmlPluginOption.tags=[]),D.fixBrowserRouter&&D.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))"}),D.manifest&&(D.manifest.publicPath||(D.manifest.publicPath=D.basename),D.htmlPluginOption.tags.push({href:e(D.manifest.publicPath,D.manifest.filename).replaceAll(/\\/g,"/"),tag:"link",rel:"manifest"})));export const CONFIG=D;export const PUBLICPATH="auto"===CONFIG.publicPath?"":CONFIG.publicPath;u(CONFIG);
|
package/lib/dev/config.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ink as e,println as o,termClear as r}from"@moneko/utils";import{hostHelp as t}from"../commom/host.mjs";import
|
|
2
|
-
`,"245");export function getServerAddress(e){return`${l.devServer.https?"https":"http"}://${"local"===e?l.devServer.host:
|
|
1
|
+
import{ink as e,println as o,termClear as r}from"@moneko/utils";import{hostHelp as t}from"../commom/host.mjs";import s from"../commom/log.mjs";import{getIPv4 as m,getPort as n}from"../commom/net.mjs";import i from"../commom/print-log.mjs";import{CONFIG as l}from"../config.mjs";let a=l.devServer.port||3e3;export const PORT=await n(a);l.devServer.port=PORT;let c="/"===l.basename?"":l.basename,d=a!==PORT&&e(`Port ${e(`${a}`,"yellow")} is in use, trying ${e(`${PORT}`,"green")} instead.
|
|
2
|
+
`,"245");export function getServerAddress(e){return`${l.devServer.https?"https":"http"}://${"local"===e?l.devServer.host:m()}:${PORT}${c}`}let p=e("You application is running here:","245");export function devLog(m,n){r(3);let a=(n?.endTime??0)-(n?.startTime??0);if(o(p,!0),o("",!0),i("Local",getServerAddress("local"),{timestamp:!1,labelBackgroundColor:"blue",labelLen:9}),i("Network",getServerAddress("net"),{timestamp:!1,labelBackgroundColor:"29"}),o("",!0),o(e(`Compiled successfully in ${e(`${a}ms`,"green")}`,"245"),!0),o("",!0),d&&o(d),t(l.devServer.host),n){let e=[];n.compilation.warnings.forEach(r=>{r.message.includes("Conflicting order between css ./node_modules/")&&r.message.includes("monaco-editor")?e.push(r.message):o(r.message)}),n.compilation.errors.forEach(e=>{o(e.message)}),e.length&&s(e.join("\n"))}m&&o(m.message)}
|
package/lib/process-env.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AppType, type Framework } from './index.mjs';
|
|
2
2
|
export declare const IS_WINDOW: boolean;
|
|
3
3
|
export declare const APPTYPE: AppType;
|
|
4
4
|
export declare const FRAMEWORK: Framework;
|
|
@@ -23,9 +23,11 @@ export declare const frameworkVersion: number;
|
|
|
23
23
|
export declare const packageJson: any;
|
|
24
24
|
/** 应用名称 */
|
|
25
25
|
export declare const PACKAGENAME: string;
|
|
26
|
+
export declare const projectNameCamelCase: string;
|
|
26
27
|
/** core 包名 */
|
|
27
28
|
export declare const coreName: string;
|
|
28
29
|
/** 是否为本地开发环境 */
|
|
29
30
|
export declare const isDev: boolean;
|
|
30
31
|
export declare const refresh: boolean;
|
|
31
32
|
export declare const isCI: boolean;
|
|
33
|
+
export declare const CACHE_NAME: string;
|
package/lib/process-env.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"node:process";import e from"./commom/has-pkg.mjs";import r from"./commom/is-ci-environment.mjs";import{
|
|
1
|
+
import o from"node:process";import e from"./commom/has-pkg.mjs";import r from"./commom/is-ci-environment.mjs";import{CUSTOMCONFIG as s}from"./commom/paths.mjs";import{readJson as t}from"./commom/read-json.mjs";import{convertToCamelCase as c,digest as p}from"./utils/index.mjs";export const IS_WINDOW="win32"===o.platform;export const APPTYPE=o.env.APPTYPE;export const FRAMEWORK=o.env.FRAMEWORK;export const NODE_ENV=o.env.NODE_ENV;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isMobile="mobile"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const SSR="true"===o.env.SSR;export const app_schema="app";export const virtual_schema="vm";export const docs_schema="docs";export const example_schema="example";export const scope_schema="scope";export const mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const framework={react:"react",solid:"solid-js"}[FRAMEWORK];export const frameworkVersionStr=framework?t(`${framework}/package.json`).version:19;export const frameworkVersion=parseFloat(frameworkVersionStr);export const packageJson=t(`${o.cwd()}/package.json`);delete packageJson.scripts;export const PACKAGENAME=packageJson.name;export const projectNameCamelCase=c(PACKAGENAME);export const coreName="@moneko/core";export const isDev="development"===NODE_ENV;export const refresh=!!(isDev&&e("solid"===FRAMEWORK?"solid-refresh":"react-refresh"));export const isCI=r();export const CACHE_NAME=p(`${PACKAGENAME}${s}${NODE_ENV}${o.argv[2]}`);
|
package/lib/utils/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash as e,createHmac as t}from"node:crypto";import{resolve as o}from"node:path";import{fileExists as r}from"@moneko/utils";import n from"../commom/paths.mjs";import
|
|
1
|
+
import{createHash as e,createHmac as t}from"node:crypto";import{resolve as o}from"node:path";import{fileExists as r}from"@moneko/utils";import n from"../commom/paths.mjs";import c from"../commom/require.mjs";export function toCamelCase(e){return e.replace(/-./g,e=>e.charAt(1).toUpperCase())}export function convertToCamelCase(e){return e.toLowerCase().replace(/^@/,"").replace(/\//g,"-").replace(/-(\w)/g,(e,t)=>t?t.toUpperCase():"").replace(/^./,e=>e.toUpperCase()).replace(/Ui$/,"UI")}export function resolveProgram(e){return o(n.programPath,`./${e}`)}export function node_modules(e){return o(n.nodeModules,`./${e}`)}export function isObject(e){let t=typeof e;return null!==e&&("object"===t||"function"===t)}export function isFunction(e){return["[object Function]","[object AsyncFunction]","[object GeneratorFunction]"].includes(Object.prototype.toString.call(e))}export function transformModule(e){let t="";if("string"==typeof e)t=e;else for(let[o,r]of Object.entries(e))t+=`export const ${o} = ${isFunction(r)?r:JSON.stringify(r)};`;return t}export function empty(){}export function digest(e,o){return t(o?.algorithm??"sha1",o?.secret??"mo").update(e).digest(o?.encoding??"hex")}export function md5(t,o="hex"){return e("md5").update(t).digest(o)}export function getConfigWithTypescript(e,t){return r(e)?(delete c.cache[e],c(e)):t??{}}
|
package/lib/vm/app.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e}from"node:path";import{getAppEntry as
|
|
1
|
+
import{join as e}from"node:path";import{getAppEntry as r,getAppFallback as o,getAppMergeRouter as m,getAppNormalizeCss as t,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as p}from"@moneko/mdx";import n,{routeDir as i}from"../commom/paths.mjs";import f from"../commom/reactive-object.mjs";import{readJson as l}from"../commom/read-json.mjs";import{CONFIG as c}from"../config.mjs";import d from"../plugin/module-federation.mjs";import{app_schema as u,APPTYPE as j,FRAMEWORK as x,framework as y,frameworkVersionStr as g,SSR as h}from"../process-env.mjs";import k from"../utils/create-types.mjs";import{generateDeclaration as v}from"../utils/dts.mjs";import{convertToCamelCase as C,transformModule as b}from"../utils/index.mjs";import{vm_dts as D}from"./dts.mjs";import{generateLocales as w}from"./locales.mjs";import z from"./render-app.mjs";import{getRouter as M}from"./routes.mjs";export const app_vm=new f({env:()=>{let e=`${u}:env`,r=b(c.env);return D.setData(e,k(e,v(r,e))),r},info:r=>{let o=e(n.programPath,"package.json"),m=l(o),t=b({...m,projectName:C(m.name),ssr:h,base:c.basename,type:j,routerMode:c.routerMode,prefixCls:c.prefixCls,theme:c.theme,frameworkVersion:g,framework:y}),s=`${u}:info`;return r?.addDependency(o),D.setData(s,k(s,v(t,s))),t},render:{type:".tsx",source:()=>"react"===x?z:""},entry:()=>r(e(c.alias["@"],"./index.ts"),!!d.length,!!c.rem,!!c.normalizeCss,j,x),fallback:()=>o(c.fallbackCompPath),"merge-router":()=>m(),"prefix-router":()=>s(),suspense:{type:".tsx",source:()=>p(j,x)},routes:e=>(e.addContextDependency(i),M()),locals:r=>{let o=e(c.alias["@"],"./locales");return r.addContextDependency(o),w()},normalize:{type:".css",source:()=>t()},rem:()=>a(c.rem?.designSize||1680)});
|
package/lib/vm/dts.d.mts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ConfigType } from '../../typings/global.js';
|
|
2
|
+
import ReactiveObject from '../commom/reactive-object.mjs';
|
|
3
|
+
export declare const dts_path: string;
|
|
4
|
+
export declare const vm_dts: ReactiveObject<Record<string, string>>;
|
|
5
|
+
export declare function initDts(config: ConfigType): void;
|
package/lib/vm/dts.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{join as t}from"node:path";import{updateFile as e,updateFileSync as o}from"@moneko/utils";import s from"../commom/paths.mjs";import m from"../commom/reactive-object.mjs";import{readJson as r}from"../commom/read-json.mjs";import{app_schema as n,APPTYPE as a,CACHE_NAME as i,FRAMEWORK as d,framework as p,frameworkVersionStr as l,packageJson as v,SSR as f,virtual_schema as c}from"../process-env.mjs";import j from"../utils/create-types.mjs";import{generateDeclaration as u}from"../utils/dts.mjs";import{convertToCamelCase as $,transformModule as _}from"../utils/index.mjs";export const dts_path=t(s.nodeModules,"@types",i,"index.d.ts");export const vm_dts=new m({});vm_dts.on("change",()=>{let t=Object.values(vm_dts.data).join("\n");e(dts_path,t)});export function initDts(e){let m=j(`${n}:env`,u(_(e.env),`${n}:env`));vm_dts.setData(`${n}:env`,m);let h=j(`${n}:info`,u(_({...r(t(s.programPath,"package.json")),projectName:$(v.name),ssr:f,type:a,frameworkVersion:l,framework:p,base:e.basename,routerMode:e.routerMode,prefixCls:e.prefixCls,theme:e.theme}),`${n}:info`));vm_dts.setData(`${n}:info`,h),e.virtualModule&&Object.keys(e.virtualModule).map(t=>{let o=_(e.virtualModule[t]),s=`${c}:${t}`;vm_dts.setData(s,j(s,u(o,s)))}),o(dts_path,Object.values(vm_dts.data).join("\n")),o(t(s.nodeModules,"@moneko/init.d.json"),JSON.stringify({extends:`@moneko/${d}/base`,compilerOptions:{types:[`@moneko/${d}/env.d.ts`,`@types/${i}/index.d.ts`]}}))}
|
package/lib/vm/virtual.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from"../commom/reactive-object.mjs";import{CONFIG as m}from"../config.mjs";import{virtual_schema as o}from"../process-env.mjs";import r from"../utils/create-types.mjs";import{generateDeclaration as e}from"../utils/dts.mjs";import{transformModule as s}from"../utils/index.mjs";import{vm_dts as i}from"./dts.mjs";export const virtual_vm=new t({});m.virtualModule&&Object.keys(m.virtualModule).map(t=>{let l=s(m.virtualModule[t]);virtual_vm.setData(t,l);let a=`${o}:${t}`;i.setData(a,r(a,e(l,a)))});
|
package/package.json
CHANGED
package/lib/vm/info.d.mts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare const app: {
|
|
2
|
-
projectName: string;
|
|
3
|
-
ssr: boolean;
|
|
4
|
-
base: string;
|
|
5
|
-
type: import("../index.mjs").AppType;
|
|
6
|
-
routerMode: "browser" | "hash" | "memory";
|
|
7
|
-
prefixCls: string | undefined;
|
|
8
|
-
theme: import("../index.mjs").Theme | undefined;
|
|
9
|
-
frameworkVersion: string;
|
|
10
|
-
framework: "react" | "solid-js";
|
|
11
|
-
};
|
|
12
|
-
export default app;
|
package/lib/vm/info.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{CONFIG as e}from"../config.mjs";import{APPTYPE as r,framework as o,frameworkVersionStr as m,packageJson as s,SSR as t}from"../process-env.mjs";import{convertToCamelCase as f}from"../utils/index.mjs";let i={projectName:f(s.name),ssr:t,base:e.basename,type:r,routerMode:e.routerMode,prefixCls:e.prefixCls,theme:e.theme,frameworkVersion:m,framework:o};export default i;
|