@inappstory/react-sdk 1.8.0-rc.1 → 1.8.0-rc.10

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.
@@ -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;
@@ -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,8 +10,12 @@ 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
 
17
20
  /**
18
21
  * Interface for `StoryManager` event handlers.
@@ -53,12 +56,6 @@ export interface StoryManagerEventsProps {
53
56
  */
54
57
  onShowSlide?: (event: ShowSlideEvent) => void;
55
58
 
56
- /**
57
- * Called when a user clicks on an interactive button in the story
58
- * @param event - Contains URL
59
- */
60
- onClickOnButton?: (event: ClickOnButtonEvent) => void;
61
-
62
59
  /**
63
60
  * Called when a user likes a story
64
61
  * @param event - Contains story ID and like status
@@ -106,4 +103,35 @@ export interface StoryManagerEventsProps {
106
103
  * @param event - Contains widget type and event-specific data
107
104
  */
108
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;
109
137
  }
@@ -2,4 +2,5 @@ export * from "./appearance-manager";
2
2
  export * from "./story-list";
3
3
  export * from "./storyManager";
4
4
  export * from "./ias-container";
5
- export * from "./in-app-messaging"
5
+ export * from "./in-app-messaging"
6
+ export * from "./events"
@@ -1,3 +1,4 @@
1
+ import { StoryManagerEvents } from "./events";
1
2
  import { PublicEventHandler, PublicEvents } from "./ias-container";
2
3
  import { InAppMessaging } from "./in-app-messaging/inAppMessaging";
3
4
 
@@ -38,7 +39,7 @@ export type StoryManagerConfig = {
38
39
  placeholders?: Record<string, string>;
39
40
  /** Image placeholders to be replaced in stories (optional)
40
41
  * @see https://docs.inappstory.com/sdk-guides/js-sdk/placeholders.html
41
- * @example
42
+ * @example
42
43
  * imagePlaceholders: {
43
44
  * "your-image-placeholder-key": "value"
44
45
  * }
@@ -52,6 +53,55 @@ export type StoryManagerConfig = {
52
53
  * @see https://docs.inappstory.com/sdk-guides/react-sdk/user-settings.html#overview
53
54
  */
54
55
  disableDeviceId?: boolean;
56
+ /**
57
+ * Use anonymous session. Warning: not all functionality will be available.
58
+ */
59
+ anonymous?: boolean;
60
+
61
+ /**
62
+ * The field is responsible for passing user variables and widget variables (for example, the "products" widget)
63
+ */
64
+ options?: {
65
+ /**
66
+ * Point of sale
67
+ */
68
+ pos?: string;
69
+ } & Record<string, any>;
70
+
71
+ /**
72
+ * A local BLOB-based cache used to prefetch data or as a fallback when the standard HTTP cache is unavailable (e.g., in environments with limited WebView).
73
+ * */
74
+ cache?: {
75
+ /** Cache type: 'memory' — fast but temporary; 'indexeddb' — persistent
76
+ * @default "indexeddb"
77
+ */
78
+ type: "memory" | "indexeddb";
79
+
80
+ /** Maximum cache size (e.g., in bytes or number of elements)
81
+ * @default 20
82
+ */
83
+ maxSize?: number;
84
+
85
+ /** Resource lifetime in the cache (in seconds).
86
+ * @default 0 (infinite)
87
+ */
88
+ ttl?: number;
89
+
90
+ /** Cache operation logging (for debugging)
91
+ * @default false
92
+ */
93
+ debug?: boolean;
94
+
95
+ /** Maximum number of parallel requests
96
+ * @default 5
97
+ */
98
+ concurrency?: number;
99
+
100
+ /** Prefetch resources
101
+ * @default false
102
+ */
103
+ prefetch?: boolean;
104
+ };
55
105
  };
56
106
 
57
107
  /**
@@ -78,7 +128,6 @@ export type UgcEditorConfig = {
78
128
 
79
129
  /**
80
130
  * Handler for story link click events.
81
- * @deprecated Use `clickOnButton` event instead
82
131
  */
83
132
  export type StoryLinkClickHandler = (payload: {
84
133
  data: { id: number; index: number; isDeeplink: boolean; url: string };
@@ -118,8 +167,6 @@ export declare class StoryManager {
118
167
  * storyManager.storyLinkClickHandler = ({ data, src }) => {
119
168
  * console.log("Link clicked:", data.url, "from", src);
120
169
  * };
121
- * @deprecated Use `clickOnButton` event instead
122
- * @see https://docs.inappstory.com/sdk-guides/reack-sdk/link-handling.html
123
170
  */
124
171
  set storyLinkClickHandler(value: StoryLinkClickHandler);
125
172
 
@@ -149,10 +196,10 @@ export declare class StoryManager {
149
196
  };
150
197
 
151
198
  */
152
- showOnboardingStories(options?: { feed?: string; customTags?: Array<string>; limit?: number }): Promise<{
199
+ showOnboardingStories(options?: { feed?: string; customTags?: string[]; limit?: number }): Promise<{
153
200
  stories: {
154
201
  title: Option<string>;
155
- tags: Array<string>;
202
+ tags: string[];
156
203
  slidesCount: Option<number>;
157
204
  ugcPayload?: Record<string, unknown>;
158
205
  id: number;
@@ -185,12 +232,11 @@ export declare class StoryManager {
185
232
  /**
186
233
  * Opens a game by its instance ID.
187
234
  * @param gameInstanceId Game instance identifier
188
- * @param gameOptions Optional game parameters
189
235
  * @see https://docs.inappstory.com/sdk-guides/react-sdk/games.html
190
236
  * @example
191
237
  * storyManager.openGame("your-game-id")
192
238
  */
193
- openGame(gameInstanceId: string | number, gameOptions?: { demoMode?: boolean }): Promise<void>;
239
+ openGame(gameInstanceId: string | number): Promise<void>;
194
240
 
195
241
  /**
196
242
  * Closes the currently active game, if any.
@@ -221,7 +267,10 @@ export declare class StoryManager {
221
267
  * @param listener The event handler
222
268
  * @see https://docs.inappstory.com/sdk-guides/react-sdk/events.html
223
269
  */
224
- on<Event extends keyof PublicEvents>(eventName: Event, listener: PublicEventHandler<Event>): this;
270
+ on<EventName extends keyof StoryManagerEvents>(
271
+ eventName: EventName,
272
+ listener: (event: StoryManagerEvents[EventName]) => void
273
+ ): this;
225
274
 
226
275
  /**
227
276
  * Subscribes to a one-time SDK event.
@@ -229,7 +278,10 @@ export declare class StoryManager {
229
278
  * @param listener The event handler
230
279
  * @see https://docs.inappstory.com/sdk-guides/react-sdk/events.html
231
280
  */
232
- once<Event extends keyof PublicEvents>(eventName: Event, listener: PublicEventHandler<Event>): this;
281
+ once<EventName extends keyof StoryManagerEvents>(
282
+ eventName: EventName,
283
+ listener: (event: StoryManagerEvents[EventName]) => void
284
+ ): this;
233
285
 
234
286
  /**
235
287
  * Unsubscribes from an SDK event.
@@ -237,7 +289,10 @@ export declare class StoryManager {
237
289
  * @param listener The event handler
238
290
  * @see https://docs.inappstory.com/sdk-guides/react-sdk/events.html
239
291
  */
240
- off<Event extends keyof PublicEvents>(eventName: Event, listener: PublicEventHandler<Event>): this;
292
+ off<EventName extends keyof StoryManagerEvents>(
293
+ eventName: EventName,
294
+ listener: (event: StoryManagerEvents[EventName]) => void
295
+ ): this;
241
296
 
242
297
  /**
243
298
  * Installs a plugin at the class level.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inappstory/react-sdk",
3
- "version": "1.8.0-rc.1",
3
+ "version": "1.8.0-rc.10",
4
4
  "description": "React SDK",
5
5
  "keywords": [
6
6
  "stories",
@@ -58,7 +58,7 @@
58
58
  "Samsung >= 5"
59
59
  ],
60
60
  "dependencies": {
61
- "@inappstory/slide-api": "^0.1.21",
61
+ "@inappstory/slide-api": "^0.1.24",
62
62
  "async-mutex": "^0.5.0",
63
63
  "bowser": "^2.11.0",
64
64
  "classnames": "^2.5.1",