@moneko/core 3.0.0-beta.16 → 3.0.0-beta.19
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/build/common.js +2 -2
- package/build/esm.d.ts +1 -1
- package/build/esm.js +1 -1
- package/build/module-federation.js +1 -1
- package/build/module.config.js +1 -1
- package/build/process-env.d.ts +1 -0
- package/build/process-env.js +1 -1
- package/build/swcrc.js +1 -1
- package/build/tsloader.config.js +1 -1
- package/build/utils.d.ts +7 -1
- package/build/utils.js +1 -1
- package/build/webpack.common.js +1 -1
- package/build/webpack.prod.js +1 -1
- package/lib/index.js +1 -7
- package/lib/normalize.css +3 -3
- package/lib/packages/library/bootstrap.js +1 -0
- package/lib/packages/library/index.d.ts +1 -1
- package/lib/packages/library/index.js +1 -4
- package/lib/refresh-rem.js +1 -49
- package/lib/router/index.js +1 -277
- package/package.json +4 -11
- package/typings/global.d.ts +2 -0
- package/lib/packages/library/bootstrap.jsx +0 -28
package/build/common.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from"fs";import t from"path";import o from"readline";import s from"chalk";import{merge as l}from"webpack-merge";import
|
|
1
|
+
import e from"fs";import t from"path";import o from"readline";import s from"chalk";import{merge as l}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as i,hasReact as r,pkgName as a,PROGRAMPATH as c}from"./process-env.js";import{isFunction as p,readConf as m}from"./utils.js";export const ENTRYPATH={mobile:"mobile",site:"site","back-stage":"back-stage","single-spa":"single-spa",library:"library","single-component":"single-component"};let u=[a,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design"],d={chunks:"all",minSize:1024,minChunks:1};"single-component"===n&&(d=!1);let h={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:{analyzerMode:"static",reportFilename:"report.html",openAnalyzer:!1},entry:{},minifier:{},sourceMap:{filename:"[file].map",publicPath:""},env:{},routeBaseName:"/",publicPath:"/",designSize:"mobile"===n?375:1680,fallbackCompPath:null,modifyVars:{},prefixCls:"n",alias:{},layoutSider:{},moduleRules:[],prefixJsLoader:[],cssModules:[],importOnDemand:{},proxy:[],cacheDirectory:c+"/node_modules/.temp_cache",devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`./node_modules/${a}/template/index.html`,favicon:`./node_modules/${a}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:d,runtimeChunk:"single-component"!==n&&"single",moduleFederation:[],rulesInclude:{less:u,css:u,js:u,media:u,fonts:u},mdx:{jsxImportSource:r?"react":"solid-js/h",remarkPlugins:[],rehypePlugins:[]}};export const log=e=>{o.cursorTo(process.stdout,0),process.stdout.write(e)};let f=h,g=null,y={},w={};try{g=t.join(c,"./config/index.ts"),e.accessSync(g,e.constants.R_OK)}catch(e){g=null}if(g)try{let e=(await m(g,"index")).default;y=p(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}if(i){let o=null;try{o=t.join(c,`./config/${i}.ts`),e.accessSync(o,e.constants.R_OK)}catch(e){o=null}if(null!==o)try{let e=(await m(o,i)).default;w=p(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}}!1===(f=l(f,y,w)).devtool&&(f.sourceMap=!1),!1===f.sourceMap&&(f.devtool=!1),f.fixBrowserRouter&&(f.htmlPluginOption.tags||(f.htmlPluginOption.tags=[]),f.htmlPluginOption.tags.push({textContent:`
|
|
2
2
|
(function(l) {
|
|
3
3
|
if (l.search[1] === '/' ) {
|
|
4
4
|
var decoded = l.search.slice(1).split('&').map(function(s) {
|
|
@@ -9,4 +9,4 @@ import e from"fs";import t from"path";import o from"readline";import s from"chal
|
|
|
9
9
|
);
|
|
10
10
|
}
|
|
11
11
|
}(window.location))
|
|
12
|
-
`}));export const CONFIG=
|
|
12
|
+
`}));export const CONFIG=f;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,log};
|
package/build/esm.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function esm(templateStrings:
|
|
1
|
+
export default function esm(templateStrings: TemplateStringsArray, ...substitutions: unknown[]): string;
|
package/build/esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function t(t,...
|
|
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")}`}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"external-remotes-plugin";import r from"webpack";import
|
|
1
|
+
import e from"external-remotes-plugin";import r from"webpack";import t from"webpack/lib/container/ModuleFederationPlugin.js";import{CONFIG as o}from"./common.js";import{resolve as l}from"./utils.js";let a=r.NormalModuleReplacementPlugin,i={},m={},n={};export const moduleFederation=o.moduleFederation?.map(e=>{if(Array.isArray(e.remotes))for(let r=0,t=e.remotes.length;r<t;r++){let t=e.remotes[r],o=t.alias||t.name,l=t.filename||"remote_entry.js";if(n[o]=`${t.name}@${t.host}/${l}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)i[t.library[e]]=`${o}/${t.library[e]}`}if(Array.isArray(e.exposes))for(let r=0,t=e.exposes.length;r<t;r++){let t=e.exposes[r];"string"==typeof t?m[`./${t}`]=l(t):"[object Object]"===Object.prototype.toString.call(t)&&(m[`./${t.name}`]=l(t.path))}return new t({filename:"remote_entry.js",...e,remotes:n,exposes:m})});moduleFederation.length&&(moduleFederation.push(new e),moduleFederation.push(new a(/(.*)/,e=>{i[e.request]&&(e.request=i[e.request])})));
|
package/build/module.config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import
|
|
1
|
+
import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import{CONFIG as o,PUBLICPATH as t}from"./common.js";import{hasPkg as l}from"./has-pkg.js";import r from"./modifyVars.js";import{APPTYPE as a,DEV as i,pkgName as n}from"./process-env.js";import c from"./swcrc.js";import m from"./tsloader.config.js";import{resolveNodeModulesPath as p,resolveProgramPath as d}from"./utils.js";let u="single-spa"===a?t:"../",f={loader:e.loader,options:{publicPath:"/"!==u?u:"../"}},y=l("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};i&&(f="style-loader");let x=[...o.cssModules,n,"neko-ui"].map(p),g=[p(`${n}/lib/styles/eval/*.less`),...["src/styles/variables/*.less","src/styles/mixins/*.less","site/styles/variables/*.less","site/styles/mixins/*.less"].map(d)],$=["components","example","mock","site","src"].map(d),j=[f,{loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,o=x.length;s<o;s++)if(e&&e?.includes(x[s]))return/(.*(?<!\.global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.global\.(le|c)ss)$)/i.test(e)},localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},y,"css-unicode-loader",{loader:"less-loader",options:{sourceMap:!!o.sourceMap,lessOptions:{modifyVars:r,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:g}}].filter(Boolean),b={loader:"tsc"===o.compiler?"ts-loader":"swc-loader",options:"tsc"===o.compiler?m:c(i)},v={rules:[{oneOf:[{resourceQuery:/raw/,type:"asset/source"},{resourceQuery:/\.wasm$/,type:"webassembly/async"},{test:/\.less$/,use:j,include:$.concat(o.rulesInclude?.less?.map(p)||[])},{test:/\.css$/,use:[f,"css-loader",y,"css-unicode-loader"].filter(Boolean),include:$.concat(o.rulesInclude?.css?.map(p)||[])},{test:/\.(gif|png|jpe?g|ico|mp4)$/i,type:"asset",generator:{filename:"assets/images/[name][ext][query]"},include:$.concat(o.rulesInclude?.media?.map(p)||[])},{test:/\.(eot|ttf|otf|woff(|2))$/,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:$.concat(o.rulesInclude?.fonts?.map(p)||[])},{test:/\.svg$/,type:"asset/inline",generator:{dataUrl:e=>s("string"!=typeof e?e.toString():e)}},{test:/\.txt$/,type:"asset/source"},{test:/\.(cj|mj|t|j)s(|x)$/,use:[...o.prefixJsLoader,b].filter(Boolean),include:$.concat(o.rulesInclude?.js?.map(p)||[])},{test:/\.mdx?$/,use:[...o.prefixJsLoader,b,{loader:"@mdx-js/loader",options:o.mdx}].filter(Boolean),include:$,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...o.moduleRules]};export default v;
|
package/build/process-env.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const APPTYPE: AppType;
|
|
|
4
4
|
export declare const PROGRAMPATH: string;
|
|
5
5
|
export declare const PACKAGENAME: string;
|
|
6
6
|
export declare const PACKAGEVERSION: string;
|
|
7
|
+
export declare const cacheDir: string;
|
|
7
8
|
export declare const pkgName: string;
|
|
8
9
|
export declare const NODE_ENV: string | undefined;
|
|
9
10
|
export declare const CUSTOMCONFIG: string | undefined;
|
package/build/process-env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as e}from"fs";import{join as
|
|
1
|
+
import{readFileSync as e,existsSync as o,mkdirSync as r}from"fs";import{join as t}from"path";import n from"url";import{hasPkg as s}from"./has-pkg.js";import{resolveProgramPath as p}from"./utils.js";import a from"./yarn-argv.js";export const __dirname=n.fileURLToPath(new URL(".",import.meta.url));export const APPTYPE=process.env.APPTYPE;export const PROGRAMPATH=process.cwd();export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;let c=e(t(__dirname,"../package.json"),{encoding:"utf-8"});export const cacheDir=t(PROGRAMPATH,"./node_modules/.cache/@moneko/cli/");o(cacheDir)||r(cacheDir,{recursive:!0});export const pkgName=JSON.parse(c).name;export const NODE_ENV=process.env.NODE_ENV;export const CUSTOMCONFIG=process.env.npm_config_config||a.config;export const DEV="development"===process.env.NODE_ENV;export let hasEslintConfig=!!Object.keys(process.env).filter(e=>e.startsWith("npm_package_eslintConfig_")).length;export let hasStylelintConfig=!!Object.keys(process.env).filter(e=>e.startsWith("npm_package_stylelint_")).length;export const hasReact=s("react");export const hasAntd=s("antd");export const programInfo={name:PACKAGENAME,version:PACKAGEVERSION,type:APPTYPE,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 o=e(p("package.json"),{encoding:"utf-8"}),{description:r,author:t,repository:n,eslintConfig:s,stylelint:a}=JSON.parse(o);programInfo.author="string"==typeof t?{name:t}:t,programInfo.repository="string"==typeof t?{url:n}:n,programInfo.description=r,hasEslintConfig=!!s,hasStylelintConfig=!!a}
|
package/build/swcrc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{merge as e}from"webpack-merge";import{CONFIG as o}from"./common.js";import r from"./envFlags.js";import{hasReact as t}from"./process-env.js";let s={env:{targets:["last 2 version","> 0.5%","ie 11","not dead"],mode:"entry",coreJs:"3"}};export const swcMinifyOption={compress:{top_retain:[],keep_infinity:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],toplevel:!1,drop_console:!0,drop_debugger:!0,module:!1,ecma:2015,ie8:!1,keep_classnames:void 0,keep_fnames:!1},mangle:!0};export default((n=!1)=>{let a={module:{type:"es6",ignoreDynamic:!0,strict:!0,strictMode:!0,lazy:!0,noInterop:!0},jsc:{parser:{syntax:"typescript",decorators:!0,dynamicImport:!0,tsx:!0},loose:!0,target:"es2022",externalHelpers:!0,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,useBuiltins:!0,refresh:n,development:n,importSource:t?"react":"solid-js/h"},constModules:{globals:{"env-flags":r}},optimizer:{simplify:!1}},experimental:{plugins:[["swc-plugin-another-transform-imports",function(e){for(let o=0,r=Object.keys(e),t=r.length;o<t;o++)e[r[o]].transform=`${r[o]}/${e[r[o]].transform}`,e[r[o]].style&&(e[r[o]].style=`${r[o]}/${e[r[o]].style}`);return e}(o.importOnDemand||{})]]}},sourceMaps:!0,parseMap:!0},c=Object.assign(a,!n&&s);return o.swcrc&&(c=e(c,"function"==typeof o.swcrc?o.swcrc(n):o.swcrc)),c});
|
|
1
|
+
import{merge as e}from"webpack-merge";import{CONFIG as o}from"./common.js";import r from"./envFlags.js";import{hasReact as t}from"./process-env.js";let s={env:{targets:["last 2 version","> 0.5%","ie 11","not dead"],mode:"entry",coreJs:"3"}};export const swcMinifyOption={compress:{top_retain:[],keep_infinity:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],toplevel:!1,drop_console:!0,drop_debugger:!0,module:!1,ecma:2015,ie8:!1,keep_classnames:void 0,keep_fnames:!1},mangle:!0};export default((n=!1)=>{let a={module:{type:"es6",ignoreDynamic:!0,strict:!0,strictMode:!0,lazy:!0,noInterop:!0},jsc:{parser:{syntax:"typescript",decorators:!0,dynamicImport:!0,tsx:!0},loose:!0,target:"es2022",externalHelpers:!0,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,useBuiltins:!0,refresh:t&&n,development:n,importSource:t?"react":"solid-js/h"},constModules:{globals:{"env-flags":r}},optimizer:{simplify:!1}},experimental:{plugins:[["swc-plugin-another-transform-imports",function(e){for(let o=0,r=Object.keys(e),t=r.length;o<t;o++)e[r[o]].transform=`${r[o]}/${e[r[o]].transform}`,e[r[o]].style&&(e[r[o]].style=`${r[o]}/${e[r[o]].style}`);return e}(o.importOnDemand||{})]]}},sourceMaps:!0,parseMap:!0},c=Object.assign(a,!n&&s);return o.swcrc&&(c=e(c,"function"==typeof o.swcrc?o.swcrc(n):o.swcrc)),c});
|
package/build/tsloader.config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from"fs";import r from"ts-import-plugin";import o from"webpack-merge";import{CONFIG as e}from"./common.js";import{isFunction as m,resolveProgramPath as s,readConf as a}from"./utils.js";let i=[];Array.isArray(e.importOnDemand)&&Object.assign(i,e.importOnDemand.map(t=>r(t)));let n=[...i],p={transpileOnly:!0,getCustomTransformers:()=>({before:n})};try{let r=s("tsloader.config.ts");t.accessSync(r,t.constants.R_OK);let e=(await a(r,"tsloader.config")).default;p=o(p,m(e)?e(process):e)}catch(t){}export default p;
|
package/build/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function tfc(filepath: string): string;
|
|
2
|
+
export declare function readConf(src: string, name: string): Promise<any>;
|
|
2
3
|
export declare function toUpperCaseString(string: string): string;
|
|
3
4
|
export declare function getIPAdress(): string | undefined | void;
|
|
4
5
|
type ProgramPath<T extends string> = `~/${T extends string ? T : string}`;
|
|
@@ -13,6 +14,11 @@ export declare function resolveProgramPath<T extends string>(src: T): ProgramPat
|
|
|
13
14
|
* @returns {string} 位于项目根目录node_modules下的位置
|
|
14
15
|
*/
|
|
15
16
|
export declare const resolveNodeModulesPath: <T extends string>(src: T) => `~/${`node_modules/${T extends string ? T : string}` extends infer T_1 ? T_1 extends `node_modules/${T extends string ? T : string}` ? T_1 extends string ? T_1 : string : never : never}`;
|
|
17
|
+
/** 获取模块真实入口位置
|
|
18
|
+
* @param {string} url 路径
|
|
19
|
+
* @returns {string} 模块真实入口路径
|
|
20
|
+
*/
|
|
21
|
+
export declare const resolve: (url: string) => string;
|
|
16
22
|
export declare function isObject(target: unknown): target is object;
|
|
17
23
|
export declare function isFunction(target: unknown): target is (...args: unknown[]) => unknown;
|
|
18
24
|
export {};
|
package/build/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{writeFileSync as e}from"fs";import{networkInterfaces as t}from"os";import r from"path";import{transformFileSync as o}from"@swc/core";import{cacheDir as n}from"./process-env.js";import s from"./resolver-sync.js";let c={inputSourceMap:!1,sourceMaps:!1,module:{type:"es6"},jsc:{parser:{syntax:"typescript"},loose:!1}};export function tfc(e){return o(e,c).code||"{}"}export function readConf(t,o){let s=r.join(n,`${o}.mjs`);return e(s,tfc(t),"utf-8"),import(s)}export function toUpperCaseString(e){return e?.replace(/\b\w/g,e=>e.toUpperCase()).replace(/\./g," ")}export function getIPAdress(){let e=t();for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];for(let e=0;e<r.length;e++){let t=r[e];if("IPv4"===t.family&&"127.0.0.1"!==t.address&&!t.address.startsWith("169.254")&&!t.internal)return t.address}}}export function resolveProgramPath(e){return r.resolve(process.cwd(),"./"+e)}export const resolveNodeModulesPath=e=>resolveProgramPath(`node_modules/${e}`);export const resolve=e=>s.resolveSync({},process.cwd(),e)||e;export function isObject(e){let t=typeof e;return null!==e&&("object"==t||"function"==t)}export function isFunction(e){if(!isObject(e))return!1;let t=Object.prototype.toString.call(e);return"[object Function]"==t||"[object AsyncFunction]"==t||"[object GeneratorFunction]"==t||"[object Proxy]"==t}
|
package/build/webpack.common.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"fs";import{join as t}from"path";import s from"add-asset-html-webpack-plugin";import n from"html-webpack-plugin";import o from"webpack";import l from"webpackbar";import{CONFIG as i,ENTRYPATH as a,PUBLICPATH as r}from"./common.js";import p from"./done.js";import m from"./envFlags.js";import c from"./html-add-entry-attr.js";import u from"./html-plugin-option.js";import{moduleFederation as f}from"./module-federation.js";import d from"./module.config.js";import{APPTYPE as g,DEV as j,hasEslintConfig as h,hasStylelintConfig as b,PACKAGENAME as y,PROGRAMPATH as w,__dirname as x}from"./process-env.js";import{seo as k}from"./seo.js";import{resolveProgramPath as v}from"./utils.js";let C=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],O=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],P=e.readdirSync(w),T=!1,$=!1;for(let e=0,t=P.length;e<t;e++)O.includes(P[e])&&($=!0),C.includes(P[e])&&(T=!0);T||(T=h),$||($=b);let A=$?(await import("stylelint-webpack-plugin")).default:null,B=T?(await import("eslint-webpack-plugin")).default:null,S={"@":v("src")};Object.assign(S,i.alias),"library"===g&&Object.assign(S,{"@":v("site"),"@pkg":v("components"),[y]:v("components")});let M=i.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:v("library"===g?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name].[hash][ext]",library:y,libraryTarget:"window",globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${y}`,pathinfo:!1,clean:!0,publicPath:r};let F=t(x,`../lib/packages/${a[g]}/index.js`);"single-component"===g&&(Object.assign(S,{[y]:v("umd")}),F=v(j?"example/index.ts":"src/index.ts"),outputConfig.path=v(j?"dist":"umd"),outputConfig.filename="index.js",outputConfig.library=y,outputConfig.libraryTarget="umd",outputConfig.libraryExport="default");let K={main:F};i.entry&&("string"==typeof i.entry?K=i.entry:Object.keys(i.entry)&&Object.assign(K,i.entry)),i.output&&("string"==typeof i.output?outputConfig.path=i.output:Object.keys(i.output)&&Object.assign(outputConfig,i.output));let L=i.routeBaseName.split("/").filter(Boolean).length,W=Array(L).fill("..").join("/")+(L?"/":"")+"404.html",{pathSegmentsToKeep:D=L,path:R=W}=i.fixBrowserRouter||{},_={entry:K,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",plugins:[new o.AutomaticPrefetchPlugin,...f,B&&new B({threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),A&&new A({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),new n(u),i.fixBrowserRouter&&new n({filename:R,inject:!1,templateContent:()=>`<html html><head><title>${u.title}</title><script>var pathSegmentsToKeep = ${D||L};var l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new s(M),"single-spa"===g&&new c(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new o.DefinePlugin(m),new o.WatchIgnorePlugin({paths:[/\.d\.ts$/]}),i.sourceMap&&new o.SourceMapDevToolPlugin(i.sourceMap),new l({name:"编译中",color:"#6f42c1"}),new p({done:()=>{!j&&i.seo&&k(),i.done?.()}}),...i.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:S,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:d,externals:i.externals,output:outputConfig};export default _;
|
|
1
|
+
import e from"fs";import{join as t}from"path";import s from"add-asset-html-webpack-plugin";import n from"html-webpack-plugin";import o from"webpack";import l from"webpackbar";import{CONFIG as i,ENTRYPATH as a,PUBLICPATH as r}from"./common.js";import p from"./done.js";import m from"./envFlags.js";import c from"./html-add-entry-attr.js";import u from"./html-plugin-option.js";import{moduleFederation as f}from"./module-federation.js";import d from"./module.config.js";import{APPTYPE as g,DEV as j,hasEslintConfig as h,hasStylelintConfig as b,PACKAGENAME as y,PROGRAMPATH as w,__dirname as x}from"./process-env.js";import{seo as k}from"./seo.js";import{resolveProgramPath as v}from"./utils.js";let C=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],O=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],P=e.readdirSync(w),T=!1,$=!1;for(let e=0,t=P.length;e<t;e++)O.includes(P[e])&&($=!0),C.includes(P[e])&&(T=!0);T||(T=h),$||($=b);let A=$?(await import("stylelint-webpack-plugin")).default:null,B=T?(await import("eslint-webpack-plugin")).default:null,S={"@":v("src")};Object.assign(S,i.alias),"library"===g&&Object.assign(S,{"@":v("site"),"@pkg":v("components"),[y]:v("components")});let M=i.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:v("library"===g?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name].[hash][ext]",library:y,libraryTarget:"window",globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${y}`,pathinfo:!1,clean:!0,publicPath:r};let F=t(x,`../lib/packages/${a[g]}/index.js`);"single-component"===g&&(Object.assign(S,{[y]:v("umd")}),F=v(j?"example/index.ts":"src/index.ts"),outputConfig.path=v(j?"dist":"umd"),outputConfig.filename="index.js",outputConfig.library=y,outputConfig.libraryTarget="umd",outputConfig.libraryExport="default");let K={main:F};i.entry&&("string"==typeof i.entry?K=i.entry:Object.keys(i.entry)&&Object.assign(K,i.entry)),i.output&&("string"==typeof i.output?outputConfig.path=i.output:Object.keys(i.output)&&Object.assign(outputConfig,i.output));let L=i.routeBaseName.split("/").filter(Boolean).length,W=Array(L).fill("..").join("/")+(L?"/":"")+"404.html",{pathSegmentsToKeep:D=L,path:R=W}=i.fixBrowserRouter||{},_={entry:K,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",plugins:[new o.AutomaticPrefetchPlugin,...f,B&&new B({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),A&&new A({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),new n(u),i.fixBrowserRouter&&new n({filename:R,inject:!1,templateContent:()=>`<html html><head><title>${u.title}</title><script>var pathSegmentsToKeep = ${D||L};var l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}),new s(M),"single-spa"===g&&new c(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new o.DefinePlugin(m),new o.WatchIgnorePlugin({paths:[/\.d\.ts$/]}),i.sourceMap&&new o.SourceMapDevToolPlugin(i.sourceMap),new l({name:"编译中",color:"#6f42c1"}),new p({done:()=>{!j&&i.seo&&k(),i.done?.()}}),...i.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:S,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:d,externals:i.externals,output:outputConfig};export default _;
|
package/build/webpack.prod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e
|
|
1
|
+
import e from"css-minimizer-webpack-plugin";import i from"mini-css-extract-plugin";import n from"terser-webpack-plugin";import m from"webpack";import{BundleAnalyzerPlugin as o}from"webpack-bundle-analyzer";import{merge as r}from"webpack-merge";import{CONFIG as s}from"./common.js";import{getMinifyOption as t}from"./minify.js";import c from"./webpack.common.js";let{cssnanoMinify:l,swcMinify:p}=e,a="swc"===s.compiler?"swc":"terser",u="swc"===s.compiler?"swc":"cssnano",d={splitChunks:s.splitChunk,runtimeChunk:s.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:[new n(t(s.minifier.js?.type||a,s.minifier.js?.options)),new e({minify:{swc:p,cssnano:l}[s.minifier.css?.type||u],minimizerOptions:s.minifier.css?.options})]},f=!1;s.cacheDirectory&&(f={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.cacheDirectory});export default r(c,{devtool:!1===s.devtool||s.devtool?s.devtool:"cheap-module-source-map",mode:"production",cache:f,optimization:d,plugins:[new i({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),s.bundleAnalyzer&&new o(s.bundleAnalyzer),s.splitChunk&&new m.optimize.MinChunkSizePlugin({minChunkSize:1e4})].filter(Boolean)});
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const projectBasicInfo = {
|
|
3
|
-
projectName: projectName,
|
|
4
|
-
providerConfig: providerConfig,
|
|
5
|
-
programInfo: programInfo,
|
|
6
|
-
coverage: projectCoverage,
|
|
7
|
-
};
|
|
1
|
+
export var projectBasicInfo={projectName:projectName,providerConfig:providerConfig,programInfo:programInfo,coverage:projectCoverage};
|
package/lib/normalize.css
CHANGED
|
@@ -5,15 +5,15 @@ body {
|
|
|
5
5
|
margin: 0;
|
|
6
6
|
padding: 0;
|
|
7
7
|
inline-size: 100vi;
|
|
8
|
-
font-size:
|
|
8
|
+
font-size: 14px;
|
|
9
9
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
|
|
10
10
|
Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
|
|
11
11
|
'Noto Color Emoji', Helvetica, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans';
|
|
12
12
|
color: var(--text-color, rgb(0 0 0 / 65%));
|
|
13
13
|
line-height: 1.8;
|
|
14
|
-
transition-duration:
|
|
14
|
+
transition-duration: 0.3s;
|
|
15
15
|
transition-property: background-color, color;
|
|
16
|
-
transition-timing-function:
|
|
16
|
+
transition-timing-function: cubic-bezier(0.94, -0.1, 0.1, 1.2);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
#root {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Router as o}from"@solidjs/router";import{render as n,createComponent as t}from"solid-js/web";import r from"@/index";function e(o){return["[object Function]","[object AsyncFunction]","[object GeneratorFunction]","[object Proxy]"].includes(Object.prototype.toString.call(o))}var i=APPENTRY?await import(APPENTRY):null,u=document.getElementById("root");i&&e(i.bootstrap)&&i.bootstrap(),window.rootInstance={unmount:function(){return null},render:function(){window.rootInstance.unmount=n(function(){return t(o,{children:t(r,{})})},u)}},window.rootInstance.render(),i&&e(i.mount)&&i.mount();
|
package/lib/refresh-rem.js
CHANGED
|
@@ -1,49 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
(function (doc, win) {
|
|
3
|
-
function refreshRem() {
|
|
4
|
-
const docEl = doc.documentElement;
|
|
5
|
-
const clientWidth = docEl.clientWidth || doc.body.clientWidth;
|
|
6
|
-
const _designSize = clientWidth <= 375 ? 375 : programInfo.designSize;
|
|
7
|
-
let unitSize = clientWidth;
|
|
8
|
-
if (clientWidth <= 375) {
|
|
9
|
-
unitSize = clientWidth;
|
|
10
|
-
}
|
|
11
|
-
else if (clientWidth <= programInfo.designSize) {
|
|
12
|
-
unitSize = _designSize;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
unitSize = clientWidth;
|
|
16
|
-
}
|
|
17
|
-
// 窗口大于设计尺寸的时候,使用窗口大小
|
|
18
|
-
// const unitSize = clientWidth > designSize ? designSize : clientWidth;
|
|
19
|
-
// const rootSize = (16 / designSize) * unitSize + 'px';
|
|
20
|
-
// 保持设计比例
|
|
21
|
-
const rootSize = (16 / _designSize) * unitSize + 'px';
|
|
22
|
-
if (rootSize !== docEl.style.fontSize) {
|
|
23
|
-
docEl.style.fontSize = rootSize;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
refreshRem();
|
|
27
|
-
if ('addEventListener' in doc) {
|
|
28
|
-
const resizeEvt = 'orientationchange' in win ? 'orientationchange' : 'resize';
|
|
29
|
-
win.addEventListener(resizeEvt, refreshRem, false);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* 判断 window 及元素节点对象下是否存在 scrollTo 属性,
|
|
33
|
-
* 不存在则自定义,这样就可以解决 IE 下不兼容 scrollTo 的问题
|
|
34
|
-
*/
|
|
35
|
-
if (!window.scrollTo) {
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
window.scrollTo = function (option) {
|
|
38
|
-
window.scrollLeft = option.left;
|
|
39
|
-
window.scrollTop = option.top;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (!document.body.scrollTo) {
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
-
Element.prototype.scrollTo = function (option) {
|
|
45
|
-
this.scrollLeft = option.left;
|
|
46
|
-
this.scrollTop = option.top;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
})(document, window);
|
|
1
|
+
!function(o,n){var t=function(){var n=o.documentElement,t=n.clientWidth||o.body.clientWidth,e=t<=375?375:programInfo.designSize,i=t;i=t<=375?t:t<=programInfo.designSize?e:t;var l=16/e*i+"px";l!==n.style.fontSize&&(n.style.fontSize=l)};t(),"addEventListener"in o&&n.addEventListener("orientationchange"in n?"orientationchange":"resize",t,!1),window.scrollTo||(window.scrollTo=function(o){window.scrollLeft=o.left,window.scrollTop=o.top}),document.body.scrollTo||(Element.prototype.scrollTo=function(o){this.scrollLeft=o.left,this.scrollTop=o.top})}(document,window);
|
package/lib/router/index.js
CHANGED
|
@@ -1,277 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export function lazyImport(filePath) {
|
|
3
|
-
return new Promise(function (resolve) {
|
|
4
|
-
return import(
|
|
5
|
-
/* webpackChunkName: "[request]" */
|
|
6
|
-
'@/pages/' + filePath.replace(/:/g, '$').replace(/^\//, ''))
|
|
7
|
-
.then(resolve)
|
|
8
|
-
.catch(function () {
|
|
9
|
-
return Promise.resolve({
|
|
10
|
-
default: null,
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
export const myPkgs = [];
|
|
16
|
-
export const myDemoKv = {};
|
|
17
|
-
export const mdxComponents = {};
|
|
18
|
-
// function heading(p: Any, level: number) {
|
|
19
|
-
// return createElement(`h${level}`, {
|
|
20
|
-
// 'data-prefix': '# ',
|
|
21
|
-
// role: 'heading',
|
|
22
|
-
// 'aria-level': level,
|
|
23
|
-
// ...p,
|
|
24
|
-
// });
|
|
25
|
-
// }
|
|
26
|
-
// function pre(p: Any) {
|
|
27
|
-
// const c = createElement('code', p);
|
|
28
|
-
// if (p.className) {
|
|
29
|
-
// return createElement(
|
|
30
|
-
// mdxComponents.CodeBlock || 'pre',
|
|
31
|
-
// { lang: p.className.replace('language-', '').replace(/ .*$/, '') },
|
|
32
|
-
// c
|
|
33
|
-
// );
|
|
34
|
-
// }
|
|
35
|
-
// return c;
|
|
36
|
-
// }
|
|
37
|
-
if (APPTYPE === 'library') {
|
|
38
|
-
const models = import.meta.webpackContext?.('@pkg/', {
|
|
39
|
-
recursive: true,
|
|
40
|
-
regExp: /README\.mdx?$/,
|
|
41
|
-
mode: 'sync',
|
|
42
|
-
});
|
|
43
|
-
let overrideComps = {};
|
|
44
|
-
try {
|
|
45
|
-
overrideComps = (await import('@/components/components')).default;
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
/* empty */
|
|
49
|
-
}
|
|
50
|
-
Object.assign(mdxComponents, {
|
|
51
|
-
// h1: function (p: Any) {
|
|
52
|
-
// return heading(p, 1);
|
|
53
|
-
// },
|
|
54
|
-
// h2: function (p: Any) {
|
|
55
|
-
// return heading(p, 2);
|
|
56
|
-
// },
|
|
57
|
-
// h3: function (p: Any) {
|
|
58
|
-
// return heading(p, 3);
|
|
59
|
-
// },
|
|
60
|
-
// h4: function (p: Any) {
|
|
61
|
-
// return heading(p, 4);
|
|
62
|
-
// },
|
|
63
|
-
// h5: function (p: Any) {
|
|
64
|
-
// return heading(p, 5);
|
|
65
|
-
// },
|
|
66
|
-
// h6: function (p: Any) {
|
|
67
|
-
// return heading(p, 6);
|
|
68
|
-
// },
|
|
69
|
-
// pre: pre,
|
|
70
|
-
...overrideComps,
|
|
71
|
-
});
|
|
72
|
-
models?.keys()?.forEach(function (item) {
|
|
73
|
-
const key = item.substring(2).split('/').slice(0, -1).join('/');
|
|
74
|
-
const { basic, default: Child } = models(item);
|
|
75
|
-
myPkgs.push({
|
|
76
|
-
key: key,
|
|
77
|
-
path: key,
|
|
78
|
-
element: Child,
|
|
79
|
-
...basic,
|
|
80
|
-
props: {
|
|
81
|
-
components: mdxComponents,
|
|
82
|
-
path: key,
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
const allDemo = import.meta.webpackContext?.('@pkg/', {
|
|
87
|
-
recursive: true,
|
|
88
|
-
regExp: /\/examples\/(.+)\.mdx$/,
|
|
89
|
-
mode: 'sync',
|
|
90
|
-
});
|
|
91
|
-
allDemo?.keys()?.forEach(function (e) {
|
|
92
|
-
const k = e.substring(2), arr = k.split('/'), name = arr[0];
|
|
93
|
-
if (!Array.isArray(myDemoKv[name])) {
|
|
94
|
-
myDemoKv[name] = [];
|
|
95
|
-
}
|
|
96
|
-
const exampleStr = allDemo(e);
|
|
97
|
-
const m = exampleStr.matchAll(/```([^\r\n]+)?\r?\n([\s\S]*?)\r?\n```/g);
|
|
98
|
-
let code = '', language = '';
|
|
99
|
-
let description = null;
|
|
100
|
-
for (const match of m) {
|
|
101
|
-
language = match[1] || 'tsx';
|
|
102
|
-
code = match[2];
|
|
103
|
-
description = exampleStr.replace(match[0], '');
|
|
104
|
-
}
|
|
105
|
-
myDemoKv[name].push({
|
|
106
|
-
language: language,
|
|
107
|
-
code: code,
|
|
108
|
-
description: description,
|
|
109
|
-
title: arr.pop()?.replace(/\.mdx$/, ''),
|
|
110
|
-
noInline: /render\([^\\)]*\);?(?=\s*$)/.test(code),
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
let list = [];
|
|
115
|
-
try {
|
|
116
|
-
list = (await import('@/router')).default;
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
// eslint-disable-next-line no-console
|
|
120
|
-
console.info('自定义路由请在 router 目录下新建 index.ts, 类型: RouterProps[]', error);
|
|
121
|
-
}
|
|
122
|
-
function prefixKey(path, prev) {
|
|
123
|
-
// eslint-disable-next-line no-undefined
|
|
124
|
-
return [prev === '*' && path !== '*' ? undefined : prev, path].filter(Boolean).join('/');
|
|
125
|
-
}
|
|
126
|
-
const models = import.meta.webpackContext?.('@/pages/', {
|
|
127
|
-
recursive: true,
|
|
128
|
-
regExp: /\.(t|j)sx$/,
|
|
129
|
-
mode: 'lazy',
|
|
130
|
-
});
|
|
131
|
-
function pathToTree(input) {
|
|
132
|
-
const root = [];
|
|
133
|
-
for (let i = 0; i < input.length; i++) {
|
|
134
|
-
const chain = input[i].split('/').slice(0, -1);
|
|
135
|
-
let curr = root;
|
|
136
|
-
for (let j = 0; j < chain.length; j++) {
|
|
137
|
-
let pathRule = chain[j];
|
|
138
|
-
if (pathRule === '') {
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
if (pathRule === '.') {
|
|
142
|
-
pathRule = '*';
|
|
143
|
-
}
|
|
144
|
-
const lastHierarchy = curr;
|
|
145
|
-
// 遍历root是否已有该层级
|
|
146
|
-
if (Array.isArray(curr)) {
|
|
147
|
-
for (let k = 0; k < curr.length; k++) {
|
|
148
|
-
if (curr[k].path === pathRule) {
|
|
149
|
-
curr = curr[k].children;
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (lastHierarchy === curr) {
|
|
155
|
-
let key = j === chain.length - 1 ? input[i] : chain.slice(0, j + 1).join('/') + '/';
|
|
156
|
-
// 截取最后一个 / 前面的数据
|
|
157
|
-
key = key.substring(2, key.lastIndexOf('/'));
|
|
158
|
-
const node = {
|
|
159
|
-
key: key,
|
|
160
|
-
path: pathRule,
|
|
161
|
-
i18n: 'route-' + key,
|
|
162
|
-
children: [],
|
|
163
|
-
alive: false,
|
|
164
|
-
element: lazyImport(key),
|
|
165
|
-
hideMenu: key.includes(':'),
|
|
166
|
-
props: { path: key },
|
|
167
|
-
};
|
|
168
|
-
// 文件,最后一个字符不是"/“符号
|
|
169
|
-
// if (j === chain.length - 1) delete node.children;
|
|
170
|
-
if (Array.isArray(curr)) {
|
|
171
|
-
curr.push(node);
|
|
172
|
-
}
|
|
173
|
-
curr = node.children;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return root;
|
|
178
|
-
}
|
|
179
|
-
const routers = pathToTree(models?.keys().map(function (item) {
|
|
180
|
-
return item.replace(/\$/g, ':');
|
|
181
|
-
}) || []);
|
|
182
|
-
function merge(source, child, prev) {
|
|
183
|
-
const _ = source.find(function (item) {
|
|
184
|
-
return item.path === child.path;
|
|
185
|
-
});
|
|
186
|
-
if (!_) {
|
|
187
|
-
source.push(child);
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
// 处理key
|
|
191
|
-
_.key = prefixKey(_.path, prev);
|
|
192
|
-
if (typeof _.i18n === 'undefined') {
|
|
193
|
-
_.i18n = 'route-' + _.key;
|
|
194
|
-
}
|
|
195
|
-
if (typeof _.alive === 'undefined') {
|
|
196
|
-
_.alive = false;
|
|
197
|
-
}
|
|
198
|
-
if (typeof _.element === 'undefined' && child.element) {
|
|
199
|
-
_.element = child.element;
|
|
200
|
-
_.props = child.props;
|
|
201
|
-
}
|
|
202
|
-
if (typeof _.hideMenu === 'undefined') {
|
|
203
|
-
_.hideMenu = _.path === '*' ? true : _.key.includes(':');
|
|
204
|
-
}
|
|
205
|
-
Object.assign(_, {
|
|
206
|
-
...child,
|
|
207
|
-
..._,
|
|
208
|
-
});
|
|
209
|
-
if (child.children) {
|
|
210
|
-
if (!_.children && Array.isArray(child.children)) {
|
|
211
|
-
_.children = child.children;
|
|
212
|
-
}
|
|
213
|
-
child.children?.forEach(function (childData) {
|
|
214
|
-
merge(_?.children, childData, _?.key);
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
function findLogin(rs = [], onlyLogin, prevKey) {
|
|
220
|
-
return rs
|
|
221
|
-
.map(function (e) {
|
|
222
|
-
const _ = { ...e };
|
|
223
|
-
if (typeof _.key === 'undefined') {
|
|
224
|
-
_.key = prefixKey(e.path, prevKey);
|
|
225
|
-
}
|
|
226
|
-
if (typeof _.i18n === 'undefined') {
|
|
227
|
-
_.i18n = 'route-' + _.key;
|
|
228
|
-
}
|
|
229
|
-
if (typeof _.alive === 'undefined') {
|
|
230
|
-
_.alive = false;
|
|
231
|
-
}
|
|
232
|
-
if (_.path === '*' && typeof _.hideMenu === 'undefined') {
|
|
233
|
-
_.hideMenu = true;
|
|
234
|
-
}
|
|
235
|
-
if (Array.isArray(_.children)) {
|
|
236
|
-
// eslint-disable-next-line no-undefined
|
|
237
|
-
_.children = _.children.length ? findLogin(_.children, onlyLogin, _.key) : undefined;
|
|
238
|
-
}
|
|
239
|
-
if (!_.element) {
|
|
240
|
-
_.element = lazyImport(_.key);
|
|
241
|
-
_.props = { path: _.key };
|
|
242
|
-
}
|
|
243
|
-
return !!_.onlyLogin === onlyLogin && !_.root ? null : _;
|
|
244
|
-
})
|
|
245
|
-
.filter(Boolean);
|
|
246
|
-
}
|
|
247
|
-
const _router = [...list];
|
|
248
|
-
for (let i = 0, len = routers.length; i < len; i++) {
|
|
249
|
-
merge(_router, routers[i]);
|
|
250
|
-
}
|
|
251
|
-
/* 登录前注册的路由 */
|
|
252
|
-
export const onlyLoginRouter = findLogin(_router, false);
|
|
253
|
-
/* 登录后注册的路由 */
|
|
254
|
-
export const router = findLogin(_router, true);
|
|
255
|
-
export function matchUtil(pathname) {
|
|
256
|
-
let p = { key: '' };
|
|
257
|
-
function findPath(rs) {
|
|
258
|
-
for (let i = 0, len = rs.length; i < len; i++) {
|
|
259
|
-
if (rs[i].path && rs[i].path !== '*' && rs[i].key) {
|
|
260
|
-
try {
|
|
261
|
-
if (pathToRegexp(rs[i].key).exec(pathname.substring(1))) {
|
|
262
|
-
p = rs[i];
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
catch (error) {
|
|
267
|
-
/* empty */
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
if (Array.isArray(rs[i].children)) {
|
|
271
|
-
findPath(rs[i].children);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
findPath(router);
|
|
276
|
-
return p;
|
|
277
|
-
}
|
|
1
|
+
function e(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function r(){return(r=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}import{pathToRegexp as t}from"path-to-regexp";export function lazyImport(e){return new Promise(function(r){return import("@/pages/"+e.replace(/:/g,"$").replace(/^\//,"")).then(r).catch(function(){return Promise.resolve({default:null})})})}export var myPkgs=[];export var myDemoKv={};export var mdxComponents={};if("library"===APPTYPE&&import.meta.webpackContext){var n,o=import.meta.webpackContext("@pkg/",{recursive:!0,regExp:/README\.mdx?$/,mode:"sync"}),i={};try{i=(await import("@/components/components")).default}catch(e){}Object.assign(mdxComponents,r({},i)),null==(n=null==o?void 0:o.keys())||n.forEach(function(e){var t=e.substring(2).split("/").slice(0,-1).join("/"),n=o(e),i=n.basic,a=n.default;myPkgs.push(r({key:t,path:t,element:a},i,{props:{components:mdxComponents,path:t}}))});var a=import.meta.webpackContext("@pkg/",{recursive:!0,regExp:/\/examples\/(.+)\.mdx$/,mode:"sync"});a.keys().forEach(function(r){var t=r.substring(2).split("/"),n=t[0];Array.isArray(myDemoKv[n])||(myDemoKv[n]=[]);for(var o,i,l=a(r),c=l.matchAll(/```([^\r\n]+)?\r?\n([\s\S]*?)\r?\n```/g),p="",u="",s=null,m=function(r,t){var n="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(n)return(n=n.call(r)).next.bind(n);if(Array.isArray(r)||(n=function(r,t){if(r){if("string"==typeof r)return e(r,t);var n=Object.prototype.toString.call(r).slice(8,-1);if("Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e(r,t)}}(r))){n&&(r=n);var o=0;return function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(c);!(i=m()).done;){var d=i.value;u=d[1]||"tsx",p=d[2],s=l.replace(d[0],"")}myDemoKv[n].push({language:u,code:p,description:s,title:null==(o=t.pop())?void 0:o.replace(/\.mdx$/,""),noInline:/render\([^\\)]*\);?(?=\s*$)/.test(p)})})}var l=[];try{l=(await import("@/router")).default}catch(e){console.info("自定义路由请在 router 目录下新建 index.ts, 类型: RouterProps[]",e)}function c(e,r){return["*"===r&&"*"!==e?void 0:r,e].filter(Boolean).join("/")}var p=[];import.meta.webpackContext&&(p=import.meta.webpackContext("@/pages/",{recursive:!0,regExp:/\.(t|j)sx$/,mode:"lazy"}));var u=function(e){for(var r=[],t=0;t<e.length;t++)for(var n=e[t].split("/").slice(0,-1),o=r,i=0;i<n.length;i++){var a=n[i];if(""!==a){"."===a&&(a="*");var l=o;if(Array.isArray(o)){for(var c=0;c<o.length;c++)if(o[c].path===a){o=o[c].children;break}}if(l===o){var p=i===n.length-1?e[t]:n.slice(0,i+1).join("/")+"/",u={key:p=p.substring(2,p.lastIndexOf("/")),path:a,i18n:"route-"+p,children:[],alive:!1,element:lazyImport(p),hideMenu:p.includes(":"),props:{path:p}};Array.isArray(o)&&o.push(u),o=u.children}}}return r}(p.keys().map(function(e){return e.replace(/\$/g,":")}));function s(e,t,n){return void 0===e&&(e=[]),e.map(function(e){var o=r({},e);return void 0===o.key&&(o.key=c(e.path,n)),void 0===o.i18n&&(o.i18n="route-"+o.key),void 0===o.alive&&(o.alive=!1),"*"===o.path&&void 0===o.hideMenu&&(o.hideMenu=!0),Array.isArray(o.children)&&(o.children=o.children.length?s(o.children,t,o.key):void 0),o.element||(o.element=lazyImport(o.key),o.props={path:o.key}),!!o.onlyLogin!==t||o.root?o:null}).filter(Boolean)}for(var m=[].concat(l),d=0,h=u.length;d<h;d++)!function e(t,n,o){var i,a=t.find(function(e){return e.path===n.path});a?(a.key=c(a.path,o),void 0===a.i18n&&(a.i18n="route-"+a.key),void 0===a.alive&&(a.alive=!1),void 0===a.element&&n.element&&(a.element=n.element,a.props=n.props),void 0===a.hideMenu&&(a.hideMenu="*"===a.path||a.key.includes(":")),Object.assign(a,r({},n,a)),n.children&&(!a.children&&Array.isArray(n.children)&&(a.children=n.children),null==(i=n.children)||i.forEach(function(r){e(null==a?void 0:a.children,r,null==a?void 0:a.key)}))):t.push(n)}(m,u[d]);export var onlyLoginRouter=s(m,!1);export var router=s(m,!0);export function matchUtil(e){var r={key:""};return!function n(o){for(var i=0,a=o.length;i<a;i++){if(o[i].path&&"*"!==o[i].path&&o[i].key)try{if(t(o[i].key).exec(e.substring(1))){r=o[i];return}}catch(e){}Array.isArray(o[i].children)&&n(o[i].children)}}(router),r}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.19",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "npm run build-conf && npm run build:types",
|
|
8
|
+
"build": "npm run build-conf && npm run build-src && npm run build:types",
|
|
9
9
|
"build-conf": "swc config -d build -C module.type=nodenext -C jsc.target=esnext -C jsc.loose=true -C jsc.minify.mangle=true -C jsc.minify.compress=true -C minify=true -D",
|
|
10
|
-
"build-src": "swc src -d lib
|
|
10
|
+
"build-src": "swc src -d lib -C module.type=es6 -C jsc.loose=true -C jsc.minify.mangle=true -C jsc.minify.compress=true -C minify=true -D",
|
|
11
11
|
"build:types": "tsc && tsc --project cli.json",
|
|
12
12
|
"postbuild": "node ./copy.js ./prefix ./lib",
|
|
13
13
|
"prebuild": "rm -rf ./build && rm -rf ./lib"
|
|
@@ -17,9 +17,8 @@
|
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@emotion/css": "11.11.0",
|
|
20
|
-
"@mapbox/rehype-prism": "0.8.0",
|
|
21
20
|
"@mdx-js/loader": "2.3.0",
|
|
22
|
-
"@pmmmwh/react-refresh-webpack-plugin": "
|
|
21
|
+
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
|
|
23
22
|
"@soda/friendly-errors-webpack-plugin": "1.8.1",
|
|
24
23
|
"@swc/core": "1.3.56",
|
|
25
24
|
"@swc/css": "0.0.20",
|
|
@@ -38,12 +37,6 @@
|
|
|
38
37
|
"mini-svg-data-uri": "1.4.4",
|
|
39
38
|
"path-to-regexp": "6.2.1",
|
|
40
39
|
"portfinder": "1.0.32",
|
|
41
|
-
"rehype-accessible-emojis": "0.3.2",
|
|
42
|
-
"rehype-figure": "1.0.1",
|
|
43
|
-
"remark-frontmatter": "^4.0.1",
|
|
44
|
-
"remark-gfm": "^3.0.1",
|
|
45
|
-
"remark-mdx-frontmatter": "^3.0.0",
|
|
46
|
-
"remark-toc": "^8.0.1",
|
|
47
40
|
"style-loader": "3.3.2",
|
|
48
41
|
"style-resources-loader": "1.5.0",
|
|
49
42
|
"swc-loader": "0.2.3",
|
package/typings/global.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Options as AssetHtmlOptions } from 'add-asset-html-webpack-plugin';
|
|
3
3
|
import { Options as HtmlWebpackPluginOptions } from 'html-webpack-plugin';
|
|
4
4
|
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
|
5
|
+
import type { Options as MDXOptions } from '@mdx-js/loader';
|
|
5
6
|
import type { JsMinifyOptions, Config as SwcConfig } from '@swc/core';
|
|
6
7
|
import type { CssNanoOptionsExtended } from 'css-minimizer-webpack-plugin';
|
|
7
8
|
import type { MinifyOptions } from 'terser';
|
|
@@ -255,6 +256,7 @@ export declare type ConfigType<T = 'tsc'> = {
|
|
|
255
256
|
| false;
|
|
256
257
|
/** 📦 打包完成 */
|
|
257
258
|
done?: () => void;
|
|
259
|
+
mdx?: MDXOptions;
|
|
258
260
|
};
|
|
259
261
|
export declare interface ModuleFederationOption {
|
|
260
262
|
/** 模块名称,唯一性,不能重名 */
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Router } from '@solidjs/router';
|
|
2
|
-
import { render } from 'solid-js/web';
|
|
3
|
-
import App from '@/index';
|
|
4
|
-
function isFunction(target) {
|
|
5
|
-
return [
|
|
6
|
-
'[object Function]',
|
|
7
|
-
'[object AsyncFunction]',
|
|
8
|
-
'[object GeneratorFunction]',
|
|
9
|
-
'[object Proxy]',
|
|
10
|
-
].includes(Object.prototype.toString.call(target));
|
|
11
|
-
}
|
|
12
|
-
const appEntry = APPENTRY ? await import(APPENTRY) : null;
|
|
13
|
-
const container = document.getElementById('root');
|
|
14
|
-
if (appEntry && isFunction(appEntry.bootstrap)) {
|
|
15
|
-
appEntry.bootstrap();
|
|
16
|
-
}
|
|
17
|
-
window.rootInstance = {
|
|
18
|
-
unmount: () => null,
|
|
19
|
-
render() {
|
|
20
|
-
window.rootInstance.unmount = render(() => (<Router>
|
|
21
|
-
<App />
|
|
22
|
-
</Router>), container);
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
window.rootInstance.render();
|
|
26
|
-
if (appEntry && isFunction(appEntry.mount)) {
|
|
27
|
-
appEntry.mount();
|
|
28
|
-
}
|