@heybox/hb-sdk 0.9.6-alpha.10 → 0.9.6-alpha.11
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 +7 -0
- package/README.md +4 -0
- package/dist/cli-chunks/{artifact-BaZzEQjq.cjs → artifact-BW6SD1G6.cjs} +3 -3
- package/dist/cli-chunks/{build-Ykhw1sz9.cjs → build-B0Id0UTN.cjs} +5 -5
- package/dist/cli-chunks/{create-BEjKsD1y.cjs → create-DVu93Ekp.cjs} +1 -1
- package/dist/cli-chunks/{dev-DpkBN4ir.cjs → dev-CeSjpEZQ.cjs} +8 -8
- package/dist/cli-chunks/{dev-context-B3Y_EcXC.cjs → dev-context-CVc_BsWR.cjs} +2 -2
- package/dist/cli-chunks/{doctor-DPELjB83.cjs → doctor-BF9mtkJr.cjs} +1 -1
- package/dist/cli-chunks/{games-D2hnnWKY.cjs → games-BKnDCklM.cjs} +1 -1
- package/dist/cli-chunks/{index-DCj9vtVv.cjs → index-Cgui_8Rk.cjs} +1 -1
- package/dist/cli-chunks/{index-DIgSsTuu.cjs → index-Rp3UMZIO.cjs} +17 -17
- package/dist/cli-chunks/{index.esm-t29GC7yg.cjs → index.esm-BK0eVYaM.cjs} +6 -6
- package/dist/cli-chunks/{login-C5XmcbRa.cjs → login-DpeDN-mt.cjs} +1 -1
- package/dist/cli-chunks/{project-vite-B12EMgRq.cjs → project-vite-Cg3jYqAJ.cjs} +1 -1
- package/dist/cli-chunks/{remote-lFAA88Zl.cjs → remote-BQ-9rhTb.cjs} +6 -6
- package/dist/cli-chunks/{runtime-permission-env-CYbLBtWo.cjs → runtime-permission-env-BgipCJ0Z.cjs} +3 -3
- package/dist/cli-chunks/{skill-AilHsggi.cjs → skill-D7pd4yPq.cjs} +2 -2
- package/dist/cli-chunks/{version-KZTUyIiC.cjs → version-DbjRZkb6.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-DVlT56iQ.js +100 -0
- package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-CPk4dD63.js → desktop-app-launch-BzRxl_MM.js} +1 -1
- package/dist/devtools/browser-dev-host/assets/{index-BzOC7Q8l.js → index-DY5ZynQp.js} +3 -3
- package/dist/devtools/browser-dev-host/index.html +2 -2
- package/dist/index.cjs.js +173 -3
- package/dist/index.esm.js +173 -3
- package/dist/miniapp-publish.cjs.js +1 -1
- package/dist/miniapp-publish.esm.js +1 -1
- package/dist/protocol.cjs.js +5 -0
- package/dist/protocol.esm.js +5 -0
- package/dist/vite.cjs.js +2 -2
- package/dist/vite.esm.js +2 -2
- package/package.json +5 -5
- package/skill/skill.json +4 -4
- package/types/index.d.ts +54 -1
- package/dist/devtools/browser-dev-host/assets/browser-dev-host-C0_lx52X.js +0 -100
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-dev-host-
|
|
2
|
-
import{ac as q1,Q as Ye,aj as _3,Y as r0,af as Xe,ad as Je,u as y3,a8 as R1,ak as Qe,ai as e4,ab as H3,a7 as F1,v as t4,t as a4,ah as N1,an as s0,as as f6,am as o4,al as n4,aa as i4,c as l4,a5 as V6,b as r4,ae as s4,be as c4,V as j,bu as e6,aD as g,O as L,E as m,L as Z,av as y6,at as m6,aK as H,z as x,a9 as o3,aG as Z6,b7 as v3,U as d4,bh as g6,b8 as _2,a3 as U1,aA as W1,ay as r3,X as G1,a2 as s3,ag as H2,aH as c2,bl as s,bg as n3,az as w6,F as p6,bc as u4,bv as P6,aC as p4,bk as f4,bf as h4,aB as L3,bn as v4,C as m4,ar as d6,y as g4,G,bx as E,aP as X,T as Z1,ao as _4,bw as j1,bz as y4,ap as w4,ax as b4,au as j3,a4 as K3,S as q,aS as V3,aO as S6,R as h6,bb as P,bd as C4,bm as x4,bp as z4,by as K6,bo as j2,aq as K1,a0 as Y6,a1 as M4,bA as z,P as S4,g as A4,i as k4,j as Y1,W as B4,aU as s2,D as E4,f as H4,aL as L4,bt as V4,aQ as P4,m as O4,aY as T4,k as D4,a as $4,B as I4,aE as B0,bj as q4,bi as R4,aR as F4,n as N4,w as U4,x as W4,Z as E0,$ as H0,_ as L0,e as a2,H as G4,M as Z4,l as j4,a6 as K4,b2 as V0,b3 as L2,aT as P0,aW as Y4,b0 as O0,a_ as T0,a$ as D0,aZ as $0,aJ as X4,s as J4,aM as Q4}from"./desktop-app-launch-CPk4dD63.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const l of n)if(l.type==="childList")for(const i of l.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function a(n){const l={};return n.integrity&&(l.integrity=n.integrity),n.referrerPolicy&&(l.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?l.credentials="include":n.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(n){if(n.ep)return;n.ep=!0;const l=a(n);fetch(n.href,l)}})();const e7="modulepreload",t7=function(e){return"/"+e},I0={},a7=function(t,a,o){let n=Promise.resolve();if(a&&a.length>0){let c=function(p){return Promise.all(p.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),r=i?.nonce||i?.getAttribute("nonce");n=c(a.map(p=>{if(p=t7(p),p in I0)return;I0[p]=!0;const u=p.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":e7,u||(f.as="script"),f.crossOrigin="",f.href=p,r&&f.setAttribute("nonce",r),document.head.appendChild(f),u)return new Promise((h,v)=>{f.addEventListener("load",h),f.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${p}`)))})}))}function l(i){const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=i,window.dispatchEvent(r),!r.defaultPrevented)throw i}return n.then(i=>{for(const r of i||[])r.status==="rejected"&&l(r.reason);return t().catch(l)})};let K2;const q0=typeof window<"u"&&window.trustedTypes;if(q0)try{K2=q0.createPolicy("vue",{createHTML:e=>e})}catch{}const X1=K2?e=>K2.createHTML(e):e=>e,o7="http://www.w3.org/2000/svg",n7="http://www.w3.org/1998/Math/MathML",j6=typeof document<"u"?document:null,R0=j6&&j6.createElement("template"),i7={insert:(e,t,a)=>{t.insertBefore(e,a||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,a,o)=>{const n=t==="svg"?j6.createElementNS(o7,e):t==="mathml"?j6.createElementNS(n7,e):a?j6.createElement(e,{is:a}):j6.createElement(e);return e==="select"&&o&&o.multiple!=null&&n.setAttribute("multiple",o.multiple),n},createText:e=>j6.createTextNode(e),createComment:e=>j6.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>j6.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,a,o,n,l){const i=a?a.previousSibling:t.lastChild;if(n&&(n===l||n.nextSibling))for(;t.insertBefore(n.cloneNode(!0),a),!(n===l||!(n=n.nextSibling)););else{R0.innerHTML=X1(o==="svg"?`<svg>${e}</svg>`:o==="mathml"?`<math>${e}</math>`:e);const r=R0.content;if(o==="svg"||o==="mathml"){const c=r.firstChild;for(;c.firstChild;)r.appendChild(c.firstChild);r.removeChild(c)}t.insertBefore(r,a)}return[i?i.nextSibling:t.firstChild,a?a.previousSibling:t.lastChild]}},t3="transition",$3="animation",N3=Symbol("_vtc"),J1={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},l7=r0({},l4,J1),r7=e=>(e.displayName="Transition",e.props=l7,e),s7=r7((e,{slots:t})=>V6(r4,c7(e),t)),p3=(e,t=[])=>{H3(e)?e.forEach(a=>a(...t)):e&&e(...t)},F0=e=>e?H3(e)?e.some(t=>t.length>1):e.length>1:!1;function c7(e){const t={};for(const $ in e)$ in J1||(t[$]=e[$]);if(e.css===!1)return t;const{name:a="v",type:o,duration:n,enterFromClass:l=`${a}-enter-from`,enterActiveClass:i=`${a}-enter-active`,enterToClass:r=`${a}-enter-to`,appearFromClass:c=l,appearActiveClass:p=i,appearToClass:u=r,leaveFromClass:d=`${a}-leave-from`,leaveActiveClass:f=`${a}-leave-active`,leaveToClass:h=`${a}-leave-to`}=e,v=d7(n),_=v&&v[0],w=v&&v[1],{onBeforeEnter:b,onEnter:k,onEnterCancelled:M,onLeave:y,onLeaveCancelled:T,onBeforeAppear:S=b,onAppear:B=k,onAppearCancelled:D=M}=t,I=($,K,Q,n6)=>{$._enterCancelled=n6,f3($,K?u:r),f3($,K?p:i),Q&&Q()},F=($,K)=>{$._isLeaving=!1,f3($,d),f3($,h),f3($,f),K&&K()},J=$=>(K,Q)=>{const n6=$?B:k,t6=()=>I(K,$,Q);p3(n6,[K,t6]),N0(()=>{f3(K,$?c:l),G6(K,$?u:r),F0(n6)||U0(K,o,_,t6)})};return r0(t,{onBeforeEnter($){p3(b,[$]),G6($,l),G6($,i)},onBeforeAppear($){p3(S,[$]),G6($,c),G6($,p)},onEnter:J(!1),onAppear:J(!0),onLeave($,K){$._isLeaving=!0;const Q=()=>F($,K);G6($,d),$._enterCancelled?(G6($,f),Z0($)):(Z0($),G6($,f)),N0(()=>{$._isLeaving&&(f3($,d),G6($,h),F0(y)||U0($,o,w,Q))}),p3(y,[$,Q])},onEnterCancelled($){I($,!1,void 0,!0),p3(M,[$])},onAppearCancelled($){I($,!0,void 0,!0),p3(D,[$])},onLeaveCancelled($){F($),p3(T,[$])}})}function d7(e){if(e==null)return null;if(s4(e))return[V2(e.enter),V2(e.leave)];{const t=V2(e);return[t,t]}}function V2(e){return c4(e)}function G6(e,t){t.split(/\s+/).forEach(a=>a&&e.classList.add(a)),(e[N3]||(e[N3]=new Set)).add(t)}function f3(e,t){t.split(/\s+/).forEach(o=>o&&e.classList.remove(o));const a=e[N3];a&&(a.delete(t),a.size||(e[N3]=void 0))}function N0(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let u7=0;function U0(e,t,a,o){const n=e._endId=++u7,l=()=>{n===e._endId&&o()};if(a!=null)return setTimeout(l,a);const{type:i,timeout:r,propCount:c}=p7(e,t);if(!i)return o();const p=i+"end";let u=0;const d=()=>{e.removeEventListener(p,f),l()},f=h=>{h.target===e&&++u>=c&&d()};setTimeout(()=>{u<c&&d()},r+1),e.addEventListener(p,f)}function p7(e,t){const a=window.getComputedStyle(e),o=v=>(a[v]||"").split(", "),n=o(`${t3}Delay`),l=o(`${t3}Duration`),i=W0(n,l),r=o(`${$3}Delay`),c=o(`${$3}Duration`),p=W0(r,c);let u=null,d=0,f=0;t===t3?i>0&&(u=t3,d=i,f=l.length):t===$3?p>0&&(u=$3,d=p,f=c.length):(d=Math.max(i,p),u=d>0?i>p?t3:$3:null,f=u?u===t3?l.length:c.length:0);const h=u===t3&&/\b(?:transform|all)(?:,|$)/.test(o(`${t3}Property`).toString());return{type:u,timeout:d,propCount:f,hasTransform:h}}function W0(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max(...t.map((a,o)=>G0(a)+G0(e[o])))}function G0(e){return e==="auto"?0:Number(e.slice(0,-1).replace(",","."))*1e3}function Z0(e){return(e?e.ownerDocument:document).body.offsetHeight}function f7(e,t,a){const o=e[N3];o&&(t=(t?[t,...o]:[...o]).join(" ")),t==null?e.removeAttribute("class"):a?e.setAttribute("class",t):e.className=t}const d2=Symbol("_vod"),Q1=Symbol("_vsh"),g3={name:"show",beforeMount(e,{value:t},{transition:a}){e[d2]=e.style.display==="none"?"":e.style.display,a&&t?a.beforeEnter(e):I3(e,t)},mounted(e,{value:t},{transition:a}){a&&t&&a.enter(e)},updated(e,{value:t,oldValue:a},{transition:o}){!t!=!a&&(o?t?(o.beforeEnter(e),I3(e,!0),o.enter(e)):o.leave(e,()=>{I3(e,!1)}):I3(e,t))},beforeUnmount(e,{value:t}){I3(e,t)}};function I3(e,t){e.style.display=t?e[d2]:"none",e[Q1]=!t}const h7=Symbol(""),v7=/(?:^|;)\s*display\s*:/;function m7(e,t,a){const o=e.style,n=_3(a);let l=!1;if(a&&!n){if(t)if(_3(t))for(const i of t.split(";")){const r=i.slice(0,i.indexOf(":")).trim();a[r]==null&&F3(o,r,"")}else for(const i in t)a[i]==null&&F3(o,i,"");for(const i in a){i==="display"&&(l=!0);const r=a[i];r!=null?_7(e,i,!_3(t)&&t?t[i]:void 0,r)||F3(o,i,r):F3(o,i,"")}}else if(n){if(t!==a){const i=o[h7];i&&(a+=";"+i),o.cssText=a,l=v7.test(a)}}else t&&e.removeAttribute("style");d2 in e&&(e[d2]=l?o.display:"",e[Q1]&&(o.display="none"))}const j0=/\s*!important$/;function F3(e,t,a){if(H3(a))a.forEach(o=>F3(e,t,o));else if(a==null&&(a=""),t.startsWith("--"))e.setProperty(t,a);else{const o=g7(e,t);j0.test(a)?e.setProperty(F1(o),a.replace(j0,""),"important"):e[o]=a}}const K0=["Webkit","Moz","ms"],P2={};function g7(e,t){const a=P2[t];if(a)return a;let o=y3(t);if(o!=="filter"&&o in e)return P2[t]=o;o=t4(o);for(let n=0;n<K0.length;n++){const l=K0[n]+o;if(l in e)return P2[t]=l}return t}function _7(e,t,a,o){return e.tagName==="TEXTAREA"&&(t==="width"||t==="height")&&_3(o)&&a===o}const Y0="http://www.w3.org/1999/xlink";function X0(e,t,a,o,n,l=e4(t)){o&&t.startsWith("xlink:")?a==null?e.removeAttributeNS(Y0,t.slice(6,t.length)):e.setAttributeNS(Y0,t,a):a==null||l&&!R1(a)?e.removeAttribute(t):e.setAttribute(t,l?"":Qe(a)?String(a):a)}function J0(e,t,a,o,n){if(t==="innerHTML"||t==="textContent"){a!=null&&(e[t]=t==="innerHTML"?X1(a):a);return}const l=e.tagName;if(t==="value"&&l!=="PROGRESS"&&!l.includes("-")){const r=l==="OPTION"?e.getAttribute("value")||"":e.value,c=a==null?e.type==="checkbox"?"on":"":String(a);(r!==c||!("_value"in e))&&(e.value=c),a==null&&e.removeAttribute(t),e._value=a;return}let i=!1;if(a===""||a==null){const r=typeof e[t];r==="boolean"?a=R1(a):a==null&&r==="string"?(a="",i=!0):r==="number"&&(a=0,i=!0)}try{e[t]=a}catch{}i&&e.removeAttribute(n||t)}function m3(e,t,a,o){e.addEventListener(t,a,o)}function y7(e,t,a,o){e.removeEventListener(t,a,o)}const Q0=Symbol("_vei");function w7(e,t,a,o,n=null){const l=e[Q0]||(e[Q0]={}),i=l[t];if(o&&i)i.value=o;else{const[r,c]=b7(t);if(o){const p=l[t]=z7(o,n);m3(e,r,p,c)}else i&&(y7(e,r,i,c),l[t]=void 0)}}const e1=/(?:Once|Passive|Capture)$/;function b7(e){let t;if(e1.test(e)){t={};let o;for(;o=e.match(e1);)e=e.slice(0,e.length-o[0].length),t[o[0].toLowerCase()]=!0}return[e[2]===":"?e.slice(3):F1(e.slice(2)),t]}let O2=0;const C7=Promise.resolve(),x7=()=>O2||(C7.then(()=>O2=0),O2=Date.now());function z7(e,t){const a=o=>{if(!o._vts)o._vts=Date.now();else if(o._vts<=a.attached)return;a4(M7(o,a.value),t,5,[o])};return a.value=e,a.attached=x7(),a}function M7(e,t){if(H3(t)){const a=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{a.call(e),e._stopped=!0},t.map(o=>n=>!n._stopped&&o&&o(n))}else return t}const t1=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,S7=(e,t,a,o,n,l)=>{const i=n==="svg";t==="class"?f7(e,o,i):t==="style"?m7(e,a,o):Xe(t)?Je(t)||w7(e,t,a,o,l):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):A7(e,t,o,i))?(J0(e,t,o),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&X0(e,t,o,i,l,t!=="value")):e._isVueCE&&(k7(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!_3(o)))?J0(e,y3(t),o,l,t):(t==="true-value"?e._trueValue=o:t==="false-value"&&(e._falseValue=o),X0(e,t,o,i))};function A7(e,t,a,o){if(o)return!!(t==="innerHTML"||t==="textContent"||t in e&&t1(t)&&q1(a));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const n=e.tagName;if(n==="IMG"||n==="VIDEO"||n==="CANVAS"||n==="SOURCE")return!1}return t1(t)&&_3(a)?!1:t in e}function k7(e,t){const a=e._def.props;if(!a)return!1;const o=y3(t);return Array.isArray(a)?a.some(n=>y3(n)===o):Object.keys(a).some(n=>y3(n)===o)}const u2=e=>{const t=e.props["onUpdate:modelValue"]||!1;return H3(t)?a=>i4(t,a):t};function B7(e){e.target.composing=!0}function a1(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const A3=Symbol("_assign");function o1(e,t,a){return t&&(e=e.trim()),a&&(e=s0(e)),e}const E7={created(e,{modifiers:{lazy:t,trim:a,number:o}},n){e[A3]=u2(n);const l=o||n.props&&n.props.type==="number";m3(e,t?"change":"input",i=>{i.target.composing||e[A3](o1(e.value,a,l))}),(a||l)&&m3(e,"change",()=>{e.value=o1(e.value,a,l)}),t||(m3(e,"compositionstart",B7),m3(e,"compositionend",a1),m3(e,"change",a1))},mounted(e,{value:t}){e.value=t??""},beforeUpdate(e,{value:t,oldValue:a,modifiers:{lazy:o,trim:n,number:l}},i){if(e[A3]=u2(i),e.composing)return;const r=(l||e.type==="number")&&!/^0\d/.test(e.value)?s0(e.value):e.value,c=t??"";if(r===c)return;const p=e.getRootNode();(p instanceof Document||p instanceof ShadowRoot)&&p.activeElement===e&&e.type!=="range"&&(o&&t===a||n&&e.value.trim()===c)||(e.value=c)}},H7={deep:!0,created(e,{value:t,modifiers:{number:a}},o){const n=N1(t);m3(e,"change",()=>{const l=Array.prototype.filter.call(e.options,i=>i.selected).map(i=>a?s0(p2(i)):p2(i));e[A3](e.multiple?n?new Set(l):l:l[0]),e._assigning=!0,f6(()=>{e._assigning=!1})}),e[A3]=u2(o)},mounted(e,{value:t}){n1(e,t)},beforeUpdate(e,t,a){e[A3]=u2(a)},updated(e,{value:t}){e._assigning||n1(e,t)}};function n1(e,t){const a=e.multiple,o=H3(t);if(!(a&&!o&&!N1(t))){for(let n=0,l=e.options.length;n<l;n++){const i=e.options[n],r=p2(i);if(a)if(o){const c=typeof r;c==="string"||c==="number"?i.selected=t.some(p=>String(p)===String(r)):i.selected=o4(t,r)>-1}else i.selected=t.has(r);else if(n4(p2(i),t)){e.selectedIndex!==n&&(e.selectedIndex=n);return}}!a&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function p2(e){return"_value"in e?e._value:e.value}const L7=["ctrl","shift","alt","meta"],V7={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>L7.some(a=>e[`${a}Key`]&&!t.includes(a))},R6=(e,t)=>{if(!e)return e;const a=e._withMods||(e._withMods={}),o=t.join(".");return a[o]||(a[o]=((n,...l)=>{for(let i=0;i<t.length;i++){const r=V7[t[i]];if(r&&r(n,t))return}return e(n,...l)}))},P7=r0({patchProp:S7},i7);let i1;function O7(){return i1||(i1=Ye(P7))}const T7=((...e)=>{const t=O7().createApp(...e),{mount:a}=t;return t.mount=o=>{const n=$7(o);if(!n)return;const l=t._component;!q1(l)&&!l.render&&!l.template&&(l.template=n.innerHTML),n.nodeType===1&&(n.textContent="");const i=a(n,!1,D7(n));return n instanceof Element&&(n.removeAttribute("v-cloak"),n.setAttribute("data-v-app","")),i},t});function D7(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function $7(e){return _3(e)?document.querySelector(e):e}(()=>{var e=`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-dev-host-DVlT56iQ.js","assets/desktop-app-launch-BzRxl_MM.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{ac as q1,Q as Ye,aj as _3,Y as r0,af as Xe,ad as Je,u as y3,a8 as R1,ak as Qe,ai as e4,ab as H3,a7 as F1,v as t4,t as a4,ah as N1,an as s0,as as f6,am as o4,al as n4,aa as i4,c as l4,a5 as V6,b as r4,ae as s4,be as c4,V as j,bu as e6,aD as g,O as L,E as m,L as Z,av as y6,at as m6,aK as H,z as x,a9 as o3,aG as Z6,b7 as v3,U as d4,bh as g6,b8 as _2,a3 as U1,aA as W1,ay as r3,X as G1,a2 as s3,ag as H2,aH as c2,bl as s,bg as n3,az as w6,F as p6,bc as u4,bv as P6,aC as p4,bk as f4,bf as h4,aB as L3,bn as v4,C as m4,ar as d6,y as g4,G,bx as E,aP as X,T as Z1,ao as _4,bw as j1,bz as y4,ap as w4,ax as b4,au as j3,a4 as K3,S as q,aS as V3,aO as S6,R as h6,bb as P,bd as C4,bm as x4,bp as z4,by as K6,bo as j2,aq as K1,a0 as Y6,a1 as M4,bA as z,P as S4,g as A4,i as k4,j as Y1,W as B4,aU as s2,D as E4,f as H4,aL as L4,bt as V4,aQ as P4,m as O4,aY as T4,k as D4,a as $4,B as I4,aE as B0,bj as q4,bi as R4,aR as F4,n as N4,w as U4,x as W4,Z as E0,$ as H0,_ as L0,e as a2,H as G4,M as Z4,l as j4,a6 as K4,b2 as V0,b3 as L2,aT as P0,aW as Y4,b0 as O0,a_ as T0,a$ as D0,aZ as $0,aJ as X4,s as J4,aM as Q4}from"./desktop-app-launch-BzRxl_MM.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const l of n)if(l.type==="childList")for(const i of l.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function a(n){const l={};return n.integrity&&(l.integrity=n.integrity),n.referrerPolicy&&(l.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?l.credentials="include":n.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(n){if(n.ep)return;n.ep=!0;const l=a(n);fetch(n.href,l)}})();const e7="modulepreload",t7=function(e){return"/"+e},I0={},a7=function(t,a,o){let n=Promise.resolve();if(a&&a.length>0){let c=function(p){return Promise.all(p.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),r=i?.nonce||i?.getAttribute("nonce");n=c(a.map(p=>{if(p=t7(p),p in I0)return;I0[p]=!0;const u=p.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":e7,u||(f.as="script"),f.crossOrigin="",f.href=p,r&&f.setAttribute("nonce",r),document.head.appendChild(f),u)return new Promise((h,v)=>{f.addEventListener("load",h),f.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${p}`)))})}))}function l(i){const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=i,window.dispatchEvent(r),!r.defaultPrevented)throw i}return n.then(i=>{for(const r of i||[])r.status==="rejected"&&l(r.reason);return t().catch(l)})};let K2;const q0=typeof window<"u"&&window.trustedTypes;if(q0)try{K2=q0.createPolicy("vue",{createHTML:e=>e})}catch{}const X1=K2?e=>K2.createHTML(e):e=>e,o7="http://www.w3.org/2000/svg",n7="http://www.w3.org/1998/Math/MathML",j6=typeof document<"u"?document:null,R0=j6&&j6.createElement("template"),i7={insert:(e,t,a)=>{t.insertBefore(e,a||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,a,o)=>{const n=t==="svg"?j6.createElementNS(o7,e):t==="mathml"?j6.createElementNS(n7,e):a?j6.createElement(e,{is:a}):j6.createElement(e);return e==="select"&&o&&o.multiple!=null&&n.setAttribute("multiple",o.multiple),n},createText:e=>j6.createTextNode(e),createComment:e=>j6.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>j6.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,a,o,n,l){const i=a?a.previousSibling:t.lastChild;if(n&&(n===l||n.nextSibling))for(;t.insertBefore(n.cloneNode(!0),a),!(n===l||!(n=n.nextSibling)););else{R0.innerHTML=X1(o==="svg"?`<svg>${e}</svg>`:o==="mathml"?`<math>${e}</math>`:e);const r=R0.content;if(o==="svg"||o==="mathml"){const c=r.firstChild;for(;c.firstChild;)r.appendChild(c.firstChild);r.removeChild(c)}t.insertBefore(r,a)}return[i?i.nextSibling:t.firstChild,a?a.previousSibling:t.lastChild]}},t3="transition",$3="animation",N3=Symbol("_vtc"),J1={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},l7=r0({},l4,J1),r7=e=>(e.displayName="Transition",e.props=l7,e),s7=r7((e,{slots:t})=>V6(r4,c7(e),t)),p3=(e,t=[])=>{H3(e)?e.forEach(a=>a(...t)):e&&e(...t)},F0=e=>e?H3(e)?e.some(t=>t.length>1):e.length>1:!1;function c7(e){const t={};for(const $ in e)$ in J1||(t[$]=e[$]);if(e.css===!1)return t;const{name:a="v",type:o,duration:n,enterFromClass:l=`${a}-enter-from`,enterActiveClass:i=`${a}-enter-active`,enterToClass:r=`${a}-enter-to`,appearFromClass:c=l,appearActiveClass:p=i,appearToClass:u=r,leaveFromClass:d=`${a}-leave-from`,leaveActiveClass:f=`${a}-leave-active`,leaveToClass:h=`${a}-leave-to`}=e,v=d7(n),_=v&&v[0],w=v&&v[1],{onBeforeEnter:b,onEnter:k,onEnterCancelled:M,onLeave:y,onLeaveCancelled:T,onBeforeAppear:S=b,onAppear:B=k,onAppearCancelled:D=M}=t,I=($,K,Q,n6)=>{$._enterCancelled=n6,f3($,K?u:r),f3($,K?p:i),Q&&Q()},F=($,K)=>{$._isLeaving=!1,f3($,d),f3($,h),f3($,f),K&&K()},J=$=>(K,Q)=>{const n6=$?B:k,t6=()=>I(K,$,Q);p3(n6,[K,t6]),N0(()=>{f3(K,$?c:l),G6(K,$?u:r),F0(n6)||U0(K,o,_,t6)})};return r0(t,{onBeforeEnter($){p3(b,[$]),G6($,l),G6($,i)},onBeforeAppear($){p3(S,[$]),G6($,c),G6($,p)},onEnter:J(!1),onAppear:J(!0),onLeave($,K){$._isLeaving=!0;const Q=()=>F($,K);G6($,d),$._enterCancelled?(G6($,f),Z0($)):(Z0($),G6($,f)),N0(()=>{$._isLeaving&&(f3($,d),G6($,h),F0(y)||U0($,o,w,Q))}),p3(y,[$,Q])},onEnterCancelled($){I($,!1,void 0,!0),p3(M,[$])},onAppearCancelled($){I($,!0,void 0,!0),p3(D,[$])},onLeaveCancelled($){F($),p3(T,[$])}})}function d7(e){if(e==null)return null;if(s4(e))return[V2(e.enter),V2(e.leave)];{const t=V2(e);return[t,t]}}function V2(e){return c4(e)}function G6(e,t){t.split(/\s+/).forEach(a=>a&&e.classList.add(a)),(e[N3]||(e[N3]=new Set)).add(t)}function f3(e,t){t.split(/\s+/).forEach(o=>o&&e.classList.remove(o));const a=e[N3];a&&(a.delete(t),a.size||(e[N3]=void 0))}function N0(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let u7=0;function U0(e,t,a,o){const n=e._endId=++u7,l=()=>{n===e._endId&&o()};if(a!=null)return setTimeout(l,a);const{type:i,timeout:r,propCount:c}=p7(e,t);if(!i)return o();const p=i+"end";let u=0;const d=()=>{e.removeEventListener(p,f),l()},f=h=>{h.target===e&&++u>=c&&d()};setTimeout(()=>{u<c&&d()},r+1),e.addEventListener(p,f)}function p7(e,t){const a=window.getComputedStyle(e),o=v=>(a[v]||"").split(", "),n=o(`${t3}Delay`),l=o(`${t3}Duration`),i=W0(n,l),r=o(`${$3}Delay`),c=o(`${$3}Duration`),p=W0(r,c);let u=null,d=0,f=0;t===t3?i>0&&(u=t3,d=i,f=l.length):t===$3?p>0&&(u=$3,d=p,f=c.length):(d=Math.max(i,p),u=d>0?i>p?t3:$3:null,f=u?u===t3?l.length:c.length:0);const h=u===t3&&/\b(?:transform|all)(?:,|$)/.test(o(`${t3}Property`).toString());return{type:u,timeout:d,propCount:f,hasTransform:h}}function W0(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max(...t.map((a,o)=>G0(a)+G0(e[o])))}function G0(e){return e==="auto"?0:Number(e.slice(0,-1).replace(",","."))*1e3}function Z0(e){return(e?e.ownerDocument:document).body.offsetHeight}function f7(e,t,a){const o=e[N3];o&&(t=(t?[t,...o]:[...o]).join(" ")),t==null?e.removeAttribute("class"):a?e.setAttribute("class",t):e.className=t}const d2=Symbol("_vod"),Q1=Symbol("_vsh"),g3={name:"show",beforeMount(e,{value:t},{transition:a}){e[d2]=e.style.display==="none"?"":e.style.display,a&&t?a.beforeEnter(e):I3(e,t)},mounted(e,{value:t},{transition:a}){a&&t&&a.enter(e)},updated(e,{value:t,oldValue:a},{transition:o}){!t!=!a&&(o?t?(o.beforeEnter(e),I3(e,!0),o.enter(e)):o.leave(e,()=>{I3(e,!1)}):I3(e,t))},beforeUnmount(e,{value:t}){I3(e,t)}};function I3(e,t){e.style.display=t?e[d2]:"none",e[Q1]=!t}const h7=Symbol(""),v7=/(?:^|;)\s*display\s*:/;function m7(e,t,a){const o=e.style,n=_3(a);let l=!1;if(a&&!n){if(t)if(_3(t))for(const i of t.split(";")){const r=i.slice(0,i.indexOf(":")).trim();a[r]==null&&F3(o,r,"")}else for(const i in t)a[i]==null&&F3(o,i,"");for(const i in a){i==="display"&&(l=!0);const r=a[i];r!=null?_7(e,i,!_3(t)&&t?t[i]:void 0,r)||F3(o,i,r):F3(o,i,"")}}else if(n){if(t!==a){const i=o[h7];i&&(a+=";"+i),o.cssText=a,l=v7.test(a)}}else t&&e.removeAttribute("style");d2 in e&&(e[d2]=l?o.display:"",e[Q1]&&(o.display="none"))}const j0=/\s*!important$/;function F3(e,t,a){if(H3(a))a.forEach(o=>F3(e,t,o));else if(a==null&&(a=""),t.startsWith("--"))e.setProperty(t,a);else{const o=g7(e,t);j0.test(a)?e.setProperty(F1(o),a.replace(j0,""),"important"):e[o]=a}}const K0=["Webkit","Moz","ms"],P2={};function g7(e,t){const a=P2[t];if(a)return a;let o=y3(t);if(o!=="filter"&&o in e)return P2[t]=o;o=t4(o);for(let n=0;n<K0.length;n++){const l=K0[n]+o;if(l in e)return P2[t]=l}return t}function _7(e,t,a,o){return e.tagName==="TEXTAREA"&&(t==="width"||t==="height")&&_3(o)&&a===o}const Y0="http://www.w3.org/1999/xlink";function X0(e,t,a,o,n,l=e4(t)){o&&t.startsWith("xlink:")?a==null?e.removeAttributeNS(Y0,t.slice(6,t.length)):e.setAttributeNS(Y0,t,a):a==null||l&&!R1(a)?e.removeAttribute(t):e.setAttribute(t,l?"":Qe(a)?String(a):a)}function J0(e,t,a,o,n){if(t==="innerHTML"||t==="textContent"){a!=null&&(e[t]=t==="innerHTML"?X1(a):a);return}const l=e.tagName;if(t==="value"&&l!=="PROGRESS"&&!l.includes("-")){const r=l==="OPTION"?e.getAttribute("value")||"":e.value,c=a==null?e.type==="checkbox"?"on":"":String(a);(r!==c||!("_value"in e))&&(e.value=c),a==null&&e.removeAttribute(t),e._value=a;return}let i=!1;if(a===""||a==null){const r=typeof e[t];r==="boolean"?a=R1(a):a==null&&r==="string"?(a="",i=!0):r==="number"&&(a=0,i=!0)}try{e[t]=a}catch{}i&&e.removeAttribute(n||t)}function m3(e,t,a,o){e.addEventListener(t,a,o)}function y7(e,t,a,o){e.removeEventListener(t,a,o)}const Q0=Symbol("_vei");function w7(e,t,a,o,n=null){const l=e[Q0]||(e[Q0]={}),i=l[t];if(o&&i)i.value=o;else{const[r,c]=b7(t);if(o){const p=l[t]=z7(o,n);m3(e,r,p,c)}else i&&(y7(e,r,i,c),l[t]=void 0)}}const e1=/(?:Once|Passive|Capture)$/;function b7(e){let t;if(e1.test(e)){t={};let o;for(;o=e.match(e1);)e=e.slice(0,e.length-o[0].length),t[o[0].toLowerCase()]=!0}return[e[2]===":"?e.slice(3):F1(e.slice(2)),t]}let O2=0;const C7=Promise.resolve(),x7=()=>O2||(C7.then(()=>O2=0),O2=Date.now());function z7(e,t){const a=o=>{if(!o._vts)o._vts=Date.now();else if(o._vts<=a.attached)return;a4(M7(o,a.value),t,5,[o])};return a.value=e,a.attached=x7(),a}function M7(e,t){if(H3(t)){const a=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{a.call(e),e._stopped=!0},t.map(o=>n=>!n._stopped&&o&&o(n))}else return t}const t1=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,S7=(e,t,a,o,n,l)=>{const i=n==="svg";t==="class"?f7(e,o,i):t==="style"?m7(e,a,o):Xe(t)?Je(t)||w7(e,t,a,o,l):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):A7(e,t,o,i))?(J0(e,t,o),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&X0(e,t,o,i,l,t!=="value")):e._isVueCE&&(k7(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!_3(o)))?J0(e,y3(t),o,l,t):(t==="true-value"?e._trueValue=o:t==="false-value"&&(e._falseValue=o),X0(e,t,o,i))};function A7(e,t,a,o){if(o)return!!(t==="innerHTML"||t==="textContent"||t in e&&t1(t)&&q1(a));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const n=e.tagName;if(n==="IMG"||n==="VIDEO"||n==="CANVAS"||n==="SOURCE")return!1}return t1(t)&&_3(a)?!1:t in e}function k7(e,t){const a=e._def.props;if(!a)return!1;const o=y3(t);return Array.isArray(a)?a.some(n=>y3(n)===o):Object.keys(a).some(n=>y3(n)===o)}const u2=e=>{const t=e.props["onUpdate:modelValue"]||!1;return H3(t)?a=>i4(t,a):t};function B7(e){e.target.composing=!0}function a1(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const A3=Symbol("_assign");function o1(e,t,a){return t&&(e=e.trim()),a&&(e=s0(e)),e}const E7={created(e,{modifiers:{lazy:t,trim:a,number:o}},n){e[A3]=u2(n);const l=o||n.props&&n.props.type==="number";m3(e,t?"change":"input",i=>{i.target.composing||e[A3](o1(e.value,a,l))}),(a||l)&&m3(e,"change",()=>{e.value=o1(e.value,a,l)}),t||(m3(e,"compositionstart",B7),m3(e,"compositionend",a1),m3(e,"change",a1))},mounted(e,{value:t}){e.value=t??""},beforeUpdate(e,{value:t,oldValue:a,modifiers:{lazy:o,trim:n,number:l}},i){if(e[A3]=u2(i),e.composing)return;const r=(l||e.type==="number")&&!/^0\d/.test(e.value)?s0(e.value):e.value,c=t??"";if(r===c)return;const p=e.getRootNode();(p instanceof Document||p instanceof ShadowRoot)&&p.activeElement===e&&e.type!=="range"&&(o&&t===a||n&&e.value.trim()===c)||(e.value=c)}},H7={deep:!0,created(e,{value:t,modifiers:{number:a}},o){const n=N1(t);m3(e,"change",()=>{const l=Array.prototype.filter.call(e.options,i=>i.selected).map(i=>a?s0(p2(i)):p2(i));e[A3](e.multiple?n?new Set(l):l:l[0]),e._assigning=!0,f6(()=>{e._assigning=!1})}),e[A3]=u2(o)},mounted(e,{value:t}){n1(e,t)},beforeUpdate(e,t,a){e[A3]=u2(a)},updated(e,{value:t}){e._assigning||n1(e,t)}};function n1(e,t){const a=e.multiple,o=H3(t);if(!(a&&!o&&!N1(t))){for(let n=0,l=e.options.length;n<l;n++){const i=e.options[n],r=p2(i);if(a)if(o){const c=typeof r;c==="string"||c==="number"?i.selected=t.some(p=>String(p)===String(r)):i.selected=o4(t,r)>-1}else i.selected=t.has(r);else if(n4(p2(i),t)){e.selectedIndex!==n&&(e.selectedIndex=n);return}}!a&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function p2(e){return"_value"in e?e._value:e.value}const L7=["ctrl","shift","alt","meta"],V7={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>L7.some(a=>e[`${a}Key`]&&!t.includes(a))},R6=(e,t)=>{if(!e)return e;const a=e._withMods||(e._withMods={}),o=t.join(".");return a[o]||(a[o]=((n,...l)=>{for(let i=0;i<t.length;i++){const r=V7[t[i]];if(r&&r(n,t))return}return e(n,...l)}))},P7=r0({patchProp:S7},i7);let i1;function O7(){return i1||(i1=Ye(P7))}const T7=((...e)=>{const t=O7().createApp(...e),{mount:a}=t;return t.mount=o=>{const n=$7(o);if(!n)return;const l=t._component;!q1(l)&&!l.render&&!l.template&&(l.template=n.innerHTML),n.nodeType===1&&(n.textContent="");const i=a(n,!1,D7(n));return n instanceof Element&&(n.removeAttribute("v-cloak"),n.setAttribute("data-v-app","")),i},t});function D7(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function $7(e){return _3(e)?document.querySelector(e):e}(()=>{var e=`
|
|
3
3
|
<div class="container">
|
|
4
4
|
<div class="screenshot">
|
|
5
5
|
<slot />
|
|
@@ -583,4 +583,4 @@ try {
|
|
|
583
583
|
const target = (await session.inspect()).targets.find(target => target.targetId === ${JSON.stringify(e.target.targetId)});
|
|
584
584
|
console.log(target);
|
|
585
585
|
if (target?.currentInstanceId) console.log(await session.logs({ instanceId: target.currentInstanceId }));
|
|
586
|
-
`}async function G2(e,t,a){const o=await fetch(e,{headers:a,signal:t,redirect:"error",credentials:"same-origin",cache:"no-store"});if(!o.ok)throw new Error(`读取连接信息失败(HTTP ${o.status})`);return o.json().catch(()=>{throw new Error("调试台没有返回有效连接信息")})}function S3(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function R3(e){return typeof e=="string"&&e.length>0}function Z2(e){return e===null||typeof e=="string"}const xn={class:"preview-connection"},zn={key:0,class:"preview-connection__message",role:"status"},Mn=["title"],Sn={key:2,class:"preview-connection__fields"},An={class:"preview-connection__field"},kn={class:"preview-connection__field"},Bn=["title"],En={class:"preview-connection__field"},Hn={key:0,class:"preview-connection__field"},Ln={key:1,class:"preview-connection__field"},Vn=["title"],Pn={key:2,class:"preview-connection__field"},On={class:"preview-connection__field"},Tn=["title"],Dn={key:3,class:"preview-connection__hint"},$n={key:4,class:"preview-connection__hint"},In=j({__name:"PreviewConnectionInfo",setup(e){const t=H(!1),a=H(!1),o=H(!1),n=H(""),l=H(),i=_2();let r,c=0;const p=x(()=>i.value?.browser?.mode==="attached"?"个人浏览器":i.value?.browser?.mode==="isolated"?"临时隔离环境":"尚未打开"),u={unsupported:"不支持原生授权","not-enabled":"未开启 Remote debugging",denied:"原生授权被拒绝",timeout:"原生授权等待超时",unavailable:"个人浏览器不可用"},d=x(()=>i.value?.browser?.fallbackReason?u[i.value.browser.fallbackReason]:"无回退"),f=x(()=>i.value?.browser?.state==="ready"&&!!(i.value.browser.cdpTargetId&&i.value.browser.cdpEndpoint)),h=x(()=>i.value?`${i.value.playwright.version} · ${i.value.playwright.installed?"已安装":"尚未安装"}`:"尚未读取");e6(t,M=>{M?_():v()}),r3(v);function v(){c++,r?.abort(),a.value=!1}async function _(){r?.abort();const M=++c;r=new AbortController,a.value=!0,n.value="",l.value=void 0;try{const y=await wn({targetId:z.diagnosticTargetId,ownerId:z.diagnosticOwnerId},r.signal);return M!==c||!t.value?void 0:(i.value=y,y)}catch(y){M===c&&!r.signal.aborted&&(n.value=y instanceof Error?y.message:"读取连接信息失败")}finally{M===c&&(a.value=!1)}}async function w(){await k("connection")}async function b(){await k("example")}async function k(M){if(!(a.value||o.value||!i.value)){if(!navigator.clipboard){n.value="浏览器未开放剪贴板,请运行 hb-sdk dev inspect";return}o.value=!0;try{const y=await _();if(!y||!t.value)return;await navigator.clipboard.writeText(M==="connection"?JSON.stringify(y,null,2):Cn(y)),t.value&&(l.value=M)}catch{t.value&&(n.value="复制失败,请检查浏览器剪贴板权限")}finally{o.value=!1}}}return(M,y)=>(g(),G(s(Z3),{modelValue:t.value,"onUpdate:modelValue":y[0]||(y[0]=T=>t.value=T),title:"连接信息","trigger-label":"查看连接信息","trigger-test-id":"preview-connection-trigger"},{trigger:E(()=>[q(s(K7),{size:18,"aria-hidden":"true"})]),default:E(()=>[m("div",xn,[a.value?(g(),L("p",zn,"正在读取连接信息…")):Z("",!0),n.value?(g(),L("p",{key:1,class:"preview-connection__message preview-connection__message--error",title:n.value,role:"status"},P(n.value),9,Mn)):Z("",!0),i.value?(g(),L("dl",Sn,[m("div",An,[y[1]||(y[1]=m("dt",null,"本页目标",-1)),m("dd",null,P(i.value.isPrimaryTarget?"主预览":"其他调试页")+" · "+P(i.value.target.metadata.displayName),1)]),m("div",kn,[y[2]||(y[2]=m("dt",null,"项目",-1)),m("dd",{title:i.value.projectRoot},P(i.value.projectRoot),9,Bn)]),m("div",En,[y[3]||(y[3]=m("dt",null,"调试台端口",-1)),m("dd",null,P(i.value.port),1)]),i.value.isPrimaryTarget?(g(),L("div",Hn,[y[4]||(y[4]=m("dt",null,"浏览器模式",-1)),m("dd",null,P(p.value),1)])):Z("",!0),i.value.isPrimaryTarget?(g(),L("div",Ln,[y[5]||(y[5]=m("dt",null,"回退原因",-1)),m("dd",{title:d.value},P(d.value),9,Vn)])):Z("",!0),i.value.isPrimaryTarget?(g(),L("div",Pn,[y[6]||(y[6]=m("dt",null,"调试标签页",-1)),m("dd",null,P(f.value?"已就绪":"尚未就绪"),1)])):Z("",!0),m("div",On,[y[7]||(y[7]=m("dt",null,"控制库",-1)),m("dd",{title:h.value},P(h.value),9,Tn)])])):Z("",!0),q(s(l0),{disabled:a.value||o.value||!i.value,"data-testid":"copy-preview-connection",onSelect:w},{default:E(()=>[h6(P(l.value==="connection"?"已复制连接 JSON":"复制连接 JSON"),1)]),_:1},8,["disabled"]),q(s(l0),{disabled:a.value||o.value||!i.value,"data-testid":"copy-preview-example",onSelect:b},{default:E(()=>[h6(P(l.value==="example"?"已复制本页示例":i.value?.isPrimaryTarget?"复制主预览连接示例":"复制本页诊断示例"),1)]),_:1},8,["disabled"]),i.value?.isPrimaryTarget&&!f.value?(g(),L("p",Dn,"先检查浏览器,再运行 preview open。")):Z("",!0),i.value&&!i.value.isPrimaryTarget?(g(),L("p",$n,"此页仅提供本目标诊断;浏览器交互连接受控主预览。")):Z("",!0),y[8]||(y[8]=m("p",{class:"preview-connection__hint"},"标签页就绪不代表业务加载完成。",-1)),y[9]||(y[9]=m("p",{class:"preview-connection__hint"},"连接信息仅供本机工具,勿公开分享。",-1))])]),_:1},8,["modelValue"]))}}),qn=M0(In,[["__scopeId","data-v-16a48ddc"]]),Rn={key:0,class:"toolbar-badge"},Fn={class:"workbench-log-filters"},Nn=["checked","onChange"],Un=["checked","onChange"],Wn=["disabled"],Gn=j({__name:"WorkbenchLogFilters",props:{activeCount:{},levels:{},sources:{}},emits:["reset","toggle-level","toggle-source"],setup(e,{emit:t}){const a=x({get:()=>z.selectedUploadSession||"all",set:i=>{z.selectedUploadSession=i==="all"?"":i}}),o=x(()=>[{value:"all",label:"全部上传会话"},...z.uploadSessions.map(i=>({value:i.id,label:i.name+" · "+i.id.slice(0,8)+(i.online?"":" · 离线")}))]),n=t,l=H(!1);return(i,r)=>(g(),G(s(Z3),{modelValue:l.value,"onUpdate:modelValue":r[2]||(r[2]=c=>l.value=c),size:"compact",title:"筛选日志","trigger-label":"筛选日志","trigger-test-id":"log-filter-trigger"},{trigger:E(()=>[q(s(at),{size:16,"aria-hidden":"true"}),e.activeCount?(g(),L("span",Rn,P(e.activeCount),1)):Z("",!0)]),default:E(()=>[m("div",Fn,[m("label",null,[r[3]||(r[3]=h6("上传会话 ",-1)),q(s(z0),{modelValue:a.value,"onUpdate:modelValue":r[0]||(r[0]=c=>a.value=c),label:"筛选日志上传会话",options:o.value},null,8,["modelValue","options"])]),m("fieldset",null,[r[4]||(r[4]=m("legend",null,"来源",-1)),(g(!0),L(p6,null,S6(s(Y1),c=>(g(),L("label",{key:c.id},[m("input",{type:"checkbox",checked:e.sources[c.id],onChange:p=>n("toggle-source",c.id)},null,40,Nn),m("span",null,P(c.label),1)]))),128))]),m("fieldset",null,[r[5]||(r[5]=m("legend",null,"级别",-1)),(g(!0),L(p6,null,S6(s(B4),c=>(g(),L("label",{key:c.id},[m("input",{type:"checkbox",checked:e.levels[c.id],onChange:p=>n("toggle-level",c.id)},null,40,Un),m("span",null,P(c.label),1)]))),128))]),m("button",{type:"button",class:"workbench-log-filters__reset",disabled:e.activeCount===0,onClick:r[1]||(r[1]=c=>n("reset"))},"重置",8,Wn)])]),_:1},8,["modelValue"]))}}),Zn=["data-level","data-source"],jn={class:"workbench-log-row__summary"},Kn={class:"workbench-log-row__content"},Yn={class:"workbench-log-row__message"},Xn={class:"workbench-log-row__secondary"},Jn=["datetime"],Qn={class:"workbench-log-row__source"},ei={key:0,class:"workbench-log-row__method"},ti={key:1,class:"workbench-log-row__repeat"},ai={class:"workbench-log-row__details"},oi={class:"workbench-log-row__metadata"},ni={key:0},ii={key:1},li={key:2},ri=j({__name:"WorkbenchLogRow",props:{entry:{}},emits:["copy"],setup(e,{emit:t}){const a=e,o=t,n=x(()=>Y1.find(({id:v})=>v===a.entry.source)?.label??a.entry.source),l=x(()=>a.entry.durationMs===void 0?"":Math.max(0,Math.round(a.entry.durationMs))+" ms"),i=x(()=>a.entry.outcome==="success"?"成功":a.entry.outcome==="error"?"失败":a.entry.outcome==="denied"?"已拒绝":a.entry.outcome==="dropped"?"已丢弃":""),r=x(()=>[a.entry.summary||a.entry.method,i.value,l.value].filter(Boolean).join(" · ")),c=x(()=>{if(a.entry.category==="console"&&h(a.entry.detail)&&"message"in a.entry.detail){const v=a.entry.detail.message;return typeof v=="string"?v:s2(v)||String(v??"")}return s2(a.entry.detail)||"{}"}),p=x(()=>new Date(a.entry.timestamp).toISOString()),u=x(()=>f(a.entry.timestamp)),d=x(()=>s2({uploadSessionId:a.entry.uploadSessionId,uploadSessionName:a.entry.uploadSessionName,targetName:a.entry.targetName,timestamp:a.entry.timestamp,source:a.entry.source,category:a.entry.category,level:a.entry.level,method:a.entry.method,summary:a.entry.summary,outcome:a.entry.outcome,durationMs:a.entry.durationMs,generation:a.entry.generation,callId:a.entry.callId,errorCode:a.entry.errorCode,repeatCount:a.entry.repeatCount,detail:a.entry.detail}));function f(v){const _=new Date(v);return[_.getHours(),_.getMinutes(),_.getSeconds()].map(b=>String(b).padStart(2,"0")).join(":")+"."+String(_.getMilliseconds()).padStart(3,"0")}function h(v){return Object.prototype.toString.call(v)==="[object Object]"}return(v,_)=>(g(),L("details",{class:"workbench-log-row","data-level":e.entry.level,"data-source":e.entry.source},[m("summary",jn,[m("span",Kn,[m("span",Yn,P(r.value),1),m("span",Xn,[m("time",{class:"workbench-log-row__time",datetime:p.value},P(u.value),9,Jn),m("span",Qn,P(e.entry.uploadSessionName||e.entry.targetName||"调试目标")+" · "+P(n.value),1),e.entry.summary?(g(),L("span",ei,P(e.entry.method),1)):Z("",!0),e.entry.repeatCount>1?(g(),L("span",ti,"x"+P(e.entry.repeatCount),1)):Z("",!0)])]),q(s(te),{class:"workbench-log-row__chevron",size:13,"aria-hidden":"true"})]),m("div",ai,[m("div",oi,[m("span",null,P(e.entry.category),1),e.entry.generation!==void 0?(g(),L("span",ni,"generation "+P(e.entry.generation),1)):Z("",!0),e.entry.callId?(g(),L("span",ii,P(e.entry.callId),1)):Z("",!0),e.entry.errorCode?(g(),L("span",li,P(e.entry.errorCode),1)):Z("",!0)]),m("pre",null,P(c.value),1),q(B6,{variant:"ghost",label:"复制日志详情",onClick:_[0]||(_[0]=w=>o("copy",d.value))},{default:E(()=>[q(s(J7),{size:15,"aria-hidden":"true"})]),_:1})])],8,Zn))}}),si=["data-preview-preset","data-preview-orientation","data-preview-runtime","data-preview-width","data-preview-height"],ci={class:"workbench__header"},di={class:"brand"},ui=["src"],pi={key:0,class:"brand__target","data-testid":"preview-owner-label"},fi={class:"workbench__header-actions"},hi={key:0,class:"desktop-launch"},vi={key:0,role:"status"},mi=["src"],gi={key:0,role:"status"},_i={class:"media-simulation",title:"媒体选择模拟开关(media.pick)"},yi=["value"],wi={class:"diagnostics"},bi={class:"mini-program-summary"},Ci={class:"mini-program-summary__icon"},xi=["src"],zi={key:1,class:"mini-program-summary__fallback"},Mi={class:"mini-program-summary__copy"},Si={class:"diagnostics__tabs"},Ai=["data-testid","onClick"],ki={key:0,class:"diagnostics__count"},Bi={class:"diagnostics__toolbar"},Ei={class:"search-field"},Hi=["src"],Li=["placeholder","aria-label"],Vi={class:"diagnostics__toolbar-actions"},Pi=["src"],Oi={key:2,class:"toolbar-badge"},Ti=["src"],Di=["src"],$i=["src"],Ii={key:0,class:"empty-state",role:"status"},qi={class:"diagnostics__content"},Ri={key:0,class:"empty-state"},Fi={id:"storage-snapshot",class:"storage-list"},Ni=["src"],Ui={key:0,class:"empty-state empty-state--error"},Wi={key:1,class:"empty-state"},Gi={class:"problem-list"},Zi={class:"problem-row__content"},ji=["src"],Ki={key:0,class:"empty-state"},Yi=["src"],Xi={key:0,class:"desktop-preview__placeholder","data-testid":"desktop-window-minimized"},Ji={key:1,class:"desktop-preview__placeholder","data-testid":"desktop-window-closed"},Qi={id:"host-overlay-layer",class:"host-overlay-layer","data-testid":"overlay-layer"},el=["data-rotating","data-orientation"],tl={id:"host-overlay-layer",class:"host-overlay-layer","data-testid":"overlay-layer"},al={class:"activity-bar"},ol={class:"activity-status"},nl={class:"activity-account"},il=400,$1=32,I1=16,ll=j({__name:"App",setup(e){const t=[{id:"logs",label:"日志"},{id:"storage",label:"存储"},{id:"sandbox",label:"沙箱"},{id:"problems",label:"问题"}],a=[...H4.map(O=>({value:O.id,label:`${O.label} · ${O.screenWidth} × ${O.screenHeight}`,testId:`preset-${O.id}`})),{value:E4,label:"桌面",testId:"preset-desktop"}],o=H(),n=H(),l=H(),i=H(innerWidth),r=H(1),c=H(!1),p=H(!1),u=H(),d=H(!1),f=H(!1),h=O4,v=j4,_=H(!1);let w=0,b,k=Promise.resolve();const M=Q4(()=>k),y=x(()=>z.display.orientation==="landscape"),T=H(y.value),S=x(()=>y.value?{width:h.value.frameHeight,height:h.value.frameWidth}:{width:h.value.frameWidth,height:h.value.frameHeight}),B=[{id:"production",label:"小黑盒正式版"},{id:"debug",label:"小黑盒 Debug 版"}],D=x(()=>Math.min(45,z.diagnosticsWidth/i.value*100)),I=x(()=>Math.min(45,320/i.value*100)),F=x(()=>Math.min(45,560/i.value*100)),J=x(()=>"搜索"),$=x(()=>({idle:"Browser 未连接",loading:"Browser 连接中",ready:"Browser 已连接",error:"Browser 连接异常",closed:"Browser 已关闭"})[z.runtimeStatus]);function K(O){const U=z.desktopLaunch.address;if(!z.desktopLaunch.ready||!U||!z.desktopLaunch.miniProgramId)return"";try{return Z4({address:U,...z.desktopLaunch.workspaceCardsEnabled&&z.desktopLaunch.devSessionId?{devSessionId:z.desktopLaunch.devSessionId}:{},miniProgramId:z.desktopLaunch.miniProgramId,target:O,...z.desktopLaunch.miniProgramManifestToken?{miniProgramManifestToken:z.desktopLaunch.miniProgramManifestToken}:{}})}catch{return""}}const Q=location.host||"本地",n6=x(()=>z.previewMode==="desktop"),t6=D4,r6=x(()=>z.miniProgram.bound?z.miniProgram.name:"小程序预览"),i6=x(()=>z.desktopLaunch.address?.appUrl||new URL(location.href).searchParams.get("mini_url")||""),s6=H(!1);e6(i6,()=>{s6.value=!1});const $6=x(()=>n6.value?{"--device-toolbar-left":"32px"}:void 0),d3=x(()=>({padding:`${c.value?96:56}px ${$1}px ${I1}px`})),u3=x(()=>{const O=t6.value,U=z.desktopWindow.availableWidth,W=z.desktopWindow.availableHeight,b6=O.height+a2;return!(U>0)||!(W>0)||!(O.width>0)||!(b6>0)?1:Math.min(1,U/O.width,(W+a2)/b6)}),e3=x(()=>n6.value?{screenWidth:t6.value.width,screenHeight:t6.value.height}:v.value),I6=x(()=>({width:`${h.value.frameWidth}px`,height:`${h.value.frameHeight}px`,"--device-frame-asset-width":`${h.value.frameAssetWidth}px`,"--device-frame-asset-height":`${h.value.frameAssetHeight}px`,"--device-frame-scale-x":String(h.value.frameWidth/h.value.frameAssetWidth),"--device-frame-scale-y":String(h.value.frameHeight/h.value.frameAssetHeight),"--mini-program-actions-top":`calc(${h.value.screenRect.top}% + ${h.value.statusBarHeight+6}px)`,"--mini-program-actions-right":`calc(${h.value.screenRect.right}% + 7px)`,"--device-rotation-duration":`${il}ms`,transform:D3.value})),D3=x(()=>{const{frameWidth:O,frameHeight:U}=h.value,W=r.value;return y.value?`translate(${(U*W-O)/2}px, ${(O*W-U)/2}px) rotate(-90deg) scale(${W})`:`translate(${(O*W-O)/2}px, ${(U*W-U)/2}px) rotate(0deg) scale(${W})`}),t2=x(()=>{const{screenWidth:O,screenHeight:U}=h.value;return T.value?{left:`${(O-U)/2}px`,top:`${(U-O)/2}px`,width:`${U}px`,height:`${O}px`,transform:"rotate(90deg)"}:{}}),z6=x(()=>({top:`${h.value.screenRect.top}%`,right:`${h.value.screenRect.right}%`,bottom:`${h.value.screenRect.bottom}%`,left:`${h.value.screenRect.left}%`,borderRadius:`${h.value.screenRadius.x}px / ${h.value.screenRadius.y}px`})),C6=x(()=>({width:`${S.value.width*r.value}px`,height:`${S.value.height*r.value}px`,"--device-scale":String(r.value)}));let l6;const H6=L4(O=>{if(O){u.value=O,d.value=!0;return}d.value=!1});e6(()=>z.logs.length?z.logs[z.logs.length-1].id:0,()=>{z.followLogs&&requestAnimationFrame(x3)}),e6(y,async O=>{k=C(O),await k}),e6(()=>[z.deviceSelectionId,z.desktopWindow.minimized,z.desktopWindow.closed],()=>requestAnimationFrame(A));async function C(O){const U=++w;b?.abort();const W=new AbortController;b=W,_.value=!0,A();try{if(await f6(),await V4([".device-presentation",".device-shell","#device-viewport"].map(b6=>document.querySelector(b6)),W.signal),U!==w)return;T.value=O,_.value=!1,await f6()}catch(b6){if(!W.signal.aborted)throw b6}}e6(()=>z.qrOpen,O=>dispatchEvent(new CustomEvent("hb-sdk:qr-open-change",{detail:{open:O}})),{flush:"post"}),w6(()=>{l6=new ResizeObserver(A),o.value&&l6.observe(o.value),n.value&&l6.observe(n.value),A()}),r3(()=>{w+=1,b?.abort(),M(),l6?.disconnect(),P4(),H6()});function A(){i.value=o.value?.getBoundingClientRect().width||innerWidth;const O=n.value?.getBoundingClientRect();if(!O)return;if(c.value=O.width<1036,n6.value){V(O);return}const U=c.value?96:56;r.value=Math.min((O.width-64)/S.value.width,(O.height-U)/S.value.height,h.value.maxPresentationScale)}function V(O){const U=c.value?96:56,W=Math.max(0,O.width-$1*2),b6=Math.max(0,O.height-U-I1);T4(W,Math.max(0,b6-a2))}function N(){d.value||(u.value=void 0)}function R(){u.value?.kind==="loading"&&u.value.dismissible&&K4()}function Y(O){O.event&&V0(O.panes[0].size/100*i.value)}function a6(){V0(400)}function c6(O){z.activeTab=O,O==="storage"&&S0()}function o6(){L2(!z.followLogs),z.followLogs&&requestAnimationFrame(x3)}function C3(O){const U=O.target,W=U.scrollTop+U.clientHeight>=U.scrollHeight-24;!W&&z.followLogs?L2(!1):W&&!z.followLogs&&(L2(!0),requestAnimationFrame(x3))}function x3(){l.value&&(l.value.scrollTop=l.value.scrollHeight)}function S0(){dispatchEvent(new CustomEvent("hb-sdk:refresh-storage"))}function A0(){P0({command:"reload"}).catch(k0)}function k2(O,U,W=Date.now(),b6="info"){const E2=X4(U);J4.event(void 0,{source:"host",method:O,timestamp:W,level:b6,message:typeof E2.message=="string"?E2.message:JSON.stringify(E2)})}function k0(O){O instanceof Error&&"code"in O&&O.code==="PREVIEW_SUPERSEDED"||k2("preview.action.failed",{message:O instanceof Error?O.message:"调试台动作失败"},Date.now(),"error")}function Te(O,U){const W=K(O);if(!W){U?.preventDefault();return}U?.preventDefault(),window.open(W,"_blank","noopener,noreferrer"),Y4(O),f.value=!1,k2("desktop.open.requested",{address:z.desktopLaunch.address.address,target:O,delivery:"navigation-intent"})}function De(O){typeof O=="string"&&P0({command:"select",preset:O}).catch(k0)}function $e(O){O0(O.width,O.height)}function Ie(O){O0(O.width,O.height,{persist:!0})}function qe(){T0(!0),requestAnimationFrame(A)}function Re(){T0(!1),requestAnimationFrame(A)}function Fe(){D0(!0)}function Ne(){D0(!1),requestAnimationFrame(A)}function Ue(){$0(!0)}function We(){$0(!1),requestAnimationFrame(A)}async function B2(O){await navigator.clipboard?.writeText(O)}async function Ge(){if(!(!i6.value||!navigator.clipboard))try{await navigator.clipboard.writeText(i6.value),s6.value=!0}catch{s6.value=!1,k2("clipboard.write.failed",{message:"复制链接失败,请检查浏览器剪贴板权限"},Date.now(),"warn")}}function Ze(O){return[O.errorCode,`${O.count} 次`].filter(Boolean).join(" · ")}function je(O){const U=O.errorCode??"";return U==="STORAGE_QUOTA_EXCEEDED"?"Storage 写入失败":U.includes("CSP")||O.method==="runtime.security"?"资源加载被阻止":O.method==="network.request"?"network.request 调用失败":O.method}function Ke(O){return O==="session"?"Session Storage":"Local Storage"}return(O,U)=>(g(),G(s(ha),{"delay-duration":300},{default:E(()=>[m("div",{class:m6(["workbench",{"workbench--chrome-hidden":s(z).screenshotChromeHidden}]),"data-testid":"workbench-root","data-preview-preset":s(z).deviceSelectionId,"data-preview-orientation":n6.value?s(t6).width>=s(t6).height?"landscape":"portrait":s(z).display.orientation,"data-preview-runtime":s(z).runtimeStatus,"data-preview-width":e3.value.screenWidth,"data-preview-height":e3.value.screenHeight},[m("header",ci,[m("div",di,[m("img",{class:"brand__logo",src:s(ka),alt:"小黑盒"},null,8,ui),U[6]||(U[6]=m("span",{class:"brand__title"},"小程序工坊调试台",-1)),s(z).diagnosticTargetId?(g(),L("span",pi,P(s(z).diagnosticOwnershipLost?"已失效调试页":s(z).diagnosticTargetId===s(z).diagnosticPrimaryTargetId?"主预览":"其他调试页")+" · "+P(s(z).diagnosticTargetName)+" · "+P(s(z).diagnosticTargetId.slice(-8)),1)):Z("",!0)]),m("div",fi,[q(qn),s(z).miniProgramSupportsDesktop?(g(),L("div",hi,[q(s(Z3),{modelValue:f.value,"onUpdate:modelValue":U[0]||(U[0]=W=>f.value=W),size:"compact",title:"在桌面端打开","trigger-label":"在桌面端打开调试页","trigger-test-id":"desktop-launch-menu-trigger"},{trigger:E(()=>[q(s(ot),{size:18,"aria-hidden":"true"})]),default:E(()=>[s(z).desktopLaunch.ready?Z("",!0):(g(),L("p",vi,P(s(z).desktopLaunch.unavailableReason),1)),(g(),L(p6,null,S6(B,W=>q(s(l0),{key:W.id,href:K(W.id)||void 0,disabled:!K(W.id),selected:s(z).desktopLaunch.target===W.id,onSelect:b6=>Te(W.id,b6)},{default:E(()=>[h6(P(W.label),1)]),_:2},1032,["href","disabled","selected","onSelect"])),64))]),_:1},8,["modelValue"])])):Z("",!0),q(s(Z3),{modelValue:s(z).qrOpen,"onUpdate:modelValue":U[1]||(U[1]=W=>s(z).qrOpen=W),title:"手机扫码调试","trigger-label":"查看手机调试二维码","trigger-test-id":"qr-trigger"},{trigger:E(()=>[m("img",{class:"toolbar-asset toolbar-asset--18",src:s(Ea),alt:""},null,8,mi)]),default:E(()=>[s(z).devReadiness?.mobile.state!=="ready"?(g(),L("p",gi,P(s(z).devReadiness?.mobile.reason||"手机调试尚未就绪"),1)):Z("",!0),U[7]||(U[7]=m("img",{id:"mobile-qr-image",class:"qr-popover__image",alt:"手机扫码调试二维码"},null,-1)),U[8]||(U[8]=m("label",{class:"qr-popover__field"},[m("span",null,"局域网"),m("select",{id:"mobile-lan-select"})],-1)),q(s(h0),{id:"mobile-qr-status","aria-live":"polite"})]),_:1},8,["modelValue"]),m("label",_i,[U[9]||(U[9]=m("span",null,"媒体",-1)),K6(m("select",{"onUpdate:modelValue":U[2]||(U[2]=W=>s(z).mediaSimulation=W),"aria-label":"媒体选择模拟","data-testid":"media-simulation-select"},[(g(!0),L(p6,null,S6(s($4),W=>(g(),L("option",{key:W,value:W},P(s(I4)[W]),9,yi))),128))],512),[[H7,s(z).mediaSimulation]])])])]),m("main",{ref_key:"mainEl",ref:o,class:"workbench__main"},[q(s(Aa),{"maximize-panes":!1,"keyboard-step":1,onResized:Y,onSplitterDblclick:a6},{default:E(()=>[q(s(L1),{size:D.value,"min-size":I.value,"max-size":F.value},{default:E(()=>[m("aside",wi,[m("div",bi,[m("div",Ci,[s(z).miniProgram.iconUrl&&!p.value?(g(),L("img",{key:0,src:s(z).miniProgram.iconUrl,alt:"",onError:U[3]||(U[3]=W=>p.value=!0)},null,40,xi)):(g(),L("span",zi,"UI"))]),m("div",Mi,[m("strong",null,P(s(z).miniProgram.name),1),m("span",null,P(s(z).miniProgram.detail||"本地调试"),1)])]),m("nav",Si,[(g(),L(p6,null,S6(t,W=>m("button",{key:W.id,class:m6([`diagnostics__tab--${W.id}`,{active:s(z).activeTab===W.id}]),"data-testid":`diagnostics-tab-${W.id}`,onClick:b6=>c6(W.id)},[h6(P(W.label),1),W.id==="problems"&&s(B0).length?(g(),L("span",ki,P(s(B0).length),1)):Z("",!0)],10,Ai)),64))]),m("div",Bi,[m("label",Ei,[m("img",{class:"toolbar-asset toolbar-asset--12",src:s(Ha),alt:""},null,8,Hi),K6(m("input",{"onUpdate:modelValue":U[4]||(U[4]=W=>s(z).queries[s(z).activeTab]=W),type:"search",placeholder:J.value,"aria-label":J.value},null,8,Li),[[E7,s(z).queries[s(z).activeTab]]])]),m("div",Vi,[s(z).activeTab==="logs"?(g(),G(s(Gn),{key:0,"active-count":s(N4),levels:s(z).logFilters.levels,sources:s(z).logFilters.sources,onReset:s(F4),onToggleLevel:s(R4),onToggleSource:s(q4)},null,8,["active-count","levels","sources","onReset","onToggleLevel","onToggleSource"])):Z("",!0),s(z).activeTab==="logs"?(g(),G(s(B6),{key:1,label:s(z).followLogs?"暂停跟随":"继续跟随","data-testid":"log-follow-toggle",onClick:o6},{default:E(()=>[s(z).followLogs?(g(),L("img",{key:0,class:"toolbar-asset toolbar-asset--18",src:s(Ba),alt:""},null,8,Pi)):(g(),G(s(nt),{key:1,size:15})),!s(z).followLogs&&s(z).pausedLogCount?(g(),L("span",Oi,P(s(z).pausedLogCount),1)):Z("",!0)]),_:1},8,["label"])):Z("",!0),s(z).activeTab==="logs"?(g(),G(s(B6),{key:2,label:"清空日志",onClick:s(U4)},{default:E(()=>[m("img",{class:"toolbar-asset toolbar-asset--18",src:s(V1),alt:""},null,8,Ti)]),_:1},8,["onClick"])):Z("",!0),s(z).activeTab==="storage"?(g(),G(s(B6),{key:3,label:"刷新 Storage",onClick:S0},{default:E(()=>[m("img",{class:"toolbar-asset toolbar-asset--18",src:s(O1),alt:""},null,8,Di)]),_:1})):Z("",!0),s(z).activeTab==="problems"?(g(),G(s(B6),{key:4,label:"清空问题","data-testid":"clear-problems",onClick:s(W4)},{default:E(()=>[m("img",{class:"toolbar-asset toolbar-asset--18",src:s(V1),alt:""},null,8,$i)]),_:1},8,["onClick"])):Z("",!0)])]),s(z).diagnosticsStale||s(z).diagnosticsGap||s(z).diagnosticsDropped?(g(),L("p",Ii,P(s(z).diagnosticsStale?"诊断服务暂不可达,当前为已接收的历史记录。":"")+" "+P(s(z).diagnosticsGap?"部分记录已超出服务缓冲,存在日志缺口。":"")+" "+P(s(z).diagnosticsDropped?`Host 发送缓冲已丢弃 ${s(z).diagnosticsDropped} 条诊断。`:""),1)):Z("",!0),m("section",qi,[s(z).activeTab==="sandbox"?(g(),G(yn,{key:0})):Z("",!0),K6(m("div",{ref_key:"logEl",ref:l,id:"logs",class:"log-list",onScroll:C3},[(g(!0),L(p6,null,S6(s(E0),W=>(g(),G(s(ri),{key:W.id,entry:W,onCopy:B2},null,8,["entry"]))),128)),s(E0).length?Z("",!0):(g(),L("p",Ri,"暂无日志"))],544),[[g3,s(z).activeTab==="logs"]]),K6(m("div",Fi,[(g(!0),L(p6,null,S6(s(H0),W=>(g(),L("details",{key:`${W.area}:${W.key}`,class:"storage-row"},[m("summary",null,[m("span",null,[m("strong",null,P(W.key),1),m("small",null,P(Ke(W.area))+" · "+P(W.bytes)+" B",1)]),q(s(B6),{label:"复制 Storage 值","data-testid":"copy-storage-value",onClick:R6(b6=>B2(W.serializedValue),["prevent"])},{default:E(()=>[m("img",{class:"toolbar-asset toolbar-asset--16",src:s(P1),alt:""},null,8,Ni)]),_:1},8,["onClick"])]),m("code",null,P(W.serializedValue),1)]))),128)),s(z).storageError?(g(),L("p",Ui,P(s(z).storageError),1)):s(H0).length?Z("",!0):(g(),L("p",Wi,"暂无 Storage 数据"))],512),[[g3,s(z).activeTab==="storage"]]),K6(m("div",Gi,[U[11]||(U[11]=m("div",{id:"csp-violations",class:"csp-violations",hidden:""},[m("strong",null,"网络或资源请求已被 CSP 阻止")],-1)),(g(!0),L(p6,null,S6(s(L0),W=>(g(),L("div",{key:W.id,class:"problem-row"},[U[10]||(U[10]=m("span",{class:"problem-row__indicator","aria-hidden":"true"},null,-1)),m("span",Zi,[m("strong",null,P(je(W)),1),m("small",null,P(Ze(W)),1)]),q(s(B6),{variant:"ghost",label:"复制问题详情",onClick:b6=>B2(s(s2)(W.detail))},{default:E(()=>[m("img",{class:"toolbar-asset toolbar-asset--16",src:s(P1),alt:""},null,8,ji)]),_:1},8,["onClick"])]))),128)),s(L0).length?Z("",!0):(g(),L("p",Ki,"未发现问题"))],512),[[g3,s(z).activeTab==="problems"]])])])]),_:1},8,["size","min-size","max-size"]),q(s(L1),null,{default:E(()=>[m("section",{ref_key:"stageEl",ref:n,class:m6(["device-stage",[`device-stage--${s(h).id}`,{"device-stage--compact":c.value}]]),style:y6({"--device-toolbar-left":`${s(h).toolbarLeft}px`})},[m("div",{class:"device-stage__toolbar",style:y6($6.value)},[q(s(z0),{open:s(z).deviceSelectOpen,"onUpdate:open":U[5]||(U[5]=W=>s(z).deviceSelectOpen=W),"model-value":s(z).deviceSelectionId,options:a,label:"选择屏幕尺寸",variant:"glass","test-id":"device-preset-trigger",class:"device-select","onUpdate:modelValue":De},{prefix:E(()=>[...U[12]||(U[12]=[h6("屏幕",-1)])]),_:1},8,["open","model-value"]),q(s(B6),{variant:"glass",label:"重新启动小程序","data-testid":"runtime-restart",onClick:A0},{default:E(()=>[m("img",{class:"toolbar-asset toolbar-asset--18",src:s(O1),alt:""},null,8,Yi)]),_:1})],4),n6.value?(g(),L("div",{key:0,class:"desktop-preview",style:y6(d3.value),"data-testid":"desktop-preview"},[s(z).desktopWindow.minimized?(g(),L("div",Xi,[U[13]||(U[13]=m("p",null,"窗口已最小化,运行实例仍在",-1)),m("button",{type:"button",class:"desktop-preview__action","data-testid":"desktop-window-restore",onClick:Ne}," 恢复窗口 ")])):s(z).desktopWindow.closed?(g(),L("div",Ji,[U[14]||(U[14]=m("p",null,"窗口已关闭,运行实例已销毁",-1)),m("button",{type:"button",class:"desktop-preview__action","data-testid":"desktop-window-reopen",onClick:We}," 重新打开 ")])):Z("",!0),K6(q(yo,{"data-preview-target":"device","data-rotating":"false",width:s(t6).width,height:s(t6).height,"min-width":s(z).desktopWindow.minWidth,"min-height":s(z).desktopWindow.minHeight,resizable:s(z).desktopWindow.resizable,maximized:s(z).desktopWindow.maximized,scale:u3.value,title:r6.value,"icon-url":s(z).miniProgram.iconUrl,detail:s(z).miniProgram.detail,"can-copy-link":!!i6.value,"link-copied":s6.value,"title-bar-height":s(a2),onResize:$e,onResizeEnd:Ie,onMaximize:qe,onRestore:Re,onMinimize:Fe,onClose:Ue,onRefresh:A0,onCopyLink:Ge},{default:E(()=>[U[15]||(U[15]=m("div",{id:"device",class:"device-content desktop-preview__device"},null,-1)),m("div",Qi,[q(D1,{feedback:u.value,visible:d.value,onDismissLoading:R,onAfterLeave:N},null,8,["feedback","visible"])])]),_:1},8,["width","height","min-width","min-height","resizable","maximized","scale","title","icon-url","detail","can-copy-link","link-copied","title-bar-height"]),[[g3,!s(z).desktopWindow.minimized&&!s(z).desktopWindow.closed]])],4)):(g(),L("div",{key:1,class:m6(["device-presentation",{"device-presentation--rotating":_.value}]),style:y6(C6.value)},[m("div",{class:m6(["device-shell",`device-shell--${s(h).platform}`]),"data-testid":"preview-device","data-preview-target":"device","data-rotating":String(_.value),"data-orientation":s(z).display.orientation,style:y6(I6.value)},[m("div",{class:"device-screen","data-testid":"device-screen","data-preview-target":"screen",style:y6(z6.value)},[m("div",{id:"device-viewport",class:"device-viewport","data-testid":"device-viewport",style:y6(t2.value)},[U[16]||(U[16]=m("div",{id:"device",class:"device-content"},null,-1)),m("div",tl,[q(D1,{feedback:u.value,visible:d.value,onDismissLoading:R,onAfterLeave:N},null,8,["feedback","visible"])]),q(Mo,{platform:s(h).platform},null,8,["platform"]),U[17]||(U[17]=m("div",{id:"host-fullscreen-exit-mount",class:"host-fullscreen-exit-mount"},null,-1))],4)],4),q(xo,{"foreground-style":s(z).navigationBarStyle,platform:s(h).platform,"capsule-hidden":s(z).display.capsuleHidden,"status-bar-hidden":s(z).display.capsuleHidden||y.value},null,8,["foreground-style","platform","capsule-hidden","status-bar-hidden"])],14,el)],6))],6)]),_:1})]),_:1})],512),m("footer",al,[m("div",null,[m("span",ol,[m("i",{class:m6(`activity-status--${s(z).runtimeStatus}`)},null,2),h6(P($.value),1)]),m("span",null,P(s(Q)),1),m("span",null,P(e3.value.screenWidth)+" × "+P(e3.value.screenHeight),1)]),m("div",null,[q(an,{entries:s(z).localPermissions,"context-warning":s(z).devContextWarning,"mini-program-id":s(z).miniProgram.id,"open-platform-base-url":s(z).openPlatformBaseUrl},null,8,["entries","context-warning","mini-program-id","open-platform-base-url"]),m("span",null,"hb-sdk "+P(s(G4)),1),m("span",nl,[q(s(Y2),{size:18,src:s(z).account.avatar,alt:s(z).account.nickname,"logged-out":!s(z).account.authenticated},null,8,["src","alt","logged-out"]),h6(P(s(z).account.nickname),1)])])])],10,si)]),_:1}))}});document.documentElement.dataset.hbTheme="light";T7(ll).mount("#app");await a7(()=>import("./browser-dev-host-C0_lx52X.js"),__vite__mapDeps([0,1]));
|
|
586
|
+
`}async function G2(e,t,a){const o=await fetch(e,{headers:a,signal:t,redirect:"error",credentials:"same-origin",cache:"no-store"});if(!o.ok)throw new Error(`读取连接信息失败(HTTP ${o.status})`);return o.json().catch(()=>{throw new Error("调试台没有返回有效连接信息")})}function S3(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function R3(e){return typeof e=="string"&&e.length>0}function Z2(e){return e===null||typeof e=="string"}const xn={class:"preview-connection"},zn={key:0,class:"preview-connection__message",role:"status"},Mn=["title"],Sn={key:2,class:"preview-connection__fields"},An={class:"preview-connection__field"},kn={class:"preview-connection__field"},Bn=["title"],En={class:"preview-connection__field"},Hn={key:0,class:"preview-connection__field"},Ln={key:1,class:"preview-connection__field"},Vn=["title"],Pn={key:2,class:"preview-connection__field"},On={class:"preview-connection__field"},Tn=["title"],Dn={key:3,class:"preview-connection__hint"},$n={key:4,class:"preview-connection__hint"},In=j({__name:"PreviewConnectionInfo",setup(e){const t=H(!1),a=H(!1),o=H(!1),n=H(""),l=H(),i=_2();let r,c=0;const p=x(()=>i.value?.browser?.mode==="attached"?"个人浏览器":i.value?.browser?.mode==="isolated"?"临时隔离环境":"尚未打开"),u={unsupported:"不支持原生授权","not-enabled":"未开启 Remote debugging",denied:"原生授权被拒绝",timeout:"原生授权等待超时",unavailable:"个人浏览器不可用"},d=x(()=>i.value?.browser?.fallbackReason?u[i.value.browser.fallbackReason]:"无回退"),f=x(()=>i.value?.browser?.state==="ready"&&!!(i.value.browser.cdpTargetId&&i.value.browser.cdpEndpoint)),h=x(()=>i.value?`${i.value.playwright.version} · ${i.value.playwright.installed?"已安装":"尚未安装"}`:"尚未读取");e6(t,M=>{M?_():v()}),r3(v);function v(){c++,r?.abort(),a.value=!1}async function _(){r?.abort();const M=++c;r=new AbortController,a.value=!0,n.value="",l.value=void 0;try{const y=await wn({targetId:z.diagnosticTargetId,ownerId:z.diagnosticOwnerId},r.signal);return M!==c||!t.value?void 0:(i.value=y,y)}catch(y){M===c&&!r.signal.aborted&&(n.value=y instanceof Error?y.message:"读取连接信息失败")}finally{M===c&&(a.value=!1)}}async function w(){await k("connection")}async function b(){await k("example")}async function k(M){if(!(a.value||o.value||!i.value)){if(!navigator.clipboard){n.value="浏览器未开放剪贴板,请运行 hb-sdk dev inspect";return}o.value=!0;try{const y=await _();if(!y||!t.value)return;await navigator.clipboard.writeText(M==="connection"?JSON.stringify(y,null,2):Cn(y)),t.value&&(l.value=M)}catch{t.value&&(n.value="复制失败,请检查浏览器剪贴板权限")}finally{o.value=!1}}}return(M,y)=>(g(),G(s(Z3),{modelValue:t.value,"onUpdate:modelValue":y[0]||(y[0]=T=>t.value=T),title:"连接信息","trigger-label":"查看连接信息","trigger-test-id":"preview-connection-trigger"},{trigger:E(()=>[q(s(K7),{size:18,"aria-hidden":"true"})]),default:E(()=>[m("div",xn,[a.value?(g(),L("p",zn,"正在读取连接信息…")):Z("",!0),n.value?(g(),L("p",{key:1,class:"preview-connection__message preview-connection__message--error",title:n.value,role:"status"},P(n.value),9,Mn)):Z("",!0),i.value?(g(),L("dl",Sn,[m("div",An,[y[1]||(y[1]=m("dt",null,"本页目标",-1)),m("dd",null,P(i.value.isPrimaryTarget?"主预览":"其他调试页")+" · "+P(i.value.target.metadata.displayName),1)]),m("div",kn,[y[2]||(y[2]=m("dt",null,"项目",-1)),m("dd",{title:i.value.projectRoot},P(i.value.projectRoot),9,Bn)]),m("div",En,[y[3]||(y[3]=m("dt",null,"调试台端口",-1)),m("dd",null,P(i.value.port),1)]),i.value.isPrimaryTarget?(g(),L("div",Hn,[y[4]||(y[4]=m("dt",null,"浏览器模式",-1)),m("dd",null,P(p.value),1)])):Z("",!0),i.value.isPrimaryTarget?(g(),L("div",Ln,[y[5]||(y[5]=m("dt",null,"回退原因",-1)),m("dd",{title:d.value},P(d.value),9,Vn)])):Z("",!0),i.value.isPrimaryTarget?(g(),L("div",Pn,[y[6]||(y[6]=m("dt",null,"调试标签页",-1)),m("dd",null,P(f.value?"已就绪":"尚未就绪"),1)])):Z("",!0),m("div",On,[y[7]||(y[7]=m("dt",null,"控制库",-1)),m("dd",{title:h.value},P(h.value),9,Tn)])])):Z("",!0),q(s(l0),{disabled:a.value||o.value||!i.value,"data-testid":"copy-preview-connection",onSelect:w},{default:E(()=>[h6(P(l.value==="connection"?"已复制连接 JSON":"复制连接 JSON"),1)]),_:1},8,["disabled"]),q(s(l0),{disabled:a.value||o.value||!i.value,"data-testid":"copy-preview-example",onSelect:b},{default:E(()=>[h6(P(l.value==="example"?"已复制本页示例":i.value?.isPrimaryTarget?"复制主预览连接示例":"复制本页诊断示例"),1)]),_:1},8,["disabled"]),i.value?.isPrimaryTarget&&!f.value?(g(),L("p",Dn,"先检查浏览器,再运行 preview open。")):Z("",!0),i.value&&!i.value.isPrimaryTarget?(g(),L("p",$n,"此页仅提供本目标诊断;浏览器交互连接受控主预览。")):Z("",!0),y[8]||(y[8]=m("p",{class:"preview-connection__hint"},"标签页就绪不代表业务加载完成。",-1)),y[9]||(y[9]=m("p",{class:"preview-connection__hint"},"连接信息仅供本机工具,勿公开分享。",-1))])]),_:1},8,["modelValue"]))}}),qn=M0(In,[["__scopeId","data-v-16a48ddc"]]),Rn={key:0,class:"toolbar-badge"},Fn={class:"workbench-log-filters"},Nn=["checked","onChange"],Un=["checked","onChange"],Wn=["disabled"],Gn=j({__name:"WorkbenchLogFilters",props:{activeCount:{},levels:{},sources:{}},emits:["reset","toggle-level","toggle-source"],setup(e,{emit:t}){const a=x({get:()=>z.selectedUploadSession||"all",set:i=>{z.selectedUploadSession=i==="all"?"":i}}),o=x(()=>[{value:"all",label:"全部上传会话"},...z.uploadSessions.map(i=>({value:i.id,label:i.name+" · "+i.id.slice(0,8)+(i.online?"":" · 离线")}))]),n=t,l=H(!1);return(i,r)=>(g(),G(s(Z3),{modelValue:l.value,"onUpdate:modelValue":r[2]||(r[2]=c=>l.value=c),size:"compact",title:"筛选日志","trigger-label":"筛选日志","trigger-test-id":"log-filter-trigger"},{trigger:E(()=>[q(s(at),{size:16,"aria-hidden":"true"}),e.activeCount?(g(),L("span",Rn,P(e.activeCount),1)):Z("",!0)]),default:E(()=>[m("div",Fn,[m("label",null,[r[3]||(r[3]=h6("上传会话 ",-1)),q(s(z0),{modelValue:a.value,"onUpdate:modelValue":r[0]||(r[0]=c=>a.value=c),label:"筛选日志上传会话",options:o.value},null,8,["modelValue","options"])]),m("fieldset",null,[r[4]||(r[4]=m("legend",null,"来源",-1)),(g(!0),L(p6,null,S6(s(Y1),c=>(g(),L("label",{key:c.id},[m("input",{type:"checkbox",checked:e.sources[c.id],onChange:p=>n("toggle-source",c.id)},null,40,Nn),m("span",null,P(c.label),1)]))),128))]),m("fieldset",null,[r[5]||(r[5]=m("legend",null,"级别",-1)),(g(!0),L(p6,null,S6(s(B4),c=>(g(),L("label",{key:c.id},[m("input",{type:"checkbox",checked:e.levels[c.id],onChange:p=>n("toggle-level",c.id)},null,40,Un),m("span",null,P(c.label),1)]))),128))]),m("button",{type:"button",class:"workbench-log-filters__reset",disabled:e.activeCount===0,onClick:r[1]||(r[1]=c=>n("reset"))},"重置",8,Wn)])]),_:1},8,["modelValue"]))}}),Zn=["data-level","data-source"],jn={class:"workbench-log-row__summary"},Kn={class:"workbench-log-row__content"},Yn={class:"workbench-log-row__message"},Xn={class:"workbench-log-row__secondary"},Jn=["datetime"],Qn={class:"workbench-log-row__source"},ei={key:0,class:"workbench-log-row__method"},ti={key:1,class:"workbench-log-row__repeat"},ai={class:"workbench-log-row__details"},oi={class:"workbench-log-row__metadata"},ni={key:0},ii={key:1},li={key:2},ri=j({__name:"WorkbenchLogRow",props:{entry:{}},emits:["copy"],setup(e,{emit:t}){const a=e,o=t,n=x(()=>Y1.find(({id:v})=>v===a.entry.source)?.label??a.entry.source),l=x(()=>a.entry.durationMs===void 0?"":Math.max(0,Math.round(a.entry.durationMs))+" ms"),i=x(()=>a.entry.outcome==="success"?"成功":a.entry.outcome==="error"?"失败":a.entry.outcome==="denied"?"已拒绝":a.entry.outcome==="dropped"?"已丢弃":""),r=x(()=>[a.entry.summary||a.entry.method,i.value,l.value].filter(Boolean).join(" · ")),c=x(()=>{if(a.entry.category==="console"&&h(a.entry.detail)&&"message"in a.entry.detail){const v=a.entry.detail.message;return typeof v=="string"?v:s2(v)||String(v??"")}return s2(a.entry.detail)||"{}"}),p=x(()=>new Date(a.entry.timestamp).toISOString()),u=x(()=>f(a.entry.timestamp)),d=x(()=>s2({uploadSessionId:a.entry.uploadSessionId,uploadSessionName:a.entry.uploadSessionName,targetName:a.entry.targetName,timestamp:a.entry.timestamp,source:a.entry.source,category:a.entry.category,level:a.entry.level,method:a.entry.method,summary:a.entry.summary,outcome:a.entry.outcome,durationMs:a.entry.durationMs,generation:a.entry.generation,callId:a.entry.callId,errorCode:a.entry.errorCode,repeatCount:a.entry.repeatCount,detail:a.entry.detail}));function f(v){const _=new Date(v);return[_.getHours(),_.getMinutes(),_.getSeconds()].map(b=>String(b).padStart(2,"0")).join(":")+"."+String(_.getMilliseconds()).padStart(3,"0")}function h(v){return Object.prototype.toString.call(v)==="[object Object]"}return(v,_)=>(g(),L("details",{class:"workbench-log-row","data-level":e.entry.level,"data-source":e.entry.source},[m("summary",jn,[m("span",Kn,[m("span",Yn,P(r.value),1),m("span",Xn,[m("time",{class:"workbench-log-row__time",datetime:p.value},P(u.value),9,Jn),m("span",Qn,P(e.entry.uploadSessionName||e.entry.targetName||"调试目标")+" · "+P(n.value),1),e.entry.summary?(g(),L("span",ei,P(e.entry.method),1)):Z("",!0),e.entry.repeatCount>1?(g(),L("span",ti,"x"+P(e.entry.repeatCount),1)):Z("",!0)])]),q(s(te),{class:"workbench-log-row__chevron",size:13,"aria-hidden":"true"})]),m("div",ai,[m("div",oi,[m("span",null,P(e.entry.category),1),e.entry.generation!==void 0?(g(),L("span",ni,"generation "+P(e.entry.generation),1)):Z("",!0),e.entry.callId?(g(),L("span",ii,P(e.entry.callId),1)):Z("",!0),e.entry.errorCode?(g(),L("span",li,P(e.entry.errorCode),1)):Z("",!0)]),m("pre",null,P(c.value),1),q(B6,{variant:"ghost",label:"复制日志详情",onClick:_[0]||(_[0]=w=>o("copy",d.value))},{default:E(()=>[q(s(J7),{size:15,"aria-hidden":"true"})]),_:1})])],8,Zn))}}),si=["data-preview-preset","data-preview-orientation","data-preview-runtime","data-preview-width","data-preview-height"],ci={class:"workbench__header"},di={class:"brand"},ui=["src"],pi={key:0,class:"brand__target","data-testid":"preview-owner-label"},fi={class:"workbench__header-actions"},hi={key:0,class:"desktop-launch"},vi={key:0,role:"status"},mi=["src"],gi={key:0,role:"status"},_i={class:"media-simulation",title:"媒体选择模拟开关(media.pick)"},yi=["value"],wi={class:"diagnostics"},bi={class:"mini-program-summary"},Ci={class:"mini-program-summary__icon"},xi=["src"],zi={key:1,class:"mini-program-summary__fallback"},Mi={class:"mini-program-summary__copy"},Si={class:"diagnostics__tabs"},Ai=["data-testid","onClick"],ki={key:0,class:"diagnostics__count"},Bi={class:"diagnostics__toolbar"},Ei={class:"search-field"},Hi=["src"],Li=["placeholder","aria-label"],Vi={class:"diagnostics__toolbar-actions"},Pi=["src"],Oi={key:2,class:"toolbar-badge"},Ti=["src"],Di=["src"],$i=["src"],Ii={key:0,class:"empty-state",role:"status"},qi={class:"diagnostics__content"},Ri={key:0,class:"empty-state"},Fi={id:"storage-snapshot",class:"storage-list"},Ni=["src"],Ui={key:0,class:"empty-state empty-state--error"},Wi={key:1,class:"empty-state"},Gi={class:"problem-list"},Zi={class:"problem-row__content"},ji=["src"],Ki={key:0,class:"empty-state"},Yi=["src"],Xi={key:0,class:"desktop-preview__placeholder","data-testid":"desktop-window-minimized"},Ji={key:1,class:"desktop-preview__placeholder","data-testid":"desktop-window-closed"},Qi={id:"host-overlay-layer",class:"host-overlay-layer","data-testid":"overlay-layer"},el=["data-rotating","data-orientation"],tl={id:"host-overlay-layer",class:"host-overlay-layer","data-testid":"overlay-layer"},al={class:"activity-bar"},ol={class:"activity-status"},nl={class:"activity-account"},il=400,$1=32,I1=16,ll=j({__name:"App",setup(e){const t=[{id:"logs",label:"日志"},{id:"storage",label:"存储"},{id:"sandbox",label:"沙箱"},{id:"problems",label:"问题"}],a=[...H4.map(O=>({value:O.id,label:`${O.label} · ${O.screenWidth} × ${O.screenHeight}`,testId:`preset-${O.id}`})),{value:E4,label:"桌面",testId:"preset-desktop"}],o=H(),n=H(),l=H(),i=H(innerWidth),r=H(1),c=H(!1),p=H(!1),u=H(),d=H(!1),f=H(!1),h=O4,v=j4,_=H(!1);let w=0,b,k=Promise.resolve();const M=Q4(()=>k),y=x(()=>z.display.orientation==="landscape"),T=H(y.value),S=x(()=>y.value?{width:h.value.frameHeight,height:h.value.frameWidth}:{width:h.value.frameWidth,height:h.value.frameHeight}),B=[{id:"production",label:"小黑盒正式版"},{id:"debug",label:"小黑盒 Debug 版"}],D=x(()=>Math.min(45,z.diagnosticsWidth/i.value*100)),I=x(()=>Math.min(45,320/i.value*100)),F=x(()=>Math.min(45,560/i.value*100)),J=x(()=>"搜索"),$=x(()=>({idle:"Browser 未连接",loading:"Browser 连接中",ready:"Browser 已连接",error:"Browser 连接异常",closed:"Browser 已关闭"})[z.runtimeStatus]);function K(O){const U=z.desktopLaunch.address;if(!z.desktopLaunch.ready||!U||!z.desktopLaunch.miniProgramId)return"";try{return Z4({address:U,...z.desktopLaunch.workspaceCardsEnabled&&z.desktopLaunch.devSessionId?{devSessionId:z.desktopLaunch.devSessionId}:{},miniProgramId:z.desktopLaunch.miniProgramId,target:O,...z.desktopLaunch.miniProgramManifestToken?{miniProgramManifestToken:z.desktopLaunch.miniProgramManifestToken}:{}})}catch{return""}}const Q=location.host||"本地",n6=x(()=>z.previewMode==="desktop"),t6=D4,r6=x(()=>z.miniProgram.bound?z.miniProgram.name:"小程序预览"),i6=x(()=>z.desktopLaunch.address?.appUrl||new URL(location.href).searchParams.get("mini_url")||""),s6=H(!1);e6(i6,()=>{s6.value=!1});const $6=x(()=>n6.value?{"--device-toolbar-left":"32px"}:void 0),d3=x(()=>({padding:`${c.value?96:56}px ${$1}px ${I1}px`})),u3=x(()=>{const O=t6.value,U=z.desktopWindow.availableWidth,W=z.desktopWindow.availableHeight,b6=O.height+a2;return!(U>0)||!(W>0)||!(O.width>0)||!(b6>0)?1:Math.min(1,U/O.width,(W+a2)/b6)}),e3=x(()=>n6.value?{screenWidth:t6.value.width,screenHeight:t6.value.height}:v.value),I6=x(()=>({width:`${h.value.frameWidth}px`,height:`${h.value.frameHeight}px`,"--device-frame-asset-width":`${h.value.frameAssetWidth}px`,"--device-frame-asset-height":`${h.value.frameAssetHeight}px`,"--device-frame-scale-x":String(h.value.frameWidth/h.value.frameAssetWidth),"--device-frame-scale-y":String(h.value.frameHeight/h.value.frameAssetHeight),"--mini-program-actions-top":`calc(${h.value.screenRect.top}% + ${h.value.statusBarHeight+6}px)`,"--mini-program-actions-right":`calc(${h.value.screenRect.right}% + 7px)`,"--device-rotation-duration":`${il}ms`,transform:D3.value})),D3=x(()=>{const{frameWidth:O,frameHeight:U}=h.value,W=r.value;return y.value?`translate(${(U*W-O)/2}px, ${(O*W-U)/2}px) rotate(-90deg) scale(${W})`:`translate(${(O*W-O)/2}px, ${(U*W-U)/2}px) rotate(0deg) scale(${W})`}),t2=x(()=>{const{screenWidth:O,screenHeight:U}=h.value;return T.value?{left:`${(O-U)/2}px`,top:`${(U-O)/2}px`,width:`${U}px`,height:`${O}px`,transform:"rotate(90deg)"}:{}}),z6=x(()=>({top:`${h.value.screenRect.top}%`,right:`${h.value.screenRect.right}%`,bottom:`${h.value.screenRect.bottom}%`,left:`${h.value.screenRect.left}%`,borderRadius:`${h.value.screenRadius.x}px / ${h.value.screenRadius.y}px`})),C6=x(()=>({width:`${S.value.width*r.value}px`,height:`${S.value.height*r.value}px`,"--device-scale":String(r.value)}));let l6;const H6=L4(O=>{if(O){u.value=O,d.value=!0;return}d.value=!1});e6(()=>z.logs.length?z.logs[z.logs.length-1].id:0,()=>{z.followLogs&&requestAnimationFrame(x3)}),e6(y,async O=>{k=C(O),await k}),e6(()=>[z.deviceSelectionId,z.desktopWindow.minimized,z.desktopWindow.closed],()=>requestAnimationFrame(A));async function C(O){const U=++w;b?.abort();const W=new AbortController;b=W,_.value=!0,A();try{if(await f6(),await V4([".device-presentation",".device-shell","#device-viewport"].map(b6=>document.querySelector(b6)),W.signal),U!==w)return;T.value=O,_.value=!1,await f6()}catch(b6){if(!W.signal.aborted)throw b6}}e6(()=>z.qrOpen,O=>dispatchEvent(new CustomEvent("hb-sdk:qr-open-change",{detail:{open:O}})),{flush:"post"}),w6(()=>{l6=new ResizeObserver(A),o.value&&l6.observe(o.value),n.value&&l6.observe(n.value),A()}),r3(()=>{w+=1,b?.abort(),M(),l6?.disconnect(),P4(),H6()});function A(){i.value=o.value?.getBoundingClientRect().width||innerWidth;const O=n.value?.getBoundingClientRect();if(!O)return;if(c.value=O.width<1036,n6.value){V(O);return}const U=c.value?96:56;r.value=Math.min((O.width-64)/S.value.width,(O.height-U)/S.value.height,h.value.maxPresentationScale)}function V(O){const U=c.value?96:56,W=Math.max(0,O.width-$1*2),b6=Math.max(0,O.height-U-I1);T4(W,Math.max(0,b6-a2))}function N(){d.value||(u.value=void 0)}function R(){u.value?.kind==="loading"&&u.value.dismissible&&K4()}function Y(O){O.event&&V0(O.panes[0].size/100*i.value)}function a6(){V0(400)}function c6(O){z.activeTab=O,O==="storage"&&S0()}function o6(){L2(!z.followLogs),z.followLogs&&requestAnimationFrame(x3)}function C3(O){const U=O.target,W=U.scrollTop+U.clientHeight>=U.scrollHeight-24;!W&&z.followLogs?L2(!1):W&&!z.followLogs&&(L2(!0),requestAnimationFrame(x3))}function x3(){l.value&&(l.value.scrollTop=l.value.scrollHeight)}function S0(){dispatchEvent(new CustomEvent("hb-sdk:refresh-storage"))}function A0(){P0({command:"reload"}).catch(k0)}function k2(O,U,W=Date.now(),b6="info"){const E2=X4(U);J4.event(void 0,{source:"host",method:O,timestamp:W,level:b6,message:typeof E2.message=="string"?E2.message:JSON.stringify(E2)})}function k0(O){O instanceof Error&&"code"in O&&O.code==="PREVIEW_SUPERSEDED"||k2("preview.action.failed",{message:O instanceof Error?O.message:"调试台动作失败"},Date.now(),"error")}function Te(O,U){const W=K(O);if(!W){U?.preventDefault();return}U?.preventDefault(),window.open(W,"_blank","noopener,noreferrer"),Y4(O),f.value=!1,k2("desktop.open.requested",{address:z.desktopLaunch.address.address,target:O,delivery:"navigation-intent"})}function De(O){typeof O=="string"&&P0({command:"select",preset:O}).catch(k0)}function $e(O){O0(O.width,O.height)}function Ie(O){O0(O.width,O.height,{persist:!0})}function qe(){T0(!0),requestAnimationFrame(A)}function Re(){T0(!1),requestAnimationFrame(A)}function Fe(){D0(!0)}function Ne(){D0(!1),requestAnimationFrame(A)}function Ue(){$0(!0)}function We(){$0(!1),requestAnimationFrame(A)}async function B2(O){await navigator.clipboard?.writeText(O)}async function Ge(){if(!(!i6.value||!navigator.clipboard))try{await navigator.clipboard.writeText(i6.value),s6.value=!0}catch{s6.value=!1,k2("clipboard.write.failed",{message:"复制链接失败,请检查浏览器剪贴板权限"},Date.now(),"warn")}}function Ze(O){return[O.errorCode,`${O.count} 次`].filter(Boolean).join(" · ")}function je(O){const U=O.errorCode??"";return U==="STORAGE_QUOTA_EXCEEDED"?"Storage 写入失败":U.includes("CSP")||O.method==="runtime.security"?"资源加载被阻止":O.method==="network.request"?"network.request 调用失败":O.method}function Ke(O){return O==="session"?"Session Storage":"Local Storage"}return(O,U)=>(g(),G(s(ha),{"delay-duration":300},{default:E(()=>[m("div",{class:m6(["workbench",{"workbench--chrome-hidden":s(z).screenshotChromeHidden}]),"data-testid":"workbench-root","data-preview-preset":s(z).deviceSelectionId,"data-preview-orientation":n6.value?s(t6).width>=s(t6).height?"landscape":"portrait":s(z).display.orientation,"data-preview-runtime":s(z).runtimeStatus,"data-preview-width":e3.value.screenWidth,"data-preview-height":e3.value.screenHeight},[m("header",ci,[m("div",di,[m("img",{class:"brand__logo",src:s(ka),alt:"小黑盒"},null,8,ui),U[6]||(U[6]=m("span",{class:"brand__title"},"小程序工坊调试台",-1)),s(z).diagnosticTargetId?(g(),L("span",pi,P(s(z).diagnosticOwnershipLost?"已失效调试页":s(z).diagnosticTargetId===s(z).diagnosticPrimaryTargetId?"主预览":"其他调试页")+" · "+P(s(z).diagnosticTargetName)+" · "+P(s(z).diagnosticTargetId.slice(-8)),1)):Z("",!0)]),m("div",fi,[q(qn),s(z).miniProgramSupportsDesktop?(g(),L("div",hi,[q(s(Z3),{modelValue:f.value,"onUpdate:modelValue":U[0]||(U[0]=W=>f.value=W),size:"compact",title:"在桌面端打开","trigger-label":"在桌面端打开调试页","trigger-test-id":"desktop-launch-menu-trigger"},{trigger:E(()=>[q(s(ot),{size:18,"aria-hidden":"true"})]),default:E(()=>[s(z).desktopLaunch.ready?Z("",!0):(g(),L("p",vi,P(s(z).desktopLaunch.unavailableReason),1)),(g(),L(p6,null,S6(B,W=>q(s(l0),{key:W.id,href:K(W.id)||void 0,disabled:!K(W.id),selected:s(z).desktopLaunch.target===W.id,onSelect:b6=>Te(W.id,b6)},{default:E(()=>[h6(P(W.label),1)]),_:2},1032,["href","disabled","selected","onSelect"])),64))]),_:1},8,["modelValue"])])):Z("",!0),q(s(Z3),{modelValue:s(z).qrOpen,"onUpdate:modelValue":U[1]||(U[1]=W=>s(z).qrOpen=W),title:"手机扫码调试","trigger-label":"查看手机调试二维码","trigger-test-id":"qr-trigger"},{trigger:E(()=>[m("img",{class:"toolbar-asset toolbar-asset--18",src:s(Ea),alt:""},null,8,mi)]),default:E(()=>[s(z).devReadiness?.mobile.state!=="ready"?(g(),L("p",gi,P(s(z).devReadiness?.mobile.reason||"手机调试尚未就绪"),1)):Z("",!0),U[7]||(U[7]=m("img",{id:"mobile-qr-image",class:"qr-popover__image",alt:"手机扫码调试二维码"},null,-1)),U[8]||(U[8]=m("label",{class:"qr-popover__field"},[m("span",null,"局域网"),m("select",{id:"mobile-lan-select"})],-1)),q(s(h0),{id:"mobile-qr-status","aria-live":"polite"})]),_:1},8,["modelValue"]),m("label",_i,[U[9]||(U[9]=m("span",null,"媒体",-1)),K6(m("select",{"onUpdate:modelValue":U[2]||(U[2]=W=>s(z).mediaSimulation=W),"aria-label":"媒体选择模拟","data-testid":"media-simulation-select"},[(g(!0),L(p6,null,S6(s($4),W=>(g(),L("option",{key:W,value:W},P(s(I4)[W]),9,yi))),128))],512),[[H7,s(z).mediaSimulation]])])])]),m("main",{ref_key:"mainEl",ref:o,class:"workbench__main"},[q(s(Aa),{"maximize-panes":!1,"keyboard-step":1,onResized:Y,onSplitterDblclick:a6},{default:E(()=>[q(s(L1),{size:D.value,"min-size":I.value,"max-size":F.value},{default:E(()=>[m("aside",wi,[m("div",bi,[m("div",Ci,[s(z).miniProgram.iconUrl&&!p.value?(g(),L("img",{key:0,src:s(z).miniProgram.iconUrl,alt:"",onError:U[3]||(U[3]=W=>p.value=!0)},null,40,xi)):(g(),L("span",zi,"UI"))]),m("div",Mi,[m("strong",null,P(s(z).miniProgram.name),1),m("span",null,P(s(z).miniProgram.detail||"本地调试"),1)])]),m("nav",Si,[(g(),L(p6,null,S6(t,W=>m("button",{key:W.id,class:m6([`diagnostics__tab--${W.id}`,{active:s(z).activeTab===W.id}]),"data-testid":`diagnostics-tab-${W.id}`,onClick:b6=>c6(W.id)},[h6(P(W.label),1),W.id==="problems"&&s(B0).length?(g(),L("span",ki,P(s(B0).length),1)):Z("",!0)],10,Ai)),64))]),m("div",Bi,[m("label",Ei,[m("img",{class:"toolbar-asset toolbar-asset--12",src:s(Ha),alt:""},null,8,Hi),K6(m("input",{"onUpdate:modelValue":U[4]||(U[4]=W=>s(z).queries[s(z).activeTab]=W),type:"search",placeholder:J.value,"aria-label":J.value},null,8,Li),[[E7,s(z).queries[s(z).activeTab]]])]),m("div",Vi,[s(z).activeTab==="logs"?(g(),G(s(Gn),{key:0,"active-count":s(N4),levels:s(z).logFilters.levels,sources:s(z).logFilters.sources,onReset:s(F4),onToggleLevel:s(R4),onToggleSource:s(q4)},null,8,["active-count","levels","sources","onReset","onToggleLevel","onToggleSource"])):Z("",!0),s(z).activeTab==="logs"?(g(),G(s(B6),{key:1,label:s(z).followLogs?"暂停跟随":"继续跟随","data-testid":"log-follow-toggle",onClick:o6},{default:E(()=>[s(z).followLogs?(g(),L("img",{key:0,class:"toolbar-asset toolbar-asset--18",src:s(Ba),alt:""},null,8,Pi)):(g(),G(s(nt),{key:1,size:15})),!s(z).followLogs&&s(z).pausedLogCount?(g(),L("span",Oi,P(s(z).pausedLogCount),1)):Z("",!0)]),_:1},8,["label"])):Z("",!0),s(z).activeTab==="logs"?(g(),G(s(B6),{key:2,label:"清空日志",onClick:s(U4)},{default:E(()=>[m("img",{class:"toolbar-asset toolbar-asset--18",src:s(V1),alt:""},null,8,Ti)]),_:1},8,["onClick"])):Z("",!0),s(z).activeTab==="storage"?(g(),G(s(B6),{key:3,label:"刷新 Storage",onClick:S0},{default:E(()=>[m("img",{class:"toolbar-asset toolbar-asset--18",src:s(O1),alt:""},null,8,Di)]),_:1})):Z("",!0),s(z).activeTab==="problems"?(g(),G(s(B6),{key:4,label:"清空问题","data-testid":"clear-problems",onClick:s(W4)},{default:E(()=>[m("img",{class:"toolbar-asset toolbar-asset--18",src:s(V1),alt:""},null,8,$i)]),_:1},8,["onClick"])):Z("",!0)])]),s(z).diagnosticsStale||s(z).diagnosticsGap||s(z).diagnosticsDropped?(g(),L("p",Ii,P(s(z).diagnosticsStale?"诊断服务暂不可达,当前为已接收的历史记录。":"")+" "+P(s(z).diagnosticsGap?"部分记录已超出服务缓冲,存在日志缺口。":"")+" "+P(s(z).diagnosticsDropped?`Host 发送缓冲已丢弃 ${s(z).diagnosticsDropped} 条诊断。`:""),1)):Z("",!0),m("section",qi,[s(z).activeTab==="sandbox"?(g(),G(yn,{key:0})):Z("",!0),K6(m("div",{ref_key:"logEl",ref:l,id:"logs",class:"log-list",onScroll:C3},[(g(!0),L(p6,null,S6(s(E0),W=>(g(),G(s(ri),{key:W.id,entry:W,onCopy:B2},null,8,["entry"]))),128)),s(E0).length?Z("",!0):(g(),L("p",Ri,"暂无日志"))],544),[[g3,s(z).activeTab==="logs"]]),K6(m("div",Fi,[(g(!0),L(p6,null,S6(s(H0),W=>(g(),L("details",{key:`${W.area}:${W.key}`,class:"storage-row"},[m("summary",null,[m("span",null,[m("strong",null,P(W.key),1),m("small",null,P(Ke(W.area))+" · "+P(W.bytes)+" B",1)]),q(s(B6),{label:"复制 Storage 值","data-testid":"copy-storage-value",onClick:R6(b6=>B2(W.serializedValue),["prevent"])},{default:E(()=>[m("img",{class:"toolbar-asset toolbar-asset--16",src:s(P1),alt:""},null,8,Ni)]),_:1},8,["onClick"])]),m("code",null,P(W.serializedValue),1)]))),128)),s(z).storageError?(g(),L("p",Ui,P(s(z).storageError),1)):s(H0).length?Z("",!0):(g(),L("p",Wi,"暂无 Storage 数据"))],512),[[g3,s(z).activeTab==="storage"]]),K6(m("div",Gi,[U[11]||(U[11]=m("div",{id:"csp-violations",class:"csp-violations",hidden:""},[m("strong",null,"网络或资源请求已被 CSP 阻止")],-1)),(g(!0),L(p6,null,S6(s(L0),W=>(g(),L("div",{key:W.id,class:"problem-row"},[U[10]||(U[10]=m("span",{class:"problem-row__indicator","aria-hidden":"true"},null,-1)),m("span",Zi,[m("strong",null,P(je(W)),1),m("small",null,P(Ze(W)),1)]),q(s(B6),{variant:"ghost",label:"复制问题详情",onClick:b6=>B2(s(s2)(W.detail))},{default:E(()=>[m("img",{class:"toolbar-asset toolbar-asset--16",src:s(P1),alt:""},null,8,ji)]),_:1},8,["onClick"])]))),128)),s(L0).length?Z("",!0):(g(),L("p",Ki,"未发现问题"))],512),[[g3,s(z).activeTab==="problems"]])])])]),_:1},8,["size","min-size","max-size"]),q(s(L1),null,{default:E(()=>[m("section",{ref_key:"stageEl",ref:n,class:m6(["device-stage",[`device-stage--${s(h).id}`,{"device-stage--compact":c.value}]]),style:y6({"--device-toolbar-left":`${s(h).toolbarLeft}px`})},[m("div",{class:"device-stage__toolbar",style:y6($6.value)},[q(s(z0),{open:s(z).deviceSelectOpen,"onUpdate:open":U[5]||(U[5]=W=>s(z).deviceSelectOpen=W),"model-value":s(z).deviceSelectionId,options:a,label:"选择屏幕尺寸",variant:"glass","test-id":"device-preset-trigger",class:"device-select","onUpdate:modelValue":De},{prefix:E(()=>[...U[12]||(U[12]=[h6("屏幕",-1)])]),_:1},8,["open","model-value"]),q(s(B6),{variant:"glass",label:"重新启动小程序","data-testid":"runtime-restart",onClick:A0},{default:E(()=>[m("img",{class:"toolbar-asset toolbar-asset--18",src:s(O1),alt:""},null,8,Yi)]),_:1})],4),n6.value?(g(),L("div",{key:0,class:"desktop-preview",style:y6(d3.value),"data-testid":"desktop-preview"},[s(z).desktopWindow.minimized?(g(),L("div",Xi,[U[13]||(U[13]=m("p",null,"窗口已最小化,运行实例仍在",-1)),m("button",{type:"button",class:"desktop-preview__action","data-testid":"desktop-window-restore",onClick:Ne}," 恢复窗口 ")])):s(z).desktopWindow.closed?(g(),L("div",Ji,[U[14]||(U[14]=m("p",null,"窗口已关闭,运行实例已销毁",-1)),m("button",{type:"button",class:"desktop-preview__action","data-testid":"desktop-window-reopen",onClick:We}," 重新打开 ")])):Z("",!0),K6(q(yo,{"data-preview-target":"device","data-rotating":"false",width:s(t6).width,height:s(t6).height,"min-width":s(z).desktopWindow.minWidth,"min-height":s(z).desktopWindow.minHeight,resizable:s(z).desktopWindow.resizable,maximized:s(z).desktopWindow.maximized,scale:u3.value,title:r6.value,"icon-url":s(z).miniProgram.iconUrl,detail:s(z).miniProgram.detail,"can-copy-link":!!i6.value,"link-copied":s6.value,"title-bar-height":s(a2),onResize:$e,onResizeEnd:Ie,onMaximize:qe,onRestore:Re,onMinimize:Fe,onClose:Ue,onRefresh:A0,onCopyLink:Ge},{default:E(()=>[U[15]||(U[15]=m("div",{id:"device",class:"device-content desktop-preview__device"},null,-1)),m("div",Qi,[q(D1,{feedback:u.value,visible:d.value,onDismissLoading:R,onAfterLeave:N},null,8,["feedback","visible"])])]),_:1},8,["width","height","min-width","min-height","resizable","maximized","scale","title","icon-url","detail","can-copy-link","link-copied","title-bar-height"]),[[g3,!s(z).desktopWindow.minimized&&!s(z).desktopWindow.closed]])],4)):(g(),L("div",{key:1,class:m6(["device-presentation",{"device-presentation--rotating":_.value}]),style:y6(C6.value)},[m("div",{class:m6(["device-shell",`device-shell--${s(h).platform}`]),"data-testid":"preview-device","data-preview-target":"device","data-rotating":String(_.value),"data-orientation":s(z).display.orientation,style:y6(I6.value)},[m("div",{class:"device-screen","data-testid":"device-screen","data-preview-target":"screen",style:y6(z6.value)},[m("div",{id:"device-viewport",class:"device-viewport","data-testid":"device-viewport",style:y6(t2.value)},[U[16]||(U[16]=m("div",{id:"device",class:"device-content"},null,-1)),m("div",tl,[q(D1,{feedback:u.value,visible:d.value,onDismissLoading:R,onAfterLeave:N},null,8,["feedback","visible"])]),q(Mo,{platform:s(h).platform},null,8,["platform"]),U[17]||(U[17]=m("div",{id:"host-fullscreen-exit-mount",class:"host-fullscreen-exit-mount"},null,-1))],4)],4),q(xo,{"foreground-style":s(z).navigationBarStyle,platform:s(h).platform,"capsule-hidden":s(z).display.capsuleHidden,"status-bar-hidden":s(z).display.capsuleHidden||y.value},null,8,["foreground-style","platform","capsule-hidden","status-bar-hidden"])],14,el)],6))],6)]),_:1})]),_:1})],512),m("footer",al,[m("div",null,[m("span",ol,[m("i",{class:m6(`activity-status--${s(z).runtimeStatus}`)},null,2),h6(P($.value),1)]),m("span",null,P(s(Q)),1),m("span",null,P(e3.value.screenWidth)+" × "+P(e3.value.screenHeight),1)]),m("div",null,[q(an,{entries:s(z).localPermissions,"context-warning":s(z).devContextWarning,"mini-program-id":s(z).miniProgram.id,"open-platform-base-url":s(z).openPlatformBaseUrl},null,8,["entries","context-warning","mini-program-id","open-platform-base-url"]),m("span",null,"hb-sdk "+P(s(G4)),1),m("span",nl,[q(s(Y2),{size:18,src:s(z).account.avatar,alt:s(z).account.nickname,"logged-out":!s(z).account.authenticated},null,8,["src","alt","logged-out"]),h6(P(s(z).account.nickname),1)])])])],10,si)]),_:1}))}});document.documentElement.dataset.hbTheme="light";T7(ll).mount("#app");await a7(()=>import("./browser-dev-host-DVlT56iQ.js"),__vite__mapDeps([0,1]));
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<meta name="theme-color" content="#f4f5f7" />
|
|
7
7
|
<title>小程序工坊调试台</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
-
<link rel="modulepreload" crossorigin href="/assets/desktop-app-launch-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-DY5ZynQp.js"></script>
|
|
9
|
+
<link rel="modulepreload" crossorigin href="/assets/desktop-app-launch-BzRxl_MM.js">
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/index-CHYEXFEg.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/dist/index.cjs.js
CHANGED
|
@@ -428,6 +428,10 @@ const USER_SHOW_APPRECIATION_METHOD = 'user.showAppreciation';
|
|
|
428
428
|
const SHARE_COPY_LINK_METHOD = 'share.copyLink';
|
|
429
429
|
const SHARE_SHOW_SHARE_MENU_METHOD = 'share.showShareMenu';
|
|
430
430
|
const SHARE_SCREENSHOT_METHOD = 'share.screenshot';
|
|
431
|
+
/** DOM 长图内部传输方法;业务仍调用 screenshotElement。
|
|
432
|
+
* @internal
|
|
433
|
+
*/
|
|
434
|
+
const SHARE_SCREENSHOT_LONG_METHOD = 'share.screenshotLong';
|
|
431
435
|
const VIEWPORT_SET_DISPLAY_METHOD = 'viewport.setDisplay';
|
|
432
436
|
const VIEWPORT_GET_WINDOW_INFO_METHOD = 'viewport.getWindowInfo';
|
|
433
437
|
const VIEWPORT_SET_NAVIGATION_BAR_STYLE_METHOD = 'viewport.setNavigationBarStyle';
|
|
@@ -7509,7 +7513,7 @@ function createMessageId() {
|
|
|
7509
7513
|
/** 构建时替换为当前发布包的实际版本。 */
|
|
7510
7514
|
const HB_SDK_VERSION = typeof undefined === 'string'
|
|
7511
7515
|
? undefined
|
|
7512
|
-
: '0.9.6-alpha.
|
|
7516
|
+
: '0.9.6-alpha.11';
|
|
7513
7517
|
|
|
7514
7518
|
const RUNTIME_MODES = new Set(['production', 'preview', 'development', 'unknown']);
|
|
7515
7519
|
const OPERATING_SYSTEM_NAMES = new Set(['android', 'ios', 'ohos', 'windows', 'macos', 'linux', 'unknown']);
|
|
@@ -7556,7 +7560,7 @@ function readRecord$1(value) {
|
|
|
7556
7560
|
|
|
7557
7561
|
const DEFAULT_TIMEOUT = 10000;
|
|
7558
7562
|
// 选择器等待、截图延迟、登录和关注确认由 Host 管理,使用长操作生命周期,不设固定总时长。
|
|
7559
|
-
const HOST_MANAGED_TIMEOUT_METHODS = new Set([FILES_PICK_FILES_METHOD, FILES_PICK_DIRECTORY_METHOD, FILES_SAVE_FILE_METHOD, SHARE_SCREENSHOT_METHOD, USER_REQUEST_FOLLOW_AUTHOR_METHOD]);
|
|
7563
|
+
const HOST_MANAGED_TIMEOUT_METHODS = new Set([FILES_PICK_FILES_METHOD, FILES_PICK_DIRECTORY_METHOD, FILES_SAVE_FILE_METHOD, SHARE_SCREENSHOT_METHOD, SHARE_SCREENSHOT_LONG_METHOD, USER_REQUEST_FOLLOW_AUTHOR_METHOD]);
|
|
7560
7564
|
const HANDSHAKE_RETRY_INTERVAL = 250;
|
|
7561
7565
|
/** 底层 bridge client,负责握手、请求响应、事件分发与超时清理。 */
|
|
7562
7566
|
class MiniProgramBridgeClient {
|
|
@@ -10592,6 +10596,14 @@ function decodeBase64Url(value) {
|
|
|
10592
10596
|
return Uint8Array.from(atob(padded), (character) => character.charCodeAt(0));
|
|
10593
10597
|
}
|
|
10594
10598
|
|
|
10599
|
+
let queue = Promise.resolve();
|
|
10600
|
+
/** 同页截图串行执行,避免长图捕获面遮挡另一次截图。 */
|
|
10601
|
+
function serializeScreenshot(capture) {
|
|
10602
|
+
const result = queue.then(capture);
|
|
10603
|
+
queue = result.catch(() => undefined);
|
|
10604
|
+
return result;
|
|
10605
|
+
}
|
|
10606
|
+
|
|
10595
10607
|
/**
|
|
10596
10608
|
* 截图并唤起分享。
|
|
10597
10609
|
*
|
|
@@ -10608,13 +10620,169 @@ function decodeBase64Url(value) {
|
|
|
10608
10620
|
* @see {@link MiniProgramScreenshotOptions}
|
|
10609
10621
|
*/
|
|
10610
10622
|
function screenshot(requester, options) {
|
|
10623
|
+
return serializeScreenshot(() => captureScreenshot(requester, options));
|
|
10624
|
+
}
|
|
10625
|
+
/** 已持有截图队列的内部入口。 */
|
|
10626
|
+
function captureScreenshot(requester, options) {
|
|
10627
|
+
warnScreenshotWatermark();
|
|
10628
|
+
return requester.request(SHARE_SCREENSHOT_METHOD, options);
|
|
10629
|
+
}
|
|
10630
|
+
function warnScreenshotWatermark() {
|
|
10611
10631
|
try {
|
|
10612
10632
|
console.warn('[hb-sdk] share.screenshot 行为变更提醒:正式版 SDK 0.9.1 及以上默认添加小程序品牌水印;低于 0.9.1(含预发布版本)的 SDK 保持无水印截图。升级前请在目标截图区域底部预留至少 57 个逻辑像素,避免遮挡重要内容;watermarkTheme 的 light 为黑色水印,dark 为白色水印且是默认值,不自动跟随系统主题。系统按键截图不在此能力范围内。');
|
|
10613
10633
|
}
|
|
10614
10634
|
catch {
|
|
10615
10635
|
// 日志输出失败不能阻断截图调用。
|
|
10616
10636
|
}
|
|
10617
|
-
|
|
10637
|
+
}
|
|
10638
|
+
|
|
10639
|
+
/** 将当前页面的 DOM 边界转换为逻辑像素矩形,再复用原截图分享流程。 */
|
|
10640
|
+
async function screenshotElement(requester, options) {
|
|
10641
|
+
return serializeScreenshot(() => captureElement(requester, options));
|
|
10642
|
+
}
|
|
10643
|
+
async function captureElement(requester, options) {
|
|
10644
|
+
if (!options || typeof options !== 'object' || Array.isArray(options) || 'rect' in options) {
|
|
10645
|
+
throw createSDKError('INVALID_PARAMS', 'share.screenshotElement 必须传入包含 element 的配置,且不能指定 rect');
|
|
10646
|
+
}
|
|
10647
|
+
const { element, ...screenshotOptions } = options;
|
|
10648
|
+
if (typeof window === 'undefined' || typeof document === 'undefined' || typeof Element === 'undefined'
|
|
10649
|
+
|| !(element instanceof Element) || element.ownerDocument !== document || !element.isConnected) {
|
|
10650
|
+
throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 必须是当前页面中已挂载的 DOM 元素');
|
|
10651
|
+
}
|
|
10652
|
+
// DOMRect 已是当前窗口逻辑像素;不叠加滚动偏移,也不乘设备像素比。
|
|
10653
|
+
const { left, top, width, height } = element.getBoundingClientRect();
|
|
10654
|
+
const windowWidth = document.documentElement.clientWidth || window.innerWidth;
|
|
10655
|
+
const windowHeight = document.documentElement.clientHeight || window.innerHeight;
|
|
10656
|
+
const visibility = window.getComputedStyle(element).visibility;
|
|
10657
|
+
if (![left, top, width, height, windowWidth, windowHeight].every(Number.isFinite)
|
|
10658
|
+
|| width <= 0 || height <= 0 || windowWidth <= 0 || windowHeight <= 0
|
|
10659
|
+
|| element.getClientRects().length === 0 || visibility === 'hidden' || visibility === 'collapse') {
|
|
10660
|
+
throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 必须具有可见的布局尺寸');
|
|
10661
|
+
}
|
|
10662
|
+
// 原生只支持纵向拼接;横向溢出不能静默退化为可见区域截图。
|
|
10663
|
+
if (width >= windowWidth + 1 || element.scrollWidth > element.clientWidth + 1) {
|
|
10664
|
+
throw createSDKError('INVALID_PARAMS', '暂不支持横向长图:元素宽度不能超过窗口,且不能包含横向溢出内容');
|
|
10665
|
+
}
|
|
10666
|
+
if (height >= windowHeight + 1 || element.scrollHeight > height + 1) {
|
|
10667
|
+
if (width > windowWidth + 1)
|
|
10668
|
+
throw createSDKError('INVALID_PARAMS', '长图宽度不能超过窗口');
|
|
10669
|
+
return screenshotLongElement(requester, options);
|
|
10670
|
+
}
|
|
10671
|
+
// clientWidth/clientHeight 为整数,DOMRect 保留亚像素;仅容忍不足 1 个逻辑像素的边界误差。
|
|
10672
|
+
const tolerance = 1;
|
|
10673
|
+
const right = left + width;
|
|
10674
|
+
const bottom = top + height;
|
|
10675
|
+
if (left <= -tolerance || top <= -tolerance || right >= windowWidth + tolerance || bottom >= windowHeight + tolerance) {
|
|
10676
|
+
throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 的完整边界必须位于当前可见窗口内');
|
|
10677
|
+
}
|
|
10678
|
+
const clippedLeft = Math.max(0, left);
|
|
10679
|
+
const clippedTop = Math.max(0, top);
|
|
10680
|
+
const clippedWidth = left < 0 || right > windowWidth ? Math.min(windowWidth, right) - clippedLeft : width;
|
|
10681
|
+
const clippedHeight = top < 0 || bottom > windowHeight ? Math.min(windowHeight, bottom) - clippedTop : height;
|
|
10682
|
+
if (clippedWidth <= 0 || clippedHeight <= 0) {
|
|
10683
|
+
throw createSDKError('INVALID_PARAMS', 'share.screenshotElement element 必须与当前可见窗口相交');
|
|
10684
|
+
}
|
|
10685
|
+
return captureScreenshot(requester, { ...screenshotOptions, rect: { left: clippedLeft, top: clippedTop, width: clippedWidth, height: clippedHeight } });
|
|
10686
|
+
}
|
|
10687
|
+
/** 在业务文档准备长图捕获面,再交给宿主原生截图。调用方持有同页截图队列。 */
|
|
10688
|
+
async function screenshotLongElement(requester, { element, ...options }) {
|
|
10689
|
+
if (!element.isConnected)
|
|
10690
|
+
throw createSDKError('INVALID_PARAMS', '截图元素已卸载');
|
|
10691
|
+
const bounds = element.getBoundingClientRect();
|
|
10692
|
+
const height = Math.max(bounds.height, element.scrollHeight + bounds.height - element.clientHeight);
|
|
10693
|
+
if (height > 10000 || bounds.width > 2048 || bounds.width * height > 4000000) {
|
|
10694
|
+
throw createSDKError('INVALID_PARAMS', '长图尺寸超过限制(高度 10000、面积 400 万逻辑像素)');
|
|
10695
|
+
}
|
|
10696
|
+
if (element.matches('iframe,video,object,embed') || element.querySelector('iframe,video,object,embed')) {
|
|
10697
|
+
throw createSDKError('INVALID_PARAMS', '长图暂不支持嵌入网页和视频');
|
|
10698
|
+
}
|
|
10699
|
+
// 在业务自己的文档内复制,DOM 不经过 bridge,也不导出 Canvas 像素。
|
|
10700
|
+
if (!(element instanceof HTMLElement))
|
|
10701
|
+
throw createSDKError('INVALID_PARAMS', '长图需要 HTML 容器元素');
|
|
10702
|
+
const sources = [element, ...element.querySelectorAll('*')];
|
|
10703
|
+
if (sources.some(source => source.shadowRoot || source.localName.includes('-'))) {
|
|
10704
|
+
throw createSDKError('INVALID_PARAMS', '长图暂不支持自定义元素和 Shadow DOM');
|
|
10705
|
+
}
|
|
10706
|
+
const clone = element.cloneNode(true);
|
|
10707
|
+
const copies = [clone, ...clone.querySelectorAll('*')];
|
|
10708
|
+
for (let i = 0; i < sources.length; i++) {
|
|
10709
|
+
const source = sources[i];
|
|
10710
|
+
const copy = copies[i];
|
|
10711
|
+
if (!copy.style)
|
|
10712
|
+
continue;
|
|
10713
|
+
const computed = window.getComputedStyle(source);
|
|
10714
|
+
if (computed.position === 'fixed' || computed.position === 'sticky')
|
|
10715
|
+
throw createSDKError('INVALID_PARAMS', '长图暂不支持固定或吸顶元素');
|
|
10716
|
+
for (let j = 0; j < computed.length; j++) {
|
|
10717
|
+
const name = computed.item(j);
|
|
10718
|
+
copy.style.setProperty(name, computed.getPropertyValue(name), 'important');
|
|
10719
|
+
}
|
|
10720
|
+
copy.style.setProperty('animation', 'none', 'important');
|
|
10721
|
+
copy.style.setProperty('transition', 'none', 'important');
|
|
10722
|
+
if (source instanceof HTMLCanvasElement) {
|
|
10723
|
+
copy.getContext('2d')?.drawImage(source, 0, 0);
|
|
10724
|
+
}
|
|
10725
|
+
if (source instanceof HTMLInputElement)
|
|
10726
|
+
copy.value = source.value;
|
|
10727
|
+
if (source instanceof HTMLTextAreaElement)
|
|
10728
|
+
copy.value = source.value;
|
|
10729
|
+
if (source instanceof HTMLSelectElement)
|
|
10730
|
+
copy.selectedIndex = source.selectedIndex;
|
|
10731
|
+
if (source instanceof HTMLImageElement) {
|
|
10732
|
+
copy.src = source.currentSrc || source.src;
|
|
10733
|
+
copy.removeAttribute('srcset');
|
|
10734
|
+
copy.loading = 'eager';
|
|
10735
|
+
}
|
|
10736
|
+
}
|
|
10737
|
+
if (window.getComputedStyle(element).backgroundColor === 'rgba(0, 0, 0, 0)')
|
|
10738
|
+
clone.style.setProperty('background-color', 'white', 'important');
|
|
10739
|
+
clone.querySelectorAll('script').forEach(script => script.remove());
|
|
10740
|
+
clone.setAttribute('aria-hidden', 'true');
|
|
10741
|
+
clone.inert = true;
|
|
10742
|
+
clone.dataset.hbScreenshotStage = '';
|
|
10743
|
+
for (const [key, value] of Object.entries({ position: 'absolute', left: '0', top: '0', margin: '0', transform: 'none', width: `${bounds.width}px`, height: `${height}px`, 'box-sizing': 'border-box', 'min-width': '0', 'max-width': 'none', 'min-height': '0', 'max-height': 'none', overflow: 'hidden', 'z-index': '2147483647', 'pointer-events': 'none' })) {
|
|
10744
|
+
clone.style.setProperty(key, value, 'important');
|
|
10745
|
+
}
|
|
10746
|
+
const x = window.scrollX;
|
|
10747
|
+
const y = window.scrollY;
|
|
10748
|
+
const documentStyles = [document.documentElement, document.body].map(node => ({ node, style: node.getAttribute('style') }));
|
|
10749
|
+
let timer;
|
|
10750
|
+
try {
|
|
10751
|
+
// 小程序经常锁定 body 的高度与滚动;临时释放裁剪,确保捕获面完整可绘制。
|
|
10752
|
+
for (const { node } of documentStyles) {
|
|
10753
|
+
node.style.setProperty('overflow', 'visible', 'important');
|
|
10754
|
+
node.style.setProperty('min-height', `${height}px`, 'important');
|
|
10755
|
+
node.style.setProperty('scroll-behavior', 'auto', 'important');
|
|
10756
|
+
}
|
|
10757
|
+
document.body.append(clone);
|
|
10758
|
+
window.scrollTo(0, 0);
|
|
10759
|
+
// body 定位上下文可能有偏移,将独立捕获面校正到文档原点。
|
|
10760
|
+
const stageBounds = clone.getBoundingClientRect();
|
|
10761
|
+
clone.style.setProperty('left', `${-stageBounds.left}px`, 'important');
|
|
10762
|
+
clone.style.setProperty('top', `${-stageBounds.top}px`, 'important');
|
|
10763
|
+
await Promise.race([
|
|
10764
|
+
Promise.all([...(clone instanceof HTMLImageElement ? [clone] : []), ...clone.querySelectorAll('img')].map(image => image.decode())),
|
|
10765
|
+
new Promise((_, reject) => { timer = setTimeout(() => reject(createSDKError('REQUEST_TIMEOUT', '长图图片加载超时')), 5000); }),
|
|
10766
|
+
]);
|
|
10767
|
+
const rendered = clone.getBoundingClientRect();
|
|
10768
|
+
if (Math.abs(rendered.left) >= 1 || Math.abs(rendered.top) >= 1 || Math.abs(rendered.width - bounds.width) >= 1 || Math.abs(rendered.height - height) >= 1) {
|
|
10769
|
+
throw createSDKError('INVALID_PARAMS', '当前页面布局无法容纳长图捕获面');
|
|
10770
|
+
}
|
|
10771
|
+
warnScreenshotWatermark();
|
|
10772
|
+
return await requester.request(SHARE_SCREENSHOT_LONG_METHOD, { ...options, rect: { left: 0, top: 0, width: bounds.width, height } });
|
|
10773
|
+
}
|
|
10774
|
+
finally {
|
|
10775
|
+
clearTimeout(timer);
|
|
10776
|
+
clone.remove();
|
|
10777
|
+
// 在恢复业务的 smooth 滚动样式前立即还原,避免退出截图后继续滚动。
|
|
10778
|
+
window.scrollTo(x, y);
|
|
10779
|
+
for (const { node, style } of documentStyles) {
|
|
10780
|
+
if (style === null)
|
|
10781
|
+
node.removeAttribute('style');
|
|
10782
|
+
else
|
|
10783
|
+
node.setAttribute('style', style);
|
|
10784
|
+
}
|
|
10785
|
+
}
|
|
10618
10786
|
}
|
|
10619
10787
|
|
|
10620
10788
|
/**
|
|
@@ -10645,6 +10813,7 @@ function createShareModule(requester, launchHref) {
|
|
|
10645
10813
|
getExtra: () => readMiniProgramShareExtra(launchHref),
|
|
10646
10814
|
showShareMenu: (options) => showShareMenu(requester, options),
|
|
10647
10815
|
screenshot: (options) => screenshot(requester, options),
|
|
10816
|
+
screenshotElement: (options) => screenshotElement(requester, options),
|
|
10648
10817
|
};
|
|
10649
10818
|
}
|
|
10650
10819
|
|
|
@@ -12219,6 +12388,7 @@ const share = {
|
|
|
12219
12388
|
getExtra: () => getDefaultSDK().share.getExtra(),
|
|
12220
12389
|
showShareMenu: (options) => getDefaultSDK().share.showShareMenu(options),
|
|
12221
12390
|
screenshot: (options) => getDefaultSDK().share.screenshot(options),
|
|
12391
|
+
screenshotElement: (options) => getDefaultSDK().share.screenshotElement(options),
|
|
12222
12392
|
};
|
|
12223
12393
|
/** 默认 SDK 实例的 Viewport 模块。 */
|
|
12224
12394
|
const viewport = {
|