@inboxsdk/core 1.0.5 → 1.1.1
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 +25 -192
- package/inboxsdk.js.map +1 -1
- package/package.json +1 -1
- package/pageWorld.js +3 -47
- package/pageWorld.js.map +1 -1
- package/src/inboxsdk-js/inboxsdk-NONREMOTE-INTEGRATED-PAGEWORLD.d.ts +3 -0
- package/src/inboxsdk-js/inboxsdk-NONREMOTE-INTEGRATED-PAGEWORLD.d.ts.map +1 -0
- package/src/inboxsdk-js/inboxsdk-NONREMOTE-INTEGRATED-PAGEWORLD.js +3 -8
- package/src/inboxsdk-js/inboxsdk-NONREMOTE.d.ts +3 -0
- package/src/inboxsdk-js/inboxsdk-NONREMOTE.d.ts.map +1 -0
- package/src/inboxsdk-js/inboxsdk-NONREMOTE.js +4 -6
- package/src/inboxsdk-js/inboxsdk-REMOTE.d.ts +3 -0
- package/src/inboxsdk-js/inboxsdk-REMOTE.d.ts.map +1 -0
- package/src/inboxsdk-js/inboxsdk-REMOTE.js +2 -5
- package/src/inboxsdk-js/inboxsdk-TEST.d.ts +3 -0
- package/src/inboxsdk-js/inboxsdk-TEST.d.ts.map +1 -0
- package/src/inboxsdk-js/inboxsdk-TEST.js +5 -6
- package/src/inboxsdk-js/inboxsdk.d.ts +8 -0
- package/src/inboxsdk-js/inboxsdk.d.ts.map +1 -0
- package/src/inboxsdk-js/inboxsdk.js +22 -32
- package/src/inboxsdk-js/loading/load-platform-implementation-DEV.d.ts +2 -0
- package/src/inboxsdk-js/loading/load-platform-implementation-DEV.d.ts.map +1 -0
- package/src/inboxsdk-js/loading/load-platform-implementation-DEV.js +14 -16
- package/src/inboxsdk-js/loading/platform-implementation-loader.d.ts +1 -1
- package/src/inboxsdk-js/loading/platform-implementation-loader.d.ts.map +1 -1
- package/src/injected-js/gmail/setup-gmail-interceptor.js +7 -14
- package/src/injected-js/main.js +0 -9
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.d.ts.map +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.js +0 -2
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-menu-item-view.js +2 -1
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/index.js +1 -2
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/index.test.js +10 -1
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/index.js +39 -35
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-toolbar-button-view.js +1 -2
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-card-view.js +2 -3
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-collapsible-section-view.js +13 -14
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-compose-notice.js +1 -2
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/size-fixer.js +2 -2
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view.js +3 -4
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view.js +7 -8
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-view.js +28 -31
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-row-list-view.js +4 -5
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-row-view.js +2 -3
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-sidebar-view.js +1 -2
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-sidebar-view.test.js +10 -0
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-view.js +10 -11
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-toolbar-view.js +4 -5
- package/src/platform-implementation-js/dom-driver/gmail/views/native-gmail-nav-item-view.js +3 -4
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-mole-view-driver.js +2 -3
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-tooltip-view.js +2 -3
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-backdrop.js +2 -3
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-drawer-view.js +5 -6
- package/src/platform-implementation-js/driver-common/sidebar/AppSidebar.js +1 -2
- package/src/platform-implementation-js/driver-common/sidebar/ContentPanelViewDriver.js +4 -5
- package/src/platform-implementation-js/lib/idMap.d.ts +1 -2
- package/src/platform-implementation-js/lib/idMap.d.ts.map +1 -1
- package/src/platform-implementation-js/lib/idMap.js +4 -44
- package/src/platform-implementation-js/lib/inject-script-EMBEDDED.d.ts.map +1 -1
- package/src/platform-implementation-js/lib/inject-script-EMBEDDED.js +3 -4
- package/src/platform-implementation-js/lib/react/ElementContainer.js +3 -7
- package/src/platform-implementation-js/main-INTEGRATED-PAGEWORLD.d.ts +3 -0
- package/src/platform-implementation-js/main-INTEGRATED-PAGEWORLD.d.ts.map +1 -0
- package/src/platform-implementation-js/main-INTEGRATED-PAGEWORLD.js +5 -9
- package/src/platform-implementation-js/main.d.ts +5 -0
- package/src/platform-implementation-js/main.d.ts.map +1 -0
- package/src/platform-implementation-js/main.js +38 -61
- package/src/platform-implementation-js/namespaces/conversations.js +2 -3
- package/src/platform-implementation-js/namespaces/lists.js +1 -2
- package/src/platform-implementation-js/namespaces/nav-menu.js +2 -3
- package/src/platform-implementation-js/namespaces/router.js +3 -4
- package/src/platform-implementation-js/namespaces/toolbars.js +1 -2
- package/src/platform-implementation-js/platform-implementation.d.ts +0 -3
- package/src/platform-implementation-js/platform-implementation.js +1 -11
- package/src/platform-implementation-js/views/app-menu-item-view.js +2 -1
- package/src/platform-implementation-js/views/collapsible-panel-view.js +2 -1
- package/src/platform-implementation-js/views/content-panel-view.js +1 -2
- package/src/platform-implementation-js/views/conversations/custom-message-view.js +3 -4
- package/src/platform-implementation-js/views/conversations/message-view.js +1 -2
- package/src/platform-implementation-js/views/conversations/thread-view.js +1 -2
- package/src/platform-implementation-js/views/nav-item-view.js +1 -2
- package/src/platform-implementation-js/views/route-view/dummy-route-view-driver.js +2 -3
- package/src/platform-implementation-js/widgets/drawer-view.js +1 -2
- package/src/platform-implementation-js/widgets/modal-view.js +1 -2
- package/src/platform-implementation-js/widgets/mole-view.js +1 -2
- package/src/injected-js/inbox/setupAjaxInterceptor.js +0 -211
- package/src/injected-js/inbox/setupClickAndGetNewIframeSrc.js +0 -67
- package/src/injected-js/inbox/setupComposeViewDraftIDFinder.js +0 -35
- package/src/injected-js/inbox/setupInboxFakeWindowResizeListener.js +0 -29
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.d.ts +0 -2
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.d.ts.map +0 -1
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.js +0 -17
- package/src/platform-implementation-js/dom-driver/inbox/__mocks__/getSidebarClassnames.js +0 -13
- package/src/platform-implementation-js/dom-driver/inbox/addNavItem.js +0 -38
- package/src/platform-implementation-js/dom-driver/inbox/addRecipientRow.js +0 -55
- package/src/platform-implementation-js/dom-driver/inbox/createLink.js +0 -19
- package/src/platform-implementation-js/dom-driver/inbox/createLink.test.js +0 -27
- package/src/platform-implementation-js/dom-driver/inbox/custom-style.js +0 -23
- package/src/platform-implementation-js/dom-driver/inbox/detection/appToolbarLocation/parser.js +0 -43
- package/src/platform-implementation-js/dom-driver/inbox/detection/attachmentCard/parser.js +0 -34
- package/src/platform-implementation-js/dom-driver/inbox/detection/attachmentOverlay/parser.js +0 -53
- package/src/platform-implementation-js/dom-driver/inbox/detection/chatSidebar/parser.js +0 -31
- package/src/platform-implementation-js/dom-driver/inbox/detection/compose/parser.js +0 -103
- package/src/platform-implementation-js/dom-driver/inbox/detection/message/parser.js +0 -69
- package/src/platform-implementation-js/dom-driver/inbox/detection/nativeDrawer/parser.js +0 -32
- package/src/platform-implementation-js/dom-driver/inbox/detection/searchBar/parser.js +0 -28
- package/src/platform-implementation-js/dom-driver/inbox/detection/thread/parser.js +0 -49
- package/src/platform-implementation-js/dom-driver/inbox/detection/thread-row/parser.js +0 -100
- package/src/platform-implementation-js/dom-driver/inbox/getComposeViewDriverLiveSet.js +0 -99
- package/src/platform-implementation-js/dom-driver/inbox/getInboxMessageIdForInboxThreadId.js +0 -36
- package/src/platform-implementation-js/dom-driver/inbox/getSidebarClassnames.js +0 -114
- package/src/platform-implementation-js/dom-driver/inbox/getSidebarClassnames.test.js +0 -73
- package/src/platform-implementation-js/dom-driver/inbox/gotoView.js +0 -39
- package/src/platform-implementation-js/dom-driver/inbox/gotoView.test.js +0 -28
- package/src/platform-implementation-js/dom-driver/inbox/inbox-butter-bar-driver.js +0 -148
- package/src/platform-implementation-js/dom-driver/inbox/inbox-driver.js +0 -866
- package/src/platform-implementation-js/dom-driver/inbox/inbox-page-communicator.js +0 -62
- package/src/platform-implementation-js/dom-driver/inbox/inboxResponseProcessor.js +0 -12
- package/src/platform-implementation-js/dom-driver/inbox/inboxResponseProcessor.test.js +0 -18
- package/src/platform-implementation-js/dom-driver/inbox/makePageParserTree.js +0 -33
- package/src/platform-implementation-js/dom-driver/inbox/pageParserOptions.js +0 -265
- package/src/platform-implementation-js/dom-driver/inbox/registerSearchSuggestionsProvider.js +0 -301
- package/src/platform-implementation-js/dom-driver/inbox/setupCustomAutocompleteSelectionHandling.js +0 -183
- package/src/platform-implementation-js/dom-driver/inbox/setupRouteViewDriverStream.js +0 -64
- package/src/platform-implementation-js/dom-driver/inbox/setupRouteViewDriverStream.test.js +0 -72
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxLabelView.js +0 -78
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxMoleViewDriver.js +0 -297
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxToolbarButtonView.js +0 -92
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxToolbarView.js +0 -54
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-sidebar-view.js +0 -272
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-toolbar-button-view.js +0 -161
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-toolbar-tooltip-view.js +0 -58
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-attachment-card-view.js +0 -198
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-attachment-overlay-view.js +0 -90
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-chat-sidebar-view.js +0 -46
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-compose-button-view.js +0 -116
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-compose-view.js +0 -843
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-custom-route-view.js +0 -76
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-custom-route-view.test.js +0 -31
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-dropdown-view.js +0 -25
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-dummy-route-view.js +0 -64
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-message-view.js +0 -275
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-modal-view.js +0 -113
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-route-view.js +0 -97
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-row-view.js +0 -316
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-view.js +0 -219
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-view.test.js +0 -171
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-tooltip-view.js +0 -128
- package/src/platform-implementation-js/dom-driver/inbox/views/inboxNavItemView.js +0 -312
- package/src/platform-implementation-js/dom-driver/inbox/waitForAnimationClickBlockerGone.js +0 -26
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.d.ts +0 -2
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.d.ts.map +0 -1
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.js +0 -4
- package/src/platform-implementation-js/lib/shared-style.js +0 -23
- package/src/types/gulp-add-src.d.ts +0 -7
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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 _difference = _interopRequireDefault(require("lodash/difference"));
|
|
9
|
-
var _once = _interopRequireDefault(require("lodash/once"));
|
|
10
|
-
var _flatMap = _interopRequireDefault(require("lodash/flatMap"));
|
|
11
|
-
var _last = _interopRequireDefault(require("lodash/last"));
|
|
12
|
-
var _transducers = _interopRequireDefault(require("transducers.js"));
|
|
13
|
-
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
|
|
14
|
-
var _logger = _interopRequireDefault(require("../../lib/logger"));
|
|
15
|
-
var _querySelectorOrFail = _interopRequireDefault(require("../../lib/dom/querySelectorOrFail"));
|
|
16
|
-
const cssProcessor = (0, _postcssSelectorParser.default)();
|
|
17
|
-
|
|
18
|
-
// There are specific classnames which are added when the chat or nav sidebars
|
|
19
|
-
// are open which affect the layout of the page. We need to be able to activate
|
|
20
|
-
// that chat sidebar layout ourselves, and we don't want to hardcode this
|
|
21
|
-
// classname because Inbox is prone to changing their classnames.
|
|
22
|
-
|
|
23
|
-
// We also get the classname for the center list element which has margins
|
|
24
|
-
// applied to it depending on the current page width and sidebar settings to
|
|
25
|
-
// keep it lined up with the search bar.
|
|
26
|
-
|
|
27
|
-
const getSidebarClassnames = (0, _once.default)(() => {
|
|
28
|
-
// We know that the page has a CSS rule which looks like
|
|
29
|
-
// .blah.chat .foo { margin-right: bigger number; margin-left: smaller number; }
|
|
30
|
-
// where .chat is the chat sidebar classname that we want to know, and .foo
|
|
31
|
-
// is one of the classnames that's on the [role=application] element.
|
|
32
|
-
|
|
33
|
-
// We could search the rules for this rule, but then we don't know which part
|
|
34
|
-
// of the selector string is the chat sidebar classname!
|
|
35
|
-
|
|
36
|
-
// There's also another similar rule for when only the nav sidebar is open:
|
|
37
|
-
// .blah.nav .foo { margin-right: smaller number; margin-left: bigger number; }
|
|
38
|
-
// If we find both of thse rules, then we can find the classname which is
|
|
39
|
-
// mentioned in the chat sidebar rule which is not mentioned in the nav
|
|
40
|
-
// sidebar rule.
|
|
41
|
-
|
|
42
|
-
// So first we find all the classnames on the [role=application] and make a
|
|
43
|
-
// regex for each one.
|
|
44
|
-
const classRegexes = Array.from((0, _querySelectorOrFail.default)(document, '[role=application]').classList).map(x => new RegExp('\\.' + x + '\\b'));
|
|
45
|
-
if (classRegexes.length === 0) throw new Error('no class names on element');
|
|
46
|
-
|
|
47
|
-
// rules will contain both the chat and nav sidebar rules.
|
|
48
|
-
const rules = _transducers.default.toArray(Array.prototype.slice.call(document.styleSheets), _transducers.default.compose(_transducers.default.filter(sheet => {
|
|
49
|
-
try {
|
|
50
|
-
return sheet.cssRules && sheet.cssRules.length;
|
|
51
|
-
} catch (err) {
|
|
52
|
-
// ignore. Sometimes pages have stylesheets that don't permit their
|
|
53
|
-
// rules to be enumerated. Possibly caused by other extensions including
|
|
54
|
-
// a css file from another domain?
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
}), _transducers.default.mapcat(sheet => Array.prototype.slice.call(sheet.cssRules || [])), _transducers.default.mapcat(rulesToStyleRules),
|
|
58
|
-
// We have all page rules. Filter it down to just rules mentioning one of
|
|
59
|
-
// [role=application]'s classnames.
|
|
60
|
-
_transducers.default.filter(rule => classRegexes.some(r => r.test(rule.selectorText))),
|
|
61
|
-
// Now just the rules that contain both margin-left and -right rules.
|
|
62
|
-
_transducers.default.filter(rule => rule.style['margin-left'] && rule.style['margin-right'])));
|
|
63
|
-
const onlyNavSidebarRule = _transducers.default.toArray(Array.prototype.slice.call(rules), _transducers.default.compose(_transducers.default.filter(rule => parseFloat(rule.style['margin-left']) > parseFloat(rule.style['margin-right'])), _transducers.default.take(1)))[0];
|
|
64
|
-
const onlyChatSidebarRule = _transducers.default.toArray(Array.prototype.slice.call(rules), _transducers.default.compose(_transducers.default.filter(rule => parseFloat(rule.style['margin-left']) < parseFloat(rule.style['margin-right'])), _transducers.default.take(1)))[0];
|
|
65
|
-
if (!onlyNavSidebarRule || !onlyChatSidebarRule) {
|
|
66
|
-
const err = new Error('Failed to parse element CSS rules');
|
|
67
|
-
_logger.default.error(err, {
|
|
68
|
-
rulesCount: rules.length,
|
|
69
|
-
hasOnlyNavSidebarRule: !!onlyNavSidebarRule,
|
|
70
|
-
hasOnlyChatSidebarRule: !!onlyChatSidebarRule
|
|
71
|
-
});
|
|
72
|
-
throw err;
|
|
73
|
-
}
|
|
74
|
-
function getMentionedClassNames(node) {
|
|
75
|
-
switch (node.type) {
|
|
76
|
-
case 'root':
|
|
77
|
-
case 'selector':
|
|
78
|
-
return (0, _flatMap.default)(node.nodes, getMentionedClassNames);
|
|
79
|
-
case 'class':
|
|
80
|
-
return [node.value];
|
|
81
|
-
default:
|
|
82
|
-
return [];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const onlyNavSidebarRuleClassNames = getMentionedClassNames(cssProcessor.process(onlyNavSidebarRule.selectorText).res);
|
|
86
|
-
const onlyChatSidebarRuleClassNames = getMentionedClassNames(cssProcessor.process(onlyChatSidebarRule.selectorText).res);
|
|
87
|
-
const chatSidebarClassNames = (0, _difference.default)(onlyChatSidebarRuleClassNames, onlyNavSidebarRuleClassNames);
|
|
88
|
-
const navSidebarClassNames = (0, _difference.default)(onlyNavSidebarRuleClassNames, onlyChatSidebarRuleClassNames);
|
|
89
|
-
const centerListClassName = (0, _last.default)(onlyNavSidebarRuleClassNames) === (0, _last.default)(onlyChatSidebarRuleClassNames) ? (0, _last.default)(onlyNavSidebarRuleClassNames) : null;
|
|
90
|
-
if (chatSidebarClassNames.length !== 1 || navSidebarClassNames.length !== 1 || !centerListClassName) {
|
|
91
|
-
_logger.default.error(new Error('Failed to find sidebar classnames'), {
|
|
92
|
-
onlyNavSidebarRuleClassNames,
|
|
93
|
-
onlyChatSidebarRuleClassNames,
|
|
94
|
-
chatSidebarClassNames,
|
|
95
|
-
navSidebarClassNames,
|
|
96
|
-
centerListClassName
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
chat: chatSidebarClassNames[0],
|
|
101
|
-
nav: navSidebarClassNames[0],
|
|
102
|
-
centerList: centerListClassName
|
|
103
|
-
};
|
|
104
|
-
});
|
|
105
|
-
var _default = getSidebarClassnames;
|
|
106
|
-
exports.default = _default;
|
|
107
|
-
function rulesToStyleRules(rule) {
|
|
108
|
-
if (rule instanceof window.CSSMediaRule) {
|
|
109
|
-
return (0, _flatMap.default)(rule.cssRules, rulesToStyleRules);
|
|
110
|
-
} else if (rule instanceof window.CSSStyleRule) {
|
|
111
|
-
return [rule];
|
|
112
|
-
}
|
|
113
|
-
return [];
|
|
114
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _getSidebarClassnames = _interopRequireDefault(require("./getSidebarClassnames"));
|
|
5
|
-
document.documentElement.innerHTML = `
|
|
6
|
-
<head>
|
|
7
|
-
<style type="text/css">
|
|
8
|
-
.blah {
|
|
9
|
-
color: red;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.bz, .bS {
|
|
13
|
-
width: 1200px;
|
|
14
|
-
margin-left: auto;
|
|
15
|
-
margin-right: auto;
|
|
16
|
-
}
|
|
17
|
-
@media (max-width: 1800px) {
|
|
18
|
-
.bz, .bS {
|
|
19
|
-
width: 66.66%;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
@media (max-width: 1260px) {
|
|
23
|
-
.bz, .bS {
|
|
24
|
-
width: 840px;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
.cM {
|
|
28
|
-
min-width: 512px;
|
|
29
|
-
padding: 56px 0 1px;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/* chat sidebar open rules */
|
|
33
|
-
@media (max-width: 1632px) {
|
|
34
|
-
.m .bz {
|
|
35
|
-
width: auto;
|
|
36
|
-
margin-left: 50px;
|
|
37
|
-
margin-right: 272px;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/* nav sidebar open rules */
|
|
42
|
-
@media (max-width: 1632px) {
|
|
43
|
-
.M .bz {
|
|
44
|
-
width: auto;
|
|
45
|
-
margin-left: 272px;
|
|
46
|
-
margin-right: 104px;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/* both open */
|
|
51
|
-
@media (max-width: 1632px) {
|
|
52
|
-
.m.M .bz {
|
|
53
|
-
margin-left: 272px;
|
|
54
|
-
margin-right: 272px;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
</style>
|
|
58
|
-
</head>
|
|
59
|
-
<body>
|
|
60
|
-
<div>
|
|
61
|
-
<div role="application" class="cM bz">
|
|
62
|
-
<p>foo
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
</body>
|
|
66
|
-
`;
|
|
67
|
-
test('works', () => {
|
|
68
|
-
expect((0, _getSidebarClassnames.default)()).toEqual({
|
|
69
|
-
chat: 'm',
|
|
70
|
-
nav: 'M',
|
|
71
|
-
centerList: 'bz'
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = gotoView;
|
|
8
|
-
var _includes = _interopRequireDefault(require("lodash/includes"));
|
|
9
|
-
var _populateRouteID = _interopRequireDefault(require("../../lib/populateRouteID"));
|
|
10
|
-
var _routeIDmatchesHash = _interopRequireDefault(require("../../lib/routeIDmatchesHash"));
|
|
11
|
-
var _router = require("../../constants/router");
|
|
12
|
-
function gotoView(driver, routeID, params) {
|
|
13
|
-
if ((0, _includes.default)(Object.values(_router.NATIVE_ROUTE_IDS), routeID)) {
|
|
14
|
-
throw new Error('NativeRouteIDs are not currently supported in Inbox');
|
|
15
|
-
}
|
|
16
|
-
if (!driver.getCustomRouteIDs().has(routeID)) {
|
|
17
|
-
const startedWithHash = routeID[0] === '#';
|
|
18
|
-
if (startedWithHash) {
|
|
19
|
-
routeID = routeID.slice(1);
|
|
20
|
-
}
|
|
21
|
-
let foundRouteID = false;
|
|
22
|
-
if (!params) {
|
|
23
|
-
// If params were given, then we don't assume it was a resolved/populated URL
|
|
24
|
-
for (let routeIDs of driver.getCustomRouteIDs()) {
|
|
25
|
-
if ((0, _routeIDmatchesHash.default)(routeIDs, routeID)) {
|
|
26
|
-
foundRouteID = true;
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (!foundRouteID) {
|
|
32
|
-
throw new Error(`Invalid routeID: ${routeID}`);
|
|
33
|
-
}
|
|
34
|
-
if (!startedWithHash) {
|
|
35
|
-
driver.getLogger().deprecationWarning('Router.goto resolved routeID without "#" prefix');
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
document.location.hash = (0, _populateRouteID.default)(routeID, params);
|
|
39
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _gotoView = _interopRequireDefault(require("./gotoView"));
|
|
5
|
-
function makeDriver() {
|
|
6
|
-
const customRouteIDs = new Set();
|
|
7
|
-
return {
|
|
8
|
-
getCustomRouteIDs: () => customRouteIDs
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
test('works for custom view', () => {
|
|
12
|
-
const driver = makeDriver();
|
|
13
|
-
driver.getCustomRouteIDs().add('example/:bar');
|
|
14
|
-
(0, _gotoView.default)(driver, 'example/:bar', {
|
|
15
|
-
bar: 'foo'
|
|
16
|
-
});
|
|
17
|
-
expect(document.location.hash).toBe('#example/foo');
|
|
18
|
-
});
|
|
19
|
-
test('fails for unknown route id', () => {
|
|
20
|
-
expect(() => (0, _gotoView.default)(makeDriver(), 'example/:bar', {
|
|
21
|
-
bar: 'foo'
|
|
22
|
-
})).toThrowError('Invalid routeID: example/:bar');
|
|
23
|
-
});
|
|
24
|
-
test('fails for native route ids', () => {
|
|
25
|
-
expect(() => (0, _gotoView.default)(makeDriver(), 'inbox/:threadID', {
|
|
26
|
-
threadID: 'abc'
|
|
27
|
-
})).toThrowError('NativeRouteIDs are not currently supported in Inbox');
|
|
28
|
-
});
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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 _kefir = _interopRequireDefault(require("kefir"));
|
|
9
|
-
var _streamWaitFor = _interopRequireDefault(require("../../lib/stream-wait-for"));
|
|
10
|
-
var _querySelectorOrFail = _interopRequireDefault(require("../../lib/dom/querySelectorOrFail"));
|
|
11
|
-
var _makeMutationObserverChunkedStream = _interopRequireDefault(require("../../lib/dom/make-mutation-observer-chunked-stream"));
|
|
12
|
-
const elements = (0, _streamWaitFor.default)(() => document.querySelector('body > div[id][jsaction] > div[id] > div[class][jsaction][aria-hidden]')).map(googleNotice => {
|
|
13
|
-
const noticeContainer = googleNotice.parentElement;
|
|
14
|
-
if (!noticeContainer) throw new Error('Should not happen');
|
|
15
|
-
let sdkNotice = noticeContainer.querySelector('.inboxsdk__butterbar');
|
|
16
|
-
if (!sdkNotice) {
|
|
17
|
-
sdkNotice = document.createElement('div');
|
|
18
|
-
sdkNotice.className = googleNotice.className + ' inboxsdk__butterbar';
|
|
19
|
-
sdkNotice.style.display = 'none';
|
|
20
|
-
noticeContainer.insertBefore(sdkNotice, googleNotice.nextSibling);
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
noticeContainer,
|
|
24
|
-
googleNotice,
|
|
25
|
-
sdkNotice
|
|
26
|
-
};
|
|
27
|
-
}).toProperty();
|
|
28
|
-
|
|
29
|
-
// We queue our notices separately from the native ones in Inbox.
|
|
30
|
-
|
|
31
|
-
const sdkNoticeIdChanges = elements.flatMapLatest(_ref => {
|
|
32
|
-
let {
|
|
33
|
-
sdkNotice
|
|
34
|
-
} = _ref;
|
|
35
|
-
return (0, _makeMutationObserverChunkedStream.default)(sdkNotice, {
|
|
36
|
-
attributes: true,
|
|
37
|
-
attributeFilter: ['data-inboxsdk-id']
|
|
38
|
-
}).map(() => sdkNotice.getAttribute('data-inboxsdk-id'));
|
|
39
|
-
});
|
|
40
|
-
const sdkRemovedNotice = sdkNoticeIdChanges.filter(id => id == null);
|
|
41
|
-
const noticeAvailableStream = sdkRemovedNotice;
|
|
42
|
-
function hideMessage(noticeContainer, googleNotice, sdkNotice) {
|
|
43
|
-
Object.assign(sdkNotice.style, {
|
|
44
|
-
opacity: '0',
|
|
45
|
-
transform: '',
|
|
46
|
-
transition: 'opacity 100ms'
|
|
47
|
-
});
|
|
48
|
-
sdkNotice.removeAttribute('data-inboxsdk-id');
|
|
49
|
-
_kefir.default.fromEvents(sdkNotice, 'transitionend').merge(_kefir.default.later(200)) // transition might not finish if element is hidden
|
|
50
|
-
.takeUntilBy(sdkNoticeIdChanges.filter(id => id != null)).onValue(() => {
|
|
51
|
-
Object.assign(sdkNotice.style, {
|
|
52
|
-
display: 'none',
|
|
53
|
-
opacity: '',
|
|
54
|
-
transition: ''
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
class InboxButterBarDriver {
|
|
59
|
-
constructor() {
|
|
60
|
-
// Force stream to be in active state. sdkRemovedNotice is prone to missing
|
|
61
|
-
// events if it only becomes active once a message has started.
|
|
62
|
-
noticeAvailableStream.onValue(() => {});
|
|
63
|
-
}
|
|
64
|
-
getNoticeAvailableStream() {
|
|
65
|
-
return noticeAvailableStream;
|
|
66
|
-
}
|
|
67
|
-
getSharedMessageQueue() {
|
|
68
|
-
const attr = document.head.getAttribute('data-inboxsdk-butterbar-queue');
|
|
69
|
-
return attr ? JSON.parse(attr) : [];
|
|
70
|
-
}
|
|
71
|
-
setSharedMessageQueue(queue) {
|
|
72
|
-
const attr = JSON.stringify(queue);
|
|
73
|
-
document.head.setAttribute('data-inboxsdk-butterbar-queue', attr);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Immediately displays the message, overriding anything else on the screen.
|
|
77
|
-
// Priority and queuing logic is handled by butter-bar.js above this.
|
|
78
|
-
showMessage(rawOptions) {
|
|
79
|
-
const instanceId = Date.now() + '-' + Math.random();
|
|
80
|
-
elements.take(1).onValue(_ref2 => {
|
|
81
|
-
let {
|
|
82
|
-
noticeContainer,
|
|
83
|
-
googleNotice,
|
|
84
|
-
sdkNotice
|
|
85
|
-
} = _ref2;
|
|
86
|
-
sdkNotice.className = googleNotice.className;
|
|
87
|
-
sdkNotice.classList.add('inboxsdk__butterbar');
|
|
88
|
-
if (rawOptions.html) {
|
|
89
|
-
sdkNotice.innerHTML = rawOptions.html;
|
|
90
|
-
} else if (rawOptions.el) {
|
|
91
|
-
sdkNotice.innerHTML = '';
|
|
92
|
-
sdkNotice.appendChild(rawOptions.el);
|
|
93
|
-
} else {
|
|
94
|
-
sdkNotice.textContent = rawOptions.text;
|
|
95
|
-
}
|
|
96
|
-
if (rawOptions.className) {
|
|
97
|
-
sdkNotice.classList.add(rawOptions.className);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// If the sdkNotice is already up, just flash it out and in instead of
|
|
101
|
-
// animating it up into position.
|
|
102
|
-
if (sdkNotice.style.display === 'block' && getComputedStyle(sdkNotice).opacity === '1') {
|
|
103
|
-
Object.assign(sdkNotice.style, {
|
|
104
|
-
opacity: '0',
|
|
105
|
-
transform: 'none',
|
|
106
|
-
transition: 'none'
|
|
107
|
-
});
|
|
108
|
-
sdkNotice.offsetHeight; // force relayout
|
|
109
|
-
Object.assign(sdkNotice.style, {
|
|
110
|
-
opacity: '1',
|
|
111
|
-
transition: ''
|
|
112
|
-
});
|
|
113
|
-
} else {
|
|
114
|
-
Object.assign(sdkNotice.style, {
|
|
115
|
-
opacity: '0',
|
|
116
|
-
transform: '',
|
|
117
|
-
transition: '',
|
|
118
|
-
display: 'block'
|
|
119
|
-
});
|
|
120
|
-
sdkNotice.offsetHeight; // force relayout
|
|
121
|
-
Object.assign(sdkNotice.style, {
|
|
122
|
-
opacity: '1',
|
|
123
|
-
transform: 'none'
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
sdkNotice.setAttribute('data-inboxsdk-id', instanceId);
|
|
127
|
-
});
|
|
128
|
-
return {
|
|
129
|
-
destroy() {
|
|
130
|
-
elements.take(1).onValue(_ref3 => {
|
|
131
|
-
let {
|
|
132
|
-
noticeContainer,
|
|
133
|
-
googleNotice,
|
|
134
|
-
sdkNotice
|
|
135
|
-
} = _ref3;
|
|
136
|
-
if (sdkNotice.getAttribute('data-inboxsdk-id') === instanceId) {
|
|
137
|
-
if (rawOptions.className) sdkNotice.classList.remove(rawOptions.className);
|
|
138
|
-
hideMessage(noticeContainer, googleNotice, sdkNotice);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
hideGmailMessage() {
|
|
145
|
-
// No-op in Inbox because we don't touch the native messages
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
exports.default = InboxButterBarDriver;
|