react-native-reanimated 3.0.0-rc.4 → 3.0.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +2 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.h +1 -0
- package/android/CMakeLists.txt +1 -0
- package/android/build.gradle +9 -1
- package/android/src/main/cpp/NativeProxy.cpp +1 -1
- package/ios/native/NativeProxy.mm +6 -1
- package/lib/commonjs/reanimated2/jestUtils.js +17 -9
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +17 -9
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/package.json +2 -2
- package/src/reanimated2/jestUtils.ts +14 -6
|
@@ -20,6 +20,7 @@ using namespace facebook;
|
|
|
20
20
|
using namespace react;
|
|
21
21
|
|
|
22
22
|
std::shared_ptr<jsi::Runtime> ReanimatedRuntime::make(
|
|
23
|
+
jsi::Runtime *rnRuntime,
|
|
23
24
|
std::shared_ptr<MessageQueueThread> jsQueue) {
|
|
24
25
|
#if JS_RUNTIME_HERMES
|
|
25
26
|
std::unique_ptr<facebook::hermes::HermesRuntime> runtime =
|
|
@@ -37,7 +38,7 @@ std::shared_ptr<jsi::Runtime> ReanimatedRuntime::make(
|
|
|
37
38
|
auto config = std::make_unique<rnv8::V8RuntimeConfig>();
|
|
38
39
|
config->enableInspector = false;
|
|
39
40
|
config->appName = "reanimated";
|
|
40
|
-
return rnv8::createSharedV8Runtime(
|
|
41
|
+
return rnv8::createSharedV8Runtime(rnRuntime, std::move(config));
|
|
41
42
|
#else
|
|
42
43
|
// This is required by iOS, because there is an assertion in the destructor
|
|
43
44
|
// that the thread was indeed `quit` before
|
package/android/CMakeLists.txt
CHANGED
package/android/build.gradle
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import com.android.Version
|
|
2
2
|
import org.apache.tools.ant.filters.ReplaceTokens
|
|
3
|
+
import org.apache.tools.ant.taskdefs.condition.Os
|
|
3
4
|
import groovy.json.JsonSlurper
|
|
4
5
|
import java.nio.file.Paths
|
|
5
6
|
|
|
@@ -183,6 +184,13 @@ def getReanimatedVersion() {
|
|
|
183
184
|
return major.toInteger()
|
|
184
185
|
}
|
|
185
186
|
|
|
187
|
+
def toPlatformFileString(String path) {
|
|
188
|
+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|
189
|
+
path = path.replace(File.separatorChar, '/' as char)
|
|
190
|
+
}
|
|
191
|
+
return path
|
|
192
|
+
}
|
|
193
|
+
|
|
186
194
|
boolean CLIENT_SIDE_BUILD = resolveClientSideBuild()
|
|
187
195
|
if (CLIENT_SIDE_BUILD) {
|
|
188
196
|
configurations.maybeCreate("default")
|
|
@@ -447,7 +455,7 @@ android {
|
|
|
447
455
|
"-DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}",
|
|
448
456
|
"-DANDROID_TOOLCHAIN=clang",
|
|
449
457
|
"-DBOOST_VERSION=${BOOST_VERSION}",
|
|
450
|
-
"-DREACT_NATIVE_DIR=${reactNativeRootDir.path}",
|
|
458
|
+
"-DREACT_NATIVE_DIR=${toPlatformFileString(reactNativeRootDir.path)}",
|
|
451
459
|
"-DJS_RUNTIME=${JS_RUNTIME}",
|
|
452
460
|
"-DJS_RUNTIME_DIR=${jsRuntimeDir}",
|
|
453
461
|
"-DCLIENT_SIDE_BUILD=${CLIENT_SIDE_BUILD}",
|
|
@@ -203,7 +203,7 @@ void NativeProxy::installJSIBindings(
|
|
|
203
203
|
|
|
204
204
|
auto jsQueue = std::make_shared<JMessageQueueThread>(messageQueueThread);
|
|
205
205
|
std::shared_ptr<jsi::Runtime> animatedRuntime =
|
|
206
|
-
ReanimatedRuntime::make(jsQueue);
|
|
206
|
+
ReanimatedRuntime::make(runtime_, jsQueue);
|
|
207
207
|
|
|
208
208
|
auto workletRuntimeValue =
|
|
209
209
|
runtime_->global()
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
#import <dlfcn.h>
|
|
33
33
|
#endif
|
|
34
34
|
|
|
35
|
+
@interface RCTBridge (JSIRuntime)
|
|
36
|
+
- (void *)runtime;
|
|
37
|
+
@end
|
|
38
|
+
|
|
35
39
|
namespace reanimated {
|
|
36
40
|
|
|
37
41
|
using namespace facebook;
|
|
@@ -198,7 +202,8 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
|
|
|
198
202
|
auto jsQueue = std::make_shared<REAMessageThread>([NSRunLoop currentRunLoop], ^(NSError *error) {
|
|
199
203
|
throw error;
|
|
200
204
|
});
|
|
201
|
-
|
|
205
|
+
auto rnRuntime = reinterpret_cast<facebook::jsi::Runtime *>(reanimatedModule.bridge.runtime);
|
|
206
|
+
std::shared_ptr<jsi::Runtime> animatedRuntime = ReanimatedRuntime::make(rnRuntime, jsQueue);
|
|
202
207
|
|
|
203
208
|
std::shared_ptr<Scheduler> scheduler = std::make_shared<REAIOSScheduler>(jsInvoker);
|
|
204
209
|
std::shared_ptr<ErrorHandler> errorHandler = std::make_shared<REAIOSErrorHandler>(scheduler);
|
|
@@ -201,17 +201,25 @@ exports.advanceAnimationByFrame = advanceAnimationByFrame;
|
|
|
201
201
|
|
|
202
202
|
const setUpTests = function () {
|
|
203
203
|
let userConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
204
|
-
let expect;
|
|
204
|
+
let expect = global.expect;
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
} catch (_) {
|
|
209
|
-
// for Jest in version 28+
|
|
210
|
-
const {
|
|
211
|
-
expect: expectModule
|
|
212
|
-
} = require('@jest/globals');
|
|
206
|
+
if (expect === undefined) {
|
|
207
|
+
const expectModule = require('expect');
|
|
213
208
|
|
|
214
|
-
expect = expectModule;
|
|
209
|
+
expect = expectModule; // Starting from Jest 28, "expect" package uses named exports instead of default export.
|
|
210
|
+
// So, requiring "expect" package doesn't give direct access to "expect" function anymore.
|
|
211
|
+
// It gives access to the module object instead.
|
|
212
|
+
// We use this info to detect if the project uses Jest 28 or higher.
|
|
213
|
+
|
|
214
|
+
if (typeof expect === 'object') {
|
|
215
|
+
const jestGlobals = require('@jest/globals');
|
|
216
|
+
|
|
217
|
+
expect = jestGlobals.expect;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (expect === undefined || expect.extend === undefined) {
|
|
221
|
+
expect = expectModule.default;
|
|
222
|
+
}
|
|
215
223
|
}
|
|
216
224
|
|
|
217
225
|
require('setimmediate');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["config","fps","isAnimatedStyle","style","animatedStyle","getAnimatedStyleFromObject","current","value","getCurrentStyle","received","styleObject","props","currentStyle","Array","isArray","forEach","checkEqual","expectStyle","length","i","property","findStyleDiff","expect","requireAllMatch","diffs","isEqual","push","Object","keys","undefined","compareStyle","expectedStyle","message","pass","exact","currentStyleStr","JSON","stringify","expectedStyleStr","differences","map","diff","join","frameTime","requestAnimationFrameCopy","currentTimestamp","requestAnimationFrame","callback","setTimeout","beforeTest","jestResetJsReanimatedModule","global","ReanimatedDataMock","now","jest","useFakeTimers","afterTest","useRealTimers","tickTravel","advanceTimersByTime","withReanimatedTimer","animationTest","advanceAnimationByTime","time","Math","ceil","advanceAnimationByFrame","count","setUpTests","userConfig","require","_","expectModule","round","extend","toHaveAnimatedStyle","getAnimatedStyle"],"sources":["jestUtils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nimport { jestResetJsReanimatedModule } from './core';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R> {\n toHaveAnimatedStyle(\n style: Record<string, unknown>[] | Record<string, unknown>\n ): R;\n }\n }\n}\n\nlet config = {\n fps: 60,\n};\n\nconst isAnimatedStyle = (style) => {\n return !!style.animatedStyle;\n};\n\nconst getAnimatedStyleFromObject = (style) => {\n return style.animatedStyle.current.value;\n};\n\nconst getCurrentStyle = (received) => {\n const styleObject = received.props.style;\n let currentStyle = {};\n if (Array.isArray(styleObject)) {\n received.props.style.forEach((style) => {\n if (isAnimatedStyle(style)) {\n currentStyle = {\n ...currentStyle,\n ...getAnimatedStyleFromObject(style),\n };\n } else {\n currentStyle = {\n ...currentStyle,\n ...style,\n };\n }\n });\n } else {\n if (isAnimatedStyle(styleObject)) {\n currentStyle = getAnimatedStyleFromObject(styleObject);\n } else {\n currentStyle = {\n ...styleObject,\n ...received.props.animatedStyle.value,\n };\n }\n }\n return currentStyle;\n};\n\nconst checkEqual = (currentStyle, expectStyle) => {\n if (Array.isArray(expectStyle)) {\n if (expectStyle.length !== currentStyle.length) return false;\n for (let i = 0; i < currentStyle.length; i++) {\n if (!checkEqual(currentStyle[i], expectStyle[i])) {\n return false;\n }\n }\n } else if (typeof currentStyle === 'object' && currentStyle) {\n for (const property in expectStyle) {\n if (!checkEqual(currentStyle[property], expectStyle[property])) {\n return false;\n }\n }\n } else {\n return currentStyle === expectStyle;\n }\n return true;\n};\n\nconst findStyleDiff = (current, expect, requireAllMatch) => {\n const diffs = [];\n let isEqual = true;\n for (const property in expect) {\n if (!checkEqual(current[property], expect[property])) {\n isEqual = false;\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n\n if (\n requireAllMatch &&\n Object.keys(current).length !== Object.keys(expect).length\n ) {\n isEqual = false;\n for (const property in current) {\n if (expect[property] === undefined) {\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n }\n\n return { isEqual, diffs };\n};\n\nconst compareStyle = (received, expectedStyle, config) => {\n if (!received.props.style) {\n return { message: () => message, pass: false };\n }\n const { exact } = config;\n const currentStyle = getCurrentStyle(received);\n const { isEqual, diffs } = findStyleDiff(currentStyle, expectedStyle, exact);\n\n if (isEqual) {\n return { message: () => 'ok', pass: true };\n }\n\n const currentStyleStr = JSON.stringify(currentStyle);\n const expectedStyleStr = JSON.stringify(expectedStyle);\n const differences = diffs\n .map(\n (diff) =>\n `- '${diff.property}' should be ${JSON.stringify(\n diff.expect\n )}, but is ${JSON.stringify(diff.current)}`\n )\n .join('\\n');\n\n return {\n message: () =>\n `Expected: ${expectedStyleStr}\\nReceived: ${currentStyleStr}\\n\\nDifferences:\\n${differences}`,\n pass: false,\n };\n};\n\nlet frameTime = 1000 / config.fps;\nlet requestAnimationFrameCopy;\nlet currentTimestamp = 0;\n\nconst requestAnimationFrame = (callback) => {\n setTimeout(callback, frameTime);\n};\n\nconst beforeTest = () => {\n jestResetJsReanimatedModule();\n requestAnimationFrameCopy = global.requestAnimationFrame;\n global.requestAnimationFrame = requestAnimationFrame;\n global.ReanimatedDataMock = {\n now: () => currentTimestamp,\n };\n currentTimestamp = 0;\n jest.useFakeTimers();\n};\n\nconst afterTest = () => {\n jest.useRealTimers();\n global.requestAnimationFrame = requestAnimationFrameCopy;\n};\n\nconst tickTravel = () => {\n currentTimestamp += frameTime;\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const withReanimatedTimer = (animationTest) => {\n beforeTest();\n animationTest();\n afterTest();\n};\n\nexport const advanceAnimationByTime = (time = frameTime) => {\n for (let i = 0; i <= Math.ceil(time / frameTime); i++) {\n tickTravel();\n }\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const advanceAnimationByFrame = (count) => {\n for (let i = 0; i <= count; i++) {\n tickTravel();\n }\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const setUpTests = (userConfig = {}) => {\n let expect;\n try {\n expect = require('expect');\n } catch (_) {\n // for Jest in version 28+\n const { expect: expectModule } = require('@jest/globals');\n expect = expectModule;\n }\n\n require('setimmediate');\n frameTime = Math.round(1000 / config.fps);\n\n config = {\n ...config,\n ...userConfig,\n };\n\n expect.extend({\n toHaveAnimatedStyle(received, expectedStyle, config = {}) {\n return compareStyle(received, expectedStyle, config);\n },\n });\n};\n\nexport const getAnimatedStyle = (received) => {\n return getCurrentStyle(received);\n};\n"],"m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D,CALM;;;;AAOA,MAAMuB,uBAAuB,GAAIC,KAAD,IAAW;EAChD,KAAK,IAAIhD,CAAC,GAAG,CAAb,EAAgBA,CAAC,IAAIgD,KAArB,EAA4BhD,CAAC,EAA7B,EAAiC;IAC/BuC,UAAU;EACX;;EACDJ,IAAI,CAACK,mBAAL,CAAyBhB,SAAzB;AACD,CALM;;;;AAOA,MAAMyB,UAAU,GAAG,YAAqB;EAAA,IAApBC,UAAoB,uEAAP,EAAO;EAC7C,IAAI/C,MAAJ;;EACA,IAAI;IACFA,MAAM,GAAGgD,OAAO,CAAC,QAAD,CAAhB;EACD,CAFD,CAEE,OAAOC,CAAP,EAAU;IACV;IACA,MAAM;MAAEjD,MAAM,EAAEkD;IAAV,IAA2BF,OAAO,CAAC,eAAD,CAAxC;;IACAhD,MAAM,GAAGkD,YAAT;EACD;;EAEDF,OAAO,CAAC,cAAD,CAAP;;EACA3B,SAAS,GAAGqB,IAAI,CAACS,KAAL,CAAW,OAAOzE,MAAM,CAACC,GAAzB,CAAZ;EAEAD,MAAM,GAAG,EACP,GAAGA,MADI;IAEP,GAAGqE;EAFI,CAAT;EAKA/C,MAAM,CAACoD,MAAP,CAAc;IACZC,mBAAmB,CAAClE,QAAD,EAAWsB,aAAX,EAAuC;MAAA,IAAb/B,MAAa,uEAAJ,EAAI;MACxD,OAAO8B,YAAY,CAACrB,QAAD,EAAWsB,aAAX,EAA0B/B,MAA1B,CAAnB;IACD;;EAHW,CAAd;AAKD,CAvBM;;;;AAyBA,MAAM4E,gBAAgB,GAAInE,QAAD,IAAc;EAC5C,OAAOD,eAAe,CAACC,QAAD,CAAtB;AACD,CAFM"}
|
|
1
|
+
{"version":3,"names":["config","fps","isAnimatedStyle","style","animatedStyle","getAnimatedStyleFromObject","current","value","getCurrentStyle","received","styleObject","props","currentStyle","Array","isArray","forEach","checkEqual","expectStyle","length","i","property","findStyleDiff","expect","requireAllMatch","diffs","isEqual","push","Object","keys","undefined","compareStyle","expectedStyle","message","pass","exact","currentStyleStr","JSON","stringify","expectedStyleStr","differences","map","diff","join","frameTime","requestAnimationFrameCopy","currentTimestamp","requestAnimationFrame","callback","setTimeout","beforeTest","jestResetJsReanimatedModule","global","ReanimatedDataMock","now","jest","useFakeTimers","afterTest","useRealTimers","tickTravel","advanceTimersByTime","withReanimatedTimer","animationTest","advanceAnimationByTime","time","Math","ceil","advanceAnimationByFrame","count","setUpTests","userConfig","expectModule","require","jestGlobals","extend","default","round","toHaveAnimatedStyle","getAnimatedStyle"],"sources":["jestUtils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nimport { jestResetJsReanimatedModule } from './core';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R> {\n toHaveAnimatedStyle(\n style: Record<string, unknown>[] | Record<string, unknown>\n ): R;\n }\n }\n}\n\nlet config = {\n fps: 60,\n};\n\nconst isAnimatedStyle = (style) => {\n return !!style.animatedStyle;\n};\n\nconst getAnimatedStyleFromObject = (style) => {\n return style.animatedStyle.current.value;\n};\n\nconst getCurrentStyle = (received) => {\n const styleObject = received.props.style;\n let currentStyle = {};\n if (Array.isArray(styleObject)) {\n received.props.style.forEach((style) => {\n if (isAnimatedStyle(style)) {\n currentStyle = {\n ...currentStyle,\n ...getAnimatedStyleFromObject(style),\n };\n } else {\n currentStyle = {\n ...currentStyle,\n ...style,\n };\n }\n });\n } else {\n if (isAnimatedStyle(styleObject)) {\n currentStyle = getAnimatedStyleFromObject(styleObject);\n } else {\n currentStyle = {\n ...styleObject,\n ...received.props.animatedStyle.value,\n };\n }\n }\n return currentStyle;\n};\n\nconst checkEqual = (currentStyle, expectStyle) => {\n if (Array.isArray(expectStyle)) {\n if (expectStyle.length !== currentStyle.length) return false;\n for (let i = 0; i < currentStyle.length; i++) {\n if (!checkEqual(currentStyle[i], expectStyle[i])) {\n return false;\n }\n }\n } else if (typeof currentStyle === 'object' && currentStyle) {\n for (const property in expectStyle) {\n if (!checkEqual(currentStyle[property], expectStyle[property])) {\n return false;\n }\n }\n } else {\n return currentStyle === expectStyle;\n }\n return true;\n};\n\nconst findStyleDiff = (current, expect, requireAllMatch) => {\n const diffs = [];\n let isEqual = true;\n for (const property in expect) {\n if (!checkEqual(current[property], expect[property])) {\n isEqual = false;\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n\n if (\n requireAllMatch &&\n Object.keys(current).length !== Object.keys(expect).length\n ) {\n isEqual = false;\n for (const property in current) {\n if (expect[property] === undefined) {\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n }\n\n return { isEqual, diffs };\n};\n\nconst compareStyle = (received, expectedStyle, config) => {\n if (!received.props.style) {\n return { message: () => message, pass: false };\n }\n const { exact } = config;\n const currentStyle = getCurrentStyle(received);\n const { isEqual, diffs } = findStyleDiff(currentStyle, expectedStyle, exact);\n\n if (isEqual) {\n return { message: () => 'ok', pass: true };\n }\n\n const currentStyleStr = JSON.stringify(currentStyle);\n const expectedStyleStr = JSON.stringify(expectedStyle);\n const differences = diffs\n .map(\n (diff) =>\n `- '${diff.property}' should be ${JSON.stringify(\n diff.expect\n )}, but is ${JSON.stringify(diff.current)}`\n )\n .join('\\n');\n\n return {\n message: () =>\n `Expected: ${expectedStyleStr}\\nReceived: ${currentStyleStr}\\n\\nDifferences:\\n${differences}`,\n pass: false,\n };\n};\n\nlet frameTime = 1000 / config.fps;\nlet requestAnimationFrameCopy;\nlet currentTimestamp = 0;\n\nconst requestAnimationFrame = (callback) => {\n setTimeout(callback, frameTime);\n};\n\nconst beforeTest = () => {\n jestResetJsReanimatedModule();\n requestAnimationFrameCopy = global.requestAnimationFrame;\n global.requestAnimationFrame = requestAnimationFrame;\n global.ReanimatedDataMock = {\n now: () => currentTimestamp,\n };\n currentTimestamp = 0;\n jest.useFakeTimers();\n};\n\nconst afterTest = () => {\n jest.useRealTimers();\n global.requestAnimationFrame = requestAnimationFrameCopy;\n};\n\nconst tickTravel = () => {\n currentTimestamp += frameTime;\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const withReanimatedTimer = (animationTest) => {\n beforeTest();\n animationTest();\n afterTest();\n};\n\nexport const advanceAnimationByTime = (time = frameTime) => {\n for (let i = 0; i <= Math.ceil(time / frameTime); i++) {\n tickTravel();\n }\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const advanceAnimationByFrame = (count) => {\n for (let i = 0; i <= count; i++) {\n tickTravel();\n }\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const setUpTests = (userConfig = {}) => {\n let expect = global.expect;\n if (expect === undefined) {\n const expectModule = require('expect');\n expect = expectModule;\n // Starting from Jest 28, \"expect\" package uses named exports instead of default export.\n // So, requiring \"expect\" package doesn't give direct access to \"expect\" function anymore.\n // It gives access to the module object instead.\n // We use this info to detect if the project uses Jest 28 or higher.\n if (typeof expect === 'object') {\n const jestGlobals = require('@jest/globals');\n expect = jestGlobals.expect;\n }\n if (expect === undefined || expect.extend === undefined) {\n expect = expectModule.default;\n }\n }\n\n require('setimmediate');\n frameTime = Math.round(1000 / config.fps);\n\n config = {\n ...config,\n ...userConfig,\n };\n\n expect.extend({\n toHaveAnimatedStyle(received, expectedStyle, config = {}) {\n return compareStyle(received, expectedStyle, config);\n },\n });\n};\n\nexport const getAnimatedStyle = (received) => {\n return getCurrentStyle(received);\n};\n"],"mappings":";;;;;;;AAEA;;AAFA;AACA;AAcA,IAAIA,MAAM,GAAG;EACXC,GAAG,EAAE;AADM,CAAb;;AAIA,MAAMC,eAAe,GAAIC,KAAD,IAAW;EACjC,OAAO,CAAC,CAACA,KAAK,CAACC,aAAf;AACD,CAFD;;AAIA,MAAMC,0BAA0B,GAAIF,KAAD,IAAW;EAC5C,OAAOA,KAAK,CAACC,aAAN,CAAoBE,OAApB,CAA4BC,KAAnC;AACD,CAFD;;AAIA,MAAMC,eAAe,GAAIC,QAAD,IAAc;EACpC,MAAMC,WAAW,GAAGD,QAAQ,CAACE,KAAT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f,EAA0B;IACxB,MAAMyC,YAAY,GAAGC,OAAO,CAAC,QAAD,CAA5B;;IACAjD,MAAM,GAAGgD,YAAT,CAFwB,CAGxB;IACA;IACA;IACA;;IACA,IAAI,OAAOhD,MAAP,KAAkB,QAAtB,EAAgC;MAC9B,MAAMkD,WAAW,GAAGD,OAAO,CAAC,eAAD,CAA3B;;MACAjD,MAAM,GAAGkD,WAAW,CAAClD,MAArB;IACD;;IACD,IAAIA,MAAM,KAAKO,SAAX,IAAwBP,MAAM,CAACmD,MAAP,KAAkB5C,SAA9C,EAAyD;MACvDP,MAAM,GAAGgD,YAAY,CAACI,OAAtB;IACD;EACF;;EAEDH,OAAO,CAAC,cAAD,CAAP;;EACA5B,SAAS,GAAGqB,IAAI,CAACW,KAAL,CAAW,OAAO3E,MAAM,CAACC,GAAzB,CAAZ;EAEAD,MAAM,GAAG,EACP,GAAGA,MADI;IAEP,GAAGqE;EAFI,CAAT;EAKA/C,MAAM,CAACmD,MAAP,CAAc;IACZG,mBAAmB,CAACnE,QAAD,EAAWsB,aAAX,EAAuC;MAAA,IAAb/B,MAAa,uEAAJ,EAAI;MACxD,OAAO8B,YAAY,CAACrB,QAAD,EAAWsB,aAAX,EAA0B/B,MAA1B,CAAnB;IACD;;EAHW,CAAd;AAKD,CA/BM;;;;AAiCA,MAAM6E,gBAAgB,GAAIpE,QAAD,IAAc;EAC5C,OAAOD,eAAe,CAACC,QAAD,CAAtB;AACD,CAFM"}
|
|
@@ -184,17 +184,25 @@ export const advanceAnimationByFrame = count => {
|
|
|
184
184
|
};
|
|
185
185
|
export const setUpTests = function () {
|
|
186
186
|
let userConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
187
|
-
let expect;
|
|
187
|
+
let expect = global.expect;
|
|
188
188
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
} catch (_) {
|
|
192
|
-
// for Jest in version 28+
|
|
193
|
-
const {
|
|
194
|
-
expect: expectModule
|
|
195
|
-
} = require('@jest/globals');
|
|
189
|
+
if (expect === undefined) {
|
|
190
|
+
const expectModule = require('expect');
|
|
196
191
|
|
|
197
|
-
expect = expectModule;
|
|
192
|
+
expect = expectModule; // Starting from Jest 28, "expect" package uses named exports instead of default export.
|
|
193
|
+
// So, requiring "expect" package doesn't give direct access to "expect" function anymore.
|
|
194
|
+
// It gives access to the module object instead.
|
|
195
|
+
// We use this info to detect if the project uses Jest 28 or higher.
|
|
196
|
+
|
|
197
|
+
if (typeof expect === 'object') {
|
|
198
|
+
const jestGlobals = require('@jest/globals');
|
|
199
|
+
|
|
200
|
+
expect = jestGlobals.expect;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (expect === undefined || expect.extend === undefined) {
|
|
204
|
+
expect = expectModule.default;
|
|
205
|
+
}
|
|
198
206
|
}
|
|
199
207
|
|
|
200
208
|
require('setimmediate');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["jestResetJsReanimatedModule","config","fps","isAnimatedStyle","style","animatedStyle","getAnimatedStyleFromObject","current","value","getCurrentStyle","received","styleObject","props","currentStyle","Array","isArray","forEach","checkEqual","expectStyle","length","i","property","findStyleDiff","expect","requireAllMatch","diffs","isEqual","push","Object","keys","undefined","compareStyle","expectedStyle","message","pass","exact","currentStyleStr","JSON","stringify","expectedStyleStr","differences","map","diff","join","frameTime","requestAnimationFrameCopy","currentTimestamp","requestAnimationFrame","callback","setTimeout","beforeTest","global","ReanimatedDataMock","now","jest","useFakeTimers","afterTest","useRealTimers","tickTravel","advanceTimersByTime","withReanimatedTimer","animationTest","advanceAnimationByTime","time","Math","ceil","advanceAnimationByFrame","count","setUpTests","userConfig","require","_","expectModule","round","extend","toHaveAnimatedStyle","getAnimatedStyle"],"sources":["jestUtils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nimport { jestResetJsReanimatedModule } from './core';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R> {\n toHaveAnimatedStyle(\n style: Record<string, unknown>[] | Record<string, unknown>\n ): R;\n }\n }\n}\n\nlet config = {\n fps: 60,\n};\n\nconst isAnimatedStyle = (style) => {\n return !!style.animatedStyle;\n};\n\nconst getAnimatedStyleFromObject = (style) => {\n return style.animatedStyle.current.value;\n};\n\nconst getCurrentStyle = (received) => {\n const styleObject = received.props.style;\n let currentStyle = {};\n if (Array.isArray(styleObject)) {\n received.props.style.forEach((style) => {\n if (isAnimatedStyle(style)) {\n currentStyle = {\n ...currentStyle,\n ...getAnimatedStyleFromObject(style),\n };\n } else {\n currentStyle = {\n ...currentStyle,\n ...style,\n };\n }\n });\n } else {\n if (isAnimatedStyle(styleObject)) {\n currentStyle = getAnimatedStyleFromObject(styleObject);\n } else {\n currentStyle = {\n ...styleObject,\n ...received.props.animatedStyle.value,\n };\n }\n }\n return currentStyle;\n};\n\nconst checkEqual = (currentStyle, expectStyle) => {\n if (Array.isArray(expectStyle)) {\n if (expectStyle.length !== currentStyle.length) return false;\n for (let i = 0; i < currentStyle.length; i++) {\n if (!checkEqual(currentStyle[i], expectStyle[i])) {\n return false;\n }\n }\n } else if (typeof currentStyle === 'object' && currentStyle) {\n for (const property in expectStyle) {\n if (!checkEqual(currentStyle[property], expectStyle[property])) {\n return false;\n }\n }\n } else {\n return currentStyle === expectStyle;\n }\n return true;\n};\n\nconst findStyleDiff = (current, expect, requireAllMatch) => {\n const diffs = [];\n let isEqual = true;\n for (const property in expect) {\n if (!checkEqual(current[property], expect[property])) {\n isEqual = false;\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n\n if (\n requireAllMatch &&\n Object.keys(current).length !== Object.keys(expect).length\n ) {\n isEqual = false;\n for (const property in current) {\n if (expect[property] === undefined) {\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n }\n\n return { isEqual, diffs };\n};\n\nconst compareStyle = (received, expectedStyle, config) => {\n if (!received.props.style) {\n return { message: () => message, pass: false };\n }\n const { exact } = config;\n const currentStyle = getCurrentStyle(received);\n const { isEqual, diffs } = findStyleDiff(currentStyle, expectedStyle, exact);\n\n if (isEqual) {\n return { message: () => 'ok', pass: true };\n }\n\n const currentStyleStr = JSON.stringify(currentStyle);\n const expectedStyleStr = JSON.stringify(expectedStyle);\n const differences = diffs\n .map(\n (diff) =>\n `- '${diff.property}' should be ${JSON.stringify(\n diff.expect\n )}, but is ${JSON.stringify(diff.current)}`\n )\n .join('\\n');\n\n return {\n message: () =>\n `Expected: ${expectedStyleStr}\\nReceived: ${currentStyleStr}\\n\\nDifferences:\\n${differences}`,\n pass: false,\n };\n};\n\nlet frameTime = 1000 / config.fps;\nlet requestAnimationFrameCopy;\nlet currentTimestamp = 0;\n\nconst requestAnimationFrame = (callback) => {\n setTimeout(callback, frameTime);\n};\n\nconst beforeTest = () => {\n jestResetJsReanimatedModule();\n requestAnimationFrameCopy = global.requestAnimationFrame;\n global.requestAnimationFrame = requestAnimationFrame;\n global.ReanimatedDataMock = {\n now: () => currentTimestamp,\n };\n currentTimestamp = 0;\n jest.useFakeTimers();\n};\n\nconst afterTest = () => {\n jest.useRealTimers();\n global.requestAnimationFrame = requestAnimationFrameCopy;\n};\n\nconst tickTravel = () => {\n currentTimestamp += frameTime;\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const withReanimatedTimer = (animationTest) => {\n beforeTest();\n animationTest();\n afterTest();\n};\n\nexport const advanceAnimationByTime = (time = frameTime) => {\n for (let i = 0; i <= Math.ceil(time / frameTime); i++) {\n tickTravel();\n }\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const advanceAnimationByFrame = (count) => {\n for (let i = 0; i <= count; i++) {\n tickTravel();\n }\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const setUpTests = (userConfig = {}) => {\n let expect;\n try {\n expect = require('expect');\n } catch (_) {\n // for Jest in version 28+\n const { expect: expectModule } = require('@jest/globals');\n expect = expectModule;\n }\n\n require('setimmediate');\n frameTime = Math.round(1000 / config.fps);\n\n config = {\n ...config,\n ...userConfig,\n };\n\n expect.extend({\n toHaveAnimatedStyle(received, expectedStyle, config = {}) {\n return compareStyle(received, expectedStyle, config);\n },\n });\n};\n\nexport const getAnimatedStyle = (received) => {\n return getCurrentStyle(received);\n};\n"],"mappings":"AAAA;AACA;AACA,SAASA,2BAAT,QAA4C,QAA5C;AAaA,IAAIC,MAAM,GAAG;EACXC,GAAG,EAAE;AADM,CAAb;;AAIA,MAAMC,eAAe,GAAIC,KAAD,IAAW;EACjC,OAAO,CAAC,CAACA,KAAK,CAACC,aAAf;AACD,CAFD;;AAIA,MAAMC,0BAA0B,GAAIF,KAAD,IAAW;EAC5C,OAAOA,KAAK,CAACC,aAAN,CAAoBE,OAApB,CAA4BC,KAAnC;AACD,CAFD;;AAIA,MAAMC,eAAe,GAAIC,QAAD,IAAc;EACpC,MAAMC,WAAW,GAAGD,QAAQ,CAACE,KAAT,CAAeR,KAAnC;EACA,IAAIS,YAAY,GAAG,EAAnB;;EACA,IAAIC,KAAK,CAACC,OAAN,CAAcJ,WAAd,CAAJ,EAAgC;IAC9BD,QAAQ,CAACE,KAAT,CAAeR,KAAf,CAAqBY,OAArB,CAA8BZ,KAAD,IAAW;MACtC,IAAID,eAAe,CAACC,KAAD,CAAnB,EAA4B;QAC1BS,YAAY,GAAG,EACb,GAAGA,YADU;UAEb,GAAGP,0BAA0B,CAACF,KAAD;QAFhB,CAAf;MAID,CALD,MAKO;QACLS,YAAY,GAAG,EACb,GAAGA,YADU;UAEb,GAAGT;QAFU,CAAf;MAID;IACF,CAZD;EAaD,CAdD,MAcO;IACL,IAAID,eAAe,CAACQ,WAAD,CAAnB,EAAkC;MAChCE,YAAY,GAAGP,0BAA0B,CAACK,WAAD,CAAzC;IACD,CAFD,MAEO;MACLE,YAAY,GAAG,EACb,GAAGF,WADU;QAEb,GAAGD,QAAQ,CAACE,KAAT,CAAeP,aAAf,CAA6BG;MAFnB,CAAf;IAID;EACF;;EACD,OAAOK,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AFM"}
|
|
1
|
+
{"version":3,"names":["jestResetJsReanimatedModule","config","fps","isAnimatedStyle","style","animatedStyle","getAnimatedStyleFromObject","current","value","getCurrentStyle","received","styleObject","props","currentStyle","Array","isArray","forEach","checkEqual","expectStyle","length","i","property","findStyleDiff","expect","requireAllMatch","diffs","isEqual","push","Object","keys","undefined","compareStyle","expectedStyle","message","pass","exact","currentStyleStr","JSON","stringify","expectedStyleStr","differences","map","diff","join","frameTime","requestAnimationFrameCopy","currentTimestamp","requestAnimationFrame","callback","setTimeout","beforeTest","global","ReanimatedDataMock","now","jest","useFakeTimers","afterTest","useRealTimers","tickTravel","advanceTimersByTime","withReanimatedTimer","animationTest","advanceAnimationByTime","time","Math","ceil","advanceAnimationByFrame","count","setUpTests","userConfig","expectModule","require","jestGlobals","extend","default","round","toHaveAnimatedStyle","getAnimatedStyle"],"sources":["jestUtils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nimport { jestResetJsReanimatedModule } from './core';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R> {\n toHaveAnimatedStyle(\n style: Record<string, unknown>[] | Record<string, unknown>\n ): R;\n }\n }\n}\n\nlet config = {\n fps: 60,\n};\n\nconst isAnimatedStyle = (style) => {\n return !!style.animatedStyle;\n};\n\nconst getAnimatedStyleFromObject = (style) => {\n return style.animatedStyle.current.value;\n};\n\nconst getCurrentStyle = (received) => {\n const styleObject = received.props.style;\n let currentStyle = {};\n if (Array.isArray(styleObject)) {\n received.props.style.forEach((style) => {\n if (isAnimatedStyle(style)) {\n currentStyle = {\n ...currentStyle,\n ...getAnimatedStyleFromObject(style),\n };\n } else {\n currentStyle = {\n ...currentStyle,\n ...style,\n };\n }\n });\n } else {\n if (isAnimatedStyle(styleObject)) {\n currentStyle = getAnimatedStyleFromObject(styleObject);\n } else {\n currentStyle = {\n ...styleObject,\n ...received.props.animatedStyle.value,\n };\n }\n }\n return currentStyle;\n};\n\nconst checkEqual = (currentStyle, expectStyle) => {\n if (Array.isArray(expectStyle)) {\n if (expectStyle.length !== currentStyle.length) return false;\n for (let i = 0; i < currentStyle.length; i++) {\n if (!checkEqual(currentStyle[i], expectStyle[i])) {\n return false;\n }\n }\n } else if (typeof currentStyle === 'object' && currentStyle) {\n for (const property in expectStyle) {\n if (!checkEqual(currentStyle[property], expectStyle[property])) {\n return false;\n }\n }\n } else {\n return currentStyle === expectStyle;\n }\n return true;\n};\n\nconst findStyleDiff = (current, expect, requireAllMatch) => {\n const diffs = [];\n let isEqual = true;\n for (const property in expect) {\n if (!checkEqual(current[property], expect[property])) {\n isEqual = false;\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n\n if (\n requireAllMatch &&\n Object.keys(current).length !== Object.keys(expect).length\n ) {\n isEqual = false;\n for (const property in current) {\n if (expect[property] === undefined) {\n diffs.push({\n property: property,\n current: current[property],\n expect: expect[property],\n });\n }\n }\n }\n\n return { isEqual, diffs };\n};\n\nconst compareStyle = (received, expectedStyle, config) => {\n if (!received.props.style) {\n return { message: () => message, pass: false };\n }\n const { exact } = config;\n const currentStyle = getCurrentStyle(received);\n const { isEqual, diffs } = findStyleDiff(currentStyle, expectedStyle, exact);\n\n if (isEqual) {\n return { message: () => 'ok', pass: true };\n }\n\n const currentStyleStr = JSON.stringify(currentStyle);\n const expectedStyleStr = JSON.stringify(expectedStyle);\n const differences = diffs\n .map(\n (diff) =>\n `- '${diff.property}' should be ${JSON.stringify(\n diff.expect\n )}, but is ${JSON.stringify(diff.current)}`\n )\n .join('\\n');\n\n return {\n message: () =>\n `Expected: ${expectedStyleStr}\\nReceived: ${currentStyleStr}\\n\\nDifferences:\\n${differences}`,\n pass: false,\n };\n};\n\nlet frameTime = 1000 / config.fps;\nlet requestAnimationFrameCopy;\nlet currentTimestamp = 0;\n\nconst requestAnimationFrame = (callback) => {\n setTimeout(callback, frameTime);\n};\n\nconst beforeTest = () => {\n jestResetJsReanimatedModule();\n requestAnimationFrameCopy = global.requestAnimationFrame;\n global.requestAnimationFrame = requestAnimationFrame;\n global.ReanimatedDataMock = {\n now: () => currentTimestamp,\n };\n currentTimestamp = 0;\n jest.useFakeTimers();\n};\n\nconst afterTest = () => {\n jest.useRealTimers();\n global.requestAnimationFrame = requestAnimationFrameCopy;\n};\n\nconst tickTravel = () => {\n currentTimestamp += frameTime;\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const withReanimatedTimer = (animationTest) => {\n beforeTest();\n animationTest();\n afterTest();\n};\n\nexport const advanceAnimationByTime = (time = frameTime) => {\n for (let i = 0; i <= Math.ceil(time / frameTime); i++) {\n tickTravel();\n }\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const advanceAnimationByFrame = (count) => {\n for (let i = 0; i <= count; i++) {\n tickTravel();\n }\n jest.advanceTimersByTime(frameTime);\n};\n\nexport const setUpTests = (userConfig = {}) => {\n let expect = global.expect;\n if (expect === undefined) {\n const expectModule = require('expect');\n expect = expectModule;\n // Starting from Jest 28, \"expect\" package uses named exports instead of default export.\n // So, requiring \"expect\" package doesn't give direct access to \"expect\" function anymore.\n // It gives access to the module object instead.\n // We use this info to detect if the project uses Jest 28 or higher.\n if (typeof expect === 'object') {\n const jestGlobals = require('@jest/globals');\n expect = jestGlobals.expect;\n }\n if (expect === undefined || expect.extend === undefined) {\n expect = expectModule.default;\n }\n }\n\n require('setimmediate');\n frameTime = Math.round(1000 / config.fps);\n\n config = {\n ...config,\n ...userConfig,\n };\n\n expect.extend({\n toHaveAnimatedStyle(received, expectedStyle, config = {}) {\n return compareStyle(received, expectedStyle, config);\n },\n });\n};\n\nexport const getAnimatedStyle = (received) => {\n return getCurrentStyle(received);\n};\n"],"mappings":"AAAA;AACA;AACA,SAASA,2BAAT,QAA4C,QAA5C;AAaA,IAAIC,MAAM,GAAG;EACXC,GAAG,EAAE;AADM,CAAb;;AAIA,MAAMC,eAAe,GAAIC,KAAD,IAAW;EACjC,OAAO,CAAC,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animated",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.5",
|
|
4
4
|
"description": "More powerful alternative to Animated library for React Native.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "yarn run format:js && yarn run lint:js && yarn run test:unit",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"madge": "^5.0.1",
|
|
124
124
|
"prettier": "^2.5.1",
|
|
125
125
|
"react": "17.0.2",
|
|
126
|
-
"react-native": "0.70.
|
|
126
|
+
"react-native": "0.70.5",
|
|
127
127
|
"react-native-builder-bob": "^0.18.3",
|
|
128
128
|
"react-native-codegen": "^0.0.7",
|
|
129
129
|
"react-native-gesture-handler": "^2.4.2",
|
|
@@ -188,13 +188,21 @@ export const advanceAnimationByFrame = (count) => {
|
|
|
188
188
|
};
|
|
189
189
|
|
|
190
190
|
export const setUpTests = (userConfig = {}) => {
|
|
191
|
-
let expect;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
} catch (_) {
|
|
195
|
-
// for Jest in version 28+
|
|
196
|
-
const { expect: expectModule } = require('@jest/globals');
|
|
191
|
+
let expect = global.expect;
|
|
192
|
+
if (expect === undefined) {
|
|
193
|
+
const expectModule = require('expect');
|
|
197
194
|
expect = expectModule;
|
|
195
|
+
// Starting from Jest 28, "expect" package uses named exports instead of default export.
|
|
196
|
+
// So, requiring "expect" package doesn't give direct access to "expect" function anymore.
|
|
197
|
+
// It gives access to the module object instead.
|
|
198
|
+
// We use this info to detect if the project uses Jest 28 or higher.
|
|
199
|
+
if (typeof expect === 'object') {
|
|
200
|
+
const jestGlobals = require('@jest/globals');
|
|
201
|
+
expect = jestGlobals.expect;
|
|
202
|
+
}
|
|
203
|
+
if (expect === undefined || expect.extend === undefined) {
|
|
204
|
+
expect = expectModule.default;
|
|
205
|
+
}
|
|
198
206
|
}
|
|
199
207
|
|
|
200
208
|
require('setimmediate');
|