@moneko/core 3.8.7-beta.5 → 3.8.7-beta.7
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/dev.js +3 -3
- package/lib/loader/app-comment.cjs +1 -0
- package/lib/loader/app-comment.d.cts +6 -0
- package/lib/loader/app-docs.cjs +1 -0
- package/lib/loader/app-docs.d.cts +6 -0
- package/lib/loader/css-unicode.cjs +1 -1
- package/lib/loader/css-unicode.d.cts +2 -1
- package/lib/loader/mdx.cjs +1 -1
- package/lib/loader/mdx.d.cts +1 -1
- package/lib/loader/ts-doc.cjs +1 -1
- package/lib/loader/ts-doc.d.cts +5 -1
- package/lib/module.config.js +1 -1
- package/lib/plugin/done.js +1 -1
- package/lib/plugin/virtual-module.js +1 -1
- package/lib/polyfills/rem.d.ts +0 -0
- package/lib/polyfills/rem.js +0 -0
- package/lib/process-env.d.ts +0 -2
- package/lib/process-env.js +1 -1
- package/lib/prod.js +1 -1
- package/lib/reactive-object.d.ts +0 -1
- package/lib/reactive-object.js +1 -1
- package/lib/seo.js +1 -1
- package/lib/utils.d.ts +0 -1
- package/lib/utils.js +2 -2
- package/lib/vm/app.d.ts +4 -11
- package/lib/vm/app.js +1 -1
- package/lib/vm/coverage.js +1 -1
- package/lib/vm/docs.d.ts +1 -0
- package/lib/vm/docs.js +1 -1
- package/lib/vm/example.js +1 -1
- package/lib/vm/init-files.d.ts +0 -0
- package/lib/vm/init-files.js +0 -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 +2 -2
- package/lib/loader/router.cjs +0 -1
- package/lib/loader/router.d.cts +0 -1
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";import w from"./virtual-modules.js";let{AutomaticPrefetchPlugin:v,DefinePlugin:k,SourceMapDevToolPlugin:x,WatchIgnorePlugin:C}=o,O=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:j(g?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${d?"name":"chunkhash"}].js`,assetModuleFilename:e=>{let t=e.filename;return t&&t.endsWith("?url")&&/(?:webworker|worker)(\.|\b).*\.(js|ts)\b/.test(t.replace("?url",""))?"worker/[name][ext]":"assets/[name][hash][ext]"},library:{name:f,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${f}`,pathinfo:d,clean:!0,publicPath:r,asyncChunks:!0,charset:!0};let $={main:b("@app/entry")};l.polyfill&&Object.assign($,{"dom-polyfills":[`${i.corePath}/polyfills/replace-children.js`]}),l.entry&&("string"==typeof l.entry?$={main:l.entry}:Object.keys(l.entry)&&Object.assign($,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let P=l.basename.split("/").filter(Boolean).length,B=`${Array(P).fill("..").join("/")+(P?"/":"")}404.html`,{pathSegmentsToKeep:D=P,path:M=B}=l.fixBrowserRouter||{},R=!1;l.cacheDirectory&&(R={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:l.cacheDirectory,memoryCacheUnaffected:!0,name:[p,process.env.NODE_ENV].filter(Boolean).join("-"),version:h});let A=Object.assign({original:l.alias["@"],override:p&&j(p)},l.overrideResolve);export const clientConfig={entry:$,stats:"errors-only",cache:R,infrastructureLogging:{level:"error"},target:"web",externalsPresets:l.externalsPresets,plugins:[...n,new u(w),new v,l.htmlPluginOption&&new t(s),l.fixBrowserRouter&&new t({filename:M,inject:!1,templateContent:()=>`<html lang="en"><head><title>${s.title}</title><script>const pathKeep = ${D||P};const l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new e(O),y&&new c(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new k({"process.env":JSON.stringify(l.env)}),new C({paths:[/\.d\.ts$/]}),l.sourceMap&&new x(l.sourceMap),...l.plugins].filter(e=>!!e),node:{global:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:d&&{imports:!0,entries:!
|
|
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";import w from"./virtual-modules.js";let{AutomaticPrefetchPlugin:v,DefinePlugin:k,SourceMapDevToolPlugin:x,WatchIgnorePlugin:C}=o,O=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:j(g?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:`js/[${d?"name":"chunkhash"}].js`,assetModuleFilename:e=>{let t=e.filename;return t&&t.endsWith("?url")&&/(?:webworker|worker)(\.|\b).*\.(js|ts)\b/.test(t.replace("?url",""))?"worker/[name][ext]":"assets/[name][hash][ext]"},library:{name:f,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${f}`,pathinfo:d,clean:!0,publicPath:r,asyncChunks:!0,charset:!0};let $={main:b("@app/entry")};l.polyfill&&Object.assign($,{"dom-polyfills":[`${i.corePath}/polyfills/replace-children.js`]}),l.entry&&("string"==typeof l.entry?$={main:l.entry}:Object.keys(l.entry)&&Object.assign($,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let P=l.basename.split("/").filter(Boolean).length,B=`${Array(P).fill("..").join("/")+(P?"/":"")}404.html`,{pathSegmentsToKeep:D=P,path:M=B}=l.fixBrowserRouter||{},R=!1;l.cacheDirectory&&(R={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:l.cacheDirectory,memoryCacheUnaffected:!0,name:[p,process.env.NODE_ENV].filter(Boolean).join("-"),version:h});let A=Object.assign({original:l.alias["@"],override:p&&j(p)},l.overrideResolve);export const clientConfig={entry:$,stats:"errors-only",cache:R,infrastructureLogging:{level:"error"},target:"web",externalsPresets:l.externalsPresets,plugins:[...n,new u(w),new v,l.htmlPluginOption&&new t(s),l.fixBrowserRouter&&new t({filename:M,inject:!1,templateContent:()=>`<html lang="en"><head><title>${s.title}</title><script>const pathKeep = ${D||P};const l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new e(O),y&&new c(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new k({"process.env":JSON.stringify(l.env)}),new C({paths:[/\.d\.ts$/]}),l.sourceMap&&new x(l.sourceMap),...l.plugins].filter(e=>!!e),node:{global:!1},experiments:{topLevelAwait:!0,asyncWebAssembly:!0,cacheUnaffected:!0,layers:!0,lazyCompilation:d&&{imports:!0,entries:!0},buildHttp:l.buildHttp,backCompat:!0,futureDefaults:!1,css:!1,outputModule:!1},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:l.alias,plugins:[l.overrideResolve&&new m(A),...l.resolvePlugins].filter(Boolean),fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:a,externals:l.externals,output:outputConfig};
|
package/lib/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessSync as e,constants as t}from"fs";import o from"chalk";import{merge as s}from"webpack-merge";import i,{CUSTOMCONFIG as a}from"./paths.js";import{FRAMEWORK as
|
|
1
|
+
import{accessSync as e,constants as t}from"fs";import o from"chalk";import{merge as s}from"webpack-merge";import i,{CUSTOMCONFIG as a}from"./paths.js";import{FRAMEWORK as n,PACKAGENAME as r,coreName as l,isDev as c,isLibrary as m,isMobile as p,jsxImportSource as u,mainDirectory as d}from"./process-env.js";import{isFunction as h,log as f,readConf as g,resolveProgramPath as x}from"./utils.js";let C=["@moneko","neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app",".cache/http/data"],P={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{NODE_ENV:process.env.NODE_ENV},basename:"/",publicPath:"/",rem:{designSize:p?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":x(d)},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:i.webpackCachePath,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`node_modules/${l}/template/index.html`,favicon:`node_modules/${l}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],resolvePlugins:[],overrideResolve:!1,splitChunk:{chunks:"all",minSize:1024,minChunks:1,cacheGroups:{route:{test:/[\\/].git[\\/]router/,priority:-10,reuseExistingChunk:!0,name:"route"},example:{test:/[\\/].git[\\/]example/,priority:-10,reuseExistingChunk:!0,name:"example"}}},runtimeChunk:"single",moduleFederation:[],rulesInclude:{css:C,js:C,media:C,font:C,wasm:[]},mdx:{jsx:!1,development:c,jsxImportSource:u,providerImportSource:`@moneko/${n}/mdx`},jsxDomExpressions:{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1},bar:{name:"Client",color:"#6f42c1"},virtualModule:{},normalizeCss:!0,externalsPresets:{},buildHttp:{allowedUris:[],lockfileLocation:`${i.httpCachePath}/http.lock`,cacheLocation:`${i.httpCachePath}/data`,upgrade:!0}};m&&(P.alias=Object.assign(P.alias,{"@pkg":i.componentsPath,[r]:i.componentsPath}));let w=P,b={},k={};try{e(i.configPath,t.R_OK);let o=(await g(i.configPath,"index")).default;b=h(o)?o(process):o}catch(e){f(o.red(e))}if(a)try{e(i.customConfigPath,t.R_OK);let o=(await g(i.customConfigPath,a)).default;k=h(o)?o(process):o}catch(e){f(o.red(e))}"tsc"===(w=s(w,b,k)).compiler&&w.minifier&&(w.minifier.js||Object.assign(w.minifier,{js:{type:"terser"}}),w.minifier.css||Object.assign(w.minifier,{css:{type:"cssnano"}})),!1===w.devtool&&(w.sourceMap=!1),!1===w.sourceMap&&(w.devtool=!1),w.fixBrowserRouter&&w.htmlPluginOption&&(w.htmlPluginOption.tags||(w.htmlPluginOption.tags=[]),w.htmlPluginOption.tags.push({textContent:"(function(l) {if (l.search[1] === '/' ) {var decoded = l.search.slice(1).split('&').map(function(s) {return s.replace(/~and~/g, '&')}).join('?');window.history.replaceState(null, null,l.pathname.slice(0, -1) + decoded + l.hash);}}(window.location))"}));export const CONFIG=w;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,CUSTOMCONFIG:a,log:f};
|
package/lib/dev.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`);function
|
|
3
|
-
${
|
|
1
|
+
import{removeDirAll as e}from"@moneko/mdx";import o from"chalk";import t from"webpack";import s from"webpack-dev-server";import{merge as r}from"webpack-merge";import i from"webpackbar";import{clientConfig as a}from"./common.js";import{CONFIG as l}from"./config.js";import{hasPkg as n}from"./has-pkg.js";import{getIPv4 as p,getPort as m}from"./net.js";import c from"./paths.js";import{isLibrary as d,isReact as u}from"./process-env.js";import{isFunction as w,log as f,resolveProgramPath as v}from"./utils.js";let{HotModuleReplacementPlugin:h}=t,{yellow:g,green:k,grey:b,gray:$,bgBlue:x,bgGreenBright:j,blueBright:S,greenBright:y}=o,T=n("eslint-webpack-plugin"),C=n("stylelint-webpack-plugin"),A=n("@moneko/mock"),B=C?(await import("stylelint-webpack-plugin")).default:null,D=T?(await import("eslint-webpack-plugin")).default:null,E=l.devServer.port||3e3,H=await m(E,65535,l.devServer.host),M=A&&(await import("@moneko/mock")).default,O=u&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,_=!1===l.devtool||l.devtool?l.devtool:"eval-cheap-module-source-map";l.devServer.port=H;let I="/"===l.basename,J=l.devServer.https?"https:":"http:",N=I?"":l.basename,P=l.devServer.port!==H&&$(`Port ${g(E)} is in use, trying ${k(H)} instead.
|
|
2
|
+
`);function W(e){return`${J}//${"local"===e?l.devServer.host:p()}:${H}${N}`}let F=$("You application is running here:"),G=`${x(" Local ")} ${S(W("local"))}
|
|
3
|
+
${j(" Network ")} ${y(W("net"))}`,L=["js","md","mdx","jsx","ts","tsx","json","html","vue"],R=L.join(","),Y=["css","scss","sass","less","ts","tsx","js","jsx"],q=Y.join(","),z=["node_modules/","es/","lib/","umd/","docs/","coverage/","dist/"],K=[new h,O&&new O,D&&new D({fix:!0,threads:!0,files:[`${l.alias["@"]}/**/*.{${R}}`,d&&`${l.alias["@pkg"]}/**/*.{${R}}`].filter(Boolean),extensions:L,exclude:z,cache:!0,lintDirtyModulesOnly:!0}),B&&new B({fix:!0,threads:!0,files:[`${l.alias["@"]}/**/*.{${q}}`,d&&`${l.alias["@pkg"]}/**/*.{${q}}`].filter(Boolean),extensions:Y,exclude:z,cache:!0,lintDirtyModulesOnly:!0}),l.bar&&new i(l.bar)].filter(Boolean),Q={headers:{"Access-Control-Allow-Origin":"*"},compress:l.devServer.compress,host:"0.0.0.0",port:H,historyApiFallback:I||{index:N.endsWith("/")?N:`${N}/`,disableDotRule:!0},https:l.devServer.https,proxy:l.proxy,allowedHosts:l.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,o)=>{if(!o)throw Error("devServer is not defined");return o.app&&w(M)&&M(o.app,v("mock/")),e},open:!1,hot:!0},U=t(r(a,{devtool:_,mode:"development",plugins:K}));U.watch({aggregateTimeout:20,ignored:/node_modules(?![\\/]@app)/,stdin:!0},(e,o)=>{!e&&o&&(process.stdout.write("\x1b[2J\x1b[3J\x1b[H"),f([F,"",G,"",b(`Compiled successfully in ${k(`${o.endTime-o.startTime}ms`)}`)]),o.compilation.warnings.forEach(e=>f(e.message)),o.compilation.errors.forEach(e=>f(e.message)),P&&f(P))});let V=new s(Q,U);V.startCallback(e=>{e||f([F,"",G])}),V.stopCallback(o=>{o||e(c.cachePath)}),process.on("exit",function(){U.close(()=>{}),V.invalidate(),V.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 @@
|
|
|
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 +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
|
-
|
|
1
|
+
import type { LoaderContext } from 'webpack';
|
|
2
|
+
export default function (this: LoaderContext<never>, content: string): string;
|
package/lib/loader/mdx.cjs
CHANGED
|
@@ -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){
|
|
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){return this.cacheable(!0),(0,e.mdxSync)({value:t,filepath:this.resourcePath,...this.getOptions()}).code}
|
package/lib/loader/mdx.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type MdxOptions } from '@moneko/mdx';
|
|
2
2
|
import type { LoaderContext } from 'webpack';
|
|
3
|
-
export default function (this: LoaderContext<Omit<MdxOptions, 'value'>>, value: string):
|
|
3
|
+
export default function (this: LoaderContext<Omit<MdxOptions, 'value'>>, value: string): string;
|
package/lib/loader/ts-doc.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return
|
|
1
|
+
"use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return c}});const t=require("fs"),r=(e=require("./generate-doc.cjs"))&&e.__esModule?e:{default:e},s={},i={};function c(e){let c=this.getOptions(),n=this.resourcePath;void 0===i[n]&&(i[n]=0);let a=(0,t.statSync)(n).mtime.getTime(),o=s[n]!==a;return o&&(i[n]=i[n]+1,Object.assign(s,{[n]:a}),c.comment.setData(`@app/comment/${n.split("/").slice(-2).join("/").replace(/\.tsx?/,".md")}`,(0,r.default)(e,n))),this.cacheable(i[n]>1&&o),e}
|
package/lib/loader/ts-doc.d.cts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
import type ReactiveObject from '../reactive-object.js';
|
|
1
2
|
import type { LoaderContext } from 'webpack';
|
|
2
|
-
export default function (this: LoaderContext<
|
|
3
|
+
export default function (this: LoaderContext<{
|
|
4
|
+
test: RegExp;
|
|
5
|
+
comment: ReactiveObject<Record<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 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
|
|
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";import{comment as x}from"./vm/docs.js";let $={loader:`${a.corePath}/loader/css-unicode.cjs`},g=m?o:"../",v={loader:e.loader,options:{publicPath:"/"!==g?g:"../"}},j=r("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:(await import("@moneko/postcss")).default}};c&&(v="style-loader");let w=[...t.cssModules,`@moneko/${n}`,"neko-ui"].map(f),h=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(y)],b=["components","example","mock","site","src","server"].map(y);i&&b.push(y(i)),t.overrideResolve&&t.overrideResolve.override&&b.push(t.overrideResolve.override);let _={loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,t=w.length;s<t;s++)if(e&&e?.includes(w[s]))return/(.*(?<!\.?global\.(le|c|sc|sa)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.?global\.(le|c|sc|sa)ss)$)/i.test(e)},localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},k=c&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!c}},O=[v,k,_,j,$,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:l,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:h}}].filter(Boolean),B="tsc"===t.compiler,L={loader:B?"ts-loader":"swc-loader",options:B?u:p(c)};function P(e){return b.concat(t.rulesInclude?.[e]?.map(f)||[])}let R=P("media"),M={rules:[d&&{test:/^(?![._]).*(?<!\.test)\.(tsx?)$/,include:t.alias["@pkg"],exclude:[/node_modules/,/(.+)\/__tests__\/(.+)/i],enforce:"pre",use:[{loader:`${a.corePath}/loader/ts-doc.cjs`,options:{comment:x}}]},{oneOf:[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename:e=>{let s=e.filename;return s&&s.endsWith("wasm?url")?"wasm/[name][ext]":"assets/[name][ext]"}}},{test:/\.wasm$/i,type:"webassembly/async",include:P("wasm")},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:R},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>s(e.toString())},include:R},{test:/\.(gif|png|jpe?g|webp)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext]"},include:R},{test:/\.(webm|mp4|ogv)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[name][ext]"},include:R},{test:/\.(woff2?|eot|ttf|otf)(\?.*)?$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/fonts/[name][ext]"},include:P("font")},{test:/\.(sa|sc)ss$/i,use:[v,k,_,j,$,{loader:"sass-loader",options:{implementation:await import("sass"),sassOptions:{}}}].filter(Boolean),include:P("css")},{test:/\.less$/i,use:O,include:P("css")},{test:/\.css$/i,use:[v,"css-loader",j,$].filter(Boolean),include:P("css")},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...t.prefixJsLoader,L].filter(Boolean),include:P("js")},{test:/\.mdx?$/i,use:[...t.prefixJsLoader,{loader:`${a.corePath}/loader/mdx.cjs`,options:t.mdx}].filter(Boolean),include:b,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/i,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules].filter(e=>"object"==typeof e)};export default M;
|
package/lib/plugin/done.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
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{
|
|
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)}})}}
|
|
File without changes
|
|
File without changes
|
package/lib/process-env.d.ts
CHANGED
package/lib/process-env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
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;
|
package/lib/prod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{removeDirAll as e}from"@moneko/mdx";import i from"css-minimizer-webpack-plugin";import o from"mini-css-extract-plugin";import n from"terser-webpack-plugin";import m from"webpack";import{BundleAnalyzerPlugin as r}from"webpack-bundle-analyzer";import{merge as s}from"webpack-merge";import t from"webpackbar";import{clientConfig as p}from"./common.js";import{CONFIG as a}from"./config.js";import{getMinifyOption as l}from"./minify.js";import c from"./paths.js";import u from"./plugin/done.js";import f from"./seo.js";let{optimize:{MinChunkSizePlugin:d}}=m,{cssnanoMinify:h,swcMinify:k}=i,w="swc"===a.compiler,b=[];a.minifier&&(a.minifier.js&&b.push(new n(l(a.minifier.js?.type||(w?"swc":"terser"),a.minifier.js?.options))),a.minifier.css&&b.push(new i({minify:{swc:k,cssnano:h}[a.minifier.css?.type||(w?"swc":"cssnano")],minimizerOptions:a.minifier.css?.options})));let g={splitChunks:a.splitChunk,runtimeChunk:a.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:b},y=m(s(p,{devtool:!1===a.devtool||a.devtool?a.devtool:"cheap-module-source-map",mode:"production",optimization:g,plugins:[new o({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),a.splitChunk&&new d({minChunkSize:1e4}),a.bundleAnalyzer&&new r(a.bundleAnalyzer),a.bar&&new t(a.bar),new u({done:e=>{a.done?.(e),a.seo&&f()}})].filter(Boolean)}));y.watch({aggregateTimeout:20,ignored:/node_modules(?![\\/]@app)/,stdin:!0},e=>{if(e)throw y.close(()=>{}),e;y.hooks.done.tap("WatchRunPlugin",e=>{e.hasErrors(),y.close(()=>{})})}),process.on("exit",function(){e(c.cachePath)});
|
package/lib/reactive-object.d.ts
CHANGED
|
@@ -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);
|
package/lib/reactive-object.js
CHANGED
|
@@ -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
|
|
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/seo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as t,mkdirSync as o
|
|
1
|
+
import{existsSync as t,mkdirSync as o}from"fs";import{join as r}from"path";import{saveFileSync as m}from"@moneko/mdx";import{outputConfig as e}from"./common.js";import{CONFIG as i}from"./config.js";import{resolveProgramPath as s}from"./utils.js";import{routes as p}from"./vm/routes.js";export default(()=>{let{domain:f,nojekyll:n,path:a}=i.seo||{},h=a&&s(a)||e?.path;if(!f||!h)return;t(h)||o(h);let l=i.basename,c=l.endsWith("/")?l:`${l}/`;m(r(h,"CNAME"),f),m(r(h,"robots"),`Sitemap: https://${f}${c}sitemap.txt`);let j=[];!function t(o){o.forEach(o=>{j.push(`https://${f}${c}${o.key}`),Array.isArray(o.children)&&t(o.children)})}(p),m(r(h,"sitemap.txt"),j.join("\n")),n&&m(r(h,".nojekyll"),"")});
|
package/lib/utils.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export declare function log(msg: string | string[]): void;
|
|
|
8
8
|
export declare function tfc(filepath: string): string;
|
|
9
9
|
export declare function readConf(src: string, name: string): Promise<any>;
|
|
10
10
|
export declare function toUpperCaseString(string: string): string;
|
|
11
|
-
export declare function cleanDir(folderPath: string): void;
|
|
12
11
|
type ProgramPath<T extends string> = `${T extends string ? T : string}`;
|
|
13
12
|
type NodeModulesPath<T> = ProgramPath<`node_modules/${T extends string ? T : string}`>;
|
|
14
13
|
/** 位于项目根目录下的位置
|
package/lib/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)}):(
|
|
1
|
+
import{resolve as t}from"path";import e from"readline";import{loadFileSync as o,saveFileSync as r}from"@moneko/mdx";import{transformFileSync as n}from"@swc/core";import c from"./paths.js";import s from"./resolver-sync.js";export function esm(t,...e){let o=t.raw[0];for(let r=0;r<e.length;r++)o+=e[r]+t.raw[r+1];return`data:text/javascript;base64,${Buffer.from(o).toString("base64")}`}let p=/export\s+(?:async\s+)?(?:function|const)\s+(\w+)/g;export function getExportTokens(t){let e;let r=o(t)||"",n=[];for(;e=p.exec(r);)n.includes(e[1])||n.push(e[1]);return n}let a={inputSourceMap:!1,sourceMaps:!1,module:{type:"es6"},jsc:{parser:{syntax:"typescript"},loose:!1}};export function log(t){Array.isArray(t)?t.forEach(t=>{log(`${t}
|
|
2
|
+
`)}):(e.cursorTo(process.stdout,0),process.stdout.write(t))}export function tfc(t){return n(t,a).code||"{}"}export function readConf(t,e){let o=`${c.cachePath}/${e}.mjs`;return r(o,tfc(t)),import(o)}export function toUpperCaseString(t){return t?.replace(/\b\w/g,t=>t.toUpperCase()).replace(/\./g," ")}export function resolveProgramPath(e){return t(c.programPath,`./${e}`)}export const resolveNodeModulesPath=t=>resolveProgramPath(`node_modules/${t}`);export const realResolve=t=>s.resolveSync({},c.programPath,t)||t;export function isObject(t){let e=typeof t;return null!==t&&("object"==e||"function"==e)}export function isFunction(t){if(!isObject(t))return!1;let e=Object.prototype.toString.call(t);return"[object Function]"==e||"[object AsyncFunction]"==e||"[object GeneratorFunction]"==e||"[object Proxy]"==e}export function empty(){}
|
package/lib/vm/app.d.ts
CHANGED
|
@@ -7,16 +7,9 @@ declare const app: {
|
|
|
7
7
|
routerMode: "browser" | "hash" | "memory";
|
|
8
8
|
prefixCls: string | undefined;
|
|
9
9
|
theme: import("../index.js").Theme | undefined;
|
|
10
|
-
description:
|
|
11
|
-
author:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
url: string | undefined;
|
|
15
|
-
};
|
|
16
|
-
repository: {
|
|
17
|
-
type: string | undefined;
|
|
18
|
-
url: string | undefined;
|
|
19
|
-
directory: string | undefined;
|
|
20
|
-
};
|
|
10
|
+
description: any;
|
|
11
|
+
author: any;
|
|
12
|
+
repository: any;
|
|
13
|
+
keywords: any;
|
|
21
14
|
};
|
|
22
15
|
export default app;
|
package/lib/vm/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{loadFileSync as e}from"@moneko/mdx";import{CONFIG as r}from"../config.js";import{APPTYPE as o,PACKAGENAME as t,PACKAGEVERSION as s}from"../process-env.js";import{resolveProgramPath as p,toUpperCaseString as i}from"../utils.js";let{description:m,author:a,repository:n,keywords:f}=JSON.parse(e(p("package.json"))||"{}"),l={name:t,projectName:JSON.stringify(i(t).replace(/-/g," ")),version:s,base:r.basename,type:o,routerMode:r.routerMode,prefixCls:r.prefixCls,theme:r.theme,description:m,author:"string"==typeof a?{name:a}:a,repository:"string"==typeof a?{url:n}:n,keywords:f};export default l;
|
package/lib/vm/coverage.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessSync as e,constants as r
|
|
1
|
+
import{accessSync as e,constants as r}from"fs";import{loadFileSync as o}from"@moneko/mdx";import{Parser as t}from"xml2js";import c from"../paths.js";import{PACKAGENAME as a,isLibrary as m}from"../process-env.js";export const coverage={};if(m)try{e(c.coveragePath,r.R_OK);let m=new t({explicitArray:!1,async:!1}).parseString,s=o(c.coveragePath);m(s,(e,r)=>{if(!e){let e=r.coverage.project.metrics.$,o=r.coverage.project.package;Object.assign(coverage,{[a]:e}),o.forEach(e=>{Object.assign(coverage,{[e.$.name]:e.metrics.$})})}})}catch(e){}
|
package/lib/vm/docs.d.ts
CHANGED
package/lib/vm/docs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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
|
|
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)});
|
|
File without changes
|
|
File without changes
|
package/lib/vm/locales.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{existsSync as e}from"fs";import{basename as t,join 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{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"};`))},10)}
|
|
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
|
|
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{
|
|
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 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(n){let r={};return n.files.forEach(i=>{let o=s.getData(i)||{code:""},a=t(n.base,i),l=n.base.split("/").filter(Boolean),h=i.split("/").filter(Boolean).slice(0,-1),p={},f=Object.assign({meta:JSON.parse(o.frontmatter||"{}")},n.alia&&{[c]:`rr(() => import(/* webpackChunkName: '${a}' */'${e(n.alia,a)}'))rr`},n.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 e=l.length;e<h.length;e++){let t={path:h[e],key:h[e]};e===l.length?(Object.assign(p,r[t.key],{path:t.path,key:t.key},e===h.length-1&&f),r[t.key]=p):(p.children=(p.children||[]).concat([t]),n.outputSource?(Object.assign(t,{path:i.split("/").pop(),key:i.split("/").pop()},f),t.children=getTree({...n,base:`${n.base}/${t.key}`,files:n.files.filter(e=>e.startsWith(`${n.base}/${t.key}`))})):Object.assign(t,{key:h.slice(l.length,e+1).join("/")},f),p=t)}}),Object.values(r)}function h(e,t,i){if(i)s.removeData(e),t.removeData(e);else{let i=r(e)||"";if(e.endsWith(".md")||e.endsWith(".mdx")){let r=n(i);s.setData(e,r),t.setData(e,!0)}else s.setData(e,{code:i,frontmatter:"{}"}),t.setData(e,!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.
|
|
3
|
+
"version": "3.8.7-beta.7",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"author": "moneko",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@moneko/mdx": "0.1.
|
|
16
|
+
"@moneko/mdx": "0.1.10",
|
|
17
17
|
"@swc/core": "1.3.100",
|
|
18
18
|
"@swc/css": "0.0.28",
|
|
19
19
|
"@swc/helpers": "0.5.3",
|
package/lib/loader/router.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/lib/loader/router.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|