|
4 | 4 | <script type="module">
|
5 | 5 | const host = "https://localhost:2233"
|
6 | 6 |
|
7 |
| - globalThis["__DEBUG_PROXY__"] = true |
8 |
| - |
9 |
| - fetch(`${host}`) |
10 |
| - .then((res) => res.text()) |
11 |
| - .then((html) => { |
12 |
| - const parser = new DOMParser() |
13 |
| - const doc = parser.parseFromString(html, "text/html") |
14 |
| - document.head.innerHTML = doc.head.innerHTML |
15 |
| - document.body.innerHTML = doc.body.innerHTML |
16 |
| - |
17 |
| - const scripts = doc.querySelectorAll("script") |
18 |
| - scripts.forEach((script) => { |
19 |
| - const $script = document.createElement("script") |
20 |
| - $script.type = "module" |
21 |
| - $script.crossOrigin = script.crossOrigin |
22 |
| - |
23 |
| - if (script.src) { |
24 |
| - $script.src = script.src |
25 |
| - } else if (script.innerHTML) { |
26 |
| - $script.innerHTML = script.innerHTML |
27 |
| - } else { |
28 |
| - return |
29 |
| - } |
30 |
| - |
31 |
| - document.body.appendChild($script) |
32 |
| - }) |
33 |
| - |
34 |
| - scripts.forEach((script) => { |
35 |
| - script.remove() |
36 |
| - }) |
37 |
| - }) |
| 7 | + const createRefreshRuntimeScript = ` |
| 8 | +import RefreshRuntime from "${host}/@react-refresh"; |
| 9 | +RefreshRuntime.injectIntoGlobalHook(window); |
| 10 | +window.$RefreshReg$ = () => {}; |
| 11 | +window.$RefreshSig$ = () => (type) => type; |
| 12 | +window.__vite_plugin_react_preamble_installed__ = true; |
| 13 | +` |
| 14 | + const $script = document.createElement("script") |
| 15 | + $script.innerHTML = createRefreshRuntimeScript |
| 16 | + $script.type = "module" |
| 17 | + document.head.appendChild($script) |
38 | 18 | </script>
|
| 19 | + |
| 20 | + <title>Debug Proxy</title> |
| 21 | + <script type="module" src="./__debug_proxy.ts"></script> |
39 | 22 | </head>
|
40 | 23 | <body></body>
|
41 | 24 | </html>
|
0 commit comments