@inboxsdk/core 0.2.28-alpha.4 → 0.2.28-alpha.6
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 +1 -1
- package/package.json +5 -1
- package/src/inboxsdk-js/check-requirements.js +7 -3
- package/src/inboxsdk-js/header.js +1 -0
- package/src/inboxsdk-js/inboxsdk-NONREMOTE-INTEGRATED-PAGEWORLD.js +5 -6
- package/src/inboxsdk-js/inboxsdk-NONREMOTE.js +4 -3
- package/src/inboxsdk-js/inboxsdk-REMOTE.js +3 -1
- package/src/inboxsdk-js/inboxsdk-TEST.js +4 -3
- package/src/inboxsdk-js/inboxsdk.js +33 -39
- package/src/inboxsdk-js/loading/load-platform-implementation-DEV.js +15 -18
- package/src/inboxsdk.d.ts +2 -0
- package/src/injected-js/gmail/modify-suggestions.test.js +8 -9
- package/src/injected-js/gmail/setup-gmail-interceptor.js +340 -579
- package/src/injected-js/gmail/sync-compose-request-processor.test.js +39 -49
- package/src/injected-js/gmail/thread-identifier/click-and-get-popup-url.js +20 -33
- package/src/injected-js/gmail/thread-identifier/index.js +57 -93
- package/src/injected-js/gmail/thread-identifier/thread-row-parser.js +22 -31
- package/src/injected-js/gmail/thread-identifier/thread-row-parser.test.js +12 -28
- package/src/injected-js/inbox/setupAjaxInterceptor.js +64 -121
- package/src/injected-js/inbox/setupClickAndGetNewIframeSrc.js +53 -66
- package/src/injected-js/inbox/setupComposeViewDraftIDFinder.js +20 -36
- package/src/injected-js/inbox/setupInboxFakeWindowResizeListener.js +13 -13
- package/src/injected-js/main.js +11 -24
- package/src/injected-js/message-metadata-holder.js +52 -82
- package/src/injected-js/setup-data-exposer.js +89 -148
- package/src/injected-js/setup-error-silencer.js +21 -21
- package/src/injected-js/setup-event-reemitter.js +30 -22
- package/src/injected-js/setupInboxCustomViewLinkFixer.js +24 -29
- package/src/injected-js/setupPushStateListener.js +18 -11
- package/src/injected-js/xhr-helper.js +62 -65
- package/src/injected-js/xhr-proxy-factory.js +195 -445
- package/src/injected-js/xhr-proxy-factory.test.js +824 -991
- package/src/platform-implementation-js/constants/router.js +14 -9
- package/src/platform-implementation-js/constants/toolbars.js +8 -3
- package/src/platform-implementation-js/dom-driver/gmail/custom-style.js +13 -13
- package/src/platform-implementation-js/dom-driver/gmail/gmail-butter-bar-driver.js +115 -136
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-toolbar-button-for-app.js +13 -14
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/create-link.js +27 -48
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-draft-id-for-message-id.js +31 -42
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-native-nav-item.js +30 -40
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-url-object.js +10 -18
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadForOldGmailThreadId.js +21 -28
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadFromSyncThreadId.js +33 -45
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/gmail-load-event.js +31 -49
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/goto-view.js +58 -65
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/keyboard-shortcut-help-modifier.js +40 -124
- 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/open-draft-by-message-id.test.js +10 -11
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/override-gmail-back-button.js +44 -80
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-query-rewriter.js +19 -26
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-suggestions-provider.js +71 -147
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-compose-view-driver-stream.js +91 -148
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.js +150 -166
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.test.js +70 -120
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-app-id-warning.js +15 -15
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-route-view.js +44 -67
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.js +230 -379
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.test.js +121 -307
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-native-route-view.js +17 -24
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/suppressAddon.js +41 -49
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/temporary-track-download-url-validity.js +30 -40
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/thread-row-identifier.js +28 -60
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-events.js +61 -133
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.js +30 -42
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.test.js +52 -46
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.js +354 -694
- package/src/platform-implementation-js/dom-driver/gmail/make-xhr-interceptor.js +77 -93
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/index.js +35 -82
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/index.test.js +44 -94
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/add-companion-global-icon-area.js +12 -19
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/add-companion-thread-icon-area.js +17 -29
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/add-to-icon-area.js +26 -26
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/index.js +391 -797
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-toolbar-button-view/monitor-top-banner-size-and-react.js +7 -9
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-toolbar-button-view.js +60 -109
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-area-view.js +95 -135
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-card-view.js +103 -211
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-card-view.test.js +61 -61
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-backdrop.js +17 -17
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-collapsible-section-view.js +188 -541
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-button.js +67 -135
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-compose-notice.js +27 -49
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-inner-sidebar.js +7 -13
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-outer-sidebar.js +9 -22
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-recipient-row.js +36 -63
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-tooltip-to-button.js +38 -113
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/ensure-app-button-toolbars-are-closed.js +11 -16
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/ensure-grouping-is-open.js +11 -17
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/focus.js +8 -11
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/from-manager.js +27 -47
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-additional-action-toolbar.js +11 -24
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-address-changes-stream.js +59 -111
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-body-changes-stream.js +15 -14
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-formatting-area-offset-left.js +11 -17
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-minimized-stream.js +18 -24
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-response-type-changes-stream.js +19 -23
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/insert-link-into-body.js +11 -19
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/manage-button-grouping.js +141 -376
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/monitor-selection-range.js +17 -28
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/override-edit-subject.js +34 -70
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/position-formatting-toolbar.js +10 -17
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/size-fixer.js +83 -137
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/update-insert-more-area-left.js +10 -19
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view.js +632 -1190
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view/get-updated-contact.js +29 -38
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view.js +327 -617
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-processor.js +26 -49
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-view.js +188 -380
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-row-list-view.js +104 -194
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-row-view.js +382 -811
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-sidebar-view/add-icon-area.js +34 -58
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-sidebar-view.js +330 -581
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-sidebar-view.test.js +123 -277
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-view/width-manager.js +15 -35
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-view.js +216 -571
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-toolbar-view.js +152 -336
- package/src/platform-implementation-js/dom-driver/gmail/views/native-gmail-nav-item-view.js +87 -211
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/inbox-dropdown-button-view.js +10 -11
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-action-button-view.js +20 -29
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-label-view.js +41 -76
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-modal-view-driver.js +45 -99
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-mole-view-driver.js +76 -128
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-tooltip-view.js +128 -319
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-top-message-bar-driver.js +45 -78
- package/src/platform-implementation-js/dom-driver/inbox/__mocks__/getSidebarClassnames.js +8 -4
- package/src/platform-implementation-js/dom-driver/inbox/addNavItem.js +36 -54
- package/src/platform-implementation-js/dom-driver/inbox/addRecipientRow.js +35 -53
- package/src/platform-implementation-js/dom-driver/inbox/createLink.js +13 -15
- package/src/platform-implementation-js/dom-driver/inbox/createLink.test.js +15 -18
- package/src/platform-implementation-js/dom-driver/inbox/custom-style.js +14 -13
- package/src/platform-implementation-js/dom-driver/inbox/detection/appToolbarLocation/parser.js +14 -20
- package/src/platform-implementation-js/dom-driver/inbox/detection/attachmentCard/parser.js +14 -13
- package/src/platform-implementation-js/dom-driver/inbox/detection/attachmentOverlay/parser.js +35 -67
- package/src/platform-implementation-js/dom-driver/inbox/detection/chatSidebar/parser.js +16 -18
- package/src/platform-implementation-js/dom-driver/inbox/detection/compose/parser.js +68 -185
- package/src/platform-implementation-js/dom-driver/inbox/detection/message/parser.js +28 -56
- package/src/platform-implementation-js/dom-driver/inbox/detection/nativeDrawer/parser.js +12 -10
- package/src/platform-implementation-js/dom-driver/inbox/detection/searchBar/parser.js +16 -16
- package/src/platform-implementation-js/dom-driver/inbox/detection/thread/parser.js +24 -35
- package/src/platform-implementation-js/dom-driver/inbox/detection/thread-row/parser.js +37 -89
- package/src/platform-implementation-js/dom-driver/inbox/getComposeViewDriverLiveSet.js +56 -78
- package/src/platform-implementation-js/dom-driver/inbox/getInboxMessageIdForInboxThreadId.js +26 -32
- package/src/platform-implementation-js/dom-driver/inbox/getSidebarClassnames.js +52 -109
- package/src/platform-implementation-js/dom-driver/inbox/getSidebarClassnames.test.js +7 -8
- package/src/platform-implementation-js/dom-driver/inbox/gotoView.js +16 -20
- package/src/platform-implementation-js/dom-driver/inbox/gotoView.test.js +15 -16
- package/src/platform-implementation-js/dom-driver/inbox/inbox-butter-bar-driver.js +75 -83
- package/src/platform-implementation-js/dom-driver/inbox/inbox-driver.js +530 -822
- package/src/platform-implementation-js/dom-driver/inbox/inbox-page-communicator.js +48 -61
- package/src/platform-implementation-js/dom-driver/inbox/inboxResponseProcessor.js +9 -12
- package/src/platform-implementation-js/dom-driver/inbox/inboxResponseProcessor.test.js +12 -19
- package/src/platform-implementation-js/dom-driver/inbox/makePageParserTree.js +24 -33
- package/src/platform-implementation-js/dom-driver/inbox/pageParserOptions.js +201 -388
- package/src/platform-implementation-js/dom-driver/inbox/registerSearchSuggestionsProvider.js +249 -265
- package/src/platform-implementation-js/dom-driver/inbox/setupCustomAutocompleteSelectionHandling.js +84 -152
- package/src/platform-implementation-js/dom-driver/inbox/setupRouteViewDriverStream.js +55 -67
- package/src/platform-implementation-js/dom-driver/inbox/setupRouteViewDriverStream.test.js +43 -65
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxLabelView.js +31 -56
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxMoleViewDriver.js +191 -294
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxToolbarButtonView.js +32 -45
- package/src/platform-implementation-js/dom-driver/inbox/views/InboxToolbarView.js +21 -39
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-sidebar-view.js +153 -240
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-toolbar-button-view.js +75 -150
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-app-toolbar-tooltip-view.js +20 -37
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-attachment-card-view.js +60 -114
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-attachment-overlay-view.js +47 -65
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-backdrop.js +41 -52
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-chat-sidebar-view.js +27 -36
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-compose-button-view.js +52 -80
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-compose-view.js +465 -649
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-custom-route-view.js +37 -58
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-custom-route-view.test.js +14 -26
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-drawer-view.js +118 -235
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-dropdown-view.js +10 -11
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-dummy-route-view.js +28 -46
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-message-view.js +131 -202
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-modal-view.js +40 -80
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-route-view.js +35 -61
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-row-view.js +124 -221
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-view.js +125 -213
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-thread-view.test.js +104 -126
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-tooltip-view.js +36 -51
- package/src/platform-implementation-js/dom-driver/inbox/views/inboxNavItemView.js +158 -297
- package/src/platform-implementation-js/dom-driver/inbox/waitForAnimationClickBlockerGone.js +21 -35
- package/src/platform-implementation-js/driver-common/compose/getDiscardStream.js +24 -43
- package/src/platform-implementation-js/driver-common/compose/getPresendingStream.js +39 -68
- package/src/platform-implementation-js/driver-common/getGmailMessageIdForSyncMessageId.js +14 -19
- package/src/platform-implementation-js/driver-common/getGmailThreadIdForRfcMessageId.js +27 -35
- package/src/platform-implementation-js/driver-common/getRfcMessageIdForSyncMessageId.js +16 -22
- package/src/platform-implementation-js/driver-common/getThreadIdFromMessageId.js +14 -14
- package/src/platform-implementation-js/driver-common/inboxAjax.js +12 -7
- package/src/platform-implementation-js/driver-common/requestGmailThread.js +19 -20
- package/src/platform-implementation-js/driver-common/sidebar/AppSidebar.js +197 -306
- package/src/platform-implementation-js/driver-common/sidebar/ContentPanelViewDriver.js +113 -161
- package/src/platform-implementation-js/driver-interfaces/compose-view-driver.js +1 -114
- package/src/platform-implementation-js/driver-interfaces/driver.js +1 -131
- package/src/platform-implementation-js/driver-interfaces/message-view-driver.js +4 -48
- package/src/platform-implementation-js/driver-interfaces/mole-view-driver.js +1 -29
- package/src/platform-implementation-js/driver-interfaces/route-view-driver.js +1 -32
- package/src/platform-implementation-js/driver-interfaces/thread-row-view-driver.js +1 -11
- package/src/platform-implementation-js/lib/array-to-lifetimes.js +43 -41
- package/src/platform-implementation-js/lib/array-to-lifetimes.test.js +139 -155
- package/src/platform-implementation-js/lib/copyAndValidateAutocompleteResults.js +19 -38
- package/src/platform-implementation-js/lib/css-selector-escape.js +7 -3
- package/src/platform-implementation-js/lib/dom/element-view-mapper.js +8 -11
- package/src/platform-implementation-js/lib/dom/get-selection.js +23 -52
- package/src/platform-implementation-js/lib/dom/insert-html-at-cursor.js +69 -101
- package/src/platform-implementation-js/lib/dom/is-node-in-range.js +8 -10
- package/src/platform-implementation-js/lib/dom/on-mouse-down-and-up.js +15 -17
- package/src/platform-implementation-js/lib/dom/querySelectorOne.js +8 -11
- package/src/platform-implementation-js/lib/dom/set-css.js +7 -3
- package/src/platform-implementation-js/lib/dom/set-value-and-dispatch-event.js +9 -11
- package/src/platform-implementation-js/lib/dom/simulate-drag-and-drop.js +32 -33
- package/src/platform-implementation-js/lib/extract-contact-from-email-contact-string.test.js +23 -26
- package/src/platform-implementation-js/lib/handle-compose-link-chips.js +86 -149
- package/src/platform-implementation-js/lib/insert-link-chip-into-body.js +42 -57
- package/src/platform-implementation-js/lib/make-revocable-function.js +19 -21
- package/src/platform-implementation-js/lib/make-revocable-function.test.js +20 -22
- package/src/platform-implementation-js/lib/parseParamsFromRouteID.js +15 -17
- package/src/platform-implementation-js/lib/parseParamsFromRouteID.test.js +9 -18
- package/src/platform-implementation-js/lib/populateRouteID.js +8 -9
- package/src/platform-implementation-js/lib/populateRouteID.test.js +20 -19
- package/src/platform-implementation-js/lib/react/ElementContainer.js +23 -20
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.js +10 -9
- package/src/platform-implementation-js/lib/rewriteCssWithIdMap.test.js +13 -20
- package/src/platform-implementation-js/lib/routeIDmatchesHash.js +13 -18
- package/src/platform-implementation-js/lib/routeIDmatchesHash.test.js +11 -17
- package/src/platform-implementation-js/lib/shared-style.js +14 -13
- package/src/platform-implementation-js/lib/toItemWithLifetimeStream.js +18 -17
- package/src/platform-implementation-js/lib/toLiveSet.js +17 -15
- package/src/platform-implementation-js/main-INTEGRATED-PAGEWORLD.js +6 -5
- package/src/platform-implementation-js/main.js +9 -24
- package/src/platform-implementation-js/namespaces/compose.js +37 -60
- package/src/platform-implementation-js/namespaces/conversations.js +52 -124
- package/src/platform-implementation-js/namespaces/global.js +27 -39
- package/src/platform-implementation-js/namespaces/keyboard.js +29 -33
- package/src/platform-implementation-js/namespaces/lists.js +25 -31
- package/src/platform-implementation-js/namespaces/modal.js +34 -28
- package/src/platform-implementation-js/namespaces/nav-menu.js +30 -45
- package/src/platform-implementation-js/namespaces/router.js +70 -137
- package/src/platform-implementation-js/namespaces/search.js +19 -17
- package/src/platform-implementation-js/namespaces/toolbars.js +71 -117
- package/src/platform-implementation-js/namespaces/user.js +36 -37
- package/src/platform-implementation-js/namespaces/widgets.js +54 -61
- package/src/platform-implementation-js/platform-implementation.js +98 -229
- package/src/platform-implementation-js/views/app-toolbar-button-view.js +26 -47
- package/src/platform-implementation-js/views/collapsible-section-view.js +66 -63
- package/src/platform-implementation-js/views/content-panel-view.js +28 -30
- package/src/platform-implementation-js/views/conversations/attachment-card-view.js +21 -44
- package/src/platform-implementation-js/views/conversations/custom-message-view.js +44 -104
- package/src/platform-implementation-js/views/conversations/message-view.js +131 -202
- package/src/platform-implementation-js/views/conversations/thread-view.js +75 -127
- package/src/platform-implementation-js/views/native-nav-item-view.js +32 -65
- package/src/platform-implementation-js/views/nav-item-view.js +51 -115
- package/src/platform-implementation-js/views/route-view/custom-route-view.js +25 -20
- package/src/platform-implementation-js/views/route-view/dummy-route-view-driver.js +18 -18
- package/src/platform-implementation-js/views/route-view/list-route-view.js +30 -52
- package/src/platform-implementation-js/views/route-view/route-view.js +24 -35
- package/src/platform-implementation-js/views/section-view.js +60 -52
- package/src/platform-implementation-js/views/thread-row-view.js +49 -74
- package/src/platform-implementation-js/widgets/drawer-view.js +29 -36
- package/src/platform-implementation-js/widgets/modal-view.js +39 -68
- package/src/platform-implementation-js/widgets/mole-view.js +22 -22
- package/src/platform-implementation-js/widgets/top-message-bar-view.js +13 -10
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = XHRProxyFactory;
|
|
8
|
+
var _has = _interopRequireDefault(require("lodash/has"));
|
|
9
|
+
var _noop = _interopRequireDefault(require("lodash/noop"));
|
|
10
|
+
var _each = _interopRequireDefault(require("lodash/each"));
|
|
11
|
+
var _filter = _interopRequireDefault(require("lodash/filter"));
|
|
12
|
+
var _includes = _interopRequireDefault(require("lodash/includes"));
|
|
13
|
+
var _once = _interopRequireDefault(require("lodash/once"));
|
|
14
|
+
var _assert = _interopRequireDefault(require("assert"));
|
|
15
|
+
var _events = _interopRequireDefault(require("events"));
|
|
16
|
+
var _querystring = require("querystring");
|
|
17
17
|
const WARNING_TIMEOUT = 60 * 1000;
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -35,94 +35,6 @@ const WARNING_TIMEOUT = 60 * 1000;
|
|
|
35
35
|
* @property {string} [modifiedResponseText]
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
|
-
export type XHRProxyConnectionDetails = {
|
|
39
|
-
method: string,
|
|
40
|
-
url: string,
|
|
41
|
-
params: { [key: string]: string },
|
|
42
|
-
headers: { [name: string]: string },
|
|
43
|
-
responseType: string,
|
|
44
|
-
originalSendBody: ?string,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type XHRProxyConnectionDetailsWithResponse =
|
|
48
|
-
XHRProxyConnectionDetails & {
|
|
49
|
-
status: number,
|
|
50
|
-
originalResponseText: string,
|
|
51
|
-
modifiedResponseText: string,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export type XHRProxyConnectionDetailsAfterListeners =
|
|
55
|
-
XHRProxyConnectionDetails & {
|
|
56
|
-
status: number,
|
|
57
|
-
originalResponseText: ?string,
|
|
58
|
-
modifiedResponseText: ?string,
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Thing
|
|
63
|
-
*
|
|
64
|
-
* @callback XHRProxyWrapperCallback
|
|
65
|
-
* @param {XHRProxyConnectionDetails} connection
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
type Request = {|
|
|
69
|
-
method: string,
|
|
70
|
-
url: string,
|
|
71
|
-
body: string,
|
|
72
|
-
|};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Wrapper object contains optional callbacks that get run for completed
|
|
76
|
-
* requests, and a required isRelevantTo method that filters what types of
|
|
77
|
-
* requests the methods should be called for. All methods are passed an object
|
|
78
|
-
* with details about the connection as the first argument. Some methods are
|
|
79
|
-
* called with a relevant second argument (which is also present within the
|
|
80
|
-
* connection argument).
|
|
81
|
-
*
|
|
82
|
-
* @typedef {Object} XHRProxyWrapper
|
|
83
|
-
* @property {XHRProxyWrapperCallback} isRelevantTo - returns true if wrapper should be used
|
|
84
|
-
* for request.
|
|
85
|
-
* @property {XHRProxyWrapperCallback} [originalSendBodyLogger] - called with value passed to
|
|
86
|
-
* send.
|
|
87
|
-
* @property {XHRProxyWrapperCallback} [requestChanger] - Allows the protocol, URL, and body
|
|
88
|
-
* to be changed together before the connection is opened and sent.
|
|
89
|
-
* @property {XHRProxyWrapperCallback} [originalResponseTextLogger] - called with the responseText as
|
|
90
|
-
* given by the server. Is not called if responseType is set to a value besides 'text'.
|
|
91
|
-
* @property {XHRProxyWrapperCallback} [responseTextChanger] - called with the responseText as given
|
|
92
|
-
* by the server and returns new responseText value. Is not called if responseType
|
|
93
|
-
* is set to a value besides 'text'.
|
|
94
|
-
* @property {XHRProxyWrapperCallback} [finalResponseTextLogger] - called with the responseText as
|
|
95
|
-
* delivered to application code. Is not called if responseType is set to a value besides 'text'.
|
|
96
|
-
* @property {XHRProxyWrapperCallback} [afterListeners] - called after all event listeners
|
|
97
|
-
* for readystatechange have run
|
|
98
|
-
*/
|
|
99
|
-
export type Wrapper = {|
|
|
100
|
-
isRelevantTo: (connection: XHRProxyConnectionDetails) => boolean,
|
|
101
|
-
originalSendBodyLogger?: (
|
|
102
|
-
connection: XHRProxyConnectionDetails,
|
|
103
|
-
body: string
|
|
104
|
-
) => void,
|
|
105
|
-
requestChanger?: (
|
|
106
|
-
connection: XHRProxyConnectionDetails,
|
|
107
|
-
request: Object
|
|
108
|
-
) => Request | Promise<Request>,
|
|
109
|
-
originalResponseTextLogger?: (
|
|
110
|
-
connection: XHRProxyConnectionDetailsWithResponse,
|
|
111
|
-
originalResponseText: string
|
|
112
|
-
) => void,
|
|
113
|
-
responseTextChanger?: (
|
|
114
|
-
connection: XHRProxyConnectionDetailsWithResponse,
|
|
115
|
-
originalResponseText: string
|
|
116
|
-
) => string | Promise<string>,
|
|
117
|
-
finalResponseTextLogger?: (
|
|
118
|
-
connection: XHRProxyConnectionDetailsWithResponse,
|
|
119
|
-
finalResponseText: string
|
|
120
|
-
) => void,
|
|
121
|
-
afterListeners?: (
|
|
122
|
-
connection: XHRProxyConnectionDetailsAfterListeners
|
|
123
|
-
) => void,
|
|
124
|
-
|};
|
|
125
|
-
|
|
126
38
|
/**
|
|
127
39
|
* Creates a drop-in replacement for the XMLHttpRequest constructor that can
|
|
128
40
|
* have wrappers which may log or modify server responses. See
|
|
@@ -133,69 +45,34 @@ export type Wrapper = {|
|
|
|
133
45
|
* @param {Object} [opts] - Can specify a logError function
|
|
134
46
|
* @returns {function} wrapped XMLHttpRequest-like constructor
|
|
135
47
|
*/
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
function (error, label) {
|
|
144
|
-
setTimeout(function () {
|
|
145
|
-
// let window.onerror log this
|
|
146
|
-
throw error;
|
|
147
|
-
}, 1);
|
|
148
|
-
};
|
|
149
|
-
|
|
48
|
+
function XHRProxyFactory(XHR, wrappers, opts) {
|
|
49
|
+
const logError = opts && opts.logError || function (error, label) {
|
|
50
|
+
setTimeout(function () {
|
|
51
|
+
// let window.onerror log this
|
|
52
|
+
throw error;
|
|
53
|
+
}, 1);
|
|
54
|
+
};
|
|
150
55
|
function transformEvent(oldTarget, newTarget, event) {
|
|
151
56
|
const newEvent = {};
|
|
152
|
-
Object.keys(event)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
'loaded',
|
|
163
|
-
'total',
|
|
164
|
-
'type',
|
|
165
|
-
'currentTarget',
|
|
166
|
-
'target',
|
|
167
|
-
'srcElement',
|
|
168
|
-
'NONE',
|
|
169
|
-
'CAPTURING_PHASE',
|
|
170
|
-
'AT_TARGET',
|
|
171
|
-
'BUBBLING_PHASE',
|
|
172
|
-
'eventPhase',
|
|
173
|
-
])
|
|
174
|
-
.filter((name) => name in event)
|
|
175
|
-
.forEach((name) => {
|
|
176
|
-
const value = (event: any)[name];
|
|
177
|
-
if (value === oldTarget) {
|
|
178
|
-
newEvent[name] = newTarget;
|
|
179
|
-
} else if (typeof value === 'function') {
|
|
180
|
-
newEvent[name] = value.bind(event);
|
|
181
|
-
} else {
|
|
182
|
-
newEvent[name] = value;
|
|
183
|
-
}
|
|
184
|
-
});
|
|
57
|
+
Object.keys(event).concat(['bubbles', 'cancelBubble', 'cancelable', 'defaultPrevented', 'preventDefault', 'stopPropagation', 'stopImmediatePropagation', 'lengthComputable', 'loaded', 'total', 'type', 'currentTarget', 'target', 'srcElement', 'NONE', 'CAPTURING_PHASE', 'AT_TARGET', 'BUBBLING_PHASE', 'eventPhase']).filter(name => name in event).forEach(name => {
|
|
58
|
+
const value = event[name];
|
|
59
|
+
if (value === oldTarget) {
|
|
60
|
+
newEvent[name] = newTarget;
|
|
61
|
+
} else if (typeof value === 'function') {
|
|
62
|
+
newEvent[name] = value.bind(event);
|
|
63
|
+
} else {
|
|
64
|
+
newEvent[name] = value;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
185
67
|
return newEvent;
|
|
186
68
|
}
|
|
187
|
-
|
|
188
69
|
function wrapEventListener(oldTarget, newTarget, listener) {
|
|
189
70
|
return function (event) {
|
|
190
|
-
return listener.call(
|
|
191
|
-
newTarget,
|
|
192
|
-
transformEvent(oldTarget, newTarget, event)
|
|
193
|
-
);
|
|
71
|
+
return listener.call(newTarget, transformEvent(oldTarget, newTarget, event));
|
|
194
72
|
};
|
|
195
73
|
}
|
|
196
|
-
|
|
197
74
|
function findApplicableWrappers(wrappers, connection) {
|
|
198
|
-
return
|
|
75
|
+
return (0, _filter.default)(wrappers, function (wrapper) {
|
|
199
76
|
try {
|
|
200
77
|
return wrapper.isRelevantTo(connection);
|
|
201
78
|
} catch (e) {
|
|
@@ -203,21 +80,16 @@ export default function XHRProxyFactory(
|
|
|
203
80
|
}
|
|
204
81
|
});
|
|
205
82
|
}
|
|
206
|
-
|
|
207
83
|
function XHRProxy() {
|
|
208
84
|
this._wrappers = wrappers;
|
|
209
85
|
this._listeners = {};
|
|
210
86
|
this._boundListeners = {};
|
|
211
|
-
this._events = new
|
|
87
|
+
this._events = new _events.default(); // used for internal stuff, not user-visible events
|
|
212
88
|
this.responseText = '';
|
|
213
89
|
this._openState = false;
|
|
214
|
-
|
|
215
90
|
if (XHR.bind && XHR.bind.apply) {
|
|
216
91
|
// call constructor with variable number of arguments
|
|
217
|
-
this._realxhr = new (
|
|
218
|
-
XHR,
|
|
219
|
-
[null].concat(arguments)
|
|
220
|
-
))();
|
|
92
|
+
this._realxhr = new (XHR.bind.apply(XHR, [null].concat(arguments)))();
|
|
221
93
|
} else {
|
|
222
94
|
// Safari's XMLHttpRequest lacks a bind method, but its constructor
|
|
223
95
|
// doesn't support extra arguments anyway, so don't bother logging an
|
|
@@ -225,20 +97,15 @@ export default function XHRProxyFactory(
|
|
|
225
97
|
this._realxhr = new XHR();
|
|
226
98
|
}
|
|
227
99
|
const self = this;
|
|
228
|
-
|
|
229
100
|
const triggerEventListeners = (name, event) => {
|
|
230
101
|
if (this['on' + name]) {
|
|
231
102
|
try {
|
|
232
|
-
wrapEventListener(this._realxhr, this, this['on' + name]).call(
|
|
233
|
-
this,
|
|
234
|
-
event
|
|
235
|
-
);
|
|
103
|
+
wrapEventListener(this._realxhr, this, this['on' + name]).call(this, event);
|
|
236
104
|
} catch (e) {
|
|
237
105
|
logError(e, 'XMLHttpRequest event listener error');
|
|
238
106
|
}
|
|
239
107
|
}
|
|
240
|
-
|
|
241
|
-
each(this._boundListeners[name], (boundListener) => {
|
|
108
|
+
(0, _each.default)(this._boundListeners[name], boundListener => {
|
|
242
109
|
try {
|
|
243
110
|
boundListener(event);
|
|
244
111
|
} catch (e) {
|
|
@@ -246,67 +113,51 @@ export default function XHRProxyFactory(
|
|
|
246
113
|
}
|
|
247
114
|
});
|
|
248
115
|
};
|
|
249
|
-
|
|
250
|
-
const runRscListeners = (event) => {
|
|
116
|
+
const runRscListeners = event => {
|
|
251
117
|
triggerEventListeners('readystatechange', event);
|
|
252
118
|
};
|
|
253
|
-
|
|
254
119
|
this._fakeRscEvent = function () {
|
|
255
|
-
runRscListeners(
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
})
|
|
274
|
-
);
|
|
120
|
+
runRscListeners(Object.freeze({
|
|
121
|
+
bubbles: false,
|
|
122
|
+
cancelBubble: false,
|
|
123
|
+
cancelable: false,
|
|
124
|
+
defaultPrevented: false,
|
|
125
|
+
preventDefault: _noop.default,
|
|
126
|
+
stopPropagation: _noop.default,
|
|
127
|
+
stopImmediatePropagation: _noop.default,
|
|
128
|
+
type: 'readystatechange',
|
|
129
|
+
currentTarget: this,
|
|
130
|
+
target: this,
|
|
131
|
+
srcElement: this,
|
|
132
|
+
NONE: 0,
|
|
133
|
+
CAPTURING_PHASE: 1,
|
|
134
|
+
AT_TARGET: 2,
|
|
135
|
+
BUBBLING_PHASE: 3,
|
|
136
|
+
eventPhase: 0
|
|
137
|
+
}));
|
|
275
138
|
};
|
|
276
|
-
|
|
277
|
-
const deliverFinalRsc = (event) => {
|
|
139
|
+
const deliverFinalRsc = event => {
|
|
278
140
|
this.readyState = 4;
|
|
279
141
|
// Remember the status now before any event handlers are called, just in
|
|
280
142
|
// case one aborts the request.
|
|
281
143
|
var wasSuccess = this.status == 200;
|
|
282
|
-
var progressEvent = Object.assign(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
total: 0,
|
|
289
|
-
}
|
|
290
|
-
);
|
|
291
|
-
|
|
292
|
-
var supportsResponseText =
|
|
293
|
-
!this._realxhr.responseType || this._realxhr.responseType == 'text';
|
|
294
|
-
|
|
144
|
+
var progressEvent = Object.assign({}, transformEvent(this._realxhr, this, event), {
|
|
145
|
+
lengthComputable: false,
|
|
146
|
+
loaded: 0,
|
|
147
|
+
total: 0
|
|
148
|
+
});
|
|
149
|
+
var supportsResponseText = !this._realxhr.responseType || this._realxhr.responseType == 'text';
|
|
295
150
|
if (supportsResponseText) {
|
|
296
|
-
|
|
151
|
+
(0, _each.default)(this._activeWrappers, wrapper => {
|
|
297
152
|
if (wrapper.finalResponseTextLogger) {
|
|
298
153
|
try {
|
|
299
|
-
wrapper.finalResponseTextLogger(
|
|
300
|
-
this._connection,
|
|
301
|
-
this.responseText
|
|
302
|
-
);
|
|
154
|
+
wrapper.finalResponseTextLogger(this._connection, this.responseText);
|
|
303
155
|
} catch (e) {
|
|
304
156
|
logError(e);
|
|
305
157
|
}
|
|
306
158
|
}
|
|
307
159
|
});
|
|
308
160
|
}
|
|
309
|
-
|
|
310
161
|
runRscListeners(event);
|
|
311
162
|
if (wasSuccess) {
|
|
312
163
|
triggerEventListeners('load', progressEvent);
|
|
@@ -314,8 +165,7 @@ export default function XHRProxyFactory(
|
|
|
314
165
|
triggerEventListeners('error', progressEvent);
|
|
315
166
|
}
|
|
316
167
|
triggerEventListeners('loadend', progressEvent);
|
|
317
|
-
|
|
318
|
-
each(this._activeWrappers, (wrapper) => {
|
|
168
|
+
(0, _each.default)(this._activeWrappers, wrapper => {
|
|
319
169
|
if (wrapper.afterListeners) {
|
|
320
170
|
try {
|
|
321
171
|
wrapper.afterListeners(this._connection);
|
|
@@ -325,156 +175,104 @@ export default function XHRProxyFactory(
|
|
|
325
175
|
}
|
|
326
176
|
});
|
|
327
177
|
};
|
|
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
|
-
|
|
178
|
+
this._realxhr.addEventListener('readystatechange', event => {
|
|
179
|
+
if (!this._connection) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (this._realxhr.readyState >= 2) {
|
|
183
|
+
this._connection.status = this._realxhr.status;
|
|
184
|
+
}
|
|
185
|
+
const supportsResponseText = !this._realxhr.responseType || this._realxhr.responseType == 'text';
|
|
186
|
+
|
|
187
|
+
// Process the response text.
|
|
188
|
+
if (this._realxhr.readyState == 4) {
|
|
189
|
+
if (supportsResponseText) {
|
|
190
|
+
Object.defineProperty(this._connection, 'originalResponseText', {
|
|
191
|
+
enumerable: true,
|
|
192
|
+
writable: false,
|
|
193
|
+
configurable: false,
|
|
194
|
+
value: self._realxhr.responseText
|
|
195
|
+
});
|
|
196
|
+
(0, _each.default)(this._activeWrappers, wrapper => {
|
|
197
|
+
if (wrapper.originalResponseTextLogger) {
|
|
198
|
+
try {
|
|
199
|
+
wrapper.originalResponseTextLogger(this._connection, this._connection.originalResponseText);
|
|
200
|
+
} catch (e) {
|
|
201
|
+
logError(e);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
const finish = (0, _once.default)(deliverFinalRsc.bind(null, event));
|
|
206
|
+
if (this._connection.async) {
|
|
207
|
+
// If the XHR object is re-used for another connection, then we need
|
|
208
|
+
// to make sure that our upcoming async calls here do nothing.
|
|
209
|
+
// Remember the current connection object, and do nothing in our async
|
|
210
|
+
// calls if it no longer matches.
|
|
211
|
+
const startConnection = this._connection;
|
|
212
|
+
(async () => {
|
|
213
|
+
let modifiedResponseText = startConnection.originalResponseText;
|
|
214
|
+
startConnection.modifiedResponseText = modifiedResponseText;
|
|
215
|
+
for (let responseTextChanger of this._responseTextChangers) {
|
|
216
|
+
const longRunWarningTimer = setTimeout(() => {
|
|
217
|
+
// eslint-disable-next-line no-console
|
|
218
|
+
console.warn('responseTextChanger is taking too long', responseTextChanger, startConnection);
|
|
219
|
+
}, WARNING_TIMEOUT);
|
|
354
220
|
try {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
);
|
|
359
|
-
} catch (e) {
|
|
360
|
-
logError(e);
|
|
221
|
+
modifiedResponseText = await responseTextChanger(startConnection, modifiedResponseText);
|
|
222
|
+
} finally {
|
|
223
|
+
clearTimeout(longRunWarningTimer);
|
|
361
224
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
const finish = once(deliverFinalRsc.bind(null, event));
|
|
366
|
-
if (this._connection.async) {
|
|
367
|
-
// If the XHR object is re-used for another connection, then we need
|
|
368
|
-
// to make sure that our upcoming async calls here do nothing.
|
|
369
|
-
// Remember the current connection object, and do nothing in our async
|
|
370
|
-
// calls if it no longer matches.
|
|
371
|
-
const startConnection = this._connection;
|
|
372
|
-
|
|
373
|
-
(async () => {
|
|
374
|
-
let modifiedResponseText: string =
|
|
375
|
-
startConnection.originalResponseText;
|
|
376
|
-
startConnection.modifiedResponseText = modifiedResponseText;
|
|
377
|
-
|
|
378
|
-
for (let responseTextChanger of this._responseTextChangers) {
|
|
379
|
-
const longRunWarningTimer = setTimeout(() => {
|
|
380
|
-
// eslint-disable-next-line no-console
|
|
381
|
-
console.warn(
|
|
382
|
-
'responseTextChanger is taking too long',
|
|
383
|
-
responseTextChanger,
|
|
384
|
-
startConnection
|
|
385
|
-
);
|
|
386
|
-
}, WARNING_TIMEOUT);
|
|
387
|
-
try {
|
|
388
|
-
modifiedResponseText = await responseTextChanger(
|
|
389
|
-
startConnection,
|
|
390
|
-
modifiedResponseText
|
|
391
|
-
);
|
|
392
|
-
} finally {
|
|
393
|
-
clearTimeout(longRunWarningTimer);
|
|
394
|
-
}
|
|
395
|
-
if (typeof modifiedResponseText !== 'string') {
|
|
396
|
-
throw new Error(
|
|
397
|
-
'responseTextChanger returned non-string value ' +
|
|
398
|
-
modifiedResponseText
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
startConnection.modifiedResponseText = modifiedResponseText;
|
|
402
|
-
|
|
403
|
-
if (startConnection !== this._connection) break;
|
|
225
|
+
if (typeof modifiedResponseText !== 'string') {
|
|
226
|
+
throw new Error('responseTextChanger returned non-string value ' + modifiedResponseText);
|
|
404
227
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
)
|
|
423
|
-
.catch(logError);
|
|
424
|
-
return;
|
|
425
|
-
} else {
|
|
426
|
-
self.responseText = self._realxhr.responseText;
|
|
427
|
-
}
|
|
228
|
+
startConnection.modifiedResponseText = modifiedResponseText;
|
|
229
|
+
if (startConnection !== this._connection) break;
|
|
230
|
+
}
|
|
231
|
+
return modifiedResponseText;
|
|
232
|
+
})().then(modifiedResponseText => {
|
|
233
|
+
if (startConnection === self._connection) {
|
|
234
|
+
this.responseText = modifiedResponseText;
|
|
235
|
+
finish();
|
|
236
|
+
}
|
|
237
|
+
}, err => {
|
|
238
|
+
logError(err);
|
|
239
|
+
if (startConnection === this._connection) {
|
|
240
|
+
this.responseText = this._realxhr.responseText;
|
|
241
|
+
finish();
|
|
242
|
+
}
|
|
243
|
+
}).catch(logError);
|
|
244
|
+
return;
|
|
428
245
|
} else {
|
|
429
|
-
self.responseText =
|
|
246
|
+
self.responseText = self._realxhr.responseText;
|
|
430
247
|
}
|
|
431
|
-
|
|
432
|
-
deliverFinalRsc(event);
|
|
433
248
|
} else {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
} else {
|
|
249
|
+
self.responseText = '';
|
|
250
|
+
}
|
|
251
|
+
deliverFinalRsc(event);
|
|
252
|
+
} else {
|
|
253
|
+
if (self._realxhr.readyState == 1 && self.readyState == 1) {
|
|
254
|
+
// Delayed open+send just happened. We already delivered an event
|
|
255
|
+
// for this, so drop this event.
|
|
256
|
+
return;
|
|
257
|
+
} else if (self._realxhr.readyState >= 3 && supportsResponseText) {
|
|
258
|
+
if (self._responseTextChangers.length) {
|
|
259
|
+
// If we're going to transform the final response, then we don't
|
|
260
|
+
// want to expose any partial untransformed responses and we don't
|
|
261
|
+
// want to bother trying to transform partial responses. Only show
|
|
262
|
+
// an empty string as the loaded response until the connection is
|
|
263
|
+
// done.
|
|
450
264
|
self.responseText = '';
|
|
265
|
+
} else {
|
|
266
|
+
self.responseText = self._realxhr.responseText;
|
|
451
267
|
}
|
|
452
|
-
|
|
453
|
-
self.
|
|
454
|
-
runRscListeners(event);
|
|
268
|
+
} else {
|
|
269
|
+
self.responseText = '';
|
|
455
270
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
[
|
|
461
|
-
'dispatchEvent',
|
|
462
|
-
'getAllResponseHeaders',
|
|
463
|
-
'getResponseHeader',
|
|
464
|
-
'overrideMimeType',
|
|
465
|
-
'responseType',
|
|
466
|
-
'responseXML',
|
|
467
|
-
'responseURL',
|
|
468
|
-
'status',
|
|
469
|
-
'statusText',
|
|
470
|
-
'timeout',
|
|
471
|
-
'ontimeout',
|
|
472
|
-
'onloadstart',
|
|
473
|
-
'onprogress',
|
|
474
|
-
'onabort',
|
|
475
|
-
'upload',
|
|
476
|
-
'withCredentials',
|
|
477
|
-
].forEach(function (prop) {
|
|
271
|
+
self.readyState = self._realxhr.readyState;
|
|
272
|
+
runRscListeners(event);
|
|
273
|
+
}
|
|
274
|
+
}, false);
|
|
275
|
+
['dispatchEvent', 'getAllResponseHeaders', 'getResponseHeader', 'overrideMimeType', 'responseType', 'responseXML', 'responseURL', 'status', 'statusText', 'timeout', 'ontimeout', 'onloadstart', 'onprogress', 'onabort', 'upload', 'withCredentials'].forEach(function (prop) {
|
|
478
276
|
Object.defineProperty(self, prop, {
|
|
479
277
|
enumerable: true,
|
|
480
278
|
configurable: false,
|
|
@@ -491,29 +289,23 @@ export default function XHRProxyFactory(
|
|
|
491
289
|
v = wrapEventListener(this._realxhr, this, v);
|
|
492
290
|
}
|
|
493
291
|
self._realxhr[prop] = v;
|
|
494
|
-
}
|
|
292
|
+
}
|
|
495
293
|
});
|
|
496
294
|
});
|
|
497
|
-
|
|
498
|
-
(Object: any).defineProperty(self, 'response', {
|
|
295
|
+
Object.defineProperty(self, 'response', {
|
|
499
296
|
enumerable: true,
|
|
500
297
|
configurable: false,
|
|
501
298
|
get: function () {
|
|
502
|
-
if (
|
|
503
|
-
!this._realxhr.responseType ||
|
|
504
|
-
this._realxhr.responseType == 'text'
|
|
505
|
-
) {
|
|
299
|
+
if (!this._realxhr.responseType || this._realxhr.responseType == 'text') {
|
|
506
300
|
return this.responseText;
|
|
507
301
|
} else {
|
|
508
302
|
// We're not trying to transform non-text responses currently.
|
|
509
303
|
return this._realxhr.response;
|
|
510
304
|
}
|
|
511
|
-
}
|
|
305
|
+
}
|
|
512
306
|
});
|
|
513
|
-
|
|
514
307
|
self.readyState = self._realxhr.readyState;
|
|
515
308
|
}
|
|
516
|
-
|
|
517
309
|
XHRProxy.prototype.abort = function () {
|
|
518
310
|
// Important: If the request has already been sent, the XHR will change
|
|
519
311
|
// its readyState to 4 after abort. However, we sometimes asynchronously
|
|
@@ -529,21 +321,16 @@ export default function XHRProxyFactory(
|
|
|
529
321
|
}
|
|
530
322
|
this._realxhr.abort();
|
|
531
323
|
};
|
|
532
|
-
|
|
533
324
|
XHRProxy.prototype.setRequestHeader = function (name, value) {
|
|
534
325
|
var self = this;
|
|
535
326
|
if (this.readyState != 1) {
|
|
536
327
|
// eslint-disable-next-line no-console
|
|
537
|
-
console.warn(
|
|
538
|
-
'setRequestHeader improperly called at readyState ' + this.readyState
|
|
539
|
-
);
|
|
328
|
+
console.warn('setRequestHeader improperly called at readyState ' + this.readyState);
|
|
540
329
|
}
|
|
541
330
|
if (!this._openState) {
|
|
542
331
|
throw new Error('Can only set headers after open and before send');
|
|
543
332
|
}
|
|
544
|
-
|
|
545
333
|
this._connection.headers[name] = value;
|
|
546
|
-
|
|
547
334
|
if (this._connection.async && this._requestChangers.length) {
|
|
548
335
|
this._events.once('realOpen', function () {
|
|
549
336
|
self._realxhr.setRequestHeader(name, value);
|
|
@@ -552,24 +339,22 @@ export default function XHRProxyFactory(
|
|
|
552
339
|
this._realxhr.setRequestHeader(name, value);
|
|
553
340
|
}
|
|
554
341
|
};
|
|
555
|
-
|
|
556
342
|
XHRProxy.prototype.addEventListener = function (name, listener) {
|
|
557
343
|
if (!this._listeners[name]) {
|
|
558
344
|
this._listeners[name] = [];
|
|
559
345
|
this._boundListeners[name] = [];
|
|
560
346
|
}
|
|
561
|
-
if (!
|
|
347
|
+
if (!(0, _includes.default)(this._listeners[name], listener)) {
|
|
562
348
|
var boundListener = wrapEventListener(this._realxhr, this, listener);
|
|
563
349
|
this._listeners[name].push(listener);
|
|
564
350
|
this._boundListeners[name].push(boundListener);
|
|
565
|
-
if (!
|
|
351
|
+
if (!(0, _includes.default)(['readystatechange', 'load', 'error', 'loadend'], name)) {
|
|
566
352
|
// certain listeners are called manually so that the final
|
|
567
353
|
// call (when readyState==4) can be delayed.
|
|
568
354
|
this._realxhr.addEventListener(name, boundListener, false);
|
|
569
355
|
}
|
|
570
356
|
}
|
|
571
357
|
};
|
|
572
|
-
|
|
573
358
|
XHRProxy.prototype.removeEventListener = function (name, listener) {
|
|
574
359
|
if (!this._listeners[name]) {
|
|
575
360
|
return;
|
|
@@ -584,48 +369,34 @@ export default function XHRProxyFactory(
|
|
|
584
369
|
this._realxhr.removeEventListener(name, boundListener, false);
|
|
585
370
|
}
|
|
586
371
|
};
|
|
587
|
-
|
|
588
372
|
XHRProxy.prototype.open = function (method, url, async) {
|
|
589
373
|
// Work around MailTrack issue
|
|
590
374
|
if (!(this instanceof XHRProxy)) {
|
|
591
375
|
return XHR.prototype.open.apply(this, arguments);
|
|
592
376
|
}
|
|
593
|
-
|
|
594
377
|
var self = this;
|
|
595
378
|
this._connection = {
|
|
596
379
|
method: method,
|
|
597
380
|
url: url,
|
|
598
|
-
params:
|
|
381
|
+
params: (0, _querystring.parse)(url.split('?')[1] || ''),
|
|
599
382
|
headers: {},
|
|
600
|
-
async: arguments.length < 3 || !!async
|
|
383
|
+
async: arguments.length < 3 || !!async
|
|
601
384
|
};
|
|
602
385
|
this._clientStartedSend = false;
|
|
603
386
|
this._realStartedSend = false;
|
|
604
|
-
this._activeWrappers = findApplicableWrappers(
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
);
|
|
608
|
-
this._responseTextChangers = this._activeWrappers
|
|
609
|
-
.map(function (wrapper) {
|
|
610
|
-
return (
|
|
611
|
-
wrapper.responseTextChanger &&
|
|
612
|
-
wrapper.responseTextChanger.bind(wrapper)
|
|
613
|
-
);
|
|
614
|
-
})
|
|
615
|
-
.filter(Boolean);
|
|
387
|
+
this._activeWrappers = findApplicableWrappers(this._wrappers, this._connection);
|
|
388
|
+
this._responseTextChangers = this._activeWrappers.map(function (wrapper) {
|
|
389
|
+
return wrapper.responseTextChanger && wrapper.responseTextChanger.bind(wrapper);
|
|
390
|
+
}).filter(Boolean);
|
|
616
391
|
this.responseText = '';
|
|
617
392
|
this._openState = true;
|
|
618
|
-
|
|
619
393
|
function finish(method, url) {
|
|
620
394
|
return self._realxhr.open(method, url, self._connection.async);
|
|
621
395
|
}
|
|
622
|
-
|
|
623
396
|
if (this._connection.async) {
|
|
624
|
-
this._requestChangers = this._activeWrappers
|
|
625
|
-
.
|
|
626
|
-
|
|
627
|
-
})
|
|
628
|
-
.filter(Boolean);
|
|
397
|
+
this._requestChangers = this._activeWrappers.map(function (wrapper) {
|
|
398
|
+
return wrapper.requestChanger && wrapper.requestChanger.bind(wrapper);
|
|
399
|
+
}).filter(Boolean);
|
|
629
400
|
if (this._requestChangers.length) {
|
|
630
401
|
if (this.readyState != 1) {
|
|
631
402
|
this.readyState = 1;
|
|
@@ -638,7 +409,6 @@ export default function XHRProxyFactory(
|
|
|
638
409
|
finish(method, url);
|
|
639
410
|
}
|
|
640
411
|
};
|
|
641
|
-
|
|
642
412
|
XHRProxy.prototype.send = function (body) {
|
|
643
413
|
var self = this;
|
|
644
414
|
this._clientStartedSend = true;
|
|
@@ -647,11 +417,10 @@ export default function XHRProxyFactory(
|
|
|
647
417
|
enumerable: true,
|
|
648
418
|
writable: false,
|
|
649
419
|
configurable: false,
|
|
650
|
-
value: body
|
|
420
|
+
value: body
|
|
651
421
|
});
|
|
652
422
|
this._connection.responseType = this._realxhr.responseType || 'text';
|
|
653
|
-
|
|
654
|
-
each(self._activeWrappers, function (wrapper) {
|
|
423
|
+
(0, _each.default)(self._activeWrappers, function (wrapper) {
|
|
655
424
|
if (wrapper.originalSendBodyLogger) {
|
|
656
425
|
try {
|
|
657
426
|
wrapper.originalSendBodyLogger(self._connection, body);
|
|
@@ -660,80 +429,61 @@ export default function XHRProxyFactory(
|
|
|
660
429
|
}
|
|
661
430
|
}
|
|
662
431
|
});
|
|
663
|
-
|
|
664
432
|
function finish(body) {
|
|
665
433
|
self._realStartedSend = true;
|
|
666
434
|
self._realxhr.send(body);
|
|
667
435
|
}
|
|
668
|
-
|
|
669
436
|
if (this._connection.async && this._requestChangers.length) {
|
|
670
437
|
// If the XHR object is re-used for another connection, then we need
|
|
671
438
|
// to make sure that our upcoming async calls here do nothing.
|
|
672
439
|
// Remember the current connection object, and do nothing in our async
|
|
673
440
|
// calls if it no longer matches. Also check for aborts.
|
|
674
441
|
const startConnection = this._connection;
|
|
675
|
-
|
|
676
442
|
const request = {
|
|
677
443
|
method: this._connection.method,
|
|
678
444
|
url: this._connection.url,
|
|
679
|
-
body: body
|
|
445
|
+
body: body
|
|
680
446
|
};
|
|
681
|
-
|
|
682
447
|
(async () => {
|
|
683
448
|
let modifiedRequest = request;
|
|
684
449
|
for (let requestChanger of this._requestChangers) {
|
|
685
450
|
const longRunWarningTimer = setTimeout(() => {
|
|
686
451
|
// eslint-disable-next-line no-console
|
|
687
|
-
console.warn(
|
|
688
|
-
'requestChanger is taking too long',
|
|
689
|
-
requestChanger,
|
|
690
|
-
startConnection
|
|
691
|
-
);
|
|
452
|
+
console.warn('requestChanger is taking too long', requestChanger, startConnection);
|
|
692
453
|
}, WARNING_TIMEOUT);
|
|
693
454
|
try {
|
|
694
|
-
modifiedRequest = await requestChanger(
|
|
695
|
-
this._connection,
|
|
696
|
-
Object.freeze(modifiedRequest)
|
|
697
|
-
);
|
|
455
|
+
modifiedRequest = await requestChanger(this._connection, Object.freeze(modifiedRequest));
|
|
698
456
|
} finally {
|
|
699
457
|
clearTimeout(longRunWarningTimer);
|
|
700
458
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
if (startConnection !== this._connection || this._realStartedSend)
|
|
707
|
-
break;
|
|
459
|
+
(0, _assert.default)((0, _has.default)(modifiedRequest, 'method'), 'modifiedRequest has method');
|
|
460
|
+
(0, _assert.default)((0, _has.default)(modifiedRequest, 'url'), 'modifiedRequest has url');
|
|
461
|
+
(0, _assert.default)((0, _has.default)(modifiedRequest, 'body'), 'modifiedRequest has body');
|
|
462
|
+
if (startConnection !== this._connection || this._realStartedSend) break;
|
|
708
463
|
}
|
|
709
|
-
|
|
710
464
|
return modifiedRequest;
|
|
711
|
-
})()
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
722
|
-
});
|
|
465
|
+
})().catch(err => {
|
|
466
|
+
logError(err);
|
|
467
|
+
return request;
|
|
468
|
+
}).then(modifiedRequest => {
|
|
469
|
+
if (startConnection === this._connection && !this._realStartedSend) {
|
|
470
|
+
this._realxhr.open(modifiedRequest.method, modifiedRequest.url);
|
|
471
|
+
this._events.emit('realOpen');
|
|
472
|
+
finish(modifiedRequest.body);
|
|
473
|
+
}
|
|
474
|
+
});
|
|
723
475
|
} else {
|
|
724
476
|
finish(body);
|
|
725
477
|
}
|
|
726
478
|
};
|
|
727
|
-
|
|
728
479
|
[XHRProxy, XHRProxy.prototype].forEach(function (obj) {
|
|
729
480
|
Object.assign(obj, {
|
|
730
481
|
UNSENT: 0,
|
|
731
482
|
OPENED: 1,
|
|
732
483
|
HEADERS_RECEIVED: 2,
|
|
733
484
|
LOADING: 3,
|
|
734
|
-
DONE: 4
|
|
485
|
+
DONE: 4
|
|
735
486
|
});
|
|
736
487
|
});
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
}
|
|
488
|
+
return XHRProxy;
|
|
489
|
+
}
|