@streamscloud/embeddable 13.3.0 → 14.0.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.
Files changed (145) hide show
  1. package/dist/external-api/data-providers/internal-media-center-data-provider.svelte.js +6 -6
  2. package/dist/external-api/data-providers/mocks/index.d.ts +5 -0
  3. package/dist/external-api/data-providers/mocks/index.js +5 -0
  4. package/dist/{media-center/categories-following → external-api/data-providers/mocks}/mock-categories-following-handler.svelte.d.ts +1 -1
  5. package/dist/external-api/data-providers/mocks/mock-content-management-handler.svelte.d.ts +29 -0
  6. package/dist/external-api/data-providers/mocks/mock-content-management-handler.svelte.js +61 -0
  7. package/dist/{media-center/membership → external-api/data-providers/mocks}/mock-membership-handler.svelte.d.ts +1 -1
  8. package/dist/{media-center/navigation → external-api/data-providers/mocks}/mock-navigation-handler.svelte.d.ts +1 -2
  9. package/dist/{posts/social-interactions → external-api/data-providers/mocks}/mock-post-social-interactions-handler.svelte.d.ts +1 -2
  10. package/dist/{posts/social-interactions → external-api/data-providers/mocks}/mock-post-social-interactions-handler.svelte.js +17 -6
  11. package/dist/external-api/data-providers/mocks/operations.generated.d.ts +115 -0
  12. package/dist/external-api/data-providers/mocks/operations.generated.js +377 -0
  13. package/dist/external-api/data-providers/mocks/operations.graphql +18 -0
  14. package/dist/media-center/config/types.d.ts +7 -1
  15. package/dist/media-center/content-management/index.d.ts +1 -0
  16. package/dist/media-center/content-management/index.js +1 -0
  17. package/dist/media-center/content-management/types.d.ts +24 -0
  18. package/dist/media-center/content-management/types.js +1 -0
  19. package/dist/media-center/index.d.ts +2 -1
  20. package/dist/media-center/media-center/cmp.media-center-proxy.svelte +2 -2
  21. package/dist/media-center/media-center/discover/data-loading.d.ts +3 -0
  22. package/dist/media-center/media-center/discover/data-loading.js +13 -2
  23. package/dist/media-center/media-center/discover/discover-view-handler.svelte.d.ts +23 -0
  24. package/dist/media-center/media-center/discover/discover-view-handler.svelte.js +88 -0
  25. package/dist/media-center/media-center/discover/discover-view.svelte +79 -14
  26. package/dist/media-center/media-center/discover/discover-view.svelte.d.ts +2 -2
  27. package/dist/media-center/media-center/footer/media-center-footer.svelte +1 -1
  28. package/dist/media-center/media-center/handlers/index.d.ts +1 -0
  29. package/dist/media-center/media-center/handlers/index.js +1 -0
  30. package/dist/media-center/media-center/handlers/media-center-content-handler.svelte.d.ts +62 -0
  31. package/dist/media-center/media-center/handlers/media-center-content-handler.svelte.js +144 -0
  32. package/dist/media-center/media-center/header/media-center-header-mobile.svelte +10 -7
  33. package/dist/media-center/media-center/header/media-center-header.svelte +1 -1
  34. package/dist/media-center/media-center/media-center-context.svelte.d.ts +3 -2
  35. package/dist/media-center/media-center/media-center-context.svelte.js +30 -11
  36. package/dist/media-center/media-center/media-center-view.svelte +31 -13
  37. package/dist/media-center/media-center/menu/menu.svelte +13 -2
  38. package/dist/media-center/media-center/menu/menu.svelte.d.ts +1 -0
  39. package/dist/media-center/media-center/menu/popular-streams-panel-handler.svelte.d.ts +7 -0
  40. package/dist/media-center/media-center/menu/popular-streams-panel-handler.svelte.js +23 -8
  41. package/dist/media-center/media-center/moments/moments-feed-handler.svelte.d.ts +19 -2
  42. package/dist/media-center/media-center/moments/moments-feed-handler.svelte.js +51 -6
  43. package/dist/media-center/media-center/moments/moments-state.svelte.d.ts +2 -0
  44. package/dist/media-center/media-center/moments/moments-state.svelte.js +16 -1
  45. package/dist/media-center/media-center/posts-feed/posts-feed-handler.svelte.d.ts +24 -4
  46. package/dist/media-center/media-center/posts-feed/posts-feed-handler.svelte.js +90 -9
  47. package/dist/media-center/media-center/streams-feed/streams-feed-handler.svelte.d.ts +18 -3
  48. package/dist/media-center/media-center/streams-feed/streams-feed-handler.svelte.js +64 -9
  49. package/dist/posts/controls/index.d.ts +2 -1
  50. package/dist/posts/controls/index.js +2 -1
  51. package/dist/posts/controls/post-actions-generator.svelte.d.ts +20 -0
  52. package/dist/posts/controls/post-actions-generator.svelte.js +27 -0
  53. package/dist/posts/controls/post-actions-handler.svelte.d.ts +26 -0
  54. package/dist/posts/controls/post-actions-handler.svelte.js +56 -0
  55. package/dist/posts/index.d.ts +1 -0
  56. package/dist/posts/model/types.d.ts +1 -0
  57. package/dist/posts/post-viewer/cmp.post-viewer.svelte +6 -7
  58. package/dist/posts/post-viewer/cmp.post-viewer.svelte.d.ts +2 -2
  59. package/dist/posts/post-viewer/mapper.js +1 -0
  60. package/dist/posts/posts-player/cmp.posts-player.svelte +2 -1
  61. package/dist/posts/posts-player/cmp.posts-player.svelte.d.ts +2 -0
  62. package/dist/posts/posts-player/index.d.ts +2 -0
  63. package/dist/posts/posts-player/index.js +2 -1
  64. package/dist/posts/posts-player/posts-player-proxy.svelte +2 -1
  65. package/dist/posts/posts-player/posts-player-proxy.svelte.d.ts +3 -1
  66. package/dist/posts/posts-player/posts-player-view.svelte +127 -32
  67. package/dist/posts/posts-player/types.d.ts +8 -0
  68. package/dist/posts/sharing/index.d.ts +1 -0
  69. package/dist/posts/sharing/index.js +1 -0
  70. package/dist/posts/sharing/types.d.ts +5 -0
  71. package/dist/posts/sharing/types.js +1 -0
  72. package/dist/posts/social-interactions/types.d.ts +0 -1
  73. package/dist/streams/controls/index.d.ts +1 -0
  74. package/dist/streams/controls/index.js +1 -0
  75. package/dist/streams/controls/stream-actions-generator.svelte.d.ts +31 -0
  76. package/dist/streams/controls/stream-actions-generator.svelte.js +42 -0
  77. package/dist/streams/index.d.ts +1 -0
  78. package/dist/streams/index.js +1 -0
  79. package/dist/streams/layout/cmp.layout.svelte +4 -1
  80. package/dist/streams/layout/cmp.layout.svelte.d.ts +1 -0
  81. package/dist/streams/layout/element-views/cmp.short-video-stream-element.svelte +1 -0
  82. package/dist/streams/layout/models/mapper.js +1 -0
  83. package/dist/streams/sharing/index.d.ts +1 -0
  84. package/dist/streams/sharing/index.js +1 -0
  85. package/dist/streams/sharing/types.d.ts +5 -0
  86. package/dist/streams/sharing/types.js +1 -0
  87. package/dist/streams/stream-page-viewer/cmp.stream-page-viewer.svelte +43 -1
  88. package/dist/streams/stream-page-viewer/cmp.stream-page-viewer.svelte.d.ts +9 -0
  89. package/dist/streams/streams-player/cmp.streams-player.svelte +2 -1
  90. package/dist/streams/streams-player/cmp.streams-player.svelte.d.ts +2 -0
  91. package/dist/streams/streams-player/index.d.ts +2 -0
  92. package/dist/streams/streams-player/index.js +2 -1
  93. package/dist/streams/streams-player/streams-player-proxy.svelte +2 -1
  94. package/dist/streams/streams-player/streams-player-proxy.svelte.d.ts +2 -0
  95. package/dist/streams/streams-player/streams-player-view.svelte +147 -34
  96. package/dist/streams/streams-player/types.d.ts +7 -0
  97. package/dist/ui/card-actions/card-action-container.d.ts +2 -0
  98. package/dist/ui/card-actions/card-action-container.js +17 -0
  99. package/dist/ui/card-actions/cmp.card-action.svelte +28 -0
  100. package/dist/ui/card-actions/cmp.card-action.svelte.d.ts +10 -0
  101. package/dist/ui/card-actions/cmp.card-actions.svelte +71 -0
  102. package/dist/ui/card-actions/cmp.card-actions.svelte.d.ts +9 -0
  103. package/dist/ui/card-actions/index.d.ts +4 -0
  104. package/dist/ui/card-actions/index.js +3 -0
  105. package/dist/ui/card-actions/types.d.ts +9 -0
  106. package/dist/ui/card-actions/types.js +1 -0
  107. package/dist/ui/player/button/cmp.responsive-player-buttons-group.svelte +53 -0
  108. package/dist/ui/player/button/cmp.responsive-player-buttons-group.svelte.d.ts +10 -0
  109. package/dist/ui/player/button/index.d.ts +1 -0
  110. package/dist/ui/player/button/index.js +1 -0
  111. package/dist/{content-player → ui/player/content-player}/cmp.content-player.svelte +7 -29
  112. package/dist/{content-player → ui/player/content-player}/cmp.content-player.svelte.d.ts +6 -1
  113. package/dist/ui/player/content-player/content-player-config.svelte.d.ts +29 -0
  114. package/dist/ui/player/content-player/content-player-config.svelte.js +27 -0
  115. package/dist/{content-player → ui/player/content-player}/content-player-settings.svelte.d.ts +3 -3
  116. package/dist/{content-player → ui/player/content-player}/content-player-settings.svelte.js +2 -2
  117. package/dist/{content-player → ui/player/content-player}/controls-and-attachments.svelte +18 -65
  118. package/dist/{content-player → ui/player/content-player}/controls-and-attachments.svelte.d.ts +6 -0
  119. package/dist/{content-player → ui/player/content-player}/overview-panel.svelte +1 -1
  120. package/dist/{content-player → ui/player/content-player}/ui-manager.svelte.d.ts +3 -2
  121. package/dist/{content-player → ui/player/content-player}/ui-manager.svelte.js +3 -2
  122. package/dist/ui/player/providers/chunks-player-buffer/player-chunk-item.svelte.d.ts +0 -2
  123. package/dist/ui/player/providers/chunks-player-buffer/player-chunk-item.svelte.js +1 -3
  124. package/dist/ui/player/providers/chunks-player-buffer/player-chunk.svelte.d.ts +3 -2
  125. package/dist/ui/player/providers/chunks-player-buffer/player-chunk.svelte.js +11 -5
  126. package/dist/ui/player/providers/chunks-player-buffer/player-chunks-manager.svelte.d.ts +3 -0
  127. package/dist/ui/player/providers/chunks-player-buffer/player-chunks-manager.svelte.js +74 -8
  128. package/dist/ui/player/providers/default-chunks-player-buffer.svelte.d.ts +2 -0
  129. package/dist/ui/player/providers/default-chunks-player-buffer.svelte.js +15 -4
  130. package/dist/ui/player/providers/default-feed-player-buffer.svelte.d.ts +1 -0
  131. package/dist/ui/player/providers/default-feed-player-buffer.svelte.js +27 -5
  132. package/dist/ui/player/providers/types.d.ts +1 -0
  133. package/dist/ui/shadow-dom/cmp.shadow-root.svelte +9 -4
  134. package/dist/ui/shadow-dom/colors.scss +2 -0
  135. package/package.json +6 -2
  136. package/dist/content-player/content-player-config.svelte.d.ts +0 -51
  137. package/dist/content-player/content-player-config.svelte.js +0 -48
  138. package/dist/posts/controls/cmp.controls.svelte +0 -120
  139. package/dist/posts/controls/cmp.controls.svelte.d.ts +0 -16
  140. /package/dist/{media-center/categories-following → external-api/data-providers/mocks}/mock-categories-following-handler.svelte.js +0 -0
  141. /package/dist/{media-center/membership → external-api/data-providers/mocks}/mock-membership-handler.svelte.js +0 -0
  142. /package/dist/{media-center/navigation → external-api/data-providers/mocks}/mock-navigation-handler.svelte.js +0 -0
  143. /package/dist/{content-player → ui/player/content-player}/index.d.ts +0 -0
  144. /package/dist/{content-player → ui/player/content-player}/index.js +0 -0
  145. /package/dist/{content-player → ui/player/content-player}/overview-panel.svelte.d.ts +0 -0
@@ -6,7 +6,6 @@ export class PlayerChunk {
6
6
  model;
7
7
  items = $derived.by(() => this._chunkItems.map((i) => i.model));
8
8
  chunkItems = $derived.by(() => this._chunkItems);
9
- chunkIndex;
10
9
  activeChunkItem = $derived.by(() => this._chunkItems[this._activeItemIndex] ?? null);
11
10
  isEmpty = $derived.by(() => this.isFullyLoaded && this._chunkItems.length === 0);
12
11
  isFullyLoaded = $state(false);
@@ -15,9 +14,8 @@ export class PlayerChunk {
15
14
  _isLoading = $state(false);
16
15
  _itemsLoader;
17
16
  constructor(data) {
18
- const { chunk, provider, chunkIndex, callbacks } = data;
17
+ const { chunk, provider, callbacks } = data;
19
18
  this.model = chunk;
20
- this.chunkIndex = chunkIndex;
21
19
  this._itemsLoader = new CursorDataLoader({
22
20
  loadPage: async (continuationToken) => {
23
21
  if (this.isFullyLoaded) {
@@ -27,9 +25,8 @@ export class PlayerChunk {
27
25
  const newItems = result.items;
28
26
  this._chunkItems = [
29
27
  ...this._chunkItems,
30
- ...newItems.map((item, index) => new PlayerChunkItem({
28
+ ...newItems.map((item) => new PlayerChunkItem({
31
29
  model: item,
32
- indexWithinChunk: this._chunkItems.length + index,
33
30
  chunkId: this.model.id
34
31
  }))
35
32
  ];
@@ -45,6 +42,12 @@ export class PlayerChunk {
45
42
  }
46
43
  });
47
44
  }
45
+ get isLoading() {
46
+ return this._isLoading;
47
+ }
48
+ get activeItemIndex() {
49
+ return this._activeItemIndex;
50
+ }
48
51
  loadMore = () => this._itemsLoader.loadMore();
49
52
  setActiveItemIndex = async (index, warmUp = true) => {
50
53
  this._activeItemIndex = index;
@@ -52,6 +55,9 @@ export class PlayerChunk {
52
55
  await this.warmUp();
53
56
  }
54
57
  };
58
+ mutateChunkItems = (items) => {
59
+ this._chunkItems = items;
60
+ };
55
61
  warmUp = async () => {
56
62
  if (this._chunkItems.length >= this._activeItemIndex + CHUNK_ITEMS_BUFFER_SIZE || this._isLoading) {
57
63
  return;
@@ -8,9 +8,12 @@ export declare class PlayerChunksManager<TItem extends WithId, TChunk extends Wi
8
8
  constructor(provider: IChunksPlayerDataProvider<TItem, TChunk>);
9
9
  get activeChunk(): PlayerChunk<TItem, TChunk>;
10
10
  get loadedChunks(): PlayerChunk<TItem, TChunk>[];
11
+ get isLoading(): boolean;
11
12
  get flattenedChunkItems(): TItem[];
12
13
  get flattenedActiveChunkItemIndex(): number;
13
14
  tryActivateItemById: (id: string) => boolean;
15
+ removeItemById: (id: string) => boolean;
16
+ removeChunkById: (id: string) => boolean | undefined;
14
17
  initialize: () => Promise<void>;
15
18
  setActiveChunkIndex: (index: number) => Promise<void>;
16
19
  activateItemAtFlattenedIndex: (index: number) => Promise<void>;
@@ -16,6 +16,9 @@ export class PlayerChunksManager {
16
16
  get loadedChunks() {
17
17
  return this._loadedChunks;
18
18
  }
19
+ get isLoading() {
20
+ return this._fetchDeferred !== null || this._loadedChunks.some((c) => c.isLoading);
21
+ }
19
22
  get flattenedChunkItems() {
20
23
  return this._loadedChunks.reduce((acc, chunk) => {
21
24
  acc.push(...chunk.items);
@@ -27,21 +30,85 @@ export class PlayerChunksManager {
27
30
  return -1;
28
31
  }
29
32
  let itemsBeforeActiveChunk = 0;
30
- for (let i = 0; i < this.activeChunk.chunkIndex; i++) {
33
+ for (let i = 0; i < this._activeChunkIndex; i++) {
31
34
  itemsBeforeActiveChunk += this._loadedChunks[i].items.length;
32
35
  }
33
- return itemsBeforeActiveChunk + this.activeChunk.activeChunkItem.indexWithinChunk;
36
+ return itemsBeforeActiveChunk + this.activeChunk.activeItemIndex;
34
37
  }
35
38
  tryActivateItemById = (id) => {
36
- const chunkWithItem = this._loadedChunks.find((chunk) => chunk.items.some((item) => item.id === id));
39
+ const chunkWithItemIndex = this._loadedChunks.findIndex((chunk) => chunk.items.some((item) => item.id === id));
40
+ const chunkWithItem = this._loadedChunks[chunkWithItemIndex];
37
41
  if (!chunkWithItem) {
38
42
  return false;
39
43
  }
40
44
  const itemIndex = chunkWithItem.items.findIndex((item) => item.id === id);
41
- this.setActiveChunkIndex(chunkWithItem.chunkIndex);
45
+ this.setActiveChunkIndex(chunkWithItemIndex);
42
46
  this.activeChunk.setActiveItemIndex(itemIndex);
43
47
  return true;
44
48
  };
49
+ removeItemById = (id) => {
50
+ const itemIndex = this.flattenedChunkItems.findIndex((item) => item.id === id);
51
+ if (itemIndex === -1) {
52
+ return false;
53
+ }
54
+ const currentItem = this.flattenedChunkItems[this.flattenedActiveChunkItemIndex];
55
+ // Find next item to activate BEFORE removing (if removing current item)
56
+ let nextItemId = currentItem?.id;
57
+ if (this.flattenedActiveChunkItemIndex === itemIndex) {
58
+ // Try next item
59
+ if (itemIndex + 1 < this.flattenedChunkItems.length) {
60
+ nextItemId = this.flattenedChunkItems[itemIndex + 1].id;
61
+ }
62
+ // Try previous item
63
+ else if (itemIndex > 0) {
64
+ nextItemId = this.flattenedChunkItems[itemIndex - 1].id;
65
+ }
66
+ else {
67
+ // No items left
68
+ nextItemId = null;
69
+ }
70
+ }
71
+ // Remove item from chunks
72
+ this._loadedChunks.forEach((chunk) => {
73
+ if (chunk.chunkItems.some((i) => i.model.id === id)) {
74
+ chunk.mutateChunkItems(chunk.chunkItems.filter((i) => i.model.id !== id));
75
+ }
76
+ });
77
+ if (nextItemId) {
78
+ this.tryActivateItemById(nextItemId);
79
+ }
80
+ else {
81
+ this._activeChunkIndex = -1;
82
+ }
83
+ return true;
84
+ };
85
+ removeChunkById = (id) => {
86
+ const chunkIndex = this._loadedChunks.findIndex((chunk) => chunk.model.id === id);
87
+ if (chunkIndex === -1) {
88
+ return false;
89
+ }
90
+ const isActiveChunk = this._activeChunkIndex === chunkIndex;
91
+ let newActiveChunkIndex = this._activeChunkIndex;
92
+ this._loadedChunks.splice(chunkIndex, 1);
93
+ if (this._loadedChunks.length === 0) {
94
+ this._activeChunkIndex = -1;
95
+ this.provider.onEndReached?.();
96
+ return;
97
+ }
98
+ if (isActiveChunk) {
99
+ if (chunkIndex < this._loadedChunks.length) {
100
+ newActiveChunkIndex = chunkIndex;
101
+ }
102
+ else {
103
+ newActiveChunkIndex = this._loadedChunks.length - 1;
104
+ }
105
+ }
106
+ else if (this._activeChunkIndex > chunkIndex) {
107
+ newActiveChunkIndex--;
108
+ }
109
+ this.setActiveChunkIndex(newActiveChunkIndex);
110
+ return true;
111
+ };
45
112
  initialize = async () => {
46
113
  const handleInitialized = async () => {
47
114
  const startIndex = Math.min(FIXED_START_INDEX, this._loadedChunks.length - 1);
@@ -56,7 +123,7 @@ export class PlayerChunksManager {
56
123
  this.activeChunk.setActiveItemIndex(this.provider.initialData.startItemIndex);
57
124
  }
58
125
  };
59
- this._loadedChunks = this.provider.initialData.prefetchedChunks.map((chunk, chunkIndex) => new PlayerChunk({ chunk, chunkIndex, provider: { loadChunkItems: this.provider.loadChunkItems } }));
126
+ this._loadedChunks = this.provider.initialData.prefetchedChunks.map((chunk) => new PlayerChunk({ chunk, provider: { loadChunkItems: this.provider.loadChunkItems } }));
60
127
  const considerInitialized = this._loadedChunks.length !== 0;
61
128
  if (considerInitialized) {
62
129
  handleInitialized();
@@ -85,7 +152,7 @@ export class PlayerChunksManager {
85
152
  this.activeChunk.warmUp();
86
153
  }
87
154
  else {
88
- this.activeChunk.setActiveItemIndex(nextItem.indexWithinChunk);
155
+ this.activeChunk.setActiveItemIndex(this.activeChunk.chunkItems.indexOf(nextItem));
89
156
  }
90
157
  };
91
158
  warmUp = async () => {
@@ -101,9 +168,8 @@ export class PlayerChunksManager {
101
168
  const result = await this.provider.loadMoreChunks();
102
169
  this._loadedChunks = [
103
170
  ...this._loadedChunks,
104
- ...result.map((chunk, index) => new PlayerChunk({
171
+ ...result.map((chunk) => new PlayerChunk({
105
172
  chunk,
106
- chunkIndex: this._loadedChunks.length + index,
107
173
  provider: { loadChunkItems: this.provider.loadChunkItems }
108
174
  }))
109
175
  ];
@@ -14,6 +14,8 @@ export declare class DefaultChunksPlayerBuffer<TItem extends WithId, TChunk exte
14
14
  get activeChunk(): import("./chunks-player-buffer").PlayerChunk<TItem, TChunk>;
15
15
  setActiveChunkItemIndex: (index: number) => void;
16
16
  tryActivateItemById: (id: string) => boolean;
17
+ removeChunkById: (id: string) => boolean | undefined;
18
+ removeItemById: (id: string) => boolean;
17
19
  loadNext: () => Promise<void>;
18
20
  loadPrevious: () => Promise<void>;
19
21
  reset: () => void;
@@ -5,7 +5,12 @@ export class DefaultChunksPlayerBuffer {
5
5
  loaded = $derived.by(() => this._playerChunksManager.flattenedChunkItems);
6
6
  currentIndex = $derived.by(() => this._playerChunksManager.flattenedActiveChunkItemIndex);
7
7
  current = $derived(this.currentIndex >= 0 ? this.loaded[this.currentIndex] : null);
8
- canLoadNext = $derived.by(() => this.currentIndex < this.loaded.length - 1 || !!this._onEndReachedFn);
8
+ canLoadNext = $derived.by(() => {
9
+ if (this.loaded.length && this.currentIndex < this.loaded.length - 1) {
10
+ return true;
11
+ }
12
+ return !this._playerChunksManager.isLoading && !!this._onEndReachedFn;
13
+ });
9
14
  canLoadPrevious = $derived(this.currentIndex > 0);
10
15
  navigationDisabled = $derived(!this.canLoadNext && !this.canLoadPrevious);
11
16
  animationDuration = 500;
@@ -31,15 +36,21 @@ export class DefaultChunksPlayerBuffer {
31
36
  tryActivateItemById = (id) => {
32
37
  return this._playerChunksManager.tryActivateItemById(id);
33
38
  };
39
+ removeChunkById = (id) => {
40
+ return this._playerChunksManager.removeChunkById(id);
41
+ };
42
+ removeItemById = (id) => {
43
+ return this._playerChunksManager.removeItemById(id);
44
+ };
34
45
  loadNext = async () => {
35
46
  if (!this.canLoadNext) {
36
47
  return;
37
48
  }
38
- if (this.currentIndex >= this.loaded.length - 1) {
39
- this._onEndReachedFn?.();
49
+ if (this.currentIndex < this.loaded.length - 1) {
50
+ this._playerChunksManager.activateItemAtFlattenedIndex(this.currentIndex + 1);
40
51
  return;
41
52
  }
42
- this._playerChunksManager.activateItemAtFlattenedIndex(this.currentIndex + 1);
53
+ this._onEndReachedFn?.();
43
54
  };
44
55
  loadPrevious = async () => {
45
56
  if (!this.canLoadPrevious) {
@@ -19,6 +19,7 @@ export declare class DefaultFeedPlayerBuffer<T extends WithId> implements IFeedP
19
19
  private _onEndReachedFn;
20
20
  constructor(provider: IFeedPlayerDataProvider<T>);
21
21
  tryActivateItemById: (id: string) => boolean;
22
+ removeItemById: (id: string) => boolean;
22
23
  loadNext: () => Promise<void>;
23
24
  loadPrevious: () => Promise<void>;
24
25
  reset: () => void;
@@ -6,7 +6,12 @@ export class DefaultFeedPlayerBuffer {
6
6
  loaded = $derived.by(() => this._loaded);
7
7
  currentIndex = $derived.by(() => this._currentIndex);
8
8
  current = $derived(this.currentIndex >= 0 ? this.loaded[this.currentIndex] : null);
9
- canLoadNext = $derived.by(() => this.currentIndex < this.loaded.length - 1 || !!this._onEndReachedFn);
9
+ canLoadNext = $derived.by(() => {
10
+ if (this.loaded.length && this.currentIndex < this.loaded.length - 1) {
11
+ return true;
12
+ }
13
+ return !this._fetchDeferred && !!this._onEndReachedFn;
14
+ });
10
15
  canLoadPrevious = $derived(this.currentIndex > 0);
11
16
  navigationDisabled = $derived(!this.canLoadNext && !this.canLoadPrevious);
12
17
  animationDuration = 500;
@@ -31,16 +36,33 @@ export class DefaultFeedPlayerBuffer {
31
36
  this._currentIndex = itemIndex;
32
37
  return true;
33
38
  };
39
+ removeItemById = (id) => {
40
+ const itemIndex = this._loaded.findIndex((item) => item.id === id);
41
+ if (itemIndex === -1) {
42
+ return false;
43
+ }
44
+ this._loaded = this._loaded.filter((item) => item.id !== id);
45
+ if (itemIndex < this._currentIndex) {
46
+ this._currentIndex--;
47
+ }
48
+ else if (itemIndex === this._currentIndex) {
49
+ if (this._currentIndex >= this._loaded.length) {
50
+ this._currentIndex = this._loaded.length - 1;
51
+ }
52
+ // Otherwise keep the same index (activates next item)
53
+ }
54
+ return true;
55
+ };
34
56
  loadNext = async () => {
35
57
  if (!this.canLoadNext) {
36
58
  return;
37
59
  }
38
- if (this.currentIndex >= this.loaded.length - 1) {
39
- this._onEndReachedFn?.();
60
+ if (this.currentIndex < this.loaded.length - 1) {
61
+ ++this._currentIndex;
62
+ await this.warmUpBuffer();
40
63
  return;
41
64
  }
42
- ++this._currentIndex;
43
- this.warmUpBuffer();
65
+ this._onEndReachedFn?.();
44
66
  };
45
67
  loadPrevious = async () => {
46
68
  if (!this.canLoadPrevious) {
@@ -37,6 +37,7 @@ export interface IPlayerBufferBase<T extends WithId> {
37
37
  reset: () => void;
38
38
  ensureWarmedUp: () => Promise<void>;
39
39
  tryActivateItemById: (id: string) => boolean;
40
+ removeItemById: (id: string) => void;
40
41
  }
41
42
  type TExtended<T> = T & {
42
43
  mediaIndex?: number;
@@ -55,6 +55,7 @@ const styles = $derived.by(() => {
55
55
  /* Backgrounds */
56
56
  --sc-mc-color--bg-button: #ffffff;
57
57
  --sc-mc-color--bg-card: #ffffff;
58
+ --sc-mc-color--bg-card-action: #f9fafb;
58
59
  --sc-mc-color--bg-image: #d1d5db;
59
60
  --sc-mc-color--bg-panel: #ffffff;
60
61
  --sc-mc-color--bg-screen: #f9fafb;
@@ -88,6 +89,7 @@ const styles = $derived.by(() => {
88
89
  /* Backgrounds */
89
90
  --sc-mc-color--bg-button: #111827;
90
91
  --sc-mc-color--bg-card: #000000;
92
+ --sc-mc-color--bg-card-action: #111827;
91
93
  --sc-mc-color--bg-image: #374151;
92
94
  --sc-mc-color--bg-panel: #000000;
93
95
  --sc-mc-color--bg-screen: #1e1e1e;
@@ -117,14 +119,17 @@ const styles = $derived.by(() => {
117
119
  --sc-mc-color--text-inactive: #d1d5db;
118
120
  }
119
121
 
120
- .shadow-root {
121
- --_shadow-root--background-color: rgb(from var(--shadow-root--background, var(--sc-mc-color--bg-screen)) r g b);
122
- --_shadow-root--shield-color: rgb(from var(--shadow-root--background, rgb(from var(--sc-mc-color--bg-screen) r g b / 50%)) r g b / alpha);
123
- --_shadow-root--background-image-url: var(--shadow-root--background-image-url);
122
+ :host {
124
123
  font-family: "Inter", sans-serif;
125
124
  font-size: 16px;
126
125
  font-weight: normal;
127
126
  color: var(--sc-mc-color--text-primary);
127
+ }
128
+
129
+ .shadow-root {
130
+ --_shadow-root--background-color: rgb(from var(--shadow-root--background, var(--sc-mc-color--bg-screen)) r g b);
131
+ --_shadow-root--shield-color: rgb(from var(--shadow-root--background, rgb(from var(--sc-mc-color--bg-screen) r g b / 50%)) r g b / alpha);
132
+ --_shadow-root--background-image-url: var(--shadow-root--background-image-url);
128
133
  width: 100%;
129
134
  min-width: 100%;
130
135
  max-width: 100%;
@@ -5,6 +5,7 @@
5
5
  /* Backgrounds */
6
6
  --sc-mc-color--bg-button: #{colors.$color-white};
7
7
  --sc-mc-color--bg-card: #{colors.$color-white};
8
+ --sc-mc-color--bg-card-action: #{colors.$color-neutral-50};
8
9
  --sc-mc-color--bg-image: #{colors.$color-neutral-300};
9
10
  --sc-mc-color--bg-panel: #{colors.$color-white};
10
11
  --sc-mc-color--bg-screen: #{colors.$color-neutral-50};
@@ -42,6 +43,7 @@
42
43
  /* Backgrounds */
43
44
  --sc-mc-color--bg-button: #{colors.$color-neutral-900};
44
45
  --sc-mc-color--bg-card: #{colors.$color-black};
46
+ --sc-mc-color--bg-card-action: #{colors.$color-neutral-900};
45
47
  --sc-mc-color--bg-image: #{colors.$color-neutral-700};
46
48
  --sc-mc-color--bg-panel: #{colors.$color-black};
47
49
  --sc-mc-color--bg-screen: #{colors.$color-dark-800};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/embeddable",
3
- "version": "13.3.0",
3
+ "version": "14.0.0",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",
@@ -57,6 +57,10 @@
57
57
  "types": "./dist/posts/post-viewer/index.d.ts",
58
58
  "svelte": "./dist/posts/post-viewer/index.js"
59
59
  },
60
+ "./streams": {
61
+ "types": "./dist/streams/index.d.ts",
62
+ "svelte": "./dist/streams/index.js"
63
+ },
60
64
  "./streams-player": {
61
65
  "types": "./dist/streams/streams-player/index.d.ts",
62
66
  "svelte": "./dist/streams/streams-player/index.js"
@@ -180,7 +184,7 @@
180
184
  "svelte-preprocess": "^6.0.3",
181
185
  "typescript": "^5.8.3",
182
186
  "typescript-eslint": "^8.32.1",
183
- "vite": "^6.3.5",
187
+ "vite": "^6.4.1",
184
188
  "vite-tsconfig-paths": "^5.1.4",
185
189
  "wheel-gestures": "^2.2.48"
186
190
  }
@@ -1,51 +0,0 @@
1
- import { type IPostModel, PostModel } from '../posts/model';
2
- import type { IPostSocialInteractionsHandler } from '../posts/social-interactions';
3
- import type { ICloseOrchestrator } from '../ui/player/close-orchestrator';
4
- import type { IPlayerBuffer } from '../ui/player/providers';
5
- import type { PlayerSliderCallbacks } from '../ui/player/slider/types';
6
- import { ContentPlayerSettings } from './content-player-settings.svelte';
7
- import { ContentPlayerUIManager } from './ui-manager.svelte';
8
- export declare class ContentPlayerConfig<T extends {
9
- id: string;
10
- }> {
11
- playerBuffer: IPlayerBuffer<T> | null;
12
- readonly settings: ContentPlayerSettings;
13
- readonly callbacks: ContentPlayerCallbacks | null;
14
- readonly playerSliderCallbacks: PlayerSliderCallbacks | undefined;
15
- readonly socialInteractionsHandler: IPostSocialInteractionsHandler | undefined;
16
- readonly closeOrchestrator: ICloseOrchestrator;
17
- readonly uiManager: ContentPlayerUIManager;
18
- private _trackingParams;
19
- private _mappers;
20
- private mappedPostsCache;
21
- constructor(init: {
22
- playerBuffer: IPlayerBuffer<T> | null;
23
- mappers: ContentPlayerMappers<T>;
24
- socialInteractionsHandler?: IPostSocialInteractionsHandler;
25
- settings?: ContentPlayerSettings;
26
- callbacks?: ContentPlayerCallbacks;
27
- playerSliderCallbacks?: PlayerSliderCallbacks;
28
- trackingParams?: ContentPlayerTrackingParams | null;
29
- closeOrchestrator: ICloseOrchestrator;
30
- });
31
- get playerColors(): import("../ui/player/colors").PlayerColors;
32
- get trackingParams(): ContentPlayerConfig<T>['_trackingParams'];
33
- itemAsPostViewerModel: (item: T & {
34
- mediaIndex?: number;
35
- }) => PostModel | null;
36
- updateTrackingParams: (data: ContentPlayerTrackingParams | null) => void;
37
- }
38
- export type ContentPlayerMappers<T> = {
39
- postModelFromCurrentItem: (item: T) => IPostModel | null;
40
- };
41
- export type ContentPlayerCallbacks = {
42
- videoProgress?: (playerItemId: string, postId: string, progress: number) => void;
43
- productClick?: (productId: string, postId: string) => void;
44
- productImpression?: (productId: string, postId: string) => void;
45
- adClick?: (adId: string, postId: string) => void;
46
- adImpression?: (adId: string, postId: string) => void;
47
- };
48
- export type ContentPlayerTrackingParams = {
49
- streamId?: string;
50
- campaignId?: string;
51
- } | false;
@@ -1,48 +0,0 @@
1
- import { PostModel } from '../posts/model';
2
- import { ContentPlayerSettings } from './content-player-settings.svelte';
3
- import { ContentPlayerUIManager } from './ui-manager.svelte';
4
- export class ContentPlayerConfig {
5
- playerBuffer = $state.raw(null);
6
- settings;
7
- callbacks;
8
- playerSliderCallbacks;
9
- socialInteractionsHandler;
10
- closeOrchestrator;
11
- uiManager = new ContentPlayerUIManager();
12
- _trackingParams = $state.raw(null);
13
- _mappers;
14
- mappedPostsCache = new Map();
15
- constructor(init) {
16
- const { playerBuffer, trackingParams, mappers, socialInteractionsHandler, settings, callbacks, playerSliderCallbacks, closeOrchestrator } = init;
17
- this.playerBuffer = playerBuffer;
18
- this._trackingParams = trackingParams ?? null;
19
- this.settings = settings || new ContentPlayerSettings();
20
- this.callbacks = callbacks || null;
21
- this.playerSliderCallbacks = playerSliderCallbacks;
22
- this.socialInteractionsHandler = socialInteractionsHandler;
23
- this.closeOrchestrator = closeOrchestrator;
24
- this._mappers = mappers;
25
- }
26
- get playerColors() {
27
- return this.settings.playerColors;
28
- }
29
- get trackingParams() {
30
- return this._trackingParams;
31
- }
32
- itemAsPostViewerModel = (item) => {
33
- if (this.mappedPostsCache.has(item.id)) {
34
- return this.mappedPostsCache.get(item.id) || null;
35
- }
36
- const post = this._mappers.postModelFromCurrentItem(item);
37
- if (!post) {
38
- this.mappedPostsCache.set(item.id, null);
39
- return null;
40
- }
41
- const postModel = new PostModel(post);
42
- this.mappedPostsCache.set(item.id, postModel);
43
- return postModel;
44
- };
45
- updateTrackingParams = (data) => {
46
- this._trackingParams = data ?? null;
47
- };
48
- }
@@ -1,120 +0,0 @@
1
- <script lang="ts">var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { IconColor } from '../../ui/icon';
11
- import { MediaVolumeManager } from '../../ui/media-playback';
12
- import { MobilePlayerButtonsGroup, PlayerButton, PlayerButtonsGroup } from '../../ui/player/button';
13
- import IconHeartFilled from '@fluentui/svg-icons/icons/heart_32_filled.svg?raw';
14
- import IconHeart from '@fluentui/svg-icons/icons/heart_32_regular.svg?raw';
15
- import IconShare from '@fluentui/svg-icons/icons/share_48_regular.svg?raw';
16
- import IconShoppingBag from '@fluentui/svg-icons/icons/shopping_bag_32_regular.svg?raw';
17
- import IconSpeaker2 from '@fluentui/svg-icons/icons/speaker_2_32_regular.svg?raw';
18
- import IconSpeakerMute from '@fluentui/svg-icons/icons/speaker_mute_32_regular.svg?raw';
19
- let { model, activeColor, inactiveColor, socialInteractionsHandler, extraActions, on } = $props();
20
- const showSocialInteractions = $derived(!!socialInteractionsHandler && model.enableSocialInteractions);
21
- let isLikedStore = $state.raw({
22
- get isLiked() {
23
- return false;
24
- }
25
- });
26
- const actions = $derived.by(() => {
27
- const result = [];
28
- if (model.attachments) {
29
- result.push({ icon: IconShoppingBag, callback: onAttachmentsClicked });
30
- }
31
- if (showSocialInteractions) {
32
- result.push({
33
- icon: isLikedStore.isLiked ? IconHeartFilled : IconHeart,
34
- iconColor: isLikedStore.isLiked ? IconColor.Red : undefined,
35
- callback: onLikeClicked
36
- });
37
- result.push({ icon: IconShare, callback: onShareClicked });
38
- }
39
- if (model.media && !model.media.currentItem.isImage) {
40
- result.push({ icon: MediaVolumeManager.isMuted ? IconSpeakerMute : IconSpeaker2, callback: onMuteClicked });
41
- }
42
- if (extraActions === null || extraActions === void 0 ? void 0 : extraActions.length) {
43
- result.push(...extraActions);
44
- }
45
- return result;
46
- });
47
- $effect(() => {
48
- refreshIsLiked();
49
- });
50
- const onAttachmentsClicked = () => {
51
- var _a;
52
- (_a = on === null || on === void 0 ? void 0 : on.attachmentsClicked) === null || _a === void 0 ? void 0 : _a.call(on);
53
- };
54
- const onMuteClicked = () => {
55
- MediaVolumeManager.isMuted = !MediaVolumeManager.isMuted;
56
- };
57
- const onLikeClicked = () => __awaiter(void 0, void 0, void 0, function* () {
58
- if (!socialInteractionsHandler) {
59
- return;
60
- }
61
- yield socialInteractionsHandler.toggleLike(model.id);
62
- });
63
- const onShareClicked = () => __awaiter(void 0, void 0, void 0, function* () {
64
- if (!socialInteractionsHandler) {
65
- return;
66
- }
67
- yield socialInteractionsHandler.share(model.id);
68
- });
69
- const refreshIsLiked = () => __awaiter(void 0, void 0, void 0, function* () {
70
- if (!socialInteractionsHandler) {
71
- return;
72
- }
73
- isLikedStore = yield socialInteractionsHandler.getIsLiked(model.id);
74
- });
75
- </script>
76
-
77
- <div class="desktop-controls">
78
- {#if actions.length > 0}
79
- {#if actions.length === 1}
80
- <PlayerButton scaleEffect={true} activeColor={activeColor} inactiveColor={inactiveColor} icon={actions[0].icon} on={{ click: actions[0].callback }} />
81
- {:else}
82
- <PlayerButtonsGroup scaleEffect={true} activeColor={activeColor} backgroundColor={inactiveColor} actions={actions} />
83
- {/if}
84
- {/if}
85
- </div>
86
-
87
- <div class="mobile-controls">
88
- <MobilePlayerButtonsGroup actions={actions} />
89
- </div>
90
-
91
- <style>@keyframes fadeIn {
92
- 0% {
93
- opacity: 1;
94
- }
95
- 50% {
96
- opacity: 0.4;
97
- }
98
- 100% {
99
- opacity: 1;
100
- }
101
- }
102
- .desktop-controls {
103
- display: block;
104
- /* Set 'container-type: inline-size;' to reference container*/
105
- }
106
- @container (width < 576px) {
107
- .desktop-controls {
108
- display: none;
109
- }
110
- }
111
-
112
- .mobile-controls {
113
- display: none;
114
- /* Set 'container-type: inline-size;' to reference container*/
115
- }
116
- @container (width < 576px) {
117
- .mobile-controls {
118
- display: block;
119
- }
120
- }</style>
@@ -1,16 +0,0 @@
1
- import type { PostModel } from '../model';
2
- import type { IPostSocialInteractionsHandler } from '../social-interactions';
3
- import { type PlayerButtonDef } from '../../ui/player/button';
4
- type Props = {
5
- model: PostModel;
6
- activeColor: string | null;
7
- inactiveColor: string | null;
8
- socialInteractionsHandler?: IPostSocialInteractionsHandler;
9
- extraActions?: PlayerButtonDef[];
10
- on?: {
11
- attachmentsClicked?: () => void;
12
- };
13
- };
14
- declare const Cmp: import("svelte").Component<Props, {}, "">;
15
- type Cmp = ReturnType<typeof Cmp>;
16
- export default Cmp;