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

39 lines
1.1 KiB
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 type { Metadata } from 'sharp';
2022-12-01 01:44:17 +00:00
import type { ProcessStickerImageErrorType } from '../window/phase3-sticker-functions';
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;
2022-12-01 01:44:17 +00:00
ProcessStickerImageError: ProcessStickerImageErrorType;
}
}
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
};
type ProcessStickerImageFn = (
path: string | undefined
) => 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>,
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;