grab 0.0.98 → 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.
@@ -1 +1 @@
1
- 'use strict';var chunkH4U7EPBM_cjs=require('../chunk-H4U7EPBM.cjs');Object.defineProperty(exports,"DEFAULT_THEME",{enumerable:true,get:function(){return chunkH4U7EPBM_cjs.f}});Object.defineProperty(exports,"copyContent",{enumerable:true,get:function(){return chunkH4U7EPBM_cjs.d}});Object.defineProperty(exports,"formatElementInfo",{enumerable:true,get:function(){return chunkH4U7EPBM_cjs.c}});Object.defineProperty(exports,"generateSnippet",{enumerable:true,get:function(){return chunkH4U7EPBM_cjs.e}});Object.defineProperty(exports,"getStack",{enumerable:true,get:function(){return chunkH4U7EPBM_cjs.b}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunkH4U7EPBM_cjs.g}});Object.defineProperty(exports,"isInstrumentationActive",{enumerable:true,get:function(){return chunkH4U7EPBM_cjs.a}});
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}});
@@ -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, q as ReactGrabRendererProps, U as UpdatableOptions, r as copyContent, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from '../index-r1odQUH0.cjs';
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';
@@ -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, q as ReactGrabRendererProps, U as UpdatableOptions, r as copyContent, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from '../index-r1odQUH0.js';
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';
@@ -1 +1 @@
1
- export{f as DEFAULT_THEME,d as copyContent,c as formatElementInfo,e as generateSnippet,b as getStack,g as init,a as isInstrumentationActive}from'../chunk-D2FWI6AP.js';
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
  /**
@@ -81,8 +81,21 @@ interface ReactGrabState {
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
101
  interface PromptModeContext {
@@ -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
- interface ActivationKey {
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;
@@ -165,16 +177,24 @@ interface AgentOptions<T = any> {
165
177
  onDismiss?: (session: AgentSession, elements: Element[]) => void;
166
178
  }
167
179
  type ActivationMode = "toggle" | "hold";
168
- interface Options {
169
- enabled?: boolean;
170
- activationMode?: ActivationMode;
171
- keyHoldDuration?: number;
172
- allowActivationInsideInput?: boolean;
173
- maxContextLines?: number;
174
- theme?: Theme;
175
- activationShortcut?: (event: KeyboardEvent) => boolean;
176
- activationKey?: ActivationKey;
177
- getContent?: (elements: Element[]) => Promise<string> | string;
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 {
178
198
  onActivate?: () => void;
179
199
  onDeactivate?: () => void;
180
200
  onElementHover?: (element: Element) => void;
@@ -196,10 +216,38 @@ interface Options {
196
216
  x: number;
197
217
  y: number;
198
218
  }) => void;
199
- onOpenFile?: (filePath: string, lineNumber?: number) => void;
200
- agent?: AgentOptions;
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;
201
250
  }
202
- type UpdatableOptions = Pick<Options, "onActivate" | "onDeactivate" | "onElementHover" | "onElementSelect" | "onDragStart" | "onDragEnd" | "onBeforeCopy" | "onAfterCopy" | "onCopySuccess" | "onCopyError" | "onStateChange" | "onPromptModeChange" | "onSelectionBox" | "onDragBox" | "onGrabbedBox" | "onElementLabel" | "onCrosshair" | "onContextMenu" | "onOpenFile">;
203
251
  interface ReactGrabAPI {
204
252
  activate: () => void;
205
253
  deactivate: () => void;
@@ -207,11 +255,12 @@ interface ReactGrabAPI {
207
255
  isActive: () => boolean;
208
256
  dispose: () => void;
209
257
  copyElement: (elements: Element | Element[]) => Promise<boolean>;
258
+ getSource: (element: Element) => Promise<SourceInfo | null>;
210
259
  getState: () => ReactGrabState;
211
- updateTheme: (theme: DeepPartial<Theme>) => void;
212
- getTheme: () => Required<Theme>;
213
- setAgent: (options: AgentOptions) => void;
214
- updateOptions: (options: UpdatableOptions) => void;
260
+ setOptions: (options: SettableOptions) => void;
261
+ registerPlugin: (plugin: Plugin) => void;
262
+ unregisterPlugin: (name: string) => void;
263
+ getPlugins: () => string[];
215
264
  }
216
265
  interface OverlayBounds {
217
266
  borderRadius: string;
@@ -233,6 +282,7 @@ interface SelectionLabelInstance {
233
282
  element?: Element;
234
283
  elements?: Element[];
235
284
  mouseX?: number;
285
+ mouseXOffsetFromCenter?: number;
236
286
  errorMessage?: string;
237
287
  }
238
288
  interface ReactGrabRendererProps {
@@ -296,12 +346,13 @@ interface ReactGrabRendererProps {
296
346
  contextMenuTagName?: string;
297
347
  contextMenuComponentName?: string;
298
348
  contextMenuHasFilePath?: boolean;
299
- contextMenuHasAgent?: boolean;
349
+ actions?: ContextMenuAction[];
350
+ actionContext?: ActionContext;
300
351
  onContextMenuCopy?: () => void;
301
352
  onContextMenuCopyScreenshot?: () => void;
302
353
  onContextMenuOpen?: () => void;
303
- onContextMenuEdit?: () => void;
304
354
  onContextMenuDismiss?: () => void;
355
+ onContextMenuHide?: () => void;
305
356
  }
306
357
  interface GrabbedBox {
307
358
  id: string;
@@ -343,4 +394,4 @@ declare const copyContent: (content: string, options?: CopyContentOptions) => bo
343
394
 
344
395
  declare const init: (rawOptions?: Options) => ReactGrabAPI;
345
396
 
346
- 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 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 ActivationMode as p, type ReactGrabRendererProps as q, copyContent as r };
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
  /**
@@ -81,8 +81,21 @@ interface ReactGrabState {
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
101
  interface PromptModeContext {
@@ -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
- interface ActivationKey {
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;
@@ -165,16 +177,24 @@ interface AgentOptions<T = any> {
165
177
  onDismiss?: (session: AgentSession, elements: Element[]) => void;
166
178
  }
167
179
  type ActivationMode = "toggle" | "hold";
168
- interface Options {
169
- enabled?: boolean;
170
- activationMode?: ActivationMode;
171
- keyHoldDuration?: number;
172
- allowActivationInsideInput?: boolean;
173
- maxContextLines?: number;
174
- theme?: Theme;
175
- activationShortcut?: (event: KeyboardEvent) => boolean;
176
- activationKey?: ActivationKey;
177
- getContent?: (elements: Element[]) => Promise<string> | string;
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 {
178
198
  onActivate?: () => void;
179
199
  onDeactivate?: () => void;
180
200
  onElementHover?: (element: Element) => void;
@@ -196,10 +216,38 @@ interface Options {
196
216
  x: number;
197
217
  y: number;
198
218
  }) => void;
199
- onOpenFile?: (filePath: string, lineNumber?: number) => void;
200
- agent?: AgentOptions;
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;
201
250
  }
202
- type UpdatableOptions = Pick<Options, "onActivate" | "onDeactivate" | "onElementHover" | "onElementSelect" | "onDragStart" | "onDragEnd" | "onBeforeCopy" | "onAfterCopy" | "onCopySuccess" | "onCopyError" | "onStateChange" | "onPromptModeChange" | "onSelectionBox" | "onDragBox" | "onGrabbedBox" | "onElementLabel" | "onCrosshair" | "onContextMenu" | "onOpenFile">;
203
251
  interface ReactGrabAPI {
204
252
  activate: () => void;
205
253
  deactivate: () => void;
@@ -207,11 +255,12 @@ interface ReactGrabAPI {
207
255
  isActive: () => boolean;
208
256
  dispose: () => void;
209
257
  copyElement: (elements: Element | Element[]) => Promise<boolean>;
258
+ getSource: (element: Element) => Promise<SourceInfo | null>;
210
259
  getState: () => ReactGrabState;
211
- updateTheme: (theme: DeepPartial<Theme>) => void;
212
- getTheme: () => Required<Theme>;
213
- setAgent: (options: AgentOptions) => void;
214
- updateOptions: (options: UpdatableOptions) => void;
260
+ setOptions: (options: SettableOptions) => void;
261
+ registerPlugin: (plugin: Plugin) => void;
262
+ unregisterPlugin: (name: string) => void;
263
+ getPlugins: () => string[];
215
264
  }
216
265
  interface OverlayBounds {
217
266
  borderRadius: string;
@@ -233,6 +282,7 @@ interface SelectionLabelInstance {
233
282
  element?: Element;
234
283
  elements?: Element[];
235
284
  mouseX?: number;
285
+ mouseXOffsetFromCenter?: number;
236
286
  errorMessage?: string;
237
287
  }
238
288
  interface ReactGrabRendererProps {
@@ -296,12 +346,13 @@ interface ReactGrabRendererProps {
296
346
  contextMenuTagName?: string;
297
347
  contextMenuComponentName?: string;
298
348
  contextMenuHasFilePath?: boolean;
299
- contextMenuHasAgent?: boolean;
349
+ actions?: ContextMenuAction[];
350
+ actionContext?: ActionContext;
300
351
  onContextMenuCopy?: () => void;
301
352
  onContextMenuCopyScreenshot?: () => void;
302
353
  onContextMenuOpen?: () => void;
303
- onContextMenuEdit?: () => void;
304
354
  onContextMenuDismiss?: () => void;
355
+ onContextMenuHide?: () => void;
305
356
  }
306
357
  interface GrabbedBox {
307
358
  id: string;
@@ -343,4 +394,4 @@ declare const copyContent: (content: string, options?: CopyContentOptions) => bo
343
394
 
344
395
  declare const init: (rawOptions?: Options) => ReactGrabAPI;
345
396
 
346
- 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 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 ActivationMode as p, type ReactGrabRendererProps as q, copyContent as r };
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 chunkH4U7EPBM_cjs=require('./chunk-H4U7EPBM.cjs');/**
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,A=()=>typeof window>"u"?e:window.__REACT_GRAB__??e??null,d=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=chunkH4U7EPBM_cjs.g(),window.__REACT_GRAB__=e),window.dispatchEvent(new CustomEvent("react-grab:init",{detail:e})));Object.defineProperty(exports,"DEFAULT_THEME",{enumerable:true,get:function(){return chunkH4U7EPBM_cjs.f}});Object.defineProperty(exports,"formatElementInfo",{enumerable:true,get:function(){return chunkH4U7EPBM_cjs.c}});Object.defineProperty(exports,"generateSnippet",{enumerable:true,get:function(){return chunkH4U7EPBM_cjs.e}});Object.defineProperty(exports,"getStack",{enumerable:true,get:function(){return chunkH4U7EPBM_cjs.b}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunkH4U7EPBM_cjs.g}});Object.defineProperty(exports,"isInstrumentationActive",{enumerable:true,get:function(){return chunkH4U7EPBM_cjs.a}});exports.getGlobalApi=A;exports.setGlobalApi=d;
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-r1odQUH0.cjs';
2
- export { p as ActivationMode, o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, 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, P as PromptModeContext, c as ReactGrabState, f as Rect, T as Theme, U as UpdatableOptions, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './index-r1odQUH0.cjs';
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-r1odQUH0.js';
2
- export { p as ActivationMode, o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, 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, P as PromptModeContext, c as ReactGrabState, f as Rect, T as Theme, U as UpdatableOptions, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './index-r1odQUH0.js';
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 };