| /** | |
| * Single entry point for both the host shell and the embedded app. | |
| * | |
| * Rendering decision | |
| * ββββββββββββββββββ | |
| * url has `?embedded=1` β we're inside the host's iframe; load | |
| * `./embed` (the actual emotions UI). | |
| * otherwise β we're the top-level visit; load the | |
| * host shell from `@pollen-robotics/reachy-mini-sdk/host/auto` | |
| * and let it iframe us back via `?embedded=1`. | |
| * | |
| * SDK bootstrapping | |
| * βββββββββββββββββ | |
| * The host shell and the embed client both consume `window.ReachyMini` | |
| * (constructor injected by the SDK). Historically that global was set | |
| * by a `<script type="module">` tag in `index.html` pointing at a | |
| * jsdelivr CDN URL; this file now statically imports the SDK from | |
| * the `@pollen-robotics/reachy-mini-sdk` npm package and assigns the | |
| * constructor onto `window` synchronously, BEFORE the dynamic import | |
| * of the host module resolves. We still dispatch the `reachymini:ready` | |
| * event so the embed's wait loop takes its fast path immediately. | |
| * | |
| * This file is intentionally tiny - everything heavy lives in | |
| * `./embed` (the app) or `@pollen-robotics/reachy-mini-sdk/host` (the shell). | |
| */ | |
| 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); | |
| // Accept both `?embedded=1` (current, legacy-compatible naming) and | |
| // `?embed=1` (transient name used by an intermediate host refactor). | |
| // Tolerating both means mobile builds and host vendor dist that | |
| // pre-date this revert can still boot the embed entry correctly, | |
| // regardless of redeploy order. | |
| const isEmbed = | |
| params.get('embedded') === '1' || params.get('embed') === '1'; | |
| if (isEmbed) { | |
| void import('./embed'); | |
| } else { | |
| void import('@pollen-robotics/reachy-mini-sdk/host/auto').then(({ mountHost }) => { | |
| mountHost({ | |
| appName: 'Emotions', | |
| appIconUrl: '/icon.svg', | |
| appEmoji: 'π', | |
| enableMicrophone: false, | |
| 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, | |
| }); | |
| }); | |
| } | |