@thoughtspot/visual-embed-sdk 1.47.3 → 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.
Files changed (244) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/auth.d.ts.map +1 -1
  3. package/cjs/src/auth.js +11 -1
  4. package/cjs/src/auth.js.map +1 -1
  5. package/cjs/src/auth.spec.js +38 -0
  6. package/cjs/src/auth.spec.js.map +1 -1
  7. package/cjs/src/authToken.d.ts +2 -0
  8. package/cjs/src/authToken.d.ts.map +1 -1
  9. package/cjs/src/authToken.js +7 -5
  10. package/cjs/src/authToken.js.map +1 -1
  11. package/cjs/src/css-variables.d.ts +140 -0
  12. package/cjs/src/css-variables.d.ts.map +1 -1
  13. package/cjs/src/embed/app.d.ts +63 -2
  14. package/cjs/src/embed/app.d.ts.map +1 -1
  15. package/cjs/src/embed/app.js +57 -6
  16. package/cjs/src/embed/app.js.map +1 -1
  17. package/cjs/src/embed/app.spec.js +200 -1
  18. package/cjs/src/embed/app.spec.js.map +1 -1
  19. package/cjs/src/embed/auto-frame-renderer.js +7 -2
  20. package/cjs/src/embed/auto-frame-renderer.js.map +1 -1
  21. package/cjs/src/embed/auto-frame-renderer.spec.js +385 -6
  22. package/cjs/src/embed/auto-frame-renderer.spec.js.map +1 -1
  23. package/cjs/src/embed/base.d.ts +1 -0
  24. package/cjs/src/embed/base.d.ts.map +1 -1
  25. package/cjs/src/embed/base.js +13 -1
  26. package/cjs/src/embed/base.js.map +1 -1
  27. package/cjs/src/embed/base.spec.js +21 -0
  28. package/cjs/src/embed/base.spec.js.map +1 -1
  29. package/cjs/src/embed/bodyless-conversation.spec.js +86 -0
  30. package/cjs/src/embed/bodyless-conversation.spec.js.map +1 -1
  31. package/cjs/src/embed/conversation.d.ts +16 -1
  32. package/cjs/src/embed/conversation.d.ts.map +1 -1
  33. package/cjs/src/embed/conversation.js +5 -1
  34. package/cjs/src/embed/conversation.js.map +1 -1
  35. package/cjs/src/embed/conversation.spec.js +26 -0
  36. package/cjs/src/embed/conversation.spec.js.map +1 -1
  37. package/cjs/src/embed/liveboard.d.ts +48 -2
  38. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  39. package/cjs/src/embed/liveboard.js +48 -7
  40. package/cjs/src/embed/liveboard.js.map +1 -1
  41. package/cjs/src/embed/liveboard.spec.js +139 -1
  42. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  43. package/cjs/src/embed/spotter-viz-utils.d.ts +85 -0
  44. package/cjs/src/embed/spotter-viz-utils.d.ts.map +1 -0
  45. package/cjs/src/embed/spotter-viz-utils.js +17 -0
  46. package/cjs/src/embed/spotter-viz-utils.js.map +1 -0
  47. package/cjs/src/embed/spotter-viz-utils.spec.d.ts +2 -0
  48. package/cjs/src/embed/spotter-viz-utils.spec.d.ts.map +1 -0
  49. package/cjs/src/embed/spotter-viz-utils.spec.js +31 -0
  50. package/cjs/src/embed/spotter-viz-utils.spec.js.map +1 -0
  51. package/cjs/src/embed/ts-embed.d.ts +58 -38
  52. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  53. package/cjs/src/embed/ts-embed.js +247 -151
  54. package/cjs/src/embed/ts-embed.js.map +1 -1
  55. package/cjs/src/embed/ts-embed.spec.js +397 -122
  56. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  57. package/cjs/src/index.d.ts +2 -1
  58. package/cjs/src/index.d.ts.map +1 -1
  59. package/cjs/src/index.js.map +1 -1
  60. package/cjs/src/react/index.d.ts.map +1 -1
  61. package/cjs/src/react/index.js +3 -0
  62. package/cjs/src/react/index.js.map +1 -1
  63. package/cjs/src/tokenizedFetch.d.ts.map +1 -1
  64. package/cjs/src/tokenizedFetch.js +12 -9
  65. package/cjs/src/tokenizedFetch.js.map +1 -1
  66. package/cjs/src/tokenizedFetch.spec.d.ts +2 -0
  67. package/cjs/src/tokenizedFetch.spec.d.ts.map +1 -0
  68. package/cjs/src/tokenizedFetch.spec.js +68 -0
  69. package/cjs/src/tokenizedFetch.spec.js.map +1 -0
  70. package/cjs/src/types.d.ts +309 -40
  71. package/cjs/src/types.d.ts.map +1 -1
  72. package/cjs/src/types.js +251 -23
  73. package/cjs/src/types.js.map +1 -1
  74. package/cjs/src/utils/authService/tokenizedAuthService.spec.js +6 -7
  75. package/cjs/src/utils/authService/tokenizedAuthService.spec.js.map +1 -1
  76. package/cjs/src/utils/logger.js +2 -1
  77. package/cjs/src/utils/logger.js.map +1 -1
  78. package/cjs/src/utils/logger.spec.d.ts +1 -0
  79. package/cjs/src/utils/logger.spec.d.ts.map +1 -1
  80. package/cjs/src/utils/logger.spec.js +10 -9
  81. package/cjs/src/utils/logger.spec.js.map +1 -1
  82. package/cjs/src/utils.d.ts +4 -1
  83. package/cjs/src/utils.d.ts.map +1 -1
  84. package/cjs/src/utils.js +107 -10
  85. package/cjs/src/utils.js.map +1 -1
  86. package/cjs/src/utils.spec.js +163 -4
  87. package/cjs/src/utils.spec.js.map +1 -1
  88. package/dist/{index-DZq20cR6.js → index-_UGCSSDR.js} +1 -1
  89. package/dist/src/auth.d.ts.map +1 -1
  90. package/dist/src/authToken.d.ts +2 -0
  91. package/dist/src/authToken.d.ts.map +1 -1
  92. package/dist/src/css-variables.d.ts +140 -0
  93. package/dist/src/css-variables.d.ts.map +1 -1
  94. package/dist/src/embed/app.d.ts +63 -2
  95. package/dist/src/embed/app.d.ts.map +1 -1
  96. package/dist/src/embed/base.d.ts +1 -0
  97. package/dist/src/embed/base.d.ts.map +1 -1
  98. package/dist/src/embed/conversation.d.ts +16 -1
  99. package/dist/src/embed/conversation.d.ts.map +1 -1
  100. package/dist/src/embed/liveboard.d.ts +48 -2
  101. package/dist/src/embed/liveboard.d.ts.map +1 -1
  102. package/dist/src/embed/spotter-viz-utils.d.ts +85 -0
  103. package/dist/src/embed/spotter-viz-utils.d.ts.map +1 -0
  104. package/dist/src/embed/spotter-viz-utils.spec.d.ts +2 -0
  105. package/dist/src/embed/spotter-viz-utils.spec.d.ts.map +1 -0
  106. package/dist/src/embed/ts-embed.d.ts +58 -38
  107. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  108. package/dist/src/index.d.ts +2 -1
  109. package/dist/src/index.d.ts.map +1 -1
  110. package/dist/src/react/index.d.ts.map +1 -1
  111. package/dist/src/tokenizedFetch.d.ts.map +1 -1
  112. package/dist/src/tokenizedFetch.spec.d.ts +2 -0
  113. package/dist/src/tokenizedFetch.spec.d.ts.map +1 -0
  114. package/dist/src/types.d.ts +309 -40
  115. package/dist/src/types.d.ts.map +1 -1
  116. package/dist/src/utils/logger.spec.d.ts +1 -0
  117. package/dist/src/utils/logger.spec.d.ts.map +1 -1
  118. package/dist/src/utils.d.ts +4 -1
  119. package/dist/src/utils.d.ts.map +1 -1
  120. package/dist/tsembed-react.es.js +3418 -2899
  121. package/dist/tsembed-react.js +3420 -2901
  122. package/dist/tsembed.es.js +3426 -2905
  123. package/dist/tsembed.js +3419 -2898
  124. package/dist/visual-embed-sdk-react-full.d.ts +687 -78
  125. package/dist/visual-embed-sdk-react.d.ts +687 -78
  126. package/dist/visual-embed-sdk.d.ts +702 -80
  127. package/lib/package.json +1 -1
  128. package/lib/src/auth.d.ts.map +1 -1
  129. package/lib/src/auth.js +12 -2
  130. package/lib/src/auth.js.map +1 -1
  131. package/lib/src/auth.spec.js +38 -0
  132. package/lib/src/auth.spec.js.map +1 -1
  133. package/lib/src/authToken.d.ts +2 -0
  134. package/lib/src/authToken.d.ts.map +1 -1
  135. package/lib/src/authToken.js +2 -2
  136. package/lib/src/authToken.js.map +1 -1
  137. package/lib/src/css-variables.d.ts +140 -0
  138. package/lib/src/css-variables.d.ts.map +1 -1
  139. package/lib/src/embed/app.d.ts +63 -2
  140. package/lib/src/embed/app.d.ts.map +1 -1
  141. package/lib/src/embed/app.js +58 -7
  142. package/lib/src/embed/app.js.map +1 -1
  143. package/lib/src/embed/app.spec.js +201 -2
  144. package/lib/src/embed/app.spec.js.map +1 -1
  145. package/lib/src/embed/auto-frame-renderer.js +7 -2
  146. package/lib/src/embed/auto-frame-renderer.js.map +1 -1
  147. package/lib/src/embed/auto-frame-renderer.spec.js +387 -8
  148. package/lib/src/embed/auto-frame-renderer.spec.js.map +1 -1
  149. package/lib/src/embed/base.d.ts +1 -0
  150. package/lib/src/embed/base.d.ts.map +1 -1
  151. package/lib/src/embed/base.js +11 -0
  152. package/lib/src/embed/base.js.map +1 -1
  153. package/lib/src/embed/base.spec.js +22 -1
  154. package/lib/src/embed/base.spec.js.map +1 -1
  155. package/lib/src/embed/bodyless-conversation.spec.js +86 -0
  156. package/lib/src/embed/bodyless-conversation.spec.js.map +1 -1
  157. package/lib/src/embed/conversation.d.ts +16 -1
  158. package/lib/src/embed/conversation.d.ts.map +1 -1
  159. package/lib/src/embed/conversation.js +5 -1
  160. package/lib/src/embed/conversation.js.map +1 -1
  161. package/lib/src/embed/conversation.spec.js +27 -1
  162. package/lib/src/embed/conversation.spec.js.map +1 -1
  163. package/lib/src/embed/liveboard.d.ts +48 -2
  164. package/lib/src/embed/liveboard.d.ts.map +1 -1
  165. package/lib/src/embed/liveboard.js +49 -8
  166. package/lib/src/embed/liveboard.js.map +1 -1
  167. package/lib/src/embed/liveboard.spec.js +139 -1
  168. package/lib/src/embed/liveboard.spec.js.map +1 -1
  169. package/lib/src/embed/spotter-viz-utils.d.ts +85 -0
  170. package/lib/src/embed/spotter-viz-utils.d.ts.map +1 -0
  171. package/lib/src/embed/spotter-viz-utils.js +13 -0
  172. package/lib/src/embed/spotter-viz-utils.js.map +1 -0
  173. package/lib/src/embed/spotter-viz-utils.spec.d.ts +2 -0
  174. package/lib/src/embed/spotter-viz-utils.spec.d.ts.map +1 -0
  175. package/lib/src/embed/spotter-viz-utils.spec.js +29 -0
  176. package/lib/src/embed/spotter-viz-utils.spec.js.map +1 -0
  177. package/lib/src/embed/ts-embed.d.ts +58 -38
  178. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  179. package/lib/src/embed/ts-embed.js +250 -154
  180. package/lib/src/embed/ts-embed.js.map +1 -1
  181. package/lib/src/embed/ts-embed.spec.js +397 -122
  182. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  183. package/lib/src/index.d.ts +2 -1
  184. package/lib/src/index.d.ts.map +1 -1
  185. package/lib/src/index.js.map +1 -1
  186. package/lib/src/react/index.d.ts.map +1 -1
  187. package/lib/src/react/index.js +3 -0
  188. package/lib/src/react/index.js.map +1 -1
  189. package/lib/src/tokenizedFetch.d.ts.map +1 -1
  190. package/lib/src/tokenizedFetch.js +13 -10
  191. package/lib/src/tokenizedFetch.js.map +1 -1
  192. package/lib/src/tokenizedFetch.spec.d.ts +2 -0
  193. package/lib/src/tokenizedFetch.spec.d.ts.map +1 -0
  194. package/lib/src/tokenizedFetch.spec.js +65 -0
  195. package/lib/src/tokenizedFetch.spec.js.map +1 -0
  196. package/lib/src/types.d.ts +309 -40
  197. package/lib/src/types.d.ts.map +1 -1
  198. package/lib/src/types.js +251 -23
  199. package/lib/src/types.js.map +1 -1
  200. package/lib/src/utils/authService/tokenizedAuthService.spec.js +6 -7
  201. package/lib/src/utils/authService/tokenizedAuthService.spec.js.map +1 -1
  202. package/lib/src/utils/logger.js +2 -1
  203. package/lib/src/utils/logger.js.map +1 -1
  204. package/lib/src/utils/logger.spec.d.ts +1 -0
  205. package/lib/src/utils/logger.spec.d.ts.map +1 -1
  206. package/lib/src/utils/logger.spec.js +10 -9
  207. package/lib/src/utils/logger.spec.js.map +1 -1
  208. package/lib/src/utils.d.ts +4 -1
  209. package/lib/src/utils.d.ts.map +1 -1
  210. package/lib/src/utils.js +103 -9
  211. package/lib/src/utils.js.map +1 -1
  212. package/lib/src/utils.spec.js +164 -5
  213. package/lib/src/utils.spec.js.map +1 -1
  214. package/lib/src/visual-embed-sdk.d.ts +702 -80
  215. package/package.json +1 -1
  216. package/src/auth.spec.ts +55 -1
  217. package/src/auth.ts +11 -2
  218. package/src/authToken.ts +2 -2
  219. package/src/css-variables.ts +175 -1
  220. package/src/embed/app.spec.ts +260 -3
  221. package/src/embed/app.ts +127 -7
  222. package/src/embed/auto-frame-renderer.spec.ts +457 -58
  223. package/src/embed/auto-frame-renderer.ts +7 -2
  224. package/src/embed/base.spec.ts +25 -1
  225. package/src/embed/base.ts +19 -5
  226. package/src/embed/bodyless-conversation.spec.ts +93 -0
  227. package/src/embed/conversation.spec.ts +34 -0
  228. package/src/embed/conversation.ts +22 -1
  229. package/src/embed/liveboard.spec.ts +163 -1
  230. package/src/embed/liveboard.ts +106 -10
  231. package/src/embed/spotter-viz-utils.spec.ts +30 -0
  232. package/src/embed/spotter-viz-utils.ts +94 -0
  233. package/src/embed/ts-embed.spec.ts +564 -231
  234. package/src/embed/ts-embed.ts +384 -258
  235. package/src/index.ts +3 -0
  236. package/src/react/index.tsx +3 -0
  237. package/src/tokenizedFetch.spec.ts +81 -0
  238. package/src/tokenizedFetch.ts +14 -11
  239. package/src/types.ts +326 -36
  240. package/src/utils/authService/tokenizedAuthService.spec.ts +6 -6
  241. package/src/utils/logger.spec.ts +11 -9
  242. package/src/utils/logger.ts +2 -2
  243. package/src/utils.spec.ts +200 -4
  244. 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, isUndefined, getHostEventsConfig, } from '../utils';
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.el);
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.el);
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 : (authType === AuthType.TrustedAuthTokenCookieless);
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().then(async () => {
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
- }).catch((e) => {
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
- * @hidden
204
- * Internal state to track if the embed container is loaded.
205
- * This is used to trigger events after the embed container is loaded.
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.validatePreRenderViewConfig = (viewConfig) => {
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
- this.embedConfig = embedConfig;
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.isReadyForRenderPromise = getInitPromise().then(async () => {
269
- if (!embedConfig.authTriggerContainer && !embedConfig.useEventForSAMLPopup) {
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 = (this.viewConfig.overrideOrgId !== undefined
333
- || this.embedConfig.disablePreauthCache === true
334
- || this.isFullAppEmbedWithVisiblePrimaryNavbar());
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
- && appViewConfig.showPrimaryNavbar === true);
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({ eventData, executeEvent, viewConfig: this.viewConfig, getUnsavedAnswerTml });
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,24 +458,27 @@ export class TsEmbed {
446
458
  authToken = await getAuthenticationToken(this.embedConfig);
447
459
  }
448
460
  catch (e) {
449
- processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.el);
461
+ processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.hostElement);
450
462
  throw e;
451
463
  }
452
464
  return authToken;
453
465
  }
454
466
  async getDefaultAppInitData() {
455
- var _a, _b;
467
+ var _a, _b, _c;
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: { type: EmbedErrorCodes.CUSTOM_ACTION_VALIDATION, message: customActionsResult.errors }
478
+ error: {
479
+ type: EmbedErrorCodes.CUSTOM_ACTION_VALIDATION,
480
+ message: customActionsResult.errors,
481
+ },
467
482
  });
468
483
  }
469
484
  const baseInitData = {
@@ -484,7 +499,7 @@ export class TsEmbed {
484
499
  customVariablesForThirdPartyTools: this.embedConfig.customVariablesForThirdPartyTools || {},
485
500
  hiddenListColumns: this.viewConfig.hiddenListColumns || [],
486
501
  customActions: customActionsResult.actions,
487
- embedExpiryInAuthToken: this.viewConfig.refreshAuthTokenOnNearExpiry,
502
+ embedExpiryInAuthToken: (_c = this.viewConfig.refreshAuthTokenOnNearExpiry) !== null && _c !== void 0 ? _c : true,
488
503
  ...getInterceptInitData(this.viewConfig),
489
504
  ...getHostEventsConfig(this.viewConfig),
490
505
  };
@@ -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 : (authType === AuthType.TrustedAuthTokenCookieless);
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
- // TODO: Once V2 is stable, send both flags when
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.isPreRendered) {
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.isPreRenderAvailable();
894
+ return this.isPreRenderConnected();
870
895
  }
871
- isPreRenderAvailable() {
872
- return (this.isRendered
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.insertedDomEl = preRenderWrapper;
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.el.nextElementSibling) === null || _a === void 0 ? void 0 : _a.id) === TS_EMBED_ID) {
923
- this.el.nextElementSibling.remove();
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.el.parentElement.insertBefore(child, this.el.nextSibling);
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.el.innerHTML = child;
930
- this.insertedDomEl = this.el.children[0];
972
+ this.hostElement.innerHTML = child;
973
+ this.insertedDomEl = this.hostElement.children[0];
931
974
  }
932
975
  else {
933
- this.el.innerHTML = '';
934
- this.el.appendChild(child);
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.iFrame.style.height = getCssDimension(height);
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
- && errorType === EmbedErrorCodes.HOST_EVENT_VALIDATION
950
- && (!getHostEventsConfig(this.viewConfig).useHostEventsV2 || getHostEventsConfig(this.viewConfig).shouldBypassPayloadValidation)) {
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
- || (!callbackObj.options.start && dataStatus === embedEventStatus.END)) {
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.insertedDomEl) === null || _a === void 0 ? void 0 : _a[this.embedNodeKey];
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
- await this.isReadyForRenderPromise;
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
- * Context object for the embedded component.
1241
- * @returns {ContextObject} The current context object containing the page type and object ids.
1242
- * @example
1243
- * ```js
1244
- * const context = await embed.getCurrentContext();
1245
- * console.log(context);
1246
- *
1247
- * // Example output
1248
- * {
1249
- * stack: [
1250
- * {
1251
- * name: 'Liveboard',
1252
- * type: ContextType.Liveboard,
1253
- * objectIds: {
1254
- * liveboardId: '123',
1255
- * },
1256
- * },
1257
- * ],
1258
- * currentContext: {
1259
- * name: 'Liveboard',
1260
- * type: ContextType.Liveboard,
1261
- * objectIds: {
1262
- * liveboardId: '123',
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
- (_b = (_a = this.insertedDomEl) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(this.insertedDomEl);
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
- ]).catch((e) => {
1415
+ ])
1416
+ .catch((e) => {
1356
1417
  logger.log('Error destroying TS Embed', e);
1357
- }).finally(() => {
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
- await this.isReadyForRenderPromise;
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
- // Override in subclass
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 PreRender component.
1396
- * If the component is not preRendered, it attempts to create and render it.
1397
- * Also, synchronizes the style of the PreRender component with the embedding
1398
- * element.
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.isPreRenderAvailable()) {
1406
- const isAvailable = this.connectPreRendered();
1407
- if (!isAvailable) {
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.el) {
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 === this.el) {
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(this.el);
1524
+ this.resizeObserver.observe(observeTarget);
1444
1525
  }
1445
1526
  }
1446
- removeStyleProperties(this.preRenderWrapper, ['z-index', 'opacity', 'pointer-events', 'overflow']);
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.isPreRenderAvailable() || !this.el) {
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.el.getBoundingClientRect();
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
- if (!this.isPreRenderAvailable()) {
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
  /**