@lemon-fe/vite-plugin-micro-frontend 1.1.8 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,56 +1,46 @@
1
1
  #!/usr/bin/env node
2
2
  import * as path from 'path';
3
- import * as fs from 'fs';
4
- import { createRequire } from 'module';
5
- import { generateMf, generateRoutesToFile } from './index.js';
3
+ import { MICRO_FRONTEND_OPTIONS_KEY, generateMf, generateRoutesToFile } from './index.js';
6
4
 
7
- const require$1 = createRequire(import.meta.url);
8
5
  const DEFAULT_ROUTES = {
9
- pagesDir: path.resolve(process.cwd(), 'src/pages'),
10
- outputPath: path.resolve(process.cwd(), 'src/routes.ts'),
6
+ pagesDir: path.resolve(process.cwd(), "src/pages"),
7
+ outputPath: path.resolve(process.cwd(), "src/routes.ts"),
11
8
  };
12
- const DEFAULT_MF_OUTPUT = path.resolve(process.cwd(), 'src/utils/mf.tsx');
13
- function loadConfig(cwd) {
14
- const tryLoad = (filePath) => {
15
- if (fs.existsSync(filePath)) {
16
- try {
17
- return require$1(filePath);
18
- }
19
- catch (e) {
20
- console.warn('⚠️ 加载配置失败:', filePath, e);
9
+ const DEFAULT_MF_OUTPUT = path.resolve(process.cwd(), "src/utils/mf.tsx");
10
+ /** 扁平化 Vite plugins 数组(可能嵌套) */
11
+ function flattenPlugins(plugins) {
12
+ if (!Array.isArray(plugins))
13
+ return [];
14
+ return plugins.flatMap((p) => (Array.isArray(p) ? flattenPlugins(p) : [p]));
15
+ }
16
+ /** vite.config 中解析 microFrontendPlugins 的 options,供 CLI 复用 federation/routes */
17
+ async function loadConfigFromVite(cwd) {
18
+ try {
19
+ const vite = await import('vite');
20
+ const result = await vite.loadConfigFromFile({ command: "build", mode: "production" }, undefined, cwd);
21
+ if (!result?.config?.plugins)
22
+ return null;
23
+ const flat = flattenPlugins(result.config.plugins);
24
+ for (const plugin of flat) {
25
+ const raw = plugin &&
26
+ typeof plugin === "object" &&
27
+ plugin[MICRO_FRONTEND_OPTIONS_KEY];
28
+ const opts = raw;
29
+ if (opts && typeof opts === "object") {
30
+ return {
31
+ routes: opts.routes,
32
+ federation: opts.federation
33
+ ? {
34
+ remotes: opts.federation.remotes,
35
+ outputPath: opts.federation.outputPath,
36
+ }
37
+ : undefined,
38
+ };
21
39
  }
22
40
  }
23
- return null;
24
- };
25
- const configPath = [
26
- path.join(cwd, 'mf.config.cjs'),
27
- path.join(cwd, 'mf.config.js'),
28
- path.join(cwd, '.mfrc.js'),
29
- ].find(p => fs.existsSync(p));
30
- if (configPath) {
31
- const config = tryLoad(configPath);
32
- if (config && (config.routes !== undefined || config.federation !== undefined)) {
33
- return config;
34
- }
35
- if (config && config.microFrontend) {
36
- return config.microFrontend;
37
- }
38
- if (config) {
39
- return config;
40
- }
41
41
  }
42
- const pkgPath = path.join(cwd, 'package.json');
43
- if (fs.existsSync(pkgPath)) {
44
- try {
45
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
46
- const microFrontend = pkg.microFrontend ?? pkg.mf;
47
- if (microFrontend && typeof microFrontend === 'object') {
48
- return microFrontend;
49
- }
50
- }
51
- catch (_) {
52
- // ignore
53
- }
42
+ catch (_) {
43
+ // vite 未安装、或无 vite.config、或解析失败,静默回退
54
44
  }
55
45
  return null;
56
46
  }
@@ -58,23 +48,15 @@ function printUsage() {
58
48
  console.log(`
59
49
  mf generate [tmp] 生成 mf 与 routes 文件(类似 umi generate tmp)
60
50
 
61
- 配置方式(任选其一):
62
- 1. 项目根目录创建 mf.config.js / mf.config.cjs / .mfrc.js,导出:
63
- module.exports = {
64
- routes: { pagesDir: 'src/pages', outputPath: 'src/routes.ts', routeTemplate: {} },
65
- federation: { remotes: [...], outputPath: 'src/utils/mf.tsx' }
66
- };
67
- 2. 在 package.json 中增加 "microFrontend" 或 "mf" 字段,结构同上。
68
-
69
- 配置可与 vite.config 中 microFrontendPlugins 的 options 保持一致,
70
- 建议将配置抽成单独文件,在 vite.config 和 mf.config 中共同引用。
51
+ 配置:在 vite.config 中使用 microFrontendPlugins({ federation: { remotes, outputPath }, routes }),
52
+ CLI 会从 vite.config 自动读取,无需单独配置文件。
71
53
  `);
72
54
  }
73
55
  async function runGenerate(config) {
74
56
  let done = 0;
75
- if (config.federation?.remotes?.length) {
57
+ if (config.federation !== undefined) {
76
58
  generateMf({
77
- remotes: config.federation.remotes,
59
+ remotes: config.federation.remotes ?? [],
78
60
  outputPath: config.federation.outputPath ?? DEFAULT_MF_OUTPUT,
79
61
  });
80
62
  done++;
@@ -87,31 +69,32 @@ async function runGenerate(config) {
87
69
  });
88
70
  done++;
89
71
  if (done === 0) {
90
- console.log('未执行任何生成(未配置 federation.remotes,routes 已按默认路径生成)');
72
+ console.log("未执行任何生成(未配置 federation,routes 已按默认路径生成)");
91
73
  }
92
74
  }
93
75
  async function main() {
94
76
  const args = process.argv.slice(2);
95
77
  const cwd = process.cwd();
96
- if (args[0] === 'generate') {
97
- const config = loadConfig(cwd);
78
+ if (args[0] === "generate") {
79
+ const config = await loadConfigFromVite(cwd);
98
80
  if (config) {
99
81
  await runGenerate(config);
100
82
  return;
101
83
  }
102
- console.warn('未找到 mf 配置,使用默认路径生成 routes;若要生成 mf,请配置 federation.remotes。');
84
+ console.warn("未在 vite.config 中找到 microFrontendPlugins 配置,已使用默认路径生成 routes;" +
85
+ "若要生成 mf,请在 vite.config 中配置 microFrontendPlugins({ federation: { remotes } }).");
103
86
  await runGenerate({ routes: DEFAULT_ROUTES });
104
87
  return;
105
88
  }
106
- if (args[0] === '--help' || args[0] === '-h' || !args.length) {
89
+ if (args[0] === "--help" || args[0] === "-h" || !args.length) {
107
90
  printUsage();
108
91
  return;
109
92
  }
110
- console.error('未知命令:', args[0]);
93
+ console.error("未知命令:", args[0]);
111
94
  printUsage();
112
95
  process.exit(1);
113
96
  }
114
- main().catch(e => {
97
+ main().catch((e) => {
115
98
  console.error(e);
116
99
  process.exit(1);
117
100
  });
package/dist/index.d.ts CHANGED
@@ -207,7 +207,9 @@ declare function getRoutes(opts: IOpts): IRoute[];
207
207
  * @param options 微前端插件选项
208
208
  * @returns 插件数组
209
209
  */
210
+ /** 供 CLI 从 vite.config 解析时识别的标记,勿删 */
211
+ declare const MICRO_FRONTEND_OPTIONS_KEY = "__microFrontendOptions";
210
212
  declare function microFrontendPlugins(options: MicroFrontendPluginOptions): PluginOption[];
211
213
 
212
- export { autoExternalAntd, devHmrPlugin, federationPlugin, generateMf, generateRoutesToFile, getRoutes, mfGeneratorPlugin, microFrontendPlugins, pagesRoutesPlugin };
214
+ export { MICRO_FRONTEND_OPTIONS_KEY, autoExternalAntd, devHmrPlugin, federationPlugin, generateMf, generateRoutesToFile, getRoutes, mfGeneratorPlugin, microFrontendPlugins, pagesRoutesPlugin };
213
215
  export type { ComponentMetadata, FederationConfig, IRoute, MfGeneratorOptions, MicroFrontendPluginOptions, RemoteConfig, RouteConfig, RoutesPluginOptions, RoutesTemplateOptions, VitePlugin };
package/dist/index.js CHANGED
@@ -10,5 +10,5 @@ import*as e from"path";import t,{join as n,basename as r,extname as i,relative a
10
10
 
11
11
  return ${L(i)};
12
12
  })(${w(this.node)})
13
- `;return this.replaceWith(p)[0].get("arguments.0")},Ua.splitExportDeclaration=function(){if(!this.isExportDeclaration()||this.isExportAllDeclaration())throw new Error("Only default and named export declarations can be split.");if(this.isExportNamedDeclaration()&&this.get("specifiers").length>0)throw new Error("It doesn't make sense to split exported specifiers.");const e=this.get("declaration");if(this.isExportDefaultDeclaration()){const t=e.isFunctionDeclaration()||e.isClassDeclaration(),n=e.isFunctionExpression()||e.isClassExpression(),r=e.isScope()?e.scope.parent:e.scope;let i=e.node.id,s=!1;i?n&&r.hasBinding(i.name)&&(s=!0,i=r.generateUidIdentifier(i.name)):(s=!0,i=r.generateUidIdentifier("default"),(t||n)&&(e.node.id=L(i)));const a=t?e.node:M("var",[F(L(i),e.node)]),o=B(null,[j(L(i),u("default"))]);return this.insertAfter(o),this.replaceWith(a),s&&r.registerDeclaration(this),this}if(this.get("specifiers").length>0)throw new Error("It doesn't make sense to split exported specifiers.");const t=e.getOuterBindingIdentifiers(),n=Object.keys(t).map(e=>j(u(e),u(e))),r=B(null,n);return this.insertAfter(r),this.replaceWith(e.node),this},Ua.toComputedKey=function(){let e;if(this.isMemberExpression())e=this.node.property;else{if(!this.isProperty()&&!this.isMethod())throw new ReferenceError("todo");e=this.node.key}this.node.computed||d(e)&&(e=v(e.name));return e},Ua.unwrapFunctionEnvironment=function(){if(!this.isArrowFunctionExpression()&&!this.isFunctionExpression()&&!this.isFunctionDeclaration())throw this.buildCodeFrameError("Can only unwrap the environment of a function.");K(this)};var e=qr(),t=function(){if(io)return Ka;io=1,Object.defineProperty(Ka,"__esModule",{value:!0}),Ka.statements=Ka.statement=Ka.smart=Ka.program=Ka.expression=Ka.default=void 0;var e=qa(),t=lo();const n=Ka.smart=(0,t.default)(e.smart),r=Ka.statement=(0,t.default)(e.statement),i=Ka.statements=(0,t.default)(e.statements),s=Ka.expression=(0,t.default)(e.expression),a=Ka.program=(0,t.default)(e.program);return Ka.default=Object.assign(n.bind(void 0),{smart:n,statement:r,statements:i,expression:s,program:a,ast:n.ast}),Ka}(),n=Ci(),r=Ao();const{arrowFunctionExpression:i,assignmentExpression:s,binaryExpression:a,blockStatement:o,callExpression:l,conditionalExpression:c,expressionStatement:p,identifier:u,isIdentifier:d,jsxIdentifier:h,logicalExpression:f,LOGICAL_OPERATORS:m,memberExpression:y,metaProperty:T,numericLiteral:g,objectExpression:S,restElement:x,returnStatement:b,sequenceExpression:E,spreadElement:P,stringLiteral:v,super:A,thisExpression:C,toExpression:w,unaryExpression:I,toBindingIdentifierName:N,isFunction:k,isAssignmentPattern:O,isRestElement:D,getFunctionName:_,cloneNode:L,variableDeclaration:M,variableDeclarator:F,exportNamedDeclaration:B,exportSpecifier:j,inherits:R}=e;Ua.arrowFunctionToShadowed=function(){this.isArrowFunctionExpression()&&this.arrowFunctionToExpression()};const U=(0,n.environmentVisitor)({CallExpression(e,{allSuperCalls:t}){e.get("callee").isSuper()&&t.push(e)}});function K(e,t=!0,n=!0,r=!0){let o,p=e.findParent(e=>e.isArrowFunctionExpression()?(null!=o||(o=e),!1):e.isFunction()||e.isProgram()||e.isClassProperty({static:!1})||e.isClassPrivateProperty({static:!1}));const d=p.isClassMethod({kind:"constructor"});if(p.isClassProperty()||p.isClassPrivateProperty())if(o)p=o;else{if(!n)throw e.buildCodeFrameError("Unable to transform arrow inside class property");e.replaceWith(l(i([],w(e.node)),[])),p=e.get("callee"),e=p.get("body")}const{thisPaths:S,argumentsPaths:b,newTargetPaths:N,superProps:k,superCalls:O}=function(e){const t=[],n=[],r=[],i=[],s=[];return e.traverse(J,{thisPaths:t,argumentsPaths:n,newTargetPaths:r,superProps:i,superCalls:s}),{thisPaths:t,argumentsPaths:n,newTargetPaths:r,superProps:i,superCalls:s}}(e);if(d&&O.length>0){if(!n)throw O[0].buildCodeFrameError("When using '@babel/plugin-transform-arrow-functions', it's not possible to compile `super()` in an arrow function without compiling classes.\nPlease add '@babel/plugin-transform-classes' to your Babel configuration.");if(!r)throw O[0].buildCodeFrameError("When using '@babel/plugin-transform-parameters', it's not possible to compile `super()` in an arrow function with default or rest parameters without compiling classes.\nPlease add '@babel/plugin-transform-classes' to your Babel configuration.");const e=[];p.traverse(U,{allSuperCalls:e});const t=function(e){return W(e,"supercall",()=>{const t=e.scope.generateUidIdentifier("args");return i([x(t)],l(A(),[P(u(t.name))]))})}(p);e.forEach(e=>{const n=u(t);n.loc=e.node.callee.loc,e.get("callee").replaceWith(n)})}if(b.length>0){const e=W(p,"arguments",()=>{const e=()=>u("arguments");return p.scope.path.isProgram()?c(a("===",I("typeof",e()),v("undefined")),p.scope.buildUndefinedNode(),e()):e()});b.forEach(t=>{const n=u(e);n.loc=t.node.loc,t.replaceWith(n)})}if(N.length>0){const e=W(p,"newtarget",()=>T(u("new"),u("target")));N.forEach(t=>{const n=u(e);n.loc=t.node.loc,t.replaceWith(n)})}if(k.length>0){if(!n)throw k[0].buildCodeFrameError("When using '@babel/plugin-transform-arrow-functions', it's not possible to compile `super.prop` in an arrow function without compiling classes.\nPlease add '@babel/plugin-transform-classes' to your Babel configuration.");k.reduce((e,t)=>e.concat(function(e){if(e.parentPath.isAssignmentExpression()&&"="!==e.parentPath.node.operator){const n=e.parentPath,r=n.node.operator.slice(0,-1),i=n.node.right,a=function(e){return m.includes(e)}(r);if(e.node.computed){const o=e.scope.generateDeclaredUidIdentifier("tmp"),{object:l,property:c}=e.node;n.get("left").replaceWith(y(l,s("=",o,c),!0)),n.get("right").replaceWith(t(a?"=":r,y(l,u(o.name),!0),i))}else{const s=e.node.object,o=e.node.property;n.get("left").replaceWith(y(s,o)),n.get("right").replaceWith(t(a?"=":r,y(s,u(o.name)),i))}return a?n.replaceWith(f(r,n.node.left,n.node.right)):n.node.operator="=",[n.get("left"),n.get("right").get("left")]}if(e.parentPath.isUpdateExpression()){const t=e.parentPath,n=e.scope.generateDeclaredUidIdentifier("tmp"),r=e.node.computed?e.scope.generateDeclaredUidIdentifier("prop"):null,i=[s("=",n,y(e.node.object,r?s("=",r,e.node.property):e.node.property,e.node.computed)),s("=",y(e.node.object,r?u(r.name):e.node.property,e.node.computed),a(e.parentPath.node.operator[0],u(n.name),g(1)))];e.parentPath.node.prefix||i.push(u(n.name)),t.replaceWith(E(i));return[t.get("expressions.0.right"),t.get("expressions.1.left")]}return[e];function t(e,t,n){return"="===e?s("=",t,n):a(e,t,n)}}(t)),[]).forEach(e=>{const t=e.node.computed?"":e.get("property").node.name,n=e.parentPath,r=n.isAssignmentExpression({left:e.node}),a=n.isCallExpression({callee:e.node}),o=n.isTaggedTemplateExpression({tag:e.node}),c=function(e,t,n){const r=t?"set":"get";return W(e,`superprop_${r}:${n||""}`,()=>{const r=[];let a;if(n)a=y(A(),u(n));else{const t=e.scope.generateUidIdentifier("prop");r.unshift(t),a=y(A(),u(t.name),!0)}if(t){const t=e.scope.generateUidIdentifier("value");r.push(t),a=s("=",a,u(t.name))}return i(r,a)})}(p,r,t),d=[];if(e.node.computed&&d.push(e.get("property").node),r){const e=n.node.right;d.push(e)}const h=l(u(c),d);a?(n.unshiftContainer("arguments",C()),e.replaceWith(y(h,u("call"))),S.push(n.get("arguments.0"))):r?n.replaceWith(h):o?(e.replaceWith(l(y(h,u("bind"),!1),[C()])),S.push(e.get("arguments.0"))):e.replaceWith(h)})}let D;return(S.length>0||!t)&&(D=function(e,t){return W(e,"this",n=>{if(!t||!V(e))return C();e.traverse(q,{supers:new WeakSet,thisBinding:n})})}(p,d),(t||d&&V(p))&&(S.forEach(e=>{const t=e.isJSX()?h(D):u(D);t.loc=e.node.loc,e.replaceWith(t)}),t||(D=null))),{thisBinding:D,fnPath:e}}function V(e){return e.isClassMethod()&&!!e.parentPath.parentPath.node.superClass}const q=(0,n.environmentVisitor)({CallExpression(e,{supers:t,thisBinding:n}){e.get("callee").isSuper()&&(t.has(e.node)||(t.add(e.node),e.replaceWithMultiple([e.node,s("=",u(n),u("this"))])))}});function W(e,t,n){const r="binding:"+t;let i=e.getData(r);if(!i){const s=e.scope.generateUidIdentifier(t);i=s.name,e.setData(r,i),e.scope.push({id:s,init:n(i)})}return i}const J=(0,n.environmentVisitor)({ThisExpression(e,{thisPaths:t}){t.push(e)},JSXIdentifier(e,{thisPaths:t}){"this"===e.node.name&&(e.parentPath.isJSXMemberExpression({object:e.node})||e.parentPath.isJSXOpeningElement({name:e.node}))&&t.push(e)},CallExpression(e,{superCalls:t}){e.get("callee").isSuper()&&t.push(e)},MemberExpression(e,{superProps:t}){e.get("object").isSuper()&&t.push(e)},Identifier(e,{argumentsPaths:t}){if(!e.isReferencedIdentifier({name:"arguments"}))return;let n=e.scope;do{if(n.hasOwnBinding("arguments"))return void n.rename("arguments");if(n.path.isFunction()&&!n.path.isArrowFunctionExpression())break}while(n=n.parent);t.push(e)},MetaProperty(e,{newTargetPaths:t}){e.get("meta").isIdentifier({name:"new"})&&e.get("property").isIdentifier({name:"target"})&&t.push(e)}});const $={"ReferencedIdentifier|BindingIdentifier"(e,t){e.node.name===t.name&&(t.needsRename=!0,e.stop())},Scope(e,t){e.scope.hasOwnBinding(t.name)&&e.skip()}};return Ua}var po,uo={};function ho(){return po||(po=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e._guessExecutionStatusRelativeTo=function(e){return m(this,e,new Map)},e._resolve=y,e.canHaveVariableDeclarationOrExpression=function(){return("init"===this.key||"left"===this.key)&&this.parentPath.isFor()},e.canSwapBetweenExpressionAndStatement=function(e){if("body"!==this.key||!this.parentPath.isArrowFunctionExpression())return!1;if(this.isExpression())return i(e);if(this.isBlockStatement())return s(e);return!1},e.getSource=function(){const e=this.node;if(e.end){const t=this.hub.getCode();if(t)return t.slice(e.start,e.end)}return""},e.isCompletionRecord=function(e){let t=this,n=!0;do{const{type:r,container:i}=t;if(!n&&(t.isFunction()||"StaticBlock"===r))return!!e;if(n=!1,Array.isArray(i)&&t.key!==i.length-1)return!1}while((t=t.parentPath)&&!t.isProgram()&&!t.isDoExpression());return!0},e.isConstantExpression=function(){if(this.isIdentifier()){const e=this.scope.getBinding(this.node.name);return!!e&&e.constant}if(this.isLiteral())return!this.isRegExpLiteral()&&(!this.isTemplateLiteral()||this.get("expressions").every(e=>e.isConstantExpression()));if(this.isUnaryExpression())return"void"===this.node.operator&&this.get("argument").isConstantExpression();if(this.isBinaryExpression()){const{operator:e}=this.node;return"in"!==e&&"instanceof"!==e&&this.get("left").isConstantExpression()&&this.get("right").isConstantExpression()}if(this.isMemberExpression())return!this.node.computed&&this.get("object").isIdentifier({name:"Symbol"})&&!this.scope.hasBinding("Symbol",{noGlobals:!0});if(this.isCallExpression())return 1===this.node.arguments.length&&this.get("callee").matchesPattern("Symbol.for")&&!this.scope.hasBinding("Symbol",{noGlobals:!0})&&this.get("arguments")[0].isStringLiteral();return!1},e.isInStrictMode=function(){const e=(this.isProgram()?this:this.parentPath).find(e=>{if(e.isProgram({sourceType:"module"}))return!0;if(e.isClass())return!0;if(e.isArrowFunctionExpression()&&!e.get("body").isBlockStatement())return!1;let t;if(e.isFunction())t=e.node.body;else{if(!e.isProgram())return!1;t=e.node}for(const e of t.directives)if("use strict"===e.value.value)return!0;return!1});return!!e},e.isNodeType=function(e){return c(this.type,e)},e.isStatementOrBlock=function(){return!this.parentPath.isLabeledStatement()&&!i(this.container)&&n.includes(this.key)},e.isStatic=function(){return this.scope.isStatic(this.node)},e.matchesPattern=function(e,t){return p(this.node,e,t)},e.referencesImport=function(e,t){if(!this.isReferencedIdentifier()){if(this.isJSXMemberExpression()&&this.node.property.name===t||(this.isMemberExpression()||this.isOptionalMemberExpression())&&(this.node.computed?l(this.node.property,{value:t}):this.node.property.name===t)){const t=this.get("object");return t.isReferencedIdentifier()&&t.referencesImport(e,"*")}return!1}const n=this.scope.getBinding(this.node.name);if(!n||"module"!==n.kind)return!1;const r=n.path,i=r.parentPath;if(!i.isImportDeclaration())return!1;if(i.node.source.value!==e)return!1;if(!t)return!0;if(r.isImportDefaultSpecifier()&&"default"===t)return!0;if(r.isImportNamespaceSpecifier()&&"*"===t)return!0;if(r.isImportSpecifier()&&a(r.node.imported,{name:t}))return!0;return!1},e.resolve=function(e,t){return y.call(this,e,t)||this},e.willIMaybeExecuteBefore=function(e){return"after"!==this._guessExecutionStatusRelativeTo(e)};var t=qr();const{STATEMENT_OR_BLOCK_KEYS:n,VISITOR_KEYS:r,isBlockStatement:i,isExpression:s,isIdentifier:a,isLiteral:o,isStringLiteral:l,isType:c,matchesPattern:p}=t;function u(e){return e.isProgram()?e:(e.parentPath.scope.getFunctionParent()||e.parentPath.scope.getProgramParent()).path}function d(e,t){switch(e){case"LogicalExpression":case"AssignmentPattern":return"right"===t;case"ConditionalExpression":case"IfStatement":return"consequent"===t||"alternate"===t;case"WhileStatement":case"DoWhileStatement":case"ForInStatement":case"ForOfStatement":return"body"===t;case"ForStatement":return"body"===t||"update"===t;case"SwitchStatement":return"cases"===t;case"TryStatement":return"handler"===t;case"OptionalMemberExpression":return"property"===t;case"OptionalCallExpression":return"arguments"===t;default:return!1}}function h(e,t){for(let n=0;n<t;n++){const t=e[n];if(d(t.parent.type,t.parentKey))return!0}return!1}e.has=function(e){var t;const n=null==(t=this.node)?void 0:t[e];return n&&Array.isArray(n)?!!n.length:!!n},e.is=e.has,e.isnt=function(e){return!this.has(e)},e.equals=function(e,t){return this.node[e]===t};const f=Symbol();function m(e,t,n){const i={this:u(e),target:u(t)};if(i.target.node!==i.this.node)return function(e,t,n){let r,i=n.get(e.node);if(i){if(r=i.get(t.node))return r===f?"unknown":r}else n.set(e.node,i=new Map);i.set(t.node,f);const s=function(e,t,n){if(!t.isFunctionDeclaration())return"before"===m(e,t,n)?"before":"unknown";if(t.parentPath.isExportDeclaration())return"unknown";const r=t.scope.getBinding(t.node.id.name);if(!r.references)return"before";const i=r.referencePaths;let s;for(const r of i){if(!!r.find(e=>e.node===t.node))continue;if("callee"!==r.key||!r.parentPath.isCallExpression())return"unknown";const i=m(e,r,n);if(s&&s!==i)return"unknown";s=i}return s}(e,t,n);return i.set(t.node,s),s}(e,i.target,n);const s={target:t.getAncestry(),this:e.getAncestry()};if(s.target.includes(e))return"after";if(s.this.includes(t))return"before";let a;const o={target:0,this:0};for(;!a&&o.this<s.this.length;){const e=s.this[o.this];o.target=s.target.indexOf(e),o.target>=0?a=e:o.this++}if(!a)throw new Error("Internal Babel error - The two compared nodes don't appear to belong to the same program.");if(h(s.this,o.this-1)||h(s.target,o.target-1))return"unknown";const l={this:s.this[o.this-1],target:s.target[o.target-1]};if(l.target.listKey&&l.this.listKey&&l.target.container===l.this.container)return l.target.key>l.this.key?"before":"after";const c=r[a.type],p=c.indexOf(l.this.parentKey);return c.indexOf(l.target.parentKey)>p?"before":"after"}function y(e,t){var n;if(null==(n=t)||!n.includes(this))if((t=t||[]).push(this),this.isVariableDeclarator()){if(this.get("id").isIdentifier())return this.get("init").resolve(e,t)}else if(this.isReferencedIdentifier()){const n=this.scope.getBinding(this.node.name);if(!n)return;if(!n.constant)return;if("module"===n.kind)return;if(n.path!==this){const r=n.path.resolve(e,t);if(this.find(e=>e.node===r.node))return;return r}}else{if(this.isTypeCastExpression())return this.get("expression").resolve(e,t);if(e&&this.isMemberExpression()){const n=this.toComputedKey();if(!o(n))return;const r=n.value,i=this.get("object").resolve(e,t);if(i.isObjectExpression()){const n=i.get("properties");for(const i of n){if(!i.isProperty())continue;const n=i.get("key");let s=i.isnt("computed")&&n.isIdentifier({name:r});if(s=s||n.isLiteral({value:r}),s)return i.get("value").resolve(e,t)}}else if(i.isArrayExpression()&&!isNaN(+r)){const n=i.get("elements")[r];if(n)return n.resolve(e,t)}}}}}(uo)),uo}var fo,mo={};function yo(){if(fo)return mo;fo=1,Object.defineProperty(mo,"__esModule",{value:!0}),mo._getKey=f,mo._getPattern=m,mo.get=function(e,t=!0){!0===t&&(t=this.context);const n=e.split(".");return 1===n.length?f.call(this,e,t):m.call(this,n,t)},mo.getAllNextSiblings=function(){let e=this.key,t=this.getSibling(++e);const n=[];for(;t.node;)n.push(t),t=this.getSibling(++e);return n},mo.getAllPrevSiblings=function(){let e=this.key,t=this.getSibling(--e);const n=[];for(;t.node;)n.push(t),t=this.getSibling(--e);return n},mo.getAssignmentIdentifiers=function(){return n(this.node)},mo.getBindingIdentifierPaths=function(e=!1,t=!1){const n=[this],i=Object.create(null);for(;n.length;){const s=n.shift();if(!s)continue;if(!s.node)continue;const a=r.keys[s.node.type];if(s.isIdentifier())if(e){(i[s.node.name]=i[s.node.name]||[]).push(s)}else i[s.node.name]=s;else{if(s.isExportDeclaration()){const e=s.get("declaration");e.isDeclaration()&&n.push(e);continue}if(t){if(s.isFunctionDeclaration()){n.push(s.get("id"));continue}if(s.isFunctionExpression())continue}if(a)for(let e=0;e<a.length;e++){const t=a[e],r=s.get(t);Array.isArray(r)?n.push(...r):r.node&&n.push(r)}}}return i},mo.getBindingIdentifiers=function(e){return r(this.node,e)},mo.getCompletionRecords=function(e=!1){return h(this,{canHaveBreak:!1,shouldPopulateBreak:!1,inCaseClause:!1,shouldPreserveBreak:e}).map(e=>e.path)},mo.getNextSibling=function(){return this.getSibling(this.key+1)},mo.getOpposite=function(){if("left"===this.key)return this.getSibling("right");if("right"===this.key)return this.getSibling("left");return null},mo.getOuterBindingIdentifierPaths=function(e=!1){return this.getBindingIdentifierPaths(e,!0)},mo.getOuterBindingIdentifiers=function(e){return i(this.node,e)},mo.getPrevSibling=function(){return this.getSibling(this.key-1)},mo.getSibling=function(t){return e.default.get({parentPath:this.parentPath,parent:this.parent,container:this.container,listKey:this.listKey,key:t}).setContext(this.context)};var e=Po(),t=qr();const{getAssignmentIdentifiers:n,getBindingIdentifiers:r,getOuterBindingIdentifiers:i,numericLiteral:s,unaryExpression:a}=t,o=0,l=1;function c(e,t,n){return e&&t.push(...h(e,n)),t}function p(e){e.forEach(e=>{e.type=l})}function u(e,t){e.forEach(e=>{e.path.isBreakStatement({label:null})&&(t?e.path.replaceWith(a("void",s(0))):e.path.remove())})}function d(e,t){const n=[];if(t.canHaveBreak){let r=[];for(let i=0;i<e.length;i++){const s=e[i],a=Object.assign({},t,{inCaseClause:!1});s.isBlockStatement()&&(t.inCaseClause||t.shouldPopulateBreak)?a.shouldPopulateBreak=!0:a.shouldPopulateBreak=!1;const c=h(s,a);if(c.length>0&&c.every(e=>e.type===l)){r.length>0&&c.every(e=>e.path.isBreakStatement({label:null}))?(p(r),n.push(...r),r.some(e=>e.path.isDeclaration())&&(n.push(...c),t.shouldPreserveBreak||u(c,!0)),t.shouldPreserveBreak||u(c,!1)):(n.push(...c),t.shouldPopulateBreak||t.shouldPreserveBreak||u(c,!0));break}if(i===e.length-1)n.push(...c);else{r=[];for(let e=0;e<c.length;e++){const t=c[e];t.type===l&&n.push(t),t.type===o&&r.push(t)}}}}else if(e.length)for(let r=e.length-1;r>=0;r--){const i=h(e[r],t);if(i.length>1||1===i.length&&!i[0].path.isVariableDeclaration()&&!i[0].path.isEmptyStatement()){n.push(...i);break}}return n}function h(e,t){let n=[];if(e.isIfStatement())n=c(e.get("consequent"),n,t),n=c(e.get("alternate"),n,t);else{if(e.isDoExpression()||e.isFor()||e.isWhile()||e.isLabeledStatement())return c(e.get("body"),n,t);if(e.isProgram()||e.isBlockStatement())return d(e.get("body"),t);if(e.isFunction())return h(e.get("body"),t);if(e.isTryStatement())n=c(e.get("block"),n,t),n=c(e.get("handler"),n,t);else{if(e.isCatchClause())return c(e.get("body"),n,t);if(e.isSwitchStatement())return function(e,t,n){let r=[];for(let i=0;i<e.length;i++){const s=h(e[i],n),a=[],c=[];for(const e of s)e.type===o&&a.push(e),e.type===l&&c.push(e);a.length&&(r=a),t.push(...c)}return t.push(...r),t}(e.get("cases"),n,t);if(e.isSwitchCase())return d(e.get("consequent"),{canHaveBreak:!0,shouldPopulateBreak:!1,inCaseClause:!0,shouldPreserveBreak:t.shouldPreserveBreak});e.isBreakStatement()?n.push(function(e){return{type:l,path:e}}(e)):n.push(function(e){return{type:o,path:e}}(e))}}return n}function f(t,n){const r=this.node,i=r[t];return Array.isArray(i)?i.map((s,a)=>e.default.get({listKey:t,parentPath:this,parent:r,container:i,key:a}).setContext(n)):e.default.get({parentPath:this,parent:r,container:r,key:t}).setContext(n)}function m(e,t){let n=this;for(const r of e)n="."===r?n.parentPath:Array.isArray(n)?n[r]:n.get(r,t);return n}return mo}var To,go,So,xo,bo,Eo={};function Po(){if(go)return zr;go=1,Object.defineProperty(zr,"__esModule",{value:!0}),zr.default=zr.SHOULD_STOP=zr.SHOULD_SKIP=zr.REMOVED=void 0;var e=Qr(),t=Ti(),n=No(),r=Bi(),i=qr(),s=i,a=_i(),o=Gs(),l=function(){if(Qs)return Zs;Qs=1,Object.defineProperty(Zs,"__esModule",{value:!0}),Zs.find=function(e){let t=this;do{if(e(t))return t}while(t=t.parentPath);return null},Zs.findParent=function(e){let t=this;for(;t=t.parentPath;)if(e(t))return t;return null},Zs.getAncestry=function(){let e=this;const t=[];do{t.push(e)}while(e=e.parentPath);return t},Zs.getDeepestCommonAncestorFrom=function(e,t){if(!e.length)return this;if(1===e.length)return e[0];let n,r,i=1/0;const s=e.map(e=>{const t=[];do{t.unshift(e)}while((e=e.parentPath)&&e!==this);return t.length<i&&(i=t.length),t}),a=s[0];e:for(let e=0;e<i;e++){const t=a[e];for(const n of s)if(n[e]!==t)break e;n=e,r=t}if(r)return t?t(r,n,s):r;throw new Error("Couldn't find intersection")},Zs.getEarliestCommonAncestorFrom=function(e){return this.getDeepestCommonAncestorFrom(e,function(e,n,r){let i;const s=t[e.type];for(const e of r){const t=e[n+1];i?(t.listKey&&i.listKey===t.listKey&&t.key<i.key||s.indexOf(i.parentKey)>s.indexOf(t.parentKey))&&(i=t):i=t}return i})},Zs.getFunctionParent=function(){return this.findParent(e=>e.isFunction())},Zs.getStatementParent=function(){let e=this;do{if(!e.parentPath||Array.isArray(e.container)&&e.isStatement())break;e=e.parentPath}while(e);if(e&&(e.isProgram()||e.isFile()))throw new Error("File/Program node, we can't possibly find a statement parent to this");return e},Zs.inType=function(...e){let t=this;for(;t;){if(e.includes(t.node.type))return!0;t=t.parentPath}return!1},Zs.isAncestor=function(e){return e.isDescendant(this)},Zs.isDescendant=function(e){return!!this.findParent(t=>t===e)};var e=qr();const{VISITOR_KEYS:t}=e;return Zs}(),c=function(){if(ra)return ia;ra=1,Object.defineProperty(ia,"__esModule",{value:!0}),ia._getTypeAnnotation=P,ia.baseTypeStrictlyMatches=function(e){const t=this.getTypeAnnotation(),n=e.getTypeAnnotation();return!(r(t)||!o(t))&&n.type===t.type},ia.couldBeBaseType=function(e){const t=this.getTypeAnnotation();if(r(t))return!0;if(g(t)){for(const n of t.types)if(r(n)||v(e,n,!0))return!0;return!1}return v(e,t,!0)},ia.getTypeAnnotation=function(){let e=this.getData("typeAnnotation");return null!=e||(e=P.call(this)||n(),(T(e)||f(e))&&(e=e.typeAnnotation),this.setData("typeAnnotation",e)),e},ia.isBaseType=function(e,t){return v(e,this.getTypeAnnotation(),t)},ia.isGenericType=function(e){const t=this.getTypeAnnotation();return!("Array"!==e||!(h(t)||i(t)||y(t)))||(l(t)&&c(t.id,{name:e})||m(t)&&c(t.typeName,{name:e}))};var e=pa(),t=qr();const{anyTypeAnnotation:n,isAnyTypeAnnotation:r,isArrayTypeAnnotation:i,isBooleanTypeAnnotation:s,isEmptyTypeAnnotation:a,isFlowBaseAnnotation:o,isGenericTypeAnnotation:l,isIdentifier:c,isMixedTypeAnnotation:p,isNumberTypeAnnotation:u,isStringTypeAnnotation:d,isTSArrayType:h,isTSTypeAnnotation:f,isTSTypeReference:m,isTupleTypeAnnotation:y,isTypeAnnotation:T,isUnionTypeAnnotation:g,isVoidTypeAnnotation:S,stringTypeAnnotation:x,voidTypeAnnotation:b}=t,E=new WeakSet;function P(){const t=this.node;if(t){if(t.typeAnnotation)return t.typeAnnotation;if(!E.has(t)){E.add(t);try{var r;let n=e[t.type];if(n)return n.call(this,t);if(n=e[this.parentPath.type],null!=(r=n)&&r.validParent)return this.parentPath.getTypeAnnotation()}finally{E.delete(t)}}}else if("init"===this.key&&this.parentPath.isVariableDeclarator()){const e=this.parentPath.parentPath,t=e.parentPath;return"left"===e.key&&t.isForInStatement()?x():"left"===e.key&&t.isForOfStatement()?n():b()}}function v(e,t,n){if("string"===e)return d(t);if("number"===e)return u(t);if("boolean"===e)return s(t);if("any"===e)return r(t);if("mixed"===e)return p(t);if("empty"===e)return a(t);if("void"===e)return S(t);if(n)return!1;throw new Error(`Unknown base type ${e}`)}return ia}(),p=Ma(),u=ja(),d=co(),h=ho(),f=Ao(),m=f,y=Ca(),T=ka(),g=yo(),S=function(){if(To)return Eo;To=1,Object.defineProperty(Eo,"__esModule",{value:!0}),Eo.addComment=function(e,n,r){t(this.node,e,n,r)},Eo.addComments=function(e,t){n(this.node,e,t)},Eo.shareCommentsWithSiblings=function(){if("string"==typeof this.key)return;const e=this.node;if(!e)return;const t=e.trailingComments,n=e.leadingComments;if(!t&&!n)return;const i=this.getSibling(this.key-1),s=this.getSibling(this.key+1),a=Boolean(i.node),o=Boolean(s.node);a&&(n&&i.addComments("trailing",r(n,i.node.trailingComments)),t&&!o&&i.addComments("trailing",t)),o&&(t&&s.addComments("leading",r(t,s.node.leadingComments)),n&&!a&&s.addComments("leading",n))};var e=qr();const{addComment:t,addComments:n}=e;function r(e,t){if(null==t||!t.length)return e;const n=new Set(t);return e.filter(e=>!n.has(e))}return Eo}(),x=Ai();const{validate:b}=i,E=t("babel");zr.REMOVED=1,zr.SHOULD_STOP=2,zr.SHOULD_SKIP=4;const P=zr.default=class e{constructor(e,t){this.contexts=[],this.state=null,this._traverseFlags=0,this.skipKeys=null,this.parentPath=null,this.container=null,this.listKey=null,this.key=null,this.node=null,this.type=null,this._store=null,this.parent=t,this.hub=e,this.data=null,this.context=null,this.scope=null}get removed(){return(1&this._traverseFlags)>0}set removed(e){e?this._traverseFlags|=1:this._traverseFlags&=-2}get shouldStop(){return(2&this._traverseFlags)>0}set shouldStop(e){e?this._traverseFlags|=2:this._traverseFlags&=-3}get shouldSkip(){return(4&this._traverseFlags)>0}set shouldSkip(e){e?this._traverseFlags|=4:this._traverseFlags&=-5}static get({hub:t,parentPath:n,parent:r,container:i,listKey:s,key:o}){if(!t&&n&&(t=n.hub),!r)throw new Error("To get a node path the parent needs to exist");const l=i[o],c=a.getOrCreateCachedPaths(r,n);let p=c.get(l);return p||(p=new e(t,r),l&&c.set(l,p)),f.setup.call(p,n,i,s,o),p}getScope(e){return this.isScope()?new r.default(this):e}setData(e,t){return null==this.data&&(this.data=Object.create(null)),this.data[e]=t}getData(e,t){null==this.data&&(this.data=Object.create(null));let n=this.data[e];return void 0===n&&void 0!==t&&(n=this.data[e]=t),n}hasNode(){return null!=this.node}buildCodeFrameError(e,t=SyntaxError){return this.hub.buildError(this.node,e,t)}traverse(e,t){(0,n.default)(this.node,e,this.scope,t,this)}set(e,t){b(this.node,e,t),this.node[e]=t}getPathLocation(){const e=[];let t=this;do{let n=t.key;t.inList&&(n=`${t.listKey}[${n}]`),e.unshift(n)}while(t=t.parentPath);return e.join(".")}debug(e){E.enabled&&E(`${this.getPathLocation()} ${this.type}: ${e}`)}toString(){return(0,o.default)(this.node).code}get inList(){return!!this.listKey}set inList(e){e||(this.listKey=null)}get parentKey(){return this.listKey||this.key}},v={findParent:l.findParent,find:l.find,getFunctionParent:l.getFunctionParent,getStatementParent:l.getStatementParent,getEarliestCommonAncestorFrom:l.getEarliestCommonAncestorFrom,getDeepestCommonAncestorFrom:l.getDeepestCommonAncestorFrom,getAncestry:l.getAncestry,isAncestor:l.isAncestor,isDescendant:l.isDescendant,inType:l.inType,getTypeAnnotation:c.getTypeAnnotation,isBaseType:c.isBaseType,couldBeBaseType:c.couldBeBaseType,baseTypeStrictlyMatches:c.baseTypeStrictlyMatches,isGenericType:c.isGenericType,replaceWithMultiple:p.replaceWithMultiple,replaceWithSourceString:p.replaceWithSourceString,replaceWith:p.replaceWith,replaceExpressionWithStatements:p.replaceExpressionWithStatements,replaceInline:p.replaceInline,evaluateTruthy:u.evaluateTruthy,evaluate:u.evaluate,toComputedKey:d.toComputedKey,ensureBlock:d.ensureBlock,unwrapFunctionEnvironment:d.unwrapFunctionEnvironment,arrowFunctionToExpression:d.arrowFunctionToExpression,splitExportDeclaration:d.splitExportDeclaration,ensureFunctionName:d.ensureFunctionName,matchesPattern:h.matchesPattern,isStatic:h.isStatic,isNodeType:h.isNodeType,canHaveVariableDeclarationOrExpression:h.canHaveVariableDeclarationOrExpression,canSwapBetweenExpressionAndStatement:h.canSwapBetweenExpressionAndStatement,isCompletionRecord:h.isCompletionRecord,isStatementOrBlock:h.isStatementOrBlock,referencesImport:h.referencesImport,getSource:h.getSource,willIMaybeExecuteBefore:h.willIMaybeExecuteBefore,_guessExecutionStatusRelativeTo:h._guessExecutionStatusRelativeTo,resolve:h.resolve,isConstantExpression:h.isConstantExpression,isInStrictMode:h.isInStrictMode,isDenylisted:m.isDenylisted,visit:m.visit,skip:m.skip,skipKey:m.skipKey,stop:m.stop,setContext:m.setContext,requeue:m.requeue,requeueComputedKeyAndDecorators:m.requeueComputedKeyAndDecorators,remove:y.remove,insertBefore:T.insertBefore,insertAfter:T.insertAfter,unshiftContainer:T.unshiftContainer,pushContainer:T.pushContainer,getOpposite:g.getOpposite,getCompletionRecords:g.getCompletionRecords,getSibling:g.getSibling,getPrevSibling:g.getPrevSibling,getNextSibling:g.getNextSibling,getAllNextSiblings:g.getAllNextSiblings,getAllPrevSiblings:g.getAllPrevSiblings,get:g.get,getAssignmentIdentifiers:g.getAssignmentIdentifiers,getBindingIdentifiers:g.getBindingIdentifiers,getOuterBindingIdentifiers:g.getOuterBindingIdentifiers,getBindingIdentifierPaths:g.getBindingIdentifierPaths,getOuterBindingIdentifierPaths:g.getOuterBindingIdentifierPaths,shareCommentsWithSiblings:S.shareCommentsWithSiblings,addComment:S.addComment,addComments:S.addComments};Object.assign(P.prototype,v),P.prototype.arrowFunctionToShadowed=d[String("arrowFunctionToShadowed")],Object.assign(P.prototype,{has:h[String("has")],is:h[String("is")],isnt:h[String("isnt")],equals:h[String("equals")],hoist:T[String("hoist")],updateSiblingKeys:T.updateSiblingKeys,call:m.call,isBlacklisted:m[String("isBlacklisted")],setScope:m.setScope,resync:m.resync,popContext:m.popContext,pushContext:m.pushContext,setup:m.setup,setKey:m.setKey}),P.prototype._guessExecutionStatusRelativeToDifferentFunctions=h._guessExecutionStatusRelativeTo,P.prototype._guessExecutionStatusRelativeToDifferentFunctions=h._guessExecutionStatusRelativeTo,Object.assign(P.prototype,{_getTypeAnnotation:c._getTypeAnnotation,_replaceWith:p._replaceWith,_resolve:h._resolve,_call:m._call,_resyncParent:m._resyncParent,_resyncKey:m._resyncKey,_resyncList:m._resyncList,_resyncRemoved:m._resyncRemoved,_getQueueContexts:m._getQueueContexts,_removeFromScope:y._removeFromScope,_callRemovalHooks:y._callRemovalHooks,_remove:y._remove,_markRemoved:y._markRemoved,_assertUnremoved:y._assertUnremoved,_containerInsert:T._containerInsert,_containerInsertBefore:T._containerInsertBefore,_containerInsertAfter:T._containerInsertAfter,_verifyNodeList:T._verifyNodeList,_getKey:g._getKey,_getPattern:g._getPattern});for(const e of s.TYPES){const t=`is${e}`,n=s[t];P.prototype[t]=function(e){return n(this.node,e)},P.prototype[`assert${e}`]=function(t){if(!n(this.node,t))throw new TypeError(`Expected node path of type ${e}`)}}Object.assign(P.prototype,x);for(const t of Object.keys(e))"_"!==t[0]&&(s.TYPES.includes(t)||s.TYPES.push(t));return zr}function vo(){if(xo)return Xr;xo=1,Object.defineProperty(Xr,"__esModule",{value:!0}),Xr.traverseNode=function(t,r,i,s,a,o,l){const c=n[t.type];if(!c)return!1;const p=new e.default(i,r,s,a);if(l)return(null==o||!o[a.parentKey])&&p.visitQueue([a]);for(const e of c)if((null==o||!o[e])&&p.visit(t,e))return!0;return!1};var e=function(){if(So)return Hr;So=1,Object.defineProperty(Hr,"__esModule",{value:!0}),Hr.default=void 0;var e=Po(),t=qr(),n=Ao();const{VISITOR_KEYS:r}=t;return Hr.default=class{constructor(e,t,n,r){this.queue=null,this.priorityQueue=null,this.parentPath=r,this.scope=e,this.state=n,this.opts=t}shouldVisit(e){const t=this.opts;if(t.enter||t.exit)return!0;if(t[e.type])return!0;const n=r[e.type];if(null==n||!n.length)return!1;for(const t of n)if(e[t])return!0;return!1}create(t,n,r,i){return e.default.get({parentPath:this.parentPath,parent:t,container:n,key:r,listKey:i})}maybeQueue(e,t){this.queue&&(t?this.queue.push(e):this.priorityQueue.push(e))}visitMultiple(e,t,n){if(0===e.length)return!1;const r=[];for(let i=0;i<e.length;i++){const s=e[i];s&&this.shouldVisit(s)&&r.push(this.create(t,e,i,n))}return this.visitQueue(r)}visitSingle(e,t){return!!this.shouldVisit(e[t])&&this.visitQueue([this.create(e,e,t)])}visitQueue(e){this.queue=e,this.priorityQueue=[];const t=new WeakSet;let r=!1,i=0;for(;i<e.length;){const s=e[i];if(i++,n.resync.call(s),0!==s.contexts.length&&s.contexts[s.contexts.length-1]===this||n.pushContext.call(s,this),null===s.key)continue;const{node:a}=s;if(!t.has(a)){if(a&&t.add(a),s.visit()){r=!0;break}if(this.priorityQueue.length&&(r=this.visitQueue(this.priorityQueue),this.priorityQueue=[],this.queue=e,r))break}}for(let t=0;t<i;t++)n.popContext.call(e[t]);return this.queue=null,r}visit(e,t){const n=e[t];return!!n&&(Array.isArray(n)?this.visitMultiple(n,e,t):this.visitSingle(e,t))}},Hr}();Po();var t=qr();Ao();const{VISITOR_KEYS:n}=t;return Xr}function Ao(){if(bo)return Yr;bo=1,Object.defineProperty(Yr,"__esModule",{value:!0}),Yr._call=s,Yr._getQueueContexts=function(){let e=this,t=this.contexts;for(;!t.length&&(e=e.parentPath,e);)t=e.contexts;return t},Yr._resyncKey=p,Yr._resyncList=u,Yr._resyncParent=c,Yr._resyncRemoved=function(){null!=this.key&&this.container&&this.container[this.key]===this.node||n._markRemoved.call(this)},Yr.call=i,Yr.isDenylisted=a,Yr.popContext=function(){this.contexts.pop(),this.contexts.length>0?this.setContext(this.contexts[this.contexts.length-1]):this.setContext(void 0)},Yr.pushContext=function(e){this.contexts.push(e),this.setContext(e)},Yr.requeue=function(e=this){if(e.removed)return;const t=this.contexts;for(const n of t)n.maybeQueue(e)},Yr.requeueComputedKeyAndDecorators=function(){const{context:e,node:t}=this;!r.isPrivate(t)&&t.computed&&e.maybeQueue(this.get("key"));if(t.decorators)for(const t of this.get("decorators"))e.maybeQueue(t)},Yr.resync=function(){if(this.removed)return;c.call(this),u.call(this),p.call(this)},Yr.setContext=function(e){null!=this.skipKeys&&(this.skipKeys={});this._traverseFlags=0,e&&(this.context=e,this.state=e.state,this.opts=e.opts);return l.call(this),this},Yr.setKey=d,Yr.setScope=l,Yr.setup=function(e,t,n,r){this.listKey=n,this.container=t,this.parentPath=e||this.parentPath,d.call(this,r)},Yr.skip=function(){this.shouldSkip=!0},Yr.skipKey=function(e){null==this.skipKeys&&(this.skipKeys={});this.skipKeys[e]=!0},Yr.stop=function(){this._traverseFlags|=t.SHOULD_SKIP|t.SHOULD_STOP},Yr.visit=function(){var t,n;if(!this.node)return!1;if(this.isDenylisted())return!1;if(null!=(t=(n=this.opts).shouldSkip)&&t.call(n,this))return!1;const r=this.context;if(this.shouldSkip||i.call(this,"enter"))return this.debug("Skip..."),this.shouldStop;return o(this,r),this.debug("Recursing into..."),this.shouldStop=(0,e.traverseNode)(this.node,this.opts,this.scope,this.state,this,this.skipKeys),o(this,r),i.call(this,"exit"),this.shouldStop};var e=vo(),t=Po(),n=Ca(),r=qr();function i(e){const t=this.opts;return this.debug(e),!(!this.node||!s.call(this,t[e]))||!!this.node&&s.call(this,null==(n=t[this.node.type])?void 0:n[e]);var n}function s(e){if(!e)return!1;for(const t of e){if(!t)continue;const e=this.node;if(!e)return!0;const n=t.call(this.state,this,this.state);if(n&&"object"==typeof n&&"function"==typeof n.then)throw new Error("You appear to be using a plugin with an async traversal visitor, which your current version of Babel does not support. If you're using a published plugin, you may need to upgrade your @babel/core version.");if(n)throw new Error(`Unexpected return value from visitor method ${t}`);if(this.node!==e)return!0;if(this._traverseFlags>0)return!0}return!1}function a(){var e;const t=null!=(e=this.opts.denylist)?e:this.opts.blacklist;return null==t?void 0:t.includes(this.node.type)}function o(e,t){e.context!==t&&(e.context=t,e.state=t.state,e.opts=t.opts)}function l(){var e,t;if(null!=(e=this.opts)&&e.noScope)return;let n,r=this.parentPath;for((("key"===this.key||"decorators"===this.listKey)&&r.isMethod()||"discriminant"===this.key&&r.isSwitchStatement())&&(r=r.parentPath);r&&!n;){var i;if(null!=(i=r.opts)&&i.noScope)return;n=r.scope,r=r.parentPath}this.scope=this.getScope(n),null==(t=this.scope)||t.init()}function c(){this.parentPath&&(this.parent=this.parentPath.node)}function p(){if(this.container&&this.node!==this.container[this.key]){if(Array.isArray(this.container)){for(let e=0;e<this.container.length;e++)if(this.container[e]===this.node)return void d.call(this,e)}else for(const e of Object.keys(this.container))if(this.container[e]===this.node)return void d.call(this,e);this.key=null}}function u(){if(!this.parent||!this.inList)return;const e=this.parent[this.listKey];this.container!==e&&(this.container=e||null)}function d(e){var t;this.key=e,this.node=this.container[this.key],this.type=null==(t=this.node)?void 0:t.type}return Yr.isBlacklisted=a,Yr}var Co,wo,Io={};function No(){return wo||(wo=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Hub",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,"NodePath",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return a.default}}),e.visitors=e.default=void 0,Ao();var t=Ci();e.visitors=t;var n=qr(),r=_i(),i=vo(),s=Po(),a=Bi(),o=(Co||(Co=1,Object.defineProperty(Io,"__esModule",{value:!0}),Io.default=void 0,Io.default=class{getCode(){}getScope(){}addHelper(){throw new Error("Helpers are not supported by the default hub.")}buildError(e,t,n=TypeError){return new n(t)}}),Io);const{VISITOR_KEYS:l,removeProperties:c,traverseFast:p}=n;function u(e,n={},r,s,a,o){if(e){if(!n.noScope&&!r&&"Program"!==e.type&&"File"!==e.type)throw new Error(`You must pass a scope and parentPath unless traversing a Program/File. Instead of that you tried to traverse a ${e.type} node without passing scope and parentPath.`);if(!a&&o)throw new Error("visitSelf can only be used when providing a NodePath.");l[e.type]&&(t.explode(n),(0,i.traverseNode)(e,n,r,s,a,void 0,o))}}e.default=u,u.visitors=t,u.verify=t.verify,u.explode=t.explode,u.cheap=function(e,t){p(e,t)},u.node=function(e,t,n,r,s,a){(0,i.traverseNode)(e,t,n,r,s,a)},u.clearNode=function(e,t){c(e,t)},u.removeProperties=function(e,t){return p(e,u.clearNode,t),e},u.hasType=function(e,t,n){return(null==n||!n.includes(e.type))&&(e.type===t||p(e,function(e){return null!=n&&n.includes(e.type)?p.skip:e.type===t?p.stop:void 0}))},u.cache=r}($r)),$r}var ko=U(No()),Oo=U(La());function Do(e){return Oo.parse(e,{sourceType:"module",plugins:["jsx","typescript","classProperties","dynamicImport","exportDefaultFrom","exportNamespaceFrom","functionBind","nullishCoalescingOperator","objectRestSpread","optionalChaining","decorators-legacy"],allowAwaitOutsideFunction:!0})}const _o={is:e=>Jr.isStringLiteral(e),get:e=>e.value},Lo={is:e=>Jr.isNumericLiteral(e),get:e=>e.value},Mo={is:e=>Jr.isBooleanLiteral(e),get:e=>e.value},Fo={is:e=>Jr.isNullLiteral(e),get:e=>null},Bo={is:e=>Jr.isIdentifier(e)&&"undefined"===e.name,get(e){}},jo={is:e=>Jr.isObjectExpression(e),get:e=>Wo(e)},Ro={is:e=>Jr.isClass(e),get:e=>function(e){function t(e){return"static"in e&&!0===e.static}let n=e.body;if(!Jr.isClassBody(n))return;const r={};return n.body.forEach(e=>{if(t(e)&&Jr.isIdentifier(e.key))if(Jr.isMethod(e)||Jr.isTSDeclareMethod(e))r[e.key.name]=()=>{};else{const t=qo.find(t=>t.is(e.value));t&&(r[e.key.name]=t.get(e.value))}}),r}(e)},Uo={is:e=>Jr.isArrayExpression(e),get:e=>Jo(e)},Ko={is:e=>Jr.isFunctionExpression(e),get:e=>function(){}},Vo={is:e=>Jr.isArrowFunctionExpression(e),get:e=>()=>{}},qo=[_o,Lo,Mo,Fo,Bo,jo,Uo,Ro,Ko,Vo];function Wo(e){const t={};return e.properties.forEach(e=>{if(Jr.isObjectMember(e)&&Jr.isIdentifier(e.key))if(Jr.isObjectMethod(e))t[e.key.name]=()=>{};else{const n=qo.find(t=>t.is(e.value));n&&(t[e.key.name]=n.get(e.value))}}),t}function Jo(e){const t=[];return e.elements.forEach(e=>{const n=qo.find(t=>t.is(e));n&&t.push(n.get(e))}),t}function $o(e){const t=Do(e);let n;return ko(t,{Program:{enter(e){const t=e.node,r=function(e){for(const t of e.body)if(Jr.isExportDefaultDeclaration(t))return t.declaration;return null}(t);if(r)if(Jr.isIdentifier(r)){const{name:e}=r;n=function(e){const t={};for(const n of e.programNode.body){let r=n;if(Jr.isExpressionStatement(r)&&(r=r.expression),Jr.isAssignmentExpression(r)&&Jr.isMemberExpression(r.left)&&Jr.isIdentifier(r.left.object)&&r.left.object.name===e.name){const e=qo.find(e=>e.is(Jr.isAssignmentExpression(r)&&r.right));e&&(t[r.left.property.name]=e.get(r.right))}}return t}({programNode:t,name:e})}else if(Jr.isObjectExpression(r))n=Wo(r);else if(Jr.isArrayExpression(r))n=Jo(r);else{const e=qo.find(e=>e.is(r));e&&(n=e.get(r))}}}}),n}function Yo(e){return/^\\\\\?\\/.test(e)?e:e.replace(/\\/g,"/")}const Xo={javascript:[".ts",".tsx",".js",".jsx"],css:[".less",".sass",".scss",".stylus",".css"]};function Ho(e){const t=Xo[e.type];for(const r of t){const t=`${e.fileNameWithoutExt}${r}`,i=Yo(n(e.base,t));if(p(i))return{path:i,filename:t}}return null}const zo=/^\[(.+?)\]/;function Go(e){return p(e)?u(e).filter(t=>{const r=n(e,t),i=d(r),s=i.isDirectory(),a=i.isFile();if(s&&["components","component","utils","util"].includes(t))return!1;if("."===t.charAt(0))return!1;if("_"===t.charAt(0))return!1;if(/\.(test|spec|e2e)\.(j|t)sx?$/.test(t))return!1;if(/\.d\.ts$/.test(t))return!1;if(a){if(!/\.(j|t)sx?$/.test(t))return!1;const e=h(r,"utf-8");try{if(!function(e){const t=Do(e);let n=!1;return ko(t,{JSXElement(e){n=!0,e.stop()},JSXFragment(e){n=!0,e.stop()}}),n}(e))return!1}catch(e){throw new Error(`Parse conventional route component ${r} failed, ${e.message}`)}}return!0}):[]}function Qo(e,t,s){const{root:a,relDir:o=""}=e,l=n(a,o,s),c=d(l),p=zo.test(s);if(c.isDirectory()){const r=n(o,s),i=Ho({base:n(a,r),fileNameWithoutExt:"_layout",type:"javascript"}),l={path:el(r),routes:tl({...e,relDir:n(r)}),__isDynamic:p,...i?{component:i.path}:{exact:!0,__toMerge:!0}};t.push(Zo(l,e))}else{const a=r(s,i(s));t.push(Zo({path:el(n(o,a)),exact:!0,component:l,__isDynamic:p},e))}return t}function Zo(e,t){let r;if(e.component){try{r=$o(h(e.component,"utf-8"))}catch(t){throw new Error(`Parse conventional route component ${e.component} failed, ${t.message}`)}e.component=Yo(s(n(t.root,".."),e.component)),e.component=`${t.componentPrefix||"@/"}${e.component}`}return{...e,..."object"==typeof r?r:{}}}function el(e,t){return"/index/index"===(e=`/${e=Yo(e).split("/").map(e=>((e=e.replace(zo,":$1")).endsWith("$")&&(e=e.slice(0,-1)+"?"),e)).join("/")}`)&&(e="/"),"/"!==(e=e.replace(/\/index$/,"/"))&&"/"===e.slice(-1)&&(e=e.slice(0,-1)),e}function tl(e){const{root:t,relDir:r="",config:i}=e,s=function(e){const t=[],n=[],r=[];return e.forEach(e=>{const{__isDynamic:i,exact:s}=e;delete e.__isDynamic,i?t.push(e):s?n.push(e):r.push(e)}),S(t.length<=1,"We should not have multiple dynamic routes under a directory."),[...n,...r,...t].reduce((e,t)=>(t.__toMerge&&t.routes?e=e.concat(t.routes):e.push(t),e),[])}(Go(n(t,r)).reduce(Qo.bind(null,e),[]));if(!r){const n=Ho({base:t,fileNameWithoutExt:`../${i.singular?"layout":"layouts"}/index`,type:"javascript"});if(n)return[Zo({path:"/",component:n.path,routes:s},e)]}return s}function nl(t){const n=e.extname(t);if(![".tsx",".ts",".jsx",".js"].includes(n))return!1;try{const e=l.readFileSync(t,"utf-8");return/export\s+default/.test(e)}catch{return!1}}function rl(e){const t={path:e.path||""};if(void 0!==e.exact&&(t.exact=e.exact),e.component){const n=e.component.replace(/\.(tsx|ts|jsx|js)$/,"");t.component=`dynamic({ loader: () => import('${n}'), loading: LoadingComponent})`}return e.title&&"string"==typeof e.title&&(t.title=`$t({ defaultMessage: "${e.title}" })`),!0===e.keepAlive&&(t.keepAlive=!0),e.authority&&Array.isArray(e.authority)&&(t.authority=e.authority),e.routes&&e.routes.length>0&&(t.routes=e.routes.map(rl)),t}function il(e,t){return tl({root:e,componentPrefix:t.pageAliasPrefix,config:{singular:!1}}).map(rl)}async function sl(t,n){function r(e,t=2){const n=" ".repeat(t),i=" ".repeat(t+2);let s=`${n}{\n`;if(s+=`${i}path: '${e.path}',\n`,void 0!==e.exact&&null!==e.exact&&(s+=`${i}exact: ${e.exact},\n`),void 0!==e.component&&null!==e.component&&(s+=`${i}component: ${e.component},\n`),void 0!==e.title&&null!==e.title&&(s+=`${i}title: ${e.title},\n`),e.authority&&(s+=`${i}authority: ${JSON.stringify(e.authority)},\n`),e.keepAlive&&(s+=`${i}keepAlive: ${e.keepAlive},\n`),e.routes&&e.routes.length>0){s+=`${i}routes: [\n${e.routes.map(e=>r(e,t+2)).join(",\n")}\n${i}],\n`}return s=s.replace(/,\n$/,"\n"),s+=`${n}}`,s}const i=t.map(e=>r(e)).join(",\n"),s=`\n/* eslint-disable */\n// @ts-nocheck\n/**\n * 自动根据 pages 目录生成路由配置\n * 新增、删除、修改组件 title、keepAlive、authority 属性时,会自动更新路由配置\n * 路由组件只支持默认导出\n */\nimport { dynamic } from '@lemon-fe/vite-plugin-micro-frontend/runtime';\nimport LoadingComponent from '${n.defaultLoadingComponentPath||"@/components/loading"}';\nimport { $t } from '${n.intlPath||"@/utils/intl"}';\n\nexport const routers = [\n${i}\n];\n`;try{const t=e.resolve(process.cwd(),".prettierrc");let n={};if(l.existsSync(t))try{const e=l.readFileSync(t,"utf-8");n=JSON.parse(e)}catch(e){console.warn("⚠️ 读取 prettier 配置失败,使用默认配置:",e)}const r={parser:"typescript",...n};return await m.format(s,r)}catch(e){return console.error("格式化代码失败:",e),s}}async function al(t={}){const{pagesDir:n,outputPath:r,routeTemplate:i={}}=t,s=n||e.resolve(process.cwd(),"src/pages"),a=r||e.resolve(process.cwd(),"src/routes.ts");if(!l.existsSync(s))return void console.warn("⚠️ pages 目录不存在:",s);const o=il(s,i),c=await sl(o,i);l.writeFileSync(a,c),console.log("✅ 路由已生成:",a)}function ol(t={}){const{pagesDir:n,outputPath:r,watch:i=!0,ignoreDirs:s=["components","utils","hooks","typings"],routeTemplate:a={}}=t;let o=!1,c=null,p=!1,u="";const d=n||e.resolve(process.cwd(),"src/pages"),h=r||e.resolve(process.cwd(),"src/routes.ts"),m=async()=>{if(!l.existsSync(d))return void console.warn("⚠️ pages 目录不存在:",d);const e=il(d,a),t=await sl(e,a);t!==u&&(u=t,l.writeFileSync(h,t),console.log("✅ 路由已生成:",h))},y=()=>{c&&(c.close(),c=null,o=!1)};return{name:"micro-frontend:routes",enforce:"pre",configureServer(e){p||(m(),p=!0),(()=>{if(o||!i)return;if(!l.existsSync(d))return;const e=["**/node_modules/**","**/*.d.ts","**/*.less","**/*.css","**/*.scss","**/*.sass",h,...s.map(e=>`**/${e}/**`)];c=f.watch(d,{ignored:e,persistent:!0,ignoreInitial:!0}),c.on("add",e=>{nl(e)&&m()}).on("unlink",e=>{nl(e)&&m()}).on("addDir",e=>{m()}).on("unlinkDir",e=>{m()}).on("error",e=>{console.error("❌ 文件监听错误:",e)}),o=!0})(),e.httpServer?.on("close",y)},buildStart(){p||(m(),p=!0)}}}function ll(t){const{remotes:n,outputPath:r}=t,i=r||e.resolve(process.cwd(),"src/utils/mf.tsx"),s=function(e){const t=function(e){return e.reduce((e,t)=>(e[t.aliasName||t.remoteName]=t,e),{})}(e),n=JSON.stringify(t,null,2);return"/* eslint-disable */\nimport { lazy, Suspense, type ReactNode, type ComponentType } from 'react';\n\n// 远程模块配置\nconst remotes = __REMOTES_JSON__ as const;\n\ntype RemoteAlias = keyof typeof remotes;\ntype ModuleSpecifier = `${RemoteAlias}/${string}`;\n\n// 多个入口文件之间共享的变量\nconst entryShared = (window as any).__entry_shared__ || {};\n\n// 脚本加载状态: undefined=未加载, Promise=加载中, true=已完成\nconst scriptCache: Record<string, Promise<void> | true | undefined> = {};\n\n/**\n * 获取多入口共享变量(懒初始化单例)\n */\nexport function getEntryShared<T>(key: string, init: () => T): T {\n return (entryShared[key] ??= init()) as T;\n}\n\n/**\n * 安全加载远程组件\n */\nexport function safeRemoteComponent<T extends ComponentType<any>>(opts: {\n moduleSpecifier: ModuleSpecifier;\n fallbackComponent: T;\n loadingElement?: ReactNode;\n}): T {\n const LazyComponent = lazy<T>(() =>\n loadRemoteModule(opts.moduleSpecifier, { default: opts.fallbackComponent }),\n );\n\n return ((props: any) => (\n <Suspense fallback={opts.loadingElement ?? null}>\n <LazyComponent {...props} />\n </Suspense>\n )) as T;\n}\n\n// ============ 内部实现 ============\n\nasync function loadRemoteModule<T>(specifier: ModuleSpecifier, fallback: T): Promise<T> {\n try {\n const slashIndex = specifier.indexOf('/');\n const alias = specifier.slice(0, slashIndex) as RemoteAlias;\n const moduleName = specifier.slice(slashIndex + 1);\n const remote = remotes[alias];\n\n if (!remote) {\n console.error(`[MF] Unknown remote alias: \"${alias}\"`);\n return fallback;\n }\n\n // Some remotes may not have isESModule property, default to false if missing\n const isESModule = (remote as any).isESModule ?? false;\n await loadScriptOnce(remote.remoteName, remote.entry, isESModule);\n\n const container = (window as any)[remote.remoteName];\n\n if (!container) {\n console.error(`[MF] Container \"${remote.remoteName}\" not found on window`);\n return fallback;\n }\n\n // 对于 ES Module 联邦,需要先调用 init 初始化共享模块\n // if (isESModule && typeof container.init === 'function') {\n // // 初始化共享作用域(如果还没有初始化过)\n // const shareScope = (window as any).__federation_shared__ || {};\n // (window as any).__federation_shared__ = shareScope;\n // await container.init(shareScope);\n // }\n\n const factory = await container.get(`./${moduleName}`);\n const module = factory();\n\n // 确保返回 { default: Component } 格式给 React.lazy\n if (module && typeof module === 'object' && 'default' in module) {\n return module as T;\n }\n\n // 如果模块本身就是组件,包装成 { default: Component }\n return { default: module } as T;\n } catch (e) {\n console.error('[MF] Load remote module failed:', e);\n return fallback;\n }\n}\n\nasync function loadScriptOnce(name: string, url: string, isESModule?: boolean): Promise<void> {\n const cached = scriptCache[name];\n\n if (cached === true) return;\n if (cached) return cached;\n\n const promise = (async () => {\n const fullUrl = `${url}?t=${Date.now()}`;\n const baseUrl = window.location.origin;\n\n // ES Module 格式\n if (isESModule) {\n try {\n const module = await import(/* @vite-ignore */ `${baseUrl}${fullUrl}`);\n\n // Vite Module Federation 通常直接导出 get/init,而不是 default\n const container = module.default || module;\n\n // 验证容器是否有效\n if (typeof container.get !== 'function') {\n console.error('[MF] Invalid container: missing get() method', container);\n throw new Error(`Container \"${name}\" has no get() method`);\n }\n\n (window as any)[name] = container;\n return;\n } catch (e) {\n console.error('[MF] ES Module load failed:', e);\n throw e; // 对于明确指定 isESModule 的情况,不应该回退\n }\n }\n\n // 回退到 UMD 格式\n await new Promise<void>((resolve, reject) => {\n const script = document.createElement('script');\n script.src = fullUrl;\n script.async = true;\n script.onload = () => resolve();\n script.onerror = reject;\n document.head.appendChild(script);\n });\n })().then(\n () => {\n scriptCache[name] = true;\n },\n e => {\n scriptCache[name] = undefined;\n throw e;\n },\n );\n\n scriptCache[name] = promise;\n return promise;\n}\n\n".replace("__REMOTES_JSON__",n)}(n),a=e.dirname(i);if(l.existsSync(a)||l.mkdirSync(a,{recursive:!0}),l.existsSync(i)){if(l.readFileSync(i,"utf-8")===s)return}l.writeFileSync(i,s),console.log("✅ mf.tsx 已生成:",i)}function cl(e){return{name:"micro-frontend:mf-generator",enforce:"pre",configResolved(){ll(e)},buildStart(){ll(e)}}}const pl=x(import.meta.url);let ul={};try{const e=pl.resolve("@module-federation/dts-plugin/dynamic-remote-type-hints-plugin");ul["@module-federation/dts-plugin/dynamic-remote-type-hints-plugin"]=e}catch{}function dl(e){return e.replace(/\\/g,"/")}function hl(t){const n=function(t){const n={},r=[".tsx",".ts"];if(!l.existsSync(t))return n;const i=l.readdirSync(t,{withFileTypes:!0});for(const s of i)if(s.isDirectory()){const r=e.join(t,s.name),i=["index.tsx","index.ts"];let a=null;for(const t of i){const n=e.join(r,t);if(l.existsSync(n)){a=n;break}}if(a){const t=dl(e.relative(process.cwd(),a));n[`./${s.name}`]=`./${t}`}else console.warn(`⚠️ ${s.name} 目录下没有找到入口文件,已忽略`)}else{const i=e.extname(s.name);if(r.includes(i)){const r=e.join(t,s.name),a=dl(e.relative(process.cwd(),r));n[`./${e.basename(s.name,i)}`]=`./${a}`}}return n}(e.resolve(process.cwd(),t.exposesDir??"src/exposes"));return{...n,...t.exposes||{}}}function fl(t){const n=[];n.push(0===Object.keys(ul).length?{name:"mf-dts-plugin-alias",config:()=>({})}:{name:"mf-dts-plugin-alias",enforce:"pre",config:()=>({resolve:{alias:ul}})});const r=function(e,t){if(!e||0===e.length)return;const n={};for(const r of e){const{remoteName:e,entry:i}=r,s=i.startsWith("/")?i:`/${i}`;if(i.startsWith("http"))n[e]=i;else if(t){const r=t.endsWith("/")?t.slice(0,-1):t;n[e]=`${r}${s}`}n[e]=s}return n}(t.remotes,t.devHost),i=hl(t);return n.push(b({filename:t.filename||"remote.js",hostInitInjectLocation:t.hostInitInjectLocation||"entry",...t,remotes:r,exposes:i})),t.remotes&&t.remotes.length>0&&n.push(cl({remotes:t.remotes,outputPath:t.outputPath?e.resolve(process.cwd(),t.outputPath):"src/utils/mf.tsx"})),n}const ml=E(import.meta.url);function yl(){let e="";return{name:"micro-frontend:antd-external",enforce:"pre",config(n,r){const i=ml.resolve("antd/es/index.js"),s=c.readFileSync(i,"utf-8"),a=new Set,o=/export\s*\{\s*default\s+as\s+(\w+)\s*\}/g;let l;for(;l=o.exec(s);)a.add(l[1]);const p=/export\s+var\s+(\w+)\s*=/g;for(;l=p.exec(s);)a.add(l[1]);const u=`/**\n * 自动生成的 antd 代理文件\n * 由 autoExternalAntd 插件生成,请勿手动修改\n */\nconst antd = (window as any).antd;\n\n${[...a].map(e=>`export const ${e} = antd.${e};`).join("\n")}\n\nexport default antd;\n`;e=t.resolve(process.cwd(),"src/.external/antd.ts"),c.mkdirSync(t.dirname(e),{recursive:!0}),c.writeFileSync(e,u);const d=n.resolve?.alias,h=Array.isArray(d)?d:d?Object.entries(d).map(([e,t])=>({find:e,replacement:t})):[];return{resolve:{alias:[...h,{find:/^antd$/,replacement:e}]}}}}}const Tl={pagesDir:"src/pages",outputPath:"src/routes.ts",watch:!0,ignoreDirs:["components","utils","hooks","typings"],routeTemplate:{defaultLoadingComponentPath:"@/components/loading",intlPath:"@/utils/intl"}};function gl(t){const{appName:n,federation:r,routes:i,htmlTransform:s=!0,qiankun:o}=t,l=[];if(s){const e="object"==typeof s?s:{};l.push(j(e))}const c="object"==typeof i?Object.assign(Tl,i):Tl;if(l.push(ol({pagesDir:c.pagesDir?e.resolve(process.cwd(),c.pagesDir):void 0,outputPath:c.outputPath?e.resolve(process.cwd(),c.outputPath):void 0,watch:c.watch,ignoreDirs:c.ignoreDirs,routeTemplate:c.routeTemplate})),!1!==o?.enabled){const e=o?.name||n,t="development"===process.env.NODE_ENV;l.push(a(e,{useDevMode:t}))}return r&&(l.push(...fl(r)),l.push(B({relativeCSSInjection:!0}))),l}export{yl as autoExternalAntd,B as cssInjectedByJsPlugin,j as devHmrPlugin,fl as federationPlugin,ll as generateMf,al as generateRoutesToFile,tl as getRoutes,cl as mfGeneratorPlugin,gl as microFrontendPlugins,ol as pagesRoutesPlugin};
13
+ `;return this.replaceWith(p)[0].get("arguments.0")},Ua.splitExportDeclaration=function(){if(!this.isExportDeclaration()||this.isExportAllDeclaration())throw new Error("Only default and named export declarations can be split.");if(this.isExportNamedDeclaration()&&this.get("specifiers").length>0)throw new Error("It doesn't make sense to split exported specifiers.");const e=this.get("declaration");if(this.isExportDefaultDeclaration()){const t=e.isFunctionDeclaration()||e.isClassDeclaration(),n=e.isFunctionExpression()||e.isClassExpression(),r=e.isScope()?e.scope.parent:e.scope;let i=e.node.id,s=!1;i?n&&r.hasBinding(i.name)&&(s=!0,i=r.generateUidIdentifier(i.name)):(s=!0,i=r.generateUidIdentifier("default"),(t||n)&&(e.node.id=L(i)));const a=t?e.node:M("var",[F(L(i),e.node)]),o=B(null,[j(L(i),u("default"))]);return this.insertAfter(o),this.replaceWith(a),s&&r.registerDeclaration(this),this}if(this.get("specifiers").length>0)throw new Error("It doesn't make sense to split exported specifiers.");const t=e.getOuterBindingIdentifiers(),n=Object.keys(t).map(e=>j(u(e),u(e))),r=B(null,n);return this.insertAfter(r),this.replaceWith(e.node),this},Ua.toComputedKey=function(){let e;if(this.isMemberExpression())e=this.node.property;else{if(!this.isProperty()&&!this.isMethod())throw new ReferenceError("todo");e=this.node.key}this.node.computed||d(e)&&(e=v(e.name));return e},Ua.unwrapFunctionEnvironment=function(){if(!this.isArrowFunctionExpression()&&!this.isFunctionExpression()&&!this.isFunctionDeclaration())throw this.buildCodeFrameError("Can only unwrap the environment of a function.");K(this)};var e=qr(),t=function(){if(io)return Ka;io=1,Object.defineProperty(Ka,"__esModule",{value:!0}),Ka.statements=Ka.statement=Ka.smart=Ka.program=Ka.expression=Ka.default=void 0;var e=qa(),t=lo();const n=Ka.smart=(0,t.default)(e.smart),r=Ka.statement=(0,t.default)(e.statement),i=Ka.statements=(0,t.default)(e.statements),s=Ka.expression=(0,t.default)(e.expression),a=Ka.program=(0,t.default)(e.program);return Ka.default=Object.assign(n.bind(void 0),{smart:n,statement:r,statements:i,expression:s,program:a,ast:n.ast}),Ka}(),n=Ci(),r=Ao();const{arrowFunctionExpression:i,assignmentExpression:s,binaryExpression:a,blockStatement:o,callExpression:l,conditionalExpression:c,expressionStatement:p,identifier:u,isIdentifier:d,jsxIdentifier:h,logicalExpression:f,LOGICAL_OPERATORS:m,memberExpression:y,metaProperty:T,numericLiteral:g,objectExpression:S,restElement:x,returnStatement:b,sequenceExpression:E,spreadElement:P,stringLiteral:v,super:A,thisExpression:C,toExpression:w,unaryExpression:I,toBindingIdentifierName:N,isFunction:k,isAssignmentPattern:O,isRestElement:D,getFunctionName:_,cloneNode:L,variableDeclaration:M,variableDeclarator:F,exportNamedDeclaration:B,exportSpecifier:j,inherits:R}=e;Ua.arrowFunctionToShadowed=function(){this.isArrowFunctionExpression()&&this.arrowFunctionToExpression()};const U=(0,n.environmentVisitor)({CallExpression(e,{allSuperCalls:t}){e.get("callee").isSuper()&&t.push(e)}});function K(e,t=!0,n=!0,r=!0){let o,p=e.findParent(e=>e.isArrowFunctionExpression()?(null!=o||(o=e),!1):e.isFunction()||e.isProgram()||e.isClassProperty({static:!1})||e.isClassPrivateProperty({static:!1}));const d=p.isClassMethod({kind:"constructor"});if(p.isClassProperty()||p.isClassPrivateProperty())if(o)p=o;else{if(!n)throw e.buildCodeFrameError("Unable to transform arrow inside class property");e.replaceWith(l(i([],w(e.node)),[])),p=e.get("callee"),e=p.get("body")}const{thisPaths:S,argumentsPaths:b,newTargetPaths:N,superProps:k,superCalls:O}=function(e){const t=[],n=[],r=[],i=[],s=[];return e.traverse(J,{thisPaths:t,argumentsPaths:n,newTargetPaths:r,superProps:i,superCalls:s}),{thisPaths:t,argumentsPaths:n,newTargetPaths:r,superProps:i,superCalls:s}}(e);if(d&&O.length>0){if(!n)throw O[0].buildCodeFrameError("When using '@babel/plugin-transform-arrow-functions', it's not possible to compile `super()` in an arrow function without compiling classes.\nPlease add '@babel/plugin-transform-classes' to your Babel configuration.");if(!r)throw O[0].buildCodeFrameError("When using '@babel/plugin-transform-parameters', it's not possible to compile `super()` in an arrow function with default or rest parameters without compiling classes.\nPlease add '@babel/plugin-transform-classes' to your Babel configuration.");const e=[];p.traverse(U,{allSuperCalls:e});const t=function(e){return W(e,"supercall",()=>{const t=e.scope.generateUidIdentifier("args");return i([x(t)],l(A(),[P(u(t.name))]))})}(p);e.forEach(e=>{const n=u(t);n.loc=e.node.callee.loc,e.get("callee").replaceWith(n)})}if(b.length>0){const e=W(p,"arguments",()=>{const e=()=>u("arguments");return p.scope.path.isProgram()?c(a("===",I("typeof",e()),v("undefined")),p.scope.buildUndefinedNode(),e()):e()});b.forEach(t=>{const n=u(e);n.loc=t.node.loc,t.replaceWith(n)})}if(N.length>0){const e=W(p,"newtarget",()=>T(u("new"),u("target")));N.forEach(t=>{const n=u(e);n.loc=t.node.loc,t.replaceWith(n)})}if(k.length>0){if(!n)throw k[0].buildCodeFrameError("When using '@babel/plugin-transform-arrow-functions', it's not possible to compile `super.prop` in an arrow function without compiling classes.\nPlease add '@babel/plugin-transform-classes' to your Babel configuration.");k.reduce((e,t)=>e.concat(function(e){if(e.parentPath.isAssignmentExpression()&&"="!==e.parentPath.node.operator){const n=e.parentPath,r=n.node.operator.slice(0,-1),i=n.node.right,a=function(e){return m.includes(e)}(r);if(e.node.computed){const o=e.scope.generateDeclaredUidIdentifier("tmp"),{object:l,property:c}=e.node;n.get("left").replaceWith(y(l,s("=",o,c),!0)),n.get("right").replaceWith(t(a?"=":r,y(l,u(o.name),!0),i))}else{const s=e.node.object,o=e.node.property;n.get("left").replaceWith(y(s,o)),n.get("right").replaceWith(t(a?"=":r,y(s,u(o.name)),i))}return a?n.replaceWith(f(r,n.node.left,n.node.right)):n.node.operator="=",[n.get("left"),n.get("right").get("left")]}if(e.parentPath.isUpdateExpression()){const t=e.parentPath,n=e.scope.generateDeclaredUidIdentifier("tmp"),r=e.node.computed?e.scope.generateDeclaredUidIdentifier("prop"):null,i=[s("=",n,y(e.node.object,r?s("=",r,e.node.property):e.node.property,e.node.computed)),s("=",y(e.node.object,r?u(r.name):e.node.property,e.node.computed),a(e.parentPath.node.operator[0],u(n.name),g(1)))];e.parentPath.node.prefix||i.push(u(n.name)),t.replaceWith(E(i));return[t.get("expressions.0.right"),t.get("expressions.1.left")]}return[e];function t(e,t,n){return"="===e?s("=",t,n):a(e,t,n)}}(t)),[]).forEach(e=>{const t=e.node.computed?"":e.get("property").node.name,n=e.parentPath,r=n.isAssignmentExpression({left:e.node}),a=n.isCallExpression({callee:e.node}),o=n.isTaggedTemplateExpression({tag:e.node}),c=function(e,t,n){const r=t?"set":"get";return W(e,`superprop_${r}:${n||""}`,()=>{const r=[];let a;if(n)a=y(A(),u(n));else{const t=e.scope.generateUidIdentifier("prop");r.unshift(t),a=y(A(),u(t.name),!0)}if(t){const t=e.scope.generateUidIdentifier("value");r.push(t),a=s("=",a,u(t.name))}return i(r,a)})}(p,r,t),d=[];if(e.node.computed&&d.push(e.get("property").node),r){const e=n.node.right;d.push(e)}const h=l(u(c),d);a?(n.unshiftContainer("arguments",C()),e.replaceWith(y(h,u("call"))),S.push(n.get("arguments.0"))):r?n.replaceWith(h):o?(e.replaceWith(l(y(h,u("bind"),!1),[C()])),S.push(e.get("arguments.0"))):e.replaceWith(h)})}let D;return(S.length>0||!t)&&(D=function(e,t){return W(e,"this",n=>{if(!t||!V(e))return C();e.traverse(q,{supers:new WeakSet,thisBinding:n})})}(p,d),(t||d&&V(p))&&(S.forEach(e=>{const t=e.isJSX()?h(D):u(D);t.loc=e.node.loc,e.replaceWith(t)}),t||(D=null))),{thisBinding:D,fnPath:e}}function V(e){return e.isClassMethod()&&!!e.parentPath.parentPath.node.superClass}const q=(0,n.environmentVisitor)({CallExpression(e,{supers:t,thisBinding:n}){e.get("callee").isSuper()&&(t.has(e.node)||(t.add(e.node),e.replaceWithMultiple([e.node,s("=",u(n),u("this"))])))}});function W(e,t,n){const r="binding:"+t;let i=e.getData(r);if(!i){const s=e.scope.generateUidIdentifier(t);i=s.name,e.setData(r,i),e.scope.push({id:s,init:n(i)})}return i}const J=(0,n.environmentVisitor)({ThisExpression(e,{thisPaths:t}){t.push(e)},JSXIdentifier(e,{thisPaths:t}){"this"===e.node.name&&(e.parentPath.isJSXMemberExpression({object:e.node})||e.parentPath.isJSXOpeningElement({name:e.node}))&&t.push(e)},CallExpression(e,{superCalls:t}){e.get("callee").isSuper()&&t.push(e)},MemberExpression(e,{superProps:t}){e.get("object").isSuper()&&t.push(e)},Identifier(e,{argumentsPaths:t}){if(!e.isReferencedIdentifier({name:"arguments"}))return;let n=e.scope;do{if(n.hasOwnBinding("arguments"))return void n.rename("arguments");if(n.path.isFunction()&&!n.path.isArrowFunctionExpression())break}while(n=n.parent);t.push(e)},MetaProperty(e,{newTargetPaths:t}){e.get("meta").isIdentifier({name:"new"})&&e.get("property").isIdentifier({name:"target"})&&t.push(e)}});const $={"ReferencedIdentifier|BindingIdentifier"(e,t){e.node.name===t.name&&(t.needsRename=!0,e.stop())},Scope(e,t){e.scope.hasOwnBinding(t.name)&&e.skip()}};return Ua}var po,uo={};function ho(){return po||(po=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e._guessExecutionStatusRelativeTo=function(e){return m(this,e,new Map)},e._resolve=y,e.canHaveVariableDeclarationOrExpression=function(){return("init"===this.key||"left"===this.key)&&this.parentPath.isFor()},e.canSwapBetweenExpressionAndStatement=function(e){if("body"!==this.key||!this.parentPath.isArrowFunctionExpression())return!1;if(this.isExpression())return i(e);if(this.isBlockStatement())return s(e);return!1},e.getSource=function(){const e=this.node;if(e.end){const t=this.hub.getCode();if(t)return t.slice(e.start,e.end)}return""},e.isCompletionRecord=function(e){let t=this,n=!0;do{const{type:r,container:i}=t;if(!n&&(t.isFunction()||"StaticBlock"===r))return!!e;if(n=!1,Array.isArray(i)&&t.key!==i.length-1)return!1}while((t=t.parentPath)&&!t.isProgram()&&!t.isDoExpression());return!0},e.isConstantExpression=function(){if(this.isIdentifier()){const e=this.scope.getBinding(this.node.name);return!!e&&e.constant}if(this.isLiteral())return!this.isRegExpLiteral()&&(!this.isTemplateLiteral()||this.get("expressions").every(e=>e.isConstantExpression()));if(this.isUnaryExpression())return"void"===this.node.operator&&this.get("argument").isConstantExpression();if(this.isBinaryExpression()){const{operator:e}=this.node;return"in"!==e&&"instanceof"!==e&&this.get("left").isConstantExpression()&&this.get("right").isConstantExpression()}if(this.isMemberExpression())return!this.node.computed&&this.get("object").isIdentifier({name:"Symbol"})&&!this.scope.hasBinding("Symbol",{noGlobals:!0});if(this.isCallExpression())return 1===this.node.arguments.length&&this.get("callee").matchesPattern("Symbol.for")&&!this.scope.hasBinding("Symbol",{noGlobals:!0})&&this.get("arguments")[0].isStringLiteral();return!1},e.isInStrictMode=function(){const e=(this.isProgram()?this:this.parentPath).find(e=>{if(e.isProgram({sourceType:"module"}))return!0;if(e.isClass())return!0;if(e.isArrowFunctionExpression()&&!e.get("body").isBlockStatement())return!1;let t;if(e.isFunction())t=e.node.body;else{if(!e.isProgram())return!1;t=e.node}for(const e of t.directives)if("use strict"===e.value.value)return!0;return!1});return!!e},e.isNodeType=function(e){return c(this.type,e)},e.isStatementOrBlock=function(){return!this.parentPath.isLabeledStatement()&&!i(this.container)&&n.includes(this.key)},e.isStatic=function(){return this.scope.isStatic(this.node)},e.matchesPattern=function(e,t){return p(this.node,e,t)},e.referencesImport=function(e,t){if(!this.isReferencedIdentifier()){if(this.isJSXMemberExpression()&&this.node.property.name===t||(this.isMemberExpression()||this.isOptionalMemberExpression())&&(this.node.computed?l(this.node.property,{value:t}):this.node.property.name===t)){const t=this.get("object");return t.isReferencedIdentifier()&&t.referencesImport(e,"*")}return!1}const n=this.scope.getBinding(this.node.name);if(!n||"module"!==n.kind)return!1;const r=n.path,i=r.parentPath;if(!i.isImportDeclaration())return!1;if(i.node.source.value!==e)return!1;if(!t)return!0;if(r.isImportDefaultSpecifier()&&"default"===t)return!0;if(r.isImportNamespaceSpecifier()&&"*"===t)return!0;if(r.isImportSpecifier()&&a(r.node.imported,{name:t}))return!0;return!1},e.resolve=function(e,t){return y.call(this,e,t)||this},e.willIMaybeExecuteBefore=function(e){return"after"!==this._guessExecutionStatusRelativeTo(e)};var t=qr();const{STATEMENT_OR_BLOCK_KEYS:n,VISITOR_KEYS:r,isBlockStatement:i,isExpression:s,isIdentifier:a,isLiteral:o,isStringLiteral:l,isType:c,matchesPattern:p}=t;function u(e){return e.isProgram()?e:(e.parentPath.scope.getFunctionParent()||e.parentPath.scope.getProgramParent()).path}function d(e,t){switch(e){case"LogicalExpression":case"AssignmentPattern":return"right"===t;case"ConditionalExpression":case"IfStatement":return"consequent"===t||"alternate"===t;case"WhileStatement":case"DoWhileStatement":case"ForInStatement":case"ForOfStatement":return"body"===t;case"ForStatement":return"body"===t||"update"===t;case"SwitchStatement":return"cases"===t;case"TryStatement":return"handler"===t;case"OptionalMemberExpression":return"property"===t;case"OptionalCallExpression":return"arguments"===t;default:return!1}}function h(e,t){for(let n=0;n<t;n++){const t=e[n];if(d(t.parent.type,t.parentKey))return!0}return!1}e.has=function(e){var t;const n=null==(t=this.node)?void 0:t[e];return n&&Array.isArray(n)?!!n.length:!!n},e.is=e.has,e.isnt=function(e){return!this.has(e)},e.equals=function(e,t){return this.node[e]===t};const f=Symbol();function m(e,t,n){const i={this:u(e),target:u(t)};if(i.target.node!==i.this.node)return function(e,t,n){let r,i=n.get(e.node);if(i){if(r=i.get(t.node))return r===f?"unknown":r}else n.set(e.node,i=new Map);i.set(t.node,f);const s=function(e,t,n){if(!t.isFunctionDeclaration())return"before"===m(e,t,n)?"before":"unknown";if(t.parentPath.isExportDeclaration())return"unknown";const r=t.scope.getBinding(t.node.id.name);if(!r.references)return"before";const i=r.referencePaths;let s;for(const r of i){if(!!r.find(e=>e.node===t.node))continue;if("callee"!==r.key||!r.parentPath.isCallExpression())return"unknown";const i=m(e,r,n);if(s&&s!==i)return"unknown";s=i}return s}(e,t,n);return i.set(t.node,s),s}(e,i.target,n);const s={target:t.getAncestry(),this:e.getAncestry()};if(s.target.includes(e))return"after";if(s.this.includes(t))return"before";let a;const o={target:0,this:0};for(;!a&&o.this<s.this.length;){const e=s.this[o.this];o.target=s.target.indexOf(e),o.target>=0?a=e:o.this++}if(!a)throw new Error("Internal Babel error - The two compared nodes don't appear to belong to the same program.");if(h(s.this,o.this-1)||h(s.target,o.target-1))return"unknown";const l={this:s.this[o.this-1],target:s.target[o.target-1]};if(l.target.listKey&&l.this.listKey&&l.target.container===l.this.container)return l.target.key>l.this.key?"before":"after";const c=r[a.type],p=c.indexOf(l.this.parentKey);return c.indexOf(l.target.parentKey)>p?"before":"after"}function y(e,t){var n;if(null==(n=t)||!n.includes(this))if((t=t||[]).push(this),this.isVariableDeclarator()){if(this.get("id").isIdentifier())return this.get("init").resolve(e,t)}else if(this.isReferencedIdentifier()){const n=this.scope.getBinding(this.node.name);if(!n)return;if(!n.constant)return;if("module"===n.kind)return;if(n.path!==this){const r=n.path.resolve(e,t);if(this.find(e=>e.node===r.node))return;return r}}else{if(this.isTypeCastExpression())return this.get("expression").resolve(e,t);if(e&&this.isMemberExpression()){const n=this.toComputedKey();if(!o(n))return;const r=n.value,i=this.get("object").resolve(e,t);if(i.isObjectExpression()){const n=i.get("properties");for(const i of n){if(!i.isProperty())continue;const n=i.get("key");let s=i.isnt("computed")&&n.isIdentifier({name:r});if(s=s||n.isLiteral({value:r}),s)return i.get("value").resolve(e,t)}}else if(i.isArrayExpression()&&!isNaN(+r)){const n=i.get("elements")[r];if(n)return n.resolve(e,t)}}}}}(uo)),uo}var fo,mo={};function yo(){if(fo)return mo;fo=1,Object.defineProperty(mo,"__esModule",{value:!0}),mo._getKey=f,mo._getPattern=m,mo.get=function(e,t=!0){!0===t&&(t=this.context);const n=e.split(".");return 1===n.length?f.call(this,e,t):m.call(this,n,t)},mo.getAllNextSiblings=function(){let e=this.key,t=this.getSibling(++e);const n=[];for(;t.node;)n.push(t),t=this.getSibling(++e);return n},mo.getAllPrevSiblings=function(){let e=this.key,t=this.getSibling(--e);const n=[];for(;t.node;)n.push(t),t=this.getSibling(--e);return n},mo.getAssignmentIdentifiers=function(){return n(this.node)},mo.getBindingIdentifierPaths=function(e=!1,t=!1){const n=[this],i=Object.create(null);for(;n.length;){const s=n.shift();if(!s)continue;if(!s.node)continue;const a=r.keys[s.node.type];if(s.isIdentifier())if(e){(i[s.node.name]=i[s.node.name]||[]).push(s)}else i[s.node.name]=s;else{if(s.isExportDeclaration()){const e=s.get("declaration");e.isDeclaration()&&n.push(e);continue}if(t){if(s.isFunctionDeclaration()){n.push(s.get("id"));continue}if(s.isFunctionExpression())continue}if(a)for(let e=0;e<a.length;e++){const t=a[e],r=s.get(t);Array.isArray(r)?n.push(...r):r.node&&n.push(r)}}}return i},mo.getBindingIdentifiers=function(e){return r(this.node,e)},mo.getCompletionRecords=function(e=!1){return h(this,{canHaveBreak:!1,shouldPopulateBreak:!1,inCaseClause:!1,shouldPreserveBreak:e}).map(e=>e.path)},mo.getNextSibling=function(){return this.getSibling(this.key+1)},mo.getOpposite=function(){if("left"===this.key)return this.getSibling("right");if("right"===this.key)return this.getSibling("left");return null},mo.getOuterBindingIdentifierPaths=function(e=!1){return this.getBindingIdentifierPaths(e,!0)},mo.getOuterBindingIdentifiers=function(e){return i(this.node,e)},mo.getPrevSibling=function(){return this.getSibling(this.key-1)},mo.getSibling=function(t){return e.default.get({parentPath:this.parentPath,parent:this.parent,container:this.container,listKey:this.listKey,key:t}).setContext(this.context)};var e=Po(),t=qr();const{getAssignmentIdentifiers:n,getBindingIdentifiers:r,getOuterBindingIdentifiers:i,numericLiteral:s,unaryExpression:a}=t,o=0,l=1;function c(e,t,n){return e&&t.push(...h(e,n)),t}function p(e){e.forEach(e=>{e.type=l})}function u(e,t){e.forEach(e=>{e.path.isBreakStatement({label:null})&&(t?e.path.replaceWith(a("void",s(0))):e.path.remove())})}function d(e,t){const n=[];if(t.canHaveBreak){let r=[];for(let i=0;i<e.length;i++){const s=e[i],a=Object.assign({},t,{inCaseClause:!1});s.isBlockStatement()&&(t.inCaseClause||t.shouldPopulateBreak)?a.shouldPopulateBreak=!0:a.shouldPopulateBreak=!1;const c=h(s,a);if(c.length>0&&c.every(e=>e.type===l)){r.length>0&&c.every(e=>e.path.isBreakStatement({label:null}))?(p(r),n.push(...r),r.some(e=>e.path.isDeclaration())&&(n.push(...c),t.shouldPreserveBreak||u(c,!0)),t.shouldPreserveBreak||u(c,!1)):(n.push(...c),t.shouldPopulateBreak||t.shouldPreserveBreak||u(c,!0));break}if(i===e.length-1)n.push(...c);else{r=[];for(let e=0;e<c.length;e++){const t=c[e];t.type===l&&n.push(t),t.type===o&&r.push(t)}}}}else if(e.length)for(let r=e.length-1;r>=0;r--){const i=h(e[r],t);if(i.length>1||1===i.length&&!i[0].path.isVariableDeclaration()&&!i[0].path.isEmptyStatement()){n.push(...i);break}}return n}function h(e,t){let n=[];if(e.isIfStatement())n=c(e.get("consequent"),n,t),n=c(e.get("alternate"),n,t);else{if(e.isDoExpression()||e.isFor()||e.isWhile()||e.isLabeledStatement())return c(e.get("body"),n,t);if(e.isProgram()||e.isBlockStatement())return d(e.get("body"),t);if(e.isFunction())return h(e.get("body"),t);if(e.isTryStatement())n=c(e.get("block"),n,t),n=c(e.get("handler"),n,t);else{if(e.isCatchClause())return c(e.get("body"),n,t);if(e.isSwitchStatement())return function(e,t,n){let r=[];for(let i=0;i<e.length;i++){const s=h(e[i],n),a=[],c=[];for(const e of s)e.type===o&&a.push(e),e.type===l&&c.push(e);a.length&&(r=a),t.push(...c)}return t.push(...r),t}(e.get("cases"),n,t);if(e.isSwitchCase())return d(e.get("consequent"),{canHaveBreak:!0,shouldPopulateBreak:!1,inCaseClause:!0,shouldPreserveBreak:t.shouldPreserveBreak});e.isBreakStatement()?n.push(function(e){return{type:l,path:e}}(e)):n.push(function(e){return{type:o,path:e}}(e))}}return n}function f(t,n){const r=this.node,i=r[t];return Array.isArray(i)?i.map((s,a)=>e.default.get({listKey:t,parentPath:this,parent:r,container:i,key:a}).setContext(n)):e.default.get({parentPath:this,parent:r,container:r,key:t}).setContext(n)}function m(e,t){let n=this;for(const r of e)n="."===r?n.parentPath:Array.isArray(n)?n[r]:n.get(r,t);return n}return mo}var To,go,So,xo,bo,Eo={};function Po(){if(go)return zr;go=1,Object.defineProperty(zr,"__esModule",{value:!0}),zr.default=zr.SHOULD_STOP=zr.SHOULD_SKIP=zr.REMOVED=void 0;var e=Qr(),t=Ti(),n=No(),r=Bi(),i=qr(),s=i,a=_i(),o=Gs(),l=function(){if(Qs)return Zs;Qs=1,Object.defineProperty(Zs,"__esModule",{value:!0}),Zs.find=function(e){let t=this;do{if(e(t))return t}while(t=t.parentPath);return null},Zs.findParent=function(e){let t=this;for(;t=t.parentPath;)if(e(t))return t;return null},Zs.getAncestry=function(){let e=this;const t=[];do{t.push(e)}while(e=e.parentPath);return t},Zs.getDeepestCommonAncestorFrom=function(e,t){if(!e.length)return this;if(1===e.length)return e[0];let n,r,i=1/0;const s=e.map(e=>{const t=[];do{t.unshift(e)}while((e=e.parentPath)&&e!==this);return t.length<i&&(i=t.length),t}),a=s[0];e:for(let e=0;e<i;e++){const t=a[e];for(const n of s)if(n[e]!==t)break e;n=e,r=t}if(r)return t?t(r,n,s):r;throw new Error("Couldn't find intersection")},Zs.getEarliestCommonAncestorFrom=function(e){return this.getDeepestCommonAncestorFrom(e,function(e,n,r){let i;const s=t[e.type];for(const e of r){const t=e[n+1];i?(t.listKey&&i.listKey===t.listKey&&t.key<i.key||s.indexOf(i.parentKey)>s.indexOf(t.parentKey))&&(i=t):i=t}return i})},Zs.getFunctionParent=function(){return this.findParent(e=>e.isFunction())},Zs.getStatementParent=function(){let e=this;do{if(!e.parentPath||Array.isArray(e.container)&&e.isStatement())break;e=e.parentPath}while(e);if(e&&(e.isProgram()||e.isFile()))throw new Error("File/Program node, we can't possibly find a statement parent to this");return e},Zs.inType=function(...e){let t=this;for(;t;){if(e.includes(t.node.type))return!0;t=t.parentPath}return!1},Zs.isAncestor=function(e){return e.isDescendant(this)},Zs.isDescendant=function(e){return!!this.findParent(t=>t===e)};var e=qr();const{VISITOR_KEYS:t}=e;return Zs}(),c=function(){if(ra)return ia;ra=1,Object.defineProperty(ia,"__esModule",{value:!0}),ia._getTypeAnnotation=P,ia.baseTypeStrictlyMatches=function(e){const t=this.getTypeAnnotation(),n=e.getTypeAnnotation();return!(r(t)||!o(t))&&n.type===t.type},ia.couldBeBaseType=function(e){const t=this.getTypeAnnotation();if(r(t))return!0;if(g(t)){for(const n of t.types)if(r(n)||v(e,n,!0))return!0;return!1}return v(e,t,!0)},ia.getTypeAnnotation=function(){let e=this.getData("typeAnnotation");return null!=e||(e=P.call(this)||n(),(T(e)||f(e))&&(e=e.typeAnnotation),this.setData("typeAnnotation",e)),e},ia.isBaseType=function(e,t){return v(e,this.getTypeAnnotation(),t)},ia.isGenericType=function(e){const t=this.getTypeAnnotation();return!("Array"!==e||!(h(t)||i(t)||y(t)))||(l(t)&&c(t.id,{name:e})||m(t)&&c(t.typeName,{name:e}))};var e=pa(),t=qr();const{anyTypeAnnotation:n,isAnyTypeAnnotation:r,isArrayTypeAnnotation:i,isBooleanTypeAnnotation:s,isEmptyTypeAnnotation:a,isFlowBaseAnnotation:o,isGenericTypeAnnotation:l,isIdentifier:c,isMixedTypeAnnotation:p,isNumberTypeAnnotation:u,isStringTypeAnnotation:d,isTSArrayType:h,isTSTypeAnnotation:f,isTSTypeReference:m,isTupleTypeAnnotation:y,isTypeAnnotation:T,isUnionTypeAnnotation:g,isVoidTypeAnnotation:S,stringTypeAnnotation:x,voidTypeAnnotation:b}=t,E=new WeakSet;function P(){const t=this.node;if(t){if(t.typeAnnotation)return t.typeAnnotation;if(!E.has(t)){E.add(t);try{var r;let n=e[t.type];if(n)return n.call(this,t);if(n=e[this.parentPath.type],null!=(r=n)&&r.validParent)return this.parentPath.getTypeAnnotation()}finally{E.delete(t)}}}else if("init"===this.key&&this.parentPath.isVariableDeclarator()){const e=this.parentPath.parentPath,t=e.parentPath;return"left"===e.key&&t.isForInStatement()?x():"left"===e.key&&t.isForOfStatement()?n():b()}}function v(e,t,n){if("string"===e)return d(t);if("number"===e)return u(t);if("boolean"===e)return s(t);if("any"===e)return r(t);if("mixed"===e)return p(t);if("empty"===e)return a(t);if("void"===e)return S(t);if(n)return!1;throw new Error(`Unknown base type ${e}`)}return ia}(),p=Ma(),u=ja(),d=co(),h=ho(),f=Ao(),m=f,y=Ca(),T=ka(),g=yo(),S=function(){if(To)return Eo;To=1,Object.defineProperty(Eo,"__esModule",{value:!0}),Eo.addComment=function(e,n,r){t(this.node,e,n,r)},Eo.addComments=function(e,t){n(this.node,e,t)},Eo.shareCommentsWithSiblings=function(){if("string"==typeof this.key)return;const e=this.node;if(!e)return;const t=e.trailingComments,n=e.leadingComments;if(!t&&!n)return;const i=this.getSibling(this.key-1),s=this.getSibling(this.key+1),a=Boolean(i.node),o=Boolean(s.node);a&&(n&&i.addComments("trailing",r(n,i.node.trailingComments)),t&&!o&&i.addComments("trailing",t)),o&&(t&&s.addComments("leading",r(t,s.node.leadingComments)),n&&!a&&s.addComments("leading",n))};var e=qr();const{addComment:t,addComments:n}=e;function r(e,t){if(null==t||!t.length)return e;const n=new Set(t);return e.filter(e=>!n.has(e))}return Eo}(),x=Ai();const{validate:b}=i,E=t("babel");zr.REMOVED=1,zr.SHOULD_STOP=2,zr.SHOULD_SKIP=4;const P=zr.default=class e{constructor(e,t){this.contexts=[],this.state=null,this._traverseFlags=0,this.skipKeys=null,this.parentPath=null,this.container=null,this.listKey=null,this.key=null,this.node=null,this.type=null,this._store=null,this.parent=t,this.hub=e,this.data=null,this.context=null,this.scope=null}get removed(){return(1&this._traverseFlags)>0}set removed(e){e?this._traverseFlags|=1:this._traverseFlags&=-2}get shouldStop(){return(2&this._traverseFlags)>0}set shouldStop(e){e?this._traverseFlags|=2:this._traverseFlags&=-3}get shouldSkip(){return(4&this._traverseFlags)>0}set shouldSkip(e){e?this._traverseFlags|=4:this._traverseFlags&=-5}static get({hub:t,parentPath:n,parent:r,container:i,listKey:s,key:o}){if(!t&&n&&(t=n.hub),!r)throw new Error("To get a node path the parent needs to exist");const l=i[o],c=a.getOrCreateCachedPaths(r,n);let p=c.get(l);return p||(p=new e(t,r),l&&c.set(l,p)),f.setup.call(p,n,i,s,o),p}getScope(e){return this.isScope()?new r.default(this):e}setData(e,t){return null==this.data&&(this.data=Object.create(null)),this.data[e]=t}getData(e,t){null==this.data&&(this.data=Object.create(null));let n=this.data[e];return void 0===n&&void 0!==t&&(n=this.data[e]=t),n}hasNode(){return null!=this.node}buildCodeFrameError(e,t=SyntaxError){return this.hub.buildError(this.node,e,t)}traverse(e,t){(0,n.default)(this.node,e,this.scope,t,this)}set(e,t){b(this.node,e,t),this.node[e]=t}getPathLocation(){const e=[];let t=this;do{let n=t.key;t.inList&&(n=`${t.listKey}[${n}]`),e.unshift(n)}while(t=t.parentPath);return e.join(".")}debug(e){E.enabled&&E(`${this.getPathLocation()} ${this.type}: ${e}`)}toString(){return(0,o.default)(this.node).code}get inList(){return!!this.listKey}set inList(e){e||(this.listKey=null)}get parentKey(){return this.listKey||this.key}},v={findParent:l.findParent,find:l.find,getFunctionParent:l.getFunctionParent,getStatementParent:l.getStatementParent,getEarliestCommonAncestorFrom:l.getEarliestCommonAncestorFrom,getDeepestCommonAncestorFrom:l.getDeepestCommonAncestorFrom,getAncestry:l.getAncestry,isAncestor:l.isAncestor,isDescendant:l.isDescendant,inType:l.inType,getTypeAnnotation:c.getTypeAnnotation,isBaseType:c.isBaseType,couldBeBaseType:c.couldBeBaseType,baseTypeStrictlyMatches:c.baseTypeStrictlyMatches,isGenericType:c.isGenericType,replaceWithMultiple:p.replaceWithMultiple,replaceWithSourceString:p.replaceWithSourceString,replaceWith:p.replaceWith,replaceExpressionWithStatements:p.replaceExpressionWithStatements,replaceInline:p.replaceInline,evaluateTruthy:u.evaluateTruthy,evaluate:u.evaluate,toComputedKey:d.toComputedKey,ensureBlock:d.ensureBlock,unwrapFunctionEnvironment:d.unwrapFunctionEnvironment,arrowFunctionToExpression:d.arrowFunctionToExpression,splitExportDeclaration:d.splitExportDeclaration,ensureFunctionName:d.ensureFunctionName,matchesPattern:h.matchesPattern,isStatic:h.isStatic,isNodeType:h.isNodeType,canHaveVariableDeclarationOrExpression:h.canHaveVariableDeclarationOrExpression,canSwapBetweenExpressionAndStatement:h.canSwapBetweenExpressionAndStatement,isCompletionRecord:h.isCompletionRecord,isStatementOrBlock:h.isStatementOrBlock,referencesImport:h.referencesImport,getSource:h.getSource,willIMaybeExecuteBefore:h.willIMaybeExecuteBefore,_guessExecutionStatusRelativeTo:h._guessExecutionStatusRelativeTo,resolve:h.resolve,isConstantExpression:h.isConstantExpression,isInStrictMode:h.isInStrictMode,isDenylisted:m.isDenylisted,visit:m.visit,skip:m.skip,skipKey:m.skipKey,stop:m.stop,setContext:m.setContext,requeue:m.requeue,requeueComputedKeyAndDecorators:m.requeueComputedKeyAndDecorators,remove:y.remove,insertBefore:T.insertBefore,insertAfter:T.insertAfter,unshiftContainer:T.unshiftContainer,pushContainer:T.pushContainer,getOpposite:g.getOpposite,getCompletionRecords:g.getCompletionRecords,getSibling:g.getSibling,getPrevSibling:g.getPrevSibling,getNextSibling:g.getNextSibling,getAllNextSiblings:g.getAllNextSiblings,getAllPrevSiblings:g.getAllPrevSiblings,get:g.get,getAssignmentIdentifiers:g.getAssignmentIdentifiers,getBindingIdentifiers:g.getBindingIdentifiers,getOuterBindingIdentifiers:g.getOuterBindingIdentifiers,getBindingIdentifierPaths:g.getBindingIdentifierPaths,getOuterBindingIdentifierPaths:g.getOuterBindingIdentifierPaths,shareCommentsWithSiblings:S.shareCommentsWithSiblings,addComment:S.addComment,addComments:S.addComments};Object.assign(P.prototype,v),P.prototype.arrowFunctionToShadowed=d[String("arrowFunctionToShadowed")],Object.assign(P.prototype,{has:h[String("has")],is:h[String("is")],isnt:h[String("isnt")],equals:h[String("equals")],hoist:T[String("hoist")],updateSiblingKeys:T.updateSiblingKeys,call:m.call,isBlacklisted:m[String("isBlacklisted")],setScope:m.setScope,resync:m.resync,popContext:m.popContext,pushContext:m.pushContext,setup:m.setup,setKey:m.setKey}),P.prototype._guessExecutionStatusRelativeToDifferentFunctions=h._guessExecutionStatusRelativeTo,P.prototype._guessExecutionStatusRelativeToDifferentFunctions=h._guessExecutionStatusRelativeTo,Object.assign(P.prototype,{_getTypeAnnotation:c._getTypeAnnotation,_replaceWith:p._replaceWith,_resolve:h._resolve,_call:m._call,_resyncParent:m._resyncParent,_resyncKey:m._resyncKey,_resyncList:m._resyncList,_resyncRemoved:m._resyncRemoved,_getQueueContexts:m._getQueueContexts,_removeFromScope:y._removeFromScope,_callRemovalHooks:y._callRemovalHooks,_remove:y._remove,_markRemoved:y._markRemoved,_assertUnremoved:y._assertUnremoved,_containerInsert:T._containerInsert,_containerInsertBefore:T._containerInsertBefore,_containerInsertAfter:T._containerInsertAfter,_verifyNodeList:T._verifyNodeList,_getKey:g._getKey,_getPattern:g._getPattern});for(const e of s.TYPES){const t=`is${e}`,n=s[t];P.prototype[t]=function(e){return n(this.node,e)},P.prototype[`assert${e}`]=function(t){if(!n(this.node,t))throw new TypeError(`Expected node path of type ${e}`)}}Object.assign(P.prototype,x);for(const t of Object.keys(e))"_"!==t[0]&&(s.TYPES.includes(t)||s.TYPES.push(t));return zr}function vo(){if(xo)return Xr;xo=1,Object.defineProperty(Xr,"__esModule",{value:!0}),Xr.traverseNode=function(t,r,i,s,a,o,l){const c=n[t.type];if(!c)return!1;const p=new e.default(i,r,s,a);if(l)return(null==o||!o[a.parentKey])&&p.visitQueue([a]);for(const e of c)if((null==o||!o[e])&&p.visit(t,e))return!0;return!1};var e=function(){if(So)return Hr;So=1,Object.defineProperty(Hr,"__esModule",{value:!0}),Hr.default=void 0;var e=Po(),t=qr(),n=Ao();const{VISITOR_KEYS:r}=t;return Hr.default=class{constructor(e,t,n,r){this.queue=null,this.priorityQueue=null,this.parentPath=r,this.scope=e,this.state=n,this.opts=t}shouldVisit(e){const t=this.opts;if(t.enter||t.exit)return!0;if(t[e.type])return!0;const n=r[e.type];if(null==n||!n.length)return!1;for(const t of n)if(e[t])return!0;return!1}create(t,n,r,i){return e.default.get({parentPath:this.parentPath,parent:t,container:n,key:r,listKey:i})}maybeQueue(e,t){this.queue&&(t?this.queue.push(e):this.priorityQueue.push(e))}visitMultiple(e,t,n){if(0===e.length)return!1;const r=[];for(let i=0;i<e.length;i++){const s=e[i];s&&this.shouldVisit(s)&&r.push(this.create(t,e,i,n))}return this.visitQueue(r)}visitSingle(e,t){return!!this.shouldVisit(e[t])&&this.visitQueue([this.create(e,e,t)])}visitQueue(e){this.queue=e,this.priorityQueue=[];const t=new WeakSet;let r=!1,i=0;for(;i<e.length;){const s=e[i];if(i++,n.resync.call(s),0!==s.contexts.length&&s.contexts[s.contexts.length-1]===this||n.pushContext.call(s,this),null===s.key)continue;const{node:a}=s;if(!t.has(a)){if(a&&t.add(a),s.visit()){r=!0;break}if(this.priorityQueue.length&&(r=this.visitQueue(this.priorityQueue),this.priorityQueue=[],this.queue=e,r))break}}for(let t=0;t<i;t++)n.popContext.call(e[t]);return this.queue=null,r}visit(e,t){const n=e[t];return!!n&&(Array.isArray(n)?this.visitMultiple(n,e,t):this.visitSingle(e,t))}},Hr}();Po();var t=qr();Ao();const{VISITOR_KEYS:n}=t;return Xr}function Ao(){if(bo)return Yr;bo=1,Object.defineProperty(Yr,"__esModule",{value:!0}),Yr._call=s,Yr._getQueueContexts=function(){let e=this,t=this.contexts;for(;!t.length&&(e=e.parentPath,e);)t=e.contexts;return t},Yr._resyncKey=p,Yr._resyncList=u,Yr._resyncParent=c,Yr._resyncRemoved=function(){null!=this.key&&this.container&&this.container[this.key]===this.node||n._markRemoved.call(this)},Yr.call=i,Yr.isDenylisted=a,Yr.popContext=function(){this.contexts.pop(),this.contexts.length>0?this.setContext(this.contexts[this.contexts.length-1]):this.setContext(void 0)},Yr.pushContext=function(e){this.contexts.push(e),this.setContext(e)},Yr.requeue=function(e=this){if(e.removed)return;const t=this.contexts;for(const n of t)n.maybeQueue(e)},Yr.requeueComputedKeyAndDecorators=function(){const{context:e,node:t}=this;!r.isPrivate(t)&&t.computed&&e.maybeQueue(this.get("key"));if(t.decorators)for(const t of this.get("decorators"))e.maybeQueue(t)},Yr.resync=function(){if(this.removed)return;c.call(this),u.call(this),p.call(this)},Yr.setContext=function(e){null!=this.skipKeys&&(this.skipKeys={});this._traverseFlags=0,e&&(this.context=e,this.state=e.state,this.opts=e.opts);return l.call(this),this},Yr.setKey=d,Yr.setScope=l,Yr.setup=function(e,t,n,r){this.listKey=n,this.container=t,this.parentPath=e||this.parentPath,d.call(this,r)},Yr.skip=function(){this.shouldSkip=!0},Yr.skipKey=function(e){null==this.skipKeys&&(this.skipKeys={});this.skipKeys[e]=!0},Yr.stop=function(){this._traverseFlags|=t.SHOULD_SKIP|t.SHOULD_STOP},Yr.visit=function(){var t,n;if(!this.node)return!1;if(this.isDenylisted())return!1;if(null!=(t=(n=this.opts).shouldSkip)&&t.call(n,this))return!1;const r=this.context;if(this.shouldSkip||i.call(this,"enter"))return this.debug("Skip..."),this.shouldStop;return o(this,r),this.debug("Recursing into..."),this.shouldStop=(0,e.traverseNode)(this.node,this.opts,this.scope,this.state,this,this.skipKeys),o(this,r),i.call(this,"exit"),this.shouldStop};var e=vo(),t=Po(),n=Ca(),r=qr();function i(e){const t=this.opts;return this.debug(e),!(!this.node||!s.call(this,t[e]))||!!this.node&&s.call(this,null==(n=t[this.node.type])?void 0:n[e]);var n}function s(e){if(!e)return!1;for(const t of e){if(!t)continue;const e=this.node;if(!e)return!0;const n=t.call(this.state,this,this.state);if(n&&"object"==typeof n&&"function"==typeof n.then)throw new Error("You appear to be using a plugin with an async traversal visitor, which your current version of Babel does not support. If you're using a published plugin, you may need to upgrade your @babel/core version.");if(n)throw new Error(`Unexpected return value from visitor method ${t}`);if(this.node!==e)return!0;if(this._traverseFlags>0)return!0}return!1}function a(){var e;const t=null!=(e=this.opts.denylist)?e:this.opts.blacklist;return null==t?void 0:t.includes(this.node.type)}function o(e,t){e.context!==t&&(e.context=t,e.state=t.state,e.opts=t.opts)}function l(){var e,t;if(null!=(e=this.opts)&&e.noScope)return;let n,r=this.parentPath;for((("key"===this.key||"decorators"===this.listKey)&&r.isMethod()||"discriminant"===this.key&&r.isSwitchStatement())&&(r=r.parentPath);r&&!n;){var i;if(null!=(i=r.opts)&&i.noScope)return;n=r.scope,r=r.parentPath}this.scope=this.getScope(n),null==(t=this.scope)||t.init()}function c(){this.parentPath&&(this.parent=this.parentPath.node)}function p(){if(this.container&&this.node!==this.container[this.key]){if(Array.isArray(this.container)){for(let e=0;e<this.container.length;e++)if(this.container[e]===this.node)return void d.call(this,e)}else for(const e of Object.keys(this.container))if(this.container[e]===this.node)return void d.call(this,e);this.key=null}}function u(){if(!this.parent||!this.inList)return;const e=this.parent[this.listKey];this.container!==e&&(this.container=e||null)}function d(e){var t;this.key=e,this.node=this.container[this.key],this.type=null==(t=this.node)?void 0:t.type}return Yr.isBlacklisted=a,Yr}var Co,wo,Io={};function No(){return wo||(wo=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Hub",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,"NodePath",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return a.default}}),e.visitors=e.default=void 0,Ao();var t=Ci();e.visitors=t;var n=qr(),r=_i(),i=vo(),s=Po(),a=Bi(),o=(Co||(Co=1,Object.defineProperty(Io,"__esModule",{value:!0}),Io.default=void 0,Io.default=class{getCode(){}getScope(){}addHelper(){throw new Error("Helpers are not supported by the default hub.")}buildError(e,t,n=TypeError){return new n(t)}}),Io);const{VISITOR_KEYS:l,removeProperties:c,traverseFast:p}=n;function u(e,n={},r,s,a,o){if(e){if(!n.noScope&&!r&&"Program"!==e.type&&"File"!==e.type)throw new Error(`You must pass a scope and parentPath unless traversing a Program/File. Instead of that you tried to traverse a ${e.type} node without passing scope and parentPath.`);if(!a&&o)throw new Error("visitSelf can only be used when providing a NodePath.");l[e.type]&&(t.explode(n),(0,i.traverseNode)(e,n,r,s,a,void 0,o))}}e.default=u,u.visitors=t,u.verify=t.verify,u.explode=t.explode,u.cheap=function(e,t){p(e,t)},u.node=function(e,t,n,r,s,a){(0,i.traverseNode)(e,t,n,r,s,a)},u.clearNode=function(e,t){c(e,t)},u.removeProperties=function(e,t){return p(e,u.clearNode,t),e},u.hasType=function(e,t,n){return(null==n||!n.includes(e.type))&&(e.type===t||p(e,function(e){return null!=n&&n.includes(e.type)?p.skip:e.type===t?p.stop:void 0}))},u.cache=r}($r)),$r}var ko=U(No()),Oo=U(La());function Do(e){return Oo.parse(e,{sourceType:"module",plugins:["jsx","typescript","classProperties","dynamicImport","exportDefaultFrom","exportNamespaceFrom","functionBind","nullishCoalescingOperator","objectRestSpread","optionalChaining","decorators-legacy"],allowAwaitOutsideFunction:!0})}const _o={is:e=>Jr.isStringLiteral(e),get:e=>e.value},Lo={is:e=>Jr.isNumericLiteral(e),get:e=>e.value},Mo={is:e=>Jr.isBooleanLiteral(e),get:e=>e.value},Fo={is:e=>Jr.isNullLiteral(e),get:e=>null},Bo={is:e=>Jr.isIdentifier(e)&&"undefined"===e.name,get(e){}},jo={is:e=>Jr.isObjectExpression(e),get:e=>Wo(e)},Ro={is:e=>Jr.isClass(e),get:e=>function(e){function t(e){return"static"in e&&!0===e.static}let n=e.body;if(!Jr.isClassBody(n))return;const r={};return n.body.forEach(e=>{if(t(e)&&Jr.isIdentifier(e.key))if(Jr.isMethod(e)||Jr.isTSDeclareMethod(e))r[e.key.name]=()=>{};else{const t=qo.find(t=>t.is(e.value));t&&(r[e.key.name]=t.get(e.value))}}),r}(e)},Uo={is:e=>Jr.isArrayExpression(e),get:e=>Jo(e)},Ko={is:e=>Jr.isFunctionExpression(e),get:e=>function(){}},Vo={is:e=>Jr.isArrowFunctionExpression(e),get:e=>()=>{}},qo=[_o,Lo,Mo,Fo,Bo,jo,Uo,Ro,Ko,Vo];function Wo(e){const t={};return e.properties.forEach(e=>{if(Jr.isObjectMember(e)&&Jr.isIdentifier(e.key))if(Jr.isObjectMethod(e))t[e.key.name]=()=>{};else{const n=qo.find(t=>t.is(e.value));n&&(t[e.key.name]=n.get(e.value))}}),t}function Jo(e){const t=[];return e.elements.forEach(e=>{const n=qo.find(t=>t.is(e));n&&t.push(n.get(e))}),t}function $o(e){const t=Do(e);let n;return ko(t,{Program:{enter(e){const t=e.node,r=function(e){for(const t of e.body)if(Jr.isExportDefaultDeclaration(t))return t.declaration;return null}(t);if(r)if(Jr.isIdentifier(r)){const{name:e}=r;n=function(e){const t={};for(const n of e.programNode.body){let r=n;if(Jr.isExpressionStatement(r)&&(r=r.expression),Jr.isAssignmentExpression(r)&&Jr.isMemberExpression(r.left)&&Jr.isIdentifier(r.left.object)&&r.left.object.name===e.name){const e=qo.find(e=>e.is(Jr.isAssignmentExpression(r)&&r.right));e&&(t[r.left.property.name]=e.get(r.right))}}return t}({programNode:t,name:e})}else if(Jr.isObjectExpression(r))n=Wo(r);else if(Jr.isArrayExpression(r))n=Jo(r);else{const e=qo.find(e=>e.is(r));e&&(n=e.get(r))}}}}),n}function Yo(e){return/^\\\\\?\\/.test(e)?e:e.replace(/\\/g,"/")}const Xo={javascript:[".ts",".tsx",".js",".jsx"],css:[".less",".sass",".scss",".stylus",".css"]};function Ho(e){const t=Xo[e.type];for(const r of t){const t=`${e.fileNameWithoutExt}${r}`,i=Yo(n(e.base,t));if(p(i))return{path:i,filename:t}}return null}const zo=/^\[(.+?)\]/;function Go(e){return p(e)?u(e).filter(t=>{const r=n(e,t),i=d(r),s=i.isDirectory(),a=i.isFile();if(s&&["components","component","utils","util"].includes(t))return!1;if("."===t.charAt(0))return!1;if("_"===t.charAt(0))return!1;if(/\.(test|spec|e2e)\.(j|t)sx?$/.test(t))return!1;if(/\.d\.ts$/.test(t))return!1;if(a){if(!/\.(j|t)sx?$/.test(t))return!1;const e=h(r,"utf-8");try{if(!function(e){const t=Do(e);let n=!1;return ko(t,{JSXElement(e){n=!0,e.stop()},JSXFragment(e){n=!0,e.stop()}}),n}(e))return!1}catch(e){throw new Error(`Parse conventional route component ${r} failed, ${e.message}`)}}return!0}):[]}function Qo(e,t,s){const{root:a,relDir:o=""}=e,l=n(a,o,s),c=d(l),p=zo.test(s);if(c.isDirectory()){const r=n(o,s),i=Ho({base:n(a,r),fileNameWithoutExt:"_layout",type:"javascript"}),l={path:el(r),routes:tl({...e,relDir:n(r)}),__isDynamic:p,...i?{component:i.path}:{exact:!0,__toMerge:!0}};t.push(Zo(l,e))}else{const a=r(s,i(s));t.push(Zo({path:el(n(o,a)),exact:!0,component:l,__isDynamic:p},e))}return t}function Zo(e,t){let r;if(e.component){try{r=$o(h(e.component,"utf-8"))}catch(t){throw new Error(`Parse conventional route component ${e.component} failed, ${t.message}`)}e.component=Yo(s(n(t.root,".."),e.component)),e.component=`${t.componentPrefix||"@/"}${e.component}`}return{...e,..."object"==typeof r?r:{}}}function el(e,t){return"/index/index"===(e=`/${e=Yo(e).split("/").map(e=>((e=e.replace(zo,":$1")).endsWith("$")&&(e=e.slice(0,-1)+"?"),e)).join("/")}`)&&(e="/"),"/"!==(e=e.replace(/\/index$/,"/"))&&"/"===e.slice(-1)&&(e=e.slice(0,-1)),e}function tl(e){const{root:t,relDir:r="",config:i}=e,s=function(e){const t=[],n=[],r=[];return e.forEach(e=>{const{__isDynamic:i,exact:s}=e;delete e.__isDynamic,i?t.push(e):s?n.push(e):r.push(e)}),S(t.length<=1,"We should not have multiple dynamic routes under a directory."),[...n,...r,...t].reduce((e,t)=>(t.__toMerge&&t.routes?e=e.concat(t.routes):e.push(t),e),[])}(Go(n(t,r)).reduce(Qo.bind(null,e),[]));if(!r){const n=Ho({base:t,fileNameWithoutExt:`../${i.singular?"layout":"layouts"}/index`,type:"javascript"});if(n)return[Zo({path:"/",component:n.path,routes:s},e)]}return s}function nl(t){const n=e.extname(t);if(![".tsx",".ts",".jsx",".js"].includes(n))return!1;try{const e=l.readFileSync(t,"utf-8");return/export\s+default/.test(e)}catch{return!1}}function rl(e){const t={path:e.path||""};if(void 0!==e.exact&&(t.exact=e.exact),e.component){const n=e.component.replace(/\.(tsx|ts|jsx|js)$/,"");t.component=`dynamic({ loader: () => import('${n}'), loading: LoadingComponent})`}return e.title&&"string"==typeof e.title&&(t.title=`$t({ defaultMessage: "${e.title}" })`),!0===e.keepAlive&&(t.keepAlive=!0),e.authority&&Array.isArray(e.authority)&&(t.authority=e.authority),e.routes&&e.routes.length>0&&(t.routes=e.routes.map(rl)),t}function il(e,t){return tl({root:e,componentPrefix:t.pageAliasPrefix,config:{singular:!1}}).map(rl)}async function sl(t,n){function r(e,t=2){const n=" ".repeat(t),i=" ".repeat(t+2);let s=`${n}{\n`;if(s+=`${i}path: '${e.path}',\n`,void 0!==e.exact&&null!==e.exact&&(s+=`${i}exact: ${e.exact},\n`),void 0!==e.component&&null!==e.component&&(s+=`${i}component: ${e.component},\n`),void 0!==e.title&&null!==e.title&&(s+=`${i}title: ${e.title},\n`),e.authority&&(s+=`${i}authority: ${JSON.stringify(e.authority)},\n`),e.keepAlive&&(s+=`${i}keepAlive: ${e.keepAlive},\n`),e.routes&&e.routes.length>0){s+=`${i}routes: [\n${e.routes.map(e=>r(e,t+2)).join(",\n")}\n${i}],\n`}return s=s.replace(/,\n$/,"\n"),s+=`${n}}`,s}const i=t.map(e=>r(e)).join(",\n"),s=`\n/* eslint-disable */\n// @ts-nocheck\n/**\n * 自动根据 pages 目录生成路由配置\n * 新增、删除、修改组件 title、keepAlive、authority 属性时,会自动更新路由配置\n * 路由组件只支持默认导出\n */\nimport { dynamic } from '@lemon-fe/vite-plugin-micro-frontend/runtime';\nimport LoadingComponent from '${n.defaultLoadingComponentPath||"@/components/loading"}';\nimport { $t } from '${n.intlPath||"@/utils/intl"}';\n\nexport const routers = [\n${i}\n];\n`;try{const t=e.resolve(process.cwd(),".prettierrc");let n={};if(l.existsSync(t))try{const e=l.readFileSync(t,"utf-8");n=JSON.parse(e)}catch(e){console.warn("⚠️ 读取 prettier 配置失败,使用默认配置:",e)}const r={parser:"typescript",...n};return await m.format(s,r)}catch(e){return console.error("格式化代码失败:",e),s}}async function al(t={}){const{pagesDir:n,outputPath:r,routeTemplate:i={}}=t,s=n||e.resolve(process.cwd(),"src/pages"),a=r||e.resolve(process.cwd(),"src/routes.ts");if(!l.existsSync(s))return void console.warn("⚠️ pages 目录不存在:",s);const o=il(s,i),c=await sl(o,i);l.writeFileSync(a,c),console.log("✅ 路由已生成:",a)}function ol(t={}){const{pagesDir:n,outputPath:r,watch:i=!0,ignoreDirs:s=["components","utils","hooks","typings"],routeTemplate:a={}}=t;let o=!1,c=null,p=!1,u="";const d=n||e.resolve(process.cwd(),"src/pages"),h=r||e.resolve(process.cwd(),"src/routes.ts"),m=async()=>{if(!l.existsSync(d))return void console.warn("⚠️ pages 目录不存在:",d);const e=il(d,a),t=await sl(e,a);t!==u&&(u=t,l.writeFileSync(h,t),console.log("✅ 路由已生成:",h))},y=()=>{c&&(c.close(),c=null,o=!1)};return{name:"micro-frontend:routes",enforce:"pre",configureServer(e){p||(m(),p=!0),(()=>{if(o||!i)return;if(!l.existsSync(d))return;const e=["**/node_modules/**","**/*.d.ts","**/*.less","**/*.css","**/*.scss","**/*.sass",h,...s.map(e=>`**/${e}/**`)];c=f.watch(d,{ignored:e,persistent:!0,ignoreInitial:!0}),c.on("add",e=>{nl(e)&&m()}).on("unlink",e=>{nl(e)&&m()}).on("addDir",e=>{m()}).on("unlinkDir",e=>{m()}).on("error",e=>{console.error("❌ 文件监听错误:",e)}),o=!0})(),e.httpServer?.on("close",y)},buildStart(){p||(m(),p=!0)}}}function ll(t){const{remotes:n,outputPath:r}=t,i=r||e.resolve(process.cwd(),"src/utils/mf.tsx"),s=function(e){const t=function(e){return e.reduce((e,t)=>(e[t.aliasName||t.remoteName]=t,e),{})}(e),n=JSON.stringify(t,null,2);return"/* eslint-disable */\nimport { lazy, Suspense, type ReactNode, type ComponentType } from 'react';\n\n// 远程模块配置\nconst remotes = __REMOTES_JSON__ as const;\n\ntype RemoteAlias = keyof typeof remotes;\ntype ModuleSpecifier = `${RemoteAlias}/${string}`;\n\n// 多个入口文件之间共享的变量\nconst entryShared = (window as any).__entry_shared__ || {};\n\n// 脚本加载状态: undefined=未加载, Promise=加载中, true=已完成\nconst scriptCache: Record<string, Promise<void> | true | undefined> = {};\n\n/**\n * 获取多入口共享变量(懒初始化单例)\n */\nexport function getEntryShared<T>(key: string, init: () => T): T {\n return (entryShared[key] ??= init()) as T;\n}\n\n/**\n * 安全加载远程组件\n */\nexport function safeRemoteComponent<T extends ComponentType<any>>(opts: {\n moduleSpecifier: ModuleSpecifier;\n fallbackComponent: T;\n loadingElement?: ReactNode;\n}): T {\n const LazyComponent = lazy<T>(() =>\n loadRemoteModule(opts.moduleSpecifier, { default: opts.fallbackComponent }),\n );\n\n return ((props: any) => (\n <Suspense fallback={opts.loadingElement ?? null}>\n <LazyComponent {...props} />\n </Suspense>\n )) as T;\n}\n\n// ============ 内部实现 ============\n\nasync function loadRemoteModule<T>(specifier: ModuleSpecifier, fallback: T): Promise<T> {\n try {\n const slashIndex = specifier.indexOf('/');\n const alias = specifier.slice(0, slashIndex) as RemoteAlias;\n const moduleName = specifier.slice(slashIndex + 1);\n const remote = remotes[alias];\n\n if (!remote) {\n console.error(`[MF] Unknown remote alias: \"${alias}\"`);\n return fallback;\n }\n\n // Some remotes may not have isESModule property, default to false if missing\n const isESModule = (remote as any).isESModule ?? false;\n await loadScriptOnce(remote.remoteName, remote.entry, isESModule);\n\n const container = (window as any)[remote.remoteName];\n\n if (!container) {\n console.error(`[MF] Container \"${remote.remoteName}\" not found on window`);\n return fallback;\n }\n\n // 对于 ES Module 联邦,需要先调用 init 初始化共享模块\n // if (isESModule && typeof container.init === 'function') {\n // // 初始化共享作用域(如果还没有初始化过)\n // const shareScope = (window as any).__federation_shared__ || {};\n // (window as any).__federation_shared__ = shareScope;\n // await container.init(shareScope);\n // }\n\n const factory = await container.get(`./${moduleName}`);\n const module = factory();\n\n // 确保返回 { default: Component } 格式给 React.lazy\n if (module && typeof module === 'object' && 'default' in module) {\n return module as T;\n }\n\n // 如果模块本身就是组件,包装成 { default: Component }\n return { default: module } as T;\n } catch (e) {\n console.error('[MF] Load remote module failed:', e);\n return fallback;\n }\n}\n\nasync function loadScriptOnce(name: string, url: string, isESModule?: boolean): Promise<void> {\n const cached = scriptCache[name];\n\n if (cached === true) return;\n if (cached) return cached;\n\n const promise = (async () => {\n const fullUrl = `${url}?t=${Date.now()}`;\n const baseUrl = window.location.origin;\n\n // ES Module 格式\n if (isESModule) {\n try {\n const module = await import(/* @vite-ignore */ `${baseUrl}${fullUrl}`);\n\n // Vite Module Federation 通常直接导出 get/init,而不是 default\n const container = module.default || module;\n\n // 验证容器是否有效\n if (typeof container.get !== 'function') {\n console.error('[MF] Invalid container: missing get() method', container);\n throw new Error(`Container \"${name}\" has no get() method`);\n }\n\n (window as any)[name] = container;\n return;\n } catch (e) {\n console.error('[MF] ES Module load failed:', e);\n throw e; // 对于明确指定 isESModule 的情况,不应该回退\n }\n }\n\n // 回退到 UMD 格式\n await new Promise<void>((resolve, reject) => {\n const script = document.createElement('script');\n script.src = fullUrl;\n script.async = true;\n script.onload = () => resolve();\n script.onerror = reject;\n document.head.appendChild(script);\n });\n })().then(\n () => {\n scriptCache[name] = true;\n },\n e => {\n scriptCache[name] = undefined;\n throw e;\n },\n );\n\n scriptCache[name] = promise;\n return promise;\n}\n\n".replace("__REMOTES_JSON__",n)}(n),a=e.dirname(i);if(l.existsSync(a)||l.mkdirSync(a,{recursive:!0}),l.existsSync(i)){if(l.readFileSync(i,"utf-8")===s)return}l.writeFileSync(i,s),console.log("✅ mf.tsx 已生成:",i)}function cl(e){return{name:"micro-frontend:mf-generator",enforce:"pre",configResolved(){ll(e)},buildStart(){ll(e)}}}const pl=x(import.meta.url);let ul={};try{const e=pl.resolve("@module-federation/dts-plugin/dynamic-remote-type-hints-plugin");ul["@module-federation/dts-plugin/dynamic-remote-type-hints-plugin"]=e}catch{}function dl(e){return e.replace(/\\/g,"/")}function hl(t){const n=function(t){const n={},r=[".tsx",".ts"];if(!l.existsSync(t))return n;const i=l.readdirSync(t,{withFileTypes:!0});for(const s of i)if(s.isDirectory()){const r=e.join(t,s.name),i=["index.tsx","index.ts"];let a=null;for(const t of i){const n=e.join(r,t);if(l.existsSync(n)){a=n;break}}if(a){const t=dl(e.relative(process.cwd(),a));n[`./${s.name}`]=`./${t}`}else console.warn(`⚠️ ${s.name} 目录下没有找到入口文件,已忽略`)}else{const i=e.extname(s.name);if(r.includes(i)){const r=e.join(t,s.name),a=dl(e.relative(process.cwd(),r));n[`./${e.basename(s.name,i)}`]=`./${a}`}}return n}(e.resolve(process.cwd(),t.exposesDir??"src/exposes"));return{...n,...t.exposes||{}}}function fl(t){const n=[];n.push(0===Object.keys(ul).length?{name:"mf-dts-plugin-alias",config:()=>({})}:{name:"mf-dts-plugin-alias",enforce:"pre",config:()=>({resolve:{alias:ul}})});const r=function(e,t){if(!e||0===e.length)return;const n={};for(const r of e){const{remoteName:e,entry:i}=r,s=i.startsWith("/")?i:`/${i}`;if(i.startsWith("http"))n[e]=i;else if(t){const r=t.endsWith("/")?t.slice(0,-1):t;n[e]=`${r}${s}`}n[e]=s}return n}(t.remotes,t.devHost),i=hl(t);return n.push(b({filename:t.filename||"remote.js",hostInitInjectLocation:t.hostInitInjectLocation||"entry",...t,remotes:r,exposes:i})),n.push(cl({remotes:t.remotes??[],outputPath:t.outputPath?e.resolve(process.cwd(),t.outputPath):"src/utils/mf.tsx"})),n}const ml=E(import.meta.url);function yl(){let e="";return{name:"micro-frontend:antd-external",enforce:"pre",config(n,r){const i=ml.resolve("antd/es/index.js"),s=c.readFileSync(i,"utf-8"),a=new Set,o=/export\s*\{\s*default\s+as\s+(\w+)\s*\}/g;let l;for(;l=o.exec(s);)a.add(l[1]);const p=/export\s+var\s+(\w+)\s*=/g;for(;l=p.exec(s);)a.add(l[1]);const u=`/**\n * 自动生成的 antd 代理文件\n * 由 autoExternalAntd 插件生成,请勿手动修改\n */\nconst antd = (window as any).antd;\n\n${[...a].map(e=>`export const ${e} = antd.${e};`).join("\n")}\n\nexport default antd;\n`;e=t.resolve(process.cwd(),"src/.external/antd.ts"),c.mkdirSync(t.dirname(e),{recursive:!0}),c.writeFileSync(e,u);const d=n.resolve?.alias,h=Array.isArray(d)?d:d?Object.entries(d).map(([e,t])=>({find:e,replacement:t})):[];return{resolve:{alias:[...h,{find:/^antd$/,replacement:e}]}}}}}const Tl={pagesDir:"src/pages",outputPath:"src/routes.ts",watch:!0,ignoreDirs:["components","utils","hooks","typings"],routeTemplate:{defaultLoadingComponentPath:"@/components/loading",intlPath:"@/utils/intl"}},gl="__microFrontendOptions";function Sl(t){const{appName:n,federation:r,routes:i,htmlTransform:s=!0,qiankun:o}=t,l=[];if(l.push({name:"micro-frontend:options",[gl]:t}),s){const e="object"==typeof s?s:{};l.push(j(e))}const c="object"==typeof i?Object.assign(Tl,i):Tl;if(l.push(ol({pagesDir:c.pagesDir?e.resolve(process.cwd(),c.pagesDir):void 0,outputPath:c.outputPath?e.resolve(process.cwd(),c.outputPath):void 0,watch:c.watch,ignoreDirs:c.ignoreDirs,routeTemplate:c.routeTemplate})),!1!==o?.enabled){const e=o?.name||n,t="development"===process.env.NODE_ENV;l.push(a(e,{useDevMode:t}))}return r&&(l.push(...fl(r)),l.push(B({relativeCSSInjection:!0}))),l}export{gl as MICRO_FRONTEND_OPTIONS_KEY,yl as autoExternalAntd,B as cssInjectedByJsPlugin,j as devHmrPlugin,fl as federationPlugin,ll as generateMf,al as generateRoutesToFile,tl as getRoutes,cl as mfGeneratorPlugin,Sl as microFrontendPlugins,ol as pagesRoutesPlugin};
14
14
  //# sourceMappingURL=index.js.map