@empjs/cli 3.0.0-beta.3 → 3.0.0-beta.30
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/client.d.ts +11 -22
- package/dist/helper/buildPrint.d.ts +15 -0
- package/dist/helper/hmr/client.d.ts +0 -0
- package/dist/helper/hmr/config.d.ts +0 -0
- package/dist/helper/hmr/index.d.ts +0 -0
- package/dist/helper/hmr/overlay.d.ts +0 -0
- package/dist/helper/hmr/process-update.d.ts +1 -0
- package/dist/helper/ipAddress.d.ts +27 -0
- package/dist/helper/logger.d.ts +1 -0
- package/dist/helper/openBrowser.d.ts +2 -0
- package/dist/helper/utils.d.ts +3 -0
- package/dist/index.js +9 -3
- package/dist/script/base.d.ts +18 -0
- package/dist/script/devServer.d.ts +0 -0
- package/dist/script/httpBase.d.ts +10 -0
- package/dist/script/serve.d.ts +5 -5
- package/dist/store/cycle/autoDevBase.d.ts +8 -0
- package/dist/store/empConfig.d.ts +12 -6
- package/dist/store/empShareLib.d.ts +17 -2
- package/dist/store/index.d.ts +5 -0
- package/dist/store/lifeCycle.d.ts +13 -5
- package/dist/store/rspack/hook.d.ts +22 -0
- package/dist/store/rspack/module.d.ts +10 -0
- package/dist/store/rspack/plugin.d.ts +1 -2
- package/dist/types/config.d.ts +69 -3
- package/package.json +117 -106
- package/resource/openChrome.applescript +95 -0
- package/template/index.html +12 -18
- package/dist/helper/prepareURLs.d.ts +0 -6
- package/dist/store/rspack/runtimePlugins.d.ts +0 -12
- /package/dist/helper/{node-polyfill.d.ts → nodePolyfill.d.ts} +0 -0
package/client.d.ts
CHANGED
|
@@ -41,11 +41,20 @@ declare module '*.webp' {
|
|
|
41
41
|
const src: string
|
|
42
42
|
export default src
|
|
43
43
|
}
|
|
44
|
-
|
|
45
44
|
declare module '*.svg' {
|
|
45
|
+
const src: string
|
|
46
|
+
export default src
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* declare module '*.svg' {
|
|
50
|
+
const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>
|
|
51
|
+
const content: string
|
|
52
|
+
export {ReactComponent}
|
|
53
|
+
export default content
|
|
54
|
+
} */
|
|
55
|
+
declare module '*.svg?react' {
|
|
46
56
|
const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>
|
|
47
57
|
const content: string
|
|
48
|
-
|
|
49
58
|
export {ReactComponent}
|
|
50
59
|
export default content
|
|
51
60
|
}
|
|
@@ -98,23 +107,3 @@ interface ImportMetaEnv {
|
|
|
98
107
|
interface ImportMeta {
|
|
99
108
|
readonly env: ImportMetaEnv
|
|
100
109
|
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* polyfill all `core-js` features, including early-stage proposals:
|
|
104
|
-
*/
|
|
105
|
-
// declare module 'core-js/full'
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* polyfill all actual features - stable ES, web standards and stage 3 ES proposals:
|
|
109
|
-
*/
|
|
110
|
-
// declare module 'core-js/actual'
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* polyfill only stable features - ES and web standards:
|
|
114
|
-
*/
|
|
115
|
-
// declare module 'core-js/stable'
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* polyfill only stable ES features:
|
|
119
|
-
*/
|
|
120
|
-
// declare module 'core-js/es'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Stats } from '@rspack/core';
|
|
2
|
+
export declare const HTML_REGEX: RegExp;
|
|
3
|
+
export declare const JS_REGEX: RegExp;
|
|
4
|
+
export declare const TS_REGEX: RegExp;
|
|
5
|
+
export declare const SCRIPT_REGEX: RegExp;
|
|
6
|
+
export declare const TS_AND_JSX_REGEX: RegExp;
|
|
7
|
+
export declare const SVG_REGEX: RegExp;
|
|
8
|
+
export declare const CSS_REGEX: RegExp;
|
|
9
|
+
export declare const LESS_REGEX: RegExp;
|
|
10
|
+
export declare const SASS_REGEX: RegExp;
|
|
11
|
+
export declare const CSS_MODULES_REGEX: RegExp;
|
|
12
|
+
export declare const NODE_MODULES_REGEX: RegExp;
|
|
13
|
+
export declare const filterAsset: (asset: string) => boolean;
|
|
14
|
+
export declare function printFileSizes(stats: Stats): Promise<void>;
|
|
15
|
+
export declare function timeDone(mis?: number | string): void;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (hash: any, moduleMap: any, options: any): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type IpAdressOpt = {
|
|
2
|
+
protocol?: string;
|
|
3
|
+
port?: number;
|
|
4
|
+
pathname?: string;
|
|
5
|
+
host?: string;
|
|
6
|
+
};
|
|
7
|
+
declare class IpAdress {
|
|
8
|
+
imf: {
|
|
9
|
+
protocol: string;
|
|
10
|
+
port: number;
|
|
11
|
+
pathname: string;
|
|
12
|
+
};
|
|
13
|
+
host: string;
|
|
14
|
+
urls: {
|
|
15
|
+
lanUrlForConfig: string;
|
|
16
|
+
lanUrlForTerminal: string;
|
|
17
|
+
localUrlForTerminal: string;
|
|
18
|
+
localUrlForBrowser: string;
|
|
19
|
+
};
|
|
20
|
+
setup(o: IpAdressOpt): void;
|
|
21
|
+
private setupUrls;
|
|
22
|
+
getLanIp(): string;
|
|
23
|
+
formatUrl(hostname: string): string;
|
|
24
|
+
prettyPrintUrl(hostname: string): string;
|
|
25
|
+
}
|
|
26
|
+
declare const _default: IpAdress;
|
|
27
|
+
export default _default;
|
package/dist/helper/logger.d.ts
CHANGED
package/dist/helper/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const getPkgVersion: (pkgPath: string) => any;
|
|
1
2
|
export declare function clearConsole(): void;
|
|
2
3
|
export declare function deepAssign<T>(target: any, ...sources: any): T;
|
|
3
4
|
export declare const ensureArray: <T>(params: T | T[]) => T[];
|
|
@@ -9,3 +10,5 @@ export declare const ensureArray: <T>(params: T | T[]) => T[];
|
|
|
9
10
|
*/
|
|
10
11
|
export declare const jsonFilter: (d?: any, notIncludeKeys?: string[]) => any;
|
|
11
12
|
export declare const vCompare: (preVersion?: string, lastVersion?: string) => number;
|
|
13
|
+
export declare const timeFormat: (seconds: number) => string;
|
|
14
|
+
export declare const importJsVm: (content: string) => string;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
var
|
|
1
|
+
var gt=Object.defineProperty;var l=(i,e)=>()=>(i&&(e=i(i=0)),e);var J=(i,e)=>{for(var t in e)gt(i,t,{get:e[t],enumerable:!0})};import{fileURLToPath as dt}from"node:url";import{dirname as yt}from"node:path";import{readFile as bt}from"node:fs/promises";import ye from"node:module";import N from"node:path";var be,vt,V,j,ve,Ce,_=l(()=>{"use strict";be=dt(import.meta.url),vt=yt(be),V=async i=>{try{let e=await bt(i);return JSON.parse(e)}catch(e){console.error(e)}},j=ye.createRequire(import.meta.url),ve=(i,e)=>{let t=j;return e&&(t=ye.createRequire(e)),t.resolve(i)},Ce=N.resolve(vt,be).replace(`${N.sep}dist${N.sep}index.js`,"")});import E from"@rspack/core";import we from"fs";var W,xe,Se=l(()=>{"use strict";W=class{store;async setup(e){this.store=e;let t=[this.define(),this.anylayze(),this.progress(),this.copy(),this.empShare(),this.minify()];await this.store.empConfig.lifeCycle.beforePlugin(),await Promise.all(t),await this.store.empConfig.lifeCycle.afterPlugin()}async anylayze(){if(!this.store.cliOptions.analyze)return;let{default:{BundleAnalyzerPlugin:e}}=await import("webpack-bundle-analyzer");this.store.chain.plugin("bundleAnalyzerPlugin").use(e,[{}])}async define(){this.store.chain.plugin("definePlugin").use(E.DefinePlugin,[this.store.empConfig.define])}async copy(){let e=this.store.resolve("public");we.existsSync(e)&&we.readdirSync(e).length>0&&this.store.chain.plugin("copyRspackPlugin").use(E.CopyRspackPlugin,[{patterns:[{from:e,to:this.store.resolve("dist")}]}])}async progress(){this.store.empConfig.debug.progress&&this.store.chain.plugin("progressPlugin").use(E.ProgressPlugin,[{prefix:"EMP"}])}async empShare(){let{version:e,isEmpshare:t}=this.store.empConfig.empShareLib;if(!t)return;let{ModuleFederationPluginV1:s,ModuleFederationPlugin:r}=E.container,n=e===1?s:r;this.store.chain.plugin("empShare").use(n,[this.store.empConfig.empShareLib.pluginConfig])}minify(){this.store.chain.optimization.minimize(this.store.mode==="production"),this.store.chain.optimization.minimizer("minJs").use(E.SwcJsMinimizerRspackPlugin,[this.store.empConfig.build.minOptions]),this.store.chain.optimization.minimizer("minCss").use(E.SwcCssMinimizerRspackPlugin,[{}])}},xe=new W});import Ct from"chalk";import wt from"fs-extra";function Oe(){process.stdout.write(process.platform==="win32"?"\x1B[2J\x1B[0f":"\x1B[2J\x1B[3J\x1B[H")}function f(i,...e){for(let t of e)for(let s in t){let r=t[s],n=i[s];if(Object(r)==r&&Object(n)===n){i[s]=f(n,r);continue}i[s]=t[s]}return i}var Ee,T,Pe,$e,y=l(()=>{"use strict";Ee=i=>{try{let{version:e}=wt.readJSONSync(i);return e}catch{return}};T=(i="",e="")=>{let t=i.replace("^","").split("."),s=e.replace("^","").split("."),r=Math.max(t.length,s.length),n=0;for(let p=0;p<r;p++){let c=t.length>p?t[p]:0,g=isNaN(Number(c))?c.charCodeAt():Number(c),P=s.length>p?s[p]:0,m=isNaN(Number(P))?P.charCodeAt():Number(P);if(g<m){n=-1;break}else if(g>m){n=1;break}}return n},Pe=i=>{i=i/1e3;let e=s=>Ct.bold(s);if(i<1)return`${i*1e3} ms`;if(i<10){let s=i>=.01?2:3;return`${e(i.toFixed(s))} s`}if(i<60)return`${e(i.toFixed(1))} s`;let t=i/60;return`${e(t.toFixed(2))} m`},$e=i=>`data:text/javascript,${i}`});import ke from"node:path";var X,je,Te=l(()=>{"use strict";_();y();X=class{store;swcJsOptions={};swcTsOptions={};coreJs={version:"3",alias:"",path:""};async setup(e){this.store=e;let t=[this.react(),this.files(),this.scripts()];await Promise.all(t)}get isPolyfill(){return this.store.empConfig.build.polyfill}swcParser(e){switch(e){case"js":return{syntax:"ecmascript",jsx:!0,decorators:!0,decoratorsBeforeExport:!1};case"ts":return{syntax:"typescript",decorators:!0,tsx:!0,dynamicImport:!0}}}get swcTransform(){let{isDev:e}=this.store;return this.store.reactVersion?{react:{runtime:this.store.empConfig.reactRuntime,development:e,refresh:e}}:{}}swcJsc(e){let{target:t,externalHelpers:s}=this.store.empConfig.build;return{parser:this.swcParser(e),transform:this.swcTransform,target:t,externalHelpers:s,preserveAllComments:!0}}get swcCoreVersion(){let[e,t]=this.coreJs.version.split(".");return`${e}.${t}`}swcOptions(e){let t={jsc:this.swcJsc(e),isModule:"unknown"};return this.isPolyfill&&(delete t.jsc.target,t.env={coreJs:this.swcCoreVersion,targets:this.store.empConfig.build.browserslist},this.store.empConfig.isESM||(t.env.mode=this.store.empConfig.build.polyfill),this.store.empConfig.build.polyfill==="usage"&&(t.env.shippedProposals=!0,t.env.include=["es.object.values","es.array.flat"])),t}swcInitOptions(){let{externalHelpers:e}=this.store.empConfig.build;e&&this.store.chain.resolve.alias.set("@swc/helpers",ke.dirname(j.resolve("@swc/helpers/package.json"))),this.coreJs.path=j.resolve("core-js/package.json");let t=Ee(this.coreJs.path);t&&(this.coreJs.version=t),this.coreJs.alias=ke.dirname(this.coreJs.path),this.store.empConfig.build.polyfill&&(this.store.chain.resolve.alias.set("core-js",this.coreJs.alias),this.store.chain.module.rule("javascript").exclude.add(/core-js/),this.store.chain.module.rule("typescript").exclude.add(/core-js/)),this.swcTsOptions=this.swcOptions("ts"),this.swcJsOptions=this.swcOptions("js")}async scripts(){this.swcInitOptions();let e=!1,t=[];this.store.chain.merge({module:{parser:{javascript:{exportsPresence:"error",importExportsPresence:"error"}},rule:{mjs:{test:/\.m?js/,resolve:{fullySpecified:!1}},typescript:{test:/\.(ts|tsx)$/,exclude:t,sideEffects:e,use:[{loader:"builtin:swc-loader",options:this.swcTsOptions}]},javascript:{test:/\.(js|jsx)$/,exclude:t,sideEffects:e,use:[{loader:"builtin:swc-loader",options:this.swcJsOptions}]}}}})}async react(){if(this.store.reactVersion&&this.store.isDev&&this.store.empConfig.react.hmr){let{default:e}=await import("@rspack/plugin-react-refresh"),t={};this.store.empConfig.empShareLib.config.name&&(t.library=this.store.empConfig.empShareLib.config.name),this.store.chain.plugin("plugin-react-refresh").use(e,[t])}}async files(){let e=new RegExp(`${this.store.empConfig.react.svgrQuery}`);this.store.chain.merge({module:{rule:{svg:{test:/\.svg$/,oneOf:[{issuer:/\.[jt]sx?$/,resourceQuery:e,use:[{loader:this.store.importResolve("@svgr/webpack"),options:{}}]},{resourceQuery:{not:[e]},type:"asset/resource"}]}}}}),this.store.chain.merge({module:{rule:{inline:{resourceQuery:/inline/,type:"asset/inline"}}}}),this.store.chain.merge({module:{rule:{image:{test:/\.(png|jpe?g|gif|webp|ico)$/i,type:"asset/resource"},fonts:{test:/\.(|otf|ttf|eot|woff|woff2)$/i,type:"asset/resource"},svga:{test:/\.(svga)$/i,type:"asset/resource"}}}})}},je=new X});var q,Re,De=l(()=>{"use strict";q=class{store;async setup(e){this.store=e;let t=[this.common(),this.stats(),this.devServer(),this.optimization()];await Promise.all(t)}async common(){this.store.merge({node:{global:!0},experiments:{rspackFuture:{newTreeshaking:this.store.empConfig.isESM},outputModule:this.store.empConfig.isESM,topLevelAwait:!0},target:this.store.empConfig.target,infrastructureLogging:this.store.empConfig.debug.infrastructureLogging,context:this.store.root,mode:this.store.mode,cache:this.store.empConfig.debug.rspackCache,devtool:this.store.empConfig.build.sourcemap?"source-map":!1,builtins:{css:{modules:{localIdentName:this.store.isDev?"[path][name]-[local]-[hash:5]":"[local]-[hash:5]"}}},output:this.store.empConfig.output,resolve:this.store.empConfig.resolve,externals:this.store.empConfig.externals})}async stats(){this.store.merge({stats:{colors:!0,all:!1,assets:!1,chunks:!1,timings:!0,version:!0}})}async devServer(){this.store.merge({devServer:this.store.empConfig.server})}async optimization(){let e={moduleIds:this.store.empConfig.build.moduleIds,chunkIds:this.store.empConfig.build.chunkIds,minimize:this.store.empConfig.build.minify,splitChunks:{chunks:"async",cacheGroups:{}}};this.store.empConfig.build.polyfill&&(e.splitChunks.cacheGroups={}),this.store.chain.merge({optimization:e})}},Re=new q});import Me from"html-webpack-plugin";var Le,R,Fe,D,xt,L,Q=l(()=>{"use strict";y();u();Le="HtmlImportMapPlugin",R=class{importMap;constructor(e){this.importMap=e}apply(e){e.hooks.compilation.tap(Le,t=>{Me.getHooks(t).alterAssetTagGroups.tapAsync(Le,(s,r)=>{s.headTags.push({tagName:"script",attributes:{type:"importmap"},innerHTML:`${JSON.stringify(this.importMap,null,2)}`,voidTag:!1,meta:{plugin:void 0}}),r(null,s)})})}},Fe="HtmlEmpShareLibPlugin",D=class{files;constructor(e){this.files=f({js:[],css:[]},e)}apply(e){e.hooks.compilation.tap(Fe,t=>{let s=this.files;Me.getHooks(t).alterAssetTagGroups.tapAsync(Fe,(r,n)=>{s.js.map(p=>{r.headTags.push({tagName:"script",attributes:{src:p},voidTag:!1,meta:{plugin:void 0}})}),s.css.map(p=>{r.headTags.push({tagName:"link",attributes:{rel:"stylesheet",href:p},voidTag:!1,meta:{plugin:void 0}})}),n(null,r)})})}},xt=()=>{let i=[`import 'core-js/${o.empConfig.build.coreJsFeatures}'`].join(`
|
|
2
|
+
`);return $e(i)},L=class{constructor(){}apply(e){let{webpack:t}=e;new t.EntryPlugin(e.context,xt(),{name:void 0}).apply(e)}}});import St from"html-webpack-plugin";import Et from"fast-glob";import x from"node:path";var Y,Ae,Be=l(()=>{"use strict";y();Q();Y=class{store;entriesConfig={};async setup(e){this.store=e,await this.init(),this.toConfig()}setHtmlConfig(e,t){return e.template=this.setTemplate(e.template),e.favicon=this.setFavicion(e.favicon),e.chunks=t,e.filename=`${t[0]}.html`,this.store.empConfig.base&&(e.publicPath=this.store.empConfig.base),e.tags=e.tags||{},e}setChunk(e){return e.replace(x.extname(e),"").replace(`${this.store.empConfig.appSrc}${x.sep}`,"")}setTemplate(e){return e?this.store.resolve(e):this.store.empResolve(x.join("template","index.html"))}setFavicion(e){return e?this.store.resolve(e):this.store.empResolve(x.join("template","favicon.ico"))}setEntryItem(e,t,s){s=s||this.store.resolve(x.join(this.store.empConfig.appSrc,e));let r=this.setChunk(e),n=[s];this.entriesConfig[r]={entry:{[r]:n},html:this.setHtmlConfig(t,[r])}}setRspackHtmlPlugin(e,t){this.store.chain.plugin(`html-plugin-${t}`).use(St,[e]),this.store.empConfig.empShareLib&&(e.files=f(e.files,this.store.empConfig.empShareLib.externalAssets)),this.store.chain.plugin(`html-plugin-empShare-${t}`).use(D,[e.files]),this.store.empConfig.empShareLib.useImportMap&&this.store.chain.plugin(`html-plugin-import-map-${t}`).use(R,[this.store.empConfig.empShareLib.importMap])}setRspackEntry(e){this.store.merge({entry:e})}async init(){let e=x.join(this.store.appSrc,this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index.{ts,tsx,jsx,js}").replace(/\\/g,"/"),t=await Et([e]);if(t[0]){let s=x.join(this.store.empConfig.appSrc,Object.keys(this.store.empConfig.entries).length>0&&this.store.empConfig.appEntry?this.store.empConfig.appEntry:"index");this.setEntryItem(s,this.store.empConfig.html,t[0])}if(Object.keys(this.store.empConfig.entries).length>0)for(let[s,r]of Object.entries(this.store.empConfig.entries))this.setEntryItem(s,{...this.store.empConfig.html,...r})}toConfig(){for(let[e,t]of Object.entries(this.entriesConfig))this.setRspackHtmlPlugin(t.html,e),this.setRspackEntry(t.entry)}},Ae=new Y});var Z,ze,Ge=l(()=>{"use strict";Z=class{store;async setup(e){this.store=e;let t=[this.sass(),this.less(),this.css()];await Promise.all(t)}async sass(){let e={loader:this.store.importResolve("sass-loader"),options:{}};this.store.chain.merge({module:{rule:{sass:{test:/\.(sass|scss)$/,use:{postcss:this.postcss,sassLoader:e},type:"css/auto"}}}})}async less(){let e={loader:this.store.importResolve("less-loader"),options:{lessOptions:{javascriptEnabled:!0}}};this.store.chain.merge({module:{rule:{less:{test:/\.less$/,use:{postcss:this.postcss,lessLoader:e},type:"css/auto"}}}})}async css(){this.store.chain.merge({module:{rule:{css:{test:/\.css$/,use:{postcss:this.postcss},type:"css/auto"}}}})}get postcss(){return{loader:this.store.importResolve("postcss-loader"),options:{postcssOptions:{plugins:this.store.empConfig.css.postcss}}}}},ze=new Z});var K,He,Ie=l(()=>{"use strict";Se();Te();De();Be();Ge();K=class{store;async setup(e){this.store=e;let t=[Re.setup(this.store),je.setup(this.store),xe.setup(this.store),Ae.setup(this.store),ze.setup(this.store)];await Promise.all(t),await this.store.empConfig.plugins(),await this.store.empConfig.chain()}},He=new K});import h from"chalk";import{table as Ot}from"table";var ee,a,b=l(()=>{"use strict";ee=class{pname="";logLevel="debug";setup({pname:e,logLevel:t}){this.pname=e,t&&(this.logLevel=t)}debug=(...e)=>["debug"].includes(this.logLevel)&&console.log(...e);info=(...e)=>["debug","info"].includes(this.logLevel)&&console.log(...e);warn=(...e)=>["debug","info","warn"].includes(this.logLevel)&&console.warn(...e);error=(...e)=>["debug","info","warn","error"].includes(this.logLevel)&&console.error(...e);blue=e=>{console.log(`${h.white.bgBlue(this.pname)}${h.blue.bgWhite(` ${e} `)}
|
|
2
3
|
`)};cyan=e=>{console.log(`${h.white.bgCyan(this.pname)}${h.cyan.bgWhite(` ${e} `)}
|
|
3
4
|
`)};magenta=e=>{console.log(`${h.white.bgMagenta(this.pname)}${h.magenta.bgWhite(` ${e} `)}
|
|
4
5
|
`)};green=e=>{console.log(`${h.white.bgGreen(this.pname)}${h.green.bgWhite(` ${e} `)}
|
|
5
6
|
`)};yellow=e=>{console.log(`${h.white.bgYellow(this.pname)}${h.yellow.bgWhite(` ${e} `)}
|
|
6
7
|
`)};red=e=>{console.log(`${h.white.bgRed(this.pname)}${h.red.bgWhite(` ${e} `)}
|
|
7
8
|
`)};sysError=e=>{console.log(`${h.white.bgRed(" System Error Tips ")}${h.red.bgWhite(` ${e} `)}
|
|
8
|
-
`)};link=e=>h.hex("#3498db")(e);tableData=[];tableConfig={border:{topBody:"\u2500",topJoin:"\u252C",topLeft:"\u250C",topRight:"\u2510",bottomBody:"\u2500",bottomJoin:"\u2534",bottomLeft:"\u2514",bottomRight:"\u2518",bodyLeft:"\u2502",bodyRight:"\u2502",bodyJoin:"\u2502",joinBody:"\u2500",joinLeft:"\u251C",joinRight:"\u2524",joinJoin:"\u253C"}};tableInput(e){this.tableData.push(e)}tableOutput(){console.log(Je(this.tableData,this.tableConfig))}},a=new G});var P,ge=c(()=>{"use strict";P=class{externals={};externalAssets={js:[],css:[]};exp=/^([0-9a-zA-Z_\s]+)@(.*)/;async setup(e){this.setShareLib(e),delete e.shareLib}async setShareLib(e){let t=[];if(typeof e.shareLib=="object")for(let[s,r]of Object.entries(e.shareLib)){let i={};if(i.module=s,typeof r=="string"){let n=r.match(this.exp)||[];n.length>0?(i.global=n[1],i.entry=n[2],i.type="js",t.push(i),i={}):(i.global="",i.entry=r,i.type="js",t.push(i),i={})}else Array.isArray(r)?r.map(n=>{if(!n)return;if(n.split("?")[0].endsWith(".css"))i.entry=n,i.type="css";else{let l=n.match(this.exp)||[];l.length>0?(i.global=l[1],i.entry=l[2],i.type="js"):(i.global="",i.entry=n,i.type="js")}t.push(i),i={}}):typeof r=="object"&&r.entry&&(i.entry=r.entry,i.global=r.global,i.type=r.type,t.push(i),i={})}await Promise.all([this.setExternalAssets(t)])}async setExternalAssets(e=[]){if(e.length>0){let t=[];t=t.concat(e),t.map(s=>{s.type=s.type||"js",s.type==="js"&&s.module?(s.global&&(this.externals[s.module]=s.global),s.entry&&this.externalAssets.js.push(s.entry)):s.type==="css"&&s.entry&&this.externalAssets.css.push(s.entry)})}}}});import Ue from"node:fs";var I,de,ye=c(()=>{"use strict";E();ge();I=class{store;appSrc="src";appEntry="";base="";assign(e,t){return t=t||{},S(e,t)}empShareLib=new P;async setup(e){this.store=e,await this.syncEmpOptions();let{appSrc:t,base:s,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),r&&(this.appEntry=r),this.store.empOptions.empShare?.shareLib&&await this.empShareLib.setup(this.store.empOptions.empShare)}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){return this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"";return this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",sourcemap:!0,minify:!this.store.isDev,minOptions:{}},{...this.store.empOptions.build,staticDir:e})}get html(){return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,meta:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"}},files:{css:[],js:[]},tags:{headTags:[],bodyTags:[]}},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get react(){return this.assign({hmr:!0,svgr:!1},this.store.empOptions.react)}get server(){return this.assign({host:"0.0.0.0",port:8e3,open:!1,hot:!0,allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}},this.store.empOptions.server)}get empShare(){return this.assign({name:"",filename:"emp.js",shared:{}},this.store.empOptions.empShare)}get css(){return this.assign({postcss:[]},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),{assetsDir:t,staticDir:s}=this.store.empConfig.build;return this.assign({publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${s}js/[name]${e}.js`,cssFilename:`${s}css/[name]${e}.css`,cssChunkFilename:`${s}css/[name]${e}.css`,assetModuleFilename:`${s}${t}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0},this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:"cjs",s={};return Object.keys(e).map(r=>{(t==="all"||t==="esm")&&(s[`import.meta.env.${r}`]=JSON.stringify(e[r])),(t==="all"||t==="cjs")&&(s[`process.env.${r}`]=JSON.stringify(e[r])),s[`${r}`]=JSON.stringify(e[r])}),s}get externals(){return this.assign(this.empShareLib.externals,this.store.empOptions.externals)}get resolve(){return S({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){let e=this.store.resolve("emp-config.js");if(!Ue.existsSync(e))return;let{default:t}=await import(this.store.importFileUrl(e));typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{}}get moduleTransformRule(){let e={and:[/(node_modules|bower_components)/]},{moduleTransform:t}=this.store.empOptions;return t?.exclude&&(e.and=t.exclude),t?.include&&(e.not=t.include),e}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get reactRuntime(){if(this.store.reactVersion)return this.store.empOptions.reactRuntime?this.store.empOptions.reactRuntime:O(this.store.reactVersion,"17")>-1?"automatic":"classic"}},de=new I});import v from"node:path";import Ve from"webpack-chain";import{pathToFileURL as ze}from"node:url";var H,p,g=c(()=>{"use strict";ee();fe();b();ye();H=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=K;empSource=v.resolve(this.empRoot,"dist");resolve=e=>v.isAbsolute(e)?e:v.resolve(this.root,e);empResolve=e=>v.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};cacheDir="";mode="development";cliMode="dev";isDev=!0;reactVersion=void 0;cliOptions;chain;rsConfig;empOptions={};empConfig;async setup(e,t){await this.initVars(e,t),this.empConfig=de,await this.empConfig.setup(this),this.initPaths(),this.chain=new Ve,await ue.setup(this),this.setLogger(),this.toConfig(),this.logConfig()}async initVars(e,t){this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development";let s=await D(this.empResolve("package.json")),r=await D(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...r},this.reactVersion=this.pkg.dependencies.react||this.pkg.devDependencies.react}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir),this.resource.dir=v.join(this.empRoot,"resource"),this.resource.cert=v.join(this.resource.dir,"emp.cert"),this.resource.key=v.join(this.resource.dir,"emp.key")}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.empConfig.debug.loggerLevel&&(e=this.empConfig.debug.loggerLevel),a.setup({pname:` EMP v${this.empPkg.version} ${this.cliMode==="dev"?"DEV ":""}`,logLevel:e})}merge(e){this.chain.merge(e)}importResolve(e,t){return Z(e,t)}importFileUrl(e){return ze(e).toString()}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){this.empConfig.debug.showRsconfig&&console.log("[ChainConfig]",JSON.stringify(this.rsConfig,null,2))}},p=new H});import be from"node:fs/promises";var d,j=c(()=>{"use strict";b();g();E();d=class{async setup(e,t){await p.setup(e,t),p.empConfig.debug.clearLog&&ae(),a.blue(`${e} Running`),await this.run()}async run(){}get isHttps(){let{server:e,https:t}=p.rsConfig.devServer||{};return e==="https"||typeof e=="object"&&e.type==="https"||t===!0}getcert(){return Promise.all([be.readFile(p.resource.key),be.readFile(p.resource.cert)])}}});import Be from"net";import We from"os";async function k(o,e="localhost"){if(o!==_e&&(o<ve||o>J))throw new Error(`Port number must lie between ${ve} and ${J}`);let t=o,s=qe(),r;e&&!s.has(e)?r=new Set([e]):r=s;let i=new Set(["EADDRINUSE","EACCES"]);for(;t<=J;)try{return await Xe(t,r)}catch(n){if(!i.has(n.code))throw n;t+=1}throw new Error("No available ports found")}var ve,J,_e,qe,Qe,Xe,U=c(()=>{"use strict";ve=1024,J=65535,_e=443,qe=()=>{let o=We.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(o))if(t)for(let s of t)e.add(s.address);return e},Qe=(o,e)=>new Promise((t,s)=>{let r=Be.createServer();r.unref(),r.on("error",s),r.listen(o,e,()=>{let{port:i}=r.address();r.close(()=>{t(i)})})}),Xe=async(o,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await Qe(o,s)}catch(r){if(!t.has(r.code))throw r}return o}});var Ce={};$(Ce,{default:()=>Ke});import{rspack as Ye}from"@rspack/core";import{RspackDevServer as Ze}from"@rspack/dev-server";var V,Ke,xe=c(()=>{"use strict";g();j();b();U();V=class extends d{async run(){let e=Ye(p.rsConfig);if(!p.rsConfig.devServer){a.error("devServer is not defined in config");return}let t=Object.assign({},p.rsConfig.devServer),{host:s,port:r}=t;if(this.isHttps&&(t.https===!0&&delete t.https,!t.server)){let[m,l]=await this.getcert();t.server={type:"https",options:{key:m,cert:l}}}let i=await k(Number(r),s);i!==r&&(p.rsConfig.devServer.port=i,t.port=i),new Ze(t,e).start()}},Ke=new V});var we={};$(we,{default:()=>tt});import{rspack as et}from"@rspack/core";var z,tt,Se=c(()=>{"use strict";b();g();j();z=class extends d{async run(){et(p.rsConfig,(e,t)=>{if(e!==null){a.error(e.stack||e),e.message&&a.error(e.message);return}if(!t){a.red("Stats is Undefined.");return}t.hasErrors()&&(a.error(t.toString({colors:!0,children:!0})),a.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(a.yellow("Compiled with warnings."),a.warn(t.toString({colors:!0,children:!0}))),a.info(t.toString({all:!1,colors:!0,assets:!0,chunks:!1,entrypoints:!0,timings:!0,version:!0})),a.green("Compiled successfully.")})}},tt=new z});import Ee from"url";import Oe from"chalk";import{ip as st}from"address";import{gateway4sync as rt}from"default-gateway";function Pe(o,e,t,s="/"){let r=x=>Ee.format({protocol:o,hostname:x,port:t,pathname:s}),i=x=>Ee.format({protocol:o,hostname:x,port:Oe.bold(t),pathname:s}),n=e==="0.0.0.0"||e==="::",m,l,u=Oe.gray("unavailable");if(n){m="localhost";try{let{int:x}=rt();l=st(x||""),l&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(l)?u=i(l):l=void 0)}catch{}}else m=e,l=e,u=i(l);let f=i(m),Q=r(m);return{lanUrlForConfig:l,lanUrlForTerminal:u,localUrlForTerminal:f,localUrlForBrowser:Q}}var je=c(()=>{"use strict"});var $e={};$($e,{default:()=>lt});import ke from"express";import it from"cors";import ot from"compression";import nt from"https";import pt from"path";import at from"node:fs/promises";var B,lt,Re=c(()=>{"use strict";U();je();g();b();j();B=class extends d{app;startLogger({host:e,port:t,publicPath:s}){if(s&&(s.indexOf("http://")>-1||s.indexOf("https://")>-1))a.info(`- Network: ${a.link(s)}`);else{let r=this.isHttps?"https":"http",n=Pe(r,e||"0.0.0.0",t,s);a.info(`- Local: ${a.link(n.localUrlForTerminal)}`),a.info(`- Network: ${a.link(n.lanUrlForTerminal)}`)}}async run(){let e=ke();e.use(ot()),e.use(it()),this.app=e;let t=p.resolve(p.rsConfig.output?.path);this.app.use(ke.static(t));let s=await at.readFile(pt.join(t,"index.html"),"utf8");this.app.get("*",(u,f)=>f.send(s));let r=Object.assign({},p.rsConfig.devServer),{host:i,port:n}=r,m=p.rsConfig.output?.publicPath==="auto"?"/":p.rsConfig.output?.publicPath,l=await k(Number(n),i);if(this.isHttps){let[u,f]=await this.getcert();nt.createServer(typeof this.isHttps!="boolean"?this.isHttps:{key:u,cert:f},this.app).listen(l,()=>{this.startLogger({host:i,port:l,publicPath:m})})}else this.app.listen(l,()=>{this.startLogger({host:i,port:l,publicPath:m})})}},lt=new B});g();g();E();b();import{program as C}from"commander";import W,{exit as ct}from"node:process";function De(){let o="20.0.0";O(o,W.versions.node)===1&&(a.sysError(`\u5F53\u524D\u7248\u672C\u4E3Av${W.versions.node} \u6700\u4F4E\u8981\u6C42\u4E3Av${o}`),ct(0)),C.version(p.empPkg.version,"-v, --version").usage("<command> [options]"),C.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-h, --hot","\u662F\u5426\u4F7F\u7528\u70ED\u66F4\u65B0 \u9ED8\u8BA4\u542F\u52A8").option("-o, --open","\u662F\u5426\u6253\u5F00\u8C03\u8BD5\u9875\u9762 \u9ED8\u8BA4\u4E0D\u6253\u5F00").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async e=>{let{default:t}=await Promise.resolve().then(()=>(xe(),Ce));await t.setup("dev",e)}),C.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-a, --analyze","\u751F\u6210\u5206\u6790\u62A5\u544A \u9ED8\u8BA4\u4E3A false").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async e=>{let{default:t}=await Promise.resolve().then(()=>(Se(),we));await t.setup("build",e)}),C.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async e=>{let{default:t}=await Promise.resolve().then(()=>(Re(),$e));await t.setup("serve",e)}),C.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(e=>{}),C.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(e=>{}),C.parse(W.argv)}g();import mt from"fast-glob";import Te from"node:fs/promises";import _ from"node:path";var ht=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,ut=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,ft=/import\(['"]([^;\n]+?)['"]\)/,q=class{list=[];outDir=p.resolve("dist");aliasName="@empjs/cli";async setup(e,t){e&&(this.outDir=e),t&&(this.aliasName=t);let s=await this.readDts();await this.writeCode(s)}async readDts(){this.list=await mt([`${p.empConfig.build.outDir}/**/*.d.ts`]);let e=[];this.list.map(s=>{s=p.resolve(s),e.push(this.readFile(s))});let t=await Promise.all(e);return t=t.map(s=>this.replaceAliasPath(s)),t}async readFile(e){let t=await Te.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(ht,r=>{let i=r.match(ut);if(i||(i=r.match(ft)),i&&i[1]){let n=i[1];if(!n.startsWith("."))return r;let m=_.resolve(_.dirname(e),n).replace(this.outDir,this.aliasName);return r.replace(i[1],m)}return r});let s=e.replace(this.outDir,this.aliasName).replace(".d.ts","");return s.endsWith("/index")&&(s=s.replace("/index","")),t=this.warpDeclareModule(s,t),{code:t,src:e,mod:s}}warpDeclareModule(e,t){return`declare module '${e}' {\r
|
|
9
|
+
`)};link=e=>h.hex("#3498db")(e);title=e=>{console.log(`${h.greenBright.bold(`${this.pname}`)} ${h.bgGreenBright(` ${e} `)}
|
|
10
|
+
`)};tableData=[];tableConfig={border:{topBody:"\u2500",topJoin:"\u252C",topLeft:"\u250C",topRight:"\u2510",bottomBody:"\u2500",bottomJoin:"\u2534",bottomLeft:"\u2514",bottomRight:"\u2518",bodyLeft:"\u2502",bodyRight:"\u2502",bodyJoin:"\u2502",joinBody:"\u2500",joinLeft:"\u251C",joinRight:"\u2524",joinJoin:"\u253C"}};tableInput(e){this.tableData.push(e)}tableOutput(){console.log(Ot(this.tableData,this.tableConfig))}},a=new ee});var F,Ue=l(()=>{"use strict";u();F=class{externals={};externalAssets={js:[],css:[]};exp=/^([0-9a-zA-Z_\s]+)@(.*)/;config;importMap={imports:{}};version;isEmpshare=!1;async setup(){this.config=o.empConfig.empShare,this.version=o.empConfig.empShare.mfVersion,this.isEmpshare=!!o.empConfig.empShare.name,this.config.shareLib&&this.setShareLib(),this.prepareEsm()}get useImportMap(){return this.config.useImportMap&&o.empConfig.isESM}get pluginConfig(){let e={...this.config,implementation:o.importResolve("@module-federation/runtime")};return delete e.mfVersion,delete e.shareLib,delete e.useImportMap,e}prepareEsm(){if(o.empConfig.isESM){this.config.library={type:"module"};let e=this.config.remotes||{};for(let[t,s]of Object.entries(e))if(typeof s=="string"){let r=s.match(this.exp)||[];r.length>0&&(e[t]=r[2])}this.config.remotes=e}}async setShareLib(){let e=this.config,t=[];if(typeof e.shareLib=="object")for(let[s,r]of Object.entries(e.shareLib)){let n={};if(n.module=s,typeof r=="string"){let p=r.match(this.exp)||[];p.length>0?(n.global=p[1],n.entry=p[2],n.type="js",t.push(n),n={}):(n.global="",n.entry=r,n.type="js",t.push(n),n={})}else Array.isArray(r)?r.map(p=>{if(!p)return;if(p.split("?")[0].endsWith(".css"))n.entry=p,n.type="css";else{let g=p.match(this.exp)||[];g.length>0?(n.global=g[1],n.entry=g[2],n.type="js"):(n.global="",n.entry=p,n.type="js")}t.push(n),n={}}):typeof r=="object"&&r.entry&&(n.entry=r.entry,n.global=r.global,n.type=r.type,t.push(n),n={})}await Promise.all([this.setExternalAssets(t)])}async setExternalAssets(e=[]){if(e.length>0){let t=[];t=t.concat(e),t.map(s=>{s.type=s.type||"js",s.type==="js"&&s.module?(s.global?this.externals[s.module]=s.global:o.empConfig.isESM&&(this.useImportMap?(this.externals[s.module]=s.module,this.importMap.imports[s.module]=s.entry):this.externals[s.module]=s.entry),s.entry&&!o.empConfig.isESM&&this.externalAssets.js.push(s.entry)):s.type==="css"&&s.entry&&this.externalAssets.css.push(s.entry)})}}}});import Je from"url";import Ne from"chalk";import{ip as Pt}from"address";import{gateway4sync as $t}from"default-gateway";var te,O,se=l(()=>{"use strict";te=class{imf={protocol:"",port:8e3,pathname:"/"};host="0.0.0.0";urls={lanUrlForConfig:"",lanUrlForTerminal:Ne.gray("unavailable"),localUrlForTerminal:"",localUrlForBrowser:""};setup(e){e.host&&(this.host=e.host),e.protocol&&(this.imf.protocol=e.protocol),e.pathname&&(this.imf.pathname=e.pathname),e.port&&(this.imf.port=e.port),this.setupUrls()}setupUrls(){let{host:e}=this,t=e==="0.0.0.0"||e==="::",s;if(t){s="localhost";try{this.urls.lanUrlForConfig=this.getLanIp(),this.urls.lanUrlForConfig&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(this.urls.lanUrlForConfig)?this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig):this.urls.lanUrlForConfig="")}catch{}}else s=e,this.urls.lanUrlForConfig=e,this.urls.lanUrlForTerminal=this.prettyPrintUrl(this.urls.lanUrlForConfig);this.urls.localUrlForTerminal=this.prettyPrintUrl(s),this.urls.localUrlForBrowser=this.formatUrl(s)}getLanIp(){let{int:e}=$t();return Pt(e||"")||"127.0.0.1"}formatUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return Je.format({protocol:t,hostname:e,port:s,pathname:r})}prettyPrintUrl(e){let{protocol:t,port:s,pathname:r}=this.imf;return Je.format({protocol:t,hostname:e,port:Ne.bold(s),pathname:r})}},O=new te});var ie,M,re=l(()=>{"use strict";se();y();u();ie=class{isADB=!1;isHttps=!1;get isHttpBase(){let e=o.empOptions.base||"";return e.indexOf("http://")>-1||e.indexOf("https://")>-1}setup(){if(this.isADB=!!o.empOptions.autoDevBase&&o.mode==="development"&&!this.isHttpBase,!this.isADB)return;let{server:e,https:t}=o.empOptions.server||{};this.isHttps=e==="https"||typeof e=="object"&&e.type==="https"||t===!0;let s=O.getLanIp(),r=this.isHttps?"https":"http",n=o.empOptions.server?.port||8e3;o.empOptions.base=`${r}://${s}:${n}/`,o.empOptions.server=f({port:n,client:{webSocketURL:`${this.isHttps?"wss":"ws"}://${s}:${n}/ws`}},o.empOptions.server)}},M=new ie});var A,Ve=l(()=>{"use strict";re();u();Q();A=class{op={};constructor(e={}){this.op=e}async afterGetEmpOptions(){M.setup(),this.op.afterGetEmpOptions&&await this.op.afterGetEmpOptions()}async beforePlugin(){o.empConfig.build.polyfill==="entry"&&o.chain.plugin("empPolyfill").use(L),this.op.beforePlugin&&await this.op.beforePlugin()}async afterPlugin(){this.op.afterPlugin&&await this.op.afterPlugin()}async beforeBuild(){this.op.beforeBuild&&await this.op.beforeBuild()}async afterBulid(){this.op.afterBulid&&await this.op.afterBulid()}async beforeDevServe(){console.log(this.op),this.op.beforeDevServe&&await this.op.beforeDevServe()}async afterDevServe(){this.op.afterDevServe&&await this.op.afterDevServe()}async beforeServe(){this.op.beforeServe&&await this.op.beforeServe()}async afterServe(){this.op.afterServe&&await this.op.afterServe()}}});import kt from"node:fs";var oe,_e,We=l(()=>{"use strict";y();Ue();Ve();oe=class{store;appSrc="src";appEntry="";base="";target=[];assign(e,t){return t=t||{},f(e,t)}empShareLib=new F;isESM=!1;async autoDevSet(){this.store.mode==="development"&&this.store.empOptions.autoDevBase}checkIsESM(e){return["es3","es5"].indexOf(e)===-1}lifeCycle;async setup(e){this.store=e,await this.syncEmpOptions(),this.lifeCycle=new A(this.store.empOptions.lifeCycle),await this.lifeCycle.afterGetEmpOptions(),this.isESM=this.checkIsESM(this.build.target),this.store.empOptions.target?(this.target=this.store.empOptions.target,Array.isArray(this.target)&&!this.target.includes(this.build.target)&&this.target.push(this.build.target)):this.target=["web",this.build.target];let{appSrc:t,base:s,appEntry:r}=this.store.empOptions;t&&(this.appSrc=t),s&&(this.base=s),r&&(this.appEntry=r),this.store.empConfig.empShare&&await this.empShareLib.setup()}async chain(){this.store.empOptions.chain&&await this.store.empOptions.chain(this.store.chain)}async plugins(){let e=[];this.store.empOptions.plugins&&Array.isArray(this.store.empOptions.plugins)&&this.store.empOptions.plugins.length>0&&(this.store.empOptions.plugins.map(t=>{e.push(t.rsConfig(this.store))}),await Promise.all(e))}get debug(){return this.assign({loggerLevel:"info",clearLog:!0,progress:!0,showRsconfig:!1,showPerformance:!1,rspackCache:!0,infrastructureLogging:{appendOnly:!0,level:"warn"}},this.store.empOptions.debug)}get build(){let e=this.store.empOptions.build?.staticDir?`${this.store.empOptions.build?.staticDir}/`:"";return this.assign({outDir:"dist",staticDir:e,assetsDir:"assets",publicDir:"public",chunkIds:this.store.isDev?"named":"deterministic",moduleIds:this.store.isDev?"named":"deterministic",sourcemap:!0,minify:!this.store.isDev,minOptions:{},target:"es5",polyfill:!1,coreJsFeatures:"stable",externalHelpers:!1,browserslist:this.store.browserslistOptions.default},{...this.store.empOptions.build,staticDir:e})}get html(){let e=this.store.empOptions.html?.template?[]:{charset:{charset:"utf-8"},"http-equiv":{"http-equiv":"X-UA-Compatible",content:"IE=edge"},viewport:{content:"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"},keywords:{keywords:""},description:{description:""}};return this.assign({lang:"zh-CN",title:"EMP",inject:"body",minify:!this.store.isDev,scriptLoading:this.isESM?"module":"defer",meta:e,files:{css:[],js:[]},tags:{headTags:[],bodyTags:[]}},this.store.empOptions.html)}get entries(){return this.store.empOptions.entries?this.store.empOptions.entries:{}}get react(){return this.assign({hmr:!0,svgrQuery:"react"},this.store.empOptions.react)}get server(){let e={host:"0.0.0.0",port:8e3,open:process.platform==="darwin",hot:!0,watchFiles:["src/**/*.html"],static:[{directory:this.store.publicDir,watch:this.store.isDev}],allowedHosts:["all"],historyApiFallback:!0,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, PUT, DELETE, PATCH, OPTIONS","Access-Control-Allow-Headers":"X-Requested-With, content-type, Authorization"}};return this.assign(e,this.store.empOptions.server)}get empShare(){return this.assign({name:"",filename:"emp.js",shared:{},mfVersion:1.5},this.store.empOptions.empShare)}get css(){return this.assign({postcss:[]},this.store.empOptions.css)}get output(){let e=(this.store.isDev,".[contenthash:8]"),t=this.store.isDev?"":".[contenthash:8]",{assetsDir:s,staticDir:r}=this.store.empConfig.build,n={publicPath:this.store.empConfig.base?this.store.empConfig.base:"auto",crossOriginLoading:"anonymous",filename:`${r}js/[name]${e}.js`,cssFilename:`${r}css/[name]${t}.css`,cssChunkFilename:`${r}css/[name]${t}.css`,assetModuleFilename:`${r}${s}/[name]${e}[ext][query]`,path:this.store.outDir,clean:!0};return this.assign(n,this.store.empOptions.output)}get define(){let e={mode:this.store.mode,env:this.store.cliOptions.env};return this.store.empOptions.define&&(e={...e,...this.store.empOptions.define}),this.setDefine(e)}setDefine(e){let t=this.store.empOptions.defineFix?this.store.empOptions.defineFix:this.isESM?"esm":"cjs",s={};return Object.keys(e).map(r=>{(t==="all"||t==="esm")&&(s[`import.meta.env.${r}`]=JSON.stringify(e[r])),(t==="all"||t==="cjs")&&(s[`process.env.${r}`]=JSON.stringify(e[r])),s[`${r}`]=JSON.stringify(e[r])}),s}get externals(){return this.assign(this.empShareLib.externals,this.store.empOptions.externals)}get resolve(){return f({alias:{src:this.store.resolve("src"),"@":this.store.resolve("src")},extensions:["...",".js",".jsx",".mjs",".ts",".tsx",".css",".less",".scss",".sass",".json",".wasm",".vue",".svg",".svga"]},this.store.empOptions.resolve)}async syncEmpOptions(){let e=this.store.resolve("emp-config.js");if(!kt.existsSync(e))return;let{default:t}=await import(this.store.importFileUrl(e));typeof t=="function"?this.store.empOptions=await t(this.store):this.store.empOptions=t||{}}get moduleTransformRule(){let{moduleTransform:e}=this.store.empOptions,t=this.assign({defaultExclude:!1},e),s={and:[],not:[]};return t.defaultExclude===!0&&s.and.push(/(node_modules|bower_components)/),t?.exclude&&(s.and=s.and.concat(t.exclude)),e?.include&&(s.not=t.include),s}get cacheDir(){return this.store.empOptions.cacheDir?this.store.empOptions.cacheDir:"node_modules/.emp-cache"}get reactRuntime(){if(this.store.reactVersion)return this.store.empOptions.reactRuntime?this.store.empOptions.reactRuntime:T(this.store.reactVersion,"17")>-1?"automatic":"classic"}},_e=new oe});import v from"node:path";import jt from"node:fs/promises";import Tt from"webpack-chain";import{pathToFileURL as Rt}from"node:url";import Dt from"node:util";var ne,o,u=l(()=>{"use strict";_();Ie();b();We();y();ne=class{empPkg={dependencies:{},devDependencies:{},version:"2.0.0",name:""};pkg={dependencies:{},devDependencies:{},version:"0.0.0",name:""};root=process.cwd();empRoot=Ce;empSource=v.resolve(this.empRoot,"dist");resolve=e=>v.isAbsolute(e)?e:v.resolve(this.root,e);empResolve=e=>v.resolve(this.empRoot,e);appSrc="";outDir="";publicDir="";resource={dir:"",key:"",cert:""};cacheDir="";mode="development";cliMode="dev";isDev=!0;reactVersion=void 0;cliOptions;chain;rsConfig;empOptions={};empConfig;async setup(e,t){await this.initVars(e,t),this.empConfig=_e,await this.empConfig.setup(this),this.initPaths(),this.chain=new Tt,await He.setup(this),this.setLogger(),this.toConfig(),this.logConfig()}async initVars(e,t){this.cliOptions=t||{},this.cliMode="prod",this.mode=e==="dev"?"development":"production",this.isDev=this.mode==="development";let s=await V(this.empResolve("package.json")),r=await V(this.resolve("package.json"));this.empPkg={...this.empPkg,...s},this.pkg={...this.pkg,...r},this.reactVersion=this.pkg.dependencies.react||this.pkg.devDependencies.react}initPaths(){this.appSrc=this.resolve(this.empConfig.appSrc),this.outDir=this.resolve(this.empConfig.build.outDir),this.publicDir=this.resolve(this.empConfig.build.publicDir),this.cacheDir=this.resolve(this.empConfig.cacheDir),this.resource.dir=v.join(this.empRoot,"resource"),this.resource.cert=v.join(this.resource.dir,"emp.cert"),this.resource.key=v.join(this.resource.dir,"emp.key")}setLogger(){let e=this.cliMode==="dev"?"debug":"info";this.empConfig.debug.loggerLevel&&(e=this.empConfig.debug.loggerLevel),a.setup({pname:`EMP\u26A1${this.empPkg.version}${this.cliMode==="dev"?".DEV":""}`,logLevel:e})}merge(e){this.chain.merge(e)}importResolve(e,t){return ve(e,t)}importFileUrl(e){return Rt(e).toString()}toConfig(){this.rsConfig=this.chain.toConfig()}logConfig(){if(this.empConfig.debug.showRsconfig)if(typeof this.empConfig.debug.showRsconfig=="string"){let e=v.join(this.root,this.empConfig.debug.showRsconfig);jt.writeFile(e,JSON.stringify(this.rsConfig,null,2))}else{let e={colors:!0,depth:null},t=typeof this.empConfig.debug.showRsconfig=="object"?f(e,this.empConfig.debug.showRsconfig):e;console.log(a.link("[Compile Config]")),console.log(Dt.inspect(this.rsConfig,t))}}get browserslistOptions(){return{default:["chrome >= 87","edge >= 88","firefox >= 78","safari >= 14"],h5:["iOS >= 9","Android >= 4.4","last 2 versions","> 0.2%","not dead"],node:["node >= 20"]}}},o=new ne});import{exec as Lt}from"node:child_process";import{promisify as Ft}from"node:util";var qe,Xe,Mt,At,Qe,Ye=l(()=>{"use strict";b();u();qe=Ft(Lt),Xe=["Google Chrome Canary","Google Chrome Dev","Google Chrome Beta","Google Chrome","Microsoft Edge","Brave Browser","Vivaldi","Chromium"],Mt=async()=>{let i=process.env.BROWSER;if(!i||!Xe.includes(i)){let{stdout:e}=await qe("ps cax");i=Xe.find(t=>e.includes(t))}return i},At=async i=>{if(process.platform==="darwin")try{let t=await Mt();if(t){let s=`osascript openChrome.applescript "${encodeURI(i)}" "${t}"`;return await qe(s,{cwd:o.resource.dir}),!0}}catch(t){a.debug(t)}try{let{default:t}=await import("open");return await t(i),!0}catch(t){return a.error("Failed to open start URL."),a.error(t),!1}},Qe=At});import Bt from"net";import zt from"os";async function Ke(i,e="localhost"){if(i!==Gt&&(i<Ze||i>pe))throw new Error(`Port number must lie between ${Ze} and ${pe}`);let t=i,s=Ht(),r;e&&!s.has(e)?r=new Set([e]):r=s;let n=new Set(["EADDRINUSE","EACCES"]);for(;t<=pe;)try{return await Ut(t,r)}catch(p){if(!n.has(p.code))throw p;t+=1}throw new Error("No available ports found")}var Ze,pe,Gt,Ht,It,Ut,et=l(()=>{"use strict";Ze=1024,pe=65535,Gt=443,Ht=()=>{let i=zt.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(i))if(t)for(let s of t)e.add(s.address);return e},It=(i,e)=>new Promise((t,s)=>{let r=Bt.createServer();r.unref(),r.on("error",s),r.listen(i,e,()=>{let{port:n}=r.address();r.close(()=>{t(n)})})}),Ut=async(i,e)=>{let t=new Set(["EADDRNOTAVAIL","EINVAL"]);for(let s of e)try{await It(i,s)}catch(r){if(!t.has(r.code))throw r}return i}});import tt from"node:fs/promises";import B from"chalk";var C,z=l(()=>{"use strict";b();u();y();se();Ye();et();re();C=class{sf={protocol:"http",host:"0.0.0.0",port:8e3,publicPath:"",publicHasHttp:!1,isOpenBrower:!1,url:"",urls:{localUrlForBrowser:"",localUrlForTerminal:"",lanUrlForTerminal:"",lanUrlForConfig:""}};async adaptServer(){this.sf.publicPath=o.rsConfig.output?.publicPath==="auto"?"/":o.rsConfig.output?.publicPath||"/",this.sf.isOpenBrower=!!o.empConfig.server.open,this.sf.protocol=this.isHttps?"https":"http",this.sf.host=o.empConfig.server.host?o.empConfig.server.host:this.sf.host,this.sf.port=o.empConfig.server.port,await this.serverPort(),O.setup(this.sf),this.sf.publicPath&&(this.sf.publicPath.indexOf("http://")>-1||this.sf.publicPath.indexOf("https://")>-1)?(this.sf.url=this.sf.publicPath,this.sf.publicHasHttp=!0,this.sf.urls.localUrlForTerminal=O.prettyPrintUrl("localhost")):(this.sf.urls=O.urls,this.sf.url=this.sf.urls.localUrlForBrowser)}startOpen(){let{urls:e}=this.sf;this.sf.publicHasHttp?(a.info(`${B.greenBright("\u279C")} Local: ${a.link(e.localUrlForTerminal)}`),a.info(`${B.greenBright("\u279C")} Network: ${a.link(this.sf.publicPath)}`)):(a.info(`${B.greenBright("\u279C")} Local: ${a.link(e.localUrlForTerminal)}`),a.info(`${B.greenBright("\u279C")} Network: ${a.link(e.lanUrlForTerminal)}
|
|
11
|
+
`)),this.sf.isOpenBrower&&Qe(this.sf.url)}async setup(e,t){await o.setup(e,t),o.empConfig.debug.clearLog&&Oe(),a.title(`${e}`),await this.adaptServer(),await this.run()}async run(){}get isHttps(){let{server:e,https:t}=o.empConfig.server||{};return e==="https"||typeof e=="object"&&e.type==="https"||t===!0}getcert(){return Promise.all([tt.readFile(o.resource.key),tt.readFile(o.resource.cert)])}async serverPort(){if(M.isADB)return;let{port:e,host:t}=this.sf,s=await Ke(e,t);s!==e&&(this.sf.port=s,o.rsConfig.devServer?.port&&(o.rsConfig.devServer.port=s))}}});import d from"chalk";import w from"node:path";import{gzipSizeSync as Jt}from"gzip-size";import Nt from"node:fs";function Yt(i,e){let t=[i,e],s=["File","Size","Gzipped"].reduce((r,n,p)=>{let c=t[p],g=n;return c&&(g=n.length<c?n+" ".repeat(c-n.length):n),`${r+g} `}," ");console.log(d.bold.blue(s))}async function st(i){let e=i.toJson({all:!1,assets:!0,timings:!0});k(e.time);let s=e.assets.filter(m=>Xt(m.name)).map(Qt);s.sort((m,$)=>m.size-$.size);let r=Math.max(...s.map(m=>m.sizeLabel.length)),n=Math.max(...s.map(m=>(m.folder+w.sep+m.name).length));Yt(n,r);let p=0,c=0;s.forEach(m=>{let{sizeLabel:$}=m,{name:ht,folder:ft,gzipSizeLabel:ut}=m,ue=(ft+w.sep+ht).length,ge=$.length;if(p+=m.size,c+=m.gzippedSize,ge<r){let U=" ".repeat(r-ge);$+=U}let de=d.gray(m.folder+w.sep)+Zt(m.name);if(ue<n){let U=" ".repeat(n-ue);de+=U}a.info(` ${de} ${d.gray($)} ${ut}`)});let g=`${d.bold.blue("Total size:")} ${G(p)}`,P=`${d.bold.blue("Gzipped size:")} ${G(c)}`;a.info(`
|
|
12
|
+
${g}
|
|
13
|
+
${P}
|
|
14
|
+
`)}function k(i=0){a.info(`${d.greenBright("\u2713")} Ready in ${Pe(Number(i))}`)}var Vt,_t,Wt,Xt,qt,Qt,G,Zt,H=l(()=>{"use strict";u();b();y();Vt=/\.html$/,_t=/\.(?:js|mjs|cjs|jsx)$/,Wt=/\.css$/,Xt=i=>!/\.map$/.test(i)&&!/\.LICENSE\.txt$/.test(i),qt=i=>i>300*1e3?d.red:i>100*1e3?d.yellow:d.white,Qt=i=>{let e=i.name.split("?")[0],t=G(i.size),s=w.basename(e),r=w.join(w.basename(o.empConfig.build.outDir),w.dirname(e)),n=Nt.readFileSync(w.join(o.empConfig.build.outDir,e)),p=n.length,c=Jt(n),g=qt(c)(G(c));return{size:p,folder:r,name:s,gzippedSize:c,sizeLabel:t,gzipSizeLabel:g}};G=i=>{let e=i/1e3;return`${e.toFixed(e<1?2:1)} kB`},Zt=i=>_t.test(i)?d.yellowBright(i):Wt.test(i)?d.greenBright(i):Vt.test(i)?d.blueBright(i):d.magenta(i)});var it={};J(it,{default:()=>ts});import{rspack as Kt}from"@rspack/core";import{RspackDevServer as es}from"@rspack/dev-server";var ae,ts,rt=l(()=>{"use strict";u();z();b();y();H();ae=class extends C{async run(){let e=f(o.rsConfig,{stats:{all:!1,colors:!0,assets:!1,chunks:!1,entrypoints:!1,timings:!1,version:!1,errors:!0,warnings:!0},devServer:{open:!1,setupExitSignals:!0}}),t=Kt(e);if(!o.rsConfig.devServer){a.error("devServer is not defined in config");return}let s=Object.assign({},o.rsConfig.devServer);if(this.isHttps&&(s.https===!0&&delete s.https,!s.server)){let[p,c]=await this.getcert();s.server={type:"https",options:{key:p,cert:c}}}let r=new es(s,t);this.startOpen(),o.empConfig.lifeCycle.beforeDevServe&&await o.empConfig.lifeCycle.beforeDevServe(),await r.start();let n=p=>{let c=p?.toJson({all:!1,colors:!1,assets:!1,chunks:!1,timings:!0});k(c.time)};o.empConfig.debug.showPerformance&&t.hooks.afterDone.tap("done",n),r.middleware?.waitUntilValid(p=>{o.empConfig.debug.showPerformance||n(p),o.empConfig.lifeCycle.afterDevServe&&o.empConfig.lifeCycle.afterDevServe()})}},ts=new ae});var ot={};J(ot,{default:()=>is});import{rspack as ss}from"@rspack/core";var le,is,nt=l(()=>{"use strict";b();u();z();H();le=class extends C{async run(){o.empConfig.lifeCycle.beforeBuild&&await o.empConfig.lifeCycle.beforeBuild(),ss(o.rsConfig,async(e,t)=>{if(e!==null){a.error(e.stack||e),e.message&&a.error(e.message);return}if(!t){a.red("Stats is Undefined.");return}t.hasErrors()&&(a.error(t.toString({colors:!0,children:!0})),a.red("Failed to compile."),process.exit(1)),t.hasWarnings()&&(a.yellow("Compiled with warnings."),a.warn(t.toString({colors:!0,children:!0}))),await st(t),o.empConfig.lifeCycle.afterBulid&&await o.empConfig.lifeCycle.afterBulid()})}},is=new le});import rs from"express";import os from"cors";import ns from"compression";import ps from"https";var I,pt=l(()=>{"use strict";z();I=class extends C{app;async init(){let e=rs();e.use(ns()),e.use(os()),this.app=e}async server(){if(this.isHttps){let[e,t]=await this.getcert();ps.createServer(typeof this.isHttps!="boolean"?this.isHttps:{key:e,cert:t},this.app).listen(this.sf.port,async()=>{this.startOpen(),await this.onReady()})}else this.app.listen(this.sf.port,async()=>{this.startOpen(),await this.onReady()})}async onReady(){}async middleware(){}async start(){await this.init(),await this.middleware(),await this.server()}}});var at={};J(at,{default:()=>hs});import as from"express";import ls from"path";import cs from"node:fs/promises";import ms from"node:fs";var ce,hs,lt=l(()=>{"use strict";pt();u();b();H();ce=class extends I{timing=0;async run(){if(this.timing=Date.now(),!ms.existsSync(o.outDir))return a.sysError(`emp serve must be executed after emp build,${o.outDir} not exist!`);o.empConfig.lifeCycle.beforeServe&&await o.empConfig.lifeCycle.beforeServe(),this.start()}async middleware(){let e=o.resolve(o.rsConfig.output?.path);this.app.use(as.static(e));let t=await cs.readFile(ls.join(e,"index.html"),"utf8");this.app.get("*",(s,r)=>r.send(t))}async onReady(){k(Date.now()-this.timing),o.empConfig.lifeCycle.afterServe&&await o.empConfig.lifeCycle.afterServe()}},hs=new ce});u();u();y();b();import{program as S}from"commander";import me,{exit as fs}from"node:process";function ct(){let i="20.0.0";T(i,me.versions.node)===1&&(a.sysError(`\u5F53\u524D\u7248\u672C\u4E3Av${me.versions.node} \u6700\u4F4E\u8981\u6C42\u4E3Av${i}`),fs(0)),S.version(o.empPkg.version,"-v, --version").usage("<command> [options]"),S.command("dev").description("Dev \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-h, --hot","\u662F\u5426\u4F7F\u7528\u70ED\u66F4\u65B0 \u9ED8\u8BA4\u542F\u52A8").option("-o, --open","\u662F\u5426\u6253\u5F00\u8C03\u8BD5\u9875\u9762 \u9ED8\u8BA4\u4E0D\u6253\u5F00").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(e,t)=>{let[s,r]=e.split("=");return t[s]=r,t},{}).action(async e=>{let{default:t}=await Promise.resolve().then(()=>(rt(),it));await t.setup("dev",e)}),S.command("build").description("Build \u6A21\u5F0F").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").option("-a, --analyze","\u751F\u6210\u5206\u6790\u62A5\u544A \u9ED8\u8BA4\u4E3A false").option("-t, --ts","\u751F\u6210\u7C7B\u578B\u6587\u4EF6 \u9ED8\u8BA4\u4E3A false").option("-pr, --profile","\u7EDF\u8BA1\u6A21\u5757\u6D88\u8017").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").option("-ev, --env-vars <key=value>","\u5B9A\u4E49\u4E00\u4E2A\u73AF\u5883\u53D8\u91CF -ev key=value \u591A\u4E2A\u73AF\u5883\u53D8\u91CF\u91CD\u590D\u8C03\u7528 -ev key=value -ev key=value",(e,t)=>{let[s,r]=e.split("=");return t[s]=r,t},{}).action(async e=>{let{default:t}=await Promise.resolve().then(()=>(nt(),ot));await t.setup("build",e)}),S.command("serve").description("Server \u6A21\u5F0F").option("-cl, --clearLog <clearLog>","\u6E05\u7A7A\u65E5\u5FD7 \u9ED8\u8BA4\u4E3A true").action(async e=>{let{default:t}=await Promise.resolve().then(()=>(lt(),at));await t.setup("serve",e)}),S.command("dts").description("\u62C9\u53D6 remote \u9879\u76EE\u7684 d.ts").option("-p, --typingsPath <typingsPath>","\u4E0B\u8F7D\u76EE\u5F55").option("-e, --env <env>","\u90E8\u7F72\u73AF\u5883 dev\u3001test\u3001prod").action(e=>{}),S.command("init").description("\u521D\u59CB\u5316 emp \u9879\u76EE").option("-d, --data [data]","JSON\u6570\u636E http\u5730\u5740 \u6216\u8005 \u6587\u4EF6\u8DEF\u5F84\u76F8\u5BF9\u3001\u7EDD\u5BF9\u8DEF\u5F84").action(e=>{}),S.parse(me.argv)}u();import us from"fast-glob";import mt from"node:fs/promises";import he from"node:path";var gs=/(?:(?:import|export)\s?(?:type)?\s?(?:(?:\{[^;\n]+\})|(?:[^;\n]+))\s?from\s?['"][^;\n]+['"])|(?:import\(['"][^;\n]+?['"]\))/g,ds=/(?:import|export)\s?(?:type)?\s?\{?.+\}?\s?from\s?['"](.+)['"]/,ys=/import\(['"]([^;\n]+?)['"]\)/,fe=class{list=[];outDir=o.resolve("dist");aliasName="@empjs/cli";async setup(e,t){e&&(this.outDir=e),t&&(this.aliasName=t);let s=await this.readDts();await this.writeCode(s)}async readDts(){this.list=await us([`${o.empConfig.build.outDir}/**/*.d.ts`]);let e=[];this.list.map(s=>{s=o.resolve(s),e.push(this.readFile(s))});let t=await Promise.all(e);return t=t.map(s=>this.replaceAliasPath(s)),t}async readFile(e){let t=await mt.readFile(e,{encoding:"utf-8"});return{src:e,code:t}}replaceAliasPath({src:e,code:t}){t=t.replace(gs,r=>{let n=r.match(ds);if(n||(n=r.match(ys)),n&&n[1]){let p=n[1];if(!p.startsWith("."))return r;let c=he.resolve(he.dirname(e),p).replace(this.outDir,this.aliasName);return r.replace(n[1],c)}return r});let s=e.replace(this.outDir,this.aliasName).replace(".d.ts","");return s.endsWith("/index")&&(s=s.replace("/index","")),t=this.warpDeclareModule(s,t),{code:t,src:e,mod:s}}warpDeclareModule(e,t){return`declare module '${e}' {\r
|
|
9
15
|
${t}}\r
|
|
10
|
-
`}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await
|
|
16
|
+
`}async writeCode(e){let t="";e.map(s=>{t+=s.code}),await mt.writeFile(he.join(this.outDir.replace("dist","types"),"type.d.ts"),t)}},bs=new fe;function Qr(i){return i}export{Qr as defineConfig,bs as dts,ct as runScript,o as store};
|
package/dist/script/base.d.ts
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
export declare class BaseScript {
|
|
3
|
+
sf: {
|
|
4
|
+
protocol: string;
|
|
5
|
+
host: string;
|
|
6
|
+
port: number;
|
|
7
|
+
publicPath: string;
|
|
8
|
+
publicHasHttp: boolean;
|
|
9
|
+
isOpenBrower: boolean;
|
|
10
|
+
url: string;
|
|
11
|
+
urls: {
|
|
12
|
+
localUrlForBrowser: string;
|
|
13
|
+
localUrlForTerminal: string;
|
|
14
|
+
lanUrlForTerminal: string;
|
|
15
|
+
lanUrlForConfig: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
adaptServer(): Promise<void>;
|
|
19
|
+
startOpen(): void;
|
|
3
20
|
setup(cliName: string, o: any): Promise<void>;
|
|
4
21
|
run(): Promise<void>;
|
|
5
22
|
get isHttps(): boolean;
|
|
6
23
|
getcert(): Promise<[Buffer, Buffer]>;
|
|
24
|
+
serverPort(): Promise<void>;
|
|
7
25
|
}
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Express } from 'express';
|
|
2
|
+
import { BaseScript } from '../script/base';
|
|
3
|
+
export declare class HttpServer extends BaseScript {
|
|
4
|
+
app: Express;
|
|
5
|
+
init(): Promise<void>;
|
|
6
|
+
server(): Promise<void>;
|
|
7
|
+
onReady(): Promise<void>;
|
|
8
|
+
middleware(): Promise<void>;
|
|
9
|
+
start(): Promise<void>;
|
|
10
|
+
}
|
package/dist/script/serve.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
app: Express;
|
|
5
|
-
startLogger({ host, port, publicPath }: any): void;
|
|
1
|
+
import { HttpServer } from './httpBase';
|
|
2
|
+
declare class ServeScript extends HttpServer {
|
|
3
|
+
timing: number;
|
|
6
4
|
run(): Promise<void>;
|
|
5
|
+
middleware(): Promise<void>;
|
|
6
|
+
onReady(): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
declare const _default: ServeScript;
|
|
9
9
|
export default _default;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { GlobalStore } from '../store';
|
|
2
|
-
import { BuildType, DebugType, HtmlType, ReactType, ServerType } from '../types/config';
|
|
2
|
+
import { BuildType, DebugType, EMPShareType, HtmlType, ReactType, RsTarget, ServerType } from '../types/config';
|
|
3
3
|
import { Output } from '@rspack/core';
|
|
4
4
|
import { EMPShareLib } from '../store/empShareLib';
|
|
5
|
+
import { LifeCycle } from '../store/lifeCycle';
|
|
5
6
|
export declare class EmpConfig {
|
|
6
7
|
private store;
|
|
7
8
|
/**
|
|
@@ -22,8 +23,17 @@ export declare class EmpConfig {
|
|
|
22
23
|
* @default undefined
|
|
23
24
|
*/
|
|
24
25
|
base: string;
|
|
26
|
+
target: RsTarget;
|
|
25
27
|
private assign;
|
|
26
28
|
empShareLib: EMPShareLib;
|
|
29
|
+
/**
|
|
30
|
+
* 是否启动 esm 模块
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
isESM: boolean;
|
|
34
|
+
autoDevSet(): Promise<void>;
|
|
35
|
+
checkIsESM(target: string): boolean;
|
|
36
|
+
lifeCycle: LifeCycle;
|
|
27
37
|
setup(store: GlobalStore): Promise<void>;
|
|
28
38
|
chain(): Promise<void>;
|
|
29
39
|
plugins(): Promise<void>;
|
|
@@ -33,11 +43,7 @@ export declare class EmpConfig {
|
|
|
33
43
|
get entries(): import("../types/config").EntriesType;
|
|
34
44
|
get react(): Required<ReactType>;
|
|
35
45
|
get server(): ServerType;
|
|
36
|
-
get empShare():
|
|
37
|
-
name: string;
|
|
38
|
-
filename: string;
|
|
39
|
-
shared: {};
|
|
40
|
-
};
|
|
46
|
+
get empShare(): EMPShareType;
|
|
41
47
|
get css(): {
|
|
42
48
|
postcss: never[];
|
|
43
49
|
};
|
|
@@ -4,11 +4,26 @@ export type externalAssetsType = {
|
|
|
4
4
|
js: string[];
|
|
5
5
|
css: string[];
|
|
6
6
|
};
|
|
7
|
+
export type ImportMapType = {
|
|
8
|
+
imports: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
7
12
|
export declare class EMPShareLib {
|
|
8
13
|
externals: Configuration['externals'] | any;
|
|
9
14
|
externalAssets: externalAssetsType;
|
|
10
15
|
private exp;
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
config: EMPShareType;
|
|
17
|
+
importMap: ImportMapType;
|
|
18
|
+
version: EMPShareType['mfVersion'];
|
|
19
|
+
isEmpshare: boolean;
|
|
20
|
+
setup(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* 是否取用 importMap
|
|
23
|
+
*/
|
|
24
|
+
get useImportMap(): boolean | undefined;
|
|
25
|
+
get pluginConfig(): any;
|
|
26
|
+
prepareEsm(): void;
|
|
27
|
+
setShareLib(): Promise<void>;
|
|
13
28
|
private setExternalAssets;
|
|
14
29
|
}
|
package/dist/store/index.d.ts
CHANGED
|
@@ -108,6 +108,11 @@ export declare class GlobalStore {
|
|
|
108
108
|
* 打印 config
|
|
109
109
|
*/
|
|
110
110
|
logConfig(): void;
|
|
111
|
+
get browserslistOptions(): {
|
|
112
|
+
default: string[];
|
|
113
|
+
h5: string[];
|
|
114
|
+
node: string[];
|
|
115
|
+
};
|
|
111
116
|
}
|
|
112
117
|
declare const _default: GlobalStore;
|
|
113
118
|
export default _default;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
declare class LifeCycle {
|
|
3
|
-
|
|
1
|
+
export type LifeCycleType = Partial<LifeCycle>;
|
|
2
|
+
export declare class LifeCycle {
|
|
3
|
+
op: LifeCycleType;
|
|
4
|
+
constructor(op?: LifeCycleType);
|
|
5
|
+
afterGetEmpOptions(): Promise<void>;
|
|
6
|
+
beforePlugin(): Promise<void>;
|
|
7
|
+
afterPlugin(): Promise<void>;
|
|
8
|
+
beforeBuild(): Promise<void>;
|
|
9
|
+
afterBulid(): Promise<void>;
|
|
10
|
+
beforeDevServe(): Promise<void>;
|
|
11
|
+
afterDevServe(): Promise<void>;
|
|
12
|
+
beforeServe(): Promise<void>;
|
|
13
|
+
afterServe(): Promise<void>;
|
|
4
14
|
}
|
|
5
|
-
declare const _default: LifeCycle;
|
|
6
|
-
export default _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { HtmlType } from '../../types/config';
|
|
2
|
+
import { EMPShareLib } from '../empShareLib';
|
|
3
|
+
import { type Compiler } from '@rspack/core';
|
|
4
|
+
export declare const HtmlImportMapPluginName = "HtmlImportMapPlugin";
|
|
5
|
+
export declare class HtmlImportMapPlugin {
|
|
6
|
+
importMap: EMPShareLib['importMap'];
|
|
7
|
+
constructor(importMap: EMPShareLib['importMap']);
|
|
8
|
+
apply(compiler: any): void;
|
|
9
|
+
}
|
|
10
|
+
export declare const HtmlEmpShareLibPluginName = "HtmlEmpShareLibPlugin";
|
|
11
|
+
export declare class HtmlEmpShareLibPlugin {
|
|
12
|
+
files: {
|
|
13
|
+
css: string[];
|
|
14
|
+
js: string[];
|
|
15
|
+
};
|
|
16
|
+
constructor(files: HtmlType['files']);
|
|
17
|
+
apply(compiler: any): void;
|
|
18
|
+
}
|
|
19
|
+
export declare class EmpPolyfillPlugin {
|
|
20
|
+
constructor();
|
|
21
|
+
apply(compiler: Compiler): void;
|
|
22
|
+
}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import type { GlobalStore } from '../../store';
|
|
2
2
|
declare class RspackModule {
|
|
3
3
|
store: GlobalStore;
|
|
4
|
+
private swcJsOptions;
|
|
5
|
+
private swcTsOptions;
|
|
6
|
+
private coreJs;
|
|
4
7
|
setup(store: GlobalStore): Promise<void>;
|
|
8
|
+
private get isPolyfill();
|
|
9
|
+
private swcParser;
|
|
10
|
+
private get swcTransform();
|
|
11
|
+
private swcJsc;
|
|
12
|
+
private get swcCoreVersion();
|
|
13
|
+
private swcOptions;
|
|
14
|
+
swcInitOptions(): void;
|
|
5
15
|
scripts(): Promise<void>;
|
|
6
16
|
react(): Promise<void>;
|
|
7
17
|
files(): Promise<void>;
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Configuration as RsConfig } from '@rspack/core';
|
|
1
3
|
import { Configuration as devServerConfig } from '@rspack/dev-server';
|
|
2
4
|
import Chain from 'webpack-chain';
|
|
3
5
|
import { Externals, HtmlRspackPluginOptions, ModuleFederationPluginOptions, Output, Resolve, RuleSetRule, SwcJsMinimizerRspackPluginOptions } from '@rspack/core';
|
|
4
6
|
import { EMP3PluginType } from './plugin';
|
|
7
|
+
import { InspectOptions } from 'node:util';
|
|
8
|
+
import type { LifeCycle } from '../store/lifeCycle';
|
|
5
9
|
export type LoggerType = 'debug' | 'info' | 'warn' | 'error';
|
|
6
10
|
export type DebugType = {
|
|
7
11
|
loggerLevel: LoggerType;
|
|
8
12
|
clearLog: boolean;
|
|
9
13
|
progress: boolean;
|
|
10
|
-
showRsconfig: boolean;
|
|
14
|
+
showRsconfig: boolean | string | InspectOptions;
|
|
15
|
+
showPerformance: boolean;
|
|
16
|
+
rspackCache: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 是否显示执行日志
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
infrastructureLogging: RsConfig['infrastructureLogging'];
|
|
11
22
|
};
|
|
12
23
|
export type ServerType = devServerConfig & {
|
|
13
24
|
/**
|
|
@@ -52,6 +63,11 @@ export type BuildType = {
|
|
|
52
63
|
* @default 'public'
|
|
53
64
|
*/
|
|
54
65
|
publicDir?: string;
|
|
66
|
+
/**
|
|
67
|
+
* named 使用有意义、方便调试的内容当作模块 id。此选项会在开发环境下默认开启。
|
|
68
|
+
* deterministic 使用对模块标识符哈希后的数字当作模块 id,有益于长期缓存。此选项会在生产环境下默认开启。
|
|
69
|
+
*/
|
|
70
|
+
moduleIds?: 'named' | 'deterministic';
|
|
55
71
|
/**
|
|
56
72
|
* chunkIds
|
|
57
73
|
* @default named|deterministic
|
|
@@ -72,7 +88,32 @@ export type BuildType = {
|
|
|
72
88
|
* @default {}
|
|
73
89
|
*/
|
|
74
90
|
minOptions?: SwcJsMinimizerRspackPluginOptions;
|
|
91
|
+
/**
|
|
92
|
+
* 生成代码 参考 https://swc.rs/docs/configuring-swc#jsctarget
|
|
93
|
+
*/
|
|
94
|
+
target?: JscTarget;
|
|
95
|
+
/**
|
|
96
|
+
* 注入兼容代码
|
|
97
|
+
* module federation 入口 建议使用 entry
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
polyfill?: 'entry' | 'usage' | false;
|
|
101
|
+
/**
|
|
102
|
+
* 选择core-js的兼容版本有助于切换适当的代码体积
|
|
103
|
+
* @default stable
|
|
104
|
+
*/
|
|
105
|
+
coreJsFeatures?: 'full' | 'actual' | 'stable' | 'es';
|
|
106
|
+
/**
|
|
107
|
+
* @swc/helpers 外置
|
|
108
|
+
* @default false
|
|
109
|
+
*/
|
|
110
|
+
externalHelpers: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* 浏览器 兼容版本
|
|
113
|
+
*/
|
|
114
|
+
browserslist: string[];
|
|
75
115
|
};
|
|
116
|
+
export type JscTarget = 'es3' | 'es5' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022';
|
|
76
117
|
export interface HtmlType extends HtmlRspackPluginOptions {
|
|
77
118
|
/**
|
|
78
119
|
* 基于项目的根目录 index.html url
|
|
@@ -118,9 +159,10 @@ export type ReactType = {
|
|
|
118
159
|
*/
|
|
119
160
|
hmr: boolean;
|
|
120
161
|
/**
|
|
121
|
-
* 是否启动 Svg React Component
|
|
162
|
+
* 是否启动 Svg React Component
|
|
163
|
+
* @default ?react
|
|
122
164
|
*/
|
|
123
|
-
|
|
165
|
+
svgrQuery: string;
|
|
124
166
|
};
|
|
125
167
|
export type CSSOptions = {
|
|
126
168
|
postcss?: [string, any][];
|
|
@@ -128,6 +170,11 @@ export type CSSOptions = {
|
|
|
128
170
|
export interface ModuleTransform {
|
|
129
171
|
exclude?: RuleSetRule['exclude'][];
|
|
130
172
|
include?: RuleSetRule['include'][];
|
|
173
|
+
/**
|
|
174
|
+
* 默认exclude /(node_modules|bower_components)/
|
|
175
|
+
* @default false
|
|
176
|
+
*/
|
|
177
|
+
defaultExclude?: boolean;
|
|
131
178
|
}
|
|
132
179
|
export type EMPShareType = ModuleFederationPluginOptions & {
|
|
133
180
|
/**
|
|
@@ -135,9 +182,15 @@ export type EMPShareType = ModuleFederationPluginOptions & {
|
|
|
135
182
|
*/
|
|
136
183
|
shareLib?: EMPshareLibItemType;
|
|
137
184
|
/**
|
|
185
|
+
* TODO
|
|
138
186
|
* 是否使用 importMap
|
|
139
187
|
*/
|
|
140
188
|
useImportMap?: boolean;
|
|
189
|
+
/**
|
|
190
|
+
* module federation 版本
|
|
191
|
+
* @default 1
|
|
192
|
+
*/
|
|
193
|
+
mfVersion: 1 | 1.5;
|
|
141
194
|
};
|
|
142
195
|
export type EMPshareLibItemType = {
|
|
143
196
|
[module: string]: {
|
|
@@ -172,6 +225,7 @@ export type ExternalsItemType = {
|
|
|
172
225
|
*/
|
|
173
226
|
type?: string;
|
|
174
227
|
};
|
|
228
|
+
export type RsTarget = RsConfig['target'];
|
|
175
229
|
export type EmpOptions = {
|
|
176
230
|
/**
|
|
177
231
|
* publicPath 根路径 可参考webpack,业务模式默认为 auto
|
|
@@ -180,6 +234,14 @@ export type EmpOptions = {
|
|
|
180
234
|
* @default undefined
|
|
181
235
|
*/
|
|
182
236
|
base?: string;
|
|
237
|
+
/**
|
|
238
|
+
* 构建target
|
|
239
|
+
*/
|
|
240
|
+
target?: RsConfig['target'];
|
|
241
|
+
/**
|
|
242
|
+
* 启动后 自动设置 base 为当前 Ip+port的路径如 base = http://127.0.0.1:8080/ 并且固定 ws 方便代理调试
|
|
243
|
+
*/
|
|
244
|
+
autoDevBase?: boolean;
|
|
183
245
|
/**
|
|
184
246
|
* 项目代码路径
|
|
185
247
|
* @default 'src'
|
|
@@ -246,4 +308,8 @@ export type EmpOptions = {
|
|
|
246
308
|
* @default undefined
|
|
247
309
|
*/
|
|
248
310
|
reactRuntime?: 'automatic' | 'classic';
|
|
311
|
+
/**
|
|
312
|
+
* emp 执行周期
|
|
313
|
+
*/
|
|
314
|
+
lifeCycle?: LifeCycle;
|
|
249
315
|
};
|
package/package.json
CHANGED
|
@@ -1,108 +1,119 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
2
|
+
"name": "@empjs/cli",
|
|
3
|
+
"version": "3.0.0-beta.30",
|
|
4
|
+
"description": "emp",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"bin",
|
|
10
|
+
"resource",
|
|
11
|
+
"template",
|
|
12
|
+
"client.d.ts",
|
|
13
|
+
"emp-tsconfig.json"
|
|
14
|
+
],
|
|
15
|
+
"maintainers": [
|
|
16
|
+
"xuhongbin",
|
|
17
|
+
"ckken"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/empjs/emp.git",
|
|
22
|
+
"directory": "packages/cli"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"react",
|
|
29
|
+
"rspack",
|
|
30
|
+
"typescript"
|
|
31
|
+
],
|
|
32
|
+
"bin": {
|
|
33
|
+
"emp": "./bin/emp.js"
|
|
34
|
+
},
|
|
35
|
+
"main": "dist/index.js",
|
|
36
|
+
"module": "dist/index.js",
|
|
37
|
+
"types": "dist/index.d.ts",
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"import": {
|
|
41
|
+
"default": "./dist/index.js",
|
|
42
|
+
"types": "./dist/index.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"require": {
|
|
45
|
+
"default": "./dist/index.js",
|
|
46
|
+
"types": "./dist/index.d.ts"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"./emp-tsconfig.json": "./emp-tsconfig.json"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"d": "rimraf dist && pnpm run esdev:build",
|
|
53
|
+
"b": "rimraf dist && pnpm run esbuild:build",
|
|
54
|
+
"dev": "rimraf dist && pnpm run /^esdev:.*/",
|
|
55
|
+
"esdev:build": "cross-env ENV=dev node esbuild.js",
|
|
56
|
+
"esdev:tsc": "tsc -w",
|
|
57
|
+
"esdev:tsc-alias": "tsc-alias -w",
|
|
58
|
+
"build": "rimraf dist && pnpm run /^esbuild:.*/",
|
|
59
|
+
"esbuild:build": "cross-env ENV=prod node esbuild.js",
|
|
60
|
+
"esbuild:tsc": "tsc && tsc-alias",
|
|
61
|
+
"dts": "node dts-bundle.js"
|
|
62
|
+
},
|
|
63
|
+
"engines": {
|
|
64
|
+
"node": ">=20.0.0"
|
|
65
|
+
},
|
|
66
|
+
"author": "Ken",
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/compression": "^1.7.2",
|
|
69
|
+
"@types/cors": "^2.8.12",
|
|
70
|
+
"@types/default-gateway": "^7.2.1",
|
|
71
|
+
"@types/express": "^4.17.13",
|
|
72
|
+
"@types/fs-extra": "^11.0.4",
|
|
73
|
+
"@types/watchpack": "^2.4.3",
|
|
74
|
+
"@types/webpack": "^5.28.4",
|
|
75
|
+
"@types/webpack-bundle-analyzer": "^4.6.2",
|
|
76
|
+
"@types/webpack-hot-middleware": "^2.25.9",
|
|
77
|
+
"@types/webpack-sources": "^3.2.2",
|
|
78
|
+
"cross-env": "^7.0.3",
|
|
79
|
+
"esbuild": "^0.19.5",
|
|
80
|
+
"rimraf": "^5.0.5",
|
|
81
|
+
"tsc-alias": "^1.8.8"
|
|
82
|
+
},
|
|
83
|
+
"dependencies": {
|
|
84
|
+
"@module-federation/runtime": "^0.1.1",
|
|
85
|
+
"@module-federation/runtime-tools": "^0.1.1",
|
|
86
|
+
"@rspack/core": "0.5.9",
|
|
87
|
+
"@rspack/dev-server": "0.5.9",
|
|
88
|
+
"@rspack/plugin-react-refresh": "0.5.9",
|
|
89
|
+
"@svgr/webpack": "^8.1.0",
|
|
90
|
+
"@swc/helpers": "^0.5.7",
|
|
91
|
+
"@types/node": "^20.8.7",
|
|
92
|
+
"@types/react": "^18.2.30",
|
|
93
|
+
"address": "^2.0.1",
|
|
94
|
+
"ansi-html-community": "^0.0.8",
|
|
95
|
+
"chalk": "^5.3.0",
|
|
96
|
+
"commander": "^11.1.0",
|
|
97
|
+
"compression": "^1.7.4",
|
|
98
|
+
"core-js": "^3.36.1",
|
|
99
|
+
"cors": "^2.8.5",
|
|
100
|
+
"default-gateway": "^7.2.2",
|
|
101
|
+
"express": "^4.18.2",
|
|
102
|
+
"fast-glob": "^3.3.1",
|
|
103
|
+
"fs-extra": "^11.2.0",
|
|
104
|
+
"gzip-size": "^7.0.0",
|
|
105
|
+
"html-entities": "^2.5.2",
|
|
106
|
+
"html-webpack-plugin": "^5.6.0",
|
|
107
|
+
"less-loader": "^11.1.3",
|
|
108
|
+
"open": "^10.1.0",
|
|
109
|
+
"postcss": "^8.4.33",
|
|
110
|
+
"postcss-loader": "^7.3.4",
|
|
111
|
+
"react-refresh": "^0.14.0",
|
|
112
|
+
"sass-loader": "^13.3.2",
|
|
113
|
+
"strip-ansi": "^7.1.0",
|
|
114
|
+
"table": "^6.8.1",
|
|
115
|
+
"typescript-plugin-css-modules": "^5.0.2",
|
|
116
|
+
"webpack-bundle-analyzer": "^4.9.1",
|
|
117
|
+
"webpack-chain": "^6.5.1"
|
|
118
|
+
}
|
|
108
119
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
(*
|
|
2
|
+
Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
|
|
4
|
+
This source code is licensed under the MIT license found in the
|
|
5
|
+
LICENSE file at
|
|
6
|
+
https://github.com/facebookincubator/create-react-app/blob/master/LICENSE
|
|
7
|
+
*)
|
|
8
|
+
|
|
9
|
+
property targetTab: null
|
|
10
|
+
property targetTabIndex: -1
|
|
11
|
+
property targetWindow: null
|
|
12
|
+
property theProgram: "Google Chrome"
|
|
13
|
+
|
|
14
|
+
on run argv
|
|
15
|
+
set theURL to item 1 of argv
|
|
16
|
+
|
|
17
|
+
-- Allow requested program to be optional,
|
|
18
|
+
-- default to Google Chrome
|
|
19
|
+
if (count of argv) > 1 then
|
|
20
|
+
set theProgram to item 2 of argv
|
|
21
|
+
end if
|
|
22
|
+
|
|
23
|
+
using terms from application "Google Chrome"
|
|
24
|
+
tell application theProgram
|
|
25
|
+
|
|
26
|
+
if (count every window) = 0 then
|
|
27
|
+
make new window
|
|
28
|
+
end if
|
|
29
|
+
|
|
30
|
+
-- 1: Looking for tab running debugger
|
|
31
|
+
-- then, Reload debugging tab if found
|
|
32
|
+
-- then return
|
|
33
|
+
set found to my lookupTabWithUrl(theURL)
|
|
34
|
+
if found then
|
|
35
|
+
set targetWindow's active tab index to targetTabIndex
|
|
36
|
+
tell targetTab to reload
|
|
37
|
+
tell targetWindow to activate
|
|
38
|
+
set index of targetWindow to 1
|
|
39
|
+
return
|
|
40
|
+
end if
|
|
41
|
+
|
|
42
|
+
-- 2: Looking for Empty tab
|
|
43
|
+
-- In case debugging tab was not found
|
|
44
|
+
-- We try to find an empty tab instead
|
|
45
|
+
set found to my lookupTabWithUrl("chrome://newtab/")
|
|
46
|
+
if found then
|
|
47
|
+
set targetWindow's active tab index to targetTabIndex
|
|
48
|
+
set URL of targetTab to theURL
|
|
49
|
+
tell targetWindow to activate
|
|
50
|
+
return
|
|
51
|
+
end if
|
|
52
|
+
|
|
53
|
+
-- 3: Create new tab
|
|
54
|
+
-- both debugging and empty tab were not found
|
|
55
|
+
-- make a new tab with url
|
|
56
|
+
tell window 1
|
|
57
|
+
activate
|
|
58
|
+
make new tab with properties {URL:theURL}
|
|
59
|
+
end tell
|
|
60
|
+
end tell
|
|
61
|
+
end using terms from
|
|
62
|
+
end run
|
|
63
|
+
|
|
64
|
+
-- Function:
|
|
65
|
+
-- Lookup tab with given url
|
|
66
|
+
-- if found, store tab, index, and window in properties
|
|
67
|
+
-- (properties were declared on top of file)
|
|
68
|
+
on lookupTabWithUrl(lookupUrl)
|
|
69
|
+
using terms from application "Google Chrome"
|
|
70
|
+
tell application theProgram
|
|
71
|
+
-- Find a tab with the given url
|
|
72
|
+
set found to false
|
|
73
|
+
set theTabIndex to -1
|
|
74
|
+
repeat with theWindow in every window
|
|
75
|
+
set theTabIndex to 0
|
|
76
|
+
repeat with theTab in every tab of theWindow
|
|
77
|
+
set theTabIndex to theTabIndex + 1
|
|
78
|
+
if (theTab's URL as string) contains lookupUrl then
|
|
79
|
+
-- assign tab, tab index, and window to properties
|
|
80
|
+
set targetTab to theTab
|
|
81
|
+
set targetTabIndex to theTabIndex
|
|
82
|
+
set targetWindow to theWindow
|
|
83
|
+
set found to true
|
|
84
|
+
exit repeat
|
|
85
|
+
end if
|
|
86
|
+
end repeat
|
|
87
|
+
|
|
88
|
+
if found then
|
|
89
|
+
exit repeat
|
|
90
|
+
end if
|
|
91
|
+
end repeat
|
|
92
|
+
end tell
|
|
93
|
+
end using terms from
|
|
94
|
+
return found
|
|
95
|
+
end lookupTabWithUrl
|
package/template/index.html
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="<%= htmlWebpackPlugin.options.lang %>">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<!-- EMP inject js -->
|
|
16
|
-
<% for (let i in htmlWebpackPlugin.options.files.js) { %>
|
|
17
|
-
<script src="<%= htmlWebpackPlugin.options.files.js[i] %>"></script>
|
|
18
|
-
<% } %>
|
|
19
|
-
</body>
|
|
20
|
-
</html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<title>
|
|
6
|
+
<%= htmlWebpackPlugin.options.title %>
|
|
7
|
+
</title>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body>
|
|
11
|
+
<div id="emp-root"></div>
|
|
12
|
+
</body>
|
|
13
|
+
|
|
14
|
+
</html>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare class RuntimePlugins {
|
|
2
|
-
constructor();
|
|
3
|
-
beforeInit(): void;
|
|
4
|
-
beforeLoadingRemote(): void;
|
|
5
|
-
loadRemoteMatch(): void;
|
|
6
|
-
loadRemote(): void;
|
|
7
|
-
errorLoadRemote(): void;
|
|
8
|
-
beforeLoadShare(): void;
|
|
9
|
-
beforePreloadRemote(): void;
|
|
10
|
-
}
|
|
11
|
-
declare const _default: RuntimePlugins;
|
|
12
|
-
export default _default;
|
|
File without changes
|