react-code-locator 0.2.1 → 0.2.2

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/webpack.cjs CHANGED
@@ -41,5 +41,5 @@ function _markReactElementSource(element, source) {
41
41
  }
42
42
  return element;
43
43
  }
44
- `;return go.parse(e,{ecmaVersion:"latest",sourceType:"module"}).body[0]}function wl(e,t){return{type:"CallExpression",callee:{type:"Identifier",name:"_markReactElementSource"},arguments:[e,{type:"Literal",value:t}],optional:!1}}function vo(e,t){let{filename:s,projectRoot:a=process.cwd(),injectJsxSource:o=!0,injectComponentSource:c=!0}=t,p;try{p=gl(s).parse(e,{ecmaVersion:"latest",sourceType:"module",locations:!0})}catch{return null}let g=!1,b=!1,l=new Set,P=[];if(lo(p,{enter(_,B){if(o&&_.type==="CallExpression"&&bl(_)){let w=_.loc;w&&(this.replace(wl(_,Ws(s,w.start,a))),b=!0,g=!0)}if(c&&_.type==="FunctionDeclaration"){let w=_.id?.name;w&&mo(w)&&!l.has(w)&&_.loc&&(P.push({node:_,parent:B,assignment:xo(w,Ws(s,_.loc.start,a))}),l.add(w),g=!0)}if(c&&_.type==="VariableDeclarator"){let w=_.id;if(w.type==="Identifier"&&mo(w.name)&&!l.has(w.name)){let E=_.init;if(E&&Sl(E)){let D=_.loc||E.loc;D&&(P.push({node:_,parent:B,assignment:xo(w.name,Ws(s,D.start,a))}),l.add(w.name),g=!0)}}}}}),!g)return null;if(b){let _=Cl();p.body.some(w=>w.type==="FunctionDeclaration"&&w.id?.name==="_markReactElementSource")||p.body.unshift(_)}for(let{node:_,parent:B,assignment:w}of P.reverse())if(B?.type==="Program"){let E=p.body.indexOf(_);E!==-1&&p.body.splice(E+1,0,w)}else if(B?.type==="ExportNamedDeclaration"){let E=p.body.find(D=>D.type==="ExportNamedDeclaration"&&D.declaration===B);E&&p.body.splice(p.body.indexOf(E)+1,0,w)}else B?.type==="ExportDefaultDeclaration"&&p.body.splice(p.body.indexOf(B)+1,0,w);return{code:ho(p,{generator:vl})}}var _l="virtual:react-code-locator/client",jp=`\0${_l}`;var Al=/\.([jt]sx)$/,El=/node_modules/;function kl(e,t,s){let a=Array.isArray(t)?t:[t];return(Array.isArray(s)?s:[s]).some(c=>c.test(e))?!1:a.some(c=>c.test(e))}var li=Ya((e={})=>{let{include:t=Al,exclude:s=El,projectRoot:a=process.cwd(),injectComponentSource:o=!0,injectJsxSource:c=!0}=e;return{name:"react-code-locator",transform(p,g){return process.env.NODE_ENV!=="development"||!kl(g,t,s)?null:vo(p,{filename:g,projectRoot:a,injectComponentSource:o,injectJsxSource:c})}}}),Gs=li;var $p=li.webpack,zp=li.rollup,Kp=li.esbuild,Xp=li.rspack;var Tl=Gs.webpack,Pl=Gs.webpack;0&&(module.exports={webpackPlugin});
44
+ `;return go.parse(e,{ecmaVersion:"latest",sourceType:"module"}).body[0]}function wl(e,t){return{type:"CallExpression",callee:{type:"Identifier",name:"_markReactElementSource"},arguments:[e,{type:"Literal",value:t}],optional:!1}}function vo(e,t){let{filename:s,projectRoot:a=process.cwd(),injectJsxSource:o=!0,injectComponentSource:c=!0}=t,p;try{p=gl(s).parse(e,{ecmaVersion:"latest",sourceType:"module",locations:!0})}catch{return null}let g=!1,b=!1,l=new Set,P=[];if(lo(p,{enter(_,B){if(o&&_.type==="CallExpression"&&bl(_)){let w=_.loc;w&&(this.replace(wl(_,Ws(s,w.start,a))),this.skip(),b=!0,g=!0)}if(c&&_.type==="FunctionDeclaration"){let w=_.id?.name;w&&mo(w)&&!l.has(w)&&_.loc&&(P.push({node:_,parent:B,assignment:xo(w,Ws(s,_.loc.start,a))}),l.add(w),g=!0)}if(c&&_.type==="VariableDeclarator"){let w=_.id;if(w.type==="Identifier"&&mo(w.name)&&!l.has(w.name)){let E=_.init;if(E&&Sl(E)){let D=_.loc||E.loc;D&&(P.push({node:_,parent:B,assignment:xo(w.name,Ws(s,D.start,a))}),l.add(w.name),g=!0)}}}}}),!g)return null;if(b){let _=Cl();p.body.some(w=>w.type==="FunctionDeclaration"&&w.id?.name==="_markReactElementSource")||p.body.unshift(_)}for(let{node:_,parent:B,assignment:w}of P.reverse())if(B?.type==="Program"){let E=p.body.indexOf(_);E!==-1&&p.body.splice(E+1,0,w)}else if(B?.type==="ExportNamedDeclaration"){let E=p.body.find(D=>D.type==="ExportNamedDeclaration"&&D.declaration===B);E&&p.body.splice(p.body.indexOf(E)+1,0,w)}else B?.type==="ExportDefaultDeclaration"&&p.body.splice(p.body.indexOf(B)+1,0,w);return{code:ho(p,{generator:vl})}}var _l="virtual:react-code-locator/client",jp=`\0${_l}`;var Al=/\.([jt]sx)$/,El=/node_modules/;function kl(e,t,s){let a=Array.isArray(t)?t:[t];return(Array.isArray(s)?s:[s]).some(c=>c.test(e))?!1:a.some(c=>c.test(e))}var li=Ya((e={})=>{let{include:t=Al,exclude:s=El,projectRoot:a=process.cwd(),injectComponentSource:o=!0,injectJsxSource:c=!0}=e;return{name:"react-code-locator",transform(p,g){return process.env.NODE_ENV!=="development"||!kl(g,t,s)?null:vo(p,{filename:g,projectRoot:a,injectComponentSource:o,injectJsxSource:c})}}}),Gs=li;var $p=li.webpack,zp=li.rollup,Kp=li.esbuild,Xp=li.rspack;var Tl=Gs.webpack,Pl=Gs.webpack;0&&(module.exports={webpackPlugin});
45
45
  //# sourceMappingURL=webpack.cjs.map