@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
@@ -1,27 +1,111 @@
1
1
  import { StoriesListCardOptions, StoriesListCardCoverQuality, StoriesListCardViewVariant } from "../appearance-manager";
2
2
 
3
+ /**
4
+ * Represents the view model for a story preview card in the stories list
5
+ */
3
6
  export interface StoryCardViewModel {
7
+ /**
8
+ * Unique identifier of the story
9
+ */
4
10
  id: number;
11
+
12
+ /**
13
+ * Title of the story
14
+ */
5
15
  title: string;
16
+
17
+ /**
18
+ * Color of the title text in HEX format
19
+ */
6
20
  titleColor: string;
7
- magazineName: string;
21
+
22
+ /**
23
+ * Background color of the card in HEX format
24
+ */
8
25
  backgroundColor: string;
26
+
27
+ /**
28
+ * Background configuration of the card
29
+ */
9
30
  background: {
31
+ /**
32
+ * Background color in HEX format
33
+ */
10
34
  color: string;
35
+
36
+ /**
37
+ * Whether the background uses gradient effect
38
+ */
11
39
  gradient: boolean;
12
40
  };
41
+
42
+ /**
43
+ * Indicates if the story is marked as favorite
44
+ */
13
45
  favorite: boolean;
46
+
47
+ /**
48
+ * Number of likes the story has received
49
+ */
14
50
  like: number;
51
+
52
+ /**
53
+ * Deeplink URL for navigation when card is clicked (null if not available)
54
+ */
15
55
  deeplink: string | null;
56
+
57
+ /**
58
+ * Whether the story should be hidden in the reader
59
+ */
16
60
  hideInReader: boolean | null;
61
+
62
+ /**
63
+ * Game instance details (if the story is a game)
64
+ */
17
65
  gameInstance?: { id?: string };
66
+
67
+ /**
68
+ * Whether the story contains audio
69
+ */
18
70
  hasAudio: boolean | null;
71
+
72
+ /**
73
+ * Whether this card represents a favorite stories collection
74
+ */
19
75
  isFavoriteCard: boolean;
76
+
77
+ /**
78
+ * Whether this is a User Generated Content (UGC) card
79
+ */
20
80
  isUgcCard: boolean;
81
+
82
+ /**
83
+ * Whether the story is currently opened/being viewed
84
+ */
21
85
  isOpened: boolean;
86
+
87
+ /**
88
+ * URL source for the video cover (null if not available)
89
+ */
22
90
  videoCoverSrc: string | null;
23
91
 
24
- getAspectRatio(variant: StoriesListCardViewVariant): number
25
- getImageSrcByCoverQuality(coverQuality: StoriesListCardCoverQuality): string | undefined
92
+ /**
93
+ * Calculates the aspect ratio for the card based on view variant
94
+ * @param variant - The card view variant/style
95
+ * @returns The aspect ratio (width/height)
96
+ */
97
+ getAspectRatio(variant: StoriesListCardViewVariant): number;
98
+
99
+ /**
100
+ * Gets the appropriate image source URL based on requested quality
101
+ * @param coverQuality - The desired image quality level
102
+ * @returns The image URL or undefined if not available
103
+ */
104
+ getImageSrcByCoverQuality(coverQuality: StoriesListCardCoverQuality): string | undefined;
105
+
106
+ /**
107
+ * Handles click interaction with the story card
108
+ * @param index - Optional position index of the card in the list
109
+ */
26
110
  onClick(index?: number): void;
27
111
  }
@@ -1,3 +1,4 @@
1
1
  export interface StoryListApi {
2
- reload(): void
3
- }
2
+ /** Reload stories */
3
+ reload(): void;
4
+ }
@@ -1,12 +1,49 @@
1
+ /**
2
+ * Represents the loading status and metadata for a story list
3
+ */
1
4
  export interface StoryListLoadStatus {
2
- feed: string | number,
3
- filter: Record<string, any> | null,
4
- defaultListLength: number,
5
- favoriteListLength: number,
6
- success: boolean,
5
+ /**
6
+ * The feed identifier that was loaded
7
+ */
8
+ feed: string;
9
+
10
+ /**
11
+ * Applied filters for the story list, or null if no filters were applied
12
+ */
13
+ filter: Record<string, any> | null;
14
+
15
+ /**
16
+ * Number of items in the default (non-favorite) story list
17
+ */
18
+ defaultListLength: number;
19
+
20
+ /**
21
+ * Number of items in the favorites list
22
+ */
23
+ favoriteListLength: number;
24
+
25
+ /**
26
+ * Indicates whether the loading operation was successful
27
+ */
28
+ success: boolean;
29
+
30
+ /**
31
+ * Error details if the loading failed, or null if successful
32
+ */
7
33
  error: {
8
- name: string,
9
- networkStatus: number,
10
- networkMessage: string
11
- } | null
12
- }
34
+ /**
35
+ * Name/type of the error that occurred
36
+ */
37
+ name: string;
38
+
39
+ /**
40
+ * HTTP status code or network error code
41
+ */
42
+ networkStatus: number;
43
+
44
+ /**
45
+ * Human-readable error message from the network request
46
+ */
47
+ networkMessage: string;
48
+ } | null;
49
+ }
@@ -1,56 +1,170 @@
1
+ import { StoryManagerEvents } from "./events";
1
2
  import { PublicEventHandler, PublicEvents } from "./ias-container";
2
3
  import { InAppMessaging } from "./in-app-messaging/inAppMessaging";
3
4
 
5
+ /**
6
+ * Source of the link click within stories.
7
+ */
4
8
  export declare enum LinkSource {
5
9
  StoryList = "storyList",
6
10
  StoryReader = "storyReader",
7
11
  GameReader = "gameReader"
8
12
  }
9
13
 
14
+ /**
15
+ * Configuration options for initializing the StoryManager.
16
+ */
10
17
  export type StoryManagerConfig = {
18
+ /** API integration key for initializing the SDK */
11
19
  apiKey: string;
20
+ /** Unique user identifier (optional)
21
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/user-settings.html
22
+ */
12
23
  userId?: string | number;
24
+ /** Signature for the userId for validation (optional)
25
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/user-settings.html
26
+ */
13
27
  userIdSign?: string;
28
+ /** Tags used to filter stories (optional)
29
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/tags.html
30
+ */
14
31
  tags?: Array<string>;
32
+ /** Text placeholders to be replaced in stories (optional)
33
+ * @see https://docs.inappstory.com/sdk-guides/js-sdk/placeholders.html
34
+ * @example
35
+ * placeholders: {
36
+ * "your-placeholder-key": "value"
37
+ * }
38
+ */
15
39
  placeholders?: Record<string, string>;
40
+ /** Image placeholders to be replaced in stories (optional)
41
+ * @see https://docs.inappstory.com/sdk-guides/js-sdk/placeholders.html
42
+ * @example
43
+ * imagePlaceholders: {
44
+ * "your-image-placeholder-key": "value"
45
+ * }
46
+ */
16
47
  imagePlaceholders?: Record<string, string>;
48
+ /** Language code for content display (e.g., 'en-US') (optional) */
17
49
  lang?: string;
50
+ /** Text direction (optional): 'ltr' or 'rtl' */
18
51
  dir?: "ltr" | "rtl";
52
+ /** Disables automatic deviceId generation
53
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/user-settings.html#overview
54
+ */
19
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>;
20
70
  };
21
71
 
72
+ /**
73
+ * Configuration for the user-generated content (UGC) editor.
74
+ */
22
75
  export type UgcEditorConfig = {
76
+ /** Unique session identifier */
23
77
  sessionId: string;
78
+ /** SDK API key */
24
79
  apiKey: string;
80
+ /** Editor configuration (customizable externally) */
25
81
  editor: Record<any, any>;
82
+ /** SDK version */
26
83
  sdkVersion: string;
84
+ /** App package identifier (optional) */
27
85
  appPackageId?: string;
86
+ /** Unique device identifier */
28
87
  deviceId: string;
88
+ /** User identifier (optional) */
29
89
  userId?: string;
90
+ /** Language code for the editor */
30
91
  lang: string;
31
92
  };
32
93
 
94
+ /**
95
+ * Handler for story link click events.
96
+ */
33
97
  export type StoryLinkClickHandler = (payload: {
34
98
  data: { id: number; index: number; isDeeplink: boolean; url: string };
35
99
  src: LinkSource;
36
100
  }) => void;
37
101
 
102
+ /**
103
+ * Interface for external plugin integration with the StoryManager.
104
+ */
38
105
  export interface Plugin {
106
+ /** Unique plugin name */
39
107
  name: string;
108
+ /** Called when the plugin is installed */
40
109
  install(storyManager: StoryManager, options?: any): void;
110
+ /** Called when the plugin is uninstalled */
41
111
  uninstall(storyManager: StoryManager, options?: any): void;
42
112
  }
43
113
 
114
+ /**
115
+ * Main class for managing stories and games
116
+ */
44
117
  export declare class StoryManager {
118
+ /** SDK version name (e.g., '1.7.0') */
45
119
  get sdkVersionName(): string;
120
+
121
+ /** Numeric SDK version code (e.g., 10700) */
46
122
  get sdkVersionCode(): number;
123
+
124
+ /** Module for displaying in-app messages
125
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/in-app-messaging.html
126
+ */
47
127
  inAppMessaging: InAppMessaging;
48
128
 
129
+ /** Handler for story link clicks
130
+ *
131
+ * @example
132
+ * storyManager.storyLinkClickHandler = ({ data, src }) => {
133
+ * console.log("Link clicked:", data.url, "from", src);
134
+ * };
135
+ */
49
136
  set storyLinkClickHandler(value: StoryLinkClickHandler);
50
- showOnboardingStories(options?: { feed?: string; customTags?: Array<string>; limit?: number }): Promise<{
137
+
138
+ /**
139
+ * Displays onboarding stories, optionally filtered by feed, tags, or limit.
140
+ * @param options Filter options and limit
141
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/onboardings.html
142
+ * @example
143
+ * import { StoryManagerConfig, IASContainer, storyManager } from "@inappstory/react-sdk";
144
+ import { useEffect } from "react";
145
+
146
+ export const App = () => {
147
+ useEffect(() => {
148
+ storyManager.showOnboardingStories().then((result) => {
149
+ console.log("Onboarding stories displayed:", result.stories);
150
+ }).catch((error) => {
151
+ console.error("Error displaying onboarding stories:", error);
152
+ });
153
+ }, []);
154
+
155
+ const storyManagerConfig: StoryManagerConfig = {
156
+ apiKey: "{projectToken}",
157
+ userId,
158
+ };
159
+
160
+ return <IASContainer config={storyManagerConfig} />;
161
+ };
162
+
163
+ */
164
+ showOnboardingStories(options?: { feed?: string; customTags?: string[]; limit?: number }): Promise<{
51
165
  stories: {
52
166
  title: Option<string>;
53
- tags: Array<string>;
167
+ tags: string[];
54
168
  slidesCount: Option<number>;
55
169
  ugcPayload?: Record<string, unknown>;
56
170
  id: number;
@@ -58,18 +172,103 @@ export declare class StoryManager {
58
172
  feed?: Option<string>;
59
173
  filter?: Option<Record<string, any>>;
60
174
  }>;
175
+
176
+ /**
177
+ * Displays the share page for a specific story.
178
+ * @param storyId The story ID
179
+ * @see https://docs.inappstory.com/sdk-guides/sharing/sharing.html
180
+ * @example
181
+ * storyManager.showSharePage("yout-story-id").catch(console.error)
182
+ */
61
183
  showSharePage(storyId: number | string): Promise<void>;
184
+
185
+ /**
186
+ * Displays a specific story.
187
+ * @param id The story ID
188
+ */
62
189
  showStory(id: number | string): Promise<void>;
190
+
191
+ /**
192
+ * Displays a story only once.
193
+ * @param id The story ID
194
+ */
63
195
  showStoryOnce(id: number | string): Promise<void>;
64
- openGame(gameInstanceId: string | number, gameOptions?: { demoMode?: boolean }): Promise<void>;
196
+
197
+ /**
198
+ * Opens a game by its instance ID.
199
+ * @param gameInstanceId Game instance identifier
200
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/games.html
201
+ * @example
202
+ * storyManager.openGame("your-game-id")
203
+ */
204
+ openGame(gameInstanceId: string | number): Promise<void>;
205
+
206
+ /**
207
+ * Closes the currently active game, if any.
208
+ * @returns A flag indicating whether the game was closed
209
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/games.html
210
+ */
65
211
  closeGame(): Promise<boolean>;
212
+
213
+ /**
214
+ * Closes the story reader, if it is open.
215
+ * @returns A flag indicating whether the reader was closed
216
+ */
66
217
  closeStoryReader(): Promise<boolean | undefined>;
218
+
219
+ /**
220
+ * Closes the goods widget, if it is open.
221
+ */
67
222
  closeGoodsWidget(): void;
223
+
224
+ /**
225
+ * Retrieves the UGC editor configuration.
226
+ */
68
227
  getUgcEditorConfig(): Promise<UgcEditorConfig>;
69
- on<Event extends keyof PublicEvents>(eventName: Event, listener: PublicEventHandler<Event>): this;
70
- once<Event extends keyof PublicEvents>(eventName: Event, listener: PublicEventHandler<Event>): this;
71
- off<Event extends keyof PublicEvents>(eventName: Event, listener: PublicEventHandler<Event>): this;
228
+
229
+ /**
230
+ * Subscribes to an SDK event.
231
+ * @param eventName The name of the event
232
+ * @param listener The event handler
233
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/events.html
234
+ */
235
+ on<EventName extends keyof StoryManagerEvents>(
236
+ eventName: EventName,
237
+ listener: (event: StoryManagerEvents[EventName]) => void
238
+ ): this;
239
+
240
+ /**
241
+ * Subscribes to a one-time SDK event.
242
+ * @param eventName The name of the event
243
+ * @param listener The event handler
244
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/events.html
245
+ */
246
+ once<EventName extends keyof StoryManagerEvents>(
247
+ eventName: EventName,
248
+ listener: (event: StoryManagerEvents[EventName]) => void
249
+ ): this;
250
+
251
+ /**
252
+ * Unsubscribes from an SDK event.
253
+ * @param eventName The name of the event
254
+ * @param listener The event handler
255
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/events.html
256
+ */
257
+ off<EventName extends keyof StoryManagerEvents>(
258
+ eventName: EventName,
259
+ listener: (event: StoryManagerEvents[EventName]) => void
260
+ ): this;
261
+
262
+ /**
263
+ * Installs a plugin at the class level.
264
+ * @param plugin The plugin instance
265
+ * @param options Optional plugin options
266
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/plugins.html
267
+ */
72
268
  static use(plugin: Plugin, options?: any): void;
73
269
  }
74
270
 
271
+ /**
272
+ * Instance of StoryManager.
273
+ */
75
274
  export declare const storyManager: StoryManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inappstory/react-sdk",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
4
4
  "description": "React SDK",
5
5
  "keywords": [
6
6
  "stories",
@@ -35,6 +35,10 @@
35
35
  "./plugins/videoOnDemand": {
36
36
  "types": "./plugins/videoOnDemand/iasVideoOnDemandPlugin.d.ts",
37
37
  "default": "./plugins/videoOnDemand/iasVideoOnDemandPlugin.umd.js"
38
+ },
39
+ "./plugins/banners": {
40
+ "types": "./plugins/banners/types/index.d.ts",
41
+ "default": "./plugins/banners/index.esm.mjs"
38
42
  }
39
43
  },
40
44
  "main": "dist/index.umd.js",
@@ -54,7 +58,7 @@
54
58
  "Samsung >= 5"
55
59
  ],
56
60
  "dependencies": {
57
- "@inappstory/slide-api": "^0.1.18",
61
+ "@inappstory/slide-api": "^0.1.23",
58
62
  "async-mutex": "^0.5.0",
59
63
  "bowser": "^2.11.0",
60
64
  "classnames": "^2.5.1",