2021-01-14 12:07:05 -06:00
|
|
|
// Copyright 2019-2021 Signal Messenger, LLC
|
2020-10-30 15:34:04 -05:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 14:15:33 -05:00
|
|
|
import type { Metadata } from 'sharp';
|
2019-12-19 18:27:02 -05:00
|
|
|
|
2020-09-14 14:56:35 -07:00
|
|
|
declare global {
|
2021-01-14 12:07:05 -06:00
|
|
|
// We want to extend `window`'s properties, so we need an interface.
|
|
|
|
// eslint-disable-next-line no-restricted-syntax
|
2020-09-14 14:56:35 -07:00
|
|
|
interface Window {
|
2020-09-28 13:40:26 -05:00
|
|
|
processStickerImage: ProcessStickerImageFn;
|
2020-09-14 14:56:35 -07:00
|
|
|
encryptAndUpload: EncryptAndUploadFn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-28 13:40:26 -05:00
|
|
|
export type StickerImageData = {
|
2019-12-17 15:25:57 -05:00
|
|
|
buffer: Buffer;
|
|
|
|
src: string;
|
|
|
|
path: string;
|
2021-01-21 12:13:23 -06:00
|
|
|
meta: Metadata;
|
2019-12-17 15:25:57 -05:00
|
|
|
};
|
|
|
|
|
2022-06-13 14:39:35 -07:00
|
|
|
type ProcessStickerImageFn = (
|
|
|
|
path: string | undefined
|
|
|
|
) => Promise<StickerImageData>;
|
2019-12-17 15:25:57 -05:00
|
|
|
|
2020-09-28 13:40:26 -05:00
|
|
|
export type StickerData = { imageData?: StickerImageData; emoji?: string };
|
2019-12-17 15:25:57 -05:00
|
|
|
export type PackMetaData = { packId: string; key: string };
|
|
|
|
|
|
|
|
export type EncryptAndUploadFn = (
|
|
|
|
manifest: { title: string; author: string },
|
|
|
|
stickers: Array<StickerData>,
|
2022-06-13 14:39:35 -07:00
|
|
|
cover: StickerImageData | undefined,
|
2019-12-17 15:25:57 -05:00
|
|
|
onProgress?: () => unknown
|
|
|
|
) => Promise<PackMetaData>;
|
|
|
|
|
2020-09-28 13:40:26 -05:00
|
|
|
export const { encryptAndUpload, processStickerImage } = window;
|