Add getReactSource to extract React component source location

- Add bippy library for React fiber introspection
- Create build-bippy.ts and build-selector-generator.ts using Bun.build
- Use CDP Runtime.evaluate instead of addScriptTag to bypass CSP
- Add getReactSource utility function exposed in MCP VMContext
- Works on local React dev servers with JSX transform (not production builds)
This commit is contained in:
Tommy D. Rossi
2025-12-29 16:09:52 +01:00
parent 56e4e1566e
commit 5e0cd2dd98
10 changed files with 366 additions and 60 deletions
+48 -2
View File
@@ -38,7 +38,7 @@ importers:
version: link:../playwriter
zustand:
specifier: ^5.0.8
version: 5.0.8
version: 5.0.8(@types/react@19.2.7)(react@19.2.3)
devDependencies:
'@types/chrome':
specifier: ^0.0.315
@@ -124,6 +124,9 @@ importers:
'@vitest/ui':
specifier: ^4.0.8
version: 4.0.8(vitest@4.0.8)
bippy:
specifier: ^0.5.27
version: 0.5.27(@types/react@19.2.7)(react@19.2.3)
image-size:
specifier: ^2.0.2
version: 2.0.2
@@ -887,6 +890,14 @@ packages:
'@types/node@24.10.1':
resolution: {integrity: sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==}
'@types/react-reconciler@0.28.9':
resolution: {integrity: sha512-HHM3nxyUZ3zAylX8ZEyrDNd2XZOnQ0D5XfunJF5FLQnZbHHYq4UWvW1QfelQNXv1ICNkwYhfxjwfnqivYB6bFg==}
peerDependencies:
'@types/react': '*'
'@types/react@19.2.7':
resolution: {integrity: sha512-MWtvHrGZLFttgeEj28VXHxpmwYbor/ATPYbBfSFZEIRK0ecCFLl2Qo55z52Hss+UV9CRN7trSeq1zbgx7YDWWg==}
'@types/retry@0.12.0':
resolution: {integrity: sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==}
@@ -1090,6 +1101,11 @@ packages:
resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==}
engines: {node: '>=8'}
bippy@0.5.27:
resolution: {integrity: sha512-LvGYTQm5cMqEhnUT2tr6mSE1mrhmX/xxu3jiypHAscThhxC+9SWdaQW8Nye5CT/sR79LObNJlQpOUgi4DopTMg==}
peerDependencies:
react: '>=17.0.1'
body-parser@2.2.0:
resolution: {integrity: sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==}
engines: {node: '>=18'}
@@ -1228,6 +1244,9 @@ packages:
resolution: {integrity: sha512-OytmFH+13/QXONJcC75QNdMtKpceNk3u8ThBjyyYjkEcy/ekBwR1mMAuNvi3gdBPW3N5TlCzQ0WZw8H0lN/bDw==}
engines: {node: '>=20'}
csstype@3.2.3:
resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}
data-uri-to-buffer@4.0.1:
resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==}
engines: {node: '>= 12'}
@@ -2220,6 +2239,10 @@ packages:
resolution: {integrity: sha512-9G8cA+tuMS75+6G/TzW8OtLzmBDMo8p1JRxN5AZ+LAp8uxGA8V8GZm4GQ4/N5QNQEnLmg6SS7wyuSmbKepiKqA==}
engines: {node: '>= 0.10'}
react@19.2.3:
resolution: {integrity: sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==}
engines: {node: '>=0.10.0'}
read-yaml-file@1.1.0:
resolution: {integrity: sha512-VIMnQi/Z4HT2Fxuwg5KrY174U1VdUIASQVWXXyqtNRtxSr9IYkn1rsI6Tb6HsrHCmB7gVpNwX6JxPTHcH6IoTA==}
engines: {node: '>=6'}
@@ -2727,6 +2750,7 @@ packages:
whatwg-encoding@3.1.1:
resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==}
engines: {node: '>=18'}
deprecated: Use @exodus/bytes instead for a more spec-conformant and faster implementation
whatwg-mimetype@4.0.0:
resolution: {integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==}
@@ -3622,6 +3646,14 @@ snapshots:
dependencies:
undici-types: 7.16.0
'@types/react-reconciler@0.28.9(@types/react@19.2.7)':
dependencies:
'@types/react': 19.2.7
'@types/react@19.2.7':
dependencies:
csstype: 3.2.3
'@types/retry@0.12.0': {}
'@types/uuid@10.0.0': {}
@@ -3818,6 +3850,13 @@ snapshots:
binary-extensions@2.3.0: {}
bippy@0.5.27(@types/react@19.2.7)(react@19.2.3):
dependencies:
'@types/react-reconciler': 0.28.9(@types/react@19.2.7)
react: 19.2.3
transitivePeerDependencies:
- '@types/react'
body-parser@2.2.0:
dependencies:
bytes: 3.1.2
@@ -3989,6 +4028,8 @@ snapshots:
css-tree: 3.1.0
optional: true
csstype@3.2.3: {}
data-uri-to-buffer@4.0.1: {}
data-uri-to-buffer@6.0.2:
@@ -5060,6 +5101,8 @@ snapshots:
iconv-lite: 0.7.0
unpipe: 1.0.0
react@19.2.3: {}
read-yaml-file@1.1.0:
dependencies:
graceful-fs: 4.2.11
@@ -5660,4 +5703,7 @@ snapshots:
zod@3.25.76: {}
zustand@5.0.8: {}
zustand@5.0.8(@types/react@19.2.7)(react@19.2.3):
optionalDependencies:
'@types/react': 19.2.7
react: 19.2.3