virtual-human-cf 1.3.0 → 1.5.0
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/README.md +148 -65
- package/dist/api/request.d.ts +2 -0
- package/dist/api/screen.d.ts +13 -0
- package/dist/components/VirtualHumanEventAdapter.vue.d.ts +8 -3
- package/dist/style.css +1 -1
- package/dist/virtual-human-cf.es.js +2061 -161
- package/dist/virtual-human-cf.umd.js +6 -1
- package/package.json +6 -2
- package/src/api/request.ts +22 -0
- package/src/api/screen.ts +36 -0
- package/src/components/VirtualHumanEventAdapter.vue +29 -0
- package/src/components/VirtualHumanPersona.vue +3 -0
- package/tsconfig.json +6 -2
- package/vite.config.ts +6 -1
|
@@ -1 +1,6 @@
|
|
|
1
|
-
(function(f,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(f=typeof globalThis<"u"?globalThis:f||self,a(f.VirtualHumanCf={},f.Vue))})(this,function(f,a){"use strict";const $=["src","muted"],_=((d,k)=>{const n=d.__vccOpts||d;for(const[r,s]of k)n[r]=s;return n})(a.defineComponent({__name:"VirtualHumanPersona",props:{videoSrc:{type:String,required:!0},visible:{type:Boolean,default:!1},isPlaying:{type:Boolean,default:!1},muted:{type:Boolean,default:!0},isDark:{type:Boolean,default:!1},screenClientId:{type:String,required:!1},wsUrl:{type:String,required:!1},styles:{type:Object,default:()=>({width:"400px",height:"500px",left:"16px",bottom:"16px"})}},emits:["update:isPlaying","ended","update:visible"],setup(d,{emit:k}){const n=d,r=k,s=a.ref(null),P=a.ref(null),e=a.ref(null),y=a.ref(!1),p=()=>{if(e.value&&e.value.close(),!(!n.wsUrl||!n.screenClientId))try{const i=new URL(n.wsUrl);i.searchParams.append("sessionId",n.screenClientId+"-persona"),e.value=new WebSocket(i.toString()),e.value.onopen=()=>{y.value=!0,console.log(`[VirtualHumanPersona] Connected to ${n.wsUrl} for session ${n.screenClientId}-persona`)},e.value.onmessage=c=>{try{const u=JSON.parse(c.data);h(u)}catch(u){console.error("[VirtualHumanPersona] Failed to parse message:",c.data,u)}},e.value.onerror=c=>{console.error("[VirtualHumanPersona] WebSocket error:",c)},e.value.onclose=()=>{y.value=!1,console.log("[VirtualHumanPersona] WebSocket disconnected")}}catch(i){console.error("[VirtualHumanPersona] Failed to initialize WebSocket:",i)}},h=i=>{const{type:c,action:u}=i;c==="control"&&(u==="play"||u==="resume"?(r("update:isPlaying",!0),r("update:visible",!0)):u==="pause"?(r("update:isPlaying",!1),r("update:visible",!0)):u==="stop"&&(r("update:isPlaying",!1),r("update:visible",!1),s.value&&(s.value.currentTime=0)))};a.watch(()=>n.screenClientId,()=>{n.screenClientId&&n.wsUrl&&p()}),a.watch(()=>n.wsUrl,()=>{n.screenClientId&&n.wsUrl&&p()}),a.watch(()=>n.isPlaying,i=>{s.value&&(i?s.value.play().catch(c=>console.error("Video play failed:",c)):s.value.pause())});const v=()=>{n.isPlaying||r("update:isPlaying",!0)},g=()=>{n.isPlaying&&r("update:isPlaying",!1)},S=()=>{r("update:isPlaying",!1),r("ended")};return a.onMounted(()=>{n.isPlaying&&s.value&&s.value.play().catch(i=>console.error("Video play failed:",i)),n.screenClientId&&n.wsUrl&&p()}),a.onUnmounted(()=>{e.value&&e.value.close()}),(i,c)=>(a.openBlock(),a.createBlock(a.Transition,{name:"fade"},{default:a.withCtx(()=>[d.visible?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["virtual-human-container",{"is-dark":d.isDark}]),style:a.normalizeStyle(d.styles)},[a.createElementVNode("div",{class:"video-wrapper",ref_key:"wrapperRef",ref:P},[a.createElementVNode("video",{ref_key:"videoRef",ref:s,src:d.videoSrc,class:"persona-video",muted:d.muted,playsinline:"",loop:"",autoPlay:"",disablePictureInPicture:"",onPlay:v,onPause:g,onEnded:S},null,40,$)],512)],6)):a.createCommentVNode("",!0)]),_:1}))}}),[["__scopeId","data-v-bf23f155"]]),B=a.defineComponent({__name:"VirtualHumanEventAdapter",props:{screenClientId:{type:String,required:!0},wsUrl:{type:String,required:!0}},emits:["eventNotifaction","controlEvent","end","pause","connected","error","playComplete"],setup(d,{emit:k}){const n=d,r=k,s=a.ref(null),P=a.ref(!1);let e=null,y=0,p=!1,h=0,v=!1;const g=new Map,S=new Set,i=new Map;let c=null;const u=t=>{if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t.trim()!==""){const l=Number(t);if(Number.isFinite(l))return l}return null},T=()=>{c!==null&&(window.clearInterval(c),c=null)},N=()=>{T(),g.clear(),S.clear(),i.clear()},M=()=>{for(const[t]of g)if(!S.has(t)&&i.has(t))return!0;return!1},I=()=>{if(!(!e||e.state!=="running")){for(const[t,l]of i){if(S.has(t))continue;const o=g.get(t);o&&e.currentTime+.005>=l&&(S.add(t),g.delete(t),r("eventNotifaction",o))}M()||T()}},E=()=>{c===null&&M()&&(c=window.setInterval(()=>{I()},30))},R=()=>{e||(e=new(window.AudioContext||window.webkitAudioContext)({sampleRate:24e3})),e.state==="suspended"&&!v&&e.resume()},W=()=>{p&&h===0&&(r("playComplete",n.screenClientId),p=!1)},q=(t,l)=>{if(R(),!!e)try{const o=window.atob(t),b=o.length,C=new Uint8Array(b);for(let m=0;m<b;m++)C[m]=o.charCodeAt(m);const w=new Int16Array(C.buffer),A=new Float32Array(w.length);for(let m=0;m<w.length;m++)A[m]=w[m]/32768;const U=e.createBuffer(1,A.length,24e3);U.getChannelData(0).set(A);const V=e.createBufferSource();V.buffer=U,V.connect(e.destination);const H=y<e.currentTime?e.currentTime:y;l!==null&&!i.has(l)&&(i.set(l,H),I(),E()),V.start(H),y=H+U.duration,h++,V.onended=()=>{h--,W()}}catch(o){console.error("[VirtualHumanEventAdapter] Failed to decode and play audio:",o)}},z=t=>{switch(t){case"play":N(),p=!1,h=0,y=0,v=!1,e&&e.state==="suspended"&&e.resume();break;case"resume":v=!1,e&&e.state==="suspended"&&e.resume(),I(),E();break;case"pause":v=!0,e&&e.state==="running"&&e.suspend();break;case"stop":N(),v=!1,e&&(e.close(),e=null),y=0,p=!1,h=0;break;case"tts_complete":p=!0,W();break;default:console.warn(`[VirtualHumanEventAdapter] Unknown control action: ${t}`)}},x=()=>{s.value&&s.value.close();try{const t=new URL(n.wsUrl);t.searchParams.append("sessionId",n.screenClientId+"-event"),s.value=new WebSocket(t.toString()),s.value.onopen=()=>{P.value=!0,r("connected"),console.log(`[VirtualHumanEventAdapter] Connected to ${n.wsUrl} for session ${n.screenClientId}-event`)},s.value.onmessage=l=>{try{const o=JSON.parse(l.data);O(o)}catch(o){console.error("[VirtualHumanEventAdapter] Failed to parse message:",l.data,o)}},s.value.onerror=l=>{console.error("[VirtualHumanEventAdapter] WebSocket error:",l),r("error",l)},s.value.onclose=()=>{P.value=!1,console.log("[VirtualHumanEventAdapter] WebSocket disconnected")}}catch(t){console.error("[VirtualHumanEventAdapter] Failed to initialize WebSocket:",t),r("error",t)}},O=t=>{const{type:l,payload:o,action:b}=t;switch(l){case"audio":const C=(o==null?void 0:o.data)||t.data;if(C){const w=u((o==null?void 0:o.index)??t.index);q(C,w)}break;case"send_event":if(t.event){console.log("adapter send_event:",t);const w=u(t.index);if(w===null){r("eventNotifaction",t);break}g.set(w,t),I(),E()}break;case"control":b&&(console.log("adapter control:",b),r("controlEvent",b),z(b));break;case"end":console.log("adapter end:",o),r("end",o);break;case"pause":console.log("adapter pause:",o),r("pause",o);break;default:console.warn(`[VirtualHumanEventAdapter] Unknown message type: ${l}`)}};return a.watch(()=>n.screenClientId,()=>{n.screenClientId&&n.wsUrl&&x()}),a.watch(()=>n.wsUrl,()=>{n.screenClientId&&n.wsUrl&&x()}),a.onMounted(()=>{n.screenClientId&&n.wsUrl&&x()}),a.onUnmounted(()=>{s.value&&s.value.close(),e&&e.close()}),(t,l)=>a.renderSlot(t.$slots,"default")}}),F={install:d=>{d.component("VirtualHumanPersona",_),d.component("VirtualHumanEventAdapter",B)}};f.VirtualHumanEventAdapter=B,f.VirtualHumanPersona=_,f.default=F,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(H,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],g):(H=typeof globalThis<"u"?globalThis:H||self,g(H.VirtualHumanCf={},H.Vue))})(this,function(H,g){"use strict";const St=["src","muted"],Be=((e,t)=>{const n=e.__vccOpts||e;for(const[r,s]of t)n[r]=s;return n})(g.defineComponent({__name:"VirtualHumanPersona",props:{videoSrc:{type:String,required:!0},visible:{type:Boolean,default:!1},isPlaying:{type:Boolean,default:!1},muted:{type:Boolean,default:!0},isDark:{type:Boolean,default:!1},screenClientId:{type:String,required:!1},wsUrl:{type:String,required:!1},styles:{type:Object,default:()=>({width:"400px",height:"500px",left:"16px",bottom:"16px"})}},emits:["update:isPlaying","ended","update:visible"],setup(e,{emit:t}){const n=e,r=t,s=g.ref(null),i=g.ref(null),o=g.ref(null),a=g.ref(!1),d=()=>{if(o.value&&o.value.close(),!(!n.wsUrl||!n.screenClientId))try{const E=new URL(n.wsUrl);E.searchParams.append("sessionId",n.screenClientId+"-persona"),o.value=new WebSocket(E.toString()),o.value.onopen=()=>{a.value=!0,console.log(`[VirtualHumanPersona] Connected to ${n.wsUrl} for session ${n.screenClientId}-persona`)},o.value.onmessage=c=>{try{const p=JSON.parse(c.data);f(p)}catch(p){console.error("[VirtualHumanPersona] Failed to parse message:",c.data,p)}},o.value.onerror=c=>{console.error("[VirtualHumanPersona] WebSocket error:",c)},o.value.onclose=()=>{a.value=!1,console.log("[VirtualHumanPersona] WebSocket disconnected")}}catch(E){console.error("[VirtualHumanPersona] Failed to initialize WebSocket:",E)}},f=E=>{const{type:c,action:p}=E;c==="control"&&(p==="play"||p==="resume"?(r("update:isPlaying",!0),r("update:visible",!0)):p==="pause"?(s.value&&s.value.pause(),r("update:isPlaying",!1),r("update:visible",!0)):p==="stop"&&(r("update:isPlaying",!1),r("update:visible",!1),s.value&&(s.value.currentTime=0)))};g.watch(()=>n.screenClientId,()=>{n.screenClientId&&n.wsUrl&&d()}),g.watch(()=>n.wsUrl,()=>{n.screenClientId&&n.wsUrl&&d()}),g.watch(()=>n.isPlaying,E=>{s.value&&(E?s.value.play().catch(c=>console.error("Video play failed:",c)):s.value.pause())});const u=()=>{n.isPlaying||r("update:isPlaying",!0)},m=()=>{n.isPlaying&&r("update:isPlaying",!1)},w=()=>{r("update:isPlaying",!1),r("ended")};return g.onMounted(()=>{n.isPlaying&&s.value&&s.value.play().catch(E=>console.error("Video play failed:",E)),n.screenClientId&&n.wsUrl&&d()}),g.onUnmounted(()=>{o.value&&o.value.close()}),(E,c)=>(g.openBlock(),g.createBlock(g.Transition,{name:"fade"},{default:g.withCtx(()=>[e.visible?(g.openBlock(),g.createElementBlock("div",{key:0,class:g.normalizeClass(["virtual-human-container",{"is-dark":e.isDark}]),style:g.normalizeStyle(e.styles)},[g.createElementVNode("div",{class:"video-wrapper",ref_key:"wrapperRef",ref:i},[g.createElementVNode("video",{ref_key:"videoRef",ref:s,src:e.videoSrc,class:"persona-video",muted:e.muted,playsinline:"",loop:"",autoPlay:"",disablePictureInPicture:"",onPlay:u,onPause:m,onEnded:w},null,40,St)],512)],6)):g.createCommentVNode("",!0)]),_:1}))}}),[["__scopeId","data-v-02ec3645"]]);function Ie(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ot}=Object.prototype,{getPrototypeOf:Re}=Object,{iterator:le,toStringTag:Le}=Symbol,ce=(e=>t=>{const n=Ot.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),I=e=>(e=e.toLowerCase(),t=>ce(t)===e),ue=e=>t=>typeof t===e,{isArray:Q}=Array,Z=ue("undefined");function te(e){return e!==null&&!Z(e)&&e.constructor!==null&&!Z(e.constructor)&&N(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const De=I("ArrayBuffer");function At(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&De(e.buffer),t}const Tt=ue("string"),N=ue("function"),je=ue("number"),ne=e=>e!==null&&typeof e=="object",Ct=e=>e===!0||e===!1,fe=e=>{if(ce(e)!=="object")return!1;const t=Re(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Le in e)&&!(le in e)},Pt=e=>{if(!ne(e)||te(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},xt=I("Date"),_t=I("File"),Nt=e=>!!(e&&typeof e.uri<"u"),Ut=e=>e&&typeof e.getParts<"u",kt=I("Blob"),Ft=I("FileList"),Bt=e=>ne(e)&&N(e.pipe);function It(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const ve=It(),He=typeof ve.FormData<"u"?ve.FormData:void 0,Lt=e=>{let t;return e&&(He&&e instanceof He||N(e.append)&&((t=ce(e))==="formdata"||t==="object"&&N(e.toString)&&e.toString()==="[object FormData]"))},Dt=I("URLSearchParams"),[jt,vt,Ht,qt]=["ReadableStream","Request","Response","Headers"].map(I),Mt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function re(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),Q(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{if(te(e))return;const i=n?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let a;for(r=0;r<o;r++)a=i[r],t.call(null,e[a],a,e)}}function qe(e,t){if(te(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const z=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Me=e=>!Z(e)&&e!==z;function Se(){const{caseless:e,skipUndefined:t}=Me(this)&&this||{},n={},r=(s,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const o=e&&qe(n,i)||i;fe(n[o])&&fe(s)?n[o]=Se(n[o],s):fe(s)?n[o]=Se({},s):Q(s)?n[o]=s.slice():(!t||!Z(s))&&(n[o]=s)};for(let s=0,i=arguments.length;s<i;s++)arguments[s]&&re(arguments[s],r);return n}const $t=(e,t,n,{allOwnKeys:r}={})=>(re(t,(s,i)=>{n&&N(s)?Object.defineProperty(e,i,{value:Ie(s,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),zt=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Wt=(e,t,n,r)=>{let s,i,o;const a={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)o=s[i],(!r||r(o,e,t))&&!a[o]&&(t[o]=e[o],a[o]=!0);e=n!==!1&&Re(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Jt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Kt=e=>{if(!e)return null;if(Q(e))return e;let t=e.length;if(!je(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Xt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Re(Uint8Array)),Gt=(e,t)=>{const r=(e&&e[le]).call(e);let s;for(;(s=r.next())&&!s.done;){const i=s.value;t.call(e,i[0],i[1])}},Qt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Zt=I("HTMLFormElement"),Yt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),$e=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),en=I("RegExp"),Ve=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};re(n,(s,i)=>{let o;(o=t(s,i,e))!==!1&&(r[i]=o||s)}),Object.defineProperties(e,r)},tn=e=>{Ve(e,(t,n)=>{if(N(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(N(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},nn=(e,t)=>{const n={},r=s=>{s.forEach(i=>{n[i]=!0})};return Q(e)?r(e):r(String(e).split(t)),n},rn=()=>{},sn=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function on(e){return!!(e&&N(e.append)&&e[Le]==="FormData"&&e[le])}const an=e=>{const t=new Array(10),n=(r,s)=>{if(ne(r)){if(t.indexOf(r)>=0)return;if(te(r))return r;if(!("toJSON"in r)){t[s]=r;const i=Q(r)?[]:{};return re(r,(o,a)=>{const d=n(o,s+1);!Z(d)&&(i[a]=d)}),t[s]=void 0,i}}return r};return n(e,0)},ln=I("AsyncFunction"),cn=e=>e&&(ne(e)||N(e))&&N(e.then)&&N(e.catch),ze=((e,t)=>e?setImmediate:t?((n,r)=>(z.addEventListener("message",({source:s,data:i})=>{s===z&&i===n&&r.length&&r.shift()()},!1),s=>{r.push(s),z.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",N(z.postMessage)),un=typeof queueMicrotask<"u"?queueMicrotask.bind(z):typeof process<"u"&&process.nextTick||ze,l={isArray:Q,isArrayBuffer:De,isBuffer:te,isFormData:Lt,isArrayBufferView:At,isString:Tt,isNumber:je,isBoolean:Ct,isObject:ne,isPlainObject:fe,isEmptyObject:Pt,isReadableStream:jt,isRequest:vt,isResponse:Ht,isHeaders:qt,isUndefined:Z,isDate:xt,isFile:_t,isReactNativeBlob:Nt,isReactNative:Ut,isBlob:kt,isRegExp:en,isFunction:N,isStream:Bt,isURLSearchParams:Dt,isTypedArray:Xt,isFileList:Ft,forEach:re,merge:Se,extend:$t,trim:Mt,stripBOM:Vt,inherits:zt,toFlatObject:Wt,kindOf:ce,kindOfTest:I,endsWith:Jt,toArray:Kt,forEachEntry:Gt,matchAll:Qt,isHTMLForm:Zt,hasOwnProperty:$e,hasOwnProp:$e,reduceDescriptors:Ve,freezeMethods:tn,toObjectSet:nn,toCamelCase:Yt,noop:rn,toFiniteNumber:sn,findKey:qe,global:z,isContextDefined:Me,isSpecCompliantForm:on,toJSONObject:an,isAsyncFn:ln,isThenable:cn,setImmediate:ze,asap:un,isIterable:e=>e!=null&&N(e[le])};let b=class Et extends Error{static from(t,n,r,s,i,o){const a=new Et(t.message,n||t.code,r,s,i);return a.cause=t,a.name=t.name,t.status!=null&&a.status==null&&(a.status=t.status),o&&Object.assign(a,o),a}constructor(t,n,r,s,i){super(t),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),s&&(this.request=s),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:l.toJSONObject(this.config),code:this.code,status:this.status}}};b.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",b.ERR_BAD_OPTION="ERR_BAD_OPTION",b.ECONNABORTED="ECONNABORTED",b.ETIMEDOUT="ETIMEDOUT",b.ERR_NETWORK="ERR_NETWORK",b.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",b.ERR_DEPRECATED="ERR_DEPRECATED",b.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",b.ERR_BAD_REQUEST="ERR_BAD_REQUEST",b.ERR_CANCELED="ERR_CANCELED",b.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",b.ERR_INVALID_URL="ERR_INVALID_URL";const fn=null;function Oe(e){return l.isPlainObject(e)||l.isArray(e)}function We(e){return l.endsWith(e,"[]")?e.slice(0,-2):e}function Ae(e,t,n){return e?e.concat(t).map(function(s,i){return s=We(s),!n&&i?"["+s+"]":s}).join(n?".":""):t}function dn(e){return l.isArray(e)&&!e.some(Oe)}const pn=l.toFlatObject(l,{},null,function(t){return/^is[A-Z]/.test(t)});function de(e,t,n){if(!l.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=l.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(p,h){return!l.isUndefined(h[p])});const r=n.metaTokens,s=n.visitor||u,i=n.dots,o=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&l.isSpecCompliantForm(t);if(!l.isFunction(s))throw new TypeError("visitor must be a function");function f(c){if(c===null)return"";if(l.isDate(c))return c.toISOString();if(l.isBoolean(c))return c.toString();if(!d&&l.isBlob(c))throw new b("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(c)||l.isTypedArray(c)?d&&typeof Blob=="function"?new Blob([c]):Buffer.from(c):c}function u(c,p,h){let O=c;if(l.isReactNative(t)&&l.isReactNativeBlob(c))return t.append(Ae(h,p,i),f(c)),!1;if(c&&!h&&typeof c=="object"){if(l.endsWith(p,"{}"))p=r?p:p.slice(0,-2),c=JSON.stringify(c);else if(l.isArray(c)&&dn(c)||(l.isFileList(c)||l.endsWith(p,"[]"))&&(O=l.toArray(c)))return p=We(p),O.forEach(function(T,C){!(l.isUndefined(T)||T===null)&&t.append(o===!0?Ae([p],C,i):o===null?p:p+"[]",f(T))}),!1}return Oe(c)?!0:(t.append(Ae(h,p,i),f(c)),!1)}const m=[],w=Object.assign(pn,{defaultVisitor:u,convertValue:f,isVisitable:Oe});function E(c,p){if(!l.isUndefined(c)){if(m.indexOf(c)!==-1)throw Error("Circular reference detected in "+p.join("."));m.push(c),l.forEach(c,function(O,F){(!(l.isUndefined(O)||O===null)&&s.call(t,O,l.isString(F)?F.trim():F,p,w))===!0&&E(O,p?p.concat(F):[F])}),m.pop()}}if(!l.isObject(e))throw new TypeError("data must be an object");return E(e),t}function Je(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Te(e,t){this._pairs=[],e&&de(e,this,t)}const Ke=Te.prototype;Ke.append=function(t,n){this._pairs.push([t,n])},Ke.toString=function(t){const n=t?function(r){return t.call(this,r,Je)}:Je;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function hn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Xe(e,t,n){if(!t)return e;const r=n&&n.encode||hn,s=l.isFunction(n)?{serialize:n}:n,i=s&&s.serialize;let o;if(i?o=i(t,s):o=l.isURLSearchParams(t)?t.toString():new Te(t,s).toString(r),o){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class Ge{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){l.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ce={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},mn={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Te,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Pe=typeof window<"u"&&typeof document<"u",xe=typeof navigator=="object"&&navigator||void 0,yn=Pe&&(!xe||["ReactNative","NativeScript","NS"].indexOf(xe.product)<0),bn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",wn=Pe&&window.location.href||"http://localhost",x={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Pe,hasStandardBrowserEnv:yn,hasStandardBrowserWebWorkerEnv:bn,navigator:xe,origin:wn},Symbol.toStringTag,{value:"Module"})),...mn};function gn(e,t){return de(e,new x.classes.URLSearchParams,{visitor:function(n,r,s,i){return x.isNode&&l.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function En(e){return l.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Rn(e){const t={},n=Object.keys(e);let r;const s=n.length;let i;for(r=0;r<s;r++)i=n[r],t[i]=e[i];return t}function Qe(e){function t(n,r,s,i){let o=n[i++];if(o==="__proto__")return!0;const a=Number.isFinite(+o),d=i>=n.length;return o=!o&&l.isArray(s)?s.length:o,d?(l.hasOwnProp(s,o)?s[o]=[s[o],r]:s[o]=r,!a):((!s[o]||!l.isObject(s[o]))&&(s[o]=[]),t(n,r,s[o],i)&&l.isArray(s[o])&&(s[o]=Rn(s[o])),!a)}if(l.isFormData(e)&&l.isFunction(e.entries)){const n={};return l.forEachEntry(e,(r,s)=>{t(En(r),s,n,0)}),n}return null}function Sn(e,t,n){if(l.isString(e))try{return(t||JSON.parse)(e),l.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const se={transitional:Ce,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,i=l.isObject(t);if(i&&l.isHTMLForm(t)&&(t=new FormData(t)),l.isFormData(t))return s?JSON.stringify(Qe(t)):t;if(l.isArrayBuffer(t)||l.isBuffer(t)||l.isStream(t)||l.isFile(t)||l.isBlob(t)||l.isReadableStream(t))return t;if(l.isArrayBufferView(t))return t.buffer;if(l.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return gn(t,this.formSerializer).toString();if((a=l.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return de(a?{"files[]":t}:t,d&&new d,this.formSerializer)}}return i||s?(n.setContentType("application/json",!1),Sn(t)):t}],transformResponse:[function(t){const n=this.transitional||se.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(l.isResponse(t)||l.isReadableStream(t))return t;if(t&&l.isString(t)&&(r&&!this.responseType||s)){const o=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t,this.parseReviver)}catch(a){if(o)throw a.name==="SyntaxError"?b.from(a,b.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:x.classes.FormData,Blob:x.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};l.forEach(["delete","get","head","post","put","patch"],e=>{se.headers[e]={}});const On=l.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),An=e=>{const t={};let n,r,s;return e&&e.split(`
|
|
2
|
+
`).forEach(function(o){s=o.indexOf(":"),n=o.substring(0,s).trim().toLowerCase(),r=o.substring(s+1).trim(),!(!n||t[n]&&On[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ze=Symbol("internals");function oe(e){return e&&String(e).trim().toLowerCase()}function pe(e){return e===!1||e==null?e:l.isArray(e)?e.map(pe):String(e).replace(/[\r\n]+$/,"")}function Tn(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const Cn=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function _e(e,t,n,r,s){if(l.isFunction(r))return r.call(this,t,n);if(s&&(t=n),!!l.isString(t)){if(l.isString(r))return t.indexOf(r)!==-1;if(l.isRegExp(r))return r.test(t)}}function Pn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function xn(e,t){const n=l.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,i,o){return this[r].call(this,t,s,i,o)},configurable:!0})})}let U=class{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function i(a,d,f){const u=oe(d);if(!u)throw new Error("header name must be a non-empty string");const m=l.findKey(s,u);(!m||s[m]===void 0||f===!0||f===void 0&&s[m]!==!1)&&(s[m||d]=pe(a))}const o=(a,d)=>l.forEach(a,(f,u)=>i(f,u,d));if(l.isPlainObject(t)||t instanceof this.constructor)o(t,n);else if(l.isString(t)&&(t=t.trim())&&!Cn(t))o(An(t),n);else if(l.isObject(t)&&l.isIterable(t)){let a={},d,f;for(const u of t){if(!l.isArray(u))throw TypeError("Object iterator must return a key-value pair");a[f=u[0]]=(d=a[f])?l.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}o(a,n)}else t!=null&&i(n,t,r);return this}get(t,n){if(t=oe(t),t){const r=l.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Tn(s);if(l.isFunction(n))return n.call(this,s,r);if(l.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=oe(t),t){const r=l.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||_e(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function i(o){if(o=oe(o),o){const a=l.findKey(r,o);a&&(!n||_e(r,r[a],a,n))&&(delete r[a],s=!0)}}return l.isArray(t)?t.forEach(i):i(t),s}clear(t){const n=Object.keys(this);let r=n.length,s=!1;for(;r--;){const i=n[r];(!t||_e(this,this[i],i,t,!0))&&(delete this[i],s=!0)}return s}normalize(t){const n=this,r={};return l.forEach(this,(s,i)=>{const o=l.findKey(r,i);if(o){n[o]=pe(s),delete n[i];return}const a=t?Pn(i):String(i).trim();a!==i&&delete n[i],n[a]=pe(s),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return l.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&l.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
3
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[Ze]=this[Ze]={accessors:{}}).accessors,s=this.prototype;function i(o){const a=oe(o);r[a]||(xn(s,o),r[a]=!0)}return l.isArray(t)?t.forEach(i):i(t),this}};U.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),l.reduceDescriptors(U.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),l.freezeMethods(U);function Ne(e,t){const n=this||se,r=t||n,s=U.from(r.headers);let i=r.data;return l.forEach(e,function(a){i=a.call(n,i,s.normalize(),t?t.status:void 0)}),s.normalize(),i}function Ye(e){return!!(e&&e.__CANCEL__)}let ie=class extends b{constructor(t,n,r){super(t??"canceled",b.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function et(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new b("Request failed with status code "+n.status,[b.ERR_BAD_REQUEST,b.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function _n(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Nn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,i=0,o;return t=t!==void 0?t:1e3,function(d){const f=Date.now(),u=r[i];o||(o=f),n[s]=d,r[s]=f;let m=i,w=0;for(;m!==s;)w+=n[m++],m=m%e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),f-o<t)return;const E=u&&f-u;return E?Math.round(w*1e3/E):void 0}}function Un(e,t){let n=0,r=1e3/t,s,i;const o=(f,u=Date.now())=>{n=u,s=null,i&&(clearTimeout(i),i=null),e(...f)};return[(...f)=>{const u=Date.now(),m=u-n;m>=r?o(f,u):(s=f,i||(i=setTimeout(()=>{i=null,o(s)},r-m)))},()=>s&&o(s)]}const he=(e,t,n=3)=>{let r=0;const s=Nn(50,250);return Un(i=>{const o=i.loaded,a=i.lengthComputable?i.total:void 0,d=o-r,f=s(d),u=o<=a;r=o;const m={loaded:o,total:a,progress:a?o/a:void 0,bytes:d,rate:f||void 0,estimated:f&&a&&u?(a-o)/f:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(m)},n)},tt=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},nt=e=>(...t)=>l.asap(()=>e(...t)),kn=x.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,x.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(x.origin),x.navigator&&/(msie|trident)/i.test(x.navigator.userAgent)):()=>!0,Fn=x.hasStandardBrowserEnv?{write(e,t,n,r,s,i,o){if(typeof document>"u")return;const a=[`${e}=${encodeURIComponent(t)}`];l.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),l.isString(r)&&a.push(`path=${r}`),l.isString(s)&&a.push(`domain=${s}`),i===!0&&a.push("secure"),l.isString(o)&&a.push(`SameSite=${o}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Bn(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function In(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function rt(e,t,n){let r=!Bn(t);return e&&(r||n==!1)?In(e,t):t}const st=e=>e instanceof U?{...e}:e;function W(e,t){t=t||{};const n={};function r(f,u,m,w){return l.isPlainObject(f)&&l.isPlainObject(u)?l.merge.call({caseless:w},f,u):l.isPlainObject(u)?l.merge({},u):l.isArray(u)?u.slice():u}function s(f,u,m,w){if(l.isUndefined(u)){if(!l.isUndefined(f))return r(void 0,f,m,w)}else return r(f,u,m,w)}function i(f,u){if(!l.isUndefined(u))return r(void 0,u)}function o(f,u){if(l.isUndefined(u)){if(!l.isUndefined(f))return r(void 0,f)}else return r(void 0,u)}function a(f,u,m){if(m in t)return r(f,u);if(m in e)return r(void 0,f)}const d={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(f,u,m)=>s(st(f),st(u),m,!0)};return l.forEach(Object.keys({...e,...t}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const m=l.hasOwnProp(d,u)?d[u]:s,w=m(e[u],t[u],u);l.isUndefined(w)&&m!==a||(n[u]=w)}),n}const ot=e=>{const t=W({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:i,headers:o,auth:a}=t;if(t.headers=o=U.from(o),t.url=Xe(rt(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),l.isFormData(n)){if(x.hasStandardBrowserEnv||x.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(l.isFunction(n.getHeaders)){const d=n.getHeaders(),f=["content-type","content-length"];Object.entries(d).forEach(([u,m])=>{f.includes(u.toLowerCase())&&o.set(u,m)})}}if(x.hasStandardBrowserEnv&&(r&&l.isFunction(r)&&(r=r(t)),r||r!==!1&&kn(t.url))){const d=s&&i&&Fn.read(i);d&&o.set(s,d)}return t},Ln=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const s=ot(e);let i=s.data;const o=U.from(s.headers).normalize();let{responseType:a,onUploadProgress:d,onDownloadProgress:f}=s,u,m,w,E,c;function p(){E&&E(),c&&c(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let h=new XMLHttpRequest;h.open(s.method.toUpperCase(),s.url,!0),h.timeout=s.timeout;function O(){if(!h)return;const T=U.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),k={data:!a||a==="text"||a==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:T,config:e,request:h};et(function(_){n(_),p()},function(_){r(_),p()},k),h=null}"onloadend"in h?h.onloadend=O:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(O)},h.onabort=function(){h&&(r(new b("Request aborted",b.ECONNABORTED,e,h)),h=null)},h.onerror=function(C){const k=C&&C.message?C.message:"Network Error",D=new b(k,b.ERR_NETWORK,e,h);D.event=C||null,r(D),h=null},h.ontimeout=function(){let C=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const k=s.transitional||Ce;s.timeoutErrorMessage&&(C=s.timeoutErrorMessage),r(new b(C,k.clarifyTimeoutError?b.ETIMEDOUT:b.ECONNABORTED,e,h)),h=null},i===void 0&&o.setContentType(null),"setRequestHeader"in h&&l.forEach(o.toJSON(),function(C,k){h.setRequestHeader(k,C)}),l.isUndefined(s.withCredentials)||(h.withCredentials=!!s.withCredentials),a&&a!=="json"&&(h.responseType=s.responseType),f&&([w,c]=he(f,!0),h.addEventListener("progress",w)),d&&h.upload&&([m,E]=he(d),h.upload.addEventListener("progress",m),h.upload.addEventListener("loadend",E)),(s.cancelToken||s.signal)&&(u=T=>{h&&(r(!T||T.type?new ie(null,e,h):T),h.abort(),h=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));const F=_n(s.url);if(F&&x.protocols.indexOf(F)===-1){r(new b("Unsupported protocol "+F+":",b.ERR_BAD_REQUEST,e));return}h.send(i||null)})},Dn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const i=function(f){if(!s){s=!0,a();const u=f instanceof Error?f:this.reason;r.abort(u instanceof b?u:new ie(u instanceof Error?u.message:u))}};let o=t&&setTimeout(()=>{o=null,i(new b(`timeout of ${t}ms exceeded`,b.ETIMEDOUT))},t);const a=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(f=>{f.unsubscribe?f.unsubscribe(i):f.removeEventListener("abort",i)}),e=null)};e.forEach(f=>f.addEventListener("abort",i));const{signal:d}=r;return d.unsubscribe=()=>l.asap(a),d}},jn=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,s;for(;r<n;)s=r+t,yield e.slice(r,s),r=s},vn=async function*(e,t){for await(const n of Hn(e))yield*jn(n,t)},Hn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},it=(e,t,n,r)=>{const s=vn(e,t);let i=0,o,a=d=>{o||(o=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:f,value:u}=await s.next();if(f){a(),d.close();return}let m=u.byteLength;if(n){let w=i+=m;n(w)}d.enqueue(new Uint8Array(u))}catch(f){throw a(f),f}},cancel(d){return a(d),s.return()}},{highWaterMark:2})},at=64*1024,{isFunction:me}=l,qn=(({Request:e,Response:t})=>({Request:e,Response:t}))(l.global),{ReadableStream:lt,TextEncoder:ct}=l.global,ut=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Mn=e=>{e=l.merge.call({skipUndefined:!0},qn,e);const{fetch:t,Request:n,Response:r}=e,s=t?me(t):typeof fetch=="function",i=me(n),o=me(r);if(!s)return!1;const a=s&&me(lt),d=s&&(typeof ct=="function"?(c=>p=>c.encode(p))(new ct):async c=>new Uint8Array(await new n(c).arrayBuffer())),f=i&&a&&ut(()=>{let c=!1;const p=new lt,h=new n(x.origin,{body:p,method:"POST",get duplex(){return c=!0,"half"}}).headers.has("Content-Type");return p.cancel(),c&&!h}),u=o&&a&&ut(()=>l.isReadableStream(new r("").body)),m={stream:u&&(c=>c.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(c=>{!m[c]&&(m[c]=(p,h)=>{let O=p&&p[c];if(O)return O.call(p);throw new b(`Response type '${c}' is not supported`,b.ERR_NOT_SUPPORT,h)})});const w=async c=>{if(c==null)return 0;if(l.isBlob(c))return c.size;if(l.isSpecCompliantForm(c))return(await new n(x.origin,{method:"POST",body:c}).arrayBuffer()).byteLength;if(l.isArrayBufferView(c)||l.isArrayBuffer(c))return c.byteLength;if(l.isURLSearchParams(c)&&(c=c+""),l.isString(c))return(await d(c)).byteLength},E=async(c,p)=>{const h=l.toFiniteNumber(c.getContentLength());return h??w(p)};return async c=>{let{url:p,method:h,data:O,signal:F,cancelToken:T,timeout:C,onDownloadProgress:k,onUploadProgress:D,responseType:_,headers:$,withCredentials:V="same-origin",fetchOptions:ge}=ot(c),ae=t||fetch;_=_?(_+"").toLowerCase():"text";let Y=Dn([F,T&&T.toAbortSignal()],C),K=null;const L=Y&&Y.unsubscribe&&(()=>{Y.unsubscribe()});let Ee;try{if(D&&f&&h!=="get"&&h!=="head"&&(Ee=await E($,O))!==0){let P=new n(p,{method:"POST",body:O,duplex:"half"}),v;if(l.isFormData(O)&&(v=P.headers.get("content-type"))&&$.setContentType(v),P.body){const[G,q]=tt(Ee,he(nt(D)));O=it(P.body,at,G,q)}}l.isString(V)||(V=V?"include":"omit");const y=i&&"credentials"in n.prototype,A={...ge,signal:Y,method:h.toUpperCase(),headers:$.normalize().toJSON(),body:O,duplex:"half",credentials:y?V:void 0};K=i&&new n(p,A);let R=await(i?ae(K,ge):ae(p,A));const j=u&&(_==="stream"||_==="response");if(u&&(k||j&&L)){const P={};["status","statusText","headers"].forEach(ee=>{P[ee]=R[ee]});const v=l.toFiniteNumber(R.headers.get("content-length")),[G,q]=k&&tt(v,he(nt(k),!0))||[];R=new r(it(R.body,at,G,()=>{q&&q(),L&&L()}),P)}_=_||"text";let X=await m[l.findKey(m,_)||"text"](R,c);return!j&&L&&L(),await new Promise((P,v)=>{et(P,v,{data:X,headers:U.from(R.headers),status:R.status,statusText:R.statusText,config:c,request:K})})}catch(y){throw L&&L(),y&&y.name==="TypeError"&&/Load failed|fetch/i.test(y.message)?Object.assign(new b("Network Error",b.ERR_NETWORK,c,K,y&&y.response),{cause:y.cause||y}):b.from(y,y&&y.code,c,K,y&&y.response)}}},$n=new Map,ft=e=>{let t=e&&e.env||{};const{fetch:n,Request:r,Response:s}=t,i=[r,s,n];let o=i.length,a=o,d,f,u=$n;for(;a--;)d=i[a],f=u.get(d),f===void 0&&u.set(d,f=a?new Map:Mn(t)),u=f;return f};ft();const Ue={http:fn,xhr:Ln,fetch:{get:ft}};l.forEach(Ue,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const dt=e=>`- ${e}`,Vn=e=>l.isFunction(e)||e===null||e===!1;function zn(e,t){e=l.isArray(e)?e:[e];const{length:n}=e;let r,s;const i={};for(let o=0;o<n;o++){r=e[o];let a;if(s=r,!Vn(r)&&(s=Ue[(a=String(r)).toLowerCase()],s===void 0))throw new b(`Unknown adapter '${a}'`);if(s&&(l.isFunction(s)||(s=s.get(t))))break;i[a||"#"+o]=s}if(!s){const o=Object.entries(i).map(([d,f])=>`adapter ${d} `+(f===!1?"is not supported by the environment":"is not available in the build"));let a=n?o.length>1?`since :
|
|
4
|
+
`+o.map(dt).join(`
|
|
5
|
+
`):" "+dt(o[0]):"as no adapter specified";throw new b("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return s}const pt={getAdapter:zn,adapters:Ue};function ke(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ie(null,e)}function ht(e){return ke(e),e.headers=U.from(e.headers),e.data=Ne.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),pt.getAdapter(e.adapter||se.adapter,e)(e).then(function(r){return ke(e),r.data=Ne.call(e,e.transformResponse,r),r.headers=U.from(r.headers),r},function(r){return Ye(r)||(ke(e),r&&r.response&&(r.response.data=Ne.call(e,e.transformResponse,r.response),r.response.headers=U.from(r.response.headers))),Promise.reject(r)})}const mt="1.14.0",ye={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ye[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const yt={};ye.transitional=function(t,n,r){function s(i,o){return"[Axios v"+mt+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,a)=>{if(t===!1)throw new b(s(o," has been removed"+(n?" in "+n:"")),b.ERR_DEPRECATED);return n&&!yt[o]&&(yt[o]=!0,console.warn(s(o," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,o,a):!0}},ye.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Wn(e,t,n){if(typeof e!="object")throw new b("options must be an object",b.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const i=r[s],o=t[i];if(o){const a=e[i],d=a===void 0||o(a,i,e);if(d!==!0)throw new b("option "+i+" must be "+d,b.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new b("Unknown option "+i,b.ERR_BAD_OPTION)}}const be={assertOptions:Wn,validators:ye},B=be.validators;let J=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ge,response:new Ge}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const i=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
6
|
+
`+i):r.stack=i}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=W(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:i}=n;r!==void 0&&be.assertOptions(r,{silentJSONParsing:B.transitional(B.boolean),forcedJSONParsing:B.transitional(B.boolean),clarifyTimeoutError:B.transitional(B.boolean),legacyInterceptorReqResOrdering:B.transitional(B.boolean)},!1),s!=null&&(l.isFunction(s)?n.paramsSerializer={serialize:s}:be.assertOptions(s,{encode:B.function,serialize:B.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),be.assertOptions(n,{baseUrl:B.spelling("baseURL"),withXsrfToken:B.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&l.merge(i.common,i[n.method]);i&&l.forEach(["delete","get","head","post","put","patch","common"],c=>{delete i[c]}),n.headers=U.concat(o,i);const a=[];let d=!0;this.interceptors.request.forEach(function(p){if(typeof p.runWhen=="function"&&p.runWhen(n)===!1)return;d=d&&p.synchronous;const h=n.transitional||Ce;h&&h.legacyInterceptorReqResOrdering?a.unshift(p.fulfilled,p.rejected):a.push(p.fulfilled,p.rejected)});const f=[];this.interceptors.response.forEach(function(p){f.push(p.fulfilled,p.rejected)});let u,m=0,w;if(!d){const c=[ht.bind(this),void 0];for(c.unshift(...a),c.push(...f),w=c.length,u=Promise.resolve(n);m<w;)u=u.then(c[m++],c[m++]);return u}w=a.length;let E=n;for(;m<w;){const c=a[m++],p=a[m++];try{E=c(E)}catch(h){p.call(this,h);break}}try{u=ht.call(this,E)}catch(c){return Promise.reject(c)}for(m=0,w=f.length;m<w;)u=u.then(f[m++],f[m++]);return u}getUri(t){t=W(this.defaults,t);const n=rt(t.baseURL,t.url,t.allowAbsoluteUrls);return Xe(n,t.params,t.paramsSerializer)}};l.forEach(["delete","get","head","options"],function(t){J.prototype[t]=function(n,r){return this.request(W(r||{},{method:t,url:n,data:(r||{}).data}))}}),l.forEach(["post","put","patch"],function(t){function n(r){return function(i,o,a){return this.request(W(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}J.prototype[t]=n(),J.prototype[t+"Form"]=n(!0)});let Jn=class Rt{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(s=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(a=>{r.subscribe(a),i=a}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},t(function(i,o,a){r.reason||(r.reason=new ie(i,o,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Rt(function(s){t=s}),cancel:t}}};function Kn(e){return function(n){return e.apply(null,n)}}function Xn(e){return l.isObject(e)&&e.isAxiosError===!0}const Fe={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Fe).forEach(([e,t])=>{Fe[t]=e});function bt(e){const t=new J(e),n=Ie(J.prototype.request,t);return l.extend(n,J.prototype,t,{allOwnKeys:!0}),l.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return bt(W(e,s))},n}const S=bt(se);S.Axios=J,S.CanceledError=ie,S.CancelToken=Jn,S.isCancel=Ye,S.VERSION=mt,S.toFormData=de,S.AxiosError=b,S.Cancel=S.CanceledError,S.all=function(t){return Promise.all(t)},S.spread=Kn,S.isAxiosError=Xn,S.mergeConfig=W,S.AxiosHeaders=U,S.formToJSON=e=>Qe(l.isHTMLForm(e)?new FormData(e):e),S.getAdapter=pt.getAdapter,S.HttpStatusCode=Fe,S.default=S;const{Axios:or,AxiosError:ir,CanceledError:ar,isCancel:lr,CancelToken:cr,VERSION:ur,all:fr,Cancel:dr,isAxiosError:pr,spread:hr,toFormData:mr,AxiosHeaders:yr,HttpStatusCode:br,formToJSON:wr,getAdapter:gr,mergeConfig:Er}=S,wt=S.create({baseURL:"http://t1.lingganai.cyou:90",timeout:1e4});wt.interceptors.response.use(e=>{const t=e.data;return t.code===200?t.data:Promise.reject(new Error(t.message||"Error"))},e=>Promise.reject(e));const we=(e,t)=>wt.post("/api/screen/control",{screenClientId:e,action:t}),gt=g.defineComponent({__name:"VirtualHumanEventAdapter",props:{screenClientId:{type:String,required:!0},wsUrl:{type:String,required:!0}},emits:["eventNotifaction","controlEvent","end","pause","connected","error","playComplete"],setup(e,{expose:t,emit:n}){const r=e,s=n,i=g.ref(null),o=g.ref(!1);let a=null,d=0,f=!1,u=0,m=!1;const w=new Map,E=new Set,c=new Map;let p=null;t({play:()=>o.value?we(r.screenClientId,"play").then(()=>Promise.resolve(!0)).catch(()=>Promise.reject(!1)):Promise.reject(!1),pause:()=>o.value?we(r.screenClientId,"pause").then(()=>Promise.resolve(!0)).catch(()=>Promise.reject(!1)):Promise.reject(!1),resume:()=>o.value?we(r.screenClientId,"resume").then(()=>Promise.resolve(!0)).catch(()=>Promise.reject(!1)):Promise.reject(!1),stop:()=>o.value?we(r.screenClientId,"stop").then(()=>Promise.resolve(!0)).catch(()=>Promise.reject(!1)):Promise.reject(!1)});const C=y=>{if(typeof y=="number"&&Number.isFinite(y))return y;if(typeof y=="string"&&y.trim()!==""){const A=Number(y);if(Number.isFinite(A))return A}return null},k=()=>{p!==null&&(window.clearInterval(p),p=null)},D=()=>{k(),w.clear(),E.clear(),c.clear()},_=()=>{for(const[y]of w)if(!E.has(y)&&c.has(y))return!0;return!1},$=()=>{if(!(!a||a.state!=="running")){for(const[y,A]of c){if(E.has(y))continue;const R=w.get(y);R&&a.currentTime+.005>=A&&(E.add(y),w.delete(y),s("eventNotifaction",R))}_()||k()}},V=()=>{p===null&&_()&&(p=window.setInterval(()=>{$()},30))},ge=()=>{a||(a=new(window.AudioContext||window.webkitAudioContext)({sampleRate:24e3})),a.state==="suspended"&&!m&&a.resume()},ae=()=>{f&&u===0&&(s("playComplete",r.screenClientId),f=!1)},Y=(y,A)=>{if(ge(),!!a)try{const R=window.atob(y),j=R.length,X=new Uint8Array(j);for(let M=0;M<j;M++)X[M]=R.charCodeAt(M);const P=new Int16Array(X.buffer),v=new Float32Array(P.length);for(let M=0;M<P.length;M++)v[M]=P[M]/32768;const G=a.createBuffer(1,v.length,24e3);G.getChannelData(0).set(v);const q=a.createBufferSource();q.buffer=G,q.connect(a.destination);const ee=d<a.currentTime?a.currentTime:d;A!==null&&!c.has(A)&&(c.set(A,ee),$(),V()),q.start(ee),d=ee+G.duration,u++,q.onended=()=>{u--,ae()}}catch(R){console.error("[VirtualHumanEventAdapter] Failed to decode and play audio:",R)}},K=y=>{switch(y){case"play":D(),f=!1,u=0,d=0,m=!1,a&&a.state==="suspended"&&a.resume();break;case"resume":m=!1,a&&a.state==="suspended"&&a.resume(),$(),V();break;case"pause":m=!0,a&&a.state==="running"&&a.suspend();break;case"stop":D(),m=!1,a&&(a.close(),a=null),d=0,f=!1,u=0;break;case"tts_complete":f=!0,ae();break;default:console.warn(`[VirtualHumanEventAdapter] Unknown control action: ${y}`)}},L=()=>{i.value&&i.value.close();try{const y=new URL(r.wsUrl);y.searchParams.append("sessionId",r.screenClientId+"-event"),i.value=new WebSocket(y.toString()),i.value.onopen=()=>{o.value=!0,s("connected"),console.log(`[VirtualHumanEventAdapter] Connected to ${r.wsUrl} for session ${r.screenClientId}-event`)},i.value.onmessage=A=>{try{const R=JSON.parse(A.data);Ee(R)}catch(R){console.error("[VirtualHumanEventAdapter] Failed to parse message:",A.data,R)}},i.value.onerror=A=>{console.error("[VirtualHumanEventAdapter] WebSocket error:",A),s("error",A)},i.value.onclose=()=>{o.value=!1,console.log("[VirtualHumanEventAdapter] WebSocket disconnected")}}catch(y){console.error("[VirtualHumanEventAdapter] Failed to initialize WebSocket:",y),s("error",y)}},Ee=y=>{const{type:A,payload:R,action:j}=y;switch(A){case"audio":const X=(R==null?void 0:R.data)||y.data;if(X){const P=C((R==null?void 0:R.index)??y.index);Y(X,P)}break;case"send_event":if(y.event){console.log("adapter send_event:",y);const P=C(y.index);if(P===null){s("eventNotifaction",y);break}w.set(P,y),$(),V()}break;case"control":j&&(console.log("adapter control:",j),s("controlEvent",j),K(j));break;case"end":console.log("adapter end:",R),s("end",R);break;case"pause":console.log("adapter pause:",R),s("pause",R);break;default:console.warn(`[VirtualHumanEventAdapter] Unknown message type: ${A}`)}};return g.watch(()=>r.screenClientId,()=>{r.screenClientId&&r.wsUrl&&L()}),g.watch(()=>r.wsUrl,()=>{r.screenClientId&&r.wsUrl&&L()}),g.onMounted(()=>{r.screenClientId&&r.wsUrl&&L()}),g.onUnmounted(()=>{i.value&&i.value.close(),a&&a.close()}),(y,A)=>g.renderSlot(y.$slots,"default")}}),Gn={install:e=>{e.component("VirtualHumanPersona",Be),e.component("VirtualHumanEventAdapter",gt)}};H.VirtualHumanEventAdapter=gt,H.VirtualHumanPersona=Be,H.default=Gn,Object.defineProperties(H,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "virtual-human-cf",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Vue3 Digital Human Component Package by cf ",
|
|
5
5
|
"main": "dist/virtual-human-cf.umd.js",
|
|
6
6
|
"module": "dist/virtual-human-cf.es.js",
|
|
@@ -34,5 +34,9 @@
|
|
|
34
34
|
"component"
|
|
35
35
|
],
|
|
36
36
|
"author": "cuihan",
|
|
37
|
-
"license": "MIT"
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"axios": "^1.14.0",
|
|
40
|
+
"path": "^0.12.7"
|
|
41
|
+
}
|
|
38
42
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
const request = axios.create({
|
|
4
|
+
baseURL: 'http://t1.lingganai.cyou:90', // Assuming backend runs on 8080
|
|
5
|
+
timeout: 10000,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
request.interceptors.response.use(
|
|
9
|
+
(response) => {
|
|
10
|
+
const res = response.data;
|
|
11
|
+
if (res.code === 200) {
|
|
12
|
+
return res.data;
|
|
13
|
+
} else {
|
|
14
|
+
return Promise.reject(new Error(res.message || 'Error'));
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
(error) => {
|
|
18
|
+
return Promise.reject(error);
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export default request;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import request from './request';
|
|
2
|
+
|
|
3
|
+
export interface ScreenConfig {
|
|
4
|
+
id?: number;
|
|
5
|
+
name: string;
|
|
6
|
+
screenClientId: string;
|
|
7
|
+
createTime?: string;
|
|
8
|
+
updateTime?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const getScreenList = () => {
|
|
12
|
+
return request.get<any, ScreenConfig[]>('/api/screen-configs');
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const getScreenById = (id: number) => {
|
|
16
|
+
return request.get<any, ScreenConfig>(`/api/screen-configs/${id}`);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const createScreen = (data: ScreenConfig) => {
|
|
20
|
+
return request.post<any, boolean>('/api/screen-configs', data);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const updateScreen = (id: number, data: ScreenConfig) => {
|
|
24
|
+
return request.put<any, boolean>(`/api/screen-configs/${id}`, data);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const deleteScreen = (id: number) => {
|
|
28
|
+
return request.delete<any, boolean>(`/api/screen-configs/${id}`);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const controlScreen = (screenClientId: string, action: 'play' | 'pause' | 'stop' | 'resume') => {
|
|
32
|
+
return request.post<any, boolean>('/api/screen/control', {
|
|
33
|
+
screenClientId,
|
|
34
|
+
action
|
|
35
|
+
});
|
|
36
|
+
};
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
6
|
import { ref, watch, onMounted, onUnmounted } from 'vue';
|
|
7
|
+
import { controlScreen as controlScreenApi } from '@/api/screen';
|
|
7
8
|
|
|
8
9
|
const props = defineProps({
|
|
9
10
|
// 屏幕客户端ID
|
|
@@ -34,6 +35,34 @@ const firedEventIndexSet = new Set<number>();
|
|
|
34
35
|
const plannedStartTimeByIndex = new Map<number, number>();
|
|
35
36
|
let eventSchedulerTimer: number | null = null;
|
|
36
37
|
|
|
38
|
+
const play = () => {
|
|
39
|
+
if (!isConnected.value) return Promise.reject(false);
|
|
40
|
+
return controlScreenApi(props.screenClientId, 'play').then(() => Promise.resolve(true)).catch(() => Promise.reject(false));
|
|
41
|
+
};
|
|
42
|
+
// 定义控制方法
|
|
43
|
+
const pause = () => {
|
|
44
|
+
if (!isConnected.value) return Promise.reject(false);
|
|
45
|
+
return controlScreenApi(props.screenClientId, 'pause').then(() => Promise.resolve(true)).catch(() => Promise.reject(false));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const resume = () => {
|
|
49
|
+
if (!isConnected.value) return Promise.reject(false);
|
|
50
|
+
return controlScreenApi(props.screenClientId, 'resume').then(() => Promise.resolve(true)).catch(() => Promise.reject(false));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const stop = () => {
|
|
54
|
+
if (!isConnected.value) return Promise.reject(false);
|
|
55
|
+
return controlScreenApi(props.screenClientId, 'stop').then(() => Promise.resolve(true)).catch(() => Promise.reject(false));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// 暴露方法给父组件
|
|
59
|
+
defineExpose({
|
|
60
|
+
play,
|
|
61
|
+
pause,
|
|
62
|
+
resume,
|
|
63
|
+
stop
|
|
64
|
+
});
|
|
65
|
+
|
|
37
66
|
const normalizeIndex = (value: unknown): number | null => {
|
|
38
67
|
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
39
68
|
if (typeof value === 'string' && value.trim() !== '') {
|
|
@@ -130,6 +130,9 @@ const handleMessage = (msg: any) => {
|
|
|
130
130
|
emit('update:isPlaying', true);
|
|
131
131
|
emit('update:visible', true);
|
|
132
132
|
} else if (action === 'pause') {
|
|
133
|
+
if (videoRef.value) {
|
|
134
|
+
videoRef.value.pause();
|
|
135
|
+
}
|
|
133
136
|
emit('update:isPlaying', false);
|
|
134
137
|
// 暂停时不隐藏视频
|
|
135
138
|
emit('update:visible', true);
|
package/tsconfig.json
CHANGED
|
@@ -14,8 +14,12 @@
|
|
|
14
14
|
"noEmit": true,
|
|
15
15
|
"declaration": true,
|
|
16
16
|
"declarationDir": "dist",
|
|
17
|
-
"outDir": "dist"
|
|
17
|
+
"outDir": "dist",
|
|
18
|
+
"baseUrl": ".",
|
|
19
|
+
"paths": {
|
|
20
|
+
"@/*": ["./src/*"]
|
|
21
|
+
}
|
|
18
22
|
},
|
|
19
23
|
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
|
|
20
24
|
"references": [{ "path": "./tsconfig.node.json" }]
|
|
21
|
-
}
|
|
25
|
+
}
|
package/vite.config.ts
CHANGED
|
@@ -11,6 +11,11 @@ export default defineConfig({
|
|
|
11
11
|
include: ['src/**/*.ts', 'src/**/*.vue'],
|
|
12
12
|
}),
|
|
13
13
|
],
|
|
14
|
+
resolve: {
|
|
15
|
+
alias: {
|
|
16
|
+
'@': resolve(__dirname, './src')
|
|
17
|
+
}
|
|
18
|
+
},
|
|
14
19
|
build: {
|
|
15
20
|
lib: {
|
|
16
21
|
entry: resolve(__dirname, 'src/index.ts'),
|
|
@@ -31,4 +36,4 @@ export default defineConfig({
|
|
|
31
36
|
},
|
|
32
37
|
},
|
|
33
38
|
},
|
|
34
|
-
});
|
|
39
|
+
});
|