Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR aims to improve the debugging experience by making it similar to Chrome DevTools. It improves the preview, formatting and truncating of console logs and splits large arrays into smaller changes, where chunks are fetched on expand - similarly as `vscode-js-debug` does. The more detailed previews are generated based on `preview` property from the debugger, so it may not work on older RN versions. The main idea was not to reinvent the wheel but to reuse as much of https://github.com/microsoft/vscode-js-debug as possible. Thus we forked it with small patch software-mansion-labs/vscode-js-debug@a579416 that allows us to build it - otherwise the TS on our side failed. `vscode-js-debug` sits in our repo as a git submodule and no additional steps should be necessary (preinstall script should take care of pulling it, installing and building). |Before|After| |-|-| |<img width="615" alt="logs-before" src="https://github.com/user-attachments/assets/a018e8f7-3762-4f95-9e00-10fa3449bb14" />|<img width="605" alt="logs-after" src="https://github.com/user-attachments/assets/938f7444-7636-48a0-8b63-ea0d51a861bd" />| |Before|After| |-|-| |<img width="613" alt="large-arrays-before" src="https://github.com/user-attachments/assets/f8ab617e-7655-42cb-9923-0938ad56e401" />|<img width="477" alt="large-arrays-after" src="https://github.com/user-attachments/assets/a27909cd-43c7-4350-9cd5-c7a1a9069778" />| ### How Has This Been Tested: Update `printLogs` method with: ``` function printLogs() { const string = 'string'; const object = { key: 'value', key2: 'value2' }; const set = new Set([1, 2, 3, 3]); const array1000 = new Array(1000).fill(0).map((_, i) => i); const array101 = new Array(101).fill(0).map((_, i) => array1000); const int = 1; const float = 1.1; const func = function() {}; const anonymousFunc = () => {}; console.log(string, array1000, array101, object, set, int, float, func, anonymousFunc); } ``` Tested on react-native-76, react-native-73. --------- Co-authored-by: Krzysztof Magiera <[email protected]>
- Loading branch information