@inappstory/react-sdk 1.9.0-rc.0 → 1.9.1

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.
@@ -1,3 +1,4 @@
1
+ import type { ProductCartOffer, ProductCart } from "@inappstory/slide-api";
1
2
  /**
2
3
  * Base StoryReader event.
3
4
  * Used as a foundation for most story-related events.
@@ -52,6 +53,12 @@ export interface CloseStoryEvent extends StoryReaderEvent {
52
53
  action: CloseAction;
53
54
  }
54
55
 
56
+ /** Event: story reader was closed */
57
+ export interface CloseStoryReaderEvent extends StoryReaderEvent {
58
+ /** Close reason */
59
+ action: CloseAction;
60
+ }
61
+
55
62
  /** Event: user clicked on a story */
56
63
  export interface ClickOnStoryEvent extends StoryReaderEvent {
57
64
  /** Story index inside feed */
@@ -162,6 +169,20 @@ export interface EventGameEvent {
162
169
  /** Event payload */
163
170
  payload: Record<string, any>;
164
171
  }
172
+
173
+ /** Event: fired when the "Add to cart" button is pressed */
174
+ export interface ProductCartUpdatedEvent {
175
+ /** Product offer */
176
+ offer: ProductCartOffer;
177
+ /** Success callback */
178
+ onSuccess: (cart: ProductCart) => void;
179
+ /** Error callback */
180
+ onError: (error: { message: string }) => void;
181
+ }
182
+
183
+ /** Event: fired when you click the "Go to cart" button */
184
+ export interface ProductCartClickedEvent {}
185
+
165
186
  /**
166
187
  * All StoryManager events that can be emitted externally.
167
188
  */
@@ -198,6 +219,12 @@ export interface StoryManagerEvents {
198
219
  finishGame: FinishGameEvent;
199
220
  /** Custom game event */
200
221
  eventGame: EventGameEvent;
222
+ /** Close story reader event */
223
+ closeStoryReader: CloseStoryReaderEvent;
224
+ /** Fired when the "Add to cart" button is pressed */
225
+ productCartUpdated: ProductCartUpdatedEvent;
226
+ /** Fired when you click the "Go to cart" button */
227
+ productCartClicked: ProductCartClickedEvent;
201
228
  /**
202
229
  * @deprecated
203
230
  * See https://docs.inappstory.com/sdk-guides/react-sdk/link-handling.html
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  ClickOnStoryEvent,
3
3
  CloseStoryEvent,
4
+ CloseStoryReaderEvent,
4
5
  DislikeStoryEvent,
5
6
  FavoriteStoryEvent,
6
7
  FeedImpressionEvent,
@@ -14,7 +15,9 @@ import {
14
15
  StartGameEvent,
15
16
  FinishGameEvent,
16
17
  CloseGameEvent,
17
- EventGameEvent
18
+ EventGameEvent,
19
+ ProductCartUpdatedEvent,
20
+ ProductCartClickedEvent
18
21
  } from "../events";
19
22
 
20
23
  /**
@@ -50,6 +53,12 @@ export interface StoryManagerEventsProps {
50
53
  */
51
54
  onCloseStory?: (event: CloseStoryEvent) => void;
52
55
 
56
+ /**
57
+ * Called when a story reader is closed
58
+ * @param event - Contains story ID and close action
59
+ */
60
+ onCloseStoryReader?: (event: CloseStoryReaderEvent) => void;
61
+
53
62
  /**
54
63
  * Called when a new slide is shown in the story
55
64
  * @param event - Contains story ID and slide index
@@ -128,6 +137,12 @@ export interface StoryManagerEventsProps {
128
137
  */
129
138
  onEventGame?: (event: EventGameEvent) => void;
130
139
 
140
+ /** Fired when the "Add to cart" button is pressed */
141
+ onProductCartUpdated?: (event: ProductCartUpdatedEvent) => void;
142
+
143
+ /** Fired when you click the "Go to cart" button */
144
+ onProductCartClicked?: (event: ProductCartClickedEvent) => void;
145
+
131
146
  /**
132
147
  *
133
148
  * @deprecated
@@ -0,0 +1,10 @@
1
+ import type { ProductCart } from "@inappstory/slide-api";
2
+
3
+ /** Products widget API */
4
+ export interface Products {
5
+ /** Getter for getting the cart state provider */
6
+ get getProductCartState(): Promise<ProductCart>;
7
+
8
+ /** Setter for setting the cart state provider */
9
+ set getProductCartState(fn: () => Promise<ProductCart>);
10
+ }
@@ -1,6 +1,7 @@
1
1
  import { StoryManagerEvents } from "./events";
2
2
  import { PublicEventHandler, PublicEvents } from "./ias-container";
3
3
  import { InAppMessaging } from "./in-app-messaging/inAppMessaging";
4
+ import { Products } from "./products";
4
5
 
5
6
  /**
6
7
  * Source of the link click within stories.
@@ -134,6 +135,11 @@ export type StoryLinkClickHandler = (payload: {
134
135
  src: LinkSource;
135
136
  }) => void;
136
137
 
138
+ /**
139
+ * Handler for native sharing
140
+ */
141
+ export type ShareHandler = (data?: ShareData) => Promise<void>;
142
+
137
143
  /**
138
144
  * Interface for external plugin integration with the StoryManager.
139
145
  */
@@ -156,11 +162,20 @@ export declare class StoryManager {
156
162
  /** Numeric SDK version code (e.g., 10700) */
157
163
  get sdkVersionCode(): number;
158
164
 
165
+ /** SDK user device ID */
166
+ get deviceId(): string
167
+
168
+ /** SDK user agent */
169
+ get userAgent(): string;
170
+
159
171
  /** Module for displaying in-app messages
160
172
  * @see https://docs.inappstory.com/sdk-guides/react-sdk/in-app-messaging.html
161
173
  */
162
174
  inAppMessaging: InAppMessaging;
163
175
 
176
+ /** Products widget API */
177
+ products: Products;
178
+
164
179
  /** Handler for story link clicks
165
180
  *
166
181
  * @example
@@ -170,6 +185,13 @@ export declare class StoryManager {
170
185
  */
171
186
  set storyLinkClickHandler(value: StoryLinkClickHandler);
172
187
 
188
+ /**
189
+ * Sets the handler for native sharing
190
+ * @example
191
+ * manager.shareHandler = navigator.share.bind(navigator)
192
+ */
193
+ set shareHandler(value: ShareHandler);
194
+
173
195
  /**
174
196
  * Displays onboarding stories, optionally filtered by feed, tags, or limit.
175
197
  * @param options Filter options and limit
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inappstory/react-sdk",
3
- "version": "1.9.0-rc.0",
3
+ "version": "1.9.1",
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.26",
61
+ "@inappstory/slide-api": "^0.1.28",
62
62
  "async-mutex": "^0.5.0",
63
63
  "bowser": "^2.11.0",
64
64
  "classnames": "^2.5.1",