File size: 638 Bytes
8766bc5 | 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 { _ } from "svelte-i18n";
export class Gradio<T extends Record<string, any>> {
#id: number;
theme: string;
version: string;
// i18n: typeof _;
#el: HTMLElement;
root: string;
constructor(
id: number,
el: HTMLElement,
theme: string,
version: string,
root: string
) {
this.#id = id;
this.theme = theme;
this.version = version;
this.#el = el;
// this.i18n = _;
this.root = root;
}
dispatch<E extends keyof T>(event_name: E, data?: T[E]): void {
const e = new CustomEvent("gradio", {
bubbles: true,
detail: { data, id: this.#id, event: event_name }
});
this.#el.dispatchEvent(e);
}
}
|