@inappstory/react-sdk 1.7.4 → 1.7.5

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 +2821 -3365
  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 +191 -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,156 @@
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;
20
56
  };
21
57
 
58
+ /**
59
+ * Configuration for the user-generated content (UGC) editor.
60
+ */
22
61
  export type UgcEditorConfig = {
62
+ /** Unique session identifier */
23
63
  sessionId: string;
64
+ /** SDK API key */
24
65
  apiKey: string;
66
+ /** Editor configuration (customizable externally) */
25
67
  editor: Record<any, any>;
68
+ /** SDK version */
26
69
  sdkVersion: string;
70
+ /** App package identifier (optional) */
27
71
  appPackageId?: string;
72
+ /** Unique device identifier */
28
73
  deviceId: string;
74
+ /** User identifier (optional) */
29
75
  userId?: string;
76
+ /** Language code for the editor */
30
77
  lang: string;
31
78
  };
32
79
 
80
+ /**
81
+ * Handler for story link click events.
82
+ */
33
83
  export type StoryLinkClickHandler = (payload: {
34
84
  data: { id: number; index: number; isDeeplink: boolean; url: string };
35
85
  src: LinkSource;
36
86
  }) => void;
37
87
 
88
+ /**
89
+ * Interface for external plugin integration with the StoryManager.
90
+ */
38
91
  export interface Plugin {
92
+ /** Unique plugin name */
39
93
  name: string;
94
+ /** Called when the plugin is installed */
40
95
  install(storyManager: StoryManager, options?: any): void;
96
+ /** Called when the plugin is uninstalled */
41
97
  uninstall(storyManager: StoryManager, options?: any): void;
42
98
  }
43
99
 
100
+ /**
101
+ * Main class for managing stories and games
102
+ */
44
103
  export declare class StoryManager {
104
+ /** SDK version name (e.g., '1.7.0') */
45
105
  get sdkVersionName(): string;
106
+
107
+ /** Numeric SDK version code (e.g., 10700) */
46
108
  get sdkVersionCode(): number;
109
+
110
+ /** Module for displaying in-app messages
111
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/in-app-messaging.html
112
+ */
47
113
  inAppMessaging: InAppMessaging;
48
114
 
115
+ /** Handler for story link clicks
116
+ *
117
+ * @example
118
+ * storyManager.storyLinkClickHandler = ({ data, src }) => {
119
+ * console.log("Link clicked:", data.url, "from", src);
120
+ * };
121
+ */
49
122
  set storyLinkClickHandler(value: StoryLinkClickHandler);
50
- showOnboardingStories(options?: { feed?: string; customTags?: Array<string>; limit?: number }): Promise<{
123
+
124
+ /**
125
+ * Displays onboarding stories, optionally filtered by feed, tags, or limit.
126
+ * @param options Filter options and limit
127
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/onboardings.html
128
+ * @example
129
+ * import { StoryManagerConfig, IASContainer, storyManager } from "@inappstory/react-sdk";
130
+ import { useEffect } from "react";
131
+
132
+ export const App = () => {
133
+ useEffect(() => {
134
+ storyManager.showOnboardingStories().then((result) => {
135
+ console.log("Onboarding stories displayed:", result.stories);
136
+ }).catch((error) => {
137
+ console.error("Error displaying onboarding stories:", error);
138
+ });
139
+ }, []);
140
+
141
+ const storyManagerConfig: StoryManagerConfig = {
142
+ apiKey: "{projectToken}",
143
+ userId,
144
+ };
145
+
146
+ return <IASContainer config={storyManagerConfig} />;
147
+ };
148
+
149
+ */
150
+ showOnboardingStories(options?: { feed?: string; customTags?: string[]; limit?: number }): Promise<{
51
151
  stories: {
52
152
  title: Option<string>;
53
- tags: Array<string>;
153
+ tags: string[];
54
154
  slidesCount: Option<number>;
55
155
  ugcPayload?: Record<string, unknown>;
56
156
  id: number;
@@ -58,18 +158,103 @@ export declare class StoryManager {
58
158
  feed?: Option<string>;
59
159
  filter?: Option<Record<string, any>>;
60
160
  }>;
161
+
162
+ /**
163
+ * Displays the share page for a specific story.
164
+ * @param storyId The story ID
165
+ * @see https://docs.inappstory.com/sdk-guides/sharing/sharing.html
166
+ * @example
167
+ * storyManager.showSharePage("yout-story-id").catch(console.error)
168
+ */
61
169
  showSharePage(storyId: number | string): Promise<void>;
170
+
171
+ /**
172
+ * Displays a specific story.
173
+ * @param id The story ID
174
+ */
62
175
  showStory(id: number | string): Promise<void>;
176
+
177
+ /**
178
+ * Displays a story only once.
179
+ * @param id The story ID
180
+ */
63
181
  showStoryOnce(id: number | string): Promise<void>;
64
- openGame(gameInstanceId: string | number, gameOptions?: { demoMode?: boolean }): Promise<void>;
182
+
183
+ /**
184
+ * Opens a game by its instance ID.
185
+ * @param gameInstanceId Game instance identifier
186
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/games.html
187
+ * @example
188
+ * storyManager.openGame("your-game-id")
189
+ */
190
+ openGame(gameInstanceId: string | number): Promise<void>;
191
+
192
+ /**
193
+ * Closes the currently active game, if any.
194
+ * @returns A flag indicating whether the game was closed
195
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/games.html
196
+ */
65
197
  closeGame(): Promise<boolean>;
198
+
199
+ /**
200
+ * Closes the story reader, if it is open.
201
+ * @returns A flag indicating whether the reader was closed
202
+ */
66
203
  closeStoryReader(): Promise<boolean | undefined>;
204
+
205
+ /**
206
+ * Closes the goods widget, if it is open.
207
+ */
67
208
  closeGoodsWidget(): void;
209
+
210
+ /**
211
+ * Retrieves the UGC editor configuration.
212
+ */
68
213
  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;
214
+
215
+ /**
216
+ * Subscribes to an SDK event.
217
+ * @param eventName The name of the event
218
+ * @param listener The event handler
219
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/events.html
220
+ */
221
+ on<EventName extends keyof StoryManagerEvents>(
222
+ eventName: EventName,
223
+ listener: (event: StoryManagerEvents[EventName]) => void
224
+ ): this;
225
+
226
+ /**
227
+ * Subscribes to a one-time SDK event.
228
+ * @param eventName The name of the event
229
+ * @param listener The event handler
230
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/events.html
231
+ */
232
+ once<EventName extends keyof StoryManagerEvents>(
233
+ eventName: EventName,
234
+ listener: (event: StoryManagerEvents[EventName]) => void
235
+ ): this;
236
+
237
+ /**
238
+ * Unsubscribes from an SDK event.
239
+ * @param eventName The name of the event
240
+ * @param listener The event handler
241
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/events.html
242
+ */
243
+ off<EventName extends keyof StoryManagerEvents>(
244
+ eventName: EventName,
245
+ listener: (event: StoryManagerEvents[EventName]) => void
246
+ ): this;
247
+
248
+ /**
249
+ * Installs a plugin at the class level.
250
+ * @param plugin The plugin instance
251
+ * @param options Optional plugin options
252
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/plugins.html
253
+ */
72
254
  static use(plugin: Plugin, options?: any): void;
73
255
  }
74
256
 
257
+ /**
258
+ * Instance of StoryManager.
259
+ */
75
260
  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.5",
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.22",
58
62
  "async-mutex": "^0.5.0",
59
63
  "bowser": "^2.11.0",
60
64
  "classnames": "^2.5.1",