FEA-Bench / testbed /gradio-app__gradio /js /app /src /gradio_helper.ts
hc99's picture
Add files using upload-large-folder tool
8766bc5 verified
raw
history blame
638 Bytes
// 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);
}
}