@inboxsdk/core 0.1.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background.d.ts +1 -0
- package/background.js +16 -0
- package/inboxsdk.d.ts +141 -18
- package/inboxsdk.js +56 -58
- package/package.json +9 -4
- package/pageWorld.d.ts +1 -0
- package/pageWorld.js +12 -0
package/background.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/background.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|
2
|
+
if (message.type === 'inboxsdk__injectPageWorld' && sender.tab) {
|
|
3
|
+
if (chrome.scripting) {
|
|
4
|
+
// MV3
|
|
5
|
+
chrome.scripting.executeScript({
|
|
6
|
+
target: { tabId: sender.tab.id },
|
|
7
|
+
world: 'MAIN',
|
|
8
|
+
files: ['pageWorld.js']
|
|
9
|
+
});
|
|
10
|
+
sendResponse(true);
|
|
11
|
+
} else {
|
|
12
|
+
// MV2 fallback. Tell content script it needs to figure things out.
|
|
13
|
+
sendResponse(false);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
package/inboxsdk.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import * as Kefir from 'kefir';
|
|
3
|
+
import TypedEmitter from 'typed-emitter';
|
|
3
4
|
|
|
4
5
|
export const LOADER_VERSION: string;
|
|
5
6
|
export interface LoadScriptOptions {
|
|
@@ -27,6 +28,13 @@ export interface InboxSDK {
|
|
|
27
28
|
Compose: Compose;
|
|
28
29
|
ButterBar: ButterBar;
|
|
29
30
|
Lists: Lists;
|
|
31
|
+
Logger: {
|
|
32
|
+
event(name: string, extras: any): void;
|
|
33
|
+
error: (
|
|
34
|
+
err: Error & { details?: Record<string, any> },
|
|
35
|
+
options: Record<string, any>
|
|
36
|
+
) => void;
|
|
37
|
+
};
|
|
30
38
|
NavMenu: NavMenu;
|
|
31
39
|
Router: Router;
|
|
32
40
|
Widgets: Widgets;
|
|
@@ -143,8 +151,23 @@ export interface Router {
|
|
|
143
151
|
handleListRoute(
|
|
144
152
|
routeID: string,
|
|
145
153
|
handler: (listRouteView: ListRouteView) => void
|
|
146
|
-
): void;
|
|
154
|
+
): () => void;
|
|
147
155
|
NativeRouteIDs: Record<NativeRouteIdTypes, string>;
|
|
156
|
+
NativeListRouteIDs: Record<
|
|
157
|
+
| 'ALL_MAIL'
|
|
158
|
+
| 'ANY_LIST'
|
|
159
|
+
| 'DRAFTS'
|
|
160
|
+
| 'IMPORTANT'
|
|
161
|
+
| 'INBOX'
|
|
162
|
+
| 'LABEL'
|
|
163
|
+
| 'SEARCH'
|
|
164
|
+
| 'SEARCH'
|
|
165
|
+
| 'SENT'
|
|
166
|
+
| 'SPAM'
|
|
167
|
+
| 'STARRED'
|
|
168
|
+
| 'TRASH',
|
|
169
|
+
string
|
|
170
|
+
>;
|
|
148
171
|
RouteTypes: Record<RouteTypes, string>;
|
|
149
172
|
}
|
|
150
173
|
|
|
@@ -182,9 +205,15 @@ export interface Widgets {
|
|
|
182
205
|
showModalView(descriptor: ModalDescriptor): ModalView;
|
|
183
206
|
showMoleView(descriptor: MoleDescriptor): MoleView;
|
|
184
207
|
showDrawerView(descriptor: DrawerDescriptor): DrawerView;
|
|
208
|
+
showTopMessageBarView(opts: { el: Element }): Element;
|
|
185
209
|
}
|
|
186
210
|
|
|
187
211
|
export interface Toolbars {
|
|
212
|
+
addToolbarButtonForApp(
|
|
213
|
+
descriptor:
|
|
214
|
+
| AppToolbarButtonDescriptor
|
|
215
|
+
| Kefir.Stream<AppToolbarButtonDescriptor, any>
|
|
216
|
+
): AppToolbarButtonView;
|
|
188
217
|
registerThreadButton(descriptor: ToolbarButtonDescriptor): () => void;
|
|
189
218
|
registerToolbarButtonForThreadView(
|
|
190
219
|
descriptor: LegacyToolbarButtonDescriptor
|
|
@@ -196,6 +225,21 @@ export interface Toolbars {
|
|
|
196
225
|
};
|
|
197
226
|
}
|
|
198
227
|
|
|
228
|
+
export interface AppToolbarButtonDescriptor {
|
|
229
|
+
title: string;
|
|
230
|
+
titleClass?: string;
|
|
231
|
+
iconUrl: string;
|
|
232
|
+
iconClass?: string;
|
|
233
|
+
onClick: (e: MouseEvent) => void;
|
|
234
|
+
arrowColor?: string | null;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export type AppToolbarButtonView = {
|
|
238
|
+
open(): void;
|
|
239
|
+
close(): void;
|
|
240
|
+
remove(): void;
|
|
241
|
+
} & TypedEmitter<{ destroy: () => void }>;
|
|
242
|
+
|
|
199
243
|
export interface Keyboard {
|
|
200
244
|
createShortcutHandle(
|
|
201
245
|
descriptor: KeyboardShortcutDescriptor
|
|
@@ -222,6 +266,8 @@ export interface Lists {
|
|
|
222
266
|
}
|
|
223
267
|
|
|
224
268
|
export interface User {
|
|
269
|
+
/** @deprecated */
|
|
270
|
+
getAccountSwitcherContactList(): Contact[];
|
|
225
271
|
getEmailAddress(): string;
|
|
226
272
|
getLanguage(): string;
|
|
227
273
|
isConversationViewDisabled(): Promise<boolean>;
|
|
@@ -254,6 +300,7 @@ export interface ThreadRowView extends Destroyable {
|
|
|
254
300
|
| ImageDescriptor
|
|
255
301
|
| Kefir.Observable<ImageDescriptor | null, any>
|
|
256
302
|
): void;
|
|
303
|
+
getElement(): HTMLElement;
|
|
257
304
|
getVisibleDraftCount(): number;
|
|
258
305
|
getThreadIDIfStable(): string | null;
|
|
259
306
|
getThreadIDIfStableAsync(): Promise<string | null>;
|
|
@@ -327,6 +374,7 @@ export interface RouteView extends EventEmitter {
|
|
|
327
374
|
export interface ListRouteView extends RouteView {
|
|
328
375
|
addCollapsibleSection(options: any): CollapsibleSectionView;
|
|
329
376
|
addSection(options: any): SectionView;
|
|
377
|
+
refresh(): void;
|
|
330
378
|
}
|
|
331
379
|
|
|
332
380
|
export interface CustomRouteView extends RouteView {
|
|
@@ -363,14 +411,16 @@ export interface ModalButtonDescriptor {
|
|
|
363
411
|
|
|
364
412
|
export interface ModalView extends EventEmitter {
|
|
365
413
|
close(): void;
|
|
414
|
+
setTitle(s: string): void;
|
|
366
415
|
}
|
|
367
416
|
|
|
368
417
|
export interface DrawerView extends EventEmitter {
|
|
369
418
|
close(): void;
|
|
370
419
|
associateComposeView(
|
|
371
420
|
composeView: ComposeView,
|
|
372
|
-
closeWithCompose
|
|
421
|
+
closeWithCompose?: boolean
|
|
373
422
|
): void;
|
|
423
|
+
disassociateComposeView(): void;
|
|
374
424
|
}
|
|
375
425
|
|
|
376
426
|
export interface DrawerDescriptor {
|
|
@@ -421,24 +471,37 @@ export interface ThreadView extends EventEmitter {
|
|
|
421
471
|
getMessageViews(): Array<MessageView>;
|
|
422
472
|
getMessageViewsAll(): Array<MessageView>;
|
|
423
473
|
getSubject(): string;
|
|
474
|
+
/**
|
|
475
|
+
* @deprecated
|
|
476
|
+
*/
|
|
424
477
|
getThreadID(): string;
|
|
425
478
|
getThreadIDAsync(): Promise<string>;
|
|
426
479
|
addNoticeBar(): SimpleElementView;
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
export interface UNSTABLE_ThreadView extends ThreadView {
|
|
483
|
+
//#region Undocumented methods
|
|
484
|
+
/**
|
|
485
|
+
* @internal
|
|
486
|
+
*/
|
|
487
|
+
addCustomMessage: (descriptor: {
|
|
488
|
+
collapsedEl: HTMLElement;
|
|
489
|
+
headerEl: HTMLElement;
|
|
490
|
+
bodyEl: HTMLElement;
|
|
491
|
+
iconUrl: string;
|
|
492
|
+
sortDate: Date;
|
|
493
|
+
}) => CustomMessageView;
|
|
494
|
+
/**
|
|
495
|
+
* @internal
|
|
496
|
+
*/
|
|
497
|
+
registerHiddenCustomMessageNoticeProvider: (
|
|
498
|
+
provider: (
|
|
499
|
+
numCustomHidden: number,
|
|
500
|
+
numberNativeHidden: number,
|
|
501
|
+
unmountPromise: Promise<void>
|
|
502
|
+
) => HTMLElement | null
|
|
503
|
+
) => void;
|
|
504
|
+
//#endregion
|
|
442
505
|
}
|
|
443
506
|
|
|
444
507
|
export interface CustomMessageView extends EventEmitter {
|
|
@@ -464,7 +527,37 @@ export interface ContentPanelDescriptor {
|
|
|
464
527
|
orderHint?: number;
|
|
465
528
|
}
|
|
466
529
|
|
|
530
|
+
export interface MessageAttachmentIconDescriptor {
|
|
531
|
+
iconUrl: string;
|
|
532
|
+
iconClass?: string;
|
|
533
|
+
iconHtml?: string | null;
|
|
534
|
+
tooltip: string | HTMLElement;
|
|
535
|
+
onClick: () => void;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export type AttachmentIcon = TypedEmitter<{
|
|
539
|
+
tooltipHidden: () => void;
|
|
540
|
+
tooltipShown: () => void;
|
|
541
|
+
}>;
|
|
542
|
+
|
|
543
|
+
export type MessageViewToolbarSectionNames = 'MORE';
|
|
544
|
+
|
|
545
|
+
export interface MessageViewToolbarButtonDescriptor {
|
|
546
|
+
section: MessageViewToolbarSectionNames;
|
|
547
|
+
title: string;
|
|
548
|
+
iconUrl?: string;
|
|
549
|
+
iconClass?: string;
|
|
550
|
+
onClick: (e: MouseEvent) => void;
|
|
551
|
+
orderHint?: number;
|
|
552
|
+
}
|
|
553
|
+
|
|
467
554
|
export interface MessageView extends EventEmitter {
|
|
555
|
+
addAttachmentIcon(
|
|
556
|
+
opts:
|
|
557
|
+
| MessageAttachmentIconDescriptor
|
|
558
|
+
| Kefir.Stream<MessageAttachmentIconDescriptor, never>
|
|
559
|
+
): AttachmentIcon;
|
|
560
|
+
addToolbarButton(opts?: MessageViewToolbarButtonDescriptor): void;
|
|
468
561
|
getBodyElement(): HTMLElement;
|
|
469
562
|
isElementInQuotedArea(element: HTMLElement): boolean;
|
|
470
563
|
isLoaded(): boolean;
|
|
@@ -512,12 +605,14 @@ export interface LegacyToolbarButtonDescriptor {
|
|
|
512
605
|
hasDropdown?: boolean;
|
|
513
606
|
hideFor?: (routeView: RouteView) => boolean;
|
|
514
607
|
keyboardShortcutHandle?: KeyboardShortcutHandle;
|
|
608
|
+
orderHint?: number;
|
|
515
609
|
}
|
|
516
610
|
|
|
517
611
|
export interface ToolbarButtonOnClickEvent {
|
|
518
612
|
selectedThreadViews: Array<ThreadView>;
|
|
519
613
|
selectedThreadRowViews: Array<ThreadRowView>;
|
|
520
614
|
dropdown?: DropdownView;
|
|
615
|
+
threadView?: ThreadView;
|
|
521
616
|
}
|
|
522
617
|
|
|
523
618
|
export interface KeyboardShortcutDescriptor {
|
|
@@ -537,6 +632,7 @@ export interface DropdownView extends EventEmitter {
|
|
|
537
632
|
}
|
|
538
633
|
|
|
539
634
|
export interface ComposeView extends EventEmitter {
|
|
635
|
+
destroyed: boolean;
|
|
540
636
|
addButton(
|
|
541
637
|
buttonOptions:
|
|
542
638
|
| ComposeButtonDescriptor
|
|
@@ -552,28 +648,55 @@ export interface ComposeView extends EventEmitter {
|
|
|
552
648
|
close(): void;
|
|
553
649
|
ensureAppButtonToolbarsAreClosed(): void;
|
|
554
650
|
ensureFormattingToolbarIsHidden(): void;
|
|
651
|
+
forceRecipientRowsOpen(): () => void;
|
|
555
652
|
getBccRecipients(): Array<Contact>;
|
|
556
653
|
getBodyElement(): HTMLElement;
|
|
557
654
|
getCcRecipients(): Array<Contact>;
|
|
558
|
-
getCurrentDraftID(): Promise<string>;
|
|
655
|
+
getCurrentDraftID(): Promise<string | null>;
|
|
559
656
|
getElement(): HTMLElement;
|
|
560
657
|
getDraftID(): Promise<string | null>;
|
|
658
|
+
getMessageIDAsync(): Promise<string>;
|
|
561
659
|
getSubject(): string;
|
|
660
|
+
getSubjectInput(): HTMLInputElement | null;
|
|
562
661
|
getThreadID(): string;
|
|
563
662
|
getToRecipients(): Array<Contact>;
|
|
663
|
+
getHTMLContent(): string;
|
|
664
|
+
getTextContent(): string;
|
|
665
|
+
hideDiscardButton(): () => void;
|
|
666
|
+
hideNativeRecipientRows(): () => void;
|
|
667
|
+
isMinimized(): boolean;
|
|
668
|
+
setMinimized(minimized: boolean): void;
|
|
669
|
+
isFullScreen(): boolean;
|
|
564
670
|
insertHTMLIntoBodyAtCursor(html: string): HTMLElement;
|
|
565
671
|
isForward(): boolean;
|
|
566
672
|
isInlineReplyForm(): boolean;
|
|
567
673
|
isReply(): boolean;
|
|
568
674
|
overrideEditSubject(): void;
|
|
675
|
+
registerRequestModifier(
|
|
676
|
+
cb: (composeParams: { isPlainText?: boolean; body: string }) => void
|
|
677
|
+
): void;
|
|
569
678
|
replaceSendButton({ el }: { el: HTMLElement }): () => void;
|
|
570
679
|
setBccRecipients(emails: string[]): void;
|
|
571
680
|
setBodyHTML(html: string): void;
|
|
681
|
+
setBodyText(to: string): void;
|
|
572
682
|
setCcRecipients(emails: string[]): void;
|
|
573
683
|
setFullscreen(isFullScreen: boolean): void;
|
|
574
684
|
setSubject(subject: string): void;
|
|
575
685
|
setTitleBarColor(color: string): () => void;
|
|
686
|
+
setTitleBarText(to: string): () => void;
|
|
576
687
|
setToRecipients(recipients: string[]): void;
|
|
688
|
+
send(options?: SendOptions): void;
|
|
689
|
+
getFromContact(): Contact;
|
|
690
|
+
getFromContactChoices(): Contact[];
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
export interface SendOptions {
|
|
694
|
+
sendAndArchive?: boolean;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
export interface ComposeViewDestroyEvent {
|
|
698
|
+
messageID: string | null;
|
|
699
|
+
closedByInboxSDK: boolean;
|
|
577
700
|
}
|
|
578
701
|
|
|
579
702
|
export interface ComposeButtonDescriptor {
|