From 7fee83cbcdb07da287507e5f0308bc22cb9906d4 Mon Sep 17 00:00:00 2001 From: Josep Boix Requesens Date: Tue, 20 Aug 2024 09:44:24 +0200 Subject: [PATCH 1/3] chore: expose version in create script Updates create script template to include the version of the generated component or plugin. --- scripts/template/src/{{kebabCase name}}.js.hbs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/template/src/{{kebabCase name}}.js.hbs b/scripts/template/src/{{kebabCase name}}.js.hbs index babec0f..fa05734 100644 --- a/scripts/template/src/{{kebabCase name}}.js.hbs +++ b/scripts/template/src/{{kebabCase name}}.js.hbs @@ -1,4 +1,5 @@ import {{platform}} from '{{importAlias}}'; +import { version } from '../package.json'; {{#if wantLocalization}}import './lang';{{/if}} {{#ifEq type 'Plugin'}} @@ -23,6 +24,7 @@ class {{properCase name}} extends Plugin { } } +{{properCase name}}.VERSION = version; {{platform}}.registerPlugin('{{camelCase name}}', {{properCase name}}); {{else}} /** @@ -54,6 +56,7 @@ class {{properCase name}} extends {{type}} { } } +{{properCase name}}.VERSION = version; {{platform}}.registerComponent('{{properCase name}}', {{properCase name}}); {{/ifEq}} From 109905e077171fddb78ee9c0254e67882fa8c703 Mon Sep 17 00:00:00 2001 From: Josep Boix Requesens Date: Tue, 20 Aug 2024 09:54:12 +0200 Subject: [PATCH 2/3] fix(skip-button): expose skip button component version Expose the component version by adding a `VERSION` property to the constructor, to retrieve the version of the component on a given player simply do: ```javascript // Retrieve the player const player = document.getElementsByTagName('video')[0].parentElement.player; // Print the component version console.log(player.SkipButton.constructor.VERSION); ``` --- packages/skip-button/src/skip-button.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/skip-button/src/skip-button.js b/packages/skip-button/src/skip-button.js index 960d360..19b67f5 100644 --- a/packages/skip-button/src/skip-button.js +++ b/packages/skip-button/src/skip-button.js @@ -1,4 +1,5 @@ import pillarbox from '@srgssr/pillarbox-web'; +import { version } from '../package.json'; import './lang'; /** @@ -76,6 +77,7 @@ class SkipButton extends Button { } } +SkipButton.VERSION = version; pillarbox.registerComponent('SkipButton', SkipButton); export default SkipButton; From 1e07832cde152b74226313a0095468a423133ae8 Mon Sep 17 00:00:00 2001 From: Josep Boix Requesens Date: Tue, 20 Aug 2024 09:58:40 +0200 Subject: [PATCH 3/3] fix(playlist-plugin): expose playlist plugin version Expose the plugin version by adding a static getter `VERSION` to all plugins and components. To retrieve the version of the component on a given player simply do: ```javascript // Retrieve the player const player = document.getElementsByTagName('video')[0].parentElement.player; // Print the component version console.log(player.pillarboxPlaylist().version()); ``` --- packages/pillarbox-playlist/src/pillarbox-playlist.js | 5 +++++ packages/skip-button/src/skip-button.js | 5 ++++- scripts/template/src/{{kebabCase name}}.js.hbs | 10 ++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/pillarbox-playlist/src/pillarbox-playlist.js b/packages/pillarbox-playlist/src/pillarbox-playlist.js index e536fa6..b1eb63d 100644 --- a/packages/pillarbox-playlist/src/pillarbox-playlist.js +++ b/packages/pillarbox-playlist/src/pillarbox-playlist.js @@ -1,4 +1,5 @@ import videojs from 'video.js'; +import { version } from '../package.json'; /** * @ignore @@ -467,6 +468,10 @@ export class PillarboxPlaylist extends Plugin { currentIndex: this.currentIndex_ }); } + + static get VERSION() { + return version; + } } PillarboxPlaylist.prototype.options_ = { diff --git a/packages/skip-button/src/skip-button.js b/packages/skip-button/src/skip-button.js index 19b67f5..42fc339 100644 --- a/packages/skip-button/src/skip-button.js +++ b/packages/skip-button/src/skip-button.js @@ -75,9 +75,12 @@ class SkipButton extends Button { this.controlText(text); this.show(); } + + static get VERSION() { + return version; + } } -SkipButton.VERSION = version; pillarbox.registerComponent('SkipButton', SkipButton); export default SkipButton; diff --git a/scripts/template/src/{{kebabCase name}}.js.hbs b/scripts/template/src/{{kebabCase name}}.js.hbs index fa05734..be9e43b 100644 --- a/scripts/template/src/{{kebabCase name}}.js.hbs +++ b/scripts/template/src/{{kebabCase name}}.js.hbs @@ -22,9 +22,12 @@ class {{properCase name}} extends Plugin { constructor(player, options) { super(player, options); } + + static get VERSION() { + return version; + } } -{{properCase name}}.VERSION = version; {{platform}}.registerPlugin('{{camelCase name}}', {{properCase name}}); {{else}} /** @@ -54,9 +57,12 @@ class {{properCase name}} extends {{type}} { handleLanguagechange() { super.handleLanguagechange(); } + + static get VERSION() { + return version; + } } -{{properCase name}}.VERSION = version; {{platform}}.registerComponent('{{properCase name}}', {{properCase name}}); {{/ifEq}}