@popmelt.com/core 0.24.1 → 0.25.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.
Files changed (36) hide show
  1. package/README.md +34 -2
  2. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  3. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  4. package/dist/ParticipantRuntime-WZLITXXM.mjs +139 -0
  5. package/dist/PopmeltTasteConnectedPane-77Z23N6Y.mjs +81 -0
  6. package/dist/PreviewRuntime-ATSECGMB.mjs +2 -0
  7. package/dist/bridge-entry.mjs +84 -71
  8. package/dist/browser-runtime-PC2NODES.mjs +2 -0
  9. package/dist/browser.mjs +1 -1
  10. package/dist/chunk-FRHGK5ZV.mjs +2 -0
  11. package/dist/chunk-NXMPY7RX.mjs +2 -0
  12. package/dist/chunk-RLCNRGNJ.mjs +77 -0
  13. package/dist/{chunk-4WAFUF5Y.mjs → chunk-VUJWDJ6C.mjs} +1 -1
  14. package/dist/chunk-XIWFG3E4.mjs +345 -0
  15. package/dist/chunk-YHITBHLH.mjs +370 -0
  16. package/dist/{chunk-3MO7Z4DV.mjs → chunk-YMJHG3Q6.mjs} +1 -1
  17. package/dist/chunk-ZJPPZLXU.mjs +2 -0
  18. package/dist/cli.mjs +109 -96
  19. package/dist/index.mjs +1 -1
  20. package/dist/plugin-astro.mjs +1 -1
  21. package/dist/plugin-next.d.mts +6 -2
  22. package/dist/plugin-next.mjs +1 -1
  23. package/dist/plugin-nuxt.mjs +1 -1
  24. package/dist/plugin-vite.mjs +1 -1
  25. package/dist/server-6X5YVYKP.mjs +241 -0
  26. package/dist/server.d.mts +7 -0
  27. package/dist/server.mjs +87 -74
  28. package/package.json +26 -25
  29. package/dist/ParticipantRuntime-SS2IDRLA.mjs +0 -139
  30. package/dist/PreviewRuntime-NGTLOEX3.mjs +0 -2
  31. package/dist/browser-runtime-HYKTQV6Q.mjs +0 -2
  32. package/dist/chunk-3XSTOVWX.mjs +0 -2
  33. package/dist/chunk-7W3RBRFM.mjs +0 -301
  34. package/dist/chunk-B5KUI32Q.mjs +0 -413
  35. package/dist/chunk-ENERPQJN.mjs +0 -2
  36. package/dist/server-OPX7SKA7.mjs +0 -228
@@ -1 +1 @@
1
- import{a as o,b as d,c as l,d as s}from"./chunk-4WAFUF5Y.mjs";function g(r){let p=r?.basePath??"/popmelt",e={port:null,projectId:null},n="virtual:popmelt/bridge",i=`\0${n}`;return{name:"popmelt",resolveId(t){if(t===n)return i},load(t){if(t===i)return`export const bridgeUrl = ${JSON.stringify(e.port===null?null:`http://localhost:${e.port}`)}; export const projectId = ${JSON.stringify(e.projectId)};`},async configureServer(t){e=await o(r,t,5173),await d(e,t),t.middlewares.use(l(p,()=>e))},transformIndexHtml(){if(e.port!==null)return[{tag:"script",attrs:{type:"text/javascript"},children:s(e),injectTo:"head-prepend"}]}}}export{g as a};
1
+ import{a as o,b as d,c as l,d as s}from"./chunk-VUJWDJ6C.mjs";function g(r){let p=r?.basePath??"/popmelt",e={port:null,projectId:null},n="virtual:popmelt/bridge",i=`\0${n}`;return{name:"popmelt",resolveId(t){if(t===n)return i},load(t){if(t===i)return`export const bridgeUrl = ${JSON.stringify(e.port===null?null:`http://localhost:${e.port}`)}; export const projectId = ${JSON.stringify(e.projectId)};`},async configureServer(t){e=await o(r,t,5173),await d(e,t),t.middlewares.use(l(p,()=>e))},transformIndexHtml(){if(e.port!==null)return[{tag:"script",attrs:{type:"text/javascript"},children:s(e),injectTo:"head-prepend"}]}}}export{g as a};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ var j=" >>> ";function _(e){return Array.from(e.querySelectorAll("*")).flatMap(t=>t.shadowRoot?[t.shadowRoot]:[])}function W(e=document){let t=[e];for(let r of t)t.push(..._(r));return t}function v(e,t=document){let r=e.split(j);if(r.length>1){let o=t,i=null;for(let l=0;l<r.length;l+=1){if(i=o.querySelector(r[l]),!i)return null;if(l<r.length-1){if(!i.shadowRoot)return null;o=i.shadowRoot}}return i}let n=[t];for(let o of n){let i=o.querySelector(e);if(i)return i;n.push(..._(o))}return null}function m(e){if(e.parentElement)return e.parentElement;let t=e.getRootNode();return t instanceof ShadowRoot?t.host:null}function A(e,t){let r=e;for(;r;){if(r.matches(t))return r;r=m(r)}return null}function Q(e,t){let r=t;for(;r;){if(r===e)return!0;r=m(r)}return!1}function U(e,t,r){let n=typeof e.elementsFromPoint=="function"?e.elementsFromPoint(t,r):[],o=e.elementFromPoint?.(t,r)??null;return o&&!n.includes(o)?[o,...n]:n}function L(e,t){let r=[],n=new Set;for(let o of W().reverse())for(let i of U(o,e,t))n.has(i)||(n.add(i),r.push(i));return r}function N(){return j}var tt=["id","data-testid","data-test","data-cy","data-popmelt-media-id","aria-label","name","href"],k=e=>e.replace(/\s+/g," ").trim();function w(e){return e==="id"||e==="data-popmelt-media-id"||/^data-(?:testid|test|cy)(?:-[a-z0-9_-]+)?$/.test(e)}function T(e,t){return!!(t&&t.length<=200&&!(e==="id"&&/^(radix-|:|_r_)/.test(t)))}function D(e){let t={},r=new Set([...tt,...e.getAttributeNames().filter(w)]);for(let i of r){let l=e.getAttribute(i);l&&T(i,l)&&(t[i]=l)}let n=k(e.querySelector("h1,h2,h3,h4,h5,h6")?.textContent??""),o=k(Array.from(e.childNodes).filter(i=>i.nodeType===3).map(i=>i.textContent).join(" "));return{tag:e.tagName.toLowerCase(),...Object.keys(t).length?{attributes:t}:{},...n&&n.length<=200?{heading:n}:{},...o&&o.length<=200?{text:o}:{}}}function O(e,t,r=document){let n=W(r),o=s=>{try{return n.flatMap(c=>Array.from(c.querySelectorAll(s)))}catch{return[]}},i=!!(t&&(t.heading||t.text||Object.keys(t.attributes??{}).length)),l=s=>{if(!t||!i)return!0;let c=D(s);return c.tag===t.tag&&(!t.heading||c.heading===t.heading)&&(!t.text||c.text===t.text)&&Object.entries(t.attributes??{}).every(([d,E])=>s.getAttribute(d)===E)};for(let s of e){if(s.includes(" >>> ")){try{let d=v(s,r);if(d&&l(d))return{status:"matched",element:d}}catch{}continue}let c=o(s);if(c.length===1&&(/^\[data-pm=/.test(s)||!i))return{status:"matched",element:c[0]}}if(!i||e.some(s=>s.includes(" >>> "))||!/^[a-z][a-z0-9-]*$/.test(t.tag))return{status:"missing"};let a=o(t.tag);if(a.length>500)return{status:"ambiguous"};let u=Object.entries(t.attributes??{}).filter(([s])=>w(s));if(u.length){let s=a.filter(c=>u.every(([d,E])=>c.getAttribute(d)===E));return s.length===1?{status:"matched",element:s[0]}:{status:s.length?"ambiguous":"missing"}}let x=a.filter(l);return x.length===1?{status:"matched",element:x[0]}:{status:x.length?"ambiguous":"missing"}}function et(e,t,r=document){let n={};if(t)for(let[a,u]of Object.entries({...t.dataAttributes,...t.id?{id:t.id}:{}}))w(a)&&T(a,u)&&(n[a]=u);let o=t?.targetFingerprint?.tag??t?.tagName?.toLowerCase(),i=t&&o?{...t.targetFingerprint,tag:o,attributes:{...n,...t.targetFingerprint?.attributes}}:t?.targetFingerprint,l=O([e,t?.selector].filter(a=>!!a),i,r);return l.status==="matched"?l.element:null}var rt=["data-popmelt-media-id","data-testid","data-test","data-cy"];function I(e){let t=e.getRootNode();if(!(t instanceof Document||t instanceof ShadowRoot))return null;let r=new Set([...rt,...e.getAttributeNames().filter(n=>n!=="id"&&w(n))]);for(let n of r){let o=e.getAttribute(n);if(!o||o.length>200)continue;let i=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(o):Array.from(o,a=>{if(a==='"'||a==="\\")return`\\${a}`;let u=a.charCodeAt(0);return u<32||u===127?`\\${u.toString(16)} `:a}).join(""),l=`[${n}="${i}"]`;if(t.querySelectorAll(l).length===1)return l}return null}function nt(e){let t=I(e);if(t)return t;if(e.id)return`#${e.id}`;let r=e.tagName.toLowerCase(),n=Array.from(e.classList).slice(0,3).join(".");return n?`${r}.${n}`:r}function p(e){if(e.getRootNode()instanceof Document&&e.id&&!e.id.startsWith("radix-")&&!e.id.startsWith(":"))return`#${CSS.escape(e.id)}`;let t=[],r=e;for(;r&&r!==document.documentElement;){let n=r.tagName.toLowerCase(),o=I(r);if(o?n=o:r.id&&!r.id.startsWith("radix-")&&!r.id.startsWith(":")&&(n=`#${CSS.escape(r.id)}`),!o&&!n.startsWith("#")){let a=Array.from(r.classList).filter(u=>!u.startsWith("_")&&u.length<30).slice(0,2);a.length>0&&(n+="."+a.map(u=>CSS.escape(u)).join("."))}let i=r.parentElement;if(i&&!o&&!n.startsWith("#")){let a=Array.from(i.children).filter(u=>u.tagName===r.tagName);if(a.length>1){let u=a.indexOf(r)+1;n+=`:nth-of-type(${u})`}}if(t.unshift(n),o||n.startsWith("#")){let a=r.getRootNode();if(a instanceof Document)break;if(a instanceof ShadowRoot){t.unshift(N().trim()),r=a.host;continue}}if(i){r=i;continue}let l=r.getRootNode();if(!(l instanceof ShadowRoot))break;t.unshift(N().trim()),r=l.host}return t.join(" > ").replace(/ > >>> > /g,N())}function f(e){try{return v(e)}catch{return null}}function b(e){return e instanceof HTMLElement||e instanceof SVGElement}var $=new WeakMap,y=new WeakMap;function ot(e,t){if(b(t))for(let[r,n]of y.get(e)??[])n.value?t.style.setProperty(r,n.value,n.priority):t.style.removeProperty(r)}function it(e,t){$.set(e,new Set(t))}function lt(e){$.delete(e)}function M(e,t){return b(e)&&($.get(e)?.has(t)??!1)}function q(e){let t=e.sticker;return t?t.family==="padding"||t.family==="margin"?t.subproperty==="all"?10:t.subproperty==="x"||t.subproperty==="y"?20:30:t.family==="radius"||t.family==="border"?t.subproperty==="all"?10:20:10:0}function at(e){return e.changes.map((t,r)=>({change:t,index:r})).sort((t,r)=>q(t.change)-q(r.change)||t.index-r.index).map(({change:t})=>t)}function B(e,t,r){if(b(e)){let n=y.get(e);n||(n=new Map,y.set(e,n)),n.has(t)||n.set(t,{value:e.style.getPropertyValue(t),priority:e.style.getPropertyPriority(t)}),e.style.setProperty(t,r,"important")}}function ut(e,t,r,n=!1){if(b(e)){let o=n?y.get(e)?.get(t):void 0;o?.value?e.style.setProperty(t,o.value,o.priority):e.style.removeProperty(t),y.get(e)?.delete(t)}}function V(e){let t=f(e.selector);if(!t&&e.durableSelector&&(t=f(e.durableSelector),t)){let r=e.selector.match(/\[data-pm="([^"]+)"\]/)?.[1];r&&t.setAttribute("data-pm",r)}return t}function st(e){for(let t of e){let r=V(t);if(r)for(let n of at(t))M(r,n.property)||B(r,n.property,n.modified)}}function ct(e,t=!1){for(let r of e){let n=f(r.selector);if(n)for(let o of r.changes)M(n,o.property)||ut(n,o.property,o.original,t)}}function z(e){let t=f(e.selector);if(!t&&e.durableSelector&&(t=f(e.durableSelector),t)){let r=e.selector.match(/\[data-pm="([^"]+)"\]/)?.[1];r&&t.setAttribute("data-pm",r)}return t}function H(e,t){let r=e;for(let n of t)r=r?.childNodes[n]??null;return r?.nodeType===Node.TEXT_NODE?r:null}function ft(e){for(let t of e){let r=z(t);if(!r)continue;let n=H(r,t.textNodePath);n&&(n.nodeValue=t.modified)}}function dt(e){for(let t of e){let r=z(t);if(!r)continue;let n=H(r,t.textNodePath);n&&(n.nodeValue=t.original)}}function g(e,t){if(!e)return null;let r=f(e);if(!r&&t&&(r=f(t),r)){let n=e.match(/\[data-pm="([^"]+)"\]/)?.[1];n&&r.setAttribute("data-pm",n)}return r}function mt(e){e.removeAttribute("data-pm"),e.querySelectorAll("[data-pm]").forEach(t=>t.removeAttribute("data-pm"))}function gt(e,t){let r=t.match(/\[data-pm="([^"]+)"\]/)?.[1];r&&e.setAttribute("data-pm",r)}function F(e,t,r){let n=Array.from(e.children).filter(i=>i!==t),o=Math.max(0,Math.min(r,n.length));e.insertBefore(t,n[o]??null)}function ht(e){for(let t of e){let r=g(t.targetParentSelector,t.targetParentDurableSelector);if(!r)continue;if(t.operation==="move"){let i=g(t.selector,t.durableSelector);if(!i||i===r||i.contains(r))continue;F(r,i,t.targetIndex);continue}if(g(t.selector,t.durableSelector))continue;let n=g(t.sourceSelector,t.sourceDurableSelector);if(!n)continue;let o=n.cloneNode(!0);o instanceof Element&&(mt(o),gt(o,t.selector),F(r,o,t.targetIndex))}}function pt(e){for(let t of[...e].reverse()){if(t.operation==="copy"){g(t.selector,t.durableSelector)?.remove();continue}let r=g(t.selector,t.durableSelector),n=g(t.originalParentSelector,t.originalParentDurableSelector);!r||!n||r===n||r.contains(n)||F(n,r,t.originalIndex??n.children.length)}}function X(e){let t=Object.keys(e).find(i=>i.startsWith("__reactFiber$")||i.startsWith("__reactInternalInstance$"));if(!t)return null;let r=e[t],n=[],o=r?._debugSource;for(;r;){let i=r.type,l=i?.displayName||i?.name;l&&typeof l=="string"&&/^[A-Z]/.test(l)&&!l.startsWith("_")&&l!=="Fragment"&&n.unshift(l),r=r.return}return n.length>0?{name:n[n.length-1],path:n,...o?.fileName&&Number.isFinite(o.lineNumber)?{source:o}:{}}:null}function bt(e){let t=Object.keys(e).find(o=>o.startsWith("__reactFiber$")||o.startsWith("__reactInternalInstance$"));if(!t)return[];let r=e[t],n=[];for(;r;){let o=r.type,i=typeof o=="function"||typeof o=="object"?o?.displayName||o?.name:null;i&&typeof i=="string"&&/^[A-Z]/.test(i)&&!i.startsWith("_")&&i!=="Fragment"&&n.push({name:i,fiber:r}),r=r.return}return n.reverse(),n}function yt(e){let t=e,r=new Set;for(;t&&!r.has(t);){if(r.add(t),t.stateNode instanceof Element)return t.stateNode;t.child?t=t.child:t=null}return null}var St=900,C=80;function h(e){if(!e)return null;try{return v(e)}catch{return null}}function S(e){return(e??"").replace(/\s+/g," ").trim()}function Z(e){let t=S(e.getAttribute("aria-label"));if(t)return t.slice(0,C);let r=S(e.getAttribute("aria-labelledby"));if(r){let o=r.split(/\s+/).map(i=>S(document.getElementById(i)?.textContent)).filter(Boolean).join(" ");if(o)return o.slice(0,C)}let n=S(e.getAttribute("title"));return n?n.slice(0,C):S(e.textContent).slice(0,C)}function vt(e){return e.id?Array.from(document.querySelectorAll("[aria-controls]")).find(t=>t.getAttribute("aria-controls")===e.id)??null:null}function At(e){if(e instanceof HTMLDetailsElement){let n=Array.from(e.children).find(i=>i.tagName.toLowerCase()==="summary");if(!n)return null;let o=Z(n);return o?{triggerSelector:p(n),targetSelector:p(e),label:o}:null}let t=vt(e);if(!t)return null;let r=Z(t);return r?{triggerSelector:p(t),targetSelector:p(e),label:r}:null}function P(e){let t=[],r=new Set,n=m(e);for(;n&&n!==document.body&&n!==document.documentElement;){let i=At(n);i&&!r.has(i.triggerSelector)&&(r.add(i.triggerSelector),t.push(i)),n=m(n)}if(t.length===0)return;let o=t.reverse();return{steps:o,location:o.map(i=>i.label)}}function G(e){let t=e?.[0]?.revealRecipe;if(t?.steps.length)return t;let r=h(e?.[0]?.selector);return r?P(r):void 0}function Nt(e){let t=G(e)?.location.filter(Boolean);return t?.length?`Inside: ${t.join(" \u203A ")}`:null}function R(e){if(!e?.isConnected)return!1;let t=e.getBoundingClientRect();if(t.width<=0||t.height<=0||e.getClientRects().length===0)return!1;let r=e;for(;r;){let n=window.getComputedStyle(r);if(n.display==="none"||n.visibility==="hidden"||n.visibility==="collapse"||Number.parseFloat(n.opacity||"1")<=0)return!1;r=r.parentElement}return!0}function wt(e,t,r){return t.getAttribute("aria-expanded")==="true"||t.getAttribute("data-state")==="open"?!0:r instanceof HTMLDetailsElement?r.open:R(r)}function J(e,t=St){return e?new Promise(r=>{let n=performance.now(),o=()=>{let i=h(e);if(R(i)){r(i);return}if(performance.now()-n>=t){r(null);return}requestAnimationFrame(o)};o()}):Promise.resolve(null)}function Ct(e,t){return h(e)??h(t?.[0]?.selector)}async function xt(e,t){let r=Ct(e,t);if(R(r))return r;let n=G(t)??(r?P(r):void 0);if(!n)return null;for(let i of n.steps){let l=h(i.triggerSelector);if(!(l instanceof HTMLElement))return null;let a=h(i.targetSelector);if(!wt(i,l,a)&&(l.click(),!await J(i.targetSelector)))return null}let o=e&&h(e)?e:t?.[0]?.selector;return J(o)}function Et(e){let t={targetFingerprint:D(e),selector:nt(e),tagName:e.tagName.toLowerCase()};e.id&&(t.id=e.id),e.classList.length>0&&(t.className=Array.from(e.classList).join(" "));let r=Wt(e)||e.matches('button, a, [role="button"], [role="tab"]')&&(e.getAttribute("aria-label")||e.getAttribute("title")||e.textContent?.trim())||"";r&&r.length>0&&r.length<200&&(t.textContent=r);let n={};for(let a of e.attributes)a.name.startsWith("data-")&&(n[a.name]=a.value);Object.keys(n).length>0&&(t.dataAttributes=n);let o=X(e);o&&(t.reactComponent=o.name,t.reactComponentPath=o.path,o.source&&(t.reactSource=o.source));let i=Lt(e);i&&(t.context=i);let l=P(e);return l&&(t.revealRecipe=l),t}function Wt(e){let t="";for(let r of e.childNodes)r.nodeType===Node.TEXT_NODE&&(t+=r.textContent||"");return t.trim()}function $t(e,t,r){return Y(e,t,r)[0]??null}var Ft="[data-popmelt-canvas-block]";function K(e,t){let r=L(e,t).find(n=>n.id!=="devtools-canvas"&&n.id!=="devtools-scrim");return!!(r&&A(r,Ft))}function Pt(e){return e instanceof SVGElement?e.closest("svg")??e:e}function Y(e,t,r){if(K(e,t))return[];let n=new Set,o=L(e,t),i=o.map(Pt).filter(l=>n.has(l)||(n.add(l),l.id==="devtools-canvas"||l.id==="devtools-toolbar"||l.id==="devtools-scrim")||A(l,"#devtools-toolbar")||l.hasAttribute("data-devtools")||A(l,"[data-devtools]")?!1:l!==document.body&&l!==document.documentElement);return i.length>0?i:r?.allowBodyFallback&&o.includes(document.body)?[document.body]:[]}function Rt(e,t,r){for(let n of e.childNodes){if(n.nodeType!==Node.TEXT_NODE||!n.textContent?.trim())continue;let o=document.createRange();o.selectNodeContents(n);let i=o.getClientRects?.();if(i&&Array.from(i).some(l=>t>=l.left&&t<=l.right&&r>=l.top&&r<=l.bottom))return!0}return!1}function jt(e,t,r){if(Rt(e,t,r)||["button","canvas","embed","iframe","img","input","object","select","svg","textarea","video"].includes(e.tagName.toLowerCase()))return!0;let n=getComputedStyle(e);if(n.backgroundImage&&n.backgroundImage!=="none")return!0;let o=n.backgroundColor.trim();if(o&&o!=="transparent"&&!/rgba?\([^)]*,\s*0(?:\.0+)?\s*\)$/.test(o))return!0;let i=e.getBoundingClientRect(),l={top:Number.parseFloat(n.borderTopWidth)||0,right:Number.parseFloat(n.borderRightWidth)||0,bottom:Number.parseFloat(n.borderBottomWidth)||0,left:Number.parseFloat(n.borderLeftWidth)||0};return l.top>0&&r<=i.top+l.top||l.right>0&&t>=i.right-l.right||l.bottom>0&&r>=i.bottom-l.bottom||l.left>0&&t<=i.left+l.left}function _t(e,t,r){let n=Y(e,t,r);return n.find(o=>jt(o,e,t))??n.at(-1)??null}function Lt(e){let t=m(e),r=["section","article","nav","aside","header","footer","main"];for(;t&&t!==document.body;){let n=t.tagName.toLowerCase();if(r.includes(n)&&t.id)return`${n}#${t.id}`;if(t.id&&!t.id.startsWith("radix-")&&!t.id.startsWith(":"))return`${n}#${t.id}`;t=m(t)}return null}export{ct as A,ft as B,dt as C,ht as D,pt as E,W as a,v as b,m as c,A as d,Q as e,N as f,O as g,et as h,p as i,f as j,Nt as k,xt as l,X as m,bt as n,yt as o,Et as p,$t as q,K as r,_t as s,b as t,ot as u,it as v,lt as w,B as x,V as y,st as z};