@thoughtspot/visual-embed-sdk 1.39.2-alpha.1 → 1.39.2-alpha.2

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 (170) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/config.spec.js +9 -0
  3. package/cjs/src/config.spec.js.map +1 -1
  4. package/cjs/src/embed/app.d.ts +75 -15
  5. package/cjs/src/embed/app.d.ts.map +1 -1
  6. package/cjs/src/embed/app.js +68 -9
  7. package/cjs/src/embed/app.js.map +1 -1
  8. package/cjs/src/embed/app.spec.js +356 -4
  9. package/cjs/src/embed/app.spec.js.map +1 -1
  10. package/cjs/src/embed/bodyless-conversation.d.ts +19 -7
  11. package/cjs/src/embed/bodyless-conversation.d.ts.map +1 -1
  12. package/cjs/src/embed/bodyless-conversation.js +24 -4
  13. package/cjs/src/embed/bodyless-conversation.js.map +1 -1
  14. package/cjs/src/embed/bodyless-conversation.spec.js +8 -190
  15. package/cjs/src/embed/bodyless-conversation.spec.js.map +1 -1
  16. package/cjs/src/embed/conversation.d.ts +2 -60
  17. package/cjs/src/embed/conversation.d.ts.map +1 -1
  18. package/cjs/src/embed/conversation.js +1 -9
  19. package/cjs/src/embed/conversation.js.map +1 -1
  20. package/cjs/src/embed/conversation.spec.js +0 -102
  21. package/cjs/src/embed/conversation.spec.js.map +1 -1
  22. package/cjs/src/embed/liveboard.d.ts +56 -0
  23. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  24. package/cjs/src/embed/liveboard.js +46 -0
  25. package/cjs/src/embed/liveboard.js.map +1 -1
  26. package/cjs/src/embed/liveboard.spec.js +203 -0
  27. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  28. package/cjs/src/errors.d.ts +1 -0
  29. package/cjs/src/errors.d.ts.map +1 -1
  30. package/cjs/src/errors.js +1 -0
  31. package/cjs/src/errors.js.map +1 -1
  32. package/cjs/src/index.d.ts +2 -2
  33. package/cjs/src/index.d.ts.map +1 -1
  34. package/cjs/src/index.js +2 -1
  35. package/cjs/src/index.js.map +1 -1
  36. package/cjs/src/react/all-types-export.d.ts +1 -1
  37. package/cjs/src/react/all-types-export.d.ts.map +1 -1
  38. package/cjs/src/react/all-types-export.js +3 -2
  39. package/cjs/src/react/all-types-export.js.map +1 -1
  40. package/cjs/src/react/index.d.ts +71 -20
  41. package/cjs/src/react/index.d.ts.map +1 -1
  42. package/cjs/src/react/index.js +79 -42
  43. package/cjs/src/react/index.js.map +1 -1
  44. package/cjs/src/react/index.spec.js +436 -100
  45. package/cjs/src/react/index.spec.js.map +1 -1
  46. package/cjs/src/types.d.ts +46 -4
  47. package/cjs/src/types.d.ts.map +1 -1
  48. package/cjs/src/types.js +28 -0
  49. package/cjs/src/types.js.map +1 -1
  50. package/cjs/src/utils/graphql/nlsService/conversation-service.d.ts.map +1 -1
  51. package/cjs/src/utils/graphql/nlsService/conversation-service.js +2 -0
  52. package/cjs/src/utils/graphql/nlsService/conversation-service.js.map +1 -1
  53. package/cjs/src/utils/processTrigger.js +2 -1
  54. package/cjs/src/utils/processTrigger.js.map +1 -1
  55. package/cjs/src/utils.d.ts +6 -0
  56. package/cjs/src/utils.d.ts.map +1 -1
  57. package/cjs/src/utils.js +23 -3
  58. package/cjs/src/utils.js.map +1 -1
  59. package/cjs/src/utils.spec.js +237 -1
  60. package/cjs/src/utils.spec.js.map +1 -1
  61. package/dist/index-e3Uw3YFO.js +7371 -0
  62. package/dist/src/embed/app.d.ts +75 -15
  63. package/dist/src/embed/app.d.ts.map +1 -1
  64. package/dist/src/embed/bodyless-conversation.d.ts +19 -7
  65. package/dist/src/embed/bodyless-conversation.d.ts.map +1 -1
  66. package/dist/src/embed/conversation.d.ts +2 -60
  67. package/dist/src/embed/conversation.d.ts.map +1 -1
  68. package/dist/src/embed/liveboard.d.ts +56 -0
  69. package/dist/src/embed/liveboard.d.ts.map +1 -1
  70. package/dist/src/errors.d.ts +1 -0
  71. package/dist/src/errors.d.ts.map +1 -1
  72. package/dist/src/index.d.ts +2 -2
  73. package/dist/src/index.d.ts.map +1 -1
  74. package/dist/src/react/all-types-export.d.ts +1 -1
  75. package/dist/src/react/all-types-export.d.ts.map +1 -1
  76. package/dist/src/react/index.d.ts +71 -20
  77. package/dist/src/react/index.d.ts.map +1 -1
  78. package/dist/src/types.d.ts +46 -4
  79. package/dist/src/types.d.ts.map +1 -1
  80. package/dist/src/utils/graphql/nlsService/conversation-service.d.ts.map +1 -1
  81. package/dist/src/utils.d.ts +6 -0
  82. package/dist/src/utils.d.ts.map +1 -1
  83. package/dist/tsembed-react.es.js +276 -74
  84. package/dist/tsembed-react.js +276 -72
  85. package/dist/tsembed.es.js +194 -27
  86. package/dist/tsembed.js +192 -25
  87. package/dist/visual-embed-sdk-react-full.d.ts +246 -105
  88. package/dist/visual-embed-sdk-react.d.ts +246 -105
  89. package/dist/visual-embed-sdk.d.ts +176 -86
  90. package/lib/package.json +1 -1
  91. package/lib/src/config.spec.js +9 -0
  92. package/lib/src/config.spec.js.map +1 -1
  93. package/lib/src/embed/app.d.ts +75 -15
  94. package/lib/src/embed/app.d.ts.map +1 -1
  95. package/lib/src/embed/app.js +68 -9
  96. package/lib/src/embed/app.js.map +1 -1
  97. package/lib/src/embed/app.spec.js +357 -5
  98. package/lib/src/embed/app.spec.js.map +1 -1
  99. package/lib/src/embed/bodyless-conversation.d.ts +19 -7
  100. package/lib/src/embed/bodyless-conversation.d.ts.map +1 -1
  101. package/lib/src/embed/bodyless-conversation.js +23 -4
  102. package/lib/src/embed/bodyless-conversation.js.map +1 -1
  103. package/lib/src/embed/bodyless-conversation.spec.js +9 -191
  104. package/lib/src/embed/bodyless-conversation.spec.js.map +1 -1
  105. package/lib/src/embed/conversation.d.ts +2 -60
  106. package/lib/src/embed/conversation.d.ts.map +1 -1
  107. package/lib/src/embed/conversation.js +2 -10
  108. package/lib/src/embed/conversation.js.map +1 -1
  109. package/lib/src/embed/conversation.spec.js +2 -104
  110. package/lib/src/embed/conversation.spec.js.map +1 -1
  111. package/lib/src/embed/liveboard.d.ts +56 -0
  112. package/lib/src/embed/liveboard.d.ts.map +1 -1
  113. package/lib/src/embed/liveboard.js +47 -1
  114. package/lib/src/embed/liveboard.js.map +1 -1
  115. package/lib/src/embed/liveboard.spec.js +203 -0
  116. package/lib/src/embed/liveboard.spec.js.map +1 -1
  117. package/lib/src/errors.d.ts +1 -0
  118. package/lib/src/errors.d.ts.map +1 -1
  119. package/lib/src/errors.js +1 -0
  120. package/lib/src/errors.js.map +1 -1
  121. package/lib/src/index.d.ts +2 -2
  122. package/lib/src/index.d.ts.map +1 -1
  123. package/lib/src/index.js +2 -2
  124. package/lib/src/index.js.map +1 -1
  125. package/lib/src/react/all-types-export.d.ts +1 -1
  126. package/lib/src/react/all-types-export.d.ts.map +1 -1
  127. package/lib/src/react/all-types-export.js +1 -1
  128. package/lib/src/react/all-types-export.js.map +1 -1
  129. package/lib/src/react/index.d.ts +71 -20
  130. package/lib/src/react/index.d.ts.map +1 -1
  131. package/lib/src/react/index.js +79 -43
  132. package/lib/src/react/index.js.map +1 -1
  133. package/lib/src/react/index.spec.js +439 -103
  134. package/lib/src/react/index.spec.js.map +1 -1
  135. package/lib/src/types.d.ts +46 -4
  136. package/lib/src/types.d.ts.map +1 -1
  137. package/lib/src/types.js +28 -0
  138. package/lib/src/types.js.map +1 -1
  139. package/lib/src/utils/graphql/nlsService/conversation-service.d.ts.map +1 -1
  140. package/lib/src/utils/graphql/nlsService/conversation-service.js +2 -0
  141. package/lib/src/utils/graphql/nlsService/conversation-service.js.map +1 -1
  142. package/lib/src/utils/processTrigger.js +2 -1
  143. package/lib/src/utils/processTrigger.js.map +1 -1
  144. package/lib/src/utils.d.ts +6 -0
  145. package/lib/src/utils.d.ts.map +1 -1
  146. package/lib/src/utils.js +21 -2
  147. package/lib/src/utils.js.map +1 -1
  148. package/lib/src/utils.spec.js +238 -2
  149. package/lib/src/utils.spec.js.map +1 -1
  150. package/lib/src/visual-embed-sdk.d.ts +178 -88
  151. package/package.json +1 -1
  152. package/src/config.spec.ts +11 -0
  153. package/src/embed/app.spec.ts +444 -4
  154. package/src/embed/app.ts +131 -27
  155. package/src/embed/bodyless-conversation.spec.ts +9 -203
  156. package/src/embed/bodyless-conversation.ts +24 -10
  157. package/src/embed/conversation.spec.ts +5 -131
  158. package/src/embed/conversation.ts +10 -82
  159. package/src/embed/liveboard.spec.ts +251 -1
  160. package/src/embed/liveboard.ts +97 -5
  161. package/src/errors.ts +1 -0
  162. package/src/index.ts +2 -0
  163. package/src/react/all-types-export.ts +2 -1
  164. package/src/react/index.spec.tsx +556 -157
  165. package/src/react/index.tsx +117 -51
  166. package/src/types.ts +42 -0
  167. package/src/utils/graphql/nlsService/conversation-service.ts +2 -0
  168. package/src/utils/processTrigger.ts +1 -1
  169. package/src/utils.spec.ts +279 -2
  170. package/src/utils.ts +28 -2
@@ -21,7 +21,7 @@ import {
21
21
  BaseViewConfig,
22
22
  LiveboardAppEmbedViewConfig,
23
23
  } from '../types';
24
- import { getQueryParamString, isUndefined } from '../utils';
24
+ import { calculateVisibleElementData, getQueryParamString, isUndefined } from '../utils';
25
25
  import { getAuthPromise } from './base';
26
26
  import { TsEmbed, V1Embed } from './ts-embed';
27
27
  import { addPreviewStylesIfNotPresent } from '../utils/global-styles';
@@ -324,6 +324,47 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
324
324
  * ```
325
325
  */
326
326
  isLiveboardStylingAndGroupingEnabled?: boolean;
327
+ /**
328
+ * This flag is used to enable the full height lazy load data.
329
+ *
330
+ * @example
331
+ * ```js
332
+ * const embed = new LiveboardEmbed('#embed-container', {
333
+ * // ...other options
334
+ * fullHeight: true,
335
+ * lazyLoadingForFullHeight: true,
336
+ * })
337
+ * ```
338
+ *
339
+ * @type {boolean}
340
+ * @default false
341
+ * @version SDK: 1.39.0 | ThoughtSpot:10.10.0.cl
342
+ */
343
+ lazyLoadingForFullHeight?: boolean;
344
+
345
+ /**
346
+ * The margin to be used for lazy loading.
347
+ *
348
+ * For example, if the margin is set to '10px',
349
+ * the visualization will be loaded 10px before the its top edge is visible in the
350
+ * viewport.
351
+ *
352
+ * The format is similar to CSS margin.
353
+ *
354
+ * @example
355
+ * ```js
356
+ * const embed = new LiveboardEmbed('#embed-container', {
357
+ * // ...other options
358
+ * fullHeight: true,
359
+ * lazyLoadingForFullHeight: true,
360
+ * // Using 0px, the visualization will be only loaded when its visible in the viewport.
361
+ * lazyLoadingMargin: '0px',
362
+ * })
363
+ * ```
364
+ * @type {string}
365
+ * @version SDK: 1.39.0 | ThoughtSpot:10.10.0.cl
366
+ */
367
+ lazyLoadingMargin?: string;
327
368
  }
328
369
 
329
370
  /**
@@ -346,19 +387,20 @@ export class LiveboardEmbed extends V1Embed {
346
387
 
347
388
  private defaultHeight = 500;
348
389
 
349
-
390
+
350
391
  constructor(domSelector: DOMSelector, viewConfig: LiveboardViewConfig) {
351
392
  viewConfig.embedComponentType = 'LiveboardEmbed';
352
393
  super(domSelector, viewConfig);
353
394
  if (this.viewConfig.fullHeight === true) {
354
395
  if (this.viewConfig.vizId) {
355
396
  logger.warn('Full height is currently only supported for Liveboard embeds.' +
356
- 'Using full height with vizId might lead to unexpected behavior.');
397
+ 'Using full height with vizId might lead to unexpected behavior.');
357
398
  }
358
399
 
359
400
  this.on(EmbedEvent.RouteChange, this.setIframeHeightForNonEmbedLiveboard);
360
401
  this.on(EmbedEvent.EmbedHeight, this.updateIFrameHeight);
361
402
  this.on(EmbedEvent.EmbedIframeCenter, this.embedIframeCenter);
403
+ this.on(EmbedEvent.RequestVisibleEmbedCoordinates, this.requestVisibleEmbedCoordinatesHandler);
362
404
  }
363
405
  }
364
406
 
@@ -367,7 +409,7 @@ export class LiveboardEmbed extends V1Embed {
367
409
  * embedded Liveboard or visualization.
368
410
  */
369
411
  protected getEmbedParams() {
370
- let params = {};
412
+ let params: any = {};
371
413
  params = this.getBaseQueryParams(params);
372
414
  const {
373
415
  enableVizTransformations,
@@ -402,6 +444,10 @@ export class LiveboardEmbed extends V1Embed {
402
444
 
403
445
  if (fullHeight === true) {
404
446
  params[Param.fullHeight] = true;
447
+ if (this.viewConfig.lazyLoadingForFullHeight) {
448
+ params[Param.IsLazyLoadingForEmbedEnabled] = true;
449
+ params[Param.RootMarginForLazyLoad] = this.viewConfig.lazyLoadingMargin;
450
+ }
405
451
  }
406
452
  if (defaultHeight) {
407
453
  this.defaultHeight = defaultHeight;
@@ -484,6 +530,23 @@ export class LiveboardEmbed extends V1Embed {
484
530
  return suffix;
485
531
  }
486
532
 
533
+ private sendFullHeightLazyLoadData = () => {
534
+ const data = calculateVisibleElementData(this.iFrame);
535
+ this.trigger(HostEvent.VisibleEmbedCoordinates, data);
536
+ }
537
+
538
+ /**
539
+ * This is a handler for the RequestVisibleEmbedCoordinates event.
540
+ * It is used to send the visible coordinates data to the host application.
541
+ * @param data The event payload
542
+ * @param responder The responder function
543
+ */
544
+ private requestVisibleEmbedCoordinatesHandler = (data: MessagePayload, responder: any) => {
545
+ logger.info('Sending RequestVisibleEmbedCoordinates', data);
546
+ const visibleCoordinatesData = calculateVisibleElementData(this.iFrame);
547
+ responder({ type: EmbedEvent.RequestVisibleEmbedCoordinates, data: visibleCoordinatesData });
548
+ }
549
+
487
550
  /**
488
551
  * Construct the URL of the embedded ThoughtSpot Liveboard or visualization
489
552
  * to be loaded within the iFrame.
@@ -509,6 +572,7 @@ export class LiveboardEmbed extends V1Embed {
509
572
  */
510
573
  private updateIFrameHeight = (data: MessagePayload) => {
511
574
  this.setIFrameHeight(Math.max(data.data, this.defaultHeight));
575
+ this.sendFullHeightLazyLoadData();
512
576
  };
513
577
 
514
578
  private embedIframeCenter = (data: MessagePayload, responder: any) => {
@@ -582,7 +646,7 @@ export class LiveboardEmbed extends V1Embed {
582
646
  }
583
647
 
584
648
  protected beforePrerenderVisible(): void {
585
- const embedObj = this.insertedDomEl?.[this.embedNodeKey] as LiveboardEmbed;
649
+ const embedObj = (this.insertedDomEl as any)?.[this.embedNodeKey] as LiveboardEmbed;
586
650
 
587
651
  if (isUndefined(embedObj)) return;
588
652
 
@@ -622,6 +686,33 @@ export class LiveboardEmbed extends V1Embed {
622
686
  }
623
687
  return super.trigger(messageType, dataWithVizId);
624
688
  }
689
+ /**
690
+ * Destroys the ThoughtSpot embed, and remove any nodes from the DOM.
691
+ * @version SDK: 1.39.0 | ThoughtSpot: 10.10.0.cl
692
+ */
693
+ public destroy() {
694
+ super.destroy();
695
+ this.unregisterLazyLoadEvents();
696
+ }
697
+
698
+ private postRender() {
699
+ this.registerLazyLoadEvents();
700
+ }
701
+
702
+ private registerLazyLoadEvents() {
703
+ if (this.viewConfig.fullHeight && this.viewConfig.lazyLoadingForFullHeight) {
704
+ // TODO: Use passive: true, install modernizr to check for passive
705
+ window.addEventListener('resize', this.sendFullHeightLazyLoadData);
706
+ window.addEventListener('scroll', this.sendFullHeightLazyLoadData);
707
+ }
708
+ }
709
+
710
+ private unregisterLazyLoadEvents() {
711
+ if (this.viewConfig.fullHeight && this.viewConfig.lazyLoadingForFullHeight) {
712
+ window.removeEventListener('resize', this.sendFullHeightLazyLoadData);
713
+ window.removeEventListener('scroll', this.sendFullHeightLazyLoadData);
714
+ }
715
+ }
625
716
 
626
717
  /**
627
718
  * Render an embedded ThoughtSpot Liveboard or visualization
@@ -635,6 +726,7 @@ export class LiveboardEmbed extends V1Embed {
635
726
  await this.renderV1Embed(src);
636
727
  this.showPreviewLoader();
637
728
 
729
+ this.postRender();
638
730
  return this;
639
731
  }
640
732
 
package/src/errors.ts CHANGED
@@ -17,4 +17,5 @@ export const ERROR_MESSAGE = {
17
17
  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',
18
18
  MISSING_REPORTING_OBSERVER: 'ReportingObserver not supported',
19
19
  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',
20
+ SPOTTER_AGENT_NOT_INITIALIZED: 'SpotterAgent not initialized',
20
21
  };
package/src/index.ts CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  HomePageSearchBarMode,
16
16
  PrimaryNavbarVersion,
17
17
  HomePage,
18
+ ListPage,
18
19
  DataPanelCustomColumnGroupsAccordionState,
19
20
  } from './embed/app';
20
21
  import {
@@ -141,6 +142,7 @@ export {
141
142
  HomePageSearchBarMode,
142
143
  PrimaryNavbarVersion,
143
144
  HomePage,
145
+ ListPage,
144
146
  VizPoint,
145
147
  CustomActionPayload,
146
148
  UIPassthroughEvent,
@@ -12,7 +12,8 @@ export {
12
12
  SpotterEmbed,
13
13
  ConversationEmbed,
14
14
  PreRenderedConversationEmbed,
15
- SpotterAgentEmbed,
15
+ SpotterMessage,
16
+ useSpotterAgent,
16
17
  useEmbedRef,
17
18
  useInit,
18
19
  } from './index';