(target, prop)
| 202 | // it honest (command names + signatures are checked on both sides). |
| 203 | export const desktopBridge = new Proxy(electronBridge, { |
| 204 | get(target, prop) { |
| 205 | if (typeof prop !== "string") return undefined; |
| 206 | |
| 207 | // resolveWorkspaceListSelectedId is a pure function, not an IPC call |
| 208 | if (prop === "resolveWorkspaceListSelectedId") { |
| 209 | return resolveWorkspaceListSelectedId; |
| 210 | } |
| 211 | |
| 212 | const cached = target[prop]; |
| 213 | if (cached) return cached; |
| 214 | |
| 215 | const fn = async (...args: unknown[]) => { |
| 216 | const invokeDesktop = window.__OPENWORK_ELECTRON__?.invokeDesktop; |
| 217 | if (!invokeDesktop) { |
| 218 | throw new Error(`Electron desktop helper is unavailable: ${prop}`); |
| 219 | } |
| 220 | // The Proxy is the one dynamic point in the bridge: `prop` is whatever |
| 221 | // property was accessed, already constrained by the DesktopBridge |
| 222 | // surface this Proxy is exported as. |
| 223 | return invokeDesktop( |
| 224 | prop as DesktopCommandName, |
| 225 | ...(args as DesktopCommandArgs<DesktopCommandName>), |
| 226 | ); |
| 227 | }; |
| 228 | target[prop] = fn; |
| 229 | return fn; |
| 230 | }, |
| 231 | }) as unknown as DesktopBridge; |
| 232 | |
| 233 | // --------------------------------------------------------------------------- |
no outgoing calls
no test coverage detected