@inappstory/slide-api 0.0.8 → 0.0.10
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.cjs +310 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +287 -236
- package/dist/index.d.ts +287 -236
- package/dist/index.js +310 -55
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.d.cts
CHANGED
|
@@ -75,6 +75,7 @@ declare class WidgetRangeSlider extends WidgetBase<WidgetRangeSliderOptions> {
|
|
|
75
75
|
private setValue;
|
|
76
76
|
private destroy;
|
|
77
77
|
static api: {
|
|
78
|
+
widgetClassName: string;
|
|
78
79
|
refreshUserData: typeof WidgetBase.refreshUserData;
|
|
79
80
|
initWidget: (element: HTMLElement, localData?: Record<string, any>) => void;
|
|
80
81
|
click: (element: HTMLElement) => boolean;
|
|
@@ -131,6 +132,7 @@ declare class WidgetPoll extends WidgetBase<WidgetPollOptions> {
|
|
|
131
132
|
isDone(): boolean;
|
|
132
133
|
slidePollIsDone(): boolean;
|
|
133
134
|
static api: {
|
|
135
|
+
widgetClassName: string;
|
|
134
136
|
refreshUserData: typeof WidgetBase.refreshUserData;
|
|
135
137
|
initWidget: (element: HTMLElement, localData?: Record<string, any>) => void;
|
|
136
138
|
select: (element: HTMLElement) => boolean;
|
|
@@ -156,24 +158,40 @@ declare class WidgetVote extends WidgetBase<WidgetVoteOptions> {
|
|
|
156
158
|
private selectedVariant;
|
|
157
159
|
private voteAllocation;
|
|
158
160
|
private hideClientTotalResult;
|
|
161
|
+
private multipleChoice;
|
|
159
162
|
/**
|
|
160
163
|
* @throws Error
|
|
161
164
|
* @param element
|
|
162
165
|
* @param options
|
|
163
166
|
*/
|
|
164
167
|
constructor(element: HTMLElement, options: Partial<WidgetVoteOptions>);
|
|
168
|
+
private _initFromLocalData;
|
|
165
169
|
refreshUserData(localData: Record<string, any>): void;
|
|
170
|
+
private _clearSelectedVariants;
|
|
166
171
|
private _statEventVoteVariant;
|
|
172
|
+
// user click on (un)checked (radio btn) variant
|
|
173
|
+
private _checkVariant;
|
|
174
|
+
private _getCheckedVariants;
|
|
167
175
|
private _selectVariant;
|
|
176
|
+
private _fillWidget;
|
|
177
|
+
private _showSubmitBtn;
|
|
178
|
+
private _hideSubmitBtn;
|
|
168
179
|
selectVariant(variant: HTMLElement): boolean;
|
|
180
|
+
private _setInputDone;
|
|
181
|
+
private _removeInputDone;
|
|
182
|
+
private _completeWidget;
|
|
183
|
+
private submitMultipleChoice;
|
|
184
|
+
click(): boolean;
|
|
169
185
|
private displayPercents;
|
|
170
186
|
isDone(): boolean;
|
|
171
187
|
slideVoteIsDone(): boolean;
|
|
172
188
|
static api: {
|
|
189
|
+
widgetClassName: string;
|
|
173
190
|
refreshUserData: typeof WidgetBase.refreshUserData;
|
|
174
191
|
fallbackInitOnMultiSlide: (element: HTMLElement, localData?: Record<string, any>) => void;
|
|
175
192
|
initWidget: (element: HTMLElement, localData?: Record<string, any>) => void;
|
|
176
193
|
select: (element: HTMLElement) => boolean;
|
|
194
|
+
click: (element: HTMLElement) => boolean;
|
|
177
195
|
slideVoteIsDone: (element: HTMLElement) => boolean;
|
|
178
196
|
};
|
|
179
197
|
}
|
|
@@ -206,239 +224,16 @@ interface WidgetsSharedDataMap {
|
|
|
206
224
|
vote: WidgetVoteSharedData;
|
|
207
225
|
}
|
|
208
226
|
interface IAnimation {
|
|
209
|
-
start(slide: HTMLElement, animate?: boolean): void;
|
|
227
|
+
start(slide: HTMLElement, animate?: boolean): void | ((isStop: boolean) => () => void);
|
|
210
228
|
stop(slide: HTMLElement, animate?: boolean): void;
|
|
211
229
|
pause(slide: HTMLElement): void;
|
|
212
230
|
resume(slide: HTMLElement): void;
|
|
213
231
|
reset(slide: HTMLElement): void;
|
|
214
232
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
[key: string]: string;
|
|
220
|
-
};
|
|
221
|
-
requestId: number | string;
|
|
222
|
-
};
|
|
223
|
-
interface SDKApi {
|
|
224
|
-
getStoryServerData(storyId: number): Record<string, any> | null;
|
|
225
|
-
getSlideDuration(storyId: number, slideIndex: number): number | null;
|
|
226
|
-
showNextSlide(duration: number): void;
|
|
227
|
-
sendStatisticEvent(name: string, data: Record<string, string | number>, devPayload?: Record<string, string | number>): void;
|
|
228
|
-
getStoryLocalData(): Promise<Record<string, any>>;
|
|
229
|
-
isExistsShowLayer(): boolean;
|
|
230
|
-
showLayer(index: number): void;
|
|
231
|
-
storyAnimation: IAnimation | undefined;
|
|
232
|
-
isAndroid: boolean;
|
|
233
|
-
isWeb: boolean;
|
|
234
|
-
isIOS: boolean;
|
|
235
|
-
pauseUI(): void;
|
|
236
|
-
resumeUI(): void;
|
|
237
|
-
isExistsShowStoryTextInput: boolean;
|
|
238
|
-
showStoryTextInput(id: string, data: Record<string, any>): void;
|
|
239
|
-
setStoryLocalData(keyValue: Record<string, any>, sendToServer: boolean): void;
|
|
240
|
-
getWidgetsSharedData<WidgetType extends keyof WidgetsSharedDataMap>(storyId: number, widget: Widgets): WidgetsSharedDataMap[WidgetType] | null;
|
|
241
|
-
vibrate(pattern: number): void;
|
|
242
|
-
openUrl(target: string): void;
|
|
243
|
-
sendApiRequest<ResponseDTO>(url: string, method: string, params: Record<string, any> | null, headers: Record<string, any> | null, data: Record<string, any> | null, profilingKey: string): Promise<APIResponse<ResponseDTO>>;
|
|
244
|
-
sendApiRequestSupported(): boolean;
|
|
245
|
-
showToast(text: string): void;
|
|
246
|
-
sdkCanSendShareComplete: boolean;
|
|
247
|
-
isExistsShare: boolean;
|
|
248
|
-
share(id: string, config: {
|
|
249
|
-
url?: string | null;
|
|
250
|
-
text?: string | null;
|
|
251
|
-
title?: string | null;
|
|
252
|
-
files?: Array<{
|
|
253
|
-
file: File;
|
|
254
|
-
name: string;
|
|
255
|
-
type: string;
|
|
256
|
-
}> | null;
|
|
257
|
-
}): void;
|
|
258
|
-
shareSlideScreenshot(shareId: string, hideElementsSelector?: string): void;
|
|
259
|
-
isExistsShowStorySlide: boolean;
|
|
260
|
-
showStorySlide(index: number): void;
|
|
261
|
-
isExistsShowNextStory: boolean;
|
|
262
|
-
storyShowNext(): void;
|
|
263
|
-
setStorySessionValue(element: HTMLElement, key: string, value: string): void;
|
|
264
|
-
getStorySessionValue(element: HTMLElement, key: string): string | undefined;
|
|
265
|
-
}
|
|
266
|
-
declare class WidgetsService {
|
|
267
|
-
private _env;
|
|
268
|
-
private _sdkApi;
|
|
269
|
-
constructor(_env: Window, _sdkApi: SDKApi);
|
|
270
|
-
get env(): Window;
|
|
271
|
-
get sdkApi(): SDKApi;
|
|
272
|
-
}
|
|
273
|
-
declare class WidgetBase<WidgetOptions extends WidgetOptionsBase> {
|
|
274
|
-
/**
|
|
275
|
-
* @see https://github.com/Microsoft/TypeScript/issues/3841#issuecomment-1488919713
|
|
276
|
-
*/
|
|
277
|
-
["constructor"]: typeof WidgetBase;
|
|
278
|
-
static DEFAULTS: WidgetOptionsBase;
|
|
279
|
-
static widgetIndex: number;
|
|
280
|
-
protected env: Window;
|
|
281
|
-
protected sdkApi: SDKApi;
|
|
282
|
-
protected options: WidgetOptions;
|
|
283
|
-
protected element: HTMLElement;
|
|
284
|
-
protected elementId: string;
|
|
285
|
-
protected slide: HTMLElement;
|
|
286
|
-
protected slideIndex: number;
|
|
287
|
-
protected disableTimer: boolean;
|
|
288
|
-
protected layoutDirection: "ltr" | "rtl";
|
|
289
|
-
protected storyId: number;
|
|
290
|
-
protected widgetDone: Element | null;
|
|
291
|
-
protected showWidgetCompleteToast: boolean;
|
|
292
|
-
protected submitButtonAnimatedView: HTMLElement | null;
|
|
293
|
-
protected submitButtonView: HTMLElement | null;
|
|
294
|
-
protected submitButtonViewHeight: number;
|
|
295
|
-
protected savedData: Record<string, any> | null;
|
|
296
|
-
protected localData: Record<string, any>;
|
|
297
|
-
protected firstOpenTime: number;
|
|
298
|
-
protected id: string;
|
|
299
|
-
constructor(element: HTMLElement, options: Partial<WidgetOptions>, elementIdGetter?: (element: HTMLElement) => string, slideGetter?: (element: HTMLElement) => HTMLElement);
|
|
300
|
-
refreshUserData(localData: Record<string, any>): void;
|
|
301
|
-
static widgetCacheKey: string;
|
|
302
|
-
static widgetClassName: string;
|
|
303
|
-
static getInstance<Widget extends WidgetBase<WidgetOptions>, WidgetOptions extends WidgetOptionsBase>(element: HTMLElement): Widget | undefined;
|
|
304
|
-
static getInstanceById<Widget extends WidgetBase<WidgetOptions>, WidgetOptions extends WidgetOptionsBase>(id: string): Widget | undefined;
|
|
305
|
-
static createInstance<Widget extends WidgetBase<WidgetOptions>, WidgetOptions extends WidgetOptionsBase>(instantiate: (element: HTMLElement, options: Partial<WidgetOptions>) => Widget, element: HTMLElement, options: Partial<WidgetOptions>): Widget;
|
|
306
|
-
static initWidgets<Widget extends WidgetBase<WidgetOptions>, WidgetOptions extends WidgetOptionsBase>(instantiate: (element: HTMLElement, options: Partial<WidgetOptions>) => Widget, elements: Array<HTMLElement>, localData?: Record<string, any>): Promise<Record<string, any>>;
|
|
307
|
-
static get widgetsService(): WidgetsService;
|
|
308
|
-
static getLocalData(): Promise<Record<string, any>>;
|
|
309
|
-
getLocalData(): Promise<Record<string, any>>;
|
|
310
|
-
static setLocalData(keyValue: Record<string, any>, sendToServer?: boolean, syncWithRuntimeLocalData?: boolean): void;
|
|
311
|
-
setLocalData(keyValue: Record<string, any>, sendToServer?: boolean, syncWithRuntimeLocalData?: boolean): void;
|
|
312
|
-
static sendStatisticEventToApp(name: string, data: Record<string, string | number>, devPayload?: Record<string, string | number>): void;
|
|
313
|
-
sendStatisticEventToApp(name: string, data: Record<string, string | number>, devPayload?: Record<string, string | number>): void;
|
|
314
|
-
showNextSlide(): void;
|
|
315
|
-
protected _showLayout(layers: Array<HTMLElement>, selectIndex: number, withStatEvent?: boolean): void;
|
|
316
|
-
protected _statEventLayoutShow(layoutIndex: number): void;
|
|
317
|
-
static refreshUserData<Widget extends WidgetBase<WidgetOptions>, WidgetOptions extends WidgetOptionsBase>(nodes: NodeListOf<HTMLElement>, localData?: Record<string, any>): void;
|
|
318
|
-
}
|
|
319
|
-
interface SDKInterface {
|
|
320
|
-
/**
|
|
321
|
-
* Return object from widgetsData._narrative_saved_data[storyId] or null
|
|
322
|
-
*
|
|
323
|
-
* Possible implementation
|
|
324
|
-
* if ("_narrative_saved_data" in window && window._narrative_saved_data[storyId] != null && isObject(window._narrative_saved_data[storyId])) {
|
|
325
|
-
* return window._narrative_saved_data[storyId];
|
|
326
|
-
* }
|
|
327
|
-
*/
|
|
328
|
-
getStoryServerData(storyId: number): Record<string, any> | null;
|
|
329
|
-
/**
|
|
330
|
-
* Return slide duration or null
|
|
331
|
-
*
|
|
332
|
-
* Possible implementation
|
|
333
|
-
* if (
|
|
334
|
-
* "_narrative_slides_duration" in window &&
|
|
335
|
-
* window._narrative_slides_duration[storyId] != null &&
|
|
336
|
-
* isArray(window._narrative_slides_duration[storyId]) &&
|
|
337
|
-
* window._narrative_slides_duration[storyId][slideIndex] != null &&
|
|
338
|
-
* isNumber(window._narrative_slides_duration[storyId][slideIndex])
|
|
339
|
-
* ) {
|
|
340
|
-
* return window._narrative_slides_duration[storyId][slideIndex];
|
|
341
|
-
* }
|
|
342
|
-
*/
|
|
343
|
-
getSlideDuration(storyId: number, slideIndex: number): number | null;
|
|
344
|
-
showNextSlide(duration: number): void;
|
|
345
|
-
/**
|
|
346
|
-
* From native sdk, do`t implement in web|react-sdk
|
|
347
|
-
*/
|
|
348
|
-
sendStatisticEvent(name: string, data: Record<string, string | number>, devPayload?: Record<string, string | number>): void;
|
|
349
|
-
getStoryLocalData(): Promise<Record<string, any>>;
|
|
350
|
-
setStoryLocalData(keyValue: Record<string, any>, sendToServer: boolean): void;
|
|
351
|
-
showLayer(index: number): void;
|
|
352
|
-
/**
|
|
353
|
-
* Pause timer (story timeline), SlideApi used it on ShowTextInput appear
|
|
354
|
-
*/
|
|
355
|
-
pauseUI(): void;
|
|
356
|
-
/**
|
|
357
|
-
* Resume timer (story timeline), SlideApi used it on ShowTextInput disappear
|
|
358
|
-
*/
|
|
359
|
-
resumeUI(): void;
|
|
360
|
-
showStoryTextInput(id: string, data: Record<string, any>): void;
|
|
361
|
-
/**
|
|
362
|
-
* Possible implementation
|
|
363
|
-
*
|
|
364
|
-
* getWidgetsSharedData<WidgetType extends keyof WidgetsSharedDataMap>(storyId: number, widget: Widgets): WidgetsSharedDataMap[WidgetType] | null {
|
|
365
|
-
* switch (widget) {
|
|
366
|
-
* case Widgets.RangeSlider: {
|
|
367
|
-
* if ("_narrative_range_slider_data" in window && isObject(window._narrative_range_slider_data[storyId])) {
|
|
368
|
-
* return window._narrative_range_slider_data[storyId] as WidgetsSharedDataMap[WidgetType];
|
|
369
|
-
* }
|
|
370
|
-
* break;
|
|
371
|
-
* }
|
|
372
|
-
* case Widgets.Poll: {
|
|
373
|
-
* if ("_narrative_poll_data" in window && isObject(window._narrative_poll_data[storyId])) {
|
|
374
|
-
* return window._narrative_poll_data[storyId] as WidgetsSharedDataMap[WidgetType];
|
|
375
|
-
* }
|
|
376
|
-
* break;
|
|
377
|
-
* }
|
|
378
|
-
* case Widgets.Vote: {
|
|
379
|
-
* if ("_narrative_vote_data" in window && isObject(window._narrative_vote_data[storyId])) {
|
|
380
|
-
* return window._narrative_vote_data[storyId] as WidgetsSharedDataMap[WidgetType];
|
|
381
|
-
* }
|
|
382
|
-
* break;
|
|
383
|
-
* }
|
|
384
|
-
* }
|
|
385
|
-
*
|
|
386
|
-
* return null;
|
|
387
|
-
* }
|
|
388
|
-
*/
|
|
389
|
-
getWidgetsSharedData<WidgetType extends keyof WidgetsSharedDataMap>(storyId: number, widget: Widgets): WidgetsSharedDataMap[WidgetType] | null;
|
|
390
|
-
/**
|
|
391
|
-
* Possible implementation
|
|
392
|
-
*
|
|
393
|
-
* if ("_showNarrativeLink" in window) {
|
|
394
|
-
* window._showNarrativeLink(target);
|
|
395
|
-
* }
|
|
396
|
-
*/
|
|
397
|
-
openUrl(target: string): void;
|
|
398
|
-
/**
|
|
399
|
-
* Possible implementation
|
|
400
|
-
*
|
|
401
|
-
* return window._sendApiRequest(url, method, params, headers, data, profilingKey);
|
|
402
|
-
*/
|
|
403
|
-
sendApiRequest<ResponseDTO>(url: string, method: string, params: Record<string, any> | null, headers: Record<string, any> | null, data: Record<string, any> | null, profilingKey: string): Promise<APIResponse<ResponseDTO>>;
|
|
404
|
-
/**
|
|
405
|
-
* Possible implementation
|
|
406
|
-
*
|
|
407
|
-
* window._share(id, config);
|
|
408
|
-
*/
|
|
409
|
-
share(id: string, config: {
|
|
410
|
-
url?: string | null;
|
|
411
|
-
text?: string | null;
|
|
412
|
-
title?: string | null;
|
|
413
|
-
files?: Array<{
|
|
414
|
-
file: File;
|
|
415
|
-
name: string;
|
|
416
|
-
type: string;
|
|
417
|
-
}> | null;
|
|
418
|
-
}): void;
|
|
419
|
-
/**
|
|
420
|
-
* Possible implementation
|
|
421
|
-
*
|
|
422
|
-
* window.share_slide_screenshot(shareId, hideElementsSelector);
|
|
423
|
-
*/
|
|
424
|
-
shareSlideScreenshot(shareId: string, hideElementsSelector?: string): void;
|
|
425
|
-
/**
|
|
426
|
-
* Possible implementation
|
|
427
|
-
*
|
|
428
|
-
* window._showNarrativeSlide(index);
|
|
429
|
-
*/
|
|
430
|
-
showStorySlide(index: number): void;
|
|
431
|
-
/**
|
|
432
|
-
* Possible implementation
|
|
433
|
-
*
|
|
434
|
-
* window._storyShowNext();
|
|
435
|
-
*/
|
|
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;
|
|
233
|
+
declare const enum TIMELINE_ACTION {
|
|
234
|
+
START = "start",
|
|
235
|
+
PAUSE = "pause",
|
|
236
|
+
STOP = "stop"
|
|
442
237
|
}
|
|
443
238
|
type WidgetCopyOptions = WidgetOptionsBase;
|
|
444
239
|
declare class WidgetCopy extends WidgetBase<WidgetCopyOptions> {
|
|
@@ -468,8 +263,9 @@ declare class WidgetCopy extends WidgetBase<WidgetCopyOptions> {
|
|
|
468
263
|
private completeWidget;
|
|
469
264
|
isDone(): boolean;
|
|
470
265
|
static api: {
|
|
266
|
+
widgetClassName: string;
|
|
471
267
|
refreshUserData: typeof WidgetBase.refreshUserData;
|
|
472
|
-
initWidget: (nodeList:
|
|
268
|
+
initWidget: (nodeList: Iterable<HTMLElement>, localData?: Record<string, any>) => void;
|
|
473
269
|
click: (element: HTMLElement) => boolean;
|
|
474
270
|
};
|
|
475
271
|
}
|
|
@@ -501,8 +297,9 @@ declare class WidgetDataInput extends WidgetBase<WidgetDataInputOptions> {
|
|
|
501
297
|
private _fillUserText;
|
|
502
298
|
setUserText(text: string): void;
|
|
503
299
|
static api: {
|
|
300
|
+
widgetClassName: string;
|
|
504
301
|
refreshUserData: typeof WidgetBase.refreshUserData;
|
|
505
|
-
initWidget: (nodeList:
|
|
302
|
+
initWidget: (nodeList: Iterable<HTMLElement>, localData?: Record<string, any>) => void;
|
|
506
303
|
click: (element: HTMLElement) => boolean;
|
|
507
304
|
setUserData: (id: string, text: string) => void;
|
|
508
305
|
};
|
|
@@ -537,10 +334,11 @@ declare class WidgetDateCountdown extends WidgetBase<WidgetDateCountdownOptions>
|
|
|
537
334
|
private updateTimer;
|
|
538
335
|
private _asDuration;
|
|
539
336
|
static api: {
|
|
337
|
+
widgetClassName: string;
|
|
540
338
|
refreshUserData: typeof WidgetBase.refreshUserData;
|
|
541
|
-
initWidget: (nodeList:
|
|
542
|
-
pause: (nodeList:
|
|
543
|
-
resume: (nodeList:
|
|
339
|
+
initWidget: (nodeList: Iterable<HTMLElement>, layers: Array<HTMLElement>, localData?: Record<string, any>) => void;
|
|
340
|
+
pause: (nodeList: Iterable<HTMLElement>) => void;
|
|
341
|
+
resume: (nodeList: Iterable<HTMLElement>) => void;
|
|
544
342
|
};
|
|
545
343
|
}
|
|
546
344
|
declare class WidgetMultiSlide {
|
|
@@ -568,6 +366,7 @@ declare class WidgetPollLayers extends WidgetBase<WidgetPollLayersOptions> {
|
|
|
568
366
|
isDone(): boolean;
|
|
569
367
|
slidePollIsDone(): boolean;
|
|
570
368
|
static api: {
|
|
369
|
+
widgetClassName: string;
|
|
571
370
|
refreshUserData: typeof WidgetBase.refreshUserData;
|
|
572
371
|
initWidget: (element: HTMLElement, layers: Array<HTMLElement>, localData?: Record<string, any>) => void;
|
|
573
372
|
select: (element: HTMLElement) => boolean;
|
|
@@ -601,6 +400,7 @@ declare class WidgetQuest extends WidgetBase<WidgetQuestOptions> {
|
|
|
601
400
|
private getLastSlideIndexFromRouteHistory;
|
|
602
401
|
private handleRouteClick;
|
|
603
402
|
static api: {
|
|
403
|
+
widgetClassName: string;
|
|
604
404
|
refreshUserData: typeof WidgetBase.refreshUserData;
|
|
605
405
|
initWidget: (element: HTMLElement, localData?: Record<string, any>) => Promise<boolean>;
|
|
606
406
|
select: (element: HTMLElement) => boolean;
|
|
@@ -629,6 +429,7 @@ declare class WidgetQuiz extends WidgetBase<WidgetQuizOptions> {
|
|
|
629
429
|
isDone(): boolean;
|
|
630
430
|
slideQuizIsDone(): boolean;
|
|
631
431
|
static api: {
|
|
432
|
+
widgetClassName: string;
|
|
632
433
|
refreshUserData: typeof WidgetBase.refreshUserData;
|
|
633
434
|
initWidget: (element: HTMLElement, localData?: Record<string, any>) => void;
|
|
634
435
|
select: (element: HTMLElement) => boolean;
|
|
@@ -662,6 +463,7 @@ declare class WidgetQuizGrouped extends WidgetBase<WidgetQuizGroupedOptions> {
|
|
|
662
463
|
isDone(): boolean;
|
|
663
464
|
slideQuizIsDone(): boolean;
|
|
664
465
|
static api: {
|
|
466
|
+
widgetClassName: string;
|
|
665
467
|
refreshUserData: typeof WidgetBase.refreshUserData;
|
|
666
468
|
initWidget: (element: HTMLElement, localData?: Record<string, any>) => void;
|
|
667
469
|
select: (element: HTMLElement) => boolean;
|
|
@@ -695,8 +497,9 @@ declare class WidgetRate extends WidgetBase<WidgetRateOptions> {
|
|
|
695
497
|
isDone(): boolean;
|
|
696
498
|
slideRateIsDone(): boolean;
|
|
697
499
|
static api: {
|
|
500
|
+
widgetClassName: string;
|
|
698
501
|
refreshUserData: typeof WidgetBase.refreshUserData;
|
|
699
|
-
initWidget: (nodeList:
|
|
502
|
+
initWidget: (nodeList: Iterable<HTMLElement>, localData?: Record<string, any>) => void;
|
|
700
503
|
select: (element: HTMLElement) => boolean;
|
|
701
504
|
slidePollIsDone: (element: HTMLElement) => boolean;
|
|
702
505
|
setUserData: (id: string, text: string) => void;
|
|
@@ -720,8 +523,9 @@ declare class WidgetShare extends WidgetBase<WidgetShareOptions> {
|
|
|
720
523
|
_complete(isSuccess: boolean): void;
|
|
721
524
|
isDone(): boolean;
|
|
722
525
|
static api: {
|
|
526
|
+
widgetClassName: string;
|
|
723
527
|
refreshUserData: typeof WidgetBase.refreshUserData;
|
|
724
|
-
initWidget: (nodeList:
|
|
528
|
+
initWidget: (nodeList: Iterable<HTMLElement>, layers: Array<HTMLElement>, localData?: Record<string, any>) => void;
|
|
725
529
|
click: (element: HTMLElement) => void;
|
|
726
530
|
complete: (id: string, isSuccess: boolean) => void;
|
|
727
531
|
};
|
|
@@ -755,6 +559,7 @@ declare class WidgetTest extends WidgetBase<WidgetTestOptions> {
|
|
|
755
559
|
slideTestIsDone(): boolean;
|
|
756
560
|
slideTestWithTimer(): boolean;
|
|
757
561
|
static api: {
|
|
562
|
+
widgetClassName: string;
|
|
758
563
|
refreshUserData: typeof WidgetBase.refreshUserData;
|
|
759
564
|
initWidget: (element: HTMLElement, localData?: Record<string, any>) => void;
|
|
760
565
|
select: (element: HTMLElement) => boolean;
|
|
@@ -762,6 +567,252 @@ declare class WidgetTest extends WidgetBase<WidgetTestOptions> {
|
|
|
762
567
|
slideTestWithTimer: (element: HTMLElement) => boolean;
|
|
763
568
|
};
|
|
764
569
|
}
|
|
570
|
+
type APIResponse<DTO> = {
|
|
571
|
+
status: number;
|
|
572
|
+
data: DTO;
|
|
573
|
+
headers?: {
|
|
574
|
+
[key: string]: string;
|
|
575
|
+
};
|
|
576
|
+
requestId: number | string;
|
|
577
|
+
};
|
|
578
|
+
type FontDTO = {
|
|
579
|
+
url: string;
|
|
580
|
+
family: string;
|
|
581
|
+
style: string;
|
|
582
|
+
weight: string;
|
|
583
|
+
};
|
|
584
|
+
interface SDKApi {
|
|
585
|
+
getStoryServerData(storyId: number): Record<string, any> | null;
|
|
586
|
+
getSlideDuration(storyId: number, slideIndex: number): number | null;
|
|
587
|
+
showNextSlide(duration: number): void;
|
|
588
|
+
sendStatisticEvent(name: string, data: Record<string, string | number | Array<string | number>>, devPayload?: Record<string, string | number | Array<string | number>>): void;
|
|
589
|
+
getStoryLocalData(): Promise<Record<string, any>>;
|
|
590
|
+
isExistsShowLayer(): boolean;
|
|
591
|
+
showLayer(index: number): void;
|
|
592
|
+
storyAnimation: IAnimation | undefined;
|
|
593
|
+
isAndroid: boolean;
|
|
594
|
+
isWeb: boolean;
|
|
595
|
+
isIOS: boolean;
|
|
596
|
+
pauseUI(): void;
|
|
597
|
+
resumeUI(): void;
|
|
598
|
+
isExistsShowStoryTextInput: boolean;
|
|
599
|
+
showStoryTextInput(id: string, data: Record<string, any>): void;
|
|
600
|
+
setStoryLocalData(keyValue: Record<string, any>, sendToServer: boolean): void;
|
|
601
|
+
getWidgetsSharedData<WidgetType extends keyof WidgetsSharedDataMap>(storyId: number, widget: Widgets): WidgetsSharedDataMap[WidgetType] | null;
|
|
602
|
+
vibrate(pattern: number): void;
|
|
603
|
+
openUrl(target: string): void;
|
|
604
|
+
sendApiRequest<ResponseDTO>(url: string, method: string, params: Record<string, any> | null, headers: Record<string, any> | null, data: Record<string, any> | null, profilingKey: string): Promise<APIResponse<ResponseDTO>>;
|
|
605
|
+
sendApiRequestSupported(): boolean;
|
|
606
|
+
showToast(text: string): void;
|
|
607
|
+
sdkCanSendShareComplete: boolean;
|
|
608
|
+
isExistsShare: boolean;
|
|
609
|
+
share(id: string, config: {
|
|
610
|
+
url?: string | null;
|
|
611
|
+
text?: string | null;
|
|
612
|
+
title?: string | null;
|
|
613
|
+
files?: Array<{
|
|
614
|
+
file: File;
|
|
615
|
+
name: string;
|
|
616
|
+
type: string;
|
|
617
|
+
}> | null;
|
|
618
|
+
}): void;
|
|
619
|
+
shareSlideScreenshot(shareId: string, hideElementsSelector?: string): void;
|
|
620
|
+
isExistsShowStorySlide: boolean;
|
|
621
|
+
showStorySlide(index: number): void;
|
|
622
|
+
isExistsShowNextStory: boolean;
|
|
623
|
+
storyShowNext(): void;
|
|
624
|
+
setStorySessionValue(element: HTMLElement, key: string, value: string): void;
|
|
625
|
+
getStorySessionValue(element: HTMLElement, key: string): string | undefined;
|
|
626
|
+
updateTimeline(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): void;
|
|
627
|
+
/** @deprecated, used only in native sdk **/
|
|
628
|
+
storyPausedCallback(currentTime: number | null): void;
|
|
629
|
+
/** @deprecated, used only in native sdk **/
|
|
630
|
+
storyResumedCallback(currentTime: number | null): void;
|
|
631
|
+
startDisabledTimeline(storyId: number, slideIndex: number): void;
|
|
632
|
+
getStoryFonts(): Array<FontDTO>;
|
|
633
|
+
}
|
|
634
|
+
declare class WidgetsService {
|
|
635
|
+
private _env;
|
|
636
|
+
private _sdkApi;
|
|
637
|
+
constructor(_env: Window, _sdkApi: SDKApi);
|
|
638
|
+
get env(): Window;
|
|
639
|
+
get sdkApi(): SDKApi;
|
|
640
|
+
}
|
|
641
|
+
declare class WidgetBase<WidgetOptions extends WidgetOptionsBase> {
|
|
642
|
+
/**
|
|
643
|
+
* @see https://github.com/Microsoft/TypeScript/issues/3841#issuecomment-1488919713
|
|
644
|
+
*/
|
|
645
|
+
["constructor"]: typeof WidgetBase;
|
|
646
|
+
static DEFAULTS: WidgetOptionsBase;
|
|
647
|
+
static widgetIndex: number;
|
|
648
|
+
protected env: Window;
|
|
649
|
+
protected sdkApi: SDKApi;
|
|
650
|
+
protected options: WidgetOptions;
|
|
651
|
+
protected element: HTMLElement;
|
|
652
|
+
protected elementId: string;
|
|
653
|
+
protected slide: HTMLElement;
|
|
654
|
+
protected slideIndex: number;
|
|
655
|
+
protected disableTimer: boolean;
|
|
656
|
+
protected layoutDirection: "ltr" | "rtl";
|
|
657
|
+
protected storyId: number;
|
|
658
|
+
protected widgetDone: Element | null;
|
|
659
|
+
protected showWidgetCompleteToast: boolean;
|
|
660
|
+
protected submitButtonAnimatedView: HTMLElement | null;
|
|
661
|
+
protected submitButtonView: HTMLElement | null;
|
|
662
|
+
protected submitButtonViewHeight: number;
|
|
663
|
+
protected savedData: Record<string, any> | null;
|
|
664
|
+
protected localData: Record<string, any>;
|
|
665
|
+
protected firstOpenTime: number;
|
|
666
|
+
protected id: string;
|
|
667
|
+
constructor(element: HTMLElement, options: Partial<WidgetOptions>, elementIdGetter?: (element: HTMLElement) => string, slideGetter?: (element: HTMLElement) => HTMLElement);
|
|
668
|
+
refreshUserData(localData: Record<string, any>): void;
|
|
669
|
+
static widgetCacheKey: string;
|
|
670
|
+
static widgetClassName: string;
|
|
671
|
+
static getInstance<Widget extends WidgetBase<WidgetOptions>, WidgetOptions extends WidgetOptionsBase>(element: HTMLElement): Widget | undefined;
|
|
672
|
+
static getInstanceById<Widget extends WidgetBase<WidgetOptions>, WidgetOptions extends WidgetOptionsBase>(id: string): Widget | undefined;
|
|
673
|
+
static createInstance<Widget extends WidgetBase<WidgetOptions>, WidgetOptions extends WidgetOptionsBase>(instantiate: (element: HTMLElement, options: Partial<WidgetOptions>) => Widget, element: HTMLElement, options: Partial<WidgetOptions>): Widget;
|
|
674
|
+
static initWidgets<Widget extends WidgetBase<WidgetOptions>, WidgetOptions extends WidgetOptionsBase>(instantiate: (element: HTMLElement, options: Partial<WidgetOptions>) => Widget, elements: Array<HTMLElement>, localData?: Record<string, any>): Promise<Record<string, any>>;
|
|
675
|
+
static get widgetsService(): WidgetsService;
|
|
676
|
+
static getLocalData(): Promise<Record<string, any>>;
|
|
677
|
+
getLocalData(): Promise<Record<string, any>>;
|
|
678
|
+
static setLocalData(keyValue: Record<string, any>, sendToServer?: boolean, syncWithRuntimeLocalData?: boolean): void;
|
|
679
|
+
setLocalData(keyValue: Record<string, any>, sendToServer?: boolean, syncWithRuntimeLocalData?: boolean): void;
|
|
680
|
+
static sendStatisticEventToApp(name: string, data: Record<string, string | number | Array<string | number>>, devPayload?: Record<string, string | number | Array<string | number>>): void;
|
|
681
|
+
sendStatisticEventToApp(name: string, data: Record<string, string | number | Array<string | number>>, devPayload?: Record<string, string | number | Array<string | number>>): void;
|
|
682
|
+
startDisabledTimeline(): void;
|
|
683
|
+
protected _showLayout(layers: Array<HTMLElement>, selectIndex: number, withStatEvent?: boolean): void;
|
|
684
|
+
protected _statEventLayoutShow(layoutIndex: number): void;
|
|
685
|
+
static refreshUserData<Widget extends WidgetBase<WidgetOptions>, WidgetOptions extends WidgetOptionsBase>(nodes: NodeListOf<HTMLElement>, localData?: Record<string, any>): void;
|
|
686
|
+
}
|
|
687
|
+
interface SDKInterface {
|
|
688
|
+
/**
|
|
689
|
+
* Return object from widgetsData._narrative_saved_data[storyId] or null
|
|
690
|
+
*
|
|
691
|
+
* Possible implementation
|
|
692
|
+
* if ("_narrative_saved_data" in window && window._narrative_saved_data[storyId] != null && isObject(window._narrative_saved_data[storyId])) {
|
|
693
|
+
* return window._narrative_saved_data[storyId];
|
|
694
|
+
* }
|
|
695
|
+
*/
|
|
696
|
+
getStoryServerData(storyId: number): Record<string, any> | null;
|
|
697
|
+
/**
|
|
698
|
+
* Return slide duration or null
|
|
699
|
+
*
|
|
700
|
+
* Possible implementation
|
|
701
|
+
* if (
|
|
702
|
+
* "_narrative_slides_duration" in window &&
|
|
703
|
+
* window._narrative_slides_duration[storyId] != null &&
|
|
704
|
+
* isArray(window._narrative_slides_duration[storyId]) &&
|
|
705
|
+
* window._narrative_slides_duration[storyId][slideIndex] != null &&
|
|
706
|
+
* isNumber(window._narrative_slides_duration[storyId][slideIndex])
|
|
707
|
+
* ) {
|
|
708
|
+
* return window._narrative_slides_duration[storyId][slideIndex];
|
|
709
|
+
* }
|
|
710
|
+
*/
|
|
711
|
+
getSlideDuration(storyId: number, slideIndex: number): number | null;
|
|
712
|
+
showNextSlide(duration: number): void;
|
|
713
|
+
/**
|
|
714
|
+
* From native sdk, do`t implement in web|react-sdk
|
|
715
|
+
*/
|
|
716
|
+
sendStatisticEvent(name: string, data: Record<string, string | number | Array<string | number>>, devPayload?: Record<string, string | number | Array<string | number>>): void;
|
|
717
|
+
getStoryLocalData(): Promise<Record<string, any>>;
|
|
718
|
+
setStoryLocalData(keyValue: Record<string, any>, sendToServer: boolean): void;
|
|
719
|
+
showLayer(index: number): void;
|
|
720
|
+
/**
|
|
721
|
+
* Pause timer (story timeline), SlideApi used it on ShowTextInput appear
|
|
722
|
+
*/
|
|
723
|
+
pauseUI(): void;
|
|
724
|
+
/**
|
|
725
|
+
* Resume timer (story timeline), SlideApi used it on ShowTextInput disappear
|
|
726
|
+
*/
|
|
727
|
+
resumeUI(): void;
|
|
728
|
+
showStoryTextInput(id: string, data: Record<string, any>): void;
|
|
729
|
+
/**
|
|
730
|
+
* Possible implementation
|
|
731
|
+
*
|
|
732
|
+
* getWidgetsSharedData<WidgetType extends keyof WidgetsSharedDataMap>(storyId: number, widget: Widgets): WidgetsSharedDataMap[WidgetType] | null {
|
|
733
|
+
* switch (widget) {
|
|
734
|
+
* case Widgets.RangeSlider: {
|
|
735
|
+
* if ("_narrative_range_slider_data" in window && isObject(window._narrative_range_slider_data[storyId])) {
|
|
736
|
+
* return window._narrative_range_slider_data[storyId] as WidgetsSharedDataMap[WidgetType];
|
|
737
|
+
* }
|
|
738
|
+
* break;
|
|
739
|
+
* }
|
|
740
|
+
* case Widgets.Poll: {
|
|
741
|
+
* if ("_narrative_poll_data" in window && isObject(window._narrative_poll_data[storyId])) {
|
|
742
|
+
* return window._narrative_poll_data[storyId] as WidgetsSharedDataMap[WidgetType];
|
|
743
|
+
* }
|
|
744
|
+
* break;
|
|
745
|
+
* }
|
|
746
|
+
* case Widgets.Vote: {
|
|
747
|
+
* if ("_narrative_vote_data" in window && isObject(window._narrative_vote_data[storyId])) {
|
|
748
|
+
* return window._narrative_vote_data[storyId] as WidgetsSharedDataMap[WidgetType];
|
|
749
|
+
* }
|
|
750
|
+
* break;
|
|
751
|
+
* }
|
|
752
|
+
* }
|
|
753
|
+
*
|
|
754
|
+
* return null;
|
|
755
|
+
* }
|
|
756
|
+
*/
|
|
757
|
+
getWidgetsSharedData<WidgetType extends keyof WidgetsSharedDataMap>(storyId: number, widget: Widgets): WidgetsSharedDataMap[WidgetType] | null;
|
|
758
|
+
/**
|
|
759
|
+
* Possible implementation
|
|
760
|
+
*
|
|
761
|
+
* if ("_showNarrativeLink" in window) {
|
|
762
|
+
* window._showNarrativeLink(target);
|
|
763
|
+
* }
|
|
764
|
+
*/
|
|
765
|
+
openUrl(target: string): void;
|
|
766
|
+
/**
|
|
767
|
+
* Possible implementation
|
|
768
|
+
*
|
|
769
|
+
* return window._sendApiRequest(url, method, params, headers, data, profilingKey);
|
|
770
|
+
*/
|
|
771
|
+
sendApiRequest<ResponseDTO>(url: string, method: string, params: Record<string, any> | null, headers: Record<string, any> | null, data: Record<string, any> | null, profilingKey: string): Promise<APIResponse<ResponseDTO>>;
|
|
772
|
+
/**
|
|
773
|
+
* Possible implementation
|
|
774
|
+
*
|
|
775
|
+
* window._share(id, config);
|
|
776
|
+
*/
|
|
777
|
+
share(id: string, config: {
|
|
778
|
+
url?: string | null;
|
|
779
|
+
text?: string | null;
|
|
780
|
+
title?: string | null;
|
|
781
|
+
files?: Array<{
|
|
782
|
+
file: File;
|
|
783
|
+
name: string;
|
|
784
|
+
type: string;
|
|
785
|
+
}> | null;
|
|
786
|
+
}): void;
|
|
787
|
+
/**
|
|
788
|
+
* Possible implementation
|
|
789
|
+
*
|
|
790
|
+
* window.share_slide_screenshot(shareId, hideElementsSelector);
|
|
791
|
+
*/
|
|
792
|
+
shareSlideScreenshot(shareId: string, hideElementsSelector?: string): void;
|
|
793
|
+
/**
|
|
794
|
+
* Possible implementation
|
|
795
|
+
*
|
|
796
|
+
* window._showNarrativeSlide(index);
|
|
797
|
+
*/
|
|
798
|
+
showStorySlide(index: number): void;
|
|
799
|
+
/**
|
|
800
|
+
* Possible implementation
|
|
801
|
+
*
|
|
802
|
+
* window._storyShowNext();
|
|
803
|
+
*/
|
|
804
|
+
storyShowNext(): void;
|
|
805
|
+
/**
|
|
806
|
+
* Cache with lifetime - while story rendered on Screen
|
|
807
|
+
*/
|
|
808
|
+
setStorySessionValue(key: string, value: string): void;
|
|
809
|
+
getStorySessionValue(key: string): string | undefined;
|
|
810
|
+
updateTimeline?(slideIndex: number, action: TIMELINE_ACTION, currentTime: number, duration: number, showLoader: boolean, showError: boolean): void;
|
|
811
|
+
/**
|
|
812
|
+
* Get fonts from session.cache
|
|
813
|
+
*/
|
|
814
|
+
getStoryFonts(): Array<FontDTO>;
|
|
815
|
+
}
|
|
765
816
|
type WidgetCopyApi = typeof WidgetCopy.api;
|
|
766
817
|
type WidgetDataInputApi = typeof WidgetDataInput.api;
|
|
767
818
|
type WidgetDateCountdownApi = typeof WidgetDateCountdown.api;
|
|
@@ -795,4 +846,4 @@ type SlideApi = {
|
|
|
795
846
|
};
|
|
796
847
|
declare const getSlideApi: (_sdkInterface: SDKInterface) => SlideApi;
|
|
797
848
|
export { getSlideApi, Widgets };
|
|
798
|
-
export type { SDKInterface, SlideApi, WidgetCopyApi, WidgetDataInputApi, WidgetDateCountdownApi, WidgetMultiSlideApi, WidgetPollApi, WidgetPollLayersApi, WidgetQuestApi, WidgetQuizApi, WidgetQuizGroupedApi, WidgetRangeSliderApi, WidgetRateApi, WidgetShareApi, WidgetTestApi, WidgetVoteApi, IAnimation, WidgetsSharedDataMap, WidgetRangeSliderSharedData, WidgetPollSharedData, WidgetVoteSharedData };
|
|
849
|
+
export type { SDKInterface, SlideApi, WidgetCopyApi, WidgetDataInputApi, WidgetDateCountdownApi, WidgetMultiSlideApi, WidgetPollApi, WidgetPollLayersApi, WidgetQuestApi, WidgetQuizApi, WidgetQuizGroupedApi, WidgetRangeSliderApi, WidgetRateApi, WidgetShareApi, WidgetTestApi, WidgetVoteApi, IAnimation, WidgetsSharedDataMap, WidgetRangeSliderSharedData, WidgetPollSharedData, WidgetVoteSharedData, FontDTO };
|