Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow worklet referencing in plugin #5911

Merged
merged 11 commits into from
Jun 10, 2024
Prev Previous commit
Next Next commit
review changes
  • Loading branch information
tjzel committed Jun 10, 2024
commit 8f0b00ca1fb0e193a5941310321b6be01d3b66d6
Original file line number Diff line number Diff line change
Expand Up @@ -1598,210 +1598,210 @@ var foo = Gesture.Tap().numberOfTaps(2).onBegin(function () {
`;

exports[`babel plugin for referenced worklets prefers AssignmentExpression over VariableDeclarator 1`] = `
"var style = function style() {
"var styleFactory = function styleFactory() {
return 1;
};
var _worklet_2702612302885_init_data = {
code: "function style(){return'AssignmentExpression';}",
var _worklet_2302253389457_init_data = {
code: "function styleFactory(){return'AssignmentExpression';}",
location: "/dev/null",
sourceMap: "\\"mock source map\\"",
version: "x.y.z"
};
style = function () {
styleFactory = function () {
const _e = [new global.Error(), 1, -27];
const style = function () {
const styleFactory = function () {
return 'AssignmentExpression';
};
style.__closure = {};
style.__workletHash = 2702612302885;
style.__initData = _worklet_2702612302885_init_data;
style.__stackDetails = _e;
return style;
styleFactory.__closure = {};
styleFactory.__workletHash = 2302253389457;
styleFactory.__initData = _worklet_2302253389457_init_data;
styleFactory.__stackDetails = _e;
return styleFactory;
}();
animatedStyle = useAnimatedStyle(style);"
animatedStyle = useAnimatedStyle(styleFactory);"
`;

exports[`babel plugin for referenced worklets prefers FunctionDeclaration over AssignmentExpression 1`] = `
"var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _readOnlyError2 = _interopRequireDefault(require("@babel/runtime/helpers/readOnlyError"));
var _worklet_1685592196934_init_data = {
code: "function style(){return'FunctionDeclaration';}",
var _worklet_8893014081746_init_data = {
code: "function styleFactory(){return'FunctionDeclaration';}",
location: "/dev/null",
sourceMap: "\\"mock source map\\"",
version: "x.y.z"
};
var style = function () {
var styleFactory = function () {
var _e = [new global.Error(), 1, -27];
var style = function style() {
var styleFactory = function styleFactory() {
return 'FunctionDeclaration';
};
style.__closure = {};
style.__workletHash = 1685592196934;
style.__initData = _worklet_1685592196934_init_data;
style.__stackDetails = _e;
return style;
styleFactory.__closure = {};
styleFactory.__workletHash = 8893014081746;
styleFactory.__initData = _worklet_8893014081746_init_data;
styleFactory.__stackDetails = _e;
return styleFactory;
}();
(function style() {
(function styleFactory() {
return 'AssignmentExpression';
}), (0, _readOnlyError2.default)("style");
animatedStyle = useAnimatedStyle(style);"
}), (0, _readOnlyError2.default)("styleFactory");
animatedStyle = useAnimatedStyle(styleFactory);"
`;

exports[`babel plugin for referenced worklets workletizes ArrowFunctionExpression on its AssignmentExpression 1`] = `
"var style;
var _worklet_11844349717570_init_data = {
code: "function style(){return{};}",
"var styleFactory;
var _worklet_155831007318_init_data = {
code: "function styleFactory(){return{};}",
location: "/dev/null",
sourceMap: "\\"mock source map\\"",
version: "x.y.z"
};
style = function () {
styleFactory = function () {
const _e = [new global.Error(), 1, -27];
const style = function () {
const styleFactory = function () {
return {};
};
style.__closure = {};
style.__workletHash = 11844349717570;
style.__initData = _worklet_11844349717570_init_data;
style.__stackDetails = _e;
return style;
styleFactory.__closure = {};
styleFactory.__workletHash = 155831007318;
styleFactory.__initData = _worklet_155831007318_init_data;
styleFactory.__stackDetails = _e;
return styleFactory;
}();
animatedStyle = useAnimatedStyle(style);"
animatedStyle = useAnimatedStyle(styleFactory);"
`;

exports[`babel plugin for referenced worklets workletizes ArrowFunctionExpression on its VariableDeclarator 1`] = `
"var _worklet_11844349717570_init_data = {
code: "function style(){return{};}",
"var _worklet_155831007318_init_data = {
code: "function styleFactory(){return{};}",
location: "/dev/null",
sourceMap: "\\"mock source map\\"",
version: "x.y.z"
};
var style = function () {
var styleFactory = function () {
const _e = [new global.Error(), 1, -27];
const style = function () {
const styleFactory = function () {
return {};
};
style.__closure = {};
style.__workletHash = 11844349717570;
style.__initData = _worklet_11844349717570_init_data;
style.__stackDetails = _e;
return style;
styleFactory.__closure = {};
styleFactory.__workletHash = 155831007318;
styleFactory.__initData = _worklet_155831007318_init_data;
styleFactory.__stackDetails = _e;
return styleFactory;
}();
var animatedStyle = useAnimatedStyle(style);"
var animatedStyle = useAnimatedStyle(styleFactory);"
`;

exports[`babel plugin for referenced worklets workletizes ArrowFunctionExpression only on last AssignmentExpression 1`] = `
"var style;
style = function style() {
"var styleFactory;
styleFactory = function styleFactory() {
return 1;
};
var _worklet_2702612302885_init_data = {
code: "function style(){return'AssignmentExpression';}",
var _worklet_2302253389457_init_data = {
code: "function styleFactory(){return'AssignmentExpression';}",
location: "/dev/null",
sourceMap: "\\"mock source map\\"",
version: "x.y.z"
};
style = function () {
styleFactory = function () {
const _e = [new global.Error(), 1, -27];
const style = function () {
const styleFactory = function () {
return 'AssignmentExpression';
};
style.__closure = {};
style.__workletHash = 2702612302885;
style.__initData = _worklet_2702612302885_init_data;
style.__stackDetails = _e;
return style;
styleFactory.__closure = {};
styleFactory.__workletHash = 2302253389457;
styleFactory.__initData = _worklet_2302253389457_init_data;
styleFactory.__stackDetails = _e;
return styleFactory;
}();
animatedStyle = useAnimatedStyle(style);"
animatedStyle = useAnimatedStyle(styleFactory);"
`;

exports[`babel plugin for referenced worklets workletizes FunctionDeclaration 1`] = `
"var _worklet_11844349717570_init_data = {
code: "function style(){return{};}",
"var _worklet_155831007318_init_data = {
code: "function styleFactory(){return{};}",
location: "/dev/null",
sourceMap: "\\"mock source map\\"",
version: "x.y.z"
};
var style = function () {
var styleFactory = function () {
var _e = [new global.Error(), 1, -27];
var style = function style() {
var styleFactory = function styleFactory() {
return {};
};
style.__closure = {};
style.__workletHash = 11844349717570;
style.__initData = _worklet_11844349717570_init_data;
style.__stackDetails = _e;
return style;
styleFactory.__closure = {};
styleFactory.__workletHash = 155831007318;
styleFactory.__initData = _worklet_155831007318_init_data;
styleFactory.__stackDetails = _e;
return styleFactory;
}();
var animatedStyle = useAnimatedStyle(style);"
var animatedStyle = useAnimatedStyle(styleFactory);"
`;

exports[`babel plugin for referenced worklets workletizes FunctionExpression on its AssignmentExpression 1`] = `
"var style;
var _worklet_11844349717570_init_data = {
code: "function style(){return{};}",
"var styleFactory;
var _worklet_155831007318_init_data = {
code: "function styleFactory(){return{};}",
location: "/dev/null",
sourceMap: "\\"mock source map\\"",
version: "x.y.z"
};
style = function () {
styleFactory = function () {
const _e = [new global.Error(), 1, -27];
const style = function () {
const styleFactory = function () {
return {};
};
style.__closure = {};
style.__workletHash = 11844349717570;
style.__initData = _worklet_11844349717570_init_data;
style.__stackDetails = _e;
return style;
styleFactory.__closure = {};
styleFactory.__workletHash = 155831007318;
styleFactory.__initData = _worklet_155831007318_init_data;
styleFactory.__stackDetails = _e;
return styleFactory;
}();
animatedStyle = useAnimatedStyle(style);"
animatedStyle = useAnimatedStyle(styleFactory);"
`;

exports[`babel plugin for referenced worklets workletizes FunctionExpression on its VariableDeclarator 1`] = `
"var _worklet_11844349717570_init_data = {
code: "function style(){return{};}",
"var _worklet_155831007318_init_data = {
code: "function styleFactory(){return{};}",
location: "/dev/null",
sourceMap: "\\"mock source map\\"",
version: "x.y.z"
};
var style = function () {
var styleFactory = function () {
const _e = [new global.Error(), 1, -27];
const style = function () {
const styleFactory = function () {
return {};
};
style.__closure = {};
style.__workletHash = 11844349717570;
style.__initData = _worklet_11844349717570_init_data;
style.__stackDetails = _e;
return style;
styleFactory.__closure = {};
styleFactory.__workletHash = 155831007318;
styleFactory.__initData = _worklet_155831007318_init_data;
styleFactory.__stackDetails = _e;
return styleFactory;
}();
var animatedStyle = useAnimatedStyle(style);"
var animatedStyle = useAnimatedStyle(styleFactory);"
`;

exports[`babel plugin for referenced worklets workletizes FunctionExpression only on last AssignmentExpression 1`] = `
"var style;
style = function style() {
"var styleFactory;
styleFactory = function styleFactory() {
return 1;
};
var _worklet_2702612302885_init_data = {
code: "function style(){return'AssignmentExpression';}",
var _worklet_2302253389457_init_data = {
code: "function styleFactory(){return'AssignmentExpression';}",
location: "/dev/null",
sourceMap: "\\"mock source map\\"",
version: "x.y.z"
};
style = function () {
styleFactory = function () {
const _e = [new global.Error(), 1, -27];
const style = function () {
const styleFactory = function () {
return 'AssignmentExpression';
};
style.__closure = {};
style.__workletHash = 2702612302885;
style.__initData = _worklet_2702612302885_init_data;
style.__stackDetails = _e;
return style;
styleFactory.__closure = {};
styleFactory.__workletHash = 2302253389457;
styleFactory.__initData = _worklet_2302253389457_init_data;
styleFactory.__stackDetails = _e;
return styleFactory;
}();
animatedStyle = useAnimatedStyle(style);"
animatedStyle = useAnimatedStyle(styleFactory);"
`;

exports[`babel plugin for referenced worklets workletizes ObjectExpression on its AssignmentExpression 1`] = `
Expand Down Expand Up @@ -1877,17 +1877,17 @@ var scrollHandler = useAnimatedScrollHandler(handler);"
`;

exports[`babel plugin for referenced worklets workletizes assigments that appear after the worklet is used 1`] = `
"var style = function style() {
"var styleFactory = function styleFactory() {
return {};
};
animatedStyle = useAnimatedStyle(style);
animatedStyle = useAnimatedStyle(styleFactory);
var _worklet_12348123604788_init_data = {
code: "function anonymous(){return'AssignmentAfterUse';}",
location: "/dev/null",
sourceMap: "\\"mock source map\\"",
version: "x.y.z"
};
style = function () {
styleFactory = function () {
var _e = [new global.Error(), 1, -27];
var anonymous = function anonymous() {
return 'AssignmentAfterUse';
Expand All @@ -1901,47 +1901,47 @@ style = function () {
`;

exports[`babel plugin for referenced worklets workletizes in immediate scope 1`] = `
"var _worklet_11844349717570_init_data = {
code: "function style(){return{};}",
"var _worklet_155831007318_init_data = {
code: "function styleFactory(){return{};}",
location: "/dev/null",
sourceMap: "\\"mock source map\\"",
version: "x.y.z"
};
var style = function () {
var styleFactory = function () {
const _e = [new global.Error(), 1, -27];
const style = function () {
const styleFactory = function () {
return {};
};
style.__closure = {};
style.__workletHash = 11844349717570;
style.__initData = _worklet_11844349717570_init_data;
style.__stackDetails = _e;
return style;
styleFactory.__closure = {};
styleFactory.__workletHash = 155831007318;
styleFactory.__initData = _worklet_155831007318_init_data;
styleFactory.__stackDetails = _e;
return styleFactory;
}();
animatedStyle = useAnimatedStyle(style);"
animatedStyle = useAnimatedStyle(styleFactory);"
`;

exports[`babel plugin for referenced worklets workletizes in nested scope 1`] = `
"var _worklet_11844349717570_init_data = {
code: "function style(){return{};}",
"var _worklet_155831007318_init_data = {
code: "function styleFactory(){return{};}",
location: "/dev/null",
sourceMap: "\\"mock source map\\"",
version: "x.y.z"
};
function outerScope() {
var style = function () {
var styleFactory = function () {
const _e = [new global.Error(), 1, -27];
const style = function () {
const styleFactory = function () {
return {};
};
style.__closure = {};
style.__workletHash = 11844349717570;
style.__initData = _worklet_11844349717570_init_data;
style.__stackDetails = _e;
return style;
styleFactory.__closure = {};
styleFactory.__workletHash = 155831007318;
styleFactory.__initData = _worklet_155831007318_init_data;
styleFactory.__stackDetails = _e;
return styleFactory;
}();
function innerScope() {
animatedStyle = useAnimatedStyle(style);
animatedStyle = useAnimatedStyle(styleFactory);
}
}"
`;
Expand Down
Loading
Loading