@popmelt.com/core 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -1
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/dist/ExploreAttachment-BG7ZOQSA.mjs +1 -0
- package/dist/PagePreviewLayer-CBDGPMJQ.mjs +1 -0
- package/dist/ParticipantRuntime-FSZX2PUQ.mjs +1 -0
- package/dist/PhoneHostGate-OM7FLOJ2.mjs +1 -0
- package/dist/PopmeltTasteConnectedPane-KJSBPJQR.mjs +1 -0
- package/dist/PreviewRuntime-EYKB7MG5.mjs +1 -0
- package/dist/QueuedReplies-ZYUDSTS2.mjs +1 -46
- package/dist/SuppliedContext-7THB2WZY.mjs +1 -0
- package/dist/ThreadErrorCard-J2VTA5JW.mjs +1 -0
- package/dist/ThreadPanel-PNVMIIYJ.mjs +1 -0
- package/dist/adapter-react-three-fiber.mjs +1 -2
- package/dist/bridge-entry.mjs +1 -1
- package/dist/bridge-recovery-3IQN3U6D.mjs +1 -2
- package/dist/bridgeSSEStream-K3UIMBTC.mjs +1 -0
- package/dist/bridgeWebSocketStream-2SUZUBE3.mjs +1 -0
- package/dist/browser-runtime-FFT5NH66.mjs +1 -0
- package/dist/browser.mjs +1 -2
- package/dist/canvas-chat-note-MGAEUYJO.mjs +1 -0
- package/dist/checkFixture-AMLLLJNS.mjs +1 -0
- package/dist/chunk-2ETPREWQ.mjs +1 -0
- package/dist/chunk-2P2NUZW7.mjs +1 -2
- package/dist/chunk-3GXLNBXU.mjs +1 -0
- package/dist/chunk-3WSTAV5B.mjs +1 -0
- package/dist/chunk-4LHTPRFY.mjs +1 -2
- package/dist/chunk-53SKVMWR.mjs +1 -0
- package/dist/chunk-57FM7XQV.mjs +1 -0
- package/dist/chunk-5D2ADU7H.mjs +1 -0
- package/dist/chunk-5K7SACPW.mjs +1 -2
- package/dist/chunk-67OWRNU3.mjs +30 -0
- package/dist/chunk-67QNAAUC.mjs +1 -0
- package/dist/chunk-BACXPVHP.mjs +1 -0
- package/dist/chunk-BFVLMSG5.mjs +1 -0
- package/dist/chunk-BJ25TGJN.mjs +1 -0
- package/dist/chunk-DOCRI237.mjs +1 -0
- package/dist/{chunk-C5WXW6VL.mjs → chunk-E5WNW4WE.mjs} +1 -1
- package/dist/chunk-EX63NVDN.mjs +1 -2
- package/dist/chunk-F5XSNRGT.mjs +1 -2
- package/dist/chunk-FMI4VQDZ.mjs +1 -0
- package/dist/chunk-G2ZHJXHZ.mjs +1 -0
- package/dist/chunk-G6RYESYI.mjs +1 -0
- package/dist/chunk-G7JR5Z3P.mjs +1 -0
- package/dist/chunk-GRPDZGPP.mjs +1 -0
- package/dist/chunk-GSEMSZDB.mjs +1 -0
- package/dist/chunk-H2RLTCUJ.mjs +1 -0
- package/dist/chunk-HAE5LUJX.mjs +1 -0
- package/dist/{chunk-IKCHOC3U.mjs → chunk-HV7HRQ2S.mjs} +0 -1
- package/dist/chunk-J3UIBBU2.mjs +1 -2
- package/dist/chunk-J4WDYITA.mjs +1 -2
- package/dist/chunk-JRP5XFYN.mjs +1 -0
- package/dist/chunk-LD3532UC.mjs +1 -0
- package/dist/chunk-LVEMYZOA.mjs +1 -2
- package/dist/chunk-MJ2PFKF3.mjs +1 -0
- package/dist/chunk-MP6ZV2DN.mjs +1 -0
- package/dist/chunk-N2ZEZCHO.mjs +1 -2
- package/dist/chunk-N66ZZG3L.mjs +1 -0
- package/dist/chunk-NSCO633B.mjs +1 -0
- package/dist/chunk-O4HZP3RP.mjs +1 -2
- package/dist/chunk-P4KM3K5M.mjs +1 -0
- package/dist/chunk-PH2MLB3T.mjs +1 -0
- package/dist/chunk-PQT5FYN5.mjs +1 -2
- package/dist/chunk-Q6C7ZA3H.mjs +1 -0
- package/dist/chunk-Q6N77LIS.mjs +1 -0
- package/dist/chunk-Q74FBX2I.mjs +1 -0
- package/dist/chunk-QQB5G3VB.mjs +1 -0
- package/dist/chunk-R3FPXDQS.mjs +1 -0
- package/dist/chunk-RK6UROPO.mjs +1 -0
- package/dist/chunk-RR4SHK7O.mjs +1 -0
- package/dist/chunk-RSUMSUAW.mjs +1 -0
- package/dist/{chunk-GL4I4MI6.mjs → chunk-RUJC32MA.mjs} +1 -1
- package/dist/chunk-RUTWU5W2.mjs +1 -0
- package/dist/chunk-TRHC7WBO.mjs +1 -0
- package/dist/chunk-V2I7PSJW.mjs +1 -2
- package/dist/chunk-WHJEKDNP.mjs +1 -2
- package/dist/chunk-XSMCZUDR.mjs +1 -0
- package/dist/chunk-XT6PHPPG.mjs +1 -0
- package/dist/chunk-XTOCFTVW.mjs +1 -2
- package/dist/chunk-Y6WD56SO.mjs +1 -0
- package/dist/chunk-YC5CUNRU.mjs +1 -0
- package/dist/chunk-YFDD7HGT.mjs +1 -0
- package/dist/chunk-YTUQYKLM.mjs +1 -0
- package/dist/chunk-YXPRWW6B.mjs +1 -0
- package/dist/chunk-ZVDKW7TO.mjs +1 -0
- package/dist/cli.mjs +1 -1
- package/dist/codex-note-context-NUKGR2WT.mjs +1 -0
- package/dist/codex-project-KE7ZZ6YX.mjs +1 -0
- package/dist/{codex-session-registry-SPRWY2WW.mjs → codex-session-registry-ONODFWFD.mjs} +1 -2
- package/dist/focus-inspection-BPPRCMNN.mjs +1 -0
- package/dist/index.d.mts +25 -0
- package/dist/index.mjs +1 -2
- package/dist/media.mjs +1 -2
- package/dist/memory-store.mjs +1 -1
- package/dist/peer-client-UQDASAO7.mjs +1 -0
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-next.mjs +1 -1
- package/dist/plugin-nuxt.mjs +1 -1
- package/dist/plugin-vite.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/steerStyles-VKQD57KC.mjs +1 -0
- package/dist/taste-proposal-session-XU4N7RUV.mjs +1 -2
- package/dist/workspace-snapshot-RTTXNNUX.mjs +1 -2
- package/package.json +1 -1
- package/dist/ExploreAttachment-CLFSAWKM.mjs +0 -260
- package/dist/ParticipantRuntime-HW3MOZI5.mjs +0 -139
- package/dist/PopmeltTasteConnectedPane-FKIJM3C7.mjs +0 -215
- package/dist/PreviewRuntime-LFPK56NW.mjs +0 -2
- package/dist/SuppliedContext-RWN6UR3K.mjs +0 -2
- package/dist/ThreadErrorCard-7J62GD5W.mjs +0 -2
- package/dist/ThreadPanel-RJIHV3P6.mjs +0 -197
- package/dist/bridgeSSEStream-NEYI73TC.mjs +0 -4
- package/dist/bridgeWebSocketStream-H3DCP4T3.mjs +0 -2
- package/dist/browser-runtime-JJHSKIKD.mjs +0 -2
- package/dist/canvas-chat-note-NHYL3T6J.mjs +0 -2
- package/dist/checkFixture-TJDFGPQI.mjs +0 -2
- package/dist/chunk-27ADDVGC.mjs +0 -3
- package/dist/chunk-2IASPT6L.mjs +0 -2
- package/dist/chunk-2VCHBI7Y.mjs +0 -11
- package/dist/chunk-2ZJ4FBTG.mjs +0 -2
- package/dist/chunk-6V2VCKPG.mjs +0 -53
- package/dist/chunk-6VXFTT5U.mjs +0 -2
- package/dist/chunk-75PQGTKX.mjs +0 -2
- package/dist/chunk-7IJGE5AK.mjs +0 -31
- package/dist/chunk-BVTLSUQT.mjs +0 -2
- package/dist/chunk-CPOYMGYY.mjs +0 -2
- package/dist/chunk-DMWB3IRD.mjs +0 -1
- package/dist/chunk-DNOKP3JS.mjs +0 -2
- package/dist/chunk-EAV2VV2V.mjs +0 -2
- package/dist/chunk-GASEZICN.mjs +0 -2
- package/dist/chunk-H2UYAUX3.mjs +0 -2
- package/dist/chunk-HNCV37XO.mjs +0 -2
- package/dist/chunk-I63OQTCF.mjs +0 -347
- package/dist/chunk-J5SC3R5L.mjs +0 -2
- package/dist/chunk-JMMP5JSP.mjs +0 -2
- package/dist/chunk-ODIGT4YJ.mjs +0 -17
- package/dist/chunk-PHKDIU3X.mjs +0 -30
- package/dist/chunk-PSSHCTJ2.mjs +0 -8
- package/dist/chunk-W5NIRROD.mjs +0 -7
- package/dist/chunk-XKD2ABCO.mjs +0 -7
- package/dist/chunk-XMKYGH62.mjs +0 -142
- package/dist/chunk-ZHJZPC7U.mjs +0 -2
- package/dist/codex-note-context-YHKPQ4WP.mjs +0 -2
- package/dist/codex-project-7VYHYTWO.mjs +0 -2
- package/dist/focus-inspection-VBS5656D.mjs +0 -2
- package/dist/peer-client-MTWZG2FB.mjs +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{i as e,g as t,a as r}from"./chunk-5D2ADU7H.mjs";var n=new Set;function a(t){return n.has(new URL(t).origin)?new o(t,!0):e(t)?new o(t):new EventSource(t)}var o=class{constructor(e,t=!1){this.readyState=0,this.onerror=null,this.controller=new AbortController,this.listeners=new Map,this.fail=()=>{this.controller.signal.aborted||(this.readyState=2,this.controller.abort(),this.emit("error",""),this.onerror?.call(this,new Event("error")))},typeof document<"u"&&document.addEventListener("resume",this.fail,{signal:this.controller.signal}),this.read(e,t)}addEventListener(e,t){let r=this.listeners.get(e)??new Set;r.add(t),this.listeners.set(e,r)}close(){this.readyState=2,this.controller.abort(),this.listeners.clear()}emit(e,t){let r=new MessageEvent(e,{data:t});for(let t of this.listeners.get(e)??[])t(r)}async read(e,t){try{if(t){let{readBridgeWebSocket:t}=await(import("./bridgeWebSocketStream-2SUZUBE3.mjs"));return void await t(e,this.controller.signal,(e,t)=>{"connected"===e&&(this.readyState=1),this.emit(e,t)})}let{readBridgeSSE:r}=await(import("./bridgeSSEStream-K3UIMBTC.mjs"));await r(e,this.controller.signal,()=>{this.readyState=1},(e,t)=>this.emit(e,t))}catch{this.fail()}}},i="http://localhost:1111",s=new Map;function l(){return typeof window<"u"?window.__POPMELT_PROJECT_ID__??null:null}function c(e,r={}){return t(e,function(e={}){let t=l();if(!t)return e;let r=new Headers(e.headers);return r.set("X-Popmelt-Project-Id",t),{...e,headers:r}}(r))}async function d(e,t,r){let n=new URLSearchParams({annotationId:t,kind:r.kind,name:r.name}),a=await f(`${e}/draft-attachments?${n}`,{method:"POST",headers:{"Content-Type":r.blob.type},body:r.blob},15e3);if(!a.ok)throw new Error((await a.json().catch(()=>null))?.error||`Bridge returned ${a.status}`);return(await a.json()).attachment}async function u(e,t){0!==t.length&&await f(`${e}/draft-attachments/claim`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:t})},5e3)}async function p(e,t){await f(`${e}/draft-attachments/${encodeURIComponent(t)}`,{method:"DELETE"},5e3)}async function h(e,t){if((s.get(e)??0)>Date.now())return null;try{let r=await f(`${e}/capture/native`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageUrl:t.url,clip:t.clip,scale:t.scale})},2500);if(!r.ok)return s.set(e,Date.now()+(404===r.status||501===r.status?6e4:1e4)),null;let n=await r.blob();return n.size>0?n:null}catch{return s.set(e,Date.now()+1e4),null}}function f(e,t={},r=15e3){let n=new AbortController;t.signal&&t.signal.addEventListener("abort",()=>n.abort());let a=setTimeout(()=>n.abort(),r);return c(e,{...t,signal:n.signal}).finally(()=>clearTimeout(a))}async function w(e=i){try{let t=await f(`${e}/ui-preferences`,{},5e3);return t.ok?await t.json():null}catch{return null}}async function g(e,t){try{let r=await f(`${e}/ui-preferences`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({theme:t})},5e3);return r.ok?await r.json():null}catch{return null}}async function m(e=i,t){try{let r=t?`?refresh=${encodeURIComponent(t)}`:"",n=await f(`${e}/capabilities${r}`,{},t?35e3:5e3);return n.ok?await n.json():null}catch{return null}}async function y(e,t){let a=new AbortController,o=setTimeout(()=>a.abort(),t);try{let t=await c(`${e}/status`,{signal:a.signal});if(!t.ok)return null;let o=await t.json();return function(e,t){let a=new URL(e).origin;"websocket"===t&&new URL(e).pathname!==r?n.add(a):n.delete(a)}(e,o.eventTransport),o}catch{return null}finally{a.abort(),clearTimeout(o)}}async function b(e=i){return y(e,2e3)}async function $(e){return y(`http://localhost:${e}`,500)}async function I(e){return b(e)}async function j(e,t){if(typeof location<"u"&&e===location.origin+r){let r=await I(e);return t&&r?.projectId===t?{url:e,port:Number(location.port)||443,projectId:t}:null}if(e&&e!==i)try{let r=new URL(e),n=await I(e);if(!n&&!t)return null;if((n||!t)&&(!n||!t||n.projectId===t)){if(n?.projectId&&!t)return null;if(n)return{url:e,port:parseInt(r.port,10)||1111,projectId:n.projectId}}}catch{if(!t)return null}let n=typeof window<"u"?window.location.origin:null,a=await $(1111);if(a){if(t&&a.projectId===t)return{url:"http://localhost:1111",port:1111,projectId:a.projectId};if(a.devOrigin&&n&&a.devOrigin===n&&!t&&!a.projectId)return{url:"http://localhost:1111",port:1111,projectId:a.projectId}}let o=function(e=1111){return Array.from({length:Math.min(32,65536-e)},(t,r)=>e+r)}().slice(1).map(e=>$(e).then(t=>t?{status:t,port:e}:null)),s=(await Promise.all(o)).filter(e=>null!==e),l=[];a&&l.push({port:1111,devOrigin:a.devOrigin,projectId:a.projectId});for(let e of s)l.push({port:e.port,devOrigin:e.status.devOrigin,projectId:e.status.projectId});if(t){let e=l.find(e=>e.projectId===t);if(e)return{url:`http://localhost:${e.port}`,port:e.port,projectId:e.projectId}}if(n){let e=l.find(e=>e.devOrigin===n&&!e.projectId);if(e)return{url:`http://localhost:${e.port}`,port:e.port,projectId:e.projectId}}return 1!==l.length||l[0].projectId?null:{url:`http://localhost:${l[0].port}`,port:l[0].port,projectId:l[0].projectId}}async function S(e=i,t,r=-1,n={}){try{let a=await f(`${e}/jobs/${t}/events?afterSeq=${r}`,{},5e3);if(404===a.status||410===a.status)return null;if(!a.ok){if(n.retryUnavailable&&(429===a.status||a.status>=500))throw new Error("Bridge history is temporarily unavailable");return null}return await a.json()}catch(e){if(n.retryUnavailable)throw e;return null}}async function k(e,t,r=i,n,a,o,s,l,c,d,u,p,h){let w=v({screenshots:e,feedbackJson:t,color:n,provider:a,model:o,pastedImages:s,sourceId:l,agentSettings:c,continuationThreadId:d,continuationSelectorAliases:u,continuationTargetBindingId:p}),g=await f(`${r}/send`,{method:"POST",body:w,...h?{headers:{"X-Popmelt-Peer-Grant":h}}:{}},3e4);if(!g.ok){let e=await g.text();throw new Error(`Bridge returned ${g.status}: ${e}`)}return g.json()}function v({screenshots:e,feedbackJson:t,color:r,provider:n,model:a,pastedImages:o,sourceId:i,agentSettings:s,continuationThreadId:l,continuationSelectorAliases:c,continuationTargetBindingId:d}){let u=new FormData;if(e instanceof Map){let t=!0;for(let[r,n]of e){let e=encodeURIComponent(r);u.append(`screenshot-${e}`,n,`screenshot-${e}.webp`),t&&(u.append("screenshot",n,"screenshot.webp"),t=!1)}t&&u.append("screenshot",new Blob([],{type:"image/webp"}),"screenshot.webp")}else u.append("screenshot",e,"screenshot.webp");if(u.append("feedback",t),r&&u.append("color",r),n&&u.append("provider",n),a&&u.append("model",a),function(e,t){t?.reasoningEffort&&e.append("reasoningEffort",t.reasoningEffort),t?.serviceTier&&e.append("serviceTier",t.serviceTier)}(u,s),i&&u.append("sourceId",i),l&&u.append("continuationThreadId",l),d&&u.append("continuationTargetBindingId",d),c?.length&&u.append("continuationSelectorAliases",JSON.stringify(c)),o)for(let[e,t]of o)for(let r=0;r<t.length;r++)u.append(`image-${e}-${r}`,t[r],`image-${e}-${r}.webp`);return u}async function T(e=i){let t=()=>({head:{sequence:0,updatedAt:new Date(0).toISOString()},counts:{total:0,emerging:0,testing:0,grounded:0,challenged:0,retired:0,needsGrounding:0},explanations:[]});try{let r=await f(`${e}/memory/imprint-view`,{},5e3);return r.ok?r.json():t()}catch{return t()}}function O(e){return new Promise(t=>setTimeout(t,e))}async function E(e=i,t,r=15e3){let n=Date.now();try{let t=await f(`${e}/restart`,{method:"POST"},5e3);if(!t.ok){let e=await t.text().catch(()=>"");return{ok:!1,error:e?`Bridge restart returned ${t.status}: ${e}`:`Bridge restart returned ${t.status}`,elapsedMs:Date.now()-n}}}catch(e){return{ok:!1,error:e instanceof Error?e.message:"Bridge restart request failed",elapsedMs:Date.now()-n}}let a=null,o=e,s=l();for(;Date.now()-n<r;){if(await O(350),a=await b(o),!a?.ok&&s){let t=await j(e,s);t?.url&&(o=t.url,a=await b(o))}if(a?.ok&&(!s||a.projectId===s)&&(!t||a.version===t))return{ok:!0,status:a,elapsedMs:Date.now()-n,bridgeUrl:o}}let c=t?` with version ${t}`:"";return a?.ok&&t&&a.version!==t?{ok:!1,error:`Bridge is running version ${a.version??"unknown"}, but this page expects ${t}. Refresh the page to load the current package. If the mismatch remains, rebuild or update the package used by the bridge, then restart it.`,status:a,elapsedMs:Date.now()-n}:{ok:!1,error:`Bridge did not come back${c} within ${Math.round(r/1e3)}s`,status:a,elapsedMs:Date.now()-n}}async function P(e=i){return(await E(e)).ok}async function B(e,t,r=i,n,a,o,s,l,c,d){let u,p=`${r}/reply`;if(s&&s.length>0){let r=new FormData,i=new Blob([new Uint8Array([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,6,0,0,0,31,21,196,137,0,0,0,10,73,68,65,84,120,156,98,0,0,0,2,0,1,229,39,222,252,0,0,0,0,73,69,78,68,174,66,96,130])],{type:"image/png"});r.append("screenshot",i,"screenshot.png"),r.append("feedback",JSON.stringify({threadId:e,reply:t,color:n,provider:a,model:o,sourceId:l,...c,...d}));for(let e=0;e<s.length;e++)r.append(`image-reply-${e}`,s[e],`reply-image-${e}.webp`);u={method:"POST",body:r}}else u={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:e,reply:t,color:n,provider:a,model:o,sourceId:l,...c,...d})};let h=await f(p,u,3e4);if(!h.ok){let e=await h.text();throw new Error(`Bridge returned ${h.status}: ${e}`)}return h.json()}async function U(e,t=i){let r=await f(`${t}/thread/${encodeURIComponent(e)}/archive`,{method:"POST"},15e3);if(!r.ok&&404!==r.status){let e=await r.text();throw new Error(`Bridge returned ${r.status}: ${e}`)}return r.json()}async function D(e,t=i){let r=await f(`${t}/thread/${encodeURIComponent(e)}/restore`,{method:"POST"},15e3);if(!r.ok)throw new Error(`Thread restore failed: ${r.status}`)}async function C(e=i){let t=await f(`${e}/workspace/clear`,{method:"POST"},5e3);if(!t.ok){let e=await t.text();throw new Error(`Bridge returned ${t.status}: ${e}`)}return t.json()}export{a,c as b,d as c,u as d,p as e,h as f,w as g,g as h,m as i,b as j,j as k,S as l,k as m,v as n,T as o,E as p,P as q,B as r,U as s,D as t,C as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{a as i}from"./chunk-G6RYESYI.mjs";import{a}from"./chunk-57FM7XQV.mjs";var n={gap:16,padding:12,radius:20,width:360,viewportGutter:32,identitySize:24},r={gap:6,padding:"4px 8px",radius:8,iconSize:12},e={gap:3,padding:"2px 6px",radius:8,iconSize:12},d={gap:3,padding:"3px 9px 3px 6px",radius:8,iconSize:10},p=d,s={size:21,padding:3,radius:8,iconSize:15},o={padding:"0 4px",height:18,radius:6},t={fontFamily:i,fontSize:12,fontWeight:500,lineHeight:1.3};function g(i){return{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:e.gap,padding:e.padding,borderRadius:e.radius,border:0,flexShrink:0,background:a[i].control,color:a[i].primary,...t,whiteSpace:"nowrap",cursor:"pointer",transition:"box-shadow 120ms ease"}}export{n as a,r as b,e as c,d,p as e,s as f,o as g,t as h,g as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{b as e}from"./chunk-DOCRI237.mjs";import{f as t}from"./chunk-YC5CUNRU.mjs";import{b as n,a,c as o,d as i,e as r,s,r as l}from"./chunk-N66ZZG3L.mjs";import{domToCanvas as m}from"modern-screenshot";import{useId as c,useState as p,useLayoutEffect as u}from"react";async function h(s,l){if(s&&s.pathname===location.pathname)try{let c=n(s),p=a(c.element),u=c.legacyScene||(p&&(p===c.element||c.element?.closest("svg,canvas"))?p:null),h=u?"component":"element",d=u??o(c,"element",!1);if(!d||d.closest("[data-popmelt-explore-original],[data-popmelt-explore-scene]"))return;let{width:f,height:g}=d.getBoundingClientRect();if(f<=0||g<=0)return;let v=getComputedStyle(d),x={capturedAt:Date.now(),backdrop:e(d),selector:s.selector,pathname:s.pathname,scope:h,width:f,height:g,viewport:{width:innerWidth,height:innerHeight},textFonts:r(d),style:Object.fromEntries(i.map(e=>[e,v.getPropertyValue(e)]))};try{let e=l&&(d.matches("canvas")||d.querySelector("canvas"))?await l():[],n=await t(e,()=>m(d,{width:Math.ceil(f),height:Math.ceil(g),scale:Math.min(2,512/Math.max(f,g)),timeout:1500,backgroundColor:x.backdrop,style:{margin:"0",position:"static",transform:"none"},filter:e=>!(e instanceof Element&&e.matches("[data-devtools],[data-popmelt-root],[data-popmelt-explore-preview]"))}));for(;n.width&&n.height;){let e=n.toDataURL("image/webp",.8);if(e.length<=96e3&&/^data:image\/(webp|png);base64,/.test(e)){x.still=e;break}if(Math.max(n.width,n.height)<32)break;let t=document.createElement("canvas");t.width=Math.max(1,Math.floor(n.width/2)),t.height=Math.max(1,Math.floor(n.height/2)),t.getContext("2d").drawImage(n,0,0,t.width,t.height),n=t}}catch{}return x}catch{return}}async function d(e,t){let n=1===e.annotations.length&&e.annotations[0];n&&s(n.instruction??"")&&(e.exploreCapture=await h(l(n,location.pathname),t))}function f(e,t,n){let a=e.flatMap(({requestedAt:e,resolvedAt:a})=>Number.isFinite(e)&&Number.isFinite(a)?[[Math.max(t,e),Math.min(n,a)]]:[]).sort((e,t)=>e[0]-t[0]),o=t,i=0;for(let[e,t]of a)i+=Math.max(0,t-Math.max(o,e)),o=Math.max(o,t);return i}function g(e){let t=new Map,n=new Set;for(let a of e)if("approval"===a.type){let e=a.data.approval;t.set(e.id,e)}else("done"===a.type||"error"===a.type)&&n.add(String(a.data.jobId));return new Set([...t.values()].filter(e=>"pending"===e.status&&!n.has(e.jobId)).map(e=>e.jobId))}function v(e,t){if(!e?.frames?.length)return[];let n=new Map;for(let t of e.steps){let e=t.visuals?.afterFrameId;e&&!n.has(e)&&n.set(e,t.action?.label?`After ${t.action.label}`:"Resulting state")}return e.frames.flatMap((e,a)=>{let o=t[e.imageIndex];return o?[{id:e.id,imageIndex:e.imageIndex,label:0===a?"Initial state":n.get(e.id)??"State",url:o}]:[]})}function x(e){let t=e.instruction?.trim();return t?e.attachments?.some(e=>e.name?.trim()===t)?null:t:null}function b(e,t){let n=e?.tagName?.toLowerCase(),a=e?.id?`#${e.id}`:"",o=e?.className?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"",i=n?`${n}${a}${o}`:t;return e?.reactComponent?`<${e.reactComponent}> ${i}`:i}function w(e){let t=e.elements?.[0]?.reactComponent||e.elements?.[0]?.tagName||e.linkedSelector,n=e.type&&"annotation"!==e.type?`${e.type} annotation`:"Annotation";return t?`${n} on ${t}`:n}function y(e){let t=e.annotations.map(e=>{let t=e.interactionEpisode?.steps.length??0;return{kind:"annotation",annotationId:e.id,pathname:e.pathname,text:x(e)??w(e),...t>0?{interactionEpisodeStepCount:t}:{}}}),n=new Map,a=e=>{let a=`${e.pathname??""}:${e.durableSelector??e.selector}`,o=n.get(a);if(o)return o.changes.push(e.text),void(void 0!==e.annotationNumber&&(void 0===o.annotationNumber||e.annotationNumber<o.annotationNumber)&&(o.annotationNumber=e.annotationNumber));let i={kind:"changes",elementKey:a,elementLabel:b(e.element,e.selector),...void 0!==e.annotationNumber?{annotationNumber:e.annotationNumber}:{},pathname:e.pathname,changes:[e.text]};n.set(a,i),t.push(i)};for(let t of e.styleModifications??[])for(let e of t.changes)a({...t,text:`${e.property}: ${e.original||"unset"} → ${e.modified||"unset"}${e.token?` (${e.token})`:""}`});for(let t of e.textModifications??[])a({...t,text:`Text: ${t.original||"empty"} → ${t.modified||"empty"}`});for(let t of e.domModifications??[])a({...t,text:"copy"===t.operation?"Copied element":"Moved element"});return e.spacingTokenChanges?.length&&t.push({kind:"changes",elementKey:"spacing-tokens",elementLabel:"Spacing tokens",changes:e.spacingTokenChanges.map(e=>`${e.tokenName}: ${e.originalPx}px → ${e.newPx}px`)}),t}function $(e){let t=e.annotations.flatMap(e=>{let t=x(e);return t?[{instruction:t,pathname:e.pathname}]:[]});if(0===t.length)return;if(new Set(t.map(e=>e.pathname).filter(Boolean)).size<=1)return t.map(e=>e.instruction).join("\n\n");let n=new Map;for(let e of t){let t=e.pathname||"(unknown)",a=n.get(t)??[];a.push(e.instruction),n.set(t,a)}return[...n.entries()].map(([e,t])=>`\`${e}\`\n${t.map(e=>`- ${e}`).join("\n")}`).join("\n")}function M(e,t=96){let n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,Math.max(0,t-3))}...`:n}function k(e,t){let n=c(),[a,o]=p(-1),[i,r]=p(!1),s=t.some(({suffix:e})=>e);u(()=>{let t=e.current;if(!t||!s)return;let n=()=>o(t.matches(":focus")&&t.selectionStart===t.selectionEnd?t.selectionEnd:-1),a=()=>o(-1);return n(),t.addEventListener("selectionchange",n),t.addEventListener("select",n),t.addEventListener("input",n),t.addEventListener("focus",n),t.addEventListener("blur",a),()=>{t.removeEventListener("selectionchange",n),t.removeEventListener("select",n),t.removeEventListener("input",n),t.removeEventListener("focus",n),t.removeEventListener("blur",a)}},[s,e]);let l=i?void 0:t.find(({start:e,token:t,suffix:n})=>n&&e+t.length===a);return{active:l,complete:function(e,t){let n=e.currentTarget;if(!l||"Tab"!==e.key||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey||e.nativeEvent.isComposing||n.selectionStart!==a||n.selectionEnd!==a)return!1;e.preventDefault(),e.stopPropagation();let o=/\s/.test(n.value.charAt(a)),i=l.suffix+(o?"":" ");return n.ownerDocument.execCommand?.("insertText",!1,i)||(n.setRangeText(i,a,a,"end"),t()),o&&n.setSelectionRange(a+i.length+1,a+i.length+1),!0},hintId:n,inputProps:{"aria-autocomplete":l?"inline":void 0,"aria-describedby":l?n:void 0,onCompositionStart:()=>r(!0),onCompositionEnd:()=>r(!1)}}}function C(e,t,n){return n?.activePreview?n.annotationNumber:e??t}function E(e,t){return e?.trim()?e.trim():function(e){let t=e?.requestItems?.flatMap(e=>"annotation"===e.kind&&e.text.trim()?[e.text.trim()]:[]);if(t?.length)return t.join("; ");let n=e?.requestItems?.flatMap(e=>"changes"===e.kind?[`${e.elementLabel} [${e.changes.join(", ")}]`]:[]);return n?.length?n.join("; "):e?.requestText?.trim()||void 0}(t.find(e=>"human"===e.role))}export{h as a,d as b,f as c,g as d,v as e,y as f,$ as g,M as h,k as i,C as j,E as k};
|