@popmelt.com/core 0.39.0 → 0.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -29
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/claude-plugin/skills/popmelt-core/SKILL.md +5 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/codex-plugin/skills/popmelt-core/SKILL.md +5 -1
- package/dist/{ExploreAttachment-OA2PUTNR.mjs → ExploreAttachment-ZPC5AR5V.mjs} +1 -1
- package/dist/{PagePreviewLayer-HKADULHD.mjs → PagePreviewLayer-C7WBS7IX.mjs} +1 -1
- package/dist/ParticipantRuntime-CWE62D2G.mjs +1 -0
- package/dist/PhoneHostGate-NWJXZBBP.mjs +1 -0
- package/dist/PopmeltTasteConnectedPane-2BNDKMMB.mjs +1 -0
- package/dist/{PreviewRuntime-3ANAJNFO.mjs → PreviewRuntime-7EQNIOF5.mjs} +1 -1
- package/dist/SamplePlacementOverlay-ULOV22WR.mjs +1 -0
- package/dist/ShareProjectPane-KEE7EYMP.mjs +1 -0
- package/dist/SuppliedContext-IT25WBGQ.mjs +1 -0
- package/dist/ThreadErrorCard-SUFOXXLG.mjs +1 -0
- package/dist/ThreadPanel-NNJHQQSD.mjs +1 -0
- package/dist/adapter-react-three-fiber.d.mts +4 -37
- package/dist/adapter-react-three-fiber.mjs +1 -1
- package/dist/adapter-three.d.mts +14 -220
- package/dist/adapter-three.mjs +1 -45
- package/dist/bridge-entry.mjs +1 -1
- package/dist/browser-runtime-G6AEOA4X.mjs +1 -0
- package/dist/browser.d.mts +4 -4
- package/dist/browser.mjs +1 -1
- package/dist/canvas-text.d.mts +38 -0
- package/dist/canvas-text.mjs +1 -0
- package/dist/{checkFixture-I2ALOQTM.mjs → checkFixture-LBDNT3M5.mjs} +1 -1
- package/dist/chunk-2FHGLE7G.mjs +1 -0
- package/dist/chunk-32TDB3N4.mjs +1 -0
- package/dist/{chunk-W62YY5IT.mjs → chunk-44NLL6X3.mjs} +1 -1
- package/dist/chunk-4EDMISUV.mjs +1 -0
- package/dist/{chunk-UFUH63SR.mjs → chunk-4MLXPN7W.mjs} +1 -1
- package/dist/{chunk-4B6HUJCH.mjs → chunk-53QOGFAT.mjs} +1 -1
- package/dist/{chunk-MSWRCFPJ.mjs → chunk-6DU4ITXT.mjs} +1 -1
- package/dist/chunk-A4GARXVQ.mjs +1 -0
- package/dist/{chunk-6RMM7JB6.mjs → chunk-ADRWR5GI.mjs} +1 -1
- package/dist/chunk-AKEVJPGD.mjs +1 -0
- package/dist/{chunk-W5JUAOLA.mjs → chunk-BD7DW4UK.mjs} +1 -1
- package/dist/{chunk-QDFQPABM.mjs → chunk-CUVWMYUV.mjs} +1 -1
- package/dist/{chunk-4LN72RDZ.mjs → chunk-DBCCE7BA.mjs} +1 -1
- package/dist/chunk-DSTHM3V5.mjs +30 -0
- package/dist/{chunk-V56MNQLF.mjs → chunk-ECWY6Z6K.mjs} +1 -1
- package/dist/chunk-EHM2ZBQU.mjs +1 -0
- package/dist/{chunk-P3IOAIYB.mjs → chunk-EUFK7B6S.mjs} +1 -1
- package/dist/chunk-FR6VIGJ2.mjs +1 -0
- package/dist/chunk-HVDJYNQ6.mjs +1 -0
- package/dist/{chunk-TVIKC33M.mjs → chunk-KF35YUNZ.mjs} +1 -1
- package/dist/{chunk-D3BHAI37.mjs → chunk-KN4GC34I.mjs} +1 -1
- package/dist/{chunk-BDUWFDBP.mjs → chunk-KUILFVXZ.mjs} +1 -1
- package/dist/{chunk-FD6IIFJC.mjs → chunk-L3QE62SE.mjs} +1 -1
- package/dist/{chunk-IWF42SDV.mjs → chunk-MHTX52KW.mjs} +1 -1
- package/dist/chunk-N37INB4D.mjs +1 -0
- package/dist/chunk-NFPUOL4J.mjs +1 -0
- package/dist/{chunk-CPFVBR6Q.mjs → chunk-OECEYJNK.mjs} +1 -1
- package/dist/chunk-PRPXMDZ7.mjs +1 -0
- package/dist/chunk-Q5MIJ5F2.mjs +1 -0
- package/dist/chunk-QYNW5LE2.mjs +1 -0
- package/dist/chunk-RAABZFBD.mjs +1 -0
- package/dist/{chunk-OL7RDZ2R.mjs → chunk-REPKQAJK.mjs} +1 -1
- package/dist/chunk-RIGP4DAV.mjs +1 -0
- package/dist/chunk-RXC7B7SX.mjs +1 -0
- package/dist/{chunk-VWFST2IX.mjs → chunk-TVS2ZIAW.mjs} +1 -1
- package/dist/{chunk-SKM4ZXV5.mjs → chunk-UFU5IA3G.mjs} +1 -1
- package/dist/chunk-V7AOJQXQ.mjs +1 -0
- package/dist/chunk-VBH2YQLG.mjs +1 -0
- package/dist/{chunk-RJWFSAKE.mjs → chunk-VLTK7KWK.mjs} +1 -1
- package/dist/chunk-WKQGWQ3P.mjs +1 -0
- package/dist/chunk-WPU4472Z.mjs +1 -0
- package/dist/chunk-WYQZ7DAK.mjs +1 -0
- package/dist/chunk-X6I6KQDG.mjs +1 -0
- package/dist/{chunk-G6ITTTFD.mjs → chunk-XVQAHYF2.mjs} +1 -1
- package/dist/{chunk-3LZQLRZ2.mjs → chunk-YTIDSDPP.mjs} +1 -1
- package/dist/{chunk-ML7YV4RV.mjs → chunk-ZQMKLODZ.mjs} +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/codex-note-context-GXC2474A.mjs +1 -0
- package/dist/codex-project-HVK7FSWQ.mjs +1 -0
- package/dist/{codex-store-mount-MNIL3VK6.mjs → codex-store-mount-KHTSSESB.mjs} +1 -1
- package/dist/dev-server-QMA23NJQ.mjs +1 -0
- package/dist/{focus-inspection-LGIRFL2T.mjs → focus-inspection-FVQ6TVGA.mjs} +1 -1
- package/dist/guest-admission.mjs +1 -1
- package/dist/guest-live-canvas.mjs +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +1 -1
- package/dist/media.d.mts +3 -3
- package/dist/memory-legacy.d.mts +43 -1
- package/dist/memory-store.d.mts +5 -162
- package/dist/memory.d.mts +3 -531
- package/dist/{page-interaction-GC2UN47Y.mjs → page-interaction-YXHXEYOT.mjs} +1 -1
- package/dist/{page-planes-9GVbnVZa.d.mts → page-planes-Jz2yR_Wk.d.mts} +6 -1
- package/dist/{participantBootstrap-BTcD7XgB.d.mts → participantBootstrap-DDOxY-Cy.d.mts} +2 -2
- package/dist/{peer-client-XNTMFSOV.mjs → peer-client-JL754ZR7.mjs} +1 -1
- package/dist/plugin-astro.d.mts +1 -1
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-nuxt.mjs +1 -1
- package/dist/plugin-vite.d.mts +1 -1
- package/dist/plugin-vite.mjs +1 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.mjs +1 -1
- package/dist/shared-page-QN2XRXUE.mjs +1 -0
- package/dist/{subjects-D_yanOQ2.d.mts → subjects-cLtt9-iK.d.mts} +12 -0
- package/dist/{types-CggBG-H6.d.mts → types-XKO-uva0.d.mts} +1 -1
- package/dist/{index-D6bSXWNT.d.mts → validate-0kt2EgVe.d.mts} +7 -40
- package/dist/{video-adapter-CWpR4NSt.d.mts → video-adapter-xL95wukX.d.mts} +1 -1
- package/package.json +7 -3
- package/dist/ParticipantRuntime-IU2STHIT.mjs +0 -1
- package/dist/PhoneHostGate-CS3KFCP5.mjs +0 -1
- package/dist/PopmeltTasteConnectedPane-TRQCY5SM.mjs +0 -1
- package/dist/SamplePlacementOverlay-SNA4WB6Z.mjs +0 -1
- package/dist/ShareProjectPane-QLHMNZNU.mjs +0 -1
- package/dist/SuppliedContext-SFOM3R3K.mjs +0 -1
- package/dist/ThreadErrorCard-NJUVLWMU.mjs +0 -1
- package/dist/ThreadPanel-RVCNMX7B.mjs +0 -1
- package/dist/browser-runtime-BUC4RUD7.mjs +0 -1
- package/dist/chunk-25EXQOPI.mjs +0 -1
- package/dist/chunk-742KV4YS.mjs +0 -1
- package/dist/chunk-ADOCYY5I.mjs +0 -1
- package/dist/chunk-B3RA4XAR.mjs +0 -1
- package/dist/chunk-B4ZKGIGU.mjs +0 -1
- package/dist/chunk-CHK24QU5.mjs +0 -1
- package/dist/chunk-DKBVNKIG.mjs +0 -24
- package/dist/chunk-EOAWCUFT.mjs +0 -1
- package/dist/chunk-FPSR4NAR.mjs +0 -1
- package/dist/chunk-H4GG2RS4.mjs +0 -1
- package/dist/chunk-K2OUXYDM.mjs +0 -1
- package/dist/chunk-KY4YVZ3O.mjs +0 -1
- package/dist/chunk-LSKP5UC6.mjs +0 -1
- package/dist/chunk-MLNC5TMP.mjs +0 -1
- package/dist/chunk-RALP6ENI.mjs +0 -30
- package/dist/chunk-RRB5IHBT.mjs +0 -1
- package/dist/chunk-WNOLXY3Y.mjs +0 -1
- package/dist/codex-note-context-4ORRY4CH.mjs +0 -1
- package/dist/codex-project-LMAR3FMS.mjs +0 -1
- package/dist/dev-server-ZLT7TAUF.mjs +0 -1
- package/dist/shared-page-JN7T4DDQ.mjs +0 -1
- /package/dist/{chunk-CZJILD7T.mjs → chunk-6RC7JZ73.mjs} +0 -0
- /package/dist/{toolbarFonts-JAGSN3DN.mjs → toolbarFonts-33BI56VQ.mjs} +0 -0
- /package/dist/{webpEncoder-QJRHTWUU.mjs → webpEncoder-JVMGDKHV.mjs} +0 -0
package/dist/adapter-three.d.mts
CHANGED
|
@@ -1,222 +1,6 @@
|
|
|
1
|
-
import { Object3D, Intersection, Ray, Vector3, Camera, Raycaster, WebGLRenderer } from 'three';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type CanvasSampleCodec = {
|
|
5
|
-
format: string;
|
|
6
|
-
/** The renderer replays placed instances of local assets, without transferring its authored scene. */
|
|
7
|
-
placementOnly?: true;
|
|
8
|
-
read(): string;
|
|
9
|
-
accepts(value: string): boolean;
|
|
10
|
-
write(value: string): void;
|
|
11
|
-
/** Read or replace one durable subject in a serialized scene without mutating the renderer. */
|
|
12
|
-
objects?: {
|
|
13
|
-
read(scene: string, key: string): string | null;
|
|
14
|
-
replace(scene: string, key: string, value: string): string | null;
|
|
15
|
-
placement?: {
|
|
16
|
-
/** Whether this receiver can reconstruct the incoming object. */
|
|
17
|
-
canPlace?(value: string): boolean;
|
|
18
|
-
/** Convert a click in this renderer's viewport to portable object state at that location. */
|
|
19
|
-
at(value: string, point: {
|
|
20
|
-
x: number;
|
|
21
|
-
y: number;
|
|
22
|
-
}): string | null;
|
|
23
|
-
/** Show a transient ghost in the receiving renderer. Null clears it. Never include it in read() or picking. */
|
|
24
|
-
preview?(value: string | null): void;
|
|
25
|
-
/** Insert under a fresh key without replacing another object. Must be replayable. */
|
|
26
|
-
insert(scene: string, key: string, value: string): string | null;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
type TargetFingerprint = {
|
|
32
|
-
tag: string;
|
|
33
|
-
attributes?: Record<string, string>;
|
|
34
|
-
heading?: string;
|
|
35
|
-
text?: string;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
type AnnotationRevealStep = {
|
|
39
|
-
triggerSelector: string;
|
|
40
|
-
targetSelector?: string;
|
|
41
|
-
label: string;
|
|
42
|
-
};
|
|
43
|
-
type AnnotationRevealRecipe = {
|
|
44
|
-
steps: AnnotationRevealStep[];
|
|
45
|
-
location: string[];
|
|
46
|
-
};
|
|
47
|
-
type ReactSourceLocation = {
|
|
48
|
-
fileName: string;
|
|
49
|
-
lineNumber: number;
|
|
50
|
-
columnNumber?: number;
|
|
51
|
-
};
|
|
52
|
-
/** Coordinates refer to the original image, not its responsive DOM rectangle. */
|
|
53
|
-
type ImageObjectContext = {
|
|
54
|
-
src: string;
|
|
55
|
-
alt: string;
|
|
56
|
-
width: number;
|
|
57
|
-
height: number;
|
|
58
|
-
box: {
|
|
59
|
-
x: number;
|
|
60
|
-
y: number;
|
|
61
|
-
width: number;
|
|
62
|
-
height: number;
|
|
63
|
-
};
|
|
64
|
-
normalizedBox: {
|
|
65
|
-
x: number;
|
|
66
|
-
y: number;
|
|
67
|
-
width: number;
|
|
68
|
-
height: number;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
/** Coordinates refer to the decoded video frame, not its responsive DOM box. */
|
|
72
|
-
type VideoObjectContext = {
|
|
73
|
-
src: string;
|
|
74
|
-
width: number;
|
|
75
|
-
height: number;
|
|
76
|
-
duration: number;
|
|
77
|
-
currentTime: number;
|
|
78
|
-
normalizedBox: {
|
|
79
|
-
x: number;
|
|
80
|
-
y: number;
|
|
81
|
-
width: number;
|
|
82
|
-
height: number;
|
|
83
|
-
};
|
|
84
|
-
box: {
|
|
85
|
-
x: number;
|
|
86
|
-
y: number;
|
|
87
|
-
width: number;
|
|
88
|
-
height: number;
|
|
89
|
-
};
|
|
90
|
-
trackStart: number;
|
|
91
|
-
trackEnd: number;
|
|
92
|
-
};
|
|
93
|
-
type ElementInfo = {
|
|
94
|
-
/** Outermost-to-innermost screen context; selectors retain instance identity. */
|
|
95
|
-
frameContext?: {
|
|
96
|
-
url: string;
|
|
97
|
-
title: string;
|
|
98
|
-
label?: string;
|
|
99
|
-
}[];
|
|
100
|
-
targetFingerprint?: TargetFingerprint;
|
|
101
|
-
selector: string;
|
|
102
|
-
tagName: string;
|
|
103
|
-
/** Adapter-owned semantic name for a non-DOM subject. */
|
|
104
|
-
subjectLabel?: string;
|
|
105
|
-
id?: string;
|
|
106
|
-
className?: string;
|
|
107
|
-
textContent?: string;
|
|
108
|
-
dataAttributes?: Record<string, string>;
|
|
109
|
-
reactComponent?: string;
|
|
110
|
-
reactComponentPath?: string[];
|
|
111
|
-
reactSource?: ReactSourceLocation;
|
|
112
|
-
imageObject?: ImageObjectContext;
|
|
113
|
-
videoObject?: VideoObjectContext;
|
|
114
|
-
/** The real DOM surface, rather than the subject's hidden projection. */
|
|
115
|
-
sourceElement?: ElementInfo;
|
|
116
|
-
context?: string;
|
|
117
|
-
revealRecipe?: AnnotationRevealRecipe;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
type PopmeltSubjectBounds = {
|
|
121
|
-
left: number;
|
|
122
|
-
top: number;
|
|
123
|
-
width: number;
|
|
124
|
-
height: number;
|
|
125
|
-
};
|
|
126
|
-
type PopmeltSubjectTrackingAnchor = {
|
|
127
|
-
/** Horizontal position normalized within the subject bounds. */
|
|
128
|
-
x: number;
|
|
129
|
-
/** Vertical position normalized within the subject bounds. */
|
|
130
|
-
y: number;
|
|
131
|
-
};
|
|
132
|
-
type PopmeltSubjectOutlinePoint = {
|
|
133
|
-
/** Horizontal position normalized within the subject bounds. */
|
|
134
|
-
x: number;
|
|
135
|
-
/** Vertical position normalized within the subject bounds. */
|
|
136
|
-
y: number;
|
|
137
|
-
};
|
|
138
|
-
type PopmeltSubject = {
|
|
139
|
-
key: string;
|
|
140
|
-
label: string;
|
|
141
|
-
bounds: PopmeltSubjectBounds;
|
|
142
|
-
/** Viewport bounds of the renderer surface that owns this subject. */
|
|
143
|
-
surfaceBounds?: PopmeltSubjectBounds;
|
|
144
|
-
context?: string;
|
|
145
|
-
data?: Record<string, string>;
|
|
146
|
-
/** Live owning surface; never serialized or included in model context. */
|
|
147
|
-
sourceElement?: Element;
|
|
148
|
-
imageObject?: ImageObjectContext;
|
|
149
|
-
videoObject?: VideoObjectContext;
|
|
150
|
-
/** Optional provider-neutral foreground anchors used by motion tracking. */
|
|
151
|
-
trackingAnchors?: readonly PopmeltSubjectTrackingAnchor[];
|
|
152
|
-
/** Optional provider-neutral contour normalized within the subject bounds. */
|
|
153
|
-
outline?: readonly PopmeltSubjectOutlinePoint[];
|
|
154
|
-
};
|
|
155
|
-
type PopmeltSurfaceSnapshot = {
|
|
156
|
-
element: HTMLCanvasElement;
|
|
157
|
-
dataUrl: string;
|
|
158
|
-
};
|
|
159
|
-
type PopmeltSubjectCreationSession = {
|
|
160
|
-
key: string;
|
|
161
|
-
update(clientPoint: {
|
|
162
|
-
x: number;
|
|
163
|
-
y: number;
|
|
164
|
-
}): PopmeltSubject | null;
|
|
165
|
-
commit(): PopmeltSubject | null;
|
|
166
|
-
cancel(): void;
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* Minimal renderer boundary for non-DOM subjects. The adapter owns hit testing,
|
|
170
|
-
* durable keys, and viewport projection; Popmelt owns annotations and threads.
|
|
171
|
-
*/
|
|
172
|
-
type PopmeltSubjectAdapter = {
|
|
173
|
-
id: string;
|
|
174
|
-
/** Whole-surface state supported by this app's renderer on both planes. */
|
|
175
|
-
sampleCanvas?: CanvasSampleCodec & {
|
|
176
|
-
element: HTMLCanvasElement;
|
|
177
|
-
};
|
|
178
|
-
/** Surface ownership; an explicit image adapter replaces Core's default. */
|
|
179
|
-
surfaceKind?: 'image' | 'video';
|
|
180
|
-
/** Resolve once the adapter's persisted subject index is available. */
|
|
181
|
-
whenReady?(): Promise<void>;
|
|
182
|
-
/** Notify Core when asynchronous perception changes hit-testable subjects. */
|
|
183
|
-
subscribe?(listener: () => void): () => void;
|
|
184
|
-
/** Ordered hit candidates, innermost/most-specific first. */
|
|
185
|
-
hitTestAll?(clientPoint: {
|
|
186
|
-
x: number;
|
|
187
|
-
y: number;
|
|
188
|
-
}): readonly PopmeltSubject[];
|
|
189
|
-
hitTest(clientPoint: {
|
|
190
|
-
x: number;
|
|
191
|
-
y: number;
|
|
192
|
-
}): PopmeltSubject | null;
|
|
193
|
-
resolve(key: string): PopmeltSubject | null;
|
|
194
|
-
/** Recreate a missing durable subject from annotation-captured context. */
|
|
195
|
-
restoreSubject?(key: string, elementInfo: ElementInfo): PopmeltSubject | null;
|
|
196
|
-
/** Paint a live hover accent on this subject. Release it when hover ends. */
|
|
197
|
-
highlightHover?(key: string, color: string): (() => void) | undefined;
|
|
198
|
-
/** Stable camera/projection identity for comparing two rendered observations. */
|
|
199
|
-
getViewKey?(): string;
|
|
200
|
-
/** Optional clean subject crop, without Popmelt's overlay. */
|
|
201
|
-
captureSubject?(key: string): Blob | null | Promise<Blob | null>;
|
|
202
|
-
/** Optional bitmap capture for renderer surfaces that DOM cloning cannot read. */
|
|
203
|
-
captureSurfaces?(): readonly PopmeltSurfaceSnapshot[] | Promise<readonly PopmeltSurfaceSnapshot[]>;
|
|
204
|
-
/** Begin a context-aware subject-creation gesture at a viewport point. */
|
|
205
|
-
beginCreate?(clientPoint: {
|
|
206
|
-
x: number;
|
|
207
|
-
y: number;
|
|
208
|
-
}): PopmeltSubjectCreationSession | null;
|
|
209
|
-
/** Rename a subject without changing its durable key. */
|
|
210
|
-
renameSubject?(key: string, label: string): PopmeltSubject | null;
|
|
211
|
-
/** Replace a subject's viewport bounds, projected back into adapter space. */
|
|
212
|
-
updateSubjectBounds?(key: string, bounds: PopmeltSubjectBounds): PopmeltSubject | null;
|
|
213
|
-
/** Replace optional foreground anchors normalized within subject bounds. */
|
|
214
|
-
updateSubjectTrackingAnchors?(key: string, anchors: readonly PopmeltSubjectTrackingAnchor[]): PopmeltSubject | null;
|
|
215
|
-
/** Promote a transient perception candidate into a durable subject. */
|
|
216
|
-
promoteSubject?(key: string): PopmeltSubject | null;
|
|
217
|
-
/** Remove a user-created subject or hide an adapter-owned subject. */
|
|
218
|
-
removeSubject?(key: string): void;
|
|
219
|
-
};
|
|
1
|
+
import { Object3D, Intersection, Ray, Vector3, Mesh, Texture, Camera, Raycaster, WebGLRenderer } from 'three';
|
|
2
|
+
import { C as CanvasSampleCodec, P as PopmeltSubjectAdapter } from './subjects-cLtt9-iK.mjs';
|
|
3
|
+
import { CanvasTextFields } from './canvas-text.mjs';
|
|
220
4
|
|
|
221
5
|
/** The scene owns any resources or update-loop registrations created by this hook. */
|
|
222
6
|
type ThreeSampleInstance = {
|
|
@@ -229,6 +13,14 @@ type ThreeSamplingOptions = {
|
|
|
229
13
|
position?: (source: Object3D, hit: Intersection | undefined, ray: Ray) => Vector3 | null | undefined;
|
|
230
14
|
};
|
|
231
15
|
|
|
16
|
+
/** A single, non-tiling UV-mapped CanvasTexture on one mesh. Keys must be unique within the adapter. */
|
|
17
|
+
type ThreeTextSurface = {
|
|
18
|
+
mesh: Mesh;
|
|
19
|
+
texture: Texture;
|
|
20
|
+
fields: CanvasTextFields;
|
|
21
|
+
context?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
232
24
|
/** Stable while the scene's semantic hierarchy remains stable across reloads. */
|
|
233
25
|
declare function threeObjectPath(object: Object3D): string;
|
|
234
26
|
/**
|
|
@@ -255,6 +47,8 @@ type ThreeSubjectAdapterOptions = {
|
|
|
255
47
|
select?: (object: Object3D) => Object3D | null;
|
|
256
48
|
/** Override durable identity. Explicit application IDs are preferred. */
|
|
257
49
|
key?: (object: Object3D) => string | null | undefined;
|
|
50
|
+
textSurfaces?: readonly ThreeTextSurface[];
|
|
51
|
+
getEditableText?: PopmeltSubjectAdapter['getEditableText'];
|
|
258
52
|
label?: (object: Object3D) => string;
|
|
259
53
|
/** Add application-specific provenance or source hints to the model context. */
|
|
260
54
|
describe?: (object: Object3D) => Record<string, string | undefined>;
|
|
@@ -269,4 +63,4 @@ type ThreeSubjectAdapterOptions = {
|
|
|
269
63
|
declare function captureThreeRendererFrame(renderer: WebGLRenderer, scene: Object3D, camera: Camera): string | null;
|
|
270
64
|
declare function createThreeSubjectAdapter(options: ThreeSubjectAdapterOptions): PopmeltSubjectAdapter;
|
|
271
65
|
|
|
272
|
-
export { type ThreeSampleInstance, type ThreeSamplingOptions, type ThreeSubjectAdapterOptions, captureThreeRendererFrame, createThreeSubjectAdapter, selectThreeNamedPrimitiveParent, threeObjectPath };
|
|
66
|
+
export { type ThreeSampleInstance, type ThreeSamplingOptions, type ThreeSubjectAdapterOptions, type ThreeTextSurface, captureThreeRendererFrame, createThreeSubjectAdapter, selectThreeNamedPrimitiveParent, threeObjectPath };
|
package/dist/adapter-three.mjs
CHANGED
|
@@ -1,45 +1 @@
|
|
|
1
|
-
import{Box3 as ke,Matrix3 as Be,Plane as Ie,Raycaster as Ee,Vector2 as Fe,Vector3 as K}from"three";import{clone as Ge}from"three/examples/jsm/utils/SkeletonUtils.js";function U(e){try{return JSON.parse(e)}catch{return null}}function ue(e,r){return Array.isArray(e)&&e.length===r&&e.every(Number.isFinite)}function q(e){let r=e;return!!r&&typeof r.source=="string"&&!!r.source&&r.source.length<=2048&&ue(r.position,3)&&ue(r.scale,3)&&ue(r.quaternion,4)}function te(e){let r=U(e);if(!Array.isArray(r))return null;let l=new Set;for(let p of r){if(!p||typeof p.key!="string"||!/^placed-[\w-]{1,128}$/.test(p.key)||l.has(p.key)||!q(p.sample))return null;l.add(p.key)}return r}function Me(e,r){let l=Ge(e),p=new Map;function s(m){let f=p.get(m);return f||(f=m.clone(),f.transparent=!0,f.opacity*=.5,f.depthWrite=!1,p.set(m,f)),f}return l.traverse(m=>{if(r){m.raycast=()=>{},m.castShadow=!1,"isLight"in m&&(m.visible=!1);let f=m;f.material&&(f.material=Array.isArray(f.material)?f.material.map(s):s(f.material))}}),{object:l,dispose(){for(let m of p.values())m.dispose();l.traverse(m=>{"isSkinnedMesh"in m&&m.skeleton.dispose(),"isInstancedMesh"in m&&m.dispose(),"shadow"in m&&m.shadow?.dispose()})}}}function Se(e,r){e.position.fromArray(r.position),e.quaternion.fromArray(r.quaternion),e.scale.fromArray(r.scale),e.updateMatrix(),e.updateWorldMatrix(!0,!0)}function je(e,r){let l=new Map,p=new WeakMap,s,m,f=new Ee,O="[]";function w(a){if(!(!s&&!l.size))for(;a;){let i=p.get(a);if(i!==void 0)return i;a=a.parent}}function h(a){a.object.removeFromParent(),p.delete(a.object),a.dispose?.()}function S(a){return r(a.source)}function d(){m=void 0,s&&(h(s),s=void 0,e.invalidate?.())}return{codec:{format:"popmelt-three-instance/v1",placementOnly:!0,read:()=>O,accepts:a=>te(a)!==null,write(a){let i=te(a);if(!i)return;let n=new Map;try{for(let{key:o,sample:u}of i){if(l.get(o)?.sample.source===u.source)continue;let y=S(u);if(!y?.parent)throw Error("The sampled Three.js object is unavailable.");let v=e.sampling?.duplicate?.(y)??Me(y,!1);if(v.object.parent||v.object===e.scene)throw Error("A sampled object must be a fresh, detached instance.");n.set(o,v)}}catch(o){for(let u of n.values())h(u);console.warn("[Popmelt] Could not create the sampled Three.js object.",o);return}let b=new Set(i.map(o=>o.key));for(let[o,u]of l)b.has(o)&&!n.has(o)||(h(u),l.delete(o));for(let{key:o,sample:u}of i){let y=n.get(o);y&&(y.object.traverse(j=>{j!==y.object&&typeof j.userData.popmeltId=="string"&&(j.userData.popmeltId=o+"/"+j.userData.popmeltId)}),y.object.userData.popmeltId=o,p.set(y.object,o),S(u).parent.add(y.object),l.set(o,{...y,sample:u}));let v=l.get(o);v.sample=u,Se(v.object,u)}O=a,e.invalidate?.()},objects:{read(a,i){let n=te(a)?.find(o=>o.key===i);if(n)return JSON.stringify(n.sample);let b=r(i);return!b?.parent||b===e.scene?null:JSON.stringify({source:i,position:b.position.toArray(),quaternion:b.quaternion.toArray(),scale:b.scale.toArray()})},replace:()=>null,placement:{canPlace(a){let i=U(a);return q(i)&&!!S(i)?.parent},at(a,i){let n=U(a);if(!q(n))return null;let b=S(n);if(!b?.parent)return null;let o=e.canvas.getBoundingClientRect();if(!o.width||!o.height)return null;e.scene.updateWorldMatrix(!0,!0),e.camera.updateWorldMatrix(!0,!1),f.layers.mask=e.camera.layers.mask,f.setFromCamera(new Fe((i.x-o.left)/o.width*2-1,1-(i.y-o.top)/o.height*2),e.camera);let u=f.intersectObject(e.scene,!0).find(({object:v})=>{for(let j=v;j;j=j.parent)if(!j.visible||j===b||j===s?.object)return!1;return!0}),y=e.sampling?.position?.(b,u,f.ray);if(y===null)return null;if(!y){let v=new ke().setFromObject(b);if(v.isEmpty())return null;let j=v.getCenter(new K),E=b.getWorldPosition(new K);if(u){let g=u.face?.normal.clone().applyNormalMatrix(new Be().getNormalMatrix(u.object.matrixWorld))??f.ray.direction.clone().negate();g.dot(f.ray.direction)>0&&g.negate();let D=v.getSize(new K),P=(Math.abs(g.x)*D.x+Math.abs(g.y)*D.y+Math.abs(g.z)*D.z)/2;y=u.point.clone().addScaledVector(g,P)}else{let g=new Ie().setFromNormalAndCoplanarPoint(e.camera.getWorldDirection(new K),j);if(y=f.ray.intersectPlane(g,new K),!y)return null}y.add(E.sub(j))}return n.position=b.parent.worldToLocal(y.clone()).toArray(),JSON.stringify(n)},preview(a){let i=a&&U(a),n=q(i)&&S(i);if(!n||!q(i)||!n.parent)return d();if(m!==n){if(s?.source!==n){d();try{s={...Me(n,!0),source:n}}catch{m=n;return}p.set(s.object,""),n.parent.add(s.object)}Se(s.object,i),e.invalidate?.()}},insert(a,i,n){let b=te(a),o=U(n);return!b||!/^placed-[\w-]{1,128}$/.test(i)||!q(o)||!S(o)?.parent||r(i)?null:JSON.stringify([...b.filter(u=>u.key!==i),{key:i,sample:o}])}}}},owner:w,placed:l}}import{Color as Ye,EqualDepth as Qe,MeshBasicMaterial as Ze}from"three";import{Box3 as Le,Color as Ne,Frustum as ze,Matrix4 as pe,Vector2 as He,Vector4 as Ve,WebGLRenderTarget as _e}from"three";function Te(e,r,l,p,s,m){let f=e.ownerDocument,O=f.defaultView,w=f.createElement("span");w.dataset.devtools="three-hover-layer",w.setAttribute("aria-hidden","true"),w.style.cssText="all:initial!important;position:absolute!important;display:block!important;overflow:hidden!important;pointer-events:none!important;box-sizing:border-box!important;";let h=f.createElement("canvas");h.style.cssText="position:absolute;pointer-events:none;",w.attachShadow({mode:"open"}).append(h);let S=new He,d=new Ve,t=new Le,c=new pe,a=new ze,i=new _e(1,1),n=new Ne,b,o,u=null,y=new Uint8Array(0),v,j=-1,E=!1,g=!1,D=!1,P=0,H=!1,F;function N(){P++,w.remove()}function Q(x){if(F)return;let G=x.onAfterRender,T=Object.hasOwn(x,"onAfterRender"),k=function(...M){G.apply(this,M);let R=M[0];R.domElement===e&&!R.getRenderTarget()&&j!==R.info.render.frame&&!m()&&N()};x.onAfterRender=k,F=()=>{x.onAfterRender===k&&(T?x.onAfterRender=G:Reflect.deleteProperty(x,"onAfterRender"))}}function re(x,G,T,k){if(D||!O||!e.isConnected||x.getRenderTarget())return!1;let M=e.getBoundingClientRect(),R=O.devicePixelRatio||1;if(x.getDrawingBufferSize(S),S.x+1>=M.width*R&&S.y+1>=M.height*R||!M.width||!M.height||x.getScissorTest())return(w.isConnected||E)&&N(),!1;if(x.getCurrentViewport(d),d.x||d.y||d.z!==S.x||d.w!==S.y||(u??(u=h.getContext("2d")),!u))return!1;if(Q(G),j===x.info.render.frame)return!0;if(j=x.info.render.frame,E)return g=!0,!0;c.multiplyMatrices(T.projectionMatrix,T.matrixWorldInverse),t.setFromObject(r).applyMatrix4(c);let V=Math.max(0,Math.floor(((t.min.x+1)*M.width/2-3)/8)*8/M.width),he=Math.min(1,Math.ceil(((t.max.x+1)*M.width/2+3)/8)*8/M.width),ae=Math.max(0,Math.floor(((1-t.max.y)*M.height/2-3)/8)*8/M.height),ge=Math.min(1,Math.ceil(((1-t.min.y)*M.height/2+3)/8)*8/M.height),$=he-V,J=ge-ae;if(!($>0&&J>0))return N(),!0;let ie=M.width*$,oe=M.height*J,se=Math.min(Math.max(2,R),Math.sqrt(2097152/(ie*oe)),x.capabilities.maxTextureSize/Math.max(ie,oe)),B=Math.max(1,Math.ceil(ie*se)),L=Math.max(1,Math.ceil(oe*se));i.setSize(B,L),b!==T&&(b=T,o=Object.create(T),o.projectionMatrix=new pe,o.projectionMatrixInverse=new pe),c.set(1/$,0,0,(1-V-he)/$,0,1/J,0,(ae+ge-1)/J,0,0,1,0,0,0,0,1),o.projectionMatrix.multiplyMatrices(c,T.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),c.multiplyMatrices(o.projectionMatrix,o.matrixWorldInverse),a.setFromProjectionMatrix(c);let le=o,ce=x.renderLists.get(G,0),ye=[ce.opaque,ce.transmissive,ce.transparent],We=x.getClearAlpha();x.getClearColor(n);let be=P,me;try{x.setRenderTarget(i),x.setClearColor(0,0),x.state.buffers.color.setMask(!0),x.state.buffers.depth.setMask(!0),x.clear();for(let A of ye)for(let{object:C,geometry:z,material:I,group:_}of A){if(!z||!I.depthWrite||!C.layers.test(T.layers)||C.frustumCulled&&!a.intersectsObject(C))continue;C.modelViewMatrix.multiplyMatrices(le.matrixWorldInverse,C.matrixWorld),C.normalMatrix.getNormalMatrix(C.modelViewMatrix);let Z=I.colorWrite;try{I.colorWrite=!1,x.renderBufferDirect(le,G,z,I,C,_)}finally{I.colorWrite=Z}}for(let A of ye)for(let{object:C,geometry:z,material:I,group:_}of A)!z||!l.has(C)||!I.colorWrite||!C.layers.test(T.layers)||k(le,C,z,I,_,se);y.length!==B*L*4&&(y=new Uint8Array(B*L*4)),x.readRenderTargetPixelsAsync?me=x.readRenderTargetPixelsAsync(i,0,0,B,L,y):x.readRenderTargetPixels(i,0,0,B,L,y)}finally{x.setClearColor(n,We),x.setRenderTarget(null),x.state.viewport(d)}function xe(){if(P!==be||!e.isConnected||!u||!O)return;if(!v||v.width!==B||v.height!==L){h.width=B,h.height=L,v=u.createImageData(B,L);for(let W=0;W<v.data.length;W+=4)v.data[W]=p>>16&255,v.data[W+1]=p>>8&255,v.data[W+2]=p&255}for(let W=0;W<L;W++){let ee=W*B*4+3,ve=(L-W-1)*B*4+3;for(let we=0;we<B;we++,ee+=4,ve+=4)v.data[ee]=y[ve]}u.putImageData(v,0,0);let A=O.getComputedStyle(e),C=(W,ee)=>w.style.setProperty(W,ee,"important");C("position",A.position==="fixed"?"fixed":"absolute"),C("left",e.offsetLeft+"px"),C("top",e.offsetTop+"px"),C("width",e.offsetWidth+"px"),C("height",e.offsetHeight+"px"),C("border-radius",A.borderRadius),C("transform",A.transform),C("transform-origin",A.transformOrigin),C("z-index",A.zIndex);let z=parseFloat(A.paddingLeft)||0,I=parseFloat(A.paddingTop)||0,_=e.clientWidth-z-(parseFloat(A.paddingRight)||0),Z=e.clientHeight-I-(parseFloat(A.paddingBottom)||0);h.style.left=e.clientLeft+z+V*_+"px",h.style.top=e.clientTop+I+ae*Z+"px",h.style.width=$*_+"px",h.style.height=J*Z+"px",w.parentNode!==e.parentNode&&e.after(w)}return me?(E=!0,me.then(xe,()=>{be===P&&(D=!0,N())}).finally(()=>{E=!1,!H&&(g||D)&&s?.(),g=!1})):xe(),!0}function ne(){H=!0,N(),F?.(),i.dispose()}return{paint:re,dispose:ne}}import{Box3 as qe,Color as $e,Matrix4 as Je,Vector2 as fe,Vector4 as Ce,WebGLRenderTarget as Ke}from"three";var Ue=72,Xe=24;function Oe(e,r,l){let p=r.ownerDocument.defaultView,s=p?.matchMedia?.("(prefers-reduced-motion: reduce)"),m=performance.now(),f=0,O={value:0},w=new fe,h=new qe,S=new Je,d=new Ce,t;l&&s?.addEventListener("change",l);let c=new Ke(1,1,{depthBuffer:!1}),a=new Ce,i=new fe,n=new fe,b=new $e,o=-1,u,y=null;function v(g,D,P,H){let F=g.getRenderTarget();if(o===g.info.render.frame&&u===P&&y===F)return;o=g.info.render.frame,u=P,y=F,g.getCurrentViewport(a),F?i.set(F.width,F.height):g.getDrawingBufferSize(i);let N=g.domElement.getBoundingClientRect();c.setSize(Math.max(1,a.z),Math.max(1,a.w)),n.set(1*(H??i.x/Math.max(1,N.width))/c.width,1*(H??i.y/Math.max(1,N.height))/c.height);let Q=performance.now();if(s?.matches)O.value=-1;else{S.multiplyMatrices(P.projectionMatrix,P.matrixWorldInverse),h.setFromObject(e).applyMatrix4(S);let G=Math.max(1e-4,h.max.x-h.min.x),T=Math.max(1e-4,h.max.y-h.min.y),k=1/(2*n.x),M=1/(2*n.y);d.set((h.min.x+h.max.x)/2,(h.min.y+h.max.y)/2,k,M),w.set(Math.max(.5,(G*k-1)/2),Math.max(.5,(T*M-1)/2));let R=4*(w.x+w.y);O.value>=0&&Number.isFinite(R)&&R>0&&(f=(f+(Q-m)*Ue/(1e3*R))%1),O.value=Number.isFinite(R)?f*R:-1,l&&p&&t===void 0&&(t=p.requestAnimationFrame(()=>{t=void 0,l()}))}m=Q;let re=g.getActiveCubeFace(),ne=g.getActiveMipmapLevel(),x=g.getClearAlpha();g.getClearColor(b);try{g.setRenderTarget(c),g.setClearColor(0,0),g.state.buffers.color.setMask(!0),g.clear(!0,!1,!1),e.traverseVisible(G=>{let T=G;if(!T.isMesh||!T.layers.test(P.layers))return;T.modelViewMatrix.multiplyMatrices(P.matrixWorldInverse,T.matrixWorld),T.normalMatrix.getNormalMatrix(T.modelViewMatrix);let{geometry:k,material:M}=T;if(Array.isArray(M))for(let R of k.groups){let V=M[R.materialIndex??0];V?.visible&&V.colorWrite&&g.renderBufferDirect(P,D,k,V,T,R)}else M.visible&&M.colorWrite&&g.renderBufferDirect(P,D,k,M,T,null)})}finally{g.setClearColor(b,x),g.setRenderTarget(F,re,ne),g.state.viewport(a)}}function j(g){g.onBeforeCompile=D=>{D.uniforms.hoverMask={value:c.texture},D.uniforms.hoverViewport={value:a},D.uniforms.traceHeadPx=O,D.uniforms.traceHalfSizePx={value:w},D.uniforms.traceBounds={value:d},D.uniforms.hoverStep={value:n},D.fragmentShader=`
|
|
2
|
-
uniform sampler2D hoverMask;
|
|
3
|
-
uniform vec4 hoverViewport;
|
|
4
|
-
uniform vec2 hoverStep;
|
|
5
|
-
uniform float traceHeadPx;
|
|
6
|
-
uniform vec2 traceHalfSizePx;
|
|
7
|
-
uniform vec4 traceBounds;
|
|
8
|
-
float traceStrength(vec2 uv) {
|
|
9
|
-
if (traceHeadPx < 0.0) return 0.0;
|
|
10
|
-
// Map a ray from the subject center to clockwise CSS-pixel distance
|
|
11
|
-
// on the projected bounds. Crossings of holes keep the same sweep.
|
|
12
|
-
vec2 ray = (2.0 * uv - 1.0 - traceBounds.xy) * traceBounds.zw / traceHalfSizePx;
|
|
13
|
-
float radius = max(abs(ray.x), abs(ray.y));
|
|
14
|
-
if (radius < 1e-7) return 0.0;
|
|
15
|
-
vec2 edge = ray / radius;
|
|
16
|
-
float w = traceHalfSizePx.x, h = traceHalfSizePx.y;
|
|
17
|
-
float distancePx;
|
|
18
|
-
if (ray.y >= abs(ray.x)) distancePx = edge.x * w;
|
|
19
|
-
else if (ray.x >= abs(ray.y)) distancePx = w + (1.0 - edge.y) * h;
|
|
20
|
-
else if (-ray.y >= abs(ray.x)) distancePx = (2.0 - edge.x) * w + 2.0 * h;
|
|
21
|
-
else distancePx = 3.0 * w + (3.0 + edge.y) * h;
|
|
22
|
-
float perimeter = 4.0 * (w + h);
|
|
23
|
-
float behind = mod(traceHeadPx - distancePx, perimeter);
|
|
24
|
-
float segment = min(${Xe.toFixed(1)}, perimeter * ${19/100});
|
|
25
|
-
return clamp(2.0 - behind / max(segment, 0.0001), 0.0, 1.0);
|
|
26
|
-
}
|
|
27
|
-
float coverage(vec2 uv, float center) {
|
|
28
|
-
return clamp(texture2D(hoverMask, uv).a / center, 0.0, 1.0);
|
|
29
|
-
}
|
|
30
|
-
`+D.fragmentShader.replace("#include <tonemapping_fragment>",`
|
|
31
|
-
vec2 uv = (gl_FragCoord.xy - hoverViewport.xy) / hoverViewport.zw;
|
|
32
|
-
float center = max(texture2D(hoverMask, uv).a, 0.001);
|
|
33
|
-
float tracer = traceStrength(uv);
|
|
34
|
-
// The moving head fattens to two CSS pixels over the one-pixel resting line.
|
|
35
|
-
vec2 span = hoverStep * (1.0 + tracer);
|
|
36
|
-
vec2 dx = vec2(span.x, 0.0);
|
|
37
|
-
vec2 dy = vec2(0.0, span.y);
|
|
38
|
-
vec2 diag = 0.70710678 * span;
|
|
39
|
-
float inside = min(min(coverage(uv + dx, center), coverage(uv - dx, center)), min(coverage(uv + dy, center), coverage(uv - dy, center)));
|
|
40
|
-
inside = min(inside, min(coverage(uv + diag, center), coverage(uv - diag, center)));
|
|
41
|
-
diag.y = -diag.y;
|
|
42
|
-
inside = min(inside, min(coverage(uv + diag, center), coverage(uv - diag, center)));
|
|
43
|
-
gl_FragColor.a *= mix(0.38, 1.0, (1.0 - inside) * mix(${.3}, 1.0, tracer));
|
|
44
|
-
#include <tonemapping_fragment>
|
|
45
|
-
`)}}function E(){t!==void 0&&p?.cancelAnimationFrame(t),l&&s?.removeEventListener("change",l),c.dispose()}return{update:v,applyTo:j,dispose:E}}function De(e,r,l,p){let s=r;if(!r.startsWith("#")){let d=l.canvas.ownerDocument.createElement("canvas");d.width=d.height=1;let t=d.getContext("2d");if(t){t.fillStyle=r,t.fillRect(0,0,1,1);let c=t.getImageData(0,0,1,1).data;s=c[0]<<16|c[1]<<8|c[2]}}let m=Oe(e,l.canvas,l.invalidate),f=new Map,O=[],w=new Set,h=Te(l.canvas,e,w,new Ye(s).getHex(),l.invalidate,p);function S(d,t,c,a,i,n,b,o){m.update(d,t,c,o);let u=f.get(n);u||(u=new Ze({color:s,transparent:!0,depthWrite:!1,toneMapped:!1,fog:!1}),m.applyTo(u),f.set(n,u)),u.opacity=n.transparent?n.opacity:1,u.side=n.side,u.depthTest=n.depthTest,u.depthFunc=n.depthWrite?Qe:n.depthFunc,u.clippingPlanes=n.clippingPlanes,u.clipIntersection=n.clipIntersection;let y=n;u.wireframe=y.wireframe===!0,n.depthWrite||(u.map=y.map??null,u.alphaMap=y.alphaMap??null,u.alphaTest=n.alphaTest),d.renderBufferDirect(c,t,i,u,a,b)}return e.traverse(d=>{if(!d.isMesh)return;w.add(d);let t=d.onAfterRender,c=!Object.hasOwn(d,"onAfterRender"),a=function(...i){t.apply(this,i);let[n,b,o,u,y,v]=i;n.domElement!==l.canvas||typeof n.renderBufferDirect!="function"||b.overrideMaterial||!y.colorWrite||p()||h.paint(n,b,o,(j,E,g,D,P,H)=>S(n,b,j,E,g,D,P,H))||S(n,b,o,this,u,y,v)};d.onAfterRender=a,O.push(()=>{d.onAfterRender===a&&(c?Reflect.deleteProperty(d,"onAfterRender"):d.onAfterRender=t)})}),l.invalidate?.(),()=>{for(let d of O)d();for(let d of f.values())d.dispose();h.dispose(),m.dispose(),l.invalidate?.()}}import{Box3 as et,Raycaster as tt,Vector2 as rt,Vector3 as nt}from"three";function de(e){return[e.x,e.y,e.z].map(r=>Number(r.toFixed(4))).join(", ")}function Pe(e){let r=e.material;return r&&(Array.isArray(r)?r:[r]).map(s=>s.name?.trim()||s.type).filter(Boolean).join(", ")||void 0}function at(e){let p=(e.parent?.children??[]).filter(f=>f.type===e.type&&f.name===e.name),s=Math.max(0,p.indexOf(e)),m=e.name.trim()||e.type;return`${encodeURIComponent(m)}[${s}]`}function Y(e){let r=[],l=e;for(;l?.parent;)r.push(at(l)),l=l.parent;return r.reverse().join("/")}function it(e){let r=e.userData.popmeltId;return typeof r=="string"&&r.trim()?r.trim():Y(e)}function ot(e){let r=e.userData.popmeltLabel;return typeof r=="string"&&r.trim()?r.trim():e.name.trim()||e.type}function Re(e){let r=e;for(;r.parent;){let l=r.name.trim(),p=l.match(/^(.*)_(?:alpha|normal|material)(?:_\d+)+$/i),s=r.parent;for(;s.parent&&!s.name.trim();)s=s.parent;let m=s.name.trim();if(!m||!l.startsWith(`${m}_`)&&!p)break;r=s}return r}function st(e,r,l){let p=new et().setFromObject(e,!0);if(p.isEmpty())return null;let s=l.getBoundingClientRect(),m=[];for(let t of[p.min.x,p.max.x])for(let c of[p.min.y,p.max.y])for(let a of[p.min.z,p.max.z])m.push(new nt(t,c,a).project(r));let f=m.map(t=>s.left+(t.x+1)/2*s.width),O=m.map(t=>s.top+(1-t.y)/2*s.height),w=Math.max(s.left,Math.min(...f)),h=Math.min(s.right,Math.max(...f)),S=Math.max(s.top,Math.min(...O)),d=Math.min(s.bottom,Math.max(...O));return h<=w||d<=S?null:{left:w,top:S,width:h-w,height:d-S}}function Ae(e,r){let l=e.raycaster??new tt,p=new rt,s=0,m,f=t=>e.key?.(t)??it(t),O=(t,c)=>{let a=h?.owner(t)??f(t);if(!a)return null;let i=st(t,e.camera,e.canvas);return i?{key:a,label:e.label?.(t)??ot(t),sourceElement:e.canvas,bounds:i,context:Y(t),data:{renderer:"Three.js",objectType:t.type,...t.name?{objectName:t.name}:{},scenePath:Y(t),...c&&c!==t?{renderObjectName:c.name.trim()||c.type,renderObjectType:c.type,renderScenePath:Y(c)}:{},position:de(t.position),rotation:de(t.rotation),scale:de(t.scale),visible:String(t.visible),...Pe(t)?{material:Pe(t)}:{},...Object.fromEntries(Object.entries(e.describe?.(t)??{}).filter(n=>typeof n[1]=="string"&&n[1].length>0))}}:null},w=t=>{let c=null,a=!1,i=t.endsWith("]");return e.scene.traverse(n=>{!e.key&&!i&&(typeof n.userData.popmeltId!="string"||n.userData.popmeltId.trim()!==t)||h?.owner(n)!==void 0||f(n)!==t||(c?a=!0:c=n)}),a?null:c},h=e.sampleCanvas===void 0?r?.createThreeSampling(e,w):void 0,S=e.sampleCanvas??h?.codec,d=t=>h?.placed.get(t)?.object??w(t);return{id:e.id?.trim()||"three",...S&&{sampleCanvas:{...S,element:e.canvas}},hitTest({x:t,y:c}){let a=e.canvas.getBoundingClientRect();if(t<a.left||t>a.right||c<a.top||c>a.bottom)return null;p.set((t-a.left)/a.width*2-1,-((c-a.top)/a.height)*2+1),l.setFromCamera(p,e.camera);for(let i of l.intersectObject(e.scene,!0)){let n=h?.owner(i.object),b=n!==void 0?h?.placed.get(n)?.object:e.select?e.select(i.object):Re(i.object);if(!b||!b.visible)continue;let o=O(b,i.object);if(o)return o}return null},...r&&{highlightHover(t,c){let a=d(t);if(!a)return;m?.();let i=r.highlightThreeGeometry(a,c,e,()=>s>0);return m=i,()=>{m===i&&(m=void 0,i())}}},getViewKey(){let t=e.camera;return t.updateWorldMatrix(!0,!1),JSON.stringify([t.type,...t.matrixWorld.elements,...t.projectionMatrix.elements].map(c=>typeof c=="number"?Number(c.toFixed(5)):c))},resolve(t){let c=d(t);return c?O(c):null},...e.captureFrame?{async captureSurfaces(){s++;try{let t=await e.captureFrame?.();return t?[{element:e.canvas,dataUrl:t}]:[]}finally{s--,m&&e.invalidate?.()}}}:{}}}function Ct(e,r,l){let p=e.domElement.width,s=e.domElement.height;if(p<=0||s<=0)return null;let m=e.getRenderTarget(),f=e.xr.enabled;try{return e.xr.enabled=!1,e.setRenderTarget(null),e.render(r,l),e.domElement.toDataURL("image/png")}catch{return null}finally{e.setRenderTarget(m),e.xr.enabled=f}}function Ot(e){return Ae(e,{createThreeSampling:je,highlightThreeGeometry:De})}export{Ct as captureThreeRendererFrame,Ot as createThreeSubjectAdapter,Re as selectThreeNamedPrimitiveParent,Y as threeObjectPath};
|
|
1
|
+
"use client";export{c as captureThreeRendererFrame,d as createThreeSubjectAdapter,b as selectThreeNamedPrimitiveParent,a as threeObjectPath}from"./chunk-WYQZ7DAK.mjs";import"./chunk-PRPXMDZ7.mjs";import"./chunk-A4GARXVQ.mjs";import"./chunk-RIGP4DAV.mjs";import"./chunk-YGP6PPOZ.mjs";
|
package/dist/bridge-entry.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{O as o,b as s,c as e}from"./chunk-
|
|
1
|
+
import{O as o,b as s,c as e}from"./chunk-DSTHM3V5.mjs";import"./chunk-PYGRFSUU.mjs";import"./chunk-6EO73WJN.mjs";import"./chunk-NC7YXD7Q.mjs";import"./chunk-KOHR4LAQ.mjs";import"./chunk-PQKSXNIZ.mjs";import"./chunk-K22VZV3V.mjs";import"./chunk-YMWXWXPV.mjs";import"./chunk-UIADZXVT.mjs";var r=parseInt(process.env.POPMELT_PORT||"1111",10),t=process.env.POPMELT_PROJECT_ROOT||process.cwd(),c=process.env.POPMELT_DEV_ORIGIN||void 0,p=process.env.POPMELT_COPILOT_PATH||void 0,i=process.env.POPMELT_CDP_URL||void 0;(async function(){let n=await o({port:r,projectRoot:t,devOrigin:c,copilotPath:p,cursorPath:process.env.POPMELT_CURSOR_PATH||void 0,opencodePath:process.env.POPMELT_OPENCODE_PATH||void 0,nativeCaptureUrl:i,restartMode:"detached"}),P={pid:process.pid,port:n.port,startedAt:Date.now()};await s(t,P),await new Promise(o=>{let s=!1,r=async()=>{s||(s=!0,await n.close(),await e(t,P),o(),process.exit(0))};process.on("SIGTERM",r),process.on("SIGINT",r)})})().catch(o=>{console.error("[popmelt bridge-entry] Fatal:",o),process.exit(1)});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{b as m,a as r}from"./chunk-NFPUOL4J.mjs";import"./chunk-TVS2ZIAW.mjs";import"./chunk-ELKVFX2O.mjs";import"./chunk-AWWUJO3N.mjs";import"./chunk-Q6N77LIS.mjs";import"./chunk-32TDB3N4.mjs";import"./chunk-RXC7B7SX.mjs";import"./chunk-KUILFVXZ.mjs";import"./chunk-XVQAHYF2.mjs";import"./chunk-SOGN7S54.mjs";import"./chunk-6DU4ITXT.mjs";import"./chunk-REPKQAJK.mjs";import"./chunk-B4RLDY5H.mjs";import"./chunk-PH2MLB3T.mjs";import"./chunk-DBCCE7BA.mjs";import"./chunk-XTOCFTVW.mjs";import"./chunk-Q74FBX2I.mjs";import"./chunk-KCDHP4N3.mjs";import"./chunk-WPU4472Z.mjs";import"./chunk-OVZ4CQGM.mjs";import"./chunk-FHCKFQBY.mjs";import"./chunk-APP5IYTE.mjs";import"./chunk-WIJSWSNF.mjs";import"./chunk-ECWY6Z6K.mjs";import"./chunk-WKQGWQ3P.mjs";import"./chunk-4EDMISUV.mjs";import"./chunk-TMSGNHXH.mjs";import"./chunk-RAABZFBD.mjs";import"./chunk-G2ZHJXHZ.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-44NLL6X3.mjs";import"./chunk-YTIDSDPP.mjs";import"./chunk-VLTK7KWK.mjs";import"./chunk-5IZHN3A7.mjs";import"./chunk-Q5MIJ5F2.mjs";import"./chunk-RK6UROPO.mjs";import"./chunk-AOTDTBQO.mjs";import"./chunk-2F2BVGFH.mjs";import"./chunk-RWZ7SVMO.mjs";import"./chunk-HAZXZ5TU.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-AKEVJPGD.mjs";import"./chunk-X6I6KQDG.mjs";import"./chunk-ATLUO4G7.mjs";import"./chunk-2FHGLE7G.mjs";import"./chunk-C2ZSNUXQ.mjs";import"./chunk-N37INB4D.mjs";import"./chunk-FR6VIGJ2.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"./chunk-B4DYUYX4.mjs";import"./chunk-OEJXPUAR.mjs";import"./chunk-HM6EBJVO.mjs";import"./chunk-OA63PYHZ.mjs";import"./chunk-ADRWR5GI.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-N2ZEZCHO.mjs";import"./chunk-J3UIBBU2.mjs";import"./chunk-PRPXMDZ7.mjs";import"./chunk-A4GARXVQ.mjs";import"./chunk-YGP6PPOZ.mjs";import{createElement as t}from"react";import{createRoot as o}from"react-dom/client";function n(n,u){let i=o(n);return i.render(t(m,u)),()=>{i.unmount(),r()}}export{n as mountBrowserRuntime};
|
package/dist/browser.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as PopmeltOptions } from './participantBootstrap-
|
|
2
|
-
export { i as isPopmeltPreview } from './participantBootstrap-
|
|
3
|
-
import './subjects-
|
|
4
|
-
import './video-adapter-
|
|
1
|
+
import { P as PopmeltOptions } from './participantBootstrap-DDOxY-Cy.mjs';
|
|
2
|
+
export { i as isPopmeltPreview } from './participantBootstrap-DDOxY-Cy.mjs';
|
|
3
|
+
import './subjects-cLtt9-iK.mjs';
|
|
4
|
+
import './video-adapter-xL95wukX.mjs';
|
|
5
5
|
|
|
6
6
|
type PopmeltMount = {
|
|
7
7
|
/** Remove this integration's UI and subscriptions; saved work is retained. */
|
package/dist/browser.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";export{a as isPopmeltPreview}from"./chunk-KCDHP4N3.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-YGP6PPOZ.mjs";var t={unmount(){}};async function e(e={}){if(!e.enabled||typeof document>"u")return t;if(document.querySelector("[data-popmelt-browser-host], [data-popmelt-top-layer-host]"))throw new Error("Popmelt is already mounted. Unmount it before mounting again.");let o=document.createElement("div");o.setAttribute("data-popmelt-browser-host",""),o.setAttribute("data-devtools",""),document.documentElement.appendChild(o);let r=[["__POPMELT_PROJECT_ID__",e.projectId],["__POPMELT_BRIDGE_URL__",e.bridgeUrl]].flatMap(([t,e])=>{if(void 0===e)return[];let o=Object.prototype.hasOwnProperty.call(window,t),r=window[t],n=e??void 0;return window[t]=n,[()=>{window[t]===n&&(o?window[t]=r:delete window[t])}]}),n=()=>{o.remove();for(let t of r)t()};try{let{mountBrowserRuntime:t}=await(import("./browser-runtime-
|
|
1
|
+
"use client";export{a as isPopmeltPreview}from"./chunk-KCDHP4N3.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-YGP6PPOZ.mjs";var t={unmount(){}};async function e(e={}){if(!e.enabled||typeof document>"u")return t;if(document.querySelector("[data-popmelt-browser-host], [data-popmelt-top-layer-host]"))throw new Error("Popmelt is already mounted. Unmount it before mounting again.");let o=document.createElement("div");o.setAttribute("data-popmelt-browser-host",""),o.setAttribute("data-devtools",""),document.documentElement.appendChild(o);let r=[["__POPMELT_PROJECT_ID__",e.projectId],["__POPMELT_BRIDGE_URL__",e.bridgeUrl]].flatMap(([t,e])=>{if(void 0===e)return[];let o=Object.prototype.hasOwnProperty.call(window,t),r=window[t],n=e??void 0;return window[t]=n,[()=>{window[t]===n&&(o?window[t]=r:delete window[t])}]}),n=()=>{o.remove();for(let t of r)t()};try{let{mountBrowserRuntime:t}=await(import("./browser-runtime-G6AEOA4X.mjs"));if(!o.isConnected)throw new Error("Popmelt mount was removed before startup.");let r=t(o,e),m=!0;return{unmount(){if(m){m=!1;try{r()}finally{n()}}}}}catch(t){throw n(),t}}export{e as mountPopmelt};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { a as PopmeltSubjectBounds, P as PopmeltSubjectAdapter } from './subjects-cLtt9-iK.mjs';
|
|
2
|
+
|
|
3
|
+
type Bounds = PopmeltSubjectBounds;
|
|
4
|
+
type Editable = NonNullable<ReturnType<NonNullable<PopmeltSubjectAdapter['getEditableText']>>>;
|
|
5
|
+
type Point = {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
|
9
|
+
declare function textBounds(points: Point[]): Bounds | null;
|
|
10
|
+
/** One instance per painted surface. Bind the authored value before formatting or revealing it. */
|
|
11
|
+
declare function createCanvasTextFields(options: {
|
|
12
|
+
invalidate(): void;
|
|
13
|
+
sourceEditor?: boolean;
|
|
14
|
+
beginEdit?(key: string): void | (() => void);
|
|
15
|
+
}): {
|
|
16
|
+
bind: (key: string, source: string) => {
|
|
17
|
+
readonly value: string;
|
|
18
|
+
draw(ctx: CanvasRenderingContext2D, x: number, y: number, fragment?: string): void;
|
|
19
|
+
};
|
|
20
|
+
fillText(ctx: CanvasRenderingContext2D, key: string, source: string, x: number, y: number): void;
|
|
21
|
+
beginFrame(ctx: CanvasRenderingContext2D): void;
|
|
22
|
+
readonly width: number;
|
|
23
|
+
readonly height: number;
|
|
24
|
+
bounds(key: string): PopmeltSubjectBounds | null;
|
|
25
|
+
hit(x: number, y: number): string | null;
|
|
26
|
+
editable(key: string): Editable | null;
|
|
27
|
+
};
|
|
28
|
+
type CanvasTextFields = ReturnType<typeof createCanvasTextFields>;
|
|
29
|
+
/** Register alongside other subject adapters when a bitmap fills a DOM element. */
|
|
30
|
+
declare function createCanvasTextAdapter(fields: CanvasTextFields, options: {
|
|
31
|
+
id: string;
|
|
32
|
+
element: Element;
|
|
33
|
+
context?: string;
|
|
34
|
+
visible?(): boolean;
|
|
35
|
+
sourceElement?(key: string): Element | undefined;
|
|
36
|
+
}): PopmeltSubjectAdapter;
|
|
37
|
+
|
|
38
|
+
export { type CanvasTextFields, createCanvasTextAdapter, createCanvasTextFields, textBounds };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";export{c as createCanvasTextAdapter,b as createCanvasTextFields,a as textBounds}from"./chunk-RIGP4DAV.mjs";import"./chunk-YGP6PPOZ.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{b as e}from"./chunk-
|
|
1
|
+
"use client";import{b as e}from"./chunk-QYNW5LE2.mjs";import{b as t}from"./chunk-OEJXPUAR.mjs";import"./chunk-HM6EBJVO.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-YGP6PPOZ.mjs";async function o(o,n){if(!/^[a-f0-9]{64}$/.test(n.hash)||"string"!=typeof n.ticket)return;let r,i=!0;try{let r=await t(o+"/files/explore-"+n.hash+".json",{signal:AbortSignal.timeout(8e3)});if(!r.ok)throw Error("The browser could not load the fixture bundle.");let a=await r.json();i=!1,await async function(t,o){let n=document.createElement("iframe");n.sandbox.add("allow-scripts"),n.referrerPolicy="no-referrer",n.tabIndex=-1,n.inert=!0,n.setAttribute("aria-hidden","true"),n.setAttribute("data-devtools","explore-check");let r=320;try{r=document.querySelector(o)?.getBoundingClientRect().width||r}catch{}n.style.cssText="position:fixed;inset:0 auto auto 0;height:260px;border:0;opacity:0;pointer-events:none",n.style.width=Math.min(1440,Math.max(200,r))+"px";let{port1:i,port2:a}=new MessageChannel;try{await new Promise((o,s)=>{let c=setTimeout(()=>l("The fixture did not mount visible content within 12 seconds."),12e3),l=e=>{clearTimeout(c),e?s(new Error(e)):o()};i.onmessage=({data:e})=>{"painted"===e?.type&&l(),"error"===e?.type&&l(String(e.message||"The fixture failed to mount.").slice(0,500))},n.onload=()=>n.contentWindow?.postMessage({bundle:t,initial:[],reference:{style:{},width:r,fonts:"",lightInk:"#222",darkInk:"#ddd"},framing:{pageScale:null,focusX:0,focusY:0},accent:"#f00",mirror:!0,check:!0},"*",[a]),n.srcdoc=e,document.body.append(n)})}finally{n.onload=null,n.remove(),i.close(),a.close()}}(a,n.selector)}catch(e){r=e instanceof Error?e.message.slice(0,500):"The preview could not start."}await t(o+"/explore/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ticket:n.ticket,error:r,unavailable:i}),signal:AbortSignal.timeout(4e3)})}export{o as checkFixture};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{b as e}from"./chunk-N37INB4D.mjs";import{a as t,b as i,f as n,e as a,g as o,d as r}from"./chunk-FR6VIGJ2.mjs";import{m as s,b as l,o as d,a as p}from"./chunk-EILBHZDX.mjs";import{a as c}from"./chunk-OREALBUO.mjs";import{a as h}from"./chunk-7D4BUDKG.mjs";import{a as u,X as m,W as v,Oa as g,V as y}from"./chunk-OA63PYHZ.mjs";import{a as f}from"./chunk-ADRWR5GI.mjs";import{useState as b,useEffect as w,useRef as k,useLayoutEffect as x}from"react";import{jsxs as S,Fragment as $,jsx as j}from"react/jsx-runtime";var z={direct:"Edit","approval-required":"Suggest",blocked:"Blocked"},I={direct:"Use all canvas tools. Send code changes without host approval.","approval-required":"Use all canvas tools. Code changes need host approval.",blocked:"Sending code changes is blocked by the host."};function W({at:e,theme:t,label:i}){let[n,a]=b(Date.now);if(w(()=>{let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},[]),!Number.isFinite(e)||e<=0)return null;let o=Math.max(0,Math.floor((n-e)/1e3)),r=o<60?`${o}s ago`:o<3600?`${Math.floor(o/60)}m ago`:`${Math.floor(o/3600)}h ago`;return j("span",{"data-devtools":"activity-age",title:`${i}: ${new Date(e).toLocaleString()}`,"aria-label":`${i}: ${r}`,style:{background:h[t].control,borderRadius:6,padding:"0 3px",fontSize:12,fontWeight:400,color:h[t].mutedStrong,whiteSpace:"nowrap",flexShrink:0},children:r})}var R=u("lucide-hand-peace",S($,{children:[j("path",{d:"M7 12 5.1 4.9a1.75 1.75 0 0 1 3.4-.8L11 11l2.5-8a1.75 1.75 0 0 1 3.35 1.05L15 11"}),j("path",{d:"M15 14v-3a1.75 1.75 0 0 1 3.5 0v3a1.75 1.75 0 0 1-3.5 0Z"}),j("path",{d:"M18.5 13a1.75 1.75 0 0 1 3.5 0v2a1.75 1.75 0 0 1-3.5 0Z"}),j("path",{d:"M22 15v1a6 6 0 0 1-6 6h-4a6 6 0 0 1-6-6v-1"}),j("path",{d:"M6 15v-1.3a1.75 1.75 0 0 1 2.6-1.5l4 2.3a1.75 1.75 0 0 1-1.75 3.03l-.65-.37"})]}));function A({shape:e="circle",color:t,size:i=26,outline:n,style:a,...o}){return j("svg",{...o,"data-peer-shape":e,"aria-hidden":"true",width:i,height:i,viewBox:"0 0 24 24",style:{display:"block",flexShrink:0,overflow:"visible",pointerEvents:"none",...a},children:j("g",{fill:t,stroke:n??"none",strokeWidth:n?1.2:0,strokeLinejoin:"round",children:"circle"===e?j("circle",{cx:"12",cy:"12",r:"9.5"}):"square"===e?j("rect",{x:"3.25",y:"3.25",width:"17.5",height:"17.5",rx:"3"}):j("path",{d:s[e]})})})}function M(e,t){let i=Math.max(0,Math.floor((t-e)/1e3));return i<60?`${i}s`:i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}d`}var D={textAlign:"left",display:"flex",flexDirection:"column",gap:4,width:"100%"},L={display:"flex",alignItems:"baseline",gap:16,width:"100%"},C={flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",letterSpacing:"0.14px"},E={flexShrink:0,fontSize:12,fontWeight:500,letterSpacing:"0.12px"};function B(e){let n=h[e];return{display:"flex",alignItems:"center",gap:t.gap,width:t.width,maxWidth:i,boxSizing:"border-box",border:`1px solid ${n.border}`,borderRadius:t.radius,padding:t.padding,background:n.surface,color:n.primary,backdropFilter:"blur(59.5px)",fontFamily:f,fontSize:14,lineHeight:1.3,letterSpacing:"-0.01em"}}function H({peer:i,theme:s,id:u,style:$,onPermissionChange:I,onRevokeAccess:H,onInvite:F,isOwn:O=!1,onFocusSuggestion:q,onHoverSuggestion:N,onSharePreview:T,pendingSubmissions:P=[],viewedSuggestionKeys:U=[],showUnreadSuggestions:Y=!0}){let Z=k(N);Z.current=N;let G=k(null);w(()=>{let e=G.current;if(!e)return;let t=Z.current,i=t=>{if("touch"===t.pointerType)return;let i=t.target instanceof Element?t.target.closest('[data-devtools="peer-review-sent"]'):null;!i||!e.contains(i)||t.relatedTarget instanceof Node&&i.contains(t.relatedTarget)||Z.current?.("pointerover"===t.type?i.dataset.annotationId??null:null)};return e.addEventListener("pointerover",i),e.addEventListener("pointerout",i),e.addEventListener("pointercancel",i),()=>{e.removeEventListener("pointerover",i),e.removeEventListener("pointerout",i),e.removeEventListener("pointercancel",i),t?.(null)}},[i.identity.id]);let[K,V]=b(!1),[X,J]=b(),[Q,_]=b(),ee=k(0),te=k(null),ie=k(!1);x(()=>{!K&&ie.current&&(ie.current=!1,te.current?.focus({preventScroll:!0}))},[K,i.identity.id]);let ne=async(e,t)=>{V(!0),J(e),_(void 0);try{await t()||(ee.current+=1,_({target:e,pulse:ee.current}))}catch{ee.current+=1,_({target:e,pulse:ee.current})}finally{V(!1),J(void 0)}},ae=h[s],[oe,re]=b(),[se,le]=b(),de=k(0),[pe,ce]=b(Date.now);w(()=>{if(!P.length)return;let e=setInterval(()=>ce(Date.now()),3e4);return()=>clearInterval(e)},[P.length]);let[he,ue]=b("idle"),me="direct"===i.permission?m:v,ve=!O&&!!I,ge=[...P].sort((e,t)=>(t.submittedAt??0)-(e.submittedAt??0)),ye=ge.flatMap(l),fe=!(!q||!ge.length),be=new Set(U);return S("div",{id:u,ref:G,role:I||F||q||T?"group":"tooltip","data-devtools":"peer-details","data-popmelt-font":"sans","data-popmelt-theme":s,style:{...B(s),width:fe?t.width:"max-content",flexWrap:fe||T?"wrap":void 0,...$},children:[j("style",{children:`\n [data-devtools="peer-revoke"] { color: ${ae.secondary}; }\n [data-devtools="peer-revoke"]:not(:disabled):is(:hover, :focus-visible) { color: ${ae.primary}; }\n [data-devtools="peer-revoke-label"] {\n max-width: 0;\n opacity: 0;\n overflow: hidden;\n transition: max-width 160ms ease, opacity 120ms ease;\n }\n [data-devtools="peer-revoke"]:is(:hover, :focus-visible) [data-devtools="peer-revoke-label"] {\n max-width: 60px;\n opacity: 1;\n }\n [data-devtools="peer-permission"]:not(:focus-visible):has(+ [data-devtools="peer-revoke"]:is(:hover, :focus-visible)) {\n opacity: 0;\n pointer-events: none;\n }\n [data-devtools="peer-details"][data-popmelt-theme="${s}"] :is([data-devtools="peer-permission"], [data-devtools="peer-invite"]):not(:disabled):is(:hover, :focus-visible, [aria-expanded="true"]) {\n box-shadow: inset 0 0 0 100px ${ae.softHairline};\n }\n [data-devtools="peer-review-list"] .popmelt-history-row { color: ${ae.secondary}; font-size: 12px; }\n [data-devtools="peer-review-list"] .popmelt-history-row time { color: ${ae.muted}; }\n [data-devtools="peer-review-list"] .popmelt-history-row:is(:hover, :focus-visible) { color: ${ae.primary}; }\n [data-devtools="peer-review-list"] .popmelt-history-row:is(:hover, :focus-visible) time { color: ${ae.secondary}; }\n [data-popmelt-peer-action-rejection="odd"] {\n animation: popmelt-peer-action-rejection-odd 220ms ease-out;\n }\n [data-popmelt-peer-action-rejection="even"] {\n animation: popmelt-peer-action-rejection-even 220ms ease-out;\n }\n [data-popmelt-peer-action-spinner] {\n animation: popmelt-peer-action-spin 0.8s linear infinite;\n }\n @keyframes popmelt-peer-action-rejection-odd {\n ${c}\n }\n @keyframes popmelt-peer-action-rejection-even {\n ${c}\n }\n @keyframes popmelt-peer-action-spin {\n to { transform: rotate(360deg); }\n }\n @media (prefers-reduced-motion: reduce) {\n :is([data-devtools="peer-permission"], [data-devtools="peer-invite"], [data-devtools="peer-revoke-label"]) { transition: none !important; }\n [data-popmelt-peer-action-rejection] { animation: none !important; }\n [data-popmelt-peer-action-spinner] { animation: none !important; }\n }\n `}),S("div",{style:{display:"flex",alignItems:"center",gap:6,flex:"1 1 auto",minWidth:0},children:[j(A,{shape:d(i),color:i.color??ae.secondary,size:t.identitySize}),S("span",{style:{minWidth:0},children:[S("span",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[j("span",{"data-devtools":"peer-name",style:{display:"block",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i.identity.name}),!O&&void 0!==i.lastActivityAt&&j(W,{at:i.lastActivityAt,theme:s,label:"Last plane activity"})]}),void 0!==i.stagedCount&&S("span",{"data-devtools":"peer-staged-count",style:{display:"block",fontSize:12,color:ae.secondary,marginTop:3,whiteSpace:"nowrap"},children:[i.stagedCount," staged"," ",1===i.stagedCount?"change":"changes"]})]})]}),O&&F&&S("button",{type:"button","data-devtools":"peer-invite","aria-haspopup":"dialog",onClick:F,style:{...e(s),gap:n.gap,padding:n.padding,letterSpacing:"-0.01em"},children:[j(g,{size:n.iconSize,"aria-hidden":"true"}),"Invite"]}),(!O||"host"!==i.identity.relationship)&&S("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[S("button",{"data-devtools":"peer-permission",type:"button",disabled:!ve||K||"blocked"===i.permission,"aria-label":ve?"permission"===Q?.target?"Permission update failed; try again":`${z[i.permission]} permissions; switch to ${"direct"===i.permission?"Suggest":"Edit"}`:void 0,"data-popmelt-peer-action-rejection":"permission"===Q?.target?Q.pulse%2?"odd":"even":void 0,onClick:()=>ve&&I&&void ne("permission",()=>I("direct"===i.permission?"approval-required":"direct")),style:{...e(s),gap:a.gap,padding:a.padding,borderRadius:a.radius,letterSpacing:"-0.01em",transition:"box-shadow 120ms ease, opacity 120ms ease",color:K?ae.muted:ae.primary,cursor:!ve||K?"default":"pointer"},children:["permission"===X?j(y,{"data-popmelt-peer-action-spinner":!0,size:a.iconSize,strokeWidth:1.5,"aria-hidden":"true"}):j(me,{size:a.iconSize,strokeWidth:1.5,"aria-hidden":"true"}),z[i.permission]]}),!O&&H&&"host"!==i.identity.relationship&&S("button",{type:"button","data-devtools":"peer-revoke",ref:te,"aria-label":"revoke"===Q?.target?`Could not remove ${i.identity.name}; try again`:`Remove ${i.identity.name} from session`,"data-popmelt-peer-action-rejection":"revoke"===Q?.target?Q.pulse%2?"odd":"even":void 0,disabled:K,onClick:()=>{ie.current=!0,ne("revoke",H)},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",position:"relative",width:o.size,height:o.size,padding:o.padding,borderRadius:o.radius,border:0,background:"transparent",flexShrink:0,fontFamily:f,fontSize:12,fontWeight:500,lineHeight:1.3,cursor:K?"default":"pointer"},children:[j("span",{"data-devtools":"peer-revoke-label","aria-hidden":"true",style:{position:"absolute",right:18,top:"50%",transform:"translateY(-50%)"},children:j("span",{style:{display:"block",paddingRight:3,whiteSpace:"nowrap"},children:"Remove?"})}),j(R,{size:o.iconSize,strokeWidth:1.5,"aria-hidden":"true",style:{flexShrink:0}})]})]}),T&&S("div",{style:{flexBasis:"100%"},children:[j("button",{type:"button",disabled:"busy"===he,onClick:async()=>{ue("busy");try{await T(),ue("shared")}catch{ue("error")}},style:{width:"100%",padding:"8px 12px",border:`1px solid ${ae.border}`,borderRadius:r.radius,background:"transparent",color:ae.primary,font:"inherit",cursor:"pointer"},children:"busy"===he?"Requesting preview…":"shared"===he?"Share my plane again":"Share my plane"}),"error"===he&&j("div",{role:"status",style:{fontSize:12,marginTop:6},children:"Preview unavailable. Your draft still works; sharing requires a supported browser and permission."})]}),fe&&S("section",{"aria-label":"Suggestions awaiting review","data-devtools":"peer-review-list",style:{flexBasis:"100%",minWidth:0,display:"flex",flexDirection:"column",gap:12},children:[j("div",{style:{fontWeight:500,lineHeight:1,letterSpacing:"-0.14px",color:ae.secondary},children:"Awaiting review"}),j("div",{style:{display:"flex",flexDirection:"column",gap:8,maxHeight:216,overflowY:"auto",overflowX:"hidden",padding:"0 4px",margin:"0 -4px"},children:ye.map(({submission:e,annotation:t,key:n})=>{let a=Y&&!be.has(n);return j("button",{type:"button",className:"popmelt-history-row","data-devtools":"peer-review-sent","data-submission-id":e.id,"data-annotation-id":t.id,"data-unread":a?"true":void 0,disabled:K,"aria-label":`${a?"New: ":""}View ${t.label} on the peer plane`,"aria-busy":oe===n,"data-popmelt-peer-action-rejection":se?.key===n?se.pulse%2?"odd":"even":void 0,onClick:()=>{(async(e,t)=>{if(!q)return;let i=p(e,t);V(!0),re(i),le(void 0);try{await q(e,t)}catch{de.current+=1,le({key:i,pulse:de.current})}finally{V(!1),re(void 0)}})(e.id,t.id)},onFocus:()=>N?.(t.id??null),onBlur:()=>N?.(null),style:{border:0,padding:0,background:"transparent",font:"inherit",cursor:K?"default":"pointer",...D},children:S("span",{style:L,children:[j("span",{"aria-hidden":"true",style:{width:6,flexShrink:0,alignSelf:"center",marginRight:-12},children:a&&j("span",{"data-devtools":"peer-review-unread-dot",style:{display:"block",width:6,height:6,borderRadius:"50%",background:i.color??ae.secondary}})}),j("span",{style:C,children:t.label}),void 0!==e.submittedAt&&j("time",{dateTime:new Date(e.submittedAt).toISOString(),style:E,children:M(e.submittedAt,pe)})]})},n)})})]})]})}export{A as a,z as b,I as c,W as d,M as e,D as f,L as g,C as h,E as i,B as j,H as k};
|