11export declare class Utils {
22 static raiseCustomEvent ( element : HTMLElement , eventName : string , eventData : any ) : void ;
3- static findIndex < T > ( predicate : ( T ) => boolean , xs : T [ ] ) : number ;
4- static find < T > ( predicate : ( T ) => boolean , xs : T [ ] ) : T ;
5- static remove < T > ( predicate : ( T ) => boolean , xs : T [ ] ) : void ;
3+ static findIndex < T > ( predicate : ( x : T ) => boolean , xs : T [ ] ) : number ;
4+ static find < T > ( predicate : ( x : T ) => boolean , xs : T [ ] ) : T ;
5+ static remove < T > ( predicate : ( x : T ) => boolean , xs : T [ ] ) : void ;
66 static assign : ( ...args : any [ ] ) => any ;
77}
88
9- export interface IError {
10- message : string ;
11- }
12- /**
13- * Takes in schema and returns function which can be used to validate the schema with better semantics around exposing errors
14- */
15- export declare function validate ( schema : any , options ?: any ) : ( x : any ) => any [ ] ;
16- export interface ISettings {
17- filter ?: any ;
18- filterPaneEnabled ?: boolean ;
19- pageName ?: string ;
20- pageNavigationEnabled ?: boolean ;
9+
10+ export declare class Tile extends Embed {
11+ static type : string ;
2112}
22- export declare const settingsSchema : {
23- "$schema" : string ;
24- "type" : string ;
25- "properties" : {
26- "filter" : {
27- "type" : string ;
28- } ;
29- "filterPaneEnabled" : {
30- "type" : string ;
31- "messages" : {
32- "type" : string ;
33- } ;
34- } ;
35- "pageName" : {
36- "type" : string ;
37- "messages" : {
38- "type" : string ;
39- } ;
40- } ;
41- "pageNavigationEnabled" : {
42- "type" : string ;
43- "messages" : {
44- "type" : string ;
45- } ;
46- } ;
47- } ;
48- } ;
49- export declare const validateSettings : ( x : any ) => any [ ] ;
50- /**
51- * TODO: Consider adding type: "report" | "tile" property to indicate what type of object to embed
52- *
53- * This would align with goal of having single embed page which adapts to the thing being embedded
54- * instead of having M x N embed pages where M is type of object (report, tile) and N is authorization
55- * type (PaaS, SaaS, Anonymous)
56- */
57- export interface ILoadConfiguration {
58- accessToken : string ;
13+
14+
15+ import * as wpmp from 'window-post-message-proxy' ;
16+ import * as hpm from 'http-post-message' ;
17+ import * as router from 'powerbi-router' ;
18+ export interface IEvent < T > {
19+ type : string ;
5920 id : string ;
60- settings ?: ISettings ;
61- }
62- export declare const loadSchema : {
63- "$schema" : string ;
64- "type" : string ;
65- "properties" : {
66- "accessToken" : {
67- "type" : string ;
68- "messages" : {
69- "type" : string ;
70- "required" : string ;
71- } ;
72- "invalidMessage" : string ;
73- } ;
74- "id" : {
75- "type" : string ;
76- "messages" : {
77- "type" : string ;
78- "required" : string ;
79- } ;
80- } ;
81- "settings" : {
82- "$ref" : string ;
83- } ;
84- } ;
85- "required" : string [ ] ;
86- } ;
87- export declare const validateLoad : ( x : any ) => any [ ] ;
88- export interface IPageTarget {
89- type : "page" ;
9021 name : string ;
22+ value : T ;
9123}
92- export declare const pageTargetSchema : {
93- "$schema" : string ;
94- "type" : string ;
95- "properties" : {
96- "type" : {
97- "type" : string ;
98- "enum" : string [ ] ;
99- "messages" : {
100- "type" : string ;
101- "enum" : string ;
102- "required" : string ;
103- } ;
104- } ;
105- "name" : {
106- "type" : string ;
107- "messages" : {
108- "type" : string ;
109- "required" : string ;
110- } ;
111- } ;
112- } ;
113- "required" : string [ ] ;
114- } ;
115- export declare const validatePageTarget : ( x : any ) => any [ ] ;
116- export interface IVisualTarget {
117- type : "visual" ;
118- id : string ;
24+ export interface IEventHandler < T > {
25+ ( event : IEvent < T > ) : any ;
11926}
120- export declare const visualTargetSchema : {
121- "$schema" : string ;
122- "type" : string ;
123- "properties" : {
124- "type" : {
125- "type" : string ;
126- "enum" : string [ ] ;
127- "messages" : {
128- "type" : string ;
129- "enum" : string ;
130- "required" : string ;
131- } ;
132- } ;
133- "id" : {
134- "type" : string ;
135- "messages" : {
136- "type" : string ;
137- "required" : string ;
138- } ;
139- } ;
140- } ;
141- "required" : string [ ] ;
142- } ;
143- export declare const validateVisualTarget : ( x : any ) => any [ ] ;
144- export interface IPage {
145- name : string ;
146- displayName : string ;
27+ export interface IHpmFactory {
28+ ( targetWindow : Window , wpmp : wpmp . WindowPostMessageProxy , version ?: string , type ?: string , origin ?: string ) : hpm . HttpPostMessage ;
14729}
148- export declare const pageSchema : {
149- "$schema" : string ;
150- "type" : string ;
151- "properties" : {
152- "name" : {
153- "type" : string ;
154- "messages" : {
155- "type" : string ;
156- "required" : string ;
157- } ;
158- } ;
159- "displayName" : {
160- "type" : string ;
161- "messages" : {
162- "type" : string ;
163- "required" : string ;
164- } ;
165- } ;
166- } ;
167- "required" : string [ ] ;
168- } ;
169- export declare const validatePage : ( x : any ) => any [ ] ;
170-
171-
172- export declare class Tile extends Embed {
173- static type : string ;
30+ export interface IWpmpFactory {
31+ ( name ?: string , logMessages ?: boolean , eventSourceOverrideWindow ?: Window ) : wpmp . WindowPostMessageProxy ;
32+ }
33+ export interface IRouterFactory {
34+ ( wpmp : wpmp . WindowPostMessageProxy ) : router . Router ;
17435}
175-
176-
17736export interface IPowerBiElement extends HTMLElement {
17837 powerBiEmbed : embed . Embed ;
17938}
18039export interface IPowerBiConfiguration {
18140 autoEmbedOnContentLoaded ?: boolean ;
18241 onError ?: ( error : any ) => any ;
42+ logMessages ?: boolean ;
43+ wpmpName ?: string ;
18344}
18445export declare class PowerBi {
18546 /**
@@ -209,15 +70,15 @@ export declare class PowerBi {
20970 /** List of components (Reports/Tiles) that have been embedded using this service instance. */
21071 private embeds ;
21172 private hpmFactory ;
212- private wpmpFactory ;
213- private routerFactory ;
214- constructor ( hpmFactory : embed . IHpmFactory , wpmpFactory : embed . IWpmpFactory , routerFactory : embed . IRouterFactory , config ?: IPowerBiConfiguration ) ;
73+ wpmp : wpmp . WindowPostMessageProxy ;
74+ private router ;
75+ constructor ( hpmFactory : IHpmFactory , wpmpFactory : IWpmpFactory , routerFactory : IRouterFactory , config ?: IPowerBiConfiguration ) ;
21576 /**
21677 * Handler for DOMContentLoaded which searches DOM for elements having 'powerbi-embed-url' attribute
21778 * and automatically attempts to embed a powerbi component based on information from the attributes.
21879 * Only runs if `config.autoEmbedOnContentLoaded` is true when the service is created.
21980 */
220- init ( container ?: HTMLElement ) : void ;
81+ init ( container ?: HTMLElement , config ?: embed . IEmbedConfiguration ) : embed . Embed [ ] ;
22182 /**
22283 * Given an html element embed component based on configuration.
22384 * If component has already been created and attached to element re-use component instance and existing iframe,
@@ -244,6 +105,12 @@ export declare class PowerBi {
244105 * Given an html element which has component embedded within it, remove the component from list of embeds, remove association with component, and remove the iframe.
245106 */
246107 reset ( element : HTMLElement ) : void ;
108+ handleEvent ( event : IEvent < any > ) : void ;
109+ /**
110+ * Translate target into url
111+ * Target may be to the whole report, speific page, or specific visual
112+ */
113+ private getTargetUrl ( target ?) ;
247114 /**
248115 * Handler for window message event.
249116 * 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
@@ -256,10 +123,12 @@ export declare class PowerBi {
256123
257124/**
258125 * TODO: Need to find better place for these factory functions or refactor how we handle dependency injection
259- * Need to
260126 */
261127
262128export { IHpmFactory , IWpmpFactory , IRouterFactory } ;
129+ /**
130+ * TODO: Need to get sdk version and settings from package.json, Generate config file via gulp task?
131+ */
263132export declare const hpmFactory : IHpmFactory ;
264133export declare const wpmpFactory : IWpmpFactory ;
265134export declare const routerFactory : IRouterFactory ;
0 commit comments