@moneko/core 3.8.7-beta.4 → 3.8.7-beta.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/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{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};
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 r,PACKAGENAME as n,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";import{comment as C}from"./vm/docs.js";let P=["@moneko","neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app",".cache/http/data"],w={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:P,js:P,media:P,font:P,wasm:[]},mdx:{jsx:!1,development:c,jsxImportSource:u,providerImportSource:`@moneko/${r}/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&&(w.alias=Object.assign(w.alias,{"@pkg":i.componentsPath,[n]:i.componentsPath}));let b=w,v={},k={};try{e(i.configPath,t.R_OK);let o=(await g(i.configPath,"index")).default;v=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"===(b=s(b,v,k)).compiler&&b.minifier&&(b.minifier.js||Object.assign(b.minifier,{js:{type:"terser"}}),b.minifier.css||Object.assign(b.minifier,{css:{type:"cssnano"}})),!1===b.devtool&&(b.sourceMap=!1),!1===b.sourceMap&&(b.devtool=!1),b.fixBrowserRouter&&b.htmlPluginOption&&(b.htmlPluginOption.tags||(b.htmlPluginOption.tags=[]),b.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=b;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,CUSTOMCONFIG:a,log:f,comment:C};
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 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:!0,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:!0,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:20,ignored:/node_modules(?![\\/]@app)/,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
+ 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 k}from"./utils.js";let{HotModuleReplacementPlugin:j}=o,{yellow:y,green:$,grey:b,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),M=!1,O=!1;for(let e=0,t=E.length;e<t;e++)D.includes(E[e])&&(O=!0),B.includes(E[e])&&(M=!0);M||(M=d),O||(O=f);let P=O?(await import("stylelint-webpack-plugin")).default:null,_=M?(await import("eslint-webpack-plugin")).default:null,H=n.devServer.port||3e3,I=await p(H,65535,n.devServer.host),N=a("@moneko/mock")&&(await import("@moneko/mock")).default,W=h&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,F=!1===n.devtool||n.devtool?n.devtool:"eval-cheap-module-source-map";n.devServer.port=I;let G="/"===n.basename,L=n.devServer.https?"https:":"http:",R=G?"":n.basename,Y=n.devServer.port!==I&&x(`Port ${y(H)} is in use, trying ${$(I)} instead.
2
+ `);function q(e){return`${L}//${"local"===e?n.devServer.host:c()}:${I}${R}`}let z=x("You application is running here:"),J=`${S(" Local ")} ${C(q("local"))}
3
+ ${T(" Network ")} ${A(q("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 j,W&&new W,_&&new _({fix:!0,threads:!0,files:[`${n.alias["@"]}/**/*.{${Q}}`,u&&`${n.alias["@pkg"]}/**/*.{${Q}}`].filter(Boolean),extensions:K,exclude:X,cache:!0,lintDirtyModulesOnly:!0}),P&&new P({fix:!0,threads:!0,files:[`${n.alias["@"]}/**/*.{${V}}`,u&&`${n.alias["@pkg"]}/**/*.{${V}}`].filter(Boolean),extensions:U,exclude:X,cache:!0,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:G||{index:R.endsWith("/")?R:`${R}/`,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(N)&&N(t.app,k("mock/")),e},open:!1,hot:!0},et=o(r(i,{devtool:F,mode:"development",plugins:Z}));et.watch({aggregateTimeout:20,ignored:/node_modules(?![\\/]@app)/,stdin:!0},(e,t)=>{!e&&t&&(g([z,"",J,"",b(`Compiled successfully in ${$(`${t.endTime-t.startTime}ms`)}`)]),t.compilation.warnings.forEach(e=>g(e.message)),t.compilation.errors.forEach(e=>g(e.message)),Y&&g(Y))});let eo=new s(ee,et);eo.startCallback(e=>{e||g([z,"",J])}),eo.stopCallback(e=>{e||v(m.cachePath)}),process.on("exit",function(){et.close(()=>{}),eo.invalidate(),eo.stop()}),process.on("SIGINT",()=>{process.exit()});
@@ -0,0 +1 @@
1
+ "use strict";function e(e=""){let t=this.resourcePath,r=this.getOptions().comment.getData(`@app/comment/${t.split("/").slice(-2).join("/")}`);return this.cacheable(!0),r||e}Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return e}});
@@ -0,0 +1,6 @@
1
+ import type ReactiveObject from '../reactive-object.js';
2
+ import type { LoaderContext } from 'webpack';
3
+ export default function (this: LoaderContext<{
4
+ test: RegExp;
5
+ comment: ReactiveObject<Record<string, string>>;
6
+ }>, _?: string): string;
@@ -0,0 +1 @@
1
+ "use strict";function e(e=""){let t=this.getOptions().docs.getData("@app/docs");return this.cacheable(!0),t||e}Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return e}});
@@ -0,0 +1,6 @@
1
+ import type ReactiveObject from '../reactive-object.js';
2
+ import type { LoaderContext } from 'webpack';
3
+ export default function (this: LoaderContext<{
4
+ test: RegExp;
5
+ docs: ReactiveObject<Record<string, string>>;
6
+ }>, _?: string): string;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return r}});const e=/(?<!-)content\s*:\s*([^;\\}]+)/g,t=/[\u4e00-\u9faF]+/g;function r(r){return r.replace(e,function(e){return e.replace(t,function(e){return`\\${e.charCodeAt(0).toString(16)}`})})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return r}});const e=/(?<!-)content\s*:\s*([^;\\}]+)/g,t=/[\u4e00-\u9faF]+/g;function r(r){return this.cacheable(!0),r.replace(e,function(e){return e.replace(t,function(e){return`\\${e.charCodeAt(0).toString(16)}`})})}
@@ -1 +1,2 @@
1
- export default function (content: string): string;
1
+ import type { LoaderContext } from 'webpack';
2
+ export default function (this: LoaderContext<never>, content: string): string;
@@ -0,0 +1 @@
1
+ "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return k}});const t=require("path"),n=(e=require("typescript"))&&e.__esModule?e:{default:e},r=global.NEKOCLICONFIG.CONFIG,{ScriptKind:l,ScriptTarget:o,SyntaxKind:i,createSourceFile:u,forEachChild:a,getLeadingCommentRanges:c,isInterfaceDeclaration:s,isQuestionToken:f,isPropertySignature:p,isFunctionTypeNode:g,isUnionTypeNode:m,isMethodSignature:$}=n.default,d={};function b(e){let t=c(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 h(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}const 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(d[e]){let n=`/${[r.basename,d[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 E(e){return e?e.replace(/^@[a-z].+/gm,"").replace(/(\n\s+)+/g,"<br />").replace(/\n/g,"<br />").replace(/(<br \/>)$/g,""):null}function k(e,c){let j=u(c,e,o.Latest,!0,l.TS),k="";return a(j,e=>{s(e)?k+=function(e){let l=e.name.text;Object.assign(d,{[e.name.text]:(0,t.dirname)(e.getSourceFile().fileName).replace(r.alias["@pkg"],"")});let o=b(e),u=h(o),a=E(o),c=x(o)?.split("|")||[],s=c.includes("comment"),j=c.includes("initial"),k=c.includes("optional"),w=c.includes("version"),S=c.includes("author"),v=a?`\\color{|4||0.45}{${l}}`:l,O=(function(e){let t=[];if(e.heritageClauses){for(let r of e.heritageClauses)if(r.token===n.default.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>`),F=[a,v,u&&`\\color{#52c11b|1||0.9}{${u}}`,O.length>0&&`<sub>\`extends\`</sub> ${O.join(" ")}`].filter(Boolean).join(" "),N=`## ${F}`,C=e.members.filter(e=>p(e)&&e.type?.kind!==i.NeverKeyword||$(e)),q=[];if(C.length){C.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(!m(e.type))return g(e.type);for(let t of e.type.types)if(g(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,!k&&`\\color{${l?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${l?"✘":"✔"}}`,!s&&B(E(n)),t,!j&&B(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(n)),!w&&B(h(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),!w&&l[5]&&(t=!0),!S&&l[6]&&(e=!0)}),N+="\n";let l=["属性",!k&&"必要",r&&"说明","类型",n&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");N+=`|${l}|`;let i=[":-",!k&&":-",r&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);N+="\n";let u=i.join("|");N+=`|${u}|`,q.forEach(l=>{N+="\n";let o=[l[0]||"-",!k&&(l[1]||"-"),r&&(l[2]||"-"),l[3]||"-",n&&(l[4]||"-"),t&&(l[5]||"-"),e&&(l[6]||"-")].filter(Boolean).join("|");N+=`|${o}|`}),N+="\n"}return N+="\n"}(e):n.default.isEnumDeclaration(e)&&(k+=function(e){let l=e.name.text,o=b(e),i=E(o),u=h(o);Object.assign(d,{[e.name.text]:(0,t.dirname)(e.getSourceFile().fileName).replace(r.alias["@pkg"],"")});let a=i?`\\color{|4||0.45}{${l}}`:l,c=[i,a,u&&`\\color{#52c11b|1||0.9}{${u}}`].filter(Boolean).join(" "),s=x(o)?.split("|")||[],f=s.includes("comment"),p=s.includes("version"),g=s.includes("author"),m=`## ${c}`;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.default.isStringLiteral(t)?` '${t.text}'`:null}(e)),u=B(h(l)),a=B(E(l));!r||r.startsWith("\\color")||/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`),t.push([r,!f&&a,i,!p&&u,!g&&(y(l)||y(o))])});let r=!1,l=!1,i=!1;t.forEach(e=>{!f&&e[1]&&(i=!0),!p&&e[3]&&(l=!0),!g&&e[4]&&(r=!0)}),m+="\n";let u=["属性",i&&"说明","值",l&&"版本",r&&"作者"].filter(Boolean).join("|");m+=`|${u}|`;let a=[":-",i&&":-",":-",l&&":-",r&&":-"].filter(Boolean);m+="\n";let c=a.join("|");m+=`|${c}|`,t.forEach(e=>{m+="\n";let t=[e[0]||"-",i&&(e[1]||"-"),e[2]||"-",l&&(e[3]||"-"),r&&(e[4]||"-")].filter(Boolean).join("|");m+=`|${t}|`})}return m+="\n\n"}(e))}),k}
@@ -0,0 +1 @@
1
+ export default function generateDoc(content: string, path: string): string;
@@ -1 +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)}
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=>{this.cacheable(!0),n(null,e.code)}).catch(n)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return s}});const e="library"===process.env.APPTYPE,t=process.cwd();function s(s){let o=this.async(),r=this.resourcePath;e&&r.startsWith(`${t}/components`)&&console.log("docs",r),o(null,s)}
1
+ "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return i}});const t=require("fs"),s=(e=require("./generate-doc.cjs"))&&e.__esModule?e:{default:e},r={},a={};function i(e){let i=this.async(),c=this.resourcePath;void 0===a[c]&&(a[c]=0),(0,t.stat)(c,(t,l)=>{if(!t){let t=l.mtime.getTime();r[c]!==t&&(a[c]=a[c]+1,Object.assign(r,{[c]:t}),global.NEKOCLICONFIG.comment.setData(`@app/comment/${c.split("/").slice(-2).join("/").replace(/\.tsx?/,".md")}`,(0,s.default)(e,c)))}this.cacheable(a[c]>1),i(null,e)})}
@@ -1,2 +1,4 @@
1
1
  import type { LoaderContext } from 'webpack';
2
- export default function (this: LoaderContext<Record<string, string>>, value: string): void;
2
+ export default function (this: LoaderContext<{
3
+ test: RegExp;
4
+ }>, value: string): void;
@@ -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 l from"./modify-vars.js";import a,{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:`${a.corePath}/loader/css-unicode.cjs`},x=d?o:"../",$={loader:e.loader,options:{publicPath:"/"!==x?x:"../"}},g=r("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:(await import("@moneko/postcss")).default}};c&&($="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 h={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}},b=c&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!c}},k=[$,b,h,g,y,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:l,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 P=L("media"),R={rules:[{test:/\.tsx?$/i,include:t.alias["@"],exclude:[/node_modules/],enforce:"pre",use:[`${a.corePath}/loader/ts-doc.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:L("wasm")},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:P},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>s(e.toString())},include:P},{test:/\.(gif|png|jpe?g|webp)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext]"},include:P},{test:/\.(webm|mp4|ogv)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[name][ext]"},include:P},{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:[$,b,h,g,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:[$,"css-loader",g,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:`${a.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 R;
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 l from"./modify-vars.js";import a,{CUSTOMCONFIG as i}from"./paths.js";import{FRAMEWORK as n,isDev as c,isLibrary as d,isMicro as m}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:`${a.corePath}/loader/css-unicode.cjs`},$=m?o:"../",g={loader:e.loader,options:{publicPath:"/"!==$?$:"../"}},v=r("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:(await import("@moneko/postcss")).default}};c&&(g="style-loader");let j=[...t.cssModules,`@moneko/${n}`,"neko-ui"].map(f),w=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(y)],h=["components","example","mock","site","src","server"].map(y);i&&h.push(y(i)),t.overrideResolve&&t.overrideResolve.override&&h.push(t.overrideResolve.override);let b={loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,t=j.length;s<t;s++)if(e&&e?.includes(j[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}},_=c&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!c}},k=[g,_,b,v,x,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:l,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:w}}].filter(Boolean),O="tsc"===t.compiler,B={loader:O?"ts-loader":"swc-loader",options:O?u:p(c)};function L(e){return h.concat(t.rulesInclude?.[e]?.map(f)||[])}let P=L("media"),R={rules:[d&&{test:/^(?![._]).*(?<!\.test)\.(tsx?)$/,include:t.alias["@pkg"],exclude:[/node_modules/,/(.+)\/__tests__\/(.+)/i],enforce:"pre",use:[{loader:`${a.corePath}/loader/ts-doc.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:L("wasm")},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:P},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>s(e.toString())},include:P},{test:/\.(gif|png|jpe?g|webp)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext]"},include:P},{test:/\.(webm|mp4|ogv)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[name][ext]"},include:P},{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,_,b,v,x,{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",v,x].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:`${a.corePath}/loader/mdx.cjs`,options:t.mdx}].filter(Boolean),include:h,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 R;
@@ -1 +1 @@
1
- import{isDev as o}from"../process-env.js";import{vmWriteing as t}from"../reactive-object.js";let e="DoneWebpackPlugin";export default class{constructor(o){this.options=Object.assign({},o)}apply(s){o||s.hooks.compilation.tap(e,o=>{t.setData("DoneDonePlugin",!0),o.compiler.hooks.done.tap(e,()=>{t.setData("DoneDonePlugin",!1)})}),s.hooks.done.tap(e,o=>{this.options.done(o)})}}
1
+ export default class{constructor(o){this.options=Object.assign({},o)}apply(o){o.hooks.done.tap("DoneWebpackPlugin",o=>{this.options.done(o)})}}
@@ -1 +1 @@
1
- import o from"webpack-virtual-modules";import{isLibrary as t}from"../process-env.js";import{vmWriteing as e}from"../reactive-object.js";import{docs as s}from"../vm/docs.js";import{exampleModuleName as a,examples as p}from"../vm/example.js";import{locales as r,localesModuleName as i}from"../vm/locales.js";import{route as l,routesModuleName as m}from"../vm/routes.js";let n="VirtualModuleWebpackPlugin";export default class{constructor(o){this.options=o,this.hasTapped=!1}apply(d){let f=new o({[`node_modules/${m}`]:l.getData(m),[`node_modules/${a}`]:"export default []",[`node_modules/${i}`]:r.getData(i)});f.apply(d),d.hooks.compilation.tap(n,o=>{if(!this.hasTapped){let a=(t,s)=>{let a=`node_modules/${t}`;e.setData(a,!0),f.writeModule(a,s||""),o.compiler.hooks.done.tap(n,()=>{e.setData(a,!1)})};for(let o in this.options)if(Object.prototype.hasOwnProperty.call(this.options,o)){let t=this.options[o];a(o,"string"==typeof t?t:`export default ${JSON.stringify(t)}`)}for(let o of p)a(...o);for(let o of s)a(...o);l.on("change",a),r.on("change",a),t&&(p.on("change",a),s.on("change",a)),this.hasTapped=!0}})}}
1
+ import o from"webpack-virtual-modules";import{isLibrary as t}from"../process-env.js";import{resolveNodeModulesPath as e}from"../utils.js";import{comment as p,docs as s,docsModuleName as a}from"../vm/docs.js";import{exampleModuleName as r,examples as i}from"../vm/example.js";import{locales as l,localesModuleName as n}from"../vm/locales.js";import{route as f,routesModuleName as m}from"../vm/routes.js";export default class{constructor(o){this.options=o,this.hasTapped=!1}apply(c){let h=new o({[e(m)]:f.getData(m),[e(r)]:"export default []",[e(n)]:l.getData(n),[e(a)]:s.getData(a)});function u(o,t){let p=e(o);h.writeModule(p,t||"")}h.apply(c),f.on("change",u),l.on("change",u),t&&(i.on("change",u),s.on("change",u),p.on("change",u)),c.hooks.compilation.tap("VirtualModuleWebpackPlugin",()=>{if(!this.hasTapped){for(let o in this.hasTapped=!0,this.options)if(Object.prototype.hasOwnProperty.call(this.options,o)){let t=this.options[o];u(o,"string"==typeof t?t:`export default ${JSON.stringify(t)}`)}for(let o of i)u(...o);for(let o of s)u(...o);for(let o of p)u(...o)}})}}
@@ -1 +1 @@
1
- import{readFileSync as e}from"fs";import t from"./paths.js";export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;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 mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const createElement={react:"createElement",solid:"createComponent"}[FRAMEWORK];export const FRAMEWORKNAME={react:"react",solid:"solid-js"}[FRAMEWORK];export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;let o=e(`${t.corePath}/../package.json`,{encoding:"utf-8"});export const coreName=JSON.parse(o).name;export const isDev="development"===process.env.NODE_ENV;let s=Object.keys(process.env);export const hasEslintConfig=-1!==s.findIndex(e=>e.startsWith("npm_package_eslintConfig_"));export const hasStylelintConfig=-1!==s.findIndex(e=>e.startsWith("npm_package_stylelint_"));
1
+ export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;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 mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const createElement={react:"createElement",solid:"createComponent"}[FRAMEWORK];export const FRAMEWORKNAME={react:"react",solid:"solid-js"}[FRAMEWORK];export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;export const coreName="@moneko/core";export const isDev="development"===process.env.NODE_ENV;let e=Object.keys(process.env);export const hasEslintConfig=-1!==e.findIndex(e=>e.startsWith("npm_package_eslintConfig_"));export const hasStylelintConfig=-1!==e.findIndex(e=>e.startsWith("npm_package_stylelint_"));
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 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,g="swc"===a.compiler,j=[];a.minifier&&(a.minifier.js&&j.push(new n(l(a.minifier.js?.type||(g?"swc":"terser"),a.minifier.js?.options))),a.minifier.css&&j.push(new i({minify:{swc:b,cssnano:k}[a.minifier.css?.type||(g?"swc":"cssnano")],minimizerOptions:a.minifier.css?.options})));let y={splitChunks:a.splitChunk,runtimeChunk:a.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:j},z=m(t(p,{devtool:!1===a.devtool||a.devtool?a.devtool:"cheap-module-source-map",mode:"production",optimization:y,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({aggregateTimeout:20,ignored:/node_modules(?![\\/]@app)/,stdin:!0},()=>{}),f.on("change",()=>{clearTimeout(e);let i=f.data;for(let e in i)if(i[e])return;e=setTimeout(()=>{z.close(()=>{})},300)}),process.on("exit",function(){h(c.cachePath)});
1
+ import e from"css-minimizer-webpack-plugin";import i from"mini-css-extract-plugin";import o from"terser-webpack-plugin";import n from"webpack";import{BundleAnalyzerPlugin as m}from"webpack-bundle-analyzer";import{merge as r}from"webpack-merge";import s from"webpackbar";import{clientConfig as t}from"./common.js";import{CONFIG as p}from"./config.js";import{getMinifyOption as a}from"./minify.js";import l from"./paths.js";import c from"./plugin/done.js";import u from"./seo.js";import{cleanDir as f}from"./utils.js";let{optimize:{MinChunkSizePlugin:d}}=n,{cssnanoMinify:h,swcMinify:w}=e,k="swc"===p.compiler,b=[];p.minifier&&(p.minifier.js&&b.push(new o(a(p.minifier.js?.type||(k?"swc":"terser"),p.minifier.js?.options))),p.minifier.css&&b.push(new e({minify:{swc:w,cssnano:h}[p.minifier.css?.type||(k?"swc":"cssnano")],minimizerOptions:p.minifier.css?.options})));let g={splitChunks:p.splitChunk,runtimeChunk:p.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:b},j=n(r(t,{devtool:!1===p.devtool||p.devtool?p.devtool:"cheap-module-source-map",mode:"production",optimization:g,plugins:[new i({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),p.splitChunk&&new d({minChunkSize:1e4}),p.bundleAnalyzer&&new m(p.bundleAnalyzer),p.bar&&new s(p.bar),new c({done:e=>{p.done?.(e),p.seo&&u()}})].filter(Boolean)}));j.watch({aggregateTimeout:20,ignored:/node_modules(?![\\/]@app)/,stdin:!0},e=>{if(e)throw j.close(()=>{}),e;j.hooks.done.tap("WatchRunPlugin",e=>{e.hasErrors(),j.close(()=>{})})}),process.on("exit",function(){f(l.cachePath)});
@@ -8,7 +8,6 @@ declare class WriteingReactiveObject<T extends object = Record<string, string |
8
8
  removeData(key: keyof T): void;
9
9
  [Symbol.iterator](): Iterator<[keyof T, T[keyof T]]>;
10
10
  }
11
- export declare const vmWriteing: WriteingReactiveObject<Record<string, boolean>>;
12
11
  declare class ReactiveObject<T extends object = Record<string, string | undefined>> extends WriteingReactiveObject<T> {
13
12
  readonly data: T;
14
13
  constructor(props?: T);
@@ -1 +1 @@
1
- import t from"events";import{isDev as e}from"./process-env.js";class a extends t{constructor(t={}){super(),this.data=t}setData(t,a){e||a===this.data[t]||(this.data[t]=a,this.emit("change",t,a))}getData(t){return this.data[t]}removeData(t){Object.prototype.hasOwnProperty.call(this.data,t)&&(delete this.data[t],this.emit("change",t,null))}[Symbol.iterator](){let t=Object.keys(this.data),e=0;return{next:()=>{if(e<t.length){let a=t[e++];return{value:[a,this.data[a]],done:!1}}return{value:void 0,done:!0}}}}}export const vmWriteing=new a({done:!0});export default class extends a{constructor(t={}){super(),this.data=t}setData(t,e){e!==this.data[t]&&(this.data[t]=e,this.emit("change",t,e))}}
1
+ import t from"events";import{isDev as e}from"./process-env.js";class a extends t{constructor(t={}){super(),this.data=t}setData(t,a){e||a===this.data[t]||(this.data[t]=a,this.emit("change",t,a))}getData(t){return this.data[t]}removeData(t){Object.prototype.hasOwnProperty.call(this.data,t)&&(delete this.data[t],this.emit("change",t,null))}[Symbol.iterator](){let t=Object.keys(this.data),e=0;return{next:()=>{if(e<t.length){let a=t[e++];return{value:[a,this.data[a]],done:!1}}return{value:void 0,done:!0}}}}}export default class extends a{constructor(t={}){super(),this.data=t}setData(t,e){e!==this.data[t]&&(this.data[t]=e,this.emit("change",t,e))}}
package/lib/vm/docs.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  import ReactiveObject from '../reactive-object.js';
2
- export declare const docs: ReactiveObject<Record<string, string | undefined>>;
2
+ export declare const docsModuleName = "@app/docs";
3
+ export declare const docs: ReactiveObject<Record<string, string>>;
4
+ export declare const comment: ReactiveObject<Record<string, string>>;
package/lib/vm/docs.js CHANGED
@@ -1 +1 @@
1
- import{statSync as e}from"fs";import{dirname as t,join as o}from"path";import{watch as r}from"chokidar";import{CONFIG as n}from"../config.js";import s from"../generate-api.js";import i from"../paths.js";import{FRAMEWORK as a,FRAMEWORKNAME as p,createElement as l,isDev as c,isLibrary as d,isReact as m,isSolid as f}from"../process-env.js";import u,{vmWriteing as $}from"../reactive-object.js";let h="@app/comment";export const docs=new u;let g={[h]:{}},b=`() => ${l}(SuspenseComp, { comp: $1 })`,x=`import { ${l}${f?",Dynamic":""} } from "${p}${f?"/web":""}";import SuspenseComp from "@app/suspense";`;function j(e,r){let i=e.replace(RegExp(`^${n.alias["@pkg"]}`),""),a=t(i).replace(/^\//,""),p=[h,a].join("/"),c=i.split("/").pop()?.replace(/\.tsx?/,".md");if(!c)return;g[h][a]||(g[h][a]={});let d=o(p,c);if("deleted"===r)g[h][a][c]&&delete g[h][a][c];else{let t=s(e);g[d]=t,t?g[h][a][c]=`rr(() => import(/* webpackChunkName: '${d}' */'${d}?raw').then((res) => ({default: ${m?"() =>":""}${l}(${f?"Dynamic":"'n-md'"}, {text: res.default, ${f?"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`:g[h][a][c]&&delete g[h][a][c]}let u={};for(let e in g)if(Object.prototype.hasOwnProperty.call(g,e)){let t=g[e];if(e===h)for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(u[e]=Object.values(t[e]));else docs.setData(e,t)}docs.setData("@app/docs",`${x}export default ${JSON.stringify(u).replace(/"rr\((.+?)\)rr"/g,b)}`)}["react","solid"].includes(a)||(b="$1",x=""),d&&function(){$.setData("vm-docs",!0);let t=[],o=r(i.componentsPath,{ignored:[/(^|\/)\../,/(^|\/)__tests__(\/|$)/],persistent:!0,ignoreInitial:!1});function n(){o.unwatch(i.componentsPath),o.close(),$.setData("vm-docs",!1)}function s(t){return/\.tsx?$/.test(t)&&e(t).isFile()}o.on("add",e=>{s(e)&&(j(e,"added"),t.push(e))}),o.on("change",e=>{s(e)&&j(e,"change")}),o.on("unlink",e=>{s(e)&&(j(e,"deleted"),t.splice(t.indexOf(e),1))}),o.once("ready",()=>{t.forEach(e=>{j(e,"change")}),c||n()}),process.on("SIGINT",n)}();
1
+ import{FRAMEWORK as e,FRAMEWORKNAME as o,createElement as t,isReact as r,isSolid as n}from"../process-env.js";import s from"../reactive-object.js";export const docsModuleName="@app/docs";export const docs=new s({[docsModuleName]:"export default {}"});export const comment=new s({});let p={},a=`() => ${t}(SuspenseComp, { comp: $1 })`,c=`import { ${t}${n?",Dynamic":""} } from "${o}${n?"/web":""}";import SuspenseComp from "@app/suspense";`;["react","solid"].includes(e)||(a="$1",c=""),comment.on("change",(e,o)=>{!function(e,o){let[s,l]=e.replace(/^@app\/comment\//,"").split("/");p[s]||(p[s]={}),o?p[s][l]&&delete p[s][l]:p[s][l]=`rr(() => import(/* webpackChunkName: '${e}' */'${e}?raw').then((res) => ({default: ${r?"() =>":""}${t}(${n?"Dynamic":"'n-md'"}, {text: res.default, ${n?"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 i={};for(let e in p)Object.prototype.hasOwnProperty.call(p,e)&&(i[e]=Object.values(p[e]));docs.setData(docsModuleName,`${c}export default ${JSON.stringify(i).replace(/"rr\((.+?)\)rr"/g,a)}`)}(e,o?.length<0)});
package/lib/vm/example.js CHANGED
@@ -1 +1 @@
1
- let e;import{getTree as o,watchFiles as t}from"./utils.js";import r from"../paths.js";import{isLibrary as a}from"../process-env.js";import m from"../reactive-object.js";export const exampleModuleName="@app/example";export const examples=new m;a&&t(r.componentsPath,/(?<!\/examples\/(.+)\.md)$/,function(t){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),o({base:r.componentsPath,files:t,outputSource:!0}).forEach(e=>{let o=(e.children||[]).filter(e=>e.codes).map(e=>({title:e.path.replace(/.md$/,""),order:0,...e.meta,codes:e.codes})).sort((e,o)=>e.order-o.order);examples.setData(["@app/example",e.key].filter(Boolean).join("/"),`export default ${JSON.stringify(o)};`)})},8)},"vm-examples");
1
+ let e;import{getTree as o,watchFiles as t}from"./utils.js";import r from"../paths.js";import{isLibrary as a}from"../process-env.js";import p from"../reactive-object.js";export const exampleModuleName="@app/example";export const examples=new p;a&&t(r.componentsPath,/(?<!\/examples\/(.+)\.md)$/,function(t){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e),o({base:r.componentsPath,files:t,outputSource:!0}).forEach(e=>{let o=(e.children||[]).filter(e=>e.codes).map(e=>({title:e.path.replace(/.mdx$/,""),order:0,...e.meta,codes:e.codes})).sort((e,o)=>e.order-o.order);examples.setData(["@app/example",e.key].filter(Boolean).join("/"),`export default ${JSON.stringify(o)};`)})},10)});
@@ -0,0 +1 @@
1
+ export declare function scanfolder(folderPath: string, condition: (file: string) => boolean, list?: string[]): string[];
@@ -0,0 +1 @@
1
+ import{readdirSync as r,statSync as o}from"fs";import{join as t}from"path";export function scanfolder(f,e,c=[]){return r(f).forEach(r=>{let i=t(f,r);o(i).isDirectory()?scanfolder(i,e,c):e(i)&&c.push(i)}),c}
package/lib/vm/locales.js CHANGED
@@ -1,2 +1,2 @@
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(/\.[^.]+$/,"");"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$/]);
1
+ import{existsSync as e}from"fs";import{basename as t,join as o}from"path";import{watch as a}from"chokidar";import{CONFIG as l}from"../config.js";import{FRAMEWORK as r,isDev as n}from"../process-env.js";import c from"../reactive-object.js";import{empty as s,esm as i,tfc as g}from"../utils.js";let f={react:'import sso from "shared-store-object";',solid:'import { createEffect, createRoot, getOwner } from "solid-js";import { createStore } from "solid-js/store";'},u={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 p(e,t){return`${f[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);${u}`}export const localesModuleName="@app/locales";export const locales=new c({[localesModuleName]:p([],{})});let d={};async function m(e,o){let a=t(e).replace(/\.[^.]+$/,"");"deleted"===o?delete d[a]:Object.assign(d,{[a]:(await import(i`${g(e)}`)).default});let l=[],r={};for(let e in d)if(Object.prototype.hasOwnProperty.call(d,e)){let{language:t=a,title:o=t,icon:n,translation:c={}}=d[e];l.push({language:t,title:o,icon:n}),r[t]={language:t,title:o,icon:n,translation:c}}locales.setData(localesModuleName,p(l,r))}let z=o(l.alias["@"],"./locales");e(z)&&function(e,t){let o=[],l=a(e,{ignored:t,persistent:!0,ignoreInitial:!1});function r(){l.unwatch(e),l.close()}l.on("add",e=>{o.push(e),m(e,"added").finally(s)}),l.on("change",e=>{m(e,"change").finally(s)}),l.on("unlink",e=>{o.splice(o.indexOf(e),1),m(e,"deleted").finally(s)}),l.once("ready",()=>{o.forEach(e=>{m(e,"change").finally(s)}),n||r()}),process.on("SIGINT",r)}(z,[/^\..*/,/!\.ts$/,/\.d\.ts$/]);
package/lib/vm/routes.js CHANGED
@@ -1 +1 @@
1
- let e,r;import{accessSync as t,constants as o}from"fs";import{getTree as s,mergeRouter as p,watchFiles as m}from"./utils.js";import{CONFIG as u}from"../config.js";import i from"../paths.js";import{FRAMEWORK as a,FRAMEWORKNAME as c,createElement as f,isLibrary as l,isReact as n,isSolid as $}from"../process-env.js";import x from"../reactive-object.js";try{t(`${u.alias["@"]}/router/index.ts`,o.R_OK),e=!0}catch(r){e=!1}let d=`${$?"() => ":""}${f}(SuspenseComp, { comp: $1 })`,g=`import { ${f} } from "${c}";import SuspenseComp from "@app/suspense";${n?'import prefix from "@app/prefix-router";':""}`;e&&(g+='import merge from "@app/merge-router";import customRouter from "@/router";'),["react","solid"].includes(a)||(d="$1",g="");export const routesModuleName="@app/routes";export const route=new x({[routesModuleName]:"export default []"});export let routes=[];let h=l?i.componentsPath:i.pagesPath,j=l?"@pkg":"@/pages";m(h,l?/(?<!README\.mdx?)$/:/(?<!index\.tsx?)$/,function(t){clearTimeout(r),r=setTimeout(()=>{var o;clearTimeout(r),routes=p(s({base:h,files:t,alia:j}).reverse(),"key"),route.setData(routesModuleName,(o=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,d).slice(1,-1),`${g}const routes = [{ path: "/", children: [${$?'{ path: "/" },':""} ${o}] }];const _routes = ${e?'merge([...routes, ...customRouter], "path")':"routes"};export default ${n?"prefix(_routes)":"_routes"};`))},8)},"vm-router");
1
+ let e,r;import{accessSync as t,constants as o}from"fs";import{getTree as s,mergeRouter as p,watchFiles as m}from"./utils.js";import{CONFIG as u}from"../config.js";import i from"../paths.js";import{FRAMEWORK as a,FRAMEWORKNAME as c,createElement as f,isLibrary as l,isReact as n,isSolid as $}from"../process-env.js";import x from"../reactive-object.js";try{t(`${u.alias["@"]}/router/index.ts`,o.R_OK),e=!0}catch(r){e=!1}let d=`${$?"() => ":""}${f}(SuspenseComp, { comp: $1 })`,g=`import { ${f} } from "${c}";import SuspenseComp from "@app/suspense";${n?'import prefix from "@app/prefix-router";':""}`;e&&(g+='import merge from "@app/merge-router";import customRouter from "@/router";'),["react","solid"].includes(a)||(d="$1",g="");export const routesModuleName="@app/routes";export const route=new x({[routesModuleName]:"export default []"});export let routes=[];let h=l?i.componentsPath:i.pagesPath,j=l?"@pkg":"@/pages";m(h,l?/(?<!README\.mdx?)$/:/(?<!index\.tsx?)$/,function(t){clearTimeout(r),r=setTimeout(()=>{var o;clearTimeout(r),routes=p(s({base:h,files:t,alia:j}).reverse(),"key"),route.setData(routesModuleName,(o=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,d).slice(1,-1),`${g}const routes = [{ path: "/", children: [${$?'{ path: "/" },':""} ${o}] }];const _routes = ${e?'merge([...routes, ...customRouter], "path")':"routes"};export default ${n?"prefix(_routes)":"_routes"};`))},10)});
package/lib/vm/utils.d.ts CHANGED
@@ -15,5 +15,5 @@ type TreeOption = {
15
15
  outputSource?: boolean;
16
16
  };
17
17
  export declare function getTree(opt: TreeOption): BaseRoute[];
18
- export declare function watchFiles(root: string, ignored: RegExp, call: (files: string[]) => void, name: string): void;
18
+ export declare function watchFiles(root: string, ignored: RegExp, call: (files: string[]) => void): void;
19
19
  export {};
package/lib/vm/utils.js CHANGED
@@ -1 +1 @@
1
- import{readFile as e}from"fs";import{join as t,relative as n}from"path";import{frontmatter as r}from"@moneko/mdx";import{watch as a}from"chokidar";import{isDev as o,isSolid as i}from"../process-env.js";import l,{vmWriteing as s}from"../reactive-object.js";let c=new l({}),h=i?"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 a=[...n[r].children||[],...e.children||[]];n[r]=Object.assign(e,n[r]),a.length&&(n[r].children=mergeRouter(a,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=[],...a}=e;n[t]={path:a.path,key:a.key,children:[i&&{...a,path:e.path===a.path?"/":a.path},...r].filter(e=>e&&(e.component||e.children?.length))}}}),n}export function getTree(e){let r={};return e.files.forEach(a=>{let o=c.getData(a)||{code:""},i=n(e.base,a),l=e.base.split("/").filter(Boolean),s=a.split("/").filter(Boolean).slice(0,-1),p={},f=Object.assign({meta:JSON.parse(o.frontmatter||"{}")},e.alia&&{[h]:`rr(() => import(/* webpackChunkName: '${i}' */'${t(e.alia,i)}'))rr`},e.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}}(o.code.replace(/^\n+|\n+$/g,""))});for(let t=l.length;t<s.length;t++){let n={path:s[t],key:s[t]};t===l.length?(Object.assign(p,r[n.key],{path:n.path,key:n.key},t===s.length-1&&f),r[n.key]=p):(p.children=(p.children||[]).concat([n]),e.outputSource?(Object.assign(n,{path:a.split("/").pop(),key:a.split("/").pop()},f),n.children=getTree({...e,base:`${e.base}/${n.key}`,files:e.files.filter(t=>t.startsWith(`${e.base}/${n.key}`))})):Object.assign(n,{key:s.slice(l.length,t+1).join("/")},f),p=n)}}),Object.values(r)}function p(t,n,a){a?(c.removeData(t),n.removeData(t)):e(t,{encoding:"utf-8"},(e,a)=>{e||(t.endsWith(".md")||t.endsWith(".mdx")?r(a).then(e=>{c.setData(t,e),n.setData(t,!0)}):(c.setData(t,{code:a,frontmatter:"{}"}),n.setData(t,!0)))})}export function watchFiles(e,t,n,r){s.setData(r,!0);let i=new l({}),c=a(e,{ignored:(e,n)=>{if(n)return!n.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!1});function h(){c.unwatch(e),c.close(),s.setData(r,!1)}c.on("add",e=>{p(e,i)}).on("change",e=>{p(e,i)}).on("unlink",e=>{p(e,i,!0)}),c.once("ready",()=>{o||h()}),i.on("change",()=>{n(Object.keys(i.data))}),process.on("SIGINT",h)}
1
+ import{readFileSync as e}from"fs";import{join as t,relative as n}from"path";import{frontmatterSync as r}from"@moneko/mdx";import{watch as i}from"chokidar";import{isDev as o,isSolid as a}from"../process-env.js";import l from"../reactive-object.js";let s=new l({}),c=a?"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:[a&&{...i,path:e.path===i.path?"/":i.path},...r].filter(e=>e&&(e.component||e.children?.length))}}}),n}export function getTree(e){let r={};return e.files.forEach(i=>{let o=s.getData(i)||{code:""},a=n(e.base,i),l=e.base.split("/").filter(Boolean),h=i.split("/").filter(Boolean).slice(0,-1),p={},f=Object.assign({meta:JSON.parse(o.frontmatter||"{}")},e.alia&&{[c]:`rr(() => import(/* webpackChunkName: '${a}' */'${t(e.alia,a)}'))rr`},e.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}}(o.code.replace(/^\n+|\n+$/g,""))});for(let t=l.length;t<h.length;t++){let n={path:h[t],key:h[t]};t===l.length?(Object.assign(p,r[n.key],{path:n.path,key:n.key},t===h.length-1&&f),r[n.key]=p):(p.children=(p.children||[]).concat([n]),e.outputSource?(Object.assign(n,{path:i.split("/").pop(),key:i.split("/").pop()},f),n.children=getTree({...e,base:`${e.base}/${n.key}`,files:e.files.filter(t=>t.startsWith(`${e.base}/${n.key}`))})):Object.assign(n,{key:h.slice(l.length,t+1).join("/")},f),p=n)}}),Object.values(r)}function h(t,n,i){if(i)s.removeData(t),n.removeData(t);else{let i=e(t,{encoding:"utf-8"});if(t.endsWith(".md")||t.endsWith(".mdx")){let e=r(i);s.setData(t,e),n.setData(t,!0)}else s.setData(t,{code:i,frontmatter:"{}"}),n.setData(t,!0)}}export function watchFiles(e,t,n){let r=new l({}),a=i(e,{ignored:(e,n)=>{if(n)return!n.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!1});function s(){a.unwatch(e),a.close()}a.on("add",e=>{h(e,r)}).on("change",e=>{h(e,r)}).on("unlink",e=>{h(e,r,!0)}),a.once("ready",()=>{o||s()}),r.on("change",()=>{n(Object.keys(r.data))}),process.on("SIGINT",s)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.8.7-beta.4",
3
+ "version": "3.8.7-beta.6",
4
4
  "description": "core",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- export default function generateApi(path: string): string;
@@ -1 +0,0 @@
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}
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- export {};