@streamscloud/embeddable 17.0.2 → 17.0.3

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.
@@ -249,8 +249,12 @@ const onAdImpression = (adId) => {
249
249
  };
250
250
  // ── Action buttons (like, share, attachments toggle) ──
251
251
  const postActionsGenerator = untrack(() => new PostActionsGenerator({
252
- socialInteractionsHandler,
253
- sharingHandler,
252
+ get socialInteractionsHandler() {
253
+ return socialInteractionsHandler;
254
+ },
255
+ get sharingHandler() {
256
+ return sharingHandler;
257
+ },
254
258
  on: { attachmentClicked: () => (sidebarCollapsed = !sidebarCollapsed) }
255
259
  }));
256
260
  const itemActions = $derived.by(() => {
@@ -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.3",
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
  },