@inappstory/react-sdk 1.9.0-rc.0 → 1.9.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.
@@ -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
  */
@@ -161,6 +167,9 @@ export declare class StoryManager {
161
167
  */
162
168
  inAppMessaging: InAppMessaging;
163
169
 
170
+ /** Products widget API */
171
+ products: Products;
172
+
164
173
  /** Handler for story link clicks
165
174
  *
166
175
  * @example
@@ -170,6 +179,13 @@ export declare class StoryManager {
170
179
  */
171
180
  set storyLinkClickHandler(value: StoryLinkClickHandler);
172
181
 
182
+ /**
183
+ * Sets the handler for native sharing
184
+ * @example
185
+ * manager.shareHandler = navigator.share.bind(navigator)
186
+ */
187
+ set shareHandler(value: ShareHandler);
188
+
173
189
  /**
174
190
  * Displays onboarding stories, optionally filtered by feed, tags, or limit.
175
191
  * @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.0",
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.27",
62
62
  "async-mutex": "^0.5.0",
63
63
  "bowser": "^2.11.0",
64
64
  "classnames": "^2.5.1",