@zhin.js/adapter-sandbox 2.0.13 → 2.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @zhin.js/adapter-process
2
2
 
3
+ ## 2.0.14
4
+
5
+ ### Patch Changes
6
+
7
+ - abc75a4: fix: 优化,客户端构建优化
8
+ - Updated dependencies [abc75a4]
9
+ - @zhin.js/console@2.0.14
10
+
3
11
  ## 2.0.13
4
12
 
5
13
  ### Patch Changes
package/dist/index.js ADDED
@@ -0,0 +1,45 @@
1
+ import Ve,{useState as C,useEffect as Ie,useRef as we}from"react";import{cn as M,resolveMediaSrc as Pe,pickMediaRawUrl as ye}from"@zhin.js/client";import{forwardRef as da,createElement as ua}from"react";var Le=(...m)=>m.filter((L,h,x)=>!!L&&L.trim()!==""&&x.indexOf(L)===h).join(" ").trim();var Te=m=>m.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();var qe=m=>m.replace(/^([A-Z])|[\s-_]+(\w)/g,(L,h,x)=>x?x.toUpperCase():h.toLowerCase());var ke=m=>{let L=qe(m);return L.charAt(0).toUpperCase()+L.slice(1)};import{forwardRef as oa,createElement as Oe}from"react";var xe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var Ue=m=>{for(let L in m)if(L.startsWith("aria-")||L==="role"||L==="title")return!0;return!1};import{createContext as ea,useContext as aa,useMemo as Oa,createElement as Na}from"react";var ta=ea({});var He=()=>aa(ta);var Ne=oa(({color:m,size:L,strokeWidth:h,absoluteStrokeWidth:x,className:N="",children:D,iconNode:g,...p},w)=>{let{size:F=24,strokeWidth:b=2,absoluteStrokeWidth:K=!1,color:E="currentColor",className:Z=""}=He()??{},H=x??K?Number(h??b)*24/Number(L??F):h??b;return Oe("svg",{ref:w,...xe,width:L??F??xe.width,height:L??F??xe.height,stroke:m??E,strokeWidth:H,className:Le("lucide",Z,N),...!D&&!Ue(p)&&{"aria-hidden":"true"},...p},[...g.map(([B,P])=>Oe(B,P)),...Array.isArray(D)?D:[D]])});var r=(m,L)=>{let h=da(({className:x,...N},D)=>ua(Ne,{ref:D,iconNode:L,className:Le(`lucide-${Te(ke(m))}`,`lucide-${m}`,x),...N}));return h.displayName=ke(m),h};var la=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],V=r("bell",la);var sa=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],ee=r("bot",sa);var ra=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ae=r("check",ra);var fa=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],te=r("hash",fa);var ia=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],oe=r("image",ia);var ca=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],de=r("info",ca);var na=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],O=r("message-square",na);var pa=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],ue=r("music",pa);var ma=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],j=r("search",ma);var La=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],le=r("send",La);var xa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],se=r("smile",xa);var Ia=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],re=r("trash-2",Ia);var Ca=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],z=r("user-plus",Ca);var ga=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],X=r("user",ga);var ha=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],fe=r("users",ha);var Sa=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],ie=r("video",Sa);var ka=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ce=r("wifi-off",ka);var wa=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],ne=r("wifi",wa);var Pa=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],pe=r("x",Pa);import{useRef as Ee,forwardRef as ya,useImperativeHandle as Aa}from"react";import{jsx as Ma}from"react/jsx-runtime";var Ge=ya(({placeholder:m="\u8F93\u5165\u6D88\u606F...",onSend:L,onChange:h,onAtTrigger:x,minHeight:N="44px",maxHeight:D="200px"},g)=>{let p=Ee(null),w=Ee(null),F=()=>{if(!p.current)return{text:"",segments:[]};let d="",t=[],u=Array.from(p.current.childNodes);for(let c of u)if(c.nodeType===Node.TEXT_NODE){let l=c.textContent||"";l&&(d+=l,t.push({type:"text",data:{text:l}}))}else if(c.nodeType===Node.ELEMENT_NODE){let l=c;if(l.classList.contains("editor-face")){let n=l.dataset.id;d+=`[face:${n}]`,t.push({type:"face",data:{id:Number(n)}})}else if(l.classList.contains("editor-image")){let n=l.dataset.url;d+=`[image:${n}]`,t.push({type:"image",data:{url:n}})}else if(l.classList.contains("editor-video")){let n=l.dataset.url||"";d+=`[video:${n}]`,t.push({type:"video",data:{url:n}})}else if(l.classList.contains("editor-audio")){let n=l.dataset.url||"";d+=`[audio:${n}]`,t.push({type:"audio",data:{url:n}})}else if(l.classList.contains("editor-at")){let n=l.dataset.name,A=l.dataset.id;d+=`[@${n}]`,t.push({type:"at",data:{name:n,qq:A}})}else l.tagName==="BR"&&(d+=`
2
+ `)}return{text:d,segments:t}},b=d=>{if(!p.current)return;let t=document.createElement("img");t.src=`https://face.viki.moe/apng/${d}.png`,t.alt=`[face:${d}]`,t.dataset.type="face",t.dataset.id=String(d),t.className="editor-face",B(t),v()},K=d=>{if(!p.current||!d.trim())return;let t=document.createElement("img");t.src=d.trim(),t.alt=`[image:${d.trim()}]`,t.dataset.type="image",t.dataset.url=d.trim(),t.className="editor-image",B(t),v()},E=d=>{if(!p.current||!d.trim())return;let t=d.trim(),u=document.createElement("span");u.className="editor-video",u.dataset.url=t,u.contentEditable="false",u.textContent="\u{1F4F9} \u89C6\u9891",B(u),v()},Z=d=>{if(!p.current||!d.trim())return;let t=d.trim(),u=document.createElement("span");u.className="editor-audio",u.dataset.url=t,u.contentEditable="false",u.textContent="\u{1F3B5} \u97F3\u9891",B(u),v()},H=(d,t)=>{if(!p.current||!d.trim())return;let u=document.createElement("span");u.dataset.type="at",u.dataset.name=d,t&&(u.dataset.id=t),u.className="editor-at",u.contentEditable="false";let c=document.createElement("span");c.textContent="@",c.className="editor-at-symbol";let l=document.createElement("span");l.textContent=d,l.className="editor-at-name",u.appendChild(c),u.appendChild(l),B(u),v()},B=d=>{if(!p.current)return;p.current.focus();let t=window.getSelection();if(t&&t.rangeCount>0){let u=t.getRangeAt(0);if(p.current.contains(u.commonAncestorContainer))u.deleteContents(),u.insertNode(d),u.collapse(!1),t.removeAllRanges(),t.addRange(u);else{p.current.appendChild(d);let l=document.createRange();l.setStartAfter(d),l.collapse(!0),t.removeAllRanges(),t.addRange(l)}}else{p.current.appendChild(d);let u=window.getSelection();if(u){let c=document.createRange();c.setStartAfter(d),c.collapse(!0),u.removeAllRanges(),u.addRange(c)}}},P=()=>{p.current&&(p.current.innerHTML="",v())},G=()=>{p.current?.focus()},$=()=>F(),me=()=>{if(!p.current||!x)return;let d=window.getSelection();if(!d||d.rangeCount===0){x(!1,""),w.current=null;return}let t=d.getRangeAt(0);if(!p.current.contains(t.commonAncestorContainer)){x(!1,""),w.current=null;return}let u=t.startContainer;if(u.nodeType!==Node.TEXT_NODE){x(!1,""),w.current=null;return}let c=u,l=c.textContent?.substring(0,t.startOffset)||"",n=l.lastIndexOf("@");if(n!==-1){let A=l.substring(n+1);if(A.includes(" ")||A.includes(`
3
+ `)){x(!1,""),w.current=null;return}w.current=c;let W=document.createRange();W.setStart(c,n),W.setEnd(c,n+1);let T=W.getBoundingClientRect(),R=p.current.getBoundingClientRect();x(!0,A,{top:T.bottom-R.top,left:T.left-R.left})}else x(!1,""),w.current=null},v=()=>{if(me(),h){let{text:d,segments:t}=F();h(d,t)}},Ce=(d,t)=>{if(!w.current)return;let u=w.current,c=u.textContent||"",l=c.lastIndexOf("@");if(l!==-1){let n=c.substring(l+1),A=l+1+n.split(/[\s\n]/)[0].length,W=c.substring(0,l),T=c.substring(A);u.textContent=W+T;let R=window.getSelection();if(R){let q=document.createRange();q.setStart(u,l),q.collapse(!0),R.removeAllRanges(),R.addRange(q)}}w.current=null,H(d,t)},Y=d=>{d.preventDefault();let t=d.clipboardData,c=Array.from(t.items).find(n=>n.type.startsWith("image/"));if(c){let n=c.getAsFile();if(n){let A=new FileReader;A.onload=()=>{typeof A.result=="string"&&K(A.result)},A.readAsDataURL(n)}return}let l=t.getData("text/plain");l&&(document.execCommand("insertText",!1,l),v())},Q=d=>{if(d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),L)){let{text:t,segments:u}=F();L(t,u)}};return Aa(g,()=>({focus:G,clear:P,insertFace:b,insertImage:K,insertVideo:E,insertAudio:Z,insertAt:H,replaceAtTrigger:Ce,getContent:$})),Ma("div",{ref:p,contentEditable:!0,suppressContentEditableWarning:!0,onInput:v,onKeyDown:Q,onPaste:Y,"data-placeholder":m,className:"rich-text-editor",style:{width:"100%",minHeight:N,maxHeight:D,padding:"0.5rem 0.75rem",border:"1px solid var(--gray-6)",borderRadius:"6px",backgroundColor:"var(--gray-1)",fontSize:"var(--font-size-2)",outline:"none",overflowY:"auto",lineHeight:"1.5",wordWrap:"break-word",color:"var(--gray-12)"}})});Ge.displayName="RichTextEditor";var We=Ge;import{Fragment as Ba,jsx as e,jsxs as o}from"react/jsx-runtime";function Ae(){let[m,L]=C([]),[h,x]=C([{id:"user_1001",name:"\u6D4B\u8BD5\u7528\u6237",type:"private",unread:0},{id:"group_2001",name:"\u6D4B\u8BD5\u7FA4\u7EC4",type:"group",unread:0},{id:"channel_3001",name:"\u6D4B\u8BD5\u9891\u9053",type:"channel",unread:0}]),[N,D]=C([]),[g,p]=C(h[0]),[w,F]=C(""),[b,K]=C("ProcessBot"),[E,Z]=C(!1),[H,B]=C(!1),[P,G]=C(null),[$,me]=C(""),[v,Ce]=C(!1),[Y,Q]=C(null),[d,t]=C(""),[u,c]=C(""),[l,n]=C(""),[A]=C([{id:"10001",name:"\u5F20\u4E09"},{id:"10002",name:"\u674E\u56DB"},{id:"10003",name:"\u738B\u4E94"},{id:"10004",name:"\u8D75\u516D"},{id:"10005",name:"\u6D4B\u8BD5\u7528\u6237"},{id:"10086",name:"Admin"},{id:"10010",name:"Test User"}]),[W,T]=C([]),[R,q]=C(!1),[_,ge]=C("chat"),Me=we(null),J=we(null),U=we(null),ze=async()=>{try{let a=await fetch("https://face.viki.moe/metadata.json");D(await a.json())}catch(a){console.error("[Sandbox] Failed to fetch face list:",a)}};Ie(()=>{ze()},[]),Ie(()=>{let a=window.location.protocol==="https:"?"wss:":"ws:";return J.current=new WebSocket(`${a}//${window.location.host}/sandbox`),J.current.onopen=()=>Z(!0),J.current.onmessage=f=>{try{let s=JSON.parse(f.data),I=typeof s.content=="string"?he(s.content):Array.isArray(s.content)?s.content:he(String(s.content)),i=h.find(y=>y.id===s.id);if(!i){let y=s.type==="private"?`\u79C1\u804A-${s.bot||b}`:s.type==="group"?`\u7FA4\u7EC4-${s.id}`:`\u9891\u9053-${s.id}`;i={id:s.id,name:y,type:s.type,unread:0},x(k=>[...k,i]),p(i)}let S={id:`bot_${s.timestamp}`,type:"received",channelType:s.type,channelId:s.id,channelName:i.name,senderId:"bot",senderName:s.bot||b,content:I,timestamp:s.timestamp};L(y=>[...y,S])}catch(s){console.error("[Sandbox] Failed to parse message:",s)}},J.current.onclose=()=>Z(!1),()=>{J.current?.close()}},[b,h]),Ie(()=>{Me.current?.scrollIntoView({behavior:"smooth"})},[m]),Ie(()=>{T(w.trim()?he(w):[])},[w]);let he=a=>{let f=[],s=/\[@([^\]]+)\]|\[face:(\d+)\]|\[image:([^\]]+)\]|\[video:([^\]]+)\]|\[audio:([^\]]+)\]/g,I=0,i;for(;(i=s.exec(a))!==null;){if(i.index>I){let S=a.substring(I,i.index);S&&f.push({type:"text",data:{text:S}})}i[1]?f.push({type:"at",data:{qq:i[1],name:i[1]}}):i[2]?f.push({type:"face",data:{id:parseInt(i[2],10)}}):i[3]?f.push({type:"image",data:{url:i[3]}}):i[4]?f.push({type:"video",data:{url:i[4]}}):i[5]&&f.push({type:"audio",data:{url:i[5]}}),I=s.lastIndex}if(I<a.length){let S=a.substring(I);S&&f.push({type:"text",data:{text:S}})}return f.length>0?f:[{type:"text",data:{text:a}}]},Be=a=>a.length===0?!1:a.some(f=>f.type==="text"?!!String(f.data?.text??"").trim():!0),Xe=(a,f)=>{let s=f?"ring-1 ring-primary-foreground/25":"ring-1 ring-border/60";return a.map((I,i)=>{if(typeof I=="string")return e("span",{children:I.split(`
4
+ `).map((y,k)=>o(Ve.Fragment,{children:[y,k<I.split(`
5
+ `).length-1&&e("br",{})]},k))},i);let S=I.data;switch(I.type){case"text":return e("span",{children:String(S.text??"").split(`
6
+ `).map((y,k)=>o(Ve.Fragment,{children:[y,k<String(S.text??"").split(`
7
+ `).length-1&&e("br",{})]},k))},i);case"at":return o("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded bg-accent text-accent-foreground text-xs mx-0.5",children:["@",String(S.name??S.qq??"")]},i);case"face":return e("img",{src:`https://face.viki.moe/apng/${S.id}.png`,alt:"",className:"w-6 h-6 inline-block align-middle mx-0.5"},i);case"image":{let y=ye(S),k=Pe(y,"image");return k?e("a",{href:k,target:"_blank",rel:"noreferrer",className:"block my-1",children:e("img",{src:k,alt:"",className:M("max-w-[min(320px,88vw)] rounded-lg block",s,"ring-offset-0"),onError:Ye=>{Ye.target.style.display="none"}})},i):e("span",{className:"text-xs opacity-70",children:"[\u56FE\u7247]"},i)}case"video":{let y=ye(S),k=Pe(y,"video");return k?e("video",{src:k,controls:!0,playsInline:!0,preload:"metadata",className:M("max-w-[min(360px,92vw)] max-h-72 rounded-lg my-1 bg-black/10",s)},i):e("span",{className:"text-xs opacity-70",children:"[\u89C6\u9891\u65E0\u5730\u5740]"},i)}case"audio":case"record":{let y=ye(S),k=Pe(y,"audio");return k?e("audio",{src:k,controls:!0,preload:"metadata",className:M("w-full max-w-sm my-2 h-10",f&&"opacity-95")},i):e("span",{className:"text-xs opacity-70",children:"[\u97F3\u9891\u65E0\u5730\u5740]"},i)}case"file":return o("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded border text-xs mx-0.5",children:["\u{1F4CE} ",String(S.name||"\u6587\u4EF6")]},i);default:return o("span",{className:"text-xs opacity-70",children:["[",I.type,"]"]},i)}})},Fe=(a,f)=>{if(!Be(f))return;let s={id:`msg_${Date.now()}`,type:"sent",channelType:g.type,channelId:g.id,channelName:g.name,senderId:"test_user",senderName:"\u6D4B\u8BD5\u7528\u6237",content:f,timestamp:Date.now()};L(I=>[...I,s]),F(""),T([]),U.current?.clear(),J.current?.send(JSON.stringify({type:g.type,id:g.id,content:f,timestamp:Date.now()}))},Ke=()=>{confirm("\u786E\u5B9A\u6E05\u7A7A\u6240\u6709\u6D88\u606F\u8BB0\u5F55\uFF1F")&&L([])},Ze=a=>{ge("chat"),p(a),x(f=>f.map(s=>s.id===a.id?{...s,unread:0}:s)),window.innerWidth<768&&q(!1)},Qe=()=>{let a=["private","group","channel"],f=a[Math.floor(Math.random()*a.length)],s=prompt("\u8BF7\u8F93\u5165\u9891\u9053\u540D\u79F0\uFF1A");if(s){let I={id:`${f}_${Date.now()}`,name:s,type:f,unread:0};x(i=>[...i,I]),p(I)}},De=a=>{switch(a){case"private":return e(X,{size:16});case"group":return e(fe,{size:16});case"channel":return e(te,{size:16});default:return e(O,{size:16})}},_e=a=>{U.current?.insertFace(a),B(!1)},Re=()=>{let a=$.trim();!a||!P||(P==="image"?U.current?.insertImage(a):P==="video"?U.current?.insertVideo(a):U.current?.insertAudio(a),me(""),G(null))},Fa=()=>{l.trim()&&(U.current?.insertAt(l.trim()),n(""),Ce(!1))},Je=a=>{U.current?.replaceAtTrigger(a.name,a.id),Q(null),t("")},je=(a,f,s)=>{if(g.type==="private"){Q(null),t("");return}a&&s?(Q(s),t(f)):(Q(null),t(""))},be=A.filter(a=>{if(!d.trim())return!0;let f=d.toLowerCase();return a.name.toLowerCase().includes(f)||a.id.toLowerCase().includes(f)}),$e=(a,f)=>{F(a),T(f)},ve=N.filter(a=>a.name.toLowerCase().includes(u.toLowerCase())||a.describe.toLowerCase().includes(u.toLowerCase())),Se=m.filter(a=>a.channelId===g.id);return o("div",{className:"sandbox-container rounded-xl border border-border/70 bg-card/30 shadow-sm",children:[o("button",{className:"mobile-channel-toggle md:hidden",onClick:()=>q(!R),children:[e(O,{size:20})," \u9891\u9053\u5217\u8868"]}),o("div",{className:M("channel-sidebar rounded-lg border bg-card",R&&"show"),children:[e("div",{className:"p-3 border-b",children:o("div",{className:"flex justify-between items-center",children:[o("div",{className:"flex items-center gap-2",children:[e("div",{className:"p-1 rounded-md bg-secondary",children:e(O,{size:16,className:"text-muted-foreground"})}),e("h3",{className:"font-semibold",children:"\u9891\u9053\u5217\u8868"})]}),o("span",{className:M("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium border",E?"bg-emerald-100 text-emerald-800 border-emerald-200 dark:bg-emerald-900/30 dark:text-emerald-400 dark:border-emerald-800":"bg-muted text-muted-foreground"),children:[E?e(ne,{size:12}):e(ce,{size:12}),E?"\u5DF2\u8FDE\u63A5":"\u672A\u8FDE\u63A5"]})]})}),o("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:[h.map(a=>{let f=_==="chat"&&g.id===a.id;return o("div",{className:M("menu-item",f&&"active"),onClick:()=>Ze(a),children:[e("span",{className:"shrink-0",children:De(a.type)}),o("div",{className:"flex-1 min-w-0",children:[e("div",{className:"text-sm font-medium truncate",children:a.name}),e("div",{className:"text-xs text-muted-foreground",children:a.type==="private"?"\u79C1\u804A":a.type==="group"?"\u7FA4\u804A":"\u9891\u9053"})]}),a.unread>0&&e("span",{className:"inline-flex items-center justify-center h-5 min-w-5 rounded-full bg-destructive text-destructive-foreground text-[10px] font-medium px-1",children:a.unread})]},a.id)}),o("div",{className:"pt-2 mt-2 border-t space-y-1",children:[o("div",{className:M("menu-item",_==="requests"&&"active"),onClick:()=>{ge("requests"),window.innerWidth<768&&q(!1)},children:[e(z,{size:16,className:"shrink-0"}),o("div",{className:"flex-1 min-w-0",children:[e("div",{className:"text-sm font-medium",children:"\u8BF7\u6C42"}),e("div",{className:"text-xs text-muted-foreground",children:"\u597D\u53CB/\u7FA4\u9080\u8BF7\u7B49"})]})]}),o("div",{className:M("menu-item",_==="notices"&&"active"),onClick:()=>{ge("notices"),window.innerWidth<768&&q(!1)},children:[e(V,{size:16,className:"shrink-0"}),o("div",{className:"flex-1 min-w-0",children:[e("div",{className:"text-sm font-medium",children:"\u901A\u77E5"}),e("div",{className:"text-xs text-muted-foreground",children:"\u7FA4\u7BA1/\u64A4\u56DE\u7B49"})]})]})]})]}),e("div",{className:"p-2 border-t",children:e("button",{className:"w-full py-2 px-3 rounded-md border border-dashed text-sm text-muted-foreground hover:bg-accent transition-colors",onClick:Qe,children:"+ \u6DFB\u52A0\u9891\u9053"})})]}),R&&e("div",{className:"channel-overlay md:hidden",onClick:()=>q(!1)}),o("div",{className:"chat-area",children:[_==="requests"&&o("div",{className:"rounded-lg border bg-card flex-1 flex flex-col min-h-0 overflow-hidden",children:[e("div",{className:"p-3 border-b flex-shrink-0",children:o("h2",{className:"text-lg font-bold flex items-center gap-2",children:[e(z,{size:20})," \u8BF7\u6C42"]})}),o("div",{className:"flex-1 overflow-y-auto p-4 flex flex-col items-center justify-center gap-3 text-muted-foreground text-center",children:[e(z,{size:48,className:"opacity-30"}),e("span",{children:"\u6C99\u76D2\u4E3A\u6A21\u62DF\u73AF\u5883\uFF0C\u6682\u65E0\u8BF7\u6C42\u6570\u636E"}),o("span",{className:"text-sm",children:["\u5B9E\u9645\u597D\u53CB/\u7FA4\u9080\u8BF7\u7B49\u8BF7\u6C42\u8BF7\u5230\u4FA7\u8FB9\u680F ",e("strong",{children:"\u673A\u5668\u4EBA"})," \u9875\u9762\u8FDB\u5165\u5BF9\u5E94\u673A\u5668\u4EBA\u7BA1\u7406\u67E5\u770B"]})]})]}),_==="notices"&&o("div",{className:"rounded-lg border bg-card flex-1 flex flex-col min-h-0 overflow-hidden",children:[e("div",{className:"p-3 border-b flex-shrink-0",children:o("h2",{className:"text-lg font-bold flex items-center gap-2",children:[e(V,{size:20})," \u901A\u77E5"]})}),o("div",{className:"flex-1 overflow-y-auto p-4 flex flex-col items-center justify-center gap-3 text-muted-foreground text-center",children:[e(V,{size:48,className:"opacity-30"}),e("span",{children:"\u6C99\u76D2\u4E3A\u6A21\u62DF\u73AF\u5883\uFF0C\u6682\u65E0\u901A\u77E5\u6570\u636E"}),o("span",{className:"text-sm",children:["\u5B9E\u9645\u7FA4\u7BA1\u3001\u64A4\u56DE\u7B49\u901A\u77E5\u8BF7\u5230\u4FA7\u8FB9\u680F ",e("strong",{children:"\u673A\u5668\u4EBA"})," \u9875\u9762\u8FDB\u5165\u5BF9\u5E94\u673A\u5668\u4EBA\u7BA1\u7406\u67E5\u770B"]})]})]}),_==="chat"&&o(Ba,{children:[e("div",{className:"rounded-lg border bg-card p-3 flex-shrink-0",children:o("div",{className:"flex justify-between items-center flex-wrap gap-2",children:[o("div",{className:"flex items-center gap-3",children:[e("div",{className:"p-2 rounded-lg bg-secondary",children:De(g.type)}),o("div",{children:[e("h2",{className:"text-lg font-bold",children:g.name}),o("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e("span",{children:g.id}),e("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded border text-[10px]",children:Se.length}),e("span",{children:"\u6761\u6D88\u606F"})]})]}),e("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-secondary text-secondary-foreground",children:g.type==="private"?"\u79C1\u804A":g.type==="group"?"\u7FA4\u804A":"\u9891\u9053"})]}),o("div",{className:"flex items-center gap-2",children:[e("input",{value:b,onChange:a=>K(a.target.value),placeholder:"\u673A\u5668\u4EBA\u540D\u79F0",className:"h-8 w-28 rounded-md border bg-transparent px-2 text-sm"}),o("button",{className:"inline-flex items-center gap-1 h-8 px-3 rounded-md bg-secondary text-secondary-foreground text-sm hover:bg-secondary/80",onClick:Ke,children:[e(re,{size:14})," \u6E05\u7A7A"]})]})]})}),e("div",{className:"rounded-lg border bg-card flex-1 flex flex-col min-h-0",children:e("div",{className:"flex-1 overflow-y-auto p-4",children:Se.length===0?o("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[e(O,{size:64,className:"text-muted-foreground/20"}),e("span",{className:"text-muted-foreground",children:"\u6682\u65E0\u6D88\u606F\uFF0C\u5F00\u59CB\u5BF9\u8BDD\u5427\uFF01"})]}):o("div",{className:"space-y-2",children:[Se.map(a=>e("div",{className:M("flex",a.type==="sent"?"justify-end":"justify-start"),children:o("div",{className:M("max-w-[70%] p-3 rounded-2xl",a.type==="sent"?"bg-primary text-primary-foreground":"bg-muted"),children:[o("div",{className:"flex items-center gap-2 mb-1",children:[a.type==="received"&&e(ee,{size:14}),a.type==="sent"&&e(X,{size:14}),e("span",{className:"text-xs font-medium opacity-90",children:a.senderName}),e("span",{className:"text-xs opacity-70",children:new Date(a.timestamp).toLocaleTimeString()})]}),e("div",{className:"text-sm space-y-1",children:Xe(a.content,a.type==="sent")})]})},a.id)),e("div",{ref:Me})]})})}),o("div",{className:"rounded-lg border bg-card p-3 flex-shrink-0 space-y-3",children:[o("div",{className:"flex gap-2 items-center flex-wrap",children:[e("button",{type:"button",className:M("h-8 w-8 rounded-md flex items-center justify-center border transition-colors",H?"bg-primary text-primary-foreground":"hover:bg-accent"),onClick:()=>{B(!H),G(null)},title:"\u63D2\u5165\u8868\u60C5",children:e(se,{size:16})}),e("button",{type:"button",className:M("h-8 w-8 rounded-md flex items-center justify-center border transition-colors",P==="image"?"bg-primary text-primary-foreground":"hover:bg-accent"),onClick:()=>{G(a=>a==="image"?null:"image"),B(!1)},title:"\u63D2\u5165\u56FE\u7247 URL",children:e(oe,{size:16})}),e("button",{type:"button",className:M("h-8 w-8 rounded-md flex items-center justify-center border transition-colors",P==="video"?"bg-primary text-primary-foreground":"hover:bg-accent"),onClick:()=>{G(a=>a==="video"?null:"video"),B(!1)},title:"\u63D2\u5165\u89C6\u9891 URL",children:e(ie,{size:16})}),e("button",{type:"button",className:M("h-8 w-8 rounded-md flex items-center justify-center border transition-colors",P==="audio"?"bg-primary text-primary-foreground":"hover:bg-accent"),onClick:()=>{G(a=>a==="audio"?null:"audio"),B(!1)},title:"\u63D2\u5165\u97F3\u9891 URL",children:e(ue,{size:16})}),e("div",{className:"flex-1 min-w-[1rem]"}),w&&e("button",{className:"h-8 w-8 rounded-md flex items-center justify-center hover:bg-accent transition-colors",onClick:()=>{F(""),T([])},children:e(pe,{size:16})})]}),H&&o("div",{className:"p-3 rounded-md border bg-muted/30 max-h-64 overflow-y-auto space-y-2",children:[e("input",{value:u,onChange:a=>c(a.target.value),placeholder:"\u641C\u7D22\u8868\u60C5...",className:"w-full h-8 rounded-md border bg-transparent px-2 text-sm"}),e("div",{className:"grid grid-cols-8 gap-1",children:ve.slice(0,80).map(a=>e("button",{onClick:()=>_e(a.id),title:a.name,className:"w-10 h-10 rounded-md border flex items-center justify-center hover:bg-accent transition-colors",children:e("img",{src:`https://face.viki.moe/apng/${a.id}.png`,alt:a.name,className:"w-8 h-8"})},a.id))}),ve.length===0&&o("div",{className:"flex flex-col items-center gap-2 py-4",children:[e(j,{size:32,className:"text-muted-foreground/30"}),e("span",{className:"text-sm text-muted-foreground",children:"\u672A\u627E\u5230\u5339\u914D\u7684\u8868\u60C5"})]})]}),P&&o("div",{className:"p-3 rounded-md border bg-muted/30 space-y-2",children:[o("p",{className:"text-xs text-muted-foreground",children:[P==="image"&&"\u652F\u6301 http(s) \u56FE\u7247\u94FE\u63A5\u6216 data URL",P==="video"&&"\u652F\u6301\u6D4F\u89C8\u5668\u53EF\u89E3\u7801\u7684\u89C6\u9891\u76F4\u94FE\uFF08\u5982 .mp4\u3001.webm\uFF09",P==="audio"&&"\u652F\u6301 .mp3\u3001.ogg\u3001.wav \u7B49\u97F3\u9891\u76F4\u94FE"]}),e("input",{value:$,onChange:a=>me(a.target.value),placeholder:P==="image"?"\u56FE\u7247 URL\u2026":P==="video"?"\u89C6\u9891 URL\u2026":"\u97F3\u9891 URL\u2026",className:"w-full h-8 rounded-md border border-input bg-background px-2 text-sm",onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),Re())}}),o("button",{type:"button",className:"inline-flex items-center gap-1 h-8 px-3 rounded-md bg-primary text-primary-foreground text-sm disabled:opacity-50",onClick:Re,disabled:!$.trim(),children:[e(ae,{size:14})," \u63D2\u5165\u5230\u8F93\u5165\u6846"]})]}),o("div",{className:"flex gap-2 items-start",children:[o("div",{className:"flex-1 relative",children:[e(We,{ref:U,placeholder:`\u5411 ${g.name} \u53D1\u9001\u6D88\u606F...`,onSend:Fe,onChange:$e,onAtTrigger:je,minHeight:"44px",maxHeight:"200px"}),Y&&e("div",{className:"absolute z-50 rounded-lg border bg-popover shadow-md min-w-60 max-h-72 overflow-y-auto p-1",style:{top:`${Y.top}px`,left:`${Y.left}px`},children:be.length>0?be.map(a=>o("div",{className:"flex items-center gap-2 p-2 rounded-md cursor-pointer hover:bg-accent transition-colors",onClick:()=>Je(a),children:[e(X,{size:16,className:"text-muted-foreground"}),o("div",{className:"flex-1",children:[e("div",{className:"text-sm font-medium",children:a.name}),o("div",{className:"text-xs text-muted-foreground",children:["ID: ",a.id]})]})]},a.id)):o("div",{className:"flex flex-col items-center gap-2 p-4",children:[e(j,{size:20,className:"text-muted-foreground/50"}),e("span",{className:"text-xs text-muted-foreground",children:"\u672A\u627E\u5230\u5339\u914D\u7684\u7528\u6237"})]})})]}),o("button",{className:"inline-flex items-center gap-1.5 h-10 px-4 rounded-md bg-primary text-primary-foreground text-sm font-medium disabled:opacity-50 transition-colors hover:bg-primary/90",onClick:()=>{let a=U.current?.getContent();a&&Fe(a.text,a.segments)},disabled:!Be(W),children:[e(le,{size:16})," \u53D1\u9001"]})]}),o("div",{className:"flex items-center gap-2 flex-wrap text-xs text-muted-foreground",children:[e(de,{size:12})," \u5FEB\u6377\u64CD\u4F5C:",e("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"Enter"})," \u53D1\u9001",e("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"Shift+Enter"})," \u6362\u884C",e("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"[@\u540D\u79F0]"})," @\u67D0\u4EBA",e("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"[video:URL]"}),e("span",{className:"px-1 py-0.5 rounded border text-[10px]",children:"[audio:URL]"})]})]})]})]})]})}function Io(m){m.addRoute({path:"/console/sandbox",name:"\u6C99\u76D2",element:m.React.createElement(Ae,{hostReact:m.React})}),m.addTool({id:"sandbox",name:"\u6C99\u76D2",path:"/console/sandbox"})}export{Io as register};
8
+ /*! Bundled license information:
9
+
10
+ lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs:
11
+ lucide-react/dist/esm/shared/src/utils/toKebabCase.mjs:
12
+ lucide-react/dist/esm/shared/src/utils/toCamelCase.mjs:
13
+ lucide-react/dist/esm/shared/src/utils/toPascalCase.mjs:
14
+ lucide-react/dist/esm/defaultAttributes.mjs:
15
+ lucide-react/dist/esm/shared/src/utils/hasA11yProp.mjs:
16
+ lucide-react/dist/esm/context.mjs:
17
+ lucide-react/dist/esm/Icon.mjs:
18
+ lucide-react/dist/esm/createLucideIcon.mjs:
19
+ lucide-react/dist/esm/icons/bell.mjs:
20
+ lucide-react/dist/esm/icons/bot.mjs:
21
+ lucide-react/dist/esm/icons/check.mjs:
22
+ lucide-react/dist/esm/icons/hash.mjs:
23
+ lucide-react/dist/esm/icons/image.mjs:
24
+ lucide-react/dist/esm/icons/info.mjs:
25
+ lucide-react/dist/esm/icons/message-square.mjs:
26
+ lucide-react/dist/esm/icons/music.mjs:
27
+ lucide-react/dist/esm/icons/search.mjs:
28
+ lucide-react/dist/esm/icons/send.mjs:
29
+ lucide-react/dist/esm/icons/smile.mjs:
30
+ lucide-react/dist/esm/icons/trash-2.mjs:
31
+ lucide-react/dist/esm/icons/user-plus.mjs:
32
+ lucide-react/dist/esm/icons/user.mjs:
33
+ lucide-react/dist/esm/icons/users.mjs:
34
+ lucide-react/dist/esm/icons/video.mjs:
35
+ lucide-react/dist/esm/icons/wifi-off.mjs:
36
+ lucide-react/dist/esm/icons/wifi.mjs:
37
+ lucide-react/dist/esm/icons/x.mjs:
38
+ lucide-react/dist/esm/lucide-react.mjs:
39
+ (**
40
+ * @license lucide-react v1.11.0 - ISC
41
+ *
42
+ * This source code is licensed under the ISC license.
43
+ * See the LICENSE file in the root directory of this source tree.
44
+ *)
45
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-sandbox",
3
- "version": "2.0.13",
3
+ "version": "2.0.14",
4
4
  "description": "Zhin.js adapter for local testing and development",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -48,13 +48,14 @@
48
48
  "radix-ui": "^1.4.3",
49
49
  "lucide-react": "^1.11.0",
50
50
  "typescript": "^6.0.3",
51
+ "@zhin.js/cli": "1.0.68",
51
52
  "zhin.js": "1.0.72"
52
53
  },
53
54
  "peerDependencies": {
54
55
  "@zhin.js/core": "1.1.14",
55
56
  "@zhin.js/client": "1.0.18",
56
57
  "@zhin.js/http": "1.0.65",
57
- "@zhin.js/console": "2.0.13",
58
+ "@zhin.js/console": "2.0.14",
58
59
  "zhin.js": "1.0.72"
59
60
  },
60
61
  "peerDependenciesMeta": {
@@ -73,7 +74,7 @@
73
74
  "registry": "https://registry.npmjs.org"
74
75
  },
75
76
  "scripts": {
76
- "build": "tsc && node ../../../scripts/build-console-client-if-present.mjs",
77
+ "build": "zhin build",
77
78
  "clean": "rimraf lib"
78
79
  }
79
80
  }