@streamscloud/embeddable 17.0.2 → 17.0.4

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.
@@ -22,6 +22,8 @@ $effect(() => {
22
22
  }
23
23
  });
24
24
  const localization = new FeedPlayerLocalization();
25
+ // ── Mode ──
26
+ const isPreview = $derived(settings?.mode === 'preview');
25
27
  // ── Background mode ──
26
28
  const isGlassBackground = $derived(settings?.background === 'glass');
27
29
  const isTransparentBackground = $derived(settings?.background === 'transparent');
@@ -249,8 +251,12 @@ const onAdImpression = (adId) => {
249
251
  };
250
252
  // ── Action buttons (like, share, attachments toggle) ──
251
253
  const postActionsGenerator = untrack(() => new PostActionsGenerator({
252
- socialInteractionsHandler,
253
- sharingHandler,
254
+ get socialInteractionsHandler() {
255
+ return socialInteractionsHandler;
256
+ },
257
+ get sharingHandler() {
258
+ return sharingHandler;
259
+ },
254
260
  on: { attachmentClicked: () => (sidebarCollapsed = !sidebarCollapsed) }
255
261
  }));
256
262
  const itemActions = $derived.by(() => {
@@ -292,13 +298,15 @@ const itemActions = $derived.by(() => {
292
298
  enableAttachments={false}
293
299
  enableControls={showControlsOverlay}
294
300
  autoplay="on-appearance"
295
- on={{
296
- productClick: onProductClick,
297
- productImpression: onProductImpression,
298
- adClick: onAdClick,
299
- adImpression: onAdImpression,
300
- articleReadMore: (id) => on?.articleReadMore?.(id)
301
- }} />
301
+ on={isPreview
302
+ ? {}
303
+ : {
304
+ productClick: onProductClick,
305
+ productImpression: onProductImpression,
306
+ adClick: onAdClick,
307
+ adImpression: onAdImpression,
308
+ articleReadMore: (id) => on?.articleReadMore?.(id)
309
+ }} />
302
310
  </div>
303
311
  {/snippet}
304
312
  </FeedSlider>
@@ -344,22 +352,25 @@ const itemActions = $derived.by(() => {
344
352
  model={currentPostModel}
345
353
  trackingParams={currentTrackingParams}
346
354
  selectedProductId={selectedProductId}
355
+ interactionsDisabled={isPreview}
347
356
  recommendedHandler={recommendedHandler}
348
357
  playlistHandler={playlistHandler}
349
- on={{
350
- tabChange: handleTabChange,
351
- productClick: onProductClick,
352
- productImpression: onProductImpression,
353
- productBuy: on?.productBuy,
354
- productSelect: (id) => {
355
- selectedProductId = id;
356
- handleTabChange('product');
357
- },
358
- adClick: onAdClick,
359
- adImpression: onAdImpression,
360
- articleReadMore: on?.articleReadMore,
361
- postActivate: (id) => buffer?.tryActivateItemById(id)
362
- }} />
358
+ on={isPreview
359
+ ? { tabChange: () => {} }
360
+ : {
361
+ tabChange: handleTabChange,
362
+ productClick: onProductClick,
363
+ productImpression: onProductImpression,
364
+ productBuy: on?.productBuy,
365
+ productSelect: (id) => {
366
+ selectedProductId = id;
367
+ handleTabChange('product');
368
+ },
369
+ adClick: onAdClick,
370
+ adImpression: onAdImpression,
371
+ articleReadMore: on?.articleReadMore,
372
+ postActivate: (id) => buffer?.tryActivateItemById(id)
373
+ }} />
363
374
  </div>
364
375
  {/if}
365
376
  </div>
@@ -10,11 +10,11 @@ const selectedProduct = $derived.by(() => {
10
10
  }
11
11
  return model.attachments.products.find((p) => p.id === selectedProductId) ?? null;
12
12
  });
13
- let { tabs, activeTabId, model, trackingParams, selectedProductId, recommendedHandler, playlistHandler, on } = $props();
13
+ let { tabs, activeTabId, model, trackingParams, selectedProductId, interactionsDisabled, recommendedHandler, playlistHandler, on } = $props();
14
14
  </script>
15
15
 
16
16
  <div class="sidebar-panel">
17
- <SidebarTabBar tabs={tabs} activeTabId={activeTabId} on={{ tabChange: on.tabChange }} />
17
+ <SidebarTabBar tabs={tabs} activeTabId={activeTabId} disabled={interactionsDisabled} on={{ tabChange: on.tabChange }} />
18
18
 
19
19
  <div class="sidebar-panel__content">
20
20
  {#if activeTabId === 'information'}
@@ -8,6 +8,7 @@ type Props = {
8
8
  model: PostModel;
9
9
  trackingParams: TrackingParams;
10
10
  selectedProductId: string | null;
11
+ interactionsDisabled?: boolean;
11
12
  recommendedHandler?: IFeedPlayerRecommendedHandler;
12
13
  playlistHandler?: IFeedPlayerPlaylistHandler;
13
14
  on: {
@@ -1,8 +1,8 @@
1
- <script lang="ts">let { tabs, activeTabId, on } = $props();
1
+ <script lang="ts">let { tabs, activeTabId, disabled, on } = $props();
2
2
  export {};
3
3
  </script>
4
4
 
5
- <div class="sidebar-tab-bar">
5
+ <div class="sidebar-tab-bar" class:sidebar-tab-bar--disabled={disabled}>
6
6
  {#each tabs as tab (tab.id)}
7
7
  <button type="button" class="sidebar-tab-bar__tab" class:sidebar-tab-bar__tab--active={tab.id === activeTabId} onclick={() => on.tabChange(tab.id)}>
8
8
  {tab.label}
@@ -42,4 +42,8 @@ export {};
42
42
  .sidebar-tab-bar__tab--active {
43
43
  font-weight: 500;
44
44
  color: var(--_sidebar-tab-bar--color-active);
45
+ }
46
+ .sidebar-tab-bar--disabled .sidebar-tab-bar__tab:not(.sidebar-tab-bar__tab--active) {
47
+ pointer-events: none;
48
+ opacity: 0.5;
45
49
  }</style>
@@ -2,6 +2,7 @@ import type { SidebarTab } from './types';
2
2
  type Props = {
3
3
  tabs: SidebarTab[];
4
4
  activeTabId: string;
5
+ disabled?: boolean;
5
6
  on: {
6
7
  tabChange: (id: string) => void;
7
8
  };
@@ -63,4 +63,5 @@ export type FeedPlayerProps = {
63
63
  export type FeedPlayerSettings = {
64
64
  locale?: AppLocaleValue;
65
65
  background?: 'solid' | 'glass' | 'transparent';
66
+ mode?: 'default' | 'preview';
66
67
  };
@@ -1,2 +1,2 @@
1
1
  export { PostActionsGenerator } from './post-actions-generator.svelte';
2
- export { PostActionsHandler } from './post-actions-handler.svelte';
2
+ export { PostActionsHandler, type PostActionsHandlerProps } from './post-actions-handler.svelte';
@@ -3,18 +3,16 @@ import type { IPostSharingHandler } from '../sharing';
3
3
  import type { IPostSocialInteractionsHandler } from '../social-interactions';
4
4
  import { PostActionsHandler } from './post-actions-handler.svelte';
5
5
  export declare class PostActionsGenerator {
6
- private socialInteractionsHandler;
7
- private sharingHandler;
8
- private callbacks;
6
+ private props;
9
7
  private handlers;
10
- constructor(init: {
11
- socialInteractionsHandler: IPostSocialInteractionsHandler | undefined;
12
- sharingHandler: IPostSharingHandler | undefined;
13
- on: PostActionCallbacks;
14
- });
8
+ constructor(props: PostActionsGeneratorProps);
15
9
  getPostActionsHandler: (model: PostModel) => PostActionsHandler;
16
10
  }
17
- type PostActionCallbacks = {
18
- attachmentClicked: () => void;
11
+ type PostActionsGeneratorProps = {
12
+ readonly socialInteractionsHandler: IPostSocialInteractionsHandler | undefined;
13
+ readonly sharingHandler: IPostSharingHandler | undefined;
14
+ readonly on: {
15
+ attachmentClicked: () => void;
16
+ };
19
17
  };
20
18
  export {};
@@ -1,24 +1,24 @@
1
1
  import { PostActionsHandler } from './post-actions-handler.svelte';
2
2
  export class PostActionsGenerator {
3
- socialInteractionsHandler;
4
- sharingHandler;
5
- callbacks;
3
+ props;
6
4
  handlers = {};
7
- constructor(init) {
8
- this.socialInteractionsHandler = init.socialInteractionsHandler ?? null;
9
- this.sharingHandler = init.sharingHandler ?? null;
10
- this.callbacks = init.on;
5
+ constructor(props) {
6
+ this.props = props;
11
7
  }
12
8
  getPostActionsHandler = (model) => {
13
9
  let handler = this.handlers[model.id];
14
10
  if (!handler) {
11
+ const props = this.props;
15
12
  handler = new PostActionsHandler({
16
13
  post: model,
17
- socialInteractionsHandler: this.socialInteractionsHandler,
18
- callbacks: {
19
- attachmentClicked: this.callbacks.attachmentClicked,
20
- shareClicked: this.sharingHandler ? () => this.sharingHandler?.share(model.id) : undefined
21
- }
14
+ get socialInteractionsHandler() {
15
+ return props.socialInteractionsHandler ?? null;
16
+ },
17
+ get shareClicked() {
18
+ const sh = props.sharingHandler;
19
+ return sh ? () => sh.share(model.id) : undefined;
20
+ },
21
+ attachmentClicked: props.on.attachmentClicked
22
22
  });
23
23
  this.handlers[model.id] = handler;
24
24
  }
@@ -4,23 +4,20 @@ import type { IconColor } from '@streamscloud/kit/ui/icon';
4
4
  export declare class PostActionsHandler {
5
5
  readonly actions: PostAction[];
6
6
  private post;
7
- private socialInteractionsHandler;
8
- private callbacks;
7
+ private props;
9
8
  private isLikedStore;
10
- constructor(init: {
11
- post: PostModel;
12
- socialInteractionsHandler: IPostSocialInteractionsHandler | null;
13
- callbacks: PostActionCallbacks;
14
- });
9
+ constructor(props: PostActionsHandlerProps);
15
10
  private initIsLikedStore;
16
11
  }
12
+ export type PostActionsHandlerProps = {
13
+ post: PostModel;
14
+ readonly socialInteractionsHandler: IPostSocialInteractionsHandler | null;
15
+ readonly shareClicked: (() => void) | undefined;
16
+ attachmentClicked: () => void;
17
+ };
17
18
  type PostAction = {
18
19
  icon: string;
19
20
  iconColor?: IconColor;
20
21
  callback: () => void;
21
22
  };
22
- type PostActionCallbacks = {
23
- attachmentClicked: () => void;
24
- shareClicked?: () => void;
25
- };
26
23
  export {};
@@ -9,19 +9,20 @@ export class PostActionsHandler {
9
9
  actions = $derived.by(() => {
10
10
  const result = [];
11
11
  if (this.post.attachments) {
12
- result.push({ icon: IconShoppingBag, callback: this.callbacks.attachmentClicked });
12
+ result.push({ icon: IconShoppingBag, callback: this.props.attachmentClicked });
13
13
  }
14
- if (this.post.enableSocialInteractions && this.socialInteractionsHandler) {
14
+ if (this.post.enableSocialInteractions && this.props.socialInteractionsHandler) {
15
15
  result.push({
16
16
  icon: this.isLikedStore.isLiked ? IconHeartFilled : IconHeart,
17
17
  iconColor: this.isLikedStore.isLiked ? 'red' : undefined,
18
- callback: () => this.socialInteractionsHandler?.toggleLike(this.post.id)
18
+ callback: () => this.props.socialInteractionsHandler?.toggleLike(this.post.id)
19
19
  });
20
20
  }
21
- if (this.callbacks.shareClicked) {
21
+ const shareClicked = this.props.shareClicked;
22
+ if (shareClicked) {
22
23
  result.push({
23
24
  icon: IconShare,
24
- callback: () => this.callbacks.shareClicked?.()
25
+ callback: () => shareClicked()
25
26
  });
26
27
  }
27
28
  if (this.post.media && !this.post.media.currentItem.isImage) {
@@ -33,23 +34,22 @@ export class PostActionsHandler {
33
34
  return result;
34
35
  });
35
36
  post;
36
- socialInteractionsHandler;
37
- callbacks;
37
+ props;
38
38
  isLikedStore = $state.raw({
39
39
  get isLiked() {
40
40
  return false;
41
41
  }
42
42
  });
43
- constructor(init) {
44
- this.post = init.post;
45
- this.socialInteractionsHandler = init.socialInteractionsHandler;
46
- this.callbacks = init.callbacks;
43
+ constructor(props) {
44
+ this.post = props.post;
45
+ this.props = props;
47
46
  this.initIsLikedStore();
48
47
  }
49
48
  initIsLikedStore = async () => {
50
- if (!this.socialInteractionsHandler) {
49
+ const handler = this.props.socialInteractionsHandler;
50
+ if (!handler) {
51
51
  return;
52
52
  }
53
- this.isLikedStore = await this.socialInteractionsHandler.getIsLiked(this.post.id);
53
+ this.isLikedStore = await handler.getIsLiked(this.post.id);
54
54
  };
55
55
  }
@@ -79,8 +79,12 @@ const contentPlayerConfig = untrack(() => new PlayerConfig({
79
79
  }
80
80
  }));
81
81
  const postActionsGenerator = untrack(() => new PostActionsGenerator({
82
- socialInteractionsHandler,
83
- sharingHandler,
82
+ get socialInteractionsHandler() {
83
+ return socialInteractionsHandler;
84
+ },
85
+ get sharingHandler() {
86
+ return sharingHandler;
87
+ },
84
88
  on: { attachmentClicked: () => (contentPlayerConfig.uiManager.attachmentsCollapsed = !contentPlayerConfig.uiManager.attachmentsCollapsed) }
85
89
  }));
86
90
  const onProductClick = (id, postId) => {
@@ -3,15 +3,9 @@ import type { PostModel } from '../../posts/model';
3
3
  import type { IPostSocialInteractionsHandler } from '../../posts/social-interactions';
4
4
  import type { IStreamSharingHandler } from '../sharing';
5
5
  export declare class StreamActionsGenerator {
6
- private postSocialInteractionsHandler;
7
- private sharingHandler;
8
- private callbacks;
6
+ private props;
9
7
  private handlers;
10
- constructor(init: {
11
- postSocialInteractionsHandler: IPostSocialInteractionsHandler | undefined;
12
- sharingHandler: IStreamSharingHandler | undefined;
13
- on: StreamActionCallbacks;
14
- });
8
+ constructor(props: StreamActionsGeneratorProps);
15
9
  getPostActionsHandler: (data: {
16
10
  model: PostModel;
17
11
  streamId: string;
@@ -25,7 +19,11 @@ export declare class StreamActionsGenerator {
25
19
  callback: () => (void | Promise<void>) | undefined;
26
20
  }[];
27
21
  }
28
- type StreamActionCallbacks = {
29
- attachmentClicked: () => void;
22
+ type StreamActionsGeneratorProps = {
23
+ readonly postSocialInteractionsHandler: IPostSocialInteractionsHandler | undefined;
24
+ readonly sharingHandler: IStreamSharingHandler | undefined;
25
+ readonly on: {
26
+ attachmentClicked: () => void;
27
+ };
30
28
  };
31
29
  export {};
@@ -1,33 +1,33 @@
1
1
  import { PostActionsHandler } from '../../posts/controls';
2
2
  import IconShare from '@fluentui/svg-icons/icons/share_48_regular.svg?raw';
3
3
  export class StreamActionsGenerator {
4
- postSocialInteractionsHandler;
5
- sharingHandler;
6
- callbacks;
4
+ props;
7
5
  handlers = {};
8
- constructor(init) {
9
- this.postSocialInteractionsHandler = init.postSocialInteractionsHandler ?? null;
10
- this.sharingHandler = init.sharingHandler ?? null;
11
- this.callbacks = init.on;
6
+ constructor(props) {
7
+ this.props = props;
12
8
  }
13
9
  getPostActionsHandler = (data) => {
14
10
  const { model, streamId, streamPageId } = data;
15
11
  let handler = this.handlers[streamPageId];
16
12
  if (!handler) {
13
+ const props = this.props;
17
14
  handler = new PostActionsHandler({
18
15
  post: model,
19
- socialInteractionsHandler: this.postSocialInteractionsHandler,
20
- callbacks: {
21
- attachmentClicked: this.callbacks.attachmentClicked,
22
- shareClicked: this.sharingHandler ? () => this.sharingHandler?.share(streamId) : undefined
23
- }
16
+ get socialInteractionsHandler() {
17
+ return props.postSocialInteractionsHandler ?? null;
18
+ },
19
+ get shareClicked() {
20
+ const sh = props.sharingHandler;
21
+ return sh ? () => sh.share(streamId) : undefined;
22
+ },
23
+ attachmentClicked: props.on.attachmentClicked
24
24
  });
25
25
  this.handlers[streamPageId] = handler;
26
26
  }
27
27
  return handler;
28
28
  };
29
29
  getGeneralStreamPageActions = (data) => {
30
- if (!this.sharingHandler) {
30
+ if (!this.props.sharingHandler) {
31
31
  return [];
32
32
  }
33
33
  const { streamId, streamPageId } = data;
@@ -35,7 +35,7 @@ export class StreamActionsGenerator {
35
35
  return [
36
36
  {
37
37
  icon: IconShare,
38
- callback: () => this.sharingHandler?.share(streamId)
38
+ callback: () => this.props.sharingHandler?.share(streamId)
39
39
  }
40
40
  ];
41
41
  };
@@ -100,8 +100,12 @@ const contentPlayerConfig = untrack(() => new PlayerConfig({
100
100
  }
101
101
  }));
102
102
  const streamActionsGenerator = untrack(() => new StreamActionsGenerator({
103
- postSocialInteractionsHandler,
104
- sharingHandler,
103
+ get postSocialInteractionsHandler() {
104
+ return postSocialInteractionsHandler;
105
+ },
106
+ get sharingHandler() {
107
+ return sharingHandler;
108
+ },
105
109
  on: { attachmentClicked: () => (contentPlayerConfig.uiManager.attachmentsCollapsed = !contentPlayerConfig.uiManager.attachmentsCollapsed) }
106
110
  }));
107
111
  const itemAsPostModel = (item) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/embeddable",
3
- "version": "17.0.2",
3
+ "version": "17.0.4",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",
@@ -146,7 +146,7 @@
146
146
  }
147
147
  },
148
148
  "peerDependencies": {
149
- "@streamscloud/kit": "^0.2.28",
149
+ "@streamscloud/kit": ">=0.2.28",
150
150
  "@streamscloud/streams-analytics-collector": "^4.0.1",
151
151
  "svelte": "^5.51.0"
152
152
  },