diff --git a/package.json b/package.json index 8fca0bc..ffcdde7 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "prettier:fix": "prettier --write ." }, "devDependencies": { - "@playkit-js/kaltura-player-js": "^3.14.3-canary.0-99a98cb", + "@playkit-js/kaltura-player-js": "3.17.5", "conventional-github-releaser": "3.1.3", "cross-env": "^7.0.3", "css-loader": "^6.7.1", diff --git a/src/playlist.tsx b/src/playlist.tsx index 4d5f5b3..c828e58 100755 --- a/src/playlist.tsx +++ b/src/playlist.tsx @@ -7,18 +7,21 @@ import {PluginButton} from './components/plugin-button'; import {PlaylistWrapper} from './components/playlist-wrapper'; import {DataManager} from './data-manager'; import {icons} from './components/icons'; -import { pluginName } from "./index"; -import {PlaylistEvents} from './events/events' +import {pluginName} from './index'; +import {PlaylistEvents} from './events/events'; const {SidePanelModes, SidePanelPositions, ReservedPresetNames} = ui; +const {PLAYER_SIZE} = ui.Components; export class Playlist extends KalturaPlayer.core.BasePlugin { private _player: KalturaPlayerTypes.Player; private _playlistPanel = -1; private _playlistIcon = -1; + private _loaded = false; private _pluginState: PluginStates | null = null; private _dataManager: DataManager; private _offlineSlateActive = false; + private pluginMode: PluginPositions | null = null; private _activePresetName = ''; private _unsubscribeStore: Function = () => {}; private _triggeredByKeyboard = false; @@ -49,6 +52,7 @@ export class Playlist extends KalturaPlayer.core.BasePlugin { } else if (this._activePresetName === '') { this._activePresetName = state.shell.activePresetName; } + this._addSidePanel(); }); } @@ -66,10 +70,45 @@ export class Playlist extends KalturaPlayer.core.BasePlugin { return; } - const pluginMode: PluginPositions = [SidePanelPositions.RIGHT, SidePanelPositions.LEFT].includes(this.config.position) - ? PluginPositions.VERTICAL - : PluginPositions.HORIZONTAL; - // add side panel + this._loaded = true; + this._addSidePanel(); + // add plugin button + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + this._playlistIcon = this.upperBarManager!.add({ + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + ariaLabel: 'Playlist', + displayName: 'Playlist', + svgIcon: {path: icons.PLUGIN_ICON}, + onClick: this._handleClickOnPluginIcon, + component: () => { + return ; + } + }) as number; + + if ((this.config.expandOnFirstPlay && !this._pluginState) || this._pluginState === PluginStates.OPENED) { + this._activatePlugin(true); + } + } + + private _addSidePanel() { + if (!this._loaded) { + return; + } + + const pluginMode = + [SidePanelPositions.RIGHT, SidePanelPositions.LEFT].includes(this.config.position) || + [PLAYER_SIZE?.SMALL, PLAYER_SIZE?.EXTRA_SMALL, PLAYER_SIZE?.TINY].includes(this._player.ui.store.getState().shell.playerSize) + ? PluginPositions.VERTICAL + : PluginPositions.HORIZONTAL; + + if (this.pluginMode === pluginMode) { + return; + } + this.pluginMode = pluginMode; + const isPluginActive = this._isPluginActive(); + this._playlistPanel = this.sidePanelsManager!.add({ label: 'Playlist', panelComponent: () => { @@ -89,22 +128,7 @@ export class Playlist extends KalturaPlayer.core.BasePlugin { expandMode: this.config.expandMode === SidePanelModes.ALONGSIDE ? SidePanelModes.ALONGSIDE : SidePanelModes.OVER }) as number; - // add plugin button - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - this._playlistIcon = this.upperBarManager!.add({ - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - ariaLabel: 'Playlist', - displayName: 'Playlist', - svgIcon: {path: icons.PLUGIN_ICON}, - onClick: this._handleClickOnPluginIcon, - component: () => { - return ; - } - }) as number; - - if ((this.config.expandOnFirstPlay && !this._pluginState) || this._pluginState === PluginStates.OPENED) { + if (isPluginActive) { this._activatePlugin(true); } } @@ -154,7 +178,7 @@ export class Playlist extends KalturaPlayer.core.BasePlugin { this.sidePanelsManager?.activateItem(this._playlistPanel); this._pluginState === PluginStates.OPENED; this.upperBarManager?.update(this._playlistIcon); - this.dispatchEvent(PlaylistEvents.PLAYLIST_OPEN, {position: this.config.position, auto: isFirstOpen}) + this.dispatchEvent(PlaylistEvents.PLAYLIST_OPEN, {position: this.config.position, auto: isFirstOpen}); }); }; @@ -164,7 +188,7 @@ export class Playlist extends KalturaPlayer.core.BasePlugin { this.sidePanelsManager?.deactivateItem(this._playlistPanel); this._pluginState = PluginStates.CLOSED; this.upperBarManager?.update(this._playlistIcon); - this.dispatchEvent(PlaylistEvents.PLAYLIST_CLOSE, {position: this.config.position}) + this.dispatchEvent(PlaylistEvents.PLAYLIST_CLOSE, {position: this.config.position}); }); }; @@ -178,6 +202,7 @@ export class Playlist extends KalturaPlayer.core.BasePlugin { this.eventManager.removeAll(); this._playlistPanel = -1; this._playlistIcon = -1; + this._loaded = false; this._pluginButtonRef = null; this._pluginState = null; this._triggeredByKeyboard = false; diff --git a/yarn.lock b/yarn.lock index 10ca117..91cd34d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -23,14 +23,6 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/polyfill@^7.0.0": - version "7.12.1" - resolved "https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.12.1.tgz#1f2d6371d1261bbd961f3c5d5909150e12d0bd96" - integrity sha512-X0pi0V6gxLi6lFZpGmeNa4zxtwEmCs42isWLNjZZDE0Y8yVfgu0T2OAHlzBbdYlqbW/YXVvoBHpATEM+goCj8g== - dependencies: - core-js "^2.6.5" - regenerator-runtime "^0.13.4" - "@babel/runtime@^7.15.4", "@babel/runtime@^7.9.2": version "7.18.3" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.18.3.tgz#c7b654b57f6f63cf7f8b418ac9ca04408c4579f4" @@ -139,52 +131,51 @@ classnames "^2.3.2" linkify-it "^4.0.1" -"@playkit-js/kaltura-player-js@^3.14.3-canary.0-99a98cb": - version "3.14.3-canary.0-99a98cb" - resolved "https://registry.yarnpkg.com/@playkit-js/kaltura-player-js/-/kaltura-player-js-3.14.3-canary.0-99a98cb.tgz#6b81a7722fc45515a0d82fc6577ecc19a291c5ae" - integrity sha512-UaSi5mGNEc8baLDXMTnVXuWTi/cpC38yIxhhwvVc9FQR/jOznDAA9+IuFTlfNBSDEnkApUqvR0ihC7h9Y+wkSg== - dependencies: - "@babel/polyfill" "^7.0.0" - "@playkit-js/playkit-js" "^0.82.3-canary.0-60212bf" - "@playkit-js/playkit-js-dash" "^1.34.2-canary.0-73343bc" - "@playkit-js/playkit-js-hls" "^1.32.4-canary.0-cb687d0" - "@playkit-js/playkit-js-providers" "^2.39.3-canary.0-edd6027" - "@playkit-js/playkit-js-ui" "^0.77.2-canary.0-32f0182" +"@playkit-js/kaltura-player-js@3.17.5": + version "3.17.5" + resolved "https://registry.yarnpkg.com/@playkit-js/kaltura-player-js/-/kaltura-player-js-3.17.5.tgz#fbe028041194bffa784aa74c319c2ed73514dc6d" + integrity sha512-QSdfrU7qrjg2rVwRFCWEz9i5Ecmar6V0xsEqpuTjdIIsIptMixFHkRqKIpdR6Ssy3WwtzS+6GKXEeb4LEYq7FQ== + dependencies: + "@playkit-js/playkit-js" "0.84.1" + "@playkit-js/playkit-js-dash" "1.36.0" + "@playkit-js/playkit-js-hls" "1.32.9" + "@playkit-js/playkit-js-providers" "2.40.1" + "@playkit-js/playkit-js-ui" "0.77.13" "@types/preact-i18n" "^2.3.1" - hls.js "1.3.5" + hls.js "1.4.11" intersection-observer "^0.12.0" proxy-polyfill "^0.3.0" - shaka-player "4.3.5" + shaka-player "4.7.0" -"@playkit-js/playkit-js-dash@^1.34.2-canary.0-73343bc": - version "1.34.2-canary.0-73343bc" - resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js-dash/-/playkit-js-dash-1.34.2-canary.0-73343bc.tgz#a37969272bda94204ff819a801467af380c6b955" - integrity sha512-bR9JcXcdEsEALSlzh3s66Ip6wcwkGUb2JbpAyg+nB7+1DCY75C4gnxaZshIWijBs+fV/IozuoIZFvR2WRE9BcA== +"@playkit-js/playkit-js-dash@1.36.0": + version "1.36.0" + resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js-dash/-/playkit-js-dash-1.36.0.tgz#7231bf49fbffd2c606d4ed96adbcd209e4099974" + integrity sha512-3OBETIHwWoh9KRxBZAdVmhxkh7AzX05U37hSYmZt6IWgIjlXwIOhcVntkP2tGLvVMB9bF+Jw+5/TY1RyF5N05w== -"@playkit-js/playkit-js-hls@^1.32.4-canary.0-cb687d0": - version "1.32.4-canary.0-cb687d0" - resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js-hls/-/playkit-js-hls-1.32.4-canary.0-cb687d0.tgz#9d84ca8e310ec0c18bfad43b190fe486b92f0767" - integrity sha512-N7DX8BbgpI+IO4MEJS5C6ZcCm0fhaF++F3eZw/J9VtCsY8QE3ptBklNcgOpJb4OdpSBjs2EymJ/Fd/emRHZn8g== +"@playkit-js/playkit-js-hls@1.32.9": + version "1.32.9" + resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js-hls/-/playkit-js-hls-1.32.9.tgz#71d43b4d8f4df480d4183af1c4f335bb94e7c5c3" + integrity sha512-15MWDlJaGHpfvQWanDPcnUaKPbtq5mxeld58GbIHk+/6h+9JFu7ho208p3mL03C5M4qQG6nkE3d0PtO5VZEEgQ== -"@playkit-js/playkit-js-providers@^2.39.3-canary.0-edd6027": - version "2.39.3-canary.0-edd6027" - resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js-providers/-/playkit-js-providers-2.39.3-canary.0-edd6027.tgz#61d464590cb15981b9f8febdfe93156dac269a0f" - integrity sha512-qOfHROzAGs4m0JMdNWifvkM5SkKmdwPySOp4XwRzHadnE8eWSoe2y1q1OZup7FsBpslTLAD42FPTPi8Lj9DpkA== +"@playkit-js/playkit-js-providers@2.40.1": + version "2.40.1" + resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js-providers/-/playkit-js-providers-2.40.1.tgz#d2805d72ce3c53b446c44d5a023d6bad04207a86" + integrity sha512-PkM3Uw+H0KXrlUM/qqN4Mxp3lhC8WYbyNdYJ1EsAyn536sBKFjGXALQJ3wxpFerILY0oZoKcM+TjNMsKcOOM1A== -"@playkit-js/playkit-js-ui@^0.77.1": - version "0.77.1" - resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js-ui/-/playkit-js-ui-0.77.1.tgz#1bb76f5ca8dd1ed3fd389cce818e2f454d3897a0" - integrity sha512-4ReI5oAmzUGkAKwRoRO+oy0fzpG+cgXOvGkWgZ/rjObjL2bpBIkHdmgTlAHsvrdKbBUfJThqdQwPsu8FkoQyVA== +"@playkit-js/playkit-js-ui@0.77.13": + version "0.77.13" + resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js-ui/-/playkit-js-ui-0.77.13.tgz#e88543055d98d08a07267e546f623f68878f5af2" + integrity sha512-NAbOWpfGLPtZU5IEegN6ps8AEfEyuGSyMe6dHnf8U7vPSbZu8RsESezlY7kSxusRubsS8jnx3kC5MHSx8vrDVg== dependencies: preact "^10.3.4" preact-i18n "^2.0.0-preactx.2" react-redux "^7.2.0" redux "^4.0.5" -"@playkit-js/playkit-js-ui@^0.77.2-canary.0-32f0182": - version "0.77.2-canary.0-ee0e6eb" - resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js-ui/-/playkit-js-ui-0.77.2-canary.0-ee0e6eb.tgz#e39ca4c16b8588e58d72b919092dff9f01900ef5" - integrity sha512-5uA7W1mhi7YGoZY7NhDr9WgXNxVmQOz0BON8WJIbBKGBtDQAERxefIUFQIK7jvBsH8Y4G0F0wcGbzovPOGLAbw== +"@playkit-js/playkit-js-ui@^0.77.1": + version "0.77.1" + resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js-ui/-/playkit-js-ui-0.77.1.tgz#1bb76f5ca8dd1ed3fd389cce818e2f454d3897a0" + integrity sha512-4ReI5oAmzUGkAKwRoRO+oy0fzpG+cgXOvGkWgZ/rjObjL2bpBIkHdmgTlAHsvrdKbBUfJThqdQwPsu8FkoQyVA== dependencies: preact "^10.3.4" preact-i18n "^2.0.0-preactx.2" @@ -201,10 +192,10 @@ react-redux "^7.2.0" redux "^4.0.5" -"@playkit-js/playkit-js@^0.82.3-canary.0-60212bf": - version "0.82.3-canary.0-f0d3180" - resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js/-/playkit-js-0.82.3-canary.0-f0d3180.tgz#bd976cf382a38797a6c025d6bf654a62b1a8c086" - integrity sha512-3co6fH/2F3uOkxC1+3Of40fubl7qwzPa5zGwa8QSczwwNFnoovHVXi1MnNsTSvKmt7FJxFS+Lw+SzVknhSZhZA== +"@playkit-js/playkit-js@0.84.1": + version "0.84.1" + resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js/-/playkit-js-0.84.1.tgz#7fa443b167434e9e9b10e52668fbc44de0a343dd" + integrity sha512-b/I2cmOMWGDNfVCoWU2ezbPLP34Nfs71iVIBKJsiZGiPr8MmNi4uWKJefZeO8/N1wTRKGly9A0AMHxvDcA+KLg== dependencies: js-logger "^1.6.0" ua-parser-js "1.0.2" @@ -337,9 +328,9 @@ integrity sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw== "@types/preact-i18n@^2.3.1": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@types/preact-i18n/-/preact-i18n-2.3.2.tgz#7b5a31e1c84ead424e8c6ed3d57a02487d430fc7" - integrity sha512-j1J/f9yzds7X3RP7oIO5wL+owXJyULv0qRWcX/eVGP/Ojw8SdTjXAi722vv2Iv5GtMgshVCS1QEQFJRT8/qwHQ== + version "2.3.6" + resolved "https://registry.yarnpkg.com/@types/preact-i18n/-/preact-i18n-2.3.6.tgz#c5134dbe0e53b32fe22b725a341e823becc1cc3f" + integrity sha512-6gyB46Yc7y3nYqD+n1g3dLVwyY/+1pAHR4N9Mq3USfxZfO5pW1XFeayuB6NdX96BQ3rYoiOQv8qtPXnmCdyljA== dependencies: preact "^10.0.0" @@ -1539,11 +1530,6 @@ copy-concurrently@^1.0.0: rimraf "^2.5.4" run-queue "^1.0.0" -core-js@^2.6.5: - version "2.6.12" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" - integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== - core-util-is@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -2527,10 +2513,10 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" -hls.js@1.3.5: - version "1.3.5" - resolved "https://registry.yarnpkg.com/hls.js/-/hls.js-1.3.5.tgz#0e8b0799ecf2feb7ba199f5e95f35ba9552e04f4" - integrity sha512-uybAvKS6uDe0MnWNEPnO0krWVr+8m2R0hJ/viql8H3MVK+itq8gGQuIYoFHL3rECkIpNH98Lw8YuuWMKZxp3Ew== +hls.js@1.4.11: + version "1.4.11" + resolved "https://registry.yarnpkg.com/hls.js/-/hls.js-1.4.11.tgz#6ca2d7ab56f2725f27bb5f2e3c7982c6ec287118" + integrity sha512-rhPSUMACcIBbcUnwWnIcRgGXqJJt0xBRxvhzl99XpGHtnnLKjbczmmBmUuQueAQcbL3SdN7D5peAObR18VrhvQ== hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2: version "3.3.2" @@ -3937,9 +3923,9 @@ preact-i18n@^2.0.0-preactx.2: dlv "^1.1.2" preact@^10.0.0: - version "10.14.0" - resolved "https://registry.yarnpkg.com/preact/-/preact-10.14.0.tgz#7353812c33ae79c1fa91bfd792db030a90565da3" - integrity sha512-4oh2sf208mKAdL5AQtzXxE387iSGNWMX/YjwMjH6m/XROILKAmx5Pbs2FsXrW7ixoVGGjpfYSBB833vOwYxNxw== + version "10.19.6" + resolved "https://registry.yarnpkg.com/preact/-/preact-10.19.6.tgz#66007b67aad4d11899f583df1b0116d94a89b8f5" + integrity sha512-gympg+T2Z1fG1unB8NH29yHJwnEaCH37Z32diPDku316OTnRPeMbiRV9kTrfZpocXjdfnWuFUl/Mj4BHaf6gnw== preact@^10.3.4: version "10.8.1" @@ -4527,10 +4513,10 @@ setprototypeof@1.2.0: resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== -shaka-player@4.3.5: - version "4.3.5" - resolved "https://registry.yarnpkg.com/shaka-player/-/shaka-player-4.3.5.tgz#304d60ad867fb7a0780b850b32a9614296b842db" - integrity sha512-WkqvHm8QHOsQ71d/qoc2Wa6Z5rBrG3Zgsc6ho9I9e8Xwa0io+MeREgqBuG0z6qoXK55sTImipFhDoERrkmDdUg== +shaka-player@4.7.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/shaka-player/-/shaka-player-4.7.0.tgz#5bb0a60c1b7c2a8a3c2d1ff82e632c3c000219c3" + integrity sha512-utR9hKMt8GiGv7EDC8/nh8F1c4KeVGa4Wd8k6h+g2Ylks0m9//kvxvXkQnYAGJRtdql/CJC9Ur8YQ/G+kTwoiQ== dependencies: eme-encryption-scheme-polyfill "^2.1.1"