From 62939eee961b6f88cf0f2eb8be1774c66b30380b Mon Sep 17 00:00:00 2001 From: mister-ben <1676039+mister-ben@users.noreply.github.com> Date: Sun, 21 Jul 2024 20:33:21 +0200 Subject: [PATCH 1/4] wip --- package-lock.json | 16 +++++++++--- package.json | 2 ++ rollup.config.js | 5 ++++ src/js/player.js | 64 ++++++++++++++++++++++++++--------------------- 4 files changed, 56 insertions(+), 31 deletions(-) diff --git a/package-lock.json b/package-lock.json index 06fb5710a8..44d3e56e1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1587,9 +1587,9 @@ } }, "@rollup/pluginutils": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.4.tgz", - "integrity": "sha512-0KJnIoRI8A+a1dqOYLxH8vBf8bphDmty5QvIm2hqm7oFCFYKCAZWWd2hXgMibaPsNDhI0AtpYfQZJG47pt/k4g==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", + "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", "dev": true, "requires": { "@types/estree": "^1.0.0", @@ -12402,6 +12402,16 @@ "chalk": "^2.4.2" } }, + "rollup-plugin-replace": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-replace/-/rollup-plugin-replace-2.2.0.tgz", + "integrity": "sha512-/5bxtUPkDHyBJAKketb4NfaeZjL5yLZdeUihSfbF2PQMz+rSTEb8ARKoOl3UBT4m7/X+QOXJo3sLTcq+yMMYTA==", + "dev": true, + "requires": { + "magic-string": "^0.25.2", + "rollup-pluginutils": "^2.6.0" + } + }, "rollup-plugin-stub": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/rollup-plugin-stub/-/rollup-plugin-stub-1.2.0.tgz", diff --git a/package.json b/package.json index 044948e166..a1fbe6a45f 100644 --- a/package.json +++ b/package.json @@ -105,6 +105,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", @@ -153,6 +154,7 @@ "rollup-plugin-multi-entry": "^2.0.2", "rollup-plugin-node-resolve": "^4.2.4", "rollup-plugin-progress": "^1.1.2", + "rollup-plugin-replace": "^2.2.0", "rollup-plugin-stub": "^1.2.0", "rollup-plugin-svg": "^2.0.0", "sass": "^1.34.0", diff --git a/rollup.config.js b/rollup.config.js index 4a97d0156e..18cdc6ffef 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -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-ignore'; const excludeCoverage = [ 'test/**', @@ -143,6 +144,10 @@ export default cliargs => [ }, external: externals.browser, plugins: [ + excludeLines({ + include: 'src/**', + patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + }), alias({ 'video.js': path.resolve(__dirname, './src/js/video.js') }), diff --git a/src/js/player.js b/src/js/player.js index e9c7300a56..05c833cda8 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -5325,6 +5325,42 @@ 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. + */ + // exclude start + hasPlugin(name) { + return false; + } + // exclude end + + /** + * 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. + */ + usingPlugin(name) { + return false; + } } /** @@ -5527,33 +5563,5 @@ 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; From 89234d0b2e053fb5aa22725c984460c9b290378f Mon Sep 17 00:00:00 2001 From: mister-ben <1676039+mister-ben@users.noreply.github.com> Date: Mon, 22 Jul 2024 00:37:21 +0200 Subject: [PATCH 2/4] fix(types): Add has|usingPlugin to typedef --- package-lock.json | 10 ---------- package.json | 1 - rollup.config.js | 32 ++++++++++++++++++++++++++++++-- src/js/component.js | 10 ++++++++++ src/js/player.js | 6 ++++-- 5 files changed, 44 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 44d3e56e1f..776008dd76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12402,16 +12402,6 @@ "chalk": "^2.4.2" } }, - "rollup-plugin-replace": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-replace/-/rollup-plugin-replace-2.2.0.tgz", - "integrity": "sha512-/5bxtUPkDHyBJAKketb4NfaeZjL5yLZdeUihSfbF2PQMz+rSTEb8ARKoOl3UBT4m7/X+QOXJo3sLTcq+yMMYTA==", - "dev": true, - "requires": { - "magic-string": "^0.25.2", - "rollup-pluginutils": "^2.6.0" - } - }, "rollup-plugin-stub": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/rollup-plugin-stub/-/rollup-plugin-stub-1.2.0.tgz", diff --git a/package.json b/package.json index a1fbe6a45f..5e06d8bdec 100644 --- a/package.json +++ b/package.json @@ -154,7 +154,6 @@ "rollup-plugin-multi-entry": "^2.0.2", "rollup-plugin-node-resolve": "^4.2.4", "rollup-plugin-progress": "^1.1.2", - "rollup-plugin-replace": "^2.2.0", "rollup-plugin-stub": "^1.2.0", "rollup-plugin-svg": "^2.0.0", "sass": "^1.34.0", diff --git a/rollup.config.js b/rollup.config.js index 18cdc6ffef..ca2f96ac49 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -17,7 +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-ignore'; +import excludeLines from './build/rollup-exclude-lines'; const excludeCoverage = [ 'test/**', @@ -145,7 +145,7 @@ export default cliargs => [ external: externals.browser, plugins: [ excludeLines({ - include: 'src/**', + include: 'src/js/**', patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] }), alias({ @@ -174,6 +174,10 @@ export default cliargs => [ }, external: externals.browser, plugins: [ + excludeLines({ + include: 'src/js/**', + patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + }), alias({ 'video.js': path.resolve(__dirname, './src/js/video.js') }), @@ -198,6 +202,10 @@ export default cliargs => [ }, external: externals.test, plugins: [ + excludeLines({ + include: 'src/js/**', + patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + }), multiEntry({exports: false}), alias({ 'video.js': path.resolve(__dirname, './src/js/video.js') @@ -233,6 +241,10 @@ export default cliargs => [ ], external: externals.module, plugins: [ + excludeLines({ + include: 'src/js/**', + patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + }), 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'), @@ -265,6 +277,10 @@ export default cliargs => [ external: externals.browser, plugins: [ primedIgnore, + excludeLines({ + include: 'src/js/**', + patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + }), alias({ 'video.js': path.resolve(__dirname, './src/js/video.js') }), @@ -297,6 +313,10 @@ export default cliargs => [ ], external: externals.module, plugins: [ + excludeLines({ + include: 'src/js/**', + patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + }), json(), primedBabel, svg(), @@ -318,6 +338,10 @@ export default cliargs => [ external: externals.browser, plugins: [ primedResolve, + excludeLines({ + include: 'src/js/**', + patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + }), json(), primedExternalGlobals, primedCjs, @@ -342,6 +366,10 @@ export default cliargs => [ plugins: [ primedIgnore, primedResolve, + excludeLines({ + include: 'src/js/**', + patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + }), json(), primedExternalGlobals, primedCjs, diff --git a/src/js/component.js b/src/js/component.js index ad8e67f627..b64e19c416 100644 --- a/src/js/component.js +++ b/src/js/component.js @@ -151,7 +151,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`. @@ -164,7 +166,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 @@ -177,7 +181,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 @@ -191,7 +197,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` @@ -212,7 +220,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. diff --git a/src/js/player.js b/src/js/player.js index 05c833cda8..89848c0b61 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -5339,11 +5339,11 @@ class Player extends Component { * @return {boolean} * Whether or not this player has the requested plugin available. */ - // exclude start + /* start-delete-from-build */ hasPlugin(name) { return false; } - // exclude end + /* end-delete-from-build */ /** * Reports whether or not a player is using a plugin by name. @@ -5358,9 +5358,11 @@ class Player extends Component { * @return {boolean} * Whether or not this player is using the requested plugin. */ + /* start-delete-from-build */ usingPlugin(name) { return false; } + /* end-delete-from-build */ } /** From 6917b32745e7b474d579dcee449e9d72efa0ee26 Mon Sep 17 00:00:00 2001 From: mister-ben <1676039+mister-ben@users.noreply.github.com> Date: Mon, 22 Jul 2024 00:42:06 +0200 Subject: [PATCH 3/4] remove unused option --- rollup.config.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index ca2f96ac49..c24f5a9713 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -145,8 +145,7 @@ export default cliargs => [ external: externals.browser, plugins: [ excludeLines({ - include: 'src/js/**', - patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + include: 'src/js/**' }), alias({ 'video.js': path.resolve(__dirname, './src/js/video.js') @@ -175,8 +174,7 @@ export default cliargs => [ external: externals.browser, plugins: [ excludeLines({ - include: 'src/js/**', - patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + include: 'src/js/**' }), alias({ 'video.js': path.resolve(__dirname, './src/js/video.js') @@ -203,8 +201,7 @@ export default cliargs => [ external: externals.test, plugins: [ excludeLines({ - include: 'src/js/**', - patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + include: 'src/js/**' }), multiEntry({exports: false}), alias({ @@ -242,8 +239,7 @@ export default cliargs => [ external: externals.module, plugins: [ excludeLines({ - include: 'src/js/**', - patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + include: 'src/js/**' }), alias({ 'video.js': path.resolve(__dirname, './src/js/video.js'), @@ -278,8 +274,7 @@ export default cliargs => [ plugins: [ primedIgnore, excludeLines({ - include: 'src/js/**', - patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + include: 'src/js/**' }), alias({ 'video.js': path.resolve(__dirname, './src/js/video.js') @@ -314,8 +309,7 @@ export default cliargs => [ external: externals.module, plugins: [ excludeLines({ - include: 'src/js/**', - patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + include: 'src/js/**' }), json(), primedBabel, @@ -339,8 +333,7 @@ export default cliargs => [ plugins: [ primedResolve, excludeLines({ - include: 'src/js/**', - patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + include: 'src/js/**' }), json(), primedExternalGlobals, @@ -367,8 +360,7 @@ export default cliargs => [ primedIgnore, primedResolve, excludeLines({ - include: 'src/js/**', - patterns: [/\/\/\s*exclude\s*start[\s\S]*?\/\/\s*exclude\s*end/g] + include: 'src/js/**' }), json(), primedExternalGlobals, From 17c2e2929effc4b1e9f45a2a9a07a050665d6d3e Mon Sep 17 00:00:00 2001 From: mister-ben <1676039+mister-ben@users.noreply.github.com> Date: Mon, 22 Jul 2024 00:51:11 +0200 Subject: [PATCH 4/4] add eclude line plugin --- build/rollup-exclude-lines.js | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 build/rollup-exclude-lines.js diff --git a/build/rollup-exclude-lines.js b/build/rollup-exclude-lines.js new file mode 100644 index 0000000000..a9304f76a5 --- /dev/null +++ b/build/rollup-exclude-lines.js @@ -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, ''); + } + }; +}