@moneko/core 3.6.4 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common.js +1 -1
- package/lib/config.js +1 -1
- package/lib/dev.js +3 -3
- package/lib/has-pkg.js +1 -1
- package/lib/html-plugin-option.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +1 -1
- package/lib/loader/css-unicode.cjs +1 -10
- package/lib/loader/css-unicode.d.cts +1 -0
- package/lib/loader/frontmatter.cjs +1 -6
- package/lib/loader/frontmatter.d.cts +1 -0
- package/lib/loader/override.cjs +1 -0
- package/lib/loader/override.d.cts +6 -0
- package/lib/module.config.js +1 -1
- package/lib/net.d.ts +1 -2
- package/lib/net.js +1 -1
- package/lib/paths.d.ts +3 -0
- package/lib/paths.js +1 -1
- package/lib/plugin/done.js +1 -0
- package/lib/{virtual-module-plugin.d.ts → plugin/virtual-module.d.ts} +2 -2
- package/lib/plugin/virtual-module.js +1 -0
- package/lib/process-env.d.ts +3 -0
- package/lib/process-env.js +1 -1
- package/lib/prod.js +1 -1
- package/lib/reactive-object.d.ts +8 -2
- package/lib/reactive-object.js +1 -1
- package/lib/seo.d.ts +2 -1
- package/lib/seo.js +1 -1
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +2 -2
- package/lib/virtual-modules.js +1 -1
- package/lib/vm/app-entry.js +1 -0
- package/lib/{app.d.ts → vm/app.d.ts} +2 -2
- package/lib/vm/app.js +1 -0
- package/lib/vm/coverage.js +1 -0
- package/lib/{docs.d.ts → vm/docs.d.ts} +1 -1
- package/lib/vm/docs.js +1 -0
- package/lib/vm/fallback.js +1 -0
- package/lib/{locales.d.ts → vm/locales.d.ts} +1 -1
- package/lib/vm/locales.js +2 -0
- package/lib/vm/normalize-css.js +1 -0
- package/lib/vm/prefix-router.js +1 -0
- package/lib/vm/rem.js +1 -0
- package/lib/{routes.d.ts → vm/routes.d.ts} +1 -1
- package/lib/vm/routes.js +1 -0
- package/package.json +3 -3
- package/typings/global.d.ts +35 -11
- package/lib/app-entry.js +0 -1
- package/lib/app.js +0 -1
- package/lib/cleanup.d.ts +0 -1
- package/lib/cleanup.js +0 -1
- package/lib/coverage.js +0 -1
- package/lib/docs.js +0 -1
- package/lib/done.js +0 -1
- package/lib/esm.d.ts +0 -1
- package/lib/esm.js +0 -1
- package/lib/fallback.js +0 -1
- package/lib/locales.js +0 -2
- package/lib/normalize-css.js +0 -1
- package/lib/prefix-router.js +0 -1
- package/lib/rem.js +0 -1
- package/lib/routes.js +0 -1
- package/lib/virtual-module-plugin.js +0 -1
- package/lib/yarn-argv.d.ts +0 -4
- package/lib/yarn-argv.js +0 -1
- /package/lib/{html-add-entry-attr.d.ts → plugin/add-entry-attribute.d.ts} +0 -0
- /package/lib/{html-add-entry-attr.js → plugin/add-entry-attribute.js} +0 -0
- /package/lib/{done.d.ts → plugin/done.d.ts} +0 -0
- /package/lib/{app-entry.d.ts → vm/app-entry.d.ts} +0 -0
- /package/lib/{coverage.d.ts → vm/coverage.d.ts} +0 -0
- /package/lib/{fallback.d.ts → vm/fallback.d.ts} +0 -0
- /package/lib/{merge-router.d.ts → vm/merge-router.d.ts} +0 -0
- /package/lib/{merge-router.js → vm/merge-router.js} +0 -0
- /package/lib/{normalize-css.d.ts → vm/normalize-css.d.ts} +0 -0
- /package/lib/{prefix-router.d.ts → vm/prefix-router.d.ts} +0 -0
- /package/lib/{rem.d.ts → vm/rem.d.ts} +0 -0
package/lib/common.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import e from"add-asset-html-webpack-plugin";import t from"html-webpack-plugin";import o from"webpack";import r from"webpackbar";import{CONFIG as l,PUBLICPATH as s}from"./config.js";import a from"./html-plugin-option.js";import{moduleFederation as n}from"./module-federation.js";import i from"./module.config.js";import p,{CUSTOMCONFIG as c}from"./paths.js";import m from"./plugin/add-entry-attribute.js";import u from"./plugin/virtual-module.js";import{PACKAGENAME as f,PACKAGEVERSION as h,isDev as d,isLibrary as b,isMicro as y}from"./process-env.js";import{resolveNodeModulesPath as g,resolveProgramPath as j}from"./utils.js";import w from"./virtual-modules.js";let{AutomaticPrefetchPlugin:k,DefinePlugin:x,SourceMapDevToolPlugin:C,WatchIgnorePlugin:v}=o,$=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:j(b?"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:s,asyncChunks:!0,charset:!0};let O={main:g("@app/entry")};l.polyfill&&Object.assign(O,{"dom-polyfills":[`${p.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 P=l.basename.split("/").filter(Boolean).length,M=`${Array(P).fill("..").join("/")+(P?"/":"")}404.html`,{pathSegmentsToKeep:D=P,path:A=M}=l.fixBrowserRouter||{},B=!1;l.cacheDirectory&&(B={type:"filesystem",store:"pack",allowCollectingMemory:!0,cacheDirectory:l.cacheDirectory,memoryCacheUnaffected:!0,name:`${c||"default"}-${d?"development":"production"}`,version:h});export const clientConfig={entry:O,stats:"errors-only",cache:B,infrastructureLogging:{level:"error"},target:"web",externalsPresets:l.externalsPresets,plugins:[new u(w),new k,...n,l.htmlPluginOption&&new t(a),l.fixBrowserRouter&&new t({filename:A,inject:!1,templateContent:()=>`<html lang="en"><head><title>${a.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($),y&&new m(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new x({"process.env":JSON.stringify(l.env)}),new v({paths:[/\.d\.ts$/]}),l.sourceMap&&new C(l.sourceMap),l.bar&&new r(l.bar),...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,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{PACKAGENAME as n,coreName as r,isLibrary as l,isMobile as c,jsxImportSource as m,mainDirectory as p}from"./process-env.js";import{isFunction as u,log as h,readConf as d,resolveProgramPath as f}from"./utils.js";let g=["@moneko","neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app",".cache/http/data"],P={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:!1,polyfill:!1,entry:{},minifier:{js:{},css:{}},sourceMap:{filename:"[file].map",publicPath:""},env:{NODE_ENV:process.env.NODE_ENV},basename:"/",publicPath:"/",rem:{designSize:c?375:1680},fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{"@":f(p)},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:i.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:[],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:g,js:g,media:g,font:g,wasm:[]},mdx:{jsxImportSource:m,useDynamicImport:!0,remarkPlugins:[],rehypePlugins:[]},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}};l&&(P.alias=Object.assign(P.alias,{"@pkg":i.componentsPath,[n]:i.componentsPath}));let x=P,C={},w={};try{e(i.configPath,t.R_OK);let o=(await d(i.configPath,"index")).default;C=u(o)?o(process):o}catch(e){h(o.red(e))}if(a)try{e(i.customConfigPath,t.R_OK);let o=(await d(i.customConfigPath,a)).default;w=u(o)?o(process):o}catch(e){h(o.red(e))}"tsc"===(x=s(x,C,w)).compiler&&x.minifier&&(x.minifier.js||Object.assign(x.minifier,{js:{type:"terser"}}),x.minifier.css||Object.assign(x.minifier,{css:{type:"cssnano"}})),!1===x.devtool&&(x.sourceMap=!1),!1===x.sourceMap&&(x.devtool=!1),x.fixBrowserRouter&&x.htmlPluginOption&&(x.htmlPluginOption.tags||(x.htmlPluginOption.tags=[]),x.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=x;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,CUSTOMCONFIG:a,log:h};
|
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{
|
|
2
|
-
`);function
|
|
3
|
-
${S(" Network ")} ${
|
|
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 l}from"./common.js";import{CONFIG as i}from"./config.js";import{hasPkg as n}from"./has-pkg.js";import{getIPv4 as a,getPort as c}from"./net.js";import p from"./paths.js";import{hasEslintConfig as m,hasStylelintConfig as d,isLibrary as u,isReact as f}from"./process-env.js";import{cleanDir as h,isFunction as v,log as w,resolveProgramPath as g}from"./utils.js";let{HotModuleReplacementPlugin:j}=o,{yellow:k,green:y,grey:$,gray:x,bgBlue:b,bgGreenBright:S,blueBright:T,greenBright:C}=t,A=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],B=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],D=e(p.programPath),E=!1,H=!1;for(let e=0,t=D.length;e<t;e++)B.includes(D[e])&&(H=!0),A.includes(D[e])&&(E=!0);E||(E=m),H||(H=d);let M=H?(await import("stylelint-webpack-plugin")).default:null,O=E?(await import("eslint-webpack-plugin")).default:null,P=i.devServer.port||3e3,_=await c(P,65535,i.devServer.host),I=n("@moneko/mock"),J=I&&(await import("@moneko/mock")).default,N=f&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,W=!1===i.devtool||i.devtool?i.devtool:"eval-cheap-module-source-map";i.devServer.port=_;let F="/"===i.basename,G=i.devServer.https?"https:":"http:",L=F?"":i.basename,R=i.devServer.port!==_&&x(`Port ${k(P)} is in use, trying ${y(_)} instead.
|
|
2
|
+
`);function Y(e){return`${G}//${"local"===e?i.devServer.host:a()}:${_}${L}`}let q=x("You application is running here:"),z=`${b(" Local ")} ${T(Y("local"))}
|
|
3
|
+
${S(" Network ")} ${C(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=[O&&new O({fix:!0,threads:!0,files:[`${i.alias["@"]}/**/*.{${Q}}`,u&&`${i.alias["@pkg"]}/**/*.{${Q}}`].filter(Boolean),extensions:K,exclude:X,cache:!1,lintDirtyModulesOnly:!0}),M&&new M({fix:!0,threads:!0,files:[`${i.alias["@"]}/**/*.{${V}}`,u&&`${i.alias["@pkg"]}/**/*.{${V}}`].filter(Boolean),extensions:U,exclude:X,cache:!1,lintDirtyModulesOnly:!0}),new j,N&&new N].filter(Boolean),ee={headers:{"Access-Control-Allow-Origin":"*"},compress:i.devServer.compress,host:"0.0.0.0",port:_,historyApiFallback:F||{index:L.endsWith("/")?L:`${L}/`,disableDotRule:!0},https:i.devServer.https,proxy:i.proxy,allowedHosts:i.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&&v(J)&&J(t.app,g("mock/")),e},open:!1,hot:!0},et=o(r(l,{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"),w([q,"",z,"",$(`Compiled successfully in ${y(`${t.endTime-t.startTime}ms`)}`)]),t.compilation.warnings.forEach(e=>w(e.message)),t.compilation.errors.forEach(e=>w(e.message)),R&&w(R))});let eo=new s(ee,et);eo.startCallback(e=>{e||w([q,"",z])}),eo.stopCallback(e=>{e||h(p.cachePath)}),process.on("exit",function(){et.close(()=>{}),eo.invalidate(),eo.stop()}),process.on("SIGINT",()=>{process.exit()});
|
package/lib/has-pkg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessSync as
|
|
1
|
+
import{accessSync as t,constants as r}from"fs";import{resolveNodeModulesPath as o}from"./utils.js";export function hasPkg(s){let a;try{t(o(`${s}/package.json`),r.R_OK),a=!0}catch(t){a=!1}return a}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{merge as e}from"webpack-merge";import t
|
|
1
|
+
import{merge as e}from"webpack-merge";import{CONFIG as t}from"./config.js";import{PACKAGENAME as i,coreName as o}from"./process-env.js";import{resolveProgramPath as a}from"./utils.js";import m from"./vm/app.js";let{template:p,favicon:r,...l}=Object.assign({template:`node_modules/${o}/template/index.html`,favicon:`node_modules/${o}/template/favicon.ico`},t.htmlPluginOption||{}),n=e({title:t.env?.PROJECTNAME||i.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:m.description||""},tags:[],template:a(p),favicon:a(r)},l);export default n;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as paths, CUSTOMCONFIG } from './paths.js';
|
|
2
|
-
export { FRAMEWORKNAME, PACKAGENAME, PACKAGEVERSION, coreName, isDev, isLibrary, isMicro, } from './process-env.js';
|
|
2
|
+
export { FRAMEWORKNAME, PACKAGENAME, PACKAGEVERSION, coreName, isDev, isLibrary, isMicro, mainDirectory, } from './process-env.js';
|
|
3
3
|
export { realResolve, resolveNodeModulesPath, resolveProgramPath, log } from './utils.js';
|
|
4
|
-
export {
|
|
4
|
+
export { getIPv4, getPort } from './net.js';
|
|
5
5
|
export type * from '../typings/global.d.ts';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as paths,CUSTOMCONFIG}from"./paths.js";export{FRAMEWORKNAME,PACKAGENAME,PACKAGEVERSION,coreName,isDev,isLibrary,isMicro}from"./process-env.js";export{realResolve,resolveNodeModulesPath,resolveProgramPath,log}from"./utils.js";export{
|
|
1
|
+
export{default as paths,CUSTOMCONFIG}from"./paths.js";export{FRAMEWORKNAME,PACKAGENAME,PACKAGEVERSION,coreName,isDev,isLibrary,isMicro,mainDirectory}from"./process-env.js";export{realResolve,resolveNodeModulesPath,resolveProgramPath,log}from"./utils.js";export{getIPv4,getPort}from"./net.js";
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const UNICODE_MATCH_REG = /[\u4e00-\u9faF]+/g;
|
|
3
|
-
|
|
4
|
-
module.exports = function (source) {
|
|
5
|
-
return source.replace(CONTENT_MATCH_REG, function (m) {
|
|
6
|
-
return m.replace(UNICODE_MATCH_REG, function (s) {
|
|
7
|
-
return `\\${s.charCodeAt(0).toString(16)}`;
|
|
8
|
-
});
|
|
9
|
-
});
|
|
10
|
-
};
|
|
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)}`})})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (content: string): string;
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const linesExp = /^\n+|\n+$/g;
|
|
3
|
-
|
|
4
|
-
module.exports = function (source) {
|
|
5
|
-
return source.replace(regExp, '').replace(linesExp, '');
|
|
6
|
-
};
|
|
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,"")}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (content: string): string;
|
|
@@ -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("fs");function t(t){let{original:s,override:r}=this.getOptions(),i=this.resourcePath.replace(s,r);if(this.resourcePath.startsWith(s)&&(0,e.existsSync)(i)){let t=this.async();(0,e.readFile)(i,{encoding:"utf-8"},(e,s)=>{t(null,s)})}else this.callback(null,t)}
|
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 from"./paths.js";import{FRAMEWORK as
|
|
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";let x={loader:`${l.corePath}/loader/css-unicode.cjs`},$=m?o:"../",g={loader:e.loader,options:{publicPath:"/"!==$?$:"../"}},j=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(f),w=[...["src/styles/variables.less","src/styles/mixins.less","site/styles/variables.less","site/styles/mixins.less"].map(y)],h=["components","example","mock","site","src","server"].map(y);i&&h.push(y(i));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}},k=c&&{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!c}},O=[g,k,b,j,x,{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:w}}].filter(Boolean),B="tsc"===t.compiler,P={loader:B?"ts-loader":"swc-loader",options:B?u:p(c)};function L(e){return h.concat(t.rulesInclude?.[e]?.map(f)||[])}let _=L("media"),M={rules:[i&&{include:t.alias["@"],exclude:[/node_modules/],enforce:"pre",use:[{loader:`${l.corePath}/loader/override.cjs`,options:{override:y(i),original:t.alias["@"]}}]},d&&{test:/\.mdx?$/i,include:[l.componentsPath],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:`${l.corePath}/loader/frontmatter.cjs`}]},{oneOf:[{resourceQuery:/raw/i,type:"asset/source"},{resourceQuery:/url/i,type:"asset/resource",generator:{filename:e=>{let s=e.filename;return s&&s.endsWith("wasm?url")?"wasm/[name][ext]":"assets/[name][ext]"}}},{test:/\.wasm$/i,type:"webassembly/async",include:L("wasm")},{test:/\.txt$/i,type:"asset/source"},{test:/\.ico$/i,type:"asset/inline",include:_},{test:/\.svg$/i,type:"asset/inline",generator:{dataUrl:e=>s(e.toString())},include:_},{test:/\.(gif|png|jpe?g|webp)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext]"},include:_},{test:/\.(webm|mp4|ogv)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/video/[name][ext]"},include:_},{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,k,b,j,x,{loader:"sass-loader",options:{implementation:await import("sass"),sassOptions:{}}}].filter(Boolean),include:L("css")},{test:/\.less$/i,use:O,include:L("css")},{test:/\.css$/i,use:[g,"css-loader",j,x].filter(Boolean),include:L("css")},{test:/\.(cj|mj|t|j)s(|x)$/i,use:[...t.prefixJsLoader,P].filter(Boolean),include:L("js")},{test:/\.mdx?$/i,use:[...t.prefixJsLoader,P,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:h,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/i,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules].filter(e=>"object"==typeof e)};export default M;
|
package/lib/net.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export declare function getNetworkAdress(): string | undefined | void;
|
|
2
1
|
export declare function getIPv4(): string | undefined;
|
|
3
|
-
export declare function getPort(start:
|
|
2
|
+
export declare function getPort<T = number>(start: T, end: number, host?: string): Promise<T>;
|
package/lib/net.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createConnection as
|
|
1
|
+
import{createConnection as e}from"net";import r from"webpack-dev-server";let{internalIPSync:t}=r;export function getIPv4(){return t("v4")}export function getPort(r,t,o="0.0.0.0"){return new Promise(n=>{if("number"!=typeof r)n(r);else{let f=e(r,o);f.on("connect",()=>{f.destroy(),n(getPort(r+1,t,o))}),f.on("error",()=>{n(r)})}})}
|
package/lib/paths.d.ts
CHANGED
package/lib/paths.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,mkdirSync as o}from"fs";import c from"url";
|
|
1
|
+
import{existsSync as e,mkdirSync as o}from"fs";import c from"url";let t=JSON.parse(process.env.npm_config_argv||"{}")?.original;export const yarnArgv={};t?.forEach(e=>{let o=e.split("=");Object.assign(yarnArgv,{[o[0]]:o[1]||!0})});export const CUSTOMCONFIG=process.env.npm_config_config||yarnArgv.config;let a=process.cwd(),r=`${a}/node_modules/.cache/.mo`;e(r)||o(r,{recursive:!0});export default{corePath:c.fileURLToPath(new URL(".",import.meta.url)),programPath:a,webpackCachePath:`${a}/node_modules/.temp_cache`,cachePath:r,httpCachePath:`${a}/node_modules/.cache/http`,swcCachePath:`${a}/node_modules/.swc`,configPath:`${a}/config/index.ts`,customConfigPath:`${a}/config/${CUSTOMCONFIG}.ts`,coveragePath:`${a}/coverage/clover.xml`,pagesPath:`${a}/src/pages`,componentsPath:`${a}/components`};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isDev as o}from"../process-env.js";import{vmWriteing as e}from"../reactive-object.js";export default class{constructor(o){this.options=Object.assign({},o)}apply(n){o||n.hooks.compilation.tap("DoneWebpackPlugin",o=>{e.setData("DoneDonePlugin",!0),o.compiler.hooks.done.tap("DoneDonePlugin",()=>{e.setData("DoneDonePlugin",!1)})}),n.hooks.done.tap("DoneWebpackPlugin",o=>{this.options.done(o)})}}
|
|
@@ -2,10 +2,10 @@ import type { Compiler } from 'webpack';
|
|
|
2
2
|
interface VirtualModulePluginOption {
|
|
3
3
|
[key: string]: string | object;
|
|
4
4
|
}
|
|
5
|
-
declare class
|
|
5
|
+
declare class VirtualModuleWebpackPlugin {
|
|
6
6
|
private readonly options;
|
|
7
7
|
private hasTapped;
|
|
8
8
|
constructor(options: VirtualModulePluginOption);
|
|
9
9
|
apply(compiler: Compiler): void;
|
|
10
10
|
}
|
|
11
|
-
export default
|
|
11
|
+
export default VirtualModuleWebpackPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"webpack-virtual-modules";import{isLibrary as o}from"../process-env.js";import{vmWriteing as e}from"../reactive-object.js";import{resolveNodeModulesPath as s}from"../utils.js";import{docs as i}from"../vm/docs.js";import{locales as p,localesModuleName as r}from"../vm/locales.js";import{exampleModuleName as a,examples as l,route as n,routesModuleName as f}from"../vm/routes.js";export default class{constructor(t){this.options=t,this.hasTapped=!1}apply(m){let c=new t({[s(f)]:n.getData(f),[s(a)]:"export default []",[s(r)]:p.getData(r)});function h(t,o){c.writeModule(s(t),o||""),e.setData(t,!1)}c.apply(m),n.on("change",h),p.on("change",h),o&&(l.on("change",h),i.on("change",h)),m.hooks.compilation.tap("VirtualModuleWebpackPlugin",()=>{if(!this.hasTapped){for(let t in this.options)if(Object.prototype.hasOwnProperty.call(this.options,t)){let o=this.options[t];h(t,"string"==typeof o?o:`export default ${JSON.stringify(o)}`)}for(let t of l)h(...t);for(let t of i)h(...t);this.hasTapped=!0}})}}
|
package/lib/process-env.d.ts
CHANGED
|
@@ -3,8 +3,11 @@ export declare const APPTYPE: AppType;
|
|
|
3
3
|
export declare const FRAMEWORK: Framework;
|
|
4
4
|
export declare const isLibrary: boolean;
|
|
5
5
|
export declare const isMicro: boolean;
|
|
6
|
+
export declare const isMobile: boolean;
|
|
6
7
|
export declare const isReact: boolean;
|
|
7
8
|
export declare const isSolid: boolean;
|
|
9
|
+
/** 项目主要文件夹 */
|
|
10
|
+
export declare const mainDirectory: string;
|
|
8
11
|
export declare const jsxImportSource: string;
|
|
9
12
|
export declare const createElement: string;
|
|
10
13
|
/** 框架名称 */
|
package/lib/process-env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as e}from"fs";import t from"./paths.js";export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const createElement={react:"createElement",solid:"createComponent"}[FRAMEWORK];export const FRAMEWORKNAME={react:"react",solid:"solid-js"}[FRAMEWORK];export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;let o=e(`${t.corePath}/../package.json`,{encoding:"utf-8"});export const coreName=JSON.parse(o).name;export const isDev="development"===process.env.NODE_ENV;let s=Object.keys(process.env);export const hasEslintConfig=-1!==s.findIndex(e=>e.startsWith("npm_package_eslintConfig_"));export const hasStylelintConfig=-1!==s.findIndex(e=>e.startsWith("npm_package_stylelint_"));
|
|
1
|
+
import{readFileSync as e}from"fs";import t from"./paths.js";export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isMobile="mobile"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const createElement={react:"createElement",solid:"createComponent"}[FRAMEWORK];export const FRAMEWORKNAME={react:"react",solid:"solid-js"}[FRAMEWORK];export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;let o=e(`${t.corePath}/../package.json`,{encoding:"utf-8"});export const coreName=JSON.parse(o).name;export const isDev="development"===process.env.NODE_ENV;let s=Object.keys(process.env);export const hasEslintConfig=-1!==s.findIndex(e=>e.startsWith("npm_package_eslintConfig_"));export const hasStylelintConfig=-1!==s.findIndex(e=>e.startsWith("npm_package_stylelint_"));
|
package/lib/prod.js
CHANGED
|
@@ -1 +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 t}from"webpack-bundle-analyzer";import{merge as r}from"webpack-merge";import{clientConfig as s}from"./common.js";import{CONFIG as p}from"./config.js";import{getMinifyOption as l}from"./minify.js";import a from"./paths.js";import c from"./plugin/done.js";import{vmWriteing as u}from"./reactive-object.js";import f from"./seo.js";import{cleanDir as d}from"./utils.js";let{optimize:{MinChunkSizePlugin:h}}=m,{cssnanoMinify:w,swcMinify:k}=i,j="swc"===p.compiler,b=[];p.minifier&&(p.minifier.js&&b.push(new n(l(p.minifier.js?.type||(j?"swc":"terser"),p.minifier.js?.options))),p.minifier.css&&b.push(new i({minify:{swc:k,cssnano:w}[p.minifier.css?.type||(j?"swc":"cssnano")],minimizerOptions:p.minifier.css?.options})));let y={splitChunks:p.splitChunk,runtimeChunk:p.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:b},g=r(s,{devtool:!1===p.devtool||p.devtool?p.devtool:"cheap-module-source-map",mode:"production",optimization:y,plugins:[new o({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),p.bundleAnalyzer&&new t(p.bundleAnalyzer),p.splitChunk&&new h({minChunkSize:1e4}),new c({done:e=>{u.setData("done",!0),p.done?.(e),p.seo&&f(),u.setData("done",!1)}})].filter(Boolean)}),z=m(g);z.watch({},()=>{}),u.on("change",()=>{clearTimeout(e),e=setTimeout(()=>{clearTimeout(e);let i=u.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(()=>{}),d(a.cachePath)});
|
package/lib/reactive-object.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
|
-
declare class
|
|
4
|
-
|
|
3
|
+
declare class WriteingReactiveObject<T extends object = Record<string, string | undefined>> extends EventEmitter {
|
|
4
|
+
readonly data: T;
|
|
5
5
|
constructor(props?: T);
|
|
6
6
|
setData(key: keyof T, value: T[keyof T]): void;
|
|
7
7
|
getData(key: keyof T): T[keyof T];
|
|
8
8
|
[Symbol.iterator](): Iterator<[keyof T, T[keyof T]]>;
|
|
9
9
|
}
|
|
10
|
+
export declare const vmWriteing: WriteingReactiveObject<Record<string, boolean>>;
|
|
11
|
+
declare class ReactiveObject<T extends object = Record<string, string | undefined>> extends WriteingReactiveObject<T> {
|
|
12
|
+
readonly data: T;
|
|
13
|
+
constructor(props?: T);
|
|
14
|
+
setData(key: keyof T, value: T[keyof T]): void;
|
|
15
|
+
}
|
|
10
16
|
export default ReactiveObject;
|
package/lib/reactive-object.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"events";
|
|
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]}[Symbol.iterator](){let t=Object.keys(this.data),e=0;return{next:()=>{if(e<t.length){let a=t[e++];return{value:[a,this.data[a]],done:!1}}return{value:void 0,done:!0}}}}}export const vmWriteing=new a({done:!0});export default class extends a{constructor(t={}){super(),this.data=t}setData(t,e){e!==this.data[t]&&(this.data[t]=e,vmWriteing.setData(t,!0),this.emit("change",t,e))}}
|
package/lib/seo.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
declare const seo: () => void;
|
|
2
|
+
export default seo;
|
package/lib/seo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as t,mkdirSync as o,writeFileSync as r}from"fs";import{join as i}from"path";import{outputConfig as
|
|
1
|
+
import{existsSync as t,mkdirSync as o,writeFileSync as r}from"fs";import{join as i}from"path";import{outputConfig as m}from"./common.js";import{CONFIG as e}from"./config.js";import{resolveProgramPath as s}from"./utils.js";import{routes as p}from"./vm/routes.js";function f(t,o){try{r(t,o,"utf-8")}catch(t){}}export default(()=>{let{domain:r,nojekyll:n,path:a}=e.seo||{},h=a&&s(a)||m?.path;if(!r||!h)return;t(h)||o(h);let c=e.basename,l=c.endsWith("/")?c:`${c}/`;f(i(h,"CNAME"),r),f(i(h,"robots"),`Sitemap: https://${r}${l}sitemap.txt`);let u=[];!function t(o){o.forEach(o=>{u.push(`https://${r}${l}${o.key}`),Array.isArray(o.children)&&t(o.children)})}(p),f(i(h,"sitemap.txt"),u.join("\n")),n&&f(i(h,".nojekyll"),"")});
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function esm(templateStrings: TemplateStringsArray, ...substitutions: unknown[]): string;
|
|
1
2
|
/** 获取导出标识
|
|
2
3
|
* @param {string} path 文件地址
|
|
3
4
|
* @returns {string[]} 包含的标识
|
|
@@ -7,6 +8,7 @@ export declare function log(msg: string | string[]): void;
|
|
|
7
8
|
export declare function tfc(filepath: string): string;
|
|
8
9
|
export declare function readConf(src: string, name: string): Promise<any>;
|
|
9
10
|
export declare function toUpperCaseString(string: string): string;
|
|
11
|
+
export declare function cleanDir(folderPath: string): void;
|
|
10
12
|
type ProgramPath<T extends string> = `${T extends string ? T : string}`;
|
|
11
13
|
type NodeModulesPath<T> = ProgramPath<`node_modules/${T extends string ? T : string}`>;
|
|
12
14
|
/** 位于项目根目录下的位置
|
package/lib/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)}):(
|
|
1
|
+
import{existsSync as t,readFileSync as e,readdirSync as r,rmdirSync as o,statSync as n,unlinkSync as c,writeFileSync as s}from"fs";import{join as p,resolve as i}from"path";import a from"readline";import{transformFileSync as u}from"@swc/core";import f from"./paths.js";import l from"./resolver-sync.js";export function esm(t,...e){let r=t.raw[0];for(let o=0;o<e.length;o++)r+=e[o]+t.raw[o+1];return`data:text/javascript;base64,${Buffer.from(r).toString("base64")}`}let m=/export\s+(?:async\s+)?(?:function|const)\s+(\w+)/g;export function getExportTokens(t){let r;let o=e(t,{encoding:"utf-8"}),n=[];for(;r=m.exec(o);)n.includes(r[1])||n.push(r[1]);return n}let x={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
|
+
`)}):(a.cursorTo(process.stdout,0),process.stdout.write(t))}export function tfc(t){return u(t,x).code||"{}"}export function readConf(t,e){let r=`${f.cachePath}/${e}.mjs`;return s(r,tfc(t),"utf-8"),import(r)}export function toUpperCaseString(t){return t?.replace(/\b\w/g,t=>t.toUpperCase()).replace(/\./g," ")}export function cleanDir(e){t(e)&&(r(e).forEach(t=>{let r=p(e,t);n(r).isDirectory()?cleanDir(r):c(r)}),o(e))}export function resolveProgramPath(t){return i(f.programPath,`./${t}`)}export const resolveNodeModulesPath=t=>resolveProgramPath(`node_modules/${t}`);export const realResolve=t=>l.resolveSync({},f.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/virtual-modules.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{accessSync as p,constants as o}from"fs";import{join as r}from"path";import e
|
|
1
|
+
import{accessSync as p,constants as o}from"fs";import{join as r}from"path";import{CONFIG as e}from"./config.js";import{FRAMEWORKNAME as m,isLibrary as s,isReact as t}from"./process-env.js";import{resolveProgramPath as a}from"./utils.js";import c from"./vm/app-entry.js";import f from"./vm/app.js";import{coverage as i}from"./vm/coverage.js";import l from"./vm/fallback.js";import n from"./vm/merge-router.js";import u from"./vm/normalize-css.js";import x from"./vm/prefix-router.js";let j={...e.virtualModule,"@app":f,"@app/fallback":l,"@app/coverage":i,"@app/normalize/index.css":u,"@app/prefix-router":x,"@app/suspense/index.tsx":`import ${t?"React,":""}{Suspense,lazy} from "${m}";import Fallback from '@app/fallback';${s?'import scope from "@app/mdx-scope";':""}function SuspenseComp(props) {const Lazy = lazy(props.comp);return (<Suspense fallback={Fallback && <Fallback />}><Lazy ${s?"components={scope}":""}/></Suspense>);}export default SuspenseComp;`,"@app/entry":c,"@app/merge-router":n},v={};if(s)try{let e=r(a("site"),"./mdx-scope.ts");p(e,o.R_OK),v='import scope from "@/mdx-scope";export default scope;'}catch(p){v={}}Object.assign(j,{"@app/mdx-scope":v});export default j;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as o}from"fs";import{join as p}from"path";import n from"./rem.js";import{CONFIG as t}from"../config.js";import{FRAMEWORK as r,isMicro as e,isMobile as i}from"../process-env.js";import{getExportTokens as m}from"../utils.js";let s=p(t.alias["@"],"./index.ts"),_=o(s),u="",a=`const renderApp = (await import('@moneko/${r}/lib/entry.js')).default;`,d=[];if(_){let o="";e&&(d=m(s).filter(Boolean)).length&&(o=`{${d.map(o=>`${o} as app${o}`).join(",")}} from `),u=`import ${o}"@/index.ts";`}u+=`import "@app/normalize/index.css";${n}`,e?(u+="if (window.__POWERED_BY_QIANKUN__) {__webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;}",a+=`if (!window.__POWERED_BY_QIANKUN__) {renderApp();}let unmountApp = void 0;export async function bootstrap() {console.log('app bootstraped');}export async function mount(props) {${d.includes("mount")?"appmount(props);":""}unmountApp = renderApp(props);}export async function unmount(props) {${d.includes("unmount")?"appunmount(props);":""}unmountApp();}`):a+="renderApp();",i&&(a+="window.H5RemoteRuntime = {bootstrap: renderApp};");let f=`${u}${a}`;export default f;
|
|
@@ -3,10 +3,10 @@ declare const app: {
|
|
|
3
3
|
projectName: string;
|
|
4
4
|
version: string;
|
|
5
5
|
base: string;
|
|
6
|
-
type: import("
|
|
6
|
+
type: import("../index.js").AppType;
|
|
7
7
|
routerMode: "browser" | "hash" | "memory";
|
|
8
8
|
prefixCls: string | undefined;
|
|
9
|
-
theme: import("
|
|
9
|
+
theme: import("../index.js").Theme | undefined;
|
|
10
10
|
description: string | undefined;
|
|
11
11
|
author: {
|
|
12
12
|
name: string | undefined;
|
package/lib/vm/app.js
ADDED
|
@@ -0,0 +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 r=e(t("package.json"),{encoding:"utf-8"}),{description:o,author:p,repository:s}=JSON.parse(r);n.author="string"==typeof p?{name:p}:p,n.repository="string"==typeof p?{url:s}:s,n.description=o}export default n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{accessSync as e,constants as r,readFileSync as c}from"fs";import{Parser as o}from"xml2js";import t from"../paths.js";import{PACKAGENAME as a,isLibrary as s}from"../process-env.js";export const coverage={};if(s)try{e(t.coveragePath,r.R_OK);let s=new o({explicitArray:!1,async:!1}).parseString,i=c(t.coveragePath,{encoding:"utf-8"});s(i,(e,r)=>{if(!e){let e=r.coverage.project.metrics.$,c=r.coverage.project.package;Object.assign(coverage,{[a]:e}),c.forEach(e=>{Object.assign(coverage,{[e.$.name]:e.metrics.$})})}})}catch(e){}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import ReactiveObject from '
|
|
1
|
+
import ReactiveObject from '../reactive-object.js';
|
|
2
2
|
export declare const docs: ReactiveObject<Record<string, string | undefined>>;
|
package/lib/vm/docs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{statSync as e}from"fs";import{dirname as t,join as o}from"path";import{watch as r}from"chokidar";import{CONFIG as n}from"../config.js";import s from"../generate-api.js";import i from"../paths.js";import{FRAMEWORK as a,FRAMEWORKNAME as p,createElement as l,isDev as c,isLibrary as m,isReact as d,isSolid as f}from"../process-env.js";import u,{vmWriteing as $}from"../reactive-object.js";let g="@app/comment";export const docs=new u;let h={[g]:{}},b=`() => ${l}(SuspenseComp, { comp: $1 })`,x=`import { ${l}${f?",Dynamic":""} } from "${p}${f?"/web":""}";import SuspenseComp from "@app/suspense";`;function j(e,r){global.NEKOCLICONFIG.vmWriteing=!0;let i=e.replace(RegExp(`^${n.alias["@pkg"]}`),""),a=t(i).replace(/^\//,""),p=[g,a].join("/"),c=i.split("/").pop()?.replace(/\.tsx?/,".md");if(!c)return;h[g][a]||(h[g][a]={});let m=o(p,c);if("deleted"===r)h[g][a][c]&&delete h[g][a][c];else{let t=s(e);h[m]=t,t?h[g][a][c]=`rr(() => import(/* webpackChunkName: '${m}' */'${m}?raw').then((res) => ({default: ${d?"() =>":""}${l}(${f?"Dynamic":"'n-md'"}, {text: res.default, ${f?"component: 'n-md', ":""}css: 'table td a {display:inline-flex;align-items:center;gap:2px;}table td a n-img{display:inline-block;overflow:hidden;border-radius:var(--border-radius);inline-size:18px;block-size:18px;}'})})))rr`:h[g][a][c]&&delete h[g][a][c]}let u={};for(let e in h)if(Object.prototype.hasOwnProperty.call(h,e)){let t=h[e];if(e===g)for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(u[e]=Object.values(t[e]));else docs.setData(e,t)}docs.setData("@app/docs",`${x}export default ${JSON.stringify(u).replace(/"rr\((.+?)\)rr"/g,b)}`)}["react","solid"].includes(a)||(b="$1",x=""),m&&function(){$.setData("vm-docs",!0);let t=[],o=r(i.componentsPath,{ignored:[/(^|\/)\../,/(^|\/)__tests__(\/|$)/],persistent:!0,ignoreInitial:!1});function n(){o.unwatch(i.componentsPath),o.close(),$.setData("vm-docs",!1)}function s(t){return/\.tsx?$/.test(t)&&e(t).isFile()}o.on("add",e=>{s(e)&&(j(e,"added"),t.push(e))}),o.on("change",e=>{s(e)&&j(e,"change")}),o.on("unlink",e=>{s(e)&&(j(e,"deleted"),t.splice(t.indexOf(e),1))}),o.once("ready",()=>{t.forEach(e=>{j(e,"change")}),c||n()}),process.on("SIGINT",n)}();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CONFIG as l}from"../config.js";let a="export default null";l.fallbackCompPath&&(a=`import Fallback from "${l.fallbackCompPath}";export default Fallback;`);export default a;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{existsSync as e}from"fs";import{basename as t,join as a}from"path";import{watch as o}from"chokidar";import{CONFIG as l}from"../config.js";import{FRAMEWORK as r,isDev as n}from"../process-env.js";import s,{vmWriteing as c}from"../reactive-object.js";import{empty as i,esm as g,tfc as f}from"../utils.js";let u={react:'import sso from "shared-store-object";',solid:'import { createEffect, createRoot, getOwner } from "solid-js";import { createStore } from "solid-js/store";'},p={react:'let storageKey="localizable.language",language=localStorage.getItem(storageKey)||"zh_CN",{translation:a,...defaultLocale}=Object.assign({title:"简体中文",language:"zh_CN",translation:{}},resources[language]||resources.zh_CN),localizable=sso({lang:defaultLocale,t:a});export function setLang(a){let{translation:e,...l}=resources[a]||{};e&&(localizable.lang=l,localizable.t=e,localStorage.setItem(storageKey,l.language))}export default localizable;',solid:'let locale=createRoot(()=>{let e="localizable.language",a=localStorage.getItem(e)||"zh_CN",{translation:l,...o}=Object.assign({title:"简体中文",language:"zh_CN",translation:{}},resources[a]||resources.zh_CN),[n,c]=createStore({lang:o,t:l});return createEffect(()=>{let a=resources[n.lang.language]?.translation;a&&(c("t",a),localStorage.setItem(e,n.lang.language))}),{localizable:n,setLocalizable:c,setLang:function(e){let{translation:a,...l}=resources[e]||{};a&&c("lang",l)}}},getOwner());export const setLocalizable=locale.setLocalizable;export const t=locale.localizable.t;export const lang=locale.localizable.lang;export const setLang=locale.setLang;'}[r];function d(e,t){return`${u[r]}
|
|
2
|
+
export function interpolateString(r,n){return r.replace(/\\\${\\w+}/g,function(r){var t=r.slice(2,-1);var e=n[t];return e!==void 0?e.toString():""})}function deepFreeze(o) { const p = Reflect.ownKeys(o);for (const k of p) {const v = o[k];if ((v && typeof v === "object") || typeof v === "function") {deepFreeze(v);}}return Object.freeze(o);}export const locales = ${JSON.stringify(e)};const _res = ${JSON.stringify(t)};const resources = deepFreeze(_res);${p}`}export const localesModuleName="@app/locales";export const locales=new s({[localesModuleName]:d([],{})});let m={};async function z(e,a){let o=t(e).replace(/\.[^.]+$/,"");if("deleted"===a)delete m[o];else{let t=await import(g`${f(e)}`);Object.assign(m,{[o]:t.default})}let l=[],r={};for(let e in m)if(Object.prototype.hasOwnProperty.call(m,e)){let t=m[e],{language:a=o,title:n=a,icon:s,translation:c={}}=t;l.push({language:a,title:n,icon:s}),r[a]={language:a,title:n,icon:s,translation:c}}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$/]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CONFIG as e}from"../config.js";let t="";e.normalizeCss&&(t='html,body{margin:0;padding:0;line-height:1.8}input,textarea{caret-color:inherit}h1{margin:0.67em 0;font-size:2em}hr{overflow:visible;block-size:0;box-sizing:content-box}pre{font-size:1em;font-family:monospace}a{text-decoration:none;background-color:transparent;cursor:pointer}abbr[title]{border-block-end:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-size:1em;font-family:monospace}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{inset-block-end:-0.25em}sup{inset-block-start:-0.5em}img{border-style:none}img,button{outline:1px solid transparent}button,input,optgroup,select,textarea{margin:0;font-size:100%;font-family:inherit;line-height:1.15}button,input{overflow:visible}button,select{text-transform:none}button,[type="button"],[type="reset"],[type="submit"]{appearance:button}button::-moz-focus-inner,[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type="button"]:-moz-focusring,[type="reset"]:-moz-focusring,[type="submit"]:-moz-focusring{outline:1px dotted var(--primary-outline)}fieldset{padding:0.35em 0.75em 0.625em}legend{display:table;padding:0;max-inline-size:100%;white-space:normal;color:inherit;box-sizing:border-box}progress{vertical-align:baseline}textarea{overflow:auto}details{display:block}summary{display:list-item}template,[hidden]{display:none}[type="checkbox"],[type="radio"]{box-sizing:border-box;padding:0}[type="number"]::-webkit-inner-spin-button,[type="number"]::-webkit-outer-spin-button{block-size:auto}[type="search"]{appearance:textfield;outline-offset:-2px}[type="search"]::-webkit-search-decoration{appearance:none}::-webkit-file-upload-button{appearance:button;font:inherit}::-webkit-scrollbar{inline-size:5px;block-size:5px}::-webkit-scrollbar-track,::-webkit-scrollbar-thumb{background-color:transparent}:hover::-webkit-scrollbar-thumb{background-color:var(--primary-selection)}::-webkit-scrollbar-thumb:hover{background-color:var(--primary-hover)}::-webkit-scrollbar-thumb:active{background-color:var(--primary-active)}::-webkit-scrollbar-button{display:none}');export default t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isReact as e}from"../process-env.js";let t="";e&&(t='import { createElement, isValidElement } from "react";import { Outlet } from "react-router-dom";function prefix(e){return e.map(function(e){var n=Object.assign({key:e.path},e);return n.element?isValidElement(n.element)||(n.element=createElement(n.element,n.meta)):n.element=createElement(Outlet,null),Array.isArray(n.children)&&(n.children=prefix(n.children)),n})}export default prefix;');export default t;
|
package/lib/vm/rem.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CONFIG as e}from"../config.js";let t="";e.rem.designSize&&(t=`!function(e,n){function t(){let n=e.documentElement,t=n.clientWidth||e.body.clientWidth,i=t<=375?375:${e.rem.designSize},o=t;o=t<=375?t:t<=${e.rem.designSize}?i:t;let d=16/i*o+"px";d!==n.style.fontSize&&(n.style.fontSize=d)}t(),"addEventListener"in e&&n.addEventListener("orientationchange"in n?"orientationchange":"resize",t,!1)}(document,window);`);export default t;
|
package/lib/vm/routes.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e,t,r;import{accessSync as o,constants as s,readFileSync as n,readdirSync as a,statSync as p}from"fs";import{join as i,relative as l}from"path";import{watch as c}from"chokidar";import{load as m}from"js-yaml";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";let O=/^---\n([\s\S]+?)\n---\n/;try{o(`${u.alias["@"]}/router/index.ts`,s.R_OK),e=!0}catch(t){e=!1}let T=y?"component":"element";function k(e){return e.replace(/\$/g,":").replace(/^index\.tsx?$/,"/").replace(/^README\.mdx?$/,"/")}function E(e,t){let{regex:r,alia:o,base:s=e,outputSource:c}=t,u=a(e);return u.reduce((a,u)=>{let f=i(e,u),d=p(f);if(d.isDirectory()){let e=E(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)}a.push(Object.assign(t,r))}}else if(r.test(f)){let e=n(f,{encoding:"utf-8"}),t=function(e){let t=e.match(O);return t&&t[1]?t[1].trim():null}(e),r=t?m(t):{},p=l(s,f),u=k(p);a.push(Object.assign({path:u.split("/").slice(-2,-1)?.join("")||"/",key:u.replace(/\/?index.tsx?$/,"/").replace(/\/?README.mdx?$/,"/").split("/").filter(Boolean).join("/"),meta:{...r}},o&&{[T]:`rr(() => import(/* webpackChunkName: '${p}' */'${i(o,p)}'))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,s=e.split(" ").pop()||"jsx";r[s]=o.trim()}return Object.keys(r).length?r:{jsx:e}}(e.replace(O,"").replace(/^\n+|\n+$/g,""))}))}return a},[])}export const routesModuleName="@app/routes";export const route=new D({[routesModuleName]:"export default []"});export const exampleModuleName="@app/example";export const examples=new D;let M=`${y?"() => ":""}${h}(SuspenseComp, { comp: $1 })`,S=`import { ${h} } from "${x}";import SuspenseComp from "@app/suspense";${j?'import prefix from "@app/prefix-router";':""}`;e&&(S+='import merge from "@app/merge-router";import customRouter from "@/router";'),["react","solid"].includes(d)||(M="$1",S="");export let routes=[];function b(t){return`${S}const routes = [{ path: "/", children: [${y?'{ path: "/" },':""} ${t}] }];const _routes = ${e?'merge([...routes, ...customRouter], "path")':"routes"};export default ${j?"prefix(_routes)":"_routes"};`}function R(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 n(){s.unwatch(e),s.close(),N.setData(o,!1)}s.on("add",()=>{r()}).on("change",()=>{r()}).on("unlink",()=>{r()}),s.once("ready",()=>{g||n()}),process.on("SIGINT",n)}$?(R(f.componentsPath,/(?<!README\.mdx?)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),routes=E(f.componentsPath,{regex:/README\.mdx?$/,alia:"@pkg"}),route.setData(routesModuleName,b(JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,M).slice(1,-1)))},100)},"vm-router"),R(f.componentsPath,/(?<!\/examples\/(.+)\.md)$/,function(){clearTimeout(r),r=setTimeout(()=>{clearTimeout(r),E(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")):R(f.pagesPath,/(?<!index\.tsx?)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),routes=E(f.pagesPath,{regex:/index\.tsx?$/,alia:"@/pages"}),route.setData(routesModuleName,b(JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,M).slice(1,-1)))},100)},"vm-router");
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "swc src -d lib -D",
|
|
9
|
-
"
|
|
8
|
+
"build": "rm -rf ./lib && tsc && swc src -d lib -D",
|
|
9
|
+
"postbuild": "find ./lib/loader/ -type f -name \"*.js\" -execdir bash -c 'mv \"$1\" \"${1%.js}.cjs\"' _ {} \\;"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [],
|
|
12
12
|
"author": "moneko",
|
package/typings/global.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ import type { MinifyOptions } from 'terser';
|
|
|
10
10
|
import type { Options } from 'ts-import-plugin';
|
|
11
11
|
import type { Configuration, ExternalsPresets, RuleSetRule, WebpackPluginInstance } from 'webpack';
|
|
12
12
|
import type {
|
|
13
|
+
Configuration as DevServerConfiguration,
|
|
13
14
|
ProxyArray,
|
|
14
15
|
ProxyConfigArray,
|
|
15
16
|
ProxyConfigMap,
|
|
16
|
-
WebpackConfiguration,
|
|
17
17
|
} from 'webpack-dev-server';
|
|
18
18
|
export type WebpackBarOptions = ConstructorParameters<typeof WebpackBar>[0];
|
|
19
19
|
export type MinifierType = 'swc' | 'terser';
|
|
@@ -29,7 +29,32 @@ export type HtmlWebpackOption = HtmlWebpackPluginOptions & {
|
|
|
29
29
|
}[];
|
|
30
30
|
};
|
|
31
31
|
export type CssMinify = 'swc' | 'cssnano';
|
|
32
|
-
|
|
32
|
+
export type DevtoolOption =
|
|
33
|
+
| 'eval'
|
|
34
|
+
| 'eval-cheap-source-map'
|
|
35
|
+
| 'eval-cheap-module-source-map'
|
|
36
|
+
| 'eval-source-map'
|
|
37
|
+
| 'cheap-source-map'
|
|
38
|
+
| 'cheap-module-source-map'
|
|
39
|
+
| 'source-map'
|
|
40
|
+
| 'inline-cheap-source-map'
|
|
41
|
+
| 'inline-cheap-module-source-map'
|
|
42
|
+
| 'inline-source-map'
|
|
43
|
+
| 'eval-nosources-cheap-source-map'
|
|
44
|
+
| 'eval-nosources-cheap-module-source-map'
|
|
45
|
+
| 'eval-nosources-source-map'
|
|
46
|
+
| 'inline-nosources-cheap-source-map'
|
|
47
|
+
| 'inline-nosources-cheap-module-source-map'
|
|
48
|
+
| 'inline-nosources-source-map'
|
|
49
|
+
| 'nosources-cheap-source-map'
|
|
50
|
+
| 'nosources-cheap-module-source-map'
|
|
51
|
+
| 'nosources-source-map'
|
|
52
|
+
| 'hidden-nosources-cheap-source-map'
|
|
53
|
+
| 'hidden-nosources-cheap-module-source-map'
|
|
54
|
+
| 'hidden-nosources-source-map'
|
|
55
|
+
| 'hidden-cheap-source-map'
|
|
56
|
+
| 'hidden-cheap-module-source-map'
|
|
57
|
+
| 'hidden-source-map';
|
|
33
58
|
export type RulesInclude = {
|
|
34
59
|
css?: string[];
|
|
35
60
|
js?: string[];
|
|
@@ -100,7 +125,12 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
100
125
|
/** 环境变量, 可通过 process.env 获取 */
|
|
101
126
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
127
|
env?: Record<string, any>;
|
|
103
|
-
|
|
128
|
+
/**
|
|
129
|
+
* @default
|
|
130
|
+
* 开发模式: 'cheap-module-source-map'
|
|
131
|
+
* 生产模式: 'eval-cheap-module-source-map'
|
|
132
|
+
*/
|
|
133
|
+
devtool?: DevtoolOption | false;
|
|
104
134
|
sourceMap?: SourceMapDevToolPluginOptions | false;
|
|
105
135
|
/** 路径别名映射 */
|
|
106
136
|
alias: {
|
|
@@ -156,13 +186,7 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
156
186
|
/** 自定义缓存目录,为 false 时,不使用缓存 */
|
|
157
187
|
cacheDirectory: string | false;
|
|
158
188
|
/** 开发服务器设置 */
|
|
159
|
-
devServer:
|
|
160
|
-
allowedHosts?: string[];
|
|
161
|
-
host?: string;
|
|
162
|
-
port?: number;
|
|
163
|
-
https?: boolean;
|
|
164
|
-
compress?: boolean;
|
|
165
|
-
};
|
|
189
|
+
devServer: DevServerConfiguration;
|
|
166
190
|
/** HtmlWebpackPlugin Option */
|
|
167
191
|
htmlPluginOption: HtmlWebpackOption | false;
|
|
168
192
|
/** 自定义插入 html 的 js 和 css
|
|
@@ -216,7 +240,7 @@ export declare type ConfigType<T extends 'tsc' | 'swc' = 'swc'> = {
|
|
|
216
240
|
name?: string | Function;
|
|
217
241
|
};
|
|
218
242
|
/** 编译输出路径 */
|
|
219
|
-
output?: Omit<
|
|
243
|
+
output?: Omit<Configuration['output'], 'publishPath'> | string;
|
|
220
244
|
/** 模块联邦 */
|
|
221
245
|
moduleFederation: ModuleFederationOption[];
|
|
222
246
|
/** 跳过编译的模块 */
|
package/lib/app-entry.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as o}from"fs";import{join as p}from"path";import{CONFIG as n}from"./config.js";import{APPTYPE as t,FRAMEWORK as r,isMicro as e}from"./process-env.js";import i from"./rem.js";import{getExportTokens as m}from"./utils.js";let s=p(n.alias["@"],"./index.ts"),_=o(s),u="",a=`const renderApp = (await import('@moneko/${r}/lib/entry.js')).default;`,l=[];if(_){let o="";e&&(l=m(s).filter(Boolean)).length&&(o=`{${l.map(o=>`${o} as app${o}`).join(",")}} from `),u=`import ${o}"@/index.ts";`}u+=`import "@app/normalize/index.css";${i}`,e?(u+="if (window.__POWERED_BY_QIANKUN__) {__webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;}",a+=`if (!window.__POWERED_BY_QIANKUN__) {renderApp();}let unmountApp = void 0;export async function bootstrap() {console.log('app bootstraped');}export async function mount(props) {${l.includes("mount")?"appmount(props);":""}unmountApp = renderApp(props);}export async function unmount(props) {${l.includes("unmount")?"appunmount(props);":""}unmountApp();}`):a+="renderApp();","mobile"===t&&(a+="window.H5RemoteRuntime = {bootstrap: renderApp};");let d=`${u}${a}`;export default d;
|
package/lib/app.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 r=e(t("package.json"),{encoding:"utf-8"}),{description:o,author:p,repository:s}=JSON.parse(r);n.author="string"==typeof p?{name:p}:p,n.repository="string"==typeof p?{url:s}:s,n.description=o}export default n;
|
package/lib/cleanup.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function cleanDir(folderPath: string): void;
|
package/lib/cleanup.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as r,readdirSync as o,rmdirSync as i,statSync as t,unlinkSync as c}from"fs";import{join as e}from"path";export function cleanDir(f){r(f)&&(o(f).forEach(r=>{let o=e(f,r);t(o).isDirectory()?cleanDir(o):c(o)}),i(f))}
|
package/lib/coverage.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{accessSync as e,constants as r,readFileSync as c}from"fs";import{Parser as o}from"xml2js";import t from"./paths.js";import{PACKAGENAME as a,isLibrary as s}from"./process-env.js";export const coverage={};if(s)try{e(t.coveragePath,r.R_OK);let s=new o({explicitArray:!1,async:!1}).parseString,i=c(t.coveragePath,{encoding:"utf-8"});s(i,(e,r)=>{if(!e){let e=r.coverage.project.metrics.$,c=r.coverage.project.package;Object.assign(coverage,{[a]:e}),c.forEach(e=>{Object.assign(coverage,{[e.$.name]:e.metrics.$})})}})}catch(e){}
|
package/lib/docs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{statSync as e}from"fs";import{dirname as t,join as o}from"path";import{watch as r}from"chokidar";import{CONFIG as i}from"./config.js";import n from"./generate-api.js";import{FRAMEWORK as s,FRAMEWORKNAME as p,createElement as a,isLibrary as l,isReact as c,isSolid as d}from"./process-env.js";import m from"./reactive-object.js";import{resolveProgramPath as f}from"./utils.js";let u="@app/comment";export const docs=new m;let $={[u]:{}},g=`() => ${a}(SuspenseComp, { comp: $1 })`,b=`import { ${a}${d?",Dynamic":""} } from "${p}${d?"/web":""}";import SuspenseComp from "@app/suspense";`;function h(e,r){let s=e.replace(RegExp(`^${i.alias["@pkg"]}`),""),p=t(s).replace(/^\//,""),l=[u,p].join("/"),m=s.split("/").pop()?.replace(/\.tsx?/,".md");if(!m)return;$[u][p]||($[u][p]={});let f=o(l,m);if("deleted"===r)$[u][p][m]&&delete $[u][p][m];else{let t=n(e);$[f]=t,t?$[u][p][m]=`rr(() => import(/* webpackChunkName: '${f}' */'${f}?raw').then((res) => ({default: ${c?"() =>":""}${a}(${d?"Dynamic":"'n-md'"}, {text: res.default, ${d?"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`:$[u][p][m]&&delete $[u][p][m]}let h={};for(let e in $)if(Object.prototype.hasOwnProperty.call($,e)){let t=$[e];if(e===u)for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(h[e]=Object.values(t[e]));else docs.setData(e,t)}docs.setData("@app/docs",`${b}export default ${JSON.stringify(h).replace(/"rr\((.+?)\)rr"/g,g)}`)}["react","solid"].includes(s)||(g="$1",b=""),l&&function(){let t=[],o=r(f("components"),{ignored:[/(^|\/)\../,/(^|\/)__tests__(\/|$)/],persistent:!0,ignoreInitial:!1});function i(t){return/\.tsx?$/.test(t)&&e(t).isFile()}o.on("add",e=>{i(e)&&(h(e,"added"),t.push(e))}),o.on("change",e=>{i(e)&&h(e,"change")}),o.on("unlink",e=>{i(e)&&(h(e,"deleted"),t.splice(t.indexOf(e),1))}),o.on("ready",()=>{t.forEach(e=>{h(e,"change")})}),process.on("SIGINT",function(){o.close()})}();
|
package/lib/done.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default class{constructor(o){this.options=Object.assign({},o)}apply(o){o.hooks.done.tap("DoneWebpackPlugin",o=>{this.options.done(o)})}}
|
package/lib/esm.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function esm(templateStrings: TemplateStringsArray, ...substitutions: unknown[]): string;
|
package/lib/esm.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function t(t,...e){let r=t.raw[0];for(let a=0;a<e.length;a++)r+=e[a]+t.raw[a+1];return`data:text/javascript;base64,${Buffer.from(r).toString("base64")}`}
|
package/lib/fallback.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{CONFIG as l}from"./config.js";let a="export default null";l.fallbackCompPath&&(a=`import Fallback from "${l.fallbackCompPath}";export default Fallback;`);export default a;
|
package/lib/locales.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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 r from"./esm.js";import{FRAMEWORK as n,isLibrary as s}from"./process-env.js";import c from"./reactive-object.js";import{empty as i,resolveProgramPath as g,tfc as f}from"./utils.js";let p={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;'}[n];function d(e,t){return`${p[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);${u}`}export const localesModuleName="@app/locales";export const locales=new c({[localesModuleName]:d([],{})});let m={};async function z(e,o){let a=t(e).replace(/\.[^.]+$/,"");if("deleted"===o)delete m[a];else{let t=await import(r`${f(e)}`);Object.assign(m,{[a]:t.default})}let l=[],n={};for(let e in m)if(Object.prototype.hasOwnProperty.call(m,e)){let t=m[e],{language:o=a,title:r=o,icon:s,translation:c={}}=t;l.push({language:o,title:r,icon:s}),n[o]={language:o,title:r,icon:s,translation:c}}locales.setData(localesModuleName,d(l,n))}e(o(l.alias["@"],"./locales"))&&function(e,t){let o=[],l=a(e,{ignored:t,persistent:!0,ignoreInitial:!1});l.on("add",e=>{o.push(e),z(e,"added").finally(i)}),l.on("change",e=>{z(e,"change").finally(i)}),l.on("unlink",e=>{o.splice(o.indexOf(e),1),z(e,"deleted").finally(i)}),l.on("ready",()=>{o.forEach(e=>{z(e,"change").finally(i)})}),process.on("SIGINT",function(){l.close()})}(g(s?"site/locales":"src/locales"),[/^\..*/,/!\.ts$/,/\.d\.ts$/]);
|
package/lib/normalize-css.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{CONFIG as e}from"./config.js";let t="";e.normalizeCss&&(t='html,body{margin:0;padding:0;line-height:1.8}input,textarea{caret-color:inherit}h1{margin:0.67em 0;font-size:2em}hr{overflow:visible;block-size:0;box-sizing:content-box}pre{font-size:1em;font-family:monospace}a{text-decoration:none;background-color:transparent;cursor:pointer}abbr[title]{border-block-end:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-size:1em;font-family:monospace}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{inset-block-end:-0.25em}sup{inset-block-start:-0.5em}img{border-style:none}img,button{outline:1px solid transparent}button,input,optgroup,select,textarea{margin:0;font-size:100%;font-family:inherit;line-height:1.15}button,input{overflow:visible}button,select{text-transform:none}button,[type="button"],[type="reset"],[type="submit"]{appearance:button}button::-moz-focus-inner,[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type="button"]:-moz-focusring,[type="reset"]:-moz-focusring,[type="submit"]:-moz-focusring{outline:1px dotted var(--primary-outline)}fieldset{padding:0.35em 0.75em 0.625em}legend{display:table;padding:0;max-inline-size:100%;white-space:normal;color:inherit;box-sizing:border-box}progress{vertical-align:baseline}textarea{overflow:auto}details{display:block}summary{display:list-item}template,[hidden]{display:none}[type="checkbox"],[type="radio"]{box-sizing:border-box;padding:0}[type="number"]::-webkit-inner-spin-button,[type="number"]::-webkit-outer-spin-button{block-size:auto}[type="search"]{appearance:textfield;outline-offset:-2px}[type="search"]::-webkit-search-decoration{appearance:none}::-webkit-file-upload-button{appearance:button;font:inherit}::-webkit-scrollbar{inline-size:5px;block-size:5px}::-webkit-scrollbar-track,::-webkit-scrollbar-thumb{background-color:transparent}:hover::-webkit-scrollbar-thumb{background-color:var(--primary-selection)}::-webkit-scrollbar-thumb:hover{background-color:var(--primary-hover)}::-webkit-scrollbar-thumb:active{background-color:var(--primary-active)}::-webkit-scrollbar-button{display:none}');export default t;
|
package/lib/prefix-router.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{isReact as e}from"./process-env.js";let t="";e&&(t='import { createElement, isValidElement } from "react";import { Outlet } from "react-router-dom";function prefix(e){return e.map(function(e){var n=Object.assign({key:e.path},e);return n.element?isValidElement(n.element)||(n.element=createElement(n.element,n.meta)):n.element=createElement(Outlet,null),Array.isArray(n.children)&&(n.children=prefix(n.children)),n})}export default prefix;');export default t;
|
package/lib/rem.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{CONFIG as e}from"./config.js";let t="";e.rem.designSize&&(t=`!function(e,n){function t(){let n=e.documentElement,t=n.clientWidth||e.body.clientWidth,i=t<=375?375:${e.rem.designSize},o=t;o=t<=375?t:t<=${e.rem.designSize}?i:t;let d=16/i*o+"px";d!==n.style.fontSize&&(n.style.fontSize=d)}t(),"addEventListener"in e&&n.addEventListener("orientationchange"in n?"orientationchange":"resize",t,!1)}(document,window);`);export default t;
|
package/lib/routes.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
let e,t,r;import{accessSync as o,constants as s,readFileSync as n,readdirSync as i,statSync as p}from"fs";import{join as a,relative as l}from"path";import{watch as c}from"chokidar";import{load as m}from"js-yaml";import{CONFIG as u}from"./config.js";import f from"./paths.js";import{FRAMEWORK as d,FRAMEWORKNAME as x,createElement as h,isLibrary as g,isReact as $,isSolid as j}from"./process-env.js";import y from"./reactive-object.js";let N=/^---\n([\s\S]+?)\n---\n/;try{o(`${u.alias["@"]}/router/index.ts`,s.R_OK),e=!0}catch(t){e=!1}let O=j?"component":"element";function T(e){return e.replace(/\$/g,":").replace(/^index\.tsx?$/,"/").replace(/^README\.mdx?$/,"/")}function k(e,t){let{regex:r,alia:o,base:s=e,outputSource:c}=t,u=i(e);return u.reduce((i,u)=>{let f=a(e,u),d=p(f);if(d.isDirectory()){let e=k(f,{...t,base:s});if(e.length>0){let t={},r={path:T(u),key:T(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,!j&&s,{children:[j&&{...s,path:r.path===s.path?"/":s.path},...e].filter(Boolean)}):Object.assign(t,s)}i.push(Object.assign(t,r))}}else if(r.test(f)){let e=n(f,{encoding:"utf-8"}),t=function(e){let t=e.match(N);return t&&t[1]?t[1].trim():null}(e),r=t?m(t):{},p=l(s,f),u=T(p);i.push(Object.assign({path:u.split("/").slice(-2,-1)?.join("")||"/",key:u.replace(/\/?index.tsx?$/,"/").replace(/\/?README.mdx?$/,"/").split("/").filter(Boolean).join("/"),meta:{...r}},o&&{[O]:`rr(() => import(/* webpackChunkName: '${p}' */'${a(o,p)}'))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,s=e.split(" ").pop()||"jsx";r[s]=o.trim()}return Object.keys(r).length?r:{jsx:e}}(e.replace(N,"").replace(/^\n+|\n+$/g,""))}))}return i},[])}export const routesModuleName="@app/routes";export const route=new y({[routesModuleName]:"export default []"});export const exampleModuleName="@app/example";export const examples=new y;let D=`${j?"() => ":""}${h}(SuspenseComp, { comp: $1 })`,E=`import { ${h} } from "${x}";import SuspenseComp from "@app/suspense";${$?'import prefix from "@app/prefix-router";':""}`;e&&(E+='import merge from "@app/merge-router";import customRouter from "@/router";'),["react","solid"].includes(d)||(D="$1",E="");export let routes=[];function M(t){return`${E}const routes = [{ path: "/", children: [${j?'{ path: "/" },':""} ${t}] }];const _routes = ${e?'merge([...routes, ...customRouter], "path")':"routes"};export default ${$?"prefix(_routes)":"_routes"};`}function S(e,t,r){let o=c(e,{ignored:(e,r)=>{if(r)return!r.isDirectory()&&t.test(e)},persistent:!0,ignoreInitial:!1});o.on("add",()=>{r()}).on("change",()=>{r()}).on("unlink",()=>{r()}),process.on("SIGINT",function(){o.close()})}g?(S(f.componentsPath,/(?<!README\.mdx?)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),routes=k(f.componentsPath,{regex:/README\.mdx?$/,alia:"@pkg"}),route.setData(routesModuleName,M(JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,D).slice(1,-1)))},100)}),S(f.componentsPath,/(?<!\/examples\/(.+)\.md)$/,function(){clearTimeout(r),r=setTimeout(()=>{clearTimeout(r),k(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)})):S(f.pagesPath,/(?<!index\.tsx?)$/,function(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),routes=k(f.pagesPath,{regex:/index\.tsx?$/,alia:"@/pages"}),route.setData(routesModuleName,M(JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,D).slice(1,-1)))},100)});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import o from"webpack-virtual-modules";import{docs as t}from"./docs.js";import{locales as e,localesModuleName as s}from"./locales.js";import{isLibrary as i}from"./process-env.js";import{exampleModuleName as p,examples as r,route as a,routesModuleName as l}from"./routes.js";import{resolveNodeModulesPath as n}from"./utils.js";export default class{constructor(o){this.options=o,this.hasTapped=!1}apply(f){let h=new o({[n(l)]:a.getData(l),[n(p)]:"export default []",[n(s)]:e.getData(s)});function c(o,t){h.writeModule(n(o),t||"")}h.apply(f),a.on("change",c),e.on("change",c),i&&(r.on("change",c),t.on("change",c)),f.hooks.compilation.tap("VirtualModulePlugin",()=>{if(!this.hasTapped){for(let o in this.options)if(Object.prototype.hasOwnProperty.call(this.options,o)){let t=this.options[o];c(o,"string"==typeof t?t:`export default ${JSON.stringify(t)}`)}for(let o of r)c(...o);for(let o of t)c(...o);this.hasTapped=!0}})}}
|
package/lib/yarn-argv.d.ts
DELETED
package/lib/yarn-argv.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
let e=JSON.parse(process.env.npm_config_argv||"{}")?.original,a={};e?.forEach(e=>{let r=e.split("=");Object.assign(a,{[r[0]]:r[1]||!0})});export default a;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|