@streamscloud/embeddable 2.0.4 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,4 +25,7 @@ export type { IShortVideosPlayerLocalization };
25
25
  export declare const openShortVideosPlayer: (init: {
26
26
  shortVideosProvider: PlayerItemsProvider<ShortVideoViewerModel>;
27
27
  localization?: IShortVideosPlayerLocalization;
28
+ on?: {
29
+ playerClosed?: () => void;
30
+ };
28
31
  }) => void;
@@ -23,7 +23,7 @@ import { mount } from 'svelte';
23
23
  */
24
24
  export const openShortVideosPlayer = (init) => {
25
25
  const { shortVideosProvider, localization } = init;
26
- const shadowHost = new ShadowHost();
26
+ const shadowHost = new ShadowHost({ onClosed: () => init.on?.playerClosed?.() });
27
27
  mount(ShortVideosPlayer, {
28
28
  target: shadowHost.shadowRoot,
29
29
  props: {
@@ -32,5 +32,6 @@ export declare const openStreamPlayer: (init: {
32
32
  title: string;
33
33
  image: string | null;
34
34
  }) => void;
35
+ playerClosed?: () => void;
35
36
  };
36
37
  }) => void;
@@ -27,7 +27,7 @@ import { mount } from 'svelte';
27
27
  */
28
28
  export const openStreamPlayer = (init) => {
29
29
  const { streamId, graphqlUrl, localization } = init;
30
- const shadowHost = new ShadowHost();
30
+ const shadowHost = new ShadowHost({ onClosed: () => init.on?.playerClosed?.() });
31
31
  mount(StreamPlayer, {
32
32
  target: shadowHost.shadowRoot,
33
33
  props: {
@@ -35,7 +35,7 @@ export const openStreamPlayer = (init) => {
35
35
  graphql: createLocalGQLClient(graphqlUrl),
36
36
  localization,
37
37
  on: {
38
- streamActivated: data => {
38
+ streamActivated: (data) => {
39
39
  if (init.on?.streamActivated) {
40
40
  init.on.streamActivated({ title: data.title, image: data.image });
41
41
  }
@@ -1,7 +1,10 @@
1
1
  export declare class ShadowHost {
2
2
  shadowRoot: ShadowRoot;
3
3
  private host;
4
- constructor();
4
+ private callbacks;
5
+ constructor(init: {
6
+ onClosed: () => void;
7
+ });
5
8
  attachToBody(): void;
6
9
  remove(): void;
7
10
  private handleEsc;
@@ -3,7 +3,11 @@ import reset from './_reset.scss?raw';
3
3
  export class ShadowHost {
4
4
  shadowRoot;
5
5
  host;
6
- constructor() {
6
+ callbacks;
7
+ constructor(init) {
8
+ this.callbacks = {
9
+ onClosed: init.onClosed
10
+ };
7
11
  const host = document.createElement('div');
8
12
  host.style.all = 'unset';
9
13
  host.style.position = 'fixed';
@@ -30,6 +34,7 @@ export class ShadowHost {
30
34
  this.host.remove();
31
35
  document.getElementsByTagName('html')[0].style.overflow = '';
32
36
  document.removeEventListener('keydown', this.handleEsc);
37
+ this.callbacks.onClosed();
33
38
  }
34
39
  handleEsc = (event) => {
35
40
  if (event.key === 'Escape' || event.key === 'Esc') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/embeddable",
3
- "version": "2.0.4",
3
+ "version": "2.1.0",
4
4
  "author": "StreamsCloud",
5
5
  "repository": "https://github.com/StreamsCloud/streamscloud-frontend-packages.git",
6
6
  "type": "module",