@inappstory/slide-api 0.0.5 → 0.0.6

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
@@ -260,6 +260,8 @@ interface SDKApi {
260
260
  showStorySlide(index: number): void;
261
261
  isExistsShowNextStory: boolean;
262
262
  storyShowNext(): void;
263
+ setStorySessionValue(element: HTMLElement, key: string, value: string): void;
264
+ getStorySessionValue(element: HTMLElement, key: string): string | undefined;
263
265
  }
264
266
  declare class WidgetsService {
265
267
  private _env;
@@ -432,6 +434,11 @@ interface SDKInterface {
432
434
  * window._storyShowNext();
433
435
  */
434
436
  storyShowNext(): void;
437
+ /**
438
+ * Cache with lifetime - while story rendered on Screen
439
+ */
440
+ setStorySessionValue(key: string, value: string): void;
441
+ getStorySessionValue(key: string): string | undefined;
435
442
  }
436
443
  type WidgetCopyOptions = WidgetOptionsBase;
437
444
  declare class WidgetCopy extends WidgetBase<WidgetCopyOptions> {
package/dist/index.d.ts CHANGED
@@ -260,6 +260,8 @@ interface SDKApi {
260
260
  showStorySlide(index: number): void;
261
261
  isExistsShowNextStory: boolean;
262
262
  storyShowNext(): void;
263
+ setStorySessionValue(element: HTMLElement, key: string, value: string): void;
264
+ getStorySessionValue(element: HTMLElement, key: string): string | undefined;
263
265
  }
264
266
  declare class WidgetsService {
265
267
  private _env;
@@ -432,6 +434,11 @@ interface SDKInterface {
432
434
  * window._storyShowNext();
433
435
  */
434
436
  storyShowNext(): void;
437
+ /**
438
+ * Cache with lifetime - while story rendered on Screen
439
+ */
440
+ setStorySessionValue(key: string, value: string): void;
441
+ getStorySessionValue(key: string): string | undefined;
435
442
  }
436
443
  type WidgetCopyOptions = WidgetOptionsBase;
437
444
  declare class WidgetCopy extends WidgetBase<WidgetCopyOptions> {
package/dist/index.js CHANGED
@@ -1124,6 +1124,12 @@ class EsModuleSdkApi {
1124
1124
  storyShowNext() {
1125
1125
  this.sdkBinding().storyShowNext();
1126
1126
  }
1127
+ setStorySessionValue(element, key, value) {
1128
+ this.sdkBinding().setStorySessionValue(key, value);
1129
+ }
1130
+ getStorySessionValue(element, key) {
1131
+ return this.sdkBinding().getStorySessionValue(key);
1132
+ }
1127
1133
  static get [Symbol.for("___CTOR_ARGS___")]() { return [`() => SDKInterface`]; }
1128
1134
  }
1129
1135
 
@@ -2821,35 +2827,10 @@ class WidgetQuest extends WidgetBase {
2821
2827
  }
2822
2828
  refreshUserData(localData) { }
2823
2829
  setStorySessionValue(name, value) {
2824
- try {
2825
- var parent = this.element.closest(".stories-item");
2826
- if (parent) {
2827
- parent.dataset[name] = value;
2828
- }
2829
- else {
2830
- //@ts-ignore
2831
- this.env[name] = value;
2832
- }
2833
- }
2834
- catch (e) {
2835
- console.error(e);
2836
- }
2830
+ this.sdkApi.setStorySessionValue(this.element, name, value);
2837
2831
  }
2838
2832
  getStorySessionValue(name) {
2839
- try {
2840
- var parent = this.element.closest(".stories-item");
2841
- if (parent) {
2842
- return parent.dataset[name];
2843
- }
2844
- else {
2845
- // @ts-ignore
2846
- return this.env[name];
2847
- }
2848
- }
2849
- catch (e) {
2850
- console.error(e);
2851
- return undefined;
2852
- }
2833
+ return this.sdkApi.getStorySessionValue(this.element, name);
2853
2834
  }
2854
2835
  init() {
2855
2836
  if (this.localData) {
@@ -2866,6 +2847,7 @@ class WidgetQuest extends WidgetBase {
2866
2847
  lastSlideIdx !== this.slideIndex /*&& this.slideIndex === this.firstSlideWithQuestIndex()*/) {
2867
2848
  if (this.getStorySessionValue("__storyQuestSlideChanged") === undefined) {
2868
2849
  // global flag - был сделан переход на нужный слайд, больше не нужно повторять за эту сессию
2850
+ // perform showStorySlide with lastSlideIdx only on story open first time (not on second slide, etc)
2869
2851
  this.setStorySessionValue("__storyQuestSlideChanged", "1");
2870
2852
  if (this.sdkApi.isExistsShowStorySlide) {
2871
2853
  this.sdkApi.showStorySlide(lastSlideIdx);