@popmelt.com/core 0.32.2 → 0.33.1

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.
Files changed (112) hide show
  1. package/README.md +23 -0
  2. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  3. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  4. package/dist/ExploreAttachment-VKCCEIM7.mjs +1 -0
  5. package/dist/ParticipantRuntime-YS5SIZUQ.mjs +1 -0
  6. package/dist/PopmeltTasteConnectedPane-FKIJM3C7.mjs +1 -0
  7. package/dist/PreviewRuntime-LFPK56NW.mjs +1 -0
  8. package/dist/QueuedReplies-ZYUDSTS2.mjs +1 -46
  9. package/dist/SuppliedContext-RWN6UR3K.mjs +1 -0
  10. package/dist/ThreadErrorCard-7J62GD5W.mjs +1 -0
  11. package/dist/ThreadPanel-KVNM67WO.mjs +1 -0
  12. package/dist/adapter-react-three-fiber.mjs +1 -2
  13. package/dist/bridge-entry.mjs +1 -1
  14. package/dist/bridge-recovery-3IQN3U6D.mjs +1 -2
  15. package/dist/bridgeSSEStream-NEYI73TC.mjs +1 -4
  16. package/dist/bridgeWebSocketStream-H3DCP4T3.mjs +1 -2
  17. package/dist/browser-runtime-AP35S5MK.mjs +1 -0
  18. package/dist/browser.mjs +1 -2
  19. package/dist/canvas-chat-note-NHYL3T6J.mjs +1 -2
  20. package/dist/checkFixture-MWBOYIM2.mjs +1 -0
  21. package/dist/chunk-27ADDVGC.mjs +1 -0
  22. package/dist/chunk-2IASPT6L.mjs +1 -0
  23. package/dist/chunk-2P2NUZW7.mjs +1 -2
  24. package/dist/chunk-2VCHBI7Y.mjs +1 -0
  25. package/dist/chunk-2ZJ4FBTG.mjs +1 -0
  26. package/dist/chunk-4LHTPRFY.mjs +1 -2
  27. package/dist/chunk-5K7SACPW.mjs +1 -0
  28. package/dist/chunk-6V2VCKPG.mjs +1 -0
  29. package/dist/chunk-6VXFTT5U.mjs +1 -2
  30. package/dist/chunk-75PQGTKX.mjs +1 -0
  31. package/dist/chunk-BVTLSUQT.mjs +1 -0
  32. package/dist/chunk-CPOYMGYY.mjs +1 -2
  33. package/dist/chunk-DNOKP3JS.mjs +1 -0
  34. package/dist/chunk-EAV2VV2V.mjs +1 -0
  35. package/dist/chunk-EX63NVDN.mjs +1 -2
  36. package/dist/chunk-F5XSNRGT.mjs +1 -0
  37. package/dist/chunk-GASEZICN.mjs +1 -0
  38. package/dist/chunk-GL4I4MI6.mjs +1 -3
  39. package/dist/chunk-H7XMDLGU.mjs +30 -0
  40. package/dist/chunk-HVD5ZG6W.mjs +1 -0
  41. package/dist/chunk-IKCHOC3U.mjs +1 -2
  42. package/dist/chunk-J3UIBBU2.mjs +1 -2
  43. package/dist/chunk-J4WDYITA.mjs +1 -2
  44. package/dist/chunk-JMMP5JSP.mjs +1 -0
  45. package/dist/chunk-LVEMYZOA.mjs +1 -2
  46. package/dist/chunk-N2QUNHV6.mjs +1 -0
  47. package/dist/chunk-N2ZEZCHO.mjs +1 -2
  48. package/dist/chunk-N6JTX4PD.mjs +2 -0
  49. package/dist/chunk-NOHXTT24.mjs +1 -1
  50. package/dist/chunk-O4HZP3RP.mjs +1 -2
  51. package/dist/chunk-ODIGT4YJ.mjs +1 -0
  52. package/dist/chunk-PQT5FYN5.mjs +1 -0
  53. package/dist/chunk-PSSHCTJ2.mjs +1 -0
  54. package/dist/chunk-QOJCTLQW.mjs +1 -0
  55. package/dist/chunk-QXVMGZFP.mjs +1 -1
  56. package/dist/chunk-RESPUCV7.mjs +1 -0
  57. package/dist/chunk-SHAIHRV2.mjs +1 -0
  58. package/dist/chunk-V2I7PSJW.mjs +1 -0
  59. package/dist/chunk-VPPVURBR.mjs +2 -0
  60. package/dist/chunk-W5NIRROD.mjs +1 -0
  61. package/dist/chunk-WHJEKDNP.mjs +1 -0
  62. package/dist/chunk-XKD2ABCO.mjs +1 -0
  63. package/dist/chunk-XTOCFTVW.mjs +1 -2
  64. package/dist/chunk-YLKEDOII.mjs +31 -0
  65. package/dist/chunk-ZHJZPC7U.mjs +1 -0
  66. package/dist/cli.mjs +1 -69
  67. package/dist/codex-note-context-4JYQ437H.mjs +2 -0
  68. package/dist/codex-project-FA4EK6VR.mjs +2 -0
  69. package/dist/codex-session-registry-SPRWY2WW.mjs +1 -1
  70. package/dist/focus-inspection-VBS5656D.mjs +1 -0
  71. package/dist/index.mjs +1 -2
  72. package/dist/media.mjs +1 -2
  73. package/dist/memory-legacy.mjs +1 -1
  74. package/dist/memory-store.mjs +1 -1
  75. package/dist/peer-client-KJCPXT76.mjs +2 -0
  76. package/dist/plugin-astro.mjs +1 -31
  77. package/dist/plugin-nuxt.mjs +1 -30
  78. package/dist/plugin-vite.mjs +1 -1
  79. package/dist/server.d.mts +2 -0
  80. package/dist/server.mjs +1 -14
  81. package/dist/taste-proposal-session-XU4N7RUV.mjs +1 -2
  82. package/dist/workspace-snapshot-RTTXNNUX.mjs +1 -0
  83. package/package.json +4 -2
  84. package/dist/ParticipantRuntime-M762IJI2.mjs +0 -139
  85. package/dist/PopmeltTasteConnectedPane-ZW47K7VZ.mjs +0 -221
  86. package/dist/PreviewRuntime-QDA4OF67.mjs +0 -2
  87. package/dist/SuppliedContext-NURVPZ4L.mjs +0 -2
  88. package/dist/ThreadErrorCard-OMXKVZY4.mjs +0 -2
  89. package/dist/browser-runtime-VHGXBZA5.mjs +0 -2
  90. package/dist/chunk-2RRYBN2J.mjs +0 -17
  91. package/dist/chunk-3GHVZGWO.mjs +0 -347
  92. package/dist/chunk-45JUZT7H.mjs +0 -2
  93. package/dist/chunk-5HNQZ6TH.mjs +0 -2
  94. package/dist/chunk-ABX3VAYF.mjs +0 -317
  95. package/dist/chunk-B2MFT2SV.mjs +0 -62
  96. package/dist/chunk-C3VWS5R6.mjs +0 -3
  97. package/dist/chunk-EXDOFFFJ.mjs +0 -2
  98. package/dist/chunk-F6AMPRUB.mjs +0 -2
  99. package/dist/chunk-K63SG2J5.mjs +0 -2
  100. package/dist/chunk-KAKYUYLC.mjs +0 -310
  101. package/dist/chunk-MTQ5IWIK.mjs +0 -2
  102. package/dist/chunk-MZNY6VXR.mjs +0 -2
  103. package/dist/chunk-QTGE5KAA.mjs +0 -2
  104. package/dist/chunk-RCVAPQ7X.mjs +0 -2
  105. package/dist/chunk-VAPWW76T.mjs +0 -1
  106. package/dist/chunk-WL62X74S.mjs +0 -342
  107. package/dist/chunk-YHSHUWWI.mjs +0 -1
  108. package/dist/codex-note-context-NGOK23TK.mjs +0 -2
  109. package/dist/codex-project-EMYHOQCC.mjs +0 -2
  110. package/dist/focus-inspection-G72JLJYG.mjs +0 -2
  111. package/dist/peer-client-6FUDDS46.mjs +0 -2
  112. package/dist/workspace-snapshot-O34KMJ2V.mjs +0 -2
@@ -1,2 +0,0 @@
1
- "use client";
2
- import{k as y,a as g,i as S}from"./chunk-EXDOFFFJ.mjs";function h(e){return Array.from(e,t=>{if(t==='"'||t==="\\")return`\\${t}`;let r=t.codePointAt(0);return r<32||r===127?`\\${r.toString(16)} `:t}).join("")}function f(e){return`[data-popmelt-subject-adapter="${h(e.adapter)}"][data-popmelt-subject-key="${h(e.key)}"]`}function k(e){let t=e?.getAttribute("data-popmelt-subject-adapter"),r=e?.getAttribute("data-popmelt-subject-key");return t&&r?{adapter:t,key:r}:void 0}function d(e,t){let r=!1;e.dataset.popmeltSubjectLabel!==t.label&&(e.dataset.popmeltSubjectLabel=t.label,r=!0);let{left:a,top:i,width:n,height:s}=t.bounds,u=l=>`${Math.round(l*2)/2}px`,b={left:u(a),top:u(i),width:u(Math.max(0,n)),height:u(Math.max(0,s))};for(let[l,c]of Object.entries(b)){let m=l;e.style[m]!==c&&(e.style[m]=c,r=!0)}let o=t.surfaceBounds,j={popmeltSubjectSurfaceLeft:o?String(o.left):void 0,popmeltSubjectSurfaceTop:o?String(o.top):void 0,popmeltSubjectSurfaceWidth:o?String(o.width):void 0,popmeltSubjectSurfaceHeight:o?String(o.height):void 0};for(let[l,c]of Object.entries(j))c===void 0?l in e.dataset&&(delete e.dataset[l],r=!0):e.dataset[l]!==c&&(e.dataset[l]=c,r=!0);let p=t.outline?.map(l=>`${l.x},${l.y}`).join(" ");return p?e.dataset.popmeltSubjectOutline!==p&&(e.dataset.popmeltSubjectOutline=p,r=!0):e.dataset.popmeltSubjectOutline!==void 0&&(delete e.dataset.popmeltSubjectOutline,r=!0),r}var v=class{constructor(e){this.adapters=e,this.projections=new Map,this.frameListeners=new Set,this.frame=null,this.lastProjectionFrameTime=0,this.adapterUnsubscribes=e.flatMap(t=>{let r=t.subscribe?.(()=>{for(let a of this.frameListeners)a()});return r?[r]:[]})}async whenReady(){await Promise.all(this.adapters.map(e=>e.whenReady?.()))}hitTest(e){return this.hitTestAll(e)[0]??null}hitTestAll(e){let t=new Map;for(let r=this.adapters.length-1;r>=0;r-=1){let a=this.adapters[r];if(!a)continue;let i=(a.hitTestAll?.(e)??[a.hitTest(e)]).filter(n=>!!n).filter(n=>{let s=n.sourceElement;return s?(t.has(s)||t.set(s,y(s,e.x,e.y)),t.get(s)):!0}).map(n=>this.project(a,n));if(i.length>0)return i}return[]}resolve(e){let t=this.adapters.find(a=>a.id===e.adapter);if(!t)return null;let r=t.resolve(e.key);return r?this.project(t,r):null}restore(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.restoreSubject?.(e.key,t);return r&&a?this.project(r,a):null}async captureFeedback(e){let t=this.resolve(e);if(!t)return null;let{adapter:r,subject:a}=t,i={...t.elementInfo};if(a.sourceElement&&(i.sourceElement={...S(a.sourceElement),selector:g(a.sourceElement)}),!r.captureSubject)return{elementInfo:i};try{let n=await r.captureSubject(e.key);return n?{elementInfo:i,crop:n}:{elementInfo:i,warning:"Object crop unavailable; use the page screenshot and image coordinates."}}catch{return{elementInfo:i,warning:"Object crop unavailable (the image may block canvas access via CORS); use the page screenshot and image coordinates."}}}beginCreate(e){for(let t=this.adapters.length-1;t>=0;t-=1){let r=this.adapters[t],a=r?.beginCreate?.(e);if(r&&a)return{adapter:r,session:a}}return null}rename(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.renameSubject?.(e.key,t);return r&&a?this.project(r,a):null}updateBounds(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.updateSubjectBounds?.(e.key,t);return r&&a?this.project(r,a):null}updateTrackingAnchors(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.updateSubjectTrackingAnchors?.(e.key,t);return r&&a?this.project(r,a):null}promote(e){let t=this.adapters.find(a=>a.id===e.adapter),r=t?.promoteSubject?.(e.key);return t&&r?this.project(t,r):null}remove(e){this.adapters.find(t=>t.id===e.adapter)?.removeSubject?.(e.key)}async captureSurfaces(){return(await Promise.all(this.adapters.map(async e=>e.captureSurfaces?.()??[]))).flat()}subscribeFrame(e){return this.frameListeners.add(e),()=>this.frameListeners.delete(e)}destroy(){this.frame!==null&&cancelAnimationFrame(this.frame),this.frame=null;for(let e of this.projections.values())e.element.remove();this.projections.clear();for(let e of this.adapterUnsubscribes)e();this.frameListeners.clear()}project(e,t){let r={adapter:e.id,key:t.key},a=`${e.id}\0${t.key}`,i=this.projections.get(a);if(i)return i.subject=t,i.elementInfo=this.elementInfo(e,t,i.selector),d(i.element,t),i;let n=f(r),s=document.createElement("div");s.dataset.popmeltSubjectAdapter=e.id,s.dataset.popmeltSubjectKey=t.key,s.dataset.popmeltSubjectLabel=t.label,s.dataset.popmeltSubjectProjection="true",s.setAttribute("aria-hidden","true"),Object.assign(s.style,{position:"fixed",pointerEvents:"none",opacity:"0",zIndex:"-1"}),d(s,t),document.body.appendChild(s);let u={adapter:e,subject:t,target:r,element:s,selector:n,elementInfo:this.elementInfo(e,t,n)};return this.projections.set(a,u),this.ensureFrame(),u}elementInfo(e,t,r){return{selector:r,tagName:e.id,subjectLabel:t.label,textContent:t.label,context:t.context,...t.imageObject?{imageObject:t.imageObject}:{},...t.videoObject?{videoObject:t.videoObject}:{},dataAttributes:{adapter:e.id,key:t.key,...t.data??{}}}}ensureFrame(){if(this.frame!==null||this.projections.size===0)return;let e=t=>{if(this.frame=null,this.lastProjectionFrameTime>0&&t-this.lastProjectionFrameTime<32){this.ensureFrame();return}this.lastProjectionFrameTime=t;let r=!1;for(let[a,i]of this.projections){let n=i.adapter.resolve(i.target.key);if(!n){i.element.remove(),this.projections.delete(a),r=!0;continue}i.subject=n,r=d(i.element,n)||r}if(r)for(let a of this.frameListeners)a();this.projections.size>0&&this.ensureFrame()};this.frame=requestAnimationFrame(e)}};export{f as a,k as b,v as c};
@@ -1,2 +0,0 @@
1
- "use client";
2
- import{a as d,e}from"./chunk-2RRYBN2J.mjs";var p={gap:16,padding:12,radius:20,width:360,viewportGutter:32,identitySize:24},s={gap:6,padding:"4px 8px",radius:8,iconSize:12},a={gap:3,padding:"2px 6px",radius:8,iconSize:12},n={gap:3,padding:"3px 9px 3px 6px",radius:8,iconSize:10},o=n,t={size:21,padding:3,radius:8,iconSize:15},g={padding:"0 4px",height:18,radius:6},r={fontFamily:d,fontSize:12,fontWeight:500,lineHeight:1.3};function u(i){return{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:a.gap,padding:a.padding,borderRadius:a.radius,border:0,flexShrink:0,background:e[i].control,color:e[i].primary,...r,whiteSpace:"nowrap",cursor:"pointer",transition:"box-shadow 120ms ease"}}export{p as a,s as b,a as c,n as d,o as e,t as f,g,r as h,u as i};
@@ -1,2 +0,0 @@
1
- "use client";
2
- import{c as v}from"./chunk-MTQ5IWIK.mjs";import{a as P,l as R,h as $,j as x,k as g,i as b,m as y}from"./chunk-F6AMPRUB.mjs";import{v as A}from"./chunk-RCVAPQ7X.mjs";var O="__popmelt_code_preview";function C(a,n){let t=new URL(a,n);if(t.origin!==new URL(n).origin||!/^https?:$/.test(t.protocol))throw new Error("Code previews must use the same application origin");return t.hash="",t.searchParams.delete("popmelt"),t.searchParams.set(O,"1"),t.href}function T(a,n){if(!new URL(location.href).searchParams.has(O))return!1;if(parent===window)return!0;window.__POPMELT_CODE_PREVIEW__?.dispose();let t=P,w="",s=!1,u=0,d=new Map,h=()=>{for(let[e,i]of d)i===null?e.removeAttribute("data-pm"):e.setAttribute("data-pm",i);d.clear()},r=new v(n?.get()??[]),m=()=>{for(let e of t.annotations)e.target&&r.resolve(e.target)},_=()=>{R(t.domModifications),$(t.styleModifications),x(t.textModifications),m();for(let e of t.annotations){let i=e.linkedSelector?.match(/^\[data-pm="([^"]+)"\]$/)?.[1];if(!i)continue;let o=A(e.linkedSelector,e.elements?.[0]);o&&(d.has(o)||d.set(o,o.getAttribute("data-pm")),o.setAttribute("data-pm",i))}},c=new MutationObserver(e=>{e.some(i=>i.addedNodes.length)&&(cancelAnimationFrame(u),u=requestAnimationFrame(()=>{c.disconnect(),_(),p()}))}),p=()=>c.observe(document.body,{childList:!0,subtree:!0}),E=()=>{let e=r;e.whenReady().then(()=>{!s&&r===e&&(m(),document.dispatchEvent(new Event("popmelt-subjects-ready")))})},L=n?.subscribe(()=>{r.destroy(),r=new v(n.get()),m(),E()});E();let f={dispose(){s||(s=!0,c.disconnect(),L?.(),r.destroy(),cancelAnimationFrame(u),window.removeEventListener("pagehide",f.dispose),window.__POPMELT_CODE_PREVIEW__===f&&delete window.__POPMELT_CODE_PREVIEW__,g(t.textModifications),b(t.styleModifications,!0),y(t.domModifications),h())},source:a,getSubjects:()=>r,update(e){if(s)throw new Error("Preview runtime closed");if(e.draft.source&&e.draft.source.sourceId!==a.sourceId)throw new Error("This draft belongs to a different source");let i=JSON.stringify([e.planeId,e.draft.revision,e.draft.source?.sourceId,e.draft.source?.revision]);if(w===i)return;let o=structuredClone(e.draft.state??P),l=M=>!M.pathname||M.pathname===location.pathname,I={...o,annotations:o.annotations.filter(l),styleModifications:o.styleModifications.filter(l),textModifications:o.textModifications.filter(l),domModifications:o.domModifications.filter(l)};c.disconnect(),g(t.textModifications),b(t.styleModifications,!0),y(t.domModifications),h(),t=I,_(),p(),w=i}};return window.__POPMELT_CODE_PREVIEW__=f,p(),window.addEventListener("pagehide",f.dispose,{once:!0}),!0}export{C as a,T as b};
@@ -1,2 +0,0 @@
1
- "use client";
2
- function m(t){try{let e=t.defaultView?.frameElement;return e?.localName==="iframe"?e:null}catch{return null}}function w(t){if(t.localName!=="iframe"||t.closest("[data-devtools],[data-popmelt-peer-surface]"))return null;try{let e=t.contentDocument;return e?.documentElement?e:null}catch{return null}}function D(t){let e=t.getBoundingClientRect(),r=t.offsetWidth?e.width/t.offsetWidth:1,u=t.offsetHeight?e.height/t.offsetHeight:1;return{x:e.left+t.clientLeft*r,y:e.top+t.clientTop*u,sx:r,sy:u}}function v(t,e){let{left:r,top:u,width:o,height:n}=t,l=m(e);for(;l;){let a=D(l);r=a.x+r*a.sx,u=a.y+u*a.sy,o*=a.sx,n*=a.sy,l=m(l.ownerDocument)}return new DOMRect(r,u,o,n)}function V(t){return v(t.getBoundingClientRect(),t.ownerDocument)}function M(t,e,r){let u=[],o=m(r);for(;o;)u.unshift(o),o=m(o.ownerDocument);for(let n of u){let l=D(n);t=(t-l.x)/l.sx,e=(e-l.y)/l.sy}return{x:t,y:e}}function k(t){return t.ownerDocument.defaultView??window}function z(t){return!!(t&&t.namespaceURI==="http://www.w3.org/1999/xhtml")}function A(t,e=document){if(t===e)return!0;let r=m(t);return!!(r?.isConnected&&r.contentDocument===t&&A(r.ownerDocument,e))}function B(t,e){if(!A(e))return new DOMRect(0,0,0,0);let r=t.left,u=t.top,o=t.right,n=t.bottom;for(let l=m(e);l;l=m(l.ownerDocument)){let a=v({left:0,top:0,width:l.clientWidth,height:l.clientHeight},l.contentDocument);r=Math.max(r,a.left),u=Math.max(u,a.top),o=Math.min(o,a.right),n=Math.min(n,a.bottom)}return new DOMRect(r,u,Math.max(0,o-r),Math.max(0,n-u))}var g="@frame(";function I(t,e){return`${g}${encodeURIComponent(JSON.stringify({selector:t,url:e.URL}))}) `}function O(t){if(!t.startsWith(g))return null;let e=t.indexOf(") ");if(e<0)return null;try{let r=JSON.parse(decodeURIComponent(t.slice(g.length,e)));return typeof r.selector!="string"||typeof r.url!="string"?null:{...r,rest:t.slice(e+2)}}catch{return null}}var b=" >>> ";function N(t){return Array.from(t.querySelectorAll("*")).flatMap(e=>e.shadowRoot?[e.shadowRoot]:[])}function S(t=document){let e=[t];for(let r of e)e.push(...N(r));return e}function p(t,e=document){if(t.startsWith(g)){let o=O(t);if(!o)return null;let n=o.selector.startsWith(g)||o.selector.includes(b)?[p(o.selector,e)].filter(s=>!!s):S(e).flatMap(s=>Array.from(s.querySelectorAll(o.selector))),l=n.length===1?n[0]:null,a=l&&w(l);return!a||a.URL!==o.url?null:p(o.rest,a)}let r=t.split(b);if(r.length>1){let o=e,n=null;for(let l=0;l<r.length;l+=1){if(n=o.querySelector(r[l]),!n)return null;if(l<r.length-1){if(!n.shadowRoot)return null;o=n.shadowRoot}}return n}let u=[e];for(let o of u){let n=o.querySelector(t);if(n)return n;u.push(...N(o))}return null}function R(t){if(t.parentElement)return t.parentElement;let e=t.getRootNode();return"host"in e?e.host:null}function _(t,e){return e.startsWith(g)||e.includes(b)?p(e)===t:t.matches(e)}function $(t,e){let r=t;for(;r;){if(r.matches(e))return r;r=R(r)}return null}function H(t,e){let r=e;for(;r;){if(r===t)return!0;r=R(r)}return!1}var W=new WeakMap;function E(t){let e=t.getAttribute("style");return t.style.setProperty("pointer-events","auto","important"),()=>{e===null?t.removeAttribute("style"):t.setAttribute("style",e)}}function J(t){let e=t.nodeType===9?t:t.ownerDocument,r="* { pointer-events: auto !important; }",u=[];try{let o=e.defaultView?.CSSStyleSheet;if(o?.prototype.replaceSync&&"adoptedStyleSheets"in t){let n=W.get(e);n||(n=new o,n.replaceSync(r),W.set(e,n));let l=[...t.adoptedStyleSheets];t.adoptedStyleSheets=[...l,n],u.push(()=>{t.adoptedStyleSheets=l})}else{let n=e.createElement("style");n.textContent=r,(t.nodeType===9?e.head??e.documentElement:t).appendChild(n),u.push(()=>n.remove())}for(let n of t.querySelectorAll('[style*="pointer-events"]'))n.style.getPropertyValue("pointer-events")!=="none"||n.style.getPropertyPriority("pointer-events")!=="important"||u.push(E(n))}catch(o){throw u.reverse().forEach(n=>n()),o}return()=>u.reverse().forEach(o=>o())}function G(t,e,r,u=n=>[n],o){let n=[];for(let l of t.querySelectorAll("iframe")){if(!w(l))continue;let a=l.getBoundingClientRect();e<a.left||e>a.right||r<a.top||r>a.bottom||l.ownerDocument.defaultView?.getComputedStyle(l).pointerEvents==="none"&&n.push(E(l))}try{let l=()=>{let c=typeof t.elementsFromPoint=="function"?t.elementsFromPoint(e,r):[],i=t.elementFromPoint?.(e,r)??null;return(i&&!c.includes(i)?[i,...c]:c).filter(f=>t.nodeType===9||f.getRootNode()===t)},a=l(),s=a;if(o){let c=J(t);try{s=l()}finally{c()}s=s.filter(i=>a.includes(i)||o(i))}return s.flatMap(u)}finally{n.forEach(l=>l())}}function q(t,e,r=document,u){let o=[],n=new Set,l=r.nodeType===9?r:r.ownerDocument,a=M(t,e,l);for(let s of S(r).reverse())for(let c of G(s,a.x,a.y,i=>{let f=w(i);return f?[...q(t,e,f,u),i]:[i]},u))n.has(c)||(n.add(c),o.push(c));return o}function K(){return b}var Q=["id","data-testid","data-test","data-cy","data-popmelt-media-id","aria-label","name","href"],j=t=>t.replace(/\s+/g," ").trim();function y(t){return t==="id"||t==="data-popmelt-media-id"||/^data-(?:testid|test|cy)(?:-[a-z0-9_-]+)?$/.test(t)}function F(t,e){return!!(e&&e.length<=200&&!(t==="id"&&/^(radix-|:|_r_)/.test(e)))}function P(t){let e={},r=new Set([...Q,...t.getAttributeNames().filter(y)]);for(let n of r){let l=t.getAttribute(n);l&&F(n,l)&&(e[n]=l)}let u=j(t.querySelector("h1,h2,h3,h4,h5,h6")?.textContent??""),o=j(Array.from(t.childNodes).filter(n=>n.nodeType===3).map(n=>n.textContent).join(" "));return{tag:t.tagName.toLowerCase(),...Object.keys(e).length?{attributes:e}:{},...u&&u.length<=200?{heading:u}:{},...o&&o.length<=200?{text:o}:{}}}function L(t,e,r=document){let u=S(r),o=i=>{try{return u.flatMap(f=>Array.from(f.querySelectorAll(i)))}catch{return[]}},n=!!(e&&(e.heading||e.text||Object.keys(e.attributes??{}).length)),l=i=>{if(!e||!n)return!0;let f=P(i);return f.tag===e.tag&&(!e.heading||f.heading===e.heading)&&(!e.text||f.text===e.text)&&Object.entries(e.attributes??{}).every(([h,d])=>i.getAttribute(h)===d)};for(let i of t){if(i.includes(" >>> ")||i.startsWith("@frame(")){try{let h=p(i,r),d=O(i),C=Object.entries(e?.attributes??{}).filter(([x])=>y(x)),T=d&&h&&(d.rest.startsWith("[data-pm=")||C.length>0&&h.tagName.toLowerCase()===e?.tag&&C.every(([x,U])=>h.getAttribute(x)===U));if(h&&(T||l(h)))return{status:"matched",element:h}}catch{}continue}let f=o(i);if(f.length===1&&(/^\[data-pm=/.test(i)||!n))return{status:"matched",element:f[0]}}if(!n||t.some(i=>i.includes(" >>> ")||i.startsWith("@frame("))||!/^[a-z][a-z0-9-]*$/.test(e.tag))return{status:"missing"};let a=o(e.tag);if(a.length>500)return{status:"ambiguous"};let s=Object.entries(e.attributes??{}).filter(([i])=>y(i));if(s.length){let i=a.filter(f=>s.every(([h,d])=>f.getAttribute(h)===d));return i.length===1?{status:"matched",element:i[0]}:{status:i.length?"ambiguous":"missing"}}let c=a.filter(l);return c.length===1?{status:"matched",element:c[0]}:{status:c.length?"ambiguous":"missing"}}function X(t,e,r=document){let u={};if(e)for(let[a,s]of Object.entries({...e.dataAttributes,...e.id?{id:e.id}:{}}))y(a)&&F(a,s)&&(u[a]=s);let o=e?.targetFingerprint?.tag??e?.tagName?.toLowerCase(),n=e&&o?{...e.targetFingerprint,tag:o,attributes:{...u,...e.targetFingerprint?.attributes}}:e?.targetFingerprint,l=L([t,e?.selector].filter(a=>!!a),n,r);return l.status==="matched"?l.element:null}export{m as a,w as b,v as c,V as d,M as e,k as f,z as g,A as h,B as i,I as j,S as k,p as l,R as m,_ as n,$ as o,H as p,q,K as r,y as s,P as t,L as u,X as v};
@@ -1 +0,0 @@
1
- import{a as p}from"./chunk-NOHXTT24.mjs";import{request as c}from"http";function u(){let e=process.env.POPMELT_BRIDGE_URL;if(!e)return null;try{let t=new URL(e);return{port:t.port?Number.parseInt(t.port,10):null,projectId:process.env.POPMELT_PROJECT_ID||null,leaseEligible:!1}}catch{return null}}async function h(e,t,i){let r=u();if(e?.bridge===!1||r)return r??{port:null,projectId:null,leaseEligible:!1};try{let{startPopmelt:o}=await import("./server.mjs"),n=t.config?.server?.host,l=n===!0?"0.0.0.0":n||"localhost",s=t.config?.server?.port??i,d=`http://${l==="0.0.0.0"?"localhost":l}:${s}`,a=await o({port:e?.port,experimentalEventTransport:e?.experimentalEventTransport,projectRoot:e?.projectRoot,devOrigin:d,force:!0,detached:!0,manageLease:!1});return console.log(`[popmelt] bridge ready at http://localhost:${a.port}`),{port:a.port,projectId:a.projectId,leaseEligible:!0}}catch(o){let n=o instanceof Error?o.message:String(o);return console.warn("[popmelt] bridge failed to start:",n),{port:null,projectId:null,leaseEligible:!1}}}async function v(e,t,i=fetch){if(!e.leaseEligible||e.port===null)return null;let r=await p({port:e.port,projectId:e.projectId},i);if(!r)return null;let o=()=>{n()},n=async()=>{process.removeListener("beforeExit",o),await r.release()};return process.once("beforeExit",o),t.httpServer?.once("close",()=>{n()}),{id:r.id,release:n}}function g(e,t,i){if(i.port===null)return null;let r=new URL(t,"http://popmelt.local");if(r.pathname!==`${e}/status`)return null;let o=new URL("/status",`http://localhost:${i.port}`);return r.searchParams.forEach((n,l)=>o.searchParams.append(l,n)),i.projectId&&o.searchParams.set("projectId",i.projectId),o}function b(e,t){return(i,r,o)=>{let n=g(e,i.url||"",t());if(!n)return o();let l=c(n,{method:i.method,headers:{...i.headers,host:n.host}},s=>{r.writeHead(s.statusCode||502,s.headers),s.pipe(r)});l.on("error",()=>{r.writeHead(502,{"Content-Type":"text/plain"}),r.end(`Popmelt bridge not running on port ${t().port}`)}),i.pipe(l)}}function P(e){let t=e.port===null?null:`http://localhost:${e.port}`;return`window.__POPMELT_BRIDGE_URL__=${JSON.stringify(t)};window.__POPMELT_PROJECT_ID__=${JSON.stringify(e.projectId)};`}export{h as a,v as b,b as c,P as d};