@vxrn/compiler 1.25.16 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cache.cjs +4 -2
- package/dist/cjs/configure.cjs +9 -1
- package/dist/cjs/index.cjs +87 -5
- package/dist/cjs/reactNativeCodegen.cjs +140 -0
- package/dist/cjs/reactNativeViewConfig.cjs +489 -0
- package/dist/cjs/transformBabel.cjs +15 -20
- package/dist/cjs/transformBabel.test.cjs +260 -0
- package/dist/cjs/transformHermesAsync.cjs +61 -0
- package/dist/cjs/transformHermesLoops.cjs +319 -0
- package/dist/cjs/transformHermesLoops.test.cjs +257 -0
- package/dist/cjs/transformSWC.cjs +110 -138
- package/dist/cjs/transformSWC.test.cjs +117 -0
- package/dist/cjs/transformWorklets.cjs +123 -0
- package/dist/cjs/transformWorklets.test.cjs +604 -0
- package/dist/cjs/worklets/autoworklet.cjs +265 -0
- package/dist/cjs/worklets/globals.cjs +73 -0
- package/dist/cjs/worklets/hash.cjs +38 -0
- package/dist/cjs/worklets/scope.cjs +370 -0
- package/dist/cjs/worklets/serialize.cjs +101 -0
- package/dist/cjs/worklets/transform.cjs +266 -0
- package/dist/cjs/worklets/types.cjs +18 -0
- package/dist/esm/cache.mjs +5 -3
- package/dist/esm/cache.mjs.map +1 -1
- package/dist/esm/configure.mjs +8 -1
- package/dist/esm/configure.mjs.map +1 -1
- package/dist/esm/index.js +75 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +75 -6
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/reactNativeCodegen.mjs +104 -0
- package/dist/esm/reactNativeCodegen.mjs.map +1 -0
- package/dist/esm/reactNativeViewConfig.mjs +460 -0
- package/dist/esm/reactNativeViewConfig.mjs.map +1 -0
- package/dist/esm/transformBabel.mjs +14 -19
- package/dist/esm/transformBabel.mjs.map +1 -1
- package/dist/esm/transformBabel.test.mjs +261 -1
- package/dist/esm/transformBabel.test.mjs.map +1 -1
- package/dist/esm/transformHermesAsync.mjs +25 -0
- package/dist/esm/transformHermesAsync.mjs.map +1 -0
- package/dist/esm/transformHermesLoops.mjs +283 -0
- package/dist/esm/transformHermesLoops.mjs.map +1 -0
- package/dist/esm/transformHermesLoops.test.mjs +234 -0
- package/dist/esm/transformHermesLoops.test.mjs.map +1 -0
- package/dist/esm/transformSWC.mjs +96 -139
- package/dist/esm/transformSWC.mjs.map +1 -1
- package/dist/esm/transformSWC.test.mjs +118 -0
- package/dist/esm/transformSWC.test.mjs.map +1 -0
- package/dist/esm/transformWorklets.mjs +82 -0
- package/dist/esm/transformWorklets.mjs.map +1 -0
- package/dist/esm/transformWorklets.test.mjs +581 -0
- package/dist/esm/transformWorklets.test.mjs.map +1 -0
- package/dist/esm/worklets/autoworklet.mjs +234 -0
- package/dist/esm/worklets/autoworklet.mjs.map +1 -0
- package/dist/esm/worklets/globals.mjs +46 -0
- package/dist/esm/worklets/globals.mjs.map +1 -0
- package/dist/esm/worklets/hash.mjs +13 -0
- package/dist/esm/worklets/hash.mjs.map +1 -0
- package/dist/esm/worklets/scope.mjs +345 -0
- package/dist/esm/worklets/scope.mjs.map +1 -0
- package/dist/esm/worklets/serialize.mjs +75 -0
- package/dist/esm/worklets/serialize.mjs.map +1 -0
- package/dist/esm/worklets/transform.mjs +229 -0
- package/dist/esm/worklets/transform.mjs.map +1 -0
- package/dist/esm/worklets/types.mjs +2 -0
- package/dist/esm/worklets/types.mjs.map +1 -0
- package/package.json +11 -6
- package/src/cache.ts +10 -3
- package/src/configure.ts +12 -0
- package/src/index.ts +96 -13
- package/src/reactNativeCodegen.ts +181 -0
- package/src/reactNativeViewConfig.ts +593 -0
- package/src/transformBabel.test.ts +268 -1
- package/src/transformBabel.ts +21 -31
- package/src/transformHermesAsync.ts +30 -0
- package/src/transformHermesLoops.test.ts +341 -0
- package/src/transformHermesLoops.ts +435 -0
- package/src/transformSWC.test.ts +132 -0
- package/src/transformSWC.ts +121 -161
- package/src/transformWorklets.test.ts +708 -0
- package/src/transformWorklets.ts +160 -0
- package/src/types.ts +4 -4
- package/src/worklets/autoworklet.ts +391 -0
- package/src/worklets/globals.ts +129 -0
- package/src/worklets/hash.ts +14 -0
- package/src/worklets/scope.ts +401 -0
- package/src/worklets/serialize.ts +114 -0
- package/src/worklets/transform.ts +319 -0
- package/src/worklets/types.ts +26 -0
- package/types/cache.d.ts +1 -0
- package/types/cache.d.ts.map +1 -1
- package/types/configure.d.ts +2 -0
- package/types/configure.d.ts.map +1 -1
- package/types/index.d.ts +6 -0
- package/types/index.d.ts.map +1 -1
- package/types/reactNativeCodegen.d.ts +5 -0
- package/types/reactNativeCodegen.d.ts.map +1 -0
- package/types/reactNativeViewConfig.d.ts +35 -0
- package/types/reactNativeViewConfig.d.ts.map +1 -0
- package/types/transformBabel.d.ts +3 -3
- package/types/transformBabel.d.ts.map +1 -1
- package/types/transformHermesAsync.d.ts +5 -0
- package/types/transformHermesAsync.d.ts.map +1 -0
- package/types/transformHermesLoops.d.ts +5 -0
- package/types/transformHermesLoops.d.ts.map +1 -0
- package/types/transformHermesLoops.test.d.ts +2 -0
- package/types/transformHermesLoops.test.d.ts.map +1 -0
- package/types/transformSWC.d.ts +13 -3
- package/types/transformSWC.d.ts.map +1 -1
- package/types/transformSWC.test.d.ts +2 -0
- package/types/transformSWC.test.d.ts.map +1 -0
- package/types/transformWorklets.d.ts +23 -0
- package/types/transformWorklets.d.ts.map +1 -0
- package/types/transformWorklets.test.d.ts +2 -0
- package/types/transformWorklets.test.d.ts.map +1 -0
- package/types/types.d.ts +4 -4
- package/types/types.d.ts.map +1 -1
- package/types/worklets/autoworklet.d.ts +14 -0
- package/types/worklets/autoworklet.d.ts.map +1 -0
- package/types/worklets/globals.d.ts +4 -0
- package/types/worklets/globals.d.ts.map +1 -0
- package/types/worklets/hash.d.ts +5 -0
- package/types/worklets/hash.d.ts.map +1 -0
- package/types/worklets/scope.d.ts +7 -0
- package/types/worklets/scope.d.ts.map +1 -0
- package/types/worklets/serialize.d.ts +12 -0
- package/types/worklets/serialize.d.ts.map +1 -0
- package/types/worklets/transform.d.ts +10 -0
- package/types/worklets/transform.d.ts.map +1 -0
- package/types/worklets/types.d.ts +21 -0
- package/types/worklets/types.d.ts.map +1 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var autoworklet_exports = {};
|
|
24
|
+
__export(autoworklet_exports, {
|
|
25
|
+
AUTOWORKLET_FUNCTION_ARGS: () => AUTOWORKLET_FUNCTION_ARGS,
|
|
26
|
+
GESTURE_BUILDER_METHODS: () => GESTURE_BUILDER_METHODS,
|
|
27
|
+
WORKLET_DIRECTIVES: () => WORKLET_DIRECTIVES,
|
|
28
|
+
bodyStartAfterDirectives: () => bodyStartAfterDirectives,
|
|
29
|
+
findWorkletCandidates: () => findWorkletCandidates,
|
|
30
|
+
hasDirective: () => hasDirective,
|
|
31
|
+
hasWorkletDirective: () => hasWorkletDirective
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(autoworklet_exports);
|
|
34
|
+
const AUTOWORKLET_FUNCTION_ARGS = Object.assign(/* @__PURE__ */Object.create(null), {
|
|
35
|
+
useFrameCallback: [0],
|
|
36
|
+
useAnimatedStyle: [0],
|
|
37
|
+
useAnimatedProps: [0],
|
|
38
|
+
createAnimatedPropAdapter: [0],
|
|
39
|
+
useDerivedValue: [0],
|
|
40
|
+
useAnimatedScrollHandler: [0],
|
|
41
|
+
useAnimatedGestureHandler: [0],
|
|
42
|
+
useAnimatedReaction: [0, 1],
|
|
43
|
+
withTiming: [2],
|
|
44
|
+
withSpring: [2],
|
|
45
|
+
withDecay: [1],
|
|
46
|
+
withRepeat: [3],
|
|
47
|
+
runOnUI: [0],
|
|
48
|
+
executeOnUIRuntimeSync: [0],
|
|
49
|
+
scheduleOnUI: [0],
|
|
50
|
+
runOnUISync: [0],
|
|
51
|
+
runOnUIAsync: [0],
|
|
52
|
+
runOnRuntime: [1],
|
|
53
|
+
runOnRuntimeSync: [1],
|
|
54
|
+
runOnRuntimeAsync: [1],
|
|
55
|
+
scheduleOnRuntime: [1],
|
|
56
|
+
runOnRuntimeSyncWithId: [1],
|
|
57
|
+
scheduleOnRuntimeWithId: [1],
|
|
58
|
+
useTapGesture: [0],
|
|
59
|
+
usePanGesture: [0],
|
|
60
|
+
usePinchGesture: [0],
|
|
61
|
+
useRotationGesture: [0],
|
|
62
|
+
useFlingGesture: [0],
|
|
63
|
+
useLongPressGesture: [0],
|
|
64
|
+
useNativeGesture: [0],
|
|
65
|
+
useManualGesture: [0],
|
|
66
|
+
useHoverGesture: [0]
|
|
67
|
+
});
|
|
68
|
+
const GESTURE_BUILDER_METHODS = /* @__PURE__ */new Set(["onBegin", "onStart", "onEnd", "onFinalize", "onUpdate", "onChange", "onTouchesDown", "onTouchesMove", "onTouchesUp", "onTouchesCancelled"]);
|
|
69
|
+
const GESTURE_KINDS = /* @__PURE__ */new Set(["Tap", "Pan", "Pinch", "Rotation", "Fling", "LongPress", "ForceTouch", "Native", "Manual", "Race", "Simultaneous", "Exclusive", "Hover"]);
|
|
70
|
+
const LAYOUT_ANIMATIONS = new Set(`BounceIn BounceInDown BounceInLeft BounceInRight BounceInUp BounceOut BounceOutDown
|
|
71
|
+
BounceOutLeft BounceOutRight BounceOutUp FadeIn FadeInDown FadeInLeft FadeInRight FadeInUp
|
|
72
|
+
FadeOut FadeOutDown FadeOutLeft FadeOutRight FadeOutUp FlipInEasyX FlipInEasyY FlipInXDown
|
|
73
|
+
FlipInXUp FlipInYLeft FlipInYRight FlipOutEasyX FlipOutEasyY FlipOutXDown FlipOutXUp
|
|
74
|
+
FlipOutYLeft FlipOutYRight LightSpeedInLeft LightSpeedInRight LightSpeedOutLeft
|
|
75
|
+
LightSpeedOutRight PinwheelIn PinwheelOut RollInLeft RollInRight RollOutLeft RollOutRight
|
|
76
|
+
RotateInDownLeft RotateInDownRight RotateInUpLeft RotateInUpRight RotateOutDownLeft
|
|
77
|
+
RotateOutDownRight RotateOutUpLeft RotateOutUpRight SlideInDown SlideInLeft SlideInRight
|
|
78
|
+
SlideInUp SlideOutDown SlideOutLeft SlideOutRight SlideOutUp StretchInX StretchInY
|
|
79
|
+
StretchOutX StretchOutY ZoomIn ZoomInDown ZoomInEasyDown ZoomInEasyUp ZoomInLeft ZoomInRight
|
|
80
|
+
ZoomInRotate ZoomInUp ZoomOut ZoomOutDown ZoomOutEasyDown ZoomOutEasyUp ZoomOutLeft
|
|
81
|
+
ZoomOutRight ZoomOutRotate ZoomOutUp Layout LinearTransition SequencedTransition
|
|
82
|
+
FadingTransition JumpingTransition CurvedTransition EntryExitTransition`.split(/\s+/));
|
|
83
|
+
const LAYOUT_ANIMATION_CHAIN_METHODS = /* @__PURE__ */new Set(["build", "duration", "delay", "getDuration", "randomDelay", "getDelay", "getDelayFunction", "easing", "rotate", "springify", "damping", "mass", "stiffness", "overshootClamping", "energyThreshold", "restDisplacementThreshold", "restSpeedThreshold", "withInitialValues", "getAnimationAndConfig", "easingX", "easingY", "easingWidth", "easingHeight", "entering", "exiting", "reverse"]);
|
|
84
|
+
function isGestureObject(exp) {
|
|
85
|
+
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);
|
|
86
|
+
}
|
|
87
|
+
function containsGestureObject(exp) {
|
|
88
|
+
if (isGestureObject(exp)) return true;
|
|
89
|
+
return exp?.type === "CallExpression" && exp.callee?.type === "MemberExpression" && containsGestureObject(exp.callee.object);
|
|
90
|
+
}
|
|
91
|
+
function isLayoutAnimationChain(exp) {
|
|
92
|
+
if (exp?.type === "Identifier" && LAYOUT_ANIMATIONS.has(exp.name)) return true;
|
|
93
|
+
if (exp?.type === "NewExpression" && exp.callee?.type === "Identifier" && LAYOUT_ANIMATIONS.has(exp.callee.name)) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
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);
|
|
97
|
+
}
|
|
98
|
+
function isChainedCallback(callee) {
|
|
99
|
+
if (callee?.type !== "MemberExpression" || callee.property?.type !== "Identifier") {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
const name = callee.property.name;
|
|
103
|
+
if (GESTURE_BUILDER_METHODS.has(name)) return containsGestureObject(callee.object);
|
|
104
|
+
if (name === "withCallback") return isLayoutAnimationChain(callee.object);
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
const WORKLET_DIRECTIVES = ["worklet", "no-worklet-closure", "limit-init-data-hoisting"];
|
|
108
|
+
function statementDirective(stmt) {
|
|
109
|
+
if (!stmt || stmt.type !== "ExpressionStatement") return void 0;
|
|
110
|
+
if (typeof stmt.directive === "string") return stmt.directive;
|
|
111
|
+
if (stmt.expression?.type === "Literal" && typeof stmt.expression.value === "string") {
|
|
112
|
+
return stmt.expression.value;
|
|
113
|
+
}
|
|
114
|
+
return void 0;
|
|
115
|
+
}
|
|
116
|
+
function hasDirective(fnNode, directive) {
|
|
117
|
+
if (!fnNode || !fnNode.body) return false;
|
|
118
|
+
if (Array.isArray(fnNode.body.directives)) {
|
|
119
|
+
for (const d of fnNode.body.directives) {
|
|
120
|
+
if (d.directive === directive || d.value === directive) {
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (fnNode.body.type === "BlockStatement" && Array.isArray(fnNode.body.body)) {
|
|
126
|
+
for (const stmt of fnNode.body.body) {
|
|
127
|
+
const found = statementDirective(stmt);
|
|
128
|
+
if (found === void 0) break;
|
|
129
|
+
if (found === directive) return true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
function hasWorkletDirective(fnNode) {
|
|
135
|
+
return hasDirective(fnNode, "worklet");
|
|
136
|
+
}
|
|
137
|
+
function bodyStartAfterDirectives(fnNode, code) {
|
|
138
|
+
let start = fnNode.body.start + 1;
|
|
139
|
+
if (fnNode.body.type !== "BlockStatement" || !Array.isArray(fnNode.body.body)) return start;
|
|
140
|
+
for (const stmt of fnNode.body.body) {
|
|
141
|
+
const found = statementDirective(stmt);
|
|
142
|
+
if (found === void 0 || !WORKLET_DIRECTIVES.includes(found)) break;
|
|
143
|
+
start = stmt.end;
|
|
144
|
+
while (start < fnNode.body.end && (code[start] === ";" || /\s/.test(code[start]))) {
|
|
145
|
+
start++;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return start;
|
|
149
|
+
}
|
|
150
|
+
function findWorkletCandidates(program) {
|
|
151
|
+
const candidates = [];
|
|
152
|
+
const seenStarts = /* @__PURE__ */new Set();
|
|
153
|
+
function addCandidate(candidate) {
|
|
154
|
+
const fnStart = candidate.fnNode.start;
|
|
155
|
+
if (seenStarts.has(fnStart)) return;
|
|
156
|
+
seenStarts.add(fnStart);
|
|
157
|
+
candidates.push(candidate);
|
|
158
|
+
}
|
|
159
|
+
function getCalleeName(callee) {
|
|
160
|
+
if (!callee) return null;
|
|
161
|
+
if (callee.type === "Identifier") {
|
|
162
|
+
return callee.name;
|
|
163
|
+
}
|
|
164
|
+
if (callee.type === "MemberExpression" && !callee.computed && callee.property?.type === "Identifier") {
|
|
165
|
+
return callee.property.name;
|
|
166
|
+
}
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
function walk(node, parent) {
|
|
170
|
+
if (!node || typeof node !== "object") return;
|
|
171
|
+
if (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") {
|
|
172
|
+
if (hasWorkletDirective(node)) {
|
|
173
|
+
let kind = "function_expression";
|
|
174
|
+
if (node.type === "FunctionDeclaration") kind = "function_declaration";else if (node.type === "ArrowFunctionExpression") kind = "arrow_function";
|
|
175
|
+
let name = node.id?.name;
|
|
176
|
+
if (!name && parent?.type === "VariableDeclarator" && parent.id?.name) {
|
|
177
|
+
name = parent.id.name;
|
|
178
|
+
}
|
|
179
|
+
addCandidate({
|
|
180
|
+
node,
|
|
181
|
+
fnNode: node,
|
|
182
|
+
kind,
|
|
183
|
+
name,
|
|
184
|
+
parent,
|
|
185
|
+
isAutoWorklet: false
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
} else if (node.type === "Property" && (node.method || node.value?.type === "FunctionExpression" || node.value?.type === "ArrowFunctionExpression")) {
|
|
189
|
+
const fn = node.value;
|
|
190
|
+
if (hasWorkletDirective(fn)) {
|
|
191
|
+
addCandidate({
|
|
192
|
+
node: node.method ? node : fn,
|
|
193
|
+
fnNode: fn,
|
|
194
|
+
kind: node.method ? "object_method" : fn.type === "ArrowFunctionExpression" ? "arrow_function" : "function_expression",
|
|
195
|
+
name: node.key?.name,
|
|
196
|
+
parent,
|
|
197
|
+
isAutoWorklet: false
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (node.type === "CallExpression") {
|
|
202
|
+
const calleeName = getCalleeName(node.callee);
|
|
203
|
+
const argIndices = calleeName ? AUTOWORKLET_FUNCTION_ARGS[calleeName] : void 0;
|
|
204
|
+
const chained = !argIndices && isChainedCallback(node.callee);
|
|
205
|
+
const indices = argIndices ?? (chained ? node.arguments.map((_, i) => i) : void 0);
|
|
206
|
+
if (indices) {
|
|
207
|
+
for (const idx of indices) {
|
|
208
|
+
const arg = node.arguments[idx];
|
|
209
|
+
if (!arg) continue;
|
|
210
|
+
if (arg.type === "ArrowFunctionExpression" || arg.type === "FunctionExpression") {
|
|
211
|
+
let name = arg.id?.name;
|
|
212
|
+
if (!name && parent?.type === "VariableDeclarator" && parent.id?.name) {
|
|
213
|
+
name = parent.id.name;
|
|
214
|
+
}
|
|
215
|
+
addCandidate({
|
|
216
|
+
node: arg,
|
|
217
|
+
fnNode: arg,
|
|
218
|
+
kind: arg.type === "ArrowFunctionExpression" ? "arrow_function" : "function_expression",
|
|
219
|
+
name,
|
|
220
|
+
parent: node,
|
|
221
|
+
isAutoWorklet: true
|
|
222
|
+
});
|
|
223
|
+
} else if (arg.type === "ObjectExpression" && Array.isArray(arg.properties)) {
|
|
224
|
+
for (const prop of arg.properties) {
|
|
225
|
+
if (prop.type === "Property") {
|
|
226
|
+
if (prop.method) {
|
|
227
|
+
addCandidate({
|
|
228
|
+
node: prop,
|
|
229
|
+
fnNode: prop.value,
|
|
230
|
+
kind: "object_method",
|
|
231
|
+
name: prop.key?.name,
|
|
232
|
+
parent: arg,
|
|
233
|
+
isAutoWorklet: true
|
|
234
|
+
});
|
|
235
|
+
} else if (prop.value?.type === "ArrowFunctionExpression" || prop.value?.type === "FunctionExpression") {
|
|
236
|
+
addCandidate({
|
|
237
|
+
node: prop.value,
|
|
238
|
+
fnNode: prop.value,
|
|
239
|
+
kind: prop.value.type === "ArrowFunctionExpression" ? "arrow_function" : "function_expression",
|
|
240
|
+
name: prop.key?.name,
|
|
241
|
+
parent: prop,
|
|
242
|
+
isAutoWorklet: true
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
for (const key of Object.keys(node)) {
|
|
252
|
+
if (key === "start" || key === "end" || key === "loc" || key === "range") continue;
|
|
253
|
+
const child = node[key];
|
|
254
|
+
if (Array.isArray(child)) {
|
|
255
|
+
for (const item of child) {
|
|
256
|
+
walk(item, node);
|
|
257
|
+
}
|
|
258
|
+
} else if (child && typeof child === "object") {
|
|
259
|
+
walk(child, node);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
walk(program, null);
|
|
264
|
+
return candidates;
|
|
265
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var globals_exports = {};
|
|
24
|
+
__export(globals_exports, {
|
|
25
|
+
DEFAULT_GLOBALS: () => DEFAULT_GLOBALS,
|
|
26
|
+
JS_GLOBALS: () => JS_GLOBALS,
|
|
27
|
+
createGlobalsSet: () => createGlobalsSet
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(globals_exports);
|
|
30
|
+
const JS_GLOBALS = /* @__PURE__ */new Set([
|
|
31
|
+
// Value properties
|
|
32
|
+
"globalThis", "Infinity", "NaN", "undefined",
|
|
33
|
+
// Function properties
|
|
34
|
+
"eval", "isFinite", "isNaN", "parseFloat", "parseInt", "decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent", "escape", "unescape",
|
|
35
|
+
// Fundamental objects
|
|
36
|
+
"Object", "Function", "Boolean", "Symbol",
|
|
37
|
+
// Error objects
|
|
38
|
+
"Error", "AggregateError", "EvalError", "RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError", "InternalError",
|
|
39
|
+
// Numbers and dates
|
|
40
|
+
"Number", "BigInt", "Math", "Date",
|
|
41
|
+
// Text processing
|
|
42
|
+
"String", "RegExp",
|
|
43
|
+
// Indexed collections
|
|
44
|
+
"Array", "Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "BigInt64Array", "BigUint64Array", "Float32Array", "Float64Array",
|
|
45
|
+
// Keyed collections
|
|
46
|
+
"Map", "Set", "WeakMap", "WeakSet",
|
|
47
|
+
// Structured data
|
|
48
|
+
"ArrayBuffer", "SharedArrayBuffer", "DataView", "Atomics", "JSON",
|
|
49
|
+
// Managing memory
|
|
50
|
+
"WeakRef", "FinalizationRegistry",
|
|
51
|
+
// Control abstraction objects
|
|
52
|
+
"Iterator", "AsyncIterator", "Promise", "GeneratorFunction", "AsyncGeneratorFunction", "Generator", "AsyncGenerator", "AsyncFunction",
|
|
53
|
+
// Reflection
|
|
54
|
+
"Reflect", "Proxy",
|
|
55
|
+
// Internationalization
|
|
56
|
+
"Intl"]);
|
|
57
|
+
const DEFAULT_GLOBALS = /* @__PURE__ */new Set([...JS_GLOBALS,
|
|
58
|
+
// Environment / Runtime
|
|
59
|
+
"null", "this", "global", "window", "self", "console", "performance", "arguments", "require", "fetch", "XMLHttpRequest", "WebSocket", "queueMicrotask", "requestAnimationFrame", "cancelAnimationFrame", "setTimeout", "clearTimeout", "setImmediate", "clearImmediate", "setInterval", "clearInterval", "HermesInternal", "_WORKLET"]);
|
|
60
|
+
function createGlobalsSet(customGlobals, strictGlobal) {
|
|
61
|
+
const set = /* @__PURE__ */new Set();
|
|
62
|
+
if (!strictGlobal) {
|
|
63
|
+
for (const g of DEFAULT_GLOBALS) {
|
|
64
|
+
set.add(g);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (customGlobals) {
|
|
68
|
+
for (const g of customGlobals) {
|
|
69
|
+
set.add(g);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return set;
|
|
73
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var hash_exports = {};
|
|
24
|
+
__export(hash_exports, {
|
|
25
|
+
calculateWorkletHash: () => calculateWorkletHash
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(hash_exports);
|
|
28
|
+
function calculateWorkletHash(str) {
|
|
29
|
+
let i = str.length;
|
|
30
|
+
let hash1 = 5381;
|
|
31
|
+
let hash2 = 52711;
|
|
32
|
+
while (i--) {
|
|
33
|
+
const char = str.charCodeAt(i);
|
|
34
|
+
hash1 = hash1 * 33 ^ char;
|
|
35
|
+
hash2 = hash2 * 33 ^ char;
|
|
36
|
+
}
|
|
37
|
+
return (hash1 >>> 0) * 4096 + (hash2 >>> 0);
|
|
38
|
+
}
|