@thoughtspot/visual-embed-sdk 1.36.3 → 1.36.5

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 (185) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/css-variables.d.ts +1 -1
  3. package/cjs/src/css-variables.d.ts.map +1 -1
  4. package/cjs/src/embed/app.d.ts.map +1 -1
  5. package/cjs/src/embed/app.js +1 -1
  6. package/cjs/src/embed/app.js.map +1 -1
  7. package/cjs/src/embed/base.d.ts +4 -0
  8. package/cjs/src/embed/base.d.ts.map +1 -1
  9. package/cjs/src/embed/base.js +27 -1
  10. package/cjs/src/embed/base.js.map +1 -1
  11. package/cjs/src/embed/bodyless-conversation.d.ts.map +1 -1
  12. package/cjs/src/embed/bodyless-conversation.js +1 -1
  13. package/cjs/src/embed/bodyless-conversation.js.map +1 -1
  14. package/cjs/src/embed/conversation.d.ts.map +1 -1
  15. package/cjs/src/embed/conversation.js +1 -1
  16. package/cjs/src/embed/conversation.js.map +1 -1
  17. package/cjs/src/embed/embedConfig.d.ts.map +1 -1
  18. package/cjs/src/embed/embedConfig.js.map +1 -1
  19. package/cjs/src/embed/liveboard.d.ts +2 -2
  20. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  21. package/cjs/src/embed/liveboard.js +4 -5
  22. package/cjs/src/embed/liveboard.js.map +1 -1
  23. package/cjs/src/embed/liveboard.spec.js +11 -11
  24. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  25. package/cjs/src/embed/sage.d.ts.map +1 -1
  26. package/cjs/src/embed/sage.js +1 -1
  27. package/cjs/src/embed/sage.js.map +1 -1
  28. package/cjs/src/embed/search-bar.d.ts.map +1 -1
  29. package/cjs/src/embed/search-bar.js +1 -1
  30. package/cjs/src/embed/search-bar.js.map +1 -1
  31. package/cjs/src/embed/search.d.ts.map +1 -1
  32. package/cjs/src/embed/search.js +1 -1
  33. package/cjs/src/embed/search.js.map +1 -1
  34. package/cjs/src/embed/ts-embed.d.ts +4 -3
  35. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  36. package/cjs/src/embed/ts-embed.js +25 -16
  37. package/cjs/src/embed/ts-embed.js.map +1 -1
  38. package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
  39. package/cjs/src/embed/ts-embed.spec.js +71 -5
  40. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  41. package/cjs/src/errors.d.ts +1 -0
  42. package/cjs/src/errors.d.ts.map +1 -1
  43. package/cjs/src/errors.js +1 -0
  44. package/cjs/src/errors.js.map +1 -1
  45. package/cjs/src/react/all-types-export.d.ts +1 -1
  46. package/cjs/src/react/all-types-export.d.ts.map +1 -1
  47. package/cjs/src/react/all-types-export.js +2 -1
  48. package/cjs/src/react/all-types-export.js.map +1 -1
  49. package/cjs/src/react/index.d.ts +16 -0
  50. package/cjs/src/react/index.d.ts.map +1 -1
  51. package/cjs/src/react/index.js +25 -2
  52. package/cjs/src/react/index.js.map +1 -1
  53. package/cjs/src/types.d.ts +43 -19
  54. package/cjs/src/types.d.ts.map +1 -1
  55. package/cjs/src/types.js +43 -19
  56. package/cjs/src/types.js.map +1 -1
  57. package/cjs/src/utils/with-resolvers-polyfill.d.ts +1 -0
  58. package/cjs/src/utils/with-resolvers-polyfill.d.ts.map +1 -0
  59. package/cjs/src/utils/with-resolvers-polyfill.js +12 -0
  60. package/cjs/src/utils/with-resolvers-polyfill.js.map +1 -0
  61. package/cjs/src/utils.d.ts +17 -2
  62. package/cjs/src/utils.d.ts.map +1 -1
  63. package/cjs/src/utils.js +27 -3
  64. package/cjs/src/utils.js.map +1 -1
  65. package/dist/{index-BJx3m5_V.js → index-Cyvfex-A.js} +1 -1
  66. package/dist/src/css-variables.d.ts +1 -1
  67. package/dist/src/css-variables.d.ts.map +1 -1
  68. package/dist/src/embed/app.d.ts.map +1 -1
  69. package/dist/src/embed/base.d.ts +4 -0
  70. package/dist/src/embed/base.d.ts.map +1 -1
  71. package/dist/src/embed/bodyless-conversation.d.ts.map +1 -1
  72. package/dist/src/embed/conversation.d.ts.map +1 -1
  73. package/dist/src/embed/embedConfig.d.ts.map +1 -1
  74. package/dist/src/embed/liveboard.d.ts +2 -2
  75. package/dist/src/embed/liveboard.d.ts.map +1 -1
  76. package/dist/src/embed/sage.d.ts.map +1 -1
  77. package/dist/src/embed/search-bar.d.ts.map +1 -1
  78. package/dist/src/embed/search.d.ts.map +1 -1
  79. package/dist/src/embed/ts-embed.d.ts +4 -3
  80. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  81. package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
  82. package/dist/src/errors.d.ts +1 -0
  83. package/dist/src/errors.d.ts.map +1 -1
  84. package/dist/src/react/all-types-export.d.ts +1 -1
  85. package/dist/src/react/all-types-export.d.ts.map +1 -1
  86. package/dist/src/react/index.d.ts +16 -0
  87. package/dist/src/react/index.d.ts.map +1 -1
  88. package/dist/src/types.d.ts +43 -19
  89. package/dist/src/types.d.ts.map +1 -1
  90. package/dist/src/utils/with-resolvers-polyfill.d.ts +1 -0
  91. package/dist/src/utils/with-resolvers-polyfill.d.ts.map +1 -0
  92. package/dist/src/utils.d.ts +17 -2
  93. package/dist/src/utils.d.ts.map +1 -1
  94. package/dist/tsembed-react.es.js +392 -64
  95. package/dist/tsembed-react.js +390 -61
  96. package/dist/tsembed.es.js +128 -51
  97. package/dist/tsembed.js +127 -50
  98. package/dist/visual-embed-sdk-react-full.d.ts +1277 -1234
  99. package/dist/visual-embed-sdk-react.d.ts +711 -668
  100. package/dist/visual-embed-sdk.d.ts +53 -24
  101. package/lib/package.json +1 -1
  102. package/lib/src/css-variables.d.ts +1 -1
  103. package/lib/src/css-variables.d.ts.map +1 -1
  104. package/lib/src/embed/app.d.ts.map +1 -1
  105. package/lib/src/embed/app.js +1 -1
  106. package/lib/src/embed/app.js.map +1 -1
  107. package/lib/src/embed/base.d.ts +4 -0
  108. package/lib/src/embed/base.d.ts.map +1 -1
  109. package/lib/src/embed/base.js +24 -1
  110. package/lib/src/embed/base.js.map +1 -1
  111. package/lib/src/embed/bodyless-conversation.d.ts.map +1 -1
  112. package/lib/src/embed/bodyless-conversation.js +1 -1
  113. package/lib/src/embed/bodyless-conversation.js.map +1 -1
  114. package/lib/src/embed/conversation.d.ts.map +1 -1
  115. package/lib/src/embed/conversation.js +1 -1
  116. package/lib/src/embed/conversation.js.map +1 -1
  117. package/lib/src/embed/embedConfig.d.ts.map +1 -1
  118. package/lib/src/embed/embedConfig.js.map +1 -1
  119. package/lib/src/embed/liveboard.d.ts +2 -2
  120. package/lib/src/embed/liveboard.d.ts.map +1 -1
  121. package/lib/src/embed/liveboard.js +4 -5
  122. package/lib/src/embed/liveboard.js.map +1 -1
  123. package/lib/src/embed/liveboard.spec.js +11 -11
  124. package/lib/src/embed/liveboard.spec.js.map +1 -1
  125. package/lib/src/embed/sage.d.ts.map +1 -1
  126. package/lib/src/embed/sage.js +1 -1
  127. package/lib/src/embed/sage.js.map +1 -1
  128. package/lib/src/embed/search-bar.d.ts.map +1 -1
  129. package/lib/src/embed/search-bar.js +1 -1
  130. package/lib/src/embed/search-bar.js.map +1 -1
  131. package/lib/src/embed/search.d.ts.map +1 -1
  132. package/lib/src/embed/search.js +1 -1
  133. package/lib/src/embed/search.js.map +1 -1
  134. package/lib/src/embed/ts-embed.d.ts +4 -3
  135. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  136. package/lib/src/embed/ts-embed.js +26 -17
  137. package/lib/src/embed/ts-embed.js.map +1 -1
  138. package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
  139. package/lib/src/embed/ts-embed.spec.js +71 -5
  140. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  141. package/lib/src/errors.d.ts +1 -0
  142. package/lib/src/errors.d.ts.map +1 -1
  143. package/lib/src/errors.js +1 -0
  144. package/lib/src/errors.js.map +1 -1
  145. package/lib/src/react/all-types-export.d.ts +1 -1
  146. package/lib/src/react/all-types-export.d.ts.map +1 -1
  147. package/lib/src/react/all-types-export.js +1 -1
  148. package/lib/src/react/all-types-export.js.map +1 -1
  149. package/lib/src/react/index.d.ts +16 -0
  150. package/lib/src/react/index.d.ts.map +1 -1
  151. package/lib/src/react/index.js +23 -1
  152. package/lib/src/react/index.js.map +1 -1
  153. package/lib/src/types.d.ts +43 -19
  154. package/lib/src/types.d.ts.map +1 -1
  155. package/lib/src/types.js +43 -19
  156. package/lib/src/types.js.map +1 -1
  157. package/lib/src/utils/with-resolvers-polyfill.d.ts +1 -0
  158. package/lib/src/utils/with-resolvers-polyfill.d.ts.map +1 -0
  159. package/lib/src/utils/with-resolvers-polyfill.js +12 -0
  160. package/lib/src/utils/with-resolvers-polyfill.js.map +1 -0
  161. package/lib/src/utils.d.ts +17 -2
  162. package/lib/src/utils.d.ts.map +1 -1
  163. package/lib/src/utils.js +25 -2
  164. package/lib/src/utils.js.map +1 -1
  165. package/lib/src/visual-embed-sdk.d.ts +54 -25
  166. package/package.json +1 -1
  167. package/src/css-variables.ts +1 -1
  168. package/src/embed/app.ts +2 -1
  169. package/src/embed/base.ts +41 -1
  170. package/src/embed/bodyless-conversation.ts +2 -1
  171. package/src/embed/conversation.ts +2 -1
  172. package/src/embed/embedConfig.ts +1 -1
  173. package/src/embed/liveboard.spec.ts +11 -11
  174. package/src/embed/liveboard.ts +5 -6
  175. package/src/embed/sage.ts +1 -2
  176. package/src/embed/search-bar.tsx +1 -2
  177. package/src/embed/search.ts +1 -2
  178. package/src/embed/ts-embed.spec.ts +83 -5
  179. package/src/embed/ts-embed.ts +33 -17
  180. package/src/errors.ts +1 -0
  181. package/src/react/all-types-export.ts +1 -0
  182. package/src/react/index.tsx +27 -2
  183. package/src/types.ts +43 -19
  184. package/src/utils/with-resolvers-polyfill.ts +11 -0
  185. package/src/utils.ts +35 -4
@@ -1,6 +1,6 @@
1
- /* @thoughtspot/visual-embed-sdk version 1.36.3 */
1
+ /* @thoughtspot/visual-embed-sdk version 1.36.5 */
2
2
  import * as React from 'react';
3
- import React__default from 'react';
3
+ import React__default, { useRef } from 'react';
4
4
 
5
5
  function _mergeNamespaces(n, m) {
6
6
  m.forEach(function (e) {
@@ -461,13 +461,23 @@ const sdkWindowKey = '_tsEmbedSDK';
461
461
  * Stores a value in the global `window` object under the `_tsEmbedSDK` namespace.
462
462
  * @param key - The key under which the value will be stored.
463
463
  * @param value - The value to store.
464
+ * @param options - Additional options.
465
+ * @param options.ignoreIfAlreadyExists - Does not set if value for key is set.
466
+ *
467
+ * @returns The stored value.
468
+ *
469
+ * @version SDK: 1.36.2 | ThoughtSpot: *
464
470
  */
465
- const storeValueInWindow = (key, value) => {
471
+ function storeValueInWindow(key, value, options = {}) {
466
472
  if (!window[sdkWindowKey]) {
467
473
  window[sdkWindowKey] = {};
468
474
  }
475
+ if (options.ignoreIfAlreadyExists && key in window[sdkWindowKey]) {
476
+ return window[sdkWindowKey][key];
477
+ }
469
478
  window[sdkWindowKey][key] = value;
470
- };
479
+ return value;
480
+ }
471
481
  /**
472
482
  * Retrieves a stored value from the global `window` object under the `_tsEmbedSDK` namespace.
473
483
  * @param key - The key whose value needs to be retrieved.
@@ -864,8 +874,9 @@ var EmbedEvent;
864
874
  */
865
875
  EmbedEvent["Load"] = "load";
866
876
  /**
867
- * Data pertaining to an Answer or Liveboard is received
868
- * @return data - The Answer or Liveboard data
877
+ * Data pertaining to an Answer or Liveboard is received.
878
+ * The event payload includes the raw data of the object.
879
+ * @return data - Answer of Liveboard data
869
880
  * @version SDK: 1.1.0 | ThoughtSpot: ts7.may.cl, 8.4.1.sw
870
881
  * @example
871
882
  *```js
@@ -1769,17 +1780,39 @@ var EmbedEvent;
1769
1780
  */
1770
1781
  EmbedEvent["ParameterChanged"] = "parameterChanged";
1771
1782
  /**
1772
- * Emitted when the table viz renders.
1773
- * You can use this event as a hook to trigger
1774
- * other events on the rendered table viz data.
1783
+ * Emits when a table visualization is rendered in
1784
+ * the ThoughtSpot embedded app.
1785
+ * You can also use this event as a hook to trigger host events
1786
+ * such as `HostEvent.TransformTableVizData` on the table visualization.
1787
+ * The event payload contains the data used in the rendered table.
1788
+ * You can extract the relevant data from the payload
1789
+ * stored in `payload.data.data.columnDataLite`.
1790
+ * `columnDataLite` is a multidimensional array that contains
1791
+ * data values for each column, which was used in the query to
1792
+ * generate the table visualization. To find and modify specific cell data,
1793
+ * you can either loop through the array or directly access a cell if
1794
+ * you know its position and data index.
1795
+ * In the following code sample, the first cell in the first column
1796
+ * (`columnDataLite[0].dataValue[0]`) is set to `new fob`.
1797
+ * Note that any changes made to the data in the payload will only update the
1798
+ * visual presentation and do not affect the underlying data.
1799
+ * To persist data value modifications after a reload or during chart
1800
+ * interactions such as drill down, ensure that the modified
1801
+ * payload in the `columnDataLite` is passed on to
1802
+ * `HostEvent.TransformTableVizData` and trigger an update to
1803
+ * the table visualization.
1804
+ * If the Row-Level Security (RLS) rules are applied on the
1805
+ * Worksheet or Model, exercise caution when changing column
1806
+ * or table cell values to maintain data security.
1807
+ *
1775
1808
  * @example
1776
1809
  * ```js
1777
1810
  * searchEmbed.on(EmbedEvent.TableVizRendered, (payload) => {
1778
- * console.log(payload);
1779
- * const columnDataLite = payload.data.data.columnDataLite;
1780
- * columnDataLite[0].dataValue[0]="new fob";
1781
- * console.log('>>> new Data', columnDataLite);
1782
- * searchEmbed.trigger(HostEvent.TransformTableVizData, columnDataLite);
1811
+ * console.log(payload);
1812
+ * const columnDataLite = payload.data.data.columnDataLite;
1813
+ * columnDataLite[0].dataValue[0]="new fob";
1814
+ * console.log('>>> new Data', columnDataLite);
1815
+ * searchEmbed.trigger(HostEvent.TransformTableVizData, columnDataLite);
1783
1816
  * })
1784
1817
  * ```
1785
1818
  * @version SDK: 1.35.12 | ThoughtSpot: 10.7.0.cl
@@ -2818,19 +2851,20 @@ var HostEvent;
2818
2851
  */
2819
2852
  HostEvent["UIPassthrough"] = "UiPassthrough";
2820
2853
  /**
2821
- * Triggers the table viz rerender with the updated data.
2854
+ * Triggers the table visualization re-render with the updated data.
2822
2855
  * Includes the following properties:
2823
- * @param - columnDataLite - an array of object containing data
2824
- * transformed from data picked from TableVizRendered event.
2825
- * For example, { columnDataLite: []}
2856
+ * @param - `columnDataLite` - an array of object containing the
2857
+ * data value modifications retrieved from the `EmbedEvent.TableVizRendered`
2858
+ * payload.For example, { columnDataLite: []}`.
2859
+ *
2826
2860
  * @example
2827
2861
  * ```js
2828
2862
  * searchEmbed.on(EmbedEvent.TableVizRendered, (payload) => {
2829
- * console.log(payload);
2830
- * const columnDataLite = payload.data.data.columnDataLite;
2831
- * columnDataLite[0].dataValue[0]="new fob";
2832
- * console.log('>>> new Data', columnDataLite);
2833
- * searchEmbed.trigger(HostEvent.TransformTableVizData, columnDataLite);
2863
+ * console.log(payload);
2864
+ * const columnDataLite = payload.data.data.columnDataLite;
2865
+ * columnDataLite[0].dataValue[0]="new fob";
2866
+ * console.log('>>> new Data', columnDataLite);
2867
+ * searchEmbed.trigger(HostEvent.TransformTableVizData, columnDataLite);
2834
2868
  * })
2835
2869
  * ```
2836
2870
  * @version SDK: 1.35.12 | ThoughtSpot: 10.7.0.cl
@@ -6557,6 +6591,9 @@ const logFunctions = {
6557
6591
  [LogLevel.TRACE]: console.trace,
6558
6592
  };
6559
6593
  let globalLogLevelOverride = LogLevel.TRACE;
6594
+ const setGlobalLogLevelOverride = (logLevel) => {
6595
+ globalLogLevelOverride = logLevel;
6596
+ };
6560
6597
  const logLevelToNumber = {
6561
6598
  [LogLevel.SILENT]: 0,
6562
6599
  [LogLevel.ERROR]: 1,
@@ -6633,6 +6670,7 @@ const ERROR_MESSAGE = {
6633
6670
  CSP_VIOLATION_ALERT: 'CSP violation detected. Please check the console errors for more details.',
6634
6671
  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',
6635
6672
  MISSING_REPORTING_OBSERVER: 'ReportingObserver not supported',
6673
+ 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',
6636
6674
  };
6637
6675
 
6638
6676
  const EndPoints = {
@@ -6839,7 +6877,18 @@ const configKey = 'embedConfig';
6839
6877
  * @version SDK: 1.19.0 | ThoughtSpot: *
6840
6878
  * @group Global methods
6841
6879
  */
6842
- const getEmbedConfig = () => getValueFromWindow(configKey) || {};
6880
+ const getEmbedConfig = () => getValueFromWindow(configKey) || {};
6881
+ /**
6882
+ * Sets the configuration embed was initialized with.
6883
+ * And returns the new configuration.
6884
+ * @param newConfig The configuration to set.
6885
+ * @version SDK: 1.27.0 | ThoughtSpot: *
6886
+ * @group Global methods
6887
+ */
6888
+ const setEmbedConfig = (newConfig) => {
6889
+ storeValueInWindow(configKey, newConfig);
6890
+ return getValueFromWindow(configKey);
6891
+ };
6843
6892
 
6844
6893
  /**
6845
6894
  * Fetch wrapper that adds the authentication token to the request.
@@ -7446,7 +7495,7 @@ class AnswerService {
7446
7495
  async getTML() {
7447
7496
  const { object } = await this.executeQuery(getAnswerTML, {});
7448
7497
  const edoc = object[0].edoc;
7449
- const YAML = await import('./index-BJx3m5_V.js');
7498
+ const YAML = await import('./index-Cyvfex-A.js');
7450
7499
  const parsedDoc = YAML.parse(edoc);
7451
7500
  return {
7452
7501
  answer: {
@@ -13827,7 +13876,7 @@ function initMixpanel(sessionInfo) {
13827
13876
  }
13828
13877
  }
13829
13878
 
13830
- createCommonjsModule(function (module) {
13879
+ var eventemitter3 = createCommonjsModule(function (module) {
13831
13880
 
13832
13881
  var has = Object.prototype.hasOwnProperty
13833
13882
  , prefix = '~';
@@ -14170,7 +14219,52 @@ var ReportType;
14170
14219
  ReportType["CSP_VIOLATION"] = "csp-violation";
14171
14220
  ReportType["DEPRECATION"] = "deprecation";
14172
14221
  ReportType["INTERVENTION"] = "intervention";
14173
- })(ReportType || (ReportType = {}));
14222
+ })(ReportType || (ReportType = {}));
14223
+ let globalObserver = null;
14224
+ /**
14225
+ * Register a global ReportingObserver to capture all unhandled errors
14226
+ * @param overrideExisting boolean to override existing observer
14227
+ * @returns ReportingObserver | null
14228
+ */
14229
+ function registerReportingObserver(overrideExisting = false) {
14230
+ if (!(window.ReportingObserver)) {
14231
+ logger$3.warn(ERROR_MESSAGE.MISSING_REPORTING_OBSERVER);
14232
+ return null;
14233
+ }
14234
+ if (overrideExisting) {
14235
+ resetGlobalReportingObserver();
14236
+ }
14237
+ if (globalObserver) {
14238
+ return globalObserver;
14239
+ }
14240
+ const embedConfig = getEmbedConfig();
14241
+ globalObserver = new ReportingObserver((reports) => {
14242
+ reports.forEach((report) => {
14243
+ const { type, url, body } = report;
14244
+ const reportBody = body;
14245
+ const isThoughtSpotHost = url
14246
+ && url.startsWith(embedConfig.thoughtSpotHost);
14247
+ const isFrameHostError = type === ReportType.CSP_VIOLATION
14248
+ && reportBody.effectiveDirective === 'frame-ancestors';
14249
+ if (isThoughtSpotHost && isFrameHostError) {
14250
+ if (!embedConfig.suppressErrorAlerts) {
14251
+ alert(ERROR_MESSAGE.CSP_VIOLATION_ALERT);
14252
+ }
14253
+ logger$3.error(ERROR_MESSAGE.CSP_FRAME_HOST_VIOLATION_LOG_MESSAGE);
14254
+ }
14255
+ });
14256
+ }, { buffered: true });
14257
+ globalObserver.observe();
14258
+ return globalObserver;
14259
+ }
14260
+ /**
14261
+ * Resets the global ReportingObserver
14262
+ */
14263
+ function resetGlobalReportingObserver() {
14264
+ if (globalObserver)
14265
+ globalObserver.disconnect();
14266
+ globalObserver = null;
14267
+ }
14174
14268
 
14175
14269
  /**
14176
14270
  *
@@ -14352,7 +14446,45 @@ const getSessionDetails = (sessionInfoResp) => {
14352
14446
  clusterName: sessionInfoResp.configInfo.selfClusterName,
14353
14447
  ...sessionInfoResp,
14354
14448
  };
14355
- };
14449
+ };
14450
+ /**
14451
+ * Resets the cached session info object and forces a new fetch on the next call.
14452
+ * @example ```js
14453
+ * resetCachedSessionInfo();
14454
+ * const sessionInfo = await getSessionInfo();
14455
+ * console.log(sessionInfo);
14456
+ * ```
14457
+ * @version SDK: 1.28.3 | ThoughtSpot: *
14458
+ * @returns {void}
14459
+ */
14460
+ function resetCachedSessionInfo() {
14461
+ sessionInfo = null;
14462
+ }
14463
+ /**
14464
+ * Resets the cached preauth info object and forces a new fetch on the next call.
14465
+ * @example ```js
14466
+ * resetCachedPreauthInfo();
14467
+ * const preauthInfo = await getPreauthInfo();
14468
+ * console.log(preauthInfo);
14469
+ * ```
14470
+ * @version SDK: 1.28.3 | ThoughtSpot: *
14471
+ * @returns {void}
14472
+ */
14473
+ function resetCachedPreauthInfo() {
14474
+ preauthInfo = null;
14475
+ }
14476
+
14477
+ /**
14478
+ * This function resets all the services that are cached in the SDK.
14479
+ * This is to be called when the user logs out of the application and also
14480
+ * when init is called again.
14481
+ * @version SDK: 1.30.2 | ThoughtSpot: *
14482
+ */
14483
+ function resetAllCachedServices() {
14484
+ resetCachedAuthToken();
14485
+ resetCachedSessionInfo();
14486
+ resetCachedPreauthInfo();
14487
+ }
14356
14488
 
14357
14489
  // eslint-disable-next-line import/no-mutable-exports
14358
14490
  let loggedInStatus = false;
@@ -14422,42 +14554,61 @@ var AuthEvent;
14422
14554
  */
14423
14555
  AuthEvent["TRIGGER_SSO_POPUP"] = "TRIGGER_SSO_POPUP";
14424
14556
  })(AuthEvent || (AuthEvent = {}));
14557
+ let authEE;
14558
+ /**
14559
+ *
14560
+ * @param eventEmitter
14561
+ */
14562
+ function setAuthEE(eventEmitter) {
14563
+ authEE = eventEmitter;
14564
+ }
14425
14565
  /**
14426
14566
  *
14427
14567
  */
14428
14568
  function notifyAuthSDKSuccess() {
14429
- {
14569
+ if (!authEE) {
14430
14570
  logger$3.error(ERROR_MESSAGE.SDK_NOT_INITIALIZED);
14431
14571
  return;
14432
14572
  }
14573
+ authEE.emit(AuthStatus.SDK_SUCCESS);
14433
14574
  }
14434
14575
  /**
14435
14576
  *
14436
14577
  */
14437
14578
  async function notifyAuthSuccess() {
14438
- {
14579
+ if (!authEE) {
14439
14580
  logger$3.error(ERROR_MESSAGE.SDK_NOT_INITIALIZED);
14440
14581
  return;
14441
14582
  }
14583
+ try {
14584
+ getPreauthInfo();
14585
+ const sessionInfo = await getSessionInfo();
14586
+ authEE.emit(AuthStatus.SUCCESS, sessionInfo);
14587
+ }
14588
+ catch (e) {
14589
+ logger$3.error(ERROR_MESSAGE.SESSION_INFO_FAILED);
14590
+ }
14442
14591
  }
14443
14592
  /**
14444
14593
  *
14445
14594
  * @param failureType
14446
14595
  */
14447
14596
  function notifyAuthFailure(failureType) {
14448
- {
14597
+ if (!authEE) {
14449
14598
  logger$3.error(ERROR_MESSAGE.SDK_NOT_INITIALIZED);
14450
14599
  return;
14451
14600
  }
14601
+ authEE.emit(AuthStatus.FAILURE, failureType);
14452
14602
  }
14453
14603
  /**
14454
14604
  *
14455
14605
  */
14456
14606
  function notifyLogout() {
14457
- {
14607
+ if (!authEE) {
14458
14608
  logger$3.error(ERROR_MESSAGE.SDK_NOT_INITIALIZED);
14459
14609
  return;
14460
14610
  }
14611
+ authEE.emit(AuthStatus.LOGOUT);
14461
14612
  }
14462
14613
  /**
14463
14614
  * Check if we are logged into the ThoughtSpot cluster
@@ -14618,6 +14769,7 @@ async function samlPopupFlow(ssoURL, triggerContainer, triggerText) {
14618
14769
  samlAuthWindow.focus();
14619
14770
  }
14620
14771
  };
14772
+ authEE === null || authEE === void 0 ? void 0 : authEE.emit(AuthStatus.WAITING_FOR_POPUP);
14621
14773
  const containerEl = getDOMNode(triggerContainer);
14622
14774
  if (containerEl) {
14623
14775
  containerEl.innerHTML = '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
@@ -14633,6 +14785,7 @@ async function samlPopupFlow(ssoURL, triggerContainer, triggerText) {
14633
14785
  }
14634
14786
  });
14635
14787
  });
14788
+ authEE === null || authEE === void 0 ? void 0 : authEE.once(AuthEvent.TRIGGER_SSO_POPUP, openPopup);
14636
14789
  return samlCompletionPromise;
14637
14790
  }
14638
14791
  /**
@@ -14716,6 +14869,18 @@ const authenticate = async (embedConfig) => {
14716
14869
  }
14717
14870
  };
14718
14871
 
14872
+ if (typeof Promise.withResolvers === 'undefined') {
14873
+ Promise.withResolvers = () => {
14874
+ let resolve;
14875
+ let reject;
14876
+ const promise = new Promise((res, rej) => {
14877
+ resolve = res;
14878
+ reject = rej;
14879
+ });
14880
+ return { promise, resolve, reject };
14881
+ };
14882
+ }
14883
+
14719
14884
  /* eslint-disable camelcase */
14720
14885
  /* eslint-disable import/no-mutable-exports */
14721
14886
  /**
@@ -14725,12 +14890,12 @@ const authenticate = async (embedConfig) => {
14725
14890
  * @summary Base classes
14726
14891
  * @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
14727
14892
  */
14728
- ({
14893
+ const CONFIG_DEFAULTS = {
14729
14894
  loginFailedMessage: 'Not logged in',
14730
14895
  authTriggerText: 'Authorize',
14731
14896
  authType: AuthType.None,
14732
14897
  logLevel: LogLevel.ERROR,
14733
- });
14898
+ };
14734
14899
  let authPromise;
14735
14900
  const getAuthPromise = () => authPromise;
14736
14901
  /**
@@ -14752,12 +14917,146 @@ const handleAuth = () => {
14752
14917
  });
14753
14918
  return authPromise;
14754
14919
  };
14755
- ({
14920
+ const hostUrlToFeatureUrl = {
14756
14921
  [PrefetchFeatures.SearchEmbed]: (url, flags) => `${url}v2/?${flags}#/embed/answer`,
14757
14922
  [PrefetchFeatures.LiveboardEmbed]: (url, flags) => `${url}?${flags}`,
14758
14923
  [PrefetchFeatures.FullApp]: (url, flags) => `${url}?${flags}`,
14759
14924
  [PrefetchFeatures.VizEmbed]: (url, flags) => `${url}?${flags}`,
14760
- });
14925
+ };
14926
+ /**
14927
+ * Prefetches static resources from the specified URL. Web browsers can then cache the
14928
+ * prefetched resources and serve them from the user's local disk to provide faster access
14929
+ * to your app.
14930
+ * @param url The URL provided for prefetch
14931
+ * @param prefetchFeatures Specify features which needs to be prefetched.
14932
+ * @param additionalFlags This can be used to add any URL flag.
14933
+ * @version SDK: 1.4.0 | ThoughtSpot: ts7.sep.cl, 7.2.1
14934
+ * @group Global methods
14935
+ */
14936
+ const prefetch = (url, prefetchFeatures, additionalFlags) => {
14937
+ var _a;
14938
+ if (url === '') {
14939
+ // eslint-disable-next-line no-console
14940
+ logger$3.warn('The prefetch method does not have a valid URL');
14941
+ }
14942
+ else {
14943
+ const features = [PrefetchFeatures.FullApp];
14944
+ let hostUrl = url || getEmbedConfig().thoughtSpotHost;
14945
+ const prefetchFlags = {
14946
+ [Param.EmbedApp]: true,
14947
+ ...(_a = getEmbedConfig()) === null || _a === void 0 ? void 0 : _a.additionalFlags,
14948
+ ...additionalFlags,
14949
+ };
14950
+ hostUrl = hostUrl[hostUrl.length - 1] === '/' ? hostUrl : `${hostUrl}/`;
14951
+ Array.from(new Set(features
14952
+ .map((feature) => hostUrlToFeatureUrl[feature](hostUrl, getQueryParamString(prefetchFlags)))))
14953
+ .forEach((prefetchUrl, index) => {
14954
+ const iFrame = document.createElement('iframe');
14955
+ iFrame.src = prefetchUrl;
14956
+ iFrame.style.width = '0';
14957
+ iFrame.style.height = '0';
14958
+ iFrame.style.border = '0';
14959
+ iFrame.classList.add('prefetchIframe');
14960
+ iFrame.classList.add(`prefetchIframeNum-${index}`);
14961
+ document.body.appendChild(iFrame);
14962
+ });
14963
+ }
14964
+ };
14965
+ /**
14966
+ *
14967
+ * @param embedConfig
14968
+ */
14969
+ function sanity(embedConfig) {
14970
+ if (embedConfig.thoughtSpotHost === undefined) {
14971
+ throw new Error('ThoughtSpot host not provided');
14972
+ }
14973
+ if (embedConfig.authType === AuthType.TrustedAuthToken) {
14974
+ if (!embedConfig.authEndpoint && typeof embedConfig.getAuthToken !== 'function') {
14975
+ throw new Error('Trusted auth should provide either authEndpoint or getAuthToken');
14976
+ }
14977
+ }
14978
+ }
14979
+ /**
14980
+ *
14981
+ * @param embedConfig
14982
+ */
14983
+ function backwardCompat(embedConfig) {
14984
+ const newConfig = { ...embedConfig };
14985
+ if (embedConfig.noRedirect !== undefined && embedConfig.inPopup === undefined) {
14986
+ newConfig.inPopup = embedConfig.noRedirect;
14987
+ }
14988
+ return newConfig;
14989
+ }
14990
+ const initFlagKey = 'initFlagKey';
14991
+ const createAndSetInitPromise = () => {
14992
+ const { promise: initPromise, resolve: initPromiseResolve,
14993
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14994
+ // @ts-ignore
14995
+ } = Promise.withResolvers();
14996
+ const initFlagStore = {
14997
+ initPromise,
14998
+ isInitCalled: false,
14999
+ initPromiseResolve,
15000
+ };
15001
+ storeValueInWindow(initFlagKey, initFlagStore, {
15002
+ // In case of diff imports the promise might be already set
15003
+ ignoreIfAlreadyExists: true,
15004
+ });
15005
+ };
15006
+ createAndSetInitPromise();
15007
+ const getInitPromise = () => { var _a; return (_a = getValueFromWindow(initFlagKey)) === null || _a === void 0 ? void 0 : _a.initPromise; };
15008
+ const getIsInitCalled = () => { var _a; return !!((_a = getValueFromWindow(initFlagKey)) === null || _a === void 0 ? void 0 : _a.isInitCalled); };
15009
+ /**
15010
+ * Initializes the Visual Embed SDK globally and perform
15011
+ * authentication if applicable. This function needs to be called before any ThoughtSpot
15012
+ * component like Liveboard etc can be embedded. But need not wait for AuthEvent.SUCCESS
15013
+ * to actually embed. That is handled internally.
15014
+ * @param embedConfig The configuration object containing ThoughtSpot host,
15015
+ * authentication mechanism and so on.
15016
+ * @example
15017
+ * ```js
15018
+ * const authStatus = init({
15019
+ * thoughtSpotHost: 'https://my.thoughtspot.cloud',
15020
+ * authType: AuthType.None,
15021
+ * });
15022
+ * authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
15023
+ * ```
15024
+ * @returns {@link AuthEventEmitter} event emitter which emits events on authentication success,
15025
+ * failure and logout. See {@link AuthStatus}
15026
+ * @version SDK: 1.0.0 | ThoughtSpot ts7.april.cl, 7.2.1
15027
+ * @group Authentication / Init
15028
+ */
15029
+ const init = (embedConfig) => {
15030
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
15031
+ sanity(embedConfig);
15032
+ resetAllCachedServices();
15033
+ embedConfig = setEmbedConfig(backwardCompat({
15034
+ ...CONFIG_DEFAULTS,
15035
+ ...embedConfig,
15036
+ thoughtSpotHost: getThoughtSpotHost(embedConfig),
15037
+ }));
15038
+ setGlobalLogLevelOverride(embedConfig.logLevel);
15039
+ registerReportingObserver();
15040
+ const authEE = new eventemitter3();
15041
+ setAuthEE(authEE);
15042
+ handleAuth();
15043
+ const { password, ...configToTrack } = getEmbedConfig();
15044
+ uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
15045
+ ...configToTrack,
15046
+ usedCustomizationSheet: ((_b = (_a = embedConfig.customizations) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.customCSSUrl) != null,
15047
+ 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,
15048
+ 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,
15049
+ usedCustomizationStrings: !!((_k = (_j = embedConfig.customizations) === null || _j === void 0 ? void 0 : _j.content) === null || _k === void 0 ? void 0 : _k.strings),
15050
+ usedCustomizationIconSprite: !!((_l = embedConfig.customizations) === null || _l === void 0 ? void 0 : _l.iconSpriteUrl),
15051
+ });
15052
+ if (getEmbedConfig().callPrefetch) {
15053
+ prefetch(getEmbedConfig().thoughtSpotHost);
15054
+ }
15055
+ // Resolves the promise created in the initPromiseKey
15056
+ getValueFromWindow(initFlagKey).initPromiseResolve(authEE);
15057
+ getValueFromWindow(initFlagKey).isInitCalled = true;
15058
+ return authEE;
15059
+ };
14761
15060
  /**
14762
15061
  *
14763
15062
  */
@@ -14886,7 +15185,7 @@ function processEventData(type, e, thoughtSpotHost, containerEl) {
14886
15185
  return e;
14887
15186
  }
14888
15187
 
14889
- 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={".":{"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,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};
15188
+ var name="@thoughtspot/visual-embed-sdk";var version$1="1.36.5";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={".":{"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,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};
14890
15189
 
14891
15190
  /**
14892
15191
  * Reloads the ThoughtSpot iframe.
@@ -15195,13 +15494,6 @@ class TsEmbed {
15195
15494
  }
15196
15495
  };
15197
15496
  this.el = getDOMNode(domSelector);
15198
- // TODO: handle error
15199
- this.embedConfig = getEmbedConfig();
15200
- if (!this.embedConfig.authTriggerContainer && !this.embedConfig.useEventForSAMLPopup) {
15201
- this.embedConfig.authTriggerContainer = domSelector;
15202
- }
15203
- this.thoughtSpotHost = getThoughtSpotHost(this.embedConfig);
15204
- this.thoughtSpotV2Base = getV2BasePath(this.embedConfig);
15205
15497
  this.eventHandlerMap = new Map();
15206
15498
  this.isError = false;
15207
15499
  this.viewConfig = {
@@ -15209,12 +15501,21 @@ class TsEmbed {
15209
15501
  excludeRuntimeParametersfromURL: false,
15210
15502
  ...viewConfig,
15211
15503
  };
15212
- this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
15213
15504
  this.registerAppInit();
15214
15505
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_EMBED_CREATE, {
15215
15506
  ...viewConfig,
15216
15507
  });
15217
15508
  this.hostEventClient = new HostEventClient(this.iFrame);
15509
+ this.isReadyForRenderPromise = getInitPromise().then(async () => {
15510
+ const embedConfig = getEmbedConfig();
15511
+ this.embedConfig = embedConfig;
15512
+ if (!embedConfig.authTriggerContainer && !embedConfig.useEventForSAMLPopup) {
15513
+ this.embedConfig.authTriggerContainer = domSelector;
15514
+ }
15515
+ this.thoughtSpotHost = getThoughtSpotHost(embedConfig);
15516
+ this.thoughtSpotV2Base = getV2BasePath(embedConfig);
15517
+ this.shouldEncodeUrlQueryParams = embedConfig.shouldEncodeUrlQueryParams;
15518
+ });
15218
15519
  }
15219
15520
  /**
15220
15521
  * Throws error encountered during initialization.
@@ -15932,6 +16233,10 @@ class TsEmbed {
15932
16233
  * @param args
15933
16234
  */
15934
16235
  async render() {
16236
+ if (!getIsInitCalled()) {
16237
+ logger$3.error(ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
16238
+ }
16239
+ await this.isReadyForRenderPromise;
15935
16240
  this.isRendered = true;
15936
16241
  return this;
15937
16242
  }
@@ -15939,21 +16244,20 @@ class TsEmbed {
15939
16244
  return '';
15940
16245
  }
15941
16246
  handleRenderForPrerender() {
15942
- this.render();
16247
+ return this.render();
15943
16248
  }
15944
16249
  /**
15945
16250
  * Creates the preRender shell
15946
16251
  * @param showPreRenderByDefault - Show the preRender after render, hidden by default
15947
16252
  */
15948
- preRender(showPreRenderByDefault = false) {
16253
+ async preRender(showPreRenderByDefault = false) {
15949
16254
  if (!this.viewConfig.preRenderId) {
15950
16255
  logger$3.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
15951
16256
  return this;
15952
16257
  }
15953
16258
  this.isPreRendered = true;
15954
16259
  this.showPreRenderByDefault = showPreRenderByDefault;
15955
- this.handleRenderForPrerender();
15956
- return this;
16260
+ return this.handleRenderForPrerender();
15957
16261
  }
15958
16262
  /**
15959
16263
  * Get the Post Url Params for THOUGHTSPOT from the current
@@ -16006,6 +16310,10 @@ class TsEmbed {
16006
16310
  * @returns
16007
16311
  */
16008
16312
  async prerenderGeneric() {
16313
+ if (!getIsInitCalled()) {
16314
+ logger$3.error(ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
16315
+ }
16316
+ await this.isReadyForRenderPromise;
16009
16317
  const prerenderFrameSrc = this.getRootIframeSrc();
16010
16318
  this.isRendered = true;
16011
16319
  return this.renderIFrame(prerenderFrameSrc);
@@ -16019,17 +16327,16 @@ class TsEmbed {
16019
16327
  * Also, synchronizes the style of the PreRender component with the embedding
16020
16328
  * element.
16021
16329
  */
16022
- showPreRender() {
16330
+ async showPreRender() {
16023
16331
  if (!this.viewConfig.preRenderId) {
16024
16332
  logger$3.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
16025
- return;
16333
+ return this;
16026
16334
  }
16027
16335
  if (!this.isPreRenderAvailable()) {
16028
16336
  const isAvailable = this.connectPreRendered();
16029
16337
  if (!isAvailable) {
16030
16338
  // if the Embed component is not preRendered , Render it now and
16031
- this.preRender(true);
16032
- return;
16339
+ return this.preRender(true);
16033
16340
  }
16034
16341
  this.validatePreRenderViewConfig(this.viewConfig);
16035
16342
  }
@@ -16052,6 +16359,7 @@ class TsEmbed {
16052
16359
  this.beforePrerenderVisible();
16053
16360
  removeStyleProperties(this.preRenderWrapper, ['z-index', 'opacity', 'pointer-events']);
16054
16361
  this.subscribeToEvents();
16362
+ return this;
16055
16363
  }
16056
16364
  /**
16057
16365
  * Synchronizes the style properties of the PreRender component with the embedding
@@ -16237,7 +16545,7 @@ let SearchBarEmbed$1 = class SearchBarEmbed extends TsEmbed {
16237
16545
  * Render the embedded ThoughtSpot search
16238
16546
  */
16239
16547
  async render() {
16240
- super.render();
16548
+ await super.render();
16241
16549
  const src = this.getIFrameSrc();
16242
16550
  await this.renderIFrame(src);
16243
16551
  return this;
@@ -16324,7 +16632,7 @@ let SageEmbed$1 = class SageEmbed extends V1Embed {
16324
16632
  * @returns {SageEmbed} Eureka/Sage embed
16325
16633
  */
16326
16634
  async render() {
16327
- super.render();
16635
+ await super.render();
16328
16636
  const src = this.getIFrameSrc();
16329
16637
  await this.renderV1Embed(src);
16330
16638
  return this;
@@ -16496,7 +16804,7 @@ let SearchEmbed$1 = class SearchEmbed extends TsEmbed {
16496
16804
  * Render the embedded ThoughtSpot search
16497
16805
  */
16498
16806
  async render() {
16499
- super.render();
16807
+ await super.render();
16500
16808
  this.viewConfig;
16501
16809
  const src = this.getIFrameSrc();
16502
16810
  await this.renderIFrame(src);
@@ -16795,7 +17103,7 @@ let AppEmbed$1 = class AppEmbed extends V1Embed {
16795
17103
  * to be embedded.
16796
17104
  */
16797
17105
  async render() {
16798
- super.render();
17106
+ await super.render();
16799
17107
  const src = this.getIFrameSrc();
16800
17108
  await this.renderV1Embed(src);
16801
17109
  return this;
@@ -17074,12 +17382,11 @@ let LiveboardEmbed$1 = class LiveboardEmbed extends V1Embed {
17074
17382
  this.navigateToLiveboard(libId);
17075
17383
  }
17076
17384
  }
17077
- handleRenderForPrerender() {
17385
+ async handleRenderForPrerender() {
17078
17386
  if (isUndefined$1(this.viewConfig.liveboardId)) {
17079
- this.prerenderGeneric();
17080
- return;
17387
+ return this.prerenderGeneric();
17081
17388
  }
17082
- super.handleRenderForPrerender();
17389
+ return super.handleRenderForPrerender();
17083
17390
  }
17084
17391
  /**
17085
17392
  * Triggers an event to the embedded app
@@ -17104,7 +17411,7 @@ let LiveboardEmbed$1 = class LiveboardEmbed extends V1Embed {
17104
17411
  * visualization ID and the runtime filters.
17105
17412
  */
17106
17413
  async render() {
17107
- super.render();
17414
+ await super.render();
17108
17415
  const src = this.getIFrameSrc();
17109
17416
  await this.renderV1Embed(src);
17110
17417
  this.showPreviewLoader();
@@ -17241,7 +17548,7 @@ let ConversationEmbed$1 = class ConversationEmbed extends TsEmbed {
17241
17548
  return `${this.getEmbedBasePath(query)}/embed/${path}${tsPostHashParams}`;
17242
17549
  }
17243
17550
  async render() {
17244
- super.render();
17551
+ await super.render();
17245
17552
  const src = this.getIframeSrc();
17246
17553
  await this.renderIFrame(src);
17247
17554
  return this;
@@ -17510,6 +17817,27 @@ const PreRenderedConversationEmbed = componentFactory(ConversationEmbed$1, true)
17510
17817
  */
17511
17818
  function useEmbedRef() {
17512
17819
  return React__default.useRef(null);
17820
+ }
17821
+ /**
17822
+ *
17823
+ * @param config - EmbedConfig
17824
+ * @returns AuthEventEmitter
17825
+ * @example
17826
+ * ```
17827
+ * function Component() {
17828
+ * const authEE = useInit({ ...initConfig });
17829
+ * return <LiveboardEmbed ref={ref} liveboardId={<id>} />
17830
+ * }
17831
+ * ```
17832
+ * @version SDK: 1.36.2 | ThoughtSpot: *
17833
+ */
17834
+ function useInit(config) {
17835
+ const ref = useRef(null);
17836
+ useDeepCompareEffect(() => {
17837
+ const authEE = init(config);
17838
+ ref.current = authEE;
17839
+ }, [config]);
17840
+ return ref;
17513
17841
  }
17514
17842
 
17515
- export { Action, AppEmbed, ConversationEmbed, EmbedEvent, HomeLeftNavItem, HomepageModule, HostEvent, LiveboardEmbed, LogLevel, Page, PinboardEmbed, PreRenderedAppEmbed, PreRenderedConversationEmbed, PreRenderedLiveboardEmbed, PreRenderedPinboardEmbed, PreRenderedSageEmbed, PreRenderedSearchBarEmbed, PreRenderedSearchEmbed, RuntimeFilterOp, SageEmbed, SearchBarEmbed, SearchEmbed, getSessionInfo, useEmbedRef };
17843
+ export { Action, AppEmbed, ConversationEmbed, EmbedEvent, HomeLeftNavItem, HomepageModule, HostEvent, LiveboardEmbed, LogLevel, Page, PinboardEmbed, PreRenderedAppEmbed, PreRenderedConversationEmbed, PreRenderedLiveboardEmbed, PreRenderedPinboardEmbed, PreRenderedSageEmbed, PreRenderedSearchBarEmbed, PreRenderedSearchEmbed, RuntimeFilterOp, SageEmbed, SearchBarEmbed, SearchEmbed, getSessionInfo, useEmbedRef, useInit };