@popmelt.com/core 0.38.0 → 0.38.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.
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/dist/{ParticipantRuntime-CGJH7YZL.mjs → ParticipantRuntime-ZNEFG34O.mjs} +1 -1
- package/dist/bridge-entry.mjs +1 -1
- package/dist/{browser-runtime-WXDKC4TL.mjs → browser-runtime-Q26JF5EA.mjs} +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/{chunk-2GICKLUW.mjs → chunk-2IWVTTYX.mjs} +1 -1
- package/dist/{chunk-ACBGA4NT.mjs → chunk-2WQXHUEQ.mjs} +1 -1
- package/dist/{chunk-3DUTQ6GY.mjs → chunk-3OGSLX4V.mjs} +1 -1
- package/dist/{chunk-7MYZEG74.mjs → chunk-AEC67LMY.mjs} +1 -1
- package/dist/{chunk-Y3WTPLDG.mjs → chunk-FQLIJAUB.mjs} +1 -1
- package/dist/{chunk-6V4Q2JFN.mjs → chunk-N3MHDOMU.mjs} +1 -1
- package/dist/{chunk-X56HNVHF.mjs → chunk-QQPUMPKU.mjs} +1 -1
- package/dist/{chunk-O2OYVEL7.mjs → chunk-UOK5LOPJ.mjs} +1 -1
- package/dist/{chunk-BRAEIDNX.mjs → chunk-VG4ZV2OT.mjs} +1 -1
- package/dist/{chunk-ZSTKAPV5.mjs → chunk-WC7B5NU3.mjs} +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/{codex-note-context-WYH7D6SS.mjs → codex-note-context-4X7I5AIJ.mjs} +1 -1
- package/dist/{codex-project-Q4CKTDOH.mjs → codex-project-Q6YT5P37.mjs} +1 -1
- package/dist/{codex-store-mount-RSRKEV2B.mjs → codex-store-mount-WJAATWHT.mjs} +1 -1
- package/dist/dev-server-NROXLQKM.mjs +1 -0
- package/dist/guest-admission.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{peer-client-HYSUL7UZ.mjs → peer-client-DWC5F6JN.mjs} +1 -1
- package/dist/plugin-astro.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/webpEncoder-QJRHTWUU.mjs +1 -0
- package/package.json +1 -1
- package/dist/dev-server-SDS67665.mjs +0 -1
- package/dist/webpEncoder-MTPCVDOG.mjs +0 -1
- /package/dist/{chunk-FIOGWEZA.mjs → chunk-L45FX4SU.mjs} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{d as t,b as e,c as o,a as r}from"./chunk-GTVTUWGH.mjs";import"./chunk-SKM4ZXV5.mjs";import"./chunk-TXL2CR66.mjs";import{f as i}from"./chunk-ZSTKAPV5.mjs";import"./chunk-ZHXTB5IN.mjs";import"./chunk-FYURSPM3.mjs";import"./chunk-43BZCDGL.mjs";import"./chunk-PH2MLB3T.mjs";import"./chunk-ZVDKW7TO.mjs";import"./chunk-XTOCFTVW.mjs";import"./chunk-KHDXOXYF.mjs";import"./chunk-SOGN7S54.mjs";import"./chunk-BJUSVIDN.mjs";import"./chunk-WNOLXY3Y.mjs";import{a as n}from"./chunk-JAMYVQFC.mjs";import{i as a,Y as s}from"./chunk-G6BN5TAZ.mjs";import"./chunk-B3RA4XAR.mjs";import"./chunk-DBCBG5J6.mjs";import"./chunk-G2ZHJXHZ.mjs";import"./chunk-TMSGNHXH.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-3LZQLRZ2.mjs";import"./chunk-RJWFSAKE.mjs";import"./chunk-P2WAXWAZ.mjs";import"./chunk-2F2BVGFH.mjs";import"./chunk-RWZ7SVMO.mjs";import"./chunk-RK6UROPO.mjs";import"./chunk-5IZHN3A7.mjs";import"./chunk-AOTDTBQO.mjs";import"./chunk-HAZXZ5TU.mjs";import"./chunk-TVIKC33M.mjs";import"./chunk-25EXQOPI.mjs";import"./chunk-VXRRHXUP.mjs";import"./chunk-WP2SHSCG.mjs";import{e as c,g as l,f as p}from"./chunk-AAMUU2QA.mjs";import"./chunk-LH7HKUCK.mjs";import{a as m}from"./chunk-3DUTQ6GY.mjs";import{b as h,f as u,c as d,d as f}from"./chunk-3VOEPWRL.mjs";import{o as j}from"./chunk-X56HNVHF.mjs";import"./chunk-X6I6KQDG.mjs";import"./chunk-ATLUO4G7.mjs";import"./chunk-JJRKR4X3.mjs";import"./chunk-C2ZSNUXQ.mjs";import"./chunk-TEXVTTWA.mjs";import"./chunk-Q6C7ZA3H.mjs";import"./chunk-EILBHZDX.mjs";import"./chunk-XJJDBMZI.mjs";import"./chunk-OREALBUO.mjs";import"./chunk-B4DYUYX4.mjs";import"./chunk-CK3CDA3L.mjs";import{c as k,a as g}from"./chunk-WJVRGXOS.mjs";import"./chunk-BEGAJYOY.mjs";import"./chunk-AGCS65LT.mjs";import{U as w}from"./chunk-OA63PYHZ.mjs";import"./chunk-6RMM7JB6.mjs";import{b as y}from"./chunk-SUAHDXJZ.mjs";import"./chunk-PRPXMDZ7.mjs";import"./chunk-A4GARXVQ.mjs";import"./chunk-YGP6PPOZ.mjs";import{useState as S,useSyncExternalStore as v,useEffect as I}from"react";import{jsx as A,jsxs as P}from"react/jsx-runtime";function O(t,i){let n,a={phase:"starting"},m=0,j=!1,k=!1,g=0,w=new Set,S=`popmelt-participant:${t.projectId}`,v=new h(t.url,t.projectId),I=t=>{if(!k){a=t;for(let t of w)t()}},A=()=>history.state?.popmeltGuestEntry===t.projectId,P=e=>history.replaceState({...history.state,popmeltGuestEntry:t.projectId},"",e),O=t=>fetch("/__popmelt/host",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(t),redirect:"error"}),H=async(e={},o=!1,r)=>{if(y(t.url))return null;let i=await O(e);if(403===i.status){let e=i.headers.get("X-Popmelt-Host-Origin"),n=i.headers.get("X-Popmelt-Session"),a=new URL(location.href);if(!o||!n||window.top!==window||!["localhost","127.0.0.1","[::1]"].includes(a.hostname)||a.pathname.startsWith("/__popmelt/")||a.searchParams.has("__popmelt_code_preview")||a.hash.includes("popmelt-")||A())return null;let s=localStorage.getItem(`popmelt-admission:${t.projectId}`);if(s)try{if(JSON.parse(s)?.receipt)return null}catch{return null}if(e&&function(t,e){try{let o=new URL(t),r=new URL(e),i=["localhost","127.0.0.1","[::1]"];return o.origin===t&&r.origin===e&&t!==e&&["http:","https:"].includes(o.protocol)&&o.protocol===r.protocol&&o.port===r.port&&i.includes(o.hostname)&&i.includes(r.hostname)}catch{return!1}}(location.origin,e)){let t=await fetch(e+"/__popmelt/host",{method:"HEAD",credentials:"omit",redirect:"error",referrerPolicy:"no-referrer",signal:AbortSignal.timeout(2e3)}).catch(()=>null);if(!k&&204===t?.status&&t.headers.get("X-Popmelt-Session")===n)throw a.host=new URL(e).host,location.replace(a.href),X;return null}let c=i.headers.get("X-Popmelt-Local-Port");if(!c||!/^[1-9]\d{0,4}$/.test(c)||Number(c)>65535)return null;let l=await fetch("http://127.0.0.1:"+c+"/",{method:"POST",headers:{"X-Popmelt-Session":n},credentials:"omit",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer",signal:AbortSignal.timeout(6500)}).catch(()=>null);if(!l?.ok||k)return null;let p=await l.json().catch(()=>null);if("string"!=typeof p?.proof||(i=await O({localProof:p.proof,previousId:r}),403===i.status))return null}if(!i.ok)throw new Error(`Host entry unavailable (${i.status}).`);let n=`popmelt-before-participants:${t.projectId}`;return null===localStorage.getItem(n)&&localStorage.setItem(n,JSON.stringify(Object.fromEntries(Object.values(s(t.projectId)).map(t=>[t,localStorage.getItem(t)])))),await i.json()},X=Symbol("navigating"),R=async(a,s=g)=>{if(k||s!==g)return;let m=await r({bridgeUrl:t.url,projectId:t.projectId,credential:a,runtimeStorage:sessionStorage,observedSource:{sourceId:t.projectId,revision:t.revision},loadOwnSource:i,prepareApplication:t.planeApps?async r=>{if(k||s!==g)throw X;let i=c(location.pathname);if(r.author.id===a.participantId&&"host"===r.author.relationship&&!y(t.url)){if("/"!==i){let t=new URL(location.href);throw t.pathname=p(t.pathname),location.replace(t.href),X}return("/"===r.ownWorkspace?.basePath?r.ownWorkspace.revision:void 0)??r.draft.source?.revision??t.revision}let n=await e(a,a.participantId,void 0,location.pathname);if(k||s!==g)throw X;let m=o(n.application);if(t.appVersion??(t.appVersion=n.application.version),m!==l(location.pathname)||t.appVersion&&t.appVersion!==n.application.version)throw localStorage.setItem(S,JSON.stringify(a)),location.replace(m+location.search+location.hash),X;return n.application.basis??t.revision}:void 0}).catch(t=>{if(t!==X)throw t});if(m){if(k||s!==g)return void m.dispose();try{localStorage.setItem(S,JSON.stringify(a))}catch(t){throw m.dispose(),t}if(n?.dispose(),A()){let t={...history.state};delete t.popmeltGuestEntry,history.replaceState(t,"")}n=m,I({phase:"connected",connection:m}),H({credential:a}).catch(()=>{})}},b=()=>{P(location.href),g++,n?.dispose(),n=void 0,function(t,e){t.removeItem(`popmelt-participant:${e}`);let o,r=`popmelt-admission:${e}`;try{o=JSON.parse(t.getItem(r)??"null")}catch{return void t.removeItem(r)}o&&"object"==typeof o&&t.setItem(r,JSON.stringify({name:o.name,colorIdentity:o.colorIdentity??o.receipt}))}(localStorage,t.projectId),I({phase:"entry",invitation:null})};return{client:v,getSnapshot:()=>a,subscribe:t=>(w.add(t),()=>{w.delete(t)}),retain(){if(k)throw new Error("Participant lifecycle is disposed");m++,j||(j=!0,(async()=>{let t=u(location.href),e=new URL(t.cleanUrl),o=new URLSearchParams(e.hash.slice(1)),r=o.get("popmelt-host");o.delete("popmelt-host"),r&&(e.hash=o.toString()),t.token?P(e.href):e.href!==location.href&&history.replaceState(history.state,"",e);let i=null;if(r){if(i=await H({token:r}),!i&&!t.token&&(i=await H({},!0)),!i)throw new Error("Host entry expired. Use the current private host link.")}else if(!t.token&&!A()){try{i=JSON.parse(localStorage.getItem(S)??"null")}catch{}i??(i=await H({},!0))}if(k)return;if(!i)return void I({phase:"entry",invitation:t.token??null});let n=g;for(let e=1;!k&&n===g;e++)try{return void await R(i,n)}catch(o){if(k||n!==g)return;if(d(o)){I({phase:"error",message:o.message}),await new Promise(t=>setTimeout(t,f(e)));continue}if("access_removed"===o.code)return void b();if(401!==o.status)throw o;let a=await H({},!r&&!t.token,i.participantId);return void(a?await R(a):b())}})().catch(t=>{t!==X&&I({phase:"error",message:t.message})}));let t=!1;return()=>{t||(t=!0,m--,queueMicrotask(()=>{m||k||(k=!0,g++,n?.dispose(),n=void 0,w.clear())}))}},removed:b,async join(e,o){if("entry"!==a.phase||!a.invitation||k)throw new Error("No active invitation");if(!o)throw new Error("Peer identity is not ready");let r=g,i=await v.joinOrRequestAdmission(a.invitation,e,o);if(!k&&r===g){if("admission"in i)return localStorage.setItem(`popmelt-admission:${t.projectId}`,JSON.stringify({name:i.admission.name,receipt:o,colorIdentity:o})),void I({phase:"entry",invitation:null});await R(i.joined.credential,r)}},admit:t=>R(t)}}function H({config:r,loadOwnSource:s,children:p}){let[h]=S(()=>O(r,s)),u=a(),d=v(h.subscribe,h.getSnapshot,h.getSnapshot);I(()=>h.retain(),[h]);let[f,H,X]=k(),R="connected"===d.phase?d.connection:null;if(I(()=>{if(!R||!r.planeApps)return;let t,i=new AbortController,n=R.isHost&&!y(r.url)&&"/"===c(location.pathname),a=n?void 0:r.appVersion,s=async()=>{try{let t=await e(R.credential,R.credential.participantId,i.signal,location.pathname);if(n&&"/"!==t.application.basePath)throw new Error("Host checkout unavailable");let s=o(t.application);if(a??(a=t.application.version),!i.signal.aborted&&(s!==l(location.pathname)||t.application.version!==a)){if(R.isHost&&!y(r.url)){let t=await fetch(s+location.search,{method:"HEAD",headers:{Accept:"text/html"},mode:"same-origin",cache:"no-store",signal:i.signal});if(!t.ok||!t.headers.get("content-type")?.includes("text/html")||l(new URL(t.url).pathname)!==s)throw new Error("Host plane document unavailable")}return await R.state.flush(),void(i.signal.aborted||(s===l(location.pathname)?location.reload():location.replace(s+location.search+location.hash)))}}catch{}i.signal.aborted||(t=setTimeout(s,1500))};return s(),()=>{i.abort(),clearTimeout(t)}},[r.planeApps,r.appVersion,r.url,R,u]),R)return A(t,{connection:R,codePreviewUrl:location.href,planeApps:r.planeApps,onAccessRemoved:h.removed,children:p});let b="starting"===d.phase||"error"===d.phase,T="entry"===d.phase?d.invitation:null;return A(n,{children:A("div",{"data-devtools":"participant-entry",style:{display:"contents",pointerEvents:"auto"},children:b?A(i,{entry:{theme:f,themePreference:X,onThemePreferenceChange:H,ariaLabel:"starting"===d.phase?"Popmelt connecting":"Popmelt disconnected",action:null,logoOnly:!0,connected:!1,connection:P("span",{"data-popmelt-entry-content":!0,role:"status",style:{...j(g[f],!1),cursor:"default"},children:[A(w,{size:14,strokeWidth:1.5,"aria-hidden":"true"}),"starting"===d.phase?"Connecting…":"Disconnected"]})}}):A(m,{showHostLinkHelp:window.top===window&&["localhost","127.0.0.1","[::1]"].includes(location.hostname)&&!y(r.url)&&"/"===c(location.pathname),client:h.client,storage:localStorage,storageKey:`popmelt-admission:${r.projectId}`,theme:f,themePreference:X,onThemePreferenceChange:H,onAdmitted:h.admit,onJoin:T?h.join:void 0},T??"request-access")})})}export{H as default};
|
|
1
|
+
"use client";import{d as t,b as e,c as o,a as r}from"./chunk-GTVTUWGH.mjs";import"./chunk-SKM4ZXV5.mjs";import"./chunk-TXL2CR66.mjs";import{f as i}from"./chunk-WC7B5NU3.mjs";import"./chunk-ZHXTB5IN.mjs";import"./chunk-FYURSPM3.mjs";import"./chunk-43BZCDGL.mjs";import"./chunk-PH2MLB3T.mjs";import"./chunk-ZVDKW7TO.mjs";import"./chunk-XTOCFTVW.mjs";import"./chunk-KHDXOXYF.mjs";import"./chunk-SOGN7S54.mjs";import"./chunk-BJUSVIDN.mjs";import"./chunk-WNOLXY3Y.mjs";import{a as n}from"./chunk-JAMYVQFC.mjs";import{i as a,Y as s}from"./chunk-G6BN5TAZ.mjs";import"./chunk-B3RA4XAR.mjs";import"./chunk-DBCBG5J6.mjs";import"./chunk-G2ZHJXHZ.mjs";import"./chunk-TMSGNHXH.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-3LZQLRZ2.mjs";import"./chunk-RJWFSAKE.mjs";import"./chunk-P2WAXWAZ.mjs";import"./chunk-2F2BVGFH.mjs";import"./chunk-RWZ7SVMO.mjs";import"./chunk-RK6UROPO.mjs";import"./chunk-5IZHN3A7.mjs";import"./chunk-AOTDTBQO.mjs";import"./chunk-HAZXZ5TU.mjs";import"./chunk-TVIKC33M.mjs";import"./chunk-25EXQOPI.mjs";import"./chunk-VXRRHXUP.mjs";import"./chunk-WP2SHSCG.mjs";import{e as c,g as l,f as p}from"./chunk-AAMUU2QA.mjs";import"./chunk-LH7HKUCK.mjs";import{a as m}from"./chunk-3OGSLX4V.mjs";import{b as h,f as u,c as d,d as f}from"./chunk-3VOEPWRL.mjs";import{o as j}from"./chunk-QQPUMPKU.mjs";import"./chunk-X6I6KQDG.mjs";import"./chunk-ATLUO4G7.mjs";import"./chunk-JJRKR4X3.mjs";import"./chunk-C2ZSNUXQ.mjs";import"./chunk-TEXVTTWA.mjs";import"./chunk-Q6C7ZA3H.mjs";import"./chunk-EILBHZDX.mjs";import"./chunk-XJJDBMZI.mjs";import"./chunk-OREALBUO.mjs";import"./chunk-B4DYUYX4.mjs";import"./chunk-CK3CDA3L.mjs";import{c as k,a as g}from"./chunk-WJVRGXOS.mjs";import"./chunk-BEGAJYOY.mjs";import"./chunk-AGCS65LT.mjs";import{U as w}from"./chunk-OA63PYHZ.mjs";import"./chunk-6RMM7JB6.mjs";import{b as y}from"./chunk-SUAHDXJZ.mjs";import"./chunk-PRPXMDZ7.mjs";import"./chunk-A4GARXVQ.mjs";import"./chunk-YGP6PPOZ.mjs";import{useState as S,useSyncExternalStore as v,useEffect as I}from"react";import{jsx as P,jsxs as A}from"react/jsx-runtime";function O(t,i){let n,a={phase:"starting"},m=0,j=!1,k=!1,g=0,w=new Set,S=`popmelt-participant:${t.projectId}`,v=new h(t.url,t.projectId),I=t=>{if(!k){a=t;for(let t of w)t()}},P=()=>history.state?.popmeltGuestEntry===t.projectId,A=e=>history.replaceState({...history.state,popmeltGuestEntry:t.projectId},"",e),O=t=>fetch("/__popmelt/host",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(t),redirect:"error"}),X=async(e={},o=!1,r)=>{if(y(t.url))return null;let i=await O(e);if(403===i.status){let e=i.headers.get("X-Popmelt-Host-Origin"),n=i.headers.get("X-Popmelt-Session"),a=new URL(location.href);if(!o||!n||window.top!==window||!["localhost","127.0.0.1","[::1]"].includes(a.hostname)||a.pathname.startsWith("/__popmelt/")||a.searchParams.has("__popmelt_code_preview")||a.hash.includes("popmelt-")||P())return null;let s=localStorage.getItem(`popmelt-admission:${t.projectId}`);if(s)try{if(JSON.parse(s)?.receipt)return null}catch{return null}if(e&&function(t,e){try{let o=new URL(t),r=new URL(e),i=["localhost","127.0.0.1","[::1]"];return o.origin===t&&r.origin===e&&t!==e&&["http:","https:"].includes(o.protocol)&&o.protocol===r.protocol&&o.port===r.port&&i.includes(o.hostname)&&i.includes(r.hostname)}catch{return!1}}(location.origin,e)){let t=await fetch(e+"/__popmelt/host",{method:"HEAD",credentials:"omit",redirect:"error",referrerPolicy:"no-referrer",signal:AbortSignal.timeout(2e3)}).catch(()=>null);if(!k&&204===t?.status&&t.headers.get("X-Popmelt-Session")===n)throw a.host=new URL(e).host,location.replace(a.href),H;return null}let c=i.headers.get("X-Popmelt-Local-Port");if(!c||!/^[1-9]\d{0,4}$/.test(c)||Number(c)>65535)return null;let l=await fetch("http://127.0.0.1:"+c+"/",{method:"POST",headers:{"X-Popmelt-Session":n},credentials:"omit",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer",signal:AbortSignal.timeout(6500)}).catch(()=>null);if(!l?.ok||k)return null;let p=await l.json().catch(()=>null);if("string"!=typeof p?.proof||(i=await O({localProof:p.proof,previousId:r}),403===i.status))return null}if(!i.ok)throw new Error(`Host entry unavailable (${i.status}).`);let n=`popmelt-before-participants:${t.projectId}`;return null===localStorage.getItem(n)&&localStorage.setItem(n,JSON.stringify(Object.fromEntries(Object.values(s(t.projectId)).map(t=>[t,localStorage.getItem(t)])))),await i.json()},H=Symbol("navigating"),R=async(a,s=g)=>{if(k||s!==g)return;let m=await r({bridgeUrl:t.url,projectId:t.projectId,credential:a,runtimeStorage:sessionStorage,observedSource:{sourceId:t.projectId,revision:t.revision},loadOwnSource:i,prepareApplication:t.planeApps?async r=>{if(k||s!==g)throw H;let i=c(location.pathname);if(r.author.id===a.participantId&&"host"===r.author.relationship&&!y(t.url)){if("/"!==i){let t=new URL(location.href);throw t.pathname=p(t.pathname),location.replace(t.href),H}return("/"===r.ownWorkspace?.basePath?r.ownWorkspace.revision:void 0)??r.draft.source?.revision??t.revision}let n=await e(a,a.participantId,void 0,location.pathname);if(k||s!==g)throw H;let m=o(n.application);if(t.appVersion??(t.appVersion=n.application.version),m!==l(location.pathname)||t.appVersion&&t.appVersion!==n.application.version)throw localStorage.setItem(S,JSON.stringify(a)),location.replace(m+location.search+location.hash),H;return n.application.basis??t.revision}:void 0}).catch(t=>{if(t!==H)throw t});if(m){if(k||s!==g)return void m.dispose();try{localStorage.setItem(S,JSON.stringify(a))}catch(t){throw m.dispose(),t}if(n?.dispose(),P()){let t={...history.state};delete t.popmeltGuestEntry,history.replaceState(t,"")}n=m,I({phase:"connected",connection:m}),X({credential:a}).catch(()=>{})}},b=()=>{A(location.href),g++,n?.dispose(),n=void 0,function(t,e){t.removeItem(`popmelt-participant:${e}`);let o,r=`popmelt-admission:${e}`;try{o=JSON.parse(t.getItem(r)??"null")}catch{return void t.removeItem(r)}o&&"object"==typeof o&&t.setItem(r,JSON.stringify({name:o.name,colorIdentity:o.colorIdentity??o.receipt}))}(localStorage,t.projectId),I({phase:"entry",invitation:null})};return{client:v,getSnapshot:()=>a,subscribe:t=>(w.add(t),()=>{w.delete(t)}),retain(){if(k)throw new Error("Participant lifecycle is disposed");m++,j||(j=!0,(async()=>{let t=u(location.href),e=new URL(t.cleanUrl),o=new URLSearchParams(e.hash.slice(1)),r=o.get("popmelt-host");o.delete("popmelt-host"),r&&(e.hash=o.toString()),t.token?A(e.href):e.href!==location.href&&history.replaceState(history.state,"",e);let i=null;if(r){if(i=await X({token:r}),!i&&!t.token&&(i=await X({},!0)),!i)throw new Error("Host entry expired. Use the current private host link.")}else if(!t.token&&!P()){try{i=JSON.parse(localStorage.getItem(S)??"null")}catch{}i??(i=await X({},!0))}if(k)return;if(!i)return void I({phase:"entry",invitation:t.token??null});let n=g;for(let e=1;!k&&n===g;e++)try{return void await R(i,n)}catch(o){if(k||n!==g)return;if(d(o)){I({phase:"error",message:o.message}),await new Promise(t=>setTimeout(t,f(e)));continue}if("access_removed"===o.code)return void b();if(401!==o.status)throw o;let a=await X({},!r&&!t.token,i.participantId);return void(a?await R(a):b())}})().catch(t=>{t!==H&&I({phase:"error",message:t.message})}));let t=!1;return()=>{t||(t=!0,m--,queueMicrotask(()=>{m||k||(k=!0,g++,n?.dispose(),n=void 0,w.clear())}))}},removed:b,async join(e,o){if("entry"!==a.phase||!a.invitation||k)throw new Error("No active invitation");if(!o)throw new Error("Peer identity is not ready");let r=g,i=await v.joinOrRequestAdmission(a.invitation,e,o);if(!k&&r===g){if("admission"in i)return localStorage.setItem(`popmelt-admission:${t.projectId}`,JSON.stringify({name:i.admission.name,receipt:o,colorIdentity:o})),void I({phase:"entry",invitation:null});await R(i.joined.credential,r)}},admit:t=>R(t)}}function X({config:r,loadOwnSource:s,children:p}){let[h]=S(()=>O(r,s)),u=a(),d=v(h.subscribe,h.getSnapshot,h.getSnapshot);I(()=>h.retain(),[h]);let[f,X,H]=k(),R="connected"===d.phase?d.connection:null;if(I(()=>{if(!R||!r.planeApps)return;let t,i=new AbortController,n=R.isHost&&!y(r.url)&&"/"===c(location.pathname),a=n?void 0:r.appVersion,s=async()=>{try{let t=await e(R.credential,R.credential.participantId,i.signal,location.pathname);if(n&&"/"!==t.application.basePath)throw new Error("Host checkout unavailable");let s=o(t.application);if(a??(a=t.application.version),!i.signal.aborted&&(s!==l(location.pathname)||t.application.version!==a)){if(R.isHost&&!y(r.url)){let t=await fetch(s+location.search,{method:"HEAD",headers:{Accept:"text/html"},mode:"same-origin",cache:"no-store",signal:i.signal});if(!t.ok||!t.headers.get("content-type")?.includes("text/html")||l(new URL(t.url).pathname)!==s)throw new Error("Host plane document unavailable")}return await R.state.flush(),void(i.signal.aborted||(s===l(location.pathname)?location.reload():location.replace(s+location.search+location.hash)))}}catch{}i.signal.aborted||(t=setTimeout(s,1500))};return s(),()=>{i.abort(),clearTimeout(t)}},[r.planeApps,r.appVersion,r.url,R,u]),R)return P(t,{connection:R,codePreviewUrl:location.href,planeApps:r.planeApps,onAccessRemoved:h.removed,children:p});let b="starting"===d.phase||"error"===d.phase,U="entry"===d.phase?d.invitation:null;return P(n,{children:P("div",{"data-devtools":"participant-entry",style:{display:"contents",pointerEvents:"auto"},children:b?P(i,{entry:{theme:f,themePreference:H,onThemePreferenceChange:X,ariaLabel:"starting"===d.phase?"Popmelt connecting":"Popmelt disconnected",action:null,logoOnly:!0,connected:!1,connection:A("span",{"data-popmelt-entry-content":!0,role:"status",style:{...j(g[f],!1),cursor:"default"},children:[P(w,{size:14,strokeWidth:1.5,"aria-hidden":"true"}),"starting"===d.phase?"Connecting…":"Disconnected"]})}}):P(m,{showHostLinkHelp:window.top===window&&["localhost","127.0.0.1","[::1]"].includes(location.hostname)&&!y(r.url)&&"/"===c(location.pathname),client:h.client,storage:localStorage,storageKey:`popmelt-admission:${r.projectId}`,theme:f,themePreference:H,onThemePreferenceChange:X,onAdmitted:h.admit,onJoin:U?h.join:void 0},U??"request-access")})})}export{X as default};
|
package/dist/bridge-entry.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{O as o,b as s,c as e}from"./chunk-
|
|
1
|
+
import{O as o,b as s,c as e}from"./chunk-VG4ZV2OT.mjs";import"./chunk-PYGRFSUU.mjs";import"./chunk-6EO73WJN.mjs";import"./chunk-EFWBHWHP.mjs";import"./chunk-TSQEBZYO.mjs";import"./chunk-UTP56NCY.mjs";import"./chunk-GLF7Z5IR.mjs";import"./chunk-YMWXWXPV.mjs";import"./chunk-KF73S7MG.mjs";var r=parseInt(process.env.POPMELT_PORT||"1111",10),t=process.env.POPMELT_PROJECT_ROOT||process.cwd(),c=process.env.POPMELT_DEV_ORIGIN||void 0,p=process.env.POPMELT_COPILOT_PATH||void 0,i=process.env.POPMELT_CDP_URL||void 0;(async function(){let n=await o({port:r,projectRoot:t,devOrigin:c,copilotPath:p,cursorPath:process.env.POPMELT_CURSOR_PATH||void 0,opencodePath:process.env.POPMELT_OPENCODE_PATH||void 0,nativeCaptureUrl:i,restartMode:"detached"}),P={pid:process.pid,port:n.port,startedAt:Date.now()};await s(t,P),await new Promise(o=>{let s=!1,r=async()=>{s||(s=!0,await n.close(),await e(t,P),o(),process.exit(0))};process.on("SIGTERM",r),process.on("SIGINT",r)})})().catch(o=>{console.error("[popmelt bridge-entry] Fatal:",o),process.exit(1)});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{b as m,a as r}from"./chunk-
|
|
1
|
+
"use client";import{b as m,a as r}from"./chunk-2IWVTTYX.mjs";import"./chunk-5F34UIKL.mjs";import"./chunk-WC7B5NU3.mjs";import"./chunk-ZHXTB5IN.mjs";import"./chunk-FYURSPM3.mjs";import"./chunk-43BZCDGL.mjs";import"./chunk-PH2MLB3T.mjs";import"./chunk-ELKVFX2O.mjs";import"./chunk-AWWUJO3N.mjs";import"./chunk-Q6N77LIS.mjs";import"./chunk-ZVDKW7TO.mjs";import"./chunk-XTOCFTVW.mjs";import"./chunk-Q74FBX2I.mjs";import"./chunk-KHDXOXYF.mjs";import"./chunk-SOGN7S54.mjs";import"./chunk-BJUSVIDN.mjs";import"./chunk-KCDHP4N3.mjs";import"./chunk-BOZVNUHJ.mjs";import"./chunk-OVZ4CQGM.mjs";import"./chunk-WIJSWSNF.mjs";import"./chunk-JAMYVQFC.mjs";import"./chunk-FHCKFQBY.mjs";import"./chunk-APP5IYTE.mjs";import"./chunk-W62YY5IT.mjs";import"./chunk-G6BN5TAZ.mjs";import"./chunk-B3RA4XAR.mjs";import"./chunk-DBCBG5J6.mjs";import"./chunk-G2ZHJXHZ.mjs";import"./chunk-TMSGNHXH.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-3LZQLRZ2.mjs";import"./chunk-RJWFSAKE.mjs";import"./chunk-P2WAXWAZ.mjs";import"./chunk-2F2BVGFH.mjs";import"./chunk-RWZ7SVMO.mjs";import"./chunk-RK6UROPO.mjs";import"./chunk-5IZHN3A7.mjs";import"./chunk-AOTDTBQO.mjs";import"./chunk-HAZXZ5TU.mjs";import"./chunk-TVIKC33M.mjs";import"./chunk-25EXQOPI.mjs";import"./chunk-VXRRHXUP.mjs";import"./chunk-WP2SHSCG.mjs";import"./chunk-AAMUU2QA.mjs";import"./chunk-LH7HKUCK.mjs";import"./chunk-QQPUMPKU.mjs";import"./chunk-X6I6KQDG.mjs";import"./chunk-ATLUO4G7.mjs";import"./chunk-JJRKR4X3.mjs";import"./chunk-C2ZSNUXQ.mjs";import"./chunk-TEXVTTWA.mjs";import"./chunk-Q6C7ZA3H.mjs";import"./chunk-EILBHZDX.mjs";import"./chunk-XJJDBMZI.mjs";import"./chunk-OREALBUO.mjs";import"./chunk-B4DYUYX4.mjs";import"./chunk-CK3CDA3L.mjs";import"./chunk-WJVRGXOS.mjs";import"./chunk-BEGAJYOY.mjs";import"./chunk-AGCS65LT.mjs";import"./chunk-OA63PYHZ.mjs";import"./chunk-6RMM7JB6.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-N2ZEZCHO.mjs";import"./chunk-J3UIBBU2.mjs";import"./chunk-PRPXMDZ7.mjs";import"./chunk-A4GARXVQ.mjs";import"./chunk-YGP6PPOZ.mjs";import{createElement as t}from"react";import{createRoot as o}from"react-dom/client";function n(n,u){let i=o(n);return i.render(t(m,u)),()=>{i.unmount(),r()}}export{n as mountBrowserRuntime};
|
package/dist/browser.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";export{a as isPopmeltPreview}from"./chunk-KCDHP4N3.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-YGP6PPOZ.mjs";var t={unmount(){}};async function e(e={}){if(!e.enabled||typeof document>"u")return t;if(document.querySelector("[data-popmelt-browser-host], [data-popmelt-top-layer-host]"))throw new Error("Popmelt is already mounted. Unmount it before mounting again.");let o=document.createElement("div");o.setAttribute("data-popmelt-browser-host",""),o.setAttribute("data-devtools",""),document.documentElement.appendChild(o);let r=[["__POPMELT_PROJECT_ID__",e.projectId],["__POPMELT_BRIDGE_URL__",e.bridgeUrl]].flatMap(([t,e])=>{if(void 0===e)return[];let o=Object.prototype.hasOwnProperty.call(window,t),r=window[t],n=e??void 0;return window[t]=n,[()=>{window[t]===n&&(o?window[t]=r:delete window[t])}]}),n=()=>{o.remove();for(let t of r)t()};try{let{mountBrowserRuntime:t}=await(import("./browser-runtime-
|
|
1
|
+
"use client";export{a as isPopmeltPreview}from"./chunk-KCDHP4N3.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-YGP6PPOZ.mjs";var t={unmount(){}};async function e(e={}){if(!e.enabled||typeof document>"u")return t;if(document.querySelector("[data-popmelt-browser-host], [data-popmelt-top-layer-host]"))throw new Error("Popmelt is already mounted. Unmount it before mounting again.");let o=document.createElement("div");o.setAttribute("data-popmelt-browser-host",""),o.setAttribute("data-devtools",""),document.documentElement.appendChild(o);let r=[["__POPMELT_PROJECT_ID__",e.projectId],["__POPMELT_BRIDGE_URL__",e.bridgeUrl]].flatMap(([t,e])=>{if(void 0===e)return[];let o=Object.prototype.hasOwnProperty.call(window,t),r=window[t],n=e??void 0;return window[t]=n,[()=>{window[t]===n&&(o?window[t]=r:delete window[t])}]}),n=()=>{o.remove();for(let t of r)t()};try{let{mountBrowserRuntime:t}=await(import("./browser-runtime-Q26JF5EA.mjs"));if(!o.isConnected)throw new Error("Popmelt mount was removed before startup.");let r=t(o,e),m=!0;return{unmount(){if(m){m=!1;try{r()}finally{n()}}}}}catch(t){throw n(),t}}export{e as mountPopmelt};
|