2163 Commits

Author SHA1 Message Date
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
Oskar Kwaśniewski
068820b3fa feat: add visionOS support (#2190)
This PR adds support for visionOS. I've migrated the `UIScreen` API to take `displayScale` from `currentTraitCollection` - same as I did in Core (https://github.com/facebook/react-native/pull/41214/files)
2023-12-06 14:37:54 +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
Eric Rozell
20de90d272 Minor fix to prevent crash when Loaded fires twice (#2180)
There are many reasons Loaded can fire twice. Usually, it will happen when the native SvgView component is moved, but it can also happen if an ancestor of SvgView is reparented. There is a crash that appears to occur when we attempt to call CreateResources twice. This resolves that crash.
2023-11-28 10:42:20 +01:00
Maxwell You
fc1c9a0347 fix SvgCssUri fallback (#2171)
When using the `SvgCssUri` component, specifying `fallback` does not render the fallback component in the case of an error.

I looked through the source code and believe this is because `SvgCssUri` is rendering a `SvgCss`
22f47333fb/src/css.tsx (L712)
which renders a `SvgAst`
22f47333fb/src/css.tsx (L696)
which does not use the `fallback` prop
22f47333fb/src/xml.tsx (L96)

This fix copies over the error handling code from `SvgUri` so `SvgCssUri` can render a fallback on error. I tested the change in my project and this works like it does for `SvgUri`

Co-authored-by: Maxwell You <maxwell.you@mlb.com>
2023-11-15 16:59:40 +01:00
Wojciech Lewicki
ab52bdd118 fix: remove unused header causing problems (#2175)
PR removing the unused header in `Image` component causing problems mentioned in https://github.com/software-mansion/react-native-svg/issues/2082 and https://github.com/software-mansion/react-native-svg/issues/2154.
2023-11-15 15:20:07 +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
Marlene Cota
f88532d195 [Windows] Port to Direct2D to remove win2d dependency (#2052)
This change removes the win2d (Direct2D wrapper) dependency by using D2D directly. This removes the manual step of adding the win2d to any new react-native-windows projects that want to use react-native-svg. It is also a stepping stone to an easier Fabric implementation for windows.
2023-11-14 11:33:19 +01:00
Wojciech Lewicki
22f47333fb chore: bump examples to rn 0.72.6 (#2166)
PR bumping example apps to the newest RN version so its easier to bump to 0.73.x then.
2023-10-26 10:57:03 +02:00