Skip to content

Commit d6ecab0

Browse files
committed
Merge pull request microsoft#10 from Microsoft/dev
1 parent 1a52f36 commit d6ecab0

21 files changed

+581
-441
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules/
22
bower_components/
33
coverage/
44
typings/
5+
test/*.spec.js

CHANGELOG.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# 2.0.0-beta.1 (GA candidate)
2+
3+
## Breaking
4+
5+
- DOMContentLoaded handler is now opt-in instead of the default behavior
6+
- Reasons:
7+
- The primary use case will be using the core library within another library which may not have the DOM ready even if DOMContentLoaded has fired.
8+
- Most developers using SPA applications will fetch embed data asynchronously and not know report data by the time the DOMContentLoaded has fired.
9+
- How to opt-in to DOMContentLoaded:
10+
- Call `enableAutoEmbed()` on an instance of the PowerBi service to add the event listener.
11+
12+
Example:
13+
```
14+
<script src="powerbi.js"></script>
15+
<script>
16+
powerbi.enableAutoEmbed();
17+
</script>
18+
```
19+
20+
Alternately if you are creating an instance of the service you can pass a configuration parameter `autoEmbedOnContentLoaded`
21+
22+
Example:
23+
```
24+
var powerbiService = new Powerbi({ autoEmbedOnContentLoaded: true });
25+
```
26+
- `powerbi.get(element: HTMLElement)` is removed. Use `powerbi.embed(element: HTMLElement, config: IEmbedOptions = {})`.
27+
- Reasons:
28+
- powerbi.embed performed the same function and is more semantic.
29+
- Embed urls must be provided by the server and will not be constructed by the components. This implies that the attributes `powerbi-report` will no longer be used.
30+
- Reasons:
31+
32+
The construction of these urls was unreliable since it dependeded on assumptions about server configuration (target environment, component type, etc).
33+
Since url would be incorrect in some cases it could cause trouble for developers. Also, since the sever is already returning access tokens it's trival for the server to also provide embed urls and this reduces complexity.
34+
35+
Previously you could supply the embed information in two ways:
36+
37+
1. Using report id:
38+
39+
`<div powerbi-embed powerbi-report="5dac7a4a-4452-46b3-99f6-a25915e0fe55" powerbi-access-token="..."></div>`
40+
41+
This would implicitly construct the embed url to be something like: `https://embedded.powerbi.com/reports/5dac7a4a-4452-46b3-99f6-a25915e0fe55`
42+
However
43+
44+
2. Using embed url:
45+
46+
`<div powerbi-embed-url="https://embedded.powerbi.com/reports/5dac7a4a-4452-46b3-99f6-a25915e0fe55" powerbi-access-token="..."></div>`
47+
48+
Now only the latter options (#2) is supported.
49+
50+
- Embed url attribute changed from `powerbi-embed` to `powerbi-embed-url`
51+
- Component type is specified by attribute `powerbi-type`. Use `powerbi-type="report"` instead of applying the attribute `powerbi-report`
52+
- Configuration option attributes all start with prefix `powerbi-options-`. Example (`powerbi-options-filter`)
53+
54+
## Changes
55+
56+
- Fix bug to prevent memory leak of holding references to iframe elements which had been removed from the DOM.
57+
- Detect overwriting container with new component and either throw error or properly cleanup and replace old component based on `config.overwrite` setting.
58+
- Fix bug with prematurely attempting to parse post message data until it is known that it originated from embedded iframe.
59+
60+
# 1.0.0 (Preview)

dist/powerbi.d.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ export interface IPowerBiConfiguration {
77
onError?: (error: any) => any;
88
}
99

10+
declare global {
11+
interface Window {
12+
Powerbi: typeof PowerBi;
13+
}
14+
}
15+
1016
export class PowerBi {
1117
/**
1218
* List of components this service can embed.
@@ -42,6 +48,12 @@ export class PowerBi {
4248
* If component has already been created and attached to eleemnt simply return it to prevent creating duplicate components for same element.
4349
*/
4450
embed(element: IPowerBiElement, config?: IEmbedOptions): Embed;
51+
/**
52+
* Adds event handler for DOMContentLoaded which finds all elements in DOM with attribute powerbi-embed-url
53+
* then attempts to initiate the embed process based on data from other powerbi-* attributes.
54+
* (This is usually only useful for applications rendered on by the server since all the data needed will be available by the time the handler is called.)
55+
*/
56+
enableAutoEmbed(): void;
4557
/**
4658
* Remove component from the list of embedded components.
4759
*/
@@ -53,7 +65,7 @@ export class PowerBi {
5365
*
5466
* If an error occurs when parsing event.data call error handler provided during configuration.
5567
*/
56-
onReceiveMessage(event: MessageEvent): void;
68+
private onReceiveMessage(event: MessageEvent): void;
5769
}
5870

5971

@@ -65,11 +77,15 @@ export interface IEmbedOptions {
6577
embedUrl?: string;
6678
webUrl?: string;
6779
name?: string;
80+
filter?: any;
6881
filterPaneEnabled?: boolean;
6982
getGlobalAccessToken?: () => string;
7083
overwrite?: boolean;
7184
}
7285
declare abstract class Embed {
86+
public static embedUrlAttribute: string;
87+
public static accessTokenAttribute: string;
88+
public static typeAttribute: string;
7389
/**
7490
* Default options for embeddable component.
7591
*/

0 commit comments

Comments
 (0)