@thoughtspot/visual-embed-sdk 1.35.0 → 1.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/package.json +15 -3
- package/cjs/src/embed/base.native.d.ts +1 -0
- package/cjs/src/embed/base.native.d.ts.map +1 -0
- package/cjs/src/embed/base.native.js +1 -0
- package/cjs/src/embed/base.native.js.map +1 -0
- package/cjs/src/embed/hello.d.ts +2 -0
- package/cjs/src/embed/hello.d.ts.map +1 -0
- package/cjs/src/embed/hello.js +6 -0
- package/cjs/src/embed/hello.js.map +1 -0
- package/cjs/src/embed/searchEmbed-basic-auth.spec.d.ts +2 -0
- package/cjs/src/embed/searchEmbed-basic-auth.spec.d.ts.map +1 -0
- package/cjs/src/embed/searchEmbed-basic-auth.spec.js +104 -0
- package/cjs/src/embed/searchEmbed-basic-auth.spec.js.map +1 -0
- package/cjs/src/native/LiveboardEmbed.d.ts +13 -0
- package/cjs/src/native/LiveboardEmbed.d.ts.map +1 -0
- package/cjs/src/native/LiveboardEmbed.js +146 -0
- package/cjs/src/native/LiveboardEmbed.js.map +1 -0
- package/cjs/src/native/commonUtils.d.ts +20 -0
- package/cjs/src/native/commonUtils.d.ts.map +1 -0
- package/cjs/src/native/commonUtils.js +175 -0
- package/cjs/src/native/commonUtils.js.map +1 -0
- package/cjs/src/native/commonUtils.spec.d.ts +2 -0
- package/cjs/src/native/commonUtils.spec.d.ts.map +1 -0
- package/cjs/src/native/commonUtils.spec.js +127 -0
- package/cjs/src/native/commonUtils.spec.js.map +1 -0
- package/cjs/src/native/embedConfig.d.ts +10 -0
- package/cjs/src/native/embedConfig.d.ts.map +1 -0
- package/cjs/src/native/embedConfig.js +12 -0
- package/cjs/src/native/embedConfig.js.map +1 -0
- package/cjs/src/native/index.d.ts +2 -0
- package/cjs/src/native/index.d.ts.map +1 -0
- package/cjs/src/native/index.js +7 -0
- package/cjs/src/native/index.js.map +1 -0
- package/cjs/src/native/types.d.ts +10 -0
- package/cjs/src/native/types.d.ts.map +1 -0
- package/cjs/src/native/types.js +3 -0
- package/cjs/src/native/types.js.map +1 -0
- package/cjs/src/parsers/filtersToRuntimeFilters.d.ts +6 -0
- package/cjs/src/parsers/filtersToRuntimeFilters.d.ts.map +1 -0
- package/cjs/src/parsers/filtersToRuntimeFilters.js +60 -0
- package/cjs/src/parsers/filtersToRuntimeFilters.js.map +1 -0
- package/cjs/src/parsers/filtersToRuntimeFilters.spec.d.ts +2 -0
- package/cjs/src/parsers/filtersToRuntimeFilters.spec.d.ts.map +1 -0
- package/cjs/src/parsers/filtersToRuntimeFilters.spec.js +205 -0
- package/cjs/src/parsers/filtersToRuntimeFilters.spec.js.map +1 -0
- package/cjs/src/parsers/index.d.ts +2 -0
- package/cjs/src/parsers/index.d.ts.map +1 -0
- package/cjs/src/parsers/index.js +6 -0
- package/cjs/src/parsers/index.js.map +1 -0
- package/cjs/src/parsers/index.spec.d.ts +2 -0
- package/cjs/src/parsers/index.spec.d.ts.map +1 -0
- package/cjs/src/parsers/index.spec.js +9 -0
- package/cjs/src/parsers/index.spec.js.map +1 -0
- package/cjs/src/react-native/Liveboard.d.ts +1 -0
- package/cjs/src/react-native/Liveboard.d.ts.map +1 -0
- package/cjs/src/react-native/Liveboard.js +1 -0
- package/cjs/src/react-native/Liveboard.js.map +1 -0
- package/cjs/src/utils/processData.spec.js +33 -0
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/cjs/src/utils.d.ts +15 -0
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +24 -3
- package/cjs/src/utils.js.map +1 -1
- package/cjs/src/utils.spec.js +132 -0
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/{index-A4UOqx43.js → index-BXczdQc7.js} +1 -1
- package/dist/index-Bh8kjZh8.js +7370 -0
- package/dist/src/embed/hello.d.ts +2 -0
- package/dist/src/embed/hello.d.ts.map +1 -0
- package/dist/src/embed/searchEmbed-basic-auth.spec.d.ts +2 -0
- package/dist/src/embed/searchEmbed-basic-auth.spec.d.ts.map +1 -0
- package/dist/src/native/LiveboardEmbed.d.ts +13 -0
- package/dist/src/native/LiveboardEmbed.d.ts.map +1 -0
- package/dist/src/native/commonUtils.d.ts +20 -0
- package/dist/src/native/commonUtils.d.ts.map +1 -0
- package/dist/src/native/commonUtils.spec.d.ts +2 -0
- package/dist/src/native/commonUtils.spec.d.ts.map +1 -0
- package/dist/src/native/embedConfig.d.ts +10 -0
- package/dist/src/native/embedConfig.d.ts.map +1 -0
- package/dist/src/native/index.d.ts +2 -0
- package/dist/src/native/index.d.ts.map +1 -0
- package/dist/src/native/types.d.ts +10 -0
- package/dist/src/native/types.d.ts.map +1 -0
- package/dist/src/parsers/filtersToRuntimeFilters.d.ts +6 -0
- package/dist/src/parsers/filtersToRuntimeFilters.d.ts.map +1 -0
- package/dist/src/parsers/filtersToRuntimeFilters.spec.d.ts +2 -0
- package/dist/src/parsers/filtersToRuntimeFilters.spec.d.ts.map +1 -0
- package/dist/src/parsers/index.d.ts +2 -0
- package/dist/src/parsers/index.d.ts.map +1 -0
- package/dist/src/parsers/index.spec.d.ts +2 -0
- package/dist/src/parsers/index.spec.d.ts.map +1 -0
- package/dist/src/utils.d.ts +15 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-parsers.es.js +3831 -0
- package/dist/tsembed-parsers.js +3840 -0
- package/dist/tsembed-react.es.js +3 -3
- package/dist/tsembed-react.js +2 -2
- package/dist/tsembed.es.js +3 -3
- package/dist/tsembed.js +2 -2
- package/lib/package.json +15 -3
- package/lib/src/embed/base.native.d.ts +1 -0
- package/lib/src/embed/base.native.d.ts.map +1 -0
- package/lib/src/embed/base.native.js +1 -0
- package/lib/src/embed/base.native.js.map +1 -0
- package/lib/src/embed/hello.d.ts +2 -0
- package/lib/src/embed/hello.d.ts.map +1 -0
- package/lib/src/embed/hello.js +2 -0
- package/lib/src/embed/hello.js.map +1 -0
- package/lib/src/embed/searchEmbed-basic-auth.spec.d.ts +2 -0
- package/lib/src/embed/searchEmbed-basic-auth.spec.d.ts.map +1 -0
- package/lib/src/embed/searchEmbed-basic-auth.spec.js +101 -0
- package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +1 -0
- package/lib/src/native/LiveboardEmbed.d.ts +13 -0
- package/lib/src/native/LiveboardEmbed.d.ts.map +1 -0
- package/lib/src/native/LiveboardEmbed.js +141 -0
- package/lib/src/native/LiveboardEmbed.js.map +1 -0
- package/lib/src/native/commonUtils.d.ts +20 -0
- package/lib/src/native/commonUtils.d.ts.map +1 -0
- package/lib/src/native/commonUtils.js +169 -0
- package/lib/src/native/commonUtils.js.map +1 -0
- package/lib/src/native/commonUtils.spec.d.ts +2 -0
- package/lib/src/native/commonUtils.spec.d.ts.map +1 -0
- package/lib/src/native/commonUtils.spec.js +124 -0
- package/lib/src/native/commonUtils.spec.js.map +1 -0
- package/lib/src/native/embedConfig.d.ts +10 -0
- package/lib/src/native/embedConfig.d.ts.map +1 -0
- package/lib/src/native/embedConfig.js +7 -0
- package/lib/src/native/embedConfig.js.map +1 -0
- package/lib/src/native/index.d.ts +2 -0
- package/lib/src/native/index.d.ts.map +1 -0
- package/lib/src/native/index.js +2 -0
- package/lib/src/native/index.js.map +1 -0
- package/lib/src/native/types.d.ts +10 -0
- package/lib/src/native/types.d.ts.map +1 -0
- package/lib/src/native/types.js +2 -0
- package/lib/src/native/types.js.map +1 -0
- package/lib/src/parsers/filtersToRuntimeFilters.d.ts +6 -0
- package/lib/src/parsers/filtersToRuntimeFilters.d.ts.map +1 -0
- package/lib/src/parsers/filtersToRuntimeFilters.js +55 -0
- package/lib/src/parsers/filtersToRuntimeFilters.js.map +1 -0
- package/lib/src/parsers/filtersToRuntimeFilters.spec.d.ts +2 -0
- package/lib/src/parsers/filtersToRuntimeFilters.spec.d.ts.map +1 -0
- package/lib/src/parsers/filtersToRuntimeFilters.spec.js +203 -0
- package/lib/src/parsers/filtersToRuntimeFilters.spec.js.map +1 -0
- package/lib/src/parsers/index.d.ts +2 -0
- package/lib/src/parsers/index.d.ts.map +1 -0
- package/lib/src/parsers/index.js +2 -0
- package/lib/src/parsers/index.js.map +1 -0
- package/lib/src/parsers/index.spec.d.ts +2 -0
- package/lib/src/parsers/index.spec.d.ts.map +1 -0
- package/lib/src/parsers/index.spec.js +7 -0
- package/lib/src/parsers/index.spec.js.map +1 -0
- package/lib/src/react-native/Liveboard.d.ts +1 -0
- package/lib/src/react-native/Liveboard.d.ts.map +1 -0
- package/lib/src/react-native/Liveboard.js +1 -0
- package/lib/src/react-native/Liveboard.js.map +1 -0
- package/lib/src/utils/processData.spec.js +33 -0
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils.d.ts +15 -0
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +20 -2
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +133 -1
- package/lib/src/utils.spec.js.map +1 -1
- package/package.json +15 -3
- package/src/native/commonUtils.spec.tsx +161 -0
- package/src/native/commonUtils.ts +183 -0
- package/src/native/index.ts +1 -0
- package/src/native/types.ts +10 -0
- package/src/utils/processData.spec.ts +42 -0
- package/src/utils.spec.ts +147 -1
- package/src/utils.ts +25 -2
package/cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtspot/visual-embed-sdk",
|
|
3
|
-
"version": "1.35.
|
|
3
|
+
"version": "1.35.1",
|
|
4
4
|
"description": "ThoughtSpot Embed SDK",
|
|
5
5
|
"module": "lib/src/index.js",
|
|
6
6
|
"main": "dist/tsembed.js",
|
|
@@ -26,6 +26,16 @@
|
|
|
26
26
|
"import": "./lib/src/react/all-types-export.js",
|
|
27
27
|
"require": "./cjs/src/react/all-types-export.js",
|
|
28
28
|
"types": "./lib/src/react/all-types-export.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./native": {
|
|
31
|
+
"import": "./lib/src/native/index.js",
|
|
32
|
+
"require": "./cjs/src/native/index.js",
|
|
33
|
+
"types": "./lib/src/native/index.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./lib/src/native": {
|
|
36
|
+
"import": "./lib/src/native/index.js",
|
|
37
|
+
"require": "./cjs/src/native/index.js",
|
|
38
|
+
"types": "./lib/src/native/index.d.ts"
|
|
29
39
|
}
|
|
30
40
|
},
|
|
31
41
|
"typesVersions": {
|
|
@@ -76,6 +86,8 @@
|
|
|
76
86
|
"html-react-parser": "^1.4.12",
|
|
77
87
|
"lodash": "^4.17.21",
|
|
78
88
|
"mixpanel-browser": "2.47.0",
|
|
89
|
+
"react-native": "^0.76.3",
|
|
90
|
+
"react-native-webview": "^13.12.4",
|
|
79
91
|
"ts-deepmerge": "^6.0.2",
|
|
80
92
|
"tslib": "^2.5.3",
|
|
81
93
|
"use-deep-compare-effect": "^1.8.1",
|
|
@@ -112,11 +124,11 @@
|
|
|
112
124
|
"eslint-config-airbnb-base": "^14.2.0",
|
|
113
125
|
"eslint-config-prettier": "^6.15.0",
|
|
114
126
|
"eslint-import-resolver-typescript": "^2.3.0",
|
|
127
|
+
"eslint-plugin-comment-length": "1.7.3",
|
|
115
128
|
"eslint-plugin-import": "^2.22.1",
|
|
129
|
+
"eslint-plugin-jsdoc": "^46.9.0",
|
|
116
130
|
"eslint-plugin-prettier": "^3.1.4",
|
|
117
131
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
118
|
-
"eslint-plugin-comment-length": "1.7.3",
|
|
119
|
-
"eslint-plugin-jsdoc": "^46.9.0",
|
|
120
132
|
"fs-extra": "^10.0.0",
|
|
121
133
|
"gh-pages": "^3.1.0",
|
|
122
134
|
"highlight.js": "^10.6.0",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=base.native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.native.d.ts","sourceRoot":"","sources":["../../../src/embed/base.native.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=base.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.native.js","sourceRoot":"","sources":["../../../src/embed/base.native.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hello.d.ts","sourceRoot":"","sources":["../../../src/embed/hello.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,QAAO,MAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hello.js","sourceRoot":"","sources":["../../../src/embed/hello.ts"],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,GAAW,EAAE,CAAC,MAAM,CAAC;AAArC,QAAA,aAAa,iBAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchEmbed-basic-auth.spec.d.ts","sourceRoot":"","sources":["../../../src/embed/searchEmbed-basic-auth.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const search_1 = require("./search");
|
|
5
|
+
const baseInstance = tslib_1.__importStar(require("./base"));
|
|
6
|
+
const authService = tslib_1.__importStar(require("../utils/authService"));
|
|
7
|
+
const authInstance = tslib_1.__importStar(require("../auth"));
|
|
8
|
+
const config = tslib_1.__importStar(require("../config"));
|
|
9
|
+
const embedConfigInstance = tslib_1.__importStar(require("./embedConfig"));
|
|
10
|
+
const index_1 = require("../index");
|
|
11
|
+
const types_1 = require("../types");
|
|
12
|
+
const test_utils_1 = require("../test/test-utils");
|
|
13
|
+
const auth_spec_1 = require("../auth.spec");
|
|
14
|
+
const thoughtSpotHost = 'tshost';
|
|
15
|
+
(0, index_1.init)({
|
|
16
|
+
thoughtSpotHost,
|
|
17
|
+
authType: types_1.AuthType.Basic,
|
|
18
|
+
username: 'tsadmin',
|
|
19
|
+
password: 'admin',
|
|
20
|
+
});
|
|
21
|
+
describe('Search embed tests when authType is Basic', () => {
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param version
|
|
25
|
+
*/
|
|
26
|
+
function setupVersion(version) {
|
|
27
|
+
jest.spyOn(window, 'addEventListener').mockImplementation((event, handler, options) => {
|
|
28
|
+
handler({
|
|
29
|
+
data: {
|
|
30
|
+
type: 'xyz',
|
|
31
|
+
},
|
|
32
|
+
ports: [3000],
|
|
33
|
+
source: null,
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(async () => ({
|
|
37
|
+
json: () => ({
|
|
38
|
+
...auth_spec_1.mockSessionInfo,
|
|
39
|
+
releaseVersion: version,
|
|
40
|
+
}),
|
|
41
|
+
status: 200,
|
|
42
|
+
}));
|
|
43
|
+
jest.spyOn(authInstance, 'getReleaseVersion').mockReturnValue(version);
|
|
44
|
+
}
|
|
45
|
+
beforeEach(() => {
|
|
46
|
+
document.body.innerHTML = (0, test_utils_1.getDocumentBody)();
|
|
47
|
+
jest.spyOn(baseInstance, 'getAuthPromise').mockResolvedValue(true);
|
|
48
|
+
});
|
|
49
|
+
afterEach(() => {
|
|
50
|
+
jest.clearAllMocks();
|
|
51
|
+
});
|
|
52
|
+
test('when releaseVersion is empty', async () => {
|
|
53
|
+
setupVersion('');
|
|
54
|
+
const mockAlert = spyOn(window, 'alert');
|
|
55
|
+
const searchEmbed = new search_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
|
|
56
|
+
await searchEmbed.render();
|
|
57
|
+
expect(mockAlert).not.toBeCalled();
|
|
58
|
+
});
|
|
59
|
+
test("when releaseVersion is '7.0.1.cl' ", async () => {
|
|
60
|
+
setupVersion('7.0.1.cl');
|
|
61
|
+
const mockAlert = jest.spyOn(window, 'alert');
|
|
62
|
+
const searchEmbed = new search_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
|
|
63
|
+
await searchEmbed.render();
|
|
64
|
+
expect(mockAlert).not.toBeCalled();
|
|
65
|
+
});
|
|
66
|
+
test('when releaseVersion is above 8.4.0.sw', async () => {
|
|
67
|
+
setupVersion('8.4.0.sw');
|
|
68
|
+
const mockAlert = jest.spyOn(window, 'alert');
|
|
69
|
+
const searchEmbed = new search_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
|
|
70
|
+
await searchEmbed.render();
|
|
71
|
+
expect(mockAlert).not.toBeCalled();
|
|
72
|
+
});
|
|
73
|
+
test('releaseVersion is above 8.4.0.sw', async () => {
|
|
74
|
+
setupVersion('8.8.0.sw');
|
|
75
|
+
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
|
|
76
|
+
const mockAlert = jest.spyOn(window, 'alert');
|
|
77
|
+
const searchEmbed = new search_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
|
|
78
|
+
await searchEmbed.render();
|
|
79
|
+
expect(mockAlert).not.toBeCalled();
|
|
80
|
+
});
|
|
81
|
+
test('Alert should not appear when suppressSearchEmbedBetaWarning is true and releaseVersion is ts7.dec.cl', async () => {
|
|
82
|
+
setupVersion('ts7.dec.cl');
|
|
83
|
+
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
|
|
84
|
+
jest.spyOn(embedConfigInstance, 'getEmbedConfig').mockReturnValue({
|
|
85
|
+
suppressSearchEmbedBetaWarning: true,
|
|
86
|
+
});
|
|
87
|
+
const mockAlert = jest.spyOn(window, 'alert');
|
|
88
|
+
const searchEmbed = new search_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
|
|
89
|
+
await searchEmbed.render();
|
|
90
|
+
expect(mockAlert).not.toBeCalled();
|
|
91
|
+
});
|
|
92
|
+
test('Alert should not appear when suppressSearchEmbedBetaWarning is true and releaseVersion is 8.4.0.sw', async () => {
|
|
93
|
+
setupVersion('8.4.0.sw');
|
|
94
|
+
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
|
|
95
|
+
jest.spyOn(embedConfigInstance, 'getEmbedConfig').mockReturnValue({
|
|
96
|
+
suppressSearchEmbedBetaWarning: true,
|
|
97
|
+
});
|
|
98
|
+
const mockAlert = jest.spyOn(window, 'alert');
|
|
99
|
+
const searchEmbed = new search_1.SearchEmbed((0, test_utils_1.getRootEl)(), {});
|
|
100
|
+
await searchEmbed.render();
|
|
101
|
+
expect(mockAlert).not.toBeCalled();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=searchEmbed-basic-auth.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchEmbed-basic-auth.spec.js","sourceRoot":"","sources":["../../../src/embed/searchEmbed-basic-auth.spec.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,6DAAuC;AACvC,0EAAoD;AACpD,8DAAwC;AACxC,0DAAoC;AACpC,2EAAqD;AAErD,oCAAgC;AAChC,oCAAoC;AACpC,mDAAgE;AAChE,4CAA+C;AAG/C,MAAM,eAAe,GAAG,QAAQ,CAAC;AACjC,IAAA,YAAI,EAAC;IACD,eAAe;IACf,QAAQ,EAAE,gBAAQ,CAAC,KAAK;IACxB,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,OAAO;CACpB,CAAC,CAAC;AAEH,QAAQ,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACvD;;;OAGG;IACH,SAAS,YAAY,CAAC,OAAe;QACjC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,kBAAkB,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;YAClF,OAAO,CAAC;gBACJ,IAAI,EAAE;oBACF,IAAI,EAAE,KAAK;iBACd;gBACD,KAAK,EAAE,CAAC,IAAI,CAAC;gBACb,MAAM,EAAE,IAAI;aACf,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,W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
6
|
+
export declare enum Param {
|
|
7
|
+
Version = "sdkVersion"
|
|
8
|
+
}
|
|
9
|
+
export type QueryParams = {
|
|
10
|
+
[key: string]: string | boolean | number;
|
|
11
|
+
};
|
|
12
|
+
export declare const LiveboardEmbed: React.FC<LiveboardEmbedProps>;
|
|
13
|
+
//# sourceMappingURL=LiveboardEmbed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveboardEmbed.d.ts","sourceRoot":"","sources":["../../../src/native/LiveboardEmbed.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAS3D,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CACjC,CAAC;AAEF,oBAAY,KAAK;IACb,OAAO,eAAe;CACzB;AAED,MAAM,MAAM,WAAW,GAAG;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;CAC5C,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAkKxD,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiveboardEmbed = exports.Param = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
const react_native_1 = require("react-native");
|
|
7
|
+
const react_native_webview_1 = tslib_1.__importDefault(require("react-native-webview"));
|
|
8
|
+
const embedConfig_1 = require("./embedConfig");
|
|
9
|
+
const auth_spec_1 = require("src/auth.spec");
|
|
10
|
+
const package_json_1 = tslib_1.__importDefault(require("../../package.json"));
|
|
11
|
+
const utils_1 = require("src/utils");
|
|
12
|
+
const { version } = package_json_1.default;
|
|
13
|
+
var Param;
|
|
14
|
+
(function (Param) {
|
|
15
|
+
Param["Version"] = "sdkVersion";
|
|
16
|
+
})(Param = exports.Param || (exports.Param = {}));
|
|
17
|
+
const LiveboardEmbed = ({ liveboardId, getToken }) => {
|
|
18
|
+
const webViewRef = (0, react_1.useRef)(null);
|
|
19
|
+
const [embedUrl, setEmbedUrl] = (0, react_1.useState)("");
|
|
20
|
+
const [webViewLoaded, setWebViewLoaded] = (0, react_1.useState)(false);
|
|
21
|
+
const getEmbedParamsString = () => {
|
|
22
|
+
const queryparamsH = getBaseQueryParams();
|
|
23
|
+
return getQueryParamString(queryparamsH);
|
|
24
|
+
};
|
|
25
|
+
const getEmbedBasePath = (query) => {
|
|
26
|
+
let queryString = (query.startsWith('?')) ? query : `?${query}`;
|
|
27
|
+
queryString = `?base64UrlEncodedFlags=${(0, utils_1.getEncodedQueryParamsString)(queryString.substr(1))}`;
|
|
28
|
+
const basePath = [auth_spec_1.embedConfig === null || auth_spec_1.embedConfig === void 0 ? void 0 : auth_spec_1.embedConfig.host, queryString]
|
|
29
|
+
.filter((x) => x.length > 0)
|
|
30
|
+
.join('/');
|
|
31
|
+
return `${basePath}#`;
|
|
32
|
+
};
|
|
33
|
+
const getRootWebViewSrc = () => {
|
|
34
|
+
const query = getEmbedParamsString();
|
|
35
|
+
return getEmbedBasePath(query);
|
|
36
|
+
};
|
|
37
|
+
const getQueryParamString = (queryParams, shouldSerializeParamValues = false) => {
|
|
38
|
+
const qp = [];
|
|
39
|
+
const params = Object.keys(queryParams);
|
|
40
|
+
params.forEach((key) => {
|
|
41
|
+
const val = queryParams[key];
|
|
42
|
+
if (val !== undefined) {
|
|
43
|
+
const serializedValue = shouldSerializeParamValues
|
|
44
|
+
? (0, utils_1.serializeParam)(val)
|
|
45
|
+
: (0, utils_1.paramToString)(val);
|
|
46
|
+
qp.push(`${key}=${serializedValue}`);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (qp.length) {
|
|
50
|
+
return qp.join('&');
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
};
|
|
54
|
+
const getBaseQueryParams = (queryParams = {}) => {
|
|
55
|
+
var _a;
|
|
56
|
+
let hostAppUrl = ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.host) || '';
|
|
57
|
+
if (hostAppUrl.includes('localhost') || hostAppUrl.includes('127.0.0.1')) {
|
|
58
|
+
hostAppUrl = 'local-host';
|
|
59
|
+
}
|
|
60
|
+
queryParams[Param.Version] = version;
|
|
61
|
+
return queryParams;
|
|
62
|
+
};
|
|
63
|
+
const handleAppInit = async () => {
|
|
64
|
+
const authToken = await getToken();
|
|
65
|
+
const initPayload = {
|
|
66
|
+
type: "appInit",
|
|
67
|
+
data: {
|
|
68
|
+
host: auth_spec_1.embedConfig === null || auth_spec_1.embedConfig === void 0 ? void 0 : auth_spec_1.embedConfig.host,
|
|
69
|
+
authToken,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
const jsCode = `
|
|
73
|
+
window.postMessage(${JSON.stringify(initPayload)});
|
|
74
|
+
`;
|
|
75
|
+
if (webViewRef.current && webViewLoaded) {
|
|
76
|
+
webViewRef.current.injectJavaScript(jsCode);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
// Generate embed URL
|
|
80
|
+
const constructEmbedUrl = async () => {
|
|
81
|
+
const embedConfig = (0, embedConfig_1.getEmbedConfig)();
|
|
82
|
+
const host = (embedConfig === null || embedConfig === void 0 ? void 0 : embedConfig.host) || "";
|
|
83
|
+
const url = `${host}/?authType=AuthServerCookieless#/embed/liveboard/${liveboardId}`;
|
|
84
|
+
setEmbedUrl(url);
|
|
85
|
+
};
|
|
86
|
+
// Handle messages from the WebView
|
|
87
|
+
const handleOnMessage = (event) => {
|
|
88
|
+
try {
|
|
89
|
+
const message = JSON.parse(event.nativeEvent.data);
|
|
90
|
+
switch (message.type) {
|
|
91
|
+
case "AppInit":
|
|
92
|
+
handleAppInit();
|
|
93
|
+
break;
|
|
94
|
+
case "AuthExpiry" || "ThoughtspotAuthExpired":
|
|
95
|
+
handleAuthExpiry();
|
|
96
|
+
break;
|
|
97
|
+
case "CustomEvent":
|
|
98
|
+
console.log("Custom event received:", message.data);
|
|
99
|
+
break;
|
|
100
|
+
default:
|
|
101
|
+
console.warn("Unhandled message type:", message.type);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
console.error("Failed to handle message from WebView:", error);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
// Handle auth token expiry
|
|
109
|
+
const handleAuthExpiry = async () => {
|
|
110
|
+
var _a;
|
|
111
|
+
const authToken = await getToken();
|
|
112
|
+
const payload = {
|
|
113
|
+
type: "AuthExpiry",
|
|
114
|
+
data: { authToken },
|
|
115
|
+
};
|
|
116
|
+
(_a = webViewRef.current) === null || _a === void 0 ? void 0 : _a.injectJavaScript(`
|
|
117
|
+
window.postMessage(${JSON.stringify(payload)}, "*");
|
|
118
|
+
`);
|
|
119
|
+
};
|
|
120
|
+
(0, react_1.useEffect)(() => {
|
|
121
|
+
constructEmbedUrl();
|
|
122
|
+
}, []);
|
|
123
|
+
if (!embedUrl) {
|
|
124
|
+
return (react_1.default.createElement(react_native_1.View, { style: styles.loadingContainer },
|
|
125
|
+
react_1.default.createElement(react_native_1.Text, null, "Loading Liveboard...")));
|
|
126
|
+
}
|
|
127
|
+
return (react_1.default.createElement(react_native_webview_1.default, { ref: webViewRef, source: { uri: embedUrl }, style: styles.webview, onMessage: handleOnMessage, onLoadStart: () => console.log('WebView load started'), injectedJavaScriptBeforeContentLoaded: `
|
|
128
|
+
window.ReactNativeWebView = {
|
|
129
|
+
postMessage: function(data) {
|
|
130
|
+
window.postMessage(data, '*');
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
`, onLoad: () => setWebViewLoaded(true), javaScriptEnabled: true, domStorageEnabled: true, cacheEnabled: false, originWhitelist: ["*"], onHttpError: (event) => console.log("HTTP Error: ", event.nativeEvent), onError: (event) => console.error("WebView Error: ", event.nativeEvent) }));
|
|
134
|
+
};
|
|
135
|
+
exports.LiveboardEmbed = LiveboardEmbed;
|
|
136
|
+
const styles = react_native_1.StyleSheet.create({
|
|
137
|
+
webview: {
|
|
138
|
+
flex: 1,
|
|
139
|
+
},
|
|
140
|
+
loadingContainer: {
|
|
141
|
+
flex: 1,
|
|
142
|
+
justifyContent: "center",
|
|
143
|
+
alignItems: "center",
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
//# sourceMappingURL=LiveboardEmbed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveboardEmbed.js","sourceRoot":"","sources":["../../../src/native/LiveboardEmbed.tsx"],"names":[],"mappings":";;;;AAAA,uDAA2D;AAC3D,+CAAsD;AACtD,wFAAoE;AACpE,+CAA+C;AAC/C,6CAA4C;AAC5C,8EAAyC;AACzC,qCAAuF;AACvF,MAAM,EAAE,OAAO,EAAE,GAAG,sBAAO,CAAC;AAO5B,IAAY,KAEX;AAFD,WAAY,KAAK;IACb,+BAAsB,CAAA;AAC1B,CAAC,EAFW,KAAK,GAAL,aAAK,KAAL,aAAK,QAEhB;AAOM,MAAM,cAAc,GAAkC,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE;IACzF,MAAM,UAAU,GAAG,IAAA,cAAM,EAAU,IAAI,CAAC,CAAC;IACzC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAS,EAAE,CAAC,CAAC;IACrD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAAU,KAAK,CAAC,CAAC;IAEnE,MAAM,oBAAoB,GAAG,GAAG,EAAE;QAChC,MAAM,YAAY,GAAG,kBAAkB,EAAE,CAAC;QAC1C,OAAO,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAC3C,CAAC,CAAA;IACD,MAAM,gBAAgB,GAAG,CA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,CACL,8BAAC,mBAAI,IAAC,KAAK,EAAE,MAAM,CAAC,gBAAgB;YAClC,8BAAC,mBAAI,+BAA4B,CAC5B,CACR,CAAC;KACH;IAED,OAAO,CACL,8BAAC,8BAAO,IACN,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,EACzB,KAAK,EAAE,MAAM,CAAC,OAAO,EACrB,SAAS,EAAE,eAAe,EAC1B,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,EACtD,qCAAqC,EAAE;;;;;;OAMtC,EACD,MAAM,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,EACpC,iBAAiB,QACjB,iBAAiB,QACjB,YAAY,EAAE,KAAK,EACnB,eAAe,EAAE,CAAC,GAAG,CAAC,EACtB,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,WAAW,CAAC,EACtE,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,WAAW,CAAC,GACvE,CACH,CAAC;AACJ,CAAC,CAAC;AAlKW,QAAA,cAAc,kBAkKzB;AAEF,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE;QACP,IAAI,EAAE,CAAC;KACR;IACD,gBAAgB,EAAE;QAChB,IAAI,EAAE,CAAC;QACP,cAAc,EAAE,QAAQ;QACxB,UAAU,EAAE,QAAQ;KACrB;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WebViewConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* This method constructs the webview URL with given config.
|
|
4
|
+
* @param config To get the webviewURL pass the necessary config options.
|
|
5
|
+
* host: string;
|
|
6
|
+
* authType: AuthType;
|
|
7
|
+
* liveboardId: string;
|
|
8
|
+
* getAuthToken: () => Promise<string>;
|
|
9
|
+
* These four are necessary arguments.
|
|
10
|
+
* @returns The Promise for WebView URL.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getWebViewUrl: (config: WebViewConfig) => Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* setting up message handling for the message replies to TS instances.
|
|
15
|
+
* @param config The webview config
|
|
16
|
+
* @param event The message event from the WebView.
|
|
17
|
+
* @param WebViewRef Ref to use and inject javascript
|
|
18
|
+
*/
|
|
19
|
+
export declare const setupWebViewMessageHandler: (config: WebViewConfig, event: any, webViewRef: any) => Promise<void>;
|
|
20
|
+
//# sourceMappingURL=commonUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commonUtils.d.ts","sourceRoot":"","sources":["../../../src/native/commonUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,WAAkB,aAAa,KAAG,QAAQ,MAAM,CA+BzE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,WAC3B,aAAa,SACd,GAAG,cACE,GAAG,kBA2ElB,CAAC"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupWebViewMessageHandler = exports.getWebViewUrl = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const package_json_1 = tslib_1.__importDefault(require("../../package.json"));
|
|
8
|
+
const logger_1 = require("../utils/logger");
|
|
9
|
+
/**
|
|
10
|
+
* This method constructs the webview URL with given config.
|
|
11
|
+
* @param config To get the webviewURL pass the necessary config options.
|
|
12
|
+
* host: string;
|
|
13
|
+
* authType: AuthType;
|
|
14
|
+
* liveboardId: string;
|
|
15
|
+
* getAuthToken: () => Promise<string>;
|
|
16
|
+
* These four are necessary arguments.
|
|
17
|
+
* @returns The Promise for WebView URL.
|
|
18
|
+
*/
|
|
19
|
+
const getWebViewUrl = async (config) => {
|
|
20
|
+
if (typeof config.getAuthToken !== 'function') {
|
|
21
|
+
throw new Error('`getAuthToken` must be a function that returns a Promise.');
|
|
22
|
+
}
|
|
23
|
+
const authToken = await config.getAuthToken();
|
|
24
|
+
if (!authToken) {
|
|
25
|
+
throw new Error('Failed to fetch initial authentication token.');
|
|
26
|
+
}
|
|
27
|
+
const hostAppUrl = encodeURIComponent(config.host.includes('localhost')
|
|
28
|
+
|| config.host.includes('127.0.0.1')
|
|
29
|
+
|| config.host.includes('10.0.2.2')
|
|
30
|
+
? 'local-host'
|
|
31
|
+
: config.host);
|
|
32
|
+
const queryParams = {
|
|
33
|
+
[types_1.Param.EmbedApp]: true,
|
|
34
|
+
[types_1.Param.HostAppUrl]: hostAppUrl,
|
|
35
|
+
[types_1.Param.Version]: package_json_1.default.version,
|
|
36
|
+
[types_1.Param.AuthType]: config.authType,
|
|
37
|
+
[types_1.Param.livedBoardEmbed]: true,
|
|
38
|
+
[types_1.Param.EnableFlipTooltipToContextMenu]: true,
|
|
39
|
+
[types_1.Param.ContextMenuTrigger]: true,
|
|
40
|
+
};
|
|
41
|
+
const queryString = (0, utils_1.getQueryParamString)(queryParams);
|
|
42
|
+
const webViewUrl = `${config.host}/embed?${queryString}#/embed/viz/${encodeURIComponent(config.liveboardId)}`;
|
|
43
|
+
return webViewUrl;
|
|
44
|
+
};
|
|
45
|
+
exports.getWebViewUrl = getWebViewUrl;
|
|
46
|
+
/**
|
|
47
|
+
* setting up message handling for the message replies to TS instances.
|
|
48
|
+
* @param config The webview config
|
|
49
|
+
* @param event The message event from the WebView.
|
|
50
|
+
* @param WebViewRef Ref to use and inject javascript
|
|
51
|
+
*/
|
|
52
|
+
const setupWebViewMessageHandler = async (config, event, webViewRef) => {
|
|
53
|
+
const message = JSON.parse(event.nativeEvent.data);
|
|
54
|
+
const injectJavaScript = (codeSnip) => {
|
|
55
|
+
if (webViewRef === null || webViewRef === void 0 ? void 0 : webViewRef.current) {
|
|
56
|
+
webViewRef.current.injectJavaScript(codeSnip);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
logger_1.logger.error('Reference for Webview not found!!');
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const defaultHandleMessage = async () => {
|
|
63
|
+
switch (message.type) {
|
|
64
|
+
case 'appInit': {
|
|
65
|
+
try {
|
|
66
|
+
const authToken = await config.getAuthToken();
|
|
67
|
+
const initPayload = {
|
|
68
|
+
type: 'appInit',
|
|
69
|
+
data: {
|
|
70
|
+
host: config.host,
|
|
71
|
+
authToken,
|
|
72
|
+
customisations: (0, utils_1.getCustomisationsMobileEmbed)(config),
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
injectJavaScript(jsCodeToHandleInteractionsForContextMenu);
|
|
76
|
+
injectJavaScript(`window.postMessage(${JSON.stringify(initPayload)}, '*');`);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
console.error('Error handling appInit:', error);
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case 'ThoughtspotAuthExpired': {
|
|
84
|
+
try {
|
|
85
|
+
const newAuthToken = await config.getAuthToken();
|
|
86
|
+
if (newAuthToken) {
|
|
87
|
+
const authExpirePayload = {
|
|
88
|
+
type: 'ThoughtspotAuthExpired',
|
|
89
|
+
data: { authToken: newAuthToken },
|
|
90
|
+
};
|
|
91
|
+
injectJavaScript(`window.postMessage(${JSON.stringify(authExpirePayload)}, '*');`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
console.error('Error refreshing token on expiry:', error);
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
case 'ThoughtspotAuthFailure': {
|
|
100
|
+
try {
|
|
101
|
+
const newAuthToken = await config.getAuthToken();
|
|
102
|
+
if (newAuthToken) {
|
|
103
|
+
const authFailurePayload = {
|
|
104
|
+
type: 'ThoughtspotAuthFailure',
|
|
105
|
+
data: { authToken: newAuthToken },
|
|
106
|
+
};
|
|
107
|
+
injectJavaScript(`window.postMessage(${JSON.stringify(authFailurePayload)}, '*');`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
console.error('Error refreshing token on failure:', error);
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
default:
|
|
116
|
+
console.warn('Unhandled message type:', message.type);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
if (config.handleMessage) {
|
|
120
|
+
await config.handleMessage(event);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
await defaultHandleMessage();
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
exports.setupWebViewMessageHandler = setupWebViewMessageHandler;
|
|
127
|
+
const jsCodeToHandleInteractionsForContextMenu = `
|
|
128
|
+
// Disabling auofocus
|
|
129
|
+
document.querySelectorAll('input[autofocus], textarea[autofocus]').forEach(el => el.removeAttribute('autofocus'));
|
|
130
|
+
|
|
131
|
+
// adding meta tag to keep fixed viewport scalign
|
|
132
|
+
const meta = document.createElement('meta');
|
|
133
|
+
meta.name = 'viewport';
|
|
134
|
+
meta.content = 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no';
|
|
135
|
+
document.head.appendChild(meta);
|
|
136
|
+
|
|
137
|
+
// input focus problem. -> we can just force it inside our view.
|
|
138
|
+
document.addEventListener('focusin', (event) => {
|
|
139
|
+
const target = event.target;
|
|
140
|
+
|
|
141
|
+
if (
|
|
142
|
+
target.tagName === 'INPUT' ||
|
|
143
|
+
target.tagName === 'TEXTAREA'
|
|
144
|
+
) {
|
|
145
|
+
const rect = target.getBoundingClientRect();
|
|
146
|
+
if (
|
|
147
|
+
rect.top < 0 ||
|
|
148
|
+
rect.bottom > window.innerHeight ||
|
|
149
|
+
rect.left < 0 ||
|
|
150
|
+
rect.right > window.innerWidth
|
|
151
|
+
) {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
// target.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'end' });
|
|
154
|
+
const horizontalPadding = 10;
|
|
155
|
+
|
|
156
|
+
let scrollX = 0;
|
|
157
|
+
|
|
158
|
+
if (rect.left < horizontalPadding) {
|
|
159
|
+
scrollX = rect.left - horizontalPadding;
|
|
160
|
+
}
|
|
161
|
+
if (rect.right > window.innerWidth - horizontalPadding) {
|
|
162
|
+
scrollX = rect.right - window.innerWidth + horizontalPadding;
|
|
163
|
+
}
|
|
164
|
+
const scrollY = rect.top - (window.innerHeight / 2 - rect.height / 2);
|
|
165
|
+
|
|
166
|
+
window.scrollBy({
|
|
167
|
+
top: scrollY,
|
|
168
|
+
left: scrollX,
|
|
169
|
+
behavior: 'smooth',
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
`;
|
|
175
|
+
//# sourceMappingURL=commonUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commonUtils.js","sourceRoot":"","sources":["../../../src/native/commonUtils.ts"],"names":[],"mappings":";;;;AAAA,oCAA6E;AAC7E,oCAAiC;AACjC,8EAAyC;AAEzC,4CAAyC;AAEzC;;;;;;;;;GASG;AACI,MAAM,aAAa,GAAG,KAAK,EAAE,MAAqB,EAAmB,EAAE;IAC1E,IAAI,OAAO,MAAM,CAAC,YAAY,KAAK,UAAU,EAAE;QAC3C,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;KAChF;IAED,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IAC9C,IAAI,CAAC,SAAS,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;KACpE;IAED,MAAM,UAAU,GAAG,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