@inappstory/slide-api 0.1.26 → 0.1.28

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
@@ -400,20 +434,23 @@ declare class WidgetProducts extends WidgetBase<WidgetProductsOptions> {
400
434
  private _statEventWidgetClick;
401
435
  private _statEventWidgetOpen;
402
436
  private _statEventWidgetCardClick;
437
+ private getOrFetchProducts;
403
438
  fetchProducts(): Promise<{
404
439
  message: string;
405
- models: Array<OfferModel>;
440
+ models: Array<OfferDto>;
406
441
  }>;
407
442
  private cacheOffersMediaResources;
408
443
  private revokeOffersMediaResources;
409
444
  private initSwipeGestureDetector;
410
445
  private productsView;
411
446
  private isOpen;
447
+ private isLoading;
412
448
  get isForcePaused(): boolean;
413
449
  private currentModels;
414
450
  openProductsView(): Promise<void>;
415
451
  closeProductsView(): void;
416
452
  private createCardView;
453
+ private showProductDetails;
417
454
  private createScrollView;
418
455
  private createProductsView;
419
456
  private scrollViewRef;
@@ -953,6 +990,9 @@ declare global {
953
990
  storyLoaded(data?: string): void;
954
991
  storyLoadingFailed(data?: string): void;
955
992
  storyStarted(currentTime?: number): void;
993
+ productCartUpdate(data: string, callbacks: string): void;
994
+ productCartGetState(callbacks: string): void;
995
+ productCartClicked(): void;
956
996
  }>;
957
997
  webkit?: {
958
998
  messageHandlers?: Partial<{
@@ -977,6 +1017,15 @@ declare global {
977
1017
  storyStarted: {
978
1018
  postMessage(data: string): void;
979
1019
  };
1020
+ productCartUpdate: {
1021
+ postMessage(data: string): void;
1022
+ };
1023
+ productCartGetState: {
1024
+ postMessage(data: string): void;
1025
+ };
1026
+ productCartClicked: {
1027
+ postMessage(data: string): void;
1028
+ };
980
1029
  }>;
981
1030
  };
982
1031
  isWeb?: boolean;
@@ -992,6 +1041,7 @@ declare global {
992
1041
  __sdkSupportFileAssetsProtocol: boolean;
993
1042
  __sdkSupportTimelineOnBeforeStart: boolean;
994
1043
  __sdkSupportCorrectPauseResumeLifecycle: boolean;
1044
+ _isSdkSupportProductCart: boolean;
995
1045
  _share(id: string, config: {
996
1046
  url?: string | null;
997
1047
  text?: string | null;
@@ -1028,6 +1078,23 @@ declare global {
1028
1078
  }) => void;
1029
1079
  _onEvent<K extends keyof EventHandlersEventMap>(name: K, event: EventHandlersEventMap[K]): void;
1030
1080
  _onCardLoadingStateChange(state: CARD_LOADING_STATE, reason?: string): void;
1081
+ _promiseApiQueue: Map<string, {
1082
+ onSuccess: (value: any) => void;
1083
+ onError: (reason?: any) => void;
1084
+ }>;
1085
+ _wrapInPromise: <T>() => {
1086
+ successCb: string;
1087
+ errorCb: string;
1088
+ requestId: string;
1089
+ getPromise: (sdkApiCall: Function) => Promise<T>;
1090
+ };
1091
+ completeAsyncRequestSuccessfully: (requestId: string, plainData: string) => void;
1092
+ completeAsyncRequestError: (requestId: string, reason?: string) => void;
1093
+ _productCartUpdate(data: {
1094
+ offer: ProductCartOffer;
1095
+ }): Promise<ProductCart>;
1096
+ _productCartGetState(): Promise<ProductCart>;
1097
+ _productCartClicked(): void;
1031
1098
  }
1032
1099
  }
1033
1100
 
@@ -1062,7 +1129,7 @@ declare class SlideTimeline {
1062
1129
  * Start timeline after slide started
1063
1130
  * Nothing do if old sdk
1064
1131
  */
1065
- slideStarted(): void;
1132
+ slideStarted(): Promise<void>;
1066
1133
  slideRestarted(): void;
1067
1134
  /**
1068
1135
  *
@@ -1144,7 +1211,7 @@ interface SDKApi {
1144
1211
  setCardSessionValue(element: HTMLElement, key: string, value: string): void;
1145
1212
  getCardSessionValue(element: HTMLElement, key: string): string | undefined;
1146
1213
  isSdkSupportUpdateTimeline(): boolean;
1147
- updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): void;
1214
+ updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): Promise<void>;
1148
1215
  /** @deprecated, used only in native sdk **/
1149
1216
  cardPausedCallback(currentTime: number | null): void;
1150
1217
  /** @deprecated, used only in native sdk **/
@@ -1167,6 +1234,14 @@ interface SDKApi {
1167
1234
  isSdkSupportCorrectPauseResumeLifecycle(): boolean;
1168
1235
  emitEvent<K extends keyof EventHandlersEventMap>(name: K, event: EventHandlersEventMap[K]): void;
1169
1236
  onCardLoadingStateChange(state: CARD_LOADING_STATE, reason?: string): void;
1237
+ isSdkSupportProductCart: boolean;
1238
+ productCartUpdate(data: {
1239
+ offer: ProductCartOffer;
1240
+ }): Promise<ProductCart>;
1241
+ productCartGetState(): Promise<ProductCart>;
1242
+ productCartClicked(): void;
1243
+ onWidgetRequirePauseUI(): void;
1244
+ onWidgetRequireResumeUI(): void;
1170
1245
  }
1171
1246
 
1172
1247
  interface ISlideApiDeps {
@@ -1218,6 +1293,12 @@ interface ISlideApiDeps {
1218
1293
  cardPausedCallback: SDKApi["cardPausedCallback"];
1219
1294
  /** @deprecated, used only in native sdk **/
1220
1295
  cardResumedCallback: SDKApi["cardResumedCallback"];
1296
+ isSdkSupportProductCart: SDKApi["isSdkSupportProductCart"];
1297
+ productCartUpdate: SDKApi["productCartUpdate"];
1298
+ productCartGetState: SDKApi["productCartGetState"];
1299
+ productCartClicked: SDKApi["productCartClicked"];
1300
+ onWidgetRequirePauseUI: SDKApi["onWidgetRequirePauseUI"];
1301
+ onWidgetRequireResumeUI: SDKApi["onWidgetRequireResumeUI"];
1221
1302
  }
1222
1303
 
1223
1304
  type WidgetOptionsBase = {
@@ -1460,7 +1541,7 @@ interface SDKInterface {
1460
1541
  */
1461
1542
  setCardSessionValue(key: string, value: string): void;
1462
1543
  getCardSessionValue(key: string): string | undefined;
1463
- updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): void;
1544
+ updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): Promise<void>;
1464
1545
  /**
1465
1546
  * Get fonts from session.cache
1466
1547
  */
@@ -1504,6 +1585,13 @@ interface SDKInterface {
1504
1585
  }): void;
1505
1586
  onEvent<K extends keyof EventHandlersEventMap>(name: K, event: EventHandlersEventMap[K]): void;
1506
1587
  onCardLoadingStateChange(state: CARD_LOADING_STATE, reason?: string): void;
1588
+ productCartUpdate(data: {
1589
+ offer: ProductCartOffer;
1590
+ }): Promise<ProductCart>;
1591
+ productCartGetState(): Promise<ProductCart>;
1592
+ productCartClicked(): void;
1593
+ onWidgetRequirePauseUI(): void;
1594
+ onWidgetRequireResumeUI(): void;
1507
1595
  }
1508
1596
 
1509
1597
  type LocalData = Record<string, any>;
@@ -2120,4 +2208,4 @@ declare class SlideApi extends CardApi {
2120
2208
  }
2121
2209
 
2122
2210
  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 };
2211
+ 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
@@ -400,20 +434,23 @@ declare class WidgetProducts extends WidgetBase<WidgetProductsOptions> {
400
434
  private _statEventWidgetClick;
401
435
  private _statEventWidgetOpen;
402
436
  private _statEventWidgetCardClick;
437
+ private getOrFetchProducts;
403
438
  fetchProducts(): Promise<{
404
439
  message: string;
405
- models: Array<OfferModel>;
440
+ models: Array<OfferDto>;
406
441
  }>;
407
442
  private cacheOffersMediaResources;
408
443
  private revokeOffersMediaResources;
409
444
  private initSwipeGestureDetector;
410
445
  private productsView;
411
446
  private isOpen;
447
+ private isLoading;
412
448
  get isForcePaused(): boolean;
413
449
  private currentModels;
414
450
  openProductsView(): Promise<void>;
415
451
  closeProductsView(): void;
416
452
  private createCardView;
453
+ private showProductDetails;
417
454
  private createScrollView;
418
455
  private createProductsView;
419
456
  private scrollViewRef;
@@ -953,6 +990,9 @@ declare global {
953
990
  storyLoaded(data?: string): void;
954
991
  storyLoadingFailed(data?: string): void;
955
992
  storyStarted(currentTime?: number): void;
993
+ productCartUpdate(data: string, callbacks: string): void;
994
+ productCartGetState(callbacks: string): void;
995
+ productCartClicked(): void;
956
996
  }>;
957
997
  webkit?: {
958
998
  messageHandlers?: Partial<{
@@ -977,6 +1017,15 @@ declare global {
977
1017
  storyStarted: {
978
1018
  postMessage(data: string): void;
979
1019
  };
1020
+ productCartUpdate: {
1021
+ postMessage(data: string): void;
1022
+ };
1023
+ productCartGetState: {
1024
+ postMessage(data: string): void;
1025
+ };
1026
+ productCartClicked: {
1027
+ postMessage(data: string): void;
1028
+ };
980
1029
  }>;
981
1030
  };
982
1031
  isWeb?: boolean;
@@ -992,6 +1041,7 @@ declare global {
992
1041
  __sdkSupportFileAssetsProtocol: boolean;
993
1042
  __sdkSupportTimelineOnBeforeStart: boolean;
994
1043
  __sdkSupportCorrectPauseResumeLifecycle: boolean;
1044
+ _isSdkSupportProductCart: boolean;
995
1045
  _share(id: string, config: {
996
1046
  url?: string | null;
997
1047
  text?: string | null;
@@ -1028,6 +1078,23 @@ declare global {
1028
1078
  }) => void;
1029
1079
  _onEvent<K extends keyof EventHandlersEventMap>(name: K, event: EventHandlersEventMap[K]): void;
1030
1080
  _onCardLoadingStateChange(state: CARD_LOADING_STATE, reason?: string): void;
1081
+ _promiseApiQueue: Map<string, {
1082
+ onSuccess: (value: any) => void;
1083
+ onError: (reason?: any) => void;
1084
+ }>;
1085
+ _wrapInPromise: <T>() => {
1086
+ successCb: string;
1087
+ errorCb: string;
1088
+ requestId: string;
1089
+ getPromise: (sdkApiCall: Function) => Promise<T>;
1090
+ };
1091
+ completeAsyncRequestSuccessfully: (requestId: string, plainData: string) => void;
1092
+ completeAsyncRequestError: (requestId: string, reason?: string) => void;
1093
+ _productCartUpdate(data: {
1094
+ offer: ProductCartOffer;
1095
+ }): Promise<ProductCart>;
1096
+ _productCartGetState(): Promise<ProductCart>;
1097
+ _productCartClicked(): void;
1031
1098
  }
1032
1099
  }
1033
1100
 
@@ -1062,7 +1129,7 @@ declare class SlideTimeline {
1062
1129
  * Start timeline after slide started
1063
1130
  * Nothing do if old sdk
1064
1131
  */
1065
- slideStarted(): void;
1132
+ slideStarted(): Promise<void>;
1066
1133
  slideRestarted(): void;
1067
1134
  /**
1068
1135
  *
@@ -1144,7 +1211,7 @@ interface SDKApi {
1144
1211
  setCardSessionValue(element: HTMLElement, key: string, value: string): void;
1145
1212
  getCardSessionValue(element: HTMLElement, key: string): string | undefined;
1146
1213
  isSdkSupportUpdateTimeline(): boolean;
1147
- updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): void;
1214
+ updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): Promise<void>;
1148
1215
  /** @deprecated, used only in native sdk **/
1149
1216
  cardPausedCallback(currentTime: number | null): void;
1150
1217
  /** @deprecated, used only in native sdk **/
@@ -1167,6 +1234,14 @@ interface SDKApi {
1167
1234
  isSdkSupportCorrectPauseResumeLifecycle(): boolean;
1168
1235
  emitEvent<K extends keyof EventHandlersEventMap>(name: K, event: EventHandlersEventMap[K]): void;
1169
1236
  onCardLoadingStateChange(state: CARD_LOADING_STATE, reason?: string): void;
1237
+ isSdkSupportProductCart: boolean;
1238
+ productCartUpdate(data: {
1239
+ offer: ProductCartOffer;
1240
+ }): Promise<ProductCart>;
1241
+ productCartGetState(): Promise<ProductCart>;
1242
+ productCartClicked(): void;
1243
+ onWidgetRequirePauseUI(): void;
1244
+ onWidgetRequireResumeUI(): void;
1170
1245
  }
1171
1246
 
1172
1247
  interface ISlideApiDeps {
@@ -1218,6 +1293,12 @@ interface ISlideApiDeps {
1218
1293
  cardPausedCallback: SDKApi["cardPausedCallback"];
1219
1294
  /** @deprecated, used only in native sdk **/
1220
1295
  cardResumedCallback: SDKApi["cardResumedCallback"];
1296
+ isSdkSupportProductCart: SDKApi["isSdkSupportProductCart"];
1297
+ productCartUpdate: SDKApi["productCartUpdate"];
1298
+ productCartGetState: SDKApi["productCartGetState"];
1299
+ productCartClicked: SDKApi["productCartClicked"];
1300
+ onWidgetRequirePauseUI: SDKApi["onWidgetRequirePauseUI"];
1301
+ onWidgetRequireResumeUI: SDKApi["onWidgetRequireResumeUI"];
1221
1302
  }
1222
1303
 
1223
1304
  type WidgetOptionsBase = {
@@ -1460,7 +1541,7 @@ interface SDKInterface {
1460
1541
  */
1461
1542
  setCardSessionValue(key: string, value: string): void;
1462
1543
  getCardSessionValue(key: string): string | undefined;
1463
- updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): void;
1544
+ updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): Promise<void>;
1464
1545
  /**
1465
1546
  * Get fonts from session.cache
1466
1547
  */
@@ -1504,6 +1585,13 @@ interface SDKInterface {
1504
1585
  }): void;
1505
1586
  onEvent<K extends keyof EventHandlersEventMap>(name: K, event: EventHandlersEventMap[K]): void;
1506
1587
  onCardLoadingStateChange(state: CARD_LOADING_STATE, reason?: string): void;
1588
+ productCartUpdate(data: {
1589
+ offer: ProductCartOffer;
1590
+ }): Promise<ProductCart>;
1591
+ productCartGetState(): Promise<ProductCart>;
1592
+ productCartClicked(): void;
1593
+ onWidgetRequirePauseUI(): void;
1594
+ onWidgetRequireResumeUI(): void;
1507
1595
  }
1508
1596
 
1509
1597
  type LocalData = Record<string, any>;
@@ -2120,4 +2208,4 @@ declare class SlideApi extends CardApi {
2120
2208
  }
2121
2209
 
2122
2210
  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 };
2211
+ export type { EventHandlersEventMap, FontDTO, ProductCart, ProductCartOffer, SDKInterface, ShowSlideEvent, WidgetPollSharedData, WidgetRangeSliderSharedData, WidgetVoteSharedData, WidgetsSharedDataMap };