summaryrefslogtreecommitdiff
path: root/src/apps/index.ts
blob: ab9453e86b867bd67cf2aad468004df2111226f8 (plain)
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
import { Music } from "./music";
import { Edit } from "./edit_rich";

import { JSX } from "preact";
import { Source, SourceTypes } from "$/apps/source";
import { Signal } from "@preact/signals";
import { Browser } from "./browser";
import { Image } from "./image";
import { Video } from "./video";
import { Audio } from "./audio";

type AppProps = {
    source: Signal<Source>,
    title: Signal<string | undefined>,
    contentReady: Signal<boolean>,
    sizingFinished: Signal<boolean>
}

// *sigh* i'd like to make props *required*, but ts doesn't let me
// https://stackoverflow.com/questions/75481900/can-i-make-an-argument-required-in-a-typescript-function-type
export type App = (props: AppProps) => JSX.Element;

type AppRegistry = {
    [SourceType in SourceTypes]: App
}

export const APP_REGISTRY: AppRegistry = Object.create({
    listen: Music,
    text: Edit,
    link: Browser,
    image: Image,
    video: Video,
    audio: Audio
});