@thoughtspot/visual-embed-sdk 1.51.2 → 1.52.1
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/cjs/package.json +9 -1
- package/cjs/src/api-intercept.d.ts.map +1 -1
- package/cjs/src/api-intercept.js +1 -0
- package/cjs/src/api-intercept.js.map +1 -1
- package/cjs/src/contracts/contracts.spec.d.ts +2 -0
- package/cjs/src/contracts/contracts.spec.d.ts.map +1 -0
- package/cjs/src/contracts/contracts.spec.js +345 -0
- package/cjs/src/contracts/contracts.spec.js.map +1 -0
- package/cjs/src/contracts/embed-event-payloads.d.ts +73 -0
- package/cjs/src/contracts/embed-event-payloads.d.ts.map +1 -0
- package/cjs/src/contracts/embed-event-payloads.js +3 -0
- package/cjs/src/contracts/embed-event-payloads.js.map +1 -0
- package/cjs/src/contracts/host-event-contracts.d.ts +378 -0
- package/cjs/src/contracts/host-event-contracts.d.ts.map +1 -0
- package/cjs/src/contracts/host-event-contracts.js +3 -0
- package/cjs/src/contracts/host-event-contracts.js.map +1 -0
- package/cjs/src/contracts/index.d.ts +22 -0
- package/cjs/src/contracts/index.d.ts.map +1 -0
- package/cjs/src/contracts/index.js +33 -0
- package/cjs/src/contracts/index.js.map +1 -0
- package/cjs/src/contracts/ui-passthrough-contracts.d.ts +277 -0
- package/cjs/src/contracts/ui-passthrough-contracts.d.ts.map +1 -0
- package/cjs/src/{embed/hostEventClient/contracts.js → contracts/ui-passthrough-contracts.js} +6 -2
- package/cjs/src/contracts/ui-passthrough-contracts.js.map +1 -0
- package/cjs/src/css-variables.d.ts +1 -1
- package/cjs/src/embed/app.d.ts +17 -140
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +20 -120
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +70 -26
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/conversation.d.ts +5 -5
- package/cjs/src/embed/events.spec.js +12 -2
- package/cjs/src/embed/events.spec.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts +3 -2
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.js +23 -18
- package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js +36 -36
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/cjs/src/embed/hostEventClient/utils.d.ts +1 -1
- package/cjs/src/embed/hostEventClient/utils.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/utils.js +3 -3
- package/cjs/src/embed/hostEventClient/utils.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +9 -161
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +68 -135
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +215 -32
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/search.d.ts +14 -0
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +4 -1
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/search.spec.js +65 -0
- package/cjs/src/embed/search.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +21 -25
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +105 -72
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +380 -33
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/full-height.d.ts +137 -0
- package/cjs/src/full-height.d.ts.map +1 -0
- package/cjs/src/full-height.js +272 -0
- package/cjs/src/full-height.js.map +1 -0
- package/cjs/src/full-height.spec.d.ts +2 -0
- package/cjs/src/full-height.spec.d.ts.map +1 -0
- package/cjs/src/full-height.spec.js +835 -0
- package/cjs/src/full-height.spec.js.map +1 -0
- package/cjs/src/index.d.ts +4 -3
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +5 -4
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/react/all-types-export.d.ts +1 -1
- package/cjs/src/react/all-types-export.d.ts.map +1 -1
- package/cjs/src/react/all-types-export.js +2 -1
- package/cjs/src/react/all-types-export.js.map +1 -1
- package/cjs/src/react/all-types-export.parity.spec.js +55 -3
- package/cjs/src/react/all-types-export.parity.spec.js.map +1 -1
- package/cjs/src/react/index.d.ts +8 -8
- package/cjs/src/react/index.d.ts.map +1 -1
- package/cjs/src/react/index.js +1 -1
- package/cjs/src/react/index.js.map +1 -1
- package/cjs/src/react/index.spec.js +7 -7
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/types.d.ts +664 -39
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +406 -13
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/processTrigger.d.ts +3 -1
- package/cjs/src/utils/processTrigger.d.ts.map +1 -1
- package/cjs/src/utils/processTrigger.js +19 -51
- package/cjs/src/utils/processTrigger.js.map +1 -1
- package/cjs/src/utils/transport/iframe-transport.d.ts +55 -0
- package/cjs/src/utils/transport/iframe-transport.d.ts.map +1 -0
- package/cjs/src/utils/transport/iframe-transport.js +108 -0
- package/cjs/src/utils/transport/iframe-transport.js.map +1 -0
- package/cjs/src/utils/transport/iframe-transport.spec.d.ts +2 -0
- package/cjs/src/utils/transport/iframe-transport.spec.d.ts.map +1 -0
- package/cjs/src/utils/transport/iframe-transport.spec.js +140 -0
- package/cjs/src/utils/transport/iframe-transport.spec.js.map +1 -0
- package/cjs/src/utils.d.ts +18 -0
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +39 -1
- package/cjs/src/utils.js.map +1 -1
- package/cjs/src/utils.spec.js +62 -0
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/{index-D8_Zs-Nr.js → index-C1pmYb5H.js} +1 -1
- package/dist/src/api-intercept.d.ts.map +1 -1
- package/dist/src/contracts/contracts.spec.d.ts +2 -0
- package/dist/src/contracts/contracts.spec.d.ts.map +1 -0
- package/dist/src/contracts/embed-event-payloads.d.ts +73 -0
- package/dist/src/contracts/embed-event-payloads.d.ts.map +1 -0
- package/dist/src/contracts/host-event-contracts.d.ts +378 -0
- package/dist/src/contracts/host-event-contracts.d.ts.map +1 -0
- package/dist/src/contracts/index.d.ts +22 -0
- package/dist/src/contracts/index.d.ts.map +1 -0
- package/dist/src/contracts/ui-passthrough-contracts.d.ts +277 -0
- package/dist/src/contracts/ui-passthrough-contracts.d.ts.map +1 -0
- package/dist/src/css-variables.d.ts +1 -1
- package/dist/src/embed/app.d.ts +17 -140
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/conversation.d.ts +5 -5
- package/dist/src/embed/hostEventClient/host-event-client.d.ts +3 -2
- package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/utils.d.ts +1 -1
- package/dist/src/embed/hostEventClient/utils.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +9 -161
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +14 -0
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +21 -25
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/dist/src/full-height.d.ts +137 -0
- package/dist/src/full-height.d.ts.map +1 -0
- package/dist/src/full-height.spec.d.ts +2 -0
- package/dist/src/full-height.spec.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/react/all-types-export.d.ts +1 -1
- package/dist/src/react/all-types-export.d.ts.map +1 -1
- package/dist/src/react/index.d.ts +8 -8
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +664 -39
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/processTrigger.d.ts +3 -1
- package/dist/src/utils/processTrigger.d.ts.map +1 -1
- package/dist/src/utils/transport/iframe-transport.d.ts +55 -0
- package/dist/src/utils/transport/iframe-transport.d.ts.map +1 -0
- package/dist/src/utils/transport/iframe-transport.spec.d.ts +2 -0
- package/dist/src/utils/transport/iframe-transport.spec.d.ts.map +1 -0
- package/dist/src/utils.d.ts +18 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +1031 -392
- package/dist/tsembed-react.js +1030 -391
- package/dist/tsembed.es.js +1031 -392
- package/dist/tsembed.js +1029 -390
- package/dist/visual-embed-sdk-react-full.d.ts +1483 -693
- package/dist/visual-embed-sdk-react.d.ts +1364 -647
- package/dist/visual-embed-sdk.d.ts +1426 -659
- package/lib/package.json +9 -1
- package/lib/src/api-intercept.d.ts.map +1 -1
- package/lib/src/api-intercept.js +2 -1
- package/lib/src/api-intercept.js.map +1 -1
- package/lib/src/contracts/contracts.spec.d.ts +2 -0
- package/lib/src/contracts/contracts.spec.d.ts.map +1 -0
- package/lib/src/contracts/contracts.spec.js +342 -0
- package/lib/src/contracts/contracts.spec.js.map +1 -0
- package/lib/src/contracts/embed-event-payloads.d.ts +73 -0
- package/lib/src/contracts/embed-event-payloads.d.ts.map +1 -0
- package/lib/src/contracts/embed-event-payloads.js +2 -0
- package/lib/src/contracts/embed-event-payloads.js.map +1 -0
- package/lib/src/contracts/host-event-contracts.d.ts +378 -0
- package/lib/src/contracts/host-event-contracts.d.ts.map +1 -0
- package/lib/src/contracts/host-event-contracts.js +2 -0
- package/lib/src/contracts/host-event-contracts.js.map +1 -0
- package/lib/src/contracts/index.d.ts +22 -0
- package/lib/src/contracts/index.d.ts.map +1 -0
- package/lib/src/contracts/index.js +22 -0
- package/lib/src/contracts/index.js.map +1 -0
- package/lib/src/contracts/ui-passthrough-contracts.d.ts +277 -0
- package/lib/src/contracts/ui-passthrough-contracts.d.ts.map +1 -0
- package/lib/src/{embed/hostEventClient/contracts.js → contracts/ui-passthrough-contracts.js} +6 -2
- package/lib/src/contracts/ui-passthrough-contracts.js.map +1 -0
- package/lib/src/css-variables.d.ts +1 -1
- package/lib/src/embed/app.d.ts +17 -140
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +22 -122
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +70 -26
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/conversation.d.ts +5 -5
- package/lib/src/embed/events.spec.js +12 -2
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.d.ts +3 -2
- package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.js +6 -1
- package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.spec.js +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/lib/src/embed/hostEventClient/utils.d.ts +1 -1
- package/lib/src/embed/hostEventClient/utils.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/utils.js +1 -1
- package/lib/src/embed/hostEventClient/utils.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +9 -161
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +70 -137
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +215 -32
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/search.d.ts +14 -0
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +4 -1
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/search.spec.js +65 -0
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +21 -25
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +106 -73
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +378 -31
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/full-height.d.ts +137 -0
- package/lib/src/full-height.d.ts.map +1 -0
- package/lib/src/full-height.js +268 -0
- package/lib/src/full-height.js.map +1 -0
- package/lib/src/full-height.spec.d.ts +2 -0
- package/lib/src/full-height.spec.d.ts.map +1 -0
- package/lib/src/full-height.spec.js +833 -0
- package/lib/src/full-height.spec.js.map +1 -0
- package/lib/src/index.d.ts +4 -3
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +3 -3
- package/lib/src/index.js.map +1 -1
- package/lib/src/react/all-types-export.d.ts +1 -1
- package/lib/src/react/all-types-export.d.ts.map +1 -1
- package/lib/src/react/all-types-export.js +1 -1
- package/lib/src/react/all-types-export.js.map +1 -1
- package/lib/src/react/all-types-export.parity.spec.js +55 -3
- package/lib/src/react/all-types-export.parity.spec.js.map +1 -1
- package/lib/src/react/index.d.ts +8 -8
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +1 -1
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +7 -7
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +664 -39
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +405 -12
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/processTrigger.d.ts +3 -1
- package/lib/src/utils/processTrigger.d.ts.map +1 -1
- package/lib/src/utils/processTrigger.js +19 -51
- package/lib/src/utils/processTrigger.js.map +1 -1
- package/lib/src/utils/transport/iframe-transport.d.ts +55 -0
- package/lib/src/utils/transport/iframe-transport.d.ts.map +1 -0
- package/lib/src/utils/transport/iframe-transport.js +101 -0
- package/lib/src/utils/transport/iframe-transport.js.map +1 -0
- package/lib/src/utils/transport/iframe-transport.spec.d.ts +2 -0
- package/lib/src/utils/transport/iframe-transport.spec.d.ts.map +1 -0
- package/lib/src/utils/transport/iframe-transport.spec.js +138 -0
- package/lib/src/utils/transport/iframe-transport.spec.js.map +1 -0
- package/lib/src/utils.d.ts +18 -0
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +37 -0
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +63 -1
- package/lib/src/utils.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +1426 -659
- package/package.json +9 -1
- package/src/api-intercept.ts +2 -1
- package/src/contracts/contracts.spec.ts +392 -0
- package/src/contracts/embed-event-payloads.ts +83 -0
- package/src/contracts/host-event-contracts.ts +456 -0
- package/src/contracts/index.ts +53 -0
- package/src/contracts/ui-passthrough-contracts.ts +301 -0
- package/src/css-variables.ts +1 -1
- package/src/embed/app.spec.ts +86 -34
- package/src/embed/app.ts +37 -264
- package/src/embed/conversation.ts +5 -5
- package/src/embed/events.spec.ts +14 -2
- package/src/embed/hostEventClient/host-event-client.spec.ts +2 -2
- package/src/embed/hostEventClient/host-event-client.ts +18 -5
- package/src/embed/hostEventClient/utils.ts +2 -1
- package/src/embed/liveboard.spec.ts +261 -42
- package/src/embed/liveboard.ts +78 -297
- package/src/embed/search.spec.ts +80 -0
- package/src/embed/search.ts +20 -0
- package/src/embed/ts-embed.spec.ts +518 -31
- package/src/embed/ts-embed.ts +133 -82
- package/src/full-height.spec.ts +1008 -0
- package/src/full-height.ts +361 -0
- package/src/index.ts +95 -5
- package/src/react/all-types-export.parity.spec.ts +63 -3
- package/src/react/all-types-export.ts +46 -0
- package/src/react/index.spec.tsx +7 -7
- package/src/react/index.tsx +9 -9
- package/src/types.ts +665 -37
- package/src/utils/processTrigger.ts +28 -58
- package/src/utils/transport/iframe-transport.spec.ts +177 -0
- package/src/utils/transport/iframe-transport.ts +122 -0
- package/src/utils.spec.ts +71 -0
- package/src/utils.ts +38 -0
- package/cjs/src/embed/hostEventClient/contracts.d.ts +0 -231
- package/cjs/src/embed/hostEventClient/contracts.d.ts.map +0 -1
- package/cjs/src/embed/hostEventClient/contracts.js.map +0 -1
- package/dist/src/embed/hostEventClient/contracts.d.ts +0 -231
- package/dist/src/embed/hostEventClient/contracts.d.ts.map +0 -1
- package/lib/src/embed/hostEventClient/contracts.d.ts +0 -231
- package/lib/src/embed/hostEventClient/contracts.d.ts.map +0 -1
- package/lib/src/embed/hostEventClient/contracts.js.map +0 -1
- package/src/embed/hostEventClient/contracts.ts +0 -262
package/src/embed/ts-embed.ts
CHANGED
|
@@ -10,20 +10,26 @@ import isEqual from 'lodash/isEqual';
|
|
|
10
10
|
import isEmpty from 'lodash/isEmpty';
|
|
11
11
|
import isObject from 'lodash/isObject';
|
|
12
12
|
import {
|
|
13
|
-
HostEventRequest,
|
|
14
|
-
TriggerPayload,
|
|
15
|
-
TriggerResponse,
|
|
16
13
|
UIPassthroughArrayResponse,
|
|
17
14
|
UIPassthroughEvent,
|
|
18
15
|
UIPassthroughRequest,
|
|
19
|
-
} from '
|
|
16
|
+
} from '../contracts/ui-passthrough-contracts';
|
|
17
|
+
// Contract resolution comes from the shared contracts module (the single
|
|
18
|
+
// source of truth for event payload shapes) rather than the legacy
|
|
19
|
+
// UI-passthrough-only mapping.
|
|
20
|
+
import {
|
|
21
|
+
HostEventRequest,
|
|
22
|
+
TriggerData,
|
|
23
|
+
TriggerResponse,
|
|
24
|
+
} from '../contracts/host-event-contracts';
|
|
25
|
+
import { EmbedEventPayload } from '../contracts/embed-event-payloads';
|
|
26
|
+
import { isMessageFromIframe } from '../utils/transport/iframe-transport';
|
|
20
27
|
import { logger } from '../utils/logger';
|
|
21
28
|
import { getAuthenticationToken } from '../authToken';
|
|
22
29
|
import { AnswerService } from '../utils/graphql/answerService/answerService';
|
|
23
30
|
import {
|
|
24
31
|
getEncodedQueryParamsString,
|
|
25
32
|
getCssDimension,
|
|
26
|
-
getOffsetTop,
|
|
27
33
|
embedEventStatus,
|
|
28
34
|
setAttributes,
|
|
29
35
|
getCustomisations,
|
|
@@ -63,6 +69,7 @@ import {
|
|
|
63
69
|
DefaultAppInitData,
|
|
64
70
|
AllEmbedViewConfig as ViewConfig,
|
|
65
71
|
EmbedErrorDetailsEvent,
|
|
72
|
+
EmbedErrorSeverity,
|
|
66
73
|
ErrorDetailsTypes,
|
|
67
74
|
EmbedErrorCodes,
|
|
68
75
|
MessagePayload,
|
|
@@ -109,6 +116,14 @@ const TS_EMBED_ID = '_thoughtspot-embed';
|
|
|
109
116
|
const PRERENDER_CONTAINER_ORIGINAL_POSITION_KEY = 'tsEmbedOriginalPosition';
|
|
110
117
|
const PRERENDER_WRAPPER_ID_PREFIX = 'tsEmbed-pre-render-wrapper-';
|
|
111
118
|
|
|
119
|
+
// The container applies UpdateEmbedParams through React state, so a delivered
|
|
120
|
+
// post is not the same as the params being in effect.
|
|
121
|
+
const UPDATE_EMBED_PARAMS_SETTLE_MS = 200;
|
|
122
|
+
|
|
123
|
+
// The container ignores runtimeFilterParams/runtimeParameterParams unless truthy, so
|
|
124
|
+
// null or '' leaves the previous embed's values in place. '&' is truthy and parses to {}.
|
|
125
|
+
const NO_RUNTIME_PARAMS = '&';
|
|
126
|
+
|
|
112
127
|
/**
|
|
113
128
|
* The event id map from v2 event names to v1 event id
|
|
114
129
|
* v1 events are the classic embed events implemented in Blink v1
|
|
@@ -141,6 +156,8 @@ export class TsEmbed {
|
|
|
141
156
|
*/
|
|
142
157
|
protected embedNodeKey = '__tsEmbed';
|
|
143
158
|
|
|
159
|
+
protected embedContainerLoadedKey = '__tsEmbedContainerLoaded';
|
|
160
|
+
|
|
144
161
|
protected isAppInitialized = false;
|
|
145
162
|
|
|
146
163
|
/**
|
|
@@ -284,6 +301,7 @@ export class TsEmbed {
|
|
|
284
301
|
errorType: ErrorDetailsTypes.VALIDATION_ERROR,
|
|
285
302
|
message: ERROR_MESSAGE.INIT_SDK_REQUIRED,
|
|
286
303
|
code: EmbedErrorCodes.INIT_ERROR,
|
|
304
|
+
severity: EmbedErrorSeverity.SEV1,
|
|
287
305
|
error: ERROR_MESSAGE.INIT_SDK_REQUIRED,
|
|
288
306
|
});
|
|
289
307
|
}
|
|
@@ -295,7 +313,10 @@ export class TsEmbed {
|
|
|
295
313
|
*/
|
|
296
314
|
protected handleError(errorDetails: EmbedErrorDetailsEvent) {
|
|
297
315
|
this.isError = true;
|
|
298
|
-
this.executeCallbacks(EmbedEvent.Error,
|
|
316
|
+
this.executeCallbacks(EmbedEvent.Error, {
|
|
317
|
+
severity: EmbedErrorSeverity.SEV3,
|
|
318
|
+
...errorDetails,
|
|
319
|
+
});
|
|
299
320
|
// Log error
|
|
300
321
|
logger.error(errorDetails);
|
|
301
322
|
}
|
|
@@ -393,6 +414,7 @@ export class TsEmbed {
|
|
|
393
414
|
errorType: ErrorDetailsTypes.NETWORK,
|
|
394
415
|
message: ERROR_MESSAGE.OFFLINE_WARNING,
|
|
395
416
|
code: EmbedErrorCodes.NETWORK_ERROR,
|
|
417
|
+
severity: EmbedErrorSeverity.SEV2,
|
|
396
418
|
offlineWarning: ERROR_MESSAGE.OFFLINE_WARNING,
|
|
397
419
|
};
|
|
398
420
|
this.executeCallbacks(EmbedEvent.Error, errorDetails);
|
|
@@ -433,7 +455,7 @@ export class TsEmbed {
|
|
|
433
455
|
const eventType = this.getEventType(event);
|
|
434
456
|
const eventPort = this.getEventPort(event);
|
|
435
457
|
const eventData = this.formatEventData(event, eventType);
|
|
436
|
-
if (event
|
|
458
|
+
if (isMessageFromIframe(event, this.iFrame, this.thoughtSpotHost)) {
|
|
437
459
|
const processedEventData = processEventData(
|
|
438
460
|
eventType,
|
|
439
461
|
eventData,
|
|
@@ -714,7 +736,18 @@ export class TsEmbed {
|
|
|
714
736
|
queryParams[key] = deserializeParam(queryParams[key]);
|
|
715
737
|
});
|
|
716
738
|
const appInitData = await this.getAppInitData();
|
|
717
|
-
return {
|
|
739
|
+
return {
|
|
740
|
+
...this.viewConfig,
|
|
741
|
+
...queryParams,
|
|
742
|
+
...appInitData,
|
|
743
|
+
// A show cycle has no URL to carry these, so the payload always states them
|
|
744
|
+
// — including "none", which is the case that leaks the previous filters.
|
|
745
|
+
runtimeFilterParams:
|
|
746
|
+
getFilterQuery(this.viewConfig.runtimeFilters ?? []) || NO_RUNTIME_PARAMS,
|
|
747
|
+
runtimeParameterParams:
|
|
748
|
+
getRuntimeParameters(this.viewConfig.runtimeParameters ?? [])
|
|
749
|
+
|| NO_RUNTIME_PARAMS,
|
|
750
|
+
};
|
|
718
751
|
}
|
|
719
752
|
|
|
720
753
|
/**
|
|
@@ -967,18 +1000,19 @@ export class TsEmbed {
|
|
|
967
1000
|
}
|
|
968
1001
|
|
|
969
1002
|
/**
|
|
970
|
-
* Returns a merged {@link PreRenderConfig} object where each
|
|
971
|
-
*
|
|
972
|
-
*
|
|
1003
|
+
* Returns a merged {@link PreRenderConfig} object where each key prefers the
|
|
1004
|
+
* value from `preRenderConfig` over its deprecated top-level `viewConfig`
|
|
1005
|
+
* counterpart (`id`/`preRenderId`, `containerSelector`/`preRenderContainer`,
|
|
1006
|
+
* `doNotTrackSize`/`doNotTrackPreRenderSize`) for backward compatibility.
|
|
973
1007
|
*/
|
|
974
1008
|
protected getPreRenderConfig(): PreRenderConfig {
|
|
975
1009
|
const viewCfg = this.viewConfig as BaseViewConfig;
|
|
976
1010
|
const preRenderCfg = viewCfg.preRenderConfig ?? {};
|
|
977
1011
|
return {
|
|
978
1012
|
...preRenderCfg,
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1013
|
+
id: preRenderCfg.id ?? viewCfg.preRenderId,
|
|
1014
|
+
containerSelector: preRenderCfg.containerSelector ?? viewCfg.preRenderContainer,
|
|
1015
|
+
doNotTrackSize: preRenderCfg.doNotTrackSize ?? viewCfg.doNotTrackPreRenderSize,
|
|
982
1016
|
};
|
|
983
1017
|
}
|
|
984
1018
|
|
|
@@ -986,7 +1020,7 @@ export class TsEmbed {
|
|
|
986
1020
|
* Returns true if this embed instance is configured for pre-rendering.
|
|
987
1021
|
*/
|
|
988
1022
|
protected isPreRenderEmbed() {
|
|
989
|
-
return !!this.getPreRenderConfig().
|
|
1023
|
+
return !!this.getPreRenderConfig().id;
|
|
990
1024
|
}
|
|
991
1025
|
protected handleInsertionIntoDOM(child: string | Node): void {
|
|
992
1026
|
if (this.isPreRenderEmbed()) {
|
|
@@ -1092,6 +1126,7 @@ export class TsEmbed {
|
|
|
1092
1126
|
errorType: ErrorDetailsTypes.API,
|
|
1093
1127
|
message: error.message || ERROR_MESSAGE.LOGIN_FAILED,
|
|
1094
1128
|
code: EmbedErrorCodes.LOGIN_FAILED,
|
|
1129
|
+
severity: EmbedErrorSeverity.SEV1,
|
|
1095
1130
|
error: error,
|
|
1096
1131
|
});
|
|
1097
1132
|
});
|
|
@@ -1117,6 +1152,8 @@ export class TsEmbed {
|
|
|
1117
1152
|
return preRenderWrapper;
|
|
1118
1153
|
}
|
|
1119
1154
|
|
|
1155
|
+
// TODO(SCAL-338011): move the pre-render code out to its own file, the way
|
|
1156
|
+
// full height did. It is spread across this class and getting messy.
|
|
1120
1157
|
protected preRenderWrapper: HTMLElement;
|
|
1121
1158
|
|
|
1122
1159
|
protected preRenderChild: HTMLElement;
|
|
@@ -1200,7 +1237,7 @@ export class TsEmbed {
|
|
|
1200
1237
|
* fresh element; an element passed directly cannot be re-resolved.
|
|
1201
1238
|
*/
|
|
1202
1239
|
private resolvePreRenderContainerTarget(): HTMLElement {
|
|
1203
|
-
const containerConfig = this.getPreRenderConfig().
|
|
1240
|
+
const containerConfig = this.getPreRenderConfig().containerSelector;
|
|
1204
1241
|
let container: Element | null = null;
|
|
1205
1242
|
if (typeof containerConfig === 'string') {
|
|
1206
1243
|
try {
|
|
@@ -1224,7 +1261,7 @@ export class TsEmbed {
|
|
|
1224
1261
|
}
|
|
1225
1262
|
const ownerContainer = preRenderedObject.preRenderContainerEl ?? document.body;
|
|
1226
1263
|
if (
|
|
1227
|
-
this.getPreRenderConfig().
|
|
1264
|
+
this.getPreRenderConfig().containerSelector
|
|
1228
1265
|
&& this.resolvePreRenderContainerTarget() !== ownerContainer
|
|
1229
1266
|
) {
|
|
1230
1267
|
logger.warn(
|
|
@@ -1462,41 +1499,6 @@ export class TsEmbed {
|
|
|
1462
1499
|
return V1EventMap[eventType] || eventType;
|
|
1463
1500
|
}
|
|
1464
1501
|
|
|
1465
|
-
/**
|
|
1466
|
-
* Calculates the iframe center for the current visible viewPort
|
|
1467
|
-
* of iframe using Scroll position of Host App, offsetTop for iframe
|
|
1468
|
-
* in Host app. ViewPort height of the tab.
|
|
1469
|
-
* @returns iframe Center in visible viewport,
|
|
1470
|
-
* Iframe height,
|
|
1471
|
-
* View port height.
|
|
1472
|
-
*/
|
|
1473
|
-
protected getIframeCenter() {
|
|
1474
|
-
const offsetTopClient = getOffsetTop(this.iFrame);
|
|
1475
|
-
const scrollTopClient = window.scrollY;
|
|
1476
|
-
const viewPortHeight = window.innerHeight;
|
|
1477
|
-
const iframeHeight = this.iFrame.offsetHeight;
|
|
1478
|
-
const iframeScrolled = scrollTopClient - offsetTopClient;
|
|
1479
|
-
let iframeVisibleViewPort;
|
|
1480
|
-
let iframeOffset;
|
|
1481
|
-
|
|
1482
|
-
if (iframeScrolled < 0) {
|
|
1483
|
-
iframeVisibleViewPort = viewPortHeight - (offsetTopClient - scrollTopClient);
|
|
1484
|
-
iframeVisibleViewPort = Math.min(iframeHeight, iframeVisibleViewPort);
|
|
1485
|
-
iframeOffset = 0;
|
|
1486
|
-
} else {
|
|
1487
|
-
iframeVisibleViewPort = Math.min(iframeHeight - iframeScrolled, viewPortHeight);
|
|
1488
|
-
iframeOffset = iframeScrolled;
|
|
1489
|
-
}
|
|
1490
|
-
const iframeCenter = iframeOffset + iframeVisibleViewPort / 2;
|
|
1491
|
-
return {
|
|
1492
|
-
iframeCenter,
|
|
1493
|
-
iframeScrolled,
|
|
1494
|
-
iframeHeight,
|
|
1495
|
-
viewPortHeight,
|
|
1496
|
-
iframeVisibleViewPort,
|
|
1497
|
-
};
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
1502
|
/**
|
|
1501
1503
|
* Registers an event listener to trigger an alert when the ThoughtSpot app
|
|
1502
1504
|
* sends an event of a particular message type to the host application.
|
|
@@ -1520,9 +1522,12 @@ export class TsEmbed {
|
|
|
1520
1522
|
* });
|
|
1521
1523
|
* ```
|
|
1522
1524
|
*/
|
|
1523
|
-
public on(
|
|
1524
|
-
messageType:
|
|
1525
|
-
callback:
|
|
1525
|
+
public on<EmbedEventT extends EmbedEvent>(
|
|
1526
|
+
messageType: EmbedEventT,
|
|
1527
|
+
callback: (
|
|
1528
|
+
payload: EmbedEventPayload<EmbedEventT>,
|
|
1529
|
+
responder?: (data: any) => void,
|
|
1530
|
+
) => void,
|
|
1526
1531
|
options: MessageOptions = { start: false },
|
|
1527
1532
|
isRegisteredBySDK = false,
|
|
1528
1533
|
): typeof TsEmbed.prototype {
|
|
@@ -1600,14 +1605,34 @@ export class TsEmbed {
|
|
|
1600
1605
|
protected getPreRenderObj<T extends TsEmbed>(): T {
|
|
1601
1606
|
const embedObj = (this.preRenderWrapper as any)?.[this.embedNodeKey] as T;
|
|
1602
1607
|
if (embedObj === (this as any)) {
|
|
1603
|
-
logger.
|
|
1608
|
+
logger.debug('embedObj is same as this');
|
|
1604
1609
|
}
|
|
1605
1610
|
return embedObj;
|
|
1606
1611
|
}
|
|
1607
1612
|
|
|
1613
|
+
protected takeOverPreRender(): void {
|
|
1614
|
+
if (!this.preRenderWrapper) return;
|
|
1615
|
+
(this.preRenderWrapper as any)[this.embedNodeKey] = this;
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
// The flag lives on the wrapper because it describes the iframe: an instance
|
|
1619
|
+
// hidden when the container announced itself would otherwise report false forever.
|
|
1620
|
+
private markEmbedContainerLoaded() {
|
|
1621
|
+
this.isEmbedContainerLoaded = true;
|
|
1622
|
+
if (this.preRenderWrapper) {
|
|
1623
|
+
(this.preRenderWrapper as any)[this.embedContainerLoadedKey] = true;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1608
1627
|
private checkEmbedContainerLoaded() {
|
|
1609
1628
|
if (this.isEmbedContainerLoaded) return true;
|
|
1610
1629
|
|
|
1630
|
+
if ((this.preRenderWrapper as any)?.[this.embedContainerLoadedKey]) {
|
|
1631
|
+
this.isEmbedContainerLoaded = true;
|
|
1632
|
+
return true;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
// Older builds stamped the flag on the instance, not the wrapper.
|
|
1611
1636
|
const preRenderObj = this.getPreRenderObj<TsEmbed>();
|
|
1612
1637
|
if (preRenderObj && preRenderObj.isEmbedContainerLoaded) {
|
|
1613
1638
|
this.isEmbedContainerLoaded = true;
|
|
@@ -1640,7 +1665,7 @@ export class TsEmbed {
|
|
|
1640
1665
|
(source: EmbedEvent.AuthInit | EmbedEvent.EmbedListenerReady) => () => {
|
|
1641
1666
|
const processEmbedContainerReady = () => {
|
|
1642
1667
|
logger.debug('processEmbedContainerReady');
|
|
1643
|
-
this.
|
|
1668
|
+
this.markEmbedContainerLoaded();
|
|
1644
1669
|
this.executeEmbedContainerReadyCallbacks();
|
|
1645
1670
|
};
|
|
1646
1671
|
if (source === EmbedEvent.AuthInit) {
|
|
@@ -1656,8 +1681,12 @@ export class TsEmbed {
|
|
|
1656
1681
|
|
|
1657
1682
|
/**
|
|
1658
1683
|
* Triggers an event to the embedded app
|
|
1684
|
+
*
|
|
1685
|
+
* Payload typing: from SDK 1.52.0 (ThoughtSpot Cloud 26.9.0.cl), unknown fields
|
|
1686
|
+
* on a known event's payload fail to compile. From SDK 1.54.0 (26.11.0.cl) the
|
|
1687
|
+
* payload is checked strictly against the event contract — update call sites now.
|
|
1659
1688
|
* @param {HostEvent} messageType The event type
|
|
1660
|
-
* @param {
|
|
1689
|
+
* @param {TriggerData} data The payload, typed against the event's contract
|
|
1661
1690
|
* @param {ContextType} context Optional context type to specify the context from which the event is triggered.
|
|
1662
1691
|
* Use ContextType.Search for search answer context, ContextType.Answer for answer/explore context,
|
|
1663
1692
|
* ContextType.Liveboard for liveboard context, or ContextType.Spotter for spotter context.
|
|
@@ -1680,7 +1709,10 @@ export class TsEmbed {
|
|
|
1680
1709
|
ContextT extends ContextType = ContextType,
|
|
1681
1710
|
>(
|
|
1682
1711
|
messageType: HostEventT,
|
|
1683
|
-
|
|
1712
|
+
// Contract shape is the contextual type: payload fields autocomplete
|
|
1713
|
+
// and unknown fields on object literals are flagged. Strict checks
|
|
1714
|
+
// land in SDK 1.54.0 — see TriggerData.
|
|
1715
|
+
data: TriggerData<HostEventT> = {} as any,
|
|
1684
1716
|
context?: ContextT,
|
|
1685
1717
|
): Promise<TriggerResponse<PayloadT, HostEventT, ContextT>> {
|
|
1686
1718
|
uploadMixpanelEvent(`${MIXPANEL_EVENT.VISUAL_SDK_TRIGGER}-${messageType}`);
|
|
@@ -1850,7 +1882,7 @@ export class TsEmbed {
|
|
|
1850
1882
|
showPreRenderByDefault,
|
|
1851
1883
|
replaceExistingPreRender,
|
|
1852
1884
|
});
|
|
1853
|
-
if (!this.getPreRenderConfig().
|
|
1885
|
+
if (!this.getPreRenderConfig().id) {
|
|
1854
1886
|
logger.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
|
|
1855
1887
|
return this;
|
|
1856
1888
|
}
|
|
@@ -2007,24 +2039,34 @@ export class TsEmbed {
|
|
|
2007
2039
|
return this.renderIFrame(prerenderFrameSrc);
|
|
2008
2040
|
}
|
|
2009
2041
|
|
|
2042
|
+
// Subclasses that navigate the pre-render on show must await this before
|
|
2043
|
+
// triggering Navigate. Resolves even on failure, so navigation is never blocked.
|
|
2044
|
+
protected preRenderParamsApplied: Promise<void> = Promise.resolve();
|
|
2045
|
+
|
|
2010
2046
|
protected beforePrerenderVisible(): void {
|
|
2011
2047
|
// We can ignore this as its a bit expensive and the newer customers
|
|
2012
2048
|
// have moved on to UpdateEmbedParams supported clusters
|
|
2013
2049
|
// this.validatePreRenderViewConfig(this.viewConfig); removed in #517
|
|
2014
2050
|
logger.debug('triggering UpdateEmbedParams', this.viewConfig);
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2051
|
+
// Created synchronously: a queued navigation needs something to await
|
|
2052
|
+
// whether the container is already loaded or not.
|
|
2053
|
+
this.preRenderParamsApplied = new Promise<void>((resolve) => {
|
|
2054
|
+
this.executeAfterEmbedContainerLoaded(async () => {
|
|
2055
|
+
try {
|
|
2056
|
+
const params = await this.getUpdateEmbedParamsObject();
|
|
2057
|
+
this.trigger(HostEvent.UpdateEmbedParams, params);
|
|
2058
|
+
} catch (error) {
|
|
2059
|
+
logger.error(ERROR_MESSAGE.UPDATE_PARAMS_FAILED, error);
|
|
2060
|
+
this.handleError({
|
|
2061
|
+
errorType: ErrorDetailsTypes.API,
|
|
2062
|
+
message: error?.message || ERROR_MESSAGE.UPDATE_PARAMS_FAILED,
|
|
2063
|
+
code: EmbedErrorCodes.UPDATE_PARAMS_FAILED,
|
|
2064
|
+
error: error?.message || error,
|
|
2065
|
+
});
|
|
2066
|
+
} finally {
|
|
2067
|
+
setTimeout(resolve, UPDATE_EMBED_PARAMS_SETTLE_MS);
|
|
2068
|
+
}
|
|
2069
|
+
});
|
|
2028
2070
|
});
|
|
2029
2071
|
}
|
|
2030
2072
|
|
|
@@ -2036,14 +2078,14 @@ export class TsEmbed {
|
|
|
2036
2078
|
*/
|
|
2037
2079
|
public async showPreRender(): Promise<TsEmbed> {
|
|
2038
2080
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_SHOW_PRE_RENDER, {
|
|
2039
|
-
preRenderId: this.getPreRenderConfig().
|
|
2081
|
+
preRenderId: this.getPreRenderConfig().id,
|
|
2040
2082
|
embedComponentType: this.viewConfig.embedComponentType,
|
|
2041
2083
|
});
|
|
2042
2084
|
|
|
2043
2085
|
if (this.shouldWaitForRenderPromise) await this.isReadyForRenderPromise;
|
|
2044
2086
|
|
|
2045
2087
|
|
|
2046
|
-
if (!this.getPreRenderConfig().
|
|
2088
|
+
if (!this.getPreRenderConfig().id) {
|
|
2047
2089
|
logger.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
|
|
2048
2090
|
return this;
|
|
2049
2091
|
}
|
|
@@ -2085,7 +2127,7 @@ export class TsEmbed {
|
|
|
2085
2127
|
customContainer.addEventListener('scroll', this.containerScrollListener);
|
|
2086
2128
|
}
|
|
2087
2129
|
|
|
2088
|
-
if (!this.getPreRenderConfig().
|
|
2130
|
+
if (!this.getPreRenderConfig().doNotTrackSize) {
|
|
2089
2131
|
const observeTarget = (this.insertedDomEl as HTMLElement) ?? this.hostElement;
|
|
2090
2132
|
this.resizeObserver = new ResizeObserver((entries) => {
|
|
2091
2133
|
entries.forEach((entry) => {
|
|
@@ -2111,6 +2153,9 @@ export class TsEmbed {
|
|
|
2111
2153
|
this.setupFullscreenChangeHandler();
|
|
2112
2154
|
}
|
|
2113
2155
|
|
|
2156
|
+
// Last, so everything above still sees the instance being taken over from.
|
|
2157
|
+
this.takeOverPreRender();
|
|
2158
|
+
|
|
2114
2159
|
return this;
|
|
2115
2160
|
}
|
|
2116
2161
|
|
|
@@ -2160,7 +2205,7 @@ export class TsEmbed {
|
|
|
2160
2205
|
*/
|
|
2161
2206
|
public hidePreRender(): void {
|
|
2162
2207
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_HIDE_PRE_RENDER, {
|
|
2163
|
-
preRenderId: this.getPreRenderConfig().
|
|
2208
|
+
preRenderId: this.getPreRenderConfig().id,
|
|
2164
2209
|
embedComponentType: this.viewConfig.embedComponentType,
|
|
2165
2210
|
});
|
|
2166
2211
|
|
|
@@ -2204,7 +2249,7 @@ export class TsEmbed {
|
|
|
2204
2249
|
* @property {string} child - The HTML element ID for the PreRender child.
|
|
2205
2250
|
*/
|
|
2206
2251
|
public getPreRenderIds() {
|
|
2207
|
-
const preRenderId = this.getPreRenderConfig().
|
|
2252
|
+
const preRenderId = this.getPreRenderConfig().id;
|
|
2208
2253
|
return {
|
|
2209
2254
|
wrapper: `${PRERENDER_WRAPPER_ID_PREFIX}${preRenderId}`,
|
|
2210
2255
|
child: `tsEmbed-pre-render-child-${preRenderId}`,
|
|
@@ -2331,12 +2376,18 @@ export class V1Embed extends TsEmbed {
|
|
|
2331
2376
|
* });
|
|
2332
2377
|
* ```
|
|
2333
2378
|
*/
|
|
2334
|
-
public on(
|
|
2335
|
-
messageType:
|
|
2336
|
-
callback:
|
|
2379
|
+
public on<EmbedEventT extends EmbedEvent>(
|
|
2380
|
+
messageType: EmbedEventT,
|
|
2381
|
+
callback: (
|
|
2382
|
+
payload: EmbedEventPayload<EmbedEventT>,
|
|
2383
|
+
responder?: (data: any) => void,
|
|
2384
|
+
) => void,
|
|
2337
2385
|
options: MessageOptions = { start: false },
|
|
2338
2386
|
): typeof TsEmbed.prototype {
|
|
2339
|
-
|
|
2387
|
+
// Mirror the base TsEmbed.on generic signature so the enriched
|
|
2388
|
+
// EmbedEventPayload (e.g. CustomAction's answerService) flows through
|
|
2389
|
+
// the override too, and the class hierarchy stays assignable.
|
|
2390
|
+
const eventType = this.getCompatibleEventType(messageType) as EmbedEventT;
|
|
2340
2391
|
return super.on(eventType, callback, options);
|
|
2341
2392
|
}
|
|
2342
2393
|
|