@thoughtspot/visual-embed-sdk 1.51.0 → 1.51.1

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 (212) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/config.d.ts +1 -0
  3. package/cjs/src/config.d.ts.map +1 -1
  4. package/cjs/src/config.js +2 -1
  5. package/cjs/src/config.js.map +1 -1
  6. package/cjs/src/css-variables.d.ts +27 -0
  7. package/cjs/src/css-variables.d.ts.map +1 -1
  8. package/cjs/src/embed/app.d.ts +43 -12
  9. package/cjs/src/embed/app.d.ts.map +1 -1
  10. package/cjs/src/embed/app.js +29 -3
  11. package/cjs/src/embed/app.js.map +1 -1
  12. package/cjs/src/embed/app.spec.js +253 -1
  13. package/cjs/src/embed/app.spec.js.map +1 -1
  14. package/cjs/src/embed/base.d.ts +1 -1
  15. package/cjs/src/embed/base.js +1 -1
  16. package/cjs/src/embed/conversation.d.ts +171 -1
  17. package/cjs/src/embed/conversation.d.ts.map +1 -1
  18. package/cjs/src/embed/conversation.js +4 -2
  19. package/cjs/src/embed/conversation.js.map +1 -1
  20. package/cjs/src/embed/conversation.spec.js +125 -0
  21. package/cjs/src/embed/conversation.spec.js.map +1 -1
  22. package/cjs/src/embed/events.spec.js +3 -0
  23. package/cjs/src/embed/events.spec.js.map +1 -1
  24. package/cjs/src/embed/host-events.spec.js +36 -0
  25. package/cjs/src/embed/host-events.spec.js.map +1 -1
  26. package/cjs/src/embed/hostEventClient/host-event-client.d.ts +1 -1
  27. package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  28. package/cjs/src/embed/hostEventClient/host-event-client.spec.js +18 -0
  29. package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  30. package/cjs/src/embed/liveboard.d.ts +40 -13
  31. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  32. package/cjs/src/embed/liveboard.js +25 -4
  33. package/cjs/src/embed/liveboard.js.map +1 -1
  34. package/cjs/src/embed/liveboard.spec.js +349 -2
  35. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  36. package/cjs/src/embed/spotter-utils.d.ts +8 -1
  37. package/cjs/src/embed/spotter-utils.d.ts.map +1 -1
  38. package/cjs/src/embed/spotter-utils.js +15 -1
  39. package/cjs/src/embed/spotter-utils.js.map +1 -1
  40. package/cjs/src/embed/spotter-utils.spec.js +68 -0
  41. package/cjs/src/embed/spotter-utils.spec.js.map +1 -1
  42. package/cjs/src/embed/spotter-viz-utils.d.ts +9 -10
  43. package/cjs/src/embed/spotter-viz-utils.d.ts.map +1 -1
  44. package/cjs/src/embed/spotter-viz-utils.js.map +1 -1
  45. package/cjs/src/embed/ts-embed.d.ts +16 -8
  46. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  47. package/cjs/src/embed/ts-embed.js +69 -32
  48. package/cjs/src/embed/ts-embed.js.map +1 -1
  49. package/cjs/src/embed/ts-embed.spec.js +537 -3
  50. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  51. package/cjs/src/index.d.ts +3 -3
  52. package/cjs/src/index.d.ts.map +1 -1
  53. package/cjs/src/index.js +3 -2
  54. package/cjs/src/index.js.map +1 -1
  55. package/cjs/src/react/all-types-export.d.ts +1 -1
  56. package/cjs/src/react/all-types-export.d.ts.map +1 -1
  57. package/cjs/src/react/all-types-export.js +2 -1
  58. package/cjs/src/react/all-types-export.js.map +1 -1
  59. package/cjs/src/react/all-types-export.parity.spec.d.ts +2 -0
  60. package/cjs/src/react/all-types-export.parity.spec.d.ts.map +1 -0
  61. package/cjs/src/react/all-types-export.parity.spec.js +194 -0
  62. package/cjs/src/react/all-types-export.parity.spec.js.map +1 -0
  63. package/cjs/src/react/index.d.ts +66 -32
  64. package/cjs/src/react/index.d.ts.map +1 -1
  65. package/cjs/src/react/index.js +5 -3
  66. package/cjs/src/react/index.js.map +1 -1
  67. package/cjs/src/react/index.spec.js +101 -0
  68. package/cjs/src/react/index.spec.js.map +1 -1
  69. package/cjs/src/types.d.ts +330 -18
  70. package/cjs/src/types.d.ts.map +1 -1
  71. package/cjs/src/types.js +182 -12
  72. package/cjs/src/types.js.map +1 -1
  73. package/cjs/src/utils.spec.js +4 -0
  74. package/cjs/src/utils.spec.js.map +1 -1
  75. package/dist/{index-aBzH5ZwF.js → index-DxLfQxoT.js} +1 -1
  76. package/dist/src/config.d.ts +1 -0
  77. package/dist/src/config.d.ts.map +1 -1
  78. package/dist/src/css-variables.d.ts +27 -0
  79. package/dist/src/css-variables.d.ts.map +1 -1
  80. package/dist/src/embed/app.d.ts +43 -12
  81. package/dist/src/embed/app.d.ts.map +1 -1
  82. package/dist/src/embed/base.d.ts +1 -1
  83. package/dist/src/embed/conversation.d.ts +171 -1
  84. package/dist/src/embed/conversation.d.ts.map +1 -1
  85. package/dist/src/embed/hostEventClient/host-event-client.d.ts +1 -1
  86. package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  87. package/dist/src/embed/liveboard.d.ts +40 -13
  88. package/dist/src/embed/liveboard.d.ts.map +1 -1
  89. package/dist/src/embed/spotter-utils.d.ts +8 -1
  90. package/dist/src/embed/spotter-utils.d.ts.map +1 -1
  91. package/dist/src/embed/spotter-viz-utils.d.ts +9 -10
  92. package/dist/src/embed/spotter-viz-utils.d.ts.map +1 -1
  93. package/dist/src/embed/ts-embed.d.ts +16 -8
  94. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  95. package/dist/src/index.d.ts +3 -3
  96. package/dist/src/index.d.ts.map +1 -1
  97. package/dist/src/react/all-types-export.d.ts +1 -1
  98. package/dist/src/react/all-types-export.d.ts.map +1 -1
  99. package/dist/src/react/all-types-export.parity.spec.d.ts +2 -0
  100. package/dist/src/react/all-types-export.parity.spec.d.ts.map +1 -0
  101. package/dist/src/react/index.d.ts +66 -32
  102. package/dist/src/react/index.d.ts.map +1 -1
  103. package/dist/src/types.d.ts +330 -18
  104. package/dist/src/types.d.ts.map +1 -1
  105. package/dist/tsembed-react.es.js +330 -61
  106. package/dist/tsembed-react.js +329 -60
  107. package/dist/tsembed.es.js +390 -123
  108. package/dist/tsembed.js +392 -125
  109. package/dist/visual-embed-sdk-react-full.d.ts +696 -89
  110. package/dist/visual-embed-sdk-react.d.ts +692 -88
  111. package/dist/visual-embed-sdk.d.ts +632 -59
  112. package/lib/package.json +1 -1
  113. package/lib/src/config.d.ts +1 -0
  114. package/lib/src/config.d.ts.map +1 -1
  115. package/lib/src/config.js +1 -0
  116. package/lib/src/config.js.map +1 -1
  117. package/lib/src/css-variables.d.ts +27 -0
  118. package/lib/src/css-variables.d.ts.map +1 -1
  119. package/lib/src/embed/app.d.ts +43 -12
  120. package/lib/src/embed/app.d.ts.map +1 -1
  121. package/lib/src/embed/app.js +30 -4
  122. package/lib/src/embed/app.js.map +1 -1
  123. package/lib/src/embed/app.spec.js +253 -1
  124. package/lib/src/embed/app.spec.js.map +1 -1
  125. package/lib/src/embed/base.d.ts +1 -1
  126. package/lib/src/embed/base.js +1 -1
  127. package/lib/src/embed/conversation.d.ts +171 -1
  128. package/lib/src/embed/conversation.d.ts.map +1 -1
  129. package/lib/src/embed/conversation.js +5 -3
  130. package/lib/src/embed/conversation.js.map +1 -1
  131. package/lib/src/embed/conversation.spec.js +125 -0
  132. package/lib/src/embed/conversation.spec.js.map +1 -1
  133. package/lib/src/embed/events.spec.js +3 -0
  134. package/lib/src/embed/events.spec.js.map +1 -1
  135. package/lib/src/embed/host-events.spec.js +36 -0
  136. package/lib/src/embed/host-events.spec.js.map +1 -1
  137. package/lib/src/embed/hostEventClient/host-event-client.d.ts +1 -1
  138. package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  139. package/lib/src/embed/hostEventClient/host-event-client.spec.js +18 -0
  140. package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  141. package/lib/src/embed/liveboard.d.ts +40 -13
  142. package/lib/src/embed/liveboard.d.ts.map +1 -1
  143. package/lib/src/embed/liveboard.js +25 -4
  144. package/lib/src/embed/liveboard.js.map +1 -1
  145. package/lib/src/embed/liveboard.spec.js +349 -2
  146. package/lib/src/embed/liveboard.spec.js.map +1 -1
  147. package/lib/src/embed/spotter-utils.d.ts +8 -1
  148. package/lib/src/embed/spotter-utils.d.ts.map +1 -1
  149. package/lib/src/embed/spotter-utils.js +13 -0
  150. package/lib/src/embed/spotter-utils.js.map +1 -1
  151. package/lib/src/embed/spotter-utils.spec.js +69 -1
  152. package/lib/src/embed/spotter-utils.spec.js.map +1 -1
  153. package/lib/src/embed/spotter-viz-utils.d.ts +9 -10
  154. package/lib/src/embed/spotter-viz-utils.d.ts.map +1 -1
  155. package/lib/src/embed/spotter-viz-utils.js.map +1 -1
  156. package/lib/src/embed/ts-embed.d.ts +16 -8
  157. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  158. package/lib/src/embed/ts-embed.js +69 -32
  159. package/lib/src/embed/ts-embed.js.map +1 -1
  160. package/lib/src/embed/ts-embed.spec.js +537 -3
  161. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  162. package/lib/src/index.d.ts +3 -3
  163. package/lib/src/index.d.ts.map +1 -1
  164. package/lib/src/index.js +2 -2
  165. package/lib/src/index.js.map +1 -1
  166. package/lib/src/react/all-types-export.d.ts +1 -1
  167. package/lib/src/react/all-types-export.d.ts.map +1 -1
  168. package/lib/src/react/all-types-export.js +1 -1
  169. package/lib/src/react/all-types-export.js.map +1 -1
  170. package/lib/src/react/all-types-export.parity.spec.d.ts +2 -0
  171. package/lib/src/react/all-types-export.parity.spec.d.ts.map +1 -0
  172. package/lib/src/react/all-types-export.parity.spec.js +191 -0
  173. package/lib/src/react/all-types-export.parity.spec.js.map +1 -0
  174. package/lib/src/react/index.d.ts +66 -32
  175. package/lib/src/react/index.d.ts.map +1 -1
  176. package/lib/src/react/index.js +5 -3
  177. package/lib/src/react/index.js.map +1 -1
  178. package/lib/src/react/index.spec.js +102 -1
  179. package/lib/src/react/index.spec.js.map +1 -1
  180. package/lib/src/types.d.ts +330 -18
  181. package/lib/src/types.d.ts.map +1 -1
  182. package/lib/src/types.js +182 -12
  183. package/lib/src/types.js.map +1 -1
  184. package/lib/src/utils.spec.js +4 -0
  185. package/lib/src/utils.spec.js.map +1 -1
  186. package/lib/src/visual-embed-sdk.d.ts +632 -59
  187. package/package.json +1 -1
  188. package/src/config.ts +1 -0
  189. package/src/css-variables.ts +32 -0
  190. package/src/embed/app.spec.ts +335 -1
  191. package/src/embed/app.ts +71 -13
  192. package/src/embed/base.ts +1 -1
  193. package/src/embed/conversation.spec.ts +136 -0
  194. package/src/embed/conversation.ts +181 -3
  195. package/src/embed/events.spec.ts +4 -0
  196. package/src/embed/host-events.spec.ts +48 -0
  197. package/src/embed/hostEventClient/host-event-client.spec.ts +34 -0
  198. package/src/embed/hostEventClient/host-event-client.ts +2 -2
  199. package/src/embed/liveboard.spec.ts +457 -2
  200. package/src/embed/liveboard.ts +74 -15
  201. package/src/embed/spotter-utils.spec.ts +72 -0
  202. package/src/embed/spotter-utils.ts +21 -1
  203. package/src/embed/spotter-viz-utils.ts +9 -10
  204. package/src/embed/ts-embed.spec.ts +699 -3
  205. package/src/embed/ts-embed.ts +83 -37
  206. package/src/index.ts +43 -2
  207. package/src/react/all-types-export.parity.spec.ts +208 -0
  208. package/src/react/all-types-export.ts +22 -0
  209. package/src/react/index.spec.tsx +158 -0
  210. package/src/react/index.tsx +70 -33
  211. package/src/types.ts +329 -16
  212. package/src/utils.spec.ts +5 -0
@@ -10,6 +10,7 @@ import isEqual from 'lodash/isEqual';
10
10
  import isEmpty from 'lodash/isEmpty';
11
11
  import isObject from 'lodash/isObject';
12
12
  import {
13
+ HostEventRequest,
13
14
  TriggerPayload,
14
15
  TriggerResponse,
15
16
  UIPassthroughArrayResponse,
@@ -66,6 +67,8 @@ import {
66
67
  MessagePayload,
67
68
  ContextType,
68
69
  ContextObject,
70
+ PreRenderConfig,
71
+ BaseViewConfig,
69
72
  } from '../types';
70
73
  import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
71
74
  import { processEventData, processAuthFailure } from '../utils/processData';
@@ -206,7 +209,7 @@ export class TsEmbed {
206
209
 
207
210
  private resizeObserver: ResizeObserver;
208
211
 
209
- private preRenderContainerEl: HTMLElement | null = null;
212
+ private preRenderContainerEl: HTMLElement = document.body;
210
213
 
211
214
  private containerScrollListener: (() => void) | null = null;
212
215
 
@@ -959,11 +962,27 @@ export class TsEmbed {
959
962
  return iFrame;
960
963
  }
961
964
 
965
+ /**
966
+ * Returns a merged {@link PreRenderConfig} object where each shared key
967
+ * prefers `preRenderConfig.key` over the top-level `viewConfig.key` for
968
+ * backward compatibility.
969
+ */
970
+ protected getPreRenderConfig(): PreRenderConfig {
971
+ const viewCfg = this.viewConfig as BaseViewConfig;
972
+ const preRenderCfg = viewCfg.preRenderConfig ?? {};
973
+ return {
974
+ ...preRenderCfg,
975
+ preRenderId: preRenderCfg.preRenderId ?? viewCfg.preRenderId,
976
+ preRenderContainer: preRenderCfg.preRenderContainer ?? viewCfg.preRenderContainer,
977
+ doNotTrackPreRenderSize: preRenderCfg.doNotTrackPreRenderSize ?? viewCfg.doNotTrackPreRenderSize,
978
+ };
979
+ }
980
+
962
981
  /**
963
982
  * Returns true if this embed instance is configured for pre-rendering.
964
983
  */
965
984
  protected isPreRenderEmbed() {
966
- return !!this.viewConfig.preRenderId;
985
+ return !!this.getPreRenderConfig().preRenderId;
967
986
  }
968
987
  protected handleInsertionIntoDOM(child: string | Node): void {
969
988
  if (this.isPreRenderEmbed()) {
@@ -1119,6 +1138,7 @@ export class TsEmbed {
1119
1138
  this.setIframeElement(this.preRenderChild);
1120
1139
  }
1121
1140
  this.isRendered = true;
1141
+ this.inheritPreRenderContainer();
1122
1142
  }
1123
1143
 
1124
1144
  return this.isPreRenderConnected();
@@ -1176,7 +1196,7 @@ export class TsEmbed {
1176
1196
  * fresh element; an element passed directly cannot be re-resolved.
1177
1197
  */
1178
1198
  private resolvePreRenderContainerTarget(): HTMLElement {
1179
- const containerConfig = this.viewConfig.preRenderContainer;
1199
+ const containerConfig = this.getPreRenderConfig().preRenderContainer;
1180
1200
  let container: Element | null = null;
1181
1201
  if (typeof containerConfig === 'string') {
1182
1202
  try {
@@ -1193,15 +1213,40 @@ export class TsEmbed {
1193
1213
  return (container as HTMLElement) ?? document.body;
1194
1214
  }
1195
1215
 
1216
+ private inheritPreRenderContainer(): void {
1217
+ const preRenderedObject = this.getPreRenderObj<TsEmbed>();
1218
+ if (!preRenderedObject || preRenderedObject === (this as TsEmbed)) {
1219
+ return;
1220
+ }
1221
+ const ownerContainer = preRenderedObject.preRenderContainerEl ?? document.body;
1222
+ if (
1223
+ this.getPreRenderConfig().preRenderContainer
1224
+ && this.resolvePreRenderContainerTarget() !== ownerContainer
1225
+ ) {
1226
+ logger.warn(
1227
+ 'preRenderContainer is applied only by the component that creates the preRender; '
1228
+ + 'the one passed here is ignored. Set it on the PreRender component instead.',
1229
+ );
1230
+ }
1231
+ this.preRenderContainerEl = ownerContainer;
1232
+ this.applyPreRenderContainerPositioning();
1233
+ }
1234
+
1235
+ private getCustomPreRenderContainer(): HTMLElement | null {
1236
+ const container = this.preRenderContainerEl;
1237
+ return container && container !== document.body ? container : null;
1238
+ }
1239
+
1196
1240
  /**
1197
- * Makes the container a positioning context for the absolutely positioned
1198
- * wrapper, stashing the original inline `position` on the element (once) so
1199
- * destroy() can restore it exactly, leaving no trace. Recording it on the
1200
- * element rather than per-instance lets the override be reverted even when
1201
- * embeds share the same container.
1241
+ * Makes the resolved container a positioning context for the absolutely
1242
+ * positioned wrapper, stashing the original inline `position` on the element
1243
+ * (once) so destroy() can restore it exactly, leaving no trace. Recording it
1244
+ * on the element rather than per-instance lets the override be reverted even
1245
+ * when embeds share the same container.
1202
1246
  */
1203
- private applyPreRenderContainerPositioning(container: HTMLElement): void {
1204
- if (container === document.body) {
1247
+ private applyPreRenderContainerPositioning(): void {
1248
+ const container = this.getCustomPreRenderContainer();
1249
+ if (!container) {
1205
1250
  return;
1206
1251
  }
1207
1252
  const pos = window.getComputedStyle(container).position;
@@ -1247,11 +1292,11 @@ export class TsEmbed {
1247
1292
  resolved.addEventListener('scroll', this.containerScrollListener);
1248
1293
  }
1249
1294
  }
1250
- this.applyPreRenderContainerPositioning(resolved);
1295
+ this.preRenderContainerEl = resolved;
1296
+ this.applyPreRenderContainerPositioning();
1251
1297
  if (wrapper.parentNode !== resolved) {
1252
1298
  resolved.appendChild(wrapper);
1253
1299
  }
1254
- this.preRenderContainerEl = resolved;
1255
1300
  }
1256
1301
 
1257
1302
  protected insertIntoDOMForPreRender(child: string | Node): void {
@@ -1279,7 +1324,7 @@ export class TsEmbed {
1279
1324
 
1280
1325
  const targetContainer = this.resolvePreRenderContainerTarget();
1281
1326
  this.preRenderContainerEl = targetContainer;
1282
- this.applyPreRenderContainerPositioning(targetContainer);
1327
+ this.applyPreRenderContainerPositioning();
1283
1328
  targetContainer.appendChild(preRenderWrapper);
1284
1329
  }
1285
1330
 
@@ -1625,7 +1670,11 @@ export class TsEmbed {
1625
1670
  * ```
1626
1671
  * @version SDK: 1.45.2 | ThoughtSpot: 26.3.0.cl (for context parameter)
1627
1672
  */
1628
- public async trigger<HostEventT extends HostEvent, PayloadT, ContextT extends ContextType>(
1673
+ public async trigger<
1674
+ HostEventT extends HostEvent,
1675
+ PayloadT = HostEventRequest<HostEventT>,
1676
+ ContextT extends ContextType = ContextType,
1677
+ >(
1629
1678
  messageType: HostEventT,
1630
1679
  data: TriggerPayload<PayloadT, HostEventT> = {} as any,
1631
1680
  context?: ContextT,
@@ -1797,7 +1846,7 @@ export class TsEmbed {
1797
1846
  showPreRenderByDefault,
1798
1847
  replaceExistingPreRender,
1799
1848
  });
1800
- if (!this.viewConfig.preRenderId) {
1849
+ if (!this.getPreRenderConfig().preRenderId) {
1801
1850
  logger.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
1802
1851
  return this;
1803
1852
  }
@@ -1856,13 +1905,13 @@ export class TsEmbed {
1856
1905
  * same container — a shared container still needs the positioning context.
1857
1906
  */
1858
1907
  private restorePreRenderContainerPosition(): void {
1859
- const container = this.preRenderContainerEl as HTMLElement | null;
1908
+ const container = this.preRenderContainerEl;
1860
1909
  if (!container || container === document.body) {
1861
1910
  return;
1862
1911
  }
1863
1912
  // Drop our reference up front so a destroyed embed never pins a
1864
1913
  // detached container in memory; restoration uses the local handle.
1865
- this.preRenderContainerEl = null;
1914
+ this.preRenderContainerEl = document.body;
1866
1915
  const originalPosition = container.dataset[PRERENDER_CONTAINER_ORIGINAL_POSITION_KEY];
1867
1916
  if (originalPosition === undefined) {
1868
1917
  // We never overrode this container's position; nothing to restore.
@@ -1888,10 +1937,7 @@ export class TsEmbed {
1888
1937
  if (!this.containerScrollListener) {
1889
1938
  return;
1890
1939
  }
1891
- const customContainer =
1892
- this.preRenderContainerEl && this.preRenderContainerEl !== document.body
1893
- ? this.preRenderContainerEl
1894
- : null;
1940
+ const customContainer = this.getCustomPreRenderContainer();
1895
1941
  customContainer?.removeEventListener('scroll', this.containerScrollListener);
1896
1942
  this.containerScrollListener = null;
1897
1943
  }
@@ -1986,14 +2032,14 @@ export class TsEmbed {
1986
2032
  */
1987
2033
  public async showPreRender(): Promise<TsEmbed> {
1988
2034
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_SHOW_PRE_RENDER, {
1989
- preRenderId: this.viewConfig.preRenderId,
2035
+ preRenderId: this.getPreRenderConfig().preRenderId,
1990
2036
  embedComponentType: this.viewConfig.embedComponentType,
1991
2037
  });
1992
2038
 
1993
2039
  if (this.shouldWaitForRenderPromise) await this.isReadyForRenderPromise;
1994
2040
 
1995
2041
 
1996
- if (!this.viewConfig.preRenderId) {
2042
+ if (!this.getPreRenderConfig().preRenderId) {
1997
2043
  logger.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
1998
2044
  return this;
1999
2045
  }
@@ -2029,16 +2075,13 @@ export class TsEmbed {
2029
2075
 
2030
2076
  this.syncPreRenderStyle();
2031
2077
 
2032
- const customContainer =
2033
- this.preRenderContainerEl && this.preRenderContainerEl !== document.body
2034
- ? this.preRenderContainerEl
2035
- : null;
2078
+ const customContainer = this.getCustomPreRenderContainer();
2036
2079
  if (customContainer && !this.containerScrollListener) {
2037
2080
  this.containerScrollListener = () => this.syncPreRenderStyle();
2038
2081
  customContainer.addEventListener('scroll', this.containerScrollListener);
2039
2082
  }
2040
2083
 
2041
- if (!this.viewConfig.doNotTrackPreRenderSize) {
2084
+ if (!this.getPreRenderConfig().doNotTrackPreRenderSize) {
2042
2085
  const observeTarget = (this.insertedDomEl as HTMLElement) ?? this.hostElement;
2043
2086
  this.resizeObserver = new ResizeObserver((entries) => {
2044
2087
  entries.forEach((entry) => {
@@ -2084,15 +2127,16 @@ export class TsEmbed {
2084
2127
  logger.error(ERROR_MESSAGE.SYNC_STYLE_CALLED_BEFORE_RENDER);
2085
2128
  return;
2086
2129
  }
2130
+ if (!this.getPreRenderPlaceHolderElement().isConnected) {
2131
+ logger.debug('syncPreRenderStyle skipped: placeholder is detached');
2132
+ return;
2133
+ }
2087
2134
  // Self-heal if the resolved container was remounted/detached, so we
2088
2135
  // never measure a stale node (which would collapse the wrapper).
2089
2136
  this.reconcilePreRenderContainer();
2090
2137
  const elBoundingClient = this.getPreRenderPlaceHolderElement().getBoundingClientRect();
2091
2138
 
2092
- const containerEl =
2093
- this.preRenderContainerEl && this.preRenderContainerEl !== document.body
2094
- ? this.preRenderContainerEl
2095
- : null;
2139
+ const containerEl = this.getCustomPreRenderContainer();
2096
2140
  const containerRect = containerEl?.getBoundingClientRect() ?? { x: 0, y: 0 };
2097
2141
  const scrollX = containerEl ? containerEl.scrollLeft : window.scrollX;
2098
2142
  const scrollY = containerEl ? containerEl.scrollTop : window.scrollY;
@@ -2112,7 +2156,7 @@ export class TsEmbed {
2112
2156
  */
2113
2157
  public hidePreRender(): void {
2114
2158
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_HIDE_PRE_RENDER, {
2115
- preRenderId: this.viewConfig.preRenderId,
2159
+ preRenderId: this.getPreRenderConfig().preRenderId,
2116
2160
  embedComponentType: this.viewConfig.embedComponentType,
2117
2161
  });
2118
2162
 
@@ -2122,10 +2166,11 @@ export class TsEmbed {
2122
2166
  logger.warn('PreRender should be called before hiding it using hidePreRender.');
2123
2167
  return;
2124
2168
  }
2169
+ const { zIndex } = this.getPreRenderConfig();
2125
2170
  const preRenderHideStyles = {
2126
2171
  opacity: '0',
2127
2172
  pointerEvents: 'none',
2128
- zIndex: '-1000',
2173
+ zIndex: zIndex !== undefined ? String(zIndex) : '-1000',
2129
2174
  position: 'absolute',
2130
2175
  top: '0',
2131
2176
  left: '0',
@@ -2155,10 +2200,11 @@ export class TsEmbed {
2155
2200
  * @property {string} child - The HTML element ID for the PreRender child.
2156
2201
  */
2157
2202
  public getPreRenderIds() {
2203
+ const preRenderId = this.getPreRenderConfig().preRenderId;
2158
2204
  return {
2159
- wrapper: `${PRERENDER_WRAPPER_ID_PREFIX}${this.viewConfig.preRenderId}`,
2160
- child: `tsEmbed-pre-render-child-${this.viewConfig.preRenderId}`,
2161
- placeHolder: `tsEmbed-pre-render-placeholder-${this.viewConfig.preRenderId}`,
2205
+ wrapper: `${PRERENDER_WRAPPER_ID_PREFIX}${preRenderId}`,
2206
+ child: `tsEmbed-pre-render-child-${preRenderId}`,
2207
+ placeHolder: `tsEmbed-pre-render-placeholder-${preRenderId}`,
2162
2208
  };
2163
2209
  }
2164
2210
 
package/src/index.ts CHANGED
@@ -32,7 +32,7 @@ import { PinboardEmbed, LiveboardViewConfig, LiveboardEmbed } from './embed/live
32
32
  import { SearchEmbed, SearchViewConfig } from './embed/search';
33
33
  import { SearchBarEmbed, SearchBarViewConfig } from './embed/search-bar';
34
34
  import { SpotterAgentEmbed, SpotterAgentEmbedViewConfig, BodylessConversation, BodylessConversationViewConfig} from './embed/bodyless-conversation';
35
- import { SpotterEmbed, SpotterEmbedViewConfig, SpotterChatViewConfig, SpotterSidebarViewConfig, SpotterQueryMode, SpotterShareConversationConfig, ConversationEmbed, ConversationViewConfig } from './embed/conversation';
35
+ import { SpotterEmbed, SpotterEmbedViewConfig, SpotterChatViewConfig, SpotterSidebarViewConfig, SpotterAnalystConfig, SpotterQueryMode, SpotterShareConversationConfig, StarterPromptsConfig, StarterPromptCategory, StarterPreviewDataCategory, StarterPromptQuestion, ConversationEmbed, ConversationViewConfig } from './embed/conversation';
36
36
  import { SpotterVizConfig, SpotterVizStarterPrompt, SpotterVizLoaderTip } from './embed/spotter-viz-utils';
37
37
  import {
38
38
  AuthFailureType, AuthStatus, AuthEvent, AuthEventEmitter,
@@ -88,7 +88,24 @@ import { uploadMixpanelEvent, MIXPANEL_EVENT } from './mixpanel-service';
88
88
  import { tokenizedFetch } from './tokenizedFetch';
89
89
  import { getAnswerFromQuery } from './utils/graphql/nlsService/nls-answer-service';
90
90
  import { createLiveboardWithAnswers } from './utils/liveboardService/liveboardService';
91
- import { UIPassthroughEvent } from './embed/hostEventClient/contracts';
91
+ import {
92
+ UIPassthroughEvent,
93
+ UIPassthroughContractBase,
94
+ UIPassthroughRequest,
95
+ UIPassthroughResponse,
96
+ UIPassthroughArrayResponse,
97
+ HostEventRequest,
98
+ HostEventResponse,
99
+ TriggerPayload,
100
+ TriggerResponse,
101
+ LiveboardTab,
102
+ LiveboardGroup,
103
+ ApplicabilityLevel,
104
+ Applicability,
105
+ FilterUpdate,
106
+ LiveboardFilter,
107
+ LiveboardParameter,
108
+ } from './embed/hostEventClient/contracts';
92
109
 
93
110
  export {
94
111
  init,
@@ -117,8 +134,13 @@ export {
117
134
  SpotterEmbedViewConfig,
118
135
  SpotterChatViewConfig,
119
136
  SpotterSidebarViewConfig,
137
+ SpotterAnalystConfig,
120
138
  SpotterQueryMode,
121
139
  SpotterShareConversationConfig,
140
+ StarterPromptsConfig,
141
+ StarterPromptCategory,
142
+ StarterPreviewDataCategory,
143
+ StarterPromptQuestion,
122
144
  ConversationViewConfig,
123
145
  ConversationEmbed,
124
146
  AuthFailureType,
@@ -170,6 +192,25 @@ export {
170
192
  VizPoint,
171
193
  CustomActionPayload,
172
194
  UIPassthroughEvent,
195
+ // Host event payload / response contracts. These describe what to send with
196
+ // `embed.trigger(HostEvent.X, payload)` and what the returned promise
197
+ // resolves with. See `UIPassthroughContractBase` for the per-event
198
+ // request/response shapes.
199
+ UIPassthroughContractBase,
200
+ UIPassthroughRequest,
201
+ UIPassthroughResponse,
202
+ UIPassthroughArrayResponse,
203
+ HostEventRequest,
204
+ HostEventResponse,
205
+ TriggerPayload,
206
+ TriggerResponse,
207
+ LiveboardTab,
208
+ LiveboardGroup,
209
+ ApplicabilityLevel,
210
+ Applicability,
211
+ FilterUpdate,
212
+ LiveboardFilter,
213
+ LiveboardParameter,
173
214
  ListPageColumns,
174
215
  DataPanelCustomColumnGroupsAccordionState,
175
216
  CustomActionsPosition,
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Parity gate: every symbol exported from `src/index.ts` must also be exported
3
+ * from `src/react/all-types-export.ts`.
4
+ *
5
+ * `package.json` `exports` restricts consumers to two entry points — `.` and
6
+ * `./react` — and the React surface is a HAND-MAINTAINED duplicate export list,
7
+ * not a `export * from '../index'`. So a symbol added only to `src/index.ts` is
8
+ * invisible to every React consumer.
9
+ *
10
+ * The sibling `all-types-export.spec.ts` cannot catch this: it inspects the
11
+ * module at runtime, and type-only exports (interfaces, type aliases) are
12
+ * erased by the compiler. This spec therefore compares the two files as TEXT.
13
+ */
14
+ import * as fs from 'fs';
15
+ import * as path from 'path';
16
+
17
+ const INDEX_PATH = path.join(__dirname, '..', 'index.ts');
18
+ const REACT_EXPORT_PATH = path.join(__dirname, 'all-types-export.ts');
19
+
20
+ /**
21
+ * Symbols intentionally absent from the React surface.
22
+ * Add here only with a reason — every entry is a thing React users cannot use.
23
+ */
24
+ const REACT_EXEMPT = new Set<string>([
25
+ // React has its own component wrappers for these; the raw classes are not
26
+ // part of the /react surface.
27
+ 'SearchEmbed',
28
+ 'SearchBarEmbed',
29
+ 'LiveboardEmbed',
30
+ 'AppEmbed',
31
+ 'SpotterEmbed',
32
+ 'SpotterAgentEmbed',
33
+ 'ConversationEmbed',
34
+ 'BodylessConversation',
35
+ 'PreRenderedSearchEmbed',
36
+ 'PreRenderedSearchBarEmbed',
37
+ 'PreRenderedLiveboardEmbed',
38
+ 'PreRenderedAppEmbed',
39
+ 'PreRenderedConversationEmbed',
40
+ 'PinboardEmbed',
41
+ 'TsEmbed',
42
+ 'V1Embed',
43
+ ]);
44
+
45
+ /**
46
+ * PRE-EXISTING gaps, discovered when this spec was introduced. These are
47
+ * symbols React consumers cannot import today — most look like oversights
48
+ * rather than deliberate omissions (e.g. `ContextType`, `CustomActionPayload`,
49
+ * `VizPoint`, the Spotter view configs).
50
+ *
51
+ * This list may only ever SHRINK. Do not add to it — a new entry means a
52
+ * symbol was added to `src/index.ts` without adding it to the React surface,
53
+ * which is exactly what this spec exists to prevent. Removing entries (by
54
+ * exporting them from `all-types-export.ts`) is a welcome follow-up; it is
55
+ * deliberately out of scope for the change that introduced this gate.
56
+ */
57
+ const KNOWN_REACT_GAPS = new Set<string>([
58
+ 'AnswerService',
59
+ 'AutoMCPFrameRendererViewConfig',
60
+ 'BackgroundFormatType',
61
+ 'BodylessConversationViewConfig',
62
+ 'ConditionalFormattingComparisonType',
63
+ 'ConditionalFormattingOperator',
64
+ 'ContextMenuTriggerOptions',
65
+ 'ContextType',
66
+ 'ConversationViewConfig',
67
+ 'CustomActionPayload',
68
+ 'DataLabelFilterOperator',
69
+ 'EmbedErrorCodes',
70
+ 'EmbedErrorDetailsEvent',
71
+ 'ErrorDetailsTypes',
72
+ 'HomeLeftNavItem',
73
+ 'HomePage',
74
+ 'HomePageSearchBarMode',
75
+ 'HomepageModule',
76
+ 'LegendPosition',
77
+ 'ListPage',
78
+ 'ListPageColumns',
79
+ 'LogLevel',
80
+ 'MIXPANEL_EVENT',
81
+ 'PrimaryNavbarVersion',
82
+ 'SessionInterface',
83
+ 'SpotterAgentEmbedViewConfig',
84
+ 'SpotterChatViewConfig',
85
+ 'SpotterEmbedViewConfig',
86
+ 'SpotterQueryMode',
87
+ 'SpotterShareConversationConfig',
88
+ 'SpotterSidebarViewConfig',
89
+ 'SpotterVizConfig',
90
+ 'SpotterVizLoaderTip',
91
+ 'SpotterVizStarterPrompt',
92
+ 'TableContentDensity',
93
+ 'TableTheme',
94
+ 'UnderlyingDataPoint',
95
+ 'VisualizationOverrides',
96
+ 'VizPoint',
97
+ // Standalone helpers re-exported from src/index.ts outside the main block.
98
+ 'createLiveboardWithAnswers',
99
+ 'executeTML',
100
+ 'executeTMLInput',
101
+ 'exportTML',
102
+ 'exportTMLInput',
103
+ 'getAnswerFromQuery',
104
+ 'startAutoMCPFrameRenderer',
105
+ 'tokenizedFetch',
106
+ ]);
107
+
108
+ /**
109
+ * Extract identifiers from every `export { ... }` / `export type { ... }` block
110
+ * in a source file. Handles `a`, `a as b` (records the exported name `b`),
111
+ * comments and trailing commas.
112
+ *
113
+ * `export * from '...'` cannot be enumerated by name (the names live in another
114
+ * module), so it would silently defeat this parity gate. We refuse to run
115
+ * against it: if either file adopts a star re-export, this throws so the gate
116
+ * is extended deliberately rather than passing blind.
117
+ */
118
+ const extractExportedNames = (source: string): Set<string> => {
119
+ if (/export\s*\*/.test(source)) {
120
+ throw new Error(
121
+ 'Parity extractor found an `export *` re-export, which it cannot '
122
+ + 'enumerate by name. Extend extractExportedNames to resolve star '
123
+ + 'exports before relying on this gate.',
124
+ );
125
+ }
126
+ const names = new Set<string>();
127
+ // Matches `export { ... }` and `export type { ... }`.
128
+ const blockRe = /export\s*(?:type\s+)?\{([\s\S]*?)\}/g;
129
+ let match = blockRe.exec(source);
130
+ while (match !== null) {
131
+ match[1]
132
+ // strip line and block comments
133
+ .replace(/\/\*[\s\S]*?\*\//g, '')
134
+ .replace(/\/\/[^\n]*/g, '')
135
+ .split(',')
136
+ .map((entry) => entry.trim())
137
+ .filter(Boolean)
138
+ .forEach((entry) => {
139
+ // `foo as bar` exports the name `bar`
140
+ const parts = entry.split(/\s+as\s+/);
141
+ const exported = (parts[parts.length - 1] || '').trim();
142
+ if (/^[A-Za-z_$][\w$]*$/.test(exported)) {
143
+ names.add(exported);
144
+ }
145
+ });
146
+ match = blockRe.exec(source);
147
+ }
148
+ return names;
149
+ };
150
+
151
+ describe('react/all-types-export parity with index', () => {
152
+ it('exports every symbol that src/index.ts exports', () => {
153
+ const indexNames = extractExportedNames(fs.readFileSync(INDEX_PATH, 'utf8'));
154
+ const reactNames = extractExportedNames(fs.readFileSync(REACT_EXPORT_PATH, 'utf8'));
155
+
156
+ // Sanity: the extractor found something. Guards against a regex that
157
+ // silently matches nothing after a refactor.
158
+ expect(indexNames.size).toBeGreaterThan(50);
159
+ expect(reactNames.size).toBeGreaterThan(50);
160
+
161
+ const missing = [...indexNames]
162
+ .filter((name) => !reactNames.has(name))
163
+ .filter((name) => !REACT_EXEMPT.has(name))
164
+ .filter((name) => !KNOWN_REACT_GAPS.has(name))
165
+ .sort();
166
+
167
+ if (missing.length > 0) {
168
+ throw new Error(
169
+ 'These symbols are exported from src/index.ts but NOT from '
170
+ + 'src/react/all-types-export.ts, so React consumers cannot '
171
+ + `import them:\n ${missing.join('\n ')}\n\n`
172
+ + 'Add them to src/react/all-types-export.ts. Do NOT add them '
173
+ + 'to KNOWN_REACT_GAPS — that list is a shrinking backlog of '
174
+ + 'pre-existing gaps and must never grow.',
175
+ );
176
+ }
177
+ });
178
+
179
+ it('KNOWN_REACT_GAPS only lists symbols that are genuinely still missing', () => {
180
+ // Ratchet: once a gap is fixed, its entry must be deleted, so the list
181
+ // can only shrink.
182
+ const indexNames = extractExportedNames(fs.readFileSync(INDEX_PATH, 'utf8'));
183
+ const reactNames = extractExportedNames(fs.readFileSync(REACT_EXPORT_PATH, 'utf8'));
184
+
185
+ const stale = [...KNOWN_REACT_GAPS]
186
+ .filter((name) => reactNames.has(name) || !indexNames.has(name))
187
+ .sort();
188
+
189
+ if (stale.length > 0) {
190
+ throw new Error(
191
+ 'These entries in KNOWN_REACT_GAPS are no longer gaps (they are '
192
+ + 'now exported from the React surface, or no longer exported '
193
+ + `from src/index.ts). Delete them from the list:\n ${stale.join('\n ')}`,
194
+ );
195
+ }
196
+ });
197
+
198
+ it('exposes the host event contract types on the React surface', () => {
199
+ const reactNames = extractExportedNames(fs.readFileSync(REACT_EXPORT_PATH, 'utf8'));
200
+ [
201
+ 'UIPassthroughContractBase',
202
+ 'HostEventRequest',
203
+ 'HostEventResponse',
204
+ 'TriggerPayload',
205
+ 'TriggerResponse',
206
+ ].forEach((name) => expect(reactNames.has(name)).toBe(true));
207
+ });
208
+ });
@@ -56,8 +56,30 @@ export {
56
56
  RuntimeParameter,
57
57
  resetCachedAuthToken,
58
58
  UIPassthroughEvent,
59
+ // Host event payload / response contracts — kept in sync with src/index.ts
60
+ // (enforced by all-types-export.parity.spec.ts).
61
+ UIPassthroughContractBase,
62
+ UIPassthroughRequest,
63
+ UIPassthroughResponse,
64
+ UIPassthroughArrayResponse,
65
+ HostEventRequest,
66
+ HostEventResponse,
67
+ TriggerPayload,
68
+ TriggerResponse,
69
+ LiveboardTab,
70
+ LiveboardGroup,
71
+ ApplicabilityLevel,
72
+ Applicability,
73
+ FilterUpdate,
74
+ LiveboardFilter,
75
+ LiveboardParameter,
59
76
  DataPanelCustomColumnGroupsAccordionState,
60
77
  InterceptedApiType,
61
78
  CustomActionsPosition,
62
79
  CustomActionTarget,
80
+ SpotterAnalystConfig,
81
+ StarterPromptsConfig,
82
+ StarterPromptCategory,
83
+ StarterPreviewDataCategory,
84
+ StarterPromptQuestion,
63
85
  } from '../index';