@iebh/tera-fy 1.1.0 → 1.2.1
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/CHANGELOG.md +3 -285
- package/api.md +192 -208
- package/dist/terafy.es2019.js +1 -1
- package/dist/terafy.js +1 -1
- package/hints.md +0 -9
- package/lib/projectFile.js +5 -5
- package/lib/terafy.client.js +12 -22
- package/lib/terafy.server.js +69 -25
- package/package.json +29 -10
- package/widgets/tera-file-select.vue +19 -10
package/dist/terafy.es2019.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Er=Object.defineProperty;var Cr=(t,e,r)=>e in t?Er(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var h=(t,e,r)=>(Cr(t,typeof e!="symbol"?e+"":e,r),r);function Ut(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:l,basePath:c,basePathForRemoves:x,diffs:v}){var T=Object.keys(s),w=T.length,b=Object.keys(l),P=b.length,y,i=s.length-l.length;if(Rr(s,l)){for(var m=0;m<w;m++){var f=Array.isArray(s)?Number(T[m]):T[m];f in l||(y=x.concat(f),v.remove.push({op:"remove",path:r(y)}))}for(var m=0;m<P;m++){var f=Array.isArray(l)?Number(b[m]):b[m];p({key:f,obj1:s,obj2:l,path:c.concat(f),pathForRemoves:c.concat(f),diffs:v})}}else{for(var m=0;m<i;m++)y=x.concat(m),v.remove.push({op:"remove",path:r(y)});for(var S=s.slice(i),m=0;m<P;m++)p({key:m,obj1:S,obj2:l,path:c.concat(m),pathForRemoves:c.concat(m+i),diffs:v})}}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 p({key:s,obj1:l,obj2:c,path:x,pathForRemoves:v,diffs:T}){var w=l[s],b=c[s];if(!(s in l)&&s in c){var P=b;T.add.push({op:"add",path:r(x),value:P})}else w!==b&&(Object(w)!==w||Object(b)!==b||Mr(w,b)||!Object.keys(w).length&&!Object.keys(b).length&&String(w)!=String(b)?n(x,T,b):o({obj1:l[s],obj2:c[s],basePath:x,basePathForRemoves:v,diffs:T}))}function n(s,l,c){l.replace.push({op:"replace",path:r(s),value:c})}}function Gt(t){return[""].concat(t).join("/")}function Mr(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function Rr(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,p=0;p<e.length&&String(t[p])===String(e[p]);p++)o++;for(var n=e.length;n>0&&String(t[n+r])===String(e[n]);n--)a++;return o>=a}return!0}var Br=typeof global=="object"&&global&&global.Object===Object&&global,ot=Br;var Lr=typeof self=="object"&&self&&self.Object===Object&&self,Fr=ot||Lr||Function("return this")(),g=Fr;var Nr=g.Symbol,_=Nr;var Kt=Object.prototype,Dr=Kt.hasOwnProperty,kr=Kt.toString,tt=_?_.toStringTag:void 0;function Ur(t){var e=Dr.call(t,tt),r=t[tt];try{t[tt]=void 0;var o=!0}catch{}var a=kr.call(t);return o&&(e?t[tt]=r:delete t[tt]),a}var Wt=Ur;var Gr=Object.prototype,Kr=Gr.toString;function Wr(t){return Kr.call(t)}var zt=Wr;var zr="[object Null]",Vr="[object Undefined]",Vt=_?_.toStringTag:void 0;function qr(t){return t==null?t===void 0?Vr:zr:Vt&&Vt in Object(t)?Wt(t):zt(t)}var I=qr;function Hr(t){return t!=null&&typeof t=="object"}var A=Hr;var $r=Array.isArray,U=$r;function Yr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var O=Yr;var Zr="[object AsyncFunction]",Jr="[object Function]",Xr="[object GeneratorFunction]",Qr="[object Proxy]";function to(t){if(!O(t))return!1;var e=I(t);return e==Jr||e==Xr||e==Zr||e==Qr}var at=to;var eo=g["__core-js_shared__"],st=eo;var qt=function(){var t=/[^.]+$/.exec(st&&st.keys&&st.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function ro(t){return!!qt&&qt in t}var Ht=ro;var oo=Function.prototype,ao=oo.toString;function so(t){if(t!=null){try{return ao.call(t)}catch{}try{return t+""}catch{}}return""}var E=so;var io=/[\\^$.*+?()[\]{}|]/g,fo=/^\[object .+?Constructor\]$/,no=Function.prototype,po=Object.prototype,lo=no.toString,mo=po.hasOwnProperty,uo=RegExp("^"+lo.call(mo).replace(io,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function co(t){if(!O(t)||Ht(t))return!1;var e=at(t)?uo:fo;return e.test(E(t))}var $t=co;function ho(t,e){return t==null?void 0:t[e]}var Yt=ho;function xo(t,e){var r=Yt(t,e);return $t(r)?r:void 0}var j=xo;var go=j(g,"WeakMap"),it=go;var Zt=Object.create,bo=function(){function t(){}return function(e){if(!O(e))return{};if(Zt)return Zt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Jt=bo;function yo(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Xt=yo;var vo=function(){try{var t=j(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Ot=vo;function wo(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Qt=wo;var jo=9007199254740991,To=/^(?:0|[1-9]\d*)$/;function Ao(t,e){var r=typeof t;return e=e==null?jo:e,!!e&&(r=="number"||r!="symbol"&&To.test(t))&&t>-1&&t%1==0&&t<e}var te=Ao;function Oo(t,e,r){e=="__proto__"&&Ot?Ot(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var ft=Oo;function Po(t,e){return t===e||t!==t&&e!==e}var nt=Po;var So=Object.prototype,_o=So.hasOwnProperty;function Io(t,e,r){var o=t[e];(!(_o.call(t,e)&&nt(o,r))||r===void 0&&!(e in t))&&ft(t,e,r)}var pt=Io;function Eo(t,e,r,o){var a=!r;r||(r={});for(var p=-1,n=e.length;++p<n;){var s=e[p],l=o?o(r[s],t[s],s,r,t):void 0;l===void 0&&(l=t[s]),a?ft(r,s,l):pt(r,s,l)}return r}var R=Eo;var Co=9007199254740991;function Mo(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Co}var lt=Mo;function Ro(t){return t!=null&<(t.length)&&!at(t)}var mt=Ro;var Bo=Object.prototype;function Lo(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Bo;return t===r}var G=Lo;function Fo(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ee=Fo;var No="[object Arguments]";function Do(t){return A(t)&&I(t)==No}var Pt=Do;var re=Object.prototype,ko=re.hasOwnProperty,Uo=re.propertyIsEnumerable,Go=Pt(function(){return arguments}())?Pt:function(t){return A(t)&&ko.call(t,"callee")&&!Uo.call(t,"callee")},oe=Go;function Ko(){return!1}var ae=Ko;var fe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,se=fe&&typeof module=="object"&&module&&!module.nodeType&&module,Wo=se&&se.exports===fe,ie=Wo?g.Buffer:void 0,zo=ie?ie.isBuffer:void 0,Vo=zo||ae,ut=Vo;var qo="[object Arguments]",Ho="[object Array]",$o="[object Boolean]",Yo="[object Date]",Zo="[object Error]",Jo="[object Function]",Xo="[object Map]",Qo="[object Number]",ta="[object Object]",ea="[object RegExp]",ra="[object Set]",oa="[object String]",aa="[object WeakMap]",sa="[object ArrayBuffer]",ia="[object DataView]",fa="[object Float32Array]",na="[object Float64Array]",pa="[object Int8Array]",la="[object Int16Array]",ma="[object Int32Array]",ua="[object Uint8Array]",da="[object Uint8ClampedArray]",ca="[object Uint16Array]",ha="[object Uint32Array]",d={};d[fa]=d[na]=d[pa]=d[la]=d[ma]=d[ua]=d[da]=d[ca]=d[ha]=!0;d[qo]=d[Ho]=d[sa]=d[$o]=d[ia]=d[Yo]=d[Zo]=d[Jo]=d[Xo]=d[Qo]=d[ta]=d[ea]=d[ra]=d[oa]=d[aa]=!1;function xa(t){return A(t)&<(t.length)&&!!d[I(t)]}var ne=xa;function ga(t){return function(e){return t(e)}}var K=ga;var pe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,et=pe&&typeof module=="object"&&module&&!module.nodeType&&module,ba=et&&et.exports===pe,St=ba&&ot.process,ya=function(){try{var t=et&&et.require&&et.require("util").types;return t||St&&St.binding&&St.binding("util")}catch{}}(),C=ya;var le=C&&C.isTypedArray,va=le?K(le):ne,me=va;var wa=Object.prototype,ja=wa.hasOwnProperty;function Ta(t,e){var r=U(t),o=!r&&oe(t),a=!r&&!o&&ut(t),p=!r&&!o&&!a&&me(t),n=r||o||a||p,s=n?ee(t.length,String):[],l=s.length;for(var c in t)(e||ja.call(t,c))&&!(n&&(c=="length"||a&&(c=="offset"||c=="parent")||p&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||te(c,l)))&&s.push(c);return s}var dt=Ta;function Aa(t,e){return function(r){return t(e(r))}}var ct=Aa;var Oa=ct(Object.keys,Object),ue=Oa;var Pa=Object.prototype,Sa=Pa.hasOwnProperty;function _a(t){if(!G(t))return ue(t);var e=[];for(var r in Object(t))Sa.call(t,r)&&r!="constructor"&&e.push(r);return e}var de=_a;function Ia(t){return mt(t)?dt(t):de(t)}var W=Ia;function Ea(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var ce=Ea;var Ca=Object.prototype,Ma=Ca.hasOwnProperty;function Ra(t){if(!O(t))return ce(t);var e=G(t),r=[];for(var o in t)o=="constructor"&&(e||!Ma.call(t,o))||r.push(o);return r}var he=Ra;function Ba(t){return mt(t)?dt(t,!0):he(t)}var z=Ba;var La=j(Object,"create"),M=La;function Fa(){this.__data__=M?M(null):{},this.size=0}var xe=Fa;function Na(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var ge=Na;var Da="__lodash_hash_undefined__",ka=Object.prototype,Ua=ka.hasOwnProperty;function Ga(t){var e=this.__data__;if(M){var r=e[t];return r===Da?void 0:r}return Ua.call(e,t)?e[t]:void 0}var be=Ga;var Ka=Object.prototype,Wa=Ka.hasOwnProperty;function za(t){var e=this.__data__;return M?e[t]!==void 0:Wa.call(e,t)}var ye=za;var Va="__lodash_hash_undefined__";function qa(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=M&&e===void 0?Va:e,this}var ve=qa;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=xe;V.prototype.delete=ge;V.prototype.get=be;V.prototype.has=ye;V.prototype.set=ve;var _t=V;function Ha(){this.__data__=[],this.size=0}var we=Ha;function $a(t,e){for(var r=t.length;r--;)if(nt(t[r][0],e))return r;return-1}var B=$a;var Ya=Array.prototype,Za=Ya.splice;function Ja(t){var e=this.__data__,r=B(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Za.call(e,r,1),--this.size,!0}var je=Ja;function Xa(t){var e=this.__data__,r=B(e,t);return r<0?void 0:e[r][1]}var Te=Xa;function Qa(t){return B(this.__data__,t)>-1}var Ae=Qa;function ts(t,e){var r=this.__data__,o=B(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Oe=ts;function q(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])}}q.prototype.clear=we;q.prototype.delete=je;q.prototype.get=Te;q.prototype.has=Ae;q.prototype.set=Oe;var L=q;var es=j(g,"Map"),F=es;function rs(){this.size=0,this.__data__={hash:new _t,map:new(F||L),string:new _t}}var Pe=rs;function os(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Se=os;function as(t,e){var r=t.__data__;return Se(e)?r[typeof e=="string"?"string":"hash"]:r.map}var N=as;function ss(t){var e=N(this,t).delete(t);return this.size-=e?1:0,e}var _e=ss;function is(t){return N(this,t).get(t)}var Ie=is;function fs(t){return N(this,t).has(t)}var Ee=fs;function ns(t,e){var r=N(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ce=ns;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=Pe;H.prototype.delete=_e;H.prototype.get=Ie;H.prototype.has=Ee;H.prototype.set=Ce;var Me=H;function ps(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var ht=ps;var ls=ct(Object.getPrototypeOf,Object),xt=ls;function ms(){this.__data__=new L,this.size=0}var Re=ms;function us(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var Be=us;function ds(t){return this.__data__.get(t)}var Le=ds;function cs(t){return this.__data__.has(t)}var Fe=cs;var hs=200;function xs(t,e){var r=this.__data__;if(r instanceof L){var o=r.__data__;if(!F||o.length<hs-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new Me(o)}return r.set(t,e),this.size=r.size,this}var Ne=xs;function $(t){var e=this.__data__=new L(t);this.size=e.size}$.prototype.clear=Re;$.prototype.delete=Be;$.prototype.get=Le;$.prototype.has=Fe;$.prototype.set=Ne;var De=$;function gs(t,e){return t&&R(e,W(e),t)}var ke=gs;function bs(t,e){return t&&R(e,z(e),t)}var Ue=bs;var ze=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ge=ze&&typeof module=="object"&&module&&!module.nodeType&&module,ys=Ge&&Ge.exports===ze,Ke=ys?g.Buffer:void 0,We=Ke?Ke.allocUnsafe:void 0;function vs(t,e){if(e)return t.slice();var r=t.length,o=We?We(r):new t.constructor(r);return t.copy(o),o}var Ve=vs;function ws(t,e){for(var r=-1,o=t==null?0:t.length,a=0,p=[];++r<o;){var n=t[r];e(n,r,t)&&(p[a++]=n)}return p}var qe=ws;function js(){return[]}var gt=js;var Ts=Object.prototype,As=Ts.propertyIsEnumerable,He=Object.getOwnPropertySymbols,Os=He?function(t){return t==null?[]:(t=Object(t),qe(He(t),function(e){return As.call(t,e)}))}:gt,Y=Os;function Ps(t,e){return R(t,Y(t),e)}var $e=Ps;var Ss=Object.getOwnPropertySymbols,_s=Ss?function(t){for(var e=[];t;)ht(e,Y(t)),t=xt(t);return e}:gt,bt=_s;function Is(t,e){return R(t,bt(t),e)}var Ye=Is;function Es(t,e,r){var o=e(t);return U(t)?o:ht(o,r(t))}var yt=Es;function Cs(t){return yt(t,W,Y)}var Ze=Cs;function Ms(t){return yt(t,z,bt)}var Je=Ms;var Rs=j(g,"DataView"),vt=Rs;var Bs=j(g,"Promise"),wt=Bs;var Ls=j(g,"Set"),jt=Ls;var Xe="[object Map]",Fs="[object Object]",Qe="[object Promise]",tr="[object Set]",er="[object WeakMap]",rr="[object DataView]",Ns=E(vt),Ds=E(F),ks=E(wt),Us=E(jt),Gs=E(it),D=I;(vt&&D(new vt(new ArrayBuffer(1)))!=rr||F&&D(new F)!=Xe||wt&&D(wt.resolve())!=Qe||jt&&D(new jt)!=tr||it&&D(new it)!=er)&&(D=function(t){var e=I(t),r=e==Fs?t.constructor:void 0,o=r?E(r):"";if(o)switch(o){case Ns:return rr;case Ds:return Xe;case ks:return Qe;case Us:return tr;case Gs:return er}return e});var Z=D;var Ks=Object.prototype,Ws=Ks.hasOwnProperty;function zs(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 or=zs;var Vs=g.Uint8Array,It=Vs;function qs(t){var e=new t.constructor(t.byteLength);return new It(e).set(new It(t)),e}var J=qs;function Hs(t,e){var r=e?J(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var ar=Hs;var $s=/\w*$/;function Ys(t){var e=new t.constructor(t.source,$s.exec(t));return e.lastIndex=t.lastIndex,e}var sr=Ys;var ir=_?_.prototype:void 0,fr=ir?ir.valueOf:void 0;function Zs(t){return fr?Object(fr.call(t)):{}}var nr=Zs;function Js(t,e){var r=e?J(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var pr=Js;var Xs="[object Boolean]",Qs="[object Date]",ti="[object Map]",ei="[object Number]",ri="[object RegExp]",oi="[object Set]",ai="[object String]",si="[object Symbol]",ii="[object ArrayBuffer]",fi="[object DataView]",ni="[object Float32Array]",pi="[object Float64Array]",li="[object Int8Array]",mi="[object Int16Array]",ui="[object Int32Array]",di="[object Uint8Array]",ci="[object Uint8ClampedArray]",hi="[object Uint16Array]",xi="[object Uint32Array]";function gi(t,e,r){var o=t.constructor;switch(e){case ii:return J(t);case Xs:case Qs:return new o(+t);case fi:return ar(t,r);case ni:case pi:case li:case mi:case ui:case di:case ci:case hi:case xi:return pr(t,r);case ti:return new o;case ei:case ai:return new o(t);case ri:return sr(t);case oi:return new o;case si:return nr(t)}}var lr=gi;function bi(t){return typeof t.constructor=="function"&&!G(t)?Jt(xt(t)):{}}var mr=bi;var yi="[object Map]";function vi(t){return A(t)&&Z(t)==yi}var ur=vi;var dr=C&&C.isMap,wi=dr?K(dr):ur,cr=wi;var ji="[object Set]";function Ti(t){return A(t)&&Z(t)==ji}var hr=Ti;var xr=C&&C.isSet,Ai=xr?K(xr):hr,gr=Ai;var Oi=1,Pi=2,Si=4,br="[object Arguments]",_i="[object Array]",Ii="[object Boolean]",Ei="[object Date]",Ci="[object Error]",yr="[object Function]",Mi="[object GeneratorFunction]",Ri="[object Map]",Bi="[object Number]",vr="[object Object]",Li="[object RegExp]",Fi="[object Set]",Ni="[object String]",Di="[object Symbol]",ki="[object WeakMap]",Ui="[object ArrayBuffer]",Gi="[object DataView]",Ki="[object Float32Array]",Wi="[object Float64Array]",zi="[object Int8Array]",Vi="[object Int16Array]",qi="[object Int32Array]",Hi="[object Uint8Array]",$i="[object Uint8ClampedArray]",Yi="[object Uint16Array]",Zi="[object Uint32Array]",u={};u[br]=u[_i]=u[Ui]=u[Gi]=u[Ii]=u[Ei]=u[Ki]=u[Wi]=u[zi]=u[Vi]=u[qi]=u[Ri]=u[Bi]=u[vr]=u[Li]=u[Fi]=u[Ni]=u[Di]=u[Hi]=u[$i]=u[Yi]=u[Zi]=!0;u[Ci]=u[yr]=u[ki]=!1;function Tt(t,e,r,o,a,p){var n,s=e&Oi,l=e&Pi,c=e&Si;if(r&&(n=a?r(t,o,a,p):r(t)),n!==void 0)return n;if(!O(t))return t;var x=U(t);if(x){if(n=or(t),!s)return Xt(t,n)}else{var v=Z(t),T=v==yr||v==Mi;if(ut(t))return Ve(t,s);if(v==vr||v==br||T&&!a){if(n=l||T?{}:mr(t),!s)return l?Ye(t,Ue(n,t)):$e(t,ke(n,t))}else{if(!u[v])return a?t:{};n=lr(t,v,s)}}p||(p=new De);var w=p.get(t);if(w)return w;p.set(t,n),gr(t)?t.forEach(function(y){n.add(Tt(y,e,r,y,t,p))}):cr(t)&&t.forEach(function(y,i){n.set(i,Tt(y,e,r,i,t,p))});var b=c?l?Je:Ze:l?z:W,P=x?void 0:b(t);return Qt(P||t,function(y,i){P&&(i=y,y=t[i]),pt(n,i,Tt(y,e,r,i,t,p))}),n}var wr=Tt;var Ji=1,Xi=4;function Qi(t){return wr(t,Ji|Xi)}var Et=Qi;function jr(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 Ct=(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 tf="array",ef="bit",Tr="bits",rf="byte",Ar="bytes",X="",of="exponent",af="function",Or="iec",sf="Invalid number",ff="Invalid rounding method",Mt="jedec",nf="object",Pr=".",pf="round",lf="s",mf="si",uf="kbit",df="kB",cf=" ",hf="string",xf="0",Rt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function Sr(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:p=X,localeOptions:n={},separator:s=X,spacer:l=cf,symbols:c={},standard:x=X,output:v=hf,fullform:T=!1,fullforms:w=[],exponent:b=-1,roundingMethod:P=pf,precision:y=0}={}){let i=b,m=Number(t),f=[],S=0,At=X;x===mf?(o=10,x=Mt):x===Or||x===Mt?o=2:o===2?x=Or:(o=10,x=Mt);let rt=o===10?1e3:1024,_r=T===!0,Lt=m<0,Ft=Math[P];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(sf);if(typeof Ft!==af)throw new TypeError(ff);if(Lt&&(m=-m),(i===-1||isNaN(i))&&(i=Math.floor(Math.log(m)/Math.log(rt)),i<0&&(i=0)),i>8&&(y>0&&(y+=8-i),i=8),v===of)return i;if(m===0)f[0]=0,At=f[1]=Rt.symbol[x][e?Tr:Ar][i];else{S=m/(o===2?Math.pow(2,i*10):Math.pow(1e3,i)),e&&(S=S*8,S>=rt&&i<8&&(S=S/rt,i++));let Q=Math.pow(10,i>0?a:0);f[0]=Ft(S*Q)/Q,f[0]===rt&&i<8&&b===-1&&(f[0]=1,i++),At=f[1]=o===10&&i===1?e?uf:df:Rt.symbol[x][e?Tr:Ar][i]}if(Lt&&(f[0]=-f[0]),y>0&&(f[0]=f[0].toPrecision(y)),f[1]=c[f[1]]||f[1],p===!0?f[0]=f[0].toLocaleString():p.length>0?f[0]=f[0].toLocaleString(p,n):s.length>0&&(f[0]=f[0].toString().replace(Pr,s)),r&&Number.isInteger(f[0])===!1&&a>0){let Q=s||Pr,Nt=f[0].toString().split(Q),Dt=Nt[1]||X,kt=Dt.length,Ir=a-kt;f[0]=`${Nt[0]}${Q}${Dt.padEnd(kt+Ir,xf)}`}return _r&&(f[1]=w[i]?w[i]:Rt.fullform[x][i]+(e?ef:rf)+(f[0]===1?X:lf)),v===tf?f:v===nf?{value:f[0],symbol:f[1],exponent:i,unit:At}:f.join(l)}var k=class{constructor(e){h(this,"tera");h(this,"id");h(this,"name");h(this,"path");h(this,"parsedName");h(this,"created");h(this,"createdFormatted");h(this,"modified");h(this,"modifiedFormatted");h(this,"accessed");h(this,"accessedFormatted");h(this,"size");h(this,"sizeFormatted");h(this,"mime");if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),this.sizeFormatted=Sr(this.size||0,{spacer:""}),this.createdFormatted=this.created.toLocaleDateString(),this.modifiedFormatted=this.modified.toLocaleDateString(),this.accessedFormatted=this.accessed.toLocaleDateString()}getContents(){return this.tera.getProjectFile(this.path)}setContents(e){return this.tera.setProjectFile(this.path,e)}getRefs(){return this.tera.parseProjectLibrary(this.path)}setRefs(e){return this.tera.setProjectLibrary(this.path,e)}};var Bt=class{constructor(e){h(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});h(this,"events",jr());h(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});h(this,"methods",["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","parseProjectLibrary","setProjectLibrary","uiAlert","uiSplat","uiWindow"]);h(this,"plugins",[]);h(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=Ct();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||Ct(),...Et(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=Ut(r,e,Gt);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(`
|
|
1
|
+
var Er=Object.defineProperty;var Cr=(t,e,r)=>e in t?Er(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var h=(t,e,r)=>(Cr(t,typeof e!="symbol"?e+"":e,r),r);function Ut(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:l,basePath:c,basePathForRemoves:x,diffs:v}){var T=Object.keys(s),w=T.length,b=Object.keys(l),P=b.length,y,i=s.length-l.length;if(Rr(s,l)){for(var m=0;m<w;m++){var f=Array.isArray(s)?Number(T[m]):T[m];f in l||(y=x.concat(f),v.remove.push({op:"remove",path:r(y)}))}for(var m=0;m<P;m++){var f=Array.isArray(l)?Number(b[m]):b[m];p({key:f,obj1:s,obj2:l,path:c.concat(f),pathForRemoves:c.concat(f),diffs:v})}}else{for(var m=0;m<i;m++)y=x.concat(m),v.remove.push({op:"remove",path:r(y)});for(var S=s.slice(i),m=0;m<P;m++)p({key:m,obj1:S,obj2:l,path:c.concat(m),pathForRemoves:c.concat(m+i),diffs:v})}}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 p({key:s,obj1:l,obj2:c,path:x,pathForRemoves:v,diffs:T}){var w=l[s],b=c[s];if(!(s in l)&&s in c){var P=b;T.add.push({op:"add",path:r(x),value:P})}else w!==b&&(Object(w)!==w||Object(b)!==b||Mr(w,b)||!Object.keys(w).length&&!Object.keys(b).length&&String(w)!=String(b)?n(x,T,b):o({obj1:l[s],obj2:c[s],basePath:x,basePathForRemoves:v,diffs:T}))}function n(s,l,c){l.replace.push({op:"replace",path:r(s),value:c})}}function Gt(t){return[""].concat(t).join("/")}function Mr(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function Rr(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,p=0;p<e.length&&String(t[p])===String(e[p]);p++)o++;for(var n=e.length;n>0&&String(t[n+r])===String(e[n]);n--)a++;return o>=a}return!0}var Br=typeof global=="object"&&global&&global.Object===Object&&global,ot=Br;var Lr=typeof self=="object"&&self&&self.Object===Object&&self,Fr=ot||Lr||Function("return this")(),g=Fr;var Nr=g.Symbol,_=Nr;var Kt=Object.prototype,Dr=Kt.hasOwnProperty,kr=Kt.toString,tt=_?_.toStringTag:void 0;function Ur(t){var e=Dr.call(t,tt),r=t[tt];try{t[tt]=void 0;var o=!0}catch{}var a=kr.call(t);return o&&(e?t[tt]=r:delete t[tt]),a}var Wt=Ur;var Gr=Object.prototype,Kr=Gr.toString;function Wr(t){return Kr.call(t)}var zt=Wr;var zr="[object Null]",Vr="[object Undefined]",Vt=_?_.toStringTag:void 0;function qr(t){return t==null?t===void 0?Vr:zr:Vt&&Vt in Object(t)?Wt(t):zt(t)}var I=qr;function Hr(t){return t!=null&&typeof t=="object"}var A=Hr;var $r=Array.isArray,U=$r;function Yr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var O=Yr;var Zr="[object AsyncFunction]",Jr="[object Function]",Xr="[object GeneratorFunction]",Qr="[object Proxy]";function to(t){if(!O(t))return!1;var e=I(t);return e==Jr||e==Xr||e==Zr||e==Qr}var at=to;var eo=g["__core-js_shared__"],st=eo;var qt=function(){var t=/[^.]+$/.exec(st&&st.keys&&st.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function ro(t){return!!qt&&qt in t}var Ht=ro;var oo=Function.prototype,ao=oo.toString;function so(t){if(t!=null){try{return ao.call(t)}catch{}try{return t+""}catch{}}return""}var E=so;var io=/[\\^$.*+?()[\]{}|]/g,fo=/^\[object .+?Constructor\]$/,no=Function.prototype,po=Object.prototype,lo=no.toString,mo=po.hasOwnProperty,uo=RegExp("^"+lo.call(mo).replace(io,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function co(t){if(!O(t)||Ht(t))return!1;var e=at(t)?uo:fo;return e.test(E(t))}var $t=co;function ho(t,e){return t==null?void 0:t[e]}var Yt=ho;function xo(t,e){var r=Yt(t,e);return $t(r)?r:void 0}var j=xo;var go=j(g,"WeakMap"),it=go;var Zt=Object.create,bo=function(){function t(){}return function(e){if(!O(e))return{};if(Zt)return Zt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Jt=bo;function yo(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Xt=yo;var vo=function(){try{var t=j(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Ot=vo;function wo(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Qt=wo;var jo=9007199254740991,To=/^(?:0|[1-9]\d*)$/;function Ao(t,e){var r=typeof t;return e=e==null?jo:e,!!e&&(r=="number"||r!="symbol"&&To.test(t))&&t>-1&&t%1==0&&t<e}var te=Ao;function Oo(t,e,r){e=="__proto__"&&Ot?Ot(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var ft=Oo;function Po(t,e){return t===e||t!==t&&e!==e}var nt=Po;var So=Object.prototype,_o=So.hasOwnProperty;function Io(t,e,r){var o=t[e];(!(_o.call(t,e)&&nt(o,r))||r===void 0&&!(e in t))&&ft(t,e,r)}var pt=Io;function Eo(t,e,r,o){var a=!r;r||(r={});for(var p=-1,n=e.length;++p<n;){var s=e[p],l=o?o(r[s],t[s],s,r,t):void 0;l===void 0&&(l=t[s]),a?ft(r,s,l):pt(r,s,l)}return r}var R=Eo;var Co=9007199254740991;function Mo(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Co}var lt=Mo;function Ro(t){return t!=null&<(t.length)&&!at(t)}var mt=Ro;var Bo=Object.prototype;function Lo(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Bo;return t===r}var G=Lo;function Fo(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var ee=Fo;var No="[object Arguments]";function Do(t){return A(t)&&I(t)==No}var Pt=Do;var re=Object.prototype,ko=re.hasOwnProperty,Uo=re.propertyIsEnumerable,Go=Pt(function(){return arguments}())?Pt:function(t){return A(t)&&ko.call(t,"callee")&&!Uo.call(t,"callee")},oe=Go;function Ko(){return!1}var ae=Ko;var fe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,se=fe&&typeof module=="object"&&module&&!module.nodeType&&module,Wo=se&&se.exports===fe,ie=Wo?g.Buffer:void 0,zo=ie?ie.isBuffer:void 0,Vo=zo||ae,ut=Vo;var qo="[object Arguments]",Ho="[object Array]",$o="[object Boolean]",Yo="[object Date]",Zo="[object Error]",Jo="[object Function]",Xo="[object Map]",Qo="[object Number]",ta="[object Object]",ea="[object RegExp]",ra="[object Set]",oa="[object String]",aa="[object WeakMap]",sa="[object ArrayBuffer]",ia="[object DataView]",fa="[object Float32Array]",na="[object Float64Array]",pa="[object Int8Array]",la="[object Int16Array]",ma="[object Int32Array]",ua="[object Uint8Array]",da="[object Uint8ClampedArray]",ca="[object Uint16Array]",ha="[object Uint32Array]",d={};d[fa]=d[na]=d[pa]=d[la]=d[ma]=d[ua]=d[da]=d[ca]=d[ha]=!0;d[qo]=d[Ho]=d[sa]=d[$o]=d[ia]=d[Yo]=d[Zo]=d[Jo]=d[Xo]=d[Qo]=d[ta]=d[ea]=d[ra]=d[oa]=d[aa]=!1;function xa(t){return A(t)&<(t.length)&&!!d[I(t)]}var ne=xa;function ga(t){return function(e){return t(e)}}var K=ga;var pe=typeof exports=="object"&&exports&&!exports.nodeType&&exports,et=pe&&typeof module=="object"&&module&&!module.nodeType&&module,ba=et&&et.exports===pe,St=ba&&ot.process,ya=function(){try{var t=et&&et.require&&et.require("util").types;return t||St&&St.binding&&St.binding("util")}catch{}}(),C=ya;var le=C&&C.isTypedArray,va=le?K(le):ne,me=va;var wa=Object.prototype,ja=wa.hasOwnProperty;function Ta(t,e){var r=U(t),o=!r&&oe(t),a=!r&&!o&&ut(t),p=!r&&!o&&!a&&me(t),n=r||o||a||p,s=n?ee(t.length,String):[],l=s.length;for(var c in t)(e||ja.call(t,c))&&!(n&&(c=="length"||a&&(c=="offset"||c=="parent")||p&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||te(c,l)))&&s.push(c);return s}var dt=Ta;function Aa(t,e){return function(r){return t(e(r))}}var ct=Aa;var Oa=ct(Object.keys,Object),ue=Oa;var Pa=Object.prototype,Sa=Pa.hasOwnProperty;function _a(t){if(!G(t))return ue(t);var e=[];for(var r in Object(t))Sa.call(t,r)&&r!="constructor"&&e.push(r);return e}var de=_a;function Ia(t){return mt(t)?dt(t):de(t)}var W=Ia;function Ea(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var ce=Ea;var Ca=Object.prototype,Ma=Ca.hasOwnProperty;function Ra(t){if(!O(t))return ce(t);var e=G(t),r=[];for(var o in t)o=="constructor"&&(e||!Ma.call(t,o))||r.push(o);return r}var he=Ra;function Ba(t){return mt(t)?dt(t,!0):he(t)}var z=Ba;var La=j(Object,"create"),M=La;function Fa(){this.__data__=M?M(null):{},this.size=0}var xe=Fa;function Na(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var ge=Na;var Da="__lodash_hash_undefined__",ka=Object.prototype,Ua=ka.hasOwnProperty;function Ga(t){var e=this.__data__;if(M){var r=e[t];return r===Da?void 0:r}return Ua.call(e,t)?e[t]:void 0}var be=Ga;var Ka=Object.prototype,Wa=Ka.hasOwnProperty;function za(t){var e=this.__data__;return M?e[t]!==void 0:Wa.call(e,t)}var ye=za;var Va="__lodash_hash_undefined__";function qa(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=M&&e===void 0?Va:e,this}var ve=qa;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=xe;V.prototype.delete=ge;V.prototype.get=be;V.prototype.has=ye;V.prototype.set=ve;var _t=V;function Ha(){this.__data__=[],this.size=0}var we=Ha;function $a(t,e){for(var r=t.length;r--;)if(nt(t[r][0],e))return r;return-1}var B=$a;var Ya=Array.prototype,Za=Ya.splice;function Ja(t){var e=this.__data__,r=B(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Za.call(e,r,1),--this.size,!0}var je=Ja;function Xa(t){var e=this.__data__,r=B(e,t);return r<0?void 0:e[r][1]}var Te=Xa;function Qa(t){return B(this.__data__,t)>-1}var Ae=Qa;function ts(t,e){var r=this.__data__,o=B(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Oe=ts;function q(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])}}q.prototype.clear=we;q.prototype.delete=je;q.prototype.get=Te;q.prototype.has=Ae;q.prototype.set=Oe;var L=q;var es=j(g,"Map"),F=es;function rs(){this.size=0,this.__data__={hash:new _t,map:new(F||L),string:new _t}}var Pe=rs;function os(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Se=os;function as(t,e){var r=t.__data__;return Se(e)?r[typeof e=="string"?"string":"hash"]:r.map}var N=as;function ss(t){var e=N(this,t).delete(t);return this.size-=e?1:0,e}var _e=ss;function is(t){return N(this,t).get(t)}var Ie=is;function fs(t){return N(this,t).has(t)}var Ee=fs;function ns(t,e){var r=N(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ce=ns;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=Pe;H.prototype.delete=_e;H.prototype.get=Ie;H.prototype.has=Ee;H.prototype.set=Ce;var Me=H;function ps(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var ht=ps;var ls=ct(Object.getPrototypeOf,Object),xt=ls;function ms(){this.__data__=new L,this.size=0}var Re=ms;function us(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var Be=us;function ds(t){return this.__data__.get(t)}var Le=ds;function cs(t){return this.__data__.has(t)}var Fe=cs;var hs=200;function xs(t,e){var r=this.__data__;if(r instanceof L){var o=r.__data__;if(!F||o.length<hs-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new Me(o)}return r.set(t,e),this.size=r.size,this}var Ne=xs;function $(t){var e=this.__data__=new L(t);this.size=e.size}$.prototype.clear=Re;$.prototype.delete=Be;$.prototype.get=Le;$.prototype.has=Fe;$.prototype.set=Ne;var De=$;function gs(t,e){return t&&R(e,W(e),t)}var ke=gs;function bs(t,e){return t&&R(e,z(e),t)}var Ue=bs;var ze=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ge=ze&&typeof module=="object"&&module&&!module.nodeType&&module,ys=Ge&&Ge.exports===ze,Ke=ys?g.Buffer:void 0,We=Ke?Ke.allocUnsafe:void 0;function vs(t,e){if(e)return t.slice();var r=t.length,o=We?We(r):new t.constructor(r);return t.copy(o),o}var Ve=vs;function ws(t,e){for(var r=-1,o=t==null?0:t.length,a=0,p=[];++r<o;){var n=t[r];e(n,r,t)&&(p[a++]=n)}return p}var qe=ws;function js(){return[]}var gt=js;var Ts=Object.prototype,As=Ts.propertyIsEnumerable,He=Object.getOwnPropertySymbols,Os=He?function(t){return t==null?[]:(t=Object(t),qe(He(t),function(e){return As.call(t,e)}))}:gt,Y=Os;function Ps(t,e){return R(t,Y(t),e)}var $e=Ps;var Ss=Object.getOwnPropertySymbols,_s=Ss?function(t){for(var e=[];t;)ht(e,Y(t)),t=xt(t);return e}:gt,bt=_s;function Is(t,e){return R(t,bt(t),e)}var Ye=Is;function Es(t,e,r){var o=e(t);return U(t)?o:ht(o,r(t))}var yt=Es;function Cs(t){return yt(t,W,Y)}var Ze=Cs;function Ms(t){return yt(t,z,bt)}var Je=Ms;var Rs=j(g,"DataView"),vt=Rs;var Bs=j(g,"Promise"),wt=Bs;var Ls=j(g,"Set"),jt=Ls;var Xe="[object Map]",Fs="[object Object]",Qe="[object Promise]",tr="[object Set]",er="[object WeakMap]",rr="[object DataView]",Ns=E(vt),Ds=E(F),ks=E(wt),Us=E(jt),Gs=E(it),D=I;(vt&&D(new vt(new ArrayBuffer(1)))!=rr||F&&D(new F)!=Xe||wt&&D(wt.resolve())!=Qe||jt&&D(new jt)!=tr||it&&D(new it)!=er)&&(D=function(t){var e=I(t),r=e==Fs?t.constructor:void 0,o=r?E(r):"";if(o)switch(o){case Ns:return rr;case Ds:return Xe;case ks:return Qe;case Us:return tr;case Gs:return er}return e});var Z=D;var Ks=Object.prototype,Ws=Ks.hasOwnProperty;function zs(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 or=zs;var Vs=g.Uint8Array,It=Vs;function qs(t){var e=new t.constructor(t.byteLength);return new It(e).set(new It(t)),e}var J=qs;function Hs(t,e){var r=e?J(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var ar=Hs;var $s=/\w*$/;function Ys(t){var e=new t.constructor(t.source,$s.exec(t));return e.lastIndex=t.lastIndex,e}var sr=Ys;var ir=_?_.prototype:void 0,fr=ir?ir.valueOf:void 0;function Zs(t){return fr?Object(fr.call(t)):{}}var nr=Zs;function Js(t,e){var r=e?J(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var pr=Js;var Xs="[object Boolean]",Qs="[object Date]",ti="[object Map]",ei="[object Number]",ri="[object RegExp]",oi="[object Set]",ai="[object String]",si="[object Symbol]",ii="[object ArrayBuffer]",fi="[object DataView]",ni="[object Float32Array]",pi="[object Float64Array]",li="[object Int8Array]",mi="[object Int16Array]",ui="[object Int32Array]",di="[object Uint8Array]",ci="[object Uint8ClampedArray]",hi="[object Uint16Array]",xi="[object Uint32Array]";function gi(t,e,r){var o=t.constructor;switch(e){case ii:return J(t);case Xs:case Qs:return new o(+t);case fi:return ar(t,r);case ni:case pi:case li:case mi:case ui:case di:case ci:case hi:case xi:return pr(t,r);case ti:return new o;case ei:case ai:return new o(t);case ri:return sr(t);case oi:return new o;case si:return nr(t)}}var lr=gi;function bi(t){return typeof t.constructor=="function"&&!G(t)?Jt(xt(t)):{}}var mr=bi;var yi="[object Map]";function vi(t){return A(t)&&Z(t)==yi}var ur=vi;var dr=C&&C.isMap,wi=dr?K(dr):ur,cr=wi;var ji="[object Set]";function Ti(t){return A(t)&&Z(t)==ji}var hr=Ti;var xr=C&&C.isSet,Ai=xr?K(xr):hr,gr=Ai;var Oi=1,Pi=2,Si=4,br="[object Arguments]",_i="[object Array]",Ii="[object Boolean]",Ei="[object Date]",Ci="[object Error]",yr="[object Function]",Mi="[object GeneratorFunction]",Ri="[object Map]",Bi="[object Number]",vr="[object Object]",Li="[object RegExp]",Fi="[object Set]",Ni="[object String]",Di="[object Symbol]",ki="[object WeakMap]",Ui="[object ArrayBuffer]",Gi="[object DataView]",Ki="[object Float32Array]",Wi="[object Float64Array]",zi="[object Int8Array]",Vi="[object Int16Array]",qi="[object Int32Array]",Hi="[object Uint8Array]",$i="[object Uint8ClampedArray]",Yi="[object Uint16Array]",Zi="[object Uint32Array]",u={};u[br]=u[_i]=u[Ui]=u[Gi]=u[Ii]=u[Ei]=u[Ki]=u[Wi]=u[zi]=u[Vi]=u[qi]=u[Ri]=u[Bi]=u[vr]=u[Li]=u[Fi]=u[Ni]=u[Di]=u[Hi]=u[$i]=u[Yi]=u[Zi]=!0;u[Ci]=u[yr]=u[ki]=!1;function Tt(t,e,r,o,a,p){var n,s=e&Oi,l=e&Pi,c=e&Si;if(r&&(n=a?r(t,o,a,p):r(t)),n!==void 0)return n;if(!O(t))return t;var x=U(t);if(x){if(n=or(t),!s)return Xt(t,n)}else{var v=Z(t),T=v==yr||v==Mi;if(ut(t))return Ve(t,s);if(v==vr||v==br||T&&!a){if(n=l||T?{}:mr(t),!s)return l?Ye(t,Ue(n,t)):$e(t,ke(n,t))}else{if(!u[v])return a?t:{};n=lr(t,v,s)}}p||(p=new De);var w=p.get(t);if(w)return w;p.set(t,n),gr(t)?t.forEach(function(y){n.add(Tt(y,e,r,y,t,p))}):cr(t)&&t.forEach(function(y,i){n.set(i,Tt(y,e,r,i,t,p))});var b=c?l?Je:Ze:l?z:W,P=x?void 0:b(t);return Qt(P||t,function(y,i){P&&(i=y,y=t[i]),pt(n,i,Tt(y,e,r,i,t,p))}),n}var wr=Tt;var Ji=1,Xi=4;function Qi(t){return wr(t,Ji|Xi)}var Et=Qi;function jr(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 Ct=(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 tf="array",ef="bit",Tr="bits",rf="byte",Ar="bytes",X="",of="exponent",af="function",Or="iec",sf="Invalid number",ff="Invalid rounding method",Mt="jedec",nf="object",Pr=".",pf="round",lf="s",mf="si",uf="kbit",df="kB",cf=" ",hf="string",xf="0",Rt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function Sr(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:p=X,localeOptions:n={},separator:s=X,spacer:l=cf,symbols:c={},standard:x=X,output:v=hf,fullform:T=!1,fullforms:w=[],exponent:b=-1,roundingMethod:P=pf,precision:y=0}={}){let i=b,m=Number(t),f=[],S=0,At=X;x===mf?(o=10,x=Mt):x===Or||x===Mt?o=2:o===2?x=Or:(o=10,x=Mt);let rt=o===10?1e3:1024,_r=T===!0,Lt=m<0,Ft=Math[P];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(sf);if(typeof Ft!==af)throw new TypeError(ff);if(Lt&&(m=-m),(i===-1||isNaN(i))&&(i=Math.floor(Math.log(m)/Math.log(rt)),i<0&&(i=0)),i>8&&(y>0&&(y+=8-i),i=8),v===of)return i;if(m===0)f[0]=0,At=f[1]=Rt.symbol[x][e?Tr:Ar][i];else{S=m/(o===2?Math.pow(2,i*10):Math.pow(1e3,i)),e&&(S=S*8,S>=rt&&i<8&&(S=S/rt,i++));let Q=Math.pow(10,i>0?a:0);f[0]=Ft(S*Q)/Q,f[0]===rt&&i<8&&b===-1&&(f[0]=1,i++),At=f[1]=o===10&&i===1?e?uf:df:Rt.symbol[x][e?Tr:Ar][i]}if(Lt&&(f[0]=-f[0]),y>0&&(f[0]=f[0].toPrecision(y)),f[1]=c[f[1]]||f[1],p===!0?f[0]=f[0].toLocaleString():p.length>0?f[0]=f[0].toLocaleString(p,n):s.length>0&&(f[0]=f[0].toString().replace(Pr,s)),r&&Number.isInteger(f[0])===!1&&a>0){let Q=s||Pr,Nt=f[0].toString().split(Q),Dt=Nt[1]||X,kt=Dt.length,Ir=a-kt;f[0]=`${Nt[0]}${Q}${Dt.padEnd(kt+Ir,xf)}`}return _r&&(f[1]=w[i]?w[i]:Rt.fullform[x][i]+(e?ef:rf)+(f[0]===1?X:lf)),v===tf?f:v===nf?{value:f[0],symbol:f[1],exponent:i,unit:At}:f.join(l)}var k=class{constructor(e){h(this,"tera");h(this,"id");h(this,"name");h(this,"path");h(this,"parsedName");h(this,"created");h(this,"createdFormatted");h(this,"modified");h(this,"modifiedFormatted");h(this,"accessed");h(this,"accessedFormatted");h(this,"size");h(this,"sizeFormatted");h(this,"mime");if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),this.sizeFormatted=Sr(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(){return this.tera.getProjectFile(this.path)}setContents(e){return this.tera.setProjectFile(this.path,e)}getRefs(){return this.tera.getProjectLibrary(this.path)}setRefs(e){return this.tera.setProjectLibrary(this.path,e)}};var Bt=class{constructor(e){h(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});h(this,"events",jr());h(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});h(this,"methods",["handshake","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","saveProjectState","replaceProjectState","applyProjectStatePatch","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","uiAlert","uiSplat","uiWindow"]);h(this,"plugins",[]);h(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=Ct();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||Ct(),...Et(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&&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=Ut(r,e,Gt);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
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)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new k({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new k({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new k({tera:this,...r}))}};export{Bt as default};
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
package/dist/terafy.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function kt(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:l,basePath:c,basePathForRemoves:h,diffs:y}){var j=Object.keys(s),v=j.length,g=Object.keys(l),O=g.length,b,i=s.length-l.length;if(Er(s,l)){for(var m=0;m<v;m++){var f=Array.isArray(s)?Number(j[m]):j[m];f in l||(b=h.concat(f),y.remove.push({op:"remove",path:r(b)}))}for(var m=0;m<O;m++){var f=Array.isArray(l)?Number(g[m]):g[m];p({key:f,obj1:s,obj2:l,path:c.concat(f),pathForRemoves:c.concat(f),diffs:y})}}else{for(var m=0;m<i;m++)b=h.concat(m),y.remove.push({op:"remove",path:r(b)});for(var P=s.slice(i),m=0;m<O;m++)p({key:m,obj1:P,obj2:l,path:c.concat(m),pathForRemoves:c.concat(m+i),diffs:y})}}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 p({key:s,obj1:l,obj2:c,path:h,pathForRemoves:y,diffs:j}){var v=l[s],g=c[s];if(!(s in l)&&s in c){var O=g;j.add.push({op:"add",path:r(h),value:O})}else v!==g&&(Object(v)!==v||Object(g)!==g||Ir(v,g)||!Object.keys(v).length&&!Object.keys(g).length&&String(v)!=String(g)?n(h,j,g):o({obj1:l[s],obj2:c[s],basePath:h,basePathForRemoves:y,diffs:j}))}function n(s,l,c){l.replace.push({op:"replace",path:r(s),value:c})}}function Ut(t){return[""].concat(t).join("/")}function Ir(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function Er(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,p=0;p<e.length&&String(t[p])===String(e[p]);p++)o++;for(var n=e.length;n>0&&String(t[n+r])===String(e[n]);n--)a++;return o>=a}return!0}var Cr=typeof global=="object"&&global&&global.Object===Object&&global,rt=Cr;var Mr=typeof self=="object"&&self&&self.Object===Object&&self,Rr=rt||Mr||Function("return this")(),x=Rr;var Br=x.Symbol,S=Br;var Gt=Object.prototype,Lr=Gt.hasOwnProperty,Fr=Gt.toString,Q=S?S.toStringTag:void 0;function Nr(t){var e=Lr.call(t,Q),r=t[Q];try{t[Q]=void 0;var o=!0}catch{}var a=Fr.call(t);return o&&(e?t[Q]=r:delete t[Q]),a}var Kt=Nr;var Dr=Object.prototype,kr=Dr.toString;function Ur(t){return kr.call(t)}var Wt=Ur;var Gr="[object Null]",Kr="[object Undefined]",zt=S?S.toStringTag:void 0;function Wr(t){return t==null?t===void 0?Kr:Gr:zt&&zt in Object(t)?Kt(t):Wt(t)}var _=Wr;function zr(t){return t!=null&&typeof t=="object"}var T=zr;var Vr=Array.isArray,k=Vr;function qr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var A=qr;var Hr="[object AsyncFunction]",$r="[object Function]",Yr="[object GeneratorFunction]",Zr="[object Proxy]";function Jr(t){if(!A(t))return!1;var e=_(t);return e==$r||e==Yr||e==Hr||e==Zr}var ot=Jr;var Xr=x["__core-js_shared__"],at=Xr;var Vt=function(){var t=/[^.]+$/.exec(at&&at.keys&&at.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Qr(t){return!!Vt&&Vt in t}var qt=Qr;var to=Function.prototype,eo=to.toString;function ro(t){if(t!=null){try{return eo.call(t)}catch{}try{return t+""}catch{}}return""}var I=ro;var oo=/[\\^$.*+?()[\]{}|]/g,ao=/^\[object .+?Constructor\]$/,so=Function.prototype,io=Object.prototype,fo=so.toString,no=io.hasOwnProperty,po=RegExp("^"+fo.call(no).replace(oo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function lo(t){if(!A(t)||qt(t))return!1;var e=ot(t)?po:ao;return e.test(I(t))}var Ht=lo;function mo(t,e){return t?.[e]}var $t=mo;function uo(t,e){var r=$t(t,e);return Ht(r)?r:void 0}var w=uo;var co=w(x,"WeakMap"),st=co;var Yt=Object.create,ho=function(){function t(){}return function(e){if(!A(e))return{};if(Yt)return Yt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Zt=ho;function xo(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Jt=xo;var go=function(){try{var t=w(Object,"defineProperty");return t({},"",{}),t}catch{}}(),At=go;function bo(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Xt=bo;var yo=9007199254740991,vo=/^(?:0|[1-9]\d*)$/;function wo(t,e){var r=typeof t;return e=e??yo,!!e&&(r=="number"||r!="symbol"&&vo.test(t))&&t>-1&&t%1==0&&t<e}var Qt=wo;function jo(t,e,r){e=="__proto__"&&At?At(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var it=jo;function To(t,e){return t===e||t!==t&&e!==e}var ft=To;var Ao=Object.prototype,Oo=Ao.hasOwnProperty;function Po(t,e,r){var o=t[e];(!(Oo.call(t,e)&&ft(o,r))||r===void 0&&!(e in t))&&it(t,e,r)}var nt=Po;function So(t,e,r,o){var a=!r;r||(r={});for(var p=-1,n=e.length;++p<n;){var s=e[p],l=o?o(r[s],t[s],s,r,t):void 0;l===void 0&&(l=t[s]),a?it(r,s,l):nt(r,s,l)}return r}var M=So;var _o=9007199254740991;function Io(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=_o}var pt=Io;function Eo(t){return t!=null&&pt(t.length)&&!ot(t)}var lt=Eo;var Co=Object.prototype;function Mo(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Co;return t===r}var U=Mo;function Ro(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var te=Ro;var Bo="[object Arguments]";function Lo(t){return T(t)&&_(t)==Bo}var Ot=Lo;var ee=Object.prototype,Fo=ee.hasOwnProperty,No=ee.propertyIsEnumerable,Do=Ot(function(){return arguments}())?Ot:function(t){return T(t)&&Fo.call(t,"callee")&&!No.call(t,"callee")},re=Do;function ko(){return!1}var oe=ko;var ie=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ae=ie&&typeof module=="object"&&module&&!module.nodeType&&module,Uo=ae&&ae.exports===ie,se=Uo?x.Buffer:void 0,Go=se?se.isBuffer:void 0,Ko=Go||oe,mt=Ko;var Wo="[object Arguments]",zo="[object Array]",Vo="[object Boolean]",qo="[object Date]",Ho="[object Error]",$o="[object Function]",Yo="[object Map]",Zo="[object Number]",Jo="[object Object]",Xo="[object RegExp]",Qo="[object Set]",ta="[object String]",ea="[object WeakMap]",ra="[object ArrayBuffer]",oa="[object DataView]",aa="[object Float32Array]",sa="[object Float64Array]",ia="[object Int8Array]",fa="[object Int16Array]",na="[object Int32Array]",pa="[object Uint8Array]",la="[object Uint8ClampedArray]",ma="[object Uint16Array]",ua="[object Uint32Array]",d={};d[aa]=d[sa]=d[ia]=d[fa]=d[na]=d[pa]=d[la]=d[ma]=d[ua]=!0;d[Wo]=d[zo]=d[ra]=d[Vo]=d[oa]=d[qo]=d[Ho]=d[$o]=d[Yo]=d[Zo]=d[Jo]=d[Xo]=d[Qo]=d[ta]=d[ea]=!1;function da(t){return T(t)&&pt(t.length)&&!!d[_(t)]}var fe=da;function ca(t){return function(e){return t(e)}}var G=ca;var ne=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tt=ne&&typeof module=="object"&&module&&!module.nodeType&&module,ha=tt&&tt.exports===ne,Pt=ha&&rt.process,xa=function(){try{var t=tt&&tt.require&&tt.require("util").types;return t||Pt&&Pt.binding&&Pt.binding("util")}catch{}}(),E=xa;var pe=E&&E.isTypedArray,ga=pe?G(pe):fe,le=ga;var ba=Object.prototype,ya=ba.hasOwnProperty;function va(t,e){var r=k(t),o=!r&&re(t),a=!r&&!o&&mt(t),p=!r&&!o&&!a&&le(t),n=r||o||a||p,s=n?te(t.length,String):[],l=s.length;for(var c in t)(e||ya.call(t,c))&&!(n&&(c=="length"||a&&(c=="offset"||c=="parent")||p&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Qt(c,l)))&&s.push(c);return s}var ut=va;function wa(t,e){return function(r){return t(e(r))}}var dt=wa;var ja=dt(Object.keys,Object),me=ja;var Ta=Object.prototype,Aa=Ta.hasOwnProperty;function Oa(t){if(!U(t))return me(t);var e=[];for(var r in Object(t))Aa.call(t,r)&&r!="constructor"&&e.push(r);return e}var ue=Oa;function Pa(t){return lt(t)?ut(t):ue(t)}var K=Pa;function Sa(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var de=Sa;var _a=Object.prototype,Ia=_a.hasOwnProperty;function Ea(t){if(!A(t))return de(t);var e=U(t),r=[];for(var o in t)o=="constructor"&&(e||!Ia.call(t,o))||r.push(o);return r}var ce=Ea;function Ca(t){return lt(t)?ut(t,!0):ce(t)}var W=Ca;var Ma=w(Object,"create"),C=Ma;function Ra(){this.__data__=C?C(null):{},this.size=0}var he=Ra;function Ba(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var xe=Ba;var La="__lodash_hash_undefined__",Fa=Object.prototype,Na=Fa.hasOwnProperty;function Da(t){var e=this.__data__;if(C){var r=e[t];return r===La?void 0:r}return Na.call(e,t)?e[t]:void 0}var ge=Da;var ka=Object.prototype,Ua=ka.hasOwnProperty;function Ga(t){var e=this.__data__;return C?e[t]!==void 0:Ua.call(e,t)}var be=Ga;var Ka="__lodash_hash_undefined__";function Wa(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=C&&e===void 0?Ka:e,this}var ye=Wa;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=he;z.prototype.delete=xe;z.prototype.get=ge;z.prototype.has=be;z.prototype.set=ye;var St=z;function za(){this.__data__=[],this.size=0}var ve=za;function Va(t,e){for(var r=t.length;r--;)if(ft(t[r][0],e))return r;return-1}var R=Va;var qa=Array.prototype,Ha=qa.splice;function $a(t){var e=this.__data__,r=R(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Ha.call(e,r,1),--this.size,!0}var we=$a;function Ya(t){var e=this.__data__,r=R(e,t);return r<0?void 0:e[r][1]}var je=Ya;function Za(t){return R(this.__data__,t)>-1}var Te=Za;function Ja(t,e){var r=this.__data__,o=R(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Ae=Ja;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=ve;V.prototype.delete=we;V.prototype.get=je;V.prototype.has=Te;V.prototype.set=Ae;var B=V;var Xa=w(x,"Map"),L=Xa;function Qa(){this.size=0,this.__data__={hash:new St,map:new(L||B),string:new St}}var Oe=Qa;function ts(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Pe=ts;function es(t,e){var r=t.__data__;return Pe(e)?r[typeof e=="string"?"string":"hash"]:r.map}var F=es;function rs(t){var e=F(this,t).delete(t);return this.size-=e?1:0,e}var Se=rs;function os(t){return F(this,t).get(t)}var _e=os;function as(t){return F(this,t).has(t)}var Ie=as;function ss(t,e){var r=F(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ee=ss;function q(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])}}q.prototype.clear=Oe;q.prototype.delete=Se;q.prototype.get=_e;q.prototype.has=Ie;q.prototype.set=Ee;var Ce=q;function is(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var ct=is;var fs=dt(Object.getPrototypeOf,Object),ht=fs;function ns(){this.__data__=new B,this.size=0}var Me=ns;function ps(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var Re=ps;function ls(t){return this.__data__.get(t)}var Be=ls;function ms(t){return this.__data__.has(t)}var Le=ms;var us=200;function ds(t,e){var r=this.__data__;if(r instanceof B){var o=r.__data__;if(!L||o.length<us-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 Fe=ds;function H(t){var e=this.__data__=new B(t);this.size=e.size}H.prototype.clear=Me;H.prototype.delete=Re;H.prototype.get=Be;H.prototype.has=Le;H.prototype.set=Fe;var Ne=H;function cs(t,e){return t&&M(e,K(e),t)}var De=cs;function hs(t,e){return t&&M(e,W(e),t)}var ke=hs;var We=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ue=We&&typeof module=="object"&&module&&!module.nodeType&&module,xs=Ue&&Ue.exports===We,Ge=xs?x.Buffer:void 0,Ke=Ge?Ge.allocUnsafe:void 0;function gs(t,e){if(e)return t.slice();var r=t.length,o=Ke?Ke(r):new t.constructor(r);return t.copy(o),o}var ze=gs;function bs(t,e){for(var r=-1,o=t==null?0:t.length,a=0,p=[];++r<o;){var n=t[r];e(n,r,t)&&(p[a++]=n)}return p}var Ve=bs;function ys(){return[]}var xt=ys;var vs=Object.prototype,ws=vs.propertyIsEnumerable,qe=Object.getOwnPropertySymbols,js=qe?function(t){return t==null?[]:(t=Object(t),Ve(qe(t),function(e){return ws.call(t,e)}))}:xt,$=js;function Ts(t,e){return M(t,$(t),e)}var He=Ts;var As=Object.getOwnPropertySymbols,Os=As?function(t){for(var e=[];t;)ct(e,$(t)),t=ht(t);return e}:xt,gt=Os;function Ps(t,e){return M(t,gt(t),e)}var $e=Ps;function Ss(t,e,r){var o=e(t);return k(t)?o:ct(o,r(t))}var bt=Ss;function _s(t){return bt(t,K,$)}var Ye=_s;function Is(t){return bt(t,W,gt)}var Ze=Is;var Es=w(x,"DataView"),yt=Es;var Cs=w(x,"Promise"),vt=Cs;var Ms=w(x,"Set"),wt=Ms;var Je="[object Map]",Rs="[object Object]",Xe="[object Promise]",Qe="[object Set]",tr="[object WeakMap]",er="[object DataView]",Bs=I(yt),Ls=I(L),Fs=I(vt),Ns=I(wt),Ds=I(st),N=_;(yt&&N(new yt(new ArrayBuffer(1)))!=er||L&&N(new L)!=Je||vt&&N(vt.resolve())!=Xe||wt&&N(new wt)!=Qe||st&&N(new st)!=tr)&&(N=function(t){var e=_(t),r=e==Rs?t.constructor:void 0,o=r?I(r):"";if(o)switch(o){case Bs:return er;case Ls:return Je;case Fs:return Xe;case Ns:return Qe;case Ds:return tr}return e});var Y=N;var ks=Object.prototype,Us=ks.hasOwnProperty;function Gs(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Us.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var rr=Gs;var Ks=x.Uint8Array,_t=Ks;function Ws(t){var e=new t.constructor(t.byteLength);return new _t(e).set(new _t(t)),e}var Z=Ws;function zs(t,e){var r=e?Z(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var or=zs;var Vs=/\w*$/;function qs(t){var e=new t.constructor(t.source,Vs.exec(t));return e.lastIndex=t.lastIndex,e}var ar=qs;var sr=S?S.prototype:void 0,ir=sr?sr.valueOf:void 0;function Hs(t){return ir?Object(ir.call(t)):{}}var fr=Hs;function $s(t,e){var r=e?Z(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var nr=$s;var Ys="[object Boolean]",Zs="[object Date]",Js="[object Map]",Xs="[object Number]",Qs="[object RegExp]",ti="[object Set]",ei="[object String]",ri="[object Symbol]",oi="[object ArrayBuffer]",ai="[object DataView]",si="[object Float32Array]",ii="[object Float64Array]",fi="[object Int8Array]",ni="[object Int16Array]",pi="[object Int32Array]",li="[object Uint8Array]",mi="[object Uint8ClampedArray]",ui="[object Uint16Array]",di="[object Uint32Array]";function ci(t,e,r){var o=t.constructor;switch(e){case oi:return Z(t);case Ys:case Zs:return new o(+t);case ai:return or(t,r);case si:case ii:case fi:case ni:case pi:case li:case mi:case ui:case di:return nr(t,r);case Js:return new o;case Xs:case ei:return new o(t);case Qs:return ar(t);case ti:return new o;case ri:return fr(t)}}var pr=ci;function hi(t){return typeof t.constructor=="function"&&!U(t)?Zt(ht(t)):{}}var lr=hi;var xi="[object Map]";function gi(t){return T(t)&&Y(t)==xi}var mr=gi;var ur=E&&E.isMap,bi=ur?G(ur):mr,dr=bi;var yi="[object Set]";function vi(t){return T(t)&&Y(t)==yi}var cr=vi;var hr=E&&E.isSet,wi=hr?G(hr):cr,xr=wi;var ji=1,Ti=2,Ai=4,gr="[object Arguments]",Oi="[object Array]",Pi="[object Boolean]",Si="[object Date]",_i="[object Error]",br="[object Function]",Ii="[object GeneratorFunction]",Ei="[object Map]",Ci="[object Number]",yr="[object Object]",Mi="[object RegExp]",Ri="[object Set]",Bi="[object String]",Li="[object Symbol]",Fi="[object WeakMap]",Ni="[object ArrayBuffer]",Di="[object DataView]",ki="[object Float32Array]",Ui="[object Float64Array]",Gi="[object Int8Array]",Ki="[object Int16Array]",Wi="[object Int32Array]",zi="[object Uint8Array]",Vi="[object Uint8ClampedArray]",qi="[object Uint16Array]",Hi="[object Uint32Array]",u={};u[gr]=u[Oi]=u[Ni]=u[Di]=u[Pi]=u[Si]=u[ki]=u[Ui]=u[Gi]=u[Ki]=u[Wi]=u[Ei]=u[Ci]=u[yr]=u[Mi]=u[Ri]=u[Bi]=u[Li]=u[zi]=u[Vi]=u[qi]=u[Hi]=!0;u[_i]=u[br]=u[Fi]=!1;function jt(t,e,r,o,a,p){var n,s=e&ji,l=e&Ti,c=e&Ai;if(r&&(n=a?r(t,o,a,p):r(t)),n!==void 0)return n;if(!A(t))return t;var h=k(t);if(h){if(n=rr(t),!s)return Jt(t,n)}else{var y=Y(t),j=y==br||y==Ii;if(mt(t))return ze(t,s);if(y==yr||y==gr||j&&!a){if(n=l||j?{}:lr(t),!s)return l?$e(t,ke(n,t)):He(t,De(n,t))}else{if(!u[y])return a?t:{};n=pr(t,y,s)}}p||(p=new Ne);var v=p.get(t);if(v)return v;p.set(t,n),xr(t)?t.forEach(function(b){n.add(jt(b,e,r,b,t,p))}):dr(t)&&t.forEach(function(b,i){n.set(i,jt(b,e,r,i,t,p))});var g=c?l?Ze:Ye:l?W:K,O=h?void 0:g(t);return Xt(O||t,function(b,i){O&&(i=b,b=t[i]),nt(n,i,jt(b,e,r,i,t,p))}),n}var vr=jt;var $i=1,Yi=4;function Zi(t){return vr(t,$i|Yi)}var It=Zi;function wr(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 Et=(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 Ji="array",Xi="bit",jr="bits",Qi="byte",Tr="bytes",J="",tf="exponent",ef="function",Ar="iec",rf="Invalid number",of="Invalid rounding method",Ct="jedec",af="object",Or=".",sf="round",ff="s",nf="si",pf="kbit",lf="kB",mf=" ",uf="string",df="0",Mt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function Pr(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:p=J,localeOptions:n={},separator:s=J,spacer:l=mf,symbols:c={},standard:h=J,output:y=uf,fullform:j=!1,fullforms:v=[],exponent:g=-1,roundingMethod:O=sf,precision:b=0}={}){let i=g,m=Number(t),f=[],P=0,Tt=J;h===nf?(o=10,h=Ct):h===Ar||h===Ct?o=2:o===2?h=Ar:(o=10,h=Ct);let et=o===10?1e3:1024,Sr=j===!0,Bt=m<0,Lt=Math[O];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(rf);if(typeof Lt!==ef)throw new TypeError(of);if(Bt&&(m=-m),(i===-1||isNaN(i))&&(i=Math.floor(Math.log(m)/Math.log(et)),i<0&&(i=0)),i>8&&(b>0&&(b+=8-i),i=8),y===tf)return i;if(m===0)f[0]=0,Tt=f[1]=Mt.symbol[h][e?jr:Tr][i];else{P=m/(o===2?Math.pow(2,i*10):Math.pow(1e3,i)),e&&(P=P*8,P>=et&&i<8&&(P=P/et,i++));let X=Math.pow(10,i>0?a:0);f[0]=Lt(P*X)/X,f[0]===et&&i<8&&g===-1&&(f[0]=1,i++),Tt=f[1]=o===10&&i===1?e?pf:lf:Mt.symbol[h][e?jr:Tr][i]}if(Bt&&(f[0]=-f[0]),b>0&&(f[0]=f[0].toPrecision(b)),f[1]=c[f[1]]||f[1],p===!0?f[0]=f[0].toLocaleString():p.length>0?f[0]=f[0].toLocaleString(p,n):s.length>0&&(f[0]=f[0].toString().replace(Or,s)),r&&Number.isInteger(f[0])===!1&&a>0){let X=s||Or,Ft=f[0].toString().split(X),Nt=Ft[1]||J,Dt=Nt.length,_r=a-Dt;f[0]=`${Ft[0]}${X}${Nt.padEnd(Dt+_r,df)}`}return Sr&&(f[1]=v[i]?v[i]:Mt.fullform[h][i]+(e?Xi:Qi)+(f[0]===1?J:ff)),y===Ji?f:y===af?{value:f[0],symbol:f[1],exponent:i,unit:Tt}:f.join(l)}var D=class{tera;id;name;path;parsedName;created;createdFormatted;modified;modifiedFormatted;accessed;accessedFormatted;size;sizeFormatted;mime;constructor(e){if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),this.sizeFormatted=Pr(this.size||0,{spacer:""}),this.createdFormatted=this.created.toLocaleDateString(),this.modifiedFormatted=this.modified.toLocaleDateString(),this.accessedFormatted=this.accessed.toLocaleDateString()}getContents(){return this.tera.getProjectFile(this.path)}setContents(e){return this.tera.setProjectFile(this.path,e)}getRefs(){return this.tera.parseProjectLibrary(this.path)}setRefs(e){return this.tera.setProjectLibrary(this.path,e)}};var Rt=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=wr();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","setProjectFile","selectProjectLibrary","parseProjectLibrary","setProjectLibrary","uiAlert","uiSplat","uiWindow"];plugins=[];send(e){let r=Et();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||Et(),...It(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=kt(r,e,Ut);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(`
|
|
1
|
+
function kt(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:l,basePath:c,basePathForRemoves:h,diffs:y}){var j=Object.keys(s),v=j.length,g=Object.keys(l),O=g.length,b,i=s.length-l.length;if(Er(s,l)){for(var m=0;m<v;m++){var f=Array.isArray(s)?Number(j[m]):j[m];f in l||(b=h.concat(f),y.remove.push({op:"remove",path:r(b)}))}for(var m=0;m<O;m++){var f=Array.isArray(l)?Number(g[m]):g[m];p({key:f,obj1:s,obj2:l,path:c.concat(f),pathForRemoves:c.concat(f),diffs:y})}}else{for(var m=0;m<i;m++)b=h.concat(m),y.remove.push({op:"remove",path:r(b)});for(var P=s.slice(i),m=0;m<O;m++)p({key:m,obj1:P,obj2:l,path:c.concat(m),pathForRemoves:c.concat(m+i),diffs:y})}}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 p({key:s,obj1:l,obj2:c,path:h,pathForRemoves:y,diffs:j}){var v=l[s],g=c[s];if(!(s in l)&&s in c){var O=g;j.add.push({op:"add",path:r(h),value:O})}else v!==g&&(Object(v)!==v||Object(g)!==g||Ir(v,g)||!Object.keys(v).length&&!Object.keys(g).length&&String(v)!=String(g)?n(h,j,g):o({obj1:l[s],obj2:c[s],basePath:h,basePathForRemoves:y,diffs:j}))}function n(s,l,c){l.replace.push({op:"replace",path:r(s),value:c})}}function Ut(t){return[""].concat(t).join("/")}function Ir(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function Er(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,p=0;p<e.length&&String(t[p])===String(e[p]);p++)o++;for(var n=e.length;n>0&&String(t[n+r])===String(e[n]);n--)a++;return o>=a}return!0}var Cr=typeof global=="object"&&global&&global.Object===Object&&global,rt=Cr;var Mr=typeof self=="object"&&self&&self.Object===Object&&self,Rr=rt||Mr||Function("return this")(),x=Rr;var Br=x.Symbol,S=Br;var Gt=Object.prototype,Lr=Gt.hasOwnProperty,Fr=Gt.toString,Q=S?S.toStringTag:void 0;function Nr(t){var e=Lr.call(t,Q),r=t[Q];try{t[Q]=void 0;var o=!0}catch{}var a=Fr.call(t);return o&&(e?t[Q]=r:delete t[Q]),a}var Kt=Nr;var Dr=Object.prototype,kr=Dr.toString;function Ur(t){return kr.call(t)}var Wt=Ur;var Gr="[object Null]",Kr="[object Undefined]",zt=S?S.toStringTag:void 0;function Wr(t){return t==null?t===void 0?Kr:Gr:zt&&zt in Object(t)?Kt(t):Wt(t)}var _=Wr;function zr(t){return t!=null&&typeof t=="object"}var T=zr;var Vr=Array.isArray,k=Vr;function qr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var A=qr;var Hr="[object AsyncFunction]",$r="[object Function]",Yr="[object GeneratorFunction]",Zr="[object Proxy]";function Jr(t){if(!A(t))return!1;var e=_(t);return e==$r||e==Yr||e==Hr||e==Zr}var ot=Jr;var Xr=x["__core-js_shared__"],at=Xr;var Vt=function(){var t=/[^.]+$/.exec(at&&at.keys&&at.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Qr(t){return!!Vt&&Vt in t}var qt=Qr;var to=Function.prototype,eo=to.toString;function ro(t){if(t!=null){try{return eo.call(t)}catch{}try{return t+""}catch{}}return""}var I=ro;var oo=/[\\^$.*+?()[\]{}|]/g,ao=/^\[object .+?Constructor\]$/,so=Function.prototype,io=Object.prototype,fo=so.toString,no=io.hasOwnProperty,po=RegExp("^"+fo.call(no).replace(oo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function lo(t){if(!A(t)||qt(t))return!1;var e=ot(t)?po:ao;return e.test(I(t))}var Ht=lo;function mo(t,e){return t?.[e]}var $t=mo;function uo(t,e){var r=$t(t,e);return Ht(r)?r:void 0}var w=uo;var co=w(x,"WeakMap"),st=co;var Yt=Object.create,ho=function(){function t(){}return function(e){if(!A(e))return{};if(Yt)return Yt(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Zt=ho;function xo(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var Jt=xo;var go=function(){try{var t=w(Object,"defineProperty");return t({},"",{}),t}catch{}}(),At=go;function bo(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var Xt=bo;var yo=9007199254740991,vo=/^(?:0|[1-9]\d*)$/;function wo(t,e){var r=typeof t;return e=e??yo,!!e&&(r=="number"||r!="symbol"&&vo.test(t))&&t>-1&&t%1==0&&t<e}var Qt=wo;function jo(t,e,r){e=="__proto__"&&At?At(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var it=jo;function To(t,e){return t===e||t!==t&&e!==e}var ft=To;var Ao=Object.prototype,Oo=Ao.hasOwnProperty;function Po(t,e,r){var o=t[e];(!(Oo.call(t,e)&&ft(o,r))||r===void 0&&!(e in t))&&it(t,e,r)}var nt=Po;function So(t,e,r,o){var a=!r;r||(r={});for(var p=-1,n=e.length;++p<n;){var s=e[p],l=o?o(r[s],t[s],s,r,t):void 0;l===void 0&&(l=t[s]),a?it(r,s,l):nt(r,s,l)}return r}var M=So;var _o=9007199254740991;function Io(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=_o}var pt=Io;function Eo(t){return t!=null&&pt(t.length)&&!ot(t)}var lt=Eo;var Co=Object.prototype;function Mo(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Co;return t===r}var U=Mo;function Ro(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var te=Ro;var Bo="[object Arguments]";function Lo(t){return T(t)&&_(t)==Bo}var Ot=Lo;var ee=Object.prototype,Fo=ee.hasOwnProperty,No=ee.propertyIsEnumerable,Do=Ot(function(){return arguments}())?Ot:function(t){return T(t)&&Fo.call(t,"callee")&&!No.call(t,"callee")},re=Do;function ko(){return!1}var oe=ko;var ie=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ae=ie&&typeof module=="object"&&module&&!module.nodeType&&module,Uo=ae&&ae.exports===ie,se=Uo?x.Buffer:void 0,Go=se?se.isBuffer:void 0,Ko=Go||oe,mt=Ko;var Wo="[object Arguments]",zo="[object Array]",Vo="[object Boolean]",qo="[object Date]",Ho="[object Error]",$o="[object Function]",Yo="[object Map]",Zo="[object Number]",Jo="[object Object]",Xo="[object RegExp]",Qo="[object Set]",ta="[object String]",ea="[object WeakMap]",ra="[object ArrayBuffer]",oa="[object DataView]",aa="[object Float32Array]",sa="[object Float64Array]",ia="[object Int8Array]",fa="[object Int16Array]",na="[object Int32Array]",pa="[object Uint8Array]",la="[object Uint8ClampedArray]",ma="[object Uint16Array]",ua="[object Uint32Array]",d={};d[aa]=d[sa]=d[ia]=d[fa]=d[na]=d[pa]=d[la]=d[ma]=d[ua]=!0;d[Wo]=d[zo]=d[ra]=d[Vo]=d[oa]=d[qo]=d[Ho]=d[$o]=d[Yo]=d[Zo]=d[Jo]=d[Xo]=d[Qo]=d[ta]=d[ea]=!1;function da(t){return T(t)&&pt(t.length)&&!!d[_(t)]}var fe=da;function ca(t){return function(e){return t(e)}}var G=ca;var ne=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tt=ne&&typeof module=="object"&&module&&!module.nodeType&&module,ha=tt&&tt.exports===ne,Pt=ha&&rt.process,xa=function(){try{var t=tt&&tt.require&&tt.require("util").types;return t||Pt&&Pt.binding&&Pt.binding("util")}catch{}}(),E=xa;var pe=E&&E.isTypedArray,ga=pe?G(pe):fe,le=ga;var ba=Object.prototype,ya=ba.hasOwnProperty;function va(t,e){var r=k(t),o=!r&&re(t),a=!r&&!o&&mt(t),p=!r&&!o&&!a&&le(t),n=r||o||a||p,s=n?te(t.length,String):[],l=s.length;for(var c in t)(e||ya.call(t,c))&&!(n&&(c=="length"||a&&(c=="offset"||c=="parent")||p&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Qt(c,l)))&&s.push(c);return s}var ut=va;function wa(t,e){return function(r){return t(e(r))}}var dt=wa;var ja=dt(Object.keys,Object),me=ja;var Ta=Object.prototype,Aa=Ta.hasOwnProperty;function Oa(t){if(!U(t))return me(t);var e=[];for(var r in Object(t))Aa.call(t,r)&&r!="constructor"&&e.push(r);return e}var ue=Oa;function Pa(t){return lt(t)?ut(t):ue(t)}var K=Pa;function Sa(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var de=Sa;var _a=Object.prototype,Ia=_a.hasOwnProperty;function Ea(t){if(!A(t))return de(t);var e=U(t),r=[];for(var o in t)o=="constructor"&&(e||!Ia.call(t,o))||r.push(o);return r}var ce=Ea;function Ca(t){return lt(t)?ut(t,!0):ce(t)}var W=Ca;var Ma=w(Object,"create"),C=Ma;function Ra(){this.__data__=C?C(null):{},this.size=0}var he=Ra;function Ba(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var xe=Ba;var La="__lodash_hash_undefined__",Fa=Object.prototype,Na=Fa.hasOwnProperty;function Da(t){var e=this.__data__;if(C){var r=e[t];return r===La?void 0:r}return Na.call(e,t)?e[t]:void 0}var ge=Da;var ka=Object.prototype,Ua=ka.hasOwnProperty;function Ga(t){var e=this.__data__;return C?e[t]!==void 0:Ua.call(e,t)}var be=Ga;var Ka="__lodash_hash_undefined__";function Wa(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=C&&e===void 0?Ka:e,this}var ye=Wa;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=he;z.prototype.delete=xe;z.prototype.get=ge;z.prototype.has=be;z.prototype.set=ye;var St=z;function za(){this.__data__=[],this.size=0}var ve=za;function Va(t,e){for(var r=t.length;r--;)if(ft(t[r][0],e))return r;return-1}var R=Va;var qa=Array.prototype,Ha=qa.splice;function $a(t){var e=this.__data__,r=R(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():Ha.call(e,r,1),--this.size,!0}var we=$a;function Ya(t){var e=this.__data__,r=R(e,t);return r<0?void 0:e[r][1]}var je=Ya;function Za(t){return R(this.__data__,t)>-1}var Te=Za;function Ja(t,e){var r=this.__data__,o=R(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var Ae=Ja;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=ve;V.prototype.delete=we;V.prototype.get=je;V.prototype.has=Te;V.prototype.set=Ae;var B=V;var Xa=w(x,"Map"),L=Xa;function Qa(){this.size=0,this.__data__={hash:new St,map:new(L||B),string:new St}}var Oe=Qa;function ts(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Pe=ts;function es(t,e){var r=t.__data__;return Pe(e)?r[typeof e=="string"?"string":"hash"]:r.map}var F=es;function rs(t){var e=F(this,t).delete(t);return this.size-=e?1:0,e}var Se=rs;function os(t){return F(this,t).get(t)}var _e=os;function as(t){return F(this,t).has(t)}var Ie=as;function ss(t,e){var r=F(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var Ee=ss;function q(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])}}q.prototype.clear=Oe;q.prototype.delete=Se;q.prototype.get=_e;q.prototype.has=Ie;q.prototype.set=Ee;var Ce=q;function is(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var ct=is;var fs=dt(Object.getPrototypeOf,Object),ht=fs;function ns(){this.__data__=new B,this.size=0}var Me=ns;function ps(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var Re=ps;function ls(t){return this.__data__.get(t)}var Be=ls;function ms(t){return this.__data__.has(t)}var Le=ms;var us=200;function ds(t,e){var r=this.__data__;if(r instanceof B){var o=r.__data__;if(!L||o.length<us-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 Fe=ds;function H(t){var e=this.__data__=new B(t);this.size=e.size}H.prototype.clear=Me;H.prototype.delete=Re;H.prototype.get=Be;H.prototype.has=Le;H.prototype.set=Fe;var Ne=H;function cs(t,e){return t&&M(e,K(e),t)}var De=cs;function hs(t,e){return t&&M(e,W(e),t)}var ke=hs;var We=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ue=We&&typeof module=="object"&&module&&!module.nodeType&&module,xs=Ue&&Ue.exports===We,Ge=xs?x.Buffer:void 0,Ke=Ge?Ge.allocUnsafe:void 0;function gs(t,e){if(e)return t.slice();var r=t.length,o=Ke?Ke(r):new t.constructor(r);return t.copy(o),o}var ze=gs;function bs(t,e){for(var r=-1,o=t==null?0:t.length,a=0,p=[];++r<o;){var n=t[r];e(n,r,t)&&(p[a++]=n)}return p}var Ve=bs;function ys(){return[]}var xt=ys;var vs=Object.prototype,ws=vs.propertyIsEnumerable,qe=Object.getOwnPropertySymbols,js=qe?function(t){return t==null?[]:(t=Object(t),Ve(qe(t),function(e){return ws.call(t,e)}))}:xt,$=js;function Ts(t,e){return M(t,$(t),e)}var He=Ts;var As=Object.getOwnPropertySymbols,Os=As?function(t){for(var e=[];t;)ct(e,$(t)),t=ht(t);return e}:xt,gt=Os;function Ps(t,e){return M(t,gt(t),e)}var $e=Ps;function Ss(t,e,r){var o=e(t);return k(t)?o:ct(o,r(t))}var bt=Ss;function _s(t){return bt(t,K,$)}var Ye=_s;function Is(t){return bt(t,W,gt)}var Ze=Is;var Es=w(x,"DataView"),yt=Es;var Cs=w(x,"Promise"),vt=Cs;var Ms=w(x,"Set"),wt=Ms;var Je="[object Map]",Rs="[object Object]",Xe="[object Promise]",Qe="[object Set]",tr="[object WeakMap]",er="[object DataView]",Bs=I(yt),Ls=I(L),Fs=I(vt),Ns=I(wt),Ds=I(st),N=_;(yt&&N(new yt(new ArrayBuffer(1)))!=er||L&&N(new L)!=Je||vt&&N(vt.resolve())!=Xe||wt&&N(new wt)!=Qe||st&&N(new st)!=tr)&&(N=function(t){var e=_(t),r=e==Rs?t.constructor:void 0,o=r?I(r):"";if(o)switch(o){case Bs:return er;case Ls:return Je;case Fs:return Xe;case Ns:return Qe;case Ds:return tr}return e});var Y=N;var ks=Object.prototype,Us=ks.hasOwnProperty;function Gs(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Us.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var rr=Gs;var Ks=x.Uint8Array,_t=Ks;function Ws(t){var e=new t.constructor(t.byteLength);return new _t(e).set(new _t(t)),e}var Z=Ws;function zs(t,e){var r=e?Z(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var or=zs;var Vs=/\w*$/;function qs(t){var e=new t.constructor(t.source,Vs.exec(t));return e.lastIndex=t.lastIndex,e}var ar=qs;var sr=S?S.prototype:void 0,ir=sr?sr.valueOf:void 0;function Hs(t){return ir?Object(ir.call(t)):{}}var fr=Hs;function $s(t,e){var r=e?Z(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var nr=$s;var Ys="[object Boolean]",Zs="[object Date]",Js="[object Map]",Xs="[object Number]",Qs="[object RegExp]",ti="[object Set]",ei="[object String]",ri="[object Symbol]",oi="[object ArrayBuffer]",ai="[object DataView]",si="[object Float32Array]",ii="[object Float64Array]",fi="[object Int8Array]",ni="[object Int16Array]",pi="[object Int32Array]",li="[object Uint8Array]",mi="[object Uint8ClampedArray]",ui="[object Uint16Array]",di="[object Uint32Array]";function ci(t,e,r){var o=t.constructor;switch(e){case oi:return Z(t);case Ys:case Zs:return new o(+t);case ai:return or(t,r);case si:case ii:case fi:case ni:case pi:case li:case mi:case ui:case di:return nr(t,r);case Js:return new o;case Xs:case ei:return new o(t);case Qs:return ar(t);case ti:return new o;case ri:return fr(t)}}var pr=ci;function hi(t){return typeof t.constructor=="function"&&!U(t)?Zt(ht(t)):{}}var lr=hi;var xi="[object Map]";function gi(t){return T(t)&&Y(t)==xi}var mr=gi;var ur=E&&E.isMap,bi=ur?G(ur):mr,dr=bi;var yi="[object Set]";function vi(t){return T(t)&&Y(t)==yi}var cr=vi;var hr=E&&E.isSet,wi=hr?G(hr):cr,xr=wi;var ji=1,Ti=2,Ai=4,gr="[object Arguments]",Oi="[object Array]",Pi="[object Boolean]",Si="[object Date]",_i="[object Error]",br="[object Function]",Ii="[object GeneratorFunction]",Ei="[object Map]",Ci="[object Number]",yr="[object Object]",Mi="[object RegExp]",Ri="[object Set]",Bi="[object String]",Li="[object Symbol]",Fi="[object WeakMap]",Ni="[object ArrayBuffer]",Di="[object DataView]",ki="[object Float32Array]",Ui="[object Float64Array]",Gi="[object Int8Array]",Ki="[object Int16Array]",Wi="[object Int32Array]",zi="[object Uint8Array]",Vi="[object Uint8ClampedArray]",qi="[object Uint16Array]",Hi="[object Uint32Array]",u={};u[gr]=u[Oi]=u[Ni]=u[Di]=u[Pi]=u[Si]=u[ki]=u[Ui]=u[Gi]=u[Ki]=u[Wi]=u[Ei]=u[Ci]=u[yr]=u[Mi]=u[Ri]=u[Bi]=u[Li]=u[zi]=u[Vi]=u[qi]=u[Hi]=!0;u[_i]=u[br]=u[Fi]=!1;function jt(t,e,r,o,a,p){var n,s=e&ji,l=e&Ti,c=e&Ai;if(r&&(n=a?r(t,o,a,p):r(t)),n!==void 0)return n;if(!A(t))return t;var h=k(t);if(h){if(n=rr(t),!s)return Jt(t,n)}else{var y=Y(t),j=y==br||y==Ii;if(mt(t))return ze(t,s);if(y==yr||y==gr||j&&!a){if(n=l||j?{}:lr(t),!s)return l?$e(t,ke(n,t)):He(t,De(n,t))}else{if(!u[y])return a?t:{};n=pr(t,y,s)}}p||(p=new Ne);var v=p.get(t);if(v)return v;p.set(t,n),xr(t)?t.forEach(function(b){n.add(jt(b,e,r,b,t,p))}):dr(t)&&t.forEach(function(b,i){n.set(i,jt(b,e,r,i,t,p))});var g=c?l?Ze:Ye:l?W:K,O=h?void 0:g(t);return Xt(O||t,function(b,i){O&&(i=b,b=t[i]),nt(n,i,jt(b,e,r,i,t,p))}),n}var vr=jt;var $i=1,Yi=4;function Zi(t){return vr(t,$i|Yi)}var It=Zi;function wr(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 Et=(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 Ji="array",Xi="bit",jr="bits",Qi="byte",Tr="bytes",J="",tf="exponent",ef="function",Ar="iec",rf="Invalid number",of="Invalid rounding method",Ct="jedec",af="object",Or=".",sf="round",ff="s",nf="si",pf="kbit",lf="kB",mf=" ",uf="string",df="0",Mt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function Pr(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:p=J,localeOptions:n={},separator:s=J,spacer:l=mf,symbols:c={},standard:h=J,output:y=uf,fullform:j=!1,fullforms:v=[],exponent:g=-1,roundingMethod:O=sf,precision:b=0}={}){let i=g,m=Number(t),f=[],P=0,Tt=J;h===nf?(o=10,h=Ct):h===Ar||h===Ct?o=2:o===2?h=Ar:(o=10,h=Ct);let et=o===10?1e3:1024,Sr=j===!0,Bt=m<0,Lt=Math[O];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(rf);if(typeof Lt!==ef)throw new TypeError(of);if(Bt&&(m=-m),(i===-1||isNaN(i))&&(i=Math.floor(Math.log(m)/Math.log(et)),i<0&&(i=0)),i>8&&(b>0&&(b+=8-i),i=8),y===tf)return i;if(m===0)f[0]=0,Tt=f[1]=Mt.symbol[h][e?jr:Tr][i];else{P=m/(o===2?Math.pow(2,i*10):Math.pow(1e3,i)),e&&(P=P*8,P>=et&&i<8&&(P=P/et,i++));let X=Math.pow(10,i>0?a:0);f[0]=Lt(P*X)/X,f[0]===et&&i<8&&g===-1&&(f[0]=1,i++),Tt=f[1]=o===10&&i===1?e?pf:lf:Mt.symbol[h][e?jr:Tr][i]}if(Bt&&(f[0]=-f[0]),b>0&&(f[0]=f[0].toPrecision(b)),f[1]=c[f[1]]||f[1],p===!0?f[0]=f[0].toLocaleString():p.length>0?f[0]=f[0].toLocaleString(p,n):s.length>0&&(f[0]=f[0].toString().replace(Or,s)),r&&Number.isInteger(f[0])===!1&&a>0){let X=s||Or,Ft=f[0].toString().split(X),Nt=Ft[1]||J,Dt=Nt.length,_r=a-Dt;f[0]=`${Ft[0]}${X}${Nt.padEnd(Dt+_r,df)}`}return Sr&&(f[1]=v[i]?v[i]:Mt.fullform[h][i]+(e?Xi:Qi)+(f[0]===1?J:ff)),y===Ji?f:y===af?{value:f[0],symbol:f[1],exponent:i,unit:Tt}:f.join(l)}var D=class{tera;id;name;path;parsedName;created;createdFormatted;modified;modifiedFormatted;accessed;accessedFormatted;size;sizeFormatted;mime;constructor(e){if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e),this.sizeFormatted=Pr(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(){return this.tera.getProjectFile(this.path)}setContents(e){return this.tera.setProjectFile(this.path,e)}getRefs(){return this.tera.getProjectLibrary(this.path)}setRefs(e){return this.tera.setProjectLibrary(this.path,e)}};var Rt=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=wr();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","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","uiAlert","uiSplat","uiWindow"];plugins=[];send(e){let r=Et();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||Et(),...It(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&&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=kt(r,e,Ut);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
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)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new D({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new D({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new D({tera:this,...r}))}};export{Rt as default};
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
package/hints.md
CHANGED
|
@@ -15,12 +15,3 @@ Hint Reference
|
|
|
15
15
|
The following is a non-definitive list of hints that can be associated with files. In all cases the hint should be a lower-case single, past-tense word. Upper-case indicates a variable.
|
|
16
16
|
|
|
17
17
|
This list should also be mirrored in the main tera-tools.com/api/tools.json meta-list.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
| Hint | Description |
|
|
21
|
-
|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
22
|
-
| `search` | The product of a search design stage |
|
|
23
|
-
| `deduped` | One or more files, that are the product of a deduplication stage |
|
|
24
|
-
| `screened-X` | One or more files from the screening stage, generally there will be one file per reviewer where `X` indicates the reviewer number starting with the number 1 |
|
|
25
|
-
| `disputed` | Generally a single file which is the product of a resolved dispute stage which merges in multiple `screened-X` files |
|
|
26
|
-
| `snowballed` | A file which has been through the snowballing stage |
|
package/lib/projectFile.js
CHANGED
|
@@ -120,9 +120,9 @@ export default class ProjectFile {
|
|
|
120
120
|
|
|
121
121
|
// Set all `*Formatted` fields
|
|
122
122
|
this.sizeFormatted = filesize(this.size || 0, {spacer: ''});
|
|
123
|
-
this.createdFormatted = this.created.toLocaleDateString();
|
|
124
|
-
this.modifiedFormatted = this.modified.toLocaleDateString();
|
|
125
|
-
this.accessedFormatted = this.accessed.toLocaleDateString();
|
|
123
|
+
this.createdFormatted = this.created ? this.created.toLocaleDateString() : 'Unknown created date';
|
|
124
|
+
this.modifiedFormatted = this.modified ? this.modified.toLocaleDateString() : 'Unknown modified date';
|
|
125
|
+
this.accessedFormatted = this.accessed ? this.accessed.toLocaleDateString() : 'Unknown access date';
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
|
|
@@ -157,10 +157,10 @@ export default class ProjectFile {
|
|
|
157
157
|
*
|
|
158
158
|
* @returns {Promise<Array<Ref>>} An eventual array of RefLib references
|
|
159
159
|
*
|
|
160
|
-
* @see
|
|
160
|
+
* @see getProjectLibrary()
|
|
161
161
|
*/
|
|
162
162
|
getRefs() {
|
|
163
|
-
return this.tera.
|
|
163
|
+
return this.tera.getProjectLibrary(this.path);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
|
package/lib/terafy.client.js
CHANGED
|
@@ -74,7 +74,7 @@ export default class TeraFy {
|
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* List of function stubs mapped
|
|
77
|
+
* List of function stubs mapped from the server to here
|
|
78
78
|
* This array is forms the reference of `TeraFy.METHOD()` objects to provide locally which will be mapped via `TeraFy.rpc(METHOD, ...args)`
|
|
79
79
|
*
|
|
80
80
|
* @type {Array<String>}
|
|
@@ -112,7 +112,7 @@ export default class TeraFy {
|
|
|
112
112
|
|
|
113
113
|
// Project Libraries
|
|
114
114
|
'selectProjectLibrary',
|
|
115
|
-
'
|
|
115
|
+
'getProjectLibrary',
|
|
116
116
|
'setProjectLibrary',
|
|
117
117
|
|
|
118
118
|
// UI
|
|
@@ -238,7 +238,7 @@ export default class TeraFy {
|
|
|
238
238
|
id: message.id,
|
|
239
239
|
action: 'response',
|
|
240
240
|
isError: true,
|
|
241
|
-
response: e.toString(),
|
|
241
|
+
response: e ? e.toString() : e,
|
|
242
242
|
});
|
|
243
243
|
})
|
|
244
244
|
} else if (message?.action == 'event') {
|
|
@@ -938,16 +938,16 @@ export default class TeraFy {
|
|
|
938
938
|
* @param {Boolean} [options.allowCancel=true] Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed
|
|
939
939
|
* @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
|
|
940
940
|
* @param {FileFilters} [options.filters] Optional file filters, defaults to citation library selection only
|
|
941
|
-
* @param {*} [options.*] Additional options - see `
|
|
941
|
+
* @param {*} [options.*] Additional options - see `getProjectLibrary()`
|
|
942
942
|
*
|
|
943
943
|
* @returns {Promise<Array<Ref>>} A collection of references from the selected file
|
|
944
944
|
*/
|
|
945
945
|
|
|
946
946
|
|
|
947
947
|
/**
|
|
948
|
-
*
|
|
948
|
+
* Fetch + convert a project file into a library of citations
|
|
949
949
|
*
|
|
950
|
-
* @function
|
|
950
|
+
* @function getProjectLibrary
|
|
951
951
|
* @param {String} path File path to read, if omitted the contents of `options` are used to guess at a suitable file
|
|
952
952
|
*
|
|
953
953
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
@@ -964,13 +964,17 @@ export default class TeraFy {
|
|
|
964
964
|
* Save back a citation library from some input
|
|
965
965
|
*
|
|
966
966
|
* @function setProjectLibrary
|
|
967
|
-
* @param {String} [path] File path to save back to
|
|
968
|
-
* @param {Array<RefLibRef
|
|
967
|
+
* @param {String} [path] File path to save back to, if omitted one will be prompted for
|
|
968
|
+
* @param {Array<RefLibRef>|Blob|File} [refs] Collection of references for the selected library or the raw Blob/File
|
|
969
969
|
*
|
|
970
970
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
971
|
+
* @param {String} [options.path] Alternate method to specify the path to save as, if omitted one will be prompted for
|
|
972
|
+
* @param {Array<RefLibRef>|Blob|File} [options.refs] Alternate method to specify the refs to save as an array or raw Blob/File
|
|
971
973
|
* @param {String} [options.format='json'] Input format used. ENUM: 'pojo' (return a parsed JS collection), 'blob' (raw JS Blob object), 'file' (named JS File object)
|
|
972
974
|
* @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
|
|
973
975
|
* @param {String} [options.hint] Hint to store against the library. Generally corresponds to the current operation being performed - e.g. 'deduped'
|
|
976
|
+
* @param {String} [options.filename] Suggested filename if path is unspecified
|
|
977
|
+
* @param {String} [options.title='Save citation library'] Dialog title if path is unspecified and we need to prompt
|
|
974
978
|
* @param {Boolean} [options.overwrite=true] Allow existing file upsert
|
|
975
979
|
* @param {Object} [options.meta] Optional meta data to merge into the file data
|
|
976
980
|
*
|
|
@@ -978,20 +982,6 @@ export default class TeraFy {
|
|
|
978
982
|
*/
|
|
979
983
|
|
|
980
984
|
|
|
981
|
-
/**
|
|
982
|
-
* Save back a projects citation library
|
|
983
|
-
*
|
|
984
|
-
* @function setProjectLibrary
|
|
985
|
-
* @param {Array<RefLibRef>} Collection of references for the selected library
|
|
986
|
-
*
|
|
987
|
-
* @param {Object} [options] Additional options to mutate behaviour
|
|
988
|
-
* @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
|
|
989
|
-
* @param {String} [options.hint] Hint to store against the library. Generally corresponds to the current operation being performed - e.g. 'deduped'
|
|
990
|
-
*
|
|
991
|
-
* @returns {Promise} A promise which resolves when the save operation has completed
|
|
992
|
-
*/
|
|
993
|
-
|
|
994
|
-
|
|
995
985
|
/**
|
|
996
986
|
* Display simple text within TERA
|
|
997
987
|
*
|
package/lib/terafy.server.js
CHANGED
|
@@ -279,7 +279,7 @@ export default class TeraFyServer {
|
|
|
279
279
|
id: message.id,
|
|
280
280
|
action: 'response',
|
|
281
281
|
isError: true,
|
|
282
|
-
response: e.toString(),
|
|
282
|
+
response: e ? e.toString() : e,
|
|
283
283
|
});
|
|
284
284
|
})
|
|
285
285
|
}
|
|
@@ -915,7 +915,7 @@ export default class TeraFyServer {
|
|
|
915
915
|
|
|
916
916
|
return app.service('$projects').promise()
|
|
917
917
|
.then(()=> settings.autoRequire && this.requireProject())
|
|
918
|
-
.then(
|
|
918
|
+
.then(()=> this.requestFocus(()=>
|
|
919
919
|
app.service('$prompt').dialog({
|
|
920
920
|
title: settings.title,
|
|
921
921
|
component: settings.save ? 'filesSave' : 'filesOpen',
|
|
@@ -997,7 +997,7 @@ export default class TeraFyServer {
|
|
|
997
997
|
}
|
|
998
998
|
// }}}
|
|
999
999
|
|
|
1000
|
-
// Project Libraries - selectProjectLibrary(),
|
|
1000
|
+
// Project Libraries - selectProjectLibrary(), getProjectLibrary(), setProjectLibrary() {{{
|
|
1001
1001
|
|
|
1002
1002
|
/**
|
|
1003
1003
|
* Prompt the user to select a library to operate on and return a array of references in a given format
|
|
@@ -1011,7 +1011,7 @@ export default class TeraFyServer {
|
|
|
1011
1011
|
* @param {Boolean} [options.allowCancel=true] Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed
|
|
1012
1012
|
* @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
|
|
1013
1013
|
* @param {FileFilters} [options.filters] Optional file filters, defaults to citation library selection only
|
|
1014
|
-
* @param {*} [options.*] Additional options - see `
|
|
1014
|
+
* @param {*} [options.*] Additional options - see `getProjectLibrary()`
|
|
1015
1015
|
*
|
|
1016
1016
|
* @returns {Promise<Array<Ref>>} A collection of references from the selected file
|
|
1017
1017
|
*/
|
|
@@ -1033,12 +1033,12 @@ export default class TeraFyServer {
|
|
|
1033
1033
|
|
|
1034
1034
|
return app.service('$projects').promise()
|
|
1035
1035
|
.then(()=> this.selectProjectFile(settings))
|
|
1036
|
-
.then(selectedFile => this.
|
|
1036
|
+
.then(selectedFile => this.getProjectLibrary(selectedFile.path, settings))
|
|
1037
1037
|
}
|
|
1038
1038
|
|
|
1039
1039
|
|
|
1040
1040
|
/**
|
|
1041
|
-
*
|
|
1041
|
+
* Fetch + convert a project file into a library of citations
|
|
1042
1042
|
*
|
|
1043
1043
|
* @param {String} path File path to read, if omitted the contents of `options` are used to guess at a suitable file
|
|
1044
1044
|
*
|
|
@@ -1050,7 +1050,7 @@ export default class TeraFyServer {
|
|
|
1050
1050
|
*
|
|
1051
1051
|
* @returns {Promise<Array<Ref>>|Promise<*>} A collection of references (default bevahiour) or a whatever format was requested
|
|
1052
1052
|
*/
|
|
1053
|
-
|
|
1053
|
+
getProjectLibrary(path, options) {
|
|
1054
1054
|
let settings = {
|
|
1055
1055
|
format: 'pojo',
|
|
1056
1056
|
autoRequire: true,
|
|
@@ -1091,13 +1091,17 @@ export default class TeraFyServer {
|
|
|
1091
1091
|
/**
|
|
1092
1092
|
* Save back a citation library from some input
|
|
1093
1093
|
*
|
|
1094
|
-
* @param {String} [path] File path to save back to
|
|
1095
|
-
* @param {Array<RefLibRef
|
|
1094
|
+
* @param {String} [path] File path to save back to, if omitted one will be prompted for
|
|
1095
|
+
* @param {Array<RefLibRef>|Blob|File} [refs] Collection of references for the selected library or the raw Blob/File
|
|
1096
1096
|
*
|
|
1097
1097
|
* @param {Object} [options] Additional options to mutate behaviour
|
|
1098
|
-
* @param {String} [options.
|
|
1098
|
+
* @param {String} [options.path] Alternate method to specify the path to save as, if omitted one will be prompted for
|
|
1099
|
+
* @param {Array<RefLibRef>|Blob|File} [options.refs] Alternate method to specify the refs to save as an array or raw Blob/File
|
|
1100
|
+
* @param {String} [options.format='auto'] Input format used. ENUM: 'auto' (try to figure it out from context), 'pojo' (JS array of RefLib references), 'blob' (raw JS Blob object), 'file' (named JS File object)
|
|
1099
1101
|
* @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
|
|
1100
|
-
* @param {String} [options.hint] Hint to store against the library. Generally corresponds to the current operation being performed - e.g. 'deduped'
|
|
1102
|
+
* @param {String|Array<String>} [options.hint] Hint(s) to store against the library. Generally corresponds to the current operation being performed - e.g. 'deduped'
|
|
1103
|
+
* @param {String} [options.filename] Suggested filename if path is unspecified
|
|
1104
|
+
* @param {String} [options.title='Save citation library'] Dialog title if path is unspecified and we need to prompt
|
|
1101
1105
|
* @param {Boolean} [options.overwrite=true] Allow existing file upsert
|
|
1102
1106
|
* @param {Object} [options.meta] Optional meta data to merge into the file data
|
|
1103
1107
|
*
|
|
@@ -1105,37 +1109,77 @@ export default class TeraFyServer {
|
|
|
1105
1109
|
*/
|
|
1106
1110
|
setProjectLibrary(path, refs, options) {
|
|
1107
1111
|
let settings = {
|
|
1112
|
+
format: 'auto',
|
|
1108
1113
|
autoRequire: true,
|
|
1109
1114
|
hint: null,
|
|
1115
|
+
filename: null,
|
|
1116
|
+
title: 'Save citation library',
|
|
1110
1117
|
overwrite: true,
|
|
1111
1118
|
meta: null,
|
|
1112
|
-
...
|
|
1119
|
+
...(
|
|
1120
|
+
typeof path == 'string' && Array.isArray(refs) ? {path, refs, ...options} // Called as (path, refs, options?)
|
|
1121
|
+
: Array.isArray(path) || refs instanceof Blob || refs instanceof File ? {refs: path, ...refs} // Called as (refs, options?)
|
|
1122
|
+
: path // Called as (options?)
|
|
1123
|
+
)
|
|
1113
1124
|
};
|
|
1125
|
+
if (!settings.refs) throw new Error('No refs to save');
|
|
1114
1126
|
|
|
1115
1127
|
return Promise.resolve()
|
|
1116
1128
|
.then(()=> settings.autoRequire && this.requireProject())
|
|
1117
1129
|
.then(()=> {
|
|
1130
|
+
if (settings.path) return; // We already have a file path specified - skip
|
|
1131
|
+
|
|
1132
|
+
// Prompt for a save filename
|
|
1133
|
+
return this.selectProjectFile({
|
|
1134
|
+
title: 'Save citation library',
|
|
1135
|
+
save: true,
|
|
1136
|
+
hint: settings.hint,
|
|
1137
|
+
saveFilename: settings.filename,
|
|
1138
|
+
filters: {
|
|
1139
|
+
library: true,
|
|
1140
|
+
},
|
|
1141
|
+
autoRequire: false, // Handled above anyway
|
|
1142
|
+
})
|
|
1143
|
+
.then(path => settings.path = path)
|
|
1144
|
+
})
|
|
1145
|
+
.then(()=> { // Correct filename to a full path if needed
|
|
1146
|
+
if (!/^\/.+\/.+/.test(settings.path)) { // Not already a qualified full path for a project
|
|
1147
|
+
settings.path = `/projects/${app.service('$projects').active.id}/${settings.path}`;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
this.debug('Save citation library as', path);
|
|
1151
|
+
})
|
|
1152
|
+
.then(()=> {
|
|
1153
|
+
// Mutate settings.ref -> Blob or File format needed by Supabase
|
|
1154
|
+
if (settings.format == 'auto') {
|
|
1155
|
+
settings.format =
|
|
1156
|
+
Array.isArray(settings.refs) ? 'pojo'
|
|
1157
|
+
: settings.refs instanceof Blob ? 'blob'
|
|
1158
|
+
: settings.refs instanceof File ? 'file'
|
|
1159
|
+
: (()=> { throw new Error('Unable to guess input format for setLibaryFormat()') })();
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1118
1162
|
switch (settings.format) {
|
|
1119
|
-
// NOTE: Any updates to the format list should also extend
|
|
1163
|
+
// NOTE: Any updates to the format list should also extend getProjectLibrary()
|
|
1120
1164
|
case 'pojo': // Use as is
|
|
1121
|
-
if (!Array.isArray(refs)) throw new Error('setProjectLibrary() with format=pojo requires an array of references');
|
|
1122
|
-
|
|
1165
|
+
if (!Array.isArray(settings.refs)) throw new Error('setProjectLibrary() with format=pojo requires an array of references');
|
|
1166
|
+
|
|
1167
|
+
// Get Reflib to encode the POJO into a Blob/File
|
|
1168
|
+
return Reflib.downloadFile(settings.refs, {
|
|
1169
|
+
filename: settings.path,
|
|
1170
|
+
promptDownload: false, // Just return the fileBlob we hand to Supabase
|
|
1171
|
+
})
|
|
1123
1172
|
case 'blob':
|
|
1173
|
+
if (!(settings.refs instanceof Blob)) throw new Error("setProjectLibrary({format: 'blob'} but non-Blob provided as `refs`");
|
|
1174
|
+
return new File([settings.refs], app.service('$supabase')._parsePath(settings.path).basename);
|
|
1124
1175
|
case 'file':
|
|
1125
|
-
|
|
1176
|
+
if (!(settings.ref instanceof File)) throw new Error("setProjectLibrary({format: 'file'} but non-File provided as `refs`");
|
|
1177
|
+
return settings.refs;
|
|
1126
1178
|
default:
|
|
1127
1179
|
throw new Error(`Unsupported library format "${settings.format}"`);
|
|
1128
1180
|
}
|
|
1129
1181
|
})
|
|
1130
|
-
.then(
|
|
1131
|
-
refs instanceof Blob ? new File([refs], app.service('$supabase')._parsePath(path).basename)
|
|
1132
|
-
: refs instanceof File ? refs
|
|
1133
|
-
: Reflib.downloadFile(refs, { // Get Reflib to encode for us
|
|
1134
|
-
filename: path,
|
|
1135
|
-
promptDownload: false, // Just return the fileBlob we hand to Supabase
|
|
1136
|
-
})
|
|
1137
|
-
)
|
|
1138
|
-
.then(fileBlob => this.$supabase.fileUpload(path, {
|
|
1182
|
+
.then(fileBlob => app.service('$supabase').fileUpload(settings.path, {
|
|
1139
1183
|
file: fileBlob,
|
|
1140
1184
|
mode: 'encoded',
|
|
1141
1185
|
overwrite: true,
|