diff --git a/packages/docs-reanimated/docs/reanimated-babel-plugin/options.md b/packages/docs-reanimated/docs/reanimated-babel-plugin/options.md index 3aa0ee11657..ba9599ccac4 100644 --- a/packages/docs-reanimated/docs/reanimated-babel-plugin/options.md +++ b/packages/docs-reanimated/docs/reanimated-babel-plugin/options.md @@ -19,6 +19,7 @@ interface ReanimatedPluginOptions { omitNativeOnlyData?: boolean; globals?: string[]; substituteWebPlatformChecks?: boolean; + disableSourceMaps?: boolean; } ``` @@ -189,4 +190,12 @@ There is a [huge list of identifiers whitelisted by default](https://github.com/ ### substituteWebPlatformChecks +Defaults to `false`. + This option can also be useful for Web apps. In Reanimated, we have numerous checks to determine the right function implementation for a specific target platform. Enabling this option changes all the checks that identify if the target is a Web app to `true`. This alteration can aid in tree-shaking and contribute to reducing the bundle size. + +### disableSourceMaps + +Defaults to `false`. + +This option turns off the source map generation for worklets. Mostly used for testing purposes. diff --git a/packages/react-native-reanimated/__tests__/__snapshots__/plugin.test.ts.snap b/packages/react-native-reanimated/__tests__/__snapshots__/plugin.test.ts.snap index 7f1bf7f7934..e2b4ffe89fb 100644 --- a/packages/react-native-reanimated/__tests__/__snapshots__/plugin.test.ts.snap +++ b/packages/react-native-reanimated/__tests__/__snapshots__/plugin.test.ts.snap @@ -15,63 +15,63 @@ exports[`babel plugin for DirectiveLiterals doesn't transform functions without `; exports[`babel plugin for DirectiveLiterals doesn't transform string literals 1`] = ` -"var _worklet_9810417751380_init_data = { - code: "function foo(x){const bar='worklet';const baz=\\"worklet\\";}", +"var _worklet_7224155149057_init_data = { + code: "function foo_null1(x){const bar='worklet';const baz=\\"worklet\\";}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function foo(x) { + var foo_null1 = function foo_null1(x) { var bar = 'worklet'; var baz = "worklet"; }; - foo.__closure = {}; - foo.__workletHash = 9810417751380; - foo.__initData = _worklet_9810417751380_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 7224155149057; + foo_null1.__initData = _worklet_7224155149057_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; exports[`babel plugin for DirectiveLiterals removes "worklet"; directive from worklets 1`] = ` -"var _worklet_4679479961836_init_data = { - code: "function foo(x){return x+2;}", +"var _worklet_2156194750585_init_data = { + code: "function foo_null1(x){return x+2;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function foo(x) { + var foo_null1 = function foo_null1(x) { return x + 2; }; - foo.__closure = {}; - foo.__workletHash = 4679479961836; - foo.__initData = _worklet_4679479961836_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 2156194750585; + foo_null1.__initData = _worklet_2156194750585_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; exports[`babel plugin for DirectiveLiterals removes 'worklet'; directive from worklets 1`] = ` -"var _worklet_4679479961836_init_data = { - code: "function foo(x){return x+2;}", +"var _worklet_2156194750585_init_data = { + code: "function foo_null1(x){return x+2;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function foo(x) { + var foo_null1 = function foo_null1(x) { return x + 2; }; - foo.__closure = {}; - foo.__workletHash = 4679479961836; - foo.__initData = _worklet_4679479961836_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 2156194750585; + foo_null1.__initData = _worklet_2156194750585_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; @@ -136,256 +136,256 @@ exports[`babel plugin for Layout Animations doesn't workletize callback function `; exports[`babel plugin for Layout Animations workletizes callback functions on known chained methods after 1`] = ` -"var _worklet_9297685979719_init_data = { - code: "function anonymous(){console.log('FadeIn with build after');}", +"var _worklet_7317097572766_init_data = { + code: "function null1(){console.log('FadeIn with build after');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; FadeIn.withCallback(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('FadeIn with build after'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 9297685979719; - anonymous.__initData = _worklet_9297685979719_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 7317097572766; + null1.__initData = _worklet_7317097572766_init_data; + null1.__stackDetails = _e; + return null1; }()).build();" `; exports[`babel plugin for Layout Animations workletizes callback functions on known chained methods after with new keyword 1`] = ` -"var _worklet_9297685979719_init_data = { - code: "function anonymous(){console.log('FadeIn with build after');}", +"var _worklet_7317097572766_init_data = { + code: "function null1(){console.log('FadeIn with build after');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; new FadeIn().withCallback(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('FadeIn with build after'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 9297685979719; - anonymous.__initData = _worklet_9297685979719_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 7317097572766; + null1.__initData = _worklet_7317097572766_init_data; + null1.__stackDetails = _e; + return null1; }()).build();" `; exports[`babel plugin for Layout Animations workletizes callback functions on known chained methods before 1`] = ` -"var _worklet_7455148134810_init_data = { - code: "function anonymous(){console.log('FadeIn with build before');}", +"var _worklet_12678290670659_init_data = { + code: "function null1(){console.log('FadeIn with build before');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; FadeIn.build().withCallback(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('FadeIn with build before'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 7455148134810; - anonymous.__initData = _worklet_7455148134810_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 12678290670659; + null1.__initData = _worklet_12678290670659_init_data; + null1.__stackDetails = _e; + return null1; }());" `; exports[`babel plugin for Layout Animations workletizes callback functions on known chained methods before with new keyword 1`] = ` -"var _worklet_7455148134810_init_data = { - code: "function anonymous(){console.log('FadeIn with build before');}", +"var _worklet_12678290670659_init_data = { + code: "function null1(){console.log('FadeIn with build before');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; new FadeIn().build().withCallback(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('FadeIn with build before'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 7455148134810; - anonymous.__initData = _worklet_7455148134810_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 12678290670659; + null1.__initData = _worklet_12678290670659_init_data; + null1.__stackDetails = _e; + return null1; }());" `; exports[`babel plugin for Layout Animations workletizes callback functions on longer chains of known objects 1`] = ` -"var _worklet_1134777276323_init_data = { - code: "function anonymous(){console.log('FadeIn with build');}", +"var _worklet_11557425704826_init_data = { + code: "function null1(){console.log('FadeIn with build');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; FadeIn.build().duration().withCallback(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('FadeIn with build'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 1134777276323; - anonymous.__initData = _worklet_1134777276323_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 11557425704826; + null1.__initData = _worklet_11557425704826_init_data; + null1.__stackDetails = _e; + return null1; }());" `; exports[`babel plugin for Layout Animations workletizes callback functions on longer chains of known objects with new keyword 1`] = ` -"var _worklet_1134777276323_init_data = { - code: "function anonymous(){console.log('FadeIn with build');}", +"var _worklet_11557425704826_init_data = { + code: "function null1(){console.log('FadeIn with build');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; new FadeIn().build().duration().withCallback(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('FadeIn with build'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 1134777276323; - anonymous.__initData = _worklet_1134777276323_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 11557425704826; + null1.__initData = _worklet_11557425704826_init_data; + null1.__stackDetails = _e; + return null1; }());" `; exports[`babel plugin for Layout Animations workletizes callback functions on unknown objects chained after 1`] = ` -"var _worklet_5878665076948_init_data = { - code: "function anonymous(){console.log('FadeIn with AmogusIn after');}", +"var _worklet_6642833765517_init_data = { + code: "function null1(){console.log('FadeIn with AmogusIn after');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; FadeIn.withCallback(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('FadeIn with AmogusIn after'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 5878665076948; - anonymous.__initData = _worklet_5878665076948_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 6642833765517; + null1.__initData = _worklet_6642833765517_init_data; + null1.__stackDetails = _e; + return null1; }()).AmogusIn();" `; exports[`babel plugin for Layout Animations workletizes callback functions on unknown objects chained after with new keyword 1`] = ` -"var _worklet_5878665076948_init_data = { - code: "function anonymous(){console.log('FadeIn with AmogusIn after');}", +"var _worklet_6642833765517_init_data = { + code: "function null1(){console.log('FadeIn with AmogusIn after');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; new FadeIn().withCallback(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('FadeIn with AmogusIn after'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 5878665076948; - anonymous.__initData = _worklet_5878665076948_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 6642833765517; + null1.__initData = _worklet_6642833765517_init_data; + null1.__stackDetails = _e; + return null1; }()).AmogusIn();" `; exports[`babel plugin for Layout Animations workletizes unchained callback functions automatically 1`] = ` -"var _worklet_7606417127287_init_data = { - code: "function anonymous(){console.log('FadeIn');}", +"var _worklet_5714930700718_init_data = { + code: "function null1(){console.log('FadeIn');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; FadeIn.withCallback(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('FadeIn'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 7606417127287; - anonymous.__initData = _worklet_7606417127287_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 5714930700718; + null1.__initData = _worklet_5714930700718_init_data; + null1.__stackDetails = _e; + return null1; }());" `; exports[`babel plugin for Layout Animations workletizes unchained callback functions automatically with new keyword 1`] = ` -"var _worklet_7606417127287_init_data = { - code: "function anonymous(){console.log('FadeIn');}", +"var _worklet_5714930700718_init_data = { + code: "function null1(){console.log('FadeIn');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; new FadeIn().withCallback(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('FadeIn'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 7606417127287; - anonymous.__initData = _worklet_7606417127287_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 5714930700718; + null1.__initData = _worklet_5714930700718_init_data; + null1.__stackDetails = _e; + return null1; }());" `; exports[`babel plugin for async functions makes an async worklet factory 1`] = ` "var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); -var _worklet_2720353136439_init_data = { - code: "async function foo(){await Promise.resolve();}", +var _worklet_14005565322850_init_data = { + code: "async function foo_null1(){await Promise.resolve();}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function () { + var foo_null1 = function () { var _ref = (0, _asyncToGenerator2.default)(function* () { yield Promise.resolve(); }); - return function foo() { + return function foo_null1() { return _ref.apply(this, arguments); }; }(); - foo.__closure = {}; - foo.__workletHash = 2720353136439; - foo.__initData = _worklet_2720353136439_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 14005565322850; + foo_null1.__initData = _worklet_14005565322850_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; exports[`babel plugin for async functions makes an async worklet string 1`] = ` "var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); -var _worklet_2720353136439_init_data = { - code: "async function foo(){await Promise.resolve();}", +var _worklet_14005565322850_init_data = { + code: "async function foo_null1(){await Promise.resolve();}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function () { + var foo_null1 = function () { var _ref = (0, _asyncToGenerator2.default)(function* () { yield Promise.resolve(); }); - return function foo() { + return function foo_null1() { return _ref.apply(this, arguments); }; }(); - foo.__closure = {}; - foo.__workletHash = 2720353136439; - foo.__initData = _worklet_2720353136439_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 14005565322850; + foo_null1.__initData = _worklet_14005565322850_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; @@ -393,8 +393,8 @@ exports[`babel plugin for class worklets workletizes class field 1`] = ` "var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _worklet_16347365292089_init_data = { - code: "function anonymous(x){return x+2;}", +var _worklet_2294411833184_init_data = { + code: "function null1(x){return x+2;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -403,14 +403,14 @@ var Foo = (0, _createClass2.default)(function Foo() { (0, _classCallCheck2.default)(this, Foo); this.bar = function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous(x) { + var null1 = function null1(x) { return x + 2; }; - anonymous.__closure = {}; - anonymous.__workletHash = 16347365292089; - anonymous.__initData = _worklet_16347365292089_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 2294411833184; + null1.__initData = _worklet_2294411833184_init_data; + null1.__stackDetails = _e; + return null1; }(); });" `; @@ -419,25 +419,25 @@ exports[`babel plugin for class worklets workletizes constructor 1`] = ` "var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); -var _worklet_11052941891417_init_data = { - code: "function Foo(x){const Foo=this._recur;const{_classCallCheck}=this.__closure;_classCallCheck(this,Foo);this.x=x;}", +var _worklet_8889327806636_init_data = { + code: "function Foo_null1(x){const Foo_null1=this._recur;const{_classCallCheck}=this.__closure;_classCallCheck(this,Foo_null1);this.x=x;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var Foo = (0, _createClass2.default)(function () { var _e = [new global.Error(), -2, -27]; - var Foo = function Foo(x) { + var Foo_null1 = function Foo_null1(x) { (0, _classCallCheck2.default)(this, Foo); this.x = x; }; - Foo.__closure = { + Foo_null1.__closure = { _classCallCheck: _classCallCheck2.default }; - Foo.__workletHash = 11052941891417; - Foo.__initData = _worklet_11052941891417_init_data; - Foo.__stackDetails = _e; - return Foo; + Foo_null1.__workletHash = 8889327806636; + Foo_null1.__initData = _worklet_8889327806636_init_data; + Foo_null1.__stackDetails = _e; + return Foo_null1; }());" `; @@ -445,8 +445,8 @@ exports[`babel plugin for class worklets workletizes getter 1`] = ` "var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _worklet_13932542455552_init_data = { - code: "function get(){const{x}=this.__closure;return x+2;}", +var _worklet_13515258128853_init_data = { + code: "function get_null1(){const{x}=this.__closure;return x+2;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -459,16 +459,16 @@ var Foo = function () { key: "bar", get: function () { var _e = [new global.Error(), -2, -27]; - var get = function get() { + var get_null1 = function get_null1() { return x + 2; }; - get.__closure = { + get_null1.__closure = { x: x }; - get.__workletHash = 13932542455552; - get.__initData = _worklet_13932542455552_init_data; - get.__stackDetails = _e; - return get; + get_null1.__workletHash = 13515258128853; + get_null1.__initData = _worklet_13515258128853_init_data; + get_null1.__stackDetails = _e; + return get_null1; }() }]); }();" @@ -478,8 +478,8 @@ exports[`babel plugin for class worklets workletizes instance method 1`] = ` "var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _worklet_16974800582491_init_data = { - code: "function bar(x){return x+2;}", +var _worklet_10686480819086_init_data = { + code: "function bar_null1(x){return x+2;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -492,14 +492,14 @@ var Foo = function () { key: "bar", value: function () { var _e = [new global.Error(), 1, -27]; - var bar = function bar(x) { + var bar_null1 = function bar_null1(x) { return x + 2; }; - bar.__closure = {}; - bar.__workletHash = 16974800582491; - bar.__initData = _worklet_16974800582491_init_data; - bar.__stackDetails = _e; - return bar; + bar_null1.__closure = {}; + bar_null1.__workletHash = 10686480819086; + bar_null1.__initData = _worklet_10686480819086_init_data; + bar_null1.__stackDetails = _e; + return bar_null1; }() }]); }();" @@ -509,8 +509,8 @@ exports[`babel plugin for class worklets workletizes setter 1`] = ` "var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _worklet_6451428689423_init_data = { - code: "function set(x){this.x=x+2;}", +var _worklet_14784735859354_init_data = { + code: "function set_null1(x){this.x=x+2;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -523,14 +523,14 @@ var Foo = function () { key: "bar", set: function () { var _e = [new global.Error(), 1, -27]; - var set = function set(x) { + var set_null1 = function set_null1(x) { this.x = x + 2; }; - set.__closure = {}; - set.__workletHash = 6451428689423; - set.__initData = _worklet_6451428689423_init_data; - set.__stackDetails = _e; - return set; + set_null1.__closure = {}; + set_null1.__workletHash = 14784735859354; + set_null1.__initData = _worklet_14784735859354_init_data; + set_null1.__stackDetails = _e; + return set_null1; }() }]); }();" @@ -543,22 +543,22 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl var Foo = (0, _createClass2.default)(function Foo() { (0, _classCallCheck2.default)(this, Foo); }); -var _worklet_16347365292089_init_data = { - code: "function anonymous(x){return x+2;}", +var _worklet_2294411833184_init_data = { + code: "function null1(x){return x+2;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; Foo.bar = function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous(x) { + var null1 = function null1(x) { return x + 2; }; - anonymous.__closure = {}; - anonymous.__workletHash = 16347365292089; - anonymous.__initData = _worklet_16347365292089_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 2294411833184; + null1.__initData = _worklet_2294411833184_init_data; + null1.__stackDetails = _e; + return null1; }();" `; @@ -566,8 +566,8 @@ exports[`babel plugin for class worklets workletizes static method 1`] = ` "var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); -var _worklet_16974800582491_init_data = { - code: "function bar(x){return x+2;}", +var _worklet_10686480819086_init_data = { + code: "function bar_null1(x){return x+2;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -580,14 +580,14 @@ var Foo = function () { key: "bar", value: function () { var _e = [new global.Error(), 1, -27]; - var bar = function bar(x) { + var bar_null1 = function bar_null1(x) { return x + 2; }; - bar.__closure = {}; - bar.__workletHash = 16974800582491; - bar.__initData = _worklet_16974800582491_init_data; - bar.__stackDetails = _e; - return bar; + bar_null1.__closure = {}; + bar_null1.__workletHash = 10686480819086; + bar_null1.__initData = _worklet_10686480819086_init_data; + bar_null1.__stackDetails = _e; + return bar_null1; }() }]); }();" @@ -598,88 +598,88 @@ exports[`babel plugin for closure capturing captures worklets environment 1`] = var objX = { x: x }; -var _worklet_3447562087488_init_data = { - code: "function f(){const{x,objX}=this.__closure;return{res:x+objX.x};}", +var _worklet_10550735168277_init_data = { + code: "function f_null1(){const{x,objX}=this.__closure;return{res:x+objX.x};}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var f = function () { var _e = [new global.Error(), -3, -27]; - var f = function f() { + var f_null1 = function f_null1() { return { res: x + objX.x }; }; - f.__closure = { + f_null1.__closure = { x: x, objX: objX }; - f.__workletHash = 3447562087488; - f.__initData = _worklet_3447562087488_init_data; - f.__stackDetails = _e; - return f; + f_null1.__workletHash = 10550735168277; + f_null1.__initData = _worklet_10550735168277_init_data; + f_null1.__stackDetails = _e; + return f_null1; }();" `; exports[`babel plugin for closure capturing doesn't capture arguments 1`] = ` -"var _worklet_17093819837059_init_data = { - code: "function f(a,b,c){console.log(arguments);}", +"var _worklet_11756143316246_init_data = { + code: "function f_null1(a,b,c){console.log(arguments);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var f = function () { var _e = [new global.Error(), 1, -27]; - var f = function f(a, b, c) { + var f_null1 = function f_null1(a, b, c) { console.log(arguments); }; - f.__closure = {}; - f.__workletHash = 17093819837059; - f.__initData = _worklet_17093819837059_init_data; - f.__stackDetails = _e; - return f; + f_null1.__closure = {}; + f_null1.__workletHash = 11756143316246; + f_null1.__initData = _worklet_11756143316246_init_data; + f_null1.__stackDetails = _e; + return f_null1; }();" `; exports[`babel plugin for closure capturing doesn't capture custom globals 1`] = ` "var foo = 42; -var _worklet_7141086932261_init_data = { - code: "function f(){console.log(foo);}", +var _worklet_11658370598384_init_data = { + code: "function f_null1(){console.log(foo);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var f = function () { var _e = [new global.Error(), 1, -27]; - var f = function f() { + var f_null1 = function f_null1() { console.log(foo); }; - f.__closure = {}; - f.__workletHash = 7141086932261; - f.__initData = _worklet_7141086932261_init_data; - f.__stackDetails = _e; - return f; + f_null1.__closure = {}; + f_null1.__workletHash = 11658370598384; + f_null1.__initData = _worklet_11658370598384_init_data; + f_null1.__stackDetails = _e; + return f_null1; }();" `; exports[`babel plugin for closure capturing doesn't capture default globals 1`] = ` -"var _worklet_13298016111221_init_data = { - code: "function f(){console.log('test');}", +"var _worklet_9451494835104_init_data = { + code: "function f_null1(){console.log('test');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var f = function () { var _e = [new global.Error(), 1, -27]; - var f = function f() { + var f_null1 = function f_null1() { console.log('test'); }; - f.__closure = {}; - f.__workletHash = 13298016111221; - f.__initData = _worklet_13298016111221_init_data; - f.__stackDetails = _e; - return f; + f_null1.__closure = {}; + f_null1.__workletHash = 9451494835104; + f_null1.__initData = _worklet_9451494835104_init_data; + f_null1.__stackDetails = _e; + return f_null1; }();" `; @@ -687,120 +687,120 @@ exports[`babel plugin for closure capturing doesn't capture objects' properties "var foo = { bar: 42 }; -var _worklet_3750134465664_init_data = { - code: "function f(){const{foo}=this.__closure;console.log(foo.bar);}", +var _worklet_239990909653_init_data = { + code: "function f_null1(){const{foo}=this.__closure;console.log(foo.bar);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var f = function () { var _e = [new global.Error(), -2, -27]; - var f = function f() { + var f_null1 = function f_null1() { console.log(foo.bar); }; - f.__closure = { + f_null1.__closure = { foo: foo }; - f.__workletHash = 3750134465664; - f.__initData = _worklet_3750134465664_init_data; - f.__stackDetails = _e; - return f; + f_null1.__workletHash = 239990909653; + f_null1.__initData = _worklet_239990909653_init_data; + f_null1.__stackDetails = _e; + return f_null1; }();" `; exports[`babel plugin for debugging does inject location for worklets in dev builds 1`] = ` -"var _worklet_1852213185147_init_data = { - code: "function anonymous(){const x=1;}", +"var _worklet_8623346549410_init_data = { + code: "function null1(){const x=1;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = useAnimatedStyle(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { var x = 1; }; - anonymous.__closure = {}; - anonymous.__workletHash = 1852213185147; - anonymous.__initData = _worklet_1852213185147_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 8623346549410; + null1.__initData = _worklet_8623346549410_init_data; + null1.__stackDetails = _e; + return null1; }());" `; exports[`babel plugin for debugging doesn't inject location for worklets in production builds 1`] = ` -"var _worklet_1852213185147_init_data = { - code: "function anonymous(){const x=1;}" +"var _worklet_8623346549410_init_data = { + code: "function null1(){const x=1;}" }; var foo = useAnimatedStyle(function () { - var anonymous = function anonymous() { + var null1 = function null1() { var x = 1; }; - anonymous.__closure = {}; - anonymous.__workletHash = 1852213185147; - anonymous.__initData = _worklet_1852213185147_init_data; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 8623346549410; + null1.__initData = _worklet_8623346549410_init_data; + return null1; }());" `; exports[`babel plugin for debugging doesn't inject version for worklets in production builds 1`] = ` -"var _worklet_1852213185147_init_data = { - code: "function anonymous(){const x=1;}" +"var _worklet_8623346549410_init_data = { + code: "function null1(){const x=1;}" }; var foo = useAnimatedStyle(function () { - var anonymous = function anonymous() { + var null1 = function null1() { var x = 1; }; - anonymous.__closure = {}; - anonymous.__workletHash = 1852213185147; - anonymous.__initData = _worklet_1852213185147_init_data; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 8623346549410; + null1.__initData = _worklet_8623346549410_init_data; + return null1; }());" `; exports[`babel plugin for explicit worklets workletizes ArrowFunctionExpression 1`] = ` -"var _worklet_16347365292089_init_data = { - code: "function anonymous(x){return x+2;}", +"var _worklet_2294411833184_init_data = { + code: "function null1(x){return x+2;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous(x) { + var null1 = function null1(x) { return x + 2; }; - anonymous.__closure = {}; - anonymous.__workletHash = 16347365292089; - anonymous.__initData = _worklet_16347365292089_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 2294411833184; + null1.__initData = _worklet_2294411833184_init_data; + null1.__stackDetails = _e; + return null1; }();" `; exports[`babel plugin for explicit worklets workletizes FunctionDeclaration 1`] = ` -"var _worklet_4679479961836_init_data = { - code: "function foo(x){return x+2;}", +"var _worklet_2156194750585_init_data = { + code: "function foo_null1(x){return x+2;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function foo(x) { + var foo_null1 = function foo_null1(x) { return x + 2; }; - foo.__closure = {}; - foo.__workletHash = 4679479961836; - foo.__initData = _worklet_4679479961836_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 2156194750585; + foo_null1.__initData = _worklet_2156194750585_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; exports[`babel plugin for explicit worklets workletizes ObjectMethod 1`] = ` -"var _worklet_16974800582491_init_data = { - code: "function bar(x){return x+2;}", +"var _worklet_10686480819086_init_data = { + code: "function bar_null1(x){return x+2;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -808,187 +808,187 @@ exports[`babel plugin for explicit worklets workletizes ObjectMethod 1`] = ` var foo = { bar: function () { var _e = [new global.Error(), 1, -27]; - var bar = function bar(x) { + var bar_null1 = function bar_null1(x) { return x + 2; }; - bar.__closure = {}; - bar.__workletHash = 16974800582491; - bar.__initData = _worklet_16974800582491_init_data; - bar.__stackDetails = _e; - return bar; + bar_null1.__closure = {}; + bar_null1.__workletHash = 10686480819086; + bar_null1.__initData = _worklet_10686480819086_init_data; + bar_null1.__stackDetails = _e; + return bar_null1; }() };" `; exports[`babel plugin for explicit worklets workletizes named FunctionExpression 1`] = ` -"var _worklet_4679479961836_init_data = { - code: "function foo(x){return x+2;}", +"var _worklet_2156194750585_init_data = { + code: "function foo_null1(x){return x+2;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function foo(x) { + var foo_null1 = function foo_null1(x) { return x + 2; }; - foo.__closure = {}; - foo.__workletHash = 4679479961836; - foo.__initData = _worklet_4679479961836_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 2156194750585; + foo_null1.__initData = _worklet_2156194750585_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; exports[`babel plugin for explicit worklets workletizes unnamed FunctionExpression 1`] = ` -"var _worklet_16347365292089_init_data = { - code: "function anonymous(x){return x+2;}", +"var _worklet_2294411833184_init_data = { + code: "function null1(x){return x+2;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous(x) { + var null1 = function null1(x) { return x + 2; }; - anonymous.__closure = {}; - anonymous.__workletHash = 16347365292089; - anonymous.__initData = _worklet_16347365292089_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 2294411833184; + null1.__initData = _worklet_2294411833184_init_data; + null1.__stackDetails = _e; + return null1; }();" `; exports[`babel plugin for function hooks workletizes hook wrapped ArrowFunctionExpression automatically 1`] = ` -"var _worklet_9645206935615_init_data = { - code: "function anonymous(){return{width:50};}", +"var _worklet_1392490775014_init_data = { + code: "function null1(){return{width:50};}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var animatedStyle = useAnimatedStyle(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { return { width: 50 }; }; - anonymous.__closure = {}; - anonymous.__workletHash = 9645206935615; - anonymous.__initData = _worklet_9645206935615_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 1392490775014; + null1.__initData = _worklet_1392490775014_init_data; + null1.__stackDetails = _e; + return null1; }());" `; exports[`babel plugin for function hooks workletizes hook wrapped named FunctionExpression automatically 1`] = ` -"var _worklet_6275510763626_init_data = { - code: "function foo(){return{width:50};}", +"var _worklet_9984171279103_init_data = { + code: "function foo_null1(){return{width:50};}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var animatedStyle = useAnimatedStyle(function () { var _e = [new global.Error(), 1, -27]; - var foo = function foo() { + var foo_null1 = function foo_null1() { return { width: 50 }; }; - foo.__closure = {}; - foo.__workletHash = 6275510763626; - foo.__initData = _worklet_6275510763626_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 9984171279103; + foo_null1.__initData = _worklet_9984171279103_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }());" `; exports[`babel plugin for function hooks workletizes hook wrapped unnamed FunctionExpression automatically 1`] = ` -"var _worklet_9645206935615_init_data = { - code: "function anonymous(){return{width:50};}", +"var _worklet_1392490775014_init_data = { + code: "function null1(){return{width:50};}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var animatedStyle = useAnimatedStyle(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { return { width: 50 }; }; - anonymous.__closure = {}; - anonymous.__workletHash = 9645206935615; - anonymous.__initData = _worklet_9645206935615_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 1392490775014; + null1.__initData = _worklet_1392490775014_init_data; + null1.__stackDetails = _e; + return null1; }());" `; exports[`babel plugin for function hooks workletizes hook wrapped worklet reference automatically 1`] = ` -"var _worklet_377598887181_init_data = { - code: "function style(){return{color:'red',backgroundColor:'blue'};}", +"var _worklet_3038192071896_init_data = { + code: "function style_null1(){return{color:'red',backgroundColor:'blue'};}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var style = function () { const _e = [new global.Error(), 1, -27]; - const style = function () { + const style_null1 = function () { return { color: 'red', backgroundColor: 'blue' }; }; - style.__closure = {}; - style.__workletHash = 377598887181; - style.__initData = _worklet_377598887181_init_data; - style.__stackDetails = _e; - return style; + style_null1.__closure = {}; + style_null1.__workletHash = 3038192071896; + style_null1.__initData = _worklet_3038192071896_init_data; + style_null1.__stackDetails = _e; + return style_null1; }(); var animatedStyle = useAnimatedStyle(style);" `; exports[`babel plugin for generators makes a generator worklet factory 1`] = ` -"var _worklet_4939499253486_init_data = { - code: "function*foo(){yield'hello';yield'world';}", +"var _worklet_4135278281851_init_data = { + code: "function*foo_null1(){yield'hello';yield'world';}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function* foo() { + var foo_null1 = function* foo_null1() { yield 'hello'; yield 'world'; }; - foo.__closure = {}; - foo.__workletHash = 4939499253486; - foo.__initData = _worklet_4939499253486_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 4135278281851; + foo_null1.__initData = _worklet_4135278281851_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; exports[`babel plugin for generators makes a generator worklet string 1`] = ` -"var _worklet_4939499253486_init_data = { - code: "function*foo(){yield'hello';yield'world';}", +"var _worklet_4135278281851_init_data = { + code: "function*foo_null1(){yield'hello';yield'world';}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function* foo() { + var foo_null1 = function* foo_null1() { yield 'hello'; yield 'world'; }; - foo.__closure = {}; - foo.__workletHash = 4939499253486; - foo.__initData = _worklet_4939499253486_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 4135278281851; + foo_null1.__initData = _worklet_4135278281851_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; @@ -1056,40 +1056,40 @@ exports[`babel plugin for object hooks supports empty object in useAnimatedGestu exports[`babel plugin for object hooks supports empty object in useAnimatedScrollHandler 1`] = `"useAnimatedScrollHandler({});"`; exports[`babel plugin for object hooks transforms ArrowFunctionExpression as argument of useAnimatedScrollHandler 1`] = ` -"var _worklet_1022605193782_init_data = { - code: "function anonymous(event){console.log(event);}", +"var _worklet_6572201563503_init_data = { + code: "function null1(event){console.log(event);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; useAnimatedScrollHandler(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous(event) { + var null1 = function null1(event) { console.log(event); }; - anonymous.__closure = {}; - anonymous.__workletHash = 1022605193782; - anonymous.__initData = _worklet_1022605193782_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 6572201563503; + null1.__initData = _worklet_6572201563503_init_data; + null1.__stackDetails = _e; + return null1; }());" `; exports[`babel plugin for object hooks transforms each object property in useAnimatedGestureHandler 1`] = ` -"var _worklet_14892326408241_init_data = { - code: "function anonymous(){}", +"var _worklet_17107900483944_init_data = { + code: "function null1(){}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_14892326408241_init_data2 = { - code: "function anonymous(){}", +var _worklet_15612771346699_init_data = { + code: "function null2(){}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_14892326408241_init_data3 = { - code: "function anonymous(){}", +var _worklet_3001796818986_init_data = { + code: "function null3(){}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1097,61 +1097,61 @@ var _worklet_14892326408241_init_data3 = { useAnimatedGestureHandler({ onStart: function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() {}; - anonymous.__closure = {}; - anonymous.__workletHash = 14892326408241; - anonymous.__initData = _worklet_14892326408241_init_data; - anonymous.__stackDetails = _e; - return anonymous; + var null1 = function null1() {}; + null1.__closure = {}; + null1.__workletHash = 17107900483944; + null1.__initData = _worklet_17107900483944_init_data; + null1.__stackDetails = _e; + return null1; }(), onUpdate: function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() {}; - anonymous.__closure = {}; - anonymous.__workletHash = 14892326408241; - anonymous.__initData = _worklet_14892326408241_init_data2; - anonymous.__stackDetails = _e; - return anonymous; + var null2 = function null2() {}; + null2.__closure = {}; + null2.__workletHash = 15612771346699; + null2.__initData = _worklet_15612771346699_init_data; + null2.__stackDetails = _e; + return null2; }(), onEnd: function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() {}; - anonymous.__closure = {}; - anonymous.__workletHash = 14892326408241; - anonymous.__initData = _worklet_14892326408241_init_data3; - anonymous.__stackDetails = _e; - return anonymous; + var null3 = function null3() {}; + null3.__closure = {}; + null3.__workletHash = 3001796818986; + null3.__initData = _worklet_3001796818986_init_data; + null3.__stackDetails = _e; + return null3; }() });" `; exports[`babel plugin for object hooks transforms each object property in useAnimatedScrollHandler 1`] = ` -"var _worklet_14892326408241_init_data = { - code: "function anonymous(){}", +"var _worklet_17107900483944_init_data = { + code: "function null1(){}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_14892326408241_init_data2 = { - code: "function anonymous(){}", +var _worklet_15612771346699_init_data = { + code: "function null2(){}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_14892326408241_init_data3 = { - code: "function anonymous(){}", +var _worklet_3001796818986_init_data = { + code: "function null3(){}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_14892326408241_init_data4 = { - code: "function anonymous(){}", +var _worklet_14370141256397_init_data = { + code: "function null4(){}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_14892326408241_init_data5 = { - code: "function anonymous(){}", +var _worklet_16301592545772_init_data = { + code: "function null5(){}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1159,95 +1159,95 @@ var _worklet_14892326408241_init_data5 = { useAnimatedScrollHandler({ onScroll: function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() {}; - anonymous.__closure = {}; - anonymous.__workletHash = 14892326408241; - anonymous.__initData = _worklet_14892326408241_init_data; - anonymous.__stackDetails = _e; - return anonymous; + var null1 = function null1() {}; + null1.__closure = {}; + null1.__workletHash = 17107900483944; + null1.__initData = _worklet_17107900483944_init_data; + null1.__stackDetails = _e; + return null1; }(), onBeginDrag: function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() {}; - anonymous.__closure = {}; - anonymous.__workletHash = 14892326408241; - anonymous.__initData = _worklet_14892326408241_init_data2; - anonymous.__stackDetails = _e; - return anonymous; + var null2 = function null2() {}; + null2.__closure = {}; + null2.__workletHash = 15612771346699; + null2.__initData = _worklet_15612771346699_init_data; + null2.__stackDetails = _e; + return null2; }(), onEndDrag: function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() {}; - anonymous.__closure = {}; - anonymous.__workletHash = 14892326408241; - anonymous.__initData = _worklet_14892326408241_init_data3; - anonymous.__stackDetails = _e; - return anonymous; + var null3 = function null3() {}; + null3.__closure = {}; + null3.__workletHash = 3001796818986; + null3.__initData = _worklet_3001796818986_init_data; + null3.__stackDetails = _e; + return null3; }(), onMomentumBegin: function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() {}; - anonymous.__closure = {}; - anonymous.__workletHash = 14892326408241; - anonymous.__initData = _worklet_14892326408241_init_data4; - anonymous.__stackDetails = _e; - return anonymous; + var null4 = function null4() {}; + null4.__closure = {}; + null4.__workletHash = 14370141256397; + null4.__initData = _worklet_14370141256397_init_data; + null4.__stackDetails = _e; + return null4; }(), onMomentumEnd: function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() {}; - anonymous.__closure = {}; - anonymous.__workletHash = 14892326408241; - anonymous.__initData = _worklet_14892326408241_init_data5; - anonymous.__stackDetails = _e; - return anonymous; + var null5 = function null5() {}; + null5.__closure = {}; + null5.__workletHash = 16301592545772; + null5.__initData = _worklet_16301592545772_init_data; + null5.__stackDetails = _e; + return null5; }() });" `; exports[`babel plugin for object hooks transforms named FunctionExpression as argument of useAnimatedScrollHandler 1`] = ` -"var _worklet_14540236792163_init_data = { - code: "function foo(event){console.log(event);}", +"var _worklet_13903338421046_init_data = { + code: "function foo_null1(event){console.log(event);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; useAnimatedScrollHandler(function () { var _e = [new global.Error(), 1, -27]; - var foo = function foo(event) { + var foo_null1 = function foo_null1(event) { console.log(event); }; - foo.__closure = {}; - foo.__workletHash = 14540236792163; - foo.__initData = _worklet_14540236792163_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 13903338421046; + foo_null1.__initData = _worklet_13903338421046_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }());" `; exports[`babel plugin for object hooks transforms unnamed FunctionExpression as argument of useAnimatedScrollHandler 1`] = ` -"var _worklet_1022605193782_init_data = { - code: "function anonymous(event){console.log(event);}", +"var _worklet_6572201563503_init_data = { + code: "function null1(event){console.log(event);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; useAnimatedScrollHandler(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous(event) { + var null1 = function null1(event) { console.log(event); }; - anonymous.__closure = {}; - anonymous.__workletHash = 1022605193782; - anonymous.__initData = _worklet_1022605193782_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 6572201563503; + null1.__initData = _worklet_6572201563503_init_data; + null1.__stackDetails = _e; + return null1; }());" `; exports[`babel plugin for object hooks workletizes useAnimatedGestureHandler wrapped ArrowFunctionExpression automatically 1`] = ` -"var _worklet_1022605193782_init_data = { - code: "function anonymous(event){console.log(event);}", +"var _worklet_6572201563503_init_data = { + code: "function null1(event){console.log(event);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1255,21 +1255,21 @@ exports[`babel plugin for object hooks workletizes useAnimatedGestureHandler wra useAnimatedGestureHandler({ onStart: function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous(event) { + var null1 = function null1(event) { console.log(event); }; - anonymous.__closure = {}; - anonymous.__workletHash = 1022605193782; - anonymous.__initData = _worklet_1022605193782_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 6572201563503; + null1.__initData = _worklet_6572201563503_init_data; + null1.__stackDetails = _e; + return null1; }() });" `; exports[`babel plugin for object hooks workletizes useAnimatedGestureHandler wrapped ObjectMethod automatically 1`] = ` -"var _worklet_338158776260_init_data = { - code: "function onStart(event){console.log(event);}", +"var _worklet_6368412250705_init_data = { + code: "function onStart_null1(event){console.log(event);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1277,21 +1277,21 @@ exports[`babel plugin for object hooks workletizes useAnimatedGestureHandler wra useAnimatedGestureHandler({ onStart: function () { var _e = [new global.Error(), 1, -27]; - var onStart = function onStart(event) { + var onStart_null1 = function onStart_null1(event) { console.log(event); }; - onStart.__closure = {}; - onStart.__workletHash = 338158776260; - onStart.__initData = _worklet_338158776260_init_data; - onStart.__stackDetails = _e; - return onStart; + onStart_null1.__closure = {}; + onStart_null1.__workletHash = 6368412250705; + onStart_null1.__initData = _worklet_6368412250705_init_data; + onStart_null1.__stackDetails = _e; + return onStart_null1; }() });" `; exports[`babel plugin for object hooks workletizes useAnimatedGestureHandler wrapped named FunctionExpression automatically 1`] = ` -"var _worklet_338158776260_init_data = { - code: "function onStart(event){console.log(event);}", +"var _worklet_6368412250705_init_data = { + code: "function onStart_null1(event){console.log(event);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1299,21 +1299,21 @@ exports[`babel plugin for object hooks workletizes useAnimatedGestureHandler wra useAnimatedGestureHandler({ onStart: function () { var _e = [new global.Error(), 1, -27]; - var onStart = function onStart(event) { + var onStart_null1 = function onStart_null1(event) { console.log(event); }; - onStart.__closure = {}; - onStart.__workletHash = 338158776260; - onStart.__initData = _worklet_338158776260_init_data; - onStart.__stackDetails = _e; - return onStart; + onStart_null1.__closure = {}; + onStart_null1.__workletHash = 6368412250705; + onStart_null1.__initData = _worklet_6368412250705_init_data; + onStart_null1.__stackDetails = _e; + return onStart_null1; }() });" `; exports[`babel plugin for object hooks workletizes useAnimatedGestureHandler wrapped unnamed FunctionExpression automatically 1`] = ` -"var _worklet_1022605193782_init_data = { - code: "function anonymous(event){console.log(event);}", +"var _worklet_6572201563503_init_data = { + code: "function null1(event){console.log(event);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1321,21 +1321,21 @@ exports[`babel plugin for object hooks workletizes useAnimatedGestureHandler wra useAnimatedGestureHandler({ onStart: function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous(event) { + var null1 = function null1(event) { console.log(event); }; - anonymous.__closure = {}; - anonymous.__workletHash = 1022605193782; - anonymous.__initData = _worklet_1022605193782_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 6572201563503; + null1.__initData = _worklet_6572201563503_init_data; + null1.__stackDetails = _e; + return null1; }() });" `; exports[`babel plugin for object hooks workletizes useAnimatedScrollHandler wrapped ArrowFunctionExpression automatically 1`] = ` -"var _worklet_1022605193782_init_data = { - code: "function anonymous(event){console.log(event);}", +"var _worklet_6572201563503_init_data = { + code: "function null1(event){console.log(event);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1343,21 +1343,21 @@ exports[`babel plugin for object hooks workletizes useAnimatedScrollHandler wrap useAnimatedScrollHandler({ onScroll: function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous(event) { + var null1 = function null1(event) { console.log(event); }; - anonymous.__closure = {}; - anonymous.__workletHash = 1022605193782; - anonymous.__initData = _worklet_1022605193782_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 6572201563503; + null1.__initData = _worklet_6572201563503_init_data; + null1.__stackDetails = _e; + return null1; }() });" `; exports[`babel plugin for object hooks workletizes useAnimatedScrollHandler wrapped ObjectMethod automatically 1`] = ` -"var _worklet_947458829673_init_data = { - code: "function onScroll(event){console.log(event);}", +"var _worklet_11162089192476_init_data = { + code: "function onScroll_null1(event){console.log(event);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1365,21 +1365,21 @@ exports[`babel plugin for object hooks workletizes useAnimatedScrollHandler wrap useAnimatedGestureHandler({ onScroll: function () { var _e = [new global.Error(), 1, -27]; - var onScroll = function onScroll(event) { + var onScroll_null1 = function onScroll_null1(event) { console.log(event); }; - onScroll.__closure = {}; - onScroll.__workletHash = 947458829673; - onScroll.__initData = _worklet_947458829673_init_data; - onScroll.__stackDetails = _e; - return onScroll; + onScroll_null1.__closure = {}; + onScroll_null1.__workletHash = 11162089192476; + onScroll_null1.__initData = _worklet_11162089192476_init_data; + onScroll_null1.__stackDetails = _e; + return onScroll_null1; }() });" `; exports[`babel plugin for object hooks workletizes useAnimatedScrollHandler wrapped named FunctionExpression automatically 1`] = ` -"var _worklet_947458829673_init_data = { - code: "function onScroll(event){console.log(event);}", +"var _worklet_11162089192476_init_data = { + code: "function onScroll_null1(event){console.log(event);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1387,21 +1387,21 @@ exports[`babel plugin for object hooks workletizes useAnimatedScrollHandler wrap useAnimatedScrollHandler({ onScroll: function () { var _e = [new global.Error(), 1, -27]; - var onScroll = function onScroll(event) { + var onScroll_null1 = function onScroll_null1(event) { console.log(event); }; - onScroll.__closure = {}; - onScroll.__workletHash = 947458829673; - onScroll.__initData = _worklet_947458829673_init_data; - onScroll.__stackDetails = _e; - return onScroll; + onScroll_null1.__closure = {}; + onScroll_null1.__workletHash = 11162089192476; + onScroll_null1.__initData = _worklet_11162089192476_init_data; + onScroll_null1.__stackDetails = _e; + return onScroll_null1; }() });" `; exports[`babel plugin for object hooks workletizes useAnimatedScrollHandler wrapped unnamed FunctionExpression automatically 1`] = ` -"var _worklet_1022605193782_init_data = { - code: "function anonymous(event){console.log(event);}", +"var _worklet_6572201563503_init_data = { + code: "function null1(event){console.log(event);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1409,14 +1409,14 @@ exports[`babel plugin for object hooks workletizes useAnimatedScrollHandler wrap useAnimatedScrollHandler({ onScroll: function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous(event) { + var null1 = function null1(event) { console.log(event); }; - anonymous.__closure = {}; - anonymous.__workletHash = 1022605193782; - anonymous.__initData = _worklet_1022605193782_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 6572201563503; + null1.__initData = _worklet_6572201563503_init_data; + null1.__stackDetails = _e; + return null1; }() });" `; @@ -1450,82 +1450,82 @@ function App() { `; exports[`babel plugin for react-native-gesture-handler transforms spread operator in worklets for arrays 1`] = ` -"var _worklet_3161057533258_init_data = { - code: "function foo(){const bar=[4,5];const baz=[1,...[2,3],...bar];}", +"var _worklet_10797201137439_init_data = { + code: "function foo_null1(){const bar=[4,5];const baz=[1,...[2,3],...bar];}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function foo() { + var foo_null1 = function foo_null1() { var bar = [4, 5]; var baz = [1].concat([2, 3], bar); }; - foo.__closure = {}; - foo.__workletHash = 3161057533258; - foo.__initData = _worklet_3161057533258_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 10797201137439; + foo_null1.__initData = _worklet_10797201137439_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; exports[`babel plugin for react-native-gesture-handler transforms spread operator in worklets for function arguments 1`] = ` -"var _worklet_9866931756941_init_data = { - code: "function foo(...args){console.log(args);}", +"var _worklet_7564534166424_init_data = { + code: "function foo_null1(...args){console.log(args);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function foo() { + var foo_null1 = function foo_null1() { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } console.log(args); }; - foo.__closure = {}; - foo.__workletHash = 9866931756941; - foo.__initData = _worklet_9866931756941_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 7564534166424; + foo_null1.__initData = _worklet_7564534166424_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; exports[`babel plugin for react-native-gesture-handler transforms spread operator in worklets for function calls 1`] = ` "var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); -var _worklet_2015887751437_init_data = { - code: "function foo(arg){console.log(...arg);}", +var _worklet_14662302952728_init_data = { + code: "function foo_null1(arg){console.log(...arg);}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function foo(arg) { + var foo_null1 = function foo_null1(arg) { var _console; (_console = console).log.apply(_console, (0, _toConsumableArray2.default)(arg)); }; - foo.__closure = {}; - foo.__workletHash = 2015887751437; - foo.__initData = _worklet_2015887751437_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 14662302952728; + foo_null1.__initData = _worklet_14662302952728_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; exports[`babel plugin for react-native-gesture-handler transforms spread operator in worklets for objects 1`] = ` -"var _worklet_792186851025_init_data = { - code: "function foo(){const bar={d:4,e:5};const baz={a:1,...{b:2,c:3},...bar};}", +"var _worklet_4831123253572_init_data = { + code: "function foo_null1(){const bar={d:4,e:5};const baz={a:1,...{b:2,c:3},...bar};}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function foo() { + var foo_null1 = function foo_null1() { var bar = { d: 4, e: 5 @@ -1537,63 +1537,63 @@ var foo = function () { c: 3 }, bar); }; - foo.__closure = {}; - foo.__workletHash = 792186851025; - foo.__initData = _worklet_792186851025_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 4831123253572; + foo_null1.__initData = _worklet_4831123253572_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; exports[`babel plugin for react-native-gesture-handler workletizes possibly chained gesture object callback functions automatically 1`] = ` -"var _worklet_15393478329680_init_data = { - code: "function anonymous(){console.log('onBegin');}", +"var _worklet_13539781966089_init_data = { + code: "function null1(){console.log('onBegin');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_12748187344900_init_data = { - code: "function anonymous(_event){console.log('onStart');}", +var _worklet_16446448315454_init_data = { + code: "function null2(_event){console.log('onStart');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_232586479291_init_data = { - code: "function anonymous(_event,_success){console.log('onEnd');}", +var _worklet_16462958026656_init_data = { + code: "function null3(_event,_success){console.log('onEnd');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = Gesture.Tap().numberOfTaps(2).onBegin(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('onBegin'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 15393478329680; - anonymous.__initData = _worklet_15393478329680_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 13539781966089; + null1.__initData = _worklet_13539781966089_init_data; + null1.__stackDetails = _e; + return null1; }()).onStart(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous(_event) { + var null2 = function null2(_event) { console.log('onStart'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 12748187344900; - anonymous.__initData = _worklet_12748187344900_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null2.__closure = {}; + null2.__workletHash = 16446448315454; + null2.__initData = _worklet_16446448315454_init_data; + null2.__stackDetails = _e; + return null2; }()).onEnd(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous(_event, _success) { + var null3 = function null3(_event, _success) { console.log('onEnd'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 232586479291; - anonymous.__initData = _worklet_232586479291_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null3.__closure = {}; + null3.__workletHash = 16462958026656; + null3.__initData = _worklet_16462958026656_init_data; + null3.__stackDetails = _e; + return null3; }());" `; @@ -1601,22 +1601,22 @@ exports[`babel plugin for referenced worklets prefers AssignmentExpression over "var styleFactory = function styleFactory() { return 1; }; -var _worklet_2302253389457_init_data = { - code: "function styleFactory(){return'AssignmentExpression';}", +var _worklet_7165463824996_init_data = { + code: "function styleFactory_null1(){return'AssignmentExpression';}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; styleFactory = function () { const _e = [new global.Error(), 1, -27]; - const styleFactory = function () { + const styleFactory_null1 = function () { return 'AssignmentExpression'; }; - styleFactory.__closure = {}; - styleFactory.__workletHash = 2302253389457; - styleFactory.__initData = _worklet_2302253389457_init_data; - styleFactory.__stackDetails = _e; - return styleFactory; + styleFactory_null1.__closure = {}; + styleFactory_null1.__workletHash = 7165463824996; + styleFactory_null1.__initData = _worklet_7165463824996_init_data; + styleFactory_null1.__stackDetails = _e; + return styleFactory_null1; }(); animatedStyle = useAnimatedStyle(styleFactory);" `; @@ -1624,22 +1624,22 @@ 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_8893014081746_init_data = { - code: "function styleFactory(){return'FunctionDeclaration';}", +var _worklet_2619465543015_init_data = { + code: "function styleFactory_null1(){return'FunctionDeclaration';}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var styleFactory = function () { var _e = [new global.Error(), 1, -27]; - var styleFactory = function styleFactory() { + var styleFactory_null1 = function styleFactory_null1() { return 'FunctionDeclaration'; }; - styleFactory.__closure = {}; - styleFactory.__workletHash = 8893014081746; - styleFactory.__initData = _worklet_8893014081746_init_data; - styleFactory.__stackDetails = _e; - return styleFactory; + styleFactory_null1.__closure = {}; + styleFactory_null1.__workletHash = 2619465543015; + styleFactory_null1.__initData = _worklet_2619465543015_init_data; + styleFactory_null1.__stackDetails = _e; + return styleFactory_null1; }(); (function styleFactory() { return 'AssignmentExpression'; @@ -1649,43 +1649,43 @@ animatedStyle = useAnimatedStyle(styleFactory);" exports[`babel plugin for referenced worklets workletizes ArrowFunctionExpression on its AssignmentExpression 1`] = ` "var styleFactory; -var _worklet_155831007318_init_data = { - code: "function styleFactory(){return{};}", +var _worklet_17388574355683_init_data = { + code: "function styleFactory_null1(){return{};}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; styleFactory = function () { const _e = [new global.Error(), 1, -27]; - const styleFactory = function () { + const styleFactory_null1 = function () { return {}; }; - styleFactory.__closure = {}; - styleFactory.__workletHash = 155831007318; - styleFactory.__initData = _worklet_155831007318_init_data; - styleFactory.__stackDetails = _e; - return styleFactory; + styleFactory_null1.__closure = {}; + styleFactory_null1.__workletHash = 17388574355683; + styleFactory_null1.__initData = _worklet_17388574355683_init_data; + styleFactory_null1.__stackDetails = _e; + return styleFactory_null1; }(); animatedStyle = useAnimatedStyle(styleFactory);" `; exports[`babel plugin for referenced worklets workletizes ArrowFunctionExpression on its VariableDeclarator 1`] = ` -"var _worklet_155831007318_init_data = { - code: "function styleFactory(){return{};}", +"var _worklet_17388574355683_init_data = { + code: "function styleFactory_null1(){return{};}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var styleFactory = function () { const _e = [new global.Error(), 1, -27]; - const styleFactory = function () { + const styleFactory_null1 = function () { return {}; }; - styleFactory.__closure = {}; - styleFactory.__workletHash = 155831007318; - styleFactory.__initData = _worklet_155831007318_init_data; - styleFactory.__stackDetails = _e; - return styleFactory; + styleFactory_null1.__closure = {}; + styleFactory_null1.__workletHash = 17388574355683; + styleFactory_null1.__initData = _worklet_17388574355683_init_data; + styleFactory_null1.__stackDetails = _e; + return styleFactory_null1; }(); var animatedStyle = useAnimatedStyle(styleFactory);" `; @@ -1695,86 +1695,86 @@ exports[`babel plugin for referenced worklets workletizes ArrowFunctionExpressio styleFactory = function styleFactory() { return 1; }; -var _worklet_2302253389457_init_data = { - code: "function styleFactory(){return'AssignmentExpression';}", +var _worklet_7165463824996_init_data = { + code: "function styleFactory_null1(){return'AssignmentExpression';}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; styleFactory = function () { const _e = [new global.Error(), 1, -27]; - const styleFactory = function () { + const styleFactory_null1 = function () { return 'AssignmentExpression'; }; - styleFactory.__closure = {}; - styleFactory.__workletHash = 2302253389457; - styleFactory.__initData = _worklet_2302253389457_init_data; - styleFactory.__stackDetails = _e; - return styleFactory; + styleFactory_null1.__closure = {}; + styleFactory_null1.__workletHash = 7165463824996; + styleFactory_null1.__initData = _worklet_7165463824996_init_data; + styleFactory_null1.__stackDetails = _e; + return styleFactory_null1; }(); animatedStyle = useAnimatedStyle(styleFactory);" `; exports[`babel plugin for referenced worklets workletizes FunctionDeclaration 1`] = ` -"var _worklet_155831007318_init_data = { - code: "function styleFactory(){return{};}", +"var _worklet_17388574355683_init_data = { + code: "function styleFactory_null1(){return{};}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var styleFactory = function () { var _e = [new global.Error(), 1, -27]; - var styleFactory = function styleFactory() { + var styleFactory_null1 = function styleFactory_null1() { return {}; }; - styleFactory.__closure = {}; - styleFactory.__workletHash = 155831007318; - styleFactory.__initData = _worklet_155831007318_init_data; - styleFactory.__stackDetails = _e; - return styleFactory; + styleFactory_null1.__closure = {}; + styleFactory_null1.__workletHash = 17388574355683; + styleFactory_null1.__initData = _worklet_17388574355683_init_data; + styleFactory_null1.__stackDetails = _e; + return styleFactory_null1; }(); var animatedStyle = useAnimatedStyle(styleFactory);" `; exports[`babel plugin for referenced worklets workletizes FunctionExpression on its AssignmentExpression 1`] = ` "var styleFactory; -var _worklet_155831007318_init_data = { - code: "function styleFactory(){return{};}", +var _worklet_17388574355683_init_data = { + code: "function styleFactory_null1(){return{};}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; styleFactory = function () { const _e = [new global.Error(), 1, -27]; - const styleFactory = function () { + const styleFactory_null1 = function () { return {}; }; - styleFactory.__closure = {}; - styleFactory.__workletHash = 155831007318; - styleFactory.__initData = _worklet_155831007318_init_data; - styleFactory.__stackDetails = _e; - return styleFactory; + styleFactory_null1.__closure = {}; + styleFactory_null1.__workletHash = 17388574355683; + styleFactory_null1.__initData = _worklet_17388574355683_init_data; + styleFactory_null1.__stackDetails = _e; + return styleFactory_null1; }(); animatedStyle = useAnimatedStyle(styleFactory);" `; exports[`babel plugin for referenced worklets workletizes FunctionExpression on its VariableDeclarator 1`] = ` -"var _worklet_155831007318_init_data = { - code: "function styleFactory(){return{};}", +"var _worklet_17388574355683_init_data = { + code: "function styleFactory_null1(){return{};}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var styleFactory = function () { const _e = [new global.Error(), 1, -27]; - const styleFactory = function () { + const styleFactory_null1 = function () { return {}; }; - styleFactory.__closure = {}; - styleFactory.__workletHash = 155831007318; - styleFactory.__initData = _worklet_155831007318_init_data; - styleFactory.__stackDetails = _e; - return styleFactory; + styleFactory_null1.__closure = {}; + styleFactory_null1.__workletHash = 17388574355683; + styleFactory_null1.__initData = _worklet_17388574355683_init_data; + styleFactory_null1.__stackDetails = _e; + return styleFactory_null1; }(); var animatedStyle = useAnimatedStyle(styleFactory);" `; @@ -1784,30 +1784,30 @@ exports[`babel plugin for referenced worklets workletizes FunctionExpression onl styleFactory = function styleFactory() { return 1; }; -var _worklet_2302253389457_init_data = { - code: "function styleFactory(){return'AssignmentExpression';}", +var _worklet_7165463824996_init_data = { + code: "function styleFactory_null1(){return'AssignmentExpression';}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; styleFactory = function () { const _e = [new global.Error(), 1, -27]; - const styleFactory = function () { + const styleFactory_null1 = function () { return 'AssignmentExpression'; }; - styleFactory.__closure = {}; - styleFactory.__workletHash = 2302253389457; - styleFactory.__initData = _worklet_2302253389457_init_data; - styleFactory.__stackDetails = _e; - return styleFactory; + styleFactory_null1.__closure = {}; + styleFactory_null1.__workletHash = 7165463824996; + styleFactory_null1.__initData = _worklet_7165463824996_init_data; + styleFactory_null1.__stackDetails = _e; + return styleFactory_null1; }(); animatedStyle = useAnimatedStyle(styleFactory);" `; exports[`babel plugin for referenced worklets workletizes ObjectExpression on its AssignmentExpression 1`] = ` "var handler; -var _worklet_16988157363598_init_data = { - code: "function onScroll(){}", +var _worklet_10431207809979_init_data = { + code: "function onScroll_null1(){}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1815,20 +1815,20 @@ var _worklet_16988157363598_init_data = { handler = { onScroll: function () { const _e = [new global.Error(), 1, -27]; - const onScroll = function () {}; - onScroll.__closure = {}; - onScroll.__workletHash = 16988157363598; - onScroll.__initData = _worklet_16988157363598_init_data; - onScroll.__stackDetails = _e; - return onScroll; + const onScroll_null1 = function () {}; + onScroll_null1.__closure = {}; + onScroll_null1.__workletHash = 10431207809979; + onScroll_null1.__initData = _worklet_10431207809979_init_data; + onScroll_null1.__stackDetails = _e; + return onScroll_null1; }() }; var scrollHandler = useAnimatedScrollHandler(handler);" `; exports[`babel plugin for referenced worklets workletizes ObjectExpression on its VariableDeclarator 1`] = ` -"var _worklet_16988157363598_init_data = { - code: "function onScroll(){}", +"var _worklet_10431207809979_init_data = { + code: "function onScroll_null1(){}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1836,12 +1836,12 @@ exports[`babel plugin for referenced worklets workletizes ObjectExpression on it var handler = { onScroll: function () { const _e = [new global.Error(), 1, -27]; - const onScroll = function () {}; - onScroll.__closure = {}; - onScroll.__workletHash = 16988157363598; - onScroll.__initData = _worklet_16988157363598_init_data; - onScroll.__stackDetails = _e; - return onScroll; + const onScroll_null1 = function () {}; + onScroll_null1.__closure = {}; + onScroll_null1.__workletHash = 10431207809979; + onScroll_null1.__initData = _worklet_10431207809979_init_data; + onScroll_null1.__stackDetails = _e; + return onScroll_null1; }() }; var scrollHandler = useAnimatedScrollHandler(handler);" @@ -1854,8 +1854,8 @@ handler = { return 1; } }; -var _worklet_9384619123806_init_data = { - code: "function onScroll(){return'AssignmentExpression';}", +var _worklet_3006312818667_init_data = { + code: "function onScroll_null1(){return'AssignmentExpression';}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1863,14 +1863,14 @@ var _worklet_9384619123806_init_data = { handler = { onScroll: function () { const _e = [new global.Error(), 1, -27]; - const onScroll = function () { + const onScroll_null1 = function () { return 'AssignmentExpression'; }; - onScroll.__closure = {}; - onScroll.__workletHash = 9384619123806; - onScroll.__initData = _worklet_9384619123806_init_data; - onScroll.__stackDetails = _e; - return onScroll; + onScroll_null1.__closure = {}; + onScroll_null1.__workletHash = 3006312818667; + onScroll_null1.__initData = _worklet_3006312818667_init_data; + onScroll_null1.__stackDetails = _e; + return onScroll_null1; }() }; var scrollHandler = useAnimatedScrollHandler(handler);" @@ -1881,49 +1881,49 @@ exports[`babel plugin for referenced worklets workletizes assigments that appear return {}; }; animatedStyle = useAnimatedStyle(styleFactory); -var _worklet_12348123604788_init_data = { - code: "function anonymous(){return'AssignmentAfterUse';}", +var _worklet_506044013293_init_data = { + code: "function null1(){return'AssignmentAfterUse';}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; styleFactory = function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { return 'AssignmentAfterUse'; }; - anonymous.__closure = {}; - anonymous.__workletHash = 12348123604788; - anonymous.__initData = _worklet_12348123604788_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 506044013293; + null1.__initData = _worklet_506044013293_init_data; + null1.__stackDetails = _e; + return null1; }();" `; exports[`babel plugin for referenced worklets workletizes in immediate scope 1`] = ` -"var _worklet_155831007318_init_data = { - code: "function styleFactory(){return{};}", +"var _worklet_17388574355683_init_data = { + code: "function styleFactory_null1(){return{};}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var styleFactory = function () { const _e = [new global.Error(), 1, -27]; - const styleFactory = function () { + const styleFactory_null1 = function () { return {}; }; - styleFactory.__closure = {}; - styleFactory.__workletHash = 155831007318; - styleFactory.__initData = _worklet_155831007318_init_data; - styleFactory.__stackDetails = _e; - return styleFactory; + styleFactory_null1.__closure = {}; + styleFactory_null1.__workletHash = 17388574355683; + styleFactory_null1.__initData = _worklet_17388574355683_init_data; + styleFactory_null1.__stackDetails = _e; + return styleFactory_null1; }(); animatedStyle = useAnimatedStyle(styleFactory);" `; exports[`babel plugin for referenced worklets workletizes in nested scope 1`] = ` -"var _worklet_155831007318_init_data = { - code: "function styleFactory(){return{};}", +"var _worklet_17388574355683_init_data = { + code: "function styleFactory_null1(){return{};}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1931,14 +1931,14 @@ exports[`babel plugin for referenced worklets workletizes in nested scope 1`] = function outerScope() { var styleFactory = function () { const _e = [new global.Error(), 1, -27]; - const styleFactory = function () { + const styleFactory_null1 = function () { return {}; }; - styleFactory.__closure = {}; - styleFactory.__workletHash = 155831007318; - styleFactory.__initData = _worklet_155831007318_init_data; - styleFactory.__stackDetails = _e; - return styleFactory; + styleFactory_null1.__closure = {}; + styleFactory_null1.__workletHash = 17388574355683; + styleFactory_null1.__initData = _worklet_17388574355683_init_data; + styleFactory_null1.__stackDetails = _e; + return styleFactory_null1; }(); function innerScope() { animatedStyle = useAnimatedStyle(styleFactory); @@ -1955,8 +1955,8 @@ exports[`babel plugin for sequence expressions supports SequenceExpression 1`] = `; exports[`babel plugin for sequence expressions supports SequenceExpression, many arguments 1`] = ` -"var _worklet_4434179069699_init_data = { - code: "function onStart(){}", +"var _worklet_8764176270806_init_data = { + code: "function onStart_null1(){}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1965,20 +1965,20 @@ function App() { (0, 3, fun)({ onStart: function () { var _e = [new global.Error(), 1, -27]; - var onStart = function onStart() {}; - onStart.__closure = {}; - onStart.__workletHash = 4434179069699; - onStart.__initData = _worklet_4434179069699_init_data; - onStart.__stackDetails = _e; - return onStart; + var onStart_null1 = function onStart_null1() {}; + onStart_null1.__closure = {}; + onStart_null1.__workletHash = 8764176270806; + onStart_null1.__initData = _worklet_8764176270806_init_data; + onStart_null1.__stackDetails = _e; + return onStart_null1; }() }, []); }" `; exports[`babel plugin for sequence expressions supports SequenceExpression, with objectHook 1`] = ` -"var _worklet_4434179069699_init_data = { - code: "function onStart(){}", +"var _worklet_8764176270806_init_data = { + code: "function onStart_null1(){}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -1987,20 +1987,20 @@ function App() { (0, useAnimatedGestureHandler)({ onStart: function () { var _e = [new global.Error(), 1, -27]; - var onStart = function onStart() {}; - onStart.__closure = {}; - onStart.__workletHash = 4434179069699; - onStart.__initData = _worklet_4434179069699_init_data; - onStart.__stackDetails = _e; - return onStart; + var onStart_null1 = function onStart_null1() {}; + onStart_null1.__closure = {}; + onStart_null1.__workletHash = 8764176270806; + onStart_null1.__initData = _worklet_8764176270806_init_data; + onStart_null1.__stackDetails = _e; + return onStart_null1; }() }, []); }" `; exports[`babel plugin for sequence expressions supports SequenceExpression, with worklet 1`] = ` -"var _worklet_4434179069699_init_data = { - code: "function onStart(){}", +"var _worklet_8764176270806_init_data = { + code: "function onStart_null1(){}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -2009,20 +2009,20 @@ function App() { (0, fun)({ onStart: function () { var _e = [new global.Error(), 1, -27]; - var onStart = function onStart() {}; - onStart.__closure = {}; - onStart.__workletHash = 4434179069699; - onStart.__initData = _worklet_4434179069699_init_data; - onStart.__stackDetails = _e; - return onStart; + var onStart_null1 = function onStart_null1() {}; + onStart_null1.__closure = {}; + onStart_null1.__workletHash = 8764176270806; + onStart_null1.__initData = _worklet_8764176270806_init_data; + onStart_null1.__stackDetails = _e; + return onStart_null1; }() }, []); }" `; exports[`babel plugin for sequence expressions supports SequenceExpression, with worklet closure 1`] = ` -"var _worklet_5519800181618_init_data = { - code: "function onStart(){const{obj}=this.__closure;const a=obj.a;}", +"var _worklet_10926786553639_init_data = { + code: "function onStart_null1(){const{obj}=this.__closure;const a=obj.a;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -2035,42 +2035,42 @@ function App() { (0, fun)({ onStart: function () { var _e = [new global.Error(), -2, -27]; - var onStart = function onStart() { + var onStart_null1 = function onStart_null1() { var a = obj.a; }; - onStart.__closure = { + onStart_null1.__closure = { obj: obj }; - onStart.__workletHash = 5519800181618; - onStart.__initData = _worklet_5519800181618_init_data; - onStart.__stackDetails = _e; - return onStart; + onStart_null1.__workletHash = 10926786553639; + onStart_null1.__initData = _worklet_10926786553639_init_data; + onStart_null1.__stackDetails = _e; + return onStart_null1; }() }, []); }" `; exports[`babel plugin for web configuration doesn't substitute isWeb and shouldBeUseWeb in worklets 1`] = ` -"var _worklet_8641000714901_init_data = { - code: "function foo(){const{isWeb,shouldBeUseWeb}=this.__closure;const x=isWeb();const y=shouldBeUseWeb();}", +"var _worklet_8645270621312_init_data = { + code: "function foo_null1(){const{isWeb,shouldBeUseWeb}=this.__closure;const x=isWeb();const y=shouldBeUseWeb();}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), -3, -27]; - var foo = function foo() { + var foo_null1 = function foo_null1() { var x = true; var y = true; }; - foo.__closure = { + foo_null1.__closure = { isWeb: isWeb, shouldBeUseWeb: shouldBeUseWeb }; - foo.__workletHash = 8641000714901; - foo.__initData = _worklet_8641000714901_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__workletHash = 8645270621312; + foo_null1.__initData = _worklet_8645270621312_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; @@ -2085,35 +2085,35 @@ var y = shouldBeUseWeb();" `; exports[`babel plugin for web configuration includes initData when omitNativeOnlyData option is set to false 1`] = ` -"var _worklet_17472070642672_init_data = { - code: "function foo(){var foo='bar';}", +"var _worklet_8266917884050_init_data = { + code: "function foo_null1(){var bar='bar';}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function foo() { - var foo = 'bar'; - }; - foo.__closure = {}; - foo.__workletHash = 17472070642672; - foo.__initData = _worklet_17472070642672_init_data; - foo.__stackDetails = _e; - return foo; + var foo_null1 = function foo_null1() { + var bar = 'bar'; + }; + foo_null1.__closure = {}; + foo_null1.__workletHash = 8266917884050; + foo_null1.__initData = _worklet_8266917884050_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; exports[`babel plugin for web configuration skips initData when omitNativeOnlyData option is set to true 1`] = ` "var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function foo() { + var foo_null1 = function foo_null1() { var foo = 'bar'; }; - foo.__closure = {}; - foo.__workletHash = 17472070642672; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 7087145691632; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; @@ -2123,340 +2123,340 @@ var y = true;" `; exports[`babel plugin for worklet nesting doesn't process nested worklets when disabled 1`] = ` -"var _worklet_1678749606628_init_data = { - code: "function foo(x){function bar(x){'worklet';return x+2;}return bar(x)+1;}", +"var _worklet_16658893781105_init_data = { + code: "function foo_null1(x){function bar(x){'worklet';return x+2;}return bar(x)+1;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_16974800582491_init_data = { - code: "function bar(x){return x+2;}", +var _worklet_17260955035117_init_data = { + code: "function bar_null2(x){return x+2;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), 1, -27]; - var foo = function foo(x) { + var foo_null1 = function foo_null1(x) { var bar = function () { var _e = [new global.Error(), 1, -27]; - var bar = function bar(x) { + var bar_null2 = function bar_null2(x) { return x + 2; }; - bar.__closure = {}; - bar.__workletHash = 16974800582491; - bar.__initData = _worklet_16974800582491_init_data; - bar.__stackDetails = _e; - return bar; + bar_null2.__closure = {}; + bar_null2.__workletHash = 17260955035117; + bar_null2.__initData = _worklet_17260955035117_init_data; + bar_null2.__stackDetails = _e; + return bar_null2; }(); return bar(x) + 1; }; - foo.__closure = {}; - foo.__workletHash = 1678749606628; - foo.__initData = _worklet_1678749606628_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__closure = {}; + foo_null1.__workletHash = 16658893781105; + foo_null1.__initData = _worklet_16658893781105_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; exports[`babel plugin for worklet nesting transpiles nested worklets embedded in runOnJS in runOnUI 1`] = ` -"var _worklet_13427774179957_init_data = { - code: "function anonymous(){console.log('Hello from JS thread');}", +"var _worklet_5655279400236_init_data = { + code: "function null1(){console.log('Hello from JS thread');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_12029053563916_init_data = { - code: "function anonymous(){const{runOnJS,_worklet_13427774179957_init_data}=this.__closure;console.log('Hello from UI thread');runOnJS(function(){const _e=[new global.Error(),1,-27];const anonymous=function(){console.log('Hello from JS thread');};anonymous.__closure={};anonymous.__workletHash=13427774179957;anonymous.__initData=_worklet_13427774179957_init_data;anonymous.__stackDetails=_e;return anonymous;}())();}", +var _worklet_8060856534633_init_data = { + code: "function null2(){const{runOnJS,_worklet_5655279400236_init_data}=this.__closure;console.log('Hello from UI thread');runOnJS(function(){const _e=[new global.Error(),1,-27];const null1=function(){console.log('Hello from JS thread');};null1.__closure={};null1.__workletHash=5655279400236;null1.__initData=_worklet_5655279400236_init_data;null1.__stackDetails=_e;return null1;}())();}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; runOnUI(function () { var _e = [new global.Error(), -3, -27]; - var anonymous = function anonymous() { + var null2 = function null2() { console.log('Hello from UI thread'); runOnJS(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('Hello from JS thread'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 13427774179957; - anonymous.__initData = _worklet_13427774179957_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 5655279400236; + null1.__initData = _worklet_5655279400236_init_data; + null1.__stackDetails = _e; + return null1; }())(); }; - anonymous.__closure = { + null2.__closure = { runOnJS: runOnJS, - _worklet_13427774179957_init_data: _worklet_13427774179957_init_data + _worklet_5655279400236_init_data: _worklet_5655279400236_init_data }; - anonymous.__workletHash = 12029053563916; - anonymous.__initData = _worklet_12029053563916_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null2.__workletHash = 8060856534633; + null2.__initData = _worklet_8060856534633_init_data; + null2.__stackDetails = _e; + return null2; }())();" `; exports[`babel plugin for worklet nesting transpiles nested worklets embedded in runOnUI in runOnJS in runOnUI 1`] = ` -"var _worklet_15780567630262_init_data = { - code: "function anonymous(){const{runOnUI}=this.__closure;console.log('Hello from JS thread');runOnUI(function(){console.log('Hello from UI thread again');})();}", +"var _worklet_7185083753711_init_data = { + code: "function null1(){const{runOnUI}=this.__closure;console.log('Hello from JS thread');runOnUI(function(){console.log('Hello from UI thread again');})();}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_10673554115844_init_data = { - code: "function anonymous(){const{runOnJS,runOnUI,_worklet_15780567630262_init_data}=this.__closure;console.log('Hello from UI thread');runOnJS(function(){const _e=[new global.Error(),-2,-27];const anonymous=function(){console.log('Hello from JS thread');runOnUI(function(){console.log('Hello from UI thread again');})();};anonymous.__closure={runOnUI:runOnUI};anonymous.__workletHash=15780567630262;anonymous.__initData=_worklet_15780567630262_init_data;anonymous.__stackDetails=_e;return anonymous;}())();}", +var _worklet_3809176378244_init_data = { + code: "function null2(){const{runOnJS,runOnUI,_worklet_7185083753711_init_data}=this.__closure;console.log('Hello from UI thread');runOnJS(function(){const _e=[new global.Error(),-2,-27];const null1=function(){console.log('Hello from JS thread');runOnUI(function(){console.log('Hello from UI thread again');})();};null1.__closure={runOnUI:runOnUI};null1.__workletHash=7185083753711;null1.__initData=_worklet_7185083753711_init_data;null1.__stackDetails=_e;return null1;}())();}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_12364489264272_init_data = { - code: "function anonymous(){console.log('Hello from UI thread again');}", +var _worklet_2520605269387_init_data = { + code: "function null3(){console.log('Hello from UI thread again');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; runOnUI(function () { var _e = [new global.Error(), -4, -27]; - var anonymous = function anonymous() { + var null2 = function null2() { console.log('Hello from UI thread'); runOnJS(function () { var _e = [new global.Error(), -2, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('Hello from JS thread'); runOnUI(function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null3 = function null3() { console.log('Hello from UI thread again'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 12364489264272; - anonymous.__initData = _worklet_12364489264272_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null3.__closure = {}; + null3.__workletHash = 2520605269387; + null3.__initData = _worklet_2520605269387_init_data; + null3.__stackDetails = _e; + return null3; }())(); }; - anonymous.__closure = { + null1.__closure = { runOnUI: runOnUI }; - anonymous.__workletHash = 15780567630262; - anonymous.__initData = _worklet_15780567630262_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__workletHash = 7185083753711; + null1.__initData = _worklet_7185083753711_init_data; + null1.__stackDetails = _e; + return null1; }())(); }; - anonymous.__closure = { + null2.__closure = { runOnJS: runOnJS, runOnUI: runOnUI, - _worklet_15780567630262_init_data: _worklet_15780567630262_init_data + _worklet_7185083753711_init_data: _worklet_7185083753711_init_data }; - anonymous.__workletHash = 10673554115844; - anonymous.__initData = _worklet_10673554115844_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null2.__workletHash = 3809176378244; + null2.__initData = _worklet_3809176378244_init_data; + null2.__stackDetails = _e; + return null2; }())();" `; exports[`babel plugin for worklet nesting transpiles nested worklets when enabled 1`] = ` -"var _worklet_14052814262791_init_data = { - code: "function anonymous(){console.log('bar');}", +"var _worklet_8064116599518_init_data = { + code: "function null1(){console.log('bar');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_6747298666324_init_data = { - code: "function anonymous(){const{_worklet_14052814262791_init_data}=this.__closure;const bar=function(){const _e=[new global.Error(),1,-27];const anonymous=function(){console.log('bar');};anonymous.__closure={};anonymous.__workletHash=14052814262791;anonymous.__initData=_worklet_14052814262791_init_data;anonymous.__stackDetails=_e;return anonymous;}();bar();}", +var _worklet_1516424759965_init_data = { + code: "function null2(){const{_worklet_8064116599518_init_data}=this.__closure;const bar=function(){const _e=[new global.Error(),1,-27];const null1=function(){console.log('bar');};null1.__closure={};null1.__workletHash=8064116599518;null1.__initData=_worklet_8064116599518_init_data;null1.__stackDetails=_e;return null1;}();bar();}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), -2, -27]; - var anonymous = function anonymous() { + var null2 = function null2() { var bar = function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('bar'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 14052814262791; - anonymous.__initData = _worklet_14052814262791_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 8064116599518; + null1.__initData = _worklet_8064116599518_init_data; + null1.__stackDetails = _e; + return null1; }(); bar(); }; - anonymous.__closure = { - _worklet_14052814262791_init_data: _worklet_14052814262791_init_data + null2.__closure = { + _worklet_8064116599518_init_data: _worklet_8064116599518_init_data }; - anonymous.__workletHash = 6747298666324; - anonymous.__initData = _worklet_6747298666324_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null2.__workletHash = 1516424759965; + null2.__initData = _worklet_1516424759965_init_data; + null2.__stackDetails = _e; + return null2; }();" `; exports[`babel plugin for worklet nesting transpiles nested worklets when enabled with depth 3 1`] = ` -"var _worklet_744555119489_init_data = { - code: "function anonymous(){console.log('foobar');}", +"var _worklet_3230974749144_init_data = { + code: "function null1(){console.log('foobar');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_2165106463703_init_data = { - code: "function anonymous(){const{_worklet_744555119489_init_data}=this.__closure;const foobar=function(){const _e=[new global.Error(),1,-27];const anonymous=function(){console.log('foobar');};anonymous.__closure={};anonymous.__workletHash=744555119489;anonymous.__initData=_worklet_744555119489_init_data;anonymous.__stackDetails=_e;return anonymous;}();}", +var _worklet_6327850153424_init_data = { + code: "function null2(){const{_worklet_3230974749144_init_data}=this.__closure;const foobar=function(){const _e=[new global.Error(),1,-27];const null1=function(){console.log('foobar');};null1.__closure={};null1.__workletHash=3230974749144;null1.__initData=_worklet_3230974749144_init_data;null1.__stackDetails=_e;return null1;}();}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_15490975732628_init_data = { - code: "function anonymous(){const{_worklet_744555119489_init_data,_worklet_2165106463703_init_data}=this.__closure;const bar=function(){const _e=[new global.Error(),-2,-27];const anonymous=function(){const foobar=function(){const _e=[new global.Error(),1,-27];const anonymous=function(){console.log('foobar');};anonymous.__closure={};anonymous.__workletHash=744555119489;anonymous.__initData=_worklet_744555119489_init_data;anonymous.__stackDetails=_e;return anonymous;}();};anonymous.__closure={_worklet_744555119489_init_data:_worklet_744555119489_init_data};anonymous.__workletHash=2165106463703;anonymous.__initData=_worklet_2165106463703_init_data;anonymous.__stackDetails=_e;return anonymous;}();bar();}", +var _worklet_2612038668792_init_data = { + code: "function null3(){const{_worklet_3230974749144_init_data,_worklet_6327850153424_init_data}=this.__closure;const bar=function(){const _e=[new global.Error(),-2,-27];const null2=function(){const foobar=function(){const _e=[new global.Error(),1,-27];const null1=function(){console.log('foobar');};null1.__closure={};null1.__workletHash=3230974749144;null1.__initData=_worklet_3230974749144_init_data;null1.__stackDetails=_e;return null1;}();};null2.__closure={_worklet_3230974749144_init_data:_worklet_3230974749144_init_data};null2.__workletHash=6327850153424;null2.__initData=_worklet_6327850153424_init_data;null2.__stackDetails=_e;return null2;}();bar();}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), -3, -27]; - var anonymous = function anonymous() { + var null3 = function null3() { var bar = function () { var _e = [new global.Error(), -2, -27]; - var anonymous = function anonymous() { + var null2 = function null2() { var foobar = function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('foobar'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 744555119489; - anonymous.__initData = _worklet_744555119489_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 3230974749144; + null1.__initData = _worklet_3230974749144_init_data; + null1.__stackDetails = _e; + return null1; }(); }; - anonymous.__closure = { - _worklet_744555119489_init_data: _worklet_744555119489_init_data + null2.__closure = { + _worklet_3230974749144_init_data: _worklet_3230974749144_init_data }; - anonymous.__workletHash = 2165106463703; - anonymous.__initData = _worklet_2165106463703_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null2.__workletHash = 6327850153424; + null2.__initData = _worklet_6327850153424_init_data; + null2.__stackDetails = _e; + return null2; }(); bar(); }; - anonymous.__closure = { - _worklet_744555119489_init_data: _worklet_744555119489_init_data, - _worklet_2165106463703_init_data: _worklet_2165106463703_init_data + null3.__closure = { + _worklet_3230974749144_init_data: _worklet_3230974749144_init_data, + _worklet_6327850153424_init_data: _worklet_6327850153424_init_data }; - anonymous.__workletHash = 15490975732628; - anonymous.__initData = _worklet_15490975732628_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null3.__workletHash = 2612038668792; + null3.__initData = _worklet_2612038668792_init_data; + null3.__stackDetails = _e; + return null3; }();" `; exports[`babel plugin for worklet nesting transpiles worklets with functions defined on UI thread to run them on JS 1`] = ` -"var _worklet_2310082662475_init_data = { - code: "function anonymous(){console.log('Good morning from JS thread!');}", +"var _worklet_12864992966034_init_data = { + code: "function null1(){console.log('Good morning from JS thread!');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_9108102051728_init_data = { - code: "function anonymous(){console.log('Good afternoon from JS thread');}", +var _worklet_4437925222314_init_data = { + code: "function null2(){console.log('Good afternoon from JS thread');}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; -var _worklet_7385395288732_init_data = { - code: "function anonymous(){const{_worklet_2310082662475_init_data,_worklet_9108102051728_init_data,runOnJS}=this.__closure;const a=function(){const _e=[new global.Error(),1,-27];const anonymous=function(){console.log('Good morning from JS thread!');};anonymous.__closure={};anonymous.__workletHash=2310082662475;anonymous.__initData=_worklet_2310082662475_init_data;anonymous.__stackDetails=_e;return anonymous;}();const b=function(){const _e=[new global.Error(),1,-27];const anonymous=function(){console.log('Good afternoon from JS thread');};anonymous.__closure={};anonymous.__workletHash=9108102051728;anonymous.__initData=_worklet_9108102051728_init_data;anonymous.__stackDetails=_e;return anonymous;}();const func=Math.random()<0.5?a:b;runOnJS(func)();}", +var _worklet_10266484047832_init_data = { + code: "function null3(){const{_worklet_12864992966034_init_data,_worklet_4437925222314_init_data,runOnJS}=this.__closure;const a=function(){const _e=[new global.Error(),1,-27];const null1=function(){console.log('Good morning from JS thread!');};null1.__closure={};null1.__workletHash=12864992966034;null1.__initData=_worklet_12864992966034_init_data;null1.__stackDetails=_e;return null1;}();const b=function(){const _e=[new global.Error(),1,-27];const null2=function(){console.log('Good afternoon from JS thread');};null2.__closure={};null2.__workletHash=4437925222314;null2.__initData=_worklet_4437925222314_init_data;null2.__stackDetails=_e;return null2;}();const func=Math.random()<0.5?a:b;runOnJS(func)();}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; runOnUI(function () { var _e = [new global.Error(), -4, -27]; - var anonymous = function anonymous() { + var null3 = function null3() { var a = function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { console.log('Good morning from JS thread!'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 2310082662475; - anonymous.__initData = _worklet_2310082662475_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 12864992966034; + null1.__initData = _worklet_12864992966034_init_data; + null1.__stackDetails = _e; + return null1; }(); var b = function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null2 = function null2() { console.log('Good afternoon from JS thread'); }; - anonymous.__closure = {}; - anonymous.__workletHash = 9108102051728; - anonymous.__initData = _worklet_9108102051728_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null2.__closure = {}; + null2.__workletHash = 4437925222314; + null2.__initData = _worklet_4437925222314_init_data; + null2.__stackDetails = _e; + return null2; }(); var func = Math.random() < 0.5 ? a : b; runOnJS(func)(); }; - anonymous.__closure = { - _worklet_2310082662475_init_data: _worklet_2310082662475_init_data, - _worklet_9108102051728_init_data: _worklet_9108102051728_init_data, + null3.__closure = { + _worklet_12864992966034_init_data: _worklet_12864992966034_init_data, + _worklet_4437925222314_init_data: _worklet_4437925222314_init_data, runOnJS: runOnJS }; - anonymous.__workletHash = 7385395288732; - anonymous.__initData = _worklet_7385395288732_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null3.__workletHash = 10266484047832; + null3.__initData = _worklet_10266484047832_init_data; + null3.__stackDetails = _e; + return null3; }())();" `; exports[`babel plugin generally removes comments from worklets 1`] = ` -"var _worklet_235615426006_init_data = { - code: "function anonymous(){return true;}", +"var _worklet_5099191671055_init_data = { + code: "function null1(){return true;}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var f = function () { var _e = [new global.Error(), 1, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { return true; }; - anonymous.__closure = {}; - anonymous.__workletHash = 235615426006; - anonymous.__initData = _worklet_235615426006_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__closure = {}; + null1.__workletHash = 5099191671055; + null1.__initData = _worklet_5099191671055_init_data; + null1.__stackDetails = _e; + return null1; }();" `; exports[`babel plugin generally supports recursive calls 1`] = ` "var a = 1; -var _worklet_210900050506_init_data = { - code: "function foo(t){const foo=this._recur;const{a}=this.__closure;if(t>0){return a+foo(t-1);}}", +var _worklet_12624627966719_init_data = { + code: "function foo_null1(t){const foo_null1=this._recur;const{a}=this.__closure;if(t>0){return a+foo_null1(t-1);}}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" }; var foo = function () { var _e = [new global.Error(), -2, -27]; - var foo = function foo(t) { + var foo_null1 = function foo_null1(t) { if (t > 0) { return a + foo(t - 1); } }; - foo.__closure = { + foo_null1.__closure = { a: a }; - foo.__workletHash = 210900050506; - foo.__initData = _worklet_210900050506_init_data; - foo.__stackDetails = _e; - return foo; + foo_null1.__workletHash = 12624627966719; + foo_null1.__initData = _worklet_12624627966719_init_data; + foo_null1.__stackDetails = _e; + return foo_null1; }();" `; @@ -2465,8 +2465,8 @@ exports[`babel plugin generally transforms 1`] = ` var _jsxRuntime = require("react/jsx-runtime"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } -var _worklet_13769858944821_init_data = { - code: "function anonymous(){const{offset}=this.__closure;return{transform:[{translateX:offset.value*255}]};}", +var _worklet_6576407799916_init_data = { + code: "function null1(){const{offset}=this.__closure;return{transform:[{translateX:offset.value*255}]};}", location: "/dev/null", sourceMap: "\\"mock source map\\"", version: "x.y.z" @@ -2475,20 +2475,20 @@ function Box() { var offset = (0, _reactNativeReanimated.useSharedValue)(0); var animatedStyles = (0, _reactNativeReanimated.useAnimatedStyle)(function () { var _e = [new global.Error(), -2, -27]; - var anonymous = function anonymous() { + var null1 = function null1() { return { transform: [{ translateX: offset.value * 255 }] }; }; - anonymous.__closure = { + null1.__closure = { offset: offset }; - anonymous.__workletHash = 13769858944821; - anonymous.__initData = _worklet_13769858944821_init_data; - anonymous.__stackDetails = _e; - return anonymous; + null1.__workletHash = 6576407799916; + null1.__initData = _worklet_6576407799916_init_data; + null1.__stackDetails = _e; + return null1; }()); return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, { children: [(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, { @@ -2502,3 +2502,100 @@ function Box() { }); }" `; + +exports[`babel plugin names appends file name to function name 1`] = ` +"var _worklet_3008648901742_init_data = { + code: "function foo_sourceJs1(){return 1;}", + location: "/source.js", + version: "x.y.z" +}; +var foo = function () { + var _e = [new global.Error(), 1, -27]; + var foo_sourceJs1 = function foo_sourceJs1() { + return 1; + }; + foo_sourceJs1.__closure = {}; + foo_sourceJs1.__workletHash = 3008648901742; + foo_sourceJs1.__initData = _worklet_3008648901742_init_data; + foo_sourceJs1.__stackDetails = _e; + return foo_sourceJs1; +}();" +`; + +exports[`babel plugin names appends library name to function name 1`] = ` +"var _worklet_1237424241422_init_data = { + code: "function foo_library_sourceJs1(){return 1;}", + location: "/node_modules/library/source.js", + version: "x.y.z" +}; +var foo = function () { + var _e = [new global.Error(), 1, -27]; + var foo_library_sourceJs1 = function foo_library_sourceJs1() { + return 1; + }; + foo_library_sourceJs1.__closure = {}; + foo_library_sourceJs1.__workletHash = 1237424241422; + foo_library_sourceJs1.__initData = _worklet_1237424241422_init_data; + foo_library_sourceJs1.__stackDetails = _e; + return foo_library_sourceJs1; +}();" +`; + +exports[`babel plugin names handles names with illegal characters 1`] = ` +"var _worklet_16115589986830_init_data = { + code: "function foo_SourceJs1(){return 1;}", + location: "/-source.js", + version: "x.y.z" +}; +var foo = function () { + var _e = [new global.Error(), 1, -27]; + var foo_SourceJs1 = function foo_SourceJs1() { + return 1; + }; + foo_SourceJs1.__closure = {}; + foo_SourceJs1.__workletHash = 16115589986830; + foo_SourceJs1.__initData = _worklet_16115589986830_init_data; + foo_SourceJs1.__stackDetails = _e; + return foo_SourceJs1; +}();" +`; + +exports[`babel plugin names unnamed ArrowFunctionExpression 1`] = ` +"var _worklet_1420107288296_init_data = { + code: "function null1(){return 1;}", + location: "/dev/null", + sourceMap: "\\"mock source map\\"", + version: "x.y.z" +}; +(function () { + var _e = [new global.Error(), 1, -27]; + var null1 = function null1() { + return 1; + }; + null1.__closure = {}; + null1.__workletHash = 1420107288296; + null1.__initData = _worklet_1420107288296_init_data; + null1.__stackDetails = _e; + return null1; +})();" +`; + +exports[`babel plugin names unnamed FunctionExpression 1`] = ` +"var _worklet_1420107288296_init_data = { + code: "function null1(){return 1;}", + location: "/dev/null", + sourceMap: "\\"mock source map\\"", + version: "x.y.z" +}; +[function () { + var _e = [new global.Error(), 1, -27]; + var null1 = function null1() { + return 1; + }; + null1.__closure = {}; + null1.__workletHash = 1420107288296; + null1.__initData = _worklet_1420107288296_init_data; + null1.__stackDetails = _e; + return null1; +}()]();" +`; diff --git a/packages/react-native-reanimated/__tests__/plugin.test.ts b/packages/react-native-reanimated/__tests__/plugin.test.ts index 938c9540559..3b176f1c992 100644 --- a/packages/react-native-reanimated/__tests__/plugin.test.ts +++ b/packages/react-native-reanimated/__tests__/plugin.test.ts @@ -13,13 +13,14 @@ const MOCK_LOCATION = '/dev/null'; function runPlugin( input: string, transformOpts: TransformOptions = {}, - pluginOpts: ReanimatedPluginOptions = {} + pluginOpts: ReanimatedPluginOptions = {}, + filename: string = MOCK_LOCATION ) { const transformed = transformSync(input.replace(/<\/?script[^>]*>/g, ''), { // Our babel presets require us to specify a filename here // but it is never used so we put in '/dev/null' // as a safe fallback. - filename: MOCK_LOCATION, + filename, compact: false, plugins: [[plugin, pluginOpts]], babelrc: false, @@ -93,10 +94,11 @@ describe('babel plugin', () => { `; const { code } = runPlugin(input); - expect(code).toContain('sourceMap: "{'); + // Expect a string that contains (including the backslash): sourceMap: \"{ + expect(code).toMatch(/sourceMap: /gm); // this non-mocked source map is hard-coded, feel free to update it accordingly expect(code).toContain( - '\\"mappings\\":\\"AACQ,SAAAA,GAASA,CAAA,CAAG,CAEV,GAAI,CAAAA,GAAG,CAAG,KAAK,CACjB\\"' + 'AACQ,SAAAA,SAAeA,CAAA,EAEb,GAAI,CAAAA,SAAM,CAAK,MACjB' ); }); @@ -147,7 +149,109 @@ describe('babel plugin', () => { `; const { code } = runPlugin(input); - expect(code).toContain('const foo=this._recur'); + expect(code).toMatch(/const foo_null[0-9]+=this._recur;/gm); + expect(code).toMatchSnapshot(); + }); + }); + + describe('names', () => { + it('unnamed ArrowFunctionExpression', () => { + const input = html``; + + const { code } = runPlugin(input); + expect(code).toMatch(/function null[0-9]+\(\)/gm); + expect(code).toMatchSnapshot(); + }); + + it('unnamed FunctionExpression', () => { + const input = html``; + + const { code } = runPlugin(input); + expect(code).toMatch(/function null[0-9]+\(\)/gm); + expect(code).toMatchSnapshot(); + }); + + it('names ObjectMethod with expression key', () => { + const input = html``; + + // TODO: this is an edge case that wasn't ever handled. + expect(() => runPlugin(input)).toThrow(); + // const { code } = runPlugin(input); + // expect(code).toMatch(/function foo_null[0-9]+\(\)/gm); + // expect(code).toMatchSnapshot(); + }); + + it('appends file name to function name', () => { + const input = html``; + + const { code } = runPlugin( + input, + {}, + { disableSourceMaps: true }, + '/source.js' + ); + expect(code).toMatch(/function foo_sourceJs[0-9]+\(\)/gm); + expect(code).toMatchSnapshot(); + }); + + it('appends library name to function name', () => { + const input = html``; + + const { code } = runPlugin( + input, + {}, + { disableSourceMaps: true }, + '/node_modules/library/source.js' + ); + expect(code).toMatch(/function foo_library_sourceJs[0-9]+\(\)/gm); + expect(code).toMatchSnapshot(); + }); + + it('handles names with illegal characters', () => { + const input = html``; + + const { code } = runPlugin( + input, + {}, + { + disableSourceMaps: true, + }, + '/-source.js' + ); + expect(code).toMatch(/function foo_SourceJs[0-9]+\(\)/gm); expect(code).toMatchSnapshot(); }); }); @@ -276,7 +380,7 @@ describe('babel plugin', () => { `; const { code } = runPlugin(input, undefined, { globals: ['foo'] }); - expect(code).toContain('f.__closure = {};'); + expect(code).toMatch(/f_null[0-9]+\.__closure = \{\}/gm); expect(code).toMatchSnapshot(); }); @@ -289,7 +393,7 @@ describe('babel plugin', () => { `; const { code } = runPlugin(input); - expect(code).toContain('f.__closure = {};'); + expect(code).toMatch(/f_null[0-9]+\.__closure = \{\}/gm); expect(code).toMatchSnapshot(); }); @@ -1064,11 +1168,10 @@ describe('babel plugin', () => { const { code } = runPlugin(input); expect(code).not.toHaveInlineStyleWarning(); expect(code).toMatchSnapshot(); - // }); }); }); - describe('is indempotent', () => { + describe('is idempotent', () => { it('for common cases', () => { function resultIsIdempotent(input: string) { const firstResult = runPlugin(input).code; @@ -1614,7 +1717,7 @@ describe('babel plugin', () => { const input = html``; @@ -1698,7 +1801,10 @@ describe('babel plugin', () => { `; const { code } = runPlugin(input); - expect(code).toContain('var foo = function* foo() {'); + expect(code).toMatch( + /var foo_null[0-9]+ = function\* foo_null[0-9]+\(\) {/gm + ); + expect(code).toMatchSnapshot(); }); @@ -1712,8 +1818,8 @@ describe('babel plugin', () => { `; const { code } = runPlugin(input); - expect(code).toContain( - `code: "function*foo(){yield'hello';yield'world';}"` + expect(code).toMatch( + /code: "function\*foo_null[0-9]+\(\){yield'hello';yield'world';}"/gm ); expect(code).toMatchSnapshot(); }); @@ -1742,8 +1848,8 @@ describe('babel plugin', () => { `; const { code } = runPlugin(input); - expect(code).toContain( - `code: "async function foo(){await Promise.resolve();}"` + expect(code).toMatch( + /code: "async function foo_null[0-9]+\(\){await Promise.resolve\(\);}"/gm ); expect(code).toMatchSnapshot(); }); diff --git a/packages/react-native-reanimated/plugin/build/plugin.js b/packages/react-native-reanimated/plugin/build/plugin.js index 6ffae2f7ab2..c3b41e18533 100644 --- a/packages/react-native-reanimated/plugin/build/plugin.js +++ b/packages/react-native-reanimated/plugin/build/plugin.js @@ -233,16 +233,17 @@ var require_workletStringCode = __commonJS({ var fs = __importStar(require("fs")); var utils_12 = require_utils(); var MOCK_SOURCE_MAP = "mock source map"; - function buildWorkletString(fun, closureVariables, name, inputMap) { + function buildWorkletString(fun, state, closureVariables, nameWithSource, inputMap) { + restoreRecursiveCalls(fun, nameWithSource); const draftExpression = fun.program.body.find((obj) => (0, types_12.isFunctionDeclaration)(obj)) || fun.program.body.find((obj) => (0, types_12.isExpressionStatement)(obj)) || void 0; (0, assert_1.strict)(draftExpression, "[Reanimated] `draftExpression` is undefined."); const expression = (0, types_12.isFunctionDeclaration)(draftExpression) ? draftExpression : draftExpression.expression; (0, assert_1.strict)("params" in expression, "'params' property is undefined in 'expression'"); (0, assert_1.strict)((0, types_12.isBlockStatement)(expression.body), "[Reanimated] `expression.body` is not a `BlockStatement`"); - const workletFunction = (0, types_12.functionExpression)((0, types_12.identifier)(name), expression.params, expression.body, expression.generator, expression.async); + const workletFunction = (0, types_12.functionExpression)((0, types_12.identifier)(nameWithSource), expression.params, expression.body, expression.generator, expression.async); const code = (0, generator_1.default)(workletFunction).code; (0, assert_1.strict)(inputMap, "[Reanimated] `inputMap` is undefined."); - const includeSourceMap = !(0, utils_12.isRelease)(); + const includeSourceMap = !((0, utils_12.isRelease)() || state.opts.disableSourceMaps); if (includeSourceMap) { inputMap.sourcesContent = []; for (const sourceFile of inputMap.sources) { @@ -272,6 +273,19 @@ var require_workletStringCode = __commonJS({ return [transformed.code, JSON.stringify(sourceMap)]; } exports2.buildWorkletString = buildWorkletString; + function restoreRecursiveCalls(file, newName) { + (0, core_1.traverse)(file, { + FunctionExpression(path) { + if (!path.node.id) { + path.stop(); + return; + } + const oldName = path.node.id.name; + const scope = path.scope; + scope.rename(oldName, newName); + } + }); + } function shouldMockSourceMap() { return process.env.REANIMATED_JEST_SHOULD_MOCK_SOURCE_MAP === "1"; } @@ -362,11 +376,11 @@ var require_workletFactory = __commonJS({ (0, assert_1.strict)(transformed, "[Reanimated] `transformed` is undefined."); (0, assert_1.strict)(transformed.ast, "[Reanimated] `transformed.ast` is undefined."); const variables = makeArrayFromCapturedBindings(transformed.ast, fun); - const functionName = makeWorkletName(fun); + const functionName = makeWorkletName(fun, state); const functionIdentifier = (0, types_12.identifier)(functionName); const clone = (0, types_12.cloneNode)(fun.node); const funExpression = (0, types_12.isBlockStatement)(clone.body) ? (0, types_12.functionExpression)(null, clone.params, clone.body, clone.generator, clone.async) : clone; - let [funString, sourceMapString] = (0, workletStringCode_1.buildWorkletString)(transformed.ast, variables, functionName, transformed.map); + let [funString, sourceMapString] = (0, workletStringCode_1.buildWorkletString)(transformed.ast, state, variables, functionName, transformed.map); (0, assert_1.strict)(funString, "[Reanimated] `funString` is undefined."); const workletHash = hash(funString); let lineOffset = 1; @@ -455,17 +469,29 @@ var require_workletFactory = __commonJS({ } return (hash1 >>> 0) * 4096 + (hash2 >>> 0); } - function makeWorkletName(fun) { + function makeWorkletName(fun, state) { + let source = "unknownFile"; + if (state.file.opts.filename) { + const filepath = state.file.opts.filename; + source = (0, path_1.basename)(filepath); + const splitFilepath = filepath.split("/"); + const nodeModulesIndex = splitFilepath.indexOf("node_modules"); + if (nodeModulesIndex !== -1) { + const libraryName = splitFilepath[nodeModulesIndex + 1]; + source = `${libraryName}_${source}`; + } + } + const suffix = `${source}${state.workletNumber++}`; if ((0, types_12.isObjectMethod)(fun.node) && (0, types_12.isIdentifier)(fun.node.key)) { - return fun.node.key.name; + return (0, types_12.toIdentifier)(`${fun.node.key.name}_${suffix}`); } if ((0, types_12.isFunctionDeclaration)(fun.node) && (0, types_12.isIdentifier)(fun.node.id)) { - return fun.node.id.name; + return (0, types_12.toIdentifier)(`${fun.node.id.name}_${suffix}`); } if ((0, types_12.isFunctionExpression)(fun.node) && (0, types_12.isIdentifier)(fun.node.id)) { - return fun.node.id.name; + return (0, types_12.toIdentifier)(`${fun.node.id.name}_${suffix}`); } - return "anonymous"; + return (0, types_12.toIdentifier)(suffix); } function makeArrayFromCapturedBindings(ast, fun) { const closure = /* @__PURE__ */ new Map(); @@ -1124,8 +1150,9 @@ module.exports = function() { } } return { - pre() { + pre(state) { runWithTaggedExceptions(() => { + state.workletNumber = 1; (0, globals_1.initializeGlobals)(); utils_1.addCustomGlobals.call(this); }); @@ -1148,6 +1175,13 @@ module.exports = function() { }); } }, + Program: { + enter(_path, state) { + runWithTaggedExceptions(() => { + state.workletNumber = 1; + }); + } + }, JSXAttribute: { enter(path, state) { runWithTaggedExceptions(() => (0, inlineStylesWarning_1.processInlineStylesWarning)(path, state)); diff --git a/packages/react-native-reanimated/plugin/src/plugin.ts b/packages/react-native-reanimated/plugin/src/plugin.ts index 305a25d0d22..8bc1acece13 100644 --- a/packages/react-native-reanimated/plugin/src/plugin.ts +++ b/packages/react-native-reanimated/plugin/src/plugin.ts @@ -22,8 +22,10 @@ module.exports = function (): PluginItem { } return { - pre() { + pre(state: ReanimatedPluginPass) { runWithTaggedExceptions(() => { + // Initialize worklet number. + state.workletNumber = 1; initializeGlobals(); addCustomGlobals.call(this); }); @@ -50,6 +52,14 @@ module.exports = function (): PluginItem { }); }, }, + Program: { + enter(_path, state) { + runWithTaggedExceptions(() => { + // Reset worklet number. + state.workletNumber = 1; + }); + }, + }, JSXAttribute: { enter(path, state) { runWithTaggedExceptions(() => diff --git a/packages/react-native-reanimated/plugin/src/types.ts b/packages/react-native-reanimated/plugin/src/types.ts index 228669f1b87..9403577fdba 100644 --- a/packages/react-native-reanimated/plugin/src/types.ts +++ b/packages/react-native-reanimated/plugin/src/types.ts @@ -14,6 +14,7 @@ export interface ReanimatedPluginOptions { omitNativeOnlyData?: boolean; globals?: string[]; substituteWebPlatformChecks?: boolean; + disableSourceMaps?: boolean; } export interface ReanimatedPluginPass { @@ -24,6 +25,7 @@ export interface ReanimatedPluginPass { filename: string | undefined; get(key: unknown): unknown; set(key: unknown, value: unknown): void; + workletNumber: number; [key: string]: unknown; } diff --git a/packages/react-native-reanimated/plugin/src/workletFactory.ts b/packages/react-native-reanimated/plugin/src/workletFactory.ts index eceff3b0b7e..522ccb1c0bb 100644 --- a/packages/react-native-reanimated/plugin/src/workletFactory.ts +++ b/packages/react-native-reanimated/plugin/src/workletFactory.ts @@ -33,11 +33,12 @@ import { objectProperty, returnStatement, stringLiteral, + toIdentifier, variableDeclaration, variableDeclarator, } from '@babel/types'; import { strict as assert } from 'assert'; -import { relative } from 'path'; +import { basename, relative } from 'path'; import { buildWorkletString } from './workletStringCode'; import { globals } from './globals'; import type { ReanimatedPluginPass, WorkletizableFunction } from './types'; @@ -104,7 +105,7 @@ export function makeWorkletFactory( const variables = makeArrayFromCapturedBindings(transformed.ast, fun); - const functionName = makeWorkletName(fun); + const functionName = makeWorkletName(fun, state); const functionIdentifier = identifier(functionName); const clone = cloneNode(fun.node); @@ -120,6 +121,7 @@ export function makeWorkletFactory( let [funString, sourceMapString] = buildWorkletString( transformed.ast, + state, variables, functionName, transformed.map @@ -325,17 +327,38 @@ function hash(str: string): number { return (hash1 >>> 0) * 4096 + (hash2 >>> 0); } -function makeWorkletName(fun: NodePath): string { +function makeWorkletName( + fun: NodePath, + state: ReanimatedPluginPass +): string { + let source = 'unknownFile'; + + if (state.file.opts.filename) { + const filepath = state.file.opts.filename; + source = basename(filepath); + + // Get the library name from the path. + const splitFilepath = filepath.split('/'); + const nodeModulesIndex = splitFilepath.indexOf('node_modules'); + if (nodeModulesIndex !== -1) { + const libraryName = splitFilepath[nodeModulesIndex + 1]; + source = `${libraryName}_${source}`; + } + } + + const suffix = `${source}${state.workletNumber++}`; if (isObjectMethod(fun.node) && isIdentifier(fun.node.key)) { - return fun.node.key.name; + return toIdentifier(`${fun.node.key.name}_${suffix}`); } if (isFunctionDeclaration(fun.node) && isIdentifier(fun.node.id)) { - return fun.node.id.name; + return toIdentifier(`${fun.node.id.name}_${suffix}`); } if (isFunctionExpression(fun.node) && isIdentifier(fun.node.id)) { - return fun.node.id.name; + return toIdentifier(`${fun.node.id.name}_${suffix}`); } - return 'anonymous'; // fallback for ArrowFunctionExpression and unnamed FunctionExpression + + // Fallback for ArrowFunctionExpression and unnamed FunctionExpression. + return toIdentifier(suffix); } function makeArrayFromCapturedBindings( diff --git a/packages/react-native-reanimated/plugin/src/workletStringCode.ts b/packages/react-native-reanimated/plugin/src/workletStringCode.ts index ce5e9267082..36649e9e7c1 100644 --- a/packages/react-native-reanimated/plugin/src/workletStringCode.ts +++ b/packages/react-native-reanimated/plugin/src/workletStringCode.ts @@ -1,5 +1,5 @@ import type { BabelFileResult, NodePath, PluginItem } from '@babel/core'; -import { transformSync } from '@babel/core'; +import { transformSync, traverse } from '@babel/core'; import generate from '@babel/generator'; import type { File as BabelFile, @@ -29,16 +29,19 @@ import { strict as assert } from 'assert'; import * as convertSourceMap from 'convert-source-map'; import * as fs from 'fs'; import { isRelease } from './utils'; -import type { WorkletizableFunction } from './types'; +import type { ReanimatedPluginPass, WorkletizableFunction } from './types'; const MOCK_SOURCE_MAP = 'mock source map'; export function buildWorkletString( fun: BabelFile, + state: ReanimatedPluginPass, closureVariables: Array, - name: string, + nameWithSource: string, inputMap: BabelFileResult['map'] ): Array { + restoreRecursiveCalls(fun, nameWithSource); + const draftExpression = (fun.program.body.find((obj) => isFunctionDeclaration(obj) ) || @@ -61,7 +64,7 @@ export function buildWorkletString( ); const workletFunction = functionExpression( - identifier(name), + identifier(nameWithSource), expression.params, expression.body, expression.generator, @@ -72,7 +75,7 @@ export function buildWorkletString( assert(inputMap, '[Reanimated] `inputMap` is undefined.'); - const includeSourceMap = !isRelease(); + const includeSourceMap = !(isRelease() || state.opts.disableSourceMaps); if (includeSourceMap) { // Clear contents array (should be empty anyways) @@ -116,6 +119,24 @@ export function buildWorkletString( return [transformed.code, JSON.stringify(sourceMap)]; } +/** + * Function that restores recursive calls after the name of the worklet has changed. + */ +function restoreRecursiveCalls(file: BabelFile, newName: string): void { + traverse(file, { + FunctionExpression(path) { + if (!path.node.id) { + // Function wasn't named, hence it couldn't have had recursive calls by its name. + path.stop(); + return; + } + const oldName = path.node.id.name; + const scope = path.scope; + scope.rename(oldName, newName); + }, + }); +} + function shouldMockSourceMap() { // We don't want to pollute tests with source maps so we mock it // for all tests (except one)