@popmelt.com/core 0.41.2 → 0.42.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 (172) hide show
  1. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  2. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  3. package/dist/{ExploreAttachment-GTHGWP6E.mjs → ExploreAttachment-TRA62BMX.mjs} +1 -1
  4. package/dist/PagePreviewLayer-TX74TJBY.mjs +1 -0
  5. package/dist/ParticipantRuntime-Y7MKLWBC.mjs +1 -0
  6. package/dist/PhoneHostGate-XRYFSUJA.mjs +1 -0
  7. package/dist/{PopmeltProvider-5g-1VH5a.d.mts → PopmeltProvider-NwqjKtGG.d.mts} +1 -1
  8. package/dist/PopmeltTasteConnectedPane-NMKIRMDM.mjs +1 -0
  9. package/dist/{PreviewRuntime-7EQNIOF5.mjs → PreviewRuntime-VJXFECBF.mjs} +1 -1
  10. package/dist/{QueuedReplies-U7GLT6QK.mjs → QueuedReplies-X2N4JRS6.mjs} +1 -1
  11. package/dist/SamplePlacementOverlay-VWCULP2R.mjs +1 -0
  12. package/dist/ShareProjectPane-L6AO57IN.mjs +1 -0
  13. package/dist/SuppliedContext-UGQSL4IG.mjs +1 -0
  14. package/dist/{ThreadErrorCard-L7F7VX6H.mjs → ThreadErrorCard-WSNEGY7J.mjs} +1 -1
  15. package/dist/ThreadPanel-QNDCQOA4.mjs +1 -0
  16. package/dist/adapter-react-three-fiber.d.mts +1 -1
  17. package/dist/adapter-three.d.mts +1 -1
  18. package/dist/bridge-entry.mjs +1 -1
  19. package/dist/{bridgeSSEStream-AUMOLOCC.mjs → bridgeSSEStream-BHUFYHTT.mjs} +1 -1
  20. package/dist/{bridgeWebSocketStream-PE5XBFAM.mjs → bridgeWebSocketStream-L277I5ZX.mjs} +1 -1
  21. package/dist/browser-runtime-3PAM2ZUE.mjs +1 -0
  22. package/dist/browser.d.mts +4 -4
  23. package/dist/browser.mjs +1 -1
  24. package/dist/canvas-chat-note-HTK23RYE.mjs +1 -0
  25. package/dist/canvas-text.d.mts +1 -1
  26. package/dist/{checkFixture-ZD5UD7OR.mjs → checkFixture-C26VSTGP.mjs} +1 -1
  27. package/dist/chunk-23YWKAQM.mjs +1 -0
  28. package/dist/chunk-2OWGUAUI.mjs +1 -0
  29. package/dist/{chunk-YTIDSDPP.mjs → chunk-2PARHFWP.mjs} +1 -1
  30. package/dist/chunk-2YT4X5VC.mjs +1 -0
  31. package/dist/{chunk-KYOD2RVN.mjs → chunk-47SWWW5Y.mjs} +1 -1
  32. package/dist/chunk-56AALMHI.mjs +1 -0
  33. package/dist/chunk-5JAZXI47.mjs +1 -0
  34. package/dist/chunk-5SXPTNUM.mjs +1 -0
  35. package/dist/chunk-5YNIYMKX.mjs +1 -0
  36. package/dist/{chunk-VTOLKIBD.mjs → chunk-7PZN2RNE.mjs} +1 -1
  37. package/dist/chunk-ALW6WNDJ.mjs +1 -0
  38. package/dist/{chunk-ADRWR5GI.mjs → chunk-BH5BNULT.mjs} +1 -1
  39. package/dist/chunk-BZPWT44Z.mjs +1 -0
  40. package/dist/chunk-DAMF6ZWZ.mjs +1 -0
  41. package/dist/chunk-E7VH7WB5.mjs +1 -0
  42. package/dist/chunk-EBESPLST.mjs +1 -0
  43. package/dist/{chunk-SHYAV76M.mjs → chunk-ECGXE2Z6.mjs} +1 -1
  44. package/dist/chunk-EEU5J3CD.mjs +1 -0
  45. package/dist/chunk-FGJX74DI.mjs +1 -0
  46. package/dist/chunk-I3LFTKJP.mjs +1 -0
  47. package/dist/chunk-K4CIGHJI.mjs +1 -0
  48. package/dist/chunk-KYS76O3N.mjs +1 -0
  49. package/dist/chunk-LB66O2BP.mjs +1 -0
  50. package/dist/chunk-LEMLTB2X.mjs +1 -0
  51. package/dist/chunk-M2BCEQDP.mjs +1 -0
  52. package/dist/{chunk-44NLL6X3.mjs → chunk-MYEG7OXO.mjs} +1 -1
  53. package/dist/chunk-NMMTIZ6K.mjs +1 -0
  54. package/dist/chunk-NWQGXYER.mjs +1 -0
  55. package/dist/{chunk-BWBGZZG7.mjs → chunk-OBYCW4I3.mjs} +1 -1
  56. package/dist/chunk-ODZOYCTC.mjs +1 -0
  57. package/dist/{chunk-EKRMVMQ4.mjs → chunk-OOFTFGZL.mjs} +1 -1
  58. package/dist/chunk-OSUJWNS2.mjs +1 -0
  59. package/dist/chunk-PACB6IBR.mjs +1 -0
  60. package/dist/{chunk-3IS5RGG6.mjs → chunk-PGIWJ37M.mjs} +1 -1
  61. package/dist/{chunk-P5ESNJTD.mjs → chunk-PLRJ4GAR.mjs} +1 -1
  62. package/dist/{chunk-KF35YUNZ.mjs → chunk-QF5B6AYF.mjs} +1 -1
  63. package/dist/chunk-QKJPWA2I.mjs +1 -0
  64. package/dist/{chunk-4O6YFMWF.mjs → chunk-RBX7ANQX.mjs} +1 -1
  65. package/dist/chunk-RQHZNEA2.mjs +1 -0
  66. package/dist/{chunk-B5NNYNRA.mjs → chunk-SDXFJ7JW.mjs} +1 -1
  67. package/dist/{chunk-EHM2ZBQU.mjs → chunk-SKQA53J2.mjs} +1 -1
  68. package/dist/chunk-TJ25JLBL.mjs +1 -0
  69. package/dist/chunk-U522GPBG.mjs +1 -0
  70. package/dist/{chunk-5J4BZL6N.mjs → chunk-V5K4F2XQ.mjs} +1 -1
  71. package/dist/chunk-VGX6J2OP.mjs +1 -0
  72. package/dist/{chunk-EO3SHOXX.mjs → chunk-VPF4NHAP.mjs} +1 -1
  73. package/dist/{chunk-2EQSGPAN.mjs → chunk-WNCZCPTX.mjs} +1 -1
  74. package/dist/chunk-XMCHOGMG.mjs +1 -0
  75. package/dist/chunk-XNCN6DGG.mjs +30 -0
  76. package/dist/{chunk-2B62TYAL.mjs → chunk-XRM2KI4C.mjs} +1 -1
  77. package/dist/{chunk-YU5PF45T.mjs → chunk-YFXYRNER.mjs} +1 -1
  78. package/dist/{chunk-63F7KX4E.mjs → chunk-YZIDCW7A.mjs} +1 -1
  79. package/dist/chunk-Z32CLWW2.mjs +1 -0
  80. package/dist/{chunk-KCDHP4N3.mjs → chunk-ZCJCM3DT.mjs} +1 -1
  81. package/dist/{chunk-WIJSWSNF.mjs → chunk-ZE3LG7MR.mjs} +1 -1
  82. package/dist/chunk-ZEIVO4X7.mjs +1 -0
  83. package/dist/{chunk-44KCB7YO.mjs → chunk-ZQLNGMVV.mjs} +1 -1
  84. package/dist/cli.mjs +1 -1
  85. package/dist/codex-note-context-327LH622.mjs +1 -0
  86. package/dist/codex-project-25QJDNJN.mjs +1 -0
  87. package/dist/{codex-store-mount-FPS3CDO4.mjs → codex-store-mount-BRHVGYZU.mjs} +1 -1
  88. package/dist/{dev-server-D8Qxrp1A.d.mts → dev-server-C-mvGeOM.d.mts} +2 -2
  89. package/dist/dev-server-ZLIPCFFT.mjs +1 -0
  90. package/dist/{focus-inspection-FVQ6TVGA.mjs → focus-inspection-TPTEFBH3.mjs} +1 -1
  91. package/dist/guest-admission.mjs +1 -1
  92. package/dist/guest-live-canvas.mjs +1 -1
  93. package/dist/index.d.mts +7 -7
  94. package/dist/index.mjs +1 -1
  95. package/dist/{invitationLink-LUIIOAEZ.mjs → invitationLink-RX53O6RI.mjs} +1 -1
  96. package/dist/media.d.mts +3 -3
  97. package/dist/memory-store.d.mts +6 -6
  98. package/dist/{page-interaction-ZXM6ZLL4.mjs → page-interaction-6SR32FFS.mjs} +1 -1
  99. package/dist/{page-planes-BeFZ3Wso.d.mts → page-planes-C5J6qgMj.d.mts} +99 -50
  100. package/dist/{participantBootstrap-BcfNTEe9.d.mts → participantBootstrap-BjHfrdwL.d.mts} +3 -2
  101. package/dist/peer-client-2LEZ7SW4.mjs +1 -0
  102. package/dist/phone-recovery.mjs +1 -0
  103. package/dist/plugin-astro.d.mts +7 -7
  104. package/dist/plugin-astro.mjs +1 -1
  105. package/dist/plugin-next.mjs +1 -1
  106. package/dist/plugin-nuxt.d.mts +5 -5
  107. package/dist/plugin-nuxt.mjs +1 -1
  108. package/dist/plugin-vite.d.mts +8 -7
  109. package/dist/plugin-vite.mjs +1 -1
  110. package/dist/project-id.mjs +1 -0
  111. package/dist/{protocol-BIUE4rB6.d.mts → protocol-aJ3S127Q.d.mts} +5 -1
  112. package/dist/server.d.mts +15 -7
  113. package/dist/server.mjs +1 -1
  114. package/dist/shared-page-KQSG3DM3.mjs +1 -0
  115. package/dist/{subjects-qHIrZrlt.d.mts → subjects-CGN4QTSS.d.mts} +1 -1
  116. package/dist/{video-adapter-B5eap10v.d.mts → video-adapter-DtIw_QVy.d.mts} +1 -1
  117. package/dist/{workspace-snapshot-RUGPDEYJ.mjs → workspace-snapshot-DX62ZFVF.mjs} +1 -1
  118. package/infra/phone-pairing/machine-config.mjs +15 -2
  119. package/infra/phone-pairing/machine-service.mjs +39 -13
  120. package/infra/phone-pairing/managed-install.mjs +8 -2
  121. package/package.json +1 -1
  122. package/dist/PagePreviewLayer-FHYXOFOZ.mjs +0 -1
  123. package/dist/ParticipantRuntime-NY7N7HFZ.mjs +0 -1
  124. package/dist/PhoneHostGate-RXW6DVQD.mjs +0 -1
  125. package/dist/PopmeltTasteConnectedPane-6T3F6ZNL.mjs +0 -1
  126. package/dist/SamplePlacementOverlay-K3Z5C67A.mjs +0 -1
  127. package/dist/ShareProjectPane-AFQS4SEM.mjs +0 -1
  128. package/dist/SuppliedContext-V62BO3EY.mjs +0 -1
  129. package/dist/ThreadPanel-ZXEPKB2P.mjs +0 -1
  130. package/dist/browser-runtime-FFURXKEP.mjs +0 -1
  131. package/dist/canvas-chat-note-RGALD6IH.mjs +0 -1
  132. package/dist/chunk-2F2BVGFH.mjs +0 -1
  133. package/dist/chunk-2IPPW6IP.mjs +0 -1
  134. package/dist/chunk-4XBW5E6L.mjs +0 -1
  135. package/dist/chunk-5GQXAV54.mjs +0 -30
  136. package/dist/chunk-6VZCE37E.mjs +0 -1
  137. package/dist/chunk-72CUIZA2.mjs +0 -1
  138. package/dist/chunk-7NXVLIDS.mjs +0 -1
  139. package/dist/chunk-7XGXFP5L.mjs +0 -1
  140. package/dist/chunk-BDSIJTX5.mjs +0 -1
  141. package/dist/chunk-C2ZSNUXQ.mjs +0 -1
  142. package/dist/chunk-DLXTHDBS.mjs +0 -1
  143. package/dist/chunk-EILBHZDX.mjs +0 -1
  144. package/dist/chunk-FLHUSWSY.mjs +0 -1
  145. package/dist/chunk-FQRYGTZ3.mjs +0 -1
  146. package/dist/chunk-HAZXZ5TU.mjs +0 -1
  147. package/dist/chunk-JXXK3Z5E.mjs +0 -1
  148. package/dist/chunk-KNMBEVHX.mjs +0 -1
  149. package/dist/chunk-MBEFYXSZ.mjs +0 -1
  150. package/dist/chunk-OTMGCIRL.mjs +0 -1
  151. package/dist/chunk-PRZ6C5X3.mjs +0 -1
  152. package/dist/chunk-QRFIQC2P.mjs +0 -1
  153. package/dist/chunk-RWZ7SVMO.mjs +0 -1
  154. package/dist/chunk-SOGN7S54.mjs +0 -1
  155. package/dist/chunk-SUAHDXJZ.mjs +0 -1
  156. package/dist/chunk-TMW3SI7F.mjs +0 -1
  157. package/dist/chunk-TNVYP6S4.mjs +0 -1
  158. package/dist/chunk-UFU5IA3G.mjs +0 -1
  159. package/dist/chunk-UNUYNWTJ.mjs +0 -1
  160. package/dist/chunk-VLTK7KWK.mjs +0 -1
  161. package/dist/chunk-WMCWSV2W.mjs +0 -1
  162. package/dist/chunk-WVGFWHL3.mjs +0 -1
  163. package/dist/chunk-YIKAZQRM.mjs +0 -1
  164. package/dist/codex-note-context-ECY4QU74.mjs +0 -1
  165. package/dist/codex-project-J7C4YAM2.mjs +0 -1
  166. package/dist/dev-server-5CHO7PTQ.mjs +0 -1
  167. package/dist/peer-client-4WNS5XZ4.mjs +0 -1
  168. package/dist/shared-page-3AVCYUOT.mjs +0 -1
  169. /package/dist/{chunk-CIKFUS7J.mjs → chunk-R565ZNSP.mjs} +0 -0
  170. /package/dist/{chunk-RG2CK6VE.mjs → chunk-XBA5ROC5.mjs} +0 -0
  171. /package/dist/{toolbarFonts-33BI56VQ.mjs → toolbarFonts-RR24L4CJ.mjs} +0 -0
  172. /package/dist/{webpEncoder-JVMGDKHV.mjs → webpEncoder-XTISHUBA.mjs} +0 -0
package/dist/server.d.mts CHANGED
@@ -1,16 +1,16 @@
1
- import { a as ParticipantAgentAdapter, b as ParticipantCredential, P as PopmeltHandle, d as ParticipantPlaneApps, e as PopmeltOptions, f as PhoneApp, g as PageFramework, N as NextBundlerFlag, G as GuestAppRequest, h as PeerSessions, i as PeerShape } from './page-planes-BeFZ3Wso.mjs';
2
- export { j as ParticipantAgentView, k as createParticipantGuestAccess, c as createParticipantPlaneApps } from './page-planes-BeFZ3Wso.mjs';
3
- import { f as ParticipantBootstrapConfig } from './participantBootstrap-BcfNTEe9.mjs';
1
+ import { a as ParticipantAgentAdapter, b as ParticipantCredential, P as PopmeltHandle, d as ParticipantPlaneApps, e as PopmeltOptions, f as PhoneApp, g as PageFramework, N as NextBundlerFlag, G as GuestAppRequest, h as PeerSessions, i as PeerShape } from './page-planes-C5J6qgMj.mjs';
2
+ export { j as ParticipantAgentView, k as createParticipantGuestAccess, c as createParticipantPlaneApps } from './page-planes-C5J6qgMj.mjs';
3
+ import { f as ParticipantBootstrapConfig } from './participantBootstrap-BjHfrdwL.mjs';
4
4
  import * as node_http from 'node:http';
5
5
  import { IncomingMessage, ServerResponse } from 'node:http';
6
6
  import { c as ImprintGraph, d as ImprintTransaction, e as ImprintMutation, f as ImprintContext, g as ImprintSummaryKind, h as ImprintExplanationKind, i as ImprintScope, j as ImprintTopologyRelationType, k as ImprintExplanationRef, I as ImprintThreadSummary, a as ImprintGroundingAction, l as ImprintRelation, Q as QualifiedImprintRelation } from './types-XKO-uva0.mjs';
7
7
  export { m as ImprintConcrete, n as ImprintEvidence, o as ImprintExplanation, p as ImprintExplanationState, q as ImprintRelationType } from './types-XKO-uva0.mjs';
8
8
  import 'vite';
9
- import './protocol-BIUE4rB6.mjs';
10
- import './PopmeltProvider-5g-1VH5a.mjs';
9
+ import './protocol-aJ3S127Q.mjs';
10
+ import './subjects-CGN4QTSS.mjs';
11
+ import './PopmeltProvider-NwqjKtGG.mjs';
11
12
  import 'react';
12
- import './subjects-qHIrZrlt.mjs';
13
- import './video-adapter-B5eap10v.mjs';
13
+ import './video-adapter-DtIw_QVy.mjs';
14
14
 
15
15
  /** One disposable, local Chrome profile per agent. Never attaches to a user's browser. */
16
16
  declare function managedParticipantBrowser(url: string): ParticipantAgentAdapter;
@@ -282,6 +282,13 @@ declare function startDevelopmentSession(options: {
282
282
  port: number;
283
283
  projectId: string;
284
284
  storeId?: string;
285
+ guestRecoveryUrl?: () => string | undefined;
286
+ redeemGuestHandoff?: (ticket: string, origin: string) => Promise<{
287
+ bookmark: string;
288
+ credential: ParticipantCredential;
289
+ sharedPath: string;
290
+ }>;
291
+ checkGuestBookmark?: (bookmark: string) => Promise<void>;
285
292
  visitGuestInvite?: PeerSessions["visitGuestInvite"];
286
293
  guestInviteAppearance?: (invitation: string) => Promise<{
287
294
  projectName?: string;
@@ -292,6 +299,7 @@ declare function startDevelopmentSession(options: {
292
299
  id: string;
293
300
  revision?: string;
294
301
  }>;
302
+ remoteGuestAvailable?: () => boolean;
295
303
  participantHost?: () => Promise<ParticipantCredential>;
296
304
  }>;
297
305
 
package/dist/server.mjs CHANGED
@@ -1 +1 @@
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};
1
+ import{a as t,b as s,c as m}from"./chunk-XMCHOGMG.mjs";import"./chunk-WNCZCPTX.mjs";import"./chunk-PCUUOIFD.mjs";import"./chunk-YZIDCW7A.mjs";import{h as a,i as r,j as i,k as p}from"./chunk-XNCN6DGG.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,e,f as u}from"./chunk-TJ25JLBL.mjs";import{b as h}from"./chunk-NMMTIZ6K.mjs";import"./chunk-HKHZBKAN.mjs";import"./chunk-R565ZNSP.mjs";import"./chunk-ZEIVO4X7.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,h 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-YZIDCW7A.mjs";import"./chunk-HKHZBKAN.mjs";import"./chunk-R565ZNSP.mjs";import"./chunk-KF73S7MG.mjs";export{r as createSharedPageReader,a as sharedPagePath};
@@ -625,4 +625,4 @@ type PopmeltSubjectAdapter = {
625
625
  removeSubject?(key: string): void;
626
626
  };
627
627
 
628
- export type { Annotation as A, BridgeStatus as B, CanvasSampleCodec as C, DomModification as D, ElementInfo as E, ImageObjectContext as I, OpaqueTargetReference as O, PopmeltSubjectAdapter as P, ReactSourceLocation as R, SubjectFeedbackAttachment as S, TextModification as T, VideoObjectContext as V, PopmeltSubjectBounds as a, PopmeltSubject as b, PopmeltSubjectCreationSession as c, PopmeltSubjectOutlinePoint as d, PopmeltSubjectTrackingAnchor as e, AnnotationAttachment as f, StyleModification as g, SpacingTokenChange as h, AnnotationRegion as i, AnnotationType as j, ClaudeResponse as k, Point as l, PopmeltSurfaceSnapshot as m, StyleChange as n, ToolType as o, StickerFamily as p, StickerSubproperty as q, AnnotationState as r };
628
+ export type { Annotation as A, BridgeStatus as B, CanvasSampleCodec as C, DomModification as D, ElementInfo as E, ImageObjectContext as I, OpaqueTargetReference as O, PopmeltSubjectAdapter as P, ReactSourceLocation as R, SubjectFeedbackAttachment as S, TextModification as T, VideoObjectContext as V, PopmeltSubjectBounds as a, PopmeltSubject as b, PopmeltSubjectCreationSession as c, PopmeltSubjectOutlinePoint as d, PopmeltSubjectTrackingAnchor as e, AnnotationAttachment as f, StyleModification as g, SpacingTokenChange as h, AnnotationRegion as i, AnnotationType as j, ClaudeResponse as k, Point as l, PopmeltSurfaceSnapshot as m, StyleChange as n, ToolType as o, AnnotationState as p, StickerFamily as q, StickerSubproperty as r };
@@ -1,4 +1,4 @@
1
- import { P as PopmeltSubjectAdapter, b as PopmeltSubject, E as ElementInfo, c as PopmeltSubjectCreationSession, a as PopmeltSubjectBounds, d as PopmeltSubjectOutlinePoint, e as PopmeltSubjectTrackingAnchor } from './subjects-qHIrZrlt.mjs';
1
+ import { P as PopmeltSubjectAdapter, b as PopmeltSubject, E as ElementInfo, c as PopmeltSubjectCreationSession, a as PopmeltSubjectBounds, d as PopmeltSubjectOutlinePoint, e as PopmeltSubjectTrackingAnchor } from './subjects-CGN4QTSS.mjs';
2
2
 
3
3
  /** Geometry is normalized against the loaded image, not its rendered size. */
4
4
  type ImageObjectBox = {
@@ -1 +1 @@
1
- "use client";import{b as t}from"./chunk-HAZXZ5TU.mjs";import{f as e}from"./chunk-AAMUU2QA.mjs";import{v as n,d as a,o as i}from"./chunk-LH7HKUCK.mjs";import"./chunk-YGP6PPOZ.mjs";function r(t,e){let n=t.filter(t=>!(e.kind&&t.kind!==e.kind||e.entryId&&t.id!==e.entryId||e.pathname&&t.pathname!==e.pathname)),a=Number.isInteger(e.limit)?Math.min(50,Math.max(1,e.limit)):20,i=Number.isInteger(e.offset)?Math.max(0,e.offset):0;return{entries:n.slice(i,i+a).map(({details:t,...n})=>e.entryId?{...n,details:t}:n),total:n.length,nextOffset:i+a<n.length?i+a:null}}function o(r,o,s,d=!1){if(!r||!o)return null;let c=e=>{let n=a(e),r=t(e),o=t=>t.width>0&&t.height>0&&t.bottom>0&&t.right>0&&t.top<innerHeight&&t.left<innerWidth;return e.isConnected&&n.width>0&&n.height>0&&(d||o(n)||!!r&&o(r))&&!i(e,'[data-popmelt-private], [aria-hidden="true"]')},u=t=>{try{let e=t?document.querySelectorAll(t):[];return 1===e.length?e[0]:null}catch{return null}};if(o.startsWith("thread:")){let t=o.slice(7),a=[...document.querySelectorAll("[data-popmelt-thread-id]")].filter(e=>e.getAttribute("data-popmelt-thread-id")===t&&c(e));if(1===a.length)return a[0].querySelector("[data-popmelt-thread-header]");let i=r.annotations.filter(n=>n.threadId===t&&(!n.pathname||n.pathname===e(location.pathname))),l=new Set(i.map(t=>t.target?s.resolve(t.target)?.element??null:n(t.linkedSelector,t.elements?.[0])).filter(t=>!!t&&c(t)));return 1===l.size?[...l][0]:null}let m=l(r,{entryId:o});if(!("entries"in m)||1!==m.entries.length)return null;let h=m.entries[0];if(h.pathname&&h.pathname!==e(location.pathname))return null;let p=r.annotations.find(t=>`draft:${t.id}`===o);if(p?.target){let t=s.resolve(p.target)?.element;return t&&c(t)?t:null}let f="details"in h?h.details:void 0,g=[...r.styleModifications,...r.textModifications].find(t=>t.selector===h.selector),k=p?.elements?.[0]??g?.element,y=k?n(h.selector,{...k,selector:f?.durableSelector??k.selector}):u(h.selector)??u(f?.durableSelector);return y&&c(y)?y:null}function l(t,n={}){if(!t)return{status:"unavailable",reason:"browser_state_unavailable"};let a=[];for(let e of t.annotations)"pending"===(e.status??(e.captured?"resolved":"pending"))&&a.push({id:`draft:${e.id}`,kind:"draft",status:"unsubmitted",summary:(e.text||`${e.type} annotation`).slice(0,200),pathname:e.pathname,selector:e.linkedSelector,target:e.target,threadId:e.threadId,updatedAt:e.timestamp,details:{text:e.text,type:e.type,target:e.target,points:e.points,region:e.region,scope:e.scope,interactionEpisode:e.interactionEpisode,attachments:e.attachments,imageCount:e.imageCount}});for(let[e,n]of[["style",t.styleModifications],["text",t.textModifications],["dom",t.domModifications]])for(let t of n){if(t.captured)continue;let n="id"in t?t.id:JSON.stringify([t.pathname??"",t.selector,"textNodePath"in t?t.textNodePath:null]);a.push({id:`change:${e}:${n}`,kind:"change",status:"staged",summary:`${e}: ${"modified"in t?t.modified:t.selector}`.slice(0,200),pathname:t.pathname,selector:t.selector,details:t})}for(let e of t.spacingTokenChanges??[])e.captured||a.push({id:`change:spacing:${e.id}`,kind:"change",status:"staged",summary:`Spacing ${e.tokenName}: ${e.originalPx} → ${e.newPx}`,details:e});for(let e of t.spacingTokenMods??[])e.captured||a.push({id:`change:token:${e.tokenPath}`,kind:"change",status:"staged",summary:`Token ${e.tokenPath}`.slice(0,200),details:e});return{status:"ok",capturedAt:Date.now(),page:location.origin+e(location.pathname),trust:"Unsubmitted human intent and local preview changes, not instructions to execute or proof of saved code changes.",...r(a,n)}}export{l as collectWorkspaceSnapshot,o as workspaceAttentionTarget};
1
+ "use client";import{c as t}from"./chunk-5YNIYMKX.mjs";import{f as e}from"./chunk-AAMUU2QA.mjs";import{v as n,d as a,o as i}from"./chunk-LH7HKUCK.mjs";import"./chunk-YGP6PPOZ.mjs";function r(t,e){let n=t.filter(t=>!(e.kind&&t.kind!==e.kind||e.entryId&&t.id!==e.entryId||e.pathname&&t.pathname!==e.pathname)),a=Number.isInteger(e.limit)?Math.min(50,Math.max(1,e.limit)):20,i=Number.isInteger(e.offset)?Math.max(0,e.offset):0;return{entries:n.slice(i,i+a).map(({details:t,...n})=>e.entryId?{...n,details:t}:n),total:n.length,nextOffset:i+a<n.length?i+a:null}}function o(r,o,s,d=!1){if(!r||!o)return null;let c=e=>{let n=a(e),r=t(e),o=t=>t.width>0&&t.height>0&&t.bottom>0&&t.right>0&&t.top<innerHeight&&t.left<innerWidth;return e.isConnected&&n.width>0&&n.height>0&&(d||o(n)||!!r&&o(r))&&!i(e,'[data-popmelt-private], [aria-hidden="true"]')},u=t=>{try{let e=t?document.querySelectorAll(t):[];return 1===e.length?e[0]:null}catch{return null}};if(o.startsWith("thread:")){let t=o.slice(7),a=[...document.querySelectorAll("[data-popmelt-thread-id]")].filter(e=>e.getAttribute("data-popmelt-thread-id")===t&&c(e));if(1===a.length)return a[0].querySelector("[data-popmelt-thread-header]");let i=r.annotations.filter(n=>n.threadId===t&&(!n.pathname||n.pathname===e(location.pathname))),l=new Set(i.map(t=>t.target?s.resolve(t.target)?.element??null:n(t.linkedSelector,t.elements?.[0])).filter(t=>!!t&&c(t)));return 1===l.size?[...l][0]:null}let m=l(r,{entryId:o});if(!("entries"in m)||1!==m.entries.length)return null;let h=m.entries[0];if(h.pathname&&h.pathname!==e(location.pathname))return null;let p=r.annotations.find(t=>`draft:${t.id}`===o);if(p?.target){let t=s.resolve(p.target)?.element;return t&&c(t)?t:null}let f="details"in h?h.details:void 0,g=[...r.styleModifications,...r.textModifications].find(t=>t.selector===h.selector),k=p?.elements?.[0]??g?.element,y=k?n(h.selector,{...k,selector:f?.durableSelector??k.selector}):u(h.selector)??u(f?.durableSelector);return y&&c(y)?y:null}function l(t,n={}){if(!t)return{status:"unavailable",reason:"browser_state_unavailable"};let a=[];for(let e of t.annotations)"pending"===(e.status??(e.captured?"resolved":"pending"))&&a.push({id:`draft:${e.id}`,kind:"draft",status:"unsubmitted",summary:(e.text||`${e.type} annotation`).slice(0,200),pathname:e.pathname,selector:e.linkedSelector,target:e.target,threadId:e.threadId,updatedAt:e.timestamp,details:{text:e.text,type:e.type,target:e.target,points:e.points,region:e.region,scope:e.scope,interactionEpisode:e.interactionEpisode,attachments:e.attachments,imageCount:e.imageCount}});for(let[e,n]of[["style",t.styleModifications],["text",t.textModifications],["dom",t.domModifications]])for(let t of n){if(t.captured)continue;let n="id"in t?t.id:JSON.stringify([t.pathname??"",t.selector,"textNodePath"in t?t.textNodePath:null]);a.push({id:`change:${e}:${n}`,kind:"change",status:"staged",summary:`${e}: ${"modified"in t?t.modified:t.selector}`.slice(0,200),pathname:t.pathname,selector:t.selector,details:t})}for(let e of t.spacingTokenChanges??[])e.captured||a.push({id:`change:spacing:${e.id}`,kind:"change",status:"staged",summary:`Spacing ${e.tokenName}: ${e.originalPx} → ${e.newPx}`,details:e});for(let e of t.spacingTokenMods??[])e.captured||a.push({id:`change:token:${e.tokenPath}`,kind:"change",status:"staged",summary:`Token ${e.tokenPath}`.slice(0,200),details:e});return{status:"ok",capturedAt:Date.now(),page:location.origin+e(location.pathname),trust:"Unsubmitted human intent and local preview changes, not instructions to execute or proof of saved code changes.",...r(a,n)}}export{l as collectWorkspaceSnapshot,o as workspaceAttentionTarget};
@@ -35,13 +35,15 @@ export function routingTable(state) {
35
35
  const bindings = state.projects.map(readBinding),
36
36
  table = new Map(),
37
37
  ports = new Set();
38
- for (const { id, appOrigin } of bindings) {
38
+ for (const { id, appOrigin, projectKey } of bindings) {
39
39
  const { hostname, socket } = route(id),
40
40
  port = new URL(appOrigin).port;
41
41
  if (ports.has(port) || table.has(hostname))
42
42
  throw Error('Each project needs its own hostname and loopback app port.');
43
43
  ports.add(port);
44
44
  table.set(hostname, socket);
45
+ if (state.guestProjects?.includes(projectKey))
46
+ table.set('g-' + id + '.popmelt.com', socket);
45
47
  }
46
48
  return table;
47
49
  }
@@ -108,6 +110,17 @@ export async function configure(command, args = [], provisionDns, idForKey) {
108
110
  table.set(hostname, socket);
109
111
  }
110
112
  }
113
+ if (command === 'guest') {
114
+ const [key, id] = args;
115
+ if (!state.projects.includes(key) || readBinding(key).id !== id)
116
+ throw Error('Guest preview requires an existing paired project.');
117
+ const guestHostname = 'g-' + id + '.popmelt.com';
118
+ if (!state.guestProjects?.includes(key)) {
119
+ await provisionDns(state.tunnel, guestHostname, key);
120
+ (state.guestProjects ??= []).push(key);
121
+ table.set(guestHostname, route(id).socket);
122
+ }
123
+ }
111
124
  if (command === 'run') state.liveRouting = true;
112
125
  const ingress = state.liveRouting
113
126
  ? [{ hostname: '*.popmelt.com', service: 'unix:' + routerSocket }]
@@ -144,7 +157,7 @@ export async function configure(command, args = [], provisionDns, idForKey) {
144
157
  return {
145
158
  tunnel: state.tunnel,
146
159
  config,
147
- projects: table.size,
160
+ projects: state.projects.length,
148
161
  ...(project && route(project.id)),
149
162
  };
150
163
  });
@@ -132,7 +132,13 @@ export async function serve(registerDns = provisionDns, idForKey) {
132
132
  res.setHeader('Cache-Control', 'private, no-store');
133
133
  if (
134
134
  req.headers.origin === 'https://pair.popmelt.com' &&
135
- ['/__pair/options', '/__pair/finish'].includes(req.url)
135
+ [
136
+ '/__pair/options',
137
+ '/__pair/finish',
138
+ '/__pair/guest/options',
139
+ '/__pair/guest/finish',
140
+ '/__pair/guest/destination',
141
+ ].includes(req.url)
136
142
  ) {
137
143
  res.setHeader('Access-Control-Allow-Origin', req.headers.origin);
138
144
  res.setHeader('Vary', 'Origin');
@@ -150,6 +156,20 @@ export async function serve(registerDns = provisionDns, idForKey) {
150
156
  req.method === 'GET' &&
151
157
  req.headers['sec-fetch-mode'] === 'navigate'
152
158
  ) {
159
+ const guest = /^g-([a-f0-9]{32})\.popmelt\.com$/.exec(
160
+ req.headers.host,
161
+ )?.[1];
162
+ if (guest) {
163
+ res.setHeader('Retry-After', '3');
164
+ return res
165
+ .writeHead(503, {
166
+ 'Content-Type': 'text/html; charset=utf-8',
167
+ 'Content-Security-Policy': "default-src 'none'",
168
+ })
169
+ .end(
170
+ '<!doctype html><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="refresh" content="3"><title>Project reconnecting</title><p>The shared project is restarting. This tab will retry.</p>',
171
+ );
172
+ }
153
173
  const id = /^p-([a-f0-9]{32})\.popmelt\.com$/.exec(
154
174
  req.headers.host,
155
175
  )?.[1];
@@ -167,7 +187,7 @@ export async function serve(registerDns = provisionDns, idForKey) {
167
187
  const closeHmr = serveViteHmr(router, (req) => {
168
188
  const host = req.headers.host;
169
189
  const socketPath = routes.get(host);
170
- if (socketPath && req.headers.cookie)
190
+ if (socketPath && host.startsWith('p-') && req.headers.cookie)
171
191
  return { host, socketPath, cookie: req.headers.cookie };
172
192
  });
173
193
  // Serialize adds, including the DNS operation. Duplicate clicks reuse the
@@ -176,7 +196,7 @@ export async function serve(registerDns = provisionDns, idForKey) {
176
196
  const control = createServer({ requestTimeout: 10000 }, async (req, res) => {
177
197
  if (
178
198
  req.method !== 'POST' ||
179
- req.url !== '/projects' ||
199
+ !['/projects', '/guest-project'].includes(req.url) ||
180
200
  req.headers['content-type'] !== 'application/json'
181
201
  ) {
182
202
  res.writeHead(404).end();
@@ -190,27 +210,33 @@ export async function serve(registerDns = provisionDns, idForKey) {
190
210
  if (size > 8192) throw Error('Invalid project registration.');
191
211
  chunks.push(chunk);
192
212
  }
193
- const { root, origin, reconnectId } = JSON.parse(
213
+ const { root, origin, reconnectId, key, id } = JSON.parse(
194
214
  Buffer.concat(chunks).toString('utf8'),
195
215
  );
216
+ const guest = req.url === '/guest-project';
196
217
  if (
197
- typeof root !== 'string' ||
198
- !isAbsolute(root) ||
199
- typeof origin !== 'string' ||
200
- (reconnectId !== undefined &&
201
- (typeof reconnectId !== 'string' ||
202
- !/^[0-9a-f]{32}$/.test(reconnectId)))
218
+ guest
219
+ ? typeof key !== 'string' ||
220
+ !/^[0-9a-f]{64}$/.test(key) ||
221
+ typeof id !== 'string' ||
222
+ !/^[0-9a-f]{32}$/.test(id)
223
+ : typeof root !== 'string' ||
224
+ !isAbsolute(root) ||
225
+ typeof origin !== 'string' ||
226
+ (reconnectId !== undefined &&
227
+ (typeof reconnectId !== 'string' ||
228
+ !/^[0-9a-f]{32}$/.test(reconnectId)))
203
229
  )
204
230
  throw Error('Invalid project registration.');
205
231
  const added = tail.then(async () => {
206
232
  const result = await configure(
207
- 'add',
208
- [root, origin, reconnectId],
233
+ guest ? 'guest' : 'add',
234
+ guest ? [key, id] : [root, origin, reconnectId],
209
235
  registerDns,
210
236
  idForKey,
211
237
  );
212
238
  routes = routingTable(readState());
213
- return result;
239
+ return guest ? { id, hostname: 'g-' + id + '.popmelt.com' } : result;
214
240
  });
215
241
  tail = added.catch(() => {});
216
242
  const result = await added;
@@ -132,11 +132,17 @@ export async function managedDns() {
132
132
  return {
133
133
  idForKey: (key) => projectId(deviceId, key),
134
134
  register: async (tunnel, hostname, key) => {
135
- const result = await send(device, '/v1/project', { project: key });
135
+ const guest =
136
+ hostname === 'g-' + projectId(deviceId, key) + '.popmelt.com';
137
+ const result = await send(device, '/v1/project', {
138
+ project: key,
139
+ ...(guest && { guest: true }),
140
+ });
136
141
  if (
137
142
  result.tunnel !== tunnel ||
138
143
  result.id !== projectId(deviceId, key) ||
139
- hostname !== 'p-' + result.id + '.popmelt.com'
144
+ hostname !== (guest ? 'g-' : 'p-') + result.id + '.popmelt.com' ||
145
+ (guest && result.guest !== true)
140
146
  )
141
147
  throw Error('Could not verify the project registration.');
142
148
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popmelt.com/core",
3
- "version": "0.41.2",
3
+ "version": "0.42.0",
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)",
@@ -1 +0,0 @@
1
- "use client";export{f as PagePreviewLayer}from"./chunk-44KCB7YO.mjs";import"./chunk-4XBW5E6L.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-SHYAV76M.mjs";import"./chunk-WMCWSV2W.mjs";import"./chunk-7NXVLIDS.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-YGP6PPOZ.mjs";
@@ -1 +0,0 @@
1
- "use client";import{d as t,b as e,c as o,a as r}from"./chunk-KNMBEVHX.mjs";import"./chunk-UFU5IA3G.mjs";import"./chunk-EO3SHOXX.mjs";import{f as i}from"./chunk-FLHUSWSY.mjs";import"./chunk-RXC7B7SX.mjs";import"./chunk-B5NNYNRA.mjs";import"./chunk-FQRYGTZ3.mjs";import"./chunk-SOGN7S54.mjs";import"./chunk-2B62TYAL.mjs";import"./chunk-P5ESNJTD.mjs";import"./chunk-B4RLDY5H.mjs";import"./chunk-PH2MLB3T.mjs";import"./chunk-2IPPW6IP.mjs";import"./chunk-XTOCFTVW.mjs";import"./chunk-EHM2ZBQU.mjs";import{a as n}from"./chunk-YU5PF45T.mjs";import{h as a,X as s}from"./chunk-MBEFYXSZ.mjs";import"./chunk-PRZ6C5X3.mjs";import"./chunk-VOL4KS67.mjs";import"./chunk-VLTK7KWK.mjs";import"./chunk-VTOLKIBD.mjs";import"./chunk-G2ZHJXHZ.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-TMW3SI7F.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{e as c,g as l,f as p}from"./chunk-AAMUU2QA.mjs";import"./chunk-LH7HKUCK.mjs";import{a as m}from"./chunk-OTMGCIRL.mjs";import{b as h,f as u,c as d,d as f}from"./chunk-JXXK3Z5E.mjs";import{p as j}from"./chunk-3IS5RGG6.mjs";import"./chunk-DUWONLQE.mjs";import"./chunk-ATLUO4G7.mjs";import"./chunk-6VZCE37E.mjs";import"./chunk-C2ZSNUXQ.mjs";import"./chunk-EILBHZDX.mjs";import"./chunk-EKRMVMQ4.mjs";import"./chunk-ZVDKW7TO.mjs";import"./chunk-HQVWOBYH.mjs";import"./chunk-Q6C7ZA3H.mjs";import"./chunk-OREALBUO.mjs";import"./chunk-CK3CDA3L.mjs";import{c as k,a as g}from"./chunk-SHYAV76M.mjs";import"./chunk-WMCWSV2W.mjs";import{V as w}from"./chunk-KE4MQBRY.mjs";import"./chunk-B4DYUYX4.mjs";import"./chunk-7NXVLIDS.mjs";import"./chunk-ADRWR5GI.mjs";import{b as S}from"./chunk-SUAHDXJZ.mjs";import"./chunk-PRPXMDZ7.mjs";import"./chunk-YGP6PPOZ.mjs";import{useState as y,useSyncExternalStore as v,useEffect as I}from"react";import{jsx as P,jsxs as O}from"react/jsx-runtime";function H(t,i){let n,a={phase:"starting"},m=0,j=!1,k=!1,g=0,w=new Set,y=`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,O=e=>history.replaceState({...history.state,popmeltGuestEntry:t.projectId},"",e),H=t=>fetch("/__popmelt/host",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(t),redirect:"error"}),A=async(e={},o=!1,r)=>{if(S(t.url))return null;let i=await H(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),U;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 H({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()},U=Symbol("navigating"),b=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 U;let i=c(location.pathname);if(r.author.id===a.participantId&&"host"===r.author.relationship&&!S(t.url)){if("/"!==i){let t=new URL(location.href);throw t.pathname=p(t.pathname),location.replace(t.href),U}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 U;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(y,JSON.stringify(a)),location.replace(m+location.search+location.hash),U;return n.application.basis??t.revision}:void 0}).catch(t=>{if(t!==U)throw t});if(m){if(k||s!==g)return void m.dispose();try{localStorage.setItem(y,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}),A({credential:a}).catch(()=>{})}},R=()=>{O(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?O(e.href):e.href!==location.href&&history.replaceState(history.state,"",e);let i=null;if(r){if(i=await A({token:r}),!i&&!t.token&&(i=await A({},!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(y)??"null")}catch{}i??(i=await A({},!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 b(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 R();if(401!==o.status)throw o;let a=await A({},!r&&!t.token,i.participantId);return void(a?await b(a):R())}})().catch(t=>{t!==U&&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:R,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 b(i.joined.credential,r)}},admit:t=>b(t)}}function A({config:r,loadOwnSource:s,children:p}){let[h]=y(()=>H(r,s)),u=a(),d=v(h.subscribe,h.getSnapshot,h.getSnapshot);I(()=>h.retain(),[h]);let[f,A,U]=k(),b="connected"===d.phase?d.connection:null;if(I(()=>{if(!b||!r.planeApps)return;let t,i=new AbortController,n=b.isHost&&!S(r.url)&&"/"===c(location.pathname),a=n?void 0:r.appVersion,s=async()=>{try{let t=await e(b.credential,b.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(b.isHost&&!S(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 b.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,b,u]),b)return P(t,{connection:b,codePreviewUrl:location.href,planeApps:r.planeApps,onAccessRemoved:h.removed,children:p});let R="starting"===d.phase||"error"===d.phase,E="entry"===d.phase?d.invitation:null;return P(n,{children:P("div",{"data-devtools":"participant-entry",style:{display:"contents",pointerEvents:"auto"},children:R?P(i,{entry:{theme:f,themePreference:U,onThemePreferenceChange:A,ariaLabel:"starting"===d.phase?"Popmelt connecting":"Popmelt disconnected",action:null,logoOnly:!0,connected:!1,connection:O("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)&&!S(r.url)&&"/"===c(location.pathname),client:h.client,storage:localStorage,storageKey:`popmelt-admission:${r.projectId}`,theme:f,themePreference:U,onThemePreferenceChange:A,onAdmitted:h.admit,onJoin:E?h.join:void 0},E??"request-access")})})}export{A as default};
@@ -1 +0,0 @@
1
- "use client";import{a as r,d as o}from"./chunk-KNMBEVHX.mjs";import"./chunk-UFU5IA3G.mjs";import"./chunk-EO3SHOXX.mjs";import"./chunk-FQRYGTZ3.mjs";import"./chunk-SOGN7S54.mjs";import"./chunk-2IPPW6IP.mjs";import"./chunk-EHM2ZBQU.mjs";import"./chunk-MBEFYXSZ.mjs";import"./chunk-PRZ6C5X3.mjs";import"./chunk-VOL4KS67.mjs";import"./chunk-VLTK7KWK.mjs";import"./chunk-VTOLKIBD.mjs";import"./chunk-G2ZHJXHZ.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-TMW3SI7F.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-JXXK3Z5E.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-SHYAV76M.mjs";import{j as t}from"./chunk-WMCWSV2W.mjs";import"./chunk-KE4MQBRY.mjs";import"./chunk-B4DYUYX4.mjs";import{b as n,f as i,h as e,c as m,e as c,a as p}from"./chunk-7NXVLIDS.mjs";import"./chunk-ADRWR5GI.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-PRPXMDZ7.mjs";import"./chunk-YGP6PPOZ.mjs";import{useState as s,useEffect as h,cloneElement as u}from"react";import{jsxs as j,jsx as a,Fragment as d}from"react/jsx-runtime";function k({children:k,projectId:l,participantConfig:f}){let[I,g]=s(null),[H,P]=s(""),[S,U]=s(!1),[Z,X]=s(0),b=n();if(h(()=>{let o,n,c=!1;return g(null),P(""),U(!1),i(l).then(async i=>{if(c)return;let s=location.origin+p;n=e(s,i,b?U:void 0);let h=await t(s);if(!h)throw new Error("Could not reach the project bridge.");if(h.projectId!==i.projectId)throw new m("This bridge belongs to another project.");if(!c){if(h.phoneParticipantId)o=await r({projectId:i.projectId,bridgeUrl:s,credential:{participantId:h.phoneParticipantId,token:""},runtimeStorage:sessionStorage,observedSource:{sourceId:i.projectId,revision:f?.revision??"unversioned"}});else if(f)throw new Error("This phone is not connected to the multiplayer host.");c?o?.dispose():g({bridgeUrl:s,projectId:i.projectId,connection:o})}}).catch(r=>{n?.(),c||(r instanceof m&&b&&U(!0),P(r instanceof Error?r.message:"Phone pairing failed."))}),()=>{c=!0,o?.dispose(),n?.()}},[l,f,Z,b]),H&&!b)return j("p",{role:"alert","data-devtools":"phone-pairing-error",children:[H," ",a("button",{type:"button",onClick:c,children:"Forget this pairing"})]});let K=I&&u(k,{bridgeUrl:I.bridgeUrl,projectId:I.projectId}),O=I?.connection?a(o,{connection:I.connection,onAccessRemoved:c,children:K}):K;return j(d,{children:[O,b&&(S||H)&&a("div",{role:"alert","data-devtools":"phone-pairing-error",style:{position:"fixed",zIndex:2147483647,inset:"auto 12px max(12px, env(safe-area-inset-bottom))",marginInline:"auto",width:"fit-content",padding:"10px 14px",borderRadius:12,background:"#171717",color:"#fff",font:"14px system-ui"},children:j(d,S?{children:["Popmelt needs your passkey."," ",a("a",{href:b,style:{color:"inherit"},children:"Unlock project"})]}:{children:[H," ",a("button",{type:"button",onClick:()=>X(r=>r+1),children:"Try again"})]})})]})}export{k as PhoneHostGate};