@moneko/core 3.8.3 → 3.8.5-beta.0

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/common.js CHANGED
@@ -1 +1 @@
1
- import e from"add-asset-html-webpack-plugin";import t from"html-webpack-plugin";import o from"webpack";import r from"webpackbar";import{CONFIG as l,PUBLICPATH as s}from"./config.js";import n from"./html-plugin-option.js";import{moduleFederation as a}from"./module-federation.js";import i from"./module.config.js";import p,{CUSTOMCONFIG as c}from"./paths.js";import m from"./plugin/add-entry-attribute.js";import u from"./plugin/override-resolve.js";import f from"./plugin/virtual-module.js";import{PACKAGENAME as h,PACKAGEVERSION as d,isDev as b,isLibrary as g,isMicro as y}from"./process-env.js";import{resolveNodeModulesPath as j,resolveProgramPath as w}from"./utils.js";import v from"./virtual-modules.js";let{AutomaticPrefetchPlugin:k,DefinePlugin:x,SourceMapDevToolPlugin:C,WatchIgnorePlugin:O}=o,$=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:w(g?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${b?"name":"chunkhash"}].js`,assetModuleFilename:e=>{let t=e.filename;return t&&t.endsWith("?url")&&/(?:webworker|worker)(\.|\b).*\.(js|ts)\b/.test(t.replace("?url",""))?"worker/[name][ext]":"assets/[name][hash][ext]"},library:{name:h,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${h}`,pathinfo:b,clean:!0,publicPath:s,asyncChunks:!0,charset:!0};let P={main:j("@app/entry")};l.polyfill&&Object.assign(P,{"dom-polyfills":[`${p.corePath}/polyfills/replace-children.js`]}),l.entry&&("string"==typeof l.entry?P={main:l.entry}:Object.keys(l.entry)&&Object.assign(P,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let B=l.basename.split("/").filter(Boolean).length,D=`${Array(B).fill("..").join("/")+(B?"/":"")}404.html`,{pathSegmentsToKeep:M=B,path:R=D}=l.fixBrowserRouter||{},A=!1;l.cacheDirectory&&(A={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:l.cacheDirectory,memoryCacheUnaffected:!0,name:[c,process.env.NODE_ENV].filter(Boolean).join("-"),version:d});let H=Object.assign({original:l.alias["@"],override:c&&w(c)},l.overrideResolve);export const clientConfig={entry:P,stats:"errors-only",cache:A,infrastructureLogging:{level:"error"},target:"web",externalsPresets:l.externalsPresets,plugins:[new f(v),new k,...a,l.htmlPluginOption&&new t(n),l.fixBrowserRouter&&new t({filename:R,inject:!1,templateContent:()=>`<html lang="en"><head><title>${n.title}</title><script>const pathKeep = ${M||B};const l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new e($),y&&new m(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new x({"process.env":JSON.stringify(l.env)}),new O({paths:[/\.d\.ts$/]}),l.sourceMap&&new C(l.sourceMap),l.bar&&new r(l.bar),...l.plugins].filter(e=>!!e),experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:b&&{imports:!1,entries:!1},buildHttp:l.buildHttp,backCompat:!0,futureDefaults:!1,css:!1,outputModule:!1},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:l.alias,plugins:[l.overrideResolve&&new u(H),...l.resolvePlugins].filter(Boolean),fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:i,externals:l.externals,output:outputConfig};
1
+ import e from"add-asset-html-webpack-plugin";import t from"html-webpack-plugin";import o from"webpack";import{CONFIG as l,PUBLICPATH as r}from"./config.js";import s from"./html-plugin-option.js";import{moduleFederation as n}from"./module-federation.js";import i from"./module.config.js";import a,{CUSTOMCONFIG as p}from"./paths.js";import c from"./plugin/add-entry-attribute.js";import m from"./plugin/override-resolve.js";import u from"./plugin/virtual-module.js";import{PACKAGENAME as f,PACKAGEVERSION as h,isDev as d,isLibrary as g,isMicro as y}from"./process-env.js";import{resolveNodeModulesPath as b,resolveProgramPath as j}from"./utils.js";import w from"./virtual-modules.js";let{AutomaticPrefetchPlugin:v,DefinePlugin:k,SourceMapDevToolPlugin:x,WatchIgnorePlugin:C}=o,O=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:j(g?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${d?"name":"chunkhash"}].js`,assetModuleFilename:e=>{let t=e.filename;return t&&t.endsWith("?url")&&/(?:webworker|worker)(\.|\b).*\.(js|ts)\b/.test(t.replace("?url",""))?"worker/[name][ext]":"assets/[name][hash][ext]"},library:{name:f,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${f}`,pathinfo:d,clean:!0,publicPath:r,asyncChunks:!0,charset:!0};let $={main:b("@app/entry")};l.polyfill&&Object.assign($,{"dom-polyfills":[`${a.corePath}/polyfills/replace-children.js`]}),l.entry&&("string"==typeof l.entry?$={main:l.entry}:Object.keys(l.entry)&&Object.assign($,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let P=l.basename.split("/").filter(Boolean).length,B=`${Array(P).fill("..").join("/")+(P?"/":"")}404.html`,{pathSegmentsToKeep:D=P,path:M=B}=l.fixBrowserRouter||{},R=!1;l.cacheDirectory&&(R={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:l.cacheDirectory,memoryCacheUnaffected:!0,name:[p,process.env.NODE_ENV].filter(Boolean).join("-"),version:h});let A=Object.assign({original:l.alias["@"],override:p&&j(p)},l.overrideResolve);export const clientConfig={entry:$,stats:"errors-only",cache:R,infrastructureLogging:{level:"error"},target:"web",externalsPresets:l.externalsPresets,plugins:[new u(w),new v,...n,l.htmlPluginOption&&new t(s),l.fixBrowserRouter&&new t({filename:M,inject:!1,templateContent:()=>`<html lang="en"><head><title>${s.title}</title><script>const pathKeep = ${D||P};const l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new e(O),y&&new c(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new k({"process.env":JSON.stringify(l.env)}),new C({paths:[/\.d\.ts$/]}),l.sourceMap&&new x(l.sourceMap),...l.plugins].filter(e=>!!e),experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:d&&{imports:!1,entries:!1},buildHttp:l.buildHttp,backCompat:!0,futureDefaults:!1,css:!1,outputModule:!1},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:l.alias,plugins:[l.overrideResolve&&new m(A),...l.resolvePlugins].filter(Boolean),fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:i,externals:l.externals,output:outputConfig};
package/lib/config.js CHANGED
@@ -1 +1 @@
1
- import{accessSync as e,constants as t}from"fs";import o from"chalk";import{merge as s}from"webpack-merge";import i,{CUSTOMCONFIG as a}from"./paths.js";import{PACKAGENAME as n,coreName as r,isLibrary as l,isMobile as c,jsxImportSource as m,mainDirectory as p}from"./process-env.js";import{isFunction as u,log as h,readConf as d,resolveProgramPath as f}from"./utils.js";let g=["@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"],P={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{NODE_ENV:process.env.NODE_ENV},basename:"/",publicPath:"/",rem:{designSize:c?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":f(p)},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:i.webpackCachePath,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`node_modules/${r}/template/index.html`,favicon:`node_modules/${r}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:{chunks:"all",minSize:1024,minChunks:1,cacheGroups:{route:{test:/[\\/].git[\\/]router/,priority:-10,reuseExistingChunk:!0,name:"route"},example:{test:/[\\/].git[\\/]example/,priority:-10,reuseExistingChunk:!0,name:"example"}}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:g,js:g,media:g,font:g,wasm:[]},mdx:{jsxImportSource:m,useDynamicImport:!0,remarkPlugins:[],rehypePlugins:[]},jsxDomExpressions:{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1},bar:{name:"Client",color:"#6f42c1"},virtualModule:{},normalizeCss:!0,externalsPresets:{},buildHttp:{allowedUris:[],lockfileLocation:`${i.httpCachePath}/http.lock`,cacheLocation:`${i.httpCachePath}/data`,upgrade:!0}};l&&(P.alias=Object.assign(P.alias,{"@pkg":i.componentsPath,[n]:i.componentsPath}));let x=P,C={},w={};try{e(i.configPath,t.R_OK);let o=(await d(i.configPath,"index")).default;C=u(o)?o(process):o}catch(e){h(o.red(e))}if(a)try{e(i.customConfigPath,t.R_OK);let o=(await d(i.customConfigPath,a)).default;w=u(o)?o(process):o}catch(e){h(o.red(e))}"tsc"===(x=s(x,C,w)).compiler&&x.minifier&&(x.minifier.js||Object.assign(x.minifier,{js:{type:"terser"}}),x.minifier.css||Object.assign(x.minifier,{css:{type:"cssnano"}})),!1===x.devtool&&(x.sourceMap=!1),!1===x.sourceMap&&(x.devtool=!1),x.fixBrowserRouter&&x.htmlPluginOption&&(x.htmlPluginOption.tags||(x.htmlPluginOption.tags=[]),x.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=x;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,CUSTOMCONFIG:a,log:h};
1
+ import{accessSync as e,constants as t}from"fs";import o from"chalk";import{merge as s}from"webpack-merge";import i,{CUSTOMCONFIG as a}from"./paths.js";import{FRAMEWORK as n,PACKAGENAME as r,coreName as l,isDev as c,isLibrary as m,isMobile as p,jsxImportSource as u,mainDirectory as d}from"./process-env.js";import{isFunction as h,log as f,readConf as g,resolveProgramPath as x}from"./utils.js";let C=["@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"],P={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{NODE_ENV:process.env.NODE_ENV},basename:"/",publicPath:"/",rem:{designSize:p?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":x(d)},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:i.webpackCachePath,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`node_modules/${l}/template/index.html`,favicon:`node_modules/${l}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:{chunks:"all",minSize:1024,minChunks:1,cacheGroups:{route:{test:/[\\/].git[\\/]router/,priority:-10,reuseExistingChunk:!0,name:"route"},example:{test:/[\\/].git[\\/]example/,priority:-10,reuseExistingChunk:!0,name:"example"}}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:C,js:C,media:C,font:C,wasm:[]},mdx:{jsx:!1,development:c,jsxImportSource:u,providerImportSource:`@moneko/${n}/mdx`},jsxDomExpressions:{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1},bar:{name:"Client",color:"#6f42c1"},virtualModule:{},normalizeCss:!0,externalsPresets:{},buildHttp:{allowedUris:[],lockfileLocation:`${i.httpCachePath}/http.lock`,cacheLocation:`${i.httpCachePath}/data`,upgrade:!0}};m&&(P.alias=Object.assign(P.alias,{"@pkg":i.componentsPath,[r]:i.componentsPath}));let w=P,b={},k={};try{e(i.configPath,t.R_OK);let o=(await g(i.configPath,"index")).default;b=h(o)?o(process):o}catch(e){f(o.red(e))}if(a)try{e(i.customConfigPath,t.R_OK);let o=(await g(i.customConfigPath,a)).default;k=h(o)?o(process):o}catch(e){f(o.red(e))}"tsc"===(w=s(w,b,k)).compiler&&w.minifier&&(w.minifier.js||Object.assign(w.minifier,{js:{type:"terser"}}),w.minifier.css||Object.assign(w.minifier,{css:{type:"cssnano"}})),!1===w.devtool&&(w.sourceMap=!1),!1===w.sourceMap&&(w.devtool=!1),w.fixBrowserRouter&&w.htmlPluginOption&&(w.htmlPluginOption.tags||(w.htmlPluginOption.tags=[]),w.htmlPluginOption.tags.push({textContent:"(function(l) {if (l.search[1] === '/' ) {var decoded = l.search.slice(1).split('&').map(function(s) {return s.replace(/~and~/g, '&')}).join('?');window.history.replaceState(null, null,l.pathname.slice(0, -1) + decoded + l.hash);}}(window.location))"}));export const CONFIG=w;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,CUSTOMCONFIG:a,log:f};
package/lib/dev.js CHANGED
@@ -1,3 +1,3 @@
1
- import{readdirSync as e}from"fs";import t from"chalk";import o from"webpack";import s from"webpack-dev-server";import{merge as r}from"webpack-merge";import{clientConfig as l}from"./common.js";import{CONFIG as i}from"./config.js";import{hasPkg as n}from"./has-pkg.js";import{getIPv4 as a,getPort as c}from"./net.js";import p from"./paths.js";import{hasEslintConfig as m,hasStylelintConfig as d,isLibrary as u,isReact as f}from"./process-env.js";import{cleanDir as h,isFunction as v,log as w,resolveProgramPath as g}from"./utils.js";let{HotModuleReplacementPlugin:j}=o,{yellow:k,green:y,grey:$,gray:x,bgBlue:b,bgGreenBright:S,blueBright:T,greenBright:C}=t,A=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],B=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],D=e(p.programPath),E=!1,H=!1;for(let e=0,t=D.length;e<t;e++)B.includes(D[e])&&(H=!0),A.includes(D[e])&&(E=!0);E||(E=m),H||(H=d);let M=H?(await import("stylelint-webpack-plugin")).default:null,O=E?(await import("eslint-webpack-plugin")).default:null,P=i.devServer.port||3e3,_=await c(P,65535,i.devServer.host),I=n("@moneko/mock"),J=I&&(await import("@moneko/mock")).default,N=f&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,W=!1===i.devtool||i.devtool?i.devtool:"eval-cheap-module-source-map";i.devServer.port=_;let F="/"===i.basename,G=i.devServer.https?"https:":"http:",L=F?"":i.basename,R=i.devServer.port!==_&&x(`Port ${k(P)} is in use, trying ${y(_)} instead.
2
- `);function Y(e){return`${G}//${"local"===e?i.devServer.host:a()}:${_}${L}`}let q=x("You application is running here:"),z=`${b(" Local ")} ${T(Y("local"))}
3
- ${S(" Network ")} ${C(Y("net"))}`,K=["js","md","mdx","jsx","ts","tsx","json","html","vue"],Q=K.join(","),U=["css","scss","sass","less","ts","tsx","js","jsx"],V=U.join(","),X=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],Z=[O&&new O({fix:!0,threads:!0,files:[`${i.alias["@"]}/**/*.{${Q}}`,u&&`${i.alias["@pkg"]}/**/*.{${Q}}`].filter(Boolean),extensions:K,exclude:X,cache:!1,lintDirtyModulesOnly:!0}),M&&new M({fix:!0,threads:!0,files:[`${i.alias["@"]}/**/*.{${V}}`,u&&`${i.alias["@pkg"]}/**/*.{${V}}`].filter(Boolean),extensions:U,exclude:X,cache:!1,lintDirtyModulesOnly:!0}),new j,N&&new N].filter(Boolean),ee={headers:{"Access-Control-Allow-Origin":"*"},compress:i.devServer.compress,host:"0.0.0.0",port:_,historyApiFallback:F||{index:L.endsWith("/")?L:`${L}/`,disableDotRule:!0},https:i.devServer.https,proxy:i.proxy,allowedHosts:i.devServer.allowedHosts,client:{reconnect:!0,progress:!1,logging:"info",overlay:!1,webSocketTransport:"ws"},webSocketServer:"ws",static:{watch:{ignored:e=>e.endsWith(".d.ts")||e.includes("/node_modules/")}},setupMiddlewares:(e,t)=>{if(!t)throw Error("devServer is not defined");return t.app&&v(J)&&J(t.app,g("mock/")),e},open:!1,hot:!0},et=o(r(l,{devtool:W,mode:"development",plugins:Z}));et.watch({aggregateTimeout:600,ignored:/node_modules/,stdin:!0},(e,t)=>{!e&&t&&(process.stdout.write("\x1b[2J\x1b[3J\x1b[H"),w([q,"",z,"",$(`Compiled successfully in ${y(`${t.endTime-t.startTime}ms`)}`)]),t.compilation.warnings.forEach(e=>w(e.message)),t.compilation.errors.forEach(e=>w(e.message)),R&&w(R))});let eo=new s(ee,et);eo.startCallback(e=>{e||w([q,"",z])}),eo.stopCallback(e=>{e||h(p.cachePath)}),process.on("exit",function(){et.close(()=>{}),eo.invalidate(),eo.stop()}),process.on("SIGINT",()=>{process.exit()});
1
+ import{readdirSync as e}from"fs";import t from"chalk";import o from"webpack";import s from"webpack-dev-server";import{merge as r}from"webpack-merge";import l from"webpackbar";import{clientConfig as i}from"./common.js";import{CONFIG as n}from"./config.js";import{hasPkg as a}from"./has-pkg.js";import{getIPv4 as c,getPort as p}from"./net.js";import m from"./paths.js";import{hasEslintConfig as d,hasStylelintConfig as f,isLibrary as u,isReact as h}from"./process-env.js";import{cleanDir as v,isFunction as w,log as g,resolveProgramPath as b}from"./utils.js";let{HotModuleReplacementPlugin:k}=o,{yellow:j,green:y,grey:$,gray:x,bgBlue:S,bgGreenBright:T,blueBright:C,greenBright:A}=t,B=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],D=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],E=e(m.programPath),H=!1,M=!1;for(let e=0,t=E.length;e<t;e++)D.includes(E[e])&&(M=!0),B.includes(E[e])&&(H=!0);H||(H=d),M||(M=f);let O=M?(await import("stylelint-webpack-plugin")).default:null,P=H?(await import("eslint-webpack-plugin")).default:null,_=n.devServer.port||3e3,I=await p(_,65535,n.devServer.host),J=a("@moneko/mock")&&(await import("@moneko/mock")).default,N=h&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,W=!1===n.devtool||n.devtool?n.devtool:"eval-cheap-module-source-map";n.devServer.port=I;let F="/"===n.basename,G=n.devServer.https?"https:":"http:",L=F?"":n.basename,R=n.devServer.port!==I&&x(`Port ${j(_)} is in use, trying ${y(I)} instead.
2
+ `);function Y(e){return`${G}//${"local"===e?n.devServer.host:c()}:${I}${L}`}let q=x("You application is running here:"),z=`${S(" Local ")} ${C(Y("local"))}
3
+ ${T(" Network ")} ${A(Y("net"))}`,K=["js","md","mdx","jsx","ts","tsx","json","html","vue"],Q=K.join(","),U=["css","scss","sass","less","ts","tsx","js","jsx"],V=U.join(","),X=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],Z=[new k,N&&new N,P&&new P({fix:!0,threads:!0,files:[`${n.alias["@"]}/**/*.{${Q}}`,u&&`${n.alias["@pkg"]}/**/*.{${Q}}`].filter(Boolean),extensions:K,exclude:X,cache:!1,lintDirtyModulesOnly:!0}),O&&new O({fix:!0,threads:!0,files:[`${n.alias["@"]}/**/*.{${V}}`,u&&`${n.alias["@pkg"]}/**/*.{${V}}`].filter(Boolean),extensions:U,exclude:X,cache:!1,lintDirtyModulesOnly:!0}),n.bar&&new l(n.bar)].filter(Boolean),ee={headers:{"Access-Control-Allow-Origin":"*"},compress:n.devServer.compress,host:"0.0.0.0",port:I,historyApiFallback:F||{index:L.endsWith("/")?L:`${L}/`,disableDotRule:!0},https:n.devServer.https,proxy:n.proxy,allowedHosts:n.devServer.allowedHosts,client:{reconnect:!0,progress:!1,logging:"info",overlay:!1,webSocketTransport:"ws"},webSocketServer:"ws",static:{watch:{ignored:e=>e.endsWith(".d.ts")||e.includes("/node_modules/")}},setupMiddlewares:(e,t)=>{if(!t)throw Error("devServer is not defined");return t.app&&w(J)&&J(t.app,b("mock/")),e},open:!1,hot:!0},et=o(r(i,{devtool:W,mode:"development",plugins:Z}));et.watch({aggregateTimeout:600,ignored:/node_modules/,stdin:!0},(e,t)=>{!e&&t&&(process.stdout.write("\x1b[2J\x1b[3J\x1b[H"),g([q,"",z,"",$(`Compiled successfully in ${y(`${t.endTime-t.startTime}ms`)}`)]),t.compilation.warnings.forEach(e=>g(e.message)),t.compilation.errors.forEach(e=>g(e.message)),R&&g(R))});let eo=new s(ee,et);eo.startCallback(e=>{e||g([q,"",z])}),eo.stopCallback(e=>{e||v(m.cachePath)}),process.on("exit",function(){et.close(()=>{}),eo.invalidate(),eo.stop()}),process.on("SIGINT",()=>{process.exit()});
@@ -1 +1 @@
1
- import{readFileSync as e}from"fs";import{dirname as t}from"path";import n from"typescript";import{CONFIG as r}from"./config.js";let{ScriptKind:l,ScriptTarget:o,SyntaxKind:i,createSourceFile:c,forEachChild:a,getLeadingCommentRanges:u,isInterfaceDeclaration:s,isQuestionToken:f,isPropertySignature:p,isFunctionTypeNode:m,isUnionTypeNode:g,isMethodSignature:$}=n,h={};function b(e){let t=u(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.substring(t[0].pos,t[0].end),r=n.match(/\/\*\*([\s\S]*?)\*\//);if(r)return r[1].replace(/^\s*\* ?/gm,"").replace(/\s+$/,"").trim()}return null}function d(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function y(e){if(!e)return null;let t=e.match(/@author (\w+)\s*(?:<([^>]+)>)?/);if(t?.length){let e=t[1].trim(),n=t[2]?.trim(),r=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(n);return n?r&&(n=`mailto:${n}`):n=`https://github.com/${e}`,`[![${e}](https://avatars.githubusercontent.com/${e}?s=64)${e}](${n})`}return null}function x(e){if(!e)return null;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():null}let j=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function T(e,t){if(!e)return null;let n=e.replace(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if(h[e]){let n=`/${[r.basename,h[e]].join("/").split("/").filter(Boolean).join("/")}`;return t?`[\\color{#009688}{${e}}](${n})`:`[${e}](${n})`}return t?`\\color{#009688}{${e}}`:e});return t&&(n=n.replace(j,e=>`\\color{#009688}{${e}}`)),n}function B(e){return(function(e){let t;if(!e)return null;let n=[];for(;t=/\\color{([^|}]*)\|?([^|}]*)\|?([^|}]*)\|?([^}]*)}{([^}]*)}/g.exec(e);)n.push(t[0]);return e.replace(/[{}[\]()=>]|keyof|typeof|true|false/g,e=>n.some(t=>t.includes(e))?e:`\\color{#569cd6}{${e}}`)})(e)?.replace(/^\s*\|\s*|\s*\|\s*$/gm,"").replace(/\n/g,"<br/>").replace(/\*/g,"\\*").replace(/\|/g,"\\|").replace(/(['"])((?:(?!\1).)*)\1/g,"\\color{#ce9178}{$1$2$1}")}function k(e){return e?e.replace(/^@[a-z].+/gm,"").replace(/(\n\s+)+/g,"<br />").replace(/\n/g,"<br />").replace(/(<br \/>)$/g,""):null}export default function w(u){let j=e(u,{encoding:"utf-8"}),w=c(u,j,o.Latest,!0,l.TS),E="";return a(w,e=>{s(e)?E+=function(e){let l=e.name.text;Object.assign(h,{[e.name.text]:t(e.getSourceFile().fileName).replace(r.alias["@pkg"],"")});let o=b(e),c=d(o),a=k(o),u=x(o)?.split("|")||[],s=u.includes("comment"),j=u.includes("initial"),w=u.includes("optional"),E=u.includes("version"),S=u.includes("author"),v=a?`\\color{|4||0.45}{${l}}`:l,F=(function(e){let t=[];if(e.heritageClauses){for(let r of e.heritageClauses)if(r.token===n.SyntaxKind.ExtendsKeyword)for(let e of r.types)t.push(e.getText())}return t})(e)?.map(e=>`<n-tag color="#4c81db" css=".tag{gap:0px;}">${T(B(e))}</n-tag>`),z=[a,v,c&&`\\color{#52c11b|1||0.9}{${c}}`,F.length>0&&`<sub>\`extends\`</sub> ${F.join(" ")}`].filter(Boolean).join(" "),K=`## ${z}`,N=e.members.filter(e=>p(e)&&e.type?.kind!==i.NeverKeyword||$(e)),q=[];if(N.length){N.forEach(e=>{let t=T(B($(e)?`(${e.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${e.type?.getText()||"any"}`:e.type?.getText()||"any"),!0),n=b(e),r=B(e.name.getText());!r||r.startsWith("\\color")||($(e)||function(e){if(e.type){if(!g(e.type))return m(e.type);for(let t of e.type.types)if(m(t))return!0}return!1}(e)||t?.includes("=>")?r=`\\color{#f9a913}{${r}}`:/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`));let l=e.questionToken&&f(e.questionToken);q.push([r,!w&&`\\color{${l?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${l?"✘":"✔"}}`,!s&&B(k(n)),t,!j&&B(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(n)),!E&&B(d(n)),!S&&(y(n)||y(o))])});let e=!1,t=!1,n=!1,r=!1;q.forEach(l=>{!s&&l[2]&&(r=!0),!j&&l[4]&&(n=!0),!E&&l[5]&&(t=!0),!S&&l[6]&&(e=!0)}),K+="\n";let l=["属性",!w&&"必要",r&&"说明","类型",n&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");K+=`|${l}|`;let i=[":-",!w&&":-",r&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);K+="\n";let c=i.join("|");K+=`|${c}|`,q.forEach(l=>{K+="\n";let o=[l[0]||"-",!w&&(l[1]||"-"),r&&(l[2]||"-"),l[3]||"-",n&&(l[4]||"-"),t&&(l[5]||"-"),e&&(l[6]||"-")].filter(Boolean).join("|");K+=`|${o}|`}),K+="\n"}return K+="\n"}(e):n.isEnumDeclaration(e)&&(E+=function(e){let l=e.name.text,o=b(e),i=k(o),c=d(o);Object.assign(h,{[e.name.text]:t(e.getSourceFile().fileName).replace(r.alias["@pkg"],"")});let a=i?`\\color{|4||0.45}{${l}}`:l,u=[i,a,c&&`\\color{#52c11b|1||0.9}{${c}}`].filter(Boolean).join(" "),s=x(o)?.split("|")||[],f=s.includes("comment"),p=s.includes("version"),m=s.includes("author"),g=`## ${u}`;if(e.members.length){let t=[];e.members.forEach(e=>{let r=B(e.name.getText()),l=b(e),i=B(function(e){let t=e.initializer;return t&&n.isStringLiteral(t)?` '${t.text}'`:null}(e)),c=B(d(l)),a=B(k(l));!r||r.startsWith("\\color")||/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`),t.push([r,!f&&a,i,!p&&c,!m&&(y(l)||y(o))])});let r=!1,l=!1,i=!1;t.forEach(e=>{!f&&e[1]&&(i=!0),!p&&e[3]&&(l=!0),!m&&e[4]&&(r=!0)}),g+="\n";let c=["属性",i&&"说明","值",l&&"版本",r&&"作者"].filter(Boolean).join("|");g+=`|${c}|`;let a=[":-",i&&":-",":-",l&&":-",r&&":-"].filter(Boolean);g+="\n";let u=a.join("|");g+=`|${u}|`,t.forEach(e=>{g+="\n";let t=[e[0]||"-",i&&(e[1]||"-"),e[2]||"-",l&&(e[3]||"-"),r&&(e[4]||"-")].filter(Boolean).join("|");g+=`|${t}|`})}return g+="\n\n"}(e))}),E}
1
+ import{readFileSync as e}from"fs";import{dirname as t}from"path";import n from"typescript";import{CONFIG as r}from"./config.js";let{ScriptKind:l,ScriptTarget:o,SyntaxKind:i,createSourceFile:c,forEachChild:a,getLeadingCommentRanges:u,isInterfaceDeclaration:s,isQuestionToken:f,isPropertySignature:p,isFunctionTypeNode:m,isUnionTypeNode:g,isMethodSignature:$}=n,h={};function b(e){let t=u(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.substring(t[0].pos,t[0].end).match(/\/\*\*([\s\S]*?)\*\//);if(n)return n[1].replace(/^\s*\* ?/gm,"").replace(/\s+$/,"").trim()}return null}function d(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function y(e){if(!e)return null;let t=e.match(/@author (\w+)\s*(?:<([^>]+)>)?/);if(t?.length){let e=t[1].trim(),n=t[2]?.trim(),r=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(n);return n?r&&(n=`mailto:${n}`):n=`https://github.com/${e}`,`[![${e}](https://avatars.githubusercontent.com/${e}?s=64)${e}](${n})`}return null}function x(e){if(!e)return null;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():null}let j=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function T(e,t){if(!e)return null;let n=e.replace(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if(h[e]){let n=`/${[r.basename,h[e]].join("/").split("/").filter(Boolean).join("/")}`;return t?`[\\color{#009688}{${e}}](${n})`:`[${e}](${n})`}return t?`\\color{#009688}{${e}}`:e});return t&&(n=n.replace(j,e=>`\\color{#009688}{${e}}`)),n}function B(e){return(function(e){let t;if(!e)return null;let n=[];for(;t=/\\color{([^|}]*)\|?([^|}]*)\|?([^|}]*)\|?([^}]*)}{([^}]*)}/g.exec(e);)n.push(t[0]);return e.replace(/[{}[\]()=>]|keyof|typeof|true|false/g,e=>n.some(t=>t.includes(e))?e:`\\color{#569cd6}{${e}}`)})(e)?.replace(/^\s*\|\s*|\s*\|\s*$/gm,"").replace(/\n/g,"<br/>").replace(/\*/g,"\\*").replace(/\|/g,"\\|").replace(/(['"])((?:(?!\1).)*)\1/g,"\\color{#ce9178}{$1$2$1}")}function k(e){return e?e.replace(/^@[a-z].+/gm,"").replace(/(\n\s+)+/g,"<br />").replace(/\n/g,"<br />").replace(/(<br \/>)$/g,""):null}export default function w(u){let j=e(u,{encoding:"utf-8"}),w=c(u,j,o.Latest,!0,l.TS),E="";return a(w,e=>{s(e)?E+=function(e){let l=e.name.text;Object.assign(h,{[e.name.text]:t(e.getSourceFile().fileName).replace(r.alias["@pkg"],"")});let o=b(e),c=d(o),a=k(o),u=x(o)?.split("|")||[],s=u.includes("comment"),j=u.includes("initial"),w=u.includes("optional"),E=u.includes("version"),S=u.includes("author"),v=a?`\\color{|4||0.45}{${l}}`:l,F=(function(e){let t=[];if(e.heritageClauses){for(let r of e.heritageClauses)if(r.token===n.SyntaxKind.ExtendsKeyword)for(let e of r.types)t.push(e.getText())}return t})(e)?.map(e=>`<n-tag color="#4c81db" css=".tag{gap:0px;}">${T(B(e))}</n-tag>`),z=[a,v,c&&`\\color{#52c11b|1||0.9}{${c}}`,F.length>0&&`<sub>\`extends\`</sub> ${F.join(" ")}`].filter(Boolean).join(" "),K=`## ${z}`,N=e.members.filter(e=>p(e)&&e.type?.kind!==i.NeverKeyword||$(e)),q=[];if(N.length){N.forEach(e=>{let t=T(B($(e)?`(${e.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${e.type?.getText()||"any"}`:e.type?.getText()||"any"),!0),n=b(e),r=B(e.name.getText());!r||r.startsWith("\\color")||($(e)||function(e){if(e.type){if(!g(e.type))return m(e.type);for(let t of e.type.types)if(m(t))return!0}return!1}(e)||t?.includes("=>")?r=`\\color{#f9a913}{${r}}`:/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`));let l=e.questionToken&&f(e.questionToken);q.push([r,!w&&`\\color{${l?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${l?"✘":"✔"}}`,!s&&B(k(n)),t,!j&&B(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(n)),!E&&B(d(n)),!S&&(y(n)||y(o))])});let e=!1,t=!1,n=!1,r=!1;q.forEach(l=>{!s&&l[2]&&(r=!0),!j&&l[4]&&(n=!0),!E&&l[5]&&(t=!0),!S&&l[6]&&(e=!0)}),K+="\n";let l=["属性",!w&&"必要",r&&"说明","类型",n&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");K+=`|${l}|`;let i=[":-",!w&&":-",r&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);K+="\n";let c=i.join("|");K+=`|${c}|`,q.forEach(l=>{K+="\n";let o=[l[0]||"-",!w&&(l[1]||"-"),r&&(l[2]||"-"),l[3]||"-",n&&(l[4]||"-"),t&&(l[5]||"-"),e&&(l[6]||"-")].filter(Boolean).join("|");K+=`|${o}|`}),K+="\n"}return K+="\n"}(e):n.isEnumDeclaration(e)&&(E+=function(e){let l=e.name.text,o=b(e),i=k(o),c=d(o);Object.assign(h,{[e.name.text]:t(e.getSourceFile().fileName).replace(r.alias["@pkg"],"")});let a=i?`\\color{|4||0.45}{${l}}`:l,u=[i,a,c&&`\\color{#52c11b|1||0.9}{${c}}`].filter(Boolean).join(" "),s=x(o)?.split("|")||[],f=s.includes("comment"),p=s.includes("version"),m=s.includes("author"),g=`## ${u}`;if(e.members.length){let t=[];e.members.forEach(e=>{let r=B(e.name.getText()),l=b(e),i=B(function(e){let t=e.initializer;return t&&n.isStringLiteral(t)?` '${t.text}'`:null}(e)),c=B(d(l)),a=B(k(l));!r||r.startsWith("\\color")||/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`),t.push([r,!f&&a,i,!p&&c,!m&&(y(l)||y(o))])});let r=!1,l=!1,i=!1;t.forEach(e=>{!f&&e[1]&&(i=!0),!p&&e[3]&&(l=!0),!m&&e[4]&&(r=!0)}),g+="\n";let c=["属性",i&&"说明","值",l&&"版本",r&&"作者"].filter(Boolean).join("|");g+=`|${c}|`;let a=[":-",i&&":-",":-",l&&":-",r&&":-"].filter(Boolean);g+="\n";let u=a.join("|");g+=`|${u}|`,t.forEach(e=>{g+="\n";let t=[e[0]||"-",i&&(e[1]||"-"),e[2]||"-",l&&(e[3]||"-"),r&&(e[4]||"-")].filter(Boolean).join("|");g+=`|${t}|`})}return g+="\n\n"}(e))}),E}
package/lib/index.d.ts CHANGED
@@ -3,4 +3,6 @@ export { FRAMEWORKNAME, PACKAGENAME, PACKAGEVERSION, coreName, isDev, isLibrary,
3
3
  export { realResolve, resolveNodeModulesPath, resolveProgramPath, log } from './utils.js';
4
4
  export { getIPv4, getPort } from './net.js';
5
5
  export { default as osTmpDir } from './os-tmp-dir.js';
6
+ export type { MdxOptions } from '@moneko/mdx';
7
+ export type { OverrideResolverOption } from './plugin/override-resolve.js';
6
8
  export type * from '../typings/global.d.ts';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return t}});const e=require("@moneko/mdx");function t(t){let n=this.async();(0,e.mdx)({value:t,filepath:this.resourcePath,...this.getOptions()}).then(e=>{n(null,e.code)}).catch(n)}
@@ -0,0 +1,3 @@
1
+ import { type MdxOptions } from '@moneko/mdx';
2
+ import type { LoaderContext } from 'webpack';
3
+ export default function (this: LoaderContext<Omit<MdxOptions, 'value'>>, value: string): void;
@@ -1 +1 @@
1
- import e from"external-remotes-plugin";import r from"webpack";import t from"webpack/lib/container/ModuleFederationPlugin.js";import{CONFIG as o}from"./config.js";import{realResolve as l}from"./utils.js";let i=r.NormalModuleReplacementPlugin,a={},n={},s={};export const moduleFederation=o.moduleFederation?.map(e=>{if(Array.isArray(e.remotes))for(let r=0,t=e.remotes.length;r<t;r++){let t=e.remotes[r],o=t.alias||t.name,l=t.filename||"remote_entry.js";if(s[o]=`${t.name}@${t.host}/${l}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)a[t.library[e]]=`${o}/${t.library[e]}`}if(Array.isArray(e.exposes))for(let r=0,t=e.exposes.length;r<t;r++){let t=e.exposes[r];"string"==typeof t?n[`./${t}`]=l(t):"[object Object]"===Object.prototype.toString.call(t)&&(n[`./${t.name}`]=l(t.path))}return new t({filename:"remote_entry.js",...e,remotes:s,exposes:n})});moduleFederation.length&&(moduleFederation.push(new e),moduleFederation.push(new i(/(.*)/,e=>{a[e.request]&&(e.request=a[e.request])})));
1
+ import e from"webpack";import r from"webpack/lib/container/ModuleFederationPlugin.js";import{CONFIG as t}from"./config.js";import o from"./plugin/external-remotes.js";import{realResolve as l}from"./utils.js";let i=e.NormalModuleReplacementPlugin,a={},n={},s={};export const moduleFederation=t.moduleFederation?.map(e=>{if(Array.isArray(e.remotes))for(let r=0,t=e.remotes.length;r<t;r++){let t=e.remotes[r],o=t.alias||t.name,l=t.filename||"remote_entry.js";if(s[o]=`${t.name}@${t.host}/${l}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)a[t.library[e]]=`${o}/${t.library[e]}`}if(Array.isArray(e.exposes))for(let r=0,t=e.exposes.length;r<t;r++){let t=e.exposes[r];"string"==typeof t?n[`./${t}`]=l(t):"[object Object]"===Object.prototype.toString.call(t)&&(n[`./${t.name}`]=l(t.path))}return new r({filename:"remote_entry.js",...e,remotes:s,exposes:n})});moduleFederation.length&&(moduleFederation.push(new o),moduleFederation.push(new i(/(.*)/,e=>{a[e.request]&&(e.request=a[e.request])})));
@@ -1 +1 @@
1
- import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as o}from"./config.js";import{hasPkg as r}from"./has-pkg.js";import a from"./modify-vars.js";import l,{CUSTOMCONFIG as i}from"./paths.js";import{FRAMEWORK as n,isDev as c,isLibrary as m,isMicro as d}from"./process-env.js";import p from"./swcrc.js";import u from"./tsloader.config.js";import{resolveNodeModulesPath as f,resolveProgramPath as y}from"./utils.js";let x={loader:`${l.corePath}/loader/css-unicode.cjs`},$=d?o:"../",g={loader:e.loader,options:{publicPath:"/"!==$?$:"../"}},j=r("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:(await import("@moneko/postcss")).default}};c&&(g="style-loader");let w=[...t.cssModules,`@moneko/${n}`,"neko-ui"].map(f),v=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(y)],b=["components","example","mock","site","src","server"].map(y);i&&b.push(y(i));let h={loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,t=w.length;s<t;s++)if(e&&e?.includes(w[s]))return/(.*(?<!\.?global\.(le|c|sc|sa)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c|sc|sa)ss)$)/i.test(e)},localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},k=c&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!c}},O=[g,k,h,j,x,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:v}}].filter(Boolean),B="tsc"===t.compiler,L={loader:B?"ts-loader":"swc-loader",options:B?u:p(c)};function P(e){return b.concat(t.rulesInclude?.[e]?.map(f)||[])}let M=P("media"),_={rules:[m&&{test:/\.mdx?$/i,include:[l.componentsPath],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:`${l.corePath}/loader/frontmatter.cjs`}]},{oneOf:[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename:e=>{let s=e.filename;return s&&s.endsWith("wasm?url")?"wasm/[name][ext]":"assets/[name][ext]"}}},{test:/\.wasm$/i,type:"webassembly/async",include:P("wasm")},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:M},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>s(e.toString())},include:M},{test:/\.(gif|png|jpe?g|webp)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext]"},include:M},{test:/\.(webm|mp4|ogv)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[name][ext]"},include:M},{test:/\.(woff2?|eot|ttf|otf)(\?.*)?$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[name][ext]"},include:P("font")},{test:/\.(sa|sc)ss$/i,use:[g,k,h,j,x,{loader:"sass-loader",options:{implementation:await import("sass"),sassOptions:{}}}].filter(Boolean),include:P("css")},{test:/\.less$/i,use:O,include:P("css")},{test:/\.css$/i,use:[g,"css-loader",j,x].filter(Boolean),include:P("css")},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...t.prefixJsLoader,L].filter(Boolean),include:P("js")},{test:/\.mdx?$/i,use:[...t.prefixJsLoader,L,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:b,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/i,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules].filter(e=>"object"==typeof e)};export default _;
1
+ import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as o}from"./config.js";import{hasPkg as r}from"./has-pkg.js";import a from"./modify-vars.js";import l,{CUSTOMCONFIG as i}from"./paths.js";import{FRAMEWORK as n,isDev as c,isMicro as d}from"./process-env.js";import m from"./swcrc.js";import p from"./tsloader.config.js";import{resolveNodeModulesPath as u,resolveProgramPath as f}from"./utils.js";let y={loader:`${l.corePath}/loader/css-unicode.cjs`},x=d?o:"../",g={loader:e.loader,options:{publicPath:"/"!==x?x:"../"}},$=r("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:(await import("@moneko/postcss")).default}};c&&(g="style-loader");let v=[...t.cssModules,`@moneko/${n}`,"neko-ui"].map(u),j=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(f)],w=["components","example","mock","site","src","server"].map(f);i&&w.push(f(i)),t.overrideResolve&&t.overrideResolve.override&&w.push(t.overrideResolve.override);let b={loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,t=v.length;s<t;s++)if(e&&e?.includes(v[s]))return/(.*(?<!\.?global\.(le|c|sc|sa)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c|sc|sa)ss)$)/i.test(e)},localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},h=c&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!c}},k=[g,h,b,$,y,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:j}}].filter(Boolean),O="tsc"===t.compiler,B={loader:O?"ts-loader":"swc-loader",options:O?p:m(c)};function L(e){return w.concat(t.rulesInclude?.[e]?.map(u)||[])}let R=L("media"),M={rules:[{oneOf:[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename:e=>{let s=e.filename;return s&&s.endsWith("wasm?url")?"wasm/[name][ext]":"assets/[name][ext]"}}},{test:/\.wasm$/i,type:"webassembly/async",include:L("wasm")},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:R},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>s(e.toString())},include:R},{test:/\.(gif|png|jpe?g|webp)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext]"},include:R},{test:/\.(webm|mp4|ogv)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[name][ext]"},include:R},{test:/\.(woff2?|eot|ttf|otf)(\?.*)?$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[name][ext]"},include:L("font")},{test:/\.(sa|sc)ss$/i,use:[g,h,b,$,y,{loader:"sass-loader",options:{implementation:await import("sass"),sassOptions:{}}}].filter(Boolean),include:L("css")},{test:/\.less$/i,use:k,include:L("css")},{test:/\.css$/i,use:[g,"css-loader",$,y].filter(Boolean),include:L("css")},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...t.prefixJsLoader,B].filter(Boolean),include:L("js")},{test:/\.mdx?$/i,use:[...t.prefixJsLoader,{loader:`${l.corePath}/loader/mdx.cjs`,options:t.mdx}].filter(Boolean),include:w,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/i,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules].filter(e=>"object"==typeof e)};export default M;
@@ -1 +1 @@
1
- export default class{constructor(t){this.entryMatchCallback=t}apply(t){t.hooks.compilation.tap("AddEntryAttributeWebpackPlugin",a=>{let e=t.options.plugins.map(({constructor:t})=>t).find(t=>t&&"HtmlWebpackPlugin"===t.name);if(e){let t=e.getHooks(a);t.alterAssetTagGroups.tap("AddEntryAttributeWebpackPlugin",t=>(t.headTags.forEach(t=>{"script"===t.tagName&&this.entryMatchCallback(t.attributes.src)&&(t.attributes.entry=!0)}),t))}})}}
1
+ export default class{constructor(t){this.entryMatchCallback=t}apply(t){t.hooks.compilation.tap("AddEntryAttributeWebpackPlugin",a=>{let e=t.options.plugins.map(({constructor:t})=>t).find(t=>t&&"HtmlWebpackPlugin"===t.name);e&&e.getHooks(a).alterAssetTagGroups.tap("AddEntryAttributeWebpackPlugin",t=>(t.headTags.forEach(t=>{"script"===t.tagName&&this.entryMatchCallback(t.attributes.src)&&(t.attributes.entry=!0)}),t))})}}
@@ -6,4 +6,5 @@ declare class DoneWebpackPlugin {
6
6
  });
7
7
  apply(compiler: Compiler): void;
8
8
  }
9
+ export type DonePluginOption = ConstructorParameters<typeof DoneWebpackPlugin>[0]['done'];
9
10
  export default DoneWebpackPlugin;
@@ -1 +1 @@
1
- import{isDev as o}from"../process-env.js";import{vmWriteing as e}from"../reactive-object.js";export default class{constructor(o){this.options=Object.assign({},o)}apply(n){o||n.hooks.compilation.tap("DoneWebpackPlugin",o=>{e.setData("DoneDonePlugin",!0),o.compiler.hooks.done.tap("DoneDonePlugin",()=>{e.setData("DoneDonePlugin",!1)})}),n.hooks.done.tap("DoneWebpackPlugin",o=>{this.options.done(o)})}}
1
+ import{isDev as o}from"../process-env.js";import{vmWriteing as e}from"../reactive-object.js";let t="DoneWebpackPlugin";export default class{constructor(o){this.options=Object.assign({},o)}apply(n){o||n.hooks.compilation.tap(t,o=>{e.setData("DoneDonePlugin",!0),o.compiler.hooks.done.tap("DoneDonePlugin",()=>{e.setData("DoneDonePlugin",!1)})}),n.hooks.done.tap(t,o=>{this.options.done(o)})}}
@@ -0,0 +1,5 @@
1
+ import { type Compiler } from 'webpack';
2
+ declare class ExternalTemplateRemotesPlugin {
3
+ apply(compiler: Compiler): void;
4
+ }
5
+ export default ExternalTemplateRemotesPlugin;
@@ -0,0 +1 @@
1
+ import{Compilation as e,sources as t}from"webpack";import s from"webpack/lib/util/extractUrlAndGlobal.js";let l="ExternalRemotesPlugin";export default class{apply(o){o.hooks.make.tap(l,o=>{let r=[];o.hooks.buildModule.tap(l,e=>{"ExternalModule"===e.constructor.name&&"script"===e.externalType&&r.push(e)}),o.hooks.processAssets.tap({name:l,stage:e.PROCESS_ASSETS_STAGE_ADDITIONS},()=>{r.forEach(e=>{let l=s(e.request)[0],r=function(e){let t=[],s=[],l=!1,o=!1;for(let r of e)if("["===r){if(l){o=!0;break}l=!0,s.length&&(t.push(`"${s.join("")}"`),s.length=0)}else if("]"===r){if(!l){o=!0;break}l=!1,s.length&&(t.push(`${s.join("")}`),s.length=0),s.length=0}else s.push(r);if(l||o)throw Error(`Invalid template URL "${e}"`);return s.length&&t.push(`"${s.join("")}"`),t.join(" + ")}(l),a=o.getAsset(e.userRequest)?.source,n=new t.RawSource(a?.source().replace(`"${l}"`,r));o.updateAsset(e.userRequest,n)})})})}}
@@ -1 +1 @@
1
- import{existsSync as e}from"fs";import{relative as t}from"path";import r from"../paths.js";export default class{constructor(e){this.options=e}apply(i){let{override:a,original:s}=this.options;if(a&&s){let o=`./${t(r.programPath,s)}`,l=`./${t(r.programPath,a)}`;i.getHook("existing-file").tapAsync("OverrideResolverPlugin",(t,r,p)=>{let n=t.request||t.path;if(n&&n.startsWith(s)&&t.relativePath){let h=n.replace(s,a);if(e(h)){let e=t.relativePath.replace(o,l);return Object.assign(t,{path:h,relativePath:e,__innerRequest_relativePath:e,__innerRequest:e}),i.doResolve("resolved",t,`OverrideResolverPlugin 使用目标模块${a}`,r,p)}}return p()})}}}
1
+ import{existsSync as t}from"fs";import{relative as e}from"path";import r from"../paths.js";let a="OverrideResolverPlugin";export default class{constructor(t){this.options=t}apply(i){let{override:s,original:o}=this.options;if(s&&o){let l=`./${e(r.programPath,o)}`,p=`./${e(r.programPath,s)}`;i.getHook("existing-file").tapAsync(a,(e,r,h)=>{let n=e.request||e.path;if(n&&n.startsWith(o)&&e.relativePath){let f=n.replace(o,s);if(t(f)){let t=e.relativePath.replace(l,p);return Object.assign(e,{path:f,relativePath:t,__innerRequest_relativePath:t,__innerRequest:t}),i.doResolve("resolved",e,`${a} 使用目标模块${s}`,r,h)}}return h()})}}}
package/lib/prod.js CHANGED
@@ -1 +1 @@
1
- let e;import i from"css-minimizer-webpack-plugin";import o from"mini-css-extract-plugin";import n from"terser-webpack-plugin";import m from"webpack";import{BundleAnalyzerPlugin as t}from"webpack-bundle-analyzer";import{merge as r}from"webpack-merge";import{clientConfig as s}from"./common.js";import{CONFIG as p}from"./config.js";import{getMinifyOption as l}from"./minify.js";import a from"./paths.js";import c from"./plugin/done.js";import{vmWriteing as u}from"./reactive-object.js";import f from"./seo.js";import{cleanDir as d}from"./utils.js";let{optimize:{MinChunkSizePlugin:h}}=m,{cssnanoMinify:w,swcMinify:k}=i,j="swc"===p.compiler,b=[];p.minifier&&(p.minifier.js&&b.push(new n(l(p.minifier.js?.type||(j?"swc":"terser"),p.minifier.js?.options))),p.minifier.css&&b.push(new i({minify:{swc:k,cssnano:w}[p.minifier.css?.type||(j?"swc":"cssnano")],minimizerOptions:p.minifier.css?.options})));let y={splitChunks:p.splitChunk,runtimeChunk:p.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:b},g=r(s,{devtool:!1===p.devtool||p.devtool?p.devtool:"cheap-module-source-map",mode:"production",optimization:y,plugins:[new o({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),p.bundleAnalyzer&&new t(p.bundleAnalyzer),p.splitChunk&&new h({minChunkSize:1e4}),new c({done:e=>{u.setData("done",!0),p.done?.(e),p.seo&&f(),u.setData("done",!1)}})].filter(Boolean)}),z=m(g);z.watch({},()=>{}),u.on("change",()=>{clearTimeout(e),e=setTimeout(()=>{clearTimeout(e);let i=u.data;if(!i.done&&!i.DoneDonePlugin){for(let e in i)if(Object.prototype.hasOwnProperty.call(i,e)&&i[e])return;z.close(()=>{})}},300)}),process.on("exit",function(){z.close(()=>{}),d(a.cachePath)});
1
+ let e;import i from"css-minimizer-webpack-plugin";import o from"mini-css-extract-plugin";import n from"terser-webpack-plugin";import m from"webpack";import{BundleAnalyzerPlugin as r}from"webpack-bundle-analyzer";import{merge as t}from"webpack-merge";import s from"webpackbar";import{clientConfig as p}from"./common.js";import{CONFIG as a}from"./config.js";import{getMinifyOption as l}from"./minify.js";import c from"./paths.js";import u from"./plugin/done.js";import{vmWriteing as f}from"./reactive-object.js";import d from"./seo.js";import{cleanDir as h}from"./utils.js";let{optimize:{MinChunkSizePlugin:w}}=m,{cssnanoMinify:k,swcMinify:b}=i,j="swc"===a.compiler,y=[];a.minifier&&(a.minifier.js&&y.push(new n(l(a.minifier.js?.type||(j?"swc":"terser"),a.minifier.js?.options))),a.minifier.css&&y.push(new i({minify:{swc:b,cssnano:k}[a.minifier.css?.type||(j?"swc":"cssnano")],minimizerOptions:a.minifier.css?.options})));let g={splitChunks:a.splitChunk,runtimeChunk:a.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:y},z=m(t(p,{devtool:!1===a.devtool||a.devtool?a.devtool:"cheap-module-source-map",mode:"production",optimization:g,plugins:[new o({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),a.bundleAnalyzer&&new r(a.bundleAnalyzer),a.splitChunk&&new w({minChunkSize:1e4}),a.bar&&new s(a.bar),new u({done:e=>{f.setData("done",!0),a.done?.(e),a.seo&&d(),f.setData("done",!1)}})].filter(Boolean)}));z.watch({},()=>{}),f.on("change",()=>{clearTimeout(e),e=setTimeout(()=>{clearTimeout(e);let i=f.data;if(!i.done&&!i.DoneDonePlugin){for(let e in i)if(Object.prototype.hasOwnProperty.call(i,e)&&i[e])return;z.close(()=>{})}},300)}),process.on("exit",function(){z.close(()=>{}),h(c.cachePath)});
package/lib/vm/app.js CHANGED
@@ -1 +1 @@
1
- import{readFileSync as e}from"fs";import{CONFIG as r}from"../config.js";import{APPTYPE as o,PACKAGENAME as p,PACKAGEVERSION as s}from"../process-env.js";import{resolveProgramPath as t,toUpperCaseString as a}from"../utils.js";let n={name:p,projectName:JSON.stringify(a(p).replace(/-/g," ")),version:s,base:r.basename,type:o,routerMode:r.routerMode,prefixCls:r.prefixCls,theme:r.theme,description:process.env.npm_package_description,author:{name:process.env.npm_package_author_name,email:process.env.npm_package_author_email,url:process.env.npm_package_author_url},repository:{type:process.env.npm_package_repository_type,url:process.env.npm_package_repository_url,directory:process.env.npm_package_repository_directory}};if(parseInt(process.versions.node)>14){let r=e(t("package.json"),{encoding:"utf-8"}),{description:o,author:p,repository:s}=JSON.parse(r);n.author="string"==typeof p?{name:p}:p,n.repository="string"==typeof p?{url:s}:s,n.description=o}export default n;
1
+ import{readFileSync as e}from"fs";import{CONFIG as r}from"../config.js";import{APPTYPE as o,PACKAGENAME as p,PACKAGEVERSION as s}from"../process-env.js";import{resolveProgramPath as t,toUpperCaseString as a}from"../utils.js";let n={name:p,projectName:JSON.stringify(a(p).replace(/-/g," ")),version:s,base:r.basename,type:o,routerMode:r.routerMode,prefixCls:r.prefixCls,theme:r.theme,description:process.env.npm_package_description,author:{name:process.env.npm_package_author_name,email:process.env.npm_package_author_email,url:process.env.npm_package_author_url},repository:{type:process.env.npm_package_repository_type,url:process.env.npm_package_repository_url,directory:process.env.npm_package_repository_directory}};if(parseInt(process.versions.node)>14){let{description:r,author:o,repository:p}=JSON.parse(e(t("package.json"),{encoding:"utf-8"}));n.author="string"==typeof o?{name:o}:o,n.repository="string"==typeof o?{url:p}:p,n.description=r}export default n;
package/lib/vm/locales.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import{existsSync as e}from"fs";import{basename as t,join as a}from"path";import{watch as o}from"chokidar";import{CONFIG as l}from"../config.js";import{FRAMEWORK as r,isDev as n}from"../process-env.js";import s,{vmWriteing as c}from"../reactive-object.js";import{empty as i,esm as g,tfc as f}from"../utils.js";let u={react:'import sso from "shared-store-object";',solid:'import { createEffect, createRoot, getOwner } from "solid-js";import { createStore } from "solid-js/store";'},p={react:'let storageKey="localizable.language",language=localStorage.getItem(storageKey)||"zh_CN",{translation:a,...defaultLocale}=Object.assign({title:"简体中文",language:"zh_CN",translation:{}},resources[language]||resources.zh_CN),localizable=sso({lang:defaultLocale,t:a});export function setLang(a){let{translation:e,...l}=resources[a]||{};e&&(localizable.lang=l,localizable.t=e,localStorage.setItem(storageKey,l.language))}export default localizable;',solid:'let locale=createRoot(()=>{let e="localizable.language",a=localStorage.getItem(e)||"zh_CN",{translation:l,...o}=Object.assign({title:"简体中文",language:"zh_CN",translation:{}},resources[a]||resources.zh_CN),[n,c]=createStore({lang:o,t:l});return createEffect(()=>{let a=resources[n.lang.language]?.translation;a&&(c("t",a),localStorage.setItem(e,n.lang.language))}),{localizable:n,setLocalizable:c,setLang:function(e){let{translation:a,...l}=resources[e]||{};a&&c("lang",l)}}},getOwner());export const setLocalizable=locale.setLocalizable;export const t=locale.localizable.t;export const lang=locale.localizable.lang;export const setLang=locale.setLang;'}[r];function d(e,t){return`${u[r]}
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);${p}`}export const localesModuleName="@app/locales";export const locales=new s({[localesModuleName]:d([],{})});let m={};async function z(e,a){let o=t(e).replace(/\.[^.]+$/,"");if("deleted"===a)delete m[o];else{let t=await import(g`${f(e)}`);Object.assign(m,{[o]:t.default})}let l=[],r={};for(let e in m)if(Object.prototype.hasOwnProperty.call(m,e)){let t=m[e],{language:a=o,title:n=a,icon:s,translation:c={}}=t;l.push({language:a,title:n,icon:s}),r[a]={language:a,title:n,icon:s,translation:c}}locales.setData(localesModuleName,d(l,r))}let b=a(l.alias["@"],"./locales");e(b)&&function(e,t){c.setData("vm-locals",!0);let a=[],l=o(e,{ignored:t,persistent:!0,ignoreInitial:!1});function r(){l.unwatch(e),l.close(),c.setData("vm-locals",!1)}l.on("add",e=>{a.push(e),z(e,"added").finally(i)}),l.on("change",e=>{z(e,"change").finally(i)}),l.on("unlink",e=>{a.splice(a.indexOf(e),1),z(e,"deleted").finally(i)}),l.once("ready",()=>{a.forEach(e=>{z(e,"change").finally(i)}),n||r()}),process.on("SIGINT",r)}(b,[/^\..*/,/!\.ts$/,/\.d\.ts$/]);
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);${p}`}export const localesModuleName="@app/locales";export const locales=new s({[localesModuleName]:d([],{})});let m={};async function z(e,a){let o=t(e).replace(/\.[^.]+$/,"");"deleted"===a?delete m[o]:Object.assign(m,{[o]:(await import(g`${f(e)}`)).default});let l=[],r={};for(let e in m)if(Object.prototype.hasOwnProperty.call(m,e)){let{language:t=o,title:a=t,icon:n,translation:s={}}=m[e];l.push({language:t,title:a,icon:n}),r[t]={language:t,title:a,icon:n,translation:s}}locales.setData(localesModuleName,d(l,r))}let b=a(l.alias["@"],"./locales");e(b)&&function(e,t){c.setData("vm-locals",!0);let a=[],l=o(e,{ignored:t,persistent:!0,ignoreInitial:!1});function r(){l.unwatch(e),l.close(),c.setData("vm-locals",!1)}l.on("add",e=>{a.push(e),z(e,"added").finally(i)}),l.on("change",e=>{z(e,"change").finally(i)}),l.on("unlink",e=>{a.splice(a.indexOf(e),1),z(e,"deleted").finally(i)}),l.once("ready",()=>{a.forEach(e=>{z(e,"change").finally(i)}),n||r()}),process.on("SIGINT",r)}(b,[/^\..*/,/!\.ts$/,/\.d\.ts$/]);
package/lib/vm/routes.js CHANGED
@@ -1 +1 @@
1
- let e,t,r;import{accessSync as o,constants as s,readFileSync as n,readdirSync as a,statSync as p}from"fs";import{join as i,relative as l}from"path";import{watch as c}from"chokidar";import{load as m}from"js-yaml";import{CONFIG as u}from"../config.js";import f from"../paths.js";import{FRAMEWORK as d,FRAMEWORKNAME as x,createElement as h,isDev as g,isLibrary as $,isReact as j,isSolid as y}from"../process-env.js";import D,{vmWriteing as N}from"../reactive-object.js";let O=/^---\n([\s\S]+?)\n---\n/;try{o(`${u.alias["@"]}/router/index.ts`,s.R_OK),e=!0}catch(t){e=!1}let T=y?"component":"element";function k(e){return e.replace(/\$/g,":").replace(/^index\.tsx?$/,"/").replace(/^README\.mdx?$/,"/")}function E(e,t){let{regex:r,alia:o,base:s=e,outputSource:c}=t,u=a(e);return u.reduce((a,u)=>{let f=i(e,u),d=p(f);if(d.isDirectory()){let e=E(f,{...t,base:s});if(e.length>0){let t={},r={path:k(u),key:k(l(s,f))};if(c)Object.assign(t,{children:e});else{let o=e.findIndex(e=>"/"===e.path||r.path===e.path),s=e.splice(o,1)[0];e.length?Object.assign(t,!y&&s,{children:[y&&{...s,path:r.path===s.path?"/":s.path},...e].filter(Boolean)}):Object.assign(t,s)}a.push(Object.assign(t,r))}}else if(r.test(f)){let e=n(f,{encoding:"utf-8"}),t=function(e){let t=e.match(O);return t&&t[1]?t[1].trim():null}(e),r=t?m(t):{},p=l(s,f),u=k(p);a.push(Object.assign({path:u.split("/").slice(-2,-1)?.join("")||"/",key:u.replace(/\/?index.tsx?$/,"/").replace(/\/?README.mdx?$/,"/").split("/").filter(Boolean).join("/"),meta:{...r}},o&&{[T]:`rr(() => import(/* webpackChunkName: '${p}' */'${i(o,p)}'))rr`},c&&{codes:function(e){let t;let r={},o=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=o.exec(e));){let[,e="jsx",o]=t,s=e.split(" ").pop()||"jsx";r[s]=o.trim()}return Object.keys(r).length?r:{jsx:e}}(e.replace(O,"").replace(/^\n+|\n+$/g,""))}))}return a},[])}export const routesModuleName="@app/routes";export const route=new D({[routesModuleName]:"export default []"});export const exampleModuleName="@app/example";export const examples=new D;let M=`${y?"() => ":""}${h}(SuspenseComp, { comp: $1 })`,S=`import { ${h} } from "${x}";import SuspenseComp from "@app/suspense";${j?'import prefix from "@app/prefix-router";':""}`;e&&(S+='import merge from "@app/merge-router";import customRouter from "@/router";'),["react","solid"].includes(d)||(M="$1",S="");export let routes=[];function b(t){return`${S}const routes = [{ path: "/", children: [${y?'{ path: "/" },':""} ${t}] }];const _routes = ${e?'merge([...routes, ...customRouter], "path")':"routes"};export default ${j?"prefix(_routes)":"_routes"};`}function R(e,t,r,o){N.setData(o,!0);let s=c(e,{ignored:(e,r)=>{if(r)return!r.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!1});function n(){s.unwatch(e),s.close(),N.setData(o,!1)}s.on("add",()=>{r()}).on("change",()=>{r()}).on("unlink",()=>{r()}),s.once("ready",()=>{g||n()}),process.on("SIGINT",n)}$?(R(f.componentsPath,/(?<!README\.mdx?)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),routes=E(f.componentsPath,{regex:/README\.mdx?$/,alia:"@pkg"}),route.setData(routesModuleName,b(JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,M).slice(1,-1)))},100)},"vm-router"),R(f.componentsPath,/(?<!\/examples\/(.+)\.md)$/,function(){clearTimeout(r),r=setTimeout(()=>{clearTimeout(r),E(f.componentsPath,{regex:/\/examples\/(.+)\.md$/,outputSource:!0}).forEach(e=>{let t=["@app/example",e.key].filter(Boolean).join("/"),r=e.children?.[0].children?.filter(e=>e.codes)?.map(e=>({title:e.path.replace(/.md$/,""),order:0,...e.meta,codes:e.codes})).sort((e,t)=>e.order-t.order)||[];examples.setData(t,`export default ${JSON.stringify(r)};`)})},100)},"vm-examples")):R(f.pagesPath,/(?<!index\.tsx?)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),routes=E(f.pagesPath,{regex:/index\.tsx?$/,alia:"@/pages"}),route.setData(routesModuleName,b(JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,M).slice(1,-1)))},100)},"vm-router");
1
+ let e,t,r;import{accessSync as o,constants as s,readFileSync as a,readdirSync as n,statSync as p}from"fs";import{join as i,relative as l}from"path";import{frontmatterSync as m}from"@moneko/mdx";import{watch as c}from"chokidar";import{CONFIG as u}from"../config.js";import f from"../paths.js";import{FRAMEWORK as d,FRAMEWORKNAME as x,createElement as h,isDev as g,isLibrary as $,isReact as j,isSolid as y}from"../process-env.js";import D,{vmWriteing as N}from"../reactive-object.js";try{o(`${u.alias["@"]}/router/index.ts`,s.R_OK),e=!0}catch(t){e=!1}let O=y?"component":"element";function k(e){return e.replace(/\$/g,":").replace(/^index\.tsx?$/,"/").replace(/^README\.mdx?$/,"/")}function T(e,t){let{regex:r,alia:o,base:s=e,outputSource:c}=t;return n(e).reduce((n,u)=>{let f=i(e,u);if(p(f).isDirectory()){let e=T(f,{...t,base:s});if(e.length>0){let t={},r={path:k(u),key:k(l(s,f))};if(c)Object.assign(t,{children:e});else{let o=e.findIndex(e=>"/"===e.path||r.path===e.path),s=e.splice(o,1)[0];e.length?Object.assign(t,!y&&s,{children:[y&&{...s,path:r.path===s.path?"/":s.path},...e].filter(Boolean)}):Object.assign(t,s)}n.push(Object.assign(t,r))}}else if(r.test(f)){let{frontmatter:e,code:t}=m(a(f,{encoding:"utf-8"})),r=l(s,f),p=k(r);n.push(Object.assign({path:p.split("/").slice(-2,-1)?.join("")||"/",key:p.replace(/\/?index.tsx?$/,"/").replace(/\/?README.mdx?$/,"/").split("/").filter(Boolean).join("/"),meta:JSON.parse(e)},o&&{[O]:`rr(() => import(/* webpackChunkName: '${r}' */'${i(o,r)}'))rr`},c&&{codes:function(e){let t;let r={},o=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=o.exec(e));){let[,e="jsx",o]=t;r[e.split(" ").pop()||"jsx"]=o.trim()}return Object.keys(r).length?r:{jsx:e}}(t.replace(/^\n+|\n+$/g,""))}))}return n},[])}export const routesModuleName="@app/routes";export const route=new D({[routesModuleName]:"export default []"});export const exampleModuleName="@app/example";export const examples=new D;let E=`${y?"() => ":""}${h}(SuspenseComp, { comp: $1 })`,M=`import { ${h} } from "${x}";import SuspenseComp from "@app/suspense";${j?'import prefix from "@app/prefix-router";':""}`;e&&(M+='import merge from "@app/merge-router";import customRouter from "@/router";'),["react","solid"].includes(d)||(E="$1",M="");export let routes=[];function S(t){return`${M}const routes = [{ path: "/", children: [${y?'{ path: "/" },':""} ${t}] }];const _routes = ${e?'merge([...routes, ...customRouter], "path")':"routes"};export default ${j?"prefix(_routes)":"_routes"};`}function b(e,t,r,o){N.setData(o,!0);let s=c(e,{ignored:(e,r)=>{if(r)return!r.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!1});function a(){s.unwatch(e),s.close(),N.setData(o,!1)}s.on("add",()=>{r()}).on("change",()=>{r()}).on("unlink",()=>{r()}),s.once("ready",()=>{g||a()}),process.on("SIGINT",a)}$?(b(f.componentsPath,/(?<!README\.mdx?)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),routes=T(f.componentsPath,{regex:/README\.mdx?$/,alia:"@pkg"}),route.setData(routesModuleName,S(JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,E).slice(1,-1)))},100)},"vm-router"),b(f.componentsPath,/(?<!\/examples\/(.+)\.md)$/,function(){clearTimeout(r),r=setTimeout(()=>{clearTimeout(r),T(f.componentsPath,{regex:/\/examples\/(.+)\.md$/,outputSource:!0}).forEach(e=>{let t=["@app/example",e.key].filter(Boolean).join("/"),r=e.children?.[0].children?.filter(e=>e.codes)?.map(e=>({title:e.path.replace(/.md$/,""),order:0,...e.meta,codes:e.codes})).sort((e,t)=>e.order-t.order)||[];examples.setData(t,`export default ${JSON.stringify(r)};`)})},100)},"vm-examples")):b(f.pagesPath,/(?<!index\.tsx?)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),routes=T(f.pagesPath,{regex:/index\.tsx?$/,alia:"@/pages"}),route.setData(routesModuleName,S(JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,E).slice(1,-1)))},100)},"vm-router");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.8.3",
3
+ "version": "3.8.5-beta.0",
4
4
  "description": "core",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -12,19 +12,17 @@
12
12
  "author": "moneko",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@mdx-js/loader": "3.0.0",
16
- "@swc/core": "1.3.96",
15
+ "@moneko/mdx": "0.1.9",
16
+ "@swc/core": "1.3.99",
17
17
  "@swc/css": "0.0.28",
18
18
  "@swc/helpers": "0.5.3",
19
19
  "@teamsupercell/typings-for-css-modules-loader": "2.5.2",
20
- "@types/webpack-bundle-analyzer": "4.6.2",
21
20
  "add-asset-html-webpack-plugin": "6.0.0",
22
- "core-js": "3.33.2",
23
- "core-js-compat": "3.33.2",
21
+ "core-js": "3.33.3",
22
+ "core-js-compat": "3.33.3",
24
23
  "cross-env": "7.0.3",
25
24
  "css-loader": "6.8.1",
26
25
  "css-minimizer-webpack-plugin": "5.0.1",
27
- "external-remotes-plugin": "1.0.0",
28
26
  "html-webpack-plugin": "5.5.3",
29
27
  "less": "4.2.0",
30
28
  "less-loader": "11.1.3",
@@ -37,14 +35,14 @@
37
35
  "swc-loader": "0.2.3",
38
36
  "swc-plugin-another-transform-imports": "0.2.7",
39
37
  "ts-import-plugin": "3.0.0",
40
- "ts-loader": "9.5.0",
38
+ "ts-loader": "9.5.1",
41
39
  "typescript": "5.2.2",
42
40
  "webpack": "5.77.0",
43
- "webpack-bundle-analyzer": "4.9.1",
41
+ "webpack-bundle-analyzer": "4.10.1",
44
42
  "webpack-cli": "5.1.4",
45
43
  "webpack-dev-server": "4.15.1",
46
44
  "webpack-merge": "5.10.0",
47
- "webpack-virtual-modules": "0.6.0",
45
+ "webpack-virtual-modules": "0.6.1",
48
46
  "webpackbar": "5.0.2",
49
47
  "xml2js": "0.6.2"
50
48
  },
@@ -1,12 +1,12 @@
1
- import { Options as AssetHtmlOptions } from 'add-asset-html-webpack-plugin';
2
- import { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
3
- import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
4
1
  import WebpackBar from 'webpackbar';
5
- import DoneWebpackPlugin from '../lib/plugin/done';
6
- import type { OverrideResolverOption } from '../lib/plugin/override-resolve';
7
- import type { Options as MDXOptions } from '@mdx-js/loader';
2
+ import type { BundleAnalyzerOption } from './bundle-analyzer.d';
3
+ import type { OverrideResolverOption } from '../lib/index';
4
+ import type { DonePluginOption } from '../lib/plugin/done';
5
+ import type { MdxOptions } from '@moneko/mdx';
8
6
  import type { JsMinifyOptions, Config as SwcConfig } from '@swc/core';
7
+ import type { Options as AssetHtmlOptions } from 'add-asset-html-webpack-plugin';
9
8
  import type { CssNanoOptionsExtended } from 'css-minimizer-webpack-plugin';
9
+ import type { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
10
10
  import type { MinifyOptions } from 'terser';
11
11
  import type { Options } from 'ts-import-plugin';
12
12
  import type {
@@ -280,7 +280,7 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
280
280
  * openAnalyzer: false,
281
281
  * }
282
282
  */
283
- bundleAnalyzer: BundleAnalyzerPlugin.Options | false;
283
+ bundleAnalyzer: BundleAnalyzerOption | false;
284
284
  /** seo优化
285
285
  * @default false
286
286
  */
@@ -299,8 +299,8 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
299
299
  }
300
300
  | false;
301
301
  /** 📦 打包完成 */
302
- done?: ConstructorParameters<typeof DoneWebpackPlugin>[0]['done'];
303
- mdx?: MDXOptions;
302
+ done?: DonePluginOption;
303
+ mdx?: Omit<MdxOptions, 'value' | 'filepath'>;
304
304
  jsxDomExpressions?: {
305
305
  moduleName?: string;
306
306
  builtIns?: string[];
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return t}});const e=/^---\n([\s\S]+?)\n---\n/,n=/^\n+|\n+$/g;function t(t){return t.replace(e,"").replace(n,"")}
@@ -1 +0,0 @@
1
- export default function (content: string): string;