2024-04-15 09:13:29 -05:00
|
|
|
export interface PenpotFile {
|
2024-02-28 06:54:37 -05:00
|
|
|
id: string;
|
2024-04-15 09:13:29 -05:00
|
|
|
name: string;
|
|
|
|
revn: number;
|
|
|
|
}
|
2024-04-12 03:45:39 -05:00
|
|
|
|
2024-04-15 09:13:29 -05:00
|
|
|
export interface PenpotPage {
|
|
|
|
id: string;
|
|
|
|
name: string;
|
2024-04-18 10:11:48 -05:00
|
|
|
getShapeById(id: string): PenpotShape | null;
|
2024-04-12 03:45:39 -05:00
|
|
|
findShapes(): PenpotShape[];
|
2024-02-28 06:54:37 -05:00
|
|
|
}
|
|
|
|
|
2024-04-15 09:13:29 -05:00
|
|
|
export interface PenpotFill {
|
|
|
|
fillColor: string;
|
|
|
|
fillOpacity: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface PenpotShape {
|
2024-02-28 06:54:37 -05:00
|
|
|
id: string;
|
2024-04-15 09:13:29 -05:00
|
|
|
name: string;
|
|
|
|
fills: PenpotFill[]
|
2024-02-28 06:54:37 -05:00
|
|
|
}
|
|
|
|
|
2024-03-27 07:57:02 -05:00
|
|
|
export interface EventsMap {
|
2024-04-12 03:45:39 -05:00
|
|
|
pagechange: PenpotPage;
|
|
|
|
filechange: PenpotFile;
|
2024-03-07 04:34:06 -05:00
|
|
|
selectionchange: string[];
|
2024-04-12 03:45:39 -05:00
|
|
|
themechange: PenpotTheme;
|
2024-02-27 08:50:38 -05:00
|
|
|
}
|
|
|
|
|
2024-04-12 03:45:39 -05:00
|
|
|
export type PenpotTheme = 'light' | 'dark';
|
2024-03-08 06:27:58 -05:00
|
|
|
|
2024-03-27 07:57:02 -05:00
|
|
|
export interface Penpot {
|
2024-02-27 08:50:38 -05:00
|
|
|
ui: {
|
|
|
|
open: (
|
|
|
|
name: string,
|
|
|
|
url: string,
|
|
|
|
options: { width: number; height: number }
|
|
|
|
) => void;
|
|
|
|
sendMessage: (message: unknown) => void;
|
|
|
|
onMessage: <T>(callback: (message: T) => void) => void;
|
|
|
|
};
|
2024-03-27 07:57:02 -05:00
|
|
|
log: (...data: unknown[]) => 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-04-12 03:45:39 -05:00
|
|
|
getFile: () => PenpotFile | null;
|
|
|
|
getPage: () => PenpotPage | null;
|
|
|
|
getCurrentPage: () => PenpotPage | null;
|
|
|
|
getSelected: () => string[];
|
2024-04-15 09:13:29 -05:00
|
|
|
getSelectedShapes(): PenpotShape[];
|
2024-04-12 03:45:39 -05:00
|
|
|
getTheme: () => PenpotTheme;
|
2024-03-04 08:11:34 -05:00
|
|
|
fetch: typeof fetch;
|
2024-02-27 08:50:38 -05:00
|
|
|
}
|
|
|
|
|
2024-03-27 07:57:02 -05:00
|
|
|
declare global {
|
2024-02-27 08:50:38 -05:00
|
|
|
const penpot: Penpot;
|
|
|
|
}
|