@concord-consortium/lara-interactive-api 1.4.0-pre.4 → 1.5.2
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/api.d.ts +11 -1
- package/client.d.ts +3 -1
- package/index-bundle.d.ts +18 -1
- package/index.js +72 -6
- package/package.json +1 -1
package/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IInitInteractive, INavigationOptions, IAuthInfo, ISupportedFeatures, IShowModal, ICloseModal, IGetInteractiveListOptions, IGetInteractiveListResponse, ISetLinkedInteractives, IGetLibraryInteractiveListRequest, IJwtResponse, ICustomMessageHandler, ICustomMessagesHandledMap, IGetInteractiveSnapshotOptions, IGetInteractiveSnapshotResponse, IAddLinkedInteractiveStateListenerOptions, IDecoratedContentEvent, ITextDecorationHandler, WriteAttachmentParams, ReadAttachmentParams, GetAttachmentUrlParams, IGetReportItemAnswerHandler, IReportItemAnswer } from "./types";
|
|
1
|
+
import { IInitInteractive, INavigationOptions, IAuthInfo, ISupportedFeatures, IShowModal, ICloseModal, IGetInteractiveListOptions, IGetInteractiveListResponse, ISetLinkedInteractives, IGetLibraryInteractiveListRequest, IJwtResponse, ICustomMessageHandler, ICustomMessagesHandledMap, IGetInteractiveSnapshotOptions, IGetInteractiveSnapshotResponse, IAddLinkedInteractiveStateListenerOptions, IDecoratedContentEvent, ITextDecorationHandler, WriteAttachmentParams, ReadAttachmentParams, GetAttachmentUrlParams, IGetReportItemAnswerHandler, IReportItemAnswer, OnUnloadFunction } from "./types";
|
|
2
2
|
export declare const getInitInteractiveMessage: <InteractiveState = {}, AuthoredState = {}, GlobalInteractiveState = {}>() => Promise<IInitInteractive<InteractiveState, AuthoredState, GlobalInteractiveState> | null>;
|
|
3
3
|
export declare const getMode: () => Promise<"runtime" | "authoring" | "report" | "reportItem" | undefined>;
|
|
4
4
|
export declare const getInteractiveState: <InteractiveState>() => InteractiveState | null;
|
|
@@ -74,6 +74,9 @@ export declare const removeGetReportItemAnswerListener: () => void;
|
|
|
74
74
|
export declare const setSupportedFeatures: (features: ISupportedFeatures) => void;
|
|
75
75
|
export declare const setHeight: (height: number | string) => void;
|
|
76
76
|
export declare const postDecoratedContentEvent: (msg: IDecoratedContentEvent) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Providing empty string or null disables hint.
|
|
79
|
+
*/
|
|
77
80
|
export declare const setHint: (hint: string | null) => void;
|
|
78
81
|
export declare const setNavigation: (options: INavigationOptions) => void;
|
|
79
82
|
export declare const getAuthInfo: () => Promise<IAuthInfo>;
|
|
@@ -85,6 +88,12 @@ export declare const addAuthoredStateListener: <AuthoredState>(listener: (author
|
|
|
85
88
|
export declare const removeAuthoredStateListener: <AuthoredState>(listener: (authoredState: AuthoredState) => void) => void;
|
|
86
89
|
export declare const addGlobalInteractiveStateListener: <GlobalInteractiveState>(listener: (globalInteractiveState: GlobalInteractiveState) => void) => void;
|
|
87
90
|
export declare const removeGlobalInteractiveStateListener: <GlobalInteractiveState>(listener: (globalInteractiveState: GlobalInteractiveState) => void) => void;
|
|
91
|
+
/**
|
|
92
|
+
* The listener should be called immediately after it is added with any state of the linked
|
|
93
|
+
* interactive that the host currently knows about. This first call might not happen
|
|
94
|
+
* synchronously it could be slightly delayed. And then the listener should be called again
|
|
95
|
+
* whenever the state of the linked interactive changes.
|
|
96
|
+
*/
|
|
88
97
|
export declare const addLinkedInteractiveStateListener: <LinkedInteractiveState>(listener: (linkedIntState: LinkedInteractiveState | undefined) => void, options: IAddLinkedInteractiveStateListenerOptions) => void;
|
|
89
98
|
export declare const removeLinkedInteractiveStateListener: <InteractiveState>(listener: (intState: InteractiveState | null) => void) => void;
|
|
90
99
|
/**
|
|
@@ -105,3 +114,4 @@ export declare const writeAttachment: (params: WriteAttachmentParams) => Promise
|
|
|
105
114
|
export declare const readAttachment: (params: ReadAttachmentParams) => Promise<Response>;
|
|
106
115
|
export declare const getAttachmentUrl: (params: GetAttachmentUrlParams) => Promise<string>;
|
|
107
116
|
export declare const sendReportItemAnswer: (request: Omit<IReportItemAnswer, "requestId">) => void;
|
|
117
|
+
export declare const setOnUnload: (onUnload?: OnUnloadFunction<{}> | undefined) => void;
|
package/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as iframePhone from "iframe-phone";
|
|
2
|
-
import { ClientMessage, ICustomMessageHandler, ICustomMessagesHandledMap, ISupportedFeaturesRequest, ServerMessage, ITextDecorationHandler, IGetReportItemAnswerHandler } from "./types";
|
|
2
|
+
import { ClientMessage, ICustomMessageHandler, ICustomMessagesHandledMap, ISupportedFeaturesRequest, ServerMessage, ITextDecorationHandler, IGetReportItemAnswerHandler, OnUnloadFunction } from "./types";
|
|
3
3
|
import { ManagedState } from "./managed-state";
|
|
4
4
|
export declare const getClient: () => Client;
|
|
5
5
|
export declare class Client {
|
|
@@ -8,6 +8,7 @@ export declare class Client {
|
|
|
8
8
|
private customMessagesHandled;
|
|
9
9
|
private listeners;
|
|
10
10
|
private requestId;
|
|
11
|
+
private onUnload;
|
|
11
12
|
constructor();
|
|
12
13
|
getNextRequestId(): number;
|
|
13
14
|
post(message: ClientMessage, content?: any): void;
|
|
@@ -20,5 +21,6 @@ export declare class Client {
|
|
|
20
21
|
addGetReportItemAnswerListener(callback: IGetReportItemAnswerHandler): void;
|
|
21
22
|
removeGetReportItemAnswerListener(): boolean;
|
|
22
23
|
setSupportedFeatures: (request: ISupportedFeaturesRequest) => void;
|
|
24
|
+
setOnUnload: (onUnload?: OnUnloadFunction<{}> | undefined) => void;
|
|
23
25
|
private connect;
|
|
24
26
|
}
|
package/index-bundle.d.ts
CHANGED
|
@@ -111,6 +111,7 @@ interface IAuthoringInitInteractive<AuthoredState = {}> {
|
|
|
111
111
|
interface IReportInitInteractive<InteractiveState = {}, AuthoredState = {}> {
|
|
112
112
|
version: 1;
|
|
113
113
|
mode: "report";
|
|
114
|
+
view?: "standalone";
|
|
114
115
|
hostFeatures: IHostFeatures;
|
|
115
116
|
authoredState: AuthoredState;
|
|
116
117
|
interactiveState: InteractiveState;
|
|
@@ -384,6 +385,10 @@ interface IDataset {
|
|
|
384
385
|
interface IInteractiveStateWithDataset {
|
|
385
386
|
dataset?: IDataset | null;
|
|
386
387
|
}
|
|
388
|
+
interface IGetInteractiveState {
|
|
389
|
+
unloading?: boolean;
|
|
390
|
+
}
|
|
391
|
+
declare type OnUnloadFunction<InteractiveState = {}> = (options: IGetInteractiveState) => Promise<InteractiveState>;
|
|
387
392
|
|
|
388
393
|
declare type ChoiceId = string;
|
|
389
394
|
interface IAuthoringMetadataBase {
|
|
@@ -525,6 +530,9 @@ declare const removeGetReportItemAnswerListener: () => void;
|
|
|
525
530
|
declare const setSupportedFeatures: (features: ISupportedFeatures) => void;
|
|
526
531
|
declare const setHeight: (height: number | string) => void;
|
|
527
532
|
declare const postDecoratedContentEvent: (msg: IDecoratedContentEvent) => void;
|
|
533
|
+
/**
|
|
534
|
+
* Providing empty string or null disables hint.
|
|
535
|
+
*/
|
|
528
536
|
declare const setHint: (hint: string | null) => void;
|
|
529
537
|
declare const setNavigation: (options: INavigationOptions) => void;
|
|
530
538
|
declare const getAuthInfo: () => Promise<IAuthInfo>;
|
|
@@ -536,6 +544,12 @@ declare const addAuthoredStateListener: <AuthoredState>(listener: (authoredState
|
|
|
536
544
|
declare const removeAuthoredStateListener: <AuthoredState>(listener: (authoredState: AuthoredState) => void) => void;
|
|
537
545
|
declare const addGlobalInteractiveStateListener: <GlobalInteractiveState>(listener: (globalInteractiveState: GlobalInteractiveState) => void) => void;
|
|
538
546
|
declare const removeGlobalInteractiveStateListener: <GlobalInteractiveState>(listener: (globalInteractiveState: GlobalInteractiveState) => void) => void;
|
|
547
|
+
/**
|
|
548
|
+
* The listener should be called immediately after it is added with any state of the linked
|
|
549
|
+
* interactive that the host currently knows about. This first call might not happen
|
|
550
|
+
* synchronously it could be slightly delayed. And then the listener should be called again
|
|
551
|
+
* whenever the state of the linked interactive changes.
|
|
552
|
+
*/
|
|
539
553
|
declare const addLinkedInteractiveStateListener: <LinkedInteractiveState>(listener: (linkedIntState: LinkedInteractiveState | undefined) => void, options: IAddLinkedInteractiveStateListenerOptions) => void;
|
|
540
554
|
declare const removeLinkedInteractiveStateListener: <InteractiveState>(listener: (intState: InteractiveState | null) => void) => void;
|
|
541
555
|
/**
|
|
@@ -556,6 +570,7 @@ declare const writeAttachment: (params: WriteAttachmentParams) => Promise<Respon
|
|
|
556
570
|
declare const readAttachment: (params: ReadAttachmentParams) => Promise<Response>;
|
|
557
571
|
declare const getAttachmentUrl: (params: GetAttachmentUrlParams) => Promise<string>;
|
|
558
572
|
declare const sendReportItemAnswer: (request: Omit<IReportItemAnswer, "requestId">) => void;
|
|
573
|
+
declare const setOnUnload: (onUnload?: OnUnloadFunction<{}> | undefined) => void;
|
|
559
574
|
|
|
560
575
|
declare type UpdateFunc<S> = (prevState: S | null) => S;
|
|
561
576
|
declare const useInteractiveState: <InteractiveState>() => {
|
|
@@ -604,6 +619,7 @@ declare class Client {
|
|
|
604
619
|
private customMessagesHandled;
|
|
605
620
|
private listeners;
|
|
606
621
|
private requestId;
|
|
622
|
+
private onUnload;
|
|
607
623
|
constructor();
|
|
608
624
|
getNextRequestId(): number;
|
|
609
625
|
post(message: ClientMessage, content?: any): void;
|
|
@@ -616,7 +632,8 @@ declare class Client {
|
|
|
616
632
|
addGetReportItemAnswerListener(callback: IGetReportItemAnswerHandler): void;
|
|
617
633
|
removeGetReportItemAnswerListener(): boolean;
|
|
618
634
|
setSupportedFeatures: (request: ISupportedFeaturesRequest) => void;
|
|
635
|
+
setOnUnload: (onUnload?: OnUnloadFunction<{}> | undefined) => void;
|
|
619
636
|
private connect;
|
|
620
637
|
}
|
|
621
638
|
|
|
622
|
-
export { ChoiceId, Client, ClientMessage, DeprecatedRuntimeClientMessage, DeprecatedRuntimeServerMessage, GetAttachmentUrlParams, GlobalIFrameSaverClientMessage, GlobalIFrameSaverServerMessage, IAddLinkedInteractiveStateListenerOptions, IAddLinkedInteractiveStateListenerRequest, IAttachmentUrlRequest, IAttachmentUrlResponse, IAuthInfo, IAuthoringClientMessage, IAuthoringCustomReportField, IAuthoringCustomReportFields, IAuthoringImageQuestionMetadata, IAuthoringInitInteractive, IAuthoringInteractiveMetadata, IAuthoringMetadata, IAuthoringMetadataBase, IAuthoringMultipleChoiceChoiceMetadata, IAuthoringMultipleChoiceMetadata, IAuthoringOpenResponseMetadata, IAuthoringServerMessage, IBaseShowModal, ICloseModal, IContextMember, IContextMembership, ICustomMessage, ICustomMessageHandler, ICustomMessageOptions, ICustomMessagesHandledMap, ICustomReportFieldsAuthoredState, ICustomReportFieldsAuthoredStateField, ICustomReportFieldsInteractiveState, IDataset, IDecoratedContentEvent, IGetAuthInfoRequest, IGetAuthInfoResponse, IGetFirebaseJwtRequest, IGetFirebaseJwtResponse, IGetInteractiveListOptions, IGetInteractiveListRequest, IGetInteractiveListResponse, IGetInteractiveSnapshotOptions, IGetInteractiveSnapshotRequest, IGetInteractiveSnapshotResponse, IGetLibraryInteractiveListOptions, IGetLibraryInteractiveListRequest, IGetLibraryInteractiveListResponse, IGetReportItemAnswer, IGetReportItemAnswerHandler, IHintRequest, IHostFeatureSupport, IHostFeatures, IHostModalSupport, IInitInteractive, IInteractiveListResponseItem, IInteractiveStateProps, IInteractiveStateWithDataset, IJwtClaims, IJwtResponse, ILibraryInteractiveListResponseItem, ILinkedInteractive, ILinkedInteractiveStateResponse, INavigationOptions, IPortalClaims, IRemoveLinkedInteractiveStateListenerRequest, IReportInitInteractive, IReportItemAnswer, IReportItemClientMessage, IReportItemInitInteractive, IReportItemServerMessage, IRuntimeClientMessage, IRuntimeCustomReportValues, IRuntimeImageQuestionMetadata, IRuntimeInitInteractive, IRuntimeInteractiveMetadata, IRuntimeMetadata, IRuntimeMetadataBase, IRuntimeMultipleChoiceMetadata, IRuntimeOpenResponseMetadata, IRuntimeServerMessage, ISetLinkedInteractives, IShowAlert, IShowDialog, IShowLightbox, IShowModal, ISupportedFeatures, ISupportedFeaturesRequest, ITextDecorationHandler, ITextDecorationHandlerInfo, ITextDecorationInfo, IThemeInfo, IWriteAttachmentRequest, IframePhoneServerMessage, InitInteractiveMode, InteractiveItemId, LoggerClientMessage, ModalType, ReadAttachmentParams, ServerMessage, WriteAttachmentParams, addAuthoredStateListener, addCustomMessageListener, addDecorateContentListener, addGetReportItemAnswerListener, addGlobalInteractiveStateListener, addInteractiveStateListener, addLinkedInteractiveStateListener, closeModal, flushStateUpdates, getAttachmentUrl, getAuthInfo, getAuthoredState, getClient, getFirebaseJwt, getGlobalInteractiveState, getInitInteractiveMessage, getInteractiveList, getInteractiveSnapshot, getInteractiveState, getLibraryInteractiveList, getMode, inIframe, log, postDecoratedContentEvent, readAttachment, removeAuthoredStateListener, removeCustomMessageListener, removeDecorateContentListener, removeGetReportItemAnswerListener, removeGlobalInteractiveStateListener, removeInteractiveStateListener, removeLinkedInteractiveStateListener, sendReportItemAnswer, setAuthoredState, setGlobalInteractiveState, setHeight, setHint, setInteractiveState, setInteractiveStateTimeout, setLinkedInteractives, setNavigation, setSupportedFeatures, showModal, useAuthoredState, useAutoSetHeight, useCustomMessages, useDecorateContent, useGlobalInteractiveState, useInitMessage, useInteractiveState, writeAttachment };
|
|
639
|
+
export { ChoiceId, Client, ClientMessage, DeprecatedRuntimeClientMessage, DeprecatedRuntimeServerMessage, GetAttachmentUrlParams, GlobalIFrameSaverClientMessage, GlobalIFrameSaverServerMessage, IAddLinkedInteractiveStateListenerOptions, IAddLinkedInteractiveStateListenerRequest, IAttachmentUrlRequest, IAttachmentUrlResponse, IAuthInfo, IAuthoringClientMessage, IAuthoringCustomReportField, IAuthoringCustomReportFields, IAuthoringImageQuestionMetadata, IAuthoringInitInteractive, IAuthoringInteractiveMetadata, IAuthoringMetadata, IAuthoringMetadataBase, IAuthoringMultipleChoiceChoiceMetadata, IAuthoringMultipleChoiceMetadata, IAuthoringOpenResponseMetadata, IAuthoringServerMessage, IBaseShowModal, ICloseModal, IContextMember, IContextMembership, ICustomMessage, ICustomMessageHandler, ICustomMessageOptions, ICustomMessagesHandledMap, ICustomReportFieldsAuthoredState, ICustomReportFieldsAuthoredStateField, ICustomReportFieldsInteractiveState, IDataset, IDecoratedContentEvent, IGetAuthInfoRequest, IGetAuthInfoResponse, IGetFirebaseJwtRequest, IGetFirebaseJwtResponse, IGetInteractiveListOptions, IGetInteractiveListRequest, IGetInteractiveListResponse, IGetInteractiveSnapshotOptions, IGetInteractiveSnapshotRequest, IGetInteractiveSnapshotResponse, IGetInteractiveState, IGetLibraryInteractiveListOptions, IGetLibraryInteractiveListRequest, IGetLibraryInteractiveListResponse, IGetReportItemAnswer, IGetReportItemAnswerHandler, IHintRequest, IHostFeatureSupport, IHostFeatures, IHostModalSupport, IInitInteractive, IInteractiveListResponseItem, IInteractiveStateProps, IInteractiveStateWithDataset, IJwtClaims, IJwtResponse, ILibraryInteractiveListResponseItem, ILinkedInteractive, ILinkedInteractiveStateResponse, INavigationOptions, IPortalClaims, IRemoveLinkedInteractiveStateListenerRequest, IReportInitInteractive, IReportItemAnswer, IReportItemClientMessage, IReportItemInitInteractive, IReportItemServerMessage, IRuntimeClientMessage, IRuntimeCustomReportValues, IRuntimeImageQuestionMetadata, IRuntimeInitInteractive, IRuntimeInteractiveMetadata, IRuntimeMetadata, IRuntimeMetadataBase, IRuntimeMultipleChoiceMetadata, IRuntimeOpenResponseMetadata, IRuntimeServerMessage, ISetLinkedInteractives, IShowAlert, IShowDialog, IShowLightbox, IShowModal, ISupportedFeatures, ISupportedFeaturesRequest, ITextDecorationHandler, ITextDecorationHandlerInfo, ITextDecorationInfo, IThemeInfo, IWriteAttachmentRequest, IframePhoneServerMessage, InitInteractiveMode, InteractiveItemId, LoggerClientMessage, ModalType, OnUnloadFunction, ReadAttachmentParams, ServerMessage, WriteAttachmentParams, addAuthoredStateListener, addCustomMessageListener, addDecorateContentListener, addGetReportItemAnswerListener, addGlobalInteractiveStateListener, addInteractiveStateListener, addLinkedInteractiveStateListener, closeModal, flushStateUpdates, getAttachmentUrl, getAuthInfo, getAuthoredState, getClient, getFirebaseJwt, getGlobalInteractiveState, getInitInteractiveMessage, getInteractiveList, getInteractiveSnapshot, getInteractiveState, getLibraryInteractiveList, getMode, inIframe, log, postDecoratedContentEvent, readAttachment, removeAuthoredStateListener, removeCustomMessageListener, removeDecorateContentListener, removeGetReportItemAnswerListener, removeGlobalInteractiveStateListener, removeInteractiveStateListener, removeLinkedInteractiveStateListener, sendReportItemAnswer, setAuthoredState, setGlobalInteractiveState, setHeight, setHint, setInteractiveState, setInteractiveStateTimeout, setLinkedInteractives, setNavigation, setOnUnload, setSupportedFeatures, showModal, useAuthoredState, useAutoSetHeight, useCustomMessages, useDecorateContent, useGlobalInteractiveState, useInitMessage, useInteractiveState, writeAttachment };
|
package/index.js
CHANGED
|
@@ -4099,7 +4099,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
4099
4099
|
return t;
|
|
4100
4100
|
};
|
|
4101
4101
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4102
|
-
exports.sendReportItemAnswer = exports.getAttachmentUrl = exports.readAttachment = exports.writeAttachment = exports.getLibraryInteractiveList = exports.getInteractiveSnapshot = exports.setLinkedInteractives = exports.getInteractiveList = exports.closeModal = exports.showModal = exports.removeLinkedInteractiveStateListener = exports.addLinkedInteractiveStateListener = exports.removeGlobalInteractiveStateListener = exports.addGlobalInteractiveStateListener = exports.removeAuthoredStateListener = exports.addAuthoredStateListener = exports.removeInteractiveStateListener = exports.addInteractiveStateListener = exports.log = exports.getFirebaseJwt = exports.getAuthInfo = exports.setNavigation = exports.setHint = exports.postDecoratedContentEvent = exports.setHeight = exports.setSupportedFeatures = exports.removeGetReportItemAnswerListener = exports.addGetReportItemAnswerListener = exports.removeDecorateContentListener = exports.addDecorateContentListener = exports.removeCustomMessageListener = exports.addCustomMessageListener = exports.setGlobalInteractiveState = exports.getGlobalInteractiveState = exports.setAuthoredState = exports.getAuthoredState = exports.flushStateUpdates = exports.setInteractiveState = exports.setInteractiveStateTimeout = exports.getInteractiveState = exports.getMode = exports.getInitInteractiveMessage = void 0;
|
|
4102
|
+
exports.setOnUnload = exports.sendReportItemAnswer = exports.getAttachmentUrl = exports.readAttachment = exports.writeAttachment = exports.getLibraryInteractiveList = exports.getInteractiveSnapshot = exports.setLinkedInteractives = exports.getInteractiveList = exports.closeModal = exports.showModal = exports.removeLinkedInteractiveStateListener = exports.addLinkedInteractiveStateListener = exports.removeGlobalInteractiveStateListener = exports.addGlobalInteractiveStateListener = exports.removeAuthoredStateListener = exports.addAuthoredStateListener = exports.removeInteractiveStateListener = exports.addInteractiveStateListener = exports.log = exports.getFirebaseJwt = exports.getAuthInfo = exports.setNavigation = exports.setHint = exports.postDecoratedContentEvent = exports.setHeight = exports.setSupportedFeatures = exports.removeGetReportItemAnswerListener = exports.addGetReportItemAnswerListener = exports.removeDecorateContentListener = exports.addDecorateContentListener = exports.removeCustomMessageListener = exports.addCustomMessageListener = exports.setGlobalInteractiveState = exports.getGlobalInteractiveState = exports.setAuthoredState = exports.getAuthoredState = exports.flushStateUpdates = exports.setInteractiveState = exports.setInteractiveStateTimeout = exports.getInteractiveState = exports.getMode = exports.getInitInteractiveMessage = void 0;
|
|
4103
4103
|
var client_1 = __webpack_require__(/*! ./client */ "./src/interactive-api-client/client.ts");
|
|
4104
4104
|
var uuid_1 = __webpack_require__(/*! uuid */ "./node_modules/uuid/dist/esm-browser/index.js");
|
|
4105
4105
|
var THROW_NOT_IMPLEMENTED_YET = function (method) {
|
|
@@ -4265,7 +4265,7 @@ var postDecoratedContentEvent = function (msg) {
|
|
|
4265
4265
|
(0, client_1.getClient)().post("decoratedContentEvent", msg);
|
|
4266
4266
|
};
|
|
4267
4267
|
exports.postDecoratedContentEvent = postDecoratedContentEvent;
|
|
4268
|
-
|
|
4268
|
+
/**
|
|
4269
4269
|
* Providing empty string or null disables hint.
|
|
4270
4270
|
*/
|
|
4271
4271
|
var setHint = function (hint) {
|
|
@@ -4364,6 +4364,12 @@ var removeGlobalInteractiveStateListener = function (listener) {
|
|
|
4364
4364
|
exports.removeGlobalInteractiveStateListener = removeGlobalInteractiveStateListener;
|
|
4365
4365
|
// Mapping between external listener and internal listener, so it's possible to remove linkedInteractiveState listeners.
|
|
4366
4366
|
var _linkedInteractiveStateListeners = new Map();
|
|
4367
|
+
/**
|
|
4368
|
+
* The listener should be called immediately after it is added with any state of the linked
|
|
4369
|
+
* interactive that the host currently knows about. This first call might not happen
|
|
4370
|
+
* synchronously it could be slightly delayed. And then the listener should be called again
|
|
4371
|
+
* whenever the state of the linked interactive changes.
|
|
4372
|
+
*/
|
|
4367
4373
|
var addLinkedInteractiveStateListener = function (listener, options) {
|
|
4368
4374
|
var client = (0, client_1.getClient)();
|
|
4369
4375
|
var listenerId = (0, uuid_1.v4)();
|
|
@@ -4563,6 +4569,10 @@ var sendReportItemAnswer = function (request) {
|
|
|
4563
4569
|
(0, client_1.getClient)().post("reportItemAnswer", request);
|
|
4564
4570
|
};
|
|
4565
4571
|
exports.sendReportItemAnswer = sendReportItemAnswer;
|
|
4572
|
+
var setOnUnload = function (onUnload) {
|
|
4573
|
+
(0, client_1.getClient)().setOnUnload(onUnload);
|
|
4574
|
+
};
|
|
4575
|
+
exports.setOnUnload = setOnUnload;
|
|
4566
4576
|
|
|
4567
4577
|
|
|
4568
4578
|
/***/ }),
|
|
@@ -4587,6 +4597,42 @@ var __assign = (this && this.__assign) || function () {
|
|
|
4587
4597
|
};
|
|
4588
4598
|
return __assign.apply(this, arguments);
|
|
4589
4599
|
};
|
|
4600
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4601
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4602
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4603
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
4604
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
4605
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
4606
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
4607
|
+
});
|
|
4608
|
+
};
|
|
4609
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
4610
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
4611
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
4612
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
4613
|
+
function step(op) {
|
|
4614
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
4615
|
+
while (_) try {
|
|
4616
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
4617
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
4618
|
+
switch (op[0]) {
|
|
4619
|
+
case 0: case 1: t = op; break;
|
|
4620
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
4621
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
4622
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
4623
|
+
default:
|
|
4624
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
4625
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
4626
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
4627
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
4628
|
+
if (t[2]) _.ops.pop();
|
|
4629
|
+
_.trys.pop(); continue;
|
|
4630
|
+
}
|
|
4631
|
+
op = body.call(thisArg, _);
|
|
4632
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
4633
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
4634
|
+
}
|
|
4635
|
+
};
|
|
4590
4636
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
4591
4637
|
var t = {};
|
|
4592
4638
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -4635,6 +4681,7 @@ var Client = /** @class */ (function () {
|
|
|
4635
4681
|
this.managedState = new managed_state_1.ManagedState();
|
|
4636
4682
|
this.listeners = {};
|
|
4637
4683
|
this.requestId = 1;
|
|
4684
|
+
this.onUnload = undefined;
|
|
4638
4685
|
this.setSupportedFeatures = function (request) {
|
|
4639
4686
|
var newRequest = request;
|
|
4640
4687
|
if (_this.customMessagesHandled) {
|
|
@@ -4644,6 +4691,9 @@ var Client = /** @class */ (function () {
|
|
|
4644
4691
|
}
|
|
4645
4692
|
_this.post("supportedFeatures", newRequest);
|
|
4646
4693
|
};
|
|
4694
|
+
this.setOnUnload = function (onUnload) {
|
|
4695
|
+
_this.onUnload = onUnload;
|
|
4696
|
+
};
|
|
4647
4697
|
if (!(0, in_frame_1.inIframe)()) {
|
|
4648
4698
|
// tslint:disable-next-line:no-console
|
|
4649
4699
|
console.warn("Interactive API is meant to be used in iframe");
|
|
@@ -4784,10 +4834,26 @@ var Client = /** @class */ (function () {
|
|
|
4784
4834
|
_this.managedState.globalInteractiveState = parseJSONIfString(newInitMessage.globalInteractiveState);
|
|
4785
4835
|
}
|
|
4786
4836
|
});
|
|
4787
|
-
this.addListener("getInteractiveState", function () {
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4837
|
+
this.addListener("getInteractiveState", function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
4838
|
+
var finalState;
|
|
4839
|
+
return __generator(this, function (_a) {
|
|
4840
|
+
switch (_a.label) {
|
|
4841
|
+
case 0:
|
|
4842
|
+
if (!((options === null || options === void 0 ? void 0 : options.unloading) && this.onUnload)) return [3 /*break*/, 2];
|
|
4843
|
+
return [4 /*yield*/, this.onUnload(options)];
|
|
4844
|
+
case 1:
|
|
4845
|
+
finalState = _a.sent();
|
|
4846
|
+
if (finalState) {
|
|
4847
|
+
this.managedState.interactiveState = finalState;
|
|
4848
|
+
}
|
|
4849
|
+
_a.label = 2;
|
|
4850
|
+
case 2:
|
|
4851
|
+
this.post("interactiveState", this.managedState.interactiveState);
|
|
4852
|
+
this.managedState.interactiveStateDirty = false;
|
|
4853
|
+
return [2 /*return*/];
|
|
4854
|
+
}
|
|
4855
|
+
});
|
|
4856
|
+
}); });
|
|
4791
4857
|
this.addListener("loadInteractiveGlobal", function (globalState) {
|
|
4792
4858
|
_this.managedState.globalInteractiveState = parseJSONIfString(globalState);
|
|
4793
4859
|
});
|