react-grab 0.0.97 → 0.1.0-beta.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 +132 -372
- package/dist/chunk-DIAOCH5J.cjs +88 -0
- package/dist/chunk-VXZ5VMRT.js +88 -0
- package/dist/cli.cjs +1 -420
- 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-RhgdSH9U.d.cts → index-BdKhAk4Q.d.cts} +106 -31
- package/dist/{index-RhgdSH9U.d.ts → index-BdKhAk4Q.d.ts} +106 -31
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.global.js +27 -35
- package/dist/index.js +2 -2
- package/dist/styles.css +1 -1
- package/package.json +3 -6
- package/dist/chunk-K6AYIDZE.js +0 -94
- package/dist/chunk-QVFHXAET.cjs +0 -94
package/dist/core/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkDIAOCH5J_cjs=require('../chunk-DIAOCH5J.cjs');Object.defineProperty(exports,"DEFAULT_THEME",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.j}});Object.defineProperty(exports,"copyContent",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.e}});Object.defineProperty(exports,"formatElementInfo",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.d}});Object.defineProperty(exports,"generateSnippet",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.f}});Object.defineProperty(exports,"getStack",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.c}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.k}});Object.defineProperty(exports,"isInstrumentationActive",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.b}});
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, D as DEFAULT_THEME, O as Options, d as OverlayBounds, R as ReactGrabAPI,
|
|
1
|
+
export { s as ActionContext, o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, r as ContextMenuAction, D as DEFAULT_THEME, O as Options, d as OverlayBounds, t as Plugin, u as PluginConfig, v as PluginHooks, R as ReactGrabAPI, w as ReactGrabRendererProps, p as SettableOptions, S as SourceInfo, x as copyContent, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from '../index-BdKhAk4Q.cjs';
|
|
2
2
|
export { isInstrumentationActive } from 'bippy';
|
|
3
3
|
import 'bippy/source';
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, D as DEFAULT_THEME, O as Options, d as OverlayBounds, R as ReactGrabAPI,
|
|
1
|
+
export { s as ActionContext, o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, r as ContextMenuAction, D as DEFAULT_THEME, O as Options, d as OverlayBounds, t as Plugin, u as PluginConfig, v as PluginHooks, R as ReactGrabAPI, w as ReactGrabRendererProps, p as SettableOptions, S as SourceInfo, x as copyContent, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from '../index-BdKhAk4Q.js';
|
|
2
2
|
export { isInstrumentationActive } from 'bippy';
|
|
3
3
|
import 'bippy/source';
|
package/dist/core/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{j as DEFAULT_THEME,e as copyContent,d as formatElementInfo,f as generateSnippet,c as getStack,k as init,b as isInstrumentationActive}from'../chunk-VXZ5VMRT.js';
|
|
@@ -2,7 +2,7 @@ import { StackFrame } from 'bippy/source';
|
|
|
2
2
|
import 'bippy';
|
|
3
3
|
|
|
4
4
|
type DeepPartial<T> = {
|
|
5
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
5
|
+
[P in keyof T]?: T[P] extends object ? T[P] extends (...args: unknown[]) => unknown ? T[P] : DeepPartial<T[P]> : T[P];
|
|
6
6
|
};
|
|
7
7
|
interface Theme {
|
|
8
8
|
/**
|
|
@@ -80,12 +80,25 @@ interface ReactGrabState {
|
|
|
80
80
|
isActive: boolean;
|
|
81
81
|
isDragging: boolean;
|
|
82
82
|
isCopying: boolean;
|
|
83
|
-
|
|
83
|
+
isPromptMode: boolean;
|
|
84
|
+
isCrosshairVisible: boolean;
|
|
85
|
+
isSelectionBoxVisible: boolean;
|
|
86
|
+
isDragBoxVisible: boolean;
|
|
84
87
|
targetElement: Element | null;
|
|
85
88
|
dragBounds: DragRect | null;
|
|
89
|
+
/**
|
|
90
|
+
* Currently visible grabbed boxes (success flash effects).
|
|
91
|
+
* These are temporary visual indicators shown after elements are grabbed/copied.
|
|
92
|
+
*/
|
|
93
|
+
grabbedBoxes: Array<{
|
|
94
|
+
id: string;
|
|
95
|
+
bounds: OverlayBounds;
|
|
96
|
+
createdAt: number;
|
|
97
|
+
}>;
|
|
98
|
+
selectionFilePath: string | null;
|
|
86
99
|
}
|
|
87
100
|
type ElementLabelVariant = "hover" | "processing" | "success";
|
|
88
|
-
interface
|
|
101
|
+
interface PromptModeContext {
|
|
89
102
|
x: number;
|
|
90
103
|
y: number;
|
|
91
104
|
targetElement: Element | null;
|
|
@@ -98,14 +111,13 @@ interface ElementLabelContext {
|
|
|
98
111
|
x: number;
|
|
99
112
|
y: number;
|
|
100
113
|
content: string;
|
|
114
|
+
element?: Element;
|
|
115
|
+
tagName?: string;
|
|
116
|
+
componentName?: string;
|
|
117
|
+
filePath?: string;
|
|
118
|
+
lineNumber?: number;
|
|
101
119
|
}
|
|
102
|
-
|
|
103
|
-
key?: string;
|
|
104
|
-
metaKey?: boolean;
|
|
105
|
-
ctrlKey?: boolean;
|
|
106
|
-
shiftKey?: boolean;
|
|
107
|
-
altKey?: boolean;
|
|
108
|
-
}
|
|
120
|
+
type ActivationKey = string | ((event: KeyboardEvent) => boolean);
|
|
109
121
|
interface AgentContext<T = unknown> {
|
|
110
122
|
content: string[];
|
|
111
123
|
prompt: string;
|
|
@@ -117,6 +129,7 @@ interface AgentSession {
|
|
|
117
129
|
context: AgentContext;
|
|
118
130
|
lastStatus: string;
|
|
119
131
|
isStreaming: boolean;
|
|
132
|
+
isFading?: boolean;
|
|
120
133
|
createdAt: number;
|
|
121
134
|
lastUpdatedAt: number;
|
|
122
135
|
position: {
|
|
@@ -164,16 +177,24 @@ interface AgentOptions<T = any> {
|
|
|
164
177
|
onDismiss?: (session: AgentSession, elements: Element[]) => void;
|
|
165
178
|
}
|
|
166
179
|
type ActivationMode = "toggle" | "hold";
|
|
167
|
-
interface
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
180
|
+
interface ActionContext {
|
|
181
|
+
element: Element;
|
|
182
|
+
elements: Element[];
|
|
183
|
+
filePath?: string;
|
|
184
|
+
lineNumber?: number;
|
|
185
|
+
componentName?: string;
|
|
186
|
+
tagName?: string;
|
|
187
|
+
enterPromptMode?: (agent?: AgentOptions) => void;
|
|
188
|
+
}
|
|
189
|
+
interface ContextMenuAction {
|
|
190
|
+
id: string;
|
|
191
|
+
label: string;
|
|
192
|
+
shortcut?: string;
|
|
193
|
+
enabled?: boolean | ((context: ActionContext) => boolean);
|
|
194
|
+
onAction: (context: ActionContext) => void;
|
|
195
|
+
agent?: AgentOptions;
|
|
196
|
+
}
|
|
197
|
+
interface PluginHooks {
|
|
177
198
|
onActivate?: () => void;
|
|
178
199
|
onDeactivate?: () => void;
|
|
179
200
|
onElementHover?: (element: Element) => void;
|
|
@@ -185,16 +206,48 @@ interface Options {
|
|
|
185
206
|
onCopySuccess?: (elements: Element[], content: string) => void;
|
|
186
207
|
onCopyError?: (error: Error) => void;
|
|
187
208
|
onStateChange?: (state: ReactGrabState) => void;
|
|
188
|
-
|
|
209
|
+
onPromptModeChange?: (isPromptMode: boolean, context: PromptModeContext) => void;
|
|
189
210
|
onSelectionBox?: (visible: boolean, bounds: OverlayBounds | null, element: Element | null) => void;
|
|
190
211
|
onDragBox?: (visible: boolean, bounds: OverlayBounds | null) => void;
|
|
191
212
|
onGrabbedBox?: (bounds: OverlayBounds, element: Element) => void;
|
|
192
213
|
onElementLabel?: (visible: boolean, variant: ElementLabelVariant, context: ElementLabelContext) => void;
|
|
193
214
|
onCrosshair?: (visible: boolean, context: CrosshairContext) => void;
|
|
194
|
-
|
|
195
|
-
|
|
215
|
+
onContextMenu?: (element: Element, position: {
|
|
216
|
+
x: number;
|
|
217
|
+
y: number;
|
|
218
|
+
}) => void;
|
|
219
|
+
onOpenFile?: (filePath: string, lineNumber?: number) => boolean | void;
|
|
220
|
+
}
|
|
221
|
+
interface PluginConfig {
|
|
222
|
+
theme?: DeepPartial<Theme>;
|
|
223
|
+
options?: SettableOptions;
|
|
224
|
+
actions?: ContextMenuAction[];
|
|
225
|
+
hooks?: PluginHooks;
|
|
226
|
+
cleanup?: () => void;
|
|
227
|
+
}
|
|
228
|
+
interface Plugin {
|
|
229
|
+
name: string;
|
|
230
|
+
theme?: DeepPartial<Theme>;
|
|
231
|
+
options?: SettableOptions;
|
|
232
|
+
actions?: ContextMenuAction[];
|
|
233
|
+
hooks?: PluginHooks;
|
|
234
|
+
setup?: (api: ReactGrabAPI) => PluginConfig | void;
|
|
235
|
+
}
|
|
236
|
+
interface Options {
|
|
237
|
+
enabled?: boolean;
|
|
238
|
+
activationMode?: ActivationMode;
|
|
239
|
+
keyHoldDuration?: number;
|
|
240
|
+
allowActivationInsideInput?: boolean;
|
|
241
|
+
maxContextLines?: number;
|
|
242
|
+
activationKey?: ActivationKey;
|
|
243
|
+
getContent?: (elements: Element[]) => Promise<string> | string;
|
|
244
|
+
}
|
|
245
|
+
type SettableOptions = Omit<Options, "enabled">;
|
|
246
|
+
interface SourceInfo {
|
|
247
|
+
filePath: string;
|
|
248
|
+
lineNumber: number | null;
|
|
249
|
+
componentName: string | null;
|
|
196
250
|
}
|
|
197
|
-
type UpdatableOptions = Pick<Options, "onActivate" | "onDeactivate" | "onElementHover" | "onElementSelect" | "onDragStart" | "onDragEnd" | "onBeforeCopy" | "onAfterCopy" | "onCopySuccess" | "onCopyError" | "onStateChange" | "onInputModeChange" | "onSelectionBox" | "onDragBox" | "onGrabbedBox" | "onElementLabel" | "onCrosshair" | "onOpenFile">;
|
|
198
251
|
interface ReactGrabAPI {
|
|
199
252
|
activate: () => void;
|
|
200
253
|
deactivate: () => void;
|
|
@@ -202,11 +255,12 @@ interface ReactGrabAPI {
|
|
|
202
255
|
isActive: () => boolean;
|
|
203
256
|
dispose: () => void;
|
|
204
257
|
copyElement: (elements: Element | Element[]) => Promise<boolean>;
|
|
258
|
+
getSource: (element: Element) => Promise<SourceInfo | null>;
|
|
205
259
|
getState: () => ReactGrabState;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
260
|
+
setOptions: (options: SettableOptions) => void;
|
|
261
|
+
registerPlugin: (plugin: Plugin) => void;
|
|
262
|
+
unregisterPlugin: (name: string) => void;
|
|
263
|
+
getPlugins: () => string[];
|
|
210
264
|
}
|
|
211
265
|
interface OverlayBounds {
|
|
212
266
|
borderRadius: string;
|
|
@@ -216,16 +270,20 @@ interface OverlayBounds {
|
|
|
216
270
|
x: number;
|
|
217
271
|
y: number;
|
|
218
272
|
}
|
|
219
|
-
type SelectionLabelStatus = "idle" | "copying" | "copied" | "fading";
|
|
273
|
+
type SelectionLabelStatus = "idle" | "copying" | "copied" | "fading" | "error";
|
|
220
274
|
interface SelectionLabelInstance {
|
|
221
275
|
id: string;
|
|
222
276
|
bounds: OverlayBounds;
|
|
277
|
+
boundsMultiple?: OverlayBounds[];
|
|
223
278
|
tagName: string;
|
|
224
279
|
componentName?: string;
|
|
225
280
|
status: SelectionLabelStatus;
|
|
226
281
|
createdAt: number;
|
|
227
282
|
element?: Element;
|
|
283
|
+
elements?: Element[];
|
|
228
284
|
mouseX?: number;
|
|
285
|
+
mouseXOffsetFromCenter?: number;
|
|
286
|
+
errorMessage?: string;
|
|
229
287
|
}
|
|
230
288
|
interface ReactGrabRendererProps {
|
|
231
289
|
selectionVisible?: boolean;
|
|
@@ -251,7 +309,7 @@ interface ReactGrabRendererProps {
|
|
|
251
309
|
mouseY?: number;
|
|
252
310
|
crosshairVisible?: boolean;
|
|
253
311
|
inputValue?: string;
|
|
254
|
-
|
|
312
|
+
isPromptMode?: boolean;
|
|
255
313
|
replyToPrompt?: string;
|
|
256
314
|
hasAgent?: boolean;
|
|
257
315
|
isAgentConnected?: boolean;
|
|
@@ -266,6 +324,8 @@ interface ReactGrabRendererProps {
|
|
|
266
324
|
onFollowUpSubmitSession?: (sessionId: string, prompt: string) => void;
|
|
267
325
|
onAcknowledgeSessionError?: (sessionId: string) => void;
|
|
268
326
|
onRetrySession?: (sessionId: string) => void;
|
|
327
|
+
onShowContextMenuSession?: (sessionId: string) => void;
|
|
328
|
+
onShowContextMenuInstance?: (instanceId: string) => void;
|
|
269
329
|
onInputChange?: (value: string) => void;
|
|
270
330
|
onInputSubmit?: () => void;
|
|
271
331
|
onInputCancel?: () => void;
|
|
@@ -278,6 +338,21 @@ interface ReactGrabRendererProps {
|
|
|
278
338
|
toolbarVisible?: boolean;
|
|
279
339
|
isActive?: boolean;
|
|
280
340
|
onToggleActive?: () => void;
|
|
341
|
+
contextMenuPosition?: {
|
|
342
|
+
x: number;
|
|
343
|
+
y: number;
|
|
344
|
+
} | null;
|
|
345
|
+
contextMenuBounds?: OverlayBounds | null;
|
|
346
|
+
contextMenuTagName?: string;
|
|
347
|
+
contextMenuComponentName?: string;
|
|
348
|
+
contextMenuHasFilePath?: boolean;
|
|
349
|
+
actions?: ContextMenuAction[];
|
|
350
|
+
actionContext?: ActionContext;
|
|
351
|
+
onContextMenuCopy?: () => void;
|
|
352
|
+
onContextMenuCopyScreenshot?: () => void;
|
|
353
|
+
onContextMenuOpen?: () => void;
|
|
354
|
+
onContextMenuDismiss?: () => void;
|
|
355
|
+
onContextMenuHide?: () => void;
|
|
281
356
|
}
|
|
282
357
|
interface GrabbedBox {
|
|
283
358
|
id: string;
|
|
@@ -319,4 +394,4 @@ declare const copyContent: (content: string, options?: CopyContentOptions) => bo
|
|
|
319
394
|
|
|
320
395
|
declare const init: (rawOptions?: Options) => ReactGrabAPI;
|
|
321
396
|
|
|
322
|
-
export { type AgentContext as A, type CrosshairContext as C, DEFAULT_THEME as D, type ElementLabelVariant as E, type GrabbedBox as G, type
|
|
397
|
+
export { type AgentContext as A, type CrosshairContext as C, DEFAULT_THEME as D, type ElementLabelVariant as E, type GrabbedBox as G, type Options as O, type PromptModeContext as P, type ReactGrabAPI as R, type SourceInfo as S, type Theme as T, 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 SettableOptions as p, type ActivationMode as q, type ContextMenuAction as r, type ActionContext as s, type Plugin as t, type PluginConfig as u, type PluginHooks as v, type ReactGrabRendererProps as w, copyContent as x };
|
|
@@ -2,7 +2,7 @@ import { StackFrame } from 'bippy/source';
|
|
|
2
2
|
import 'bippy';
|
|
3
3
|
|
|
4
4
|
type DeepPartial<T> = {
|
|
5
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
5
|
+
[P in keyof T]?: T[P] extends object ? T[P] extends (...args: unknown[]) => unknown ? T[P] : DeepPartial<T[P]> : T[P];
|
|
6
6
|
};
|
|
7
7
|
interface Theme {
|
|
8
8
|
/**
|
|
@@ -80,12 +80,25 @@ interface ReactGrabState {
|
|
|
80
80
|
isActive: boolean;
|
|
81
81
|
isDragging: boolean;
|
|
82
82
|
isCopying: boolean;
|
|
83
|
-
|
|
83
|
+
isPromptMode: boolean;
|
|
84
|
+
isCrosshairVisible: boolean;
|
|
85
|
+
isSelectionBoxVisible: boolean;
|
|
86
|
+
isDragBoxVisible: boolean;
|
|
84
87
|
targetElement: Element | null;
|
|
85
88
|
dragBounds: DragRect | null;
|
|
89
|
+
/**
|
|
90
|
+
* Currently visible grabbed boxes (success flash effects).
|
|
91
|
+
* These are temporary visual indicators shown after elements are grabbed/copied.
|
|
92
|
+
*/
|
|
93
|
+
grabbedBoxes: Array<{
|
|
94
|
+
id: string;
|
|
95
|
+
bounds: OverlayBounds;
|
|
96
|
+
createdAt: number;
|
|
97
|
+
}>;
|
|
98
|
+
selectionFilePath: string | null;
|
|
86
99
|
}
|
|
87
100
|
type ElementLabelVariant = "hover" | "processing" | "success";
|
|
88
|
-
interface
|
|
101
|
+
interface PromptModeContext {
|
|
89
102
|
x: number;
|
|
90
103
|
y: number;
|
|
91
104
|
targetElement: Element | null;
|
|
@@ -98,14 +111,13 @@ interface ElementLabelContext {
|
|
|
98
111
|
x: number;
|
|
99
112
|
y: number;
|
|
100
113
|
content: string;
|
|
114
|
+
element?: Element;
|
|
115
|
+
tagName?: string;
|
|
116
|
+
componentName?: string;
|
|
117
|
+
filePath?: string;
|
|
118
|
+
lineNumber?: number;
|
|
101
119
|
}
|
|
102
|
-
|
|
103
|
-
key?: string;
|
|
104
|
-
metaKey?: boolean;
|
|
105
|
-
ctrlKey?: boolean;
|
|
106
|
-
shiftKey?: boolean;
|
|
107
|
-
altKey?: boolean;
|
|
108
|
-
}
|
|
120
|
+
type ActivationKey = string | ((event: KeyboardEvent) => boolean);
|
|
109
121
|
interface AgentContext<T = unknown> {
|
|
110
122
|
content: string[];
|
|
111
123
|
prompt: string;
|
|
@@ -117,6 +129,7 @@ interface AgentSession {
|
|
|
117
129
|
context: AgentContext;
|
|
118
130
|
lastStatus: string;
|
|
119
131
|
isStreaming: boolean;
|
|
132
|
+
isFading?: boolean;
|
|
120
133
|
createdAt: number;
|
|
121
134
|
lastUpdatedAt: number;
|
|
122
135
|
position: {
|
|
@@ -164,16 +177,24 @@ interface AgentOptions<T = any> {
|
|
|
164
177
|
onDismiss?: (session: AgentSession, elements: Element[]) => void;
|
|
165
178
|
}
|
|
166
179
|
type ActivationMode = "toggle" | "hold";
|
|
167
|
-
interface
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
180
|
+
interface ActionContext {
|
|
181
|
+
element: Element;
|
|
182
|
+
elements: Element[];
|
|
183
|
+
filePath?: string;
|
|
184
|
+
lineNumber?: number;
|
|
185
|
+
componentName?: string;
|
|
186
|
+
tagName?: string;
|
|
187
|
+
enterPromptMode?: (agent?: AgentOptions) => void;
|
|
188
|
+
}
|
|
189
|
+
interface ContextMenuAction {
|
|
190
|
+
id: string;
|
|
191
|
+
label: string;
|
|
192
|
+
shortcut?: string;
|
|
193
|
+
enabled?: boolean | ((context: ActionContext) => boolean);
|
|
194
|
+
onAction: (context: ActionContext) => void;
|
|
195
|
+
agent?: AgentOptions;
|
|
196
|
+
}
|
|
197
|
+
interface PluginHooks {
|
|
177
198
|
onActivate?: () => void;
|
|
178
199
|
onDeactivate?: () => void;
|
|
179
200
|
onElementHover?: (element: Element) => void;
|
|
@@ -185,16 +206,48 @@ interface Options {
|
|
|
185
206
|
onCopySuccess?: (elements: Element[], content: string) => void;
|
|
186
207
|
onCopyError?: (error: Error) => void;
|
|
187
208
|
onStateChange?: (state: ReactGrabState) => void;
|
|
188
|
-
|
|
209
|
+
onPromptModeChange?: (isPromptMode: boolean, context: PromptModeContext) => void;
|
|
189
210
|
onSelectionBox?: (visible: boolean, bounds: OverlayBounds | null, element: Element | null) => void;
|
|
190
211
|
onDragBox?: (visible: boolean, bounds: OverlayBounds | null) => void;
|
|
191
212
|
onGrabbedBox?: (bounds: OverlayBounds, element: Element) => void;
|
|
192
213
|
onElementLabel?: (visible: boolean, variant: ElementLabelVariant, context: ElementLabelContext) => void;
|
|
193
214
|
onCrosshair?: (visible: boolean, context: CrosshairContext) => void;
|
|
194
|
-
|
|
195
|
-
|
|
215
|
+
onContextMenu?: (element: Element, position: {
|
|
216
|
+
x: number;
|
|
217
|
+
y: number;
|
|
218
|
+
}) => void;
|
|
219
|
+
onOpenFile?: (filePath: string, lineNumber?: number) => boolean | void;
|
|
220
|
+
}
|
|
221
|
+
interface PluginConfig {
|
|
222
|
+
theme?: DeepPartial<Theme>;
|
|
223
|
+
options?: SettableOptions;
|
|
224
|
+
actions?: ContextMenuAction[];
|
|
225
|
+
hooks?: PluginHooks;
|
|
226
|
+
cleanup?: () => void;
|
|
227
|
+
}
|
|
228
|
+
interface Plugin {
|
|
229
|
+
name: string;
|
|
230
|
+
theme?: DeepPartial<Theme>;
|
|
231
|
+
options?: SettableOptions;
|
|
232
|
+
actions?: ContextMenuAction[];
|
|
233
|
+
hooks?: PluginHooks;
|
|
234
|
+
setup?: (api: ReactGrabAPI) => PluginConfig | void;
|
|
235
|
+
}
|
|
236
|
+
interface Options {
|
|
237
|
+
enabled?: boolean;
|
|
238
|
+
activationMode?: ActivationMode;
|
|
239
|
+
keyHoldDuration?: number;
|
|
240
|
+
allowActivationInsideInput?: boolean;
|
|
241
|
+
maxContextLines?: number;
|
|
242
|
+
activationKey?: ActivationKey;
|
|
243
|
+
getContent?: (elements: Element[]) => Promise<string> | string;
|
|
244
|
+
}
|
|
245
|
+
type SettableOptions = Omit<Options, "enabled">;
|
|
246
|
+
interface SourceInfo {
|
|
247
|
+
filePath: string;
|
|
248
|
+
lineNumber: number | null;
|
|
249
|
+
componentName: string | null;
|
|
196
250
|
}
|
|
197
|
-
type UpdatableOptions = Pick<Options, "onActivate" | "onDeactivate" | "onElementHover" | "onElementSelect" | "onDragStart" | "onDragEnd" | "onBeforeCopy" | "onAfterCopy" | "onCopySuccess" | "onCopyError" | "onStateChange" | "onInputModeChange" | "onSelectionBox" | "onDragBox" | "onGrabbedBox" | "onElementLabel" | "onCrosshair" | "onOpenFile">;
|
|
198
251
|
interface ReactGrabAPI {
|
|
199
252
|
activate: () => void;
|
|
200
253
|
deactivate: () => void;
|
|
@@ -202,11 +255,12 @@ interface ReactGrabAPI {
|
|
|
202
255
|
isActive: () => boolean;
|
|
203
256
|
dispose: () => void;
|
|
204
257
|
copyElement: (elements: Element | Element[]) => Promise<boolean>;
|
|
258
|
+
getSource: (element: Element) => Promise<SourceInfo | null>;
|
|
205
259
|
getState: () => ReactGrabState;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
260
|
+
setOptions: (options: SettableOptions) => void;
|
|
261
|
+
registerPlugin: (plugin: Plugin) => void;
|
|
262
|
+
unregisterPlugin: (name: string) => void;
|
|
263
|
+
getPlugins: () => string[];
|
|
210
264
|
}
|
|
211
265
|
interface OverlayBounds {
|
|
212
266
|
borderRadius: string;
|
|
@@ -216,16 +270,20 @@ interface OverlayBounds {
|
|
|
216
270
|
x: number;
|
|
217
271
|
y: number;
|
|
218
272
|
}
|
|
219
|
-
type SelectionLabelStatus = "idle" | "copying" | "copied" | "fading";
|
|
273
|
+
type SelectionLabelStatus = "idle" | "copying" | "copied" | "fading" | "error";
|
|
220
274
|
interface SelectionLabelInstance {
|
|
221
275
|
id: string;
|
|
222
276
|
bounds: OverlayBounds;
|
|
277
|
+
boundsMultiple?: OverlayBounds[];
|
|
223
278
|
tagName: string;
|
|
224
279
|
componentName?: string;
|
|
225
280
|
status: SelectionLabelStatus;
|
|
226
281
|
createdAt: number;
|
|
227
282
|
element?: Element;
|
|
283
|
+
elements?: Element[];
|
|
228
284
|
mouseX?: number;
|
|
285
|
+
mouseXOffsetFromCenter?: number;
|
|
286
|
+
errorMessage?: string;
|
|
229
287
|
}
|
|
230
288
|
interface ReactGrabRendererProps {
|
|
231
289
|
selectionVisible?: boolean;
|
|
@@ -251,7 +309,7 @@ interface ReactGrabRendererProps {
|
|
|
251
309
|
mouseY?: number;
|
|
252
310
|
crosshairVisible?: boolean;
|
|
253
311
|
inputValue?: string;
|
|
254
|
-
|
|
312
|
+
isPromptMode?: boolean;
|
|
255
313
|
replyToPrompt?: string;
|
|
256
314
|
hasAgent?: boolean;
|
|
257
315
|
isAgentConnected?: boolean;
|
|
@@ -266,6 +324,8 @@ interface ReactGrabRendererProps {
|
|
|
266
324
|
onFollowUpSubmitSession?: (sessionId: string, prompt: string) => void;
|
|
267
325
|
onAcknowledgeSessionError?: (sessionId: string) => void;
|
|
268
326
|
onRetrySession?: (sessionId: string) => void;
|
|
327
|
+
onShowContextMenuSession?: (sessionId: string) => void;
|
|
328
|
+
onShowContextMenuInstance?: (instanceId: string) => void;
|
|
269
329
|
onInputChange?: (value: string) => void;
|
|
270
330
|
onInputSubmit?: () => void;
|
|
271
331
|
onInputCancel?: () => void;
|
|
@@ -278,6 +338,21 @@ interface ReactGrabRendererProps {
|
|
|
278
338
|
toolbarVisible?: boolean;
|
|
279
339
|
isActive?: boolean;
|
|
280
340
|
onToggleActive?: () => void;
|
|
341
|
+
contextMenuPosition?: {
|
|
342
|
+
x: number;
|
|
343
|
+
y: number;
|
|
344
|
+
} | null;
|
|
345
|
+
contextMenuBounds?: OverlayBounds | null;
|
|
346
|
+
contextMenuTagName?: string;
|
|
347
|
+
contextMenuComponentName?: string;
|
|
348
|
+
contextMenuHasFilePath?: boolean;
|
|
349
|
+
actions?: ContextMenuAction[];
|
|
350
|
+
actionContext?: ActionContext;
|
|
351
|
+
onContextMenuCopy?: () => void;
|
|
352
|
+
onContextMenuCopyScreenshot?: () => void;
|
|
353
|
+
onContextMenuOpen?: () => void;
|
|
354
|
+
onContextMenuDismiss?: () => void;
|
|
355
|
+
onContextMenuHide?: () => void;
|
|
281
356
|
}
|
|
282
357
|
interface GrabbedBox {
|
|
283
358
|
id: string;
|
|
@@ -319,4 +394,4 @@ declare const copyContent: (content: string, options?: CopyContentOptions) => bo
|
|
|
319
394
|
|
|
320
395
|
declare const init: (rawOptions?: Options) => ReactGrabAPI;
|
|
321
396
|
|
|
322
|
-
export { type AgentContext as A, type CrosshairContext as C, DEFAULT_THEME as D, type ElementLabelVariant as E, type GrabbedBox as G, type
|
|
397
|
+
export { type AgentContext as A, type CrosshairContext as C, DEFAULT_THEME as D, type ElementLabelVariant as E, type GrabbedBox as G, type Options as O, type PromptModeContext as P, type ReactGrabAPI as R, type SourceInfo as S, type Theme as T, 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 SettableOptions as p, type ActivationMode as q, type ContextMenuAction as r, type ActionContext as s, type Plugin as t, type PluginConfig as u, type PluginHooks as v, type ReactGrabRendererProps as w, copyContent as x };
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkDIAOCH5J_cjs=require('./chunk-DIAOCH5J.cjs');/**
|
|
2
2
|
* @license MIT
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2025 Aiden Bai
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
var e=null,
|
|
9
|
+
var e=null,c=()=>typeof window>"u"?e:window.__REACT_GRAB__??e??null,f=t=>{e=t,typeof window<"u"&&(t?window.__REACT_GRAB__=t:delete window.__REACT_GRAB__);};typeof window<"u"&&(window.__REACT_GRAB__?e=window.__REACT_GRAB__:(e=chunkDIAOCH5J_cjs.k(),window.__REACT_GRAB__=e),window.dispatchEvent(new CustomEvent("react-grab:init",{detail:e})));Object.defineProperty(exports,"DEFAULT_THEME",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.j}});Object.defineProperty(exports,"captureElementScreenshot",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.h}});Object.defineProperty(exports,"combineBounds",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.g}});Object.defineProperty(exports,"copyImageToClipboard",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.i}});Object.defineProperty(exports,"formatElementInfo",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.d}});Object.defineProperty(exports,"generateSnippet",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.f}});Object.defineProperty(exports,"getStack",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.c}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.k}});Object.defineProperty(exports,"isInstrumentationActive",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.b}});Object.defineProperty(exports,"isScreenshotSupported",{enumerable:true,get:function(){return chunkDIAOCH5J_cjs.a}});exports.getGlobalApi=c;exports.setGlobalApi=f;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import { R as ReactGrabAPI } from './index-
|
|
2
|
-
export {
|
|
1
|
+
import { R as ReactGrabAPI } from './index-BdKhAk4Q.cjs';
|
|
2
|
+
export { s as ActionContext, q as ActivationMode, o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, r as ContextMenuAction, C as CrosshairContext, D as DEFAULT_THEME, h as DeepPartial, e as DragRect, j as ElementLabelContext, E as ElementLabelVariant, G as GrabbedBox, O as Options, d as OverlayBounds, t as Plugin, u as PluginConfig, v as PluginHooks, P as PromptModeContext, c as ReactGrabState, f as Rect, p as SettableOptions, S as SourceInfo, T as Theme, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './index-BdKhAk4Q.cjs';
|
|
3
3
|
export { isInstrumentationActive } from 'bippy';
|
|
4
4
|
import 'bippy/source';
|
|
5
5
|
|
|
6
|
+
interface ElementBounds {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
declare const combineBounds: (boundsList: ElementBounds[]) => ElementBounds;
|
|
13
|
+
declare const captureElementScreenshot: (bounds: ElementBounds) => Promise<Blob>;
|
|
14
|
+
declare const copyImageToClipboard: (blob: Blob) => Promise<boolean>;
|
|
15
|
+
|
|
16
|
+
declare const isScreenshotSupported: () => boolean;
|
|
17
|
+
|
|
6
18
|
declare global {
|
|
7
19
|
interface Window {
|
|
8
20
|
__REACT_GRAB__?: ReactGrabAPI;
|
|
@@ -11,4 +23,4 @@ declare global {
|
|
|
11
23
|
declare const getGlobalApi: () => ReactGrabAPI | null;
|
|
12
24
|
declare const setGlobalApi: (api: ReactGrabAPI | null) => void;
|
|
13
25
|
|
|
14
|
-
export { ReactGrabAPI, getGlobalApi, setGlobalApi };
|
|
26
|
+
export { type ElementBounds, ReactGrabAPI, captureElementScreenshot, combineBounds, copyImageToClipboard, getGlobalApi, isScreenshotSupported, setGlobalApi };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import { R as ReactGrabAPI } from './index-
|
|
2
|
-
export {
|
|
1
|
+
import { R as ReactGrabAPI } from './index-BdKhAk4Q.js';
|
|
2
|
+
export { s as ActionContext, q as ActivationMode, o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, r as ContextMenuAction, C as CrosshairContext, D as DEFAULT_THEME, h as DeepPartial, e as DragRect, j as ElementLabelContext, E as ElementLabelVariant, G as GrabbedBox, O as Options, d as OverlayBounds, t as Plugin, u as PluginConfig, v as PluginHooks, P as PromptModeContext, c as ReactGrabState, f as Rect, p as SettableOptions, S as SourceInfo, T as Theme, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './index-BdKhAk4Q.js';
|
|
3
3
|
export { isInstrumentationActive } from 'bippy';
|
|
4
4
|
import 'bippy/source';
|
|
5
5
|
|
|
6
|
+
interface ElementBounds {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
declare const combineBounds: (boundsList: ElementBounds[]) => ElementBounds;
|
|
13
|
+
declare const captureElementScreenshot: (bounds: ElementBounds) => Promise<Blob>;
|
|
14
|
+
declare const copyImageToClipboard: (blob: Blob) => Promise<boolean>;
|
|
15
|
+
|
|
16
|
+
declare const isScreenshotSupported: () => boolean;
|
|
17
|
+
|
|
6
18
|
declare global {
|
|
7
19
|
interface Window {
|
|
8
20
|
__REACT_GRAB__?: ReactGrabAPI;
|
|
@@ -11,4 +23,4 @@ declare global {
|
|
|
11
23
|
declare const getGlobalApi: () => ReactGrabAPI | null;
|
|
12
24
|
declare const setGlobalApi: (api: ReactGrabAPI | null) => void;
|
|
13
25
|
|
|
14
|
-
export { ReactGrabAPI, getGlobalApi, setGlobalApi };
|
|
26
|
+
export { type ElementBounds, ReactGrabAPI, captureElementScreenshot, combineBounds, copyImageToClipboard, getGlobalApi, isScreenshotSupported, setGlobalApi };
|