Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 6x 6x | import type RendererAPI from "./setup";
export type WindowWithAPI = {
API: typeof RendererAPI;
};
// Use a Proxy so window.API is accessed lazily at call time rather than at
// module evaluation time. This matters for the web app where window.API is
// set by installWebRendererApi() after modules have already been loaded.
const API = new Proxy({} as typeof RendererAPI, {
get(_target, prop: string) {
return (window as unknown as WindowWithAPI).API[
prop as keyof typeof RendererAPI
];
},
});
export default API;
|