Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit c1e7a1b

Browse files
author
Gerardo Pacheco
authored
Merge pull request #17 from wordpress-mobile/upstream-2.9.1
Update `trunk` with upstream version `2.9.1`
2 parents 56b511a + 0b231b0 commit c1e7a1b

493 files changed

Lines changed: 24234 additions & 6087 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ module.exports = {
55
'standard',
66
'plugin:@typescript-eslint/recommended',
77
'prettier',
8-
'prettier/flowtype',
9-
'prettier/react',
10-
'prettier/standard',
118
'plugin:import/typescript',
129
],
1310
plugins: ['react', 'react-native', 'import', 'jest', '@typescript-eslint'],
@@ -17,7 +14,9 @@ module.exports = {
1714
},
1815
settings: {
1916
'import/resolver': {
20-
'babel-module': {},
17+
'babel-module': {
18+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
19+
},
2120
},
2221
},
2322
rules: {

.github/workflows/android-build.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ jobs:
2020
steps:
2121
- name: checkout
2222
uses: actions/checkout@v2
23+
- name: Set up JDK 11
24+
uses: actions/setup-java@v1
25+
with:
26+
java-version: '11'
27+
- name: Install NDK
28+
uses: nttld/setup-ndk@v1
29+
id: setup-ndk
30+
with:
31+
ndk-version: r21d
2332
- name: Set ANDROID_NDK
2433
run: echo "ANDROID_NDK=$ANDROID_HOME/ndk-bundle" >> $GITHUB_ENV
2534
- name: Accept licenses

.github/workflows/build-npm-package.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
- name: Check out
1313
uses: actions/checkout@v1
1414

15-
- name: Set up JDK 1.8
15+
- name: Set up JDK 11
1616
uses: actions/setup-java@v1
1717
with:
18-
java-version: 1.8
18+
java-version: '11'
1919

2020
- name: Install NDK
2121
uses: nttld/setup-ndk@v1
@@ -38,7 +38,7 @@ jobs:
3838
path: '*.tgz'
3939

4040
- name: Compress Android build output
41-
run: zip -r android-build-output.zip android/build/
41+
run: zip -r android-build-output.zip build_output
4242

4343
- name: Upload Android build folder
4444
uses: actions/upload-artifact@v2

.github/workflows/tv-os-build.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Test tvOS build
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
paths:
7+
- 'ios/**'
8+
- 'Common/**'
9+
push:
10+
branches:
11+
- main
12+
workflow_dispatch:
13+
jobs:
14+
build:
15+
runs-on: macos-latest
16+
env:
17+
WORKING_DIRECTORY: TVOSExample
18+
concurrency:
19+
group: ios-tv-${{ github.ref }}
20+
cancel-in-progress: true
21+
steps:
22+
- name: checkout
23+
uses: actions/checkout@v2
24+
- name: Use Node.js 14
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: 14
28+
cache: 'yarn'
29+
cache-dependency-path: 'TVOSExample/yarn.lock'
30+
- name: Install Reanimated node dependencies
31+
run: yarn
32+
- name: Install node dependencies
33+
working-directory: ${{ env.WORKING_DIRECTORY }}
34+
run: yarn
35+
- name: Install pods
36+
working-directory: ${{ env.WORKING_DIRECTORY }}/ios
37+
run: pod install
38+
- name: Build app
39+
working-directory: ${{ env.WORKING_DIRECTORY }}
40+
run: yarn tv-os

.github/workflows/validate-java.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
branches:
55
- main
66
paths:
7-
- 'android/src/java**'
7+
- 'android/src/main/java/**'
88
push:
99
branches:
1010
- main

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ lib/
5656
react-native-reanimated-tests.js
5757

5858
# eclipse
59-
*.settings**
59+
*.settings**
60+
FabricExample
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#include "AnimatedSensorModule.h"
2+
#include "MutableValue.h"
3+
#include "ValueWrapper.h"
4+
5+
namespace reanimated {
6+
7+
AnimatedSensorModule::AnimatedSensorModule(
8+
const PlatformDepMethodsHolder &platformDepMethodsHolder,
9+
RuntimeManager *runtimeManager)
10+
: platformRegisterSensorFunction_(platformDepMethodsHolder.registerSensor),
11+
platformUnregisterSensorFunction_(
12+
platformDepMethodsHolder.unregisterSensor),
13+
runtimeManager_(runtimeManager) {}
14+
15+
AnimatedSensorModule::~AnimatedSensorModule() {
16+
// It is called during app reload because app reload doesn't call hooks
17+
// unmounting
18+
for (auto sensorId : sensorsIds_) {
19+
platformUnregisterSensorFunction_(sensorId);
20+
}
21+
}
22+
23+
jsi::Value AnimatedSensorModule::registerSensor(
24+
jsi::Runtime &rt,
25+
const jsi::Value &sensorType,
26+
const jsi::Value &interval,
27+
const jsi::Value &sensorDataContainer) {
28+
std::shared_ptr<ShareableValue> sensorsData = ShareableValue::adapt(
29+
rt, sensorDataContainer.getObject(rt), runtimeManager_);
30+
auto &mutableObject =
31+
ValueWrapper::asMutableValue(sensorsData->valueContainer);
32+
33+
std::function<void(double[])> setter;
34+
if (sensorType.asNumber() == SensorType::ROTATION_VECTOR) {
35+
setter = [&, mutableObject](double newValues[]) {
36+
jsi::Runtime &runtime = *runtimeManager_->runtime.get();
37+
jsi::Object value(runtime);
38+
value.setProperty(runtime, "qw", newValues[0]);
39+
value.setProperty(runtime, "qx", newValues[1]);
40+
value.setProperty(runtime, "qy", newValues[2]);
41+
value.setProperty(runtime, "qz", newValues[3]);
42+
value.setProperty(runtime, "yaw", newValues[4]);
43+
value.setProperty(runtime, "pitch", newValues[5]);
44+
value.setProperty(runtime, "roll", newValues[6]);
45+
mutableObject->setValue(runtime, std::move(value));
46+
};
47+
} else {
48+
setter = [&, mutableObject](double newValues[]) {
49+
jsi::Runtime &runtime = *runtimeManager_->runtime.get();
50+
jsi::Object value(runtime);
51+
value.setProperty(runtime, "x", newValues[0]);
52+
value.setProperty(runtime, "y", newValues[1]);
53+
value.setProperty(runtime, "z", newValues[2]);
54+
mutableObject->setValue(runtime, std::move(value));
55+
};
56+
}
57+
58+
int sensorId = platformRegisterSensorFunction_(
59+
sensorType.asNumber(), interval.asNumber(), setter);
60+
if (sensorId != -1) {
61+
sensorsIds_.insert(sensorId);
62+
}
63+
return jsi::Value(sensorId);
64+
}
65+
66+
void AnimatedSensorModule::unregisterSensor(const jsi::Value &sensorId) {
67+
// It is called during sensor hook unmounting
68+
sensorsIds_.erase(sensorId.getNumber());
69+
platformUnregisterSensorFunction_(sensorId.asNumber());
70+
}
71+
72+
} // namespace reanimated

Common/cpp/NativeModules/NativeReanimatedModule.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "JSIStoreValueUser.h"
99
#include "Mapper.h"
1010
#include "MapperRegistry.h"
11+
#include "MutableValue.h"
1112
#include "ReanimatedHiddenHeaders.h"
1213
#include "RuntimeDecorator.h"
1314
#include "ShareableValue.h"
@@ -70,7 +71,10 @@ NativeReanimatedModule::NativeReanimatedModule(
7071
mapperRegistry(std::make_shared<MapperRegistry>()),
7172
eventHandlerRegistry(std::make_shared<EventHandlerRegistry>()),
7273
requestRender(platformDepMethodsHolder.requestRender),
73-
propObtainer(propObtainer) {
74+
propObtainer(propObtainer),
75+
animatedSensorModule(platformDepMethodsHolder, this),
76+
configurePropsPlatformFunction(
77+
platformDepMethodsHolder.configurePropsFunction) {
7478
auto requestAnimationFrame = [=](FrameCallback callback) {
7579
frameCallbacks.push_back(callback);
7680
maybeRequestRender();
@@ -85,6 +89,8 @@ NativeReanimatedModule::NativeReanimatedModule(
8589
platformDepMethodsHolder.scrollToFunction,
8690
platformDepMethodsHolder.measuringFunction,
8791
platformDepMethodsHolder.getCurrentTime,
92+
platformDepMethodsHolder.registerSensor,
93+
platformDepMethodsHolder.unregisterSensor,
8894
platformDepMethodsHolder.setGestureStateFunction,
8995
layoutAnimationsProxy);
9096
onRenderCallback = [this](double timestampMs) {
@@ -243,6 +249,14 @@ jsi::Value NativeReanimatedModule::enableLayoutAnimations(
243249
return jsi::Value::undefined();
244250
}
245251

252+
jsi::Value NativeReanimatedModule::configureProps(
253+
jsi::Runtime &rt,
254+
const jsi::Value &uiProps,
255+
const jsi::Value &nativeProps) {
256+
configurePropsPlatformFunction(rt, uiProps, nativeProps);
257+
return jsi::Value::undefined();
258+
}
259+
246260
void NativeReanimatedModule::onEvent(
247261
std::string eventName,
248262
std::string eventAsString) {
@@ -298,4 +312,19 @@ void NativeReanimatedModule::onRender(double timestampMs) {
298312
}
299313
}
300314

315+
jsi::Value NativeReanimatedModule::registerSensor(
316+
jsi::Runtime &rt,
317+
const jsi::Value &sensorType,
318+
const jsi::Value &interval,
319+
const jsi::Value &sensorDataContainer) {
320+
return animatedSensorModule.registerSensor(
321+
rt, sensorType, interval, sensorDataContainer);
322+
}
323+
324+
void NativeReanimatedModule::unregisterSensor(
325+
jsi::Runtime &rt,
326+
const jsi::Value &sensorId) {
327+
animatedSensorModule.unregisterSensor(sensorId);
328+
}
329+
301330
} // namespace reanimated

0 commit comments

Comments
 (0)