(e)
| 34 | `,n.template.expression.ast` |
| 35 | (o, v) => o.${n.types.cloneNode(e)} = v |
| 36 | `]}function getComputedKeyLastElement(e){e=(0,i.skipTransparentExprWrappers)(e);if(e.isSequenceExpression()){const t=e.get("expressions");return getComputedKeyLastElement(t[t.length-1])}return e}function getComputedKeyMemoiser(e){const t=getComputedKeyLastElement(e);if(t.isConstantExpression()){return n.types.cloneNode(e.node)}else if(t.isIdentifier()&&e.scope.hasUid(t.node.name)){return n.types.cloneNode(e.node)}else if(t.isAssignmentExpression()&&t.get("left").isIdentifier()){return n.types.cloneNode(t.node.left)}else{throw new Error(`Internal Error: the computed key ${e.toString()} has not yet been memoised.`)}}function prependExpressionsToComputedKey(e,t){const r=t.get("key");if(r.isSequenceExpression()){e.push(...r.node.expressions)}else{e.push(r.node)}r.replaceWith(maybeSequenceExpression(e))}function appendExpressionsToComputedKey(e,t){const r=t.get("key");const s=getComputedKeyLastElement(r);if(s.isConstantExpression()){prependExpressionsToComputedKey(e,t)}else{const i=r.scope.parent;const a=(0,o.memoiseComputedKey)(s.node,i,i.generateUid("computedKey"));if(!a){prependExpressionsToComputedKey(e,t)}else{const t=[...e,n.types.cloneNode(a.left)];const r=s.parentPath;if(r.isSequenceExpression()){r.pushContainer("expressions",t)}else{s.replaceWith(maybeSequenceExpression([n.types.cloneNode(a),...t]))}}}}function prependExpressionsToFieldInitializer(e,t){const r=t.get("value");if(r.node){e.push(r.node)}else if(e.length>0){e[e.length-1]=n.types.unaryExpression("void",e[e.length-1])}r.replaceWith(maybeSequenceExpression(e))}function prependExpressionsToStaticBlock(e,t){t.unshiftContainer("body",n.types.expressionStatement(maybeSequenceExpression(e)))}function prependExpressionsToConstructor(e,t){t.node.body.body.unshift(n.types.expressionStatement(maybeSequenceExpression(e)))}function isProtoInitCallExpression(e,t){return n.types.isCallExpression(e)&&n.types.isIdentifier(e.callee,{name:t.name})}function optimizeSuperCallAndExpressions(e,t){if(t){if(e.length>=2&&isProtoInitCallExpression(e[1],t)){const r=n.types.callExpression(n.types.cloneNode(t),[e[0]]);e.splice(0,2,r)}if(e.length>=2&&n.types.isThisExpression(e[e.length-1])&&isProtoInitCallExpression(e[e.length-2],t)){e.splice(e.length-1,1)}}return maybeSequenceExpression(e)}function insertExpressionsAfterSuperCallAndOptimize(e,t,r){t.traverse({CallExpression:{exit(t){if(!t.get("callee").isSuper())return;const s=[t.node,...e.map((e=>n.types.cloneNode(e)))];if(t.isCompletionRecord()){s.push(n.types.thisExpression())}t.replaceWith(optimizeSuperCallAndExpressions(s,r));t.skip()}},ClassMethod(e){if(e.node.kind==="constructor"){e.skip()}}})}function createConstructorFromExpressions(e,t){const r=[n.types.expressionStatement(maybeSequenceExpression(e))];if(t){r.unshift(n.types.expressionStatement(n.types.callExpression(n.types.super(),[n.types.spreadElement(n.types.identifier("args"))])))}return n.types.classMethod("constructor",n.types.identifier("constructor"),t?[n.types.restElement(n.types.identifier("args"))]:[],n.types.blockStatement(r))}function createStaticBlockFromExpressions(e){return n.types.staticBlock([n.types.expressionStatement(maybeSequenceExpression(e))])}const l=0;const c=1;const p=2;const u=3;const d=4;const f=5;const h=8;const m=16;function getElementKind(e){switch(e.node.type){case"ClassProperty":case"ClassPrivateProperty":return l;case"ClassAccessorProperty":return c;case"ClassMethod":case"ClassPrivateMethod":if(e.node.kind==="get"){return u}else if(e.node.kind==="set"){return d}else{return p}}}function toSortedDecoratorInfo(e){return[...e.filter((e=>e.isStatic&&e.kind>=c&&e.kind<=d)),...e.filter((e=>!e.isStatic&&e.kind>=c&&e.kind<=d)),...e.filter((e=>e.isStatic&&e.kind===l)),...e.filter((e=>!e.isStatic&&e.kind===l))]}function generateDecorationList(e,t,r){const s=e.length;const i=t.some(Boolean);const a=[];for(let o=0;o<s;o++){if((r==="2023-11"||r==="2023-05")&&i){a.push(t[o]||n.types.unaryExpression("void",n.types.numericLiteral(0)))}a.push(e[o].expression)}return{haveThis:i,decs:a}}function generateDecorationExprs(e,t){return n.types.arrayExpression(e.map((e=>{let r=e.kind;if(e.isStatic){r+=t==="2023-11"||t==="2023-05"?h:f}if(e.decoratorsHaveThis)r+=m;return n.types.arrayExpression([e.decoratorsArray,n.types.numericLiteral(r),e.name,...e.privateMethods||[]])})))}function extractElementLocalAssignments(e){const t=[];for(const r of e){const{locals:e}=r;if(Array.isArray(e)){t.push(...e)}else if(e!==undefined){t.push(e)}}return t}function addCallAccessorsFor(e,t,r,s,i,a){t.insertAfter(n.types.classPrivateMethod("get",n.types.cloneNode(r),[],n.types.blockStatement([n.types.returnStatement(n.types.callExpression(n.types.cloneNode(s),e==="2023-11"&&a?[]:[n.types.thisExpression()]))]),a));t.insertAfter(n.types.classPrivateMethod("set",n.types.cloneNode(r),[n.types.identifier("v")],n.types.blockStatement([n.types.expressionStatement(n.types.callExpression(n.types.cloneNode(i),e==="2023-11"&&a?[n.types.identifier("v")]:[n.types.thisExpression(),n.types.identifier("v")]))]),a))}function movePrivateAccessor(e,t,r,s){let i;let a;if(e.node.kind==="set"){i=[n.types.identifier("v")];a=[n.types.expressionStatement(n.types.callExpression(r,[n.types.thisExpression(),n.types.identifier("v")]))]}else{i=[];a=[n.types.returnStatement(n.types.callExpression(r,[n.types.thisExpression()]))]}e.replaceWith(n.types.classPrivateMethod(e.node.kind,n.types.cloneNode(t),i,n.types.blockStatement(a),s))}function isClassDecoratableElementPath(e){const{type:t}=e;return t!=="TSDeclareMethod"&&t!=="TSIndexSignature"&&t!=="StaticBlock"}function staticBlockToIIFE(e){return n.types.callExpression(n.types.arrowFunctionExpression([],n.types.blockStatement(e.body)),[])}function staticBlockToFunctionClosure(e){return n.types.functionExpression(null,[],n.types.blockStatement(e.body))}function fieldInitializerToClosure(e){return n.types.functionExpression(null,[],n.types.blockStatement([n.types.returnStatement(e)]))}function maybeSequenceExpression(e){if(e.length===0)return n.types.unaryExpression("void",n.types.numericLiteral(0));if(e.length===1)return e[0];return n.types.sequenceExpression(e)}function createFunctionExpressionFromPrivateMethod(e){const{params:t,body:r,generator:s,async:i}=e;return n.types.functionExpression(undefined,t,r,s,i)}function createSetFunctionNameCall(e,t){return n.types.callExpression(e.addHelper("setFunctionName"),[n.types.thisExpression(),t])}function createToPropertyKeyCall(e,t){return n.types.callExpression(e.addHelper("toPropertyKey"),[t])}function createPrivateBrandCheckClosure(e){return n.types.arrowFunctionExpression([n.types.identifier("_")],n.types.binaryExpression("in",n.types.cloneNode(e),n.types.identifier("_")))}function usesPrivateField(e){{try{n.types.traverseFast(e,(e=>{if(n.types.isPrivateName(e)){throw null}}));return false}catch(e){return true}}}function convertToComputedKey(e){const{node:t}=e;t.computed=true;if(n.types.isIdentifier(t.key)){t.key=n.types.stringLiteral(t.key.name)}}function hasInstancePrivateAccess(e,t){let r=false;if(t.length>0){const n=(0,a.privateNameVisitorFactory)({PrivateName(e,t){if(t.privateNamesMap.has(e.node.id.name)){r=true;e.stop()}}});const s=new Map;for(const e of t){s.set(e,null)}e.traverse(n,{privateNamesMap:s})}return r}function checkPrivateMethodUpdateError(e,t){const r=(0,a.privateNameVisitorFactory)({PrivateName(e,t){if(!t.privateNamesMap.has(e.node.id.name))return;const r=e.parentPath;const n=r.parentPath;if(n.node.type==="AssignmentExpression"&&n.node.left===r.node||n.node.type==="UpdateExpression"||n.node.type==="RestElement"||n.node.type==="ArrayPattern"||n.node.type==="ObjectProperty"&&n.node.value===r.node&&n.parentPath.type==="ObjectPattern"||n.node.type==="ForOfStatement"&&n.node.left===r.node){throw e.buildCodeFrameError(`Decorated private methods are read-only, but "#${e.node.id.name}" is updated via this expression.`)}}});const n=new Map;for(const e of t){n.set(e,null)}e.traverse(r,{privateNamesMap:n})}function transformClass(e,t,r,i,a,p,f){var h;const m=e.get("body.body");const y=e.node.decorators;let g=false;let b=false;let T=false;const S=createLazyPrivateUidGeneratorForClass(e);const x=[];const E=e.scope.parent;const memoiseExpression=(e,t,r)=>{const s=generateLetUidIdentifier(E,t);r.push(n.types.assignmentExpression("=",s,e));return n.types.cloneNode(s)};let P;let v;const A=(h=e.node.id)==null?void 0:h.name;const w=typeof a==="object"?a:undefined;const usesFunctionContextOrYieldAwait=e=>{{try{n.types.traverseFast(e,(e=>{if(n.types.isThisExpression(e)||n.types.isSuper(e)||n.types.isYieldExpression(e)||n.types.isAwaitExpression(e)||n.types.isIdentifier(e,{name:"arguments"})||A&&n.types.isIdentifier(e,{name:A})||n.types.isMetaProperty(e)&&e.meta.name!=="import"){throw null}}));return false}catch(e){return true}}};const I=[];for(const r of m){if(!isClassDecoratableElementPath(r)){continue}const s=r.node;if(!s.static&&n.types.isPrivateName(s.key)){I.push(s.key.id.name)}if(isDecorated(s)){switch(s.type){case"ClassProperty":p.ClassProperty(r,t);break;case"ClassPrivateProperty":p.ClassPrivateProperty(r,t);break;case"ClassAccessorProperty":p.ClassAccessorProperty(r,t);if(f==="2023-11"){break}default:if(s.static){v!=null?v:v=generateLetUidIdentifier(E,"initStatic")}else{P!=null?P:P=generateLetUidIdentifier(E,"initProto")}break}g=true;T||(T=s.decorators.some(usesFunctionContextOrYieldAwait))}else if(s.type==="ClassAccessorProperty"){p.ClassAccessorProperty(r,t);const{key:i,value:l,static:c,computed:u}=s;const d=S();const h=generateClassProperty(d,l,c);const m=r.get("key");const[y]=r.replaceWith(h);let g,b;if(u&&!m.isConstantExpression()){g=(0,o.memoiseComputedKey)(createToPropertyKeyCall(t,i),E,E.generateUid("computedKey"));b=n.types.cloneNode(g.left)}else{g=n.types.cloneNode(i);b=n.types.cloneNode(i)}assignIdForAnonymousClass(e,a);addProxyAccessorsFor(e.node.id,y,g,b,d,u,c,f)}if("computed"in r.node&&r.node.computed){b||(b=!E.isStatic(r.node.key))}}if(!y&&!g){if(!e.node.id&&typeof a==="string"){e.node.id=n.types.identifier(a)}if(w){e.node.body.body.unshift(createStaticBlockFromExpressions([createSetFunctionNameCall(t,w)]))}return}const C=[];let O;const N=new Set;let k,_;let D=null;function handleDecorators(e){let t=false;let r=false;const s=[];for(const i of e){const{expression:e}=i;let a;if((f==="2023-11"||f==="2023-05")&&n.types.isMemberExpression(e)){if(n.types.isSuper(e.object)){a=n.types.thisExpression()}else if(E.isStatic(e.object)){a=n.types.cloneNode(e.object)}else{D!=null?D:D=generateLetUidIdentifier(E,"obj");a=n.types.assignmentExpression("=",n.types.cloneNode(D),e.object);e.object=n.types.cloneNode(D)}}s.push(a);t||(t=!E.isStatic(e));r||(r=usesFunctionContextOrYieldAwait(i))}return{hasSideEffects:t,usesFnContext:r,decoratorsThis:s}}const M=b||T||f!=="2023-11";let L=false;let j=0;let F=[];let B;let R=[];if(y){k=generateLetUidIdentifier(E,"initClass");L=e.isClassDeclaration();({id:_,path:e}=replaceClassWithVar(e,a));e.node.decorators=null;const t=y.some(usesPrivateField);const{hasSideEffects:r,usesFnContext:s,decoratorsThis:i}=handleDecorators(y);const{haveThis:l,decs:c}=generateDecorationList(y,i,f);j=l?1:0;F=c;if(s||r&&M||t){B=memoiseExpression(n.types.arrayExpression(F),"classDecs",x)}if(!g){for(const t of e.get("body.body")){const{node:e}=t;const r="computed"in e&&e.computed;if(r){if(t.isClassProperty({static:true})){if(!t.get("key").isConstantExpression()){const t=e.key;const r=(0,o.memoiseComputedKey)(t,E,E.generateUid("computedKey"));if(r!=null){e.key=n.types.cloneNode(r.left);R.push(r)}}}else if(R.length>0){prependExpressionsToComputedKey(R,t);R=[]}}}}}else{assignIdForAnonymousClass(e,a);_=n.types.cloneNode(e.node.id)}let U;let K=false;let V=[];let W=[];if(g){if(P){const e=n.types.callExpression(n.types.cloneNode(P),[n.types.thisExpression()]);V.push(e)}for(const i of m){if(!isClassDecoratableElementPath(i)){if(W.length>0&&i.isStaticBlock()){prependExpressionsToStaticBlock(W,i);W=[]}continue}const{node:p}=i;const h=p.decorators;const m=!!(h!=null&&h.length);const g="computed"in p&&p.computed;let b="computedKey";if(p.key.type==="PrivateName"){b=p.key.id.name}else if(!g&&p.key.type==="Identifier"){b=p.key.name}let T;let x;if(m){const{hasSideEffects:e,usesFnContext:t,decoratorsThis:r}=handleDecorators(h);const{decs:s,haveThis:i}=generateDecorationList(h,r,f);x=i;T=s.length===1?s[0]:n.types.arrayExpression(s);if(t||e&&M){T=memoiseExpression(T,b+"Decs",R)}}if(g){if(!i.get("key").isConstantExpression()){const e=p.key;const r=(0,o.memoiseComputedKey)(m?createToPropertyKeyCall(t,e):e,E,E.generateUid("computedKey"));if(r!=null){if(y&&i.isClassProperty({static:true})){p.key=n.types.cloneNode(r.left);R.push(r)}else{p.key=r}}}}const{key:P,static:v}=p;const A=P.type==="PrivateName";const w=getElementKind(i);if(A&&!v){if(m){K=true}if(n.types.isClassPrivateProperty(p)||!U){U=P}}if(i.isClassMethod({kind:"constructor"})){O=i}let I;if(m){let o;let p;if(g){p=getComputedKeyMemoiser(i.get("key"))}else if(P.type==="PrivateName"){p=n.types.stringLiteral(P.id.name)}else if(P.type==="Identifier"){p=n.types.stringLiteral(P.name)}else{p=n.types.cloneNode(P)}if(w===c){const{value:t}=i.node;const r=f==="2023-11"&&v?[]:[n.types.thisExpression()];if(t){r.push(n.types.cloneNode(t))}const s=S();const l=generateLetUidIdentifier(E,`init_${b}`);const c=n.types.callExpression(n.types.cloneNode(l),r);const p=generateClassProperty(s,c,v);const[u]=i.replaceWith(p);if(A){o=extractProxyAccessorsFor(s,f);const e=generateLetUidIdentifier(E,`get_${b}`);const t=generateLetUidIdentifier(E,`set_${b}`);addCallAccessorsFor(f,u,P,e,t,v);I=[l,e,t]}else{assignIdForAnonymousClass(e,a);addProxyAccessorsFor(e.node.id,u,n.types.cloneNode(P),n.types.isAssignmentExpression(P)?n.types.cloneNode(P.left):n.types.cloneNode(P),s,g,v,f);I=[l]}}else if(w===l){const e=generateLetUidIdentifier(E,`init_${b}`);const t=i.get("value");const r=f==="2023-11"&&v?[]:[n.types.thisExpression()];if(t.node)r.push(t.node);t.replaceWith(n.types.callExpression(n.types.cloneNode(e),r));I=[e];if(A){o=extractProxyAccessorsFor(P,f)}}else if(A){const a=generateLetUidIdentifier(E,`call_${b}`);I=[a];const l=new s.default({constantSuper:r,methodPath:i,objectRef:_,superRef:e.node.superClass,file:t.file,refToPreserve:_});l.replace();o=[createFunctionExpressionFromPrivateMethod(i.node)];if(w===u||w===d){movePrivateAccessor(i,n.types.cloneNode(P),n.types.cloneNode(a),v)}else{const t=i.node;e.node.body.body.unshift(n.types.classPrivateProperty(P,n.types.cloneNode(a),[],t.static));N.add(P.id.name);i.remove()}}C.push({kind:w,decoratorsArray:T,decoratorsHaveThis:x,name:p,isStatic:v,privateMethods:o,locals:I});if(i.node){i.node.decorators=null}}if(g&&R.length>0){if(y&&i.isClassProperty({static:true})){}else{prependExpressionsToComputedKey(R,w===c?i.getNextSibling():i);R=[]}}if(V.length>0&&!v&&(w===l||w===c)){prependExpressionsToFieldInitializer(V,i);V=[]}if(W.length>0&&v&&(w===l||w===c)){prependExpressionsToFieldInitializer(W,i);W=[]}if(m&&f==="2023-11"){if(w===l||w===c){const e=generateLetUidIdentifier(E,`init_extra_${b}`);I.push(e);const t=n.types.callExpression(n.types.cloneNode(e),v?[]:[n.types.thisExpression()]);if(!v){V.push(t)}else{W.push(t)}}}}}if(R.length>0){const t=e.get("body.body");let r;for(let e=t.length-1;e>=0;e--){const s=t[e];const i=s.node;if(i.computed){if(y&&n.types.isClassProperty(i,{static:true})){continue}r=s;break}}if(r!=null){appendExpressionsToComputedKey(R,r);R=[]}else{}}if(V.length>0){const t=!!e.node.superClass;if(O){if(t){insertExpressionsAfterSuperCallAndOptimize(V,O,P)}else{prependExpressionsToConstructor(V,O)}}else{e.node.body.body.unshift(createConstructorFromExpressions(V,t))}V=[]}if(W.length>0){e.node.body.body.push(createStaticBlockFromExpressions(W));W=[]}const $=toSortedDecoratorInfo(C);const q=generateDecorationExprs(f==="2023-11"?C:$,f);const H=extractElementLocalAssignments($);if(P){H.push(P)}if(v){H.push(v)}const G=[];let J=false;const z=k&&n.types.callExpression(n.types.cloneNode(k),[]);let X=e;const Y=e.node;const Q=[];if(y){G.push(_,k);const a=[];e.get("body.body").forEach((o=>{if(o.isStaticBlock()){if(hasInstancePrivateAccess(o,I)){const e=memoiseExpression(staticBlockToFunctionClosure(o.node),"staticBlock",Q);W.push(n.types.callExpression(n.types.memberExpression(e,n.types.identifier("call")),[n.types.thisExpression()]))}else{W.push(staticBlockToIIFE(o.node))}o.remove();return}if((o.isClassProperty()||o.isClassPrivateProperty())&&o.node.static){const e=o.get("value");if(hasInstancePrivateAccess(e,I)){const t=memoiseExpression(fieldInitializerToClosure(e.node),"fieldValue",Q);e.replaceWith(n.types.callExpression(n.types.memberExpression(t,n.types.identifier("call")),[n.types.thisExpression()]))}if(W.length>0){prependExpressionsToFieldInitializer(W,o);W=[]}o.node.static=false;a.push(o.node);o.remove()}else if(o.isClassPrivateMethod({static:true})){if(hasInstancePrivateAccess(o,I)){const a=new s.default({constantSuper:r,methodPath:o,objectRef:_,superRef:e.node.superClass,file:t.file,refToPreserve:_});a.replace();const l=memoiseExpression(createFunctionExpressionFromPrivateMethod(o.node),o.get("key.id").node.name,Q);if(i){o.node.params=[n.types.restElement(n.types.identifier("arg"))];o.node.body=n.types.blockStatement([n.types.returnStatement(n.types.callExpression(n.types.memberExpression(l,n.types.identifier("apply")),[n.types.thisExpression(),n.types.identifier("arg")]))])}else{o.node.params=o.node.params.map(((e,t)=>{if(n.types.isRestElement(e)){return n.types.restElement(n.types.identifier("arg"))}else{return n.types.identifier("_"+t)}}));o.node.body=n.types.blockStatement([n.types.returnStatement(n.types.callExpression(n.types.memberExpression(l,n.types.identifier("apply")),[n.types.thisExpression(),n.types.identifier("arguments")]))])}}o.node.static=false;a.push(o.node);o.remove()}}));if(a.length>0||W.length>0){const r=n.template.expression.ast` |
| 37 | class extends ${t.addHelper("identity")} {} |
| 38 | `;r.body.body=[n.types.classProperty(n.types.toExpression(Y),undefined,undefined,undefined,true,true),...a];const s=[];const i=n.types.newExpression(r,[]);if(W.length>0){s.push(...W)}if(z){J=true;s.push(z)}if(s.length>0){s.unshift(n.types.callExpression(n.types.super(),[n.types.cloneNode(_)]));r.body.body.push(createConstructorFromExpressions(s,false))}else{i.arguments.push(n.types.cloneNode(_))}const[o]=e.replaceWith(i);X=o.get("callee").get("body").get("body.0.key")}}if(!J&&z){e.node.body.body.push(n.types.staticBlock([n.types.expressionStatement(z)]))}let{superClass:Z}=Y;if(Z&&(f==="2023-11"||f==="2023-05")){const t=e.scope.maybeGenerateMemoised(Z);if(t){Y.superClass=n.types.assignmentExpression("=",t,Z);Z=t}}const ee=n.types.staticBlock([]);Y.body.body.unshift(ee);const te=ee.body;if(R.length>0){const e=X.get("body.body");let t;for(const r of e){if((r.isClassProperty()||r.isClassMethod())&&r.node.kind!=="constructor"){t=r;break}}if(t!=null){convertToComputedKey(t);prependExpressionsToComputedKey(R,t)}else{Y.body.body.unshift(n.types.classProperty(n.types.sequenceExpression([...R,n.types.stringLiteral("_")]),undefined,undefined,undefined,true,true));te.push(n.types.expressionStatement(n.types.unaryExpression("delete",n.types.memberExpression(n.types.thisExpression(),n.types.identifier("_")))))}R=[]}te.push(n.types.expressionStatement(createLocalsAssignment(H,G,q,B!=null?B:n.types.arrayExpression(F),n.types.numericLiteral(j),K?U:null,w,n.types.cloneNode(Z),t,f)));if(v){te.push(n.types.expressionStatement(n.types.callExpression(n.types.cloneNode(v),[n.types.thisExpression()])))}if(Q.length>0){te.push(...Q.map((e=>n.types.expressionStatement(e))))}e.insertBefore(x.map((e=>n.types.expressionStatement(e))));if(L){const t=E.getBinding(_.name);if(!t.constantViolations.length){e.insertBefore(n.types.variableDeclaration("let",[n.types.variableDeclarator(n.types.cloneNode(_))]))}else{const t=E.generateUidIdentifier("t"+_.name);const r=_;e.replaceWithMultiple([n.types.variableDeclaration("let",[n.types.variableDeclarator(n.types.cloneNode(r)),n.types.variableDeclarator(t)]),n.types.blockStatement([n.types.variableDeclaration("let",[n.types.variableDeclarator(n.types.cloneNode(_))]),e.node,n.types.expressionStatement(n.types.assignmentExpression("=",n.types.cloneNode(t),n.types.cloneNode(_)))]),n.types.expressionStatement(n.types.assignmentExpression("=",n.types.cloneNode(r),n.types.cloneNode(t)))])}}if(N.size>0){checkPrivateMethodUpdateError(e,N)}e.scope.crawl();return e}function createLocalsAssignment(e,t,r,s,i,a,o,l,c,p){let u,d;const f=[o?createSetFunctionNameCall(c,o):n.types.thisExpression(),s,r];{if(p!=="2023-11"){f.splice(1,2,r,s)}if(p==="2021-12"||p==="2022-03"&&!c.availableHelper("applyDecs2203R")){u=n.types.arrayPattern([...e,...t]);d=n.types.callExpression(c.addHelper(p==="2021-12"?"applyDecs":"applyDecs2203"),f);return n.types.assignmentExpression("=",u,d)}else if(p==="2022-03"){d=n.types.callExpression(c.addHelper("applyDecs2203R"),f)}else if(p==="2023-01"){if(a){f.push(createPrivateBrandCheckClosure(a))}d=n.types.callExpression(c.addHelper("applyDecs2301"),f)}else if(p==="2023-05"){if(a||l||i.value!==0){f.push(i)}if(a){f.push(createPrivateBrandCheckClosure(a))}else if(l){f.push(n.types.unaryExpression("void",n.types.numericLiteral(0)))}if(l)f.push(l);d=n.types.callExpression(c.addHelper("applyDecs2305"),f)}}if(p==="2023-11"){if(a||l||i.value!==0){f.push(i)}if(a){f.push(createPrivateBrandCheckClosure(a))}else if(l){f.push(n.types.unaryExpression("void",n.types.numericLiteral(0)))}if(l)f.push(l);d=n.types.callExpression(c.addHelper("applyDecs2311"),f)}if(e.length>0){if(t.length>0){u=n.types.objectPattern([n.types.objectProperty(n.types.identifier("e"),n.types.arrayPattern(e)),n.types.objectProperty(n.types.identifier("c"),n.types.arrayPattern(t))])}else{u=n.types.arrayPattern(e);d=n.types.memberExpression(d,n.types.identifier("e"),false,false)}}else{u=n.types.arrayPattern(t);d=n.types.memberExpression(d,n.types.identifier("c"),false,false)}return n.types.assignmentExpression("=",u,d)}function isProtoKey(e){return e.type==="Identifier"?e.name==="__proto__":e.value==="__proto__"}function isDecorated(e){return e.decorators&&e.decorators.length>0}function shouldTransformElement(e){switch(e.type){case"ClassAccessorProperty":return true;case"ClassMethod":case"ClassProperty":case"ClassPrivateMethod":case"ClassPrivateProperty":return isDecorated(e);default:return false}}function shouldTransformClass(e){return isDecorated(e)||e.body.body.some(shouldTransformElement)}function NamedEvaluationVisitoryFactory(e,t){function handleComputedProperty(e,t,r){switch(t.type){case"StringLiteral":return n.types.stringLiteral(t.value);case"NumericLiteral":case"BigIntLiteral":{const r=t.value+"";e.get("key").replaceWith(n.types.stringLiteral(r));return n.types.stringLiteral(r)}default:{const s=e.scope.maybeGenerateMemoised(t);e.get("key").replaceWith(n.types.assignmentExpression("=",s,createToPropertyKeyCall(r,t)));return n.types.cloneNode(s)}}}return{VariableDeclarator(r,n){const s=r.node.id;if(s.type==="Identifier"){const a=(0,i.skipTransparentExprWrappers)(r.get("init"));if(e(a)){const e=s.name;t(a,n,e)}}},AssignmentExpression(r,n){const s=r.node.left;if(s.type==="Identifier"){const a=(0,i.skipTransparentExprWrappers)(r.get("right"));if(e(a)){switch(r.node.operator){case"=":case"&&=":case"||=":case"??=":t(a,n,s.name)}}}},AssignmentPattern(r,n){const s=r.node.left;if(s.type==="Identifier"){const a=(0,i.skipTransparentExprWrappers)(r.get("right"));if(e(a)){const e=s.name;t(a,n,e)}}},ObjectExpression(r,s){for(const a of r.get("properties")){if(!a.isObjectProperty())continue;const{node:r}=a;const o=r.key;const l=(0,i.skipTransparentExprWrappers)(a.get("value"));if(e(l)){if(!r.computed){if(!isProtoKey(o)){if(o.type==="Identifier"){t(l,s,o.name)}else{const e=n.types.stringLiteral(o.value+"");t(l,s,e)}}}else{const e=handleComputedProperty(a,o,s);t(l,s,e)}}}},ClassPrivateProperty(r,s){const{node:a}=r;const o=(0,i.skipTransparentExprWrappers)(r.get("value"));if(e(o)){const e=n.types.stringLiteral("#"+a.key.id.name);t(o,s,e)}},ClassAccessorProperty(r,s){const{node:a}=r;const o=a.key;const l=(0,i.skipTransparentExprWrappers)(r.get("value"));if(e(l)){if(!a.computed){if(o.type==="Identifier"){t(l,s,o.name)}else if(o.type==="PrivateName"){const e=n.types.stringLiteral("#"+o.id.name);t(l,s,e)}else{const e=n.types.stringLiteral(o.value+"");t(l,s,e)}}else{const e=handleComputedProperty(r,o,s);t(l,s,e)}}},ClassProperty(r,s){const{node:a}=r;const o=a.key;const l=(0,i.skipTransparentExprWrappers)(r.get("value"));if(e(l)){if(!a.computed){if(o.type==="Identifier"){t(l,s,o.name)}else{const e=n.types.stringLiteral(o.value+"");t(l,s,e)}}else{const e=handleComputedProperty(r,o,s);t(l,s,e)}}}}}function isDecoratedAnonymousClassExpression(e){return e.isClassExpression({id:null})&&shouldTransformClass(e.node)}function generateLetUidIdentifier(e,t){const r=e.generateUidIdentifier(t);e.push({id:r,kind:"let"});return n.types.cloneNode(r)}function _default({assertVersion:e,assumption:t},{loose:s},i,a){var o,l;{if(i==="2023-11"||i==="2023-05"||i==="2023-01"){e("^7.21.0")}else if(i==="2021-12"){e("^7.16.0")}else{e("^7.19.0")}}const c=new WeakSet;const p=(o=t("constantSuper"))!=null?o:s;const u=(l=t("ignoreFunctionLength"))!=null?l:s;const d=NamedEvaluationVisitoryFactory(isDecoratedAnonymousClassExpression,visitClass);function visitClass(e,t,r){var n;if(c.has(e))return;const{node:s}=e;r!=null?r:r=(n=s.id)==null?void 0:n.name;const a=transformClass(e,t,p,u,r,d,i);if(a){c.add(a);return}c.add(e)}return{name:"proposal-decorators",inherits:a,visitor:Object.assign({ExportDefaultDeclaration(e,t){const{declaration:s}=e.node;if((s==null?void 0:s.type)==="ClassDeclaration"&&isDecorated(s)){const a=!s.id;{var i;(i=e.splitExportDeclaration)!=null?i:e.splitExportDeclaration=r(8026).NodePath.prototype.splitExportDeclaration}const o=e.splitExportDeclaration();if(a){visitClass(o,t,n.types.stringLiteral("default"))}}},ExportNamedDeclaration(e){const{declaration:t}=e.node;if((t==null?void 0:t.type)==="ClassDeclaration"&&isDecorated(t)){{var n;(n=e.splitExportDeclaration)!=null?n:e.splitExportDeclaration=r(8026).NodePath.prototype.splitExportDeclaration}e.splitExportDeclaration()}},Class(e,t){visitClass(e,t,undefined)}},d)}}},1409:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.FEATURES=void 0;t.enableFeature=enableFeature;t.isLoose=isLoose;t.shouldTransform=shouldTransform;var n=r(7009);const s=t.FEATURES=Object.freeze({fields:1<<1,privateMethods:1<<2,decorators:1<<3,privateIn:1<<4,staticBlocks:1<<5});const i=new Map([[s.fields,"@babel/plugin-transform-class-properties"],[s.privateMethods,"@babel/plugin-transform-private-methods"],[s.privateIn,"@babel/plugin-transform-private-property-in-object"]]);const a="@babel/plugin-class-features/featuresKey";const o="@babel/plugin-class-features/looseKey";{var l="@babel/plugin-class-features/looseLowPriorityKey/#__internal__@babel/preset-env__please-overwrite-loose-instead-of-throwing"}{var canIgnoreLoose=function(e,t){return!!(e.get(l)&t)}}function enableFeature(e,t,r){if(!hasFeature(e,t)||canIgnoreLoose(e,t)){e.set(a,e.get(a)|t);if(r==="#__internal__@babel/preset-env__prefer-true-but-false-is-ok-if-it-prevents-an-error"){setLoose(e,t,true);e.set(l,e.get(l)|t)}else if(r==="#__internal__@babel/preset-env__prefer-false-but-true-is-ok-if-it-prevents-an-error"){setLoose(e,t,false);e.set(l,e.get(l)|t)}else{setLoose(e,t,r)}}let n;for(const[t,r]of i){if(!hasFeature(e,t))continue;{if(canIgnoreLoose(e,t))continue}const i=isLoose(e,t);if(n===!i){throw new Error("'loose' mode configuration must be the same for @babel/plugin-transform-class-properties, "+"@babel/plugin-transform-private-methods and "+"@babel/plugin-transform-private-property-in-object (when they are enabled)."+"\n\n"+getBabelShowConfigForHint(e))}else{n=i;{var s=r}}}if(n!==undefined){for(const[t,r]of i){if(hasFeature(e,t)&&isLoose(e,t)!==n){setLoose(e,t,n);console.warn(`Though the "loose" option was set to "${!n}" in your @babel/preset-env `+`config, it will not be used for ${r} since the "loose" mode option was set to `+`"${n}" for ${s}.\nThe "loose" option must be the `+`same for @babel/plugin-transform-class-properties, @babel/plugin-transform-private-methods `+`and @babel/plugin-transform-private-property-in-object (when they are enabled): you can `+`silence this warning by explicitly adding\n`+`\t["${r}", { "loose": ${n} }]\n`+`to the "plugins" section of your Babel config.`+"\n\n"+getBabelShowConfigForHint(e))}}}}function getBabelShowConfigForHint(e){let{filename:t}=e.opts;if(!t||t==="unknown"){t="[name of the input file]"}return`If you already set the same 'loose' mode for these plugins in your config, it's possible that they are enabled multiple times with different options.\nYou can re-run Babel with the BABEL_SHOW_CONFIG_FOR environment variable to show the loaded configuration:\n\tnpx cross-env BABEL_SHOW_CONFIG_FOR=${t} <your build command>\nSee https://babeljs.io/docs/configuration#print-effective-configs for more info.`}function hasFeature(e,t){return!!(e.get(a)&t)}function isLoose(e,t){return!!(e.get(o)&t)}function setLoose(e,t,r){if(r)e.set(o,e.get(o)|t);else e.set(o,e.get(o)&~t);{e.set(l,e.get(l)&~t)}}function shouldTransform(e,t){let r=null;let i=null;let a=null;let o=null;let l=null;if((0,n.hasOwnDecorators)(e.node)){r=e.get("decorators.0")}for(const t of e.get("body.body")){if(!r&&(0,n.hasOwnDecorators)(t.node)){r=t.get("decorators.0")}if(!i&&t.isClassProperty()){i=t}if(!a&&t.isClassPrivateProperty()){a=t}if(!o&&t.isClassPrivateMethod!=null&&t.isClassPrivateMethod()){o=t}if(!l&&t.isStaticBlock!=null&&t.isStaticBlock()){l=t}}if(r&&a){throw a.buildCodeFrameError("Private fields in decorated classes are not supported yet.")}if(r&&o){throw o.buildCodeFrameError("Private methods in decorated classes are not supported yet.")}if(r&&!hasFeature(t,s.decorators)){throw e.buildCodeFrameError("Decorators are not enabled."+"\nIf you are using "+'["@babel/plugin-proposal-decorators", { "version": "legacy" }], '+'make sure it comes *before* "@babel/plugin-transform-class-properties" '+"and enable loose mode, like so:\n"+'\t["@babel/plugin-proposal-decorators", { "version": "legacy" }]\n'+'\t["@babel/plugin-transform-class-properties", { "loose": true }]')}if(o&&!hasFeature(t,s.privateMethods)){throw o.buildCodeFrameError("Class private methods are not enabled. "+"Please add `@babel/plugin-transform-private-methods` to your configuration.")}if((i||a)&&!hasFeature(t,s.fields)&&!hasFeature(t,s.privateMethods)){throw e.buildCodeFrameError("Class fields are not enabled. "+"Please add `@babel/plugin-transform-class-properties` to your configuration.")}if(l&&!hasFeature(t,s.staticBlocks)){throw e.buildCodeFrameError("Static class blocks are not enabled. "+"Please add `@babel/plugin-transform-class-static-block` to your configuration.")}if(r||o||l){return true}if((i||a)&&hasFeature(t,s.fields)){return true}return false}},4697:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.buildCheckInRHS=buildCheckInRHS;t.buildFieldsInitNodes=buildFieldsInitNodes;t.buildPrivateNamesMap=buildPrivateNamesMap;t.buildPrivateNamesNodes=buildPrivateNamesNodes;t.privateNameVisitorFactory=privateNameVisitorFactory;t.transformPrivateNamesUsage=transformPrivateNamesUsage;var n=r(2358);var s=r(8026);var i=r(6721);var a=r(3034);var o=r(582);var l=r(344);var c=r(9102);var p=r(1238);{var newHelpers=e=>{return e.availableHelper("classPrivateFieldGet2")}}function buildPrivateNamesMap(e,t,r,s){const i=new Map;let a;for(const o of r){if(o.isPrivate()){const{name:r}=o.node.key.id;let l=i.get(r);if(!l){const n=!o.isProperty();const c=o.node.static;let p=false;let u;if(!t&&newHelpers(s)&&n&&!c){p=!!a;a!=null?a:a=o.scope.generateUidIdentifier(`${e}_brand`);u=a}else{u=o.scope.generateUidIdentifier(r)}l={id:u,static:c,method:n,initAdded:p};i.set(r,l)}if(o.isClassPrivateMethod()){if(o.node.kind==="get"){const{body:e}=o.node.body;let t;if(e.length===1&&n.types.isReturnStatement(t=e[0])&&n.types.isCallExpression(t=t.argument)&&t.arguments.length===1&&n.types.isThisExpression(t.arguments[0])&&n.types.isIdentifier(t=t.callee)){l.getId=n.types.cloneNode(t);l.getterDeclared=true}else{l.getId=o.scope.generateUidIdentifier(`get_${r}`)}}else if(o.node.kind==="set"){const{params:e}=o.node;const{body:t}=o.node.body;let s;if(t.length===1&&n.types.isExpressionStatement(s=t[0])&&n.types.isCallExpression(s=s.expression)&&s.arguments.length===2&&n.types.isThisExpression(s.arguments[0])&&n.types.isIdentifier(s.arguments[1],{name:e[0].name})&&n.types.isIdentifier(s=s.callee)){l.setId=n.types.cloneNode(s);l.setterDeclared=true}else{l.setId=o.scope.generateUidIdentifier(`set_${r}`)}}else if(o.node.kind==="method"){l.methodId=o.scope.generateUidIdentifier(r)}}i.set(r,l)}}return i}function buildPrivateNamesNodes(e,t,r,s){const i=[];const a=new Set;for(const[o,c]of e){const{static:e,method:p,getId:u,setId:d}=c;const f=u||d;const h=n.types.cloneNode(c.id);let m;if(t){m=n.types.callExpression(s.addHelper("classPrivateFieldLooseKey"),[n.types.stringLiteral(o)])}else if(r){m=n.types.callExpression(n.types.identifier("Symbol"),[n.types.stringLiteral(o)])}else if(!e){if(a.has(h.name))continue;a.add(h.name);m=n.types.newExpression(n.types.identifier(p&&(!f||newHelpers(s))?"WeakSet":"WeakMap"),[])}if(m){if(!r){(0,l.default)(m)}i.push(n.template.statement.ast`var ${h} = ${m}`)}}return i}function privateNameVisitorFactory(e){const t=s.visitors.environmentVisitor(Object.assign({},e));const r=Object.assign({},e,{Class(e){const{privateNamesMap:n}=this;const s=e.get("body.body");const i=new Map(n);const a=[];for(const e of s){if(!e.isPrivate())continue;const{name:t}=e.node.key.id;i.delete(t);a.push(t)}if(!a.length){return}e.get("body").traverse(t,Object.assign({},this,{redeclared:a}));e.traverse(r,Object.assign({},this,{privateNamesMap:i}));e.skipKey("body")}});return r}const u=privateNameVisitorFactory({PrivateName(e,{noDocumentAll:t}){const{privateNamesMap:r,redeclared:n}=this;const{node:s,parentPath:i}=e;if(!i.isMemberExpression({property:s})&&!i.isOptionalMemberExpression({property:s})){return}const{name:a}=s.id;if(!r.has(a))return;if(n!=null&&n.includes(a))return;this.handle(i,t)}});function unshadow(e,t,r){while((n=t)!=null&&n.hasBinding(e)&&!t.bindingIdentifierEquals(e,r)){var n;t.rename(e);t=t.parent}}function buildCheckInRHS(e,t,r){if(r||!(t.availableHelper!=null&&t.availableHelper("checkInRHS")))return e;return n.types.callExpression(t.addHelper("checkInRHS"),[e])}const d=privateNameVisitorFactory({BinaryExpression(e,{file:t}){const{operator:r,left:s,right:i}=e.node;if(r!=="in")return;if(!n.types.isPrivateName(s))return;const{privateFieldsAsProperties:a,privateNamesMap:o,redeclared:l}=this;const{name:c}=s.id;if(!o.has(c))return;if(l!=null&&l.includes(c))return;unshadow(this.classRef.name,e.scope,this.innerBinding);if(a){const{id:r}=o.get(c);e.replaceWith(n.template.expression.ast` |
| 39 | Object.prototype.hasOwnProperty.call(${buildCheckInRHS(i,t)}, ${n.types.cloneNode(r)}) |
no test coverage detected