Panos Vekris
40a4feb681
replace '$TEMPORARY$string<>' with 'string' ( #46876 )
...
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46876
* Used codemods of [this commit](https://www.internalfb.com/intern/commit/cloud/FBS/3a8982d63197fff7bac8b6d448545ec9660f331e )
* `js1 flow-runner codemod flow/replaceTempStringWithString`
* `js1 flow-runner codemod flow/simplifyUnionsOfString`
Changelog: [internal]
Reviewed By: SamChou19815
Differential Revision: D63991775
fbshipit-source-id: 5b9d1fdf045405230ca2b0969357ae92479692b5
2024-10-07 19:18:14 -07:00
Peter Abbondanzo
2e80f5acf1
Load XML files on disk by default ( #46371 )
...
Summary:
X-link: https://github.com/facebook/metro/pull/1348
Pull Request resolved: https://github.com/facebook/react-native/pull/46371
## Internal
Vector drawable image support was added in D59530172 but importing vector drawable asset types was not supported out of the box. It required custom source transformers like the one added in D60021474. This is because Android cannot load vector drawable XML over the network. Vector drawables are compiled by AAPT as part of the build process. Even though Metro can serve XML, it would never load.
## Summary
This adds some minor checks in the `AssetSourceResolver` to only attempt loading XML asset types from disk on the Android platform. XML assets like vector drawables are precompiled and cannot be served over the network by Metro.
## Changelog
[Android] [Added] - Adds support for importing XML assets as images
Reviewed By: javache
Differential Revision: D62302929
fbshipit-source-id: 01e49ac5b0429d291318984128dfca2dc058149d
2024-09-09 10:18:10 -07:00
Sam Zhou
41f525ccae
Pre-suppress unsafe string key access errors in xplat/js ( #44221 )
...
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44221
This diff pre-suppresses errors of the following pattern, to prepare for the next Flow release.
```
declare const obj: {foo: string};
declare const key: string;
obj[key]; // error: invalid-computed-prop
```
Changelog: [Internal]
Reviewed By: alexmckenley
Differential Revision: D56477899
fbshipit-source-id: 5676b8685bd3157a519fe433cfce0fa28e003502
2024-04-23 11:36:14 -07:00
Pranav Yadav
8a49754cda
Refactor: JS substr() is deprecated, using slice() instead ( #37136 )
...
Summary:
Fixes: https://github.com/facebook/react-native/issues/37135
- `substr()` is not part of the core JS since ~2018
- No wonder why no one noticed this :)
- Though its supported by modern browsers, its deprecated
- Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr
### Why `slice()` and not `substring()`?
> Beacuse I like pizza ;) jk
The reason, that I'm not using the most obvious alternative `substring()` is;
- It _swaps the args_ passed, when; `startIndex > endIndex` —which I think is not a property of _good_ fn
and also does not reflects the same in it's name.
- It _doesn't support negative args_, which I think reduces flexibility to work with it.
- It could lead to more bugs in most of the cases.
### Refecrences:
- Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring#differences_between_substring_and_slice
- Ref. for `slice()`: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice
- Ref. for `substring()`: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring
## Changelog:
[GENERAL][FIXED] - Refactor: `substr()` is deprecated, using `slice()` instead across RN codebase
Pull Request resolved: https://github.com/facebook/react-native/pull/37136
Test Plan: - `yarn lint && yarn flow && yarn test-ci` --> _should be green_
Reviewed By: christophpurrer
Differential Revision: D45477910
Pulled By: jacdebug
fbshipit-source-id: 96a80893477599b9a549918924157627b9b0c3f4
2023-05-02 11:28:56 -07:00
Andres Suarez
8bd3edec88
Update copyright headers from Facebook to Meta
...
Reviewed By: aaronabramov
Differential Revision: D33367752
fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
Moti Zilberman
cb610ddca7
Assume *.ktx assets are packaged as Android drawables
...
Summary:
Updates React Native's asset runtime to look for `*.ktx` assets under `drawable-*` on Android.
This by itself does **not**:
1. Add runtime support for loading KTX images.
2. Update the OSS packager to actually package KTX files as drawables. (This will need to happen [here](https://github.com/react-native-community/cli/blob/cddb0c3fb06ef949ea689221c6167147af40e37f/packages/cli-plugin-metro/src/commands/bundle/assetPathUtils.ts#L39-L46 ).)
Changelog:
[Android][Changed] Assume *.ktx assets are packaged as Android drawables
Reviewed By: javache
Differential Revision: D32597214
fbshipit-source-id: 25007c1e0eba769ce9e484fa20da5f26890eb38d
2021-11-22 13:56:53 -08:00
Moti Zilberman
f22e6033d9
Support nonstandard pixel densities for Android drawables
...
Summary:
Adds functionality to RN's built-in version of the `getAndroidAssetSuffix` function. Open source uses a [fork of this code](https://github.com/react-native-community/cli/blob/df55a78f2d27e3443f15b15b87459b54a78e2c47/packages/cli/src/commands/bundle/assetPathUtils.ts#L19-L36 ) as part of the RN CLI and is therefore unaffected.
Specifically, we can now package drawable assets for Android with nonstandard pixel densities by placing them in [`drawable-<nnn>dpi`](https://developer.android.com/guide/topics/resources/providing-resources#:~:text=nnndpi ), where `nnn` is a number representing a pixel density. Previously using nonstandard scale factors like `1.25x` would be a build-time error when building for Android.
We could send a corresponding PR to the RN CLI, but [Gradle doesn't support this convention](https://issuetracker.google.com/issues/72884435 ) (although it is documented and supported by Android) so it may not be of much use in OSS right away.
Changelog: [Internal]
Reviewed By: cortinico
Differential Revision: D30784087
fbshipit-source-id: ea82f924d14a316702cabba759722cf26f69eb21
2021-09-09 08:19:42 -07:00
Christoph Nakazawa
63377fa66b
Add @react-native/assets package for Asset Registry related code
...
Summary: Changelog: [Internal]
Reviewed By: GijsWeterings
Differential Revision: D22628865
fbshipit-source-id: 66ff311b2dab4e0c42f906d5a2642997b1570ae4
2020-07-23 05:07:40 -07:00