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

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