@thoughtspot/visual-embed-sdk 1.10.0-alpha.3 → 1.11.0-alpha.0
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/CHANGELOG.md +4 -0
- package/README.md +22 -3
- package/dist/src/embed/app.d.ts +4 -2
- package/dist/src/embed/ts-embed.d.ts +1 -1
- package/dist/src/types.d.ts +14 -1
- package/dist/tsembed.es.js +39 -11
- package/dist/tsembed.js +39 -11
- package/lib/package.json +1 -1
- package/lib/src/embed/app.d.ts +4 -2
- package/lib/src/embed/app.js +17 -7
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +36 -2
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/events.spec.js +30 -1
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +1 -1
- package/lib/src/embed/ts-embed.js +9 -4
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/types.d.ts +14 -1
- package/lib/src/types.js +13 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +19 -4
- package/package.json +1 -1
- package/src/embed/app.spec.ts +49 -1
- package/src/embed/app.ts +18 -6
- package/src/embed/events.spec.ts +32 -0
- package/src/embed/ts-embed.ts +9 -3
- package/src/types.ts +13 -0
- package/dist/src/embed/pinboard.d.ts +0 -91
- package/dist/src/utils/plugin.d.ts +0 -0
- package/dist/src/v1/api.d.ts +0 -19
- package/lib/src/embed/pinboard.d.ts +0 -91
- package/lib/src/embed/pinboard.js +0 -110
- package/lib/src/embed/pinboard.js.map +0 -1
- package/lib/src/utils/plugin.d.ts +0 -0
- package/lib/src/utils/plugin.js +0 -1
- package/lib/src/utils/plugin.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ This project follows Semantic Versioning.
|
|
|
7
7
|
|
|
8
8
|
### New Features
|
|
9
9
|
- Events for all actions on Search Embed
|
|
10
|
+
## 1.10.0 (04-22-2022)
|
|
11
|
+
|
|
12
|
+
- Release to support TS version 8.2.0.cl
|
|
13
|
+
- Please check the full list of changes [here](https://developers.thoughtspot.com/docs/?pageid=whats-new)
|
|
10
14
|
|
|
11
15
|
## 1.9.5 (04-06-2022)
|
|
12
16
|
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<br/>
|
|
6
6
|
|
|
7
|
-
# ThoughtSpot Visual Embed SDK [](https://coveralls.io/github/ts-blink/embed-sdk?branch=main)  [](https://www.jsdelivr.com/package/npm/@thoughtspot/visual-embed-sdk)
|
|
7
|
+
# ThoughtSpot Visual Embed SDK <br/> [](https://coveralls.io/github/ts-blink/embed-sdk?branch=main)  [](https://www.jsdelivr.com/package/npm/@thoughtspot/visual-embed-sdk) 
|
|
8
8
|
|
|
9
9
|
SDK to embed ThoughtSpot into your web apps.
|
|
10
10
|
|
|
@@ -25,6 +25,8 @@ The SDK is written in TypeScript and is also provided both as ES Module (ESM) an
|
|
|
25
25
|
```js
|
|
26
26
|
// ESM via NPM
|
|
27
27
|
import * as TsEmbedSDK from '@thoughtspot/visual-embed-sdk';
|
|
28
|
+
// OR
|
|
29
|
+
import { LiveboardEmbed } from '@thoughtspot/visual-embed-sdk';
|
|
28
30
|
|
|
29
31
|
// NPM <script>
|
|
30
32
|
<script src="https://cdn.jsdelivr.net/npm/@thoughtspot/visual-embed-sdk/dist/tsembed.js"></script>;
|
|
@@ -41,7 +43,8 @@ import {
|
|
|
41
43
|
|
|
42
44
|
## Live Playground
|
|
43
45
|
|
|
44
|
-
Visit our [code playground](https://try-everywhere.thoughtspot.cloud/v2/#/everywhere).
|
|
46
|
+
Visit our [code playground](https://try-everywhere.thoughtspot.cloud/v2/#/everywhere). <br/><br/>
|
|
47
|
+
Start a [free trial](https://www.thoughtspot.com/trial?tsref=trialtse) on your own data.
|
|
45
48
|
|
|
46
49
|
<br/>
|
|
47
50
|
|
|
@@ -132,10 +135,26 @@ const appEmbed = new AppEmbed(document.getElementById('ts-embed'), {
|
|
|
132
135
|
appEmbed.render();
|
|
133
136
|
```
|
|
134
137
|
|
|
138
|
+
### Triggering and Listening to events
|
|
139
|
+
```js
|
|
140
|
+
// NPM
|
|
141
|
+
import { LiveboardEmbed, Page, AuthType, init, EmbedEvent, HostEvent } from '@thoughtspot/visual-embed-sdk';
|
|
142
|
+
|
|
143
|
+
// .. Do init and create a liveboardEmbed object as above.
|
|
144
|
+
|
|
145
|
+
liveboardEmbed.render();
|
|
146
|
+
|
|
147
|
+
liveboardEmbed.on(EmbedEvent.LiveboardRendered, () => {
|
|
148
|
+
liveboardEmbed.trigger(HostEvent.SetVisibleVizs, ['viz1', 'viz2']);
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
135
152
|
## React Components
|
|
136
153
|
|
|
137
154
|
All the above flavors of embedding are also provided as React components for your convenience.
|
|
138
155
|
The constructor options are passed as props and the event listeners can be attached using `on<EventName>` convention.
|
|
156
|
+
<br/><br/>
|
|
157
|
+
Checkout a comprehensive working demo [here](https://codesandbox.io/s/github/ashubham/big-react-demo)
|
|
139
158
|
|
|
140
159
|
### Search Component
|
|
141
160
|
|
|
@@ -166,7 +185,7 @@ const MyComponent = ({ dataSources }) => {
|
|
|
166
185
|
};
|
|
167
186
|
```
|
|
168
187
|
|
|
169
|
-
### Triggering events on React components
|
|
188
|
+
### Triggering events on React components (> version 1.9.2)
|
|
170
189
|
|
|
171
190
|
```jsx
|
|
172
191
|
import { HostEvent } from '@thoughtspot/visual-embed-sdk';
|
package/dist/src/embed/app.d.ts
CHANGED
|
@@ -118,10 +118,12 @@ export declare class AppEmbed extends V1Embed {
|
|
|
118
118
|
/**
|
|
119
119
|
* Navigate to particular page for app embed. eg:answers/pinboards/home
|
|
120
120
|
* This is used for embedding answers, pinboards, visualizations and full application only.
|
|
121
|
-
* @param path The string, set to iframe src and navigate to new page
|
|
121
|
+
* @param path string | number The string, set to iframe src and navigate to new page
|
|
122
122
|
* eg: appEmbed.navigateToPage('pinboards')
|
|
123
|
+
* When used with `noReload` this can also be a number like 1/-1 to go forward/back.
|
|
124
|
+
* @param noReload boolean Trigger the navigation without reloading the page (version: 1.12.0 | 8.4.0.cl)
|
|
123
125
|
*/
|
|
124
|
-
navigateToPage(path: string): void;
|
|
126
|
+
navigateToPage(path: string | number, noReload?: boolean): void;
|
|
125
127
|
/**
|
|
126
128
|
* Renders the embedded application pages in the ThoughtSpot app.
|
|
127
129
|
* @param renderOptions An object containing the page ID
|
|
@@ -293,5 +293,5 @@ export declare class V1Embed extends TsEmbed {
|
|
|
293
293
|
* @param iframeSrc
|
|
294
294
|
*/
|
|
295
295
|
protected renderV1Embed(iframeSrc: string): void;
|
|
296
|
-
on(messageType: EmbedEvent, callback: MessageCallback): typeof TsEmbed.prototype;
|
|
296
|
+
on(messageType: EmbedEvent, callback: MessageCallback, options?: MessageOptions): typeof TsEmbed.prototype;
|
|
297
297
|
}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -383,6 +383,12 @@ export declare enum EmbedEvent {
|
|
|
383
383
|
* @version 1.9.1 or later
|
|
384
384
|
*/
|
|
385
385
|
LiveboardRendered = "PinboardRendered",
|
|
386
|
+
/**
|
|
387
|
+
* This can be used to register an event listener which
|
|
388
|
+
* is triggered on all events.
|
|
389
|
+
* @version SDK: 1.10.0 | ThoughtSpot: any
|
|
390
|
+
*/
|
|
391
|
+
ALL = "*",
|
|
386
392
|
/**
|
|
387
393
|
* Emitted when answer is saved in the app
|
|
388
394
|
* @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
|
|
@@ -525,7 +531,14 @@ export declare enum HostEvent {
|
|
|
525
531
|
* @param - {@link RuntimeFilter}[] an array of {@link RuntimeFilter} Types.
|
|
526
532
|
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
527
533
|
*/
|
|
528
|
-
UpdateRuntimeFilters = "UpdateRuntimeFilters"
|
|
534
|
+
UpdateRuntimeFilters = "UpdateRuntimeFilters",
|
|
535
|
+
/**
|
|
536
|
+
* Navigate to a specific page in App embed without any reload.
|
|
537
|
+
* This is the same as calling `appEmbed.navigateToPage(path, true)`
|
|
538
|
+
* @param path - the path to navigate to (can be a number[1/-1] to go forward/back)
|
|
539
|
+
* @version SDK: 1.12.0 | ThoughtSpot: 8.4.0.cl
|
|
540
|
+
*/
|
|
541
|
+
Navigate = "Navigate"
|
|
529
542
|
}
|
|
530
543
|
/**
|
|
531
544
|
* The different visual modes that the data sources panel within
|
package/dist/tsembed.es.js
CHANGED
|
@@ -357,6 +357,12 @@ var EmbedEvent;
|
|
|
357
357
|
* @version 1.9.1 or later
|
|
358
358
|
*/
|
|
359
359
|
EmbedEvent["LiveboardRendered"] = "PinboardRendered";
|
|
360
|
+
/**
|
|
361
|
+
* This can be used to register an event listener which
|
|
362
|
+
* is triggered on all events.
|
|
363
|
+
* @version SDK: 1.10.0 | ThoughtSpot: any
|
|
364
|
+
*/
|
|
365
|
+
EmbedEvent["ALL"] = "*";
|
|
360
366
|
/**
|
|
361
367
|
* Emitted when answer is saved in the app
|
|
362
368
|
* @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
|
|
@@ -502,6 +508,13 @@ var HostEvent;
|
|
|
502
508
|
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
503
509
|
*/
|
|
504
510
|
HostEvent["UpdateRuntimeFilters"] = "UpdateRuntimeFilters";
|
|
511
|
+
/**
|
|
512
|
+
* Navigate to a specific page in App embed without any reload.
|
|
513
|
+
* This is the same as calling `appEmbed.navigateToPage(path, true)`
|
|
514
|
+
* @param path - the path to navigate to (can be a number[1/-1] to go forward/back)
|
|
515
|
+
* @version SDK: 1.12.0 | ThoughtSpot: 8.4.0.cl
|
|
516
|
+
*/
|
|
517
|
+
HostEvent["Navigate"] = "Navigate";
|
|
505
518
|
})(HostEvent || (HostEvent = {}));
|
|
506
519
|
/**
|
|
507
520
|
* The different visual modes that the data sources panel within
|
|
@@ -9075,7 +9088,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
|
|
|
9075
9088
|
}
|
|
9076
9089
|
}
|
|
9077
9090
|
|
|
9078
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.
|
|
9091
|
+
var name="@thoughtspot/visual-embed-sdk";var version="1.11.0-alpha.0";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/**"];var exports={".":"./lib/src/index.js","./react":"./lib/src/react/index.js"};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs && npx istanbul-merge --out ./coverage/coverage.json ./coverage/docs/coverage-final.json ./coverage/sdk/coverage-final.json && npx istanbul report --include ./coverage/coverage.json --dir ./coverage lcov",posttest:"cat ./coverage/sdk/lcov.info | coveralls",prepublishOnly:"npm run test; npm run tsc; npm run bundle-dts; npm run build","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1","mixpanel-browser":"^2.41.0"};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","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","dts-bundle":"0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.1.0","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"4.1.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^4.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-neo-theme":"^1.1.0","typedoc-plugin-toc-group":"0.0.5",typescript:"^4.1.0","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports,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};
|
|
9079
9092
|
|
|
9080
9093
|
/**
|
|
9081
9094
|
* Copyright (c) 2022
|
|
@@ -9182,9 +9195,10 @@ class TsEmbed {
|
|
|
9182
9195
|
* will be removed for ts7.oct.cl
|
|
9183
9196
|
* @hidden
|
|
9184
9197
|
*/
|
|
9185
|
-
formatEventData(event) {
|
|
9198
|
+
formatEventData(event, eventType) {
|
|
9186
9199
|
const eventData = {
|
|
9187
9200
|
...event.data,
|
|
9201
|
+
type: eventType,
|
|
9188
9202
|
};
|
|
9189
9203
|
if (!eventData.data) {
|
|
9190
9204
|
eventData.data = event.data.payload;
|
|
@@ -9201,7 +9215,7 @@ class TsEmbed {
|
|
|
9201
9215
|
window.addEventListener('message', (event) => {
|
|
9202
9216
|
const eventType = this.getEventType(event);
|
|
9203
9217
|
const eventPort = this.getEventPort(event);
|
|
9204
|
-
const eventData = this.formatEventData(event);
|
|
9218
|
+
const eventData = this.formatEventData(event, eventType);
|
|
9205
9219
|
if (event.source === this.iFrame.contentWindow) {
|
|
9206
9220
|
this.executeCallbacks(eventType, getProcessData(eventType, eventData, this.thoughtSpotHost), eventPort);
|
|
9207
9221
|
}
|
|
@@ -9319,6 +9333,7 @@ class TsEmbed {
|
|
|
9319
9333
|
data: {
|
|
9320
9334
|
timestamp: initTimestamp,
|
|
9321
9335
|
},
|
|
9336
|
+
type: EmbedEvent.Init,
|
|
9322
9337
|
});
|
|
9323
9338
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
9324
9339
|
(_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then(() => {
|
|
@@ -9350,6 +9365,7 @@ class TsEmbed {
|
|
|
9350
9365
|
data: {
|
|
9351
9366
|
timestamp: loadTimestamp,
|
|
9352
9367
|
},
|
|
9368
|
+
type: EmbedEvent.Load,
|
|
9353
9369
|
});
|
|
9354
9370
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_IFRAME_LOAD_PERFORMANCE, {
|
|
9355
9371
|
timeTookToLoad: loadTimestamp - initTimestamp,
|
|
@@ -9389,6 +9405,8 @@ class TsEmbed {
|
|
|
9389
9405
|
*/
|
|
9390
9406
|
executeCallbacks(eventType, data, eventPort) {
|
|
9391
9407
|
const callbacks = this.eventHandlerMap.get(eventType) || [];
|
|
9408
|
+
const allHandlers = this.eventHandlerMap.get(EmbedEvent.ALL) || [];
|
|
9409
|
+
callbacks.push(...allHandlers);
|
|
9392
9410
|
const dataStatus = (data === null || data === void 0 ? void 0 : data.status) || embedEventStatus.END;
|
|
9393
9411
|
callbacks.forEach((callbackObj) => {
|
|
9394
9412
|
if ((callbackObj.options.start &&
|
|
@@ -9555,9 +9573,9 @@ class V1Embed extends TsEmbed {
|
|
|
9555
9573
|
this.renderIFrame(iframeSrc, this.viewConfig.frameParams);
|
|
9556
9574
|
}
|
|
9557
9575
|
// @override
|
|
9558
|
-
on(messageType, callback) {
|
|
9576
|
+
on(messageType, callback, options = { start: false }) {
|
|
9559
9577
|
const eventType = this.getCompatibleEventType(messageType);
|
|
9560
|
-
return super.on(eventType, callback);
|
|
9578
|
+
return super.on(eventType, callback, options);
|
|
9561
9579
|
}
|
|
9562
9580
|
}
|
|
9563
9581
|
|
|
@@ -9688,19 +9706,29 @@ class AppEmbed extends V1Embed {
|
|
|
9688
9706
|
/**
|
|
9689
9707
|
* Navigate to particular page for app embed. eg:answers/pinboards/home
|
|
9690
9708
|
* This is used for embedding answers, pinboards, visualizations and full application only.
|
|
9691
|
-
* @param path The string, set to iframe src and navigate to new page
|
|
9709
|
+
* @param path string | number The string, set to iframe src and navigate to new page
|
|
9692
9710
|
* eg: appEmbed.navigateToPage('pinboards')
|
|
9711
|
+
* When used with `noReload` this can also be a number like 1/-1 to go forward/back.
|
|
9712
|
+
* @param noReload boolean Trigger the navigation without reloading the page (version: 1.12.0 | 8.4.0.cl)
|
|
9693
9713
|
*/
|
|
9694
|
-
navigateToPage(path) {
|
|
9695
|
-
if (this.iFrame) {
|
|
9714
|
+
navigateToPage(path, noReload = false) {
|
|
9715
|
+
if (!this.iFrame) {
|
|
9716
|
+
console.log('Please call render before invoking this method');
|
|
9717
|
+
return;
|
|
9718
|
+
}
|
|
9719
|
+
if (noReload) {
|
|
9720
|
+
this.trigger(HostEvent.Navigate, path);
|
|
9721
|
+
}
|
|
9722
|
+
else {
|
|
9723
|
+
if (typeof path !== 'string') {
|
|
9724
|
+
console.warn('Path can only by a string when triggered without noReload');
|
|
9725
|
+
return;
|
|
9726
|
+
}
|
|
9696
9727
|
const iframeSrc = this.iFrame.src;
|
|
9697
9728
|
const embedPath = '#/embed';
|
|
9698
9729
|
const currentPath = iframeSrc.includes(embedPath) ? embedPath : '#';
|
|
9699
9730
|
this.iFrame.src = `${iframeSrc.split(currentPath)[0]}${currentPath}/${path.replace(/^\/?#?\//, '')}`;
|
|
9700
9731
|
}
|
|
9701
|
-
else {
|
|
9702
|
-
console.log('Please call render before invoking this method');
|
|
9703
|
-
}
|
|
9704
9732
|
}
|
|
9705
9733
|
/**
|
|
9706
9734
|
* Renders the embedded application pages in the ThoughtSpot app.
|
package/dist/tsembed.js
CHANGED
|
@@ -347,6 +347,12 @@
|
|
|
347
347
|
* @version 1.9.1 or later
|
|
348
348
|
*/
|
|
349
349
|
EmbedEvent["LiveboardRendered"] = "PinboardRendered";
|
|
350
|
+
/**
|
|
351
|
+
* This can be used to register an event listener which
|
|
352
|
+
* is triggered on all events.
|
|
353
|
+
* @version SDK: 1.10.0 | ThoughtSpot: any
|
|
354
|
+
*/
|
|
355
|
+
EmbedEvent["ALL"] = "*";
|
|
350
356
|
/**
|
|
351
357
|
* Emitted when answer is saved in the app
|
|
352
358
|
* @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
|
|
@@ -483,6 +489,13 @@
|
|
|
483
489
|
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
484
490
|
*/
|
|
485
491
|
HostEvent["UpdateRuntimeFilters"] = "UpdateRuntimeFilters";
|
|
492
|
+
/**
|
|
493
|
+
* Navigate to a specific page in App embed without any reload.
|
|
494
|
+
* This is the same as calling `appEmbed.navigateToPage(path, true)`
|
|
495
|
+
* @param path - the path to navigate to (can be a number[1/-1] to go forward/back)
|
|
496
|
+
* @version SDK: 1.12.0 | ThoughtSpot: 8.4.0.cl
|
|
497
|
+
*/
|
|
498
|
+
HostEvent["Navigate"] = "Navigate";
|
|
486
499
|
})(exports.HostEvent || (exports.HostEvent = {}));
|
|
487
500
|
(function (DataSourceVisualMode) {
|
|
488
501
|
/**
|
|
@@ -9044,7 +9057,7 @@
|
|
|
9044
9057
|
}
|
|
9045
9058
|
}
|
|
9046
9059
|
|
|
9047
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.
|
|
9060
|
+
var name="@thoughtspot/visual-embed-sdk";var version="1.11.0-alpha.0";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/**"];var exports$1={".":"./lib/src/index.js","./react":"./lib/src/react/index.js"};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs && npx istanbul-merge --out ./coverage/coverage.json ./coverage/docs/coverage-final.json ./coverage/sdk/coverage-final.json && npx istanbul report --include ./coverage/coverage.json --dir ./coverage lcov",posttest:"cat ./coverage/sdk/lcov.info | coveralls",prepublishOnly:"npm run test; npm run tsc; npm run bundle-dts; npm run build","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1","mixpanel-browser":"^2.41.0"};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","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","dts-bundle":"0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.1.0","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"4.1.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^4.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-neo-theme":"^1.1.0","typedoc-plugin-toc-group":"0.0.5",typescript:"^4.1.0","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports$1,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};
|
|
9048
9061
|
|
|
9049
9062
|
/**
|
|
9050
9063
|
* Copyright (c) 2022
|
|
@@ -9151,9 +9164,10 @@
|
|
|
9151
9164
|
* will be removed for ts7.oct.cl
|
|
9152
9165
|
* @hidden
|
|
9153
9166
|
*/
|
|
9154
|
-
formatEventData(event) {
|
|
9167
|
+
formatEventData(event, eventType) {
|
|
9155
9168
|
const eventData = {
|
|
9156
9169
|
...event.data,
|
|
9170
|
+
type: eventType,
|
|
9157
9171
|
};
|
|
9158
9172
|
if (!eventData.data) {
|
|
9159
9173
|
eventData.data = event.data.payload;
|
|
@@ -9170,7 +9184,7 @@
|
|
|
9170
9184
|
window.addEventListener('message', (event) => {
|
|
9171
9185
|
const eventType = this.getEventType(event);
|
|
9172
9186
|
const eventPort = this.getEventPort(event);
|
|
9173
|
-
const eventData = this.formatEventData(event);
|
|
9187
|
+
const eventData = this.formatEventData(event, eventType);
|
|
9174
9188
|
if (event.source === this.iFrame.contentWindow) {
|
|
9175
9189
|
this.executeCallbacks(eventType, getProcessData(eventType, eventData, this.thoughtSpotHost), eventPort);
|
|
9176
9190
|
}
|
|
@@ -9288,6 +9302,7 @@
|
|
|
9288
9302
|
data: {
|
|
9289
9303
|
timestamp: initTimestamp,
|
|
9290
9304
|
},
|
|
9305
|
+
type: exports.EmbedEvent.Init,
|
|
9291
9306
|
});
|
|
9292
9307
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
9293
9308
|
(_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then(() => {
|
|
@@ -9319,6 +9334,7 @@
|
|
|
9319
9334
|
data: {
|
|
9320
9335
|
timestamp: loadTimestamp,
|
|
9321
9336
|
},
|
|
9337
|
+
type: exports.EmbedEvent.Load,
|
|
9322
9338
|
});
|
|
9323
9339
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_IFRAME_LOAD_PERFORMANCE, {
|
|
9324
9340
|
timeTookToLoad: loadTimestamp - initTimestamp,
|
|
@@ -9358,6 +9374,8 @@
|
|
|
9358
9374
|
*/
|
|
9359
9375
|
executeCallbacks(eventType, data, eventPort) {
|
|
9360
9376
|
const callbacks = this.eventHandlerMap.get(eventType) || [];
|
|
9377
|
+
const allHandlers = this.eventHandlerMap.get(exports.EmbedEvent.ALL) || [];
|
|
9378
|
+
callbacks.push(...allHandlers);
|
|
9361
9379
|
const dataStatus = (data === null || data === void 0 ? void 0 : data.status) || embedEventStatus.END;
|
|
9362
9380
|
callbacks.forEach((callbackObj) => {
|
|
9363
9381
|
if ((callbackObj.options.start &&
|
|
@@ -9524,9 +9542,9 @@
|
|
|
9524
9542
|
this.renderIFrame(iframeSrc, this.viewConfig.frameParams);
|
|
9525
9543
|
}
|
|
9526
9544
|
// @override
|
|
9527
|
-
on(messageType, callback) {
|
|
9545
|
+
on(messageType, callback, options = { start: false }) {
|
|
9528
9546
|
const eventType = this.getCompatibleEventType(messageType);
|
|
9529
|
-
return super.on(eventType, callback);
|
|
9547
|
+
return super.on(eventType, callback, options);
|
|
9530
9548
|
}
|
|
9531
9549
|
}
|
|
9532
9550
|
|
|
@@ -9652,19 +9670,29 @@
|
|
|
9652
9670
|
/**
|
|
9653
9671
|
* Navigate to particular page for app embed. eg:answers/pinboards/home
|
|
9654
9672
|
* This is used for embedding answers, pinboards, visualizations and full application only.
|
|
9655
|
-
* @param path The string, set to iframe src and navigate to new page
|
|
9673
|
+
* @param path string | number The string, set to iframe src and navigate to new page
|
|
9656
9674
|
* eg: appEmbed.navigateToPage('pinboards')
|
|
9675
|
+
* When used with `noReload` this can also be a number like 1/-1 to go forward/back.
|
|
9676
|
+
* @param noReload boolean Trigger the navigation without reloading the page (version: 1.12.0 | 8.4.0.cl)
|
|
9657
9677
|
*/
|
|
9658
|
-
navigateToPage(path) {
|
|
9659
|
-
if (this.iFrame) {
|
|
9678
|
+
navigateToPage(path, noReload = false) {
|
|
9679
|
+
if (!this.iFrame) {
|
|
9680
|
+
console.log('Please call render before invoking this method');
|
|
9681
|
+
return;
|
|
9682
|
+
}
|
|
9683
|
+
if (noReload) {
|
|
9684
|
+
this.trigger(exports.HostEvent.Navigate, path);
|
|
9685
|
+
}
|
|
9686
|
+
else {
|
|
9687
|
+
if (typeof path !== 'string') {
|
|
9688
|
+
console.warn('Path can only by a string when triggered without noReload');
|
|
9689
|
+
return;
|
|
9690
|
+
}
|
|
9660
9691
|
const iframeSrc = this.iFrame.src;
|
|
9661
9692
|
const embedPath = '#/embed';
|
|
9662
9693
|
const currentPath = iframeSrc.includes(embedPath) ? embedPath : '#';
|
|
9663
9694
|
this.iFrame.src = `${iframeSrc.split(currentPath)[0]}${currentPath}/${path.replace(/^\/?#?\//, '')}`;
|
|
9664
9695
|
}
|
|
9665
|
-
else {
|
|
9666
|
-
console.log('Please call render before invoking this method');
|
|
9667
|
-
}
|
|
9668
9696
|
}
|
|
9669
9697
|
/**
|
|
9670
9698
|
* Renders the embedded application pages in the ThoughtSpot app.
|
package/lib/package.json
CHANGED
package/lib/src/embed/app.d.ts
CHANGED
|
@@ -118,10 +118,12 @@ export declare class AppEmbed extends V1Embed {
|
|
|
118
118
|
/**
|
|
119
119
|
* Navigate to particular page for app embed. eg:answers/pinboards/home
|
|
120
120
|
* This is used for embedding answers, pinboards, visualizations and full application only.
|
|
121
|
-
* @param path The string, set to iframe src and navigate to new page
|
|
121
|
+
* @param path string | number The string, set to iframe src and navigate to new page
|
|
122
122
|
* eg: appEmbed.navigateToPage('pinboards')
|
|
123
|
+
* When used with `noReload` this can also be a number like 1/-1 to go forward/back.
|
|
124
|
+
* @param noReload boolean Trigger the navigation without reloading the page (version: 1.12.0 | 8.4.0.cl)
|
|
123
125
|
*/
|
|
124
|
-
navigateToPage(path: string): void;
|
|
126
|
+
navigateToPage(path: string | number, noReload?: boolean): void;
|
|
125
127
|
/**
|
|
126
128
|
* Renders the embedded application pages in the ThoughtSpot app.
|
|
127
129
|
* @param renderOptions An object containing the page ID
|
package/lib/src/embed/app.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
10
10
|
*/
|
|
11
11
|
import { getFilterQuery, getQueryParamString } from '../utils';
|
|
12
|
-
import { Param } from '../types';
|
|
12
|
+
import { Param, HostEvent } from '../types';
|
|
13
13
|
import { V1Embed } from './ts-embed';
|
|
14
14
|
/**
|
|
15
15
|
* Pages within the ThoughtSpot app that can be embedded.
|
|
@@ -128,19 +128,29 @@ export class AppEmbed extends V1Embed {
|
|
|
128
128
|
/**
|
|
129
129
|
* Navigate to particular page for app embed. eg:answers/pinboards/home
|
|
130
130
|
* This is used for embedding answers, pinboards, visualizations and full application only.
|
|
131
|
-
* @param path The string, set to iframe src and navigate to new page
|
|
131
|
+
* @param path string | number The string, set to iframe src and navigate to new page
|
|
132
132
|
* eg: appEmbed.navigateToPage('pinboards')
|
|
133
|
+
* When used with `noReload` this can also be a number like 1/-1 to go forward/back.
|
|
134
|
+
* @param noReload boolean Trigger the navigation without reloading the page (version: 1.12.0 | 8.4.0.cl)
|
|
133
135
|
*/
|
|
134
|
-
navigateToPage(path) {
|
|
135
|
-
if (this.iFrame) {
|
|
136
|
+
navigateToPage(path, noReload = false) {
|
|
137
|
+
if (!this.iFrame) {
|
|
138
|
+
console.log('Please call render before invoking this method');
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (noReload) {
|
|
142
|
+
this.trigger(HostEvent.Navigate, path);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
if (typeof path !== 'string') {
|
|
146
|
+
console.warn('Path can only by a string when triggered without noReload');
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
136
149
|
const iframeSrc = this.iFrame.src;
|
|
137
150
|
const embedPath = '#/embed';
|
|
138
151
|
const currentPath = iframeSrc.includes(embedPath) ? embedPath : '#';
|
|
139
152
|
this.iFrame.src = `${iframeSrc.split(currentPath)[0]}${currentPath}/${path.replace(/^\/?#?\//, '')}`;
|
|
140
153
|
}
|
|
141
|
-
else {
|
|
142
|
-
console.log('Please call render before invoking this method');
|
|
143
|
-
}
|
|
144
154
|
}
|
|
145
155
|
/**
|
|
146
156
|
* Renders the embedded application pages in the ThoughtSpot app.
|
package/lib/src/embed/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/embed/app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,KAAK,EAA8B,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/embed/app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,KAAK,EAA8B,SAAS,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAAE,OAAO,EAAc,MAAM,YAAY,CAAC;AAEjD;;GAEG;AACH,qCAAqC;AACrC,MAAM,CAAN,IAAY,IA6BX;AA7BD,WAAY,IAAI;IACZ;;OAEG;IACH,qBAAa,CAAA;IACb;;OAEG;IACH,yBAAiB,CAAA;IACjB;;OAEG;IACH,2BAAmB,CAAA;IACnB;;OAEG;IACH,iCAAyB,CAAA;IACzB;;OAEG;IACH,+BAAuB,CAAA;IACvB;;OAEG;IACH,qBAAa,CAAA;IACb;;OAEG;IACH,yBAAiB,CAAA;AACrB,CAAC,EA7BW,IAAI,KAAJ,IAAI,QA6Bf;AA+CD;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,OAAO;IAGjC,kDAAkD;IAClD,YAAY,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MAAM,CAAC,GAAG,CAAC;YAClC,MAAM,SAAS,GAAG,SAAS,CAAC;YAC5B,MAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;YACpE,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,GACd,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAClC,GAAG,WAAW,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC;SACpD;IACL,CAAC;IAED;;;;OAIG;IACI,MAAM;QACT,KAAK,CAAC,MAAM,EAAE,CAAC;QAEf,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC;QACzD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACrE,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACzD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAExB,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AppEmbed, Page } from './app';
|
|
2
2
|
import { init } from '../index';
|
|
3
|
-
import { Action, AuthType, RuntimeFilterOp } from '../types';
|
|
4
|
-
import { executeAfterWait, getDocumentBody, getIFrameSrc, getRootEl, } from '../test/test-utils';
|
|
3
|
+
import { Action, AuthType, HostEvent, RuntimeFilterOp } from '../types';
|
|
4
|
+
import { executeAfterWait, getDocumentBody, getIFrameSrc, getRootEl, getIFrameEl, } from '../test/test-utils';
|
|
5
5
|
import { version } from '../../package.json';
|
|
6
6
|
import * as config from '../config';
|
|
7
7
|
const defaultViewConfig = {
|
|
@@ -63,6 +63,7 @@ describe('App embed tests', () => {
|
|
|
63
63
|
[Page.Liveboards]: 'pinboards',
|
|
64
64
|
[Page.Data]: 'data/tables',
|
|
65
65
|
[Page.Home]: 'home',
|
|
66
|
+
[Page.SpotIQ]: 'insights/results',
|
|
66
67
|
};
|
|
67
68
|
const pageIds = Object.keys(pageRouteMap);
|
|
68
69
|
for (let i = 0; i < pageIds.length; i++) {
|
|
@@ -148,6 +149,39 @@ describe('App embed tests', () => {
|
|
|
148
149
|
appEmbed.navigateToPage(path);
|
|
149
150
|
expect(getIFrameSrc()).toBe(`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}${defaultParamsPost}#/${path}`);
|
|
150
151
|
});
|
|
152
|
+
test('navigateToPage with noReload should trigger the appropriate event', async () => {
|
|
153
|
+
const appEmbed = new AppEmbed(getRootEl(), {
|
|
154
|
+
frameParams: {
|
|
155
|
+
width: '100%',
|
|
156
|
+
height: '100%',
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
await appEmbed.render();
|
|
160
|
+
const iframe = getIFrameEl();
|
|
161
|
+
iframe.contentWindow.postMessage = jest.fn();
|
|
162
|
+
appEmbed.navigateToPage(path, true);
|
|
163
|
+
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({
|
|
164
|
+
type: HostEvent.Navigate,
|
|
165
|
+
data: path,
|
|
166
|
+
}), `http://${thoughtSpotHost}`);
|
|
167
|
+
appEmbed.navigateToPage(-1, true);
|
|
168
|
+
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({
|
|
169
|
+
type: HostEvent.Navigate,
|
|
170
|
+
data: -1,
|
|
171
|
+
}), `http://${thoughtSpotHost}`);
|
|
172
|
+
});
|
|
173
|
+
test('Do not allow number path without noReload in navigateToPage', async () => {
|
|
174
|
+
const appEmbed = new AppEmbed(getRootEl(), {
|
|
175
|
+
frameParams: {
|
|
176
|
+
width: '100%',
|
|
177
|
+
height: '100%',
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
await appEmbed.render();
|
|
181
|
+
spyOn(console, 'warn');
|
|
182
|
+
appEmbed.navigateToPage(-1);
|
|
183
|
+
expect(console.warn).toHaveBeenCalledWith('Path can only by a string when triggered without noReload');
|
|
184
|
+
});
|
|
151
185
|
test('navigateToPage function use before render', async () => {
|
|
152
186
|
spyOn(console, 'log');
|
|
153
187
|
const appEmbed = new AppEmbed(getRootEl(), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.spec.js","sourceRoot":"","sources":["../../../src/embed/app.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,IAAI,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"app.spec.js","sourceRoot":"","sources":["../../../src/embed/app.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,IAAI,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EACH,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,SAAS,EACT,WAAW,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAEpC,MAAM,iBAAiB,GAAG;IACtB,WAAW,EAAE;QACT,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,GAAG;KACd;CACJ,CAAC;AACF,MAAM,eAAe,GAAG,QAAQ,CAAC;AACjC,MAAM,aAAa,GAAG,2EAA2E,OAAO,E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