/ src / main.ts
main.ts
 1  import { mount } from "svelte";
 2  import "./app.css";
 3  import App from "./App.svelte";
 4  import { whenDOMReady, whenOdysseyLoaded } from "@abcnews/env-utils";
 5  import { type Island, observeIslands } from "./lib/islands";
 6  
 7  const islands: Island[] = [
 8    {
 9      name: "app",
10      component: App,
11    },
12  ];
13  
14  const mountIsland = ({
15    island,
16    entry,
17  }: {
18    island: Island;
19    entry: IntersectionObserverEntry;
20  }) => {
21    mount(island.component, { target: entry.target as HTMLElement });
22  };
23  
24  async function init() {
25    await whenDOMReady;
26    await whenOdysseyLoaded;
27  
28    observeIslands({ islands, onObservation: mountIsland });
29  }
30  
31  const app = init();
32  export default app;