Skip to content

Commit 6a18899

Browse files
committed
Add gulp compile:dts task which generates single .d.ts from multiple files as workaround. (#16)
* Add gulp dts task which generates single .d.ts from multiple files as workaround. This uses concatenation which means we can use default exports. * Clean up gulp file
1 parent 76e82ae commit 6a18899

14 files changed

+192
-297
lines changed

dist/powerbi.d.ts

Lines changed: 124 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,105 @@
1+
export declare class Utils {
2+
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;
6+
static assign: (...args: any[]) => any;
7+
}
8+
9+
declare global {
10+
interface Document {
11+
mozCancelFullScreen: Function;
12+
msExitFullscreen: Function;
13+
}
14+
interface HTMLIFrameElement {
15+
mozRequestFullScreen: Function;
16+
msRequestFullscreen: Function;
17+
}
18+
}
19+
export interface ILoadMessage {
20+
action: string;
21+
accessToken: string;
22+
}
23+
export interface IEmbedOptions {
24+
type?: string;
25+
id?: string;
26+
accessToken?: string;
27+
embedUrl?: string;
28+
webUrl?: string;
29+
name?: string;
30+
filterPaneEnabled?: boolean;
31+
getGlobalAccessToken?: () => string;
32+
}
33+
export interface IEmbedConstructor {
34+
new (...args: any[]): Embed;
35+
}
36+
export declare abstract class Embed {
37+
static embedUrlAttribute: string;
38+
static accessTokenAttribute: string;
39+
static typeAttribute: string;
40+
/**
41+
* Attribute used to specify type of visual.
42+
* Example: `<div powerbi-type="report"></div>`
43+
*/
44+
static name: string;
45+
/**
46+
* Default options for embeddable component.
47+
*/
48+
private static defaultOptions;
49+
element: HTMLElement;
50+
iframe: HTMLIFrameElement;
51+
options: IEmbedOptions;
52+
constructor(element: HTMLElement, options: IEmbedOptions);
53+
/**
54+
* Handler for when the iframe has finished loading the powerbi placeholder page.
55+
* This is used to inject configuration options such as access token, loadAction, etc
56+
* which allow iframe to load the actual report with authentication.
57+
*/
58+
load(options: IEmbedOptions, requireId?: boolean, message?: ILoadMessage): void;
59+
/**
60+
* Get access token from first available location: options, attribute, global.
61+
*/
62+
private getAccessToken();
63+
/**
64+
* Get embed url from first available location: options, attribute.
65+
*/
66+
protected getEmbedUrl(): string;
67+
/**
68+
* Request the browser to make the components iframe fullscreen.
69+
*/
70+
fullscreen(): void;
71+
/**
72+
* Exit fullscreen.
73+
*/
74+
exitFullscreen(): void;
75+
/**
76+
* Return true if iframe is fullscreen,
77+
* otherwise return false
78+
*/
79+
private isFullscreen(iframe);
80+
}
81+
export {};
82+
83+
84+
export interface IReportLoadMessage extends ILoadMessage {
85+
reportId: string;
86+
}
87+
export declare class Report extends Embed {
88+
static name: string;
89+
getEmbedUrl(): string;
90+
load(options: IEmbedOptions, requireId?: boolean): void;
91+
}
92+
93+
94+
export interface ITileLoadMessage extends ILoadMessage {
95+
tileId: string;
96+
}
97+
export declare class Tile extends Embed {
98+
static name: string;
99+
getEmbedUrl(): string;
100+
load(options: IEmbedOptions, requireId?: boolean): void;
101+
}
102+
1103

2104
export interface IPowerBiElement extends HTMLElement {
3105
powerBiEmbed: Embed;
@@ -6,15 +108,7 @@ export interface IPowerBiConfiguration {
6108
autoEmbedOnContentLoaded?: boolean;
7109
onError?: (error: any) => any;
8110
}
9-
10-
declare global {
11-
interface Window {
12-
Powerbi: typeof PowerBi;
13-
powerbi: PowerBi;
14-
}
15-
}
16-
17-
export class PowerBi {
111+
export declare class PowerBi {
18112
/**
19113
* List of components this service can embed.
20114
*/
@@ -39,24 +133,35 @@ export class PowerBi {
39133
private embeds;
40134
constructor(config?: IPowerBiConfiguration);
41135
/**
42-
* Handler for DOMContentLoaded which searches DOM for elements having 'powerbi-embed' attribute
136+
* Handler for DOMContentLoaded which searches DOM for elements having 'powerbi-embed-url' attribute
43137
* and automatically attempts to embed a powerbi component based on information from the attributes.
44138
* Only runs if `config.autoEmbedOnContentLoaded` is true when the service is created.
45139
*/
46-
init(container: HTMLElement): void;
140+
init(container?: HTMLElement): void;
47141
/**
48142
* Given an html element embed component based on configuration.
49-
* If component has already been created and attached to eleemnt simply return it to prevent creating duplicate components for same element.
143+
* If component has already been created and attached to element re-use component instance and existing iframe,
144+
* otherwise create a new component instance
50145
*/
51146
embed(element: HTMLElement, config?: IEmbedOptions): Embed;
147+
/**
148+
* Given an html element embed component base configuration.
149+
* Save component instance on element for later lookup.
150+
*/
151+
private embedNew(element, config);
152+
private embedExisting(element, config);
52153
/**
53154
* Adds event handler for DOMContentLoaded which finds all elements in DOM with attribute powerbi-embed-url
54155
* then attempts to initiate the embed process based on data from other powerbi-* attributes.
55156
* (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.)
56157
*/
57158
enableAutoEmbed(): void;
58159
/**
59-
* Remove component from the list of embedded components.
160+
* Returns instance of component associated with element.
161+
*/
162+
get(element: HTMLElement): Embed;
163+
/**
164+
* 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.
60165
*/
61166
reset(element: HTMLElement): void;
62167
/**
@@ -66,69 +171,13 @@ export class PowerBi {
66171
*
67172
* If an error occurs when parsing event.data call error handler provided during configuration.
68173
*/
69-
private onReceiveMessage(event: MessageEvent): void;
70-
}
71-
72-
export interface IEmbedOptions {
73-
type?: string;
74-
id?: string;
75-
accessToken?: string;
76-
embedUrl?: string;
77-
webUrl?: string;
78-
name?: string;
79-
filter?: any;
80-
filterPaneEnabled?: boolean;
81-
getGlobalAccessToken?: () => string;
82-
}
83-
84-
declare abstract class Embed {
85-
public static embedUrlAttribute: string;
86-
public static accessTokenAttribute: string;
87-
public static typeAttribute: string;
88-
/**
89-
* Default options for embeddable component.
90-
*/
91-
private static defaultOptions;
92-
element: HTMLElement;
93-
iframe: HTMLIFrameElement;
94-
options: IEmbedOptions;
95-
constructor(element: HTMLElement, options: IEmbedOptions);
96-
/**
97-
* Handler for when the iframe has finished loading the powerbi placeholder page.
98-
* This is used to inject configuration options such as access token, action, etc
99-
* which allow iframe to load the actual report with authentication.
100-
*/
101-
load(options: IEmbedOptions, requireId: boolean, message: IEmbedOptions);
102-
/**
103-
* Get access token from first available location: options, attribute, global.
104-
*/
105-
private getAccessToken();
106-
/**
107-
* Get embed url from first available location: options, attribute.
108-
*/
109-
protected getEmbedUrl(): string;
110-
/**
111-
* Request the browser to make the components iframe fullscreen.
112-
*/
113-
fullscreen(): void;
114-
/**
115-
* Exit fullscreen.
116-
*/
117-
exitFullscreen(): void;
118-
/**
119-
* Return true if iframe is fullscreen,
120-
* otherwise return false
121-
*/
122-
private isFullscreen(iframe);
174+
private onReceiveMessage(event);
123175
}
124176

125-
export class Report extends Embed {
126-
constructor(element: HTMLElement, options: IEmbedOptions);
127-
getEmbedUrl(): string;
128-
}
129177

130-
export class Tile extends Embed {
131-
constructor(element: HTMLElement, options: IEmbedOptions);
132-
getEmbedUrl(): string;
178+
declare global {
179+
interface Window {
180+
Powerbi: typeof PowerBi;
181+
powerbi: PowerBi;
182+
}
133183
}
134-

0 commit comments

Comments
 (0)