grab 0.0.7 → 0.0.77
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/LICENSE +13 -11
- package/README.md +328 -93
- package/dist/chunk-RM6XONHW.cjs +8533 -0
- package/dist/chunk-VOXBYN56.js +8526 -0
- package/dist/cli.cjs +408 -0
- package/dist/core-BIJVr_bk.d.cts +308 -0
- package/dist/core-BIJVr_bk.d.ts +308 -0
- package/dist/core.cjs +30 -0
- package/dist/core.d.cts +3 -0
- package/dist/core.d.ts +3 -0
- package/dist/core.js +1 -0
- package/dist/index.cjs +67 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.global.js +94 -0
- package/dist/index.js +41 -0
- package/dist/styles.css +2 -0
- package/package.json +70 -26
- package/lib/grab.js +0 -103
- package/lib/grab.min.js +0 -10
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { StackFrame } from 'bippy/source';
|
|
2
|
+
import 'bippy';
|
|
3
|
+
|
|
4
|
+
type DeepPartial<T> = {
|
|
5
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
6
|
+
};
|
|
7
|
+
interface Theme {
|
|
8
|
+
/**
|
|
9
|
+
* Globally toggle the entire overlay
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Base hue (0-360) used to generate colors throughout the interface using HSL color space
|
|
15
|
+
* @default 0
|
|
16
|
+
*/
|
|
17
|
+
hue?: number;
|
|
18
|
+
/**
|
|
19
|
+
* The highlight box that appears when hovering over an element before selecting it
|
|
20
|
+
*/
|
|
21
|
+
selectionBox?: {
|
|
22
|
+
/**
|
|
23
|
+
* Whether to show the selection highlight
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The rectangular selection area that appears when clicking and dragging to select multiple elements
|
|
30
|
+
*/
|
|
31
|
+
dragBox?: {
|
|
32
|
+
/**
|
|
33
|
+
* Whether to show the drag selection box
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Brief flash/highlight boxes that appear on elements immediately after they're successfully grabbed/copied
|
|
40
|
+
*/
|
|
41
|
+
grabbedBoxes?: {
|
|
42
|
+
/**
|
|
43
|
+
* Whether to show these success flash effects
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
enabled?: boolean;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The floating label that follows the cursor showing information about the currently hovered element
|
|
50
|
+
*/
|
|
51
|
+
elementLabel?: {
|
|
52
|
+
/**
|
|
53
|
+
* Whether to show the label
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
enabled?: boolean;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* The crosshair cursor overlay that helps with precise element targeting
|
|
60
|
+
*/
|
|
61
|
+
crosshair?: {
|
|
62
|
+
/**
|
|
63
|
+
* Whether to show the crosshair
|
|
64
|
+
* @default true
|
|
65
|
+
*/
|
|
66
|
+
enabled?: boolean;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
interface ReactGrabState {
|
|
70
|
+
isActive: boolean;
|
|
71
|
+
isDragging: boolean;
|
|
72
|
+
isCopying: boolean;
|
|
73
|
+
isInputMode: boolean;
|
|
74
|
+
targetElement: Element | null;
|
|
75
|
+
dragBounds: DragRect | null;
|
|
76
|
+
}
|
|
77
|
+
type ElementLabelVariant = "hover" | "processing" | "success";
|
|
78
|
+
interface InputModeContext {
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
targetElement: Element | null;
|
|
82
|
+
}
|
|
83
|
+
interface CrosshairContext {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
}
|
|
87
|
+
interface ElementLabelContext {
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
content: string;
|
|
91
|
+
}
|
|
92
|
+
interface ActivationKey {
|
|
93
|
+
key?: string;
|
|
94
|
+
metaKey?: boolean;
|
|
95
|
+
ctrlKey?: boolean;
|
|
96
|
+
shiftKey?: boolean;
|
|
97
|
+
altKey?: boolean;
|
|
98
|
+
}
|
|
99
|
+
interface AgentContext<T = unknown> {
|
|
100
|
+
content: string;
|
|
101
|
+
prompt: string;
|
|
102
|
+
options?: T;
|
|
103
|
+
}
|
|
104
|
+
interface AgentSession {
|
|
105
|
+
id: string;
|
|
106
|
+
context: AgentContext;
|
|
107
|
+
lastStatus: string;
|
|
108
|
+
isStreaming: boolean;
|
|
109
|
+
createdAt: number;
|
|
110
|
+
position: {
|
|
111
|
+
x: number;
|
|
112
|
+
y: number;
|
|
113
|
+
};
|
|
114
|
+
selectionBounds?: OverlayBounds;
|
|
115
|
+
tagName?: string;
|
|
116
|
+
componentName?: string;
|
|
117
|
+
error?: string;
|
|
118
|
+
}
|
|
119
|
+
interface AgentProvider<T = any> {
|
|
120
|
+
send: (context: AgentContext<T>, signal: AbortSignal) => AsyncIterable<string>;
|
|
121
|
+
resume?: (sessionId: string, signal: AbortSignal, storage: AgentSessionStorage) => AsyncIterable<string>;
|
|
122
|
+
supportsResume?: boolean;
|
|
123
|
+
checkConnection?: () => Promise<boolean>;
|
|
124
|
+
getCompletionMessage?: () => string | undefined;
|
|
125
|
+
undo?: () => Promise<void>;
|
|
126
|
+
}
|
|
127
|
+
interface AgentSessionStorage {
|
|
128
|
+
getItem(key: string): string | null;
|
|
129
|
+
setItem(key: string, value: string): void;
|
|
130
|
+
removeItem(key: string): void;
|
|
131
|
+
}
|
|
132
|
+
interface AgentCompleteResult {
|
|
133
|
+
error?: string;
|
|
134
|
+
}
|
|
135
|
+
interface AgentOptions<T = any> {
|
|
136
|
+
provider?: AgentProvider<T>;
|
|
137
|
+
storage?: AgentSessionStorage | null;
|
|
138
|
+
getOptions?: () => T;
|
|
139
|
+
onStart?: (session: AgentSession, element: Element | undefined) => void;
|
|
140
|
+
onStatus?: (status: string, session: AgentSession) => void;
|
|
141
|
+
onComplete?: (session: AgentSession, element: Element | undefined) => AgentCompleteResult | void;
|
|
142
|
+
onError?: (error: Error, session: AgentSession) => void;
|
|
143
|
+
onResume?: (session: AgentSession) => void;
|
|
144
|
+
onAbort?: (session: AgentSession, element: Element | undefined) => void;
|
|
145
|
+
onUndo?: (session: AgentSession, element: Element | undefined) => void;
|
|
146
|
+
}
|
|
147
|
+
interface Options {
|
|
148
|
+
enabled?: boolean;
|
|
149
|
+
keyHoldDuration?: number;
|
|
150
|
+
allowActivationInsideInput?: boolean;
|
|
151
|
+
maxContextLines?: number;
|
|
152
|
+
theme?: Theme;
|
|
153
|
+
activationShortcut?: (event: KeyboardEvent) => boolean;
|
|
154
|
+
activationKey?: ActivationKey;
|
|
155
|
+
onActivate?: () => void;
|
|
156
|
+
onDeactivate?: () => void;
|
|
157
|
+
onElementHover?: (element: Element) => void;
|
|
158
|
+
onElementSelect?: (element: Element) => void;
|
|
159
|
+
onDragStart?: (startX: number, startY: number) => void;
|
|
160
|
+
onDragEnd?: (elements: Element[], bounds: DragRect) => void;
|
|
161
|
+
onBeforeCopy?: (elements: Element[]) => void | Promise<void>;
|
|
162
|
+
onAfterCopy?: (elements: Element[], success: boolean) => void;
|
|
163
|
+
onCopySuccess?: (elements: Element[], content: string) => void;
|
|
164
|
+
onCopyError?: (error: Error) => void;
|
|
165
|
+
onStateChange?: (state: ReactGrabState) => void;
|
|
166
|
+
onInputModeChange?: (isInputMode: boolean, context: InputModeContext) => void;
|
|
167
|
+
onSelectionBox?: (visible: boolean, bounds: OverlayBounds | null, element: Element | null) => void;
|
|
168
|
+
onDragBox?: (visible: boolean, bounds: OverlayBounds | null) => void;
|
|
169
|
+
onGrabbedBox?: (bounds: OverlayBounds, element: Element) => void;
|
|
170
|
+
onElementLabel?: (visible: boolean, variant: ElementLabelVariant, context: ElementLabelContext) => void;
|
|
171
|
+
onCrosshair?: (visible: boolean, context: CrosshairContext) => void;
|
|
172
|
+
onOpenFile?: (filePath: string, lineNumber?: number) => void;
|
|
173
|
+
agent?: AgentOptions;
|
|
174
|
+
}
|
|
175
|
+
interface UpdatableOptions {
|
|
176
|
+
onActivate?: () => void;
|
|
177
|
+
onDeactivate?: () => void;
|
|
178
|
+
onElementHover?: (element: Element) => void;
|
|
179
|
+
onElementSelect?: (element: Element) => void;
|
|
180
|
+
onDragStart?: (startX: number, startY: number) => void;
|
|
181
|
+
onDragEnd?: (elements: Element[], bounds: DragRect) => void;
|
|
182
|
+
onBeforeCopy?: (elements: Element[]) => void | Promise<void>;
|
|
183
|
+
onAfterCopy?: (elements: Element[], success: boolean) => void;
|
|
184
|
+
onCopySuccess?: (elements: Element[], content: string) => void;
|
|
185
|
+
onCopyError?: (error: Error) => void;
|
|
186
|
+
onStateChange?: (state: ReactGrabState) => void;
|
|
187
|
+
onInputModeChange?: (isInputMode: boolean, context: InputModeContext) => void;
|
|
188
|
+
onSelectionBox?: (visible: boolean, bounds: OverlayBounds | null, element: Element | null) => void;
|
|
189
|
+
onDragBox?: (visible: boolean, bounds: OverlayBounds | null) => void;
|
|
190
|
+
onGrabbedBox?: (bounds: OverlayBounds, element: Element) => void;
|
|
191
|
+
onElementLabel?: (visible: boolean, variant: ElementLabelVariant, context: ElementLabelContext) => void;
|
|
192
|
+
onCrosshair?: (visible: boolean, context: CrosshairContext) => void;
|
|
193
|
+
onOpenFile?: (filePath: string, lineNumber?: number) => void;
|
|
194
|
+
}
|
|
195
|
+
interface ReactGrabAPI {
|
|
196
|
+
activate: () => void;
|
|
197
|
+
deactivate: () => void;
|
|
198
|
+
toggle: () => void;
|
|
199
|
+
isActive: () => boolean;
|
|
200
|
+
dispose: () => void;
|
|
201
|
+
copyElement: (elements: Element | Element[]) => Promise<boolean>;
|
|
202
|
+
getState: () => ReactGrabState;
|
|
203
|
+
updateTheme: (theme: DeepPartial<Theme>) => void;
|
|
204
|
+
getTheme: () => Required<Theme>;
|
|
205
|
+
setAgent: (options: AgentOptions) => void;
|
|
206
|
+
updateOptions: (options: UpdatableOptions) => void;
|
|
207
|
+
}
|
|
208
|
+
interface OverlayBounds {
|
|
209
|
+
borderRadius: string;
|
|
210
|
+
height: number;
|
|
211
|
+
transform: string;
|
|
212
|
+
width: number;
|
|
213
|
+
x: number;
|
|
214
|
+
y: number;
|
|
215
|
+
}
|
|
216
|
+
type SelectionLabelStatus = "idle" | "copying" | "copied" | "fading";
|
|
217
|
+
interface SelectionLabelInstance {
|
|
218
|
+
id: string;
|
|
219
|
+
bounds: OverlayBounds;
|
|
220
|
+
tagName: string;
|
|
221
|
+
componentName?: string;
|
|
222
|
+
status: SelectionLabelStatus;
|
|
223
|
+
createdAt: number;
|
|
224
|
+
element?: Element;
|
|
225
|
+
mouseX?: number;
|
|
226
|
+
}
|
|
227
|
+
interface ReactGrabRendererProps {
|
|
228
|
+
selectionVisible?: boolean;
|
|
229
|
+
selectionBounds?: OverlayBounds;
|
|
230
|
+
selectionFilePath?: string;
|
|
231
|
+
selectionLineNumber?: number;
|
|
232
|
+
selectionTagName?: string;
|
|
233
|
+
selectionComponentName?: string;
|
|
234
|
+
selectionLabelVisible?: boolean;
|
|
235
|
+
selectionLabelStatus?: SelectionLabelStatus;
|
|
236
|
+
labelInstances?: SelectionLabelInstance[];
|
|
237
|
+
dragVisible?: boolean;
|
|
238
|
+
dragBounds?: OverlayBounds;
|
|
239
|
+
grabbedBoxes?: Array<{
|
|
240
|
+
id: string;
|
|
241
|
+
bounds: OverlayBounds;
|
|
242
|
+
createdAt: number;
|
|
243
|
+
}>;
|
|
244
|
+
labelZIndex?: number;
|
|
245
|
+
mouseX?: number;
|
|
246
|
+
mouseY?: number;
|
|
247
|
+
crosshairVisible?: boolean;
|
|
248
|
+
inputValue?: string;
|
|
249
|
+
isInputExpanded?: boolean;
|
|
250
|
+
hasAgent?: boolean;
|
|
251
|
+
isAgentConnected?: boolean;
|
|
252
|
+
agentSessions?: Map<string, AgentSession>;
|
|
253
|
+
onAbortSession?: (sessionId: string) => void;
|
|
254
|
+
onDismissSession?: (sessionId: string) => void;
|
|
255
|
+
onUndoSession?: (sessionId: string) => void;
|
|
256
|
+
onAcknowledgeSessionError?: (sessionId: string) => void;
|
|
257
|
+
onInputChange?: (value: string) => void;
|
|
258
|
+
onInputSubmit?: () => void;
|
|
259
|
+
onInputCancel?: () => void;
|
|
260
|
+
onToggleExpand?: () => void;
|
|
261
|
+
isPendingDismiss?: boolean;
|
|
262
|
+
onConfirmDismiss?: () => void;
|
|
263
|
+
onCancelDismiss?: () => void;
|
|
264
|
+
nativeSelectionCursorVisible?: boolean;
|
|
265
|
+
nativeSelectionCursorX?: number;
|
|
266
|
+
nativeSelectionCursorY?: number;
|
|
267
|
+
nativeSelectionTagName?: string;
|
|
268
|
+
nativeSelectionComponentName?: string;
|
|
269
|
+
nativeSelectionBounds?: OverlayBounds;
|
|
270
|
+
onNativeSelectionCopy?: () => void;
|
|
271
|
+
onNativeSelectionEnter?: () => void;
|
|
272
|
+
theme?: Required<Theme>;
|
|
273
|
+
}
|
|
274
|
+
interface GrabbedBox {
|
|
275
|
+
id: string;
|
|
276
|
+
bounds: OverlayBounds;
|
|
277
|
+
createdAt: number;
|
|
278
|
+
element: Element;
|
|
279
|
+
}
|
|
280
|
+
interface Rect {
|
|
281
|
+
left: number;
|
|
282
|
+
top: number;
|
|
283
|
+
right: number;
|
|
284
|
+
bottom: number;
|
|
285
|
+
}
|
|
286
|
+
interface DragRect {
|
|
287
|
+
x: number;
|
|
288
|
+
y: number;
|
|
289
|
+
width: number;
|
|
290
|
+
height: number;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
declare const getStack: (element: Element) => Promise<StackFrame[] | null>;
|
|
294
|
+
interface GetElementContextOptions {
|
|
295
|
+
maxLines?: number;
|
|
296
|
+
}
|
|
297
|
+
declare const getElementContext: (element: Element, options?: GetElementContextOptions) => Promise<string>;
|
|
298
|
+
|
|
299
|
+
declare const DEFAULT_THEME: Required<Theme>;
|
|
300
|
+
|
|
301
|
+
interface GenerateSnippetOptions {
|
|
302
|
+
maxLines?: number;
|
|
303
|
+
}
|
|
304
|
+
declare const generateSnippet: (elements: Element[], options?: GenerateSnippetOptions) => Promise<string>;
|
|
305
|
+
|
|
306
|
+
declare const init: (rawOptions?: Options) => ReactGrabAPI;
|
|
307
|
+
|
|
308
|
+
export { type AgentContext as A, type CrosshairContext as C, DEFAULT_THEME as D, type ElementLabelVariant as E, type GrabbedBox as G, type InputModeContext as I, type Options as O, type ReactGrabAPI as R, type Theme as T, type UpdatableOptions as U, getElementContext as a, generateSnippet as b, type ReactGrabState as c, type OverlayBounds as d, type DragRect as e, type Rect as f, getStack as g, type DeepPartial as h, init as i, type ElementLabelContext as j, type AgentSession as k, type AgentProvider as l, type AgentSessionStorage as m, type AgentOptions as n, type AgentCompleteResult as o, type ReactGrabRendererProps as p };
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { StackFrame } from 'bippy/source';
|
|
2
|
+
import 'bippy';
|
|
3
|
+
|
|
4
|
+
type DeepPartial<T> = {
|
|
5
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
6
|
+
};
|
|
7
|
+
interface Theme {
|
|
8
|
+
/**
|
|
9
|
+
* Globally toggle the entire overlay
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Base hue (0-360) used to generate colors throughout the interface using HSL color space
|
|
15
|
+
* @default 0
|
|
16
|
+
*/
|
|
17
|
+
hue?: number;
|
|
18
|
+
/**
|
|
19
|
+
* The highlight box that appears when hovering over an element before selecting it
|
|
20
|
+
*/
|
|
21
|
+
selectionBox?: {
|
|
22
|
+
/**
|
|
23
|
+
* Whether to show the selection highlight
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The rectangular selection area that appears when clicking and dragging to select multiple elements
|
|
30
|
+
*/
|
|
31
|
+
dragBox?: {
|
|
32
|
+
/**
|
|
33
|
+
* Whether to show the drag selection box
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Brief flash/highlight boxes that appear on elements immediately after they're successfully grabbed/copied
|
|
40
|
+
*/
|
|
41
|
+
grabbedBoxes?: {
|
|
42
|
+
/**
|
|
43
|
+
* Whether to show these success flash effects
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
enabled?: boolean;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The floating label that follows the cursor showing information about the currently hovered element
|
|
50
|
+
*/
|
|
51
|
+
elementLabel?: {
|
|
52
|
+
/**
|
|
53
|
+
* Whether to show the label
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
enabled?: boolean;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* The crosshair cursor overlay that helps with precise element targeting
|
|
60
|
+
*/
|
|
61
|
+
crosshair?: {
|
|
62
|
+
/**
|
|
63
|
+
* Whether to show the crosshair
|
|
64
|
+
* @default true
|
|
65
|
+
*/
|
|
66
|
+
enabled?: boolean;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
interface ReactGrabState {
|
|
70
|
+
isActive: boolean;
|
|
71
|
+
isDragging: boolean;
|
|
72
|
+
isCopying: boolean;
|
|
73
|
+
isInputMode: boolean;
|
|
74
|
+
targetElement: Element | null;
|
|
75
|
+
dragBounds: DragRect | null;
|
|
76
|
+
}
|
|
77
|
+
type ElementLabelVariant = "hover" | "processing" | "success";
|
|
78
|
+
interface InputModeContext {
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
targetElement: Element | null;
|
|
82
|
+
}
|
|
83
|
+
interface CrosshairContext {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
}
|
|
87
|
+
interface ElementLabelContext {
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
content: string;
|
|
91
|
+
}
|
|
92
|
+
interface ActivationKey {
|
|
93
|
+
key?: string;
|
|
94
|
+
metaKey?: boolean;
|
|
95
|
+
ctrlKey?: boolean;
|
|
96
|
+
shiftKey?: boolean;
|
|
97
|
+
altKey?: boolean;
|
|
98
|
+
}
|
|
99
|
+
interface AgentContext<T = unknown> {
|
|
100
|
+
content: string;
|
|
101
|
+
prompt: string;
|
|
102
|
+
options?: T;
|
|
103
|
+
}
|
|
104
|
+
interface AgentSession {
|
|
105
|
+
id: string;
|
|
106
|
+
context: AgentContext;
|
|
107
|
+
lastStatus: string;
|
|
108
|
+
isStreaming: boolean;
|
|
109
|
+
createdAt: number;
|
|
110
|
+
position: {
|
|
111
|
+
x: number;
|
|
112
|
+
y: number;
|
|
113
|
+
};
|
|
114
|
+
selectionBounds?: OverlayBounds;
|
|
115
|
+
tagName?: string;
|
|
116
|
+
componentName?: string;
|
|
117
|
+
error?: string;
|
|
118
|
+
}
|
|
119
|
+
interface AgentProvider<T = any> {
|
|
120
|
+
send: (context: AgentContext<T>, signal: AbortSignal) => AsyncIterable<string>;
|
|
121
|
+
resume?: (sessionId: string, signal: AbortSignal, storage: AgentSessionStorage) => AsyncIterable<string>;
|
|
122
|
+
supportsResume?: boolean;
|
|
123
|
+
checkConnection?: () => Promise<boolean>;
|
|
124
|
+
getCompletionMessage?: () => string | undefined;
|
|
125
|
+
undo?: () => Promise<void>;
|
|
126
|
+
}
|
|
127
|
+
interface AgentSessionStorage {
|
|
128
|
+
getItem(key: string): string | null;
|
|
129
|
+
setItem(key: string, value: string): void;
|
|
130
|
+
removeItem(key: string): void;
|
|
131
|
+
}
|
|
132
|
+
interface AgentCompleteResult {
|
|
133
|
+
error?: string;
|
|
134
|
+
}
|
|
135
|
+
interface AgentOptions<T = any> {
|
|
136
|
+
provider?: AgentProvider<T>;
|
|
137
|
+
storage?: AgentSessionStorage | null;
|
|
138
|
+
getOptions?: () => T;
|
|
139
|
+
onStart?: (session: AgentSession, element: Element | undefined) => void;
|
|
140
|
+
onStatus?: (status: string, session: AgentSession) => void;
|
|
141
|
+
onComplete?: (session: AgentSession, element: Element | undefined) => AgentCompleteResult | void;
|
|
142
|
+
onError?: (error: Error, session: AgentSession) => void;
|
|
143
|
+
onResume?: (session: AgentSession) => void;
|
|
144
|
+
onAbort?: (session: AgentSession, element: Element | undefined) => void;
|
|
145
|
+
onUndo?: (session: AgentSession, element: Element | undefined) => void;
|
|
146
|
+
}
|
|
147
|
+
interface Options {
|
|
148
|
+
enabled?: boolean;
|
|
149
|
+
keyHoldDuration?: number;
|
|
150
|
+
allowActivationInsideInput?: boolean;
|
|
151
|
+
maxContextLines?: number;
|
|
152
|
+
theme?: Theme;
|
|
153
|
+
activationShortcut?: (event: KeyboardEvent) => boolean;
|
|
154
|
+
activationKey?: ActivationKey;
|
|
155
|
+
onActivate?: () => void;
|
|
156
|
+
onDeactivate?: () => void;
|
|
157
|
+
onElementHover?: (element: Element) => void;
|
|
158
|
+
onElementSelect?: (element: Element) => void;
|
|
159
|
+
onDragStart?: (startX: number, startY: number) => void;
|
|
160
|
+
onDragEnd?: (elements: Element[], bounds: DragRect) => void;
|
|
161
|
+
onBeforeCopy?: (elements: Element[]) => void | Promise<void>;
|
|
162
|
+
onAfterCopy?: (elements: Element[], success: boolean) => void;
|
|
163
|
+
onCopySuccess?: (elements: Element[], content: string) => void;
|
|
164
|
+
onCopyError?: (error: Error) => void;
|
|
165
|
+
onStateChange?: (state: ReactGrabState) => void;
|
|
166
|
+
onInputModeChange?: (isInputMode: boolean, context: InputModeContext) => void;
|
|
167
|
+
onSelectionBox?: (visible: boolean, bounds: OverlayBounds | null, element: Element | null) => void;
|
|
168
|
+
onDragBox?: (visible: boolean, bounds: OverlayBounds | null) => void;
|
|
169
|
+
onGrabbedBox?: (bounds: OverlayBounds, element: Element) => void;
|
|
170
|
+
onElementLabel?: (visible: boolean, variant: ElementLabelVariant, context: ElementLabelContext) => void;
|
|
171
|
+
onCrosshair?: (visible: boolean, context: CrosshairContext) => void;
|
|
172
|
+
onOpenFile?: (filePath: string, lineNumber?: number) => void;
|
|
173
|
+
agent?: AgentOptions;
|
|
174
|
+
}
|
|
175
|
+
interface UpdatableOptions {
|
|
176
|
+
onActivate?: () => void;
|
|
177
|
+
onDeactivate?: () => void;
|
|
178
|
+
onElementHover?: (element: Element) => void;
|
|
179
|
+
onElementSelect?: (element: Element) => void;
|
|
180
|
+
onDragStart?: (startX: number, startY: number) => void;
|
|
181
|
+
onDragEnd?: (elements: Element[], bounds: DragRect) => void;
|
|
182
|
+
onBeforeCopy?: (elements: Element[]) => void | Promise<void>;
|
|
183
|
+
onAfterCopy?: (elements: Element[], success: boolean) => void;
|
|
184
|
+
onCopySuccess?: (elements: Element[], content: string) => void;
|
|
185
|
+
onCopyError?: (error: Error) => void;
|
|
186
|
+
onStateChange?: (state: ReactGrabState) => void;
|
|
187
|
+
onInputModeChange?: (isInputMode: boolean, context: InputModeContext) => void;
|
|
188
|
+
onSelectionBox?: (visible: boolean, bounds: OverlayBounds | null, element: Element | null) => void;
|
|
189
|
+
onDragBox?: (visible: boolean, bounds: OverlayBounds | null) => void;
|
|
190
|
+
onGrabbedBox?: (bounds: OverlayBounds, element: Element) => void;
|
|
191
|
+
onElementLabel?: (visible: boolean, variant: ElementLabelVariant, context: ElementLabelContext) => void;
|
|
192
|
+
onCrosshair?: (visible: boolean, context: CrosshairContext) => void;
|
|
193
|
+
onOpenFile?: (filePath: string, lineNumber?: number) => void;
|
|
194
|
+
}
|
|
195
|
+
interface ReactGrabAPI {
|
|
196
|
+
activate: () => void;
|
|
197
|
+
deactivate: () => void;
|
|
198
|
+
toggle: () => void;
|
|
199
|
+
isActive: () => boolean;
|
|
200
|
+
dispose: () => void;
|
|
201
|
+
copyElement: (elements: Element | Element[]) => Promise<boolean>;
|
|
202
|
+
getState: () => ReactGrabState;
|
|
203
|
+
updateTheme: (theme: DeepPartial<Theme>) => void;
|
|
204
|
+
getTheme: () => Required<Theme>;
|
|
205
|
+
setAgent: (options: AgentOptions) => void;
|
|
206
|
+
updateOptions: (options: UpdatableOptions) => void;
|
|
207
|
+
}
|
|
208
|
+
interface OverlayBounds {
|
|
209
|
+
borderRadius: string;
|
|
210
|
+
height: number;
|
|
211
|
+
transform: string;
|
|
212
|
+
width: number;
|
|
213
|
+
x: number;
|
|
214
|
+
y: number;
|
|
215
|
+
}
|
|
216
|
+
type SelectionLabelStatus = "idle" | "copying" | "copied" | "fading";
|
|
217
|
+
interface SelectionLabelInstance {
|
|
218
|
+
id: string;
|
|
219
|
+
bounds: OverlayBounds;
|
|
220
|
+
tagName: string;
|
|
221
|
+
componentName?: string;
|
|
222
|
+
status: SelectionLabelStatus;
|
|
223
|
+
createdAt: number;
|
|
224
|
+
element?: Element;
|
|
225
|
+
mouseX?: number;
|
|
226
|
+
}
|
|
227
|
+
interface ReactGrabRendererProps {
|
|
228
|
+
selectionVisible?: boolean;
|
|
229
|
+
selectionBounds?: OverlayBounds;
|
|
230
|
+
selectionFilePath?: string;
|
|
231
|
+
selectionLineNumber?: number;
|
|
232
|
+
selectionTagName?: string;
|
|
233
|
+
selectionComponentName?: string;
|
|
234
|
+
selectionLabelVisible?: boolean;
|
|
235
|
+
selectionLabelStatus?: SelectionLabelStatus;
|
|
236
|
+
labelInstances?: SelectionLabelInstance[];
|
|
237
|
+
dragVisible?: boolean;
|
|
238
|
+
dragBounds?: OverlayBounds;
|
|
239
|
+
grabbedBoxes?: Array<{
|
|
240
|
+
id: string;
|
|
241
|
+
bounds: OverlayBounds;
|
|
242
|
+
createdAt: number;
|
|
243
|
+
}>;
|
|
244
|
+
labelZIndex?: number;
|
|
245
|
+
mouseX?: number;
|
|
246
|
+
mouseY?: number;
|
|
247
|
+
crosshairVisible?: boolean;
|
|
248
|
+
inputValue?: string;
|
|
249
|
+
isInputExpanded?: boolean;
|
|
250
|
+
hasAgent?: boolean;
|
|
251
|
+
isAgentConnected?: boolean;
|
|
252
|
+
agentSessions?: Map<string, AgentSession>;
|
|
253
|
+
onAbortSession?: (sessionId: string) => void;
|
|
254
|
+
onDismissSession?: (sessionId: string) => void;
|
|
255
|
+
onUndoSession?: (sessionId: string) => void;
|
|
256
|
+
onAcknowledgeSessionError?: (sessionId: string) => void;
|
|
257
|
+
onInputChange?: (value: string) => void;
|
|
258
|
+
onInputSubmit?: () => void;
|
|
259
|
+
onInputCancel?: () => void;
|
|
260
|
+
onToggleExpand?: () => void;
|
|
261
|
+
isPendingDismiss?: boolean;
|
|
262
|
+
onConfirmDismiss?: () => void;
|
|
263
|
+
onCancelDismiss?: () => void;
|
|
264
|
+
nativeSelectionCursorVisible?: boolean;
|
|
265
|
+
nativeSelectionCursorX?: number;
|
|
266
|
+
nativeSelectionCursorY?: number;
|
|
267
|
+
nativeSelectionTagName?: string;
|
|
268
|
+
nativeSelectionComponentName?: string;
|
|
269
|
+
nativeSelectionBounds?: OverlayBounds;
|
|
270
|
+
onNativeSelectionCopy?: () => void;
|
|
271
|
+
onNativeSelectionEnter?: () => void;
|
|
272
|
+
theme?: Required<Theme>;
|
|
273
|
+
}
|
|
274
|
+
interface GrabbedBox {
|
|
275
|
+
id: string;
|
|
276
|
+
bounds: OverlayBounds;
|
|
277
|
+
createdAt: number;
|
|
278
|
+
element: Element;
|
|
279
|
+
}
|
|
280
|
+
interface Rect {
|
|
281
|
+
left: number;
|
|
282
|
+
top: number;
|
|
283
|
+
right: number;
|
|
284
|
+
bottom: number;
|
|
285
|
+
}
|
|
286
|
+
interface DragRect {
|
|
287
|
+
x: number;
|
|
288
|
+
y: number;
|
|
289
|
+
width: number;
|
|
290
|
+
height: number;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
declare const getStack: (element: Element) => Promise<StackFrame[] | null>;
|
|
294
|
+
interface GetElementContextOptions {
|
|
295
|
+
maxLines?: number;
|
|
296
|
+
}
|
|
297
|
+
declare const getElementContext: (element: Element, options?: GetElementContextOptions) => Promise<string>;
|
|
298
|
+
|
|
299
|
+
declare const DEFAULT_THEME: Required<Theme>;
|
|
300
|
+
|
|
301
|
+
interface GenerateSnippetOptions {
|
|
302
|
+
maxLines?: number;
|
|
303
|
+
}
|
|
304
|
+
declare const generateSnippet: (elements: Element[], options?: GenerateSnippetOptions) => Promise<string>;
|
|
305
|
+
|
|
306
|
+
declare const init: (rawOptions?: Options) => ReactGrabAPI;
|
|
307
|
+
|
|
308
|
+
export { type AgentContext as A, type CrosshairContext as C, DEFAULT_THEME as D, type ElementLabelVariant as E, type GrabbedBox as G, type InputModeContext as I, type Options as O, type ReactGrabAPI as R, type Theme as T, type UpdatableOptions as U, getElementContext as a, generateSnippet as b, type ReactGrabState as c, type OverlayBounds as d, type DragRect as e, type Rect as f, getStack as g, type DeepPartial as h, init as i, type ElementLabelContext as j, type AgentSession as k, type AgentProvider as l, type AgentSessionStorage as m, type AgentOptions as n, type AgentCompleteResult as o, type ReactGrabRendererProps as p };
|
package/dist/core.cjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkRM6XONHW_cjs = require('./chunk-RM6XONHW.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "DEFAULT_THEME", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkRM6XONHW_cjs.DEFAULT_THEME; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "formatElementInfo", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkRM6XONHW_cjs.getElementContext; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "generateSnippet", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkRM6XONHW_cjs.generateSnippet; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "getStack", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkRM6XONHW_cjs.getStack; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "init", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkRM6XONHW_cjs.init; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "isInstrumentationActive", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunkRM6XONHW_cjs.Ee; }
|
|
30
|
+
});
|
package/dist/core.d.cts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { o as AgentCompleteResult, A as AgentContext, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, D as DEFAULT_THEME, O as Options, d as OverlayBounds, R as ReactGrabAPI, p as ReactGrabRendererProps, U as UpdatableOptions, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './core-BIJVr_bk.cjs';
|
|
2
|
+
export { isInstrumentationActive } from 'bippy';
|
|
3
|
+
import 'bippy/source';
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { o as AgentCompleteResult, A as AgentContext, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, D as DEFAULT_THEME, O as Options, d as OverlayBounds, R as ReactGrabAPI, p as ReactGrabRendererProps, U as UpdatableOptions, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './core-BIJVr_bk.js';
|
|
2
|
+
export { isInstrumentationActive } from 'bippy';
|
|
3
|
+
import 'bippy/source';
|
package/dist/core.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEFAULT_THEME, getElementContext as formatElementInfo, generateSnippet, getStack, init, Ee as isInstrumentationActive } from './chunk-VOXBYN56.js';
|