0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 21:53:27 -05:00
penpot-exporter-figma-plugin/ui-src/context/messages.ts
Jordi Sala Morales 1f8f4bf539
Add more loaders so we can track the progress better (#145)
* Add more loaders so we can track the progress better

* fix lint
2024-06-06 17:24:59 +02:00

58 lines
1.1 KiB
TypeScript

import { PenpotDocument } from '@ui/types';
import { Steps } from '.';
export type MessageData = { pluginMessage?: PluginMessage };
type PluginMessage =
| PenpotDocumentMessage
| CustomFontsMessage
| ChangesDetectedMessage
| ProgressStepMessage
| ProgressCurrentItemMessage
| ProgressTotalItemsMessage
| ProgressProcessedItemsMessage;
type PenpotDocumentMessage = {
type: 'PENPOT_DOCUMENT';
data: PenpotDocument;
};
type CustomFontsMessage = {
type: 'CUSTOM_FONTS';
data: string[];
};
type ChangesDetectedMessage = {
type: 'CHANGES_DETECTED';
};
type ProgressStepMessage = {
type: 'PROGRESS_STEP';
data: Steps;
};
type ProgressCurrentItemMessage = {
type: 'PROGRESS_CURRENT_ITEM';
data: string;
};
type ProgressTotalItemsMessage = {
type: 'PROGRESS_TOTAL_ITEMS';
data: number;
};
type ProgressProcessedItemsMessage = {
type: 'PROGRESS_PROCESSED_ITEMS';
data: number;
};
export const sendMessage = (pluginMessage: PluginMessage) => {
window.dispatchEvent(
new MessageEvent<MessageData>('message', {
data: {
pluginMessage
}
})
);
};