Граф коммитов

24 Коммитов

Автор SHA1 Сообщение Дата
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
Valentin Shergin d0871d0a9a Clang format for all React Native files
Summary:
Buckle up, this enables clang-format prettifier for all files in React Native opensource repo.

Changelog: [Internal] Clang-format codemod.

Reviewed By: mdvacca

Differential Revision: D20331210

fbshipit-source-id: 8da0f94700be0c35bfd399e0c48f1706de04f5b1
2020-03-08 23:01:17 -07:00
Andy Matuschak f21fa4ecb7 Enabling RCTWebSocket on UIKitForMac (macOS Catalyst) (#27469)
Summary:
In https://github.com/facebook/react-native/issues/25427, radex added initial support for running React Native projects on macOS via Catalyst. However, `RCTWebSocket` was disabled for that target because of some compilation issues. This meant that running projects via a connection to the packager wasn't possible: no live reload, and projects must be run in "Release" mode. It also meant making manual changes to Xcode projects deploying to macOS and scattering a number of conditional checks throughout the codebase.

In this change, I've implemented support for `RCTWebSocket` on the macOS target and re-enabled the affected features. Live reload and the inspector now work for macOS targets. Manual modifications of Xcode build settings are no longer necessary for react-native projects running on macOS.

![Screen Shot 2019-12-10 at 8 36 38 AM](https://user-images.githubusercontent.com/2771/70549905-ce7b0800-1b29-11ea-85c6-07bf09811ae2.png)

### Limitations

There's no binding which displays the developer menu (since there's no shake event on macOS). We'll probably want to add one, perhaps to the menu bar.

I've chosen not to commit the modifications to RNTester which enable macOS support, since that would imply more "official" support for this target than I suspect you all would like to convey. I'm happy to add those chunks if it would be helpful.

## Changelog

[iOS] [Added] - Added web socket support for macOS (Catalyst), enabling debug builds and live reload
Pull Request resolved: https://github.com/facebook/react-native/pull/27469

Test Plan:
* Open RNTester/RNTester.xcodeproj with Xcode 11.2.1, run it like a normal iOS app -- make sure it compiles and runs correctly (no regression)
* Select "My Mac" as device target, and run. You may need to configure a valid development team to make signing work.
* RNTester should run fine with no additional configuration. Modify a file in RNTester, note that live reload is now working.
* Test the developer inspector. To display the developer menu, you'll need to manually show it; here's an example diff which does that:
```
 diff --git a/RNTester/js/RNTesterApp.ios.js b/RNTester/js/RNTesterApp.ios.js
index 8245a68d12..a447ad3b1b 100644
 --- a/RNTester/js/RNTesterApp.ios.js
+++ b/RNTester/js/RNTesterApp.ios.js
@@ -19,6 +19,8 @@ const React = require('react');
 const SnapshotViewIOS = require('./examples/Snapshot/SnapshotViewIOS.ios');
 const URIActionMap = require('./utils/URIActionMap');

+import NativeDevMenu from '../../Libraries/NativeModules/specs/NativeDevMenu';
+
 const {
   AppRegistry,
   AsyncStorage,
@@ -143,6 +145,7 @@ class RNTesterApp extends React.Component<Props, RNTesterNavigationState> {

   UNSAFE_componentWillMount() {
     BackHandler.addEventListener('hardwareBackPress', this._handleBack);
+    NativeDevMenu.show();
   }

   componentDidMount() {
```

Reviewed By: sammy-SC

Differential Revision: D18945861

Pulled By: hramos

fbshipit-source-id: edcf02c5803742c89a845a3e5d72bc7dacae839f
2019-12-17 16:52:29 -08:00
Rick Hanlon 13992f90e4 Reconnect to debugger after reload
Summary:
This diff allows re-connecting to the debugger websocket after reloading so that if, for example, metro has restarted, we'll reconnect to allow for debugging. Previously you would need to kill the app and re-open it to re-register the debugger websocket.

Changelog: [iOS] [Fixed] Reconnect to debugger websocket after metro is restarted.

Reviewed By: motiz88

Differential Revision: D18820399

fbshipit-source-id: ddbfa4476e70a6313c877a050ef2d77c04d1657e
2019-12-06 04:59:22 -08:00
Andres Suarez aee88b6843 Tidy up license headers [3/n]
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: yungsters

Differential Revision: D17952693

fbshipit-source-id: 8fcb8e58a2e04e7a3169f4d525bffc00835768e6
2019-10-16 10:06:34 -07:00
Ashok Menon e6d5f2e80d Make sure requests are sent in sequential order on iOS.
Summary:
blairv recently brought an issue with heap snapshots to our attention:  When
captured from iOS, the viewer would quite regularly hang forever instead of
capturing the snapshot.

Further investigation showed that it was because the message that Hermes sends
to indicate that it had finished sending chunks of the heap snapshot was
arriving to chrome before the last chunk of the snapshot.  This caused Chrome
to believe the snapshot was malformed.

I confirmed that:

 - Sends from the Hermes Inspector were occurring in the correct order.
 - The WebSocket protocol, being built on top of TCP, also preserves order.
 - The Inspector Proxy in Metro was preserving the order of requests it was
   given, but the responses were already in the wrong order when they reached
   it.

This left the code that Hermes' Inspector calls into to send its messages.  On
iOS, the logic to send the request is run on the global dispatch queue which
can and does schedule jobs concurrently with each other.  Because the messages
containing heap snapshot chunks are much larger than the "Ok" message used to
indicate the end of the snapshot, the earlier chunk message would often lose
the race with the later "Ok" message.

There was already a serial background queue used by the websocket server to
schedule the actual sending of the message.  I re-use it in this diff to
process the message as well.

The architecture of the [same code in Android](https://our.intern.facebook.com/intern/diffusion/FBS/browse/master/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java?commit=64c8954ec7be555509437db6944b9a71a350e87c&lines=283) initially seems to be broken in
the same way, but it is not, because AsyncTask does not run tasks concurrently
any more because Google found it exposed too many concurrency bugs to do so.

pakoito, it seems like you might be somewhat familiar with what's going on
here.  Let me know if what I've done is sensible.

Reviewed By: pakoito

Differential Revision: D17106960

fbshipit-source-id: af85ff1753324340bb55fc63048e8bd424c8a983
2019-09-04 05:37:29 -07:00
James Treanor 8131b7bb7b CocoaPods frameworks compatibility: Step 2 (#25619)
Summary:
This is my proposal for fixing `use_frameworks!` compatibility without breaking all `<React/*>` imports I outlined in https://github.com/facebook/react-native/pull/25393#issuecomment-508457700. If accepted, it will fix https://github.com/facebook/react-native/issues/25349.

It builds on the changes I made in https://github.com/facebook/react-native/pull/25496 by ensuring each podspec has a unique value for `header_dir` so that framework imports do not conflict. Every podspec which should be included in the `<React/*>` namespace now includes it's headers from `React-Core.podspec`.

The following pods can still be imported with `<React/*>` and so should not have breaking changes: `React-ART`,`React-DevSupport`, `React-CoreModules`, `React-RCTActionSheet`, `React-RCTAnimation`, `React-RCTBlob`, `React-RCTImage`, `React-RCTLinking`, `React-RCTNetwork`, `React-RCTPushNotification`, `React-RCTSettings`, `React-RCTText`, `React-RCTSettings`, `React-RCTVibration`, `React-RCTWebSocket` .

There are still a few breaking changes which I hope will be acceptable:

- `React-Core.podspec` has been moved to the root of the project. Any `Podfile` that references it will need to update the path.
- ~~`React-turbomodule-core`'s headers now live under `<turbomodule/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511091823.
- ~~`React-turbomodulesamples`'s headers now live under `<turbomodulesamples/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511091823.
- ~~`React-TypeSaferty`'s headers now live under `<TypeSafety/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511040967.
- ~~`React-jscallinvoker`'s headers now live under `<jscallinvoker/*>`~~ Replaced by https://github.com/facebook/react-native/pull/25619#issuecomment-511091823.
- Each podspec now uses `s.static_framework = true`. This means that a minimum of CocoaPods 1.5 ([released in April 2018](http://blog.cocoapods.org/CocoaPods-1.5.0/)) is now required. This is needed so that the ` __has_include` conditions can still work when frameworks are enabled.

Still to do:

- ~~Including `React-turbomodule-core` with `use_frameworks!` enabled causes the C++ import failures we saw in https://github.com/facebook/react-native/issues/25349. I'm sure it will be possible to fix this but I need to dig deeper (perhaps a custom modulemap would be needed).~~ Addressed by 33573511f0.
- I haven't got Fabric working yet. I wonder if it would be acceptable to move Fabric out of the `<React/*>` namespace since it is new? �

## Changelog

[iOS] [Fixed] - Fixed compatibility with CocoaPods frameworks.
Pull Request resolved: https://github.com/facebook/react-native/pull/25619

Test Plan:
### FB

```
buck build catalyst
```

### Sample Project

Everything should work exactly as before, where `use_frameworks!` is not in `Podfile`s. I have a branch on my [sample project](https://github.com/jtreanor/react-native-cocoapods-frameworks) here which has `use_frameworks!` in its `Podfile` to demonstrate this is fixed.

You can see that it works with these steps:

1. `git clone git@github.com:jtreanor/react-native-cocoapods-frameworks.git`
2. `git checkout fix-frameworks-subspecs`
3. `cd ios && pod install`
4. `cd .. && react-native run-ios`

The sample app will build and run successfully. To see that it still works without frameworks, remove `use_frameworks!` from the `Podfile` and do steps 3 and 4 again.

### RNTesterPods

`RNTesterPodsPods` can now work with or without `use_frameworks!`.

1. Go to the `RNTester` directory and run `pod install`.
2. Run the tests in `RNTesterPods.xcworkspace` to see that everything still works fine.
3. Uncomment the `use_frameworks!` line at the top of `RNTester/Podfile` and run `pod install` again.
4. Run the tests again and see that it still works with frameworks enabled.

Reviewed By: PeteTheHeat

Differential Revision: D16465247

Pulled By: PeteTheHeat

fbshipit-source-id: cad837e9cced06d30cc5b372af1c65c7780b9e7a
2019-07-24 23:27:09 -07:00
Min ho Kim 84f5ebe4f9 Fix typos (#25770)
Summary:
Fix typos mostly in comments and some string literals.

## Changelog

[General] [Fixed] - Fix typos
Pull Request resolved: https://github.com/facebook/react-native/pull/25770

Differential Revision: D16437857

Pulled By: cpojer

fbshipit-source-id: ffeb4d6b175e341381352091134f7c97d78c679f
2019-07-23 03:23:11 -07:00
Radosław Pietruszewski 3724810d21 Initial UIKitForMac support (#25427)
Summary:
This PR adds initial support for Project Catalyst a.k.a. UIKitForMac. This is not yet meant for production, but this is enough for RNTester to successfully compile and mostly work :)

Some APIs are not supported on the Mac -- e.g. telephony, and deprecated APIs are removed on Mac ���-- those had to be ifdef'd out via platform checks.

The biggest limitation right now is that I couldn't get Web Socket code to successfully compile, and so there are a lot of temporary platform checks  for that , and the RCTWebSocket.xcodeproj is marked as not supporting UIKitForMac. Again -- temporary, until someone with more knowledge knows how to fix this.

https://github.com/react-native-community/discussions-and-proposals/issues/131

## Changelog

[iOS] [Added] - Fixed compilation for macOS (Project Catalyst) -- not meant for production use yet
Pull Request resolved: https://github.com/facebook/react-native/pull/25427

Test Plan:
- Open RNTester/RNTester.xcodeproj with Xcode 10.2, run it like a normal iOS app -- make sure it compiles and runs correctly (no regression)
- Open the same project with Xcode 11 beta 2 (or higher) on macOS Catalina beta, select "My Mac" as device target, and run -- see that it actually compiles and runs. **Note** there are unfortunately some required steps:
   - change build configuration to Release (because packager doesn't work correctly yet)
   - change development team to yours if Xcode tells you to
   - go to RNTester project → Build phases → Link binary with libraries, and change `platforms` for `libRCTWebSocket.a` to `iOS` (without Mac compatibility). I can't commit that change because it breaks compatibility with earlier Xcode versions

The two extra steps for successful compile will disappear once web socket compilation for Catalyst is fixed

Reviewed By: mmmulani

Differential Revision: D16088263

Pulled By: sammy-SC

fbshipit-source-id: 9c0b932b048e50a8e0f336eaa0612851b1909cae
2019-07-04 10:30:33 -07:00
Mikael Sand d9489c4e9c Don't reconnect inspector if connection refused (#22625)
Summary:
(Together with a pr to react-devtools) Fixes https://github.com/facebook/react-native/issues/21030

[iOS] [Fixed] - Fix infinite retry loop of inspector
Pull Request resolved: https://github.com/facebook/react-native/pull/22625

Differential Revision: D14169392

Pulled By: hramos

fbshipit-source-id: 2e301fd9d458598b62399fc61a9859ad29928483
2019-02-21 12:52:39 -08:00
Eric Lewis 468ae234a6 Fix xcode warnings (#23565)
Summary:
As part of #22609, this fixes yet more warnings.
- Adding more __unused to params.
- Refactors `isPackagerRunning` to use NSURLSession.
- Turns off suspicious comma warnings

[iOS] [Fixed] - Xcode Warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/23565

Differential Revision: D14161151

Pulled By: cpojer

fbshipit-source-id: 339874711eca718fc6151e84737ccc975225d736
2019-02-20 18:46:23 -08:00
Tim Yung a689711f68 RN: Missing Copyright Headers
Summary: Adds copyright headers to all files that are missing them.

Reviewed By: hramos

Differential Revision: D12837494

fbshipit-source-id: 6330a18919676dec9ff2c03b7c9329ed9127d930
2018-10-31 01:37:26 -07:00
Nurzhan Bakibayev 1b65c6d73a Show warning instead of error on duplicate connection
Summary: Show warning instead of error on duplicate connection

Reviewed By: alexeylang

Differential Revision: D9117286

fbshipit-source-id: 81b135584bb3f44e37388de6df9d6386e5fb758a
2018-08-02 03:16:33 -07:00
Paco Estevez Garcia ad2d9e7fab Forward VM version to inspector
Reviewed By: bnham

Differential Revision: D6938018

fbshipit-source-id: c79853ddf835acab86a16ebd539874d29d3aa60a
2018-02-13 08:16:50 -08:00
Ray Shih 88980f2ef7 Implement bundle sync status
Reviewed By: pakoito

Differential Revision: D6807480

fbshipit-source-id: d71f2cecd882c47e79bb71dfb9d03d3597fa4068
2018-02-01 06:18:13 -08:00
Ben Nham 30da2622e2 avoid redbox in handleWrappedEvent
Reviewed By: Hypuk

Differential Revision: D6602420

fbshipit-source-id: 14cf396014d896878032ee4ab67a45700eb6c257
2017-12-19 10:30:52 -08:00
Adam Ernst b1701ccaef Fix RCTInspectorPackagerConnection logspam for real
Reviewed By: danzimm

Differential Revision: D6486113

fbshipit-source-id: f6e661ce95ae89bafce9e0d773b484b28e4f83c4
2017-12-05 10:34:10 -08:00
Adam Ernst ff3dc2ed19 Silence RCTInspectorPackagerConnection logspam
Reviewed By: jingc

Differential Revision: D6480638

fbshipit-source-id: 7610f4136b81fcb16c93920c3b70bf551b4e9ddd
2017-12-04 18:22:51 -08:00
Nurzhan Bakibayev 7d0c128174 Remove 'Debug JS on-device (experimental)' feature
Reviewed By: bnham

Differential Revision: D5706200

fbshipit-source-id: f389222a9266819c5730860a2e3e461eb1068d0e
2017-08-29 04:29:57 -07:00
Paco Estevez Garcia 41504103ce Force the debugger to disconnect before a bundle reload
Reviewed By: bnham

Differential Revision: D5594238

fbshipit-source-id: feff9f179534c8e617f8fa7c8a7b1bc525c07cae
2017-08-14 08:16:52 -07:00
Theo Yaung a6ad4a059a Reduce log level for connection errors
Reviewed By: bnham

Differential Revision: D5523206

fbshipit-source-id: ccc3d0862444c5ff4dc42c4fd00e418e15b2a31e
2017-07-28 18:31:22 -07:00
Paco Estevez Garcia d94f3e4b98 Debugger channel messages should be processed only on a background thread
Reviewed By: bnham

Differential Revision: D5470226

fbshipit-source-id: ccbc351e3f64f2baa8a3c74c5d0c67c44731bf32
2017-07-24 06:45:26 -07:00
Paco Estevez Garcia 90fad3c68b Add app name to PageInfo
Reviewed By: dcaspi

Differential Revision: D5436099

fbshipit-source-id: 73be706fbb36fe7c16b206de7ca3ba0cc3fa019b
2017-07-19 11:47:44 -07:00
Theo Yaung ba2e486b33 Connection management
Reviewed By: javache

Differential Revision: D5171773

fbshipit-source-id: 6421739736f732e021e85474253ab0ddb3804b0a
2017-06-08 07:45:53 -07:00