Skip to content

Commit

Permalink
Merge branch 'main' into type-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mister-ben committed Aug 13, 2024
2 parents 4d14bae + e715145 commit 0b48cd5
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 59 deletions.
41 changes: 41 additions & 0 deletions build/rollup-exclude-lines.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Remove parts of files from outputs. Everything between a pair of `/* start-delete-from-build *\u002f`
* and `/* end-delete-from-build *\u002f` comments
*
* Based on https://github.com/se-panfilov/rollup-plugin-strip-code
*/

import { createFilter } from '@rollup/pluginutils';

const START_COMMENT = 'start-delete-from-build';
const END_COMMENT = 'end-delete-from-build';

/**
* Remove lines of code surrounded by comments
*
* @param {Object} [options] Options
* @param {string} [options.include] Files to inlcude
* @param {string} [options.exclude] Files to exclude
* @param {string} [options.startComment] Starting keywork, default start-delete-from-build
* @param {string} [options.endComment] Eding keywork, default end-delete-from-build
* @param {RegExp} [options.pattern] Custom regex
* @return void
*/
export default function excludeLines(options = {}) {
// assume that the myPlugin accepts options of `options.include` and `options.exclude`
const filter = createFilter(options.include, options.exclude);

return {
transform(code, id) {
if (!filter(id)) {
return;
}

const startComment = options.startComment || START_COMMENT;
const endComment = options.endComment || END_COMMENT;
const defaultPattern = new RegExp(`([\\t ]*\\/\\* ?${startComment} ?\\*\\/)[\\s\\S]*?(\\/\\* ?${endComment} ?\\*\\/[\\t ]*\\n?)`, 'g');

return code.replace(options.pattern || defaultPattern, '');
}
};
}
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,14 @@
},
"dependencies": {
"@babel/runtime": "^7.12.5",
"@videojs/http-streaming": "3.13.2",
"@videojs/http-streaming": "3.13.3",
"@videojs/vhs-utils": "^4.0.0",
"@videojs/xhr": "2.7.0",
"aes-decrypter": "^4.0.1",
"global": "4.4.0",
"m3u8-parser": "^7.1.0",
"mpd-parser": "^1.2.2",
"mux.js": "^7.0.1",
"safe-json-parse": "4.0.0",
"videojs-contrib-quality-levels": "4.1.0",
"videojs-font": "4.2.0",
"videojs-vtt.js": "0.15.5"
Expand All @@ -105,6 +104,7 @@
"@babel/preset-env": "^7.9.0",
"@rollup/plugin-image": "^3.0.2",
"@rollup/plugin-replace": "^2.4.1",
"@rollup/pluginutils": "^5.1.0",
"@types/node": "^18.8.3",
"access-sniff": "^3.2.0",
"autoprefixer": "^10.2.5",
Expand Down
25 changes: 25 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import image from '@rollup/plugin-image';
import istanbul from 'rollup-plugin-istanbul';
import externalGlobals from 'rollup-plugin-external-globals';
import svg from 'rollup-plugin-svg';
import excludeLines from './build/rollup-exclude-lines';

const excludeCoverage = [
'test/**',
Expand Down Expand Up @@ -143,6 +144,9 @@ export default cliargs => [
},
external: externals.browser,
plugins: [
excludeLines({
include: 'src/js/**'
}),
alias({
'video.js': path.resolve(__dirname, './src/js/video.js')
}),
Expand All @@ -169,6 +173,9 @@ export default cliargs => [
},
external: externals.browser,
plugins: [
excludeLines({
include: 'src/js/**'
}),
alias({
'video.js': path.resolve(__dirname, './src/js/video.js')
}),
Expand All @@ -193,6 +200,9 @@ export default cliargs => [
},
external: externals.test,
plugins: [
excludeLines({
include: 'src/js/**'
}),
multiEntry({exports: false}),
alias({
'video.js': path.resolve(__dirname, './src/js/video.js')
Expand Down Expand Up @@ -228,6 +238,9 @@ export default cliargs => [
],
external: externals.module,
plugins: [
excludeLines({
include: 'src/js/**'
}),
alias({
'video.js': path.resolve(__dirname, './src/js/video.js'),
'videojs-contrib-quality-levels': path.resolve(__dirname, './node_modules/videojs-contrib-quality-levels/dist/videojs-contrib-quality-levels.es.js'),
Expand Down Expand Up @@ -260,6 +273,9 @@ export default cliargs => [
external: externals.browser,
plugins: [
primedIgnore,
excludeLines({
include: 'src/js/**'
}),
alias({
'video.js': path.resolve(__dirname, './src/js/video.js')
}),
Expand Down Expand Up @@ -292,6 +308,9 @@ export default cliargs => [
],
external: externals.module,
plugins: [
excludeLines({
include: 'src/js/**'
}),
json(),
primedBabel,
svg(),
Expand All @@ -313,6 +332,9 @@ export default cliargs => [
external: externals.browser,
plugins: [
primedResolve,
excludeLines({
include: 'src/js/**'
}),
json(),
primedExternalGlobals,
primedCjs,
Expand All @@ -337,6 +359,9 @@ export default cliargs => [
plugins: [
primedIgnore,
primedResolve,
excludeLines({
include: 'src/js/**'
}),
json(),
primedExternalGlobals,
primedCjs,
Expand Down
12 changes: 11 additions & 1 deletion src/js/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ class Component {
* @param {Function} fn
* The function to call with `EventTarget`s
*/
/* start-delete-from-build */
on(type, fn) {}
/* end-delete-from-build */

/**
* Removes an `event listener` for a specific event from an instance of `EventTarget`.
Expand All @@ -162,7 +164,9 @@ class Component {
* @param {Function} [fn]
* The function to remove. If not specified, all listeners managed by Video.js will be removed.
*/
/* start-delete-from-build */
off(type, fn) {}
/* end-delete-from-build */

/**
* This function will add an `event listener` that gets triggered only once. After the
Expand All @@ -175,7 +179,9 @@ class Component {
* @param {Function} fn
* The function to be called once for each event name.
*/
/* start-delete-from-build */
one(type, fn) {}
/* end-delete-from-build */

/**
* This function will add an `event listener` that gets triggered only once and is
Expand All @@ -189,7 +195,9 @@ class Component {
* @param {Function} fn
* The function to be called once for each event name.
*/
/* start-delete-from-build */
any(type, fn) {}
/* end-delete-from-build */

/**
* This function causes an event to happen. This will then cause any `event listeners`
Expand All @@ -210,7 +218,9 @@ class Component {
* @param {Object} [hash]
* Optionally extra argument to pass through to an event listener
*/
/* start-delete-from-build */
trigger(event, hash) {}
/* end-delete-from-build */

/**
* Dispose of the `Component` and all child components.
Expand Down Expand Up @@ -1712,7 +1722,7 @@ class Component {
*/
requestNamedAnimationFrame(name, fn) {
if (this.namedRafs_.has(name)) {
return;
this.cancelNamedAnimationFrame(name);
}
this.clearTimersOnDispose_();

Expand Down
78 changes: 43 additions & 35 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { bufferedPercent } from './utils/buffer.js';
import * as stylesheet from './utils/stylesheet.js';
import FullscreenApi from './fullscreen-api.js';
import MediaError from './media-error.js';
import safeParseTuple from 'safe-json-parse/tuple';
import {merge} from './utils/obj';
import {silencePromise, isPromise} from './utils/promise';
import textTrackConverter from './tracks/text-track-list-converter.js';
Expand Down Expand Up @@ -5282,13 +5281,12 @@ class Player extends Component {
// Check if data-setup attr exists.
if (dataSetup !== null) {
// Parse options JSON
// If empty string, make it a parsable json object.
const [err, data] = safeParseTuple(dataSetup || '{}');

if (err) {
log.error(err);
try {
// If empty string, make it a parsable json object.
Object.assign(tagOptions, JSON.parse(dataSetup || '{}'));
} catch (e) {
log.error('data-setup', e);
}
Object.assign(tagOptions, data);
}

Object.assign(baseOptions, tagOptions);
Expand Down Expand Up @@ -5376,6 +5374,44 @@ class Player extends Component {
*/
this.trigger('playbackrateschange');
}

/**
* Reports whether or not a player has a plugin available.
*
* This does not report whether or not the plugin has ever been initialized
* on this player. For that, [usingPlugin]{@link Player#usingPlugin}.
*
* @method hasPlugin
* @param {string} name
* The name of a plugin.
*
* @return {boolean}
* Whether or not this player has the requested plugin available.
*/
/* start-delete-from-build */
hasPlugin(name) {
return false;
}
/* end-delete-from-build */

/**
* Reports whether or not a player is using a plugin by name.
*
* For basic plugins, this only reports whether the plugin has _ever_ been
* initialized on this player.
*
* @method Player#usingPlugin
* @param {string} name
* The name of a plugin.
*
* @return {boolean}
* Whether or not this player is using the requested plugin.
*/
/* start-delete-from-build */
usingPlugin(name) {
return false;
}
/* end-delete-from-build */
}

TRACK_TYPES.names.forEach(function(name) {
Expand Down Expand Up @@ -5527,34 +5563,6 @@ TECH_EVENTS_RETRIGGER.forEach(function(event) {
* @type {Event}
*/

/**
* Reports whether or not a player has a plugin available.
*
* This does not report whether or not the plugin has ever been initialized
* on this player. For that, [usingPlugin]{@link Player#usingPlugin}.
*
* @method Player#hasPlugin
* @param {string} name
* The name of a plugin.
*
* @return {boolean}
* Whether or not this player has the requested plugin available.
*/

/**
* Reports whether or not a player is using a plugin by name.
*
* For basic plugins, this only reports whether the plugin has _ever_ been
* initialized on this player.
*
* @method Player#usingPlugin
* @param {string} name
* The name of a plugin.
*
* @return {boolean}
* Whether or not this player is using the requested plugin.
*/

Component.registerComponent('Player', Player);
export default Player;
// Including a named export so Typescript can use module augmentation with plugins
Expand Down
Loading

0 comments on commit 0b48cd5

Please sign in to comment.