react-native-reanimated 3.15.0 → 3.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -65,7 +65,7 @@ function setupRequestAnimationFrame() {
65
65
  // so we avoid doing requestAnimationFrame batching in Jest environment.
66
66
  const nativeRequestAnimationFrame = global.requestAnimationFrame;
67
67
  let animationFrameCallbacks = [];
68
- let lastNativeAnimationFrameTimestamp = -1;
68
+ let flushRequested = false;
69
69
  global.__flushAnimationFrame = frameTimestamp => {
70
70
  const currentCallbacks = animationFrameCallbacks;
71
71
  animationFrameCallbacks = [];
@@ -74,16 +74,10 @@ function setupRequestAnimationFrame() {
74
74
  };
75
75
  global.requestAnimationFrame = callback => {
76
76
  animationFrameCallbacks.push(callback);
77
- if (animationFrameCallbacks.length === 1) {
78
- // We schedule native requestAnimationFrame only when the first callback
79
- // is added and then use it to execute all the enqueued callbacks. Once
80
- // the callbacks are run, we clear the array.
77
+ if (!flushRequested) {
78
+ flushRequested = true;
81
79
  nativeRequestAnimationFrame(timestamp => {
82
- if (lastNativeAnimationFrameTimestamp >= timestamp) {
83
- // Make sure we only execute the callbacks once for a given frame
84
- return;
85
- }
86
- lastNativeAnimationFrameTimestamp = timestamp;
80
+ flushRequested = false;
87
81
  global.__frameTimestamp = timestamp;
88
82
  global.__flushAnimationFrame(timestamp);
89
83
  global.__frameTimestamp = undefined;
@@ -1 +1 @@
1
- {"version":3,"names":["reportFatalErrorOnJS","isChromeDebugger","isJest","shouldBeUseWeb","runOnJS","setupMicrotasks","callMicrotasks","runOnUIImmediately","mockedRequestAnimationFrame","IS_JEST","SHOULD_BE_USE_WEB","IS_CHROME_DEBUGGER","callGuardDEV","fn","args","e","global","__ErrorUtils","reportFatalError","setupCallGuard","__callGuardDEV","error","message","stack","capturableConsole","console","setupConsole","assert","debug","log","warn","info","setupRequestAnimationFrame","nativeRequestAnimationFrame","requestAnimationFrame","animationFrameCallbacks","lastNativeAnimationFrameTimestamp","__flushAnimationFrame","frameTimestamp","currentCallbacks","forEach","f","callback","push","length","timestamp","__frameTimestamp","undefined","initializeUIRuntime","globalThis"],"sources":["initializers.ts"],"sourcesContent":["'use strict';\nimport { reportFatalErrorOnJS } from './errors';\nimport { isChromeDebugger, isJest, shouldBeUseWeb } from './PlatformChecker';\nimport {\n runOnJS,\n setupMicrotasks,\n callMicrotasks,\n runOnUIImmediately,\n} from './threads';\nimport { mockedRequestAnimationFrame } from './mockedRequestAnimationFrame';\n\nconst IS_JEST = isJest();\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\nconst IS_CHROME_DEBUGGER = isChromeDebugger();\n\n// callGuard is only used with debug builds\nexport function callGuardDEV<Args extends unknown[], ReturnValue>(\n fn: (...args: Args) => ReturnValue,\n ...args: Args\n): ReturnValue | void {\n 'worklet';\n try {\n return fn(...args);\n } catch (e) {\n if (global.__ErrorUtils) {\n global.__ErrorUtils.reportFatalError(e as Error);\n } else {\n throw e;\n }\n }\n}\n\nexport function setupCallGuard() {\n 'worklet';\n global.__callGuardDEV = callGuardDEV;\n global.__ErrorUtils = {\n reportFatalError: (error: Error) => {\n runOnJS(reportFatalErrorOnJS)({\n message: error.message,\n stack: error.stack,\n });\n },\n };\n}\n\n// We really have to create a copy of console here. Function runOnJS we use on elements inside\n// this object makes it not configurable\nconst capturableConsole = { ...console };\n\nexport function setupConsole() {\n 'worklet';\n if (!IS_CHROME_DEBUGGER) {\n // @ts-ignore TypeScript doesn't like that there are missing methods in console object, but we don't provide all the methods for the UI runtime console version\n global.console = {\n /* eslint-disable @typescript-eslint/unbound-method */\n assert: runOnJS(capturableConsole.assert),\n debug: runOnJS(capturableConsole.debug),\n log: runOnJS(capturableConsole.log),\n warn: runOnJS(capturableConsole.warn),\n error: runOnJS(capturableConsole.error),\n info: runOnJS(capturableConsole.info),\n /* eslint-enable @typescript-eslint/unbound-method */\n };\n }\n}\n\nfunction setupRequestAnimationFrame() {\n 'worklet';\n\n // Jest mocks requestAnimationFrame API and it does not like if that mock gets overridden\n // so we avoid doing requestAnimationFrame batching in Jest environment.\n const nativeRequestAnimationFrame = global.requestAnimationFrame;\n\n let animationFrameCallbacks: Array<(timestamp: number) => void> = [];\n let lastNativeAnimationFrameTimestamp = -1;\n\n global.__flushAnimationFrame = (frameTimestamp: number) => {\n const currentCallbacks = animationFrameCallbacks;\n animationFrameCallbacks = [];\n currentCallbacks.forEach((f) => f(frameTimestamp));\n callMicrotasks();\n };\n\n global.requestAnimationFrame = (\n callback: (timestamp: number) => void\n ): number => {\n animationFrameCallbacks.push(callback);\n if (animationFrameCallbacks.length === 1) {\n // We schedule native requestAnimationFrame only when the first callback\n // is added and then use it to execute all the enqueued callbacks. Once\n // the callbacks are run, we clear the array.\n nativeRequestAnimationFrame((timestamp) => {\n if (lastNativeAnimationFrameTimestamp >= timestamp) {\n // Make sure we only execute the callbacks once for a given frame\n return;\n }\n lastNativeAnimationFrameTimestamp = timestamp;\n global.__frameTimestamp = timestamp;\n global.__flushAnimationFrame(timestamp);\n global.__frameTimestamp = undefined;\n });\n }\n // Reanimated currently does not support cancelling callbacks requested with\n // requestAnimationFrame. We return -1 as identifier which isn't in line\n // with the spec but it should give users better clue in case they actually\n // attempt to store the value returned from rAF and use it for cancelling.\n return -1;\n };\n}\n\nexport function initializeUIRuntime() {\n if (IS_JEST) {\n // requestAnimationFrame react-native jest's setup is incorrect as it polyfills\n // the method directly using setTimeout, therefore the callback doesn't get the\n // expected timestamp as the only argument: https://github.com/facebook/react-native/blob/main/packages/react-native/jest/setup.js#L28\n // We override this setup here to make sure that callbacks get the proper timestamps\n // when executed. For non-jest environments we define requestAnimationFrame in setupRequestAnimationFrame\n // @ts-ignore TypeScript uses Node definition for rAF, setTimeout, etc which returns a Timeout object rather than a number\n globalThis.requestAnimationFrame = mockedRequestAnimationFrame;\n }\n\n runOnUIImmediately(() => {\n 'worklet';\n setupCallGuard();\n setupConsole();\n if (!SHOULD_BE_USE_WEB) {\n setupMicrotasks();\n setupRequestAn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ACA;IACA;IACA;IACA;IACA,OAAO,CAAC,CAAC;EACX,CAAC;AACH;AAEA,OAAO,SAASC,mBAAmBA,CAAA,EAAG;EACpC,IAAIvC,OAAO,EAAE;IACX;IACA;IACA;IACA;IACA;IACA;IACAwC,UAAU,CAACf,qBAAqB,GAAG1B,2BAA2B;EAChE;EAEAD,kBAAkB,CAAC,MAAM;IACvB,SAAS;;IACTY,cAAc,CAAC,CAAC;IAChBO,YAAY,CAAC,CAAC;IACd,IAAI,CAAChB,iBAAiB,EAAE;MACtBL,eAAe,CAAC,CAAC;MACjB2B,0BAA0B,CAAC,CAAC;IAC9B;EACF,CAAC,CAAC,CAAC,CAAC;AACN","ignoreList":[]}
1
+ {"version":3,"names":["reportFatalErrorOnJS","isChromeDebugger","isJest","shouldBeUseWeb","runOnJS","setupMicrotasks","callMicrotasks","runOnUIImmediately","mockedRequestAnimationFrame","IS_JEST","SHOULD_BE_USE_WEB","IS_CHROME_DEBUGGER","callGuardDEV","fn","args","e","global","__ErrorUtils","reportFatalError","setupCallGuard","__callGuardDEV","error","message","stack","capturableConsole","console","setupConsole","assert","debug","log","warn","info","setupRequestAnimationFrame","nativeRequestAnimationFrame","requestAnimationFrame","animationFrameCallbacks","flushRequested","__flushAnimationFrame","frameTimestamp","currentCallbacks","forEach","f","callback","push","timestamp","__frameTimestamp","undefined","initializeUIRuntime","globalThis"],"sources":["initializers.ts"],"sourcesContent":["'use strict';\nimport { reportFatalErrorOnJS } from './errors';\nimport { isChromeDebugger, isJest, shouldBeUseWeb } from './PlatformChecker';\nimport {\n runOnJS,\n setupMicrotasks,\n callMicrotasks,\n runOnUIImmediately,\n} from './threads';\nimport { mockedRequestAnimationFrame } from './mockedRequestAnimationFrame';\n\nconst IS_JEST = isJest();\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\nconst IS_CHROME_DEBUGGER = isChromeDebugger();\n\n// callGuard is only used with debug builds\nexport function callGuardDEV<Args extends unknown[], ReturnValue>(\n fn: (...args: Args) => ReturnValue,\n ...args: Args\n): ReturnValue | void {\n 'worklet';\n try {\n return fn(...args);\n } catch (e) {\n if (global.__ErrorUtils) {\n global.__ErrorUtils.reportFatalError(e as Error);\n } else {\n throw e;\n }\n }\n}\n\nexport function setupCallGuard() {\n 'worklet';\n global.__callGuardDEV = callGuardDEV;\n global.__ErrorUtils = {\n reportFatalError: (error: Error) => {\n runOnJS(reportFatalErrorOnJS)({\n message: error.message,\n stack: error.stack,\n });\n },\n };\n}\n\n// We really have to create a copy of console here. Function runOnJS we use on elements inside\n// this object makes it not configurable\nconst capturableConsole = { ...console };\n\nexport function setupConsole() {\n 'worklet';\n if (!IS_CHROME_DEBUGGER) {\n // @ts-ignore TypeScript doesn't like that there are missing methods in console object, but we don't provide all the methods for the UI runtime console version\n global.console = {\n /* eslint-disable @typescript-eslint/unbound-method */\n assert: runOnJS(capturableConsole.assert),\n debug: runOnJS(capturableConsole.debug),\n log: runOnJS(capturableConsole.log),\n warn: runOnJS(capturableConsole.warn),\n error: runOnJS(capturableConsole.error),\n info: runOnJS(capturableConsole.info),\n /* eslint-enable @typescript-eslint/unbound-method */\n };\n }\n}\n\nfunction setupRequestAnimationFrame() {\n 'worklet';\n\n // Jest mocks requestAnimationFrame API and it does not like if that mock gets overridden\n // so we avoid doing requestAnimationFrame batching in Jest environment.\n const nativeRequestAnimationFrame = global.requestAnimationFrame;\n\n let animationFrameCallbacks: Array<(timestamp: number) => void> = [];\n let flushRequested = false;\n\n global.__flushAnimationFrame = (frameTimestamp: number) => {\n const currentCallbacks = animationFrameCallbacks;\n animationFrameCallbacks = [];\n currentCallbacks.forEach((f) => f(frameTimestamp));\n callMicrotasks();\n };\n\n global.requestAnimationFrame = (\n callback: (timestamp: number) => void\n ): number => {\n animationFrameCallbacks.push(callback);\n if (!flushRequested) {\n flushRequested = true;\n nativeRequestAnimationFrame((timestamp) => {\n flushRequested = false;\n global.__frameTimestamp = timestamp;\n global.__flushAnimationFrame(timestamp);\n global.__frameTimestamp = undefined;\n });\n }\n // Reanimated currently does not support cancelling callbacks requested with\n // requestAnimationFrame. We return -1 as identifier which isn't in line\n // with the spec but it should give users better clue in case they actually\n // attempt to store the value returned from rAF and use it for cancelling.\n return -1;\n };\n}\n\nexport function initializeUIRuntime() {\n if (IS_JEST) {\n // requestAnimationFrame react-native jest's setup is incorrect as it polyfills\n // the method directly using setTimeout, therefore the callback doesn't get the\n // expected timestamp as the only argument: https://github.com/facebook/react-native/blob/main/packages/react-native/jest/setup.js#L28\n // We override this setup here to make sure that callbacks get the proper timestamps\n // when executed. For non-jest environments we define requestAnimationFrame in setupRequestAnimationFrame\n // @ts-ignore TypeScript uses Node definition for rAF, setTimeout, etc which returns a Timeout object rather than a number\n globalThis.requestAnimationFrame = mockedRequestAnimationFrame;\n }\n\n runOnUIImmediately(() => {\n 'worklet';\n setupCallGuard();\n setupConsole();\n if (!SHOULD_BE_USE_WEB) {\n setupMicrotasks();\n setupRequestAnimationFrame();\n }\n })();\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,oBAAoB,QAAQ,UAAU;AAC/C,SAASC,gBAAgB,EAAEC,MAAM,EAAEC,cAAc,QAAQ,mBAAmB;AAC5E,SACEC,OAAO,EACPC,eAAe,EACfC,cAAc,EACdC,kBAAkB,QACb,WAAW;AAClB,SAASC,2BAA2B,QAAQ,+BAA+B;AAE3E,MAAMC,OAAO,GAAGP,MAAM,CAAC,CAAC;AACxB,MAAMQ,iBAAiB,GAAGP,cAAc,CAAC,CAAC;AAC1C,MAAMQ,kBAAkB,GAAGV,gBAAgB,CAAC,CAAC;;AAE7C;AACA,OAAO,SAASW,YAAYA,CAC1BC,EAAkC,EAClC,GAAGC,IAAU,EACO;EACpB,SAAS;;EACT,IAAI;IACF,OAAOD,EAAE,CAAC,GAAGC,IAAI,CAAC;EACpB,CAAC,CAAC,OAAOC,CAAC,EAAE;IACV,IAAIC,MAAM,CAACC,YAAY,EAAE;MACvBD,MAAM,CAACC,YAAY,CAACC,gBAAgB,CAACH,C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AE;IAC5BI,gBAAgB,CAACC,OAAO,CAAEC,CAAC,IAAKA,CAAC,CAACH,cAAc,CAAC,CAAC;IAClDhC,cAAc,CAAC,CAAC;EAClB,CAAC;EAEDU,MAAM,CAACkB,qBAAqB,GAC1BQ,QAAqC,IAC1B;IACXP,uBAAuB,CAACQ,IAAI,CAACD,QAAQ,CAAC;IACtC,IAAI,CAACN,cAAc,EAAE;MACnBA,cAAc,GAAG,IAAI;MACrBH,2BAA2B,CAAEW,SAAS,IAAK;QACzCR,cAAc,GAAG,KAAK;QACtBpB,MAAM,CAAC6B,gBAAgB,GAAGD,SAAS;QACnC5B,MAAM,CAACqB,qBAAqB,CAACO,SAAS,CAAC;QACvC5B,MAAM,CAAC6B,gBAAgB,GAAGC,SAAS;MACrC,CAAC,CAAC;IACJ;IACA;IACA;IACA;IACA;IACA,OAAO,CAAC,CAAC;EACX,CAAC;AACH;AAEA,OAAO,SAASC,mBAAmBA,CAAA,EAAG;EACpC,IAAItC,OAAO,EAAE;IACX;IACA;IACA;IACA;IACA;IACA;IACAuC,UAAU,CAACd,qBAAqB,GAAG1B,2BAA2B;EAChE;EAEAD,kBAAkB,CAAC,MAAM;IACvB,SAAS;;IACTY,cAAc,CAAC,CAAC;IAChBO,YAAY,CAAC,CAAC;IACd,IAAI,CAAChB,iBAAiB,EAAE;MACtBL,eAAe,CAAC,CAAC;MACjB2B,0BAA0B,CAAC,CAAC;IAC9B;EACF,CAAC,CAAC,CAAC,CAAC;AACN","ignoreList":[]}
@@ -5,5 +5,5 @@
5
5
  * with the version used to build the native part of the library in runtime.
6
6
  * Remember to keep this in sync with the version declared in `package.json`
7
7
  */
8
- export const jsVersion = '3.15.0';
8
+ export const jsVersion = '3.15.1';
9
9
  //# sourceMappingURL=jsVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["jsVersion"],"sources":["jsVersion.ts"],"sourcesContent":["'use strict';\n/**\n * We hardcode the version of Reanimated here in order to compare it\n * with the version used to build the native part of the library in runtime.\n * Remember to keep this in sync with the version declared in `package.json`\n */\nexport const jsVersion = '3.15.0';\n"],"mappings":"AAAA,YAAY;;AACZ;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,SAAS,GAAG,QAAQ","ignoreList":[]}
1
+ {"version":3,"names":["jsVersion"],"sources":["jsVersion.ts"],"sourcesContent":["'use strict';\n/**\n * We hardcode the version of Reanimated here in order to compare it\n * with the version used to build the native part of the library in runtime.\n * Remember to keep this in sync with the version declared in `package.json`\n */\nexport const jsVersion = '3.15.1';\n"],"mappings":"AAAA,YAAY;;AACZ;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,SAAS,GAAG,QAAQ","ignoreList":[]}
@@ -3,4 +3,4 @@
3
3
  * with the version used to build the native part of the library in runtime.
4
4
  * Remember to keep this in sync with the version declared in `package.json`
5
5
  */
6
- export declare const jsVersion = "3.15.0";
6
+ export declare const jsVersion = "3.15.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-reanimated",
3
- "version": "3.15.0",
3
+ "version": "3.15.1",
4
4
  "description": "More powerful alternative to Animated library for React Native.",
5
5
  "scripts": {
6
6
  "test": "yarn format:js && yarn lint:js && yarn test:unit",
@@ -261,8 +261,8 @@ var require_workletStringCode = __commonJS({
261
261
  var types_2 = require_types();
262
262
  var utils_12 = require_utils();
263
263
  var MOCK_SOURCE_MAP = "mock source map";
264
- function buildWorkletString(fun, state, closureVariables, nameWithSource, inputMap) {
265
- restoreRecursiveCalls(fun, nameWithSource);
264
+ function buildWorkletString(fun, state, closureVariables, workletName, inputMap) {
265
+ restoreRecursiveCalls(fun, workletName);
266
266
  const draftExpression = fun.program.body.find((obj) => (0, types_12.isFunctionDeclaration)(obj)) || fun.program.body.find((obj) => (0, types_12.isExpressionStatement)(obj)) || void 0;
267
267
  (0, assert_1.strict)(draftExpression, "[Reanimated] `draftExpression` is undefined.");
268
268
  const expression = (0, types_12.isFunctionDeclaration)(draftExpression) ? draftExpression : draftExpression.expression;
@@ -289,7 +289,7 @@ var require_workletStringCode = __commonJS({
289
289
  parsedClasses.add(constructorName);
290
290
  }
291
291
  });
292
- const workletFunction = (0, types_12.functionExpression)((0, types_12.identifier)(nameWithSource), expression.params, expression.body, expression.generator, expression.async);
292
+ const workletFunction = (0, types_12.functionExpression)((0, types_12.identifier)(workletName), expression.params, expression.body, expression.generator, expression.async);
293
293
  const code = (0, generator_1.default)(workletFunction).code;
294
294
  (0, assert_1.strict)(inputMap, "[Reanimated] `inputMap` is undefined.");
295
295
  const includeSourceMap = !((0, utils_12.isRelease)() || state.opts.disableSourceMaps);
@@ -426,11 +426,10 @@ var require_workletFactory = __commonJS({
426
426
  (0, assert_1.strict)(transformed, "[Reanimated] `transformed` is undefined.");
427
427
  (0, assert_1.strict)(transformed.ast, "[Reanimated] `transformed.ast` is undefined.");
428
428
  const variables = makeArrayFromCapturedBindings(transformed.ast, fun);
429
- const functionName = makeWorkletName(fun, state);
430
- const functionIdentifier = (0, types_12.identifier)(functionName);
431
429
  const clone = (0, types_12.cloneNode)(fun.node);
432
430
  const funExpression = (0, types_12.isBlockStatement)(clone.body) ? (0, types_12.functionExpression)(null, clone.params, clone.body, clone.generator, clone.async) : clone;
433
- let [funString, sourceMapString] = (0, workletStringCode_1.buildWorkletString)(transformed.ast, state, variables, functionName, transformed.map);
431
+ const { workletName, reactName } = makeWorkletName(fun, state);
432
+ let [funString, sourceMapString] = (0, workletStringCode_1.buildWorkletString)(transformed.ast, state, variables, workletName, transformed.map);
434
433
  (0, assert_1.strict)(funString, "[Reanimated] `funString` is undefined.");
435
434
  const workletHash = hash(funString);
436
435
  let lineOffset = 1;
@@ -473,13 +472,13 @@ var require_workletFactory = __commonJS({
473
472
  (0, assert_1.strict)(!(0, types_12.isObjectMethod)(funExpression), "[Reanimated] `funExpression` is an `ObjectMethod`.");
474
473
  const statements = [
475
474
  (0, types_12.variableDeclaration)("const", [
476
- (0, types_12.variableDeclarator)(functionIdentifier, funExpression)
475
+ (0, types_12.variableDeclarator)((0, types_12.identifier)(reactName), funExpression)
477
476
  ]),
478
- (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)(functionIdentifier, (0, types_12.identifier)("__closure"), false), (0, types_12.objectExpression)(variables.map((variable) => variable.name.endsWith(types_2.workletClassFactorySuffix) ? (0, types_12.objectProperty)((0, types_12.identifier)(variable.name), (0, types_12.memberExpression)((0, types_12.identifier)(variable.name.slice(0, variable.name.length - types_2.workletClassFactorySuffix.length)), (0, types_12.identifier)(variable.name))) : (0, types_12.objectProperty)((0, types_12.identifier)(variable.name), variable, false, true))))),
479
- (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)(functionIdentifier, (0, types_12.identifier)("__workletHash"), false), (0, types_12.numericLiteral)(workletHash)))
477
+ (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__closure"), false), (0, types_12.objectExpression)(variables.map((variable) => variable.name.endsWith(types_2.workletClassFactorySuffix) ? (0, types_12.objectProperty)((0, types_12.identifier)(variable.name), (0, types_12.memberExpression)((0, types_12.identifier)(variable.name.slice(0, variable.name.length - types_2.workletClassFactorySuffix.length)), (0, types_12.identifier)(variable.name))) : (0, types_12.objectProperty)((0, types_12.identifier)(variable.name), variable, false, true))))),
478
+ (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__workletHash"), false), (0, types_12.numericLiteral)(workletHash)))
480
479
  ];
481
480
  if (shouldIncludeInitData) {
482
- statements.push((0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)(functionIdentifier, (0, types_12.identifier)("__initData"), false), initDataId)));
481
+ statements.push((0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__initData"), false), initDataId)));
483
482
  }
484
483
  if (!(0, utils_12.isRelease)()) {
485
484
  statements.unshift((0, types_12.variableDeclaration)("const", [
@@ -489,9 +488,9 @@ var require_workletFactory = __commonJS({
489
488
  (0, types_12.numericLiteral)(-27)
490
489
  ]))
491
490
  ]));
492
- statements.push((0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)(functionIdentifier, (0, types_12.identifier)("__stackDetails"), false), (0, types_12.identifier)("_e"))));
491
+ statements.push((0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__stackDetails"), false), (0, types_12.identifier)("_e"))));
493
492
  }
494
- statements.push((0, types_12.returnStatement)(functionIdentifier));
493
+ statements.push((0, types_12.returnStatement)((0, types_12.identifier)(reactName)));
495
494
  const newFun = (0, types_12.functionExpression)(void 0, [], (0, types_12.blockStatement)(statements));
496
495
  return newFun;
497
496
  }
@@ -532,16 +531,15 @@ var require_workletFactory = __commonJS({
532
531
  }
533
532
  }
534
533
  const suffix = `${source}${state.workletNumber++}`;
534
+ let reactName = "";
535
535
  if ((0, types_12.isObjectMethod)(fun.node) && (0, types_12.isIdentifier)(fun.node.key)) {
536
- return (0, types_12.toIdentifier)(`${fun.node.key.name}_${suffix}`);
536
+ reactName = fun.node.key.name;
537
+ } else if (((0, types_12.isFunctionDeclaration)(fun.node) || (0, types_12.isFunctionExpression)(fun.node)) && (0, types_12.isIdentifier)(fun.node.id)) {
538
+ reactName = fun.node.id.name;
537
539
  }
538
- if ((0, types_12.isFunctionDeclaration)(fun.node) && (0, types_12.isIdentifier)(fun.node.id)) {
539
- return (0, types_12.toIdentifier)(`${fun.node.id.name}_${suffix}`);
540
- }
541
- if ((0, types_12.isFunctionExpression)(fun.node) && (0, types_12.isIdentifier)(fun.node.id)) {
542
- return (0, types_12.toIdentifier)(`${fun.node.id.name}_${suffix}`);
543
- }
544
- return (0, types_12.toIdentifier)(suffix);
540
+ const workletName = reactName ? (0, types_12.toIdentifier)(`${reactName}_${suffix}`) : (0, types_12.toIdentifier)(suffix);
541
+ reactName = reactName || (0, types_12.toIdentifier)(suffix);
542
+ return { workletName, reactName };
545
543
  }
546
544
  function makeArrayFromCapturedBindings(ast, fun) {
547
545
  const closure = /* @__PURE__ */ new Map();
@@ -72,7 +72,7 @@ function setupRequestAnimationFrame() {
72
72
  const nativeRequestAnimationFrame = global.requestAnimationFrame;
73
73
 
74
74
  let animationFrameCallbacks: Array<(timestamp: number) => void> = [];
75
- let lastNativeAnimationFrameTimestamp = -1;
75
+ let flushRequested = false;
76
76
 
77
77
  global.__flushAnimationFrame = (frameTimestamp: number) => {
78
78
  const currentCallbacks = animationFrameCallbacks;
@@ -85,16 +85,10 @@ function setupRequestAnimationFrame() {
85
85
  callback: (timestamp: number) => void
86
86
  ): number => {
87
87
  animationFrameCallbacks.push(callback);
88
- if (animationFrameCallbacks.length === 1) {
89
- // We schedule native requestAnimationFrame only when the first callback
90
- // is added and then use it to execute all the enqueued callbacks. Once
91
- // the callbacks are run, we clear the array.
88
+ if (!flushRequested) {
89
+ flushRequested = true;
92
90
  nativeRequestAnimationFrame((timestamp) => {
93
- if (lastNativeAnimationFrameTimestamp >= timestamp) {
94
- // Make sure we only execute the callbacks once for a given frame
95
- return;
96
- }
97
- lastNativeAnimationFrameTimestamp = timestamp;
91
+ flushRequested = false;
98
92
  global.__frameTimestamp = timestamp;
99
93
  global.__flushAnimationFrame(timestamp);
100
94
  global.__frameTimestamp = undefined;
@@ -4,4 +4,4 @@
4
4
  * with the version used to build the native part of the library in runtime.
5
5
  * Remember to keep this in sync with the version declared in `package.json`
6
6
  */
7
- export const jsVersion = '3.15.0';
7
+ export const jsVersion = '3.15.1';