Owns the host<->guest postMessage channel for one embedded TeXbrain iframe.
Usage: const client = new EditorBridgeClient(iframe.contentWindow, EDITOR_ORIGIN, { getThemeState: () => useThemeStore.getState(), getInitialDoc: () => ({ mainFile, files, projectName }), fs: new ApiFsResponder(...), onCompiled: (status, log, pdf) => { ... }, }); // later, on host theme change: client.pushTheme(); // ... client.sendCompile(); client.destroy(); // on unmount
the iframe's contentWindow (the embedded editor)
the editor's origin (EDITOR_ORIGIN); pinned, never '*'
host hooks (theme/doc/fs/compiled callbacks)
Remove the message listener. Call on iframe unmount.
Push the current host theme to the editor (e.g. on a theme change).
Ask the editor to compile its current buffers now.
Mount a document/project into the editor.
Owns the host<->guest postMessage channel for one embedded TeXbrain iframe.
Usage: const client = new EditorBridgeClient(iframe.contentWindow, EDITOR_ORIGIN, { getThemeState: () => useThemeStore.getState(), getInitialDoc: () => ({ mainFile, files, projectName }), fs: new ApiFsResponder(...), onCompiled: (status, log, pdf) => { ... }, }); // later, on host theme change: client.pushTheme(); // ... client.sendCompile(); client.destroy(); // on unmount