@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 CHANGED
@@ -1 +1 @@
1
- import{spawn as e}from"node:child_process";import{relative as t}from"node:path";import{fileExists as a,ink as n,println as r,progressBar as o,updateFile as l}from"@moneko/utils";import s from"../commom/parse-args.mjs";import m from"../commom/paths.mjs";import{readJson as i}from"../commom/read-json.mjs";import p from"../commom/require.mjs";let c=p.resolve(`${m.programPath}/package.json`);async function d(t){return new Promise(a=>{let n=e("npm",["view",t,"version"],{shell:!0}),r="";n.stdout.on("data",e=>{r+=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&&(r+=`Err: ${t[0]}`.trim())}),n.on("close",async()=>{a(r.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 r;let o=await u(e[t],n),l=(r=e[t],Object.keys(o).filter(e=>{let t=f(r[e]);return r[e]!==`${t[0]}${o[e]}`}).map(e=>{var t,a;let n,l,s=f(r[e]),m=o[e].includes("Err:"),i=m?"red":h[t=s[1],a=o[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:r[e],latest:`${s[0]}${o[e].replace("Err:","")}`,color:i,err:m?o[e]:void 0}}));l.length&&(a[t]=l)}}function $(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 f(e){let t=e.match(/^([^\d]*)(.*)$/);return t?[t[1],t[2]]:["",e]}async function y(){let e=s(process.argv),o=i(c),p={done:[],total:Object.keys({...o.peerDependencies||{},...o.optionalDependencies||{},...o.devDependencies||{},...o.dependencies||{}}).length},d={};if(r(""),await Promise.allSettled([g(o,"peerDependencies",d,p),g(o,"optionalDependencies",d,p),g(o,"devDependencies",d,p),g(o,"dependencies",d,p)]),r(""),Object.keys(d)?.length>0){var u;let s=(u=o.packageManager)?u.split("@")[0]:a(`${m.programPath}/pnpm-lock.yaml`)?"pnpm":a(`${m.programPath}/yarn.lock`)?"yarn":a(`${m.programPath}/bun.lockb`)?"bun":a(`${m.programPath}/deno.lock`)?"deno":"npm",i=Object.keys(d),p="".padEnd(3," ");r(""),r(n("⚡ Updates available for:","magenta",{bold:!0})),r("");let h=$(i,d,"name"),g=$(i,d,"latest"),f=$(i,d,"wanted");i.forEach(e=>{r(n(`${e}:`,"145")),d[e].forEach(t=>{r(`${n(t.name.padEnd(h," "),t.color,{bold:!0})}${p}${t.wanted.padStart(f," ")}${p}${n("→",t.color)}${p}${n(t.latest.padStart(g," "),t.color)}`),t.err||(o[e][t.name]=t.latest)}),r("")}),e["-u"]?(await l(c,JSON.stringify(o,null,2)),r(`✅ ${n(t(m.programPath,c),"yellow")} upgrade completed successfully.`),r(`⏳ Run ${n(`${s} install`,"blue")} to install new versions.`)):r(`⏳ Run ${n("mo pin -u","blue")} to upgrade package.json`)}else r(""),r("🎉 All dependencies match the latest package versions");r("")}export default y;
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 o from"typescript";import{cwd as i}from"./utils/config.mjs";async function n(n){return new Promise(s=>{let r=o.parseJsonConfigFileContent({extends:e(i,"tsconfig.json"),compilerOptions:{outDir:n,typeRoots:["node_modules/@types/","node_modules/.pnpm/node_modules/@types/"],declaration:!0,emitDeclarationOnly:!0,skipLibCheck:!0,skipDefaultLibCheck:!0,noEmitOnError:!1},include:[e(i,"components"),e(i,"typings")],exclude:[e(i,"components/**/examples/*"),e(i,"components/**/__tests__/*"),e(i,"components/**/__mocks__/*")]},o.sys,i);r.options.incremental&&(r.options.tsBuildInfoFile=r.options.tsBuildInfoFile??e(n,".tsbuildinfo"));let l=o.createProgram(r.fileNames,r.options),m=l.emit();o.getPreEmitDiagnostics(l).concat(m.diagnostics).forEach(e=>{if(t.write("\n"),e.file){let{line:i,character:n}=e.file.getLineAndCharacterOfPosition(e.start),s=o.flattenDiagnosticMessageText(e.messageText,"\n");t.write(`${e.file.fileName} (${i+1},${n+1}): ${s}`)}else t.write(o.flattenDiagnosticMessageText(e.messageText,"\n"))}),s(!0)})}export default n;
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 t,completedInfo as e,ink as m,println as i,progressBar as n}from"@moneko/utils";import a from"webpack";import s 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,t=o.name||"Build";u.plugins.push(new a.ProgressPlugin({handler(e,m,...i){let a=i.length?`[${m}] ${i.join(" ")}`:" ";o.quiet?r.stdout.write(`${a}
2
- `):(n(e||0,1,{msg:a,name:t,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===e&&r.stdout.write("\r\x1b[2K"))}}))}let d=a(u);async function f(){let r=await new Promise((o,r)=>{d?.run((t,e)=>{t&&r(t),e?o(e):r(Error("编译过程中没有生成统计信息"))})});(r.hasErrors()||r.hasWarnings())&&function(o){let{warnings:r,errors:t}=o.compilation,e=[];r.forEach(o=>{o.message.includes("Conflicting order between css ./node_modules/.pnpm/monaco-editor")?e.push(o.message):i(m(o.message,"178"))}),e.length&&s(e.join("\n")),t.forEach(o=>{i(m(o.message,"red"))})}(r),await new Promise(n=>{r.compilation.compiler.cache.shutdown(a=>{a&&i(m(a.toString(),"red")),t(r.compilation.outputOptions.path,["\\.js$"]),e(~~((r.endTime-r.startTime)/10)/100,o(l.programPath,r.compilation.outputOptions.path)),n()})})}r.on("exit",p),await f();
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 t,println as i,progressBar as n}from"@moneko/utils";import s from"webpack";import{merge as a}from"webpack-merge";import p from"./build/common.mjs";import l 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(p,{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 s.ProgressPlugin({handler(e,t,...i){let s=i.length?`[${t}] ${i.join(" ")}`:" ";o.quiet?r.stdout.write(`${s}
2
- `):(n(e||0,1,{msg:s,name:m,barColor:o.barColor,nameColor:o.nameColor,barBgColor:o.barBgColor,msgColor:o.msgColor}),1===e&&r.stdout.write("\r\x1b[2K"))}}))}let b=s(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/.pnpm/monaco-editor")?e.push(o.message):i(t(o.message,"178"))}),e.length&&l(e.join("\n")),m.forEach(o=>{i(t(o.message,"red"))})}(r),await new Promise(n=>{r.compilation.compiler.cache.shutdown(s=>{s&&i(t(s.toString(),"red")),m(r.compilation.outputOptions.path,["\\.js$"]),e(~~((r.endTime-r.startTime)/10)/100,o(u.programPath,r.compilation.outputOptions.path)),n()})}),f.seo&&d()}r.on("exit",c),await j();
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,8 @@
1
+ type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'deno' | 'npm';
2
+ /**
3
+ * 获取包管理器
4
+ * @param {string | void} packageManager 包管理器
5
+ * @returns {PackageManager}
6
+ */
7
+ export declare function getPackageManager(packageManager?: string): PackageManager;
8
+ export {};
@@ -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 o}from"node:path";import{argv as s}from"node:process";import a,{config_files as n,CUSTOMCONFIG as i,TMP_DIR as r}from"./commom/paths.mjs";import l from"./commom/rule.mjs";import{OverrideResolverPlugin as m}from"./plugin/override-resolve.mjs";import{digest as c,isObject as p,resolveProgram as u}from"./utils/index.mjs";import h from"./vm/info.mjs";import{CONFIG as d}from"./config.mjs";import f from"./plugins.config.mjs";import{app_schema as g,isCI as y,isDev as b,isLibrary as j,NODE_ENV as v,packageJson as C}from"./process-env.mjs";export const outputConfig={path:u(j?"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 o=e(t.filename||"").substring(1);return`assets/${o}/[hash][ext]`},library:{name:`${h.projectName}`,type:"umd",umdNamedDefine:!0},globalObject:"self",chunkLoadingGlobal:`webpackJsonp_${C.name}`,pathinfo:b,clean:!0,publicPath:d.publicPath,asyncChunks:!0,charset:!0,iife:!0,crossOriginLoading:"use-credentials",enabledWasmLoadingTypes:["fetch"],uniqueName:`${h.projectName}`};let P={main:[`${g}:entry`]},k=[t(a.corePath,"./polyfills/public-path.mjs")];if(b&&d.refresh&&d.env.injectRemoteReactRefresh&&k.push(t(a.corePath,"./polyfills/inject-react-refresh.mjs")),d.polyfill&&k.push(t(a.corePath,"./polyfills/replace-children.mjs")),d.entry&&("string"==typeof d.entry?P={...P,main:[d.entry]}:Object.keys(d.entry)&&(P=Object.assign(P,d.entry))),"string"==typeof P.main?P.main=[...k,P.main]:Array.isArray(P.main)&&(P.main=[...k,...P.main]),d.output){if("string"==typeof d.output)outputConfig.path=d.output;else if(Object.keys(d.output)){let e=d.output,t={...outputConfig.library};Object.assign(outputConfig,e),"object"==typeof d.output&&e.library&&(outputConfig.library=Object.assign(t,e.library))}}let x={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:a.webpackCachePath,memoryCacheUnaffected:!b,name:c(`${i}-${v}-${s[2]}`),version:`${C.version}`,buildDependencies:{config:n},maxMemoryGenerations:1};!1===d.cache?x=!1:p(d.cache)&&(x=Object.assign(x,d.cache)),y&&(void 0===d.cache||d.cache&&!d.cache.cacheDirectory)&&(x.cacheDirectory=o(r,C.name));let M={},O={imports:!0,entries:!0,test:e=>{let o=e.nameForCondition();return!!(o&&(/^[a-z][a-z0-9]*:.+$/.test(o)||o?.startsWith(t(a.programPath,"src"))||o?.startsWith(t(a.programPath,"site"))||o?.startsWith(a.componentsPath)))}};d.lazyCompilation&&b&&"true"!==process.env.IS_BUILD?p(d.lazyCompilation)?Object.assign(M,O,d.lazyCompilation):Object.assign(M,O):M=!1;export const commonConfig={name:"client",target:"web",devtool:d.devtool,entry:P,mode:d.mode??"production",cache:x,snapshot:{immutablePaths:[a.pnpmNodeModules,a.denoNodeModules,l.node_modules],managedPaths:[a.pnpmNodeModules,a.denoNodeModules,l.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:d.externalsPresets,plugins:f,node:{global:!1,__filename:!1,__dirname:!1},experiments:{asyncWebAssembly:!0,cacheUnaffected:!b,lazyCompilation:M,buildHttp:p(d.buildHttp)?{allowedUris:[],lockfileLocation:o(a.httpCachePath,"http.lock"),cacheLocation:o(a.httpCachePath,"data"),upgrade:!0,...d.buildHttp}:d.buildHttp,backCompat:!0,futureDefaults:!0,css:!0,outputModule:!1},resolve:{extensions:[".mts",".mjs",".ts",".tsx",".js",".jsx",".json",".wasm"],alias:d.alias,modules:[a.nodeModules,a.pnpmNodeModules,a.denoNodeModules],mainFields:["browser","module","main"],mainFiles:["index"],plugins:d.resolvePlugins,preferAbsolute:!0,cache:!0,fallback:{}},externals:d.externals,output:outputConfig,recordsPath:d.recordsPath};d.overrideResolve&&commonConfig.resolve.plugins.push(new m(Object.assign({original:d.alias["@"],override:i&&u(i)},d.overrideResolve)));
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 u,FRAMEWORK as d,frameworkVersion as f,isCI as h,isDev as g,isLibrary as v,isMobile as x,isReact as P,jsxImportSource as b,mainDirectory as C,NODE_ENV as j,PACKAGENAME as k}from"./process-env.mjs";let w=[/(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 I=await s(j,u,d,[],"true"===t.env.IS_BUILD),[O,S]=await Promise.all([getConfig(n.configPath),getConfig(n.customConfigPath)]),y={mode:j,strict:!1,devtool:"true"!==t.env.IS_BUILD&&g?"eval-cheap-module-source-map":"cheap-module-source-map",seo:!1,bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:"",namespace:k,moduleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]",fallbackModuleFilenameTemplate:"moneko://[namespace]/[resource-path]?[loaders]"},env:I,basename:"/",publicPath:"auto",rem:{designSize:x?375:1920},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:Object.assign({"@":c(C)},P&&f<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:k.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:w,js:w,media:w,font:w,wasm:[]},mdx:{jsx:!1,development:g,jsxImportSource:b,providerImportSource:`@moneko/${d}/mdx`},jsxDomExpressions:r,bar:{name:"Client",nameColor:"68",msgColor:"242",barBgColor:"15",barColor:"69",quiet:h},normalizeCss:!0,externalsPresets:{},buildHttp:void 0,virtualModule:{},cssExtract:{},externals:["@swc/core"],lazyCompilation:!1,performance:!1,refresh:"solid"!==d,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"};v&&(y.alias=Object.assign(y.alias,{"@pkg":n.componentsPath,[k]:n.componentsPath}));let M=y;(!1===(M=a(M,O,S)).devtool||!1===M.sourceMap)&&(M.sourceMap=!1,M.devtool=!1),"true"===t.env.CODESPACES&&(M.devServer.https=!1),!1===M.devServer.https&&"darwin"===t.platform&&(M.devServer.open=!1),M.htmlPluginOption&&(M.htmlPluginOption.tags||(M.htmlPluginOption.tags=[]),M.fixBrowserRouter&&M.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))"}),M.manifest&&(M.manifest.publicPath||(M.manifest.publicPath=M.basename),M.htmlPluginOption.tags.push({href:e(M.manifest.publicPath,M.manifest.filename).replaceAll(/\\/g,"/"),tag:"link",rel:"manifest"})));export const CONFIG=M;export const PUBLICPATH="auto"===CONFIG.publicPath?"":CONFIG.publicPath;
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);
@@ -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 m from"../commom/log.mjs";import{getIPv4 as s,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 p="/"===l.basename?"":l.basename,c=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:s()}:${PORT}${p}`}let d=e("You application is running here:","245");export function devLog(s,n){r(3);let a=(n?.endTime??0)-(n?.startTime??0);if(o(d,!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),c&&o(c),t(l.devServer.host),n){let e=[];n.compilation.warnings.forEach(r=>{r.message.includes("Conflicting order between css ./node_modules/.pnpm/monaco-editor")?e.push(r.message):o(r.message)}),n.compilation.errors.forEach(e=>{o(e.message)}),e.length&&m(e.join("\n"))}s&&o(s.message)}
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)}
@@ -1,4 +1,4 @@
1
- import type { AppType, Framework } from './index.mjs';
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;
@@ -1 +1 @@
1
- import o from"node:process";import e from"./commom/has-pkg.mjs";import r from"./commom/is-ci-environment.mjs";import{readJson as s}from"./commom/read-json.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?s(`${framework}/package.json`).version:19;export const frameworkVersion=parseFloat(frameworkVersionStr);export const packageJson=s(`${o.cwd()}/package.json`);delete packageJson.scripts;export const PACKAGENAME=packageJson.name;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();
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]}`);
@@ -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 i 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(/-(\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 i.cache[e],i(e)):t??{}}
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 t,getAppFallback as o,getAppMergeRouter as r,getAppNormalizeCss as s,getAppPrefixRouter as m,getAppRem as n,getAppSuspense as a}from"@moneko/mdx";import{updateFileSync as p}from"@moneko/utils";import i,{routeDir as c}from"../commom/paths.mjs";import l from"../commom/reactive-object.mjs";import{readJson as u}from"../commom/read-json.mjs";import{CONFIG as f}from"../config.mjs";import d from"../plugin/module-federation.mjs";import{app_schema as j,APPTYPE as x,FRAMEWORK as y}from"../process-env.mjs";import g from"../utils/create-types.mjs";import{generateDeclaration as v}from"../utils/dts.mjs";import{node_modules as D,transformModule as h}from"../utils/index.mjs";import k from"./info.mjs";import{generateLocales as $}from"./locales.mjs";import b from"./render-app.mjs";import{getRouter as C}from"./routes.mjs";let z=new l({});z.on("change",()=>{p(D(`@types/$${j}/index.d.ts`),Object.values(z.data).join("\n"))});export const app_vm=new l({env:{source:()=>{let e=`${j}:env`,t=h(f.env);return z.setData(e,g(e,v(t,e))),t}},info:{source:t=>{let o=e(i.programPath,"package.json"),r=h({...u(o),...k}),s=`${j}:info`;return t.addDependency(o),z.setData(s,g(s,v(r,s))),r}},render:{type:".tsx",source:()=>"react"===y?b:""},entry:{type:".tsx",source:()=>{let o=`${j}:entry`,r=t(e(f.alias["@"],"./index.ts"),!!d.length,!!f.rem,!!f.normalizeCss,x,y);return z.setData(o,g(o,v(r,o))),r}},fallback:{type:".tsx",source:()=>{let e=`${j}:fallback`,t=o(f.fallbackCompPath);return z.setData(e,g(e,v(t,e))),t}},"merge-router":{type:".tsx",source:()=>r()},"prefix-router":{type:".tsx",source:()=>m()},suspense:{type:".tsx",source:()=>a(x,y)},routes:{type:".tsx",source:e=>(e.addContextDependency(c),C())},locals:{type:".tsx",source:t=>{let o=e(f.alias["@"],"./locales");return t.addContextDependency(o),$()}},normalize:{type:".css",source:()=>s()},rem:{source:()=>n(f.rem?.designSize||1680)}});
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)});
@@ -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`]}}))}
@@ -1 +1 @@
1
- import{updateFileSync as t}from"@moneko/utils";import m from"../commom/reactive-object.mjs";import{CONFIG as o}from"../config.mjs";import{virtual_schema as r}from"../process-env.mjs";import e from"../utils/create-types.mjs";import{generateDeclaration as i}from"../utils/dts.mjs";import{node_modules as s,transformModule as l}from"../utils/index.mjs";export const virtual_vm=new m({});o.virtualModule&&t(s(`@types/$${r}/index.d.ts`),Object.keys(o.virtualModule).map(t=>{let m=l(o.virtualModule[t]);virtual_vm.setData(t,m);let s=`${r}:${t}`;return e(s,i(m,s))}).join("\n"));
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "4.0.4",
3
+ "version": "4.0.6",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
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;