Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update wp-fork to version 2.9.1 #18

Merged
merged 125 commits into from
Oct 11, 2022
Merged

Update wp-fork to version 2.9.1 #18

merged 125 commits into from
Oct 11, 2022

Conversation

geriux
Copy link

@geriux geriux commented Aug 11, 2022

Description

This PR updates the wp-fork branch with upstream version 2.9.1 and applies the required changes to publish the Android library associated with the package.

Since the PR contains a massive amount of changed files, in order to review this PR, it's better to compare the branch with the upstream repository and validate that we apply the same changes we have in wp-fork:

NOTE: Once this PR is ready, we should also merge #17 so the diff showed in wp-fork doesn't contain the 2.9.1 version changes.

Changes

Test code and steps to reproduce

Checklist

  • Included code example that can be used to test this change
  • Updated TS types
  • Added TS types tests
  • Added unit / integration tests
  • Updated documentation
  • Ensured that CI passes

kkafar and others added 30 commits February 9, 2022 13:57
## Description

Fixes 
* software-mansion#2971


## Changes

Updated TS types definition in [react-native-reanimated.d.ts](https://github.com/software-mansion/react-native-reanimated/blob/main/react-native-reanimated.d.ts)


### Before 

![image](https://user-images.githubusercontent.com/50801299/153204844-888501cb-c009-4691-9046-ba55b4525bb8.png)


### After

No such error


## Test code and steps to reproduce

```js
import Animated, {
    useSharedValue,
    withTiming,
    useAnimatedStyle,
    Easing,
  } from 'react-native-reanimated';
  import { View, Button } from 'react-native';
  import React from 'react';
  
  export function TestScreen() {
    const randomWidth = useSharedValue(10);
  
    const config = {
      duration: 500,
      easing: Easing.bezier(0.5, 0.01, 0, 1),
    };
  
    const style = useAnimatedStyle(() => {
      return {
        width: withTiming(randomWidth.value, config),
      };
    });
  
    return (
      <View
        style={{
          flex: 1,
          alignItems: 'center',
          justifyContent: 'center',
          flexDirection: 'column',
        }}>
        <Animated.View
          style={[{ width: 100, height: 80, backgroundColor: 'black', margin: 30 }, style]}
        />
        <Button
          title="toggle"
          onPress={() => {
            randomWidth.value = Math.random() * 350;
          }}
        />
      </View>
    );
  }
```

## Checklist

- [x] Included code example that can be used to test this change
- [x] Updated TS types
- [ ] Added TS types tests
- [ ] Added unit / integration tests
- [ ] Updated documentation
- [x] Ensured that CI passes
## Description

`CGPointMake(x, y)` doesn't accept `NaN` as argument. I added a check for this case.

### Example
```js
import React, { memo, useState } from 'react';
import { Button, SafeAreaView, View } from 'react-native';
import Animated, { SlideInDown } from 'react-native-reanimated';

const AppComponent = () => {
  const [count, setCount] = useState(0);
  return (
    <SafeAreaView style={{flex: 1}}>
      <Button title="increment" onPress={() => setCount(v => v + 1)} />
      <View style={{height: 40, overflow: 'hidden'}}>
        <Animated.Text exiting={SlideInDown} key={count}>
          {count}
        </Animated.Text>
      </View>
    </SafeAreaView>
  );
};

export default App;
```

Fixes software-mansion#2878
* Check for NaN

* Revert

* Rename function

* Update definition
…oveLeftovers (software-mansion#2982)

* Ignore IllegalViewOperationException in AnimationsManager#removeLeftovers method

* Do not execute AnimationsManager#findRoot when view is null
## Description

Exported JSI functions seem to follow some name conventions. The function name prefix is quite long and easy to make typos so I added a macro for generating them.

## Test code and steps to reproduce

Built and ran the example app
## Description
Added the link of available gesture handlers

## Changes
Document change
## Description

Reanimated animations now handle the "Slow animations" option in iOS simulator and provide similar functionality on Android via dev menu toggle. 

## Changes

`frameTimestamp` in `requestRender` is calculated using drag coefficient if the slow mode is enabled.

## Screenshots / GIFs

Started with slow animations on, disabled halfway through animation. Recorded at [94b1060](software-mansion@94b1060).

|iOS|Android|
|-|-|
|<video src="https://user-images.githubusercontent.com/12465392/152365949-6989db2d-0cc0-4e32-8590-fe43a71c3b70.mp4" />|<video src="https://user-images.githubusercontent.com/12465392/152382546-a78b14a7-0bfb-44db-afe9-690ea5e0464d.mov" />|
…mansion#2992)

## Description
This is a follow up pr of software-mansion#2901 which unfortunately doesn't solve [the issue](software-mansion#2814). I do not fully understand why but the try/catch currently has no effect. It's a bit surprising to me because as far as I can see `folly::json::parse_error` should be the same as `std::exception` but I see that the crash is still happening for us in production after updating to 2.4.1 and I can also reproduce it with the example app.

@piotrekzyla @tomekzaw 

## Changes
Make sure the try/catch actually works by catching a more generic error.

## Test code and steps to reproduce
I tested the code change with the example app by manually adding a `NaN` value to the event.

<img width="880" alt="Screenshot 2022-02-10 at 23 42 36" src="https://user-images.githubusercontent.com/5617793/153509602-097625f2-4516-4a42-9a28-2bd8684e8a38.png">

 
## Checklist

- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Added TS types tests
- [ ] Added unit / integration tests
- [ ] Updated documentation
- [ ] Ensured that CI passes
## Description
This PR adds a getter for `ReactInstanceManager`. The motivation for this PR is to fix issues software-mansion#2719 and software-mansion#2801

Those Android apps whose application class does not implement `ReactApplication` or simply have a different mechanism for storing a `ReactInstanceManager`, currently they have an incompatibility with `react-native-reanimated` ending in a crash when launching the app, as the issues indicates.
Normally, those apps are where [React Native is integrated with existing Android apps](https://reactnative.dev/docs/integration-with-existing-apps)

So, introducing this getter allows us to override this getter and implement a custom way to return the `ReactInstanceManager` to be used by `react-native-reanimated`.

<!--
Description and motivation for this PR.

Inlude Fixes #<number> if this is fixing some issue.

Fixes # .
-->

## Changes
- Added `getReactInstanceManager` method for android.
<!--
Please describe things you've changed here, make a **high level** overview, if change is simple you can omit this section.

For example:

- Added `foo` method which add bouncing animation
- Updated `about.md` docs
- Added caching in CI builds

-->

<!--

## Screenshots / GIFs

Here you can add screenshots / GIFs documenting your change.

You can add before / after section if you're changing some behavior.

### Before

### After

-->

## Test code and steps to reproduce
This is an example of how to use and override this getter. It is necessary to manually link `react-native-reanimated` before to be able to do it.
```java

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {

    private static ReactInstanceManager mReactInstanceManager;
    ...

    @OverRide
    protected void onCreate(Bundle savedInstanceState) {
       ...
        List<ReactPackage> packages = new PackageList(getApplication()).getPackages();

        // Adding manually Reanimated package here, with overriding getReactInstanceManager method
         packages.add(new ReanimatedPackage() {
            @OverRide
            public ReactInstanceManager getReactInstanceManager(ReactApplicationContext reactContext) {
               // Implement here your way to get the ReactInstanceManager
               return MainActivity.getReactInstanceManager();
            }
         });

        mReactInstanceManager = ReactInstanceManager.builder()
                .setApplication(getApplication())
                .setCurrentActivity(this)
                .setBundleAssetName("index.android.bundle")
                .setJSMainModulePath("index")
                .setJSIModulesPackage(new ReanimatedJSIModulePackage()) // Adding ReanimatedJSIModulePackage here
                .addPackages(packages)
                .setUseDeveloperSupport(BuildConfig.DEBUG)
                .setInitialLifecycleState(LifecycleState.RESUMED)
                .build();
       
        ...
    }
...
}
```
<!--
Please include code that can be used to test this change and short description how this example should work.
This snippet should be as minimal as possible and ready to be pasted into editor (don't exclude exports or remove "not important" parts of reproduction example)
-->

## Checklist

- [x] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Added TS types tests
- [ ] Added unit / integration tests
- [ ] Updated documentation
- [ ] Ensured that CI passes
## Description

This pr introduce a new layout animation modifier `withInitialValues` to sets initial values for pre-defined animations.

This is needed for third-party libraries to override animation props and add initial values - like `originX` & `originY`.

## Changes

- feat: added `withInitialValues` modifier to `ComplexAnimationBuilder`.
- docs: added the mention for the `withInitialValues` modifier.

## Test code and steps to reproduce

Tested the example `DefaultAnimations.tsx >> FadeIn`, where i added a background color as an initial value, and it works

```tsx
FadeIn.withInitialValues({ backgroundColor: 'red' })
``` 

## Checklist

- [x] Included code example that can be used to test this change
- [x] Updated TS types
- [x] Added TS types tests
- [ ] Added unit / integration tests
- [x] Updated documentation
- [ ] Ensured that CI passes
…n#2996)

Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.7 to 1.14.8.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](follow-redirects/follow-redirects@v1.14.7...v1.14.8)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
## Description

Update RN to 0.68
## Description

Stack PR (base).

* software-mansion#2986
* software-mansion#2988
* software-mansion#2990

Some dependencies in `package.json` are outdated, especially `react-native-screens`.

This PR should be merged only after all PRs mentioned above are merged (or rejected).

## Changes

see files

## Checklist

- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Added TS types tests
- [ ] Added unit / integration tests
- [ ] Updated documentation
- [x] Ensured that CI passes
…n#2988)

## Description

Update dev dependencies && update jest snapshots

Part of stack PR:
* software-mansion#2986
* software-mansion#2988
* software-mansion#2990

## Checklist

- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Added TS types tests
- [ ] Added unit / integration tests
- [ ] Updated documentation
- [x] Ensured that CI passes
## Description

Fixes the issue when Gradle would crash while linting. More information: diffplug/spotless#834

## Changes

- Added workaround from diffplug/spotless#834 (comment)

## Test code and steps to reproduce

Linted some Java code.
Bumps [ajv](https://github.com/ajv-validator/ajv) from 6.10.2 to 6.12.6.
- [Release notes](https://github.com/ajv-validator/ajv/releases)
- [Commits](ajv-validator/ajv@v6.10.2...v6.12.6)

---
updated-dependencies:
- dependency-name: ajv
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [ajv](https://github.com/ajv-validator/ajv) from 6.10.2 to 6.12.6.
- [Release notes](https://github.com/ajv-validator/ajv/releases)
- [Commits](ajv-validator/ajv@v6.10.2...v6.12.6)

---
updated-dependencies:
- dependency-name: ajv
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Until now it didn't successfully transpile `performance.now()` (or `_chronoNow`).
## Description

software-mansion#2979 introduced a typo, [as reported here](software-mansion#2979 (comment)).

🤦🏼 

## Changes

Fixed the typo

## Test code and steps to reproduce

```js
import Animated, {
    useSharedValue,
    withTiming,
    useAnimatedStyle,
    Easing,
  } from 'react-native-reanimated';
  import { View, Button } from 'react-native';
  import React from 'react';
  
  export function TestScreen() {
    const randomWidth = useSharedValue(10);
  
    const config = {
      duration: 500,
      easing: Easing.bezier(0.5, 0.01, 0, 1),
    };
  
    const style = useAnimatedStyle(() => {
      return {
        width: withTiming(randomWidth.value, config),
      };
    });
  
    return (
      <View
        style={{
          flex: 1,
          alignItems: 'center',
          justifyContent: 'center',
          flexDirection: 'column',
        }}>
        <Animated.View
          style={[{ width: 100, height: 80, backgroundColor: 'black', margin: 30 }, style]}
        />
        <Button
          title="toggle"
          onPress={() => {
            randomWidth.value = Math.random() * 350;
          }}
        />
      </View>
    );
  }
```


## Checklist

- [x] Included code example that can be used to test this change
- [x] Updated TS types
- [ ] Added TS types tests
- [ ] Added unit / integration tests
- [ ] Updated documentation
- [ ] Ensured that CI passes
Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.5.3 to 1.5.7.
- [Release notes](https://github.com/unshiftio/url-parse/releases)
- [Commits](unshiftio/url-parse@1.5.3...1.5.7)

---
updated-dependencies:
- dependency-name: url-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.5.3 to 1.5.7.
- [Release notes](https://github.com/unshiftio/url-parse/releases)
- [Commits](unshiftio/url-parse@1.5.3...1.5.7)

---
updated-dependencies:
- dependency-name: url-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
## Description

The CI failed, so I fixed eslint errors and ran prettier.
## Description

I do it often 😄 So I want to make it faster.
## Description

Part of stack PR:
* software-mansion#2986
* software-mansion#2988
* software-mansion#2990

## Changes

Update jest to latest release version.

## Test code and steps to reproduce

run `yarn jest`


## Checklist

- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Added TS types tests
- [ ] Added unit / integration tests
- [ ] Updated documentation
- [ ] Ensured that CI passes
## Description

This patch removes setup instructions for Android. iOS is in progress (there's some complexity with bridge init lifecycle - Reanimated replaces native RN modules).

## Changes

- Move initialization from `ReanimatedJSIModulePackage` to `ReanimatedModule` by utilizing `@ReactMethod(isBlockingSynchronousMethod = true)` annotation.

## Test code and steps to reproduce

I tested it on the example app but maybe it's worth building the package and checking on the freshly generated app.
## Description

In `d.ts` was used export from `.ts` file. To make it correct we should use the direct import described here - https://stackoverflow.com/a/51114250/7276742

Thanks for the help for @terrysahaidak 🚀
## Description

Fixes software-mansion#2345.

In some cases is possible to call `updateProps` on the not yet mounted component. These updates were overridden by React Layout props. I detect this situation and save new props to buffer, and schedule updates of these props after mounting of component.

<details>
<summary>Code to reproduce</summary>

```js
import * as React from 'react';
import { View, StyleSheet, Platform } from 'react-native';
import Animated, {
  useAnimatedStyle,
  useSharedValue,
  useAnimatedScrollHandler,
} from 'react-native-reanimated';

export default function Repro() {
  const translationY = useSharedValue(200);

  const scrollHandler = useAnimatedScrollHandler(({ contentOffset: { y } }) => {
    translationY.value = 200 + y + 20;
  });

  const animatedHeaderStyle = useAnimatedStyle(() => {
    return {
      position: 'absolute',
      backgroundColor: 'red',
      height: 200,
      top: 0,
      left: 0,
      right: 0,
      paddingTop: 100,
      width: translationY.value,
    };
  }, [translationY]);

  console.log("Render", "----------------------------------")
  
  return (
    <View style={styles.container}>
      <Animated.ScrollView
        contentInset={{ top: 200 }}
        contentOffset={{
          y: -200,
          x: 0,
        }}
        contentContainerStyle={styles.contentContainer}
        style={styles.container}
        onScroll={scrollHandler}
        scrollEventThrottle={16}>
      </Animated.ScrollView>
      <Animated.View style={animatedHeaderStyle}>
      </Animated.View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  contentContainer: {
    paddingTop: Platform.OS === 'android' ? 200 : undefined,
  },
  blueSpace: {
    height: 500,
    backgroundColor: 'blue',
  },
  middleLine: {
    height: 10,
    backgroundColor: 'green',
  },
});
```
</details>
piaskowyk and others added 20 commits June 14, 2022 16:53
## Description

I just removed type form TS for unimplemented method `createWorklet`

This PR should be copied to the Reanimated2 branch also.

Fixes: software-mansion#3131
…n#3327)

## Description

During the installation of `react-native-reanimated` it's incredibly common to encounter a false-positive error that is easily fixed by clearing the cache.

This PR adds a note to the docs about cleaning the cache after installing reanimated's babel plugin.

Fixes software-mansion#1875

## Screenshots / GIFs

Sorry for the dark theme 🙈 

<img width="823" alt="image" src="https://user-images.githubusercontent.com/39658211/175934379-b33f8630-b269-40f2-b9bb-481bb5fb8eea.png">


## Test code and steps to reproduce

```sh
cd docs/
yarn
yarn start
```

and navigate to http://localhost:3000/react-native-reanimated/docs/fundamentals/installation

## Checklist

- [x] Updated documentation
## Description

This PR adds descriptions to options of the `withSpring` animation.

https://docs.swmansion.com/react-native-reanimated/docs/api/animations/withSpring


## Screenshots / GIFs

### Before

![image](https://user-images.githubusercontent.com/39658211/175949620-091a7b24-8df1-421f-a822-4f3507872a46.png)

### After

Sorry for the dark theme 🙈

![image](https://user-images.githubusercontent.com/39658211/175949320-e9a4cc64-d2de-4595-84fa-e5c8d4d3531e.png)


## Test code and steps to reproduce

```sh
cd docs/
yarn
yarn start
```

and navigate to http://localhost:3000/react-native-reanimated/docs/api/animations/withSpring

## Checklist

- [x] Updated documentation
working example with imports

## Description

Had to adjust the example to make it work, this is the result I reached. Hope it makes sense.

## Changes

- add imports
- updated the styling (could see the button)
- add inline Incrementor component to isolate the logic


## Screenshots / GIFs

### Before

Didn't make that

### After

![Jun-23-2022 11-10-07](https://user-images.githubusercontent.com/678806/175262737-7ee38bd1-4aca-492b-80bf-2d65d811fe11.gif)


## Test code and steps to reproduce

🤷‍♂️

## Checklist

- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Added TS types tests
- [ ] Added unit / integration tests
- [ ] Updated documentation
- [ ] Ensured that CI passes

🤷‍♂️
Bumps [jsdom](https://github.com/jsdom/jsdom) from 16.4.0 to 16.7.0.
- [Release notes](https://github.com/jsdom/jsdom/releases)
- [Changelog](https://github.com/jsdom/jsdom/blob/master/Changelog.md)
- [Commits](jsdom/jsdom@16.4.0...16.7.0)

---
updated-dependencies:
- dependency-name: jsdom
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [jpeg-js](https://github.com/eugeneware/jpeg-js) from 0.4.3 to 0.4.4.
- [Release notes](https://github.com/eugeneware/jpeg-js/releases)
- [Commits](jpeg-js/jpeg-js@v0.4.3...v0.4.4)

---
updated-dependencies:
- dependency-name: jpeg-js
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…mansion#3312)

## Description

This caused gradle to crash for some reason (rnMinorVersion variable was
    not defined in detectAAR method)

Should be merged to 2.8.0 line.


## Changes

Removed usage of global scoped `rnMinorVersion` variable in `detectAAR` method.

## Test code and steps to reproduce

create fresh RN application, install 2.8.0 with this patch and see it works
## Description

This PR allows to run a sequence of just one animation. It makes little sense, but this is no reason to crash the whole app.

## Changes

Removed code that throws exception when there's just one animation in a sequence.

It was added in software-mansion@66232c6 but removing it doesn't break the app.

<!--

## Screenshots / GIFs

Here you can add screenshots / GIFs documenting your change.

You can add before / after section if you're changing some behavior.

### Before

### After

-->

## Test code and steps to reproduce

<!--
Please include code that can be used to test this change and short description how this example should work.
This snippet should be as minimal as possible and ready to be pasted into editor (don't exclude exports or remove "not important" parts of reproduction example)
-->

## Checklist

- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Added TS types tests
- [ ] Added unit / integration tests
- [ ] Updated documentation
- [ ] Ensured that CI passes
## Description

When running tests in jest, getting this error:

 ```sh
TypeError: (0 , _reactNativeReanimated.runOnUI) is not a function
```
## Changes


Add `runOnUI` to `mock.ts`
## Description

Override of `style` props in `AnimatedProps` is conflicting and throw an error. Omitting the `style` key before merging the new interface fix the issue.

Fixes software-mansion#2968 .

## Changes

Upgrade `AnimatedProps` type.

### Before

<img width="1655" alt="Screen Shot 2022-06-20 at 12 13 42 PM" src="https://user-images.githubusercontent.com/3551795/174580308-4ee93da4-92c6-401c-bd9a-f48e6b69099c.png">

### After

<img width="866" alt="Screen Shot 2022-06-20 at 12 14 01 PM" src="https://user-images.githubusercontent.com/3551795/174580340-87abf015-bae1-437c-b29b-ff6efd72c1f4.png">

## Checklist

- [ ] Included code example that can be used to test this change
- [x] Updated TS types
- [ ] Added TS types tests
- [ ] Added unit / integration tests
- [ ] Updated documentation
- [ ] Ensured that CI passes
## Description

Bump version of react-native to 69.
# Conflicts:
#	RNReanimated.podspec
#	android-npm/build.gradle
#	android/build.gradle
#	android/gradle.properties
#	createNPMPackage.sh
#	package.json
#	yarn.lock
@geriux geriux marked this pull request as ready for review October 10, 2022 10:18
@geriux
Copy link
Author

geriux commented Oct 10, 2022

Hey @derekblank 👋 this is now ready for review 🚀

Copy link

@derekblank derekblank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@geriux geriux merged commit edab86e into wp-fork Oct 11, 2022
@geriux geriux deleted the wp-fork-2.9.1 branch October 11, 2022 06:44
@fluiddot
Copy link

fluiddot commented Oct 11, 2022

Heads up that I've merged trunk into wp-fork (353392d) after this PR was merged into wp-fork. This way we'll see the actual file changes made in wp-fork against trunk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.