Skip to content

Commit

Permalink
Merge pull request #18 from wordpress-mobile/wp-fork-2.9.1
Browse files Browse the repository at this point in the history
Update wp-fork to version `2.9.1`
  • Loading branch information
Gerardo Pacheco authored Oct 11, 2022
2 parents 0f902a0 + 2193fe1 commit edab86e
Show file tree
Hide file tree
Showing 496 changed files with 24,205 additions and 5,936 deletions.
7 changes: 3 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ module.exports = {
'standard',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/flowtype',
'prettier/react',
'prettier/standard',
'plugin:import/typescript',
],
plugins: ['react', 'react-native', 'import', 'jest', '@typescript-eslint'],
Expand All @@ -17,7 +14,9 @@ module.exports = {
},
settings: {
'import/resolver': {
'babel-module': {},
'babel-module': {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
rules: {
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: '11'
- name: Install NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r21d
- name: Set ANDROID_NDK
run: echo "ANDROID_NDK=$ANDROID_HOME/ndk-bundle" >> $GITHUB_ENV
- name: Accept licenses
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-npm-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
- name: Check out
uses: actions/checkout@v1

- name: Set up JDK 1.8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: '11'

- name: Install NDK
uses: nttld/setup-ndk@v1
Expand All @@ -38,7 +38,7 @@ jobs:
path: '*.tgz'

- name: Compress Android build output
run: zip -r android-build-output.zip android/build/
run: zip -r android-build-output.zip build_output

- name: Upload Android build folder
uses: actions/upload-artifact@v2
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/tv-os-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Test tvOS build
on:
pull_request:
branches:
- main
paths:
- 'ios/**'
- 'Common/**'
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: macos-latest
env:
WORKING_DIRECTORY: TVOSExample
concurrency:
group: ios-tv-${{ github.ref }}
cancel-in-progress: true
steps:
- name: checkout
uses: actions/checkout@v2
- name: Use Node.js 14
uses: actions/setup-node@v2
with:
node-version: 14
cache: 'yarn'
cache-dependency-path: 'TVOSExample/yarn.lock'
- name: Install Reanimated node dependencies
run: yarn
- name: Install node dependencies
working-directory: ${{ env.WORKING_DIRECTORY }}
run: yarn
- name: Install pods
working-directory: ${{ env.WORKING_DIRECTORY }}/ios
run: pod install
- name: Build app
working-directory: ${{ env.WORKING_DIRECTORY }}
run: yarn tv-os
2 changes: 1 addition & 1 deletion .github/workflows/validate-java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches:
- main
paths:
- 'android/src/java**'
- 'android/src/main/java/**'
push:
branches:
- main
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ lib/
react-native-reanimated-tests.js

# eclipse
*.settings**
*.settings**
FabricExample
72 changes: 72 additions & 0 deletions Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include "AnimatedSensorModule.h"
#include "MutableValue.h"
#include "ValueWrapper.h"

namespace reanimated {

AnimatedSensorModule::AnimatedSensorModule(
const PlatformDepMethodsHolder &platformDepMethodsHolder,
RuntimeManager *runtimeManager)
: platformRegisterSensorFunction_(platformDepMethodsHolder.registerSensor),
platformUnregisterSensorFunction_(
platformDepMethodsHolder.unregisterSensor),
runtimeManager_(runtimeManager) {}

AnimatedSensorModule::~AnimatedSensorModule() {
// It is called during app reload because app reload doesn't call hooks
// unmounting
for (auto sensorId : sensorsIds_) {
platformUnregisterSensorFunction_(sensorId);
}
}

jsi::Value AnimatedSensorModule::registerSensor(
jsi::Runtime &rt,
const jsi::Value &sensorType,
const jsi::Value &interval,
const jsi::Value &sensorDataContainer) {
std::shared_ptr<ShareableValue> sensorsData = ShareableValue::adapt(
rt, sensorDataContainer.getObject(rt), runtimeManager_);
auto &mutableObject =
ValueWrapper::asMutableValue(sensorsData->valueContainer);

std::function<void(double[])> setter;
if (sensorType.asNumber() == SensorType::ROTATION_VECTOR) {
setter = [&, mutableObject](double newValues[]) {
jsi::Runtime &runtime = *runtimeManager_->runtime.get();
jsi::Object value(runtime);
value.setProperty(runtime, "qw", newValues[0]);
value.setProperty(runtime, "qx", newValues[1]);
value.setProperty(runtime, "qy", newValues[2]);
value.setProperty(runtime, "qz", newValues[3]);
value.setProperty(runtime, "yaw", newValues[4]);
value.setProperty(runtime, "pitch", newValues[5]);
value.setProperty(runtime, "roll", newValues[6]);
mutableObject->setValue(runtime, std::move(value));
};
} else {
setter = [&, mutableObject](double newValues[]) {
jsi::Runtime &runtime = *runtimeManager_->runtime.get();
jsi::Object value(runtime);
value.setProperty(runtime, "x", newValues[0]);
value.setProperty(runtime, "y", newValues[1]);
value.setProperty(runtime, "z", newValues[2]);
mutableObject->setValue(runtime, std::move(value));
};
}

int sensorId = platformRegisterSensorFunction_(
sensorType.asNumber(), interval.asNumber(), setter);
if (sensorId != -1) {
sensorsIds_.insert(sensorId);
}
return jsi::Value(sensorId);
}

void AnimatedSensorModule::unregisterSensor(const jsi::Value &sensorId) {
// It is called during sensor hook unmounting
sensorsIds_.erase(sensorId.getNumber());
platformUnregisterSensorFunction_(sensorId.asNumber());
}

} // namespace reanimated
31 changes: 30 additions & 1 deletion Common/cpp/NativeModules/NativeReanimatedModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "JSIStoreValueUser.h"
#include "Mapper.h"
#include "MapperRegistry.h"
#include "MutableValue.h"
#include "ReanimatedHiddenHeaders.h"
#include "RuntimeDecorator.h"
#include "ShareableValue.h"
Expand Down Expand Up @@ -70,7 +71,10 @@ NativeReanimatedModule::NativeReanimatedModule(
mapperRegistry(std::make_shared<MapperRegistry>()),
eventHandlerRegistry(std::make_shared<EventHandlerRegistry>()),
requestRender(platformDepMethodsHolder.requestRender),
propObtainer(propObtainer) {
propObtainer(propObtainer),
animatedSensorModule(platformDepMethodsHolder, this),
configurePropsPlatformFunction(
platformDepMethodsHolder.configurePropsFunction) {
auto requestAnimationFrame = [=](FrameCallback callback) {
frameCallbacks.push_back(callback);
maybeRequestRender();
Expand All @@ -85,6 +89,8 @@ NativeReanimatedModule::NativeReanimatedModule(
platformDepMethodsHolder.scrollToFunction,
platformDepMethodsHolder.measuringFunction,
platformDepMethodsHolder.getCurrentTime,
platformDepMethodsHolder.registerSensor,
platformDepMethodsHolder.unregisterSensor,
platformDepMethodsHolder.setGestureStateFunction,
layoutAnimationsProxy);
onRenderCallback = [this](double timestampMs) {
Expand Down Expand Up @@ -243,6 +249,14 @@ jsi::Value NativeReanimatedModule::enableLayoutAnimations(
return jsi::Value::undefined();
}

jsi::Value NativeReanimatedModule::configureProps(
jsi::Runtime &rt,
const jsi::Value &uiProps,
const jsi::Value &nativeProps) {
configurePropsPlatformFunction(rt, uiProps, nativeProps);
return jsi::Value::undefined();
}

void NativeReanimatedModule::onEvent(
std::string eventName,
std::string eventAsString) {
Expand Down Expand Up @@ -298,4 +312,19 @@ void NativeReanimatedModule::onRender(double timestampMs) {
}
}

jsi::Value NativeReanimatedModule::registerSensor(
jsi::Runtime &rt,
const jsi::Value &sensorType,
const jsi::Value &interval,
const jsi::Value &sensorDataContainer) {
return animatedSensorModule.registerSensor(
rt, sensorType, interval, sensorDataContainer);
}

void NativeReanimatedModule::unregisterSensor(
jsi::Runtime &rt,
const jsi::Value &sensorId) {
animatedSensorModule.unregisterSensor(sensorId);
}

} // namespace reanimated
Loading

0 comments on commit edab86e

Please sign in to comment.