-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
window.d.ts
615 lines (570 loc) · 22.1 KB
/
window.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
// Copyright 2020-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
// Captures the globals put in place by preload.js, background.js and others
import { DeepPartial, Store } from 'redux';
import * as Backbone from 'backbone';
import * as Underscore from 'underscore';
import moment from 'moment';
import PQueue from 'p-queue/dist';
import { Ref } from 'react';
import { imageToBlurHash } from './util/imageToBlurHash';
import * as Util from './util';
import {
ConversationModelCollectionType,
MessageModelCollectionType,
MessageAttributesType,
ReactionAttributesType,
} from './model-types.d';
import { TextSecureType } from './textsecure.d';
import { Storage } from './textsecure/Storage';
import {
ChallengeHandler,
IPCRequest as IPCChallengeRequest,
} from './challenge';
import { WebAPIConnectType } from './textsecure/WebAPI';
import { CallingClass } from './services/calling';
import * as Groups from './groups';
import * as Crypto from './Crypto';
import * as Curve from './Curve';
import * as RemoteConfig from './RemoteConfig';
import * as OS from './OS';
import { getEnvironment } from './environment';
import * as zkgroup from './util/zkgroup';
import { LocalizerType, BodyRangesType, BodyRangeType } from './types/Util';
import * as EmbeddedContact from './types/EmbeddedContact';
import * as Errors from './types/errors';
import { ConversationController } from './ConversationController';
import { ReduxActions } from './state/types';
import { createStore } from './state/createStore';
import { createApp } from './state/roots/createApp';
import { createChatColorPicker } from './state/roots/createChatColorPicker';
import { createConversationDetails } from './state/roots/createConversationDetails';
import { createForwardMessageModal } from './state/roots/createForwardMessageModal';
import { createGroupLinkManagement } from './state/roots/createGroupLinkManagement';
import { createGroupV1MigrationModal } from './state/roots/createGroupV1MigrationModal';
import { createGroupV2JoinModal } from './state/roots/createGroupV2JoinModal';
import { createGroupV2Permissions } from './state/roots/createGroupV2Permissions';
import { createLeftPane } from './state/roots/createLeftPane';
import { createMessageDetail } from './state/roots/createMessageDetail';
import { createConversationNotificationsSettings } from './state/roots/createConversationNotificationsSettings';
import { createPendingInvites } from './state/roots/createPendingInvites';
import { createSafetyNumberViewer } from './state/roots/createSafetyNumberViewer';
import { createShortcutGuideModal } from './state/roots/createShortcutGuideModal';
import { createStickerManager } from './state/roots/createStickerManager';
import { createStickerPreviewModal } from './state/roots/createStickerPreviewModal';
import * as appDuck from './state/ducks/app';
import * as callingDuck from './state/ducks/calling';
import * as conversationsDuck from './state/ducks/conversations';
import * as emojisDuck from './state/ducks/emojis';
import * as expirationDuck from './state/ducks/expiration';
import * as itemsDuck from './state/ducks/items';
import * as linkPreviewsDuck from './state/ducks/linkPreviews';
import * as networkDuck from './state/ducks/network';
import * as updatesDuck from './state/ducks/updates';
import * as userDuck from './state/ducks/user';
import * as searchDuck from './state/ducks/search';
import * as stickersDuck from './state/ducks/stickers';
import * as conversationsSelectors from './state/selectors/conversations';
import * as searchSelectors from './state/selectors/search';
import AccountManager from './textsecure/AccountManager';
import { SendOptionsType } from './textsecure/SendMessage';
import Data from './sql/Client';
import { UserMessage } from './types/Message';
import { PhoneNumberFormat } from 'google-libphonenumber';
import { MessageModel } from './models/messages';
import { ConversationModel } from './models/conversations';
import { combineNames } from './util';
import { BatcherType } from './util/batcher';
import { AttachmentList } from './components/conversation/AttachmentList';
import { CaptionEditor } from './components/CaptionEditor';
import { ChatColorPicker } from './components/ChatColorPicker';
import { ConfirmationDialog } from './components/ConfirmationDialog';
import { ContactDetail } from './components/conversation/ContactDetail';
import { ContactModal } from './components/conversation/ContactModal';
import { ErrorModal } from './components/ErrorModal';
import { Lightbox } from './components/Lightbox';
import { MediaGallery } from './components/conversation/media-gallery/MediaGallery';
import { MessageDetail } from './components/conversation/MessageDetail';
import { ProgressModal } from './components/ProgressModal';
import { Quote } from './components/conversation/Quote';
import { StagedLinkPreview } from './components/conversation/StagedLinkPreview';
import { DisappearingTimeDialog } from './components/DisappearingTimeDialog';
import { WhatsNew } from './components/WhatsNew';
import { MIMEType } from './types/MIME';
import { DownloadedAttachmentType } from './types/Attachment';
import { ElectronLocaleType } from './util/mapToSupportLocale';
import { SignalProtocolStore } from './SignalProtocolStore';
import { Context as SignalContext } from './context';
import { StartupQueue } from './util/StartupQueue';
import { SocketStatus } from './types/SocketStatus';
import SyncRequest from './textsecure/SyncRequest';
import { ConversationColorType, CustomColorType } from './types/Colors';
import { MessageController } from './util/MessageController';
import { isValidGuid } from './util/isValidGuid';
import { StateType } from './state/reducer';
import { SystemTraySetting } from './types/SystemTraySetting';
import { UUID } from './types/UUID';
import { Address } from './types/Address';
import { QualifiedAddress } from './types/QualifiedAddress';
import { CI } from './CI';
import { IPCEventsType, IPCEventsValuesType } from './util/createIPCEvents';
import { ConversationView } from './views/conversation_view';
import { LoggerType } from './types/Logging';
import { SettingType } from './util/preload';
export { Long } from 'long';
type TaskResultType = any;
export type WhatIsThis = any;
// Synced with the type in ts/shims/showConfirmationDialog
// we are duplicating it here because that file cannot import/export.
type ConfirmationDialogViewProps = {
cancelText?: string;
confirmStyle?: 'affirmative' | 'negative';
message: string;
okText: string;
reject?: (error: Error) => void;
resolve: () => void;
};
export declare class WebAudioRecorderClass {
constructor(
node: GainNode,
options: {
encoding: string;
workerDir: string;
options?: { timeLimit?: number };
}
);
// Callbacks
onComplete?: (recorder: WebAudioRecorderClass, blob: Blob) => unknown;
onError?: (recorder: WebAudioRecorderClass, error: Error) => unknown;
onTimeout?: () => unknown;
// Class properties
startRecording: () => unknown;
finishRecording: () => unknown;
isRecording: () => boolean;
cancelRecording: () => unknown;
worker: Worker;
}
declare global {
// We want to extend `window`'s properties, so we need an interface.
// eslint-disable-next-line no-restricted-syntax
interface Window {
startApp: () => void;
QRCode: any;
removeSetupMenuItems: () => unknown;
showPermissionsPopup: () => unknown;
FontFace: typeof FontFace;
_: typeof Underscore;
$: typeof jQuery;
moment: typeof moment;
imageToBlurHash: typeof imageToBlurHash;
loadImage: any;
isBehindProxy: () => boolean;
getAutoLaunch: () => boolean;
setAutoLaunch: (value: boolean) => void;
PQueue: typeof PQueue;
PQueueType: PQueue;
Mustache: {
render: (template: string, data: any, partials?: any) => string;
parse: (template: string) => void;
};
WebAudioRecorder: typeof WebAudioRecorderClass;
WhatIsThis: WhatIsThis;
addSetupMenuItems: () => void;
attachmentDownloadQueue: Array<MessageModel> | undefined;
startupProcessingQueue: StartupQueue | undefined;
baseAttachmentsPath: string;
baseStickersPath: string;
baseTempPath: string;
drawAttention: () => void;
enterKeyboardMode: () => void;
enterMouseMode: () => void;
getAccountManager: () => AccountManager;
getBuiltInImages: () => Promise<Array<string>>;
getConversations: () => ConversationModelCollectionType;
getBuildCreation: () => number;
getEnvironment: typeof getEnvironment;
getExpiration: () => string;
getGuid: () => string;
getHostName: () => string;
getInboxCollection: () => ConversationModelCollectionType;
getInteractionMode: () => 'mouse' | 'keyboard';
getLocale: () => ElectronLocaleType;
getMediaCameraPermissions: () => Promise<boolean>;
getMediaPermissions: () => Promise<boolean>;
getServerPublicParams: () => string;
getSfuUrl: () => string;
getSocketStatus: () => SocketStatus;
getSyncRequest: (timeoutMillis?: number) => SyncRequest;
getTitle: () => string;
waitForEmptyEventQueue: () => Promise<void>;
getVersion: () => string;
showCallingPermissionsPopup: (forCamera: boolean) => Promise<void>;
i18n: LocalizerType;
isActive: () => boolean;
isAfterVersion: (version: string, anotherVersion: string) => boolean;
isBeforeVersion: (version: string, anotherVersion: string) => boolean;
isFullScreen: () => boolean;
isValidGuid: typeof isValidGuid;
libphonenumber: {
util: {
getRegionCodeForNumber: (number: string) => string;
parseNumber: (
e164: string,
defaultRegionCode?: string
) =>
| { isValidNumber: false; error: unknown }
| {
isValidNumber: true;
regionCode: string | undefined;
countryCode: string;
nationalNumber: string;
e164: string;
};
};
parse: (number: string) => string;
getRegionCodeForNumber: (number: string) => string;
format: (number: string, format: PhoneNumberFormat) => string;
};
nodeSetImmediate: typeof setImmediate;
onFullScreenChange: (fullScreen: boolean) => void;
platform: string;
preloadedImages: Array<WhatIsThis>;
reduxActions: ReduxActions;
reduxStore: Store<StateType>;
registerForActive: (handler: () => void) => void;
restart: () => void;
setImmediate: typeof setImmediate;
showWindow: () => void;
showSettings: () => void;
shutdown: () => void;
showDebugLog: () => void;
sendChallengeRequest: (request: IPCChallengeRequest) => void;
setAutoHideMenuBar: (value: WhatIsThis) => void;
setBadgeCount: (count: number) => void;
setMenuBarVisibility: (value: WhatIsThis) => void;
updateSystemTraySetting: (value: SystemTraySetting) => void;
showConfirmationDialog: (options: ConfirmationDialogViewProps) => void;
showKeyboardShortcuts: () => void;
storage: Storage;
systemTheme: WhatIsThis;
textsecure: TextSecureType;
titleBarDoubleClick: () => void;
unregisterForActive: (handler: () => void) => void;
updateTrayIcon: (count: number) => void;
sqlInitializer: {
initialize: () => Promise<void>;
goBackToMainProcess: () => Promise<void>;
};
Backbone: typeof Backbone;
CI?: CI;
Accessibility: {
reducedMotionSetting: boolean;
};
Signal: {
Backbone: any;
Crypto: typeof Crypto;
Curve: typeof Curve;
Data: typeof Data;
Groups: typeof Groups;
RemoteConfig: typeof RemoteConfig;
Services: {
calling: CallingClass;
enableStorageService: () => boolean;
eraseAllStorageServiceState: () => Promise<void>;
initializeGroupCredentialFetcher: () => void;
initializeNetworkObserver: (network: ReduxActions['network']) => void;
initializeUpdateListener: (updates: ReduxActions['updates']) => void;
retryPlaceholders?: Util.RetryPlaceholders;
lightSessionResetQueue?: PQueue;
runStorageServiceSyncJob: () => Promise<void>;
storageServiceUploadJob: () => void;
};
Migrations: {
readTempData: (path: string) => Promise<Uint8Array>;
deleteAttachmentData: (path: string) => Promise<void>;
doesAttachmentExist: (path: string) => Promise<boolean>;
writeNewAttachmentData: (data: Uint8Array) => Promise<string>;
deleteExternalMessageFiles: (attributes: unknown) => Promise<void>;
getAbsoluteAttachmentPath: (path: string) => string;
loadAttachmentData: (attachment: WhatIsThis) => WhatIsThis;
loadQuoteData: (quote: unknown) => WhatIsThis;
loadPreviewData: (preview: unknown) => WhatIsThis;
loadStickerData: (sticker: unknown) => WhatIsThis;
readStickerData: (path: string) => Promise<Uint8Array>;
deleteSticker: (path: string) => Promise<void>;
getAbsoluteStickerPath: (path: string) => string;
processNewEphemeralSticker: (
stickerData: Uint8Array
) => {
path: string;
width: number;
height: number;
};
processNewSticker: (
stickerData: Uint8Array
) => {
path: string;
width: number;
height: number;
};
copyIntoAttachmentsDirectory: (
path: string
) => Promise<{ path: string; size: number }>;
upgradeMessageSchema: (attributes: unknown) => WhatIsThis;
processNewAttachment: (
attachment: DownloadedAttachmentType
) => Promise<DownloadedAttachmentType>;
copyIntoTempDirectory: any;
deleteDraftFile: (path: string) => Promise<void>;
deleteTempFile: (path: string) => Promise<void>;
getAbsoluteDraftPath: any;
getAbsoluteTempPath: any;
openFileInFolder: any;
readAttachmentData: (path: string) => Promise<Uint8Array>;
readDraftData: (path: string) => Promise<Uint8Array>;
saveAttachmentToDisk: (options: {
data: Uint8Array;
name: string;
}) => Promise<null | { fullPath: string; name: string }>;
writeNewDraftData: (data: Uint8Array) => Promise<string>;
deleteAvatar: (path: string) => Promise<void>;
getAbsoluteAvatarPath: (src: string) => string;
writeNewAvatarData: (data: Uint8Array) => Promise<string>;
};
Types: {
Message: {
CURRENT_SCHEMA_VERSION: number;
VERSION_NEEDED_FOR_DISPLAY: number;
GROUP: 'group';
PRIVATE: 'private';
initializeSchemaVersion: (version: {
message: unknown;
logger: unknown;
}) => unknown & {
schemaVersion: number;
};
hasExpiration: (json: string) => boolean;
};
Sticker: {
emoji: string;
packId: string;
packKey: string;
stickerId: number;
data: {
pending: boolean;
path: string;
};
width: number;
height: number;
path: string;
};
UUID: typeof UUID;
Address: typeof Address;
QualifiedAddress: typeof QualifiedAddress;
};
Util: typeof Util;
GroupChange: {
renderChange: (change: unknown, things: unknown) => Array<string>;
};
Components: {
AttachmentList: typeof AttachmentList;
CaptionEditor: typeof CaptionEditor;
ChatColorPicker: typeof ChatColorPicker;
ConfirmationDialog: typeof ConfirmationDialog;
ContactDetail: typeof ContactDetail;
ContactModal: typeof ContactModal;
DisappearingTimeDialog: typeof DisappearingTimeDialog;
ErrorModal: typeof ErrorModal;
Lightbox: typeof Lightbox;
MediaGallery: typeof MediaGallery;
MessageDetail: typeof MessageDetail;
ProgressModal: typeof ProgressModal;
Quote: typeof Quote;
StagedLinkPreview: typeof StagedLinkPreview;
WhatsNew: typeof WhatsNew;
};
OS: typeof OS;
Workflow: {
IdleDetector: WhatIsThis;
MessageDataMigrator: WhatIsThis;
};
IndexedDB: {
removeDatabase: WhatIsThis;
doesDatabaseExist: WhatIsThis;
};
Views: WhatIsThis;
State: {
createStore: typeof createStore;
Roots: {
createApp: typeof createApp;
createChatColorPicker: typeof createChatColorPicker;
createConversationDetails: typeof createConversationDetails;
createForwardMessageModal: typeof createForwardMessageModal;
createGroupLinkManagement: typeof createGroupLinkManagement;
createGroupV1MigrationModal: typeof createGroupV1MigrationModal;
createGroupV2JoinModal: typeof createGroupV2JoinModal;
createGroupV2Permissions: typeof createGroupV2Permissions;
createLeftPane: typeof createLeftPane;
createMessageDetail: typeof createMessageDetail;
createConversationNotificationsSettings: typeof createConversationNotificationsSettings;
createPendingInvites: typeof createPendingInvites;
createSafetyNumberViewer: typeof createSafetyNumberViewer;
createShortcutGuideModal: typeof createShortcutGuideModal;
createStickerManager: typeof createStickerManager;
createStickerPreviewModal: typeof createStickerPreviewModal;
};
Ducks: {
app: typeof appDuck;
calling: typeof callingDuck;
conversations: typeof conversationsDuck;
emojis: typeof emojisDuck;
expiration: typeof expirationDuck;
items: typeof itemsDuck;
linkPreviews: typeof linkPreviewsDuck;
network: typeof networkDuck;
updates: typeof updatesDuck;
user: typeof userDuck;
search: typeof searchDuck;
stickers: typeof stickersDuck;
};
Selectors: {
conversations: typeof conversationsSelectors;
search: typeof searchSelectors;
};
};
conversationControllerStart: WhatIsThis;
Emojis: {
getInitialState: () => WhatIsThis;
load: () => void;
};
challengeHandler: ChallengeHandler;
};
SignalContext: SignalContext;
ConversationController: ConversationController;
Events: IPCEventsType;
MessageController: MessageController;
SignalProtocolStore: typeof SignalProtocolStore;
WebAPI: WebAPIConnectType;
Whisper: WhisperType;
getServerTrustRoot: () => WhatIsThis;
readyForUpdates: () => void;
logAppLoadedEvent?: (options: { processedCount?: number }) => void;
logAuthenticatedConnect?: () => void;
// Runtime Flags
isShowingModal?: boolean;
// Feature Flags
GV2_ENABLE_SINGLE_CHANGE_PROCESSING: boolean;
GV2_ENABLE_CHANGE_PROCESSING: boolean;
GV2_ENABLE_STATE_PROCESSING: boolean;
GV2_MIGRATION_DISABLE_ADD: boolean;
GV2_MIGRATION_DISABLE_INVITE: boolean;
RETRY_DELAY: boolean;
// Context Isolation
SignalWindow: {
Settings: {
themeSetting: SettingType<IPCEventsValuesType['themeSetting']>;
waitForChange: () => Promise<void>;
};
config: string;
context: SignalContext;
getAppInstance: () => string | undefined;
getEnvironment: () => string;
getNodeVersion: () => string;
getVersion: () => string;
i18n: LocalizerType;
log: LoggerType;
renderWindow: () => void;
};
}
// We want to extend `Error`, so we need an interface.
// eslint-disable-next-line no-restricted-syntax
interface Error {
originalError?: Event;
reason?: any;
stackForLog?: string;
}
// Uint8Array and ArrayBuffer are type-compatible in TypeScript's covariant
// type checker, but in reality they are not. Let's assert correct use!
interface Uint8Array {
__uint8array: never;
}
interface ArrayBuffer {
__array_buffer: never;
}
interface SharedArrayBuffer {
__array_buffer: never;
}
}
export class CertificateValidatorType {
validate: (cerficate: any, certificateTime: number) => Promise<void>;
}
export class GumVideoCapturer {
constructor(
maxWidth: number,
maxHeight: number,
maxFramerate: number,
localPreview: Ref<HTMLVideoElement>
);
}
export class CanvasVideoRenderer {
constructor(canvas: Ref<HTMLCanvasElement>);
}
export type DeliveryReceiptBatcherItemType = {
messageId: string;
source?: string;
sourceUuid?: string;
timestamp: number;
};
export class AnyViewClass extends window.Backbone.View<any> {
public headerTitle?: string;
static show(view: typeof AnyViewClass, element: Element): void;
constructor(options?: any);
}
export class BasicReactWrapperViewClass extends AnyViewClass {
public update(options: any): void;
}
export type WhisperType = {
Conversation: typeof ConversationModel;
ConversationCollection: typeof ConversationModelCollectionType;
Message: typeof MessageModel;
MessageCollection: typeof MessageModelCollectionType;
GroupMemberConversation: WhatIsThis;
RotateSignedPreKeyListener: WhatIsThis;
WallClockListener: WhatIsThis;
deliveryReceiptQueue: PQueue;
deliveryReceiptBatcher: BatcherType<DeliveryReceiptBatcherItemType>;
events: Backbone.Events;
activeConfirmationView: WhatIsThis;
Database: {
open: () => Promise<IDBDatabase>;
handleDOMException: (
context: string,
error: DOMException | null,
reject: Function
) => void;
};
ExpiringMessagesListener: {
init: (events: Backbone.Events) => void;
update: () => void;
};
TapToViewMessagesListener: {
nextCheck: null | number;
init: (events: Backbone.Events) => void;
update: () => void;
};
// Backbone views
// Modernized
ConversationView: typeof ConversationView;
// Note: we can no longer use 'View.extend' once we've moved to Typescript's preferred
// 'extend View' syntax. Thus, we'll need to typescriptify most of it at once.
ClearDataView: typeof AnyViewClass;
ConversationLoadingScreen: typeof AnyViewClass;
GroupMemberList: typeof AnyViewClass;
InboxView: typeof AnyViewClass;
InstallView: typeof AnyViewClass;
KeyVerificationPanelView: typeof AnyViewClass;
ReactWrapperView: typeof BasicReactWrapperViewClass;
SafetyNumberChangeDialogView: typeof AnyViewClass;
StandaloneRegistrationView: typeof AnyViewClass;
View: typeof AnyViewClass;
};