@popmelt.com/core 0.15.0 → 0.16.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/dist/index.d.mts CHANGED
@@ -1,31 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { PropsWithChildren } from 'react';
3
-
4
- declare const STICKER_COLOR_NAMES: readonly ["slate", "gray", "zinc", "neutral", "stone", "red", "orange", "amber", "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", "violet", "purple", "fuchsia", "pink", "rose"];
5
- type StickerColorName = (typeof STICKER_COLOR_NAMES)[number];
6
- declare const STICKER_COLOR_STEPS: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
7
- type StickerColorStep = (typeof STICKER_COLOR_STEPS)[number];
8
-
9
- declare const STICKER_FAMILIES: readonly ["padding", "margin", "border", "radius", "stack", "grid", "text", "color", "transform", "opacity"];
10
- type StickerFamily = (typeof STICKER_FAMILIES)[number];
11
- declare const SPACING_STEPS: readonly [0, 1, 2, 3, 4, 6, 8, 10, 12, 16];
12
- declare const TRANSLATE_STEPS: readonly [-16, -12, -10, -8, -6, -4, -3, -2, -1, 0, 1, 2, 3, 4, 6, 8, 10, 12, 16];
13
- declare const BORDER_STEPS: readonly [0, 1, 2, 4, 8];
14
- declare const DIRECTION_STEPS: readonly ["vertical", "horizontal"];
15
- declare const ALIGN_STEPS: readonly ["stretch", "start", "center", "end", "baseline"];
16
- declare const JUSTIFY_STEPS: readonly ["start", "center", "end", "between", "around", "evenly"];
17
- declare const GRID_COUNT_STEPS: readonly [1, 2, 3, 4, 5, 6];
18
- declare const FONT_SIZE_STEPS: readonly ["xs", "sm", "base", "lg", "xl", "2xl", "3xl", "4xl"];
19
- declare const FONT_WEIGHT_STEPS: readonly [300, 400, 500, 600, 700, 800];
20
- declare const LINE_HEIGHT_STEPS: readonly ["none", "tight", "snug", "normal", "relaxed", "loose"];
21
- declare const LETTER_SPACING_STEPS: readonly ["tighter", "tight", "normal", "wide", "wider", "widest"];
22
- declare const TEXT_ALIGN_STEPS: readonly ["left", "center", "right", "justify"];
23
- declare const SCALE_STEPS: readonly [25, 50, 75, 90, 95, 100, 105, 110, 125, 150];
24
- declare const ROTATE_STEPS: readonly [-180, -90, -45, -25, -12, -6, -3, -2, -1, 0, 1, 2, 3, 6, 12, 25, 45, 90, 180];
25
- declare const OPACITY_STEPS: readonly [0, 5, 10, 20, 25, 30, 40, 50, 60, 70, 75, 80, 90, 95, 100];
26
- declare const MIX_BLEND_STEPS: readonly ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"];
27
- type StickerStep = (typeof SPACING_STEPS)[number] | (typeof BORDER_STEPS)[number] | (typeof DIRECTION_STEPS)[number] | (typeof ALIGN_STEPS)[number] | (typeof JUSTIFY_STEPS)[number] | (typeof GRID_COUNT_STEPS)[number] | (typeof FONT_SIZE_STEPS)[number] | (typeof FONT_WEIGHT_STEPS)[number] | (typeof LINE_HEIGHT_STEPS)[number] | (typeof LETTER_SPACING_STEPS)[number] | (typeof TEXT_ALIGN_STEPS)[number] | (typeof TRANSLATE_STEPS)[number] | (typeof SCALE_STEPS)[number] | (typeof ROTATE_STEPS)[number] | (typeof OPACITY_STEPS)[number] | (typeof MIX_BLEND_STEPS)[number] | StickerColorStep;
28
- type StickerSubproperty = 'all' | 'x' | 'y' | 'top' | 'right' | 'bottom' | 'left' | 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left' | 'vertical' | 'horizontal' | 'direction' | 'gap' | 'align' | 'justify' | 'rows' | 'columns' | 'size' | 'weight' | 'line-height' | 'letter-spacing' | 'text-align' | 'color' | 'translate' | 'scale' | 'rotate' | 'opacity' | 'mix-blend' | StickerColorName;
3
+ import { I as ImageRecognitionProvider, P as PopmeltSubjectAdapter, a as ImageSubjectAdapterOptions, A as Annotation, E as ElementInfo, b as AnnotationAttachment, S as SubjectFeedbackAttachment, c as StyleModification, T as TextModification, D as DomModification, d as SpacingTokenChange } from './image-adapter-D8L8QumX.mjs';
4
+ export { e as AnnotationType, B as BridgeStatus, C as ClaudeResponse, f as ImageObjectContext, O as OpaqueTargetReference, g as Point, h as PopmeltSubject, i as PopmeltSubjectBounds, j as PopmeltSubjectCreationSession, k as PopmeltSurfaceSnapshot, R as ReactSourceLocation, l as StyleChange, m as ToolType } from './image-adapter-D8L8QumX.mjs';
29
5
 
30
6
  /** Client-side envelope used for persisted and streaming bridge events. */
31
7
  type BridgeEvent = {
@@ -34,207 +10,24 @@ type BridgeEvent = {
34
10
  timestamp: number;
35
11
  };
36
12
 
37
- type AnnotationLifecycleStatus = 'pending' | 'sending' | 'in_flight' | 'resolved' | 'needs_review' | 'dismissed' | 'waiting_input' | 'failed';
38
- type ScopeBreadth = 'instance' | 'pattern';
39
- type ScopeTarget = 'element' | 'component' | 'token';
40
- type Scope = {
41
- breadth: ScopeBreadth;
42
- target: ScopeTarget;
43
- };
44
- declare const TOOL_TYPES: readonly ["inspector", "sticker", "model"];
45
- type ToolType = (typeof TOOL_TYPES)[number];
46
- declare const LEGACY_ANNOTATION_TYPES: readonly ["freehand", "line", "rectangle", "circle"];
47
- type LegacyAnnotationType = (typeof LEGACY_ANNOTATION_TYPES)[number];
48
- type AnnotationType = LegacyAnnotationType | 'text';
49
- type Point = {
50
- x: number;
51
- y: number;
52
- };
53
- type AnnotationRevealStep = {
54
- triggerSelector: string;
55
- targetSelector?: string;
56
- label: string;
57
- };
58
- type AnnotationRevealRecipe = {
59
- steps: AnnotationRevealStep[];
60
- location: string[];
61
- };
62
- type ElementInfo = {
63
- selector: string;
64
- tagName: string;
65
- /** Adapter-owned semantic name for a non-DOM subject. */
66
- subjectLabel?: string;
67
- id?: string;
68
- className?: string;
69
- textContent?: string;
70
- dataAttributes?: Record<string, string>;
71
- reactComponent?: string;
72
- context?: string;
73
- revealRecipe?: AnnotationRevealRecipe;
74
- };
75
- /** Renderer-owned identity for a target that does not exist as a DOM node. */
76
- type OpaqueTargetReference = {
77
- adapter: string;
78
- key: string;
79
- };
80
- type StyleChange = {
81
- property: string;
82
- original: string;
83
- modified: string;
84
- token?: string;
85
- sticker?: {
86
- family: StickerFamily;
87
- subproperty: StickerSubproperty;
88
- step: StickerStep;
89
- axisSteps?: {
90
- x: StickerStep;
91
- y: StickerStep;
92
- };
93
- };
94
- };
95
- type StyleModification = {
96
- selector: string;
97
- durableSelector?: string;
98
- element: ElementInfo;
99
- changes: StyleChange[];
100
- createdAt?: number;
101
- annotationNumber?: number;
102
- captured?: boolean;
103
- pathname?: string;
104
- };
105
- type TextModification = {
106
- selector: string;
107
- durableSelector?: string;
108
- element: ElementInfo;
109
- textNodePath: number[];
110
- original: string;
111
- modified: string;
112
- createdAt?: number;
113
- annotationNumber?: number;
114
- captured?: boolean;
115
- pathname?: string;
116
- };
117
- type DomInsertionPlacement = 'before' | 'after';
118
- type DomModification = {
119
- id: string;
120
- operation: 'move' | 'copy';
121
- selector: string;
122
- durableSelector?: string;
123
- element: ElementInfo;
124
- sourceSelector?: string;
125
- sourceDurableSelector?: string;
126
- sourceElement?: ElementInfo;
127
- originalParentSelector?: string;
128
- originalParentDurableSelector?: string;
129
- originalIndex?: number;
130
- targetParentSelector: string;
131
- targetParentDurableSelector?: string;
132
- targetIndex: number;
133
- referenceSelector?: string;
134
- referenceDurableSelector?: string;
135
- placement: DomInsertionPlacement;
136
- captured?: boolean;
137
- pathname?: string;
138
- };
139
- type SpacingElementEvidence = {
140
- selector: string;
141
- reactComponent?: string;
142
- className: string;
143
- property: string;
144
- matchedClass?: string;
145
- suggestedClass?: string;
146
- };
147
- type SpacingTokenChange = {
148
- id: string;
149
- tokenPath: string;
150
- tokenName: string;
151
- originalPx: number;
152
- newPx: number;
153
- captured?: boolean;
154
- affectedElements: SpacingElementEvidence[];
155
- };
156
- type AnnotationAttachment = {
157
- id: string;
158
- name: string;
159
- mimeType: string;
160
- size: number;
161
- kind: 'svg' | 'text';
13
+ type PopmeltExtensionRuntime = {
14
+ /** Optional perception contribution for Core's built-in image adapter. */
15
+ imageRecognition?: ImageRecognitionProvider;
16
+ /** Optional non-DOM subject adapters contributed by the extension. */
17
+ subjectAdapters?: readonly PopmeltSubjectAdapter[];
18
+ /** Release extension-owned resources. */
19
+ dispose?(): void | Promise<void>;
162
20
  };
163
- type Annotation = {
21
+ type PopmeltExtension = {
22
+ /** Stable package-level identity used to reconcile extension configuration. */
164
23
  id: string;
165
- type: AnnotationType;
166
- points: Point[];
167
- color: string;
168
- strokeWidth: number;
169
- text?: string;
170
- fontSize?: number;
171
- timestamp: number;
172
- groupId?: string;
173
- captured?: boolean;
174
- status?: AnnotationLifecycleStatus;
175
- question?: string;
176
- resolutionSummary?: string;
177
- scope?: Scope | null;
178
- replyCount?: number;
179
- replyJobIds?: string[];
180
- threadId?: string;
181
- targetBindingId?: string;
182
- target?: OpaqueTargetReference;
183
- pathname?: string;
184
- elements?: ElementInfo[];
185
- linkedSelector?: string;
186
- linkedAnchor?: 'top-left' | 'bottom-left';
187
- imageCount?: number;
188
- attachments?: AnnotationAttachment[];
189
- };
190
- type BridgeStatus = {
191
- ok: boolean;
192
- activeJob: {
193
- id: string;
194
- status: string;
195
- } | null;
196
- queueDepth: number;
197
- sessionId: string | null;
198
- };
199
- type ClaudeResponse = {
200
- jobId: string;
201
- sessionId?: string;
202
- text: string;
203
- success: boolean;
204
- toolsUsed: string[];
24
+ /** Stable signature for configuration changes that require reactivation. */
25
+ configurationKey: string;
26
+ /** Activate lazily after the Core provider mounts in the browser. */
27
+ activate(): PopmeltExtensionRuntime;
205
28
  };
206
29
 
207
- type PopmeltSubjectBounds = {
208
- left: number;
209
- top: number;
210
- width: number;
211
- height: number;
212
- };
213
- type PopmeltSubject = {
214
- key: string;
215
- label: string;
216
- bounds: PopmeltSubjectBounds;
217
- context?: string;
218
- data?: Record<string, string>;
219
- };
220
- type PopmeltSurfaceSnapshot = {
221
- element: HTMLCanvasElement;
222
- dataUrl: string;
223
- };
224
- /**
225
- * Minimal renderer boundary for non-DOM subjects. The adapter owns hit testing,
226
- * durable keys, and viewport projection; Popmelt owns annotations and threads.
227
- */
228
- type PopmeltSubjectAdapter = {
229
- id: string;
230
- hitTest(clientPoint: {
231
- x: number;
232
- y: number;
233
- }): PopmeltSubject | null;
234
- resolve(key: string): PopmeltSubject | null;
235
- /** Optional bitmap capture for renderer surfaces that DOM cloning cannot read. */
236
- captureSurfaces?(): readonly PopmeltSurfaceSnapshot[] | Promise<readonly PopmeltSurfaceSnapshot[]>;
237
- };
30
+ type ImageAnnotationOptions = Omit<ImageSubjectAdapterOptions, 'id'>;
238
31
 
239
32
  declare global {
240
33
  interface Window {
@@ -256,8 +49,12 @@ type PopmeltProviderProps = PropsWithChildren<{
256
49
  navigate?: (url: string) => void | Promise<unknown>;
257
50
  /** Optional non-DOM renderer adapters, such as Three.js scene subjects. */
258
51
  subjectAdapters?: readonly PopmeltSubjectAdapter[];
52
+ /** Optional packages that contribute perception or additional subject surfaces. */
53
+ extensions?: readonly PopmeltExtension[];
54
+ /** Manual image annotation is enabled by default; false disables the built-in adapter. */
55
+ imageAnnotation?: boolean | ImageAnnotationOptions;
259
56
  }>;
260
- declare function PopmeltProvider({ children, enabled, bridgeUrl, projectId: projectIdProp, navigate: navigateProp, subjectAdapters, }: PopmeltProviderProps): react.JSX.Element;
57
+ declare function PopmeltProvider({ children, enabled, bridgeUrl, projectId: projectIdProp, navigate: navigateProp, subjectAdapters, extensions, imageAnnotation, }: PopmeltProviderProps): react.JSX.Element;
261
58
  declare function usePopmelt(): PopmeltContextValue;
262
59
 
263
60
  type AnnotationData = {
@@ -270,6 +67,7 @@ type AnnotationData = {
270
67
  elements: ElementInfo[];
271
68
  imageCount?: number;
272
69
  attachments?: AnnotationAttachment[];
70
+ subjectFeedback?: SubjectFeedbackAttachment;
273
71
  };
274
72
  type FeedbackData = {
275
73
  timestamp: string;
@@ -290,4 +88,4 @@ type FeedbackData = {
290
88
  spacingTokenChanges?: SpacingTokenChange[];
291
89
  };
292
90
 
293
- export { type Annotation, type AnnotationType, type BridgeEvent, type BridgeStatus, type ClaudeResponse, type ElementInfo, type FeedbackData, type OpaqueTargetReference, type Point, PopmeltProvider, type PopmeltSubject, type PopmeltSubjectAdapter, type PopmeltSubjectBounds, type PopmeltSurfaceSnapshot, type StyleChange, type StyleModification, type ToolType, usePopmelt };
91
+ export { Annotation, type BridgeEvent, ElementInfo, type FeedbackData, type ImageAnnotationOptions, type PopmeltExtension, type PopmeltExtensionRuntime, PopmeltProvider, type PopmeltProviderProps, PopmeltSubjectAdapter, StyleModification, usePopmelt };