feat: console.log에서 %c 등 포맷 지정자 지원#37
Merged
Merged
Conversation
브라우저 DevTools처럼 console.log의 %c, %s, %d, %i, %f, %o, %O, %% 포맷 지정자를 파싱해서 렌더링해요. %c는 CSS 문자열을 파싱해 이후 텍스트 세그먼트에 인라인 스타일로 적용돼요. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
console.log의 포맷 지정자(%c,%s,%d,%i,%f,%o,%O,%%)를 파싱해 렌더링해요.%c는 이어지는 CSS 문자열을 파싱해서 이후 텍스트 세그먼트에 인라인 스타일로 적용해요. 새%c가 등장하면 스타일이 교체돼요(Chrome DevTools 동작과 동일).setupLogMonitor)과LogEntry타입은 건드리지 않고, 렌더링 시점(LogPanel)에서만 파싱해요. 원본args를 그대로 보존해 호환성을 유지해요.구현
package/src/utils/parseFormat.ts—parseConsoleArgs(args)→{ segments, rest }. 정규식 기반 스캔으로 포맷 지정자별 분기 처리.package/src/utils/parseCssStyle.ts— CSS 문자열 →Record<string, string>변환.url()/expression()/@import같은 위험 패턴은 drop.package/src/components/LogPanel.tsx—log.args.map부분을segments+rest렌더링으로 교체. Lynx가 지원 안 하는 CSS 속성은 런타임에서 무시되도록 둬요.Test plan
yarn dev:example로 example 앱 실행 후 "Test CSS Console Log" 버튼 탭[Css Test]배지가 어두운 배경 + 핑크 텍스트로 렌더되는지 확인screen:home/tab:feed는 주황 볼드로 렌더되는지 확인mixed format: alice got 42 points (59.95fps)텍스트로 치환되는지 확인%o예제에서 객체가 기존 토글 UI로 렌더되고 뒤의'end'도 함께 표시되는지 확인escaped % percent로%%가 리터럴%로 표시되는지 확인