@popmelt.com/core 0.27.1 → 0.28.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 (55) hide show
  1. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  2. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  3. package/dist/ParticipantRuntime-JUOBT3CY.mjs +139 -0
  4. package/dist/PopmeltTasteConnectedPane-JO4QR6ZT.mjs +221 -0
  5. package/dist/PreviewRuntime-JAZLAGQE.mjs +2 -0
  6. package/dist/bridge-entry.mjs +2 -229
  7. package/dist/browser-runtime-6KNOQXAJ.mjs +2 -0
  8. package/dist/browser.mjs +1 -1
  9. package/dist/chunk-35UEAIRA.mjs +289 -0
  10. package/dist/chunk-3LBOX7HQ.mjs +3 -0
  11. package/dist/chunk-3NTTM74X.mjs +1 -0
  12. package/dist/chunk-3THBMCJW.mjs +369 -0
  13. package/dist/chunk-A2UXK7AS.mjs +77 -0
  14. package/dist/chunk-GL4I4MI6.mjs +3 -0
  15. package/dist/chunk-HGW2U6PD.mjs +2 -0
  16. package/dist/chunk-JQHZFDY5.mjs +2 -0
  17. package/dist/chunk-LVEMYZOA.mjs +2 -0
  18. package/dist/chunk-MP7S5ALD.mjs +2 -0
  19. package/dist/chunk-O4HZP3RP.mjs +2 -0
  20. package/dist/chunk-QUNV5PNI.mjs +2 -0
  21. package/dist/chunk-QXVMGZFP.mjs +1 -0
  22. package/dist/chunk-SWTSMLHA.mjs +2 -0
  23. package/dist/{chunk-CLDWTCKX.mjs → chunk-VRFM3TLR.mjs} +1 -1
  24. package/dist/chunk-W4VRK56P.mjs +347 -0
  25. package/dist/chunk-XOGBFVWI.mjs +2 -0
  26. package/dist/chunk-XTOCFTVW.mjs +2 -0
  27. package/dist/cli.mjs +169 -106
  28. package/dist/focus-inspection-2FPCQIN2.mjs +2 -0
  29. package/dist/index-CHp2bgs1.d.mts +565 -0
  30. package/dist/index.mjs +1 -1
  31. package/dist/memory-legacy.d.mts +1 -489
  32. package/dist/memory-legacy.mjs +1 -1
  33. package/dist/memory-store.d.mts +2 -660
  34. package/dist/memory-store.mjs +1 -3
  35. package/dist/plugin-astro.mjs +1 -1
  36. package/dist/plugin-nuxt.mjs +1 -1
  37. package/dist/plugin-vite.mjs +1 -1
  38. package/dist/server.d.mts +3 -291
  39. package/dist/server.mjs +7 -234
  40. package/dist/taste-proposal-session-XU4N7RUV.mjs +2 -0
  41. package/dist/types-Bur49CLH.d.mts +349 -0
  42. package/dist/workspace-snapshot-EJQHHDQ4.mjs +2 -0
  43. package/package.json +1 -1
  44. package/dist/ParticipantRuntime-TWGYNKIS.mjs +0 -139
  45. package/dist/PopmeltTasteConnectedPane-WDF556E2.mjs +0 -81
  46. package/dist/PreviewRuntime-KGLZJGUN.mjs +0 -2
  47. package/dist/browser-runtime-PFJI3VEQ.mjs +0 -2
  48. package/dist/chunk-3PVLCKSV.mjs +0 -370
  49. package/dist/chunk-7MGWRICI.mjs +0 -77
  50. package/dist/chunk-7YCLSSQA.mjs +0 -2
  51. package/dist/chunk-D7HY2EDH.mjs +0 -2
  52. package/dist/chunk-TSY2K45H.mjs +0 -2
  53. package/dist/chunk-YC7B37F6.mjs +0 -1
  54. package/dist/chunk-YMCTJKYN.mjs +0 -345
  55. package/dist/server-J5NV3BMT.mjs +0 -241
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ import{l as N,d as W}from"./chunk-HGW2U6PD.mjs";import{destroyContext as F,domToCanvas as z,createContext as J}from"modern-screenshot";function A(t,e,n){if(t===null||typeof t=="string"||typeof t=="boolean")return;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Comment metadata at ${e} must be finite.`);return}if(typeof t!="object")throw new TypeError(`Comment metadata at ${e} must be JSON-serializable.`);if(n.has(t))throw new TypeError(`Comment metadata at ${e} contains a cycle.`);let o=Object.getPrototypeOf(t);if(!Array.isArray(t)&&o!==Object.prototype&&o!==null)throw new TypeError(`Comment metadata at ${e} must use plain objects and arrays.`);if(n.add(t),Array.isArray(t))t.forEach((l,r)=>A(l,`${e}[${r}]`,n));else for(let[l,r]of Object.entries(t))A(r,`${e}.${l}`,n);n.delete(t)}function X(t){if(t===void 0)return;if(t===null||Array.isArray(t)||typeof t!="object")throw new TypeError("Comment metadata must be a JSON object.");A(t,"meta",new Set);let e=JSON.stringify(t);if(new TextEncoder().encode(e).byteLength>65536)throw new RangeError("Comment metadata exceeds the 65536 byte limit.");return JSON.parse(e)}var S="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",q=1500,G=5e3,Q=24e6,K=16e3,V=4,Z=["position","inset","top","right","bottom","left","z-index","display","visibility","opacity","overflow","overflow-x","overflow-y","box-sizing","box-decoration-break","float","clear","width","min-width","max-width","height","min-height","max-height","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","border","border-width","border-style","border-color","border-top","border-right","border-bottom","border-left","border-radius","outline","outline-offset","box-shadow","background","background-color","background-image","background-size","background-position","background-repeat","background-clip","background-origin","color","font","font-family","font-size","font-style","font-weight","font-stretch","font-variant","line-height","letter-spacing","text-align","text-decoration","text-indent","text-overflow","text-shadow","text-transform","white-space","word-break","overflow-wrap","vertical-align","direction","writing-mode","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","align-content","align-items","align-self","justify-content","justify-items","justify-self","gap","row-gap","column-gap","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-row","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","order","columns","column-count","column-fill","column-rule","column-span","column-width","list-style","list-style-image","list-style-position","list-style-type","object-fit","object-position","aspect-ratio","transform","transform-box","transform-origin","transform-style","perspective","perspective-origin","backface-visibility","clip","clip-path","filter","backdrop-filter","mix-blend-mode","isolation","mask","mask-image","mask-position","mask-repeat","mask-size","content","quotes","counter-increment","counter-reset","appearance","accent-color","caret-color","cursor","pointer-events","fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity"];async function _(t,e){try{let n=await t();if(n)return n}catch{}return e()}var C=new Map,$=new WeakMap,tt=1;function p(){return typeof performance<"u"?performance.now():Date.now()}function E(t){if(t?.debug!==void 0)return t.debug;if(typeof window>"u")return!1;try{return window.localStorage.getItem("popmelt:screenshot-debug")==="true"}catch{return!1}}function et(t){let e=0,n=0;for(let o of t.querySelectorAll("img[src]"))P(o.currentSrc||o.src)&&(e++,(!o.complete||o.naturalWidth===0)&&n++);return{remoteImages:e,unresolvedRemoteImages:n}}function nt(t){return new Promise((e,n)=>{let o=new FileReader;o.onload=()=>e(String(o.result)),o.onerror=()=>n(o.error??new Error("Asset could not be read")),o.readAsDataURL(t)})}function ot(t,e){let n=null;return async o=>{if(!P(o))return!1;n??(n=Date.now()+t);let l=n-Date.now();if(l<=0)return e(),S;let r=new AbortController,a=setTimeout(()=>r.abort(),l);try{let s=await fetch(o,{cache:"force-cache",mode:"cors",signal:r.signal});if(!s.ok)throw new Error(`Asset returned ${s.status}`);return await nt(await s.blob())}catch{return e(),S}finally{clearTimeout(a)}}}function rt(t,e,n){let o=$.get(t);o||(o=tt++,$.set(t,o));let l=e.filter(r=>(r.status??"pending")==="pending").map(r=>{let a=r.points[0],s=r.points[r.points.length-1];return`${r.id}:${r.points.length}:${a?.x??""}:${a?.y??""}:${s?.x??""}:${s?.y??""}`}).join("|");return[o,window.location.href,window.innerWidth,window.innerHeight,n?.dpr??window.devicePixelRatio??1,n?.viewportOnly?window.scrollY:"",l].join("::")}function at(t,e,n){let o=Math.min(e,n);return{top:Math.max(0,Math.min(t,n-o)),height:o,annotations:[]}}function P(t){if(typeof window>"u")return!1;try{let e=new URL(t,window.location.href);return e.protocol!=="http:"&&e.protocol!=="https:"?!1:e.origin!==window.location.origin}catch{return!1}}function it(t){let e=document.createElement("canvas").getContext("2d");return e?(e.fillStyle=t,e.fillStyle):"#888888"}function j(t,e=[],n,o,l=[],r=[],a){let s=new Map,c=[];for(let i of t)if(i.groupId){let m=s.get(i.groupId)||[];m.push(i),s.set(i.groupId,m)}else c.push(i);let u=[];for(let[i,m]of s){let h=m.find(d=>d.type!=="text"),f=m.find(d=>d.type==="text");if(h){let d=h.linkedSelector||f?.linkedSelector,g=f?.imageCount||h.imageCount,w=f?.attachments||h.attachments,y=f?.interactionEpisode||h.interactionEpisode,v=h.pathname||f?.pathname;u.push({id:h.id,type:h.type,instruction:f?.text,...d?{linkedSelector:d}:{},...h.target||f?.target?{target:h.target??f?.target}:{},...v?{pathname:v}:{},elements:h.elements||[],...g?{imageCount:g}:{},...w?.length?{attachments:w}:{},...y?{interactionEpisode:y}:{}})}}for(let i of c)u.push({id:i.id,type:i.type,instruction:i.type==="text"?i.text:void 0,...i.linkedSelector?{linkedSelector:i.linkedSelector}:{},...i.target?{target:i.target}:{},...i.pathname?{pathname:i.pathname}:{},elements:i.elements||[],...i.imageCount?{imageCount:i.imageCount}:{},...i.attachments?.length?{attachments:i.attachments}:{},...i.interactionEpisode?{interactionEpisode:i.interactionEpisode}:{}});return{timestamp:new Date().toISOString(),url:window.location.href,viewport:{width:window.innerWidth,height:window.innerHeight},scrollPosition:{x:window.scrollX,y:window.scrollY},annotations:u,styleModifications:e,...l.length>0?{textModifications:l}:{},...r.length>0?{domModifications:r}:{},...n?{inspectedElement:n}:{},...o&&o.length>0?{spacingTokenChanges:o}:{},...a?{meta:a}:{}}}function lt(t){if(!t.points||t.points.length===0)return null;let e=t.points.map(o=>o.x),n=t.points.map(o=>o.y);return{minX:Math.min(...e),minY:Math.min(...n),maxX:Math.max(...e),maxY:Math.max(...n)}}function st(t,e){if(t.length===0)return[];let n=t.map(i=>({annotation:i,bounds:lt(i)})).filter(i=>i.bounds!==null);if(n.length===0)return[];n.sort((i,m)=>i.bounds.minY-m.bounds.minY);let o=Math.min(...n.map(i=>i.bounds.minY)),l=Math.max(...n.map(i=>i.bounds.maxY));if(l-o<=e){let i=(o+l)/2,m=Math.max(0,i-e/2);return[{top:m,bottom:m+e,annotations:t}]}let r=[],a=50,s=Math.max(0,o-a),c=[],u=s;for(let{annotation:i,bounds:m}of n){let h=m.maxY+a;if(h-s<=e)c.push(i),u=Math.max(u,h);else{if(c.length>0){let f=(s+u)/2,d=Math.max(0,f-e/2);r.push({top:d,bottom:d+e,annotations:c})}s=Math.max(0,m.minY-a),c=[i],u=m.maxY+a}}if(c.length>0){let i=(s+u)/2,m=Math.max(0,i-e/2);r.push({top:m,bottom:m+e,annotations:c})}return r}function ct(t){let e=new Map;for(let n of t)if(n.linkedSelector)try{let o=N(n.linkedSelector);if(o){let l=W(o);e.set(n.id,{x:l.left+window.scrollX,y:l.top+window.scrollY,width:l.width,height:l.height})}}catch{}return e}function T(t,e,n,o,l){if(t.save(),t.scale(o,o),l)for(let r of e){let a=l.get(r.id);if(!a)continue;let s=a.y-n;t.fillStyle=r.color,t.globalAlpha=.05,t.fillRect(a.x,s,a.width,a.height),t.globalAlpha=1,t.strokeStyle=r.color,t.lineWidth=1,t.setLineDash([2,4]),t.strokeRect(a.x,s,a.width,a.height),t.setLineDash([])}for(let r of e){let a=r.points.map(s=>({x:s.x,y:s.y-n}));switch(t.strokeStyle=r.color,t.fillStyle=r.color,t.lineWidth=r.strokeWidth,t.lineCap="round",t.lineJoin="round",r.type){case"freehand":if(a.length<2)break;t.beginPath(),t.moveTo(a[0].x,a[0].y);for(let s=1;s<a.length;s++)t.lineTo(a[s].x,a[s].y);t.stroke();break;case"line":if(a.length<2)break;t.beginPath(),t.moveTo(a[0].x,a[0].y),t.lineTo(a[a.length-1].x,a[a.length-1].y),t.stroke();break;case"rectangle":{if(a.length<2)break;let s=a[0],c=a[a.length-1],u=Math.min(s.x,c.x),i=Math.min(s.y,c.y),m=Math.abs(c.x-s.x),h=Math.abs(c.y-s.y);t.strokeRect(u,i,m,h);break}case"circle":{if(a.length<2)break;let s=a[0],c=a[a.length-1],u=(s.x+c.x)/2,i=(s.y+c.y)/2,m=Math.abs(c.x-s.x)/2,h=Math.abs(c.y-s.y)/2;t.beginPath(),t.ellipse(u,i,m,h,0,0,Math.PI*2),t.stroke();break}case"text":{if(!r.text||a.length<1)break;let s=a[0],c=r.fontSize||16;t.font=`${c}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=r.color;let u=(r.imageCount&&r.imageCount>0?`[${r.imageCount} image${r.imageCount>1?"s":""}] ${r.text}`:r.text).split(`
3
+ `),i=c*1.2,m=4,h=0;for(let f of u)h=Math.max(h,t.measureText(f).width);t.fillRect(s.x-m,s.y-m,h+m*2,u.length*i+m*2),t.fillStyle="#ffffff",u.forEach((f,d)=>{t.fillText(f,s.x,s.y+c+d*i)});break}}}t.restore()}async function dt(t,e,n=[],o){let l=rt(t,n,o),r=C.get(l);if(r)return E(o)&&console.debug("[Screenshot] Reusing in-flight capture",l),r;let a=Mt(t,n,o).finally(()=>C.delete(l));return C.set(l,a),a}function mt(){let t=getComputedStyle(document.documentElement).backgroundColor;return t&&t!=="rgba(0, 0, 0, 0)"&&t!=="transparent"?t:"#ffffff"}function ht(t){return t instanceof HTMLElement?t.id==="devtools-canvas"||t.id==="devtools-toolbar"||t.id==="devtools-scrim"?!1:t.dataset.devtools===void 0:!0}function ut(t,e,n,o){return t.length===0?[{top:Math.max(0,Math.min(o,Math.max(0,n-e))),height:Math.min(e,n||e),annotations:[]}]:t.map(l=>{let r=Math.min(e,n||e);return{top:Math.max(0,Math.min(l.top,Math.max(0,n-r))),height:r,annotations:l.annotations}})}function ft(t,e,n){if(t.length===0)return null;let o=Math.min(...t.map(a=>a.top)),l=Math.max(...t.map(a=>a.top+a.height))-o,r=e*l*n*n;return l>K||r>Q?null:{top:o,height:l}}async function gt(t,e){let n=[];for(let o of t){let l=Object.getOwnPropertyDescriptor(o.element,"toDataURL");try{Object.defineProperty(o.element,"toDataURL",{configurable:!0,value:()=>o.dataUrl}),n.push(()=>{l?Object.defineProperty(o.element,"toDataURL",l):Reflect.deleteProperty(o.element,"toDataURL")})}catch{}}try{return await e()}finally{for(let o of n.reverse())o()}}async function pt(t,e,n,o,l,r,a,s){let c=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)>window.innerHeight*V||t.querySelectorAll("*").length>2500,u=s?await s():[];return gt(u,()=>J(t,{autoDestruct:!1,filter:ht,features:{restoreScrollPosition:!0},onCloneNode:i=>{t===document.body&&(i.style.margin=getComputedStyle(t).margin)},onCloneEachNode:i=>{if(i.nodeType===1&&i.localName==="html"&&i.ownerDocument!==document){let m=i.style;m.overflow="hidden",m.display="inline-block",m.clipPath=`inset(0 round ${m.borderRadius||"0px"})`}},scale:o,backgroundColor:mt(),width:n,height:e.height,style:{transform:`translate(${-window.scrollX}px, ${-e.top}px)`,transformOrigin:"top left"},timeout:l,debug:r,includeStyleProperties:c?[...Z]:null,fetchFn:ot(l,()=>{a.remoteAssetFallbacks++}),fetch:{requestInit:{cache:"force-cache"},placeholderImage:S}}))}async function wt(t,e,n){return t.width=n,t.height=e.height,t.style={transform:`translate(${-window.scrollX}px, ${-e.top}px)`,transformOrigin:"top left"},z(t)}async function yt(t,e,n){let o=document.createElement("canvas");o.width=e,o.height=n;let l=o.getContext("2d");if(!l)throw new Error("Canvas context unavailable");if(typeof createImageBitmap=="function"){let s=await createImageBitmap(t);return l.drawImage(s,0,0,e,n),s.close(),o}let r=new Image,a=URL.createObjectURL(t);try{return await new Promise((s,c)=>{r.onload=()=>s(),r.onerror=()=>c(new Error("Native screenshot could not be decoded")),r.src=a}),l.drawImage(r,0,0,e,n),o}finally{URL.revokeObjectURL(a)}}async function L(t,e,n,o,l,r){if(o?.nativeCapture){let u=p();try{let i=await o.nativeCapture({url:window.location.href,clip:{x:window.scrollX,y:t.top,width:e,height:t.height},scale:n});if(r.nativeMs+=p()-u,i)return r.mode=r.renderMs>0||r.contextMs>0?"mixed":"native",yt(i,Math.round(e*n),Math.round(t.height*n))}catch(i){r.nativeMs+=p()-u,E(o)&&console.debug("[Screenshot] Native capture unavailable; using DOM fallback",i)}}let a=await l(),s=p(),c=await wt(a,t,e);return r.renderMs+=p()-s,r.mode=r.mode==="native"?"mixed":"dom",c}function U(t,e,n,o,l,r){let a=document.createElement("canvas");a.width=Math.round(o*l),a.height=Math.round(n.height*l);let s=a.getContext("2d");if(!s)throw new Error("Canvas context unavailable");let c=Math.round((n.top-e)*l);return s.drawImage(t,0,c,a.width,a.height,0,0,a.width,a.height),T(s,n.annotations,n.top,l,r),a}function bt(t){if(t.length===1)return t[0];let e=document.createElement("canvas");e.width=t[0]?.width??0,e.height=t.reduce((l,r)=>l+r.height,0);let n=e.getContext("2d");if(!n)throw new Error("Canvas context unavailable");let o=0;for(let l of t)n.drawImage(l,0,o),o+=l.height;return e}function xt(t,e="image/webp",n=.8){return new Promise(o=>t.toBlob(o,e,n))}async function Mt(t,e,n){let o=p(),l=n?.dpr??(window.devicePixelRatio||1),r=window.innerWidth,a=window.innerHeight,s=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight),c=Math.max(250,n?.mediaTimeoutMs??q),u=E(n),i=e.filter(b=>(b.status??"pending")==="pending"),m=ct(i),h=n?.viewportOnly?[at(window.scrollY,a,s)]:ut(st(i,a),a,s,window.scrollY),f=et(t),d={startedAt:o,mode:"dom",mediaTimeoutMs:c,ranges:h.length,...f,remoteAssetFallbacks:0,nativeMs:0,contextMs:0,renderMs:0,compositeMs:0,encodeMs:0};console.log("[Screenshot] Starting capture with",i.length,"active annotations (filtered",e.length-i.length,"captured);",`${h.length} range(s), ${f.remoteImages} remote image(s), ${f.unresolvedRemoteImages} unresolved`);let g=null,w=null,y=ft(h,r,l),v=y??h[0],R=async()=>{if(!g){let b=p();g=pt(t,v,r,l,c,u,d,n?.captureSurfaces).then(x=>(w=x,d.contextMs+=p()-b,x))}return g};try{let b=p(),x;if(y){let M=await L(y,r,l,n,R,d);x=h.map(k=>U(M,y.top,k,r,l,m))}else{x=[];for(let M of h){let k=await L(M,r,l,n,R,d);x.push(U(k,M.top,M,r,l,m))}}let Y=bt(x);d.compositeMs+=p()-b-d.renderMs-d.nativeMs-d.contextMs;let B=p(),I=await xt(Y);d.encodeMs=p()-B;let O=p()-d.startedAt,H={mode:d.mode,totalMs:Math.round(O),mediaTimeoutMs:d.mediaTimeoutMs,ranges:d.ranges,remoteImages:d.remoteImages,unresolvedRemoteImages:d.unresolvedRemoteImages,remoteAssetFallbacks:d.remoteAssetFallbacks,nativeMs:Math.round(d.nativeMs),contextMs:Math.round(d.contextMs),renderMs:Math.round(d.renderMs),compositeMs:Math.max(0,Math.round(d.compositeMs)),encodeMs:Math.round(d.encodeMs),overBudget:O>G};return console.log("[Screenshot] Capture complete",JSON.stringify(H)),I?[I]:[]}catch(b){return console.error("[Screenshot] Capture failed:",b),[]}finally{w&&F(w)}}async function D(t){if(t.length===0)return null;if(t.length===1)return t[0];let e=await Promise.all(t.map(s=>new Promise((c,u)=>{let i=new Image;i.onload=()=>c(i),i.onerror=u,i.src=URL.createObjectURL(s)}))),n=e[0].width,o=e.reduce((s,c)=>s+c.height,0),l=document.createElement("canvas");l.width=n,l.height=o;let r=l.getContext("2d");if(!r)return null;let a=0;for(let s of e)r.drawImage(s,0,a),a+=s.height,URL.revokeObjectURL(s.src);return new Promise(s=>{l.toBlob(c=>s(c),"image/webp",.8)})}async function vt(t,e,n,o,l){try{let r=Array.isArray(t)?t:[t];if(r.length===0)return!1;let a=await D(r);if(!a)return!1;let s=a;if(a.type!=="image/png"){let f=new Image,d=URL.createObjectURL(a);await new Promise(w=>{f.onload=()=>w(),f.src=d}),URL.revokeObjectURL(d);let g=document.createElement("canvas");g.width=f.naturalWidth,g.height=f.naturalHeight,g.getContext("2d").drawImage(f,0,0),s=await new Promise(w=>g.toBlob(y=>w(y),"image/png"))}let c={"image/png":s},u=e&&e.length>0,i=n&&n.length>0,m=o&&o.length>0,h=l&&l.length>0;if(u||i||m||h){let f=e?e.filter(d=>(d.status??"pending")==="pending"):[];if(f.length>0||i||m||h){let d=j(f,n||[],void 0,void 0,o||[],l||[]),g=new Blob([JSON.stringify(d,null,2)],{type:"text/plain"});c["text/plain"]=g}}return await navigator.clipboard.write([new ClipboardItem(c)]),!0}catch(r){return console.warn("Clipboard write failed:",r),!1}}export{X as a,_ as b,it as c,j as d,T as e,dt as f,D as g,vt as h};
@@ -0,0 +1 @@
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,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};