post-robot
Advanced tools
Comparing version 2.0.20 to 2.0.21
{ | ||
"name": "post-robot", | ||
"main": "index.js", | ||
"version": "2.0.20", | ||
"version": "2.0.21", | ||
"authors": [ | ||
@@ -6,0 +6,0 @@ "Daniel Brain <dbrain@paypal.com>" |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("postRobot",[],n):"object"==typeof exports?exports.postRobot=n():e.postRobot=n()}(this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,n,t){"use strict";function r(){(0,u.registerGlobals)(),i.util.listen(window,"message",a.messageListener),(0,i.initOnReady)()}Object.defineProperty(n,"__esModule",{value:!0}),n.Promise=void 0;var o=t(1);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(8);Object.defineProperty(n,"Promise",{enumerable:!0,get:function(){return i.Promise}});var a=t(6),u=t(17);r(),n["default"]=e.exports},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.util=n.openBridge=n.reset=n.parent=void 0;var r=t(2);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(25);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(26);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})});var a=t(27);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return a[e]}})});var u=t(6);Object.defineProperty(n,"reset",{enumerable:!0,get:function(){return u.resetListeners}});var s=t(18);Object.defineProperty(n,"openBridge",{enumerable:!0,get:function(){return s.openBridge}});var c=t(12);Object.defineProperty(n,"util",{enumerable:!0,get:function(){return c.util}});var d=t(14);n.parent=(0,d.getParentWindow)()},function(e,n,t){"use strict";function r(e){return s.promise.nodeify(new s.promise.Promise(function(n,t){if(!e.name)throw new Error("Expected options.name");if(!e.window)throw new Error("Expected options.window");if(a.CONFIG.MOCK_MODE)e.window=window;else if("string"==typeof e.window){var r=document.getElementById(e.window);if(!r)throw new Error("Expected options.window "+e.window+" to be a valid element id");if("iframe"!==r.tagName.toLowerCase())throw new Error("Expected options.window "+e.window+" to be an iframe");if(e.window=r.contentWindow,!e.window)throw new Error("Expected options.window")}var o=e.name+"_"+s.util.uniqueID();if(u.listeners.response[o]=e,(0,s.isWindowClosed)(e.window))throw new Error("Target window is closed");var i=!1;return e.respond=function(e,r){return e||(i=!0),e?t(e):n(r)},s.promise.run(function(){return(0,s.getParentWindow)(e.window)===window?(0,s.onWindowReady)(e.window):void 0}).then(function(){e.timeout&&!function(){var n=s.util.intervalTimeout(e.timeout,100,function(r){return i?n.cancel():r?void 0:t(new Error("Post message response timed out after "+e.timeout+" ms"))},e.timeout)}(),(0,u.sendMessage)(e.window,{hash:o,type:a.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,name:e.name,data:e.data},e.domain||"*")["catch"](t);var n=s.util.intervalTimeout(a.CONFIG.ACK_TIMEOUT,100,function(r){return e.ack?n.cancel():r?void 0:t(new Error("No ack for postMessage "+e.name+" in "+a.CONFIG.ACK_TIMEOUT+"ms"))})})["catch"](t)}),e.callback)}function o(e,n,t,o,i){return i||(!o&&t instanceof Function?(i=t,o={},t={}):o instanceof Function&&(i=o,o={})),o=o||{},o.window=e,o.name=n,o.data=t,o.callback=i,r(o)}function i(e,n,t,r){var i=(0,s.getParentWindow)();if(!window)throw new Error("Window does not have a parent");return o(i,e,n,t,r)}Object.defineProperty(n,"__esModule",{value:!0}),n.request=r,n.send=o,n.sendToParent=i;var a=t(3),u=t(6),s=t(8)},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(4);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(5);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,n,t){"use strict";function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}Object.defineProperty(n,"__esModule",{value:!0}),n.CONFIG=void 0;var o,i=t(5);n.CONFIG={ALLOW_POSTMESSAGE_POPUP:!1,LOG_LEVEL:"info",ACK_TIMEOUT:500,LOG_TO_PAGE:!1,MOCK_MODE:!1,ALLOWED_POST_MESSAGE_METHODS:(o={},r(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,!0),r(o,i.CONSTANTS.SEND_STRATEGIES.GLOBAL_METHOD,!0),r(o,i.CONSTANTS.SEND_STRATEGIES.FOREIGN_BRIDGE,!0),r(o,i.CONSTANTS.SEND_STRATEGIES.LOCAL_BRIDGE,!0),o)}},function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=n.CONSTANTS={POST_MESSAGE_TYPE:{REQUEST:"postrobot_message_request",RESPONSE:"postrobot_message_response",ACK:"postrobot_message_ack"},POST_MESSAGE_ACK:{SUCCESS:"success",ERROR:"error"},POST_MESSAGE_NAMES:{METHOD:"postrobot_method",READY:"postrobot_ready"},WINDOW_TYPES:{FULLPAGE:"fullpage",POPUP:"popup",IFRAME:"iframe"},WINDOW_PROPS:{POSTROBOT:"__postRobot__"},SERIALIZATION_TYPES:{METHOD:"postrobot_method"},SEND_STRATEGIES:{POST_MESSAGE:"postrobot_post_message",GLOBAL_METHOD:"postrobot_global_method",FOREIGN_BRIDGE:"postrobot_foreign_bridge",LOCAL_BRIDGE:"postrobot_local_bridge"}};n.POST_MESSAGE_NAMES_LIST=Object.keys(t.POST_MESSAGE_NAMES).map(function(e){return t.POST_MESSAGE_NAMES[e]})},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(7);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(21);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(23);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,n,t){"use strict";function r(e){try{e=JSON.parse(e)}catch(n){return}if(e.type&&w.RECEIVE_MESSAGE_TYPES[e.type])return e}function o(e,n){var t={"window.parent":function(e){return window.parent},"window.opener":function(e){return(0,c.getOpener)(window)},"window.parent.opener":function(e){return(0,c.getOpener)(window.parent)}},r=void 0;try{r=t[e](n)}catch(o){throw new Error("Can not get "+e+": "+o.message)}if(!r)throw new Error("Can not get "+e+": not available");return r}function i(e,n){if(!s.CONFIG.MOCK_MODE&&n){var t=(0,l.getRequestListener)(n.name,e);if(n.type!==s.CONSTANTS.POST_MESSAGE_TYPE.REQUEST||!n.name||!t||t.proxy!==!1){var r=(n.type===s.CONSTANTS.POST_MESSAGE_TYPE.REQUEST||n.type===s.CONSTANTS.POST_MESSAGE_TYPE.ACK)&&l.listeners.response[n.hash];if(!r)for(var i=0;i<l.listeners.proxies.length;i++){var a=l.listeners.proxies[i];if(e===a.from)return a.to}if(n.targetHint){var u=o(n.targetHint,n.target);return delete n.targetHint,u}if(n.target&&n.target!==(0,c.getWindowId)(window)){var d=(0,c.getWindowById)(n.target);if(!d)throw new Error("Unable to find window to proxy message to: "+n.target);return d}}}}function a(e){try{e.source}catch(n){return}var t=e.source,a=e.origin,u=e.data,d=r(u);if(d&&-1===p.indexOf(d.id)){p.push(d.id),(0,c.registerWindow)(d.source,t);var l=void 0;try{l=i(t,d)}catch(n){return c.log.debug(n.message)}var S=-1!==s.POST_MESSAGE_NAMES_LIST.indexOf(d.name)?"debug":"info";if(c.log.logLevel(S,[l?"#receiveproxy":"#receive",d.type,d.name,d]),l)return(0,c.isWindowClosed)(l)?c.log.debug("Target window is closed: "+d.target+" - can not proxy "+d.type+" "+d.name):(delete d.target,(0,f.sendMessage)(l,d,d.domain||"*",!0));if(d.originalSource!==d.source){if(d.sourceHint)t=o(d.sourceHint,d.originalSource),delete d.sourceHint;else{var E=(0,c.getWindowById)(d.originalSource);if(!E)throw new Error("Can not find original message source: "+d.originalSource);t=E}(0,c.registerWindow)(d.originalSource,t)}if((0,c.isWindowClosed)(t))return c.log.debug("Source window is closed: "+d.originalSource+" - can not send "+d.type+" "+d.name);if(s.CONFIG.MOCK_MODE)return w.RECEIVE_MESSAGE_TYPES[d.type](t,d,a);d.data&&(d.data=(0,c.deserializeMethods)(t,d.data)),w.RECEIVE_MESSAGE_TYPES[d.type](t,d,a)}}function u(e){try{e.source}catch(n){return}e={source:e.source||e.sourceElement,origin:e.origin||e.originalEvent.origin,data:e.data};try{(0,d.emulateIERestrictions)(e.source,window)}catch(n){return}a(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.receiveMessage=a,n.messageListener=u;var s=t(3),c=t(8),d=t(17),f=t(21),l=t(23),w=t(24),p=[]},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(9);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(12);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(13);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})});var a=t(14);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return a[e]}})});var u=t(15);Object.keys(u).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return u[e]}})});var s=t(11);Object.keys(s).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return s[e]}})});var c=t(16);Object.keys(c).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return c[e]}})})},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.promise=n.Promise=void 0;var r=t(10),o=t(11),i=n.Promise=r.SyncPromise,a=n.promise={Promise:i,run:function(e){return i.resolve().then(e)},nextTick:function(e){return new i(function(n,t){(0,o.nextTick)(function(){return a.run(e).then(n,t)})})},method:function(e){return function(){var n=this,t=arguments;return i.resolve().then(function(){return e.apply(n,t)})}},nodeify:function(e,n){return n?void e.then(function(e){n(null,e)},function(e){n(e)}):e},deNodeify:function(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];return new i(function(n,r){try{return t.length<e.length?e.apply(void 0,t.concat([function(e,t){return e?r(e):n(t)}])):a.run(function(){return e.apply(void 0,t)}).then(n,r)}catch(o){return r(o)}})},map:function(e,n){for(var t=[],r=function(r){t.push(a.run(function(){return n(e[r])}))},o=0;o<e.length;o++)r(o);return i.all(t)}}},function(e,n){"use strict";function t(e,n,t){function r(){if(a){if(s)return t(o);if(u)return n(i)}}var o,i,a=!1,u=!1,s=!1;try{e(function(e){i=e,u=!0,r()},function(e){o=e,s=!0,r()})}catch(c){return t(c)}a=!0,r()}function r(){window.Promise=o}Object.defineProperty(n,"__esModule",{value:!0}),n.patchPromise=r;var o=n.SyncPromise=function(e){if(this.resolved=!1,this.rejected=!1,this.handlers=[],e){var n=this;t(e,function(e){return n.resolve(e)},function(e){return n.reject(e)})}};o.resolve=function(e){return e&&e.then?e:(new o).resolve(e)},o.reject=function(e){return(new o).reject(e)},o.prototype.resolve=function(e){if(this.resolved||this.rejected)return this;if(e&&e.then)throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},o.prototype.reject=function(e){if(this.resolved||this.rejected)return this;if(e&&e.then)throw new Error("Can not reject promise with another promise");return this.rejected=!0,this.value=e,this.dispatch(),this},o.prototype.dispatch=function(){if(this.resolved||this.rejected)for(;this.handlers.length;){var e,n,t=this.handlers.shift();try{this.resolved?e=t.onSuccess?t.onSuccess(this.value):this.value:t.onError?e=t.onError(this.value):n=this.value}catch(r){n=r}if(e===this)throw new Error("Can not return a promise from the the same promise");n?t.promise.reject(n):e&&e.then?e.then(function(e){t.promise.resolve(e)},function(e){t.promise.reject(e)}):t.promise.resolve(e)}},o.prototype.then=function(e,n){var t=new o;return this.handlers.push({promise:t,onSuccess:e,onError:n}),this.dispatch(),t},o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.done=function(e,n){this.then(e,n||function(e){console.error(e.stack||e.toString())})},o.all=function(e){for(var n=new o,t=e.length,r=[],i=0;i<e.length;i++)e[i].then(function(e){r[i]=e,t-=1,0===t&&n.resolve(r)},function(e){n.reject(e)});return n}},function(e,n,t){"use strict";function r(e){return window.setImmediate?window.setImmediate.call(window,e):window.nextTick?window.nextTick.call(window,e):(a.push(e),void window.postMessage(i,"*"))}Object.defineProperty(n,"__esModule",{value:!0}),n.nextTick=r;var o=t(12),i="__nextTick__postRobot__"+o.util.uniqueID(),a=[];window.addEventListener("message",function(e){if(e.data===i){var n=a.shift();n.call()}})},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.util=void 0;var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=t(3),i=n.util={isPopup:function(){return Boolean(window.opener)},isIframe:function(){return Boolean(window.parent&&window!==window.parent)},isFullpage:function(){return Boolean(!i.isIframe()&&!i.isPopup())},getType:function(){return i.isPopup()?o.CONSTANTS.WINDOW_TYPES.POPUP:i.isIframe()?o.CONSTANTS.WINDOW_TYPES.IFRAME:o.CONSTANTS.WINDOW_TYPES.FULLPAGE},once:function(e){if(!e)return e;var n=!1;return function(){return n?void 0:(n=!0,e.apply(this,arguments))}},noop:function(){},safeHasProp:function(e,n){try{return!!e[n]}catch(t){return!1}},safeGetProp:function(e,n){try{return e[n]}catch(t){return}},listen:function(e,n,t){return e.addEventListener?e.addEventListener(n,t):e.attachEvent("on"+n,t),{cancel:function(){e.removeEventListener?e.removeEventListener(n,t):e.detachEvent("on"+n,t)}}},apply:function(e,n,t){return e.apply instanceof Function?e.apply(n,t):e(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9])},find:function(e,n,t){if(!e)return t;for(var r=0;r<e.length;r++)if(n(e[r]))return e[r];return t},map:function(e,n){for(var t=[],r=0;r<e.length;r++)t.push(n(e[r]));return t},some:function(e,n){n=n||Boolean;for(var t=0;t<e.length;t++)if(n(e[t]))return!0;return!1},keys:function(e){var n=[];for(var t in e)e.hasOwnProperty(t)&&n.push(t);return n},values:function(e){var n=[];for(var t in e)e.hasOwnProperty(t)&&n.push(e[t]);return n},getByValue:function(e,n){for(var t in e)if(e.hasOwnProperty(t)&&e[t]===n)return t},uniqueID:function(){var e="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return e.charAt(Math.floor(Math.random()*e.length))})},memoize:function(e){var n={};return function(){var t=JSON.stringify(Array.prototype.slice.call(arguments));return n.hasOwnProperty(t)||(n[t]=e.apply(this,arguments)),n[t]}},extend:function(e,n){if(!n)return e;for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);return e},each:function(e,n){if(e instanceof Array)for(var t=0;t<e.length;t++)n(e[t],t);else if(e instanceof Object&&!(e instanceof Function))for(var r in e)e.hasOwnProperty(r)&&n(e[r],r)},replaceObject:function(e,n){var t=e instanceof Array?[]:{};return i.each(e,function(e,o){var a=n(e);void 0!==a?t[o]=a:"object"===("undefined"==typeof e?"undefined":r(e))&&null!==e?t[o]=i.replaceObject(e,n):t[o]=e}),t},safeInterval:function(e,n){function t(){r=setTimeout(t,n),e.call()}var r=void 0;return r=setTimeout(t,n),{cancel:function(){clearTimeout(r)}}},intervalTimeout:function(e,n,t){var r=i.safeInterval(function(){e-=n,e=0>=e?0:e,0===e&&r.cancel(),t(e)},n);return r},getDomain:function(e){return e.mockDomain||e.location.protocol+"//"+e.location.host}}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.log=void 0;var r=t(12),o=t(3),i=["debug","info","warn","error"],a=n.log={clearLogs:function(){if(window.console&&window.console.clear&&window.console.clear(),o.CONFIG.LOG_TO_PAGE){var e=document.getElementById("postRobotLogs");e&&e.parentNode.removeChild(e)}},writeToPage:function(e,n){setTimeout(function(){var t=document.getElementById("postRobotLogs");t||(t=document.createElement("div"),t.id="postRobotLogs",t.style.cssText="width: 800px; font-family: monospace; white-space: pre-wrap;",document.body.appendChild(t));var o=document.createElement("div"),i=(new Date).toString().split(" ")[4],a=r.util.map(n,function(e){if("string"==typeof e)return e;if(!e)return toString.call(e);var n=void 0;try{n=JSON.stringify(e,0,2)}catch(t){n="[object]"}return"\n\n"+n+"\n\n"}).join(" "),u=i+" "+e+" "+a;o.innerHTML=u;var s={log:"#ddd",warn:"orange",error:"red",info:"blue",debug:"#aaa"}[e];o.style.cssText="margin-top: 10px; color: "+s+";",t.childNodes.length?t.insertBefore(o,t.childNodes[0]):t.appendChild(o)})},logLevel:function(e,n){i.indexOf(e)<i.indexOf(o.CONFIG.LOG_LEVEL)||(n=Array.prototype.slice.call(n),n.unshift(window.location.host),n.unshift(r.util.getType().toLowerCase()),n.unshift("[post-robot]"),o.CONFIG.LOG_TO_PAGE&&a.writeToPage(e,n),window.console&&(window.console[e]||(e="log"),window.console[e]&&window.console[e].apply(window.console,n)))},debug:function(){a.logLevel("debug",arguments)},info:function(){a.logLevel("info",arguments)},warn:function(){a.logLevel("warn",arguments)},error:function(){a.logLevel("error",arguments)}}},function(e,n,t){"use strict";function r(e){for(var n=p,t=Array.isArray(n),r=0,n=t?n:n[Symbol.iterator]();;){var o;if(t){if(r>=n.length)break;o=n[r++]}else{if(r=n.next(),r.done)break;o=r.value}var i=o;if(i.win===e){if(!i.match)return!1;i.match=!1;try{i.match=w.util.getDomain(window)===w.util.getDomain(e)}catch(a){return}return i.match}}var u=!1;try{w.util.getDomain(window)===w.util.getDomain(e)&&(u=!0)}catch(a){}return p.push({win:e,match:u}),u}function o(e){if(e)try{return e.opener}catch(n){return}}function i(e){e=e||window;var n=o(e);return n?n:e.parent!==e?e.parent:void 0}function a(e){if(e===window)return E;for(var n=S.length-1;n>=0;n--){var t=S[n];try{if(t.win===e)return t.id}catch(r){continue}}}function u(e){if(e===window.name||e===E)return window;if(window.frames&&window.frames[e])return window.frames[e];for(var n=S.length-1;n>=0;n--){var t=S[n];try{if(t.id===e)return t.win}catch(r){continue}}}function s(e,n){for(var t=S,r=Array.isArray(t),o=0,t=r?t:t[Symbol.iterator]();;){var i;if(r){if(o>=t.length)break;i=t[o++]}else{if(o=t.next(),o.done)break;i=o.value}var a=i;try{if(a.id===e&&a.win===n)return}catch(u){continue}if(a.id===e&&a.win!==n)throw new Error("Can not register a duplicate window with name "+e)}S.push({id:e,win:n})}function c(e,n){if(e===n)return!0;var t=a(e),r=a(n);return!(!t||!r||t!==r)}function d(e,n){try{return e.top===n.top}catch(t){return!1}}function f(e,n){var t=void 0;try{t=e[n]}catch(r){}return t}function l(e){try{return!e||e.closed||"undefined"==typeof e.closed||r(e)&&f(e,"mockclosed")}catch(n){return!0}}Object.defineProperty(n,"__esModule",{value:!0}),n.isSameDomain=r,n.getOpener=o,n.getParentWindow=i,n.getWindowId=a,n.getWindowById=u,n.registerWindow=s,n.isWindowEqual=c,n.isSameTopWindow=d,n.isWindowClosed=l;var w=t(12),p=[],S=[],E=window.name||w.util.getType()+"_"+w.util.uniqueID(),O=window.open;window.open=function(e,n,t,r){n||(n=w.util.uniqueID(),arguments[1]=n);var o=w.util.apply(O,this,arguments);return s(n,o),o}},function(e,n,t){"use strict";function r(e){return e instanceof Object&&e.__type__===s.CONSTANTS.SERIALIZATION_TYPES.METHOD&&e.__id__}function o(e,n){var t=c.util.uniqueID();return f[t]={win:e,method:n},{__type__:s.CONSTANTS.SERIALIZATION_TYPES.METHOD,__id__:t}}function i(e,n){return l(),c.util.replaceObject({obj:n},function(n){return n instanceof Function?o(e,n):void 0}).obj}function a(e,n){return function(){var t=Array.prototype.slice.call(arguments);return(0,d.send)(e,s.CONSTANTS.POST_MESSAGE_NAMES.METHOD,{id:n.__id__,args:t})}}function u(e,n){return c.util.replaceObject({obj:n},function(n){return r(n)?a(e,n):void 0}).obj}Object.defineProperty(n,"__esModule",{value:!0}),n.listenForMethods=void 0,n.serializeMethod=o,n.serializeMethods=i,n.deserializeMethod=a,n.deserializeMethods=u;var s=t(3),c=t(12),d=t(1),f={},l=n.listenForMethods=c.util.once(function(){(0,d.on)(s.CONSTANTS.POST_MESSAGE_NAMES.METHOD,function(e,n){if(!f[n.id])throw new Error("Could not find method with id: "+n.id);if(f[n.id].win!==e)throw new Error("Method window does not match");return f[n.id].method.apply(null,n.args)})})},function(e,n,t){"use strict";function r(){(0,u.on)(i.CONSTANTS.POST_MESSAGE_NAMES.READY,function(e,n){d.push(e);for(var t=f,r=Array.isArray(t),o=0,t=r?t:t[Symbol.iterator]();;){var i;if(r){if(o>=t.length)break;i=t[o++]}else{if(o=t.next(),o.done)break;i=o.value}var a=i;a.win===e&&a.resolve(a.win)}});var e=(0,a.getParentWindow)();e&&(0,u.send)(e,i.CONSTANTS.POST_MESSAGE_NAMES.READY,{})["catch"](function(e){s.log.debug(e.stack||e.toString())})}function o(e){return new c.promise.Promise(function(n){return-1!==d.indexOf(e)?n(e):void f.push({win:e,resolve:n})})}Object.defineProperty(n,"__esModule",{value:!0}),n.initOnReady=r,n.onWindowReady=o;var i=t(3),a=t(14),u=t(1),s=t(13),c=t(9),d=[],f=[]},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(18);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(19);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(20);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,n,t){"use strict";function r(){return a.promise.Promise.resolve().then(function(){return s})}function o(e){try{if(!e||!e.frames||!e.frames.length)return;for(var n=0;n<e.frames.length;n++)try{var t=e.frames[n];if(t&&t!==window&&(0,a.isSameDomain)(t)&&t[i.CONSTANTS.WINDOW_PROPS.POSTROBOT])return t}catch(r){continue}}catch(r){return}}Object.defineProperty(n,"__esModule",{value:!0}),n.openBridge=void 0,n.getBridge=r,n.getBridgeFor=o;var i=t(3),a=t(8),u="postrobot_bridge",s=void 0;n.openBridge=a.util.memoize(function(e){if(s)throw new Error("Only one bridge supported");var n=new a.promise.Promise(function(e){return window.document.body?e(window.document):void window.document.addEventListener("DOMContentLoaded",function(n){return e(window.document)})});return s=n.then(function(n){a.log.debug("Opening bridge:",e);var t=u+"_"+a.util.uniqueID(),r=n.createElement("iframe");return r.setAttribute("name",t),r.setAttribute("id",t),r.setAttribute("style","margin: 0; padding: 0; border: 0px none; overflow: hidden;"),r.setAttribute("frameborder","0"),r.setAttribute("border","0"),r.setAttribute("scrolling","no"),r.setAttribute("allowTransparency","true"),r.setAttribute("tabindex","-1"),r.setAttribute("hidden","true"),r.setAttribute("title",""),r.setAttribute("role","presentation"),r.src=e,n.body.appendChild(r),new a.promise.Promise(function(e,n){r.onload=e,r.onerror=n}).then(function(){return(0,a.onWindowReady)(r.contentWindow)})})})},function(e,n,t){"use strict";function r(){if(window[o.CONSTANTS.WINDOW_PROPS.POSTROBOT])throw new Error("Attempting to load postRobot twice on the same window");window[o.CONSTANTS.WINDOW_PROPS.POSTROBOT]={postMessage:function(e){(0,i.nextTick)(function(){return(0,a.receiveMessage)(e)})}}}Object.defineProperty(n,"__esModule",{value:!0}),n.registerGlobals=r;var o=t(3),i=t(8),a=t(6)},function(e,n,t){"use strict";function r(e,n){if(!o.CONFIG.ALLOW_POSTMESSAGE_POPUP&&!(0,i.isSameTopWindow)(e,n))throw new Error("Can not send and receive post messages between two different windows (disabled to emulate IE)")}Object.defineProperty(n,"__esModule",{value:!0}),n.emulateIERestrictions=r;var o=t(3),i=t(8)},function(e,n,t){"use strict";function r(e,n){var t=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],r=u.util.uniqueID(),o=(0,u.getWindowId)(window),a=u.util.getType(),s=(0,u.getWindowId)(e);return i({},n,t,{id:n.id||r,source:o,originalSource:n.originalSource||o,windowType:a,originalWindowType:n.originalWindowType||a,target:n.target||s})}function o(e,n,t,o){return u.promise.run(function(){n=r(e,n,{data:(0,u.serializeMethods)(e,n.data),domain:t});var i=-1!==a.POST_MESSAGE_NAMES_LIST.indexOf(n.name)?"debug":"info";if(u.log.logLevel(i,[o?"#sendproxy":"#send",n.type,n.name,n]),a.CONFIG.MOCK_MODE)return delete n.target,window[a.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:u.util.getDomain(window),source:window,data:JSON.stringify(n)});if(e===window)throw new Error("Attemping to send message to self");if((0,u.isWindowClosed)(e))throw new Error("Window is closed");u.log.debug("Running send message strategies",n);var c=[];return u.promise.map(u.util.keys(s.SEND_MESSAGE_STRATEGIES),function(r){return u.promise.run(function(){if(!a.CONFIG.ALLOWED_POST_MESSAGE_METHODS[r])throw new Error("Strategy disallowed: "+r);return s.SEND_MESSAGE_STRATEGIES[r](e,n,t)}).then(function(){return c.push(r+": success"),!0},function(e){return c.push(r+": "+e.message),!1})}).then(function(e){var t=u.util.some(e),r=n.type+" "+n.name+" "+(t?"success":"error")+":\n - "+c.join("\n - ")+"\n";if(u.log.debug(r),!t)throw new Error(r)})})}Object.defineProperty(n,"__esModule",{value:!0});var i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e};n.buildMessage=r,n.sendMessage=o;var a=t(3),u=t(8),s=t(22)},function(e,n,t){"use strict";function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}Object.defineProperty(n,"__esModule",{value:!0}),n.SEND_MESSAGE_STRATEGIES=void 0;var o,i=t(3),a=t(8),u=t(17);n.SEND_MESSAGE_STRATEGIES=(o={},r(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,function(e,n,t){return(0,u.emulateIERestrictions)(window,e),e.postMessage(JSON.stringify(n,0,2),t)}),r(o,i.CONSTANTS.SEND_STRATEGIES.GLOBAL_METHOD,function(e,n,t){if(!(0,a.isSameDomain)(e))throw new Error("Window is not on the same domain");var r=a.util.getDomain(window),o=void 0;try{o=a.util.getDomain(e)}catch(u){throw new Error("Can not read target window domain: "+u.message)}if(r!==o)throw new Error("Can not send global message - source "+r+" does not match target "+o);if("*"!==t&&o!==t)throw new Error("Can post post through global method - specified domain "+t+" does not match target domain "+o);if(!a.util.safeHasProp(e,i.CONSTANTS.WINDOW_PROPS.POSTROBOT))throw new Error("post-robot not available on target window at "+o);e[i.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:a.util.getDomain(window),source:window,data:JSON.stringify(n,0,2)})}),r(o,i.CONSTANTS.SEND_STRATEGIES.FOREIGN_BRIDGE,function(e,n,t){if((0,a.isSameTopWindow)(window,e))throw new Error("Can only use bridge to communicate between two different windows, not between frames");var r=(0,u.getBridgeFor)(e);if(!r)throw new Error("No bridge available in window");if(!(0,a.isSameDomain)(r))throw new Error("Bridge is not on the same domain");var o=a.util.getDomain(window),s=void 0;try{s=a.util.getDomain(r)}catch(c){throw new Error("Can not read bridge window domain: "+c.message)}if(o!==s)throw new Error("Can not accept global message through bridge - source "+o+" does not match bridge "+s);if(!a.util.safeHasProp(r,i.CONSTANTS.WINDOW_PROPS.POSTROBOT))throw new Error("post-robot not available on bridge at "+s);n.targetHint="window.parent",window===(0,a.getOpener)(e)&&(n.sourceHint="window.opener"),r[i.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:a.util.getDomain(window),source:window,data:JSON.stringify(n,0,2)})}),r(o,i.CONSTANTS.SEND_STRATEGIES.LOCAL_BRIDGE,function(e,n,t){if((0,a.isSameTopWindow)(window,e))throw new Error("Can only use bridge to communicate between two different windows, not between frames");if(!n.target)throw new Error("Can not post message down through bridge without target");return e===(0,a.getOpener)(window)&&(n.targetHint="window.parent.opener"),window===(0,a.getOpener)(e)&&(n.sourceHint="window.opener"),(0,u.getBridge)().then(function(r){if(!r)throw new Error("Bridge not initialized");if(e===r)throw new Error("Message target is bridge");r.postMessage(JSON.stringify(n,0,2),t)})}),o)},function(e,n,t){"use strict";function r(){n.listeners=s={request:[],response:{},proxies:[]}}function o(e,n){for(var t=s.request,r=Array.isArray(t),o=0,t=r?t:t[Symbol.iterator]();;){var i;if(r){if(o>=t.length)break;i=t[o++]}else{if(o=t.next(),o.done)break;i=o.value}var a=i;if(a.name===e){if(!a.win)return a.options;if(n&&(0,u.isWindowEqual)(n,a.win))return a.options}}}function i(e){for(var n=void 0,t=s.request,r=Array.isArray(t),o=0,t=r?t:t[Symbol.iterator]();;){var i;if(r){if(o>=t.length)break;i=t[o++]}else{if(o=t.next(),o.done)break;i=o.value}var a=i;if(a.options===e){n=a;break}}n&&s.request.splice(s.request.indexOf(n),1)}function a(e,n,t,r){var a=o(e,n);if(a){if(!r)throw new Error("Request listener already exists for "+e);i(a)}s.request.push({name:e,win:n,options:t})}Object.defineProperty(n,"__esModule",{value:!0}),n.listeners=void 0,n.resetListeners=r,n.getRequestListener=o,n.removeRequestListener=i,n.addRequestListener=a;var u=t(8),s=n.listeners=void 0;r()},function(e,n,t){"use strict";function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}Object.defineProperty(n,"__esModule",{value:!0}),n.RECEIVE_MESSAGE_TYPES=void 0;var o,i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},a=t(3),u=t(8),s=t(21),c=t(23);n.RECEIVE_MESSAGE_TYPES=(o={},r(o,a.CONSTANTS.POST_MESSAGE_TYPE.ACK,function(e,n,t){var r=c.listeners.response[n.hash];if(!r)throw new Error("No handler found for post message ack for message: "+n.name+" in "+window.location.href);r.ack=!0}),r(o,a.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,function(e,n,t){function r(t){return(0,u.isWindowClosed)(e)?void 0:(0,s.sendMessage)(e,i({target:n.originalSource,hash:n.hash,name:n.name},t),"*")}var o=(0,c.getRequestListener)(n.name,e);return r({type:a.CONSTANTS.POST_MESSAGE_TYPE.ACK}).then(function(){return u.promise.run(function(){if(!o)throw new Error("No postmessage request handler for "+n.name+" in "+window.location.href);if(o.domain){var r="string"==typeof o.domain&&t===o.domain||o.domain instanceof RegExp&&t.match(o.domain);if(!r)throw new Error("Message origin "+t+" does not match domain "+o.domain)}return u.promise.deNodeify(o.handler,e,n.data)}).then(function(e){return r({type:a.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:a.CONSTANTS.POST_MESSAGE_ACK.SUCCESS,data:e})},function(e){return r({type:a.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:a.CONSTANTS.POST_MESSAGE_ACK.ERROR,error:e.stack?e.message+"\n"+e.stack:e.toString()})})})["catch"](function(e){return o&&o.handleError?o.handleError(e):void u.log.error(e.stack||e.toString())})}),r(o,a.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,function(e,n,t){var r=c.listeners.response[n.hash];if(!r)throw new Error("No response handler found for post message response "+n.name+" in "+window.location.href);return delete c.listeners.response[n.hash],n.ack===a.CONSTANTS.POST_MESSAGE_ACK.ERROR?r.respond(new Error(n.error)):n.ack===a.CONSTANTS.POST_MESSAGE_ACK.SUCCESS?r.respond(null,n.data||n.response):void 0}),o)},function(e,n,t){"use strict";function r(e){if(!e.name)throw new Error("Expected options.name");e.handler=e.handler||u.util.noop,e.errorHandler=e.errorHandler||function(e){throw e},e.once&&!function(){var n=e.handler;e.handler=u.util.once(function(){return(0,s.removeRequestListener)(e),n.apply(this,arguments)})}();var n=e.override||a.CONFIG.MOCK_MODE;return(0,s.addRequestListener)(e.name,e.window,e,n),e.handleError=function(n){e.errorHandler(n)},e.window&&e.errorOnClose&&!function(){var n=u.util.safeInterval(function(){(0,u.isWindowClosed)(e.window)&&(n.cancel(),e.handleError(new Error("Post message target window is closed")))},50)}(), | ||
{cancel:function(){(0,s.removeRequestListener)(e)}}}function o(e,n,t,o){return n instanceof Function&&(o=t,t=n,n={}),n.name=e,n.handler=t||n.handler,n.errorHandler=o||n.errorHandler,r(n)}function i(e,n,t,o){n instanceof Function&&(o=t,t=n,n={}),n.name=e,n.handler=t||n.handler,n.errorHandler=o||n.errorHandler,n.once=!0;var i=new u.promise.Promise(function(e,t){n.handler=n.handler||e,n.errorHandler=n.errorHandler||t}),a=r(n);return u.util.extend(i,a),i}Object.defineProperty(n,"__esModule",{value:!0}),n.listen=r,n.on=o,n.once=i;var a=t(3),u=t(8),s=t(6)},function(e,n,t){"use strict";function r(e,n){i.listeners.proxies.push({from:e,to:n}),i.listeners.proxies.push({from:n,to:e})}function o(e,n){for(var t=[],r=0;r<i.listeners.proxies.length;r++){var o=i.listeners.proxies[r];(o.to===e&&o.from===n||o.to===n&&o.from===e)&&t.push(o)}for(var a=0;a<t.length;a++)i.listeners.proxies.splice(i.listeners.proxies.indexOf(t[a]),1)}Object.defineProperty(n,"__esModule",{value:!0}),n.proxy=r,n.unproxy=o;var i=t(6)},function(e,n,t){"use strict";function r(){i.CONFIG.MOCK_MODE=!0}function o(){i.CONFIG.MOCK_MODE=!1}Object.defineProperty(n,"__esModule",{value:!0}),n.CONSTANTS=n.CONFIG=void 0,n.enableMockMode=r,n.disableMockMode=o;var i=t(3);Object.defineProperty(n,"CONFIG",{enumerable:!0,get:function(){return i.CONFIG}}),Object.defineProperty(n,"CONSTANTS",{enumerable:!0,get:function(){return i.CONSTANTS}})}])}); | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define("postRobot",[],n):"object"==typeof exports?exports.postRobot=n():e.postRobot=n()}(this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var t={};return n.m=e,n.c=t,n.p="",n(0)}([function(e,n,t){"use strict";function r(){(0,u.registerGlobals)(),i.util.listen(window,"message",a.messageListener),(0,i.initOnReady)()}Object.defineProperty(n,"__esModule",{value:!0}),n.Promise=void 0;var o=t(1);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(8);Object.defineProperty(n,"Promise",{enumerable:!0,get:function(){return i.Promise}});var a=t(6),u=t(17);r(),n["default"]=e.exports},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.util=n.openBridge=n.reset=n.parent=void 0;var r=t(2);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(25);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(26);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})});var a=t(27);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return a[e]}})});var u=t(6);Object.defineProperty(n,"reset",{enumerable:!0,get:function(){return u.resetListeners}});var s=t(18);Object.defineProperty(n,"openBridge",{enumerable:!0,get:function(){return s.openBridge}});var c=t(12);Object.defineProperty(n,"util",{enumerable:!0,get:function(){return c.util}});var d=t(14);n.parent=(0,d.getParentWindow)()},function(e,n,t){"use strict";function r(e){return s.promise.nodeify(new s.promise.Promise(function(n,t){if(!e.name)throw new Error("Expected options.name");if(!e.window)throw new Error("Expected options.window");if(a.CONFIG.MOCK_MODE)e.window=window;else if("string"==typeof e.window){var r=document.getElementById(e.window);if(!r)throw new Error("Expected options.window "+e.window+" to be a valid element id");if("iframe"!==r.tagName.toLowerCase())throw new Error("Expected options.window "+e.window+" to be an iframe");if(e.window=r.contentWindow,!e.window)throw new Error("Expected options.window")}var o=e.name+"_"+s.util.uniqueID();if(u.listeners.response[o]=e,(0,s.isWindowClosed)(e.window))throw new Error("Target window is closed");var i=!1;return e.respond=function(e,r){return e||(i=!0),e?t(e):n(r)},s.promise.run(function(){return(0,s.getParentWindow)(e.window)===window?(0,s.onWindowReady)(e.window):void 0}).then(function(){e.timeout&&!function(){var n=s.util.intervalTimeout(e.timeout,100,function(r){return i?n.cancel():r?void 0:t(new Error("Post message response timed out after "+e.timeout+" ms"))},e.timeout)}(),(0,u.sendMessage)(e.window,{hash:o,type:a.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,name:e.name,data:e.data},e.domain||"*")["catch"](t);var n=s.util.intervalTimeout(a.CONFIG.ACK_TIMEOUT,100,function(r){return e.ack?n.cancel():r?void 0:t(new Error("No ack for postMessage "+e.name+" in "+a.CONFIG.ACK_TIMEOUT+"ms"))})})["catch"](t)}),e.callback)}function o(e,n,t,o,i){return i||(!o&&t instanceof Function?(i=t,o={},t={}):o instanceof Function&&(i=o,o={})),o=o||{},o.window=e,o.name=n,o.data=t,o.callback=i,r(o)}function i(e,n,t,r){var i=(0,s.getParentWindow)();if(!window)throw new Error("Window does not have a parent");return o(i,e,n,t,r)}Object.defineProperty(n,"__esModule",{value:!0}),n.request=r,n.send=o,n.sendToParent=i;var a=t(3),u=t(6),s=t(8)},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(4);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(5);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,n,t){"use strict";function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}Object.defineProperty(n,"__esModule",{value:!0}),n.CONFIG=void 0;var o,i=t(5);n.CONFIG={ALLOW_POSTMESSAGE_POPUP:!1,LOG_LEVEL:"info",ACK_TIMEOUT:500,LOG_TO_PAGE:!1,MOCK_MODE:!1,ALLOWED_POST_MESSAGE_METHODS:(o={},r(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,!0),r(o,i.CONSTANTS.SEND_STRATEGIES.GLOBAL_METHOD,!0),r(o,i.CONSTANTS.SEND_STRATEGIES.FOREIGN_BRIDGE,!0),r(o,i.CONSTANTS.SEND_STRATEGIES.LOCAL_BRIDGE,!0),o)}},function(e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var t=n.CONSTANTS={POST_MESSAGE_TYPE:{REQUEST:"postrobot_message_request",RESPONSE:"postrobot_message_response",ACK:"postrobot_message_ack"},POST_MESSAGE_ACK:{SUCCESS:"success",ERROR:"error"},POST_MESSAGE_NAMES:{METHOD:"postrobot_method",READY:"postrobot_ready"},WINDOW_TYPES:{FULLPAGE:"fullpage",POPUP:"popup",IFRAME:"iframe"},WINDOW_PROPS:{POSTROBOT:"__postRobot__"},SERIALIZATION_TYPES:{METHOD:"postrobot_method"},SEND_STRATEGIES:{POST_MESSAGE:"postrobot_post_message",GLOBAL_METHOD:"postrobot_global_method",FOREIGN_BRIDGE:"postrobot_foreign_bridge",LOCAL_BRIDGE:"postrobot_local_bridge"}};n.POST_MESSAGE_NAMES_LIST=Object.keys(t.POST_MESSAGE_NAMES).map(function(e){return t.POST_MESSAGE_NAMES[e]})},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(7);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(21);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(23);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,n,t){"use strict";function r(e){try{e=JSON.parse(e)}catch(n){return}if(e.type&&w.RECEIVE_MESSAGE_TYPES[e.type])return e}function o(e,n){var t={"window.parent":function(e){return window.parent},"window.opener":function(e){return(0,c.getOpener)(window)},"window.parent.opener":function(e){return(0,c.getOpener)(window.parent)}},r=void 0;try{r=t[e](n)}catch(o){throw new Error("Can not get "+e+": "+o.message)}if(!r)throw new Error("Can not get "+e+": not available");return r}function i(e,n){if(!s.CONFIG.MOCK_MODE&&n){var t=(0,l.getRequestListener)(n.name,e);if(n.type!==s.CONSTANTS.POST_MESSAGE_TYPE.REQUEST||!n.name||!t||t.proxy!==!1){var r=(n.type===s.CONSTANTS.POST_MESSAGE_TYPE.REQUEST||n.type===s.CONSTANTS.POST_MESSAGE_TYPE.ACK)&&l.listeners.response[n.hash];if(!r)for(var i=0;i<l.listeners.proxies.length;i++){var a=l.listeners.proxies[i];if(e===a.from)return a.to}if(n.targetHint){var u=o(n.targetHint,n.target);return delete n.targetHint,u}if(n.target&&n.target!==(0,c.getWindowId)(window)){var d=(0,c.getWindowById)(n.target);if(!d)throw new Error("Unable to find window to proxy message to: "+n.target);return d}}}}function a(e){try{e.source}catch(n){return}var t=e.source,a=e.origin,u=e.data,d=r(u);if(d&&-1===p.indexOf(d.id)){p.push(d.id),(0,c.registerWindow)(d.source,t);var l=void 0;try{l=i(t,d)}catch(n){return c.log.debug(n.message)}var S=-1!==s.POST_MESSAGE_NAMES_LIST.indexOf(d.name)||d.type===s.CONSTANTS.POST_MESSAGE_TYPE.ACK||l?"debug":"info";if(c.log.logLevel(S,[l?"#receiveproxy":"#receive",d.type,d.name,d]),l)return(0,c.isWindowClosed)(l)?c.log.debug("Target window is closed: "+d.target+" - can not proxy "+d.type+" "+d.name):(delete d.target,(0,f.sendMessage)(l,d,d.domain||"*",!0));if(d.originalSource!==d.source){if(d.sourceHint)t=o(d.sourceHint,d.originalSource),delete d.sourceHint;else{var E=(0,c.getWindowById)(d.originalSource);if(!E)throw new Error("Can not find original message source: "+d.originalSource);t=E}(0,c.registerWindow)(d.originalSource,t)}if((0,c.isWindowClosed)(t))return c.log.debug("Source window is closed: "+d.originalSource+" - can not send "+d.type+" "+d.name);if(s.CONFIG.MOCK_MODE)return w.RECEIVE_MESSAGE_TYPES[d.type](t,d,a);d.data&&(d.data=(0,c.deserializeMethods)(t,d.data)),w.RECEIVE_MESSAGE_TYPES[d.type](t,d,a)}}function u(e){try{e.source}catch(n){return}e={source:e.source||e.sourceElement,origin:e.origin||e.originalEvent.origin,data:e.data};try{(0,d.emulateIERestrictions)(e.source,window)}catch(n){return}a(e)}Object.defineProperty(n,"__esModule",{value:!0}),n.receiveMessage=a,n.messageListener=u;var s=t(3),c=t(8),d=t(17),f=t(21),l=t(23),w=t(24),p=[]},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(9);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(12);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(13);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})});var a=t(14);Object.keys(a).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return a[e]}})});var u=t(15);Object.keys(u).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return u[e]}})});var s=t(11);Object.keys(s).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return s[e]}})});var c=t(16);Object.keys(c).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return c[e]}})})},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.promise=n.Promise=void 0;var r=t(10),o=t(11),i=n.Promise=r.SyncPromise,a=n.promise={Promise:i,run:function(e){return i.resolve().then(e)},nextTick:function(e){return new i(function(n,t){(0,o.nextTick)(function(){return a.run(e).then(n,t)})})},method:function(e){return function(){var n=this,t=arguments;return i.resolve().then(function(){return e.apply(n,t)})}},nodeify:function(e,n){return n?void e.then(function(e){n(null,e)},function(e){n(e)}):e},deNodeify:function(e){for(var n=arguments.length,t=Array(n>1?n-1:0),r=1;n>r;r++)t[r-1]=arguments[r];return new i(function(n,r){try{return t.length<e.length?e.apply(void 0,t.concat([function(e,t){return e?r(e):n(t)}])):a.run(function(){return e.apply(void 0,t)}).then(n,r)}catch(o){return r(o)}})},map:function(e,n){for(var t=[],r=function(r){t.push(a.run(function(){return n(e[r])}))},o=0;o<e.length;o++)r(o);return i.all(t)}}},function(e,n){"use strict";function t(e,n,t){function r(){if(a){if(s)return t(o);if(u)return n(i)}}var o,i,a=!1,u=!1,s=!1;try{e(function(e){i=e,u=!0,r()},function(e){o=e,s=!0,r()})}catch(c){return t(c)}a=!0,r()}function r(){window.Promise=o}Object.defineProperty(n,"__esModule",{value:!0}),n.patchPromise=r;var o=n.SyncPromise=function(e){if(this.resolved=!1,this.rejected=!1,this.handlers=[],e){var n=this;t(e,function(e){return n.resolve(e)},function(e){return n.reject(e)})}};o.resolve=function(e){return e&&e.then?e:(new o).resolve(e)},o.reject=function(e){return(new o).reject(e)},o.prototype.resolve=function(e){if(this.resolved||this.rejected)return this;if(e&&e.then)throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},o.prototype.reject=function(e){if(this.resolved||this.rejected)return this;if(e&&e.then)throw new Error("Can not reject promise with another promise");return this.rejected=!0,this.value=e,this.dispatch(),this},o.prototype.dispatch=function(){if(this.resolved||this.rejected)for(;this.handlers.length;){var e,n,t=this.handlers.shift();try{this.resolved?e=t.onSuccess?t.onSuccess(this.value):this.value:t.onError?e=t.onError(this.value):n=this.value}catch(r){n=r}if(e===this)throw new Error("Can not return a promise from the the same promise");n?t.promise.reject(n):e&&e.then?e.then(function(e){t.promise.resolve(e)},function(e){t.promise.reject(e)}):t.promise.resolve(e)}},o.prototype.then=function(e,n){var t=new o;return this.handlers.push({promise:t,onSuccess:e,onError:n}),this.dispatch(),t},o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.done=function(e,n){this.then(e,n||function(e){console.error(e.stack||e.toString())})},o.all=function(e){for(var n=new o,t=e.length,r=[],i=0;i<e.length;i++)e[i].then(function(e){r[i]=e,t-=1,0===t&&n.resolve(r)},function(e){n.reject(e)});return n}},function(e,n,t){"use strict";function r(e){a.push(e),window.postMessage(i,"*")}Object.defineProperty(n,"__esModule",{value:!0}),n.nextTick=r;var o=t(12),i="__nextTick__postRobot__"+o.util.uniqueID(),a=[];window.addEventListener("message",function(e){if(e.data===i){var n=a.shift();n.call()}})},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.util=void 0;var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=t(3),i=n.util={isPopup:function(){return Boolean(window.opener)},isIframe:function(){return Boolean(window.parent&&window!==window.parent)},isFullpage:function(){return Boolean(!i.isIframe()&&!i.isPopup())},getType:function(){return i.isPopup()?o.CONSTANTS.WINDOW_TYPES.POPUP:i.isIframe()?o.CONSTANTS.WINDOW_TYPES.IFRAME:o.CONSTANTS.WINDOW_TYPES.FULLPAGE},once:function(e){if(!e)return e;var n=!1;return function(){return n?void 0:(n=!0,e.apply(this,arguments))}},noop:function(){},safeHasProp:function(e,n){try{return!!e[n]}catch(t){return!1}},safeGetProp:function(e,n){try{return e[n]}catch(t){return}},listen:function(e,n,t){return e.addEventListener?e.addEventListener(n,t):e.attachEvent("on"+n,t),{cancel:function(){e.removeEventListener?e.removeEventListener(n,t):e.detachEvent("on"+n,t)}}},apply:function(e,n,t){return e.apply instanceof Function?e.apply(n,t):e(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9])},find:function(e,n,t){if(!e)return t;for(var r=0;r<e.length;r++)if(n(e[r]))return e[r];return t},map:function(e,n){for(var t=[],r=0;r<e.length;r++)t.push(n(e[r]));return t},some:function(e,n){n=n||Boolean;for(var t=0;t<e.length;t++)if(n(e[t]))return!0;return!1},keys:function(e){var n=[];for(var t in e)e.hasOwnProperty(t)&&n.push(t);return n},values:function(e){var n=[];for(var t in e)e.hasOwnProperty(t)&&n.push(e[t]);return n},getByValue:function(e,n){for(var t in e)if(e.hasOwnProperty(t)&&e[t]===n)return t},uniqueID:function(){var e="0123456789abcdef";return"xxxxxxxxxx".replace(/./g,function(){return e.charAt(Math.floor(Math.random()*e.length))})},memoize:function(e){var n={};return function(){var t=JSON.stringify(Array.prototype.slice.call(arguments));return n.hasOwnProperty(t)||(n[t]=e.apply(this,arguments)),n[t]}},extend:function(e,n){if(!n)return e;for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);return e},each:function(e,n){if(e instanceof Array)for(var t=0;t<e.length;t++)n(e[t],t);else if(e instanceof Object&&!(e instanceof Function))for(var r in e)e.hasOwnProperty(r)&&n(e[r],r)},replaceObject:function(e,n){var t=e instanceof Array?[]:{};return i.each(e,function(e,o){var a=n(e);void 0!==a?t[o]=a:"object"===("undefined"==typeof e?"undefined":r(e))&&null!==e?t[o]=i.replaceObject(e,n):t[o]=e}),t},safeInterval:function(e,n){function t(){r=setTimeout(t,n),e.call()}var r=void 0;return r=setTimeout(t,n),{cancel:function(){clearTimeout(r)}}},intervalTimeout:function(e,n,t){var r=i.safeInterval(function(){e-=n,e=0>=e?0:e,0===e&&r.cancel(),t(e)},n);return r},getDomain:function(e){return e.mockDomain||e.location.protocol+"//"+e.location.host}}},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.log=void 0;var r=t(12),o=t(3),i=["debug","info","warn","error"],a=n.log={clearLogs:function(){if(window.console&&window.console.clear&&window.console.clear(),o.CONFIG.LOG_TO_PAGE){var e=document.getElementById("postRobotLogs");e&&e.parentNode.removeChild(e)}},writeToPage:function(e,n){setTimeout(function(){var t=document.getElementById("postRobotLogs");t||(t=document.createElement("div"),t.id="postRobotLogs",t.style.cssText="width: 800px; font-family: monospace; white-space: pre-wrap;",document.body.appendChild(t));var o=document.createElement("div"),i=(new Date).toString().split(" ")[4],a=r.util.map(n,function(e){if("string"==typeof e)return e;if(!e)return toString.call(e);var n=void 0;try{n=JSON.stringify(e,0,2)}catch(t){n="[object]"}return"\n\n"+n+"\n\n"}).join(" "),u=i+" "+e+" "+a;o.innerHTML=u;var s={log:"#ddd",warn:"orange",error:"red",info:"blue",debug:"#aaa"}[e];o.style.cssText="margin-top: 10px; color: "+s+";",t.childNodes.length?t.insertBefore(o,t.childNodes[0]):t.appendChild(o)})},logLevel:function(e,n){i.indexOf(e)<i.indexOf(o.CONFIG.LOG_LEVEL)||(n=Array.prototype.slice.call(n),n.unshift(window.location.host),n.unshift(r.util.getType().toLowerCase()),n.unshift("[post-robot]"),o.CONFIG.LOG_TO_PAGE&&a.writeToPage(e,n),window.console&&(window.console[e]||(e="log"),window.console[e]&&window.console[e].apply(window.console,n)))},debug:function(){a.logLevel("debug",arguments)},info:function(){a.logLevel("info",arguments)},warn:function(){a.logLevel("warn",arguments)},error:function(){a.logLevel("error",arguments)}}},function(e,n,t){"use strict";function r(e,n){var t=void 0;try{t=e[n]}catch(r){}return t}function o(e){for(var n=p,t=Array.isArray(n),r=0,n=t?n:n[Symbol.iterator]();;){var o;if(t){if(r>=n.length)break;o=n[r++]}else{if(r=n.next(),r.done)break;o=r.value}var i=o;if(i.win===e){if(!i.match)return!1;i.match=!1;try{i.match=w.util.getDomain(window)===w.util.getDomain(e)}catch(a){return}return i.match}}var u=!1;try{w.util.getDomain(window)===w.util.getDomain(e)&&(u=!0)}catch(a){}return p.push({win:e,match:u}),u}function i(e){try{return!e||e.closed||"undefined"==typeof e.closed||o(e)&&r(e,"mockclosed")}catch(n){return!0}}function a(e){if(e)try{return e.opener}catch(n){return}}function u(e){e=e||window;var n=a(e);return n?n:e.parent!==e?e.parent:void 0}function s(e){if(e===window)return E;for(var n=S.length-1;n>=0;n--){var t=S[n];try{if(t.win===e)return t.id}catch(r){continue}}}function c(e){if(e===window.name||e===E)return window;if(window.frames&&window.frames[e])return window.frames[e];for(var n=S.length-1;n>=0;n--){var t=S[n];try{if(t.id===e)return t.win}catch(r){continue}}}function d(e,n){for(var t=S,r=Array.isArray(t),o=0,t=r?t:t[Symbol.iterator]();;){var a;if(r){if(o>=t.length)break;a=t[o++]}else{if(o=t.next(),o.done)break;a=o.value}var u=a;try{if(u.id===e&&u.win===n)return}catch(s){continue}if(u.id===e&&u.win!==n&&!i(u.win))throw new Error("Can not register a duplicate window with name "+e)}S.push({id:e,win:n})}function f(e,n){if(e===n)return!0;var t=s(e),r=s(n);return!(!t||!r||t!==r)}function l(e,n){try{return e.top===n.top}catch(t){return!1}}Object.defineProperty(n,"__esModule",{value:!0}),n.isSameDomain=o,n.isWindowClosed=i,n.getOpener=a,n.getParentWindow=u,n.getWindowId=s,n.getWindowById=c,n.registerWindow=d,n.isWindowEqual=f,n.isSameTopWindow=l;var w=t(12),p=[],S=[],E=window.name||w.util.getType()+"_"+w.util.uniqueID(),O=window.open;window.open=function(e,n,t,r){n||(n=w.util.uniqueID(),arguments[1]=n);var o=w.util.apply(O,this,arguments);return d(n,o),o}},function(e,n,t){"use strict";function r(e){return e instanceof Object&&e.__type__===s.CONSTANTS.SERIALIZATION_TYPES.METHOD&&e.__id__}function o(e,n){var t=c.util.uniqueID();return f[t]={win:e,method:n},{__type__:s.CONSTANTS.SERIALIZATION_TYPES.METHOD,__id__:t}}function i(e,n){return l(),c.util.replaceObject({obj:n},function(n){return n instanceof Function?o(e,n):void 0}).obj}function a(e,n){return function(){var t=Array.prototype.slice.call(arguments);return(0,d.send)(e,s.CONSTANTS.POST_MESSAGE_NAMES.METHOD,{id:n.__id__,args:t})}}function u(e,n){return c.util.replaceObject({obj:n},function(n){return r(n)?a(e,n):void 0}).obj}Object.defineProperty(n,"__esModule",{value:!0}),n.listenForMethods=void 0,n.serializeMethod=o,n.serializeMethods=i,n.deserializeMethod=a,n.deserializeMethods=u;var s=t(3),c=t(12),d=t(1),f={},l=n.listenForMethods=c.util.once(function(){(0,d.on)(s.CONSTANTS.POST_MESSAGE_NAMES.METHOD,function(e,n){if(!f[n.id])throw new Error("Could not find method with id: "+n.id);if(f[n.id].win!==e)throw new Error("Method window does not match");return f[n.id].method.apply(null,n.args)})})},function(e,n,t){"use strict";function r(){(0,u.on)(i.CONSTANTS.POST_MESSAGE_NAMES.READY,function(e,n){d.push(e);for(var t=f,r=Array.isArray(t),o=0,t=r?t:t[Symbol.iterator]();;){var i;if(r){if(o>=t.length)break;i=t[o++]}else{if(o=t.next(),o.done)break;i=o.value}var a=i;a.win===e&&a.resolve(a.win)}});var e=(0,a.getParentWindow)();e&&(0,u.send)(e,i.CONSTANTS.POST_MESSAGE_NAMES.READY,{})["catch"](function(e){s.log.debug(e.stack||e.toString())})}function o(e){return new c.promise.Promise(function(n){return-1!==d.indexOf(e)?n(e):void f.push({win:e,resolve:n})})}Object.defineProperty(n,"__esModule",{value:!0}),n.initOnReady=r,n.onWindowReady=o;var i=t(3),a=t(14),u=t(1),s=t(13),c=t(9),d=[],f=[]},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=t(18);Object.keys(r).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return r[e]}})});var o=t(19);Object.keys(o).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return o[e]}})});var i=t(20);Object.keys(i).forEach(function(e){"default"!==e&&Object.defineProperty(n,e,{enumerable:!0,get:function(){return i[e]}})})},function(e,n,t){"use strict";function r(){return a.promise.Promise.resolve().then(function(){return s})}function o(e){try{if(!e||!e.frames||!e.frames.length)return;for(var n=0;n<e.frames.length;n++)try{var t=e.frames[n];if(t&&t!==window&&(0,a.isSameDomain)(t)&&t[i.CONSTANTS.WINDOW_PROPS.POSTROBOT])return t}catch(r){continue}}catch(r){return}}Object.defineProperty(n,"__esModule",{value:!0}),n.openBridge=void 0,n.getBridge=r,n.getBridgeFor=o;var i=t(3),a=t(8),u="postrobot_bridge",s=void 0;n.openBridge=a.util.memoize(function(e){if(s)throw new Error("Only one bridge supported");var n=new a.promise.Promise(function(e){return window.document.body?e(window.document):void window.document.addEventListener("DOMContentLoaded",function(n){return e(window.document)})});return s=n.then(function(n){a.log.debug("Opening bridge:",e);var t=u+"_"+a.util.uniqueID(),r=n.createElement("iframe");return r.setAttribute("name",t),r.setAttribute("id",t),r.setAttribute("style","margin: 0; padding: 0; border: 0px none; overflow: hidden;"),r.setAttribute("frameborder","0"),r.setAttribute("border","0"),r.setAttribute("scrolling","no"),r.setAttribute("allowTransparency","true"),r.setAttribute("tabindex","-1"),r.setAttribute("hidden","true"),r.setAttribute("title",""),r.setAttribute("role","presentation"),r.src=e,n.body.appendChild(r),new a.promise.Promise(function(e,n){r.onload=e,r.onerror=n}).then(function(){return(0,a.onWindowReady)(r.contentWindow)})})})},function(e,n,t){"use strict";function r(){if(window[o.CONSTANTS.WINDOW_PROPS.POSTROBOT])throw new Error("Attempting to load postRobot twice on the same window");window[o.CONSTANTS.WINDOW_PROPS.POSTROBOT]={postMessage:function(e){(0,i.receiveMessage)(e)}}}Object.defineProperty(n,"__esModule",{value:!0}),n.registerGlobals=r;var o=t(3),i=t(6)},function(e,n,t){"use strict";function r(e,n){if(!o.CONFIG.ALLOW_POSTMESSAGE_POPUP&&!(0,i.isSameTopWindow)(e,n))throw new Error("Can not send and receive post messages between two different windows (disabled to emulate IE)")}Object.defineProperty(n,"__esModule",{value:!0}),n.emulateIERestrictions=r;var o=t(3),i=t(8)},function(e,n,t){"use strict";function r(e,n){var t=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],r=u.util.uniqueID(),o=(0,u.getWindowId)(window),a=u.util.getType(),s=(0,u.getWindowId)(e);return i({},n,t,{id:n.id||r,source:o,originalSource:n.originalSource||o,windowType:a,originalWindowType:n.originalWindowType||a,target:n.target||s})}function o(e,n,t,o){return u.promise.run(function(){n=r(e,n,{data:(0,u.serializeMethods)(e,n.data),domain:t});var i=-1!==a.POST_MESSAGE_NAMES_LIST.indexOf(n.name)||n.type===a.CONSTANTS.POST_MESSAGE_TYPE.ACK||o?"debug":"info";if(u.log.logLevel(i,[o?"#sendproxy":"#send",n.type,n.name,n]),a.CONFIG.MOCK_MODE)return delete n.target,window[a.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:u.util.getDomain(window),source:window,data:JSON.stringify(n)});if(e===window)throw new Error("Attemping to send message to self");if((0,u.isWindowClosed)(e))throw new Error("Window is closed");u.log.debug("Running send message strategies",n);var c=[];return u.promise.map(u.util.keys(s.SEND_MESSAGE_STRATEGIES),function(r){return u.promise.run(function(){if(!a.CONFIG.ALLOWED_POST_MESSAGE_METHODS[r])throw new Error("Strategy disallowed: "+r);return s.SEND_MESSAGE_STRATEGIES[r](e,n,t)}).then(function(){return c.push(r+": success"),!0},function(e){return c.push(r+": "+e.message),!1})}).then(function(e){var t=u.util.some(e),r=n.type+" "+n.name+" "+(t?"success":"error")+":\n - "+c.join("\n - ")+"\n";if(u.log.debug(r),!t)throw new Error(r)})})}Object.defineProperty(n,"__esModule",{value:!0});var i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e};n.buildMessage=r,n.sendMessage=o;var a=t(3),u=t(8),s=t(22)},function(e,n,t){"use strict";function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}Object.defineProperty(n,"__esModule",{value:!0}),n.SEND_MESSAGE_STRATEGIES=void 0;var o,i=t(3),a=t(8),u=t(17);n.SEND_MESSAGE_STRATEGIES=(o={},r(o,i.CONSTANTS.SEND_STRATEGIES.POST_MESSAGE,function(e,n,t){return(0,u.emulateIERestrictions)(window,e),e.postMessage(JSON.stringify(n,0,2),t)}),r(o,i.CONSTANTS.SEND_STRATEGIES.GLOBAL_METHOD,function(e,n,t){if(!(0,a.isSameDomain)(e))throw new Error("Window is not on the same domain");if((0,a.isSameTopWindow)(window,e))throw new Error("Can only use global method to communicate between two different windows, not between frames");var r=a.util.getDomain(window),o=void 0;try{o=a.util.getDomain(e)}catch(u){throw new Error("Can not read target window domain: "+u.message)}if(r!==o)throw new Error("Can not send global message - source "+r+" does not match target "+o);if("*"!==t&&o!==t)throw new Error("Can post post through global method - specified domain "+t+" does not match target domain "+o);if(!a.util.safeHasProp(e,i.CONSTANTS.WINDOW_PROPS.POSTROBOT))throw new Error("post-robot not available on target window at "+o);e[i.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:a.util.getDomain(window),source:window,data:JSON.stringify(n,0,2)})}),r(o,i.CONSTANTS.SEND_STRATEGIES.FOREIGN_BRIDGE,function(e,n,t){if((0,a.isSameTopWindow)(window,e))throw new Error("Can only use bridge to communicate between two different windows, not between frames");var r=(0,u.getBridgeFor)(e);if(!r)throw new Error("No bridge available in window");if(!(0,a.isSameDomain)(r))throw new Error("Bridge is not on the same domain");var o=a.util.getDomain(window),s=void 0;try{s=a.util.getDomain(r)}catch(c){throw new Error("Can not read bridge window domain: "+c.message)}if(o!==s)throw new Error("Can not accept global message through bridge - source "+o+" does not match bridge "+s);if(!a.util.safeHasProp(r,i.CONSTANTS.WINDOW_PROPS.POSTROBOT))throw new Error("post-robot not available on bridge at "+s);n.targetHint="window.parent",window===(0,a.getOpener)(e)&&(n.sourceHint="window.opener"),r[i.CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({origin:a.util.getDomain(window),source:window,data:JSON.stringify(n,0,2)})}),r(o,i.CONSTANTS.SEND_STRATEGIES.LOCAL_BRIDGE,function(e,n,t){if((0,a.isSameTopWindow)(window,e))throw new Error("Can only use bridge to communicate between two different windows, not between frames");if(!n.target)throw new Error("Can not post message down through bridge without target");return e===(0,a.getOpener)(window)&&(n.targetHint="window.parent.opener"),window===(0,a.getOpener)(e)&&(n.sourceHint="window.opener"),(0,u.getBridge)().then(function(r){if(!r)throw new Error("Bridge not initialized");if(e===r)throw new Error("Message target is bridge");r.postMessage(JSON.stringify(n,0,2),t)})}),o)},function(e,n,t){"use strict";function r(){n.listeners=s={request:[],response:{},proxies:[]}}function o(e,n){for(var t=s.request,r=Array.isArray(t),o=0,t=r?t:t[Symbol.iterator]();;){var i;if(r){if(o>=t.length)break;i=t[o++]}else{if(o=t.next(),o.done)break;i=o.value}var a=i;if(a.name===e){if(!a.win)return a.options;if(n&&(0,u.isWindowEqual)(n,a.win))return a.options}}}function i(e){for(var n=void 0,t=s.request,r=Array.isArray(t),o=0,t=r?t:t[Symbol.iterator]();;){var i;if(r){if(o>=t.length)break;i=t[o++]}else{if(o=t.next(),o.done)break;i=o.value}var a=i;if(a.options===e){n=a;break}}n&&s.request.splice(s.request.indexOf(n),1)}function a(e,n,t,r){var a=o(e,n);if(a){if(!r)throw new Error("Request listener already exists for "+e);i(a)}s.request.push({name:e,win:n,options:t})}Object.defineProperty(n,"__esModule",{value:!0}),n.listeners=void 0,n.resetListeners=r,n.getRequestListener=o,n.removeRequestListener=i,n.addRequestListener=a;var u=t(8),s=n.listeners=void 0;r()},function(e,n,t){"use strict";function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}Object.defineProperty(n,"__esModule",{value:!0}),n.RECEIVE_MESSAGE_TYPES=void 0;var o,i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},a=t(3),u=t(8),s=t(21),c=t(23);n.RECEIVE_MESSAGE_TYPES=(o={},r(o,a.CONSTANTS.POST_MESSAGE_TYPE.ACK,function(e,n,t){var r=c.listeners.response[n.hash];if(!r)throw new Error("No handler found for post message ack for message: "+n.name+" in "+window.location.href);r.ack=!0}),r(o,a.CONSTANTS.POST_MESSAGE_TYPE.REQUEST,function(e,n,t){function r(t){return(0,u.isWindowClosed)(e)?void 0:(0,s.sendMessage)(e,i({target:n.originalSource,hash:n.hash,name:n.name},t),"*")}var o=(0,c.getRequestListener)(n.name,e);return r({type:a.CONSTANTS.POST_MESSAGE_TYPE.ACK}).then(function(){return u.promise.run(function(){if(!o)throw new Error("No postmessage request handler for "+n.name+" in "+window.location.href);if(o.domain){var r="string"==typeof o.domain&&t===o.domain||o.domain instanceof RegExp&&t.match(o.domain);if(!r)throw new Error("Message origin "+t+" does not match domain "+o.domain)}return u.promise.deNodeify(o.handler,e,n.data)}).then(function(e){return r({type:a.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:a.CONSTANTS.POST_MESSAGE_ACK.SUCCESS,data:e})},function(e){return r({type:a.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,ack:a.CONSTANTS.POST_MESSAGE_ACK.ERROR,error:e.stack?e.message+"\n"+e.stack:e.toString()})})})["catch"](function(e){return o&&o.handleError?o.handleError(e):void u.log.error(e.stack||e.toString())})}),r(o,a.CONSTANTS.POST_MESSAGE_TYPE.RESPONSE,function(e,n,t){var r=c.listeners.response[n.hash];if(!r)throw new Error("No response handler found for post message response "+n.name+" in "+window.location.href);return delete c.listeners.response[n.hash],n.ack===a.CONSTANTS.POST_MESSAGE_ACK.ERROR?r.respond(new Error(n.error)):n.ack===a.CONSTANTS.POST_MESSAGE_ACK.SUCCESS?r.respond(null,n.data||n.response):void 0}),o)},function(e,n,t){"use strict";function r(e){if(!e.name)throw new Error("Expected options.name");e.handler=e.handler||u.util.noop,e.errorHandler=e.errorHandler||function(e){throw e},e.once&&!function(){var n=e.handler;e.handler=u.util.once(function(){return(0,s.removeRequestListener)(e),n.apply(this,arguments)})}();var n=e.override||a.CONFIG.MOCK_MODE;return(0,s.addRequestListener)(e.name,e.window,e,n),e.handleError=function(n){e.errorHandler(n)},e.window&&e.errorOnClose&&!function(){var n=u.util.safeInterval(function(){(0,u.isWindowClosed)(e.window)&&(n.cancel(), | ||
e.handleError(new Error("Post message target window is closed")))},50)}(),{cancel:function(){(0,s.removeRequestListener)(e)}}}function o(e,n,t,o){return n instanceof Function&&(o=t,t=n,n={}),n.name=e,n.handler=t||n.handler,n.errorHandler=o||n.errorHandler,r(n)}function i(e,n,t,o){n instanceof Function&&(o=t,t=n,n={}),n.name=e,n.handler=t||n.handler,n.errorHandler=o||n.errorHandler,n.once=!0;var i=new u.promise.Promise(function(e,t){n.handler=n.handler||e,n.errorHandler=n.errorHandler||t}),a=r(n);return u.util.extend(i,a),i}Object.defineProperty(n,"__esModule",{value:!0}),n.listen=r,n.on=o,n.once=i;var a=t(3),u=t(8),s=t(6)},function(e,n,t){"use strict";function r(e,n){i.listeners.proxies.push({from:e,to:n}),i.listeners.proxies.push({from:n,to:e})}function o(e,n){for(var t=[],r=0;r<i.listeners.proxies.length;r++){var o=i.listeners.proxies[r];(o.to===e&&o.from===n||o.to===n&&o.from===e)&&t.push(o)}for(var a=0;a<t.length;a++)i.listeners.proxies.splice(i.listeners.proxies.indexOf(t[a]),1)}Object.defineProperty(n,"__esModule",{value:!0}),n.proxy=r,n.unproxy=o;var i=t(6)},function(e,n,t){"use strict";function r(){i.CONFIG.MOCK_MODE=!0}function o(){i.CONFIG.MOCK_MODE=!1}Object.defineProperty(n,"__esModule",{value:!0}),n.CONSTANTS=n.CONFIG=void 0,n.enableMockMode=r,n.disableMockMode=o;var i=t(3);Object.defineProperty(n,"CONFIG",{enumerable:!0,get:function(){return i.CONFIG}}),Object.defineProperty(n,"CONSTANTS",{enumerable:!0,get:function(){return i.CONSTANTS}})}])}); |
{ | ||
"name": "post-robot", | ||
"version": "2.0.20", | ||
"version": "2.0.21", | ||
"description": "Simple postMessage based server.", | ||
@@ -5,0 +5,0 @@ "main": "dist/post-robot.min.js", |
import { CONSTANTS } from '../conf'; | ||
import { nextTick } from '../lib'; | ||
import { receiveMessage } from '../drivers'; | ||
@@ -16,5 +15,5 @@ | ||
postMessage: event => { | ||
nextTick(() => receiveMessage(event)); | ||
receiveMessage(event); | ||
} | ||
}; | ||
} |
@@ -134,3 +134,3 @@ | ||
let level = POST_MESSAGE_NAMES_LIST.indexOf(message.name) !== -1 ? 'debug' : 'info'; | ||
let level = (POST_MESSAGE_NAMES_LIST.indexOf(message.name) !== -1 || message.type === CONSTANTS.POST_MESSAGE_TYPE.ACK || proxyWindow) ? 'debug' : 'info'; | ||
log.logLevel(level, [ proxyWindow ? '#receiveproxy' : '#receive', message.type, message.name, message ]); | ||
@@ -137,0 +137,0 @@ |
@@ -36,3 +36,3 @@ | ||
let level = POST_MESSAGE_NAMES_LIST.indexOf(message.name) !== -1 ? 'debug' : 'info'; | ||
let level = (POST_MESSAGE_NAMES_LIST.indexOf(message.name) !== -1 || message.type === CONSTANTS.POST_MESSAGE_TYPE.ACK || isProxy) ? 'debug' : 'info'; | ||
log.logLevel(level, [ isProxy ? '#sendproxy' : '#send', message.type, message.name, message ]); | ||
@@ -39,0 +39,0 @@ |
@@ -21,2 +21,6 @@ | ||
if (isSameTopWindow(window, win)) { | ||
throw new Error(`Can only use global method to communicate between two different windows, not between frames`); | ||
} | ||
let sourceDomain = util.getDomain(window); | ||
@@ -23,0 +27,0 @@ let targetDomain; |
@@ -16,12 +16,4 @@ | ||
if (window.setImmediate) { | ||
return window.setImmediate.call(window, method); | ||
} | ||
if (window.nextTick) { | ||
return window.nextTick.call(window, method); | ||
} | ||
queue.push(method); | ||
window.postMessage(tickMessageName, '*'); | ||
} |
import { util } from './util'; | ||
function safeGet(obj, prop) { | ||
let result; | ||
try { | ||
result = obj[prop]; | ||
} catch (err) { | ||
// pass | ||
} | ||
return result; | ||
} | ||
let domainMatches = []; | ||
@@ -45,2 +58,11 @@ | ||
export function isWindowClosed(win) { | ||
try { | ||
return !win || win.closed || typeof win.closed === 'undefined' || (isSameDomain(win) && safeGet(win, 'mockclosed')); | ||
} catch (err) { | ||
return true; | ||
} | ||
} | ||
export function getOpener(win) { | ||
@@ -136,3 +158,5 @@ | ||
if (map.id === id && map.win !== win) { | ||
throw new Error(`Can not register a duplicate window with name ${id}`); | ||
if (!isWindowClosed(map.win)) { | ||
throw new Error(`Can not register a duplicate window with name ${id}`); | ||
} | ||
} | ||
@@ -186,23 +210,2 @@ } | ||
return win; | ||
}; | ||
function safeGet(obj, prop) { | ||
let result; | ||
try { | ||
result = obj[prop]; | ||
} catch (err) { | ||
// pass | ||
} | ||
return result; | ||
} | ||
export function isWindowClosed(win) { | ||
try { | ||
return !win || win.closed || typeof win.closed === 'undefined' || (isSameDomain(win) && safeGet(win, 'mockclosed')); | ||
} catch (err) { | ||
return true; | ||
} | ||
} | ||
}; |
Sorry, the diff of this file is too big to display
193862
4228