Skip to content

Commit

Permalink
fix: allow console.log to use CSS (gronxb#29)
Browse files Browse the repository at this point in the history
* fix: fix unable to find

* feat: add showing object in devtools

* fix: allow css in react-native dev-tools

* Update packages/react-native/src/integrations/console.ts

Co-authored-by: Sungyu Kang  <[email protected]>

---------

Co-authored-by: Sungyu Kang <[email protected]>
  • Loading branch information
doyoonkim12345 and gronxb authored Feb 15, 2024
1 parent 65a2bc5 commit c2c8091
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions packages/react-native/src/integrations/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,24 @@ export const INJECT_DEBUG = `
export type LogType = "log" | "error" | "warn";

export const handleLog = (type: LogType, message: string) => {
const parsedMessage = JSON.parse(message);
const [formatMessage, ...parsedMessage] = JSON.parse(message);
const webviewMark = "(WebView) ";

const webviewMarkedMessage =
typeof formatMessage === "string"
? [webviewMark + formatMessage, ...parsedMessage]
: [webviewMark, formatMessage, ...parsedMessage];
switch (type) {
case "log": {
console.log("(WebView)", parsedMessage);
console.log(...webviewMarkedMessage);
break;
}
case "error": {
console.error("(WebView)", parsedMessage);
console.error(...webviewMarkedMessage);
break;
}
case "warn": {
console.warn("(WebView)", parsedMessage);
console.warn(...webviewMarkedMessage);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
"devDependencies": {
"esbuild": "^0.19.4"
}
}
}

0 comments on commit c2c8091

Please sign in to comment.