Skip to content

Commit e86370c

Browse files
author
Matt Mazzola
committed
Remove old eventMap and event processing code since we have more robust event model
1 parent 2ddf1e2 commit e86370c

5 files changed

Lines changed: 29 additions & 107 deletions

File tree

‎dist/powerbi.d.ts‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface IServiceConfiguration extends IDebugOptions {
4646
autoEmbedOnContentLoaded?: boolean;
4747
onError?: (error: any) => any;
4848
}
49-
export declare class PowerBi {
49+
export declare class Service {
5050
/**
5151
* List of components this service can embed.
5252
*/
@@ -116,14 +116,6 @@ export declare class PowerBi {
116116
* Target may be to the whole report, speific page, or specific visual
117117
*/
118118
private getTargetUrl(target?);
119-
/**
120-
* Handler for window message event.
121-
* Parses event data as json and if it came from an iframe that matches one from an existing embeded component re-dispatches the event on the iframe's parent element
122-
* to simulate the event bubbling through the two separate windows / DOMs.
123-
*
124-
* If an error occurs when parsing event.data call error handler provided during configuration.
125-
*/
126-
private onReceiveMessage(event);
127119
}
128120

129121
/**
@@ -141,7 +133,7 @@ export declare const routerFactory: IRouterFactory;
141133

142134
declare global {
143135
interface Window {
144-
Powerbi: typeof PowerBi;
145-
powerbi: PowerBi;
136+
Powerbi: typeof Service;
137+
powerbi: Service;
146138
}
147139
}

‎dist/powerbi.js‎

Lines changed: 22 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/powerbi.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/powerbi.min.js‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/service.ts‎

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,6 @@ export class Service {
5858
Tile,
5959
Report
6060
];
61-
/**
62-
* Mapping of event names from iframe postMessage to their name percieved by parent DOM.
63-
* Example: User clicks on embeded report which is inside iframe. The iframe code resends
64-
* event as postMessage with { event: 'reportClicked', ... } and this name is converted to hyphenated
65-
* name and dispatched from the parent element of the iframe to simulate the event bubbling through two
66-
* different windows / DOMs
67-
*/
68-
private static eventMap = {
69-
'tileClicked': 'tile-click',
70-
'tileLoaded': 'tile-load',
71-
'reportPageLoaded': 'report-load'
72-
};
7361

7462
/**
7563
* Default configuration for service.
@@ -292,34 +280,4 @@ export class Service {
292280

293281
return targetUrl;
294282
}
295-
296-
/**
297-
* Handler for window message event.
298-
* Parses event data as json and if it came from an iframe that matches one from an existing embeded component re-dispatches the event on the iframe's parent element
299-
* to simulate the event bubbling through the two separate windows / DOMs.
300-
*
301-
* If an error occurs when parsing event.data call error handler provided during configuration.
302-
*/
303-
private onReceiveMessage(event: MessageEvent): void {
304-
if (!event) {
305-
return;
306-
}
307-
308-
try {
309-
// Only raise the event on the embed that matches the post message origin
310-
const embed = Utils.find(embed => event.source === embed.iframe.contentWindow, this.embeds);
311-
if(embed) {
312-
let messageData = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;
313-
Utils.raiseCustomEvent(embed.element, PowerBi.eventMap[messageData.event], messageData);
314-
}
315-
}
316-
catch (e) {
317-
if (typeof this.config.onError === 'function') {
318-
this.config.onError.call(window, e);
319-
}
320-
else {
321-
throw e;
322-
}
323-
}
324-
}
325283
}

0 commit comments

Comments
 (0)