@moneko/core 3.8.7-beta.8 → 3.8.8
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 +1 -1
- package/lib/config.js +1 -1
- package/lib/html-plugin-option.js +1 -1
- package/lib/loader/ts-doc.cjs +1 -1
- package/lib/loader/ts-doc.d.cts +4 -1
- package/lib/module.config.js +1 -1
- package/lib/swcrc.js +1 -1
- package/lib/vm/docs.js +9 -1
- package/lib/vm/example.js +1 -1
- package/lib/vm/generate-doc.js +1 -0
- package/lib/vm/locales.js +2 -2
- package/lib/vm/routes.js +1 -1
- package/lib/vm/utils.d.ts +1 -1
- package/lib/vm/utils.js +1 -1
- package/package.json +1 -1
- package/lib/loader/app-comment.cjs +0 -1
- package/lib/loader/app-comment.d.cts +0 -6
- package/lib/loader/app-docs.cjs +0 -1
- package/lib/loader/app-docs.d.cts +0 -6
- package/lib/loader/generate-doc.cjs +0 -1
- /package/lib/{loader/generate-doc.d.cts → vm/generate-doc.d.ts} +0 -0
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{CONFIG as l,PUBLICPATH as r}from"./config.js";import s from"./html-plugin-option.js";import n from"./module-federation.js";import a from"./module.config.js";import i,{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";let{AutomaticPrefetchPlugin:w,DefinePlugin:v,SourceMapDevToolPlugin:k,WatchIgnorePlugin:x}=o,C=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 O={main:b("@app/entry")};l.polyfill&&Object.assign(O,{"dom-polyfills":[`${i.corePath}/polyfills/replace-children.js`]}),l.entry&&("string"==typeof l.entry?O={main:l.entry}:Object.keys(l.entry)&&Object.assign(O,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let $=l.basename.split("/").filter(Boolean).length,P=`${Array($).fill("..").join("/")+($?"/":"")}404.html`,{pathSegmentsToKeep:M=$,path:B=P}=l.fixBrowserRouter||{},D=!1;l.cacheDirectory&&(D={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:l.cacheDirectory,memoryCacheUnaffected:!0,name:[p,process.env.NODE_ENV].filter(Boolean).join("-"),version:h});let R=Object.assign({original:l.alias["@"],override:p&&j(p)},l.overrideResolve);export const clientConfig={entry:O,stats:"errors-only",cache:D,infrastructureLogging:{level:"error"},target:"web",externalsPresets:l.externalsPresets,plugins:[...n,new u(l.virtualModule||{}),new w,l.htmlPluginOption&&new t(s),l.fixBrowserRouter&&new t({filename:B,inject:!1,templateContent:()=>`<html lang="en"><head><title>${s.title}</title><script>const pathKeep = ${M||$};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(C),y&&new c(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new v({"process.env":JSON.stringify(l.env)}),new x({paths:[/\.d\.ts$/]}),l.sourceMap&&new k(l.sourceMap),...l.plugins].filter(e=>!!e),node:{global:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:d&&{imports:!
|
|
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 n from"./module-federation.js";import a from"./module.config.js";import i,{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";let{AutomaticPrefetchPlugin:w,DefinePlugin:v,SourceMapDevToolPlugin:k,WatchIgnorePlugin:x}=o,C=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 O={main:b("@app/entry")};l.polyfill&&Object.assign(O,{"dom-polyfills":[`${i.corePath}/polyfills/replace-children.js`]}),l.entry&&("string"==typeof l.entry?O={main:l.entry}:Object.keys(l.entry)&&Object.assign(O,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let $=l.basename.split("/").filter(Boolean).length,P=`${Array($).fill("..").join("/")+($?"/":"")}404.html`,{pathSegmentsToKeep:M=$,path:B=P}=l.fixBrowserRouter||{},D=!1;l.cacheDirectory&&(D={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:l.cacheDirectory,memoryCacheUnaffected:!0,name:[p,process.env.NODE_ENV].filter(Boolean).join("-"),version:h});let R=Object.assign({original:l.alias["@"],override:p&&j(p)},l.overrideResolve);export const clientConfig={entry:O,stats:"errors-only",cache:D,infrastructureLogging:{level:"error"},target:"web",externalsPresets:l.externalsPresets,plugins:[...n,new u(l.virtualModule||{}),new w,l.htmlPluginOption&&new t(s),l.fixBrowserRouter&&new t({filename:B,inject:!1,templateContent:()=>`<html lang="en"><head><title>${s.title}</title><script>const pathKeep = ${M||$};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(C),y&&new c(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new v({"process.env":JSON.stringify(l.env)}),new x({paths:[/\.d\.ts$/]}),l.sourceMap&&new k(l.sourceMap),...l.plugins].filter(e=>!!e),node:{global:!1},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(R),...l.resolvePlugins].filter(Boolean),fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:a,externals:l.externals,output:outputConfig};
|
package/lib/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fileExists as e}from"@moneko/mdx";import
|
|
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
|
|
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/loader/ts-doc.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return i}});const e=require("fs"),t={},s={};function i(i){let r=this.resourcePath,{comment:n,generateDoc:c}=this.getOptions();return void 0===s[r]&&(s[r]=0),(0,e.stat)(r,(e,o)=>{if(!e){let e=o.mtime.getTime();t[r]!==e&&(s[r]=s[r]+1,Object.assign(t,{[r]:e}),n.setData(`@app/comment/${r.split("/").slice(-2).join("/").replace(/\.tsx?/,".md")}`,c(i,r)))}}),this.cacheable(!0),i}
|
package/lib/loader/ts-doc.d.cts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type ReactiveObject from '../reactive-object.js';
|
|
2
2
|
import type { LoaderContext } from 'webpack';
|
|
3
|
-
export default function (this: LoaderContext<
|
|
3
|
+
export default function (this: LoaderContext<{
|
|
4
|
+
comment: ReactiveObject<Record<string, string>>;
|
|
5
|
+
generateDoc(content: string, path: string): string;
|
|
6
|
+
}>, value: string): string;
|
package/lib/module.config.js
CHANGED
|
@@ -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
|
|
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 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";import{comment as x}from"./vm/docs.js";import g from"./vm/generate-doc.js";let $={loader:`${l.corePath}/loader/css-unicode.cjs`},v=m?o:"../",j={loader:e.loader,options:{publicPath:"/"!==v?v:"../"}},w=r("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:(await import("@moneko/postcss")).default}};c&&(j="style-loader");let h=[...t.cssModules,`@moneko/${n}`,"neko-ui"].map(f),b=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(y)],_=["components","example","mock","site","src","server"].map(y);i&&_.push(y(i)),t.overrideResolve&&t.overrideResolve.override&&_.push(t.overrideResolve.override);let k={loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,t=h.length;s<t;s++)if(e&&e?.includes(h[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}},O=c&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!c}},B=[j,O,k,w,$,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:b}}].filter(Boolean),L="tsc"===t.compiler,P={loader:L?"ts-loader":"swc-loader",options:L?u:p(c)};function R(e){return _.concat(t.rulesInclude?.[e]?.map(f)||[])}let M=R("media"),I={rules:[d&&c&&{test:/^(?![._]).*(?<!\.test)\.(tsx?)$/,include:t.alias["@pkg"],exclude:[/node_modules/,/(.+)\/__tests__\/(.+)/i],enforce:"pre",loader:`${l.corePath}/loader/ts-doc.cjs`,options:{comment:x,generateDoc:g}},{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:R("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:R("font")},{test:/\.(sa|sc)ss$/i,use:[j,O,k,w,$,{loader:"sass-loader",options:{implementation:await import("sass"),sassOptions:{}}}].filter(Boolean),include:R("css")},{test:/\.less$/i,use:B,include:R("css")},{test:/\.css$/i,use:[j,"css-loader",w,$].filter(Boolean),include:R("css")},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...t.prefixJsLoader,P].filter(Boolean),include:R("js")},{test:/\.mdx?$/i,use:[...t.prefixJsLoader,{loader:`${l.corePath}/loader/mdx.cjs`,options:t.mdx}].filter(Boolean),include:_,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 I;
|
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((
|
|
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{
|
|
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/example.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{scanFolder as e}from"@moneko/mdx";import{getTree as o,watchFiles as t}from"./utils.js";import r from"../paths.js";import{isDev as m,isLibrary as p}from"../process-env.js";import s from"../reactive-object.js";export const exampleModuleName="@app/example";export const examples=new s;function a(e){o({base:r.componentsPath,files:e,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)};`)})}let l=e(r.componentsPath).filter(e=>!/(?<!\/examples\/(.+)\.md)$/.test(e));p&&(a(l),m&&t(r.componentsPath,/(?<!\/examples\/(.+)\.md)$/,a,l));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dirname as e}from"path";import t from"typescript";import{CONFIG as n}from"../config.js";let{ScriptKind:r,ScriptTarget:l,SyntaxKind:o,createSourceFile:i,forEachChild:a,getLeadingCommentRanges:c,isInterfaceDeclaration:u,isQuestionToken:s,isPropertySignature:f,isFunctionTypeNode:p,isUnionTypeNode:m,isMethodSignature:g}=t,$={};function h(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 b(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function d(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}](${n})`}return null}function y(e){if(!e)return null;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():null}let x=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function j(e,t){if(!e)return null;let r=e.replace(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if($[e]){let r=`/${[n.basename,$[e]].join("/").split("/").filter(Boolean).join("/")}`;return t?`[\\color{#009688}{${e}}](${r})`:`[${e}](${r})`}return t?`\\color{#009688}{${e}}`:e});return t&&(r=r.replace(x,e=>`\\color{#009688}{${e}}`)),r}function T(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 B(e){return e?e.replace(/^@[a-z].+/gm,"").replace(/(\n\s+)+/g,"<br />").replace(/\n/g,"<br />").replace(/(<br \/>)$/g,""):null}export default function k(c,x){let k=i(x,c,l.Latest,!0,r.TS),w="";return a(k,r=>{u(r)?w+=function(r){let l=r.name.text;Object.assign($,{[r.name.text]:e(r.getSourceFile().fileName).replace(n.alias["@pkg"],"")});let i=h(r),a=b(i),c=B(i),u=y(i)?.split("|")||[],x=u.includes("comment"),k=u.includes("initial"),w=u.includes("optional"),E=u.includes("version"),S=u.includes("author"),v=c?`\\color{|4||0.45}{${l}}`:l,F=(function(e){let n=[];if(e.heritageClauses){for(let r of e.heritageClauses)if(r.token===t.SyntaxKind.ExtendsKeyword)for(let e of r.types)n.push(e.getText())}return n})(r)?.map(e=>`<n-tag color="#4c81db" css=".tag{gap:0px;}">${j(T(e))}</n-tag>`),z=[c,v,a&&`\\color{#52c11b|1||0.9}{${a}}`,F.length>0&&`<sub>\`extends\`</sub> ${F.join(" ")}`].filter(Boolean).join(" "),K=`## ${z}`,N=r.members.filter(e=>f(e)&&e.type?.kind!==o.NeverKeyword||g(e)),q=[];if(N.length){N.forEach(e=>{let t=j(T(g(e)?`(${e.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${e.type?.getText()||"any"}`:e.type?.getText()||"any"),!0),n=h(e),r=T(e.name.getText());!r||r.startsWith("\\color")||(g(e)||function(e){if(e.type){if(!m(e.type))return p(e.type);for(let t of e.type.types)if(p(t))return!0}return!1}(e)||t?.includes("=>")?r=`\\color{#f9a913}{${r}}`:/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`));let l=e.questionToken&&s(e.questionToken);q.push([r,!w&&`\\color{${l?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${l?"✘":"✔"}}`,!x&&T(B(n)),t,!k&&T(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(n)),!E&&T(b(n)),!S&&(d(n)||d(i))])});let e=!1,t=!1,n=!1,r=!1;q.forEach(l=>{!x&&l[2]&&(r=!0),!k&&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 o=[":-",!w&&":-",r&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);K+="\n";let a=o.join("|");K+=`|${a}|`,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"}(r):t.isEnumDeclaration(r)&&(w+=function(r){let l=r.name.text,o=h(r),i=B(o),a=b(o);Object.assign($,{[r.name.text]:e(r.getSourceFile().fileName).replace(n.alias["@pkg"],"")});let c=i?`\\color{|4||0.45}{${l}}`:l,u=[i,c,a&&`\\color{#52c11b|1||0.9}{${a}}`].filter(Boolean).join(" "),s=y(o)?.split("|")||[],f=s.includes("comment"),p=s.includes("version"),m=s.includes("author"),g=`## ${u}`;if(r.members.length){let e=[];r.members.forEach(n=>{let r=T(n.name.getText()),l=h(n),i=T(function(e){let n=e.initializer;return n&&t.isStringLiteral(n)?` '${n.text}'`:null}(n)),a=T(b(l)),c=T(B(l));!r||r.startsWith("\\color")||/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`),e.push([r,!f&&c,i,!p&&a,!m&&(d(l)||d(o))])});let n=!1,l=!1,i=!1;e.forEach(e=>{!f&&e[1]&&(i=!0),!p&&e[3]&&(l=!0),!m&&e[4]&&(n=!0)}),g+="\n";let a=["属性",i&&"说明","值",l&&"版本",n&&"作者"].filter(Boolean).join("|");g+=`|${a}|`;let c=[":-",i&&":-",":-",l&&":-",n&&":-"].filter(Boolean);g+="\n";let u=c.join("|");g+=`|${u}|`,e.forEach(e=>{g+="\n";let t=[e[0]||"-",i&&(e[1]||"-"),e[2]||"-",l&&(e[3]||"-"),n&&(e[4]||"-")].filter(Boolean).join("|");g+=`|${t}|`})}return g+="\n\n"}(r))}),w}
|
package/lib/vm/locales.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{basename as e,join as t}from"path";import{directoryExists as o}from"@moneko/mdx";import{watch as
|
|
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);${
|
|
1
|
+
import{basename as e,join as t}from"path";import{directoryExists as o,scanFolder as a}from"@moneko/mdx";import{watch as l}from"chokidar";import{CONFIG as r}from"../config.js";import{FRAMEWORK as n,isDev as s}from"../process-env.js";import c from"../reactive-object.js";import{esm as i,tfc as g}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";'},f={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;'}[n];function p(e,t){return`${u[n]}
|
|
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);${f}`}export const localesModuleName="@app/locales";export const locales=new c({[localesModuleName]:p([],{})});let d={};async function m(t,o){let a=e(t).replace(/\.[^.]+$/,"");"deleted"===o?delete d[a]:Object.assign(d,{[a]:(await import(i`${g(t)}`)).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:s={}}=d[e];l.push({language:t,title:o,icon:n}),r[t]={language:t,title:o,icon:n,translation:s}}locales.setData(localesModuleName,p(l,r))}let z=t(r.alias["@"],"./locales");o(z)&&(a(z).filter(e=>!/^\..*/.test(e)&&!/!\.ts$/.test(e)&&!/\.d\.ts$/.test(e)).forEach(e=>{m(e,"added")}),s&&function(e,t){let o=l(e,{ignored:t,persistent:!0,ignoreInitial:!0});function a(){o.unwatch(e),o.close()}o.on("add",e=>{m(e,"added")}),o.on("change",e=>{m(e,"change")}),o.on("unlink",e=>{m(e,"deleted")}),o.once("ready",()=>{s||a()}),process.on("SIGINT",a)}(z,[/^\..*/,/!\.ts$/,/\.d\.ts$/]));
|
package/lib/vm/routes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{fileExists as e,scanFolder as r}from"@moneko/mdx";import{getTree as o,mergeRouter as t,watchFiles as s}from"./utils.js";import{CONFIG as p}from"../config.js";import m from"../paths.js";import{FRAMEWORK as u,FRAMEWORKNAME as i,createElement as a,isDev as f,isLibrary as n,isReact as l,isSolid as c}from"../process-env.js";import $ from"../reactive-object.js";let x=e(`${p.alias["@"]}/router/index.ts`),d=`${c?"() => ":""}${a}(SuspenseComp, { comp: $1 })`,g=`import { ${a} } from "${i}";import SuspenseComp from "@app/suspense";${l?'import prefix from "@app/prefix-router";':""}`;x&&(g+='import merge from "@app/merge-router";import customRouter from "@/router";'),["react","solid"].includes(u)||(d="$1",g="");export const routesModuleName="@app/routes";export const route=new $({[routesModuleName]:"export default []"});export let routes=[];let h=n?m.componentsPath:m.pagesPath,j=n?/(?<!README\.mdx?)$/:/(?<!index\.tsx?)$/,M=n?"@pkg":"@/pages";function N(e){var r;routes=t(o({base:h,files:e,alia:M}),"key"),route.setData(routesModuleName,(r=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,d).slice(1,-1),`${g}const routes = [{ path: "/", children: [${c?'{ path: "/" },':""} ${r}] }];const _routes = ${x?'merge([...routes, ...customRouter], "path")':"routes"};export default ${l?"prefix(_routes)":"_routes"};`))}let k=r(h).filter(e=>!j.test(e));N(k),f&&s(h,j,N,k);
|
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): void;
|
|
18
|
+
export declare function watchFiles(root: string, ignored: RegExp, call: (files: string[]) => void, files?: string[]): void;
|
|
19
19
|
export {};
|
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
|
|
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).sort((e,t)=>e.key>t.key?1:-1)}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)}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function e(){let e=this.resourcePath,t=this.getOptions();return this.cacheable(!0),t.comment.getData(`@app/comment/${e.split("/").slice(-2).join("/")}`)}Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return e}});
|
package/lib/loader/app-docs.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
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}});
|
|
@@ -1 +0,0 @@
|
|
|
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}](${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}
|
|
File without changes
|