@thoughtspot/visual-embed-sdk 1.36.3 → 1.36.4
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.
- package/cjs/package.json +1 -1
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +1 -1
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/base.d.ts +4 -0
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +27 -1
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/bodyless-conversation.d.ts.map +1 -1
- package/cjs/src/embed/bodyless-conversation.js +1 -1
- package/cjs/src/embed/bodyless-conversation.js.map +1 -1
- package/cjs/src/embed/conversation.d.ts.map +1 -1
- package/cjs/src/embed/conversation.js +1 -1
- package/cjs/src/embed/conversation.js.map +1 -1
- package/cjs/src/embed/embedConfig.d.ts.map +1 -1
- package/cjs/src/embed/embedConfig.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +2 -2
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +4 -5
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +11 -11
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/sage.d.ts.map +1 -1
- package/cjs/src/embed/sage.js +1 -1
- package/cjs/src/embed/sage.js.map +1 -1
- package/cjs/src/embed/search-bar.d.ts.map +1 -1
- package/cjs/src/embed/search-bar.js +1 -1
- package/cjs/src/embed/search-bar.js.map +1 -1
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +1 -1
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +4 -3
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +25 -16
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +71 -5
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/errors.d.ts +1 -0
- package/cjs/src/errors.d.ts.map +1 -1
- package/cjs/src/errors.js +1 -0
- package/cjs/src/errors.js.map +1 -1
- package/cjs/src/react/all-types-export.d.ts +1 -1
- package/cjs/src/react/all-types-export.d.ts.map +1 -1
- package/cjs/src/react/all-types-export.js +2 -1
- package/cjs/src/react/all-types-export.js.map +1 -1
- package/cjs/src/react/index.d.ts +16 -0
- package/cjs/src/react/index.d.ts.map +1 -1
- package/cjs/src/react/index.js +25 -2
- package/cjs/src/react/index.js.map +1 -1
- package/cjs/src/utils/with-resolvers-polyfill.d.ts +1 -0
- package/cjs/src/utils/with-resolvers-polyfill.d.ts.map +1 -0
- package/cjs/src/utils/with-resolvers-polyfill.js +12 -0
- package/cjs/src/utils/with-resolvers-polyfill.js.map +1 -0
- package/cjs/src/utils.d.ts +17 -2
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +27 -3
- package/cjs/src/utils.js.map +1 -1
- package/dist/{index-BJx3m5_V.js → index-NZYq1Tu3.js} +1 -1
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts +4 -0
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/bodyless-conversation.d.ts.map +1 -1
- package/dist/src/embed/conversation.d.ts.map +1 -1
- package/dist/src/embed/embedConfig.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +2 -2
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/sage.d.ts.map +1 -1
- package/dist/src/embed/search-bar.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +4 -3
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/dist/src/errors.d.ts +1 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/react/all-types-export.d.ts +1 -1
- package/dist/src/react/all-types-export.d.ts.map +1 -1
- package/dist/src/react/index.d.ts +16 -0
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/utils/with-resolvers-polyfill.d.ts +1 -0
- package/dist/src/utils/with-resolvers-polyfill.d.ts.map +1 -0
- package/dist/src/utils.d.ts +17 -2
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +349 -45
- package/dist/tsembed-react.js +347 -42
- package/dist/tsembed.es.js +85 -32
- package/dist/tsembed.js +84 -31
- package/dist/visual-embed-sdk-react-full.d.ts +1233 -1214
- package/dist/visual-embed-sdk-react.d.ts +668 -649
- package/dist/visual-embed-sdk.d.ts +9 -4
- package/lib/package.json +1 -1
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +1 -1
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/base.d.ts +4 -0
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +24 -1
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/bodyless-conversation.d.ts.map +1 -1
- package/lib/src/embed/bodyless-conversation.js +1 -1
- package/lib/src/embed/bodyless-conversation.js.map +1 -1
- package/lib/src/embed/conversation.d.ts.map +1 -1
- package/lib/src/embed/conversation.js +1 -1
- package/lib/src/embed/conversation.js.map +1 -1
- package/lib/src/embed/embedConfig.d.ts.map +1 -1
- package/lib/src/embed/embedConfig.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +2 -2
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +4 -5
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +11 -11
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/sage.d.ts.map +1 -1
- package/lib/src/embed/sage.js +1 -1
- package/lib/src/embed/sage.js.map +1 -1
- package/lib/src/embed/search-bar.d.ts.map +1 -1
- package/lib/src/embed/search-bar.js +1 -1
- package/lib/src/embed/search-bar.js.map +1 -1
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +1 -1
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +4 -3
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +26 -17
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +71 -5
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/errors.d.ts +1 -0
- package/lib/src/errors.d.ts.map +1 -1
- package/lib/src/errors.js +1 -0
- package/lib/src/errors.js.map +1 -1
- package/lib/src/react/all-types-export.d.ts +1 -1
- package/lib/src/react/all-types-export.d.ts.map +1 -1
- package/lib/src/react/all-types-export.js +1 -1
- package/lib/src/react/all-types-export.js.map +1 -1
- package/lib/src/react/index.d.ts +16 -0
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +23 -1
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/utils/with-resolvers-polyfill.d.ts +1 -0
- package/lib/src/utils/with-resolvers-polyfill.d.ts.map +1 -0
- package/lib/src/utils/with-resolvers-polyfill.js +12 -0
- package/lib/src/utils/with-resolvers-polyfill.js.map +1 -0
- package/lib/src/utils.d.ts +17 -2
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +25 -2
- package/lib/src/utils.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +10 -5
- package/package.json +1 -1
- package/src/embed/app.ts +2 -1
- package/src/embed/base.ts +41 -1
- package/src/embed/bodyless-conversation.ts +2 -1
- package/src/embed/conversation.ts +2 -1
- package/src/embed/embedConfig.ts +1 -1
- package/src/embed/liveboard.spec.ts +11 -11
- package/src/embed/liveboard.ts +5 -6
- package/src/embed/sage.ts +1 -2
- package/src/embed/search-bar.tsx +1 -2
- package/src/embed/search.ts +1 -2
- package/src/embed/ts-embed.spec.ts +83 -5
- package/src/embed/ts-embed.ts +33 -17
- package/src/errors.ts +1 -0
- package/src/react/all-types-export.ts +1 -0
- package/src/react/index.tsx +27 -2
- package/src/utils/with-resolvers-polyfill.ts +11 -0
- package/src/utils.ts +35 -4
package/dist/tsembed-react.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/* @thoughtspot/visual-embed-sdk version 1.36.
|
|
1
|
+
/* @thoughtspot/visual-embed-sdk version 1.36.4 */
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import React__default from 'react';
|
|
3
|
+
import React__default, { useRef } from 'react';
|
|
4
4
|
|
|
5
5
|
function _mergeNamespaces(n, m) {
|
|
6
6
|
m.forEach(function (e) {
|
|
@@ -461,13 +461,23 @@ const sdkWindowKey = '_tsEmbedSDK';
|
|
|
461
461
|
* Stores a value in the global `window` object under the `_tsEmbedSDK` namespace.
|
|
462
462
|
* @param key - The key under which the value will be stored.
|
|
463
463
|
* @param value - The value to store.
|
|
464
|
+
* @param options - Additional options.
|
|
465
|
+
* @param options.ignoreIfAlreadyExists - Does not set if value for key is set.
|
|
466
|
+
*
|
|
467
|
+
* @returns The stored value.
|
|
468
|
+
*
|
|
469
|
+
* @version SDK: 1.36.2 | ThoughtSpot: *
|
|
464
470
|
*/
|
|
465
|
-
|
|
471
|
+
function storeValueInWindow(key, value, options = {}) {
|
|
466
472
|
if (!window[sdkWindowKey]) {
|
|
467
473
|
window[sdkWindowKey] = {};
|
|
468
474
|
}
|
|
475
|
+
if (options.ignoreIfAlreadyExists && key in window[sdkWindowKey]) {
|
|
476
|
+
return window[sdkWindowKey][key];
|
|
477
|
+
}
|
|
469
478
|
window[sdkWindowKey][key] = value;
|
|
470
|
-
|
|
479
|
+
return value;
|
|
480
|
+
}
|
|
471
481
|
/**
|
|
472
482
|
* Retrieves a stored value from the global `window` object under the `_tsEmbedSDK` namespace.
|
|
473
483
|
* @param key - The key whose value needs to be retrieved.
|
|
@@ -6557,6 +6567,9 @@ const logFunctions = {
|
|
|
6557
6567
|
[LogLevel.TRACE]: console.trace,
|
|
6558
6568
|
};
|
|
6559
6569
|
let globalLogLevelOverride = LogLevel.TRACE;
|
|
6570
|
+
const setGlobalLogLevelOverride = (logLevel) => {
|
|
6571
|
+
globalLogLevelOverride = logLevel;
|
|
6572
|
+
};
|
|
6560
6573
|
const logLevelToNumber = {
|
|
6561
6574
|
[LogLevel.SILENT]: 0,
|
|
6562
6575
|
[LogLevel.ERROR]: 1,
|
|
@@ -6633,6 +6646,7 @@ const ERROR_MESSAGE = {
|
|
|
6633
6646
|
CSP_VIOLATION_ALERT: 'CSP violation detected. Please check the console errors for more details.',
|
|
6634
6647
|
CSP_FRAME_HOST_VIOLATION_LOG_MESSAGE: 'Please set up CSP correctly for the application to start working. For more information, see https://developers.thoughtspot.com/docs/security-settings#csp-viz-embed-hosts. \n If the issue persists, refer to https://developers.thoughtspot.com/docs/security-settings#csp-viz-embed-hosts',
|
|
6635
6648
|
MISSING_REPORTING_OBSERVER: 'ReportingObserver not supported',
|
|
6649
|
+
RENDER_CALLED_BEFORE_INIT: 'Looks like render was called before calling init, the render won\'t start until init is called.\nFor more info check\n1. https://developers.thoughtspot.com/docs/Function_init#_init\n2.https://developers.thoughtspot.com/docs/getting-started#initSdk',
|
|
6636
6650
|
};
|
|
6637
6651
|
|
|
6638
6652
|
const EndPoints = {
|
|
@@ -6839,7 +6853,18 @@ const configKey = 'embedConfig';
|
|
|
6839
6853
|
* @version SDK: 1.19.0 | ThoughtSpot: *
|
|
6840
6854
|
* @group Global methods
|
|
6841
6855
|
*/
|
|
6842
|
-
const getEmbedConfig = () => getValueFromWindow(configKey) || {};
|
|
6856
|
+
const getEmbedConfig = () => getValueFromWindow(configKey) || {};
|
|
6857
|
+
/**
|
|
6858
|
+
* Sets the configuration embed was initialized with.
|
|
6859
|
+
* And returns the new configuration.
|
|
6860
|
+
* @param newConfig The configuration to set.
|
|
6861
|
+
* @version SDK: 1.27.0 | ThoughtSpot: *
|
|
6862
|
+
* @group Global methods
|
|
6863
|
+
*/
|
|
6864
|
+
const setEmbedConfig = (newConfig) => {
|
|
6865
|
+
storeValueInWindow(configKey, newConfig);
|
|
6866
|
+
return getValueFromWindow(configKey);
|
|
6867
|
+
};
|
|
6843
6868
|
|
|
6844
6869
|
/**
|
|
6845
6870
|
* Fetch wrapper that adds the authentication token to the request.
|
|
@@ -7446,7 +7471,7 @@ class AnswerService {
|
|
|
7446
7471
|
async getTML() {
|
|
7447
7472
|
const { object } = await this.executeQuery(getAnswerTML, {});
|
|
7448
7473
|
const edoc = object[0].edoc;
|
|
7449
|
-
const YAML = await import('./index-
|
|
7474
|
+
const YAML = await import('./index-NZYq1Tu3.js');
|
|
7450
7475
|
const parsedDoc = YAML.parse(edoc);
|
|
7451
7476
|
return {
|
|
7452
7477
|
answer: {
|
|
@@ -13827,7 +13852,7 @@ function initMixpanel(sessionInfo) {
|
|
|
13827
13852
|
}
|
|
13828
13853
|
}
|
|
13829
13854
|
|
|
13830
|
-
createCommonjsModule(function (module) {
|
|
13855
|
+
var eventemitter3 = createCommonjsModule(function (module) {
|
|
13831
13856
|
|
|
13832
13857
|
var has = Object.prototype.hasOwnProperty
|
|
13833
13858
|
, prefix = '~';
|
|
@@ -14170,7 +14195,52 @@ var ReportType;
|
|
|
14170
14195
|
ReportType["CSP_VIOLATION"] = "csp-violation";
|
|
14171
14196
|
ReportType["DEPRECATION"] = "deprecation";
|
|
14172
14197
|
ReportType["INTERVENTION"] = "intervention";
|
|
14173
|
-
})(ReportType || (ReportType = {}));
|
|
14198
|
+
})(ReportType || (ReportType = {}));
|
|
14199
|
+
let globalObserver = null;
|
|
14200
|
+
/**
|
|
14201
|
+
* Register a global ReportingObserver to capture all unhandled errors
|
|
14202
|
+
* @param overrideExisting boolean to override existing observer
|
|
14203
|
+
* @returns ReportingObserver | null
|
|
14204
|
+
*/
|
|
14205
|
+
function registerReportingObserver(overrideExisting = false) {
|
|
14206
|
+
if (!(window.ReportingObserver)) {
|
|
14207
|
+
logger$3.warn(ERROR_MESSAGE.MISSING_REPORTING_OBSERVER);
|
|
14208
|
+
return null;
|
|
14209
|
+
}
|
|
14210
|
+
if (overrideExisting) {
|
|
14211
|
+
resetGlobalReportingObserver();
|
|
14212
|
+
}
|
|
14213
|
+
if (globalObserver) {
|
|
14214
|
+
return globalObserver;
|
|
14215
|
+
}
|
|
14216
|
+
const embedConfig = getEmbedConfig();
|
|
14217
|
+
globalObserver = new ReportingObserver((reports) => {
|
|
14218
|
+
reports.forEach((report) => {
|
|
14219
|
+
const { type, url, body } = report;
|
|
14220
|
+
const reportBody = body;
|
|
14221
|
+
const isThoughtSpotHost = url
|
|
14222
|
+
&& url.startsWith(embedConfig.thoughtSpotHost);
|
|
14223
|
+
const isFrameHostError = type === ReportType.CSP_VIOLATION
|
|
14224
|
+
&& reportBody.effectiveDirective === 'frame-ancestors';
|
|
14225
|
+
if (isThoughtSpotHost && isFrameHostError) {
|
|
14226
|
+
if (!embedConfig.suppressErrorAlerts) {
|
|
14227
|
+
alert(ERROR_MESSAGE.CSP_VIOLATION_ALERT);
|
|
14228
|
+
}
|
|
14229
|
+
logger$3.error(ERROR_MESSAGE.CSP_FRAME_HOST_VIOLATION_LOG_MESSAGE);
|
|
14230
|
+
}
|
|
14231
|
+
});
|
|
14232
|
+
}, { buffered: true });
|
|
14233
|
+
globalObserver.observe();
|
|
14234
|
+
return globalObserver;
|
|
14235
|
+
}
|
|
14236
|
+
/**
|
|
14237
|
+
* Resets the global ReportingObserver
|
|
14238
|
+
*/
|
|
14239
|
+
function resetGlobalReportingObserver() {
|
|
14240
|
+
if (globalObserver)
|
|
14241
|
+
globalObserver.disconnect();
|
|
14242
|
+
globalObserver = null;
|
|
14243
|
+
}
|
|
14174
14244
|
|
|
14175
14245
|
/**
|
|
14176
14246
|
*
|
|
@@ -14352,7 +14422,45 @@ const getSessionDetails = (sessionInfoResp) => {
|
|
|
14352
14422
|
clusterName: sessionInfoResp.configInfo.selfClusterName,
|
|
14353
14423
|
...sessionInfoResp,
|
|
14354
14424
|
};
|
|
14355
|
-
};
|
|
14425
|
+
};
|
|
14426
|
+
/**
|
|
14427
|
+
* Resets the cached session info object and forces a new fetch on the next call.
|
|
14428
|
+
* @example ```js
|
|
14429
|
+
* resetCachedSessionInfo();
|
|
14430
|
+
* const sessionInfo = await getSessionInfo();
|
|
14431
|
+
* console.log(sessionInfo);
|
|
14432
|
+
* ```
|
|
14433
|
+
* @version SDK: 1.28.3 | ThoughtSpot: *
|
|
14434
|
+
* @returns {void}
|
|
14435
|
+
*/
|
|
14436
|
+
function resetCachedSessionInfo() {
|
|
14437
|
+
sessionInfo = null;
|
|
14438
|
+
}
|
|
14439
|
+
/**
|
|
14440
|
+
* Resets the cached preauth info object and forces a new fetch on the next call.
|
|
14441
|
+
* @example ```js
|
|
14442
|
+
* resetCachedPreauthInfo();
|
|
14443
|
+
* const preauthInfo = await getPreauthInfo();
|
|
14444
|
+
* console.log(preauthInfo);
|
|
14445
|
+
* ```
|
|
14446
|
+
* @version SDK: 1.28.3 | ThoughtSpot: *
|
|
14447
|
+
* @returns {void}
|
|
14448
|
+
*/
|
|
14449
|
+
function resetCachedPreauthInfo() {
|
|
14450
|
+
preauthInfo = null;
|
|
14451
|
+
}
|
|
14452
|
+
|
|
14453
|
+
/**
|
|
14454
|
+
* This function resets all the services that are cached in the SDK.
|
|
14455
|
+
* This is to be called when the user logs out of the application and also
|
|
14456
|
+
* when init is called again.
|
|
14457
|
+
* @version SDK: 1.30.2 | ThoughtSpot: *
|
|
14458
|
+
*/
|
|
14459
|
+
function resetAllCachedServices() {
|
|
14460
|
+
resetCachedAuthToken();
|
|
14461
|
+
resetCachedSessionInfo();
|
|
14462
|
+
resetCachedPreauthInfo();
|
|
14463
|
+
}
|
|
14356
14464
|
|
|
14357
14465
|
// eslint-disable-next-line import/no-mutable-exports
|
|
14358
14466
|
let loggedInStatus = false;
|
|
@@ -14422,42 +14530,61 @@ var AuthEvent;
|
|
|
14422
14530
|
*/
|
|
14423
14531
|
AuthEvent["TRIGGER_SSO_POPUP"] = "TRIGGER_SSO_POPUP";
|
|
14424
14532
|
})(AuthEvent || (AuthEvent = {}));
|
|
14533
|
+
let authEE;
|
|
14534
|
+
/**
|
|
14535
|
+
*
|
|
14536
|
+
* @param eventEmitter
|
|
14537
|
+
*/
|
|
14538
|
+
function setAuthEE(eventEmitter) {
|
|
14539
|
+
authEE = eventEmitter;
|
|
14540
|
+
}
|
|
14425
14541
|
/**
|
|
14426
14542
|
*
|
|
14427
14543
|
*/
|
|
14428
14544
|
function notifyAuthSDKSuccess() {
|
|
14429
|
-
{
|
|
14545
|
+
if (!authEE) {
|
|
14430
14546
|
logger$3.error(ERROR_MESSAGE.SDK_NOT_INITIALIZED);
|
|
14431
14547
|
return;
|
|
14432
14548
|
}
|
|
14549
|
+
authEE.emit(AuthStatus.SDK_SUCCESS);
|
|
14433
14550
|
}
|
|
14434
14551
|
/**
|
|
14435
14552
|
*
|
|
14436
14553
|
*/
|
|
14437
14554
|
async function notifyAuthSuccess() {
|
|
14438
|
-
{
|
|
14555
|
+
if (!authEE) {
|
|
14439
14556
|
logger$3.error(ERROR_MESSAGE.SDK_NOT_INITIALIZED);
|
|
14440
14557
|
return;
|
|
14441
14558
|
}
|
|
14559
|
+
try {
|
|
14560
|
+
getPreauthInfo();
|
|
14561
|
+
const sessionInfo = await getSessionInfo();
|
|
14562
|
+
authEE.emit(AuthStatus.SUCCESS, sessionInfo);
|
|
14563
|
+
}
|
|
14564
|
+
catch (e) {
|
|
14565
|
+
logger$3.error(ERROR_MESSAGE.SESSION_INFO_FAILED);
|
|
14566
|
+
}
|
|
14442
14567
|
}
|
|
14443
14568
|
/**
|
|
14444
14569
|
*
|
|
14445
14570
|
* @param failureType
|
|
14446
14571
|
*/
|
|
14447
14572
|
function notifyAuthFailure(failureType) {
|
|
14448
|
-
{
|
|
14573
|
+
if (!authEE) {
|
|
14449
14574
|
logger$3.error(ERROR_MESSAGE.SDK_NOT_INITIALIZED);
|
|
14450
14575
|
return;
|
|
14451
14576
|
}
|
|
14577
|
+
authEE.emit(AuthStatus.FAILURE, failureType);
|
|
14452
14578
|
}
|
|
14453
14579
|
/**
|
|
14454
14580
|
*
|
|
14455
14581
|
*/
|
|
14456
14582
|
function notifyLogout() {
|
|
14457
|
-
{
|
|
14583
|
+
if (!authEE) {
|
|
14458
14584
|
logger$3.error(ERROR_MESSAGE.SDK_NOT_INITIALIZED);
|
|
14459
14585
|
return;
|
|
14460
14586
|
}
|
|
14587
|
+
authEE.emit(AuthStatus.LOGOUT);
|
|
14461
14588
|
}
|
|
14462
14589
|
/**
|
|
14463
14590
|
* Check if we are logged into the ThoughtSpot cluster
|
|
@@ -14618,6 +14745,7 @@ async function samlPopupFlow(ssoURL, triggerContainer, triggerText) {
|
|
|
14618
14745
|
samlAuthWindow.focus();
|
|
14619
14746
|
}
|
|
14620
14747
|
};
|
|
14748
|
+
authEE === null || authEE === void 0 ? void 0 : authEE.emit(AuthStatus.WAITING_FOR_POPUP);
|
|
14621
14749
|
const containerEl = getDOMNode(triggerContainer);
|
|
14622
14750
|
if (containerEl) {
|
|
14623
14751
|
containerEl.innerHTML = '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
|
|
@@ -14633,6 +14761,7 @@ async function samlPopupFlow(ssoURL, triggerContainer, triggerText) {
|
|
|
14633
14761
|
}
|
|
14634
14762
|
});
|
|
14635
14763
|
});
|
|
14764
|
+
authEE === null || authEE === void 0 ? void 0 : authEE.once(AuthEvent.TRIGGER_SSO_POPUP, openPopup);
|
|
14636
14765
|
return samlCompletionPromise;
|
|
14637
14766
|
}
|
|
14638
14767
|
/**
|
|
@@ -14716,6 +14845,18 @@ const authenticate = async (embedConfig) => {
|
|
|
14716
14845
|
}
|
|
14717
14846
|
};
|
|
14718
14847
|
|
|
14848
|
+
if (typeof Promise.withResolvers === 'undefined') {
|
|
14849
|
+
Promise.withResolvers = () => {
|
|
14850
|
+
let resolve;
|
|
14851
|
+
let reject;
|
|
14852
|
+
const promise = new Promise((res, rej) => {
|
|
14853
|
+
resolve = res;
|
|
14854
|
+
reject = rej;
|
|
14855
|
+
});
|
|
14856
|
+
return { promise, resolve, reject };
|
|
14857
|
+
};
|
|
14858
|
+
}
|
|
14859
|
+
|
|
14719
14860
|
/* eslint-disable camelcase */
|
|
14720
14861
|
/* eslint-disable import/no-mutable-exports */
|
|
14721
14862
|
/**
|
|
@@ -14725,12 +14866,12 @@ const authenticate = async (embedConfig) => {
|
|
|
14725
14866
|
* @summary Base classes
|
|
14726
14867
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
14727
14868
|
*/
|
|
14728
|
-
|
|
14869
|
+
const CONFIG_DEFAULTS = {
|
|
14729
14870
|
loginFailedMessage: 'Not logged in',
|
|
14730
14871
|
authTriggerText: 'Authorize',
|
|
14731
14872
|
authType: AuthType.None,
|
|
14732
14873
|
logLevel: LogLevel.ERROR,
|
|
14733
|
-
}
|
|
14874
|
+
};
|
|
14734
14875
|
let authPromise;
|
|
14735
14876
|
const getAuthPromise = () => authPromise;
|
|
14736
14877
|
/**
|
|
@@ -14752,12 +14893,146 @@ const handleAuth = () => {
|
|
|
14752
14893
|
});
|
|
14753
14894
|
return authPromise;
|
|
14754
14895
|
};
|
|
14755
|
-
|
|
14896
|
+
const hostUrlToFeatureUrl = {
|
|
14756
14897
|
[PrefetchFeatures.SearchEmbed]: (url, flags) => `${url}v2/?${flags}#/embed/answer`,
|
|
14757
14898
|
[PrefetchFeatures.LiveboardEmbed]: (url, flags) => `${url}?${flags}`,
|
|
14758
14899
|
[PrefetchFeatures.FullApp]: (url, flags) => `${url}?${flags}`,
|
|
14759
14900
|
[PrefetchFeatures.VizEmbed]: (url, flags) => `${url}?${flags}`,
|
|
14760
|
-
}
|
|
14901
|
+
};
|
|
14902
|
+
/**
|
|
14903
|
+
* Prefetches static resources from the specified URL. Web browsers can then cache the
|
|
14904
|
+
* prefetched resources and serve them from the user's local disk to provide faster access
|
|
14905
|
+
* to your app.
|
|
14906
|
+
* @param url The URL provided for prefetch
|
|
14907
|
+
* @param prefetchFeatures Specify features which needs to be prefetched.
|
|
14908
|
+
* @param additionalFlags This can be used to add any URL flag.
|
|
14909
|
+
* @version SDK: 1.4.0 | ThoughtSpot: ts7.sep.cl, 7.2.1
|
|
14910
|
+
* @group Global methods
|
|
14911
|
+
*/
|
|
14912
|
+
const prefetch = (url, prefetchFeatures, additionalFlags) => {
|
|
14913
|
+
var _a;
|
|
14914
|
+
if (url === '') {
|
|
14915
|
+
// eslint-disable-next-line no-console
|
|
14916
|
+
logger$3.warn('The prefetch method does not have a valid URL');
|
|
14917
|
+
}
|
|
14918
|
+
else {
|
|
14919
|
+
const features = [PrefetchFeatures.FullApp];
|
|
14920
|
+
let hostUrl = url || getEmbedConfig().thoughtSpotHost;
|
|
14921
|
+
const prefetchFlags = {
|
|
14922
|
+
[Param.EmbedApp]: true,
|
|
14923
|
+
...(_a = getEmbedConfig()) === null || _a === void 0 ? void 0 : _a.additionalFlags,
|
|
14924
|
+
...additionalFlags,
|
|
14925
|
+
};
|
|
14926
|
+
hostUrl = hostUrl[hostUrl.length - 1] === '/' ? hostUrl : `${hostUrl}/`;
|
|
14927
|
+
Array.from(new Set(features
|
|
14928
|
+
.map((feature) => hostUrlToFeatureUrl[feature](hostUrl, getQueryParamString(prefetchFlags)))))
|
|
14929
|
+
.forEach((prefetchUrl, index) => {
|
|
14930
|
+
const iFrame = document.createElement('iframe');
|
|
14931
|
+
iFrame.src = prefetchUrl;
|
|
14932
|
+
iFrame.style.width = '0';
|
|
14933
|
+
iFrame.style.height = '0';
|
|
14934
|
+
iFrame.style.border = '0';
|
|
14935
|
+
iFrame.classList.add('prefetchIframe');
|
|
14936
|
+
iFrame.classList.add(`prefetchIframeNum-${index}`);
|
|
14937
|
+
document.body.appendChild(iFrame);
|
|
14938
|
+
});
|
|
14939
|
+
}
|
|
14940
|
+
};
|
|
14941
|
+
/**
|
|
14942
|
+
*
|
|
14943
|
+
* @param embedConfig
|
|
14944
|
+
*/
|
|
14945
|
+
function sanity(embedConfig) {
|
|
14946
|
+
if (embedConfig.thoughtSpotHost === undefined) {
|
|
14947
|
+
throw new Error('ThoughtSpot host not provided');
|
|
14948
|
+
}
|
|
14949
|
+
if (embedConfig.authType === AuthType.TrustedAuthToken) {
|
|
14950
|
+
if (!embedConfig.authEndpoint && typeof embedConfig.getAuthToken !== 'function') {
|
|
14951
|
+
throw new Error('Trusted auth should provide either authEndpoint or getAuthToken');
|
|
14952
|
+
}
|
|
14953
|
+
}
|
|
14954
|
+
}
|
|
14955
|
+
/**
|
|
14956
|
+
*
|
|
14957
|
+
* @param embedConfig
|
|
14958
|
+
*/
|
|
14959
|
+
function backwardCompat(embedConfig) {
|
|
14960
|
+
const newConfig = { ...embedConfig };
|
|
14961
|
+
if (embedConfig.noRedirect !== undefined && embedConfig.inPopup === undefined) {
|
|
14962
|
+
newConfig.inPopup = embedConfig.noRedirect;
|
|
14963
|
+
}
|
|
14964
|
+
return newConfig;
|
|
14965
|
+
}
|
|
14966
|
+
const initFlagKey = 'initFlagKey';
|
|
14967
|
+
const createAndSetInitPromise = () => {
|
|
14968
|
+
const { promise: initPromise, resolve: initPromiseResolve,
|
|
14969
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
14970
|
+
// @ts-ignore
|
|
14971
|
+
} = Promise.withResolvers();
|
|
14972
|
+
const initFlagStore = {
|
|
14973
|
+
initPromise,
|
|
14974
|
+
isInitCalled: false,
|
|
14975
|
+
initPromiseResolve,
|
|
14976
|
+
};
|
|
14977
|
+
storeValueInWindow(initFlagKey, initFlagStore, {
|
|
14978
|
+
// In case of diff imports the promise might be already set
|
|
14979
|
+
ignoreIfAlreadyExists: true,
|
|
14980
|
+
});
|
|
14981
|
+
};
|
|
14982
|
+
createAndSetInitPromise();
|
|
14983
|
+
const getInitPromise = () => { var _a; return (_a = getValueFromWindow(initFlagKey)) === null || _a === void 0 ? void 0 : _a.initPromise; };
|
|
14984
|
+
const getIsInitCalled = () => { var _a; return !!((_a = getValueFromWindow(initFlagKey)) === null || _a === void 0 ? void 0 : _a.isInitCalled); };
|
|
14985
|
+
/**
|
|
14986
|
+
* Initializes the Visual Embed SDK globally and perform
|
|
14987
|
+
* authentication if applicable. This function needs to be called before any ThoughtSpot
|
|
14988
|
+
* component like Liveboard etc can be embedded. But need not wait for AuthEvent.SUCCESS
|
|
14989
|
+
* to actually embed. That is handled internally.
|
|
14990
|
+
* @param embedConfig The configuration object containing ThoughtSpot host,
|
|
14991
|
+
* authentication mechanism and so on.
|
|
14992
|
+
* @example
|
|
14993
|
+
* ```js
|
|
14994
|
+
* const authStatus = init({
|
|
14995
|
+
* thoughtSpotHost: 'https://my.thoughtspot.cloud',
|
|
14996
|
+
* authType: AuthType.None,
|
|
14997
|
+
* });
|
|
14998
|
+
* authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
|
|
14999
|
+
* ```
|
|
15000
|
+
* @returns {@link AuthEventEmitter} event emitter which emits events on authentication success,
|
|
15001
|
+
* failure and logout. See {@link AuthStatus}
|
|
15002
|
+
* @version SDK: 1.0.0 | ThoughtSpot ts7.april.cl, 7.2.1
|
|
15003
|
+
* @group Authentication / Init
|
|
15004
|
+
*/
|
|
15005
|
+
const init = (embedConfig) => {
|
|
15006
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
15007
|
+
sanity(embedConfig);
|
|
15008
|
+
resetAllCachedServices();
|
|
15009
|
+
embedConfig = setEmbedConfig(backwardCompat({
|
|
15010
|
+
...CONFIG_DEFAULTS,
|
|
15011
|
+
...embedConfig,
|
|
15012
|
+
thoughtSpotHost: getThoughtSpotHost(embedConfig),
|
|
15013
|
+
}));
|
|
15014
|
+
setGlobalLogLevelOverride(embedConfig.logLevel);
|
|
15015
|
+
registerReportingObserver();
|
|
15016
|
+
const authEE = new eventemitter3();
|
|
15017
|
+
setAuthEE(authEE);
|
|
15018
|
+
handleAuth();
|
|
15019
|
+
const { password, ...configToTrack } = getEmbedConfig();
|
|
15020
|
+
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
|
|
15021
|
+
...configToTrack,
|
|
15022
|
+
usedCustomizationSheet: ((_b = (_a = embedConfig.customizations) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.customCSSUrl) != null,
|
|
15023
|
+
usedCustomizationVariables: ((_e = (_d = (_c = embedConfig.customizations) === null || _c === void 0 ? void 0 : _c.style) === null || _d === void 0 ? void 0 : _d.customCSS) === null || _e === void 0 ? void 0 : _e.variables) != null,
|
|
15024
|
+
usedCustomizationRules: ((_h = (_g = (_f = embedConfig.customizations) === null || _f === void 0 ? void 0 : _f.style) === null || _g === void 0 ? void 0 : _g.customCSS) === null || _h === void 0 ? void 0 : _h.rules_UNSTABLE) != null,
|
|
15025
|
+
usedCustomizationStrings: !!((_k = (_j = embedConfig.customizations) === null || _j === void 0 ? void 0 : _j.content) === null || _k === void 0 ? void 0 : _k.strings),
|
|
15026
|
+
usedCustomizationIconSprite: !!((_l = embedConfig.customizations) === null || _l === void 0 ? void 0 : _l.iconSpriteUrl),
|
|
15027
|
+
});
|
|
15028
|
+
if (getEmbedConfig().callPrefetch) {
|
|
15029
|
+
prefetch(getEmbedConfig().thoughtSpotHost);
|
|
15030
|
+
}
|
|
15031
|
+
// Resolves the promise created in the initPromiseKey
|
|
15032
|
+
getValueFromWindow(initFlagKey).initPromiseResolve(authEE);
|
|
15033
|
+
getValueFromWindow(initFlagKey).isInitCalled = true;
|
|
15034
|
+
return authEE;
|
|
15035
|
+
};
|
|
14761
15036
|
/**
|
|
14762
15037
|
*
|
|
14763
15038
|
*/
|
|
@@ -14886,7 +15161,7 @@ function processEventData(type, e, thoughtSpotHost, containerEl) {
|
|
|
14886
15161
|
return e;
|
|
14887
15162
|
}
|
|
14888
15163
|
|
|
14889
|
-
var name="@thoughtspot/visual-embed-sdk";var version$1="1.36.
|
|
15164
|
+
var name="@thoughtspot/visual-embed-sdk";var version$1="1.36.4";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","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",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme --json static/typedoc/typedoc.json --disableOutputCheck","test-sdk":"jest -c jest.config.sdk.js --runInBand",test:"npm run test-sdk",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",dev:"vite -c vite.local.config.ts"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3",lodash:"^4.17.21","mixpanel-browser":"2.47.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1",yaml:"^2.5.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/lodash":"^4.17.0","@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",crypto:"^1.0.1","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","eslint-plugin-comment-length":"1.7.3","eslint-plugin-jsdoc":"^46.9.0","fs-extra":"^10.0.0","gh-pages":"6.3.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-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",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:"4.24.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",vite:"^5.3.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","embedded","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$1,description:description,module:module,main:main,types:types,files:files,exports:exports,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.es.js",limit:"31 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};
|
|
14890
15165
|
|
|
14891
15166
|
/**
|
|
14892
15167
|
* Reloads the ThoughtSpot iframe.
|
|
@@ -15195,13 +15470,6 @@ class TsEmbed {
|
|
|
15195
15470
|
}
|
|
15196
15471
|
};
|
|
15197
15472
|
this.el = getDOMNode(domSelector);
|
|
15198
|
-
// TODO: handle error
|
|
15199
|
-
this.embedConfig = getEmbedConfig();
|
|
15200
|
-
if (!this.embedConfig.authTriggerContainer && !this.embedConfig.useEventForSAMLPopup) {
|
|
15201
|
-
this.embedConfig.authTriggerContainer = domSelector;
|
|
15202
|
-
}
|
|
15203
|
-
this.thoughtSpotHost = getThoughtSpotHost(this.embedConfig);
|
|
15204
|
-
this.thoughtSpotV2Base = getV2BasePath(this.embedConfig);
|
|
15205
15473
|
this.eventHandlerMap = new Map();
|
|
15206
15474
|
this.isError = false;
|
|
15207
15475
|
this.viewConfig = {
|
|
@@ -15209,12 +15477,21 @@ class TsEmbed {
|
|
|
15209
15477
|
excludeRuntimeParametersfromURL: false,
|
|
15210
15478
|
...viewConfig,
|
|
15211
15479
|
};
|
|
15212
|
-
this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
|
|
15213
15480
|
this.registerAppInit();
|
|
15214
15481
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_EMBED_CREATE, {
|
|
15215
15482
|
...viewConfig,
|
|
15216
15483
|
});
|
|
15217
15484
|
this.hostEventClient = new HostEventClient(this.iFrame);
|
|
15485
|
+
this.isReadyForRenderPromise = getInitPromise().then(async () => {
|
|
15486
|
+
const embedConfig = getEmbedConfig();
|
|
15487
|
+
this.embedConfig = embedConfig;
|
|
15488
|
+
if (!embedConfig.authTriggerContainer && !embedConfig.useEventForSAMLPopup) {
|
|
15489
|
+
this.embedConfig.authTriggerContainer = domSelector;
|
|
15490
|
+
}
|
|
15491
|
+
this.thoughtSpotHost = getThoughtSpotHost(embedConfig);
|
|
15492
|
+
this.thoughtSpotV2Base = getV2BasePath(embedConfig);
|
|
15493
|
+
this.shouldEncodeUrlQueryParams = embedConfig.shouldEncodeUrlQueryParams;
|
|
15494
|
+
});
|
|
15218
15495
|
}
|
|
15219
15496
|
/**
|
|
15220
15497
|
* Throws error encountered during initialization.
|
|
@@ -15932,6 +16209,10 @@ class TsEmbed {
|
|
|
15932
16209
|
* @param args
|
|
15933
16210
|
*/
|
|
15934
16211
|
async render() {
|
|
16212
|
+
if (!getIsInitCalled()) {
|
|
16213
|
+
logger$3.error(ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
|
|
16214
|
+
}
|
|
16215
|
+
await this.isReadyForRenderPromise;
|
|
15935
16216
|
this.isRendered = true;
|
|
15936
16217
|
return this;
|
|
15937
16218
|
}
|
|
@@ -15939,21 +16220,20 @@ class TsEmbed {
|
|
|
15939
16220
|
return '';
|
|
15940
16221
|
}
|
|
15941
16222
|
handleRenderForPrerender() {
|
|
15942
|
-
this.render();
|
|
16223
|
+
return this.render();
|
|
15943
16224
|
}
|
|
15944
16225
|
/**
|
|
15945
16226
|
* Creates the preRender shell
|
|
15946
16227
|
* @param showPreRenderByDefault - Show the preRender after render, hidden by default
|
|
15947
16228
|
*/
|
|
15948
|
-
preRender(showPreRenderByDefault = false) {
|
|
16229
|
+
async preRender(showPreRenderByDefault = false) {
|
|
15949
16230
|
if (!this.viewConfig.preRenderId) {
|
|
15950
16231
|
logger$3.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
|
|
15951
16232
|
return this;
|
|
15952
16233
|
}
|
|
15953
16234
|
this.isPreRendered = true;
|
|
15954
16235
|
this.showPreRenderByDefault = showPreRenderByDefault;
|
|
15955
|
-
this.handleRenderForPrerender();
|
|
15956
|
-
return this;
|
|
16236
|
+
return this.handleRenderForPrerender();
|
|
15957
16237
|
}
|
|
15958
16238
|
/**
|
|
15959
16239
|
* Get the Post Url Params for THOUGHTSPOT from the current
|
|
@@ -16006,6 +16286,10 @@ class TsEmbed {
|
|
|
16006
16286
|
* @returns
|
|
16007
16287
|
*/
|
|
16008
16288
|
async prerenderGeneric() {
|
|
16289
|
+
if (!getIsInitCalled()) {
|
|
16290
|
+
logger$3.error(ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
|
|
16291
|
+
}
|
|
16292
|
+
await this.isReadyForRenderPromise;
|
|
16009
16293
|
const prerenderFrameSrc = this.getRootIframeSrc();
|
|
16010
16294
|
this.isRendered = true;
|
|
16011
16295
|
return this.renderIFrame(prerenderFrameSrc);
|
|
@@ -16019,17 +16303,16 @@ class TsEmbed {
|
|
|
16019
16303
|
* Also, synchronizes the style of the PreRender component with the embedding
|
|
16020
16304
|
* element.
|
|
16021
16305
|
*/
|
|
16022
|
-
showPreRender() {
|
|
16306
|
+
async showPreRender() {
|
|
16023
16307
|
if (!this.viewConfig.preRenderId) {
|
|
16024
16308
|
logger$3.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
|
|
16025
|
-
return;
|
|
16309
|
+
return this;
|
|
16026
16310
|
}
|
|
16027
16311
|
if (!this.isPreRenderAvailable()) {
|
|
16028
16312
|
const isAvailable = this.connectPreRendered();
|
|
16029
16313
|
if (!isAvailable) {
|
|
16030
16314
|
// if the Embed component is not preRendered , Render it now and
|
|
16031
|
-
this.preRender(true);
|
|
16032
|
-
return;
|
|
16315
|
+
return this.preRender(true);
|
|
16033
16316
|
}
|
|
16034
16317
|
this.validatePreRenderViewConfig(this.viewConfig);
|
|
16035
16318
|
}
|
|
@@ -16052,6 +16335,7 @@ class TsEmbed {
|
|
|
16052
16335
|
this.beforePrerenderVisible();
|
|
16053
16336
|
removeStyleProperties(this.preRenderWrapper, ['z-index', 'opacity', 'pointer-events']);
|
|
16054
16337
|
this.subscribeToEvents();
|
|
16338
|
+
return this;
|
|
16055
16339
|
}
|
|
16056
16340
|
/**
|
|
16057
16341
|
* Synchronizes the style properties of the PreRender component with the embedding
|
|
@@ -16237,7 +16521,7 @@ let SearchBarEmbed$1 = class SearchBarEmbed extends TsEmbed {
|
|
|
16237
16521
|
* Render the embedded ThoughtSpot search
|
|
16238
16522
|
*/
|
|
16239
16523
|
async render() {
|
|
16240
|
-
super.render();
|
|
16524
|
+
await super.render();
|
|
16241
16525
|
const src = this.getIFrameSrc();
|
|
16242
16526
|
await this.renderIFrame(src);
|
|
16243
16527
|
return this;
|
|
@@ -16324,7 +16608,7 @@ let SageEmbed$1 = class SageEmbed extends V1Embed {
|
|
|
16324
16608
|
* @returns {SageEmbed} Eureka/Sage embed
|
|
16325
16609
|
*/
|
|
16326
16610
|
async render() {
|
|
16327
|
-
super.render();
|
|
16611
|
+
await super.render();
|
|
16328
16612
|
const src = this.getIFrameSrc();
|
|
16329
16613
|
await this.renderV1Embed(src);
|
|
16330
16614
|
return this;
|
|
@@ -16496,7 +16780,7 @@ let SearchEmbed$1 = class SearchEmbed extends TsEmbed {
|
|
|
16496
16780
|
* Render the embedded ThoughtSpot search
|
|
16497
16781
|
*/
|
|
16498
16782
|
async render() {
|
|
16499
|
-
super.render();
|
|
16783
|
+
await super.render();
|
|
16500
16784
|
this.viewConfig;
|
|
16501
16785
|
const src = this.getIFrameSrc();
|
|
16502
16786
|
await this.renderIFrame(src);
|
|
@@ -16795,7 +17079,7 @@ let AppEmbed$1 = class AppEmbed extends V1Embed {
|
|
|
16795
17079
|
* to be embedded.
|
|
16796
17080
|
*/
|
|
16797
17081
|
async render() {
|
|
16798
|
-
super.render();
|
|
17082
|
+
await super.render();
|
|
16799
17083
|
const src = this.getIFrameSrc();
|
|
16800
17084
|
await this.renderV1Embed(src);
|
|
16801
17085
|
return this;
|
|
@@ -17074,12 +17358,11 @@ let LiveboardEmbed$1 = class LiveboardEmbed extends V1Embed {
|
|
|
17074
17358
|
this.navigateToLiveboard(libId);
|
|
17075
17359
|
}
|
|
17076
17360
|
}
|
|
17077
|
-
handleRenderForPrerender() {
|
|
17361
|
+
async handleRenderForPrerender() {
|
|
17078
17362
|
if (isUndefined$1(this.viewConfig.liveboardId)) {
|
|
17079
|
-
this.prerenderGeneric();
|
|
17080
|
-
return;
|
|
17363
|
+
return this.prerenderGeneric();
|
|
17081
17364
|
}
|
|
17082
|
-
super.handleRenderForPrerender();
|
|
17365
|
+
return super.handleRenderForPrerender();
|
|
17083
17366
|
}
|
|
17084
17367
|
/**
|
|
17085
17368
|
* Triggers an event to the embedded app
|
|
@@ -17104,7 +17387,7 @@ let LiveboardEmbed$1 = class LiveboardEmbed extends V1Embed {
|
|
|
17104
17387
|
* visualization ID and the runtime filters.
|
|
17105
17388
|
*/
|
|
17106
17389
|
async render() {
|
|
17107
|
-
super.render();
|
|
17390
|
+
await super.render();
|
|
17108
17391
|
const src = this.getIFrameSrc();
|
|
17109
17392
|
await this.renderV1Embed(src);
|
|
17110
17393
|
this.showPreviewLoader();
|
|
@@ -17241,7 +17524,7 @@ let ConversationEmbed$1 = class ConversationEmbed extends TsEmbed {
|
|
|
17241
17524
|
return `${this.getEmbedBasePath(query)}/embed/${path}${tsPostHashParams}`;
|
|
17242
17525
|
}
|
|
17243
17526
|
async render() {
|
|
17244
|
-
super.render();
|
|
17527
|
+
await super.render();
|
|
17245
17528
|
const src = this.getIframeSrc();
|
|
17246
17529
|
await this.renderIFrame(src);
|
|
17247
17530
|
return this;
|
|
@@ -17510,6 +17793,27 @@ const PreRenderedConversationEmbed = componentFactory(ConversationEmbed$1, true)
|
|
|
17510
17793
|
*/
|
|
17511
17794
|
function useEmbedRef() {
|
|
17512
17795
|
return React__default.useRef(null);
|
|
17796
|
+
}
|
|
17797
|
+
/**
|
|
17798
|
+
*
|
|
17799
|
+
* @param config - EmbedConfig
|
|
17800
|
+
* @returns AuthEventEmitter
|
|
17801
|
+
* @example
|
|
17802
|
+
* ```
|
|
17803
|
+
* function Component() {
|
|
17804
|
+
* const authEE = useInit({ ...initConfig });
|
|
17805
|
+
* return <LiveboardEmbed ref={ref} liveboardId={<id>} />
|
|
17806
|
+
* }
|
|
17807
|
+
* ```
|
|
17808
|
+
* @version SDK: 1.36.2 | ThoughtSpot: *
|
|
17809
|
+
*/
|
|
17810
|
+
function useInit(config) {
|
|
17811
|
+
const ref = useRef(null);
|
|
17812
|
+
useDeepCompareEffect(() => {
|
|
17813
|
+
const authEE = init(config);
|
|
17814
|
+
ref.current = authEE;
|
|
17815
|
+
}, [config]);
|
|
17816
|
+
return ref;
|
|
17513
17817
|
}
|
|
17514
17818
|
|
|
17515
|
-
export { Action, AppEmbed, ConversationEmbed, EmbedEvent, HomeLeftNavItem, HomepageModule, HostEvent, LiveboardEmbed, LogLevel, Page, PinboardEmbed, PreRenderedAppEmbed, PreRenderedConversationEmbed, PreRenderedLiveboardEmbed, PreRenderedPinboardEmbed, PreRenderedSageEmbed, PreRenderedSearchBarEmbed, PreRenderedSearchEmbed, RuntimeFilterOp, SageEmbed, SearchBarEmbed, SearchEmbed, getSessionInfo, useEmbedRef };
|
|
17819
|
+
export { Action, AppEmbed, ConversationEmbed, EmbedEvent, HomeLeftNavItem, HomepageModule, HostEvent, LiveboardEmbed, LogLevel, Page, PinboardEmbed, PreRenderedAppEmbed, PreRenderedConversationEmbed, PreRenderedLiveboardEmbed, PreRenderedPinboardEmbed, PreRenderedSageEmbed, PreRenderedSearchBarEmbed, PreRenderedSearchEmbed, RuntimeFilterOp, SageEmbed, SearchBarEmbed, SearchEmbed, getSessionInfo, useEmbedRef, useInit };
|