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

35 lines
960 B
TypeScript
Raw Normal View History

// Copyright 2019-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import { Metadata } from 'sharp';
declare global {
// We want to extend `window`'s properties, so we need an interface.
// eslint-disable-next-line no-restricted-syntax
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;
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;