|
1 | 1 | /*! powerbi-client v2.0.0-beta.6 | (c) 2016 Microsoft Corporation MIT */
|
2 |
| -export declare class Utils { |
3 |
| - static raiseCustomEvent(element: HTMLElement, eventName: string, eventData: any): void; |
4 |
| - static findIndex<T>(predicate: (x: T) => boolean, xs: T[]): number; |
5 |
| - static find<T>(predicate: (x: T) => boolean, xs: T[]): T; |
6 |
| - static remove<T>(predicate: (x: T) => boolean, xs: T[]): void; |
7 |
| - static assign: (...args: any[]) => any; |
8 |
| -} |
9 |
| - |
10 |
| - |
11 |
| -export declare class Tile extends Embed { |
12 |
| - static type: string; |
13 |
| -} |
14 |
| - |
15 |
| - |
16 |
| -import * as wpmp from 'window-post-message-proxy'; |
17 |
| -import * as hpm from 'http-post-message'; |
18 |
| -import * as router from 'powerbi-router'; |
19 |
| -export interface IEvent<T> { |
20 |
| - type: string; |
21 |
| - id: string; |
22 |
| - name: string; |
23 |
| - value: T; |
24 |
| -} |
25 |
| -export interface IEventHandler<T> { |
26 |
| - (event: IEvent<T>): any; |
27 |
| -} |
28 |
| -export interface IHpmFactory { |
29 |
| - (targetWindow: Window, wpmp: wpmp.WindowPostMessageProxy, version?: string, type?: string, origin?: string): hpm.HttpPostMessage; |
30 |
| -} |
31 |
| -export interface IWpmpFactory { |
32 |
| - (name?: string, logMessages?: boolean, eventSourceOverrideWindow?: Window): wpmp.WindowPostMessageProxy; |
33 |
| -} |
34 |
| -export interface IRouterFactory { |
35 |
| - (wpmp: wpmp.WindowPostMessageProxy): router.Router; |
36 |
| -} |
37 |
| -export interface IPowerBiElement extends HTMLElement { |
38 |
| - powerBiEmbed: embed.Embed; |
39 |
| -} |
40 |
| -export interface IDebugOptions { |
41 |
| - logMessages?: boolean; |
42 |
| - wpmpName?: string; |
43 |
| - eventSourceOverrideWindow?: Window; |
44 |
| -} |
45 |
| -export interface IServiceConfiguration extends IDebugOptions { |
46 |
| - autoEmbedOnContentLoaded?: boolean; |
47 |
| - onError?: (error: any) => any; |
48 |
| -} |
49 |
| -export declare class Service { |
50 |
| - /** |
51 |
| - * List of components this service can embed. |
52 |
| - */ |
53 |
| - /** |
54 |
| - * TODO: See if it's possible to remove need for this interface and just use Embed base object as common between Tile and Report |
55 |
| - * This was only put it to allow both types of components to be in the same list |
56 |
| - */ |
57 |
| - private static components; |
58 |
| - /** |
59 |
| - * Mapping of event names from iframe postMessage to their name percieved by parent DOM. |
60 |
| - * Example: User clicks on embeded report which is inside iframe. The iframe code resends |
61 |
| - * event as postMessage with { event: 'reportClicked', ... } and this name is converted to hyphenated |
62 |
| - * name and dispatched from the parent element of the iframe to simulate the event bubbling through two |
63 |
| - * different windows / DOMs |
64 |
| - */ |
65 |
| - private static eventMap; |
66 |
| - /** |
67 |
| - * Default configuration for service. |
68 |
| - */ |
69 |
| - private static defaultConfig; |
70 |
| - /** Save access token as fallback/global token to use when local token for report/tile is not provided. */ |
71 |
| - accessToken: string; |
72 |
| - /** Configuration object */ |
73 |
| - private config; |
74 |
| - /** List of components (Reports/Tiles) that have been embedded using this service instance. */ |
75 |
| - private embeds; |
76 |
| - private hpmFactory; |
77 |
| - /** TODO: Look for way to make this private. This should be private but in embed constructor needs to pass the wpmp instance to the hpm factory. */ |
78 |
| - wpmp: wpmp.WindowPostMessageProxy; |
79 |
| - private router; |
80 |
| - constructor(hpmFactory: IHpmFactory, wpmpFactory: IWpmpFactory, routerFactory: IRouterFactory, config?: IServiceConfiguration); |
81 |
| - /** |
82 |
| - * Handler for DOMContentLoaded which searches DOM for elements having 'powerbi-embed-url' attribute |
83 |
| - * and automatically attempts to embed a powerbi component based on information from the attributes. |
84 |
| - * Only runs if `config.autoEmbedOnContentLoaded` is true when the service is created. |
85 |
| - */ |
86 |
| - init(container?: HTMLElement, config?: embed.IEmbedConfiguration): embed.Embed[]; |
87 |
| - /** |
88 |
| - * Given an html element embed component based on configuration. |
89 |
| - * If component has already been created and attached to element re-use component instance and existing iframe, |
90 |
| - * otherwise create a new component instance |
91 |
| - */ |
92 |
| - embed(element: HTMLElement, config?: embed.IEmbedConfiguration): embed.Embed; |
93 |
| - /** |
94 |
| - * Given an html element embed component base configuration. |
95 |
| - * Save component instance on element for later lookup. |
96 |
| - */ |
97 |
| - private embedNew(element, config); |
98 |
| - private embedExisting(element, config); |
99 |
| - /** |
100 |
| - * Adds event handler for DOMContentLoaded which finds all elements in DOM with attribute powerbi-embed-url |
101 |
| - * then attempts to initiate the embed process based on data from other powerbi-* attributes. |
102 |
| - * (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.) |
103 |
| - */ |
104 |
| - enableAutoEmbed(): void; |
105 |
| - /** |
106 |
| - * Returns instance of component associated with element. |
107 |
| - */ |
108 |
| - get(element: HTMLElement): embed.Embed; |
109 |
| - /** |
110 |
| - * 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. |
111 |
| - */ |
112 |
| - reset(element: HTMLElement): void; |
113 |
| - handleEvent(event: IEvent<any>): void; |
114 |
| - /** |
115 |
| - * Translate target into url |
116 |
| - * Target may be to the whole report, speific page, or specific visual |
117 |
| - */ |
118 |
| - private getTargetUrl(target?); |
119 |
| -} |
120 |
| - |
121 |
| -/** |
122 |
| - * TODO: Need to find better place for these factory functions or refactor how we handle dependency injection |
123 |
| - */ |
124 |
| - |
125 |
| -export { IHpmFactory, IWpmpFactory, IRouterFactory }; |
126 |
| -/** |
127 |
| - * TODO: Need to get sdk version and settings from package.json, Generate config file via gulp task? |
128 |
| - */ |
129 |
| -export declare const hpmFactory: IHpmFactory; |
130 |
| -export declare const wpmpFactory: IWpmpFactory; |
131 |
| -export declare const routerFactory: IRouterFactory; |
132 |
| - |
133 |
| - |
| 2 | +import { Service } from './service'; |
| 3 | +import * as factories from './factories'; |
| 4 | +export { Service, factories }; |
| 5 | +export * from './report'; |
| 6 | +export * from './tile'; |
| 7 | +export * from './embed'; |
134 | 8 | declare global {
|
135 | 9 | interface Window {
|
136 | 10 | Powerbi: typeof Service;
|
|
0 commit comments