Skip to content

Commit a05fa2e

Browse files
author
submarine-launched
authored
Merge pull request #381 from microsoft/release-2.19.1
Release 2.19.1
2 parents 70119ae + 8b1fe7c commit a05fa2e

15 files changed

+329
-181
lines changed

dist/powerbi-client.d.ts

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// powerbi-client v2.18.7
1+
// powerbi-client v2.19.1
22
// Copyright (c) Microsoft Corporation.
33
// Licensed under the MIT License.
44
declare module "config" {
@@ -190,6 +190,13 @@ declare module "embed" {
190190
* @hidden
191191
*/
192192
eventHandlers: IInternalEventHandler<any>[];
193+
/**
194+
* Gets or sets the eventHooks.
195+
*
196+
* @type {models.EventHooks}
197+
* @hidden
198+
*/
199+
eventHooks: models.EventHooks;
193200
/**
194201
* Gets or sets the Power BI embed service.
195202
*
@@ -418,6 +425,14 @@ declare module "embed" {
418425
* @returns {void}
419426
*/
420427
populateConfig(config: IBootstrapEmbedConfiguration, isBootstrap: boolean): void;
428+
/**
429+
* Validate EventHooks
430+
*
431+
* @private
432+
* @param {models.EventHooks} eventHooks
433+
* @hidden
434+
*/
435+
private validateEventHooks;
421436
/**
422437
* Adds locale parameters to embedUrl
423438
*
@@ -2159,10 +2174,6 @@ declare module "service" {
21592174
* @hidden
21602175
*/
21612176
private embedExisting;
2162-
/**
2163-
* @hidden
2164-
*/
2165-
private registerApplicationContextHook;
21662177
/**
21672178
* Adds an event handler for DOMContentLoaded, which searches the DOM for elements that have the 'powerbi-embed-url' attribute,
21682179
* and automatically attempts to embed a powerbi component based on information from other powerbi-* attributes.
@@ -2211,6 +2222,7 @@ declare module "service" {
22112222
* @hidden
22122223
*/
22132224
handleTileEvents(event: IEvent<any>): void;
2225+
private invokeSDKHook;
22142226
/**
22152227
* Given an event object, finds the embed component with the matching type and ID, and invokes its handleEvent method with the event object.
22162228
*
@@ -2771,6 +2783,7 @@ declare module "powerbi-client" {
27712783
global {
27722784
interface Window {
27732785
powerbi: service.Service;
2786+
powerBISDKGlobalServiceInstanceName?: string;
27742787
}
27752788
}
27762789
}

dist/powerbi.js

+182-103
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/powerbi.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@ gulp.task('test:js', 'Run js tests', function (done) {
220220
configFile: __dirname + '/karma.conf.js',
221221
singleRun: argv.watch ? false : true,
222222
captureTimeout: argv.timeout || 60000
223-
}, function () {
223+
}, function (exitStatus) {
224224
done();
225+
process.exit(exitStatus);
225226
})
226227
.on('browser_register', (browser) => {
227228
if (argv.chrome) {

karma.conf.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = function (config) {
2323
{ pattern: './test/**/*.html', served: true, included: false }
2424
],
2525
exclude: [],
26-
reporters: argv.debug ? ['spec', 'kjhtml'] : ['spec', 'coverage', 'kjhtml'],
26+
reporters: argv.chrome ? ['kjhtml'] : ['spec', 'junit'],
2727
autoWatch: true,
2828
browsers: [browserName],
2929
browserNoActivityTimeout: 300000,
@@ -33,27 +33,24 @@ module.exports = function (config) {
3333
'karma-jasmine',
3434
'karma-spec-reporter',
3535
'karma-phantomjs-launcher',
36-
'karma-coverage',
37-
'karma-jasmine-html-reporter'
36+
'karma-jasmine-html-reporter',
37+
'karma-junit-reporter'
3838
],
3939
customLaunchers: {
4040
'Chrome_headless': {
41-
base: argv.debug ? 'Chrome' : 'ChromeHeadless',
41+
base: 'Chrome',
4242
flags: flags.concat("--no-sandbox", "--window-size=800,800"),
4343
},
4444
},
45-
preprocessors: { './tmp/**/*.js': ['coverage'] },
46-
coverageReporter: {
47-
reporters: [
48-
{ type: 'html' },
49-
{ type: 'text-summary' }
50-
]
45+
junitReporter: {
46+
outputDir: 'tmp',
47+
outputFile: 'testresults.xml',
48+
useBrowserName: false
5149
},
5250
retryLimit: 0,
5351
logLevel: argv.debug ? config.LOG_DEBUG : config.LOG_INFO,
5452
client: {
5553
clearContext: false, // leave Jasmine Spec Runner output visible in browser
56-
args: argv.logMessages ? ['logMessages'] : []
5754
}
5855
});
5956
};

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "powerbi-client",
3-
"version": "2.18.7",
3+
"version": "2.19.1",
44
"description": "JavaScript library for embedding Power BI into your apps. Provides service which makes it easy to embed different types of components and an object model which allows easy interaction with these components such as changing pages, applying filters, and responding to data selection.",
55
"main": "dist/powerbi.js",
66
"types": "dist/powerbi-client.d.ts",
@@ -16,7 +16,7 @@
1616
"prestart": "cd demo && npm install",
1717
"test": "gulp test",
1818
"gulp": "gulp",
19-
"tests": "npm test -- --chrome --watch --debug"
19+
"tests": "npm test -- --chrome --watch"
2020
},
2121
"keywords": [
2222
"microsoft",
@@ -64,10 +64,10 @@
6464
"json-loader": "^0.5.4",
6565
"karma": "6.3.5",
6666
"karma-chrome-launcher": "^3.1.0",
67-
"karma-coverage": "^2.0.3",
6867
"karma-firefox-launcher": "^1.2.0",
6968
"karma-jasmine": "4.0.1",
7069
"karma-jasmine-html-reporter": "1.7.0",
70+
"karma-junit-reporter": "^2.0.1",
7171
"karma-phantomjs-launcher": "^1.0.4",
7272
"karma-spec-reporter": "0.0.32",
7373
"moment": "^2.14.1",
@@ -81,7 +81,7 @@
8181
},
8282
"dependencies": {
8383
"http-post-message": "^0.2",
84-
"powerbi-models": "^1.9.7",
84+
"powerbi-models": "^1.9.8",
8585
"powerbi-router": "^0.1",
8686
"window-post-message-proxy": "^0.2"
8787
},

src/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/** @ignore *//** */
55
const config = {
6-
version: '2.18.7',
6+
version: '2.19.1',
77
type: 'js'
88
};
99

src/embed.ts

+46-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export interface IInternalEventHandler<T> {
7070
*/
7171
export abstract class Embed {
7272
/** @hidden */
73-
static allowedEvents = ["loaded", "saved", "rendered", "saveAsTriggered", "error", "dataSelected", "buttonClicked"];
73+
static allowedEvents = ["loaded", "saved", "rendered", "saveAsTriggered", "error", "dataSelected", "buttonClicked", "info"];
7474
/** @hidden */
7575
static accessTokenAttribute = 'powerbi-access-token';
7676
/** @hidden */
@@ -108,6 +108,14 @@ export abstract class Embed {
108108
*/
109109
eventHandlers: IInternalEventHandler<any>[];
110110

111+
/**
112+
* Gets or sets the eventHooks.
113+
*
114+
* @type {models.EventHooks}
115+
* @hidden
116+
*/
117+
eventHooks: models.EventHooks;
118+
111119
/**
112120
* Gets or sets the Power BI embed service.
113121
*
@@ -537,14 +545,48 @@ export abstract class Embed {
537545
this.config.accessToken = this.getAccessToken(this.service.accessToken);
538546
}
539547

540-
const registerQueryCallback = !!(<IEmbedConfiguration>this.config).eventHooks?.applicationContextProvider;
548+
this.eventHooks = (<IEmbedConfiguration>this.config).eventHooks;
549+
this.validateEventHooks(this.eventHooks);
541550
delete (<IEmbedConfiguration>this.config).eventHooks;
542-
if (registerQueryCallback && this.embedtype === "report")
543-
this.config.embedUrl = addParamToUrl(this.config.embedUrl, "registerQueryCallback", "true");
544551

545552
this.configChanged(isBootstrap);
546553
}
547554

555+
/**
556+
* Validate EventHooks
557+
*
558+
* @private
559+
* @param {models.EventHooks} eventHooks
560+
* @hidden
561+
*/
562+
private validateEventHooks(eventHooks: models.EventHooks): void {
563+
if (!eventHooks) {
564+
return;
565+
}
566+
567+
for (let key in eventHooks) {
568+
if (eventHooks.hasOwnProperty(key) && typeof eventHooks[key] !== 'function') {
569+
throw new Error(key + " must be a function");
570+
}
571+
}
572+
573+
const applicationContextProvider = eventHooks.applicationContextProvider;
574+
if (!!applicationContextProvider) {
575+
if (this.embedtype.toLowerCase() !== "report") {
576+
throw new Error("applicationContextProvider is only supported in report embed");
577+
}
578+
579+
this.config.embedUrl = addParamToUrl(this.config.embedUrl, "registerQueryCallback", "true");
580+
}
581+
582+
const accessTokenProvider = eventHooks.accessTokenProvider;
583+
if (!!accessTokenProvider) {
584+
if (this.embedtype.toLowerCase() !== "report" || this.config.tokenType !== models.TokenType.Aad) {
585+
throw new Error("accessTokenProvider is only supported in report SaaS embed");
586+
}
587+
}
588+
}
589+
548590
/**
549591
* Adds locale parameters to embedUrl
550592
*

src/powerbi-client.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ declare var powerbi: service.Service;
6060
declare global {
6161
interface Window {
6262
powerbi: service.Service;
63+
powerBISDKGlobalServiceInstanceName?: string;
6364
}
6465
}
6566

@@ -69,4 +70,10 @@ declare global {
6970
* Note: create an instance of the class with the default configuration for normal usage, or save the class so that you can create an instance of the service.
7071
*/
7172
var powerbi = new service.Service(factories.hpmFactory, factories.wpmpFactory, factories.routerFactory);
72-
window.powerbi = powerbi;
73+
// powerBI SDK may use Power BI object under different key, in order to avoid name collisions
74+
if (window.powerbi && window.powerBISDKGlobalServiceInstanceName) {
75+
window[window.powerBISDKGlobalServiceInstanceName] = powerbi;
76+
} else {
77+
// Default to Power BI.
78+
window.powerbi = powerbi;
79+
}

0 commit comments

Comments
 (0)