340 Commits

Author SHA1 Message Date
Jakub Grzywacz
04d0e89d27 chore: bump package and tests-example to react-native@0.77.0 (#2621)
# Summary

Bumped package and tests-example app from *last* golden release
`react-native@0.77.0-rc.7` to stable `react-native@0.77.0` and tested
for regression.

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |          |
| Android |          |

## Checklist

<!-- Check completed item, when applicable, via: [X] -->

- [x] I have tested this on a device and a simulator
2025-01-22 13:05:19 +01:00
Jakub Grzywacz
9ed8eb1587 Release 15.11.1 2025-01-09 21:00:44 +01:00
Jakub Grzywacz
7f6fa1026b fix: include scripts/rnsvg_utils.rb in release (#2607)
# Summary

Hotfix for #2606, where `RNSVG.podspec` imports `scripts/rnsvg_utils.rb`
but `scripts` catalog is not included in the release.

Closes #2606

# Issue
```bash
❯ bundle exec pod install

[!] Invalid `Podfile` file:
[!] Invalid `RNSVG.podspec` file: cannot load such file -- /node_modules/react-native-svg/scripts/rnsvg_utils.

 #  from /node_modules/react-native-svg/RNSVG.podspec:2
 #  -------------------------------------------
 #  require 'json'
 >  require_relative './scripts/rnsvg_utils'
 #
 #  -------------------------------------------
```
2025-01-09 20:59:38 +01:00
Jakub Grzywacz
6d353737b3 Release 15.11.0 2025-01-09 17:03:59 +01:00
Jakub Grzywacz
c7743f1a41 chore: bump react-native and other packages (#2598)
# Summary

* Bump react-native and other packages (babel, eslint, prettier,
`@types`) to resolve errors in
https://github.com/software-mansion/react-native-svg/pull/2586
* Cleanup unused/unnecessary devDependencies 

## Test Plan

Lib should work exactly the same as before.
2025-01-07 14:28:14 +01:00
Jakub Grzywacz
bf1c32d9a5 feat: add codegen ios.componentProvider (#2572)
# Summary

Add a newly introduced field `ios.componentProvider` to the `codegen`
configuration to create an association map between JS components and
their native implementations.

When this field is defined, it is used and codegen don't crawl the file
system looking for the mapping. You can find the documentation for it
here:
https://github.com/facebook/react-native-website/pull/4388/files#diff-7fbb6ff2e58f8bd50d2763e551c63e1816adb6d593f40d489785b575b0e82718R76

## Test Plan

Running `pod install` in the `tests-example` will currently hang and
eventually crash, as it attempts to crawl through the entire repository.
2024-12-10 17:03:47 +01:00
Jakub Grzywacz
c59eb295db Release 15.10.1 2024-12-05 11:41:55 +01:00
Jakub Grzywacz
3b5c5f0593 Release 15.10.0 2024-12-03 12:54:54 +01:00
Jakub Grzywacz
bba8b3f0a8 Release 15.9.0 2024-11-13 14:22:18 +01:00
Jakub Grzywacz
b3b175a7fb feat: move examples to ./apps (#2507)
# Summary

Due to the large number of example apps in the repository, I decided to
change the structure and move all applications into an "apps" folder to
maintain a clear structure.
2024-10-25 16:12:23 +02:00
Jakub Grzywacz
19c7ff8310 chore: set yarn version (#2504)
# Summary

Similar to
https://github.com/software-mansion/react-native-gesture-handler/pull/2882
Sets the package manager used in the example apps and in the root of the
repository to yarn@1.22.22.

## Test Plan

Install dependencies & build apps
2024-10-25 11:38:59 +02:00
Jakub Grzywacz
4637dee1e4 feat: FeComposite filter (#2433)
# Summary

<img width="324" alt="image"
src="https://github.com/user-attachments/assets/0a9b4a56-d093-49f7-aacd-c198ee00f256">

## Test Plan

Examples app -> Filters -> FeComposite

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |          |
| macOS   |    *      |
| Android |          |
| Web     |          |

_*_ macOS isn't working as:
* `CGBitmapContextCreateImage` always returns null
* FeFlood isn't aligned properly (will be fixed in the following PR)
2024-10-25 11:18:07 +02:00
Jakub Grzywacz
81c69e30d3 Release 15.8.0 2024-10-17 14:25:01 +02:00
Jakub Grzywacz
3cc340424c Release 15.8.0-rc.3 2024-10-14 10:43:37 +02:00
Jakub Grzywacz
4058b4cc34 Release 15.8.0-rc.2 2024-10-14 09:54:04 +02:00
Jakub Grzywacz
279a7916da chore: change babel preset to @react-native/babel-preset (#2482)
# Summary

Change babel preset from `metro-react-native-babel-preset` to
`@react-native/babel-preset` to properly parse flow files.
2024-10-14 09:50:57 +02:00
Jakub Grzywacz
09006498a8 Release 15.8.0-rc.1 2024-09-17 14:57:57 +02:00
Jakub Grzywacz
1ca8edd6d2 Release 15.8.0-rc.0 2024-09-17 11:08:10 +02:00
Jakub Grzywacz
b65b3c2679 feat: support react-native@0.76 (#2445)
# Summary

This PR adds support for React Native 0.76 (currently: 0.76.0-rc.0).
2024-09-17 11:02:48 +02:00
Jakub Grzywacz
6af15f7670 Release 15.7.0 2024-09-17 10:57:14 +02:00
Bartosz Stefańczyk
a089cc2efc feat: e2e snapshot tests (#2338)
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect -->

# Summary

This PR adds E2E tests based on view screenshots done via
`react-native-view-shot`. It only works with devices that have their
[pixel ratio](https://reactnative.dev/docs/pixelratio) equal `3`. If you
want to use device with different pixel ratio, you need to adjust it in
`e2e/generateReferences.ts` viewport and regenerate reference images
(see below).

Steps to run tests:
- Run Metro server for example app via `yarn start` in example app's
directory
- Run `example` app on platform of your choice (currently only Android &
iOS are supported) via `yarn android` or `yarn ios` in example app's
directory
- Run `yarn e2e` in project's root directory to start Jest server
- Select `E2E` tab in example app
- Wait for tests to finish
- You can see test results, as well as diffs (actual rendered svg vs
reference image) in `e2e/diffs` directory

Steps to add new test cases:
- Put SVG of your choice to `e2e/cases` directory
- Run `yarn generateE2eRefrences`, this will open headless chrome
browser via `puppeteer` and snapshot all rendered SVGs to .png files and
later use them as reference in tests
- You should see new .png files in `e2e/references`
- When you run E2E tests again, it will use new test case(s) you've
added

## Test Plan


https://github.com/software-mansion/react-native-svg/assets/41289688/24ee5447-ce9a-43b6-9dde-76229d25a30a


https://github.com/software-mansion/react-native-svg/assets/41289688/71d1873f-8155-4494-80bd-e4c1fa72a065


### What's required for testing (prerequisites)?
See Summary

### What are the steps to reproduce (after prerequisites)?
See Summary

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    	     |
| Android |         |
| Web | 			 |
## Checklist



<!-- Check completed item, when applicable, via: [X] -->

- [X] I have tested this on a device and a simulator
- [x] I added documentation in `README.md`
- [X] I updated the typed files (typescript)
- [X] I added a test for the API in the `__tests__` folder

---------

Co-authored-by: bohdanprog <bohdan.artiukhov@swmansion.com>
Co-authored-by: Jakub Grzywacz <jakub.grzywacz@swmansion.com>
2024-08-23 13:29:38 +02:00
Jakub Grzywacz
ea99e5c875 Release 15.6.0 2024-08-21 15:16:16 +02:00
Jakub Grzywacz
4100c0897c chore: fix prettier (#2416)
# Summary

Fix pre-commit `format-js` prettier error caused by
https://github.com/software-mansion/react-native-svg/pull/2408
2024-08-20 12:07:36 +02:00
Jakub Grzywacz
d11d892496 feat: rewrite Svg transform (#2403)
# Summary

Currently, when applying transforms depending on the type (RN style vs
SVG style) transforms behave differently giving wrong results.

Example component
```tsx
<Svg
  height="200"
  viewBox="0 0 200 200"
  width="200"
  // transform={[{scale: 2}]}
  // transform="scale(2)"
  // transform={[{rotate: '45deg'}]}
  // transform="rotate(45)"
  // transform={[{translateX: 100}, {translateY: 100}]}
  // transform="translate(100 100)"
>
  <Mask id="myMask">
    <Rect fill="white" height="100" width="100" x="0" y="0" />
    <Path d="M10,35 A20,20,0,0,1,50,35 A20,20,0,0,1,90,35 Q90,65,50,95 Q10,65,10,35 Z" />
  </Mask>
  <Rect fill="pink" height="200" width="300" x="0" y="0" />
  <Circle cx="50" cy="50" fill="purple" mask="url(#myMask)" r="50" />
  <Rect fill="green" x="50" y="100" width="100" height="100" />
</Svg>
```
| Attribute | Before | After |
| --- | --- | --- |
| `transform={[{scale: 2}]}` | <img width="250" alt="image"
src="https://github.com/user-attachments/assets/c04d7e11-e039-4d1a-b804-e993f3877b6a">
| <img width="250" alt="image"
src="https://github.com/user-attachments/assets/bb717ae4-7c8f-410a-942d-1bd6feab273c">
|
| `transform="scale(2)"` | <img width="250" alt="image"
src="https://github.com/user-attachments/assets/85717613-ede0-44a8-8524-c9af4b37c09d">
| <img width="250" alt="image"
src="https://github.com/user-attachments/assets/f4e23bc6-8cfb-4509-a2f5-45c4f642c197">
|
| `transform={[{rotate: '45deg'}]}` | <img width="250" alt="image"
src="https://github.com/user-attachments/assets/90131401-2c52-4e8a-81ab-6cd449625953">
| <img width="250" alt="image"
src="https://github.com/user-attachments/assets/bab46300-4794-4322-bd95-d6e7e7abd30e">
|
| `transform="rotate(45)"` | <img width="250" alt="image"
src="https://github.com/user-attachments/assets/6d308022-4844-451a-b767-1c3e94e7a295">
| <img width="250" alt="image"
src="https://github.com/user-attachments/assets/553bbad5-9e37-4a52-b4e0-fa0c7b6b558e">
|
| `transform={[{translateX: 100}, {translateY: 100}]}` | <img
width="250" alt="image"
src="https://github.com/user-attachments/assets/91508d75-2b0a-4be6-9280-2ace017d9271">
| <img width="250" alt="image"
src="https://github.com/user-attachments/assets/36fb5cad-1ccf-4c99-8ffd-70ea56ba589f">
|
| `transform="translate(100 100)"` | <img width="250" alt="image"
src="https://github.com/user-attachments/assets/28fa66f2-b2f2-4b86-bb41-47bd507d6018">
| <img width="250" alt="image"
src="https://github.com/user-attachments/assets/36fb5cad-1ccf-4c99-8ffd-70ea56ba589f">
|

## Test Plan

Test example app -> `Test2403`
2024-08-19 09:16:18 +02:00
Jakub Grzywacz
f12ec19b6c Release 15.5.0 2024-08-06 15:25:49 +02:00
Jakub Grzywacz
52466a2564 feat: introduce CSS filter API on FilterImage (#2359)
# Summary

Provide a **CSS**-like filter API in the `FilterImage` component. 
Unlike the SVG filter API, which can be complex and challenging even for
simple tasks, the CSS API is straightforward and allows users to quickly
achieve satisfactory results.

The full API can be viewed here
https://developer.mozilla.org/en-US/docs/Web/CSS/filter
_We support all `<filter-function>` listed in the docs while we do not
support functions from `<url>` (`url()` and `src()`)._

All shorthands are implemented according to the W3 standard described
here
https://www.w3.org/TR/filter-effects-1/#ShorthandEquivalents

This PR also changes the `filters` prop behavior as it adds `fe` in
front of `name` attribute to not introduce any abstract above that
specified in the docs.
```tsx
<FilterImage
  source={myImage}
  filters={[{ name: 'colorMatrix', type: 'saturate', values: 0.2 }])
/>
```
is now 
```tsx
<FilterImage
  source={myImage}
  filters={[{ name: 'feColorMatrix', type: 'saturate', values: 0.2 }])
/>
```

## Examples
Below are the simple examples of the usage

through `StyleSheet`
```tsx
import React from 'react';
import {StyleSheet, View} from 'react-native';
import {FilterImage} from 'react-native-svg/filter-image';

export default () => {
  return (
    <FilterImage
      style={styles.image}
      source={{
        uri: 'https://cdn.pixabay.com/photo/2024/05/26/00/40/lizard-8787888_1280.jpg',
      }}
    />
  );
};
const styles = StyleSheet.create({
  image: {
    width: 200,
    height: 200,
    filter: 'saturate(100) grayscale(100%)',
  },
});
```

or directly in the `style` prop

```tsx
import React from 'react';
import {StyleSheet, View} from 'react-native';
import {FilterImage} from 'react-native-svg/filter-image';

export default () => {
  return (
    <FilterImage
      style={{
        width: 200,
        height: 200,
        filter: 'saturate(100) grayscale(100%)',
      }}
      source={{
        uri: 'https://cdn.pixabay.com/photo/2024/05/26/00/40/lizard-8787888_1280.jpg',
      }}
    />
  );
};
```

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |         |
| Android |         |

## Checklist

- [x] I have tested this on a device and a simulator
- [x] I added documentation in `README.md`
- [x] I updated the typed files (typescript)
2024-07-25 10:19:47 +02:00
Maciej Stosio
567e90521a Feat: add scripts to sync archs (#2357)
Changes moved from:
https://github.com/software-mansion/react-native-screens/pull/2224

## Description

When changing native props on Fabric, codegen generates corresponding
interfaces and delegates. To make sure both implementations are
consistent, we implement those interfaces on Paper too. Currently, after
generating interfaces using codegen, developer needs to copy
corresponding files for paper manually. This task adds Gradle task, that
automates this.

## Changes
Current assumption: 
Two scripts: `check-archs-consistency` and `sync-archs`. The first one
generates codegen interfaces and compares them with what we have for
paper, the second generates and copies for paper to sync the archs.
- sync is run when staged on changes to `src/paper`
- check is run on CI when `src/paper` or
`android/src/paper/java/com/facebook/react/viewmanagers` changes

## Test code and steps to reproduce

Open `src/fabric/LineNativeComponent.ts` or/and
`src/fabric/NativeSvgRenderableModule.ts` and remove any proper form
interface. Now:
- when building paper, interface should be updated
- when committing, interface should be updated
- if committed and pushed, Test consistency between Paper & Fabric
should fail :)
Brining back the prop and repeating up should cause the interface back
and CI green.
Posting changes in other places should cause CI task to run. 

You can also run those commands yourself using `yarn
check-archs-consistency` and `yarn sync-archs`
2024-07-22 14:58:37 +02:00
Jakub Grzywacz
5d7f21265a Release 15.4.0 2024-07-11 15:01:30 +02:00
Jakub Grzywacz
08e92074b4 feat: filters support FeColorMatrix and FilterImage (#2316)
# Summary

Introducing the long-awaited **Filters** in `react-native-svg` 🎉

### Motivation

This PR is the beginning of bringing support of SVG Filters into
`react-native-svg`.

* **related issues**: This PR series will address the following issues:
#150, #176, #635, #883, #994, #996, #1216
* **feature overview**: This PR is a boilerplate for Filters
   * introducing `Filter` component and `FeColorMatrix` as a start. 
* It also introduces a new subdirectory called
`react-native-svg/filter-image` with a `FilterImage` component.

# Usage

## Filter and Fe...

Filters are compatible with the web familiar standard, so most things
should be compatible out-of-the-box and changes will be limited to using
a capital letter as it's component.

### Example

```tsx
import React from 'react';
import { FeColorMatrix, Filter, Rect, Svg } from 'react-native-svg';

export default () => {
  return (
    <Svg height="300" width="300">
      <Filter id="myFilter">
        <FeColorMatrix type="saturate" values="0.2" />
      </Filter>
      <Rect
        x="0"
        y="0"
        width="300"
        height="300"
        fill="red"
        filter="url(#myFilter)"
      />
    </Svg>
  );
};
```

![image](https://github.com/software-mansion/react-native-svg/assets/39670088/c36fb238-95f4-455d-b0aa-2a7d4038b828)

## Filter Image

`FilterImage` is a new component that is not strictly related to SVG.
Its behavior should be the same as a regular `Image` component from
React Native with one exception - the additional prop `filters`, which
accepts an array of filters to apply to the image.

### Example

```tsx
import React from 'react';
import { StyleSheet } from 'react-native';
import { FilterImage } from 'react-native-svg/filter-image';

const myImage = require('./myImage.jpg');

export default () => {
  return (
    <FilterImage
      style={styles.image}
      source={myImage}
      filters={[
        { name: 'colorMatrix', type: 'saturate', values: 0.2 },
        {
          name: 'colorMatrix',
          type: 'matrix',
          values: [
            0.2, 0.2, 0.2, 0, 0, 0.2, 0.2, 0.2, 0, 0, 0.2, 0.2, 0.2, 0, 0, 0, 0,
            0, 1, 0,
          ],
        },
      ]}
    />
  );
};
const styles = StyleSheet.create({
  image: {
    width: 200,
    height: 200,
  },
});
```


![image](https://github.com/software-mansion/react-native-svg/assets/39670088/666ed89f-68d8-491b-b97f-1eef112b7095)

## Test Plan

**Example App**: Updated the example app with various filter effects,
showcasing real-world usage.

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |         |
| Android |         |

## Checklist

- [x] I have tested this on a device and a simulator
- [x] I added documentation in `README.md` and `USAGE.md`
- [x] I updated the typed files (typescript)
2024-07-11 11:17:35 +02:00
Bartosz Stefańczyk
dd57e9e83b fix: fix format-js task to reflect changes made to folder structure (#2342)
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect -->

# Summary
Fixes following error while commiting:
```
✖ yarn format-js:
[error] No files matching the pattern were found: "./Example/src/**/*.tsx".
error Command failed with exit code 2.
```


## Test Plan

Run `yarn format-js` or do a commit so hook will get ran.

### What's required for testing (prerequisites)?
-

### What are the steps to reproduce (after prerequisites)?
See test plan

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |         |
| Android |         |

## Checklist

<!-- Check completed item, when applicable, via: [X] -->

- [X] I have tested this on a device and a simulator
- [ ] I added documentation in `README.md`
- [] I updated the typed files (typescript)
- [ ] I added a test for the API in the `__tests__` folder
2024-07-10 14:45:36 +02:00
Jakub Grzywacz
d6027ace60 Release 15.3.0 2024-05-16 15:09:14 +02:00
Jakub Grzywacz
0db87030da fix: change android package name (#2275)
# Summary

Fixes android packageName by changing it in codegen configuration from
`com.horcrux.rnsvg` to `com.horcrux.svg`

## Tests

Tested with oldest supported `react-native@0.70.0` with an old
architecture and everything is working as expected.
2024-05-15 14:53:09 +02:00
Wojciech Lewicki
a256f25de8 Release 15.2.0 2024-04-23 13:42:15 +02:00
Wojciech Lewicki
15f5b11f31 chore: bump package.json to 15.2.0-rc.0 2024-03-05 14:59:24 +01:00
Wojciech Lewicki
31772c0c0f Release 15.1.0 2024-03-05 11:38:43 +01:00
Wojciech Lewicki
e332c4ada9 Release 15.0.0 2024-02-26 15:32:58 +01:00
Wojciech Lewicki
2806bb2bee Release 14.1.0 2023-12-04 15:18:30 +01:00
Wojciech Lewicki
03ca039497 feat: add support for RN 73 (#2181)
PR bumping the library code to compile on new arch on RN 0.73.x and restoring the proper configuration of Image component on new arch on Android.

Also bumping the FabricExample to check if the code works correctly.
2023-12-01 11:58:49 +01:00
Wojciech Lewicki
1868f00f20 Release 14.0.0 2023-11-14 12:41:33 +01:00
Wojciech Lewicki
2b030dda12 feat: move css to different package for size reduction (#2168)
PR based on https://github.com/software-mansion/react-native-svg/pull/1452 extracting `css` related components to different package to reduce the size of the package.

***THIS IS A BREAKING CHANGE***. From now on, you should import 
```
  SvgCss,
  SvgCssUri,
  SvgWithCss,
  SvgWithCssUri,
  inlineStyles,
  LocalSvg,
  WithLocalSvg,
  loadLocalRawResource,
  ```
 from `react-native-svg/css` package instead.
2023-11-14 11:50:03 +01:00
Wojciech Lewicki
f9c7d8a807 Release 13.14.0 2023-09-20 17:29:47 +02:00
Wojciech Lewicki
849513946e Release 13.13.0 2023-08-24 15:34:12 +02:00
Wojciech Lewicki
fb28d7809c Release 13.12.0 2023-08-21 16:00:42 +02:00
Wojciech Lewicki
9176c4c95a Release 13.11.0 2023-08-07 18:49:17 +02:00
Wojciech Lewicki
416ccc8a86 fix: bump packages, eslint, tsconfig, prettier and resolve all conflicts (#2114)
PR bumping packages, eslint, tsconfig, prettier and resolving all conflicts connected to it.
2023-08-07 17:44:58 +02:00
Wojciech Lewicki
0e931577ac Release 13.10.0 2023-07-07 12:53:47 +02:00
Wojciech Lewicki
d31ffdb762 Release 13.9.0 2023-03-30 17:35:20 +02:00
Risto Keravuori
eaf79ea3ee Upgrade rn-builder-bob to enable tree-shaking in rn-web (#1993)
Upgrade rn-builder-bob to enable tree-shaking in rn-web
2023-03-21 14:49:28 +01:00
Wojciech Lewicki
2c59100e24 Release 13.8.0 2023-02-01 11:42:40 +01:00
Wojciech Lewicki
cb87e7510f feat: update FabricExample to 0.71.0-rc.6 (#1962)
PR bumping examples to RN 0.71. For now web Example seems not to load code properly.
2023-01-13 14:19:17 +01:00