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

37 lines
868 B
TypeScript
Raw Normal View History

2023-04-20 15:59:17 +00:00
// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2024-08-26 17:16:10 +00:00
import { contextBridge, ipcRenderer, webUtils } from 'electron';
2023-04-20 15:59:17 +00:00
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,
});
}
2023-04-20 15:59:17 +00:00
);
contextBridge.exposeInMainWorld(
'installStickerPack',
(packId: string, key: string) =>
ipcRenderer.invoke('install-sticker-pack', packId, key)
);
2024-08-26 17:16:10 +00:00
contextBridge.exposeInMainWorld('getFilePath', (file: File) =>
webUtils.getPathForFile(file)
);