@popmelt.com/core 0.41.0 → 0.41.2

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 (105) hide show
  1. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  2. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  3. package/codex-plugin/assets/popmelt-logo.svg +1 -1
  4. package/dist/{ExploreAttachment-ALV7FL3Y.mjs → ExploreAttachment-GTHGWP6E.mjs} +1 -1
  5. package/dist/PagePreviewLayer-FHYXOFOZ.mjs +1 -0
  6. package/dist/{ParticipantRuntime-CBUA7BL5.mjs → ParticipantRuntime-NY7N7HFZ.mjs} +1 -1
  7. package/dist/PhoneHostGate-RXW6DVQD.mjs +1 -0
  8. package/dist/{PopmeltTasteConnectedPane-PD64Q6LF.mjs → PopmeltTasteConnectedPane-6T3F6ZNL.mjs} +1 -1
  9. package/dist/{QueuedReplies-ESF5UL3J.mjs → QueuedReplies-U7GLT6QK.mjs} +1 -1
  10. package/dist/{SamplePlacementOverlay-V533Y4XN.mjs → SamplePlacementOverlay-K3Z5C67A.mjs} +1 -1
  11. package/dist/{ShareProjectPane-PMODH6QQ.mjs → ShareProjectPane-AFQS4SEM.mjs} +1 -1
  12. package/dist/{SuppliedContext-ADMN2D2I.mjs → SuppliedContext-V62BO3EY.mjs} +1 -1
  13. package/dist/ThreadErrorCard-L7F7VX6H.mjs +1 -0
  14. package/dist/ThreadPanel-ZXEPKB2P.mjs +1 -0
  15. package/dist/bridge-entry.mjs +1 -1
  16. package/dist/{bridgeSSEStream-2KKFO64A.mjs → bridgeSSEStream-AUMOLOCC.mjs} +1 -1
  17. package/dist/{bridgeWebSocketStream-XTHQPBPI.mjs → bridgeWebSocketStream-PE5XBFAM.mjs} +1 -1
  18. package/dist/{browser-runtime-FUXWVGQ7.mjs → browser-runtime-FFURXKEP.mjs} +1 -1
  19. package/dist/browser.mjs +1 -1
  20. package/dist/canvas-chat-note-RGALD6IH.mjs +1 -0
  21. package/dist/{checkFixture-42NYMFAK.mjs → checkFixture-ZD5UD7OR.mjs} +1 -1
  22. package/dist/chunk-2B62TYAL.mjs +1 -0
  23. package/dist/{chunk-VJKC2RJB.mjs → chunk-2EQSGPAN.mjs} +1 -1
  24. package/dist/{chunk-S2U2IGUO.mjs → chunk-2IPPW6IP.mjs} +1 -1
  25. package/dist/chunk-3IS5RGG6.mjs +1 -0
  26. package/dist/{chunk-LDDDSIAQ.mjs → chunk-44KCB7YO.mjs} +1 -1
  27. package/dist/{chunk-WSI2SQWU.mjs → chunk-4O6YFMWF.mjs} +1 -1
  28. package/dist/chunk-4XBW5E6L.mjs +1 -0
  29. package/dist/chunk-5GQXAV54.mjs +30 -0
  30. package/dist/{chunk-YHCZYT4T.mjs → chunk-63F7KX4E.mjs} +1 -1
  31. package/dist/{chunk-YG3RSK5J.mjs → chunk-6VZCE37E.mjs} +1 -1
  32. package/dist/{chunk-W5TNOJOR.mjs → chunk-72CUIZA2.mjs} +1 -1
  33. package/dist/chunk-7NXVLIDS.mjs +1 -0
  34. package/dist/{chunk-776SEJZO.mjs → chunk-7XGXFP5L.mjs} +1 -1
  35. package/dist/{chunk-SZQTGYPS.mjs → chunk-B5NNYNRA.mjs} +1 -1
  36. package/dist/{chunk-XHTSKQMB.mjs → chunk-BDSIJTX5.mjs} +1 -1
  37. package/dist/{chunk-S7IWZSWH.mjs → chunk-BWBGZZG7.mjs} +1 -1
  38. package/dist/{chunk-GE5BE6PI.mjs → chunk-DLXTHDBS.mjs} +1 -1
  39. package/dist/{chunk-HFKGW34E.mjs → chunk-EKRMVMQ4.mjs} +1 -1
  40. package/dist/{chunk-Z4NMA34Y.mjs → chunk-EO3SHOXX.mjs} +1 -1
  41. package/dist/chunk-FLHUSWSY.mjs +1 -0
  42. package/dist/{chunk-FZUHHJWW.mjs → chunk-FQRYGTZ3.mjs} +1 -1
  43. package/dist/{chunk-5TCWBNV4.mjs → chunk-JXXK3Z5E.mjs} +1 -1
  44. package/dist/{chunk-RFTQCRGC.mjs → chunk-KNMBEVHX.mjs} +1 -1
  45. package/dist/{chunk-DMKBAI2Z.mjs → chunk-KYOD2RVN.mjs} +1 -1
  46. package/dist/chunk-MBEFYXSZ.mjs +1 -0
  47. package/dist/{chunk-DDUXU6LA.mjs → chunk-OTMGCIRL.mjs} +1 -1
  48. package/dist/{chunk-VSWRWS2H.mjs → chunk-P5ESNJTD.mjs} +1 -1
  49. package/dist/chunk-QRFIQC2P.mjs +1 -0
  50. package/dist/{chunk-7D4BUDKG.mjs → chunk-SHYAV76M.mjs} +1 -1
  51. package/dist/chunk-TMW3SI7F.mjs +1 -0
  52. package/dist/chunk-TNVYP6S4.mjs +1 -0
  53. package/dist/chunk-UNUYNWTJ.mjs +1 -0
  54. package/dist/chunk-VTOLKIBD.mjs +1 -0
  55. package/dist/chunk-WMCWSV2W.mjs +1 -0
  56. package/dist/chunk-WVGFWHL3.mjs +1 -0
  57. package/dist/{chunk-XGSOAF5E.mjs → chunk-YIKAZQRM.mjs} +1 -1
  58. package/dist/{chunk-ULR4IDEX.mjs → chunk-YU5PF45T.mjs} +1 -1
  59. package/dist/cli.mjs +1 -1
  60. package/dist/codex-note-context-ECY4QU74.mjs +1 -0
  61. package/dist/codex-project-J7C4YAM2.mjs +1 -0
  62. package/dist/{codex-store-mount-KFJYT6AS.mjs → codex-store-mount-FPS3CDO4.mjs} +1 -1
  63. package/dist/dev-server-5CHO7PTQ.mjs +1 -0
  64. package/dist/guest-admission.mjs +1 -1
  65. package/dist/guest-live-canvas.mjs +1 -1
  66. package/dist/index.mjs +1 -1
  67. package/dist/{page-interaction-74JGNCZ5.mjs → page-interaction-ZXM6ZLL4.mjs} +1 -1
  68. package/dist/peer-client-4WNS5XZ4.mjs +1 -0
  69. package/dist/plugin-astro.mjs +1 -1
  70. package/dist/plugin-nuxt.mjs +1 -1
  71. package/dist/plugin-vite.mjs +1 -1
  72. package/dist/provider-setup.mjs +1 -0
  73. package/dist/server.mjs +1 -1
  74. package/dist/shared-page-3AVCYUOT.mjs +1 -0
  75. package/dist/thread-errors.mjs +1 -0
  76. package/infra/phone-pairing/app-listener.cjs +13 -4
  77. package/infra/phone-pairing/machine-service.mjs +8 -0
  78. package/infra/phone-pairing/vite-hmr.cjs +17 -0
  79. package/infra/phone-pairing/vite-hmr.mjs +99 -0
  80. package/package.json +3 -1
  81. package/dist/PagePreviewLayer-UPCGG4EV.mjs +0 -1
  82. package/dist/PhoneHostGate-TVNOJYL5.mjs +0 -1
  83. package/dist/ThreadErrorCard-KS2XWRT3.mjs +0 -1
  84. package/dist/ThreadPanel-5TDPZBAU.mjs +0 -1
  85. package/dist/canvas-chat-note-XMVKWL2J.mjs +0 -1
  86. package/dist/chunk-2TA7N3CI.mjs +0 -1
  87. package/dist/chunk-3HVPVKWV.mjs +0 -1
  88. package/dist/chunk-4RQ5XD3I.mjs +0 -1
  89. package/dist/chunk-AOFKEBLN.mjs +0 -1
  90. package/dist/chunk-GLIGPLM4.mjs +0 -1
  91. package/dist/chunk-HFWGYXPG.mjs +0 -1
  92. package/dist/chunk-HM6EBJVO.mjs +0 -1
  93. package/dist/chunk-ITLRSHNZ.mjs +0 -1
  94. package/dist/chunk-OEJXPUAR.mjs +0 -1
  95. package/dist/chunk-PTMHSMZH.mjs +0 -1
  96. package/dist/chunk-SOFNYBJD.mjs +0 -1
  97. package/dist/chunk-TA2BMDSC.mjs +0 -30
  98. package/dist/chunk-XDZUDDYB.mjs +0 -1
  99. package/dist/chunk-ZXCAONMC.mjs +0 -1
  100. package/dist/codex-note-context-WX33QFE7.mjs +0 -1
  101. package/dist/codex-project-77GHT2I3.mjs +0 -1
  102. package/dist/dev-server-FZJ6HDKP.mjs +0 -1
  103. package/dist/peer-client-B2KMU667.mjs +0 -1
  104. package/dist/shared-page-6AUYAPJ3.mjs +0 -1
  105. /package/dist/{chunk-WWNI7JCA.mjs → chunk-RG2CK6VE.mjs} +0 -0
@@ -1 +1 @@
1
- import{a as e,b as t,c as r}from"./chunk-VJKC2RJB.mjs";import"./chunk-PCUUOIFD.mjs";import{a,b as i}from"./chunk-YHCZYT4T.mjs";import{a as n}from"./chunk-ITLRSHNZ.mjs";import{b as s}from"./chunk-HKHZBKAN.mjs";import"./chunk-CIKFUS7J.mjs";import"./chunk-GLF7Z5IR.mjs";import"./chunk-KD2AOPYP.mjs";import"./chunk-KF73S7MG.mjs";import{execFile as o}from"child_process";import{createHash as l,randomBytes as c}from"crypto";import{mkdir as p,mkdtemp as u,readFile as f,readdir as m,realpath as d,rm as h,stat as g}from"fs/promises";import{extname as w,join as y,relative as v,resolve as b,sep as x}from"path";import{promisify as S}from"util";import{parse as E,serialize as R}from"parse5";var j=S(o),N=33554432,L=(e,t)=>e.attrs.find(e=>e.name===t)?.value;async function k(o,S,k,A,P){let T=async(e,t,r)=>{let n=new URL(k,t),o=await fetch(n,{redirect:"manual",headers:{Accept:"text/html"},signal:AbortSignal.timeout(15e3)});if(200!==o.status||!o.headers.get("content-type")?.includes("text/html"))throw await(o.body?.cancel()),Error("Page unavailable");return async function(e,t,r,n,o){let p=c(18).toString("base64"),u=Buffer.byteLength(r);if(u>N)throw Error("Shared page exceeds the preview size limit");async function h(r,a,s){let l=new URL(r,a);if(l.origin!==t.origin||l.username||l.password)return;let c=decodeURIComponent(l.pathname);if(c.split("/").some(e=>e.startsWith(".")||"node_modules"===e)||/[\\%?#]/.test(c)||i(c)||!s.has(w(c).toLowerCase()))return;let p="next"===n&&c.startsWith("/_next/static/"),m=p?y(e,".next","static"):o,h=b(m,"."+(p?c.slice(13):c));if(h.startsWith(m+x))try{if(await d(h)!==h)return;let e=await g(h);if(!e.isFile()||e.size>N-u)throw Error("Shared page exceeds the preview size limit");return u+=e.size,{data:await f(h),url:l}}catch(e){if("ENOENT"!==e.code)throw e}}let v=new Set(Object.keys(a).filter(e=>".css"!==e)),S=new Set,j=Object.create(null),k=async(e,r)=>{if(e.startsWith("data:"))return e;let i=new URL(e,r);if(i.origin===t.origin&&j[i.pathname])return j[i.pathname];let n=await h(e,r,v),s=n?"data:"+a[w(n.url.pathname).toLowerCase()]+";base64,"+n.data.toString("base64"):"";return s.startsWith("data:image/")&&(j[i.pathname]=s),s};async function A(e,t){let r=/url\(\s*(['"]?)([^)'"]+)\1\s*\)/gi,a=0,i="";for(let n of e.matchAll(r))n[2].startsWith("#")||(i+=e.slice(a,n.index)+"url("+JSON.stringify(await k(n[2].trim(),t))+")",a=n.index+n[0].length);return i+e.slice(a)}let P=E(r);function T(e,t){e.childNodes=[{nodeName:"#text",value:t,parentNode:e}]}let _=new Set,I=new Set,U=new Set,H=new Set([".js",".mjs"]);function z(e){_.add(e.url.pathname);let t=e.data.toString();for(let e of t.matchAll(/["'](\/(?:[A-Za-z0-9_.%~-]+\/)*[A-Za-z0-9_.%~-]+\.(?:png|jpe?g|gif|webp|avif|svg|ico))["']/gi))S.add(e[1]);for(let e of t.matchAll(/["'](?:\/_next\/)?(static\/chunks\/[\w./%-]+\.js)["']/g))I.add("/_next/"+e[1]);for(let e of t.matchAll(/\b[\w$]+\.e\((\d+)\)/g))U.add(e[1]);return('if(document.currentScript)document.currentScript.setAttribute("src",'+JSON.stringify(e.url.pathname).replace(/</g,"\\u003c")+");\n"+t).replace(/<\/script/gi,"<\\/script")}let D=function(e,t){let r="popmelt-module:/",a=new Map,i=new Map,n=new Map,s=new Map;function o(t,r){if(r&&"object"==typeof r)for(let[a,i]of Object.entries(r)){let r=/^(?:\.{0,2}\/|https?:)/.test(a)?new URL(a,e).href:a;t.has(r)||t.set(r,"string"==typeof i?new URL(i,e).href:null)}}function l(e,t){if(e.has(t))return e.get(t);let r=[...e.keys()].filter(e=>e.endsWith("/")&&t.startsWith(e)).sort((e,t)=>t.length-e.length)[0];if(r){let a=e.get(r);return a?.endsWith("/")?a+t.slice(r.length):null}}function c(t){let i=new URL(t,e).href,n=a.get(i)??"entry-"+a.size;return a.set(i,n),r+n+".js"}return{entry:c,importMap(t){let r=JSON.parse(t);o(n,r.imports);for(let[t,a]of Object.entries(r.scopes??{})){let r=new URL(t,e).href,i=s.get(r)??new Map;o(i,a),s.set(r,i)}},inline(t){let r=new URL(e);return r.hash="inline-"+i.size,i.set(r.href,t),c(r.href)},async compile(){if(!a.size)return;let o={name:"invited-page-modules",setup(r){r.onResolve({filter:/.*/},t=>{let r,a=t.importer||e.href,i=/^(?:\.{0,2}\/|https?:\/\/)/.test(t.path),o=i?new URL(t.path,a).href:t.path;if("entry-point"!==t.kind){for(let e of[...s.keys()].filter(e=>a===e||e.endsWith("/")&&a.startsWith(e)).sort((e,t)=>t.length-e.length))if(r=l(s.get(e),o),void 0!==r)break;void 0===r&&(r=l(n,o))}if(null===r||!i&&!r)return{external:!0};let c=new URL(r??o);return c.origin!==e.origin?{path:c.href,external:!0}:{path:c.href,namespace:"page"}}),r.onLoad({filter:/.*/,namespace:"page"},async({path:r})=>{let a=i.get(r)??(await t(r,e))?.data.toString();if(void 0===a)throw new Error("Invited page module unavailable");return{contents:a,loader:"js"}})}},{build:c}=await(import("esbuild")),p=await c({entryPoints:[...a].map(([e,t])=>({in:e,out:t})),bundle:!0,splitting:!0,format:"esm",platform:"browser",publicPath:r,write:!1,outdir:"/",logLevel:"silent",legalComments:"none",minify:!0,plugins:[o]});return Object.fromEntries(p.outputFiles.map(e=>[r+e.path.split(/[\\/]/).pop(),"data:text/javascript;base64,"+Buffer.from(e.contents).toString("base64")]))}}}(t,(e,t)=>h(e,t,H)),W=new Set;await async function e(r){let a=[];for(let i of r.childNodes){if("tagName"in i){let r=i.tagName;if(["base","iframe","frame","embed","object"].includes(r)||"meta"===r&&L(i,"http-equiv"))continue;if("html"===n)for(let e of i.attrs)/^on[a-z]+$/.test(e.name)&&W.add("'sha256-"+l("sha256").update(e.value).digest("base64")+"'");if("astro"===n&&"astro-island"===r)for(let e of i.attrs)["component-url","renderer-url","before-hydration-url"].includes(e.name)&&e.value&&(e.value=D.entry(e.value));if("script"===r){let e=()=>i.childNodes.map(e=>"value"in e?e.value:"").join("");if("next"!==n&&"importmap"===L(i,"type")){D.importMap(e());continue}let r,a=L(i,"src");if("next"!==n&&"module"===L(i,"type")){let t=a?D.entry(a):D.inline(e());T(i,"import "+JSON.stringify(t)+";")}else if(a){if(void 0!==L(i,"nomodule"))continue;let e=await h(a,t,H);if(!e)continue;"next"===n?T(i,z(e)):r="data:text/javascript;base64,"+e.data.toString("base64")}i.attrs=i.attrs.filter(e=>["type","id","async","defer"].includes(e.name)||e.name.startsWith("data-")),r&&i.attrs.push({name:"src",value:r}),i.attrs.push({name:"nonce",value:p})}else if("link"===r){if("stylesheet"!==L(i,"rel"))continue;let e=await h(L(i,"href")??"",t,new Set([".css"]));if(!e)continue;i.tagName=i.nodeName="style",i.attrs=[],T(i,(await A(e.data.toString(),e.url)).replace(/<\/style/gi,"<\\/style"))}else if("style"===r)for(let e of i.childNodes)"value"in e&&(e.value=(await A(e.value,t)).replace(/<\/style/gi,"<\\/style"));else if("img"===r){let e=L(i,"src")??"";e.startsWith("/_next/image?")&&(e=new URL(e,t).searchParams.get("url")??""),i.attrs=i.attrs.filter(e=>"src"!==e.name&&"srcset"!==e.name),e&&(await k(e,t),i.attrs.push({name:"src",value:e}))}await e(i)}a.push(i)}r.childNodes=a}(P);let F=[],J=await D.compile();J&&F.push('<script type="importmap" nonce="'+p+'">'+JSON.stringify({imports:J})+"<\/script>");let B=U.size?await m(y(e,".next","static","chunks")):[],C=new Map;for(let e of B){let t=/^(\d+)[.-][\w.-]+\.js$/.exec(e);if(t){let r=t[1],a=C.get(r)??[];a.push("/_next/static/chunks/"+e),C.set(r,a)}}let q=()=>{for(let e of U)for(let t of C.get(e)??[])I.add(t);U.clear()};q();for(let e of I){if(_.has(e))continue;let r=await h(e,t,H);r&&F.push('<script nonce="'+p+'">'+z(r)+"<\/script>"),q()}for(let e of S)await k(e,t);let K="("+O.toString()+")("+JSON.stringify(j).replace(/</g,"\\u003c")+","+JSON.stringify(t.pathname).replace(/</g,"\\u003c")+");",Y=Buffer.from(await s("live-canvas")).toString().replace(/<\/script/gi,"<\\/script");return{body:R(P).replace(/<head(?: [^>]*)?>/i,e=>e+'<meta name="popmelt-live-canvas" content="1"><script nonce="'+p+'">('+M.toString()+")();"+K+"\n"+Y+"<\/script>"+F.join("")),policy:"sandbox allow-scripts; default-src 'none'; script-src 'nonce-"+p+"'"+(J?" data:":"")+(W.size?"; script-src-attr 'unsafe-hashes' "+[...W].join(" "):"")+"; style-src 'unsafe-inline'; img-src data:; font-src data:; connect-src 'none'; form-action 'none'; base-uri 'none'; frame-ancestors 'self'"}}(e,n,await o.text(),A,r)};if("html"===A){let e=await r(o,A,o,void 0,{});try{return await T(o,e.origin,o)}finally{await e.close()}}let _=y(o,".popmelt");await p(_,{recursive:!0});let I,U=await u(y(_,"interact-"));try{let a=await(await n(o,U)).capture(),i=async e=>(await j("git",e,{cwd:o,env:{...process.env,GIT_INDEX_FILE:y(U,"index")}})).stdout.trim(),s=await i(["rev-parse","--show-toplevel"]),l=y(U,"checkout");await j("git",["init","--quiet","--template=",l]),await i(["read-tree",a]),await i(["-C",s,"checkout-index","--all","--prefix="+l+x]);let c=y(l,v(s,o)),{cli:p}=await t(o,A),u="next"===A?await e(S):{},f="nuxt"===A?["--input-type=module","-e","\nimport { loadNuxt, buildNuxt } from 'nuxt/kit';\nimport { createRequire } from 'node:module';\nimport { writeFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nconst require = createRequire(import.meta.url);\nconst routerPath = createRequire(require.resolve('nuxt/package.json')).resolve('vue-router');\nconst { createMemoryHistory, createRouter } = await import(routerPath);\nconst route = process.argv[1];\nconst options = resolve('.popmelt-router.mjs');\nawait writeFile(options, 'import { createMemoryHistory } from ' + JSON.stringify(routerPath) +\n ';export default { history: () => createMemoryHistory() };');\nconst nuxt = await loadNuxt({ cwd: process.cwd(), dev: false, overrides: {\n nitro: { preset: 'node-server' }, experimental: { appManifest: false, payloadExtraction: false },\n vite: { build: { modulePreload: false } },\n hooks: {\n 'pages:routerOptions'({files}) { files.push({path: options}); },\n 'pages:resolved'(pages) {\n if (!pages.length) return;\n const record = page => ({ path: page.path, alias: page.alias ?? [],\n component: {}, meta: { page }, children: (page.children || []).map(record) });\n const router = createRouter({ history: createMemoryHistory(), routes: pages.map(record) });\n const selected = new Set(router.resolve(route).matched.map(r => r.meta.page));\n const trim = list => {\n for (let i = list.length - 1; i >= 0; i--) {\n const page = list[i];\n if (!selected.has(page)) list.splice(i, 1);\n else if (page.children) trim(page.children);\n }\n };\n trim(pages);\n },\n },\n}});\ntry { await buildNuxt(nuxt); } finally { await nuxt.close(); }\n",k]:[p,"build",..."next"===A?[...P?[P]:[],"--experimental-build-mode","compile"]:[]];await j(process.execPath,f,{cwd:c,timeout:18e4,maxBuffer:8388608,env:{...u,PATH:process.env.PATH,HOME:process.env.HOME,TMPDIR:process.env.TMPDIR,SystemRoot:process.env.SystemRoot,CI:"1",NODE_ENV:"production",NEXT_TELEMETRY_DISABLED:"1",ASTRO_TELEMETRY_DISABLED:"1",NUXT_TELEMETRY_DISABLED:"1",POPMELT_PLANE_RENDERER:"1"}}),I=await r(c,A,s,void 0,u,!0);let m=y(c,"nuxt"===A?".output/public":"astro"===A?(await g(y(c,"dist/client")).catch(()=>{}))?.isDirectory()?"dist/client":"dist":"public");return await T(c,I.origin,m)}finally{try{await(I?.close())}finally{await h(U,{recursive:!0,force:!0,maxRetries:3})}}}function M(){Object.defineProperty(navigator,"locks",{value:void 0});let e=new Map;Object.defineProperty(document,"cookie",{get:()=>Array.from(e,([e,t])=>e+"="+t).join("; "),set:t=>{let[r,...a]=String(t).split(";"),i=r.indexOf("=");if(i<1)return;let n=r.slice(0,i).trim();a.some(e=>/^\s*max-age=0\s*$/i.test(e))?e.delete(n):e.set(n,r.slice(i+1))}});for(let e of["localStorage","sessionStorage"]){let t=new Map;Object.defineProperty(window,e,{value:{get length(){return t.size},key:e=>Array.from(t.keys())[e]??null,getItem:e=>t.get(String(e))??null,setItem:(e,r)=>{t.set(String(e),String(r))},removeItem:e=>{t.delete(String(e))},clear:()=>t.clear()}})}}function O(e,t){let r=new URL(t,location.href);function a(t){if(t&&!t.startsWith("data:"))try{let a=new URL(t,r);if(a.origin!==r.origin)return;if("/_next/image"===a.pathname&&(a=new URL(a.searchParams.get("url")??"",r)),a.origin===r.origin)return e[a.pathname]}catch{}}function i(e){if(e instanceof HTMLImageElement){let t=a(e.getAttribute("src")??"");t&&(e.removeAttribute("srcset"),e.src=t)}else if(e instanceof HTMLVideoElement){let t=a(e.getAttribute("poster")??"");t&&(e.poster=t)}}new MutationObserver(e=>{for(let t of e)if("attributes"===t.type)i(t.target);else for(let e of t.addedNodes)e instanceof Element&&(i(e),e.querySelectorAll("img,video[poster]").forEach(i))}).observe(document,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["src","poster","srcset"]})}function A(e,t,r,a){let i,n="";return async(s,o)=>{let l=o+"\n"+s;for(;i&&n!==l;){let e=i;await e.catch(()=>{}),i===e&&(i=void 0)}if(!i||n!==l){n=l;let o=k(e,t,s,r,a);i=o,o.catch(()=>{i===o&&(i=void 0)})}return i}}export{A as pageInteraction};
1
+ import{a as e,b as t,c as r}from"./chunk-2EQSGPAN.mjs";import"./chunk-PCUUOIFD.mjs";import{a,b as i}from"./chunk-63F7KX4E.mjs";import{a as n}from"./chunk-WVGFWHL3.mjs";import{b as s}from"./chunk-HKHZBKAN.mjs";import"./chunk-CIKFUS7J.mjs";import"./chunk-GLF7Z5IR.mjs";import"./chunk-KD2AOPYP.mjs";import"./chunk-KF73S7MG.mjs";import{execFile as o}from"child_process";import{createHash as l,randomBytes as c}from"crypto";import{mkdir as p,mkdtemp as u,readFile as f,readdir as m,realpath as d,rm as h,stat as g}from"fs/promises";import{extname as w,join as y,relative as v,resolve as b,sep as x}from"path";import{promisify as S}from"util";import{parse as E,serialize as j}from"parse5";var N=S(o),R=33554432,L=(e,t)=>e.attrs.find(e=>e.name===t)?.value;async function k(o,S,k,A,P){let _=async(e,t,r)=>{let n=new URL(k,t),o=await fetch(n,{redirect:"manual",headers:{Accept:"text/html"},signal:AbortSignal.timeout(15e3)});if(200!==o.status||!o.headers.get("content-type")?.includes("text/html"))throw await(o.body?.cancel()),Error("Page unavailable");return async function(e,t,r,n,o){let p=c(18).toString("base64"),u=Buffer.byteLength(r);if(u>R)throw Error("Shared page exceeds the preview size limit");async function h(r,a,s){let l=new URL(r,a);if(l.origin!==t.origin||l.username||l.password)return;let c=decodeURIComponent(l.pathname);if(c.split("/").some(e=>e.startsWith(".")||"node_modules"===e)||/[\\%?#]/.test(c)||i(c)||!s.has(w(c).toLowerCase()))return;let p="next"===n&&c.startsWith("/_next/static/"),m=p?y(e,".next","static"):o,h=b(m,"."+(p?c.slice(13):c));if(h.startsWith(m+x))try{if(await d(h)!==h)return;let e=await g(h);if(!e.isFile()||e.size>R-u)throw Error("Shared page exceeds the preview size limit");return u+=e.size,{data:await f(h),url:l}}catch(e){if("ENOENT"!==e.code)throw e}}let v=new Set(Object.keys(a).filter(e=>".css"!==e)),S=new Set,N=Object.create(null),k=async(e,r)=>{if(e.startsWith("data:"))return e;let i=new URL(e,r);if(i.origin===t.origin&&N[i.pathname])return N[i.pathname];let n=await h(e,r,v),s=n?"data:"+a[w(n.url.pathname).toLowerCase()]+";base64,"+n.data.toString("base64"):"";return s.startsWith("data:image/")&&(N[i.pathname]=s),s};async function A(e,t){let r=/url\(\s*(['"]?)([^)'"]+)\1\s*\)/gi,a=0,i="";for(let n of e.matchAll(r))n[2].startsWith("#")||(i+=e.slice(a,n.index)+"url("+JSON.stringify(await k(n[2].trim(),t))+")",a=n.index+n[0].length);return i+e.slice(a)}let P=E(r);function _(e,t){e.childNodes=[{nodeName:"#text",value:t,parentNode:e}]}let I=new Set,U=new Set,T=new Set,W=new Set([".js",".mjs"]);function z(e){I.add(e.url.pathname);let t=e.data.toString();for(let e of t.matchAll(/["'](\/(?:[A-Za-z0-9_.%~-]+\/)*[A-Za-z0-9_.%~-]+\.(?:png|jpe?g|gif|webp|avif|svg|ico))["']/gi))S.add(e[1]);for(let e of t.matchAll(/["'](?:\/_next\/)?(static\/chunks\/[\w./%-]+\.js)["']/g))U.add("/_next/"+e[1]);for(let e of t.matchAll(/\b[\w$]+\.e\((\d+)\)/g))T.add(e[1]);return('if(document.currentScript)document.currentScript.setAttribute("src",'+JSON.stringify(e.url.pathname).replace(/</g,"\\u003c")+");\n"+t).replace(/<\/script/gi,"<\\/script")}let D=function(e,t){let r="popmelt-module:/",a=new Map,i=new Map,n=new Map,s=new Map;function o(t,r){if(r&&"object"==typeof r)for(let[a,i]of Object.entries(r)){let r=/^(?:\.{0,2}\/|https?:)/.test(a)?new URL(a,e).href:a;t.has(r)||t.set(r,"string"==typeof i?new URL(i,e).href:null)}}function l(e,t){if(e.has(t))return e.get(t);let r=[...e.keys()].filter(e=>e.endsWith("/")&&t.startsWith(e)).sort((e,t)=>t.length-e.length)[0];if(r){let a=e.get(r);return a?.endsWith("/")?a+t.slice(r.length):null}}function c(t){let i=new URL(t,e).href,n=a.get(i)??"entry-"+a.size;return a.set(i,n),r+n+".js"}return{entry:c,importMap(t){let r=JSON.parse(t);o(n,r.imports);for(let[t,a]of Object.entries(r.scopes??{})){let r=new URL(t,e).href,i=s.get(r)??new Map;o(i,a),s.set(r,i)}},inline(t){let r=new URL(e);return r.hash="inline-"+i.size,i.set(r.href,t),c(r.href)},async compile(){if(!a.size)return;let o={name:"invited-page-modules",setup(r){r.onResolve({filter:/.*/},t=>{let r,a=t.importer||e.href,i=/^(?:\.{0,2}\/|https?:\/\/)/.test(t.path),o=i?new URL(t.path,a).href:t.path;if("entry-point"!==t.kind){for(let e of[...s.keys()].filter(e=>a===e||e.endsWith("/")&&a.startsWith(e)).sort((e,t)=>t.length-e.length))if(r=l(s.get(e),o),void 0!==r)break;void 0===r&&(r=l(n,o))}if(null===r||!i&&!r)return{external:!0};let c=new URL(r??o);return c.origin!==e.origin?{path:c.href,external:!0}:{path:c.href,namespace:"page"}}),r.onLoad({filter:/.*/,namespace:"page"},async({path:r})=>{let a=i.get(r)??(await t(r,e))?.data.toString();if(void 0===a)throw new Error("Invited page module unavailable");return{contents:a,loader:"js"}})}},{build:c}=await(import("esbuild")),p=await c({entryPoints:[...a].map(([e,t])=>({in:e,out:t})),bundle:!0,splitting:!0,format:"esm",platform:"browser",publicPath:r,write:!1,outdir:"/",logLevel:"silent",legalComments:"none",minify:!0,plugins:[o]});return Object.fromEntries(p.outputFiles.map(e=>[r+e.path.split(/[\\/]/).pop(),"data:text/javascript;base64,"+Buffer.from(e.contents).toString("base64")]))}}}(t,(e,t)=>h(e,t,W)),F=new Set;await async function e(r){let a=[];for(let i of r.childNodes){if("tagName"in i){let r=i.tagName;if(["base","iframe","frame","embed","object"].includes(r)||"meta"===r&&L(i,"http-equiv"))continue;if("html"===n)for(let e of i.attrs)/^on[a-z]+$/.test(e.name)&&F.add("'sha256-"+l("sha256").update(e.value).digest("base64")+"'");if("astro"===n&&"astro-island"===r)for(let e of i.attrs)["component-url","renderer-url","before-hydration-url"].includes(e.name)&&e.value&&(e.value=D.entry(e.value));if("script"===r){let e=()=>i.childNodes.map(e=>"value"in e?e.value:"").join("");if("next"!==n&&"importmap"===L(i,"type")){D.importMap(e());continue}let r,a=L(i,"src");if("next"!==n&&"module"===L(i,"type")){let t=a?D.entry(a):D.inline(e());_(i,"import "+JSON.stringify(t)+";")}else if(a){if(void 0!==L(i,"nomodule"))continue;let e=await h(a,t,W);if(!e)continue;"next"===n?_(i,z(e)):r="data:text/javascript;base64,"+e.data.toString("base64")}i.attrs=i.attrs.filter(e=>["type","id","async","defer"].includes(e.name)||e.name.startsWith("data-")),r&&i.attrs.push({name:"src",value:r}),i.attrs.push({name:"nonce",value:p})}else if("link"===r){if("stylesheet"!==L(i,"rel"))continue;let e=await h(L(i,"href")??"",t,new Set([".css"]));if(!e)continue;i.tagName=i.nodeName="style",i.attrs=[],_(i,(await A(e.data.toString(),e.url)).replace(/<\/style/gi,"<\\/style"))}else if("style"===r)for(let e of i.childNodes)"value"in e&&(e.value=(await A(e.value,t)).replace(/<\/style/gi,"<\\/style"));else if("img"===r){let e=L(i,"src")??"";e.startsWith("/_next/image?")&&(e=new URL(e,t).searchParams.get("url")??""),i.attrs=i.attrs.filter(e=>"src"!==e.name&&"srcset"!==e.name),e&&(await k(e,t),i.attrs.push({name:"src",value:e}))}await e(i)}a.push(i)}r.childNodes=a}(P);let H=[],B=await D.compile();B&&H.push('<script type="importmap" nonce="'+p+'">'+JSON.stringify({imports:B})+"<\/script>");let J=T.size?await m(y(e,".next","static","chunks")):[],q=new Map;for(let e of J){let t=/^(\d+)[.-][\w.-]+\.js$/.exec(e);if(t){let r=t[1],a=q.get(r)??[];a.push("/_next/static/chunks/"+e),q.set(r,a)}}let C=()=>{for(let e of T)for(let t of q.get(e)??[])U.add(t);T.clear()};C();for(let e of U){if(I.has(e))continue;let r=await h(e,t,W);r&&H.push('<script nonce="'+p+'">'+z(r)+"<\/script>"),C()}for(let e of S)await k(e,t);let K="("+O.toString()+")("+JSON.stringify(N).replace(/</g,"\\u003c")+","+JSON.stringify(t.pathname).replace(/</g,"\\u003c")+");",G=Buffer.from(await s("live-canvas")).toString().replace(/<\/script/gi,"<\\/script");return{body:j(P).replace(/<head(?: [^>]*)?>/i,e=>e+'<meta name="popmelt-live-canvas" content="1"><script nonce="'+p+'">('+M.toString()+")();"+K+"\n"+G+"<\/script>"+H.join("")),policy:"sandbox allow-scripts; default-src 'none'; script-src 'nonce-"+p+"'"+(B?" data:":"")+(F.size?"; script-src-attr 'unsafe-hashes' "+[...F].join(" "):"")+"; style-src 'unsafe-inline'; img-src data:; font-src data:; connect-src 'none'; form-action 'none'; base-uri 'none'; frame-ancestors 'self'"}}(e,n,await o.text(),A,r)};if("html"===A){let e=await r(o,A,o,void 0,{});try{return await _(o,e.origin,o)}finally{await e.close()}}let I=y(o,".popmelt");await p(I,{recursive:!0});let U,T=await u(y(I,"interact-"));try{let a=await(await n(o,T)).capture(),i=async e=>(await N("git",e,{cwd:o,env:{...process.env,GIT_INDEX_FILE:y(T,"index")}})).stdout.trim(),s=await i(["rev-parse","--show-toplevel"]),l=y(T,"checkout");await N("git",["init","--quiet","--template=",l]),await i(["read-tree",a]),await i(["-C",s,"checkout-index","--all","--prefix="+l+x]);let c=y(l,v(s,o)),{cli:p}=await t(o,A),u="next"===A?await e(S):{},f="nuxt"===A?["--input-type=module","-e","\nimport { loadNuxt, buildNuxt } from 'nuxt/kit';\nimport { createRequire } from 'node:module';\nimport { writeFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nconst require = createRequire(import.meta.url);\nconst routerPath = createRequire(require.resolve('nuxt/package.json')).resolve('vue-router');\nconst { createMemoryHistory, createRouter } = await import(routerPath);\nconst route = process.argv[1];\nconst options = resolve('.popmelt-router.mjs');\nawait writeFile(options, 'import { createMemoryHistory } from ' + JSON.stringify(routerPath) +\n ';export default { history: () => createMemoryHistory() };');\nconst nuxt = await loadNuxt({ cwd: process.cwd(), dev: false, overrides: {\n nitro: { preset: 'node-server' }, experimental: { appManifest: false, payloadExtraction: false },\n vite: { build: { modulePreload: false } },\n hooks: {\n 'pages:routerOptions'({files}) { files.push({path: options}); },\n 'pages:resolved'(pages) {\n if (!pages.length) return;\n const record = page => ({ path: page.path, alias: page.alias ?? [],\n component: {}, meta: { page }, children: (page.children || []).map(record) });\n const router = createRouter({ history: createMemoryHistory(), routes: pages.map(record) });\n const selected = new Set(router.resolve(route).matched.map(r => r.meta.page));\n const trim = list => {\n for (let i = list.length - 1; i >= 0; i--) {\n const page = list[i];\n if (!selected.has(page)) list.splice(i, 1);\n else if (page.children) trim(page.children);\n }\n };\n trim(pages);\n },\n },\n}});\ntry { await buildNuxt(nuxt); } finally { await nuxt.close(); }\n",k]:[p,"build",..."next"===A?[...P?[P]:[],"--experimental-build-mode","compile"]:[]];await N(process.execPath,f,{cwd:c,timeout:18e4,maxBuffer:8388608,env:{...u,PATH:process.env.PATH,HOME:process.env.HOME,TMPDIR:process.env.TMPDIR,SystemRoot:process.env.SystemRoot,CI:"1",NODE_ENV:"production",NEXT_TELEMETRY_DISABLED:"1",ASTRO_TELEMETRY_DISABLED:"1",NUXT_TELEMETRY_DISABLED:"1",POPMELT_PLANE_RENDERER:"1"}}),U=await r(c,A,s,void 0,u,!0);let m=y(c,"nuxt"===A?".output/public":"astro"===A?(await g(y(c,"dist/client")).catch(()=>{}))?.isDirectory()?"dist/client":"dist":"public");return await _(c,U.origin,m)}finally{try{await(U?.close())}finally{await h(T,{recursive:!0,force:!0,maxRetries:3})}}}function M(){Object.defineProperty(navigator,"locks",{value:void 0});let e=new Map;Object.defineProperty(document,"cookie",{get:()=>Array.from(e,([e,t])=>e+"="+t).join("; "),set:t=>{let[r,...a]=String(t).split(";"),i=r.indexOf("=");if(i<1)return;let n=r.slice(0,i).trim();a.some(e=>/^\s*max-age=0\s*$/i.test(e))?e.delete(n):e.set(n,r.slice(i+1))}});for(let e of["localStorage","sessionStorage"]){let t=new Map;Object.defineProperty(window,e,{value:{get length(){return t.size},key:e=>Array.from(t.keys())[e]??null,getItem:e=>t.get(String(e))??null,setItem:(e,r)=>{t.set(String(e),String(r))},removeItem:e=>{t.delete(String(e))},clear:()=>t.clear()}})}}function O(e,t){let r=new URL(t,location.href);function a(t){if(t&&!t.startsWith("data:"))try{let a=new URL(t,r);if(a.origin!==r.origin)return;if("/_next/image"===a.pathname&&(a=new URL(a.searchParams.get("url")??"",r)),a.origin===r.origin)return e[a.pathname]}catch{}}function i(e){if(e instanceof HTMLImageElement){let t=a(e.getAttribute("src")??"");t&&(e.removeAttribute("srcset"),e.src=t)}else if(e instanceof HTMLVideoElement){let t=a(e.getAttribute("poster")??"");t&&(e.poster=t)}}new MutationObserver(e=>{for(let t of e)if("attributes"===t.type)i(t.target);else for(let e of t.addedNodes)e instanceof Element&&(i(e),e.querySelectorAll("img,video[poster]").forEach(i))}).observe(document,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["src","poster","srcset"]})}function A(e,t,r,a){let i,n="";return async(s,o)=>{let l=o+"\n"+s;for(;i&&n!==l;){let e=i;await e.catch(()=>{}),i===e&&(i=void 0)}if(!i||n!==l){n=l;let o=k(e,t,s,r,a);i=o,o.catch(()=>{i===o&&(i=void 0)})}return i}}export{A as pageInteraction};
@@ -0,0 +1 @@
1
+ import{a as m,b as n,c as s,d as r,e as t,f as o}from"./chunk-DLXTHDBS.mjs";import"./chunk-7XGXFP5L.mjs";import"./chunk-BDSIJTX5.mjs";import"./chunk-2EQSGPAN.mjs";import"./chunk-PCUUOIFD.mjs";import"./chunk-63F7KX4E.mjs";import"./chunk-5GQXAV54.mjs";import"./chunk-ALWPAFIW.mjs";import"./chunk-BSVZXOOS.mjs";import"./chunk-7OATJ6BO.mjs";import"./chunk-NC7YXD7Q.mjs";import"./chunk-KOHR4LAQ.mjs";import"./chunk-UNUYNWTJ.mjs";import"./chunk-WVGFWHL3.mjs";import"./chunk-HKHZBKAN.mjs";import"./chunk-CIKFUS7J.mjs";import"./chunk-72CUIZA2.mjs";import"./chunk-GLF7Z5IR.mjs";import"./chunk-KD2AOPYP.mjs";import"./chunk-KF73S7MG.mjs";import"./chunk-NOHXTT24.mjs";export{m as agentCredentialFile,t as callPeer,r as canvasChatRequest,s as enrolledCanvasEndpoint,o as runPeerCommand,n as sendThreadNote};
@@ -1 +1 @@
1
- import{b as t}from"./chunk-AOFKEBLN.mjs";import"./chunk-WSI2SQWU.mjs";import"./chunk-LWPNOBGS.mjs";import"./chunk-4RQ5XD3I.mjs";import"./chunk-ITLRSHNZ.mjs";import"./chunk-HKHZBKAN.mjs";import"./chunk-CIKFUS7J.mjs";import"./chunk-W5TNOJOR.mjs";import"./chunk-GLF7Z5IR.mjs";import"./chunk-KD2AOPYP.mjs";import"./chunk-KF73S7MG.mjs";import"./chunk-WWNI7JCA.mjs";import"./chunk-NOHXTT24.mjs";import{fileURLToPath as e}from"url";function n(n={}){return{name:"popmelt",hooks:{"astro:config:setup"({command:r,config:i,updateConfig:s,injectScript:m}){if("dev"!==r||"1"===process.env.POPMELT_PLANE_RENDERER)return;let{client:a=!0,...d}=n;s({vite:{plugins:[t({...d,projectRoot:n.projectRoot??e(i.root)},"astro")],optimizeDeps:{include:a?["react","react/jsx-runtime","react/jsx-dev-runtime","react-dom","react-dom/client"]:[]}}}),m("page",a?o:"\nimport { bridgeUrl, projectId } from 'virtual:popmelt/bridge';\nif (bridgeUrl) window.__POPMELT_BRIDGE_URL__ = bridgeUrl;\nif (projectId) window.__POPMELT_PROJECT_ID__ = projectId;\n")}}}}var o="\nimport { bridgeUrl, projectId } from 'virtual:popmelt/bridge';\nimport { navigate } from 'astro:transitions/client';\nlet disposed = false;\nlet mounting;\nconst start = () => {\n if (disposed || mounting || !bridgeUrl || !projectId) return;\n mounting = Promise.resolve(import.meta.hot?.data.cleanup).then(async () => {\n if (disposed) return;\n const { mountPopmelt } = await import('@popmelt.com/core/browser');\n if (disposed) return;\n const handle = await mountPopmelt({ enabled: true, bridgeUrl, projectId, navigate });\n return handle;\n }).catch(error => { console.warn('[popmelt] startup failed:', error); });\n};\n// The standalone hosts live outside body, so Astro's body swaps retain them.\ndocument.addEventListener('astro:page-load', start);\nif (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start, { once: true });\nelse start();\nimport.meta.hot?.dispose(data => {\n if (disposed) return;\n disposed = true;\n document.removeEventListener('astro:page-load', start);\n document.removeEventListener('DOMContentLoaded', start);\n data.cleanup = mounting?.then(handle => handle?.unmount());\n});\n";export{n as popmelt};
1
+ import{b as t}from"./chunk-TNVYP6S4.mjs";import"./chunk-4O6YFMWF.mjs";import"./chunk-LWPNOBGS.mjs";import"./chunk-UNUYNWTJ.mjs";import"./chunk-WVGFWHL3.mjs";import"./chunk-HKHZBKAN.mjs";import"./chunk-CIKFUS7J.mjs";import"./chunk-72CUIZA2.mjs";import"./chunk-GLF7Z5IR.mjs";import"./chunk-KD2AOPYP.mjs";import"./chunk-KF73S7MG.mjs";import"./chunk-RG2CK6VE.mjs";import"./chunk-NOHXTT24.mjs";import{fileURLToPath as e}from"url";function n(n={}){return{name:"popmelt",hooks:{"astro:config:setup"({command:r,config:i,updateConfig:s,injectScript:m}){if("dev"!==r||"1"===process.env.POPMELT_PLANE_RENDERER)return;let{client:a=!0,...d}=n;s({vite:{plugins:[t({...d,projectRoot:n.projectRoot??e(i.root)},"astro")],optimizeDeps:{include:a?["react","react/jsx-runtime","react/jsx-dev-runtime","react-dom","react-dom/client"]:[]}}}),m("page",a?o:"\nimport { bridgeUrl, projectId } from 'virtual:popmelt/bridge';\nif (bridgeUrl) window.__POPMELT_BRIDGE_URL__ = bridgeUrl;\nif (projectId) window.__POPMELT_PROJECT_ID__ = projectId;\n")}}}}var o="\nimport { bridgeUrl, projectId } from 'virtual:popmelt/bridge';\nimport { navigate } from 'astro:transitions/client';\nlet disposed = false;\nlet mounting;\nconst start = () => {\n if (disposed || mounting || !bridgeUrl || !projectId) return;\n mounting = Promise.resolve(import.meta.hot?.data.cleanup).then(async () => {\n if (disposed) return;\n const { mountPopmelt } = await import('@popmelt.com/core/browser');\n if (disposed) return;\n const handle = await mountPopmelt({ enabled: true, bridgeUrl, projectId, navigate });\n return handle;\n }).catch(error => { console.warn('[popmelt] startup failed:', error); });\n};\n// The standalone hosts live outside body, so Astro's body swaps retain them.\ndocument.addEventListener('astro:page-load', start);\nif (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start, { once: true });\nelse start();\nimport.meta.hot?.dispose(data => {\n if (disposed) return;\n disposed = true;\n document.removeEventListener('astro:page-load', start);\n document.removeEventListener('DOMContentLoaded', start);\n data.cleanup = mounting?.then(handle => handle?.unmount());\n});\n";export{n as popmelt};
@@ -1 +1 @@
1
- import{b as e,c as t}from"./chunk-WWNI7JCA.mjs";import{b as o}from"./chunk-NOHXTT24.mjs";import{addPluginTemplate as n,defineNuxtModule as r}from"nuxt/kit";var p=r({meta:{name:"@popmelt.com/core/nuxt",configKey:"popmelt"},async setup(r,p){if(!p.options.dev||"1"===process.env.POPMELT_PLANE_RENDERER)return;let s={config:{server:p.options.devServer},middlewares:{use(){}}},i=await e({...r,projectRoot:r.projectRoot??p.options.rootDir},s,3e3,void 0,"nuxt");if(null===i.port)return;i.updateOrigin&&p.hook("listen",async(e,t)=>{s.httpServer=e;let o=e.address();if(!o||"string"==typeof o)return;let n="127.0.0.1"===o.address?"127.0.0.1":"::1"===o.address?"[::1]":"localhost";await i.updateOrigin(`${t.https?"https":"http"}://${n}:${o.port}`)}),p.hook("nitro:config",e=>{e.routeRules??={},Object.assign(e.routeRules,{...i.bootstrap?.planeApps&&{"/__popmelt/planes/**":{proxy:{to:`http://127.0.0.1:${i.port}/__popmelt/planes/**`,headers:{"x-popmelt-project-id":i.projectId}}}},...i.bootstrap&&{"/__popmelt/host":{proxy:`http://127.0.0.1:${i.port}/__popmelt/host?projectId=${encodeURIComponent(i.projectId)}`}},"/popmelt/phone":{proxy:`http://127.0.0.1:${i.port}/phone-host`}})}),p.hook("vite:extend",({config:e})=>{e.server??={},e.server.fs??={},e.server.fs.strict=!0,e.server.fs.deny=[...e.server.fs.deny??[".env",".env.*","*.{crt,pem}","**/.git/**"],"**/.popmelt","**/.popmelt/**"],e.server.watch??={};let t=e.server.watch.ignored;e.server.watch.ignored=[...Array.isArray(t)?t:t?[t]:[],"**/.popmelt/**"],e.optimizeDeps??={},e.optimizeDeps.include=[...new Set([...e.optimizeDeps.include??[],"react","react/jsx-runtime","react/jsx-dev-runtime","react-dom","react-dom/client"])]});let d=await t(i,s),a=d?o(d):void 0;p.hook("close",async()=>{a?.(),await(d?.release())}),n({filename:"popmelt.client.mjs",mode:"client",getContents:()=>`import { defineNuxtPlugin } from '#app';\nexport default defineNuxtPlugin((nuxtApp) => {\n let disposed = false;\n let mounting;\n const bridgeUrl = ${JSON.stringify(`http://localhost:${i.port}`)};\n const projectId = ${JSON.stringify(i.projectId)};\n ${i.bootstrap?`window.__POPMELT_PARTICIPANTS__=${JSON.stringify(i.bootstrap)};`:""}\n const dispose = () => {\n if (disposed) return;\n disposed = true;\n void mounting?.then(handle => handle?.unmount());\n };\n nuxtApp.hook('app:mounted', () => {\n if (disposed || mounting) return;\n mounting = import('@popmelt.com/core/browser').then(({ mountPopmelt }) => {\n if (disposed) return;\n return mountPopmelt({\n enabled: true,\n bridgeUrl,\n projectId,\n navigate: (url) => nuxtApp.$router.push(url),\n });\n }).then(handle => {\n if (disposed) handle?.unmount();\n return handle;\n }).catch(error => { console.warn('[popmelt] startup failed:', error); });\n });\n nuxtApp.vueApp.onUnmount(dispose);\n import.meta.hot?.dispose(dispose);\n});`})}});export{p as default};
1
+ import{b as e,c as t}from"./chunk-RG2CK6VE.mjs";import{b as o}from"./chunk-NOHXTT24.mjs";import{addPluginTemplate as n,defineNuxtModule as r}from"nuxt/kit";var p=r({meta:{name:"@popmelt.com/core/nuxt",configKey:"popmelt"},async setup(r,p){if(!p.options.dev||"1"===process.env.POPMELT_PLANE_RENDERER)return;let s={config:{server:p.options.devServer},middlewares:{use(){}}},i=await e({...r,projectRoot:r.projectRoot??p.options.rootDir},s,3e3,void 0,"nuxt");if(null===i.port)return;i.updateOrigin&&p.hook("listen",async(e,t)=>{s.httpServer=e;let o=e.address();if(!o||"string"==typeof o)return;let n="127.0.0.1"===o.address?"127.0.0.1":"::1"===o.address?"[::1]":"localhost";await i.updateOrigin(`${t.https?"https":"http"}://${n}:${o.port}`)}),p.hook("nitro:config",e=>{e.routeRules??={},Object.assign(e.routeRules,{...i.bootstrap?.planeApps&&{"/__popmelt/planes/**":{proxy:{to:`http://127.0.0.1:${i.port}/__popmelt/planes/**`,headers:{"x-popmelt-project-id":i.projectId}}}},...i.bootstrap&&{"/__popmelt/host":{proxy:`http://127.0.0.1:${i.port}/__popmelt/host?projectId=${encodeURIComponent(i.projectId)}`}},"/popmelt/phone":{proxy:`http://127.0.0.1:${i.port}/phone-host`}})}),p.hook("vite:extend",({config:e})=>{e.server??={},e.server.fs??={},e.server.fs.strict=!0,e.server.fs.deny=[...e.server.fs.deny??[".env",".env.*","*.{crt,pem}","**/.git/**"],"**/.popmelt","**/.popmelt/**"],e.server.watch??={};let t=e.server.watch.ignored;e.server.watch.ignored=[...Array.isArray(t)?t:t?[t]:[],"**/.popmelt/**"],e.optimizeDeps??={},e.optimizeDeps.include=[...new Set([...e.optimizeDeps.include??[],"react","react/jsx-runtime","react/jsx-dev-runtime","react-dom","react-dom/client"])]});let d=await t(i,s),a=d?o(d):void 0;p.hook("close",async()=>{a?.(),await(d?.release())}),n({filename:"popmelt.client.mjs",mode:"client",getContents:()=>`import { defineNuxtPlugin } from '#app';\nexport default defineNuxtPlugin((nuxtApp) => {\n let disposed = false;\n let mounting;\n const bridgeUrl = ${JSON.stringify(`http://localhost:${i.port}`)};\n const projectId = ${JSON.stringify(i.projectId)};\n ${i.bootstrap?`window.__POPMELT_PARTICIPANTS__=${JSON.stringify(i.bootstrap)};`:""}\n const dispose = () => {\n if (disposed) return;\n disposed = true;\n void mounting?.then(handle => handle?.unmount());\n };\n nuxtApp.hook('app:mounted', () => {\n if (disposed || mounting) return;\n mounting = import('@popmelt.com/core/browser').then(({ mountPopmelt }) => {\n if (disposed) return;\n return mountPopmelt({\n enabled: true,\n bridgeUrl,\n projectId,\n navigate: (url) => nuxtApp.$router.push(url),\n });\n }).then(handle => {\n if (disposed) handle?.unmount();\n return handle;\n }).catch(error => { console.warn('[popmelt] startup failed:', error); });\n });\n nuxtApp.vueApp.onUnmount(dispose);\n import.meta.hot?.dispose(dispose);\n});`})}});export{p as default};
@@ -1 +1 @@
1
- import{a as m,b as p}from"./chunk-AOFKEBLN.mjs";import"./chunk-WSI2SQWU.mjs";import"./chunk-LWPNOBGS.mjs";import"./chunk-4RQ5XD3I.mjs";import"./chunk-ITLRSHNZ.mjs";import"./chunk-HKHZBKAN.mjs";import"./chunk-CIKFUS7J.mjs";import"./chunk-W5TNOJOR.mjs";import"./chunk-GLF7Z5IR.mjs";import"./chunk-KD2AOPYP.mjs";import"./chunk-KF73S7MG.mjs";import"./chunk-WWNI7JCA.mjs";import"./chunk-NOHXTT24.mjs";export{m as participantPlanes,p as popmelt};
1
+ import{a as m,b as p}from"./chunk-TNVYP6S4.mjs";import"./chunk-4O6YFMWF.mjs";import"./chunk-LWPNOBGS.mjs";import"./chunk-UNUYNWTJ.mjs";import"./chunk-WVGFWHL3.mjs";import"./chunk-HKHZBKAN.mjs";import"./chunk-CIKFUS7J.mjs";import"./chunk-72CUIZA2.mjs";import"./chunk-GLF7Z5IR.mjs";import"./chunk-KD2AOPYP.mjs";import"./chunk-KF73S7MG.mjs";import"./chunk-RG2CK6VE.mjs";import"./chunk-NOHXTT24.mjs";export{m as participantPlanes,p as popmelt};
@@ -0,0 +1 @@
1
+ var l={codex:{label:"Codex",installUrl:"https://github.com/openai/codex#installing-and-running-codex-cli",installTool:"npm",installPackage:"@openai/codex",loginArgs:["login"]},claude:{label:"Claude Code",installUrl:"https://code.claude.com/docs/en/setup#install-claude-code",installTool:"npm",installPackage:"@anthropic-ai/claude-code",loginArgs:["auth","login"]},cursor:{label:"Grok Code (Cursor)",installUrl:"https://cursor.com/docs/cli/installation",installTool:"brew",installPackage:"cursor-cli",loginArgs:["login"]},opencode:{label:"OpenCode",installUrl:"https://opencode.ai/docs/",installTool:"npm",installPackage:"@opencode/cli",loginArgs:["auth","login"]},copilot:{label:"GitHub Copilot",installUrl:"https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli",installTool:"npm",installPackage:"@github/copilot",loginArgs:["login"]},omp:{label:"Oh My Pi",installUrl:"https://github.com/can1357/oh-my-pi#install",installTool:"bun",installPackage:"@oh-my-pi/pi-coding-agent",loginArgs:["setup"]}},o={...l,cloudflared:{label:"cloudflared",installUrl:"https://developers.cloudflare.com/tunnel/downloads/",installTool:"brew",installPackage:"cloudflared",loginArgs:[]}},a=o=>"cloudflared"===o?["install","cloudflared"]:"cursor"===o?["install","--cask","cursor-cli"]:["install","-g",l[o].installPackage];export{l as PROVIDER_SETUP,o as SETTINGS_CLIS,a as providerInstallArgs};
package/dist/server.mjs CHANGED
@@ -1 +1 @@
1
- import{a as t,b as s,c as m}from"./chunk-XHTSKQMB.mjs";import"./chunk-VJKC2RJB.mjs";import"./chunk-PCUUOIFD.mjs";import"./chunk-YHCZYT4T.mjs";import{i as a,j as r,k as i,l as p}from"./chunk-TA2BMDSC.mjs";import"./chunk-ALWPAFIW.mjs";import"./chunk-BSVZXOOS.mjs";import"./chunk-7OATJ6BO.mjs";import{a as n,b as o}from"./chunk-NC7YXD7Q.mjs";import"./chunk-KOHR4LAQ.mjs";import{b as c,d as e,e as u}from"./chunk-4RQ5XD3I.mjs";import{b as j}from"./chunk-ITLRSHNZ.mjs";import"./chunk-HKHZBKAN.mjs";import"./chunk-CIKFUS7J.mjs";import"./chunk-W5TNOJOR.mjs";import"./chunk-GLF7Z5IR.mjs";import"./chunk-KD2AOPYP.mjs";import"./chunk-KF73S7MG.mjs";import"./chunk-NOHXTT24.mjs";export{p as ImprintService,a as ImprintStore,u as createParticipantDevBootstrap,c as createParticipantGuestAccess,e as createParticipantHostEntry,j as createParticipantPlaneApps,i as formatImprintPrompt,n as imprintExplanationRef,t as managedParticipantBrowser,r as parseImprintDraft,o as qualifyImprintRelation,m as startDevelopmentSession,s as startPopmelt};
1
+ import{a as t,b as s,c as m}from"./chunk-BDSIJTX5.mjs";import"./chunk-2EQSGPAN.mjs";import"./chunk-PCUUOIFD.mjs";import"./chunk-63F7KX4E.mjs";import{i as a,j as r,k as i,l as p}from"./chunk-5GQXAV54.mjs";import"./chunk-ALWPAFIW.mjs";import"./chunk-BSVZXOOS.mjs";import"./chunk-7OATJ6BO.mjs";import{a as n,b as o}from"./chunk-NC7YXD7Q.mjs";import"./chunk-KOHR4LAQ.mjs";import{b as c,d as e,e as u}from"./chunk-UNUYNWTJ.mjs";import{b as j}from"./chunk-WVGFWHL3.mjs";import"./chunk-HKHZBKAN.mjs";import"./chunk-CIKFUS7J.mjs";import"./chunk-72CUIZA2.mjs";import"./chunk-GLF7Z5IR.mjs";import"./chunk-KD2AOPYP.mjs";import"./chunk-KF73S7MG.mjs";import"./chunk-NOHXTT24.mjs";export{p as ImprintService,a as ImprintStore,u as createParticipantDevBootstrap,c as createParticipantGuestAccess,e as createParticipantHostEntry,j as createParticipantPlaneApps,i as formatImprintPrompt,n as imprintExplanationRef,t as managedParticipantBrowser,r as parseImprintDraft,o as qualifyImprintRelation,m as startDevelopmentSession,s as startPopmelt};
@@ -0,0 +1 @@
1
+ import{c as a,d as r}from"./chunk-63F7KX4E.mjs";import"./chunk-HKHZBKAN.mjs";import"./chunk-CIKFUS7J.mjs";import"./chunk-KF73S7MG.mjs";export{r as createSharedPageReader,a as sharedPagePath};
@@ -0,0 +1 @@
1
+ var e={capacity:{label:"At capacity",message:"The model provider is temporarily unavailable. Try again shortly."},rate_limited:{label:"Rate limited",message:"The model provider is receiving too many requests. Try again shortly."},timeout:{label:"Timed out",message:"The model took too long to respond. Try again."},connection:{label:"Connection lost",message:"The model provider disconnected before the run completed. Try again."},authentication:{label:"Sign-in required",message:"The model provider needs to be authenticated before this run can continue."},send_rejected:{label:"Not sent",message:"This reply did not reach the thread. Try again when the connection is ready."},interrupted:{label:"Interrupted",message:"The Popmelt bridge stopped before this run finished. Send the thread again to continue."},failed:{label:"Failed",message:"The model could not complete this run. Try again, or inspect the job diagnostics if the problem continues."}};function t(t,i){let n=i??function(e){let t="string"==typeof e?e:(()=>{try{return JSON.stringify(e)}catch{return String(e??"")}})();return/\b(?:http\s*)?503\b|server at capacity|\bat capacity\b|resource[_\s-]?exhausted|temporarily unavailable/i.test(t)?"capacity":/\b(?:http\s*)?429\b|rate[_\s-]?limit|too many requests/i.test(t)?"rate_limited":/timed?\s*out|timeout/i.test(t)?"timeout":/auth(?:entication|orization)? required|oauth|not authenticated|sign[ -]?in required|unauthorized|\b401\b/i.test(t)?"authentication":/transport channel closed|connection (?:closed|lost|reset)|socket hang up|network error|disconnected/i.test(t)?"connection":"failed"}(t);return{kind:n,...e[n]}}export{t as presentThreadError};
@@ -21,17 +21,25 @@ function listenerFor(server, directory) {
21
21
  if (pending) return pending;
22
22
  const dir = directory || fs.mkdtempSync('/tmp/popmelt-app-');
23
23
  const socketPath = join(dir, randomUUID() + '.sock');
24
+ const ownsRequest = (req) =>
25
+ appPort(server) === port &&
26
+ req.headers.host?.split(':').at(-1) === String(port);
24
27
  const listener = http.createServer((req, res) => {
25
28
  // The reservation may have changed while this request was in flight.
26
- if (
27
- appPort(server) !== port ||
28
- req.headers.host?.split(':').at(-1) !== String(port)
29
- )
29
+ if (!ownsRequest(req))
30
30
  return res.writeHead(503, { 'x-popmelt-app-offline': '1' }).end();
31
31
  if (req.method === 'HEAD' && req.url === '/__pair/listener')
32
32
  return res.writeHead(204).end();
33
33
  server.emit('request', req, res);
34
34
  });
35
+ const { isViteHmr } = module.require('./vite-hmr.cjs');
36
+ const upgrades = new Set();
37
+ listener.on('upgrade', (req, socket, head) => {
38
+ if (!ownsRequest(req) || !isViteHmr(req)) return socket.destroy();
39
+ upgrades.add(socket);
40
+ socket.once('close', () => upgrades.delete(socket));
41
+ if (!server.emit('upgrade', req, socket, head)) socket.destroy();
42
+ });
35
43
  pending = new Promise((resolve, reject) => {
36
44
  function close() {
37
45
  resolve(undefined);
@@ -40,6 +48,7 @@ function listenerFor(server, directory) {
40
48
  if (!directory) fs.rmdir(dir, () => {});
41
49
  });
42
50
  listener.closeAllConnections();
51
+ for (const socket of upgrades) socket.destroy();
43
52
  }
44
53
  server.once('close', close);
45
54
  listener.once('error', (err) => {
@@ -1,3 +1,4 @@
1
+ import { serveViteHmr } from './vite-hmr.mjs';
1
2
  import { createServer, request } from 'node:http';
2
3
  import { createConnection } from 'node:net';
3
4
  import { chmod, lstat, unlink } from 'node:fs/promises';
@@ -163,6 +164,12 @@ export async function serve(registerDns = provisionDns, idForKey) {
163
164
  req.once('error', () => upstream.destroy());
164
165
  req.pipe(upstream);
165
166
  });
167
+ const closeHmr = serveViteHmr(router, (req) => {
168
+ const host = req.headers.host;
169
+ const socketPath = routes.get(host);
170
+ if (socketPath && req.headers.cookie)
171
+ return { host, socketPath, cookie: req.headers.cookie };
172
+ });
166
173
  // Serialize adds, including the DNS operation. Duplicate clicks reuse the
167
174
  // persisted binding and never start another connector.
168
175
  let tail = Promise.resolve();
@@ -239,6 +246,7 @@ export async function serve(registerDns = provisionDns, idForKey) {
239
246
  const stopWatching = watchVolumes();
240
247
  return () => {
241
248
  stopWatching?.();
249
+ closeHmr();
242
250
  for (const server of [control, router]) {
243
251
  server.close();
244
252
  server.closeAllConnections();
@@ -0,0 +1,17 @@
1
+ const phoneHmrPath = 'popmelt-vite-hmr';
2
+ const route =
3
+ /^\/(?:[\w@~-][\w.@~-]*\/)*popmelt-vite-hmr(\?token=[\w-]{1,128})?$/;
4
+
5
+ function isViteHmr(req) {
6
+ const protocol = req.headers['sec-websocket-protocol'];
7
+ const match = route.exec(req.url || '');
8
+ return (
9
+ req.method === 'GET' &&
10
+ req.headers.upgrade?.toLowerCase() === 'websocket' &&
11
+ !!match &&
12
+ (protocol === 'vite-ping' || (protocol === 'vite-hmr' && !!match[1]))
13
+ );
14
+ }
15
+
16
+ exports.phoneHmrPath = phoneHmrPath;
17
+ exports.isViteHmr = isViteHmr;
@@ -0,0 +1,99 @@
1
+ import { createConnection } from 'node:net';
2
+ import { WebSocket, WebSocketServer } from 'ws';
3
+ import { isViteHmr } from './vite-hmr.cjs';
4
+
5
+ // Only the Mac router carries the session cookie to the authenticated project.
6
+ export function serveViteHmr(server, resolveTarget) {
7
+ const sockets = new WebSocketServer({
8
+ noServer: true,
9
+ clientTracking: false,
10
+ maxPayload: 65536,
11
+ });
12
+ const active = new Set();
13
+ server.on('upgrade', async (req, socket, head) => {
14
+ const origin = req.headers.origin;
15
+ if (
16
+ !isViteHmr(req) ||
17
+ origin !== 'https://' + req.headers.host ||
18
+ active.size >= 64
19
+ )
20
+ return socket.destroy();
21
+ const protocol = req.headers['sec-websocket-protocol'];
22
+ let app, phone;
23
+ let timeout = setTimeout(stop, 5000);
24
+ function stop() {
25
+ if (!active.delete(stop)) return;
26
+ clearTimeout(timeout);
27
+ socket.destroy();
28
+ app?.terminate();
29
+ }
30
+ active.add(stop);
31
+ socket.once('close', stop);
32
+ socket.once('error', stop);
33
+ try {
34
+ const target = await resolveTarget(req);
35
+ if (
36
+ !target ||
37
+ socket.destroyed ||
38
+ (target.until && target.until <= Date.now())
39
+ )
40
+ return stop();
41
+ const scheme = target.secure && !target.socketPath ? 'wss' : 'ws';
42
+ app = new WebSocket(scheme + '://' + target.host + req.url, protocol, {
43
+ origin,
44
+ headers: target.cookie ? { cookie: target.cookie } : {},
45
+ ...(target.socketPath && {
46
+ createConnection: () => createConnection(target.socketPath),
47
+ }),
48
+ handshakeTimeout: 5000,
49
+ maxPayload: 4 * 1024 * 1024,
50
+ perMessageDeflate: false,
51
+ });
52
+ app.once('error', stop);
53
+ app.once('close', () => (phone ? phone.close() : stop()));
54
+ app.once('open', () => {
55
+ if (
56
+ socket.destroyed ||
57
+ app.protocol !== protocol ||
58
+ (target.until && target.until <= Date.now())
59
+ )
60
+ return stop();
61
+ sockets.handleUpgrade(req, socket, head, (client) => {
62
+ phone = client;
63
+ clearTimeout(timeout);
64
+ if (target.until)
65
+ timeout = setTimeout(stop, Math.max(0, target.until - Date.now()));
66
+ client.once('close', stop);
67
+ client.once('error', stop);
68
+ app.on('message', (data, binary) => {
69
+ if (binary || client.bufferedAmount + data.length > 4 * 1024 * 1024)
70
+ return stop();
71
+ client.send(data, { binary: false }, (err) => {
72
+ if (err) stop();
73
+ });
74
+ });
75
+ // Phones subscribe to updates. A framework can invalidate a module that
76
+ // cannot hot-accept; refresh that phone without exposing Vite's RPC.
77
+ client.on('message', (data, binary) => {
78
+ if (binary) return stop();
79
+ try {
80
+ const message = JSON.parse(data);
81
+ if (
82
+ message.type === 'custom' &&
83
+ message.event === 'vite:invalidate'
84
+ )
85
+ client.send('{"type":"full-reload","path":"*"}');
86
+ } catch {
87
+ stop();
88
+ }
89
+ });
90
+ });
91
+ });
92
+ } catch {
93
+ stop();
94
+ }
95
+ });
96
+ return () => {
97
+ for (const stop of active) stop();
98
+ };
99
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popmelt.com/core",
3
- "version": "0.41.0",
3
+ "version": "0.41.2",
4
4
  "description": "A tiny, powerful design layer for humans and AI",
5
5
  "license": "PolyForm-Shield-1.0.0",
6
6
  "author": "Popmelt <reb@popmelt.com> (https://popmelt.com)",
@@ -112,6 +112,8 @@
112
112
  "dist",
113
113
  "infra/phone-pairing/binding.mjs",
114
114
  "infra/phone-pairing/app-listener.cjs",
115
+ "infra/phone-pairing/vite-hmr.cjs",
116
+ "infra/phone-pairing/vite-hmr.mjs",
115
117
  "infra/phone-pairing/reservations.mjs",
116
118
  "infra/phone-pairing/writer-lock.mjs",
117
119
  "infra/phone-pairing/machine.mjs",
@@ -1 +0,0 @@
1
- "use client";export{f as PagePreviewLayer}from"./chunk-LDDDSIAQ.mjs";import"./chunk-GLIGPLM4.mjs";import"./chunk-JWWWU4GY.mjs";import"./chunk-Q6N77LIS.mjs";import"./chunk-FHCKFQBY.mjs";import"./chunk-APP5IYTE.mjs";import"./chunk-VOL4KS67.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-AOTDTBQO.mjs";import"./chunk-WP2SHSCG.mjs";import"./chunk-LH7HKUCK.mjs";import"./chunk-ZVDKW7TO.mjs";import"./chunk-Q6C7ZA3H.mjs";import"./chunk-7D4BUDKG.mjs";import"./chunk-OEJXPUAR.mjs";import"./chunk-HM6EBJVO.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-YGP6PPOZ.mjs";
@@ -1 +0,0 @@
1
- "use client";import{a as r,d as t}from"./chunk-RFTQCRGC.mjs";import"./chunk-UFU5IA3G.mjs";import"./chunk-Z4NMA34Y.mjs";import"./chunk-FZUHHJWW.mjs";import"./chunk-SOGN7S54.mjs";import"./chunk-S2U2IGUO.mjs";import"./chunk-EHM2ZBQU.mjs";import"./chunk-2TA7N3CI.mjs";import"./chunk-PRZ6C5X3.mjs";import"./chunk-VOL4KS67.mjs";import"./chunk-VLTK7KWK.mjs";import"./chunk-PTMHSMZH.mjs";import"./chunk-G2ZHJXHZ.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-HFWGYXPG.mjs";import"./chunk-RK6UROPO.mjs";import"./chunk-AOTDTBQO.mjs";import"./chunk-2F2BVGFH.mjs";import"./chunk-RWZ7SVMO.mjs";import"./chunk-HAZXZ5TU.mjs";import"./chunk-YTIDSDPP.mjs";import"./chunk-KF35YUNZ.mjs";import"./chunk-VBH2YQLG.mjs";import"./chunk-VXRRHXUP.mjs";import"./chunk-WP2SHSCG.mjs";import"./chunk-AAMUU2QA.mjs";import"./chunk-LH7HKUCK.mjs";import"./chunk-5TCWBNV4.mjs";import"./chunk-EILBHZDX.mjs";import"./chunk-ZVDKW7TO.mjs";import"./chunk-HQVWOBYH.mjs";import"./chunk-Q6C7ZA3H.mjs";import"./chunk-OREALBUO.mjs";import"./chunk-CK3CDA3L.mjs";import"./chunk-7D4BUDKG.mjs";import{b as o}from"./chunk-OEJXPUAR.mjs";import"./chunk-KE4MQBRY.mjs";import"./chunk-B4DYUYX4.mjs";import{d as n,f as i,c as m,a as e}from"./chunk-HM6EBJVO.mjs";import"./chunk-ADRWR5GI.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-PRPXMDZ7.mjs";import"./chunk-YGP6PPOZ.mjs";import{useState as c,useEffect as s,cloneElement as p}from"react";import{jsxs as h,jsx as u}from"react/jsx-runtime";function j({children:j,projectId:k,participantConfig:a}){let[l,d]=c(null),[H,U]=c("");if(s(()=>{let t,m,c=!1;return d(null),U(""),n(k).then(async n=>{if(c)return;let s=location.origin+e;m=i(s,n);let p=await o(s+"/status",{signal:AbortSignal.timeout(6e3)}),h=p.ok?await p.json():null;if(h?.projectId!==n.projectId)throw new Error("Phone access expired. Create a fresh pairing link in the project terminal.");if(!c){if(h.phoneParticipantId)t=await r({projectId:n.projectId,bridgeUrl:s,credential:{participantId:h.phoneParticipantId,token:""},runtimeStorage:sessionStorage,observedSource:{sourceId:n.projectId,revision:a?.revision??"unversioned"}});else if(a)throw new Error("This phone is not connected to the multiplayer host.");c?t?.dispose():d({bridgeUrl:s,projectId:n.projectId,connection:t})}}).catch(r=>{m?.(),c||U(r instanceof Error?r.message:"Phone pairing failed.")}),()=>{c=!0,t?.dispose(),m?.()}},[k,a]),H)return h("p",{role:"alert","data-devtools":"phone-pairing-error",children:[H," ",u("button",{type:"button",onClick:m,children:"Forget this pairing"})]});if(!l)return null;let I=p(j,{bridgeUrl:l.bridgeUrl,projectId:l.projectId});return l.connection?u(t,{connection:l.connection,onAccessRemoved:m,children:I}):I}export{j as PhoneHostGate};
@@ -1 +0,0 @@
1
- "use client";import{b as e}from"./chunk-VSWRWS2H.mjs";import"./chunk-HFKGW34E.mjs";import"./chunk-CK3CDA3L.mjs";import"./chunk-7D4BUDKG.mjs";import"./chunk-OEJXPUAR.mjs";import"./chunk-KE4MQBRY.mjs";import"./chunk-HM6EBJVO.mjs";import"./chunk-ADRWR5GI.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-YGP6PPOZ.mjs";import{jsx as t,jsxs as i,Fragment as r}from"react/jsx-runtime";var n={capacity:{label:"At capacity",message:"The model provider is temporarily unavailable. Try again shortly."},rate_limited:{label:"Rate limited",message:"The model provider is receiving too many requests. Try again shortly."},timeout:{label:"Timed out",message:"The model took too long to respond. Try again."},connection:{label:"Connection lost",message:"The model provider disconnected before the run completed. Try again."},authentication:{label:"Sign-in required",message:"The model provider needs to be authenticated before this run can continue."},send_rejected:{label:"Not sent",message:"This reply did not reach the thread. Try again when the connection is ready."},interrupted:{label:"Interrupted",message:"The Popmelt bridge stopped before this run finished. Send the thread again to continue."},failed:{label:"Failed",message:"The model could not complete this run. Try again, or inspect the job diagnostics if the problem continues."}};function o(e,t){let i=t??function(e){let t="string"==typeof e?e:(()=>{try{return JSON.stringify(e)}catch{return String(e??"")}})();return/\b(?:http\s*)?503\b|server at capacity|\bat capacity\b|resource[_\s-]?exhausted|temporarily unavailable/i.test(t)?"capacity":/\b(?:http\s*)?429\b|rate[_\s-]?limit|too many requests/i.test(t)?"rate_limited":/timed?\s*out|timeout/i.test(t)?"timeout":/auth(?:entication|orization)? required|oauth|not authenticated|sign[ -]?in required|unauthorized|\b401\b/i.test(t)?"authentication":/transport channel closed|connection (?:closed|lost|reset)|socket hang up|network error|disconnected/i.test(t)?"connection":"failed"}(e);return{kind:i,...n[i]}}var a={unavailable:"Open Codex or Claude in this project with the Popmelt integration enabled, then try again.",ambiguous:"More than one chat is available for this project. Send a note to this canvas thread from the intended chat first.",changed:"The destination chat has changed or its access is unavailable. Refresh the thread before trying again.",uncertain:"Delivery is unconfirmed. Check the destination chat before sending another copy."};function s({message:{error:n,errorKind:s,provider:d},bridgeUrl:c,canSignIn:l}){let h=function(e,t){let i=o(e,t);return"send_rejected"===t&&"string"==typeof e&&Object.values(a).some(t=>t===e)&&(i.message=e),i}(n,s);return t("div",{style:{backgroundColor:"var(--popmelt-thread-soft)",border:"1px solid var(--popmelt-thread-border)",borderRadius:24,color:"var(--popmelt-thread-muted-strong)",fontSize:14,letterSpacing:"0.14px",lineHeight:1.35,padding:16},children:!l||"authentication"!==h.kind||"codex"!==d&&"claude"!==d?i(r,{children:[t("span",{style:{color:"#f59e0b"},children:h.label})," — "+h.message]}):t(e,{provider:d,bridgeUrl:c})})}export{s as default};