2.95 kBTypeScriptView Raw
1import { IpcMainEvent, WebContents } from '@theia/electron/shared/electron';
2import { ContributionProvider } from '../../common/contribution-provider';
3import { MessagingContribution } from '../../node/messaging/messaging-contribution';
4import { ElectronConnectionHandler } from '../../electron-common/messaging/electron-connection-handler';
5import { ElectronMainApplicationContribution } from '../electron-main-application';
6import { ElectronMessagingService } from './electron-messaging-service';
7import { AbstractChannel, Channel, ChannelMultiplexer, MessageProvider } from '../../common/message-rpc/channel';
8import { Emitter, WriteBuffer } from '../../common';
9/**
10 * This component replicates the role filled by `MessagingContribution` but for Electron.
11 * Unlike the WebSocket based implementation, we do not expect to receive
12 * connection events. Instead, we'll create channels based on incoming `open`
13 * events on the `ipcMain` channel.
14 * This component allows communication between renderer process (frontend) and electron main process.
15 */
16export declare class ElectronMessagingContribution implements ElectronMainApplicationContribution, ElectronMessagingService {
17 protected readonly messagingContributions: ContributionProvider<ElectronMessagingService.Contribution>;
18 protected readonly connectionHandlers: ContributionProvider<ElectronConnectionHandler>;
19 protected readonly channelHandlers: MessagingContribution.ConnectionHandlers<Channel>;
20 /**
21 * Each electron window has a main channel and its own multiplexer to route multiple client messages the same IPC connection.
22 */
23 protected readonly windowChannelMultiplexer: Map<number, {
24 channel: ElectronWebContentChannel;
25 multiplexer: ChannelMultiplexer;
26 }>;
27 protected init(): void;
28 protected handleIpcEvent(event: IpcMainEvent, data: Uint8Array): void;
29 protected createWindowChannelData(sender: Electron.WebContents): {
30 channel: ElectronWebContentChannel;
31 multiplexer: ChannelMultiplexer;
32 };
33 /**
34 * Creates the main channel to a window.
35 * @param sender The window that the channel should be established to.
36 */
37 protected createWindowMainChannel(sender: WebContents): ElectronWebContentChannel;
38 protected disposeMultiplexer(windowId: number, multiplexer: ChannelMultiplexer, reason: string): void;
39 onStart(): void;
40 ipcChannel(spec: string, callback: (params: any, channel: Channel) => void): void;
41}
42/**
43 * Used to establish a connection between the ipcMain and the Electron frontend (window).
44 * Messages a transferred via electron IPC.
45 */
46export declare class ElectronWebContentChannel extends AbstractChannel {
47 protected readonly sender: Electron.WebContents;
48 readonly onMessageEmitter: Emitter<MessageProvider>;
49 constructor(sender: Electron.WebContents);
50 getWriteBuffer(): WriteBuffer;
51}
52//# sourceMappingURL=electron-messaging-contribution.d.ts.map
\No newline at end of file