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

24 Коммитов

Автор SHA1 Сообщение Дата
Rubén Norte 8abe737068 Centralize public access to LogBox in LogBox module
Summary:
Some components are using `LogBoxData` directly, forcing logs to be shown on the screen even when LogBox is uninstalled. This changes all accesses to `LogBoxData` to go through `LogBox` so `uninstall` is used correctly.

It also changes when LogBox is installed, moving it from `AppContainer` to `InitializeCore` (which happens earlier) so we can capture more logs in LogBox.

Changelog: [General][Changed] Initialized LogBox earlier and centralized access in LogBox module

Reviewed By: rickhanlonii

Differential Revision: D27999361

fbshipit-source-id: 1115ef6b71e08cc33743d205da0064fbe9a74a0e
2021-05-04 10:58:24 -07:00
Micha Reiser 93377ff508 Remove "use strict" directive from ES Modules
Summary:
ES Modules implicitly enable strict mode. Adding the "use strict" directive is, therefore, not required.

This diff removes all "use strict" directives from ES modules.

Changelog:

[Internal]

Reviewed By: motiz88

Differential Revision: D26172715

fbshipit-source-id: 57957bcbb672c4c3e62b1db633cf425c1c9d6430
2021-02-02 11:12:56 -08:00
Rick Hanlon f28c7505fa Fix LogBox.ignoreAllLogs used with no argument (#29310)
Summary:
When you call `LogBox.ignoreAllLogs()` it should ignore logs.

This fixes a bug that made this equivalent to `LogBox.ignoreAllLogs(false)`

## Changelog

[General] [Fixed] - LogBox.ignoreAllLogs() should ignore logs

Pull Request resolved: https://github.com/facebook/react-native/pull/29310

Test Plan: Added tests

Reviewed By: TheSavior

Differential Revision: D22448436

Pulled By: rickhanlonii

fbshipit-source-id: 6ba12b9d9c1f29cf3ac503946ac5ca0097425a7a
2020-07-08 18:51:58 -07:00
Janic Duplessis d3b937f990 Make sure LogBox is not included in production bundles (#28984)
Summary:
I was doing some bundle inspection and noticed the LogBox module was included. It does amount to around 15kb so I think it is worth making sure it is not there.

To fix it I moved some imports to require inside __DEV__ blocks to make sure metro is able to remove these imports.

## Changelog

[General] [Fixed] - Make sure LogBox is not included in production bundles
Pull Request resolved: https://github.com/facebook/react-native/pull/28984

Test Plan: Tested using react-native-bundle-visualizer and made sure nothing from LogBox was included in the bundle after these changes.

Reviewed By: TheSavior

Differential Revision: D21794466

Pulled By: rickhanlonii

fbshipit-source-id: 6cb0c0a89633e9850019bd61478c35e9c21638dc
2020-06-02 18:00:45 -07:00
Rick Hanlon ec0c65c4b2 Improve component stack parsing
Summary:
Update the error log message parsing to fix missing component stacks in console.errors.

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D20801985

fbshipit-source-id: ae544200315a8c3c0310e8370bc38b0546734f38
2020-04-01 16:43:15 -07:00
Michael Bolin 0b9ea60b4f Back out "Upgrade Prettier from 1.17 to 2.0.2."
Differential Revision: D20639755

fbshipit-source-id: 5028563f9cf0527a30b4259daac50cdc03934bfd
2020-03-24 21:47:35 -07:00
Michael Bolin cf44650b3f Upgrade Prettier from 1.17 to 2.0.2.
Summary:
This gets us on the latest Prettier 2.x:
https://prettier.io/blog/2020/03/21/2.0.0.html

Notably, this adds support for TypeScript 3.8,
which introduces new syntax, such as `import type`.

Reviewed By: zertosh

Differential Revision: D20636268

fbshipit-source-id: fca5833d003804333a05ba16325bbbe0e06d6c8a
2020-03-24 20:24:47 -07:00
Rick Hanlon 9c64bd5739 Properly handle LogBox errors during tests
Summary:
This diff fixes an issue where errors in LogBox during tests would cause the tests to crash.

The crash is due to the NativeExceptionsManager module not being mocked (as all native module need to be in tests). The fix is to properly mock the NativeExceptionManger.

This fix exposed an infinite loop issue where failures in LogBox will be logged to the ExceptionManager, which logs to the console, which logs to LogBox, creating a loop. This diff also fixes that look by moving the LogBox internal error check to the top of the monkey patched console methods.

Changelog: [Internal]

Differential Revision: D20428590

fbshipit-source-id: 7289a480c99ba8dee67772178b7629afb40b330a
2020-03-19 20:31:01 -07:00
Rick Hanlon c6d5019573 Interpolate strings before giving them to abd
Summary:
This diff interpolates logs before passing them downstream so that we don't see a bunch of logs with "%s" everywhere.

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D20034903

fbshipit-source-id: 966917aa21ba07af3fb114e6a6931d4bbf860040
2020-02-21 09:33:00 -08:00
Rick Hanlon 372771dc8c Remove LogBox.ignoreWarnings
Summary:
This method isn't necessary for the migration to LogBox because we have a YellowBoxDeprecated module instructing users to use LogBox.ignoreLogs (so no old code should be calling LogBox.ignoreWarnings).

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D19950302

fbshipit-source-id: 4850884e770f812273978b9a205f5b914e5a9d2f
2020-02-19 18:01:43 -08:00
Rick Hanlon 87f1e22434 Deprecate console.disableYellowBox in favor of LogBox.ignoreAllLogs()
Summary:
We're replacing console.disableYellowBox (untyped, global hack, only warnings) with LogBox.ignoreAllLogs() (typed, local method, handles errors and warnings).

Changelog: [General] [Removed] Replace console.disableYellowBox with LogBox.ignoreAllLogs.

Reviewed By: TheSavior

Differential Revision: D19813775

fbshipit-source-id: ffd33ddbca0276a27d23b5b6023a15aef761934e
2020-02-18 06:19:45 -08:00
Rick Hanlon 587979552d LogBox - Update to use it's own root for the inspector
Summary:
Apologies for the large diff, it was difficult to break down.

This diff is a major refactor of LogBox that:
- Separates LogBoxNotification and LogBoxInspector
- Moves them each to their own container
- Updates AppContainer to only render the notification
- Updates the native logbox root to render the inspector
- Adds withSubscription HOC to manage subscribing to LogBoxData
- Simplifies LogBox to export an object instead of a component

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D18750011

fbshipit-source-id: 639885d29e55e125892d1c2b6bbf2826f27d78db
2019-12-10 02:31:38 -08:00
George Zahariev 8553e1acc4 Exact-by-default codemod for react-native-github
Summary:
We are rolling out exact-by-default syntax to xplat/js.

I had to manually move around some comments to preserve proper placement.

Changelog: [Internal]

Reviewed By: jbrown215

Differential Revision: D18633611

fbshipit-source-id: 48f7468dcc55b1d00985419d035a61c6820b3abe
2019-11-21 09:42:57 -08:00
Rick Hanlon b346970016 LogBox - Minor error message formatting fixes
Summary:
Adds better handling of component stacks for warnings and clarifies why we ignore `(ADVICE)` warnings.

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D18575693

fbshipit-source-id: f4eacbf74c62cd079f2c441951849fb03e0941dd
2019-11-18 13:47:42 -08:00
Rick Hanlon c1d9a1f099 LogBox - Add support for filtering warnings
Summary:
This diff adds the ability to set a custom warning filter function.

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D18422114

fbshipit-source-id: a2949a013f478093a2fabc003c496353b8fdbc3a
2019-11-11 16:12:43 -08:00
Rick Hanlon fe82f402a9 LogBox - Rework how fatals and syntax errors are handled
Summary:
This diff makes a few changes to how errors and warnings are handled in LogBox:

- Soft errors continue to notify the user collapsed.
- Fatal errors pop up full screen over the content, but are dismissible.
- Syntax errors pop up full screen, and are **not** dismissible.
- Removed the "Reload" button on fatals, and added back the dismiss/close.
- Removed all buttons from syntax errors so users are encouraged to fix it and safe without reloading.

To do this we needed to:
- Move the selectedLogIndex state out of the component and up to the rest of the log state.
- Change the way popping a log works, it's now done by setting selectedLogIndex at log time instead of deriving it at render time, that means `selectedLogIndex` is now the sole state value for deciding if the log inspector is open or not
- Whenever the state is updated, find a syntax error if it's there, instead of doing this at render time

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D18421089

fbshipit-source-id: d2c4937f666f1302ed1a7b1b9c6679b0509136c5
2019-11-11 16:12:43 -08:00
Rick Hanlon 5eddf1d79a LogBox - Show native redbox when failing to handle logs in LogBox
Summary:
This diff adds error handling to logbox so that if there is an error either when parsing logs or when rendering LogBox, we show a native redbox with the error that was thrown and a message explaining that it's an internal React Native error.

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D18394788

fbshipit-source-id: 5d74d58e4b28ef6d863079e83677fb23ef4ccb34
2019-11-08 07:41:09 -08:00
Rick Hanlon 059e54a6e3 LogBox - hide only non-fatal errors for disableLogBox
Summary:
This diff updates the handling for `console.disableLogBox` so that:

- It does not disable fatals and syntax errors
- When there is a fatal or syntax error, the hidden logs are still shown and browsable

Changelog: [Internal]

Differential Revision: D18339684

fbshipit-source-id: 906122cc19ce50b3a21a42ae455206796953bcf3
2019-11-06 10:12:01 -08:00
Rick Hanlon a09ab64874 Don't pass through ignored warnings to console
Summary:
This diff check if warnings are ignored before calling through to the wrapped console.warn implementation below, thus preventing ignored logs from being sent to adb/metro/flipper and cleaning them up a bit.

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D18239936

fbshipit-source-id: 533beced3e66ad1a4d0810933862c63a0b88628c
2019-10-31 16:26:44 -07:00
Rick Hanlon 1807a6afee LogBox - Dismiss errors and warnings independently
Summary:
This diff makes the warning and error notifications independently dismissible

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D18218937

fbshipit-source-id: 198b18d7f177fcb59506a4adfed5b1ce0a331aba
2019-10-31 16:26:43 -07:00
Rick Hanlon b2bafa06fa LogBox - Better error support
Summary:
This diff adds support for thrown exceptions to redboxes, and hides the native redbox when we show an error in LogBox.

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D18212064

fbshipit-source-id: 92031d554968bcb079f81568673ae85697c8f5ad
2019-10-31 16:26:43 -07:00
Rick Hanlon c5aa26da41 Add log level to support errors
Summary:
This diff adds a level to LogBox logs so that we can store and display errors in later diffs

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D18091101

fbshipit-source-id: 21661d28a7945bdcb56702e2a03ab3612c11fe35
2019-10-28 10:10:54 -07:00
Rick Hanlon cc056907cf Clean up API for LogBoxLogParser
Summary:
This diff cleans up two functions from:

```
LogBoxLogData.add({args: ['A']});
LogBoxLogParser({args: ['A']});
```

to:

```
LogBoxLogData.add(['A']);
LogBoxLogParser.parseLog(['A']);
```

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D18056462

fbshipit-source-id: be6108069fc24b1f25d1382ad31c314183c793f8
2019-10-22 14:13:20 -07:00
Rick Hanlon 7d4121da02 Add LogBox for warnings
Summary:
# Overview

This diff adds the initial LogBox redesign implementing only Warnings for now. The following diffs include the tests for this, as well as a way to enable an experimental flag to opt-in.

Changelog: [Internal]

## Changes

To init LogBox, we've taken the core of YellowBox and rewritten it entirely.

Differences from Yellowbox include:
- Data model re-written
  - More performant
  - Allows a future listing of logs in order
  - Allows a future toggle to show ignored logs
  - Moves category into a property
  - Groups by the same sequential message (as chrome does) instead of by category
  - Does not store dupes of the same messages, only a count
- UI revamp
  - Color and design refresh
  - Does not spam UI with logs
  - Only shows the most recent log
  - Dismiss all button is always in one place
  - Allows navigating through all of the warnings in the list, not just ones in the same category
  - Collapses message to 5 lines (tap to expand)
  - Collapses unrelated stack frames (tap to expand)
  - Moves React stack to it's own section
  - Formats React Stack like a stack frame
  - Collapses any React frames over 3 deep (tap to expand)
  - Adds a "Meta" information (to be expanded on later)
  - De-emphasizes the source map indicator
- Better Engineering
  - Rewrote almost all components to hooks (will follow up with the rest)
  - Added more tests for Data files
  - Added testes for UI components (previously there were none)
  - Refactored some imperative render code to declarative

## Known Problems

- The first major problem is that in the collapsed state (which is meant to model the FBLogger on Comet) does not show the user how many logs are in the console (only the count of the current log).
- The way we're doing symbolication and navigation is slow. We will follow up with perf improvements
- The React Stack logic is too simple and missed cases
- We need to get properly scaled images for the close button

## What's next

Next up we'll be:
- Move over Moti's improvements to filtering and YellowBox changes since I started this
- Adding in Errors, and not using the native redbox when LogBox is available
- Adding in a list of all errors and a way to navigate to it
- Adding in Logs, so users can see console.log in the app
- Make React stack frames clickable
- And many more

Reviewed By: cpojer

Differential Revision: D17965726

fbshipit-source-id: 2f28584ecb7e3ca8d3df034ea1e1a4a50e018c02
2019-10-21 21:08:02 -07:00