@moneko/core 3.0.0-beta.9 → 3.0.0-beta.91
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/app.d.ts +31 -0
- package/lib/app.js +1 -0
- package/lib/cleanup.js +1 -0
- package/{build → lib}/common.d.ts +1 -1
- package/lib/common.js +12 -0
- package/{build → lib}/coverage.d.ts +1 -1
- package/{build → lib}/coverage.js +1 -1
- package/lib/define.d.ts +4 -0
- package/lib/define.js +1 -0
- package/lib/docs.d.ts +1 -0
- package/lib/docs.js +1 -0
- package/{build → lib}/done.d.ts +2 -7
- package/lib/done.js +1 -0
- package/lib/esm.d.ts +1 -0
- package/lib/esm.js +1 -0
- package/lib/generate-api.d.ts +1 -0
- package/lib/generate-api.js +1 -0
- package/lib/html-add-entry-attr.js +1 -0
- package/{build → lib}/html-plugin-option.d.ts +1 -1
- package/lib/html-plugin-option.js +1 -0
- package/lib/index.d.ts +3 -36
- package/lib/index.js +1 -1
- package/lib/loader/frontmatter.cjs +6 -0
- package/lib/modifyVars.js +1 -0
- package/lib/module-federation.js +1 -0
- package/lib/module.config.js +1 -0
- package/lib/net.d.ts +3 -0
- package/lib/net.js +1 -0
- package/lib/object-listener.d.ts +4 -0
- package/lib/object-listener.js +1 -0
- package/{build → lib}/process-env.d.ts +7 -3
- package/lib/process-env.js +1 -0
- package/lib/routes.d.ts +11 -0
- package/lib/routes.js +1 -0
- package/lib/seo.js +1 -0
- package/{build → lib}/swcrc.d.ts +1 -1
- package/lib/swcrc.js +1 -0
- package/{build → lib}/tsloader.config.d.ts +1 -1
- package/lib/tsloader.config.js +1 -0
- package/{build → lib}/utils.d.ts +9 -4
- package/lib/utils.js +1 -0
- package/lib/virtual-module-plugin.d.ts +12 -0
- package/lib/virtual-module-plugin.js +1 -0
- package/lib/virtual-modules.d.ts +2 -0
- package/lib/virtual-modules.js +1 -0
- package/{build → lib}/webpack.common.d.ts +4 -0
- package/lib/webpack.common.js +1 -0
- package/lib/webpack.dev.js +4 -0
- package/lib/webpack.prod.d.ts +3 -0
- package/lib/webpack.prod.js +1 -0
- package/package.json +27 -37
- package/template/index.html +38 -1
- package/typings/global.d.ts +53 -20
- package/build/common.js +0 -12
- package/build/done.js +0 -1
- package/build/envFlags.d.ts +0 -17
- package/build/envFlags.js +0 -1
- package/build/html-add-entry-attr.js +0 -1
- package/build/html-plugin-option.js +0 -1
- package/build/index.d.ts +0 -2
- package/build/index.js +0 -1
- package/build/modifyVars.js +0 -1
- package/build/module-federation.js +0 -1
- package/build/module.config.js +0 -1
- package/build/process-env.js +0 -1
- package/build/seo.js +0 -1
- package/build/swcrc.js +0 -1
- package/build/tsloader.config.js +0 -1
- package/build/utils.js +0 -1
- package/build/webpack.common.js +0 -1
- package/build/webpack.dev.d.ts +0 -2
- package/build/webpack.dev.js +0 -4
- package/build/webpack.prod.js +0 -1
- package/lib/normalize.css +0 -254
- package/lib/packages/library/bootstrap.js +0 -1
- package/lib/packages/library/index.d.ts +0 -4
- package/lib/packages/library/index.js +0 -1
- package/lib/refresh-rem.d.ts +0 -0
- package/lib/refresh-rem.js +0 -1
- package/lib/router/index.d.ts +0 -52
- package/lib/router/index.js +0 -1
- /package/lib/{packages/library/bootstrap.d.ts → cleanup.d.ts} +0 -0
- /package/{build → lib}/has-pkg.d.ts +0 -0
- /package/{build → lib}/has-pkg.js +0 -0
- /package/{build → lib}/html-add-entry-attr.d.ts +0 -0
- /package/{build → lib}/minify.d.ts +0 -0
- /package/{build → lib}/minify.js +0 -0
- /package/{build → lib}/modifyVars.d.ts +0 -0
- /package/{build → lib}/module-federation.d.ts +0 -0
- /package/{build → lib}/module.config.d.ts +0 -0
- /package/{build → lib}/resolver-sync.d.ts +0 -0
- /package/{build → lib}/resolver-sync.js +0 -0
- /package/{build → lib}/seo.d.ts +0 -0
- /package/{build/webpack.prod.d.ts → lib/webpack.dev.d.ts} +0 -0
- /package/{build → lib}/yarn-argv.d.ts +0 -0
- /package/{build → lib}/yarn-argv.js +0 -0
package/lib/app.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare const app: {
|
|
2
|
+
base: string;
|
|
3
|
+
designSize: number;
|
|
4
|
+
routerMode: "browser" | "hash" | "memory";
|
|
5
|
+
mode: "csr" | "ssr";
|
|
6
|
+
locales: boolean;
|
|
7
|
+
favicon: string | false | undefined;
|
|
8
|
+
prefixCls: string | undefined;
|
|
9
|
+
theme: import("./index.js").Theme | undefined;
|
|
10
|
+
type: import("./index.js").AppType;
|
|
11
|
+
persist: boolean;
|
|
12
|
+
projectName: string;
|
|
13
|
+
iconfont: {
|
|
14
|
+
scriptUrl?: string | string[] | undefined;
|
|
15
|
+
extraCommonProps?: Record<string, any> | undefined;
|
|
16
|
+
} | undefined;
|
|
17
|
+
name: string;
|
|
18
|
+
version: string;
|
|
19
|
+
description: string | undefined;
|
|
20
|
+
author: {
|
|
21
|
+
name: string | undefined;
|
|
22
|
+
email: string | undefined;
|
|
23
|
+
url: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
repository: {
|
|
26
|
+
type: string | undefined;
|
|
27
|
+
url: string | undefined;
|
|
28
|
+
directory: string | undefined;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export default app;
|
package/lib/app.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"fs";import e from"path";import{CONFIG as i}from"./common.js";import t from"./html-plugin-option.js";import{APPTYPE as r,PACKAGENAME as s,PROGRAMPATH as m,programInfo as n}from"./process-env.js";import{toUpperCaseString as p}from"./utils.js";let f="library"===r?"site":"src",c={...n,base:i.routeBaseName,designSize:i.designSize,routerMode:i.routerMode,mode:i.mode,locales:o.existsSync(e.join(m,`./${f}/locales`)),favicon:t.favicon,prefixCls:i.prefixCls,theme:i.theme,type:r,persist:o.existsSync(e.join(m,`./${f}/persist.ts`)),projectName:JSON.stringify(p(s)),iconfont:i.iconfont};export default c;
|
package/lib/cleanup.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as o,readdirSync as r,rmdirSync as t,statSync as i,unlinkSync as f}from"fs";import{join as s}from"path";import{cacheDir as c}from"./process-env.js";process.on("exit",function(){!function c(e){o(e)&&(r(e).forEach(o=>{let r=s(e,o);i(r).isDirectory()?c(r):f(r)}),t(e))}(c)});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AppType, ConfigType } from '../typings/global.
|
|
1
|
+
import type { AppType, ConfigType } from '../typings/global.js';
|
|
2
2
|
export declare const ENTRYPATH: Record<AppType, string>;
|
|
3
3
|
export declare const log: (msg: string) => void;
|
|
4
4
|
export declare const CONFIG: ConfigType<"swc">;
|
package/lib/common.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import e from"fs";import t from"path";import o from"readline";import s from"chalk";import{merge as i}from"webpack-merge";import{APPTYPE as n,CUSTOMCONFIG as r,FRAMEWORK as l,PROGRAMPATH as a,jsxImportSource as c,pkgName as m}from"./process-env.js";import{isFunction as p,readConf as u}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 d=[`@moneko/${l}`,"neko-ui","antd","@antv","katex","font-pingfang-sc","font-pingfang-tc","react-photo-view","react-markdown-editor-lite","schema-design","@app"],h={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"}}};"single-component"===n&&(h=!1);let g={seo:!1,mode:"csr",compiler:"swc",bundleAnalyzer:{analyzerMode:"static",reportFilename:"report.html",openAnalyzer:!1},entry:{},minifier:{js:{},css:{}},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:`${a}/node_modules/.temp_cache`,devServer:{allowedHosts:[".baidu.com"],host:"localhost",port:3e3,https:!1,compress:!1},htmlPluginOption:{template:`./node_modules/${m}/template/index.html`,favicon:`./node_modules/${m}/template/favicon.ico`,tags:[]},assetHtml:[],routerMode:"browser",fixBrowserRouter:!1,plugins:[],splitChunk:h,runtimeChunk:"single-component"!==n&&"single",moduleFederation:[],rulesInclude:{less:d,css:d,js:d,media:d,fonts:d},mdx:{jsxImportSource:c,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:"编译中",color:"#6f42c1"},virtualModule:{}};export const log=e=>{o.cursorTo(process.stdout,0),process.stdout.write(e)};let f=g,y=null,x={},b={};try{y=t.join(a,"./config/index.ts"),e.accessSync(y,e.constants.R_OK)}catch(e){y=null}if(y)try{let e=(await u(y,"index")).default;x=p(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}if(r){let o=null;try{o=t.join(a,`./config/${r}.ts`),e.accessSync(o,e.constants.R_OK)}catch(e){o=null}if(null!==o)try{let e=(await u(o,r)).default;b=p(e)?e(process):e}catch(e){process.stdout.write(s.red(e))}}"tsc"===(f=i(f,x,b)).compiler&&f.minifier&&(f.minifier.js||Object.assign(f.minifier,{js:{type:"terser"}}),f.minifier.css||Object.assign(f.minifier,{css:{type:"cssnano"}})),!1===f.devtool&&(f.sourceMap=!1),!1===f.sourceMap&&(f.devtool=!1),f.fixBrowserRouter&&f.htmlPluginOption&&(f.htmlPluginOption.tags||(f.htmlPluginOption.tags=[]),f.htmlPluginOption.tags.push({textContent:`
|
|
2
|
+
(function(l) {
|
|
3
|
+
if (l.search[1] === '/' ) {
|
|
4
|
+
var decoded = l.search.slice(1).split('&').map(function(s) {
|
|
5
|
+
return s.replace(/~and~/g, '&')
|
|
6
|
+
}).join('?');
|
|
7
|
+
window.history.replaceState(null, null,
|
|
8
|
+
l.pathname.slice(0, -1) + decoded + l.hash
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
}(window.location))
|
|
12
|
+
`}));export const CONFIG=f;export const PUBLICPATH=CONFIG.publicPath||"/";global.NEKOCLICONFIG={CONFIG,log};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CoverageType, ProjectCoverageType } from '../typings/global.
|
|
1
|
+
import type { CoverageType, ProjectCoverageType } from '../typings/global.js';
|
|
2
2
|
export declare const coverage: Record<string, CoverageType & Partial<ProjectCoverageType>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{accessSync as e,constants as r,readFileSync as c}from"fs";import{join as o}from"path";import{Parser as t}from"xml2js";import{PACKAGENAME as a,PROGRAMPATH as s}from"./process-env.js";export const coverage={};try{let i=o(s,"./coverage/clover.xml");e(i,r.R_OK);let m=new t({explicitArray:!1,async:!1}),p=c(i,{encoding:"utf-8"});m.parseString(p,(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/define.d.ts
ADDED
package/lib/define.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CONFIG as o}from"./common.js";import{NODE_ENV as e}from"./process-env.js";let r={"process.env":JSON.stringify({NODE_ENV:e,...o.env})};export default r;
|
package/lib/docs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const envApi: Record<string, string>;
|
package/lib/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 n from"./generate-api.js";import{APPTYPE as p,FRAMEWORK as i}from"./process-env.js";import{resolveNodeModulesPath as s,resolveProgramPath as l}from"./utils.js";import{vm as m}from"./virtual-module-plugin.js";import{alias as a}from"./webpack.common.js";let c="@app/comment";export const envApi={};let d={[c]:{}},f={react:"createElement","solid-js":"createComponent"}[i],u=`() => ${f}(SuspenseComp, { comp: $1 })`,$=`import { ${f} } from "${i}";import { SuspenseComp } from "@moneko/${i}";`;function j(e,r){let p=e.replace(RegExp(`^${a["@pkg"]}`),""),i=t(p).replace(/^\//,""),l=[c,i].join("/"),j=p.split("/").pop()?.replace(/\.tsx?/,".md");if(!j)return;d[c][i]||(d[c][i]={});let g=o(l,j);if("deleted"===r)d[c][i][j]&&delete d[c][i][j];else{let t=n(e);d[g]=t,t?d[c][i][j]=`rr(() => import(/* webpackChunkName: '${g}' */'${g}?raw').then((res) => ({default: ${f}(Dynamic, {text: res.default, component: 'n-md'})})))rr`:d[c][i][j]&&delete d[c][i][j]}let h={};for(let e in d[c])Object.prototype.hasOwnProperty.call(d[c],e)&&(h[e]=Object.values(d[c][e]));let y={...d};for(let e in delete y[c],Object.assign(envApi,{...y,"@app/docs":`${$}export default ${JSON.stringify(h).replace(/"rr\((.+?)\)rr"/g,u)}`}),envApi)Object.prototype.hasOwnProperty.call(envApi,e)&&m?.writeModule(s(e),envApi[e])}["react","solid-js"].includes(i)||(u="$1",$=""),"solid-js"===i&&($=`import { Dynamic } from "${i}/web";${$}`),"library"===p&&function(){let t=[],o=r(l("components"),{ignored:[/(^|[\\/\\])\../,/(^|[\\/\\])__tests__([\\/\\]|$)/],persistent:!0,ignoreInitial:!1});function n(t){return/\.tsx?$/.test(t)&&e(t).isFile()}o.on("add",e=>{n(e)&&(j(e,"added"),t.push(e))}),o.on("change",e=>{n(e)&&j(e,"change")}),o.on("unlink",e=>{n(e)&&(j(e,"deleted"),t.splice(t.indexOf(e),1))}),o.on("ready",()=>{t.forEach(e=>{j(e,"change")})}),process.on("SIGINT",function(){o.close()})}();
|
package/{build → lib}/done.d.ts
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Compiler } from 'webpack';
|
|
1
2
|
declare class DoneWebpackPlugin {
|
|
2
3
|
options: {
|
|
3
4
|
done?: () => void;
|
|
@@ -5,12 +6,6 @@ declare class DoneWebpackPlugin {
|
|
|
5
6
|
constructor(options: {
|
|
6
7
|
done?: () => void;
|
|
7
8
|
});
|
|
8
|
-
apply(compiler:
|
|
9
|
-
hooks: {
|
|
10
|
-
done: {
|
|
11
|
-
tap: (arg0: string, arg1: () => void) => void;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
}): void;
|
|
9
|
+
apply(compiler: Compiler): void;
|
|
15
10
|
}
|
|
16
11
|
export default DoneWebpackPlugin;
|
package/lib/done.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default class{constructor(o){this.options=Object.assign({},o)}apply(o){o.hooks.done.tap("DoneWebpackPlugin",()=>{this.options.done?.()})}};
|
package/lib/esm.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function esm(templateStrings: TemplateStringsArray, ...substitutions: unknown[]): string;
|
package/lib/esm.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
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")}`}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function generateApi(path: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileSync as e}from"fs";import{dirname as t}from"path";import n from"typescript";import{CONFIG as r}from"./common.js";import{alias as l}from"./webpack.common.js";let{ScriptKind:o,ScriptTarget:i,SyntaxKind:u,createSourceFile:c,forEachChild:a,getLeadingCommentRanges:s,isInterfaceDeclaration:f,isQuestionToken:m,isPropertySignature:p,isFunctionTypeNode:g,isUnionTypeNode:$,isMethodSignature:h}=n,b={};function d(e){let t=s(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.substring(t[0].pos,t[0].end),r=n.match(/\/\*\*([\s\S]*?)\*\//);if(r){let e=r[1].replace(/^\s*\* ?/gm,"").replace(/\s+$/,"").trim();return e}}return null}function y(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function x(e){if(!e)return null;let t=e.match(/@author (\w+)\s*(?:<([^>]+)>)?/);if(t?.length){let e=t[1].trim(),n=t[2]?.trim(),r=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(n);return n?r&&(n=`mailto:${n}`):n=`https://github.com/${e}`,`[${e}${r?" 📧":" ⎋"}](${n})`}return null}function j(e){if(!e)return null;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():null}let T=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function k(e,t){if(!e)return null;let n=e.replace(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if(b[e]){let n=`/${[r.routeBaseName,b[e]].join("/").split("/").filter(Boolean).join("/")}`;return t?`[\\color{#009688}{${e}}](${n})`:`[${e}](${n})`}return t?`\\color{#009688}{${e}}`:e});return t&&(n=n.replace(T,e=>`\\color{#009688}{${e}}`)),n}function w(e){return(function(e){let t;if(!e)return null;let n=[];for(;t=/\\color{([^|}]*)\|?([^|}]*)\|?([^|}]*)\|?([^}]*)}{([^}]*)}/g.exec(e);)n.push(t[0]);return e.replace(/(\{|\}|\[|\]|\(|\)|=>|keyof|typeof|true|false)/g,e=>n.some(t=>t.includes(e))?e:`\\color{#569cd6}{${e}}`)})(e)?.replace(/^\s*\|\s*|\s*\|\s*$/gm,"").replace(/\n/g,"<br/>").replace(/\*/g,"\\*").replace(/\|/g,"\\|").replace(/(['"])((?:(?!\1).)*)\1/g,"\\color{#ce9178}{$1$2$1}")}function B(e){return e?e.replace(/^@[a-z].+/gm,"").replace(/(\n\s+)+/g,"<br />").replace(/\n/g,"<br />").replace(/(<br \/>)$/g,""):null}export default function E(r){let s=e(r,"utf-8"),T=c(r,s,i.Latest,!0,o.TS),E="";return a(T,e=>{f(e)?E+=function(e){let r=e.name.text;Object.assign(b,{[e.name.text]:t(e.getSourceFile().fileName).replace(l["@pkg"],"")});let o=d(e),i=y(o),c=B(o),a=j(o)?.split("|")||[],s=a.includes("comment"),f=a.includes("initial"),T=a.includes("optional"),E=a.includes("version"),S=a.includes("author"),v=c?`\\color{|4||0.45}{${r}}`:r,F=(function(e){let t=[];if(e.heritageClauses){for(let r of e.heritageClauses)if(r.token===n.SyntaxKind.ExtendsKeyword)for(let e of r.types)t.push(e.getText())}return t})(e)?.map(e=>`<n-tag color="#4c81db" css=".tag{gap:0px;}">${k(w(e))}</n-tag>`),N=[c,v,i&&`\\color{#52c11b|1||0.9}{${i}}`,F.length>0&&`<sub>\`extends\`</sub> ${F.join(" ")}`].filter(Boolean).join(" "),z=`## ${N}`,K=e.members.filter(e=>p(e)&&e.type?.kind!==u.NeverKeyword||h(e)),q=[];if(K.length){K.forEach(e=>{let t=k(w(h(e)?`(${e.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${e.type?.getText()||"any"}`:e.type?.getText()||"any"),!0),n=d(e),r=w(e.name.getText());!r||r.startsWith("\\color")||(h(e)||function(e){if(e.type){if(!$(e.type))return g(e.type);for(let t of e.type.types)if(g(t))return!0}return!1}(e)||t?.includes("=>")?r=`\\color{#f9a913}{${r}}`:/^("|')(.+)("|')$/.test(r)||(r=`\\color{#4c81db}{${r}}`));let l=e.questionToken&&m(e.questionToken);q.push([r,!T&&`\\color{${l?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${l?"✘":"✔"}}`,!s&&w(B(n)),t,!f&&w(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(n)),!E&&w(y(n)),!S&&(x(n)||x(o))])});let e=!1,t=!1,n=!1,r=!1;q.forEach(l=>{!s&&l[2]&&(r=!0),!f&&l[4]&&(n=!0),!E&&l[5]&&(t=!0),!S&&l[6]&&(e=!0)}),z+="\n";let l=["属性",!T&&"必要",r&&"说明","类型",n&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");z+=`|${l}|`;let i=[":-",!T&&":-",r&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);z+="\n";let u=i.join("|");z+=`|${u}|`,q.forEach(l=>{z+="\n";let o=[l[0]||"-",!T&&(l[1]||"-"),r&&(l[2]||"-"),l[3]||"-",n&&(l[4]||"-"),t&&(l[5]||"-"),e&&(l[6]||"-")].filter(Boolean).join("|");z+=`|${o}|`}),z+="\n"}return z+="\n"}(e):n.isEnumDeclaration(e)&&(E+=function(e){let r=e.name.text;Object.assign(b,{[e.name.text]:t(e.getSourceFile().fileName).replace(l["@pkg"],"")});let o=d(e),i=j(o)?.split("|")||[],u=i.includes("comment"),c=i.includes("version"),a=i.includes("author"),s=`## ${r}`;if(e.members.length){let t=[];e.members.forEach(e=>{let r=w(e.name.getText()),l=d(e),i=w(function(e){let t=e.initializer;return t&&n.isStringLiteral(t)?` '${t.text}'`:null}(e)),s=w(y(l)),f=w(B(l));!r||r.startsWith("\\color")||/^("|')(.+)("|')$/.test(r)||(r=`\\color{#4c81db}{${r}}`),t.push([r,!u&&f,i,!c&&s,!a&&(x(l)||x(o))])});let r=!1,l=!1,i=!1;t.forEach(e=>{!u&&e[1]&&(i=!0),!c&&e[3]&&(l=!0),!a&&e[4]&&(r=!0)}),s+="\n";let f=["属性",i&&"说明","值",l&&"版本",r&&"作者"].filter(Boolean).join("|");s+=`|${f}|`;let m=[":-",i&&":-",":-",l&&":-",r&&":-"].filter(Boolean);s+="\n";let p=m.join("|");s+=`|${p}|`,t.forEach(e=>{s+="\n";let t=[e[0]||"-",i&&(e[1]||"-"),e[2]||"-",l&&(e[3]||"-"),r&&(e[4]||"-")].filter(Boolean).join("|");s+=`|${t}|`})}return s+="\n\n"}(e))}),E}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"html-webpack-plugin";export default class{constructor(t){this.entryMatchCallback=t}apply(a){a.hooks.compilation.tap("AddEntryAttributeWebpackPlugin",e=>{let r=a.options.plugins.find(a=>a instanceof t);if(r){let t=r.getHooks(e);t.alterAssetTagGroups.tap("AddEntryAttributeWebpackPlugin",t=>(t.headTags.forEach(t=>{"script"===t.tagName&&"string"==typeof t.attributes?.src&&this.entryMatchCallback(t.attributes.src)&&(t.attributes.entry=!0)}),t))}})}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"path";import{merge as t}from"webpack-merge";import{CONFIG as i}from"./common.js";import{PACKAGENAME as o,PROGRAMPATH as a,pkgName as m,programInfo as p}from"./process-env.js";let{template:r,favicon:n,...l}=i.htmlPluginOption||{template:`./node_modules/${m}/template/index.html`,favicon:`./node_modules/${m}/template/favicon.ico`},s=t({title:i.env?.PROJECTNAME||o.toLocaleUpperCase()||"Title",filename:"index.html",hash:!1,minify:{collapseWhitespace:!0,removeComments:!0,removeRedundantAttributes:!1,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeAttributeQuotes:!0,useShortDoctype:!0},meta:{charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no",viewport:"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no","apple-mobile-web-app-capable":"yes",renderer:"webkit",description:p.description||""},tags:[],template:e.join(a,r),favicon:e.join(a,n)},l);export default s;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,36 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export type PartialConfigType<T = 'swc'> = Partial<ConfigType<T>>;
|
|
5
|
-
export type PartialCommomType<T = 'swc'> = Partial<CommomType<T>>;
|
|
6
|
-
/** 一些项目基本信息 */
|
|
7
|
-
export declare const projectBasicInfo: {
|
|
8
|
-
projectName: string;
|
|
9
|
-
providerConfig: {
|
|
10
|
-
[key: string]: any;
|
|
11
|
-
prefixCls: string;
|
|
12
|
-
iconPrefixCls: string;
|
|
13
|
-
input: React.InputHTMLAttributes<HTMLInputElement>;
|
|
14
|
-
};
|
|
15
|
-
programInfo: {
|
|
16
|
-
name: string;
|
|
17
|
-
description: string;
|
|
18
|
-
version: string;
|
|
19
|
-
type: "mobile" | "site" | "back-stage" | "single-spa" | "library";
|
|
20
|
-
author: {
|
|
21
|
-
name: string;
|
|
22
|
-
url?: string | undefined;
|
|
23
|
-
email?: string | undefined;
|
|
24
|
-
};
|
|
25
|
-
repository: {
|
|
26
|
-
type?: string | undefined;
|
|
27
|
-
url?: string | undefined;
|
|
28
|
-
directory?: string | undefined;
|
|
29
|
-
};
|
|
30
|
-
routerMode: "hash" | "browser" | "memory";
|
|
31
|
-
routeBaseName: string;
|
|
32
|
-
designSize: number;
|
|
33
|
-
renderMode: "ssr" | "csr";
|
|
34
|
-
};
|
|
35
|
-
coverage: Record<string, CoverageType & Partial<ProjectCoverageType>>;
|
|
36
|
-
};
|
|
1
|
+
export * from './process-env.js';
|
|
2
|
+
export * from './utils.js';
|
|
3
|
+
export * from '../typings/global.js';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export*from"./process-env.js";export*from"./utils.js";export*from"../typings/global.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CONFIG as i}from"./common.js";import o from"./html-plugin-option.js";let f=i.prefixCls||"n",n={};Object.assign(n,{"@prefix-cls":f,"@ant-prefix":f,"@iconfont-css-prefix":`${f}-icon`,"@favicon":JSON.stringify(o.favicon)},i.modifyVars||{});export default n;
|
|
@@ -0,0 +1 @@
|
|
|
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])})));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve as e}from"path";import s from"mini-css-extract-plugin";import o from"mini-svg-data-uri";import{CONFIG as t,PUBLICPATH as l}from"./common.js";import{hasPkg as r}from"./has-pkg.js";import a from"./modifyVars.js";import{APPTYPE as n,DEV as i,FRAMEWORK as c,__dirname as m}from"./process-env.js";import p from"./swcrc.js";import d from"./tsloader.config.js";import{resolveNodeModulesPath as u,resolveProgramPath as f}from"./utils.js";let y="single-spa"===n?l:"../",x={loader:s.loader,options:{publicPath:"/"!==y?y:"../"}},g=r("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};i&&(x="style-loader");let $=[...t.cssModules,`@moneko/${c}`,"neko-ui"].map(u),j=[...["src/styles/variables/*.less","src/styles/mixins/*.less","site/styles/variables/*.less","site/styles/mixins/*.less"].map(f)],b=["components","example","mock","site","src"].map(f),v=[x,{loader:"@teamsupercell/typings-for-css-modules-loader",options:{verifyOnly:!i}},{loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,o=$.length;s<o;s++)if(e&&e?.includes($[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}},g,"css-unicode-loader",{loader:"less-loader",options:{sourceMap:!!t.sourceMap,lessOptions:{modifyVars:a,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:j}}].filter(Boolean),w={loader:"tsc"===t.compiler?"ts-loader":"swc-loader",options:"tsc"===t.compiler?d:p(i)},h={rules:[{test:/\.mdx?$/,include:[f("components")],exclude:[/(.+)\/examples\/(.+).mdx?$/i],enforce:"pre",use:[{loader:e(m,"./loader/frontmatter.cjs")}]},{oneOf:[{resourceQuery:/raw/,type:"asset/source"},{test:/\.wasm$/,type:"webassembly/async"},{test:/\.txt$/,type:"asset/source"},{test:/\.(gif|png|jpe?g|ico|mp4)$/i,type:"asset",dependency:{not:["url"]},generator:{filename:"assets/images/[name][ext][query]"},include:b.concat(t.rulesInclude?.media?.map(u)||[])},{test:/\.svg$/,type:"asset/inline",generator:{dataUrl:e=>o("string"!=typeof e?e.toString():e)}},{test:/\.(eot|ttf|otf|woff(|2))$/,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:b.concat(t.rulesInclude?.fonts?.map(u)||[])},{test:/\.less$/,use:v,include:b.concat(t.rulesInclude?.less?.map(u)||[])},{test:/\.css$/,use:[x,"css-loader",g,"css-unicode-loader"].filter(Boolean),include:b.concat(t.rulesInclude?.css?.map(u)||[])},{test:/\.(cj|mj|t|j)s(|x)$/,use:[...t.prefixJsLoader,w].filter(Boolean),include:b.concat(t.rulesInclude?.js?.map(u)||[])},{test:/\.mdx?$/,use:[...t.prefixJsLoader,w,{loader:"@mdx-js/loader",options:t.mdx}].filter(Boolean),include:b,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...t.moduleRules]};export default h;
|
package/lib/net.d.ts
ADDED
package/lib/net.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createConnection as t}from"net";import{networkInterfaces as e}from"os";import r from"webpack-dev-server";let{internalIPSync:o}=r;export function getNetworkAdress(){let t=e();for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let r=t[e];for(let t=0;t<r.length;t++){let e=r[t];if("IPv4"===e.family&&"127.0.0.1"!==e.address&&!e.address.startsWith("169.254")&&!e.internal)return e.address}}}export function getIPv4(){return o("v4")}export function getPort(e,r,o="0.0.0.0"){return new Promise(n=>{let s=t(e,o);s.on("connect",()=>{s.destroy(),n(getPort(e+1,r,o))}),s.on("error",()=>{n(e)})})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function e(e){let t=[],n=new Proxy(e,{set:(e,n,r)=>(e[n]=r,t.forEach(t=>{t(e)}),!0)});return{data:n,listener:function(e){return t.push(e),()=>{let n=t.indexOf(e);-1!==n&&t.splice(n,1)}}}}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import type { AppType } from '../typings/global.
|
|
1
|
+
import type { AppType, Framework } from '../typings/global.js';
|
|
2
2
|
export declare const __dirname: string;
|
|
3
3
|
export declare const APPTYPE: AppType;
|
|
4
|
+
export declare const FRAMEWORK: Framework;
|
|
5
|
+
export declare const isReact: boolean;
|
|
6
|
+
export declare const isSolid: boolean;
|
|
7
|
+
export declare const jsxImportSource: string;
|
|
4
8
|
export declare const PROGRAMPATH: string;
|
|
5
9
|
export declare const PACKAGENAME: string;
|
|
6
10
|
export declare const PACKAGEVERSION: string;
|
|
7
11
|
export declare const pkgName: string;
|
|
12
|
+
export declare const DEV: boolean;
|
|
13
|
+
export declare const cacheDir: string;
|
|
8
14
|
export declare const NODE_ENV: string | undefined;
|
|
9
15
|
export declare const CUSTOMCONFIG: string | undefined;
|
|
10
|
-
export declare const DEV: boolean;
|
|
11
16
|
export declare let hasEslintConfig: boolean;
|
|
12
17
|
export declare let hasStylelintConfig: boolean;
|
|
13
|
-
export declare const hasReact: boolean;
|
|
14
18
|
export declare const hasAntd: boolean;
|
|
15
19
|
export declare const programInfo: {
|
|
16
20
|
name: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as e,mkdirSync as o,readFileSync as r}from"fs";import{join as s}from"path";import t from"url";import{hasPkg as n}from"./has-pkg.js";import{resolveProgramPath as p}from"./utils.js";import c from"./yarn-argv.js";export const __dirname=t.fileURLToPath(new URL(".",import.meta.url));export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;export const isReact="react"===FRAMEWORK;export const isSolid="solid-js"===FRAMEWORK;export const jsxImportSource={react:"react","solid-js":"solid-js/h"}[FRAMEWORK];export const PROGRAMPATH=process.cwd();export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;let a=r(s(__dirname,"../package.json"),{encoding:"utf-8"});export const pkgName=JSON.parse(a).name;export const DEV="development"===process.env.NODE_ENV;export const cacheDir=s(PROGRAMPATH,"./node_modules/.cache/.mo/");e(cacheDir)||o(cacheDir,{recursive:!0});export const NODE_ENV=process.env.NODE_ENV;export const CUSTOMCONFIG=process.env.npm_config_config||c.config;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 hasAntd=n("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 e=r(p("package.json"),{encoding:"utf-8"}),{description:o,author:s,repository:t,eslintConfig:n,stylelint:c}=JSON.parse(e);programInfo.author="string"==typeof s?{name:s}:s,programInfo.repository="string"==typeof s?{url:t}:t,programInfo.description=o,hasEslintConfig=!!n,hasStylelintConfig=!!c}
|
package/lib/routes.d.ts
ADDED
package/lib/routes.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e,t;import{readFileSync as r,readdirSync as o,statSync as n}from"fs";import{join as i,relative as l}from"path";import{watch as s}from"chokidar";import{load as c}from"js-yaml";import{APPTYPE as p,DEV as m,FRAMEWORK as a,PROGRAMPATH as u}from"./process-env.js";import{resolveNodeModulesPath as f}from"./utils.js";import{vm as d}from"./virtual-module-plugin.js";let g=/^---\n([\s\S]+?)\n---\n/;function h(e,t){let{regex:s,alia:p,base:m=e,outputSource:a}=t,u=o(e);return u.reduce((o,u)=>{let f=i(e,u),d=n(f);if(d.isDirectory()){let e=h(f,{...t,base:m});if(e.length>0){let t={},r={path:u,key:l(m,f)};if(a)Object.assign(t,{children:e});else{let o=e.splice(0,1)[0];e.length?Object.assign(t,{children:[{...o,path:"/",key:r.key},...e]}):Object.assign(t,o)}o.push(Object.assign(t,r))}}else if(s.test(f)){let e=r(f,{encoding:"utf-8"}),t=function(e){let t=e.match(g);return t&&t[1]?t[1].trim():null}(e),n=t?c(t):{},s=l(m,f);o.push(Object.assign({path:u,key:s,meta:{...n}},p&&{component:`rr(() => import(/* webpackChunkName: '${s}' */'${i(p,s)}'))rr`},a&&{codes:function(e){let t;let r={},o=/```(.+?)\n([\s\S]*?)\n```/g;for(;null!==(t=o.exec(e));){let[,e="jsx",o]=t,n=e.split(" ").pop()||"jsx";r[n]=o.trim()}return Object.keys(r).length?r:{jsx:e}}(e.replace(g,"").replace(/^\n+|\n+$/g,""))}))}return o},[])}let $=i(u,"./components");export let routes=[];function j(){clearTimeout(e),e=setTimeout(()=>{clearTimeout(e);let t={react:"createElement","solid-js":"createComponent"}[a],r=`() => ${t}(SuspenseComp, { comp: $1 })`,o=`import { ${t} } from "${a}";import { SuspenseComp } from "@moneko/${a}";`;["react","solid-js"].includes(a)||(r="$1",o=""),routes=h($,{regex:/README\.mdx?$/,alia:"@pkg"});let n=JSON.stringify(routes).replace(/"rr\((.+?)\)rr"/g,r);d?.writeModule(f("@app/routes"),`${o}export default ${n}`)},100)}function x(){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),h($,{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);d?.writeModule(f(t),`export default ${JSON.stringify(r)};`)})},100)}function k(e,t,r){let o=s(e,{ignored:(e,r)=>{if(r)return!r?.isDirectory()&&t.test(e)},persistent:!0});o.on("add",()=>{r()}).on("change",()=>{r()}).on("unlink",()=>{r()}),process.on("SIGINT",function(){o.close()})}"library"===p&&(m?(k($,/(?<!README\.mdx?)$/,j),k($,/(?<!\/examples\/(.+)\.md)$/,x)):(j(),x()));
|
package/lib/seo.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as t,mkdirSync as o,writeFileSync as r}from"fs";import{join as e}from"path";import{CONFIG as s}from"./common.js";import{routes as m}from"./routes.js";import{resolveProgramPath as i}from"./utils.js";import{outputConfig as p}from"./webpack.common.js";function n(t,o){try{r(t,o,"utf-8")}catch(t){}}export const seo=()=>{let{domain:r,nojekyll:c,path:a}=s.seo||{};if(!r)return;let f=s.routeBaseName,h=f.endsWith("/")?f:`${f}/`,l=a&&i(a)||p?.path||process.cwd();t(l)||o(l),n(e(l,"CNAME"),r),n(e(l,"robots"),`Sitemap: https://${r}${h}sitemap.txt`);let u=[];!function t(o){o.forEach(o=>{u.push(`https://${r}${h}${o.key}`),Array.isArray(o.children)&&t(o.children)})}(m),n(e(l,"sitemap.txt"),u.join("\n")),c&&n(e(l,".nojekyll"),"")};
|
package/{build → lib}/swcrc.d.ts
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Config as SwcConfig
|
|
1
|
+
import type { JsMinifyOptions, Config as SwcConfig } from '@swc/core';
|
|
2
2
|
export declare const swcMinifyOption: JsMinifyOptions;
|
|
3
3
|
declare const _default: (isDev?: boolean) => SwcConfig;
|
|
4
4
|
export default _default;
|
package/lib/swcrc.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{merge as e}from"webpack-merge";import{CONFIG as o}from"./common.js";import{isReact as r,isSolid as s,jsxImportSource as t}from"./process-env.js";let n={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((a=!1)=>{let c={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:r&&a,development:a,importSource:t},optimizer:{simplify:!1}},experimental:{plugins:[["swc-plugin-another-transform-imports",function(e){for(let o=0,r=Object.keys(e),s=r.length;o<s;o++)e[r[o]].transform=`${r[o]}/${e[r[o]].transform}`,e[r[o]].style&&(e[r[o]].style=`${r[o]}/${e[r[o]].style}`);return e}(o.importOnDemand||{})],s&&["@moneko/jsx-dom-expressions",o.jsxDomExpressions||{}]].filter(Boolean)}},sourceMaps:!0,parseMap:!0},i=Object.assign(c,!a&&n);return o.swcrc&&(i=e(i,"function"==typeof o.swcrc?o.swcrc(a):o.swcrc)),i});
|
|
@@ -0,0 +1 @@
|
|
|
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,readConf as s,resolveProgramPath 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=a("tsloader.config.ts");t.accessSync(r,t.constants.R_OK);let e=(await s(r,"tsloader.config")).default;p=o(p,m(e)?e(process):e)}catch(t){}export default p;
|
package/{build → lib}/utils.d.ts
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
-
type ProgramPath<T extends string> = `~/${T extends string ? T : string}`;
|
|
4
|
+
type ProgramPath<T extends string> = `${T extends string ? T : string}`;
|
|
5
5
|
type NodeModulesPath<T> = ProgramPath<`node_modules/${T extends string ? T : string}`>;
|
|
6
6
|
/** 位于项目根目录下的位置
|
|
7
7
|
* @param {string} src 路径
|
|
@@ -12,7 +12,12 @@ export declare function resolveProgramPath<T extends string>(src: T): ProgramPat
|
|
|
12
12
|
* @param {string} src 路径
|
|
13
13
|
* @returns {string} 位于项目根目录node_modules下的位置
|
|
14
14
|
*/
|
|
15
|
-
export declare const resolveNodeModulesPath: <T extends string>(src: T) =>
|
|
15
|
+
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}`;
|
|
16
|
+
/** 获取模块真实入口位置
|
|
17
|
+
* @param {string} url 路径
|
|
18
|
+
* @returns {string} 模块真实入口路径
|
|
19
|
+
*/
|
|
20
|
+
export declare const resolve: (url: string) => string;
|
|
16
21
|
export declare function isObject(target: unknown): target is object;
|
|
17
22
|
export declare function isFunction(target: unknown): target is (...args: unknown[]) => unknown;
|
|
18
23
|
export {};
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as e}from"fs";import o from"path";import{transformFileSync as t}from"@swc/core";import{cacheDir as r}from"./process-env.js";import n from"./resolver-sync.js";let c={inputSourceMap:!1,sourceMaps:!1,module:{type:"es6"},jsc:{parser:{syntax:"typescript"},loose:!1}};export function tfc(e){return t(e,c).code||"{}"}export function readConf(t,n){let c=o.join(r,`${n}.mjs`);return e(c,tfc(t),"utf-8"),import(c)}export function toUpperCaseString(e){return e?.replace(/\b\w/g,e=>e.toUpperCase()).replace(/\./g," ")}export function resolveProgramPath(e){return o.resolve(process.cwd(),`./${e}`)}export const resolveNodeModulesPath=e=>resolveProgramPath(`node_modules/${e}`);export const resolve=e=>n.resolveSync({},process.cwd(),e)||e;export function isObject(e){let o=typeof e;return null!==e&&("object"==o||"function"==o)}export function isFunction(e){if(!isObject(e))return!1;let o=Object.prototype.toString.call(e);return"[object Function]"==o||"[object AsyncFunction]"==o||"[object GeneratorFunction]"==o||"[object Proxy]"==o}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import VirtualModulesPlugin from 'webpack-virtual-modules';
|
|
2
|
+
import type { Compiler } from 'webpack';
|
|
3
|
+
interface VirtualModulePluginOption {
|
|
4
|
+
[key: string]: string | object;
|
|
5
|
+
}
|
|
6
|
+
export declare let vm: VirtualModulesPlugin;
|
|
7
|
+
declare class VirtualModulePlugin {
|
|
8
|
+
private options;
|
|
9
|
+
constructor(options: VirtualModulePluginOption);
|
|
10
|
+
apply(compiler: Compiler): void;
|
|
11
|
+
}
|
|
12
|
+
export default VirtualModulePlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"webpack-virtual-modules";import{resolveNodeModulesPath as o}from"./utils.js";export let vm;export default class{constructor(t){this.options=t}apply(i){(vm=new t).apply(i),i.hooks.compilation.tap("VirtualModulePlugin",()=>{for(let t in this.options)if(Object.prototype.hasOwnProperty.call(this.options,t)){let i=this.options[t];"string"==typeof i?vm.writeModule(o(t),i):vm.writeModule(o(t),`export default ${JSON.stringify(i)}`)}})}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{accessSync as o,constants as p}from"fs";import{join as a}from"path";import t from"./app.js";import{CONFIG as r}from"./common.js";import{coverage as e}from"./coverage.js";import{APPTYPE as l,PROGRAMPATH as m}from"./process-env.js";let c={...r.virtualModule,"@app":t,"@app/fallback":"export default null"};if(r.fallbackCompPath&&Object.assign(c,{"@app/fallback":`import Fallback from "${r.fallbackCompPath}";export default Fallback;`}),"library"===l){let t={};try{let r=a(m,"./site/mdx-scope.ts");o(r,p.R_OK),t='import scope from "@/mdx-scope";export default scope;'}catch(o){t={}}Object.assign(c,{"@app/coverage":e,"@app/mdx-scope":t})}export default c;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import './cleanup.js';
|
|
2
|
+
import './docs.js';
|
|
3
|
+
import './routes.js';
|
|
1
4
|
import type { WebpackConfiguration } from 'webpack-dev-server';
|
|
5
|
+
export declare const alias: Record<string, string>;
|
|
2
6
|
export declare const outputConfig: WebpackConfiguration['output'];
|
|
3
7
|
declare const config: WebpackConfiguration;
|
|
4
8
|
export default config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"fs";import t from"add-asset-html-webpack-plugin";import s from"html-webpack-plugin";import o from"webpack";import n from"webpackbar";import"./cleanup.js";import{CONFIG as l,ENTRYPATH as i,PUBLICPATH as a}from"./common.js";import r from"./define.js";import"./docs.js";import p from"./done.js";import m from"./html-add-entry-attr.js";import c from"./html-plugin-option.js";import{moduleFederation as u}from"./module-federation.js";import d from"./module.config.js";import{APPTYPE as f,DEV as j,FRAMEWORK as g,PACKAGENAME as h,PROGRAMPATH as b,hasEslintConfig as y,hasStylelintConfig as w}from"./process-env.js";import"./routes.js";import{seo as x}from"./seo.js";import{resolveNodeModulesPath as k,resolveProgramPath as v}from"./utils.js";import O from"./virtual-module-plugin.js";import C from"./virtual-modules.js";let{AutomaticPrefetchPlugin:$,DefinePlugin:B,SourceMapDevToolPlugin:A,WatchIgnorePlugin:S}=o,T=[".eslintrc.js",".eslintrc.json",".eslintrc.yaml",".eslintrc.json"],K=[".stylelintrc",".stylelintrc.json",".stylelintrc.yaml",".stylelintrc.yml",".stylelintrc.js","stylelint.config.js","stylelint.config.cjs"],L=e.readdirSync(b),M=!1,P=!1;for(let e=0,t=L.length;e<t;e++)K.includes(L[e])&&(P=!0),T.includes(L[e])&&(M=!0);M||(M=y),P||(P=w);let F=P?(await import("stylelint-webpack-plugin")).default:null,N=M?(await import("eslint-webpack-plugin")).default:null;export const alias={"@":v("src")};Object.assign(alias,l.alias),"library"===f&&Object.assign(alias,{"@":v("site"),"@pkg":v("components"),[h]:v("components")});let R=l.assetHtml.map(e=>({publicPath:"",...e}));export const outputConfig={path:v("library"===f?"docs":"dist"),filename:"js/[name].bundle.js",chunkFilename:"js/[name].chunk.js",assetModuleFilename:"assets/[name][hash][ext][query]",library:{name:h,type:"window"},globalObject:"window",chunkLoadingGlobal:`webpackJsonp_${h}`,pathinfo:j,clean:!0,publicPath:a};let W=k(`@moneko/${g}/lib/packages/${i[f]}/index.js`);"single-component"===f&&(Object.assign(alias,{[h]:v("umd")}),W=v(j?"example/index.ts":"src/index.ts"),outputConfig.path=v(j?"dist":"umd"),outputConfig.filename="index.js",outputConfig.globalObject="this",outputConfig.library={export:"default",name:h,type:"umd",umdNamedDefine:!0});let _={main:W};l.entry&&("string"==typeof l.entry?_=l.entry:Object.keys(l.entry)&&Object.assign(_,l.entry)),l.output&&("string"==typeof l.output?outputConfig.path=l.output:Object.keys(l.output)&&Object.assign(outputConfig,l.output));let q=l.routeBaseName.split("/").filter(Boolean).length,D=`${Array(q).fill("..").join("/")+(q?"/":"")}404.html`,{pathSegmentsToKeep:G=q,path:H=D}=l.fixBrowserRouter||{},J={entry:_,stats:"errors-only",infrastructureLogging:{level:"none"},target:"web",plugins:[new $,...u,N&&new N({fix:!0,threads:!0,extensions:["js","md","mdx","cjs","ejs","mjs","jsx","ts","tsx","json","html","coffee","vue"]}),F&&new F({fix:!0,threads:!0,extensions:["css","scss","sass","less","ts","tsx","js","jsx"],exclude:["node_modules/","es/","lib/","docs/","coverage/","dist/"]}),l.htmlPluginOption&&new s(c),l.fixBrowserRouter&&new s({filename:H,inject:!1,templateContent:()=>`<html html><head><title>${c.title}</title><script>var pathSegmentsToKeep = ${G||q};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 t(R),"single-spa"===f&&new m(e=>!!(e.match(/main\.(.*)\.bundle.js$/)||e.match("main.bundle.js"))),new B(r),new S({paths:[/\.d\.ts$/]}),l.sourceMap&&new A(l.sourceMap),l.bar&&new n(l.bar),new p({done:()=>{!j&&l.seo&&x(),l.done?.(),j||setTimeout(()=>{process.exit(0)},2e3)}}),new O(C),...l.plugins].filter(Boolean),experiments:{topLevelAwait:!0,syncWebAssembly:!0,asyncWebAssembly:!0},resolve:{extensions:[".tsx",".ts",".js",".jsx"],alias:alias,fallback:{path:!1,fs:!1,crypto:!1,assert:!1}},module:d,externals:l.externals,output:outputConfig};export default J;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import e from"@soda/friendly-errors-webpack-plugin";import o from"chalk";import r from"webpack";import{merge as t}from"webpack-merge";import{CONFIG as s}from"./common.js";import{hasPkg as a}from"./has-pkg.js";import{getIPv4 as p,getPort as i}from"./net.js";import{CUSTOMCONFIG as m,isReact as l}from"./process-env.js";import{isFunction as n,resolveProgramPath as c}from"./utils.js";import d from"./webpack.common.js";let{HotModuleReplacementPlugin:v}=r,{yellow:h,green:f}=o,w=p(),u=s.devServer.port||3e3,g=await i(u,65535,s.devServer.host),k=s.devServer.port!==g,y=a("@moneko/mock"),$=y&&await import("@moneko/mock"),S=l&&(await import("@pmmmwh/react-refresh-webpack-plugin")).default,b=!1;s.cacheDirectory&&(b={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.cacheDirectory,name:`${m||"default"}-development`});let j=!1===s.devtool||s.devtool?s.devtool:"eval-cheap-module-source-map";s.devServer.port=g;let x="/"===s.routeBaseName,D=s.devServer.https?"https:":"http:",A=x?"":s.routeBaseName;export default t(d,{devtool:j,mode:"development",cache:b,devServer:{headers:{"Access-Control-Allow-Origin":"*"},compress:s.devServer.compress,host:"0.0.0.0",port:g,historyApiFallback:x||{index:A.endsWith("/")?A:`${A}/`,disableDotRule:!0},https:s.devServer.https,proxy:s.proxy,allowedHosts:s.devServer.allowedHosts,client:{progress:!1,logging:"info",overlay:!1},static:{watch:{ignored:e=>e.endsWith(".d.ts")||/\/node_modules\//.test(e)}},setupMiddlewares:(e,o)=>{if(!o)throw Error("webpack-dev-server is not defined");return o.app&&n($)&&$(o.app,c("mock/")),e},open:!1,hot:!0},plugins:[new v,S&&new S,new e({compilationSuccessInfo:{messages:[`You application is running here:
|
|
2
|
+
|
|
3
|
+
Local: ${o.cyan(`${D}//${s.devServer.host}:${g}${A}`)}
|
|
4
|
+
Network: ${o.cyan(`${D}//${w}:${g}${A}`)}`],notes:k?[`Port ${h(u)} is in use, trying ${f(g)} instead`]:[]},clearConsole:!0})].filter(Boolean)});
|
|
@@ -0,0 +1 @@
|
|
|
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{CUSTOMCONFIG as c}from"./process-env.js";import l from"./webpack.common.js";let{optimize:p}=m,{cssnanoMinify:a,swcMinify:u}=e,f="swc"===s.compiler?"swc":"terser",d="swc"===s.compiler?"swc":"cssnano",h=[];s.minifier&&(s.minifier.js&&h.push(new n(t(s.minifier.js?.type||f,s.minifier.js?.options))),s.minifier.css&&h.push(new e({minify:{swc:u,cssnano:a}[s.minifier.css?.type||d],minimizerOptions:s.minifier.css?.options})));let k={splitChunks:s.splitChunk,runtimeChunk:s.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,minimize:!0,minimizer:h},w=!1;s.cacheDirectory&&(w={type:"filesystem",allowCollectingMemory:!0,cacheDirectory:s.cacheDirectory,name:`${c||"default"}-production`});export default r(l,{devtool:!1===s.devtool||s.devtool?s.devtool:"cheap-module-source-map",mode:"production",cache:w,optimization:k,plugins:[new i({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),s.bundleAnalyzer&&new o(s.bundleAnalyzer),s.splitChunk&&new p.MinChunkSizePlugin({minChunkSize:1e4})].filter(Boolean)});
|
package/package.json
CHANGED
|
@@ -1,77 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.91",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "
|
|
9
|
-
"
|
|
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 --copy-files",
|
|
11
|
-
"build:types": "tsc && tsc --project cli.json",
|
|
12
|
-
"postbuild": "node ./copy.js ./prefix ./lib",
|
|
13
|
-
"prebuild": "rm -rf ./build && rm -rf ./lib"
|
|
8
|
+
"build": "swc src -d lib -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",
|
|
9
|
+
"prebuild": "rm -rf ./lib && tsc"
|
|
14
10
|
},
|
|
15
11
|
"keywords": [],
|
|
16
12
|
"author": "moneko",
|
|
17
13
|
"license": "MIT",
|
|
18
14
|
"dependencies": {
|
|
19
|
-
"@emotion/css": "11.11.0",
|
|
20
|
-
"@mapbox/rehype-prism": "0.8.0",
|
|
21
15
|
"@mdx-js/loader": "2.3.0",
|
|
22
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
|
|
23
16
|
"@soda/friendly-errors-webpack-plugin": "1.8.1",
|
|
24
|
-
"@swc/core": "1.3.
|
|
25
|
-
"@swc/css": "0.0.
|
|
17
|
+
"@swc/core": "1.3.62",
|
|
18
|
+
"@swc/css": "0.0.28",
|
|
26
19
|
"@swc/helpers": "0.5.1",
|
|
20
|
+
"@teamsupercell/typings-for-css-modules-loader": "2.5.2",
|
|
27
21
|
"add-asset-html-webpack-plugin": "6.0.0",
|
|
28
|
-
"core-js": "3.
|
|
22
|
+
"core-js": "3.31.1",
|
|
29
23
|
"cross-env": "7.0.3",
|
|
30
|
-
"css-loader": "6.
|
|
31
|
-
"css-minimizer-webpack-plugin": "5.0.
|
|
24
|
+
"css-loader": "6.8.1",
|
|
25
|
+
"css-minimizer-webpack-plugin": "5.0.1",
|
|
32
26
|
"css-unicode-loader": "1.0.3",
|
|
33
27
|
"external-remotes-plugin": "1.0.0",
|
|
34
|
-
"html-webpack-plugin": "5.5.
|
|
28
|
+
"html-webpack-plugin": "5.5.3",
|
|
35
29
|
"less": "4.1.3",
|
|
36
|
-
"less-loader": "11.1.
|
|
37
|
-
"mini-css-extract-plugin": "2.7.
|
|
30
|
+
"less-loader": "11.1.3",
|
|
31
|
+
"mini-css-extract-plugin": "2.7.6",
|
|
38
32
|
"mini-svg-data-uri": "1.4.4",
|
|
39
33
|
"path-to-regexp": "6.2.1",
|
|
40
|
-
"
|
|
41
|
-
"rehype-accessible-emojis": "0.3.2",
|
|
42
|
-
"rehype-figure": "1.0.1",
|
|
43
|
-
"style-loader": "3.3.2",
|
|
34
|
+
"style-loader": "3.3.3",
|
|
44
35
|
"style-resources-loader": "1.5.0",
|
|
45
36
|
"swc-loader": "0.2.3",
|
|
46
|
-
"swc-plugin-another-transform-imports": "0.2.
|
|
37
|
+
"swc-plugin-another-transform-imports": "0.2.4",
|
|
47
38
|
"ts-import-plugin": "3.0.0",
|
|
48
|
-
"ts-loader": "9.4.
|
|
39
|
+
"ts-loader": "9.4.4",
|
|
49
40
|
"typescript": "5.0.4",
|
|
50
|
-
"webpack": "5.
|
|
51
|
-
"webpack-bundle-analyzer": "4.
|
|
52
|
-
"webpack-cli": "5.1.
|
|
53
|
-
"webpack-dev-server": "4.15.
|
|
54
|
-
"webpack-merge": "5.
|
|
41
|
+
"webpack": "5.88.1",
|
|
42
|
+
"webpack-bundle-analyzer": "4.9.0",
|
|
43
|
+
"webpack-cli": "5.1.4",
|
|
44
|
+
"webpack-dev-server": "4.15.1",
|
|
45
|
+
"webpack-merge": "5.9.0",
|
|
46
|
+
"webpack-virtual-modules": "0.5.0",
|
|
55
47
|
"webpackbar": "5.0.2",
|
|
56
|
-
"xml2js": "0.
|
|
48
|
+
"xml2js": "0.6.1"
|
|
57
49
|
},
|
|
58
50
|
"devDependencies": {
|
|
59
|
-
"@moneko/mock": "^1.0.
|
|
51
|
+
"@moneko/mock": "^1.0.10",
|
|
60
52
|
"@moneko/postcss": "^1.0.30",
|
|
61
|
-
"@solidjs/router": "^0.8.2",
|
|
62
53
|
"@swc/cli": "0.1.62",
|
|
54
|
+
"@types/js-yaml": "^4.0.5",
|
|
63
55
|
"@types/mini-css-extract-plugin": "^2.5.1",
|
|
64
56
|
"@types/shelljs": "^0.8.12",
|
|
65
57
|
"@types/webpack-bundle-analyzer": "^4.6.0",
|
|
66
|
-
"@types/webpack-env": "^1.18.
|
|
67
|
-
"eslint-config-neko": "^1.
|
|
58
|
+
"@types/webpack-env": "^1.18.1",
|
|
59
|
+
"eslint-config-neko": "^1.1.1",
|
|
68
60
|
"shelljs": "^0.8.5",
|
|
69
|
-
"
|
|
70
|
-
"stylelint-config-moneko": "^1.0.15"
|
|
61
|
+
"stylelint-config-moneko": "^1.0.17"
|
|
71
62
|
},
|
|
72
63
|
"files": [
|
|
73
64
|
"lib",
|
|
74
|
-
"build",
|
|
75
65
|
"template",
|
|
76
66
|
"typings/global.d.ts"
|
|
77
67
|
]
|