@concord-consortium/lara-interactive-api 1.3.0-pre.2 → 1.4.0-pre.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 +5 -6
- package/client.d.ts +3 -1
- package/hooks.d.ts +3 -0
- package/index-bundle.d.ts +85 -18
- package/index.d.ts +1 -0
- package/index.js +998 -3
- package/package.json +1 -1
package/api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IInitInteractive, INavigationOptions, IAuthInfo, ISupportedFeatures, IShowModal, ICloseModal, IGetInteractiveListOptions, IGetInteractiveListResponse, ISetLinkedInteractives, IGetLibraryInteractiveListRequest, IJwtResponse, ICustomMessageHandler, ICustomMessagesHandledMap, IGetInteractiveSnapshotOptions, IGetInteractiveSnapshotResponse, IAddLinkedInteractiveStateListenerOptions, IDecoratedContentEvent, ITextDecorationHandler,
|
|
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";
|
|
2
2
|
export declare const getInitInteractiveMessage: <InteractiveState = {}, AuthoredState = {}, GlobalInteractiveState = {}>() => Promise<IInitInteractive<InteractiveState, AuthoredState, GlobalInteractiveState> | null>;
|
|
3
|
-
export declare const getMode: () => Promise<"runtime" | "authoring" | "report" | undefined>;
|
|
3
|
+
export declare const getMode: () => Promise<"runtime" | "authoring" | "report" | "reportItem" | undefined>;
|
|
4
4
|
export declare const getInteractiveState: <InteractiveState>() => InteractiveState | null;
|
|
5
5
|
export declare const setInteractiveStateTimeout = 2000;
|
|
6
6
|
/**
|
|
@@ -69,6 +69,8 @@ export declare const addCustomMessageListener: (callback: ICustomMessageHandler,
|
|
|
69
69
|
export declare const removeCustomMessageListener: () => void;
|
|
70
70
|
export declare const addDecorateContentListener: (callback: ITextDecorationHandler) => void;
|
|
71
71
|
export declare const removeDecorateContentListener: () => void;
|
|
72
|
+
export declare const addGetReportItemAnswerListener: (callback: IGetReportItemAnswerHandler) => void;
|
|
73
|
+
export declare const removeGetReportItemAnswerListener: () => void;
|
|
72
74
|
export declare const setSupportedFeatures: (features: ISupportedFeatures) => void;
|
|
73
75
|
export declare const setHeight: (height: number | string) => void;
|
|
74
76
|
export declare const postDecoratedContentEvent: (msg: IDecoratedContentEvent) => void;
|
|
@@ -99,10 +101,7 @@ export declare const getInteractiveSnapshot: (options: IGetInteractiveSnapshotOp
|
|
|
99
101
|
* @todo Implement this function.
|
|
100
102
|
*/
|
|
101
103
|
export declare const getLibraryInteractiveList: (options: IGetLibraryInteractiveListRequest) => void;
|
|
102
|
-
declare type WriteAttachmentParams = Omit<IWriteAttachmentRequest, "requestId" | "operation">;
|
|
103
104
|
export declare const writeAttachment: (params: WriteAttachmentParams) => Promise<Response>;
|
|
104
|
-
declare type ReadAttachmentParams = Omit<IAttachmentUrlRequest, "requestId" | "operation" | "contentType" | "expiresIn">;
|
|
105
105
|
export declare const readAttachment: (params: ReadAttachmentParams) => Promise<Response>;
|
|
106
|
-
declare type GetAttachmentUrlParams = Omit<IAttachmentUrlRequest, "requestId" | "operation">;
|
|
107
106
|
export declare const getAttachmentUrl: (params: GetAttachmentUrlParams) => Promise<string>;
|
|
108
|
-
export
|
|
107
|
+
export declare const sendReportItemAnswer: (request: Omit<IReportItemAnswer, "requestId">) => 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 } from "./types";
|
|
2
|
+
import { ClientMessage, ICustomMessageHandler, ICustomMessagesHandledMap, ISupportedFeaturesRequest, ServerMessage, ITextDecorationHandler, IGetReportItemAnswerHandler } from "./types";
|
|
3
3
|
import { ManagedState } from "./managed-state";
|
|
4
4
|
export declare const getClient: () => Client;
|
|
5
5
|
export declare class Client {
|
|
@@ -17,6 +17,8 @@ export declare class Client {
|
|
|
17
17
|
removeCustomMessageListener(): boolean;
|
|
18
18
|
addDecorateContentListener(callback: ITextDecorationHandler): void;
|
|
19
19
|
removeDecorateContentListener(): boolean;
|
|
20
|
+
addGetReportItemAnswerListener(callback: IGetReportItemAnswerHandler): void;
|
|
21
|
+
removeGetReportItemAnswerListener(): boolean;
|
|
20
22
|
setSupportedFeatures: (request: ISupportedFeaturesRequest) => void;
|
|
21
23
|
private connect;
|
|
22
24
|
}
|
package/hooks.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ISupportedFeatures } from "@concord-consortium/interactive-api-host";
|
|
1
2
|
import { ICustomMessageHandler, ICustomMessagesHandledMap, IInitInteractive, ITextDecorationHandler } from "./types";
|
|
2
3
|
declare type UpdateFunc<S> = (prevState: S | null) => S;
|
|
3
4
|
export declare const useInteractiveState: <InteractiveState>() => {
|
|
@@ -15,4 +16,6 @@ export declare const useGlobalInteractiveState: <GlobalInteractiveState>() => {
|
|
|
15
16
|
export declare const useInitMessage: <InteractiveState = {}, AuthoredState = {}, GlobalInteractiveState = {}>() => IInitInteractive<InteractiveState, AuthoredState, GlobalInteractiveState> | null;
|
|
16
17
|
export declare const useCustomMessages: (callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap | undefined) => void;
|
|
17
18
|
export declare const useDecorateContent: (callback: ITextDecorationHandler) => void;
|
|
19
|
+
export declare const useAutoSetHeight: () => void;
|
|
20
|
+
export declare const useSetSupportedFeatures: (features: ISupportedFeatures) => void;
|
|
18
21
|
export {};
|
package/index-bundle.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ISupportedFeatures as ISupportedFeatures$1 } from '@concord-consortium/interactive-api-host';
|
|
2
|
+
import * as iframePhone from 'iframe-phone';
|
|
3
|
+
|
|
1
4
|
interface IEventListener {
|
|
2
5
|
type: string;
|
|
3
6
|
listener: (evt: Event) => void;
|
|
@@ -42,9 +45,8 @@ interface IInteractiveStateProps<InteractiveState = {}> {
|
|
|
42
45
|
updatedAt?: string;
|
|
43
46
|
interactiveStateUrl?: string;
|
|
44
47
|
interactive: {
|
|
45
|
-
id?:
|
|
48
|
+
id?: string;
|
|
46
49
|
name?: string;
|
|
47
|
-
questionId?: string;
|
|
48
50
|
};
|
|
49
51
|
pageNumber?: number;
|
|
50
52
|
pageName?: string;
|
|
@@ -75,9 +77,8 @@ interface IRuntimeInitInteractive<InteractiveState = {}, AuthoredState = {}, Glo
|
|
|
75
77
|
collaboratorUrls: string[] | null;
|
|
76
78
|
classInfoUrl: string;
|
|
77
79
|
interactive: {
|
|
78
|
-
id:
|
|
80
|
+
id: string;
|
|
79
81
|
name: string;
|
|
80
|
-
questionId: string;
|
|
81
82
|
};
|
|
82
83
|
authInfo: {
|
|
83
84
|
provider: string;
|
|
@@ -116,15 +117,18 @@ interface IReportInitInteractive<InteractiveState = {}, AuthoredState = {}> {
|
|
|
116
117
|
interactiveState: InteractiveState;
|
|
117
118
|
themeInfo: IThemeInfo;
|
|
118
119
|
}
|
|
119
|
-
interface
|
|
120
|
+
interface IReportItemInitInteractive<InteractiveState = {}, AuthoredState = {}> {
|
|
120
121
|
version: 1;
|
|
121
|
-
mode: "
|
|
122
|
+
mode: "reportItem";
|
|
122
123
|
hostFeatures: IHostFeatures;
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
interactiveItemId: string;
|
|
125
|
+
view: "singleAnswer" | "multipleAnswer";
|
|
126
|
+
users: Record<string, {
|
|
127
|
+
hasAnswer: boolean;
|
|
128
|
+
}>;
|
|
125
129
|
}
|
|
126
|
-
declare type IInitInteractive<InteractiveState = {}, AuthoredState = {}, GlobalInteractiveState = {}> = IRuntimeInitInteractive<InteractiveState, AuthoredState, GlobalInteractiveState> | IAuthoringInitInteractive<AuthoredState> | IReportInitInteractive<InteractiveState, AuthoredState>;
|
|
127
|
-
declare type InitInteractiveMode = "runtime" | "authoring" | "report";
|
|
130
|
+
declare type IInitInteractive<InteractiveState = {}, AuthoredState = {}, GlobalInteractiveState = {}> = IRuntimeInitInteractive<InteractiveState, AuthoredState, GlobalInteractiveState> | IAuthoringInitInteractive<AuthoredState> | IReportInitInteractive<InteractiveState, AuthoredState> | IReportItemInitInteractive<InteractiveState, AuthoredState>;
|
|
131
|
+
declare type InitInteractiveMode = "runtime" | "authoring" | "report" | "reportItem";
|
|
128
132
|
interface ICustomReportFieldsAuthoredStateField {
|
|
129
133
|
key: string;
|
|
130
134
|
columnHeader: string;
|
|
@@ -147,14 +151,16 @@ declare type IRuntimeClientMessage = "interactiveState" | "height" | "hint" | "g
|
|
|
147
151
|
declare type IRuntimeServerMessage = "attachmentUrl" | "authInfo" | "getInteractiveState" | "initInteractive" | "firebaseJWT" | "closedModal" | "customMessage" | "libraryInteractiveList" | "interactiveSnapshot" | "contextMembership" | "linkedInteractiveState" | "decorateContent";
|
|
148
152
|
declare type IAuthoringClientMessage = "getInteractiveList" | "setLinkedInteractives" | "getFirebaseJWT";
|
|
149
153
|
declare type IAuthoringServerMessage = "interactiveList" | "firebaseJWT";
|
|
154
|
+
declare type IReportItemClientMessage = "reportItemAnswer" | "reportItemClientReady";
|
|
155
|
+
declare type IReportItemServerMessage = "getReportItemAnswer";
|
|
150
156
|
declare type GlobalIFrameSaverClientMessage = "interactiveStateGlobal";
|
|
151
157
|
declare type GlobalIFrameSaverServerMessage = "loadInteractiveGlobal";
|
|
152
158
|
declare type LoggerClientMessage = "log";
|
|
153
159
|
declare type IframePhoneServerMessage = "hello";
|
|
154
160
|
declare type DeprecatedRuntimeClientMessage = "setLearnerUrl";
|
|
155
161
|
declare type DeprecatedRuntimeServerMessage = "getLearnerUrl" | "loadInteractive";
|
|
156
|
-
declare type ClientMessage = DeprecatedRuntimeClientMessage | IRuntimeClientMessage | IAuthoringClientMessage | GlobalIFrameSaverClientMessage | LoggerClientMessage;
|
|
157
|
-
declare type ServerMessage = IframePhoneServerMessage | DeprecatedRuntimeServerMessage | IRuntimeServerMessage | IAuthoringServerMessage | GlobalIFrameSaverServerMessage;
|
|
162
|
+
declare type ClientMessage = DeprecatedRuntimeClientMessage | IRuntimeClientMessage | IAuthoringClientMessage | GlobalIFrameSaverClientMessage | LoggerClientMessage | IReportItemClientMessage;
|
|
163
|
+
declare type ServerMessage = IframePhoneServerMessage | DeprecatedRuntimeServerMessage | IRuntimeServerMessage | IAuthoringServerMessage | GlobalIFrameSaverServerMessage | IReportItemServerMessage;
|
|
158
164
|
interface IContextMember {
|
|
159
165
|
userId: string;
|
|
160
166
|
firstName: string;
|
|
@@ -265,7 +271,7 @@ interface IAuthInfo {
|
|
|
265
271
|
interface IAttachmentUrlRequest extends IBaseRequestResponse {
|
|
266
272
|
name: string;
|
|
267
273
|
operation: "read" | "write";
|
|
268
|
-
|
|
274
|
+
interactiveId?: string;
|
|
269
275
|
contentType?: string;
|
|
270
276
|
expiresIn?: number;
|
|
271
277
|
}
|
|
@@ -277,6 +283,9 @@ interface IAttachmentUrlResponse extends IBaseRequestResponse {
|
|
|
277
283
|
url?: string;
|
|
278
284
|
error?: string;
|
|
279
285
|
}
|
|
286
|
+
declare type ReadAttachmentParams = Omit<IAttachmentUrlRequest, "requestId" | "operation" | "contentType" | "expiresIn">;
|
|
287
|
+
declare type WriteAttachmentParams = Omit<IWriteAttachmentRequest, "requestId" | "operation">;
|
|
288
|
+
declare type GetAttachmentUrlParams = Omit<IAttachmentUrlRequest, "requestId" | "operation">;
|
|
280
289
|
interface IGetAuthInfoRequest extends IBaseRequestResponse {
|
|
281
290
|
}
|
|
282
291
|
interface IGetAuthInfoResponse extends IBaseRequestResponse, IAuthInfo {
|
|
@@ -342,6 +351,18 @@ interface ILinkedInteractiveStateResponse<LinkedInteractiveState> {
|
|
|
342
351
|
listenerId: string;
|
|
343
352
|
interactiveState: LinkedInteractiveState | undefined;
|
|
344
353
|
}
|
|
354
|
+
interface IGetReportItemAnswer<InteractiveState = {}, AuthoredState = {}> extends IBaseRequestResponse {
|
|
355
|
+
type: "html";
|
|
356
|
+
platformUserId: string;
|
|
357
|
+
interactiveState: InteractiveState;
|
|
358
|
+
authoredState: AuthoredState;
|
|
359
|
+
}
|
|
360
|
+
interface IReportItemAnswer extends IBaseRequestResponse {
|
|
361
|
+
type: "html";
|
|
362
|
+
platformUserId: string;
|
|
363
|
+
html: string;
|
|
364
|
+
}
|
|
365
|
+
declare type IGetReportItemAnswerHandler = (message: IGetReportItemAnswer) => void;
|
|
345
366
|
/**
|
|
346
367
|
* Interface that can be used by interactives to export and consume datasets. For example:
|
|
347
368
|
* - Vortex interactive is exporting its dataset in the interactive state
|
|
@@ -430,7 +451,7 @@ declare type IRuntimeMetadata = IRuntimeInteractiveMetadata | IRuntimeOpenRespon
|
|
|
430
451
|
declare const inIframe: () => boolean;
|
|
431
452
|
|
|
432
453
|
declare const getInitInteractiveMessage: <InteractiveState = {}, AuthoredState = {}, GlobalInteractiveState = {}>() => Promise<IInitInteractive<InteractiveState, AuthoredState, GlobalInteractiveState> | null>;
|
|
433
|
-
declare const getMode: () => Promise<"runtime" | "authoring" | "report" | undefined>;
|
|
454
|
+
declare const getMode: () => Promise<"runtime" | "authoring" | "report" | "reportItem" | undefined>;
|
|
434
455
|
declare const getInteractiveState: <InteractiveState>() => InteractiveState | null;
|
|
435
456
|
declare const setInteractiveStateTimeout = 2000;
|
|
436
457
|
/**
|
|
@@ -499,6 +520,8 @@ declare const addCustomMessageListener: (callback: ICustomMessageHandler, handle
|
|
|
499
520
|
declare const removeCustomMessageListener: () => void;
|
|
500
521
|
declare const addDecorateContentListener: (callback: ITextDecorationHandler) => void;
|
|
501
522
|
declare const removeDecorateContentListener: () => void;
|
|
523
|
+
declare const addGetReportItemAnswerListener: (callback: IGetReportItemAnswerHandler) => void;
|
|
524
|
+
declare const removeGetReportItemAnswerListener: () => void;
|
|
502
525
|
declare const setSupportedFeatures: (features: ISupportedFeatures) => void;
|
|
503
526
|
declare const setHeight: (height: number | string) => void;
|
|
504
527
|
declare const postDecoratedContentEvent: (msg: IDecoratedContentEvent) => void;
|
|
@@ -529,12 +552,10 @@ declare const getInteractiveSnapshot: (options: IGetInteractiveSnapshotOptions)
|
|
|
529
552
|
* @todo Implement this function.
|
|
530
553
|
*/
|
|
531
554
|
declare const getLibraryInteractiveList: (options: IGetLibraryInteractiveListRequest) => void;
|
|
532
|
-
declare type WriteAttachmentParams = Omit<IWriteAttachmentRequest, "requestId" | "operation">;
|
|
533
555
|
declare const writeAttachment: (params: WriteAttachmentParams) => Promise<Response>;
|
|
534
|
-
declare type ReadAttachmentParams = Omit<IAttachmentUrlRequest, "requestId" | "operation" | "contentType" | "expiresIn">;
|
|
535
556
|
declare const readAttachment: (params: ReadAttachmentParams) => Promise<Response>;
|
|
536
|
-
declare type GetAttachmentUrlParams = Omit<IAttachmentUrlRequest, "requestId" | "operation">;
|
|
537
557
|
declare const getAttachmentUrl: (params: GetAttachmentUrlParams) => Promise<string>;
|
|
558
|
+
declare const sendReportItemAnswer: (request: Omit<IReportItemAnswer, "requestId">) => void;
|
|
538
559
|
|
|
539
560
|
declare type UpdateFunc<S> = (prevState: S | null) => S;
|
|
540
561
|
declare const useInteractiveState: <InteractiveState>() => {
|
|
@@ -552,5 +573,51 @@ declare const useGlobalInteractiveState: <GlobalInteractiveState>() => {
|
|
|
552
573
|
declare const useInitMessage: <InteractiveState = {}, AuthoredState = {}, GlobalInteractiveState = {}>() => IInitInteractive<InteractiveState, AuthoredState, GlobalInteractiveState> | null;
|
|
553
574
|
declare const useCustomMessages: (callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap | undefined) => void;
|
|
554
575
|
declare const useDecorateContent: (callback: ITextDecorationHandler) => void;
|
|
576
|
+
declare const useAutoSetHeight: () => void;
|
|
577
|
+
declare const useSetSupportedFeatures: (features: ISupportedFeatures$1) => void;
|
|
578
|
+
|
|
579
|
+
declare type ManagedStateEvent = "interactiveStateUpdated" | "globalInteractiveStateUpdated" | "authoredStateUpdated" | "initInteractive";
|
|
580
|
+
declare class ManagedState {
|
|
581
|
+
interactiveStateDirty: boolean;
|
|
582
|
+
private _initMessage;
|
|
583
|
+
private _interactiveState;
|
|
584
|
+
private _authoredState;
|
|
585
|
+
private _globalInteractiveState;
|
|
586
|
+
private emitter;
|
|
587
|
+
get initMessage(): any;
|
|
588
|
+
set initMessage(value: any);
|
|
589
|
+
get interactiveState(): any;
|
|
590
|
+
set interactiveState(value: any);
|
|
591
|
+
get authoredState(): any;
|
|
592
|
+
set authoredState(value: any);
|
|
593
|
+
get globalInteractiveState(): any;
|
|
594
|
+
set globalInteractiveState(value: any);
|
|
595
|
+
emit(event: ManagedStateEvent, content?: any): void;
|
|
596
|
+
on(event: ManagedStateEvent, handler: any): void;
|
|
597
|
+
off(event: ManagedStateEvent, handler: any): void;
|
|
598
|
+
once(event: ManagedStateEvent, handler: any): void;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
declare const getClient: () => Client;
|
|
602
|
+
declare class Client {
|
|
603
|
+
phone: iframePhone.IFrameEndpoint;
|
|
604
|
+
managedState: ManagedState;
|
|
605
|
+
private customMessagesHandled;
|
|
606
|
+
private listeners;
|
|
607
|
+
private requestId;
|
|
608
|
+
constructor();
|
|
609
|
+
getNextRequestId(): number;
|
|
610
|
+
post(message: ClientMessage, content?: any): void;
|
|
611
|
+
addListener(message: ServerMessage, callback: iframePhone.ListenerCallback, requestId?: number): boolean;
|
|
612
|
+
removeListener(message: ServerMessage, requestId?: number, callback?: iframePhone.ListenerCallback): boolean;
|
|
613
|
+
addCustomMessageListener(callback: ICustomMessageHandler, handles?: ICustomMessagesHandledMap): void;
|
|
614
|
+
removeCustomMessageListener(): boolean;
|
|
615
|
+
addDecorateContentListener(callback: ITextDecorationHandler): void;
|
|
616
|
+
removeDecorateContentListener(): boolean;
|
|
617
|
+
addGetReportItemAnswerListener(callback: IGetReportItemAnswerHandler): void;
|
|
618
|
+
removeGetReportItemAnswerListener(): boolean;
|
|
619
|
+
setSupportedFeatures: (request: ISupportedFeaturesRequest) => void;
|
|
620
|
+
private connect;
|
|
621
|
+
}
|
|
555
622
|
|
|
556
|
-
export { ChoiceId, ClientMessage, DeprecatedRuntimeClientMessage, DeprecatedRuntimeServerMessage, GlobalIFrameSaverClientMessage, GlobalIFrameSaverServerMessage, IAddLinkedInteractiveStateListenerOptions, IAddLinkedInteractiveStateListenerRequest,
|
|
623
|
+
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, useSetSupportedFeatures, writeAttachment };
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1944,6 +1944,948 @@ process.chdir = function (dir) {
|
|
|
1944
1944
|
process.umask = function() { return 0; };
|
|
1945
1945
|
|
|
1946
1946
|
|
|
1947
|
+
/***/ }),
|
|
1948
|
+
|
|
1949
|
+
/***/ "./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js":
|
|
1950
|
+
/*!*************************************************************************!*\
|
|
1951
|
+
!*** ./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js ***!
|
|
1952
|
+
\*************************************************************************/
|
|
1953
|
+
/*! exports provided: default */
|
|
1954
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1955
|
+
|
|
1956
|
+
"use strict";
|
|
1957
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1958
|
+
/* WEBPACK VAR INJECTION */(function(global) {/**
|
|
1959
|
+
* A collection of shims that provide minimal functionality of the ES6 collections.
|
|
1960
|
+
*
|
|
1961
|
+
* These implementations are not meant to be used outside of the ResizeObserver
|
|
1962
|
+
* modules as they cover only a limited range of use cases.
|
|
1963
|
+
*/
|
|
1964
|
+
/* eslint-disable require-jsdoc, valid-jsdoc */
|
|
1965
|
+
var MapShim = (function () {
|
|
1966
|
+
if (typeof Map !== 'undefined') {
|
|
1967
|
+
return Map;
|
|
1968
|
+
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Returns index in provided array that matches the specified key.
|
|
1971
|
+
*
|
|
1972
|
+
* @param {Array<Array>} arr
|
|
1973
|
+
* @param {*} key
|
|
1974
|
+
* @returns {number}
|
|
1975
|
+
*/
|
|
1976
|
+
function getIndex(arr, key) {
|
|
1977
|
+
var result = -1;
|
|
1978
|
+
arr.some(function (entry, index) {
|
|
1979
|
+
if (entry[0] === key) {
|
|
1980
|
+
result = index;
|
|
1981
|
+
return true;
|
|
1982
|
+
}
|
|
1983
|
+
return false;
|
|
1984
|
+
});
|
|
1985
|
+
return result;
|
|
1986
|
+
}
|
|
1987
|
+
return /** @class */ (function () {
|
|
1988
|
+
function class_1() {
|
|
1989
|
+
this.__entries__ = [];
|
|
1990
|
+
}
|
|
1991
|
+
Object.defineProperty(class_1.prototype, "size", {
|
|
1992
|
+
/**
|
|
1993
|
+
* @returns {boolean}
|
|
1994
|
+
*/
|
|
1995
|
+
get: function () {
|
|
1996
|
+
return this.__entries__.length;
|
|
1997
|
+
},
|
|
1998
|
+
enumerable: true,
|
|
1999
|
+
configurable: true
|
|
2000
|
+
});
|
|
2001
|
+
/**
|
|
2002
|
+
* @param {*} key
|
|
2003
|
+
* @returns {*}
|
|
2004
|
+
*/
|
|
2005
|
+
class_1.prototype.get = function (key) {
|
|
2006
|
+
var index = getIndex(this.__entries__, key);
|
|
2007
|
+
var entry = this.__entries__[index];
|
|
2008
|
+
return entry && entry[1];
|
|
2009
|
+
};
|
|
2010
|
+
/**
|
|
2011
|
+
* @param {*} key
|
|
2012
|
+
* @param {*} value
|
|
2013
|
+
* @returns {void}
|
|
2014
|
+
*/
|
|
2015
|
+
class_1.prototype.set = function (key, value) {
|
|
2016
|
+
var index = getIndex(this.__entries__, key);
|
|
2017
|
+
if (~index) {
|
|
2018
|
+
this.__entries__[index][1] = value;
|
|
2019
|
+
}
|
|
2020
|
+
else {
|
|
2021
|
+
this.__entries__.push([key, value]);
|
|
2022
|
+
}
|
|
2023
|
+
};
|
|
2024
|
+
/**
|
|
2025
|
+
* @param {*} key
|
|
2026
|
+
* @returns {void}
|
|
2027
|
+
*/
|
|
2028
|
+
class_1.prototype.delete = function (key) {
|
|
2029
|
+
var entries = this.__entries__;
|
|
2030
|
+
var index = getIndex(entries, key);
|
|
2031
|
+
if (~index) {
|
|
2032
|
+
entries.splice(index, 1);
|
|
2033
|
+
}
|
|
2034
|
+
};
|
|
2035
|
+
/**
|
|
2036
|
+
* @param {*} key
|
|
2037
|
+
* @returns {void}
|
|
2038
|
+
*/
|
|
2039
|
+
class_1.prototype.has = function (key) {
|
|
2040
|
+
return !!~getIndex(this.__entries__, key);
|
|
2041
|
+
};
|
|
2042
|
+
/**
|
|
2043
|
+
* @returns {void}
|
|
2044
|
+
*/
|
|
2045
|
+
class_1.prototype.clear = function () {
|
|
2046
|
+
this.__entries__.splice(0);
|
|
2047
|
+
};
|
|
2048
|
+
/**
|
|
2049
|
+
* @param {Function} callback
|
|
2050
|
+
* @param {*} [ctx=null]
|
|
2051
|
+
* @returns {void}
|
|
2052
|
+
*/
|
|
2053
|
+
class_1.prototype.forEach = function (callback, ctx) {
|
|
2054
|
+
if (ctx === void 0) { ctx = null; }
|
|
2055
|
+
for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
|
|
2056
|
+
var entry = _a[_i];
|
|
2057
|
+
callback.call(ctx, entry[1], entry[0]);
|
|
2058
|
+
}
|
|
2059
|
+
};
|
|
2060
|
+
return class_1;
|
|
2061
|
+
}());
|
|
2062
|
+
})();
|
|
2063
|
+
|
|
2064
|
+
/**
|
|
2065
|
+
* Detects whether window and document objects are available in current environment.
|
|
2066
|
+
*/
|
|
2067
|
+
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;
|
|
2068
|
+
|
|
2069
|
+
// Returns global object of a current environment.
|
|
2070
|
+
var global$1 = (function () {
|
|
2071
|
+
if (typeof global !== 'undefined' && global.Math === Math) {
|
|
2072
|
+
return global;
|
|
2073
|
+
}
|
|
2074
|
+
if (typeof self !== 'undefined' && self.Math === Math) {
|
|
2075
|
+
return self;
|
|
2076
|
+
}
|
|
2077
|
+
if (typeof window !== 'undefined' && window.Math === Math) {
|
|
2078
|
+
return window;
|
|
2079
|
+
}
|
|
2080
|
+
// eslint-disable-next-line no-new-func
|
|
2081
|
+
return Function('return this')();
|
|
2082
|
+
})();
|
|
2083
|
+
|
|
2084
|
+
/**
|
|
2085
|
+
* A shim for the requestAnimationFrame which falls back to the setTimeout if
|
|
2086
|
+
* first one is not supported.
|
|
2087
|
+
*
|
|
2088
|
+
* @returns {number} Requests' identifier.
|
|
2089
|
+
*/
|
|
2090
|
+
var requestAnimationFrame$1 = (function () {
|
|
2091
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
2092
|
+
// It's required to use a bounded function because IE sometimes throws
|
|
2093
|
+
// an "Invalid calling object" error if rAF is invoked without the global
|
|
2094
|
+
// object on the left hand side.
|
|
2095
|
+
return requestAnimationFrame.bind(global$1);
|
|
2096
|
+
}
|
|
2097
|
+
return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
|
|
2098
|
+
})();
|
|
2099
|
+
|
|
2100
|
+
// Defines minimum timeout before adding a trailing call.
|
|
2101
|
+
var trailingTimeout = 2;
|
|
2102
|
+
/**
|
|
2103
|
+
* Creates a wrapper function which ensures that provided callback will be
|
|
2104
|
+
* invoked only once during the specified delay period.
|
|
2105
|
+
*
|
|
2106
|
+
* @param {Function} callback - Function to be invoked after the delay period.
|
|
2107
|
+
* @param {number} delay - Delay after which to invoke callback.
|
|
2108
|
+
* @returns {Function}
|
|
2109
|
+
*/
|
|
2110
|
+
function throttle (callback, delay) {
|
|
2111
|
+
var leadingCall = false, trailingCall = false, lastCallTime = 0;
|
|
2112
|
+
/**
|
|
2113
|
+
* Invokes the original callback function and schedules new invocation if
|
|
2114
|
+
* the "proxy" was called during current request.
|
|
2115
|
+
*
|
|
2116
|
+
* @returns {void}
|
|
2117
|
+
*/
|
|
2118
|
+
function resolvePending() {
|
|
2119
|
+
if (leadingCall) {
|
|
2120
|
+
leadingCall = false;
|
|
2121
|
+
callback();
|
|
2122
|
+
}
|
|
2123
|
+
if (trailingCall) {
|
|
2124
|
+
proxy();
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
/**
|
|
2128
|
+
* Callback invoked after the specified delay. It will further postpone
|
|
2129
|
+
* invocation of the original function delegating it to the
|
|
2130
|
+
* requestAnimationFrame.
|
|
2131
|
+
*
|
|
2132
|
+
* @returns {void}
|
|
2133
|
+
*/
|
|
2134
|
+
function timeoutCallback() {
|
|
2135
|
+
requestAnimationFrame$1(resolvePending);
|
|
2136
|
+
}
|
|
2137
|
+
/**
|
|
2138
|
+
* Schedules invocation of the original function.
|
|
2139
|
+
*
|
|
2140
|
+
* @returns {void}
|
|
2141
|
+
*/
|
|
2142
|
+
function proxy() {
|
|
2143
|
+
var timeStamp = Date.now();
|
|
2144
|
+
if (leadingCall) {
|
|
2145
|
+
// Reject immediately following calls.
|
|
2146
|
+
if (timeStamp - lastCallTime < trailingTimeout) {
|
|
2147
|
+
return;
|
|
2148
|
+
}
|
|
2149
|
+
// Schedule new call to be in invoked when the pending one is resolved.
|
|
2150
|
+
// This is important for "transitions" which never actually start
|
|
2151
|
+
// immediately so there is a chance that we might miss one if change
|
|
2152
|
+
// happens amids the pending invocation.
|
|
2153
|
+
trailingCall = true;
|
|
2154
|
+
}
|
|
2155
|
+
else {
|
|
2156
|
+
leadingCall = true;
|
|
2157
|
+
trailingCall = false;
|
|
2158
|
+
setTimeout(timeoutCallback, delay);
|
|
2159
|
+
}
|
|
2160
|
+
lastCallTime = timeStamp;
|
|
2161
|
+
}
|
|
2162
|
+
return proxy;
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
// Minimum delay before invoking the update of observers.
|
|
2166
|
+
var REFRESH_DELAY = 20;
|
|
2167
|
+
// A list of substrings of CSS properties used to find transition events that
|
|
2168
|
+
// might affect dimensions of observed elements.
|
|
2169
|
+
var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
|
|
2170
|
+
// Check if MutationObserver is available.
|
|
2171
|
+
var mutationObserverSupported = typeof MutationObserver !== 'undefined';
|
|
2172
|
+
/**
|
|
2173
|
+
* Singleton controller class which handles updates of ResizeObserver instances.
|
|
2174
|
+
*/
|
|
2175
|
+
var ResizeObserverController = /** @class */ (function () {
|
|
2176
|
+
/**
|
|
2177
|
+
* Creates a new instance of ResizeObserverController.
|
|
2178
|
+
*
|
|
2179
|
+
* @private
|
|
2180
|
+
*/
|
|
2181
|
+
function ResizeObserverController() {
|
|
2182
|
+
/**
|
|
2183
|
+
* Indicates whether DOM listeners have been added.
|
|
2184
|
+
*
|
|
2185
|
+
* @private {boolean}
|
|
2186
|
+
*/
|
|
2187
|
+
this.connected_ = false;
|
|
2188
|
+
/**
|
|
2189
|
+
* Tells that controller has subscribed for Mutation Events.
|
|
2190
|
+
*
|
|
2191
|
+
* @private {boolean}
|
|
2192
|
+
*/
|
|
2193
|
+
this.mutationEventsAdded_ = false;
|
|
2194
|
+
/**
|
|
2195
|
+
* Keeps reference to the instance of MutationObserver.
|
|
2196
|
+
*
|
|
2197
|
+
* @private {MutationObserver}
|
|
2198
|
+
*/
|
|
2199
|
+
this.mutationsObserver_ = null;
|
|
2200
|
+
/**
|
|
2201
|
+
* A list of connected observers.
|
|
2202
|
+
*
|
|
2203
|
+
* @private {Array<ResizeObserverSPI>}
|
|
2204
|
+
*/
|
|
2205
|
+
this.observers_ = [];
|
|
2206
|
+
this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
|
|
2207
|
+
this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY);
|
|
2208
|
+
}
|
|
2209
|
+
/**
|
|
2210
|
+
* Adds observer to observers list.
|
|
2211
|
+
*
|
|
2212
|
+
* @param {ResizeObserverSPI} observer - Observer to be added.
|
|
2213
|
+
* @returns {void}
|
|
2214
|
+
*/
|
|
2215
|
+
ResizeObserverController.prototype.addObserver = function (observer) {
|
|
2216
|
+
if (!~this.observers_.indexOf(observer)) {
|
|
2217
|
+
this.observers_.push(observer);
|
|
2218
|
+
}
|
|
2219
|
+
// Add listeners if they haven't been added yet.
|
|
2220
|
+
if (!this.connected_) {
|
|
2221
|
+
this.connect_();
|
|
2222
|
+
}
|
|
2223
|
+
};
|
|
2224
|
+
/**
|
|
2225
|
+
* Removes observer from observers list.
|
|
2226
|
+
*
|
|
2227
|
+
* @param {ResizeObserverSPI} observer - Observer to be removed.
|
|
2228
|
+
* @returns {void}
|
|
2229
|
+
*/
|
|
2230
|
+
ResizeObserverController.prototype.removeObserver = function (observer) {
|
|
2231
|
+
var observers = this.observers_;
|
|
2232
|
+
var index = observers.indexOf(observer);
|
|
2233
|
+
// Remove observer if it's present in registry.
|
|
2234
|
+
if (~index) {
|
|
2235
|
+
observers.splice(index, 1);
|
|
2236
|
+
}
|
|
2237
|
+
// Remove listeners if controller has no connected observers.
|
|
2238
|
+
if (!observers.length && this.connected_) {
|
|
2239
|
+
this.disconnect_();
|
|
2240
|
+
}
|
|
2241
|
+
};
|
|
2242
|
+
/**
|
|
2243
|
+
* Invokes the update of observers. It will continue running updates insofar
|
|
2244
|
+
* it detects changes.
|
|
2245
|
+
*
|
|
2246
|
+
* @returns {void}
|
|
2247
|
+
*/
|
|
2248
|
+
ResizeObserverController.prototype.refresh = function () {
|
|
2249
|
+
var changesDetected = this.updateObservers_();
|
|
2250
|
+
// Continue running updates if changes have been detected as there might
|
|
2251
|
+
// be future ones caused by CSS transitions.
|
|
2252
|
+
if (changesDetected) {
|
|
2253
|
+
this.refresh();
|
|
2254
|
+
}
|
|
2255
|
+
};
|
|
2256
|
+
/**
|
|
2257
|
+
* Updates every observer from observers list and notifies them of queued
|
|
2258
|
+
* entries.
|
|
2259
|
+
*
|
|
2260
|
+
* @private
|
|
2261
|
+
* @returns {boolean} Returns "true" if any observer has detected changes in
|
|
2262
|
+
* dimensions of it's elements.
|
|
2263
|
+
*/
|
|
2264
|
+
ResizeObserverController.prototype.updateObservers_ = function () {
|
|
2265
|
+
// Collect observers that have active observations.
|
|
2266
|
+
var activeObservers = this.observers_.filter(function (observer) {
|
|
2267
|
+
return observer.gatherActive(), observer.hasActive();
|
|
2268
|
+
});
|
|
2269
|
+
// Deliver notifications in a separate cycle in order to avoid any
|
|
2270
|
+
// collisions between observers, e.g. when multiple instances of
|
|
2271
|
+
// ResizeObserver are tracking the same element and the callback of one
|
|
2272
|
+
// of them changes content dimensions of the observed target. Sometimes
|
|
2273
|
+
// this may result in notifications being blocked for the rest of observers.
|
|
2274
|
+
activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
|
|
2275
|
+
return activeObservers.length > 0;
|
|
2276
|
+
};
|
|
2277
|
+
/**
|
|
2278
|
+
* Initializes DOM listeners.
|
|
2279
|
+
*
|
|
2280
|
+
* @private
|
|
2281
|
+
* @returns {void}
|
|
2282
|
+
*/
|
|
2283
|
+
ResizeObserverController.prototype.connect_ = function () {
|
|
2284
|
+
// Do nothing if running in a non-browser environment or if listeners
|
|
2285
|
+
// have been already added.
|
|
2286
|
+
if (!isBrowser || this.connected_) {
|
|
2287
|
+
return;
|
|
2288
|
+
}
|
|
2289
|
+
// Subscription to the "Transitionend" event is used as a workaround for
|
|
2290
|
+
// delayed transitions. This way it's possible to capture at least the
|
|
2291
|
+
// final state of an element.
|
|
2292
|
+
document.addEventListener('transitionend', this.onTransitionEnd_);
|
|
2293
|
+
window.addEventListener('resize', this.refresh);
|
|
2294
|
+
if (mutationObserverSupported) {
|
|
2295
|
+
this.mutationsObserver_ = new MutationObserver(this.refresh);
|
|
2296
|
+
this.mutationsObserver_.observe(document, {
|
|
2297
|
+
attributes: true,
|
|
2298
|
+
childList: true,
|
|
2299
|
+
characterData: true,
|
|
2300
|
+
subtree: true
|
|
2301
|
+
});
|
|
2302
|
+
}
|
|
2303
|
+
else {
|
|
2304
|
+
document.addEventListener('DOMSubtreeModified', this.refresh);
|
|
2305
|
+
this.mutationEventsAdded_ = true;
|
|
2306
|
+
}
|
|
2307
|
+
this.connected_ = true;
|
|
2308
|
+
};
|
|
2309
|
+
/**
|
|
2310
|
+
* Removes DOM listeners.
|
|
2311
|
+
*
|
|
2312
|
+
* @private
|
|
2313
|
+
* @returns {void}
|
|
2314
|
+
*/
|
|
2315
|
+
ResizeObserverController.prototype.disconnect_ = function () {
|
|
2316
|
+
// Do nothing if running in a non-browser environment or if listeners
|
|
2317
|
+
// have been already removed.
|
|
2318
|
+
if (!isBrowser || !this.connected_) {
|
|
2319
|
+
return;
|
|
2320
|
+
}
|
|
2321
|
+
document.removeEventListener('transitionend', this.onTransitionEnd_);
|
|
2322
|
+
window.removeEventListener('resize', this.refresh);
|
|
2323
|
+
if (this.mutationsObserver_) {
|
|
2324
|
+
this.mutationsObserver_.disconnect();
|
|
2325
|
+
}
|
|
2326
|
+
if (this.mutationEventsAdded_) {
|
|
2327
|
+
document.removeEventListener('DOMSubtreeModified', this.refresh);
|
|
2328
|
+
}
|
|
2329
|
+
this.mutationsObserver_ = null;
|
|
2330
|
+
this.mutationEventsAdded_ = false;
|
|
2331
|
+
this.connected_ = false;
|
|
2332
|
+
};
|
|
2333
|
+
/**
|
|
2334
|
+
* "Transitionend" event handler.
|
|
2335
|
+
*
|
|
2336
|
+
* @private
|
|
2337
|
+
* @param {TransitionEvent} event
|
|
2338
|
+
* @returns {void}
|
|
2339
|
+
*/
|
|
2340
|
+
ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
|
|
2341
|
+
var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
|
|
2342
|
+
// Detect whether transition may affect dimensions of an element.
|
|
2343
|
+
var isReflowProperty = transitionKeys.some(function (key) {
|
|
2344
|
+
return !!~propertyName.indexOf(key);
|
|
2345
|
+
});
|
|
2346
|
+
if (isReflowProperty) {
|
|
2347
|
+
this.refresh();
|
|
2348
|
+
}
|
|
2349
|
+
};
|
|
2350
|
+
/**
|
|
2351
|
+
* Returns instance of the ResizeObserverController.
|
|
2352
|
+
*
|
|
2353
|
+
* @returns {ResizeObserverController}
|
|
2354
|
+
*/
|
|
2355
|
+
ResizeObserverController.getInstance = function () {
|
|
2356
|
+
if (!this.instance_) {
|
|
2357
|
+
this.instance_ = new ResizeObserverController();
|
|
2358
|
+
}
|
|
2359
|
+
return this.instance_;
|
|
2360
|
+
};
|
|
2361
|
+
/**
|
|
2362
|
+
* Holds reference to the controller's instance.
|
|
2363
|
+
*
|
|
2364
|
+
* @private {ResizeObserverController}
|
|
2365
|
+
*/
|
|
2366
|
+
ResizeObserverController.instance_ = null;
|
|
2367
|
+
return ResizeObserverController;
|
|
2368
|
+
}());
|
|
2369
|
+
|
|
2370
|
+
/**
|
|
2371
|
+
* Defines non-writable/enumerable properties of the provided target object.
|
|
2372
|
+
*
|
|
2373
|
+
* @param {Object} target - Object for which to define properties.
|
|
2374
|
+
* @param {Object} props - Properties to be defined.
|
|
2375
|
+
* @returns {Object} Target object.
|
|
2376
|
+
*/
|
|
2377
|
+
var defineConfigurable = (function (target, props) {
|
|
2378
|
+
for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
|
|
2379
|
+
var key = _a[_i];
|
|
2380
|
+
Object.defineProperty(target, key, {
|
|
2381
|
+
value: props[key],
|
|
2382
|
+
enumerable: false,
|
|
2383
|
+
writable: false,
|
|
2384
|
+
configurable: true
|
|
2385
|
+
});
|
|
2386
|
+
}
|
|
2387
|
+
return target;
|
|
2388
|
+
});
|
|
2389
|
+
|
|
2390
|
+
/**
|
|
2391
|
+
* Returns the global object associated with provided element.
|
|
2392
|
+
*
|
|
2393
|
+
* @param {Object} target
|
|
2394
|
+
* @returns {Object}
|
|
2395
|
+
*/
|
|
2396
|
+
var getWindowOf = (function (target) {
|
|
2397
|
+
// Assume that the element is an instance of Node, which means that it
|
|
2398
|
+
// has the "ownerDocument" property from which we can retrieve a
|
|
2399
|
+
// corresponding global object.
|
|
2400
|
+
var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
|
|
2401
|
+
// Return the local global object if it's not possible extract one from
|
|
2402
|
+
// provided element.
|
|
2403
|
+
return ownerGlobal || global$1;
|
|
2404
|
+
});
|
|
2405
|
+
|
|
2406
|
+
// Placeholder of an empty content rectangle.
|
|
2407
|
+
var emptyRect = createRectInit(0, 0, 0, 0);
|
|
2408
|
+
/**
|
|
2409
|
+
* Converts provided string to a number.
|
|
2410
|
+
*
|
|
2411
|
+
* @param {number|string} value
|
|
2412
|
+
* @returns {number}
|
|
2413
|
+
*/
|
|
2414
|
+
function toFloat(value) {
|
|
2415
|
+
return parseFloat(value) || 0;
|
|
2416
|
+
}
|
|
2417
|
+
/**
|
|
2418
|
+
* Extracts borders size from provided styles.
|
|
2419
|
+
*
|
|
2420
|
+
* @param {CSSStyleDeclaration} styles
|
|
2421
|
+
* @param {...string} positions - Borders positions (top, right, ...)
|
|
2422
|
+
* @returns {number}
|
|
2423
|
+
*/
|
|
2424
|
+
function getBordersSize(styles) {
|
|
2425
|
+
var positions = [];
|
|
2426
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2427
|
+
positions[_i - 1] = arguments[_i];
|
|
2428
|
+
}
|
|
2429
|
+
return positions.reduce(function (size, position) {
|
|
2430
|
+
var value = styles['border-' + position + '-width'];
|
|
2431
|
+
return size + toFloat(value);
|
|
2432
|
+
}, 0);
|
|
2433
|
+
}
|
|
2434
|
+
/**
|
|
2435
|
+
* Extracts paddings sizes from provided styles.
|
|
2436
|
+
*
|
|
2437
|
+
* @param {CSSStyleDeclaration} styles
|
|
2438
|
+
* @returns {Object} Paddings box.
|
|
2439
|
+
*/
|
|
2440
|
+
function getPaddings(styles) {
|
|
2441
|
+
var positions = ['top', 'right', 'bottom', 'left'];
|
|
2442
|
+
var paddings = {};
|
|
2443
|
+
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
2444
|
+
var position = positions_1[_i];
|
|
2445
|
+
var value = styles['padding-' + position];
|
|
2446
|
+
paddings[position] = toFloat(value);
|
|
2447
|
+
}
|
|
2448
|
+
return paddings;
|
|
2449
|
+
}
|
|
2450
|
+
/**
|
|
2451
|
+
* Calculates content rectangle of provided SVG element.
|
|
2452
|
+
*
|
|
2453
|
+
* @param {SVGGraphicsElement} target - Element content rectangle of which needs
|
|
2454
|
+
* to be calculated.
|
|
2455
|
+
* @returns {DOMRectInit}
|
|
2456
|
+
*/
|
|
2457
|
+
function getSVGContentRect(target) {
|
|
2458
|
+
var bbox = target.getBBox();
|
|
2459
|
+
return createRectInit(0, 0, bbox.width, bbox.height);
|
|
2460
|
+
}
|
|
2461
|
+
/**
|
|
2462
|
+
* Calculates content rectangle of provided HTMLElement.
|
|
2463
|
+
*
|
|
2464
|
+
* @param {HTMLElement} target - Element for which to calculate the content rectangle.
|
|
2465
|
+
* @returns {DOMRectInit}
|
|
2466
|
+
*/
|
|
2467
|
+
function getHTMLElementContentRect(target) {
|
|
2468
|
+
// Client width & height properties can't be
|
|
2469
|
+
// used exclusively as they provide rounded values.
|
|
2470
|
+
var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
|
|
2471
|
+
// By this condition we can catch all non-replaced inline, hidden and
|
|
2472
|
+
// detached elements. Though elements with width & height properties less
|
|
2473
|
+
// than 0.5 will be discarded as well.
|
|
2474
|
+
//
|
|
2475
|
+
// Without it we would need to implement separate methods for each of
|
|
2476
|
+
// those cases and it's not possible to perform a precise and performance
|
|
2477
|
+
// effective test for hidden elements. E.g. even jQuery's ':visible' filter
|
|
2478
|
+
// gives wrong results for elements with width & height less than 0.5.
|
|
2479
|
+
if (!clientWidth && !clientHeight) {
|
|
2480
|
+
return emptyRect;
|
|
2481
|
+
}
|
|
2482
|
+
var styles = getWindowOf(target).getComputedStyle(target);
|
|
2483
|
+
var paddings = getPaddings(styles);
|
|
2484
|
+
var horizPad = paddings.left + paddings.right;
|
|
2485
|
+
var vertPad = paddings.top + paddings.bottom;
|
|
2486
|
+
// Computed styles of width & height are being used because they are the
|
|
2487
|
+
// only dimensions available to JS that contain non-rounded values. It could
|
|
2488
|
+
// be possible to utilize the getBoundingClientRect if only it's data wasn't
|
|
2489
|
+
// affected by CSS transformations let alone paddings, borders and scroll bars.
|
|
2490
|
+
var width = toFloat(styles.width), height = toFloat(styles.height);
|
|
2491
|
+
// Width & height include paddings and borders when the 'border-box' box
|
|
2492
|
+
// model is applied (except for IE).
|
|
2493
|
+
if (styles.boxSizing === 'border-box') {
|
|
2494
|
+
// Following conditions are required to handle Internet Explorer which
|
|
2495
|
+
// doesn't include paddings and borders to computed CSS dimensions.
|
|
2496
|
+
//
|
|
2497
|
+
// We can say that if CSS dimensions + paddings are equal to the "client"
|
|
2498
|
+
// properties then it's either IE, and thus we don't need to subtract
|
|
2499
|
+
// anything, or an element merely doesn't have paddings/borders styles.
|
|
2500
|
+
if (Math.round(width + horizPad) !== clientWidth) {
|
|
2501
|
+
width -= getBordersSize(styles, 'left', 'right') + horizPad;
|
|
2502
|
+
}
|
|
2503
|
+
if (Math.round(height + vertPad) !== clientHeight) {
|
|
2504
|
+
height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
// Following steps can't be applied to the document's root element as its
|
|
2508
|
+
// client[Width/Height] properties represent viewport area of the window.
|
|
2509
|
+
// Besides, it's as well not necessary as the <html> itself neither has
|
|
2510
|
+
// rendered scroll bars nor it can be clipped.
|
|
2511
|
+
if (!isDocumentElement(target)) {
|
|
2512
|
+
// In some browsers (only in Firefox, actually) CSS width & height
|
|
2513
|
+
// include scroll bars size which can be removed at this step as scroll
|
|
2514
|
+
// bars are the only difference between rounded dimensions + paddings
|
|
2515
|
+
// and "client" properties, though that is not always true in Chrome.
|
|
2516
|
+
var vertScrollbar = Math.round(width + horizPad) - clientWidth;
|
|
2517
|
+
var horizScrollbar = Math.round(height + vertPad) - clientHeight;
|
|
2518
|
+
// Chrome has a rather weird rounding of "client" properties.
|
|
2519
|
+
// E.g. for an element with content width of 314.2px it sometimes gives
|
|
2520
|
+
// the client width of 315px and for the width of 314.7px it may give
|
|
2521
|
+
// 314px. And it doesn't happen all the time. So just ignore this delta
|
|
2522
|
+
// as a non-relevant.
|
|
2523
|
+
if (Math.abs(vertScrollbar) !== 1) {
|
|
2524
|
+
width -= vertScrollbar;
|
|
2525
|
+
}
|
|
2526
|
+
if (Math.abs(horizScrollbar) !== 1) {
|
|
2527
|
+
height -= horizScrollbar;
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
return createRectInit(paddings.left, paddings.top, width, height);
|
|
2531
|
+
}
|
|
2532
|
+
/**
|
|
2533
|
+
* Checks whether provided element is an instance of the SVGGraphicsElement.
|
|
2534
|
+
*
|
|
2535
|
+
* @param {Element} target - Element to be checked.
|
|
2536
|
+
* @returns {boolean}
|
|
2537
|
+
*/
|
|
2538
|
+
var isSVGGraphicsElement = (function () {
|
|
2539
|
+
// Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
|
|
2540
|
+
// interface.
|
|
2541
|
+
if (typeof SVGGraphicsElement !== 'undefined') {
|
|
2542
|
+
return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
|
|
2543
|
+
}
|
|
2544
|
+
// If it's so, then check that element is at least an instance of the
|
|
2545
|
+
// SVGElement and that it has the "getBBox" method.
|
|
2546
|
+
// eslint-disable-next-line no-extra-parens
|
|
2547
|
+
return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
|
|
2548
|
+
typeof target.getBBox === 'function'); };
|
|
2549
|
+
})();
|
|
2550
|
+
/**
|
|
2551
|
+
* Checks whether provided element is a document element (<html>).
|
|
2552
|
+
*
|
|
2553
|
+
* @param {Element} target - Element to be checked.
|
|
2554
|
+
* @returns {boolean}
|
|
2555
|
+
*/
|
|
2556
|
+
function isDocumentElement(target) {
|
|
2557
|
+
return target === getWindowOf(target).document.documentElement;
|
|
2558
|
+
}
|
|
2559
|
+
/**
|
|
2560
|
+
* Calculates an appropriate content rectangle for provided html or svg element.
|
|
2561
|
+
*
|
|
2562
|
+
* @param {Element} target - Element content rectangle of which needs to be calculated.
|
|
2563
|
+
* @returns {DOMRectInit}
|
|
2564
|
+
*/
|
|
2565
|
+
function getContentRect(target) {
|
|
2566
|
+
if (!isBrowser) {
|
|
2567
|
+
return emptyRect;
|
|
2568
|
+
}
|
|
2569
|
+
if (isSVGGraphicsElement(target)) {
|
|
2570
|
+
return getSVGContentRect(target);
|
|
2571
|
+
}
|
|
2572
|
+
return getHTMLElementContentRect(target);
|
|
2573
|
+
}
|
|
2574
|
+
/**
|
|
2575
|
+
* Creates rectangle with an interface of the DOMRectReadOnly.
|
|
2576
|
+
* Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
|
|
2577
|
+
*
|
|
2578
|
+
* @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
|
|
2579
|
+
* @returns {DOMRectReadOnly}
|
|
2580
|
+
*/
|
|
2581
|
+
function createReadOnlyRect(_a) {
|
|
2582
|
+
var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
|
|
2583
|
+
// If DOMRectReadOnly is available use it as a prototype for the rectangle.
|
|
2584
|
+
var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
|
|
2585
|
+
var rect = Object.create(Constr.prototype);
|
|
2586
|
+
// Rectangle's properties are not writable and non-enumerable.
|
|
2587
|
+
defineConfigurable(rect, {
|
|
2588
|
+
x: x, y: y, width: width, height: height,
|
|
2589
|
+
top: y,
|
|
2590
|
+
right: x + width,
|
|
2591
|
+
bottom: height + y,
|
|
2592
|
+
left: x
|
|
2593
|
+
});
|
|
2594
|
+
return rect;
|
|
2595
|
+
}
|
|
2596
|
+
/**
|
|
2597
|
+
* Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
|
|
2598
|
+
* Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
|
|
2599
|
+
*
|
|
2600
|
+
* @param {number} x - X coordinate.
|
|
2601
|
+
* @param {number} y - Y coordinate.
|
|
2602
|
+
* @param {number} width - Rectangle's width.
|
|
2603
|
+
* @param {number} height - Rectangle's height.
|
|
2604
|
+
* @returns {DOMRectInit}
|
|
2605
|
+
*/
|
|
2606
|
+
function createRectInit(x, y, width, height) {
|
|
2607
|
+
return { x: x, y: y, width: width, height: height };
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2610
|
+
/**
|
|
2611
|
+
* Class that is responsible for computations of the content rectangle of
|
|
2612
|
+
* provided DOM element and for keeping track of it's changes.
|
|
2613
|
+
*/
|
|
2614
|
+
var ResizeObservation = /** @class */ (function () {
|
|
2615
|
+
/**
|
|
2616
|
+
* Creates an instance of ResizeObservation.
|
|
2617
|
+
*
|
|
2618
|
+
* @param {Element} target - Element to be observed.
|
|
2619
|
+
*/
|
|
2620
|
+
function ResizeObservation(target) {
|
|
2621
|
+
/**
|
|
2622
|
+
* Broadcasted width of content rectangle.
|
|
2623
|
+
*
|
|
2624
|
+
* @type {number}
|
|
2625
|
+
*/
|
|
2626
|
+
this.broadcastWidth = 0;
|
|
2627
|
+
/**
|
|
2628
|
+
* Broadcasted height of content rectangle.
|
|
2629
|
+
*
|
|
2630
|
+
* @type {number}
|
|
2631
|
+
*/
|
|
2632
|
+
this.broadcastHeight = 0;
|
|
2633
|
+
/**
|
|
2634
|
+
* Reference to the last observed content rectangle.
|
|
2635
|
+
*
|
|
2636
|
+
* @private {DOMRectInit}
|
|
2637
|
+
*/
|
|
2638
|
+
this.contentRect_ = createRectInit(0, 0, 0, 0);
|
|
2639
|
+
this.target = target;
|
|
2640
|
+
}
|
|
2641
|
+
/**
|
|
2642
|
+
* Updates content rectangle and tells whether it's width or height properties
|
|
2643
|
+
* have changed since the last broadcast.
|
|
2644
|
+
*
|
|
2645
|
+
* @returns {boolean}
|
|
2646
|
+
*/
|
|
2647
|
+
ResizeObservation.prototype.isActive = function () {
|
|
2648
|
+
var rect = getContentRect(this.target);
|
|
2649
|
+
this.contentRect_ = rect;
|
|
2650
|
+
return (rect.width !== this.broadcastWidth ||
|
|
2651
|
+
rect.height !== this.broadcastHeight);
|
|
2652
|
+
};
|
|
2653
|
+
/**
|
|
2654
|
+
* Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
|
|
2655
|
+
* from the corresponding properties of the last observed content rectangle.
|
|
2656
|
+
*
|
|
2657
|
+
* @returns {DOMRectInit} Last observed content rectangle.
|
|
2658
|
+
*/
|
|
2659
|
+
ResizeObservation.prototype.broadcastRect = function () {
|
|
2660
|
+
var rect = this.contentRect_;
|
|
2661
|
+
this.broadcastWidth = rect.width;
|
|
2662
|
+
this.broadcastHeight = rect.height;
|
|
2663
|
+
return rect;
|
|
2664
|
+
};
|
|
2665
|
+
return ResizeObservation;
|
|
2666
|
+
}());
|
|
2667
|
+
|
|
2668
|
+
var ResizeObserverEntry = /** @class */ (function () {
|
|
2669
|
+
/**
|
|
2670
|
+
* Creates an instance of ResizeObserverEntry.
|
|
2671
|
+
*
|
|
2672
|
+
* @param {Element} target - Element that is being observed.
|
|
2673
|
+
* @param {DOMRectInit} rectInit - Data of the element's content rectangle.
|
|
2674
|
+
*/
|
|
2675
|
+
function ResizeObserverEntry(target, rectInit) {
|
|
2676
|
+
var contentRect = createReadOnlyRect(rectInit);
|
|
2677
|
+
// According to the specification following properties are not writable
|
|
2678
|
+
// and are also not enumerable in the native implementation.
|
|
2679
|
+
//
|
|
2680
|
+
// Property accessors are not being used as they'd require to define a
|
|
2681
|
+
// private WeakMap storage which may cause memory leaks in browsers that
|
|
2682
|
+
// don't support this type of collections.
|
|
2683
|
+
defineConfigurable(this, { target: target, contentRect: contentRect });
|
|
2684
|
+
}
|
|
2685
|
+
return ResizeObserverEntry;
|
|
2686
|
+
}());
|
|
2687
|
+
|
|
2688
|
+
var ResizeObserverSPI = /** @class */ (function () {
|
|
2689
|
+
/**
|
|
2690
|
+
* Creates a new instance of ResizeObserver.
|
|
2691
|
+
*
|
|
2692
|
+
* @param {ResizeObserverCallback} callback - Callback function that is invoked
|
|
2693
|
+
* when one of the observed elements changes it's content dimensions.
|
|
2694
|
+
* @param {ResizeObserverController} controller - Controller instance which
|
|
2695
|
+
* is responsible for the updates of observer.
|
|
2696
|
+
* @param {ResizeObserver} callbackCtx - Reference to the public
|
|
2697
|
+
* ResizeObserver instance which will be passed to callback function.
|
|
2698
|
+
*/
|
|
2699
|
+
function ResizeObserverSPI(callback, controller, callbackCtx) {
|
|
2700
|
+
/**
|
|
2701
|
+
* Collection of resize observations that have detected changes in dimensions
|
|
2702
|
+
* of elements.
|
|
2703
|
+
*
|
|
2704
|
+
* @private {Array<ResizeObservation>}
|
|
2705
|
+
*/
|
|
2706
|
+
this.activeObservations_ = [];
|
|
2707
|
+
/**
|
|
2708
|
+
* Registry of the ResizeObservation instances.
|
|
2709
|
+
*
|
|
2710
|
+
* @private {Map<Element, ResizeObservation>}
|
|
2711
|
+
*/
|
|
2712
|
+
this.observations_ = new MapShim();
|
|
2713
|
+
if (typeof callback !== 'function') {
|
|
2714
|
+
throw new TypeError('The callback provided as parameter 1 is not a function.');
|
|
2715
|
+
}
|
|
2716
|
+
this.callback_ = callback;
|
|
2717
|
+
this.controller_ = controller;
|
|
2718
|
+
this.callbackCtx_ = callbackCtx;
|
|
2719
|
+
}
|
|
2720
|
+
/**
|
|
2721
|
+
* Starts observing provided element.
|
|
2722
|
+
*
|
|
2723
|
+
* @param {Element} target - Element to be observed.
|
|
2724
|
+
* @returns {void}
|
|
2725
|
+
*/
|
|
2726
|
+
ResizeObserverSPI.prototype.observe = function (target) {
|
|
2727
|
+
if (!arguments.length) {
|
|
2728
|
+
throw new TypeError('1 argument required, but only 0 present.');
|
|
2729
|
+
}
|
|
2730
|
+
// Do nothing if current environment doesn't have the Element interface.
|
|
2731
|
+
if (typeof Element === 'undefined' || !(Element instanceof Object)) {
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2734
|
+
if (!(target instanceof getWindowOf(target).Element)) {
|
|
2735
|
+
throw new TypeError('parameter 1 is not of type "Element".');
|
|
2736
|
+
}
|
|
2737
|
+
var observations = this.observations_;
|
|
2738
|
+
// Do nothing if element is already being observed.
|
|
2739
|
+
if (observations.has(target)) {
|
|
2740
|
+
return;
|
|
2741
|
+
}
|
|
2742
|
+
observations.set(target, new ResizeObservation(target));
|
|
2743
|
+
this.controller_.addObserver(this);
|
|
2744
|
+
// Force the update of observations.
|
|
2745
|
+
this.controller_.refresh();
|
|
2746
|
+
};
|
|
2747
|
+
/**
|
|
2748
|
+
* Stops observing provided element.
|
|
2749
|
+
*
|
|
2750
|
+
* @param {Element} target - Element to stop observing.
|
|
2751
|
+
* @returns {void}
|
|
2752
|
+
*/
|
|
2753
|
+
ResizeObserverSPI.prototype.unobserve = function (target) {
|
|
2754
|
+
if (!arguments.length) {
|
|
2755
|
+
throw new TypeError('1 argument required, but only 0 present.');
|
|
2756
|
+
}
|
|
2757
|
+
// Do nothing if current environment doesn't have the Element interface.
|
|
2758
|
+
if (typeof Element === 'undefined' || !(Element instanceof Object)) {
|
|
2759
|
+
return;
|
|
2760
|
+
}
|
|
2761
|
+
if (!(target instanceof getWindowOf(target).Element)) {
|
|
2762
|
+
throw new TypeError('parameter 1 is not of type "Element".');
|
|
2763
|
+
}
|
|
2764
|
+
var observations = this.observations_;
|
|
2765
|
+
// Do nothing if element is not being observed.
|
|
2766
|
+
if (!observations.has(target)) {
|
|
2767
|
+
return;
|
|
2768
|
+
}
|
|
2769
|
+
observations.delete(target);
|
|
2770
|
+
if (!observations.size) {
|
|
2771
|
+
this.controller_.removeObserver(this);
|
|
2772
|
+
}
|
|
2773
|
+
};
|
|
2774
|
+
/**
|
|
2775
|
+
* Stops observing all elements.
|
|
2776
|
+
*
|
|
2777
|
+
* @returns {void}
|
|
2778
|
+
*/
|
|
2779
|
+
ResizeObserverSPI.prototype.disconnect = function () {
|
|
2780
|
+
this.clearActive();
|
|
2781
|
+
this.observations_.clear();
|
|
2782
|
+
this.controller_.removeObserver(this);
|
|
2783
|
+
};
|
|
2784
|
+
/**
|
|
2785
|
+
* Collects observation instances the associated element of which has changed
|
|
2786
|
+
* it's content rectangle.
|
|
2787
|
+
*
|
|
2788
|
+
* @returns {void}
|
|
2789
|
+
*/
|
|
2790
|
+
ResizeObserverSPI.prototype.gatherActive = function () {
|
|
2791
|
+
var _this = this;
|
|
2792
|
+
this.clearActive();
|
|
2793
|
+
this.observations_.forEach(function (observation) {
|
|
2794
|
+
if (observation.isActive()) {
|
|
2795
|
+
_this.activeObservations_.push(observation);
|
|
2796
|
+
}
|
|
2797
|
+
});
|
|
2798
|
+
};
|
|
2799
|
+
/**
|
|
2800
|
+
* Invokes initial callback function with a list of ResizeObserverEntry
|
|
2801
|
+
* instances collected from active resize observations.
|
|
2802
|
+
*
|
|
2803
|
+
* @returns {void}
|
|
2804
|
+
*/
|
|
2805
|
+
ResizeObserverSPI.prototype.broadcastActive = function () {
|
|
2806
|
+
// Do nothing if observer doesn't have active observations.
|
|
2807
|
+
if (!this.hasActive()) {
|
|
2808
|
+
return;
|
|
2809
|
+
}
|
|
2810
|
+
var ctx = this.callbackCtx_;
|
|
2811
|
+
// Create ResizeObserverEntry instance for every active observation.
|
|
2812
|
+
var entries = this.activeObservations_.map(function (observation) {
|
|
2813
|
+
return new ResizeObserverEntry(observation.target, observation.broadcastRect());
|
|
2814
|
+
});
|
|
2815
|
+
this.callback_.call(ctx, entries, ctx);
|
|
2816
|
+
this.clearActive();
|
|
2817
|
+
};
|
|
2818
|
+
/**
|
|
2819
|
+
* Clears the collection of active observations.
|
|
2820
|
+
*
|
|
2821
|
+
* @returns {void}
|
|
2822
|
+
*/
|
|
2823
|
+
ResizeObserverSPI.prototype.clearActive = function () {
|
|
2824
|
+
this.activeObservations_.splice(0);
|
|
2825
|
+
};
|
|
2826
|
+
/**
|
|
2827
|
+
* Tells whether observer has active observations.
|
|
2828
|
+
*
|
|
2829
|
+
* @returns {boolean}
|
|
2830
|
+
*/
|
|
2831
|
+
ResizeObserverSPI.prototype.hasActive = function () {
|
|
2832
|
+
return this.activeObservations_.length > 0;
|
|
2833
|
+
};
|
|
2834
|
+
return ResizeObserverSPI;
|
|
2835
|
+
}());
|
|
2836
|
+
|
|
2837
|
+
// Registry of internal observers. If WeakMap is not available use current shim
|
|
2838
|
+
// for the Map collection as it has all required methods and because WeakMap
|
|
2839
|
+
// can't be fully polyfilled anyway.
|
|
2840
|
+
var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
|
|
2841
|
+
/**
|
|
2842
|
+
* ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
|
|
2843
|
+
* exposing only those methods and properties that are defined in the spec.
|
|
2844
|
+
*/
|
|
2845
|
+
var ResizeObserver = /** @class */ (function () {
|
|
2846
|
+
/**
|
|
2847
|
+
* Creates a new instance of ResizeObserver.
|
|
2848
|
+
*
|
|
2849
|
+
* @param {ResizeObserverCallback} callback - Callback that is invoked when
|
|
2850
|
+
* dimensions of the observed elements change.
|
|
2851
|
+
*/
|
|
2852
|
+
function ResizeObserver(callback) {
|
|
2853
|
+
if (!(this instanceof ResizeObserver)) {
|
|
2854
|
+
throw new TypeError('Cannot call a class as a function.');
|
|
2855
|
+
}
|
|
2856
|
+
if (!arguments.length) {
|
|
2857
|
+
throw new TypeError('1 argument required, but only 0 present.');
|
|
2858
|
+
}
|
|
2859
|
+
var controller = ResizeObserverController.getInstance();
|
|
2860
|
+
var observer = new ResizeObserverSPI(callback, controller, this);
|
|
2861
|
+
observers.set(this, observer);
|
|
2862
|
+
}
|
|
2863
|
+
return ResizeObserver;
|
|
2864
|
+
}());
|
|
2865
|
+
// Expose public methods of ResizeObserver.
|
|
2866
|
+
[
|
|
2867
|
+
'observe',
|
|
2868
|
+
'unobserve',
|
|
2869
|
+
'disconnect'
|
|
2870
|
+
].forEach(function (method) {
|
|
2871
|
+
ResizeObserver.prototype[method] = function () {
|
|
2872
|
+
var _a;
|
|
2873
|
+
return (_a = observers.get(this))[method].apply(_a, arguments);
|
|
2874
|
+
};
|
|
2875
|
+
});
|
|
2876
|
+
|
|
2877
|
+
var index = (function () {
|
|
2878
|
+
// Export existing implementation if available.
|
|
2879
|
+
if (typeof global$1.ResizeObserver !== 'undefined') {
|
|
2880
|
+
return global$1.ResizeObserver;
|
|
2881
|
+
}
|
|
2882
|
+
return ResizeObserver;
|
|
2883
|
+
})();
|
|
2884
|
+
|
|
2885
|
+
/* harmony default export */ __webpack_exports__["default"] = (index);
|
|
2886
|
+
|
|
2887
|
+
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
|
|
2888
|
+
|
|
1947
2889
|
/***/ }),
|
|
1948
2890
|
|
|
1949
2891
|
/***/ "./node_modules/setimmediate/setImmediate.js":
|
|
@@ -3157,7 +4099,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
3157
4099
|
return t;
|
|
3158
4100
|
};
|
|
3159
4101
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3160
|
-
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.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.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;
|
|
3161
4103
|
var client_1 = __webpack_require__(/*! ./client */ "./src/interactive-api-client/client.ts");
|
|
3162
4104
|
var uuid_1 = __webpack_require__(/*! uuid */ "./node_modules/uuid/dist/esm-browser/index.js");
|
|
3163
4105
|
var THROW_NOT_IMPLEMENTED_YET = function (method) {
|
|
@@ -3299,6 +4241,14 @@ var removeDecorateContentListener = function () {
|
|
|
3299
4241
|
(0, client_1.getClient)().removeDecorateContentListener();
|
|
3300
4242
|
};
|
|
3301
4243
|
exports.removeDecorateContentListener = removeDecorateContentListener;
|
|
4244
|
+
var addGetReportItemAnswerListener = function (callback) {
|
|
4245
|
+
(0, client_1.getClient)().addGetReportItemAnswerListener(callback);
|
|
4246
|
+
};
|
|
4247
|
+
exports.addGetReportItemAnswerListener = addGetReportItemAnswerListener;
|
|
4248
|
+
var removeGetReportItemAnswerListener = function () {
|
|
4249
|
+
(0, client_1.getClient)().removeGetReportItemAnswerListener();
|
|
4250
|
+
};
|
|
4251
|
+
exports.removeGetReportItemAnswerListener = removeGetReportItemAnswerListener;
|
|
3302
4252
|
var setSupportedFeatures = function (features) {
|
|
3303
4253
|
var request = {
|
|
3304
4254
|
apiVersion: 1,
|
|
@@ -3609,6 +4559,10 @@ var getAttachmentUrl = function (params) {
|
|
|
3609
4559
|
});
|
|
3610
4560
|
};
|
|
3611
4561
|
exports.getAttachmentUrl = getAttachmentUrl;
|
|
4562
|
+
var sendReportItemAnswer = function (request) {
|
|
4563
|
+
(0, client_1.getClient)().post("reportItemAnswer", request);
|
|
4564
|
+
};
|
|
4565
|
+
exports.sendReportItemAnswer = sendReportItemAnswer;
|
|
3612
4566
|
|
|
3613
4567
|
|
|
3614
4568
|
/***/ }),
|
|
@@ -3801,6 +4755,12 @@ var Client = /** @class */ (function () {
|
|
|
3801
4755
|
Client.prototype.removeDecorateContentListener = function () {
|
|
3802
4756
|
return this.removeListener("decorateContent");
|
|
3803
4757
|
};
|
|
4758
|
+
Client.prototype.addGetReportItemAnswerListener = function (callback) {
|
|
4759
|
+
this.addListener("getReportItemAnswer", callback);
|
|
4760
|
+
};
|
|
4761
|
+
Client.prototype.removeGetReportItemAnswerListener = function () {
|
|
4762
|
+
return this.removeListener("getReportItemAnswer");
|
|
4763
|
+
};
|
|
3804
4764
|
Client.prototype.connect = function () {
|
|
3805
4765
|
var _this = this;
|
|
3806
4766
|
this.phone = iframePhone.getIFrameEndpoint();
|
|
@@ -3808,7 +4768,12 @@ var Client = /** @class */ (function () {
|
|
|
3808
4768
|
_this.managedState.initMessage = newInitMessage;
|
|
3809
4769
|
// parseJSONIfString is used below quite a few times, as LARA and report are not consistent about format.
|
|
3810
4770
|
// Sometimes they send string (report page), sometimes already parsed JSON (authoring, runtime).
|
|
3811
|
-
|
|
4771
|
+
if (newInitMessage.mode === "reportItem") {
|
|
4772
|
+
_this.managedState.authoredState = {};
|
|
4773
|
+
}
|
|
4774
|
+
else {
|
|
4775
|
+
_this.managedState.authoredState = parseJSONIfString(newInitMessage.authoredState);
|
|
4776
|
+
}
|
|
3812
4777
|
if (newInitMessage.mode === "runtime" || newInitMessage.mode === "report") {
|
|
3813
4778
|
_this.managedState.interactiveState = parseJSONIfString(newInitMessage.interactiveState);
|
|
3814
4779
|
// Don't consider initial state to be dirty, as user would see warnings while trying to leave page even
|
|
@@ -3881,8 +4846,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
3881
4846
|
}
|
|
3882
4847
|
};
|
|
3883
4848
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3884
|
-
exports.useDecorateContent = exports.useCustomMessages = exports.useInitMessage = exports.useGlobalInteractiveState = exports.useAuthoredState = exports.useInteractiveState = void 0;
|
|
4849
|
+
exports.useSetSupportedFeatures = exports.useAutoSetHeight = exports.useDecorateContent = exports.useCustomMessages = exports.useInitMessage = exports.useGlobalInteractiveState = exports.useAuthoredState = exports.useInteractiveState = void 0;
|
|
3885
4850
|
var react_1 = __webpack_require__(/*! react */ "react");
|
|
4851
|
+
var resize_observer_polyfill_1 = __webpack_require__(/*! resize-observer-polyfill */ "./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js");
|
|
3886
4852
|
var client = __webpack_require__(/*! ./api */ "./src/interactive-api-client/api.ts");
|
|
3887
4853
|
var handleUpdate = function (newStateOrUpdateFunc, prevState) {
|
|
3888
4854
|
if (typeof newStateOrUpdateFunc === "function") {
|
|
@@ -4004,6 +4970,34 @@ var useDecorateContent = function (callback) {
|
|
|
4004
4970
|
}, []);
|
|
4005
4971
|
};
|
|
4006
4972
|
exports.useDecorateContent = useDecorateContent;
|
|
4973
|
+
var useAutoSetHeight = function () {
|
|
4974
|
+
var initMessage = (0, exports.useInitMessage)();
|
|
4975
|
+
(0, react_1.useEffect)(function () {
|
|
4976
|
+
if (initMessage) {
|
|
4977
|
+
var body_1 = document.body;
|
|
4978
|
+
var html_1 = document.documentElement;
|
|
4979
|
+
var updateHeight_1 = function () {
|
|
4980
|
+
var height = Math.max(body_1.scrollHeight, body_1.offsetHeight, html_1.clientHeight, html_1.scrollHeight, html_1.offsetHeight);
|
|
4981
|
+
client.setHeight(height);
|
|
4982
|
+
};
|
|
4983
|
+
var observer_1 = new resize_observer_polyfill_1.default(function () { return updateHeight_1(); });
|
|
4984
|
+
if (body_1) {
|
|
4985
|
+
observer_1.observe(body_1);
|
|
4986
|
+
}
|
|
4987
|
+
return function () { return observer_1.disconnect(); };
|
|
4988
|
+
}
|
|
4989
|
+
}, [initMessage]);
|
|
4990
|
+
};
|
|
4991
|
+
exports.useAutoSetHeight = useAutoSetHeight;
|
|
4992
|
+
var useSetSupportedFeatures = function (features) {
|
|
4993
|
+
var initMessage = (0, exports.useInitMessage)();
|
|
4994
|
+
(0, react_1.useEffect)(function () {
|
|
4995
|
+
if (initMessage) {
|
|
4996
|
+
client.setSupportedFeatures(features);
|
|
4997
|
+
}
|
|
4998
|
+
}, [initMessage]);
|
|
4999
|
+
};
|
|
5000
|
+
exports.useSetSupportedFeatures = useSetSupportedFeatures;
|
|
4007
5001
|
|
|
4008
5002
|
|
|
4009
5003
|
/***/ }),
|
|
@@ -4058,6 +5052,7 @@ __exportStar(__webpack_require__(/*! ./metadata-types */ "./src/interactive-api-
|
|
|
4058
5052
|
__exportStar(__webpack_require__(/*! ./in-frame */ "./src/interactive-api-client/in-frame.ts"), exports);
|
|
4059
5053
|
__exportStar(__webpack_require__(/*! ./api */ "./src/interactive-api-client/api.ts"), exports);
|
|
4060
5054
|
__exportStar(__webpack_require__(/*! ./hooks */ "./src/interactive-api-client/hooks.ts"), exports);
|
|
5055
|
+
__exportStar(__webpack_require__(/*! ./client */ "./src/interactive-api-client/client.ts"), exports);
|
|
4061
5056
|
|
|
4062
5057
|
|
|
4063
5058
|
/***/ }),
|