2024-02-27 14:50:38 +01:00
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
|
|
|
2024-02-28 12:54:37 +01:00
|
|
|
interface Page {
|
|
|
|
name: string;
|
|
|
|
id: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface File {
|
|
|
|
name: string;
|
|
|
|
id: string;
|
|
|
|
revn: number;
|
|
|
|
}
|
|
|
|
|
2024-02-27 14:50:38 +01:00
|
|
|
interface EventsMap {
|
2024-02-28 12:54:37 +01:00
|
|
|
pagechange: Page;
|
|
|
|
filechange: File;
|
2024-03-07 10:34:06 +01:00
|
|
|
selectionchange: string[];
|
2024-03-08 12:27:58 +01:00
|
|
|
themechange: Theme;
|
2024-02-27 14:50:38 +01:00
|
|
|
}
|
|
|
|
|
2024-03-08 12:27:58 +01:00
|
|
|
type Theme = 'light' | 'dark';
|
|
|
|
|
2024-02-27 14:50:38 +01:00
|
|
|
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 12:54:37 +01:00
|
|
|
log: (...data: any[]) => void;
|
2024-02-27 14:50:38 +01: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 12:54:37 +01:00
|
|
|
off: <T extends keyof EventsMap>(
|
|
|
|
type: T,
|
|
|
|
callback: (event: EventsMap[T]) => void
|
|
|
|
) => void;
|
2024-03-05 11:36:56 +01:00
|
|
|
getFileState: () => File | null;
|
|
|
|
getPageState: () => Page | null;
|
2024-03-08 12:27:58 +01:00
|
|
|
getSelection: () => string[];
|
|
|
|
getTheme: () => Theme;
|
2024-03-04 14:11:34 +01:00
|
|
|
fetch: typeof fetch;
|
2024-02-27 14:50:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
declare namespace globalThis {
|
|
|
|
const penpot: Penpot;
|
|
|
|
}
|