mirror of
				https://gitea.invidious.io/iv-org/videojs-quality-selector.git
				synced 2024-08-15 00:43:13 +00:00 
			
		
		
		
	Merge pull request #86 from crgwbr/crweber/es6_classes
refactor: use es6 classes
This commit is contained in:
		
						commit
						c416a312ab
					
				
					 14 changed files with 8254 additions and 2747 deletions
				
			
		
							
								
								
									
										1
									
								
								.browserslistrc
									
										
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								.browserslistrc
									
										
									
									
									
										Symbolic link
									
								
							|  | @ -0,0 +1 @@ | ||||||
|  | ./node_modules/@silvermine/standardization/browserslist/.browserslistrc-broad-support | ||||||
|  | @ -1,5 +1,4 @@ | ||||||
| { | { | ||||||
| 
 |    "extends": "@silvermine/eslint-config/node", | ||||||
|    "extends": "@silvermine/eslint-config/node" |    "parser": "babel-eslint" | ||||||
| 
 |  | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										23
									
								
								Gruntfile.js
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								Gruntfile.js
									
										
									
									
									
								
							|  | @ -2,9 +2,6 @@ | ||||||
|  * Copyright (c) 2017 Jeremy Thomerson |  * Copyright (c) 2017 Jeremy Thomerson | ||||||
|  * Licensed under the MIT license. |  * Licensed under the MIT license. | ||||||
|  */ |  */ | ||||||
| 
 |  | ||||||
| 'use strict'; |  | ||||||
| 
 |  | ||||||
| var path = require('path'), | var path = require('path'), | ||||||
|     getCodeVersion = require('silvermine-serverless-utils/src/get-code-version'); |     getCodeVersion = require('silvermine-serverless-utils/src/get-code-version'); | ||||||
| 
 | 
 | ||||||
|  | @ -52,6 +49,26 @@ module.exports = function(grunt) { | ||||||
|          main: { |          main: { | ||||||
|             src: config.js.standalone, |             src: config.js.standalone, | ||||||
|             dest: config.dist.js.bundle, |             dest: config.dist.js.bundle, | ||||||
|  |             options: { | ||||||
|  |                transform: [ | ||||||
|  |                   [ | ||||||
|  |                      'babelify', | ||||||
|  |                      { | ||||||
|  |                         presets: [ | ||||||
|  |                            [ | ||||||
|  |                               '@babel/preset-env', | ||||||
|  |                               { | ||||||
|  |                                  debug: true, | ||||||
|  |                                  useBuiltIns: 'usage', | ||||||
|  |                                  shippedProposals: true, | ||||||
|  |                                  corejs: 3, | ||||||
|  |                               }, | ||||||
|  |                            ], | ||||||
|  |                         ], | ||||||
|  |                      }, | ||||||
|  |                   ], | ||||||
|  |                ], | ||||||
|  |             }, | ||||||
|          }, |          }, | ||||||
|       }, |       }, | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,5 +1,3 @@ | ||||||
| 'use strict'; |  | ||||||
| 
 |  | ||||||
| module.exports = { | module.exports = { | ||||||
|    extends: [ '@silvermine/standardization/commitlint.js' ], |    extends: [ '@silvermine/standardization/commitlint.js' ], | ||||||
| }; | }; | ||||||
|  |  | ||||||
							
								
								
									
										10947
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										10947
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										13
									
								
								package.json
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								package.json
									
										
									
									
									
								
							|  | @ -33,19 +33,31 @@ | ||||||
|   }, |   }, | ||||||
|   "homepage": "https://github.com/silvermine/videojs-quality-selector#readme", |   "homepage": "https://github.com/silvermine/videojs-quality-selector#readme", | ||||||
|   "devDependencies": { |   "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/eslint-config": "3.0.1", | ||||||
|     "@silvermine/standardization": "2.0.0", |     "@silvermine/standardization": "2.0.0", | ||||||
|     "autoprefixer": "8.6.5", |     "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", |     "coveralls": "3.0.3", | ||||||
|     "eslint": "6.8.0", |     "eslint": "6.8.0", | ||||||
|     "expect.js": "0.3.1", |     "expect.js": "0.3.1", | ||||||
|     "grunt": "1.4.0", |     "grunt": "1.4.0", | ||||||
|     "grunt-browserify": "5.3.0", |     "grunt-browserify": "5.3.0", | ||||||
|  |     "grunt-cli": "1.3.2", | ||||||
|     "grunt-contrib-clean": "2.0.0", |     "grunt-contrib-clean": "2.0.0", | ||||||
|     "grunt-contrib-uglify": "4.0.1", |     "grunt-contrib-uglify": "4.0.1", | ||||||
|     "grunt-contrib-watch": "1.1.0", |     "grunt-contrib-watch": "1.1.0", | ||||||
|  |     "grunt-eslint": "22.0.0", | ||||||
|  |     "grunt-markdownlint": "3.1.4", | ||||||
|     "grunt-postcss": "0.9.0", |     "grunt-postcss": "0.9.0", | ||||||
|     "grunt-sass": "3.0.2", |     "grunt-sass": "3.0.2", | ||||||
|  |     "grunt-stylelint": "0.16.0", | ||||||
|     "mocha": "8.4.0", |     "mocha": "8.4.0", | ||||||
|     "mocha-lcov-reporter": "1.3.0", |     "mocha-lcov-reporter": "1.3.0", | ||||||
|     "nyc": "15.1.0", |     "nyc": "15.1.0", | ||||||
|  | @ -58,7 +70,6 @@ | ||||||
|     "video.js": ">=6.0.0" |     "video.js": ">=6.0.0" | ||||||
|   }, |   }, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "class.extend": "0.9.1", |  | ||||||
|     "underscore": "1.13.1" |     "underscore": "1.13.1" | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,5 +1,3 @@ | ||||||
| 'use strict'; |  | ||||||
| 
 |  | ||||||
| var _ = require('underscore'), | var _ = require('underscore'), | ||||||
|     events = require('../events'); |     events = require('../events'); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,5 +1,3 @@ | ||||||
| 'use strict'; |  | ||||||
| 
 |  | ||||||
| var _ = require('underscore'), | var _ = require('underscore'), | ||||||
|     events = require('../events'), |     events = require('../events'), | ||||||
|     qualityOptionFactory = require('./QualityOption'), |     qualityOptionFactory = require('./QualityOption'), | ||||||
|  |  | ||||||
|  | @ -1,9 +1,5 @@ | ||||||
| 'use strict'; |  | ||||||
| 
 |  | ||||||
| module.exports = { | module.exports = { | ||||||
| 
 |  | ||||||
|    QUALITY_REQUESTED: 'qualityRequested', |    QUALITY_REQUESTED: 'qualityRequested', | ||||||
|    QUALITY_SELECTED: 'qualitySelected', |    QUALITY_SELECTED: 'qualitySelected', | ||||||
|    PLAYER_SOURCES_CHANGED: 'playerSourcesChanged', |    PLAYER_SOURCES_CHANGED: 'playerSourcesChanged', | ||||||
| 
 |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -1,5 +1,3 @@ | ||||||
| 'use strict'; |  | ||||||
| 
 |  | ||||||
| var _ = require('underscore'), | var _ = require('underscore'), | ||||||
|     events = require('./events'), |     events = require('./events'), | ||||||
|     qualitySelectorFactory = require('./components/QualitySelector'), |     qualitySelectorFactory = require('./components/QualitySelector'), | ||||||
|  |  | ||||||
|  | @ -1,5 +1,3 @@ | ||||||
| 'use strict'; |  | ||||||
| 
 |  | ||||||
| var _ = require('underscore'), | var _ = require('underscore'), | ||||||
|     events = require('../events'); |     events = require('../events'); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,3 +1 @@ | ||||||
| 'use strict'; |  | ||||||
| 
 |  | ||||||
| require('./index')(); | require('./index')(); | ||||||
|  |  | ||||||
|  | @ -1,17 +1,13 @@ | ||||||
| 'use strict'; | class SafeSeek { | ||||||
| 
 |    constructor(player, seekToTime) { | ||||||
| var Class = require('class.extend'); |  | ||||||
| 
 |  | ||||||
| module.exports = Class.extend({ |  | ||||||
|    init: function(player, seekToTime) { |  | ||||||
|       this._player = player; |       this._player = player; | ||||||
|       this._seekToTime = seekToTime; |       this._seekToTime = seekToTime; | ||||||
|       this._hasFinished = false; |       this._hasFinished = false; | ||||||
|       this._keepThisInstanceWhenPlayerSourcesChange = false; |       this._keepThisInstanceWhenPlayerSourcesChange = false; | ||||||
|       this._seekWhenSafe(); |       this._seekWhenSafe(); | ||||||
|    }, |    } | ||||||
| 
 | 
 | ||||||
|    _seekWhenSafe: function() { |    _seekWhenSafe() { | ||||||
|       var HAVE_FUTURE_DATA = 3; |       var HAVE_FUTURE_DATA = 3; | ||||||
| 
 | 
 | ||||||
|       // `readyState` in Video.js is the same as the HTML5 Media element's `readyState`
 |       // `readyState` in Video.js is the same as the HTML5 Media element's `readyState`
 | ||||||
|  | @ -35,9 +31,9 @@ module.exports = Class.extend({ | ||||||
|       } else { |       } else { | ||||||
|          this._seek(); |          this._seek(); | ||||||
|       } |       } | ||||||
|    }, |    } | ||||||
| 
 | 
 | ||||||
|    onPlayerSourcesChange: function() { |    onPlayerSourcesChange() { | ||||||
|       if (this._keepThisInstanceWhenPlayerSourcesChange) { |       if (this._keepThisInstanceWhenPlayerSourcesChange) { | ||||||
|          // By setting this to `false`, we know that if the player sources change again
 |          // 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
 |          // the change did not originate from a quality selection change, the new sources
 | ||||||
|  | @ -47,9 +43,9 @@ module.exports = Class.extend({ | ||||||
|       } else { |       } else { | ||||||
|          this.cancel(); |          this.cancel(); | ||||||
|       } |       } | ||||||
|    }, |    } | ||||||
| 
 | 
 | ||||||
|    onQualitySelectionChange: function() { |    onQualitySelectionChange() { | ||||||
|       // `onPlayerSourcesChange` will cancel this pending seek unless we tell it not to.
 |       // `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
 |       // 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
 |       // paused, the `preload` attribute is set to `none`, and the user selects one
 | ||||||
|  | @ -60,21 +56,23 @@ module.exports = Class.extend({ | ||||||
|       if (!this.hasFinished()) { |       if (!this.hasFinished()) { | ||||||
|          this._keepThisInstanceWhenPlayerSourcesChange = true; |          this._keepThisInstanceWhenPlayerSourcesChange = true; | ||||||
|       } |       } | ||||||
|    }, |    } | ||||||
| 
 | 
 | ||||||
|    _seek: function() { |    _seek() { | ||||||
|       this._player.currentTime(this._seekToTime); |       this._player.currentTime(this._seekToTime); | ||||||
|       this._keepThisInstanceWhenPlayerSourcesChange = false; |       this._keepThisInstanceWhenPlayerSourcesChange = false; | ||||||
|       this._hasFinished = true; |       this._hasFinished = true; | ||||||
|    }, |    } | ||||||
| 
 | 
 | ||||||
|    hasFinished: function() { |    hasFinished() { | ||||||
|       return this._hasFinished; |       return this._hasFinished; | ||||||
|    }, |    } | ||||||
| 
 | 
 | ||||||
|    cancel: function() { |    cancel() { | ||||||
|       this._player.off('canplay', this._seekFn); |       this._player.off('canplay', this._seekFn); | ||||||
|       this._keepThisInstanceWhenPlayerSourcesChange = false; |       this._keepThisInstanceWhenPlayerSourcesChange = false; | ||||||
|       this._hasFinished = true; |       this._hasFinished = true; | ||||||
|    }, |    } | ||||||
| }); | } | ||||||
|  | 
 | ||||||
|  | module.exports = SafeSeek; | ||||||
|  |  | ||||||
|  | @ -1,5 +1,3 @@ | ||||||
| 'use strict'; |  | ||||||
| 
 |  | ||||||
| var expect = require('expect.js'); | var expect = require('expect.js'); | ||||||
| 
 | 
 | ||||||
| describe('Everything', function() { | describe('Everything', function() { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue