@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.
Files changed (201) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/css-variables.d.ts +140 -0
  3. package/cjs/src/css-variables.d.ts.map +1 -1
  4. package/cjs/src/embed/app.d.ts +62 -1
  5. package/cjs/src/embed/app.d.ts.map +1 -1
  6. package/cjs/src/embed/app.js +57 -6
  7. package/cjs/src/embed/app.js.map +1 -1
  8. package/cjs/src/embed/app.spec.js +191 -1
  9. package/cjs/src/embed/app.spec.js.map +1 -1
  10. package/cjs/src/embed/auto-frame-renderer.js +7 -2
  11. package/cjs/src/embed/auto-frame-renderer.js.map +1 -1
  12. package/cjs/src/embed/auto-frame-renderer.spec.js +385 -6
  13. package/cjs/src/embed/auto-frame-renderer.spec.js.map +1 -1
  14. package/cjs/src/embed/base.d.ts +1 -0
  15. package/cjs/src/embed/base.d.ts.map +1 -1
  16. package/cjs/src/embed/base.js +13 -1
  17. package/cjs/src/embed/base.js.map +1 -1
  18. package/cjs/src/embed/base.spec.js +21 -0
  19. package/cjs/src/embed/base.spec.js.map +1 -1
  20. package/cjs/src/embed/bodyless-conversation.spec.js +86 -0
  21. package/cjs/src/embed/bodyless-conversation.spec.js.map +1 -1
  22. package/cjs/src/embed/conversation.d.ts +16 -1
  23. package/cjs/src/embed/conversation.d.ts.map +1 -1
  24. package/cjs/src/embed/conversation.js +5 -1
  25. package/cjs/src/embed/conversation.js.map +1 -1
  26. package/cjs/src/embed/conversation.spec.js +26 -0
  27. package/cjs/src/embed/conversation.spec.js.map +1 -1
  28. package/cjs/src/embed/liveboard.d.ts +47 -1
  29. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  30. package/cjs/src/embed/liveboard.js +47 -6
  31. package/cjs/src/embed/liveboard.js.map +1 -1
  32. package/cjs/src/embed/liveboard.spec.js +129 -1
  33. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  34. package/cjs/src/embed/spotter-viz-utils.d.ts +85 -0
  35. package/cjs/src/embed/spotter-viz-utils.d.ts.map +1 -0
  36. package/cjs/src/embed/spotter-viz-utils.js +17 -0
  37. package/cjs/src/embed/spotter-viz-utils.js.map +1 -0
  38. package/cjs/src/embed/spotter-viz-utils.spec.d.ts +2 -0
  39. package/cjs/src/embed/spotter-viz-utils.spec.d.ts.map +1 -0
  40. package/cjs/src/embed/spotter-viz-utils.spec.js +31 -0
  41. package/cjs/src/embed/spotter-viz-utils.spec.js.map +1 -0
  42. package/cjs/src/embed/ts-embed.d.ts +58 -38
  43. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  44. package/cjs/src/embed/ts-embed.js +245 -149
  45. package/cjs/src/embed/ts-embed.js.map +1 -1
  46. package/cjs/src/embed/ts-embed.spec.js +369 -123
  47. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  48. package/cjs/src/index.d.ts +2 -1
  49. package/cjs/src/index.d.ts.map +1 -1
  50. package/cjs/src/index.js.map +1 -1
  51. package/cjs/src/react/index.d.ts.map +1 -1
  52. package/cjs/src/react/index.js +3 -0
  53. package/cjs/src/react/index.js.map +1 -1
  54. package/cjs/src/types.d.ts +267 -27
  55. package/cjs/src/types.d.ts.map +1 -1
  56. package/cjs/src/types.js +223 -19
  57. package/cjs/src/types.js.map +1 -1
  58. package/cjs/src/utils/authService/tokenizedAuthService.spec.js +6 -7
  59. package/cjs/src/utils/authService/tokenizedAuthService.spec.js.map +1 -1
  60. package/cjs/src/utils/logger.js +2 -1
  61. package/cjs/src/utils/logger.js.map +1 -1
  62. package/cjs/src/utils/logger.spec.d.ts +1 -0
  63. package/cjs/src/utils/logger.spec.d.ts.map +1 -1
  64. package/cjs/src/utils/logger.spec.js +10 -9
  65. package/cjs/src/utils/logger.spec.js.map +1 -1
  66. package/cjs/src/utils.d.ts +4 -1
  67. package/cjs/src/utils.d.ts.map +1 -1
  68. package/cjs/src/utils.js +107 -10
  69. package/cjs/src/utils.js.map +1 -1
  70. package/cjs/src/utils.spec.js +163 -4
  71. package/cjs/src/utils.spec.js.map +1 -1
  72. package/dist/{index-Ck-r09gt.js → index-_UGCSSDR.js} +1 -1
  73. package/dist/src/css-variables.d.ts +140 -0
  74. package/dist/src/css-variables.d.ts.map +1 -1
  75. package/dist/src/embed/app.d.ts +62 -1
  76. package/dist/src/embed/app.d.ts.map +1 -1
  77. package/dist/src/embed/base.d.ts +1 -0
  78. package/dist/src/embed/base.d.ts.map +1 -1
  79. package/dist/src/embed/conversation.d.ts +16 -1
  80. package/dist/src/embed/conversation.d.ts.map +1 -1
  81. package/dist/src/embed/liveboard.d.ts +47 -1
  82. package/dist/src/embed/liveboard.d.ts.map +1 -1
  83. package/dist/src/embed/spotter-viz-utils.d.ts +85 -0
  84. package/dist/src/embed/spotter-viz-utils.d.ts.map +1 -0
  85. package/dist/src/embed/spotter-viz-utils.spec.d.ts +2 -0
  86. package/dist/src/embed/spotter-viz-utils.spec.d.ts.map +1 -0
  87. package/dist/src/embed/ts-embed.d.ts +58 -38
  88. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  89. package/dist/src/index.d.ts +2 -1
  90. package/dist/src/index.d.ts.map +1 -1
  91. package/dist/src/react/index.d.ts.map +1 -1
  92. package/dist/src/types.d.ts +267 -27
  93. package/dist/src/types.d.ts.map +1 -1
  94. package/dist/src/utils/logger.spec.d.ts +1 -0
  95. package/dist/src/utils/logger.spec.d.ts.map +1 -1
  96. package/dist/src/utils.d.ts +4 -1
  97. package/dist/src/utils.d.ts.map +1 -1
  98. package/dist/tsembed-react.es.js +3708 -3226
  99. package/dist/tsembed-react.js +3358 -2876
  100. package/dist/tsembed.es.js +3713 -3229
  101. package/dist/tsembed.js +3708 -3224
  102. package/dist/visual-embed-sdk-react-full.d.ts +643 -63
  103. package/dist/visual-embed-sdk-react.d.ts +643 -63
  104. package/dist/visual-embed-sdk.d.ts +658 -65
  105. package/lib/package.json +1 -1
  106. package/lib/src/css-variables.d.ts +140 -0
  107. package/lib/src/css-variables.d.ts.map +1 -1
  108. package/lib/src/embed/app.d.ts +62 -1
  109. package/lib/src/embed/app.d.ts.map +1 -1
  110. package/lib/src/embed/app.js +58 -7
  111. package/lib/src/embed/app.js.map +1 -1
  112. package/lib/src/embed/app.spec.js +192 -2
  113. package/lib/src/embed/app.spec.js.map +1 -1
  114. package/lib/src/embed/auto-frame-renderer.js +7 -2
  115. package/lib/src/embed/auto-frame-renderer.js.map +1 -1
  116. package/lib/src/embed/auto-frame-renderer.spec.js +387 -8
  117. package/lib/src/embed/auto-frame-renderer.spec.js.map +1 -1
  118. package/lib/src/embed/base.d.ts +1 -0
  119. package/lib/src/embed/base.d.ts.map +1 -1
  120. package/lib/src/embed/base.js +11 -0
  121. package/lib/src/embed/base.js.map +1 -1
  122. package/lib/src/embed/base.spec.js +22 -1
  123. package/lib/src/embed/base.spec.js.map +1 -1
  124. package/lib/src/embed/bodyless-conversation.spec.js +86 -0
  125. package/lib/src/embed/bodyless-conversation.spec.js.map +1 -1
  126. package/lib/src/embed/conversation.d.ts +16 -1
  127. package/lib/src/embed/conversation.d.ts.map +1 -1
  128. package/lib/src/embed/conversation.js +5 -1
  129. package/lib/src/embed/conversation.js.map +1 -1
  130. package/lib/src/embed/conversation.spec.js +27 -1
  131. package/lib/src/embed/conversation.spec.js.map +1 -1
  132. package/lib/src/embed/liveboard.d.ts +47 -1
  133. package/lib/src/embed/liveboard.d.ts.map +1 -1
  134. package/lib/src/embed/liveboard.js +48 -7
  135. package/lib/src/embed/liveboard.js.map +1 -1
  136. package/lib/src/embed/liveboard.spec.js +129 -1
  137. package/lib/src/embed/liveboard.spec.js.map +1 -1
  138. package/lib/src/embed/spotter-viz-utils.d.ts +85 -0
  139. package/lib/src/embed/spotter-viz-utils.d.ts.map +1 -0
  140. package/lib/src/embed/spotter-viz-utils.js +13 -0
  141. package/lib/src/embed/spotter-viz-utils.js.map +1 -0
  142. package/lib/src/embed/spotter-viz-utils.spec.d.ts +2 -0
  143. package/lib/src/embed/spotter-viz-utils.spec.d.ts.map +1 -0
  144. package/lib/src/embed/spotter-viz-utils.spec.js +29 -0
  145. package/lib/src/embed/spotter-viz-utils.spec.js.map +1 -0
  146. package/lib/src/embed/ts-embed.d.ts +58 -38
  147. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  148. package/lib/src/embed/ts-embed.js +248 -152
  149. package/lib/src/embed/ts-embed.js.map +1 -1
  150. package/lib/src/embed/ts-embed.spec.js +369 -123
  151. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  152. package/lib/src/index.d.ts +2 -1
  153. package/lib/src/index.d.ts.map +1 -1
  154. package/lib/src/index.js.map +1 -1
  155. package/lib/src/react/index.d.ts.map +1 -1
  156. package/lib/src/react/index.js +3 -0
  157. package/lib/src/react/index.js.map +1 -1
  158. package/lib/src/types.d.ts +267 -27
  159. package/lib/src/types.d.ts.map +1 -1
  160. package/lib/src/types.js +223 -19
  161. package/lib/src/types.js.map +1 -1
  162. package/lib/src/utils/authService/tokenizedAuthService.spec.js +6 -7
  163. package/lib/src/utils/authService/tokenizedAuthService.spec.js.map +1 -1
  164. package/lib/src/utils/logger.js +2 -1
  165. package/lib/src/utils/logger.js.map +1 -1
  166. package/lib/src/utils/logger.spec.d.ts +1 -0
  167. package/lib/src/utils/logger.spec.d.ts.map +1 -1
  168. package/lib/src/utils/logger.spec.js +10 -9
  169. package/lib/src/utils/logger.spec.js.map +1 -1
  170. package/lib/src/utils.d.ts +4 -1
  171. package/lib/src/utils.d.ts.map +1 -1
  172. package/lib/src/utils.js +103 -9
  173. package/lib/src/utils.js.map +1 -1
  174. package/lib/src/utils.spec.js +164 -5
  175. package/lib/src/utils.spec.js.map +1 -1
  176. package/lib/src/visual-embed-sdk.d.ts +658 -65
  177. package/package.json +1 -1
  178. package/src/css-variables.ts +175 -1
  179. package/src/embed/app.spec.ts +247 -3
  180. package/src/embed/app.ts +125 -5
  181. package/src/embed/auto-frame-renderer.spec.ts +457 -58
  182. package/src/embed/auto-frame-renderer.ts +7 -2
  183. package/src/embed/base.spec.ts +25 -1
  184. package/src/embed/base.ts +19 -5
  185. package/src/embed/bodyless-conversation.spec.ts +93 -0
  186. package/src/embed/conversation.spec.ts +34 -0
  187. package/src/embed/conversation.ts +22 -1
  188. package/src/embed/liveboard.spec.ts +149 -1
  189. package/src/embed/liveboard.ts +102 -6
  190. package/src/embed/spotter-viz-utils.spec.ts +30 -0
  191. package/src/embed/spotter-viz-utils.ts +94 -0
  192. package/src/embed/ts-embed.spec.ts +532 -234
  193. package/src/embed/ts-embed.ts +383 -257
  194. package/src/index.ts +3 -0
  195. package/src/react/index.tsx +3 -0
  196. package/src/types.ts +284 -23
  197. package/src/utils/authService/tokenizedAuthService.spec.ts +6 -6
  198. package/src/utils/logger.spec.ts +11 -9
  199. package/src/utils/logger.ts +2 -2
  200. package/src/utils.spec.ts +200 -4
  201. package/src/utils.ts +128 -9
@@ -9,7 +9,6 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.V1Embed = exports.TsEmbed = exports.THOUGHTSPOT_PARAM_PREFIX = void 0;
11
11
  const tslib_1 = require("tslib");
12
- const isEqual_1 = tslib_1.__importDefault(require("lodash/isEqual"));
13
12
  const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
14
13
  const isObject_1 = tslib_1.__importDefault(require("lodash/isObject"));
15
14
  const contracts_1 = require("./hostEventClient/contracts");
@@ -80,7 +79,7 @@ class TsEmbed {
80
79
  const eventPort = this.getEventPort(event);
81
80
  const eventData = this.formatEventData(event, eventType);
82
81
  if (event.source === this.iFrame.contentWindow) {
83
- const processedEventData = (0, processData_1.processEventData)(eventType, eventData, this.thoughtSpotHost, this.isPreRendered ? this.preRenderWrapper : this.el);
82
+ const processedEventData = (0, processData_1.processEventData)(eventType, eventData, this.thoughtSpotHost, this.isPreRendered ? this.preRenderWrapper : this.hostElement);
84
83
  if (eventType === types_1.EmbedEvent.ApiIntercept) {
85
84
  this.handleApiInterceptEvent({ eventData, eventPort });
86
85
  return;
@@ -108,7 +107,7 @@ class TsEmbed {
108
107
  };
109
108
  this.handleAuthFailure = (error) => {
110
109
  logger_1.logger.error(`${errors_1.ERROR_MESSAGE.INVALID_TOKEN_ERROR} Error : ${error === null || error === void 0 ? void 0 : error.message}`);
111
- (0, processData_1.processAuthFailure)(error, this.isPreRendered ? this.preRenderWrapper : this.el);
110
+ (0, processData_1.processAuthFailure)(error, this.isPreRendered ? this.preRenderWrapper : this.hostElement);
112
111
  };
113
112
  /**
114
113
  * Refresh the auth token if the autoLogin is true and the authType is TrustedAuthTokenCookieless
@@ -132,7 +131,7 @@ class TsEmbed {
132
131
  const { authType, autoLogin: autoLoginConfig } = this.embedConfig;
133
132
  // Default autoLogin: true for cookieless if undefined/null, otherwise
134
133
  // false
135
- const autoLogin = autoLoginConfig !== null && autoLoginConfig !== void 0 ? autoLoginConfig : (authType === types_1.AuthType.TrustedAuthTokenCookieless);
134
+ const autoLogin = autoLoginConfig !== null && autoLoginConfig !== void 0 ? autoLoginConfig : authType === types_1.AuthType.TrustedAuthTokenCookieless;
136
135
  try {
137
136
  await this.refreshAuthTokenForCookieless(responder, types_1.EmbedEvent.AuthExpire, false);
138
137
  }
@@ -150,7 +149,8 @@ class TsEmbed {
150
149
  * @param responder
151
150
  */
152
151
  this.idleSessionTimeout = (_, responder) => {
153
- (0, base_1.handleAuth)().then(async () => {
152
+ (0, base_1.handleAuth)()
153
+ .then(async () => {
154
154
  let authToken = '';
155
155
  try {
156
156
  authToken = await (0, authToken_1.getAuthenticationToken)(this.embedConfig);
@@ -162,7 +162,8 @@ class TsEmbed {
162
162
  catch (e) {
163
163
  this.handleAuthFailure(e);
164
164
  }
165
- }).catch((e) => {
165
+ })
166
+ .catch((e) => {
166
167
  logger_1.logger.error(`Auto Login failed, Error : ${e === null || e === void 0 ? void 0 : e.message}`);
167
168
  });
168
169
  (0, base_1.notifyAuthFailure)(auth_1.AuthFailureType.IDLE_SESSION_TIMEOUT);
@@ -204,10 +205,10 @@ class TsEmbed {
204
205
  };
205
206
  };
206
207
  /**
207
- * @hidden
208
- * Internal state to track if the embed container is loaded.
209
- * This is used to trigger events after the embed container is loaded.
210
- */
208
+ * @hidden
209
+ * Internal state to track if the embed container is loaded.
210
+ * This is used to trigger events after the embed container is loaded.
211
+ */
211
212
  this.isEmbedContainerLoaded = false;
212
213
  /**
213
214
  * @hidden
@@ -233,28 +234,7 @@ class TsEmbed {
233
234
  processEmbedContainerReady();
234
235
  }
235
236
  };
236
- this.validatePreRenderViewConfig = (viewConfig) => {
237
- var _a;
238
- const preRenderAllowedKeys = ['preRenderId', 'vizId', 'liveboardId'];
239
- const preRenderedObject = (_a = this.insertedDomEl) === null || _a === void 0 ? void 0 : _a[this.embedNodeKey];
240
- if (!preRenderedObject)
241
- return;
242
- if (viewConfig.preRenderId) {
243
- const allOtherKeys = Object.keys(viewConfig).filter((key) => !preRenderAllowedKeys.includes(key) && !key.startsWith('on'));
244
- allOtherKeys.forEach((key) => {
245
- if (!(0, utils_1.isUndefined)(viewConfig[key])
246
- && !(0, isEqual_1.default)(viewConfig[key], preRenderedObject.viewConfig[key])) {
247
- logger_1.logger.warn(`${viewConfig.embedComponentType || 'Component'} was pre-rendered with `
248
- + `"${key}" as "${JSON.stringify(preRenderedObject.viewConfig[key])}" `
249
- + `but a different value "${JSON.stringify(viewConfig[key])}" `
250
- + 'was passed to the Embed component. '
251
- + 'The new value provided is ignored, the value provided during '
252
- + 'preRender is used.');
253
- }
254
- });
255
- }
256
- };
257
- this.el = (0, utils_1.getDOMNode)(domSelector);
237
+ this.hostElement = (0, utils_1.getDOMNode)(domSelector);
258
238
  this.eventHandlerMap = new Map();
259
239
  this.isError = false;
260
240
  this.viewConfig = {
@@ -267,16 +247,43 @@ class TsEmbed {
267
247
  ...viewConfig,
268
248
  });
269
249
  const embedConfig = (0, embedConfig_1.getEmbedConfig)();
270
- this.embedConfig = embedConfig;
250
+ if (embedConfig) {
251
+ this.embedConfig = embedConfig;
252
+ this.thoughtSpotHost = (0, config_1.getThoughtSpotHost)(embedConfig);
253
+ this.thoughtSpotV2Base = (0, config_1.getV2BasePath)(embedConfig);
254
+ }
271
255
  this.hostEventClient = new host_event_client_1.HostEventClient(this.iFrame);
272
- this.isReadyForRenderPromise = (0, base_1.getInitPromise)().then(async () => {
273
- if (!embedConfig.authTriggerContainer && !embedConfig.useEventForSAMLPopup) {
256
+ this.shouldWaitForRenderPromise = !(0, base_1.getIsInitCompleted)();
257
+ const afterInit = () => {
258
+ // Prefer the config captured at construction time; fall back to
259
+ // getEmbedConfig() for the case where init()
260
+ // hadn't been called yet.
261
+ this.embedConfig = embedConfig !== null && embedConfig !== void 0 ? embedConfig : (0, embedConfig_1.getEmbedConfig)();
262
+ if (!this.embedConfig) {
263
+ logger_1.logger.error('embedConfig unavailable in afterInit; init() may not have completed');
264
+ return;
265
+ }
266
+ if (!this.embedConfig.authTriggerContainer && !this.embedConfig.useEventForSAMLPopup) {
274
267
  this.embedConfig.authTriggerContainer = domSelector;
275
268
  }
276
- this.thoughtSpotHost = (0, config_1.getThoughtSpotHost)(embedConfig);
277
- this.thoughtSpotV2Base = (0, config_1.getV2BasePath)(embedConfig);
278
- this.shouldEncodeUrlQueryParams = embedConfig.shouldEncodeUrlQueryParams;
279
- });
269
+ this.thoughtSpotHost = (0, config_1.getThoughtSpotHost)(this.embedConfig);
270
+ this.thoughtSpotV2Base = (0, config_1.getV2BasePath)(this.embedConfig);
271
+ this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
272
+ };
273
+ if (!this.shouldWaitForRenderPromise) {
274
+ afterInit();
275
+ }
276
+ else {
277
+ this.isReadyForRenderPromise = (0, base_1.getInitPromise)()
278
+ .then(afterInit)
279
+ .catch((err) => {
280
+ logger_1.logger.error('SDK init failed before embed could be configured', err);
281
+ this.throwInitError();
282
+ })
283
+ .finally(() => {
284
+ this.shouldWaitForRenderPromise = false;
285
+ });
286
+ }
280
287
  }
281
288
  /**
282
289
  * Throws error encountered during initialization.
@@ -333,9 +340,9 @@ class TsEmbed {
333
340
  // 3. FullAppEmbed has primary navbar visible since:
334
341
  // - primary navbar requires fresh auth state for navigation
335
342
  // - cached auth may not reflect current user permissions
336
- const isDisabled = (this.viewConfig.overrideOrgId !== undefined
337
- || this.embedConfig.disablePreauthCache === true
338
- || this.isFullAppEmbedWithVisiblePrimaryNavbar());
343
+ const isDisabled = this.viewConfig.overrideOrgId !== undefined ||
344
+ this.embedConfig.disablePreauthCache === true ||
345
+ this.isFullAppEmbedWithVisiblePrimaryNavbar();
339
346
  return !isDisabled;
340
347
  }
341
348
  /**
@@ -346,8 +353,8 @@ class TsEmbed {
346
353
  const appViewConfig = this.viewConfig;
347
354
  // Check if this is a FullAppEmbed (AppEmbed)
348
355
  // showPrimaryNavbar defaults to true if not explicitly set to false
349
- return (appViewConfig.embedComponentType === 'AppEmbed'
350
- && appViewConfig.showPrimaryNavbar === true);
356
+ return (appViewConfig.embedComponentType === 'AppEmbed' &&
357
+ appViewConfig.showPrimaryNavbar === true);
351
358
  }
352
359
  /**
353
360
  * fix for ts7.sep.cl
@@ -390,7 +397,7 @@ class TsEmbed {
390
397
  this.subscribedListeners.online = onlineEventListener;
391
398
  this.subscribedListeners.offline = offlineEventListener;
392
399
  }
393
- handleApiInterceptEvent({ eventData, eventPort }) {
400
+ handleApiInterceptEvent({ eventData, eventPort, }) {
394
401
  const executeEvent = (_eventType, data) => {
395
402
  this.executeCallbacks(_eventType, data, eventPort);
396
403
  };
@@ -399,7 +406,12 @@ class TsEmbed {
399
406
  const response = await this.triggerUIPassThrough(contracts_1.UIPassthroughEvent.GetUnsavedAnswerTML, props);
400
407
  return (_b = (_a = response.filter((item) => item.value)) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.value;
401
408
  };
402
- (0, api_intercept_1.handleInterceptEvent)({ eventData, executeEvent, viewConfig: this.viewConfig, getUnsavedAnswerTml });
409
+ (0, api_intercept_1.handleInterceptEvent)({
410
+ eventData,
411
+ executeEvent,
412
+ viewConfig: this.viewConfig,
413
+ getUnsavedAnswerTml,
414
+ });
403
415
  }
404
416
  /**
405
417
  * Subscribe to message events that depend on successful iframe setup
@@ -450,7 +462,7 @@ class TsEmbed {
450
462
  authToken = await (0, authToken_1.getAuthenticationToken)(this.embedConfig);
451
463
  }
452
464
  catch (e) {
453
- (0, processData_1.processAuthFailure)(e, this.isPreRendered ? this.preRenderWrapper : this.el);
465
+ (0, processData_1.processAuthFailure)(e, this.isPreRendered ? this.preRenderWrapper : this.hostElement);
454
466
  throw e;
455
467
  }
456
468
  return authToken;
@@ -460,14 +472,17 @@ class TsEmbed {
460
472
  const authToken = await this.getAuthTokenForCookielessInit();
461
473
  const customActionsResult = (0, custom_actions_1.getCustomActions)([
462
474
  ...(this.viewConfig.customActions || []),
463
- ...(this.embedConfig.customActions || [])
475
+ ...(this.embedConfig.customActions || []),
464
476
  ]);
465
477
  if (customActionsResult.errors.length > 0) {
466
478
  this.handleError({
467
479
  errorType: types_1.ErrorDetailsTypes.VALIDATION_ERROR,
468
480
  message: customActionsResult.errors,
469
481
  code: types_1.EmbedErrorCodes.CUSTOM_ACTION_VALIDATION,
470
- error: { type: types_1.EmbedErrorCodes.CUSTOM_ACTION_VALIDATION, message: customActionsResult.errors }
482
+ error: {
483
+ type: types_1.EmbedErrorCodes.CUSTOM_ACTION_VALIDATION,
484
+ message: customActionsResult.errors,
485
+ },
471
486
  });
472
487
  }
473
488
  const baseInitData = {
@@ -506,7 +521,7 @@ class TsEmbed {
506
521
  */
507
522
  async refreshAuthTokenForCookieless(responder, eventType, forceRefresh = false) {
508
523
  const { authType, autoLogin } = this.embedConfig;
509
- const isAutoLoginTrue = autoLogin !== null && autoLogin !== void 0 ? autoLogin : (authType === types_1.AuthType.TrustedAuthTokenCookieless);
524
+ const isAutoLoginTrue = autoLogin !== null && autoLogin !== void 0 ? autoLogin : authType === types_1.AuthType.TrustedAuthTokenCookieless;
510
525
  if (isAutoLoginTrue && authType === types_1.AuthType.TrustedAuthTokenCookieless) {
511
526
  const authToken = await (0, authToken_1.getAuthenticationToken)(this.embedConfig, forceRefresh);
512
527
  responder({
@@ -643,8 +658,7 @@ class TsEmbed {
643
658
  if (spriteUrl) {
644
659
  queryParams[types_1.Param.IconSpriteUrl] = spriteUrl.replace('https://', '');
645
660
  }
646
- const stringIDsUrl = ((_c = customizations === null || customizations === void 0 ? void 0 : customizations.content) === null || _c === void 0 ? void 0 : _c.stringIDsUrl)
647
- || ((_d = embedCustomizations === null || embedCustomizations === void 0 ? void 0 : embedCustomizations.content) === null || _d === void 0 ? void 0 : _d.stringIDsUrl);
661
+ 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);
648
662
  if (stringIDsUrl) {
649
663
  queryParams[types_1.Param.StringIDsUrl] = stringIDsUrl;
650
664
  }
@@ -654,15 +668,10 @@ class TsEmbed {
654
668
  if (locale !== undefined) {
655
669
  queryParams[types_1.Param.Locale] = locale;
656
670
  }
657
- // TODO: Once V2 is stable, send both flags when
658
- // linkOverride is true (remove the else-if).
659
- if (enableLinkOverridesV2) {
671
+ if (!disableRedirectionLinksInNewTab && (enableLinkOverridesV2 || linkOverride)) {
660
672
  queryParams[types_1.Param.EnableLinkOverridesV2] = true;
661
673
  queryParams[types_1.Param.LinkOverride] = true;
662
674
  }
663
- else if (linkOverride) {
664
- queryParams[types_1.Param.LinkOverride] = linkOverride;
665
- }
666
675
  if (insertInToSlide) {
667
676
  queryParams[types_1.Param.ShowInsertToSlide] = insertInToSlide;
668
677
  }
@@ -743,8 +752,14 @@ class TsEmbed {
743
752
  iFrame.name = 'ThoughtSpot Embedded Analytics';
744
753
  return iFrame;
745
754
  }
755
+ /**
756
+ * Returns true if this embed instance is configured for pre-rendering.
757
+ */
758
+ isPreRenderEmbed() {
759
+ return !!this.viewConfig.preRenderId;
760
+ }
746
761
  handleInsertionIntoDOM(child) {
747
- if (this.isPreRendered) {
762
+ if (this.isPreRenderEmbed()) {
748
763
  this.insertIntoDOMForPreRender(child);
749
764
  }
750
765
  else {
@@ -753,6 +768,9 @@ class TsEmbed {
753
768
  if (this.insertedDomEl instanceof Node) {
754
769
  this.insertedDomEl[this.embedNodeKey] = this;
755
770
  }
771
+ if (this.preRenderWrapper) {
772
+ this.preRenderWrapper[this.embedNodeKey] = this;
773
+ }
756
774
  }
757
775
  /**
758
776
  * Renders the embedded ThoughtSpot app in an iframe and sets up
@@ -857,6 +875,14 @@ class TsEmbed {
857
875
  (0, utils_1.setStyleProperties)(preRenderWrapper, initialPreRenderWrapperStyle);
858
876
  return preRenderWrapper;
859
877
  }
878
+ /**
879
+ * Checks for an existing pre-rendered component and connects to it.
880
+ *
881
+ * If a matching pre-rendered component is found in the DOM, this method
882
+ * sets the internal properties of the embed object to reference it.
883
+ *
884
+ * @returns True if a connection was successfully established, false otherwise.
885
+ */
860
886
  connectPreRendered() {
861
887
  const preRenderIds = this.getPreRenderIds();
862
888
  const preRenderWrapperElement = document.getElementById(preRenderIds.wrapper);
@@ -867,15 +893,12 @@ class TsEmbed {
867
893
  if (this.preRenderChild instanceof HTMLIFrameElement) {
868
894
  this.setIframeElement(this.preRenderChild);
869
895
  }
870
- this.insertedDomEl = this.preRenderWrapper;
871
896
  this.isRendered = true;
872
897
  }
873
- return this.isPreRenderAvailable();
898
+ return this.isPreRenderConnected();
874
899
  }
875
- isPreRenderAvailable() {
876
- return (this.isRendered
877
- && this.isPreRendered
878
- && Boolean(this.preRenderWrapper && this.preRenderChild));
900
+ isPreRenderConnected() {
901
+ return Boolean(this.preRenderWrapper && this.preRenderChild);
879
902
  }
880
903
  createPreRenderChild(child) {
881
904
  var _a;
@@ -896,6 +919,23 @@ class TsEmbed {
896
919
  }
897
920
  return divChildNode;
898
921
  }
922
+ /**
923
+ * Creates the in-flow placeholder div inserted into the host element when
924
+ * showPreRender() is called. The wrapper observes this element to stay
925
+ * aligned with the host layout.
926
+ */
927
+ createPreRenderPlaceholder() {
928
+ const placeholder = document.createElement('div');
929
+ const id = this.getPreRenderIds();
930
+ const { width: frameWidth, height: frameHeight } = this.viewConfig.frameParams || {};
931
+ const width = (0, utils_1.getCssDimension)(frameWidth || config_1.DEFAULT_EMBED_WIDTH);
932
+ const height = (0, utils_1.getCssDimension)(frameHeight || config_1.DEFAULT_EMBED_HEIGHT);
933
+ placeholder.style.width = width;
934
+ placeholder.style.height = height;
935
+ // we can improve this , lol
936
+ placeholder.id = id.placeHolder;
937
+ return placeholder;
938
+ }
899
939
  insertIntoDOMForPreRender(child) {
900
940
  const preRenderChild = this.createPreRenderChild(child);
901
941
  const preRenderWrapper = this.createPreRenderWrapper();
@@ -905,7 +945,10 @@ class TsEmbed {
905
945
  if (preRenderChild instanceof HTMLIFrameElement) {
906
946
  this.setIframeElement(preRenderChild);
907
947
  }
908
- this.insertedDomEl = preRenderWrapper;
948
+ if (this.iFrame) {
949
+ this.iFrame.style.height = '100%';
950
+ this.iFrame.style.width = '100%';
951
+ }
909
952
  if (this.showPreRenderByDefault) {
910
953
  this.showPreRender();
911
954
  }
@@ -923,19 +966,19 @@ class TsEmbed {
923
966
  div.id = TS_EMBED_ID;
924
967
  child = div;
925
968
  }
926
- if (((_a = this.el.nextElementSibling) === null || _a === void 0 ? void 0 : _a.id) === TS_EMBED_ID) {
927
- this.el.nextElementSibling.remove();
969
+ if (((_a = this.hostElement.nextElementSibling) === null || _a === void 0 ? void 0 : _a.id) === TS_EMBED_ID) {
970
+ this.hostElement.nextElementSibling.remove();
928
971
  }
929
- this.el.parentElement.insertBefore(child, this.el.nextSibling);
972
+ this.hostElement.parentElement.insertBefore(child, this.hostElement.nextSibling);
930
973
  this.insertedDomEl = child;
931
974
  }
932
975
  else if (typeof child === 'string') {
933
- this.el.innerHTML = child;
934
- this.insertedDomEl = this.el.children[0];
976
+ this.hostElement.innerHTML = child;
977
+ this.insertedDomEl = this.hostElement.children[0];
935
978
  }
936
979
  else {
937
- this.el.innerHTML = '';
938
- this.el.appendChild(child);
980
+ this.hostElement.innerHTML = '';
981
+ this.hostElement.appendChild(child);
939
982
  this.insertedDomEl = child;
940
983
  }
941
984
  }
@@ -944,14 +987,26 @@ class TsEmbed {
944
987
  * @param height The height in pixels
945
988
  */
946
989
  setIFrameHeight(height) {
947
- this.iFrame.style.height = (0, utils_1.getCssDimension)(height);
990
+ if (this.isPreRendered) {
991
+ if (this.insertedDomEl) {
992
+ this.insertedDomEl.style.height = (0, utils_1.getCssDimension)(height);
993
+ }
994
+ else if (this.preRenderWrapper) {
995
+ this.preRenderWrapper.style.height = (0, utils_1.getCssDimension)(height);
996
+ }
997
+ }
998
+ else {
999
+ // normal (non-preRender) mode: size the iframe directly
1000
+ this.iFrame.style.height = (0, utils_1.getCssDimension)(height);
1001
+ }
948
1002
  }
949
1003
  shouldSkipEvent(eventType, data) {
950
1004
  var _a, _b, _c;
951
1005
  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;
952
- if (eventType === types_1.EmbedEvent.Error
953
- && errorType === types_1.EmbedErrorCodes.HOST_EVENT_VALIDATION
954
- && (!(0, utils_1.getHostEventsConfig)(this.viewConfig).useHostEventsV2 || (0, utils_1.getHostEventsConfig)(this.viewConfig).shouldBypassPayloadValidation)) {
1006
+ if (eventType === types_1.EmbedEvent.Error &&
1007
+ errorType === types_1.EmbedErrorCodes.HOST_EVENT_VALIDATION &&
1008
+ (!(0, utils_1.getHostEventsConfig)(this.viewConfig).useHostEventsV2 ||
1009
+ (0, utils_1.getHostEventsConfig)(this.viewConfig).shouldBypassPayloadValidation)) {
955
1010
  logger_1.logger.warn(`Host Event Validation failed: ${(_c = data === null || data === void 0 ? void 0 : data.data) === null || _c === void 0 ? void 0 : _c.message}`);
956
1011
  return true;
957
1012
  }
@@ -974,10 +1029,10 @@ class TsEmbed {
974
1029
  if (
975
1030
  // When start status is true it trigger only start releated
976
1031
  // payload
977
- (callbackObj.options.start && dataStatus === utils_1.embedEventStatus.START)
1032
+ (callbackObj.options.start && dataStatus === utils_1.embedEventStatus.START) ||
978
1033
  // When start status is false it trigger only end releated
979
1034
  // payload
980
- || (!callbackObj.options.start && dataStatus === utils_1.embedEventStatus.END)) {
1035
+ (!callbackObj.options.start && dataStatus === utils_1.embedEventStatus.END)) {
981
1036
  const responder = this.createEmbedEventResponder(eventPort, eventType);
982
1037
  callbackObj.callback(data, responder);
983
1038
  }
@@ -1113,7 +1168,7 @@ class TsEmbed {
1113
1168
  }
1114
1169
  getPreRenderObj() {
1115
1170
  var _a;
1116
- const embedObj = (_a = this.insertedDomEl) === null || _a === void 0 ? void 0 : _a[this.embedNodeKey];
1171
+ const embedObj = (_a = this.preRenderWrapper) === null || _a === void 0 ? void 0 : _a[this.embedNodeKey];
1117
1172
  if (embedObj === this) {
1118
1173
  logger_1.logger.info('embedObj is same as this');
1119
1174
  }
@@ -1188,7 +1243,7 @@ class TsEmbed {
1188
1243
  });
1189
1244
  return null;
1190
1245
  }
1191
- // Check if iframe exists before triggering -
1246
+ // Check if iframe exists before triggering -
1192
1247
  // this prevents the error when auth fails
1193
1248
  if (!this.iFrame) {
1194
1249
  logger_1.logger.debug(`Cannot trigger ${messageType} - iframe not available (likely due to auth failure)`);
@@ -1230,7 +1285,8 @@ class TsEmbed {
1230
1285
  if (!(0, base_1.getIsInitCalled)()) {
1231
1286
  logger_1.logger.error(errors_1.ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
1232
1287
  }
1233
- await this.isReadyForRenderPromise;
1288
+ if (this.shouldWaitForRenderPromise)
1289
+ await this.isReadyForRenderPromise;
1234
1290
  this.isRendered = true;
1235
1291
  return this;
1236
1292
  }
@@ -1241,33 +1297,33 @@ class TsEmbed {
1241
1297
  return this.render();
1242
1298
  }
1243
1299
  /**
1244
- * Context object for the embedded component.
1245
- * @returns {ContextObject} The current context object containing the page type and object ids.
1246
- * @example
1247
- * ```js
1248
- * const context = await embed.getCurrentContext();
1249
- * console.log(context);
1250
- *
1251
- * // Example output
1252
- * {
1253
- * stack: [
1254
- * {
1255
- * name: 'Liveboard',
1256
- * type: ContextType.Liveboard,
1257
- * objectIds: {
1258
- * liveboardId: '123',
1259
- * },
1260
- * },
1261
- * ],
1262
- * currentContext: {
1263
- * name: 'Liveboard',
1264
- * type: ContextType.Liveboard,
1265
- * objectIds: {
1266
- * liveboardId: '123',
1267
- * },
1268
- * },
1269
- * }
1270
- * ```
1300
+ * Context object for the embedded component.
1301
+ * @returns {ContextObject} The current context object containing the page type and object ids.
1302
+ * @example
1303
+ * ```js
1304
+ * const context = await embed.getCurrentContext();
1305
+ * console.log(context);
1306
+ *
1307
+ * // Example output
1308
+ * {
1309
+ * stack: [
1310
+ * {
1311
+ * name: 'Liveboard',
1312
+ * type: ContextType.Liveboard,
1313
+ * objectIds: {
1314
+ * liveboardId: '123',
1315
+ * },
1316
+ * },
1317
+ * ],
1318
+ * currentContext: {
1319
+ * name: 'Liveboard',
1320
+ * type: ContextType.Liveboard,
1321
+ * objectIds: {
1322
+ * liveboardId: '123',
1323
+ * },
1324
+ * },
1325
+ * }
1326
+ * ```
1271
1327
  * @version SDK: 1.45.2 | ThoughtSpot: 26.3.0.cl
1272
1328
  */
1273
1329
  async getCurrentContext() {
@@ -1305,6 +1361,9 @@ class TsEmbed {
1305
1361
  this.showPreRenderByDefault = showPreRenderByDefault;
1306
1362
  const isAlreadyRendered = this.connectPreRendered();
1307
1363
  if (isAlreadyRendered && !replaceExistingPreRender) {
1364
+ if (this.showPreRenderByDefault) {
1365
+ this.showPreRender();
1366
+ }
1308
1367
  return this;
1309
1368
  }
1310
1369
  return this.handleRenderForPrerender();
@@ -1340,25 +1399,28 @@ class TsEmbed {
1340
1399
  * @version SDK: 1.19.1 | ThoughtSpot: *
1341
1400
  */
1342
1401
  destroy() {
1343
- var _a, _b;
1402
+ var _a, _b, _c;
1344
1403
  try {
1345
1404
  this.removeFullscreenChangeHandler();
1346
1405
  this.unsubscribeToEvents();
1406
+ (_a = this.preRenderWrapper) === null || _a === void 0 ? void 0 : _a.remove();
1347
1407
  if (!this.isRendered) {
1348
1408
  return;
1349
1409
  }
1350
1410
  if (!(0, embedConfig_1.getEmbedConfig)().waitForCleanupOnDestroy) {
1351
1411
  this.trigger(types_1.HostEvent.DestroyEmbed);
1352
- (_b = (_a = this.insertedDomEl) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(this.insertedDomEl);
1412
+ (_c = (_b = this.insertedDomEl) === null || _b === void 0 ? void 0 : _b.parentNode) === null || _c === void 0 ? void 0 : _c.removeChild(this.insertedDomEl);
1353
1413
  }
1354
1414
  else {
1355
1415
  const cleanupTimeout = (0, embedConfig_1.getEmbedConfig)().cleanupTimeout;
1356
1416
  Promise.race([
1357
1417
  this.trigger(types_1.HostEvent.DestroyEmbed),
1358
1418
  new Promise((resolve) => setTimeout(resolve, cleanupTimeout)),
1359
- ]).catch((e) => {
1419
+ ])
1420
+ .catch((e) => {
1360
1421
  logger_1.logger.log('Error destroying TS Embed', e);
1361
- }).finally(() => {
1422
+ })
1423
+ .finally(() => {
1362
1424
  var _a, _b;
1363
1425
  try {
1364
1426
  (_b = (_a = this.insertedDomEl) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(this.insertedDomEl);
@@ -1387,56 +1449,75 @@ class TsEmbed {
1387
1449
  if (!(0, base_1.getIsInitCalled)()) {
1388
1450
  logger_1.logger.error(errors_1.ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
1389
1451
  }
1390
- await this.isReadyForRenderPromise;
1452
+ if (this.shouldWaitForRenderPromise)
1453
+ await this.isReadyForRenderPromise;
1391
1454
  const prerenderFrameSrc = this.getRootIframeSrc();
1392
1455
  this.isRendered = true;
1393
1456
  return this.renderIFrame(prerenderFrameSrc);
1394
1457
  }
1395
1458
  beforePrerenderVisible() {
1396
- // Override in subclass
1459
+ // We can ignore this as its a bit expensive and the newer customers
1460
+ // have moved on to UpdateEmbedParams supported clusters
1461
+ // this.validatePreRenderViewConfig(this.viewConfig); removed in #517
1462
+ logger_1.logger.debug('triggering UpdateEmbedParams', this.viewConfig);
1463
+ this.executeAfterEmbedContainerLoaded(async () => {
1464
+ try {
1465
+ const params = await this.getUpdateEmbedParamsObject();
1466
+ this.trigger(types_1.HostEvent.UpdateEmbedParams, params);
1467
+ }
1468
+ catch (error) {
1469
+ logger_1.logger.error(errors_1.ERROR_MESSAGE.UPDATE_PARAMS_FAILED, error);
1470
+ this.handleError({
1471
+ errorType: types_1.ErrorDetailsTypes.API,
1472
+ message: (error === null || error === void 0 ? void 0 : error.message) || errors_1.ERROR_MESSAGE.UPDATE_PARAMS_FAILED,
1473
+ code: types_1.EmbedErrorCodes.UPDATE_PARAMS_FAILED,
1474
+ error: (error === null || error === void 0 ? void 0 : error.message) || error,
1475
+ });
1476
+ }
1477
+ });
1397
1478
  }
1398
1479
  /**
1399
- * Displays the PreRender component.
1400
- * If the component is not preRendered, it attempts to create and render it.
1401
- * Also, synchronizes the style of the PreRender component with the embedding
1402
- * element.
1480
+ * Displays the pre-rendered component inside the host element.
1481
+ * If the component has not been pre-rendered yet, it initiates rendering first.
1482
+ * Inserts a placeholder element into the host and positions the pre-render
1483
+ * wrapper to overlay it.
1403
1484
  */
1404
1485
  async showPreRender() {
1486
+ var _a;
1487
+ if (this.shouldWaitForRenderPromise)
1488
+ await this.isReadyForRenderPromise;
1405
1489
  if (!this.viewConfig.preRenderId) {
1406
1490
  logger_1.logger.error(errors_1.ERROR_MESSAGE.PRERENDER_ID_MISSING);
1407
1491
  return this;
1408
1492
  }
1409
- if (!this.isPreRenderAvailable()) {
1410
- const isAvailable = this.connectPreRendered();
1411
- if (!isAvailable) {
1412
- // if the Embed component is not preRendered , Render it now and
1413
- return this.preRender(true);
1414
- }
1415
- this.validatePreRenderViewConfig(this.viewConfig);
1416
- logger_1.logger.debug('triggering UpdateEmbedParams', this.viewConfig);
1417
- this.executeAfterEmbedContainerLoaded(async () => {
1418
- try {
1419
- const params = await this.getUpdateEmbedParamsObject();
1420
- this.trigger(types_1.HostEvent.UpdateEmbedParams, params);
1421
- }
1422
- catch (error) {
1423
- logger_1.logger.error(errors_1.ERROR_MESSAGE.UPDATE_PARAMS_FAILED, error);
1424
- this.handleError({
1425
- errorType: types_1.ErrorDetailsTypes.API,
1426
- message: (error === null || error === void 0 ? void 0 : error.message) || errors_1.ERROR_MESSAGE.UPDATE_PARAMS_FAILED,
1427
- code: types_1.EmbedErrorCodes.UPDATE_PARAMS_FAILED,
1428
- error: (error === null || error === void 0 ? void 0 : error.message) || error,
1429
- });
1430
- }
1431
- });
1493
+ if (!this.isPreRenderConnected()) {
1494
+ // this will call showPreRender down the line
1495
+ return this.preRender(true);
1432
1496
  }
1497
+ this.isRendered = true;
1433
1498
  this.beforePrerenderVisible();
1434
- if (this.el) {
1499
+ if (this.hostElement) {
1500
+ this.insertedDomEl = this.createPreRenderPlaceholder();
1501
+ if (this.viewConfig.fullHeight) {
1502
+ // If fullHeight has already sized the wrapper, seed the placeholder
1503
+ // with the same height so syncPreRenderStyle gets an accurate rect.
1504
+ const existingHeight = this.preRenderWrapper.style.height;
1505
+ if (existingHeight) {
1506
+ this.insertedDomEl.style.height = existingHeight;
1507
+ }
1508
+ }
1509
+ const placeHolderId = this.getPreRenderIds().placeHolder;
1510
+ const oldEle = this.hostElement.querySelector(`#${placeHolderId}`);
1511
+ if (oldEle) {
1512
+ this.hostElement.removeChild(oldEle);
1513
+ }
1514
+ this.hostElement.appendChild(this.insertedDomEl);
1435
1515
  this.syncPreRenderStyle();
1436
1516
  if (!this.viewConfig.doNotTrackPreRenderSize) {
1517
+ const observeTarget = (_a = this.insertedDomEl) !== null && _a !== void 0 ? _a : this.hostElement;
1437
1518
  this.resizeObserver = new ResizeObserver((entries) => {
1438
1519
  entries.forEach((entry) => {
1439
- if (entry.contentRect && entry.target === this.el) {
1520
+ if (entry.contentRect && entry.target === observeTarget) {
1440
1521
  (0, utils_1.setStyleProperties)(this.preRenderWrapper, {
1441
1522
  width: `${entry.contentRect.width}px`,
1442
1523
  height: `${entry.contentRect.height}px`,
@@ -1444,10 +1525,15 @@ class TsEmbed {
1444
1525
  }
1445
1526
  });
1446
1527
  });
1447
- this.resizeObserver.observe(this.el);
1528
+ this.resizeObserver.observe(observeTarget);
1448
1529
  }
1449
1530
  }
1450
- (0, utils_1.removeStyleProperties)(this.preRenderWrapper, ['z-index', 'opacity', 'pointer-events', 'overflow']);
1531
+ (0, utils_1.removeStyleProperties)(this.preRenderWrapper, [
1532
+ 'z-index',
1533
+ 'opacity',
1534
+ 'pointer-events',
1535
+ 'overflow',
1536
+ ]);
1451
1537
  this.subscribeToEvents();
1452
1538
  // Setup fullscreen change handler for prerendered components
1453
1539
  if (this.iFrame) {
@@ -1455,6 +1541,9 @@ class TsEmbed {
1455
1541
  }
1456
1542
  return this;
1457
1543
  }
1544
+ getPreRenderPlaceHolderElement() {
1545
+ return this.insertedDomEl;
1546
+ }
1458
1547
  /**
1459
1548
  * Synchronizes the style properties of the PreRender component with the embedding
1460
1549
  * element. This function adjusts the position, width, and height of the PreRender
@@ -1464,16 +1553,17 @@ class TsEmbed {
1464
1553
  * is not defined or not found.
1465
1554
  */
1466
1555
  syncPreRenderStyle() {
1467
- if (!this.isPreRenderAvailable() || !this.el) {
1556
+ if (!this.isPreRenderConnected() || !this.getPreRenderPlaceHolderElement()) {
1468
1557
  logger_1.logger.error(errors_1.ERROR_MESSAGE.SYNC_STYLE_CALLED_BEFORE_RENDER);
1469
1558
  return;
1470
1559
  }
1471
- const elBoundingClient = this.el.getBoundingClientRect();
1560
+ const elBoundingClient = this.getPreRenderPlaceHolderElement().getBoundingClientRect();
1472
1561
  (0, utils_1.setStyleProperties)(this.preRenderWrapper, {
1473
1562
  top: `${elBoundingClient.y + window.scrollY}px`,
1474
1563
  left: `${elBoundingClient.x + window.scrollX}px`,
1475
1564
  width: `${elBoundingClient.width}px`,
1476
1565
  height: `${elBoundingClient.height}px`,
1566
+ position: 'absolute',
1477
1567
  });
1478
1568
  }
1479
1569
  /**
@@ -1481,7 +1571,8 @@ class TsEmbed {
1481
1571
  * If the component is not preRendered, it issues a warning.
1482
1572
  */
1483
1573
  hidePreRender() {
1484
- if (!this.isPreRenderAvailable()) {
1574
+ logger_1.logger.debug('HidePreRender Called');
1575
+ if (!this.isPreRenderConnected()) {
1485
1576
  // if the embed component is not preRendered , nothing to hide
1486
1577
  logger_1.logger.warn('PreRender should be called before hiding it using hidePreRender.');
1487
1578
  return;
@@ -1499,6 +1590,10 @@ class TsEmbed {
1499
1590
  if (this.resizeObserver) {
1500
1591
  this.resizeObserver.disconnect();
1501
1592
  }
1593
+ const placeHolderEle = this.getPreRenderPlaceHolderElement();
1594
+ if (placeHolderEle) {
1595
+ placeHolderEle.parentElement.removeChild(placeHolderEle);
1596
+ }
1502
1597
  this.unsubscribeToEvents();
1503
1598
  }
1504
1599
  /**
@@ -1512,6 +1607,7 @@ class TsEmbed {
1512
1607
  return {
1513
1608
  wrapper: `tsEmbed-pre-render-wrapper-${this.viewConfig.preRenderId}`,
1514
1609
  child: `tsEmbed-pre-render-child-${this.viewConfig.preRenderId}`,
1610
+ placeHolder: `tsEmbed-pre-render-placeholder-${this.viewConfig.preRenderId}`,
1515
1611
  };
1516
1612
  }
1517
1613
  /**