react-native-worklets 0.2.0 → 0.3.0-nightly-20250424-43520c73e

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.
Files changed (38) hide show
  1. package/RNWorklets.podspec +12 -3
  2. package/android/CMakeLists.txt +87 -7
  3. package/android/build.gradle +23 -9
  4. package/apple/worklets/apple/SlowAnimations.mm +1 -3
  5. package/apple/worklets/apple/WorkletsModule.h +4 -1
  6. package/apple/worklets/apple/WorkletsModule.mm +19 -2
  7. package/lib/module/WorkletsError.js +19 -5
  8. package/lib/module/WorkletsError.js.map +1 -1
  9. package/lib/module/WorkletsModule/NativeWorklets.js +8 -1
  10. package/lib/module/WorkletsModule/NativeWorklets.js.map +1 -1
  11. package/lib/module/errors.js +0 -28
  12. package/lib/module/errors.js.map +1 -1
  13. package/lib/module/index.js +0 -1
  14. package/lib/module/index.js.map +1 -1
  15. package/lib/module/privateGlobals.d.js +1 -0
  16. package/lib/module/privateGlobals.d.js.map +1 -1
  17. package/lib/module/runtimes.js +2 -2
  18. package/lib/module/runtimes.js.map +1 -1
  19. package/lib/module/threads.js +2 -2
  20. package/lib/module/threads.js.map +1 -1
  21. package/lib/typescript/WorkletsError.d.ts +13 -1
  22. package/lib/typescript/WorkletsError.d.ts.map +1 -1
  23. package/lib/typescript/WorkletsModule/NativeWorklets.d.ts.map +1 -1
  24. package/lib/typescript/errors.d.ts +0 -11
  25. package/lib/typescript/errors.d.ts.map +1 -1
  26. package/lib/typescript/index.d.ts +0 -2
  27. package/lib/typescript/index.d.ts.map +1 -1
  28. package/package.json +10 -10
  29. package/plugin/index.js +1665 -2
  30. package/scripts/worklets_utils.rb +6 -1
  31. package/src/WorkletsError.ts +27 -7
  32. package/src/WorkletsModule/NativeWorklets.ts +9 -1
  33. package/src/errors.ts +0 -40
  34. package/src/index.ts +0 -2
  35. package/src/privateGlobals.d.ts +3 -0
  36. package/src/runtimes.ts +2 -2
  37. package/src/threads.ts +2 -2
  38. package/android/src/main/cpp/worklets/CMakeLists.txt +0 -85
package/plugin/index.js CHANGED
@@ -1,3 +1,1666 @@
1
- "use strict";var st=Object.create;var ge=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var ct=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var p=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var dt=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of lt(t))!ut.call(e,n)&&n!==r&&ge(e,n,{get:()=>t[n],enumerable:!(i=at(t,n))||i.enumerable});return e};var A=(e,t,r)=>(r=e!=null?st(ct(e)):{},dt(t||!e||!e.__esModule?ge(r,"default",{value:e,enumerable:!0}):r,e));var Oe=p(w=>{"use strict";Object.defineProperty(w,"__esModule",{value:!0});w.isGestureObjectEventCallbackMethod=w.isGestureHandlerEventCallback=w.gestureHandlerBuilderMethods=void 0;var I=require("@babel/types"),ft=new Set(["Tap","Pan","Pinch","Rotation","Fling","LongPress","ForceTouch","Native","Manual","Race","Simultaneous","Exclusive","Hover"]);w.gestureHandlerBuilderMethods=new Set(["onBegin","onStart","onEnd","onFinalize","onUpdate","onChange","onTouchesDown","onTouchesMove","onTouchesUp","onTouchesCancelled"]);function pt(e){return(0,I.isCallExpression)(e.parent)&&(0,I.isExpression)(e.parent.callee)&&_e(e.parent.callee)}w.isGestureHandlerEventCallback=pt;function _e(e){return(0,I.isMemberExpression)(e)&&(0,I.isIdentifier)(e.property)&&w.gestureHandlerBuilderMethods.has(e.property.name)&&ve(e.object)}w.isGestureObjectEventCallbackMethod=_e;function ve(e){return!!(mt(e)||(0,I.isCallExpression)(e)&&(0,I.isMemberExpression)(e.callee)&&ve(e.callee.object))}function mt(e){return(0,I.isCallExpression)(e)&&(0,I.isMemberExpression)(e.callee)&&(0,I.isIdentifier)(e.callee.object)&&e.callee.object.name==="Gesture"&&(0,I.isIdentifier)(e.callee.property)&&ft.has(e.callee.property.name)}});var Ie=p(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.isLayoutAnimationCallback=void 0;var S=require("@babel/types"),bt=new Set(["BounceIn","BounceInDown","BounceInLeft","BounceInRight","BounceInUp","BounceOut","BounceOutDown","BounceOutLeft","BounceOutRight","BounceOutUp","FadeIn","FadeInDown","FadeInLeft","FadeInRight","FadeInUp","FadeOut","FadeOutDown","FadeOutLeft","FadeOutRight","FadeOutUp","FlipInEasyX","FlipInEasyY","FlipInXDown","FlipInXUp","FlipInYLeft","FlipInYRight","FlipOutEasyX","FlipOutEasyY","FlipOutXDown","FlipOutXUp","FlipOutYLeft","FlipOutYRight","LightSpeedInLeft","LightSpeedInRight","LightSpeedOutLeft","LightSpeedOutRight","PinwheelIn","PinwheelOut","RollInLeft","RollInRight","RollOutLeft","RollOutRight","RotateInDownLeft","RotateInDownRight","RotateInUpLeft","RotateInUpRight","RotateOutDownLeft","RotateOutDownRight","RotateOutUpLeft","RotateOutUpRight","SlideInDown","SlideInLeft","SlideInRight","SlideInUp","SlideOutDown","SlideOutLeft","SlideOutRight","SlideOutUp","StretchInX","StretchInY","StretchOutX","StretchOutY","ZoomIn","ZoomInDown","ZoomInEasyDown","ZoomInEasyUp","ZoomInLeft","ZoomInRight","ZoomInRotate","ZoomInUp","ZoomOut","ZoomOutDown","ZoomOutEasyDown","ZoomOutEasyUp","ZoomOutLeft","ZoomOutRight","ZoomOutRotate","ZoomOutUp"]),yt=new Set(["Layout","LinearTransition","SequencedTransition","FadingTransition","JumpingTransition","CurvedTransition","EntryExitTransition"]),he=new Set([...bt,...yt]),kt=new Set(["build","duration","delay","getDuration","randomDelay","getDelay","getDelayFunction"]),gt=new Set(["easing","rotate","springify","damping","mass","stiffness","overshootClamping","restDisplacementThreshold","restSpeedThreshold","withInitialValues","getAnimationAndConfig"]),_t=new Set(["easingX","easingY","easingWidth","easingHeight","entering","exiting","reverse"]),vt=new Set([...kt,...gt,..._t]),Ot=new Set(["withCallback"]);function ht(e){return(0,S.isCallExpression)(e.parent)&&(0,S.isExpression)(e.parent.callee)&&Et(e.parent.callee)}X.isLayoutAnimationCallback=ht;function Et(e){return(0,S.isMemberExpression)(e)&&(0,S.isIdentifier)(e.property)&&Ot.has(e.property.name)&&Ee(e.object)}function Ee(e){return(0,S.isIdentifier)(e)&&he.has(e.name)?!0:!!((0,S.isNewExpression)(e)&&(0,S.isIdentifier)(e.callee)&&he.has(e.callee.name)||(0,S.isCallExpression)(e)&&(0,S.isMemberExpression)(e.callee)&&(0,S.isIdentifier)(e.callee.property)&&vt.has(e.callee.property.name)&&Ee(e.callee.object))}});var x=p(b=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0});b.workletClassFactorySuffix=b.isWorkletizableObjectNode=b.isWorkletizableObjectPath=b.isWorkletizableFunctionNode=b.isWorkletizableFunctionPath=b.WorkletizableObject=b.WorkletizableFunction=void 0;var H=require("@babel/types");b.WorkletizableFunction="FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod";b.WorkletizableObject="ObjectExpression";function It(e){return e.isFunctionDeclaration()||e.isFunctionExpression()||e.isArrowFunctionExpression()||e.isObjectMethod()}b.isWorkletizableFunctionPath=It;function St(e){return(0,H.isFunctionDeclaration)(e)||(0,H.isFunctionExpression)(e)||(0,H.isArrowFunctionExpression)(e)||(0,H.isObjectMethod)(e)}b.isWorkletizableFunctionNode=St;function xt(e){return e.isObjectExpression()}b.isWorkletizableObjectPath=xt;function Wt(e){return(0,H.isObjectExpression)(e)}b.isWorkletizableObjectNode=Wt;b.workletClassFactorySuffix="__classFactory"});var q=p(P=>{"use strict";Object.defineProperty(P,"__esModule",{value:!0});P.replaceWithFactoryCall=P.isRelease=void 0;var Z=require("@babel/types");function wt(){var e,t;let r=/(prod|release|stag[ei])/i;return!!(!((e=process.env.BABEL_ENV)===null||e===void 0)&&e.match(r)||!((t=process.env.NODE_ENV)===null||t===void 0)&&t.match(r))}P.isRelease=wt;function Ct(e,t,r){if(!t||!jt(e))e.replaceWith(r);else{let i=(0,Z.variableDeclaration)("const",[(0,Z.variableDeclarator)((0,Z.identifier)(t),r)]);e.replaceWith(i)}}P.replaceWithFactoryCall=Ct;function jt(e){return(0,Z.isScopable)(e.parent)||(0,Z.isExportNamedDeclaration)(e.parent)}});var le=p(g=>{"use strict";Object.defineProperty(g,"__esModule",{value:!0});g.addCustomGlobals=g.initializeGlobals=g.globals=g.defaultGlobals=g.initializeState=void 0;var Ft=["globalThis","Infinity","NaN","undefined","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape","Object","Function","Boolean","Symbol","Error","AggregateError","EvalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError","InternalError","Number","BigInt","Math","Date","String","RegExp","Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","BigInt64Array","BigUint64Array","Float32Array","Float64Array","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Atomics","JSON","WeakRef","FinalizationRegistry","Iterator","AsyncIterator","Promise","GeneratorFunction","AsyncGeneratorFunction","Generator","AsyncGenerator","AsyncFunction","Reflect","Proxy","Intl","null","this","global","window","globalThis","console","performance","queueMicrotask","requestAnimationFrame","setImmediate","arguments","HermesInternal","ReanimatedError","_WORKLET","WorkletsError","__workletsLoggerConfig"],Dt=["_IS_FABRIC","_log","_toString","_scheduleHostFunctionOnJS","_scheduleRemoteFunctionOnJS","_scheduleOnRuntime","_makeShareableClone","_updateProps","_measure","_dispatchCommand","_setGestureState","_notifyAboutProgress","_notifyAboutEnd","_runOnUIQueue","_getAnimationTimestamp"];function Mt(e){e.workletNumber=1,e.classesToWorkletize=[],Se(),xe(e)}g.initializeState=Mt;g.defaultGlobals=new Set(Ft.concat(Dt));function Se(){g.globals=new Set(g.defaultGlobals)}g.initializeGlobals=Se;function xe(e){e.opts&&Array.isArray(e.opts.globals)&&e.opts.globals.forEach(t=>{g.globals.add(t)})}g.addCustomGlobals=xe});var $=p(z=>{"use strict";var Rt=z&&z.__rest||function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]]);return r};Object.defineProperty(z,"__esModule",{value:!0});z.workletTransformSync=void 0;var At=require("@babel/core");function Pt(e,t){let{extraPlugins:r=[],extraPresets:i=[]}=t,n=Rt(t,["extraPlugins","extraPresets"]);return(0,At.transformSync)(e,Object.assign(Object.assign({},n),{plugins:[...zt,...r],presets:[...qt,...i]}))}z.workletTransformSync=Pt;var qt=[require.resolve("@babel/preset-typescript")],zt=[]});var Ce=p(v=>{"use strict";var Lt=v&&v.__createBinding||(Object.create?function(e,t,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){i===void 0&&(i=r),e[i]=t[r]}),Tt=v&&v.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),We=v&&v.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&Lt(t,e,r);return Tt(t,e),t},Nt=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(v,"__esModule",{value:!0});v.buildWorkletString=void 0;var we=require("@babel/core"),Bt=Nt(require("@babel/generator")),u=require("@babel/types"),V=require("assert"),Ut=We(require("convert-source-map")),Gt=We(require("fs")),Ht=$(),Zt=x(),Vt=q(),Jt="mock source map";function Xt(e,t,r,i,n){var s;$t(e,i);let l=e.program.body.find(_=>(0,u.isFunctionDeclaration)(_))||e.program.body.find(_=>(0,u.isExpressionStatement)(_))||void 0;(0,V.strict)(l,"[Reanimated] `draftExpression` is undefined.");let a=(0,u.isFunctionDeclaration)(l)?l:l.expression;(0,V.strict)("params"in a,"'params' property is undefined in 'expression'"),(0,V.strict)((0,u.isBlockStatement)(a.body),"[Reanimated] `expression.body` is not a `BlockStatement`");let y=new Set;(0,we.traverse)(e,{NewExpression(_){if(!(0,u.isIdentifier)(_.node.callee))return;let W=_.node.callee.name;if(!r.some(J=>J.name===W)||y.has(W))return;let R=r.findIndex(J=>J.name===W);r.splice(R,1);let oe=W+Zt.workletClassFactorySuffix;r.push((0,u.identifier)(oe)),(0,u.assertBlockStatement)(a.body),a.body.body.unshift((0,u.variableDeclaration)("const",[(0,u.variableDeclarator)((0,u.identifier)(W),(0,u.callExpression)((0,u.identifier)(oe),[]))])),y.add(W)}});let d=(0,u.functionExpression)((0,u.identifier)(i),a.params,a.body,a.generator,a.async),F=(0,Bt.default)(d).code;(0,V.strict)(n,"[Reanimated] `inputMap` is undefined.");let E=!((0,Vt.isRelease)()||t.opts.disableSourceMaps);if(E){n.sourcesContent=[];for(let _ of n.sources)n.sourcesContent.push(Gt.readFileSync(_).toString("utf-8"))}let M=(0,Ht.workletTransformSync)(F,{filename:t.file.opts.filename,extraPlugins:[er(r),...(s=t.opts.extraPlugins)!==null&&s!==void 0?s:[]],extraPresets:t.opts.extraPresets,compact:!0,sourceMaps:E,inputSourceMap:n,ast:!1,babelrc:!1,configFile:!1,comments:!1});(0,V.strict)(M,"[Reanimated] `transformed` is null.");let D;return E&&(Yt()?D=Jt:(D=Ut.fromObject(M.map).toObject(),delete D.sourcesContent)),[M.code,JSON.stringify(D)]}v.buildWorkletString=Xt;function $t(e,t){(0,we.traverse)(e,{FunctionExpression(r){if(!r.node.id){r.stop();return}let i=r.node.id.name;r.scope.rename(i,t)}})}function Yt(){return process.env.REANIMATED_JEST_SHOULD_MOCK_SOURCE_MAP==="1"}function Kt(e,t,r){t.length===0||!(0,u.isProgram)(e.parent)||(0,u.isExpression)(e.node.body)||e.node.body.body.unshift(r)}function Qt(e){var t;(0,u.isProgram)(e.parent)&&!(0,u.isArrowFunctionExpression)(e.node)&&!(0,u.isObjectMethod)(e.node)&&e.node.id&&e.scope.parent&&((t=e.scope.parent.bindings[e.node.id.name])===null||t===void 0?void 0:t.references)>0&&e.node.body.body.unshift((0,u.variableDeclaration)("const",[(0,u.variableDeclarator)((0,u.identifier)(e.node.id.name),(0,u.memberExpression)((0,u.thisExpression)(),(0,u.identifier)("_recur")))]))}function er(e){let t=(0,u.variableDeclaration)("const",[(0,u.variableDeclarator)((0,u.objectPattern)(e.map(r=>(0,u.objectProperty)((0,u.identifier)(r.name),(0,u.identifier)(r.name),!1,!0))),(0,u.memberExpression)((0,u.thisExpression)(),(0,u.identifier)("__closure")))]);return{visitor:{"FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod":r=>{Kt(r,e,t),Qt(r)}}}}});var De=p(L=>{"use strict";var tr=L&&L.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(L,"__esModule",{value:!0});L.makeWorkletFactory=void 0;var rr=require("@babel/core"),nr=tr(require("@babel/generator")),o=require("@babel/types"),C=require("assert"),Fe=require("path"),ir=le(),or=$(),je=x(),ce=q(),sr=Ce(),ar=require("../package.json").version,lr="x.y.z";function cr(e,t){var r;ur(e),(0,C.strict)(t.file.opts.filename,"[Reanimated] `state.file.opts.filename` is undefined.");let i=(0,nr.default)(e.node,{sourceMaps:!0,sourceFileName:t.file.opts.filename});i.code="("+(e.isObjectMethod()?"function ":"")+i.code+`
2
- )`;let n=(0,or.workletTransformSync)(i.code,{extraPlugins:[...br,...(r=t.opts.extraPlugins)!==null&&r!==void 0?r:[]],extraPresets:t.opts.extraPresets,filename:t.file.opts.filename,ast:!0,babelrc:!1,configFile:!1,inputSourceMap:i.map});(0,C.strict)(n,"[Reanimated] `transformed` is undefined."),(0,C.strict)(n.ast,"[Reanimated] `transformed.ast` is undefined.");let s=mr(n.ast,e),l=(0,o.cloneNode)(e.node),a=(0,o.isBlockStatement)(l.body)?(0,o.functionExpression)(null,l.params,l.body,l.generator,l.async):l,{workletName:y,reactName:d}=pr(e,t),[F,E]=(0,sr.buildWorkletString)(n.ast,t,s,y,n.map);(0,C.strict)(F,"[Reanimated] `funString` is undefined.");let M=fr(F),D=1;s.length>0&&(D-=s.length+2);let _=e.parentPath.isProgram()?e:e.findParent(k=>{var se,ae;return(ae=(se=k.parentPath)===null||se===void 0?void 0:se.isProgram())!==null&&ae!==void 0?ae:!1});(0,C.strict)(_,"[Reanimated] `pathForStringDefinitions` is null."),(0,C.strict)(_.parentPath,"[Reanimated] `pathForStringDefinitions.parentPath` is null.");let W=_.parentPath.scope.generateUidIdentifier(`worklet_${M}_init_data`),R=(0,o.objectExpression)([(0,o.objectProperty)((0,o.identifier)("code"),(0,o.stringLiteral)(F))]);if(!(0,ce.isRelease)()){let k=t.file.opts.filename;t.opts.relativeSourceLocation&&(k=(0,Fe.relative)(t.cwd,k),E=E==null?void 0:E.replace(t.file.opts.filename,k)),R.properties.push((0,o.objectProperty)((0,o.identifier)("location"),(0,o.stringLiteral)(k)))}E&&R.properties.push((0,o.objectProperty)((0,o.identifier)("sourceMap"),(0,o.stringLiteral)(E))),!(0,ce.isRelease)()&&R.properties.push((0,o.objectProperty)((0,o.identifier)("version"),(0,o.stringLiteral)(dr()?lr:ar)));let ke=!t.opts.omitNativeOnlyData;ke&&_.insertBefore((0,o.variableDeclaration)("const",[(0,o.variableDeclarator)(W,R)])),(0,C.strict)(!(0,o.isFunctionDeclaration)(a),"[Reanimated] `funExpression` is a `FunctionDeclaration`."),(0,C.strict)(!(0,o.isObjectMethod)(a),"[Reanimated] `funExpression` is an `ObjectMethod`.");let G=[(0,o.variableDeclaration)("const",[(0,o.variableDeclarator)((0,o.identifier)(d),a)]),(0,o.expressionStatement)((0,o.assignmentExpression)("=",(0,o.memberExpression)((0,o.identifier)(d),(0,o.identifier)("__closure"),!1),(0,o.objectExpression)(s.map(k=>k.name.endsWith(je.workletClassFactorySuffix)?(0,o.objectProperty)((0,o.identifier)(k.name),(0,o.memberExpression)((0,o.identifier)(k.name.slice(0,k.name.length-je.workletClassFactorySuffix.length)),(0,o.identifier)(k.name))):(0,o.objectProperty)((0,o.identifier)(k.name),k,!1,!0))))),(0,o.expressionStatement)((0,o.assignmentExpression)("=",(0,o.memberExpression)((0,o.identifier)(d),(0,o.identifier)("__workletHash"),!1),(0,o.numericLiteral)(M)))];return ke&&G.push((0,o.expressionStatement)((0,o.assignmentExpression)("=",(0,o.memberExpression)((0,o.identifier)(d),(0,o.identifier)("__initData"),!1),W))),(0,ce.isRelease)()||(G.unshift((0,o.variableDeclaration)("const",[(0,o.variableDeclarator)((0,o.identifier)("_e"),(0,o.arrayExpression)([(0,o.newExpression)((0,o.memberExpression)((0,o.identifier)("global"),(0,o.identifier)("Error")),[]),(0,o.numericLiteral)(D),(0,o.numericLiteral)(-27)]))])),G.push((0,o.expressionStatement)((0,o.assignmentExpression)("=",(0,o.memberExpression)((0,o.identifier)(d),(0,o.identifier)("__stackDetails"),!1),(0,o.identifier)("_e"))))),G.push((0,o.returnStatement)((0,o.identifier)(d))),(0,o.functionExpression)(void 0,[],(0,o.blockStatement)(G))}L.makeWorkletFactory=cr;function ur(e){e.traverse({DirectiveLiteral(t){t.node.value==="worklet"&&t.getFunctionParent()===e&&t.parentPath.remove()}})}function dr(){return process.env.REANIMATED_JEST_SHOULD_MOCK_VERSION==="1"}function fr(e){let t=e.length,r=5381,i=52711;for(;t--;){let n=e.charCodeAt(t);r=r*33^n,i=i*33^n}return(r>>>0)*4096+(i>>>0)}function pr(e,t){let r="unknownFile";if(t.file.opts.filename){let l=t.file.opts.filename;r=(0,Fe.basename)(l);let a=l.split("/"),y=a.indexOf("node_modules");y!==-1&&(r=`${a[y+1]}_${r}`)}let i=`${r}${t.workletNumber++}`,n="";(0,o.isObjectMethod)(e.node)&&(0,o.isIdentifier)(e.node.key)?n=e.node.key.name:((0,o.isFunctionDeclaration)(e.node)||(0,o.isFunctionExpression)(e.node))&&(0,o.isIdentifier)(e.node.id)&&(n=e.node.id.name);let s=n?(0,o.toIdentifier)(`${n}_${i}`):(0,o.toIdentifier)(i);return n=n||(0,o.toIdentifier)(i),{workletName:s,reactName:n}}function mr(e,t){let r=new Map,i=new Map;return(0,rr.traverse)(e,{Identifier(n){if(!n.isReferencedIdentifier())return;let s=n.node.name;if(ir.globals.has(s)||"id"in t.node&&t.node.id&&t.node.id.name===s)return;let l=n.parent;if((0,o.isMemberExpression)(l)&&l.property===n.node&&!l.computed||(0,o.isObjectProperty)(l)&&(0,o.isObjectExpression)(n.parentPath.parent)&&n.node!==l.value)return;let a=n.scope;for(;a!=null;){if(a.bindings[s]!=null)return;a=a.parent}r.set(s,n.node),i.set(s,!1)}}),t.traverse({Identifier(n){if(!n.isReferencedIdentifier())return;let s=r.get(n.node.name);!s||i.get(n.node.name)||(s.loc=n.node.loc,i.set(n.node.name,!0))}}),Array.from(r.values())}var br=[require.resolve("@babel/plugin-transform-shorthand-properties"),require.resolve("@babel/plugin-transform-arrow-functions"),require.resolve("@babel/plugin-transform-optional-chaining"),require.resolve("@babel/plugin-transform-nullish-coalescing-operator"),[require.resolve("@babel/plugin-transform-template-literals"),{loose:!0}]]});var Me=p(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.makeWorkletFactoryCall=void 0;var yr=require("@babel/types"),kr=De();function gr(e,t){let r=(0,kr.makeWorkletFactory)(e,t),i=(0,yr.callExpression)(r,[]);return _r(e,i),i}Y.makeWorkletFactoryCall=gr;function _r(e,t){let r=e.node.loc;r&&(t.callee.loc={filename:r.filename,identifierName:r.identifierName,start:r.start,end:r.start})}});var K=p(j=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});j.substituteObjectMethodWithObjectProperty=j.processWorklet=j.processIfWithWorkletDirective=void 0;var ue=require("@babel/types"),vr=x(),Or=q(),hr=Me();function Re(e,t){return!(0,ue.isBlockStatement)(e.node.body)||!Er(e.node.body.directives)?!1:(Ae(e,t),!0)}j.processIfWithWorkletDirective=Re;function Ae(e,t){t.opts.processNestedWorklets&&e.traverse({[vr.WorkletizableFunction](i,n){Re(i,n)}},t);let r=(0,hr.makeWorkletFactoryCall)(e,t);Ir(e,r)}j.processWorklet=Ae;function Er(e){return e.some(t=>(0,ue.isDirectiveLiteral)(t.value)&&t.value.value==="worklet")}function Ir(e,t){var r;if(e.isObjectMethod())Pe(e,t);else{let i="id"in e.node?(r=e.node.id)===null||r===void 0?void 0:r.name:void 0;(0,Or.replaceWithFactoryCall)(e,i,t)}}function Pe(e,t){let r=(0,ue.objectProperty)(e.node.key,t);e.replaceWith(r)}j.substituteObjectMethodWithObjectProperty=Pe});var ze=p(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.processWorkletizableObject=void 0;var Sr=x(),qe=K();function xr(e,t){let r=e.get("properties");for(let i of r)if(i.isObjectMethod())(0,qe.processWorklet)(i,t);else if(i.isObjectProperty()){let n=i.get("value");(0,Sr.isWorkletizableFunctionPath)(n)&&(0,qe.processWorklet)(n,t)}else throw new Error(`[Reanimated] '${i.type}' as to-be workletized argument is not supported for object hooks.`)}Q.processWorkletizableObject=xr});var Le=p(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.findReferencedWorklet=void 0;var T=x();function de(e,t,r){let i=e.node.name,s=e.scope.getBinding(i);return s?t&&s.path.isFunctionDeclaration()?s.path:s.constant?Wr(s,t,r):wr(s,t,r):void 0}ee.findReferencedWorklet=de;function Wr(e,t,r){let i=e.path;if(!i.isVariableDeclarator())return;let n=i.get("init");if(t&&(0,T.isWorkletizableFunctionPath)(n)||r&&(0,T.isWorkletizableObjectPath)(n))return n;if(n.isIdentifier()&&n.isReferencedIdentifier())return de(n,t,r)}function wr(e,t,r){let i=e.constantViolations.reverse().find(s=>s.isAssignmentExpression()&&(t&&(0,T.isWorkletizableFunctionPath)(s.get("right"))||r&&(0,T.isWorkletizableObjectPath)(s.get("right"))));if(!i||!i.isAssignmentExpression())return;let n=i.get("right");if(t&&(0,T.isWorkletizableFunctionPath)(n)||r&&(0,T.isWorkletizableObjectPath)(n))return n;if(n.isIdentifier()&&n.isReferencedIdentifier())return de(n,t,r)}});var He=p(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.processCalleesAutoworkletizableCallbacks=N.processIfAutoworkletizableCallback=void 0;var Te=require("@babel/types"),fe=Oe(),Cr=Ie(),jr=ze(),Fr=Le(),te=x(),Ge=K(),Ne=new Set(["useAnimatedGestureHandler","useAnimatedScrollHandler"]),Be=new Set(["useFrameCallback","useAnimatedStyle","useAnimatedProps","createAnimatedPropAdapter","useDerivedValue","useAnimatedScrollHandler","useAnimatedReaction","useWorkletCallback","withTiming","withSpring","withDecay","withRepeat","runOnUI","executeOnUIRuntimeSync"]),Dr=new Map([["useAnimatedGestureHandler",[0]],["useFrameCallback",[0]],["useAnimatedStyle",[0]],["useAnimatedProps",[0]],["createAnimatedPropAdapter",[0]],["useDerivedValue",[0]],["useAnimatedScrollHandler",[0]],["useAnimatedReaction",[0,1]],["useWorkletCallback",[0]],["withTiming",[2]],["withSpring",[2]],["withDecay",[1]],["withRepeat",[3]],["runOnUI",[0]],["executeOnUIRuntimeSync",[0]],...Array.from(fe.gestureHandlerBuilderMethods).map(e=>[e,[0]])]);function Mr(e,t){return(0,fe.isGestureHandlerEventCallback)(e)||(0,Cr.isLayoutAnimationCallback)(e)?((0,Ge.processWorklet)(e,t),!0):!1}N.processIfAutoworkletizableCallback=Mr;function Rr(e,t){let r=(0,Te.isSequenceExpression)(e.node.callee)?e.node.callee.expressions[e.node.callee.expressions.length-1]:e.node.callee,i="name"in r?r.name:"property"in r&&"name"in r.property?r.property.name:void 0;if(i!==void 0){if(Be.has(i)||Ne.has(i)){let n=Be.has(i),s=Ne.has(i),l=Dr.get(i),a=e.get("arguments").filter((y,d)=>l.includes(d));Ue(a,t,n,s)}else if(!(0,Te.isV8IntrinsicIdentifier)(r)&&(0,fe.isGestureObjectEventCallbackMethod)(r)){let n=e.get("arguments");Ue(n,t,!0,!0)}}}N.processCalleesAutoworkletizableCallbacks=Rr;function Ue(e,t,r,i){e.forEach(n=>{let s=Ar(n,r,i);s&&((0,te.isWorkletizableFunctionPath)(s)?(0,Ge.processWorklet)(s,t):(0,te.isWorkletizableObjectPath)(s)&&(0,jr.processWorkletizableObject)(s,t))})}function Ar(e,t,r){if(t&&(0,te.isWorkletizableFunctionPath)(e)||r&&(0,te.isWorkletizableObjectPath)(e))return e;if(e.isIdentifier()&&e.isReferencedIdentifier())return(0,Fr.findReferencedWorklet)(e,t,r)}});var Xe=p(B=>{"use strict";var Ze=B&&B.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(B,"__esModule",{value:!0});B.processIfWorkletClass=void 0;var Pr=Ze(require("@babel/generator")),qr=Ze(require("@babel/traverse")),c=require("@babel/types"),re=require("assert"),zr=$(),Lr=x(),Tr=q(),Ve="__workletClass";function Nr(e,t){return Qr(e,t)?(Jr(e.node.body),Br(e,t),!0):!1}B.processIfWorkletClass=Nr;function Br(e,t){(0,re.strict)(e.node.id);let r=e.node.id.name,i=Ur(e.node,t);Xr(i),Gr(i.program.body),Hr(i.program.body,r),i.program.body.push((0,c.returnStatement)((0,c.identifier)(r)));let n=(0,c.functionExpression)(null,[],(0,c.blockStatement)([...i.program.body])),s=(0,c.callExpression)(n,[]);(0,Tr.replaceWithFactoryCall)(e,r,s)}function Ur(e,t){var r;let i=(0,Pr.default)(e).code,n=(0,zr.workletTransformSync)(i,{extraPlugins:["@babel/plugin-transform-class-properties","@babel/plugin-transform-classes","@babel/plugin-transform-unicode-regex",...(r=t.opts.extraPlugins)!==null&&r!==void 0?r:[]],extraPresets:t.opts.extraPresets,filename:t.file.opts.filename,ast:!0,babelrc:!1,configFile:!1});return(0,re.strict)(n&&n.ast),n.ast}function Gr(e){e.forEach(t=>{if((0,c.isFunctionDeclaration)(t)){let r=(0,c.directive)((0,c.directiveLiteral)("worklet"));t.body.directives.push(r)}})}function Hr(e,t){let r=t+Lr.workletClassFactorySuffix,i=Zr(e,t),s=e[i].declarations[0].init,l=(0,c.functionDeclaration)((0,c.identifier)(r),[],(0,c.blockStatement)([(0,c.variableDeclaration)("const",[(0,c.variableDeclarator)((0,c.identifier)(t),s)]),(0,c.expressionStatement)((0,c.assignmentExpression)("=",(0,c.memberExpression)((0,c.identifier)(t),(0,c.identifier)(r)),(0,c.identifier)(r))),(0,c.returnStatement)((0,c.identifier)(t))],[(0,c.directive)((0,c.directiveLiteral)("worklet"))])),a=(0,c.variableDeclaration)("const",[(0,c.variableDeclarator)((0,c.identifier)(t),(0,c.callExpression)((0,c.identifier)(r),[]))]);e.splice(i,1,l,a)}function Zr(e,t){let r=e.findIndex(i=>(0,c.isVariableDeclaration)(i)&&i.declarations.some(n=>(0,c.isIdentifier)(n.id)&&n.id.name===t));return(0,re.strict)(r>=0),r}function Vr(e){return e.body.some(t=>(0,c.isClassProperty)(t)&&(0,c.isIdentifier)(t.key)&&t.key.name===Ve)}function Jr(e){e.body=e.body.filter(t=>!(0,c.isClassProperty)(t)||!(0,c.isIdentifier)(t.key)||t.key.name!==Ve)}function Xr(e){let t=$r(e),r=Yr(t),i=t.map(a=>a.index),n=r.map(a=>a.index),s=e.program.body,l=[...s];for(let a=0;a<t.length;a++){let y=n[a],d=i[a],F=l[y];s[d]=F}}function $r(e){let t=[];return(0,qr.default)(e,{Program:{enter:r=>{r.get("body").forEach((n,s)=>{var l;let a=n.getBindingIdentifiers();if(!n.isFunctionDeclaration()||!(!((l=n.node.id)===null||l===void 0)&&l.name))return;let y={name:n.node.id.name,index:s,dependencies:new Set};t.push(y),n.traverse({Identifier(d){Kr(d,a,n)&&y.dependencies.add(d.node.name)}})})}}}),t}function Yr(e){let t=[],r=new Set;for(let i of e)Je(i,e,t,r);return t}function Je(e,t,r,i){if(i.has(e.name))throw new Error("Cycle detected. This should never happen.");if(!r.find(n=>n.name===e.name)){i.add(e.name);for(let n of e.dependencies)if(!r.find(s=>s.name===n)){let s=t.find(l=>l.name===n);(0,re.strict)(s),Je(s,t,r,i)}r.push(e),i.delete(e.name)}}function Kr(e,t,r){return e.isReferencedIdentifier()&&!(e.node.name in t)&&!r.scope.hasOwnBinding(e.node.name)&&r.scope.hasReference(e.node.name)}function Qr(e,t){var r;let i=(r=e.node.id)===null||r===void 0?void 0:r.name,n=e.node;if(!i)return!1;let s=Vr(n.body),l=t.classesToWorkletize.some(d=>d.node===n),a=e.parentPath.isProgram()&&t.classesToWorkletize.some(d=>d.name===i);return t.classesToWorkletize=t.classesToWorkletize.filter(d=>d.node!==n&&d.name!==i),s||l||a}});var pe=p(h=>{"use strict";Object.defineProperty(h,"__esModule",{value:!0});h.isContextObject=h.processIfWorkletContextObject=h.contextObjectMarker=void 0;var O=require("@babel/types");h.contextObjectMarker="__workletContextObject";function en(e,t){return $e(e.node)?(rn(e.node),tn(e.node),!0):!1}h.processIfWorkletContextObject=en;function $e(e){return e.properties.some(t=>(0,O.isObjectProperty)(t)&&(0,O.isIdentifier)(t.key)&&t.key.name===h.contextObjectMarker)}h.isContextObject=$e;function tn(e){let t=(0,O.functionExpression)(null,[],(0,O.blockStatement)([(0,O.returnStatement)((0,O.cloneNode)(e))],[(0,O.directive)((0,O.directiveLiteral)("worklet"))]));e.properties.push((0,O.objectProperty)((0,O.identifier)(`${h.contextObjectMarker}Factory`),t))}function rn(e){e.properties=e.properties.filter(t=>!((0,O.isObjectProperty)(t)&&(0,O.isIdentifier)(t.key)&&t.key.name===h.contextObjectMarker))}});var tt=p(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.isImplicitContextObject=U.processIfWorkletFile=void 0;var m=require("@babel/types"),Ye=pe(),Ke=x();function nn(e,t){return e.node.directives.some(r=>r.value.value==="worklet")?(e.node.directives=e.node.directives.filter(r=>r.value.value!=="worklet"),on(e,t),!0):!1}U.processIfWorkletFile=nn;function on(e,t){let r=e.get("body");pn(e.node),r.forEach(i=>{let n=sn(i);me(n,t)})}function sn(e){return e.isExportNamedDeclaration()||e.isExportDefaultDeclaration()?e.get("declaration"):e}function me(e,t){var r;(0,Ke.isWorkletizableFunctionPath)(e)?(e.isArrowFunctionExpression()&&cn(e.node),Qe(e.node.body)):(0,Ke.isWorkletizableObjectPath)(e)?et(e)?un(e.node):ln(e,t):e.isVariableDeclaration()?an(e,t):e.isClassDeclaration()&&(fn(e.node.body),!((r=e.node.id)===null||r===void 0)&&r.name&&t.classesToWorkletize.push({node:e.node,name:e.node.id.name}))}function an(e,t){e.get("declarations").forEach(i=>{let n=i.get("init");n.isExpression()&&me(n,t)})}function ln(e,t){e.get("properties").forEach(i=>{if(i.isObjectMethod())Qe(i.node.body);else if(i.isObjectProperty()){let n=i.get("value");me(n,t)}})}function cn(e){(0,m.isBlockStatement)(e.body)||(e.body=(0,m.blockStatement)([(0,m.returnStatement)(e.body)]))}function Qe(e){e.directives.some(t=>t.value.value==="worklet")||e.directives.push((0,m.directive)((0,m.directiveLiteral)("worklet")))}function un(e){e.properties.some(t=>(0,m.isObjectProperty)(t)&&(0,m.isIdentifier)(t.key)&&t.key.name===Ye.contextObjectMarker)||e.properties.push((0,m.objectProperty)((0,m.identifier)(`${Ye.contextObjectMarker}`),(0,m.booleanLiteral)(!0)))}function et(e){return e.get("properties").some(r=>r.isObjectMethod()?dn(r):!1)}U.isImplicitContextObject=et;function dn(e){let t=!1;return e.traverse({ThisExpression(r){t=!0,r.stop()}}),t}function fn(e){e.body.push((0,m.classProperty)((0,m.identifier)("__workletClass"),(0,m.booleanLiteral)(!0)))}function pn(e){let t=e.body,r=t.length,i=0;for(;i<r;){let n=t[i];if(!mn(n)){i++;continue}let s=t.splice(i,1);t.push(...s),r--}}function mn(e){return(0,m.isExpressionStatement)(e)&&(0,m.isAssignmentExpression)(e.expression)&&(0,m.isMemberExpression)(e.expression.left)&&(0,m.isIdentifier)(e.expression.left.object)&&e.expression.left.object.name==="exports"}});var rt=p(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.processInlineStylesWarning=void 0;var f=require("@babel/types"),be=require("assert"),bn=q();function yn(e){return(0,f.callExpression)((0,f.arrowFunctionExpression)([],(0,f.blockStatement)([(0,f.expressionStatement)((0,f.callExpression)((0,f.memberExpression)((0,f.identifier)("console"),(0,f.identifier)("warn")),[(0,f.callExpression)((0,f.memberExpression)((0,f.callExpression)((0,f.identifier)("require"),[(0,f.stringLiteral)("react-native-reanimated")]),(0,f.identifier)("getUseOfValueInStyleWarning")),[])])),(0,f.returnStatement)(e.node)])),[])}function kn(e){e.isMemberExpression()&&(0,f.isIdentifier)(e.node.property)&&e.node.property.name==="value"&&e.replaceWith(yn(e))}function gn(e){if((0,f.isArrayExpression)(e.node)){let t=e.get("elements");(0,be.strict)(Array.isArray(t),"[Reanimated] `elements` should be an array.");for(let r of t)r.isObjectExpression()&&ye(r)}}function ye(e){let t=e.get("properties");for(let r of t)if(r.isObjectProperty()){let i=r.get("value");(0,f.isIdentifier)(r.node.key)&&r.node.key.name==="transform"?gn(i):kn(i)}}function _n(e,t){if((0,bn.isRelease)()||t.opts.disableInlineStylesWarning||e.node.name.name!=="style"||!(0,f.isJSXExpressionContainer)(e.node.value))return;let r=e.get("value").get("expression");if((0,be.strict)(!Array.isArray(r),"[Reanimated] `expression` should not be an array."),r.isArrayExpression()){let i=r.get("elements");(0,be.strict)(Array.isArray(i),"[Reanimated] `elements` should be an array.");for(let n of i)n.isObjectExpression()&&ye(n)}else r.isObjectExpression()&&ye(r)}ne.processInlineStylesWarning=_n});var it=p(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.substituteWebCallExpression=void 0;var nt=require("@babel/types");function vn(e){let t=e.node.callee;if((0,nt.isIdentifier)(t)){let r=t.name;(r==="isWeb"||r==="shouldBeUseWeb")&&e.replaceWith((0,nt.booleanLiteral)(!0))}}ie.substituteWebCallExpression=vn});Object.defineProperty(exports,"__esModule",{value:!0});var ot=He(),On=Xe(),hn=pe(),En=tt(),In=le(),Sn=rt(),xn=x(),Wn=it(),wn=K();module.exports=function(){function e(t){try{t()}catch(r){throw new Error(`[Reanimated] Babel plugin exception: ${r}`)}}return{name:"reanimated",pre(){e(()=>{(0,In.initializeState)(this)})},visitor:{CallExpression:{enter(t,r){e(()=>{(0,ot.processCalleesAutoworkletizableCallbacks)(t,r),r.opts.substituteWebPlatformChecks&&(0,Wn.substituteWebCallExpression)(t)})}},[xn.WorkletizableFunction]:{enter(t,r){e(()=>{(0,wn.processIfWithWorkletDirective)(t,r)||(0,ot.processIfAutoworkletizableCallback)(t,r)})}},ObjectExpression:{enter(t,r){e(()=>{(0,hn.processIfWorkletContextObject)(t,r)})}},ClassDeclaration:{enter(t,r){e(()=>{(0,On.processIfWorkletClass)(t,r)})}},Program:{enter(t,r){e(()=>{(0,En.processIfWorkletFile)(t,r)})}},JSXAttribute:{enter(t,r){e(()=>(0,Sn.processInlineStylesWarning)(t,r))}}}}};
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+
28
+ // lib/gestureHandlerAutoworkletization.js
29
+ var require_gestureHandlerAutoworkletization = __commonJS({
30
+ "lib/gestureHandlerAutoworkletization.js"(exports2) {
31
+ "use strict";
32
+ Object.defineProperty(exports2, "__esModule", { value: true });
33
+ exports2.isGestureObjectEventCallbackMethod = exports2.isGestureHandlerEventCallback = exports2.gestureHandlerBuilderMethods = void 0;
34
+ var types_12 = require("@babel/types");
35
+ var gestureHandlerGestureObjects = /* @__PURE__ */ new Set([
36
+ "Tap",
37
+ "Pan",
38
+ "Pinch",
39
+ "Rotation",
40
+ "Fling",
41
+ "LongPress",
42
+ "ForceTouch",
43
+ "Native",
44
+ "Manual",
45
+ "Race",
46
+ "Simultaneous",
47
+ "Exclusive",
48
+ "Hover"
49
+ ]);
50
+ exports2.gestureHandlerBuilderMethods = /* @__PURE__ */ new Set([
51
+ "onBegin",
52
+ "onStart",
53
+ "onEnd",
54
+ "onFinalize",
55
+ "onUpdate",
56
+ "onChange",
57
+ "onTouchesDown",
58
+ "onTouchesMove",
59
+ "onTouchesUp",
60
+ "onTouchesCancelled"
61
+ ]);
62
+ function isGestureHandlerEventCallback(path) {
63
+ return (0, types_12.isCallExpression)(path.parent) && (0, types_12.isExpression)(path.parent.callee) && isGestureObjectEventCallbackMethod(path.parent.callee);
64
+ }
65
+ exports2.isGestureHandlerEventCallback = isGestureHandlerEventCallback;
66
+ function isGestureObjectEventCallbackMethod(exp) {
67
+ return (0, types_12.isMemberExpression)(exp) && (0, types_12.isIdentifier)(exp.property) && exports2.gestureHandlerBuilderMethods.has(exp.property.name) && containsGestureObject(exp.object);
68
+ }
69
+ exports2.isGestureObjectEventCallbackMethod = isGestureObjectEventCallbackMethod;
70
+ function containsGestureObject(exp) {
71
+ if (isGestureObject(exp)) {
72
+ return true;
73
+ }
74
+ if ((0, types_12.isCallExpression)(exp) && (0, types_12.isMemberExpression)(exp.callee) && containsGestureObject(exp.callee.object)) {
75
+ return true;
76
+ }
77
+ return false;
78
+ }
79
+ function isGestureObject(exp) {
80
+ return (0, types_12.isCallExpression)(exp) && (0, types_12.isMemberExpression)(exp.callee) && (0, types_12.isIdentifier)(exp.callee.object) && exp.callee.object.name === "Gesture" && (0, types_12.isIdentifier)(exp.callee.property) && gestureHandlerGestureObjects.has(exp.callee.property.name);
81
+ }
82
+ }
83
+ });
84
+
85
+ // lib/layoutAnimationAutoworkletization.js
86
+ var require_layoutAnimationAutoworkletization = __commonJS({
87
+ "lib/layoutAnimationAutoworkletization.js"(exports2) {
88
+ "use strict";
89
+ Object.defineProperty(exports2, "__esModule", { value: true });
90
+ exports2.isLayoutAnimationCallback = void 0;
91
+ var types_12 = require("@babel/types");
92
+ var EntryExitAnimations = /* @__PURE__ */ new Set([
93
+ "BounceIn",
94
+ "BounceInDown",
95
+ "BounceInLeft",
96
+ "BounceInRight",
97
+ "BounceInUp",
98
+ "BounceOut",
99
+ "BounceOutDown",
100
+ "BounceOutLeft",
101
+ "BounceOutRight",
102
+ "BounceOutUp",
103
+ "FadeIn",
104
+ "FadeInDown",
105
+ "FadeInLeft",
106
+ "FadeInRight",
107
+ "FadeInUp",
108
+ "FadeOut",
109
+ "FadeOutDown",
110
+ "FadeOutLeft",
111
+ "FadeOutRight",
112
+ "FadeOutUp",
113
+ "FlipInEasyX",
114
+ "FlipInEasyY",
115
+ "FlipInXDown",
116
+ "FlipInXUp",
117
+ "FlipInYLeft",
118
+ "FlipInYRight",
119
+ "FlipOutEasyX",
120
+ "FlipOutEasyY",
121
+ "FlipOutXDown",
122
+ "FlipOutXUp",
123
+ "FlipOutYLeft",
124
+ "FlipOutYRight",
125
+ "LightSpeedInLeft",
126
+ "LightSpeedInRight",
127
+ "LightSpeedOutLeft",
128
+ "LightSpeedOutRight",
129
+ "PinwheelIn",
130
+ "PinwheelOut",
131
+ "RollInLeft",
132
+ "RollInRight",
133
+ "RollOutLeft",
134
+ "RollOutRight",
135
+ "RotateInDownLeft",
136
+ "RotateInDownRight",
137
+ "RotateInUpLeft",
138
+ "RotateInUpRight",
139
+ "RotateOutDownLeft",
140
+ "RotateOutDownRight",
141
+ "RotateOutUpLeft",
142
+ "RotateOutUpRight",
143
+ "SlideInDown",
144
+ "SlideInLeft",
145
+ "SlideInRight",
146
+ "SlideInUp",
147
+ "SlideOutDown",
148
+ "SlideOutLeft",
149
+ "SlideOutRight",
150
+ "SlideOutUp",
151
+ "StretchInX",
152
+ "StretchInY",
153
+ "StretchOutX",
154
+ "StretchOutY",
155
+ "ZoomIn",
156
+ "ZoomInDown",
157
+ "ZoomInEasyDown",
158
+ "ZoomInEasyUp",
159
+ "ZoomInLeft",
160
+ "ZoomInRight",
161
+ "ZoomInRotate",
162
+ "ZoomInUp",
163
+ "ZoomOut",
164
+ "ZoomOutDown",
165
+ "ZoomOutEasyDown",
166
+ "ZoomOutEasyUp",
167
+ "ZoomOutLeft",
168
+ "ZoomOutRight",
169
+ "ZoomOutRotate",
170
+ "ZoomOutUp"
171
+ ]);
172
+ var LayoutTransitions = /* @__PURE__ */ new Set([
173
+ "Layout",
174
+ "LinearTransition",
175
+ "SequencedTransition",
176
+ "FadingTransition",
177
+ "JumpingTransition",
178
+ "CurvedTransition",
179
+ "EntryExitTransition"
180
+ ]);
181
+ var LayoutAnimations = /* @__PURE__ */ new Set([
182
+ ...EntryExitAnimations,
183
+ ...LayoutTransitions
184
+ ]);
185
+ var BaseAnimationsChainableMethods = /* @__PURE__ */ new Set([
186
+ "build",
187
+ "duration",
188
+ "delay",
189
+ "getDuration",
190
+ "randomDelay",
191
+ "getDelay",
192
+ "getDelayFunction"
193
+ ]);
194
+ var ComplexAnimationsChainableMethods = /* @__PURE__ */ new Set([
195
+ "easing",
196
+ "rotate",
197
+ "springify",
198
+ "damping",
199
+ "mass",
200
+ "stiffness",
201
+ "overshootClamping",
202
+ "restDisplacementThreshold",
203
+ "restSpeedThreshold",
204
+ "withInitialValues",
205
+ "getAnimationAndConfig"
206
+ ]);
207
+ var DefaultTransitionChainableMethods = /* @__PURE__ */ new Set([
208
+ "easingX",
209
+ "easingY",
210
+ "easingWidth",
211
+ "easingHeight",
212
+ "entering",
213
+ "exiting",
214
+ "reverse"
215
+ ]);
216
+ var LayoutAnimationsChainableMethods = /* @__PURE__ */ new Set([
217
+ ...BaseAnimationsChainableMethods,
218
+ ...ComplexAnimationsChainableMethods,
219
+ ...DefaultTransitionChainableMethods
220
+ ]);
221
+ var LayoutAnimationsCallbacks = /* @__PURE__ */ new Set(["withCallback"]);
222
+ function isLayoutAnimationCallback(path) {
223
+ return (0, types_12.isCallExpression)(path.parent) && (0, types_12.isExpression)(path.parent.callee) && isLayoutAnimationCallbackMethod(path.parent.callee);
224
+ }
225
+ exports2.isLayoutAnimationCallback = isLayoutAnimationCallback;
226
+ function isLayoutAnimationCallbackMethod(exp) {
227
+ return (0, types_12.isMemberExpression)(exp) && (0, types_12.isIdentifier)(exp.property) && LayoutAnimationsCallbacks.has(exp.property.name) && isLayoutAnimationsChainableOrNewOperator(exp.object);
228
+ }
229
+ function isLayoutAnimationsChainableOrNewOperator(exp) {
230
+ if ((0, types_12.isIdentifier)(exp) && LayoutAnimations.has(exp.name)) {
231
+ return true;
232
+ } else if ((0, types_12.isNewExpression)(exp) && (0, types_12.isIdentifier)(exp.callee) && LayoutAnimations.has(exp.callee.name)) {
233
+ return true;
234
+ }
235
+ if ((0, types_12.isCallExpression)(exp) && (0, types_12.isMemberExpression)(exp.callee) && (0, types_12.isIdentifier)(exp.callee.property) && LayoutAnimationsChainableMethods.has(exp.callee.property.name) && isLayoutAnimationsChainableOrNewOperator(exp.callee.object)) {
236
+ return true;
237
+ }
238
+ return false;
239
+ }
240
+ }
241
+ });
242
+
243
+ // lib/types.js
244
+ var require_types = __commonJS({
245
+ "lib/types.js"(exports2) {
246
+ "use strict";
247
+ Object.defineProperty(exports2, "__esModule", { value: true });
248
+ exports2.workletClassFactorySuffix = exports2.isWorkletizableObjectNode = exports2.isWorkletizableObjectPath = exports2.isWorkletizableFunctionNode = exports2.isWorkletizableFunctionPath = exports2.WorkletizableObject = exports2.WorkletizableFunction = void 0;
249
+ var types_12 = require("@babel/types");
250
+ exports2.WorkletizableFunction = "FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod";
251
+ exports2.WorkletizableObject = "ObjectExpression";
252
+ function isWorkletizableFunctionPath(path) {
253
+ return path.isFunctionDeclaration() || path.isFunctionExpression() || path.isArrowFunctionExpression() || path.isObjectMethod();
254
+ }
255
+ exports2.isWorkletizableFunctionPath = isWorkletizableFunctionPath;
256
+ function isWorkletizableFunctionNode(node) {
257
+ return (0, types_12.isFunctionDeclaration)(node) || (0, types_12.isFunctionExpression)(node) || (0, types_12.isArrowFunctionExpression)(node) || (0, types_12.isObjectMethod)(node);
258
+ }
259
+ exports2.isWorkletizableFunctionNode = isWorkletizableFunctionNode;
260
+ function isWorkletizableObjectPath(path) {
261
+ return path.isObjectExpression();
262
+ }
263
+ exports2.isWorkletizableObjectPath = isWorkletizableObjectPath;
264
+ function isWorkletizableObjectNode(node) {
265
+ return (0, types_12.isObjectExpression)(node);
266
+ }
267
+ exports2.isWorkletizableObjectNode = isWorkletizableObjectNode;
268
+ exports2.workletClassFactorySuffix = "__classFactory";
269
+ }
270
+ });
271
+
272
+ // lib/utils.js
273
+ var require_utils = __commonJS({
274
+ "lib/utils.js"(exports2) {
275
+ "use strict";
276
+ Object.defineProperty(exports2, "__esModule", { value: true });
277
+ exports2.replaceWithFactoryCall = exports2.isRelease = void 0;
278
+ var types_12 = require("@babel/types");
279
+ function isRelease() {
280
+ var _a, _b;
281
+ const pattern = /(prod|release|stag[ei])/i;
282
+ return !!(((_a = process.env.BABEL_ENV) === null || _a === void 0 ? void 0 : _a.match(pattern)) || ((_b = process.env.NODE_ENV) === null || _b === void 0 ? void 0 : _b.match(pattern)));
283
+ }
284
+ exports2.isRelease = isRelease;
285
+ function replaceWithFactoryCall(toReplace, name, factoryCall) {
286
+ if (!name || !needsDeclaration(toReplace)) {
287
+ toReplace.replaceWith(factoryCall);
288
+ } else {
289
+ const replacement = (0, types_12.variableDeclaration)("const", [
290
+ (0, types_12.variableDeclarator)((0, types_12.identifier)(name), factoryCall)
291
+ ]);
292
+ toReplace.replaceWith(replacement);
293
+ }
294
+ }
295
+ exports2.replaceWithFactoryCall = replaceWithFactoryCall;
296
+ function needsDeclaration(nodePath) {
297
+ return (0, types_12.isScopable)(nodePath.parent) || (0, types_12.isExportNamedDeclaration)(nodePath.parent);
298
+ }
299
+ }
300
+ });
301
+
302
+ // lib/globals.js
303
+ var require_globals = __commonJS({
304
+ "lib/globals.js"(exports2) {
305
+ "use strict";
306
+ Object.defineProperty(exports2, "__esModule", { value: true });
307
+ exports2.addCustomGlobals = exports2.initializeGlobals = exports2.globals = exports2.defaultGlobals = exports2.initializeState = void 0;
308
+ var notCapturedIdentifiers = [
309
+ "globalThis",
310
+ "Infinity",
311
+ "NaN",
312
+ "undefined",
313
+ "eval",
314
+ "isFinite",
315
+ "isNaN",
316
+ "parseFloat",
317
+ "parseInt",
318
+ "decodeURI",
319
+ "decodeURIComponent",
320
+ "encodeURI",
321
+ "encodeURIComponent",
322
+ "escape",
323
+ "unescape",
324
+ "Object",
325
+ "Function",
326
+ "Boolean",
327
+ "Symbol",
328
+ "Error",
329
+ "AggregateError",
330
+ "EvalError",
331
+ "RangeError",
332
+ "ReferenceError",
333
+ "SyntaxError",
334
+ "TypeError",
335
+ "URIError",
336
+ "InternalError",
337
+ "Number",
338
+ "BigInt",
339
+ "Math",
340
+ "Date",
341
+ "String",
342
+ "RegExp",
343
+ "Array",
344
+ "Int8Array",
345
+ "Uint8Array",
346
+ "Uint8ClampedArray",
347
+ "Int16Array",
348
+ "Uint16Array",
349
+ "Int32Array",
350
+ "Uint32Array",
351
+ "BigInt64Array",
352
+ "BigUint64Array",
353
+ "Float32Array",
354
+ "Float64Array",
355
+ "Map",
356
+ "Set",
357
+ "WeakMap",
358
+ "WeakSet",
359
+ "ArrayBuffer",
360
+ "SharedArrayBuffer",
361
+ "DataView",
362
+ "Atomics",
363
+ "JSON",
364
+ "WeakRef",
365
+ "FinalizationRegistry",
366
+ "Iterator",
367
+ "AsyncIterator",
368
+ "Promise",
369
+ "GeneratorFunction",
370
+ "AsyncGeneratorFunction",
371
+ "Generator",
372
+ "AsyncGenerator",
373
+ "AsyncFunction",
374
+ "Reflect",
375
+ "Proxy",
376
+ "Intl",
377
+ "null",
378
+ "this",
379
+ "global",
380
+ "window",
381
+ "globalThis",
382
+ "console",
383
+ "performance",
384
+ "queueMicrotask",
385
+ "requestAnimationFrame",
386
+ "setImmediate",
387
+ "arguments",
388
+ "HermesInternal",
389
+ "ReanimatedError",
390
+ "_WORKLET",
391
+ "WorkletsError",
392
+ "__workletsLoggerConfig"
393
+ ];
394
+ var notCapturedIdentifiers_DEPRECATED = [
395
+ "_IS_FABRIC",
396
+ "_log",
397
+ "_toString",
398
+ "_scheduleHostFunctionOnJS",
399
+ "_scheduleRemoteFunctionOnJS",
400
+ "_scheduleOnRuntime",
401
+ "_makeShareableClone",
402
+ "_updateProps",
403
+ "_measure",
404
+ "_dispatchCommand",
405
+ "_setGestureState",
406
+ "_notifyAboutProgress",
407
+ "_notifyAboutEnd",
408
+ "_runOnUIQueue",
409
+ "_getAnimationTimestamp"
410
+ ];
411
+ function initializeState(state) {
412
+ state.workletNumber = 1;
413
+ state.classesToWorkletize = [];
414
+ initializeGlobals();
415
+ addCustomGlobals(state);
416
+ }
417
+ exports2.initializeState = initializeState;
418
+ exports2.defaultGlobals = new Set(notCapturedIdentifiers.concat(notCapturedIdentifiers_DEPRECATED));
419
+ function initializeGlobals() {
420
+ exports2.globals = new Set(exports2.defaultGlobals);
421
+ }
422
+ exports2.initializeGlobals = initializeGlobals;
423
+ function addCustomGlobals(state) {
424
+ if (state.opts && Array.isArray(state.opts.globals)) {
425
+ state.opts.globals.forEach((name) => {
426
+ exports2.globals.add(name);
427
+ });
428
+ }
429
+ }
430
+ exports2.addCustomGlobals = addCustomGlobals;
431
+ }
432
+ });
433
+
434
+ // lib/transform.js
435
+ var require_transform = __commonJS({
436
+ "lib/transform.js"(exports2) {
437
+ "use strict";
438
+ var __rest = exports2 && exports2.__rest || function(s, e) {
439
+ var t = {};
440
+ for (var p in s)
441
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
442
+ t[p] = s[p];
443
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
444
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
445
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
446
+ t[p[i]] = s[p[i]];
447
+ }
448
+ return t;
449
+ };
450
+ Object.defineProperty(exports2, "__esModule", { value: true });
451
+ exports2.workletTransformSync = void 0;
452
+ var core_1 = require("@babel/core");
453
+ function workletTransformSync(code, opts) {
454
+ const { extraPlugins = [], extraPresets = [] } = opts, rest = __rest(opts, ["extraPlugins", "extraPresets"]);
455
+ return (0, core_1.transformSync)(code, Object.assign(Object.assign({}, rest), { plugins: [...defaultPlugins, ...extraPlugins], presets: [...defaultPresets, ...extraPresets] }));
456
+ }
457
+ exports2.workletTransformSync = workletTransformSync;
458
+ var defaultPresets = [
459
+ require.resolve("@babel/preset-typescript")
460
+ ];
461
+ var defaultPlugins = [];
462
+ }
463
+ });
464
+
465
+ // lib/workletStringCode.js
466
+ var require_workletStringCode = __commonJS({
467
+ "lib/workletStringCode.js"(exports2) {
468
+ "use strict";
469
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
470
+ if (k2 === void 0)
471
+ k2 = k;
472
+ var desc = Object.getOwnPropertyDescriptor(m, k);
473
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
474
+ desc = { enumerable: true, get: function() {
475
+ return m[k];
476
+ } };
477
+ }
478
+ Object.defineProperty(o, k2, desc);
479
+ } : function(o, m, k, k2) {
480
+ if (k2 === void 0)
481
+ k2 = k;
482
+ o[k2] = m[k];
483
+ });
484
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
485
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
486
+ } : function(o, v) {
487
+ o["default"] = v;
488
+ });
489
+ var __importStar = exports2 && exports2.__importStar || function(mod) {
490
+ if (mod && mod.__esModule)
491
+ return mod;
492
+ var result = {};
493
+ if (mod != null) {
494
+ for (var k in mod)
495
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
496
+ __createBinding(result, mod, k);
497
+ }
498
+ __setModuleDefault(result, mod);
499
+ return result;
500
+ };
501
+ var __importDefault = exports2 && exports2.__importDefault || function(mod) {
502
+ return mod && mod.__esModule ? mod : { "default": mod };
503
+ };
504
+ Object.defineProperty(exports2, "__esModule", { value: true });
505
+ exports2.buildWorkletString = void 0;
506
+ var core_1 = require("@babel/core");
507
+ var generator_1 = __importDefault(require("@babel/generator"));
508
+ var types_12 = require("@babel/types");
509
+ var assert_1 = require("assert");
510
+ var convertSourceMap = __importStar(require("convert-source-map"));
511
+ var fs = __importStar(require("fs"));
512
+ var transform_1 = require_transform();
513
+ var types_2 = require_types();
514
+ var utils_1 = require_utils();
515
+ var MOCK_SOURCE_MAP = "mock source map";
516
+ function buildWorkletString(fun, state, closureVariables, workletName, inputMap) {
517
+ var _a;
518
+ restoreRecursiveCalls(fun, workletName);
519
+ const draftExpression = fun.program.body.find((obj) => (0, types_12.isFunctionDeclaration)(obj)) || fun.program.body.find((obj) => (0, types_12.isExpressionStatement)(obj)) || void 0;
520
+ (0, assert_1.strict)(draftExpression, "[Reanimated] `draftExpression` is undefined.");
521
+ const expression = (0, types_12.isFunctionDeclaration)(draftExpression) ? draftExpression : draftExpression.expression;
522
+ (0, assert_1.strict)("params" in expression, "'params' property is undefined in 'expression'");
523
+ (0, assert_1.strict)((0, types_12.isBlockStatement)(expression.body), "[Reanimated] `expression.body` is not a `BlockStatement`");
524
+ const parsedClasses = /* @__PURE__ */ new Set();
525
+ (0, core_1.traverse)(fun, {
526
+ NewExpression(path) {
527
+ if (!(0, types_12.isIdentifier)(path.node.callee)) {
528
+ return;
529
+ }
530
+ const constructorName = path.node.callee.name;
531
+ if (!closureVariables.some((variable) => variable.name === constructorName) || parsedClasses.has(constructorName)) {
532
+ return;
533
+ }
534
+ const index = closureVariables.findIndex((variable) => variable.name === constructorName);
535
+ closureVariables.splice(index, 1);
536
+ const workletClassFactoryName = constructorName + types_2.workletClassFactorySuffix;
537
+ closureVariables.push((0, types_12.identifier)(workletClassFactoryName));
538
+ (0, types_12.assertBlockStatement)(expression.body);
539
+ expression.body.body.unshift((0, types_12.variableDeclaration)("const", [
540
+ (0, types_12.variableDeclarator)((0, types_12.identifier)(constructorName), (0, types_12.callExpression)((0, types_12.identifier)(workletClassFactoryName), []))
541
+ ]));
542
+ parsedClasses.add(constructorName);
543
+ }
544
+ });
545
+ const workletFunction = (0, types_12.functionExpression)((0, types_12.identifier)(workletName), expression.params, expression.body, expression.generator, expression.async);
546
+ const code = (0, generator_1.default)(workletFunction).code;
547
+ (0, assert_1.strict)(inputMap, "[Reanimated] `inputMap` is undefined.");
548
+ const includeSourceMap = !((0, utils_1.isRelease)() || state.opts.disableSourceMaps);
549
+ if (includeSourceMap) {
550
+ inputMap.sourcesContent = [];
551
+ for (const sourceFile of inputMap.sources) {
552
+ inputMap.sourcesContent.push(fs.readFileSync(sourceFile).toString("utf-8"));
553
+ }
554
+ }
555
+ const transformed = (0, transform_1.workletTransformSync)(code, {
556
+ filename: state.file.opts.filename,
557
+ extraPlugins: [
558
+ getClosurePlugin(closureVariables),
559
+ ...(_a = state.opts.extraPlugins) !== null && _a !== void 0 ? _a : []
560
+ ],
561
+ extraPresets: state.opts.extraPresets,
562
+ compact: true,
563
+ sourceMaps: includeSourceMap,
564
+ inputSourceMap: inputMap,
565
+ ast: false,
566
+ babelrc: false,
567
+ configFile: false,
568
+ comments: false
569
+ });
570
+ (0, assert_1.strict)(transformed, "[Reanimated] `transformed` is null.");
571
+ let sourceMap;
572
+ if (includeSourceMap) {
573
+ if (shouldMockSourceMap()) {
574
+ sourceMap = MOCK_SOURCE_MAP;
575
+ } else {
576
+ sourceMap = convertSourceMap.fromObject(transformed.map).toObject();
577
+ delete sourceMap.sourcesContent;
578
+ }
579
+ }
580
+ return [transformed.code, JSON.stringify(sourceMap)];
581
+ }
582
+ exports2.buildWorkletString = buildWorkletString;
583
+ function restoreRecursiveCalls(file, newName) {
584
+ (0, core_1.traverse)(file, {
585
+ FunctionExpression(path) {
586
+ if (!path.node.id) {
587
+ path.stop();
588
+ return;
589
+ }
590
+ const oldName = path.node.id.name;
591
+ const scope = path.scope;
592
+ scope.rename(oldName, newName);
593
+ }
594
+ });
595
+ }
596
+ function shouldMockSourceMap() {
597
+ return process.env.REANIMATED_JEST_SHOULD_MOCK_SOURCE_MAP === "1";
598
+ }
599
+ function prependClosure(path, closureVariables, closureDeclaration) {
600
+ if (closureVariables.length === 0 || !(0, types_12.isProgram)(path.parent)) {
601
+ return;
602
+ }
603
+ if (!(0, types_12.isExpression)(path.node.body)) {
604
+ path.node.body.body.unshift(closureDeclaration);
605
+ }
606
+ }
607
+ function prependRecursiveDeclaration(path) {
608
+ var _a;
609
+ if ((0, types_12.isProgram)(path.parent) && !(0, types_12.isArrowFunctionExpression)(path.node) && !(0, types_12.isObjectMethod)(path.node) && path.node.id && path.scope.parent) {
610
+ const hasRecursiveCalls = ((_a = path.scope.parent.bindings[path.node.id.name]) === null || _a === void 0 ? void 0 : _a.references) > 0;
611
+ if (hasRecursiveCalls) {
612
+ path.node.body.body.unshift((0, types_12.variableDeclaration)("const", [
613
+ (0, types_12.variableDeclarator)((0, types_12.identifier)(path.node.id.name), (0, types_12.memberExpression)((0, types_12.thisExpression)(), (0, types_12.identifier)("_recur")))
614
+ ]));
615
+ }
616
+ }
617
+ }
618
+ function getClosurePlugin(closureVariables) {
619
+ const closureDeclaration = (0, types_12.variableDeclaration)("const", [
620
+ (0, types_12.variableDeclarator)((0, types_12.objectPattern)(closureVariables.map((variable) => (0, types_12.objectProperty)((0, types_12.identifier)(variable.name), (0, types_12.identifier)(variable.name), false, true))), (0, types_12.memberExpression)((0, types_12.thisExpression)(), (0, types_12.identifier)("__closure")))
621
+ ]);
622
+ return {
623
+ visitor: {
624
+ "FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod": (path) => {
625
+ prependClosure(path, closureVariables, closureDeclaration);
626
+ prependRecursiveDeclaration(path);
627
+ }
628
+ }
629
+ };
630
+ }
631
+ }
632
+ });
633
+
634
+ // lib/workletFactory.js
635
+ var require_workletFactory = __commonJS({
636
+ "lib/workletFactory.js"(exports2) {
637
+ "use strict";
638
+ var __importDefault = exports2 && exports2.__importDefault || function(mod) {
639
+ return mod && mod.__esModule ? mod : { "default": mod };
640
+ };
641
+ Object.defineProperty(exports2, "__esModule", { value: true });
642
+ exports2.makeWorkletFactory = void 0;
643
+ var core_1 = require("@babel/core");
644
+ var generator_1 = __importDefault(require("@babel/generator"));
645
+ var types_12 = require("@babel/types");
646
+ var assert_1 = require("assert");
647
+ var path_1 = require("path");
648
+ var globals_12 = require_globals();
649
+ var transform_1 = require_transform();
650
+ var types_2 = require_types();
651
+ var utils_1 = require_utils();
652
+ var workletStringCode_1 = require_workletStringCode();
653
+ var REAL_VERSION = require("../package.json").version;
654
+ var MOCK_VERSION = "x.y.z";
655
+ function makeWorkletFactory(fun, state) {
656
+ var _a;
657
+ removeWorkletDirective(fun);
658
+ (0, assert_1.strict)(state.file.opts.filename, "[Reanimated] `state.file.opts.filename` is undefined.");
659
+ const codeObject = (0, generator_1.default)(fun.node, {
660
+ sourceMaps: true,
661
+ sourceFileName: state.file.opts.filename
662
+ });
663
+ codeObject.code = "(" + (fun.isObjectMethod() ? "function " : "") + codeObject.code + "\n)";
664
+ const transformed = (0, transform_1.workletTransformSync)(codeObject.code, {
665
+ extraPlugins: [...extraPlugins, ...(_a = state.opts.extraPlugins) !== null && _a !== void 0 ? _a : []],
666
+ extraPresets: state.opts.extraPresets,
667
+ filename: state.file.opts.filename,
668
+ ast: true,
669
+ babelrc: false,
670
+ configFile: false,
671
+ inputSourceMap: codeObject.map
672
+ });
673
+ (0, assert_1.strict)(transformed, "[Reanimated] `transformed` is undefined.");
674
+ (0, assert_1.strict)(transformed.ast, "[Reanimated] `transformed.ast` is undefined.");
675
+ const closureVariables = makeArrayFromCapturedBindings(transformed.ast, fun);
676
+ const clone = (0, types_12.cloneNode)(fun.node);
677
+ const funExpression = (0, types_12.isBlockStatement)(clone.body) ? (0, types_12.functionExpression)(null, clone.params, clone.body, clone.generator, clone.async) : clone;
678
+ const { workletName, reactName } = makeWorkletName(fun, state);
679
+ let [funString, sourceMapString] = (0, workletStringCode_1.buildWorkletString)(transformed.ast, state, closureVariables, workletName, transformed.map);
680
+ (0, assert_1.strict)(funString, "[Reanimated] `funString` is undefined.");
681
+ const workletHash = hash(funString);
682
+ let lineOffset = 1;
683
+ if (closureVariables.length > 0) {
684
+ lineOffset -= closureVariables.length + 2;
685
+ }
686
+ const pathForStringDefinitions = fun.parentPath.isProgram() ? fun : fun.findParent((path) => {
687
+ var _a2, _b;
688
+ return (_b = (_a2 = path.parentPath) === null || _a2 === void 0 ? void 0 : _a2.isProgram()) !== null && _b !== void 0 ? _b : false;
689
+ });
690
+ (0, assert_1.strict)(pathForStringDefinitions, "[Reanimated] `pathForStringDefinitions` is null.");
691
+ (0, assert_1.strict)(pathForStringDefinitions.parentPath, "[Reanimated] `pathForStringDefinitions.parentPath` is null.");
692
+ const initDataId = pathForStringDefinitions.parentPath.scope.generateUidIdentifier(`worklet_${workletHash}_init_data`);
693
+ const initDataObjectExpression = (0, types_12.objectExpression)([
694
+ (0, types_12.objectProperty)((0, types_12.identifier)("code"), (0, types_12.stringLiteral)(funString))
695
+ ]);
696
+ const shouldInjectLocation = !(0, utils_1.isRelease)();
697
+ if (shouldInjectLocation) {
698
+ let location = state.file.opts.filename;
699
+ if (state.opts.relativeSourceLocation) {
700
+ location = (0, path_1.relative)(state.cwd, location);
701
+ sourceMapString = sourceMapString === null || sourceMapString === void 0 ? void 0 : sourceMapString.replace(state.file.opts.filename, location);
702
+ }
703
+ initDataObjectExpression.properties.push((0, types_12.objectProperty)((0, types_12.identifier)("location"), (0, types_12.stringLiteral)(location)));
704
+ }
705
+ if (sourceMapString) {
706
+ initDataObjectExpression.properties.push((0, types_12.objectProperty)((0, types_12.identifier)("sourceMap"), (0, types_12.stringLiteral)(sourceMapString)));
707
+ }
708
+ const shouldInjectVersion = !(0, utils_1.isRelease)();
709
+ if (shouldInjectVersion) {
710
+ initDataObjectExpression.properties.push((0, types_12.objectProperty)((0, types_12.identifier)("version"), (0, types_12.stringLiteral)(shouldMockVersion() ? MOCK_VERSION : REAL_VERSION)));
711
+ }
712
+ const shouldIncludeInitData = !state.opts.omitNativeOnlyData;
713
+ if (shouldIncludeInitData) {
714
+ pathForStringDefinitions.insertBefore((0, types_12.variableDeclaration)("const", [
715
+ (0, types_12.variableDeclarator)(initDataId, initDataObjectExpression)
716
+ ]));
717
+ }
718
+ (0, assert_1.strict)(!(0, types_12.isFunctionDeclaration)(funExpression), "[Reanimated] `funExpression` is a `FunctionDeclaration`.");
719
+ (0, assert_1.strict)(!(0, types_12.isObjectMethod)(funExpression), "[Reanimated] `funExpression` is an `ObjectMethod`.");
720
+ const statements = [
721
+ (0, types_12.variableDeclaration)("const", [
722
+ (0, types_12.variableDeclarator)((0, types_12.identifier)(reactName), funExpression)
723
+ ]),
724
+ (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__closure"), false), (0, types_12.objectExpression)(closureVariables.map((variable) => variable.name.endsWith(types_2.workletClassFactorySuffix) ? (0, types_12.objectProperty)((0, types_12.identifier)(variable.name), (0, types_12.memberExpression)((0, types_12.identifier)(variable.name.slice(0, variable.name.length - types_2.workletClassFactorySuffix.length)), (0, types_12.identifier)(variable.name))) : (0, types_12.objectProperty)((0, types_12.cloneNode)(variable, true), (0, types_12.cloneNode)(variable, true), false, true))))),
725
+ (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__workletHash"), false), (0, types_12.numericLiteral)(workletHash)))
726
+ ];
727
+ if (shouldIncludeInitData) {
728
+ statements.push((0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__initData"), false), (0, types_12.cloneNode)(initDataId, true))));
729
+ }
730
+ if (!(0, utils_1.isRelease)()) {
731
+ statements.unshift((0, types_12.variableDeclaration)("const", [
732
+ (0, types_12.variableDeclarator)((0, types_12.identifier)("_e"), (0, types_12.arrayExpression)([
733
+ (0, types_12.newExpression)((0, types_12.memberExpression)((0, types_12.identifier)("global"), (0, types_12.identifier)("Error")), []),
734
+ (0, types_12.numericLiteral)(lineOffset),
735
+ (0, types_12.numericLiteral)(-27)
736
+ ]))
737
+ ]));
738
+ statements.push((0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__stackDetails"), false), (0, types_12.identifier)("_e"))));
739
+ }
740
+ statements.push((0, types_12.returnStatement)((0, types_12.identifier)(reactName)));
741
+ const factoryParams = [
742
+ (0, types_12.cloneNode)(initDataId, true),
743
+ ...closureVariables.map((variableId) => (0, types_12.cloneNode)(variableId, true))
744
+ ];
745
+ const factoryParamObjectPattern = (0, types_12.objectPattern)(factoryParams.map((param) => (0, types_12.objectProperty)((0, types_12.cloneNode)(param, true), (0, types_12.cloneNode)(param, true), false, true)));
746
+ const factory = (0, types_12.functionExpression)((0, types_12.identifier)(workletName + "Factory"), [factoryParamObjectPattern], (0, types_12.blockStatement)(statements));
747
+ const factoryCallArgs = [
748
+ (0, types_12.identifier)(initDataId.name),
749
+ ...closureVariables.map((variableId) => (0, types_12.cloneNode)(variableId, true))
750
+ ];
751
+ const factoryCallParamPack = (0, types_12.objectExpression)(factoryCallArgs.map((param) => (0, types_12.objectProperty)((0, types_12.cloneNode)(param, true), (0, types_12.cloneNode)(param, true), false, true)));
752
+ return { factory, factoryCallParamPack };
753
+ }
754
+ exports2.makeWorkletFactory = makeWorkletFactory;
755
+ function removeWorkletDirective(fun) {
756
+ fun.traverse({
757
+ DirectiveLiteral(path) {
758
+ if (path.node.value === "worklet" && path.getFunctionParent() === fun) {
759
+ path.parentPath.remove();
760
+ }
761
+ }
762
+ });
763
+ }
764
+ function shouldMockVersion() {
765
+ return process.env.REANIMATED_JEST_SHOULD_MOCK_VERSION === "1";
766
+ }
767
+ function hash(str) {
768
+ let i = str.length;
769
+ let hash1 = 5381;
770
+ let hash2 = 52711;
771
+ while (i--) {
772
+ const char = str.charCodeAt(i);
773
+ hash1 = hash1 * 33 ^ char;
774
+ hash2 = hash2 * 33 ^ char;
775
+ }
776
+ return (hash1 >>> 0) * 4096 + (hash2 >>> 0);
777
+ }
778
+ function makeWorkletName(fun, state) {
779
+ let source = "unknownFile";
780
+ if (state.file.opts.filename) {
781
+ const filepath = state.file.opts.filename;
782
+ source = (0, path_1.basename)(filepath);
783
+ const splitFilepath = filepath.split("/");
784
+ const nodeModulesIndex = splitFilepath.indexOf("node_modules");
785
+ if (nodeModulesIndex !== -1) {
786
+ const libraryName = splitFilepath[nodeModulesIndex + 1];
787
+ source = `${libraryName}_${source}`;
788
+ }
789
+ }
790
+ const suffix = `${source}${state.workletNumber++}`;
791
+ let reactName = "";
792
+ if ((0, types_12.isObjectMethod)(fun.node) && (0, types_12.isIdentifier)(fun.node.key)) {
793
+ reactName = fun.node.key.name;
794
+ } else if (((0, types_12.isFunctionDeclaration)(fun.node) || (0, types_12.isFunctionExpression)(fun.node)) && (0, types_12.isIdentifier)(fun.node.id)) {
795
+ reactName = fun.node.id.name;
796
+ }
797
+ const workletName = reactName ? (0, types_12.toIdentifier)(`${reactName}_${suffix}`) : (0, types_12.toIdentifier)(suffix);
798
+ reactName = reactName || (0, types_12.toIdentifier)(suffix);
799
+ return { workletName, reactName };
800
+ }
801
+ function makeArrayFromCapturedBindings(ast, fun) {
802
+ const closure = /* @__PURE__ */ new Map();
803
+ const isLocationAssignedMap = /* @__PURE__ */ new Map();
804
+ (0, core_1.traverse)(ast, {
805
+ Identifier(path) {
806
+ if (!path.isReferencedIdentifier()) {
807
+ return;
808
+ }
809
+ const name = path.node.name;
810
+ if (globals_12.globals.has(name)) {
811
+ return;
812
+ }
813
+ if ("id" in fun.node && fun.node.id && fun.node.id.name === name) {
814
+ return;
815
+ }
816
+ const parentNode = path.parent;
817
+ if ((0, types_12.isMemberExpression)(parentNode) && parentNode.property === path.node && !parentNode.computed) {
818
+ return;
819
+ }
820
+ if ((0, types_12.isObjectProperty)(parentNode) && (0, types_12.isObjectExpression)(path.parentPath.parent) && path.node !== parentNode.value) {
821
+ return;
822
+ }
823
+ let currentScope = path.scope;
824
+ while (currentScope != null) {
825
+ if (currentScope.bindings[name] != null) {
826
+ return;
827
+ }
828
+ currentScope = currentScope.parent;
829
+ }
830
+ closure.set(name, (0, types_12.cloneNode)(path.node, true));
831
+ isLocationAssignedMap.set(name, false);
832
+ }
833
+ });
834
+ fun.traverse({
835
+ Identifier(path) {
836
+ if (!path.isReferencedIdentifier()) {
837
+ return;
838
+ }
839
+ const node = closure.get(path.node.name);
840
+ if (!node || isLocationAssignedMap.get(path.node.name)) {
841
+ return;
842
+ }
843
+ node.loc = path.node.loc;
844
+ isLocationAssignedMap.set(path.node.name, true);
845
+ }
846
+ });
847
+ return Array.from(closure.values());
848
+ }
849
+ var extraPlugins = [
850
+ require.resolve("@babel/plugin-transform-shorthand-properties"),
851
+ require.resolve("@babel/plugin-transform-arrow-functions"),
852
+ require.resolve("@babel/plugin-transform-optional-chaining"),
853
+ require.resolve("@babel/plugin-transform-nullish-coalescing-operator"),
854
+ [
855
+ require.resolve("@babel/plugin-transform-template-literals"),
856
+ { loose: true }
857
+ ]
858
+ ];
859
+ }
860
+ });
861
+
862
+ // lib/workletFactoryCall.js
863
+ var require_workletFactoryCall = __commonJS({
864
+ "lib/workletFactoryCall.js"(exports2) {
865
+ "use strict";
866
+ Object.defineProperty(exports2, "__esModule", { value: true });
867
+ exports2.makeWorkletFactoryCall = void 0;
868
+ var types_12 = require("@babel/types");
869
+ var workletFactory_1 = require_workletFactory();
870
+ function makeWorkletFactoryCall(path, state) {
871
+ const { factory, factoryCallParamPack } = (0, workletFactory_1.makeWorkletFactory)(path, state);
872
+ const factoryCall = (0, types_12.callExpression)(factory, [factoryCallParamPack]);
873
+ addStackTraceDataToWorkletFactory(path, factoryCall);
874
+ const replacement = factoryCall;
875
+ return replacement;
876
+ }
877
+ exports2.makeWorkletFactoryCall = makeWorkletFactoryCall;
878
+ function addStackTraceDataToWorkletFactory(path, workletFactoryCall) {
879
+ const originalWorkletLocation = path.node.loc;
880
+ if (originalWorkletLocation) {
881
+ workletFactoryCall.callee.loc = {
882
+ filename: originalWorkletLocation.filename,
883
+ identifierName: originalWorkletLocation.identifierName,
884
+ start: originalWorkletLocation.start,
885
+ end: originalWorkletLocation.start
886
+ };
887
+ }
888
+ }
889
+ }
890
+ });
891
+
892
+ // lib/workletSubstitution.js
893
+ var require_workletSubstitution = __commonJS({
894
+ "lib/workletSubstitution.js"(exports2) {
895
+ "use strict";
896
+ Object.defineProperty(exports2, "__esModule", { value: true });
897
+ exports2.substituteObjectMethodWithObjectProperty = exports2.processWorklet = exports2.processIfWithWorkletDirective = void 0;
898
+ var types_12 = require("@babel/types");
899
+ var types_2 = require_types();
900
+ var utils_1 = require_utils();
901
+ var workletFactoryCall_1 = require_workletFactoryCall();
902
+ function processIfWithWorkletDirective(path, state) {
903
+ if (!(0, types_12.isBlockStatement)(path.node.body)) {
904
+ return false;
905
+ }
906
+ if (!hasWorkletDirective(path.node.body.directives)) {
907
+ return false;
908
+ }
909
+ processWorklet(path, state);
910
+ return true;
911
+ }
912
+ exports2.processIfWithWorkletDirective = processIfWithWorkletDirective;
913
+ function processWorklet(path, state) {
914
+ if (state.opts.processNestedWorklets) {
915
+ path.traverse({
916
+ [types_2.WorkletizableFunction](subPath, passedState) {
917
+ processIfWithWorkletDirective(subPath, passedState);
918
+ }
919
+ }, state);
920
+ }
921
+ const workletFactoryCall = (0, workletFactoryCall_1.makeWorkletFactoryCall)(path, state);
922
+ substituteWorkletWithWorkletFactoryCall(path, workletFactoryCall);
923
+ path.scope.getProgramParent().crawl();
924
+ }
925
+ exports2.processWorklet = processWorklet;
926
+ function hasWorkletDirective(directives) {
927
+ return directives.some((directive) => (0, types_12.isDirectiveLiteral)(directive.value) && directive.value.value === "worklet");
928
+ }
929
+ function substituteWorkletWithWorkletFactoryCall(path, workletFactoryCall) {
930
+ var _a;
931
+ if (path.isObjectMethod()) {
932
+ substituteObjectMethodWithObjectProperty(path, workletFactoryCall);
933
+ } else {
934
+ const name = "id" in path.node ? (_a = path.node.id) === null || _a === void 0 ? void 0 : _a.name : void 0;
935
+ (0, utils_1.replaceWithFactoryCall)(path, name, workletFactoryCall);
936
+ }
937
+ }
938
+ function substituteObjectMethodWithObjectProperty(path, workletFactoryCall) {
939
+ const replacement = (0, types_12.objectProperty)(path.node.key, workletFactoryCall);
940
+ path.replaceWith(replacement);
941
+ }
942
+ exports2.substituteObjectMethodWithObjectProperty = substituteObjectMethodWithObjectProperty;
943
+ }
944
+ });
945
+
946
+ // lib/objectWorklets.js
947
+ var require_objectWorklets = __commonJS({
948
+ "lib/objectWorklets.js"(exports2) {
949
+ "use strict";
950
+ Object.defineProperty(exports2, "__esModule", { value: true });
951
+ exports2.processWorkletizableObject = void 0;
952
+ var types_12 = require_types();
953
+ var workletSubstitution_12 = require_workletSubstitution();
954
+ function processWorkletizableObject(path, state) {
955
+ const properties = path.get("properties");
956
+ for (const property of properties) {
957
+ if (property.isObjectMethod()) {
958
+ (0, workletSubstitution_12.processWorklet)(property, state);
959
+ } else if (property.isObjectProperty()) {
960
+ const value = property.get("value");
961
+ if ((0, types_12.isWorkletizableFunctionPath)(value)) {
962
+ (0, workletSubstitution_12.processWorklet)(value, state);
963
+ }
964
+ } else {
965
+ throw new Error(`[Reanimated] '${property.type}' as to-be workletized argument is not supported for object hooks.`);
966
+ }
967
+ }
968
+ }
969
+ exports2.processWorkletizableObject = processWorkletizableObject;
970
+ }
971
+ });
972
+
973
+ // lib/referencedWorklets.js
974
+ var require_referencedWorklets = __commonJS({
975
+ "lib/referencedWorklets.js"(exports2) {
976
+ "use strict";
977
+ Object.defineProperty(exports2, "__esModule", { value: true });
978
+ exports2.findReferencedWorklet = void 0;
979
+ var types_12 = require_types();
980
+ function findReferencedWorklet(workletIdentifier, acceptWorkletizableFunction, acceptObject) {
981
+ const workletName = workletIdentifier.node.name;
982
+ const scope = workletIdentifier.scope;
983
+ const workletBinding = scope.getBinding(workletName);
984
+ if (!workletBinding) {
985
+ return void 0;
986
+ }
987
+ if (acceptWorkletizableFunction && workletBinding.path.isFunctionDeclaration()) {
988
+ return workletBinding.path;
989
+ }
990
+ const isConstant = workletBinding.constant;
991
+ if (isConstant) {
992
+ return findReferencedWorkletFromVariableDeclarator(workletBinding, acceptWorkletizableFunction, acceptObject);
993
+ }
994
+ return findReferencedWorkletFromAssignmentExpression(workletBinding, acceptWorkletizableFunction, acceptObject);
995
+ }
996
+ exports2.findReferencedWorklet = findReferencedWorklet;
997
+ function findReferencedWorkletFromVariableDeclarator(workletBinding, acceptWorkletizableFunction, acceptObject) {
998
+ const workletDeclaration = workletBinding.path;
999
+ if (!workletDeclaration.isVariableDeclarator()) {
1000
+ return void 0;
1001
+ }
1002
+ const worklet = workletDeclaration.get("init");
1003
+ if (acceptWorkletizableFunction && (0, types_12.isWorkletizableFunctionPath)(worklet)) {
1004
+ return worklet;
1005
+ }
1006
+ if (acceptObject && (0, types_12.isWorkletizableObjectPath)(worklet)) {
1007
+ return worklet;
1008
+ }
1009
+ if (worklet.isIdentifier() && worklet.isReferencedIdentifier()) {
1010
+ return findReferencedWorklet(worklet, acceptWorkletizableFunction, acceptObject);
1011
+ }
1012
+ return void 0;
1013
+ }
1014
+ function findReferencedWorkletFromAssignmentExpression(workletBinding, acceptWorkletizableFunction, acceptObject) {
1015
+ const workletDeclaration = workletBinding.constantViolations.reverse().find((constantViolation) => constantViolation.isAssignmentExpression() && (acceptWorkletizableFunction && (0, types_12.isWorkletizableFunctionPath)(constantViolation.get("right")) || acceptObject && (0, types_12.isWorkletizableObjectPath)(constantViolation.get("right"))));
1016
+ if (!workletDeclaration || !workletDeclaration.isAssignmentExpression()) {
1017
+ return void 0;
1018
+ }
1019
+ const workletDefinition = workletDeclaration.get("right");
1020
+ if (acceptWorkletizableFunction && (0, types_12.isWorkletizableFunctionPath)(workletDefinition)) {
1021
+ return workletDefinition;
1022
+ }
1023
+ if (acceptObject && (0, types_12.isWorkletizableObjectPath)(workletDefinition)) {
1024
+ return workletDefinition;
1025
+ }
1026
+ if (workletDefinition.isIdentifier() && workletDefinition.isReferencedIdentifier()) {
1027
+ return findReferencedWorklet(workletDefinition, acceptWorkletizableFunction, acceptObject);
1028
+ }
1029
+ return void 0;
1030
+ }
1031
+ }
1032
+ });
1033
+
1034
+ // lib/autoworkletization.js
1035
+ var require_autoworkletization = __commonJS({
1036
+ "lib/autoworkletization.js"(exports2) {
1037
+ "use strict";
1038
+ Object.defineProperty(exports2, "__esModule", { value: true });
1039
+ exports2.processCalleesAutoworkletizableCallbacks = exports2.processIfAutoworkletizableCallback = void 0;
1040
+ var types_12 = require("@babel/types");
1041
+ var gestureHandlerAutoworkletization_1 = require_gestureHandlerAutoworkletization();
1042
+ var layoutAnimationAutoworkletization_1 = require_layoutAnimationAutoworkletization();
1043
+ var objectWorklets_1 = require_objectWorklets();
1044
+ var referencedWorklets_1 = require_referencedWorklets();
1045
+ var types_2 = require_types();
1046
+ var workletSubstitution_12 = require_workletSubstitution();
1047
+ var reanimatedObjectHooks = /* @__PURE__ */ new Set([
1048
+ "useAnimatedGestureHandler",
1049
+ "useAnimatedScrollHandler"
1050
+ ]);
1051
+ var reanimatedFunctionHooks = /* @__PURE__ */ new Set([
1052
+ "useFrameCallback",
1053
+ "useAnimatedStyle",
1054
+ "useAnimatedProps",
1055
+ "createAnimatedPropAdapter",
1056
+ "useDerivedValue",
1057
+ "useAnimatedScrollHandler",
1058
+ "useAnimatedReaction",
1059
+ "useWorkletCallback",
1060
+ "withTiming",
1061
+ "withSpring",
1062
+ "withDecay",
1063
+ "withRepeat",
1064
+ "runOnUI",
1065
+ "executeOnUIRuntimeSync"
1066
+ ]);
1067
+ var reanimatedFunctionArgsToWorkletize = new Map([
1068
+ ["useAnimatedGestureHandler", [0]],
1069
+ ["useFrameCallback", [0]],
1070
+ ["useAnimatedStyle", [0]],
1071
+ ["useAnimatedProps", [0]],
1072
+ ["createAnimatedPropAdapter", [0]],
1073
+ ["useDerivedValue", [0]],
1074
+ ["useAnimatedScrollHandler", [0]],
1075
+ ["useAnimatedReaction", [0, 1]],
1076
+ ["useWorkletCallback", [0]],
1077
+ ["withTiming", [2]],
1078
+ ["withSpring", [2]],
1079
+ ["withDecay", [1]],
1080
+ ["withRepeat", [3]],
1081
+ ["runOnUI", [0]],
1082
+ ["executeOnUIRuntimeSync", [0]],
1083
+ ...Array.from(gestureHandlerAutoworkletization_1.gestureHandlerBuilderMethods).map((name) => [name, [0]])
1084
+ ]);
1085
+ function processIfAutoworkletizableCallback(path, state) {
1086
+ if ((0, gestureHandlerAutoworkletization_1.isGestureHandlerEventCallback)(path) || (0, layoutAnimationAutoworkletization_1.isLayoutAnimationCallback)(path)) {
1087
+ (0, workletSubstitution_12.processWorklet)(path, state);
1088
+ return true;
1089
+ }
1090
+ return false;
1091
+ }
1092
+ exports2.processIfAutoworkletizableCallback = processIfAutoworkletizableCallback;
1093
+ function processCalleesAutoworkletizableCallbacks(path, state) {
1094
+ const callee = (0, types_12.isSequenceExpression)(path.node.callee) ? path.node.callee.expressions[path.node.callee.expressions.length - 1] : path.node.callee;
1095
+ const name = "name" in callee ? callee.name : "property" in callee && "name" in callee.property ? callee.property.name : void 0;
1096
+ if (name === void 0) {
1097
+ return;
1098
+ }
1099
+ if (reanimatedFunctionHooks.has(name) || reanimatedObjectHooks.has(name)) {
1100
+ const acceptWorkletizableFunction = reanimatedFunctionHooks.has(name);
1101
+ const acceptObject = reanimatedObjectHooks.has(name);
1102
+ const argIndices = reanimatedFunctionArgsToWorkletize.get(name);
1103
+ const args = path.get("arguments").filter((_, index) => argIndices.includes(index));
1104
+ processArgs(args, state, acceptWorkletizableFunction, acceptObject);
1105
+ } else if (!(0, types_12.isV8IntrinsicIdentifier)(callee) && (0, gestureHandlerAutoworkletization_1.isGestureObjectEventCallbackMethod)(callee)) {
1106
+ const args = path.get("arguments");
1107
+ processArgs(args, state, true, true);
1108
+ }
1109
+ }
1110
+ exports2.processCalleesAutoworkletizableCallbacks = processCalleesAutoworkletizableCallbacks;
1111
+ function processArgs(args, state, acceptWorkletizableFunction, acceptObject) {
1112
+ args.forEach((arg) => {
1113
+ const maybeWorklet = findWorklet(arg, acceptWorkletizableFunction, acceptObject);
1114
+ if (!maybeWorklet) {
1115
+ return;
1116
+ }
1117
+ if ((0, types_2.isWorkletizableFunctionPath)(maybeWorklet)) {
1118
+ (0, workletSubstitution_12.processWorklet)(maybeWorklet, state);
1119
+ } else if ((0, types_2.isWorkletizableObjectPath)(maybeWorklet)) {
1120
+ (0, objectWorklets_1.processWorkletizableObject)(maybeWorklet, state);
1121
+ }
1122
+ });
1123
+ }
1124
+ function findWorklet(arg, acceptWorkletizableFunction, acceptObject) {
1125
+ if (acceptWorkletizableFunction && (0, types_2.isWorkletizableFunctionPath)(arg)) {
1126
+ return arg;
1127
+ }
1128
+ if (acceptObject && (0, types_2.isWorkletizableObjectPath)(arg)) {
1129
+ return arg;
1130
+ }
1131
+ if (arg.isIdentifier() && arg.isReferencedIdentifier()) {
1132
+ return (0, referencedWorklets_1.findReferencedWorklet)(arg, acceptWorkletizableFunction, acceptObject);
1133
+ }
1134
+ return void 0;
1135
+ }
1136
+ }
1137
+ });
1138
+
1139
+ // lib/class.js
1140
+ var require_class = __commonJS({
1141
+ "lib/class.js"(exports2) {
1142
+ "use strict";
1143
+ var __importDefault = exports2 && exports2.__importDefault || function(mod) {
1144
+ return mod && mod.__esModule ? mod : { "default": mod };
1145
+ };
1146
+ Object.defineProperty(exports2, "__esModule", { value: true });
1147
+ exports2.processIfWorkletClass = void 0;
1148
+ var generator_1 = __importDefault(require("@babel/generator"));
1149
+ var traverse_1 = __importDefault(require("@babel/traverse"));
1150
+ var types_12 = require("@babel/types");
1151
+ var assert_1 = require("assert");
1152
+ var transform_1 = require_transform();
1153
+ var types_2 = require_types();
1154
+ var utils_1 = require_utils();
1155
+ var classWorkletMarker = "__workletClass";
1156
+ function processIfWorkletClass(classPath, state) {
1157
+ if (!isWorkletizableClass(classPath, state)) {
1158
+ return false;
1159
+ }
1160
+ removeWorkletClassMarker(classPath.node.body);
1161
+ processClass(classPath, state);
1162
+ return true;
1163
+ }
1164
+ exports2.processIfWorkletClass = processIfWorkletClass;
1165
+ function processClass(classPath, state) {
1166
+ (0, assert_1.strict)(classPath.node.id);
1167
+ const className = classPath.node.id.name;
1168
+ const polyfilledClassAst = getPolyfilledAst(classPath.node, state);
1169
+ sortPolyfills(polyfilledClassAst);
1170
+ appendWorkletDirectiveToPolyfills(polyfilledClassAst.program.body);
1171
+ replaceClassDeclarationWithFactoryAndCall(polyfilledClassAst.program.body, className);
1172
+ polyfilledClassAst.program.body.push((0, types_12.returnStatement)((0, types_12.identifier)(className)));
1173
+ const factoryFactory = (0, types_12.functionExpression)(null, [], (0, types_12.blockStatement)([...polyfilledClassAst.program.body]));
1174
+ const factoryCall = (0, types_12.callExpression)(factoryFactory, []);
1175
+ (0, utils_1.replaceWithFactoryCall)(classPath, className, factoryCall);
1176
+ }
1177
+ function getPolyfilledAst(classNode, state) {
1178
+ var _a;
1179
+ const classCode = (0, generator_1.default)(classNode).code;
1180
+ const classWithPolyfills = (0, transform_1.workletTransformSync)(classCode, {
1181
+ extraPlugins: [
1182
+ "@babel/plugin-transform-class-properties",
1183
+ "@babel/plugin-transform-classes",
1184
+ "@babel/plugin-transform-unicode-regex",
1185
+ ...(_a = state.opts.extraPlugins) !== null && _a !== void 0 ? _a : []
1186
+ ],
1187
+ extraPresets: state.opts.extraPresets,
1188
+ filename: state.file.opts.filename,
1189
+ ast: true,
1190
+ babelrc: false,
1191
+ configFile: false
1192
+ });
1193
+ (0, assert_1.strict)(classWithPolyfills && classWithPolyfills.ast);
1194
+ return classWithPolyfills.ast;
1195
+ }
1196
+ function appendWorkletDirectiveToPolyfills(statements) {
1197
+ statements.forEach((statement) => {
1198
+ if ((0, types_12.isFunctionDeclaration)(statement)) {
1199
+ const workletDirective = (0, types_12.directive)((0, types_12.directiveLiteral)("worklet"));
1200
+ statement.body.directives.push(workletDirective);
1201
+ }
1202
+ });
1203
+ }
1204
+ function replaceClassDeclarationWithFactoryAndCall(statements, className) {
1205
+ const classFactoryName = className + types_2.workletClassFactorySuffix;
1206
+ const classDeclarationIndex = getPolyfilledClassDeclarationIndex(statements, className);
1207
+ const classDeclarationToReplace = statements[classDeclarationIndex];
1208
+ const classDeclarationInit = classDeclarationToReplace.declarations[0].init;
1209
+ const classFactoryDeclaration = (0, types_12.functionDeclaration)((0, types_12.identifier)(classFactoryName), [], (0, types_12.blockStatement)([
1210
+ (0, types_12.variableDeclaration)("const", [
1211
+ (0, types_12.variableDeclarator)((0, types_12.identifier)(className), classDeclarationInit)
1212
+ ]),
1213
+ (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(className), (0, types_12.identifier)(classFactoryName)), (0, types_12.identifier)(classFactoryName))),
1214
+ (0, types_12.returnStatement)((0, types_12.identifier)(className))
1215
+ ], [(0, types_12.directive)((0, types_12.directiveLiteral)("worklet"))]));
1216
+ const newClassDeclaration = (0, types_12.variableDeclaration)("const", [
1217
+ (0, types_12.variableDeclarator)((0, types_12.identifier)(className), (0, types_12.callExpression)((0, types_12.identifier)(classFactoryName), []))
1218
+ ]);
1219
+ statements.splice(classDeclarationIndex, 1, classFactoryDeclaration, newClassDeclaration);
1220
+ }
1221
+ function getPolyfilledClassDeclarationIndex(statements, className) {
1222
+ const index = statements.findIndex((statement) => (0, types_12.isVariableDeclaration)(statement) && statement.declarations.some((declaration) => (0, types_12.isIdentifier)(declaration.id) && declaration.id.name === className));
1223
+ (0, assert_1.strict)(index >= 0);
1224
+ return index;
1225
+ }
1226
+ function hasWorkletClassMarker(classBody) {
1227
+ return classBody.body.some((statement) => (0, types_12.isClassProperty)(statement) && (0, types_12.isIdentifier)(statement.key) && statement.key.name === classWorkletMarker);
1228
+ }
1229
+ function removeWorkletClassMarker(classBody) {
1230
+ classBody.body = classBody.body.filter((statement) => !(0, types_12.isClassProperty)(statement) || !(0, types_12.isIdentifier)(statement.key) || statement.key.name !== classWorkletMarker);
1231
+ }
1232
+ function sortPolyfills(ast) {
1233
+ const toSort = getPolyfillsToSort(ast);
1234
+ const sorted = topoSort(toSort);
1235
+ const toSortIndices = toSort.map((element) => element.index);
1236
+ const sortedIndices = sorted.map((element) => element.index);
1237
+ const statements = ast.program.body;
1238
+ const oldStatements = [...statements];
1239
+ for (let i = 0; i < toSort.length; i++) {
1240
+ const sourceIndex = sortedIndices[i];
1241
+ const targetIndex = toSortIndices[i];
1242
+ const source = oldStatements[sourceIndex];
1243
+ statements[targetIndex] = source;
1244
+ }
1245
+ }
1246
+ function getPolyfillsToSort(ast) {
1247
+ const polyfills = [];
1248
+ (0, traverse_1.default)(ast, {
1249
+ Program: {
1250
+ enter: (functionPath) => {
1251
+ const statements = functionPath.get("body");
1252
+ statements.forEach((statement, index) => {
1253
+ var _a;
1254
+ const bindingIdentifiers = statement.getBindingIdentifiers();
1255
+ if (!statement.isFunctionDeclaration() || !((_a = statement.node.id) === null || _a === void 0 ? void 0 : _a.name)) {
1256
+ return;
1257
+ }
1258
+ const element = {
1259
+ name: statement.node.id.name,
1260
+ index,
1261
+ dependencies: /* @__PURE__ */ new Set()
1262
+ };
1263
+ polyfills.push(element);
1264
+ statement.traverse({
1265
+ Identifier(path) {
1266
+ if (isOutsideDependency(path, bindingIdentifiers, statement)) {
1267
+ element.dependencies.add(path.node.name);
1268
+ }
1269
+ }
1270
+ });
1271
+ });
1272
+ }
1273
+ }
1274
+ });
1275
+ return polyfills;
1276
+ }
1277
+ function topoSort(toSort) {
1278
+ const sorted = [];
1279
+ const stack = /* @__PURE__ */ new Set();
1280
+ for (const element of toSort) {
1281
+ recursiveTopoSort(element, toSort, sorted, stack);
1282
+ }
1283
+ return sorted;
1284
+ }
1285
+ function recursiveTopoSort(current, toSort, sorted, stack) {
1286
+ if (stack.has(current.name)) {
1287
+ throw new Error("Cycle detected. This should never happen.");
1288
+ }
1289
+ if (sorted.find((element) => element.name === current.name)) {
1290
+ return;
1291
+ }
1292
+ stack.add(current.name);
1293
+ for (const dependency of current.dependencies) {
1294
+ if (!sorted.find((element) => element.name === dependency)) {
1295
+ const next = toSort.find((element) => element.name === dependency);
1296
+ (0, assert_1.strict)(next);
1297
+ recursiveTopoSort(next, toSort, sorted, stack);
1298
+ }
1299
+ }
1300
+ sorted.push(current);
1301
+ stack.delete(current.name);
1302
+ }
1303
+ function isOutsideDependency(identifierPath, bindingIdentifiers, functionPath) {
1304
+ return identifierPath.isReferencedIdentifier() && !(identifierPath.node.name in bindingIdentifiers) && !functionPath.scope.hasOwnBinding(identifierPath.node.name) && functionPath.scope.hasReference(identifierPath.node.name);
1305
+ }
1306
+ function isWorkletizableClass(classPath, state) {
1307
+ var _a;
1308
+ const className = (_a = classPath.node.id) === null || _a === void 0 ? void 0 : _a.name;
1309
+ const classNode = classPath.node;
1310
+ if (!className) {
1311
+ return false;
1312
+ }
1313
+ const isMarked = hasWorkletClassMarker(classNode.body);
1314
+ const isMemoizedNode = state.classesToWorkletize.some((record) => record.node === classNode);
1315
+ const isTopLevelMemoizedName = classPath.parentPath.isProgram() && state.classesToWorkletize.some((record) => record.name === className);
1316
+ state.classesToWorkletize = state.classesToWorkletize.filter((record) => record.node !== classNode && record.name !== className);
1317
+ const result = isMarked || isMemoizedNode || isTopLevelMemoizedName;
1318
+ return result;
1319
+ }
1320
+ }
1321
+ });
1322
+
1323
+ // lib/contextObject.js
1324
+ var require_contextObject = __commonJS({
1325
+ "lib/contextObject.js"(exports2) {
1326
+ "use strict";
1327
+ Object.defineProperty(exports2, "__esModule", { value: true });
1328
+ exports2.isContextObject = exports2.processIfWorkletContextObject = exports2.contextObjectMarker = void 0;
1329
+ var types_12 = require("@babel/types");
1330
+ exports2.contextObjectMarker = "__workletContextObject";
1331
+ function processIfWorkletContextObject(path, _state) {
1332
+ if (!isContextObject(path.node)) {
1333
+ return false;
1334
+ }
1335
+ removeContextObjectMarker(path.node);
1336
+ processWorkletContextObject(path.node);
1337
+ return true;
1338
+ }
1339
+ exports2.processIfWorkletContextObject = processIfWorkletContextObject;
1340
+ function isContextObject(objectExpression) {
1341
+ return objectExpression.properties.some((property) => (0, types_12.isObjectProperty)(property) && (0, types_12.isIdentifier)(property.key) && property.key.name === exports2.contextObjectMarker);
1342
+ }
1343
+ exports2.isContextObject = isContextObject;
1344
+ function processWorkletContextObject(objectExpression) {
1345
+ const workletObjectFactory = (0, types_12.functionExpression)(null, [], (0, types_12.blockStatement)([(0, types_12.returnStatement)((0, types_12.cloneNode)(objectExpression))], [(0, types_12.directive)((0, types_12.directiveLiteral)("worklet"))]));
1346
+ objectExpression.properties.push((0, types_12.objectProperty)((0, types_12.identifier)(`${exports2.contextObjectMarker}Factory`), workletObjectFactory));
1347
+ }
1348
+ function removeContextObjectMarker(objectExpression) {
1349
+ objectExpression.properties = objectExpression.properties.filter((property) => !((0, types_12.isObjectProperty)(property) && (0, types_12.isIdentifier)(property.key) && property.key.name === exports2.contextObjectMarker));
1350
+ }
1351
+ }
1352
+ });
1353
+
1354
+ // lib/file.js
1355
+ var require_file = __commonJS({
1356
+ "lib/file.js"(exports2) {
1357
+ "use strict";
1358
+ Object.defineProperty(exports2, "__esModule", { value: true });
1359
+ exports2.isImplicitContextObject = exports2.processIfWorkletFile = void 0;
1360
+ var types_12 = require("@babel/types");
1361
+ var contextObject_12 = require_contextObject();
1362
+ var types_2 = require_types();
1363
+ function processIfWorkletFile(path, state) {
1364
+ if (!path.node.directives.some((functionDirective) => functionDirective.value.value === "worklet")) {
1365
+ return false;
1366
+ }
1367
+ path.node.directives = path.node.directives.filter((functionDirective) => functionDirective.value.value !== "worklet");
1368
+ processWorkletFile(path, state);
1369
+ return true;
1370
+ }
1371
+ exports2.processIfWorkletFile = processIfWorkletFile;
1372
+ function processWorkletFile(programPath, state) {
1373
+ const statements = programPath.get("body");
1374
+ dehoistCommonJSExports(programPath.node);
1375
+ statements.forEach((statement) => {
1376
+ const candidatePath = getCandidate(statement);
1377
+ processWorkletizableEntity(candidatePath, state);
1378
+ });
1379
+ }
1380
+ function getCandidate(statementPath) {
1381
+ if (statementPath.isExportNamedDeclaration() || statementPath.isExportDefaultDeclaration()) {
1382
+ return statementPath.get("declaration");
1383
+ } else {
1384
+ return statementPath;
1385
+ }
1386
+ }
1387
+ function processWorkletizableEntity(nodePath, state) {
1388
+ var _a;
1389
+ if ((0, types_2.isWorkletizableFunctionPath)(nodePath)) {
1390
+ if (nodePath.isArrowFunctionExpression()) {
1391
+ replaceImplicitReturnWithBlock(nodePath.node);
1392
+ }
1393
+ appendWorkletDirective(nodePath.node.body);
1394
+ } else if ((0, types_2.isWorkletizableObjectPath)(nodePath)) {
1395
+ if (isImplicitContextObject(nodePath)) {
1396
+ appendWorkletContextObjectMarker(nodePath.node);
1397
+ } else {
1398
+ processWorkletAggregator(nodePath, state);
1399
+ }
1400
+ } else if (nodePath.isVariableDeclaration()) {
1401
+ processVariableDeclaration(nodePath, state);
1402
+ } else if (nodePath.isClassDeclaration()) {
1403
+ appendWorkletClassMarker(nodePath.node.body);
1404
+ if ((_a = nodePath.node.id) === null || _a === void 0 ? void 0 : _a.name) {
1405
+ state.classesToWorkletize.push({
1406
+ node: nodePath.node,
1407
+ name: nodePath.node.id.name
1408
+ });
1409
+ }
1410
+ }
1411
+ }
1412
+ function processVariableDeclaration(variableDeclarationPath, state) {
1413
+ const declarations = variableDeclarationPath.get("declarations");
1414
+ declarations.forEach((declaration) => {
1415
+ const initPath = declaration.get("init");
1416
+ if (initPath.isExpression()) {
1417
+ processWorkletizableEntity(initPath, state);
1418
+ }
1419
+ });
1420
+ }
1421
+ function processWorkletAggregator(objectPath, state) {
1422
+ const properties = objectPath.get("properties");
1423
+ properties.forEach((property) => {
1424
+ if (property.isObjectMethod()) {
1425
+ appendWorkletDirective(property.node.body);
1426
+ } else if (property.isObjectProperty()) {
1427
+ const valuePath = property.get("value");
1428
+ processWorkletizableEntity(valuePath, state);
1429
+ }
1430
+ });
1431
+ }
1432
+ function replaceImplicitReturnWithBlock(path) {
1433
+ if (!(0, types_12.isBlockStatement)(path.body)) {
1434
+ path.body = (0, types_12.blockStatement)([(0, types_12.returnStatement)(path.body)]);
1435
+ }
1436
+ }
1437
+ function appendWorkletDirective(node) {
1438
+ if (!node.directives.some((functionDirective) => functionDirective.value.value === "worklet")) {
1439
+ node.directives.push((0, types_12.directive)((0, types_12.directiveLiteral)("worklet")));
1440
+ }
1441
+ }
1442
+ function appendWorkletContextObjectMarker(objectExpression) {
1443
+ if (objectExpression.properties.some((value) => (0, types_12.isObjectProperty)(value) && (0, types_12.isIdentifier)(value.key) && value.key.name === contextObject_12.contextObjectMarker)) {
1444
+ return;
1445
+ }
1446
+ objectExpression.properties.push((0, types_12.objectProperty)((0, types_12.identifier)(`${contextObject_12.contextObjectMarker}`), (0, types_12.booleanLiteral)(true)));
1447
+ }
1448
+ function isImplicitContextObject(path) {
1449
+ const propertyPaths = path.get("properties");
1450
+ return propertyPaths.some((propertyPath) => {
1451
+ if (!propertyPath.isObjectMethod()) {
1452
+ return false;
1453
+ }
1454
+ return hasThisExpression(propertyPath);
1455
+ });
1456
+ }
1457
+ exports2.isImplicitContextObject = isImplicitContextObject;
1458
+ function hasThisExpression(path) {
1459
+ let result = false;
1460
+ path.traverse({
1461
+ ThisExpression(thisPath) {
1462
+ result = true;
1463
+ thisPath.stop();
1464
+ }
1465
+ });
1466
+ return result;
1467
+ }
1468
+ function appendWorkletClassMarker(classBody) {
1469
+ classBody.body.push((0, types_12.classProperty)((0, types_12.identifier)("__workletClass"), (0, types_12.booleanLiteral)(true)));
1470
+ }
1471
+ function dehoistCommonJSExports(program) {
1472
+ const statements = program.body;
1473
+ let end = statements.length;
1474
+ let current = 0;
1475
+ while (current < end) {
1476
+ const statement = statements[current];
1477
+ if (!isCommonJSExport(statement)) {
1478
+ current++;
1479
+ continue;
1480
+ }
1481
+ const exportStatement = statements.splice(current, 1);
1482
+ statements.push(...exportStatement);
1483
+ end--;
1484
+ }
1485
+ }
1486
+ function isCommonJSExport(statement) {
1487
+ return (0, types_12.isExpressionStatement)(statement) && (0, types_12.isAssignmentExpression)(statement.expression) && (0, types_12.isMemberExpression)(statement.expression.left) && (0, types_12.isIdentifier)(statement.expression.left.object) && statement.expression.left.object.name === "exports";
1488
+ }
1489
+ }
1490
+ });
1491
+
1492
+ // lib/inlineStylesWarning.js
1493
+ var require_inlineStylesWarning = __commonJS({
1494
+ "lib/inlineStylesWarning.js"(exports2) {
1495
+ "use strict";
1496
+ Object.defineProperty(exports2, "__esModule", { value: true });
1497
+ exports2.processInlineStylesWarning = void 0;
1498
+ var types_12 = require("@babel/types");
1499
+ var assert_1 = require("assert");
1500
+ var utils_1 = require_utils();
1501
+ function generateInlineStylesWarning(path) {
1502
+ return (0, types_12.callExpression)((0, types_12.arrowFunctionExpression)([], (0, types_12.blockStatement)([
1503
+ (0, types_12.expressionStatement)((0, types_12.callExpression)((0, types_12.memberExpression)((0, types_12.identifier)("console"), (0, types_12.identifier)("warn")), [
1504
+ (0, types_12.callExpression)((0, types_12.memberExpression)((0, types_12.callExpression)((0, types_12.identifier)("require"), [
1505
+ (0, types_12.stringLiteral)("react-native-reanimated")
1506
+ ]), (0, types_12.identifier)("getUseOfValueInStyleWarning")), [])
1507
+ ])),
1508
+ (0, types_12.returnStatement)(path.node)
1509
+ ])), []);
1510
+ }
1511
+ function processPropertyValueForInlineStylesWarning(path) {
1512
+ if (path.isMemberExpression() && (0, types_12.isIdentifier)(path.node.property)) {
1513
+ if (path.node.property.name === "value") {
1514
+ path.replaceWith(generateInlineStylesWarning(path));
1515
+ }
1516
+ }
1517
+ }
1518
+ function processTransformPropertyForInlineStylesWarning(path) {
1519
+ if ((0, types_12.isArrayExpression)(path.node)) {
1520
+ const elements = path.get("elements");
1521
+ (0, assert_1.strict)(Array.isArray(elements), "[Reanimated] `elements` should be an array.");
1522
+ for (const element of elements) {
1523
+ if (element.isObjectExpression()) {
1524
+ processStyleObjectForInlineStylesWarning(element);
1525
+ }
1526
+ }
1527
+ }
1528
+ }
1529
+ function processStyleObjectForInlineStylesWarning(path) {
1530
+ const properties = path.get("properties");
1531
+ for (const property of properties) {
1532
+ if (property.isObjectProperty()) {
1533
+ const value = property.get("value");
1534
+ if ((0, types_12.isIdentifier)(property.node.key) && property.node.key.name === "transform") {
1535
+ processTransformPropertyForInlineStylesWarning(value);
1536
+ } else {
1537
+ processPropertyValueForInlineStylesWarning(value);
1538
+ }
1539
+ }
1540
+ }
1541
+ }
1542
+ function processInlineStylesWarning(path, state) {
1543
+ if ((0, utils_1.isRelease)()) {
1544
+ return;
1545
+ }
1546
+ if (state.opts.disableInlineStylesWarning) {
1547
+ return;
1548
+ }
1549
+ if (path.node.name.name !== "style") {
1550
+ return;
1551
+ }
1552
+ if (!(0, types_12.isJSXExpressionContainer)(path.node.value)) {
1553
+ return;
1554
+ }
1555
+ const expression = path.get("value").get("expression");
1556
+ (0, assert_1.strict)(!Array.isArray(expression), "[Reanimated] `expression` should not be an array.");
1557
+ if (expression.isArrayExpression()) {
1558
+ const elements = expression.get("elements");
1559
+ (0, assert_1.strict)(Array.isArray(elements), "[Reanimated] `elements` should be an array.");
1560
+ for (const element of elements) {
1561
+ if (element.isObjectExpression()) {
1562
+ processStyleObjectForInlineStylesWarning(element);
1563
+ }
1564
+ }
1565
+ } else if (expression.isObjectExpression()) {
1566
+ processStyleObjectForInlineStylesWarning(expression);
1567
+ }
1568
+ }
1569
+ exports2.processInlineStylesWarning = processInlineStylesWarning;
1570
+ }
1571
+ });
1572
+
1573
+ // lib/webOptimization.js
1574
+ var require_webOptimization = __commonJS({
1575
+ "lib/webOptimization.js"(exports2) {
1576
+ "use strict";
1577
+ Object.defineProperty(exports2, "__esModule", { value: true });
1578
+ exports2.substituteWebCallExpression = void 0;
1579
+ var types_12 = require("@babel/types");
1580
+ function substituteWebCallExpression(path) {
1581
+ const callee = path.node.callee;
1582
+ if ((0, types_12.isIdentifier)(callee)) {
1583
+ const name = callee.name;
1584
+ if (name === "isWeb" || name === "shouldBeUseWeb") {
1585
+ path.replaceWith((0, types_12.booleanLiteral)(true));
1586
+ }
1587
+ }
1588
+ }
1589
+ exports2.substituteWebCallExpression = substituteWebCallExpression;
1590
+ }
1591
+ });
1592
+
1593
+ // lib/plugin.js
1594
+ Object.defineProperty(exports, "__esModule", { value: true });
1595
+ var autoworkletization_1 = require_autoworkletization();
1596
+ var class_1 = require_class();
1597
+ var contextObject_1 = require_contextObject();
1598
+ var file_1 = require_file();
1599
+ var globals_1 = require_globals();
1600
+ var inlineStylesWarning_1 = require_inlineStylesWarning();
1601
+ var types_1 = require_types();
1602
+ var webOptimization_1 = require_webOptimization();
1603
+ var workletSubstitution_1 = require_workletSubstitution();
1604
+ module.exports = function() {
1605
+ function runWithTaggedExceptions(fun) {
1606
+ try {
1607
+ fun();
1608
+ } catch (e) {
1609
+ throw new Error(`[Reanimated] Babel plugin exception: ${e}`);
1610
+ }
1611
+ }
1612
+ return {
1613
+ name: "reanimated",
1614
+ pre() {
1615
+ runWithTaggedExceptions(() => {
1616
+ (0, globals_1.initializeState)(this);
1617
+ });
1618
+ },
1619
+ visitor: {
1620
+ CallExpression: {
1621
+ enter(path, state) {
1622
+ runWithTaggedExceptions(() => {
1623
+ (0, autoworkletization_1.processCalleesAutoworkletizableCallbacks)(path, state);
1624
+ if (state.opts.substituteWebPlatformChecks) {
1625
+ (0, webOptimization_1.substituteWebCallExpression)(path);
1626
+ }
1627
+ });
1628
+ }
1629
+ },
1630
+ [types_1.WorkletizableFunction]: {
1631
+ enter(path, state) {
1632
+ runWithTaggedExceptions(() => {
1633
+ (0, workletSubstitution_1.processIfWithWorkletDirective)(path, state) || (0, autoworkletization_1.processIfAutoworkletizableCallback)(path, state);
1634
+ });
1635
+ }
1636
+ },
1637
+ ObjectExpression: {
1638
+ enter(path, state) {
1639
+ runWithTaggedExceptions(() => {
1640
+ (0, contextObject_1.processIfWorkletContextObject)(path, state);
1641
+ });
1642
+ }
1643
+ },
1644
+ ClassDeclaration: {
1645
+ enter(path, state) {
1646
+ runWithTaggedExceptions(() => {
1647
+ (0, class_1.processIfWorkletClass)(path, state);
1648
+ });
1649
+ }
1650
+ },
1651
+ Program: {
1652
+ enter(path, state) {
1653
+ runWithTaggedExceptions(() => {
1654
+ (0, file_1.processIfWorkletFile)(path, state);
1655
+ });
1656
+ }
1657
+ },
1658
+ JSXAttribute: {
1659
+ enter(path, state) {
1660
+ runWithTaggedExceptions(() => (0, inlineStylesWarning_1.processInlineStylesWarning)(path, state));
1661
+ }
1662
+ }
1663
+ }
1664
+ };
1665
+ };
3
1666
  //# sourceMappingURL=index.js.map