react-grab 0.1.0-beta.12 → 0.1.0-beta.13
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 +11 -93
- package/dist/chunk-5TQBD3AH.cjs +106 -0
- package/dist/chunk-6PEZJBAF.cjs +10 -0
- package/dist/chunk-EHGLOVF2.js +106 -0
- package/dist/chunk-G7QPN3E5.cjs +11 -0
- package/dist/chunk-IYMRLGML.js +10 -0
- package/dist/chunk-PPI6EUPG.js +11 -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/design-system.cjs +1 -1
- package/dist/design-system.js +1 -1
- package/dist/{index-bp3m7etC.d.cts → index-S4g1Qwb1.d.cts} +58 -8
- package/dist/{index-bp3m7etC.d.ts → index-S4g1Qwb1.d.ts} +58 -8
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.global.js +45 -40
- package/dist/index.js +2 -2
- package/dist/styles.css +1 -1
- package/package.json +30 -31
- package/dist/chunk-2OP4FRK6.js +0 -101
- package/dist/chunk-77NP5QEW.js +0 -11
- package/dist/chunk-CXR4WNCU.js +0 -10
- package/dist/chunk-FSCLGHFJ.cjs +0 -11
- package/dist/chunk-IQAOZJY4.cjs +0 -10
- package/dist/chunk-QABZD56C.cjs +0 -101
|
@@ -96,6 +96,7 @@ interface ReactGrabState {
|
|
|
96
96
|
createdAt: number;
|
|
97
97
|
}>;
|
|
98
98
|
selectionFilePath: string | null;
|
|
99
|
+
toolbarState: ToolbarState | null;
|
|
99
100
|
}
|
|
100
101
|
type ElementLabelVariant = "hover" | "processing" | "success";
|
|
101
102
|
interface PromptModeContext {
|
|
@@ -177,6 +178,12 @@ interface AgentOptions<T = any> {
|
|
|
177
178
|
onDismiss?: (session: AgentSession, elements: Element[]) => void;
|
|
178
179
|
}
|
|
179
180
|
type ActivationMode = "toggle" | "hold";
|
|
181
|
+
interface ActionContextHooks {
|
|
182
|
+
transformHtmlContent: (html: string, elements: Element[]) => Promise<string>;
|
|
183
|
+
transformScreenshot: (blob: Blob, elements: Element[], bounds: ScreenshotBounds) => Promise<Blob>;
|
|
184
|
+
onOpenFile: (filePath: string, lineNumber?: number) => boolean | void;
|
|
185
|
+
transformOpenFileUrl: (url: string, filePath: string, lineNumber?: number) => string;
|
|
186
|
+
}
|
|
180
187
|
interface ActionContext {
|
|
181
188
|
element: Element;
|
|
182
189
|
elements: Element[];
|
|
@@ -185,15 +192,30 @@ interface ActionContext {
|
|
|
185
192
|
componentName?: string;
|
|
186
193
|
tagName?: string;
|
|
187
194
|
enterPromptMode?: (agent?: AgentOptions) => void;
|
|
195
|
+
hooks: ActionContextHooks;
|
|
196
|
+
performWithFeedback: (action: () => Promise<boolean>) => Promise<void>;
|
|
197
|
+
hideContextMenu: () => void;
|
|
198
|
+
hideOverlay: () => void;
|
|
199
|
+
showOverlay: () => void;
|
|
200
|
+
cleanup: () => void;
|
|
201
|
+
}
|
|
202
|
+
interface ContextMenuActionContext extends ActionContext {
|
|
203
|
+
copy?: () => void;
|
|
188
204
|
}
|
|
189
205
|
interface ContextMenuAction {
|
|
190
206
|
id: string;
|
|
191
207
|
label: string;
|
|
192
208
|
shortcut?: string;
|
|
193
209
|
enabled?: boolean | ((context: ActionContext) => boolean);
|
|
194
|
-
onAction: (context:
|
|
210
|
+
onAction: (context: ContextMenuActionContext) => void | Promise<void>;
|
|
195
211
|
agent?: AgentOptions;
|
|
196
212
|
}
|
|
213
|
+
interface ScreenshotBounds {
|
|
214
|
+
x: number;
|
|
215
|
+
y: number;
|
|
216
|
+
width: number;
|
|
217
|
+
height: number;
|
|
218
|
+
}
|
|
197
219
|
interface PluginHooks {
|
|
198
220
|
onActivate?: () => void;
|
|
199
221
|
onDeactivate?: () => void;
|
|
@@ -202,6 +224,7 @@ interface PluginHooks {
|
|
|
202
224
|
onDragStart?: (startX: number, startY: number) => void;
|
|
203
225
|
onDragEnd?: (elements: Element[], bounds: DragRect) => void;
|
|
204
226
|
onBeforeCopy?: (elements: Element[]) => void | Promise<void>;
|
|
227
|
+
transformCopyContent?: (content: string, elements: Element[]) => string | Promise<string>;
|
|
205
228
|
onAfterCopy?: (elements: Element[], success: boolean) => void;
|
|
206
229
|
onCopySuccess?: (elements: Element[], content: string) => void;
|
|
207
230
|
onCopyError?: (error: Error) => void;
|
|
@@ -217,6 +240,12 @@ interface PluginHooks {
|
|
|
217
240
|
y: number;
|
|
218
241
|
}) => void;
|
|
219
242
|
onOpenFile?: (filePath: string, lineNumber?: number) => boolean | void;
|
|
243
|
+
transformHtmlContent?: (html: string, elements: Element[]) => string | Promise<string>;
|
|
244
|
+
transformScreenshot?: (blob: Blob, elements: Element[], bounds: ScreenshotBounds) => Blob | Promise<Blob>;
|
|
245
|
+
transformAgentContext?: (context: AgentContext, elements: Element[]) => AgentContext | Promise<AgentContext>;
|
|
246
|
+
transformActionContext?: (context: ActionContext) => ActionContext;
|
|
247
|
+
transformOpenFileUrl?: (url: string, filePath: string, lineNumber?: number) => string;
|
|
248
|
+
transformSnippet?: (snippet: string, element: Element) => string | Promise<string>;
|
|
220
249
|
}
|
|
221
250
|
interface PluginConfig {
|
|
222
251
|
theme?: DeepPartial<Theme>;
|
|
@@ -241,18 +270,37 @@ interface Options {
|
|
|
241
270
|
maxContextLines?: number;
|
|
242
271
|
activationKey?: ActivationKey;
|
|
243
272
|
getContent?: (elements: Element[]) => Promise<string> | string;
|
|
273
|
+
/**
|
|
274
|
+
* Whether to freeze React state updates while React Grab is active.
|
|
275
|
+
* This prevents UI changes from interfering with element selection.
|
|
276
|
+
* @default true
|
|
277
|
+
*/
|
|
278
|
+
freezeReactUpdates?: boolean;
|
|
279
|
+
}
|
|
280
|
+
interface SettableOptions extends Options {
|
|
281
|
+
enabled?: never;
|
|
244
282
|
}
|
|
245
|
-
type SettableOptions = Omit<Options, "enabled">;
|
|
246
283
|
interface SourceInfo {
|
|
247
284
|
filePath: string;
|
|
248
285
|
lineNumber: number | null;
|
|
249
286
|
componentName: string | null;
|
|
250
287
|
}
|
|
288
|
+
interface ToolbarState {
|
|
289
|
+
edge: "top" | "bottom" | "left" | "right";
|
|
290
|
+
ratio: number;
|
|
291
|
+
collapsed: boolean;
|
|
292
|
+
enabled: boolean;
|
|
293
|
+
}
|
|
251
294
|
interface ReactGrabAPI {
|
|
252
295
|
activate: () => void;
|
|
253
296
|
deactivate: () => void;
|
|
254
297
|
toggle: () => void;
|
|
255
298
|
isActive: () => boolean;
|
|
299
|
+
isEnabled: () => boolean;
|
|
300
|
+
setEnabled: (enabled: boolean) => void;
|
|
301
|
+
getToolbarState: () => ToolbarState | null;
|
|
302
|
+
setToolbarState: (state: Partial<ToolbarState>) => void;
|
|
303
|
+
onToolbarStateChange: (callback: (state: ToolbarState) => void) => () => void;
|
|
256
304
|
dispose: () => void;
|
|
257
305
|
copyElement: (elements: Element | Element[]) => Promise<boolean>;
|
|
258
306
|
getSource: (element: Element) => Promise<SourceInfo | null>;
|
|
@@ -311,6 +359,7 @@ interface ReactGrabRendererProps {
|
|
|
311
359
|
mouseX?: number;
|
|
312
360
|
mouseY?: number;
|
|
313
361
|
crosshairVisible?: boolean;
|
|
362
|
+
isFrozen?: boolean;
|
|
314
363
|
inputValue?: string;
|
|
315
364
|
isPromptMode?: boolean;
|
|
316
365
|
replyToPrompt?: string;
|
|
@@ -329,6 +378,7 @@ interface ReactGrabRendererProps {
|
|
|
329
378
|
onRetrySession?: (sessionId: string) => void;
|
|
330
379
|
onShowContextMenuSession?: (sessionId: string) => void;
|
|
331
380
|
onShowContextMenuInstance?: (instanceId: string) => void;
|
|
381
|
+
onLabelInstanceHoverChange?: (instanceId: string, isHovered: boolean) => void;
|
|
332
382
|
onInputChange?: (value: string) => void;
|
|
333
383
|
onInputSubmit?: () => void;
|
|
334
384
|
onInputCancel?: () => void;
|
|
@@ -343,6 +393,10 @@ interface ReactGrabRendererProps {
|
|
|
343
393
|
onToggleActive?: () => void;
|
|
344
394
|
enabled?: boolean;
|
|
345
395
|
onToggleEnabled?: () => void;
|
|
396
|
+
shakeCount?: number;
|
|
397
|
+
onToolbarStateChange?: (state: ToolbarState) => void;
|
|
398
|
+
onSubscribeToToolbarStateChanges?: (callback: (state: ToolbarState) => void) => () => void;
|
|
399
|
+
onToolbarSelectHoverChange?: (isHovered: boolean) => void;
|
|
346
400
|
contextMenuPosition?: {
|
|
347
401
|
x: number;
|
|
348
402
|
y: number;
|
|
@@ -353,10 +407,6 @@ interface ReactGrabRendererProps {
|
|
|
353
407
|
contextMenuHasFilePath?: boolean;
|
|
354
408
|
actions?: ContextMenuAction[];
|
|
355
409
|
actionContext?: ActionContext;
|
|
356
|
-
onContextMenuCopy?: () => void;
|
|
357
|
-
onContextMenuCopyScreenshot?: () => void;
|
|
358
|
-
onContextMenuCopyHtml?: () => void;
|
|
359
|
-
onContextMenuOpen?: () => void;
|
|
360
410
|
onContextMenuDismiss?: () => void;
|
|
361
411
|
onContextMenuHide?: () => void;
|
|
362
412
|
}
|
|
@@ -394,10 +444,10 @@ declare const generateSnippet: (elements: Element[], options?: GenerateSnippetOp
|
|
|
394
444
|
|
|
395
445
|
interface CopyContentOptions {
|
|
396
446
|
onSuccess?: () => void;
|
|
397
|
-
|
|
447
|
+
name?: string;
|
|
398
448
|
}
|
|
399
449
|
declare const copyContent: (content: string, options?: CopyContentOptions) => boolean;
|
|
400
450
|
|
|
401
451
|
declare const init: (rawOptions?: Options) => ReactGrabAPI;
|
|
402
452
|
|
|
403
|
-
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
|
|
453
|
+
export { type AgentContext as A, copyContent as B, type CrosshairContext as C, DEFAULT_THEME as D, type ElementLabelVariant as E, type GrabbedBox as G, type Options as O, type Plugin 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 ToolbarState as d, type OverlayBounds as e, type DragRect as f, getStack as g, type Rect as h, init as i, type DeepPartial as j, type PromptModeContext as k, type ElementLabelContext as l, type AgentSession as m, type AgentProvider as n, type AgentSessionStorage as o, type AgentOptions as p, type AgentCompleteResult as q, type SettableOptions as r, type ActivationMode as s, type ContextMenuAction as t, type ContextMenuActionContext as u, type ActionContext as v, type ActionContextHooks as w, type PluginConfig as x, type PluginHooks as y, type ReactGrabRendererProps as z };
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk6PEZJBAF_cjs=require('./chunk-6PEZJBAF.cjs'),chunk5TQBD3AH_cjs=require('./chunk-5TQBD3AH.cjs');require('./chunk-G7QPN3E5.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,x=()=>typeof window>"u"?e:window.__REACT_GRAB__??e??null,R=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=chunk5TQBD3AH_cjs.o(),window.__REACT_GRAB__=e),window.dispatchEvent(new CustomEvent("react-grab:init",{detail:e})));Object.defineProperty(exports,"renderDesignSystemPreview",{enumerable:true,get:function(){return chunk6PEZJBAF_cjs.a}});Object.defineProperty(exports,"DEFAULT_THEME",{enumerable:true,get:function(){return chunk5TQBD3AH_cjs.j}});Object.defineProperty(exports,"captureElementScreenshot",{enumerable:true,get:function(){return chunk5TQBD3AH_cjs.g}});Object.defineProperty(exports,"combineBounds",{enumerable:true,get:function(){return chunk5TQBD3AH_cjs.f}});Object.defineProperty(exports,"commentPlugin",{enumerable:true,get:function(){return chunk5TQBD3AH_cjs.n}});Object.defineProperty(exports,"copyHtmlPlugin",{enumerable:true,get:function(){return chunk5TQBD3AH_cjs.l}});Object.defineProperty(exports,"copyImageToClipboard",{enumerable:true,get:function(){return chunk5TQBD3AH_cjs.h}});Object.defineProperty(exports,"formatElementInfo",{enumerable:true,get:function(){return chunk5TQBD3AH_cjs.c}});Object.defineProperty(exports,"generateSnippet",{enumerable:true,get:function(){return chunk5TQBD3AH_cjs.e}});Object.defineProperty(exports,"getStack",{enumerable:true,get:function(){return chunk5TQBD3AH_cjs.b}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunk5TQBD3AH_cjs.o}});Object.defineProperty(exports,"isInstrumentationActive",{enumerable:true,get:function(){return chunk5TQBD3AH_cjs.a}});Object.defineProperty(exports,"isScreenshotSupported",{enumerable:true,get:function(){return chunk5TQBD3AH_cjs.i}});Object.defineProperty(exports,"openPlugin",{enumerable:true,get:function(){return chunk5TQBD3AH_cjs.m}});Object.defineProperty(exports,"screenshotPlugin",{enumerable:true,get:function(){return chunk5TQBD3AH_cjs.k}});exports.getGlobalApi=x;exports.setGlobalApi=R;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { R as ReactGrabAPI } from './index-
|
|
2
|
-
export {
|
|
1
|
+
import { P as Plugin, R as ReactGrabAPI } from './index-S4g1Qwb1.cjs';
|
|
2
|
+
export { v as ActionContext, w as ActionContextHooks, s as ActivationMode, q as AgentCompleteResult, A as AgentContext, p as AgentOptions, n as AgentProvider, m as AgentSession, o as AgentSessionStorage, t as ContextMenuAction, u as ContextMenuActionContext, C as CrosshairContext, D as DEFAULT_THEME, j as DeepPartial, f as DragRect, l as ElementLabelContext, E as ElementLabelVariant, G as GrabbedBox, O as Options, e as OverlayBounds, x as PluginConfig, y as PluginHooks, k as PromptModeContext, c as ReactGrabState, h as Rect, r as SettableOptions, S as SourceInfo, T as Theme, d as ToolbarState, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './index-S4g1Qwb1.cjs';
|
|
3
3
|
export { renderDesignSystemPreview } from './design-system.cjs';
|
|
4
4
|
export { isInstrumentationActive } from 'bippy';
|
|
5
5
|
import 'bippy/source';
|
|
6
6
|
|
|
7
|
+
declare const screenshotPlugin: Plugin;
|
|
8
|
+
|
|
9
|
+
declare const copyHtmlPlugin: Plugin;
|
|
10
|
+
|
|
11
|
+
declare const openPlugin: Plugin;
|
|
12
|
+
|
|
13
|
+
declare const commentPlugin: Plugin;
|
|
14
|
+
|
|
7
15
|
interface ElementBounds {
|
|
8
16
|
x: number;
|
|
9
17
|
y: number;
|
|
@@ -24,4 +32,4 @@ declare global {
|
|
|
24
32
|
declare const getGlobalApi: () => ReactGrabAPI | null;
|
|
25
33
|
declare const setGlobalApi: (api: ReactGrabAPI | null) => void;
|
|
26
34
|
|
|
27
|
-
export { type ElementBounds, ReactGrabAPI, captureElementScreenshot, combineBounds, copyImageToClipboard, getGlobalApi, isScreenshotSupported, setGlobalApi };
|
|
35
|
+
export { type ElementBounds, Plugin, ReactGrabAPI, captureElementScreenshot, combineBounds, commentPlugin, copyHtmlPlugin, copyImageToClipboard, getGlobalApi, isScreenshotSupported, openPlugin, screenshotPlugin, setGlobalApi };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { R as ReactGrabAPI } from './index-
|
|
2
|
-
export {
|
|
1
|
+
import { P as Plugin, R as ReactGrabAPI } from './index-S4g1Qwb1.js';
|
|
2
|
+
export { v as ActionContext, w as ActionContextHooks, s as ActivationMode, q as AgentCompleteResult, A as AgentContext, p as AgentOptions, n as AgentProvider, m as AgentSession, o as AgentSessionStorage, t as ContextMenuAction, u as ContextMenuActionContext, C as CrosshairContext, D as DEFAULT_THEME, j as DeepPartial, f as DragRect, l as ElementLabelContext, E as ElementLabelVariant, G as GrabbedBox, O as Options, e as OverlayBounds, x as PluginConfig, y as PluginHooks, k as PromptModeContext, c as ReactGrabState, h as Rect, r as SettableOptions, S as SourceInfo, T as Theme, d as ToolbarState, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './index-S4g1Qwb1.js';
|
|
3
3
|
export { renderDesignSystemPreview } from './design-system.js';
|
|
4
4
|
export { isInstrumentationActive } from 'bippy';
|
|
5
5
|
import 'bippy/source';
|
|
6
6
|
|
|
7
|
+
declare const screenshotPlugin: Plugin;
|
|
8
|
+
|
|
9
|
+
declare const copyHtmlPlugin: Plugin;
|
|
10
|
+
|
|
11
|
+
declare const openPlugin: Plugin;
|
|
12
|
+
|
|
13
|
+
declare const commentPlugin: Plugin;
|
|
14
|
+
|
|
7
15
|
interface ElementBounds {
|
|
8
16
|
x: number;
|
|
9
17
|
y: number;
|
|
@@ -24,4 +32,4 @@ declare global {
|
|
|
24
32
|
declare const getGlobalApi: () => ReactGrabAPI | null;
|
|
25
33
|
declare const setGlobalApi: (api: ReactGrabAPI | null) => void;
|
|
26
34
|
|
|
27
|
-
export { type ElementBounds, ReactGrabAPI, captureElementScreenshot, combineBounds, copyImageToClipboard, getGlobalApi, isScreenshotSupported, setGlobalApi };
|
|
35
|
+
export { type ElementBounds, Plugin, ReactGrabAPI, captureElementScreenshot, combineBounds, commentPlugin, copyHtmlPlugin, copyImageToClipboard, getGlobalApi, isScreenshotSupported, openPlugin, screenshotPlugin, setGlobalApi };
|