()
| 16 | * EventClient protocol is identical across the wire (see design doc). |
| 17 | */ |
| 18 | export function generateRuntimeBridgeCode(): string { |
| 19 | return ` |
| 20 | ;(function __tsdRuntimeBridge() { |
| 21 | if (typeof import.meta === 'undefined' || !import.meta.hot) return; |
| 22 | if (!globalThis.__TANSTACK_EVENT_TARGET__) { |
| 23 | var target = new EventTarget(); |
| 24 | globalThis.__TANSTACK_EVENT_TARGET__ = target; |
| 25 | |
| 26 | // Complete EventClient's connect handshake locally so queued events flush. |
| 27 | target.addEventListener('tanstack-connect', function () { |
| 28 | target.dispatchEvent(new CustomEvent('tanstack-connect-success')); |
| 29 | }); |
| 30 | |
| 31 | // Worker -> Vite dev server. |
| 32 | target.addEventListener('tanstack-dispatch-event', function (e) { |
| 33 | import.meta.hot.send('tsd:to-server', e.detail); |
| 34 | }); |
| 35 | |
| 36 | // Vite dev server -> worker listeners. |
| 37 | import.meta.hot.on('tsd:to-client', function (event) { |
| 38 | target.dispatchEvent(new CustomEvent(event.type, { detail: event })); |
| 39 | target.dispatchEvent(new CustomEvent('tanstack-devtools-global', { detail: event })); |
| 40 | }); |
| 41 | } |
| 42 | })(); |
| 43 | ` |
| 44 | } |
| 45 | |
| 46 | function isEventClientModule(id: string, code: string): boolean { |
| 47 | const isEventClientPath = |
no outgoing calls
no test coverage detected