mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-08-27 22:04:01 +02:00
Add the Yaak Bridge so a browser tab can run the real engine
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
23e7229e63
commit
99a318224f
@@ -1,14 +1,30 @@
|
||||
import { createBridgePlatform } from "./bridge";
|
||||
import { bridgeConfig, promptForToken, shouldUseBridge } from "./connect";
|
||||
import { setPlatform } from "./registry";
|
||||
import { createTauriPlatform } from "./tauri";
|
||||
|
||||
// Desktop is the only host today, so it is installed unconditionally and
|
||||
// synchronously — several modules call commands while the module graph is still
|
||||
// evaluating, so there is no later moment to do this in.
|
||||
// This line is the swap point, and it has to run synchronously: several modules
|
||||
// call commands while the module graph is still evaluating, so there is no
|
||||
// later moment to install a host in.
|
||||
//
|
||||
// This line is the swap point. A browser build selects its own host here, and
|
||||
// because nothing else in the app imports a host directly, that is the whole
|
||||
// change.
|
||||
setPlatform(createTauriPlatform());
|
||||
// Both hosts are constructible without waiting for anything. The bridge host
|
||||
// opens its connection in the background and queues calls made before it lands,
|
||||
// which is why picking a host here does not mean blocking on one.
|
||||
if (shouldUseBridge()) {
|
||||
const config = bridgeConfig();
|
||||
if (config == null) {
|
||||
// No token yet: put the connect form on screen and install a host that
|
||||
// never connects. Boot then stalls at its own top-level await rather than
|
||||
// failing somewhere that doesn't explain itself — and it stalls in the one
|
||||
// place already designed to wait, which keeps this file synchronous.
|
||||
promptForToken();
|
||||
setPlatform(createBridgePlatform(window.location.origin, null));
|
||||
} else {
|
||||
setPlatform(createBridgePlatform(config.url, config.token));
|
||||
}
|
||||
} else {
|
||||
setPlatform(createTauriPlatform());
|
||||
}
|
||||
|
||||
export * from "./capabilities";
|
||||
export { platform, setPlatform } from "./registry";
|
||||
|
||||
Reference in New Issue
Block a user