dsh-duet 0.3.2 → 0.3.3
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 +2 -0
- package/assets/avatar/desktop/companion.mjs +3 -3
- package/assets/avatar/desktop/manifest.json +1 -1
- package/desktop/bin/darwin-arm64/duet-avatar.app/Contents/MacOS/duet-avatar +0 -0
- package/desktop/bin/darwin-arm64/manifest.json +3 -3
- package/desktop/bin/win32-x64/duet-avatar.exe +0 -0
- package/desktop/bin/win32-x64/manifest.json +3 -3
- package/package.json +2 -2
- package/src/avatar/companion.mjs +5 -3
- package/src/client/agent-tasks.mjs +116 -18
- package/src/client/audio.mjs +1 -1
- package/src/client/avatar.mjs +15 -2
- package/src/client/browser.mjs +24 -24
- package/src/client/composer-bridge.mjs +1 -1
- package/src/client/connection-hint.mjs +1 -1
- package/src/client/entry.js +2 -2
- package/src/client/feedback.mjs +1 -1
- package/src/client/identity.mjs +1 -1
- package/src/client/interactions.mjs +5 -4
- package/src/client/notice.mjs +30 -9
- package/src/client/settings.html +5 -4
- package/src/client/sidebar-layout.mjs +26 -0
- package/src/client/tutorial-adapter.mjs +5 -5
- package/src/client/tutorial.mjs +1 -1
- package/src/client/work-mode.mjs +1 -1
- package/src/host/agent-connection.mjs +6 -1
- package/src/host/assets.mjs +1 -0
- package/src/host/auth.mjs +13 -0
- package/src/host/avatar.mjs +32 -13
- package/src/host/plugin.mjs +18 -15
- package/src/host/proxy.mjs +3 -2
- package/src/host/sync-feed.mjs +3 -2
- package/src/shared/state.mjs +29 -4
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{mountAvatarRenderer as st}from"./renderer.mjs";var ge=Object.freeze({large:1,medium:.75,small:.5}),j=e=>Object.hasOwn(ge,e)?e:"large";var mt=Object.freeze({enabled:!0,webOnly:!1,size:"large"}),ce=class{constructor(t=15e3,i=Date.now(),c=6e4){this.interval=t,this.timeout=c,this.last=this.tick=i}touch(t=Date.now()){this.last=t}expired(t=Date.now()){return(t-this.tick>this.interval*2||t<this.tick)&&(this.last=t),this.tick=t,t-this.last>this.timeout}},ft=Object.freeze({off:"\u5F53\u524D\u663E\u793A\uFF1A\u5DF2\u5173\u95ED",desktop:"\u5F53\u524D\u663E\u793A\uFF1A\u684C\u9762\u6D6E\u52A8\u7A97\u53E3",connecting:"\u5F53\u524D\u663E\u793A\uFF1A\u6B63\u5728\u542F\u52A8\u684C\u9762\u7A97\u53E3",recovering:"\u5F53\u524D\u663E\u793A\uFF1A\u684C\u9762\u8FDE\u63A5\u6062\u590D\u4E2D",other:"\u5F53\u524D\u663E\u793A\uFF1A\u7531\u53E6\u4E00\u4E2A DSH \u9875\u9762\u7BA1\u7406\u684C\u9762\u7A97\u53E3",web:"\u5F53\u524D\u663E\u793A\uFF1A\u7F51\u9875\u5185",fallback:"\u5F53\u524D\u663E\u793A\uFF1A\u7F51\u9875\u5185\uFF08\u684C\u9762\u7EC4\u4EF6\u6682\u4E0D\u53EF\u7528\uFF09",unavailable:"\u5F53\u524D\u663E\u793A\uFF1A\u5F62\u8C61\u52A0\u8F7D\u5931\u8D25"});function Me(e){if(!e||!["off","online","tts_only"].includes(e.mode)||!Number.isFinite(e.rms)||e.rms<0||e.rms>1)throw Error("invalid_avatar_frame");return{type:"frame",mode:e.mode,ready:e.ready===!0,rms:e.rms,size:j(e.size),viseme:["A","I","U","E","O"].includes(e.viseme)?e.viseme:"A",text:typeof e.text=="string"?e.text.slice(-240):"",utterance:typeof e.utterance=="string"?e.utterance.slice(0,100):""}}function Oe(e){if(e?.type!=="input_effect"||typeof e.text!="string"||!e.text||e.text.length>600)throw Error("invalid_avatar_input_effect");return{type:"input_effect",text:e.text}}var Ie="display:flex;align-items:center;gap:12px;width:100%;box-sizing:border-box;padding:14px 16px;margin:0;border:1px solid #ffffff90;border-radius:20px;background:#f7f9fbe8;color:#253344;text-align:left;cursor:pointer;box-shadow:0 6px 18px -8px #172c4938;backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);font:13px/1.5 -apple-system,BlinkMacSystemFont,system-ui,sans-serif",ue=Object.keys(ge),ye={large:"\u5927\uFF08100%\uFF09",medium:"\u4E2D\uFF0875%\uFF09",small:"\u5C0F\uFF0850%\uFF09"},ae=e=>ue[(ue.indexOf(j(e))+1)%ue.length];function oe(e,t,{label:i=!1}={}){let c=j(t),n=`\u5F62\u8C61\u5927\u5C0F\uFF1A${ye[c]}\uFF0C\u70B9\u51FB\u5207\u6362\u4E3A${ye[ae(c)]}`;e.type="button",e.dataset.size=c,e.setAttribute("aria-label",n),e.title=n;let a=ue.filter(l=>l!==c).concat(c).map(l=>{let r={large:18,medium:12,small:6}[l];return`<rect data-size-square="${l}" x="3" y="${21-r}" width="${r}" height="${r}" stroke-width="${l===c?"2.8":"1"}"/>`}).join("");e.innerHTML=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true">${a}</svg>${i?`<span>${ye[c]}</span>`:""}`}function Re({onChange:e=()=>{},floating:t=!1,origin:i="page",anchor:c=()=>null,viewport:n=()=>[0,0,innerWidth,innerHeight]}={}){let a=null,l,r,k,v=!1,_=()=>{if(!t||!r)return;let f=c()?.getBoundingClientRect();if(!f)return;let g=r.getBoundingClientRect(),[m,o,x,d]=n(),S=f.top-g.height-16>=o+12?f.top-g.height-16:f.bottom+12;r.style.left=Math.max(m+12,Math.min(f.left+f.width/2-g.width/2,m+x-g.width-12))+"px",r.style.top=Math.max(o+12,Math.min(S,o+d-g.height-12))+"px",r.style.bottom="auto"},C=f=>{if(!a)return;let g=l;a=null,l=null,document.removeEventListener("keydown",M,!0),window.removeEventListener("resize",_),r?.remove(),r=null,k?.isConnected&&k.focus({preventScroll:!0}),e(),g(f)},M=f=>{if(f.key==="Escape")f.preventDefault(),f.stopImmediatePropagation(),C(!1);else if(f.key==="Tab"&&!t){f.preventDefault();let g=[...r.querySelectorAll("button")],m=g.indexOf(document.activeElement);g[(m+(f.shiftKey?-1:1)+g.length)%g.length].focus()}};return{ask(){if(v)return Promise.resolve(!1);if(a)return a;k=document.activeElement,a=new Promise(o=>l=o),r=document.createElement("div"),r.dataset.avatarCloseOverlay="",r.style.cssText="position:fixed;inset:0;z-index:2147483600;display:flex;align-items:center;justify-content:center;padding:12px;box-sizing:border-box;background:#0003;pointer-events:auto",t&&(r.dataset.duetAvatarSurface="110",r.dataset.duetSurfaceOrigin=i,r.style.cssText="position:fixed;left:12px;bottom:100px;width:260px;max-width:calc(100vw - 24px);z-index:2147483600;pointer-events:auto");let f=document.createElement("div");f.dataset.avatarCloseConfirm="",f.setAttribute("role","alertdialog"),f.setAttribute("aria-modal",String(!t)),f.setAttribute("aria-label","\u9690\u85CF\u62DF\u4EBA\u89D2\u8272\uFF1F"),f.style.cssText="box-sizing:border-box;width:260px;max-width:100%;padding:16px;border:1px solid #8dc5ed55;border-radius:16px;background:#142638;color:#e9f4ff;font:13px/1.6 system-ui;box-shadow:0 8px 28px #0005";let g=document.createElement("div");g.textContent="\u9690\u85CF\u62DF\u4EBA\u89D2\u8272\uFF1F",g.style.cssText="font-size:14px;font-weight:600;margin-bottom:14px";let m=document.createElement("div");m.style.cssText="display:flex;justify-content:flex-end;gap:8px";for(let[o,x]of[["\u53D6\u6D88",!1],["\u9690\u85CF\u62DF\u4EBA\u89D2\u8272",!0]]){let d=document.createElement("button");d.type="button",d.textContent=o,d.dataset.avatarCloseChoice=x?"confirm":"cancel",d.style.cssText=`font:13px system-ui;display:block;width:auto;min-width:56px;min-height:32px;padding:6px 10px;border:0;border-radius:8px;cursor:pointer;background:${x?"#dcefff":"#294154"};color:${x?"#185a89":"#e9f4ff"}`,d.onclick=()=>C(x),m.append(d)}return f.append(g,m),r.append(f),document.body.append(r),document.addEventListener("keydown",M,!0),window.addEventListener("resize",_),_(),m.firstChild.focus(),e(),a},cancel(){C(!1)},dispose(){v=!0,C(!1)},get element(){return r}}}function qe(e,t,i,c){let[n,a,l,r]=t;return!l||!r||i<n||c<a||i>=n+l||c>=a+r||e?.length!==3072?!1:e[Math.floor((c-a)/r*64)*48+Math.floor((i-n)/l*48)]===1}function Ne({tools:e,avatar:t,hitTest:i=()=>!1,onChange:c=()=>{}}){let n=!1,a=!1,l=!1,r=!1,k={x:-1,y:-1,overAvatar:!1},v,_,C=h=>{let A=h.getBoundingClientRect();return[A.x,A.y,A.width,A.height]},M=([h,A,te,de])=>k.x>=h&&k.y>=A&&k.x<h+te&&k.y<A+de,f=()=>{let h=t.getBoundingClientRect(),A=e.getBoundingClientRect();return[Math.min(h.left,A.left),h.bottom-2,Math.max(h.right,A.right)-Math.min(h.left,A.left),Math.max(0,A.top-h.bottom)+4]},g=()=>{e.dataset.revealed=String(a),e.dataset.interactive=String(l),e.dataset.confirming=String(r),c()},m=()=>r||e.dataset.keyboard==="true"&&!!e.querySelector(":focus-visible")||k.overAvatar||l&&(M(C(e))||M(f())),o=()=>{n||(m()?(clearTimeout(v),v=null,clearTimeout(_),_=null,(!a||!l)&&(a=!0,l=!0,g())):a&&!v&&(v=setTimeout(()=>{if(v=null,n||m())return o();a=!1,g(),_=setTimeout(()=>{if(_=null,!n){if(m())return o();l=!1,g()}},500)},180)))},x=h=>{n||(k={x:Number.isFinite(h.x)?h.x:-1,y:Number.isFinite(h.y)?h.y:-1,overAvatar:h.overAvatar===!0},t.style.pointerEvents=k.overAvatar?"auto":"none",o())},d=h=>x({x:h.clientX,y:h.clientY,overAvatar:i(h.clientX,h.clientY)}),S=()=>x({x:-1,y:-1,overAvatar:!1}),T=()=>queueMicrotask(o),L=h=>{["Shift","Control","Alt","Meta"].includes(h.key)||(e.dataset.keyboard="true"),T()},H=()=>{e.dataset.keyboard="false",T()},I=()=>{e.dataset.keyboard="false",S()},O=(h,A,te)=>(h.addEventListener(A,te),()=>h.removeEventListener(A,te)),V=[O(document,"pointermove",d),O(document,"pointerleave",S),O(document,"focusin",T),O(document,"focusout",T),O(document,"keydown",L),O(document,"pointerdown",H),O(window,"blur",I)];return e.dataset.keyboard="false",e.dataset.revealed="false",e.dataset.interactive="false",e.dataset.confirming="false",t.style.pointerEvents="none",{pointer:x,refresh(){o()},setConfirmation(h){r=!!h,g(),o()},get interactive(){return l},regions(){return l?[C(e),f()]:[]},dispose(){n=!0,clearTimeout(v),clearTimeout(_),V.forEach(h=>h())}}}function Be(e){if(e?.type!=="surface")throw Error("invalid_surface");if(e.panel===null)return{type:"surface",panel:null};let t=e.panel;if(!t||!/^s\d+$/.test(t.id)||!Number.isSafeInteger(t.revision)||t.revision<1||!Array.isArray(t.nodes)||t.nodes.length>160)throw Error("invalid_surface");let i=0,c=t.nodes.map(n=>{if(!n||!["text","heading","button","checkbox","break"].includes(n.kind)||typeof n.text!="string"||n.text.length>4e3||(i+=n.text.length,i>1e4))throw Error("invalid_surface");let a={kind:n.kind,text:n.text};if(["running","completed","waiting","failed","stopped"].includes(n.taskState)&&(a.taskState=n.taskState),n.kind==="button"&&n.taskState==="completed"&&Number.isInteger(n.countdown)&&n.countdown>=0&&n.countdown<=10&&(a.countdown=n.countdown),n.kind==="button"||n.kind==="checkbox"){if(!/^a\d+$/.test(n.action))throw Error("invalid_surface");Object.assign(a,{action:n.action,disabled:n.disabled===!0,checked:n.checked===!0,gesture:n.gesture===!0,label:String(n.label||"").slice(0,100)})}return a});return{type:"surface",panel:{id:t.id,revision:t.revision,nodes:c,target:["online","tts_only"].includes(t.target)?t.target:null,...t.layout==="tasks"?{layout:"tasks"}:{}}}}function Le(e,{send:t,changed:i}){let c=null,n="",a=new Map;return{update(l){let r=Be(l).panel,k=JSON.stringify(r);if(k===n)return;let v=e.contains(document.activeElement)?document.activeElement.dataset.surfaceAction:null,_=e.scrollTop,C=c?.id===r?.id;n=k,c=r,e.hidden=!r,e.dataset.layout=r?.layout||"";let M=[],f=new Map,g=(m,o)=>{let x=C?a.get(m):null,d=x?.tagName.toLowerCase()===o?x:document.createElement(o);return f.set(m,d),M.push(d),d};if(r){if(r.nodes.some(m=>m.gesture)){let m=r.nodes.find(x=>x.gesture&&x.kind==="button"),o=g("gesture","p");o.className="gesture-note",o.textContent=m?.text==="\u5F00\u59CB\u6559\u5B66"?"\u8BF7\u56DE\u5230 DSH\uFF0C\u70B9\u51FB\u201C\u5F00\u59CB\u6559\u5B66\u201D\u3002":"\u8BF7\u56DE\u5230 DSH\uFF0C\u70B9\u51FB\u201C\u542F\u52A8\u97F3\u9891\u64AD\u653E\u201D\u3002"}for(let[m,o]of r.nodes.entries()){let x=o.kind==="break"?"br":o.kind==="heading"?"h3":o.kind==="button"?"button":o.kind==="checkbox"?"input":"span",d=g(o.action||"node"+m,x);if(o.taskState?d.dataset.taskState=o.taskState:delete d.dataset.taskState,o.countdown!==void 0){let S=d.querySelector("[data-task-copy]"),T=d.querySelector("[data-task-countdown-label]");(!S||!T)&&(S=document.createElement("span"),S.dataset.taskCopy="",T=document.createElement("small"),T.dataset.taskCountdownLabel="",d.replaceChildren(S,T)),S.textContent=o.text,S.style.cssText="min-width:0;white-space:pre-line;overflow-wrap:anywhere",T.textContent=`${o.countdown}s \u540E\u6D88\u5931`,T.style.cssText="margin-left:auto;flex-shrink:0;color:#737b85;font:400 10px/1.4 system-ui;white-space:nowrap"}else(d.textContent!==o.text||d.querySelector("[data-task-countdown-label]"))&&(d.textContent=o.text);if(o.kind==="checkbox"&&(d.type="checkbox",d.checked=o.checked),o.kind==="button"||o.kind==="checkbox"){d.dataset.surfaceAction=o.action,o.kind==="button"&&(d.type="button"),d.disabled=o.disabled||o.gesture,o.label?d.setAttribute("aria-label",o.label):d.removeAttribute("aria-label");let S=()=>{c!==r||d.disabled||t({type:"surface_action",id:r.id,revision:r.revision,action:o.action,checked:d.checked===!0})};o.kind==="checkbox"?d.onchange=S:d.onclick=S}}}for(M.forEach((m,o)=>{e.children[o]!==m&&e.insertBefore(m,e.children[o]||null)});e.children.length>M.length;)e.lastElementChild.remove();if(a=f,v){let m=a.get(v);m&&!m.disabled&&document.activeElement!==m&&m.focus({preventScroll:!0})}e.scrollTop=_,i(!!r,r?.target)}}}var $e="avatar_local_v1";var tt=["open_dsh","pending","settings","tutorial","hide","notifications","size","bubble","view","dismiss"],we=["small","medium","large"],nt=["completed","failed","stopped","approval","question","plan_review"];var pe=(e,t)=>typeof e=="string"?e.slice(0,t):"";function De(e){if(e?.type!=="menu_action"||!tt.includes(e.action)||!/^[a-zA-Z0-9-]{1,64}$/.test(e.request_id||""))throw Error("invalid_avatar_menu_action");let t={type:"menu_action",request_id:e.request_id,action:e.action};if(["size","bubble"].includes(e.action)){if(!we.includes(e.value))throw Error("invalid_avatar_size");t.value=e.value}if(["view","dismiss"].includes(e.action)){if(typeof e.id!="string"||!e.id||e.id.length>512)throw Error("invalid_avatar_notice");t.id=e.id}if(e.action==="notifications"){if(typeof e.value!="boolean")throw Error("invalid_avatar_preference");t.value=e.value}if(e.action==="snooze"){if(![0,30].includes(e.value))throw Error("invalid_avatar_snooze");t.value=e.value}return t}function He(e){if(e?.type!=="local_state"||e.protocol!==$e||!Number.isSafeInteger(e.revision)||e.revision<0||!Array.isArray(e.items)||e.items.length>32)throw Error("invalid_avatar_local_state");let t=e.items.map(i=>{if(!nt.includes(i.status)||!i.id||typeof i.id!="string"||i.id.length>512)throw Error("invalid_avatar_notice");return{id:i.id,session_id:pe(i.session_id,256),name:pe(i.name,100),status:i.status,summary:pe(i.summary,240),pending:i.pending===!0,unread:i.unread===!0}});for(;JSON.stringify(t).length>12e3;)t.pop();return{type:"local_state",protocol:$e,revision:e.revision,items:t,size:we.includes(e.size)?e.size:"large",bubble:we.includes(e.bubble)?e.bubble:"medium",enabled:e.enabled!==!1,snoozed:e.snoozed===!0,running:Math.max(0,Math.min(1e4,Number(e.running)||0)),available:e.available===!0,toast:t.some(i=>i.id===e.toast)?e.toast:null}}function Pe(e){if(e?.type!=="menu_result"||!/^[a-zA-Z0-9-]{1,64}$/.test(e.request_id||""))throw Error("invalid_avatar_menu_result");return{type:"menu_result",request_id:e.request_id,ok:e.ok===!0,message:pe(e.message,180)}}var Ue={completed:"\u672C\u8F6E\u5DF2\u5B8C\u6210",failed:"\u6267\u884C\u5931\u8D25",stopped:"\u5DF2\u505C\u6B62",approval:"\u7B49\u5F85\u6388\u6743",question:"\u7B49\u5F85\u56DE\u7B54",plan_review:"\u7B49\u5F85\u65B9\u6848\u786E\u8BA4"},Ve={small:"\u7D27\u51D1",medium:"\u6807\u51C6",large:"\u5BBD\u677E"},ve={open:"M14 3h7v7m0-7L10 14M10 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5",pending:"M8 4h8m-9 0H5v17h14V4h-2M8 3h8v4H8zM8 12h8m-8 4h5",bubble:"M5 4h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-5 3v-3H3V6a2 2 0 0 1 2-2zM7 9h10m-10 4h6",tutorial:"m9 5 10 7-10 7z",settings:"M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8M9 3h6l1 3 3 1 2 5-2 5-3 1-1 3H9l-1-3-3-1-2-5 2-5 3-1z",hide:"m4 4 16 16M9 5a11 11 0 0 1 12 7l-3 4M6 6a13 13 0 0 0-5 6s4 7 11 7l3-1M10 10a3 3 0 0 0 4 4",back:"m14 5-7 7 7 7"},at=e=>{let t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true"),t.innerHTML=`<path d="${ve[e]||ve.pending}"/>`,t};function je({anchor:e,viewport:t=()=>[0,0,innerWidth,innerHeight],send:i,changed:c=()=>{}}){let n={items:[],running:0,enabled:!0,size:"large",bubble:"medium"},a,l,r="main",k,v=!1,_,C,M,f,g=document.createElement("style");g.textContent=`
|
|
1
|
+
import{mountAvatarRenderer as rt}from"./renderer.mjs";var ye=Object.freeze({large:1,medium:.75,small:.5}),j=e=>Object.hasOwn(ye,e)?e:"large";var ft=Object.freeze({enabled:!0,webOnly:!1,size:"large"}),ce=class{constructor(t=15e3,i=Date.now(),c=6e4){this.interval=t,this.timeout=c,this.last=this.tick=i}touch(t=Date.now()){this.last=t}expired(t=Date.now()){return(t-this.tick>this.interval*2||t<this.tick)&&(this.last=t),this.tick=t,t-this.last>this.timeout}},ht=Object.freeze({off:"\u5F53\u524D\u663E\u793A\uFF1A\u5DF2\u5173\u95ED",desktop:"\u5F53\u524D\u663E\u793A\uFF1A\u684C\u9762\u6D6E\u52A8\u7A97\u53E3",connecting:"\u5F53\u524D\u663E\u793A\uFF1A\u6B63\u5728\u542F\u52A8\u684C\u9762\u7A97\u53E3",recovering:"\u5F53\u524D\u663E\u793A\uFF1A\u684C\u9762\u8FDE\u63A5\u6062\u590D\u4E2D",other:"\u5F53\u524D\u663E\u793A\uFF1A\u7531\u53E6\u4E00\u4E2A DSH \u9875\u9762\u7BA1\u7406\u684C\u9762\u7A97\u53E3",web:"\u5F53\u524D\u663E\u793A\uFF1A\u7F51\u9875\u5185",fallback:"\u5F53\u524D\u663E\u793A\uFF1A\u7F51\u9875\u5185\uFF08\u684C\u9762\u7EC4\u4EF6\u6682\u4E0D\u53EF\u7528\uFF09",unavailable:"\u5F53\u524D\u663E\u793A\uFF1A\u5F62\u8C61\u52A0\u8F7D\u5931\u8D25"});function Oe(e){if(!e||!["off","online","tts_only"].includes(e.mode)||!Number.isFinite(e.rms)||e.rms<0||e.rms>1)throw Error("invalid_avatar_frame");return{type:"frame",mode:e.mode,ready:e.ready===!0,rms:e.rms,size:j(e.size),viseme:["A","I","U","E","O"].includes(e.viseme)?e.viseme:"A",text:typeof e.text=="string"?e.text.slice(-240):"",utterance:typeof e.utterance=="string"?e.utterance.slice(0,100):""}}function Ie(e){if(e?.type!=="input_effect"||typeof e.text!="string"||!e.text||e.text.length>600)throw Error("invalid_avatar_input_effect");return{type:"input_effect",text:e.text}}var Re="display:flex;align-items:center;gap:12px;width:100%;box-sizing:border-box;padding:14px 16px;margin:0;border:1px solid #ffffff90;border-radius:20px;background:#f7f9fbe8;color:#253344;text-align:left;cursor:pointer;box-shadow:0 6px 18px -8px #172c4938;backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);font:13px/1.5 -apple-system,BlinkMacSystemFont,system-ui,sans-serif",ue=Object.keys(ye),we={large:"\u5927\uFF08100%\uFF09",medium:"\u4E2D\uFF0875%\uFF09",small:"\u5C0F\uFF0850%\uFF09"},ae=e=>ue[(ue.indexOf(j(e))+1)%ue.length];function oe(e,t,{label:i=!1}={}){let c=j(t),n=`\u5F62\u8C61\u5927\u5C0F\uFF1A${we[c]}\uFF0C\u70B9\u51FB\u5207\u6362\u4E3A${we[ae(c)]}`;e.type="button",e.dataset.size=c,e.setAttribute("aria-label",n),e.title=n;let a=ue.filter(l=>l!==c).concat(c).map(l=>{let r={large:18,medium:12,small:6}[l];return`<rect data-size-square="${l}" x="3" y="${21-r}" width="${r}" height="${r}" stroke-width="${l===c?"2.8":"1"}"/>`}).join("");e.innerHTML=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true">${a}</svg>${i?`<span>${we[c]}</span>`:""}`}function qe({onChange:e=()=>{},floating:t=!1,origin:i="page",anchor:c=()=>null,viewport:n=()=>[0,0,innerWidth,innerHeight]}={}){let a=null,l,r,k,v=!1,_=()=>{if(!t||!r)return;let f=c()?.getBoundingClientRect();if(!f)return;let g=r.getBoundingClientRect(),[m,o,x,d]=n(),S=f.top-g.height-16>=o+12?f.top-g.height-16:f.bottom+12;r.style.left=Math.max(m+12,Math.min(f.left+f.width/2-g.width/2,m+x-g.width-12))+"px",r.style.top=Math.max(o+12,Math.min(S,o+d-g.height-12))+"px",r.style.bottom="auto"},C=f=>{if(!a)return;let g=l;a=null,l=null,document.removeEventListener("keydown",M,!0),window.removeEventListener("resize",_),r?.remove(),r=null,k?.isConnected&&k.focus({preventScroll:!0}),e(),g(f)},M=f=>{if(f.key==="Escape")f.preventDefault(),f.stopImmediatePropagation(),C(!1);else if(f.key==="Tab"&&!t){f.preventDefault();let g=[...r.querySelectorAll("button")],m=g.indexOf(document.activeElement);g[(m+(f.shiftKey?-1:1)+g.length)%g.length].focus()}};return{ask(){if(v)return Promise.resolve(!1);if(a)return a;k=document.activeElement,a=new Promise(o=>l=o),r=document.createElement("div"),r.dataset.avatarCloseOverlay="",r.style.cssText="position:fixed;inset:0;z-index:2147483600;display:flex;align-items:center;justify-content:center;padding:12px;box-sizing:border-box;background:#0003;pointer-events:auto",t&&(r.dataset.duetAvatarSurface="110",r.dataset.duetSurfaceOrigin=i,r.style.cssText="position:fixed;left:12px;bottom:100px;width:260px;max-width:calc(100vw - 24px);z-index:2147483600;pointer-events:auto");let f=document.createElement("div");f.dataset.avatarCloseConfirm="",f.setAttribute("role","alertdialog"),f.setAttribute("aria-modal",String(!t)),f.setAttribute("aria-label","\u9690\u85CF\u62DF\u4EBA\u89D2\u8272\uFF1F"),f.style.cssText="box-sizing:border-box;width:260px;max-width:100%;padding:16px;border:1px solid #8dc5ed55;border-radius:16px;background:#142638;color:#e9f4ff;font:13px/1.6 system-ui;box-shadow:0 8px 28px #0005";let g=document.createElement("div");g.textContent="\u9690\u85CF\u62DF\u4EBA\u89D2\u8272\uFF1F",g.style.cssText="font-size:14px;font-weight:600;margin-bottom:14px";let m=document.createElement("div");m.style.cssText="display:flex;justify-content:flex-end;gap:8px";for(let[o,x]of[["\u53D6\u6D88",!1],["\u9690\u85CF\u62DF\u4EBA\u89D2\u8272",!0]]){let d=document.createElement("button");d.type="button",d.textContent=o,d.dataset.avatarCloseChoice=x?"confirm":"cancel",d.style.cssText=`font:13px system-ui;display:block;width:auto;min-width:56px;min-height:32px;padding:6px 10px;border:0;border-radius:8px;cursor:pointer;background:${x?"#dcefff":"#294154"};color:${x?"#185a89":"#e9f4ff"}`,d.onclick=()=>C(x),m.append(d)}return f.append(g,m),r.append(f),document.body.append(r),document.addEventListener("keydown",M,!0),window.addEventListener("resize",_),_(),m.firstChild.focus(),e(),a},cancel(){C(!1)},dispose(){v=!0,C(!1)},get element(){return r}}}function Ne(e,t,i,c){let[n,a,l,r]=t;return!l||!r||i<n||c<a||i>=n+l||c>=a+r||e?.length!==3072?!1:e[Math.floor((c-a)/r*64)*48+Math.floor((i-n)/l*48)]===1}function Be({tools:e,avatar:t,hitTest:i=()=>!1,onChange:c=()=>{}}){let n=!1,a=!1,l=!1,r=!1,k={x:-1,y:-1,overAvatar:!1},v,_,C=h=>{let A=h.getBoundingClientRect();return[A.x,A.y,A.width,A.height]},M=([h,A,te,de])=>k.x>=h&&k.y>=A&&k.x<h+te&&k.y<A+de,f=()=>{let h=t.getBoundingClientRect(),A=e.getBoundingClientRect();return[Math.min(h.left,A.left),h.bottom-2,Math.max(h.right,A.right)-Math.min(h.left,A.left),Math.max(0,A.top-h.bottom)+4]},g=()=>{e.dataset.revealed=String(a),e.dataset.interactive=String(l),e.dataset.confirming=String(r),c()},m=()=>r||e.dataset.keyboard==="true"&&!!e.querySelector(":focus-visible")||k.overAvatar||l&&(M(C(e))||M(f())),o=()=>{n||(m()?(clearTimeout(v),v=null,clearTimeout(_),_=null,(!a||!l)&&(a=!0,l=!0,g())):a&&!v&&(v=setTimeout(()=>{if(v=null,n||m())return o();a=!1,g(),_=setTimeout(()=>{if(_=null,!n){if(m())return o();l=!1,g()}},500)},180)))},x=h=>{n||(k={x:Number.isFinite(h.x)?h.x:-1,y:Number.isFinite(h.y)?h.y:-1,overAvatar:h.overAvatar===!0},t.style.pointerEvents=k.overAvatar?"auto":"none",o())},d=h=>x({x:h.clientX,y:h.clientY,overAvatar:i(h.clientX,h.clientY)}),S=()=>x({x:-1,y:-1,overAvatar:!1}),T=()=>queueMicrotask(o),L=h=>{["Shift","Control","Alt","Meta"].includes(h.key)||(e.dataset.keyboard="true"),T()},P=()=>{e.dataset.keyboard="false",T()},I=()=>{e.dataset.keyboard="false",S()},O=(h,A,te)=>(h.addEventListener(A,te),()=>h.removeEventListener(A,te)),V=[O(document,"pointermove",d),O(document,"pointerleave",S),O(document,"focusin",T),O(document,"focusout",T),O(document,"keydown",L),O(document,"pointerdown",P),O(window,"blur",I)];return e.dataset.keyboard="false",e.dataset.revealed="false",e.dataset.interactive="false",e.dataset.confirming="false",t.style.pointerEvents="none",{pointer:x,refresh(){o()},setConfirmation(h){r=!!h,g(),o()},get interactive(){return l},regions(){return l?[C(e),f()]:[]},dispose(){n=!0,clearTimeout(v),clearTimeout(_),V.forEach(h=>h())}}}function Le(e){if(e?.type!=="surface")throw Error("invalid_surface");if(e.panel===null)return{type:"surface",panel:null};let t=e.panel;if(!t||!/^s\d+$/.test(t.id)||!Number.isSafeInteger(t.revision)||t.revision<1||!Array.isArray(t.nodes)||t.nodes.length>160)throw Error("invalid_surface");let i=0,c=t.nodes.map(n=>{if(!n||!["text","heading","button","checkbox","break"].includes(n.kind)||typeof n.text!="string"||n.text.length>4e3||(i+=n.text.length,i>1e4))throw Error("invalid_surface");let a={kind:n.kind,text:n.text};if(["running","completed","waiting","failed","stopped"].includes(n.taskState)&&(a.taskState=n.taskState),n.kind==="button"&&n.taskState==="completed"&&Number.isInteger(n.countdown)&&n.countdown>=0&&n.countdown<=10&&(a.countdown=n.countdown),n.kind==="button"||n.kind==="checkbox"){if(!/^a\d+$/.test(n.action))throw Error("invalid_surface");Object.assign(a,{action:n.action,disabled:n.disabled===!0,checked:n.checked===!0,gesture:n.gesture===!0,label:String(n.label||"").slice(0,100)})}return a});return{type:"surface",panel:{id:t.id,revision:t.revision,nodes:c,target:["online","tts_only"].includes(t.target)?t.target:null,...t.layout==="tasks"?{layout:"tasks"}:{}}}}function $e(e,{send:t,changed:i}){let c=null,n="",a=new Map;return{update(l){let r=Le(l).panel,k=JSON.stringify(r);if(k===n)return;let v=e.contains(document.activeElement)?document.activeElement.dataset.surfaceAction:null,_=e.scrollTop,C=c?.id===r?.id;n=k,c=r,e.hidden=!r,e.dataset.layout=r?.layout||"";let M=[],f=new Map,g=(m,o)=>{let x=C?a.get(m):null,d=x?.tagName.toLowerCase()===o?x:document.createElement(o);return f.set(m,d),M.push(d),d};if(r){if(r.nodes.some(m=>m.gesture)){let m=r.nodes.find(x=>x.gesture&&x.kind==="button"),o=g("gesture","p");o.className="gesture-note",o.textContent=m?.text==="\u5F00\u59CB\u6559\u5B66"?"\u8BF7\u56DE\u5230 DSH\uFF0C\u70B9\u51FB\u201C\u5F00\u59CB\u6559\u5B66\u201D\u3002":"\u8BF7\u56DE\u5230 DSH\uFF0C\u70B9\u51FB\u201C\u542F\u52A8\u97F3\u9891\u64AD\u653E\u201D\u3002"}for(let[m,o]of r.nodes.entries()){let x=o.kind==="break"?"br":o.kind==="heading"?"h3":o.kind==="button"?"button":o.kind==="checkbox"?"input":"span",d=g(o.action||"node"+m,x);if(o.taskState?d.dataset.taskState=o.taskState:delete d.dataset.taskState,o.countdown!==void 0){let S=d.querySelector("[data-task-copy]"),T=d.querySelector("[data-task-countdown-label]");(!S||!T)&&(S=document.createElement("span"),S.dataset.taskCopy="",T=document.createElement("small"),T.dataset.taskCountdownLabel="",d.replaceChildren(S,T)),S.textContent=o.text,S.style.cssText="min-width:0;white-space:pre-line;overflow-wrap:anywhere",T.textContent=`${o.countdown}s \u540E\u6D88\u5931`,T.style.cssText="margin-left:auto;flex-shrink:0;color:#737b85;font:400 10px/1.4 system-ui;white-space:nowrap"}else(d.textContent!==o.text||d.querySelector("[data-task-countdown-label]"))&&(d.textContent=o.text);if(o.kind==="checkbox"&&(d.type="checkbox",d.checked=o.checked),o.kind==="button"||o.kind==="checkbox"){d.dataset.surfaceAction=o.action,o.kind==="button"&&(d.type="button"),d.disabled=o.disabled||o.gesture,o.label?d.setAttribute("aria-label",o.label):d.removeAttribute("aria-label");let S=()=>{c!==r||d.disabled||t({type:"surface_action",id:r.id,revision:r.revision,action:o.action,checked:d.checked===!0})};o.kind==="checkbox"?d.onchange=S:d.onclick=S}}}for(M.forEach((m,o)=>{e.children[o]!==m&&e.insertBefore(m,e.children[o]||null)});e.children.length>M.length;)e.lastElementChild.remove();if(a=f,v){let m=a.get(v);m&&!m.disabled&&document.activeElement!==m&&m.focus({preventScroll:!0})}e.scrollTop=_,i(!!r,r?.target)}}}var De="avatar_local_v1";var nt=["open_dsh","pending","settings","tutorial","hide","notifications","size","bubble","view","dismiss"],ve=["small","medium","large"],it=["completed","failed","stopped","approval","question","plan_review"];var pe=(e,t)=>typeof e=="string"?e.slice(0,t):"";function He(e){if(e?.type!=="menu_action"||!nt.includes(e.action)||!/^[a-zA-Z0-9-]{1,64}$/.test(e.request_id||""))throw Error("invalid_avatar_menu_action");let t={type:"menu_action",request_id:e.request_id,action:e.action};if(["size","bubble"].includes(e.action)){if(!ve.includes(e.value))throw Error("invalid_avatar_size");t.value=e.value}if(["view","dismiss"].includes(e.action)){if(typeof e.id!="string"||!e.id||e.id.length>512)throw Error("invalid_avatar_notice");t.id=e.id}if(e.action==="notifications"){if(typeof e.value!="boolean")throw Error("invalid_avatar_preference");t.value=e.value}if(e.action==="snooze"){if(![0,30].includes(e.value))throw Error("invalid_avatar_snooze");t.value=e.value}return t}function Pe(e){if(e?.type!=="local_state"||e.protocol!==De||!Number.isSafeInteger(e.revision)||e.revision<0||!Array.isArray(e.items)||e.items.length>32)throw Error("invalid_avatar_local_state");let t=e.items.map(i=>{if(!it.includes(i.status)||!i.id||typeof i.id!="string"||i.id.length>512)throw Error("invalid_avatar_notice");return{id:i.id,session_id:pe(i.session_id,256),name:pe(i.name,100),status:i.status,summary:pe(i.summary,240),pending:i.pending===!0,unread:i.unread===!0}});for(;JSON.stringify(t).length>12e3;)t.pop();return{type:"local_state",protocol:De,revision:e.revision,items:t,size:ve.includes(e.size)?e.size:"large",bubble:ve.includes(e.bubble)?e.bubble:"medium",enabled:e.enabled!==!1,snoozed:e.snoozed===!0,running:Math.max(0,Math.min(1e4,Number(e.running)||0)),available:e.available===!0,toast:t.some(i=>i.id===e.toast)?e.toast:null}}function Ue(e){if(e?.type!=="menu_result"||!/^[a-zA-Z0-9-]{1,64}$/.test(e.request_id||""))throw Error("invalid_avatar_menu_result");return{type:"menu_result",request_id:e.request_id,ok:e.ok===!0,message:pe(e.message,180)}}var Ve={completed:"\u672C\u8F6E\u5DF2\u5B8C\u6210",failed:"\u6267\u884C\u5931\u8D25",stopped:"\u5DF2\u505C\u6B62",approval:"\u7B49\u5F85\u6388\u6743",question:"\u7B49\u5F85\u56DE\u7B54",plan_review:"\u7B49\u5F85\u65B9\u6848\u786E\u8BA4"},je={small:"\u7D27\u51D1",medium:"\u6807\u51C6",large:"\u5BBD\u677E"},_e={open:"M14 3h7v7m0-7L10 14M10 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5",pending:"M8 4h8m-9 0H5v17h14V4h-2M8 3h8v4H8zM8 12h8m-8 4h5",bubble:"M5 4h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-5 3v-3H3V6a2 2 0 0 1 2-2zM7 9h10m-10 4h6",tutorial:"m9 5 10 7-10 7z",settings:"M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8M9 3h6l1 3 3 1 2 5-2 5-3 1-1 3H9l-1-3-3-1-2-5 2-5 3-1z",hide:"m4 4 16 16M9 5a11 11 0 0 1 12 7l-3 4M6 6a13 13 0 0 0-5 6s4 7 11 7l3-1M10 10a3 3 0 0 0 4 4",back:"m14 5-7 7 7 7"},ot=e=>{let t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true"),t.innerHTML=`<path d="${_e[e]||_e.pending}"/>`,t};function Fe({anchor:e,viewport:t=()=>[0,0,innerWidth,innerHeight],send:i,changed:c=()=>{}}){let n={items:[],running:0,enabled:!0,size:"large",bubble:"medium"},a,l,r="main",k,v=!1,_,C,M,f,g=document.createElement("style");g.textContent=`
|
|
2
2
|
.duet-pet-menu{position:fixed;z-index:2147483601;box-sizing:border-box;width:264px;max-width:calc(100vw - 24px);padding:9px;border:1px solid #a7c5dc30;border-radius:18px;background:#142330f7;color:#eaf2f8;font:13px/1.5 Inter,"PingFang SC",sans-serif;box-shadow:0 16px 48px #0004,0 2px 8px #0002;backdrop-filter:blur(20px);pointer-events:auto;overflow:auto}
|
|
3
3
|
.duet-pet-menu button{position:relative;display:flex;align-items:center;justify-content:flex-start;gap:10px;box-sizing:border-box;width:100%;min-height:39px;margin:0;border:0;border-radius:10px;padding:8px 11px;background:transparent;color:inherit;text-align:left;font:inherit;cursor:pointer;height:auto;flex-shrink:0;letter-spacing:normal}
|
|
4
4
|
.duet-pet-menu button>[data-label]{min-width:0;flex:1;overflow-wrap:anywhere}
|
|
@@ -11,7 +11,7 @@ import{mountAvatarRenderer as st}from"./renderer.mjs";var ge=Object.freeze({larg
|
|
|
11
11
|
.duet-pet-menu [data-switch]:after{content:'';position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:white;transition:transform .15s}.duet-pet-menu [aria-checked=true] [data-switch]{background:#6eabc9}.duet-pet-menu [aria-checked=true] [data-switch]:after{transform:translateX(12px)}
|
|
12
12
|
.duet-pet-menu [data-bubble-preview]{margin:12px 9px;padding:12px 14px;border-radius:15px 15px 15px 4px;border:1px solid #8dc5ed45;background:#213b4c;white-space:pre-wrap;overflow:auto;line-height:1.7;scrollbar-width:thin}
|
|
13
13
|
.duet-pet-menu p{margin:10px 12px;color:#a7bdd0}.duet-pet-menu [data-notice-title]{padding:8px 11px;font-weight:600}
|
|
14
|
-
`,document.head.append(g);let m=s=>{let[u,y,b,w]=t();s.style.maxHeight=Math.max(40,w-24)+"px",s.style.maxWidth=Math.max(40,b-24)+"px";let E=e().getBoundingClientRect(),
|
|
14
|
+
`,document.head.append(g);let m=s=>{let[u,y,b,w]=t();s.style.maxHeight=Math.max(40,w-24)+"px",s.style.maxWidth=Math.max(40,b-24)+"px";let E=e().getBoundingClientRect(),B=s.getBoundingClientRect(),tt=_?.y??(E.top-B.height-12>=y?E.top-B.height-12:E.bottom+12);s.style.left=Math.max(u+12,Math.min(_?.x??E.left,u+b-B.width-12))+"px",s.style.top=Math.max(y+12,Math.min(tt,y+w-B.height-12))+"px"},o=()=>{a?.remove(),a=null,_=null,C?.isConnected&&C.focus({preventScroll:!0}),c()},x=(s,u,y)=>i(He({type:"menu_action",request_id:crypto.randomUUID(),action:s,value:u,id:y})),d=(s,u,y=u,b)=>{let w=document.createElement("button");w.type="button",w.setAttribute("role","menuitem"),w.dataset.menuAction=u,_e[y]&&w.append(ot(y));let E=document.createElement("span");return E.dataset.label="",E.textContent=s,w.append(E),w.onclick=()=>{if(["pending","bubble_panel","back"].includes(u)){r=u==="back"?"main":u,P();return}o(),x(u,void 0,b)},w},S=()=>"\u5F85\u5904\u7406\u4E8B\u9879\u4E0E\u901A\u77E5",T=s=>{let u=document.createElement("span");return u.dataset.value="",s.append(u),u},L=()=>{if(!a)return;let s=a.querySelector("[data-menu-action=size]");if(s){let E=s.querySelector("[data-size-icon]");oe(E,n.size),s.querySelector("[data-value]").textContent={large:"\u5927",medium:"\u4E2D",small:"\u5C0F"}[n.size],s.setAttribute("aria-label",E.getAttribute("aria-label"))}a.querySelector("[data-menu-action=notifications]")?.setAttribute("aria-checked",String(n.enabled));let y=a.querySelector("[data-menu-action=bubble]");y&&(y.querySelector("[data-value]").textContent=je[n.bubble],y.setAttribute("aria-label",`\u6C14\u6CE1\u5927\u5C0F\uFF1A${je[n.bubble]}\uFF0C\u70B9\u51FB\u5207\u6362`));let b=a.querySelector("[data-bubble-preview]");b&&(b.style.maxHeight={small:60,medium:110,large:180}[n.bubble]+"px",b.dataset.size=n.bubble);let w=a.querySelector("[data-menu-action=pending] span");w&&(w.textContent=S()),m(a),c()},P=()=>{if(!a)return;a.replaceChildren();let s=document.createElement("div");s.dataset.wordmark="",s.append("duet");let u=document.createElement("span");u.textContent=".",s.append(u),a.append(s);let y=()=>a.append(document.createElement("hr"));if(r==="main"){a.append(d("\u6253\u5F00 DSH","open_dsh","open"),d(S(),"pending"));let b=d("\u4EFB\u52A1\u901A\u77E5","notifications","pending");b.setAttribute("role","menuitemcheckbox");let w=document.createElement("span");w.dataset.switch="",b.append(w),b.onclick=()=>{n.enabled=!n.enabled,L(),x("notifications",n.enabled)},a.append(b),y();let E=d("\u5F62\u8C61\u5927\u5C0F","size"),B=document.createElement("span");B.dataset.sizeIcon="",E.prepend(B),T(E),E.onclick=()=>{n.size=ae(n.size),L(),x("size",n.size)},a.append(E,d("\u6C14\u6CE1\u5927\u5C0F","bubble_panel","bubble")),y(),a.append(d("\u4F7F\u7528\u6559\u5B66","tutorial"),d("duet \u8BBE\u7F6E","settings"),d("\u9690\u85CF\u5F62\u8C61","hide"))}else if(r==="bubble_panel"){let b=d("\u6C14\u6CE1\u5927\u5C0F","bubble","bubble");T(b),b.onclick=()=>{n.bubble={small:"medium",medium:"large",large:"small"}[n.bubble],L(),x("bubble",n.bubble)},a.append(b);let w=document.createElement("div");w.dataset.bubblePreview="",w.setAttribute("aria-label","\u793A\u4F8B\u6C14\u6CE1"),w.textContent=`\u597D\u7684\uFF0C\u6211\u6765\u5E2E\u4F60\u3002
|
|
15
15
|
\u4EFB\u52A1\u5B8C\u6210\u540E\uFF0C\u6211\u4F1A\u5728\u8FD9\u91CC\u544A\u8BC9\u4F60\u7ED3\u679C\u3002
|
|
16
16
|
\u4E5F\u53EF\u4EE5\u968F\u65F6\u6253\u65AD\u6211\uFF0C\u7EE7\u7EED\u804A\u804A\u4F60\u7684\u65B0\u60F3\u6CD5\u3002
|
|
17
|
-
\u8FD9\u662F\u4E00\u6BB5\u8F83\u957F\u7684\u6587\u5B57\uFF0C\u4F60\u53EF\u4EE5\u770B\u770B\u5F53\u524D\u6C14\u6CE1\u80FD\u663E\u793A\u591A\u5C11\u5185\u5BB9\u3002`,a.append(w,d("\u8FD4\u56DE","back"))}else{if(!n.available){let b=document.createElement("p");b.textContent="\u6B63\u5728\u8FDE\u63A5 DSH",a.append(b)}if(!n.items.length){let b=document.createElement("p");b.textContent="\u6682\u65F6\u6CA1\u6709\u5F85\u5904\u7406\u4E8B\u9879\u6216\u65B0\u901A\u77E5",a.append(b)}for(let b of n.items){let w=d(`${b.unread?"\u25CF ":""}${b.name||"\u672A\u547D\u540D\u4F1A\u8BDD"} \xB7 ${Ue[b.status]}`,"view","pending",b.id);w.title=b.summary,a.append(w)}a.append(d("\u8FD4\u56DE","back"))}L(),a.querySelector("button")?.focus({preventScroll:!0})},I=(s,u="main")=>{v||(s?.preventDefault(),s?.stopPropagation(),o(),C=document.activeElement,r=u,_=s&&Number.isFinite(s.clientX)&&s.clientX>0?{x:s.clientX,y:s.clientY}:null,a=document.createElement("div"),a.className="duet-pet-menu",a.dataset.duetContextMenu="",a.setAttribute("role","menu"),a.setAttribute("aria-label","duet \u5F62\u8C61\u83DC\u5355"),document.body.append(a),H())},O=s=>{a&&!a.contains(s.target)&&(s.preventDefault(),s.stopPropagation(),o())},V=s=>{if(!a)return;if(s.key==="Escape"){s.preventDefault(),s.stopImmediatePropagation(),o();return}let u=[...a.querySelectorAll("button")],y=u.indexOf(document.activeElement);["ArrowDown","ArrowUp","Home","End","Tab"].includes(s.key)&&(s.preventDefault(),u[s.key==="Home"?0:s.key==="End"?u.length-1:(y+(s.key==="ArrowUp"||s.key==="Tab"&&s.shiftKey?-1:1)+u.length)%u.length]?.focus())},h=(s,u)=>{s.className="duet-pet-menu",s.setAttribute("aria-label",u)},A=s=>{if(n=He(s),M!==n.toast){clearTimeout(k),clearTimeout(f),l?.remove(),l=null,M=n.toast;let u=n.items.find(y=>y.id===n.toast);if(u){if(l=document.createElement("section"),l.dataset.duetLocalNotice="",u.status==="completed"){l.setAttribute("aria-label","DSH \u4EFB\u52A1\u901A\u77E5"),l.setAttribute("role","status"),l.style.cssText="position:fixed;z-index:2147483600;width:264px;max-width:calc(100vw - 24px);pointer-events:auto";let y=document.createElement("button");y.type="button",y.dataset.completionCard="",y.style.cssText=Ie;let b=document.createElement("span");b.textContent="\u2713",b.setAttribute("aria-hidden","true"),b.style.cssText="flex:0 0 18px;width:18px;height:18px;border-radius:50%;background:#dcefe8;color:#23845e;text-align:center;font:600 14px/18px system-ui";let w=document.createElement("span"),E=document.createElement("strong"),N=document.createElement("small");w.style.cssText="min-width:0;overflow-wrap:anywhere",E.textContent=u.name||"\u672A\u547D\u540D\u4F1A\u8BDD",E.style.cssText="display:block;font-size:13px;font-weight:550",N.textContent="\u5DF2\u5B8C\u6210",N.style.cssText="display:block;font-size:11px;opacity:.7",w.append(E,N),y.append(b,w),y.setAttribute("aria-label",`${E.textContent} \xB7 \u5DF2\u5B8C\u6210\uFF0C\u67E5\u770B\u4F1A\u8BDD`),y.onclick=()=>x("view",void 0,u.id),l.append(y)}else{h(l,"DSH \u4EFB\u52A1\u901A\u77E5");let y=document.createElement("div");y.dataset.noticeTitle="",y.textContent=`${u.name||"\u672A\u547D\u540D\u4F1A\u8BDD"} \xB7 ${Ue[u.status]}`,l.append(y,d(u.pending?"\u53BB\u5904\u7406":"\u67E5\u770B","view","open",u.id),d("\u6536\u8D77","dismiss","hide",u.id))}document.body.append(l),m(l),u.pending||(k=setTimeout(()=>{l?.remove(),l=null,c()},u.status==="completed"?3e3:8e3))}}L(),c()},te=s=>{let u=Pe(s);u.message&&(clearTimeout(f),l?.remove(),l=document.createElement("section"),h(l,"\u64CD\u4F5C\u63D0\u793A"),l.textContent=u.message,document.body.append(l),m(l),c(),f=setTimeout(()=>{l?.remove(),l=null,c()},4e3))},de=()=>{a&&m(a),l&&m(l)};return document.addEventListener("pointerdown",O,!0),document.addEventListener("keydown",V,!0),window.addEventListener("resize",de),window.addEventListener("blur",o),{open:I,close:o,update:A,result:te,get active(){return!!a},regions(){return[a,l].filter(s=>s?.isConnected&&!s.hidden).map(s=>{let u=s.getBoundingClientRect();return[u.x,u.y,u.width,u.height]})},dispose(){v=!0,o(),g.remove(),clearTimeout(k),clearTimeout(f),l?.remove(),document.removeEventListener("pointerdown",O,!0),document.removeEventListener("keydown",V,!0),window.removeEventListener("resize",de),window.removeEventListener("blur",o)}}}var F=(e,t,i)=>Number.isFinite(e)&&e>=t&&e<=i,_e=e=>e&&F(e.width,1,1e6)&&F(e.height,1,1e6)?{width:e.width,height:e.height}:null;function Fe(e){if(!e||!["desktop_physical","viewport_css"].includes(e.space))return null;let t=_e(e.total_resolution),i=e.avatar_position;if(!t||!i||!F(i.x,-1e6,1e6)||!F(i.y,-1e6,1e6)||!_e(i))return null;let c={space:e.space,total_resolution:t,avatar_position:{x:i.x,y:i.y,width:i.width,height:i.height}};if(e.space==="desktop_physical"){if(!e.desktop_origin||!F(e.desktop_origin.x,-1e6,1e6)||!F(e.desktop_origin.y,-1e6,1e6)||!F(e.scale,.25,16))return null;c.desktop_origin={x:e.desktop_origin.x,y:e.desktop_origin.y},c.scale=e.scale}else{let n=_e(e.viewport_resolution);if(!n)return null;c.viewport_resolution=n}return c}var ne=window.__DUET_AVATAR__,P=(e,t)=>window.__TAURI__.core.invoke(e,t);if(!ne||!/^ws:\/\/127\.0\.0\.1:\d+\/?$/.test(ne.url)||!/^[a-f0-9]{64}$/.test(ne.token))throw Error("companion must be started by duet");var p=e=>document.getElementById(e),D=new WebSocket(ne.url,[`duet-avatar-${ne.token}`]),xe=!1,X=!1,B=!1,Y=Date.now(),G,he,W=null,ke=!1,J=null,me=null,K=j(ne.size),le=!1,Ee=null,R,Je="medium",Ye,z={mode:"off",ready:!1,rms:0,viseme:"A",text:"",utterance:""},re=null,Se=[],Xe,Ke,be=null,Ae=!1,We="";async function rt(){if(!(!xe||B||Ae)){Ae=!0;try{let e=await P("avatar_geometry"),t=p("avatar").getBoundingClientRect(),i=e.scale,c=Fe({space:"desktop_physical",total_resolution:e.total_resolution,desktop_origin:e.desktop_origin,scale:i,avatar_position:{x:e.window_origin.x+t.x*i,y:e.window_origin.y+t.y*i,width:t.width*i,height:t.height*i}}),n=JSON.stringify(c);c&&n!==We&&(We=n,q({type:"avatar_geometry",position:c}))}catch{}finally{Ae=!1}}}var Te=()=>{if(!be)return[0,0,innerWidth,innerHeight];let[e,t,i,c]=be,n=Math.max(0,e),a=Math.max(0,t);return[n,a,Math.max(1,Math.min(innerWidth,e+i)-n),Math.max(1,Math.min(innerHeight,t+c)-a)]},Q=Ne({tools:p("tools"),avatar:p("avatar"),hitTest:(e,t)=>qe(Se,se(p("avatar")),e,t),onChange:()=>{ee()}}),Ge={getBoundingClientRect(){let e=p("avatar").getBoundingClientRect(),t=p("tools").getBoundingClientRect();return{left:e.left,width:e.width,top:e.top,bottom:Math.max(e.bottom,t.bottom)}}},Z=Re({floating:!0,origin:"avatar",anchor:()=>Ge,viewport:Te,onChange:()=>Q.setConfirmation(le||!!Z.element||R?.active)}),lt=Le(p("surface"),{send:e=>q(e),changed:(e,t)=>{le=e,e||(Ee=null),Q.setConfirmation(e||!!Z.element||R?.active);for(let i of document.querySelectorAll("[data-mode]"))i.toggleAttribute("data-teaching",i.dataset.mode===t);ie(),ee()}});R=je({anchor:()=>Ge,viewport:Te,send:async e=>{if(e.action==="hide")p("close").click();else{if(["open_dsh","view","settings"].includes(e.action))try{await P("focus_dsh")}catch{R.result({type:"menu_result",request_id:e.request_id,ok:!1,message:"\u672A\u80FD\u5524\u8D77 DSH\uFF0C\u8BF7\u786E\u8BA4\u6240\u5C5E\u7A97\u53E3\u4ECD\u7136\u6253\u5F00\uFF1B\u82E5\u521A\u66F4\u65B0\u63D2\u4EF6\uFF0C\u8BF7\u66F4\u65B0\u684C\u9762\u5F62\u8C61\u3002"});return}q(e)}},changed:()=>{Q.setConfirmation(le||!!Z.element||R.active),ee()}});var dt=Promise.all([window.__TAURI__.event.listen("avatar-pointer",e=>Q.pointer(e.payload)).then(e=>{B?e():Xe=e}),window.__TAURI__.event.listen("avatar-viewport",e=>{!Array.isArray(e.payload)||e.payload.length!==4||!e.payload.every(Number.isFinite)||be?.every((t,i)=>t===e.payload[i])||(be=e.payload,ie(),window.dispatchEvent(new Event("resize")),ee())}).then(e=>{B?e():Ke=e})]).catch(()=>{X=!0,q({type:"failed"}),U()});oe(p("size"),K);var q=e=>{D.readyState===1&&D.bufferedAmount<16e3&&D.send(JSON.stringify(e))};function ie(){let e=p("bubble"),t=p("surface"),i=[e,t].filter(I=>!I.hidden);if(!i.length)return;let[c,n,a,l]=Te(),r=p("avatar").getBoundingClientRect(),k=p("tools").getBoundingClientRect(),v=r.width/p("avatar").offsetWidth||1,_=12*v;e.style.width="256px",e.style.right="auto";for(let I of i)I.style.maxHeight=Math.max(1,l-24)/v+"px";let C=e.hidden?0:Math.min({small:90,medium:180,large:260}[Je]*v,e.getBoundingClientRect().height),M=t.hidden?0:Math.min((t.dataset.layout==="tasks"?384:256)*v,t.getBoundingClientRect().height),f=i.length>1?_:0,g=C+M+f,m=Math.max(0,r.top-_-(n+12)),o=Math.max(0,n+l-12-(k.bottom+_)),x=le?Ee:null;(!x||(x==="above"?m:o)<Math.min(g,80*v))&&(x=m>=g?"above":o>=g?"below":m>=o?"above":"below"),le&&(Ee=x);let d=x==="above"?m:o,S=t.hidden?d:Math.min(C,Math.max(0,(d-f)*.3)),T=Math.min(C,S),L=Math.min(M,Math.max(0,d-T-f));e.hidden||(e.style.maxHeight=Math.max(1,T/v)+"px"),t.hidden||(t.style.maxHeight=Math.max(1,L/v)+"px");let H=x==="above"?r.top-_:k.bottom+_;for(let I of i){let O=I.getBoundingClientRect(),V=I.offsetParent.getBoundingClientRect(),h=Math.max(c+12,Math.min(r.left+r.width/2-O.width/2,c+a-12-O.width)),A=x==="above"?H-O.height:H;I.style.left=(h-V.left)/v+"px",I.style.top=(A-V.top)/v+"px",I.style.bottom="auto",I.style.right="auto",H=x==="above"?A-_:A+O.height+_}e.hidden||(e.scrollTop=e.scrollHeight)}var ze=()=>{let e=re?.text||z.text,t=p("bubble").hidden===!!e||p("text").textContent!==e;p("bubble").hidden=!e,p("bubble").dataset.input=String(!!re),p("keyboard").toggleAttribute("hidden",!re),p("text").textContent!==e&&(p("text").textContent=e),t&&ie()},fe=()=>{clearTimeout(he),re=null,ze()},ct=()=>{for(let t of document.querySelectorAll("[data-mode]")){let i=z.mode===t.dataset.mode;t.disabled=!1,t.setAttribute("aria-pressed",String(i)),t.setAttribute("aria-busy",String(i&&!z.ready)),t.querySelector("[data-connecting-ring]").hidden=!(i&&!z.ready),t.setAttribute("aria-label",`${i?"\u5173\u95ED":"\u6253\u5F00"}${t.dataset.mode==="online"?"\u4EA4\u4E92\u6A21\u5F0F":"\u64AD\u62A5\u6A21\u5F0F"}`),t.title=i&&!z.ready?`\u6B63\u5728\u8FDE\u63A5${t.dataset.mode==="online"?"\u4EA4\u4E92\u6A21\u5F0F":"\u64AD\u62A5\u6A21\u5F0F"}`:t.getAttribute("aria-label")}p("dot").style.color=z.ready?"#7fd6a6":"#ed9b35";let e=z.mode==="off"?"\u8BED\u97F3\u672A\u5F00\u542F":z.ready?z.mode==="online"?"\u4EA4\u4E92\u6A21\u5F0F":"\u64AD\u62A5\u6A21\u5F0F":"\u6B63\u5728\u8FDE\u63A5\u2026";p("status").textContent!==e&&(p("status").textContent=e)},U=()=>{B||(B=!0,R.dispose(),Z.dispose(),Q.dispose(),Xe?.(),Ke?.(),clearInterval(ut),clearInterval(pt),clearTimeout(he),G?.update({...z,rms:0,text:""}),G?.dispose(),D.close(),P("hide_avatar").catch(()=>{}))},Ce=()=>{X?q({type:"failed"}):xe&&q({type:"ready",protocol:2})},Ze=e=>(K=j(e),J||K===me?J||Promise.resolve():(J=(async()=>{for(await W;!B&&K!==me;){let t=K,i=!0,c=await P("set_avatar_size",{size:t,panel:i});if(!c||!Number.isFinite(c.scale)||c.scale<=0||c.scale>1)throw Error("invalid_avatar_layout");p("shell").style.transform=`scale(${c.fit??1})`,p("shell").dataset.panel=String(i),p("stage").dataset.size=t,p("stage").style.setProperty("--scale",c.scale),oe(p("size"),t),me=t,Q.refresh(),ie()}})().catch(()=>{X=!0,q({type:"failed"}),U()}).finally(()=>{J=null}),J));try{G=st(p("avatar"),{modelURL:"./character.glb",onReady(){Promise.all([dt,Ze(K)]).then(async()=>{if(!(B||X)&&(xe=!0,await ee(),!B))return Ce(),P("show_avatar")}).catch(()=>{X=!0,q({type:"failed"}),U()})},onError(){X=!0,Ce()}})}catch{X=!0}D.onopen=Ce;var Qe=new ce(1e3);D.onmessage=e=>{Qe.touch();try{let t=JSON.parse(e.data);if(t.type==="frame")z=Me(t),Y=Date.now(),G?.update(z),Ze(z.size),z.mode==="off"&&fe(),ze(),ct();else if(t.type==="input_effect")re=Oe(t),Y=Date.now(),clearTimeout(he),ze(),he=setTimeout(fe,1600);else if(t.type==="clear_input_effect")fe();else if(t.type==="surface")lt.update(t),Y=Date.now();else if(t.type==="local_state")R.update(t),Je=t.bubble,ie(),Y=Date.now(),t.toast&&t.toast!==Ye&&z.mode==="off"&&t.items.find(i=>i.id===t.toast)?.status==="completed"&&G?.update({...z,text:"\u5B8C\u6210\u4E86",utterance:"notice-"+t.toast}),Ye=t.toast;else if(t.type==="menu_result")R.result(t),Y=Date.now();else if(t.type==="owner_focus")P("remember_dsh").catch(()=>{}),Y=Date.now();else if(t.type!=="alive")throw Error("invalid_avatar_message")}catch{D.close(1008,"invalid_avatar_message")}};D.onclose=U;D.onerror=U;var ut=setInterval(()=>{if(Qe.expired()){U();return}Date.now()-Y>1500&&(G?.update({...z,rms:0,text:""}),z={...z,text:""},fe()),q({type:"alive"}),rt()},1e3),se=e=>{let t=e.getBoundingClientRect();return[t.x,t.y,t.width,t.height]};function ee(){if(!(!xe||J||B||document.hidden))return W?(ke=!0,W):(W=(async()=>{do{if(ke=!1,B||J||document.hidden)break;let e=Z.element?[se(Z.element)]:R.active?[[0,0,innerWidth,innerHeight]]:[...Q.regions(),...p("bubble").hidden?[]:[se(p("bubble"))],...p("surface").hidden?[]:[se(p("surface"))],...R.regions()];Se=G.hitMask(),await P("avatar_hit_mask",{mask:Se,avatar:se(p("avatar")),regions:e})}while(ke)})().catch(()=>{}).finally(()=>{W=null}),W)}var pt=setInterval(()=>{W||ee()},350);for(let e of document.querySelectorAll("[data-mode]")){let t=document.createElement("span");t.dataset.connectingRing="",t.hidden=!0,t.innerHTML='<svg viewBox="0 0 30 30" preserveAspectRatio="none" aria-hidden="true"><rect x="1" y="1" width="28" height="28" rx="7" pathLength="100"/></svg>',e.append(t),e.onclick=()=>q({type:"mode",mode:e.dataset.mode})}p("close").onclick=async()=>{await Z.ask()&&!B&&(q({type:"hide"}),U())};p("size").onclick=()=>q({type:"size",size:ae(me||K)});var $=null;p("avatar").tabIndex=0;p("avatar").oncontextmenu=e=>{$=null,R.open(e)};p("avatar").onkeydown=e=>{(e.key==="ContextMenu"||e.key==="F10"&&e.shiftKey)&&($=null,R.open(e))};p("avatar").onpointerdown=e=>{e.button===0&&!e.ctrlKey&&!R.active&&($={x:e.clientX,y:e.clientY})};p("avatar").onpointermove=e=>{$&&!R.active&&e.buttons===1&&Math.hypot(e.clientX-$.x,e.clientY-$.y)>4&&($=null,P("drag_avatar").catch(()=>{}))};window.addEventListener("pointerup",()=>{$=null});window.addEventListener("blur",()=>{$=null});window.addEventListener("resize",()=>{ie(),ee()});window.addEventListener("pagehide",U,{once:!0});
|
|
17
|
+
\u8FD9\u662F\u4E00\u6BB5\u8F83\u957F\u7684\u6587\u5B57\uFF0C\u4F60\u53EF\u4EE5\u770B\u770B\u5F53\u524D\u6C14\u6CE1\u80FD\u663E\u793A\u591A\u5C11\u5185\u5BB9\u3002`,a.append(w,d("\u8FD4\u56DE","back"))}else{if(!n.available){let b=document.createElement("p");b.textContent="\u6B63\u5728\u8FDE\u63A5 DSH",a.append(b)}if(!n.items.length){let b=document.createElement("p");b.textContent="\u6682\u65F6\u6CA1\u6709\u5F85\u5904\u7406\u4E8B\u9879\u6216\u65B0\u901A\u77E5",a.append(b)}for(let b of n.items){let w=d(`${b.unread?"\u25CF ":""}${b.name||"\u672A\u547D\u540D\u4F1A\u8BDD"} \xB7 ${Ve[b.status]}`,"view","pending",b.id);w.title=b.summary,a.append(w)}a.append(d("\u8FD4\u56DE","back"))}L(),a.querySelector("button")?.focus({preventScroll:!0})},I=(s,u="main")=>{v||(s?.preventDefault(),s?.stopPropagation(),o(),C=document.activeElement,r=u,_=s&&Number.isFinite(s.clientX)&&s.clientX>0?{x:s.clientX,y:s.clientY}:null,a=document.createElement("div"),a.className="duet-pet-menu",a.dataset.duetContextMenu="",a.setAttribute("role","menu"),a.setAttribute("aria-label","duet \u5F62\u8C61\u83DC\u5355"),document.body.append(a),P())},O=s=>{a&&!a.contains(s.target)&&(s.preventDefault(),s.stopPropagation(),o())},V=s=>{if(!a)return;if(s.key==="Escape"){s.preventDefault(),s.stopImmediatePropagation(),o();return}let u=[...a.querySelectorAll("button")],y=u.indexOf(document.activeElement);["ArrowDown","ArrowUp","Home","End","Tab"].includes(s.key)&&(s.preventDefault(),u[s.key==="Home"?0:s.key==="End"?u.length-1:(y+(s.key==="ArrowUp"||s.key==="Tab"&&s.shiftKey?-1:1)+u.length)%u.length]?.focus())},h=(s,u)=>{s.className="duet-pet-menu",s.setAttribute("aria-label",u)},A=s=>{if(n=Pe(s),M!==n.toast){clearTimeout(k),clearTimeout(f),l?.remove(),l=null,M=n.toast;let u=n.items.find(y=>y.id===n.toast);if(u){if(l=document.createElement("section"),l.dataset.duetLocalNotice="",u.status==="completed"){l.setAttribute("aria-label","DSH \u4EFB\u52A1\u901A\u77E5"),l.setAttribute("role","status"),l.style.cssText="position:fixed;z-index:2147483600;width:264px;max-width:calc(100vw - 24px);pointer-events:auto";let y=document.createElement("button");y.type="button",y.dataset.completionCard="",y.style.cssText=Re;let b=document.createElement("span");b.textContent="\u2713",b.setAttribute("aria-hidden","true"),b.style.cssText="flex:0 0 18px;width:18px;height:18px;border-radius:50%;background:#dcefe8;color:#23845e;text-align:center;font:600 14px/18px system-ui";let w=document.createElement("span"),E=document.createElement("strong"),B=document.createElement("small");w.style.cssText="min-width:0;overflow-wrap:anywhere",E.textContent=u.name||"\u672A\u547D\u540D\u4F1A\u8BDD",E.style.cssText="display:block;font-size:13px;font-weight:550",B.textContent="\u5DF2\u5B8C\u6210",B.style.cssText="display:block;font-size:11px;opacity:.7",w.append(E,B),y.append(b,w),y.setAttribute("aria-label",`${E.textContent} \xB7 \u5DF2\u5B8C\u6210\uFF0C\u67E5\u770B\u4F1A\u8BDD`),y.onclick=()=>x("view",void 0,u.id),l.append(y)}else{h(l,"DSH \u4EFB\u52A1\u901A\u77E5");let y=document.createElement("div");y.dataset.noticeTitle="",y.textContent=`${u.name||"\u672A\u547D\u540D\u4F1A\u8BDD"} \xB7 ${Ve[u.status]}`,l.append(y,d(u.pending?"\u53BB\u5904\u7406":"\u67E5\u770B","view","open",u.id),d("\u6536\u8D77","dismiss","hide",u.id))}document.body.append(l),m(l),u.pending||(k=setTimeout(()=>{l?.remove(),l=null,c()},u.status==="completed"?3e3:8e3))}}L(),c()},te=s=>{let u=Ue(s);u.message&&(clearTimeout(f),l?.remove(),l=document.createElement("section"),h(l,"\u64CD\u4F5C\u63D0\u793A"),l.textContent=u.message,document.body.append(l),m(l),c(),f=setTimeout(()=>{l?.remove(),l=null,c()},4e3))},de=()=>{a&&m(a),l&&m(l)};return document.addEventListener("pointerdown",O,!0),document.addEventListener("keydown",V,!0),window.addEventListener("resize",de),window.addEventListener("blur",o),{open:I,close:o,update:A,result:te,get active(){return!!a},regions(){return[a,l].filter(s=>s?.isConnected&&!s.hidden).map(s=>{let u=s.getBoundingClientRect();return[u.x,u.y,u.width,u.height]})},dispose(){v=!0,o(),g.remove(),clearTimeout(k),clearTimeout(f),l?.remove(),document.removeEventListener("pointerdown",O,!0),document.removeEventListener("keydown",V,!0),window.removeEventListener("resize",de),window.removeEventListener("blur",o)}}}var F=(e,t,i)=>Number.isFinite(e)&&e>=t&&e<=i,ke=e=>e&&F(e.width,1,1e6)&&F(e.height,1,1e6)?{width:e.width,height:e.height}:null;function Ye(e){if(!e||!["desktop_physical","viewport_css"].includes(e.space))return null;let t=ke(e.total_resolution),i=e.avatar_position;if(!t||!i||!F(i.x,-1e6,1e6)||!F(i.y,-1e6,1e6)||!ke(i))return null;let c={space:e.space,total_resolution:t,avatar_position:{x:i.x,y:i.y,width:i.width,height:i.height}};if(e.space==="desktop_physical"){if(!e.desktop_origin||!F(e.desktop_origin.x,-1e6,1e6)||!F(e.desktop_origin.y,-1e6,1e6)||!F(e.scale,.25,16))return null;c.desktop_origin={x:e.desktop_origin.x,y:e.desktop_origin.y},c.scale=e.scale}else{let n=ke(e.viewport_resolution);if(!n)return null;c.viewport_resolution=n}return c}var ne=window.__DUET_AVATAR__,U=(e,t)=>window.__TAURI__.core.invoke(e,t);if(!ne||!/^ws:\/\/127\.0\.0\.1:\d+\/?$/.test(ne.url)||!/^[a-f0-9]{64}$/.test(ne.token))throw Error("companion must be started by duet");var p=e=>document.getElementById(e),D=new WebSocket(ne.url,[`duet-avatar-${ne.token}`]),ge=!1,X=!1,q=!1,Y=Date.now(),G,be,W=null,Ae=!1,J=null,me=null,K=j(ne.size),le=!1,Se=null,R,Xe="medium",We,z={mode:"off",ready:!1,rms:0,viseme:"A",text:"",utterance:""},re=null,ze=[],Ke,Ge,xe=null,Ee=!1,Je="";async function lt(){if(!(!ge||q||Ee)){Ee=!0;try{let e=await U("avatar_geometry"),t=p("avatar").getBoundingClientRect(),i=e.scale,c=Ye({space:"desktop_physical",total_resolution:e.total_resolution,desktop_origin:e.desktop_origin,scale:i,avatar_position:{x:e.window_origin.x+t.x*i,y:e.window_origin.y+t.y*i,width:t.width*i,height:t.height*i}}),n=JSON.stringify(c);c&&n!==Je&&(Je=n,N({type:"avatar_geometry",position:c}))}catch{}finally{Ee=!1}}}var Me=()=>{if(!xe)return[0,0,innerWidth,innerHeight];let[e,t,i,c]=xe,n=Math.max(0,e),a=Math.max(0,t);return[n,a,Math.max(1,Math.min(innerWidth,e+i)-n),Math.max(1,Math.min(innerHeight,t+c)-a)]},Q=Be({tools:p("tools"),avatar:p("avatar"),hitTest:(e,t)=>Ne(ze,se(p("avatar")),e,t),onChange:()=>{ee()}}),Ze={getBoundingClientRect(){let e=p("avatar").getBoundingClientRect(),t=p("tools").getBoundingClientRect();return{left:e.left,width:e.width,top:e.top,bottom:Math.max(e.bottom,t.bottom)}}},Z=qe({floating:!0,origin:"avatar",anchor:()=>Ze,viewport:Me,onChange:()=>Q.setConfirmation(le||!!Z.element||R?.active)}),dt=$e(p("surface"),{send:e=>N(e),changed:(e,t)=>{le=e,e||(Se=null),Q.setConfirmation(e||!!Z.element||R?.active);for(let i of document.querySelectorAll("[data-mode]"))i.toggleAttribute("data-teaching",i.dataset.mode===t);ie(),ee()}});R=Fe({anchor:()=>Ze,viewport:Me,send:async e=>{if(e.action==="hide")p("close").click();else{if(["open_dsh","view","settings"].includes(e.action))try{await U("focus_dsh")}catch{R.result({type:"menu_result",request_id:e.request_id,ok:!1,message:"\u672A\u80FD\u5524\u8D77 DSH\uFF0C\u8BF7\u786E\u8BA4\u6240\u5C5E\u7A97\u53E3\u4ECD\u7136\u6253\u5F00\uFF1B\u82E5\u521A\u66F4\u65B0\u63D2\u4EF6\uFF0C\u8BF7\u66F4\u65B0\u684C\u9762\u5F62\u8C61\u3002"});return}N(e)}},changed:()=>{Q.setConfirmation(le||!!Z.element||R.active),ee()}});var ct=Promise.all([window.__TAURI__.event.listen("avatar-pointer",e=>Q.pointer(e.payload)).then(e=>{q?e():Ke=e}),window.__TAURI__.event.listen("avatar-viewport",e=>{!Array.isArray(e.payload)||e.payload.length!==4||!e.payload.every(Number.isFinite)||xe?.every((t,i)=>t===e.payload[i])||(xe=e.payload,ie(),window.dispatchEvent(new Event("resize")),ee())}).then(e=>{q?e():Ge=e})]).catch(()=>{X=!0,N({type:"failed"}),H()});oe(p("size"),K);var N=e=>{D.readyState===1&&D.bufferedAmount<16e3&&D.send(JSON.stringify(e))};function ie(){let e=p("bubble"),t=p("surface"),i=[e,t].filter(I=>!I.hidden);if(!i.length)return;let[c,n,a,l]=Me(),r=p("avatar").getBoundingClientRect(),k=p("tools").getBoundingClientRect(),v=r.width/p("avatar").offsetWidth||1,_=12*v;e.style.width="256px",e.style.right="auto";for(let I of i)I.style.maxHeight=Math.max(1,l-24)/v+"px";let C=e.hidden?0:Math.min({small:90,medium:180,large:260}[Xe]*v,e.getBoundingClientRect().height),M=t.hidden?0:Math.min((t.dataset.layout==="tasks"?384:256)*v,t.getBoundingClientRect().height),f=i.length>1?_:0,g=C+M+f,m=Math.max(0,r.top-_-(n+12)),o=Math.max(0,n+l-12-(k.bottom+_)),x=le?Se:null;(!x||(x==="above"?m:o)<Math.min(g,80*v))&&(x=m>=g?"above":o>=g?"below":m>=o?"above":"below"),le&&(Se=x);let d=x==="above"?m:o,S=t.hidden?d:Math.min(C,Math.max(0,(d-f)*.3)),T=Math.min(C,S),L=Math.min(M,Math.max(0,d-T-f));e.hidden||(e.style.maxHeight=Math.max(1,T/v)+"px"),t.hidden||(t.style.maxHeight=Math.max(1,L/v)+"px");let P=x==="above"?r.top-_:k.bottom+_;for(let I of i){let O=I.getBoundingClientRect(),V=I.offsetParent.getBoundingClientRect(),h=Math.max(c+12,Math.min(r.left+r.width/2-O.width/2,c+a-12-O.width)),A=x==="above"?P-O.height:P;I.style.left=(h-V.left)/v+"px",I.style.top=(A-V.top)/v+"px",I.style.bottom="auto",I.style.right="auto",P=x==="above"?A-_:A+O.height+_}e.hidden||(e.scrollTop=e.scrollHeight)}var Ce=()=>{let e=re?.text||z.text,t=p("bubble").hidden===!!e||p("text").textContent!==e;p("bubble").hidden=!e,p("bubble").dataset.input=String(!!re),p("keyboard").toggleAttribute("hidden",!re),p("text").textContent!==e&&(p("text").textContent=e),t&&ie()},fe=()=>{clearTimeout(be),re=null,Ce()},ut=()=>{for(let t of document.querySelectorAll("[data-mode]")){let i=z.mode===t.dataset.mode;t.disabled=!1,t.setAttribute("aria-pressed",String(i)),t.setAttribute("aria-busy",String(i&&!z.ready)),t.querySelector("[data-connecting-ring]").hidden=!(i&&!z.ready),t.setAttribute("aria-label",`${i?"\u5173\u95ED":"\u6253\u5F00"}${t.dataset.mode==="online"?"\u4EA4\u4E92\u6A21\u5F0F":"\u64AD\u62A5\u6A21\u5F0F"}`),t.title=i&&!z.ready?`\u6B63\u5728\u8FDE\u63A5${t.dataset.mode==="online"?"\u4EA4\u4E92\u6A21\u5F0F":"\u64AD\u62A5\u6A21\u5F0F"}`:t.getAttribute("aria-label")}p("dot").style.color=z.ready?"#7fd6a6":"#ed9b35";let e=z.mode==="off"?"\u8BED\u97F3\u672A\u5F00\u542F":z.ready?z.mode==="online"?"\u4EA4\u4E92\u6A21\u5F0F":"\u64AD\u62A5\u6A21\u5F0F":"\u6B63\u5728\u8FDE\u63A5\u2026";p("status").textContent!==e&&(p("status").textContent=e)},H=()=>{q||(q=!0,R.dispose(),Z.dispose(),Q.dispose(),Ke?.(),Ge?.(),clearInterval(pt),clearInterval(mt),clearTimeout(be),G?.update({...z,rms:0,text:""}),G?.dispose(),D.close(),U("hide_avatar").catch(()=>{}))},he,Te=()=>{X?N({type:"failed"}):ge&&N({type:"ready",protocol:2,...typeof he?.visible=="boolean"?{window_visible:he.visible,fullscreen_suppressed:he.fullscreen_suppressed===!0}:{}})},Qe=e=>(K=j(e),J||K===me?J||Promise.resolve():(J=(async()=>{for(await W;!q&&K!==me;){let t=K,i=!0,c=await U("set_avatar_size",{size:t,panel:i});if(!c||!Number.isFinite(c.scale)||c.scale<=0||c.scale>1)throw Error("invalid_avatar_layout");p("shell").style.transform=`scale(${c.fit??1})`,p("shell").dataset.panel=String(i),p("stage").dataset.size=t,p("stage").style.setProperty("--scale",c.scale),oe(p("size"),t),me=t,Q.refresh(),ie()}})().catch(()=>{X=!0,N({type:"failed"}),H()}).finally(()=>{J=null}),J));try{G=rt(p("avatar"),{modelURL:"./character.glb",onReady(){Promise.all([ct,Qe(K)]).then(async()=>{q||X||(he=await U("show_avatar"),!q&&(ge=!0,await ee(),!q&&Te()))}).catch(()=>{X=!0,N({type:"failed"}),H()})},onError(){X=!0,Te()}})}catch{X=!0}D.onopen=Te;var et=new ce(1e3);D.onmessage=e=>{et.touch();try{let t=JSON.parse(e.data);if(t.type==="shutdown")H();else if(t.type==="frame")z=Oe(t),Y=Date.now(),G?.update(z),Qe(z.size),z.mode==="off"&&fe(),Ce(),ut();else if(t.type==="input_effect")re=Ie(t),Y=Date.now(),clearTimeout(be),Ce(),be=setTimeout(fe,1600);else if(t.type==="clear_input_effect")fe();else if(t.type==="surface")dt.update(t),Y=Date.now();else if(t.type==="local_state")R.update(t),Xe=t.bubble,ie(),Y=Date.now(),t.toast&&t.toast!==We&&z.mode==="off"&&t.items.find(i=>i.id===t.toast)?.status==="completed"&&G?.update({...z,text:"\u5B8C\u6210\u4E86",utterance:"notice-"+t.toast}),We=t.toast;else if(t.type==="menu_result")R.result(t),Y=Date.now();else if(t.type==="owner_focus")U("remember_dsh").catch(()=>{}),Y=Date.now();else if(t.type!=="alive")throw Error("invalid_avatar_message")}catch{D.close(1008,"invalid_avatar_message")}};D.onclose=H;D.onerror=H;var pt=setInterval(()=>{if(et.expired()){H();return}Date.now()-Y>1500&&(G?.update({...z,rms:0,text:""}),z={...z,text:""},fe()),N({type:"alive"}),lt()},1e3),se=e=>{let t=e.getBoundingClientRect();return[t.x,t.y,t.width,t.height]};function ee(){if(!(!ge||J||q||document.hidden))return W?(Ae=!0,W):(W=(async()=>{do{if(Ae=!1,q||J||document.hidden)break;let e=Z.element?[se(Z.element)]:R.active?[[0,0,innerWidth,innerHeight]]:[...Q.regions(),...p("bubble").hidden?[]:[se(p("bubble"))],...p("surface").hidden?[]:[se(p("surface"))],...R.regions()];ze=G.hitMask(),await U("avatar_hit_mask",{mask:ze,avatar:se(p("avatar")),regions:e})}while(Ae)})().catch(()=>{}).finally(()=>{W=null}),W)}var mt=setInterval(()=>{W||ee()},350);for(let e of document.querySelectorAll("[data-mode]")){let t=document.createElement("span");t.dataset.connectingRing="",t.hidden=!0,t.innerHTML='<svg viewBox="0 0 30 30" preserveAspectRatio="none" aria-hidden="true"><rect x="1" y="1" width="28" height="28" rx="7" pathLength="100"/></svg>',e.append(t),e.onclick=()=>N({type:"mode",mode:e.dataset.mode})}p("close").onclick=async()=>{await Z.ask()&&!q&&(N({type:"hide"}),H())};p("size").onclick=()=>N({type:"size",size:ae(me||K)});var $=null;p("avatar").tabIndex=0;p("avatar").oncontextmenu=e=>{$=null,R.open(e)};p("avatar").onkeydown=e=>{(e.key==="ContextMenu"||e.key==="F10"&&e.shiftKey)&&($=null,R.open(e))};p("avatar").onpointerdown=e=>{e.button===0&&!e.ctrlKey&&!R.active&&($={x:e.clientX,y:e.clientY})};p("avatar").onpointermove=e=>{$&&!R.active&&e.buttons===1&&Math.hypot(e.clientX-$.x,e.clientY-$.y)>4&&($=null,U("drag_avatar").catch(()=>{}))};window.addEventListener("pointerup",()=>{$=null});window.addEventListener("blur",()=>{$=null});window.addEventListener("resize",()=>{ie(),ee()});window.addEventListener("pagehide",H,{once:!0});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"protocol": 2,
|
|
3
3
|
"files": {
|
|
4
4
|
"index.html": "28752006598f995ca6064318dfc0e15d2f0d4b94a3ee7aaf88a0adfec3de5b02",
|
|
5
|
-
"companion.mjs": "
|
|
5
|
+
"companion.mjs": "49c5fc795e9fcf344163a1e8e2c8074892472aa38ea0d8b32a0f91a7d3631411",
|
|
6
6
|
"renderer.mjs": "2cbfccca5c10ca2dc720461b3a9a2c5b59a5ef679210206869fa9159316b5650",
|
|
7
7
|
"character.glb": "4d39cf66e6ce8d389ec18884e2f4de0e142aa4a08d552f68d01d640ed5976471",
|
|
8
8
|
"portrait.png": "6d739465edf7d53f2b621c275a3486e9e8cfd8e363a5fae39792df59053268b4"
|
|
Binary file
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"schema": 2,
|
|
3
3
|
"protocol": 2,
|
|
4
4
|
"platform": "darwin-arm64",
|
|
5
|
-
"version": "0.3.
|
|
6
|
-
"sourceSha256": "
|
|
5
|
+
"version": "0.3.3",
|
|
6
|
+
"sourceSha256": "7a4c1760234ae4923fdda5a71874dac3c74ae1c49e61626d80a3096c99865069",
|
|
7
7
|
"executable": "duet-avatar.app/Contents/MacOS/duet-avatar",
|
|
8
8
|
"files": {
|
|
9
9
|
"duet-avatar.app/Contents/Info.plist": "ebdb818ab02ce11b372aec7962f1fca66680c49671d3a4986bb2c52118aedc71",
|
|
10
|
-
"duet-avatar.app/Contents/MacOS/duet-avatar": "
|
|
10
|
+
"duet-avatar.app/Contents/MacOS/duet-avatar": "22c8776797ad13192d0f457cf8f90eb7ed66b43fa3f0565e724e04665374e0ef",
|
|
11
11
|
"duet-avatar.app/Contents/Resources/duet companion.icns": "c0f7a8240eb31544f979513fdc90886512579b84b0ee3aa398c9205879ce0119",
|
|
12
12
|
"duet-avatar.app/Contents/_CodeSignature/CodeResources": "5cfa4150d7c2c81d73f019e2da679ae7722a25f1f5a94ffea76bdfc0fd3b282f"
|
|
13
13
|
}
|
|
Binary file
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"schema": 2,
|
|
3
3
|
"protocol": 2,
|
|
4
4
|
"platform": "win32-x64",
|
|
5
|
-
"version": "0.3.
|
|
6
|
-
"sourceSha256": "
|
|
5
|
+
"version": "0.3.3",
|
|
6
|
+
"sourceSha256": "7a4c1760234ae4923fdda5a71874dac3c74ae1c49e61626d80a3096c99865069",
|
|
7
7
|
"executable": "duet-avatar.exe",
|
|
8
8
|
"files": {
|
|
9
|
-
"duet-avatar.exe": "
|
|
9
|
+
"duet-avatar.exe": "ca380b9ffb101b0b7796658b905fff42ae5f94e02ddf3a6ccea01bafd2f6f463"
|
|
10
10
|
}
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-duet",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "duet(二重奏):只用语音就能操作 DSH,边听边说、随时插话的全双工语音助手。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh-plugin",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "node scripts/test.mjs",
|
|
24
24
|
"check": "node scripts/check-package.mjs",
|
|
25
|
-
"test:browser": "node tests/browser/entry-loading.mjs && node tests/browser/settings.mjs && node tests/browser/tutorial.mjs && node tests/browser/feedback.mjs && node tests/browser/connection-hint.mjs && node tests/browser/update-notice.mjs && node tests/browser/voices.mjs && node tests/browser/controls-layout.mjs && node tests/browser/resilience.mjs && node tests/browser/page-binding.mjs && node tests/browser/stop-task.mjs && node tests/browser/desktop-settings.mjs && node tests/browser/desktop-identity.mjs && node tests/browser/audio-interruption.mjs",
|
|
25
|
+
"test:browser": "node tests/browser/entry-loading.mjs && node tests/browser/settings.mjs && node tests/browser/tutorial.mjs && node tests/browser/feedback.mjs && node tests/browser/connection-hint.mjs && node tests/browser/update-notice.mjs && node tests/browser/voices.mjs && node tests/browser/controls-layout.mjs && node tests/browser/resilience.mjs && node tests/browser/page-binding.mjs && node tests/browser/stop-task.mjs && node tests/browser/desktop-settings.mjs && node tests/browser/desktop-identity.mjs && node tests/browser/audio-interruption.mjs && node tests/browser/agent-task-sidebar.mjs",
|
|
26
26
|
"test:work-mode": "node tests/browser/work-mode.mjs",
|
|
27
27
|
"test:agent-navigation": "node tests/browser/agent-tool-views.mjs && node tests/browser/work-mode.mjs && node tests/browser/agent-tasks.mjs",
|
|
28
28
|
"test:host": "node tests/host/isolated-host.mjs",
|
package/src/avatar/companion.mjs
CHANGED
|
@@ -117,7 +117,8 @@ const close=()=>{
|
|
|
117
117
|
model?.update({...frame,rms:0,text:''});model?.dispose();socket.close()
|
|
118
118
|
void invoke('hide_avatar').catch(()=>{})
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
let nativeVisibility
|
|
121
|
+
const notifyReady=()=>{if(failed)send({type:'failed'});else if(ready)send({type:'ready',protocol:AVATAR_UI_PROTOCOL,...(typeof nativeVisibility?.visible==='boolean'?{window_visible:nativeVisibility.visible,fullscreen_suppressed:nativeVisibility.fullscreen_suppressed===true}:{})})}
|
|
121
122
|
// Serialize native resize and hit-mask updates, including rapid preference changes.
|
|
122
123
|
// The owning page persists the preference; this window never opens a second store.
|
|
123
124
|
const requestSize=size=>{
|
|
@@ -139,7 +140,7 @@ const requestSize=size=>{
|
|
|
139
140
|
return sizePending
|
|
140
141
|
}
|
|
141
142
|
try{model=mountAvatarRenderer($('avatar'),{modelURL:'./character.glb',onReady(){
|
|
142
|
-
void Promise.all([pointerReady,requestSize(desiredSize)]).then(async()=>{if(closed||failed)return;ready=true;await refreshMask();if(closed)return;notifyReady()
|
|
143
|
+
void Promise.all([pointerReady,requestSize(desiredSize)]).then(async()=>{if(closed||failed)return;nativeVisibility=await invoke('show_avatar');if(closed)return;ready=true;await refreshMask();if(closed)return;notifyReady()})
|
|
143
144
|
.catch(()=>{failed=true;send({type:'failed'});close()})
|
|
144
145
|
},onError(){failed=true;notifyReady()}})}catch{failed=true}
|
|
145
146
|
socket.onopen=notifyReady
|
|
@@ -148,7 +149,8 @@ socket.onmessage=e=>{
|
|
|
148
149
|
liveness.touch()
|
|
149
150
|
try{
|
|
150
151
|
const message=JSON.parse(e.data)
|
|
151
|
-
if(message.type==='
|
|
152
|
+
if(message.type==='shutdown'){close()}
|
|
153
|
+
else if(message.type==='frame'){
|
|
152
154
|
frame=avatarFrame(message);last=Date.now();model?.update(frame);void requestSize(frame.size)
|
|
153
155
|
if(frame.mode==='off')clearInput();caption();controls()
|
|
154
156
|
}else if(message.type==='input_effect'){
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import {sidebarElement,clipToSidebar} from './sidebar-layout.mjs'
|
|
1
2
|
import {focusedSession,openLocalSession} from './composer.mjs'
|
|
2
3
|
import {taskBubbleCardStyle} from '../shared/avatar-ui.mjs'
|
|
3
|
-
import {TASK_STATES as states, noteTaskNoticeVisit, taskCardState, visibleTaskRows,
|
|
4
|
+
import {TASK_STATES as states, noteTaskNoticeVisit, taskCardState, visibleTaskRows, taskCompletionSeconds} from '../shared/work-mode.mjs'
|
|
4
5
|
const active=new Set(['queued','pending','running','progress','waiting','waiting_user','blocked'])
|
|
5
6
|
const bubbleCSS=`
|
|
7
|
+
[data-duet-agent-tasks][data-sidebar-tasks]{pointer-events:none}
|
|
8
|
+
[data-duet-agent-tasks][data-sidebar-tasks]::before{display:none}
|
|
9
|
+
[data-duet-agent-tasks][data-sidebar-tasks]>summary,[data-duet-agent-tasks][data-sidebar-tasks]>[data-task-list]{pointer-events:auto}
|
|
6
10
|
[data-duet-agent-tasks]{position:fixed;isolation:isolate;z-index:2147483599;margin:0;color:CanvasText;font:13px/1.35 -apple-system,BlinkMacSystemFont,system-ui,sans-serif}
|
|
7
11
|
[data-duet-agent-tasks] summary,[data-duet-agent-tasks] [data-task-list]{box-sizing:border-box;background:Canvas;border:1px solid color-mix(in srgb,CanvasText 12%,Canvas);box-shadow:0 8px 22px -7px #0003,0 1px 4px #0001}
|
|
8
12
|
[data-duet-agent-tasks] summary{position:relative;display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;column-gap:8px;padding:7px 15px;border-radius:24px;text-align:start;list-style:none;cursor:pointer;user-select:none}
|
|
@@ -20,7 +24,25 @@ const bubbleCSS=`
|
|
|
20
24
|
[data-duet-agent-tasks] [data-task-list]{background:transparent!important;border:0;box-shadow:none;padding:0;backdrop-filter:none!important;-webkit-backdrop-filter:none!important}
|
|
21
25
|
[data-duet-agent-tasks] [data-task-list] button{${taskBubbleCardStyle};margin-bottom:8px}
|
|
22
26
|
[data-duet-agent-tasks] [data-task-list] button span{font-size:13px;font-weight:550;line-height:1.5;overflow-wrap:anywhere}
|
|
27
|
+
[data-duet-agent-tasks][data-sidebar-tasks] summary{display:none}
|
|
28
|
+
[data-duet-agent-tasks][data-sidebar-tasks] [data-task-list]{position:relative;overflow:visible;max-height:none}
|
|
29
|
+
[data-duet-agent-tasks][data-sidebar-tasks] [data-task-list] button{position:absolute;left:0;top:var(--task-y);width:100%;height:72px;min-height:0;margin:0;padding:9px 10px;gap:7px;align-items:flex-start;border-radius:13px;background:#f4f8fc!important;backdrop-filter:none;box-shadow:0 3px 10px #243c5620;text-align:left;transition:box-shadow .18s}
|
|
30
|
+
[data-duet-agent-tasks][data-sidebar-tasks] [data-task-copy]{min-width:0;flex:1}
|
|
31
|
+
[data-duet-agent-tasks][data-sidebar-tasks] [data-task-name]{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:12px;line-height:18px}
|
|
32
|
+
[data-duet-agent-tasks][data-sidebar-tasks] [data-task-progress]{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;font-size:11px;line-height:16px;color:#617287;font-weight:400;margin-top:3px;white-space:pre-wrap}
|
|
33
|
+
[data-duet-agent-tasks][data-sidebar-tasks] [data-task-state]::before{margin-top:2px}
|
|
34
|
+
/* Keep the invisible anchor's geometry/hit area, so replacing it with the
|
|
35
|
+
detail does not move its neighbours or flicker between hover targets. */
|
|
36
|
+
[data-duet-agent-tasks][data-sidebar-tasks] button[data-expanded]{opacity:0;z-index:100!important}
|
|
37
|
+
[data-duet-task-detail]{position:fixed;z-index:2147483600;box-sizing:border-box;border-radius:16px;overflow:auto;box-shadow:0 10px 32px #243c5640;background:#fff;animation:duet-task-detail-in .16s ease-out}
|
|
38
|
+
[data-duet-task-detail]>button{${taskBubbleCardStyle};align-items:flex-start;border-radius:16px;background:#fff;backdrop-filter:none;box-shadow:none}
|
|
39
|
+
[data-duet-task-detail] [data-task-copy]{min-width:0;flex:1}
|
|
40
|
+
[data-duet-task-detail] [data-task-name]{display:block;font-size:13px;font-weight:600;white-space:normal;overflow-wrap:anywhere}
|
|
41
|
+
[data-duet-task-detail] [data-task-progress]{display:block;font-size:12px;line-height:1.6;color:#617287;white-space:pre-wrap;overflow-wrap:anywhere;margin-top:6px}
|
|
42
|
+
@keyframes duet-task-detail-in{from{opacity:0}to{opacity:1}}
|
|
43
|
+
@media(prefers-reduced-motion:reduce){[data-duet-task-detail]{animation:none}}
|
|
23
44
|
[data-task-state]::before{content:'';display:block;flex:0 0 18px;width:18px;height:18px;box-sizing:border-box;border:2px solid #62a0cd45;border-top-color:#468abf;border-radius:50%;animation:duet-task-spin 1s linear infinite}
|
|
45
|
+
[data-task-state=running]::before{flex:0 0 16px;width:16px;min-width:16px;max-width:16px;height:16px;min-height:16px;max-height:16px;padding:0;border:0;border-radius:0;box-sizing:content-box;background:center/16px 16px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='%23d8e8f5' stroke-width='2.4'/%3E%3Cpath d='M12 3a9 9 0 0 1 9 9' fill='none' stroke='%234c91c7' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");transform-origin:50% 50%;animation:duet-task-spin 1.1s linear infinite}
|
|
24
46
|
[data-task-state=completed]::before{content:'✓';border:0;background:#dcefe8;color:#23845e;text-align:center;font:600 14px/18px system-ui;animation:none}
|
|
25
47
|
[data-task-state=waiting]::before{content:'?';border:0;background:#fff0d9;color:#ad7523;text-align:center;font:600 13px/18px system-ui;animation:none}
|
|
26
48
|
[data-task-state=failed]::before,[data-task-state=stopped]::before{content:'!';border:0;background:#f8e3e3;color:#b45353;text-align:center;font:600 13px/18px system-ui;animation:none}
|
|
@@ -34,24 +56,60 @@ const bubbleCSS=`
|
|
|
34
56
|
|
|
35
57
|
/** A local, connection-owned projection; never turn the model's short handles into UI routes. */
|
|
36
58
|
export function agentTaskPanel(ctx,anchor,notice,presentation=()=>null){
|
|
37
|
-
let box,summary,title,statusLine,count,list,attempt,currentFrame,limit=50,lifecycle,resize,mutations,raf=0,tracked,timer
|
|
59
|
+
let box,summary,title,statusLine,count,list,attempt,currentFrame,limit=50,lifecycle,resize,mutations,raf=0,tracked,timer,releaseTaskLayout
|
|
38
60
|
let countdowns=[]
|
|
61
|
+
let detail,detailSource,detailTimer,suppressedDetail
|
|
62
|
+
function closeDetail(){
|
|
63
|
+
clearTimeout(detailTimer);detail?.remove();detail=null
|
|
64
|
+
detailSource?.removeAttribute('data-expanded');detailSource?.removeAttribute('aria-expanded');detailSource=null
|
|
65
|
+
}
|
|
66
|
+
const laterClose=()=>{clearTimeout(detailTimer);detailTimer=setTimeout(closeDetail,140)}
|
|
67
|
+
function showDetail(button){
|
|
68
|
+
if(!box?.hasAttribute('data-sidebar-tasks'))return
|
|
69
|
+
if(suppressedDetail===button)return
|
|
70
|
+
clearTimeout(detailTimer)
|
|
71
|
+
if(detailSource===button&&detail)return
|
|
72
|
+
closeDetail();detailSource=button;button.dataset.expanded='';button.setAttribute('aria-expanded','true')
|
|
73
|
+
const a=button.getBoundingClientRect()
|
|
74
|
+
detail=document.createElement('div');detail.dataset.duetTaskDetail=''
|
|
75
|
+
detail.setAttribute('role','region');detail.setAttribute('aria-label','任务最新进度')
|
|
76
|
+
// Lay out one separate card at its final width. Fade opacity only: no
|
|
77
|
+
// animated width or per-frame text wrapping, and never move over the pet.
|
|
78
|
+
const x=Math.min(innerWidth-48,a.left),width=Math.max(40,Math.min(320,innerWidth-x-8))
|
|
79
|
+
Object.assign(detail.style,{left:x+'px',width:width+'px',maxHeight:Math.min(360,innerHeight-16)+'px'})
|
|
80
|
+
const copy=button.cloneNode(true);copy.removeAttribute('data-expanded');copy.removeAttribute('aria-expanded');copy.removeAttribute('style');copy.title=''
|
|
81
|
+
copy.onclick=()=>button.click();detail.append(copy);document.body.append(detail)
|
|
82
|
+
detail.style.top=Math.max(8,Math.min(a.top,innerHeight-detail.offsetHeight-8))+'px'
|
|
83
|
+
detail.onpointerenter=()=>clearTimeout(detailTimer);detail.onpointerleave=laterClose
|
|
84
|
+
detail.onfocusin=()=>clearTimeout(detailTimer);detail.onfocusout=laterClose
|
|
85
|
+
}
|
|
39
86
|
function reset(){
|
|
87
|
+
closeDetail();suppressedDetail=null
|
|
88
|
+
releaseTaskLayout?.(false);releaseTaskLayout=null
|
|
40
89
|
clearInterval(timer);timer=null;countdowns=[]
|
|
41
90
|
attempt?.abort();lifecycle?.abort();resize?.disconnect();mutations?.disconnect();cancelAnimationFrame(raf)
|
|
42
91
|
box?.remove();box=null;currentFrame=null;tracked=null;raf=0;limit=50
|
|
43
92
|
}
|
|
44
93
|
function place(){
|
|
45
|
-
if(!box
|
|
46
|
-
const view=presentation(),
|
|
94
|
+
if(!box)return
|
|
95
|
+
const view=presentation(),web=location.protocol!=='dsh-app:'&&!view?.native&&!['desktop','connecting','recovering','other'].includes(view?.mode)
|
|
96
|
+
releaseTaskLayout=view?.taskLayout??releaseTaskLayout
|
|
97
|
+
releaseTaskLayout?.(web&&!box.hidden)
|
|
98
|
+
if(box.hidden)return
|
|
99
|
+
const pet=view?.anchor,stage=pet?.querySelector('[data-duet-avatar-stage]')||pet
|
|
100
|
+
const sidebar=web?sidebarElement(anchor()):null,bounds=sidebar?.getBoundingClientRect()
|
|
101
|
+
box.toggleAttribute('data-sidebar-tasks',Boolean(bounds))
|
|
102
|
+
clipToSidebar(summary,null);clipToSidebar(list,null)
|
|
47
103
|
// Native presentation is projected through avatar-surfaces, not positioned
|
|
48
104
|
// against the DSH toolbar. Keep it off-page during desktop reconnects too.
|
|
49
105
|
if(view?.native || ['desktop','connecting','recovering','other'].includes(view?.mode)){
|
|
106
|
+
closeDetail()
|
|
107
|
+
if(box.hasAttribute('data-inline')&&list.querySelectorAll('button[data-task-state]').length>3){box.removeAttribute('data-inline');summary.hidden=false;box.open=false}
|
|
50
108
|
box.style.visibility='hidden';return
|
|
51
109
|
}
|
|
52
110
|
const target=stage?.isConnected && stage.getBoundingClientRect().height?stage:anchor()
|
|
53
111
|
if(!target?.isConnected){box.style.visibility='hidden';return}
|
|
54
|
-
if(target!==tracked){resize.disconnect();resize.observe(target);tracked=target}
|
|
112
|
+
if(target!==tracked){resize.disconnect();resize.observe(target);if(sidebar&&sidebar!==target)resize.observe(sidebar);tracked=target}
|
|
55
113
|
const a=target.getBoundingClientRect(), gap=8
|
|
56
114
|
if(!a.width||!a.height){box.style.visibility='hidden';return}
|
|
57
115
|
box.style.visibility='visible'
|
|
@@ -63,10 +121,34 @@ export function agentTaskPanel(ctx,anchor,notice,presentation=()=>null){
|
|
|
63
121
|
const inline=box.hasAttribute('data-inline')
|
|
64
122
|
if(inline)box.style.width=Math.min(innerWidth-2*gap,width)+'px';else box.style.width=''
|
|
65
123
|
const card=inline?box:summary
|
|
66
|
-
const
|
|
67
|
-
const
|
|
124
|
+
const hasPet=target===stage
|
|
125
|
+
const left=clamp(bounds&&!hasPet?bounds.left+gap:a.right+gap,innerWidth-card.offsetWidth)
|
|
126
|
+
const top=clamp(bounds&&!hasPet?a.top-card.offsetHeight-gap:a.top+(a.height-card.offsetHeight)/2,innerHeight-card.offsetHeight)
|
|
68
127
|
Object.assign(box.style,{left:left+'px',top:top+'px'})
|
|
69
|
-
if(
|
|
128
|
+
if(bounds){
|
|
129
|
+
if(!box.hasAttribute('data-inline')){box.setAttribute('data-inline','');summary.hidden=true;box.open=true}
|
|
130
|
+
// Keep every task reachable in a bounded fan. Hover changes only its layer,
|
|
131
|
+
// not its neighbours' positions, so moving between tasks stays predictable.
|
|
132
|
+
const buttons=[...list.children].filter(e=>e.matches('button[data-task-state]'))
|
|
133
|
+
const step=Math.min(52,(Math.min(270,innerHeight*.36)-72)/Math.max(1,buttons.length-1))
|
|
134
|
+
const height=72+Math.max(0,buttons.length-1)*step
|
|
135
|
+
// The portrait viewport contains transparent side gutters. Cards may
|
|
136
|
+
// overlap that gutter, while the central body remains unobstructed.
|
|
137
|
+
const x=hasPet?Math.max(bounds.left+gap,a.left+a.width*.82+gap):bounds.left+gap
|
|
138
|
+
const w=Math.min(180,Math.max(40,bounds.right-x-gap))
|
|
139
|
+
const toolbar=anchor()?.getBoundingClientRect()
|
|
140
|
+
const bottom=Math.min(innerHeight-gap,toolbar?.top>height+gap?toolbar.top-gap:innerHeight-gap)
|
|
141
|
+
const y=Math.max(gap,Math.min(hasPet?a.top+(a.height-height)/2:a.top-height-gap,bottom-height))
|
|
142
|
+
Object.assign(box.style,{left:x+'px',top:y+'px',width:w+'px'})
|
|
143
|
+
Object.assign(list.style,{width:'100%',height:height+'px',left:'',top:'',bottom:'',maxHeight:'none'})
|
|
144
|
+
buttons.forEach((button,i)=>{
|
|
145
|
+
button.style.setProperty('--task-y',i*step+'px');button.style.zIndex=String(i+1)
|
|
146
|
+
})
|
|
147
|
+
return
|
|
148
|
+
}
|
|
149
|
+
list.style.height=''
|
|
150
|
+
if(inline){Object.assign(list.style,{width:'100%',left:'',top:'',bottom:'',maxHeight:'65vh'});clipToSidebar(list,bounds);return}
|
|
151
|
+
clipToSidebar(summary,bounds)
|
|
70
152
|
if(!box.open)return
|
|
71
153
|
list.style.width=Math.min(264,innerWidth-left-gap)+'px'
|
|
72
154
|
const below=innerHeight-top-summary.offsetHeight-2*gap,above=top-2*gap
|
|
@@ -74,6 +156,7 @@ export function agentTaskPanel(ctx,anchor,notice,presentation=()=>null){
|
|
|
74
156
|
Object.assign(list.style,{left:clamp(left,innerWidth-list.offsetWidth)+'px',
|
|
75
157
|
top:up?'auto':top+summary.offsetHeight+gap+'px',bottom:up?innerHeight-top+gap+'px':'auto',
|
|
76
158
|
maxHeight:Math.max(32,Math.min(innerHeight*.46,up?above:below))+'px'})
|
|
159
|
+
clipToSidebar(list,bounds)
|
|
77
160
|
}
|
|
78
161
|
function schedule(){if(!raf)raf=requestAnimationFrame(()=>{raf=0;place()})}
|
|
79
162
|
function tick(){
|
|
@@ -129,14 +212,22 @@ export function agentTaskPanel(ctx,anchor,notice,presentation=()=>null){
|
|
|
129
212
|
list=document.createElement('div');list.dataset.taskList=''
|
|
130
213
|
box.append(summary,list,style);document.body.append(box)
|
|
131
214
|
lifecycle=new AbortController();const {signal}=lifecycle
|
|
132
|
-
resize=new ResizeObserver(schedule);mutations=new MutationObserver(schedule)
|
|
133
|
-
mutations.observe(
|
|
134
|
-
window.addEventListener('resize',schedule,{signal});document.addEventListener('scroll',schedule,{signal,capture:true,passive:true})
|
|
215
|
+
resize=new ResizeObserver(schedule);mutations=new MutationObserver(records=>{if(records.some(r=>!box?.contains(r.target)))schedule()})
|
|
216
|
+
mutations.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:['class','style','hidden']})
|
|
217
|
+
window.addEventListener('resize',()=>{closeDetail();schedule()},{signal});document.addEventListener('scroll',e=>{if(!detail?.contains(e.target)){closeDetail();schedule()}},{signal,capture:true,passive:true})
|
|
135
218
|
window.addEventListener('duet:avatar-presentation',schedule,{signal})
|
|
136
219
|
box.addEventListener('toggle',place,{signal})
|
|
137
|
-
document.addEventListener('pointerdown',e=>{if(box.open&&!box.hasAttribute('data-inline')&&!box.contains(e.target))box.open=false},{signal,capture:true})
|
|
220
|
+
document.addEventListener('pointerdown',e=>{if(!presentation()?.native&&box.open&&!box.hasAttribute('data-inline')&&!box.contains(e.target))box.open=false},{signal,capture:true})
|
|
138
221
|
document.addEventListener('keydown',e=>{if(box.open&&!box.hasAttribute('data-inline')&&e.key==='Escape'){box.open=false;summary.focus()}},{signal})
|
|
222
|
+
document.addEventListener('keydown',e=>{if(e.key==='Escape'){suppressedDetail=detailSource;closeDetail()}},{signal})
|
|
223
|
+
document.addEventListener('pointermove',e=>{
|
|
224
|
+
if(!suppressedDetail)return
|
|
225
|
+
const r=suppressedDetail.getBoundingClientRect()
|
|
226
|
+
if(e.clientX<r.left||e.clientX>r.right||e.clientY<r.top||e.clientY>r.bottom)suppressedDetail=null
|
|
227
|
+
},{signal,passive:true})
|
|
228
|
+
document.addEventListener('pointerdown',e=>{if(!box.contains(e.target)&&!detail?.contains(e.target))closeDetail()},{signal,capture:true})
|
|
139
229
|
}
|
|
230
|
+
closeDetail()
|
|
140
231
|
currentFrame=frame
|
|
141
232
|
const candidates=frame.rows.filter(r=>r && /^worker-[a-f0-9]{32}$/.test(r.session_id))
|
|
142
233
|
const id=focusedSession(ctx)
|
|
@@ -155,7 +246,8 @@ export function agentTaskPanel(ctx,anchor,notice,presentation=()=>null){
|
|
|
155
246
|
summary.setAttribute('aria-label',['代理任务',title.textContent,statusLine.textContent,count.textContent].join(','))
|
|
156
247
|
box.toggleAttribute('data-stacked',rows.length>1)
|
|
157
248
|
box.hidden=!rows.length
|
|
158
|
-
const
|
|
249
|
+
const view=presentation(),web=location.protocol!=='dsh-app:'&&!view?.native&&!['desktop','connecting','recovering','other'].includes(view?.mode)
|
|
250
|
+
const inline=web||rows.length<=3,wasInline=box.hasAttribute('data-inline')
|
|
159
251
|
box.toggleAttribute('data-inline',inline);summary.hidden=inline
|
|
160
252
|
if(inline)box.open=true;else if(wasInline)box.open=false
|
|
161
253
|
if(box.hidden)box.open=false
|
|
@@ -164,14 +256,20 @@ export function agentTaskPanel(ctx,anchor,notice,presentation=()=>null){
|
|
|
164
256
|
if(!rows.length)list.textContent='还没有任务'
|
|
165
257
|
for(const r of rows.slice(0,limit)){
|
|
166
258
|
const button=document.createElement('button');button.type='button'
|
|
167
|
-
const label=document.createElement('span');label.dataset.taskCopy=''
|
|
168
|
-
const
|
|
169
|
-
|
|
259
|
+
const label=document.createElement('span');label.dataset.taskCopy=''
|
|
260
|
+
const name=document.createElement('span');name.dataset.taskName='';name.textContent=r.name||'未命名任务'
|
|
261
|
+
const progress=document.createElement('small');progress.dataset.taskProgress=''
|
|
262
|
+
progress.textContent=typeof r.progress==='string'&&r.progress.trim()?r.progress:(states[r.state]||'状态待确认')+' · 暂无进度更新'
|
|
263
|
+
progress.style.cssText='font-size:11px;font-weight:400;overflow-wrap:anywhere'
|
|
170
264
|
button.dataset.taskState=taskCardState(r)
|
|
171
|
-
button.title=
|
|
265
|
+
button.title=name.textContent+' · '+(states[r.state]||'状态待确认')+' · '+progress.textContent
|
|
172
266
|
button.setAttribute('aria-label',button.title)
|
|
173
|
-
label.append(document.createTextNode('\n'),
|
|
267
|
+
label.append(name,document.createTextNode('\n'),progress)
|
|
174
268
|
button.append(label)
|
|
269
|
+
const expand=()=>showDetail(button)
|
|
270
|
+
button.onpointerenter=expand;button.onfocus=expand
|
|
271
|
+
button.onpointerleave=laterClose
|
|
272
|
+
button.onblur=laterClose
|
|
175
273
|
const seconds=taskCompletionSeconds(r)
|
|
176
274
|
if(seconds!==null){
|
|
177
275
|
const countdown=document.createElement('small');countdown.dataset.taskCountdownLabel=''
|
package/src/client/audio.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { microphoneConstraints } from './microphone.mjs?v=0.3.
|
|
1
|
+
import { microphoneConstraints } from './microphone.mjs?v=0.3.3'
|
|
2
2
|
import { captionCue, captionAt, AudioCaptionTimeline } from '../shared/avatar.mjs'
|
|
3
3
|
|
|
4
4
|
export const AUDIO_STOP_PROTOCOL = 'audio_stop_candidates_v1'
|
package/src/client/avatar.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { avatarCloseConfirmation } from '../shared/avatar-ui.mjs'
|
|
|
7
7
|
import {mountAvatarMenu} from '../shared/avatar-menu-ui.mjs'
|
|
8
8
|
import {avatarLocalState,avatarMenuResult,noticePreferences} from '../shared/avatar-menu.mjs'
|
|
9
9
|
import {AvatarActivityClock,avatarGeometry} from '../shared/avatar-activity.mjs'
|
|
10
|
+
import {sidebarBounds} from './sidebar-layout.mjs'
|
|
10
11
|
|
|
11
12
|
/** Page-bound presentation. The native helper cannot acquire its own voice session. */
|
|
12
13
|
export function mountAvatar({controls, audio, state, notice, requestMode, onSurfaceAction=()=>{}, onMenuAction=()=>{}, focusedSession=()=>null}) {
|
|
@@ -16,6 +17,7 @@ export function mountAvatar({controls, audio, state, notice, requestMode, onSurf
|
|
|
16
17
|
let forceWebOnly=false,configLoaded=false
|
|
17
18
|
let menu,localState,lastNotice,retryTimer,connectTimer,reconnect,retryCount=0,presentationMode='off'
|
|
18
19
|
let desktopPosition=null,activityStartTimer
|
|
20
|
+
let taskCards=false
|
|
19
21
|
const activity=new AvatarActivityClock({snapshot:()=>{
|
|
20
22
|
const p=noticePreferences(),r=root?.getBoundingClientRect(),screen=window.screen
|
|
21
23
|
const position=native?desktopPosition:r?avatarGeometry({space:'viewport_css',total_resolution:{width:screen.width,height:screen.height},viewport_resolution:{width:innerWidth,height:innerHeight},avatar_position:{x:r.x,y:r.y,width:r.width,height:r.height}}):null
|
|
@@ -47,6 +49,8 @@ export function mountAvatar({controls, audio, state, notice, requestMode, onSurf
|
|
|
47
49
|
}
|
|
48
50
|
const place=()=>{
|
|
49
51
|
if(!root)return
|
|
52
|
+
const taskLayout=taskCards&&location.protocol!=='dsh-app:'&&!native
|
|
53
|
+
root.toggleAttribute('data-duet-task-layout',taskLayout)
|
|
50
54
|
const c=controls(),r=c?.getBoundingClientRect()
|
|
51
55
|
root.hidden=!r||c.dataset.compact==='true'
|
|
52
56
|
// Insert a sibling between DSH's scrollable workspace region and its footer.
|
|
@@ -61,7 +65,9 @@ export function mountAvatar({controls, audio, state, notice, requestMode, onSurf
|
|
|
61
65
|
const scale=Math.min(avatarScale(prefs.size),width/180,innerHeight*.32/210)
|
|
62
66
|
root.dataset.size=prefs.size
|
|
63
67
|
root.style.cssText='position:relative;flex:0 0 auto;align-self:stretch;min-width:0;display:flex;flex-direction:column;align-items:center;pointer-events:none'
|
|
64
|
-
|
|
68
|
+
if(taskLayout)root.style.alignItems='flex-start'
|
|
69
|
+
// Move the unchanged viewport, not its camera/aspect or selected size.
|
|
70
|
+
stage.style.cssText=`position:relative;width:${width}px;max-width:100%;height:${210*scale}px;transform:translateX(${taskLayout?-width*.22:0}px)`
|
|
65
71
|
caption.style.position='relative';caption.style.bottom='auto';caption.style.left='auto';caption.style.right='auto'
|
|
66
72
|
caption.style.width='calc(100% - 16px)';caption.style.maxHeight=`min(${{small:90,medium:180,large:260}[noticePreferences().bubble]}px,16vh)`
|
|
67
73
|
caption.style.order='-1';if(!caption.hidden)caption.scrollTop=caption.scrollHeight
|
|
@@ -74,6 +80,12 @@ export function mountAvatar({controls, audio, state, notice, requestMode, onSurf
|
|
|
74
80
|
root.dataset.size=prefs.size;root.style.width=`${width}px`;root.style.height=`${height}px`
|
|
75
81
|
root.style.left=`${Math.max(8,Math.min(innerWidth-width-8,r.left))}px`;root.style.top=`${top}px`
|
|
76
82
|
stage.style.width=`${base}px`;stage.style.transform=`scale(${scale})`
|
|
83
|
+
stage.style.height='210px'
|
|
84
|
+
if(taskLayout){
|
|
85
|
+
const side=sidebarBounds(c)
|
|
86
|
+
if(side)root.style.left=`${side.left+8}px`
|
|
87
|
+
stage.style.transform=`translateX(${-width*.22}px) scale(${scale})`
|
|
88
|
+
}
|
|
77
89
|
const bubbleWidth=Math.min(base-8,innerWidth-16),left=parseFloat(root.style.left)
|
|
78
90
|
caption.style.width=`${bubbleWidth}px`;caption.style.left=`${Math.max(8,Math.min(innerWidth-bubbleWidth-8,left+width/2-bubbleWidth/2))-left}px`
|
|
79
91
|
caption.style.maxHeight=`${Math.max(30,Math.min({small:90,medium:180,large:260}[noticePreferences().bubble],top-18))}px`
|
|
@@ -214,7 +226,8 @@ export function mountAvatar({controls, audio, state, notice, requestMode, onSurf
|
|
|
214
226
|
.then(r=>r.ok?r.json():{}).then(config=>{forceWebOnly=config.avatar?.web_only===true})
|
|
215
227
|
.catch(()=>{}).finally(()=>{clearTimeout(configTimeout);configLoaded=true;if(!dead)start()})
|
|
216
228
|
return {
|
|
217
|
-
presentation(){return {native,mode:presentationMode,anchor:root&&!root.hidden?root:null
|
|
229
|
+
presentation(){return {native,mode:presentationMode,anchor:root&&!root.hidden?root:null,
|
|
230
|
+
taskLayout(value){const next=value===true&&location.protocol!=='dsh-app:'&&!native;if(next!==taskCards){taskCards=next;place()}}}},
|
|
218
231
|
surface(value){return native&&send(value)},
|
|
219
232
|
syncToggle,
|
|
220
233
|
setSize,
|