signal-desktop/ts/windows/sticker-creator/preload.ts
2024-05-15 15:26:37 -07:00

32 lines
759 B
TypeScript

// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { contextBridge, ipcRenderer } from 'electron';
let onProgress: (() => void) | undefined;
ipcRenderer.on('art-creator:onUploadProgress', () => {
onProgress?.();
});
contextBridge.exposeInMainWorld(
'uploadStickerPack',
async (
manifest: Uint8Array,
stickers: Readonly<Uint8Array>,
newOnProgress: (() => void) | undefined
): Promise<string> => {
onProgress = newOnProgress;
return ipcRenderer.invoke('art-creator:uploadStickerPack', {
manifest,
stickers,
});
}
);
contextBridge.exposeInMainWorld(
'installStickerPack',
(packId: string, key: string) =>
ipcRenderer.invoke('install-sticker-pack', packId, key)
);