@thoughtspot/visual-embed-sdk 1.24.0-alpha.7 → 1.24.0-dev

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 (75) hide show
  1. package/cjs/package.json +2 -2
  2. package/cjs/src/embed/liveboard.d.ts +1 -0
  3. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  4. package/cjs/src/embed/liveboard.js +5 -0
  5. package/cjs/src/embed/liveboard.js.map +1 -1
  6. package/cjs/src/embed/ts-embed.d.ts +19 -0
  7. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  8. package/cjs/src/embed/ts-embed.js +131 -4
  9. package/cjs/src/embed/ts-embed.js.map +1 -1
  10. package/cjs/src/react/all-types-export.d.ts +1 -1
  11. package/cjs/src/react/all-types-export.d.ts.map +1 -1
  12. package/cjs/src/react/all-types-export.js +2 -1
  13. package/cjs/src/react/all-types-export.js.map +1 -1
  14. package/cjs/src/react/index.d.ts +1 -0
  15. package/cjs/src/react/index.d.ts.map +1 -1
  16. package/cjs/src/react/index.js +18 -4
  17. package/cjs/src/react/index.js.map +1 -1
  18. package/cjs/src/types.d.ts +9 -0
  19. package/cjs/src/types.d.ts.map +1 -1
  20. package/cjs/src/types.js.map +1 -1
  21. package/cjs/src/utils.d.ts +2 -0
  22. package/cjs/src/utils.d.ts.map +1 -1
  23. package/cjs/src/utils.js +17 -1
  24. package/cjs/src/utils.js.map +1 -1
  25. package/dist/src/embed/liveboard.d.ts +1 -0
  26. package/dist/src/embed/liveboard.d.ts.map +1 -1
  27. package/dist/src/embed/ts-embed.d.ts +19 -0
  28. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  29. package/dist/src/react/all-types-export.d.ts +1 -1
  30. package/dist/src/react/all-types-export.d.ts.map +1 -1
  31. package/dist/src/react/index.d.ts +1 -0
  32. package/dist/src/react/index.d.ts.map +1 -1
  33. package/dist/src/types.d.ts +9 -0
  34. package/dist/src/types.d.ts.map +1 -1
  35. package/dist/src/utils.d.ts +2 -0
  36. package/dist/src/utils.d.ts.map +1 -1
  37. package/dist/tsembed-react.es.js +171 -11
  38. package/dist/tsembed-react.js +171 -10
  39. package/dist/tsembed.es.js +152 -6
  40. package/dist/tsembed.js +152 -6
  41. package/dist/visual-embed-sdk-react-full.d.ts +29 -0
  42. package/dist/visual-embed-sdk-react.d.ts +29 -0
  43. package/dist/visual-embed-sdk.d.ts +28 -0
  44. package/lib/package.json +2 -2
  45. package/lib/src/embed/liveboard.d.ts +1 -0
  46. package/lib/src/embed/liveboard.d.ts.map +1 -1
  47. package/lib/src/embed/liveboard.js +5 -0
  48. package/lib/src/embed/liveboard.js.map +1 -1
  49. package/lib/src/embed/ts-embed.d.ts +19 -0
  50. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  51. package/lib/src/embed/ts-embed.js +132 -5
  52. package/lib/src/embed/ts-embed.js.map +1 -1
  53. package/lib/src/react/all-types-export.d.ts +1 -1
  54. package/lib/src/react/all-types-export.d.ts.map +1 -1
  55. package/lib/src/react/all-types-export.js +1 -1
  56. package/lib/src/react/all-types-export.js.map +1 -1
  57. package/lib/src/react/index.d.ts +1 -0
  58. package/lib/src/react/index.d.ts.map +1 -1
  59. package/lib/src/react/index.js +17 -3
  60. package/lib/src/react/index.js.map +1 -1
  61. package/lib/src/types.d.ts +9 -0
  62. package/lib/src/types.d.ts.map +1 -1
  63. package/lib/src/types.js.map +1 -1
  64. package/lib/src/utils.d.ts +2 -0
  65. package/lib/src/utils.d.ts.map +1 -1
  66. package/lib/src/utils.js +14 -0
  67. package/lib/src/utils.js.map +1 -1
  68. package/lib/src/visual-embed-sdk.d.ts +28 -0
  69. package/package.json +5 -5
  70. package/src/embed/liveboard.ts +8 -0
  71. package/src/embed/ts-embed.ts +169 -12
  72. package/src/react/all-types-export.ts +1 -0
  73. package/src/react/index.tsx +25 -8
  74. package/src/types.ts +10 -0
  75. package/src/utils.ts +20 -0
@@ -193,7 +193,21 @@ const getRuntimeFilters = (runtimefilters) => getFilterQuery(runtimefilters || [
193
193
  */
194
194
  function getDOMNode(domSelector) {
195
195
  return typeof domSelector === 'string' ? document.querySelector(domSelector) : domSelector;
196
- }
196
+ }
197
+ const setStyleProperties = (element, styleProperties) => {
198
+ if (!element || !styleProperties)
199
+ return;
200
+ Object.keys(styleProperties).forEach((styleProperty) => {
201
+ element.style[styleProperty] = styleProperties[styleProperty].toString();
202
+ });
203
+ };
204
+ const removeStyleProperties = (element, styleProperties) => {
205
+ if (!element || !styleProperties)
206
+ return;
207
+ styleProperties.forEach((styleProperty) => {
208
+ element.style.removeProperty(styleProperty);
209
+ });
210
+ };
197
211
 
198
212
  /**
199
213
  * Copyright (c) 2023
@@ -11256,7 +11270,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
11256
11270
  });
11257
11271
  }
11258
11272
 
11259
- var name="@thoughtspot/visual-embed-sdk";var version="1.24.0-alpha.7";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",dompurify:"^2.3.4","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^40.1.0",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","current-git-branch":"^1.1.0","dts-bundle":"^0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.13.1","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"6.7.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.js",limit:"40 kB"}],scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
11273
+ var name="@thoughtspot/visual-embed-sdk";var version="1.24.0-dev";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",dompurify:"^2.3.4","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^40.1.0",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","current-git-branch":"^1.1.0","dts-bundle":"^0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.13.1","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"6.7.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.js",limit:"40 kB"}],scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
11260
11274
 
11261
11275
  /**
11262
11276
  * Copyright (c) 2022
@@ -11651,7 +11665,12 @@ class TsEmbed {
11651
11665
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
11652
11666
  return (_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
11653
11667
  if (!isLoggedIn) {
11654
- this.insertIntoDOM(this.embedConfig.loginFailedMessage);
11668
+ if (this.isPreRendered) {
11669
+ this.insertIntoDOMForPreRender(this.embedConfig.loginFailedMessage);
11670
+ }
11671
+ else {
11672
+ this.insertIntoDOM(this.embedConfig.loginFailedMessage);
11673
+ }
11655
11674
  return;
11656
11675
  }
11657
11676
  this.iFrame = this.iFrame || this.createIframeEl(url);
@@ -11673,7 +11692,12 @@ class TsEmbed {
11673
11692
  this.iFrame.addEventListener('error', () => {
11674
11693
  nextInQueue();
11675
11694
  });
11676
- this.insertIntoDOM(this.iFrame);
11695
+ if (this.isPreRendered) {
11696
+ this.insertIntoDOMForPreRender(this.iFrame);
11697
+ }
11698
+ else {
11699
+ this.insertIntoDOM(this.iFrame);
11700
+ }
11677
11701
  const prefetchIframe = document.querySelectorAll('.prefetchIframe');
11678
11702
  if (prefetchIframe.length) {
11679
11703
  prefetchIframe.forEach((el) => {
@@ -11686,11 +11710,119 @@ class TsEmbed {
11686
11710
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED, {
11687
11711
  error: JSON.stringify(error),
11688
11712
  });
11689
- this.insertIntoDOM(this.embedConfig.loginFailedMessage);
11713
+ if (this.isPreRendered) {
11714
+ this.insertIntoDOMForPreRender(this.embedConfig.loginFailedMessage);
11715
+ }
11716
+ else {
11717
+ this.insertIntoDOM(this.embedConfig.loginFailedMessage);
11718
+ }
11690
11719
  this.handleError(error);
11691
11720
  });
11692
11721
  });
11693
11722
  }
11723
+ getPreRenderIds() {
11724
+ return {
11725
+ wrapper: `tsEmbed-pre-render-wrapper-${this.viewConfig.preRenderId}`,
11726
+ shield: `tsEmbed-pre-render-shield-${this.viewConfig.preRenderId}`,
11727
+ child: `tsEmbed-pre-render-child-${this.viewConfig.preRenderId}`,
11728
+ };
11729
+ }
11730
+ createPreRenderWrapper(child) {
11731
+ if (!this.viewConfig.preRenderId) {
11732
+ throw new Error('Pre render id is required');
11733
+ }
11734
+ const preRenderIds = this.getPreRenderIds();
11735
+ const stalePreRenderWrapper = document.getElementById(preRenderIds.wrapper);
11736
+ if (stalePreRenderWrapper) {
11737
+ console.log('Found stale wrapper , removing');
11738
+ stalePreRenderWrapper.remove();
11739
+ }
11740
+ const preRenderWrapper = document.createElement('div');
11741
+ preRenderWrapper.id = preRenderIds.wrapper;
11742
+ setStyleProperties(preRenderWrapper, { position: 'absolute', width: '100vw', height: '100vh' });
11743
+ const preRenderShield = document.createElement('div');
11744
+ preRenderShield.id = preRenderIds.shield;
11745
+ setStyleProperties(preRenderShield, { position: 'absolute', width: '100%', height: '100%' });
11746
+ child.id = preRenderIds.child;
11747
+ preRenderWrapper.appendChild(child);
11748
+ preRenderWrapper.appendChild(preRenderShield);
11749
+ this.preRenderWrapper = preRenderWrapper;
11750
+ this.preRenderShield = preRenderShield;
11751
+ this.preRenderChild = child;
11752
+ return preRenderWrapper;
11753
+ }
11754
+ isPreRenderAvailable() {
11755
+ const preRenderIds = this.getPreRenderIds();
11756
+ this.preRenderWrapper = this.preRenderWrapper
11757
+ || document.getElementById(preRenderIds.wrapper);
11758
+ this.preRenderShield = this.preRenderShield
11759
+ || document.getElementById(preRenderIds.shield);
11760
+ this.preRenderChild = this.preRenderChild
11761
+ || document.getElementById(preRenderIds.child);
11762
+ return !!this.preRenderWrapper && !!this.preRenderShield
11763
+ && !!this.preRenderChild;
11764
+ }
11765
+ insertIntoDOMForPreRender(child) {
11766
+ let childNode;
11767
+ if (typeof child === 'string') {
11768
+ const divChildNode = document.createElement('div');
11769
+ divChildNode.innerHTML = child;
11770
+ childNode = divChildNode;
11771
+ }
11772
+ else {
11773
+ childNode = child;
11774
+ }
11775
+ const preRenderWrapper = this.createPreRenderWrapper(childNode);
11776
+ document.body.appendChild(preRenderWrapper);
11777
+ this.hidePreRender();
11778
+ }
11779
+ hidePreRender() {
11780
+ if (!this.isPreRenderAvailable()) {
11781
+ // if the embed component is not preRendered , nothing to hide
11782
+ console.log('No preRender found, not hiding ');
11783
+ return;
11784
+ }
11785
+ setStyleProperties(this.preRenderWrapper, {
11786
+ opacity: '0',
11787
+ pointerEvents: 'none',
11788
+ zIndex: '-1000',
11789
+ position: 'absolute ',
11790
+ top: '0',
11791
+ left: '0',
11792
+ });
11793
+ const childBoundingRect = this.preRenderChild.getBoundingClientRect();
11794
+ setStyleProperties(this.preRenderShield, {
11795
+ opacity: '0',
11796
+ pointerEvents: 'none',
11797
+ zIndex: '1',
11798
+ width: `${childBoundingRect.width}px`,
11799
+ height: `${childBoundingRect.height}px`,
11800
+ position: 'absolute',
11801
+ top: '0',
11802
+ left: '0',
11803
+ });
11804
+ }
11805
+ showPreRender() {
11806
+ if (!this.isPreRenderAvailable()) {
11807
+ // if the Embed component is nor preRendered , Render it now and
11808
+ // show it (hide is defalt behaviour)
11809
+ console.log('No preRender found, creating new ');
11810
+ this.render();
11811
+ return;
11812
+ }
11813
+ this.syncPreRenderStyle();
11814
+ removeStyleProperties(this.preRenderWrapper, ['z-index', 'opacity', 'pointer-events']);
11815
+ setStyleProperties(this.preRenderShield, { zIndex: '-1' });
11816
+ }
11817
+ syncPreRenderStyle() {
11818
+ if (!this.el) {
11819
+ throw new Error('Embed element is not defined');
11820
+ }
11821
+ const elBoundingClient = this.el.getBoundingClientRect();
11822
+ setStyleProperties(this.preRenderWrapper, {
11823
+ top: `${elBoundingClient.y}px`, left: `${elBoundingClient.x}px`, width: `${elBoundingClient.width}px`, height: `${elBoundingClient.height}px`,
11824
+ });
11825
+ }
11694
11826
  insertIntoDOM(child) {
11695
11827
  var _a;
11696
11828
  if (this.viewConfig.insertAsSibling) {
@@ -11905,6 +12037,13 @@ class TsEmbed {
11905
12037
  this.isRendered = true;
11906
12038
  return this;
11907
12039
  }
12040
+ /**
12041
+ * Creates the preRender shell
12042
+ */
12043
+ preRender() {
12044
+ this.isPreRendered = true;
12045
+ return this;
12046
+ }
11908
12047
  /**
11909
12048
  * Get the Post Url Params for THOUGHTSPOT from the current
11910
12049
  * host app URL.
@@ -11986,8 +12125,10 @@ class V1Embed extends TsEmbed {
11986
12125
  let queryString = queryParams;
11987
12126
  if (!this.viewConfig.excludeRuntimeFiltersfromURL) {
11988
12127
  const runtimeFilters = this.viewConfig.runtimeFilters;
12128
+ const runtimeParameters = this.viewConfig.runtimeParameters;
12129
+ const parameterQuery = getRuntimeParameters(runtimeParameters || []);
11989
12130
  const filterQuery = getFilterQuery(runtimeFilters || []);
11990
- queryString = [filterQuery, queryParams].filter(Boolean).join('&');
12131
+ queryString = [parameterQuery, filterQuery, queryParams].filter(Boolean).join('&');
11991
12132
  }
11992
12133
  return this.getV1EmbedBasePath(queryString);
11993
12134
  }
@@ -12385,6 +12526,11 @@ class LiveboardEmbed extends V1Embed {
12385
12526
  this.renderV1Embed(src);
12386
12527
  return this;
12387
12528
  }
12529
+ preRender() {
12530
+ super.preRender();
12531
+ this.render();
12532
+ return this;
12533
+ }
12388
12534
  navigateToLiveboard(liveboardId, vizId, activeTabId) {
12389
12535
  const path = this.getIframeSuffixSrc(liveboardId, vizId, activeTabId);
12390
12536
  this.viewConfig.liveboardId = liveboardId;
package/dist/tsembed.js CHANGED
@@ -199,7 +199,21 @@
199
199
  */
200
200
  function getDOMNode(domSelector) {
201
201
  return typeof domSelector === 'string' ? document.querySelector(domSelector) : domSelector;
202
- }
202
+ }
203
+ const setStyleProperties = (element, styleProperties) => {
204
+ if (!element || !styleProperties)
205
+ return;
206
+ Object.keys(styleProperties).forEach((styleProperty) => {
207
+ element.style[styleProperty] = styleProperties[styleProperty].toString();
208
+ });
209
+ };
210
+ const removeStyleProperties = (element, styleProperties) => {
211
+ if (!element || !styleProperties)
212
+ return;
213
+ styleProperties.forEach((styleProperty) => {
214
+ element.style.removeProperty(styleProperty);
215
+ });
216
+ };
203
217
 
204
218
  /**
205
219
  * Copyright (c) 2023
@@ -11138,7 +11152,7 @@
11138
11152
  });
11139
11153
  }
11140
11154
 
11141
- var name="@thoughtspot/visual-embed-sdk";var version="1.24.0-alpha.7";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports$1={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",dompurify:"^2.3.4","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^40.1.0",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","current-git-branch":"^1.1.0","dts-bundle":"^0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.13.1","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"6.7.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports$1,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.js",limit:"40 kB"}],scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
11155
+ var name="@thoughtspot/visual-embed-sdk";var version="1.24.0-dev";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports$1={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",dompurify:"^2.3.4","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^40.1.0",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","current-git-branch":"^1.1.0","dts-bundle":"^0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.13.1","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"6.7.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports$1,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.js",limit:"40 kB"}],scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
11142
11156
 
11143
11157
  /**
11144
11158
  * Copyright (c) 2022
@@ -11533,7 +11547,12 @@
11533
11547
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
11534
11548
  return (_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
11535
11549
  if (!isLoggedIn) {
11536
- this.insertIntoDOM(this.embedConfig.loginFailedMessage);
11550
+ if (this.isPreRendered) {
11551
+ this.insertIntoDOMForPreRender(this.embedConfig.loginFailedMessage);
11552
+ }
11553
+ else {
11554
+ this.insertIntoDOM(this.embedConfig.loginFailedMessage);
11555
+ }
11537
11556
  return;
11538
11557
  }
11539
11558
  this.iFrame = this.iFrame || this.createIframeEl(url);
@@ -11555,7 +11574,12 @@
11555
11574
  this.iFrame.addEventListener('error', () => {
11556
11575
  nextInQueue();
11557
11576
  });
11558
- this.insertIntoDOM(this.iFrame);
11577
+ if (this.isPreRendered) {
11578
+ this.insertIntoDOMForPreRender(this.iFrame);
11579
+ }
11580
+ else {
11581
+ this.insertIntoDOM(this.iFrame);
11582
+ }
11559
11583
  const prefetchIframe = document.querySelectorAll('.prefetchIframe');
11560
11584
  if (prefetchIframe.length) {
11561
11585
  prefetchIframe.forEach((el) => {
@@ -11568,11 +11592,119 @@
11568
11592
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED, {
11569
11593
  error: JSON.stringify(error),
11570
11594
  });
11571
- this.insertIntoDOM(this.embedConfig.loginFailedMessage);
11595
+ if (this.isPreRendered) {
11596
+ this.insertIntoDOMForPreRender(this.embedConfig.loginFailedMessage);
11597
+ }
11598
+ else {
11599
+ this.insertIntoDOM(this.embedConfig.loginFailedMessage);
11600
+ }
11572
11601
  this.handleError(error);
11573
11602
  });
11574
11603
  });
11575
11604
  }
11605
+ getPreRenderIds() {
11606
+ return {
11607
+ wrapper: `tsEmbed-pre-render-wrapper-${this.viewConfig.preRenderId}`,
11608
+ shield: `tsEmbed-pre-render-shield-${this.viewConfig.preRenderId}`,
11609
+ child: `tsEmbed-pre-render-child-${this.viewConfig.preRenderId}`,
11610
+ };
11611
+ }
11612
+ createPreRenderWrapper(child) {
11613
+ if (!this.viewConfig.preRenderId) {
11614
+ throw new Error('Pre render id is required');
11615
+ }
11616
+ const preRenderIds = this.getPreRenderIds();
11617
+ const stalePreRenderWrapper = document.getElementById(preRenderIds.wrapper);
11618
+ if (stalePreRenderWrapper) {
11619
+ console.log('Found stale wrapper , removing');
11620
+ stalePreRenderWrapper.remove();
11621
+ }
11622
+ const preRenderWrapper = document.createElement('div');
11623
+ preRenderWrapper.id = preRenderIds.wrapper;
11624
+ setStyleProperties(preRenderWrapper, { position: 'absolute', width: '100vw', height: '100vh' });
11625
+ const preRenderShield = document.createElement('div');
11626
+ preRenderShield.id = preRenderIds.shield;
11627
+ setStyleProperties(preRenderShield, { position: 'absolute', width: '100%', height: '100%' });
11628
+ child.id = preRenderIds.child;
11629
+ preRenderWrapper.appendChild(child);
11630
+ preRenderWrapper.appendChild(preRenderShield);
11631
+ this.preRenderWrapper = preRenderWrapper;
11632
+ this.preRenderShield = preRenderShield;
11633
+ this.preRenderChild = child;
11634
+ return preRenderWrapper;
11635
+ }
11636
+ isPreRenderAvailable() {
11637
+ const preRenderIds = this.getPreRenderIds();
11638
+ this.preRenderWrapper = this.preRenderWrapper
11639
+ || document.getElementById(preRenderIds.wrapper);
11640
+ this.preRenderShield = this.preRenderShield
11641
+ || document.getElementById(preRenderIds.shield);
11642
+ this.preRenderChild = this.preRenderChild
11643
+ || document.getElementById(preRenderIds.child);
11644
+ return !!this.preRenderWrapper && !!this.preRenderShield
11645
+ && !!this.preRenderChild;
11646
+ }
11647
+ insertIntoDOMForPreRender(child) {
11648
+ let childNode;
11649
+ if (typeof child === 'string') {
11650
+ const divChildNode = document.createElement('div');
11651
+ divChildNode.innerHTML = child;
11652
+ childNode = divChildNode;
11653
+ }
11654
+ else {
11655
+ childNode = child;
11656
+ }
11657
+ const preRenderWrapper = this.createPreRenderWrapper(childNode);
11658
+ document.body.appendChild(preRenderWrapper);
11659
+ this.hidePreRender();
11660
+ }
11661
+ hidePreRender() {
11662
+ if (!this.isPreRenderAvailable()) {
11663
+ // if the embed component is not preRendered , nothing to hide
11664
+ console.log('No preRender found, not hiding ');
11665
+ return;
11666
+ }
11667
+ setStyleProperties(this.preRenderWrapper, {
11668
+ opacity: '0',
11669
+ pointerEvents: 'none',
11670
+ zIndex: '-1000',
11671
+ position: 'absolute ',
11672
+ top: '0',
11673
+ left: '0',
11674
+ });
11675
+ const childBoundingRect = this.preRenderChild.getBoundingClientRect();
11676
+ setStyleProperties(this.preRenderShield, {
11677
+ opacity: '0',
11678
+ pointerEvents: 'none',
11679
+ zIndex: '1',
11680
+ width: `${childBoundingRect.width}px`,
11681
+ height: `${childBoundingRect.height}px`,
11682
+ position: 'absolute',
11683
+ top: '0',
11684
+ left: '0',
11685
+ });
11686
+ }
11687
+ showPreRender() {
11688
+ if (!this.isPreRenderAvailable()) {
11689
+ // if the Embed component is nor preRendered , Render it now and
11690
+ // show it (hide is defalt behaviour)
11691
+ console.log('No preRender found, creating new ');
11692
+ this.render();
11693
+ return;
11694
+ }
11695
+ this.syncPreRenderStyle();
11696
+ removeStyleProperties(this.preRenderWrapper, ['z-index', 'opacity', 'pointer-events']);
11697
+ setStyleProperties(this.preRenderShield, { zIndex: '-1' });
11698
+ }
11699
+ syncPreRenderStyle() {
11700
+ if (!this.el) {
11701
+ throw new Error('Embed element is not defined');
11702
+ }
11703
+ const elBoundingClient = this.el.getBoundingClientRect();
11704
+ setStyleProperties(this.preRenderWrapper, {
11705
+ top: `${elBoundingClient.y}px`, left: `${elBoundingClient.x}px`, width: `${elBoundingClient.width}px`, height: `${elBoundingClient.height}px`,
11706
+ });
11707
+ }
11576
11708
  insertIntoDOM(child) {
11577
11709
  var _a;
11578
11710
  if (this.viewConfig.insertAsSibling) {
@@ -11787,6 +11919,13 @@
11787
11919
  this.isRendered = true;
11788
11920
  return this;
11789
11921
  }
11922
+ /**
11923
+ * Creates the preRender shell
11924
+ */
11925
+ preRender() {
11926
+ this.isPreRendered = true;
11927
+ return this;
11928
+ }
11790
11929
  /**
11791
11930
  * Get the Post Url Params for THOUGHTSPOT from the current
11792
11931
  * host app URL.
@@ -11868,8 +12007,10 @@
11868
12007
  let queryString = queryParams;
11869
12008
  if (!this.viewConfig.excludeRuntimeFiltersfromURL) {
11870
12009
  const runtimeFilters = this.viewConfig.runtimeFilters;
12010
+ const runtimeParameters = this.viewConfig.runtimeParameters;
12011
+ const parameterQuery = getRuntimeParameters(runtimeParameters || []);
11871
12012
  const filterQuery = getFilterQuery(runtimeFilters || []);
11872
- queryString = [filterQuery, queryParams].filter(Boolean).join('&');
12013
+ queryString = [parameterQuery, filterQuery, queryParams].filter(Boolean).join('&');
11873
12014
  }
11874
12015
  return this.getV1EmbedBasePath(queryString);
11875
12016
  }
@@ -12262,6 +12403,11 @@
12262
12403
  this.renderV1Embed(src);
12263
12404
  return this;
12264
12405
  }
12406
+ preRender() {
12407
+ super.preRender();
12408
+ this.render();
12409
+ return this;
12410
+ }
12265
12411
  navigateToLiveboard(liveboardId, vizId, activeTabId) {
12266
12412
  const path = this.getIframeSuffixSrc(liveboardId, vizId, activeTabId);
12267
12413
  this.viewConfig.liveboardId = liveboardId;
@@ -109,6 +109,7 @@ type EmbedComponent = typeof SearchEmbed | typeof AppEmbed | typeof LiveboardEmb
109
109
  * @returns {React.MutableRefObject<T extends TsEmbed>} ref
110
110
  */
111
111
  export function useEmbedRef<T extends EmbedComponent>(): React.MutableRefObject<React.ComponentRef<T>>;
112
+ export const PreRenderedLiveboardEmbed: React.ForwardRefExoticComponent<LiveboardProps & React.RefAttributes<_LiveboardEmbed>>;
112
113
 
113
114
  /**
114
115
  * Copyright (c) 2023
@@ -719,6 +720,7 @@ export declare class LiveboardEmbed extends V1Embed {
719
720
  * visualization ID and the runtime filters.
720
721
  */
721
722
  render(): LiveboardEmbed;
723
+ preRender(): LiveboardEmbed;
722
724
  navigateToLiveboard(liveboardId: string, vizId?: string, activeTabId?: string): void;
723
725
  }
724
726
  /**
@@ -1647,6 +1649,11 @@ export interface ViewConfig {
1647
1649
  * visualization, or Liveboard.
1648
1650
  */
1649
1651
  runtimeFilters?: RuntimeFilter[];
1652
+ /**
1653
+ * The list of parameter override to apply to a search answer,
1654
+ * visualization, or Liveboard.
1655
+ */
1656
+ runtimeParameters?: RuntimeParameter[];
1650
1657
  /**
1651
1658
  * The locale/language to use for the embedded view.
1652
1659
  *
@@ -1788,6 +1795,10 @@ export interface ViewConfig {
1788
1795
  * @version SDK: 1.27.0 | Thoughtspot: 9.8.0.cl
1789
1796
  */
1790
1797
  hiddenHomeLeftNavItems?: HomeLeftNavItem[];
1798
+ /**
1799
+ * TBD
1800
+ */
1801
+ preRenderId?: string;
1791
1802
  }
1792
1803
  /**
1793
1804
  * MessagePayload: Embed event payload: message type, data and status (start/end)
@@ -4538,6 +4549,20 @@ export declare class TsEmbed {
4538
4549
  * @param frameOptions
4539
4550
  */
4540
4551
  protected renderIFrame(url: string): Promise<any>;
4552
+ getPreRenderIds(): {
4553
+ wrapper: string;
4554
+ shield: string;
4555
+ child: string;
4556
+ };
4557
+ protected createPreRenderWrapper(child: HTMLElement): HTMLDivElement;
4558
+ protected preRenderWrapper: HTMLElement;
4559
+ protected preRenderShield: HTMLElement;
4560
+ protected preRenderChild: HTMLElement;
4561
+ protected isPreRenderAvailable(): boolean;
4562
+ protected insertIntoDOMForPreRender(child: string | HTMLElement): void;
4563
+ hidePreRender(): void;
4564
+ showPreRender(): void;
4565
+ syncPreRenderStyle(): void;
4541
4566
  protected insertIntoDOM(child: string | Node): void;
4542
4567
  /**
4543
4568
  * Sets the height of the iframe
@@ -4634,6 +4659,10 @@ export declare class TsEmbed {
4634
4659
  * @param args
4635
4660
  */
4636
4661
  render(): TsEmbed;
4662
+ /**
4663
+ * Creates the preRender shell
4664
+ */
4665
+ preRender(): TsEmbed;
4637
4666
  /**
4638
4667
  * Get the Post Url Params for THOUGHTSPOT from the current
4639
4668
  * host app URL.
@@ -109,6 +109,7 @@ type EmbedComponent = typeof SearchEmbed | typeof AppEmbed | typeof LiveboardEmb
109
109
  * @returns {React.MutableRefObject<T extends TsEmbed>} ref
110
110
  */
111
111
  export function useEmbedRef<T extends EmbedComponent>(): React.MutableRefObject<React.ComponentRef<T>>;
112
+ export const PreRenderedLiveboardEmbed: React.ForwardRefExoticComponent<LiveboardProps & React.RefAttributes<_LiveboardEmbed>>;
112
113
 
113
114
  /**
114
115
  * @group Embed components
@@ -708,6 +709,7 @@ export declare class LiveboardEmbed extends V1Embed {
708
709
  * visualization ID and the runtime filters.
709
710
  */
710
711
  render(): LiveboardEmbed;
712
+ preRender(): LiveboardEmbed;
711
713
  navigateToLiveboard(liveboardId: string, vizId?: string, activeTabId?: string): void;
712
714
  }
713
715
  /**
@@ -1358,6 +1360,11 @@ export interface ViewConfig {
1358
1360
  * visualization, or Liveboard.
1359
1361
  */
1360
1362
  runtimeFilters?: RuntimeFilter[];
1363
+ /**
1364
+ * The list of parameter override to apply to a search answer,
1365
+ * visualization, or Liveboard.
1366
+ */
1367
+ runtimeParameters?: RuntimeParameter[];
1361
1368
  /**
1362
1369
  * The locale/language to use for the embedded view.
1363
1370
  *
@@ -1499,6 +1506,10 @@ export interface ViewConfig {
1499
1506
  * @version SDK: 1.27.0 | Thoughtspot: 9.8.0.cl
1500
1507
  */
1501
1508
  hiddenHomeLeftNavItems?: HomeLeftNavItem[];
1509
+ /**
1510
+ * TBD
1511
+ */
1512
+ preRenderId?: string;
1502
1513
  }
1503
1514
  /**
1504
1515
  * MessagePayload: Embed event payload: message type, data and status (start/end)
@@ -3908,6 +3919,20 @@ export declare class TsEmbed {
3908
3919
  * @param frameOptions
3909
3920
  */
3910
3921
  protected renderIFrame(url: string): Promise<any>;
3922
+ getPreRenderIds(): {
3923
+ wrapper: string;
3924
+ shield: string;
3925
+ child: string;
3926
+ };
3927
+ protected createPreRenderWrapper(child: HTMLElement): HTMLDivElement;
3928
+ protected preRenderWrapper: HTMLElement;
3929
+ protected preRenderShield: HTMLElement;
3930
+ protected preRenderChild: HTMLElement;
3931
+ protected isPreRenderAvailable(): boolean;
3932
+ protected insertIntoDOMForPreRender(child: string | HTMLElement): void;
3933
+ hidePreRender(): void;
3934
+ showPreRender(): void;
3935
+ syncPreRenderStyle(): void;
3911
3936
  protected insertIntoDOM(child: string | Node): void;
3912
3937
  /**
3913
3938
  * Sets the height of the iframe
@@ -4004,6 +4029,10 @@ export declare class TsEmbed {
4004
4029
  * @param args
4005
4030
  */
4006
4031
  render(): TsEmbed;
4032
+ /**
4033
+ * Creates the preRender shell
4034
+ */
4035
+ preRender(): TsEmbed;
4007
4036
  /**
4008
4037
  * Get the Post Url Params for THOUGHTSPOT from the current
4009
4038
  * host app URL.