react-grab 0.1.24 → 0.1.26
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 +109 -7
- package/dist/chunk-447CSJVY.js +26 -0
- package/dist/chunk-EMBZHHMN.js +101 -0
- package/dist/chunk-GGMYMQUS.cjs +101 -0
- package/dist/chunk-LCM4WNAK.cjs +26 -0
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/{index-BurXddDF.d.cts → index-CN8HkCli.d.cts} +2 -2
- package/dist/{index-BurXddDF.d.ts → index-CN8HkCli.d.ts} +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.global.js +37 -37
- package/dist/index.js +1 -1
- package/dist/primitives.cjs +2 -2
- package/dist/primitives.d.cts +6 -2
- package/dist/primitives.d.ts +6 -2
- package/dist/primitives.js +2 -2
- package/dist/styles.css +1 -1
- package/package.json +3 -13
- package/dist/chunk-CHTY5GHQ.cjs +0 -26
- package/dist/chunk-UERZTOK6.js +0 -101
- package/dist/chunk-XWSK4QRO.cjs +0 -101
- package/dist/chunk-Z5IMKMDB.js +0 -26
- package/dist/react.cjs +0 -19239
- package/dist/react.d.cts +0 -345
- package/dist/react.d.ts +0 -345
- package/dist/react.js +0 -19225
package/dist/react.d.cts
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
type DeepPartial<T> = {
|
|
2
|
-
[P in keyof T]?: T[P] extends object ? T[P] extends (...args: unknown[]) => unknown ? T[P] : DeepPartial<T[P]> : T[P];
|
|
3
|
-
};
|
|
4
|
-
interface Theme {
|
|
5
|
-
/**
|
|
6
|
-
* Globally toggle the entire overlay
|
|
7
|
-
* @default true
|
|
8
|
-
*/
|
|
9
|
-
enabled?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Base hue (0-360) used to generate colors throughout the interface using HSL color space
|
|
12
|
-
* @default 0
|
|
13
|
-
*/
|
|
14
|
-
hue?: number;
|
|
15
|
-
/**
|
|
16
|
-
* The highlight box that appears when hovering over an element before selecting it
|
|
17
|
-
*/
|
|
18
|
-
selectionBox?: {
|
|
19
|
-
/**
|
|
20
|
-
* Whether to show the selection highlight
|
|
21
|
-
* @default true
|
|
22
|
-
*/
|
|
23
|
-
enabled?: boolean;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* The rectangular selection area that appears when clicking and dragging to select multiple elements
|
|
27
|
-
*/
|
|
28
|
-
dragBox?: {
|
|
29
|
-
/**
|
|
30
|
-
* Whether to show the drag selection box
|
|
31
|
-
* @default true
|
|
32
|
-
*/
|
|
33
|
-
enabled?: boolean;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Brief flash/highlight boxes that appear on elements immediately after they're successfully grabbed/copied
|
|
37
|
-
*/
|
|
38
|
-
grabbedBoxes?: {
|
|
39
|
-
/**
|
|
40
|
-
* Whether to show these success flash effects
|
|
41
|
-
* @default true
|
|
42
|
-
*/
|
|
43
|
-
enabled?: boolean;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* The floating label that follows the cursor showing information about the currently hovered element
|
|
47
|
-
*/
|
|
48
|
-
elementLabel?: {
|
|
49
|
-
/**
|
|
50
|
-
* Whether to show the label
|
|
51
|
-
* @default true
|
|
52
|
-
*/
|
|
53
|
-
enabled?: boolean;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* The crosshair cursor overlay that helps with precise element targeting
|
|
57
|
-
*/
|
|
58
|
-
crosshair?: {
|
|
59
|
-
/**
|
|
60
|
-
* Whether to show the crosshair
|
|
61
|
-
* @default true
|
|
62
|
-
*/
|
|
63
|
-
enabled?: boolean;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* The floating toolbar that allows toggling React Grab activation
|
|
67
|
-
*/
|
|
68
|
-
toolbar?: {
|
|
69
|
-
/**
|
|
70
|
-
* Whether to show the toolbar
|
|
71
|
-
* @default true
|
|
72
|
-
*/
|
|
73
|
-
enabled?: boolean;
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
interface ReactGrabState {
|
|
77
|
-
isActive: boolean;
|
|
78
|
-
isDragging: boolean;
|
|
79
|
-
isCopying: boolean;
|
|
80
|
-
isPromptMode: boolean;
|
|
81
|
-
isCrosshairVisible: boolean;
|
|
82
|
-
isSelectionBoxVisible: boolean;
|
|
83
|
-
isDragBoxVisible: boolean;
|
|
84
|
-
targetElement: Element | null;
|
|
85
|
-
dragBounds: DragRect | null;
|
|
86
|
-
/**
|
|
87
|
-
* Currently visible grabbed boxes (success flash effects).
|
|
88
|
-
* These are temporary visual indicators shown after elements are grabbed/copied.
|
|
89
|
-
*/
|
|
90
|
-
grabbedBoxes: Array<{
|
|
91
|
-
id: string;
|
|
92
|
-
bounds: OverlayBounds;
|
|
93
|
-
createdAt: number;
|
|
94
|
-
}>;
|
|
95
|
-
labelInstances: Array<{
|
|
96
|
-
id: string;
|
|
97
|
-
status: SelectionLabelStatus;
|
|
98
|
-
tagName: string;
|
|
99
|
-
componentName?: string;
|
|
100
|
-
createdAt: number;
|
|
101
|
-
}>;
|
|
102
|
-
selectionFilePath: string | null;
|
|
103
|
-
toolbarState: ToolbarState | null;
|
|
104
|
-
}
|
|
105
|
-
type ElementLabelVariant = "hover" | "processing" | "success";
|
|
106
|
-
interface PromptModeContext {
|
|
107
|
-
x: number;
|
|
108
|
-
y: number;
|
|
109
|
-
targetElement: Element | null;
|
|
110
|
-
}
|
|
111
|
-
interface CrosshairContext {
|
|
112
|
-
x: number;
|
|
113
|
-
y: number;
|
|
114
|
-
}
|
|
115
|
-
interface ElementLabelContext {
|
|
116
|
-
x: number;
|
|
117
|
-
y: number;
|
|
118
|
-
content: string;
|
|
119
|
-
element?: Element;
|
|
120
|
-
tagName?: string;
|
|
121
|
-
componentName?: string;
|
|
122
|
-
filePath?: string;
|
|
123
|
-
lineNumber?: number;
|
|
124
|
-
}
|
|
125
|
-
type ActivationKey = string | ((event: KeyboardEvent) => boolean);
|
|
126
|
-
interface AgentContext<T = unknown> {
|
|
127
|
-
content: string[];
|
|
128
|
-
prompt: string;
|
|
129
|
-
options?: T;
|
|
130
|
-
sessionId?: string;
|
|
131
|
-
}
|
|
132
|
-
interface AgentSession {
|
|
133
|
-
id: string;
|
|
134
|
-
context: AgentContext;
|
|
135
|
-
lastStatus: string;
|
|
136
|
-
isStreaming: boolean;
|
|
137
|
-
isFading?: boolean;
|
|
138
|
-
createdAt: number;
|
|
139
|
-
lastUpdatedAt: number;
|
|
140
|
-
position: {
|
|
141
|
-
x: number;
|
|
142
|
-
y: number;
|
|
143
|
-
};
|
|
144
|
-
selectionBounds: OverlayBounds[];
|
|
145
|
-
tagName?: string;
|
|
146
|
-
componentName?: string;
|
|
147
|
-
error?: string;
|
|
148
|
-
}
|
|
149
|
-
interface AgentProvider<T = any> {
|
|
150
|
-
send: (context: AgentContext<T>, signal: AbortSignal) => AsyncIterable<string>;
|
|
151
|
-
resume?: (sessionId: string, signal: AbortSignal, storage: AgentSessionStorage) => AsyncIterable<string>;
|
|
152
|
-
abort?: (sessionId: string) => Promise<void>;
|
|
153
|
-
supportsResume?: boolean;
|
|
154
|
-
supportsFollowUp?: boolean;
|
|
155
|
-
dismissButtonText?: string;
|
|
156
|
-
checkConnection?: () => Promise<boolean>;
|
|
157
|
-
getCompletionMessage?: () => string | undefined;
|
|
158
|
-
undo?: () => Promise<void>;
|
|
159
|
-
canUndo?: () => boolean;
|
|
160
|
-
redo?: () => Promise<void>;
|
|
161
|
-
canRedo?: () => boolean;
|
|
162
|
-
}
|
|
163
|
-
interface AgentSessionStorage {
|
|
164
|
-
getItem(key: string): string | null;
|
|
165
|
-
setItem(key: string, value: string): void;
|
|
166
|
-
removeItem(key: string): void;
|
|
167
|
-
}
|
|
168
|
-
interface AgentCompleteResult {
|
|
169
|
-
error?: string;
|
|
170
|
-
}
|
|
171
|
-
interface AgentOptions<T = any> {
|
|
172
|
-
provider?: AgentProvider<T>;
|
|
173
|
-
storage?: AgentSessionStorage | null;
|
|
174
|
-
getOptions?: () => T;
|
|
175
|
-
onStart?: (session: AgentSession, elements: Element[]) => void;
|
|
176
|
-
onStatus?: (status: string, session: AgentSession) => void;
|
|
177
|
-
onComplete?: (session: AgentSession, elements: Element[]) => AgentCompleteResult | void | Promise<AgentCompleteResult | void>;
|
|
178
|
-
onError?: (error: Error, session: AgentSession) => void;
|
|
179
|
-
onResume?: (session: AgentSession) => void;
|
|
180
|
-
onAbort?: (session: AgentSession, elements: Element[]) => void;
|
|
181
|
-
onUndo?: (session: AgentSession, elements: Element[]) => void;
|
|
182
|
-
onDismiss?: (session: AgentSession, elements: Element[]) => void;
|
|
183
|
-
}
|
|
184
|
-
type ActivationMode = "toggle" | "hold";
|
|
185
|
-
interface ActionContextHooks {
|
|
186
|
-
transformHtmlContent: (html: string, elements: Element[]) => Promise<string>;
|
|
187
|
-
onOpenFile: (filePath: string, lineNumber?: number) => boolean | void;
|
|
188
|
-
transformOpenFileUrl: (url: string, filePath: string, lineNumber?: number) => string;
|
|
189
|
-
}
|
|
190
|
-
interface ActionContext {
|
|
191
|
-
element: Element;
|
|
192
|
-
elements: Element[];
|
|
193
|
-
filePath?: string;
|
|
194
|
-
lineNumber?: number;
|
|
195
|
-
componentName?: string;
|
|
196
|
-
tagName?: string;
|
|
197
|
-
enterPromptMode?: (agent?: AgentOptions) => void;
|
|
198
|
-
hooks: ActionContextHooks;
|
|
199
|
-
performWithFeedback: (action: () => Promise<boolean>) => Promise<void>;
|
|
200
|
-
hideContextMenu: () => void;
|
|
201
|
-
cleanup: () => void;
|
|
202
|
-
}
|
|
203
|
-
interface ContextMenuActionContext extends ActionContext {
|
|
204
|
-
copy?: () => void;
|
|
205
|
-
}
|
|
206
|
-
interface ContextMenuAction {
|
|
207
|
-
id: string;
|
|
208
|
-
label: string;
|
|
209
|
-
target?: "context-menu";
|
|
210
|
-
shortcut?: string;
|
|
211
|
-
enabled?: boolean | ((context: ActionContext) => boolean);
|
|
212
|
-
onAction: (context: ContextMenuActionContext) => void | Promise<void>;
|
|
213
|
-
agent?: AgentOptions;
|
|
214
|
-
}
|
|
215
|
-
interface PluginHooks {
|
|
216
|
-
onActivate?: () => void;
|
|
217
|
-
onDeactivate?: () => void;
|
|
218
|
-
cancelPendingToolbarActions?: () => void;
|
|
219
|
-
onElementHover?: (element: Element) => void;
|
|
220
|
-
onElementSelect?: (element: Element) => boolean | void | Promise<boolean>;
|
|
221
|
-
onDragStart?: (startX: number, startY: number) => void;
|
|
222
|
-
onDragEnd?: (elements: Element[], bounds: DragRect) => void;
|
|
223
|
-
onBeforeCopy?: (elements: Element[]) => void | Promise<void>;
|
|
224
|
-
transformCopyContent?: (content: string, elements: Element[]) => string | Promise<string>;
|
|
225
|
-
onAfterCopy?: (elements: Element[], success: boolean) => void;
|
|
226
|
-
onCopySuccess?: (elements: Element[], content: string) => void;
|
|
227
|
-
onCopyError?: (error: Error) => void;
|
|
228
|
-
onStateChange?: (state: ReactGrabState) => void;
|
|
229
|
-
onPromptModeChange?: (isPromptMode: boolean, context: PromptModeContext) => void;
|
|
230
|
-
onSelectionBox?: (visible: boolean, bounds: OverlayBounds | null, element: Element | null) => void;
|
|
231
|
-
onDragBox?: (visible: boolean, bounds: OverlayBounds | null) => void;
|
|
232
|
-
onGrabbedBox?: (bounds: OverlayBounds, element: Element) => void;
|
|
233
|
-
onElementLabel?: (visible: boolean, variant: ElementLabelVariant, context: ElementLabelContext) => void;
|
|
234
|
-
onCrosshair?: (visible: boolean, context: CrosshairContext) => void;
|
|
235
|
-
onContextMenu?: (element: Element, position: {
|
|
236
|
-
x: number;
|
|
237
|
-
y: number;
|
|
238
|
-
}) => void;
|
|
239
|
-
onOpenFile?: (filePath: string, lineNumber?: number) => boolean | void;
|
|
240
|
-
transformHtmlContent?: (html: string, elements: Element[]) => string | Promise<string>;
|
|
241
|
-
transformAgentContext?: (context: AgentContext, elements: Element[]) => AgentContext | Promise<AgentContext>;
|
|
242
|
-
transformActionContext?: (context: ActionContext) => ActionContext;
|
|
243
|
-
transformOpenFileUrl?: (url: string, filePath: string, lineNumber?: number) => string;
|
|
244
|
-
transformSnippet?: (snippet: string, element: Element) => string | Promise<string>;
|
|
245
|
-
}
|
|
246
|
-
interface ToolbarMenuAction {
|
|
247
|
-
id: string;
|
|
248
|
-
label: string;
|
|
249
|
-
shortcut?: string;
|
|
250
|
-
target: "toolbar";
|
|
251
|
-
enabled?: boolean | (() => boolean);
|
|
252
|
-
isActive?: () => boolean;
|
|
253
|
-
onAction: () => void | Promise<void>;
|
|
254
|
-
}
|
|
255
|
-
type PluginAction = ContextMenuAction | ToolbarMenuAction;
|
|
256
|
-
interface PluginConfig {
|
|
257
|
-
theme?: DeepPartial<Theme>;
|
|
258
|
-
options?: SettableOptions;
|
|
259
|
-
actions?: PluginAction[];
|
|
260
|
-
hooks?: PluginHooks;
|
|
261
|
-
cleanup?: () => void;
|
|
262
|
-
}
|
|
263
|
-
interface Plugin {
|
|
264
|
-
name: string;
|
|
265
|
-
theme?: DeepPartial<Theme>;
|
|
266
|
-
options?: SettableOptions;
|
|
267
|
-
actions?: PluginAction[];
|
|
268
|
-
hooks?: PluginHooks;
|
|
269
|
-
setup?: (api: ReactGrabAPI, hooks: ActionContextHooks) => PluginConfig | void;
|
|
270
|
-
}
|
|
271
|
-
interface Options {
|
|
272
|
-
enabled?: boolean;
|
|
273
|
-
activationMode?: ActivationMode;
|
|
274
|
-
keyHoldDuration?: number;
|
|
275
|
-
allowActivationInsideInput?: boolean;
|
|
276
|
-
maxContextLines?: number;
|
|
277
|
-
activationKey?: ActivationKey;
|
|
278
|
-
getContent?: (elements: Element[]) => Promise<string> | string;
|
|
279
|
-
/**
|
|
280
|
-
* Whether to freeze React state updates while React Grab is active.
|
|
281
|
-
* This prevents UI changes from interfering with element selection.
|
|
282
|
-
* @default true
|
|
283
|
-
*/
|
|
284
|
-
freezeReactUpdates?: boolean;
|
|
285
|
-
}
|
|
286
|
-
interface SettableOptions extends Options {
|
|
287
|
-
enabled?: never;
|
|
288
|
-
}
|
|
289
|
-
interface SourceInfo {
|
|
290
|
-
filePath: string;
|
|
291
|
-
lineNumber: number | null;
|
|
292
|
-
componentName: string | null;
|
|
293
|
-
}
|
|
294
|
-
interface ToolbarState {
|
|
295
|
-
edge: "top" | "bottom" | "left" | "right";
|
|
296
|
-
ratio: number;
|
|
297
|
-
collapsed: boolean;
|
|
298
|
-
enabled: boolean;
|
|
299
|
-
}
|
|
300
|
-
interface ReactGrabAPI {
|
|
301
|
-
activate: () => void;
|
|
302
|
-
deactivate: () => void;
|
|
303
|
-
toggle: () => void;
|
|
304
|
-
comment: () => void;
|
|
305
|
-
isActive: () => boolean;
|
|
306
|
-
isEnabled: () => boolean;
|
|
307
|
-
setEnabled: (enabled: boolean) => void;
|
|
308
|
-
getToolbarState: () => ToolbarState | null;
|
|
309
|
-
setToolbarState: (state: Partial<ToolbarState>) => void;
|
|
310
|
-
onToolbarStateChange: (callback: (state: ToolbarState) => void) => () => void;
|
|
311
|
-
dispose: () => void;
|
|
312
|
-
copyElement: (elements: Element | Element[]) => Promise<boolean>;
|
|
313
|
-
getSource: (element: Element) => Promise<SourceInfo | null>;
|
|
314
|
-
getStackContext: (element: Element) => Promise<string>;
|
|
315
|
-
getState: () => ReactGrabState;
|
|
316
|
-
setOptions: (options: SettableOptions) => void;
|
|
317
|
-
registerPlugin: (plugin: Plugin) => void;
|
|
318
|
-
unregisterPlugin: (name: string) => void;
|
|
319
|
-
getPlugins: () => string[];
|
|
320
|
-
getDisplayName: (element: Element) => string | null;
|
|
321
|
-
}
|
|
322
|
-
interface OverlayBounds {
|
|
323
|
-
borderRadius: string;
|
|
324
|
-
height: number;
|
|
325
|
-
transform: string;
|
|
326
|
-
width: number;
|
|
327
|
-
x: number;
|
|
328
|
-
y: number;
|
|
329
|
-
}
|
|
330
|
-
type SelectionLabelStatus = "idle" | "copying" | "copied" | "fading" | "error";
|
|
331
|
-
interface DragRect {
|
|
332
|
-
x: number;
|
|
333
|
-
y: number;
|
|
334
|
-
width: number;
|
|
335
|
-
height: number;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
declare global {
|
|
339
|
-
interface Window {
|
|
340
|
-
__REACT_GRAB__?: ReactGrabAPI;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
declare const ReactGrab: (props: Options) => null;
|
|
344
|
-
|
|
345
|
-
export { ReactGrab };
|
package/dist/react.d.ts
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
type DeepPartial<T> = {
|
|
2
|
-
[P in keyof T]?: T[P] extends object ? T[P] extends (...args: unknown[]) => unknown ? T[P] : DeepPartial<T[P]> : T[P];
|
|
3
|
-
};
|
|
4
|
-
interface Theme {
|
|
5
|
-
/**
|
|
6
|
-
* Globally toggle the entire overlay
|
|
7
|
-
* @default true
|
|
8
|
-
*/
|
|
9
|
-
enabled?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Base hue (0-360) used to generate colors throughout the interface using HSL color space
|
|
12
|
-
* @default 0
|
|
13
|
-
*/
|
|
14
|
-
hue?: number;
|
|
15
|
-
/**
|
|
16
|
-
* The highlight box that appears when hovering over an element before selecting it
|
|
17
|
-
*/
|
|
18
|
-
selectionBox?: {
|
|
19
|
-
/**
|
|
20
|
-
* Whether to show the selection highlight
|
|
21
|
-
* @default true
|
|
22
|
-
*/
|
|
23
|
-
enabled?: boolean;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* The rectangular selection area that appears when clicking and dragging to select multiple elements
|
|
27
|
-
*/
|
|
28
|
-
dragBox?: {
|
|
29
|
-
/**
|
|
30
|
-
* Whether to show the drag selection box
|
|
31
|
-
* @default true
|
|
32
|
-
*/
|
|
33
|
-
enabled?: boolean;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Brief flash/highlight boxes that appear on elements immediately after they're successfully grabbed/copied
|
|
37
|
-
*/
|
|
38
|
-
grabbedBoxes?: {
|
|
39
|
-
/**
|
|
40
|
-
* Whether to show these success flash effects
|
|
41
|
-
* @default true
|
|
42
|
-
*/
|
|
43
|
-
enabled?: boolean;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* The floating label that follows the cursor showing information about the currently hovered element
|
|
47
|
-
*/
|
|
48
|
-
elementLabel?: {
|
|
49
|
-
/**
|
|
50
|
-
* Whether to show the label
|
|
51
|
-
* @default true
|
|
52
|
-
*/
|
|
53
|
-
enabled?: boolean;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* The crosshair cursor overlay that helps with precise element targeting
|
|
57
|
-
*/
|
|
58
|
-
crosshair?: {
|
|
59
|
-
/**
|
|
60
|
-
* Whether to show the crosshair
|
|
61
|
-
* @default true
|
|
62
|
-
*/
|
|
63
|
-
enabled?: boolean;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* The floating toolbar that allows toggling React Grab activation
|
|
67
|
-
*/
|
|
68
|
-
toolbar?: {
|
|
69
|
-
/**
|
|
70
|
-
* Whether to show the toolbar
|
|
71
|
-
* @default true
|
|
72
|
-
*/
|
|
73
|
-
enabled?: boolean;
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
interface ReactGrabState {
|
|
77
|
-
isActive: boolean;
|
|
78
|
-
isDragging: boolean;
|
|
79
|
-
isCopying: boolean;
|
|
80
|
-
isPromptMode: boolean;
|
|
81
|
-
isCrosshairVisible: boolean;
|
|
82
|
-
isSelectionBoxVisible: boolean;
|
|
83
|
-
isDragBoxVisible: boolean;
|
|
84
|
-
targetElement: Element | null;
|
|
85
|
-
dragBounds: DragRect | null;
|
|
86
|
-
/**
|
|
87
|
-
* Currently visible grabbed boxes (success flash effects).
|
|
88
|
-
* These are temporary visual indicators shown after elements are grabbed/copied.
|
|
89
|
-
*/
|
|
90
|
-
grabbedBoxes: Array<{
|
|
91
|
-
id: string;
|
|
92
|
-
bounds: OverlayBounds;
|
|
93
|
-
createdAt: number;
|
|
94
|
-
}>;
|
|
95
|
-
labelInstances: Array<{
|
|
96
|
-
id: string;
|
|
97
|
-
status: SelectionLabelStatus;
|
|
98
|
-
tagName: string;
|
|
99
|
-
componentName?: string;
|
|
100
|
-
createdAt: number;
|
|
101
|
-
}>;
|
|
102
|
-
selectionFilePath: string | null;
|
|
103
|
-
toolbarState: ToolbarState | null;
|
|
104
|
-
}
|
|
105
|
-
type ElementLabelVariant = "hover" | "processing" | "success";
|
|
106
|
-
interface PromptModeContext {
|
|
107
|
-
x: number;
|
|
108
|
-
y: number;
|
|
109
|
-
targetElement: Element | null;
|
|
110
|
-
}
|
|
111
|
-
interface CrosshairContext {
|
|
112
|
-
x: number;
|
|
113
|
-
y: number;
|
|
114
|
-
}
|
|
115
|
-
interface ElementLabelContext {
|
|
116
|
-
x: number;
|
|
117
|
-
y: number;
|
|
118
|
-
content: string;
|
|
119
|
-
element?: Element;
|
|
120
|
-
tagName?: string;
|
|
121
|
-
componentName?: string;
|
|
122
|
-
filePath?: string;
|
|
123
|
-
lineNumber?: number;
|
|
124
|
-
}
|
|
125
|
-
type ActivationKey = string | ((event: KeyboardEvent) => boolean);
|
|
126
|
-
interface AgentContext<T = unknown> {
|
|
127
|
-
content: string[];
|
|
128
|
-
prompt: string;
|
|
129
|
-
options?: T;
|
|
130
|
-
sessionId?: string;
|
|
131
|
-
}
|
|
132
|
-
interface AgentSession {
|
|
133
|
-
id: string;
|
|
134
|
-
context: AgentContext;
|
|
135
|
-
lastStatus: string;
|
|
136
|
-
isStreaming: boolean;
|
|
137
|
-
isFading?: boolean;
|
|
138
|
-
createdAt: number;
|
|
139
|
-
lastUpdatedAt: number;
|
|
140
|
-
position: {
|
|
141
|
-
x: number;
|
|
142
|
-
y: number;
|
|
143
|
-
};
|
|
144
|
-
selectionBounds: OverlayBounds[];
|
|
145
|
-
tagName?: string;
|
|
146
|
-
componentName?: string;
|
|
147
|
-
error?: string;
|
|
148
|
-
}
|
|
149
|
-
interface AgentProvider<T = any> {
|
|
150
|
-
send: (context: AgentContext<T>, signal: AbortSignal) => AsyncIterable<string>;
|
|
151
|
-
resume?: (sessionId: string, signal: AbortSignal, storage: AgentSessionStorage) => AsyncIterable<string>;
|
|
152
|
-
abort?: (sessionId: string) => Promise<void>;
|
|
153
|
-
supportsResume?: boolean;
|
|
154
|
-
supportsFollowUp?: boolean;
|
|
155
|
-
dismissButtonText?: string;
|
|
156
|
-
checkConnection?: () => Promise<boolean>;
|
|
157
|
-
getCompletionMessage?: () => string | undefined;
|
|
158
|
-
undo?: () => Promise<void>;
|
|
159
|
-
canUndo?: () => boolean;
|
|
160
|
-
redo?: () => Promise<void>;
|
|
161
|
-
canRedo?: () => boolean;
|
|
162
|
-
}
|
|
163
|
-
interface AgentSessionStorage {
|
|
164
|
-
getItem(key: string): string | null;
|
|
165
|
-
setItem(key: string, value: string): void;
|
|
166
|
-
removeItem(key: string): void;
|
|
167
|
-
}
|
|
168
|
-
interface AgentCompleteResult {
|
|
169
|
-
error?: string;
|
|
170
|
-
}
|
|
171
|
-
interface AgentOptions<T = any> {
|
|
172
|
-
provider?: AgentProvider<T>;
|
|
173
|
-
storage?: AgentSessionStorage | null;
|
|
174
|
-
getOptions?: () => T;
|
|
175
|
-
onStart?: (session: AgentSession, elements: Element[]) => void;
|
|
176
|
-
onStatus?: (status: string, session: AgentSession) => void;
|
|
177
|
-
onComplete?: (session: AgentSession, elements: Element[]) => AgentCompleteResult | void | Promise<AgentCompleteResult | void>;
|
|
178
|
-
onError?: (error: Error, session: AgentSession) => void;
|
|
179
|
-
onResume?: (session: AgentSession) => void;
|
|
180
|
-
onAbort?: (session: AgentSession, elements: Element[]) => void;
|
|
181
|
-
onUndo?: (session: AgentSession, elements: Element[]) => void;
|
|
182
|
-
onDismiss?: (session: AgentSession, elements: Element[]) => void;
|
|
183
|
-
}
|
|
184
|
-
type ActivationMode = "toggle" | "hold";
|
|
185
|
-
interface ActionContextHooks {
|
|
186
|
-
transformHtmlContent: (html: string, elements: Element[]) => Promise<string>;
|
|
187
|
-
onOpenFile: (filePath: string, lineNumber?: number) => boolean | void;
|
|
188
|
-
transformOpenFileUrl: (url: string, filePath: string, lineNumber?: number) => string;
|
|
189
|
-
}
|
|
190
|
-
interface ActionContext {
|
|
191
|
-
element: Element;
|
|
192
|
-
elements: Element[];
|
|
193
|
-
filePath?: string;
|
|
194
|
-
lineNumber?: number;
|
|
195
|
-
componentName?: string;
|
|
196
|
-
tagName?: string;
|
|
197
|
-
enterPromptMode?: (agent?: AgentOptions) => void;
|
|
198
|
-
hooks: ActionContextHooks;
|
|
199
|
-
performWithFeedback: (action: () => Promise<boolean>) => Promise<void>;
|
|
200
|
-
hideContextMenu: () => void;
|
|
201
|
-
cleanup: () => void;
|
|
202
|
-
}
|
|
203
|
-
interface ContextMenuActionContext extends ActionContext {
|
|
204
|
-
copy?: () => void;
|
|
205
|
-
}
|
|
206
|
-
interface ContextMenuAction {
|
|
207
|
-
id: string;
|
|
208
|
-
label: string;
|
|
209
|
-
target?: "context-menu";
|
|
210
|
-
shortcut?: string;
|
|
211
|
-
enabled?: boolean | ((context: ActionContext) => boolean);
|
|
212
|
-
onAction: (context: ContextMenuActionContext) => void | Promise<void>;
|
|
213
|
-
agent?: AgentOptions;
|
|
214
|
-
}
|
|
215
|
-
interface PluginHooks {
|
|
216
|
-
onActivate?: () => void;
|
|
217
|
-
onDeactivate?: () => void;
|
|
218
|
-
cancelPendingToolbarActions?: () => void;
|
|
219
|
-
onElementHover?: (element: Element) => void;
|
|
220
|
-
onElementSelect?: (element: Element) => boolean | void | Promise<boolean>;
|
|
221
|
-
onDragStart?: (startX: number, startY: number) => void;
|
|
222
|
-
onDragEnd?: (elements: Element[], bounds: DragRect) => void;
|
|
223
|
-
onBeforeCopy?: (elements: Element[]) => void | Promise<void>;
|
|
224
|
-
transformCopyContent?: (content: string, elements: Element[]) => string | Promise<string>;
|
|
225
|
-
onAfterCopy?: (elements: Element[], success: boolean) => void;
|
|
226
|
-
onCopySuccess?: (elements: Element[], content: string) => void;
|
|
227
|
-
onCopyError?: (error: Error) => void;
|
|
228
|
-
onStateChange?: (state: ReactGrabState) => void;
|
|
229
|
-
onPromptModeChange?: (isPromptMode: boolean, context: PromptModeContext) => void;
|
|
230
|
-
onSelectionBox?: (visible: boolean, bounds: OverlayBounds | null, element: Element | null) => void;
|
|
231
|
-
onDragBox?: (visible: boolean, bounds: OverlayBounds | null) => void;
|
|
232
|
-
onGrabbedBox?: (bounds: OverlayBounds, element: Element) => void;
|
|
233
|
-
onElementLabel?: (visible: boolean, variant: ElementLabelVariant, context: ElementLabelContext) => void;
|
|
234
|
-
onCrosshair?: (visible: boolean, context: CrosshairContext) => void;
|
|
235
|
-
onContextMenu?: (element: Element, position: {
|
|
236
|
-
x: number;
|
|
237
|
-
y: number;
|
|
238
|
-
}) => void;
|
|
239
|
-
onOpenFile?: (filePath: string, lineNumber?: number) => boolean | void;
|
|
240
|
-
transformHtmlContent?: (html: string, elements: Element[]) => string | Promise<string>;
|
|
241
|
-
transformAgentContext?: (context: AgentContext, elements: Element[]) => AgentContext | Promise<AgentContext>;
|
|
242
|
-
transformActionContext?: (context: ActionContext) => ActionContext;
|
|
243
|
-
transformOpenFileUrl?: (url: string, filePath: string, lineNumber?: number) => string;
|
|
244
|
-
transformSnippet?: (snippet: string, element: Element) => string | Promise<string>;
|
|
245
|
-
}
|
|
246
|
-
interface ToolbarMenuAction {
|
|
247
|
-
id: string;
|
|
248
|
-
label: string;
|
|
249
|
-
shortcut?: string;
|
|
250
|
-
target: "toolbar";
|
|
251
|
-
enabled?: boolean | (() => boolean);
|
|
252
|
-
isActive?: () => boolean;
|
|
253
|
-
onAction: () => void | Promise<void>;
|
|
254
|
-
}
|
|
255
|
-
type PluginAction = ContextMenuAction | ToolbarMenuAction;
|
|
256
|
-
interface PluginConfig {
|
|
257
|
-
theme?: DeepPartial<Theme>;
|
|
258
|
-
options?: SettableOptions;
|
|
259
|
-
actions?: PluginAction[];
|
|
260
|
-
hooks?: PluginHooks;
|
|
261
|
-
cleanup?: () => void;
|
|
262
|
-
}
|
|
263
|
-
interface Plugin {
|
|
264
|
-
name: string;
|
|
265
|
-
theme?: DeepPartial<Theme>;
|
|
266
|
-
options?: SettableOptions;
|
|
267
|
-
actions?: PluginAction[];
|
|
268
|
-
hooks?: PluginHooks;
|
|
269
|
-
setup?: (api: ReactGrabAPI, hooks: ActionContextHooks) => PluginConfig | void;
|
|
270
|
-
}
|
|
271
|
-
interface Options {
|
|
272
|
-
enabled?: boolean;
|
|
273
|
-
activationMode?: ActivationMode;
|
|
274
|
-
keyHoldDuration?: number;
|
|
275
|
-
allowActivationInsideInput?: boolean;
|
|
276
|
-
maxContextLines?: number;
|
|
277
|
-
activationKey?: ActivationKey;
|
|
278
|
-
getContent?: (elements: Element[]) => Promise<string> | string;
|
|
279
|
-
/**
|
|
280
|
-
* Whether to freeze React state updates while React Grab is active.
|
|
281
|
-
* This prevents UI changes from interfering with element selection.
|
|
282
|
-
* @default true
|
|
283
|
-
*/
|
|
284
|
-
freezeReactUpdates?: boolean;
|
|
285
|
-
}
|
|
286
|
-
interface SettableOptions extends Options {
|
|
287
|
-
enabled?: never;
|
|
288
|
-
}
|
|
289
|
-
interface SourceInfo {
|
|
290
|
-
filePath: string;
|
|
291
|
-
lineNumber: number | null;
|
|
292
|
-
componentName: string | null;
|
|
293
|
-
}
|
|
294
|
-
interface ToolbarState {
|
|
295
|
-
edge: "top" | "bottom" | "left" | "right";
|
|
296
|
-
ratio: number;
|
|
297
|
-
collapsed: boolean;
|
|
298
|
-
enabled: boolean;
|
|
299
|
-
}
|
|
300
|
-
interface ReactGrabAPI {
|
|
301
|
-
activate: () => void;
|
|
302
|
-
deactivate: () => void;
|
|
303
|
-
toggle: () => void;
|
|
304
|
-
comment: () => void;
|
|
305
|
-
isActive: () => boolean;
|
|
306
|
-
isEnabled: () => boolean;
|
|
307
|
-
setEnabled: (enabled: boolean) => void;
|
|
308
|
-
getToolbarState: () => ToolbarState | null;
|
|
309
|
-
setToolbarState: (state: Partial<ToolbarState>) => void;
|
|
310
|
-
onToolbarStateChange: (callback: (state: ToolbarState) => void) => () => void;
|
|
311
|
-
dispose: () => void;
|
|
312
|
-
copyElement: (elements: Element | Element[]) => Promise<boolean>;
|
|
313
|
-
getSource: (element: Element) => Promise<SourceInfo | null>;
|
|
314
|
-
getStackContext: (element: Element) => Promise<string>;
|
|
315
|
-
getState: () => ReactGrabState;
|
|
316
|
-
setOptions: (options: SettableOptions) => void;
|
|
317
|
-
registerPlugin: (plugin: Plugin) => void;
|
|
318
|
-
unregisterPlugin: (name: string) => void;
|
|
319
|
-
getPlugins: () => string[];
|
|
320
|
-
getDisplayName: (element: Element) => string | null;
|
|
321
|
-
}
|
|
322
|
-
interface OverlayBounds {
|
|
323
|
-
borderRadius: string;
|
|
324
|
-
height: number;
|
|
325
|
-
transform: string;
|
|
326
|
-
width: number;
|
|
327
|
-
x: number;
|
|
328
|
-
y: number;
|
|
329
|
-
}
|
|
330
|
-
type SelectionLabelStatus = "idle" | "copying" | "copied" | "fading" | "error";
|
|
331
|
-
interface DragRect {
|
|
332
|
-
x: number;
|
|
333
|
-
y: number;
|
|
334
|
-
width: number;
|
|
335
|
-
height: number;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
declare global {
|
|
339
|
-
interface Window {
|
|
340
|
-
__REACT_GRAB__?: ReactGrabAPI;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
declare const ReactGrab: (props: Options) => null;
|
|
344
|
-
|
|
345
|
-
export { ReactGrab };
|