2021-01-14 18:07:05 +00:00
|
|
|
// Copyright 2019-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { Metadata } from 'sharp';
|
2019-12-19 23:27:02 +00:00
|
|
|
|
2020-09-14 21:56:35 +00:00
|
|
|
declare global {
|
2021-01-14 18:07:05 +00:00
|
|
|
// We want to extend `window`'s properties, so we need an interface.
|
|
|
|
// eslint-disable-next-line no-restricted-syntax
|
2020-09-14 21:56:35 +00:00
|
|
|
interface Window {
|
2020-09-28 18:40:26 +00:00
|
|
|
processStickerImage: ProcessStickerImageFn;
|
2020-09-14 21:56:35 +00:00
|
|
|
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;
|
2021-01-21 18:13:23 +00:00
|
|
|
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;
|