diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b5469d..4cce0b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 2.0.1 / 18 June 2019 + +When the `AdvertisingProvider` unmounted when it didn't have a config, a null pointer execption +ocurred. This was fixed. + +* See [PR 13](https://github.com/technology-ebay-de/react-prebid/pull/13) + ## 2.0.0 / 16 June 2019 You can now update the `AdvertisingProvider` by re-rendering it with a different configuration prop than before. diff --git a/index.js b/index.js index 31cfdf1..3609a6f 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=3)}([function(t,e){t.exports=require("prop-types")},function(t,e){t.exports=require("react")},function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var i=Array.isArray,o=Object.keys,a=Object.prototype.hasOwnProperty;t.exports=function t(e,r){if(e===r)return!0;if(e&&r&&"object"==n(e)&&"object"==n(r)){var u,s,c,f=i(e),l=i(r);if(f&&l){if((s=e.length)!=r.length)return!1;for(u=s;0!=u--;)if(!t(e[u],r[u]))return!1;return!0}if(f!=l)return!1;var p=e instanceof Date,h=r instanceof Date;if(p!=h)return!1;if(p&&h)return e.getTime()==r.getTime();var d=e instanceof RegExp,y=r instanceof RegExp;if(d!=y)return!1;if(d&&y)return e.toString()==r.toString();var v=o(e);if((s=v.length)!==o(r).length)return!1;for(u=s;0!=u--;)if(!a.call(r,v[u]))return!1;for(u=s;0!=u--;)if(!t(e[c=v[u]],r[c]))return!1;return!0}return e!=e&&r!=r}},function(t,e,r){r(4),t.exports=r(6)},function(t,e,r){(function(t){function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var r=function(t){"use strict";var r,n=Object.prototype,i=n.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,o=Object.create(i.prototype),a=new R(n||[]);return o._invoke=function(t,e,r){var n=l;return function(i,o){if(n===h)throw new Error("Generator is already running");if(n===d){if("throw"===i)throw o;return q()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var u=E(a,r);if(u){if(u===y)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=d,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=h;var s=f(t,e,r);if("normal"===s.type){if(n=r.done?d:p,s.arg===y)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=d,r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l="suspendedStart",p="suspendedYield",h="executing",d="completed",y={};function v(){}function g(){}function m(){}var b={};b[a]=function(){return this};var w=Object.getPrototypeOf,O=w&&w(w(T([])));O&&O!==n&&i.call(O,a)&&(b=O);var S=m.prototype=v.prototype=Object.create(b);function k(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function x(t){var r;this._invoke=function(n,o){function a(){return new Promise(function(r,a){!function r(n,o,a,u){var s=f(t[n],t,o);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"===e(l)&&i.call(l,"__await")?Promise.resolve(l.__await).then(function(t){r("next",t,a,u)},function(t){r("throw",t,a,u)}):Promise.resolve(l).then(function(t){c.value=t,a(c)},function(t){return r("throw",t,a,u)})}u(s.arg)}(n,o,r,a)})}return r=r?r.then(a,a):a()}}function E(t,e){var n=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,E(t,e),"throw"===e.method))return y;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var i=f(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,y;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,y):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,y)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function T(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(s&&c){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;P(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:T(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),y}},t}("object"===e(t)?t.exports:{});try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}}).call(this,r(5)(t))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,r){"use strict";r.r(e);var n=r(1),i=r.n(n),o=function(t){return t.reduce(function(t,e){return t.concat(e.prebid.map(function(t){return{code:e.id,mediaTypes:t.mediaTypes,bids:t.bids}}))},[])};function a(t){return function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e1&&void 0!==arguments[1]?arguments[1]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=e,this.slots={},this.plugins=r,this.gptSizeMappings={},this.customEventCallbacks={},this.customEventHandlers={},this.queue=[],e&&this[E]()}var e,r,n;return e=t,r=[{key:"setup",value:function(){var e=c(regeneratorRuntime.mark(function e(){var r,n,i,o,a,u,s,c,f,l,p=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.slots,n=this.queue,this[b](),e.next=4,Promise.all([t[x](this[y].bind(this)),t[k](this[g].bind(this))]);case 4:if(0!==n.length){e.next=6;break}return e.abrupt("return");case 6:for(i=!0,o=!1,a=void 0,e.prev=9,u=function(){var t=c.value,e=t.id,r=t.customEventHandlers;Object.keys(r).forEach(function(t){return p.customEventCallbacks[t]||(p.customEventCallbacks[t]={}),p.customEventCallbacks[t][e]=r[t]})},s=n[Symbol.iterator]();!(i=(c=s.next()).done);i=!0)u();e.next=18;break;case 14:e.prev=14,e.t0=e.catch(9),o=!0,a=e.t0;case 18:e.prev=18,e.prev=19,i||null==s.return||s.return();case 21:if(e.prev=21,!o){e.next=24;break}throw a;case 24:return e.finish(21);case 25:return e.finish(18);case 26:f=n.map(function(t){return t.id}),l=n.map(function(t){var e=t.id;return r[e]}),t[x](function(){return window.pbjs.requestBids({adUnitCodes:f,bidsBackHandler:function(){window.pbjs.setTargetingForGPTAsync(f),t[k](function(){return window.googletag.pubads().refresh(l)})}})});case 29:case"end":return e.stop()}},e,this,[[9,14,18,26],[19,,21,25]])}));return function(){return e.apply(this,arguments)}}()},{key:"teardown",value:function(){var e=c(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this[O](),e.next=3,Promise.all([t[x](this[v].bind(this)),t[k](this[m].bind(this))]);case 3:this.slots={},this.gptSizeMappings={},this.queue={};case 6:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"activate",value:function(e){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.slots;0!==Object.values(i).length?(Object.keys(n).forEach(function(t){return r.customEventCallbacks[t]||(r.customEventCallbacks[t]={}),r.customEventCallbacks[t][e]=n[t]}),t[x](function(){return window.pbjs.requestBids({adUnitCodes:[e],bidsBackHandler:function(){window.pbjs.setTargetingForGPTAsync([e]),t[k](function(){return window.googletag.pubads().refresh([i[e]])})}})})):this.queue.push({id:e,customEventHandlers:n})}},{key:"isConfigReady",value:function(){return Boolean(this.config)}},{key:"setConfig",value:function(t){this.config=t,this[E]()}},{key:b,value:function(){var t=this;this.config.customEvents&&Object.keys(this.config.customEvents).forEach(function(e){return t[w](e,t.config.customEvents[e])})}},{key:w,value:function(t,e){var r=e.eventMessagePrefix,n=e.divIdPrefix,i=this.customEventCallbacks;this.customEventHandlers[t]=function(e){var o=e.data;if("string"==typeof o&&o.startsWith("".concat(r))){var a="".concat(n||"").concat(o.substr(r.length)),u=i[t];if(u){var s=u[a];s&&s()}}},window.addEventListener("message",this.customEventHandlers[t])}},{key:O,value:function(){var t=this;this.config.customEvents&&Object.keys(this.config.customEvents).forEach(function(e){return window.removeEventListener("message",t.customEventHandlers[e])})}},{key:l,value:function(){if(this.config.sizeMappings)for(var t=0,e=Object.entries(this.config.sizeMappings);t0&&l.setCollapseEmptyDiv.apply(l,a(i));for(var d=0,y=Object.entries(s);d=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(s&&c){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;P(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:T(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),y}},t}("object"===e(t)?t.exports:{});try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}}).call(this,r(5)(t))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,r){"use strict";r.r(e);var n=r(1),i=r.n(n),o=function(t){return t.reduce(function(t,e){return t.concat(e.prebid.map(function(t){return{code:e.id,mediaTypes:t.mediaTypes,bids:t.bids}}))},[])};function a(t){return function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e1&&void 0!==arguments[1]?arguments[1]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=e,this.slots={},this.plugins=r,this.gptSizeMappings={},this.customEventCallbacks={},this.customEventHandlers={},this.queue=[],e&&this[E]()}var e,r,n;return e=t,r=[{key:"setup",value:function(){var e=c(regeneratorRuntime.mark(function e(){var r,n,i,o,a,u,s,c,f,l,p=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.slots,n=this.queue,this[b](),e.next=4,Promise.all([t[x](this[y].bind(this)),t[k](this[g].bind(this))]);case 4:if(0!==n.length){e.next=6;break}return e.abrupt("return");case 6:for(i=!0,o=!1,a=void 0,e.prev=9,u=function(){var t=c.value,e=t.id,r=t.customEventHandlers;Object.keys(r).forEach(function(t){return p.customEventCallbacks[t]||(p.customEventCallbacks[t]={}),p.customEventCallbacks[t][e]=r[t]})},s=n[Symbol.iterator]();!(i=(c=s.next()).done);i=!0)u();e.next=18;break;case 14:e.prev=14,e.t0=e.catch(9),o=!0,a=e.t0;case 18:e.prev=18,e.prev=19,i||null==s.return||s.return();case 21:if(e.prev=21,!o){e.next=24;break}throw a;case 24:return e.finish(21);case 25:return e.finish(18);case 26:f=n.map(function(t){return t.id}),l=n.map(function(t){var e=t.id;return r[e]}),t[x](function(){return window.pbjs.requestBids({adUnitCodes:f,bidsBackHandler:function(){window.pbjs.setTargetingForGPTAsync(f),t[k](function(){return window.googletag.pubads().refresh(l)})}})});case 29:case"end":return e.stop()}},e,this,[[9,14,18,26],[19,,21,25]])}));return function(){return e.apply(this,arguments)}}()},{key:"teardown",value:function(){var e=c(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this[O](),e.next=3,Promise.all([t[x](this[v].bind(this)),t[k](this[m].bind(this))]);case 3:this.slots={},this.gptSizeMappings={},this.queue={};case 6:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"activate",value:function(e){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.slots;0!==Object.values(i).length?(Object.keys(n).forEach(function(t){return r.customEventCallbacks[t]||(r.customEventCallbacks[t]={}),r.customEventCallbacks[t][e]=n[t]}),t[x](function(){return window.pbjs.requestBids({adUnitCodes:[e],bidsBackHandler:function(){window.pbjs.setTargetingForGPTAsync([e]),t[k](function(){return window.googletag.pubads().refresh([i[e]])})}})})):this.queue.push({id:e,customEventHandlers:n})}},{key:"isConfigReady",value:function(){return Boolean(this.config)}},{key:"setConfig",value:function(t){this.config=t,this[E]()}},{key:b,value:function(){var t=this;this.config.customEvents&&Object.keys(this.config.customEvents).forEach(function(e){return t[w](e,t.config.customEvents[e])})}},{key:w,value:function(t,e){var r=e.eventMessagePrefix,n=e.divIdPrefix,i=this.customEventCallbacks;this.customEventHandlers[t]=function(e){var o=e.data;if("string"==typeof o&&o.startsWith("".concat(r))){var a="".concat(n||"").concat(o.substr(r.length)),u=i[t];if(u){var s=u[a];s&&s()}}},window.addEventListener("message",this.customEventHandlers[t])}},{key:O,value:function(){var t=this;this.config.customEvents&&Object.keys(this.config.customEvents).forEach(function(e){return window.removeEventListener("message",t.customEventHandlers[e])})}},{key:l,value:function(){if(this.config.sizeMappings)for(var t=0,e=Object.entries(this.config.sizeMappings);t0&&l.setCollapseEmptyDiv.apply(l,a(i));for(var d=0,y=Object.entries(s);d