Spaces:
Running
Running
File size: 1,954 Bytes
a519434 82a4679 a519434 82a4679 a519434 a99b699 a519434 e6c8aff a519434 82a4679 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | import { ReachyMini } from "@pollen-robotics/reachy-mini-sdk";
(window as unknown as { ReachyMini: typeof ReachyMini }).ReachyMini = ReachyMini;
window.dispatchEvent(new Event("reachymini:ready"));
const params = new URLSearchParams(window.location.search);
const isEmbed = params.get("embedded") === "1" || params.get("embed") === "1";
// The host shell's HF OAuth redirect returns to `/?code=…` (or `?error=…`);
// resume the host directly so the sign-in round-trip completes.
const isOAuthReturn = params.has("code") || params.has("error");
const launched = sessionStorage.getItem("cookaiware:launched") === "1";
function bootHost(): Promise<void> {
sessionStorage.setItem("cookaiware:launched", "1");
const root = document.getElementById("root");
if (root) root.innerHTML = "";
return import("@pollen-robotics/reachy-mini-sdk/host/auto").then(({ mountHost }) => {
mountHost({
appName: "CookAIware",
appIconUrl: "/icon.png",
appEmoji: "🍲",
enableMicrophone: true,
// Dev shortcuts from .env.local (gitignored), see guide §9.
devToken:
import.meta.env.VITE_HF_TOKEN && import.meta.env.VITE_HF_USERNAME
? {
token: import.meta.env.VITE_HF_TOKEN as string,
userName: import.meta.env.VITE_HF_USERNAME as string,
}
: undefined,
clientId: import.meta.env.VITE_HF_OAUTH_CLIENT_ID as string | undefined,
});
});
}
if (import.meta.env.DEV && params.get("uidev") === "1") {
// Dev-only UI harness without a robot session.
void import("./devUi");
} else if (isEmbed) {
void import("./embed");
} else if (isOAuthReturn || launched) {
// Returning from sign-in, or already launched this session → host shell.
void bootHost();
} else {
// Fresh visit → informational landing page; "Connect your Reachy" hands off.
void import("./landing").then(({ renderLanding }) => renderLanding(() => void bootHost()));
}
|