@thoughtspot/visual-embed-sdk 1.48.0 → 1.49.0
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 +1 -1
- package/cjs/src/css-variables.d.ts +140 -0
- package/cjs/src/css-variables.d.ts.map +1 -1
- package/cjs/src/embed/app.d.ts +62 -1
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +57 -6
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +191 -1
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/auto-frame-renderer.js +7 -2
- package/cjs/src/embed/auto-frame-renderer.js.map +1 -1
- package/cjs/src/embed/auto-frame-renderer.spec.js +385 -6
- package/cjs/src/embed/auto-frame-renderer.spec.js.map +1 -1
- package/cjs/src/embed/base.d.ts +1 -0
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +13 -1
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/base.spec.js +21 -0
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/bodyless-conversation.spec.js +86 -0
- package/cjs/src/embed/bodyless-conversation.spec.js.map +1 -1
- package/cjs/src/embed/conversation.d.ts +16 -1
- package/cjs/src/embed/conversation.d.ts.map +1 -1
- package/cjs/src/embed/conversation.js +5 -1
- package/cjs/src/embed/conversation.js.map +1 -1
- package/cjs/src/embed/conversation.spec.js +26 -0
- package/cjs/src/embed/conversation.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +47 -1
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +47 -6
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +129 -1
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/spotter-viz-utils.d.ts +85 -0
- package/cjs/src/embed/spotter-viz-utils.d.ts.map +1 -0
- package/cjs/src/embed/spotter-viz-utils.js +17 -0
- package/cjs/src/embed/spotter-viz-utils.js.map +1 -0
- package/cjs/src/embed/spotter-viz-utils.spec.d.ts +2 -0
- package/cjs/src/embed/spotter-viz-utils.spec.d.ts.map +1 -0
- package/cjs/src/embed/spotter-viz-utils.spec.js +31 -0
- package/cjs/src/embed/spotter-viz-utils.spec.js.map +1 -0
- package/cjs/src/embed/ts-embed.d.ts +58 -38
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +245 -149
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +369 -123
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/index.d.ts +2 -1
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/react/index.d.ts.map +1 -1
- package/cjs/src/react/index.js +3 -0
- package/cjs/src/react/index.js.map +1 -1
- package/cjs/src/types.d.ts +267 -27
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +223 -19
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.spec.js +6 -7
- package/cjs/src/utils/authService/tokenizedAuthService.spec.js.map +1 -1
- package/cjs/src/utils/logger.js +2 -1
- package/cjs/src/utils/logger.js.map +1 -1
- package/cjs/src/utils/logger.spec.d.ts +1 -0
- package/cjs/src/utils/logger.spec.d.ts.map +1 -1
- package/cjs/src/utils/logger.spec.js +10 -9
- package/cjs/src/utils/logger.spec.js.map +1 -1
- package/cjs/src/utils.d.ts +4 -1
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +107 -10
- package/cjs/src/utils.js.map +1 -1
- package/cjs/src/utils.spec.js +163 -4
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/{index-Ck-r09gt.js → index-_UGCSSDR.js} +1 -1
- package/dist/src/css-variables.d.ts +140 -0
- package/dist/src/css-variables.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +62 -1
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts +1 -0
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/conversation.d.ts +16 -1
- package/dist/src/embed/conversation.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +47 -1
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/spotter-viz-utils.d.ts +85 -0
- package/dist/src/embed/spotter-viz-utils.d.ts.map +1 -0
- package/dist/src/embed/spotter-viz-utils.spec.d.ts +2 -0
- package/dist/src/embed/spotter-viz-utils.spec.d.ts.map +1 -0
- package/dist/src/embed/ts-embed.d.ts +58 -38
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +267 -27
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/logger.spec.d.ts +1 -0
- package/dist/src/utils/logger.spec.d.ts.map +1 -1
- package/dist/src/utils.d.ts +4 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +3708 -3226
- package/dist/tsembed-react.js +3358 -2876
- package/dist/tsembed.es.js +3713 -3229
- package/dist/tsembed.js +3708 -3224
- package/dist/visual-embed-sdk-react-full.d.ts +643 -63
- package/dist/visual-embed-sdk-react.d.ts +643 -63
- package/dist/visual-embed-sdk.d.ts +658 -65
- package/lib/package.json +1 -1
- package/lib/src/css-variables.d.ts +140 -0
- package/lib/src/css-variables.d.ts.map +1 -1
- package/lib/src/embed/app.d.ts +62 -1
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +58 -7
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +192 -2
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/auto-frame-renderer.js +7 -2
- package/lib/src/embed/auto-frame-renderer.js.map +1 -1
- package/lib/src/embed/auto-frame-renderer.spec.js +387 -8
- package/lib/src/embed/auto-frame-renderer.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +1 -0
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +11 -0
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +22 -1
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/bodyless-conversation.spec.js +86 -0
- package/lib/src/embed/bodyless-conversation.spec.js.map +1 -1
- package/lib/src/embed/conversation.d.ts +16 -1
- package/lib/src/embed/conversation.d.ts.map +1 -1
- package/lib/src/embed/conversation.js +5 -1
- package/lib/src/embed/conversation.js.map +1 -1
- package/lib/src/embed/conversation.spec.js +27 -1
- package/lib/src/embed/conversation.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +47 -1
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +48 -7
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +129 -1
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/spotter-viz-utils.d.ts +85 -0
- package/lib/src/embed/spotter-viz-utils.d.ts.map +1 -0
- package/lib/src/embed/spotter-viz-utils.js +13 -0
- package/lib/src/embed/spotter-viz-utils.js.map +1 -0
- package/lib/src/embed/spotter-viz-utils.spec.d.ts +2 -0
- package/lib/src/embed/spotter-viz-utils.spec.d.ts.map +1 -0
- package/lib/src/embed/spotter-viz-utils.spec.js +29 -0
- package/lib/src/embed/spotter-viz-utils.spec.js.map +1 -0
- package/lib/src/embed/ts-embed.d.ts +58 -38
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +248 -152
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +369 -123
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +2 -1
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js.map +1 -1
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +3 -0
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/types.d.ts +267 -27
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +223 -19
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.spec.js +6 -7
- package/lib/src/utils/authService/tokenizedAuthService.spec.js.map +1 -1
- package/lib/src/utils/logger.js +2 -1
- package/lib/src/utils/logger.js.map +1 -1
- package/lib/src/utils/logger.spec.d.ts +1 -0
- package/lib/src/utils/logger.spec.d.ts.map +1 -1
- package/lib/src/utils/logger.spec.js +10 -9
- package/lib/src/utils/logger.spec.js.map +1 -1
- package/lib/src/utils.d.ts +4 -1
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +103 -9
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +164 -5
- package/lib/src/utils.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +658 -65
- package/package.json +1 -1
- package/src/css-variables.ts +175 -1
- package/src/embed/app.spec.ts +247 -3
- package/src/embed/app.ts +125 -5
- package/src/embed/auto-frame-renderer.spec.ts +457 -58
- package/src/embed/auto-frame-renderer.ts +7 -2
- package/src/embed/base.spec.ts +25 -1
- package/src/embed/base.ts +19 -5
- package/src/embed/bodyless-conversation.spec.ts +93 -0
- package/src/embed/conversation.spec.ts +34 -0
- package/src/embed/conversation.ts +22 -1
- package/src/embed/liveboard.spec.ts +149 -1
- package/src/embed/liveboard.ts +102 -6
- package/src/embed/spotter-viz-utils.spec.ts +30 -0
- package/src/embed/spotter-viz-utils.ts +94 -0
- package/src/embed/ts-embed.spec.ts +532 -234
- package/src/embed/ts-embed.ts +383 -257
- package/src/index.ts +3 -0
- package/src/react/index.tsx +3 -0
- package/src/types.ts +284 -23
- package/src/utils/authService/tokenizedAuthService.spec.ts +6 -6
- package/src/utils/logger.spec.ts +11 -9
- package/src/utils/logger.ts +2 -2
- package/src/utils.spec.ts +200 -4
- package/src/utils.ts +128 -9
|
@@ -5,27 +5,26 @@
|
|
|
5
5
|
* @summary Base classes
|
|
6
6
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
7
7
|
*/
|
|
8
|
-
import isEqual from 'lodash/isEqual';
|
|
9
8
|
import isEmpty from 'lodash/isEmpty';
|
|
10
9
|
import isObject from 'lodash/isObject';
|
|
11
10
|
import { UIPassthroughEvent, } from './hostEventClient/contracts';
|
|
12
11
|
import { logger } from '../utils/logger';
|
|
13
12
|
import { getAuthenticationToken } from '../authToken';
|
|
14
13
|
import { AnswerService } from '../utils/graphql/answerService/answerService';
|
|
15
|
-
import { getEncodedQueryParamsString, getCssDimension, getOffsetTop, embedEventStatus, setAttributes, getCustomisations, getRuntimeFilters, getDOMNode, getFilterQuery, getQueryParamString, getRuntimeParameters, setStyleProperties, removeStyleProperties,
|
|
14
|
+
import { getEncodedQueryParamsString, getCssDimension, getOffsetTop, embedEventStatus, setAttributes, getCustomisations, getRuntimeFilters, getDOMNode, getFilterQuery, getQueryParamString, getRuntimeParameters, setStyleProperties, removeStyleProperties, getHostEventsConfig, } from '../utils';
|
|
16
15
|
import { getCustomActions } from '../utils/custom-actions';
|
|
17
16
|
import { getThoughtSpotHost, URL_MAX_LENGTH, DEFAULT_EMBED_WIDTH, DEFAULT_EMBED_HEIGHT, getV2BasePath, } from '../config';
|
|
18
17
|
import { AuthType, HostEvent, EmbedEvent, Action, Param, ContextMenuTriggerOptions, ErrorDetailsTypes, EmbedErrorCodes, } from '../types';
|
|
19
18
|
import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
|
|
20
19
|
import { processEventData, processAuthFailure } from '../utils/processData';
|
|
21
20
|
import { version } from '../../package.json';
|
|
22
|
-
import { getAuthPromise, renderInQueue, handleAuth, notifyAuthFailure, getInitPromise, getIsInitCalled, } from './base';
|
|
21
|
+
import { getAuthPromise, renderInQueue, handleAuth, notifyAuthFailure, getInitPromise, getIsInitCalled, getIsInitCompleted, } from './base';
|
|
23
22
|
import { AuthFailureType } from '../auth';
|
|
24
23
|
import { getEmbedConfig } from './embedConfig';
|
|
25
24
|
import { ERROR_MESSAGE } from '../errors';
|
|
26
25
|
import { getPreauthInfo } from '../utils/sessionInfoService';
|
|
27
26
|
import { HostEventClient } from './hostEventClient/host-event-client';
|
|
28
|
-
import { getInterceptInitData, handleInterceptEvent, processApiInterceptResponse, processLegacyInterceptResponse } from '../api-intercept';
|
|
27
|
+
import { getInterceptInitData, handleInterceptEvent, processApiInterceptResponse, processLegacyInterceptResponse, } from '../api-intercept';
|
|
29
28
|
/**
|
|
30
29
|
* Global prefix for all ThoughtSpot postHash Params.
|
|
31
30
|
*/
|
|
@@ -76,7 +75,7 @@ export class TsEmbed {
|
|
|
76
75
|
const eventPort = this.getEventPort(event);
|
|
77
76
|
const eventData = this.formatEventData(event, eventType);
|
|
78
77
|
if (event.source === this.iFrame.contentWindow) {
|
|
79
|
-
const processedEventData = processEventData(eventType, eventData, this.thoughtSpotHost, this.isPreRendered ? this.preRenderWrapper : this.
|
|
78
|
+
const processedEventData = processEventData(eventType, eventData, this.thoughtSpotHost, this.isPreRendered ? this.preRenderWrapper : this.hostElement);
|
|
80
79
|
if (eventType === EmbedEvent.ApiIntercept) {
|
|
81
80
|
this.handleApiInterceptEvent({ eventData, eventPort });
|
|
82
81
|
return;
|
|
@@ -104,7 +103,7 @@ export class TsEmbed {
|
|
|
104
103
|
};
|
|
105
104
|
this.handleAuthFailure = (error) => {
|
|
106
105
|
logger.error(`${ERROR_MESSAGE.INVALID_TOKEN_ERROR} Error : ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
107
|
-
processAuthFailure(error, this.isPreRendered ? this.preRenderWrapper : this.
|
|
106
|
+
processAuthFailure(error, this.isPreRendered ? this.preRenderWrapper : this.hostElement);
|
|
108
107
|
};
|
|
109
108
|
/**
|
|
110
109
|
* Refresh the auth token if the autoLogin is true and the authType is TrustedAuthTokenCookieless
|
|
@@ -128,7 +127,7 @@ export class TsEmbed {
|
|
|
128
127
|
const { authType, autoLogin: autoLoginConfig } = this.embedConfig;
|
|
129
128
|
// Default autoLogin: true for cookieless if undefined/null, otherwise
|
|
130
129
|
// false
|
|
131
|
-
const autoLogin = autoLoginConfig !== null && autoLoginConfig !== void 0 ? autoLoginConfig :
|
|
130
|
+
const autoLogin = autoLoginConfig !== null && autoLoginConfig !== void 0 ? autoLoginConfig : authType === AuthType.TrustedAuthTokenCookieless;
|
|
132
131
|
try {
|
|
133
132
|
await this.refreshAuthTokenForCookieless(responder, EmbedEvent.AuthExpire, false);
|
|
134
133
|
}
|
|
@@ -146,7 +145,8 @@ export class TsEmbed {
|
|
|
146
145
|
* @param responder
|
|
147
146
|
*/
|
|
148
147
|
this.idleSessionTimeout = (_, responder) => {
|
|
149
|
-
handleAuth()
|
|
148
|
+
handleAuth()
|
|
149
|
+
.then(async () => {
|
|
150
150
|
let authToken = '';
|
|
151
151
|
try {
|
|
152
152
|
authToken = await getAuthenticationToken(this.embedConfig);
|
|
@@ -158,7 +158,8 @@ export class TsEmbed {
|
|
|
158
158
|
catch (e) {
|
|
159
159
|
this.handleAuthFailure(e);
|
|
160
160
|
}
|
|
161
|
-
})
|
|
161
|
+
})
|
|
162
|
+
.catch((e) => {
|
|
162
163
|
logger.error(`Auto Login failed, Error : ${e === null || e === void 0 ? void 0 : e.message}`);
|
|
163
164
|
});
|
|
164
165
|
notifyAuthFailure(AuthFailureType.IDLE_SESSION_TIMEOUT);
|
|
@@ -200,10 +201,10 @@ export class TsEmbed {
|
|
|
200
201
|
};
|
|
201
202
|
};
|
|
202
203
|
/**
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
* @hidden
|
|
205
|
+
* Internal state to track if the embed container is loaded.
|
|
206
|
+
* This is used to trigger events after the embed container is loaded.
|
|
207
|
+
*/
|
|
207
208
|
this.isEmbedContainerLoaded = false;
|
|
208
209
|
/**
|
|
209
210
|
* @hidden
|
|
@@ -229,28 +230,7 @@ export class TsEmbed {
|
|
|
229
230
|
processEmbedContainerReady();
|
|
230
231
|
}
|
|
231
232
|
};
|
|
232
|
-
this.
|
|
233
|
-
var _a;
|
|
234
|
-
const preRenderAllowedKeys = ['preRenderId', 'vizId', 'liveboardId'];
|
|
235
|
-
const preRenderedObject = (_a = this.insertedDomEl) === null || _a === void 0 ? void 0 : _a[this.embedNodeKey];
|
|
236
|
-
if (!preRenderedObject)
|
|
237
|
-
return;
|
|
238
|
-
if (viewConfig.preRenderId) {
|
|
239
|
-
const allOtherKeys = Object.keys(viewConfig).filter((key) => !preRenderAllowedKeys.includes(key) && !key.startsWith('on'));
|
|
240
|
-
allOtherKeys.forEach((key) => {
|
|
241
|
-
if (!isUndefined(viewConfig[key])
|
|
242
|
-
&& !isEqual(viewConfig[key], preRenderedObject.viewConfig[key])) {
|
|
243
|
-
logger.warn(`${viewConfig.embedComponentType || 'Component'} was pre-rendered with `
|
|
244
|
-
+ `"${key}" as "${JSON.stringify(preRenderedObject.viewConfig[key])}" `
|
|
245
|
-
+ `but a different value "${JSON.stringify(viewConfig[key])}" `
|
|
246
|
-
+ 'was passed to the Embed component. '
|
|
247
|
-
+ 'The new value provided is ignored, the value provided during '
|
|
248
|
-
+ 'preRender is used.');
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
this.el = getDOMNode(domSelector);
|
|
233
|
+
this.hostElement = getDOMNode(domSelector);
|
|
254
234
|
this.eventHandlerMap = new Map();
|
|
255
235
|
this.isError = false;
|
|
256
236
|
this.viewConfig = {
|
|
@@ -263,16 +243,43 @@ export class TsEmbed {
|
|
|
263
243
|
...viewConfig,
|
|
264
244
|
});
|
|
265
245
|
const embedConfig = getEmbedConfig();
|
|
266
|
-
|
|
246
|
+
if (embedConfig) {
|
|
247
|
+
this.embedConfig = embedConfig;
|
|
248
|
+
this.thoughtSpotHost = getThoughtSpotHost(embedConfig);
|
|
249
|
+
this.thoughtSpotV2Base = getV2BasePath(embedConfig);
|
|
250
|
+
}
|
|
267
251
|
this.hostEventClient = new HostEventClient(this.iFrame);
|
|
268
|
-
this.
|
|
269
|
-
|
|
252
|
+
this.shouldWaitForRenderPromise = !getIsInitCompleted();
|
|
253
|
+
const afterInit = () => {
|
|
254
|
+
// Prefer the config captured at construction time; fall back to
|
|
255
|
+
// getEmbedConfig() for the case where init()
|
|
256
|
+
// hadn't been called yet.
|
|
257
|
+
this.embedConfig = embedConfig !== null && embedConfig !== void 0 ? embedConfig : getEmbedConfig();
|
|
258
|
+
if (!this.embedConfig) {
|
|
259
|
+
logger.error('embedConfig unavailable in afterInit; init() may not have completed');
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (!this.embedConfig.authTriggerContainer && !this.embedConfig.useEventForSAMLPopup) {
|
|
270
263
|
this.embedConfig.authTriggerContainer = domSelector;
|
|
271
264
|
}
|
|
272
|
-
this.thoughtSpotHost = getThoughtSpotHost(embedConfig);
|
|
273
|
-
this.thoughtSpotV2Base = getV2BasePath(embedConfig);
|
|
274
|
-
this.shouldEncodeUrlQueryParams = embedConfig.shouldEncodeUrlQueryParams;
|
|
275
|
-
}
|
|
265
|
+
this.thoughtSpotHost = getThoughtSpotHost(this.embedConfig);
|
|
266
|
+
this.thoughtSpotV2Base = getV2BasePath(this.embedConfig);
|
|
267
|
+
this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
|
|
268
|
+
};
|
|
269
|
+
if (!this.shouldWaitForRenderPromise) {
|
|
270
|
+
afterInit();
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
this.isReadyForRenderPromise = getInitPromise()
|
|
274
|
+
.then(afterInit)
|
|
275
|
+
.catch((err) => {
|
|
276
|
+
logger.error('SDK init failed before embed could be configured', err);
|
|
277
|
+
this.throwInitError();
|
|
278
|
+
})
|
|
279
|
+
.finally(() => {
|
|
280
|
+
this.shouldWaitForRenderPromise = false;
|
|
281
|
+
});
|
|
282
|
+
}
|
|
276
283
|
}
|
|
277
284
|
/**
|
|
278
285
|
* Throws error encountered during initialization.
|
|
@@ -329,9 +336,9 @@ export class TsEmbed {
|
|
|
329
336
|
// 3. FullAppEmbed has primary navbar visible since:
|
|
330
337
|
// - primary navbar requires fresh auth state for navigation
|
|
331
338
|
// - cached auth may not reflect current user permissions
|
|
332
|
-
const isDisabled =
|
|
333
|
-
|
|
334
|
-
|
|
339
|
+
const isDisabled = this.viewConfig.overrideOrgId !== undefined ||
|
|
340
|
+
this.embedConfig.disablePreauthCache === true ||
|
|
341
|
+
this.isFullAppEmbedWithVisiblePrimaryNavbar();
|
|
335
342
|
return !isDisabled;
|
|
336
343
|
}
|
|
337
344
|
/**
|
|
@@ -342,8 +349,8 @@ export class TsEmbed {
|
|
|
342
349
|
const appViewConfig = this.viewConfig;
|
|
343
350
|
// Check if this is a FullAppEmbed (AppEmbed)
|
|
344
351
|
// showPrimaryNavbar defaults to true if not explicitly set to false
|
|
345
|
-
return (appViewConfig.embedComponentType === 'AppEmbed'
|
|
346
|
-
|
|
352
|
+
return (appViewConfig.embedComponentType === 'AppEmbed' &&
|
|
353
|
+
appViewConfig.showPrimaryNavbar === true);
|
|
347
354
|
}
|
|
348
355
|
/**
|
|
349
356
|
* fix for ts7.sep.cl
|
|
@@ -386,7 +393,7 @@ export class TsEmbed {
|
|
|
386
393
|
this.subscribedListeners.online = onlineEventListener;
|
|
387
394
|
this.subscribedListeners.offline = offlineEventListener;
|
|
388
395
|
}
|
|
389
|
-
handleApiInterceptEvent({ eventData, eventPort }) {
|
|
396
|
+
handleApiInterceptEvent({ eventData, eventPort, }) {
|
|
390
397
|
const executeEvent = (_eventType, data) => {
|
|
391
398
|
this.executeCallbacks(_eventType, data, eventPort);
|
|
392
399
|
};
|
|
@@ -395,7 +402,12 @@ export class TsEmbed {
|
|
|
395
402
|
const response = await this.triggerUIPassThrough(UIPassthroughEvent.GetUnsavedAnswerTML, props);
|
|
396
403
|
return (_b = (_a = response.filter((item) => item.value)) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.value;
|
|
397
404
|
};
|
|
398
|
-
handleInterceptEvent({
|
|
405
|
+
handleInterceptEvent({
|
|
406
|
+
eventData,
|
|
407
|
+
executeEvent,
|
|
408
|
+
viewConfig: this.viewConfig,
|
|
409
|
+
getUnsavedAnswerTml,
|
|
410
|
+
});
|
|
399
411
|
}
|
|
400
412
|
/**
|
|
401
413
|
* Subscribe to message events that depend on successful iframe setup
|
|
@@ -446,7 +458,7 @@ export class TsEmbed {
|
|
|
446
458
|
authToken = await getAuthenticationToken(this.embedConfig);
|
|
447
459
|
}
|
|
448
460
|
catch (e) {
|
|
449
|
-
processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.
|
|
461
|
+
processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.hostElement);
|
|
450
462
|
throw e;
|
|
451
463
|
}
|
|
452
464
|
return authToken;
|
|
@@ -456,14 +468,17 @@ export class TsEmbed {
|
|
|
456
468
|
const authToken = await this.getAuthTokenForCookielessInit();
|
|
457
469
|
const customActionsResult = getCustomActions([
|
|
458
470
|
...(this.viewConfig.customActions || []),
|
|
459
|
-
...(this.embedConfig.customActions || [])
|
|
471
|
+
...(this.embedConfig.customActions || []),
|
|
460
472
|
]);
|
|
461
473
|
if (customActionsResult.errors.length > 0) {
|
|
462
474
|
this.handleError({
|
|
463
475
|
errorType: ErrorDetailsTypes.VALIDATION_ERROR,
|
|
464
476
|
message: customActionsResult.errors,
|
|
465
477
|
code: EmbedErrorCodes.CUSTOM_ACTION_VALIDATION,
|
|
466
|
-
error: {
|
|
478
|
+
error: {
|
|
479
|
+
type: EmbedErrorCodes.CUSTOM_ACTION_VALIDATION,
|
|
480
|
+
message: customActionsResult.errors,
|
|
481
|
+
},
|
|
467
482
|
});
|
|
468
483
|
}
|
|
469
484
|
const baseInitData = {
|
|
@@ -502,7 +517,7 @@ export class TsEmbed {
|
|
|
502
517
|
*/
|
|
503
518
|
async refreshAuthTokenForCookieless(responder, eventType, forceRefresh = false) {
|
|
504
519
|
const { authType, autoLogin } = this.embedConfig;
|
|
505
|
-
const isAutoLoginTrue = autoLogin !== null && autoLogin !== void 0 ? autoLogin :
|
|
520
|
+
const isAutoLoginTrue = autoLogin !== null && autoLogin !== void 0 ? autoLogin : authType === AuthType.TrustedAuthTokenCookieless;
|
|
506
521
|
if (isAutoLoginTrue && authType === AuthType.TrustedAuthTokenCookieless) {
|
|
507
522
|
const authToken = await getAuthenticationToken(this.embedConfig, forceRefresh);
|
|
508
523
|
responder({
|
|
@@ -639,8 +654,7 @@ export class TsEmbed {
|
|
|
639
654
|
if (spriteUrl) {
|
|
640
655
|
queryParams[Param.IconSpriteUrl] = spriteUrl.replace('https://', '');
|
|
641
656
|
}
|
|
642
|
-
const stringIDsUrl = ((_c = customizations === null || customizations === void 0 ? void 0 : customizations.content) === null || _c === void 0 ? void 0 : _c.stringIDsUrl)
|
|
643
|
-
|| ((_d = embedCustomizations === null || embedCustomizations === void 0 ? void 0 : embedCustomizations.content) === null || _d === void 0 ? void 0 : _d.stringIDsUrl);
|
|
657
|
+
const stringIDsUrl = ((_c = customizations === null || customizations === void 0 ? void 0 : customizations.content) === null || _c === void 0 ? void 0 : _c.stringIDsUrl) || ((_d = embedCustomizations === null || embedCustomizations === void 0 ? void 0 : embedCustomizations.content) === null || _d === void 0 ? void 0 : _d.stringIDsUrl);
|
|
644
658
|
if (stringIDsUrl) {
|
|
645
659
|
queryParams[Param.StringIDsUrl] = stringIDsUrl;
|
|
646
660
|
}
|
|
@@ -650,15 +664,10 @@ export class TsEmbed {
|
|
|
650
664
|
if (locale !== undefined) {
|
|
651
665
|
queryParams[Param.Locale] = locale;
|
|
652
666
|
}
|
|
653
|
-
|
|
654
|
-
// linkOverride is true (remove the else-if).
|
|
655
|
-
if (enableLinkOverridesV2) {
|
|
667
|
+
if (!disableRedirectionLinksInNewTab && (enableLinkOverridesV2 || linkOverride)) {
|
|
656
668
|
queryParams[Param.EnableLinkOverridesV2] = true;
|
|
657
669
|
queryParams[Param.LinkOverride] = true;
|
|
658
670
|
}
|
|
659
|
-
else if (linkOverride) {
|
|
660
|
-
queryParams[Param.LinkOverride] = linkOverride;
|
|
661
|
-
}
|
|
662
671
|
if (insertInToSlide) {
|
|
663
672
|
queryParams[Param.ShowInsertToSlide] = insertInToSlide;
|
|
664
673
|
}
|
|
@@ -739,8 +748,14 @@ export class TsEmbed {
|
|
|
739
748
|
iFrame.name = 'ThoughtSpot Embedded Analytics';
|
|
740
749
|
return iFrame;
|
|
741
750
|
}
|
|
751
|
+
/**
|
|
752
|
+
* Returns true if this embed instance is configured for pre-rendering.
|
|
753
|
+
*/
|
|
754
|
+
isPreRenderEmbed() {
|
|
755
|
+
return !!this.viewConfig.preRenderId;
|
|
756
|
+
}
|
|
742
757
|
handleInsertionIntoDOM(child) {
|
|
743
|
-
if (this.
|
|
758
|
+
if (this.isPreRenderEmbed()) {
|
|
744
759
|
this.insertIntoDOMForPreRender(child);
|
|
745
760
|
}
|
|
746
761
|
else {
|
|
@@ -749,6 +764,9 @@ export class TsEmbed {
|
|
|
749
764
|
if (this.insertedDomEl instanceof Node) {
|
|
750
765
|
this.insertedDomEl[this.embedNodeKey] = this;
|
|
751
766
|
}
|
|
767
|
+
if (this.preRenderWrapper) {
|
|
768
|
+
this.preRenderWrapper[this.embedNodeKey] = this;
|
|
769
|
+
}
|
|
752
770
|
}
|
|
753
771
|
/**
|
|
754
772
|
* Renders the embedded ThoughtSpot app in an iframe and sets up
|
|
@@ -853,6 +871,14 @@ export class TsEmbed {
|
|
|
853
871
|
setStyleProperties(preRenderWrapper, initialPreRenderWrapperStyle);
|
|
854
872
|
return preRenderWrapper;
|
|
855
873
|
}
|
|
874
|
+
/**
|
|
875
|
+
* Checks for an existing pre-rendered component and connects to it.
|
|
876
|
+
*
|
|
877
|
+
* If a matching pre-rendered component is found in the DOM, this method
|
|
878
|
+
* sets the internal properties of the embed object to reference it.
|
|
879
|
+
*
|
|
880
|
+
* @returns True if a connection was successfully established, false otherwise.
|
|
881
|
+
*/
|
|
856
882
|
connectPreRendered() {
|
|
857
883
|
const preRenderIds = this.getPreRenderIds();
|
|
858
884
|
const preRenderWrapperElement = document.getElementById(preRenderIds.wrapper);
|
|
@@ -863,15 +889,12 @@ export class TsEmbed {
|
|
|
863
889
|
if (this.preRenderChild instanceof HTMLIFrameElement) {
|
|
864
890
|
this.setIframeElement(this.preRenderChild);
|
|
865
891
|
}
|
|
866
|
-
this.insertedDomEl = this.preRenderWrapper;
|
|
867
892
|
this.isRendered = true;
|
|
868
893
|
}
|
|
869
|
-
return this.
|
|
894
|
+
return this.isPreRenderConnected();
|
|
870
895
|
}
|
|
871
|
-
|
|
872
|
-
return (this.
|
|
873
|
-
&& this.isPreRendered
|
|
874
|
-
&& Boolean(this.preRenderWrapper && this.preRenderChild));
|
|
896
|
+
isPreRenderConnected() {
|
|
897
|
+
return Boolean(this.preRenderWrapper && this.preRenderChild);
|
|
875
898
|
}
|
|
876
899
|
createPreRenderChild(child) {
|
|
877
900
|
var _a;
|
|
@@ -892,6 +915,23 @@ export class TsEmbed {
|
|
|
892
915
|
}
|
|
893
916
|
return divChildNode;
|
|
894
917
|
}
|
|
918
|
+
/**
|
|
919
|
+
* Creates the in-flow placeholder div inserted into the host element when
|
|
920
|
+
* showPreRender() is called. The wrapper observes this element to stay
|
|
921
|
+
* aligned with the host layout.
|
|
922
|
+
*/
|
|
923
|
+
createPreRenderPlaceholder() {
|
|
924
|
+
const placeholder = document.createElement('div');
|
|
925
|
+
const id = this.getPreRenderIds();
|
|
926
|
+
const { width: frameWidth, height: frameHeight } = this.viewConfig.frameParams || {};
|
|
927
|
+
const width = getCssDimension(frameWidth || DEFAULT_EMBED_WIDTH);
|
|
928
|
+
const height = getCssDimension(frameHeight || DEFAULT_EMBED_HEIGHT);
|
|
929
|
+
placeholder.style.width = width;
|
|
930
|
+
placeholder.style.height = height;
|
|
931
|
+
// we can improve this , lol
|
|
932
|
+
placeholder.id = id.placeHolder;
|
|
933
|
+
return placeholder;
|
|
934
|
+
}
|
|
895
935
|
insertIntoDOMForPreRender(child) {
|
|
896
936
|
const preRenderChild = this.createPreRenderChild(child);
|
|
897
937
|
const preRenderWrapper = this.createPreRenderWrapper();
|
|
@@ -901,7 +941,10 @@ export class TsEmbed {
|
|
|
901
941
|
if (preRenderChild instanceof HTMLIFrameElement) {
|
|
902
942
|
this.setIframeElement(preRenderChild);
|
|
903
943
|
}
|
|
904
|
-
this.
|
|
944
|
+
if (this.iFrame) {
|
|
945
|
+
this.iFrame.style.height = '100%';
|
|
946
|
+
this.iFrame.style.width = '100%';
|
|
947
|
+
}
|
|
905
948
|
if (this.showPreRenderByDefault) {
|
|
906
949
|
this.showPreRender();
|
|
907
950
|
}
|
|
@@ -919,19 +962,19 @@ export class TsEmbed {
|
|
|
919
962
|
div.id = TS_EMBED_ID;
|
|
920
963
|
child = div;
|
|
921
964
|
}
|
|
922
|
-
if (((_a = this.
|
|
923
|
-
this.
|
|
965
|
+
if (((_a = this.hostElement.nextElementSibling) === null || _a === void 0 ? void 0 : _a.id) === TS_EMBED_ID) {
|
|
966
|
+
this.hostElement.nextElementSibling.remove();
|
|
924
967
|
}
|
|
925
|
-
this.
|
|
968
|
+
this.hostElement.parentElement.insertBefore(child, this.hostElement.nextSibling);
|
|
926
969
|
this.insertedDomEl = child;
|
|
927
970
|
}
|
|
928
971
|
else if (typeof child === 'string') {
|
|
929
|
-
this.
|
|
930
|
-
this.insertedDomEl = this.
|
|
972
|
+
this.hostElement.innerHTML = child;
|
|
973
|
+
this.insertedDomEl = this.hostElement.children[0];
|
|
931
974
|
}
|
|
932
975
|
else {
|
|
933
|
-
this.
|
|
934
|
-
this.
|
|
976
|
+
this.hostElement.innerHTML = '';
|
|
977
|
+
this.hostElement.appendChild(child);
|
|
935
978
|
this.insertedDomEl = child;
|
|
936
979
|
}
|
|
937
980
|
}
|
|
@@ -940,14 +983,26 @@ export class TsEmbed {
|
|
|
940
983
|
* @param height The height in pixels
|
|
941
984
|
*/
|
|
942
985
|
setIFrameHeight(height) {
|
|
943
|
-
this.
|
|
986
|
+
if (this.isPreRendered) {
|
|
987
|
+
if (this.insertedDomEl) {
|
|
988
|
+
this.insertedDomEl.style.height = getCssDimension(height);
|
|
989
|
+
}
|
|
990
|
+
else if (this.preRenderWrapper) {
|
|
991
|
+
this.preRenderWrapper.style.height = getCssDimension(height);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
else {
|
|
995
|
+
// normal (non-preRender) mode: size the iframe directly
|
|
996
|
+
this.iFrame.style.height = getCssDimension(height);
|
|
997
|
+
}
|
|
944
998
|
}
|
|
945
999
|
shouldSkipEvent(eventType, data) {
|
|
946
1000
|
var _a, _b, _c;
|
|
947
1001
|
const errorType = (_a = data === null || data === void 0 ? void 0 : data.errorType) !== null && _a !== void 0 ? _a : (_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.code;
|
|
948
|
-
if (eventType === EmbedEvent.Error
|
|
949
|
-
|
|
950
|
-
|
|
1002
|
+
if (eventType === EmbedEvent.Error &&
|
|
1003
|
+
errorType === EmbedErrorCodes.HOST_EVENT_VALIDATION &&
|
|
1004
|
+
(!getHostEventsConfig(this.viewConfig).useHostEventsV2 ||
|
|
1005
|
+
getHostEventsConfig(this.viewConfig).shouldBypassPayloadValidation)) {
|
|
951
1006
|
logger.warn(`Host Event Validation failed: ${(_c = data === null || data === void 0 ? void 0 : data.data) === null || _c === void 0 ? void 0 : _c.message}`);
|
|
952
1007
|
return true;
|
|
953
1008
|
}
|
|
@@ -970,10 +1025,10 @@ export class TsEmbed {
|
|
|
970
1025
|
if (
|
|
971
1026
|
// When start status is true it trigger only start releated
|
|
972
1027
|
// payload
|
|
973
|
-
(callbackObj.options.start && dataStatus === embedEventStatus.START)
|
|
1028
|
+
(callbackObj.options.start && dataStatus === embedEventStatus.START) ||
|
|
974
1029
|
// When start status is false it trigger only end releated
|
|
975
1030
|
// payload
|
|
976
|
-
|
|
1031
|
+
(!callbackObj.options.start && dataStatus === embedEventStatus.END)) {
|
|
977
1032
|
const responder = this.createEmbedEventResponder(eventPort, eventType);
|
|
978
1033
|
callbackObj.callback(data, responder);
|
|
979
1034
|
}
|
|
@@ -1109,7 +1164,7 @@ export class TsEmbed {
|
|
|
1109
1164
|
}
|
|
1110
1165
|
getPreRenderObj() {
|
|
1111
1166
|
var _a;
|
|
1112
|
-
const embedObj = (_a = this.
|
|
1167
|
+
const embedObj = (_a = this.preRenderWrapper) === null || _a === void 0 ? void 0 : _a[this.embedNodeKey];
|
|
1113
1168
|
if (embedObj === this) {
|
|
1114
1169
|
logger.info('embedObj is same as this');
|
|
1115
1170
|
}
|
|
@@ -1184,7 +1239,7 @@ export class TsEmbed {
|
|
|
1184
1239
|
});
|
|
1185
1240
|
return null;
|
|
1186
1241
|
}
|
|
1187
|
-
// Check if iframe exists before triggering -
|
|
1242
|
+
// Check if iframe exists before triggering -
|
|
1188
1243
|
// this prevents the error when auth fails
|
|
1189
1244
|
if (!this.iFrame) {
|
|
1190
1245
|
logger.debug(`Cannot trigger ${messageType} - iframe not available (likely due to auth failure)`);
|
|
@@ -1226,7 +1281,8 @@ export class TsEmbed {
|
|
|
1226
1281
|
if (!getIsInitCalled()) {
|
|
1227
1282
|
logger.error(ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
|
|
1228
1283
|
}
|
|
1229
|
-
|
|
1284
|
+
if (this.shouldWaitForRenderPromise)
|
|
1285
|
+
await this.isReadyForRenderPromise;
|
|
1230
1286
|
this.isRendered = true;
|
|
1231
1287
|
return this;
|
|
1232
1288
|
}
|
|
@@ -1237,33 +1293,33 @@ export class TsEmbed {
|
|
|
1237
1293
|
return this.render();
|
|
1238
1294
|
}
|
|
1239
1295
|
/**
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1296
|
+
* Context object for the embedded component.
|
|
1297
|
+
* @returns {ContextObject} The current context object containing the page type and object ids.
|
|
1298
|
+
* @example
|
|
1299
|
+
* ```js
|
|
1300
|
+
* const context = await embed.getCurrentContext();
|
|
1301
|
+
* console.log(context);
|
|
1302
|
+
*
|
|
1303
|
+
* // Example output
|
|
1304
|
+
* {
|
|
1305
|
+
* stack: [
|
|
1306
|
+
* {
|
|
1307
|
+
* name: 'Liveboard',
|
|
1308
|
+
* type: ContextType.Liveboard,
|
|
1309
|
+
* objectIds: {
|
|
1310
|
+
* liveboardId: '123',
|
|
1311
|
+
* },
|
|
1312
|
+
* },
|
|
1313
|
+
* ],
|
|
1314
|
+
* currentContext: {
|
|
1315
|
+
* name: 'Liveboard',
|
|
1316
|
+
* type: ContextType.Liveboard,
|
|
1317
|
+
* objectIds: {
|
|
1318
|
+
* liveboardId: '123',
|
|
1319
|
+
* },
|
|
1320
|
+
* },
|
|
1321
|
+
* }
|
|
1322
|
+
* ```
|
|
1267
1323
|
* @version SDK: 1.45.2 | ThoughtSpot: 26.3.0.cl
|
|
1268
1324
|
*/
|
|
1269
1325
|
async getCurrentContext() {
|
|
@@ -1301,6 +1357,9 @@ export class TsEmbed {
|
|
|
1301
1357
|
this.showPreRenderByDefault = showPreRenderByDefault;
|
|
1302
1358
|
const isAlreadyRendered = this.connectPreRendered();
|
|
1303
1359
|
if (isAlreadyRendered && !replaceExistingPreRender) {
|
|
1360
|
+
if (this.showPreRenderByDefault) {
|
|
1361
|
+
this.showPreRender();
|
|
1362
|
+
}
|
|
1304
1363
|
return this;
|
|
1305
1364
|
}
|
|
1306
1365
|
return this.handleRenderForPrerender();
|
|
@@ -1336,25 +1395,28 @@ export class TsEmbed {
|
|
|
1336
1395
|
* @version SDK: 1.19.1 | ThoughtSpot: *
|
|
1337
1396
|
*/
|
|
1338
1397
|
destroy() {
|
|
1339
|
-
var _a, _b;
|
|
1398
|
+
var _a, _b, _c;
|
|
1340
1399
|
try {
|
|
1341
1400
|
this.removeFullscreenChangeHandler();
|
|
1342
1401
|
this.unsubscribeToEvents();
|
|
1402
|
+
(_a = this.preRenderWrapper) === null || _a === void 0 ? void 0 : _a.remove();
|
|
1343
1403
|
if (!this.isRendered) {
|
|
1344
1404
|
return;
|
|
1345
1405
|
}
|
|
1346
1406
|
if (!getEmbedConfig().waitForCleanupOnDestroy) {
|
|
1347
1407
|
this.trigger(HostEvent.DestroyEmbed);
|
|
1348
|
-
(
|
|
1408
|
+
(_c = (_b = this.insertedDomEl) === null || _b === void 0 ? void 0 : _b.parentNode) === null || _c === void 0 ? void 0 : _c.removeChild(this.insertedDomEl);
|
|
1349
1409
|
}
|
|
1350
1410
|
else {
|
|
1351
1411
|
const cleanupTimeout = getEmbedConfig().cleanupTimeout;
|
|
1352
1412
|
Promise.race([
|
|
1353
1413
|
this.trigger(HostEvent.DestroyEmbed),
|
|
1354
1414
|
new Promise((resolve) => setTimeout(resolve, cleanupTimeout)),
|
|
1355
|
-
])
|
|
1415
|
+
])
|
|
1416
|
+
.catch((e) => {
|
|
1356
1417
|
logger.log('Error destroying TS Embed', e);
|
|
1357
|
-
})
|
|
1418
|
+
})
|
|
1419
|
+
.finally(() => {
|
|
1358
1420
|
var _a, _b;
|
|
1359
1421
|
try {
|
|
1360
1422
|
(_b = (_a = this.insertedDomEl) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(this.insertedDomEl);
|
|
@@ -1383,56 +1445,75 @@ export class TsEmbed {
|
|
|
1383
1445
|
if (!getIsInitCalled()) {
|
|
1384
1446
|
logger.error(ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
|
|
1385
1447
|
}
|
|
1386
|
-
|
|
1448
|
+
if (this.shouldWaitForRenderPromise)
|
|
1449
|
+
await this.isReadyForRenderPromise;
|
|
1387
1450
|
const prerenderFrameSrc = this.getRootIframeSrc();
|
|
1388
1451
|
this.isRendered = true;
|
|
1389
1452
|
return this.renderIFrame(prerenderFrameSrc);
|
|
1390
1453
|
}
|
|
1391
1454
|
beforePrerenderVisible() {
|
|
1392
|
-
//
|
|
1455
|
+
// We can ignore this as its a bit expensive and the newer customers
|
|
1456
|
+
// have moved on to UpdateEmbedParams supported clusters
|
|
1457
|
+
// this.validatePreRenderViewConfig(this.viewConfig); removed in #517
|
|
1458
|
+
logger.debug('triggering UpdateEmbedParams', this.viewConfig);
|
|
1459
|
+
this.executeAfterEmbedContainerLoaded(async () => {
|
|
1460
|
+
try {
|
|
1461
|
+
const params = await this.getUpdateEmbedParamsObject();
|
|
1462
|
+
this.trigger(HostEvent.UpdateEmbedParams, params);
|
|
1463
|
+
}
|
|
1464
|
+
catch (error) {
|
|
1465
|
+
logger.error(ERROR_MESSAGE.UPDATE_PARAMS_FAILED, error);
|
|
1466
|
+
this.handleError({
|
|
1467
|
+
errorType: ErrorDetailsTypes.API,
|
|
1468
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || ERROR_MESSAGE.UPDATE_PARAMS_FAILED,
|
|
1469
|
+
code: EmbedErrorCodes.UPDATE_PARAMS_FAILED,
|
|
1470
|
+
error: (error === null || error === void 0 ? void 0 : error.message) || error,
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
});
|
|
1393
1474
|
}
|
|
1394
1475
|
/**
|
|
1395
|
-
* Displays the
|
|
1396
|
-
* If the component
|
|
1397
|
-
*
|
|
1398
|
-
*
|
|
1476
|
+
* Displays the pre-rendered component inside the host element.
|
|
1477
|
+
* If the component has not been pre-rendered yet, it initiates rendering first.
|
|
1478
|
+
* Inserts a placeholder element into the host and positions the pre-render
|
|
1479
|
+
* wrapper to overlay it.
|
|
1399
1480
|
*/
|
|
1400
1481
|
async showPreRender() {
|
|
1482
|
+
var _a;
|
|
1483
|
+
if (this.shouldWaitForRenderPromise)
|
|
1484
|
+
await this.isReadyForRenderPromise;
|
|
1401
1485
|
if (!this.viewConfig.preRenderId) {
|
|
1402
1486
|
logger.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
|
|
1403
1487
|
return this;
|
|
1404
1488
|
}
|
|
1405
|
-
if (!this.
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
// if the Embed component is not preRendered , Render it now and
|
|
1409
|
-
return this.preRender(true);
|
|
1410
|
-
}
|
|
1411
|
-
this.validatePreRenderViewConfig(this.viewConfig);
|
|
1412
|
-
logger.debug('triggering UpdateEmbedParams', this.viewConfig);
|
|
1413
|
-
this.executeAfterEmbedContainerLoaded(async () => {
|
|
1414
|
-
try {
|
|
1415
|
-
const params = await this.getUpdateEmbedParamsObject();
|
|
1416
|
-
this.trigger(HostEvent.UpdateEmbedParams, params);
|
|
1417
|
-
}
|
|
1418
|
-
catch (error) {
|
|
1419
|
-
logger.error(ERROR_MESSAGE.UPDATE_PARAMS_FAILED, error);
|
|
1420
|
-
this.handleError({
|
|
1421
|
-
errorType: ErrorDetailsTypes.API,
|
|
1422
|
-
message: (error === null || error === void 0 ? void 0 : error.message) || ERROR_MESSAGE.UPDATE_PARAMS_FAILED,
|
|
1423
|
-
code: EmbedErrorCodes.UPDATE_PARAMS_FAILED,
|
|
1424
|
-
error: (error === null || error === void 0 ? void 0 : error.message) || error,
|
|
1425
|
-
});
|
|
1426
|
-
}
|
|
1427
|
-
});
|
|
1489
|
+
if (!this.isPreRenderConnected()) {
|
|
1490
|
+
// this will call showPreRender down the line
|
|
1491
|
+
return this.preRender(true);
|
|
1428
1492
|
}
|
|
1493
|
+
this.isRendered = true;
|
|
1429
1494
|
this.beforePrerenderVisible();
|
|
1430
|
-
if (this.
|
|
1495
|
+
if (this.hostElement) {
|
|
1496
|
+
this.insertedDomEl = this.createPreRenderPlaceholder();
|
|
1497
|
+
if (this.viewConfig.fullHeight) {
|
|
1498
|
+
// If fullHeight has already sized the wrapper, seed the placeholder
|
|
1499
|
+
// with the same height so syncPreRenderStyle gets an accurate rect.
|
|
1500
|
+
const existingHeight = this.preRenderWrapper.style.height;
|
|
1501
|
+
if (existingHeight) {
|
|
1502
|
+
this.insertedDomEl.style.height = existingHeight;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
const placeHolderId = this.getPreRenderIds().placeHolder;
|
|
1506
|
+
const oldEle = this.hostElement.querySelector(`#${placeHolderId}`);
|
|
1507
|
+
if (oldEle) {
|
|
1508
|
+
this.hostElement.removeChild(oldEle);
|
|
1509
|
+
}
|
|
1510
|
+
this.hostElement.appendChild(this.insertedDomEl);
|
|
1431
1511
|
this.syncPreRenderStyle();
|
|
1432
1512
|
if (!this.viewConfig.doNotTrackPreRenderSize) {
|
|
1513
|
+
const observeTarget = (_a = this.insertedDomEl) !== null && _a !== void 0 ? _a : this.hostElement;
|
|
1433
1514
|
this.resizeObserver = new ResizeObserver((entries) => {
|
|
1434
1515
|
entries.forEach((entry) => {
|
|
1435
|
-
if (entry.contentRect && entry.target ===
|
|
1516
|
+
if (entry.contentRect && entry.target === observeTarget) {
|
|
1436
1517
|
setStyleProperties(this.preRenderWrapper, {
|
|
1437
1518
|
width: `${entry.contentRect.width}px`,
|
|
1438
1519
|
height: `${entry.contentRect.height}px`,
|
|
@@ -1440,10 +1521,15 @@ export class TsEmbed {
|
|
|
1440
1521
|
}
|
|
1441
1522
|
});
|
|
1442
1523
|
});
|
|
1443
|
-
this.resizeObserver.observe(
|
|
1524
|
+
this.resizeObserver.observe(observeTarget);
|
|
1444
1525
|
}
|
|
1445
1526
|
}
|
|
1446
|
-
removeStyleProperties(this.preRenderWrapper, [
|
|
1527
|
+
removeStyleProperties(this.preRenderWrapper, [
|
|
1528
|
+
'z-index',
|
|
1529
|
+
'opacity',
|
|
1530
|
+
'pointer-events',
|
|
1531
|
+
'overflow',
|
|
1532
|
+
]);
|
|
1447
1533
|
this.subscribeToEvents();
|
|
1448
1534
|
// Setup fullscreen change handler for prerendered components
|
|
1449
1535
|
if (this.iFrame) {
|
|
@@ -1451,6 +1537,9 @@ export class TsEmbed {
|
|
|
1451
1537
|
}
|
|
1452
1538
|
return this;
|
|
1453
1539
|
}
|
|
1540
|
+
getPreRenderPlaceHolderElement() {
|
|
1541
|
+
return this.insertedDomEl;
|
|
1542
|
+
}
|
|
1454
1543
|
/**
|
|
1455
1544
|
* Synchronizes the style properties of the PreRender component with the embedding
|
|
1456
1545
|
* element. This function adjusts the position, width, and height of the PreRender
|
|
@@ -1460,16 +1549,17 @@ export class TsEmbed {
|
|
|
1460
1549
|
* is not defined or not found.
|
|
1461
1550
|
*/
|
|
1462
1551
|
syncPreRenderStyle() {
|
|
1463
|
-
if (!this.
|
|
1552
|
+
if (!this.isPreRenderConnected() || !this.getPreRenderPlaceHolderElement()) {
|
|
1464
1553
|
logger.error(ERROR_MESSAGE.SYNC_STYLE_CALLED_BEFORE_RENDER);
|
|
1465
1554
|
return;
|
|
1466
1555
|
}
|
|
1467
|
-
const elBoundingClient = this.
|
|
1556
|
+
const elBoundingClient = this.getPreRenderPlaceHolderElement().getBoundingClientRect();
|
|
1468
1557
|
setStyleProperties(this.preRenderWrapper, {
|
|
1469
1558
|
top: `${elBoundingClient.y + window.scrollY}px`,
|
|
1470
1559
|
left: `${elBoundingClient.x + window.scrollX}px`,
|
|
1471
1560
|
width: `${elBoundingClient.width}px`,
|
|
1472
1561
|
height: `${elBoundingClient.height}px`,
|
|
1562
|
+
position: 'absolute',
|
|
1473
1563
|
});
|
|
1474
1564
|
}
|
|
1475
1565
|
/**
|
|
@@ -1477,7 +1567,8 @@ export class TsEmbed {
|
|
|
1477
1567
|
* If the component is not preRendered, it issues a warning.
|
|
1478
1568
|
*/
|
|
1479
1569
|
hidePreRender() {
|
|
1480
|
-
|
|
1570
|
+
logger.debug('HidePreRender Called');
|
|
1571
|
+
if (!this.isPreRenderConnected()) {
|
|
1481
1572
|
// if the embed component is not preRendered , nothing to hide
|
|
1482
1573
|
logger.warn('PreRender should be called before hiding it using hidePreRender.');
|
|
1483
1574
|
return;
|
|
@@ -1495,6 +1586,10 @@ export class TsEmbed {
|
|
|
1495
1586
|
if (this.resizeObserver) {
|
|
1496
1587
|
this.resizeObserver.disconnect();
|
|
1497
1588
|
}
|
|
1589
|
+
const placeHolderEle = this.getPreRenderPlaceHolderElement();
|
|
1590
|
+
if (placeHolderEle) {
|
|
1591
|
+
placeHolderEle.parentElement.removeChild(placeHolderEle);
|
|
1592
|
+
}
|
|
1498
1593
|
this.unsubscribeToEvents();
|
|
1499
1594
|
}
|
|
1500
1595
|
/**
|
|
@@ -1508,6 +1603,7 @@ export class TsEmbed {
|
|
|
1508
1603
|
return {
|
|
1509
1604
|
wrapper: `tsEmbed-pre-render-wrapper-${this.viewConfig.preRenderId}`,
|
|
1510
1605
|
child: `tsEmbed-pre-render-child-${this.viewConfig.preRenderId}`,
|
|
1606
|
+
placeHolder: `tsEmbed-pre-render-placeholder-${this.viewConfig.preRenderId}`,
|
|
1511
1607
|
};
|
|
1512
1608
|
}
|
|
1513
1609
|
/**
|