@avaturn-live/web-sdk 0.0.15 → 0.0.16
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/dist/main.cjs +1 -1
- package/dist/main.d.ts +2 -2
- package/dist/main.js +7 -7
- package/dist/type.d.ts +1 -0
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -41,4 +41,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
41
41
|
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const r=new this(e);return n.forEach(i=>r.set(i)),r}static accessor(e){const r=(this[Ms]=this[Ms]={accessors:{}}).accessors,i=this.prototype;function s(a){const c=gt(a);r[c]||(Lu(i,a),r[c]=!0)}return v.isArray(e)?e.forEach(s):s(e),this}}X.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);v.reduceDescriptors(X.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}});v.freezeMethods(X);function In(t,e){const n=this||Rt,r=e||n,i=X.from(r.headers);let s=r.data;return v.forEach(t,function(c){s=c.call(n,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function qo(t){return!!(t&&t.__CANCEL__)}function dt(t,e,n){A.call(this,t??"canceled",A.ERR_CANCELED,e,n),this.name="CanceledError"}v.inherits(dt,A,{__CANCEL__:!0});function Jo(t,e,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):e(new A("Request failed with status code "+n.status,[A.ERR_BAD_REQUEST,A.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Nu(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function ju(t,e){t=t||10;const n=new Array(t),r=new Array(t);let i=0,s=0,a;return e=e!==void 0?e:1e3,function(l){const p=Date.now(),h=r[s];a||(a=p),n[i]=l,r[i]=p;let f=s,_=0;for(;f!==i;)_+=n[f++],f=f%t;if(i=(i+1)%t,i===s&&(s=(s+1)%t),p-a<e)return;const k=h&&p-h;return k?Math.round(_*1e3/k):void 0}}function Iu(t,e){let n=0;const r=1e3/e;let i=null;return function(){const a=this===!0,c=Date.now();if(a||c-n>r)return i&&(clearTimeout(i),i=null),n=c,t.apply(null,arguments);i||(i=setTimeout(()=>(i=null,n=Date.now(),t.apply(null,arguments)),r-(c-n)))}}const an=(t,e,n=3)=>{let r=0;const i=ju(50,250);return Iu(s=>{const a=s.loaded,c=s.lengthComputable?s.total:void 0,l=a-r,p=i(l),h=a<=c;r=a;const f={loaded:a,total:c,progress:c?a/c:void 0,bytes:l,rate:p||void 0,estimated:p&&c&&h?(c-a)/p:void 0,event:s,lengthComputable:c!=null};f[e?"download":"upload"]=!0,t(f)},n)},Bu=le.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function i(s){let a=s;return e&&(n.setAttribute("href",a),a=n.href),n.setAttribute("href",a),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=i(window.location.href),function(a){const c=v.isString(a)?i(a):a;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}(),Fu=le.hasStandardBrowserEnv?{write(t,e,n,r,i,s){const a=[t+"="+encodeURIComponent(e)];v.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),v.isString(r)&&a.push("path="+r),v.isString(i)&&a.push("domain="+i),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Uu(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function qu(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function Vo(t,e){return t&&!Uu(e)?qu(t,e):e}const Os=t=>t instanceof X?{...t}:t;function We(t,e){e=e||{};const n={};function r(p,h,f){return v.isPlainObject(p)&&v.isPlainObject(h)?v.merge.call({caseless:f},p,h):v.isPlainObject(h)?v.merge({},h):v.isArray(h)?h.slice():h}function i(p,h,f){if(v.isUndefined(h)){if(!v.isUndefined(p))return r(void 0,p,f)}else return r(p,h,f)}function s(p,h){if(!v.isUndefined(h))return r(void 0,h)}function a(p,h){if(v.isUndefined(h)){if(!v.isUndefined(p))return r(void 0,p)}else return r(void 0,h)}function c(p,h,f){if(f in e)return r(p,h);if(f in t)return r(void 0,p)}const l={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c,headers:(p,h)=>i(Os(p),Os(h),!0)};return v.forEach(Object.keys(Object.assign({},t,e)),function(h){const f=l[h]||i,_=f(t[h],e[h],h);v.isUndefined(_)&&f!==c||(n[h]=_)}),n}const $o=t=>{const e=We({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:s,headers:a,auth:c}=e;e.headers=a=X.from(a),e.url=Bo(Vo(e.baseURL,e.url),t.params,t.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let l;if(v.isFormData(n)){if(le.hasStandardBrowserEnv||le.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((l=a.getContentType())!==!1){const[p,...h]=l?l.split(";").map(f=>f.trim()).filter(Boolean):[];a.setContentType([p||"multipart/form-data",...h].join("; "))}}if(le.hasStandardBrowserEnv&&(r&&v.isFunction(r)&&(r=r(e)),r||r!==!1&&Bu(e.url))){const p=i&&s&&Fu.read(s);p&&a.set(i,p)}return e},Ju=typeof XMLHttpRequest<"u",Vu=Ju&&function(t){return new Promise(function(n,r){const i=$o(t);let s=i.data;const a=X.from(i.headers).normalize();let{responseType:c}=i,l;function p(){i.cancelToken&&i.cancelToken.unsubscribe(l),i.signal&&i.signal.removeEventListener("abort",l)}let h=new XMLHttpRequest;h.open(i.method.toUpperCase(),i.url,!0),h.timeout=i.timeout;function f(){if(!h)return;const k=X.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),w={data:!c||c==="text"||c==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:k,config:t,request:h};Jo(function(M){n(M),p()},function(M){r(M),p()},w),h=null}"onloadend"in h?h.onloadend=f:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(f)},h.onabort=function(){h&&(r(new A("Request aborted",A.ECONNABORTED,i,h)),h=null)},h.onerror=function(){r(new A("Network Error",A.ERR_NETWORK,i,h)),h=null},h.ontimeout=function(){let y=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const w=i.transitional||Fo;i.timeoutErrorMessage&&(y=i.timeoutErrorMessage),r(new A(y,w.clarifyTimeoutError?A.ETIMEDOUT:A.ECONNABORTED,i,h)),h=null},s===void 0&&a.setContentType(null),"setRequestHeader"in h&&v.forEach(a.toJSON(),function(y,w){h.setRequestHeader(w,y)}),v.isUndefined(i.withCredentials)||(h.withCredentials=!!i.withCredentials),c&&c!=="json"&&(h.responseType=i.responseType),typeof i.onDownloadProgress=="function"&&h.addEventListener("progress",an(i.onDownloadProgress,!0)),typeof i.onUploadProgress=="function"&&h.upload&&h.upload.addEventListener("progress",an(i.onUploadProgress)),(i.cancelToken||i.signal)&&(l=k=>{h&&(r(!k||k.type?new dt(null,t,h):k),h.abort(),h=null)},i.cancelToken&&i.cancelToken.subscribe(l),i.signal&&(i.signal.aborted?l():i.signal.addEventListener("abort",l)));const _=Nu(i.url);if(_&&le.protocols.indexOf(_)===-1){r(new A("Unsupported protocol "+_+":",A.ERR_BAD_REQUEST,t));return}h.send(s||null)})},$u=(t,e)=>{let n=new AbortController,r;const i=function(l){if(!r){r=!0,a();const p=l instanceof Error?l:this.reason;n.abort(p instanceof A?p:new dt(p instanceof Error?p.message:p))}};let s=e&&setTimeout(()=>{i(new A(`timeout ${e} of ms exceeded`,A.ETIMEDOUT))},e);const a=()=>{t&&(s&&clearTimeout(s),s=null,t.forEach(l=>{l&&(l.removeEventListener?l.removeEventListener("abort",i):l.unsubscribe(i))}),t=null)};t.forEach(l=>l&&l.addEventListener&&l.addEventListener("abort",i));const{signal:c}=n;return c.unsubscribe=a,[c,()=>{s&&clearTimeout(s),s=null}]},Gu=function*(t,e){let n=t.byteLength;if(!e||n<e){yield t;return}let r=0,i;for(;r<n;)i=r+e,yield t.slice(r,i),r=i},zu=async function*(t,e,n){for await(const r of t)yield*Gu(ArrayBuffer.isView(r)?r:await n(String(r)),e)},Ps=(t,e,n,r,i)=>{const s=zu(t,e,i);let a=0;return new ReadableStream({type:"bytes",async pull(c){const{done:l,value:p}=await s.next();if(l){c.close(),r();return}let h=p.byteLength;n&&n(a+=h),c.enqueue(new Uint8Array(p))},cancel(c){return r(c),s.return()}},{highWaterMark:2})},As=(t,e)=>{const n=t!=null;return r=>setTimeout(()=>e({lengthComputable:n,total:t,loaded:r}))},yn=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Go=yn&&typeof ReadableStream=="function",lr=yn&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),Yu=Go&&(()=>{let t=!1;const e=new Request(le.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e})(),Rs=64*1024,ur=Go&&!!(()=>{try{return v.isReadableStream(new Response("").body)}catch{}})(),cn={stream:ur&&(t=>t.body)};yn&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!cn[e]&&(cn[e]=v.isFunction(t[e])?n=>n[e]():(n,r)=>{throw new A(`Response type '${e}' is not supported`,A.ERR_NOT_SUPPORT,r)})})})(new Response);const Hu=async t=>{if(t==null)return 0;if(v.isBlob(t))return t.size;if(v.isSpecCompliantForm(t))return(await new Request(t).arrayBuffer()).byteLength;if(v.isArrayBufferView(t))return t.byteLength;if(v.isURLSearchParams(t)&&(t=t+""),v.isString(t))return(await lr(t)).byteLength},Wu=async(t,e)=>{const n=v.toFiniteNumber(t.getContentLength());return n??Hu(e)},Qu=yn&&(async t=>{let{url:e,method:n,data:r,signal:i,cancelToken:s,timeout:a,onDownloadProgress:c,onUploadProgress:l,responseType:p,headers:h,withCredentials:f="same-origin",fetchOptions:_}=$o(t);p=p?(p+"").toLowerCase():"text";let[k,y]=i||s||a?$u([i,s],a):[],w,T;const M=()=>{!w&&setTimeout(()=>{k&&k.unsubscribe()}),w=!0};let B;try{if(l&&Yu&&n!=="get"&&n!=="head"&&(B=await Wu(h,r))!==0){let se=new Request(e,{method:"POST",body:r,duplex:"half"}),ye;v.isFormData(r)&&(ye=se.headers.get("content-type"))&&h.setContentType(ye),se.body&&(r=Ps(se.body,Rs,As(B,an(l)),null,lr))}v.isString(f)||(f=f?"cors":"omit"),T=new Request(e,{..._,signal:k,method:n.toUpperCase(),headers:h.normalize().toJSON(),body:r,duplex:"half",withCredentials:f});let L=await fetch(T);const te=ur&&(p==="stream"||p==="response");if(ur&&(c||te)){const se={};["status","statusText","headers"].forEach(ht=>{se[ht]=L[ht]});const ye=v.toFiniteNumber(L.headers.get("content-length"));L=new Response(Ps(L.body,Rs,c&&As(ye,an(c,!0)),te&&M,lr),se)}p=p||"text";let Ne=await cn[v.findKey(cn,p)||"text"](L,t);return!te&&M(),y&&y(),await new Promise((se,ye)=>{Jo(se,ye,{data:Ne,headers:X.from(L.headers),status:L.status,statusText:L.statusText,config:t,request:T})})}catch(L){throw M(),L&&L.name==="TypeError"&&/fetch/i.test(L.message)?Object.assign(new A("Network Error",A.ERR_NETWORK,t,T),{cause:L.cause||L}):A.from(L,L&&L.code,t,T)}}),dr={http:pu,xhr:Vu,fetch:Qu};v.forEach(dr,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const xs=t=>`- ${t}`,Ku=t=>v.isFunction(t)||t===null||t===!1,zo={getAdapter:t=>{t=v.isArray(t)?t:[t];const{length:e}=t;let n,r;const i={};for(let s=0;s<e;s++){n=t[s];let a;if(r=n,!Ku(n)&&(r=dr[(a=String(n)).toLowerCase()],r===void 0))throw new A(`Unknown adapter '${a}'`);if(r)break;i[a||"#"+s]=r}if(!r){const s=Object.entries(i).map(([c,l])=>`adapter ${c} `+(l===!1?"is not supported by the environment":"is not available in the build"));let a=e?s.length>1?`since :
|
|
42
42
|
`+s.map(xs).join(`
|
|
43
43
|
`):" "+xs(s[0]):"as no adapter specified";throw new A("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return r},adapters:dr};function Bn(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new dt(null,t)}function Ds(t){return Bn(t),t.headers=X.from(t.headers),t.data=In.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),zo.getAdapter(t.adapter||Rt.adapter)(t).then(function(r){return Bn(t),r.data=In.call(t,t.transformResponse,r),r.headers=X.from(r.headers),r},function(r){return qo(r)||(Bn(t),r&&r.response&&(r.response.data=In.call(t,t.transformResponse,r.response),r.response.headers=X.from(r.response.headers))),Promise.reject(r)})}const Yo="1.7.2",Pr={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Pr[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});const Ls={};Pr.transitional=function(e,n,r){function i(s,a){return"[Axios v"+Yo+"] Transitional option '"+s+"'"+a+(r?". "+r:"")}return(s,a,c)=>{if(e===!1)throw new A(i(a," has been removed"+(n?" in "+n:"")),A.ERR_DEPRECATED);return n&&!Ls[a]&&(Ls[a]=!0,console.warn(i(a," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(s,a,c):!0}};function Xu(t,e,n){if(typeof t!="object")throw new A("options must be an object",A.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let i=r.length;for(;i-- >0;){const s=r[i],a=e[s];if(a){const c=t[s],l=c===void 0||a(c,s,t);if(l!==!0)throw new A("option "+s+" must be "+l,A.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new A("Unknown option "+s,A.ERR_BAD_OPTION)}}const hr={assertOptions:Xu,validators:Pr},Me=hr.validators;class Ve{constructor(e){this.defaults=e,this.interceptors={request:new Cs,response:new Cs}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
44
|
-
`+s):r.stack=s}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=We(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:s}=n;r!==void 0&&hr.assertOptions(r,{silentJSONParsing:Me.transitional(Me.boolean),forcedJSONParsing:Me.transitional(Me.boolean),clarifyTimeoutError:Me.transitional(Me.boolean)},!1),i!=null&&(v.isFunction(i)?n.paramsSerializer={serialize:i}:hr.assertOptions(i,{encode:Me.function,serialize:Me.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let a=s&&v.merge(s.common,s[n.method]);s&&v.forEach(["delete","get","head","post","put","patch","common"],y=>{delete s[y]}),n.headers=X.concat(a,s);const c=[];let l=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(n)===!1||(l=l&&w.synchronous,c.unshift(w.fulfilled,w.rejected))});const p=[];this.interceptors.response.forEach(function(w){p.push(w.fulfilled,w.rejected)});let h,f=0,_;if(!l){const y=[Ds.bind(this),void 0];for(y.unshift.apply(y,c),y.push.apply(y,p),_=y.length,h=Promise.resolve(n);f<_;)h=h.then(y[f++],y[f++]);return h}_=c.length;let k=n;for(f=0;f<_;){const y=c[f++],w=c[f++];try{k=y(k)}catch(T){w.call(this,T);break}}try{h=Ds.call(this,k)}catch(y){return Promise.reject(y)}for(f=0,_=p.length;f<_;)h=h.then(p[f++],p[f++]);return h}getUri(e){e=We(this.defaults,e);const n=Vo(e.baseURL,e.url);return Bo(n,e.params,e.paramsSerializer)}}v.forEach(["delete","get","head","options"],function(e){Ve.prototype[e]=function(n,r){return this.request(We(r||{},{method:e,url:n,data:(r||{}).data}))}});v.forEach(["post","put","patch"],function(e){function n(r){return function(s,a,c){return this.request(We(c||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}Ve.prototype[e]=n(),Ve.prototype[e+"Form"]=n(!0)});class Ar{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(i=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](i);r._listeners=null}),this.promise.then=i=>{let s;const a=new Promise(c=>{r.subscribe(c),s=c}).then(i);return a.cancel=function(){r.unsubscribe(s)},a},e(function(s,a,c){r.reason||(r.reason=new dt(s,a,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}static source(){let e;return{token:new Ar(function(i){e=i}),cancel:e}}}function Zu(t){return function(n){return t.apply(null,n)}}function ed(t){return v.isObject(t)&&t.isAxiosError===!0}const pr={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(pr).forEach(([t,e])=>{pr[e]=t});function Ho(t){const e=new Ve(t),n=Co(Ve.prototype.request,e);return v.extend(n,Ve.prototype,e,{allOwnKeys:!0}),v.extend(n,e,null,{allOwnKeys:!0}),n.create=function(i){return Ho(We(t,i))},n}const $=Ho(Rt);$.Axios=Ve;$.CanceledError=dt;$.CancelToken=Ar;$.isCancel=qo;$.VERSION=Yo;$.toFormData=vn;$.AxiosError=A;$.Cancel=$.CanceledError;$.all=function(e){return Promise.all(e)};$.spread=Zu;$.isAxiosError=ed;$.mergeConfig=We;$.AxiosHeaders=X;$.formToJSON=t=>Uo(v.isHTMLForm(t)?new FormData(t):t);$.getAdapter=zo.getAdapter;$.HttpStatusCode=pr;$.default=$;class td{constructor({apiHost:e="https://api.avaturn.live",sessionToken:n,preloadBundle:r,keepAlive:
|
|
44
|
+
`+s):r.stack=s}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=We(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:s}=n;r!==void 0&&hr.assertOptions(r,{silentJSONParsing:Me.transitional(Me.boolean),forcedJSONParsing:Me.transitional(Me.boolean),clarifyTimeoutError:Me.transitional(Me.boolean)},!1),i!=null&&(v.isFunction(i)?n.paramsSerializer={serialize:i}:hr.assertOptions(i,{encode:Me.function,serialize:Me.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let a=s&&v.merge(s.common,s[n.method]);s&&v.forEach(["delete","get","head","post","put","patch","common"],y=>{delete s[y]}),n.headers=X.concat(a,s);const c=[];let l=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(n)===!1||(l=l&&w.synchronous,c.unshift(w.fulfilled,w.rejected))});const p=[];this.interceptors.response.forEach(function(w){p.push(w.fulfilled,w.rejected)});let h,f=0,_;if(!l){const y=[Ds.bind(this),void 0];for(y.unshift.apply(y,c),y.push.apply(y,p),_=y.length,h=Promise.resolve(n);f<_;)h=h.then(y[f++],y[f++]);return h}_=c.length;let k=n;for(f=0;f<_;){const y=c[f++],w=c[f++];try{k=y(k)}catch(T){w.call(this,T);break}}try{h=Ds.call(this,k)}catch(y){return Promise.reject(y)}for(f=0,_=p.length;f<_;)h=h.then(p[f++],p[f++]);return h}getUri(e){e=We(this.defaults,e);const n=Vo(e.baseURL,e.url);return Bo(n,e.params,e.paramsSerializer)}}v.forEach(["delete","get","head","options"],function(e){Ve.prototype[e]=function(n,r){return this.request(We(r||{},{method:e,url:n,data:(r||{}).data}))}});v.forEach(["post","put","patch"],function(e){function n(r){return function(s,a,c){return this.request(We(c||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}Ve.prototype[e]=n(),Ve.prototype[e+"Form"]=n(!0)});class Ar{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(i=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](i);r._listeners=null}),this.promise.then=i=>{let s;const a=new Promise(c=>{r.subscribe(c),s=c}).then(i);return a.cancel=function(){r.unsubscribe(s)},a},e(function(s,a,c){r.reason||(r.reason=new dt(s,a,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}static source(){let e;return{token:new Ar(function(i){e=i}),cancel:e}}}function Zu(t){return function(n){return t.apply(null,n)}}function ed(t){return v.isObject(t)&&t.isAxiosError===!0}const pr={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(pr).forEach(([t,e])=>{pr[e]=t});function Ho(t){const e=new Ve(t),n=Co(Ve.prototype.request,e);return v.extend(n,Ve.prototype,e,{allOwnKeys:!0}),v.extend(n,e,null,{allOwnKeys:!0}),n.create=function(i){return Ho(We(t,i))},n}const $=Ho(Rt);$.Axios=Ve;$.CanceledError=dt;$.CancelToken=Ar;$.isCancel=qo;$.VERSION=Yo;$.toFormData=vn;$.AxiosError=A;$.Cancel=$.CanceledError;$.all=function(e){return Promise.all(e)};$.spread=Zu;$.isAxiosError=ed;$.mergeConfig=We;$.AxiosHeaders=X;$.formToJSON=t=>Uo(v.isHTMLForm(t)?new FormData(t):t);$.getAdapter=zo.getAdapter;$.HttpStatusCode=pr;$.default=$;class td{constructor({apiHost:e="https://api.avaturn.live",sessionToken:n,preloadBundle:r,preconnect:i,keepAlive:s}){we(this,"inited",!1);we(this,"mediaStream");we(this,"session_id","");we(this,"timeout",0);we(this,"keepAlive",!1);we(this,"fetcher");we(this,"call");we(this,"handlers",{});if(typeof window>"u")throw new Error("Unfortunately, SDK only works on the client side.");this.fetcher=$.create({baseURL:`${e}/_sdk/v0`,headers:{"X-Session-Token":n}}),this.keepAlive=!!s,this.keepAlive=!!s,this.mediaStream=new MediaStream,this.call=Ol.createCallObject({videoSource:!1,audioSource:!1,dailyConfig:{avoidEval:!0}}),r&&this.call.load(),i&&this.fetcher.post("/sessions/start_stream")}startIdleTimeout(){this.timeout=setTimeout(()=>{var e;(e=this.handlers.idle)==null||e.forEach(n=>n({data:null})),this.keepAlive||this.dispose()},60*1e3)}restartIdleTimeout(){clearTimeout(this.timeout),this.startIdleTimeout()}async init(e){if(this.inited)return;this.startIdleTimeout();const{data:n}=await this.fetcher.get("/sessions");return this.session_id=n.id,await this.call.join({token:n.limited_access_token,url:n.room_url}),this.inited=!0,new Promise((r,i)=>{var c,l;const s=e!=null&&e.timeout&&e.timeout>0?e==null?void 0:e.timeout:3e4,a=e!=null&&e.timeout?setTimeout(()=>i("Connection timeout"),s):null;(c=this.call)==null||c.on("participant-updated",({participant:p})=>{var _,k;if(!p.owner)return;const{video:h,audio:f}=p.tracks;h.persistentTrack&&((_=this.mediaStream)==null||_.addTrack(h.persistentTrack)),f.persistentTrack&&((k=this.mediaStream)==null||k.addTrack(f.persistentTrack)),a&&clearTimeout(a),r(null)}),(l=this.call)==null||l.on("app-message",({data:p})=>{var h;p.type&&((h=this.handlers[p.type])==null||h.forEach(f=>f(p)))})})}async task(e){if(!this.session_id)throw new Error("It seems that the session is not initialized.");this.restartIdleTimeout();const{data:n}=await this.fetcher.post("/sessions/tasks",{text:e});return n}on(e,n){this.handlers[e]||(this.handlers[e]=[]),this.handlers[e].push(n)}off(e,n){this.handlers[e]&&(this.handlers[e]=this.handlers[e].filter(r=>r!==n))}async dispose(){var e;this.mediaStream=new MediaStream,this.timeout&&clearTimeout(this.timeout),await((e=this.call)==null?void 0:e.destroy())}}exports.AvaturnHead=td;
|
package/dist/main.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare class AvaturnHead implements IAvaturnHead {
|
|
|
8
8
|
private readonly fetcher;
|
|
9
9
|
private call;
|
|
10
10
|
private handlers;
|
|
11
|
-
constructor({ apiHost, sessionToken, preloadBundle, keepAlive, }: AvaturnHeadConfig);
|
|
11
|
+
constructor({ apiHost, sessionToken, preloadBundle, preconnect, keepAlive, }: AvaturnHeadConfig);
|
|
12
12
|
private startIdleTimeout;
|
|
13
13
|
private restartIdleTimeout;
|
|
14
14
|
init(config?: {
|
|
@@ -17,5 +17,5 @@ export declare class AvaturnHead implements IAvaturnHead {
|
|
|
17
17
|
task(text: string): Promise<any>;
|
|
18
18
|
on<T extends AvaturnHeadEvent>(eventName: T, cb: AvaturnEventCallback<T>): void;
|
|
19
19
|
off<T extends AvaturnHeadEvent>(eventName: T, cb: AvaturnEventCallback<T>): void;
|
|
20
|
-
dispose(): void
|
|
20
|
+
dispose(): Promise<void>;
|
|
21
21
|
}
|
package/dist/main.js
CHANGED
|
@@ -7264,7 +7264,7 @@ $.getAdapter = zo.getAdapter;
|
|
|
7264
7264
|
$.HttpStatusCode = pr;
|
|
7265
7265
|
$.default = $;
|
|
7266
7266
|
class nd {
|
|
7267
|
-
constructor({ apiHost: e = "https://api.avaturn.live", sessionToken: n, preloadBundle: r,
|
|
7267
|
+
constructor({ apiHost: e = "https://api.avaturn.live", sessionToken: n, preloadBundle: r, preconnect: i, keepAlive: s }) {
|
|
7268
7268
|
we(this, "inited", !1);
|
|
7269
7269
|
we(this, "mediaStream");
|
|
7270
7270
|
we(this, "session_id", "");
|
|
@@ -7280,13 +7280,13 @@ class nd {
|
|
|
7280
7280
|
headers: {
|
|
7281
7281
|
"X-Session-Token": n
|
|
7282
7282
|
}
|
|
7283
|
-
}), this.keepAlive = !!
|
|
7283
|
+
}), this.keepAlive = !!s, this.keepAlive = !!s, this.mediaStream = new MediaStream(), this.call = Ol.createCallObject({
|
|
7284
7284
|
videoSource: !1,
|
|
7285
7285
|
audioSource: !1,
|
|
7286
7286
|
dailyConfig: {
|
|
7287
7287
|
avoidEval: !0
|
|
7288
7288
|
}
|
|
7289
|
-
}), r && this.call.load();
|
|
7289
|
+
}), r && this.call.load(), i && this.fetcher.post("/sessions/start_stream");
|
|
7290
7290
|
}
|
|
7291
7291
|
startIdleTimeout() {
|
|
7292
7292
|
this.timeout = setTimeout(() => {
|
|
@@ -7307,13 +7307,13 @@ class nd {
|
|
|
7307
7307
|
url: n.room_url
|
|
7308
7308
|
}), this.inited = !0, new Promise((r, i) => {
|
|
7309
7309
|
var c, l;
|
|
7310
|
-
const s = e != null && e.timeout && e.timeout > 0 ? e == null ? void 0 : e.timeout : 3e4, a = setTimeout(i, s);
|
|
7310
|
+
const s = e != null && e.timeout && e.timeout > 0 ? e == null ? void 0 : e.timeout : 3e4, a = e != null && e.timeout ? setTimeout(() => i("Connection timeout"), s) : null;
|
|
7311
7311
|
(c = this.call) == null || c.on("participant-updated", ({ participant: p }) => {
|
|
7312
7312
|
var _, k;
|
|
7313
7313
|
if (!p.owner)
|
|
7314
7314
|
return;
|
|
7315
7315
|
const { video: h, audio: f } = p.tracks;
|
|
7316
|
-
h.persistentTrack && ((_ = this.mediaStream) == null || _.addTrack(h.persistentTrack)), f.persistentTrack && ((k = this.mediaStream) == null || k.addTrack(f.persistentTrack)), clearTimeout(a), r(null);
|
|
7316
|
+
h.persistentTrack && ((_ = this.mediaStream) == null || _.addTrack(h.persistentTrack)), f.persistentTrack && ((k = this.mediaStream) == null || k.addTrack(f.persistentTrack)), a && clearTimeout(a), r(null);
|
|
7317
7317
|
}), (l = this.call) == null || l.on("app-message", ({ data: p }) => {
|
|
7318
7318
|
var h;
|
|
7319
7319
|
p.type && ((h = this.handlers[p.type]) == null || h.forEach((f) => f(p)));
|
|
@@ -7335,9 +7335,9 @@ class nd {
|
|
|
7335
7335
|
off(e, n) {
|
|
7336
7336
|
this.handlers[e] && (this.handlers[e] = this.handlers[e].filter((r) => r !== n));
|
|
7337
7337
|
}
|
|
7338
|
-
dispose() {
|
|
7338
|
+
async dispose() {
|
|
7339
7339
|
var e;
|
|
7340
|
-
|
|
7340
|
+
this.mediaStream = new MediaStream(), this.timeout && clearTimeout(this.timeout), await ((e = this.call) == null ? void 0 : e.destroy());
|
|
7341
7341
|
}
|
|
7342
7342
|
}
|
|
7343
7343
|
export {
|
package/dist/type.d.ts
CHANGED