@inappstory/js-sdk 3.6.4 → 3.6.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.
- package/dist/index.esm.mjs +104 -88
- package/dist/index.esm.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/types/appearance-manager/appearanceCommon.d.ts +69 -3
- package/dist/types/appearance-manager/appearanceManager.d.ts +69 -1
- package/dist/types/appearance-manager/gameReader.d.ts +91 -15
- package/dist/types/appearance-manager/goodsWidget.d.ts +98 -17
- package/dist/types/appearance-manager/sharePanel.d.ts +129 -2
- package/dist/types/appearance-manager/storiesList.d.ts +303 -5
- package/dist/types/appearance-manager/storyFavoriteReader.d.ts +34 -0
- package/dist/types/appearance-manager/storyReader.d.ts +260 -0
- package/dist/types/events.d.ts +207 -0
- package/dist/types/in-app-messaging/iamErrors.d.ts +49 -45
- package/dist/types/in-app-messaging/inAppMessaging.d.ts +166 -0
- package/dist/types/inAppStoryManager.d.ts +205 -6
- package/dist/types/index.d.ts +1 -1
- package/dist/types/share-page/sharePage.d.ts +4 -0
- package/dist/types/story-list/StoryList.d.ts +30 -0
- package/dist/types/story-list/UGCStoryList.d.ts +30 -0
- package/dist/types/story-list/storyListLoadStatus.ts +46 -9
- package/package.json +6 -2
- package/plugins/dotLottie/iasDotLottiePlugin.umd.js +1 -1
- package/plugins/videoOnDemand/iasVideoOnDemandPlugin.umd.js +1 -1
- package/dist/types/appearance-manager/storyReader.ts +0 -73
- package/dist/types/publicEvents.d.ts +0 -104
|
@@ -1,48 +1,214 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IamNotFoundByEventError,
|
|
3
|
+
IamMessageOpenError,
|
|
4
|
+
IamOtherReaderIsOpenError,
|
|
5
|
+
IamShowOnlyIfLoadedError,
|
|
6
|
+
IamMessageLimitExceededError,
|
|
7
|
+
IamNotFoundByIdError,
|
|
8
|
+
IamFrequencyLimitError,
|
|
9
|
+
IamCheckDisplayTimeRangeError
|
|
10
|
+
} from "./iamErrors";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Enum representing different types of in-app messages
|
|
14
|
+
*/
|
|
1
15
|
export declare enum IamMessageType {
|
|
16
|
+
/**
|
|
17
|
+
* Message appears as a bottom sheet (slides up from bottom of screen)
|
|
18
|
+
*/
|
|
2
19
|
BottomSheet = 1,
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Message appears as a modal dialog (centered on screen)
|
|
23
|
+
*/
|
|
3
24
|
Modal = 2,
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Message takes up the full screen
|
|
28
|
+
*/
|
|
4
29
|
Fullscreen = 3
|
|
5
30
|
}
|
|
6
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Interface representing an in-app message
|
|
34
|
+
*/
|
|
7
35
|
export interface IamMessage {
|
|
36
|
+
/**
|
|
37
|
+
* Unique identifier for the message
|
|
38
|
+
*/
|
|
8
39
|
id: number;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Name of the campaign this message belongs to
|
|
43
|
+
*/
|
|
9
44
|
campaignName: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Visual presentation type of the message
|
|
48
|
+
*/
|
|
10
49
|
type: IamMessageType;
|
|
11
50
|
}
|
|
12
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Type mapping of all possible IAM events and their payload structures
|
|
54
|
+
*/
|
|
13
55
|
export type IamEvents = {
|
|
56
|
+
/**
|
|
57
|
+
* Triggered when a message is closed
|
|
58
|
+
*/
|
|
14
59
|
close: {
|
|
60
|
+
/**
|
|
61
|
+
* The message that was closed
|
|
62
|
+
*/
|
|
15
63
|
message: IamMessage;
|
|
16
64
|
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Triggered when a widget within a message fires an event
|
|
68
|
+
*/
|
|
17
69
|
widgetEvent: {
|
|
70
|
+
/**
|
|
71
|
+
* The message containing the widget
|
|
72
|
+
*/
|
|
18
73
|
message: IamMessage;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Name/type of the widget event
|
|
77
|
+
*/
|
|
19
78
|
name: string;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Additional data associated with the event
|
|
82
|
+
*/
|
|
20
83
|
data: Record<string, any>;
|
|
21
84
|
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Triggered when a button is clicked within a message
|
|
88
|
+
*/
|
|
22
89
|
clickOnButton: {
|
|
90
|
+
/**
|
|
91
|
+
* Unique identifier of the clicked button
|
|
92
|
+
*/
|
|
23
93
|
id: number;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Index position of the button
|
|
97
|
+
*/
|
|
24
98
|
index: number;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* URL associated with the button (if any)
|
|
102
|
+
*/
|
|
25
103
|
url: string;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* ID of the HTML element that was clicked
|
|
107
|
+
*/
|
|
26
108
|
elementId: string;
|
|
27
109
|
};
|
|
28
110
|
};
|
|
29
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Type definition for IAM event handlers
|
|
114
|
+
* @template Event - The event name (keyof IamEvents)
|
|
115
|
+
*/
|
|
30
116
|
export type IamEventHandler<Event extends keyof IamEvents> = (event: IamEvents[Event]) => void;
|
|
31
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Interface for the In-App Messaging service
|
|
120
|
+
*/
|
|
32
121
|
export interface InAppMessaging {
|
|
122
|
+
/**
|
|
123
|
+
* Gets the currently active/open message
|
|
124
|
+
*/
|
|
33
125
|
get activeMessage(): IamMessage | null;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Indicates whether messages have been loaded
|
|
129
|
+
*/
|
|
34
130
|
get isLoaded(): boolean;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Indicates whether messages are currently loading
|
|
134
|
+
*/
|
|
35
135
|
get isLoading(): boolean;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Indicates whether a message is currently open/visible
|
|
139
|
+
*/
|
|
36
140
|
get isOpened(): boolean;
|
|
37
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Preloads messages for faster display later
|
|
144
|
+
* @param options - Optional configuration
|
|
145
|
+
* @param options.tags - Filter messages by tags
|
|
146
|
+
* @returns Promise resolving to array of loaded messages
|
|
147
|
+
*/
|
|
38
148
|
preload(options?: { tags?: string[] }): Promise<IamMessage[]>;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Displays a message by its ID
|
|
152
|
+
* @param messageId - The ID of the message to show
|
|
153
|
+
* @param options - Optional display configuration
|
|
154
|
+
* @param options.showOnlyIfLoaded - If true, only shows messages that were preloaded
|
|
155
|
+
* @returns Promise resolving to the displayed message
|
|
156
|
+
* @throws {IamNotFoundByIdError} If no message exists with this ID
|
|
157
|
+
* @throws {IamMessageOpenError} If this message is already open
|
|
158
|
+
* @throws {IamOtherReaderIsOpenError} If another reader is active
|
|
159
|
+
* @throws {IamShowOnlyIfLoadedError} If showOnlyIfLoaded=true but message wasn't preloaded
|
|
160
|
+
* @throws {IamMessageLimitExceededError} If message display limit was reached
|
|
161
|
+
*/
|
|
39
162
|
showMessageById(messageId: number | string, options?: { showOnlyIfLoaded?: boolean }): Promise<IamMessage>;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Displays a message associated with an event name
|
|
166
|
+
* @param eventName - The event name triggering the message
|
|
167
|
+
* @param options - Optional display configuration
|
|
168
|
+
* @param options.showOnlyIfLoaded - If true, only shows messages that were preloaded
|
|
169
|
+
* @param options.tags - Filter messages by tags
|
|
170
|
+
* @returns Promise resolving to the displayed message
|
|
171
|
+
* @throws {IamNotFoundByEventError} If no message exists for this event
|
|
172
|
+
* @throws {IamFrequencyLimitError} If message frequency limit was exceeded
|
|
173
|
+
* @throws {IamCheckDisplayTimeRangeError} If current time is outside allowed display period
|
|
174
|
+
* @throws {IamOtherReaderIsOpenError} If another reader is active
|
|
175
|
+
* @throws {IamShowOnlyIfLoadedError} If showOnlyIfLoaded=true but message wasn't preloaded
|
|
176
|
+
*/
|
|
40
177
|
showMessageByEvent(
|
|
41
178
|
eventName: string,
|
|
42
179
|
options?: { showOnlyIfLoaded?: boolean; tags?: string[] }
|
|
43
180
|
): Promise<IamMessage>;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Closes the currently open message
|
|
184
|
+
* @returns Promise that resolves when the message is closed
|
|
185
|
+
*/
|
|
44
186
|
close(): Promise<void>;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Registers an event listener
|
|
190
|
+
* @template Event - The event name to listen for
|
|
191
|
+
* @param eventName - Name of the event to listen for
|
|
192
|
+
* @param listener - Callback function to handle the event
|
|
193
|
+
* @returns The InAppMessaging instance for chaining
|
|
194
|
+
*/
|
|
45
195
|
on<Event extends keyof IamEvents>(eventName: Event, listener: IamEventHandler<Event>): this;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Registers a one-time event listener
|
|
199
|
+
* @template Event - The event name to listen for
|
|
200
|
+
* @param eventName - Name of the event to listen for
|
|
201
|
+
* @param listener - Callback function to handle the event
|
|
202
|
+
* @returns The InAppMessaging instance for chaining
|
|
203
|
+
*/
|
|
46
204
|
once<Event extends keyof IamEvents>(eventName: Event, listener: IamEventHandler<Event>): this;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Removes an event listener
|
|
208
|
+
* @template Event - The event name to remove listener for
|
|
209
|
+
* @param eventName - Name of the event
|
|
210
|
+
* @param listener - Callback function to remove
|
|
211
|
+
* @returns The InAppMessaging instance for chaining
|
|
212
|
+
*/
|
|
47
213
|
off<Event extends keyof IamEvents>(eventName: Event, listener: IamEventHandler<Event>): this;
|
|
48
214
|
}
|
|
@@ -3,89 +3,284 @@ import { AppearanceManager } from "./appearance-manager/appearanceManager";
|
|
|
3
3
|
import { StoriesList, UGCStoriesList } from "./story-list";
|
|
4
4
|
import { PublicEventHandler, PublicEvents } from "./publicEvents";
|
|
5
5
|
import { InAppMessaging } from "./in-app-messaging";
|
|
6
|
+
import { StoryManagerEvents } from "./events";
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Source of a link click within stories.
|
|
10
|
+
*/
|
|
7
11
|
export declare enum StoryLinkSource {
|
|
8
12
|
StoryList = "storyList",
|
|
9
13
|
StoryReader = "storyReader",
|
|
10
14
|
GameReader = "gameReader"
|
|
11
15
|
}
|
|
12
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Configuration options for initializing the InAppStoryManager.
|
|
19
|
+
*/
|
|
13
20
|
export type InAppStoryManagerConfig = {
|
|
21
|
+
/** API key for initializing the SDK */
|
|
14
22
|
apiKey: string;
|
|
23
|
+
/** Unique user identifier (optional)
|
|
24
|
+
* @see https://docs.inappstory.com/sdk-guides/react-sdk/user-settings.html
|
|
25
|
+
*/
|
|
15
26
|
userId?: string | number;
|
|
27
|
+
/** Signature for the userId for validation (optional)
|
|
28
|
+
* @see https://docs.inappstory.com/sdk-guides/react-sdk/user-settings.html
|
|
29
|
+
*/
|
|
16
30
|
userIdSign?: string;
|
|
31
|
+
/** Tags for filtering stories (optional)
|
|
32
|
+
* @see https://docs.inappstory.com/sdk-guides/react-sdk/tags.html
|
|
33
|
+
*/
|
|
17
34
|
tags?: Array<string>;
|
|
35
|
+
/** Text placeholders to replace in stories (optional)
|
|
36
|
+
* @example
|
|
37
|
+
* placeholders: {
|
|
38
|
+
* "userName": "John"
|
|
39
|
+
* }
|
|
40
|
+
* @see https://docs.inappstory.com/sdk-guides/js-sdk/placeholders.html
|
|
41
|
+
*/
|
|
18
42
|
placeholders?: Record<string, string>;
|
|
43
|
+
/** Image placeholders to replace in stories (optional)
|
|
44
|
+
* @example
|
|
45
|
+
* imagePlaceholders: {
|
|
46
|
+
* "avatar": "https://example.com/avatar.png"
|
|
47
|
+
* }
|
|
48
|
+
* @see https://docs.inappstory.com/sdk-guides/js-sdk/placeholders.html
|
|
49
|
+
*/
|
|
19
50
|
imagePlaceholders?: Record<string, string>;
|
|
51
|
+
/** Language code for content display (e.g., "en-US") */
|
|
20
52
|
lang?: string;
|
|
21
|
-
|
|
53
|
+
/** Text direction: 'ltr' or 'rtl' */
|
|
54
|
+
dir?: "ltr" | "rtl";
|
|
55
|
+
/** Disables automatic deviceId generation
|
|
56
|
+
* @see https://docs.inappstory.com/sdk-guides/react-sdk/user-settings.html#overview
|
|
57
|
+
*/
|
|
22
58
|
disableDeviceId?: boolean;
|
|
23
59
|
};
|
|
24
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Configuration for the User Generated Content (UGC) editor.
|
|
63
|
+
*/
|
|
25
64
|
export type UgcEditorConfig = {
|
|
65
|
+
/** Unique session identifier */
|
|
26
66
|
sessionId: string;
|
|
67
|
+
/** SDK API key */
|
|
27
68
|
apiKey: string;
|
|
69
|
+
/** Editor configuration */
|
|
28
70
|
editor: Record<any, any>;
|
|
71
|
+
/** SDK version */
|
|
29
72
|
sdkVersion: string;
|
|
73
|
+
/** Application package identifier (optional) */
|
|
30
74
|
appPackageId?: string;
|
|
75
|
+
/** Unique device identifier */
|
|
31
76
|
deviceId: string;
|
|
77
|
+
/** User identifier (optional) */
|
|
32
78
|
userId?: string;
|
|
79
|
+
/** Editor language code */
|
|
33
80
|
lang: string;
|
|
34
81
|
};
|
|
35
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Handler for story link click events.
|
|
85
|
+
*/
|
|
36
86
|
export type StoryLinkClickHandler = (payload: {
|
|
37
87
|
data: { id: number; index: number; isDeeplink: boolean; url: string };
|
|
38
88
|
src: StoryLinkSource;
|
|
39
89
|
}) => void;
|
|
40
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Interface for external plugin integration.
|
|
93
|
+
*/
|
|
41
94
|
export interface Plugin {
|
|
95
|
+
/** Unique plugin name */
|
|
42
96
|
name: string;
|
|
97
|
+
/** Called when the plugin is installed */
|
|
43
98
|
install(inAppStoryManager: InAppStoryManager, options?: any): void;
|
|
99
|
+
/** Called when the plugin is uninstalled */
|
|
44
100
|
uninstall(inAppStoryManager: InAppStoryManager, options?: any): void;
|
|
45
101
|
}
|
|
46
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Main class for managing stories, games, and content.
|
|
105
|
+
*/
|
|
47
106
|
export declare class InAppStoryManager {
|
|
107
|
+
/** SDK version name (e.g., '1.7.0') */
|
|
48
108
|
get sdkVersionName(): string;
|
|
109
|
+
|
|
110
|
+
/** Numeric SDK version code (e.g., 10700) */
|
|
49
111
|
get sdkVersionCode(): number;
|
|
112
|
+
|
|
113
|
+
/** Module for displaying in-app messages */
|
|
50
114
|
inAppMessaging: InAppMessaging;
|
|
115
|
+
|
|
116
|
+
/** Sets the handler for story link clicks
|
|
117
|
+
* @example
|
|
118
|
+
* manager.storyLinkClickHandler = ({ data, src }) => {
|
|
119
|
+
* console.log(`Link clicked: ${data.url} from ${src}`);
|
|
120
|
+
* };
|
|
121
|
+
*/
|
|
51
122
|
set storyLinkClickHandler(value: StoryLinkClickHandler);
|
|
52
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Creates an instance of InAppStoryManager.
|
|
126
|
+
* @param config SDK configuration
|
|
127
|
+
*/
|
|
53
128
|
constructor(config: InAppStoryManagerConfig);
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Gets the current instance of the manager.
|
|
132
|
+
*/
|
|
54
133
|
static getInstance(): InAppStoryManager;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Installs a plugin at the class level.
|
|
137
|
+
* @param plugin The plugin instance
|
|
138
|
+
* @param options Optional plugin options
|
|
139
|
+
*/
|
|
55
140
|
static use(plugin: Plugin, options?: any): void;
|
|
56
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Destroys the manager instance.
|
|
144
|
+
*/
|
|
57
145
|
destroy(): void;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Displays onboarding stories.
|
|
149
|
+
* @param appearanceManager Appearance manager instance
|
|
150
|
+
* @param options Optional filtering options
|
|
151
|
+
*/
|
|
58
152
|
showOnboardingStories(
|
|
59
153
|
appearanceManager: AppearanceManager,
|
|
60
154
|
options?: { feed?: string; customTags?: Array<string>; limit?: number }
|
|
61
155
|
): Promise<void>;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Displays the share page for a specific story.
|
|
159
|
+
* @param storyId The story ID
|
|
160
|
+
*/
|
|
62
161
|
showSharePage(storyId: number | string, appearanceManager: AppearanceManager): Promise<void>;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Opens a specific story.
|
|
165
|
+
* @param id The story ID
|
|
166
|
+
*/
|
|
63
167
|
showStory(id: number | string, appearanceManager: AppearanceManager): Promise<void>;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Opens a specific story only once.
|
|
171
|
+
* @param id The story ID
|
|
172
|
+
*/
|
|
64
173
|
showStoryOnce(id: number | string, appearanceManager: AppearanceManager): Promise<void>;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Opens a game by its instance ID.
|
|
177
|
+
* @param gameInstanceId Game instance identifier
|
|
178
|
+
* @param appearanceManager Appearance manager instance
|
|
179
|
+
*/
|
|
65
180
|
openGame(
|
|
66
181
|
gameInstanceId: string | number,
|
|
67
|
-
appearanceManager: AppearanceManager
|
|
68
|
-
gameOptions?: { demoMode?: boolean }
|
|
182
|
+
appearanceManager: AppearanceManager
|
|
69
183
|
): Promise<void>;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Closes the currently active game, if any.
|
|
187
|
+
* @returns Whether the game was closed
|
|
188
|
+
*/
|
|
70
189
|
closeGame(): Promise<boolean>;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Closes the story reader, if it is open.
|
|
193
|
+
*/
|
|
71
194
|
closeStoryReader(): Promise<boolean | undefined>;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Closes the goods widget, if it is open.
|
|
198
|
+
*/
|
|
72
199
|
closeGoodsWidget(): void;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Retrieves the UGC editor configuration.
|
|
203
|
+
*/
|
|
73
204
|
getUgcEditorConfig(): Promise<UgcEditorConfig>;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Retrieves the nonce, if set.
|
|
208
|
+
*/
|
|
74
209
|
getNonce(): string | undefined;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Sets the user ID.
|
|
213
|
+
* @param userId User identifier
|
|
214
|
+
* @param sign Optional signature
|
|
215
|
+
*/
|
|
75
216
|
setUserId(userId: string | number, sign?: string): Promise<void>;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Logs out the current user.
|
|
220
|
+
*/
|
|
76
221
|
userLogout(): Promise<void>;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Sets the content language.
|
|
225
|
+
*/
|
|
77
226
|
setLang(lang: string): void;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Sets tags for filtering stories.
|
|
230
|
+
*/
|
|
78
231
|
setTags(tags: string[]): void;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Sets text placeholders.
|
|
235
|
+
*/
|
|
79
236
|
setPlaceholders(placeholders: Dict<string, string>): void;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Sets image placeholders.
|
|
240
|
+
*/
|
|
80
241
|
setImagePlaceholders(imagePlaceholders: Dict<string, string>): void;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Subscribes to an SDK event.
|
|
245
|
+
* @param eventName The name of the event
|
|
246
|
+
* @param listener The event handler
|
|
247
|
+
* @see https://docs.inappstory.com/sdk-guides/react-sdk/events.html
|
|
248
|
+
*/
|
|
249
|
+
on<EventName extends keyof StoryManagerEvents>(
|
|
250
|
+
eventName: EventName,
|
|
251
|
+
listener: (event: StoryManagerEvents[EventName]) => void
|
|
252
|
+
): this;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Subscribes to a one-time SDK event.
|
|
256
|
+
* @param eventName The name of the event
|
|
257
|
+
* @param listener The event handler
|
|
258
|
+
* @see https://docs.inappstory.com/sdk-guides/react-sdk/events.html
|
|
259
|
+
*/
|
|
260
|
+
once<EventName extends keyof StoryManagerEvents>(
|
|
261
|
+
eventName: EventName,
|
|
262
|
+
listener: (event: StoryManagerEvents[EventName]) => void
|
|
263
|
+
): this;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Unsubscribes from an SDK event.
|
|
267
|
+
* @param eventName The name of the event
|
|
268
|
+
* @param listener The event handler
|
|
269
|
+
* @see https://docs.inappstory.com/sdk-guides/react-sdk/events.html
|
|
270
|
+
*/
|
|
271
|
+
off<EventName extends keyof StoryManagerEvents>(
|
|
272
|
+
eventName: EventName,
|
|
273
|
+
listener: (event: StoryManagerEvents[EventName]) => void
|
|
274
|
+
): this;
|
|
84
275
|
|
|
85
276
|
/** @deprecated Use `showSharePage()` instead */
|
|
86
277
|
SharePage: {
|
|
87
278
|
new (storyId: number | string, appearanceManager: AppearanceManager, options?: SharePageOptions): SharePage;
|
|
88
279
|
};
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Component for displaying a list of stories.
|
|
283
|
+
*/
|
|
89
284
|
StoriesList: {
|
|
90
285
|
new (
|
|
91
286
|
mountSelector: string,
|
|
@@ -93,6 +288,10 @@ export declare class InAppStoryManager {
|
|
|
93
288
|
options: { feed?: string; testKey?: string; useUgcCard?: boolean }
|
|
94
289
|
): StoriesList;
|
|
95
290
|
};
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Component for displaying a list of UGC stories.
|
|
294
|
+
*/
|
|
96
295
|
UGCStoriesList: {
|
|
97
296
|
new (
|
|
98
297
|
mountSelector: string,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export type SharePageOptions = {
|
|
|
7
7
|
handleStoryReaderClose?: () => void;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use showSharePage() instead
|
|
12
|
+
* @see https://docs.inappstory.com/sdk-guides/sharing/sharing.html
|
|
13
|
+
*/
|
|
10
14
|
export declare class SharePage extends EventEmitter {
|
|
11
15
|
constructor(storyId: number | string, appearanceManager: AppearanceManager, options?: SharePageOptions);
|
|
12
16
|
|
|
@@ -2,18 +2,48 @@ import { EventEmitter } from "events";
|
|
|
2
2
|
import { AppearanceManager } from "../appearance-manager";
|
|
3
3
|
import { StoriesListType } from "./storiesListType";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Component for rendering and managing a list of stories.
|
|
7
|
+
*
|
|
8
|
+
* Emits events related to story list loading and interactions.
|
|
9
|
+
*/
|
|
5
10
|
export declare class StoriesList extends EventEmitter {
|
|
11
|
+
/** Type of the stories list (e.g., regular, UGC, etc.) */
|
|
6
12
|
get type(): StoriesListType;
|
|
13
|
+
|
|
14
|
+
/** Feed slug used for loading stories */
|
|
7
15
|
get feedSlug(): string;
|
|
16
|
+
|
|
17
|
+
/** Test key for loading stories in test mode */
|
|
8
18
|
get testKey(): string;
|
|
19
|
+
|
|
20
|
+
/** Whether the list includes a UGC card */
|
|
9
21
|
get useUgcCard(): boolean;
|
|
10
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new StoriesList instance and mounts it to the given selector.
|
|
25
|
+
* @param mountSelector CSS selector or DOM element where the list will be mounted
|
|
26
|
+
* @param appearanceManager Instance controlling the list’s appearance
|
|
27
|
+
* @param options Additional configuration:
|
|
28
|
+
* - `feed`: Feed slug to load stories from
|
|
29
|
+
* - `testKey`: Key for loading test stories
|
|
30
|
+
* - `useUgcCard`: Whether to display a UGC card in the list
|
|
31
|
+
*/
|
|
11
32
|
constructor(
|
|
12
33
|
mountSelector: string,
|
|
13
34
|
appearanceManager: AppearanceManager,
|
|
14
35
|
options: { feed?: string; testKey?: string; useUgcCard?: boolean }
|
|
15
36
|
);
|
|
16
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Reloads the list of stories.
|
|
40
|
+
* @param options Options for reloading:
|
|
41
|
+
* - `needLoader`: Whether to show a loading indicator
|
|
42
|
+
*/
|
|
17
43
|
reload(options?: { needLoader: boolean }): Promise<void>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Destroys the list instance and removes it from the DOM.
|
|
47
|
+
*/
|
|
18
48
|
destroy(): void;
|
|
19
49
|
}
|
|
@@ -2,18 +2,48 @@ import { EventEmitter } from "events";
|
|
|
2
2
|
import { AppearanceManager } from "../appearance-manager";
|
|
3
3
|
import { StoriesListType } from "./storiesListType";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Component for rendering and managing a list of user-generated content (UGC) stories.
|
|
7
|
+
*
|
|
8
|
+
* Emits events related to list loading, filtering, and user interactions.
|
|
9
|
+
*/
|
|
5
10
|
export declare class UGCStoriesList extends EventEmitter {
|
|
11
|
+
/** Type of the stories list (e.g., regular, UGC, etc.) */
|
|
6
12
|
get type(): StoriesListType;
|
|
13
|
+
|
|
14
|
+
/** Feed slug used for loading stories (if applicable) */
|
|
7
15
|
get feedSlug(): string;
|
|
16
|
+
|
|
17
|
+
/** Test key for loading stories in test mode */
|
|
8
18
|
get testKey(): string;
|
|
19
|
+
|
|
20
|
+
/** Whether the list includes a UGC card */
|
|
9
21
|
get useUgcCard(): boolean;
|
|
10
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new UGCStoriesList instance and mounts it to the given selector.
|
|
25
|
+
* @param mountSelector CSS selector or DOM element where the list will be mounted
|
|
26
|
+
* @param appearanceManager Instance controlling the list’s appearance
|
|
27
|
+
* @param options Additional configuration:
|
|
28
|
+
* - `filter`: Filter parameters for loading specific stories
|
|
29
|
+
* - `testKey`: Key for loading test stories
|
|
30
|
+
* - `useUgcCard`: Whether to display a UGC card in the list
|
|
31
|
+
*/
|
|
11
32
|
constructor(
|
|
12
33
|
mountSelector: string,
|
|
13
34
|
appearanceManager: AppearanceManager,
|
|
14
35
|
options: { filter?: Record<string, any>; testKey?: string; useUgcCard?: boolean }
|
|
15
36
|
);
|
|
16
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Reloads the list of UGC stories.
|
|
40
|
+
* @param options Options for reloading:
|
|
41
|
+
* - `needLoader`: Whether to show a loading indicator
|
|
42
|
+
*/
|
|
17
43
|
reload(options?: { needLoader: boolean }): Promise<void>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Destroys the list instance and removes it from the DOM.
|
|
47
|
+
*/
|
|
18
48
|
destroy(): void;
|
|
19
49
|
}
|
|
@@ -1,12 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the loading status and metadata for a story list
|
|
3
|
+
*/
|
|
1
4
|
export interface StoryListLoadStatus {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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;
|
|
12
49
|
}
|