@thoughtspot/visual-embed-sdk 1.51.0 → 1.51.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 (228) 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/search.spec.js +28 -0
  37. package/cjs/src/embed/search.spec.js.map +1 -1
  38. package/cjs/src/embed/spotter-utils.d.ts +8 -1
  39. package/cjs/src/embed/spotter-utils.d.ts.map +1 -1
  40. package/cjs/src/embed/spotter-utils.js +15 -1
  41. package/cjs/src/embed/spotter-utils.js.map +1 -1
  42. package/cjs/src/embed/spotter-utils.spec.js +68 -0
  43. package/cjs/src/embed/spotter-utils.spec.js.map +1 -1
  44. package/cjs/src/embed/spotter-viz-utils.d.ts +9 -10
  45. package/cjs/src/embed/spotter-viz-utils.d.ts.map +1 -1
  46. package/cjs/src/embed/spotter-viz-utils.js.map +1 -1
  47. package/cjs/src/embed/ts-embed.d.ts +97 -9
  48. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  49. package/cjs/src/embed/ts-embed.js +76 -35
  50. package/cjs/src/embed/ts-embed.js.map +1 -1
  51. package/cjs/src/embed/ts-embed.spec.js +537 -3
  52. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  53. package/cjs/src/index.d.ts +3 -3
  54. package/cjs/src/index.d.ts.map +1 -1
  55. package/cjs/src/index.js +3 -2
  56. package/cjs/src/index.js.map +1 -1
  57. package/cjs/src/react/all-types-export.d.ts +1 -1
  58. package/cjs/src/react/all-types-export.d.ts.map +1 -1
  59. package/cjs/src/react/all-types-export.js +2 -1
  60. package/cjs/src/react/all-types-export.js.map +1 -1
  61. package/cjs/src/react/all-types-export.parity.spec.d.ts +2 -0
  62. package/cjs/src/react/all-types-export.parity.spec.d.ts.map +1 -0
  63. package/cjs/src/react/all-types-export.parity.spec.js +194 -0
  64. package/cjs/src/react/all-types-export.parity.spec.js.map +1 -0
  65. package/cjs/src/react/index.d.ts +66 -32
  66. package/cjs/src/react/index.d.ts.map +1 -1
  67. package/cjs/src/react/index.js +5 -3
  68. package/cjs/src/react/index.js.map +1 -1
  69. package/cjs/src/react/index.spec.js +101 -0
  70. package/cjs/src/react/index.spec.js.map +1 -1
  71. package/cjs/src/types.d.ts +330 -18
  72. package/cjs/src/types.d.ts.map +1 -1
  73. package/cjs/src/types.js +182 -12
  74. package/cjs/src/types.js.map +1 -1
  75. package/cjs/src/utils.d.ts +5 -0
  76. package/cjs/src/utils.d.ts.map +1 -1
  77. package/cjs/src/utils.js +19 -1
  78. package/cjs/src/utils.js.map +1 -1
  79. package/cjs/src/utils.spec.js +37 -0
  80. package/cjs/src/utils.spec.js.map +1 -1
  81. package/dist/{index-aBzH5ZwF.js → index-D8_Zs-Nr.js} +1 -1
  82. package/dist/src/config.d.ts +1 -0
  83. package/dist/src/config.d.ts.map +1 -1
  84. package/dist/src/css-variables.d.ts +27 -0
  85. package/dist/src/css-variables.d.ts.map +1 -1
  86. package/dist/src/embed/app.d.ts +43 -12
  87. package/dist/src/embed/app.d.ts.map +1 -1
  88. package/dist/src/embed/base.d.ts +1 -1
  89. package/dist/src/embed/conversation.d.ts +171 -1
  90. package/dist/src/embed/conversation.d.ts.map +1 -1
  91. package/dist/src/embed/hostEventClient/host-event-client.d.ts +1 -1
  92. package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  93. package/dist/src/embed/liveboard.d.ts +40 -13
  94. package/dist/src/embed/liveboard.d.ts.map +1 -1
  95. package/dist/src/embed/spotter-utils.d.ts +8 -1
  96. package/dist/src/embed/spotter-utils.d.ts.map +1 -1
  97. package/dist/src/embed/spotter-viz-utils.d.ts +9 -10
  98. package/dist/src/embed/spotter-viz-utils.d.ts.map +1 -1
  99. package/dist/src/embed/ts-embed.d.ts +97 -9
  100. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  101. package/dist/src/index.d.ts +3 -3
  102. package/dist/src/index.d.ts.map +1 -1
  103. package/dist/src/react/all-types-export.d.ts +1 -1
  104. package/dist/src/react/all-types-export.d.ts.map +1 -1
  105. package/dist/src/react/all-types-export.parity.spec.d.ts +2 -0
  106. package/dist/src/react/all-types-export.parity.spec.d.ts.map +1 -0
  107. package/dist/src/react/index.d.ts +66 -32
  108. package/dist/src/react/index.d.ts.map +1 -1
  109. package/dist/src/types.d.ts +330 -18
  110. package/dist/src/types.d.ts.map +1 -1
  111. package/dist/src/utils.d.ts +5 -0
  112. package/dist/src/utils.d.ts.map +1 -1
  113. package/dist/tsembed-react.es.js +354 -64
  114. package/dist/tsembed-react.js +353 -63
  115. package/dist/tsembed.es.js +414 -126
  116. package/dist/tsembed.js +416 -128
  117. package/dist/visual-embed-sdk-react-full.d.ts +777 -90
  118. package/dist/visual-embed-sdk-react.d.ts +773 -89
  119. package/dist/visual-embed-sdk.d.ts +713 -60
  120. package/lib/package.json +1 -1
  121. package/lib/src/config.d.ts +1 -0
  122. package/lib/src/config.d.ts.map +1 -1
  123. package/lib/src/config.js +1 -0
  124. package/lib/src/config.js.map +1 -1
  125. package/lib/src/css-variables.d.ts +27 -0
  126. package/lib/src/css-variables.d.ts.map +1 -1
  127. package/lib/src/embed/app.d.ts +43 -12
  128. package/lib/src/embed/app.d.ts.map +1 -1
  129. package/lib/src/embed/app.js +30 -4
  130. package/lib/src/embed/app.js.map +1 -1
  131. package/lib/src/embed/app.spec.js +253 -1
  132. package/lib/src/embed/app.spec.js.map +1 -1
  133. package/lib/src/embed/base.d.ts +1 -1
  134. package/lib/src/embed/base.js +1 -1
  135. package/lib/src/embed/conversation.d.ts +171 -1
  136. package/lib/src/embed/conversation.d.ts.map +1 -1
  137. package/lib/src/embed/conversation.js +5 -3
  138. package/lib/src/embed/conversation.js.map +1 -1
  139. package/lib/src/embed/conversation.spec.js +125 -0
  140. package/lib/src/embed/conversation.spec.js.map +1 -1
  141. package/lib/src/embed/events.spec.js +3 -0
  142. package/lib/src/embed/events.spec.js.map +1 -1
  143. package/lib/src/embed/host-events.spec.js +36 -0
  144. package/lib/src/embed/host-events.spec.js.map +1 -1
  145. package/lib/src/embed/hostEventClient/host-event-client.d.ts +1 -1
  146. package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  147. package/lib/src/embed/hostEventClient/host-event-client.spec.js +18 -0
  148. package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  149. package/lib/src/embed/liveboard.d.ts +40 -13
  150. package/lib/src/embed/liveboard.d.ts.map +1 -1
  151. package/lib/src/embed/liveboard.js +25 -4
  152. package/lib/src/embed/liveboard.js.map +1 -1
  153. package/lib/src/embed/liveboard.spec.js +349 -2
  154. package/lib/src/embed/liveboard.spec.js.map +1 -1
  155. package/lib/src/embed/search.spec.js +28 -0
  156. package/lib/src/embed/search.spec.js.map +1 -1
  157. package/lib/src/embed/spotter-utils.d.ts +8 -1
  158. package/lib/src/embed/spotter-utils.d.ts.map +1 -1
  159. package/lib/src/embed/spotter-utils.js +13 -0
  160. package/lib/src/embed/spotter-utils.js.map +1 -1
  161. package/lib/src/embed/spotter-utils.spec.js +69 -1
  162. package/lib/src/embed/spotter-utils.spec.js.map +1 -1
  163. package/lib/src/embed/spotter-viz-utils.d.ts +9 -10
  164. package/lib/src/embed/spotter-viz-utils.d.ts.map +1 -1
  165. package/lib/src/embed/spotter-viz-utils.js.map +1 -1
  166. package/lib/src/embed/ts-embed.d.ts +97 -9
  167. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  168. package/lib/src/embed/ts-embed.js +77 -36
  169. package/lib/src/embed/ts-embed.js.map +1 -1
  170. package/lib/src/embed/ts-embed.spec.js +537 -3
  171. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  172. package/lib/src/index.d.ts +3 -3
  173. package/lib/src/index.d.ts.map +1 -1
  174. package/lib/src/index.js +2 -2
  175. package/lib/src/index.js.map +1 -1
  176. package/lib/src/react/all-types-export.d.ts +1 -1
  177. package/lib/src/react/all-types-export.d.ts.map +1 -1
  178. package/lib/src/react/all-types-export.js +1 -1
  179. package/lib/src/react/all-types-export.js.map +1 -1
  180. package/lib/src/react/all-types-export.parity.spec.d.ts +2 -0
  181. package/lib/src/react/all-types-export.parity.spec.d.ts.map +1 -0
  182. package/lib/src/react/all-types-export.parity.spec.js +191 -0
  183. package/lib/src/react/all-types-export.parity.spec.js.map +1 -0
  184. package/lib/src/react/index.d.ts +66 -32
  185. package/lib/src/react/index.d.ts.map +1 -1
  186. package/lib/src/react/index.js +5 -3
  187. package/lib/src/react/index.js.map +1 -1
  188. package/lib/src/react/index.spec.js +102 -1
  189. package/lib/src/react/index.spec.js.map +1 -1
  190. package/lib/src/types.d.ts +330 -18
  191. package/lib/src/types.d.ts.map +1 -1
  192. package/lib/src/types.js +182 -12
  193. package/lib/src/types.js.map +1 -1
  194. package/lib/src/utils.d.ts +5 -0
  195. package/lib/src/utils.d.ts.map +1 -1
  196. package/lib/src/utils.js +17 -0
  197. package/lib/src/utils.js.map +1 -1
  198. package/lib/src/utils.spec.js +38 -1
  199. package/lib/src/utils.spec.js.map +1 -1
  200. package/lib/src/visual-embed-sdk.d.ts +713 -60
  201. package/package.json +1 -1
  202. package/src/config.ts +1 -0
  203. package/src/css-variables.ts +32 -0
  204. package/src/embed/app.spec.ts +335 -1
  205. package/src/embed/app.ts +71 -13
  206. package/src/embed/base.ts +1 -1
  207. package/src/embed/conversation.spec.ts +136 -0
  208. package/src/embed/conversation.ts +181 -3
  209. package/src/embed/events.spec.ts +4 -0
  210. package/src/embed/host-events.spec.ts +48 -0
  211. package/src/embed/hostEventClient/host-event-client.spec.ts +34 -0
  212. package/src/embed/hostEventClient/host-event-client.ts +2 -2
  213. package/src/embed/liveboard.spec.ts +457 -2
  214. package/src/embed/liveboard.ts +74 -15
  215. package/src/embed/search.spec.ts +31 -0
  216. package/src/embed/spotter-utils.spec.ts +72 -0
  217. package/src/embed/spotter-utils.ts +21 -1
  218. package/src/embed/spotter-viz-utils.ts +9 -10
  219. package/src/embed/ts-embed.spec.ts +699 -3
  220. package/src/embed/ts-embed.ts +91 -41
  221. package/src/index.ts +43 -2
  222. package/src/react/all-types-export.parity.spec.ts +208 -0
  223. package/src/react/all-types-export.ts +22 -0
  224. package/src/react/index.spec.tsx +158 -0
  225. package/src/react/index.tsx +70 -33
  226. package/src/types.ts +329 -16
  227. package/src/utils.spec.ts +49 -0
  228. package/src/utils.ts +16 -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,
@@ -37,6 +38,7 @@ import {
37
38
  isUndefined,
38
39
  getHostEventsConfig,
39
40
  getValueFromWindow,
41
+ deserializeParam,
40
42
  } from '../utils';
41
43
  import { getCustomActions } from '../utils/custom-actions';
42
44
  import {
@@ -66,6 +68,8 @@ import {
66
68
  MessagePayload,
67
69
  ContextType,
68
70
  ContextObject,
71
+ PreRenderConfig,
72
+ BaseViewConfig,
69
73
  } from '../types';
70
74
  import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
71
75
  import { processEventData, processAuthFailure } from '../utils/processData';
@@ -206,7 +210,7 @@ export class TsEmbed {
206
210
 
207
211
  private resizeObserver: ResizeObserver;
208
212
 
209
- private preRenderContainerEl: HTMLElement | null = null;
213
+ private preRenderContainerEl: HTMLElement = document.body;
210
214
 
211
215
  private containerScrollListener: (() => void) | null = null;
212
216
 
@@ -703,11 +707,14 @@ export class TsEmbed {
703
707
  }
704
708
 
705
709
  protected async getUpdateEmbedParamsObject() {
706
- let queryParams = this.getEmbedParamsObject();
710
+ const queryParams = this.getEmbedParamsObject();
711
+ // Values are URL-serialized (e.g. dataSources as '["guid"]'); parse
712
+ // them back so the event payload matches a URL load (SCAL-334713).
713
+ Object.keys(queryParams).forEach((key) => {
714
+ queryParams[key] = deserializeParam(queryParams[key]);
715
+ });
707
716
  const appInitData = await this.getAppInitData();
708
- queryParams = { ...this.viewConfig, ...queryParams, ...appInitData };
709
-
710
- return queryParams;
717
+ return { ...this.viewConfig, ...queryParams, ...appInitData };
711
718
  }
712
719
 
713
720
  /**
@@ -959,11 +966,27 @@ export class TsEmbed {
959
966
  return iFrame;
960
967
  }
961
968
 
969
+ /**
970
+ * Returns a merged {@link PreRenderConfig} object where each shared key
971
+ * prefers `preRenderConfig.key` over the top-level `viewConfig.key` for
972
+ * backward compatibility.
973
+ */
974
+ protected getPreRenderConfig(): PreRenderConfig {
975
+ const viewCfg = this.viewConfig as BaseViewConfig;
976
+ const preRenderCfg = viewCfg.preRenderConfig ?? {};
977
+ return {
978
+ ...preRenderCfg,
979
+ preRenderId: preRenderCfg.preRenderId ?? viewCfg.preRenderId,
980
+ preRenderContainer: preRenderCfg.preRenderContainer ?? viewCfg.preRenderContainer,
981
+ doNotTrackPreRenderSize: preRenderCfg.doNotTrackPreRenderSize ?? viewCfg.doNotTrackPreRenderSize,
982
+ };
983
+ }
984
+
962
985
  /**
963
986
  * Returns true if this embed instance is configured for pre-rendering.
964
987
  */
965
988
  protected isPreRenderEmbed() {
966
- return !!this.viewConfig.preRenderId;
989
+ return !!this.getPreRenderConfig().preRenderId;
967
990
  }
968
991
  protected handleInsertionIntoDOM(child: string | Node): void {
969
992
  if (this.isPreRenderEmbed()) {
@@ -1119,6 +1142,7 @@ export class TsEmbed {
1119
1142
  this.setIframeElement(this.preRenderChild);
1120
1143
  }
1121
1144
  this.isRendered = true;
1145
+ this.inheritPreRenderContainer();
1122
1146
  }
1123
1147
 
1124
1148
  return this.isPreRenderConnected();
@@ -1176,7 +1200,7 @@ export class TsEmbed {
1176
1200
  * fresh element; an element passed directly cannot be re-resolved.
1177
1201
  */
1178
1202
  private resolvePreRenderContainerTarget(): HTMLElement {
1179
- const containerConfig = this.viewConfig.preRenderContainer;
1203
+ const containerConfig = this.getPreRenderConfig().preRenderContainer;
1180
1204
  let container: Element | null = null;
1181
1205
  if (typeof containerConfig === 'string') {
1182
1206
  try {
@@ -1193,15 +1217,40 @@ export class TsEmbed {
1193
1217
  return (container as HTMLElement) ?? document.body;
1194
1218
  }
1195
1219
 
1220
+ private inheritPreRenderContainer(): void {
1221
+ const preRenderedObject = this.getPreRenderObj<TsEmbed>();
1222
+ if (!preRenderedObject || preRenderedObject === (this as TsEmbed)) {
1223
+ return;
1224
+ }
1225
+ const ownerContainer = preRenderedObject.preRenderContainerEl ?? document.body;
1226
+ if (
1227
+ this.getPreRenderConfig().preRenderContainer
1228
+ && this.resolvePreRenderContainerTarget() !== ownerContainer
1229
+ ) {
1230
+ logger.warn(
1231
+ 'preRenderContainer is applied only by the component that creates the preRender; '
1232
+ + 'the one passed here is ignored. Set it on the PreRender component instead.',
1233
+ );
1234
+ }
1235
+ this.preRenderContainerEl = ownerContainer;
1236
+ this.applyPreRenderContainerPositioning();
1237
+ }
1238
+
1239
+ private getCustomPreRenderContainer(): HTMLElement | null {
1240
+ const container = this.preRenderContainerEl;
1241
+ return container && container !== document.body ? container : null;
1242
+ }
1243
+
1196
1244
  /**
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.
1245
+ * Makes the resolved container a positioning context for the absolutely
1246
+ * positioned wrapper, stashing the original inline `position` on the element
1247
+ * (once) so destroy() can restore it exactly, leaving no trace. Recording it
1248
+ * on the element rather than per-instance lets the override be reverted even
1249
+ * when embeds share the same container.
1202
1250
  */
1203
- private applyPreRenderContainerPositioning(container: HTMLElement): void {
1204
- if (container === document.body) {
1251
+ private applyPreRenderContainerPositioning(): void {
1252
+ const container = this.getCustomPreRenderContainer();
1253
+ if (!container) {
1205
1254
  return;
1206
1255
  }
1207
1256
  const pos = window.getComputedStyle(container).position;
@@ -1247,11 +1296,11 @@ export class TsEmbed {
1247
1296
  resolved.addEventListener('scroll', this.containerScrollListener);
1248
1297
  }
1249
1298
  }
1250
- this.applyPreRenderContainerPositioning(resolved);
1299
+ this.preRenderContainerEl = resolved;
1300
+ this.applyPreRenderContainerPositioning();
1251
1301
  if (wrapper.parentNode !== resolved) {
1252
1302
  resolved.appendChild(wrapper);
1253
1303
  }
1254
- this.preRenderContainerEl = resolved;
1255
1304
  }
1256
1305
 
1257
1306
  protected insertIntoDOMForPreRender(child: string | Node): void {
@@ -1279,7 +1328,7 @@ export class TsEmbed {
1279
1328
 
1280
1329
  const targetContainer = this.resolvePreRenderContainerTarget();
1281
1330
  this.preRenderContainerEl = targetContainer;
1282
- this.applyPreRenderContainerPositioning(targetContainer);
1331
+ this.applyPreRenderContainerPositioning();
1283
1332
  targetContainer.appendChild(preRenderWrapper);
1284
1333
  }
1285
1334
 
@@ -1625,7 +1674,11 @@ export class TsEmbed {
1625
1674
  * ```
1626
1675
  * @version SDK: 1.45.2 | ThoughtSpot: 26.3.0.cl (for context parameter)
1627
1676
  */
1628
- public async trigger<HostEventT extends HostEvent, PayloadT, ContextT extends ContextType>(
1677
+ public async trigger<
1678
+ HostEventT extends HostEvent,
1679
+ PayloadT = HostEventRequest<HostEventT>,
1680
+ ContextT extends ContextType = ContextType,
1681
+ >(
1629
1682
  messageType: HostEventT,
1630
1683
  data: TriggerPayload<PayloadT, HostEventT> = {} as any,
1631
1684
  context?: ContextT,
@@ -1797,7 +1850,7 @@ export class TsEmbed {
1797
1850
  showPreRenderByDefault,
1798
1851
  replaceExistingPreRender,
1799
1852
  });
1800
- if (!this.viewConfig.preRenderId) {
1853
+ if (!this.getPreRenderConfig().preRenderId) {
1801
1854
  logger.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
1802
1855
  return this;
1803
1856
  }
@@ -1856,13 +1909,13 @@ export class TsEmbed {
1856
1909
  * same container — a shared container still needs the positioning context.
1857
1910
  */
1858
1911
  private restorePreRenderContainerPosition(): void {
1859
- const container = this.preRenderContainerEl as HTMLElement | null;
1912
+ const container = this.preRenderContainerEl;
1860
1913
  if (!container || container === document.body) {
1861
1914
  return;
1862
1915
  }
1863
1916
  // Drop our reference up front so a destroyed embed never pins a
1864
1917
  // detached container in memory; restoration uses the local handle.
1865
- this.preRenderContainerEl = null;
1918
+ this.preRenderContainerEl = document.body;
1866
1919
  const originalPosition = container.dataset[PRERENDER_CONTAINER_ORIGINAL_POSITION_KEY];
1867
1920
  if (originalPosition === undefined) {
1868
1921
  // We never overrode this container's position; nothing to restore.
@@ -1888,10 +1941,7 @@ export class TsEmbed {
1888
1941
  if (!this.containerScrollListener) {
1889
1942
  return;
1890
1943
  }
1891
- const customContainer =
1892
- this.preRenderContainerEl && this.preRenderContainerEl !== document.body
1893
- ? this.preRenderContainerEl
1894
- : null;
1944
+ const customContainer = this.getCustomPreRenderContainer();
1895
1945
  customContainer?.removeEventListener('scroll', this.containerScrollListener);
1896
1946
  this.containerScrollListener = null;
1897
1947
  }
@@ -1986,14 +2036,14 @@ export class TsEmbed {
1986
2036
  */
1987
2037
  public async showPreRender(): Promise<TsEmbed> {
1988
2038
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_SHOW_PRE_RENDER, {
1989
- preRenderId: this.viewConfig.preRenderId,
2039
+ preRenderId: this.getPreRenderConfig().preRenderId,
1990
2040
  embedComponentType: this.viewConfig.embedComponentType,
1991
2041
  });
1992
2042
 
1993
2043
  if (this.shouldWaitForRenderPromise) await this.isReadyForRenderPromise;
1994
2044
 
1995
2045
 
1996
- if (!this.viewConfig.preRenderId) {
2046
+ if (!this.getPreRenderConfig().preRenderId) {
1997
2047
  logger.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
1998
2048
  return this;
1999
2049
  }
@@ -2029,16 +2079,13 @@ export class TsEmbed {
2029
2079
 
2030
2080
  this.syncPreRenderStyle();
2031
2081
 
2032
- const customContainer =
2033
- this.preRenderContainerEl && this.preRenderContainerEl !== document.body
2034
- ? this.preRenderContainerEl
2035
- : null;
2082
+ const customContainer = this.getCustomPreRenderContainer();
2036
2083
  if (customContainer && !this.containerScrollListener) {
2037
2084
  this.containerScrollListener = () => this.syncPreRenderStyle();
2038
2085
  customContainer.addEventListener('scroll', this.containerScrollListener);
2039
2086
  }
2040
2087
 
2041
- if (!this.viewConfig.doNotTrackPreRenderSize) {
2088
+ if (!this.getPreRenderConfig().doNotTrackPreRenderSize) {
2042
2089
  const observeTarget = (this.insertedDomEl as HTMLElement) ?? this.hostElement;
2043
2090
  this.resizeObserver = new ResizeObserver((entries) => {
2044
2091
  entries.forEach((entry) => {
@@ -2084,15 +2131,16 @@ export class TsEmbed {
2084
2131
  logger.error(ERROR_MESSAGE.SYNC_STYLE_CALLED_BEFORE_RENDER);
2085
2132
  return;
2086
2133
  }
2134
+ if (!this.getPreRenderPlaceHolderElement().isConnected) {
2135
+ logger.debug('syncPreRenderStyle skipped: placeholder is detached');
2136
+ return;
2137
+ }
2087
2138
  // Self-heal if the resolved container was remounted/detached, so we
2088
2139
  // never measure a stale node (which would collapse the wrapper).
2089
2140
  this.reconcilePreRenderContainer();
2090
2141
  const elBoundingClient = this.getPreRenderPlaceHolderElement().getBoundingClientRect();
2091
2142
 
2092
- const containerEl =
2093
- this.preRenderContainerEl && this.preRenderContainerEl !== document.body
2094
- ? this.preRenderContainerEl
2095
- : null;
2143
+ const containerEl = this.getCustomPreRenderContainer();
2096
2144
  const containerRect = containerEl?.getBoundingClientRect() ?? { x: 0, y: 0 };
2097
2145
  const scrollX = containerEl ? containerEl.scrollLeft : window.scrollX;
2098
2146
  const scrollY = containerEl ? containerEl.scrollTop : window.scrollY;
@@ -2112,7 +2160,7 @@ export class TsEmbed {
2112
2160
  */
2113
2161
  public hidePreRender(): void {
2114
2162
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_HIDE_PRE_RENDER, {
2115
- preRenderId: this.viewConfig.preRenderId,
2163
+ preRenderId: this.getPreRenderConfig().preRenderId,
2116
2164
  embedComponentType: this.viewConfig.embedComponentType,
2117
2165
  });
2118
2166
 
@@ -2122,10 +2170,11 @@ export class TsEmbed {
2122
2170
  logger.warn('PreRender should be called before hiding it using hidePreRender.');
2123
2171
  return;
2124
2172
  }
2173
+ const { zIndex } = this.getPreRenderConfig();
2125
2174
  const preRenderHideStyles = {
2126
2175
  opacity: '0',
2127
2176
  pointerEvents: 'none',
2128
- zIndex: '-1000',
2177
+ zIndex: zIndex !== undefined ? String(zIndex) : '-1000',
2129
2178
  position: 'absolute',
2130
2179
  top: '0',
2131
2180
  left: '0',
@@ -2155,10 +2204,11 @@ export class TsEmbed {
2155
2204
  * @property {string} child - The HTML element ID for the PreRender child.
2156
2205
  */
2157
2206
  public getPreRenderIds() {
2207
+ const preRenderId = this.getPreRenderConfig().preRenderId;
2158
2208
  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}`,
2209
+ wrapper: `${PRERENDER_WRAPPER_ID_PREFIX}${preRenderId}`,
2210
+ child: `tsEmbed-pre-render-child-${preRenderId}`,
2211
+ placeHolder: `tsEmbed-pre-render-placeholder-${preRenderId}`,
2162
2212
  };
2163
2213
  }
2164
2214
 
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';