@inappstory/slide-api 0.1.26 → 0.1.27

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.d.cts CHANGED
@@ -30,6 +30,30 @@ declare const enum SLIDE_IN_CACHE_STATUS {
30
30
  SUCCESS = 1
31
31
  }
32
32
 
33
+ type ProductCartOffer = {
34
+ offerId: string;
35
+ groupId?: string;
36
+ name?: string;
37
+ description?: string;
38
+ url?: string;
39
+ coverUrl?: string;
40
+ imageUrls: Array<string>;
41
+ currency?: string;
42
+ price?: string;
43
+ oldPrice?: string;
44
+ adult?: boolean;
45
+ availability: number;
46
+ size?: string;
47
+ color?: string;
48
+ quantity: number;
49
+ };
50
+ type ProductCart = {
51
+ offers: Array<ProductCartOffer>;
52
+ price: string;
53
+ oldPrice?: string;
54
+ priceCurrency: string;
55
+ };
56
+
33
57
  interface IAnimation {
34
58
  init(slide: HTMLElement, animate?: boolean): void;
35
59
  start(slide: HTMLElement, animate?: boolean): void | ((isStop: boolean) => () => void);
@@ -351,19 +375,29 @@ declare class WidgetPollLayers extends WidgetBase<WidgetPollLayersOptions> {
351
375
 
352
376
  type WidgetProductsOptions = WidgetOptionsBase;
353
377
 
354
- type OfferModel = {
378
+ type OfferDto = {
355
379
  id: number;
356
380
  offerId: string;
381
+ groupId?: string;
357
382
  name?: string;
358
383
  description?: string;
359
384
  price?: string;
360
385
  oldPrice?: string;
386
+ size?: string;
387
+ color?: string;
361
388
  currency?: string;
362
389
  availability: number;
363
390
  adult?: boolean;
364
391
  coverUrl?: string;
365
392
  url?: string;
393
+ images?: {
394
+ url: string;
395
+ width: number;
396
+ height: number;
397
+ }[];
398
+ subOffersApi?: Omit<OfferDto, "subOffersApi">[];
366
399
  };
400
+
367
401
  /**
368
402
  * adult: null
369
403
  * availability: 1
@@ -402,7 +436,7 @@ declare class WidgetProducts extends WidgetBase<WidgetProductsOptions> {
402
436
  private _statEventWidgetCardClick;
403
437
  fetchProducts(): Promise<{
404
438
  message: string;
405
- models: Array<OfferModel>;
439
+ models: Array<OfferDto>;
406
440
  }>;
407
441
  private cacheOffersMediaResources;
408
442
  private revokeOffersMediaResources;
@@ -414,6 +448,7 @@ declare class WidgetProducts extends WidgetBase<WidgetProductsOptions> {
414
448
  openProductsView(): Promise<void>;
415
449
  closeProductsView(): void;
416
450
  private createCardView;
451
+ private showProductDetails;
417
452
  private createScrollView;
418
453
  private createProductsView;
419
454
  private scrollViewRef;
@@ -953,6 +988,9 @@ declare global {
953
988
  storyLoaded(data?: string): void;
954
989
  storyLoadingFailed(data?: string): void;
955
990
  storyStarted(currentTime?: number): void;
991
+ productCartUpdate(data: string, callbacks: string): void;
992
+ productCartGetState(callbacks: string): void;
993
+ productCartClicked(): void;
956
994
  }>;
957
995
  webkit?: {
958
996
  messageHandlers?: Partial<{
@@ -977,6 +1015,15 @@ declare global {
977
1015
  storyStarted: {
978
1016
  postMessage(data: string): void;
979
1017
  };
1018
+ productCartUpdate: {
1019
+ postMessage(data: string): void;
1020
+ };
1021
+ productCartGetState: {
1022
+ postMessage(data: string): void;
1023
+ };
1024
+ productCartClicked: {
1025
+ postMessage(data: string): void;
1026
+ };
980
1027
  }>;
981
1028
  };
982
1029
  isWeb?: boolean;
@@ -992,6 +1039,7 @@ declare global {
992
1039
  __sdkSupportFileAssetsProtocol: boolean;
993
1040
  __sdkSupportTimelineOnBeforeStart: boolean;
994
1041
  __sdkSupportCorrectPauseResumeLifecycle: boolean;
1042
+ _isSdkSupportProductCart: boolean;
995
1043
  _share(id: string, config: {
996
1044
  url?: string | null;
997
1045
  text?: string | null;
@@ -1028,6 +1076,23 @@ declare global {
1028
1076
  }) => void;
1029
1077
  _onEvent<K extends keyof EventHandlersEventMap>(name: K, event: EventHandlersEventMap[K]): void;
1030
1078
  _onCardLoadingStateChange(state: CARD_LOADING_STATE, reason?: string): void;
1079
+ _promiseApiQueue: Map<string, {
1080
+ onSuccess: (value: any) => void;
1081
+ onError: (reason?: any) => void;
1082
+ }>;
1083
+ _wrapInPromise: <T>() => {
1084
+ successCb: string;
1085
+ errorCb: string;
1086
+ requestId: string;
1087
+ getPromise: (sdkApiCall: Function) => Promise<T>;
1088
+ };
1089
+ completeAsyncRequestSuccessfully: (requestId: string, plainData: string) => void;
1090
+ completeAsyncRequestError: (requestId: string, reason?: string) => void;
1091
+ _productCartUpdate(data: {
1092
+ offer: ProductCartOffer;
1093
+ }): Promise<ProductCart>;
1094
+ _productCartGetState(): Promise<ProductCart>;
1095
+ _productCartClicked(): void;
1031
1096
  }
1032
1097
  }
1033
1098
 
@@ -1062,7 +1127,7 @@ declare class SlideTimeline {
1062
1127
  * Start timeline after slide started
1063
1128
  * Nothing do if old sdk
1064
1129
  */
1065
- slideStarted(): void;
1130
+ slideStarted(): Promise<void>;
1066
1131
  slideRestarted(): void;
1067
1132
  /**
1068
1133
  *
@@ -1144,7 +1209,7 @@ interface SDKApi {
1144
1209
  setCardSessionValue(element: HTMLElement, key: string, value: string): void;
1145
1210
  getCardSessionValue(element: HTMLElement, key: string): string | undefined;
1146
1211
  isSdkSupportUpdateTimeline(): boolean;
1147
- updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): void;
1212
+ updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): Promise<void>;
1148
1213
  /** @deprecated, used only in native sdk **/
1149
1214
  cardPausedCallback(currentTime: number | null): void;
1150
1215
  /** @deprecated, used only in native sdk **/
@@ -1167,6 +1232,14 @@ interface SDKApi {
1167
1232
  isSdkSupportCorrectPauseResumeLifecycle(): boolean;
1168
1233
  emitEvent<K extends keyof EventHandlersEventMap>(name: K, event: EventHandlersEventMap[K]): void;
1169
1234
  onCardLoadingStateChange(state: CARD_LOADING_STATE, reason?: string): void;
1235
+ isSdkSupportProductCart: boolean;
1236
+ productCartUpdate(data: {
1237
+ offer: ProductCartOffer;
1238
+ }): Promise<ProductCart>;
1239
+ productCartGetState(): Promise<ProductCart>;
1240
+ productCartClicked(): void;
1241
+ onWidgetRequirePauseUI(): void;
1242
+ onWidgetRequireResumeUI(): void;
1170
1243
  }
1171
1244
 
1172
1245
  interface ISlideApiDeps {
@@ -1218,6 +1291,12 @@ interface ISlideApiDeps {
1218
1291
  cardPausedCallback: SDKApi["cardPausedCallback"];
1219
1292
  /** @deprecated, used only in native sdk **/
1220
1293
  cardResumedCallback: SDKApi["cardResumedCallback"];
1294
+ isSdkSupportProductCart: SDKApi["isSdkSupportProductCart"];
1295
+ productCartUpdate: SDKApi["productCartUpdate"];
1296
+ productCartGetState: SDKApi["productCartGetState"];
1297
+ productCartClicked: SDKApi["productCartClicked"];
1298
+ onWidgetRequirePauseUI: SDKApi["onWidgetRequirePauseUI"];
1299
+ onWidgetRequireResumeUI: SDKApi["onWidgetRequireResumeUI"];
1221
1300
  }
1222
1301
 
1223
1302
  type WidgetOptionsBase = {
@@ -1460,7 +1539,7 @@ interface SDKInterface {
1460
1539
  */
1461
1540
  setCardSessionValue(key: string, value: string): void;
1462
1541
  getCardSessionValue(key: string): string | undefined;
1463
- updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): void;
1542
+ updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): Promise<void>;
1464
1543
  /**
1465
1544
  * Get fonts from session.cache
1466
1545
  */
@@ -1504,6 +1583,13 @@ interface SDKInterface {
1504
1583
  }): void;
1505
1584
  onEvent<K extends keyof EventHandlersEventMap>(name: K, event: EventHandlersEventMap[K]): void;
1506
1585
  onCardLoadingStateChange(state: CARD_LOADING_STATE, reason?: string): void;
1586
+ productCartUpdate(data: {
1587
+ offer: ProductCartOffer;
1588
+ }): Promise<ProductCart>;
1589
+ productCartGetState(): Promise<ProductCart>;
1590
+ productCartClicked(): void;
1591
+ onWidgetRequirePauseUI(): void;
1592
+ onWidgetRequireResumeUI(): void;
1507
1593
  }
1508
1594
 
1509
1595
  type LocalData = Record<string, any>;
@@ -2120,4 +2206,4 @@ declare class SlideApi extends CardApi {
2120
2206
  }
2121
2207
 
2122
2208
  export { CARD_LOADING_STATE, ON_SLIDE_STOP_PREPARE_FOR_RESTART, SLIDE_IN_CACHE_STATUS, SlideApi, TIMELINE_ACTION, Widgets };
2123
- export type { EventHandlersEventMap, FontDTO, SDKInterface, ShowSlideEvent, WidgetPollSharedData, WidgetRangeSliderSharedData, WidgetVoteSharedData, WidgetsSharedDataMap };
2209
+ export type { EventHandlersEventMap, FontDTO, ProductCart, ProductCartOffer, SDKInterface, ShowSlideEvent, WidgetPollSharedData, WidgetRangeSliderSharedData, WidgetVoteSharedData, WidgetsSharedDataMap };
package/dist/index.d.ts CHANGED
@@ -30,6 +30,30 @@ declare const enum SLIDE_IN_CACHE_STATUS {
30
30
  SUCCESS = 1
31
31
  }
32
32
 
33
+ type ProductCartOffer = {
34
+ offerId: string;
35
+ groupId?: string;
36
+ name?: string;
37
+ description?: string;
38
+ url?: string;
39
+ coverUrl?: string;
40
+ imageUrls: Array<string>;
41
+ currency?: string;
42
+ price?: string;
43
+ oldPrice?: string;
44
+ adult?: boolean;
45
+ availability: number;
46
+ size?: string;
47
+ color?: string;
48
+ quantity: number;
49
+ };
50
+ type ProductCart = {
51
+ offers: Array<ProductCartOffer>;
52
+ price: string;
53
+ oldPrice?: string;
54
+ priceCurrency: string;
55
+ };
56
+
33
57
  interface IAnimation {
34
58
  init(slide: HTMLElement, animate?: boolean): void;
35
59
  start(slide: HTMLElement, animate?: boolean): void | ((isStop: boolean) => () => void);
@@ -351,19 +375,29 @@ declare class WidgetPollLayers extends WidgetBase<WidgetPollLayersOptions> {
351
375
 
352
376
  type WidgetProductsOptions = WidgetOptionsBase;
353
377
 
354
- type OfferModel = {
378
+ type OfferDto = {
355
379
  id: number;
356
380
  offerId: string;
381
+ groupId?: string;
357
382
  name?: string;
358
383
  description?: string;
359
384
  price?: string;
360
385
  oldPrice?: string;
386
+ size?: string;
387
+ color?: string;
361
388
  currency?: string;
362
389
  availability: number;
363
390
  adult?: boolean;
364
391
  coverUrl?: string;
365
392
  url?: string;
393
+ images?: {
394
+ url: string;
395
+ width: number;
396
+ height: number;
397
+ }[];
398
+ subOffersApi?: Omit<OfferDto, "subOffersApi">[];
366
399
  };
400
+
367
401
  /**
368
402
  * adult: null
369
403
  * availability: 1
@@ -402,7 +436,7 @@ declare class WidgetProducts extends WidgetBase<WidgetProductsOptions> {
402
436
  private _statEventWidgetCardClick;
403
437
  fetchProducts(): Promise<{
404
438
  message: string;
405
- models: Array<OfferModel>;
439
+ models: Array<OfferDto>;
406
440
  }>;
407
441
  private cacheOffersMediaResources;
408
442
  private revokeOffersMediaResources;
@@ -414,6 +448,7 @@ declare class WidgetProducts extends WidgetBase<WidgetProductsOptions> {
414
448
  openProductsView(): Promise<void>;
415
449
  closeProductsView(): void;
416
450
  private createCardView;
451
+ private showProductDetails;
417
452
  private createScrollView;
418
453
  private createProductsView;
419
454
  private scrollViewRef;
@@ -953,6 +988,9 @@ declare global {
953
988
  storyLoaded(data?: string): void;
954
989
  storyLoadingFailed(data?: string): void;
955
990
  storyStarted(currentTime?: number): void;
991
+ productCartUpdate(data: string, callbacks: string): void;
992
+ productCartGetState(callbacks: string): void;
993
+ productCartClicked(): void;
956
994
  }>;
957
995
  webkit?: {
958
996
  messageHandlers?: Partial<{
@@ -977,6 +1015,15 @@ declare global {
977
1015
  storyStarted: {
978
1016
  postMessage(data: string): void;
979
1017
  };
1018
+ productCartUpdate: {
1019
+ postMessage(data: string): void;
1020
+ };
1021
+ productCartGetState: {
1022
+ postMessage(data: string): void;
1023
+ };
1024
+ productCartClicked: {
1025
+ postMessage(data: string): void;
1026
+ };
980
1027
  }>;
981
1028
  };
982
1029
  isWeb?: boolean;
@@ -992,6 +1039,7 @@ declare global {
992
1039
  __sdkSupportFileAssetsProtocol: boolean;
993
1040
  __sdkSupportTimelineOnBeforeStart: boolean;
994
1041
  __sdkSupportCorrectPauseResumeLifecycle: boolean;
1042
+ _isSdkSupportProductCart: boolean;
995
1043
  _share(id: string, config: {
996
1044
  url?: string | null;
997
1045
  text?: string | null;
@@ -1028,6 +1076,23 @@ declare global {
1028
1076
  }) => void;
1029
1077
  _onEvent<K extends keyof EventHandlersEventMap>(name: K, event: EventHandlersEventMap[K]): void;
1030
1078
  _onCardLoadingStateChange(state: CARD_LOADING_STATE, reason?: string): void;
1079
+ _promiseApiQueue: Map<string, {
1080
+ onSuccess: (value: any) => void;
1081
+ onError: (reason?: any) => void;
1082
+ }>;
1083
+ _wrapInPromise: <T>() => {
1084
+ successCb: string;
1085
+ errorCb: string;
1086
+ requestId: string;
1087
+ getPromise: (sdkApiCall: Function) => Promise<T>;
1088
+ };
1089
+ completeAsyncRequestSuccessfully: (requestId: string, plainData: string) => void;
1090
+ completeAsyncRequestError: (requestId: string, reason?: string) => void;
1091
+ _productCartUpdate(data: {
1092
+ offer: ProductCartOffer;
1093
+ }): Promise<ProductCart>;
1094
+ _productCartGetState(): Promise<ProductCart>;
1095
+ _productCartClicked(): void;
1031
1096
  }
1032
1097
  }
1033
1098
 
@@ -1062,7 +1127,7 @@ declare class SlideTimeline {
1062
1127
  * Start timeline after slide started
1063
1128
  * Nothing do if old sdk
1064
1129
  */
1065
- slideStarted(): void;
1130
+ slideStarted(): Promise<void>;
1066
1131
  slideRestarted(): void;
1067
1132
  /**
1068
1133
  *
@@ -1144,7 +1209,7 @@ interface SDKApi {
1144
1209
  setCardSessionValue(element: HTMLElement, key: string, value: string): void;
1145
1210
  getCardSessionValue(element: HTMLElement, key: string): string | undefined;
1146
1211
  isSdkSupportUpdateTimeline(): boolean;
1147
- updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): void;
1212
+ updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): Promise<void>;
1148
1213
  /** @deprecated, used only in native sdk **/
1149
1214
  cardPausedCallback(currentTime: number | null): void;
1150
1215
  /** @deprecated, used only in native sdk **/
@@ -1167,6 +1232,14 @@ interface SDKApi {
1167
1232
  isSdkSupportCorrectPauseResumeLifecycle(): boolean;
1168
1233
  emitEvent<K extends keyof EventHandlersEventMap>(name: K, event: EventHandlersEventMap[K]): void;
1169
1234
  onCardLoadingStateChange(state: CARD_LOADING_STATE, reason?: string): void;
1235
+ isSdkSupportProductCart: boolean;
1236
+ productCartUpdate(data: {
1237
+ offer: ProductCartOffer;
1238
+ }): Promise<ProductCart>;
1239
+ productCartGetState(): Promise<ProductCart>;
1240
+ productCartClicked(): void;
1241
+ onWidgetRequirePauseUI(): void;
1242
+ onWidgetRequireResumeUI(): void;
1170
1243
  }
1171
1244
 
1172
1245
  interface ISlideApiDeps {
@@ -1218,6 +1291,12 @@ interface ISlideApiDeps {
1218
1291
  cardPausedCallback: SDKApi["cardPausedCallback"];
1219
1292
  /** @deprecated, used only in native sdk **/
1220
1293
  cardResumedCallback: SDKApi["cardResumedCallback"];
1294
+ isSdkSupportProductCart: SDKApi["isSdkSupportProductCart"];
1295
+ productCartUpdate: SDKApi["productCartUpdate"];
1296
+ productCartGetState: SDKApi["productCartGetState"];
1297
+ productCartClicked: SDKApi["productCartClicked"];
1298
+ onWidgetRequirePauseUI: SDKApi["onWidgetRequirePauseUI"];
1299
+ onWidgetRequireResumeUI: SDKApi["onWidgetRequireResumeUI"];
1221
1300
  }
1222
1301
 
1223
1302
  type WidgetOptionsBase = {
@@ -1460,7 +1539,7 @@ interface SDKInterface {
1460
1539
  */
1461
1540
  setCardSessionValue(key: string, value: string): void;
1462
1541
  getCardSessionValue(key: string): string | undefined;
1463
- updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): void;
1542
+ updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): Promise<void>;
1464
1543
  /**
1465
1544
  * Get fonts from session.cache
1466
1545
  */
@@ -1504,6 +1583,13 @@ interface SDKInterface {
1504
1583
  }): void;
1505
1584
  onEvent<K extends keyof EventHandlersEventMap>(name: K, event: EventHandlersEventMap[K]): void;
1506
1585
  onCardLoadingStateChange(state: CARD_LOADING_STATE, reason?: string): void;
1586
+ productCartUpdate(data: {
1587
+ offer: ProductCartOffer;
1588
+ }): Promise<ProductCart>;
1589
+ productCartGetState(): Promise<ProductCart>;
1590
+ productCartClicked(): void;
1591
+ onWidgetRequirePauseUI(): void;
1592
+ onWidgetRequireResumeUI(): void;
1507
1593
  }
1508
1594
 
1509
1595
  type LocalData = Record<string, any>;
@@ -2120,4 +2206,4 @@ declare class SlideApi extends CardApi {
2120
2206
  }
2121
2207
 
2122
2208
  export { CARD_LOADING_STATE, ON_SLIDE_STOP_PREPARE_FOR_RESTART, SLIDE_IN_CACHE_STATUS, SlideApi, TIMELINE_ACTION, Widgets };
2123
- export type { EventHandlersEventMap, FontDTO, SDKInterface, ShowSlideEvent, WidgetPollSharedData, WidgetRangeSliderSharedData, WidgetVoteSharedData, WidgetsSharedDataMap };
2209
+ export type { EventHandlersEventMap, FontDTO, ProductCart, ProductCartOffer, SDKInterface, ShowSlideEvent, WidgetPollSharedData, WidgetRangeSliderSharedData, WidgetVoteSharedData, WidgetsSharedDataMap };