Merge pull request #86 from crgwbr/crweber/es6_classes

refactor: use es6 classes
This commit is contained in:
Matt Luedke 2022-12-27 08:37:22 -05:00 committed by GitHub
commit c416a312ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 8254 additions and 2747 deletions

1
.browserslistrc Symbolic link
View file

@ -0,0 +1 @@
./node_modules/@silvermine/standardization/browserslist/.browserslistrc-broad-support

View file

@ -1,5 +1,4 @@
{
"extends": "@silvermine/eslint-config/node"
"extends": "@silvermine/eslint-config/node",
"parser": "babel-eslint"
}

View file

@ -2,9 +2,6 @@
* Copyright (c) 2017 Jeremy Thomerson
* Licensed under the MIT license.
*/
'use strict';
var path = require('path'),
getCodeVersion = require('silvermine-serverless-utils/src/get-code-version');
@ -52,6 +49,26 @@ module.exports = function(grunt) {
main: {
src: config.js.standalone,
dest: config.dist.js.bundle,
options: {
transform: [
[
'babelify',
{
presets: [
[
'@babel/preset-env',
{
debug: true,
useBuiltIns: 'usage',
shippedProposals: true,
corejs: 3,
},
],
],
},
],
],
},
},
},

View file

@ -1,5 +1,3 @@
'use strict';
module.exports = {
extends: [ '@silvermine/standardization/commitlint.js' ],
};

10903
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -33,19 +33,31 @@
},
"homepage": "https://github.com/silvermine/videojs-quality-selector#readme",
"devDependencies": {
"@babel/core": "7.13.16",
"@babel/preset-env": "7.13.15",
"@commitlint/cli": "8.3.5",
"@commitlint/travis-cli": "8.3.5",
"@silvermine/eslint-config": "3.0.1",
"@silvermine/standardization": "2.0.0",
"autoprefixer": "8.6.5",
"babelify": "10.0.0",
"babel-eslint": "10.1.0",
"check-node-version": "4.0.3",
"core-js": "3.11.0",
"coveralls": "3.0.3",
"eslint": "6.8.0",
"expect.js": "0.3.1",
"grunt": "1.4.0",
"grunt-browserify": "5.3.0",
"grunt-cli": "1.3.2",
"grunt-contrib-clean": "2.0.0",
"grunt-contrib-uglify": "4.0.1",
"grunt-contrib-watch": "1.1.0",
"grunt-eslint": "22.0.0",
"grunt-markdownlint": "3.1.4",
"grunt-postcss": "0.9.0",
"grunt-sass": "3.0.2",
"grunt-stylelint": "0.16.0",
"mocha": "8.4.0",
"mocha-lcov-reporter": "1.3.0",
"nyc": "15.1.0",
@ -58,7 +70,6 @@
"video.js": ">=6.0.0"
},
"dependencies": {
"class.extend": "0.9.1",
"underscore": "1.13.1"
}
}

View file

@ -1,5 +1,3 @@
'use strict';
var _ = require('underscore'),
events = require('../events');

View file

@ -1,5 +1,3 @@
'use strict';
var _ = require('underscore'),
events = require('../events'),
qualityOptionFactory = require('./QualityOption'),

View file

@ -1,9 +1,5 @@
'use strict';
module.exports = {
QUALITY_REQUESTED: 'qualityRequested',
QUALITY_SELECTED: 'qualitySelected',
PLAYER_SOURCES_CHANGED: 'playerSourcesChanged',
};

View file

@ -1,5 +1,3 @@
'use strict';
var _ = require('underscore'),
events = require('./events'),
qualitySelectorFactory = require('./components/QualitySelector'),

View file

@ -1,5 +1,3 @@
'use strict';
var _ = require('underscore'),
events = require('../events');

View file

@ -1,3 +1 @@
'use strict';
require('./index')();

View file

@ -1,17 +1,13 @@
'use strict';
var Class = require('class.extend');
module.exports = Class.extend({
init: function(player, seekToTime) {
class SafeSeek {
constructor(player, seekToTime) {
this._player = player;
this._seekToTime = seekToTime;
this._hasFinished = false;
this._keepThisInstanceWhenPlayerSourcesChange = false;
this._seekWhenSafe();
},
}
_seekWhenSafe: function() {
_seekWhenSafe() {
var HAVE_FUTURE_DATA = 3;
// `readyState` in Video.js is the same as the HTML5 Media element's `readyState`
@ -35,9 +31,9 @@ module.exports = Class.extend({
} else {
this._seek();
}
},
}
onPlayerSourcesChange: function() {
onPlayerSourcesChange() {
if (this._keepThisInstanceWhenPlayerSourcesChange) {
// By setting this to `false`, we know that if the player sources change again
// the change did not originate from a quality selection change, the new sources
@ -47,9 +43,9 @@ module.exports = Class.extend({
} else {
this.cancel();
}
},
}
onQualitySelectionChange: function() {
onQualitySelectionChange() {
// `onPlayerSourcesChange` will cancel this pending seek unless we tell it not to.
// We need to reuse this same pending seek instance because when the player is
// paused, the `preload` attribute is set to `none`, and the user selects one
@ -60,21 +56,23 @@ module.exports = Class.extend({
if (!this.hasFinished()) {
this._keepThisInstanceWhenPlayerSourcesChange = true;
}
},
}
_seek: function() {
_seek() {
this._player.currentTime(this._seekToTime);
this._keepThisInstanceWhenPlayerSourcesChange = false;
this._hasFinished = true;
},
}
hasFinished: function() {
hasFinished() {
return this._hasFinished;
},
}
cancel: function() {
cancel() {
this._player.off('canplay', this._seekFn);
this._keepThisInstanceWhenPlayerSourcesChange = false;
this._hasFinished = true;
},
});
}
}
module.exports = SafeSeek;

View file

@ -1,5 +1,3 @@
'use strict';
var expect = require('expect.js');
describe('Everything', function() {