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