@thoughtspot/visual-embed-sdk 1.36.3 → 1.36.4

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 (167) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/embed/app.d.ts.map +1 -1
  3. package/cjs/src/embed/app.js +1 -1
  4. package/cjs/src/embed/app.js.map +1 -1
  5. package/cjs/src/embed/base.d.ts +4 -0
  6. package/cjs/src/embed/base.d.ts.map +1 -1
  7. package/cjs/src/embed/base.js +27 -1
  8. package/cjs/src/embed/base.js.map +1 -1
  9. package/cjs/src/embed/bodyless-conversation.d.ts.map +1 -1
  10. package/cjs/src/embed/bodyless-conversation.js +1 -1
  11. package/cjs/src/embed/bodyless-conversation.js.map +1 -1
  12. package/cjs/src/embed/conversation.d.ts.map +1 -1
  13. package/cjs/src/embed/conversation.js +1 -1
  14. package/cjs/src/embed/conversation.js.map +1 -1
  15. package/cjs/src/embed/embedConfig.d.ts.map +1 -1
  16. package/cjs/src/embed/embedConfig.js.map +1 -1
  17. package/cjs/src/embed/liveboard.d.ts +2 -2
  18. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  19. package/cjs/src/embed/liveboard.js +4 -5
  20. package/cjs/src/embed/liveboard.js.map +1 -1
  21. package/cjs/src/embed/liveboard.spec.js +11 -11
  22. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  23. package/cjs/src/embed/sage.d.ts.map +1 -1
  24. package/cjs/src/embed/sage.js +1 -1
  25. package/cjs/src/embed/sage.js.map +1 -1
  26. package/cjs/src/embed/search-bar.d.ts.map +1 -1
  27. package/cjs/src/embed/search-bar.js +1 -1
  28. package/cjs/src/embed/search-bar.js.map +1 -1
  29. package/cjs/src/embed/search.d.ts.map +1 -1
  30. package/cjs/src/embed/search.js +1 -1
  31. package/cjs/src/embed/search.js.map +1 -1
  32. package/cjs/src/embed/ts-embed.d.ts +4 -3
  33. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  34. package/cjs/src/embed/ts-embed.js +25 -16
  35. package/cjs/src/embed/ts-embed.js.map +1 -1
  36. package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
  37. package/cjs/src/embed/ts-embed.spec.js +71 -5
  38. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  39. package/cjs/src/errors.d.ts +1 -0
  40. package/cjs/src/errors.d.ts.map +1 -1
  41. package/cjs/src/errors.js +1 -0
  42. package/cjs/src/errors.js.map +1 -1
  43. package/cjs/src/react/all-types-export.d.ts +1 -1
  44. package/cjs/src/react/all-types-export.d.ts.map +1 -1
  45. package/cjs/src/react/all-types-export.js +2 -1
  46. package/cjs/src/react/all-types-export.js.map +1 -1
  47. package/cjs/src/react/index.d.ts +16 -0
  48. package/cjs/src/react/index.d.ts.map +1 -1
  49. package/cjs/src/react/index.js +25 -2
  50. package/cjs/src/react/index.js.map +1 -1
  51. package/cjs/src/utils/with-resolvers-polyfill.d.ts +1 -0
  52. package/cjs/src/utils/with-resolvers-polyfill.d.ts.map +1 -0
  53. package/cjs/src/utils/with-resolvers-polyfill.js +12 -0
  54. package/cjs/src/utils/with-resolvers-polyfill.js.map +1 -0
  55. package/cjs/src/utils.d.ts +17 -2
  56. package/cjs/src/utils.d.ts.map +1 -1
  57. package/cjs/src/utils.js +27 -3
  58. package/cjs/src/utils.js.map +1 -1
  59. package/dist/{index-BJx3m5_V.js → index-NZYq1Tu3.js} +1 -1
  60. package/dist/src/embed/app.d.ts.map +1 -1
  61. package/dist/src/embed/base.d.ts +4 -0
  62. package/dist/src/embed/base.d.ts.map +1 -1
  63. package/dist/src/embed/bodyless-conversation.d.ts.map +1 -1
  64. package/dist/src/embed/conversation.d.ts.map +1 -1
  65. package/dist/src/embed/embedConfig.d.ts.map +1 -1
  66. package/dist/src/embed/liveboard.d.ts +2 -2
  67. package/dist/src/embed/liveboard.d.ts.map +1 -1
  68. package/dist/src/embed/sage.d.ts.map +1 -1
  69. package/dist/src/embed/search-bar.d.ts.map +1 -1
  70. package/dist/src/embed/search.d.ts.map +1 -1
  71. package/dist/src/embed/ts-embed.d.ts +4 -3
  72. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  73. package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
  74. package/dist/src/errors.d.ts +1 -0
  75. package/dist/src/errors.d.ts.map +1 -1
  76. package/dist/src/react/all-types-export.d.ts +1 -1
  77. package/dist/src/react/all-types-export.d.ts.map +1 -1
  78. package/dist/src/react/index.d.ts +16 -0
  79. package/dist/src/react/index.d.ts.map +1 -1
  80. package/dist/src/utils/with-resolvers-polyfill.d.ts +1 -0
  81. package/dist/src/utils/with-resolvers-polyfill.d.ts.map +1 -0
  82. package/dist/src/utils.d.ts +17 -2
  83. package/dist/src/utils.d.ts.map +1 -1
  84. package/dist/tsembed-react.es.js +349 -45
  85. package/dist/tsembed-react.js +347 -42
  86. package/dist/tsembed.es.js +85 -32
  87. package/dist/tsembed.js +84 -31
  88. package/dist/visual-embed-sdk-react-full.d.ts +1233 -1214
  89. package/dist/visual-embed-sdk-react.d.ts +668 -649
  90. package/dist/visual-embed-sdk.d.ts +9 -4
  91. package/lib/package.json +1 -1
  92. package/lib/src/embed/app.d.ts.map +1 -1
  93. package/lib/src/embed/app.js +1 -1
  94. package/lib/src/embed/app.js.map +1 -1
  95. package/lib/src/embed/base.d.ts +4 -0
  96. package/lib/src/embed/base.d.ts.map +1 -1
  97. package/lib/src/embed/base.js +24 -1
  98. package/lib/src/embed/base.js.map +1 -1
  99. package/lib/src/embed/bodyless-conversation.d.ts.map +1 -1
  100. package/lib/src/embed/bodyless-conversation.js +1 -1
  101. package/lib/src/embed/bodyless-conversation.js.map +1 -1
  102. package/lib/src/embed/conversation.d.ts.map +1 -1
  103. package/lib/src/embed/conversation.js +1 -1
  104. package/lib/src/embed/conversation.js.map +1 -1
  105. package/lib/src/embed/embedConfig.d.ts.map +1 -1
  106. package/lib/src/embed/embedConfig.js.map +1 -1
  107. package/lib/src/embed/liveboard.d.ts +2 -2
  108. package/lib/src/embed/liveboard.d.ts.map +1 -1
  109. package/lib/src/embed/liveboard.js +4 -5
  110. package/lib/src/embed/liveboard.js.map +1 -1
  111. package/lib/src/embed/liveboard.spec.js +11 -11
  112. package/lib/src/embed/liveboard.spec.js.map +1 -1
  113. package/lib/src/embed/sage.d.ts.map +1 -1
  114. package/lib/src/embed/sage.js +1 -1
  115. package/lib/src/embed/sage.js.map +1 -1
  116. package/lib/src/embed/search-bar.d.ts.map +1 -1
  117. package/lib/src/embed/search-bar.js +1 -1
  118. package/lib/src/embed/search-bar.js.map +1 -1
  119. package/lib/src/embed/search.d.ts.map +1 -1
  120. package/lib/src/embed/search.js +1 -1
  121. package/lib/src/embed/search.js.map +1 -1
  122. package/lib/src/embed/ts-embed.d.ts +4 -3
  123. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  124. package/lib/src/embed/ts-embed.js +26 -17
  125. package/lib/src/embed/ts-embed.js.map +1 -1
  126. package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
  127. package/lib/src/embed/ts-embed.spec.js +71 -5
  128. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  129. package/lib/src/errors.d.ts +1 -0
  130. package/lib/src/errors.d.ts.map +1 -1
  131. package/lib/src/errors.js +1 -0
  132. package/lib/src/errors.js.map +1 -1
  133. package/lib/src/react/all-types-export.d.ts +1 -1
  134. package/lib/src/react/all-types-export.d.ts.map +1 -1
  135. package/lib/src/react/all-types-export.js +1 -1
  136. package/lib/src/react/all-types-export.js.map +1 -1
  137. package/lib/src/react/index.d.ts +16 -0
  138. package/lib/src/react/index.d.ts.map +1 -1
  139. package/lib/src/react/index.js +23 -1
  140. package/lib/src/react/index.js.map +1 -1
  141. package/lib/src/utils/with-resolvers-polyfill.d.ts +1 -0
  142. package/lib/src/utils/with-resolvers-polyfill.d.ts.map +1 -0
  143. package/lib/src/utils/with-resolvers-polyfill.js +12 -0
  144. package/lib/src/utils/with-resolvers-polyfill.js.map +1 -0
  145. package/lib/src/utils.d.ts +17 -2
  146. package/lib/src/utils.d.ts.map +1 -1
  147. package/lib/src/utils.js +25 -2
  148. package/lib/src/utils.js.map +1 -1
  149. package/lib/src/visual-embed-sdk.d.ts +10 -5
  150. package/package.json +1 -1
  151. package/src/embed/app.ts +2 -1
  152. package/src/embed/base.ts +41 -1
  153. package/src/embed/bodyless-conversation.ts +2 -1
  154. package/src/embed/conversation.ts +2 -1
  155. package/src/embed/embedConfig.ts +1 -1
  156. package/src/embed/liveboard.spec.ts +11 -11
  157. package/src/embed/liveboard.ts +5 -6
  158. package/src/embed/sage.ts +1 -2
  159. package/src/embed/search-bar.tsx +1 -2
  160. package/src/embed/search.ts +1 -2
  161. package/src/embed/ts-embed.spec.ts +83 -5
  162. package/src/embed/ts-embed.ts +33 -17
  163. package/src/errors.ts +1 -0
  164. package/src/react/all-types-export.ts +1 -0
  165. package/src/react/index.tsx +27 -2
  166. package/src/utils/with-resolvers-polyfill.ts +11 -0
  167. package/src/utils.ts +35 -4
@@ -1,4 +1,4 @@
1
- /* @thoughtspot/visual-embed-sdk version 1.36.3 */
1
+ /* @thoughtspot/visual-embed-sdk version 1.36.4 */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
@@ -483,13 +483,23 @@
483
483
  * Stores a value in the global `window` object under the `_tsEmbedSDK` namespace.
484
484
  * @param key - The key under which the value will be stored.
485
485
  * @param value - The value to store.
486
+ * @param options - Additional options.
487
+ * @param options.ignoreIfAlreadyExists - Does not set if value for key is set.
488
+ *
489
+ * @returns The stored value.
490
+ *
491
+ * @version SDK: 1.36.2 | ThoughtSpot: *
486
492
  */
487
- const storeValueInWindow = (key, value) => {
493
+ function storeValueInWindow(key, value, options = {}) {
488
494
  if (!window[sdkWindowKey]) {
489
495
  window[sdkWindowKey] = {};
490
496
  }
497
+ if (options.ignoreIfAlreadyExists && key in window[sdkWindowKey]) {
498
+ return window[sdkWindowKey][key];
499
+ }
491
500
  window[sdkWindowKey][key] = value;
492
- };
501
+ return value;
502
+ }
493
503
  /**
494
504
  * Retrieves a stored value from the global `window` object under the `_tsEmbedSDK` namespace.
495
505
  * @param key - The key whose value needs to be retrieved.
@@ -6579,6 +6589,9 @@
6579
6589
  [exports.LogLevel.TRACE]: console.trace,
6580
6590
  };
6581
6591
  let globalLogLevelOverride = exports.LogLevel.TRACE;
6592
+ const setGlobalLogLevelOverride = (logLevel) => {
6593
+ globalLogLevelOverride = logLevel;
6594
+ };
6582
6595
  const logLevelToNumber = {
6583
6596
  [exports.LogLevel.SILENT]: 0,
6584
6597
  [exports.LogLevel.ERROR]: 1,
@@ -6655,6 +6668,7 @@
6655
6668
  CSP_VIOLATION_ALERT: 'CSP violation detected. Please check the console errors for more details.',
6656
6669
  CSP_FRAME_HOST_VIOLATION_LOG_MESSAGE: 'Please set up CSP correctly for the application to start working. For more information, see https://developers.thoughtspot.com/docs/security-settings#csp-viz-embed-hosts. \n If the issue persists, refer to https://developers.thoughtspot.com/docs/security-settings#csp-viz-embed-hosts',
6657
6670
  MISSING_REPORTING_OBSERVER: 'ReportingObserver not supported',
6671
+ RENDER_CALLED_BEFORE_INIT: 'Looks like render was called before calling init, the render won\'t start until init is called.\nFor more info check\n1. https://developers.thoughtspot.com/docs/Function_init#_init\n2.https://developers.thoughtspot.com/docs/getting-started#initSdk',
6658
6672
  };
6659
6673
 
6660
6674
  const EndPoints = {
@@ -6861,7 +6875,18 @@
6861
6875
  * @version SDK: 1.19.0 | ThoughtSpot: *
6862
6876
  * @group Global methods
6863
6877
  */
6864
- const getEmbedConfig = () => getValueFromWindow(configKey) || {};
6878
+ const getEmbedConfig = () => getValueFromWindow(configKey) || {};
6879
+ /**
6880
+ * Sets the configuration embed was initialized with.
6881
+ * And returns the new configuration.
6882
+ * @param newConfig The configuration to set.
6883
+ * @version SDK: 1.27.0 | ThoughtSpot: *
6884
+ * @group Global methods
6885
+ */
6886
+ const setEmbedConfig = (newConfig) => {
6887
+ storeValueInWindow(configKey, newConfig);
6888
+ return getValueFromWindow(configKey);
6889
+ };
6865
6890
 
6866
6891
  /**
6867
6892
  * Fetch wrapper that adds the authentication token to the request.
@@ -13849,7 +13874,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
13849
13874
  }
13850
13875
  }
13851
13876
 
13852
- createCommonjsModule(function (module) {
13877
+ var eventemitter3 = createCommonjsModule(function (module) {
13853
13878
 
13854
13879
  var has = Object.prototype.hasOwnProperty
13855
13880
  , prefix = '~';
@@ -14192,7 +14217,52 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
14192
14217
  ReportType["CSP_VIOLATION"] = "csp-violation";
14193
14218
  ReportType["DEPRECATION"] = "deprecation";
14194
14219
  ReportType["INTERVENTION"] = "intervention";
14195
- })(ReportType || (ReportType = {}));
14220
+ })(ReportType || (ReportType = {}));
14221
+ let globalObserver = null;
14222
+ /**
14223
+ * Register a global ReportingObserver to capture all unhandled errors
14224
+ * @param overrideExisting boolean to override existing observer
14225
+ * @returns ReportingObserver | null
14226
+ */
14227
+ function registerReportingObserver(overrideExisting = false) {
14228
+ if (!(window.ReportingObserver)) {
14229
+ logger$3.warn(ERROR_MESSAGE.MISSING_REPORTING_OBSERVER);
14230
+ return null;
14231
+ }
14232
+ if (overrideExisting) {
14233
+ resetGlobalReportingObserver();
14234
+ }
14235
+ if (globalObserver) {
14236
+ return globalObserver;
14237
+ }
14238
+ const embedConfig = getEmbedConfig();
14239
+ globalObserver = new ReportingObserver((reports) => {
14240
+ reports.forEach((report) => {
14241
+ const { type, url, body } = report;
14242
+ const reportBody = body;
14243
+ const isThoughtSpotHost = url
14244
+ && url.startsWith(embedConfig.thoughtSpotHost);
14245
+ const isFrameHostError = type === ReportType.CSP_VIOLATION
14246
+ && reportBody.effectiveDirective === 'frame-ancestors';
14247
+ if (isThoughtSpotHost && isFrameHostError) {
14248
+ if (!embedConfig.suppressErrorAlerts) {
14249
+ alert(ERROR_MESSAGE.CSP_VIOLATION_ALERT);
14250
+ }
14251
+ logger$3.error(ERROR_MESSAGE.CSP_FRAME_HOST_VIOLATION_LOG_MESSAGE);
14252
+ }
14253
+ });
14254
+ }, { buffered: true });
14255
+ globalObserver.observe();
14256
+ return globalObserver;
14257
+ }
14258
+ /**
14259
+ * Resets the global ReportingObserver
14260
+ */
14261
+ function resetGlobalReportingObserver() {
14262
+ if (globalObserver)
14263
+ globalObserver.disconnect();
14264
+ globalObserver = null;
14265
+ }
14196
14266
 
14197
14267
  /**
14198
14268
  *
@@ -14374,7 +14444,45 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
14374
14444
  clusterName: sessionInfoResp.configInfo.selfClusterName,
14375
14445
  ...sessionInfoResp,
14376
14446
  };
14377
- };
14447
+ };
14448
+ /**
14449
+ * Resets the cached session info object and forces a new fetch on the next call.
14450
+ * @example ```js
14451
+ * resetCachedSessionInfo();
14452
+ * const sessionInfo = await getSessionInfo();
14453
+ * console.log(sessionInfo);
14454
+ * ```
14455
+ * @version SDK: 1.28.3 | ThoughtSpot: *
14456
+ * @returns {void}
14457
+ */
14458
+ function resetCachedSessionInfo() {
14459
+ sessionInfo = null;
14460
+ }
14461
+ /**
14462
+ * Resets the cached preauth info object and forces a new fetch on the next call.
14463
+ * @example ```js
14464
+ * resetCachedPreauthInfo();
14465
+ * const preauthInfo = await getPreauthInfo();
14466
+ * console.log(preauthInfo);
14467
+ * ```
14468
+ * @version SDK: 1.28.3 | ThoughtSpot: *
14469
+ * @returns {void}
14470
+ */
14471
+ function resetCachedPreauthInfo() {
14472
+ preauthInfo = null;
14473
+ }
14474
+
14475
+ /**
14476
+ * This function resets all the services that are cached in the SDK.
14477
+ * This is to be called when the user logs out of the application and also
14478
+ * when init is called again.
14479
+ * @version SDK: 1.30.2 | ThoughtSpot: *
14480
+ */
14481
+ function resetAllCachedServices() {
14482
+ resetCachedAuthToken();
14483
+ resetCachedSessionInfo();
14484
+ resetCachedPreauthInfo();
14485
+ }
14378
14486
 
14379
14487
  // eslint-disable-next-line import/no-mutable-exports
14380
14488
  let loggedInStatus = false;
@@ -14444,42 +14552,61 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
14444
14552
  */
14445
14553
  AuthEvent["TRIGGER_SSO_POPUP"] = "TRIGGER_SSO_POPUP";
14446
14554
  })(AuthEvent || (AuthEvent = {}));
14555
+ let authEE;
14556
+ /**
14557
+ *
14558
+ * @param eventEmitter
14559
+ */
14560
+ function setAuthEE(eventEmitter) {
14561
+ authEE = eventEmitter;
14562
+ }
14447
14563
  /**
14448
14564
  *
14449
14565
  */
14450
14566
  function notifyAuthSDKSuccess() {
14451
- {
14567
+ if (!authEE) {
14452
14568
  logger$3.error(ERROR_MESSAGE.SDK_NOT_INITIALIZED);
14453
14569
  return;
14454
14570
  }
14571
+ authEE.emit(AuthStatus.SDK_SUCCESS);
14455
14572
  }
14456
14573
  /**
14457
14574
  *
14458
14575
  */
14459
14576
  async function notifyAuthSuccess() {
14460
- {
14577
+ if (!authEE) {
14461
14578
  logger$3.error(ERROR_MESSAGE.SDK_NOT_INITIALIZED);
14462
14579
  return;
14463
14580
  }
14581
+ try {
14582
+ getPreauthInfo();
14583
+ const sessionInfo = await getSessionInfo();
14584
+ authEE.emit(AuthStatus.SUCCESS, sessionInfo);
14585
+ }
14586
+ catch (e) {
14587
+ logger$3.error(ERROR_MESSAGE.SESSION_INFO_FAILED);
14588
+ }
14464
14589
  }
14465
14590
  /**
14466
14591
  *
14467
14592
  * @param failureType
14468
14593
  */
14469
14594
  function notifyAuthFailure(failureType) {
14470
- {
14595
+ if (!authEE) {
14471
14596
  logger$3.error(ERROR_MESSAGE.SDK_NOT_INITIALIZED);
14472
14597
  return;
14473
14598
  }
14599
+ authEE.emit(AuthStatus.FAILURE, failureType);
14474
14600
  }
14475
14601
  /**
14476
14602
  *
14477
14603
  */
14478
14604
  function notifyLogout() {
14479
- {
14605
+ if (!authEE) {
14480
14606
  logger$3.error(ERROR_MESSAGE.SDK_NOT_INITIALIZED);
14481
14607
  return;
14482
14608
  }
14609
+ authEE.emit(AuthStatus.LOGOUT);
14483
14610
  }
14484
14611
  /**
14485
14612
  * Check if we are logged into the ThoughtSpot cluster
@@ -14640,6 +14767,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
14640
14767
  samlAuthWindow.focus();
14641
14768
  }
14642
14769
  };
14770
+ authEE === null || authEE === void 0 ? void 0 : authEE.emit(AuthStatus.WAITING_FOR_POPUP);
14643
14771
  const containerEl = getDOMNode(triggerContainer);
14644
14772
  if (containerEl) {
14645
14773
  containerEl.innerHTML = '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
@@ -14655,6 +14783,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
14655
14783
  }
14656
14784
  });
14657
14785
  });
14786
+ authEE === null || authEE === void 0 ? void 0 : authEE.once(AuthEvent.TRIGGER_SSO_POPUP, openPopup);
14658
14787
  return samlCompletionPromise;
14659
14788
  }
14660
14789
  /**
@@ -14738,6 +14867,18 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
14738
14867
  }
14739
14868
  };
14740
14869
 
14870
+ if (typeof Promise.withResolvers === 'undefined') {
14871
+ Promise.withResolvers = () => {
14872
+ let resolve;
14873
+ let reject;
14874
+ const promise = new Promise((res, rej) => {
14875
+ resolve = res;
14876
+ reject = rej;
14877
+ });
14878
+ return { promise, resolve, reject };
14879
+ };
14880
+ }
14881
+
14741
14882
  /* eslint-disable camelcase */
14742
14883
  /* eslint-disable import/no-mutable-exports */
14743
14884
  /**
@@ -14747,12 +14888,12 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
14747
14888
  * @summary Base classes
14748
14889
  * @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
14749
14890
  */
14750
- ({
14891
+ const CONFIG_DEFAULTS = {
14751
14892
  loginFailedMessage: 'Not logged in',
14752
14893
  authTriggerText: 'Authorize',
14753
14894
  authType: AuthType.None,
14754
14895
  logLevel: exports.LogLevel.ERROR,
14755
- });
14896
+ };
14756
14897
  let authPromise;
14757
14898
  const getAuthPromise = () => authPromise;
14758
14899
  /**
@@ -14774,12 +14915,146 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
14774
14915
  });
14775
14916
  return authPromise;
14776
14917
  };
14777
- ({
14918
+ const hostUrlToFeatureUrl = {
14778
14919
  [PrefetchFeatures.SearchEmbed]: (url, flags) => `${url}v2/?${flags}#/embed/answer`,
14779
14920
  [PrefetchFeatures.LiveboardEmbed]: (url, flags) => `${url}?${flags}`,
14780
14921
  [PrefetchFeatures.FullApp]: (url, flags) => `${url}?${flags}`,
14781
14922
  [PrefetchFeatures.VizEmbed]: (url, flags) => `${url}?${flags}`,
14782
- });
14923
+ };
14924
+ /**
14925
+ * Prefetches static resources from the specified URL. Web browsers can then cache the
14926
+ * prefetched resources and serve them from the user's local disk to provide faster access
14927
+ * to your app.
14928
+ * @param url The URL provided for prefetch
14929
+ * @param prefetchFeatures Specify features which needs to be prefetched.
14930
+ * @param additionalFlags This can be used to add any URL flag.
14931
+ * @version SDK: 1.4.0 | ThoughtSpot: ts7.sep.cl, 7.2.1
14932
+ * @group Global methods
14933
+ */
14934
+ const prefetch = (url, prefetchFeatures, additionalFlags) => {
14935
+ var _a;
14936
+ if (url === '') {
14937
+ // eslint-disable-next-line no-console
14938
+ logger$3.warn('The prefetch method does not have a valid URL');
14939
+ }
14940
+ else {
14941
+ const features = [PrefetchFeatures.FullApp];
14942
+ let hostUrl = url || getEmbedConfig().thoughtSpotHost;
14943
+ const prefetchFlags = {
14944
+ [Param.EmbedApp]: true,
14945
+ ...(_a = getEmbedConfig()) === null || _a === void 0 ? void 0 : _a.additionalFlags,
14946
+ ...additionalFlags,
14947
+ };
14948
+ hostUrl = hostUrl[hostUrl.length - 1] === '/' ? hostUrl : `${hostUrl}/`;
14949
+ Array.from(new Set(features
14950
+ .map((feature) => hostUrlToFeatureUrl[feature](hostUrl, getQueryParamString(prefetchFlags)))))
14951
+ .forEach((prefetchUrl, index) => {
14952
+ const iFrame = document.createElement('iframe');
14953
+ iFrame.src = prefetchUrl;
14954
+ iFrame.style.width = '0';
14955
+ iFrame.style.height = '0';
14956
+ iFrame.style.border = '0';
14957
+ iFrame.classList.add('prefetchIframe');
14958
+ iFrame.classList.add(`prefetchIframeNum-${index}`);
14959
+ document.body.appendChild(iFrame);
14960
+ });
14961
+ }
14962
+ };
14963
+ /**
14964
+ *
14965
+ * @param embedConfig
14966
+ */
14967
+ function sanity(embedConfig) {
14968
+ if (embedConfig.thoughtSpotHost === undefined) {
14969
+ throw new Error('ThoughtSpot host not provided');
14970
+ }
14971
+ if (embedConfig.authType === AuthType.TrustedAuthToken) {
14972
+ if (!embedConfig.authEndpoint && typeof embedConfig.getAuthToken !== 'function') {
14973
+ throw new Error('Trusted auth should provide either authEndpoint or getAuthToken');
14974
+ }
14975
+ }
14976
+ }
14977
+ /**
14978
+ *
14979
+ * @param embedConfig
14980
+ */
14981
+ function backwardCompat(embedConfig) {
14982
+ const newConfig = { ...embedConfig };
14983
+ if (embedConfig.noRedirect !== undefined && embedConfig.inPopup === undefined) {
14984
+ newConfig.inPopup = embedConfig.noRedirect;
14985
+ }
14986
+ return newConfig;
14987
+ }
14988
+ const initFlagKey = 'initFlagKey';
14989
+ const createAndSetInitPromise = () => {
14990
+ const { promise: initPromise, resolve: initPromiseResolve,
14991
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14992
+ // @ts-ignore
14993
+ } = Promise.withResolvers();
14994
+ const initFlagStore = {
14995
+ initPromise,
14996
+ isInitCalled: false,
14997
+ initPromiseResolve,
14998
+ };
14999
+ storeValueInWindow(initFlagKey, initFlagStore, {
15000
+ // In case of diff imports the promise might be already set
15001
+ ignoreIfAlreadyExists: true,
15002
+ });
15003
+ };
15004
+ createAndSetInitPromise();
15005
+ const getInitPromise = () => { var _a; return (_a = getValueFromWindow(initFlagKey)) === null || _a === void 0 ? void 0 : _a.initPromise; };
15006
+ const getIsInitCalled = () => { var _a; return !!((_a = getValueFromWindow(initFlagKey)) === null || _a === void 0 ? void 0 : _a.isInitCalled); };
15007
+ /**
15008
+ * Initializes the Visual Embed SDK globally and perform
15009
+ * authentication if applicable. This function needs to be called before any ThoughtSpot
15010
+ * component like Liveboard etc can be embedded. But need not wait for AuthEvent.SUCCESS
15011
+ * to actually embed. That is handled internally.
15012
+ * @param embedConfig The configuration object containing ThoughtSpot host,
15013
+ * authentication mechanism and so on.
15014
+ * @example
15015
+ * ```js
15016
+ * const authStatus = init({
15017
+ * thoughtSpotHost: 'https://my.thoughtspot.cloud',
15018
+ * authType: AuthType.None,
15019
+ * });
15020
+ * authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
15021
+ * ```
15022
+ * @returns {@link AuthEventEmitter} event emitter which emits events on authentication success,
15023
+ * failure and logout. See {@link AuthStatus}
15024
+ * @version SDK: 1.0.0 | ThoughtSpot ts7.april.cl, 7.2.1
15025
+ * @group Authentication / Init
15026
+ */
15027
+ const init = (embedConfig) => {
15028
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
15029
+ sanity(embedConfig);
15030
+ resetAllCachedServices();
15031
+ embedConfig = setEmbedConfig(backwardCompat({
15032
+ ...CONFIG_DEFAULTS,
15033
+ ...embedConfig,
15034
+ thoughtSpotHost: getThoughtSpotHost(embedConfig),
15035
+ }));
15036
+ setGlobalLogLevelOverride(embedConfig.logLevel);
15037
+ registerReportingObserver();
15038
+ const authEE = new eventemitter3();
15039
+ setAuthEE(authEE);
15040
+ handleAuth();
15041
+ const { password, ...configToTrack } = getEmbedConfig();
15042
+ uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
15043
+ ...configToTrack,
15044
+ usedCustomizationSheet: ((_b = (_a = embedConfig.customizations) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.customCSSUrl) != null,
15045
+ usedCustomizationVariables: ((_e = (_d = (_c = embedConfig.customizations) === null || _c === void 0 ? void 0 : _c.style) === null || _d === void 0 ? void 0 : _d.customCSS) === null || _e === void 0 ? void 0 : _e.variables) != null,
15046
+ usedCustomizationRules: ((_h = (_g = (_f = embedConfig.customizations) === null || _f === void 0 ? void 0 : _f.style) === null || _g === void 0 ? void 0 : _g.customCSS) === null || _h === void 0 ? void 0 : _h.rules_UNSTABLE) != null,
15047
+ usedCustomizationStrings: !!((_k = (_j = embedConfig.customizations) === null || _j === void 0 ? void 0 : _j.content) === null || _k === void 0 ? void 0 : _k.strings),
15048
+ usedCustomizationIconSprite: !!((_l = embedConfig.customizations) === null || _l === void 0 ? void 0 : _l.iconSpriteUrl),
15049
+ });
15050
+ if (getEmbedConfig().callPrefetch) {
15051
+ prefetch(getEmbedConfig().thoughtSpotHost);
15052
+ }
15053
+ // Resolves the promise created in the initPromiseKey
15054
+ getValueFromWindow(initFlagKey).initPromiseResolve(authEE);
15055
+ getValueFromWindow(initFlagKey).isInitCalled = true;
15056
+ return authEE;
15057
+ };
14783
15058
  /**
14784
15059
  *
14785
15060
  */
@@ -14908,7 +15183,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
14908
15183
  return e;
14909
15184
  }
14910
15185
 
14911
- var name="@thoughtspot/visual-embed-sdk";var version$1="1.36.3";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports$1={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",build:"rollup -c",watch:"rollup -cw",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme --json static/typedoc/typedoc.json --disableOutputCheck","test-sdk":"jest -c jest.config.sdk.js --runInBand",test:"npm run test-sdk",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest",dev:"vite -c vite.local.config.ts"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3",lodash:"^4.17.21","mixpanel-browser":"2.47.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1",yaml:"^2.5.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/lodash":"^4.17.0","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0",crypto:"^1.0.1","current-git-branch":"^1.1.0","dts-bundle":"^0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","eslint-plugin-comment-length":"1.7.3","eslint-plugin-jsdoc":"^46.9.0","fs-extra":"^10.0.0","gh-pages":"6.3.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"4.24.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4",vite:"^5.3.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embedded","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version$1,description:description,module:module,main:main,types:types,files:files,exports:exports$1,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.es.js",limit:"31 kB"}],scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
15186
+ var name="@thoughtspot/visual-embed-sdk";var version$1="1.36.4";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports$1={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",build:"rollup -c",watch:"rollup -cw",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme --json static/typedoc/typedoc.json --disableOutputCheck","test-sdk":"jest -c jest.config.sdk.js --runInBand",test:"npm run test-sdk",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest",dev:"vite -c vite.local.config.ts"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3",lodash:"^4.17.21","mixpanel-browser":"2.47.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1",yaml:"^2.5.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/lodash":"^4.17.0","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0",crypto:"^1.0.1","current-git-branch":"^1.1.0","dts-bundle":"^0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","eslint-plugin-comment-length":"1.7.3","eslint-plugin-jsdoc":"^46.9.0","fs-extra":"^10.0.0","gh-pages":"6.3.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"4.24.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4",vite:"^5.3.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embedded","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version$1,description:description,module:module,main:main,types:types,files:files,exports:exports$1,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.es.js",limit:"31 kB"}],scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
14912
15187
 
14913
15188
  /**
14914
15189
  * Reloads the ThoughtSpot iframe.
@@ -15217,13 +15492,6 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
15217
15492
  }
15218
15493
  };
15219
15494
  this.el = getDOMNode(domSelector);
15220
- // TODO: handle error
15221
- this.embedConfig = getEmbedConfig();
15222
- if (!this.embedConfig.authTriggerContainer && !this.embedConfig.useEventForSAMLPopup) {
15223
- this.embedConfig.authTriggerContainer = domSelector;
15224
- }
15225
- this.thoughtSpotHost = getThoughtSpotHost(this.embedConfig);
15226
- this.thoughtSpotV2Base = getV2BasePath(this.embedConfig);
15227
15495
  this.eventHandlerMap = new Map();
15228
15496
  this.isError = false;
15229
15497
  this.viewConfig = {
@@ -15231,12 +15499,21 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
15231
15499
  excludeRuntimeParametersfromURL: false,
15232
15500
  ...viewConfig,
15233
15501
  };
15234
- this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
15235
15502
  this.registerAppInit();
15236
15503
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_EMBED_CREATE, {
15237
15504
  ...viewConfig,
15238
15505
  });
15239
15506
  this.hostEventClient = new HostEventClient(this.iFrame);
15507
+ this.isReadyForRenderPromise = getInitPromise().then(async () => {
15508
+ const embedConfig = getEmbedConfig();
15509
+ this.embedConfig = embedConfig;
15510
+ if (!embedConfig.authTriggerContainer && !embedConfig.useEventForSAMLPopup) {
15511
+ this.embedConfig.authTriggerContainer = domSelector;
15512
+ }
15513
+ this.thoughtSpotHost = getThoughtSpotHost(embedConfig);
15514
+ this.thoughtSpotV2Base = getV2BasePath(embedConfig);
15515
+ this.shouldEncodeUrlQueryParams = embedConfig.shouldEncodeUrlQueryParams;
15516
+ });
15240
15517
  }
15241
15518
  /**
15242
15519
  * Throws error encountered during initialization.
@@ -15954,6 +16231,10 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
15954
16231
  * @param args
15955
16232
  */
15956
16233
  async render() {
16234
+ if (!getIsInitCalled()) {
16235
+ logger$3.error(ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
16236
+ }
16237
+ await this.isReadyForRenderPromise;
15957
16238
  this.isRendered = true;
15958
16239
  return this;
15959
16240
  }
@@ -15961,21 +16242,20 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
15961
16242
  return '';
15962
16243
  }
15963
16244
  handleRenderForPrerender() {
15964
- this.render();
16245
+ return this.render();
15965
16246
  }
15966
16247
  /**
15967
16248
  * Creates the preRender shell
15968
16249
  * @param showPreRenderByDefault - Show the preRender after render, hidden by default
15969
16250
  */
15970
- preRender(showPreRenderByDefault = false) {
16251
+ async preRender(showPreRenderByDefault = false) {
15971
16252
  if (!this.viewConfig.preRenderId) {
15972
16253
  logger$3.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
15973
16254
  return this;
15974
16255
  }
15975
16256
  this.isPreRendered = true;
15976
16257
  this.showPreRenderByDefault = showPreRenderByDefault;
15977
- this.handleRenderForPrerender();
15978
- return this;
16258
+ return this.handleRenderForPrerender();
15979
16259
  }
15980
16260
  /**
15981
16261
  * Get the Post Url Params for THOUGHTSPOT from the current
@@ -16028,6 +16308,10 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
16028
16308
  * @returns
16029
16309
  */
16030
16310
  async prerenderGeneric() {
16311
+ if (!getIsInitCalled()) {
16312
+ logger$3.error(ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
16313
+ }
16314
+ await this.isReadyForRenderPromise;
16031
16315
  const prerenderFrameSrc = this.getRootIframeSrc();
16032
16316
  this.isRendered = true;
16033
16317
  return this.renderIFrame(prerenderFrameSrc);
@@ -16041,17 +16325,16 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
16041
16325
  * Also, synchronizes the style of the PreRender component with the embedding
16042
16326
  * element.
16043
16327
  */
16044
- showPreRender() {
16328
+ async showPreRender() {
16045
16329
  if (!this.viewConfig.preRenderId) {
16046
16330
  logger$3.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
16047
- return;
16331
+ return this;
16048
16332
  }
16049
16333
  if (!this.isPreRenderAvailable()) {
16050
16334
  const isAvailable = this.connectPreRendered();
16051
16335
  if (!isAvailable) {
16052
16336
  // if the Embed component is not preRendered , Render it now and
16053
- this.preRender(true);
16054
- return;
16337
+ return this.preRender(true);
16055
16338
  }
16056
16339
  this.validatePreRenderViewConfig(this.viewConfig);
16057
16340
  }
@@ -16074,6 +16357,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
16074
16357
  this.beforePrerenderVisible();
16075
16358
  removeStyleProperties(this.preRenderWrapper, ['z-index', 'opacity', 'pointer-events']);
16076
16359
  this.subscribeToEvents();
16360
+ return this;
16077
16361
  }
16078
16362
  /**
16079
16363
  * Synchronizes the style properties of the PreRender component with the embedding
@@ -16259,7 +16543,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
16259
16543
  * Render the embedded ThoughtSpot search
16260
16544
  */
16261
16545
  async render() {
16262
- super.render();
16546
+ await super.render();
16263
16547
  const src = this.getIFrameSrc();
16264
16548
  await this.renderIFrame(src);
16265
16549
  return this;
@@ -16346,7 +16630,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
16346
16630
  * @returns {SageEmbed} Eureka/Sage embed
16347
16631
  */
16348
16632
  async render() {
16349
- super.render();
16633
+ await super.render();
16350
16634
  const src = this.getIFrameSrc();
16351
16635
  await this.renderV1Embed(src);
16352
16636
  return this;
@@ -16518,7 +16802,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
16518
16802
  * Render the embedded ThoughtSpot search
16519
16803
  */
16520
16804
  async render() {
16521
- super.render();
16805
+ await super.render();
16522
16806
  this.viewConfig;
16523
16807
  const src = this.getIFrameSrc();
16524
16808
  await this.renderIFrame(src);
@@ -16817,7 +17101,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
16817
17101
  * to be embedded.
16818
17102
  */
16819
17103
  async render() {
16820
- super.render();
17104
+ await super.render();
16821
17105
  const src = this.getIFrameSrc();
16822
17106
  await this.renderV1Embed(src);
16823
17107
  return this;
@@ -17096,12 +17380,11 @@ query GetEurekaVizSnapshots(
17096
17380
  this.navigateToLiveboard(libId);
17097
17381
  }
17098
17382
  }
17099
- handleRenderForPrerender() {
17383
+ async handleRenderForPrerender() {
17100
17384
  if (isUndefined$1(this.viewConfig.liveboardId)) {
17101
- this.prerenderGeneric();
17102
- return;
17385
+ return this.prerenderGeneric();
17103
17386
  }
17104
- super.handleRenderForPrerender();
17387
+ return super.handleRenderForPrerender();
17105
17388
  }
17106
17389
  /**
17107
17390
  * Triggers an event to the embedded app
@@ -17126,7 +17409,7 @@ query GetEurekaVizSnapshots(
17126
17409
  * visualization ID and the runtime filters.
17127
17410
  */
17128
17411
  async render() {
17129
- super.render();
17412
+ await super.render();
17130
17413
  const src = this.getIFrameSrc();
17131
17414
  await this.renderV1Embed(src);
17132
17415
  this.showPreviewLoader();
@@ -17263,7 +17546,7 @@ query GetEurekaVizSnapshots(
17263
17546
  return `${this.getEmbedBasePath(query)}/embed/${path}${tsPostHashParams}`;
17264
17547
  }
17265
17548
  async render() {
17266
- super.render();
17549
+ await super.render();
17267
17550
  const src = this.getIframeSrc();
17268
17551
  await this.renderIFrame(src);
17269
17552
  return this;
@@ -17532,6 +17815,27 @@ query GetEurekaVizSnapshots(
17532
17815
  */
17533
17816
  function useEmbedRef() {
17534
17817
  return React.useRef(null);
17818
+ }
17819
+ /**
17820
+ *
17821
+ * @param config - EmbedConfig
17822
+ * @returns AuthEventEmitter
17823
+ * @example
17824
+ * ```
17825
+ * function Component() {
17826
+ * const authEE = useInit({ ...initConfig });
17827
+ * return <LiveboardEmbed ref={ref} liveboardId={<id>} />
17828
+ * }
17829
+ * ```
17830
+ * @version SDK: 1.36.2 | ThoughtSpot: *
17831
+ */
17832
+ function useInit(config) {
17833
+ const ref = React.useRef(null);
17834
+ useDeepCompareEffect(() => {
17835
+ const authEE = init(config);
17836
+ ref.current = authEE;
17837
+ }, [config]);
17838
+ return ref;
17535
17839
  }
17536
17840
 
17537
17841
  const ALIAS = Symbol.for('yaml.alias');
@@ -24952,5 +25256,6 @@ query GetEurekaVizSnapshots(
24952
25256
  exports.SearchEmbed = SearchEmbed;
24953
25257
  exports.getSessionInfo = getSessionInfo;
24954
25258
  exports.useEmbedRef = useEmbedRef;
25259
+ exports.useInit = useInit;
24955
25260
 
24956
25261
  }));