Karolis' playground dv-svelte / master src / components / common.ts
master

Tree @master (Download .tar.gz)

common.ts @masterraw · history · blame

import type { ComponentConstructorOptions, ComponentProps } from "svelte";
import Label from "./label.svelte";
import Switch from "./switch.svelte";
import Wye from "./wye.svelte";
import Track from "./track.svelte";


export const Components = {
    Track,
    Label,
    Switch,
    Wye,
} as const

type ComponentMap = typeof Components

type props<T> = T extends { new(options: ComponentConstructorOptions<infer P>): any } ? P : never
export type tile = {
    [t in keyof ComponentMap]: {
        this: t,
        props: props<ComponentMap[t]>
    }
}[keyof ComponentMap]

export const edgePositions: { [k: number]: [number, number] } = {
    1: [0, 1],
    2: [0.5, 1],
    3: [1, 1],
    4: [0, 0.5],
    // 5: undefined,
    6: [1, 0.5],
    7: [0, 0],
    8: [0.5, 0],
    9: [1, 0],
}