@lemon-fe/vite-plugin-micro-frontend 2.0.0-beta.0 → 2.0.0-beta.1
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/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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")},$a.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},$a.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},$a.unwrapFunctionEnvironment=function(){if(!this.isArrowFunctionExpression()&&!this.isFunctionExpression()&&!this.isFunctionDeclaration())throw this.buildCodeFrameError("Can only unwrap the environment of a function.");K(this)};var e=Gr(),t=function(){if(oo)return qa;oo=1,Object.defineProperty(qa,"__esModule",{value:!0}),qa.statements=qa.statement=qa.smart=qa.program=qa.expression=qa.default=void 0;var e=Ja(),t=uo();const n=qa.smart=(0,t.default)(e.smart),r=qa.statement=(0,t.default)(e.statement),i=qa.statements=(0,t.default)(e.statements),s=qa.expression=(0,t.default)(e.expression),a=qa.program=(0,t.default)(e.program);return qa.default=Object.assign(n.bind(void 0),{smart:n,statement:r,statements:i,expression:s,program:a,ast:n.ast}),qa}(),n=Ni(),r=Io();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:_,getFunctionName:D,cloneNode:L,variableDeclaration:M,variableDeclarator:F,exportNamedDeclaration:B,exportSpecifier:j,inherits:R}=e;$a.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(W,{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 q(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=q(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=q(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 q(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 _;return(S.length>0||!t)&&(_=function(e,t){return q(e,"this",n=>{if(!t||!V(e))return C();e.traverse($,{supers:new WeakSet,thisBinding:n})})}(p,d),(t||d&&V(p))&&(S.forEach(e=>{const t=e.isJSX()?h(_):u(_);t.loc=e.node.loc,e.replaceWith(t)}),t||(_=null))),{thisBinding:_,fnPath:e}}function V(e){return e.isClassMethod()&&!!e.parentPath.parentPath.node.superClass}const $=(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 q(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 W=(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 J={"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 $a}var fo,mo={};function yo(){return fo||(fo=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=Gr();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)}}}}}(mo)),mo}var To,go={};function So(){if(To)return go;To=1,Object.defineProperty(go,"__esModule",{value:!0}),go._getKey=f,go._getPattern=m,go.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)},go.getAllNextSiblings=function(){let e=this.key,t=this.getSibling(++e);const n=[];for(;t.node;)n.push(t),t=this.getSibling(++e);return n},go.getAllPrevSiblings=function(){let e=this.key,t=this.getSibling(--e);const n=[];for(;t.node;)n.push(t),t=this.getSibling(--e);return n},go.getAssignmentIdentifiers=function(){return n(this.node)},go.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},go.getBindingIdentifiers=function(e){return r(this.node,e)},go.getCompletionRecords=function(e=!1){return h(this,{canHaveBreak:!1,shouldPopulateBreak:!1,inCaseClause:!1,shouldPreserveBreak:e}).map(e=>e.path)},go.getNextSibling=function(){return this.getSibling(this.key+1)},go.getOpposite=function(){if("left"===this.key)return this.getSibling("right");if("right"===this.key)return this.getSibling("left");return null},go.getOuterBindingIdentifierPaths=function(e=!1){return this.getBindingIdentifierPaths(e,!0)},go.getOuterBindingIdentifiers=function(e){return i(this.node,e)},go.getPrevSibling=function(){return this.getSibling(this.key-1)},go.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=Co(),t=Gr();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 go}var xo,bo,Eo,Po,vo,Ao={};function Co(){if(bo)return ii;bo=1,Object.defineProperty(ii,"__esModule",{value:!0}),ii.default=ii.SHOULD_STOP=ii.SHOULD_SKIP=ii.REMOVED=void 0;var e=ai(),t=xi(),n=_o(),r=Ui(),i=Gr(),s=i,a=Fi(),o=ea(),l=function(){if(ta)return na;ta=1,Object.defineProperty(na,"__esModule",{value:!0}),na.find=function(e){let t=this;do{if(e(t))return t}while(t=t.parentPath);return null},na.findParent=function(e){let t=this;for(;t=t.parentPath;)if(e(t))return t;return null},na.getAncestry=function(){let e=this;const t=[];do{t.push(e)}while(e=e.parentPath);return t},na.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")},na.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})},na.getFunctionParent=function(){return this.findParent(e=>e.isFunction())},na.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},na.inType=function(...e){let t=this;for(;t;){if(e.includes(t.node.type))return!0;t=t.parentPath}return!1},na.isAncestor=function(e){return e.isDescendant(this)},na.isDescendant=function(e){return!!this.findParent(t=>t===e)};var e=Gr();const{VISITOR_KEYS:t}=e;return na}(),c=function(){if(aa)return oa;aa=1,Object.defineProperty(oa,"__esModule",{value:!0}),oa._getTypeAnnotation=P,oa.baseTypeStrictlyMatches=function(e){const t=this.getTypeAnnotation(),n=e.getTypeAnnotation();return!(r(t)||!o(t))&&n.type===t.type},oa.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)},oa.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},oa.isBaseType=function(e,t){return v(e,this.getTypeAnnotation(),t)},oa.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=ha(),t=Gr();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 oa}(),p=ja(),u=Ka(),d=ho(),h=yo(),f=Io(),m=f,y=Na(),T=Da(),g=So(),S=function(){if(xo)return Ao;xo=1,Object.defineProperty(Ao,"__esModule",{value:!0}),Ao.addComment=function(e,n,r){t(this.node,e,n,r)},Ao.addComments=function(e,t){n(this.node,e,t)},Ao.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=Gr();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 Ao}(),x=Ii();const{validate:b}=i,E=t("babel");ii.REMOVED=1,ii.SHOULD_STOP=2,ii.SHOULD_SKIP=4;const P=ii.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 ii}function wo(){if(Po)return ni;Po=1,Object.defineProperty(ni,"__esModule",{value:!0}),ni.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(Eo)return ri;Eo=1,Object.defineProperty(ri,"__esModule",{value:!0}),ri.default=void 0;var e=Co(),t=Gr(),n=Io();const{VISITOR_KEYS:r}=t;return ri.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))}},ri}();Co();var t=Gr();Io();const{VISITOR_KEYS:n}=t;return ni}function Io(){if(vo)return ti;vo=1,Object.defineProperty(ti,"__esModule",{value:!0}),ti._call=s,ti._getQueueContexts=function(){let e=this,t=this.contexts;for(;!t.length&&(e=e.parentPath,e);)t=e.contexts;return t},ti._resyncKey=p,ti._resyncList=u,ti._resyncParent=c,ti._resyncRemoved=function(){null!=this.key&&this.container&&this.container[this.key]===this.node||n._markRemoved.call(this)},ti.call=i,ti.isDenylisted=a,ti.popContext=function(){this.contexts.pop(),this.contexts.length>0?this.setContext(this.contexts[this.contexts.length-1]):this.setContext(void 0)},ti.pushContext=function(e){this.contexts.push(e),this.setContext(e)},ti.requeue=function(e=this){if(e.removed)return;const t=this.contexts;for(const n of t)n.maybeQueue(e)},ti.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)},ti.resync=function(){if(this.removed)return;c.call(this),u.call(this),p.call(this)},ti.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},ti.setKey=d,ti.setScope=l,ti.setup=function(e,t,n,r){this.listKey=n,this.container=t,this.parentPath=e||this.parentPath,d.call(this,r)},ti.skip=function(){this.shouldSkip=!0},ti.skipKey=function(e){null==this.skipKeys&&(this.skipKeys={});this.skipKeys[e]=!0},ti.stop=function(){this._traverseFlags|=t.SHOULD_SKIP|t.SHOULD_STOP},ti.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=wo(),t=Co(),n=Na(),r=Gr();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 ti.isBlacklisted=a,ti}var No,ko,Oo={};function _o(){return ko||(ko=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,Io();var t=Ni();e.visitors=t;var n=Gr(),r=Fi(),i=wo(),s=Co(),a=Ui(),o=(No||(No=1,Object.defineProperty(Oo,"__esModule",{value:!0}),Oo.default=void 0,Oo.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)}}),Oo);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}(ei)),ei}var Do=X(_o()),Lo=X(Ba());function Mo(e){return Lo.parse(e,{sourceType:"module",plugins:["jsx","typescript","classProperties","dynamicImport","exportDefaultFrom","exportNamespaceFrom","functionBind","nullishCoalescingOperator","objectRestSpread","optionalChaining","decorators-legacy"],allowAwaitOutsideFunction:!0})}const Fo={is:e=>Zr.isStringLiteral(e),get:e=>e.value},Bo={is:e=>Zr.isNumericLiteral(e),get:e=>e.value},jo={is:e=>Zr.isBooleanLiteral(e),get:e=>e.value},Ro={is:e=>Zr.isNullLiteral(e),get:e=>null},Uo={is:e=>Zr.isIdentifier(e)&&"undefined"===e.name,get(e){}},Ko={is:e=>Zr.isObjectExpression(e),get:e=>Yo(e)},Vo={is:e=>Zr.isClass(e),get:e=>function(e){function t(e){return"static"in e&&!0===e.static}let n=e.body;if(!Zr.isClassBody(n))return;const r={};return n.body.forEach(e=>{if(t(e)&&Zr.isIdentifier(e.key))if(Zr.isMethod(e)||Zr.isTSDeclareMethod(e))r[e.key.name]=()=>{};else{const t=Jo.find(t=>t.is(e.value));t&&(r[e.key.name]=t.get(e.value))}}),r}(e)},$o={is:e=>Zr.isArrayExpression(e),get:e=>Xo(e)},qo={is:e=>Zr.isFunctionExpression(e),get:e=>function(){}},Wo={is:e=>Zr.isArrowFunctionExpression(e),get:e=>()=>{}},Jo=[Fo,Bo,jo,Ro,Uo,Ko,$o,Vo,qo,Wo];function Yo(e){const t={};return e.properties.forEach(e=>{if(Zr.isObjectMember(e)&&Zr.isIdentifier(e.key))if(Zr.isObjectMethod(e))t[e.key.name]=()=>{};else{const n=Jo.find(t=>t.is(e.value));n&&(t[e.key.name]=n.get(e.value))}}),t}function Xo(e){const t=[];return e.elements.forEach(e=>{const n=Jo.find(t=>t.is(e));n&&t.push(n.get(e))}),t}function Ho(e){const t=Mo(e);let n;return Do(t,{Program:{enter(e){const t=e.node,r=function(e){for(const t of e.body)if(Zr.isExportDefaultDeclaration(t))return t.declaration;return null}(t);if(r)if(Zr.isIdentifier(r)){const{name:e}=r;n=function(e){const t={};for(const n of e.programNode.body){let r=n;if(Zr.isExpressionStatement(r)&&(r=r.expression),Zr.isAssignmentExpression(r)&&Zr.isMemberExpression(r.left)&&Zr.isIdentifier(r.left.object)&&r.left.object.name===e.name){const e=Jo.find(e=>e.is(Zr.isAssignmentExpression(r)&&r.right));e&&(t[r.left.property.name]=e.get(r.right))}}return t}({programNode:t,name:e})}else if(Zr.isObjectExpression(r))n=Yo(r);else if(Zr.isArrayExpression(r))n=Xo(r);else{const e=Jo.find(e=>e.is(r));e&&(n=e.get(r))}}}}),n}function zo(e){return/^\\\\\?\\/.test(e)?e:e.replace(/\\/g,"/")}const Go={javascript:[".ts",".tsx",".js",".jsx"],css:[".less",".sass",".scss",".stylus",".css"]};function Qo(e){const t=Go[e.type];for(const r of t){const t=`${e.fileNameWithoutExt}${r}`,i=zo(n(e.base,t));if(c(i))return{path:i,filename:t}}return null}const Zo=/^\[(.+?)\]/;function el(e){return c(e)?p(e).filter(t=>{const r=n(e,t),i=u(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=d(r,"utf-8");try{if(!function(e){const t=Mo(e);let n=!1;return Do(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 tl(e,t,s){const{root:a,relDir:o=""}=e,l=n(a,o,s),c=u(l),p=Zo.test(s);if(c.isDirectory()){const r=n(o,s),i=Qo({base:n(a,r),fileNameWithoutExt:"_layout",type:"javascript"}),l={path:rl(r),routes:il({...e,relDir:n(r)}),__isDynamic:p,...i?{component:i.path}:{exact:!0,__toMerge:!0}};t.push(nl(l,e))}else{const a=r(s,i(s));t.push(nl({path:rl(n(o,a)),exact:!0,component:l,__isDynamic:p},e))}return t}function nl(e,t){let r;if(e.component){try{r=Ho(d(e.component,"utf-8"))}catch(t){throw new Error(`Parse conventional route component ${e.component} failed, ${t.message}`)}e.component=zo(s(n(t.root,".."),e.component)),e.component=`${t.componentPrefix||"@/"}${e.component}`}return{...e,..."object"==typeof r?r:{}}}function rl(e,t){return"/index/index"===(e=`/${e=zo(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 il(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)}),g(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),[])}(el(n(t,r)).reduce(tl.bind(null,e),[]));if(!r){const n=Qo({base:t,fileNameWithoutExt:`../${i.singular?"layout":"layouts"}/index`,type:"javascript"});if(n)return[nl({path:"/",component:n.path,routes:s},e)]}return s}function sl(t){const n=e.extname(t);if(![".tsx",".ts",".jsx",".js"].includes(n))return!1;try{const e=o.readFileSync(t,"utf-8");return/export\s+default/.test(e)}catch{return!1}}function al(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(al)),t}function ol(e,t){return il({root:e,componentPrefix:t.pageAliasPrefix,config:{singular:!1}}).map(al)}async function ll(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/dynamic';\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(o.existsSync(t))try{const e=o.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 cl(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(!o.existsSync(s))return void console.warn("⚠️ pages 目录不存在:",s);const l=ol(s,i),c=await ll(l,i);o.writeFileSync(a,c),console.log("✅ 路由已生成:",a)}function pl(t={}){const{pagesDir:n,outputPath:r,watch:i=!0,ignoreDirs:s=["components","utils","hooks","typings"],routeTemplate:a={}}=t;let l=!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(!o.existsSync(d))return void console.warn("⚠️ pages 目录不存在:",d);const e=ol(d,a),t=await ll(e,a);t!==u&&(u=t,o.writeFileSync(h,t),console.log("✅ 路由已生成:",h))},y=()=>{c&&(c.close(),c=null,l=!1)};return{name:"micro-frontend:routes",enforce:"pre",configureServer(e){p||(m(),p=!0),(()=>{if(l||!i)return;if(!o.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=>{sl(e)&&m()}).on("unlink",e=>{sl(e)&&m()}).on("addDir",e=>{m()}).on("unlinkDir",e=>{m()}).on("error",e=>{console.error("❌ 文件监听错误:",e)}),l=!0})(),e.httpServer?.on("close",y)},buildStart(){p||(m(),p=!0)}}}function ul(t){const{outputPath:n}=t,r=n||e.resolve(process.cwd(),"src/utils/mf.tsx"),i=function(e){const t=e.remotes.reduce((e,t)=>(e[t.aliasName||t.remoteName]=t,e),{}),n=JSON.stringify(t,null,2),r=JSON.stringify({hostName:e.hostName,devHost:e.devHost,shareScope:e.shareScope});return"/* eslint-disable */\nimport { lazy, Suspense, type ReactNode, type ComponentType } from 'react';\nimport { createRemoteLoader } from '@lemon-fe/vite-plugin-micro-frontend/runtime/federation';\n\n// 配置同时用于类型提示和运行时注册,不依赖 Vite 是否扫描到静态 remote import。\nconst remotes = __REMOTES_JSON__ as const;\nconst loadRemote = createRemoteLoader({ ...__RUNTIME_OPTIONS_JSON__, remotes });\n\ntype RemoteAlias = keyof typeof remotes;\ntype ModuleSpecifier = `${RemoteAlias}/${string}`;\n\nconst entryShared = ((globalThis as any).__entry_shared__ ||= {});\n\n/** 获取多个业务入口共享的懒初始化值。 */\nexport function getEntryShared<T>(key: string, init: () => T): T {\n return (entryShared[key] ??= init()) as T;\n}\n\n/** 使用官方 Module Federation Runtime 加载远程 React 组件。 */\nexport function safeRemoteComponent<T extends ComponentType<any>>(opts: {\n moduleSpecifier: ModuleSpecifier;\n fallbackComponent: T;\n loadingElement?: ReactNode;\n}): T {\n const LazyComponent = lazy<T>(async () => {\n try {\n const remoteModule = await loadRemote<Record<string, unknown>>(opts.moduleSpecifier);\n const remoteExport = remoteModule?.default ?? remoteModule;\n\n return {\n default: remoteExport as T,\n };\n } catch (error) {\n console.error(`[MF] Load remote module \"${opts.moduleSpecifier}\" failed:`, error);\n return { default: opts.fallbackComponent };\n }\n });\n\n return ((props: any) => (\n <Suspense fallback={opts.loadingElement ?? null}>\n <LazyComponent {...props} />\n </Suspense>\n )) as T;\n}\n".replace("__REMOTES_JSON__",()=>n).replace("__RUNTIME_OPTIONS_JSON__",()=>r)}(t),s=e.dirname(r);if(o.existsSync(s)||o.mkdirSync(s,{recursive:!0}),o.existsSync(r)){if(o.readFileSync(r,"utf-8")===i)return}o.writeFileSync(r,i),console.log("✅ mf.tsx 已生成:",r)}function dl(e){return{name:"micro-frontend:mf-generator",enforce:"pre",configResolved(){ul(e)},buildStart(){ul(e)}}}const hl="\0virtual:micro-frontend-react-bridge-provider";function fl(e){return{schemaVersion:1,appName:e.appName,loader:"module-federation",remote:{name:e.remoteName,type:"module",entry:`./${e.manifestFileName.replace(/^\/+/,"")}`,module:`${e.remoteName}/export-app`},application:{contract:"module-federation-react-bridge",version:1,mountElementId:e.mountElementId,...e.bridgeRouter?{routing:"bridge-router"}:void 0},...e.buildVersion?{buildVersion:e.buildVersion}:void 0}}function ml(t){let n=t,r=`${JSON.stringify(fl(t),null,2)}\n`,i=process.cwd(),s=e.resolve(process.cwd(),t.entry);return{name:"micro-frontend:federation-application",enforce:"pre",configResolved(a){i=a.root,s=e.resolve(a.root,t.entry);const o=function(e,t){const n=e.split("/").filter(Boolean),r=n[n.length-1],i=t.replace(/_/g,"-");return r===i||r===`app-${i}`?i:t}(a.base,t.appName);n={...t,appName:t.inferAppNameFromBase?o:t.appName,mountElementId:t.inferMountElementIdFromBase?o:t.mountElementId},r=`${JSON.stringify(fl(n),null,2)}\n`},configureServer(e){e.middlewares.use((e,n,i)=>{!function(e,t){if(!e)return!1;const n=e.split(/[?#]/)[0];return n===`/${t}`||n.endsWith(`/${t}`)}(e.url,t.capabilityFileName)?i():(n.statusCode=200,n.setHeader("Content-Type","application/json; charset=utf-8"),n.setHeader("Cache-Control","no-store"),n.setHeader("Access-Control-Allow-Origin","*"),n.end(r))})},resolveId(n,r){if(n===hl)return hl;const a=n.split(/[?#]/)[0],o=e.normalize(e.isAbsolute(a)?a:e.resolve(i,a)),l=r?.replace(/^\0/,"").startsWith("virtual:mf-exposes");return t.enhanceEntry&&l&&o===e.normalize(s)?hl:null},load:e=>t.enhanceEntry&&e===hl?n.rootComponent?`import RootComponent from ${JSON.stringify(s)};\nimport { createMicroFrontendRootBridgeProvider } from "@lemon-fe/vite-plugin-micro-frontend/runtime/bridge";\nexport default createMicroFrontendRootBridgeProvider({\n rootComponent: RootComponent,\n});\n`:`import ${JSON.stringify(s)};\nimport { createMicroFrontendBridgeProvider } from "@lemon-fe/vite-plugin-micro-frontend/runtime/bridge";\nexport default createMicroFrontendBridgeProvider({\n appName: ${JSON.stringify(n.appName)},\n mountElementId: ${JSON.stringify(n.mountElementId)},\n});\n`:null,generateBundle(){this.emitFile({type:"asset",fileName:t.capabilityFileName,source:r})}}}const yl="\nconst hook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;\nif (hook && !hook.__microFrontendTracksRenderers) {\n const inject = hook.inject;\n hook.inject = function(renderer) {\n const id = inject.apply(this, arguments);\n hook.renderers.set(id, renderer);\n return id;\n };\n hook.__microFrontendTracksRenderers = true;\n}\n";const Tl="/@micro-frontend/federation-hmr";function gl(e){return e.replace(/\\/g,"/")}function Sl(t){const n=function(t){const n={},r=[".tsx",".ts"];if(!o.existsSync(t))return n;const i=o.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(o.existsSync(n)){a=n;break}}if(a){const t=gl(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=gl(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||{}}}const xl="\nconst __remoteUrl = new URL(import.meta.url);\nconst __hostRefreshUrl = globalThis.__MF_REACT_REFRESH_URL__;\nconst __target =\n window.location.origin === __remoteUrl.origin || !__hostRefreshUrl\n ? new URL('./@mf-react-refresh-local', __remoteUrl).href\n : __hostRefreshUrl;\nconst __rt = await import(__target);\n\nif (!window.__vite_plugin_react_preamble_installed__) {\n __rt.injectIntoGlobalHook(window);\n window.$RefreshReg$ ||= () => {};\n window.$RefreshSig$ ||= () => type => type;\n window.__vite_plugin_react_preamble_installed__ = true;\n}\n\nexport const injectIntoGlobalHook = __rt.injectIntoGlobalHook;\nexport const register = __rt.register;\nexport const getRefreshReg = __rt.getRefreshReg;\nexport const createSignatureFunctionForTransform = __rt.createSignatureFunctionForTransform;\nexport const registerExportsForReactRefresh = __rt.registerExportsForReactRefresh;\nexport const validateRefreshBoundaryAndEnqueueUpdate = __rt.validateRefreshBoundaryAndEnqueueUpdate;\nexport const __hmr_import = __rt.__hmr_import;\nexport default __rt.default || __rt;\n".trimStart();function bl(){let t;return{name:"micro-frontend:federation-react-refresh-proxy",enforce:"pre",apply:"serve",configureServer(n){n.middlewares.use((r,i,s)=>{const a=r.url?.split(/[?#]/)[0];if("GET"===r.method)return a?.endsWith("/@mf-react-refresh-local")?(t??(t=function(t){try{const n=S(e.join(t,"package.json")).resolve("@vitejs/plugin-react"),r=e.join(e.dirname(n),"refresh-runtime.js");return o.readFileSync(r,"utf8")}catch{return null}}(n.config.root)),t?(i.statusCode=200,i.setHeader("Content-Type","application/javascript; charset=utf-8"),i.setHeader("Cache-Control","no-store"),i.setHeader("Access-Control-Allow-Origin","*"),void i.end(t)):void s()):void(a?.endsWith("/@react-refresh")?(i.statusCode=200,i.setHeader("Content-Type","application/javascript; charset=utf-8"),i.setHeader("Cache-Control","no-store"),i.setHeader("Access-Control-Allow-Origin","*"),i.end(xl)):s());s()})}}}function El(){const t="\0virtual:micro-frontend-bridge-router";let n="",r=[];return{name:"micro-frontend:federation-bridge-router",enforce:"pre",config(t){const i=function(t){const n=S(e.join(t,"package.json"));let r;try{r=n.resolve("react-router-dom/package.json")}catch{throw new Error("[micro-frontend] 已启用 federation.bridge.enableBridgeRouter,但无法从项目中解析 react-router-dom。")}const i=JSON.parse(o.readFileSync(r,"utf8")),s=Number.parseInt(i.version||"",10);if(5!==s&&6!==s&&7!==s)throw new Error(`[micro-frontend] Bridge Router 仅支持 React Router v5/v6/v7,当前版本为 ${i.version||"unknown"}。`);const a=n("react-router-dom");return{version:`v${s}`,exportNames:Object.keys(a).filter(e=>"BrowserRouter"!==e&&/^[A-Za-z_$][\w$]*$/.test(e))}}(e.resolve(process.cwd(),t.root||"."));r=i.exportNames,n=x(import.meta.resolve(`@module-federation/bridge-react/router-${i.version}`))},resolveId:e=>"react-router-dom"===e?t:null,load:e=>e!==t?null:`import * as ReactRouterDOMNamespace from "react-router-dom/index.js";\nimport { BrowserRouter as OfficialBridgeRouter } from ${JSON.stringify(n)};\nimport { withBridgeRouteSync } from "@lemon-fe/vite-plugin-micro-frontend/runtime/bridge";\nconst ReactRouterDOM = ReactRouterDOMNamespace.default || ReactRouterDOMNamespace;\n`+r.map(e=>`export const ${e} = ReactRouterDOM[${JSON.stringify(e)}];`).join("\n")+"\nexport const BrowserRouter = withBridgeRouteSync(OfficialBridgeRouter, ReactRouterDOM.useLocation);\n"}}function Pl(e,t){if(!e)return e;const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,r=e=>Object.prototype.hasOwnProperty.call(n,e);if(!(r("react")||r("react/"))||r("react/jsx-dev-runtime"))return e;const i=n.react??n["react/"],s="object"==typeof i?i.requiredVersion:void 0;return{...n,"react/jsx-dev-runtime":{shareScope:`__micro_frontend_react_dev_${t}`,singleton:!1,...void 0!==s?{requiredVersion:s}:void 0}}}function vl(t,n={}){const r={dts:!1,manifest:!0,shareStrategy:"loaded-first",...t,shared:Pl(t.shared,t.name),dev:(i=t.dev,!1!==i&&("object"==typeof i?{remoteHmr:!0,...i}:{remoteHmr:!0}))};var i;!function(e){if(!/^[A-Za-z_$][\w$]*$/.test(e))throw new Error(`[micro-frontend] Module Federation name "${e}" 无效,请使用不含连字符的 JavaScript 标识符(例如 earth_wms)。`)}(r.name);const s=[];r.debugReactHost&&s.push({name:"micro-frontend:react-refresh-host",enforce:"pre",apply:"serve",configureServer(e){const t=h(P.join(e.config.root,"package.json")),n=e.config.base.replace(/\/$/,""),r=new Map,i=new Map,s=e=>{const n=P.dirname(t.resolve(`${e}/package.json`)),{version:r}=JSON.parse(E.readFileSync(P.join(n,"package.json"),"utf8"));if(!String(r).startsWith("18."))throw new Error(`debugReactHost 需要 React 18 UMD,当前 ${e} 版本为 ${r}`);return E.readFileSync(P.join(n,"umd",`${e}.development.js`),"utf8")};r.set(`${n}/@micro-frontend/host-react.js`,()=>s("react")),r.set(`${n}/@micro-frontend/host-react-dom.js`,()=>{const e=h(t.resolve("@vitejs/plugin-react")),n=P.dirname(e.resolve("react-refresh/package.json"));return`(() => {\nconst exports = {};\nconst process = { env: { NODE_ENV: 'development' } };\n${E.readFileSync(P.join(n,"cjs/react-refresh-runtime.development.js"),"utf8")}\nexports.injectIntoGlobalHook(window);\n${yl}\n})();\n${s("react-dom")}`}),e.middlewares.use((e,t,n)=>{const s=e.url?.split(/[?#]/)[0]??"",a=r.get(s);if(!a||"GET"!==e.method&&"HEAD"!==e.method)return n();try{i.has(s)||i.set(s,a()),t.setHeader("Content-Type","application/javascript; charset=utf-8"),t.setHeader("Cache-Control","no-store"),t.setHeader("Access-Control-Allow-Origin","*"),t.end("HEAD"===e.method?void 0:i.get(s))}catch(e){n(e)}})}});const a=!1===r.application?void 0:r.application||{};if(a&&!1===r.manifest)throw new Error("[micro-frontend] 完整微应用必须启用 federation.manifest,如只暴露普通联邦组件,请设置 federation.application = false。");if(a?.rootComponent&&a.entry)throw new Error("[micro-frontend] federation.application.rootComponent 与 entry 不能同时配置。");const o="object"==typeof(l=r.manifest)&&l.fileName?l.fileName:"mf-manifest.json";var l;const c=[...!1===r.manifest?[]:[o],...a?[a.capabilityFileName||"micro-frontend.json"]:[]],p=Boolean(a?.rootComponent&&!1!==r.bridge?.enableBridgeRouter);var u;p&&s.push(El()),s.push(bl()),c.length>0&&s.push((u=c,{name:"micro-frontend:federation-dev-preflight",enforce:"pre",apply:"serve",configureServer(e){e.middlewares.use((t,n,r)=>{if("OPTIONS"!==t.method||!1===e.config.server.cors||!function(e,t){if(!e)return!1;const n=e.split(/[?#]/)[0];return t.some(e=>{const t=e.replace(/^\/+/,"");return n===`/${t}`||n.endsWith(`/${t}`)})}(t.url,u))return void r();const i=t.headers["access-control-request-headers"];n.statusCode=204,n.setHeader("Access-Control-Allow-Origin","*"),n.setHeader("Access-Control-Allow-Methods","GET, HEAD, PUT, PATCH, POST, DELETE, OPTIONS"),i&&n.setHeader("Access-Control-Allow-Headers",Array.isArray(i)?i.join(", "):i),"true"===t.headers["access-control-request-private-network"]&&n.setHeader("Access-Control-Allow-Private-Network","true"),n.setHeader("Content-Length","0"),n.end()})}}));const d=function(e,t,n){if(!e||0===e.length)return;const r={};for(const i of e){const{aliasName:e,remoteName:s,entry:a,isESModule:o}=i,l=e||s,c=a.startsWith("/")?a:`/${a}`;let p;p=a.startsWith("http")?a:t?new URL(c,`${t.replace(/\/$/,"")}/`).href:c,r[l]={type:o?"module":"var",name:l,entry:p,entryGlobalName:s,shareScope:n||"default"}}return r}(r.remotes,r.devHost,r.shareScope),f=Sl(r);if(a){const e=f["./export-app"];if(a.rootComponent&&e)throw new Error('[micro-frontend] federation.application.rootComponent 与 exposes["./export-app"] 不能同时配置。');const t=a.rootComponent||a.entry||("string"==typeof(m=e)?m:m?.import)||"src/main.tsx",i=a.appName||n.appName||r.name,l=a.mountElementId||i;e||(f["./export-app"]=`./${t.replace(/^\.\//,"")}`),s.push(ml({appName:i,remoteName:r.name,entry:t,mountElementId:l,manifestFileName:o,capabilityFileName:a.capabilityFileName||"micro-frontend.json",buildVersion:a.buildVersion,enhanceEntry:!e,rootComponent:!!a.rootComponent,bridgeRouter:p,inferAppNameFromBase:!a.appName,inferMountElementIdFromBase:!a.mountElementId}))}var m;const{application:y,bridge:T,devHost:g,debugReactHost:S,exposesDir:x,outputPath:v,remotes:A,...C}=r;return s.push(b({filename:"remote.js",hostInitInjectLocation:"entry",...C,remotes:d,exposes:f})),function(e){return"object"==typeof e&&null!==e&&Boolean(e.remoteHmr)}(r.dev)&&Object.keys(f).length>0&&s.push(function(){let e;const t=()=>`${e.base.replace(/\/$/,"")}${Tl}`;return{name:"micro-frontend:federation-remote-hmr-client",enforce:"post",apply:"serve",config(e){const t=e.server;if(!1===t?.hmr||!t?.origin)return;let n;try{n=new URL(t.origin)}catch{return}if("http:"!==n.protocol&&"https:"!==n.protocol)return;const r="object"==typeof t.hmr?t.hmr:{};return{server:{hmr:{...r,host:r.host??n.hostname,protocol:r.protocol??("https:"===n.protocol?"wss":"ws"),clientPort:r.clientPort??r.port??Number(n.port||("https:"===n.protocol?443:80))}}}},configResolved(t){e=t},resolveId:e=>e===Tl||e===t()?Tl:null,load(t){if(t!==Tl||!1===e.server.hmr)return null;const n=e.base.replace(/\/$/,"");return`\nimport ${JSON.stringify(`${n}/@vite/client`)};\nimport { injectIntoGlobalHook } from ${JSON.stringify(`${n}/@react-refresh`)};\n\nif (!window.__vite_plugin_react_preamble_installed__) {\n injectIntoGlobalHook(window);\n window.$RefreshReg$ ||= () => {};\n window.$RefreshSig$ ||= () => type => type;\n window.__vite_plugin_react_preamble_installed__ = true;\n}\n${yl}\n\nif (import.meta.hot) {\n let reloadTimer;\n const afterUpdate = payload => {\n const hasScriptUpdate = payload.updates?.some(update =>\n update.type === 'js-update' &&\n !/\\.(css|less|sass|scss|styl|stylus|pcss|postcss)(?:[?#]|$)/i.test(update.acceptedPath || update.path)\n );\n if (!hasScriptUpdate) return;\n\n const renderers = window.__REACT_DEVTOOLS_GLOBAL_HOOK__?.renderers;\n const activeRenderers = renderers ? Array.from(renderers.values()) : [];\n // 只要有 production renderer,就不能假设该 Remote 由另一个 development renderer 渲染。\n if (activeRenderers.length && activeRenderers.every(renderer =>\n typeof renderer.scheduleRefresh === 'function' &&\n typeof renderer.setRefreshHandler === 'function'\n )) return;\n\n clearTimeout(reloadTimer);\n reloadTimer = setTimeout(() => window.location.reload(), 50);\n };\n import.meta.hot.on('vite:afterUpdate', afterUpdate);\n import.meta.hot.dispose(() => {\n clearTimeout(reloadTimer);\n import.meta.hot.off('vite:afterUpdate', afterUpdate);\n });\n}\n`},transform(n,r){if(!1===e.server.hmr||!r.includes("virtual:mf-REMOTE_ENTRY_ID"))return null;const i=`import ${JSON.stringify(t())};`;return n.includes(i)?null:{code:`${i}\n${n}`,map:null}},transformIndexHtml(){if(!1!==e.server.hmr)return[{tag:"script",attrs:{type:"module",src:t()},injectTo:"head"}]}}}()),s.push(dl({hostName:r.name,devHost:r.devHost,shareScope:r.shareScope,remotes:r.remotes??[],outputPath:r.outputPath?e.resolve(process.cwd(),r.outputPath):"src/utils/mf.tsx"})),s}function Al(e){return e&&"/"!==e?e.replace(/^\/+|\/+$/g,""):""}function Cl(e,t,n){if(!t||!n)return e;const r=function(e){const t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`import\\((['"])\\/${t}\\/([^'"]+)\\1\\)`,"g")}(t);return e.replace(r,`import(${n} + '/$2')`)}function wl(e,t){if("boolean"==typeof t&&!t)return"";const n="boolean"==typeof t?{}:t;if(n.publicPath?.trim())return n.publicPath.trim();const r=function(e,t){const n="boolean"==typeof t?{}:t;if(n.appBase?.trim())return n.appBase.trim().replace(/^\/+|\/+$/g,"");const r=Al(e.base);return r&&"__dynamic_base__"!==r?r:""}(e,t),i=r?`/${r}`:e.base??"/";return`(window.EARTH_BASE_CONFIG && window.EARTH_BASE_CONFIG.EARTH_ALL_SHARE_HOST ? window.EARTH_BASE_CONFIG.EARTH_ALL_SHARE_HOST.replace(/\\/$/, '') : '') + ${JSON.stringify(i)}`}function Il(e,t,n){if(e)return"function"==typeof e?e.apply(t,n):e.handler.apply(t,n)}function Nl(e,t){let n;const{transformIndexHtml:r=!0,transformIndexHtmlConfig:i}=e;return{name:"micro-frontend:dynamic-base-deferred",enforce:"post",apply:"build",configResolved:e=>(n=v({publicPath:t(),transformIndexHtml:r,transformIndexHtmlConfig:i}),Il(n.configResolved,n,[e])),generateBundle(e,t,r){if(n?.generateBundle)return Il(n.generateBundle,n,[e,t,r])}}}function kl(e,t,n){const{transformIndexHtml:r=!0,removeIndexCssPreload:i=!1}=e,s=[];if(r){const e=e=>Cl(e,n(),t());s.push({name:"micro-frontend:rewrite-inline-dynamic-base-import",enforce:"post",apply:"build",transformIndexHtml:{order:"post",handler:t=>e(t)},generateBundle(t,n){for(const t of Object.values(n))"asset"===t.type&&t.fileName.endsWith(".html")&&"string"==typeof t.source&&(t.source=e(t.source))}})}return i&&s.push({name:"micro-frontend:remove-index-css-preload",enforce:"post",apply:"build",transformIndexHtml(e){let t=e.replace(/<link[^>]*rel=["']stylesheet["'][^>]*href=["']\/?index-[^"']+\.css["'][^>]*>/gi,"");return t=t.replace(/,\{"parentTagName":"head","tagName":"link","attrs":\{"rel":"stylesheet","crossorigin":"","href":"\/index-[^"]+\.css"\}\}/g,""),t}}),s}function Ol(e){const t={publicPath:"",appBasePath:""},n=function(e){return"boolean"==typeof e?{}:e}(e),r=()=>t.publicPath;return[{name:"micro-frontend:dynamic-base-init",enforce:"pre",apply:"build",config(n,r){t.publicPath=wl(n,e),t.appBasePath=Al(n.base)}},Nl(n,r),...kl(n,r,()=>t.appBasePath)]}const _l=S(import.meta.url);function Dl(){let e="";return{name:"micro-frontend:antd-external",enforce:"pre",config(n,r){const i=_l.resolve("antd/es/index.js"),s=l.readFileSync(i,"utf-8"),a=new Set,o=/export\s*\{\s*default\s+as\s+(\w+)\s*\}/g;let c;for(;c=o.exec(s);)a.add(c[1]);const p=/export\s+var\s+(\w+)\s*=/g;for(;c=p.exec(s);)a.add(c[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"),l.mkdirSync(t.dirname(e),{recursive:!0}),l.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 Ll={pagesDir:"src/pages",outputPath:"src/routes.ts",watch:!0,ignoreDirs:["components","utils","hooks","typings"],routeTemplate:{defaultLoadingComponentPath:"@/components/loading",intlPath:"@/utils/intl"}},Ml="__microFrontendOptions";function Fl(t){const{appName:n,federation:r,routes:i,dynamicBase:s}=t,a=[];a.push({name:"micro-frontend:options",[Ml]:t});const o="object"==typeof i?{...Ll,...i}:Ll;return a.push(pl({pagesDir:o.pagesDir?e.resolve(process.cwd(),o.pagesDir):void 0,outputPath:o.outputPath?e.resolve(process.cwd(),o.outputPath):void 0,watch:o.watch,ignoreDirs:o.ignoreDirs,routeTemplate:o.routeTemplate})),r&&(a.push(...vl(r,{appName:n})),a.push(R({relativeCSSInjection:!0}))),s&&a.push(...Ol(s)),a}export{Ml as MICRO_FRONTEND_OPTIONS_KEY,Dl as autoExternalAntd,R as cssInjectedByJsPlugin,J as devHmrPlugin,vl as federationPlugin,ul as generateMf,cl as generateRoutesToFile,Ol as getDynamicBasePlugins,il as getRoutes,dl as mfGeneratorPlugin,Fl as microFrontendPlugins,pl as pagesRoutesPlugin};
|
|
13
|
+
`;return this.replaceWith(p)[0].get("arguments.0")},$a.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},$a.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},$a.unwrapFunctionEnvironment=function(){if(!this.isArrowFunctionExpression()&&!this.isFunctionExpression()&&!this.isFunctionDeclaration())throw this.buildCodeFrameError("Can only unwrap the environment of a function.");K(this)};var e=Gr(),t=function(){if(oo)return qa;oo=1,Object.defineProperty(qa,"__esModule",{value:!0}),qa.statements=qa.statement=qa.smart=qa.program=qa.expression=qa.default=void 0;var e=Ja(),t=uo();const n=qa.smart=(0,t.default)(e.smart),r=qa.statement=(0,t.default)(e.statement),i=qa.statements=(0,t.default)(e.statements),s=qa.expression=(0,t.default)(e.expression),a=qa.program=(0,t.default)(e.program);return qa.default=Object.assign(n.bind(void 0),{smart:n,statement:r,statements:i,expression:s,program:a,ast:n.ast}),qa}(),n=Ni(),r=Io();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:_,getFunctionName:D,cloneNode:L,variableDeclaration:M,variableDeclarator:F,exportNamedDeclaration:B,exportSpecifier:j,inherits:R}=e;$a.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(W,{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 q(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=q(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=q(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 q(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 _;return(S.length>0||!t)&&(_=function(e,t){return q(e,"this",n=>{if(!t||!V(e))return C();e.traverse($,{supers:new WeakSet,thisBinding:n})})}(p,d),(t||d&&V(p))&&(S.forEach(e=>{const t=e.isJSX()?h(_):u(_);t.loc=e.node.loc,e.replaceWith(t)}),t||(_=null))),{thisBinding:_,fnPath:e}}function V(e){return e.isClassMethod()&&!!e.parentPath.parentPath.node.superClass}const $=(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 q(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 W=(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 J={"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 $a}var fo,mo={};function yo(){return fo||(fo=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=Gr();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)}}}}}(mo)),mo}var To,go={};function So(){if(To)return go;To=1,Object.defineProperty(go,"__esModule",{value:!0}),go._getKey=f,go._getPattern=m,go.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)},go.getAllNextSiblings=function(){let e=this.key,t=this.getSibling(++e);const n=[];for(;t.node;)n.push(t),t=this.getSibling(++e);return n},go.getAllPrevSiblings=function(){let e=this.key,t=this.getSibling(--e);const n=[];for(;t.node;)n.push(t),t=this.getSibling(--e);return n},go.getAssignmentIdentifiers=function(){return n(this.node)},go.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},go.getBindingIdentifiers=function(e){return r(this.node,e)},go.getCompletionRecords=function(e=!1){return h(this,{canHaveBreak:!1,shouldPopulateBreak:!1,inCaseClause:!1,shouldPreserveBreak:e}).map(e=>e.path)},go.getNextSibling=function(){return this.getSibling(this.key+1)},go.getOpposite=function(){if("left"===this.key)return this.getSibling("right");if("right"===this.key)return this.getSibling("left");return null},go.getOuterBindingIdentifierPaths=function(e=!1){return this.getBindingIdentifierPaths(e,!0)},go.getOuterBindingIdentifiers=function(e){return i(this.node,e)},go.getPrevSibling=function(){return this.getSibling(this.key-1)},go.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=Co(),t=Gr();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 go}var xo,bo,Eo,Po,vo,Ao={};function Co(){if(bo)return ii;bo=1,Object.defineProperty(ii,"__esModule",{value:!0}),ii.default=ii.SHOULD_STOP=ii.SHOULD_SKIP=ii.REMOVED=void 0;var e=ai(),t=xi(),n=_o(),r=Ui(),i=Gr(),s=i,a=Fi(),o=ea(),l=function(){if(ta)return na;ta=1,Object.defineProperty(na,"__esModule",{value:!0}),na.find=function(e){let t=this;do{if(e(t))return t}while(t=t.parentPath);return null},na.findParent=function(e){let t=this;for(;t=t.parentPath;)if(e(t))return t;return null},na.getAncestry=function(){let e=this;const t=[];do{t.push(e)}while(e=e.parentPath);return t},na.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")},na.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})},na.getFunctionParent=function(){return this.findParent(e=>e.isFunction())},na.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},na.inType=function(...e){let t=this;for(;t;){if(e.includes(t.node.type))return!0;t=t.parentPath}return!1},na.isAncestor=function(e){return e.isDescendant(this)},na.isDescendant=function(e){return!!this.findParent(t=>t===e)};var e=Gr();const{VISITOR_KEYS:t}=e;return na}(),c=function(){if(aa)return oa;aa=1,Object.defineProperty(oa,"__esModule",{value:!0}),oa._getTypeAnnotation=P,oa.baseTypeStrictlyMatches=function(e){const t=this.getTypeAnnotation(),n=e.getTypeAnnotation();return!(r(t)||!o(t))&&n.type===t.type},oa.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)},oa.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},oa.isBaseType=function(e,t){return v(e,this.getTypeAnnotation(),t)},oa.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=ha(),t=Gr();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 oa}(),p=ja(),u=Ka(),d=ho(),h=yo(),f=Io(),m=f,y=Na(),T=Da(),g=So(),S=function(){if(xo)return Ao;xo=1,Object.defineProperty(Ao,"__esModule",{value:!0}),Ao.addComment=function(e,n,r){t(this.node,e,n,r)},Ao.addComments=function(e,t){n(this.node,e,t)},Ao.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=Gr();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 Ao}(),x=Ii();const{validate:b}=i,E=t("babel");ii.REMOVED=1,ii.SHOULD_STOP=2,ii.SHOULD_SKIP=4;const P=ii.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 ii}function wo(){if(Po)return ni;Po=1,Object.defineProperty(ni,"__esModule",{value:!0}),ni.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(Eo)return ri;Eo=1,Object.defineProperty(ri,"__esModule",{value:!0}),ri.default=void 0;var e=Co(),t=Gr(),n=Io();const{VISITOR_KEYS:r}=t;return ri.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))}},ri}();Co();var t=Gr();Io();const{VISITOR_KEYS:n}=t;return ni}function Io(){if(vo)return ti;vo=1,Object.defineProperty(ti,"__esModule",{value:!0}),ti._call=s,ti._getQueueContexts=function(){let e=this,t=this.contexts;for(;!t.length&&(e=e.parentPath,e);)t=e.contexts;return t},ti._resyncKey=p,ti._resyncList=u,ti._resyncParent=c,ti._resyncRemoved=function(){null!=this.key&&this.container&&this.container[this.key]===this.node||n._markRemoved.call(this)},ti.call=i,ti.isDenylisted=a,ti.popContext=function(){this.contexts.pop(),this.contexts.length>0?this.setContext(this.contexts[this.contexts.length-1]):this.setContext(void 0)},ti.pushContext=function(e){this.contexts.push(e),this.setContext(e)},ti.requeue=function(e=this){if(e.removed)return;const t=this.contexts;for(const n of t)n.maybeQueue(e)},ti.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)},ti.resync=function(){if(this.removed)return;c.call(this),u.call(this),p.call(this)},ti.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},ti.setKey=d,ti.setScope=l,ti.setup=function(e,t,n,r){this.listKey=n,this.container=t,this.parentPath=e||this.parentPath,d.call(this,r)},ti.skip=function(){this.shouldSkip=!0},ti.skipKey=function(e){null==this.skipKeys&&(this.skipKeys={});this.skipKeys[e]=!0},ti.stop=function(){this._traverseFlags|=t.SHOULD_SKIP|t.SHOULD_STOP},ti.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=wo(),t=Co(),n=Na(),r=Gr();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 ti.isBlacklisted=a,ti}var No,ko,Oo={};function _o(){return ko||(ko=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,Io();var t=Ni();e.visitors=t;var n=Gr(),r=Fi(),i=wo(),s=Co(),a=Ui(),o=(No||(No=1,Object.defineProperty(Oo,"__esModule",{value:!0}),Oo.default=void 0,Oo.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)}}),Oo);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}(ei)),ei}var Do=X(_o()),Lo=X(Ba());function Mo(e){return Lo.parse(e,{sourceType:"module",plugins:["jsx","typescript","classProperties","dynamicImport","exportDefaultFrom","exportNamespaceFrom","functionBind","nullishCoalescingOperator","objectRestSpread","optionalChaining","decorators-legacy"],allowAwaitOutsideFunction:!0})}const Fo={is:e=>Zr.isStringLiteral(e),get:e=>e.value},Bo={is:e=>Zr.isNumericLiteral(e),get:e=>e.value},jo={is:e=>Zr.isBooleanLiteral(e),get:e=>e.value},Ro={is:e=>Zr.isNullLiteral(e),get:e=>null},Uo={is:e=>Zr.isIdentifier(e)&&"undefined"===e.name,get(e){}},Ko={is:e=>Zr.isObjectExpression(e),get:e=>Yo(e)},Vo={is:e=>Zr.isClass(e),get:e=>function(e){function t(e){return"static"in e&&!0===e.static}let n=e.body;if(!Zr.isClassBody(n))return;const r={};return n.body.forEach(e=>{if(t(e)&&Zr.isIdentifier(e.key))if(Zr.isMethod(e)||Zr.isTSDeclareMethod(e))r[e.key.name]=()=>{};else{const t=Jo.find(t=>t.is(e.value));t&&(r[e.key.name]=t.get(e.value))}}),r}(e)},$o={is:e=>Zr.isArrayExpression(e),get:e=>Xo(e)},qo={is:e=>Zr.isFunctionExpression(e),get:e=>function(){}},Wo={is:e=>Zr.isArrowFunctionExpression(e),get:e=>()=>{}},Jo=[Fo,Bo,jo,Ro,Uo,Ko,$o,Vo,qo,Wo];function Yo(e){const t={};return e.properties.forEach(e=>{if(Zr.isObjectMember(e)&&Zr.isIdentifier(e.key))if(Zr.isObjectMethod(e))t[e.key.name]=()=>{};else{const n=Jo.find(t=>t.is(e.value));n&&(t[e.key.name]=n.get(e.value))}}),t}function Xo(e){const t=[];return e.elements.forEach(e=>{const n=Jo.find(t=>t.is(e));n&&t.push(n.get(e))}),t}function Ho(e){const t=Mo(e);let n;return Do(t,{Program:{enter(e){const t=e.node,r=function(e){for(const t of e.body)if(Zr.isExportDefaultDeclaration(t))return t.declaration;return null}(t);if(r)if(Zr.isIdentifier(r)){const{name:e}=r;n=function(e){const t={};for(const n of e.programNode.body){let r=n;if(Zr.isExpressionStatement(r)&&(r=r.expression),Zr.isAssignmentExpression(r)&&Zr.isMemberExpression(r.left)&&Zr.isIdentifier(r.left.object)&&r.left.object.name===e.name){const e=Jo.find(e=>e.is(Zr.isAssignmentExpression(r)&&r.right));e&&(t[r.left.property.name]=e.get(r.right))}}return t}({programNode:t,name:e})}else if(Zr.isObjectExpression(r))n=Yo(r);else if(Zr.isArrayExpression(r))n=Xo(r);else{const e=Jo.find(e=>e.is(r));e&&(n=e.get(r))}}}}),n}function zo(e){return/^\\\\\?\\/.test(e)?e:e.replace(/\\/g,"/")}const Go={javascript:[".ts",".tsx",".js",".jsx"],css:[".less",".sass",".scss",".stylus",".css"]};function Qo(e){const t=Go[e.type];for(const r of t){const t=`${e.fileNameWithoutExt}${r}`,i=zo(n(e.base,t));if(c(i))return{path:i,filename:t}}return null}const Zo=/^\[(.+?)\]/;function el(e){return c(e)?p(e).filter(t=>{const r=n(e,t),i=u(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=d(r,"utf-8");try{if(!function(e){const t=Mo(e);let n=!1;return Do(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 tl(e,t,s){const{root:a,relDir:o=""}=e,l=n(a,o,s),c=u(l),p=Zo.test(s);if(c.isDirectory()){const r=n(o,s),i=Qo({base:n(a,r),fileNameWithoutExt:"_layout",type:"javascript"}),l={path:rl(r),routes:il({...e,relDir:n(r)}),__isDynamic:p,...i?{component:i.path}:{exact:!0,__toMerge:!0}};t.push(nl(l,e))}else{const a=r(s,i(s));t.push(nl({path:rl(n(o,a)),exact:!0,component:l,__isDynamic:p},e))}return t}function nl(e,t){let r;if(e.component){try{r=Ho(d(e.component,"utf-8"))}catch(t){throw new Error(`Parse conventional route component ${e.component} failed, ${t.message}`)}e.component=zo(s(n(t.root,".."),e.component)),e.component=`${t.componentPrefix||"@/"}${e.component}`}return{...e,..."object"==typeof r?r:{}}}function rl(e,t){return"/index/index"===(e=`/${e=zo(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 il(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)}),g(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),[])}(el(n(t,r)).reduce(tl.bind(null,e),[]));if(!r){const n=Qo({base:t,fileNameWithoutExt:`../${i.singular?"layout":"layouts"}/index`,type:"javascript"});if(n)return[nl({path:"/",component:n.path,routes:s},e)]}return s}function sl(t){const n=e.extname(t);if(![".tsx",".ts",".jsx",".js"].includes(n))return!1;try{const e=o.readFileSync(t,"utf-8");return/export\s+default/.test(e)}catch{return!1}}function al(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(al)),t}function ol(e,t){return il({root:e,componentPrefix:t.pageAliasPrefix,config:{singular:!1}}).map(al)}async function ll(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/dynamic';\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(o.existsSync(t))try{const e=o.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 cl(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(!o.existsSync(s))return void console.warn("⚠️ pages 目录不存在:",s);const l=ol(s,i),c=await ll(l,i);o.writeFileSync(a,c),console.log("✅ 路由已生成:",a)}function pl(t={}){const{pagesDir:n,outputPath:r,watch:i=!0,ignoreDirs:s=["components","utils","hooks","typings"],routeTemplate:a={}}=t;let l=!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(!o.existsSync(d))return void console.warn("⚠️ pages 目录不存在:",d);const e=ol(d,a),t=await ll(e,a);t!==u&&(u=t,o.writeFileSync(h,t),console.log("✅ 路由已生成:",h))},y=()=>{c&&(c.close(),c=null,l=!1)};return{name:"micro-frontend:routes",enforce:"pre",configureServer(e){p||(m(),p=!0),(()=>{if(l||!i)return;if(!o.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=>{sl(e)&&m()}).on("unlink",e=>{sl(e)&&m()}).on("addDir",e=>{m()}).on("unlinkDir",e=>{m()}).on("error",e=>{console.error("❌ 文件监听错误:",e)}),l=!0})(),e.httpServer?.on("close",y)},buildStart(){p||(m(),p=!0)}}}function ul(t){const{outputPath:n}=t,r=n||e.resolve(process.cwd(),"src/utils/mf.tsx"),i=function(e){const t=e.remotes.reduce((e,t)=>(e[t.aliasName||t.remoteName]=t,e),{}),n=JSON.stringify(t,null,2),r=JSON.stringify({hostName:e.hostName,devHost:e.devHost,shareScope:e.shareScope});return"/* eslint-disable */\nimport { lazy, Suspense, type ReactNode, type ComponentType } from 'react';\nimport { createRemoteLoader } from '@lemon-fe/vite-plugin-micro-frontend/runtime/federation';\n\n// 配置同时用于类型提示和运行时注册,不依赖 Vite 是否扫描到静态 remote import。\nconst remotes = __REMOTES_JSON__ as const;\nconst loadRemote = createRemoteLoader({ ...__RUNTIME_OPTIONS_JSON__, remotes });\n\ntype RemoteAlias = keyof typeof remotes;\ntype ModuleSpecifier = `${RemoteAlias}/${string}`;\n\nconst entryShared = ((globalThis as any).__entry_shared__ ||= {});\n\n/** 获取多个业务入口共享的懒初始化值。 */\nexport function getEntryShared<T>(key: string, init: () => T): T {\n return (entryShared[key] ??= init()) as T;\n}\n\n/** 使用官方 Module Federation Runtime 加载远程 React 组件。 */\nexport function safeRemoteComponent<T extends ComponentType<any>>(opts: {\n moduleSpecifier: ModuleSpecifier;\n fallbackComponent: T;\n loadingElement?: ReactNode;\n}): T {\n const LazyComponent = lazy<T>(async () => {\n try {\n const remoteModule = await loadRemote<Record<string, unknown>>(opts.moduleSpecifier);\n const remoteExport = remoteModule?.default ?? remoteModule;\n\n return {\n default: remoteExport as T,\n };\n } catch (error) {\n console.error(`[MF] Load remote module \"${opts.moduleSpecifier}\" failed:`, error);\n return { default: opts.fallbackComponent };\n }\n });\n\n return ((props: any) => (\n <Suspense fallback={opts.loadingElement ?? null}>\n <LazyComponent {...props} />\n </Suspense>\n )) as T;\n}\n".replace("__REMOTES_JSON__",()=>n).replace("__RUNTIME_OPTIONS_JSON__",()=>r)}(t),s=e.dirname(r);if(o.existsSync(s)||o.mkdirSync(s,{recursive:!0}),o.existsSync(r)){if(o.readFileSync(r,"utf-8")===i)return}o.writeFileSync(r,i),console.log("✅ mf.tsx 已生成:",r)}function dl(e){return{name:"micro-frontend:mf-generator",enforce:"pre",configResolved(){ul(e)},buildStart(){ul(e)}}}const hl="\0virtual:micro-frontend-react-bridge-provider";function fl(e){return{schemaVersion:1,appName:e.appName,loader:"module-federation",remote:{name:e.remoteName,type:"module",entry:`./${e.manifestFileName.replace(/^\/+/,"")}`,module:`${e.remoteName}/export-app`},application:{contract:"module-federation-react-bridge",version:1,mountElementId:e.mountElementId,...e.bridgeRouter?{routing:"bridge-router"}:void 0},...e.buildVersion?{buildVersion:e.buildVersion}:void 0}}function ml(t){let n=t,r=`${JSON.stringify(fl(t),null,2)}\n`,i=process.cwd(),s=e.resolve(process.cwd(),t.entry);return{name:"micro-frontend:federation-application",enforce:"pre",configResolved(a){i=a.root,s=e.resolve(a.root,t.entry);const o=function(e,t){const n=e.split("/").filter(Boolean),r=n[n.length-1],i=t.replace(/_/g,"-");return r===i||r===`app-${i}`?i:t}(a.base,t.appName);n={...t,appName:t.inferAppNameFromBase?o:t.appName,mountElementId:t.inferMountElementIdFromBase?o:t.mountElementId},r=`${JSON.stringify(fl(n),null,2)}\n`},configureServer(e){e.middlewares.use((e,n,i)=>{!function(e,t){if(!e)return!1;const n=e.split(/[?#]/)[0];return n===`/${t}`||n.endsWith(`/${t}`)}(e.url,t.capabilityFileName)?i():(n.statusCode=200,n.setHeader("Content-Type","application/json; charset=utf-8"),n.setHeader("Cache-Control","no-store"),n.setHeader("Access-Control-Allow-Origin","*"),n.end(r))})},resolveId(n,r){if(n===hl)return hl;const a=n.split(/[?#]/)[0],o=e.normalize(e.isAbsolute(a)?a:e.resolve(i,a)),l=r?.replace(/^\0/,"").startsWith("virtual:mf-exposes");return t.enhanceEntry&&l&&o===e.normalize(s)?hl:null},load:e=>t.enhanceEntry&&e===hl?n.rootComponent?`import RootComponent from ${JSON.stringify(s)};\nimport { createMicroFrontendRootBridgeProvider } from "@lemon-fe/vite-plugin-micro-frontend/runtime/bridge";\nexport default createMicroFrontendRootBridgeProvider({\n rootComponent: RootComponent,\n});\n`:`import ${JSON.stringify(s)};\nimport { createMicroFrontendBridgeProvider } from "@lemon-fe/vite-plugin-micro-frontend/runtime/bridge";\nexport default createMicroFrontendBridgeProvider({\n appName: ${JSON.stringify(n.appName)},\n mountElementId: ${JSON.stringify(n.mountElementId)},\n});\n`:null,generateBundle(){this.emitFile({type:"asset",fileName:t.capabilityFileName,source:r})}}}const yl="\nconst hook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;\nif (hook && !hook.__microFrontendTracksRenderers) {\n const inject = hook.inject;\n hook.inject = function(renderer) {\n const id = inject.apply(this, arguments);\n hook.renderers.set(id, renderer);\n return id;\n };\n hook.__microFrontendTracksRenderers = true;\n}\n";const Tl="/@micro-frontend/federation-hmr";function gl(e){return e.replace(/\\/g,"/")}function Sl(t){const n=function(t){const n={},r=[".tsx",".ts"];if(!o.existsSync(t))return n;const i=o.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(o.existsSync(n)){a=n;break}}if(a){const t=gl(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=gl(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||{}}}const xl="\nconst __remoteUrl = new URL(import.meta.url);\nconst __hostRefreshUrl = globalThis.__MF_REACT_REFRESH_URL__;\nconst __target =\n window.location.origin === __remoteUrl.origin || !__hostRefreshUrl\n ? new URL('./@mf-react-refresh-local', __remoteUrl).href\n : __hostRefreshUrl;\nconst __rt = await import(__target);\n\nif (!window.__vite_plugin_react_preamble_installed__) {\n __rt.injectIntoGlobalHook(window);\n window.$RefreshReg$ ||= () => {};\n window.$RefreshSig$ ||= () => type => type;\n window.__vite_plugin_react_preamble_installed__ = true;\n}\n\nexport const injectIntoGlobalHook = __rt.injectIntoGlobalHook;\nexport const register = __rt.register;\nexport const getRefreshReg = __rt.getRefreshReg;\nexport const createSignatureFunctionForTransform = __rt.createSignatureFunctionForTransform;\nexport const registerExportsForReactRefresh = __rt.registerExportsForReactRefresh;\nexport const validateRefreshBoundaryAndEnqueueUpdate = __rt.validateRefreshBoundaryAndEnqueueUpdate;\nexport const __hmr_import = __rt.__hmr_import;\nexport default __rt.default || __rt;\n".trimStart();function bl(){let t;return{name:"micro-frontend:federation-react-refresh-proxy",enforce:"pre",apply:"serve",configureServer(n){n.middlewares.use((r,i,s)=>{const a=r.url?.split(/[?#]/)[0];if("GET"===r.method)return a?.endsWith("/@mf-react-refresh-local")?(t??(t=function(t){try{const n=S(e.join(t,"package.json")).resolve("@vitejs/plugin-react"),r=e.join(e.dirname(n),"refresh-runtime.js");return o.readFileSync(r,"utf8")}catch{return null}}(n.config.root)),t?(i.statusCode=200,i.setHeader("Content-Type","application/javascript; charset=utf-8"),i.setHeader("Cache-Control","no-store"),i.setHeader("Access-Control-Allow-Origin","*"),void i.end(t)):void s()):void(a?.endsWith("/@react-refresh")?(i.statusCode=200,i.setHeader("Content-Type","application/javascript; charset=utf-8"),i.setHeader("Cache-Control","no-store"),i.setHeader("Access-Control-Allow-Origin","*"),i.end(xl)):s());s()})}}}function El(){const t="\0virtual:micro-frontend-bridge-router";let n="",r=[];return{name:"micro-frontend:federation-bridge-router",enforce:"pre",config(t){const i=function(t){const n=S(e.join(t,"package.json"));let r;try{r=n.resolve("react-router-dom/package.json")}catch{throw new Error("[micro-frontend] 已启用 federation.bridge.enableBridgeRouter,但无法从项目中解析 react-router-dom。")}const i=JSON.parse(o.readFileSync(r,"utf8")),s=Number.parseInt(i.version||"",10);if(5!==s&&6!==s&&7!==s)throw new Error(`[micro-frontend] Bridge Router 仅支持 React Router v5/v6/v7,当前版本为 ${i.version||"unknown"}。`);const a=n("react-router-dom");return{version:`v${s}`,exportNames:Object.keys(a).filter(e=>"BrowserRouter"!==e&&/^[A-Za-z_$][\w$]*$/.test(e))}}(e.resolve(process.cwd(),t.root||"."));r=i.exportNames,n=x(import.meta.resolve(`@module-federation/bridge-react/router-${i.version}`))},resolveId:e=>"react-router-dom"===e?t:null,load:e=>e!==t?null:`import * as ReactRouterDOMNamespace from "react-router-dom/index.js";\nimport { BrowserRouter as OfficialBridgeRouter } from ${JSON.stringify(n)};\nimport { withBridgeRouteSync } from "@lemon-fe/vite-plugin-micro-frontend/runtime/bridge";\nconst ReactRouterDOM = ReactRouterDOMNamespace.default || ReactRouterDOMNamespace;\n`+r.map(e=>`export const ${e} = ReactRouterDOM[${JSON.stringify(e)}];`).join("\n")+"\nexport const BrowserRouter = withBridgeRouteSync(OfficialBridgeRouter, ReactRouterDOM.useLocation);\n"}}function Pl(e,t){if(!e)return e;const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,r=e=>Object.prototype.hasOwnProperty.call(n,e);if(!(r("react")||r("react/"))||r("react/jsx-dev-runtime"))return e;const i=n.react??n["react/"],s="object"==typeof i?i.requiredVersion:void 0;return{...n,"react/jsx-dev-runtime":{shareScope:`__micro_frontend_react_dev_${t}`,singleton:!1,...void 0!==s?{requiredVersion:s}:void 0}}}function vl(t,n={}){const r={dts:!1,manifest:!0,shareStrategy:"loaded-first",...t,shared:Pl(t.shared,t.name),dev:(i=t.dev,!1!==i&&("object"==typeof i?{remoteHmr:!0,...i}:{remoteHmr:!0}))};var i;!function(e){if(!/^[A-Za-z_$][\w$]*$/.test(e))throw new Error(`[micro-frontend] Module Federation name "${e}" 无效,请使用不含连字符的 JavaScript 标识符(例如 earth_wms)。`)}(r.name);const s=[];r.debugReactHost&&s.push({name:"micro-frontend:react-refresh-host",enforce:"pre",apply:"serve",configureServer(e){const t=h(P.join(e.config.root,"package.json")),n=e.config.base.replace(/\/$/,""),r=new Map,i=new Map,s=e=>{const n=P.dirname(t.resolve(`${e}/package.json`)),{version:r}=JSON.parse(E.readFileSync(P.join(n,"package.json"),"utf8"));if(!String(r).startsWith("18."))throw new Error(`debugReactHost 需要 React 18 UMD,当前 ${e} 版本为 ${r}`);return E.readFileSync(P.join(n,"umd",`${e}.development.js`),"utf8")};r.set(`${n}/@micro-frontend/host-react.js`,()=>s("react")),r.set(`${n}/@micro-frontend/host-react-dom.js`,()=>{const e=h(t.resolve("@vitejs/plugin-react")),n=P.dirname(e.resolve("react-refresh/package.json"));return`(() => {\nconst exports = {};\nconst process = { env: { NODE_ENV: 'development' } };\n${E.readFileSync(P.join(n,"cjs/react-refresh-runtime.development.js"),"utf8")}\nexports.injectIntoGlobalHook(window);\n${yl}\n})();\n${s("react-dom")}`}),e.middlewares.use((e,t,n)=>{const s=e.url?.split(/[?#]/)[0]??"",a=r.get(s);if(!a||"GET"!==e.method&&"HEAD"!==e.method)return n();try{i.has(s)||i.set(s,a()),t.setHeader("Content-Type","application/javascript; charset=utf-8"),t.setHeader("Cache-Control","no-store"),t.setHeader("Access-Control-Allow-Origin","*"),t.end("HEAD"===e.method?void 0:i.get(s))}catch(e){n(e)}})}});const a=!1===r.application?void 0:r.application||{};if(a&&!1===r.manifest)throw new Error("[micro-frontend] 完整微应用必须启用 federation.manifest,如只暴露普通联邦组件,请设置 federation.application = false。");if(a?.rootComponent&&a.entry)throw new Error("[micro-frontend] federation.application.rootComponent 与 entry 不能同时配置。");const o="object"==typeof(l=r.manifest)&&l.fileName?l.fileName:"mf-manifest.json";var l;const c=[...!1===r.manifest?[]:[o],...a?[a.capabilityFileName||"micro-frontend.json"]:[]],p=Boolean(a?.rootComponent&&!1!==r.bridge?.enableBridgeRouter);var u;p&&s.push(El()),s.push(bl()),c.length>0&&s.push((u=c,{name:"micro-frontend:federation-dev-preflight",enforce:"pre",apply:"serve",configureServer(e){e.middlewares.use((t,n,r)=>{if("OPTIONS"!==t.method||!1===e.config.server.cors||!function(e,t){if(!e)return!1;const n=e.split(/[?#]/)[0];return t.some(e=>{const t=e.replace(/^\/+/,"");return n===`/${t}`||n.endsWith(`/${t}`)})}(t.url,u))return void r();const i=t.headers["access-control-request-headers"];n.statusCode=204,n.setHeader("Access-Control-Allow-Origin","*"),n.setHeader("Access-Control-Allow-Methods","GET, HEAD, PUT, PATCH, POST, DELETE, OPTIONS"),i&&n.setHeader("Access-Control-Allow-Headers",Array.isArray(i)?i.join(", "):i),"true"===t.headers["access-control-request-private-network"]&&n.setHeader("Access-Control-Allow-Private-Network","true"),n.setHeader("Content-Length","0"),n.end()})}}));const d=function(e,t,n){if(!e||0===e.length)return;const r={};for(const i of e){const{aliasName:e,remoteName:s,entry:a,isESModule:o}=i,l=e||s,c=a.startsWith("/")?a:`/${a}`;let p;p=a.startsWith("http")?a:t?new URL(c,`${t.replace(/\/$/,"")}/`).href:c,r[l]={type:o?"module":"var",name:l,entry:p,entryGlobalName:s,shareScope:n||"default"}}return r}(r.remotes,r.devHost,r.shareScope),f=Sl(r);if(a){const e=f["./export-app"];if(a.rootComponent&&e)throw new Error('[micro-frontend] federation.application.rootComponent 与 exposes["./export-app"] 不能同时配置。');const t=a.rootComponent||a.entry||("string"==typeof(m=e)?m:m?.import)||"src/main.tsx",i=a.appName||n.appName||r.name,l=a.mountElementId||i;e||(f["./export-app"]=`./${t.replace(/^\.\//,"")}`),s.push(ml({appName:i,remoteName:r.name,entry:t,mountElementId:l,manifestFileName:o,capabilityFileName:a.capabilityFileName||"micro-frontend.json",buildVersion:a.buildVersion,enhanceEntry:!e,rootComponent:!!a.rootComponent,bridgeRouter:p,inferAppNameFromBase:!a.appName,inferMountElementIdFromBase:!a.mountElementId}))}var m;const{application:y,bridge:T,devHost:g,debugReactHost:S,exposesDir:x,outputPath:v,remotes:A,...C}=r;return s.push(b({filename:"remote.js",hostInitInjectLocation:"entry",...C,remotes:d,exposes:f})),s.push({name:"micro-frontend:federation-commonjs-helpers",apply:"build",outputOptions:{order:"post",handler(e){const t=e.manualChunks;if("function"==typeof t)return{...e,manualChunks:(e,n)=>"\0commonjsHelpers.js"===e?"commonjs-helpers":t(e,n)}}}}),function(e){return"object"==typeof e&&null!==e&&Boolean(e.remoteHmr)}(r.dev)&&Object.keys(f).length>0&&s.push(function(){let e;const t=()=>`${e.base.replace(/\/$/,"")}${Tl}`;return{name:"micro-frontend:federation-remote-hmr-client",enforce:"post",apply:"serve",config(e){const t=e.server;if(!1===t?.hmr||!t?.origin)return;let n;try{n=new URL(t.origin)}catch{return}if("http:"!==n.protocol&&"https:"!==n.protocol)return;const r="object"==typeof t.hmr?t.hmr:{};return{server:{hmr:{...r,host:r.host??n.hostname,protocol:r.protocol??("https:"===n.protocol?"wss":"ws"),clientPort:r.clientPort??r.port??Number(n.port||("https:"===n.protocol?443:80))}}}},configResolved(t){e=t},resolveId:e=>e===Tl||e===t()?Tl:null,load(t){if(t!==Tl||!1===e.server.hmr)return null;const n=e.base.replace(/\/$/,"");return`\nimport ${JSON.stringify(`${n}/@vite/client`)};\nimport { injectIntoGlobalHook } from ${JSON.stringify(`${n}/@react-refresh`)};\n\nif (!window.__vite_plugin_react_preamble_installed__) {\n injectIntoGlobalHook(window);\n window.$RefreshReg$ ||= () => {};\n window.$RefreshSig$ ||= () => type => type;\n window.__vite_plugin_react_preamble_installed__ = true;\n}\n${yl}\n\nif (import.meta.hot) {\n let reloadTimer;\n const afterUpdate = payload => {\n const hasScriptUpdate = payload.updates?.some(update =>\n update.type === 'js-update' &&\n !/\\.(css|less|sass|scss|styl|stylus|pcss|postcss)(?:[?#]|$)/i.test(update.acceptedPath || update.path)\n );\n if (!hasScriptUpdate) return;\n\n const renderers = window.__REACT_DEVTOOLS_GLOBAL_HOOK__?.renderers;\n const activeRenderers = renderers ? Array.from(renderers.values()) : [];\n // 只要有 production renderer,就不能假设该 Remote 由另一个 development renderer 渲染。\n if (activeRenderers.length && activeRenderers.every(renderer =>\n typeof renderer.scheduleRefresh === 'function' &&\n typeof renderer.setRefreshHandler === 'function'\n )) return;\n\n clearTimeout(reloadTimer);\n reloadTimer = setTimeout(() => window.location.reload(), 50);\n };\n import.meta.hot.on('vite:afterUpdate', afterUpdate);\n import.meta.hot.dispose(() => {\n clearTimeout(reloadTimer);\n import.meta.hot.off('vite:afterUpdate', afterUpdate);\n });\n}\n`},transform(n,r){if(!1===e.server.hmr||!r.includes("virtual:mf-REMOTE_ENTRY_ID"))return null;const i=`import ${JSON.stringify(t())};`;return n.includes(i)?null:{code:`${i}\n${n}`,map:null}},transformIndexHtml(){if(!1!==e.server.hmr)return[{tag:"script",attrs:{type:"module",src:t()},injectTo:"head"}]}}}()),s.push(dl({hostName:r.name,devHost:r.devHost,shareScope:r.shareScope,remotes:r.remotes??[],outputPath:r.outputPath?e.resolve(process.cwd(),r.outputPath):"src/utils/mf.tsx"})),s}function Al(e){return e&&"/"!==e?e.replace(/^\/+|\/+$/g,""):""}function Cl(e,t,n){if(!t||!n)return e;const r=function(e){const t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`import\\((['"])\\/${t}\\/([^'"]+)\\1\\)`,"g")}(t);return e.replace(r,`import(${n} + '/$2')`)}function wl(e,t){if("boolean"==typeof t&&!t)return"";const n="boolean"==typeof t?{}:t;if(n.publicPath?.trim())return n.publicPath.trim();const r=function(e,t){const n="boolean"==typeof t?{}:t;if(n.appBase?.trim())return n.appBase.trim().replace(/^\/+|\/+$/g,"");const r=Al(e.base);return r&&"__dynamic_base__"!==r?r:""}(e,t),i=r?`/${r}`:e.base??"/";return`(window.EARTH_BASE_CONFIG && window.EARTH_BASE_CONFIG.EARTH_ALL_SHARE_HOST ? window.EARTH_BASE_CONFIG.EARTH_ALL_SHARE_HOST.replace(/\\/$/, '') : '') + ${JSON.stringify(i)}`}function Il(e,t,n){if(e)return"function"==typeof e?e.apply(t,n):e.handler.apply(t,n)}function Nl(e,t){let n;const{transformIndexHtml:r=!0,transformIndexHtmlConfig:i}=e;return{name:"micro-frontend:dynamic-base-deferred",enforce:"post",apply:"build",configResolved:e=>(n=v({publicPath:t(),transformIndexHtml:r,transformIndexHtmlConfig:i}),Il(n.configResolved,n,[e])),generateBundle(e,t,r){if(n?.generateBundle)return Il(n.generateBundle,n,[e,t,r])}}}function kl(e,t,n){const{transformIndexHtml:r=!0,removeIndexCssPreload:i=!1}=e,s=[];if(r){const e=e=>Cl(e,n(),t());s.push({name:"micro-frontend:rewrite-inline-dynamic-base-import",enforce:"post",apply:"build",transformIndexHtml:{order:"post",handler:t=>e(t)},generateBundle(t,n){for(const t of Object.values(n))"asset"===t.type&&t.fileName.endsWith(".html")&&"string"==typeof t.source&&(t.source=e(t.source))}})}return i&&s.push({name:"micro-frontend:remove-index-css-preload",enforce:"post",apply:"build",transformIndexHtml(e){let t=e.replace(/<link[^>]*rel=["']stylesheet["'][^>]*href=["']\/?index-[^"']+\.css["'][^>]*>/gi,"");return t=t.replace(/,\{"parentTagName":"head","tagName":"link","attrs":\{"rel":"stylesheet","crossorigin":"","href":"\/index-[^"]+\.css"\}\}/g,""),t}}),s}function Ol(e){const t={publicPath:"",appBasePath:""},n=function(e){return"boolean"==typeof e?{}:e}(e),r=()=>t.publicPath;return[{name:"micro-frontend:dynamic-base-init",enforce:"pre",apply:"build",config(n,r){t.publicPath=wl(n,e),t.appBasePath=Al(n.base)}},Nl(n,r),...kl(n,r,()=>t.appBasePath)]}const _l=S(import.meta.url);function Dl(){let e="";return{name:"micro-frontend:antd-external",enforce:"pre",config(n,r){const i=_l.resolve("antd/es/index.js"),s=l.readFileSync(i,"utf-8"),a=new Set,o=/export\s*\{\s*default\s+as\s+(\w+)\s*\}/g;let c;for(;c=o.exec(s);)a.add(c[1]);const p=/export\s+var\s+(\w+)\s*=/g;for(;c=p.exec(s);)a.add(c[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"),l.mkdirSync(t.dirname(e),{recursive:!0}),l.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 Ll={pagesDir:"src/pages",outputPath:"src/routes.ts",watch:!0,ignoreDirs:["components","utils","hooks","typings"],routeTemplate:{defaultLoadingComponentPath:"@/components/loading",intlPath:"@/utils/intl"}},Ml="__microFrontendOptions";function Fl(t){const{appName:n,federation:r,routes:i,dynamicBase:s}=t,a=[];a.push({name:"micro-frontend:options",[Ml]:t});const o="object"==typeof i?{...Ll,...i}:Ll;return a.push(pl({pagesDir:o.pagesDir?e.resolve(process.cwd(),o.pagesDir):void 0,outputPath:o.outputPath?e.resolve(process.cwd(),o.outputPath):void 0,watch:o.watch,ignoreDirs:o.ignoreDirs,routeTemplate:o.routeTemplate})),r&&a.push(...vl(r,{appName:n})),s&&a.push(...Ol(s)),a}export{Ml as MICRO_FRONTEND_OPTIONS_KEY,Dl as autoExternalAntd,R as cssInjectedByJsPlugin,J as devHmrPlugin,vl as federationPlugin,ul as generateMf,cl as generateRoutesToFile,Ol as getDynamicBasePlugins,il as getRoutes,dl as mfGeneratorPlugin,Fl as microFrontendPlugins,pl as pagesRoutesPlugin};
|
|
14
14
|
//# sourceMappingURL=index.js.map
|