2024-02-27 08:50:38 -05:00
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
|
|
|
2024-02-28 06:54:37 -05:00
|
|
|
interface Page {
|
|
|
|
name: string;
|
|
|
|
id: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface File {
|
|
|
|
name: string;
|
|
|
|
id: string;
|
|
|
|
revn: number;
|
|
|
|
}
|
|
|
|
|
2024-02-27 08:50:38 -05:00
|
|
|
interface EventsMap {
|
2024-02-28 06:54:37 -05:00
|
|
|
pagechange: Page;
|
|
|
|
filechange: File;
|
2024-02-27 08:50:38 -05:00
|
|
|
selectionchange: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Penpot {
|
|
|
|
ui: {
|
|
|
|
open: (
|
|
|
|
name: string,
|
|
|
|
url: string,
|
|
|
|
options: { width: number; height: number }
|
|
|
|
) => void;
|
|
|
|
sendMessage: (message: unknown) => void;
|
|
|
|
onMessage: <T>(callback: (message: T) => void) => void;
|
|
|
|
};
|
2024-02-28 06:54:37 -05:00
|
|
|
log: (...data: any[]) => void;
|
2024-02-27 08:50:38 -05:00
|
|
|
setTimeout: (callback: () => void, time: number) => void;
|
|
|
|
closePlugin: () => void;
|
|
|
|
on: <T extends keyof EventsMap>(
|
|
|
|
type: T,
|
|
|
|
callback: (event: EventsMap[T]) => void
|
|
|
|
) => void;
|
2024-02-28 06:54:37 -05:00
|
|
|
off: <T extends keyof EventsMap>(
|
|
|
|
type: T,
|
|
|
|
callback: (event: EventsMap[T]) => void
|
|
|
|
) => void;
|
2024-03-05 05:36:56 -05:00
|
|
|
getFileState: () => File | null;
|
|
|
|
getPageState: () => Page | null;
|
2024-03-04 08:11:34 -05:00
|
|
|
getSelection: () => string | null;
|
|
|
|
fetch: typeof fetch;
|
2024-02-27 08:50:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
declare namespace globalThis {
|
|
|
|
const penpot: Penpot;
|
|
|
|
}
|