@thoughtspot/visual-embed-sdk 1.35.1 → 1.35.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/package.json +3 -15
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +3 -0
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +12 -0
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/utils/processData.spec.js +0 -33
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/cjs/src/utils.d.ts +0 -15
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +3 -24
- package/cjs/src/utils.js.map +1 -1
- package/cjs/src/utils.spec.js +0 -132
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/{index-BXczdQc7.js → index-BaGHDCpW.js} +1 -1
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/utils.d.ts +0 -15
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +6 -3
- package/dist/tsembed-react.js +5 -2
- package/dist/tsembed.es.js +6 -3
- package/dist/tsembed.js +5 -2
- package/lib/package.json +3 -15
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +3 -0
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +12 -0
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/utils/processData.spec.js +0 -33
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils.d.ts +0 -15
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +2 -20
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +1 -133
- package/lib/src/utils.spec.js.map +1 -1
- package/package.json +3 -15
- package/src/embed/ts-embed.spec.ts +13 -0
- package/src/embed/ts-embed.ts +3 -0
- package/src/utils/processData.spec.ts +0 -42
- package/src/utils.spec.ts +1 -147
- package/src/utils.ts +2 -25
- package/cjs/src/embed/base.native.d.ts +0 -1
- package/cjs/src/embed/base.native.d.ts.map +0 -1
- package/cjs/src/embed/base.native.js +0 -1
- package/cjs/src/embed/base.native.js.map +0 -1
- package/cjs/src/embed/hello.d.ts +0 -2
- package/cjs/src/embed/hello.d.ts.map +0 -1
- package/cjs/src/embed/hello.js +0 -6
- package/cjs/src/embed/hello.js.map +0 -1
- package/cjs/src/embed/searchEmbed-basic-auth.spec.d.ts +0 -2
- package/cjs/src/embed/searchEmbed-basic-auth.spec.d.ts.map +0 -1
- package/cjs/src/embed/searchEmbed-basic-auth.spec.js +0 -104
- package/cjs/src/embed/searchEmbed-basic-auth.spec.js.map +0 -1
- package/cjs/src/native/LiveboardEmbed.d.ts +0 -13
- package/cjs/src/native/LiveboardEmbed.d.ts.map +0 -1
- package/cjs/src/native/LiveboardEmbed.js +0 -146
- package/cjs/src/native/LiveboardEmbed.js.map +0 -1
- package/cjs/src/native/commonUtils.d.ts +0 -20
- package/cjs/src/native/commonUtils.d.ts.map +0 -1
- package/cjs/src/native/commonUtils.js +0 -175
- package/cjs/src/native/commonUtils.js.map +0 -1
- package/cjs/src/native/commonUtils.spec.d.ts +0 -2
- package/cjs/src/native/commonUtils.spec.d.ts.map +0 -1
- package/cjs/src/native/commonUtils.spec.js +0 -127
- package/cjs/src/native/commonUtils.spec.js.map +0 -1
- package/cjs/src/native/embedConfig.d.ts +0 -10
- package/cjs/src/native/embedConfig.d.ts.map +0 -1
- package/cjs/src/native/embedConfig.js +0 -12
- package/cjs/src/native/embedConfig.js.map +0 -1
- package/cjs/src/native/index.d.ts +0 -2
- package/cjs/src/native/index.d.ts.map +0 -1
- package/cjs/src/native/index.js +0 -7
- package/cjs/src/native/index.js.map +0 -1
- package/cjs/src/native/types.d.ts +0 -10
- package/cjs/src/native/types.d.ts.map +0 -1
- package/cjs/src/native/types.js +0 -3
- package/cjs/src/native/types.js.map +0 -1
- package/cjs/src/parsers/filtersToRuntimeFilters.d.ts +0 -6
- package/cjs/src/parsers/filtersToRuntimeFilters.d.ts.map +0 -1
- package/cjs/src/parsers/filtersToRuntimeFilters.js +0 -60
- package/cjs/src/parsers/filtersToRuntimeFilters.js.map +0 -1
- package/cjs/src/parsers/filtersToRuntimeFilters.spec.d.ts +0 -2
- package/cjs/src/parsers/filtersToRuntimeFilters.spec.d.ts.map +0 -1
- package/cjs/src/parsers/filtersToRuntimeFilters.spec.js +0 -205
- package/cjs/src/parsers/filtersToRuntimeFilters.spec.js.map +0 -1
- package/cjs/src/parsers/index.d.ts +0 -2
- package/cjs/src/parsers/index.d.ts.map +0 -1
- package/cjs/src/parsers/index.js +0 -6
- package/cjs/src/parsers/index.js.map +0 -1
- package/cjs/src/parsers/index.spec.d.ts +0 -2
- package/cjs/src/parsers/index.spec.d.ts.map +0 -1
- package/cjs/src/parsers/index.spec.js +0 -9
- package/cjs/src/parsers/index.spec.js.map +0 -1
- package/cjs/src/react-native/Liveboard.d.ts +0 -1
- package/cjs/src/react-native/Liveboard.d.ts.map +0 -1
- package/cjs/src/react-native/Liveboard.js +0 -1
- package/cjs/src/react-native/Liveboard.js.map +0 -1
- package/dist/index-Bh8kjZh8.js +0 -7370
- package/dist/src/embed/hello.d.ts +0 -2
- package/dist/src/embed/hello.d.ts.map +0 -1
- package/dist/src/embed/searchEmbed-basic-auth.spec.d.ts +0 -2
- package/dist/src/embed/searchEmbed-basic-auth.spec.d.ts.map +0 -1
- package/dist/src/native/LiveboardEmbed.d.ts +0 -13
- package/dist/src/native/LiveboardEmbed.d.ts.map +0 -1
- package/dist/src/native/commonUtils.d.ts +0 -20
- package/dist/src/native/commonUtils.d.ts.map +0 -1
- package/dist/src/native/commonUtils.spec.d.ts +0 -2
- package/dist/src/native/commonUtils.spec.d.ts.map +0 -1
- package/dist/src/native/embedConfig.d.ts +0 -10
- package/dist/src/native/embedConfig.d.ts.map +0 -1
- package/dist/src/native/index.d.ts +0 -2
- package/dist/src/native/index.d.ts.map +0 -1
- package/dist/src/native/types.d.ts +0 -10
- package/dist/src/native/types.d.ts.map +0 -1
- package/dist/src/parsers/filtersToRuntimeFilters.d.ts +0 -6
- package/dist/src/parsers/filtersToRuntimeFilters.d.ts.map +0 -1
- package/dist/src/parsers/filtersToRuntimeFilters.spec.d.ts +0 -2
- package/dist/src/parsers/filtersToRuntimeFilters.spec.d.ts.map +0 -1
- package/dist/src/parsers/index.d.ts +0 -2
- package/dist/src/parsers/index.d.ts.map +0 -1
- package/dist/src/parsers/index.spec.d.ts +0 -2
- package/dist/src/parsers/index.spec.d.ts.map +0 -1
- package/dist/tsembed-parsers.es.js +0 -3831
- package/dist/tsembed-parsers.js +0 -3840
- package/lib/src/embed/base.native.d.ts +0 -1
- package/lib/src/embed/base.native.d.ts.map +0 -1
- package/lib/src/embed/base.native.js +0 -1
- package/lib/src/embed/base.native.js.map +0 -1
- package/lib/src/embed/hello.d.ts +0 -2
- package/lib/src/embed/hello.d.ts.map +0 -1
- package/lib/src/embed/hello.js +0 -2
- package/lib/src/embed/hello.js.map +0 -1
- package/lib/src/embed/searchEmbed-basic-auth.spec.d.ts +0 -2
- package/lib/src/embed/searchEmbed-basic-auth.spec.d.ts.map +0 -1
- package/lib/src/embed/searchEmbed-basic-auth.spec.js +0 -101
- package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +0 -1
- package/lib/src/native/LiveboardEmbed.d.ts +0 -13
- package/lib/src/native/LiveboardEmbed.d.ts.map +0 -1
- package/lib/src/native/LiveboardEmbed.js +0 -141
- package/lib/src/native/LiveboardEmbed.js.map +0 -1
- package/lib/src/native/commonUtils.d.ts +0 -20
- package/lib/src/native/commonUtils.d.ts.map +0 -1
- package/lib/src/native/commonUtils.js +0 -169
- package/lib/src/native/commonUtils.js.map +0 -1
- package/lib/src/native/commonUtils.spec.d.ts +0 -2
- package/lib/src/native/commonUtils.spec.d.ts.map +0 -1
- package/lib/src/native/commonUtils.spec.js +0 -124
- package/lib/src/native/commonUtils.spec.js.map +0 -1
- package/lib/src/native/embedConfig.d.ts +0 -10
- package/lib/src/native/embedConfig.d.ts.map +0 -1
- package/lib/src/native/embedConfig.js +0 -7
- package/lib/src/native/embedConfig.js.map +0 -1
- package/lib/src/native/index.d.ts +0 -2
- package/lib/src/native/index.d.ts.map +0 -1
- package/lib/src/native/index.js +0 -2
- package/lib/src/native/index.js.map +0 -1
- package/lib/src/native/types.d.ts +0 -10
- package/lib/src/native/types.d.ts.map +0 -1
- package/lib/src/native/types.js +0 -2
- package/lib/src/native/types.js.map +0 -1
- package/lib/src/parsers/filtersToRuntimeFilters.d.ts +0 -6
- package/lib/src/parsers/filtersToRuntimeFilters.d.ts.map +0 -1
- package/lib/src/parsers/filtersToRuntimeFilters.js +0 -55
- package/lib/src/parsers/filtersToRuntimeFilters.js.map +0 -1
- package/lib/src/parsers/filtersToRuntimeFilters.spec.d.ts +0 -2
- package/lib/src/parsers/filtersToRuntimeFilters.spec.d.ts.map +0 -1
- package/lib/src/parsers/filtersToRuntimeFilters.spec.js +0 -203
- package/lib/src/parsers/filtersToRuntimeFilters.spec.js.map +0 -1
- package/lib/src/parsers/index.d.ts +0 -2
- package/lib/src/parsers/index.d.ts.map +0 -1
- package/lib/src/parsers/index.js +0 -2
- package/lib/src/parsers/index.js.map +0 -1
- package/lib/src/parsers/index.spec.d.ts +0 -2
- package/lib/src/parsers/index.spec.d.ts.map +0 -1
- package/lib/src/parsers/index.spec.js +0 -7
- package/lib/src/parsers/index.spec.js.map +0 -1
- package/lib/src/react-native/Liveboard.d.ts +0 -1
- package/lib/src/react-native/Liveboard.d.ts.map +0 -1
- package/lib/src/react-native/Liveboard.js +0 -1
- package/lib/src/react-native/Liveboard.js.map +0 -1
- package/src/native/commonUtils.spec.tsx +0 -161
- package/src/native/commonUtils.ts +0 -183
- package/src/native/index.ts +0 -1
- package/src/native/types.ts +0 -10
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { getCustomisationsMobileEmbed, getQueryParamString } from '../utils';
|
|
2
|
-
import { Param } from '../types';
|
|
3
|
-
import pkgInfo from '../../package.json';
|
|
4
|
-
import { WebViewConfig } from './types';
|
|
5
|
-
import { logger } from '../utils/logger';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This method constructs the webview URL with given config.
|
|
9
|
-
* @param config To get the webviewURL pass the necessary config options.
|
|
10
|
-
* host: string;
|
|
11
|
-
* authType: AuthType;
|
|
12
|
-
* liveboardId: string;
|
|
13
|
-
* getAuthToken: () => Promise<string>;
|
|
14
|
-
* These four are necessary arguments.
|
|
15
|
-
* @returns The Promise for WebView URL.
|
|
16
|
-
*/
|
|
17
|
-
export const getWebViewUrl = async (config: WebViewConfig): Promise<string> => {
|
|
18
|
-
if (typeof config.getAuthToken !== 'function') {
|
|
19
|
-
throw new Error('`getAuthToken` must be a function that returns a Promise.');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const authToken = await config.getAuthToken();
|
|
23
|
-
if (!authToken) {
|
|
24
|
-
throw new Error('Failed to fetch initial authentication token.');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const hostAppUrl = encodeURIComponent(
|
|
28
|
-
config.host.includes('localhost')
|
|
29
|
-
|| config.host.includes('127.0.0.1')
|
|
30
|
-
|| config.host.includes('10.0.2.2')
|
|
31
|
-
? 'local-host'
|
|
32
|
-
: config.host,
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const queryParams = {
|
|
36
|
-
[Param.EmbedApp]: true,
|
|
37
|
-
[Param.HostAppUrl]: hostAppUrl,
|
|
38
|
-
[Param.Version]: pkgInfo.version,
|
|
39
|
-
[Param.AuthType]: config.authType,
|
|
40
|
-
[Param.livedBoardEmbed]: true,
|
|
41
|
-
[Param.EnableFlipTooltipToContextMenu]: true,
|
|
42
|
-
[Param.ContextMenuTrigger]: true,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const queryString = getQueryParamString(queryParams);
|
|
46
|
-
const webViewUrl = `${config.host}/embed?${queryString}#/embed/viz/${encodeURIComponent(config.liveboardId)}`;
|
|
47
|
-
return webViewUrl;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* setting up message handling for the message replies to TS instances.
|
|
52
|
-
* @param config The webview config
|
|
53
|
-
* @param event The message event from the WebView.
|
|
54
|
-
* @param WebViewRef Ref to use and inject javascript
|
|
55
|
-
*/
|
|
56
|
-
export const setupWebViewMessageHandler = async (
|
|
57
|
-
config: WebViewConfig,
|
|
58
|
-
event: any,
|
|
59
|
-
webViewRef: any,
|
|
60
|
-
) => {
|
|
61
|
-
const message = JSON.parse(event.nativeEvent.data);
|
|
62
|
-
|
|
63
|
-
const injectJavaScript = (codeSnip: string) => {
|
|
64
|
-
if (webViewRef?.current) {
|
|
65
|
-
webViewRef.current.injectJavaScript(codeSnip);
|
|
66
|
-
} else {
|
|
67
|
-
logger.error('Reference for Webview not found!!');
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const defaultHandleMessage = async () => {
|
|
72
|
-
switch (message.type) {
|
|
73
|
-
case 'appInit': {
|
|
74
|
-
try {
|
|
75
|
-
const authToken = await config.getAuthToken();
|
|
76
|
-
const initPayload = {
|
|
77
|
-
type: 'appInit',
|
|
78
|
-
data: {
|
|
79
|
-
host: config.host,
|
|
80
|
-
authToken,
|
|
81
|
-
customisations: getCustomisationsMobileEmbed(config),
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
injectJavaScript(jsCodeToHandleInteractionsForContextMenu);
|
|
85
|
-
injectJavaScript(`window.postMessage(${JSON.stringify(initPayload)}, '*');`);
|
|
86
|
-
} catch (error) {
|
|
87
|
-
console.error('Error handling appInit:', error);
|
|
88
|
-
}
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
case 'ThoughtspotAuthExpired': {
|
|
93
|
-
try {
|
|
94
|
-
const newAuthToken = await config.getAuthToken();
|
|
95
|
-
if (newAuthToken) {
|
|
96
|
-
const authExpirePayload = {
|
|
97
|
-
type: 'ThoughtspotAuthExpired',
|
|
98
|
-
data: { authToken: newAuthToken },
|
|
99
|
-
};
|
|
100
|
-
injectJavaScript(`window.postMessage(${JSON.stringify(authExpirePayload)}, '*');`);
|
|
101
|
-
}
|
|
102
|
-
} catch (error) {
|
|
103
|
-
console.error('Error refreshing token on expiry:', error);
|
|
104
|
-
}
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
case 'ThoughtspotAuthFailure': {
|
|
109
|
-
try {
|
|
110
|
-
const newAuthToken = await config.getAuthToken();
|
|
111
|
-
if (newAuthToken) {
|
|
112
|
-
const authFailurePayload = {
|
|
113
|
-
type: 'ThoughtspotAuthFailure',
|
|
114
|
-
data: { authToken: newAuthToken },
|
|
115
|
-
};
|
|
116
|
-
injectJavaScript(`window.postMessage(${JSON.stringify(authFailurePayload)}, '*');`);
|
|
117
|
-
}
|
|
118
|
-
} catch (error) {
|
|
119
|
-
console.error('Error refreshing token on failure:', error);
|
|
120
|
-
}
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
default:
|
|
125
|
-
console.warn('Unhandled message type:', message.type);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
if (config.handleMessage) {
|
|
130
|
-
await config.handleMessage(event);
|
|
131
|
-
} else {
|
|
132
|
-
await defaultHandleMessage();
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const jsCodeToHandleInteractionsForContextMenu = `
|
|
137
|
-
// Disabling auofocus
|
|
138
|
-
document.querySelectorAll('input[autofocus], textarea[autofocus]').forEach(el => el.removeAttribute('autofocus'));
|
|
139
|
-
|
|
140
|
-
// adding meta tag to keep fixed viewport scalign
|
|
141
|
-
const meta = document.createElement('meta');
|
|
142
|
-
meta.name = 'viewport';
|
|
143
|
-
meta.content = 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no';
|
|
144
|
-
document.head.appendChild(meta);
|
|
145
|
-
|
|
146
|
-
// input focus problem. -> we can just force it inside our view.
|
|
147
|
-
document.addEventListener('focusin', (event) => {
|
|
148
|
-
const target = event.target;
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
target.tagName === 'INPUT' ||
|
|
152
|
-
target.tagName === 'TEXTAREA'
|
|
153
|
-
) {
|
|
154
|
-
const rect = target.getBoundingClientRect();
|
|
155
|
-
if (
|
|
156
|
-
rect.top < 0 ||
|
|
157
|
-
rect.bottom > window.innerHeight ||
|
|
158
|
-
rect.left < 0 ||
|
|
159
|
-
rect.right > window.innerWidth
|
|
160
|
-
) {
|
|
161
|
-
event.preventDefault();
|
|
162
|
-
// target.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'end' });
|
|
163
|
-
const horizontalPadding = 10;
|
|
164
|
-
|
|
165
|
-
let scrollX = 0;
|
|
166
|
-
|
|
167
|
-
if (rect.left < horizontalPadding) {
|
|
168
|
-
scrollX = rect.left - horizontalPadding;
|
|
169
|
-
}
|
|
170
|
-
if (rect.right > window.innerWidth - horizontalPadding) {
|
|
171
|
-
scrollX = rect.right - window.innerWidth + horizontalPadding;
|
|
172
|
-
}
|
|
173
|
-
const scrollY = rect.top - (window.innerHeight / 2 - rect.height / 2);
|
|
174
|
-
|
|
175
|
-
window.scrollBy({
|
|
176
|
-
top: scrollY,
|
|
177
|
-
left: scrollX,
|
|
178
|
-
behavior: 'smooth',
|
|
179
|
-
})
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
`;
|
package/src/native/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { getWebViewUrl, setupWebViewMessageHandler } from './commonUtils';
|
package/src/native/types.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AuthType, CustomisationsInterface } from 'src/types';
|
|
2
|
-
|
|
3
|
-
export interface WebViewConfig {
|
|
4
|
-
host: string;
|
|
5
|
-
authType: AuthType;
|
|
6
|
-
liveboardId: string;
|
|
7
|
-
getAuthToken: () => Promise<string>;
|
|
8
|
-
handleMessage?: (event: any) => void;
|
|
9
|
-
customizations?: CustomisationsInterface;
|
|
10
|
-
}
|