Skip to content

Commit 4c89fb0

Browse files
author
Matt Mazzola
committed
Remove custom dts generation which did not allow using external dependencies, and use multiple .d.ts files. Update powerbi.ts to re-export other files.
1 parent 43df9ac commit 4c89fb0

12 files changed

Lines changed: 567 additions & 319 deletions

‎dist/embed.d.ts‎

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*! powerbi-client v2.0.0-beta.6 | (c) 2016 Microsoft Corporation MIT */
2+
import * as service from './service';
3+
import * as models from 'powerbi-models';
4+
import * as hpm from 'http-post-message';
5+
declare global {
6+
interface Document {
7+
mozCancelFullScreen: Function;
8+
msExitFullscreen: Function;
9+
}
10+
interface HTMLIFrameElement {
11+
mozRequestFullScreen: Function;
12+
msRequestFullscreen: Function;
13+
}
14+
}
15+
export interface IEmbedConfiguration {
16+
type?: string;
17+
id?: string;
18+
uniqueId?: string;
19+
embedUrl?: string;
20+
accessToken?: string;
21+
settings?: models.ISettings;
22+
}
23+
export interface IInternalEmbedConfiguration extends models.ILoadConfiguration {
24+
uniqueId: string;
25+
type: string;
26+
embedUrl: string;
27+
}
28+
export interface IInternalEventHandler<T> {
29+
test(event: service.IEvent<T>): boolean;
30+
handle(event: service.IEvent<T>): void;
31+
}
32+
export declare abstract class Embed {
33+
static accessTokenAttribute: string;
34+
static embedUrlAttribute: string;
35+
static nameAttribute: string;
36+
static typeAttribute: string;
37+
static type: string;
38+
private static defaultSettings;
39+
eventHandlers: IInternalEventHandler<any>[];
40+
hpm: hpm.HttpPostMessage;
41+
service: service.Service;
42+
element: HTMLElement;
43+
iframe: HTMLIFrameElement;
44+
config: IInternalEmbedConfiguration;
45+
/**
46+
* Note: there is circular reference between embeds and service
47+
* The service has list of all embeds on the host page, and each embed has reference to the service that created it.
48+
*/
49+
constructor(service: service.Service, hpmFactory: service.IHpmFactory, element: HTMLElement, config: IEmbedConfiguration);
50+
/**
51+
* Handler for when the iframe has finished loading the powerbi placeholder page.
52+
* This is used to inject configuration data such as id, access token, and settings etc
53+
* which allow iframe to load the actual report with authentication.
54+
*/
55+
load(config: models.ILoadConfiguration): Promise<void>;
56+
handleEvent(event: service.IEvent<any>): void;
57+
/**
58+
* Removes event handler(s) from list of handlers.
59+
*
60+
* If reference to existing handle function is specified remove specific handler.
61+
* If handler is not specified, remove all handlers for the event name specified.
62+
*
63+
* ```javascript
64+
* report.off('pageChanged')
65+
*
66+
* or
67+
*
68+
* const logHandler = function (event) {
69+
* console.log(event);
70+
* };
71+
*
72+
* report.off('pageChanged', logHandler);
73+
* ```
74+
*/
75+
off<T>(eventName: string, handler?: service.IEventHandler<T>): void;
76+
/**
77+
* Adds event handler for specific event.
78+
*
79+
* ```javascript
80+
* report.on('pageChanged', (event) => {
81+
* console.log('PageChanged: ', event.page.name);
82+
* });
83+
* ```
84+
*/
85+
on<T>(eventName: string, handler: service.IEventHandler<T>): void;
86+
/**
87+
* Get access token from first available location: config, attribute, global.
88+
*/
89+
private getAccessToken(globalAccessToken);
90+
/**
91+
* Get embed url from first available location: options, attribute.
92+
*/
93+
private getEmbedUrl();
94+
/**
95+
* Get unique id from first available location: options, attribute.
96+
* If neither is provided generate unique string.
97+
*/
98+
private getUniqueId();
99+
/**
100+
* Get report id from first available location: options, attribute.
101+
*/
102+
abstract getId(): string;
103+
/**
104+
* Request the browser to make the component's iframe fullscreen.
105+
*/
106+
fullscreen(): void;
107+
/**
108+
* Exit fullscreen.
109+
*/
110+
exitFullscreen(): void;
111+
/**
112+
* Return true if iframe is fullscreen,
113+
* otherwise return false
114+
*/
115+
private isFullscreen(iframe);
116+
}

‎dist/factories.d.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*! powerbi-client v2.0.0-beta.6 | (c) 2016 Microsoft Corporation MIT */
2+
/**
3+
* TODO: Need to find better place for these factory functions or refactor how we handle dependency injection
4+
*/
5+
import { IHpmFactory, IWpmpFactory, IRouterFactory } from './service';
6+
export { IHpmFactory, IWpmpFactory, IRouterFactory };
7+
/**
8+
* TODO: Need to get sdk version and settings from package.json, Generate config file via gulp task?
9+
*/
10+
export declare const hpmFactory: IHpmFactory;
11+
export declare const wpmpFactory: IWpmpFactory;
12+
export declare const routerFactory: IRouterFactory;

‎dist/powerbi.d.ts‎

Lines changed: 6 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,10 @@
11
/*! 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';
1348
declare global {
1359
interface Window {
13610
Powerbi: typeof Service;

0 commit comments

Comments
 (0)