@inboxsdk/core 1.0.1 → 1.0.2
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/inboxsdk.js +5 -5
- package/inboxsdk.js.map +1 -1
- package/package.json +1 -1
- package/pageWorld.js.map +1 -1
- package/src/inboxsdk.d.ts +16 -1
- package/src/injected-js/gmail/modify-suggestions.d.ts +2 -0
- package/src/injected-js/gmail/modify-suggestions.d.ts.map +1 -1
- package/src/platform-implementation-js/constants/router.d.ts +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.d.ts +2 -0
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.js +16 -21
- package/src/platform-implementation-js/dom-driver/gmail/gmail-butter-bar-driver.d.ts +12 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-butter-bar-driver.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-butter-bar-driver.js +152 -187
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-app-menu-item.d.ts +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-app-menu-item.d.ts.map +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-app-menu-item.js +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-toolbar-button-for-app.d.ts +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-toolbar-button-for-app.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-toolbar-button-for-app.js +15 -20
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/create-link.d.ts +4 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/create-link.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/create-link.js +59 -56
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-draft-id-for-message-id.d.ts +9 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-draft-id-for-message-id.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-draft-id-for-message-id.js +42 -54
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-native-nav-item.d.ts +4 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-native-nav-item.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-native-nav-item.js +31 -33
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-url-object.d.ts +8 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-url-object.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-url-object.js +21 -23
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadForOldGmailThreadId.d.ts +4 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadForOldGmailThreadId.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadForOldGmailThreadId.js +19 -31
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadFromSyncThreadId.d.ts +7 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/goto-view.d.ts +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/goto-view.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/goto-view.js +51 -60
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/keyboard-shortcut-help-modifier.d.ts +20 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/keyboard-shortcut-help-modifier.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/keyboard-shortcut-help-modifier.js +166 -130
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-compose-window.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-compose-window.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-compose-window.js +17 -22
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/override-gmail-back-button.d.ts +4 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/override-gmail-back-button.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/override-gmail-back-button.js +44 -51
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-query-rewriter.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-query-rewriter.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-query-rewriter.js +17 -22
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-suggestions-provider.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-suggestions-provider.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-suggestions-provider.js +136 -129
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-compose-view-driver-stream.d.ts +6 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-compose-view-driver-stream.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-compose-view-driver-stream.js +102 -95
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.d.ts +6 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.js +144 -169
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-app-id-warning.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-app-id-warning.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-app-id-warning.js +14 -23
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-route-view.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-route-view.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-route-view.js +41 -49
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.d.ts +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.js +286 -294
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-native-route-view.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-native-route-view.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-native-route-view.js +19 -26
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/suppressAddon.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/suppressAddon.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/suppressAddon.js +36 -42
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/temporary-track-download-url-validity.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/temporary-track-download-url-validity.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/temporary-track-download-url-validity.js +34 -33
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/thread-row-identifier.d.ts +13 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/thread-row-identifier.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/thread-row-identifier.js +80 -81
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-events.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-events.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-events.js +124 -81
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.d.ts +10 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.js +47 -54
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.d.ts +183 -106
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.js +712 -647
- package/src/platform-implementation-js/dom-driver/gmail/make-xhr-interceptor.d.ts +7 -0
- package/src/platform-implementation-js/dom-driver/gmail/make-xhr-interceptor.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/make-xhr-interceptor.js +93 -82
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/index.d.ts +7 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-toolbar-button-view.d.ts +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-backdrop.d.ts +11 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-backdrop.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-backdrop.js +20 -32
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view.d.ts +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view.d.ts +8 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-processor.d.ts +8 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-view.d.ts +3 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-view.js +3 -1
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-row-list-view.d.ts +10 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-row-view.d.ts +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-view.d.ts +9 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-toolbar-view.d.ts +12 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/native-gmail-nav-item-view.d.ts +9 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-modal-view-driver.d.ts +20 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-modal-view-driver.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-modal-view-driver.js +107 -108
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-mole-view-driver.d.ts +16 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-mole-view-driver.js +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-top-message-bar-driver.d.ts +13 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-top-message-bar-driver.d.ts.map +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-top-message-bar-driver.js +66 -66
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-drawer-view.d.ts +5 -0
- package/src/platform-implementation-js/driver-common/getGmailMessageIdForSyncMessageId.d.ts +6 -0
- package/src/platform-implementation-js/driver-common/getGmailThreadIdForRfcMessageId.d.ts +6 -0
- package/src/platform-implementation-js/driver-common/sidebar/ContentPanelViewDriver.d.ts +1 -0
- package/src/platform-implementation-js/driver-interfaces/driver.d.ts +3 -6
- package/src/platform-implementation-js/driver-interfaces/mole-view-driver.d.ts +27 -0
- package/src/platform-implementation-js/lib/copyAndValidateAutocompleteResults.d.ts +4 -0
- package/src/platform-implementation-js/lib/copyAndValidateAutocompleteResults.d.ts.map +1 -0
- package/src/platform-implementation-js/lib/copyAndValidateAutocompleteResults.js +34 -34
- package/src/platform-implementation-js/lib/dom/element-view-mapper.d.ts +10 -0
- package/src/platform-implementation-js/lib/dom/element-view-mapper.d.ts.map +1 -0
- package/src/platform-implementation-js/lib/dom/element-view-mapper.js +9 -17
- package/src/platform-implementation-js/lib/dom/on-mouse-down-and-up.d.ts +4 -0
- package/src/platform-implementation-js/lib/dom/on-mouse-down-and-up.d.ts.map +1 -0
- package/src/platform-implementation-js/lib/dom/on-mouse-down-and-up.js +7 -16
- package/src/platform-implementation-js/lib/populateRouteID.d.ts +6 -0
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.d.ts +2 -0
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.d.ts.map +1 -0
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.js +4 -11
- package/src/platform-implementation-js/lib/routeIDmatchesHash.d.ts +4 -0
- package/src/platform-implementation-js/lib/toLiveSet.d.ts +5 -0
- package/src/platform-implementation-js/lib/toLiveSet.d.ts.map +1 -0
- package/src/platform-implementation-js/lib/toLiveSet.js +22 -33
- package/src/platform-implementation-js/namespaces/router.d.ts +1 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.test.js +0 -183
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.test.js +0 -218
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.test.js +0 -85
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.test.js +0 -43
|
@@ -1,178 +1,153 @@
|
|
|
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
|
-
|
|
1
|
+
/* eslint-disable prefer-const */
|
|
2
|
+
import Kefir from 'kefir';
|
|
3
|
+
import get from '../../../../common/get-or-fail';
|
|
4
|
+
import GmailElementGetter from '../gmail-element-getter';
|
|
5
|
+
import GmailRouteView from '../views/gmail-route-view/gmail-route-view';
|
|
6
|
+
import getURLObject from './get-url-object';
|
|
7
|
+
import routeIDmatchesHash from '../../../lib/routeIDmatchesHash';
|
|
8
|
+
export default function setupRouteViewDriverStream(gmailRouteProcessor, driver) {
|
|
9
|
+
const customRouteIDs = driver.getCustomRouteIDs();
|
|
10
|
+
const customListRouteIDs = driver.getCustomListRouteIDs();
|
|
11
|
+
const customListSearchStringsToRouteIds = driver.getCustomListSearchStringsToRouteIds();
|
|
12
|
+
let lastNativeHash = getURLObject(document.location.href).hash;
|
|
13
|
+
let latestGmailRouteView = null;
|
|
14
|
+
driver.getStopper().onValue(() => {
|
|
15
|
+
if (latestGmailRouteView) {
|
|
16
|
+
latestGmailRouteView.destroy();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
let lastHash = lastNativeHash;
|
|
20
|
+
let sameRouteData = {};
|
|
21
|
+
const eligibleHashChanges = Kefir.fromEvents(window, 'hashchange')
|
|
22
|
+
.filter((event) => !event.oldURL.match(/#inboxsdk-fake-no-vc$/))
|
|
23
|
+
.map((event) => ({
|
|
24
|
+
new: getURLObject(event.newURL),
|
|
25
|
+
old: getURLObject(event.oldURL),
|
|
26
|
+
}))
|
|
27
|
+
.filter((event) => event.new.hash !== event.old.hash)
|
|
28
|
+
.map((event) => event.new)
|
|
29
|
+
.map((urlObject) => {
|
|
30
|
+
const { hash, name } = urlObject;
|
|
31
|
+
for (let routeIDs of customRouteIDs) {
|
|
32
|
+
let routeID = routeIDmatchesHash(routeIDs, hash);
|
|
33
|
+
if (routeID) {
|
|
34
|
+
return { urlObject, type: 'CUSTOM', routeID };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
for (let [routeIDs] of customListRouteIDs) {
|
|
38
|
+
let routeID = routeIDmatchesHash(routeIDs, name);
|
|
39
|
+
if (routeID) {
|
|
40
|
+
return { urlObject, type: 'CUSTOM_LIST_TRIGGER', routeID };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (gmailRouteProcessor.isNativeRoute(urlObject.name)) {
|
|
44
|
+
return { urlObject, type: 'NATIVE' };
|
|
45
|
+
}
|
|
46
|
+
return { urlObject, type: 'OTHER_APP_CUSTOM' };
|
|
47
|
+
});
|
|
48
|
+
const customAndCustomListRouteHashChanges = eligibleHashChanges.filter(({ type }) => type !== 'NATIVE');
|
|
49
|
+
// If a user goes from a native route to a custom route, and then back to the
|
|
50
|
+
// same native route, we need to make a new GmailRouteView because
|
|
51
|
+
// getMainContentElementChangedStream() won't be firing, except when going from thread->custom->thread
|
|
52
|
+
const revertNativeHashChanges = eligibleHashChanges
|
|
53
|
+
.filter(({ type }) => type === 'NATIVE')
|
|
54
|
+
.filter(({ urlObject }) => {
|
|
55
|
+
const tmp = lastNativeHash;
|
|
56
|
+
lastNativeHash = urlObject.hash;
|
|
57
|
+
return tmp === urlObject.hash;
|
|
58
|
+
})
|
|
59
|
+
.filter(({ urlObject }) => {
|
|
60
|
+
return urlObject.hash !== lastHash;
|
|
61
|
+
});
|
|
62
|
+
// Merge everything that can trigger a new RouteView
|
|
63
|
+
return Kefir.merge([
|
|
64
|
+
customAndCustomListRouteHashChanges,
|
|
65
|
+
revertNativeHashChanges,
|
|
66
|
+
// when native gmail changes main view there's a div that takes on role=main.
|
|
67
|
+
// getMainContentElementChangedStream doesn't respect custom views so filter
|
|
68
|
+
// out events from it. This filter is needed if the user is already at a custom
|
|
69
|
+
// view of another InboxSDK instance while this starts up.
|
|
70
|
+
GmailElementGetter.getMainContentElementChangedStream()
|
|
71
|
+
.map((_event) => ({
|
|
72
|
+
urlObject: getURLObject(document.location.href),
|
|
73
|
+
type: 'NATIVE',
|
|
74
|
+
}))
|
|
75
|
+
.filter((options) => gmailRouteProcessor.isNativeRoute(options.urlObject.name)),
|
|
76
|
+
])
|
|
77
|
+
.map((options) => {
|
|
78
|
+
const { type, urlObject } = options;
|
|
79
|
+
if (type === 'NATIVE' && urlObject.name === 'search') {
|
|
80
|
+
const customListRouteId = customListSearchStringsToRouteIds.get(urlObject.params[0]);
|
|
81
|
+
if (customListRouteId) {
|
|
82
|
+
const searchInput = GmailElementGetter.getSearchInput();
|
|
83
|
+
if (!searchInput)
|
|
84
|
+
throw new Error('Should not happen');
|
|
85
|
+
searchInput.value = '';
|
|
86
|
+
// Only rewrite the url if it's a search query with no further
|
|
87
|
+
// parameters or it has a page parameter. Don't write URLs with thread
|
|
88
|
+
// id parameters because currently other parts of the code depend on
|
|
89
|
+
// being able to parse the URL as a normal thread URL.
|
|
90
|
+
// Additionally, we don't want to treat threads as the CUSTOM_LIST type
|
|
91
|
+
// since they're not lists.
|
|
92
|
+
if (urlObject.params.length === 1 ||
|
|
93
|
+
(urlObject.params.length === 2 && urlObject.params[1][0] === 'p')) {
|
|
94
|
+
driver.hashChangeNoViewChange('#' +
|
|
95
|
+
customListRouteId +
|
|
96
|
+
(urlObject.params[1] ? '/' + urlObject.params[1] : ''));
|
|
97
|
+
return {
|
|
98
|
+
type: 'CUSTOM_LIST',
|
|
99
|
+
urlObject,
|
|
100
|
+
routeID: customListRouteId,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return options;
|
|
106
|
+
})
|
|
107
|
+
.map((options) => {
|
|
108
|
+
const MAX_KEY_CACHE = 50;
|
|
109
|
+
const { urlObject } = options;
|
|
110
|
+
if (!sameRouteData[urlObject.hash]) {
|
|
111
|
+
sameRouteData[urlObject.hash] = {
|
|
112
|
+
data: {},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
sameRouteData[urlObject.hash].lastUsedTimestamp = Date.now();
|
|
116
|
+
if (Object.keys(sameRouteData).length > MAX_KEY_CACHE) {
|
|
117
|
+
sameRouteData = Object.keys(sameRouteData)
|
|
118
|
+
.sort((a, b) => sameRouteData[b].lastUsedTimestamp -
|
|
119
|
+
sameRouteData[a].lastUsedTimestamp)
|
|
120
|
+
.slice(0, MAX_KEY_CACHE / 2)
|
|
121
|
+
.reduce((acc, hash) => ({ ...acc, [hash]: sameRouteData[hash] }), {});
|
|
122
|
+
}
|
|
48
123
|
return {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
routeID
|
|
124
|
+
...options,
|
|
125
|
+
cachedRouteData: sameRouteData[urlObject.hash].data,
|
|
52
126
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
type
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
type
|
|
69
|
-
} = _ref;
|
|
70
|
-
return type !== 'NATIVE';
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// If a user goes from a native route to a custom route, and then back to the
|
|
74
|
-
// same native route, we need to make a new GmailRouteView because
|
|
75
|
-
// getMainContentElementChangedStream() won't be firing, except when going from thread->custom->thread
|
|
76
|
-
const revertNativeHashChanges = eligibleHashChanges.filter(_ref2 => {
|
|
77
|
-
let {
|
|
78
|
-
type
|
|
79
|
-
} = _ref2;
|
|
80
|
-
return type === 'NATIVE';
|
|
81
|
-
}).filter(_ref3 => {
|
|
82
|
-
let {
|
|
83
|
-
urlObject
|
|
84
|
-
} = _ref3;
|
|
85
|
-
const tmp = lastNativeHash;
|
|
86
|
-
lastNativeHash = urlObject.hash;
|
|
87
|
-
return tmp === urlObject.hash;
|
|
88
|
-
}).filter(_ref4 => {
|
|
89
|
-
let {
|
|
90
|
-
urlObject
|
|
91
|
-
} = _ref4;
|
|
92
|
-
return urlObject.hash !== lastHash;
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// Merge everything that can trigger a new RouteView
|
|
96
|
-
return _kefir.default.merge([customAndCustomListRouteHashChanges, revertNativeHashChanges,
|
|
97
|
-
// when native gmail changes main view there's a div that takes on role=main.
|
|
98
|
-
// getMainContentElementChangedStream doesn't respect custom views so filter
|
|
99
|
-
// out events from it. This filter is needed if the user is already at a custom
|
|
100
|
-
// view of another InboxSDK instance while this starts up.
|
|
101
|
-
_gmailElementGetter.default.getMainContentElementChangedStream().map(event => ({
|
|
102
|
-
urlObject: (0, _getUrlObject.default)(document.location.href),
|
|
103
|
-
type: 'NATIVE'
|
|
104
|
-
})).filter(options => gmailRouteProcessor.isNativeRoute(options.urlObject.name))]).map(options => {
|
|
105
|
-
const {
|
|
106
|
-
type,
|
|
107
|
-
urlObject
|
|
108
|
-
} = options;
|
|
109
|
-
if (type === 'NATIVE' && urlObject.name === 'search') {
|
|
110
|
-
const customListRouteId = customListSearchStringsToRouteIds.get(urlObject.params[0]);
|
|
111
|
-
if (customListRouteId) {
|
|
112
|
-
const searchInput = _gmailElementGetter.default.getSearchInput();
|
|
113
|
-
if (!searchInput) throw new Error('Should not happen');
|
|
114
|
-
searchInput.value = '';
|
|
115
|
-
|
|
116
|
-
// Only rewrite the url if it's a search query with no further
|
|
117
|
-
// parameters or it has a page parameter. Don't write URLs with thread
|
|
118
|
-
// id parameters because currently other parts of the code depend on
|
|
119
|
-
// being able to parse the URL as a normal thread URL.
|
|
120
|
-
|
|
121
|
-
// Additionally, we don't want to treat threads as the CUSTOM_LIST type
|
|
122
|
-
// since they're not lists.
|
|
123
|
-
if (urlObject.params.length === 1 || urlObject.params.length === 2 && urlObject.params[1][0] === 'p') {
|
|
124
|
-
driver.hashChangeNoViewChange('#' + customListRouteId + (urlObject.params[1] ? '/' + urlObject.params[1] : ''));
|
|
125
|
-
return {
|
|
126
|
-
type: 'CUSTOM_LIST',
|
|
127
|
-
urlObject,
|
|
128
|
-
routeID: customListRouteId
|
|
129
|
-
};
|
|
127
|
+
})
|
|
128
|
+
.map((options) => {
|
|
129
|
+
if (options.type === 'NATIVE' || options.type === 'CUSTOM_LIST') {
|
|
130
|
+
driver.showNativeRouteView();
|
|
131
|
+
}
|
|
132
|
+
else if (options.type === 'CUSTOM_LIST_TRIGGER') {
|
|
133
|
+
driver.showCustomThreadList(options.routeID, get(customListRouteIDs, options.routeID), options.urlObject.params);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
return new GmailRouteView(options, gmailRouteProcessor, driver);
|
|
137
|
+
})
|
|
138
|
+
.filter(Boolean)
|
|
139
|
+
.map((gmailRouteView) => {
|
|
140
|
+
if (latestGmailRouteView) {
|
|
141
|
+
latestGmailRouteView.destroy();
|
|
130
142
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const MAX_KEY_CACHE = 50;
|
|
136
|
-
const {
|
|
137
|
-
urlObject
|
|
138
|
-
} = options;
|
|
139
|
-
if (!sameRouteData[urlObject.hash]) {
|
|
140
|
-
sameRouteData[urlObject.hash] = {
|
|
141
|
-
data: {}
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
sameRouteData[urlObject.hash].lastUsedTimestamp = Date.now();
|
|
145
|
-
if (Object.keys(sameRouteData).length > MAX_KEY_CACHE) {
|
|
146
|
-
sameRouteData = Object.keys(sameRouteData).sort((a, b) => sameRouteData[b].lastUsedTimestamp - sameRouteData[a].lastUsedTimestamp).slice(0, MAX_KEY_CACHE / 2).reduce((acc, hash) => ({
|
|
147
|
-
...acc,
|
|
148
|
-
[hash]: sameRouteData[hash]
|
|
149
|
-
}), {});
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
...options,
|
|
153
|
-
cachedRouteData: sameRouteData[urlObject.hash].data
|
|
154
|
-
};
|
|
155
|
-
}).map(options => {
|
|
156
|
-
if (options.type === 'NATIVE' || options.type === 'CUSTOM_LIST') {
|
|
157
|
-
driver.showNativeRouteView();
|
|
158
|
-
} else if (options.type === 'CUSTOM_LIST_TRIGGER') {
|
|
159
|
-
driver.showCustomThreadList(options.routeID, (0, _getOrFail.default)(customListRouteIDs, options.routeID), options.urlObject.params);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
return new _gmailRouteView.default(options, gmailRouteProcessor, driver);
|
|
163
|
-
}).filter(Boolean).map(gmailRouteView => {
|
|
164
|
-
if (latestGmailRouteView) {
|
|
165
|
-
latestGmailRouteView.destroy();
|
|
166
|
-
}
|
|
167
|
-
latestGmailRouteView = gmailRouteView;
|
|
168
|
-
lastHash = (0, _getUrlObject.default)(document.location.href).hash;
|
|
169
|
-
return gmailRouteView;
|
|
170
|
-
});
|
|
143
|
+
latestGmailRouteView = gmailRouteView;
|
|
144
|
+
lastHash = getURLObject(document.location.href).hash;
|
|
145
|
+
return gmailRouteView;
|
|
146
|
+
});
|
|
171
147
|
}
|
|
172
|
-
|
|
173
148
|
/*
|
|
174
149
|
* TODO: Split up "role=main" DOM watching and hash change watching.
|
|
175
150
|
*
|
|
176
151
|
* SDK only cares about hash change when the hash goes to a route that the app registered as custom.
|
|
177
152
|
* Otherwise it only responds to route changes when the role=main div changes.
|
|
178
|
-
*/
|
|
153
|
+
*/
|
package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-app-id-warning.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-app-id-warning.d.ts","sourceRoot":"","sources":["../../../../../../../src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-app-id-warning.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,WAAW,MAAM,iBAAiB,CAAC;AAE/C,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,MAAM,EAAE,WAAW,QAuB3D"}
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.default = showAppIdWarning;
|
|
8
|
-
var _kefir = _interopRequireDefault(require("kefir"));
|
|
9
|
-
var _kefirCast = _interopRequireDefault(require("kefir-cast"));
|
|
10
|
-
var _fakeWindowResize = _interopRequireDefault(require("../../../lib/fake-window-resize"));
|
|
11
|
-
function showAppIdWarning(driver) {
|
|
12
|
-
const topDiv = document.createElement('div');
|
|
13
|
-
topDiv.className = 'inboxsdk__appid_warning';
|
|
14
|
-
topDiv.innerHTML = `
|
|
1
|
+
import Kefir from 'kefir';
|
|
2
|
+
import kefirCast from 'kefir-cast';
|
|
3
|
+
export default function showAppIdWarning(driver) {
|
|
4
|
+
const topDiv = document.createElement('div');
|
|
5
|
+
topDiv.className = 'inboxsdk__appid_warning';
|
|
6
|
+
topDiv.innerHTML = `
|
|
15
7
|
<div class="inboxsdk__appid_warning_main">
|
|
16
8
|
<div class="topline">InboxSDK Developer Warning: Invalid AppId</div>
|
|
17
9
|
<div>You've loaded the InboxSDK with an unregistered appId. Registration is free but necessary to load the SDK.</div>
|
|
@@ -19,12 +11,11 @@ function showAppIdWarning(driver) {
|
|
|
19
11
|
<a class="inboxsdk__appid_register" target="_blank" href="https://www.inboxsdk.com/register">Register Your App</a>
|
|
20
12
|
<input type="button" value="" title="Close" class="inboxsdk__x_close_button" />
|
|
21
13
|
`;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
14
|
+
const topMessageBarDriver = driver.createTopMessageBarDriver(kefirCast(Kefir, { el: topDiv }));
|
|
15
|
+
const closeBtn = topDiv.querySelector('.inboxsdk__x_close_button');
|
|
16
|
+
if (!closeBtn)
|
|
17
|
+
throw new Error('Should not happen');
|
|
18
|
+
closeBtn.addEventListener('click', function (_e) {
|
|
19
|
+
topMessageBarDriver.remove();
|
|
20
|
+
});
|
|
21
|
+
}
|
package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-route-view.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-custom-route-view.d.ts","sourceRoot":"","sources":["../../../../../../../src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-route-view.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,mBAAmB,gBAEmB,GAAG,WAAW,WAAW,SA+CpE,CAAC;AACF,eAAe,mBAAmB,CAAC"}
|
package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-route-view.js
CHANGED
|
@@ -1,56 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _ud = require("ud");
|
|
9
|
-
var _gmailElementGetter = _interopRequireDefault(require("../gmail-element-getter"));
|
|
10
|
-
var _simulateMouseEvent = require("../../../lib/dom/simulate-mouse-event");
|
|
1
|
+
import { defn } from 'ud';
|
|
2
|
+
import GmailElementGetter from '../gmail-element-getter';
|
|
11
3
|
const ACTIVE_ADD_ON_ICON_SELECTOR = '.J-KU-KO';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const selection = document.getSelection();
|
|
18
|
-
for (let i = 0; i < selection.rangeCount; i++) {
|
|
19
|
-
const range = selection.getRangeAt(i);
|
|
20
|
-
if (typeof range.intersectsNode === 'function' && range.intersectsNode(contentSectionElement)) {
|
|
21
|
-
selection.removeAllRanges();
|
|
22
|
-
break;
|
|
4
|
+
import { simulateClick } from '../../../lib/dom/simulate-mouse-event';
|
|
5
|
+
const showCustomRouteView = defn(module, function showCustomRouteView(gmailDriver, element) {
|
|
6
|
+
const contentSectionElement = GmailElementGetter.getContentSectionElement();
|
|
7
|
+
if (!contentSectionElement) {
|
|
8
|
+
return;
|
|
23
9
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
10
|
+
const selection = document.getSelection();
|
|
11
|
+
for (let i = 0; i < selection.rangeCount; i++) {
|
|
12
|
+
const range = selection.getRangeAt(i);
|
|
13
|
+
if (typeof range.intersectsNode === 'function' &&
|
|
14
|
+
range.intersectsNode(contentSectionElement)) {
|
|
15
|
+
selection.removeAllRanges();
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
31
18
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
19
|
+
const customViewContainerElement = _getCustomViewContainerElement(contentSectionElement);
|
|
20
|
+
customViewContainerElement.appendChild(element);
|
|
21
|
+
const children = contentSectionElement.children;
|
|
22
|
+
Array.prototype.forEach.call(children, (child) => {
|
|
23
|
+
if (child.classList.contains('inboxsdk__custom_view')) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
child.style.display = 'none';
|
|
27
|
+
});
|
|
28
|
+
//if any thread sidebar addons are enabled then we need to turn them off
|
|
29
|
+
const companionSidebarIconContainerEl = GmailElementGetter.getCompanionSidebarIconContainerElement();
|
|
30
|
+
if (companionSidebarIconContainerEl) {
|
|
31
|
+
const activeThreadAddOnIcon = companionSidebarIconContainerEl.querySelector(ACTIVE_ADD_ON_ICON_SELECTOR);
|
|
32
|
+
if (activeThreadAddOnIcon) {
|
|
33
|
+
simulateClick(activeThreadAddOnIcon);
|
|
34
|
+
}
|
|
41
35
|
}
|
|
42
|
-
|
|
43
|
-
document.body.classList.add('inboxsdk__custom_view_active');
|
|
36
|
+
document.body.classList.add('inboxsdk__custom_view_active');
|
|
44
37
|
});
|
|
45
|
-
|
|
46
|
-
exports.default = _default;
|
|
38
|
+
export default showCustomRouteView;
|
|
47
39
|
function _getCustomViewContainerElement(contentSectionElement) {
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
let customViewContainerElement = contentSectionElement.querySelector('.inboxsdk__custom_view');
|
|
41
|
+
if (customViewContainerElement) {
|
|
42
|
+
return customViewContainerElement;
|
|
43
|
+
}
|
|
44
|
+
customViewContainerElement = document.createElement('div');
|
|
45
|
+
customViewContainerElement.classList.add('inboxsdk__custom_view');
|
|
46
|
+
contentSectionElement.appendChild(customViewContainerElement);
|
|
50
47
|
return customViewContainerElement;
|
|
51
|
-
|
|
52
|
-
customViewContainerElement = document.createElement('div');
|
|
53
|
-
customViewContainerElement.classList.add('inboxsdk__custom_view');
|
|
54
|
-
contentSectionElement.appendChild(customViewContainerElement);
|
|
55
|
-
return customViewContainerElement;
|
|
56
|
-
}
|
|
48
|
+
}
|
package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type GmailDriver from '../gmail-driver';
|
|
2
|
+
declare function _findIdFailure(id: string, err: Error): null;
|
|
3
|
+
export default function showCustomThreadList(driver: GmailDriver, customRouteID: string, onActivate: Function, params: Array<string>, findIdFailure?: typeof _findIdFailure): void;
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=show-custom-thread-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-custom-thread-list.d.ts","sourceRoot":"","sources":["../../../../../../../src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,WAAW,MAAM,iBAAiB,CAAC;AA2F/C,iBAAS,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,QAG7C;AA4XD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,MAAM,EAAE,WAAW,EACnB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,QAAQ,EACpB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EACrB,aAAa,GAAE,OAAO,cAA+B,QAgCtD"}
|