diff --git a/dist/powerbi.js b/dist/powerbi.js index d20612dd..da24b876 100644 --- a/dist/powerbi.js +++ b/dist/powerbi.js @@ -156,10 +156,22 @@ return powerBiElement.powerBiEmbed; }; /** - * Remove component from the list of embedded components. + * 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. */ - PowerBi.prototype.remove = function (component) { - util_1.default.remove(function (x) { return x === component; }, this.embeds); + PowerBi.prototype.reset = function (element) { + var powerBiElement = element; + if (!powerBiElement.powerBiEmbed) { + throw new Error("You attempted to get an instance of powerbi component associated with element: " + element.outerHTML + " but there was no associated instance."); + } + /** Remove component from internal list */ + util_1.default.remove(function (x) { return x === powerBiElement.powerBiEmbed; }, this.embeds); + /** Delete property from html element */ + delete powerBiElement.powerBiEmbed; + /** Remove iframe from element by clearing innerHTML */ + var iframe = element.querySelector('iframe'); + if (iframe) { + iframe.remove(); + } }; /** * Handler for window message event. @@ -223,6 +235,7 @@ }; return PowerBi; }()); + exports.PowerBi = PowerBi; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = PowerBi; diff --git a/dist/powerbi.js.map b/dist/powerbi.js.map index 2293682e..10e59360 100644 --- a/dist/powerbi.js.map +++ b/dist/powerbi.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap f866f928c5e8d44b01f7","webpack:///./src/powerbi.ts","webpack:///./src/core.ts","webpack:///./src/embed.ts","webpack:///./src/util.ts","webpack:///./src/report.ts","webpack:///./src/tile.ts"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;ACtCA,kCAAoB,CAAQ,CAAC;AAE7B;;;;IAIG;AACG,OAAO,CAAC,OAAO,GAAG,cAAO,CAAC;AAC1B,OAAO,CAAC,OAAO,GAAG,IAAI,cA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;KACL,aAAC;AAAD,EAAC,CA3BmC,eAAK,GA2BxC;AA3BD;yBA2BC;;;;;;;;;;;;;ACjCD,mCAA8D,CAAS,CAAC;AAMxE;KAAkC,wBAAK;KAAvC;SAAkC,8BAAK;KAoBvC,CAAC;KAnBG,0BAAW,GAAX;SACI,IAAM,QAAQ,GAAG,gBAAK,CAAC,WAAW,WAAE,CAAC;SAErC,MAAM,CAAC,QAAQ,CAAC;KACpB,CAAC;KAED,mBAAI,GAAJ,UAAK,OAAsB,EAAE,SAA0B;SAA1B,yBAA0B,GAA1B,iBAA0B;SACnD,EAAE,EAAC,SAAS,IAAI,OAAO,OAAO,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC;aAC7C,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;SACvF,CAAC;SAED,IAAM,OAAO,GAAG;aACZ,MAAM,EAAE,UAAU;aAClB,MAAM,EAAE,OAAO,CAAC,EAAE;aAClB,WAAW,EAAE,IAAI;UACpB,CAAC;SAEF,gBAAK,CAAC,IAAI,YAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;KAC5C,CAAC;KACL,WAAC;AAAD,EAAC,CApBiC,eAAK,GAoBtC;AApBD;uBAoBC","file":"powerbi.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap f866f928c5e8d44b01f7\n **/","import PowerBi from './core';\r\n\r\n/**\r\n * Make PowerBi available on global object for use in apps without module loading support.\r\n * Save class to allow creating an instance of the service.\r\n * Create instance of class with default config for normal usage.\r\n */\r\n(window).Powerbi = PowerBi;\r\n(window).powerbi = new PowerBi();\n\n\n/** WEBPACK FOOTER **\n ** ./src/powerbi.ts\n **/","import { default as Embed, IEmbedConstructor, IEmbedOptions } from './embed';\r\nimport Report from './report';\r\nimport Tile from './tile';\r\nimport Utils from './util';\r\n\r\nexport interface IPowerBiElement extends HTMLElement {\r\n powerBiEmbed: Embed;\r\n}\r\n\r\nexport interface IPowerBiConfiguration {\r\n autoEmbedOnContentLoaded?: boolean;\r\n onError?: (error: any) => any;\r\n}\r\n\r\nexport default class PowerBi {\r\n /**\r\n * List of components this service can embed.\r\n */\r\n private static components: IEmbedConstructor[] = [\r\n Tile,\r\n Report\r\n ];\r\n /**\r\n * Mapping of event names from iframe postMessage to their name percieved by parent DOM.\r\n * Example: User clicks on embeded report which is inside iframe. The iframe code resends \r\n * event as postMessage with { event: 'reportClicked', ... } and this name is converted to hyphenated\r\n * name and dispatched from the parent element of the iframe to simulate the event bubbling through two\r\n * different windows / DOMs\r\n */\r\n private static eventMap = {\r\n 'tileClicked': 'tile-click',\r\n 'tileLoaded': 'tile-load',\r\n 'reportPageLoaded': 'report-load'\r\n };\r\n \r\n /**\r\n * Default configuration for service.\r\n */\r\n private static defaultConfig: IPowerBiConfiguration = {\r\n autoEmbedOnContentLoaded: false,\r\n onError: (...args) => console.log(args[0], args.slice(1))\r\n };\r\n\r\n /** Save access token as fallback/global token to use when local token for report/tile is not provided. */\r\n accessToken: string;\r\n \r\n /** Configuration object */\r\n private config: IPowerBiConfiguration;\r\n \r\n /** List of components (Reports/Tiles) that have been embedded using this service instance. */\r\n private embeds: Embed[];\r\n \r\n constructor(config: IPowerBiConfiguration = {}) {\r\n this.embeds = [];\r\n window.addEventListener('message', this.onReceiveMessage.bind(this), false);\r\n \r\n // TODO: Change when Object.assign is available.\r\n this.config = Utils.assign({}, PowerBi.defaultConfig, config);\r\n \r\n if (this.config.autoEmbedOnContentLoaded) {\r\n this.enableAutoEmbed();\r\n }\r\n }\r\n \r\n /**\r\n * Handler for DOMContentLoaded which searches DOM for elements having 'powerbi-embed-url' attribute\r\n * and automatically attempts to embed a powerbi component based on information from the attributes.\r\n * Only runs if `config.autoEmbedOnContentLoaded` is true when the service is created.\r\n */\r\n init(container?: HTMLElement): void {\r\n container = (container && container instanceof HTMLElement) ? container : document.body;\r\n \r\n const elements = Array.prototype.slice.call(container.querySelectorAll(`[${Embed.embedUrlAttribute}]`));\r\n elements.forEach(element => this.embed(element));\r\n }\r\n \r\n /**\r\n * Given an html element embed component based on configuration.\r\n * If component has already been created and attached to element re-use component instance and existing iframe,\r\n * otherwise create a new component instance\r\n */\r\n embed(element: HTMLElement, config: IEmbedOptions = {}): Embed {\r\n let component: Embed;\r\n let powerBiElement = element;\r\n \r\n if (powerBiElement.powerBiEmbed) {\r\n component = this.embedExisting(powerBiElement, config);\r\n }\r\n else {\r\n component = this.embedNew(powerBiElement, config);\r\n }\r\n \r\n return component;\r\n }\r\n \r\n /**\r\n * Given an html element embed component base configuration.\r\n * Save component instance on element for later lookup. \r\n */\r\n private embedNew(element: IPowerBiElement, config: IEmbedOptions): Embed {\r\n const componentType = config.type || element.getAttribute(Embed.typeAttribute);\r\n if (!componentType) {\r\n throw new Error(`Attempted to embed using config ${JSON.stringify(config)} on element ${element.outerHTML}, but could not determine what type of component to embed. You must specify a type in the configuration or as an attribute such as '${Embed.typeAttribute}=\"${Report.name.toLowerCase()}\"'.`);\r\n }\r\n \r\n // Save type on configuration so it can be referenced later at known location\r\n config.type = componentType;\r\n \r\n const Component = Utils.find(component => componentType === component.name.toLowerCase(), PowerBi.components);\r\n if (!Component) {\r\n throw new Error(`Attempted to embed component of type: ${componentType} but did not find any matching component. Please verify the type you specified is intended.`);\r\n }\r\n \r\n // TODO: Consider removing in favor of passing reference to `this` in constructor\r\n // The getGlobalAccessToken function is only here so that the components (Tile | Report) can get the global access token without needing reference\r\n // to the service that they are registered within becaues it creates circular dependencies\r\n config.getGlobalAccessToken = () => this.accessToken;\r\n \r\n const component = new Component(element, config);\r\n element.powerBiEmbed = component;\r\n this.embeds.push(component);\r\n \r\n return component;\r\n }\r\n \r\n private embedExisting(element: IPowerBiElement, config: IEmbedOptions): Embed {\r\n const component = Utils.find(x => x.element === element, this.embeds);\r\n if (!component) {\r\n throw new Error(`Attempted to embed using config ${JSON.stringify(config)} on element ${element.outerHTML} which already has embedded comopnent associated, but could not find the existing comopnent in the list of active components. This could indicate the embeds list is out of sync with the DOM, or the component is referencing the incorrect HTML element.`);\r\n }\r\n \r\n component.load(config, true);\r\n \r\n return component;\r\n }\r\n \r\n /**\r\n * Adds event handler for DOMContentLoaded which finds all elements in DOM with attribute powerbi-embed-url\r\n * then attempts to initiate the embed process based on data from other powerbi-* attributes.\r\n * (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.)\r\n */\r\n enableAutoEmbed() {\r\n window.addEventListener('DOMContentLoaded', (event: Event) => this.init(document.body), false);\r\n }\r\n \r\n /**\r\n * Returns instance of component associated with element.\r\n */\r\n get(element: HTMLElement) {\r\n const powerBiElement = element;\r\n \r\n if (!powerBiElement.powerBiEmbed) {\r\n throw new Error(`You attempted to get an instance of powerbi component associated with element: ${element.outerHTML} but there was no associated instance.`);\r\n }\r\n \r\n return powerBiElement.powerBiEmbed;\r\n }\r\n \r\n /**\r\n * Remove component from the list of embedded components.\r\n */\r\n remove(component: Embed): void {\r\n Utils.remove(x => x === component, this.embeds);\r\n }\r\n \r\n /**\r\n * Handler for window message event.\r\n * 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\r\n * to simulate the event bubbling through the two separate windows / DOMs.\r\n * \r\n * If an error occurs when parsing event.data call error handler provided during configuration.\r\n */\r\n private onReceiveMessage(event: MessageEvent): void {\r\n if (!event) {\r\n return;\r\n }\r\n\r\n try {\r\n // Only raise the event on the embed that matches the post message origin\r\n const embed = Utils.find(embed => event.source === embed.iframe.contentWindow, this.embeds);\r\n if(embed) {\r\n let messageData = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;\r\n Utils.raiseCustomEvent(embed.element, PowerBi.eventMap[messageData.event], messageData);\r\n }\r\n }\r\n catch (e) {\r\n if (typeof this.config.onError === 'function') {\r\n this.config.onError.call(window, e);\r\n }\r\n else {\r\n throw e;\r\n }\r\n }\r\n }\r\n}\r\n\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/core.ts\n **/","import Utils from './util';\r\n\r\ndeclare global {\r\n interface Document {\r\n // Mozilla Fullscreen\r\n mozCancelFullScreen: Function;\r\n \r\n // Ms Fullscreen\r\n msExitFullscreen: Function;\r\n }\r\n \r\n interface HTMLIFrameElement {\r\n // Mozilla Fullscreen\r\n mozRequestFullScreen: Function;\r\n \r\n // Ms Fullscreen\r\n msRequestFullscreen: Function;\r\n }\r\n}\r\n\r\nexport interface ILoadMessage {\r\n action: string;\r\n accessToken: string;\r\n}\r\n\r\nexport interface IEmbedOptions {\r\n type?: string;\r\n id?: string;\r\n accessToken?: string;\r\n embedUrl?: string;\r\n webUrl?: string;\r\n name?: string;\r\n filterPaneEnabled?: boolean;\r\n getGlobalAccessToken?: () => string;\r\n}\r\n\r\nexport interface IEmbedConstructor {\r\n new(...args: any[]): Embed;\r\n}\r\n\r\nabstract class Embed {\r\n public static embedUrlAttribute = 'powerbi-embed-url';\r\n public static accessTokenAttribute = 'powerbi-access-token';\r\n public static typeAttribute = 'powerbi-type';\r\n \r\n /**\r\n * Attribute used to specify type of visual.\r\n * Example: `
`\r\n */\r\n public static name: string;\r\n /**\r\n * Default options for embeddable component.\r\n */\r\n private static defaultOptions: IEmbedOptions = {\r\n filterPaneEnabled: true\r\n };\r\n \r\n element: HTMLElement;\r\n iframe: HTMLIFrameElement;\r\n options: IEmbedOptions;\r\n \r\n constructor(element: HTMLElement, options: IEmbedOptions) {\r\n this.element = element;\r\n \r\n // TODO: Change when Object.assign is available.\r\n this.options = Utils.assign({}, Embed.defaultOptions, options);\r\n this.options.accessToken = this.getAccessToken();\r\n this.options.embedUrl = this.getEmbedUrl();\r\n \r\n const iframeHtml = ``;\r\n \r\n this.element.innerHTML = iframeHtml;\r\n this.iframe = this.element.childNodes[0];\r\n this.iframe.addEventListener('load', () => this.load(this.options, false), false);\r\n }\r\n \r\n /**\r\n * Handler for when the iframe has finished loading the powerbi placeholder page.\r\n * This is used to inject configuration options such as access token, loadAction, etc\r\n * which allow iframe to load the actual report with authentication.\r\n */\r\n load(options: IEmbedOptions, requireId: boolean = false, message: ILoadMessage = null) {\r\n if(!message) {\r\n throw new Error(`You called load without providing message properties from the concrete embeddable class.`);\r\n }\r\n \r\n const baseMessage = {\r\n accessToken: options.accessToken\r\n };\r\n \r\n Utils.assign(message, baseMessage);\r\n \r\n const event = {\r\n message\r\n };\r\n \r\n Utils.raiseCustomEvent(this.element, event.message.action, event);\r\n this.iframe.contentWindow.postMessage(JSON.stringify(event.message), '*');\r\n }\r\n \r\n /**\r\n * Get access token from first available location: options, attribute, global.\r\n */\r\n private getAccessToken(): string {\r\n const accessToken = this.options.accessToken || this.element.getAttribute(Embed.accessTokenAttribute) || this.options.getGlobalAccessToken();\r\n \r\n if (!accessToken) {\r\n throw new Error(`No access token was found for element. You must specify an access token directly on the element using attribute '${Embed.accessTokenAttribute}' or specify a global token at: powerbi.accessToken.`);\r\n }\r\n \r\n return accessToken;\r\n }\r\n \r\n /**\r\n * Get embed url from first available location: options, attribute.\r\n */\r\n protected getEmbedUrl(): string {\r\n const embedUrl = this.options.embedUrl || this.element.getAttribute(Embed.embedUrlAttribute);\r\n \r\n if(typeof embedUrl !== 'string' || embedUrl.length === 0) {\r\n throw new Error(`Embed Url is required, but it was not found. You must provide an embed url either as part of embed configuration or as attribute '${Embed.embedUrlAttribute}'.`);\r\n }\r\n \r\n return embedUrl; \r\n }\r\n\r\n /**\r\n * Request the browser to make the components iframe fullscreen.\r\n */\r\n fullscreen(): void {\r\n const requestFullScreen = this.iframe.requestFullscreen || this.iframe.msRequestFullscreen || this.iframe.mozRequestFullScreen || this.iframe.webkitRequestFullscreen;\r\n requestFullScreen.call(this.iframe);\r\n }\r\n \r\n /**\r\n * Exit fullscreen.\r\n */\r\n exitFullscreen(): void {\r\n if (!this.isFullscreen(this.iframe)) {\r\n return;\r\n }\r\n\r\n const exitFullscreen = document.exitFullscreen || document.mozCancelFullScreen || document.webkitExitFullscreen || document.msExitFullscreen;\r\n exitFullscreen.call(document);\r\n }\r\n \r\n /**\r\n * Return true if iframe is fullscreen,\r\n * otherwise return false \r\n */\r\n private isFullscreen(iframe: HTMLIFrameElement): boolean {\r\n const options = ['fullscreenElement', 'webkitFullscreenElement', 'mozFullscreenScreenElement', 'msFullscreenElement'];\r\n \r\n return options.some(option => document[option] === iframe);\r\n }\r\n}\r\n\r\nexport default Embed;\n\n\n/** WEBPACK FOOTER **\n ** ./src/embed.ts\n **/","export default class Utils {\r\n static raiseCustomEvent(element: HTMLElement, eventName: string, eventData: any) {\r\n let customEvent;\r\n if (typeof CustomEvent === 'function') {\r\n customEvent = new CustomEvent(eventName, {\r\n detail: eventData,\r\n bubbles: true,\r\n cancelable: true\r\n });\r\n } else {\r\n customEvent = document.createEvent('CustomEvent');\r\n customEvent.initCustomEvent(eventName, true, true, eventData);\r\n }\r\n\r\n element.dispatchEvent(customEvent);\r\n if (customEvent.defaultPrevented || !customEvent.returnValue) {\r\n return;\r\n }\r\n\r\n // TODO: Remove this? Should be better way to handle events than using eval?\r\n // What is use case?
\r\n const inlineEventAttr = 'on' + eventName.replace('-', '');\r\n const inlineScript = element.getAttribute(inlineEventAttr);\r\n if (inlineScript) {\r\n eval.call(element, inlineScript);\r\n }\r\n }\r\n \r\n static findIndex(predicate: (T) => boolean, xs: T[]): number {\r\n if(!Array.isArray(xs)) {\r\n throw new Error(`You attempted to call find with second parameter that was not an array. You passed: ${xs}`);\r\n }\r\n \r\n let index;\r\n xs.some((x, i) => {\r\n if(predicate(x)) {\r\n index = i;\r\n return true;\r\n }\r\n });\r\n \r\n return index;\r\n }\r\n \r\n static find(predicate: (T) => boolean, xs: T[]): T {\r\n const index = Utils.findIndex(predicate, xs);\r\n return xs[index];\r\n }\r\n \r\n static remove(predicate: (T) => boolean, xs: T[]): void {\r\n const index = Utils.findIndex(predicate, xs);\r\n xs.splice(index, 1);\r\n }\r\n \r\n // See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\r\n // TODO: replace in favor of using polyfill\r\n static assign = function (...args) {\r\n var target = args[0];\r\n \r\n 'use strict';\r\n if (target === undefined || target === null) {\r\n throw new TypeError('Cannot convert undefined or null to object');\r\n }\r\n\r\n var output = Object(target);\r\n for (var index = 1; index < arguments.length; index++) {\r\n var source = arguments[index];\r\n if (source !== undefined && source !== null) {\r\n for (var nextKey in source) {\r\n if (source.hasOwnProperty(nextKey)) {\r\n output[nextKey] = source[nextKey];\r\n }\r\n }\r\n }\r\n }\r\n return output;\r\n };\r\n}\n\n\n/** WEBPACK FOOTER **\n ** ./src/util.ts\n **/","import { default as Embed, IEmbedOptions, ILoadMessage } from './embed';\r\n\r\nexport interface IReportLoadMessage extends ILoadMessage {\r\n reportId: string\r\n}\r\n\r\nexport default class Report extends Embed {\r\n getEmbedUrl(): string {\r\n let embedUrl = super.getEmbedUrl();\r\n \r\n // TODO: Need safe way to add url parameters.\r\n // We are assuming embedUrls use query parameters to supply id of visual\r\n // so must prefix with '&'.\r\n if(!this.options.filterPaneEnabled) {\r\n embedUrl += `&filterPaneEnabled=false`;\r\n }\r\n\r\n return embedUrl;\r\n }\r\n\r\n load(options: IEmbedOptions, requireId: boolean = false) {\r\n if(requireId && typeof options.id !== 'string') {\r\n throw new Error(`id must be specified when loading reports on existing elements.`);\r\n }\r\n \r\n const message: IReportLoadMessage = {\r\n action: 'loadReport',\r\n reportId: options.id,\r\n accessToken: null\r\n };\r\n \r\n super.load(options, requireId, message);\r\n }\r\n}\n\n\n/** WEBPACK FOOTER **\n ** ./src/report.ts\n **/","import { default as Embed, IEmbedOptions, ILoadMessage } from './embed';\r\n\r\nexport interface ITileLoadMessage extends ILoadMessage {\r\n tileId: string\r\n}\r\n\r\nexport default class Tile extends Embed {\r\n getEmbedUrl(): string {\r\n const embedUrl = super.getEmbedUrl();\r\n\r\n return embedUrl;\r\n }\r\n \r\n load(options: IEmbedOptions, requireId: boolean = false) {\r\n if(requireId && typeof options.id !== 'string') {\r\n throw new Error(`id must be specified when loading reports on existing elements.`);\r\n }\r\n \r\n const message = {\r\n action: 'loadTile',\r\n tileId: options.id,\r\n accessToken: null\r\n };\r\n \r\n super.load(options, requireId, message);\r\n }\r\n}\n\n\n/** WEBPACK FOOTER **\n ** ./src/tile.ts\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap c1632b616db0fe89d58c","webpack:///./src/powerbi.ts","webpack:///./src/core.ts","webpack:///./src/embed.ts","webpack:///./src/util.ts","webpack:///./src/report.ts","webpack:///./src/tile.ts"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;ACtCA,kCAAoB,CAAQ,CAAC;AAE7B;;;;IAIG;AACG,OAAO,CAAC,OAAO,GAAG,cAAO,CAAC;AAC1B,OAAO,CAAC,OAAO,GAAG,IAAI,cAAO,EAAE,CAAC;;;;;;;;ACRtC,mCAAmE,CAAS,CAAC;AAC7E,oCAA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ules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap c1632b616db0fe89d58c\n **/","import PowerBi from './core';\r\n\r\n/**\r\n * Make PowerBi available on global object for use in apps without module loading support.\r\n * Save class to allow creating an instance of the service.\r\n * Create instance of class with default config for normal usage.\r\n */\r\n(window).Powerbi = PowerBi;\r\n(window).powerbi = new PowerBi();\n\n\n/** WEBPACK FOOTER **\n ** ./src/powerbi.ts\n **/","import { default as Embed, IEmbedConstructor, IEmbedOptions } from './embed';\r\nimport Report from './report';\r\nimport Tile from './tile';\r\nimport Utils from './util';\r\n\r\nexport interface IPowerBiElement extends HTMLElement {\r\n powerBiEmbed: Embed;\r\n}\r\n\r\nexport interface IPowerBiConfiguration {\r\n autoEmbedOnContentLoaded?: boolean;\r\n onError?: (error: any) => any;\r\n}\r\n\r\nexport class PowerBi {\r\n /**\r\n * List of components this service can embed.\r\n */\r\n private static components: IEmbedConstructor[] = [\r\n Tile,\r\n Report\r\n ];\r\n /**\r\n * Mapping of event names from iframe postMessage to their name percieved by parent DOM.\r\n * Example: User clicks on embeded report which is inside iframe. The iframe code resends \r\n * event as postMessage with { event: 'reportClicked', ... } and this name is converted to hyphenated\r\n * name and dispatched from the parent element of the iframe to simulate the event bubbling through two\r\n * different windows / DOMs\r\n */\r\n private static eventMap = {\r\n 'tileClicked': 'tile-click',\r\n 'tileLoaded': 'tile-load',\r\n 'reportPageLoaded': 'report-load'\r\n };\r\n \r\n /**\r\n * Default configuration for service.\r\n */\r\n private static defaultConfig: IPowerBiConfiguration = {\r\n autoEmbedOnContentLoaded: false,\r\n onError: (...args) => console.log(args[0], args.slice(1))\r\n };\r\n\r\n /** Save access token as fallback/global token to use when local token for report/tile is not provided. */\r\n accessToken: string;\r\n \r\n /** Configuration object */\r\n private config: IPowerBiConfiguration;\r\n \r\n /** List of components (Reports/Tiles) that have been embedded using this service instance. */\r\n private embeds: Embed[];\r\n \r\n constructor(config: IPowerBiConfiguration = {}) {\r\n this.embeds = [];\r\n window.addEventListener('message', this.onReceiveMessage.bind(this), false);\r\n \r\n // TODO: Change when Object.assign is available.\r\n this.config = Utils.assign({}, PowerBi.defaultConfig, config);\r\n \r\n if (this.config.autoEmbedOnContentLoaded) {\r\n this.enableAutoEmbed();\r\n }\r\n }\r\n \r\n /**\r\n * Handler for DOMContentLoaded which searches DOM for elements having 'powerbi-embed-url' attribute\r\n * and automatically attempts to embed a powerbi component based on information from the attributes.\r\n * Only runs if `config.autoEmbedOnContentLoaded` is true when the service is created.\r\n */\r\n init(container?: HTMLElement): void {\r\n container = (container && container instanceof HTMLElement) ? container : document.body;\r\n \r\n const elements = Array.prototype.slice.call(container.querySelectorAll(`[${Embed.embedUrlAttribute}]`));\r\n elements.forEach(element => this.embed(element));\r\n }\r\n \r\n /**\r\n * Given an html element embed component based on configuration.\r\n * If component has already been created and attached to element re-use component instance and existing iframe,\r\n * otherwise create a new component instance\r\n */\r\n embed(element: HTMLElement, config: IEmbedOptions = {}): Embed {\r\n let component: Embed;\r\n let powerBiElement = element;\r\n \r\n if (powerBiElement.powerBiEmbed) {\r\n component = this.embedExisting(powerBiElement, config);\r\n }\r\n else {\r\n component = this.embedNew(powerBiElement, config);\r\n }\r\n \r\n return component;\r\n }\r\n \r\n /**\r\n * Given an html element embed component base configuration.\r\n * Save component instance on element for later lookup. \r\n */\r\n private embedNew(element: IPowerBiElement, config: IEmbedOptions): Embed {\r\n const componentType = config.type || element.getAttribute(Embed.typeAttribute);\r\n if (!componentType) {\r\n throw new Error(`Attempted to embed using config ${JSON.stringify(config)} on element ${element.outerHTML}, but could not determine what type of component to embed. You must specify a type in the configuration or as an attribute such as '${Embed.typeAttribute}=\"${Report.name.toLowerCase()}\"'.`);\r\n }\r\n \r\n // Save type on configuration so it can be referenced later at known location\r\n config.type = componentType;\r\n \r\n const Component = Utils.find(component => componentType === component.name.toLowerCase(), PowerBi.components);\r\n if (!Component) {\r\n throw new Error(`Attempted to embed component of type: ${componentType} but did not find any matching component. Please verify the type you specified is intended.`);\r\n }\r\n \r\n // TODO: Consider removing in favor of passing reference to `this` in constructor\r\n // The getGlobalAccessToken function is only here so that the components (Tile | Report) can get the global access token without needing reference\r\n // to the service that they are registered within becaues it creates circular dependencies\r\n config.getGlobalAccessToken = () => this.accessToken;\r\n \r\n const component = new Component(element, config);\r\n element.powerBiEmbed = component;\r\n this.embeds.push(component);\r\n \r\n return component;\r\n }\r\n \r\n private embedExisting(element: IPowerBiElement, config: IEmbedOptions): Embed {\r\n const component = Utils.find(x => x.element === element, this.embeds);\r\n if (!component) {\r\n throw new Error(`Attempted to embed using config ${JSON.stringify(config)} on element ${element.outerHTML} which already has embedded comopnent associated, but could not find the existing comopnent in the list of active components. This could indicate the embeds list is out of sync with the DOM, or the component is referencing the incorrect HTML element.`);\r\n }\r\n \r\n component.load(config, true);\r\n \r\n return component;\r\n }\r\n \r\n /**\r\n * Adds event handler for DOMContentLoaded which finds all elements in DOM with attribute powerbi-embed-url\r\n * then attempts to initiate the embed process based on data from other powerbi-* attributes.\r\n * (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.)\r\n */\r\n enableAutoEmbed() {\r\n window.addEventListener('DOMContentLoaded', (event: Event) => this.init(document.body), false);\r\n }\r\n \r\n /**\r\n * Returns instance of component associated with element.\r\n */\r\n get(element: HTMLElement) {\r\n const powerBiElement = element;\r\n \r\n if (!powerBiElement.powerBiEmbed) {\r\n throw new Error(`You attempted to get an instance of powerbi component associated with element: ${element.outerHTML} but there was no associated instance.`);\r\n }\r\n \r\n return powerBiElement.powerBiEmbed;\r\n }\r\n \r\n /**\r\n * 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.\r\n */\r\n reset(element: HTMLElement) {\r\n const powerBiElement = element;\r\n \r\n if (!powerBiElement.powerBiEmbed) {\r\n throw new Error(`You attempted to get an instance of powerbi component associated with element: ${element.outerHTML} but there was no associated instance.`);\r\n }\r\n \r\n /** Remove component from internal list */\r\n Utils.remove(x => x === powerBiElement.powerBiEmbed, this.embeds);\r\n /** Delete property from html element */\r\n delete powerBiElement.powerBiEmbed;\r\n /** Remove iframe from element by clearing innerHTML */\r\n \r\n const iframe = element.querySelector('iframe');\r\n if(iframe) {\r\n iframe.remove();\r\n }\r\n }\r\n \r\n /**\r\n * Handler for window message event.\r\n * 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\r\n * to simulate the event bubbling through the two separate windows / DOMs.\r\n * \r\n * If an error occurs when parsing event.data call error handler provided during configuration.\r\n */\r\n private onReceiveMessage(event: MessageEvent): void {\r\n if (!event) {\r\n return;\r\n }\r\n\r\n try {\r\n // Only raise the event on the embed that matches the post message origin\r\n const embed = Utils.find(embed => event.source === embed.iframe.contentWindow, this.embeds);\r\n if(embed) {\r\n let messageData = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;\r\n Utils.raiseCustomEvent(embed.element, PowerBi.eventMap[messageData.event], messageData);\r\n }\r\n }\r\n catch (e) {\r\n if (typeof this.config.onError === 'function') {\r\n this.config.onError.call(window, e);\r\n }\r\n else {\r\n throw e;\r\n }\r\n }\r\n }\r\n}\r\n\r\nexport default PowerBi;\n\n\n/** WEBPACK FOOTER **\n ** ./src/core.ts\n **/","import Utils from './util';\r\n\r\ndeclare global {\r\n interface Document {\r\n // Mozilla Fullscreen\r\n mozCancelFullScreen: Function;\r\n \r\n // Ms Fullscreen\r\n msExitFullscreen: Function;\r\n }\r\n \r\n interface HTMLIFrameElement {\r\n // Mozilla Fullscreen\r\n mozRequestFullScreen: Function;\r\n \r\n // Ms Fullscreen\r\n msRequestFullscreen: Function;\r\n }\r\n}\r\n\r\nexport interface ILoadMessage {\r\n action: string;\r\n accessToken: string;\r\n}\r\n\r\nexport interface IEmbedOptions {\r\n type?: string;\r\n id?: string;\r\n accessToken?: string;\r\n embedUrl?: string;\r\n webUrl?: string;\r\n name?: string;\r\n filterPaneEnabled?: boolean;\r\n getGlobalAccessToken?: () => string;\r\n}\r\n\r\nexport interface IEmbedConstructor {\r\n new(...args: any[]): Embed;\r\n}\r\n\r\nabstract class Embed {\r\n public static embedUrlAttribute = 'powerbi-embed-url';\r\n public static accessTokenAttribute = 'powerbi-access-token';\r\n public static typeAttribute = 'powerbi-type';\r\n \r\n /**\r\n * Attribute used to specify type of visual.\r\n * Example: `
`\r\n */\r\n public static name: string;\r\n /**\r\n * Default options for embeddable component.\r\n */\r\n private static defaultOptions: IEmbedOptions = {\r\n filterPaneEnabled: true\r\n };\r\n \r\n element: HTMLElement;\r\n iframe: HTMLIFrameElement;\r\n options: IEmbedOptions;\r\n \r\n constructor(element: HTMLElement, options: IEmbedOptions) {\r\n this.element = element;\r\n \r\n // TODO: Change when Object.assign is available.\r\n this.options = Utils.assign({}, Embed.defaultOptions, options);\r\n this.options.accessToken = this.getAccessToken();\r\n this.options.embedUrl = this.getEmbedUrl();\r\n \r\n const iframeHtml = ``;\r\n \r\n this.element.innerHTML = iframeHtml;\r\n this.iframe = this.element.childNodes[0];\r\n this.iframe.addEventListener('load', () => this.load(this.options, false), false);\r\n }\r\n \r\n /**\r\n * Handler for when the iframe has finished loading the powerbi placeholder page.\r\n * This is used to inject configuration options such as access token, loadAction, etc\r\n * which allow iframe to load the actual report with authentication.\r\n */\r\n load(options: IEmbedOptions, requireId: boolean = false, message: ILoadMessage = null) {\r\n if(!message) {\r\n throw new Error(`You called load without providing message properties from the concrete embeddable class.`);\r\n }\r\n \r\n const baseMessage = {\r\n accessToken: options.accessToken\r\n };\r\n \r\n Utils.assign(message, baseMessage);\r\n \r\n const event = {\r\n message\r\n };\r\n \r\n Utils.raiseCustomEvent(this.element, event.message.action, event);\r\n this.iframe.contentWindow.postMessage(JSON.stringify(event.message), '*');\r\n }\r\n \r\n /**\r\n * Get access token from first available location: options, attribute, global.\r\n */\r\n private getAccessToken(): string {\r\n const accessToken = this.options.accessToken || this.element.getAttribute(Embed.accessTokenAttribute) || this.options.getGlobalAccessToken();\r\n \r\n if (!accessToken) {\r\n throw new Error(`No access token was found for element. You must specify an access token directly on the element using attribute '${Embed.accessTokenAttribute}' or specify a global token at: powerbi.accessToken.`);\r\n }\r\n \r\n return accessToken;\r\n }\r\n \r\n /**\r\n * Get embed url from first available location: options, attribute.\r\n */\r\n protected getEmbedUrl(): string {\r\n const embedUrl = this.options.embedUrl || this.element.getAttribute(Embed.embedUrlAttribute);\r\n \r\n if(typeof embedUrl !== 'string' || embedUrl.length === 0) {\r\n throw new Error(`Embed Url is required, but it was not found. You must provide an embed url either as part of embed configuration or as attribute '${Embed.embedUrlAttribute}'.`);\r\n }\r\n \r\n return embedUrl; \r\n }\r\n\r\n /**\r\n * Request the browser to make the components iframe fullscreen.\r\n */\r\n fullscreen(): void {\r\n const requestFullScreen = this.iframe.requestFullscreen || this.iframe.msRequestFullscreen || this.iframe.mozRequestFullScreen || this.iframe.webkitRequestFullscreen;\r\n requestFullScreen.call(this.iframe);\r\n }\r\n \r\n /**\r\n * Exit fullscreen.\r\n */\r\n exitFullscreen(): void {\r\n if (!this.isFullscreen(this.iframe)) {\r\n return;\r\n }\r\n\r\n const exitFullscreen = document.exitFullscreen || document.mozCancelFullScreen || document.webkitExitFullscreen || document.msExitFullscreen;\r\n exitFullscreen.call(document);\r\n }\r\n \r\n /**\r\n * Return true if iframe is fullscreen,\r\n * otherwise return false \r\n */\r\n private isFullscreen(iframe: HTMLIFrameElement): boolean {\r\n const options = ['fullscreenElement', 'webkitFullscreenElement', 'mozFullscreenScreenElement', 'msFullscreenElement'];\r\n \r\n return options.some(option => document[option] === iframe);\r\n }\r\n}\r\n\r\nexport default Embed;\n\n\n/** WEBPACK FOOTER **\n ** ./src/embed.ts\n **/","export default class Utils {\r\n static raiseCustomEvent(element: HTMLElement, eventName: string, eventData: any) {\r\n let customEvent;\r\n if (typeof CustomEvent === 'function') {\r\n customEvent = new CustomEvent(eventName, {\r\n detail: eventData,\r\n bubbles: true,\r\n cancelable: true\r\n });\r\n } else {\r\n customEvent = document.createEvent('CustomEvent');\r\n customEvent.initCustomEvent(eventName, true, true, eventData);\r\n }\r\n\r\n element.dispatchEvent(customEvent);\r\n if (customEvent.defaultPrevented || !customEvent.returnValue) {\r\n return;\r\n }\r\n\r\n // TODO: Remove this? Should be better way to handle events than using eval?\r\n // What is use case?
\r\n const inlineEventAttr = 'on' + eventName.replace('-', '');\r\n const inlineScript = element.getAttribute(inlineEventAttr);\r\n if (inlineScript) {\r\n eval.call(element, inlineScript);\r\n }\r\n }\r\n \r\n static findIndex(predicate: (T) => boolean, xs: T[]): number {\r\n if(!Array.isArray(xs)) {\r\n throw new Error(`You attempted to call find with second parameter that was not an array. You passed: ${xs}`);\r\n }\r\n \r\n let index;\r\n xs.some((x, i) => {\r\n if(predicate(x)) {\r\n index = i;\r\n return true;\r\n }\r\n });\r\n \r\n return index;\r\n }\r\n \r\n static find(predicate: (T) => boolean, xs: T[]): T {\r\n const index = Utils.findIndex(predicate, xs);\r\n return xs[index];\r\n }\r\n \r\n static remove(predicate: (T) => boolean, xs: T[]): void {\r\n const index = Utils.findIndex(predicate, xs);\r\n xs.splice(index, 1);\r\n }\r\n \r\n // See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\r\n // TODO: replace in favor of using polyfill\r\n static assign = function (...args) {\r\n var target = args[0];\r\n \r\n 'use strict';\r\n if (target === undefined || target === null) {\r\n throw new TypeError('Cannot convert undefined or null to object');\r\n }\r\n\r\n var output = Object(target);\r\n for (var index = 1; index < arguments.length; index++) {\r\n var source = arguments[index];\r\n if (source !== undefined && source !== null) {\r\n for (var nextKey in source) {\r\n if (source.hasOwnProperty(nextKey)) {\r\n output[nextKey] = source[nextKey];\r\n }\r\n }\r\n }\r\n }\r\n return output;\r\n };\r\n}\n\n\n/** WEBPACK FOOTER **\n ** ./src/util.ts\n **/","import { default as Embed, IEmbedOptions, ILoadMessage } from './embed';\r\n\r\nexport interface IReportLoadMessage extends ILoadMessage {\r\n reportId: string\r\n}\r\n\r\nexport default class Report extends Embed {\r\n getEmbedUrl(): string {\r\n let embedUrl = super.getEmbedUrl();\r\n \r\n // TODO: Need safe way to add url parameters.\r\n // We are assuming embedUrls use query parameters to supply id of visual\r\n // so must prefix with '&'.\r\n if(!this.options.filterPaneEnabled) {\r\n embedUrl += `&filterPaneEnabled=false`;\r\n }\r\n\r\n return embedUrl;\r\n }\r\n\r\n load(options: IEmbedOptions, requireId: boolean = false) {\r\n if(requireId && typeof options.id !== 'string') {\r\n throw new Error(`id must be specified when loading reports on existing elements.`);\r\n }\r\n \r\n const message: IReportLoadMessage = {\r\n action: 'loadReport',\r\n reportId: options.id,\r\n accessToken: null\r\n };\r\n \r\n super.load(options, requireId, message);\r\n }\r\n}\n\n\n/** WEBPACK FOOTER **\n ** ./src/report.ts\n **/","import { default as Embed, IEmbedOptions, ILoadMessage } from './embed';\r\n\r\nexport interface ITileLoadMessage extends ILoadMessage {\r\n tileId: string\r\n}\r\n\r\nexport default class Tile extends Embed {\r\n getEmbedUrl(): string {\r\n const embedUrl = super.getEmbedUrl();\r\n\r\n return embedUrl;\r\n }\r\n \r\n load(options: IEmbedOptions, requireId: boolean = false) {\r\n if(requireId && typeof options.id !== 'string') {\r\n throw new Error(`id must be specified when loading reports on existing elements.`);\r\n }\r\n \r\n const message = {\r\n action: 'loadTile',\r\n tileId: options.id,\r\n accessToken: null\r\n };\r\n \r\n super.load(options, requireId, message);\r\n }\r\n}\n\n\n/** WEBPACK FOOTER **\n ** ./src/tile.ts\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/powerbi.min.js b/dist/powerbi.min.js index f5d69c7c..7636e5d4 100644 --- a/dist/powerbi.min.js +++ b/dist/powerbi.min.js @@ -1,2 +1,2 @@ -!function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";var o=n(1);window.Powerbi=o["default"],window.powerbi=new o["default"]},function(e,t,n){"use strict";var o=n(2),r=n(4),i=n(5),s=n(3),a=function(){function e(t){void 0===t&&(t={}),this.embeds=[],window.addEventListener("message",this.onReceiveMessage.bind(this),!1),this.config=s["default"].assign({},e.defaultConfig,t),this.config.autoEmbedOnContentLoaded&&this.enableAutoEmbed()}return e.prototype.init=function(e){var t=this;e=e&&e instanceof HTMLElement?e:document.body;var n=Array.prototype.slice.call(e.querySelectorAll("["+o["default"].embedUrlAttribute+"]"));n.forEach(function(e){return t.embed(e)})},e.prototype.embed=function(e,t){void 0===t&&(t={});var n,o=e;return n=o.powerBiEmbed?this.embedExisting(o,t):this.embedNew(o,t)},e.prototype.embedNew=function(t,n){var i=this,a=n.type||t.getAttribute(o["default"].typeAttribute);if(!a)throw new Error("Attempted to embed using config "+JSON.stringify(n)+" on element "+t.outerHTML+", but could not determine what type of component to embed. You must specify a type in the configuration or as an attribute such as '"+o["default"].typeAttribute+'="'+r["default"].name.toLowerCase()+"\"'.");n.type=a;var u=s["default"].find(function(e){return a===e.name.toLowerCase()},e.components);if(!u)throw new Error("Attempted to embed component of type: "+a+" but did not find any matching component. Please verify the type you specified is intended.");n.getGlobalAccessToken=function(){return i.accessToken};var c=new u(t,n);return t.powerBiEmbed=c,this.embeds.push(c),c},e.prototype.embedExisting=function(e,t){var n=s["default"].find(function(t){return t.element===e},this.embeds);if(!n)throw new Error("Attempted to embed using config "+JSON.stringify(t)+" on element "+e.outerHTML+" which already has embedded comopnent associated, but could not find the existing comopnent in the list of active components. This could indicate the embeds list is out of sync with the DOM, or the component is referencing the incorrect HTML element.");return n.load(t,!0),n},e.prototype.enableAutoEmbed=function(){var e=this;window.addEventListener("DOMContentLoaded",function(t){return e.init(document.body)},!1)},e.prototype.get=function(e){var t=e;if(!t.powerBiEmbed)throw new Error("You attempted to get an instance of powerbi component associated with element: "+e.outerHTML+" but there was no associated instance.");return t.powerBiEmbed},e.prototype.remove=function(e){s["default"].remove(function(t){return t===e},this.embeds)},e.prototype.onReceiveMessage=function(t){if(t)try{var n=s["default"].find(function(e){return t.source===e.iframe.contentWindow},this.embeds);if(n){var o="string"==typeof t.data?JSON.parse(t.data):t.data;s["default"].raiseCustomEvent(n.element,e.eventMap[o.event],o)}}catch(r){if("function"!=typeof this.config.onError)throw r;this.config.onError.call(window,r)}},e.components=[i["default"],r["default"]],e.eventMap={tileClicked:"tile-click",tileLoaded:"tile-load",reportPageLoaded:"report-load"},e.defaultConfig={autoEmbedOnContentLoaded:!1,onError:function(){for(var e=[],t=0;t';this.element.innerHTML=i,this.iframe=this.element.childNodes[0],this.iframe.addEventListener("load",function(){return r.load(r.options,!1)},!1)}return e.prototype.load=function(e,t,n){if(void 0===t&&(t=!1),void 0===n&&(n=null),!n)throw new Error("You called load without providing message properties from the concrete embeddable class.");var r={accessToken:e.accessToken};o["default"].assign(n,r);var i={message:n};o["default"].raiseCustomEvent(this.element,i.message.action,i),this.iframe.contentWindow.postMessage(JSON.stringify(i.message),"*")},e.prototype.getAccessToken=function(){var t=this.options.accessToken||this.element.getAttribute(e.accessTokenAttribute)||this.options.getGlobalAccessToken();if(!t)throw new Error("No access token was found for element. You must specify an access token directly on the element using attribute '"+e.accessTokenAttribute+"' or specify a global token at: powerbi.accessToken.");return t},e.prototype.getEmbedUrl=function(){var t=this.options.embedUrl||this.element.getAttribute(e.embedUrlAttribute);if("string"!=typeof t||0===t.length)throw new Error("Embed Url is required, but it was not found. You must provide an embed url either as part of embed configuration or as attribute '"+e.embedUrlAttribute+"'.");return t},e.prototype.fullscreen=function(){var e=this.iframe.requestFullscreen||this.iframe.msRequestFullscreen||this.iframe.mozRequestFullScreen||this.iframe.webkitRequestFullscreen;e.call(this.iframe)},e.prototype.exitFullscreen=function(){if(this.isFullscreen(this.iframe)){var e=document.exitFullscreen||document.mozCancelFullScreen||document.webkitExitFullscreen||document.msExitFullscreen;e.call(document)}},e.prototype.isFullscreen=function(e){var t=["fullscreenElement","webkitFullscreenElement","mozFullscreenScreenElement","msFullscreenElement"];return t.some(function(t){return document[t]===e})},e.embedUrlAttribute="powerbi-embed-url",e.accessTokenAttribute="powerbi-access-token",e.typeAttribute="powerbi-type",e.defaultOptions={filterPaneEnabled:!0},e}();Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";var n=function(){function e(){}return e.raiseCustomEvent=function(e,t,n){var o;if("function"==typeof CustomEvent?o=new CustomEvent(t,{detail:n,bubbles:!0,cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(t,!0,!0,n)),e.dispatchEvent(o),!o.defaultPrevented&&o.returnValue){var r="on"+t.replace("-",""),i=e.getAttribute(r);i&&eval.call(e,i)}},e.findIndex=function(e,t){if(!Array.isArray(t))throw new Error("You attempted to call find with second parameter that was not an array. You passed: "+t);var n;return t.some(function(t,o){return e(t)?(n=o,!0):void 0}),n},e.find=function(t,n){var o=e.findIndex(t,n);return n[o]},e.remove=function(t,n){var o=e.findIndex(t,n);n.splice(o,1)},e.assign=function(){for(var e=[],t=0;t';this.element.innerHTML=i,this.iframe=this.element.childNodes[0],this.iframe.addEventListener("load",function(){return r.load(r.options,!1)},!1)}return e.prototype.load=function(e,t,n){if(void 0===t&&(t=!1),void 0===n&&(n=null),!n)throw new Error("You called load without providing message properties from the concrete embeddable class.");var r={accessToken:e.accessToken};o["default"].assign(n,r);var i={message:n};o["default"].raiseCustomEvent(this.element,i.message.action,i),this.iframe.contentWindow.postMessage(JSON.stringify(i.message),"*")},e.prototype.getAccessToken=function(){var t=this.options.accessToken||this.element.getAttribute(e.accessTokenAttribute)||this.options.getGlobalAccessToken();if(!t)throw new Error("No access token was found for element. You must specify an access token directly on the element using attribute '"+e.accessTokenAttribute+"' or specify a global token at: powerbi.accessToken.");return t},e.prototype.getEmbedUrl=function(){var t=this.options.embedUrl||this.element.getAttribute(e.embedUrlAttribute);if("string"!=typeof t||0===t.length)throw new Error("Embed Url is required, but it was not found. You must provide an embed url either as part of embed configuration or as attribute '"+e.embedUrlAttribute+"'.");return t},e.prototype.fullscreen=function(){var e=this.iframe.requestFullscreen||this.iframe.msRequestFullscreen||this.iframe.mozRequestFullScreen||this.iframe.webkitRequestFullscreen;e.call(this.iframe)},e.prototype.exitFullscreen=function(){if(this.isFullscreen(this.iframe)){var e=document.exitFullscreen||document.mozCancelFullScreen||document.webkitExitFullscreen||document.msExitFullscreen;e.call(document)}},e.prototype.isFullscreen=function(e){var t=["fullscreenElement","webkitFullscreenElement","mozFullscreenScreenElement","msFullscreenElement"];return t.some(function(t){return document[t]===e})},e.embedUrlAttribute="powerbi-embed-url",e.accessTokenAttribute="powerbi-access-token",e.typeAttribute="powerbi-type",e.defaultOptions={filterPaneEnabled:!0},e}();Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r},function(e,t){"use strict";var n=function(){function e(){}return e.raiseCustomEvent=function(e,t,n){var o;if("function"==typeof CustomEvent?o=new CustomEvent(t,{detail:n,bubbles:!0,cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(t,!0,!0,n)),e.dispatchEvent(o),!o.defaultPrevented&&o.returnValue){var r="on"+t.replace("-",""),i=e.getAttribute(r);i&&eval.call(e,i)}},e.findIndex=function(e,t){if(!Array.isArray(t))throw new Error("You attempted to call find with second parameter that was not an array. You passed: "+t);var n;return t.some(function(t,o){return e(t)?(n=o,!0):void 0}),n},e.find=function(t,n){var o=e.findIndex(t,n);return n[o]},e.remove=function(t,n){var o=e.findIndex(t,n);n.splice(o,1)},e.assign=function(){for(var e=[],t=0;t any; } -export default class PowerBi { +export class PowerBi { /** * List of components this service can embed. */ @@ -157,10 +157,24 @@ export default class PowerBi { } /** - * Remove component from the list of embedded components. + * 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. */ - remove(component: Embed): void { - Utils.remove(x => x === component, this.embeds); + reset(element: HTMLElement) { + const powerBiElement = element; + + if (!powerBiElement.powerBiEmbed) { + throw new Error(`You attempted to get an instance of powerbi component associated with element: ${element.outerHTML} but there was no associated instance.`); + } + + /** Remove component from internal list */ + Utils.remove(x => x === powerBiElement.powerBiEmbed, this.embeds); + /** Delete property from html element */ + delete powerBiElement.powerBiEmbed; + /** Remove iframe from element */ + const iframe = element.querySelector('iframe'); + if(iframe) { + iframe.remove(); + } } /** @@ -194,4 +208,4 @@ export default class PowerBi { } } - +export default PowerBi; \ No newline at end of file diff --git a/test/core.spec.ts b/test/core.spec.ts index 6e2483a1..5a6e4d79 100644 --- a/test/core.spec.ts +++ b/test/core.spec.ts @@ -1,6 +1,6 @@ -import PowerBi from '../src/core'; +import * as pbi from '../src/core'; -declare var powerbi: PowerBi; +declare var powerbi: pbi.PowerBi; describe('powerbi', function () { beforeAll(function () { @@ -238,6 +238,56 @@ describe('powerbi', function () { }); }); + describe('reset', function () { + it('throws an error if the element being reset does not have embedded component associated with it', function () { + // Arrange + const $element = $('
'); + + // Act + const attemptToReset = () => { + powerbi.reset($element.get(0)); + }; + + // Assert + expect(attemptToReset).toThrowError(); + }); + + it('deletes the powerBiEmbed property on the element', function () { + // Arrange + const $element = $('
'); + powerbi.embed($element.get(0), { + type: 'report', + embedUrl: 'fakeUrl', + accessToken: 'fakeToken' + }); + + // Act + expect(($element.get(0)).powerBiEmbed).toBeDefined(); + powerbi.reset($element.get(0)); + + // Assert + expect(($element.get(0)).powerBiEmbed).toBeUndefined(); + }); + + it('clears the innerHTML of the element', function () { + // Arrange + const $element = $('
'); + powerbi.embed($element.get(0), { + type: 'report', + embedUrl: 'fakeUrl', + accessToken: 'fakeToken' + }); + + // Act + var iframe = $element.find('iframe'); + expect(iframe.length).toEqual(1); + powerbi.reset($element.get(0)); + + // Assert + expect($element.html()).toEqual(''); + }); + }); + // TODO: Either find a way to fix the test or remove it. // 1. onReceiveMessage is private so it's not supposed to be accessable for testing // 2. the window.addEventListener('message', this.onReceiveMessage.bind(this)) prevents the method from being spied on.