@streamscloud/embeddable 2.9.0 → 3.0.1

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.
@@ -1,3 +1,3 @@
1
- export declare const createLocalGQLClient: (graphqlOrigin?: string, customFetch?: typeof fetch) => import("@urql/core").Client;
1
+ export declare const createLocalGQLClient: (graphqlOrigin?: string, headers?: HeadersInit, customFetch?: typeof fetch) => import("@urql/core").Client;
2
2
  export declare const resolveGraphQLOrigin: (origin?: string) => string;
3
3
  export declare const constructGraphQLUrl: (graphqlOrigin?: string) => string;
@@ -1,9 +1,10 @@
1
1
  import { createClient, fetchExchange } from '@urql/core';
2
- export const createLocalGQLClient = (graphqlOrigin, customFetch) => createClient({
2
+ export const createLocalGQLClient = (graphqlOrigin, headers, customFetch) => createClient({
3
3
  url: constructGraphQLUrl(resolveGraphQLOrigin(graphqlOrigin)),
4
4
  requestPolicy: 'network-only',
5
5
  fetchOptions: {
6
- credentials: 'include'
6
+ credentials: 'include',
7
+ headers: headers
7
8
  },
8
9
  fetch: customFetch || fetch,
9
10
  exchanges: [fetchExchange]
@@ -35,7 +35,7 @@ const initBuffer = (input) => __awaiter(void 0, void 0, void 0, function* () {
35
35
  var _a, _b;
36
36
  try {
37
37
  const { graphqlOrigin, ids, initialId } = input;
38
- const graphql = createLocalGQLClient(graphqlOrigin);
38
+ const graphql = createLocalGQLClient(graphqlOrigin, { 'x-initiator': input.initiator || 'player/short-videos' });
39
39
  const payload = yield graphql
40
40
  .query(GetShortVideosDocument, {
41
41
  input: {
@@ -80,7 +80,8 @@ export const openShortVideosPlayer = async (init) => {
80
80
  type: 'ids',
81
81
  ids: init.ids,
82
82
  initialId: init.initialId,
83
- graphqlOrigin: init.graphqlOrigin
83
+ graphqlOrigin: init.graphqlOrigin,
84
+ initiator: init.initiator
84
85
  };
85
86
  }
86
87
  else {
@@ -11,6 +11,7 @@ export type IdsPlayerInput = {
11
11
  ids: string[];
12
12
  initialId?: string;
13
13
  graphqlOrigin?: string;
14
+ initiator?: string;
14
15
  };
15
16
  export type OpenShortVideosPlayerInit = ProviderInit | IdsInit;
16
17
  type ProviderInit = {
@@ -25,6 +26,7 @@ type IdsInit = {
25
26
  graphqlOrigin?: string;
26
27
  initialId?: string;
27
28
  localization?: IShortVideosPlayerLocalization | 'en' | 'no';
29
+ initiator?: string;
28
30
  on?: {
29
31
  playerClosed?: () => void;
30
32
  };
@@ -27,7 +27,7 @@ import { StreamPlayerLocalization } from './stream-player-localization';
27
27
  import { StreamPlayerUiManager } from './ui-manager.svelte';
28
28
  import { AppEventsTracker } from '@streamscloud/streams-analytics-collector';
29
29
  import { onMount } from 'svelte';
30
- let { streamId, graphqlOrigin, localization: localizationInit, showStreamsCloudWatermark, on } = $props();
30
+ let { streamId, graphqlOrigin, localization: localizationInit, showStreamsCloudWatermark, initiator, on } = $props();
31
31
  const localization = $derived(new StreamPlayerLocalization(localizationInit));
32
32
  let model = $state(null);
33
33
  let buffer = $state.raw(null);
@@ -56,7 +56,7 @@ onMount(() => __awaiter(void 0, void 0, void 0, function* () {
56
56
  var _a, _b, _c, _d;
57
57
  uiManager.overviewCollapsed = window && window.innerWidth < window.innerHeight;
58
58
  try {
59
- const graphql = createLocalGQLClient(graphqlOrigin);
59
+ const graphql = createLocalGQLClient(graphqlOrigin, { 'x-initiator': initiator !== null && initiator !== void 0 ? initiator : 'player/stream' });
60
60
  const streamPayload = yield graphql.query(GetStreamDocument, { id: streamId }).toPromise();
61
61
  if (!((_a = streamPayload.data) === null || _a === void 0 ? void 0 : _a.stream)) {
62
62
  toastrWarning(localization.streamNotFound);
@@ -5,6 +5,7 @@ type Props = {
5
5
  localization: IStreamPlayerLocalization | Locale;
6
6
  graphqlOrigin?: string;
7
7
  showStreamsCloudWatermark?: boolean;
8
+ initiator?: string;
8
9
  on?: {
9
10
  closePlayer?: () => void;
10
11
  streamActivated?: (data: {
@@ -28,6 +28,7 @@ export declare const openStreamPlayer: (init: {
28
28
  graphqlOrigin?: string;
29
29
  localization?: IStreamPlayerLocalization | "en" | "no";
30
30
  showStreamsCloudWatermark?: boolean;
31
+ initiator?: string;
31
32
  on?: {
32
33
  streamActivated?: (data: {
33
34
  title: string;
@@ -27,7 +27,7 @@ import { mount, unmount } from 'svelte';
27
27
  * ```
28
28
  */
29
29
  export const openStreamPlayer = (init) => {
30
- const { streamId, graphqlOrigin, localization, showStreamsCloudWatermark } = init;
30
+ const { streamId, graphqlOrigin, localization, showStreamsCloudWatermark, initiator } = init;
31
31
  const shadowHost = new ShadowHost();
32
32
  const mounted = mount(StreamPlayer, {
33
33
  target: shadowHost.shadowRoot,
@@ -36,6 +36,7 @@ export const openStreamPlayer = (init) => {
36
36
  graphqlOrigin,
37
37
  localization: getLocale(localization),
38
38
  showStreamsCloudWatermark,
39
+ initiator,
39
40
  on: {
40
41
  streamActivated: (data) => {
41
42
  AppEventsTracker.setOrganizationId(data.ownerId);
@@ -1,12 +1,12 @@
1
1
  query GetStream($id: String!) {
2
- stream:embedStream(input: { id: $id }) {
2
+ stream: embedStream(input: { id: $id }) {
3
3
  ...StreamPlayerPayloadFragment
4
4
  }
5
5
  }
6
6
 
7
7
  # noinspection GraphQLSchemaValidation
8
8
  query GetStreamPages($input: EmbedStreamPagesInput!, $image_scale: ImageScale!) {
9
- streamPages:embedStreamPages(input: $input) {
9
+ streamPages: embedStreamPages(input: $input) {
10
10
  items {
11
11
  ...StreamPageViewerPayloadFragment
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/embeddable",
3
- "version": "2.9.0",
3
+ "version": "3.0.1",
4
4
  "author": "StreamsCloud",
5
5
  "repository": "https://github.com/StreamsCloud/streamscloud-frontend-packages.git",
6
6
  "type": "module",