@streamscloud/embeddable 2.3.1 → 2.4.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.
@@ -1,2 +1,4 @@
1
- export declare const createLocalGQLClient: (graphqlUrl?: string, customFetch?: typeof fetch) => import("@urql/core").Client;
2
- export declare const resolveGraphQLUrl: (url?: string) => string;
1
+ export declare const createLocalGQLClient: (graphqlOrigin?: string, customFetch?: typeof fetch) => import("@urql/core").Client;
2
+ export declare const resolveGraphQLOrigin: (origin?: string) => string;
3
+ export declare const constructCoreGraphQLUrl: (graphqlOrigin?: string) => string;
4
+ export declare const constructExternalGraphQLUrl: (graphqlOrigin?: string) => string;
@@ -1,6 +1,6 @@
1
1
  import { createClient, fetchExchange } from '@urql/core';
2
- export const createLocalGQLClient = (graphqlUrl, customFetch) => createClient({
3
- url: resolveGraphQLUrl(graphqlUrl),
2
+ export const createLocalGQLClient = (graphqlOrigin, customFetch) => createClient({
3
+ url: constructCoreGraphQLUrl(resolveGraphQLOrigin(graphqlOrigin)),
4
4
  requestPolicy: 'network-only',
5
5
  fetchOptions: {
6
6
  credentials: 'include'
@@ -8,6 +8,16 @@ export const createLocalGQLClient = (graphqlUrl, customFetch) => createClient({
8
8
  fetch: customFetch || fetch,
9
9
  exchanges: [fetchExchange]
10
10
  });
11
- export const resolveGraphQLUrl = (url) => {
12
- return url || 'https://api.streamscloud.com/graphql';
11
+ export const resolveGraphQLOrigin = (origin) => {
12
+ return origin || 'https://api.streamscloud.com';
13
+ };
14
+ export const constructCoreGraphQLUrl = (graphqlOrigin) => {
15
+ let baseUrl = resolveGraphQLOrigin(graphqlOrigin);
16
+ baseUrl = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
17
+ return `${baseUrl}graphql`;
18
+ };
19
+ export const constructExternalGraphQLUrl = (graphqlOrigin) => {
20
+ let baseUrl = resolveGraphQLOrigin(graphqlOrigin);
21
+ baseUrl = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
22
+ return `${baseUrl}external/graphql`;
13
23
  };
@@ -10,12 +10,12 @@
10
10
  import { handleEsc } from '../../core/document.event-handlers';
11
11
  import { createLocalGQLClient } from '../../core/graphql';
12
12
  import { mapShortVideoViewerModel, ShortVideoViewer } from '../short-video-viewer';
13
- import { GetShortVideosDocument } from './operations.generated';
14
13
  import { Loading } from '../../ui/loading';
15
14
  import { PlayerBuffer, PlayerSlider } from '../../ui/player';
16
15
  import { SpotlightLayout } from '../../ui/spotlight-layout';
17
16
  import { SwipeIndicator } from '../../ui/swipe-indicator';
18
17
  import { default as Controls } from './controls.svelte';
18
+ import { GetShortVideosDocument } from './operations.generated';
19
19
  import { ShortVideosPlayerLocalization } from './short-videos-player-localization.svelte';
20
20
  import { ShortVideosPlayerUiManager } from './ui-manager.svelte';
21
21
  import { onMount, untrack } from 'svelte';
@@ -24,8 +24,9 @@ const localization = $derived(new ShortVideosPlayerLocalization(localizationInit
24
24
  let everTouched = $state(false);
25
25
  let buffer = $state(input.type === 'provider' ? new PlayerBuffer(input.provider) : null);
26
26
  $effect(() => {
27
- if (input.type !== 'ids')
27
+ if (input.type !== 'ids') {
28
28
  return;
29
+ }
29
30
  untrack(() => {
30
31
  initBuffer(input);
31
32
  });
@@ -33,8 +34,8 @@ $effect(() => {
33
34
  const initBuffer = (input) => __awaiter(void 0, void 0, void 0, function* () {
34
35
  var _a, _b;
35
36
  try {
36
- const { graphqlUrl, ids, initialId } = input;
37
- const graphql = createLocalGQLClient(graphqlUrl);
37
+ const { graphqlOrigin, ids, initialId } = input;
38
+ const graphql = createLocalGQLClient(graphqlOrigin);
38
39
  const payload = yield graphql
39
40
  .query(GetShortVideosDocument, {
40
41
  input: {
@@ -1,5 +1,5 @@
1
- import type { PlayerInput } from './types';
2
1
  import { type IShortVideosPlayerLocalization } from './short-videos-player-localization.svelte';
2
+ import type { PlayerInput } from './types';
3
3
  type Props = {
4
4
  input: PlayerInput;
5
5
  localization?: IShortVideosPlayerLocalization;
@@ -1,5 +1,5 @@
1
- import { type OpenShortVideosPlayerInit } from './types';
2
1
  import type { IShortVideosPlayerLocalization } from './short-videos-player-localization.svelte';
2
+ import { type OpenShortVideosPlayerInit } from './types';
3
3
  export type { IShortVideosPlayerLocalization };
4
4
  /**
5
5
  * Opens the short videos player modal with the specified provider or by fetching videos by IDs.
@@ -51,7 +51,7 @@ export type { IShortVideosPlayerLocalization };
51
51
  *
52
52
  * openShortVideosPlayer({
53
53
  * ids: ['id1', 'id2', 'id3'],
54
- * graphqlUrl: 'https://api.example.com/graphql',
54
+ * graphqlOrigin: 'https://api.example.com',
55
55
  * initialId: 'id2',
56
56
  * localization: {
57
57
  * next: 'Next',
@@ -1,7 +1,7 @@
1
- import { isIdsInit, isShortVideosProviderInit } from './types';
2
1
  import { ShadowHost } from '../../ui/shadow-dom';
3
- import { mount, unmount } from 'svelte';
4
2
  import { default as ShortVideosPlayer } from './cmp.short-videos-player.svelte';
3
+ import { isIdsInit, isShortVideosProviderInit } from './types';
4
+ import { mount, unmount } from 'svelte';
5
5
  /**
6
6
  * Opens the short videos player modal with the specified provider or by fetching videos by IDs.
7
7
  *
@@ -52,7 +52,7 @@ import { default as ShortVideosPlayer } from './cmp.short-videos-player.svelte';
52
52
  *
53
53
  * openShortVideosPlayer({
54
54
  * ids: ['id1', 'id2', 'id3'],
55
- * graphqlUrl: 'https://api.example.com/graphql',
55
+ * graphqlOrigin: 'https://api.example.com',
56
56
  * initialId: 'id2',
57
57
  * localization: {
58
58
  * next: 'Next',
@@ -79,7 +79,7 @@ export const openShortVideosPlayer = async (init) => {
79
79
  type: 'ids',
80
80
  ids: init.ids,
81
81
  initialId: init.initialId,
82
- graphqlUrl: init.graphqlUrl
82
+ graphqlOrigin: init.graphqlOrigin
83
83
  };
84
84
  }
85
85
  else {
@@ -1,6 +1,6 @@
1
1
  import type { ShortVideoViewerModel } from '../..';
2
- import type { IShortVideosPlayerLocalization } from './short-videos-player-localization.svelte';
3
2
  import type { PlayerItemsProvider } from '../../ui/player';
3
+ import type { IShortVideosPlayerLocalization } from './short-videos-player-localization.svelte';
4
4
  export type PlayerInput = ProviderPlayerInput | IdsPlayerInput;
5
5
  export type ProviderPlayerInput = {
6
6
  type: 'provider';
@@ -10,7 +10,7 @@ export type IdsPlayerInput = {
10
10
  type: 'ids';
11
11
  ids: string[];
12
12
  initialId?: string;
13
- graphqlUrl?: string;
13
+ graphqlOrigin?: string;
14
14
  };
15
15
  export type OpenShortVideosPlayerInit = ProviderInit | IdsInit;
16
16
  type ProviderInit = {
@@ -22,7 +22,7 @@ type ProviderInit = {
22
22
  };
23
23
  type IdsInit = {
24
24
  ids: string[];
25
- graphqlUrl?: string;
25
+ graphqlOrigin?: string;
26
26
  initialId?: string;
27
27
  localization?: IShortVideosPlayerLocalization;
28
28
  on?: {
@@ -9,7 +9,7 @@
9
9
  };
10
10
  import { getOrCreateProfileId } from '../../core/analytics.profile-id';
11
11
  import { handleEsc } from '../../core/document.event-handlers';
12
- import { createLocalGQLClient, resolveGraphQLUrl } from '../../core/graphql';
12
+ import { constructExternalGraphQLUrl, createLocalGQLClient } from '../../core/graphql';
13
13
  import { toastrWarning } from '../../core/toastr';
14
14
  import { ShortVideoViewer } from '../../short-videos/short-video-viewer';
15
15
  import { mapToShortVideoViewerModel } from '../layout/models';
@@ -25,9 +25,9 @@ import { default as Overview } from './stream-overview.svelte';
25
25
  import { StreamPlayerBuffer } from './stream-player-buffer.svelte';
26
26
  import { StreamPlayerLocalization } from './stream-player-localization.svelte';
27
27
  import { StreamPlayerUiManager } from './ui-manager.svelte';
28
- import { onMount } from 'svelte';
29
28
  import { AppEventsTracker } from '@streamscloud/streams-analytics-collector';
30
- let { streamId, graphqlUrl, localization: localizationInit, on } = $props();
29
+ import { onMount } from 'svelte';
30
+ let { streamId, graphqlOrigin, localization: localizationInit, on } = $props();
31
31
  const localization = $derived(new StreamPlayerLocalization(localizationInit));
32
32
  let model = $state(null);
33
33
  let buffer = $state.raw(null);
@@ -56,14 +56,14 @@ 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(graphqlUrl);
59
+ const graphql = createLocalGQLClient(graphqlOrigin);
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);
63
63
  (_b = on === null || on === void 0 ? void 0 : on.closePlayer) === null || _b === void 0 ? void 0 : _b.call(on);
64
64
  return;
65
65
  }
66
- AppEventsTracker.setEndpoint(resolveGraphQLUrl(graphqlUrl));
66
+ AppEventsTracker.setEndpoint(constructExternalGraphQLUrl(graphqlOrigin));
67
67
  AppEventsTracker.setProfileId(getOrCreateProfileId());
68
68
  (_c = on === null || on === void 0 ? void 0 : on.streamActivated) === null || _c === void 0 ? void 0 : _c.call(on, {
69
69
  ownerId: streamPayload.data.stream.ownerProfile.id,
@@ -2,7 +2,7 @@ import { type IStreamPlayerLocalization } from './stream-player-localization.sve
2
2
  type Props = {
3
3
  streamId: string;
4
4
  localization?: IStreamPlayerLocalization;
5
- graphqlUrl?: string;
5
+ graphqlOrigin?: string;
6
6
  on?: {
7
7
  closePlayer?: () => void;
8
8
  streamActivated?: (data: {
@@ -15,7 +15,7 @@ export type { IStreamPlayerLocalization };
15
15
  *
16
16
  * openStreamPlayer({
17
17
  * streamId: '...',
18
- * graphqlUrl: 'https://api.example.com/graphql',
18
+ * graphqlOrigin: 'https://api.example.com',
19
19
  * localization: {
20
20
  * play: 'Play',
21
21
  * pause: 'Pause'
@@ -25,7 +25,7 @@ export type { IStreamPlayerLocalization };
25
25
  */
26
26
  export declare const openStreamPlayer: (init: {
27
27
  streamId: string;
28
- graphqlUrl?: string;
28
+ graphqlOrigin?: string;
29
29
  localization?: IStreamPlayerLocalization;
30
30
  on?: {
31
31
  streamActivated?: (data: {
@@ -17,7 +17,7 @@ import { mount, unmount } from 'svelte';
17
17
  *
18
18
  * openStreamPlayer({
19
19
  * streamId: '...',
20
- * graphqlUrl: 'https://api.example.com/graphql',
20
+ * graphqlOrigin: 'https://api.example.com',
21
21
  * localization: {
22
22
  * play: 'Play',
23
23
  * pause: 'Pause'
@@ -26,13 +26,13 @@ import { mount, unmount } from 'svelte';
26
26
  * ```
27
27
  */
28
28
  export const openStreamPlayer = (init) => {
29
- const { streamId, graphqlUrl, localization } = init;
29
+ const { streamId, graphqlOrigin, localization } = init;
30
30
  const shadowHost = new ShadowHost();
31
31
  const mounted = mount(StreamPlayer, {
32
32
  target: shadowHost.shadowRoot,
33
33
  props: {
34
34
  streamId,
35
- graphqlUrl,
35
+ graphqlOrigin,
36
36
  localization,
37
37
  on: {
38
38
  streamActivated: (data) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/embeddable",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "author": "StreamsCloud",
5
5
  "repository": "https://github.com/StreamsCloud/streamscloud-frontend-packages.git",
6
6
  "type": "module",