@popmelt.com/core 0.38.1 → 0.40.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.
- package/README.md +5 -32
- 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-IIEORQP3.mjs → ExploreAttachment-DBMYVYWK.mjs} +1 -1
- package/dist/PagePreviewLayer-CVUA6CTQ.mjs +1 -0
- package/dist/ParticipantRuntime-PCBEG3Q2.mjs +1 -0
- package/dist/PhoneHostGate-FZLK4R6M.mjs +1 -0
- package/dist/PopmeltTasteConnectedPane-62LUNNWZ.mjs +1 -0
- package/dist/{PreviewRuntime-3ANAJNFO.mjs → PreviewRuntime-7EQNIOF5.mjs} +1 -1
- package/dist/SamplePlacementOverlay-LR7GZVYP.mjs +1 -0
- package/dist/ShareProjectPane-U47UTAOP.mjs +1 -0
- package/dist/SuppliedContext-F7WKJ5XO.mjs +1 -0
- package/dist/ThreadErrorCard-KPP7YUFC.mjs +1 -0
- package/dist/ThreadPanel-GOYQEF3I.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 +23 -228
- package/dist/adapter-three.mjs +1 -45
- package/dist/bridge-entry.mjs +1 -1
- package/dist/{bridgeSSEStream-HUFNXYPG.mjs → bridgeSSEStream-2KKFO64A.mjs} +1 -1
- package/dist/{bridgeWebSocketStream-AS22Y2FP.mjs → bridgeWebSocketStream-XTHQPBPI.mjs} +1 -1
- package/dist/browser-runtime-BBQQQLF7.mjs +1 -0
- package/dist/browser.d.mts +4 -4
- package/dist/browser.mjs +1 -1
- package/dist/canvas-chat-note-XMVKWL2J.mjs +1 -0
- package/dist/canvas-text.d.mts +38 -0
- package/dist/canvas-text.mjs +1 -0
- package/dist/{checkFixture-UNTXJKRN.mjs → checkFixture-VDRYDCUX.mjs} +1 -1
- package/dist/{chunk-UOK5LOPJ.mjs → chunk-27WBFE5X.mjs} +1 -1
- package/dist/{chunk-5F34UIKL.mjs → chunk-3EYAVOPH.mjs} +1 -1
- package/dist/chunk-4EDMISUV.mjs +1 -0
- package/dist/chunk-52OTX7DP.mjs +1 -0
- package/dist/chunk-53QOGFAT.mjs +1 -0
- package/dist/{chunk-3VOEPWRL.mjs → chunk-5TCWBNV4.mjs} +1 -1
- package/dist/chunk-6GS4BQVU.mjs +30 -0
- package/dist/{chunk-TXL2CR66.mjs → chunk-6U5JWZ4X.mjs} +1 -1
- package/dist/{chunk-WJVRGXOS.mjs → chunk-7D4BUDKG.mjs} +1 -1
- package/dist/chunk-7DXJSJCI.mjs +1 -0
- package/dist/chunk-AKUIREET.mjs +1 -0
- package/dist/chunk-B4RLDY5H.mjs +1 -0
- package/dist/{chunk-ZHXTB5IN.mjs → chunk-BDUWFDBP.mjs} +1 -1
- package/dist/chunk-C4AMAM3W.mjs +1 -0
- package/dist/{chunk-2WQXHUEQ.mjs → chunk-CR6TRUUV.mjs} +1 -1
- package/dist/{chunk-KHDXOXYF.mjs → chunk-DJFZGYX6.mjs} +1 -1
- package/dist/chunk-EHM2ZBQU.mjs +1 -0
- package/dist/{chunk-QXFBFKN6.mjs → chunk-EWTZVC7E.mjs} +1 -1
- package/dist/{chunk-BJUSVIDN.mjs → chunk-FFBBRCPC.mjs} +1 -1
- package/dist/chunk-FR6VIGJ2.mjs +1 -0
- package/dist/{chunk-GTVTUWGH.mjs → chunk-FSSHNWMO.mjs} +1 -1
- package/dist/{chunk-AEC67LMY.mjs → chunk-HC2SF7KE.mjs} +1 -1
- package/dist/chunk-HM6EBJVO.mjs +1 -0
- package/dist/chunk-HOWDQUPT.mjs +1 -0
- package/dist/{chunk-XJJDBMZI.mjs → chunk-HQVWOBYH.mjs} +1 -1
- package/dist/chunk-HTQEMKFA.mjs +1 -0
- package/dist/{chunk-GLF7Z5IR.mjs → chunk-K22VZV3V.mjs} +1 -1
- package/dist/chunk-KOHR4LAQ.mjs +1 -0
- package/dist/chunk-LLVF422C.mjs +1 -0
- package/dist/{chunk-F3VZQGPM.mjs → chunk-LUTP7QBD.mjs} +1 -1
- package/dist/chunk-MHTX52KW.mjs +1 -0
- package/dist/chunk-NC7YXD7Q.mjs +1 -0
- package/dist/{chunk-RJWFSAKE.mjs → chunk-NFO2CREV.mjs} +1 -1
- package/dist/{chunk-TCGXG7UA.mjs → chunk-OECEYJNK.mjs} +1 -1
- package/dist/{chunk-BEGAJYOY.mjs → chunk-OEJXPUAR.mjs} +1 -1
- package/dist/{chunk-FQLIJAUB.mjs → chunk-P2LMCRUN.mjs} +1 -1
- package/dist/{chunk-43BZCDGL.mjs → chunk-PQITT2QK.mjs} +1 -1
- package/dist/chunk-PQKSXNIZ.mjs +1 -0
- package/dist/chunk-RCY5N5KQ.mjs +1 -0
- package/dist/{chunk-W62YY5IT.mjs → chunk-RDB75FUD.mjs} +1 -1
- package/dist/chunk-RIGP4DAV.mjs +1 -0
- package/dist/chunk-RXC7B7SX.mjs +1 -0
- package/dist/{chunk-JAMYVQFC.mjs → chunk-T4WUQPBS.mjs} +1 -1
- package/dist/chunk-TTOCYOEH.mjs +1 -0
- package/dist/chunk-U5NROUVA.mjs +24 -0
- package/dist/chunk-UBPJIVWE.mjs +1 -0
- package/dist/{chunk-SKM4ZXV5.mjs → chunk-UFU5IA3G.mjs} +1 -1
- package/dist/chunk-UIADZXVT.mjs +1 -0
- package/dist/chunk-UPEEIAVJ.mjs +1 -0
- package/dist/{chunk-P2WAXWAZ.mjs → chunk-V5FCWXMN.mjs} +1 -1
- package/dist/chunk-VBH2YQLG.mjs +1 -0
- package/dist/chunk-VQ76TWRR.mjs +1 -0
- package/dist/chunk-WYQZ7DAK.mjs +1 -0
- package/dist/{chunk-N3MHDOMU.mjs → chunk-Y2BJZLYU.mjs} +1 -1
- package/dist/chunk-ZC2I35WD.mjs +1 -0
- package/dist/cli.mjs +1 -1
- package/dist/codex-note-context-2CHDGTG3.mjs +1 -0
- package/dist/codex-project-TIMWOCE5.mjs +1 -0
- package/dist/{codex-store-mount-WJAATWHT.mjs → codex-store-mount-MAQK6VEG.mjs} +1 -1
- package/dist/dev-server-ESGE6QNP.mjs +1 -0
- package/dist/{focus-inspection-LGIRFL2T.mjs → focus-inspection-BMDJJC5K.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-legacy.mjs +1 -1
- package/dist/memory-store.d.mts +5 -162
- package/dist/memory-store.mjs +1 -1
- package/dist/memory.d.mts +3 -531
- package/dist/{page-interaction-TV3P6B3X.mjs → page-interaction-YXHXEYOT.mjs} +1 -1
- package/dist/{page-planes-2ZepTpen.d.mts → page-planes-Jz2yR_Wk.d.mts} +246 -2
- package/dist/{participantBootstrap-BTcD7XgB.d.mts → participantBootstrap-DDOxY-Cy.d.mts} +2 -2
- package/dist/peer-client-LPDWWFT4.mjs +1 -0
- 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 +6 -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-CHp2bgs1.d.mts → validate-0kt2EgVe.d.mts} +7 -40
- package/dist/{video-adapter-CWpR4NSt.d.mts → video-adapter-xL95wukX.d.mts} +1 -1
- package/infra/phone-pairing/binding.mjs +105 -0
- package/infra/phone-pairing/machine-config.mjs +134 -0
- package/infra/phone-pairing/machine-service.mjs +159 -0
- package/infra/phone-pairing/machine.mjs +98 -0
- package/infra/phone-pairing/managed-install.mjs +179 -0
- package/package.json +12 -1
- package/dist/PagePreviewLayer-AFSRCBAX.mjs +0 -1
- package/dist/ParticipantRuntime-ZNEFG34O.mjs +0 -1
- package/dist/PhoneHostGate-OCIMKPLM.mjs +0 -1
- package/dist/PopmeltTasteConnectedPane-N2A5XPRO.mjs +0 -1
- package/dist/SamplePlacementOverlay-EOJW6XGE.mjs +0 -1
- package/dist/ShareProjectPane-VYWTF3FW.mjs +0 -1
- package/dist/SuppliedContext-3S4HT6U6.mjs +0 -1
- package/dist/ThreadErrorCard-CTMVMETS.mjs +0 -1
- package/dist/ThreadPanel-G7OKSWD4.mjs +0 -1
- package/dist/browser-runtime-Q26JF5EA.mjs +0 -1
- package/dist/canvas-chat-note-OLVVP55Y.mjs +0 -1
- package/dist/chunk-25EXQOPI.mjs +0 -1
- package/dist/chunk-2IWVTTYX.mjs +0 -1
- package/dist/chunk-3OGSLX4V.mjs +0 -1
- package/dist/chunk-AGCS65LT.mjs +0 -1
- package/dist/chunk-AYZUOBFI.mjs +0 -1
- package/dist/chunk-B3RA4XAR.mjs +0 -1
- package/dist/chunk-BOZVNUHJ.mjs +0 -1
- package/dist/chunk-DBCBG5J6.mjs +0 -1
- package/dist/chunk-EFWBHWHP.mjs +0 -1
- package/dist/chunk-FYURSPM3.mjs +0 -1
- package/dist/chunk-G6BN5TAZ.mjs +0 -1
- package/dist/chunk-IW7V7WNL.mjs +0 -1
- package/dist/chunk-JJK4LAN6.mjs +0 -1
- package/dist/chunk-JJRKR4X3.mjs +0 -1
- package/dist/chunk-KF73S7MG.mjs +0 -1
- package/dist/chunk-KL5ODVJA.mjs +0 -1
- package/dist/chunk-L356S4EY.mjs +0 -1
- package/dist/chunk-OZBMHEOD.mjs +0 -1
- package/dist/chunk-QQPUMPKU.mjs +0 -1
- package/dist/chunk-TEXVTTWA.mjs +0 -1
- package/dist/chunk-TSQEBZYO.mjs +0 -1
- package/dist/chunk-UTP56NCY.mjs +0 -1
- package/dist/chunk-VG4ZV2OT.mjs +0 -30
- package/dist/chunk-WC7B5NU3.mjs +0 -24
- package/dist/chunk-WNOLXY3Y.mjs +0 -1
- package/dist/codex-note-context-4X7I5AIJ.mjs +0 -1
- package/dist/codex-project-Q6YT5P37.mjs +0 -1
- package/dist/dev-server-NROXLQKM.mjs +0 -1
- package/dist/peer-client-DWC5F6JN.mjs +0 -1
- package/dist/shared-page-GO76UP7I.mjs +0 -1
- /package/dist/{chunk-L45FX4SU.mjs → chunk-ERPJ6LXX.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,23 @@ 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
|
+
|
|
24
|
+
/** Stable while the scene's semantic hierarchy remains stable across reloads. */
|
|
25
|
+
declare function threeObjectPath(object: Object3D): string;
|
|
26
|
+
/**
|
|
27
|
+
* Collapses glTF material primitives such as `Object649_normal_0` onto their
|
|
28
|
+
* named parent `Object649`. Apps opt into this policy through `select` so raw
|
|
29
|
+
* mesh targeting remains available when material-level annotation is useful.
|
|
30
|
+
*/
|
|
31
|
+
declare function selectThreeNamedPrimitiveParent(object: Object3D): Object3D;
|
|
32
|
+
|
|
232
33
|
type ThreeSubjectAdapterOptions = {
|
|
233
34
|
/** Unique adapter identity when a page owns more than one Three.js surface. */
|
|
234
35
|
id?: string;
|
|
@@ -246,6 +47,8 @@ type ThreeSubjectAdapterOptions = {
|
|
|
246
47
|
select?: (object: Object3D) => Object3D | null;
|
|
247
48
|
/** Override durable identity. Explicit application IDs are preferred. */
|
|
248
49
|
key?: (object: Object3D) => string | null | undefined;
|
|
50
|
+
textSurfaces?: readonly ThreeTextSurface[];
|
|
51
|
+
getEditableText?: PopmeltSubjectAdapter['getEditableText'];
|
|
249
52
|
label?: (object: Object3D) => string;
|
|
250
53
|
/** Add application-specific provenance or source hints to the model context. */
|
|
251
54
|
describe?: (object: Object3D) => Record<string, string | undefined>;
|
|
@@ -258,14 +61,6 @@ type ThreeSubjectAdapterOptions = {
|
|
|
258
61
|
* pipeline while the previous render target and XR state are restored afterward.
|
|
259
62
|
*/
|
|
260
63
|
declare function captureThreeRendererFrame(renderer: WebGLRenderer, scene: Object3D, camera: Camera): string | null;
|
|
261
|
-
/** Stable while the scene's semantic hierarchy remains stable across reloads. */
|
|
262
|
-
declare function threeObjectPath(object: Object3D): string;
|
|
263
|
-
/**
|
|
264
|
-
* Collapses glTF material primitives such as `Object649_normal_0` onto their
|
|
265
|
-
* named parent `Object649`. Apps opt into this policy through `select` so raw
|
|
266
|
-
* mesh targeting remains available when material-level annotation is useful.
|
|
267
|
-
*/
|
|
268
|
-
declare function selectThreeNamedPrimitiveParent(object: Object3D): Object3D;
|
|
269
64
|
declare function createThreeSubjectAdapter(options: ThreeSubjectAdapterOptions): PopmeltSubjectAdapter;
|
|
270
65
|
|
|
271
|
-
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 Qe,Raycaster as Ze,Vector2 as et,Vector3 as tt}from"three";import{Box3 as Pe,Matrix3 as We,Plane as Be,Raycaster as ke,Vector2 as Ie,Vector3 as K}from"three";import{clone as Ee}from"three/examples/jsm/utils/SkeletonUtils.js";function U(e){try{return JSON.parse(e)}catch{return null}}function me(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&&me(r.position,3)&&me(r.scale,3)&&me(r.quaternion,4)}function ee(e){let r=U(e);if(!Array.isArray(r))return null;let l=new Set;for(let u of r){if(!u||typeof u.key!="string"||!/^placed-[\w-]{1,128}$/.test(u.key)||l.has(u.key)||!q(u.sample))return null;l.add(u.key)}return r}function Me(e,r){let l=Ee(e),u=new Map;function s(p){let f=u.get(p);return f||(f=p.clone(),f.transparent=!0,f.opacity*=.5,f.depthWrite=!1,u.set(p,f)),f}return l.traverse(p=>{if(r){p.raycast=()=>{},p.castShadow=!1,"isLight"in p&&(p.visible=!1);let f=p;f.material&&(f.material=Array.isArray(f.material)?f.material.map(s):s(f.material))}}),{object:l,dispose(){for(let p of u.values())p.dispose();l.traverse(p=>{"isSkinnedMesh"in p&&p.skeleton.dispose(),"isInstancedMesh"in p&&p.dispose(),"shadow"in p&&p.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,u=new WeakMap,s,p,f=new ke,O="[]";function v(n){if(!(!s&&!l.size))for(;n;){let a=u.get(n);if(a!==void 0)return a;n=n.parent}}function b(n){n.object.removeFromParent(),u.delete(n.object),n.dispose?.()}function S(n){return r(n.source)}function t(){p=void 0,s&&(b(s),s=void 0,e.invalidate?.())}return{codec:{format:"popmelt-three-instance/v1",placementOnly:!0,read:()=>O,accepts:n=>ee(n)!==null,write(n){let a=ee(n);if(!a)return;let i=new Map;try{for(let{key:c,sample:m}of a){if(l.get(c)?.sample.source===m.source)continue;let g=S(m);if(!g?.parent)throw Error("The sampled Three.js object is unavailable.");let w=e.sampling?.duplicate?.(g)??Me(g,!1);if(w.object.parent||w.object===e.scene)throw Error("A sampled object must be a fresh, detached instance.");i.set(c,w)}}catch(c){for(let m of i.values())b(m);console.warn("[Popmelt] Could not create the sampled Three.js object.",c);return}let y=new Set(a.map(c=>c.key));for(let[c,m]of l)y.has(c)&&!i.has(c)||(b(m),l.delete(c));for(let{key:c,sample:m}of a){let g=i.get(c);g&&(g.object.traverse(j=>{j!==g.object&&typeof j.userData.popmeltId=="string"&&(j.userData.popmeltId=c+"/"+j.userData.popmeltId)}),g.object.userData.popmeltId=c,u.set(g.object,c),S(m).parent.add(g.object),l.set(c,{...g,sample:m}));let w=l.get(c);w.sample=m,Se(w.object,m)}O=n,e.invalidate?.()},objects:{read(n,a){let i=ee(n)?.find(c=>c.key===a);if(i)return JSON.stringify(i.sample);let y=r(a);return!y?.parent||y===e.scene?null:JSON.stringify({source:a,position:y.position.toArray(),quaternion:y.quaternion.toArray(),scale:y.scale.toArray()})},replace:()=>null,placement:{canPlace(n){let a=U(n);return q(a)&&!!S(a)?.parent},at(n,a){let i=U(n);if(!q(i))return null;let y=S(i);if(!y?.parent)return null;let c=e.canvas.getBoundingClientRect();if(!c.width||!c.height)return null;e.scene.updateWorldMatrix(!0,!0),e.camera.updateWorldMatrix(!0,!1),f.layers.mask=e.camera.layers.mask,f.setFromCamera(new Ie((a.x-c.left)/c.width*2-1,1-(a.y-c.top)/c.height*2),e.camera);let m=f.intersectObject(e.scene,!0).find(({object:w})=>{for(let j=w;j;j=j.parent)if(!j.visible||j===y||j===s?.object)return!1;return!0}),g=e.sampling?.position?.(y,m,f.ray);if(g===null)return null;if(!g){let w=new Pe().setFromObject(y);if(w.isEmpty())return null;let j=w.getCenter(new K),E=y.getWorldPosition(new K);if(m){let h=m.face?.normal.clone().applyNormalMatrix(new We().getNormalMatrix(m.object.matrixWorld))??f.ray.direction.clone().negate();h.dot(f.ray.direction)>0&&h.negate();let D=w.getSize(new K),R=(Math.abs(h.x)*D.x+Math.abs(h.y)*D.y+Math.abs(h.z)*D.z)/2;g=m.point.clone().addScaledVector(h,R)}else{let h=new Be().setFromNormalAndCoplanarPoint(e.camera.getWorldDirection(new K),j);if(g=f.ray.intersectPlane(h,new K),!g)return null}g.add(E.sub(j))}return i.position=y.parent.worldToLocal(g.clone()).toArray(),JSON.stringify(i)},preview(n){let a=n&&U(n),i=q(a)&&S(a);if(!i||!q(a)||!i.parent)return t();if(p!==i){if(s?.source!==i){t();try{s={...Me(i,!0),source:i}}catch{p=i;return}u.set(s.object,""),i.parent.add(s.object)}Se(s.object,a),e.invalidate?.()}},insert(n,a,i){let y=ee(n),c=U(i);return!y||!/^placed-[\w-]{1,128}$/.test(a)||!q(c)||!S(c)?.parent||r(a)?null:JSON.stringify([...y.filter(m=>m.key!==a),{key:a,sample:c}])}}}},owner:v,placed:l}}import{Color as Ue,EqualDepth as Xe,MeshBasicMaterial as Ye}from"three";import{Box3 as Fe,Color as Le,Frustum as Ne,Matrix4 as pe,Vector2 as ze,Vector4 as Ge,WebGLRenderTarget as He}from"three";function Ce(e,r,l,u,s,p){let f=e.ownerDocument,O=f.defaultView,v=f.createElement("span");v.dataset.devtools="three-hover-layer",v.setAttribute("aria-hidden","true"),v.style.cssText="all:initial!important;position:absolute!important;display:block!important;overflow:hidden!important;pointer-events:none!important;box-sizing:border-box!important;";let b=f.createElement("canvas");b.style.cssText="position:absolute;pointer-events:none;",v.attachShadow({mode:"open"}).append(b);let S=new ze,t=new Ge,o=new Fe,d=new pe,n=new Ne,a=new He(1,1),i=new Le,y,c,m=null,g=new Uint8Array(0),w,j=-1,E=!1,h=!1,D=!1,R=0,H=!1,F;function z(){R++,v.remove()}function Y(x){if(F)return;let L=x.onAfterRender,C=Object.hasOwn(x,"onAfterRender"),B=function(...M){L.apply(this,M);let A=M[0];A.domElement===e&&!A.getRenderTarget()&&j!==A.info.render.frame&&!p()&&z()};x.onAfterRender=B,F=()=>{x.onAfterRender===B&&(C?x.onAfterRender=L:Reflect.deleteProperty(x,"onAfterRender"))}}function re(x,L,C,B){if(D||!O||!e.isConnected||x.getRenderTarget())return!1;let M=e.getBoundingClientRect(),A=O.devicePixelRatio||1;if(x.getDrawingBufferSize(S),S.x+1>=M.width*A&&S.y+1>=M.height*A||!M.width||!M.height||x.getScissorTest())return(v.isConnected||E)&&z(),!1;if(x.getCurrentViewport(t),t.x||t.y||t.z!==S.x||t.w!==S.y||(m??(m=b.getContext("2d")),!m))return!1;if(Y(L),j===x.info.render.frame)return!0;if(j=x.info.render.frame,E)return h=!0,!0;d.multiplyMatrices(C.projectionMatrix,C.matrixWorldInverse),o.setFromObject(r).applyMatrix4(d);let V=Math.max(0,Math.floor(((o.min.x+1)*M.width/2-3)/8)*8/M.width),he=Math.min(1,Math.ceil(((o.max.x+1)*M.width/2+3)/8)*8/M.width),ae=Math.max(0,Math.floor(((1-o.max.y)*M.height/2-3)/8)*8/M.height),ge=Math.min(1,Math.ceil(((1-o.min.y)*M.height/2+3)/8)*8/M.height),$=he-V,J=ge-ae;if(!($>0&&J>0))return z(),!0;let ie=M.width*$,oe=M.height*J,se=Math.min(Math.max(2,A),Math.sqrt(2097152/(ie*oe)),x.capabilities.maxTextureSize/Math.max(ie,oe)),k=Math.max(1,Math.ceil(ie*se)),N=Math.max(1,Math.ceil(oe*se));a.setSize(k,N),y!==C&&(y=C,c=Object.create(C),c.projectionMatrix=new pe,c.projectionMatrixInverse=new pe),d.set(1/$,0,0,(1-V-he)/$,0,1/J,0,(ae+ge-1)/J,0,0,1,0,0,0,0,1),c.projectionMatrix.multiplyMatrices(d,C.projectionMatrix),c.projectionMatrixInverse.copy(c.projectionMatrix).invert(),d.multiplyMatrices(c.projectionMatrix,c.matrixWorldInverse),n.setFromProjectionMatrix(d);let le=c,ce=x.renderLists.get(L,0),ye=[ce.opaque,ce.transmissive,ce.transparent],Ae=x.getClearAlpha();x.getClearColor(i);let be=R,ue;try{x.setRenderTarget(a),x.setClearColor(0,0),x.state.buffers.color.setMask(!0),x.state.buffers.depth.setMask(!0),x.clear();for(let P of ye)for(let{object:T,geometry:G,material:I,group:_}of P){if(!G||!I.depthWrite||!T.layers.test(C.layers)||T.frustumCulled&&!n.intersectsObject(T))continue;T.modelViewMatrix.multiplyMatrices(le.matrixWorldInverse,T.matrixWorld),T.normalMatrix.getNormalMatrix(T.modelViewMatrix);let Q=I.colorWrite;try{I.colorWrite=!1,x.renderBufferDirect(le,L,G,I,T,_)}finally{I.colorWrite=Q}}for(let P of ye)for(let{object:T,geometry:G,material:I,group:_}of P)!G||!l.has(T)||!I.colorWrite||!T.layers.test(C.layers)||B(le,T,G,I,_,se);g.length!==k*N*4&&(g=new Uint8Array(k*N*4)),x.readRenderTargetPixelsAsync?ue=x.readRenderTargetPixelsAsync(a,0,0,k,N,g):x.readRenderTargetPixels(a,0,0,k,N,g)}finally{x.setClearColor(i,Ae),x.setRenderTarget(null),x.state.viewport(t)}function xe(){if(R!==be||!e.isConnected||!m||!O)return;if(!w||w.width!==k||w.height!==N){b.width=k,b.height=N,w=m.createImageData(k,N);for(let W=0;W<w.data.length;W+=4)w.data[W]=u>>16&255,w.data[W+1]=u>>8&255,w.data[W+2]=u&255}for(let W=0;W<N;W++){let Z=W*k*4+3,ve=(N-W-1)*k*4+3;for(let we=0;we<k;we++,Z+=4,ve+=4)w.data[Z]=g[ve]}m.putImageData(w,0,0);let P=O.getComputedStyle(e),T=(W,Z)=>v.style.setProperty(W,Z,"important");T("position",P.position==="fixed"?"fixed":"absolute"),T("left",e.offsetLeft+"px"),T("top",e.offsetTop+"px"),T("width",e.offsetWidth+"px"),T("height",e.offsetHeight+"px"),T("border-radius",P.borderRadius),T("transform",P.transform),T("transform-origin",P.transformOrigin),T("z-index",P.zIndex);let G=parseFloat(P.paddingLeft)||0,I=parseFloat(P.paddingTop)||0,_=e.clientWidth-G-(parseFloat(P.paddingRight)||0),Q=e.clientHeight-I-(parseFloat(P.paddingBottom)||0);b.style.left=e.clientLeft+G+V*_+"px",b.style.top=e.clientTop+I+ae*Q+"px",b.style.width=$*_+"px",b.style.height=J*Q+"px",v.parentNode!==e.parentNode&&e.after(v)}return ue?(E=!0,ue.then(xe,()=>{be===R&&(D=!0,z())}).finally(()=>{E=!1,!H&&(h||D)&&s?.(),h=!1})):xe(),!0}function ne(){H=!0,z(),F?.(),a.dispose()}return{paint:re,dispose:ne}}import{Box3 as Ve,Color as _e,Matrix4 as qe,Vector2 as fe,Vector4 as Te,WebGLRenderTarget as $e}from"three";var Je=72,Ke=24;function Oe(e,r,l){let u=r.ownerDocument.defaultView,s=u?.matchMedia?.("(prefers-reduced-motion: reduce)"),p=performance.now(),f=0,O={value:0},v=new fe,b=new Ve,S=new qe,t=new Te,o;l&&s?.addEventListener("change",l);let d=new $e(1,1,{depthBuffer:!1}),n=new Te,a=new fe,i=new fe,y=new _e,c=-1,m,g=null;function w(h,D,R,H){let F=h.getRenderTarget();if(c===h.info.render.frame&&m===R&&g===F)return;c=h.info.render.frame,m=R,g=F,h.getCurrentViewport(n),F?a.set(F.width,F.height):h.getDrawingBufferSize(a);let z=h.domElement.getBoundingClientRect();d.setSize(Math.max(1,n.z),Math.max(1,n.w)),i.set(1*(H??a.x/Math.max(1,z.width))/d.width,1*(H??a.y/Math.max(1,z.height))/d.height);let Y=performance.now();if(s?.matches)O.value=-1;else{S.multiplyMatrices(R.projectionMatrix,R.matrixWorldInverse),b.setFromObject(e).applyMatrix4(S);let L=Math.max(1e-4,b.max.x-b.min.x),C=Math.max(1e-4,b.max.y-b.min.y),B=1/(2*i.x),M=1/(2*i.y);t.set((b.min.x+b.max.x)/2,(b.min.y+b.max.y)/2,B,M),v.set(Math.max(.5,(L*B-1)/2),Math.max(.5,(C*M-1)/2));let A=4*(v.x+v.y);O.value>=0&&Number.isFinite(A)&&A>0&&(f=(f+(Y-p)*Je/(1e3*A))%1),O.value=Number.isFinite(A)?f*A:-1,l&&u&&o===void 0&&(o=u.requestAnimationFrame(()=>{o=void 0,l()}))}p=Y;let re=h.getActiveCubeFace(),ne=h.getActiveMipmapLevel(),x=h.getClearAlpha();h.getClearColor(y);try{h.setRenderTarget(d),h.setClearColor(0,0),h.state.buffers.color.setMask(!0),h.clear(!0,!1,!1),e.traverseVisible(L=>{let C=L;if(!C.isMesh||!C.layers.test(R.layers))return;C.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,C.matrixWorld),C.normalMatrix.getNormalMatrix(C.modelViewMatrix);let{geometry:B,material:M}=C;if(Array.isArray(M))for(let A of B.groups){let V=M[A.materialIndex??0];V?.visible&&V.colorWrite&&h.renderBufferDirect(R,D,B,V,C,A)}else M.visible&&M.colorWrite&&h.renderBufferDirect(R,D,B,M,C,null)})}finally{h.setClearColor(y,x),h.setRenderTarget(F,re,ne),h.state.viewport(n)}}function j(h){h.onBeforeCompile=D=>{D.uniforms.hoverMask={value:d.texture},D.uniforms.hoverViewport={value:n},D.uniforms.traceHeadPx=O,D.uniforms.traceHalfSizePx={value:v},D.uniforms.traceBounds={value:t},D.uniforms.hoverStep={value:i},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(${Ke.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(){o!==void 0&&u?.cancelAnimationFrame(o),l&&s?.removeEventListener("change",l),d.dispose()}return{update:w,applyTo:j,dispose:E}}function De(e,r,l,u){let s=r;if(!r.startsWith("#")){let t=l.canvas.ownerDocument.createElement("canvas");t.width=t.height=1;let o=t.getContext("2d");if(o){o.fillStyle=r,o.fillRect(0,0,1,1);let d=o.getImageData(0,0,1,1).data;s=d[0]<<16|d[1]<<8|d[2]}}let p=Oe(e,l.canvas,l.invalidate),f=new Map,O=[],v=new Set,b=Ce(l.canvas,e,v,new Ue(s).getHex(),l.invalidate,u);function S(t,o,d,n,a,i,y,c){p.update(t,o,d,c);let m=f.get(i);m||(m=new Ye({color:s,transparent:!0,depthWrite:!1,toneMapped:!1,fog:!1}),p.applyTo(m),f.set(i,m)),m.opacity=i.transparent?i.opacity:1,m.side=i.side,m.depthTest=i.depthTest,m.depthFunc=i.depthWrite?Xe:i.depthFunc,m.clippingPlanes=i.clippingPlanes,m.clipIntersection=i.clipIntersection;let g=i;m.wireframe=g.wireframe===!0,i.depthWrite||(m.map=g.map??null,m.alphaMap=g.alphaMap??null,m.alphaTest=i.alphaTest),t.renderBufferDirect(d,o,a,m,n,y)}return e.traverse(t=>{if(!t.isMesh)return;v.add(t);let o=t.onAfterRender,d=!Object.hasOwn(t,"onAfterRender"),n=function(...a){o.apply(this,a);let[i,y,c,m,g,w]=a;i.domElement!==l.canvas||typeof i.renderBufferDirect!="function"||y.overrideMaterial||!g.colorWrite||u()||b.paint(i,y,c,(j,E,h,D,R,H)=>S(i,y,j,E,h,D,R,H))||S(i,y,c,this,m,g,w)};t.onAfterRender=n,O.push(()=>{t.onAfterRender===n&&(d?Reflect.deleteProperty(t,"onAfterRender"):t.onAfterRender=o)})}),l.invalidate?.(),()=>{for(let t of O)t();for(let t of f.values())t.dispose();b.dispose(),p.dispose(),l.invalidate?.()}}function de(e){return[e.x,e.y,e.z].map(r=>Number(r.toFixed(4))).join(", ")}function Re(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 St(e,r,l){let u=e.domElement.width,s=e.domElement.height;if(u<=0||s<=0)return null;let p=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(p),e.xr.enabled=f}}function rt(e){let u=(e.parent?.children??[]).filter(f=>f.type===e.type&&f.name===e.name),s=Math.max(0,u.indexOf(e)),p=e.name.trim()||e.type;return`${encodeURIComponent(p)}[${s}]`}function te(e){let r=[],l=e;for(;l?.parent;)r.push(rt(l)),l=l.parent;return r.reverse().join("/")}function nt(e){let r=e.userData.popmeltId;return typeof r=="string"&&r.trim()?r.trim():te(e)}function at(e){let r=e.userData.popmeltLabel;return typeof r=="string"&&r.trim()?r.trim():e.name.trim()||e.type}function it(e){let r=e;for(;r.parent;){let l=r.name.trim(),u=l.match(/^(.*)_(?:alpha|normal|material)(?:_\d+)+$/i),s=r.parent;for(;s.parent&&!s.name.trim();)s=s.parent;let p=s.name.trim();if(!p||!l.startsWith(`${p}_`)&&!u)break;r=s}return r}function ot(e,r,l){let u=new Qe().setFromObject(e,!0);if(u.isEmpty())return null;let s=l.getBoundingClientRect(),p=[];for(let o of[u.min.x,u.max.x])for(let d of[u.min.y,u.max.y])for(let n of[u.min.z,u.max.z])p.push(new tt(o,d,n).project(r));let f=p.map(o=>s.left+(o.x+1)/2*s.width),O=p.map(o=>s.top+(1-o.y)/2*s.height),v=Math.max(s.left,Math.min(...f)),b=Math.min(s.right,Math.max(...f)),S=Math.max(s.top,Math.min(...O)),t=Math.min(s.bottom,Math.max(...O));return b<=v||t<=S?null:{left:v,top:S,width:b-v,height:t-S}}function jt(e){let r=e.raycaster??new Ze,l=new et,u=0,s,p=t=>e.key?.(t)??nt(t),f=(t,o)=>{let d=v?.owner(t)??p(t);if(!d)return null;let n=ot(t,e.camera,e.canvas);return n?{key:d,label:e.label?.(t)??at(t),sourceElement:e.canvas,bounds:n,context:te(t),data:{renderer:"Three.js",objectType:t.type,...t.name?{objectName:t.name}:{},scenePath:te(t),...o&&o!==t?{renderObjectName:o.name.trim()||o.type,renderObjectType:o.type,renderScenePath:te(o)}:{},position:de(t.position),rotation:de(t.rotation),scale:de(t.scale),visible:String(t.visible),...Re(t)?{material:Re(t)}:{},...Object.fromEntries(Object.entries(e.describe?.(t)??{}).filter(a=>typeof a[1]=="string"&&a[1].length>0))}}:null},O=t=>{let o=null,d=!1,n=t.endsWith("]");return e.scene.traverse(a=>{!e.key&&!n&&(typeof a.userData.popmeltId!="string"||a.userData.popmeltId.trim()!==t)||v?.owner(a)!==void 0||p(a)!==t||(o?d=!0:o=a)}),d?null:o},v=e.sampleCanvas===void 0?je(e,O):void 0,b=e.sampleCanvas??v?.codec,S=t=>v?.placed.get(t)?.object??O(t);return{id:e.id?.trim()||"three",...b&&{sampleCanvas:{...b,element:e.canvas}},hitTest({x:t,y:o}){let d=e.canvas.getBoundingClientRect();if(t<d.left||t>d.right||o<d.top||o>d.bottom)return null;l.set((t-d.left)/d.width*2-1,-((o-d.top)/d.height)*2+1),r.setFromCamera(l,e.camera);for(let n of r.intersectObject(e.scene,!0)){let a=v?.owner(n.object),i=a!==void 0?v?.placed.get(a)?.object:e.select?e.select(n.object):it(n.object);if(!i||!i.visible)continue;let y=f(i,n.object);if(y)return y}return null},highlightHover(t,o){let d=S(t);if(!d)return;s?.();let n=De(d,o,e,()=>u>0);return s=n,()=>{s===n&&(s=void 0,n())}},getViewKey(){let t=e.camera;return t.updateWorldMatrix(!0,!1),JSON.stringify([t.type,...t.matrixWorld.elements,...t.projectionMatrix.elements].map(o=>typeof o=="number"?Number(o.toFixed(5)):o))},resolve(t){let o=S(t);return o?f(o):null},...e.captureFrame?{async captureSurfaces(){u++;try{let t=await e.captureFrame?.();return t?[{element:e.canvas,dataUrl:t}]:[]}finally{u--,s&&e.invalidate?.()}}}:{}}}export{St as captureThreeRendererFrame,jt as createThreeSubjectAdapter,it as selectThreeNamedPrimitiveParent,te 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-6GS4BQVU.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)});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{g as e}from"./chunk-
|
|
1
|
+
"use client";import{g as e}from"./chunk-HM6EBJVO.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-YGP6PPOZ.mjs";async function t(t,r,a,n){if(r.aborted)return;let o=await e(t,{signal:r});if(!o.ok||!o.body||!o.headers.get("content-type")?.includes("text/event-stream"))throw new Error("Event stream unavailable");if(r.aborted)return;a();let i=o.body.getReader(),s=new TextDecoder,l="",c="message",d=[],f=0;try{for(;!r.aborted;){let e,t=await i.read();if(t.done)throw new Error("Event stream ended");if(l+=s.decode(t.value,{stream:!0}),l.length>2097152)throw new Error("Event frame too large");for(;-1!==(e=l.indexOf("\n"));){let t=l.slice(0,e).replace(/\r$/,"");if(l=l.slice(e+1),t){if(t.startsWith("event:"))c=t.slice(6).trimStart();else if(t.startsWith("data:")&&(d.push(t.slice(5).replace(/^ /,"")),f+=t.length,f>2097152))throw new Error("Event frame too large")}else d.length&&n(c,d.join("\n")),c="message",d=[],f=0}}}finally{await i.cancel().catch(()=>{})}}export{t as readBridgeSSE};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{j as e}from"./chunk-
|
|
1
|
+
"use client";import{j as e}from"./chunk-HM6EBJVO.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-YGP6PPOZ.mjs";async function t(t,r,n){if(r.aborted)return;let o=new URL(t);if("http:"!==o.protocol||!["localhost","127.0.0.1","[::1]"].includes(o.hostname))throw new Error("WebSocket experiment requires a local bridge");let i=new URL(o);i.pathname="/events/ticket";let s=new AbortController,a=()=>s.abort();r.addEventListener("abort",a,{once:!0});let c=setTimeout(a,1e4);try{let a=await fetch(i,e(t,{method:"POST",signal:s.signal,redirect:"error",credentials:"omit"}));if(!a.ok)throw new Error("Event subscription unavailable");let l=await a.json();if(1!==l.version||"string"!=typeof l.ticket||l.ticket.length>128)throw new Error("Invalid event subscription");if(s.signal.aborted){if(r.aborted)return;throw new Error("Event subscription timed out")}o.protocol="ws:",o.pathname="/events/socket",o.search="",o.hash="",await new Promise((e,t)=>{let i=new WebSocket(o),a=!1,d=!1,v=n=>{d||(d=!0,s.signal.removeEventListener("abort",p),i.close(),n&&!r.aborted?t(n):e())},p=()=>v(new Error("Event subscription ended"));s.signal.addEventListener("abort",p,{once:!0}),i.onopen=()=>i.send(JSON.stringify({version:1,type:"subscribe",ticket:l.ticket})),i.onerror=()=>v(new Error("Event socket unavailable")),i.onclose=()=>v(new Error("Event socket ended")),i.onmessage=({data:e})=>{if(!d)try{if("string"!=typeof e||e.length>2097152)throw new Error("Invalid event frame");let t=JSON.parse(e);if(1!==t.version)throw new Error("Unsupported event protocol");if(a||"connected"!==t.type){if(!a||"event"!==t.type||"string"!=typeof t.event?.type)throw new Error("Unexpected event frame");n(t.event.type,JSON.stringify(t.event))}else a=!0,clearTimeout(c),n("connected",JSON.stringify({status:"connected"}))}catch{v(new Error("Invalid event frame"))}}})}finally{s.abort(),clearTimeout(c),r.removeEventListener("abort",a)}}export{t as readBridgeWebSocket};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{b as m,a as r}from"./chunk-HTQEMKFA.mjs";import"./chunk-3EYAVOPH.mjs";import"./chunk-ELKVFX2O.mjs";import"./chunk-AWWUJO3N.mjs";import"./chunk-Q6N77LIS.mjs";import"./chunk-U5NROUVA.mjs";import"./chunk-RXC7B7SX.mjs";import"./chunk-BDUWFDBP.mjs";import"./chunk-DJFZGYX6.mjs";import"./chunk-SOGN7S54.mjs";import"./chunk-AKUIREET.mjs";import"./chunk-PQITT2QK.mjs";import"./chunk-B4RLDY5H.mjs";import"./chunk-PH2MLB3T.mjs";import"./chunk-FFBBRCPC.mjs";import"./chunk-XTOCFTVW.mjs";import"./chunk-Q74FBX2I.mjs";import"./chunk-KCDHP4N3.mjs";import"./chunk-ZC2I35WD.mjs";import"./chunk-OVZ4CQGM.mjs";import"./chunk-FHCKFQBY.mjs";import"./chunk-APP5IYTE.mjs";import"./chunk-WIJSWSNF.mjs";import"./chunk-T4WUQPBS.mjs";import"./chunk-52OTX7DP.mjs";import"./chunk-4EDMISUV.mjs";import"./chunk-TMSGNHXH.mjs";import"./chunk-7DXJSJCI.mjs";import"./chunk-G2ZHJXHZ.mjs";import"./chunk-53SKVMWR.mjs";import"./chunk-RDB75FUD.mjs";import"./chunk-3LZQLRZ2.mjs";import"./chunk-NFO2CREV.mjs";import"./chunk-5IZHN3A7.mjs";import"./chunk-V5FCWXMN.mjs";import"./chunk-RK6UROPO.mjs";import"./chunk-AOTDTBQO.mjs";import"./chunk-2F2BVGFH.mjs";import"./chunk-RWZ7SVMO.mjs";import"./chunk-HAZXZ5TU.mjs";import"./chunk-TVIKC33M.mjs";import"./chunk-VBH2YQLG.mjs";import"./chunk-VXRRHXUP.mjs";import"./chunk-WP2SHSCG.mjs";import"./chunk-AAMUU2QA.mjs";import"./chunk-LH7HKUCK.mjs";import"./chunk-VQ76TWRR.mjs";import"./chunk-X6I6KQDG.mjs";import"./chunk-ATLUO4G7.mjs";import"./chunk-UPEEIAVJ.mjs";import"./chunk-C2ZSNUXQ.mjs";import"./chunk-TTOCYOEH.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-6RMM7JB6.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-N2ZEZCHO.mjs";import"./chunk-J3UIBBU2.mjs";import"./chunk-PRPXMDZ7.mjs";import"./chunk-A4GARXVQ.mjs";import"./chunk-YGP6PPOZ.mjs";import{createElement as t}from"react";import{createRoot as o}from"react-dom/client";function n(n,u){let i=o(n);return i.render(t(m,u)),()=>{i.unmount(),r()}}export{n as mountBrowserRuntime};
|
package/dist/browser.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-BBQQQLF7.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 @@
|
|
|
1
|
+
"use client";import{b as e}from"./chunk-OEJXPUAR.mjs";import"./chunk-HM6EBJVO.mjs";import"./chunk-SUAHDXJZ.mjs";import"./chunk-YGP6PPOZ.mjs";async function t(t,o,r,n,s,a){let i="claude"===n[1].toLowerCase()?"Claude":"Codex";if(!s)throw new Error("Only the host can send a chat note.");if(a)throw new Error("Send a text-only note.");let d=r.find(e=>e.provider===i&&e.linked),m=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(n[2])),h=Array.from(new Uint8Array(m),e=>e.toString(16).padStart(2,"0")).join(""),c=e=>JSON.stringify(["popmelt-note",t,o,e,h]),g=c(i),p=c(d?.id??i),l=sessionStorage.getItem(g)??sessionStorage.getItem(p)??crypto.randomUUID();sessionStorage.setItem(g,l);let I=await e(`${t}/participants/send-to-${i.toLowerCase()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:o,text:n[2],requestId:l,linkId:d?.id})}),S=await I.json();if(!I.ok||!S.queuedInChat&&!S.availableInChat)throw new Error(S.error??"The bridge did not confirm delivery.");return sessionStorage.getItem(g)===l&&sessionStorage.removeItem(g),sessionStorage.getItem(p)===l&&sessionStorage.removeItem(p),{jobId:S.jobId}}export{t as sendCanvasChatNote};
|
|
@@ -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-C4AMAM3W.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e}from"./chunk-
|
|
1
|
+
import{b as e}from"./chunk-HC2SF7KE.mjs";import{J as t,K as a,h as r,o}from"./chunk-6GS4BQVU.mjs";import{readFile as s,readdir as n,realpath as i,stat as c}from"fs/promises";import{dirname as p,join as l,parse as m,relative as u,resolve as d,sep as f}from"path";async function w(e){return c(e).then(()=>!0,()=>!1)}async function h(e){try{let t=JSON.parse(await s(e,"utf8"));return"@popmelt.com/core"===t.name||["dependencies","devDependencies","peerDependencies"].some(e=>{let a=t[e];return!(!a||"object"!=typeof a||!Object.prototype.hasOwnProperty.call(a,"@popmelt.com/core"))})}catch{return!1}}async function y(e){return i(e).catch(()=>d(e))}async function j(e){let t=new Set;try{let a=await s(l(e,"pnpm-workspace.yaml"),"utf8");for(let r of a.matchAll(/^\s*-\s*['"]?([^'"\r\n]+)['"]?\s*$/gm)){let a=r[1].trim().split(/[*{[]/,1)[0].replace(/\/$/,"");a&&t.add(d(e,a))}}catch{}try{let a=JSON.parse(await s(l(e,"package.json"),"utf8")),r=Array.isArray(a.workspaces)?a.workspaces:a.workspaces?.packages??[];for(let a of r){let r=a.split(/[*{[]/,1)[0].replace(/\/$/,"");r&&t.add(d(e,r))}}catch{}return[...t]}var k=new Set([".git",".next",".turbo","build","coverage","dist","node_modules","vendor"]);async function g(e,t=5){let a=[],r=async(e,o)=>{if(o>t)return;let s;try{s=await n(e,{withFileTypes:!0})}catch{return}s.some(e=>e.isDirectory()&&".popmelt"===e.name)&&a.push(e),await Promise.all(s.flatMap(t=>!t.isDirectory()||".popmelt"===t.name||k.has(t.name)?[]:[r(l(e,t.name),o+1)]))};return await r(e,0),a}function b(e,t){let a=u(e,t);return a?a.split(f).filter(Boolean).length:0}async function I(e=process.cwd()){let a=await y(e),o=a,s=m(o).root,n=new Map,i=(e,t)=>{let a=n.get(e)??new Set;a.add(t),n.set(e,a)},c=[];for(;await w(l(o,".popmelt"))&&i(o,"store"),await w(l(o,".popmelt","ambient.json"))&&i(o,"marker"),await h(l(o,"package.json"))&&i(o,"package"),await h(l(o,"packages","popmelt","package.json"))&&i(o,"workspace_package"),(await j(o)).length&&c.push(o),o!==s;)o=p(o);for(let e of c){let t=await j(e),a=await Promise.all(t.map(e=>g(e)));for(let e of a.flat())i(await y(e),"store")}return(await Promise.all([...n].map(async([e,a])=>{let o=await y(e),s=await t(o),n=[...a].sort();return{root:o,storeId:s.storeId,projectId:r(o),reason:n[0],reasons:n,initialized:a.has("store")}}))).sort((e,t)=>e.initialized!==t.initialized?e.initialized?-1:1:b(a,e.root)-b(a,t.root)||e.root.localeCompare(t.root))}async function P(e=process.cwd()){return(await I(e))[0]??null}function v(){return process.env.POPMELT_EXECUTION_OWNER}function O(){return v()===o}async function S(t){let r=await a(t.root);return{...await e({projectRoot:t.root,detached:!0,manageLease:!1}),storeId:r.storeId}}async function E(e,t,a={}){let r=await fetch(`http://127.0.0.1:${e.port}${t}`,{...a,headers:{"Content-Type":"application/json","X-Popmelt-Project-Id":e.projectId,...a.headers}}),o=await r.json().catch(()=>null);return{response:r,body:o}}export{I as a,P as b,v as c,O as d,S as e,E as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{b as t}from"./chunk-ELKVFX2O.mjs";import{b as e,a,c as n,d as o,e as r,p as i,o as l}from"./chunk-AWWUJO3N.mjs";import{
|
|
1
|
+
"use client";import{b as t}from"./chunk-ELKVFX2O.mjs";import{b as e,a,c as n,d as o,e as r,p as i,o as l}from"./chunk-AWWUJO3N.mjs";import{g as s,i as h}from"./chunk-4EDMISUV.mjs";import{a as m,b as c,j as p}from"./chunk-RDB75FUD.mjs";import{createContext as d,domToCanvas as u,destroyContext as f}from"modern-screenshot";async function g(i,l){if(i&&i.pathname===location.pathname)try{let s=e(i),h=a(s.element),g=s.legacyScene||(h&&(h===s.element||s.element?.closest("svg,canvas"))?h:null),w=g?"component":"element",b=g??n(s,"element",!1);if(!b||b.closest("[data-popmelt-explore-original],[data-popmelt-explore-scene]"))return;let{width:M,height:y}=b.getBoundingClientRect();if(M<=0||y<=0)return;let x=getComputedStyle(b),v={capturedAt:Date.now(),backdrop:t(b),selector:i.selector,pathname:i.pathname,scope:w,width:M,height:y,viewport:{width:innerWidth,height:innerHeight},textFonts:r(b),style:Object.fromEntries(o.map(t=>[t,x.getPropertyValue(t)]))};try{let t=m(),e=l&&(b.matches("canvas")||b.querySelector("canvas"))?await c(t,l):[],a=await p(e,async()=>{let e=await c(t,()=>d(b,{width:Math.ceil(M),height:Math.ceil(y),scale:Math.min(2,512/Math.max(M,y)),timeout:1500,backgroundColor:v.backdrop,style:{margin:"0",position:"static",transform:"none"},filter:t=>!(t instanceof Element&&t.matches("[data-devtools],[data-popmelt-root],[data-popmelt-explore-preview]"))}));try{return await c(t,()=>u(e))}finally{f(e)}});for(;a.width&&a.height;){let t=a.toDataURL("image/webp",.8);if(t.length<=96e3&&/^data:image\/(webp|png);base64,/.test(t)){v.still=t;break}if(Math.max(a.width,a.height)<32)break;let e=document.createElement("canvas");e.width=Math.max(1,Math.floor(a.width/2)),e.height=Math.max(1,Math.floor(a.height/2)),e.getContext("2d").drawImage(a,0,0,e.width,e.height),a=e}}catch{}return v}catch{return}}async function w(t,e){let a=1===t.annotations.length&&t.annotations[0];a&&i(a.instruction??"")&&(t.exploreCapture=await g(l(a,location.pathname),e))}function b(t,e,a){let n=t.flatMap(({requestedAt:t,resolvedAt:n})=>Number.isFinite(t)&&Number.isFinite(n)?[[Math.max(e,t),Math.min(a,n)]]:[]).sort((t,e)=>t[0]-e[0]),o=e,r=0;for(let[t,e]of n)r+=Math.max(0,e-Math.max(o,t)),o=Math.max(o,e);return r}function M(t){let e=new Map,a=new Set;for(let n of t)if("approval"===n.type){let t=n.data.approval;e.set(t.id,t)}else("done"===n.type||"error"===n.type)&&a.add(String(n.data.jobId));return new Map([...e.values()].filter(t=>"pending"===t.status&&!a.has(t.jobId)).map(t=>[t.jobId,t]))}function y(t,e,a){return a?.activePreview?a.annotationNumber:t??e}function x(t,e){let a=e.find(t=>"human"===t.role);return s(a?.requestItems)||t?.trim()||h(a)}export{g as a,w as b,b as c,M as d,y as e,x as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{f as e}from"./chunk-VXRRHXUP.mjs";import{e as t,f as n}from"./chunk-AAMUU2QA.mjs";import{u as a,d as i}from"./chunk-LH7HKUCK.mjs";import{createContext as r}from"react";function o(e,t){let n=a(e.filter(e=>!e.includes("data-pm=")),t);return"matched"===n.status?n.element:null}function l(e){if(!e||!/^\/(?!\/)/.test(e)||/[\\?#\s]/.test(e))return;let t=n(e);return t.startsWith("//")||t.startsWith("/__popmelt/")?void 0:new URL(t,"https://local.invalid").pathname===t?t:void 0}function s(e){let t,n=e.messages?.find(e=>"human"===e.role),a=n?.annotationSnapshot;try{if(a?.url){let e=new URL(a.url,a.url.startsWith("/")?"http://localhost":void 0);/^https?:$/.test(e.protocol)&&(t=e)}}catch{}let i=a?.annotations?.[0],r=n?.requestItems?.find(e=>"changes"===e.kind),o=(e.targetBindings??[]).map(e=>e.anchor),s=o.find(e=>"dom"===e.type),m=[...e.elementIdentifiers??[],...r?[r.elementKey]:[]],c=l(t?.pathname),p=l(s?.pathname)??l(i?.pathname)??l(r?.pathname)??l(m.find(e=>e.startsWith("/")&&e.includes(":"))?.split(":")[0])??c,u=o.filter(e=>"opaque"===e.type||l(e.pathname)===p),f=!i||i.pathname&&l(i.pathname)!==p?void 0:i;f?.target&&u.push({type:"opaque",...f.target});let h=f?.elements?.[0];!f?.region&&(f?.linkedSelector||h)&&u.push({type:"dom",pathname:p??"/",structuralSelector:h?.selector,runtimeSelector:f?.linkedSelector,targetFingerprint:h?.targetFingerprint});for(let e of m){let t=e.indexOf(":"),n=e.startsWith("/")?t>0&&l(e.slice(0,t))===p?e.slice(t+1):"":c&&c===p?e:"";n&&u.push({type:"dom",pathname:p??"/",structuralSelector:n})}let d=f?.region;if(!(u.length||d?.points.length||f||r))return null;let g=c===p&&t?t.search+t.hash:"";return{pathname:p,href:p&&p+g,targets:u,region:d,element:h}}function m(e){return n(location.pathname)+location.search+location.hash===e}function c(e){try{let t=sessionStorage.getItem(e);if(!t)return;sessionStorage.removeItem(e);let n=JSON.parse(t);if(n.expires>Date.now()&&"string"==typeof n.id&&m(n.href))return n.id}catch{}}function p(n,a,r){let l,s=!1,p=new AbortController,u=()=>{s=!0,clearTimeout(l),p.abort()};for(let e of["wheel","pointerdown","touchstart","keydown"])window.addEventListener(e,u,{capture:!0,passive:!0,signal:p.signal});let{href:f}=a;return async function(){if(f&&!m(f)){try{sessionStorage.setItem(r.storageKey,JSON.stringify({id:n,href:f,expires:Date.now()+3e4}))}catch{}if(r.navigate)await r.navigate(f);else{let e=new URL(t(location.pathname).slice(0,-1)+f,location.origin),n=e.pathname!==location.pathname||e.search!==location.search;if(location.assign(e.href),n)return}}let p=performance.now()+4e3,h=!1,d=null,g=0,x=!1,y=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth",v=async()=>{if(!s){if(!f||m(f)){!x&&f&&c(r.storageKey),x=!0;let t=d?.isConnected?d:function(e,t){for(let n of e)if("opaque"===n.type){let e=t.resolve(n);if(e)return e.subject.sourceElement??e.element}else{let e=o([n.structuralSelector,n.runtimeSelector,...n.legacySelectors??[]].filter(e=>!!e),n.targetFingerprint);if(e)return e}return null}(a.targets,r.registry);if(t){for(let e=t.parentElement;e;e=e.parentElement)e instanceof HTMLDetailsElement&&!e.open&&(e.open=!0);let e=i(t),n=e.bottom<=0||e.top>=innerHeight||e.right<=0||e.left>=innerWidth;e.height&&e.width&&(d!==t||n&&performance.now()-g>750)&&(t.scrollIntoView({behavior:d?"instant":y,block:"center",inline:"nearest"}),d=t,g=performance.now())}if(!d&&!h&&a.element?.revealRecipe&&(h=!0,await e(void 0,[a.element]),s))return;if(!t&&a.region?.points.length){let e=a.region.points.map(e=>e.x),t=a.region.points.map(e=>e.y);return window.scrollTo({left:(Math.min(...e)+Math.max(...e)-innerWidth)/2,top:(Math.min(...t)+Math.max(...t)-innerHeight)/2,behavior:y}),u()}if(!a.targets.length)return u()}else if(x)return u();performance.now()<p?l=setTimeout(()=>{v().catch(u)},d?250:160):u()}};await v()}().catch(u),u}function u(e,t){return"string"==typeof t.canvasLabel?t.canvasLabel:[e,t.modified].filter(Boolean).join(" ")}function f(e){return S(e,512)||"Empty text"}function h(e){if("changes"!==e.kind)return;if("string"==typeof e.replacementText)return e.replacementText;let t=[];for(let n of e.changes){if(!n.startsWith("Text: "))return;let e=n.slice(6).split(" → ");if(2!==e.length)return;t.push("empty"===e[1]?"":e[1])}return t.length?t.join(" "):void 0}function d(e){if(!e?.length)return;let t=[];for(let n of e){let e=h(n);if(void 0===e)return;t.push(e.replace(/\s+/g," ").trim()||"Empty text")}return t.join("; ")}function g(e=[]){let t={};if(e.some(e=>"annotation"===e.kind))return t;for(let n of e){if("changes"!==n.kind)continue;let e=h(n);void 0!==e&&(t[n.elementKey]=f(e))}return t}function x(e){let t=e?.requestItems?.flatMap(e=>"annotation"===e.kind&&e.text.trim()?[e.text.trim()]:[]);if(t?.length)return t.join("; ");let n=e?.requestItems?.flatMap(e=>"changes"===e.kind?[`${e.elementLabel} [${e.changes.join(", ")}]`]:[]);return n?.length?n.join("; "):e?.requestText?.trim()||void 0}function y(e,t){if(!e?.frames?.length)return[];let n=new Map;for(let t of e.steps){let e=t.visuals?.afterFrameId;e&&!n.has(e)&&n.set(e,t.action?.label?`After ${t.action.label}`:"Resulting state")}return e.frames.flatMap((e,a)=>{let i=t[e.imageIndex];return i?[{id:e.id,imageIndex:e.imageIndex,label:0===a?"Initial state":n.get(e.id)??"State",url:i}]:[]})}function v(e){let t=e.instruction?.trim();return t?e.attachments?.some(e=>e.name?.trim()===t)?null:t:null}function w(e,t){let n=e?.tagName?.toLowerCase(),a=e?.id?`#${e.id}`:"",i=e?.className?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"",r=n?`${n}${a}${i}`:t;return e?.reactComponent?`<${e.reactComponent}> ${r}`:r}function $(e){let t=e.elements?.[0]?.reactComponent||e.elements?.[0]?.tagName||e.linkedSelector,n=e.type&&"annotation"!==e.type?`${e.type} annotation`:"Annotation";return t?`${n} on ${t}`:n}function b(e){let t=e.annotations.map(e=>{let t=e.interactionEpisode?.steps.length??0;return{kind:"annotation",annotationId:e.id,pathname:e.pathname,text:v(e)??$(e),...t>0?{interactionEpisodeStepCount:t}:{}}}),n=new Map,a=e=>{let a=`${e.pathname??""}:${e.durableSelector??e.selector}`,i=n.get(a);if(i)return i.changes.push(e.text),void 0!==i.replacementText&&e.textEdit?i.replacementText=u(i.replacementText,e.textEdit):delete i.replacementText,void(void 0!==e.annotationNumber&&(void 0===i.annotationNumber||e.annotationNumber<i.annotationNumber)&&(i.annotationNumber=e.annotationNumber));let r={kind:"changes",elementKey:a,elementLabel:w(e.element,e.selector),...void 0!==e.annotationNumber?{annotationNumber:e.annotationNumber}:{},pathname:e.pathname,changes:[e.text],...e.textEdit?{replacementText:u(void 0,e.textEdit)}:{}};n.set(a,r),t.push(r)};for(let t of e.styleModifications??[])for(let e of t.changes)a({...t,text:`${e.property}: ${e.original||"unset"} → ${e.modified||"unset"}${e.token?` (${e.token})`:""}`});for(let t of e.textModifications??[])a({...t,textEdit:t,text:`Text: ${t.original||"empty"} → ${t.modified||"empty"}`});for(let t of e.domModifications??[])a({...t,text:"copy"===t.operation?"Copied element":"Moved element"});return e.spacingTokenChanges?.length&&t.push({kind:"changes",elementKey:"spacing-tokens",elementLabel:"Spacing tokens",changes:e.spacingTokenChanges.map(e=>`${e.tokenName}: ${e.originalPx}px → ${e.newPx}px`)}),t}function k(e){let t=e.annotations.flatMap(e=>{let t=v(e);return t?[{instruction:t,pathname:e.pathname}]:[]});if(0===t.length)return;if(new Set(t.map(e=>e.pathname).filter(Boolean)).size<=1)return t.map(e=>e.instruction).join("\n\n");let n=new Map;for(let e of t){let t=e.pathname||"(unknown)",a=n.get(t)??[];a.push(e.instruction),n.set(t,a)}return[...n.entries()].map(([e,t])=>`\`${e}\`\n${t.map(e=>`- ${e}`).join("\n")}`).join("\n")}function S(e,t=96){let n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,Math.max(0,t-3))}...`:n}var M=r(null),N=r(void 0);export{o as a,s as b,c,p as d,u as e,f,d as g,g as h,x as i,y as j,b as k,k as l,S as m,M as n,N as o};
|