diff --git a/.browserslistrc b/.browserslistrc new file mode 120000 index 0000000..fb049b7 --- /dev/null +++ b/.browserslistrc @@ -0,0 +1 @@ +./node_modules/@silvermine/standardization/browserslist/.browserslistrc-broad-support \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 120000 index 0000000..88df7a4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1 @@ +node_modules/@silvermine/standardization/.editorconfig \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index bc9e8cb..e95c418 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,5 +1,4 @@ { - - "extends": "@silvermine/eslint-config/node" - + "extends": "@silvermine/eslint-config/node", + "parser": "babel-eslint" } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b01c62f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: CI + +on: [ push, pull_request ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + uses: actions/checkout@v3 + with: + fetch-depth: 0 # Fetch all history + - + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + - run: npm i -g npm@8.5.5 + - run: npm ci + - run: npm run standards + test: + needs: [ build ] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node-version: [ 14, 16, 'lts/*', 'latest' ] + steps: + - uses: actions/checkout@v3 + - + name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - run: npm i -g npm@8.5.5 + - run: npm ci # Reinstall the dependencies to ensure they install with the current version of node + - run: npm test + - name: Coveralls + uses: coverallsapp/github-action@v1 diff --git a/.gitignore b/.gitignore index f436212..e3ec41b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .DS_Store node_modules coverage +.nyc_output dist +.idea diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..703ffa1 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/@silvermine/standardization/.markdownlint.json" +} diff --git a/.npmignore b/.npmignore index b6478af..3c7082a 100644 --- a/.npmignore +++ b/.npmignore @@ -3,3 +3,5 @@ Gruntfile.js tests/** docs +.nyc_output +coverage diff --git a/.nvmrc b/.nvmrc index 65d83ce..99cdd80 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -12.14.0 +16.15.0 diff --git a/.nycrc.json b/.nycrc.json new file mode 100644 index 0000000..11f0896 --- /dev/null +++ b/.nycrc.json @@ -0,0 +1,16 @@ +{ + "include": [ + "src/**/*.js" + ], + "extension": [ + ".js" + ], + "reporter": [ + "text-summary", + "html", + "lcov" + ], + "instrument": true, + "sourceMap": true, + "all": true +} diff --git a/.stylelintrc.yml b/.stylelintrc.yml new file mode 100644 index 0000000..40396ee --- /dev/null +++ b/.stylelintrc.yml @@ -0,0 +1 @@ +extends: ./node_modules/@silvermine/standardization/.stylelintrc.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fcdf8e6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: node_js -node_js: - - "node" # Latest node version - - "lts/*" # Latest LTS version - - "12" - - "10" - - "8" - -before_install: npm i -g npm@6.13.4 - -script: - - npm run commitlint - - grunt standards - - npm test - -# For code coverage: -after_success: - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage diff --git a/CHANGELOG.md b/CHANGELOG.md index 39c6cf1..999a8f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,15 @@ -# Silvermine VideoJS Quality/Resolution Selector Change Log +# Changelog + +All notable changes to this project will be documented in this file. +See [our coding standards][commit-messages] for commit guidelines. + +### [1.3.1](https://github.com/silvermine/videojs-quality-selector/compare/v1.3.0...v1.3.1) (2023-11-15) + + +### Bug Fixes + +* use correct icon for Video.js 8 ([1209756](https://github.com/silvermine/videojs-quality-selector/commit/1209756616af52843f55ac53e2c7fbe29df63541)) -In general, this project adheres to [Semantic Versioning](http://semver.org/). If for some -reason we do something that's not strictly semantic, it will be clearly called out below. ## 1.2.3 diff --git a/Gruntfile.js b/Gruntfile.js index 3f485c9..407d3ea 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,18 +2,25 @@ * 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'); -const sass = require('node-sass'); +const sass = require('sass'); module.exports = function(grunt) { var DEBUG = !!grunt.option('debug'), - config; + pkgJSON = grunt.file.readJSON('package.json'), + config, versionInfo; + + try { + versionInfo = getCodeVersion.both(); + } catch(e) { + // When this package is installed as a git URL, getCodeVersion throws an error and + // is not able to find the git version for this package. So, we fall back to using + // the version number from package.json + versionInfo = pkgJSON.version; + } config = { js: { @@ -22,7 +29,7 @@ module.exports = function(grunt) { }, sass: { - base: path.join(__dirname, 'src', 'sass'), + base: path.join(__dirname, 'src', 'scss'), all: [ 'src/**/*.scss' ], }, @@ -44,14 +51,34 @@ module.exports = function(grunt) { grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - versionInfo: getCodeVersion.both(), + pkg: pkgJSON, + versionInfo: versionInfo, config: config, browserify: { 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, + }, + ], + ], + }, + ], + ], + }, }, }, @@ -109,17 +136,6 @@ module.exports = function(grunt) { dist: config.dist.base, }, - eslint: { - target: config.js.all, - }, - - sasslint: { - options: { - configFile: path.join(__dirname, 'node_modules', '@silvermine/sass-lint-config', 'sass-lint.yml'), - }, - target: config.sass.all, - }, - watch: { grunt: { files: [ 'Gruntfile.js' ], @@ -136,19 +152,15 @@ module.exports = function(grunt) { tasks: [ 'build-css' ], }, }, - }); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-browserify'); - grunt.loadNpmTasks('grunt-eslint'); grunt.loadNpmTasks('grunt-postcss'); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-sass'); - grunt.loadNpmTasks('grunt-sass-lint'); - grunt.registerTask('standards', [ 'eslint', 'sasslint' ]); grunt.registerTask('build-js', [ 'browserify', 'uglify' ]); grunt.registerTask('build-css', [ 'sass', 'postcss' ]); grunt.registerTask('build', [ 'build-js', 'build-css' ]); diff --git a/README.md b/README.md index e9e36f5..ed1083a 100644 --- a/README.md +++ b/README.md @@ -31,14 +31,14 @@ for `videojs` at `window.videojs`). There is an example of this in [`docs/demo/index.html`](./docs/demo/index.html). -##### From local file: +##### From local file ```js ``` -##### From [`unpkg`](https://unpkg.com/@silvermine/videojs-quality-selector/): +##### From [`unpkg`](https://unpkg.com/@silvermine/videojs-quality-selector/) ```js @@ -50,7 +50,7 @@ There is an example of this in When using NPM/Browserify, first install the plugin. -``` +```bash npm install --save @silvermine/videojs-quality-selector ``` @@ -64,6 +64,23 @@ var videojs = require('videojs'); require('@silvermine/videojs-quality-selector')(videojs); ``` +Remember to also add the CSS to your build. With most bundlers you can: + +```js +require('@silvermine/videojs-quality-selector/dist/css/quality-selector.css') +``` + +> [!WARNING] +> This plugin's source code uses ES6+ syntax and keywords, such as `class` and `static`. +> If you need to support [browsers that do not support newer JavaScript +> syntax](https://caniuse.com/es6), you will need to use a tool like +> [Babel](https://babeljs.io/) to transpile and polyfill your code. +> +> Alternatively, you can +> `require('@silvermine/videojs-quality-selector/dist/js/silvermine-videojs-quality-selector.js')` +> to use a JavaScript file that has already been polyfilled/transpiled down to ES5 +> compatibility. + ### Providing video sources Sources can be provided with either the `` tag or via the `src` function on the @@ -72,7 +89,7 @@ instance of a `video.js` player. #### Using `` ```html -