Skip to content

Commit

Permalink
fix(playlist-plugin): expose playlist plugin version
Browse files Browse the repository at this point in the history
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());
```
  • Loading branch information
jboix committed Aug 27, 2024
1 parent 109905e commit 1e07832
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/pillarbox-playlist/src/pillarbox-playlist.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import videojs from 'video.js';
import { version } from '../package.json';

/**
* @ignore
Expand Down Expand Up @@ -467,6 +468,10 @@ export class PillarboxPlaylist extends Plugin {
currentIndex: this.currentIndex_
});
}

static get VERSION() {
return version;
}
}

PillarboxPlaylist.prototype.options_ = {
Expand Down
5 changes: 4 additions & 1 deletion packages/skip-button/src/skip-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
10 changes: 8 additions & 2 deletions scripts/template/src/{{kebabCase name}}.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
/**
Expand Down Expand Up @@ -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}}

Expand Down

0 comments on commit 1e07832

Please sign in to comment.