( code: string, id: string, environmentName: string | undefined, )
| 52 | } |
| 53 | |
| 54 | export function injectRuntimeBridge( |
| 55 | code: string, |
| 56 | id: string, |
| 57 | environmentName: string | undefined, |
| 58 | ): string | undefined { |
| 59 | // Only isolated server environments need the bridge. The client environment |
| 60 | // has `window`; the in-process RunnableDevEnvironment is handled by the |
| 61 | // runtime global guard inside the injected code. |
| 62 | if (!environmentName || environmentName === 'client') return undefined |
| 63 | if (!isEventClientModule(id, code)) return undefined |
| 64 | return `${code}\n${generateRuntimeBridgeCode()}` |
| 65 | } |
| 66 | |
| 67 | interface BridgeHotChannel { |
| 68 | on?: (event: string, cb: (data: any) => void) => void |
no test coverage detected