Files
svgedit/dist/editor/system/extensions/ext-xdomain-messaging/ext-xdomain-messaging.js
2021-03-08 23:05:05 +01:00

2 lines
12 KiB
JavaScript

System.register([],(function(t){"use strict";return{execute:function(){function _typeof(t){return(_typeof="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)}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);"Object"===e&&t.constructor&&(e=t.constructor.name);if("Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return _arrayLikeToArray(t,r)}(t)||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 _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t){var r={exports:{}};return t(r,r.exports),r.exports}var check=function(t){return t&&t.Math==Math&&t},e=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof r&&r)||function(){return this}()||Function("return this")(),fails=function(t){try{return!!t()}catch(t){return!0}},n=!fails((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),o={}.propertyIsEnumerable,i=Object.getOwnPropertyDescriptor,c={f:i&&!o.call({1:2},1)?function propertyIsEnumerable(t){var r=i(this,t);return!!r&&r.enumerable}:o},createPropertyDescriptor=function(t,r){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:r}},u={}.toString,classofRaw=function(t){return u.call(t).slice(8,-1)},a="".split,f=fails((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==classofRaw(t)?a.call(t,""):Object(t)}:Object,requireObjectCoercible=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},toIndexedObject=function(t){return f(requireObjectCoercible(t))},isObject=function(t){return"object"==typeof t?null!==t:"function"==typeof t},toPrimitive=function(t,r){if(!isObject(t))return t;var e,n;if(r&&"function"==typeof(e=t.toString)&&!isObject(n=e.call(t)))return n;if("function"==typeof(e=t.valueOf)&&!isObject(n=e.call(t)))return n;if(!r&&"function"==typeof(e=t.toString)&&!isObject(n=e.call(t)))return n;throw TypeError("Can't convert object to primitive value")},s={}.hasOwnProperty,has$1=function(t,r){return s.call(t,r)},l=e.document,p=isObject(l)&&isObject(l.createElement),documentCreateElement=function(t){return p?l.createElement(t):{}},y=!n&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),d=Object.getOwnPropertyDescriptor,g={f:n?d:function getOwnPropertyDescriptor(t,r){if(t=toIndexedObject(t),r=toPrimitive(r,!0),y)try{return d(t,r)}catch(t){}if(has$1(t,r))return createPropertyDescriptor(!c.f.call(t,r),t[r])}},anObject=function(t){if(!isObject(t))throw TypeError(String(t)+" is not an object");return t},m=Object.defineProperty,h={f:n?m:function defineProperty(t,r,e){if(anObject(t),r=toPrimitive(r,!0),anObject(e),y)try{return m(t,r,e)}catch(t){}if("get"in e||"set"in e)throw TypeError("Accessors not supported");return"value"in e&&(t[r]=e.value),t}},v=n?function(t,r,e){return h.f(t,r,createPropertyDescriptor(1,e))}:function(t,r,e){return t[r]=e,t},setGlobal=function(t,r){try{v(e,t,r)}catch(n){e[t]=r}return r},b="__core-js_shared__",w=e[b]||setGlobal(b,{}),S=Function.toString;"function"!=typeof w.inspectSource&&(w.inspectSource=function(t){return S.call(t)});var O,j,A,T=w.inspectSource,E=e.WeakMap,_="function"==typeof E&&/native code/.test(T(E)),P=createCommonjsModule((function(t){(t.exports=function(t,r){return w[t]||(w[t]=void 0!==r?r:{})})("versions",[]).push({version:"3.9.1",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),x=0,M=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++x+M).toString(36)},C=P("keys"),sharedKey=function(t){return C[t]||(C[t]=uid(t))},I={},k=e.WeakMap;if(_){var L=w.state||(w.state=new k),F=L.get,N=L.has,W=L.set;O=function(t,r){return r.facade=t,W.call(L,t,r),r},j=function(t){return F.call(L,t)||{}},A=function(t){return N.call(L,t)}}else{var D=sharedKey("state");I[D]=!0,O=function(t,r){return r.facade=t,v(t,D,r),r},j=function(t){return has$1(t,D)?t[D]:{}},A=function(t){return has$1(t,D)}}var z,R,G={set:O,get:j,has:A,enforce:function(t){return A(t)?j(t):O(t,{})},getterFor:function(t){return function(r){var e;if(!isObject(r)||(e=j(r)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return e}}},J=createCommonjsModule((function(t){var r=G.get,n=G.enforce,o=String(String).split("String");(t.exports=function(t,r,i,c){var u,a=!!c&&!!c.unsafe,f=!!c&&!!c.enumerable,s=!!c&&!!c.noTargetGet;"function"==typeof i&&("string"!=typeof r||has$1(i,"name")||v(i,"name",r),(u=n(i)).source||(u.source=o.join("string"==typeof r?r:""))),t!==e?(a?!s&&t[r]&&(f=!0):delete t[r],f?t[r]=i:v(t,r,i)):f?t[r]=i:setGlobal(r,i)})(Function.prototype,"toString",(function toString(){return"function"==typeof this&&r(this).source||T(this)}))})),K=e,aFunction=function(t){return"function"==typeof t?t:void 0},getBuiltIn=function(t,r){return arguments.length<2?aFunction(K[t])||aFunction(e[t]):K[t]&&K[t][r]||e[t]&&e[t][r]},q=Math.ceil,B=Math.floor,toInteger=function(t){return isNaN(t=+t)?0:(t>0?B:q)(t)},H=Math.min,toLength=function(t){return t>0?H(toInteger(t),9007199254740991):0},U=Math.max,V=Math.min,createMethod=function(t){return function(r,e,n){var o,i=toIndexedObject(r),c=toLength(i.length),u=function(t,r){var e=toInteger(t);return e<0?U(e+r,0):V(e,r)}(n,c);if(t&&e!=e){for(;c>u;)if((o=i[u++])!=o)return!0}else for(;c>u;u++)if((t||u in i)&&i[u]===e)return t||u||0;return!t&&-1}},X={includes:createMethod(!0),indexOf:createMethod(!1)},Y=X.indexOf,objectKeysInternal=function(t,r){var e,n=toIndexedObject(t),o=0,i=[];for(e in n)!has$1(I,e)&&has$1(n,e)&&i.push(e);for(;r.length>o;)has$1(n,e=r[o++])&&(~Y(i,e)||i.push(e));return i},$=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Q=$.concat("length","prototype"),Z={f:Object.getOwnPropertyNames||function getOwnPropertyNames(t){return objectKeysInternal(t,Q)}},tt={f:Object.getOwnPropertySymbols},rt=getBuiltIn("Reflect","ownKeys")||function ownKeys(t){var r=Z.f(anObject(t)),e=tt.f;return e?r.concat(e(t)):r},copyConstructorProperties=function(t,r){for(var e=rt(r),n=h.f,o=g.f,i=0;i<e.length;i++){var c=e[i];has$1(t,c)||n(t,c,o(r,c))}},et=/#|\.prototype\./,isForced=function(t,r){var e=ot[nt(t)];return e==ct||e!=it&&("function"==typeof r?fails(r):!!r)},nt=isForced.normalize=function(t){return String(t).replace(et,".").toLowerCase()},ot=isForced.data={},it=isForced.NATIVE="N",ct=isForced.POLYFILL="P",ut=isForced,at=g.f,_export=function(t,r){var n,o,i,c,u,a=t.target,f=t.global,s=t.stat;if(n=f?e:s?e[a]||setGlobal(a,{}):(e[a]||{}).prototype)for(o in r){if(c=r[o],i=t.noTargetGet?(u=at(n,o))&&u.value:n[o],!ut(f?o:a+(s?".":"#")+o,t.forced)&&void 0!==i){if(typeof c==typeof i)continue;copyConstructorProperties(c,i)}(t.sham||i&&i.sham)&&v(c,"sham",!0),J(n,o,c,t)}},ft="process"==classofRaw(e.process),st=getBuiltIn("navigator","userAgent")||"",lt=e.process,pt=lt&&lt.versions,yt=pt&&pt.v8;yt?R=(z=yt.split("."))[0]+z[1]:st&&(!(z=st.match(/Edge\/(\d+)/))||z[1]>=74)&&(z=st.match(/Chrome\/(\d+)/))&&(R=z[1]);var dt,gt=R&&+R,mt=!!Object.getOwnPropertySymbols&&!fails((function(){return!Symbol.sham&&(ft?38===gt:gt>37&&gt<41)})),ht=mt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,vt=P("wks"),bt=e.Symbol,wt=ht?bt:bt&&bt.withoutSetter||uid,wellKnownSymbol=function(t){return has$1(vt,t)&&(mt||"string"==typeof vt[t])||(mt&&has$1(bt,t)?vt[t]=bt[t]:vt[t]=wt("Symbol."+t)),vt[t]},St=Object.keys||function keys(t){return objectKeysInternal(t,$)},Ot=n?Object.defineProperties:function defineProperties(t,r){anObject(t);for(var e,n=St(r),o=n.length,i=0;o>i;)h.f(t,e=n[i++],r[e]);return t},jt=getBuiltIn("document","documentElement"),At=sharedKey("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(t){return"<script>"+t+"</"+"script>"},NullProtoObject=function(){try{dt=document.domain&&new ActiveXObject("htmlfile")}catch(t){}var t,r;NullProtoObject=dt?function(t){t.write(scriptTag("")),t.close();var r=t.parentWindow.Object;return t=null,r}(dt):((r=documentCreateElement("iframe")).style.display="none",jt.appendChild(r),r.src=String("javascript:"),(t=r.contentWindow.document).open(),t.write(scriptTag("document.F=Object")),t.close(),t.F);for(var e=$.length;e--;)delete NullProtoObject.prototype[$[e]];return NullProtoObject()};I[At]=!0;var Tt=Object.create||function create(t,r){var e;return null!==t?(EmptyConstructor.prototype=anObject(t),e=new EmptyConstructor,EmptyConstructor.prototype=null,e[At]=t):e=NullProtoObject(),void 0===r?e:Ot(e,r)},Et=wellKnownSymbol("unscopables"),_t=Array.prototype;null==_t[Et]&&h.f(_t,Et,{configurable:!0,value:Tt(null)});var Pt,xt=X.includes;_export({target:"Array",proto:!0},{includes:function includes(t){return xt(this,t,arguments.length>1?arguments[1]:void 0)}}),Pt="includes",_t[Et][Pt]=!0;var Mt=wellKnownSymbol("match"),notARegexp=function(t){if(function(t){var r;return isObject(t)&&(void 0!==(r=t[Mt])?!!r:"RegExp"==classofRaw(t))}(t))throw TypeError("The method doesn't accept regular expressions");return t},Ct=wellKnownSymbol("match");_export({target:"String",proto:!0,forced:!function(t){var r=/./;try{"/./"[t](r)}catch(e){try{return r[Ct]=!1,"/./"[t](r)}catch(t){}}return!1}("includes")},{includes:function includes(t){return!!~String(requireObjectCoercible(this)).indexOf(notARegexp(t),arguments.length>1?arguments[1]:void 0)}});var It,kt=Array.isArray||function isArray(t){return"Array"==classofRaw(t)},toObject=function(t){return Object(requireObjectCoercible(t))},createProperty=function(t,r,e){var n=toPrimitive(r);n in t?h.f(t,n,createPropertyDescriptor(0,e)):t[n]=e},Lt=wellKnownSymbol("species"),arraySpeciesCreate=function(t,r){var e;return kt(t)&&("function"!=typeof(e=t.constructor)||e!==Array&&!kt(e.prototype)?isObject(e)&&null===(e=e[Lt])&&(e=void 0):e=void 0),new(void 0===e?Array:e)(0===r?0:r)},Ft=wellKnownSymbol("species"),Nt=wellKnownSymbol("isConcatSpreadable"),Wt=9007199254740991,Dt="Maximum allowed index exceeded",zt=gt>=51||!fails((function(){var t=[];return t[Nt]=!1,t.concat()[0]!==t})),Rt=(It="concat",gt>=51||!fails((function(){var t=[];return(t.constructor={})[Ft]=function(){return{foo:1}},1!==t[It](Boolean).foo}))),isConcatSpreadable=function(t){if(!isObject(t))return!1;var r=t[Nt];return void 0!==r?!!r:kt(t)};_export({target:"Array",proto:!0,forced:!zt||!Rt},{concat:function concat(t){var r,e,n,o,i,c=toObject(this),u=arraySpeciesCreate(c,0),a=0;for(r=-1,n=arguments.length;r<n;r++)if(isConcatSpreadable(i=-1===r?c:arguments[r])){if(a+(o=toLength(i.length))>Wt)throw TypeError(Dt);for(e=0;e<o;e++,a++)e in i&&createProperty(u,a,i[e])}else{if(a>=Wt)throw TypeError(Dt);createProperty(u,a++,i)}return u.length=a,u}});var Gt=h.f,Jt=Function.prototype,Kt=Jt.toString,qt=/^\s*function ([^ (]*)/,Bt="name";n&&!(Bt in Jt)&&Gt(Jt,Bt,{configurable:!0,get:function(){try{return Kt.call(this).match(qt)[1]}catch(t){return""}}});t("default",{name:"xdomain-messaging",init:function init(){var t=this,r=t.svgCanvas;try{window.addEventListener("message",(function(e){if(e.data&&["string","object"].includes(_typeof(e.data))&&"|"!==e.data.charAt()){var n="object"===_typeof(e.data)?e.data:JSON.parse(e.data);if(n&&"object"===_typeof(n)&&"svgCanvas"===n.namespace){var o=t.configObj.curConfig.allowedOrigins;if(o.includes("*")||o.includes(e.origin)){var i=n.id,c=n.name,u=n.args,a={namespace:"svg-edit",id:i};try{a.result=r[c].apply(r,_toConsumableArray(u))}catch(t){a.error=t.message}e.source.postMessage(JSON.stringify(a),"*")}else console.log("Origin ".concat(e.origin," not whitelisted for posting to ").concat(window.origin))}}}))}catch(t){console.log("Error with xdomain message listener: "+t)}}})}}}));