@moneko/core 3.8.7 → 3.9.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/config.js CHANGED
@@ -1 +1 @@
1
- import{fileExists as e}from"@moneko/mdx";import{merge as o}from"webpack-merge";import t,{CUSTOMCONFIG as s}from"./paths.js";import{FRAMEWORK as i,PACKAGENAME as a,coreName as n,isDev as l,isLibrary as r,isMobile as c,isSolid as m,jsxImportSource as p,mainDirectory as d}from"./process-env.js";import{isFunction as u,log as h,readConf as f,resolveProgramPath as g}from"./utils.js";let x=["@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:{"@":g(d)},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:t.webpackCachePath,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`node_modules/${n}/template/index.html`,favicon:`node_modules/${n}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:{chunks:"all",minSize:1024,minChunks:1,cacheGroups:{}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:x,js:x,media:x,font:x,wasm:[]},mdx:{jsx:!1,development:l,jsxImportSource:p,providerImportSource:`@moneko/${i}/mdx`},jsxDomExpressions:{},bar:{name:"Client",color:"#6f42c1"},normalizeCss:!0,externalsPresets:{},buildHttp:{allowedUris:[],lockfileLocation:`${t.httpCachePath}/http.lock`,cacheLocation:`${t.httpCachePath}/data`,upgrade:!0}};m&&Object.assign(P,{jsxDomExpressions:{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1}}),r&&(P.alias=Object.assign(P.alias,{"@pkg":t.componentsPath,[a]:t.componentsPath}));let w=P,C={},b={};if(e(t.configPath)){let e=(await f(t.configPath,"index")).default;C=u(e)?e(process):e}if(s&&e(t.customConfigPath)){let e=(await f(t.customConfigPath,s)).default;b=u(e)?e(process):e}"tsc"===(w=o(w,C,b)).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:s,log:h};
1
+ import{fileExists as e}from"@moneko/mdx";import{merge as t}from"webpack-merge";import s,{CUSTOMCONFIG as o}from"./paths.js";import{FRAMEWORK as i,PACKAGENAME as n,coreName as r,isDev as a,isLibrary as l,isMobile as m,isSolid as c,jsxImportSource as p,mainDirectory as u}from"./process-env.js";import{isFunction as d,log as h,readConf as f,resolveProgramPath as g}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"],x={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:m?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":g(u)},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:s.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:{CHANGELOG:{test:/CHANGELOG\.md/,priority:-10,name:"CHANGELOG",reuseExistingChunk:!0},prismjs:{test:/(prism\.js|prism\/css\.ts)/,priority:-10,name:"vendors-prismjs",reuseExistingChunk:!0},site:{test:/site/,priority:-10,reuseExistingChunk:!0},marked:{test:/marked/,priority:-10,reuseExistingChunk:!0},"@moneko":{test:/@moneko/,priority:-10,reuseExistingChunk:!0}}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:C,js:C,media:C,font:C,wasm:[]},mdx:{jsx:!1,development:a,jsxImportSource:p,providerImportSource:`@moneko/${i}/mdx`},jsxDomExpressions:{},bar:{name:"Client",color:"#6f42c1"},normalizeCss:!0,externalsPresets:{},buildHttp:{allowedUris:[],lockfileLocation:`${s.httpCachePath}/http.lock`,cacheLocation:`${s.httpCachePath}/data`,upgrade:!0}};c&&Object.assign(x,{jsxDomExpressions:{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1}}),l&&(x.alias=Object.assign(x.alias,{"@pkg":s.componentsPath,[n]:s.componentsPath}));let k=x,P={},w={};if(e(s.configPath)){let e=(await f(s.configPath,"index")).default;P=d(e)?e(process):e}if(o&&e(s.customConfigPath)){let e=(await f(s.customConfigPath,o)).default;w=d(e)?e(process):e}"tsc"===(k=t(k,P,w)).compiler&&k.minifier&&(k.minifier.js||Object.assign(k.minifier,{js:{type:"terser"}}),k.minifier.css||Object.assign(k.minifier,{css:{type:"cssnano"}})),!1===k.devtool&&(k.sourceMap=!1),!1===k.sourceMap&&(k.devtool=!1),k.fixBrowserRouter&&k.htmlPluginOption&&(k.htmlPluginOption.tags||(k.htmlPluginOption.tags=[]),k.htmlPluginOption.tags.push({textContent:"(function(l) {if (l.search[1] === '/' ) {var decoded = l.search.slice(1).split('&').map(function(s) {return s.replace(/~and~/g, '&')}).join('?');window.history.replaceState(null, null,l.pathname.slice(0, -1) + decoded + l.hash);}}(window.location))"}));export const CONFIG=k;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,CUSTOMCONFIG:o,log:h};
@@ -1 +1 @@
1
- import{merge as e}from"webpack-merge";import{CONFIG as t}from"./config.js";import i from"./info.js";import{PACKAGENAME as o,coreName as a}from"./process-env.js";import{resolveProgramPath as r}from"./utils.js";let{template:m,favicon:p,...n}=Object.assign({template:`node_modules/${a}/template/index.html`,favicon:`node_modules/${a}/template/favicon.ico`},t.htmlPluginOption||{}),l=e({title:t.env?.PROJECTNAME||o.toLocaleUpperCase()||"Title",filename:"index.html",hash:!1,minify:{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeAttributeQuotes:!0,useShortDoctype:!0},meta:{charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no",viewport:"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no","apple-mobile-web-app-capable":"yes",renderer:"webkit",description:i.description||""},tags:[],template:r(m),favicon:r(p)},n);export default l;
1
+ import{merge as e}from"webpack-merge";import{CONFIG as t}from"./config.js";import i from"./info.js";import{PACKAGENAME as o,coreName as r}from"./process-env.js";import{resolveProgramPath as a}from"./utils.js";let{template:m,favicon:p,...n}=Object.assign({template:`node_modules/${r}/template/index.html`,favicon:`node_modules/${r}/template/favicon.ico`},t.htmlPluginOption||{}),l=e({title:t.env?.PROJECTNAME||o.toLocaleUpperCase()||"Title",filename:"index.html",hash:!1,minify:{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeAttributeQuotes:!0,useShortDoctype:!0},meta:{charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no",viewport:"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no","apple-mobile-web-app-capable":"yes",renderer:"webkit",description:i.description||"",keywords:i.keywords},tags:[],template:a(m),favicon:a(p)},n);export default l;
package/lib/prod.js CHANGED
@@ -1 +1 @@
1
- import{removeDirAll as e}from"@moneko/mdx";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 s}from"webpack-merge";import t 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 f from"./seo.js";let{optimize:{MinChunkSizePlugin:d}}=m,{cssnanoMinify:h,swcMinify:k}=i,w="swc"===a.compiler,b=[];a.minifier&&(a.minifier.js&&b.push(new n(l(a.minifier.js?.type||(w?"swc":"terser"),a.minifier.js?.options))),a.minifier.css&&b.push(new i({minify:{swc:k,cssnano:h}[a.minifier.css?.type||(w?"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:b},y=m(s(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.splitChunk&&new d({minChunkSize:1e4}),a.bundleAnalyzer&&new r(a.bundleAnalyzer),a.bar&&new t(a.bar),new u({done:e=>{a.done?.(e),a.seo&&f()}})].filter(Boolean)}));y.watch({aggregateTimeout:20,ignored:/node_modules(?![\\/]@app)/,stdin:!0},e=>{if(e)throw y.close(()=>{}),e;y.hooks.done.tap("WatchRunPlugin",e=>{e.hasErrors(),y.close(()=>{})})}),process.on("exit",function(){e(c.cachePath)});
1
+ import{removeDirAll as e}from"@moneko/mdx";import i from"css-minimizer-webpack-plugin";import o from"mini-css-extract-plugin";import m from"terser-webpack-plugin";import n from"webpack";import{BundleAnalyzerPlugin as r}from"webpack-bundle-analyzer";import{merge as s}from"webpack-merge";import t from"webpackbar";import{clientConfig as p}from"./common.js";import{CONFIG as l}from"./config.js";import{getMinifyOption as a}from"./minify.js";import c from"./paths.js";import u from"./plugin/done.js";import f from"./seo.js";let{optimize:{MinChunkSizePlugin:d}}=n,{cssnanoMinify:h,swcMinify:w}=i,k="swc"===l.compiler,b=[];l.minifier&&(l.minifier.js&&b.push(new m(a(l.minifier.js?.type||(k?"swc":"terser"),l.minifier.js?.options))),l.minifier.css&&b.push(new i({minify:{swc:w,cssnano:h}[l.minifier.css?.type||(k?"swc":"cssnano")],minimizerOptions:l.minifier.css?.options})));let g={splitChunks:l.splitChunk,runtimeChunk:l.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:b},y=n(s(p,{devtool:!1===l.devtool||l.devtool?l.devtool:"cheap-module-source-map",mode:"production",optimization:g,plugins:[new o({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),l.splitChunk&&new d({minChunkSize:1e4}),l.bundleAnalyzer&&new r(l.bundleAnalyzer),l.bar&&new t(l.bar),new u({done:e=>{l.done?.(e),l.seo&&f()}})].filter(Boolean)}));y.watch({aggregateTimeout:20,ignored:/node_modules(?![\\/]@app)/,stdin:!0},e=>{if(e)throw y.close(()=>{}),e;y.close(()=>{})}),process.on("exit",function(){e(c.cachePath)});
package/lib/swcrc.js CHANGED
@@ -1 +1 @@
1
- import{merge as e}from"webpack-merge";import{CONFIG as o}from"./config.js";import r from"./paths.js";import s from"./polyfills.js";import{isReact as t,isSolid as n,jsxImportSource as c}from"./process-env.js";export const swcMinifyOption={compress:{top_retain:[],keep_infinity:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],toplevel:!1,drop_console:!0,drop_debugger:!0,module:!1,ecma:2015,ie8:!1,keep_classnames:void 0,keep_fnames:!1},mangle:!0};export default((a=!1)=>{let l={module:{type:"es6",resolveFully:!0},jsc:{parser:{syntax:"typescript",tsx:!0,decorators:!0,dynamicImport:!0},loose:!0,target:"es2017",externalHelpers:!0,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,refresh:t&&a,development:a,importSource:c},optimizer:{simplify:!1}},experimental:{emitAssertForImportAttributes:!0,cacheRoot:r.swcCachePath,plugins:[["swc-plugin-another-transform-imports",function(e){for(let o=0,r=Object.keys(e),s=r.length;o<s;o++)e[r[o]].transform=`${r[o]}/${e[r[o]].transform}`,e[r[o]].style&&(e[r[o]].style=`${r[o]}/${e[r[o]].style}`);return e}(o.importOnDemand||{})],n&&["@moneko/jsx-dom-expressions",o.jsxDomExpressions||{}]].filter(Boolean)}},sourceMaps:!0,parseMap:!0};return(o.polyfill&&(l.jsc.target=void 0,l.env={include:s(),mode:"usage",coreJs:"3.33"}),o.swcrc)?e(l,"function"==typeof o.swcrc?o.swcrc(a):o.swcrc):l});
1
+ import{merge as e}from"webpack-merge";import{CONFIG as o}from"./config.js";import r from"./paths.js";import s from"./polyfills.js";import{isReact as t,isSolid as n,jsxImportSource as c}from"./process-env.js";export const swcMinifyOption={compress:{top_retain:[],keep_infinity:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],toplevel:!1,drop_console:!0,drop_debugger:!0,module:!1,ecma:2015,ie8:!1,keep_classnames:void 0,keep_fnames:!1},mangle:!0};export default((l=!1)=>{let p={module:{type:"es6",resolveFully:!0},jsc:{parser:{syntax:"typescript",tsx:!0,decorators:!0,dynamicImport:!0},loose:!0,target:"es2017",externalHelpers:!0,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,refresh:t&&l,development:l,importSource:c},optimizer:{simplify:!1}},experimental:{emitAssertForImportAttributes:!0,cacheRoot:r.swcCachePath,plugins:[["swc-plugin-another-transform-imports",function(e){for(let o=0,r=Object.keys(e),s=r.length;o<s;o++)e[r[o]].transform=`${r[o]}/${e[r[o]].transform}`,e[r[o]].style&&(e[r[o]].style=`${r[o]}/${e[r[o]].style}`);return e}(o.importOnDemand||{})],n&&["@moneko/jsx-dom-expressions",o.jsxDomExpressions||{}]].filter(Boolean)}},sourceMaps:!0,parseMap:!0};return(o.polyfill&&(p.jsc.target=void 0,p.env={include:s(),mode:"entry",coreJs:"3.33"}),o.swcrc)?e(p,"function"==typeof o.swcrc?o.swcrc(l):o.swcrc):p});
package/lib/vm/docs.js CHANGED
@@ -1 +1,9 @@
1
- import{loadFileSync as e,scanFolder as t}from"@moneko/mdx";import o from"./generate-doc.js";import{CONFIG as r}from"../config.js";import{FRAMEWORK as s,FRAMEWORKNAME as n,createElement as p,isReact as a,isSolid as m}from"../process-env.js";import i from"../reactive-object.js";export const docsModuleName="@app/docs";export const docs=new i({[docsModuleName]:"export default {}"});export const comment=new i({});let c={},l=`() => ${p}(SuspenseComp, { comp: $1 })`,d=`import { ${p}${m?",Dynamic":""} } from "${n}${m?"/web":""}";import SuspenseComp from "@app/suspense";`;["react","solid"].includes(s)||(l="$1",d=""),comment.on("change",(e,t)=>{!function(e,t){let[o,r]=e.replace(/^@app\/comment\//,"").split("/");c[o]||(c[o]={}),t?c[o][r]&&delete c[o][r]:c[o][r]=`rr(() => import(/* webpackChunkName: '${e}' */'${e}?raw').then((res) => ({default: ${a?"() =>":""}${p}(${m?"Dynamic":"'n-md'"}, {text: res.default, ${m?"component: 'n-md', ":""}css: 'table td a {display:inline-flex;align-items:center;gap:2px;}table td a n-img{display:inline-block;overflow:hidden;border-radius:var(--border-radius);inline-size:18px;block-size:18px;}'})})))rr`;let s={};for(let e in c)Object.prototype.hasOwnProperty.call(c,e)&&(s[e]=Object.values(c[e]));docs.setData(docsModuleName,`${d}export default ${JSON.stringify(s).replace(/"rr\((.+?)\)rr"/g,l)}`)}(e,t?.length<0)}),t(r.alias["@pkg"]).filter(e=>/^(?![._]).*(?<!\.test)\.(tsx?)$/i.test(e)).forEach(t=>{let r=e(t);r&&comment.setData(`@app/comment/${t.split("/").slice(-2).join("/").replace(/\.tsx?/,".md")}`,o(r,t))});
1
+ import{loadFileSync as e,scanFolder as t}from"@moneko/mdx";import o from"./generate-doc.js";import{CONFIG as r}from"../config.js";import{FRAMEWORKNAME as n,createElement as m,isDev as p,isReact as a,isSolid as s}from"../process-env.js";import c from"../reactive-object.js";export const docsModuleName="@app/docs";export const docs=new c({[docsModuleName]:"export default {}"});export const comment=new c({});let i={},l=`import { ${m}${s?",Dynamic":""} } from "${n}${s?"/web":""}";import SuspenseComp from "@app/suspense";
2
+ function getComment(name) {
3
+ return () =>
4
+ ${m}(SuspenseComp, {
5
+ comp: () =>
6
+ import(${p?"":"/* webpackChunkName: `@app/comment/${name}` */ "}\`@app/comment/\${name}?raw\`).then((res) => ({default: ${a?"() =>":""}${m}(${s?"Dynamic":"'n-md'"}, {text: res.default, ${s?"component: 'n-md', ":""}css: 'table td a {display:inline-flex;align-items:center;gap:2px;}table td a n-img{display:inline-block;overflow:hidden;border-radius:var(--border-radius);inline-size:18px;block-size:18px;}'})})),
7
+ });
8
+ }
9
+ `;comment.on("change",(e,t)=>{!function(e,t){let[o,r]=e.replace(/^@app\/comment\//,"").split("/");i[o]||(i[o]={}),t?i[o][r]&&delete i[o][r]:i[o][r]=`rr(getComment('${o}/${r}'))rr`;let n={};for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(n[e]=Object.values(i[e]));docs.setData(docsModuleName,`${l}export default ${JSON.stringify(n).replace(/"rr\((.+?)\)rr"/g,"$1")}`)}(e,t?.length<0)}),t(r.alias["@pkg"]).filter(e=>/^(?![._]).*(?<!\.test)\.(tsx?)$/i.test(e)).forEach(t=>{let r=e(t);r&&comment.setData(`@app/comment/${t.split("/").slice(-2).join("/").replace(/\.tsx?/,".md")}`,o(r,t))});
package/lib/vm/utils.js CHANGED
@@ -1 +1 @@
1
- import{join as e,relative as t}from"path";import{frontmatterSync as n,loadFileSync as r}from"@moneko/mdx";import{watch as i}from"chokidar";import{isDev as l,isSolid as o}from"../process-env.js";let s=o?"component":"element";export function mergeRouter(e,t){if(!e.length)return;let n=[];return e.forEach(e=>{let r=n.findIndex(n=>n[t]==e[t]);if(r>-1){let i=[...n[r].children||[],...e.children||[]];n[r]=Object.assign(e,n[r]),i.length&&(n[r].children=mergeRouter(i,t))}else n.push(Object.assign(e,Array.isArray(e.children)&&{children:mergeRouter(e.children,t)}))}),n.forEach((e,t)=>{if(e.children?.length){let{children:r=[],...i}=e;n[t]={path:i.path,key:i.key,children:[o&&{...i,path:e.path===i.path?"/":i.path},...r].filter(e=>e&&(e.component||e.children?.length))}}}),n}export function getTree(i){let l={};return i.files.forEach(o=>{let c={code:"",frontmatter:"{}"},a=t(i.base,o),h=i.base.split("/").filter(Boolean),p=o.split("/").filter(Boolean).slice(0,-1);(o.endsWith(".md")||o.endsWith(".mdx"))&&Object.assign(c,n(r(o)));let d={},f=Object.assign({meta:JSON.parse(c.frontmatter)},i.alia&&{[s]:`rr(() => import(/* webpackChunkName: '${a}' */'${e(i.alia,a)}'))rr`},i.outputSource&&{codes:function(e){let t;let n={},r=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=r.exec(e));){let[,e="jsx",r]=t;n[e.split(" ").pop()||"jsx"]=r.trim()}return Object.keys(n).length?n:{jsx:e}}(c.code.replace(/^\n+|\n+$/g,""))});for(let e=h.length;e<p.length;e++){let t={path:p[e],key:p[e]};e===h.length?(Object.assign(d,l[t.key],{path:t.path,key:t.key},e===p.length-1&&f),l[t.key]=d):(d.children=(d.children||[]).concat([t]),i.outputSource?(Object.assign(t,{path:o.split("/").pop(),key:o.split("/").pop()},f),t.children=getTree({...i,base:`${i.base}/${t.key}`,files:i.files.filter(e=>e.startsWith(`${i.base}/${t.key}`))})):Object.assign(t,{key:p.slice(h.length,e+1).join("/")},f),d=t)}}),Object.values(l)}export function watchFiles(e,t,n,r=[]){let o=i(e,{ignored:(e,n)=>{if(n)return!n.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!0});function s(){o.unwatch(e),o.close()}o.on("add",e=>{r.includes(e)||r.push(e),n(r)}).on("change",e=>{r.includes(e)||r.push(e),n(r)}).on("unlink",e=>{let t=r.indexOf(e);-1!==t&&r.splice(t,1),n(r)}),o.once("ready",()=>{l||s()}),process.on("SIGINT",s)}
1
+ import{join as e,relative as t}from"path";import{frontmatterSync as n,loadFileSync as r}from"@moneko/mdx";import{watch as i}from"chokidar";import{isSolid as l}from"../process-env.js";let o=l?"component":"element";export function mergeRouter(e,t){if(!e.length)return;let n=[];return e.forEach(e=>{let r=n.findIndex(n=>n[t]==e[t]);if(r>-1){let i=[...n[r].children||[],...e.children||[]];n[r]=Object.assign(e,n[r]),i.length&&(n[r].children=mergeRouter(i,t))}else n.push(Object.assign(e,Array.isArray(e.children)&&{children:mergeRouter(e.children,t)}))}),n.forEach((e,t)=>{if(e.children?.length){let{children:r=[],...i}=e;n[t]={path:i.path,key:i.key,children:[l&&{...i,path:e.path===i.path?"/":i.path},...r].filter(e=>e&&(e.component||e.children?.length))}}}),n}export function getTree(i){let l={};return i.files.forEach(s=>{let c={code:"",frontmatter:"{}"},a=t(i.base,s),h=i.base.split("/").filter(Boolean),p=s.split("/").filter(Boolean).slice(0,-1);(s.endsWith(".md")||s.endsWith(".mdx"))&&Object.assign(c,n(r(s)));let d={},f=Object.assign({meta:JSON.parse(c.frontmatter)},i.alia&&{[o]:`rr(() => import(/* webpackChunkName: '${a}' */'${e(i.alia,a)}'))rr`},i.outputSource&&{codes:function(e){let t;let n={},r=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=r.exec(e));){let[,e="jsx",r]=t;n[e.split(" ").pop()||"jsx"]=r.trim()}return Object.keys(n).length?n:{jsx:e}}(c.code.replace(/^\n+|\n+$/g,""))});for(let e=h.length;e<p.length;e++){let t={path:p[e],key:p[e]};e===h.length?(Object.assign(d,l[t.key],{path:t.path,key:t.key},e===p.length-1&&f),l[t.key]=d):(d.children=(d.children||[]).concat([t]),i.outputSource?(Object.assign(t,{path:s.split("/").pop(),key:s.split("/").pop()},f),t.children=getTree({...i,base:`${i.base}/${t.key}`,files:i.files.filter(e=>e.startsWith(`${i.base}/${t.key}`))})):Object.assign(t,{key:p.slice(h.length,e+1).join("/")},f),d=t)}}),Object.values(l).sort((e,t)=>e.key>t.key?1:-1)}export function watchFiles(e,t,n,r=[]){let l=i(e,{ignored:(e,n)=>{if(n)return!n.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!0});function o(){l.unwatch(e),l.close()}l.on("add",e=>{r.includes(e)||r.push(e),n(r)}).on("change",e=>{r.includes(e)||r.push(e),n(r)}).on("unlink",e=>{let t=r.indexOf(e);-1!==t&&r.splice(t,1),n(r)}),l.once("ready",()=>{o()}),process.on("SIGINT",o)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.8.7",
3
+ "version": "3.9.0",
4
4
  "description": "core",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",