-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
65 lines (53 loc) · 1.59 KB
/
main.ts
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import "../../styles/main.css";
import PageIcon from "./page-icon";
import PageTitle from "./page-title";
import Title from "./title";
import { assertNotNullable } from "./util";
import Pings from "./pings";
import User from "./user";
const pings = new Pings({
// TODO Avoid that any
workerUrl: (window as any).app.pingWorkerUrl
});
const user = new User();
new PageTitle(user, pings);
new PageIcon(user, pings);
new Title({
element: assertNotNullable(document.querySelector("#title")),
pings,
user
});
import(/* webpackChunkName: "chart" */ "./chart").then(
({ default: Chart }) =>
new Chart({
element: assertNotNullable(document.querySelector("#chart")),
pings,
user
})
);
import(/* webpackChunkName: "offline-support" */ "./offline-support").then(
({ default: OfflineSupport }) =>
new OfflineSupport({
// TODO Avoid that any
serviceWorkerUrl: (window as any).app.serviceWorkerUrl,
domElement: assertNotNullable(document.querySelector("#offline-support"))
})
);
// TODO Compose audio.ts and audio/controls.ts into a single importable
const whenAudioControls = import(
/* webpackChunkName: "audio-controls" */
"./audio/controls"
).then(({ default: AudioControls }) => AudioControls);
const whenAudio = import(
/* webpackChunkName: "audio" */
"./audio"
).then(({ default: Audio }) => Audio);
Promise.all([whenAudioControls, whenAudio]).then(
([AudioControls, Audio]) =>
new AudioControls({
audio: new Audio(user, pings),
domElement: assertNotNullable(
document.querySelector("#controls-placeholder")
)
})
);