Commit Graph

1973 Commits

Author SHA1 Message Date
Bohdan Artiukhov
9faa387a98 Fix: image onLoad props (#2317)
# Summary
Change data structure returned from the Image onLoad event.
Add fix in new arch for returned sizes.

## Test Plan

Manually test in both architectures and platforms.

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

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

## Compatibility

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

---------

Co-authored-by: Jakub Grzywacz <jakub.grzywacz@swmansion.com>
2024-07-02 09:33:25 +02:00
Jakub Grzywacz
e16a1519ba fix: new arch invalidate on mount/unmount (#2318)
# Summary

On iOS with the new architecture, when mounting or unmounting a
component, changes were not visible because `invalidate` wasn't called.
These changes override `mountChildComponentView` and
`unmountChildComponentView` to ensure that invalidate is called when
`RNSVGNode` is mounted or unmounted.

## Test Plan

`TestExample` app -> `MountUnmount` example 

```tsx
import React from 'react';
import {Button, Text, View} from 'react-native';
import {Rect, Svg} from 'react-native-svg';

export default () => {
  const [show, setShow] = React.useState(true);
  return (
    <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
      <Text>Blue rect is mounted: {show ? 'true' : 'false'}</Text>

      <Svg height="300" width="300">
        {show ? (
          <Rect x="100" y="100" width="100" height="100" fill="blue" />
        ) : null}
      </Svg>
      <Button title="Toggle" onPress={() => setShow(!show)} />
    </View>
  );
};
```


https://github.com/software-mansion/react-native-svg/assets/39670088/0eaf9a61-b47b-4f89-a7c7-a67375e2e63e


https://github.com/software-mansion/react-native-svg/assets/39670088/709feedf-63c1-47d7-b799-f3899278fe77


## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |         |
2024-07-01 16:21:18 +02:00
Bohdan Artiukhov
fe48dfb238 feat: update needs-more-info git workflow (#2314)
# Summary
update check of react-native-svg version in GitHub workflow.
2024-06-28 09:04:45 +02:00
Bohdan Artiukhov
c0ee3e9ca0 add onLoad prop to Image component (#2293)
# Summary

Closes #1442

We want to add new props to the Image Component.

## Test Plan

Added the Test component. 
Manually test that in Android and IOS platforms on new and old
Architectures.

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

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |         |
| Android |         |
2024-06-27 16:10:28 +02:00
Jakub Grzywacz
7b5d4daaed fix: scaling when mask is set (#2299)
# Summary

This PR resolves an issue raised in #1451. 
Currently, when a mask is used, we render the element as a bitmap (or
platform equivalent), but the bitmap's size does not update accordingly
with transformations. With these changes, the problem is addressed as
follows:
* **Android**: We utilize the original canvas layers to render the mask
and element with the appropriate blending mode.
* **iOS**: We create an offscreen context with the size multiplied by
the screen scale and apply the original UIGraphics CTM (current
transformation matrix) to the offscreen context. This ensures that the
same transformations are applied as on the original context.

Additionally, there is a significant performance improvement on Android
as we are not creating three new Bitmaps and three new Canvases.

## Test Plan

There are many ways for testing these changes, but the required ones
are:
* `TestsExample` app -> `Test1451.tsx`
* `Example` app -> Mask section
* `FabricExample` app -> Mask section

## Compatibility

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

## Preview

<img width="337" alt="image"
src="https://github.com/software-mansion/react-native-svg/assets/39670088/93dbae85-edbd-452a-84b0-9a50107b1361">
<img width="337" alt="image"
src="https://github.com/software-mansion/react-native-svg/assets/39670088/07838dff-cb2d-4072-a2fc-5c16a76f6c33">
2024-06-26 09:25:54 +02:00
Bohdan Artiukhov
a36a676d43 fix: android PathParser crash app if pass some wrong d prop (#2308)
Closes #2086
# Summary

The application crashes if an error is thrown when something goes wrong
during path parse.

## Test Plan
You can easily check in that component `Test2086` how it works after the
fix.

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |         |
| Android |        |
2024-06-20 14:16:39 +02:00
Bohdan Artiukhov
0596fd9dc5 fix: handle onPress prop on web app (#2302)
# Summary
Closes #1483
Closes #1524

We want a handle `onPress` prop on the web version in SVG components.

## Test Plan

Check on `react-native` web version if prop onPress works.

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| Web     |         |
2024-06-17 14:07:18 +02:00
Bohdan Artiukhov
785a2bc7ee fix: example app package.json file and yarn.lock (#2303)
# Summary
Fix problem package.json

## Test Plan
install packages and run apps.
## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| Web     |        |
2024-06-17 12:48:54 +02:00
Bohdan Artiukhov
47d9c27997 fix: issue template (#2301)
# Summary
Fix issue template
2024-06-13 17:11:14 +02:00
Bohdan Artiukhov
9d3c781b2e feat: add new bug issue template, and github actions (#2300)
# Summary

We want to add a new bug issue template, and new GitHub actions to check
if all information exists in issues.
2024-06-13 17:03:54 +02:00
Bohdan Artiukhov
474109ad71 fixed pars on Android platform prop strokeDasharray (#2294)
# Summary
Closes #2248.
Add the ability to parse `strokeDasharray` string value on the Android
platform

## Test Plan

Manually test both platforms.

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |         |
| Android |         |
2024-06-13 11:32:11 +02:00
Bohdan Artiukhov
556f1e3ec0 feat: github action close-when-stale (#2296)
# Summary
Add GH action to close issues that were without response to the
question.

## Test Plan

Check if that GH action closes the issue if no one response to the
question.
2024-06-12 15:33:29 +02:00
Kacper Kapuściak
008422b575 chore: add hire us section to readme (#2295)
This PR adds a "Hire us" section to the README with a link to the
contact form.
2024-06-11 16:29:18 +02:00
Bohdan Artiukhov
558a59609a chore: remove macos-build-test.yml (#2292)
# Summary

- remove `macos-build-test.yml`

## Test Plan

merge that PR to the main, and check if `macos-build` action will be run
2024-06-07 21:59:32 +02:00
Bohdan Artiukhov
72a9494644 chore: TestsExample app fix reanimated and metro.config issues (#2291)
# Summary

We want to fix the TextExample app

- change version of react-native-reanimated.
- add to `metro.config.js` extraNodeModules: 
```
'react-native-svg': `${__dirname}/../`
```

## Test Plan

test manually.
2024-06-07 14:23:39 +02:00
Bohdan Artiukhov
8733bea10b Handle error when pass wrong uri to SvgFromUri component (#2289)
# Summary

We want to add the ability to handle the Error when someone passes the
wrong URI to the `SvgFromUri` component.

Closes #2148 

## Test Plan

Manual tests in TestsExample app. (Test2148)
2024-06-06 11:31:12 +02:00
Maciej Stosio
170339977d fix: error when building paper after fabric (#2281)
# Summary

We had similar config in react-native-screens. It caused problem when
building Paper arch app after Fabric. Those changes help, so I'm moving
them here as well.
2024-05-21 10:42:46 +02:00
Jakub Grzywacz
d6027ace60 Release 15.3.0 2024-05-16 15:09:14 +02:00
Jakub Grzywacz
c0e5e58f9a fix: parsing < inside comments (#2277)
# Summary

When comment occurred before first tag, there was a possible parsing
error if it contains `<` character.
Here is an example (line 2 and 3 would cause separate errors):

```xml
<!-- sample rectangle -->
<!-- <sample rectangle -->
<!-- <sample> rectangle -->
<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
  <rect width="100" height="100" x="50" y="50" fill="red" />
</svg>
```

Fixes #2276

## Test Plan

Manual tests in `TestsExample` app. (Test2276)
2024-05-16 12:46:24 +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
Jakub Grzywacz
118a20c0fd fix: toDataUrl line breaks (#2272)
# Summary

This PR removes the flag to include custom line breaks on `toDataUrl`
method. Some software could not read base64 with additional line break
characters, so it could lead to corrupting the image (like in
react-native-share). Fixes #1986.

## Test Plan

`TestsExample` -> `Test1986`

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |         |
| Android |         |
2024-05-15 12:01:33 +02:00
Jakub Grzywacz
38a8dbca39 fix: radialGradient r={0} (#2271)
# Summary

* Fixed crash on Android when `<RadialGradient r={0}>`.
* Fixed render issue on Android and iOS when radius is zero. According
to [MDN
Docs](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/r#radialgradient)
> A value of lower or equal to zero will cause the area to be painted as
a single color using the color and opacity of the last gradient
`<stop>`.

## Test Plan

Test is available in `TestsExample` as `Test2170`

## Compatibility

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


Fixes #2170
2024-05-15 12:00:52 +02:00
Fabrizio Cucci
19b2e42e1b fix: Fix static view config validation for RNSVGSvgViewAndroid (#2274)
# Summary

As per title, when running an app in bridgless mode the following redbox
appears:

> StaticViewConfigValidator: Invalid static view config for
'RNSVGSvgViewAndroid'.
> 
> 'validAttributes.borderBlockColor' is missing.
> 'validAttributes.borderBlockEndColor' is missing.
> 'validAttributes.borderBlockStartColor' is missing.
> 'validAttributes.borderEndEndRadius' is missing.
> 'validAttributes.borderEndStartRadius' is missing.
> 'validAttributes.borderStartEndRadius' is missing.
> 'validAttributes.borderStartStartRadius' is missing.

## Test Plan

Tested that the redbox is gone.

## Compatibility

| OS      | Implemented |
| ------- | :---------: |
| iOS     |    N/A     |
| 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

---------

Co-authored-by: Jakub Grzywacz <jakub.grzywacz@swmansion.com>
2024-05-15 11:13:01 +02:00
Jihoon Seo
768466d8b0 fix: Fix pod install not working with lower version of Cocoapods due to visionOS (#2240)
<!-- 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
On Cocoapods versions of lower than 1.14.3, pod install fails due to it
not understanding the visionos field.
Our company cannot use a higher version of Cocoapods right now, so it
would be beneficial if we or other similar people can use the latest
version of react-native-svg without having to upgrade the Cocoapods
version.

I was able to find this solution from
https://github.com/getsentry/sentry-react-native/issues/3547#issuecomment-1907677879

## 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-05-13 09:39:59 +02:00
Jakub Grzywacz
3f9690d850 fix: imports and remove err export (#2270)
# Summary

* Removed `err` export from root file (ReactNativeSVG)
* replaced imports from `react-native-svg` with relative imports inside
`src` dir

Resolves #2265
2024-05-09 15:38:18 +02:00
Jakub Grzywacz
ee634256ff fix: set default strokeWidth to 1 on android (#2269)
# Summary

According to [MDN
Docs](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-width),
when `strokeWidth` is not provided, the default value should be set to
`1`.

On android, when we update the `strokeWidth` prop to `undefined` it was
mistakenly converted to `0` by `SVGLength`.

Fixes #2266 

## Test Plan

Test available in `TestsExample/Test2266` 

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

* Run `TestsExample` app
* Replace `ColorTest` with `Test2266` in `App.js`
2024-05-09 15:27:24 +02:00
Arthurmtro
680806e5fe Add dxguid.lib to release action (#2243)
On Windows, it's no longer possible to build the release because some lib are missing
2024-05-06 09:16:47 +02:00
Wojciech Lewicki
a256f25de8 Release 15.2.0 2024-04-23 13:42:15 +02:00
Wojciech Lewicki
577efb1278 feat: bump RN to 0.74 in Example (#2263)
# Summary

PR bumping the Example app to newest RN version.
2024-04-23 13:40:20 +02:00
Wojciech Lewicki
3ea8fc4976 feat: bump RN to 0.74 in FabricExample and remove rea hacks (#2262)
PR bumping RN to 0.74-rc.9 and removing rea hacks that are no longer
needed 🚀
2024-04-22 19:39:04 +02:00
Eric Rozell
9f6f6fd40c Adds support to compile react-native-svg against WinAppSDK (#2255)
# Summary

Adds namespace redirects required to compile react-native-svg sources
against WinAppSDK for react-native-windows.

## Test Plan

There aren't a lot of examples for building react-native-windows apps in
open source targeting WinAppSDK, but we have some proprietary builds,
and this source code is working there (it is also still compatible with
UWP).
2024-04-12 11:10:19 +02:00
Tomasz Żelawski
4b51a41a22 Fix CMakeLists for Android (#2249)
Fix CMakeLists for Android typo
2024-03-26 14:54:35 +01:00
Wojciech Lewicki
15f5b11f31 chore: bump package.json to 15.2.0-rc.0 2024-03-05 14:59:24 +01:00
Wojciech Lewicki
138c23ba10 feat: add needed changes for RN 0.74 (#2231)
PR bringing support for RN 0.74 and bridgeless mode to the library.
2024-03-05 12:52:09 +01:00
Wojciech Lewicki
31772c0c0f Release 15.1.0 2024-03-05 11:38:43 +01:00
Wojciech Lewicki
50c2289a2c feat: use dynamics instead of strings for props that can be either string or number (#2238)
# Summary

PR bringing proper support for react-native-reanimated in the library by using dynamics instead of strings for props that can be either string or number.
2024-03-05 11:36:17 +01:00
Wojciech Lewicki
e332c4ada9 Release 15.0.0 2024-02-26 15:32:58 +01:00
Wojciech Lewicki
93ca4fe580 feat: bump minimal ios version to 12.4 (#2232)
# Summary

PR updating the minimal required version of `iOS` to `12.4`. Please
notice that it can be considered a ***BREAKING CHANGE***
2024-02-26 11:34:07 +01:00
dependabot[bot]
b800050e04 chore(deps): bump ip from 1.1.8 to 1.1.9 in /Example (#2228)
Bumps [ip](https://github.com/indutny/node-ip) from 1.1.8 to 1.1.9.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="1ecbf2fd8c"><code>1ecbf2f</code></a>
1.1.9</li>
<li><a
href="6a3ada9b47"><code>6a3ada9</code></a>
lib: fixed CVE-2023-42282 and added unit test</li>
<li>See full diff in <a
href="https://github.com/indutny/node-ip/compare/v1.1.8...v1.1.9">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=ip&package-manager=npm_and_yarn&previous-version=1.1.8&new-version=1.1.9)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/software-mansion/react-native-svg/network/alerts).

</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-26 09:45:48 +01:00
Mateusz Łopaciński
b7b6a4fc53 fix: Add missing nan value checks for bounds size (#2220)
This PR adds missing checks whether SVG bounds size values are nan. This PR should fix [this](https://github.com/software-mansion/react-native-svg/issues/978) old issue that still happens sometimes.
2024-02-26 09:43:58 +01:00
Min
e6b2cc6496 fix: typo on require statement (WithLocalSvg) (#2223)
This PR fixes typo on require statement.
It makes WithLocalSvg function as expected without crash.
2024-02-26 09:18:27 +01:00
程序员小墨
e06f5879a1 fixed @Deprecated warning in React Native 0.73: 'com.facebook.react.common.StandardCharsets' is deprecated and marked for removal (#2208)
fixed warning in React Native 0.73: 'com.facebook.react.common.StandardCharsets' is deprecated and marked for removal
2024-02-26 09:14:30 +01:00
Tomek Zawadzki
871549cca4 fix: visionOS support (#2218)
This PR fixes the following errors when compiling for visionOS:

Unknown type name 'NSColor'
2024-02-05 11:49:17 +01:00
Wojciech Lewicki
615f0c68d1 Update ios-build-test.yml (#2207)
PR bumping github action for building iOS and macOS
2024-01-15 15:56:50 +01:00
Tai Enrico
a33cb315f1 fix: Ensure RNSVG.dll is built with proper publisher/versioning information via new resource file. (#2191)
On Windows, RNSVG.dll is getting flagged by AppLocker on many of our user's devices because it is missing proper publisher/versioning information in its metadata. This forces users to manually add this DLL to AppLocker's allow-list during some update/installation scenarios.

The RNSVG.sln file also currently fails to build from Visual Studio directly, because the fmt project is not explicitly included from the react-native-windows Node package.

Test Plan
For testing, I opened RNSVG.sln in Visual Studio on Windows (with Node packages installed and other build prerequisites) and built it for Debug|x64.

Without my change, building the solution fails to build directly from Visual Studio (since it fails to link fmt.lib when building the Microsoft.ReactNative project). Even when building from the terminal using MSBuild, RNSVG.dll properties do not contain proper publisher/versioning details.

With my change, building the solution in Visual Studio succeeds and RNSVG.dll contains the correct publisher/versioning details in its properties. These can be viewed via File Explorer.
2024-01-15 11:35:49 +01:00
Quang
ff18553b71 fix(SvgCssUri): support rendering fallback instead of crashing the app when loading invalid content from remote svg file (#2196)
This crash issue still happening for SvgCssUri component
#1760

Apply similar fix #2071
specifically for SvgCSSUri component to prevent crashes due to invalid svg content

What issues does the pull request solve? Please tag them so that they will get automatically closed once the PR is merged
-> When loading invalid svg uri with SvgCSSUri, the app crashes crashes. For example the content returning html content instead of valid svg content.

How did you implement the solution?
-> Passing the fallback prop to SvgCss where will be render when error being captured

What areas of the library does it impact?
SvgCss and SvgUriCss
2024-01-03 16:48:28 +01:00
Eric Rozell
07b9ca53f4 Fix crash when SVG is unloaded by XAML (#2195)
XAML may unload the root SVG panel, which will trigger a recursive unload. For GroupView, this unload will clear the child collection. However, active operations on the SVG from the React Native UIManager may still be in flight, in which case we may attempt to remove a child that has already been cleared by the root unload.
2024-01-03 15:48:22 +01:00
Renaud Chaput
d1b02154e3 Fix type exports and enable isolatedModules setting to catch it in tsc (#2197)
This is the same issue as the one I fixed last year in #1874

To prevent this from occurring again, I enabled the `isolatedModules`
Typescript option which will warn when you export non-value identifiers
without using `export type`, which will break transpilation processes
what work on a per-file basis. You can find a [more detailed explanation
in Typescript's
doc](https://www.typescriptlang.org/tsconfig#isolatedModules)
2024-01-03 15:46:49 +01:00
Wojciech Lewicki
fd31240af4 chore: bump examples to 0.73.1 (#2201)
PR bumping apps to RN 0.73.1
2024-01-03 15:44:27 +01:00
Frank Oppervoll-Larsen
3939e2059e fix: Correct types for transformsArrayToProps (#2193)
# Summary

Type TransformsStyle['transform'] has `string` added as option from
React Native 0.71.9 onward. This breaks the logic of
`transformsArrayToProps`.

This PR fixes this by scoping down the type, and removing a no-op usage
of `transformsArrayToProps`

This has been broken for a while, but not immediately visible to users
compiling using Metro and Babel.
2024-01-03 12:41:03 +01:00