@iebh/tera-fy 1.0.17 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.md +320 -200
- package/dist/plugin.vue2.es2019.js +1 -2
- package/dist/terafy.es2019.js +2 -3
- package/dist/terafy.js +2 -3
- package/lib/terafy.client.js +76 -9
- package/lib/terafy.server.js +266 -18
- package/package.json +16 -16
- package/plugins/vue2.js +68 -0
- package/utils/pDefer.js +15 -0
- package/widgets/tera-library-select.vue +8 -0
- package/dist/plugin.vue2.es2019.js.map +0 -7
- package/dist/terafy.es2019.js.map +0 -7
- package/dist/terafy.js.map +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var fr=Object.defineProperty;var sr=(t,e,r)=>e in t?fr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var k=(t,e,r)=>(sr(t,typeof e!="symbol"?e+"":e,r),r);var pr=typeof global=="object"&&global&&global.Object===Object&&global,q=pr;var nr=typeof self=="object"&&self&&self.Object===Object&&self,ir=q||nr||Function("return this")(),u=ir;var ur=u.Symbol,g=ur;var _t=Object.prototype,mr=_t.hasOwnProperty,lr=_t.toString,K=g?g.toStringTag:void 0;function dr(t){var e=mr.call(t,K),r=t[K];try{t[K]=void 0;var o=!0}catch{}var a=lr.call(t);return o&&(e?t[K]=r:delete t[K]),a}var At=dr;var cr=Object.prototype,xr=cr.toString;function gr(t){return xr.call(t)}var wt=gr;var hr="[object Null]",yr="[object Undefined]",St=g?g.toStringTag:void 0;function br(t){return t==null?t===void 0?yr:hr:St&&St in Object(t)?At(t):wt(t)}var h=br;function vr(t){return t!=null&&typeof t=="object"}var c=vr;var jr=Array.isArray,C=jr;function Tr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var x=Tr;var Or="[object AsyncFunction]",_r="[object Function]",Ar="[object GeneratorFunction]",wr="[object Proxy]";function Sr(t){if(!x(t))return!1;var e=h(t);return e==_r||e==Ar||e==Or||e==wr}var H=Sr;var Ir=u["__core-js_shared__"],$=Ir;var It=function(){var t=/[^.]+$/.exec($&&$.keys&&$.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Pr(t){return!!It&&It in t}var Pt=Pr;var Cr=Function.prototype,Er=Cr.toString;function Br(t){if(t!=null){try{return Er.call(t)}catch{}try{return t+""}catch{}}return""}var y=Br;var Lr=/[\\^$.*+?()[\]{}|]/g,Mr=/^\[object .+?Constructor\]$/,Dr=Function.prototype,Fr=Object.prototype,Nr=Dr.toString,Rr=Fr.hasOwnProperty,Ur=RegExp("^"+Nr.call(Rr).replace(Lr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Gr(t){if(!x(t)||Pt(t))return!1;var e=H(t)?Ur:Mr;return e.test(y(t))}var Ct=Gr;function Wr(t,e){return t==null?void 0:t[e]}var Et=Wr;function Kr(t,e){var r=Et(t,e);return Ct(r)?r:void 0}var m=Kr;var Vr=m(u,"WeakMap"),J=Vr;var Bt=Object.create,zr=function(){function t(){}return function(e){if(!x(e))return{};if(Bt)return Bt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Lt=zr;function kr(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Mt=kr;var qr=function(){try{var t=m(Object,"defineProperty");return t({},"",{}),t}catch{}}(),ct=qr;function Hr(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Dt=Hr;var $r=9007199254740991,Jr=/^(?:0|[1-9]\d*)$/;function Yr(t,e){var r=typeof t;return e=e==null?$r:e,!!e&&(r=="number"||r!="symbol"&&Jr.test(t))&&t>-1&&t%1==0&&t<e}var Ft=Yr;function Xr(t,e,r){e=="__proto__"&&ct?ct(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Y=Xr;function Zr(t,e){return t===e||t!==t&&e!==e}var X=Zr;var Qr=Object.prototype,to=Qr.hasOwnProperty;function eo(t,e,r){var o=t[e];(!(to.call(t,e)&&X(o,r))||r===void 0&&!(e in t))&&Y(t,e,r)}var Z=eo;function ro(t,e,r,o){var a=!r;r||(r={});for(var f=-1,s=e.length;++f<s;){var i=e[f],l=o?o(r[i],t[i],i,r,t):void 0;l===void 0&&(l=t[i]),a?Y(r,i,l):Z(r,i,l)}return r}var T=ro;var oo=9007199254740991;function ao(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=oo}var Q=ao;function fo(t){return t!=null&&Q(t.length)&&!H(t)}var tt=fo;var so=Object.prototype;function po(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||so;return t===r}var E=po;function no(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Nt=no;var io="[object Arguments]";function uo(t){return c(t)&&h(t)==io}var xt=uo;var Rt=Object.prototype,mo=Rt.hasOwnProperty,lo=Rt.propertyIsEnumerable,co=xt(function(){return arguments}())?xt:function(t){return c(t)&&mo.call(t,"callee")&&!lo.call(t,"callee")},Ut=co;function xo(){return!1}var Gt=xo;var Vt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Wt=Vt&&typeof module=="object"&&module&&!module.nodeType&&module,go=Wt&&Wt.exports===Vt,Kt=go?u.Buffer:void 0,ho=Kt?Kt.isBuffer:void 0,yo=ho||Gt,et=yo;var bo="[object Arguments]",vo="[object Array]",jo="[object Boolean]",To="[object Date]",Oo="[object Error]",_o="[object Function]",Ao="[object Map]",wo="[object Number]",So="[object Object]",Io="[object RegExp]",Po="[object Set]",Co="[object String]",Eo="[object WeakMap]",Bo="[object ArrayBuffer]",Lo="[object DataView]",Mo="[object Float32Array]",Do="[object Float64Array]",Fo="[object Int8Array]",No="[object Int16Array]",Ro="[object Int32Array]",Uo="[object Uint8Array]",Go="[object Uint8ClampedArray]",Wo="[object Uint16Array]",Ko="[object Uint32Array]",n={};n[Mo]=n[Do]=n[Fo]=n[No]=n[Ro]=n[Uo]=n[Go]=n[Wo]=n[Ko]=!0;n[bo]=n[vo]=n[Bo]=n[jo]=n[Lo]=n[To]=n[Oo]=n[_o]=n[Ao]=n[wo]=n[So]=n[Io]=n[Po]=n[Co]=n[Eo]=!1;function Vo(t){return c(t)&&Q(t.length)&&!!n[h(t)]}var zt=Vo;function zo(t){return function(e){return t(e)}}var B=zo;var kt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,V=kt&&typeof module=="object"&&module&&!module.nodeType&&module,ko=V&&V.exports===kt,gt=ko&&q.process,qo=function(){try{var t=V&&V.require&&V.require("util").types;return t||gt&>.binding&>.binding("util")}catch{}}(),b=qo;var qt=b&&b.isTypedArray,Ho=qt?B(qt):zt,Ht=Ho;var $o=Object.prototype,Jo=$o.hasOwnProperty;function Yo(t,e){var r=C(t),o=!r&&Ut(t),a=!r&&!o&&et(t),f=!r&&!o&&!a&&Ht(t),s=r||o||a||f,i=s?Nt(t.length,String):[],l=i.length;for(var d in t)(e||Jo.call(t,d))&&!(s&&(d=="length"||a&&(d=="offset"||d=="parent")||f&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||Ft(d,l)))&&i.push(d);return i}var rt=Yo;function Xo(t,e){return function(r){return t(e(r))}}var ot=Xo;var Zo=ot(Object.keys,Object),$t=Zo;var Qo=Object.prototype,ta=Qo.hasOwnProperty;function ea(t){if(!E(t))return $t(t);var e=[];for(var r in Object(t))ta.call(t,r)&&r!="constructor"&&e.push(r);return e}var Jt=ea;function ra(t){return tt(t)?rt(t):Jt(t)}var L=ra;function oa(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Yt=oa;var aa=Object.prototype,fa=aa.hasOwnProperty;function sa(t){if(!x(t))return Yt(t);var e=E(t),r=[];for(var o in t)o=="constructor"&&(e||!fa.call(t,o))||r.push(o);return r}var Xt=sa;function pa(t){return tt(t)?rt(t,!0):Xt(t)}var M=pa;var na=m(Object,"create"),v=na;function ia(){this.__data__=v?v(null):{},this.size=0}var Zt=ia;function ua(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Qt=ua;var ma="__lodash_hash_undefined__",la=Object.prototype,da=la.hasOwnProperty;function ca(t){var e=this.__data__;if(v){var r=e[t];return r===ma?void 0:r}return da.call(e,t)?e[t]:void 0}var te=ca;var xa=Object.prototype,ga=xa.hasOwnProperty;function ha(t){var e=this.__data__;return v?e[t]!==void 0:ga.call(e,t)}var ee=ha;var ya="__lodash_hash_undefined__";function ba(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=v&&e===void 0?ya:e,this}var re=ba;function D(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}D.prototype.clear=Zt;D.prototype.delete=Qt;D.prototype.get=te;D.prototype.has=ee;D.prototype.set=re;var ht=D;function va(){this.__data__=[],this.size=0}var oe=va;function ja(t,e){for(var r=t.length;r--;)if(X(t[r][0],e))return r;return-1}var O=ja;var Ta=Array.prototype,Oa=Ta.splice;function _a(t){var e=this.__data__,r=O(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Oa.call(e,r,1),--this.size,!0}var ae=_a;function Aa(t){var e=this.__data__,r=O(e,t);return r<0?void 0:e[r][1]}var fe=Aa;function wa(t){return O(this.__data__,t)>-1}var se=wa;function Sa(t,e){var r=this.__data__,o=O(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var pe=Sa;function F(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}F.prototype.clear=oe;F.prototype.delete=ae;F.prototype.get=fe;F.prototype.has=se;F.prototype.set=pe;var _=F;var Ia=m(u,"Map"),A=Ia;function Pa(){this.size=0,this.__data__={hash:new ht,map:new(A||_),string:new ht}}var ne=Pa;function Ca(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var ie=Ca;function Ea(t,e){var r=t.__data__;return ie(e)?r[typeof e=="string"?"string":"hash"]:r.map}var w=Ea;function Ba(t){var e=w(this,t).delete(t);return this.size-=e?1:0,e}var ue=Ba;function La(t){return w(this,t).get(t)}var me=La;function Ma(t){return w(this,t).has(t)}var le=Ma;function Da(t,e){var r=w(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var de=Da;function N(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}N.prototype.clear=ne;N.prototype.delete=ue;N.prototype.get=me;N.prototype.has=le;N.prototype.set=de;var ce=N;function Fa(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var at=Fa;var Na=ot(Object.getPrototypeOf,Object),ft=Na;function Ra(){this.__data__=new _,this.size=0}var xe=Ra;function Ua(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ge=Ua;function Ga(t){return this.__data__.get(t)}var he=Ga;function Wa(t){return this.__data__.has(t)}var ye=Wa;var Ka=200;function Va(t,e){var r=this.__data__;if(r instanceof _){var o=r.__data__;if(!A||o.length<Ka-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new ce(o)}return r.set(t,e),this.size=r.size,this}var be=Va;function R(t){var e=this.__data__=new _(t);this.size=e.size}R.prototype.clear=xe;R.prototype.delete=ge;R.prototype.get=he;R.prototype.has=ye;R.prototype.set=be;var ve=R;function za(t,e){return t&&T(e,L(e),t)}var je=za;function ka(t,e){return t&&T(e,M(e),t)}var Te=ka;var we=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=we&&typeof module=="object"&&module&&!module.nodeType&&module,qa=Oe&&Oe.exports===we,_e=qa?u.Buffer:void 0,Ae=_e?_e.allocUnsafe:void 0;function Ha(t,e){if(e)return t.slice();var r=t.length,o=Ae?Ae(r):new t.constructor(r);return t.copy(o),o}var Se=Ha;function $a(t,e){for(var r=-1,o=t==null?0:t.length,a=0,f=[];++r<o;){var s=t[r];e(s,r,t)&&(f[a++]=s)}return f}var Ie=$a;function Ja(){return[]}var st=Ja;var Ya=Object.prototype,Xa=Ya.propertyIsEnumerable,Pe=Object.getOwnPropertySymbols,Za=Pe?function(t){return t==null?[]:(t=Object(t),Ie(Pe(t),function(e){return Xa.call(t,e)}))}:st,U=Za;function Qa(t,e){return T(t,U(t),e)}var Ce=Qa;var tf=Object.getOwnPropertySymbols,ef=tf?function(t){for(var e=[];t;)at(e,U(t)),t=ft(t);return e}:st,pt=ef;function rf(t,e){return T(t,pt(t),e)}var Ee=rf;function of(t,e,r){var o=e(t);return C(t)?o:at(o,r(t))}var nt=of;function af(t){return nt(t,L,U)}var Be=af;function ff(t){return nt(t,M,pt)}var Le=ff;var sf=m(u,"DataView"),it=sf;var pf=m(u,"Promise"),ut=pf;var nf=m(u,"Set"),mt=nf;var Me="[object Map]",uf="[object Object]",De="[object Promise]",Fe="[object Set]",Ne="[object WeakMap]",Re="[object DataView]",mf=y(it),lf=y(A),df=y(ut),cf=y(mt),xf=y(J),I=h;(it&&I(new it(new ArrayBuffer(1)))!=Re||A&&I(new A)!=Me||ut&&I(ut.resolve())!=De||mt&&I(new mt)!=Fe||J&&I(new J)!=Ne)&&(I=function(t){var e=h(t),r=e==uf?t.constructor:void 0,o=r?y(r):"";if(o)switch(o){case mf:return Re;case lf:return Me;case df:return De;case cf:return Fe;case xf:return Ne}return e});var G=I;var gf=Object.prototype,hf=gf.hasOwnProperty;function yf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&hf.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Ue=yf;var bf=u.Uint8Array,yt=bf;function vf(t){var e=new t.constructor(t.byteLength);return new yt(e).set(new yt(t)),e}var W=vf;function jf(t,e){var r=e?W(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Ge=jf;var Tf=/\w*$/;function Of(t){var e=new t.constructor(t.source,Tf.exec(t));return e.lastIndex=t.lastIndex,e}var We=Of;var Ke=g?g.prototype:void 0,Ve=Ke?Ke.valueOf:void 0;function _f(t){return Ve?Object(Ve.call(t)):{}}var ze=_f;function Af(t,e){var r=e?W(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var ke=Af;var wf="[object Boolean]",Sf="[object Date]",If="[object Map]",Pf="[object Number]",Cf="[object RegExp]",Ef="[object Set]",Bf="[object String]",Lf="[object Symbol]",Mf="[object ArrayBuffer]",Df="[object DataView]",Ff="[object Float32Array]",Nf="[object Float64Array]",Rf="[object Int8Array]",Uf="[object Int16Array]",Gf="[object Int32Array]",Wf="[object Uint8Array]",Kf="[object Uint8ClampedArray]",Vf="[object Uint16Array]",zf="[object Uint32Array]";function kf(t,e,r){var o=t.constructor;switch(e){case Mf:return W(t);case wf:case Sf:return new o(+t);case Df:return Ge(t,r);case Ff:case Nf:case Rf:case Uf:case Gf:case Wf:case Kf:case Vf:case zf:return ke(t,r);case If:return new o;case Pf:case Bf:return new o(t);case Cf:return We(t);case Ef:return new o;case Lf:return ze(t)}}var qe=kf;function qf(t){return typeof t.constructor=="function"&&!E(t)?Lt(ft(t)):{}}var He=qf;var Hf="[object Map]";function $f(t){return c(t)&&G(t)==Hf}var $e=$f;var Je=b&&b.isMap,Jf=Je?B(Je):$e,Ye=Jf;var Yf="[object Set]";function Xf(t){return c(t)&&G(t)==Yf}var Xe=Xf;var Ze=b&&b.isSet,Zf=Ze?B(Ze):Xe,Qe=Zf;var Qf=1,ts=2,es=4,tr="[object Arguments]",rs="[object Array]",os="[object Boolean]",as="[object Date]",fs="[object Error]",er="[object Function]",ss="[object GeneratorFunction]",ps="[object Map]",ns="[object Number]",rr="[object Object]",is="[object RegExp]",us="[object Set]",ms="[object String]",ls="[object Symbol]",ds="[object WeakMap]",cs="[object ArrayBuffer]",xs="[object DataView]",gs="[object Float32Array]",hs="[object Float64Array]",ys="[object Int8Array]",bs="[object Int16Array]",vs="[object Int32Array]",js="[object Uint8Array]",Ts="[object Uint8ClampedArray]",Os="[object Uint16Array]",_s="[object Uint32Array]",p={};p[tr]=p[rs]=p[cs]=p[xs]=p[os]=p[as]=p[gs]=p[hs]=p[ys]=p[bs]=p[vs]=p[ps]=p[ns]=p[rr]=p[is]=p[us]=p[ms]=p[ls]=p[js]=p[Ts]=p[Os]=p[_s]=!0;p[fs]=p[er]=p[ds]=!1;function lt(t,e,r,o,a,f){var s,i=e&Qf,l=e&ts,d=e&es;if(r&&(s=a?r(t,o,a,f):r(t)),s!==void 0)return s;if(!x(t))return t;var vt=C(t);if(vt){if(s=Ue(t),!i)return Mt(t,s)}else{var P=G(t),jt=P==er||P==ss;if(et(t))return Se(t,i);if(P==rr||P==tr||jt&&!a){if(s=l||jt?{}:He(t),!i)return l?Ee(t,Te(s,t)):Ce(t,je(s,t))}else{if(!p[P])return a?t:{};s=qe(t,P,i)}}f||(f=new ve);var Tt=f.get(t);if(Tt)return Tt;f.set(t,s),Qe(t)?t.forEach(function(j){s.add(lt(j,e,r,j,t,f))}):Ye(t)&&t.forEach(function(j,S){s.set(S,lt(j,e,r,S,t,f))});var ar=d?l?Le:Be:l?M:L,Ot=vt?void 0:ar(t);return Dt(Ot||t,function(j,S){Ot&&(S=j,j=t[S]),Z(s,S,lt(j,e,r,S,t,f))}),s}var or=lt;var As=1,ws=4;function Ss(t){return or(t,As|ws)}var dt=Ss;var z=class{init(){}constructor(e,r){}};var bt=class extends z{constructor(){super(...arguments);k(this,"Vue");k(this,"projects");k(this,"state",null)}bindProjectState(r){let o={component:null,componentKey:null,autoRequire:!0,write:!0,...r};return Promise.resolve().then(()=>Promise.all([this.getProjectState({autoRequire:o.autoRequire}),(()=>{if(!o.componentKey){for(let a=0;a<50;a++){let f=`terafy_${a}`;if(!Object.hasOwnProperty(o.component,f)){o.componentKey=f;return}}throw new Error("Unable to find unique key to allocate against Vue2 component")}})()])).then(([a])=>{this.debug("Got project snapshot",a);let f=this.Vue.observable(a);o.component[o.componentKey]=f;let s=0;if(o.read&&this.events.on(`update:projects/${f.id}`,i=>{s++,Object.assign(f,i)}),o.write){if(!o.component)throw new Error("bindProjectState requires a VueComponent specified as `component`");let i=dt(a);o.component.$watch(o.componentKey,l=>{if(s>0){s--;return}this.createProjectStatePatch(l,i),i=dt(a)},{deep:!0})}return f})}init(r){let o={app:null,Vue:null,globalName:"$tera",subscribeState:!0,subscribeProjects:!0,stateOptions:{read:!0,write:!0},...r};if(!o.Vue)throw new Error("Vue instance to use must be specified in init options as `Vue`");if(this.Vue=r.Vue,!this.settings.app)throw new Error("Need to specify the root level Vue2 app during init");return o.stateOptions.app=this.settings.app,this.projects=this.Vue.observable([]),o.globalName&&(this.Vue.prototype[o.globalName]=this),this.state=null,Promise.resolve().then(()=>Promise.all([o.subscribeState&&this.bindProjectState({...o.stateOptions,component:this.settings.app.$root}).then(a=>this.state=a).then(()=>this.debug("INFO","Loaded project state",this.state)),o.subscribeProjects&&this.getProjects().then(a=>this.projects=this.Vue.observable(a)).then(()=>this.debug("INFO","Loaded projects",this.projects))]))}};export{bt as default};
|
|
1
|
+
var fr=Object.defineProperty;var sr=(t,e,r)=>e in t?fr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var H=(t,e,r)=>(sr(t,typeof e!="symbol"?e+"":e,r),r);var pr=typeof global=="object"&&global&&global.Object===Object&&global,$=pr;var ir=typeof self=="object"&&self&&self.Object===Object&&self,nr=$||ir||Function("return this")(),u=nr;var ur=u.Symbol,h=ur;var Ot=Object.prototype,mr=Ot.hasOwnProperty,lr=Ot.toString,K=h?h.toStringTag:void 0;function dr(t){var e=mr.call(t,K),r=t[K];try{t[K]=void 0;var o=!0}catch{}var a=lr.call(t);return o&&(e?t[K]=r:delete t[K]),a}var At=dr;var cr=Object.prototype,xr=cr.toString;function gr(t){return xr.call(t)}var wt=gr;var hr="[object Null]",yr="[object Undefined]",St=h?h.toStringTag:void 0;function br(t){return t==null?t===void 0?yr:hr:St&&St in Object(t)?At(t):wt(t)}var y=br;function jr(t){return t!=null&&typeof t=="object"}var x=jr;var vr=Array.isArray,E=vr;function Tr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var g=Tr;var _r="[object AsyncFunction]",Or="[object Function]",Ar="[object GeneratorFunction]",wr="[object Proxy]";function Sr(t){if(!g(t))return!1;var e=y(t);return e==Or||e==Ar||e==_r||e==wr}var k=Sr;var Ir=u["__core-js_shared__"],J=Ir;var It=function(){var t=/[^.]+$/.exec(J&&J.keys&&J.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Pr(t){return!!It&&It in t}var Pt=Pr;var Cr=Function.prototype,Er=Cr.toString;function Br(t){if(t!=null){try{return Er.call(t)}catch{}try{return t+""}catch{}}return""}var b=Br;var Lr=/[\\^$.*+?()[\]{}|]/g,Mr=/^\[object .+?Constructor\]$/,Dr=Function.prototype,Nr=Object.prototype,Fr=Dr.toString,Ur=Nr.hasOwnProperty,Rr=RegExp("^"+Fr.call(Ur).replace(Lr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Vr(t){if(!g(t)||Pt(t))return!1;var e=k(t)?Rr:Mr;return e.test(b(t))}var Ct=Vr;function Gr(t,e){return t==null?void 0:t[e]}var Et=Gr;function Wr(t,e){var r=Et(t,e);return Ct(r)?r:void 0}var d=Wr;var Kr=d(u,"WeakMap"),Y=Kr;var Bt=Object.create,zr=function(){function t(){}return function(e){if(!g(e))return{};if(Bt)return Bt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Lt=zr;function qr(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Mt=qr;var Hr=function(){try{var t=d(Object,"defineProperty");return t({},"",{}),t}catch{}}(),xt=Hr;function $r(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Dt=$r;var kr=9007199254740991,Jr=/^(?:0|[1-9]\d*)$/;function Yr(t,e){var r=typeof t;return e=e==null?kr:e,!!e&&(r=="number"||r!="symbol"&&Jr.test(t))&&t>-1&&t%1==0&&t<e}var Nt=Yr;function Xr(t,e,r){e=="__proto__"&&xt?xt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var X=Xr;function Zr(t,e){return t===e||t!==t&&e!==e}var Z=Zr;var Qr=Object.prototype,to=Qr.hasOwnProperty;function eo(t,e,r){var o=t[e];(!(to.call(t,e)&&Z(o,r))||r===void 0&&!(e in t))&&X(t,e,r)}var Q=eo;function ro(t,e,r,o){var a=!r;r||(r={});for(var p=-1,s=e.length;++p<s;){var f=e[p],m=o?o(r[f],t[f],f,r,t):void 0;m===void 0&&(m=t[f]),a?X(r,f,m):Q(r,f,m)}return r}var O=ro;var oo=9007199254740991;function ao(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=oo}var tt=ao;function fo(t){return t!=null&&tt(t.length)&&!k(t)}var et=fo;var so=Object.prototype;function po(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||so;return t===r}var B=po;function io(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Ft=io;var no="[object Arguments]";function uo(t){return x(t)&&y(t)==no}var gt=uo;var Ut=Object.prototype,mo=Ut.hasOwnProperty,lo=Ut.propertyIsEnumerable,co=gt(function(){return arguments}())?gt:function(t){return x(t)&&mo.call(t,"callee")&&!lo.call(t,"callee")},Rt=co;function xo(){return!1}var Vt=xo;var Kt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Gt=Kt&&typeof module=="object"&&module&&!module.nodeType&&module,go=Gt&&Gt.exports===Kt,Wt=go?u.Buffer:void 0,ho=Wt?Wt.isBuffer:void 0,yo=ho||Vt,rt=yo;var bo="[object Arguments]",jo="[object Array]",vo="[object Boolean]",To="[object Date]",_o="[object Error]",Oo="[object Function]",Ao="[object Map]",wo="[object Number]",So="[object Object]",Io="[object RegExp]",Po="[object Set]",Co="[object String]",Eo="[object WeakMap]",Bo="[object ArrayBuffer]",Lo="[object DataView]",Mo="[object Float32Array]",Do="[object Float64Array]",No="[object Int8Array]",Fo="[object Int16Array]",Uo="[object Int32Array]",Ro="[object Uint8Array]",Vo="[object Uint8ClampedArray]",Go="[object Uint16Array]",Wo="[object Uint32Array]",n={};n[Mo]=n[Do]=n[No]=n[Fo]=n[Uo]=n[Ro]=n[Vo]=n[Go]=n[Wo]=!0;n[bo]=n[jo]=n[Bo]=n[vo]=n[Lo]=n[To]=n[_o]=n[Oo]=n[Ao]=n[wo]=n[So]=n[Io]=n[Po]=n[Co]=n[Eo]=!1;function Ko(t){return x(t)&&tt(t.length)&&!!n[y(t)]}var zt=Ko;function zo(t){return function(e){return t(e)}}var L=zo;var qt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,z=qt&&typeof module=="object"&&module&&!module.nodeType&&module,qo=z&&z.exports===qt,ht=qo&&$.process,Ho=function(){try{var t=z&&z.require&&z.require("util").types;return t||ht&&ht.binding&&ht.binding("util")}catch{}}(),j=Ho;var Ht=j&&j.isTypedArray,$o=Ht?L(Ht):zt,$t=$o;var ko=Object.prototype,Jo=ko.hasOwnProperty;function Yo(t,e){var r=E(t),o=!r&&Rt(t),a=!r&&!o&&rt(t),p=!r&&!o&&!a&&$t(t),s=r||o||a||p,f=s?Ft(t.length,String):[],m=f.length;for(var l in t)(e||Jo.call(t,l))&&!(s&&(l=="length"||a&&(l=="offset"||l=="parent")||p&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Nt(l,m)))&&f.push(l);return f}var ot=Yo;function Xo(t,e){return function(r){return t(e(r))}}var at=Xo;var Zo=at(Object.keys,Object),kt=Zo;var Qo=Object.prototype,ta=Qo.hasOwnProperty;function ea(t){if(!B(t))return kt(t);var e=[];for(var r in Object(t))ta.call(t,r)&&r!="constructor"&&e.push(r);return e}var Jt=ea;function ra(t){return et(t)?ot(t):Jt(t)}var M=ra;function oa(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Yt=oa;var aa=Object.prototype,fa=aa.hasOwnProperty;function sa(t){if(!g(t))return Yt(t);var e=B(t),r=[];for(var o in t)o=="constructor"&&(e||!fa.call(t,o))||r.push(o);return r}var Xt=sa;function pa(t){return et(t)?ot(t,!0):Xt(t)}var D=pa;var ia=d(Object,"create"),v=ia;function na(){this.__data__=v?v(null):{},this.size=0}var Zt=na;function ua(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Qt=ua;var ma="__lodash_hash_undefined__",la=Object.prototype,da=la.hasOwnProperty;function ca(t){var e=this.__data__;if(v){var r=e[t];return r===ma?void 0:r}return da.call(e,t)?e[t]:void 0}var te=ca;var xa=Object.prototype,ga=xa.hasOwnProperty;function ha(t){var e=this.__data__;return v?e[t]!==void 0:ga.call(e,t)}var ee=ha;var ya="__lodash_hash_undefined__";function ba(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=v&&e===void 0?ya:e,this}var re=ba;function N(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}N.prototype.clear=Zt;N.prototype.delete=Qt;N.prototype.get=te;N.prototype.has=ee;N.prototype.set=re;var yt=N;function ja(){this.__data__=[],this.size=0}var oe=ja;function va(t,e){for(var r=t.length;r--;)if(Z(t[r][0],e))return r;return-1}var A=va;var Ta=Array.prototype,_a=Ta.splice;function Oa(t){var e=this.__data__,r=A(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():_a.call(e,r,1),--this.size,!0}var ae=Oa;function Aa(t){var e=this.__data__,r=A(e,t);return r<0?void 0:e[r][1]}var fe=Aa;function wa(t){return A(this.__data__,t)>-1}var se=wa;function Sa(t,e){var r=this.__data__,o=A(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var pe=Sa;function F(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}F.prototype.clear=oe;F.prototype.delete=ae;F.prototype.get=fe;F.prototype.has=se;F.prototype.set=pe;var w=F;var Ia=d(u,"Map"),S=Ia;function Pa(){this.size=0,this.__data__={hash:new yt,map:new(S||w),string:new yt}}var ie=Pa;function Ca(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var ne=Ca;function Ea(t,e){var r=t.__data__;return ne(e)?r[typeof e=="string"?"string":"hash"]:r.map}var I=Ea;function Ba(t){var e=I(this,t).delete(t);return this.size-=e?1:0,e}var ue=Ba;function La(t){return I(this,t).get(t)}var me=La;function Ma(t){return I(this,t).has(t)}var le=Ma;function Da(t,e){var r=I(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var de=Da;function U(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}U.prototype.clear=ie;U.prototype.delete=ue;U.prototype.get=me;U.prototype.has=le;U.prototype.set=de;var ce=U;function Na(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var ft=Na;var Fa=at(Object.getPrototypeOf,Object),st=Fa;function Ua(){this.__data__=new w,this.size=0}var xe=Ua;function Ra(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ge=Ra;function Va(t){return this.__data__.get(t)}var he=Va;function Ga(t){return this.__data__.has(t)}var ye=Ga;var Wa=200;function Ka(t,e){var r=this.__data__;if(r instanceof w){var o=r.__data__;if(!S||o.length<Wa-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new ce(o)}return r.set(t,e),this.size=r.size,this}var be=Ka;function R(t){var e=this.__data__=new w(t);this.size=e.size}R.prototype.clear=xe;R.prototype.delete=ge;R.prototype.get=he;R.prototype.has=ye;R.prototype.set=be;var je=R;function za(t,e){return t&&O(e,M(e),t)}var ve=za;function qa(t,e){return t&&O(e,D(e),t)}var Te=qa;var we=typeof exports=="object"&&exports&&!exports.nodeType&&exports,_e=we&&typeof module=="object"&&module&&!module.nodeType&&module,Ha=_e&&_e.exports===we,Oe=Ha?u.Buffer:void 0,Ae=Oe?Oe.allocUnsafe:void 0;function $a(t,e){if(e)return t.slice();var r=t.length,o=Ae?Ae(r):new t.constructor(r);return t.copy(o),o}var Se=$a;function ka(t,e){for(var r=-1,o=t==null?0:t.length,a=0,p=[];++r<o;){var s=t[r];e(s,r,t)&&(p[a++]=s)}return p}var Ie=ka;function Ja(){return[]}var pt=Ja;var Ya=Object.prototype,Xa=Ya.propertyIsEnumerable,Pe=Object.getOwnPropertySymbols,Za=Pe?function(t){return t==null?[]:(t=Object(t),Ie(Pe(t),function(e){return Xa.call(t,e)}))}:pt,V=Za;function Qa(t,e){return O(t,V(t),e)}var Ce=Qa;var tf=Object.getOwnPropertySymbols,ef=tf?function(t){for(var e=[];t;)ft(e,V(t)),t=st(t);return e}:pt,it=ef;function rf(t,e){return O(t,it(t),e)}var Ee=rf;function of(t,e,r){var o=e(t);return E(t)?o:ft(o,r(t))}var nt=of;function af(t){return nt(t,M,V)}var Be=af;function ff(t){return nt(t,D,it)}var Le=ff;var sf=d(u,"DataView"),ut=sf;var pf=d(u,"Promise"),mt=pf;var nf=d(u,"Set"),lt=nf;var Me="[object Map]",uf="[object Object]",De="[object Promise]",Ne="[object Set]",Fe="[object WeakMap]",Ue="[object DataView]",mf=b(ut),lf=b(S),df=b(mt),cf=b(lt),xf=b(Y),C=y;(ut&&C(new ut(new ArrayBuffer(1)))!=Ue||S&&C(new S)!=Me||mt&&C(mt.resolve())!=De||lt&&C(new lt)!=Ne||Y&&C(new Y)!=Fe)&&(C=function(t){var e=y(t),r=e==uf?t.constructor:void 0,o=r?b(r):"";if(o)switch(o){case mf:return Ue;case lf:return Me;case df:return De;case cf:return Ne;case xf:return Fe}return e});var G=C;var gf=Object.prototype,hf=gf.hasOwnProperty;function yf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&hf.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Re=yf;var bf=u.Uint8Array,bt=bf;function jf(t){var e=new t.constructor(t.byteLength);return new bt(e).set(new bt(t)),e}var W=jf;function vf(t,e){var r=e?W(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Ve=vf;var Tf=/\w*$/;function _f(t){var e=new t.constructor(t.source,Tf.exec(t));return e.lastIndex=t.lastIndex,e}var Ge=_f;var We=h?h.prototype:void 0,Ke=We?We.valueOf:void 0;function Of(t){return Ke?Object(Ke.call(t)):{}}var ze=Of;function Af(t,e){var r=e?W(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var qe=Af;var wf="[object Boolean]",Sf="[object Date]",If="[object Map]",Pf="[object Number]",Cf="[object RegExp]",Ef="[object Set]",Bf="[object String]",Lf="[object Symbol]",Mf="[object ArrayBuffer]",Df="[object DataView]",Nf="[object Float32Array]",Ff="[object Float64Array]",Uf="[object Int8Array]",Rf="[object Int16Array]",Vf="[object Int32Array]",Gf="[object Uint8Array]",Wf="[object Uint8ClampedArray]",Kf="[object Uint16Array]",zf="[object Uint32Array]";function qf(t,e,r){var o=t.constructor;switch(e){case Mf:return W(t);case wf:case Sf:return new o(+t);case Df:return Ve(t,r);case Nf:case Ff:case Uf:case Rf:case Vf:case Gf:case Wf:case Kf:case zf:return qe(t,r);case If:return new o;case Pf:case Bf:return new o(t);case Cf:return Ge(t);case Ef:return new o;case Lf:return ze(t)}}var He=qf;function Hf(t){return typeof t.constructor=="function"&&!B(t)?Lt(st(t)):{}}var $e=Hf;var $f="[object Map]";function kf(t){return x(t)&&G(t)==$f}var ke=kf;var Je=j&&j.isMap,Jf=Je?L(Je):ke,Ye=Jf;var Yf="[object Set]";function Xf(t){return x(t)&&G(t)==Yf}var Xe=Xf;var Ze=j&&j.isSet,Zf=Ze?L(Ze):Xe,Qe=Zf;var Qf=1,ts=2,es=4,tr="[object Arguments]",rs="[object Array]",os="[object Boolean]",as="[object Date]",fs="[object Error]",er="[object Function]",ss="[object GeneratorFunction]",ps="[object Map]",is="[object Number]",rr="[object Object]",ns="[object RegExp]",us="[object Set]",ms="[object String]",ls="[object Symbol]",ds="[object WeakMap]",cs="[object ArrayBuffer]",xs="[object DataView]",gs="[object Float32Array]",hs="[object Float64Array]",ys="[object Int8Array]",bs="[object Int16Array]",js="[object Int32Array]",vs="[object Uint8Array]",Ts="[object Uint8ClampedArray]",_s="[object Uint16Array]",Os="[object Uint32Array]",i={};i[tr]=i[rs]=i[cs]=i[xs]=i[os]=i[as]=i[gs]=i[hs]=i[ys]=i[bs]=i[js]=i[ps]=i[is]=i[rr]=i[ns]=i[us]=i[ms]=i[ls]=i[vs]=i[Ts]=i[_s]=i[Os]=!0;i[fs]=i[er]=i[ds]=!1;function dt(t,e,r,o,a,p){var s,f=e&Qf,m=e&ts,l=e&es;if(r&&(s=a?r(t,o,a,p):r(t)),s!==void 0)return s;if(!g(t))return t;var T=E(t);if(T){if(s=Re(t),!f)return Mt(t,s)}else{var c=G(t),vt=c==er||c==ss;if(rt(t))return Se(t,f);if(c==rr||c==tr||vt&&!a){if(s=m||vt?{}:$e(t),!f)return m?Ee(t,Te(s,t)):Ce(t,ve(s,t))}else{if(!i[c])return a?t:{};s=He(t,c,f)}}p||(p=new je);var Tt=p.get(t);if(Tt)return Tt;p.set(t,s),Qe(t)?t.forEach(function(_){s.add(dt(_,e,r,_,t,p))}):Ye(t)&&t.forEach(function(_,P){s.set(P,dt(_,e,r,P,t,p))});var ar=l?m?Le:Be:m?D:M,_t=T?void 0:ar(t);return Dt(_t||t,function(_,P){_t&&(P=_,_=t[P]),Q(s,P,dt(_,e,r,P,t,p))}),s}var or=dt;var As=1,ws=4;function Ss(t){return or(t,As|ws)}var ct=Ss;var q=class{init(){}constructor(e,r){}};var jt=class extends q{constructor(){super(...arguments);H(this,"Vue");H(this,"projects");H(this,"state",null)}bindProjectState(r){let o={component:null,componentKey:null,autoRequire:!0,write:!0,...r};return Promise.resolve().then(()=>Promise.all([this.getProjectState({autoRequire:o.autoRequire}),(()=>{if(!o.componentKey){for(let a=0;a<50;a++){let p=`terafy_${a}`;if(!Object.hasOwnProperty(o.component,p)){o.componentKey=p;return}}throw new Error("Unable to find unique key to allocate against Vue2 component")}})()])).then(([a])=>{this.debug("Got project snapshot",a);let p=this.Vue.observable(a);o.component[o.componentKey]=p;let s=0;if(o.read&&this.events.on(`update:projects/${p.id}`,f=>{s++,Object.assign(p,f)}),o.write){if(!o.component)throw new Error("bindProjectState requires a VueComponent specified as `component`");let f=ct(a);o.component.$watch(o.componentKey,m=>{if(s>0){s--;return}this.createProjectStatePatch(m,f),f=ct(a)},{deep:!0})}return p})}init(r){let o={app:null,Vue:null,globalName:"$tera",requireProject:!0,subscribeState:!0,subscribeProjects:!0,stateOptions:{read:!0,write:!0},...r};if(!o.Vue)throw new Error("Vue instance to use must be specified in init options as `Vue`");if(this.Vue=r.Vue,!this.settings.app)throw new Error("Need to specify the root level Vue2 app during init");return o.stateOptions.app=this.settings.app,this.projects=this.Vue.observable([]),o.globalName&&(this.Vue.prototype[o.globalName]=this),this.state=null,Promise.resolve().then(()=>o.requireProject&&this.requireProject()).then(()=>Promise.all([o.subscribeState&&this.bindProjectState({...o.stateOptions,component:this.settings.app.$root}).then(a=>this.state=a).then(()=>this.debug("INFO","Loaded project state",this.state)),o.subscribeProjects&&this.getProjects().then(a=>this.projects=this.Vue.observable(a)).then(()=>this.debug("INFO","Loaded projects",this.projects))]))}_pathSet(r,o,a,p){if(typeof r!="object")throw new Error("Cannot use _pathSet on non-object target");let s={arrayNumeric:!0,debug:!1,removeUndefined:!0,...p};s.debug&&console.log("[_pathSet]",o,"=",a,{target:r,options:p});let f=r;if(!o)throw new Error("Cannot _pathSet with undefined path");return(typeof o=="string"?o.split("."):o).some((m,l,T)=>{if(l==T.length-1)s.removeUndefined&&a===void 0?this.Vue.$delete(f,m):this.Vue.set(f,m,a);else return f[m]===void 0?(T.slice(l,T.length-1).forEach(c=>{s.arrayNumeric&&isFinite(c)?this.Vue.set(f,c,[]):this.Vue.set(f,c,{}),f=f[c]}),this.Vue.set(f,T[T.length-1],a),!0):(f=f[m],!1)}),a}};export{jt as default};
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
lodash-es/lodash.js:
|
|
@@ -12,4 +12,3 @@ lodash-es/lodash.js:
|
|
|
12
12
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
13
13
|
*)
|
|
14
14
|
*/
|
|
15
|
-
//# sourceMappingURL=plugin.vue2.es2019.js.map
|
package/dist/terafy.es2019.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var mr=Object.defineProperty;var ur=(t,e,r)=>e in t?mr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var F=(t,e,r)=>(ur(t,typeof e!="symbol"?e+"":e,r),r);function St(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(a){return a});function o({obj1:a,obj2:p,basePath:m,basePathForRemoves:w,diffs:h}){var y=Object.keys(a),b=y.length,c=Object.keys(p),L=c.length,g,v=a.length-p.length;if(cr(a,p)){for(var d=0;d<b;d++){var D=Array.isArray(a)?Number(y[d]):y[d];D in p||(g=w.concat(D),h.remove.push({op:"remove",path:r(g)}))}for(var d=0;d<L;d++){var D=Array.isArray(p)?Number(c[d]):c[d];i({key:D,obj1:a,obj2:p,path:m.concat(D),pathForRemoves:m.concat(D),diffs:h})}}else{for(var d=0;d<v;d++)g=w.concat(d),h.remove.push({op:"remove",path:r(g)});for(var lr=a.slice(v),d=0;d<L;d++)i({key:d,obj1:lr,obj2:p,path:m.concat(d),pathForRemoves:m.concat(d+v),diffs:h})}}var f={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:f}),f.remove.reverse().concat(f.replace).concat(f.add);function i({key:a,obj1:p,obj2:m,path:w,pathForRemoves:h,diffs:y}){var b=p[a],c=m[a];if(!(a in p)&&a in m){var L=c;y.add.push({op:"add",path:r(w),value:L})}else b!==c&&(Object(b)!==b||Object(c)!==c||dr(b,c)||!Object.keys(b).length&&!Object.keys(c).length&&String(b)!=String(c)?s(w,y,c):o({obj1:p[a],obj2:m[a],basePath:w,basePathForRemoves:h,diffs:y}))}function s(a,p,m){p.replace.push({op:"replace",path:r(a),value:m})}}function Pt(t){return[""].concat(t).join("/")}function dr(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function cr(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,f=0,i=0;i<e.length&&String(t[i])===String(e[i]);i++)o++;for(var s=e.length;s>0&&String(t[s+r])===String(e[s]);s--)f++;return o>=f}return!0}var xr=typeof global=="object"&&global&&global.Object===Object&&global,Z=xr;var hr=typeof self=="object"&&self&&self.Object===Object&&self,gr=Z||hr||Function("return this")(),u=gr;var yr=u.Symbol,A=yr;var It=Object.prototype,br=It.hasOwnProperty,vr=It.toString,J=A?A.toStringTag:void 0;function wr(t){var e=br.call(t,J),r=t[J];try{t[J]=void 0;var o=!0}catch{}var f=vr.call(t);return o&&(e?t[J]=r:delete t[J]),f}var Ct=wr;var jr=Object.prototype,Tr=jr.toString;function Ar(t){return Tr.call(t)}var Et=Ar;var Or="[object Null]",_r="[object Undefined]",Mt=A?A.toStringTag:void 0;function Sr(t){return t==null?t===void 0?_r:Or:Mt&&Mt in Object(t)?Ct(t):Et(t)}var O=Sr;function Pr(t){return t!=null&&typeof t=="object"}var j=Pr;var Ir=Array.isArray,N=Ir;function Cr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var T=Cr;var Er="[object AsyncFunction]",Mr="[object Function]",Rr="[object GeneratorFunction]",Lr="[object Proxy]";function Fr(t){if(!T(t))return!1;var e=O(t);return e==Mr||e==Rr||e==Er||e==Lr}var Q=Fr;var Br=u["__core-js_shared__"],tt=Br;var Rt=function(){var t=/[^.]+$/.exec(tt&&tt.keys&&tt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Dr(t){return!!Rt&&Rt in t}var Lt=Dr;var Nr=Function.prototype,Ur=Nr.toString;function kr(t){if(t!=null){try{return Ur.call(t)}catch{}try{return t+""}catch{}}return""}var _=kr;var Wr=/[\\^$.*+?()[\]{}|]/g,Gr=/^\[object .+?Constructor\]$/,Kr=Function.prototype,zr=Object.prototype,Vr=Kr.toString,qr=zr.hasOwnProperty,Hr=RegExp("^"+Vr.call(qr).replace(Wr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function $r(t){if(!T(t)||Lt(t))return!1;var e=Q(t)?Hr:Gr;return e.test(_(t))}var Ft=$r;function Yr(t,e){return t==null?void 0:t[e]}var Bt=Yr;function Jr(t,e){var r=Bt(t,e);return Ft(r)?r:void 0}var x=Jr;var Xr=x(u,"WeakMap"),et=Xr;var Dt=Object.create,Zr=function(){function t(){}return function(e){if(!T(e))return{};if(Dt)return Dt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Nt=Zr;function Qr(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Ut=Qr;var to=function(){try{var t=x(Object,"defineProperty");return t({},"",{}),t}catch{}}(),bt=to;function eo(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var kt=eo;var ro=9007199254740991,oo=/^(?:0|[1-9]\d*)$/;function ao(t,e){var r=typeof t;return e=e==null?ro:e,!!e&&(r=="number"||r!="symbol"&&oo.test(t))&&t>-1&&t%1==0&&t<e}var Wt=ao;function fo(t,e,r){e=="__proto__"&&bt?bt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var rt=fo;function so(t,e){return t===e||t!==t&&e!==e}var ot=so;var io=Object.prototype,no=io.hasOwnProperty;function po(t,e,r){var o=t[e];(!(no.call(t,e)&&ot(o,r))||r===void 0&&!(e in t))&&rt(t,e,r)}var at=po;function lo(t,e,r,o){var f=!r;r||(r={});for(var i=-1,s=e.length;++i<s;){var a=e[i],p=o?o(r[a],t[a],a,r,t):void 0;p===void 0&&(p=t[a]),f?rt(r,a,p):at(r,a,p)}return r}var I=lo;var mo=9007199254740991;function uo(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=mo}var ft=uo;function co(t){return t!=null&&ft(t.length)&&!Q(t)}var st=co;var xo=Object.prototype;function ho(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||xo;return t===r}var U=ho;function go(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Gt=go;var yo="[object Arguments]";function bo(t){return j(t)&&O(t)==yo}var vt=bo;var Kt=Object.prototype,vo=Kt.hasOwnProperty,wo=Kt.propertyIsEnumerable,jo=vt(function(){return arguments}())?vt:function(t){return j(t)&&vo.call(t,"callee")&&!wo.call(t,"callee")},zt=jo;function To(){return!1}var Vt=To;var $t=typeof exports=="object"&&exports&&!exports.nodeType&&exports,qt=$t&&typeof module=="object"&&module&&!module.nodeType&&module,Ao=qt&&qt.exports===$t,Ht=Ao?u.Buffer:void 0,Oo=Ht?Ht.isBuffer:void 0,_o=Oo||Vt,it=_o;var So="[object Arguments]",Po="[object Array]",Io="[object Boolean]",Co="[object Date]",Eo="[object Error]",Mo="[object Function]",Ro="[object Map]",Lo="[object Number]",Fo="[object Object]",Bo="[object RegExp]",Do="[object Set]",No="[object String]",Uo="[object WeakMap]",ko="[object ArrayBuffer]",Wo="[object DataView]",Go="[object Float32Array]",Ko="[object Float64Array]",zo="[object Int8Array]",Vo="[object Int16Array]",qo="[object Int32Array]",Ho="[object Uint8Array]",$o="[object Uint8ClampedArray]",Yo="[object Uint16Array]",Jo="[object Uint32Array]",l={};l[Go]=l[Ko]=l[zo]=l[Vo]=l[qo]=l[Ho]=l[$o]=l[Yo]=l[Jo]=!0;l[So]=l[Po]=l[ko]=l[Io]=l[Wo]=l[Co]=l[Eo]=l[Mo]=l[Ro]=l[Lo]=l[Fo]=l[Bo]=l[Do]=l[No]=l[Uo]=!1;function Xo(t){return j(t)&&ft(t.length)&&!!l[O(t)]}var Yt=Xo;function Zo(t){return function(e){return t(e)}}var k=Zo;var Jt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,X=Jt&&typeof module=="object"&&module&&!module.nodeType&&module,Qo=X&&X.exports===Jt,wt=Qo&&Z.process,ta=function(){try{var t=X&&X.require&&X.require("util").types;return t||wt&&wt.binding&&wt.binding("util")}catch{}}(),S=ta;var Xt=S&&S.isTypedArray,ea=Xt?k(Xt):Yt,Zt=ea;var ra=Object.prototype,oa=ra.hasOwnProperty;function aa(t,e){var r=N(t),o=!r&&zt(t),f=!r&&!o&&it(t),i=!r&&!o&&!f&&Zt(t),s=r||o||f||i,a=s?Gt(t.length,String):[],p=a.length;for(var m in t)(e||oa.call(t,m))&&!(s&&(m=="length"||f&&(m=="offset"||m=="parent")||i&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||Wt(m,p)))&&a.push(m);return a}var nt=aa;function fa(t,e){return function(r){return t(e(r))}}var pt=fa;var sa=pt(Object.keys,Object),Qt=sa;var ia=Object.prototype,na=ia.hasOwnProperty;function pa(t){if(!U(t))return Qt(t);var e=[];for(var r in Object(t))na.call(t,r)&&r!="constructor"&&e.push(r);return e}var te=pa;function la(t){return st(t)?nt(t):te(t)}var W=la;function ma(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var ee=ma;var ua=Object.prototype,da=ua.hasOwnProperty;function ca(t){if(!T(t))return ee(t);var e=U(t),r=[];for(var o in t)o=="constructor"&&(e||!da.call(t,o))||r.push(o);return r}var re=ca;function xa(t){return st(t)?nt(t,!0):re(t)}var G=xa;var ha=x(Object,"create"),P=ha;function ga(){this.__data__=P?P(null):{},this.size=0}var oe=ga;function ya(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var ae=ya;var ba="__lodash_hash_undefined__",va=Object.prototype,wa=va.hasOwnProperty;function ja(t){var e=this.__data__;if(P){var r=e[t];return r===ba?void 0:r}return wa.call(e,t)?e[t]:void 0}var fe=ja;var Ta=Object.prototype,Aa=Ta.hasOwnProperty;function Oa(t){var e=this.__data__;return P?e[t]!==void 0:Aa.call(e,t)}var se=Oa;var _a="__lodash_hash_undefined__";function Sa(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=P&&e===void 0?_a:e,this}var ie=Sa;function K(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}K.prototype.clear=oe;K.prototype.delete=ae;K.prototype.get=fe;K.prototype.has=se;K.prototype.set=ie;var jt=K;function Pa(){this.__data__=[],this.size=0}var ne=Pa;function Ia(t,e){for(var r=t.length;r--;)if(ot(t[r][0],e))return r;return-1}var C=Ia;var Ca=Array.prototype,Ea=Ca.splice;function Ma(t){var e=this.__data__,r=C(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Ea.call(e,r,1),--this.size,!0}var pe=Ma;function Ra(t){var e=this.__data__,r=C(e,t);return r<0?void 0:e[r][1]}var le=Ra;function La(t){return C(this.__data__,t)>-1}var me=La;function Fa(t,e){var r=this.__data__,o=C(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var ue=Fa;function z(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}z.prototype.clear=ne;z.prototype.delete=pe;z.prototype.get=le;z.prototype.has=me;z.prototype.set=ue;var E=z;var Ba=x(u,"Map"),M=Ba;function Da(){this.size=0,this.__data__={hash:new jt,map:new(M||E),string:new jt}}var de=Da;function Na(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var ce=Na;function Ua(t,e){var r=t.__data__;return ce(e)?r[typeof e=="string"?"string":"hash"]:r.map}var R=Ua;function ka(t){var e=R(this,t).delete(t);return this.size-=e?1:0,e}var xe=ka;function Wa(t){return R(this,t).get(t)}var he=Wa;function Ga(t){return R(this,t).has(t)}var ge=Ga;function Ka(t,e){var r=R(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var ye=Ka;function V(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}V.prototype.clear=de;V.prototype.delete=xe;V.prototype.get=he;V.prototype.has=ge;V.prototype.set=ye;var be=V;function za(t,e){for(var r=-1,o=e.length,f=t.length;++r<o;)t[f+r]=e[r];return t}var lt=za;var Va=pt(Object.getPrototypeOf,Object),mt=Va;function qa(){this.__data__=new E,this.size=0}var ve=qa;function Ha(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var we=Ha;function $a(t){return this.__data__.get(t)}var je=$a;function Ya(t){return this.__data__.has(t)}var Te=Ya;var Ja=200;function Xa(t,e){var r=this.__data__;if(r instanceof E){var o=r.__data__;if(!M||o.length<Ja-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new be(o)}return r.set(t,e),this.size=r.size,this}var Ae=Xa;function q(t){var e=this.__data__=new E(t);this.size=e.size}q.prototype.clear=ve;q.prototype.delete=we;q.prototype.get=je;q.prototype.has=Te;q.prototype.set=Ae;var Oe=q;function Za(t,e){return t&&I(e,W(e),t)}var _e=Za;function Qa(t,e){return t&&I(e,G(e),t)}var Se=Qa;var Ee=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Pe=Ee&&typeof module=="object"&&module&&!module.nodeType&&module,tf=Pe&&Pe.exports===Ee,Ie=tf?u.Buffer:void 0,Ce=Ie?Ie.allocUnsafe:void 0;function ef(t,e){if(e)return t.slice();var r=t.length,o=Ce?Ce(r):new t.constructor(r);return t.copy(o),o}var Me=ef;function rf(t,e){for(var r=-1,o=t==null?0:t.length,f=0,i=[];++r<o;){var s=t[r];e(s,r,t)&&(i[f++]=s)}return i}var Re=rf;function of(){return[]}var ut=of;var af=Object.prototype,ff=af.propertyIsEnumerable,Le=Object.getOwnPropertySymbols,sf=Le?function(t){return t==null?[]:(t=Object(t),Re(Le(t),function(e){return ff.call(t,e)}))}:ut,H=sf;function nf(t,e){return I(t,H(t),e)}var Fe=nf;var pf=Object.getOwnPropertySymbols,lf=pf?function(t){for(var e=[];t;)lt(e,H(t)),t=mt(t);return e}:ut,dt=lf;function mf(t,e){return I(t,dt(t),e)}var Be=mf;function uf(t,e,r){var o=e(t);return N(t)?o:lt(o,r(t))}var ct=uf;function df(t){return ct(t,W,H)}var De=df;function cf(t){return ct(t,G,dt)}var Ne=cf;var xf=x(u,"DataView"),xt=xf;var hf=x(u,"Promise"),ht=hf;var gf=x(u,"Set"),gt=gf;var Ue="[object Map]",yf="[object Object]",ke="[object Promise]",We="[object Set]",Ge="[object WeakMap]",Ke="[object DataView]",bf=_(xt),vf=_(M),wf=_(ht),jf=_(gt),Tf=_(et),B=O;(xt&&B(new xt(new ArrayBuffer(1)))!=Ke||M&&B(new M)!=Ue||ht&&B(ht.resolve())!=ke||gt&&B(new gt)!=We||et&&B(new et)!=Ge)&&(B=function(t){var e=O(t),r=e==yf?t.constructor:void 0,o=r?_(r):"";if(o)switch(o){case bf:return Ke;case vf:return Ue;case wf:return ke;case jf:return We;case Tf:return Ge}return e});var $=B;var Af=Object.prototype,Of=Af.hasOwnProperty;function _f(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Of.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var ze=_f;var Sf=u.Uint8Array,Tt=Sf;function Pf(t){var e=new t.constructor(t.byteLength);return new Tt(e).set(new Tt(t)),e}var Y=Pf;function If(t,e){var r=e?Y(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var Ve=If;var Cf=/\w*$/;function Ef(t){var e=new t.constructor(t.source,Cf.exec(t));return e.lastIndex=t.lastIndex,e}var qe=Ef;var He=A?A.prototype:void 0,$e=He?He.valueOf:void 0;function Mf(t){return $e?Object($e.call(t)):{}}var Ye=Mf;function Rf(t,e){var r=e?Y(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Je=Rf;var Lf="[object Boolean]",Ff="[object Date]",Bf="[object Map]",Df="[object Number]",Nf="[object RegExp]",Uf="[object Set]",kf="[object String]",Wf="[object Symbol]",Gf="[object ArrayBuffer]",Kf="[object DataView]",zf="[object Float32Array]",Vf="[object Float64Array]",qf="[object Int8Array]",Hf="[object Int16Array]",$f="[object Int32Array]",Yf="[object Uint8Array]",Jf="[object Uint8ClampedArray]",Xf="[object Uint16Array]",Zf="[object Uint32Array]";function Qf(t,e,r){var o=t.constructor;switch(e){case Gf:return Y(t);case Lf:case Ff:return new o(+t);case Kf:return Ve(t,r);case zf:case Vf:case qf:case Hf:case $f:case Yf:case Jf:case Xf:case Zf:return Je(t,r);case Bf:return new o;case Df:case kf:return new o(t);case Nf:return qe(t);case Uf:return new o;case Wf:return Ye(t)}}var Xe=Qf;function ts(t){return typeof t.constructor=="function"&&!U(t)?Nt(mt(t)):{}}var Ze=ts;var es="[object Map]";function rs(t){return j(t)&&$(t)==es}var Qe=rs;var tr=S&&S.isMap,os=tr?k(tr):Qe,er=os;var as="[object Set]";function fs(t){return j(t)&&$(t)==as}var rr=fs;var or=S&&S.isSet,ss=or?k(or):rr,ar=ss;var is=1,ns=2,ps=4,fr="[object Arguments]",ls="[object Array]",ms="[object Boolean]",us="[object Date]",ds="[object Error]",sr="[object Function]",cs="[object GeneratorFunction]",xs="[object Map]",hs="[object Number]",ir="[object Object]",gs="[object RegExp]",ys="[object Set]",bs="[object String]",vs="[object Symbol]",ws="[object WeakMap]",js="[object ArrayBuffer]",Ts="[object DataView]",As="[object Float32Array]",Os="[object Float64Array]",_s="[object Int8Array]",Ss="[object Int16Array]",Ps="[object Int32Array]",Is="[object Uint8Array]",Cs="[object Uint8ClampedArray]",Es="[object Uint16Array]",Ms="[object Uint32Array]",n={};n[fr]=n[ls]=n[js]=n[Ts]=n[ms]=n[us]=n[As]=n[Os]=n[_s]=n[Ss]=n[Ps]=n[xs]=n[hs]=n[ir]=n[gs]=n[ys]=n[bs]=n[vs]=n[Is]=n[Cs]=n[Es]=n[Ms]=!0;n[ds]=n[sr]=n[ws]=!1;function yt(t,e,r,o,f,i){var s,a=e&is,p=e&ns,m=e&ps;if(r&&(s=f?r(t,o,f,i):r(t)),s!==void 0)return s;if(!T(t))return t;var w=N(t);if(w){if(s=ze(t),!a)return Ut(t,s)}else{var h=$(t),y=h==sr||h==cs;if(it(t))return Me(t,a);if(h==ir||h==fr||y&&!f){if(s=p||y?{}:Ze(t),!a)return p?Be(t,Se(s,t)):Fe(t,_e(s,t))}else{if(!n[h])return f?t:{};s=Xe(t,h,a)}}i||(i=new Oe);var b=i.get(t);if(b)return b;i.set(t,s),ar(t)?t.forEach(function(g){s.add(yt(g,e,r,g,t,i))}):er(t)&&t.forEach(function(g,v){s.set(v,yt(g,e,r,v,t,i))});var c=m?p?Ne:De:p?G:W,L=w?void 0:c(t);return kt(L||t,function(g,v){L&&(v=g,g=t[v]),at(s,v,yt(g,e,r,v,t,i))}),s}var nr=yt;var Rs=1,Ls=4;function Fs(t){return nr(t,Rs|Ls)}var At=Fs;function pr(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(f){f(r)}),(o=t.get("*"))&&o.slice().map(function(f){f(e,r)})}}}var Ot=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var _t=class{constructor(e){F(this,"settings",{devMode:!0,mode:"detect",modeTimeout:300,siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"]});F(this,"events",pr());F(this,"dom",{el:null,iframe:null,stylesheet:null});F(this,"methods",["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","getProjectFiles","getProjectLibrary","setProjectLibrary","uiAlert"]);F(this,"plugins",[]);F(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=Ot();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,f)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:f}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||Ot(),...At(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR","Message compose client->server:",o),this.debug("ERROR","Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("Recieved",r),(r==null?void 0:r.action)=="response"&&this.acceptPostboxes[r.id])r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response);else{if((r==null?void 0:r.action)=="rpc")return Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o.toString()})});if((r==null?void 0:r.action)=="event")return Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o});r!=null&&r.id?this.debug(`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("Unexpected incoming TERA-FY CLIENT message",{message:r})}}createProjectStatePatch(e,r){let o=St(r,e,Pt);return this.debug("INFO","Created project patch",{newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"window":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}detectMode(){return this.settings.mode!="detect"?this.settings.mode:window.self===window.parent?"child":Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>"child")}injectComms(){return new Promise(e=>{switch(this.settings.mode){case"child":this.debug("Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("Embed frame ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("Using TERA site stack parent"),e();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
|
|
2
|
-
`),document.head.appendChild(this.dom.stylesheet);break;case"parent":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){let r="log";typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),!(["INFO","LOG"].includes(r)&&!this.settings.devMode)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r){return typeof e=="string"?this.settings[e]=r:Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r){return!this.settings.devMode||r===void 0?this:this.set(e,r)}use(e,r){if(typeof e!="function")throw new Error("Expected use() call to be provided with a class initalizer");let o=new e(this,r);return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(o=>!["constructor","prototype","name"].includes(o)).filter(o=>o!="init").forEach(o=>{Object.defineProperty(e,o,{value:r[o].bind(e),enumerable:!1})})}toggleDevMode(e="toggle"){return this.settings.devMode=e==="toggle"?!this.settings.devMode:e,this.dom.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}};export{_t as default};
|
|
1
|
+
var mr=Object.defineProperty;var ur=(t,e,r)=>e in t?mr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var F=(t,e,r)=>(ur(t,typeof e!="symbol"?e+"":e,r),r);function St(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(s){return s});function o({obj1:s,obj2:p,basePath:m,basePathForRemoves:w,diffs:h}){var y=Object.keys(s),b=y.length,c=Object.keys(p),L=c.length,g,v=s.length-p.length;if(cr(s,p)){for(var d=0;d<b;d++){var D=Array.isArray(s)?Number(y[d]):y[d];D in p||(g=w.concat(D),h.remove.push({op:"remove",path:r(g)}))}for(var d=0;d<L;d++){var D=Array.isArray(p)?Number(c[d]):c[d];i({key:D,obj1:s,obj2:p,path:m.concat(D),pathForRemoves:m.concat(D),diffs:h})}}else{for(var d=0;d<v;d++)g=w.concat(d),h.remove.push({op:"remove",path:r(g)});for(var lr=s.slice(v),d=0;d<L;d++)i({key:d,obj1:lr,obj2:p,path:m.concat(d),pathForRemoves:m.concat(d+v),diffs:h})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function i({key:s,obj1:p,obj2:m,path:w,pathForRemoves:h,diffs:y}){var b=p[s],c=m[s];if(!(s in p)&&s in m){var L=c;y.add.push({op:"add",path:r(w),value:L})}else b!==c&&(Object(b)!==b||Object(c)!==c||dr(b,c)||!Object.keys(b).length&&!Object.keys(c).length&&String(b)!=String(c)?f(w,y,c):o({obj1:p[s],obj2:m[s],basePath:w,basePathForRemoves:h,diffs:y}))}function f(s,p,m){p.replace.push({op:"replace",path:r(s),value:m})}}function Pt(t){return[""].concat(t).join("/")}function dr(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function cr(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,i=0;i<e.length&&String(t[i])===String(e[i]);i++)o++;for(var f=e.length;f>0&&String(t[f+r])===String(e[f]);f--)a++;return o>=a}return!0}var xr=typeof global=="object"&&global&&global.Object===Object&&global,Z=xr;var hr=typeof self=="object"&&self&&self.Object===Object&&self,gr=Z||hr||Function("return this")(),u=gr;var yr=u.Symbol,A=yr;var It=Object.prototype,br=It.hasOwnProperty,vr=It.toString,J=A?A.toStringTag:void 0;function wr(t){var e=br.call(t,J),r=t[J];try{t[J]=void 0;var o=!0}catch{}var a=vr.call(t);return o&&(e?t[J]=r:delete t[J]),a}var Ct=wr;var jr=Object.prototype,Tr=jr.toString;function Ar(t){return Tr.call(t)}var Et=Ar;var Or="[object Null]",_r="[object Undefined]",Mt=A?A.toStringTag:void 0;function Sr(t){return t==null?t===void 0?_r:Or:Mt&&Mt in Object(t)?Ct(t):Et(t)}var O=Sr;function Pr(t){return t!=null&&typeof t=="object"}var j=Pr;var Ir=Array.isArray,k=Ir;function Cr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var T=Cr;var Er="[object AsyncFunction]",Mr="[object Function]",Rr="[object GeneratorFunction]",Lr="[object Proxy]";function Fr(t){if(!T(t))return!1;var e=O(t);return e==Mr||e==Rr||e==Er||e==Lr}var Q=Fr;var Br=u["__core-js_shared__"],tt=Br;var Rt=function(){var t=/[^.]+$/.exec(tt&&tt.keys&&tt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Dr(t){return!!Rt&&Rt in t}var Lt=Dr;var kr=Function.prototype,Ur=kr.toString;function Nr(t){if(t!=null){try{return Ur.call(t)}catch{}try{return t+""}catch{}}return""}var _=Nr;var Wr=/[\\^$.*+?()[\]{}|]/g,Gr=/^\[object .+?Constructor\]$/,Kr=Function.prototype,zr=Object.prototype,Hr=Kr.toString,Vr=zr.hasOwnProperty,qr=RegExp("^"+Hr.call(Vr).replace(Wr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function $r(t){if(!T(t)||Lt(t))return!1;var e=Q(t)?qr:Gr;return e.test(_(t))}var Ft=$r;function Yr(t,e){return t==null?void 0:t[e]}var Bt=Yr;function Jr(t,e){var r=Bt(t,e);return Ft(r)?r:void 0}var x=Jr;var Xr=x(u,"WeakMap"),et=Xr;var Dt=Object.create,Zr=function(){function t(){}return function(e){if(!T(e))return{};if(Dt)return Dt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),kt=Zr;function Qr(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Ut=Qr;var to=function(){try{var t=x(Object,"defineProperty");return t({},"",{}),t}catch{}}(),bt=to;function eo(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Nt=eo;var ro=9007199254740991,oo=/^(?:0|[1-9]\d*)$/;function ao(t,e){var r=typeof t;return e=e==null?ro:e,!!e&&(r=="number"||r!="symbol"&&oo.test(t))&&t>-1&&t%1==0&&t<e}var Wt=ao;function so(t,e,r){e=="__proto__"&&bt?bt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var rt=so;function fo(t,e){return t===e||t!==t&&e!==e}var ot=fo;var io=Object.prototype,no=io.hasOwnProperty;function po(t,e,r){var o=t[e];(!(no.call(t,e)&&ot(o,r))||r===void 0&&!(e in t))&&rt(t,e,r)}var at=po;function lo(t,e,r,o){var a=!r;r||(r={});for(var i=-1,f=e.length;++i<f;){var s=e[i],p=o?o(r[s],t[s],s,r,t):void 0;p===void 0&&(p=t[s]),a?rt(r,s,p):at(r,s,p)}return r}var I=lo;var mo=9007199254740991;function uo(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=mo}var st=uo;function co(t){return t!=null&&st(t.length)&&!Q(t)}var ft=co;var xo=Object.prototype;function ho(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||xo;return t===r}var U=ho;function go(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Gt=go;var yo="[object Arguments]";function bo(t){return j(t)&&O(t)==yo}var vt=bo;var Kt=Object.prototype,vo=Kt.hasOwnProperty,wo=Kt.propertyIsEnumerable,jo=vt(function(){return arguments}())?vt:function(t){return j(t)&&vo.call(t,"callee")&&!wo.call(t,"callee")},zt=jo;function To(){return!1}var Ht=To;var $t=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vt=$t&&typeof module=="object"&&module&&!module.nodeType&&module,Ao=Vt&&Vt.exports===$t,qt=Ao?u.Buffer:void 0,Oo=qt?qt.isBuffer:void 0,_o=Oo||Ht,it=_o;var So="[object Arguments]",Po="[object Array]",Io="[object Boolean]",Co="[object Date]",Eo="[object Error]",Mo="[object Function]",Ro="[object Map]",Lo="[object Number]",Fo="[object Object]",Bo="[object RegExp]",Do="[object Set]",ko="[object String]",Uo="[object WeakMap]",No="[object ArrayBuffer]",Wo="[object DataView]",Go="[object Float32Array]",Ko="[object Float64Array]",zo="[object Int8Array]",Ho="[object Int16Array]",Vo="[object Int32Array]",qo="[object Uint8Array]",$o="[object Uint8ClampedArray]",Yo="[object Uint16Array]",Jo="[object Uint32Array]",l={};l[Go]=l[Ko]=l[zo]=l[Ho]=l[Vo]=l[qo]=l[$o]=l[Yo]=l[Jo]=!0;l[So]=l[Po]=l[No]=l[Io]=l[Wo]=l[Co]=l[Eo]=l[Mo]=l[Ro]=l[Lo]=l[Fo]=l[Bo]=l[Do]=l[ko]=l[Uo]=!1;function Xo(t){return j(t)&&st(t.length)&&!!l[O(t)]}var Yt=Xo;function Zo(t){return function(e){return t(e)}}var N=Zo;var Jt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,X=Jt&&typeof module=="object"&&module&&!module.nodeType&&module,Qo=X&&X.exports===Jt,wt=Qo&&Z.process,ta=function(){try{var t=X&&X.require&&X.require("util").types;return t||wt&&wt.binding&&wt.binding("util")}catch{}}(),S=ta;var Xt=S&&S.isTypedArray,ea=Xt?N(Xt):Yt,Zt=ea;var ra=Object.prototype,oa=ra.hasOwnProperty;function aa(t,e){var r=k(t),o=!r&&zt(t),a=!r&&!o&&it(t),i=!r&&!o&&!a&&Zt(t),f=r||o||a||i,s=f?Gt(t.length,String):[],p=s.length;for(var m in t)(e||oa.call(t,m))&&!(f&&(m=="length"||a&&(m=="offset"||m=="parent")||i&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||Wt(m,p)))&&s.push(m);return s}var nt=aa;function sa(t,e){return function(r){return t(e(r))}}var pt=sa;var fa=pt(Object.keys,Object),Qt=fa;var ia=Object.prototype,na=ia.hasOwnProperty;function pa(t){if(!U(t))return Qt(t);var e=[];for(var r in Object(t))na.call(t,r)&&r!="constructor"&&e.push(r);return e}var te=pa;function la(t){return ft(t)?nt(t):te(t)}var W=la;function ma(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var ee=ma;var ua=Object.prototype,da=ua.hasOwnProperty;function ca(t){if(!T(t))return ee(t);var e=U(t),r=[];for(var o in t)o=="constructor"&&(e||!da.call(t,o))||r.push(o);return r}var re=ca;function xa(t){return ft(t)?nt(t,!0):re(t)}var G=xa;var ha=x(Object,"create"),P=ha;function ga(){this.__data__=P?P(null):{},this.size=0}var oe=ga;function ya(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var ae=ya;var ba="__lodash_hash_undefined__",va=Object.prototype,wa=va.hasOwnProperty;function ja(t){var e=this.__data__;if(P){var r=e[t];return r===ba?void 0:r}return wa.call(e,t)?e[t]:void 0}var se=ja;var Ta=Object.prototype,Aa=Ta.hasOwnProperty;function Oa(t){var e=this.__data__;return P?e[t]!==void 0:Aa.call(e,t)}var fe=Oa;var _a="__lodash_hash_undefined__";function Sa(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=P&&e===void 0?_a:e,this}var ie=Sa;function K(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}K.prototype.clear=oe;K.prototype.delete=ae;K.prototype.get=se;K.prototype.has=fe;K.prototype.set=ie;var jt=K;function Pa(){this.__data__=[],this.size=0}var ne=Pa;function Ia(t,e){for(var r=t.length;r--;)if(ot(t[r][0],e))return r;return-1}var C=Ia;var Ca=Array.prototype,Ea=Ca.splice;function Ma(t){var e=this.__data__,r=C(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Ea.call(e,r,1),--this.size,!0}var pe=Ma;function Ra(t){var e=this.__data__,r=C(e,t);return r<0?void 0:e[r][1]}var le=Ra;function La(t){return C(this.__data__,t)>-1}var me=La;function Fa(t,e){var r=this.__data__,o=C(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var ue=Fa;function z(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}z.prototype.clear=ne;z.prototype.delete=pe;z.prototype.get=le;z.prototype.has=me;z.prototype.set=ue;var E=z;var Ba=x(u,"Map"),M=Ba;function Da(){this.size=0,this.__data__={hash:new jt,map:new(M||E),string:new jt}}var de=Da;function ka(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var ce=ka;function Ua(t,e){var r=t.__data__;return ce(e)?r[typeof e=="string"?"string":"hash"]:r.map}var R=Ua;function Na(t){var e=R(this,t).delete(t);return this.size-=e?1:0,e}var xe=Na;function Wa(t){return R(this,t).get(t)}var he=Wa;function Ga(t){return R(this,t).has(t)}var ge=Ga;function Ka(t,e){var r=R(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var ye=Ka;function H(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}H.prototype.clear=de;H.prototype.delete=xe;H.prototype.get=he;H.prototype.has=ge;H.prototype.set=ye;var be=H;function za(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var lt=za;var Ha=pt(Object.getPrototypeOf,Object),mt=Ha;function Va(){this.__data__=new E,this.size=0}var ve=Va;function qa(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var we=qa;function $a(t){return this.__data__.get(t)}var je=$a;function Ya(t){return this.__data__.has(t)}var Te=Ya;var Ja=200;function Xa(t,e){var r=this.__data__;if(r instanceof E){var o=r.__data__;if(!M||o.length<Ja-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new be(o)}return r.set(t,e),this.size=r.size,this}var Ae=Xa;function V(t){var e=this.__data__=new E(t);this.size=e.size}V.prototype.clear=ve;V.prototype.delete=we;V.prototype.get=je;V.prototype.has=Te;V.prototype.set=Ae;var Oe=V;function Za(t,e){return t&&I(e,W(e),t)}var _e=Za;function Qa(t,e){return t&&I(e,G(e),t)}var Se=Qa;var Ee=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Pe=Ee&&typeof module=="object"&&module&&!module.nodeType&&module,ts=Pe&&Pe.exports===Ee,Ie=ts?u.Buffer:void 0,Ce=Ie?Ie.allocUnsafe:void 0;function es(t,e){if(e)return t.slice();var r=t.length,o=Ce?Ce(r):new t.constructor(r);return t.copy(o),o}var Me=es;function rs(t,e){for(var r=-1,o=t==null?0:t.length,a=0,i=[];++r<o;){var f=t[r];e(f,r,t)&&(i[a++]=f)}return i}var Re=rs;function os(){return[]}var ut=os;var as=Object.prototype,ss=as.propertyIsEnumerable,Le=Object.getOwnPropertySymbols,fs=Le?function(t){return t==null?[]:(t=Object(t),Re(Le(t),function(e){return ss.call(t,e)}))}:ut,q=fs;function is(t,e){return I(t,q(t),e)}var Fe=is;var ns=Object.getOwnPropertySymbols,ps=ns?function(t){for(var e=[];t;)lt(e,q(t)),t=mt(t);return e}:ut,dt=ps;function ls(t,e){return I(t,dt(t),e)}var Be=ls;function ms(t,e,r){var o=e(t);return k(t)?o:lt(o,r(t))}var ct=ms;function us(t){return ct(t,W,q)}var De=us;function ds(t){return ct(t,G,dt)}var ke=ds;var cs=x(u,"DataView"),xt=cs;var xs=x(u,"Promise"),ht=xs;var hs=x(u,"Set"),gt=hs;var Ue="[object Map]",gs="[object Object]",Ne="[object Promise]",We="[object Set]",Ge="[object WeakMap]",Ke="[object DataView]",ys=_(xt),bs=_(M),vs=_(ht),ws=_(gt),js=_(et),B=O;(xt&&B(new xt(new ArrayBuffer(1)))!=Ke||M&&B(new M)!=Ue||ht&&B(ht.resolve())!=Ne||gt&&B(new gt)!=We||et&&B(new et)!=Ge)&&(B=function(t){var e=O(t),r=e==gs?t.constructor:void 0,o=r?_(r):"";if(o)switch(o){case ys:return Ke;case bs:return Ue;case vs:return Ne;case ws:return We;case js:return Ge}return e});var $=B;var Ts=Object.prototype,As=Ts.hasOwnProperty;function Os(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&As.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var ze=Os;var _s=u.Uint8Array,Tt=_s;function Ss(t){var e=new t.constructor(t.byteLength);return new Tt(e).set(new Tt(t)),e}var Y=Ss;function Ps(t,e){var r=e?Y(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var He=Ps;var Is=/\w*$/;function Cs(t){var e=new t.constructor(t.source,Is.exec(t));return e.lastIndex=t.lastIndex,e}var Ve=Cs;var qe=A?A.prototype:void 0,$e=qe?qe.valueOf:void 0;function Es(t){return $e?Object($e.call(t)):{}}var Ye=Es;function Ms(t,e){var r=e?Y(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Je=Ms;var Rs="[object Boolean]",Ls="[object Date]",Fs="[object Map]",Bs="[object Number]",Ds="[object RegExp]",ks="[object Set]",Us="[object String]",Ns="[object Symbol]",Ws="[object ArrayBuffer]",Gs="[object DataView]",Ks="[object Float32Array]",zs="[object Float64Array]",Hs="[object Int8Array]",Vs="[object Int16Array]",qs="[object Int32Array]",$s="[object Uint8Array]",Ys="[object Uint8ClampedArray]",Js="[object Uint16Array]",Xs="[object Uint32Array]";function Zs(t,e,r){var o=t.constructor;switch(e){case Ws:return Y(t);case Rs:case Ls:return new o(+t);case Gs:return He(t,r);case Ks:case zs:case Hs:case Vs:case qs:case $s:case Ys:case Js:case Xs:return Je(t,r);case Fs:return new o;case Bs:case Us:return new o(t);case Ds:return Ve(t);case ks:return new o;case Ns:return Ye(t)}}var Xe=Zs;function Qs(t){return typeof t.constructor=="function"&&!U(t)?kt(mt(t)):{}}var Ze=Qs;var tf="[object Map]";function ef(t){return j(t)&&$(t)==tf}var Qe=ef;var tr=S&&S.isMap,rf=tr?N(tr):Qe,er=rf;var of="[object Set]";function af(t){return j(t)&&$(t)==of}var rr=af;var or=S&&S.isSet,sf=or?N(or):rr,ar=sf;var ff=1,nf=2,pf=4,sr="[object Arguments]",lf="[object Array]",mf="[object Boolean]",uf="[object Date]",df="[object Error]",fr="[object Function]",cf="[object GeneratorFunction]",xf="[object Map]",hf="[object Number]",ir="[object Object]",gf="[object RegExp]",yf="[object Set]",bf="[object String]",vf="[object Symbol]",wf="[object WeakMap]",jf="[object ArrayBuffer]",Tf="[object DataView]",Af="[object Float32Array]",Of="[object Float64Array]",_f="[object Int8Array]",Sf="[object Int16Array]",Pf="[object Int32Array]",If="[object Uint8Array]",Cf="[object Uint8ClampedArray]",Ef="[object Uint16Array]",Mf="[object Uint32Array]",n={};n[sr]=n[lf]=n[jf]=n[Tf]=n[mf]=n[uf]=n[Af]=n[Of]=n[_f]=n[Sf]=n[Pf]=n[xf]=n[hf]=n[ir]=n[gf]=n[yf]=n[bf]=n[vf]=n[If]=n[Cf]=n[Ef]=n[Mf]=!0;n[df]=n[fr]=n[wf]=!1;function yt(t,e,r,o,a,i){var f,s=e&ff,p=e&nf,m=e&pf;if(r&&(f=a?r(t,o,a,i):r(t)),f!==void 0)return f;if(!T(t))return t;var w=k(t);if(w){if(f=ze(t),!s)return Ut(t,f)}else{var h=$(t),y=h==fr||h==cf;if(it(t))return Me(t,s);if(h==ir||h==sr||y&&!a){if(f=p||y?{}:Ze(t),!s)return p?Be(t,Se(f,t)):Fe(t,_e(f,t))}else{if(!n[h])return a?t:{};f=Xe(t,h,s)}}i||(i=new Oe);var b=i.get(t);if(b)return b;i.set(t,f),ar(t)?t.forEach(function(g){f.add(yt(g,e,r,g,t,i))}):er(t)&&t.forEach(function(g,v){f.set(v,yt(g,e,r,v,t,i))});var c=m?p?ke:De:p?G:W,L=w?void 0:c(t);return Nt(L||t,function(g,v){L&&(v=g,g=t[v]),at(f,v,yt(g,e,r,v,t,i))}),f}var nr=yt;var Rf=1,Lf=4;function Ff(t){return nr(t,Rf|Lf)}var At=Ff;function pr(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var Ot=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var _t=class{constructor(e){F(this,"settings",{devMode:!0,mode:"detect",modeTimeout:300,modeFallback:"child",siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3});F(this,"events",pr());F(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});F(this,"methods",["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","selectProjectFile","getProjectFiles","selectProjectLibrary","parseProjectLibrary","setProjectLibrary","uiAlert","uiSplat","uiWindow"]);F(this,"plugins",[]);F(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=Ot();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||Ot(),...At(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR","Message compose client->server:",o),this.debug("ERROR","Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("Recieved",r),(r==null?void 0:r.action)=="response"&&this.acceptPostboxes[r.id])r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response);else{if((r==null?void 0:r.action)=="rpc")return Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o.toString()})});if((r==null?void 0:r.action)=="event")return Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o});r!=null&&r.id?this.debug(`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("Unexpected incoming TERA-FY CLIENT message",{message:r})}}createProjectStatePatch(e,r){let o=St(r,e,Pt);return this.debug("INFO","Created project patch",{newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}detectMode(){return this.settings.mode!="detect"?this.settings.mode:window.self===window.parent?this.settings.modeFallback:Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){return new Promise(e=>{switch(this.settings.mode){case"child":this.debug("Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("Embed frame ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("Using TERA window parent"),e();break;case"popup":this.debug("Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),(()=>{let r=0,o,a=()=>{this.debug("Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("Popup window accepted handshake"),e()})};a()})();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
|
|
2
|
+
`),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){let r="log";typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),!(["INFO","LOG"].includes(r)&&!this.settings.devMode)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r){return typeof e=="string"?this.settings[e]=r:Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r){return!this.settings.devMode||r===void 0?this:this.set(e,r)}use(e,r){if(typeof e!="function")throw new Error("Expected use() call to be provided with a class initalizer");let o=new e(this,r);return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(o=>!["constructor","prototype","name"].includes(o)).filter(o=>o!="init").forEach(o=>{Object.defineProperty(e,o,{value:r[o].bind(e),enumerable:!1})})}toggleDevMode(e="toggle"){return this.settings.devMode=e==="toggle"?!this.settings.devMode:e,this.dom.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}};export{_t as default};
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
lodash-es/lodash.js:
|
|
@@ -13,4 +13,3 @@ lodash-es/lodash.js:
|
|
|
13
13
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
14
14
|
*)
|
|
15
15
|
*/
|
|
16
|
-
//# sourceMappingURL=terafy.es2019.js.map
|
package/dist/terafy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function _t(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(a){return a});function o({obj1:a,obj2:p,basePath:m,basePathForRemoves:w,diffs:h}){var y=Object.keys(a),b=y.length,c=Object.keys(p),L=c.length,g,v=a.length-p.length;if(mr(a,p)){for(var d=0;d<b;d++){var B=Array.isArray(a)?Number(y[d]):y[d];B in p||(g=w.concat(B),h.remove.push({op:"remove",path:r(g)}))}for(var d=0;d<L;d++){var B=Array.isArray(p)?Number(c[d]):c[d];i({key:B,obj1:a,obj2:p,path:m.concat(B),pathForRemoves:m.concat(B),diffs:h})}}else{for(var d=0;d<v;d++)g=w.concat(d),h.remove.push({op:"remove",path:r(g)});for(var pr=a.slice(v),d=0;d<L;d++)i({key:d,obj1:pr,obj2:p,path:m.concat(d),pathForRemoves:m.concat(d+v),diffs:h})}}var f={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:f}),f.remove.reverse().concat(f.replace).concat(f.add);function i({key:a,obj1:p,obj2:m,path:w,pathForRemoves:h,diffs:y}){var b=p[a],c=m[a];if(!(a in p)&&a in m){var L=c;y.add.push({op:"add",path:r(w),value:L})}else b!==c&&(Object(b)!==b||Object(c)!==c||lr(b,c)||!Object.keys(b).length&&!Object.keys(c).length&&String(b)!=String(c)?s(w,y,c):o({obj1:p[a],obj2:m[a],basePath:w,basePathForRemoves:h,diffs:y}))}function s(a,p,m){p.replace.push({op:"replace",path:r(a),value:m})}}function St(t){return[""].concat(t).join("/")}function lr(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function mr(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,f=0,i=0;i<e.length&&String(t[i])===String(e[i]);i++)o++;for(var s=e.length;s>0&&String(t[s+r])===String(e[s]);s--)f++;return o>=f}return!0}var ur=typeof global=="object"&&global&&global.Object===Object&&global,X=ur;var dr=typeof self=="object"&&self&&self.Object===Object&&self,cr=X||dr||Function("return this")(),u=cr;var xr=u.Symbol,A=xr;var Pt=Object.prototype,hr=Pt.hasOwnProperty,gr=Pt.toString,Y=A?A.toStringTag:void 0;function yr(t){var e=hr.call(t,Y),r=t[Y];try{t[Y]=void 0;var o=!0}catch{}var f=gr.call(t);return o&&(e?t[Y]=r:delete t[Y]),f}var It=yr;var br=Object.prototype,vr=br.toString;function wr(t){return vr.call(t)}var Ct=wr;var jr="[object Null]",Tr="[object Undefined]",Et=A?A.toStringTag:void 0;function Ar(t){return t==null?t===void 0?Tr:jr:Et&&Et in Object(t)?It(t):Ct(t)}var O=Ar;function Or(t){return t!=null&&typeof t=="object"}var j=Or;var _r=Array.isArray,D=_r;function Sr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var T=Sr;var Pr="[object AsyncFunction]",Ir="[object Function]",Cr="[object GeneratorFunction]",Er="[object Proxy]";function Mr(t){if(!T(t))return!1;var e=O(t);return e==Ir||e==Cr||e==Pr||e==Er}var Z=Mr;var Rr=u["__core-js_shared__"],Q=Rr;var Mt=function(){var t=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Lr(t){return!!Mt&&Mt in t}var Rt=Lr;var Fr=Function.prototype,Br=Fr.toString;function Dr(t){if(t!=null){try{return Br.call(t)}catch{}try{return t+""}catch{}}return""}var _=Dr;var Nr=/[\\^$.*+?()[\]{}|]/g,Ur=/^\[object .+?Constructor\]$/,kr=Function.prototype,Wr=Object.prototype,Gr=kr.toString,Kr=Wr.hasOwnProperty,zr=RegExp("^"+Gr.call(Kr).replace(Nr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Vr(t){if(!T(t)||Rt(t))return!1;var e=Z(t)?zr:Ur;return e.test(_(t))}var Lt=Vr;function qr(t,e){return t?.[e]}var Ft=qr;function Hr(t,e){var r=Ft(t,e);return Lt(r)?r:void 0}var x=Hr;var $r=x(u,"WeakMap"),tt=$r;var Bt=Object.create,Yr=function(){function t(){}return function(e){if(!T(e))return{};if(Bt)return Bt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Dt=Yr;function Jr(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Nt=Jr;var Xr=function(){try{var t=x(Object,"defineProperty");return t({},"",{}),t}catch{}}(),yt=Xr;function Zr(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Ut=Zr;var Qr=9007199254740991,to=/^(?:0|[1-9]\d*)$/;function eo(t,e){var r=typeof t;return e=e??Qr,!!e&&(r=="number"||r!="symbol"&&to.test(t))&&t>-1&&t%1==0&&t<e}var kt=eo;function ro(t,e,r){e=="__proto__"&&yt?yt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var et=ro;function oo(t,e){return t===e||t!==t&&e!==e}var rt=oo;var ao=Object.prototype,fo=ao.hasOwnProperty;function so(t,e,r){var o=t[e];(!(fo.call(t,e)&&rt(o,r))||r===void 0&&!(e in t))&&et(t,e,r)}var ot=so;function io(t,e,r,o){var f=!r;r||(r={});for(var i=-1,s=e.length;++i<s;){var a=e[i],p=o?o(r[a],t[a],a,r,t):void 0;p===void 0&&(p=t[a]),f?et(r,a,p):ot(r,a,p)}return r}var I=io;var no=9007199254740991;function po(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=no}var at=po;function lo(t){return t!=null&&at(t.length)&&!Z(t)}var ft=lo;var mo=Object.prototype;function uo(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||mo;return t===r}var N=uo;function co(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Wt=co;var xo="[object Arguments]";function ho(t){return j(t)&&O(t)==xo}var bt=ho;var Gt=Object.prototype,go=Gt.hasOwnProperty,yo=Gt.propertyIsEnumerable,bo=bt(function(){return arguments}())?bt:function(t){return j(t)&&go.call(t,"callee")&&!yo.call(t,"callee")},Kt=bo;function vo(){return!1}var zt=vo;var Ht=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vt=Ht&&typeof module=="object"&&module&&!module.nodeType&&module,wo=Vt&&Vt.exports===Ht,qt=wo?u.Buffer:void 0,jo=qt?qt.isBuffer:void 0,To=jo||zt,st=To;var Ao="[object Arguments]",Oo="[object Array]",_o="[object Boolean]",So="[object Date]",Po="[object Error]",Io="[object Function]",Co="[object Map]",Eo="[object Number]",Mo="[object Object]",Ro="[object RegExp]",Lo="[object Set]",Fo="[object String]",Bo="[object WeakMap]",Do="[object ArrayBuffer]",No="[object DataView]",Uo="[object Float32Array]",ko="[object Float64Array]",Wo="[object Int8Array]",Go="[object Int16Array]",Ko="[object Int32Array]",zo="[object Uint8Array]",Vo="[object Uint8ClampedArray]",qo="[object Uint16Array]",Ho="[object Uint32Array]",l={};l[Uo]=l[ko]=l[Wo]=l[Go]=l[Ko]=l[zo]=l[Vo]=l[qo]=l[Ho]=!0;l[Ao]=l[Oo]=l[Do]=l[_o]=l[No]=l[So]=l[Po]=l[Io]=l[Co]=l[Eo]=l[Mo]=l[Ro]=l[Lo]=l[Fo]=l[Bo]=!1;function $o(t){return j(t)&&at(t.length)&&!!l[O(t)]}var $t=$o;function Yo(t){return function(e){return t(e)}}var U=Yo;var Yt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,J=Yt&&typeof module=="object"&&module&&!module.nodeType&&module,Jo=J&&J.exports===Yt,vt=Jo&&X.process,Xo=function(){try{var t=J&&J.require&&J.require("util").types;return t||vt&&vt.binding&&vt.binding("util")}catch{}}(),S=Xo;var Jt=S&&S.isTypedArray,Zo=Jt?U(Jt):$t,Xt=Zo;var Qo=Object.prototype,ta=Qo.hasOwnProperty;function ea(t,e){var r=D(t),o=!r&&Kt(t),f=!r&&!o&&st(t),i=!r&&!o&&!f&&Xt(t),s=r||o||f||i,a=s?Wt(t.length,String):[],p=a.length;for(var m in t)(e||ta.call(t,m))&&!(s&&(m=="length"||f&&(m=="offset"||m=="parent")||i&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||kt(m,p)))&&a.push(m);return a}var it=ea;function ra(t,e){return function(r){return t(e(r))}}var nt=ra;var oa=nt(Object.keys,Object),Zt=oa;var aa=Object.prototype,fa=aa.hasOwnProperty;function sa(t){if(!N(t))return Zt(t);var e=[];for(var r in Object(t))fa.call(t,r)&&r!="constructor"&&e.push(r);return e}var Qt=sa;function ia(t){return ft(t)?it(t):Qt(t)}var k=ia;function na(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var te=na;var pa=Object.prototype,la=pa.hasOwnProperty;function ma(t){if(!T(t))return te(t);var e=N(t),r=[];for(var o in t)o=="constructor"&&(e||!la.call(t,o))||r.push(o);return r}var ee=ma;function ua(t){return ft(t)?it(t,!0):ee(t)}var W=ua;var da=x(Object,"create"),P=da;function ca(){this.__data__=P?P(null):{},this.size=0}var re=ca;function xa(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var oe=xa;var ha="__lodash_hash_undefined__",ga=Object.prototype,ya=ga.hasOwnProperty;function ba(t){var e=this.__data__;if(P){var r=e[t];return r===ha?void 0:r}return ya.call(e,t)?e[t]:void 0}var ae=ba;var va=Object.prototype,wa=va.hasOwnProperty;function ja(t){var e=this.__data__;return P?e[t]!==void 0:wa.call(e,t)}var fe=ja;var Ta="__lodash_hash_undefined__";function Aa(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=P&&e===void 0?Ta:e,this}var se=Aa;function G(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}G.prototype.clear=re;G.prototype.delete=oe;G.prototype.get=ae;G.prototype.has=fe;G.prototype.set=se;var wt=G;function Oa(){this.__data__=[],this.size=0}var ie=Oa;function _a(t,e){for(var r=t.length;r--;)if(rt(t[r][0],e))return r;return-1}var C=_a;var Sa=Array.prototype,Pa=Sa.splice;function Ia(t){var e=this.__data__,r=C(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Pa.call(e,r,1),--this.size,!0}var ne=Ia;function Ca(t){var e=this.__data__,r=C(e,t);return r<0?void 0:e[r][1]}var pe=Ca;function Ea(t){return C(this.__data__,t)>-1}var le=Ea;function Ma(t,e){var r=this.__data__,o=C(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var me=Ma;function K(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}K.prototype.clear=ie;K.prototype.delete=ne;K.prototype.get=pe;K.prototype.has=le;K.prototype.set=me;var E=K;var Ra=x(u,"Map"),M=Ra;function La(){this.size=0,this.__data__={hash:new wt,map:new(M||E),string:new wt}}var ue=La;function Fa(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var de=Fa;function Ba(t,e){var r=t.__data__;return de(e)?r[typeof e=="string"?"string":"hash"]:r.map}var R=Ba;function Da(t){var e=R(this,t).delete(t);return this.size-=e?1:0,e}var ce=Da;function Na(t){return R(this,t).get(t)}var xe=Na;function Ua(t){return R(this,t).has(t)}var he=Ua;function ka(t,e){var r=R(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var ge=ka;function z(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}z.prototype.clear=ue;z.prototype.delete=ce;z.prototype.get=xe;z.prototype.has=he;z.prototype.set=ge;var ye=z;function Wa(t,e){for(var r=-1,o=e.length,f=t.length;++r<o;)t[f+r]=e[r];return t}var pt=Wa;var Ga=nt(Object.getPrototypeOf,Object),lt=Ga;function Ka(){this.__data__=new E,this.size=0}var be=Ka;function za(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ve=za;function Va(t){return this.__data__.get(t)}var we=Va;function qa(t){return this.__data__.has(t)}var je=qa;var Ha=200;function $a(t,e){var r=this.__data__;if(r instanceof E){var o=r.__data__;if(!M||o.length<Ha-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new ye(o)}return r.set(t,e),this.size=r.size,this}var Te=$a;function V(t){var e=this.__data__=new E(t);this.size=e.size}V.prototype.clear=be;V.prototype.delete=ve;V.prototype.get=we;V.prototype.has=je;V.prototype.set=Te;var Ae=V;function Ya(t,e){return t&&I(e,k(e),t)}var Oe=Ya;function Ja(t,e){return t&&I(e,W(e),t)}var _e=Ja;var Ce=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Se=Ce&&typeof module=="object"&&module&&!module.nodeType&&module,Xa=Se&&Se.exports===Ce,Pe=Xa?u.Buffer:void 0,Ie=Pe?Pe.allocUnsafe:void 0;function Za(t,e){if(e)return t.slice();var r=t.length,o=Ie?Ie(r):new t.constructor(r);return t.copy(o),o}var Ee=Za;function Qa(t,e){for(var r=-1,o=t==null?0:t.length,f=0,i=[];++r<o;){var s=t[r];e(s,r,t)&&(i[f++]=s)}return i}var Me=Qa;function tf(){return[]}var mt=tf;var ef=Object.prototype,rf=ef.propertyIsEnumerable,Re=Object.getOwnPropertySymbols,of=Re?function(t){return t==null?[]:(t=Object(t),Me(Re(t),function(e){return rf.call(t,e)}))}:mt,q=of;function af(t,e){return I(t,q(t),e)}var Le=af;var ff=Object.getOwnPropertySymbols,sf=ff?function(t){for(var e=[];t;)pt(e,q(t)),t=lt(t);return e}:mt,ut=sf;function nf(t,e){return I(t,ut(t),e)}var Fe=nf;function pf(t,e,r){var o=e(t);return D(t)?o:pt(o,r(t))}var dt=pf;function lf(t){return dt(t,k,q)}var Be=lf;function mf(t){return dt(t,W,ut)}var De=mf;var uf=x(u,"DataView"),ct=uf;var df=x(u,"Promise"),xt=df;var cf=x(u,"Set"),ht=cf;var Ne="[object Map]",xf="[object Object]",Ue="[object Promise]",ke="[object Set]",We="[object WeakMap]",Ge="[object DataView]",hf=_(ct),gf=_(M),yf=_(xt),bf=_(ht),vf=_(tt),F=O;(ct&&F(new ct(new ArrayBuffer(1)))!=Ge||M&&F(new M)!=Ne||xt&&F(xt.resolve())!=Ue||ht&&F(new ht)!=ke||tt&&F(new tt)!=We)&&(F=function(t){var e=O(t),r=e==xf?t.constructor:void 0,o=r?_(r):"";if(o)switch(o){case hf:return Ge;case gf:return Ne;case yf:return Ue;case bf:return ke;case vf:return We}return e});var H=F;var wf=Object.prototype,jf=wf.hasOwnProperty;function Tf(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&jf.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Ke=Tf;var Af=u.Uint8Array,jt=Af;function Of(t){var e=new t.constructor(t.byteLength);return new jt(e).set(new jt(t)),e}var $=Of;function _f(t,e){var r=e?$(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var ze=_f;var Sf=/\w*$/;function Pf(t){var e=new t.constructor(t.source,Sf.exec(t));return e.lastIndex=t.lastIndex,e}var Ve=Pf;var qe=A?A.prototype:void 0,He=qe?qe.valueOf:void 0;function If(t){return He?Object(He.call(t)):{}}var $e=If;function Cf(t,e){var r=e?$(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Ye=Cf;var Ef="[object Boolean]",Mf="[object Date]",Rf="[object Map]",Lf="[object Number]",Ff="[object RegExp]",Bf="[object Set]",Df="[object String]",Nf="[object Symbol]",Uf="[object ArrayBuffer]",kf="[object DataView]",Wf="[object Float32Array]",Gf="[object Float64Array]",Kf="[object Int8Array]",zf="[object Int16Array]",Vf="[object Int32Array]",qf="[object Uint8Array]",Hf="[object Uint8ClampedArray]",$f="[object Uint16Array]",Yf="[object Uint32Array]";function Jf(t,e,r){var o=t.constructor;switch(e){case Uf:return $(t);case Ef:case Mf:return new o(+t);case kf:return ze(t,r);case Wf:case Gf:case Kf:case zf:case Vf:case qf:case Hf:case $f:case Yf:return Ye(t,r);case Rf:return new o;case Lf:case Df:return new o(t);case Ff:return Ve(t);case Bf:return new o;case Nf:return $e(t)}}var Je=Jf;function Xf(t){return typeof t.constructor=="function"&&!N(t)?Dt(lt(t)):{}}var Xe=Xf;var Zf="[object Map]";function Qf(t){return j(t)&&H(t)==Zf}var Ze=Qf;var Qe=S&&S.isMap,ts=Qe?U(Qe):Ze,tr=ts;var es="[object Set]";function rs(t){return j(t)&&H(t)==es}var er=rs;var rr=S&&S.isSet,os=rr?U(rr):er,or=os;var as=1,fs=2,ss=4,ar="[object Arguments]",is="[object Array]",ns="[object Boolean]",ps="[object Date]",ls="[object Error]",fr="[object Function]",ms="[object GeneratorFunction]",us="[object Map]",ds="[object Number]",sr="[object Object]",cs="[object RegExp]",xs="[object Set]",hs="[object String]",gs="[object Symbol]",ys="[object WeakMap]",bs="[object ArrayBuffer]",vs="[object DataView]",ws="[object Float32Array]",js="[object Float64Array]",Ts="[object Int8Array]",As="[object Int16Array]",Os="[object Int32Array]",_s="[object Uint8Array]",Ss="[object Uint8ClampedArray]",Ps="[object Uint16Array]",Is="[object Uint32Array]",n={};n[ar]=n[is]=n[bs]=n[vs]=n[ns]=n[ps]=n[ws]=n[js]=n[Ts]=n[As]=n[Os]=n[us]=n[ds]=n[sr]=n[cs]=n[xs]=n[hs]=n[gs]=n[_s]=n[Ss]=n[Ps]=n[Is]=!0;n[ls]=n[fr]=n[ys]=!1;function gt(t,e,r,o,f,i){var s,a=e&as,p=e&fs,m=e&ss;if(r&&(s=f?r(t,o,f,i):r(t)),s!==void 0)return s;if(!T(t))return t;var w=D(t);if(w){if(s=Ke(t),!a)return Nt(t,s)}else{var h=H(t),y=h==fr||h==ms;if(st(t))return Ee(t,a);if(h==sr||h==ar||y&&!f){if(s=p||y?{}:Xe(t),!a)return p?Fe(t,_e(s,t)):Le(t,Oe(s,t))}else{if(!n[h])return f?t:{};s=Je(t,h,a)}}i||(i=new Ae);var b=i.get(t);if(b)return b;i.set(t,s),or(t)?t.forEach(function(g){s.add(gt(g,e,r,g,t,i))}):tr(t)&&t.forEach(function(g,v){s.set(v,gt(g,e,r,v,t,i))});var c=m?p?De:Be:p?W:k,L=w?void 0:c(t);return Ut(L||t,function(g,v){L&&(v=g,g=t[v]),ot(s,v,gt(g,e,r,v,t,i))}),s}var ir=gt;var Cs=1,Es=4;function Ms(t){return ir(t,Cs|Es)}var Tt=Ms;function nr(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(f){f(r)}),(o=t.get("*"))&&o.slice().map(function(f){f(e,r)})}}}var At=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var Ot=class{settings={devMode:!0,mode:"detect",modeTimeout:300,siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"]};events=nr();dom={el:null,iframe:null,stylesheet:null};methods=["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","getProjectFiles","getProjectLibrary","setProjectLibrary","uiAlert"];plugins=[];send(e){let r=At();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,f)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:f}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||At(),...Tt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR","Message compose client->server:",o),this.debug("ERROR","Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("Recieved",r),r?.action=="response"&&this.acceptPostboxes[r.id])r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response);else{if(r?.action=="rpc")return Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o.toString()})});if(r?.action=="event")return Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o});r?.id?this.debug(`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("Unexpected incoming TERA-FY CLIENT message",{message:r})}}acceptPostboxes={};createProjectStatePatch(e,r){let o=_t(r,e,St);return this.debug("INFO","Created project patch",{newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}constructor(e){e&&this.set(e)}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"window":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}detectMode(){return this.settings.mode!="detect"?this.settings.mode:window.self===window.parent?"child":Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>"child")}injectComms(){return new Promise(e=>{switch(this.settings.mode){case"child":this.debug("Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("Embed frame ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("Using TERA site stack parent"),e();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
|
|
2
|
-
`),document.head.appendChild(this.dom.stylesheet);break;case"parent":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){let r="log";typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),!(["INFO","LOG"].includes(r)&&!this.settings.devMode)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r){return typeof e=="string"?this.settings[e]=r:Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r){return!this.settings.devMode||r===void 0?this:this.set(e,r)}use(e,r){if(typeof e!="function")throw new Error("Expected use() call to be provided with a class initalizer");let o=new e(this,r);return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(o=>!["constructor","prototype","name"].includes(o)).filter(o=>o!="init").forEach(o=>{Object.defineProperty(e,o,{value:r[o].bind(e),enumerable:!1})})}toggleDevMode(e="toggle"){return this.settings.devMode=e==="toggle"?!this.settings.devMode:e,this.dom.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}};export{Ot as default};
|
|
1
|
+
function _t(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(s){return s});function o({obj1:s,obj2:p,basePath:m,basePathForRemoves:w,diffs:h}){var y=Object.keys(s),b=y.length,c=Object.keys(p),L=c.length,g,v=s.length-p.length;if(mr(s,p)){for(var d=0;d<b;d++){var B=Array.isArray(s)?Number(y[d]):y[d];B in p||(g=w.concat(B),h.remove.push({op:"remove",path:r(g)}))}for(var d=0;d<L;d++){var B=Array.isArray(p)?Number(c[d]):c[d];i({key:B,obj1:s,obj2:p,path:m.concat(B),pathForRemoves:m.concat(B),diffs:h})}}else{for(var d=0;d<v;d++)g=w.concat(d),h.remove.push({op:"remove",path:r(g)});for(var pr=s.slice(v),d=0;d<L;d++)i({key:d,obj1:pr,obj2:p,path:m.concat(d),pathForRemoves:m.concat(d+v),diffs:h})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function i({key:s,obj1:p,obj2:m,path:w,pathForRemoves:h,diffs:y}){var b=p[s],c=m[s];if(!(s in p)&&s in m){var L=c;y.add.push({op:"add",path:r(w),value:L})}else b!==c&&(Object(b)!==b||Object(c)!==c||lr(b,c)||!Object.keys(b).length&&!Object.keys(c).length&&String(b)!=String(c)?f(w,y,c):o({obj1:p[s],obj2:m[s],basePath:w,basePathForRemoves:h,diffs:y}))}function f(s,p,m){p.replace.push({op:"replace",path:r(s),value:m})}}function St(t){return[""].concat(t).join("/")}function lr(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function mr(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,i=0;i<e.length&&String(t[i])===String(e[i]);i++)o++;for(var f=e.length;f>0&&String(t[f+r])===String(e[f]);f--)a++;return o>=a}return!0}var ur=typeof global=="object"&&global&&global.Object===Object&&global,X=ur;var dr=typeof self=="object"&&self&&self.Object===Object&&self,cr=X||dr||Function("return this")(),u=cr;var xr=u.Symbol,A=xr;var Pt=Object.prototype,hr=Pt.hasOwnProperty,gr=Pt.toString,Y=A?A.toStringTag:void 0;function yr(t){var e=hr.call(t,Y),r=t[Y];try{t[Y]=void 0;var o=!0}catch{}var a=gr.call(t);return o&&(e?t[Y]=r:delete t[Y]),a}var It=yr;var br=Object.prototype,vr=br.toString;function wr(t){return vr.call(t)}var Ct=wr;var jr="[object Null]",Tr="[object Undefined]",Et=A?A.toStringTag:void 0;function Ar(t){return t==null?t===void 0?Tr:jr:Et&&Et in Object(t)?It(t):Ct(t)}var O=Ar;function Or(t){return t!=null&&typeof t=="object"}var j=Or;var _r=Array.isArray,D=_r;function Sr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var T=Sr;var Pr="[object AsyncFunction]",Ir="[object Function]",Cr="[object GeneratorFunction]",Er="[object Proxy]";function Mr(t){if(!T(t))return!1;var e=O(t);return e==Ir||e==Cr||e==Pr||e==Er}var Z=Mr;var Rr=u["__core-js_shared__"],Q=Rr;var Mt=function(){var t=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Lr(t){return!!Mt&&Mt in t}var Rt=Lr;var Fr=Function.prototype,Br=Fr.toString;function Dr(t){if(t!=null){try{return Br.call(t)}catch{}try{return t+""}catch{}}return""}var _=Dr;var kr=/[\\^$.*+?()[\]{}|]/g,Ur=/^\[object .+?Constructor\]$/,Nr=Function.prototype,Wr=Object.prototype,Gr=Nr.toString,Kr=Wr.hasOwnProperty,zr=RegExp("^"+Gr.call(Kr).replace(kr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Hr(t){if(!T(t)||Rt(t))return!1;var e=Z(t)?zr:Ur;return e.test(_(t))}var Lt=Hr;function Vr(t,e){return t?.[e]}var Ft=Vr;function qr(t,e){var r=Ft(t,e);return Lt(r)?r:void 0}var x=qr;var $r=x(u,"WeakMap"),tt=$r;var Bt=Object.create,Yr=function(){function t(){}return function(e){if(!T(e))return{};if(Bt)return Bt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Dt=Yr;function Jr(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var kt=Jr;var Xr=function(){try{var t=x(Object,"defineProperty");return t({},"",{}),t}catch{}}(),yt=Xr;function Zr(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Ut=Zr;var Qr=9007199254740991,to=/^(?:0|[1-9]\d*)$/;function eo(t,e){var r=typeof t;return e=e??Qr,!!e&&(r=="number"||r!="symbol"&&to.test(t))&&t>-1&&t%1==0&&t<e}var Nt=eo;function ro(t,e,r){e=="__proto__"&&yt?yt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var et=ro;function oo(t,e){return t===e||t!==t&&e!==e}var rt=oo;var ao=Object.prototype,so=ao.hasOwnProperty;function fo(t,e,r){var o=t[e];(!(so.call(t,e)&&rt(o,r))||r===void 0&&!(e in t))&&et(t,e,r)}var ot=fo;function io(t,e,r,o){var a=!r;r||(r={});for(var i=-1,f=e.length;++i<f;){var s=e[i],p=o?o(r[s],t[s],s,r,t):void 0;p===void 0&&(p=t[s]),a?et(r,s,p):ot(r,s,p)}return r}var I=io;var no=9007199254740991;function po(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=no}var at=po;function lo(t){return t!=null&&at(t.length)&&!Z(t)}var st=lo;var mo=Object.prototype;function uo(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||mo;return t===r}var k=uo;function co(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Wt=co;var xo="[object Arguments]";function ho(t){return j(t)&&O(t)==xo}var bt=ho;var Gt=Object.prototype,go=Gt.hasOwnProperty,yo=Gt.propertyIsEnumerable,bo=bt(function(){return arguments}())?bt:function(t){return j(t)&&go.call(t,"callee")&&!yo.call(t,"callee")},Kt=bo;function vo(){return!1}var zt=vo;var qt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ht=qt&&typeof module=="object"&&module&&!module.nodeType&&module,wo=Ht&&Ht.exports===qt,Vt=wo?u.Buffer:void 0,jo=Vt?Vt.isBuffer:void 0,To=jo||zt,ft=To;var Ao="[object Arguments]",Oo="[object Array]",_o="[object Boolean]",So="[object Date]",Po="[object Error]",Io="[object Function]",Co="[object Map]",Eo="[object Number]",Mo="[object Object]",Ro="[object RegExp]",Lo="[object Set]",Fo="[object String]",Bo="[object WeakMap]",Do="[object ArrayBuffer]",ko="[object DataView]",Uo="[object Float32Array]",No="[object Float64Array]",Wo="[object Int8Array]",Go="[object Int16Array]",Ko="[object Int32Array]",zo="[object Uint8Array]",Ho="[object Uint8ClampedArray]",Vo="[object Uint16Array]",qo="[object Uint32Array]",l={};l[Uo]=l[No]=l[Wo]=l[Go]=l[Ko]=l[zo]=l[Ho]=l[Vo]=l[qo]=!0;l[Ao]=l[Oo]=l[Do]=l[_o]=l[ko]=l[So]=l[Po]=l[Io]=l[Co]=l[Eo]=l[Mo]=l[Ro]=l[Lo]=l[Fo]=l[Bo]=!1;function $o(t){return j(t)&&at(t.length)&&!!l[O(t)]}var $t=$o;function Yo(t){return function(e){return t(e)}}var U=Yo;var Yt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,J=Yt&&typeof module=="object"&&module&&!module.nodeType&&module,Jo=J&&J.exports===Yt,vt=Jo&&X.process,Xo=function(){try{var t=J&&J.require&&J.require("util").types;return t||vt&&vt.binding&&vt.binding("util")}catch{}}(),S=Xo;var Jt=S&&S.isTypedArray,Zo=Jt?U(Jt):$t,Xt=Zo;var Qo=Object.prototype,ta=Qo.hasOwnProperty;function ea(t,e){var r=D(t),o=!r&&Kt(t),a=!r&&!o&&ft(t),i=!r&&!o&&!a&&Xt(t),f=r||o||a||i,s=f?Wt(t.length,String):[],p=s.length;for(var m in t)(e||ta.call(t,m))&&!(f&&(m=="length"||a&&(m=="offset"||m=="parent")||i&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||Nt(m,p)))&&s.push(m);return s}var it=ea;function ra(t,e){return function(r){return t(e(r))}}var nt=ra;var oa=nt(Object.keys,Object),Zt=oa;var aa=Object.prototype,sa=aa.hasOwnProperty;function fa(t){if(!k(t))return Zt(t);var e=[];for(var r in Object(t))sa.call(t,r)&&r!="constructor"&&e.push(r);return e}var Qt=fa;function ia(t){return st(t)?it(t):Qt(t)}var N=ia;function na(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var te=na;var pa=Object.prototype,la=pa.hasOwnProperty;function ma(t){if(!T(t))return te(t);var e=k(t),r=[];for(var o in t)o=="constructor"&&(e||!la.call(t,o))||r.push(o);return r}var ee=ma;function ua(t){return st(t)?it(t,!0):ee(t)}var W=ua;var da=x(Object,"create"),P=da;function ca(){this.__data__=P?P(null):{},this.size=0}var re=ca;function xa(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var oe=xa;var ha="__lodash_hash_undefined__",ga=Object.prototype,ya=ga.hasOwnProperty;function ba(t){var e=this.__data__;if(P){var r=e[t];return r===ha?void 0:r}return ya.call(e,t)?e[t]:void 0}var ae=ba;var va=Object.prototype,wa=va.hasOwnProperty;function ja(t){var e=this.__data__;return P?e[t]!==void 0:wa.call(e,t)}var se=ja;var Ta="__lodash_hash_undefined__";function Aa(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=P&&e===void 0?Ta:e,this}var fe=Aa;function G(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}G.prototype.clear=re;G.prototype.delete=oe;G.prototype.get=ae;G.prototype.has=se;G.prototype.set=fe;var wt=G;function Oa(){this.__data__=[],this.size=0}var ie=Oa;function _a(t,e){for(var r=t.length;r--;)if(rt(t[r][0],e))return r;return-1}var C=_a;var Sa=Array.prototype,Pa=Sa.splice;function Ia(t){var e=this.__data__,r=C(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Pa.call(e,r,1),--this.size,!0}var ne=Ia;function Ca(t){var e=this.__data__,r=C(e,t);return r<0?void 0:e[r][1]}var pe=Ca;function Ea(t){return C(this.__data__,t)>-1}var le=Ea;function Ma(t,e){var r=this.__data__,o=C(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var me=Ma;function K(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}K.prototype.clear=ie;K.prototype.delete=ne;K.prototype.get=pe;K.prototype.has=le;K.prototype.set=me;var E=K;var Ra=x(u,"Map"),M=Ra;function La(){this.size=0,this.__data__={hash:new wt,map:new(M||E),string:new wt}}var ue=La;function Fa(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var de=Fa;function Ba(t,e){var r=t.__data__;return de(e)?r[typeof e=="string"?"string":"hash"]:r.map}var R=Ba;function Da(t){var e=R(this,t).delete(t);return this.size-=e?1:0,e}var ce=Da;function ka(t){return R(this,t).get(t)}var xe=ka;function Ua(t){return R(this,t).has(t)}var he=Ua;function Na(t,e){var r=R(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var ge=Na;function z(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}z.prototype.clear=ue;z.prototype.delete=ce;z.prototype.get=xe;z.prototype.has=he;z.prototype.set=ge;var ye=z;function Wa(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var pt=Wa;var Ga=nt(Object.getPrototypeOf,Object),lt=Ga;function Ka(){this.__data__=new E,this.size=0}var be=Ka;function za(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ve=za;function Ha(t){return this.__data__.get(t)}var we=Ha;function Va(t){return this.__data__.has(t)}var je=Va;var qa=200;function $a(t,e){var r=this.__data__;if(r instanceof E){var o=r.__data__;if(!M||o.length<qa-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new ye(o)}return r.set(t,e),this.size=r.size,this}var Te=$a;function H(t){var e=this.__data__=new E(t);this.size=e.size}H.prototype.clear=be;H.prototype.delete=ve;H.prototype.get=we;H.prototype.has=je;H.prototype.set=Te;var Ae=H;function Ya(t,e){return t&&I(e,N(e),t)}var Oe=Ya;function Ja(t,e){return t&&I(e,W(e),t)}var _e=Ja;var Ce=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Se=Ce&&typeof module=="object"&&module&&!module.nodeType&&module,Xa=Se&&Se.exports===Ce,Pe=Xa?u.Buffer:void 0,Ie=Pe?Pe.allocUnsafe:void 0;function Za(t,e){if(e)return t.slice();var r=t.length,o=Ie?Ie(r):new t.constructor(r);return t.copy(o),o}var Ee=Za;function Qa(t,e){for(var r=-1,o=t==null?0:t.length,a=0,i=[];++r<o;){var f=t[r];e(f,r,t)&&(i[a++]=f)}return i}var Me=Qa;function ts(){return[]}var mt=ts;var es=Object.prototype,rs=es.propertyIsEnumerable,Re=Object.getOwnPropertySymbols,os=Re?function(t){return t==null?[]:(t=Object(t),Me(Re(t),function(e){return rs.call(t,e)}))}:mt,V=os;function as(t,e){return I(t,V(t),e)}var Le=as;var ss=Object.getOwnPropertySymbols,fs=ss?function(t){for(var e=[];t;)pt(e,V(t)),t=lt(t);return e}:mt,ut=fs;function is(t,e){return I(t,ut(t),e)}var Fe=is;function ns(t,e,r){var o=e(t);return D(t)?o:pt(o,r(t))}var dt=ns;function ps(t){return dt(t,N,V)}var Be=ps;function ls(t){return dt(t,W,ut)}var De=ls;var ms=x(u,"DataView"),ct=ms;var us=x(u,"Promise"),xt=us;var ds=x(u,"Set"),ht=ds;var ke="[object Map]",cs="[object Object]",Ue="[object Promise]",Ne="[object Set]",We="[object WeakMap]",Ge="[object DataView]",xs=_(ct),hs=_(M),gs=_(xt),ys=_(ht),bs=_(tt),F=O;(ct&&F(new ct(new ArrayBuffer(1)))!=Ge||M&&F(new M)!=ke||xt&&F(xt.resolve())!=Ue||ht&&F(new ht)!=Ne||tt&&F(new tt)!=We)&&(F=function(t){var e=O(t),r=e==cs?t.constructor:void 0,o=r?_(r):"";if(o)switch(o){case xs:return Ge;case hs:return ke;case gs:return Ue;case ys:return Ne;case bs:return We}return e});var q=F;var vs=Object.prototype,ws=vs.hasOwnProperty;function js(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&ws.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Ke=js;var Ts=u.Uint8Array,jt=Ts;function As(t){var e=new t.constructor(t.byteLength);return new jt(e).set(new jt(t)),e}var $=As;function Os(t,e){var r=e?$(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var ze=Os;var _s=/\w*$/;function Ss(t){var e=new t.constructor(t.source,_s.exec(t));return e.lastIndex=t.lastIndex,e}var He=Ss;var Ve=A?A.prototype:void 0,qe=Ve?Ve.valueOf:void 0;function Ps(t){return qe?Object(qe.call(t)):{}}var $e=Ps;function Is(t,e){var r=e?$(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Ye=Is;var Cs="[object Boolean]",Es="[object Date]",Ms="[object Map]",Rs="[object Number]",Ls="[object RegExp]",Fs="[object Set]",Bs="[object String]",Ds="[object Symbol]",ks="[object ArrayBuffer]",Us="[object DataView]",Ns="[object Float32Array]",Ws="[object Float64Array]",Gs="[object Int8Array]",Ks="[object Int16Array]",zs="[object Int32Array]",Hs="[object Uint8Array]",Vs="[object Uint8ClampedArray]",qs="[object Uint16Array]",$s="[object Uint32Array]";function Ys(t,e,r){var o=t.constructor;switch(e){case ks:return $(t);case Cs:case Es:return new o(+t);case Us:return ze(t,r);case Ns:case Ws:case Gs:case Ks:case zs:case Hs:case Vs:case qs:case $s:return Ye(t,r);case Ms:return new o;case Rs:case Bs:return new o(t);case Ls:return He(t);case Fs:return new o;case Ds:return $e(t)}}var Je=Ys;function Js(t){return typeof t.constructor=="function"&&!k(t)?Dt(lt(t)):{}}var Xe=Js;var Xs="[object Map]";function Zs(t){return j(t)&&q(t)==Xs}var Ze=Zs;var Qe=S&&S.isMap,Qs=Qe?U(Qe):Ze,tr=Qs;var tf="[object Set]";function ef(t){return j(t)&&q(t)==tf}var er=ef;var rr=S&&S.isSet,rf=rr?U(rr):er,or=rf;var of=1,af=2,sf=4,ar="[object Arguments]",ff="[object Array]",nf="[object Boolean]",pf="[object Date]",lf="[object Error]",sr="[object Function]",mf="[object GeneratorFunction]",uf="[object Map]",df="[object Number]",fr="[object Object]",cf="[object RegExp]",xf="[object Set]",hf="[object String]",gf="[object Symbol]",yf="[object WeakMap]",bf="[object ArrayBuffer]",vf="[object DataView]",wf="[object Float32Array]",jf="[object Float64Array]",Tf="[object Int8Array]",Af="[object Int16Array]",Of="[object Int32Array]",_f="[object Uint8Array]",Sf="[object Uint8ClampedArray]",Pf="[object Uint16Array]",If="[object Uint32Array]",n={};n[ar]=n[ff]=n[bf]=n[vf]=n[nf]=n[pf]=n[wf]=n[jf]=n[Tf]=n[Af]=n[Of]=n[uf]=n[df]=n[fr]=n[cf]=n[xf]=n[hf]=n[gf]=n[_f]=n[Sf]=n[Pf]=n[If]=!0;n[lf]=n[sr]=n[yf]=!1;function gt(t,e,r,o,a,i){var f,s=e&of,p=e&af,m=e&sf;if(r&&(f=a?r(t,o,a,i):r(t)),f!==void 0)return f;if(!T(t))return t;var w=D(t);if(w){if(f=Ke(t),!s)return kt(t,f)}else{var h=q(t),y=h==sr||h==mf;if(ft(t))return Ee(t,s);if(h==fr||h==ar||y&&!a){if(f=p||y?{}:Xe(t),!s)return p?Fe(t,_e(f,t)):Le(t,Oe(f,t))}else{if(!n[h])return a?t:{};f=Je(t,h,s)}}i||(i=new Ae);var b=i.get(t);if(b)return b;i.set(t,f),or(t)?t.forEach(function(g){f.add(gt(g,e,r,g,t,i))}):tr(t)&&t.forEach(function(g,v){f.set(v,gt(g,e,r,v,t,i))});var c=m?p?De:Be:p?W:N,L=w?void 0:c(t);return Ut(L||t,function(g,v){L&&(v=g,g=t[v]),ot(f,v,gt(g,e,r,v,t,i))}),f}var ir=gt;var Cf=1,Ef=4;function Mf(t){return ir(t,Cf|Ef)}var Tt=Mf;function nr(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var At=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var Ot=class{settings={devMode:!0,mode:"detect",modeTimeout:300,modeFallback:"child",siteUrl:"https://tera-tools.com/embed",restrictOrigin:"*",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3};events=nr();dom={el:null,iframe:null,popup:null,stylesheet:null};methods=["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","selectProjectFile","getProjectFiles","selectProjectLibrary","parseProjectLibrary","setProjectLibrary","uiAlert","uiSplat","uiWindow"];plugins=[];send(e){let r=At();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||At(),...Tt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR","Message compose client->server:",o),this.debug("ERROR","Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("Recieved",r),r?.action=="response"&&this.acceptPostboxes[r.id])r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response);else{if(r?.action=="rpc")return Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o.toString()})});if(r?.action=="event")return Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o});r?.id?this.debug(`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("Unexpected incoming TERA-FY CLIENT message",{message:r})}}acceptPostboxes={};createProjectStatePatch(e,r){let o=_t(r,e,St);return this.debug("INFO","Created project patch",{newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}constructor(e){e&&this.set(e)}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.detectMode()).then(o=>this.settings.mode=o).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings))))}detectMode(){return this.settings.mode!="detect"?this.settings.mode:window.self===window.parent?this.settings.modeFallback:Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){return new Promise(e=>{switch(this.settings.mode){case"child":this.debug("Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),document.body.append(this.dom.el),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("Embed frame ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe);break;case"parent":this.debug("Using TERA window parent"),e();break;case"popup":this.debug("Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),(()=>{let r=0,o,a=()=>{this.debug("Trying handshake",++r),clearTimeout(o),o=setTimeout(a,this.settings.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(o),this.debug("Popup window accepted handshake"),e()})};a()})();break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
|
|
2
|
+
`),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){let r="log";typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),!(["INFO","LOG"].includes(r)&&!this.settings.devMode)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r){return typeof e=="string"?this.settings[e]=r:Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r){return!this.settings.devMode||r===void 0?this:this.set(e,r)}use(e,r){if(typeof e!="function")throw new Error("Expected use() call to be provided with a class initalizer");let o=new e(this,r);return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(o=>!["constructor","prototype","name"].includes(o)).filter(o=>o!="init").forEach(o=>{Object.defineProperty(e,o,{value:r[o].bind(e),enumerable:!1})})}toggleDevMode(e="toggle"){return this.settings.devMode=e==="toggle"?!this.settings.devMode:e,this.dom.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}};export{Ot as default};
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
lodash-es/lodash.js:
|
|
@@ -13,4 +13,3 @@ lodash-es/lodash.js:
|
|
|
13
13
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
14
14
|
*)
|
|
15
15
|
*/
|
|
16
|
-
//# sourceMappingURL=terafy.js.map
|
package/lib/terafy.client.js
CHANGED
|
@@ -17,16 +17,19 @@ export default class TeraFy {
|
|
|
17
17
|
*
|
|
18
18
|
* @type {Object}
|
|
19
19
|
* @property {Boolean} devMode Operate in devMode - i.e. force outer refresh when encountering an existing TeraFy instance
|
|
20
|
-
* @property {'detect'|'parent'|'child'} How to communicate with TERA. 'parent' assumes that the parent of the current document is TERA, 'child' spawns an iFrame and uses TERA there, 'detect' tries parent and
|
|
20
|
+
* @property {'detect'|'parent'|'child'|'popup'} mode How to communicate with TERA. 'parent' assumes that the parent of the current document is TERA, 'child' spawns an iFrame and uses TERA there, 'detect' tries parent and switches to `modeFallback` if communication fails
|
|
21
|
+
* @property {String} modeFallback Method to use when all method detection fails
|
|
21
22
|
* @property {Number} modeTimeout How long entities have in 'detect' mode to identify themselves
|
|
22
23
|
* @property {String} siteUrl The TERA URL to connect to
|
|
23
24
|
* @property {String} restrictOrigin URL to restrict communications to
|
|
24
25
|
* @property {Array<String>} List of sandbox allowables for the embedded if in embed mode
|
|
26
|
+
* @property {Number} handshakeInterval Interval in milliseconds when sanning for a handshake
|
|
25
27
|
*/
|
|
26
28
|
settings = {
|
|
27
29
|
devMode: true,
|
|
28
30
|
mode: 'detect',
|
|
29
31
|
modeTimeout: 300,
|
|
32
|
+
modeFallback: 'child', // ENUM: 'child' (use iframes), 'popup' (use popup windows)
|
|
30
33
|
siteUrl: 'https://tera-tools.com/embed',
|
|
31
34
|
restrictOrigin: '*', // FIXME: Need to restrict this to TERA site
|
|
32
35
|
frameSandbox: [
|
|
@@ -39,8 +42,9 @@ export default class TeraFy {
|
|
|
39
42
|
'allow-presentation',
|
|
40
43
|
'allow-same-origin',
|
|
41
44
|
'allow-scripts',
|
|
42
|
-
'allow-top-navigation'
|
|
45
|
+
'allow-top-navigation',
|
|
43
46
|
],
|
|
47
|
+
handshakeInterval: 1000,
|
|
44
48
|
};
|
|
45
49
|
|
|
46
50
|
|
|
@@ -56,12 +60,14 @@ export default class TeraFy {
|
|
|
56
60
|
*
|
|
57
61
|
* @type {Object}
|
|
58
62
|
* @property {DOMElement} el The main tera-fy div wrapper
|
|
59
|
-
* @property {DOMElement} iframe The internal iFrame element
|
|
63
|
+
* @property {DOMElement} iframe The internal iFrame element (if `settings.mode == 'child'`)
|
|
64
|
+
* @property {Window} popup The popup window context (if `settings.mode == 'popup'`)
|
|
60
65
|
* @property {DOMElement} stylesheet The corresponding stylesheet
|
|
61
66
|
*/
|
|
62
67
|
dom = {
|
|
63
68
|
el: null,
|
|
64
69
|
iframe: null,
|
|
70
|
+
popup: null,
|
|
65
71
|
stylesheet: null,
|
|
66
72
|
};
|
|
67
73
|
|
|
@@ -93,7 +99,7 @@ export default class TeraFy {
|
|
|
93
99
|
'selectProjectLibrary', 'parseProjectLibrary', 'setProjectLibrary',
|
|
94
100
|
|
|
95
101
|
// UI
|
|
96
|
-
'uiAlert',
|
|
102
|
+
'uiAlert', 'uiSplat', 'uiWindow',
|
|
97
103
|
];
|
|
98
104
|
|
|
99
105
|
|
|
@@ -149,6 +155,8 @@ export default class TeraFy {
|
|
|
149
155
|
window.parent.postMessage(payload, this.settings.restrictOrigin);
|
|
150
156
|
} else if (this.settings.mode == 'child') {
|
|
151
157
|
this.dom.iframe.contentWindow.postMessage(payload, this.settings.restrictOrigin);
|
|
158
|
+
} else if (this.settings.mode == 'popup') {
|
|
159
|
+
this.dom.popup.postMessage(payload, this.settings.restrictOrigin);
|
|
152
160
|
} else if (this.settings.mode == 'detect') {
|
|
153
161
|
throw new Error('Call init() or detectMode() before trying to send data to determine the mode');
|
|
154
162
|
} else {
|
|
@@ -305,7 +313,8 @@ export default class TeraFy {
|
|
|
305
313
|
]))
|
|
306
314
|
.then(()=> this.rpc('setServerMode', // Tell server what mode its in
|
|
307
315
|
this.settings.mode == 'child' ? 'embedded'
|
|
308
|
-
: this.settings.mode == 'parent' ? '
|
|
316
|
+
: this.settings.mode == 'parent' ? 'frame'
|
|
317
|
+
: this.settings.mode == 'popup' ? 'popup'
|
|
309
318
|
: (()=> { throw(`Unknown server mode "${this.settings.mode}"`) })()
|
|
310
319
|
))
|
|
311
320
|
.then(()=> Promise.all( // Init all plugins (with this outer module as the context)
|
|
@@ -327,7 +336,7 @@ export default class TeraFy {
|
|
|
327
336
|
if (this.settings.mode != 'detect') { // Dev has specified a forced mode to use
|
|
328
337
|
return this.settings.mode;
|
|
329
338
|
} else if (window.self === window.parent) { // This frame is already at the top
|
|
330
|
-
return
|
|
339
|
+
return this.settings.modeFallback;
|
|
331
340
|
} else { // No idea - try messaging
|
|
332
341
|
return Promise.resolve()
|
|
333
342
|
.then(()=> this.settings.mode = 'parent') // Switch to parent mode...
|
|
@@ -339,7 +348,7 @@ export default class TeraFy {
|
|
|
339
348
|
.then(()=> resolve())
|
|
340
349
|
}))
|
|
341
350
|
.then(()=> 'parent')
|
|
342
|
-
.catch(()=>
|
|
351
|
+
.catch(()=> this.settings.modeFallback)
|
|
343
352
|
}
|
|
344
353
|
}
|
|
345
354
|
|
|
@@ -373,9 +382,34 @@ export default class TeraFy {
|
|
|
373
382
|
this.dom.el.append(this.dom.iframe);
|
|
374
383
|
break;
|
|
375
384
|
case 'parent':
|
|
376
|
-
this.debug('Using TERA
|
|
385
|
+
this.debug('Using TERA window parent');
|
|
377
386
|
resolve();
|
|
378
387
|
break;
|
|
388
|
+
case 'popup':
|
|
389
|
+
this.debug('Injecting TERA site as a popup window');
|
|
390
|
+
this.dom.popup = window.open(this.settings.siteUrl, '_blank', 'popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600');
|
|
391
|
+
|
|
392
|
+
// Loop until the window context returns a handshake
|
|
393
|
+
(()=> {
|
|
394
|
+
let handshakeCount = 0;
|
|
395
|
+
let handshakeTimer;
|
|
396
|
+
|
|
397
|
+
const tryHandshake = ()=> {
|
|
398
|
+
this.debug('Trying handshake', ++handshakeCount);
|
|
399
|
+
|
|
400
|
+
clearTimeout(handshakeTimer);
|
|
401
|
+
handshakeTimer = setTimeout(tryHandshake, this.settings.handshakeInterval);
|
|
402
|
+
|
|
403
|
+
this.rpc('handshake')
|
|
404
|
+
.then(()=> {
|
|
405
|
+
clearTimeout(handshakeTimer);
|
|
406
|
+
this.debug('Popup window accepted handshake');
|
|
407
|
+
resolve();
|
|
408
|
+
});
|
|
409
|
+
};
|
|
410
|
+
tryHandshake();
|
|
411
|
+
})();
|
|
412
|
+
break;
|
|
379
413
|
default:
|
|
380
414
|
throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`);
|
|
381
415
|
}
|
|
@@ -434,6 +468,7 @@ export default class TeraFy {
|
|
|
434
468
|
document.head.appendChild(this.dom.stylesheet);
|
|
435
469
|
break;
|
|
436
470
|
case 'parent':
|
|
471
|
+
case 'popup':
|
|
437
472
|
break;
|
|
438
473
|
default:
|
|
439
474
|
throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`);
|
|
@@ -624,7 +659,11 @@ export default class TeraFy {
|
|
|
624
659
|
* This is an pre-requisite step for requireProject()
|
|
625
660
|
*
|
|
626
661
|
* @function requireUser
|
|
627
|
-
*
|
|
662
|
+
*
|
|
663
|
+
* @param {Object} [options] Additional options to mutate behaviour
|
|
664
|
+
* @param {Boolean} [options.forceRetry=false] Forcabily try to refresh the user state
|
|
665
|
+
*
|
|
666
|
+
* @returns {Promise<User>} The current logged in user or null if none
|
|
628
667
|
*/
|
|
629
668
|
|
|
630
669
|
|
|
@@ -920,5 +959,33 @@ export default class TeraFy {
|
|
|
920
959
|
* @returns {Promise} A promise which resolves when the alert has been dismissed
|
|
921
960
|
*/
|
|
922
961
|
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* Display HTML content full-screen within TERA
|
|
965
|
+
* This function is ideally called within a requestFocus() wrapper
|
|
966
|
+
*
|
|
967
|
+
* @function uiSplat
|
|
968
|
+
* @param {DOMElement|String|false} content Either a prepared DOM element or string to compile, set to falsy to remove existing content
|
|
969
|
+
*
|
|
970
|
+
* @param {Object} [options] Additional options to mutate behaviour
|
|
971
|
+
* @param {Boolean|String} [options.logo=false] Add a logo to the output, if boolean true the Tera-tools logo is used otherwise specify a path or URL
|
|
972
|
+
*/
|
|
973
|
+
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* Open a popup window containing a new site
|
|
977
|
+
*
|
|
978
|
+
* @function uiWindow
|
|
979
|
+
* @param {String} url The URL to open
|
|
980
|
+
*
|
|
981
|
+
* @param {Object} [options] Additional options to mutate behaviour
|
|
982
|
+
* @param {Number} [options.width=500] The desired width of the window
|
|
983
|
+
* @param {Number} [options.height=600] The desired height of the window
|
|
984
|
+
* @param {Boolean} [options.center=true] Attempt to center the window on the screen
|
|
985
|
+
* @param {Object} [options.permissions] Additional permissions to set on opening, defaults to a suitable set of permission for popups (see code)
|
|
986
|
+
*
|
|
987
|
+
* @returns {WindowProxy} The opened window object (if `noopener` is not set in permissions)
|
|
988
|
+
*/
|
|
989
|
+
|
|
923
990
|
// }}}
|
|
924
991
|
}
|