0
Fork 0
mirror of https://github.com/penpot/penpot-plugins.git synced 2025-01-25 08:08:40 -05:00
penpot-plugins/libs/plugin-types/index.d.ts

66 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-04-15 16:13:29 +02:00
export interface PenpotFile {
2024-02-28 12:54:37 +01:00
id: string;
2024-04-15 16:13:29 +02:00
name: string;
revn: number;
}
2024-04-12 10:45:39 +02:00
2024-04-15 16:13:29 +02:00
export interface PenpotPage {
id: string;
name: string;
2024-04-12 10:45:39 +02:00
findShapes(): PenpotShape[];
2024-02-28 12:54:37 +01:00
}
2024-04-15 16:13:29 +02:00
export interface PenpotFill {
fillColor: string;
fillOpacity: number;
}
export interface PenpotShape {
2024-02-28 12:54:37 +01:00
id: string;
2024-04-15 16:13:29 +02:00
name: string;
fills: PenpotFill[]
2024-02-28 12:54:37 +01:00
}
2024-03-27 13:57:02 +01:00
export interface EventsMap {
2024-04-12 10:45:39 +02:00
pagechange: PenpotPage;
filechange: PenpotFile;
2024-03-07 10:34:06 +01:00
selectionchange: string[];
2024-04-12 10:45:39 +02:00
themechange: PenpotTheme;
2024-02-27 14:50:38 +01:00
}
2024-04-12 10:45:39 +02:00
export type PenpotTheme = 'light' | 'dark';
2024-03-08 12:27:58 +01:00
2024-03-27 13:57:02 +01:00
export interface Penpot {
2024-02-27 14:50:38 +01: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 13:57:02 +01:00
log: (...data: unknown[]) => 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-04-12 10:45:39 +02:00
getFile: () => PenpotFile | null;
getPage: () => PenpotPage | null;
getCurrentPage: () => PenpotPage | null;
getSelected: () => string[];
2024-04-15 16:13:29 +02:00
getSelectedShapes(): PenpotShape[];
2024-04-12 10:45:39 +02:00
getTheme: () => PenpotTheme;
2024-03-04 14:11:34 +01:00
fetch: typeof fetch;
2024-02-27 14:50:38 +01:00
}
2024-03-27 13:57:02 +01:00
declare global {
2024-02-27 14:50:38 +01:00
const penpot: Penpot;
}