@inappstory/react-sdk 1.7.4 → 1.7.6

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 (30) hide show
  1. package/dist/index.esm.mjs +3113 -3593
  2. package/dist/index.esm.mjs.map +1 -1
  3. package/dist/index.umd.js +2 -2
  4. package/dist/types/appearance-manager/appearanceCommon.d.ts +69 -3
  5. package/dist/types/appearance-manager/gameReader.d.ts +83 -4
  6. package/dist/types/appearance-manager/goodsWidget.d.ts +84 -1
  7. package/dist/types/appearance-manager/sharePanel.d.ts +133 -7
  8. package/dist/types/appearance-manager/storiesList.d.ts +303 -5
  9. package/dist/types/appearance-manager/storyReader.d.ts +260 -0
  10. package/dist/types/events.d.ts +212 -0
  11. package/dist/types/ias-container/IasContainer.d.ts +24 -0
  12. package/dist/types/ias-container/appearanceOptionsProps.d.ts +20 -1
  13. package/dist/types/ias-container/index.d.ts +1 -2
  14. package/dist/types/ias-container/storyManagerEventsProps.d.ts +110 -4
  15. package/dist/types/in-app-messaging/iamErrors.d.ts +49 -45
  16. package/dist/types/in-app-messaging/inAppMessaging.d.ts +166 -0
  17. package/dist/types/index.d.ts +2 -1
  18. package/dist/types/story-list/FavoriteStoryList.d.ts +51 -1
  19. package/dist/types/story-list/StoryList.d.ts +169 -0
  20. package/dist/types/story-list/UGCStoryList.d.ts +61 -0
  21. package/dist/types/story-list/navigationViewModel.d.ts +43 -0
  22. package/dist/types/story-list/storyCardViewModel.d.ts +87 -3
  23. package/dist/types/story-list/storyListApi.d.ts +3 -2
  24. package/dist/types/story-list/storyListLoadStatus.ts +47 -10
  25. package/dist/types/storyManager.d.ts +205 -6
  26. package/package.json +6 -2
  27. package/plugins/dotLottie/iasDotLottiePlugin.umd.js +1 -1
  28. package/plugins/videoOnDemand/iasVideoOnDemandPlugin.umd.js +1 -1
  29. package/dist/types/appearance-manager/storyReader.ts +0 -125
  30. package/dist/types/ias-container/publicEvents.d.ts +0 -104
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Base StoryReader event.
3
+ * Used as a foundation for most story-related events.
4
+ */
5
+ export interface StoryReaderEvent {
6
+ /** Unique story identifier */
7
+ id: number;
8
+ /** Story title (optional) */
9
+ title?: string;
10
+ /** Number of slides in the story */
11
+ slidesCount?: number;
12
+ /** Feed name where the story was loaded from */
13
+ feed?: string;
14
+ /** Source of story launch (e.g., deeplink, banner) */
15
+ source?: string;
16
+ /** Filters applied to the story list */
17
+ filter: Record<string, unknown>;
18
+ /** User-generated payload (e.g., UGC data) */
19
+ ugcPayload: Record<string, unknown>;
20
+ /** Number of items in the default list */
21
+ defaultListLength: number;
22
+ /** Number of items in the favorites list */
23
+ favoriteListLength: number;
24
+ }
25
+
26
+ /**
27
+ * Possible reasons for closing StoryReader.
28
+ */
29
+ export enum CloseAction {
30
+ /** Closed via the close (X) button in UI */
31
+ closeReaderByCloseBtn = "closeReaderByCloseBtn",
32
+ /** Closed via ESC key (desktop only) */
33
+ closeReaderByEscBtn = "closeReaderByEscBtn",
34
+ /** Closed by swipe down (mobile only) */
35
+ swipeDown = "swipeDown",
36
+ /** Closed by swipe to next story (mobile only) */
37
+ swipe = "swipe",
38
+ /** Closed by clicking the first (backward) or last (forward) slide */
39
+ lastSlideClick = "lastSlideClick",
40
+ /** Closed automatically by timer transition to next story */
41
+ auto = "auto",
42
+ /** Closed using public API: StoryManager.closeStoryReader */
43
+ externalCloseReader = "externalCloseReader"
44
+ }
45
+
46
+ /** Event: story was shown */
47
+ export interface ShowStoryEvent extends StoryReaderEvent {}
48
+
49
+ /** Event: story was closed */
50
+ export interface CloseStoryEvent extends StoryReaderEvent {
51
+ /** Close reason */
52
+ action: CloseAction;
53
+ }
54
+
55
+ /** Event: user clicked on a story */
56
+ export interface ClickOnStoryEvent extends StoryReaderEvent {
57
+ /** Story index inside feed */
58
+ index: number;
59
+ /** Whether the click was triggered by deeplink */
60
+ isDeeplink: boolean;
61
+ /** URL if click leads externally */
62
+ url?: string;
63
+ }
64
+
65
+ /** Event: specific slide was shown */
66
+ export interface ShowSlideEvent extends StoryReaderEvent {
67
+ /** Index of the current slide */
68
+ index: number;
69
+ /** Slide payload (e.g., JSON data) */
70
+ payload: string;
71
+ }
72
+
73
+ /** Event: story was liked */
74
+ export interface LikeStoryEvent extends StoryReaderEvent {
75
+ /** true — liked, false — unliked */
76
+ value: boolean;
77
+ }
78
+
79
+ /** Event: story was disliked */
80
+ export interface DislikeStoryEvent extends StoryReaderEvent {
81
+ /** true — disliked, false — undisliked */
82
+ value: boolean;
83
+ }
84
+
85
+ /** Event: story was added/removed from favorites */
86
+ export interface FavoriteStoryEvent extends StoryReaderEvent {
87
+ /** true — added, false — removed */
88
+ value: boolean;
89
+ }
90
+
91
+ /** Event: story was shared */
92
+ export interface ShareStoryEvent extends StoryReaderEvent {}
93
+
94
+ /** Event: story was shared with a given URL */
95
+ export interface ShareStoryWithPathEvent extends StoryReaderEvent {
96
+ /** URL used for sharing */
97
+ url: string;
98
+ }
99
+
100
+ /** Event: user clicked on the "favorites" cell */
101
+ export interface ClickOnFavoriteCellEvent {
102
+ /** Feed name where the click happened */
103
+ feed: string;
104
+ }
105
+
106
+ /** Event: feed was loaded */
107
+ export interface FeedLoadEvent {
108
+ /** Feed name */
109
+ feed: string;
110
+ /** List of stories in the feed */
111
+ stories: Array<{ id: number; title: string; slidesCount: number }>;
112
+ }
113
+
114
+ /** Event: feed impression (visible stories) */
115
+ export interface FeedImpressionEvent {
116
+ /** Feed name */
117
+ feed: string;
118
+ /** Stories that entered visible area */
119
+ stories: Array<{ id: number; title: string; slidesCount: number }>;
120
+ }
121
+
122
+ /** Event: visible area with stories was updated */
123
+ export interface VisibleAreaUpdatedEvent {
124
+ /** Feed name */
125
+ feed: string;
126
+ /** Stories that became visible */
127
+ stories: Array<{ id: number; title: string; slidesCount: number }>;
128
+ }
129
+
130
+ /** Generic widget event */
131
+ export interface WidgetEvent {
132
+ /** Event name */
133
+ name: string;
134
+ /** Event data */
135
+ data: any;
136
+ }
137
+
138
+ /** Event: mini-game started */
139
+ export interface StartGameEvent {
140
+ /** Game ID */
141
+ id: string;
142
+ }
143
+
144
+ /** Event: mini-game closed */
145
+ export interface CloseGameEvent {
146
+ /** Game ID */
147
+ id: string;
148
+ }
149
+
150
+ /** Event: mini-game finished */
151
+ export interface FinishGameEvent {
152
+ /** Game ID */
153
+ id: string;
154
+ /** Game result */
155
+ result: Record<string, any>;
156
+ }
157
+
158
+ /** Generic game event */
159
+ export interface EventGameEvent {
160
+ /** Event name */
161
+ name: string;
162
+ /** Event payload */
163
+ payload: Record<string, any>;
164
+ }
165
+ /**
166
+ * All StoryManager events that can be emitted externally.
167
+ */
168
+ export interface StoryManagerEvents {
169
+ /** Story preview card is clicked */
170
+ clickOnStory: ClickOnStoryEvent;
171
+ /** Story is shown */
172
+ showStory: ShowSlideEvent;
173
+ /** Story is closed */
174
+ closeStory: CloseStoryEvent;
175
+ /** Slide is shown */
176
+ showSlide: ShowSlideEvent;
177
+ /** Story was liked */
178
+ likeStory: LikeStoryEvent;
179
+ /** Story was disliked */
180
+ dislikeStory: DislikeStoryEvent;
181
+ /** Story added/removed from favorites */
182
+ favoriteStory: FavoriteStoryEvent;
183
+ /** Story was shared */
184
+ shareStory: ShareStoryEvent;
185
+ /** Story shared with a given URL */
186
+ shareStoryWithPath: ShareStoryWithPathEvent;
187
+ /** Feed impression */
188
+ feedImpression: FeedImpressionEvent;
189
+ /** Visible area with stories was updated */
190
+ visibleAreaUpdated: VisibleAreaUpdatedEvent;
191
+ /** Widget event */
192
+ widgetEvent: WidgetEvent;
193
+ /** Game started */
194
+ startGame: StartGameEvent;
195
+ /** Game closed */
196
+ closeGame: CloseGameEvent;
197
+ /** Game finished */
198
+ finishGame: FinishGameEvent;
199
+ /** Custom game event */
200
+ eventGame: EventGameEvent;
201
+ /**
202
+ * @deprecated
203
+ * See https://docs.inappstory.com/sdk-guides/react-sdk/link-handling.html
204
+ */
205
+ clickOnButton: any;
206
+ }
207
+
208
+ /**
209
+ * @deprecated
210
+ * Use StoryManagerEvents instead
211
+ */
212
+ export type PublicEvents = StoryManagerEvents;
@@ -2,9 +2,33 @@ import { StoryManagerConfig } from "..";
2
2
  import { StoryManagerEventsProps } from "./storyManagerEventsProps";
3
3
  import { AppearanceOptionsProps } from "./appearanceOptionsProps";
4
4
 
5
+ /**
6
+ * Props interface for IASContainer component.
7
+ * @extends StoryManagerEventsProps
8
+ * @extends AppearanceOptionsProps
9
+ */
5
10
  interface IASContainerProps extends StoryManagerEventsProps, AppearanceOptionsProps {
11
+ /** Configuration object for StoryManager. Must include API key. */
6
12
  config: StoryManagerConfig;
13
+ /** Optional child components to be rendered inside the container.
14
+ * Typically includes StoryList or other InAppStory components. */
7
15
  children?: React.ReactNode;
8
16
  }
9
17
 
18
+ /**
19
+ * Main container for InAppStory SDK.
20
+ *
21
+ * Provides `StoryManager` context and renders the necessary readers (`StoryReader`, `GameReader` etc).
22
+ *
23
+ * @example
24
+ * // Basic usage with StoryList
25
+ * <IASContainer config={{
26
+ apiKey: "{your-integration-key}",
27
+ }}>
28
+ * <StoryList feedSlug="default" />
29
+ * </IASContainer>
30
+ *
31
+ * @param {IASContainerProps} props Properties including config, appearance options and event handlers
32
+ * @returns {JSX.Element} Provider component that enables InAppStory functionality for child components
33
+ */
10
34
  export declare const IASContainer: (props: IASContainerProps) => JSX.Element;
@@ -2,12 +2,31 @@ import {
2
2
  AppearanceCommonOptions,
3
3
  GameReaderOptions,
4
4
  GoodsWidgetOptions,
5
- StoryReaderOptions,
5
+ StoryReaderOptions
6
6
  } from "../appearance-manager";
7
7
 
8
+ /**
9
+ * Appearance customization options.
10
+ * Allows styling different parts of the InAppStory
11
+ */
8
12
  export interface AppearanceOptionsProps {
13
+ /**
14
+ * Common appearance options applied across All IAS components
15
+ */
9
16
  commonOptions?: AppearanceCommonOptions;
17
+
18
+ /**
19
+ * Customization options specific to the Story Reader component
20
+ */
10
21
  storyReaderOptions?: StoryReaderOptions;
22
+
23
+ /**
24
+ * Customization options specific to the Game Reader component
25
+ */
11
26
  gameReaderOptions?: GameReaderOptions;
27
+
28
+ /**
29
+ * Customization options for the Goods Widget (V1) appearance
30
+ */
12
31
  goodsWidgetOptions?: GoodsWidgetOptions;
13
32
  }
@@ -1,2 +1 @@
1
- export { IASContainer } from './IasContainer';
2
- export * from "./publicEvents"
1
+ export { IASContainer } from './IasContainer';
@@ -1,5 +1,4 @@
1
1
  import {
2
- ClickOnButtonEvent,
3
2
  ClickOnStoryEvent,
4
3
  CloseStoryEvent,
5
4
  DislikeStoryEvent,
@@ -11,21 +10,128 @@ import {
11
10
  ShowSlideEvent,
12
11
  ShowStoryEvent,
13
12
  VisibleAreaUpdatedEvent,
14
- WidgetEvent
15
- } from "./publicEvents";
13
+ WidgetEvent,
14
+ StartGameEvent,
15
+ FinishGameEvent,
16
+ CloseGameEvent,
17
+ EventGameEvent
18
+ } from "../events";
16
19
 
20
+ /**
21
+ * Interface for `StoryManager` event handlers.
22
+ * Contains callback props for various events that occur during story interactions.
23
+ * All event handlers are optional and follow the naming pattern `on[EventName]`.
24
+ *
25
+ * Each event handler receives a specific event object with relevant data about the interaction.
26
+ *
27
+ * @example
28
+ * // Example of using event handlers
29
+ * <IASContainer
30
+ * onShowStory={(event) => console.log('Story shown:', event.id)}
31
+ * onCloseStory={(event) => console.log('Story closed:', event.id)}
32
+ * />
33
+ */
17
34
  export interface StoryManagerEventsProps {
35
+ /**
36
+ * Called when a user clicks on a story in the story list
37
+ * @param event - Contains story ID and other metadata
38
+ */
18
39
  onClickOnStory?: (event: ClickOnStoryEvent) => void;
40
+
41
+ /**
42
+ * Called when a story becomes visible in the reader
43
+ * @param event - Contains story ID and opening context
44
+ */
19
45
  onShowStory?: (event: ShowStoryEvent) => void;
46
+
47
+ /**
48
+ * Called when a story is closed
49
+ * @param event - Contains story ID and close action
50
+ */
20
51
  onCloseStory?: (event: CloseStoryEvent) => void;
52
+
53
+ /**
54
+ * Called when a new slide is shown in the story
55
+ * @param event - Contains story ID and slide index
56
+ */
21
57
  onShowSlide?: (event: ShowSlideEvent) => void;
22
- onClickOnButton?: (event: ClickOnButtonEvent) => void;
58
+
59
+ /**
60
+ * Called when a user likes a story
61
+ * @param event - Contains story ID and like status
62
+ */
23
63
  onLikeStory?: (event: LikeStoryEvent) => void;
64
+
65
+ /**
66
+ * Called when a user dislikes a story
67
+ * @param event - Contains story ID and dislike status
68
+ */
24
69
  onDislikeStory?: (event: DislikeStoryEvent) => void;
70
+
71
+ /**
72
+ * Called when a user favorites a story
73
+ * @param event - Contains story ID and favorite status
74
+ */
25
75
  onFavoriteStory?: (event: FavoriteStoryEvent) => void;
76
+
77
+ /**
78
+ * Called when a user shares a story (without specific path)
79
+ * @param event - Contains story ID and share method
80
+ */
26
81
  onShareStory?: (event: ShareStoryEvent) => void;
82
+
83
+ /**
84
+ * Called when a user shares a story with a specific path/slide
85
+ * @param event - Contains story ID, slide index, and share method
86
+ */
27
87
  onShareStoryWithPath?: (event: ShareStoryWithPathEvent) => void;
88
+
89
+ /**
90
+ * Called when stories feed becomes visible to the user
91
+ * @param event - Contains feed slug and impression data
92
+ */
28
93
  onFeedImpression?: (event: FeedImpressionEvent) => void;
94
+
95
+ /**
96
+ * Called when the visible area of stories in a feed changes
97
+ * @param event - Contains visibility information for stories in viewport
98
+ */
29
99
  onVisibleAreaUpdated?: (event: VisibleAreaUpdatedEvent) => void;
100
+
101
+ /**
102
+ * Generic handler for widget-specific events
103
+ * @param event - Contains widget type and event-specific data
104
+ */
30
105
  onWidgetEvent?: (event: WidgetEvent) => void;
106
+
107
+ /**
108
+ * Called when a game is started inside the story
109
+ * @param event - Contains game identifier
110
+ */
111
+ onStartGame?: (event: StartGameEvent) => void;
112
+
113
+ /**
114
+ * Called when a game is closed by user or system
115
+ * @param event - Contains game identifier
116
+ */
117
+ onCloseGame?: (event: CloseGameEvent) => void;
118
+
119
+ /**
120
+ * Called when a game finishes
121
+ * @param event - Contains game identifier and result payload
122
+ */
123
+ onFinishGame?: (event: FinishGameEvent) => void;
124
+
125
+ /**
126
+ * Called on custom in-game events
127
+ * @param event - Contains event name and custom payload
128
+ */
129
+ onEventGame?: (event: EventGameEvent) => void;
130
+
131
+ /**
132
+ *
133
+ * @deprecated
134
+ * See https://docs.inappstory.com/sdk-guides/react-sdk/link-handling.html
135
+ */
136
+ onClickOnButton?: (event: any) => void;
31
137
  }
@@ -1,48 +1,52 @@
1
- export declare class IamNotFoundByEventError extends Error {
2
- constructor(eventName: string);
3
- name: string;
4
- }
5
-
6
- export declare class IamNotFoundByIdError extends Error {
7
- constructor(messageId: string | number);
8
- name: string;
9
- }
10
-
11
- export declare class IamNotFoundLimitError extends Error {
12
- constructor(messageId: string | number);
13
- name: string;
14
- }
15
-
16
- export declare class IamMessageOpenError extends Error {
17
- constructor(messageId: string | number);
18
- name: string;
19
- }
20
-
21
- export declare class IamOtherReaderIsOpenError extends Error {
22
- constructor();
23
- name: string;
24
- }
25
-
26
- export declare class IamShowOnlyIfLoadedError extends Error {
27
- constructor();
28
- name: string;
29
- }
30
-
31
- export declare class IamFrequencyLimitError extends Error {
32
- constructor();
33
- name: string;
34
- }
35
-
36
- export declare class IamCheckDisplayTimeRangeError extends Error {
37
- constructor();
38
- name: string;
39
- }
40
-
41
- export declare class IamMessageLimitExceededError extends Error {
42
- constructor(messageId: string | number);
43
- name: string;
44
- }
45
-
1
+ /**
2
+ * Error thrown when no message is found matching the specified event name
3
+ */
4
+ export declare class IamNotFoundByEventError extends Error {}
5
+
6
+ /**
7
+ * Error thrown when no message is found matching the specified message ID
8
+ */
9
+ export declare class IamNotFoundByIdError extends Error {}
10
+
11
+ /**
12
+ * Error thrown when no display limit configuration is found for the specified message
13
+ */
14
+ export declare class IamNotFoundLimitError extends Error {}
15
+
16
+ /**
17
+ * Error thrown when attempting to open a message that is already open
18
+ */
19
+ export declare class IamMessageOpenError extends Error {}
20
+
21
+ /**
22
+ * Error thrown when attempting to open a message while another reader is active
23
+ */
24
+ export declare class IamOtherReaderIsOpenError extends Error {}
25
+
26
+ /**
27
+ * Error thrown when attempting to show a message that hasn't been preloaded,
28
+ * when the showOnlyIfLoaded option is enabled
29
+ */
30
+ export declare class IamShowOnlyIfLoadedError extends Error {}
31
+
32
+ /**
33
+ * Error thrown when a message's frequency limit has been exceeded
34
+ */
35
+ export declare class IamFrequencyLimitError extends Error {}
36
+
37
+ /**
38
+ * Error thrown when attempting to show a message outside its allowed display time range
39
+ */
40
+ export declare class IamCheckDisplayTimeRangeError extends Error {}
41
+
42
+ /**
43
+ * Error thrown when a message's display limit has been exceeded
44
+ */
45
+ export declare class IamMessageLimitExceededError extends Error {}
46
+
47
+ /**
48
+ * Union type representing all possible In-App Messaging error types
49
+ */
46
50
  export type IamError =
47
51
  | IamNotFoundByEventError
48
52
  | IamNotFoundByIdError