File size: 1,674 Bytes
44aec57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/**
 * Single entry point for both the host shell and the embedded app.
 *
 * Rendering decision
 * ──────────────────
 *   url has `?embed=1`  β†’  we're inside the host's iframe; load
 *                          `./embed` (the Marionette UI).
 *   otherwise           β†’  we're the top-level visit; load the
 *                          host shell from `@reachy-mini/host/auto`
 *                          and let it iframe us back via `?embed=1`.
 *
 * Host delivery strategy
 * ──────────────────────
 * Today the host ships inside this bundle through a `file:` npm dep
 * (`./vendor/reachy-mini-host`). Once `@reachy-mini/host` is published
 * to npm + jsdelivr we will swap the static import for a dynamic CDN
 * import; that single-line change moves the host out of every app's
 * bundle and lets a single publish update every deployed Space on the
 * next visit.
 */

const params = new URLSearchParams(window.location.search);
const isEmbed = params.get("embed") === "1";

if (isEmbed) {
  void import("./embed");
} else {
  void import("@reachy-mini/host/auto").then(({ mountHost }) => {
    mountHost({
      appName: "Marionette",
      appIconUrl: "/icon.svg",
      appEmoji: "🎭",
      enableMicrophone: true,
      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,
    });
  });
}