mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-10-23 03:31:56 +00:00
Deglobalize ElectronBridge type.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
@@ -15,6 +15,12 @@ import {clipboard} from "electron";
|
||||
// don’t leak anything from the user’s clipboard other than the token
|
||||
// intended for us.
|
||||
|
||||
export interface ClipboardDecrypter {
|
||||
version: number;
|
||||
key: Uint8Array;
|
||||
pasted: Promise<string>;
|
||||
}
|
||||
|
||||
export class ClipboardDecrypterImpl implements ClipboardDecrypter {
|
||||
version: number;
|
||||
key: Uint8Array;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import {remote} from "electron";
|
||||
import {EventEmitter} from "events";
|
||||
|
||||
import type {ClipboardDecrypter} from "./clipboard-decrypter";
|
||||
import {ClipboardDecrypterImpl} from "./clipboard-decrypter";
|
||||
import type {NotificationData} from "./notification";
|
||||
import {newNotification} from "./notification";
|
||||
@@ -8,6 +9,21 @@ import {ipcRenderer} from "./typed-ipc-renderer";
|
||||
|
||||
type ListenerType = (...args: any[]) => void;
|
||||
|
||||
export interface ElectronBridge {
|
||||
send_event: (eventName: string | symbol, ...args: unknown[]) => boolean;
|
||||
on_event: (eventName: string, listener: ListenerType) => void;
|
||||
new_notification: (
|
||||
title: string,
|
||||
options: NotificationOptions,
|
||||
dispatch: (type: string, eventInit: EventInit) => boolean,
|
||||
) => NotificationData;
|
||||
get_idle_on_system: () => boolean;
|
||||
get_last_active_on_system: () => number;
|
||||
get_send_notification_reply_message_supported: () => boolean;
|
||||
set_send_notification_reply_message_supported: (value: boolean) => void;
|
||||
decrypt_clipboard: (version: number) => ClipboardDecrypter;
|
||||
}
|
||||
|
||||
let notificationReplySupported = false;
|
||||
// Indicates if the user is idle or not
|
||||
let idle = false;
|
||||
@@ -41,7 +57,7 @@ const electron_bridge: ElectronBridge = {
|
||||
notificationReplySupported = value;
|
||||
},
|
||||
|
||||
decrypt_clipboard: (version: number): ClipboardDecrypterImpl =>
|
||||
decrypt_clipboard: (version: number): ClipboardDecrypter =>
|
||||
new ClipboardDecrypterImpl(version),
|
||||
};
|
||||
|
||||
|
@@ -1,5 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
type ElectronBridge = import("./electron-bridge").ElectronBridge;
|
||||
|
||||
interface CompatElectronBridge extends ElectronBridge {
|
||||
readonly idle_on_system: boolean;
|
||||
readonly last_active_on_system: number;
|
||||
|
21
typings.d.ts
vendored
21
typings.d.ts
vendored
@@ -2,24 +2,3 @@ declare namespace Electron {
|
||||
// https://github.com/electron/typescript-definitions/issues/170
|
||||
interface IncomingMessage extends NodeJS.ReadableStream {}
|
||||
}
|
||||
|
||||
interface ClipboardDecrypter {
|
||||
version: number;
|
||||
key: Uint8Array;
|
||||
pasted: Promise<string>;
|
||||
}
|
||||
|
||||
interface ElectronBridge {
|
||||
send_event: (eventName: string | symbol, ...args: unknown[]) => boolean;
|
||||
on_event: (eventName: string, listener: (...args: any[]) => void) => void;
|
||||
new_notification: (
|
||||
title: string,
|
||||
options: NotificationOptions,
|
||||
dispatch: (type: string, eventInit: EventInit) => boolean,
|
||||
) => import("./app/renderer/js/notification").NotificationData;
|
||||
get_idle_on_system: () => boolean;
|
||||
get_last_active_on_system: () => number;
|
||||
get_send_notification_reply_message_supported: () => boolean;
|
||||
set_send_notification_reply_message_supported: (value: boolean) => void;
|
||||
decrypt_clipboard: (version: number) => ClipboardDecrypter;
|
||||
}
|
||||
|
Reference in New Issue
Block a user