Dropped ember-useragent dependency

no issue

We made very limited use of the `ua-parser-js` sub-dependency that `ember-useragent` pulls in so it didn't seem worth having the fairly large 17KB import or the associated sub-dependency version resolutions.

- switched the two iOS and Safari detections to use associated Regexes on `navigator.userAgent`
- dropped the "Microsoft Edge not supported" message in the editor
  - old Edge is still not supported but it was been replaced with a Chromium-based version that is supported a while back
  - we can re-introduce a warning if we get any significant reports (there is nothing showing in Sentry for this alert in the last 14 days)
This commit is contained in:
Kevin Ansfield 2022-03-07 10:06:35 +00:00
parent 20be395077
commit 4aa9d4554e
5 changed files with 11 additions and 41 deletions

View File

@ -1,6 +1,5 @@
import Mixin from '@ember/object/mixin';
import {computed} from '@ember/object';
import {inject as service} from '@ember/service';
const keyCodes = {
13: 'Enter',
@ -8,17 +7,20 @@ const keyCodes = {
};
export default Mixin.create({
userAgent: service(),
attributeBindings: ['autofocus'],
selectOnClick: false,
shouldFocus: false,
stopEnterKeyDownPropagation: false,
constructor() {
this._super(...arguments);
this._isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
},
autofocus: computed(function () {
if (this.shouldFocus) {
return (this.userAgent.os.isIOS) ? false : 'autofocus';
return (this._isIOS) ? false : 'autofocus';
}
return false;
@ -79,7 +81,7 @@ export default Mixin.create({
_focus() {
// Until mobile safari has better support
// for focusing, we just ignore it
if (this.shouldFocus && !this.userAgent.os.isIOS) {
if (this.shouldFocus && !this._isIOS) {
this.element.focus();
}
},

View File

@ -1,13 +1,11 @@
import $ from 'jquery';
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import {htmlSafe} from '@ember/template';
import {run} from '@ember/runloop';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend({
feature: service(),
notifications: service(),
userAgent: service(),
ui: service(),
classNames: ['editor'],
@ -17,18 +15,6 @@ export default AuthenticatedRoute.extend({
this.ui.set('isFullScreen', true);
},
setupController() {
this._super(...arguments);
// edge has known issues
if (this.userAgent.browser.isEdge && this.userAgent.parser.getEngine().name === 'EdgeHTML') {
this.notifications.showAlert(
htmlSafe('Microsoft Edge is not currently supported. Please use a recent version of Chrome/Firefox/Safari.'),
{type: 'info', key: 'koenig.browserSupport'}
);
}
},
deactivate() {
this._super(...arguments);
this.ui.set('isFullScreen', false);

View File

@ -1,6 +1,5 @@
// adapted from draggable.js Scrollable plugin (MIT)
// https://github.com/Shopify/draggable/blob/master/src/Draggable/Plugins/Scrollable/Scrollable.js
import UAParser from 'ua-parser-js';
import {
getDocumentScrollingElement,
getParentScrollableElement
@ -24,7 +23,7 @@ export default class ScrollHandler {
this._scroll = this._scroll.bind(this);
// cache browser info to avoid parsing on every animation frame
this.userAgent = new UAParser();
this._isSafari = navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1;
}
dragStart(draggableInfo) {
@ -91,13 +90,12 @@ export default class ScrollHandler {
let topPosition = rect.top + offsetHeight - clientY;
let bottomPosition = clientY - rect.top;
let isSafari = this.userAgent.getBrowser().name === 'Safari';
// Safari will automatically scroll when the mouse is outside of the window
// so we want to avoid our own scrolling in that situation to avoid jank
if (topPosition < sensitivity && !(isSafari && topPosition < 0)) {
if (topPosition < sensitivity && !(this._isSafari && topPosition < 0)) {
scrollableElement.scrollTop += speed;
} else if (bottomPosition < sensitivity && !(isSafari && bottomPosition < 0)) {
} else if (bottomPosition < sensitivity && !(this._isSafari && bottomPosition < 0)) {
scrollableElement.scrollTop -= speed;
}

View File

@ -117,7 +117,6 @@
"ember-test-selectors": "6.0.0",
"ember-tooltips": "3.5.1",
"ember-truth-helpers": "3.0.0",
"ember-useragent": "0.12.0",
"emberx-file-input": "1.2.1",
"eslint": "8.9.0",
"eslint-plugin-ghost": "2.12.0",

View File

@ -6188,7 +6188,7 @@ ember-auto-import@1.12.1:
walk-sync "^0.3.3"
webpack "^4.43.0"
ember-auto-import@^1.11.2, ember-auto-import@^1.11.3, ember-auto-import@^1.12.0, ember-auto-import@^1.2.19, ember-auto-import@^1.5.3:
ember-auto-import@^1.11.2, ember-auto-import@^1.11.3, ember-auto-import@^1.12.0, ember-auto-import@^1.2.19:
version "1.12.0"
resolved "https://registry.yarnpkg.com/ember-auto-import/-/ember-auto-import-1.12.0.tgz#52246b04891090e2608244e65c4c6af7710df12b"
integrity sha512-fzMGnyHGfUNFHchpLbJ98Vs/c5H2wZBMR9r/XwW+WOWPisZDGLUPPyhJQsSREPoUQ+o8GvyLaD/rkrKqW8bmgw==
@ -7546,16 +7546,6 @@ ember-truth-helpers@3.0.0, "ember-truth-helpers@^2.1.0 || ^3.0.0":
dependencies:
ember-cli-babel "^7.22.1"
ember-useragent@0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/ember-useragent/-/ember-useragent-0.12.0.tgz#0c327985810aead9b055481f71f0cbcf75b217a4"
integrity sha512-EeYWqlfF/37vP7cpvAU7srEtm8BpX0c4Hk899tQjKbNDPdNqQ0C8G9vh1YgDqPed4URJi5xmjtynGeQbDbQwpw==
dependencies:
ember-auto-import "^1.5.3"
ember-cli-babel "^7.13.0"
ember-cli-htmlbars "^4.2.0"
ua-parser-js "^0.7.31"
emberx-file-input@1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/emberx-file-input/-/emberx-file-input-1.2.1.tgz#a9214a9b3278c270a4d60e58836d2c1b98bce0ab"
@ -15179,11 +15169,6 @@ typescript-memoize@^1.0.0-alpha.3, typescript-memoize@^1.0.1:
resolved "https://registry.yarnpkg.com/typescript-memoize/-/typescript-memoize-1.1.0.tgz#4a8f512d06fc995167c703a3592219901db8bc79"
integrity sha512-LQPKVXK8QrBBkL/zclE6YgSWn0I8ew5m0Lf+XL00IwMhlotqRLlzHV+BRrljVQIc+NohUAuQP7mg4HQwrx5Xbg==
ua-parser-js@^0.7.31:
version "0.7.31"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.31.tgz#649a656b191dffab4f21d5e053e27ca17cbff5c6"
integrity sha512-qLK/Xe9E2uzmYI3qLeOmI0tEOt+TBBQyUIAh4aAgU05FVYzeZrKUdkAZfBNVGRaHVgV0TDkdEngJSw/SyQchkQ==
uc.micro@^1.0.1, uc.micro@^1.0.5:
version "1.0.6"
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac"