react-grab 0.0.73 → 0.0.75

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.
@@ -1078,7 +1078,7 @@ var buildOpenFileUrl = (filePath, lineNumber) => {
1078
1078
  };
1079
1079
 
1080
1080
  // src/constants.ts
1081
- var VERSION = "0.0.73";
1081
+ var VERSION = "0.0.75";
1082
1082
  var VIEWPORT_MARGIN_PX = 8;
1083
1083
  var OFFSCREEN_POSITION = -1e3;
1084
1084
  var SELECTION_LERP_FACTOR = 0.95;
@@ -1087,6 +1087,7 @@ var COPIED_LABEL_DURATION_MS = 1500;
1087
1087
  var SELECTION_CURSOR_SETTLE_DELAY_MS = 500;
1088
1088
  var BLUR_DEACTIVATION_THRESHOLD_MS = 500;
1089
1089
  var INPUT_FOCUS_ACTIVATION_DELAY_MS = 150;
1090
+ var DEFAULT_KEY_HOLD_DURATION_MS = 200;
1090
1091
  var DRAG_THRESHOLD_PX = 2;
1091
1092
  var ELEMENT_DETECTION_THROTTLE_MS = 32;
1092
1093
  var BOUNDS_RECALC_INTERVAL_MS = 100;
@@ -3807,7 +3808,7 @@ var Crosshair = (props) => {
3807
3808
  var useSpeechRecognition = (options) => {
3808
3809
  let speechRecognition;
3809
3810
  const [isListening, setIsListening] = createSignal(false);
3810
- const isSupported = () => typeof window !== "undefined" && (!!window.SpeechRecognition || !!window.webkitSpeechRecognition);
3811
+ const isSupported = () => typeof window !== "undefined" && (Boolean(window.SpeechRecognition) || Boolean(window.webkitSpeechRecognition));
3811
3812
  const start = () => {
3812
3813
  if (!isSupported()) return;
3813
3814
  const SpeechRecognitionConstructor = window.SpeechRecognition || window.webkitSpeechRecognition;
@@ -4058,14 +4059,10 @@ var BottomSection = (props) => (() => {
4058
4059
  })();
4059
4060
  var DismissConfirmation = (props) => {
4060
4061
  const handleKeyDown = (event) => {
4061
- if (event.code === "Enter") {
4062
+ if (event.code === "Enter" || event.code === "Escape") {
4062
4063
  event.preventDefault();
4063
4064
  event.stopPropagation();
4064
4065
  props.onConfirm?.();
4065
- } else if (event.code === "Escape") {
4066
- event.preventDefault();
4067
- event.stopPropagation();
4068
- props.onCancel?.();
4069
4066
  }
4070
4067
  };
4071
4068
  onMount(() => {
@@ -4169,6 +4166,15 @@ var SelectionLabel = (props) => {
4169
4166
  resetIdleTimer();
4170
4167
  }
4171
4168
  });
4169
+ createEffect(() => {
4170
+ void props.tagName;
4171
+ void props.componentName;
4172
+ void props.statusText;
4173
+ void props.inputValue;
4174
+ void props.hasAgent;
4175
+ void props.isInputExpanded;
4176
+ requestAnimationFrame(measureContainer);
4177
+ });
4172
4178
  createEffect(() => {
4173
4179
  if (props.visible) {
4174
4180
  requestAnimationFrame(measureContainer);
@@ -4393,7 +4399,7 @@ var SelectionLabel = (props) => {
4393
4399
  onClick: handleSubmit,
4394
4400
  shrink: true,
4395
4401
  get hasParent() {
4396
- return !!props.componentName;
4402
+ return Boolean(props.componentName);
4397
4403
  },
4398
4404
  get hasAgent() {
4399
4405
  return props.hasAgent;
@@ -4480,7 +4486,7 @@ var SelectionLabel = (props) => {
4480
4486
  dimmed: true,
4481
4487
  shrink: true,
4482
4488
  get hasParent() {
4483
- return !!props.componentName;
4489
+ return Boolean(props.componentName);
4484
4490
  },
4485
4491
  get hasAgent() {
4486
4492
  return props.hasAgent;
@@ -6258,9 +6264,15 @@ var isTargetKeyCombination = (event, options) => {
6258
6264
  };
6259
6265
 
6260
6266
  // src/utils/is-event-from-overlay.ts
6261
- var isEventFromOverlay = (event, attribute) => event.composedPath().some(
6262
- (target) => target instanceof HTMLElement && target.hasAttribute(attribute)
6263
- );
6267
+ var isEventFromOverlay = (event, attribute) => {
6268
+ try {
6269
+ return event.composedPath().some(
6270
+ (target) => target instanceof HTMLElement && target.hasAttribute(attribute)
6271
+ );
6272
+ } catch {
6273
+ return false;
6274
+ }
6275
+ };
6264
6276
 
6265
6277
  // src/theme.ts
6266
6278
  var DEFAULT_THEME = {
@@ -6726,13 +6738,15 @@ var init = (rawOptions) => {
6726
6738
  },
6727
6739
  getTheme: () => initialTheme,
6728
6740
  setAgent: () => {
6741
+ },
6742
+ updateOptions: () => {
6729
6743
  }
6730
6744
  };
6731
6745
  }
6732
6746
  const scriptOptions = getScriptOptions();
6733
- const options = {
6747
+ let options = {
6734
6748
  enabled: true,
6735
- keyHoldDuration: 200,
6749
+ keyHoldDuration: DEFAULT_KEY_HOLD_DURATION_MS,
6736
6750
  allowActivationInsideInput: true,
6737
6751
  maxContextLines: 3,
6738
6752
  ...scriptOptions,
@@ -6763,13 +6777,15 @@ var init = (rawOptions) => {
6763
6777
  },
6764
6778
  getTheme: () => mergedTheme,
6765
6779
  setAgent: () => {
6780
+ },
6781
+ updateOptions: () => {
6766
6782
  }
6767
6783
  };
6768
6784
  }
6769
6785
  hasInited = true;
6770
6786
  const logIntro = () => {
6771
6787
  try {
6772
- const version = "0.0.73";
6788
+ const version = "0.0.75";
6773
6789
  const logoDataUri = `data:image/svg+xml;base64,${btoa(LOGO_SVG)}`;
6774
6790
  console.log(`%cReact Grab${version ? ` v${version}` : ""}%c
6775
6791
  https://react-grab.com`, `background: #330039; color: #ffffff; border: 1px solid #d75fcb; padding: 4px 4px 4px 24px; border-radius: 4px; background-image: url("${logoDataUri}"); background-size: 16px 16px; background-repeat: no-repeat; background-position: 4px center; display: inline-block; margin-bottom: 4px;`, "");
@@ -7023,9 +7039,6 @@ ${plainTextContentOnly}` : plainTextContentOnly;
7023
7039
  });
7024
7040
  }
7025
7041
  }
7026
- if (didCopy) {
7027
- options.onCopySuccess?.(elements, copiedContent);
7028
- }
7029
7042
  } catch (error) {
7030
7043
  options.onCopyError?.(error);
7031
7044
  const plainTextContentOnly = createCombinedTextContent(elements);
@@ -7039,6 +7052,9 @@ ${plainTextContentOnly}` : plainTextContentOnly;
7039
7052
  });
7040
7053
  }
7041
7054
  }
7055
+ if (didCopy) {
7056
+ options.onCopySuccess?.(elements, copiedContent);
7057
+ }
7042
7058
  options.onAfterCopy?.(elements, didCopy);
7043
7059
  return didCopy;
7044
7060
  };
@@ -7304,7 +7320,7 @@ ${plainTextContentOnly}` : plainTextContentOnly;
7304
7320
  }));
7305
7321
  const startProgressAnimation = (duration) => {
7306
7322
  const startTime = Date.now();
7307
- const animationDuration = options.keyHoldDuration;
7323
+ const animationDuration = options.keyHoldDuration ?? DEFAULT_KEY_HOLD_DURATION_MS;
7308
7324
  setProgressStartTime(startTime);
7309
7325
  const animateProgress = () => {
7310
7326
  const currentStartTime = progressStartTime();
@@ -7645,7 +7661,12 @@ ${plainTextContentOnly}` : plainTextContentOnly;
7645
7661
  });
7646
7662
  }
7647
7663
  const blockEnterIfNeeded = (event) => {
7648
- const originalKey = originalKeyDescriptor?.get ? originalKeyDescriptor.get.call(event) : event.key;
7664
+ let originalKey;
7665
+ try {
7666
+ originalKey = originalKeyDescriptor?.get ? originalKeyDescriptor.get.call(event) : event.key;
7667
+ } catch {
7668
+ return false;
7669
+ }
7649
7670
  const isEnterKey = originalKey === "Enter" || isEnterCode(event.code);
7650
7671
  const isOverlayActive = isActivated() || isHoldingKeys();
7651
7672
  const shouldBlockEnter = isEnterKey && isOverlayActive && !isInputMode() && !isToggleMode();
@@ -7811,7 +7832,8 @@ ${plainTextContentOnly}` : plainTextContentOnly;
7811
7832
  if (!isHoldingKeys()) {
7812
7833
  setIsHoldingKeys(true);
7813
7834
  }
7814
- const activationDuration = isKeyboardEventTriggeredByInput(event) ? options.keyHoldDuration + INPUT_FOCUS_ACTIVATION_DELAY_MS : options.keyHoldDuration;
7835
+ const keyHoldDuration = options.keyHoldDuration ?? DEFAULT_KEY_HOLD_DURATION_MS;
7836
+ const activationDuration = isKeyboardEventTriggeredByInput(event) ? keyHoldDuration + INPUT_FOCUS_ACTIVATION_DELAY_MS : keyHoldDuration;
7815
7837
  holdTimerId = window.setTimeout(() => {
7816
7838
  activateRenderer();
7817
7839
  }, activationDuration);
@@ -7833,10 +7855,10 @@ ${plainTextContentOnly}` : plainTextContentOnly;
7833
7855
  altKey
7834
7856
  } = options.activationKey;
7835
7857
  return {
7836
- metaKey: !!metaKey,
7837
- ctrlKey: !!ctrlKey,
7838
- shiftKey: !!shiftKey,
7839
- altKey: !!altKey
7858
+ metaKey: Boolean(metaKey),
7859
+ ctrlKey: Boolean(ctrlKey),
7860
+ shiftKey: Boolean(shiftKey),
7861
+ altKey: Boolean(altKey)
7840
7862
  };
7841
7863
  }
7842
7864
  return {
@@ -8314,6 +8336,12 @@ ${plainTextContentOnly}` : plainTextContentOnly;
8314
8336
  });
8315
8337
  }
8316
8338
  agentManager.tryResumeSessions();
8339
+ },
8340
+ updateOptions: (newOptions) => {
8341
+ options = {
8342
+ ...options,
8343
+ ...newOptions
8344
+ };
8317
8345
  }
8318
8346
  };
8319
8347
  });
@@ -1080,7 +1080,7 @@ var buildOpenFileUrl = (filePath, lineNumber) => {
1080
1080
  };
1081
1081
 
1082
1082
  // src/constants.ts
1083
- var VERSION = "0.0.73";
1083
+ var VERSION = "0.0.75";
1084
1084
  var VIEWPORT_MARGIN_PX = 8;
1085
1085
  var OFFSCREEN_POSITION = -1e3;
1086
1086
  var SELECTION_LERP_FACTOR = 0.95;
@@ -1089,6 +1089,7 @@ var COPIED_LABEL_DURATION_MS = 1500;
1089
1089
  var SELECTION_CURSOR_SETTLE_DELAY_MS = 500;
1090
1090
  var BLUR_DEACTIVATION_THRESHOLD_MS = 500;
1091
1091
  var INPUT_FOCUS_ACTIVATION_DELAY_MS = 150;
1092
+ var DEFAULT_KEY_HOLD_DURATION_MS = 200;
1092
1093
  var DRAG_THRESHOLD_PX = 2;
1093
1094
  var ELEMENT_DETECTION_THROTTLE_MS = 32;
1094
1095
  var BOUNDS_RECALC_INTERVAL_MS = 100;
@@ -3809,7 +3810,7 @@ var Crosshair = (props) => {
3809
3810
  var useSpeechRecognition = (options) => {
3810
3811
  let speechRecognition;
3811
3812
  const [isListening, setIsListening] = createSignal(false);
3812
- const isSupported = () => typeof window !== "undefined" && (!!window.SpeechRecognition || !!window.webkitSpeechRecognition);
3813
+ const isSupported = () => typeof window !== "undefined" && (Boolean(window.SpeechRecognition) || Boolean(window.webkitSpeechRecognition));
3813
3814
  const start = () => {
3814
3815
  if (!isSupported()) return;
3815
3816
  const SpeechRecognitionConstructor = window.SpeechRecognition || window.webkitSpeechRecognition;
@@ -4060,14 +4061,10 @@ var BottomSection = (props) => (() => {
4060
4061
  })();
4061
4062
  var DismissConfirmation = (props) => {
4062
4063
  const handleKeyDown = (event) => {
4063
- if (event.code === "Enter") {
4064
+ if (event.code === "Enter" || event.code === "Escape") {
4064
4065
  event.preventDefault();
4065
4066
  event.stopPropagation();
4066
4067
  props.onConfirm?.();
4067
- } else if (event.code === "Escape") {
4068
- event.preventDefault();
4069
- event.stopPropagation();
4070
- props.onCancel?.();
4071
4068
  }
4072
4069
  };
4073
4070
  onMount(() => {
@@ -4171,6 +4168,15 @@ var SelectionLabel = (props) => {
4171
4168
  resetIdleTimer();
4172
4169
  }
4173
4170
  });
4171
+ createEffect(() => {
4172
+ void props.tagName;
4173
+ void props.componentName;
4174
+ void props.statusText;
4175
+ void props.inputValue;
4176
+ void props.hasAgent;
4177
+ void props.isInputExpanded;
4178
+ requestAnimationFrame(measureContainer);
4179
+ });
4174
4180
  createEffect(() => {
4175
4181
  if (props.visible) {
4176
4182
  requestAnimationFrame(measureContainer);
@@ -4395,7 +4401,7 @@ var SelectionLabel = (props) => {
4395
4401
  onClick: handleSubmit,
4396
4402
  shrink: true,
4397
4403
  get hasParent() {
4398
- return !!props.componentName;
4404
+ return Boolean(props.componentName);
4399
4405
  },
4400
4406
  get hasAgent() {
4401
4407
  return props.hasAgent;
@@ -4482,7 +4488,7 @@ var SelectionLabel = (props) => {
4482
4488
  dimmed: true,
4483
4489
  shrink: true,
4484
4490
  get hasParent() {
4485
- return !!props.componentName;
4491
+ return Boolean(props.componentName);
4486
4492
  },
4487
4493
  get hasAgent() {
4488
4494
  return props.hasAgent;
@@ -6260,9 +6266,15 @@ var isTargetKeyCombination = (event, options) => {
6260
6266
  };
6261
6267
 
6262
6268
  // src/utils/is-event-from-overlay.ts
6263
- var isEventFromOverlay = (event, attribute) => event.composedPath().some(
6264
- (target) => target instanceof HTMLElement && target.hasAttribute(attribute)
6265
- );
6269
+ var isEventFromOverlay = (event, attribute) => {
6270
+ try {
6271
+ return event.composedPath().some(
6272
+ (target) => target instanceof HTMLElement && target.hasAttribute(attribute)
6273
+ );
6274
+ } catch {
6275
+ return false;
6276
+ }
6277
+ };
6266
6278
 
6267
6279
  // src/theme.ts
6268
6280
  var DEFAULT_THEME = {
@@ -6728,13 +6740,15 @@ var init = (rawOptions) => {
6728
6740
  },
6729
6741
  getTheme: () => initialTheme,
6730
6742
  setAgent: () => {
6743
+ },
6744
+ updateOptions: () => {
6731
6745
  }
6732
6746
  };
6733
6747
  }
6734
6748
  const scriptOptions = getScriptOptions();
6735
- const options = {
6749
+ let options = {
6736
6750
  enabled: true,
6737
- keyHoldDuration: 200,
6751
+ keyHoldDuration: DEFAULT_KEY_HOLD_DURATION_MS,
6738
6752
  allowActivationInsideInput: true,
6739
6753
  maxContextLines: 3,
6740
6754
  ...scriptOptions,
@@ -6765,13 +6779,15 @@ var init = (rawOptions) => {
6765
6779
  },
6766
6780
  getTheme: () => mergedTheme,
6767
6781
  setAgent: () => {
6782
+ },
6783
+ updateOptions: () => {
6768
6784
  }
6769
6785
  };
6770
6786
  }
6771
6787
  hasInited = true;
6772
6788
  const logIntro = () => {
6773
6789
  try {
6774
- const version = "0.0.73";
6790
+ const version = "0.0.75";
6775
6791
  const logoDataUri = `data:image/svg+xml;base64,${btoa(LOGO_SVG)}`;
6776
6792
  console.log(`%cReact Grab${version ? ` v${version}` : ""}%c
6777
6793
  https://react-grab.com`, `background: #330039; color: #ffffff; border: 1px solid #d75fcb; padding: 4px 4px 4px 24px; border-radius: 4px; background-image: url("${logoDataUri}"); background-size: 16px 16px; background-repeat: no-repeat; background-position: 4px center; display: inline-block; margin-bottom: 4px;`, "");
@@ -7025,9 +7041,6 @@ ${plainTextContentOnly}` : plainTextContentOnly;
7025
7041
  });
7026
7042
  }
7027
7043
  }
7028
- if (didCopy) {
7029
- options.onCopySuccess?.(elements, copiedContent);
7030
- }
7031
7044
  } catch (error) {
7032
7045
  options.onCopyError?.(error);
7033
7046
  const plainTextContentOnly = createCombinedTextContent(elements);
@@ -7041,6 +7054,9 @@ ${plainTextContentOnly}` : plainTextContentOnly;
7041
7054
  });
7042
7055
  }
7043
7056
  }
7057
+ if (didCopy) {
7058
+ options.onCopySuccess?.(elements, copiedContent);
7059
+ }
7044
7060
  options.onAfterCopy?.(elements, didCopy);
7045
7061
  return didCopy;
7046
7062
  };
@@ -7306,7 +7322,7 @@ ${plainTextContentOnly}` : plainTextContentOnly;
7306
7322
  }));
7307
7323
  const startProgressAnimation = (duration) => {
7308
7324
  const startTime = Date.now();
7309
- const animationDuration = options.keyHoldDuration;
7325
+ const animationDuration = options.keyHoldDuration ?? DEFAULT_KEY_HOLD_DURATION_MS;
7310
7326
  setProgressStartTime(startTime);
7311
7327
  const animateProgress = () => {
7312
7328
  const currentStartTime = progressStartTime();
@@ -7647,7 +7663,12 @@ ${plainTextContentOnly}` : plainTextContentOnly;
7647
7663
  });
7648
7664
  }
7649
7665
  const blockEnterIfNeeded = (event) => {
7650
- const originalKey = originalKeyDescriptor?.get ? originalKeyDescriptor.get.call(event) : event.key;
7666
+ let originalKey;
7667
+ try {
7668
+ originalKey = originalKeyDescriptor?.get ? originalKeyDescriptor.get.call(event) : event.key;
7669
+ } catch {
7670
+ return false;
7671
+ }
7651
7672
  const isEnterKey = originalKey === "Enter" || isEnterCode(event.code);
7652
7673
  const isOverlayActive = isActivated() || isHoldingKeys();
7653
7674
  const shouldBlockEnter = isEnterKey && isOverlayActive && !isInputMode() && !isToggleMode();
@@ -7813,7 +7834,8 @@ ${plainTextContentOnly}` : plainTextContentOnly;
7813
7834
  if (!isHoldingKeys()) {
7814
7835
  setIsHoldingKeys(true);
7815
7836
  }
7816
- const activationDuration = isKeyboardEventTriggeredByInput(event) ? options.keyHoldDuration + INPUT_FOCUS_ACTIVATION_DELAY_MS : options.keyHoldDuration;
7837
+ const keyHoldDuration = options.keyHoldDuration ?? DEFAULT_KEY_HOLD_DURATION_MS;
7838
+ const activationDuration = isKeyboardEventTriggeredByInput(event) ? keyHoldDuration + INPUT_FOCUS_ACTIVATION_DELAY_MS : keyHoldDuration;
7817
7839
  holdTimerId = window.setTimeout(() => {
7818
7840
  activateRenderer();
7819
7841
  }, activationDuration);
@@ -7835,10 +7857,10 @@ ${plainTextContentOnly}` : plainTextContentOnly;
7835
7857
  altKey
7836
7858
  } = options.activationKey;
7837
7859
  return {
7838
- metaKey: !!metaKey,
7839
- ctrlKey: !!ctrlKey,
7840
- shiftKey: !!shiftKey,
7841
- altKey: !!altKey
7860
+ metaKey: Boolean(metaKey),
7861
+ ctrlKey: Boolean(ctrlKey),
7862
+ shiftKey: Boolean(shiftKey),
7863
+ altKey: Boolean(altKey)
7842
7864
  };
7843
7865
  }
7844
7866
  return {
@@ -8316,6 +8338,12 @@ ${plainTextContentOnly}` : plainTextContentOnly;
8316
8338
  });
8317
8339
  }
8318
8340
  agentManager.tryResumeSessions();
8341
+ },
8342
+ updateOptions: (newOptions) => {
8343
+ options = {
8344
+ ...options,
8345
+ ...newOptions
8346
+ };
8319
8347
  }
8320
8348
  };
8321
8349
  });
@@ -168,6 +168,26 @@ interface Options {
168
168
  onOpenFile?: (filePath: string, lineNumber?: number) => void;
169
169
  agent?: AgentOptions;
170
170
  }
171
+ interface UpdatableOptions {
172
+ onActivate?: () => void;
173
+ onDeactivate?: () => void;
174
+ onElementHover?: (element: Element) => void;
175
+ onElementSelect?: (element: Element) => void;
176
+ onDragStart?: (startX: number, startY: number) => void;
177
+ onDragEnd?: (elements: Element[], bounds: DragRect) => void;
178
+ onBeforeCopy?: (elements: Element[]) => void | Promise<void>;
179
+ onAfterCopy?: (elements: Element[], success: boolean) => void;
180
+ onCopySuccess?: (elements: Element[], content: string) => void;
181
+ onCopyError?: (error: Error) => void;
182
+ onStateChange?: (state: ReactGrabState) => void;
183
+ onInputModeChange?: (isInputMode: boolean, context: InputModeContext) => void;
184
+ onSelectionBox?: (visible: boolean, bounds: OverlayBounds | null, element: Element | null) => void;
185
+ onDragBox?: (visible: boolean, bounds: OverlayBounds | null) => void;
186
+ onGrabbedBox?: (bounds: OverlayBounds, element: Element) => void;
187
+ onElementLabel?: (visible: boolean, variant: ElementLabelVariant, context: ElementLabelContext) => void;
188
+ onCrosshair?: (visible: boolean, context: CrosshairContext) => void;
189
+ onOpenFile?: (filePath: string, lineNumber?: number) => void;
190
+ }
171
191
  interface ReactGrabAPI {
172
192
  activate: () => void;
173
193
  deactivate: () => void;
@@ -179,6 +199,7 @@ interface ReactGrabAPI {
179
199
  updateTheme: (theme: DeepPartial<Theme>) => void;
180
200
  getTheme: () => Required<Theme>;
181
201
  setAgent: (options: AgentOptions) => void;
202
+ updateOptions: (options: UpdatableOptions) => void;
182
203
  }
183
204
  interface OverlayBounds {
184
205
  borderRadius: string;
@@ -279,4 +300,4 @@ declare const generateSnippet: (elements: Element[], options?: GenerateSnippetOp
279
300
 
280
301
  declare const init: (rawOptions?: Options) => ReactGrabAPI;
281
302
 
282
- 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, 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 ReactGrabRendererProps as o };
303
+ 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 ReactGrabRendererProps as o };
@@ -168,6 +168,26 @@ interface Options {
168
168
  onOpenFile?: (filePath: string, lineNumber?: number) => void;
169
169
  agent?: AgentOptions;
170
170
  }
171
+ interface UpdatableOptions {
172
+ onActivate?: () => void;
173
+ onDeactivate?: () => void;
174
+ onElementHover?: (element: Element) => void;
175
+ onElementSelect?: (element: Element) => void;
176
+ onDragStart?: (startX: number, startY: number) => void;
177
+ onDragEnd?: (elements: Element[], bounds: DragRect) => void;
178
+ onBeforeCopy?: (elements: Element[]) => void | Promise<void>;
179
+ onAfterCopy?: (elements: Element[], success: boolean) => void;
180
+ onCopySuccess?: (elements: Element[], content: string) => void;
181
+ onCopyError?: (error: Error) => void;
182
+ onStateChange?: (state: ReactGrabState) => void;
183
+ onInputModeChange?: (isInputMode: boolean, context: InputModeContext) => void;
184
+ onSelectionBox?: (visible: boolean, bounds: OverlayBounds | null, element: Element | null) => void;
185
+ onDragBox?: (visible: boolean, bounds: OverlayBounds | null) => void;
186
+ onGrabbedBox?: (bounds: OverlayBounds, element: Element) => void;
187
+ onElementLabel?: (visible: boolean, variant: ElementLabelVariant, context: ElementLabelContext) => void;
188
+ onCrosshair?: (visible: boolean, context: CrosshairContext) => void;
189
+ onOpenFile?: (filePath: string, lineNumber?: number) => void;
190
+ }
171
191
  interface ReactGrabAPI {
172
192
  activate: () => void;
173
193
  deactivate: () => void;
@@ -179,6 +199,7 @@ interface ReactGrabAPI {
179
199
  updateTheme: (theme: DeepPartial<Theme>) => void;
180
200
  getTheme: () => Required<Theme>;
181
201
  setAgent: (options: AgentOptions) => void;
202
+ updateOptions: (options: UpdatableOptions) => void;
182
203
  }
183
204
  interface OverlayBounds {
184
205
  borderRadius: string;
@@ -279,4 +300,4 @@ declare const generateSnippet: (elements: Element[], options?: GenerateSnippetOp
279
300
 
280
301
  declare const init: (rawOptions?: Options) => ReactGrabAPI;
281
302
 
282
- 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, 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 ReactGrabRendererProps as o };
303
+ 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 ReactGrabRendererProps as o };
package/dist/core.cjs CHANGED
@@ -1,30 +1,30 @@
1
1
  'use strict';
2
2
 
3
- var chunk6ZPKD3CA_cjs = require('./chunk-6ZPKD3CA.cjs');
3
+ var chunkT2UGKGNQ_cjs = require('./chunk-T2UGKGNQ.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "DEFAULT_THEME", {
8
8
  enumerable: true,
9
- get: function () { return chunk6ZPKD3CA_cjs.DEFAULT_THEME; }
9
+ get: function () { return chunkT2UGKGNQ_cjs.DEFAULT_THEME; }
10
10
  });
11
11
  Object.defineProperty(exports, "formatElementInfo", {
12
12
  enumerable: true,
13
- get: function () { return chunk6ZPKD3CA_cjs.getElementContext; }
13
+ get: function () { return chunkT2UGKGNQ_cjs.getElementContext; }
14
14
  });
15
15
  Object.defineProperty(exports, "generateSnippet", {
16
16
  enumerable: true,
17
- get: function () { return chunk6ZPKD3CA_cjs.generateSnippet; }
17
+ get: function () { return chunkT2UGKGNQ_cjs.generateSnippet; }
18
18
  });
19
19
  Object.defineProperty(exports, "getStack", {
20
20
  enumerable: true,
21
- get: function () { return chunk6ZPKD3CA_cjs.getStack; }
21
+ get: function () { return chunkT2UGKGNQ_cjs.getStack; }
22
22
  });
23
23
  Object.defineProperty(exports, "init", {
24
24
  enumerable: true,
25
- get: function () { return chunk6ZPKD3CA_cjs.init; }
25
+ get: function () { return chunkT2UGKGNQ_cjs.init; }
26
26
  });
27
27
  Object.defineProperty(exports, "isInstrumentationActive", {
28
28
  enumerable: true,
29
- get: function () { return chunk6ZPKD3CA_cjs.Ee; }
29
+ get: function () { return chunkT2UGKGNQ_cjs.Ee; }
30
30
  });
package/dist/core.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- export { 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, o as ReactGrabRendererProps, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './core-eQvDkDGv.cjs';
1
+ export { 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, o as ReactGrabRendererProps, U as UpdatableOptions, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './core-CzaOp9UL.cjs';
2
2
  export { isInstrumentationActive } from 'bippy';
3
3
  import 'bippy/source';
package/dist/core.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { 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, o as ReactGrabRendererProps, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './core-eQvDkDGv.js';
1
+ export { 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, o as ReactGrabRendererProps, U as UpdatableOptions, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './core-CzaOp9UL.js';
2
2
  export { isInstrumentationActive } from 'bippy';
3
3
  import 'bippy/source';
package/dist/core.js CHANGED
@@ -1 +1 @@
1
- export { DEFAULT_THEME, getElementContext as formatElementInfo, generateSnippet, getStack, init, Ee as isInstrumentationActive } from './chunk-KXX6WKZA.js';
1
+ export { DEFAULT_THEME, getElementContext as formatElementInfo, generateSnippet, getStack, init, Ee as isInstrumentationActive } from './chunk-BQIOOKBH.js';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk6ZPKD3CA_cjs = require('./chunk-6ZPKD3CA.cjs');
3
+ var chunkT2UGKGNQ_cjs = require('./chunk-T2UGKGNQ.cjs');
4
4
 
5
5
  /**
6
6
  * @license MIT
@@ -31,7 +31,7 @@ if (typeof window !== "undefined") {
31
31
  if (window.__REACT_GRAB__) {
32
32
  globalApi = window.__REACT_GRAB__;
33
33
  } else {
34
- globalApi = chunk6ZPKD3CA_cjs.init();
34
+ globalApi = chunkT2UGKGNQ_cjs.init();
35
35
  window.__REACT_GRAB__ = globalApi;
36
36
  window.dispatchEvent(
37
37
  new CustomEvent("react-grab:init", { detail: globalApi })
@@ -41,27 +41,27 @@ if (typeof window !== "undefined") {
41
41
 
42
42
  Object.defineProperty(exports, "DEFAULT_THEME", {
43
43
  enumerable: true,
44
- get: function () { return chunk6ZPKD3CA_cjs.DEFAULT_THEME; }
44
+ get: function () { return chunkT2UGKGNQ_cjs.DEFAULT_THEME; }
45
45
  });
46
46
  Object.defineProperty(exports, "formatElementInfo", {
47
47
  enumerable: true,
48
- get: function () { return chunk6ZPKD3CA_cjs.getElementContext; }
48
+ get: function () { return chunkT2UGKGNQ_cjs.getElementContext; }
49
49
  });
50
50
  Object.defineProperty(exports, "generateSnippet", {
51
51
  enumerable: true,
52
- get: function () { return chunk6ZPKD3CA_cjs.generateSnippet; }
52
+ get: function () { return chunkT2UGKGNQ_cjs.generateSnippet; }
53
53
  });
54
54
  Object.defineProperty(exports, "getStack", {
55
55
  enumerable: true,
56
- get: function () { return chunk6ZPKD3CA_cjs.getStack; }
56
+ get: function () { return chunkT2UGKGNQ_cjs.getStack; }
57
57
  });
58
58
  Object.defineProperty(exports, "init", {
59
59
  enumerable: true,
60
- get: function () { return chunk6ZPKD3CA_cjs.init; }
60
+ get: function () { return chunkT2UGKGNQ_cjs.init; }
61
61
  });
62
62
  Object.defineProperty(exports, "isInstrumentationActive", {
63
63
  enumerable: true,
64
- get: function () { return chunk6ZPKD3CA_cjs.Ee; }
64
+ get: function () { return chunkT2UGKGNQ_cjs.Ee; }
65
65
  });
66
66
  exports.getGlobalApi = getGlobalApi;
67
67
  exports.setGlobalApi = setGlobalApi;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as ReactGrabAPI } from './core-eQvDkDGv.cjs';
2
- export { 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, I as InputModeContext, O as Options, d as OverlayBounds, c as ReactGrabState, f as Rect, T as Theme, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './core-eQvDkDGv.cjs';
1
+ import { R as ReactGrabAPI } from './core-CzaOp9UL.cjs';
2
+ export { 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, I as InputModeContext, O as Options, d as OverlayBounds, 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 './core-CzaOp9UL.cjs';
3
3
  export { isInstrumentationActive } from 'bippy';
4
4
  import 'bippy/source';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as ReactGrabAPI } from './core-eQvDkDGv.js';
2
- export { 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, I as InputModeContext, O as Options, d as OverlayBounds, c as ReactGrabState, f as Rect, T as Theme, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './core-eQvDkDGv.js';
1
+ import { R as ReactGrabAPI } from './core-CzaOp9UL.js';
2
+ export { 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, I as InputModeContext, O as Options, d as OverlayBounds, 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 './core-CzaOp9UL.js';
3
3
  export { isInstrumentationActive } from 'bippy';
4
4
  import 'bippy/source';
5
5