svgedit/dist/editor/extensions/ext-xdomain-messaging.js

3 lines
3.0 KiB
JavaScript
Raw Normal View History

2020-09-04 20:34:30 +00:00
function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _AwaitValue(e){this.wrapped=e}function _AsyncGenerator(e){var r,t;function resume(r,t){try{var n=e[r](t),o=n.value,a=o instanceof _AwaitValue;Promise.resolve(a?o.wrapped:o).then((function(e){a?resume("return"===r?"return":"next",e):settle(n.done?"return":"normal",e)}),(function(e){resume("throw",e)}))}catch(e){settle("throw",e)}}function settle(e,n){switch(e){case"return":r.resolve({value:n,done:!0});break;case"throw":r.reject(n);break;default:r.resolve({value:n,done:!1})}(r=r.next)?resume(r.key,r.arg):t=null}this._invoke=function send(e,n){return new Promise((function(o,a){var i={key:e,arg:n,resolve:o,reject:a,next:null};t?t=t.next=i:(r=t=i,resume(e,n))}))},"function"!=typeof e.return&&(this.return=void 0)}function _toConsumableArray(e){return function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _iterableToArray(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}"function"==typeof Symbol&&Symbol.asyncIterator&&(_AsyncGenerator.prototype[Symbol.asyncIterator]=function(){return this}),_AsyncGenerator.prototype.next=function(e){return this._invoke("next",e)},_AsyncGenerator.prototype.throw=function(e){return this._invoke("throw",e)},_AsyncGenerator.prototype.return=function(e){return this._invoke("return",e)};var e={name:"xdomain-messaging",init:function init(){var e=this,r=e.canvas;try{window.addEventListener("message",(function(t){if(t.data&&["string","object"].includes(_typeof(t.data))&&"|"!==t.data.charAt()){var n="object"===_typeof(t.data)?t.data:JSON.parse(t.data);if(n&&"object"===_typeof(n)&&"svgCanvas"===n.namespace){var o=e.curConfig.allowedOrigins;if(o.includes("*")||o.includes(t.origin)){var a=n.id,i=n.name,s=n.args,u={namespace:"svg-edit",id:a};try{u.result=r[i].apply(r,_toConsumableArray(s))}catch(e){u.error=e.message}t.source.postMessage(JSON.stringify(u),"*")}else console.log("Origin ".concat(t.origin," not whitelisted for posting to ").concat(window.origin))}}}))}catch(e){console.log("Error with xdomain message listener: "+e)}}};export default e;
2020-08-28 22:07:07 +00:00
//# sourceMappingURL=ext-xdomain-messaging.js.map