signal-desktop/sticker-creator/util/preload.ts

30 lines
824 B
TypeScript
Raw Normal View History

import { Metadata } from 'sharp';
declare global {
interface Window {
2020-09-28 18:40:26 +00:00
processStickerImage: ProcessStickerImageFn;
encryptAndUpload: EncryptAndUploadFn;
}
}
2020-09-28 18:40:26 +00:00
export type StickerImageData = {
2019-12-17 20:25:57 +00:00
buffer: Buffer;
src: string;
path: string;
meta: Metadata & { pages?: number }; // Pages is not currently in the sharp metadata type
2019-12-17 20:25:57 +00:00
};
2020-09-28 18:40:26 +00:00
type ProcessStickerImageFn = (path: string) => Promise<StickerImageData>;
2019-12-17 20:25:57 +00:00
2020-09-28 18:40:26 +00:00
export type StickerData = { imageData?: StickerImageData; emoji?: string };
2019-12-17 20:25:57 +00:00
export type PackMetaData = { packId: string; key: string };
export type EncryptAndUploadFn = (
manifest: { title: string; author: string },
stickers: Array<StickerData>,
2020-09-28 18:40:26 +00:00
cover: StickerImageData,
2019-12-17 20:25:57 +00:00
onProgress?: () => unknown
) => Promise<PackMetaData>;
2020-09-28 18:40:26 +00:00
export const { encryptAndUpload, processStickerImage } = window;