@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
@@ -0,0 +1 @@
1
+ "use client";function t(t){return!(!t||"http://www.w3.org/1999/xhtml"!==t.namespaceURI&&"http://www.w3.org/2000/svg"!==t.namespaceURI)}export{t as a};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{C as t,E as e,j as a,p as r,q as i}from"./chunk-YLKEDOII.mjs";import{readFile as o,realpath as n,mkdir as s,writeFile as c}from"fs/promises";import{createHash as p}from"crypto";import{join as d,resolve as l}from"path";function u(t,e){let a=p("sha256").update(e).digest("hex");return d(t,".popmelt","participant-agents",a+".json")}async function f(t,a){if(a.storeId!==t.storeId)return{ok:!1,body:{status:"writable_store_required"}};if("string"!=typeof a.threadId||!a.threadId||"string"!=typeof a.text||!a.text.trim()||a.text.length>8e3)return{ok:!1,body:{status:"invalid_note"}};let r;try{r=await h(t,t.sessionId,!0)}catch(t){if("ENOENT"!==t.code)throw t;return{ok:!1,body:{status:"participant_invitation_required"}}}if(!r)return{ok:!1,body:{status:"enrolled_bridge_required"}};let i=await e(r.endpoint,"/participants/thread-note",{...r.request,method:"POST",signal:AbortSignal.timeout(3e4),body:JSON.stringify({storeId:t.storeId,threadId:a.threadId,reply:a.text,sessionId:t.sessionId,requestId:a.requestId})});return{ok:i.response.ok,body:i.body}}async function h(t,r,s=!1){let c=await o(d(t.projectRoot,".popmelt","participant-bridge.json"),"utf8").then(JSON.parse).catch(e=>{if("ENOENT"!==e.code||!t.bridgePort)throw e;return{projectId:t.projectId,port:t.bridgePort}});if(c.projectId!==t.projectId||!Number.isInteger(c.port)||c.port<1||c.port>65535)return null;let p={redirect:"error",signal:AbortSignal.timeout(3e3)},l=await e(c,"/status",p);if(!l.response.ok||l.body?.projectId!==t.projectId)return null;let f,h=u(t.projectRoot,r);try{f=JSON.parse(await o(h,"utf8"))}catch(l){if("ENOENT"!==l.code||!s)throw l;let u=await n(t.projectRoot),m=a(r);if(i(u)!==t.projectId||!m)return null;let g=JSON.parse(await o(d(u,".popmelt","participant-host.json"),"utf8"));if(!(await e(c,"/participants/agent-join",{...p,method:"POST",headers:{"X-Popmelt-Participant-Id":g.participantId,"X-Popmelt-Participant-Token":g.token},body:JSON.stringify({sessionId:r,name:m,headless:!0})})).response.ok)return null;f=JSON.parse(await o(h,"utf8"))}return{endpoint:c,request:{...p,headers:{"X-Popmelt-Participant-Id":f.participantId,"X-Popmelt-Participant-Token":f.token}}}}async function m(t,a,r){let i=[t,...t.mountedStores].find(t=>t.storeId===a.storeId);if(!i||r&&i!==t)return{ok:!1,body:{status:"store_unavailable"}};if(r&&("string"!=typeof a.threadId||!a.threadId))return{ok:!1,body:{status:"thread_required"}};let o=await h(i,t.sessionId,r).catch(t=>{if("ENOENT"===t.code)return null;throw t});if(!o)return{ok:!1,body:{status:"enrolled_bridge_required",message:"Join this project as a Popmelt peer and check that its bridge is running."}};let{endpoint:n,request:s}=o,c=await e(n,r?t.sessionId.startsWith("claude:")?"/participants/link-claude-chat":"/participants/link-codex-chat":"/participants/check-claude-notes",{...s,method:"POST",body:JSON.stringify({sessionId:t.sessionId,...r?{threadId:a.threadId}:{}})});return{ok:c.response.ok,body:c.body}}async function g(a,l,f={}){if(t())return{status:"already_managed_by_bridge"};if((await e(a,"/status",{redirect:"error",signal:AbortSignal.timeout(3e3)})).body?.participantSessions)return async function(t,a,l){if(!l.projectRoot)throw new Error("Participant connections require the active project root");let f=await n(l.projectRoot);if(i(f)!==t.projectId)throw new Error("Participant project does not match");let h,m,g=d(f,".popmelt"),w=p("sha256").update(a).digest("hex"),I=async(a,r,i)=>{let o=await e(t,"/participants/"+a,{method:"POST",redirect:"error",headers:{"X-Popmelt-Participant-Id":r.participantId,"X-Popmelt-Participant-Token":r.token},body:JSON.stringify(i),signal:AbortSignal.timeout(9e4)}),n=o.body;if(!o.response.ok||n.error)throw new Error(n.error??"Participant connection unavailable");return n};try{h=JSON.parse(await o(u(f,a),"utf8"))}catch(t){if("ENOENT"!==t.code)throw t;if(!l.name)return{status:"participant_invitation_required"};let e=JSON.parse(await o(d(g,"participant-host.json"),"utf8")),r=await I("agent-join",e,{sessionId:a,name:l.name});h=r.credential,m=r.participant}if(!l.action){let t=await I("agent-connect",h,{});return{status:"participant_connected",participantId:h.participantId,participant:t.participant??m}}let y=await I("agent-act",h,{action:r(l.action)}),b=y.evidence;if(b?.frame?.image){let t=b.frame.image;if(!/^data:image\/jpeg;base64,[A-Za-z0-9+/=]+$/.test(t)||t.length>7e5)throw new Error("Invalid participant preview");let e=d(g,"artifacts","participant-previews");await s(e,{recursive:!0,mode:448});let a=d(e,w+".jpg");return await c(a,Buffer.from(t.slice(t.indexOf(",")+1),"base64"),{mode:384}),{status:"participant_connected",participant:y.participant,evidence:{...b,frame:{imagePath:a,targets:b.frame.targets}}}}return{status:"participant_connected",participant:y.participant,evidence:y.evidence}}(a,l,f);let h=async(t,r)=>{let i=await e(a,`/peers/${t}`,{method:"POST",body:JSON.stringify(r),signal:AbortSignal.timeout(5e4)}),o=i.body;if(!i.response.ok||o?.error)throw new Error(o?.error??"Peer connection unavailable");return o},m=await h("join",{sessionId:l,name:f.name}),g=f.action?await h("act",{token:m.token,clientId:f.clientId,action:r(f.action)}):m,w=g.peer;return{...g.status?{status:g.status}:{},...w?{peer:{...w,state:w.state?{annotations:w.state.annotations,styleModifications:w.state.styleModifications,textModifications:w.state.textModifications,undoDepth:w.state.undoStack.length,redoDepth:w.state.redoStack.length}:null}}:{},...g.evidence?{evidence:g.evidence}:{},clients:m.clients}}async function w(t){let a=e=>{let a=t.indexOf(e);return a>=0?t[a+1]:void 0},r=a("--session");if(!r)throw new Error("Usage: popmelt peer --session <stable-agent-session> [--project-root <active-project>] [--name <your-name>] [--client <canvas-id>] [--action <JSON>]");let s=await n(l(a("--project-root")??process.cwd())),c=JSON.parse(await o(d(s,".popmelt","bridge.lock"),"utf8")),p=i(s),u=await e({port:c.port,projectId:p},"/status",{signal:AbortSignal.timeout(3e3)});if(!u.response.ok||u.body.projectRoot!==s&&(!u.body.participantSessions||u.body.projectId!==p))throw new Error("No matching running project bridge");let f=a("--action");console.log(JSON.stringify(await g({port:c.port,projectId:p},r,{name:a("--name"),projectRoot:s,clientId:a("--client"),action:f?JSON.parse(f):void 0}),null,2))}export{u as a,f as b,h as c,m as d,g as e,w as f};
@@ -0,0 +1 @@
1
+ "use client";function e(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 t(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 n(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 a(e){let t=e.instruction?.trim();return t?e.attachments?.some(e=>e.name?.trim()===t)?null:t:null}function o(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 i(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 r(e){let t=e.annotations.map(e=>{let t=e.interactionEpisode?.steps.length??0;return{kind:"annotation",annotationId:e.id,pathname:e.pathname,text:a(e)??i(e),...t>0?{interactionEpisodeStepCount:t}:{}}}),n=new Map,r=e=>{let a=`${e.pathname??""}:${e.durableSelector??e.selector}`,i=n.get(a);if(i)return i.changes.push(e.text),void(void 0!==e.annotationNumber&&(void 0===i.annotationNumber||e.annotationNumber<i.annotationNumber)&&(i.annotationNumber=e.annotationNumber));let r={kind:"changes",elementKey:a,elementLabel:o(e.element,e.selector),...void 0!==e.annotationNumber?{annotationNumber:e.annotationNumber}:{},pathname:e.pathname,changes:[e.text]};n.set(a,r),t.push(r)};for(let t of e.styleModifications??[])for(let e of t.changes)r({...t,text:`${e.property}: ${e.original||"unset"} → ${e.modified||"unset"}${e.token?` (${e.token})`:""}`});for(let t of e.textModifications??[])r({...t,text:`Text: ${t.original||"empty"} → ${t.modified||"empty"}`});for(let t of e.domModifications??[])r({...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 l(e){let t=e.annotations.flatMap(e=>{let t=a(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 s(e,t=96){let n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,Math.max(0,t-3))}...`:n}function m(e,t,n){return n?.activePreview?n.annotationNumber:e??t}function u(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{e as a,t as b,n as c,r as d,l as e,s as f,m as g,u as h};
@@ -0,0 +1 @@
1
+ "use client";function t(t){if(typeof document<"u"&&t===document)return null;try{let e=t.defaultView?.frameElement;return"iframe"===e?.localName?e:null}catch{return null}}function e(t){if("iframe"!==t.localName||t.closest("[data-devtools],[data-popmelt-peer-surface]"))return null;try{let e=t.contentDocument;return e?.documentElement?e:null}catch{return null}}function n(t){let e=t.getBoundingClientRect(),n=t.offsetWidth?e.width/t.offsetWidth:1,r=t.offsetHeight?e.height/t.offsetHeight:1;return{x:e.left+t.clientLeft*n,y:e.top+t.clientTop*r,sx:n,sy:r}}function r(e,r){let{left:l,top:o,width:i,height:u}=e,a=t(r);for(;a;){let e=n(a);l=e.x+l*e.sx,o=e.y+o*e.sy,i*=e.sx,u*=e.sy,a=t(a.ownerDocument)}return new DOMRect(l,o,i,u)}function l(t){return r(t.getBoundingClientRect(),t.ownerDocument)}function o(e,r,l){let o=[],i=t(l);for(;i;)o.unshift(i),i=t(i.ownerDocument);for(let t of o){let l=n(t);e=(e-l.x)/l.sx,r=(r-l.y)/l.sy}return{x:e,y:r}}function i(t){return t.ownerDocument.defaultView??window}function u(t){return!(!t||"http://www.w3.org/1999/xhtml"!==t.namespaceURI)}function a(e,n=document){if(e===n)return!0;let r=t(e);return!(!r?.isConnected||r.contentDocument!==e||!a(r.ownerDocument,n))}function s(e,n){if(!a(n))return new DOMRect(0,0,0,0);let l=e.left,o=e.top,i=e.right,u=e.bottom;for(let e=t(n);e;e=t(e.ownerDocument)){let t=r({left:0,top:0,width:e.clientWidth,height:e.clientHeight},e.contentDocument);l=Math.max(l,t.left),o=Math.max(o,t.top),i=Math.min(i,t.right),u=Math.min(u,t.bottom)}return new DOMRect(l,o,Math.max(0,i-l),Math.max(0,u-o))}var f="@frame(";function c(t,e){return`${f}${encodeURIComponent(JSON.stringify({selector:t,url:e.URL}))}) `}function h(t){if(!t.startsWith(f))return null;let e=t.indexOf(") ");if(e<0)return null;try{let n=JSON.parse(decodeURIComponent(t.slice(7,e)));return"string"!=typeof n.selector||"string"!=typeof n.url?null:{...n,rest:t.slice(e+2)}}catch{return null}}var m=" >>> ";function d(t){return Array.from(t.querySelectorAll("*")).flatMap(t=>t.shadowRoot?[t.shadowRoot]:[])}function g(t=document){let e=[t];for(let t of e)e.push(...d(t));return e}function p(t,n=document){if(t.startsWith(f)){let r=h(t);if(!r)return null;let l=r.selector.startsWith(f)||r.selector.includes(m)?[p(r.selector,n)].filter(t=>!!t):g(n).flatMap(t=>Array.from(t.querySelectorAll(r.selector))),o=1===l.length?l[0]:null,i=o&&e(o);return i&&i.URL===r.url?p(r.rest,i):null}let r=t.split(m);if(r.length>1){let t=n,e=null;for(let n=0;n<r.length;n+=1){if(e=t.querySelector(r[n]),!e)return null;if(n<r.length-1){if(!e.shadowRoot)return null;t=e.shadowRoot}}return e}let l=[n];for(let e of l){let n=e.querySelector(t);if(n)return n;l.push(...d(e))}return null}function y(t){if(t.parentElement)return t.parentElement;let e=t.getRootNode();return"host"in e?e.host:null}function w(t,e){return e.startsWith(f)||e.includes(m)?p(e)===t:t.matches(e)}function b(t,e){let n=t;for(;n;){if(n.matches(e))return n;n=y(n)}return null}function S(t,e){let n=e;for(;n;){if(n===t)return!0;n=y(n)}return!1}var x=new WeakMap;function v(t){let e=t.getAttribute("style");return t.style.setProperty("pointer-events","auto","important"),()=>{null===e?t.removeAttribute("style"):t.setAttribute("style",e)}}function A(t,n,r,l=t=>[t],o){let i=[];for(let l of t.querySelectorAll("iframe")){if(!e(l))continue;let t=l.getBoundingClientRect();n<t.left||n>t.right||r<t.top||r>t.bottom||"none"===l.ownerDocument.defaultView?.getComputedStyle(l).pointerEvents&&i.push(v(l))}try{let e=()=>{let e="function"==typeof t.elementsFromPoint?t.elementsFromPoint(n,r):[],l=t.elementFromPoint?.(n,r)??null;return(l&&!e.includes(l)?[l,...e]:e).filter(e=>9===t.nodeType||e.getRootNode()===t)},i=e(),u=i;if(o){let n=function(t){let e=9===t.nodeType?t:t.ownerDocument,n="* { pointer-events: auto !important; }",r=[];try{let l=e.defaultView?.CSSStyleSheet;if(l?.prototype.replaceSync&&"adoptedStyleSheets"in t){let o=x.get(e);o||(o=new l,o.replaceSync(n),x.set(e,o));let i=[...t.adoptedStyleSheets];t.adoptedStyleSheets=[...i,o],r.push(()=>{t.adoptedStyleSheets=i})}else{let l=e.createElement("style");l.textContent=n,(9===t.nodeType?e.head??e.documentElement:t).appendChild(l),r.push(()=>l.remove())}for(let e of t.querySelectorAll('[style*="pointer-events"]'))"none"!==e.style.getPropertyValue("pointer-events")||"important"!==e.style.getPropertyPriority("pointer-events")||r.push(v(e))}catch(t){throw r.reverse().forEach(t=>t()),t}return()=>r.reverse().forEach(t=>t())}(t);try{u=e()}finally{n()}u=u.filter(t=>i.includes(t)||o(t))}return u.flatMap(l)}finally{i.forEach(t=>t())}}function R(t,n,r=document,l){let i=[],u=new Set,a=9===r.nodeType?r:r.ownerDocument,s=o(t,n,a);for(let o of g(r).reverse())for(let r of A(o,s.x,s.y,r=>{let o=e(r);return o?[...R(t,n,o,l),r]:[r]},l))u.has(r)||(u.add(r),i.push(r));return i}function C(){return m}var D=["id","data-testid","data-test","data-cy","data-popmelt-media-id","aria-label","name","href"],M=t=>t.replace(/\s+/g," ").trim();function O(t){return"id"===t||"data-popmelt-media-id"===t||/^data-(?:testid|test|cy)(?:-[a-z0-9_-]+)?$/.test(t)}function N(t,e){return!(!(e&&e.length<=200)||"id"===t&&/^(radix-|:|_r_)/.test(e))}function W(t){let e={},n=new Set([...D,...t.getAttributeNames().filter(O)]);for(let r of n){let n=t.getAttribute(r);n&&N(r,n)&&(e[r]=n)}let r=M(t.querySelector("h1,h2,h3,h4,h5,h6")?.textContent??""),l=M(Array.from(t.childNodes).filter(t=>3===t.nodeType).map(t=>t.textContent).join(" "));return{tag:t.tagName.toLowerCase(),...Object.keys(e).length?{attributes:e}:{},...r&&r.length<=200?{heading:r}:{},...l&&l.length<=200?{text:l}:{}}}function E(t,e,n=document){let r=g(n),l=t=>{try{return r.flatMap(e=>Array.from(e.querySelectorAll(t)))}catch{return[]}},o=!(!e||!(e.heading||e.text||Object.keys(e.attributes??{}).length)),i=t=>{if(!e||!o)return!0;let n=W(t);return n.tag===e.tag&&(!e.heading||n.heading===e.heading)&&(!e.text||n.text===e.text)&&Object.entries(e.attributes??{}).every(([e,n])=>t.getAttribute(e)===n)};for(let r of t){if(r.includes(" >>> ")||r.startsWith("@frame(")){try{let t=p(r,n),l=h(r),o=Object.entries(e?.attributes??{}).filter(([t])=>O(t)),u=l&&t&&(l.rest.startsWith("[data-pm=")||o.length>0&&t.tagName.toLowerCase()===e?.tag&&o.every(([e,n])=>t.getAttribute(e)===n));if(t&&(u||i(t)))return{status:"matched",element:t}}catch{}continue}let t=l(r);if(1===t.length&&(/^\[data-pm=/.test(r)||!o))return{status:"matched",element:t[0]}}if(!o||t.some(t=>t.includes(" >>> ")||t.startsWith("@frame("))||!/^[a-z][a-z0-9-]*$/.test(e.tag))return{status:"missing"};let u=l(e.tag);if(u.length>500)return{status:"ambiguous"};let a=Object.entries(e.attributes??{}).filter(([t])=>O(t));if(a.length){let t=u.filter(t=>a.every(([e,n])=>t.getAttribute(e)===n));return 1===t.length?{status:"matched",element:t[0]}:{status:t.length?"ambiguous":"missing"}}let s=u.filter(i);return 1===s.length?{status:"matched",element:s[0]}:{status:s.length?"ambiguous":"missing"}}function q(t,e,n=document){let r={};if(e)for(let[t,n]of Object.entries({...e.dataAttributes,...e.id?{id:e.id}:{}}))O(t)&&N(t,n)&&(r[t]=n);let l=e?.targetFingerprint?.tag??e?.tagName?.toLowerCase(),o=e&&l?{...e.targetFingerprint,tag:l,attributes:{...r,...e.targetFingerprint?.attributes}}:e?.targetFingerprint,i=E([t,e?.selector].filter(t=>!!t),o,n);return"matched"===i.status?i.element:null}export{t as a,e as b,r as c,l as d,o as e,i as f,u as g,a as h,s as i,c as j,g as k,p as l,y as m,w as n,b as o,S as p,R as q,C as r,O as s,W as t,E as u,q as v};
@@ -0,0 +1 @@
1
+ "use client";var t="popmelt.explore-option.v1";function e(t,e,r){return[t?"Component: "+t:"Target: "+e,"Route: "+r].join("\n")}function r(t,r){if(!r||"object"!=typeof r||Array.isArray(r))return t;let n=r.target;if(!n||"object"!=typeof n||Array.isArray(n)||"string"!=typeof n.pathname)return t;let[o,...i]=t.split("\n"),a=" · "+n.pathname;if(!o?.endsWith(a))return t;let l=o.slice(0,-a.length),p="string"==typeof n.component?n.component:void 0;return!l||p&&l!==p?t:[e(p,l,n.pathname),...i].join("\n")}function n(r,n,o,i){let a=r.options[n],{pathname:l,selector:p,element:c}=r.target,s=c?.reactSource,f=c?.reactComponent,u=o.filter(t=>t.batchId===r.id&&t.option===n).map(({part:t,property:e,from:r,to:n})=>({part:t,property:e,from:r,to:n})),d={pathname:l,selector:p,...c?.selector&&{sourceSelector:c.selector},...f&&{component:f},...s&&{source:s}},h="root"in a&&i?.path.reduce((t,e)=>t.children[e],a.root);return{source:"Popmelt",title:h&&(i?.path.length||i?.field)?a.title+" · "+(h.name??h.label??h.kind)+(i.field?" label":""):i?.fixturePart?a.title+" · "+(i.fixturePartLabel||i.fixturePart.replace(/^@/,"")):a.title,content:[e(f,c?.subjectLabel||p,l),...u.map(({part:t,property:e,to:r})=>[t,e+" → "+r].filter(Boolean).join(" · "))].join("\n"),...s&&{sourceURI:s.fileName},kind:t,selection:{batchId:r.id,index:n,target:d,option:a,steerEdits:u,...i&&(i.path.length||i.field||i.fixturePart)?{focus:{path:i.path,...i.fixturePart&&{part:i.fixturePart},...i.fixturePartLabel&&{label:i.fixturePartLabel},...i.field&&{field:i.field}}}:{}}}}function o(t,e,r){return{key:JSON.stringify([t.id,e.option,e.path,e.field,e.fixturePart]),tag:e,note:n(t,e.option,r,e)}}function i(t,e,r){let o=n(t,e,r);return{text:`Apply “${o.title}” in code.`,meta:{exploreOption:o}}}function a(t){if(!t?.startsWith("Apply “"))return;let e=t.indexOf("\nUpdate the annotated component with this reviewed option and its Steer changes. Preserve existing behavior and unrelated styling.\n```json\n");return e>0&&t.slice(0,e).endsWith("” in code.")?t.slice(0,e):void 0}export{t as a,r as b,o as c,i as d,a as e};
@@ -1,2 +1 @@
1
- "use client";
2
- function r(){let l=!1,t=null,n,a=new Set,s=()=>a.forEach(e=>e());return{connect(e){t!==e&&(n?.(),t=e,t.setAvailable(l),n=t.subscribe(s),s())},setAvailable(e){l=e,t?.setAvailable(e)},getSnapshot:()=>t?.getSnapshot()??null,subscribe(e){return a.add(e),()=>{a.delete(e)}}}}var b=r();export{b as a};
1
+ "use client";var e=function(){let e,t=!1,a=null,l=new Set,n=()=>l.forEach(e=>e());return{connect(l){a!==l&&(e?.(),a=l,a.setAvailable(t),e=a.subscribe(n),n())},setAvailable(e){t=e,a?.setAvailable(e)},getSnapshot:()=>a?.getSnapshot()??null,subscribe:e=>(l.add(e),()=>{l.delete(e)})}}();export{e as a};