@inappstory/react-sdk 1.7.2 → 1.8.0-rc.0

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 (34) hide show
  1. package/dist/index.esm.mjs +2 -2
  2. package/dist/index.umd.js +2 -2
  3. package/dist/types/appearance-manager/appearanceCommon.d.ts +69 -3
  4. package/dist/types/appearance-manager/gameReader.d.ts +83 -4
  5. package/dist/types/appearance-manager/goodsWidget.d.ts +84 -1
  6. package/dist/types/appearance-manager/sharePanel.d.ts +133 -7
  7. package/dist/types/appearance-manager/storiesList.d.ts +303 -5
  8. package/dist/types/appearance-manager/storyReader.d.ts +260 -0
  9. package/dist/types/ias-container/IasContainer.d.ts +24 -0
  10. package/dist/types/ias-container/appearanceOptionsProps.d.ts +20 -1
  11. package/dist/types/ias-container/storyManagerEventsProps.d.ts +78 -0
  12. package/dist/types/in-app-messaging/iamErrors.d.ts +49 -45
  13. package/dist/types/in-app-messaging/inAppMessaging.d.ts +166 -0
  14. package/dist/types/story-list/FavoriteStoryList.d.ts +51 -1
  15. package/dist/types/story-list/StoryList.d.ts +169 -0
  16. package/dist/types/story-list/UGCStoryList.d.ts +61 -0
  17. package/dist/types/story-list/navigationViewModel.d.ts +43 -0
  18. package/dist/types/story-list/storyCardViewModel.d.ts +87 -3
  19. package/dist/types/story-list/storyListApi.d.ts +3 -2
  20. package/dist/types/story-list/storyListLoadStatus.ts +47 -10
  21. package/dist/types/storyManager.d.ts +180 -1
  22. package/package.json +6 -2
  23. package/plugins/banners/index.esm.mjs +1 -0
  24. package/plugins/banners/package.json +24 -0
  25. package/plugins/banners/types/banner.d.ts +197 -0
  26. package/plugins/banners/types/bannerPlace.d.ts +186 -0
  27. package/plugins/banners/types/bannerPlaceAppearance.d.ts +32 -0
  28. package/plugins/banners/types/iasBannerPlace.d.ts +77 -0
  29. package/plugins/banners/types/iasBannerPreview.d.ts +58 -0
  30. package/plugins/banners/types/iasBannersProvider.d.ts +52 -0
  31. package/plugins/banners/types/index.d.ts +29 -0
  32. package/plugins/dotLottie/iasDotLottiePlugin.umd.js +1 -1
  33. package/plugins/videoOnDemand/iasVideoOnDemandPlugin.umd.js +1 -1
  34. package/dist/types/appearance-manager/storyReader.ts +0 -125
@@ -5,17 +5,78 @@ import { StoryCardViewModel } from "./storyCardViewModel";
5
5
  import { StoryListApi } from "./storyListApi";
6
6
  import { StoryListLoadStatus } from "./storyListLoadStatus";
7
7
 
8
+ /**
9
+ * Props for the UGCStoryList component that displays user-generated content stories
10
+ */
8
11
  interface UGCStoryListProps {
12
+ /**
13
+ * Ref object to access the StoryList API methods imperatively
14
+ */
9
15
  ref?: React.Ref<StoryListApi | null>;
16
+
17
+ /**
18
+ * Appearance settings for the stories list
19
+ */
10
20
  options?: StoriesListOptions;
21
+
22
+ /**
23
+ * Use the testKey to see stories with status `Moderation`.
24
+ */
11
25
  testKey?: string;
26
+
27
+ /**
28
+ * Callback triggered when a UGC story card is clicked
29
+ */
12
30
  onUgcCardClick?: () => void;
31
+
32
+ /**
33
+ * Flag to enable/disable UGC card functionality
34
+ * @default false
35
+ */
13
36
  useUgcCard?: boolean;
37
+
38
+ /**
39
+ * Flag indicating whether favorites functionality should be enabled
40
+ * @default false
41
+ */
14
42
  hasFavorite?: boolean;
43
+
44
+ /**
45
+ * Filter criteria to apply when loading stories
46
+ */
15
47
  filter?: Record<string, any>;
48
+
49
+ /**
50
+ * Callback triggered when story list loading begins
51
+ */
16
52
  onLoadStart?: () => void;
53
+
54
+ /**
55
+ * Callback triggered when story list loading completes
56
+ * @param storyListLoadStatus - Contains loading results and metadata
57
+ */
17
58
  onLoadEnd?: (storyListLoadStatus: StoryListLoadStatus) => void;
59
+
60
+ /**
61
+ * Custom render function for story cards
62
+ * @param storyCard - Data object containing card content and metadata
63
+ * @returns React node to render for the card
64
+ */
18
65
  storyCardView?: (storyCard: StoryCardViewModel) => React.ReactNode;
66
+
67
+ /**
68
+ * Custom render function for navigation controls
69
+ * @param navigation - Data object containing navigation state
70
+ * @returns React node to render for navigation
71
+ */
19
72
  navigationView?: (navigation: NavigationViewModel) => React.ReactNode;
20
73
  }
74
+
75
+ /**
76
+ * Component that displays a scrollable list of user-generated content stories
77
+ * with support for custom rendering and interaction callbacks
78
+ *
79
+ * @param props - Configuration properties for the component
80
+ * @returns React element representing the story list
81
+ */
21
82
  export declare const UGCStoryList: (props: UGCStoryListProps) => JSX.Element;
@@ -1,12 +1,55 @@
1
+ /**
2
+ * Represents the view model for navigation controls in a stories list or carousel
3
+ */
1
4
  export interface NavigationViewModel {
5
+ /**
6
+ * CSS styles to be applied to navigation elements by default
7
+ */
2
8
  defaultStyles: Record<string, string>;
9
+
10
+ /**
11
+ * Indicates whether the beginning of the list has been reached
12
+ * (disabled state for previous/back navigation)
13
+ */
3
14
  reachStart: boolean;
15
+
16
+ /**
17
+ * Indicates whether the end of the list has been reached
18
+ * (disabled state for next/forward navigation)
19
+ */
4
20
  reachEnd: boolean;
21
+
22
+ /**
23
+ * Handler for previous/back navigation action
24
+ * Scrolls to the previous item or page
25
+ */
5
26
  onPrev(): void;
27
+
28
+ /**
29
+ * Handler for next/forward navigation action
30
+ * Scrolls to the next item or page
31
+ */
6
32
  onNext(): void;
33
+
34
+ /**
35
+ * Slider state and properties
36
+ */
7
37
  slider: {
38
+ /**
39
+ * Current scroll position of the slider in pixels
40
+ */
8
41
  currentPosition: number;
42
+
43
+ /**
44
+ * Scroll direction of the slider
45
+ * @default "horizontal"
46
+ */
9
47
  direction: "horizontal" | "vertical";
48
+
49
+ /**
50
+ * Dimensions and position of the visible viewport area
51
+ * @description Uses DOMRect with properties: x, y, width, height, top, right, bottom, left
52
+ */
10
53
  viewport: DOMRect;
11
54
  };
12
55
  }
@@ -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,52 +1,154 @@
1
1
  import { PublicEventHandler, PublicEvents } from "./ias-container";
2
2
  import { InAppMessaging } from "./in-app-messaging/inAppMessaging";
3
3
 
4
+ /**
5
+ * Source of the link click within stories.
6
+ */
4
7
  export declare enum LinkSource {
5
8
  StoryList = "storyList",
6
9
  StoryReader = "storyReader",
7
10
  GameReader = "gameReader"
8
11
  }
9
12
 
13
+ /**
14
+ * Configuration options for initializing the StoryManager.
15
+ */
10
16
  export type StoryManagerConfig = {
17
+ /** API integration key for initializing the SDK */
11
18
  apiKey: string;
19
+ /** Unique user identifier (optional)
20
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/user-settings.html
21
+ */
12
22
  userId?: string | number;
23
+ /** Signature for the userId for validation (optional)
24
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/user-settings.html
25
+ */
13
26
  userIdSign?: string;
27
+ /** Tags used to filter stories (optional)
28
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/tags.html
29
+ */
14
30
  tags?: Array<string>;
31
+ /** Text placeholders to be replaced in stories (optional)
32
+ * @see https://docs.inappstory.com/sdk-guides/js-sdk/placeholders.html
33
+ * @example
34
+ * placeholders: {
35
+ * "your-placeholder-key": "value"
36
+ * }
37
+ */
15
38
  placeholders?: Record<string, string>;
39
+ /** Image placeholders to be replaced in stories (optional)
40
+ * @see https://docs.inappstory.com/sdk-guides/js-sdk/placeholders.html
41
+ * @example
42
+ * imagePlaceholders: {
43
+ * "your-image-placeholder-key": "value"
44
+ * }
45
+ */
16
46
  imagePlaceholders?: Record<string, string>;
47
+ /** Language code for content display (e.g., 'en-US') (optional) */
17
48
  lang?: string;
49
+ /** Text direction (optional): 'ltr' or 'rtl' */
18
50
  dir?: "ltr" | "rtl";
51
+ /** Disables automatic deviceId generation
52
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/user-settings.html#overview
53
+ */
19
54
  disableDeviceId?: boolean;
20
55
  };
21
56
 
57
+ /**
58
+ * Configuration for the user-generated content (UGC) editor.
59
+ */
22
60
  export type UgcEditorConfig = {
61
+ /** Unique session identifier */
23
62
  sessionId: string;
63
+ /** SDK API key */
24
64
  apiKey: string;
65
+ /** Editor configuration (customizable externally) */
25
66
  editor: Record<any, any>;
67
+ /** SDK version */
26
68
  sdkVersion: string;
69
+ /** App package identifier (optional) */
27
70
  appPackageId?: string;
71
+ /** Unique device identifier */
28
72
  deviceId: string;
73
+ /** User identifier (optional) */
29
74
  userId?: string;
75
+ /** Language code for the editor */
30
76
  lang: string;
31
77
  };
32
78
 
79
+ /**
80
+ * Handler for story link click events.
81
+ * @deprecated Use `clickOnButton` event instead
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
+ * @deprecated Use `clickOnButton` event instead
122
+ * @see https://docs.inappstory.com/sdk-guides/reack-sdk/link-handling.html
123
+ */
49
124
  set storyLinkClickHandler(value: StoryLinkClickHandler);
125
+
126
+ /**
127
+ * Displays onboarding stories, optionally filtered by feed, tags, or limit.
128
+ * @param options Filter options and limit
129
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/onboardings.html
130
+ * @example
131
+ * import { StoryManagerConfig, IASContainer, storyManager } from "@inappstory/react-sdk";
132
+ import { useEffect } from "react";
133
+
134
+ export const App = () => {
135
+ useEffect(() => {
136
+ storyManager.showOnboardingStories().then((result) => {
137
+ console.log("Onboarding stories displayed:", result.stories);
138
+ }).catch((error) => {
139
+ console.error("Error displaying onboarding stories:", error);
140
+ });
141
+ }, []);
142
+
143
+ const storyManagerConfig: StoryManagerConfig = {
144
+ apiKey: "{projectToken}",
145
+ userId,
146
+ };
147
+
148
+ return <IASContainer config={storyManagerConfig} />;
149
+ };
150
+
151
+ */
50
152
  showOnboardingStories(options?: { feed?: string; customTags?: Array<string>; limit?: number }): Promise<{
51
153
  stories: {
52
154
  title: Option<string>;
@@ -58,18 +160,95 @@ export declare class StoryManager {
58
160
  feed?: Option<string>;
59
161
  filter?: Option<Record<string, any>>;
60
162
  }>;
163
+
164
+ /**
165
+ * Displays the share page for a specific story.
166
+ * @param storyId The story ID
167
+ * @see https://docs.inappstory.com/sdk-guides/sharing/sharing.html
168
+ * @example
169
+ * storyManager.showSharePage("yout-story-id").catch(console.error)
170
+ */
61
171
  showSharePage(storyId: number | string): Promise<void>;
172
+
173
+ /**
174
+ * Displays a specific story.
175
+ * @param id The story ID
176
+ */
62
177
  showStory(id: number | string): Promise<void>;
178
+
179
+ /**
180
+ * Displays a story only once.
181
+ * @param id The story ID
182
+ */
63
183
  showStoryOnce(id: number | string): Promise<void>;
64
- openGame(gameInstanceId: string, gameOptions?: { demoMode?: boolean }): Promise<void>;
184
+
185
+ /**
186
+ * Opens a game by its instance ID.
187
+ * @param gameInstanceId Game instance identifier
188
+ * @param gameOptions Optional game parameters
189
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/games.html
190
+ * @example
191
+ * storyManager.openGame("your-game-id")
192
+ */
193
+ openGame(gameInstanceId: string | number, gameOptions?: { demoMode?: boolean }): Promise<void>;
194
+
195
+ /**
196
+ * Closes the currently active game, if any.
197
+ * @returns A flag indicating whether the game was closed
198
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/games.html
199
+ */
65
200
  closeGame(): Promise<boolean>;
201
+
202
+ /**
203
+ * Closes the story reader, if it is open.
204
+ * @returns A flag indicating whether the reader was closed
205
+ */
66
206
  closeStoryReader(): Promise<boolean | undefined>;
207
+
208
+ /**
209
+ * Closes the goods widget, if it is open.
210
+ */
67
211
  closeGoodsWidget(): void;
212
+
213
+ /**
214
+ * Retrieves the UGC editor configuration.
215
+ */
68
216
  getUgcEditorConfig(): Promise<UgcEditorConfig>;
217
+
218
+ /**
219
+ * Subscribes to an SDK event.
220
+ * @param eventName The name of the event
221
+ * @param listener The event handler
222
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/events.html
223
+ */
69
224
  on<Event extends keyof PublicEvents>(eventName: Event, listener: PublicEventHandler<Event>): 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
+ */
70
232
  once<Event extends keyof PublicEvents>(eventName: Event, listener: PublicEventHandler<Event>): this;
233
+
234
+ /**
235
+ * Unsubscribes from an SDK event.
236
+ * @param eventName The name of the event
237
+ * @param listener The event handler
238
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/events.html
239
+ */
71
240
  off<Event extends keyof PublicEvents>(eventName: Event, listener: PublicEventHandler<Event>): this;
241
+
242
+ /**
243
+ * Installs a plugin at the class level.
244
+ * @param plugin The plugin instance
245
+ * @param options Optional plugin options
246
+ * @see https://docs.inappstory.com/sdk-guides/react-sdk/plugins.html
247
+ */
72
248
  static use(plugin: Plugin, options?: any): void;
73
249
  }
74
250
 
251
+ /**
252
+ * Instance of StoryManager.
253
+ */
75
254
  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.2",
3
+ "version": "1.8.0-rc.0",
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.20",
58
62
  "async-mutex": "^0.5.0",
59
63
  "bowser": "^2.11.0",
60
64
  "classnames": "^2.5.1",