@vxrn/compiler 2.0.0-beta.127.1 → 2.0.0-beta.129.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -247,7 +247,7 @@ function findWorkletCandidates(program) {
247
247
  node: node.method ? node : fn,
248
248
  fnNode: fn,
249
249
  kind: node.method ? "object_method" : fn.type === "ArrowFunctionExpression" ? "arrow_function" : "function_expression",
250
- name: node.key?.name,
250
+ name: node.method ? node.key?.name : fn.id?.name,
251
251
  parent,
252
252
  isAutoWorklet: false
253
253
  });
@@ -292,7 +292,7 @@ function findWorkletCandidates(program) {
292
292
  node: prop.value,
293
293
  fnNode: prop.value,
294
294
  kind: prop.value.type === "ArrowFunctionExpression" ? "arrow_function" : "function_expression",
295
- name: prop.key?.name,
295
+ name: prop.value.id?.name,
296
296
  parent: prop,
297
297
  isAutoWorklet: true
298
298
  });
@@ -216,7 +216,7 @@ function findWorkletCandidates(program) {
216
216
  node: node.method ? node : fn,
217
217
  fnNode: fn,
218
218
  kind: node.method ? "object_method" : fn.type === "ArrowFunctionExpression" ? "arrow_function" : "function_expression",
219
- name: node.key?.name,
219
+ name: node.method ? node.key?.name : fn.id?.name,
220
220
  parent,
221
221
  isAutoWorklet: false
222
222
  });
@@ -261,7 +261,7 @@ function findWorkletCandidates(program) {
261
261
  node: prop.value,
262
262
  fnNode: prop.value,
263
263
  kind: prop.value.type === "ArrowFunctionExpression" ? "arrow_function" : "function_expression",
264
- name: prop.key?.name,
264
+ name: prop.value.id?.name,
265
265
  parent: prop,
266
266
  isAutoWorklet: true
267
267
  });
@@ -1 +1 @@
1
- {"version":3,"file":"autoworklet.js","names":[],"sources":["esm/worklets/autoworklet.js"],"sourcesContent":["const AUTOWORKLET_FUNCTION_ARGS = Object.assign(\n /* @__PURE__ */ Object.create(null),\n {\n useFrameCallback: [0],\n useAnimatedStyle: [0],\n useAnimatedProps: [0],\n createAnimatedPropAdapter: [0],\n useDerivedValue: [0],\n useAnimatedScrollHandler: [0],\n useAnimatedGestureHandler: [0],\n useAnimatedReaction: [0, 1],\n withTiming: [2],\n withSpring: [2],\n withDecay: [1],\n withRepeat: [3],\n runOnUI: [0],\n executeOnUIRuntimeSync: [0],\n scheduleOnUI: [0],\n runOnUISync: [0],\n runOnUIAsync: [0],\n runOnRuntime: [1],\n runOnRuntimeSync: [1],\n runOnRuntimeAsync: [1],\n scheduleOnRuntime: [1],\n runOnRuntimeSyncWithId: [1],\n scheduleOnRuntimeWithId: [1],\n useTapGesture: [0],\n usePanGesture: [0],\n usePinchGesture: [0],\n useRotationGesture: [0],\n useFlingGesture: [0],\n useLongPressGesture: [0],\n useNativeGesture: [0],\n useManualGesture: [0],\n useHoverGesture: [0]\n }\n);\nconst GESTURE_BUILDER_METHODS = /* @__PURE__ */ new Set([\n \"onBegin\",\n \"onStart\",\n \"onEnd\",\n \"onFinalize\",\n \"onUpdate\",\n \"onChange\",\n \"onTouchesDown\",\n \"onTouchesMove\",\n \"onTouchesUp\",\n \"onTouchesCancelled\"\n]);\nconst GESTURE_KINDS = /* @__PURE__ */ new Set([\n \"Tap\",\n \"Pan\",\n \"Pinch\",\n \"Rotation\",\n \"Fling\",\n \"LongPress\",\n \"ForceTouch\",\n \"Native\",\n \"Manual\",\n \"Race\",\n \"Simultaneous\",\n \"Exclusive\",\n \"Hover\"\n]);\nconst LAYOUT_ANIMATIONS = new Set(\n `BounceIn BounceInDown BounceInLeft BounceInRight BounceInUp BounceOut BounceOutDown\n BounceOutLeft BounceOutRight BounceOutUp FadeIn FadeInDown FadeInLeft FadeInRight FadeInUp\n FadeOut FadeOutDown FadeOutLeft FadeOutRight FadeOutUp FlipInEasyX FlipInEasyY FlipInXDown\n FlipInXUp FlipInYLeft FlipInYRight FlipOutEasyX FlipOutEasyY FlipOutXDown FlipOutXUp\n FlipOutYLeft FlipOutYRight LightSpeedInLeft LightSpeedInRight LightSpeedOutLeft\n LightSpeedOutRight PinwheelIn PinwheelOut RollInLeft RollInRight RollOutLeft RollOutRight\n RotateInDownLeft RotateInDownRight RotateInUpLeft RotateInUpRight RotateOutDownLeft\n RotateOutDownRight RotateOutUpLeft RotateOutUpRight SlideInDown SlideInLeft SlideInRight\n SlideInUp SlideOutDown SlideOutLeft SlideOutRight SlideOutUp StretchInX StretchInY\n StretchOutX StretchOutY ZoomIn ZoomInDown ZoomInEasyDown ZoomInEasyUp ZoomInLeft ZoomInRight\n ZoomInRotate ZoomInUp ZoomOut ZoomOutDown ZoomOutEasyDown ZoomOutEasyUp ZoomOutLeft\n ZoomOutRight ZoomOutRotate ZoomOutUp Layout LinearTransition SequencedTransition\n FadingTransition JumpingTransition CurvedTransition EntryExitTransition`.split(/\\s+/)\n);\nconst LAYOUT_ANIMATION_CHAIN_METHODS = /* @__PURE__ */ new Set([\n \"build\",\n \"duration\",\n \"delay\",\n \"getDuration\",\n \"randomDelay\",\n \"getDelay\",\n \"getDelayFunction\",\n \"easing\",\n \"rotate\",\n \"springify\",\n \"damping\",\n \"mass\",\n \"stiffness\",\n \"overshootClamping\",\n \"energyThreshold\",\n \"restDisplacementThreshold\",\n \"restSpeedThreshold\",\n \"withInitialValues\",\n \"getAnimationAndConfig\",\n \"easingX\",\n \"easingY\",\n \"easingWidth\",\n \"easingHeight\",\n \"entering\",\n \"exiting\",\n \"reverse\"\n]);\nfunction isGestureObject(exp) {\n return exp?.type === \"CallExpression\" && exp.callee?.type === \"MemberExpression\" && exp.callee.object?.type === \"Identifier\" && exp.callee.object.name === \"Gesture\" && exp.callee.property?.type === \"Identifier\" && GESTURE_KINDS.has(exp.callee.property.name);\n}\nfunction containsGestureObject(exp) {\n if (isGestureObject(exp)) return true;\n return exp?.type === \"CallExpression\" && exp.callee?.type === \"MemberExpression\" && containsGestureObject(exp.callee.object);\n}\nfunction isLayoutAnimationChain(exp) {\n if (exp?.type === \"Identifier\" && LAYOUT_ANIMATIONS.has(exp.name)) return true;\n if (exp?.type === \"NewExpression\" && exp.callee?.type === \"Identifier\" && LAYOUT_ANIMATIONS.has(exp.callee.name)) {\n return true;\n }\n return exp?.type === \"CallExpression\" && exp.callee?.type === \"MemberExpression\" && exp.callee.property?.type === \"Identifier\" && LAYOUT_ANIMATION_CHAIN_METHODS.has(exp.callee.property.name) && isLayoutAnimationChain(exp.callee.object);\n}\nfunction isChainedCallback(callee) {\n if (callee?.type !== \"MemberExpression\" || callee.property?.type !== \"Identifier\") {\n return false;\n }\n const name = callee.property.name;\n if (GESTURE_BUILDER_METHODS.has(name)) return containsGestureObject(callee.object);\n if (name === \"withCallback\") return isLayoutAnimationChain(callee.object);\n return false;\n}\nconst WORKLET_DIRECTIVES = [\n \"worklet\",\n \"no-worklet-closure\",\n \"limit-init-data-hoisting\"\n];\nfunction statementDirective(stmt) {\n if (!stmt || stmt.type !== \"ExpressionStatement\") return void 0;\n if (typeof stmt.directive === \"string\") return stmt.directive;\n if (stmt.expression?.type === \"Literal\" && typeof stmt.expression.value === \"string\") {\n return stmt.expression.value;\n }\n return void 0;\n}\nfunction hasDirective(fnNode, directive) {\n if (!fnNode || !fnNode.body) return false;\n if (Array.isArray(fnNode.body.directives)) {\n for (const d of fnNode.body.directives) {\n if (d.directive === directive || d.value === directive) {\n return true;\n }\n }\n }\n if (fnNode.body.type === \"BlockStatement\" && Array.isArray(fnNode.body.body)) {\n for (const stmt of fnNode.body.body) {\n const found = statementDirective(stmt);\n if (found === void 0) break;\n if (found === directive) return true;\n }\n }\n return false;\n}\nfunction hasWorkletDirective(fnNode) {\n return hasDirective(fnNode, \"worklet\");\n}\nfunction bodyStartAfterDirectives(fnNode, code) {\n let start = fnNode.body.start + 1;\n if (fnNode.body.type !== \"BlockStatement\" || !Array.isArray(fnNode.body.body))\n return start;\n for (const stmt of fnNode.body.body) {\n const found = statementDirective(stmt);\n if (found === void 0 || !WORKLET_DIRECTIVES.includes(found)) break;\n start = stmt.end;\n while (start < fnNode.body.end && (code[start] === \";\" || /\\s/.test(code[start]))) {\n start++;\n }\n }\n return start;\n}\nfunction findWorkletCandidates(program) {\n const candidates = [];\n const seenStarts = /* @__PURE__ */ new Set();\n function addCandidate(candidate) {\n const fnStart = candidate.fnNode.start;\n if (seenStarts.has(fnStart)) return;\n seenStarts.add(fnStart);\n candidates.push(candidate);\n }\n function getCalleeName(callee) {\n if (!callee) return null;\n if (callee.type === \"Identifier\") {\n return callee.name;\n }\n if (callee.type === \"MemberExpression\" && !callee.computed && callee.property?.type === \"Identifier\") {\n return callee.property.name;\n }\n return null;\n }\n function walk(node, parent) {\n if (!node || typeof node !== \"object\") return;\n if (node.type === \"FunctionDeclaration\" || node.type === \"FunctionExpression\" || node.type === \"ArrowFunctionExpression\") {\n if (hasWorkletDirective(node)) {\n let kind = \"function_expression\";\n if (node.type === \"FunctionDeclaration\") kind = \"function_declaration\";\n else if (node.type === \"ArrowFunctionExpression\") kind = \"arrow_function\";\n let name = node.id?.name;\n if (!name && parent?.type === \"VariableDeclarator\" && parent.id?.name) {\n name = parent.id.name;\n }\n addCandidate({\n node,\n fnNode: node,\n kind,\n name,\n parent,\n isAutoWorklet: false\n });\n }\n } else if (node.type === \"Property\" && (node.method || node.value?.type === \"FunctionExpression\" || node.value?.type === \"ArrowFunctionExpression\")) {\n const fn = node.value;\n if (hasWorkletDirective(fn)) {\n addCandidate({\n node: node.method ? node : fn,\n fnNode: fn,\n kind: node.method ? \"object_method\" : fn.type === \"ArrowFunctionExpression\" ? \"arrow_function\" : \"function_expression\",\n name: node.key?.name,\n parent,\n isAutoWorklet: false\n });\n }\n }\n if (node.type === \"CallExpression\") {\n const calleeName = getCalleeName(node.callee);\n const argIndices = calleeName ? AUTOWORKLET_FUNCTION_ARGS[calleeName] : void 0;\n const chained = !argIndices && isChainedCallback(node.callee);\n const indices = argIndices ?? (chained ? node.arguments.map((_, i) => i) : void 0);\n if (indices) {\n for (const idx of indices) {\n const arg = node.arguments[idx];\n if (!arg) continue;\n if (arg.type === \"ArrowFunctionExpression\" || arg.type === \"FunctionExpression\") {\n let name = arg.id?.name;\n if (!name && parent?.type === \"VariableDeclarator\" && parent.id?.name) {\n name = parent.id.name;\n }\n addCandidate({\n node: arg,\n fnNode: arg,\n kind: arg.type === \"ArrowFunctionExpression\" ? \"arrow_function\" : \"function_expression\",\n name,\n parent: node,\n isAutoWorklet: true\n });\n } else if (arg.type === \"ObjectExpression\" && Array.isArray(arg.properties)) {\n for (const prop of arg.properties) {\n if (prop.type === \"Property\") {\n if (prop.method) {\n addCandidate({\n node: prop,\n fnNode: prop.value,\n kind: \"object_method\",\n name: prop.key?.name,\n parent: arg,\n isAutoWorklet: true\n });\n } else if (prop.value?.type === \"ArrowFunctionExpression\" || prop.value?.type === \"FunctionExpression\") {\n addCandidate({\n node: prop.value,\n fnNode: prop.value,\n kind: prop.value.type === \"ArrowFunctionExpression\" ? \"arrow_function\" : \"function_expression\",\n name: prop.key?.name,\n parent: prop,\n isAutoWorklet: true\n });\n }\n }\n }\n }\n }\n }\n }\n for (const key of Object.keys(node)) {\n if (key === \"start\" || key === \"end\" || key === \"loc\" || key === \"range\") continue;\n const child = node[key];\n if (Array.isArray(child)) {\n for (const item of child) {\n walk(item, node);\n }\n } else if (child && typeof child === \"object\") {\n walk(child, node);\n }\n }\n }\n walk(program, null);\n return candidates;\n}\nexport {\n AUTOWORKLET_FUNCTION_ARGS,\n GESTURE_BUILDER_METHODS,\n WORKLET_DIRECTIVES,\n bodyStartAfterDirectives,\n findWorkletCandidates,\n hasDirective,\n hasWorkletDirective\n};\n//# sourceMappingURL=autoworklet.js.map\n"],"mappings":";AAAA,MAAM,4BAA4B,OAAO,OACvB,uBAAO,OAAO,IAAI,GAClC;CACE,kBAAkB,CAAC,CAAC;CACpB,kBAAkB,CAAC,CAAC;CACpB,kBAAkB,CAAC,CAAC;CACpB,2BAA2B,CAAC,CAAC;CAC7B,iBAAiB,CAAC,CAAC;CACnB,0BAA0B,CAAC,CAAC;CAC5B,2BAA2B,CAAC,CAAC;CAC7B,qBAAqB,CAAC,GAAG,CAAC;CAC1B,YAAY,CAAC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"autoworklet.js","names":[],"sources":["esm/worklets/autoworklet.js"],"sourcesContent":["const AUTOWORKLET_FUNCTION_ARGS = Object.assign(\n /* @__PURE__ */ Object.create(null),\n {\n useFrameCallback: [0],\n useAnimatedStyle: [0],\n useAnimatedProps: [0],\n createAnimatedPropAdapter: [0],\n useDerivedValue: [0],\n useAnimatedScrollHandler: [0],\n useAnimatedGestureHandler: [0],\n useAnimatedReaction: [0, 1],\n withTiming: [2],\n withSpring: [2],\n withDecay: [1],\n withRepeat: [3],\n runOnUI: [0],\n executeOnUIRuntimeSync: [0],\n scheduleOnUI: [0],\n runOnUISync: [0],\n runOnUIAsync: [0],\n runOnRuntime: [1],\n runOnRuntimeSync: [1],\n runOnRuntimeAsync: [1],\n scheduleOnRuntime: [1],\n runOnRuntimeSyncWithId: [1],\n scheduleOnRuntimeWithId: [1],\n useTapGesture: [0],\n usePanGesture: [0],\n usePinchGesture: [0],\n useRotationGesture: [0],\n useFlingGesture: [0],\n useLongPressGesture: [0],\n useNativeGesture: [0],\n useManualGesture: [0],\n useHoverGesture: [0]\n }\n);\nconst GESTURE_BUILDER_METHODS = /* @__PURE__ */ new Set([\n \"onBegin\",\n \"onStart\",\n \"onEnd\",\n \"onFinalize\",\n \"onUpdate\",\n \"onChange\",\n \"onTouchesDown\",\n \"onTouchesMove\",\n \"onTouchesUp\",\n \"onTouchesCancelled\"\n]);\nconst GESTURE_KINDS = /* @__PURE__ */ new Set([\n \"Tap\",\n \"Pan\",\n \"Pinch\",\n \"Rotation\",\n \"Fling\",\n \"LongPress\",\n \"ForceTouch\",\n \"Native\",\n \"Manual\",\n \"Race\",\n \"Simultaneous\",\n \"Exclusive\",\n \"Hover\"\n]);\nconst LAYOUT_ANIMATIONS = new Set(\n `BounceIn BounceInDown BounceInLeft BounceInRight BounceInUp BounceOut BounceOutDown\n BounceOutLeft BounceOutRight BounceOutUp FadeIn FadeInDown FadeInLeft FadeInRight FadeInUp\n FadeOut FadeOutDown FadeOutLeft FadeOutRight FadeOutUp FlipInEasyX FlipInEasyY FlipInXDown\n FlipInXUp FlipInYLeft FlipInYRight FlipOutEasyX FlipOutEasyY FlipOutXDown FlipOutXUp\n FlipOutYLeft FlipOutYRight LightSpeedInLeft LightSpeedInRight LightSpeedOutLeft\n LightSpeedOutRight PinwheelIn PinwheelOut RollInLeft RollInRight RollOutLeft RollOutRight\n RotateInDownLeft RotateInDownRight RotateInUpLeft RotateInUpRight RotateOutDownLeft\n RotateOutDownRight RotateOutUpLeft RotateOutUpRight SlideInDown SlideInLeft SlideInRight\n SlideInUp SlideOutDown SlideOutLeft SlideOutRight SlideOutUp StretchInX StretchInY\n StretchOutX StretchOutY ZoomIn ZoomInDown ZoomInEasyDown ZoomInEasyUp ZoomInLeft ZoomInRight\n ZoomInRotate ZoomInUp ZoomOut ZoomOutDown ZoomOutEasyDown ZoomOutEasyUp ZoomOutLeft\n ZoomOutRight ZoomOutRotate ZoomOutUp Layout LinearTransition SequencedTransition\n FadingTransition JumpingTransition CurvedTransition EntryExitTransition`.split(/\\s+/)\n);\nconst LAYOUT_ANIMATION_CHAIN_METHODS = /* @__PURE__ */ new Set([\n \"build\",\n \"duration\",\n \"delay\",\n \"getDuration\",\n \"randomDelay\",\n \"getDelay\",\n \"getDelayFunction\",\n \"easing\",\n \"rotate\",\n \"springify\",\n \"damping\",\n \"mass\",\n \"stiffness\",\n \"overshootClamping\",\n \"energyThreshold\",\n \"restDisplacementThreshold\",\n \"restSpeedThreshold\",\n \"withInitialValues\",\n \"getAnimationAndConfig\",\n \"easingX\",\n \"easingY\",\n \"easingWidth\",\n \"easingHeight\",\n \"entering\",\n \"exiting\",\n \"reverse\"\n]);\nfunction isGestureObject(exp) {\n return exp?.type === \"CallExpression\" && exp.callee?.type === \"MemberExpression\" && exp.callee.object?.type === \"Identifier\" && exp.callee.object.name === \"Gesture\" && exp.callee.property?.type === \"Identifier\" && GESTURE_KINDS.has(exp.callee.property.name);\n}\nfunction containsGestureObject(exp) {\n if (isGestureObject(exp)) return true;\n return exp?.type === \"CallExpression\" && exp.callee?.type === \"MemberExpression\" && containsGestureObject(exp.callee.object);\n}\nfunction isLayoutAnimationChain(exp) {\n if (exp?.type === \"Identifier\" && LAYOUT_ANIMATIONS.has(exp.name)) return true;\n if (exp?.type === \"NewExpression\" && exp.callee?.type === \"Identifier\" && LAYOUT_ANIMATIONS.has(exp.callee.name)) {\n return true;\n }\n return exp?.type === \"CallExpression\" && exp.callee?.type === \"MemberExpression\" && exp.callee.property?.type === \"Identifier\" && LAYOUT_ANIMATION_CHAIN_METHODS.has(exp.callee.property.name) && isLayoutAnimationChain(exp.callee.object);\n}\nfunction isChainedCallback(callee) {\n if (callee?.type !== \"MemberExpression\" || callee.property?.type !== \"Identifier\") {\n return false;\n }\n const name = callee.property.name;\n if (GESTURE_BUILDER_METHODS.has(name)) return containsGestureObject(callee.object);\n if (name === \"withCallback\") return isLayoutAnimationChain(callee.object);\n return false;\n}\nconst WORKLET_DIRECTIVES = [\n \"worklet\",\n \"no-worklet-closure\",\n \"limit-init-data-hoisting\"\n];\nfunction statementDirective(stmt) {\n if (!stmt || stmt.type !== \"ExpressionStatement\") return void 0;\n if (typeof stmt.directive === \"string\") return stmt.directive;\n if (stmt.expression?.type === \"Literal\" && typeof stmt.expression.value === \"string\") {\n return stmt.expression.value;\n }\n return void 0;\n}\nfunction hasDirective(fnNode, directive) {\n if (!fnNode || !fnNode.body) return false;\n if (Array.isArray(fnNode.body.directives)) {\n for (const d of fnNode.body.directives) {\n if (d.directive === directive || d.value === directive) {\n return true;\n }\n }\n }\n if (fnNode.body.type === \"BlockStatement\" && Array.isArray(fnNode.body.body)) {\n for (const stmt of fnNode.body.body) {\n const found = statementDirective(stmt);\n if (found === void 0) break;\n if (found === directive) return true;\n }\n }\n return false;\n}\nfunction hasWorkletDirective(fnNode) {\n return hasDirective(fnNode, \"worklet\");\n}\nfunction bodyStartAfterDirectives(fnNode, code) {\n let start = fnNode.body.start + 1;\n if (fnNode.body.type !== \"BlockStatement\" || !Array.isArray(fnNode.body.body))\n return start;\n for (const stmt of fnNode.body.body) {\n const found = statementDirective(stmt);\n if (found === void 0 || !WORKLET_DIRECTIVES.includes(found)) break;\n start = stmt.end;\n while (start < fnNode.body.end && (code[start] === \";\" || /\\s/.test(code[start]))) {\n start++;\n }\n }\n return start;\n}\nfunction findWorkletCandidates(program) {\n const candidates = [];\n const seenStarts = /* @__PURE__ */ new Set();\n function addCandidate(candidate) {\n const fnStart = candidate.fnNode.start;\n if (seenStarts.has(fnStart)) return;\n seenStarts.add(fnStart);\n candidates.push(candidate);\n }\n function getCalleeName(callee) {\n if (!callee) return null;\n if (callee.type === \"Identifier\") {\n return callee.name;\n }\n if (callee.type === \"MemberExpression\" && !callee.computed && callee.property?.type === \"Identifier\") {\n return callee.property.name;\n }\n return null;\n }\n function walk(node, parent) {\n if (!node || typeof node !== \"object\") return;\n if (node.type === \"FunctionDeclaration\" || node.type === \"FunctionExpression\" || node.type === \"ArrowFunctionExpression\") {\n if (hasWorkletDirective(node)) {\n let kind = \"function_expression\";\n if (node.type === \"FunctionDeclaration\") kind = \"function_declaration\";\n else if (node.type === \"ArrowFunctionExpression\") kind = \"arrow_function\";\n let name = node.id?.name;\n if (!name && parent?.type === \"VariableDeclarator\" && parent.id?.name) {\n name = parent.id.name;\n }\n addCandidate({\n node,\n fnNode: node,\n kind,\n name,\n parent,\n isAutoWorklet: false\n });\n }\n } else if (node.type === \"Property\" && (node.method || node.value?.type === \"FunctionExpression\" || node.value?.type === \"ArrowFunctionExpression\")) {\n const fn = node.value;\n if (hasWorkletDirective(fn)) {\n addCandidate({\n node: node.method ? node : fn,\n fnNode: fn,\n kind: node.method ? \"object_method\" : fn.type === \"ArrowFunctionExpression\" ? \"arrow_function\" : \"function_expression\",\n // only a method is named by its key, as upstream's plugin does: a\n // property's function has no binding of that name, so naming it would\n // shadow an outer binding it closes over with the worklet itself.\n name: node.method ? node.key?.name : fn.id?.name,\n parent,\n isAutoWorklet: false\n });\n }\n }\n if (node.type === \"CallExpression\") {\n const calleeName = getCalleeName(node.callee);\n const argIndices = calleeName ? AUTOWORKLET_FUNCTION_ARGS[calleeName] : void 0;\n const chained = !argIndices && isChainedCallback(node.callee);\n const indices = argIndices ?? (chained ? node.arguments.map((_, i) => i) : void 0);\n if (indices) {\n for (const idx of indices) {\n const arg = node.arguments[idx];\n if (!arg) continue;\n if (arg.type === \"ArrowFunctionExpression\" || arg.type === \"FunctionExpression\") {\n let name = arg.id?.name;\n if (!name && parent?.type === \"VariableDeclarator\" && parent.id?.name) {\n name = parent.id.name;\n }\n addCandidate({\n node: arg,\n fnNode: arg,\n kind: arg.type === \"ArrowFunctionExpression\" ? \"arrow_function\" : \"function_expression\",\n name,\n parent: node,\n isAutoWorklet: true\n });\n } else if (arg.type === \"ObjectExpression\" && Array.isArray(arg.properties)) {\n for (const prop of arg.properties) {\n if (prop.type === \"Property\") {\n if (prop.method) {\n addCandidate({\n node: prop,\n fnNode: prop.value,\n kind: \"object_method\",\n name: prop.key?.name,\n parent: arg,\n isAutoWorklet: true\n });\n } else if (prop.value?.type === \"ArrowFunctionExpression\" || prop.value?.type === \"FunctionExpression\") {\n addCandidate({\n node: prop.value,\n fnNode: prop.value,\n kind: prop.value.type === \"ArrowFunctionExpression\" ? \"arrow_function\" : \"function_expression\",\n name: prop.value.id?.name,\n parent: prop,\n isAutoWorklet: true\n });\n }\n }\n }\n }\n }\n }\n }\n for (const key of Object.keys(node)) {\n if (key === \"start\" || key === \"end\" || key === \"loc\" || key === \"range\") continue;\n const child = node[key];\n if (Array.isArray(child)) {\n for (const item of child) {\n walk(item, node);\n }\n } else if (child && typeof child === \"object\") {\n walk(child, node);\n }\n }\n }\n walk(program, null);\n return candidates;\n}\nexport {\n AUTOWORKLET_FUNCTION_ARGS,\n GESTURE_BUILDER_METHODS,\n WORKLET_DIRECTIVES,\n bodyStartAfterDirectives,\n findWorkletCandidates,\n hasDirective,\n hasWorkletDirective\n};\n//# sourceMappingURL=autoworklet.js.map\n"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,IAAI,GAAG;GACnC,IAAI,QAAQ,WAAW,QAAQ,SAAS,QAAQ,SAAS,QAAQ,SAAS;GAC1E,MAAM,QAAQ,KAAK;GACnB,IAAI,MAAM,QAAQ,KAAK,GAAG;IACxB,KAAK,MAAM,QAAQ,OAAO;KACxB,KAAK,MAAM,IAAI;IACjB;GACF,OAAO,IAAI,SAAS,OAAO,UAAU,UAAU;IAC7C,KAAK,OAAO,IAAI;GAClB;EACF;CACF;CACA,KAAK,SAAS,IAAI;CAClB,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vxrn/compiler",
3
- "version": "2.0.0-beta.127.1",
3
+ "version": "2.0.0-beta.129.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",
@@ -36,8 +36,8 @@
36
36
  "@babel/plugin-transform-react-jsx": "^7.27.1",
37
37
  "@babel/plugin-transform-regenerator": "^7.28.4",
38
38
  "@jridgewell/remapping": "^2.3.0",
39
- "@vxrn/utils": "2.0.0-beta.127.1",
40
- "@vxrn/vite-native-client": "2.0.0-beta.127.1",
39
+ "@vxrn/utils": "2.0.0-beta.129.1",
40
+ "@vxrn/vite-native-client": "2.0.0-beta.129.1",
41
41
  "babel-plugin-react-compiler": "^1.0.0",
42
42
  "babel-plugin-syntax-hermes-parser": "^0.36.1",
43
43
  "babel-plugin-transform-flow-enums": "^0.0.2",
@@ -624,6 +624,43 @@ describe('transformWorklets', () => {
624
624
  expect(uiRes).toBe(7)
625
625
  })
626
626
 
627
+ it('captures the outer binding a property worklet shares its key with', async () => {
628
+ // react-native-gesture-handler's NativeProxy: the property worklet calls the
629
+ // module-level host function of the same name. naming the worklet after its
630
+ // key made it capture itself, so serializing its closure never ended.
631
+ const code = `
632
+ const updateConfig = (tag) => tag * 2
633
+ export const proxy = {
634
+ updateConfig: (tag) => {
635
+ 'worklet'
636
+ return updateConfig(tag)
637
+ },
638
+ flush: function (tag) {
639
+ 'worklet'
640
+ return updateConfig(tag) + 1
641
+ },
642
+ }
643
+ `
644
+ const result = await transformWorklets('/app/proxy.ts', code, false)
645
+
646
+ const sandbox = { global: globalThis, exports: {} as any }
647
+ const runner = new Function(
648
+ 'exports',
649
+ 'global',
650
+ result.code.replace('export const proxy', 'exports.proxy')
651
+ )
652
+ runner(sandbox.exports, sandbox.global)
653
+ const { proxy } = sandbox.exports
654
+
655
+ for (const worklet of [proxy.updateConfig, proxy.flush]) {
656
+ expect(worklet.__closure.updateConfig).not.toBe(worklet)
657
+ const reconstructed = eval(`(${worklet.__initData.code})`)
658
+ expect(reconstructed.call({ __closure: worklet.__closure }, 3)).toBe(worklet(3))
659
+ }
660
+ expect(proxy.updateConfig(3)).toBe(6)
661
+ expect(proxy.flush(3)).toBe(7)
662
+ })
663
+
627
664
  it('transforms nested worklets with bottom-up composition', async () => {
628
665
  const code = `
629
666
  export function outer() {
@@ -306,7 +306,10 @@ export function findWorkletCandidates(program: any): WorkletCandidate[] {
306
306
  : fn.type === 'ArrowFunctionExpression'
307
307
  ? 'arrow_function'
308
308
  : 'function_expression',
309
- name: node.key?.name,
309
+ // only a method is named by its key, as upstream's plugin does: a
310
+ // property's function has no binding of that name, so naming it would
311
+ // shadow an outer binding it closes over with the worklet itself.
312
+ name: node.method ? node.key?.name : fn.id?.name,
310
313
  parent,
311
314
  isAutoWorklet: false,
312
315
  })
@@ -368,7 +371,7 @@ export function findWorkletCandidates(program: any): WorkletCandidate[] {
368
371
  prop.value.type === 'ArrowFunctionExpression'
369
372
  ? 'arrow_function'
370
373
  : 'function_expression',
371
- name: prop.key?.name,
374
+ name: prop.value.id?.name,
372
375
  parent: prop,
373
376
  isAutoWorklet: true,
374
377
  })
@@ -1 +1 @@
1
- {"version":3,"file":"autoworklet.d.ts","sourceRoot":"","sources":["../../src/worklets/autoworklet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAK/C,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAoC9D,CAAA;AAOD,eAAO,MAAM,uBAAuB,aAWlC,CAAA;AAoHF,eAAO,MAAM,kBAAkB,UAI9B,CAAA;AAWD,wBAAgB,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAsBpE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAExD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAa1E;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,GAAG,GAAG,gBAAgB,EAAE,CAgKtE"}
1
+ {"version":3,"file":"autoworklet.d.ts","sourceRoot":"","sources":["../../src/worklets/autoworklet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAK/C,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAoC9D,CAAA;AAOD,eAAO,MAAM,uBAAuB,aAWlC,CAAA;AAoHF,eAAO,MAAM,kBAAkB,UAI9B,CAAA;AAWD,wBAAgB,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAsBpE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAExD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAa1E;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,GAAG,GAAG,gBAAgB,EAAE,CAmKtE"}