dillon1000/react

Commit

chore[react-devtools]: improve console arguments formatting before passing it to original console (#29873)

Stacked on https://github.com/facebook/react/pull/29869.

## Summary

When using ANSI escape sequences, we construct a message in the
following way: `console.<method>('\x1b...%s\x1b[0m',
userspaceArgument1?, userspaceArgument2?, userspaceArgument3?, ...)`.

This won't dim all arguments, if user had something like `console.log(1,
2, 3)`, we would only apply it to `1`, since this is the first
arguments, so we need to:
- inline everything whats possible into a single string, while
preserving console substitutions defined by the user
- omit css and object substitutions, since we can't really inline them
and will delegate in to the environment

## How did you test this change?

Added some tests, manually inspected that it works well for web and
native cases.
Browse files
Changed paths5 files
First-parent comparison
M packages/react-devtools-shared/src/__tests__/utils-test.js ModifiedM packages/react-devtools-shared/src/backend/console.js ModifiedM packages/react-devtools-shared/src/backend/renderer.js ModifiedM packages/react-devtools-shared/src/backend/utils.js ModifiedM packages/react-devtools-shared/src/hook.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…