powerbi-client-react 1.3.0 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -99,7 +99,13 @@ __Note__: To use this library in IE browser, use [react-app-polyfill](https://ww
99
99
  interface EmbedProps {
100
100
 
101
101
  // Configuration for embedding the PowerBI entity (required)
102
- embedConfig: IEmbedConfiguration | IQnaEmbedConfiguration | IVisualEmbedConfiguration
102
+ embedConfig:
103
+ | IReportEmbedConfiguration
104
+ | IDashboardEmbedConfiguration
105
+ | ITileEmbedConfiguration
106
+ | IQnaEmbedConfiguration
107
+ | IVisualEmbedConfiguration
108
+ | IEmbedConfiguration
103
109
 
104
110
  // Callback method to get the embedded PowerBI entity object (optional)
105
111
  getEmbed?: { (embeddedComponent: Embed): void }
@@ -1,5 +1,5 @@
1
- import * as React from "react";
2
- import { service, Embed, IEmbedConfiguration, IQnaEmbedConfiguration, IVisualEmbedConfiguration } from 'powerbi-client';
1
+ import * as React from 'react';
2
+ import { service, Embed, IEmbedConfiguration, IQnaEmbedConfiguration, IVisualEmbedConfiguration, IReportEmbedConfiguration, IDashboardEmbedConfiguration, ITileEmbedConfiguration } from 'powerbi-client';
3
3
  /**
4
4
  * Type for event handler function of embedded entity
5
5
  */
@@ -10,7 +10,7 @@ export declare type EventHandler = {
10
10
  * Props interface for PowerBIEmbed component
11
11
  */
12
12
  export interface EmbedProps {
13
- embedConfig: IEmbedConfiguration | IQnaEmbedConfiguration | IVisualEmbedConfiguration;
13
+ embedConfig: IReportEmbedConfiguration | IDashboardEmbedConfiguration | ITileEmbedConfiguration | IQnaEmbedConfiguration | IVisualEmbedConfiguration | IEmbedConfiguration;
14
14
  getEmbeddedComponent?: {
15
15
  (embeddedComponent: Embed): void;
16
16
  };
@@ -38,7 +38,7 @@ export declare class PowerBIEmbed extends React.Component<EmbedProps> {
38
38
  private set embed(value);
39
39
  constructor(props: EmbedProps);
40
40
  componentDidMount(): void;
41
- componentDidUpdate(prevProps: EmbedProps): void;
41
+ componentDidUpdate(prevProps: EmbedProps): Promise<void>;
42
42
  componentWillUnmount(): void;
43
43
  render(): JSX.Element;
44
44
  /**
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("powerbi-client"),require("react"),require("lodash.isequal")):"function"==typeof define&&define.amd?define(["powerbi-client","react","lodash.isequal"],t):"object"==typeof exports?exports["powerbi-client-react"]=t(require("powerbi-client"),require("react"),require("lodash.isequal")):e["powerbi-client-react"]=t(e["powerbi-client"],e.react,e["lodash.isequal"])}(window,(function(e,t,r){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t,r){"use strict";r.r(t),r.d(t,"EmbedType",(function(){return a})),r.d(t,"PowerBIEmbed",(function(){return f}));var n=r(1),o=r(0),i=r(2),s=r.n(i);var p,a,c=(p=function(e,t){return(p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}p(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),d=function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],s=0,p=i.length;s<p;s++,o++)n[o]=i[s];return n};!function(e){e.Report="report",e.Dashboard="dashboard",e.Tile="tile",e.Qna="qna",e.Visual="visual"}(a||(a={}));var f=function(e){function t(t){var r=e.call(this,t)||this;return r.containerRef=n.createRef(),r.prevEventHandlerMapString="",r.props.service?r.powerbi=r.props.service:r.powerbi=new o.service.Service(o.factories.hpmFactory,o.factories.wpmpFactory,o.factories.routerFactory),r}return c(t,e),Object.defineProperty(t.prototype,"embed",{get:function(){return this._embed},set:function(e){this._embed=e,this.invokeGetEmbedCallback()},enumerable:!1,configurable:!0}),t.prototype.componentDidMount=function(){this.containerRef.current&&(this.props.embedConfig.accessToken&&this.props.embedConfig.embedUrl?this.embedEntity():this.embed=this.powerbi.bootstrap(this.containerRef.current,this.props.embedConfig)),this.props.eventHandlers&&this.embed&&this.setEventHandlers(this.embed,this.props.eventHandlers)},t.prototype.componentDidUpdate=function(e){if(this.embedOrUpdateAccessToken(e),this.props.eventHandlers&&this.embed&&this.setEventHandlers(this.embed,this.props.eventHandlers),s()(this.props.embedConfig.settings,e.embedConfig.settings)||this.updateSettings(),this.props.embedConfig.type===a.Report){var t=this.props.embedConfig,r=e.embedConfig;t.pageName&&t.pageName!==r.pageName&&this.embed.setPage(t.pageName).catch((function(e){console.error(e)})),t.filters&&!s()(t.filters,r.filters)?this.embed.setFilters(t.filters).catch((function(e){console.error(e)})):!t.filters&&r.filters&&this.embed.removeFilters().catch((function(e){console.error(e)}))}},t.prototype.componentWillUnmount=function(){this.containerRef.current&&this.powerbi.reset(this.containerRef.current)},t.prototype.render=function(){return n.createElement("div",{ref:this.containerRef,className:this.props.cssClassName})},t.prototype.embedEntity=function(){this.containerRef.current&&(this.props.phasedEmbedding&&this.props.embedConfig.type===a.Report?this.embed=this.powerbi.load(this.containerRef.current,this.props.embedConfig):(this.props.phasedEmbedding&&console.error("Phased embedding is not supported for type "+this.props.embedConfig.type),this.embed=this.powerbi.embed(this.containerRef.current,this.props.embedConfig)))},t.prototype.embedOrUpdateAccessToken=function(e){this.props.embedConfig.accessToken&&this.props.embedConfig.embedUrl&&(!this.containerRef.current||e.embedConfig.accessToken&&this.props.embedConfig.embedUrl===e.embedConfig.embedUrl?this.props.embedConfig.accessToken!==e.embedConfig.accessToken&&this.props.embedConfig.embedUrl===e.embedConfig.embedUrl&&this.embed&&this.embed.setAccessToken(this.props.embedConfig.accessToken).catch((function(e){console.error("setAccessToken error: "+e)})):this.embedEntity())},t.prototype.setEventHandlers=function(e,t){var r=this,n=function(e){if(!e)return"";var t=Array.from(e);return JSON.stringify(t.map((function(e){return[e[0],e[1]?e[1].toString():""]})))}(this.props.eventHandlers);if(this.prevEventHandlerMapString!==n){this.prevEventHandlerMapString=n;var i=o.Embed.allowedEvents,s=e.embedtype;switch(s){case a.Report:i=d(i,o.Report.allowedEvents);break;case a.Dashboard:i=d(i,o.Dashboard.allowedEvents);break;case a.Tile:i=d(i,o.Tile.allowedEvents);break;case a.Qna:i=d(i,o.Qna.allowedEvents);break;case a.Visual:i=d(i,o.Visual.allowedEvents);break;default:console.error("Invalid embed type "+s)}var p=[];t.forEach((function(t,n){i.includes(n)?(e.off(n),t&&e.on(n,(function(e){t(e,r.embed)}))):p.push(n)})),p.length&&console.error("Following events are invalid: "+p.join(","))}},t.prototype.invokeGetEmbedCallback=function(){this.props.getEmbeddedComponent&&this.embed&&this.props.getEmbeddedComponent(this.embed)},t.prototype.updateSettings=function(){if(this.embed&&this.props.embedConfig.settings)switch(this.props.embedConfig.type){case a.Report:var e=this.props.embedConfig.settings;this.embed.updateSettings(e).catch((function(e){console.error("Error in method updateSettings: "+e)}));break;case a.Dashboard:case a.Tile:case a.Qna:case a.Visual:break;default:console.error("Invalid embed type "+this.props.embedConfig.type)}},t}(n.Component)}])}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("powerbi-client"),require("lodash.isequal")):"function"==typeof define&&define.amd?define(["react","powerbi-client","lodash.isequal"],t):"object"==typeof exports?exports["powerbi-client-react"]=t(require("react"),require("powerbi-client"),require("lodash.isequal")):e["powerbi-client-react"]=t(e.react,e["powerbi-client"],e["lodash.isequal"])}(self,((e,t,r)=>(()=>{"use strict";var n={890:e=>{e.exports=r},719:e=>{e.exports=t},156:t=>{t.exports=e}},o={};function s(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return n[e](r,r.exports,s),r.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{s.r(i),s.d(i,{EmbedType:()=>t,PowerBIEmbed:()=>u});var e,t,r=s(156),n=s(719),o=s(890),a=s.n(o),c=(e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)},function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}),p=function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((n=n.apply(e,t||[])).next())}))},l=function(e,t){var r,n,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,n=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},d=function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var s=arguments[t],i=0,a=s.length;i<a;i++,o++)n[o]=s[i];return n};!function(e){e.Report="report",e.Dashboard="dashboard",e.Tile="tile",e.Qna="qna",e.Visual="visual"}(t||(t={}));var u=function(e){function o(t){var o=e.call(this,t)||this;return o.containerRef=r.createRef(),o.prevEventHandlerMapString="",o.props.service?o.powerbi=o.props.service:o.powerbi=new n.service.Service(n.factories.hpmFactory,n.factories.wpmpFactory,n.factories.routerFactory),o.powerbi.setSdkInfo("powerbi-client-react","1.3.5"),o}return c(o,e),Object.defineProperty(o.prototype,"embed",{get:function(){return this._embed},set:function(e){this._embed=e,this.invokeGetEmbedCallback()},enumerable:!1,configurable:!0}),o.prototype.componentDidMount=function(){this.containerRef.current&&(this.props.embedConfig.accessToken&&this.props.embedConfig.embedUrl?this.embedEntity():this.embed=this.powerbi.bootstrap(this.containerRef.current,this.props.embedConfig)),this.props.eventHandlers&&this.embed&&this.setEventHandlers(this.embed,this.props.eventHandlers)},o.prototype.componentDidUpdate=function(e){return p(this,void 0,void 0,(function(){var r,n,o,s;return l(this,(function(i){switch(i.label){case 0:return this.embedOrUpdateAccessToken(e),this.props.eventHandlers&&this.embed&&this.setEventHandlers(this.embed,this.props.eventHandlers),a()(this.props.embedConfig.settings,e.embedConfig.settings)?[3,2]:[4,this.updateSettings()];case 1:i.sent(),i.label=2;case 2:if(this.props.embedConfig.type!==t.Report)return[3,11];i.label=3;case 3:return i.trys.push([3,10,,11]),r=this.props.embedConfig,n=r.filters,o=e.embedConfig,r.pageName&&r.pageName!==o.pageName?[4,this.embed.setPage(r.pageName)]:[3,5];case 4:i.sent(),i.label=5;case 5:return!n||a()(n,o.filters)?[3,7]:[4,this.embed.setFilters(n)];case 6:return i.sent(),[3,9];case 7:return n||!o.filters?[3,9]:[4,this.embed.removeFilters()];case 8:i.sent(),i.label=9;case 9:return[3,11];case 10:return s=i.sent(),console.error(s),[3,11];case 11:return[2]}}))}))},o.prototype.componentWillUnmount=function(){this.containerRef.current&&this.powerbi.reset(this.containerRef.current)},o.prototype.render=function(){return r.createElement("div",{ref:this.containerRef,className:this.props.cssClassName})},o.prototype.embedEntity=function(){this.containerRef.current&&(this.props.phasedEmbedding&&this.props.embedConfig.type===t.Report?this.embed=this.powerbi.load(this.containerRef.current,this.props.embedConfig):(this.props.phasedEmbedding&&console.error("Phased embedding is not supported for type "+this.props.embedConfig.type),this.embed=this.powerbi.embed(this.containerRef.current,this.props.embedConfig)))},o.prototype.embedOrUpdateAccessToken=function(e){this.props.embedConfig.accessToken&&this.props.embedConfig.embedUrl&&(!this.containerRef.current||e.embedConfig.accessToken&&this.props.embedConfig.embedUrl===e.embedConfig.embedUrl?this.props.embedConfig.accessToken!==e.embedConfig.accessToken&&this.props.embedConfig.embedUrl===e.embedConfig.embedUrl&&this.embed&&this.embed.setAccessToken(this.props.embedConfig.accessToken).catch((function(e){console.error("setAccessToken error: "+e)})):this.embedEntity())},o.prototype.setEventHandlers=function(e,r){var o=this,s=function(e){if(!e)return"";var t=Array.from(e);return JSON.stringify(t.map((function(e){return[e[0],e[1]?e[1].toString():""]})))}(this.props.eventHandlers);if(this.prevEventHandlerMapString!==s){this.prevEventHandlerMapString=s;var i=n.Embed.allowedEvents,a=e.embedtype;switch(a){case t.Report:i=d(i,n.Report.allowedEvents);break;case t.Dashboard:i=d(i,n.Dashboard.allowedEvents);break;case t.Tile:i=d(i,n.Tile.allowedEvents);break;case t.Qna:i=d(i,n.Qna.allowedEvents);break;case t.Visual:i=d(i,n.Visual.allowedEvents);break;default:console.error("Invalid embed type "+a)}var c=[];r.forEach((function(t,r){i.includes(r)?(e.off(r),t&&e.on(r,(function(e){t(e,o.embed)}))):c.push(r)})),c.length&&console.error("Following events are invalid: "+c.join(","))}},o.prototype.invokeGetEmbedCallback=function(){this.props.getEmbeddedComponent&&this.embed&&this.props.getEmbeddedComponent(this.embed)},o.prototype.updateSettings=function(){return p(this,void 0,void 0,(function(){var e,r;return l(this,(function(n){switch(n.label){case 0:if(!this.embed||!this.props.embedConfig.settings)return[2];switch(this.props.embedConfig.type){case t.Report:return[3,1];case t.Dashboard:case t.Tile:case t.Qna:case t.Visual:return[3,6]}return[3,7];case 1:e=this.props.embedConfig.settings,n.label=2;case 2:return n.trys.push([2,4,,5]),[4,this.embed.updateSettings(e)];case 3:return n.sent(),[3,5];case 4:return r=n.sent(),console.error("Error in method updateSettings: "+r),[3,5];case 5:case 6:return[3,8];case 7:console.error("Invalid embed type "+this.props.embedConfig.type),n.label=8;case 8:return[2]}}))}))},o}(r.Component)})(),i})()));
2
2
  //# sourceMappingURL=powerbi-client-react.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://powerbi-client-react/webpack/universalModuleDefinition","webpack://powerbi-client-react/webpack/bootstrap","webpack://powerbi-client-react/external \"powerbi-client\"","webpack://powerbi-client-react/external \"react\"","webpack://powerbi-client-react/external \"lodash.isequal\"","webpack://powerbi-client-react/./src/PowerBIEmbed.tsx","webpack://powerbi-client-react/./src/utils.ts"],"names":["root","factory","exports","module","require","define","amd","window","__WEBPACK_EXTERNAL_MODULE__0__","__WEBPACK_EXTERNAL_MODULE__1__","__WEBPACK_EXTERNAL_MODULE__2__","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","EmbedType","props","containerRef","prevEventHandlerMapString","service","powerbi","Service","hpmFactory","wpmpFactory","routerFactory","this","_embed","newEmbedInstance","invokeGetEmbedCallback","componentDidMount","current","embedConfig","accessToken","embedUrl","embedEntity","embed","bootstrap","eventHandlers","setEventHandlers","componentDidUpdate","prevProps","embedOrUpdateAccessToken","settings","updateSettings","type","Report","prevEmbedConfig","pageName","setPage","catch","error","console","filters","setFilters","removeFilters","componentWillUnmount","reset","render","ref","className","cssClassName","phasedEmbedding","load","setAccessToken","eventHandlerMap","eventHandlerMapString","map","mapEntries","Array","from","JSON","stringify","mapEntry","toString","stringifyMap","allowedEvents","entityType","embedtype","Dashboard","Tile","Qna","Visual","invalidEvents","forEach","eventHandlerMethod","eventName","includes","off","on","event","push","length","join","getEmbeddedComponent"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,kBAAmBA,QAAQ,SAAUA,QAAQ,mBACrD,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,iBAAkB,QAAS,kBAAmBJ,GAC5B,iBAAZC,QACdA,QAAQ,wBAA0BD,EAAQG,QAAQ,kBAAmBA,QAAQ,SAAUA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AACI,GACpBL,EAAmBK,EAAO,EAAKtD,WAOjC+C,EAAcQ,KAAKL,MAKjBH,EAAcS,QACjBxC,QAAQD,MAAM,iCAAiCgC,EAAcU,KAAK,QAS5D,YAAAhE,uBAAR,WACKH,KAAKT,MAAM6E,sBAAwBpE,KAAKU,OAC3CV,KAAKT,MAAM6E,qBAAqBpE,KAAKU,QAS/B,YAAAQ,eAAR,WACC,GAAKlB,KAAKU,OAAUV,KAAKT,MAAMe,YAAYW,SAI3C,OAAQjB,KAAKT,MAAMe,YAAYa,MAC9B,KAAK7B,EAAU8B,OAGd,IAAMH,EAAWjB,KAAKT,MAAMe,YAAYW,SAGvCjB,KAAKU,MAAiBQ,eAAeD,GACpCO,OAAM,SAACC,GACPC,QAAQD,MAAM,mCAAmCA,MAEnD,MAED,KAAKnC,EAAU+D,UACf,KAAK/D,EAAUgE,KACf,KAAKhE,EAAUiE,IACf,KAAKjE,EAAUkE,OAEd,MAED,QACC9B,QAAQD,MAAM,sBAAsBzB,KAAKT,MAAMe,YAAYa,QAG/D,EA9TA,CAAkC","file":"powerbi-client-react.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"powerbi-client\"), require(\"react\"), require(\"lodash.isequal\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"powerbi-client\", \"react\", \"lodash.isequal\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"powerbi-client-react\"] = factory(require(\"powerbi-client\"), require(\"react\"), require(\"lodash.isequal\"));\n\telse\n\t\troot[\"powerbi-client-react\"] = factory(root[\"powerbi-client\"], root[\"react\"], root[\"lodash.isequal\"]);\n})(window, function(__WEBPACK_EXTERNAL_MODULE__0__, __WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__2__) {\nreturn "," \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 \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\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.l = 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// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","module.exports = __WEBPACK_EXTERNAL_MODULE__0__;","module.exports = __WEBPACK_EXTERNAL_MODULE__1__;","module.exports = __WEBPACK_EXTERNAL_MODULE__2__;","// Copyright (c) Microsoft Corporation.\r\n// Licensed under the MIT License.\r\n\r\nimport * as React from \"react\";\r\nimport {\r\n\tservice,\r\n\tfactories,\r\n\tReport,\r\n\tEmbed,\r\n\tDashboard,\r\n\tTile,\r\n\tQna,\r\n\tIEmbedConfiguration,\r\n\tVisual,\r\n\tIQnaEmbedConfiguration,\r\n\tIEmbedSettings,\r\n\tIVisualEmbedConfiguration,\r\n} from 'powerbi-client';\r\nimport isEqual from 'lodash.isequal';\r\nimport { stringifyMap } from './utils';\r\n\r\n/**\r\n * Type for event handler function of embedded entity\r\n */\r\nexport type EventHandler = {\r\n\t(event?: service.ICustomEvent<any>, embeddedEntity?: Embed): void | null;\r\n};\r\n\r\n/**\r\n * Props interface for PowerBIEmbed component\r\n */\r\nexport interface EmbedProps {\r\n\r\n\t// Configuration for embedding the PowerBI entity\r\n\tembedConfig: IEmbedConfiguration | IQnaEmbedConfiguration | IVisualEmbedConfiguration;\r\n\r\n\t// Callback method to get the embedded PowerBI entity object (Optional)\r\n\tgetEmbeddedComponent?: { (embeddedComponent: Embed): void };\r\n\r\n\t// Map of pair of event name and its handler method to be triggered on the event (Optional)\r\n\teventHandlers?: Map<string, EventHandler>;\r\n\r\n\t// CSS class to be set on the embedding container (Optional)\r\n\tcssClassName?: string;\r\n\r\n\t// Phased embedding flag (Optional)\r\n\tphasedEmbedding?: boolean;\r\n\r\n\t// Provide a custom implementation of PowerBI service (Optional)\r\n\tservice?: service.Service;\r\n}\r\n\r\nexport enum EmbedType {\r\n\tReport = 'report',\r\n\tDashboard = 'dashboard',\r\n\tTile = 'tile',\r\n\tQna = 'qna',\r\n\tVisual = 'visual'\r\n}\r\n\r\n/**\r\n * Base react component to embed Power BI entities like: reports, dashboards, tiles, visual and qna containers.\r\n */\r\nexport class PowerBIEmbed extends React.Component<EmbedProps> {\r\n\r\n\t// Embedded entity\r\n\t// Note: Do not read or assign to this member variable directly, instead use the getter and setter\r\n\tprivate _embed?: Embed;\r\n\r\n\t// Powerbi service\r\n\tprivate powerbi: service.Service;\r\n\r\n\t// Ref to the HTML div element\r\n\tprivate containerRef = React.createRef<HTMLDivElement>();\r\n\r\n\t// JSON stringify of prev event handler map\r\n\tprivate prevEventHandlerMapString = '';\r\n\r\n\t// Getter for this._embed\r\n\tprivate get embed(): Embed | undefined {\r\n\t\treturn this._embed;\r\n\t};\r\n\r\n\t// Setter for this._embed\r\n\tprivate set embed(newEmbedInstance: Embed | undefined) {\r\n\t\tthis._embed = newEmbedInstance;\r\n\r\n\t\t// Invoke callback method in props to return this embed instance\r\n\t\tthis.invokeGetEmbedCallback();\r\n\t};\r\n\r\n\tconstructor(props: EmbedProps) {\r\n\t\tsuper(props);\r\n\r\n\t\tif (this.props.service) {\r\n\t\t\tthis.powerbi = this.props.service;\r\n\t\t}\r\n\t\telse {\r\n\t\t\tthis.powerbi = new service.Service(\r\n\t\t\t\tfactories.hpmFactory,\r\n\t\t\t\tfactories.wpmpFactory,\r\n\t\t\t\tfactories.routerFactory);\r\n\t\t}\r\n\t};\r\n\r\n\tcomponentDidMount(): void {\r\n\r\n\t\t// Check if HTML container is available\r\n\t\tif (this.containerRef.current) {\r\n\r\n\t\t\t// Decide to embed, load or bootstrap\r\n\t\t\tif (this.props.embedConfig.accessToken && this.props.embedConfig.embedUrl) {\r\n\t\t\t\tthis.embedEntity();\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tthis.embed = this.powerbi.bootstrap(this.containerRef.current, this.props.embedConfig);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Set event handlers if available\r\n\t\tif (this.props.eventHandlers && this.embed) {\r\n\t\t\tthis.setEventHandlers(this.embed, this.props.eventHandlers);\r\n\t\t}\r\n\t};\r\n\r\n\tcomponentDidUpdate(prevProps: EmbedProps): void {\r\n\r\n\t\tthis.embedOrUpdateAccessToken(prevProps);\r\n\r\n\t\t// Set event handlers if available\r\n\t\tif (this.props.eventHandlers && this.embed) {\r\n\t\t\tthis.setEventHandlers(this.embed, this.props.eventHandlers);\r\n\t\t}\r\n\r\n\t\t// Allow settings update only when settings object in embedConfig of current and previous props is different\r\n\t\tif (!isEqual(this.props.embedConfig.settings, prevProps.embedConfig.settings)) {\r\n\t\t\tthis.updateSettings();\r\n\t\t}\r\n\r\n\t\t// Update pageName and filters for a report\r\n\t\tif (this.props.embedConfig.type === EmbedType.Report) {\r\n\r\n\t\t\t// Typecasting to IEmbedConfiguration as IQnAEmbedConfiguration does not have pageName\r\n\t\t\tconst embedConfig = this.props.embedConfig as IEmbedConfiguration;\r\n\t\t\tconst prevEmbedConfig = prevProps.embedConfig as IEmbedConfiguration;\r\n\r\n\t\t\t// Set new page if available and different from the previous page\r\n\t\t\tif (embedConfig.pageName && embedConfig.pageName !== prevEmbedConfig.pageName) {\r\n\r\n\t\t\t\t// Upcast to Report and call setPage\r\n\t\t\t\t(this.embed as Report).setPage(embedConfig.pageName)\r\n\t\t\t\t\t.catch((error) => {\r\n\t\t\t\t\t\tconsole.error(error);\r\n\t\t\t\t\t});\r\n\r\n\t\t\t}\r\n\r\n\t\t\t// Set filters on the embedded report if available and different from the previous filter\r\n\t\t\tif (embedConfig.filters && !isEqual(embedConfig.filters, prevEmbedConfig.filters)) {\r\n\r\n\t\t\t\t// Upcast to Report and call setFilters\r\n\t\t\t\t(this.embed as Report).setFilters(embedConfig.filters)\r\n\t\t\t\t\t.catch((error) => {\r\n\t\t\t\t\t\tconsole.error(error);\r\n\t\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\t// Remove filters on the embedded report\r\n\t\t\telse if (!embedConfig.filters && prevEmbedConfig.filters) {\r\n\r\n\t\t\t\t// Upcast to Report and call removeFilters\r\n\t\t\t\t(this.embed as Report).removeFilters()\r\n\t\t\t\t\t.catch((error) => {\r\n\t\t\t\t\t\tconsole.error(error);\r\n\t\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\tcomponentWillUnmount(): void {\r\n\t\t// Clean Up\r\n\t\tif (this.containerRef.current) {\r\n\t\t\tthis.powerbi.reset(this.containerRef.current);\r\n\t\t}\r\n\t};\r\n\r\n\trender(): JSX.Element {\r\n\t\treturn (\r\n\t\t\t<div\r\n\t\t\t\tref={this.containerRef}\r\n\t\t\t\tclassName={this.props.cssClassName}>\r\n\t\t\t</div>\r\n\t\t)\r\n\t};\r\n\r\n\t/**\r\n\t * Embed the powerbi entity (Load for phased embedding)\r\n\t */\r\n\tprivate embedEntity(): void {\r\n\t\t// Check if the HTML container is rendered and available\r\n\t\tif (!this.containerRef.current) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Load when props.phasedEmbedding is true and embed type is report, embed otherwise\r\n\t\tif (this.props.phasedEmbedding && this.props.embedConfig.type === EmbedType.Report) {\r\n\t\t\tthis.embed = this.powerbi.load(this.containerRef.current, this.props.embedConfig);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (this.props.phasedEmbedding) {\r\n\t\t\t\tconsole.error(`Phased embedding is not supported for type ${this.props.embedConfig.type}`)\r\n\t\t\t}\r\n\t\t\tthis.embed = this.powerbi.embed(this.containerRef.current, this.props.embedConfig);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * When component updates, choose to _embed_ the powerbi entity or _update the accessToken_ in the embedded entity \r\n\t * or do nothing if the embedUrl and accessToken did not update in the new props\r\n\t * \r\n\t * @param prevProps EmbedProps\r\n\t * @returns void\r\n\t */\r\n\tprivate embedOrUpdateAccessToken(prevProps: EmbedProps): void {\r\n\r\n\t\t// Check if Embed URL and Access Token are present in current props\r\n\t\tif (!this.props.embedConfig.accessToken || !this.props.embedConfig.embedUrl) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Embed or load in the following scenarios\r\n\t\t//\t\t1. AccessToken was not provided in prev props (E.g. Report was bootstrapped earlier)\r\n\t\t//\t\t2. Embed URL is updated (E.g. New report is to be embedded)\r\n\t\tif (\r\n\t\t\tthis.containerRef.current &&\r\n\t\t\t(!prevProps.embedConfig.accessToken ||\r\n\t\t\t\tthis.props.embedConfig.embedUrl !== prevProps.embedConfig.embedUrl)\r\n\t\t) {\r\n\t\t\tthis.embedEntity();\r\n\t\t}\r\n\r\n\t\t// Set new access token,\r\n\t\t// when access token is updated but embed Url is same\r\n\t\telse if (\r\n\t\t\tthis.props.embedConfig.accessToken !== prevProps.embedConfig.accessToken &&\r\n\t\t\tthis.props.embedConfig.embedUrl === prevProps.embedConfig.embedUrl &&\r\n\t\t\tthis.embed\r\n\t\t) {\r\n\t\t\tthis.embed.setAccessToken(this.props.embedConfig.accessToken)\r\n\t\t\t\t.catch((error) => {\r\n\t\t\t\t\tconsole.error(`setAccessToken error: ${error}`);\r\n\t\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Sets all event handlers from the props on the embedded entity\r\n\t * \r\n\t * @param embed Embedded object\r\n\t * @param eventHandlers Array of eventhandlers to be set on embedded entity\r\n\t * @returns void\r\n\t */\r\n\tprivate setEventHandlers(\r\n\t\tembed: Embed,\r\n\t\teventHandlerMap: Map<string, EventHandler>\r\n\t): void {\r\n\t\t// Get string representation of eventHandlerMap\r\n\t\tconst eventHandlerMapString = stringifyMap(this.props.eventHandlers);\r\n\r\n\t\t// Check if event handler map changed\r\n\t\tif (this.prevEventHandlerMapString === eventHandlerMapString) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Update prev string representation of event handler map\r\n\t\tthis.prevEventHandlerMapString = eventHandlerMapString;\r\n\r\n\t\t// List of allowed events\r\n\t\tlet allowedEvents = Embed.allowedEvents;\r\n\r\n\t\tconst entityType = embed.embedtype;\r\n\r\n\t\t// Append entity specific events\r\n\t\tswitch (entityType) {\r\n\t\t\tcase EmbedType.Report:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Report.allowedEvents]\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Dashboard:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Dashboard.allowedEvents]\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Tile:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Tile.allowedEvents]\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Qna:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Qna.allowedEvents]\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Visual:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Visual.allowedEvents]\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tconsole.error(`Invalid embed type ${entityType}`);\r\n\t\t}\r\n\r\n\t\t// Holds list of events which are not allowed\r\n\t\tconst invalidEvents: Array<string> = [];\r\n\r\n\t\t// Apply all provided event handlers\r\n\t\teventHandlerMap.forEach((eventHandlerMethod, eventName) => {\r\n\t\t\t// Check if this event is allowed\r\n\t\t\tif (allowedEvents.includes(eventName)) {\r\n\r\n\t\t\t\t// Removes event handler for this event\r\n\t\t\t\tembed.off(eventName);\r\n\r\n\t\t\t\t// Event handler is effectively removed for this event when eventHandlerMethod is null\r\n\t\t\t\tif (eventHandlerMethod) {\r\n\r\n\t\t\t\t\t// Set single event handler\r\n\t\t\t\t\tembed.on(eventName, (event: service.ICustomEvent<any>): void => {\r\n\t\t\t\t\t\teventHandlerMethod(event, this.embed);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse {\r\n\r\n\t\t\t\t// Add this event name to the list of invalid events\r\n\t\t\t\tinvalidEvents.push(eventName);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\t// Handle invalid events\r\n\t\tif (invalidEvents.length) {\r\n\t\t\tconsole.error(`Following events are invalid: ${invalidEvents.join(',')}`);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Returns the embedded object via _getEmbed_ callback method provided in props\r\n\t * \r\n\t * @returns void\r\n\t */\r\n\tprivate invokeGetEmbedCallback(): void {\r\n\t\tif (this.props.getEmbeddedComponent && this.embed) {\r\n\t\t\tthis.props.getEmbeddedComponent(this.embed);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Update settings from props of the embedded artifact\r\n\t * \r\n\t * @returns void\r\n\t */\r\n\tprivate updateSettings(): void {\r\n\t\tif (!this.embed || !this.props.embedConfig.settings) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tswitch (this.props.embedConfig.type) {\r\n\t\t\tcase EmbedType.Report: {\r\n\r\n\t\t\t\t// Typecasted to IEmbedSettings as props.embedConfig.settings can be ISettings via IQnaEmbedConfiguration\r\n\t\t\t\tconst settings = this.props.embedConfig.settings as IEmbedSettings;\r\n\r\n\t\t\t\t// Upcast to Report and call updateSettings\r\n\t\t\t\t(this.embed as Report).updateSettings(settings)\r\n\t\t\t\t\t.catch((error: any) => {\r\n\t\t\t\t\t\tconsole.error(`Error in method updateSettings: ${error}`);\r\n\t\t\t\t\t});\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase EmbedType.Dashboard:\r\n\t\t\tcase EmbedType.Tile:\r\n\t\t\tcase EmbedType.Qna:\r\n\t\t\tcase EmbedType.Visual:\r\n\t\t\t\t// updateSettings not applicable for these embedding types\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\t\t\t\tconsole.error(`Invalid embed type ${this.props.embedConfig.type}`);\r\n\t\t}\r\n\t};\r\n}\r\n","// Copyright (c) Microsoft Corporation.\r\n// Licensed under the MIT License.\r\n\r\nimport { EmbedProps } from \"./PowerBIEmbed\";\r\n\r\n/**\r\n * Get JSON string representation of the given map.\r\n * \r\n * @param map Map of event and corresponding handler method\r\n * \r\n * For example:\r\n * Input:\r\n * ```\r\n * Map([\r\n\t\t['loaded', null],\r\n\t\t['rendered', function () { console.log('Rendered'); }]\r\n\t]);\r\n * ```\r\n * Output:\r\n * ```\r\n * `[[\"loaded\",\"\"],[\"rendered\",\"function () { console.log('Rendered'); }\"]]`\r\n * ```\r\n */\r\nexport function stringifyMap(map: EmbedProps['eventHandlers']): string {\r\n\r\n\t// Return empty string for empty/null map\r\n\tif (!map) {\r\n\t\treturn '';\r\n\t}\r\n\r\n\t// Get entries of map as array\r\n\tconst mapEntries = Array.from(map);\r\n\t\r\n\t// Return JSON string\r\n\treturn JSON.stringify(mapEntries.map((mapEntry) => {\r\n\t\t\r\n\t\t// Convert event handler method to a string containing its source code for comparison\r\n\t\treturn [\r\n\t\t\tmapEntry[0], \r\n\t\t\tmapEntry[1] ? mapEntry[1].toString() : ''\r\n\t\t]; \r\n\t}));\r\n};"],"sourceRoot":""}
1
+ {"version":3,"file":"powerbi-client-react.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,SAAUA,QAAQ,kBAAmBA,QAAQ,mBACrD,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,QAAS,iBAAkB,kBAAmBJ,GAC5B,iBAAZC,QACdA,QAAQ,wBAA0BD,EAAQG,QAAQ,SAAUA,QAAQ,kBAAmBA,QAAQ,mBAE/FJ,EAAK,wBAA0BC,EAAQD,EAAY,MAAGA,EAAK,kBAAmBA,EAAK,kBACpF,CATD,CASGO,MAAM,CAACC,EAAkCC,EAAkCC,I,kCCT9EP,EAAOD,QAAUQ,C,UCAjBP,EAAOD,QAAUO,C,UCAjBN,EAAOD,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GAD,QAAQC,MAAM,sBAAsB5B,KAAKP,MAAMa,YAAYa,M,mCAG/D,EAxTA,CAAkC,Y","sources":["webpack://powerbi-client-react/webpack/universalModuleDefinition","webpack://powerbi-client-react/external umd \"lodash.isequal\"","webpack://powerbi-client-react/external umd \"powerbi-client\"","webpack://powerbi-client-react/external umd \"react\"","webpack://powerbi-client-react/webpack/bootstrap","webpack://powerbi-client-react/webpack/runtime/compat get default export","webpack://powerbi-client-react/webpack/runtime/define property getters","webpack://powerbi-client-react/webpack/runtime/hasOwnProperty shorthand","webpack://powerbi-client-react/webpack/runtime/make namespace object","webpack://powerbi-client-react/./src/PowerBIEmbed.tsx","webpack://powerbi-client-react/./src/utils.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"), require(\"powerbi-client\"), require(\"lodash.isequal\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\", \"powerbi-client\", \"lodash.isequal\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"powerbi-client-react\"] = factory(require(\"react\"), require(\"powerbi-client\"), require(\"lodash.isequal\"));\n\telse\n\t\troot[\"powerbi-client-react\"] = factory(root[\"react\"], root[\"powerbi-client\"], root[\"lodash.isequal\"]);\n})(self, (__WEBPACK_EXTERNAL_MODULE__156__, __WEBPACK_EXTERNAL_MODULE__719__, __WEBPACK_EXTERNAL_MODULE__890__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__890__;","module.exports = __WEBPACK_EXTERNAL_MODULE__719__;","module.exports = __WEBPACK_EXTERNAL_MODULE__156__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// Copyright (c) Microsoft Corporation.\r\n// Licensed under the MIT License.\r\n\r\nimport * as React from 'react';\r\nimport {\r\n\tservice,\r\n\tfactories,\r\n\tReport,\r\n\tEmbed,\r\n\tDashboard,\r\n\tTile,\r\n\tQna,\r\n\tVisual,\r\n\tIEmbedSettings,\r\n\tIEmbedConfiguration,\r\n\tIQnaEmbedConfiguration,\r\n\tIVisualEmbedConfiguration,\r\n\tIReportEmbedConfiguration,\r\n\tIDashboardEmbedConfiguration,\r\n\tITileEmbedConfiguration,\r\n} from 'powerbi-client';\r\nimport { ReportLevelFilters } from 'powerbi-models';\r\nimport isEqual from 'lodash.isequal';\r\nimport { stringifyMap, SdkType, SdkWrapperVersion } from './utils';\r\n\r\n/**\r\n * Type for event handler function of embedded entity\r\n */\r\nexport type EventHandler = {\r\n\t(event?: service.ICustomEvent<any>, embeddedEntity?: Embed): void | null;\r\n};\r\n\r\n/**\r\n * Props interface for PowerBIEmbed component\r\n */\r\nexport interface EmbedProps {\r\n\r\n\t// Configuration for embedding the PowerBI entity (Required)\r\n\tembedConfig:\r\n\t\t| IReportEmbedConfiguration\r\n\t\t| IDashboardEmbedConfiguration\r\n\t\t| ITileEmbedConfiguration\r\n\t\t| IQnaEmbedConfiguration\r\n\t\t| IVisualEmbedConfiguration\r\n\t\t| IEmbedConfiguration;\r\n\r\n\t// Callback method to get the embedded PowerBI entity object (Optional)\r\n\tgetEmbeddedComponent?: { (embeddedComponent: Embed): void };\r\n\r\n\t// Map of pair of event name and its handler method to be triggered on the event (Optional)\r\n\teventHandlers?: Map<string, EventHandler>;\r\n\r\n\t// CSS class to be set on the embedding container (Optional)\r\n\tcssClassName?: string;\r\n\r\n\t// Phased embedding flag (Optional)\r\n\tphasedEmbedding?: boolean;\r\n\r\n\t// Provide a custom implementation of PowerBI service (Optional)\r\n\tservice?: service.Service;\r\n}\r\n\r\nexport enum EmbedType {\r\n\tReport = 'report',\r\n\tDashboard = 'dashboard',\r\n\tTile = 'tile',\r\n\tQna = 'qna',\r\n\tVisual = 'visual'\r\n}\r\n\r\n/**\r\n * Base react component to embed Power BI entities like: reports, dashboards, tiles, visual and qna containers.\r\n */\r\nexport class PowerBIEmbed extends React.Component<EmbedProps> {\r\n\r\n\t// Embedded entity\r\n\t// Note: Do not read or assign to this member variable directly, instead use the getter and setter\r\n\tprivate _embed?: Embed;\r\n\r\n\t// Powerbi service\r\n\tprivate powerbi: service.Service;\r\n\r\n\t// Ref to the HTML div element\r\n\tprivate containerRef = React.createRef<HTMLDivElement>();\r\n\r\n\t// JSON stringify of prev event handler map\r\n\tprivate prevEventHandlerMapString = '';\r\n\r\n\t// Getter for this._embed\r\n\tprivate get embed(): Embed | undefined {\r\n\t\treturn this._embed;\r\n\t};\r\n\r\n\t// Setter for this._embed\r\n\tprivate set embed(newEmbedInstance: Embed | undefined) {\r\n\t\tthis._embed = newEmbedInstance;\r\n\r\n\t\t// Invoke callback method in props to return this embed instance\r\n\t\tthis.invokeGetEmbedCallback();\r\n\t};\r\n\r\n\tconstructor(props: EmbedProps) {\r\n\t\tsuper(props);\r\n\r\n\t\tif (this.props.service) {\r\n\t\t\tthis.powerbi = this.props.service;\r\n\t\t}\r\n\t\telse {\r\n\t\t\tthis.powerbi = new service.Service(\r\n\t\t\t\tfactories.hpmFactory,\r\n\t\t\t\tfactories.wpmpFactory,\r\n\t\t\t\tfactories.routerFactory);\r\n\t\t}\r\n\r\n\t\tthis.powerbi.setSdkInfo(SdkType, SdkWrapperVersion);\r\n\t};\r\n\r\n\tcomponentDidMount(): void {\r\n\r\n\t\t// Check if HTML container is available\r\n\t\tif (this.containerRef.current) {\r\n\r\n\t\t\t// Decide to embed, load or bootstrap\r\n\t\t\tif (this.props.embedConfig.accessToken && this.props.embedConfig.embedUrl) {\r\n\t\t\t\tthis.embedEntity();\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tthis.embed = this.powerbi.bootstrap(this.containerRef.current, this.props.embedConfig);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Set event handlers if available\r\n\t\tif (this.props.eventHandlers && this.embed) {\r\n\t\t\tthis.setEventHandlers(this.embed, this.props.eventHandlers);\r\n\t\t}\r\n\t};\r\n\r\n\tasync componentDidUpdate(prevProps: EmbedProps): Promise<void> {\r\n\r\n\t\tthis.embedOrUpdateAccessToken(prevProps);\r\n\r\n\t\t// Set event handlers if available\r\n\t\tif (this.props.eventHandlers && this.embed) {\r\n\t\t\tthis.setEventHandlers(this.embed, this.props.eventHandlers);\r\n\t\t}\r\n\r\n\t\t// Allow settings update only when settings object in embedConfig of current and previous props is different\r\n\t\tif (!isEqual(this.props.embedConfig.settings, prevProps.embedConfig.settings)) {\r\n\t\t\tawait this.updateSettings();\r\n\t\t}\r\n\r\n\t\t// Update pageName and filters for a report\r\n\t\tif (this.props.embedConfig.type === EmbedType.Report) {\r\n\t\t\ttry {\r\n\t\t\t\t// Typecasting to IReportEmbedConfiguration\r\n\t\t\t\tconst embedConfig = this.props.embedConfig as IReportEmbedConfiguration;\r\n\t\t\t\tconst filters = embedConfig.filters as ReportLevelFilters[];\r\n\t\t\t\tconst prevEmbedConfig = prevProps.embedConfig as IReportEmbedConfiguration;\r\n\r\n\t\t\t\t// Set new page if available and different from the previous page\r\n\t\t\t\tif (embedConfig.pageName && embedConfig.pageName !== prevEmbedConfig.pageName) {\r\n\t\t\t\t\t// Upcast to Report and call setPage\r\n\t\t\t\t\tawait (this.embed as Report).setPage(embedConfig.pageName);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Set filters on the embedded report if available and different from the previous filter\r\n\t\t\t\tif (filters && !isEqual(filters, prevEmbedConfig.filters)) {\r\n\t\t\t\t\t// Upcast to Report and call setFilters\r\n\t\t\t\t\tawait (this.embed as Report).setFilters(filters);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Remove filters on the embedded report, if previously applied\r\n\t\t\t\telse if (!filters && prevEmbedConfig.filters) {\r\n\t\t\t\t\t// Upcast to Report and call removeFilters\r\n\t\t\t\t\tawait (this.embed as Report).removeFilters();\r\n\t\t\t\t}\r\n\t\t\t} catch (err) {\r\n\t\t\t\tconsole.error(err);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\tcomponentWillUnmount(): void {\r\n\t\t// Clean Up\r\n\t\tif (this.containerRef.current) {\r\n\t\t\tthis.powerbi.reset(this.containerRef.current);\r\n\t\t}\r\n\t};\r\n\r\n\trender(): JSX.Element {\r\n\t\treturn (\r\n\t\t\t<div\r\n\t\t\t\tref={this.containerRef}\r\n\t\t\t\tclassName={this.props.cssClassName}>\r\n\t\t\t</div>\r\n\t\t)\r\n\t};\r\n\r\n\t/**\r\n\t * Embed the powerbi entity (Load for phased embedding)\r\n\t */\r\n\tprivate embedEntity(): void {\r\n\t\t// Check if the HTML container is rendered and available\r\n\t\tif (!this.containerRef.current) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Load when props.phasedEmbedding is true and embed type is report, embed otherwise\r\n\t\tif (this.props.phasedEmbedding && this.props.embedConfig.type === EmbedType.Report) {\r\n\t\t\tthis.embed = this.powerbi.load(this.containerRef.current, this.props.embedConfig);\r\n\t\t}\r\n\t\telse {\r\n\t\t\tif (this.props.phasedEmbedding) {\r\n\t\t\t\tconsole.error(`Phased embedding is not supported for type ${this.props.embedConfig.type}`)\r\n\t\t\t}\r\n\t\t\tthis.embed = this.powerbi.embed(this.containerRef.current, this.props.embedConfig);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * When component updates, choose to _embed_ the powerbi entity or _update the accessToken_ in the embedded entity \r\n\t * or do nothing if the embedUrl and accessToken did not update in the new props\r\n\t * \r\n\t * @param prevProps EmbedProps\r\n\t * @returns void\r\n\t */\r\n\tprivate embedOrUpdateAccessToken(prevProps: EmbedProps): void {\r\n\r\n\t\t// Check if Embed URL and Access Token are present in current props\r\n\t\tif (!this.props.embedConfig.accessToken || !this.props.embedConfig.embedUrl) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Embed or load in the following scenarios\r\n\t\t//\t\t1. AccessToken was not provided in prev props (E.g. Report was bootstrapped earlier)\r\n\t\t//\t\t2. Embed URL is updated (E.g. New report is to be embedded)\r\n\t\tif (\r\n\t\t\tthis.containerRef.current &&\r\n\t\t\t(!prevProps.embedConfig.accessToken ||\r\n\t\t\t\tthis.props.embedConfig.embedUrl !== prevProps.embedConfig.embedUrl)\r\n\t\t) {\r\n\t\t\tthis.embedEntity();\r\n\t\t}\r\n\r\n\t\t// Set new access token,\r\n\t\t// when access token is updated but embed Url is same\r\n\t\telse if (\r\n\t\t\tthis.props.embedConfig.accessToken !== prevProps.embedConfig.accessToken &&\r\n\t\t\tthis.props.embedConfig.embedUrl === prevProps.embedConfig.embedUrl &&\r\n\t\t\tthis.embed\r\n\t\t) {\r\n\t\t\tthis.embed.setAccessToken(this.props.embedConfig.accessToken)\r\n\t\t\t\t.catch((error) => {\r\n\t\t\t\t\tconsole.error(`setAccessToken error: ${error}`);\r\n\t\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Sets all event handlers from the props on the embedded entity\r\n\t * \r\n\t * @param embed Embedded object\r\n\t * @param eventHandlers Array of eventhandlers to be set on embedded entity\r\n\t * @returns void\r\n\t */\r\n\tprivate setEventHandlers(\r\n\t\tembed: Embed,\r\n\t\teventHandlerMap: Map<string, EventHandler>\r\n\t): void {\r\n\t\t// Get string representation of eventHandlerMap\r\n\t\tconst eventHandlerMapString = stringifyMap(this.props.eventHandlers);\r\n\r\n\t\t// Check if event handler map changed\r\n\t\tif (this.prevEventHandlerMapString === eventHandlerMapString) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Update prev string representation of event handler map\r\n\t\tthis.prevEventHandlerMapString = eventHandlerMapString;\r\n\r\n\t\t// List of allowed events\r\n\t\tlet allowedEvents = Embed.allowedEvents;\r\n\r\n\t\tconst entityType = embed.embedtype;\r\n\r\n\t\t// Append entity specific events\r\n\t\tswitch (entityType) {\r\n\t\t\tcase EmbedType.Report:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Report.allowedEvents]\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Dashboard:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Dashboard.allowedEvents]\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Tile:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Tile.allowedEvents]\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Qna:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Qna.allowedEvents]\r\n\t\t\t\tbreak;\r\n\t\t\tcase EmbedType.Visual:\r\n\t\t\t\tallowedEvents = [...allowedEvents, ...Visual.allowedEvents]\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tconsole.error(`Invalid embed type ${entityType}`);\r\n\t\t}\r\n\r\n\t\t// Holds list of events which are not allowed\r\n\t\tconst invalidEvents: Array<string> = [];\r\n\r\n\t\t// Apply all provided event handlers\r\n\t\teventHandlerMap.forEach((eventHandlerMethod, eventName) => {\r\n\t\t\t// Check if this event is allowed\r\n\t\t\tif (allowedEvents.includes(eventName)) {\r\n\r\n\t\t\t\t// Removes event handler for this event\r\n\t\t\t\tembed.off(eventName);\r\n\r\n\t\t\t\t// Event handler is effectively removed for this event when eventHandlerMethod is null\r\n\t\t\t\tif (eventHandlerMethod) {\r\n\r\n\t\t\t\t\t// Set single event handler\r\n\t\t\t\t\tembed.on(eventName, (event: service.ICustomEvent<any>): void => {\r\n\t\t\t\t\t\teventHandlerMethod(event, this.embed);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse {\r\n\r\n\t\t\t\t// Add this event name to the list of invalid events\r\n\t\t\t\tinvalidEvents.push(eventName);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\t// Handle invalid events\r\n\t\tif (invalidEvents.length) {\r\n\t\t\tconsole.error(`Following events are invalid: ${invalidEvents.join(',')}`);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Returns the embedded object via _getEmbed_ callback method provided in props\r\n\t * \r\n\t * @returns void\r\n\t */\r\n\tprivate invokeGetEmbedCallback(): void {\r\n\t\tif (this.props.getEmbeddedComponent && this.embed) {\r\n\t\t\tthis.props.getEmbeddedComponent(this.embed);\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * Update settings from props of the embedded artifact\r\n\t * \r\n\t * @returns void\r\n\t */\r\n\tprivate async updateSettings(): Promise<void> {\r\n\t\tif (!this.embed || !this.props.embedConfig.settings) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tswitch (this.props.embedConfig.type) {\r\n\t\t\tcase EmbedType.Report: {\r\n\t\t\t\t// Typecasted to IEmbedSettings as props.embedConfig.settings can be ISettings via IQnaEmbedConfiguration\r\n\t\t\t\tconst settings = this.props.embedConfig.settings as IEmbedSettings;\r\n\r\n\t\t\t\ttry {\r\n\t\t\t\t\t// Upcast to Report and call updateSettings\r\n\t\t\t\t\tawait (this.embed as Report).updateSettings(settings);\r\n\t\t\t\t} catch (error) {\r\n\t\t\t\t\tconsole.error(`Error in method updateSettings: ${error}`);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase EmbedType.Dashboard:\r\n\t\t\tcase EmbedType.Tile:\r\n\t\t\tcase EmbedType.Qna:\r\n\t\t\tcase EmbedType.Visual:\r\n\t\t\t\t// updateSettings not applicable for these embedding types\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\t\t\t\tconsole.error(`Invalid embed type ${this.props.embedConfig.type}`);\r\n\t\t}\r\n\t};\r\n}\r\n","// Copyright (c) Microsoft Corporation.\r\n// Licensed under the MIT License.\r\n\r\nimport { EmbedProps } from \"./PowerBIEmbed\";\r\n\r\n/**\r\n * Get JSON string representation of the given map.\r\n * \r\n * @param map Map of event and corresponding handler method\r\n * \r\n * For example:\r\n * Input:\r\n * ```\r\n * Map([\r\n\t\t['loaded', null],\r\n\t\t['rendered', function () { console.log('Rendered'); }]\r\n\t]);\r\n * ```\r\n * Output:\r\n * ```\r\n * `[[\"loaded\",\"\"],[\"rendered\",\"function () { console.log('Rendered'); }\"]]`\r\n * ```\r\n */\r\nexport function stringifyMap(map: EmbedProps['eventHandlers']): string {\r\n\r\n\t// Return empty string for empty/null map\r\n\tif (!map) {\r\n\t\treturn '';\r\n\t}\r\n\r\n\t// Get entries of map as array\r\n\tconst mapEntries = Array.from(map);\r\n\t\r\n\t// Return JSON string\r\n\treturn JSON.stringify(mapEntries.map((mapEntry) => {\r\n\t\t\r\n\t\t// Convert event handler method to a string containing its source code for comparison\r\n\t\treturn [\r\n\t\t\tmapEntry[0], \r\n\t\t\tmapEntry[1] ? mapEntry[1].toString() : ''\r\n\t\t]; \r\n\t}));\r\n};\r\n\r\n// SDK information to be used with service instance\r\nexport const SdkType = \"powerbi-client-react\";\r\nexport const SdkWrapperVersion = \"1.3.5\";"],"names":["root","factory","exports","module","require","define","amd","self","__WEBPACK_EXTERNAL_MODULE__156__","__WEBPACK_EXTERNAL_MODULE__719__","__WEBPACK_EXTERNAL_MODULE__890__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","EmbedType","props","containerRef","prevEventHandlerMapString","service","powerbi","factories","setSdkInfo","this","_embed","newEmbedInstance","invokeGetEmbedCallback","componentDidMount","current","embedConfig","accessToken","embedUrl","embedEntity","embed","bootstrap","eventHandlers","setEventHandlers","componentDidUpdate","prevProps","embedOrUpdateAccessToken","settings","updateSettings","type","Report","filters","prevEmbedConfig","pageName","setPage","setFilters","removeFilters","console","error","componentWillUnmount","reset","render","ref","className","cssClassName","phasedEmbedding","load","setAccessToken","catch","eventHandlerMap","eventHandlerMapString","map","mapEntries","Array","from","JSON","stringify","mapEntry","toString","stringifyMap","allowedEvents","Embed","entityType","embedtype","Dashboard","Tile","Qna","Visual","invalidEvents","forEach","eventHandlerMethod","eventName","includes","off","on","event","push","length","join","getEmbeddedComponent"],"sourceRoot":""}
package/dist/utils.d.ts CHANGED
@@ -18,3 +18,5 @@ import { EmbedProps } from "./PowerBIEmbed";
18
18
  * ```
19
19
  */
20
20
  export declare function stringifyMap(map: EmbedProps['eventHandlers']): string;
21
+ export declare const SdkType = "powerbi-client-react";
22
+ export declare const SdkWrapperVersion = "1.3.5";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powerbi-client-react",
3
- "version": "1.3.0",
3
+ "version": "1.3.5",
4
4
  "description": "React wrapper for powerbi-client library",
5
5
  "main": "dist/powerbi-client-react.js",
6
6
  "types": "dist/powerbi-client-react.d.ts",
@@ -30,7 +30,7 @@
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
32
  "lodash.isequal": "^4.5.0",
33
- "powerbi-client": "^2.15.1"
33
+ "powerbi-client": "^2.21.1"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": ">= 16"
@@ -46,15 +46,15 @@
46
46
  "eslint": "^7.4.0",
47
47
  "eslint-plugin-react": "^7.20.0",
48
48
  "jasmine-core": "^3.5.0",
49
- "karma": "^5.0.9",
49
+ "karma": "^6.3.17",
50
+ "karma-chrome-launcher": "^3.1.0",
50
51
  "karma-jasmine": "^3.1.1",
51
- "karma-phantomjs-launcher": "^1.0.4",
52
52
  "react": "^16.13.1",
53
53
  "react-app-polyfill": "^1.0.6",
54
54
  "react-dom": "^16.13.1",
55
55
  "ts-loader": "^7.0.5",
56
56
  "typescript": "^3.9.6",
57
- "webpack": "^4.43.0",
58
- "webpack-cli": "^3.3.11"
57
+ "webpack": "^5.71.0",
58
+ "webpack-cli": "^4.9.2"
59
59
  }
60
60
  }