2019-12-19 23:27:02 +00:00
|
|
|
import { Metadata } from 'sharp';
|
|
|
|
|
2020-09-14 21:56:35 +00:00
|
|
|
declare global {
|
|
|
|
interface Window {
|
|
|
|
convertToWebp: ConvertToWebpFn;
|
|
|
|
encryptAndUpload: EncryptAndUploadFn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-17 20:25:57 +00:00
|
|
|
export type WebpData = {
|
|
|
|
buffer: Buffer;
|
|
|
|
src: string;
|
|
|
|
path: string;
|
2019-12-19 23:27:02 +00:00
|
|
|
meta: Metadata & { pages?: number }; // Pages is not currently in the sharp metadata type
|
2019-12-17 20:25:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export type ConvertToWebpFn = (
|
|
|
|
path: string,
|
|
|
|
width?: number,
|
|
|
|
height?: number
|
|
|
|
) => Promise<WebpData>;
|
|
|
|
|
|
|
|
export type StickerData = { webp?: WebpData; emoji?: string };
|
|
|
|
export type PackMetaData = { packId: string; key: string };
|
|
|
|
|
|
|
|
export type EncryptAndUploadFn = (
|
|
|
|
manifest: { title: string; author: string },
|
|
|
|
stickers: Array<StickerData>,
|
|
|
|
cover: WebpData,
|
|
|
|
onProgress?: () => unknown
|
|
|
|
) => Promise<PackMetaData>;
|
|
|
|
|
2020-09-14 21:56:35 +00:00
|
|
|
export const { encryptAndUpload, convertToWebp } = window;
|