react-grab 0.1.18 → 0.1.20
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/dist/chunk-5NNTSQ2N.js +118 -0
- package/dist/chunk-DHDUZ7MT.cjs +118 -0
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.global.js +31 -31
- package/dist/index.js +1 -1
- package/dist/react.cjs +271 -93
- package/dist/react.js +271 -93
- package/package.json +1 -1
- package/dist/chunk-KEHU35AI.cjs +0 -118
- package/dist/chunk-TT33H3TZ.js +0 -118
package/dist/react.cjs
CHANGED
|
@@ -2148,11 +2148,11 @@ var init_store = __esm({
|
|
|
2148
2148
|
});
|
|
2149
2149
|
|
|
2150
2150
|
// src/constants.ts
|
|
2151
|
-
var VERSION, VIEWPORT_MARGIN_PX, OFFSCREEN_POSITION, SELECTION_LERP_FACTOR, FEEDBACK_DURATION_MS, FADE_DURATION_MS, FADE_COMPLETE_BUFFER_MS, DISMISS_ANIMATION_BUFFER_MS, KEYDOWN_SPAM_TIMEOUT_MS, BLUR_DEACTIVATION_THRESHOLD_MS, WINDOW_REFOCUS_GRACE_PERIOD_MS, INPUT_FOCUS_ACTIVATION_DELAY_MS, INPUT_TEXT_SELECTION_ACTIVATION_DELAY_MS, DEFERRED_EXECUTION_DELAY_MS, DEFAULT_KEY_HOLD_DURATION_MS, MIN_HOLD_FOR_ACTIVATION_AFTER_COPY_MS, RECENT_THRESHOLD_MS, FINDER_TIMEOUT_MS, SELECTOR_ATTR_VALUE_MAX_LENGTH_CHARS, ACTION_CYCLE_IDLE_TRIGGER_MS, DRAG_THRESHOLD_PX, ELEMENT_DETECTION_THROTTLE_MS, COMPONENT_NAME_DEBOUNCE_MS, DRAG_PREVIEW_DEBOUNCE_MS, BOUNDS_CACHE_TTL_MS, BOUNDS_RECALC_INTERVAL_MS, AUTO_SCROLL_EDGE_THRESHOLD_PX, AUTO_SCROLL_SPEED_PX, Z_INDEX_HOST, Z_INDEX_LABEL, Z_INDEX_OVERLAY_CANVAS, DRAG_LERP_FACTOR, LERP_CONVERGENCE_THRESHOLD_PX, FADE_OUT_BUFFER_MS, MIN_DEVICE_PIXEL_RATIO, GRAB_PURPLE_RGB, OVERLAY_CROSSHAIR_COLOR, OVERLAY_BORDER_COLOR_DRAG, OVERLAY_FILL_COLOR_DRAG, OVERLAY_BORDER_COLOR_DEFAULT, OVERLAY_FILL_COLOR_DEFAULT, FROZEN_GLOW_COLOR, FROZEN_GLOW_EDGE_PX, ARROW_HEIGHT_PX, ARROW_MIN_SIZE_PX, ARROW_MAX_LABEL_WIDTH_RATIO, ARROW_CENTER_PERCENT, ARROW_LABEL_MARGIN_PX, LABEL_GAP_PX, PREVIEW_TEXT_MAX_LENGTH, PREVIEW_ATTR_VALUE_MAX_LENGTH, PREVIEW_MAX_ATTRS, PREVIEW_PRIORITY_ATTRS, SYMBOLICATION_TIMEOUT_MS, MODIFIER_KEYS, ARROW_KEYS, FROZEN_ELEMENT_ATTRIBUTE, USER_IGNORE_ATTRIBUTE, VIEWPORT_COVERAGE_THRESHOLD, OVERLAY_Z_INDEX_THRESHOLD, DEV_TOOLS_OVERLAY_Z_INDEX_THRESHOLD, TOOLTIP_DELAY_MS, TOOLTIP_GRACE_PERIOD_MS, TOOLBAR_SNAP_MARGIN_PX, TOOLBAR_FADE_IN_DELAY_MS, TOOLBAR_SNAP_ANIMATION_DURATION_MS, TOOLBAR_DRAG_THRESHOLD_PX, TOOLBAR_VELOCITY_MULTIPLIER_MS, TOOLBAR_COLLAPSED_SHORT_PX, TOOLBAR_COLLAPSED_LONG_PX, TOOLBAR_COLLAPSE_ANIMATION_DURATION_MS, TOGGLE_ANIMATION_BUFFER_MS, TOOLBAR_DEFAULT_WIDTH_PX, TOOLBAR_DEFAULT_HEIGHT_PX, TOOLBAR_SHAKE_TOOLTIP_DURATION_MS, DRAG_SELECTION_COVERAGE_THRESHOLD, DRAG_SELECTION_SAMPLE_SPACING_PX, DRAG_SELECTION_MIN_SAMPLES_PER_AXIS, DRAG_SELECTION_MAX_SAMPLES_PER_AXIS, DRAG_SELECTION_MAX_TOTAL_SAMPLE_POINTS, DRAG_SELECTION_EDGE_INSET_PX, MAX_ARROW_NAVIGATION_HISTORY, MAX_MEMORY_SESSIONS, MAX_TRANSFORM_ANCESTOR_DEPTH, TRANSFORM_EARLY_BAIL_DEPTH, ELEMENT_POSITION_CACHE_DISTANCE_THRESHOLD_PX, ELEMENT_POSITION_THROTTLE_MS, VISIBILITY_CACHE_TTL_MS, ZOOM_DETECTION_THRESHOLD, MOUNT_ROOT_RECHECK_DELAY_MS, MAX_HISTORY_ITEMS, MAX_SESSION_STORAGE_SIZE_BYTES, DROPDOWN_ANIMATION_DURATION_MS, DROPDOWN_HOVER_OPEN_DELAY_MS, DROPDOWN_VIEWPORT_PADDING_PX, DROPDOWN_ANCHOR_GAP_PX, SAFE_POLYGON_BUFFER_PX, DROPDOWN_ICON_SIZE_PX, DROPDOWN_MIN_WIDTH_PX, DROPDOWN_MAX_WIDTH_PX, TOOLBAR_MENU_MIN_WIDTH_PX, PANEL_STYLES, DROPDOWN_OFFSCREEN_POSITION, DROPDOWN_EDGE_TRANSFORM_ORIGIN, LOGO_SVG, NEXTJS_REVALIDATION_DELAY_MS, IME_COMPOSING_KEY_CODE, SELECTION_LABEL_OFFSCREEN_PX, RELEVANT_CSS_PROPERTIES;
|
|
2151
|
+
var VERSION, VIEWPORT_MARGIN_PX, OFFSCREEN_POSITION, SELECTION_LERP_FACTOR, FEEDBACK_DURATION_MS, FADE_DURATION_MS, FADE_COMPLETE_BUFFER_MS, DISMISS_ANIMATION_BUFFER_MS, KEYDOWN_SPAM_TIMEOUT_MS, BLUR_DEACTIVATION_THRESHOLD_MS, WINDOW_REFOCUS_GRACE_PERIOD_MS, INPUT_FOCUS_ACTIVATION_DELAY_MS, INPUT_TEXT_SELECTION_ACTIVATION_DELAY_MS, DEFERRED_EXECUTION_DELAY_MS, DEFAULT_KEY_HOLD_DURATION_MS, MIN_HOLD_FOR_ACTIVATION_AFTER_COPY_MS, RECENT_THRESHOLD_MS, FINDER_TIMEOUT_MS, SELECTOR_ATTR_VALUE_MAX_LENGTH_CHARS, ACTION_CYCLE_IDLE_TRIGGER_MS, DRAG_THRESHOLD_PX, ELEMENT_DETECTION_THROTTLE_MS, PENDING_DETECTION_STALENESS_MS, COMPONENT_NAME_DEBOUNCE_MS, DRAG_PREVIEW_DEBOUNCE_MS, BOUNDS_CACHE_TTL_MS, BOUNDS_RECALC_INTERVAL_MS, AUTO_SCROLL_EDGE_THRESHOLD_PX, AUTO_SCROLL_SPEED_PX, Z_INDEX_HOST, Z_INDEX_LABEL, Z_INDEX_OVERLAY_CANVAS, DRAG_LERP_FACTOR, LERP_CONVERGENCE_THRESHOLD_PX, FADE_OUT_BUFFER_MS, MIN_DEVICE_PIXEL_RATIO, GRAB_PURPLE_RGB, OVERLAY_CROSSHAIR_COLOR, OVERLAY_BORDER_COLOR_DRAG, OVERLAY_FILL_COLOR_DRAG, OVERLAY_BORDER_COLOR_DEFAULT, OVERLAY_FILL_COLOR_DEFAULT, FROZEN_GLOW_COLOR, FROZEN_GLOW_EDGE_PX, ARROW_HEIGHT_PX, ARROW_MIN_SIZE_PX, ARROW_MAX_LABEL_WIDTH_RATIO, ARROW_CENTER_PERCENT, ARROW_LABEL_MARGIN_PX, LABEL_GAP_PX, PREVIEW_TEXT_MAX_LENGTH, PREVIEW_ATTR_VALUE_MAX_LENGTH, PREVIEW_MAX_ATTRS, PREVIEW_PRIORITY_ATTRS, SYMBOLICATION_TIMEOUT_MS, MODIFIER_KEYS, ARROW_KEYS, FROZEN_ELEMENT_ATTRIBUTE, USER_IGNORE_ATTRIBUTE, VIEWPORT_COVERAGE_THRESHOLD, OVERLAY_Z_INDEX_THRESHOLD, DEV_TOOLS_OVERLAY_Z_INDEX_THRESHOLD, TOOLTIP_DELAY_MS, TOOLTIP_GRACE_PERIOD_MS, TOOLBAR_SNAP_MARGIN_PX, TOOLBAR_FADE_IN_DELAY_MS, TOOLBAR_SNAP_ANIMATION_DURATION_MS, TOOLBAR_DRAG_THRESHOLD_PX, TOOLBAR_VELOCITY_MULTIPLIER_MS, TOOLBAR_COLLAPSED_SHORT_PX, TOOLBAR_COLLAPSED_LONG_PX, TOOLBAR_COLLAPSE_ANIMATION_DURATION_MS, TOGGLE_ANIMATION_BUFFER_MS, TOOLBAR_DEFAULT_WIDTH_PX, TOOLBAR_DEFAULT_HEIGHT_PX, TOOLBAR_SHAKE_TOOLTIP_DURATION_MS, DRAG_SELECTION_COVERAGE_THRESHOLD, DRAG_SELECTION_SAMPLE_SPACING_PX, DRAG_SELECTION_MIN_SAMPLES_PER_AXIS, DRAG_SELECTION_MAX_SAMPLES_PER_AXIS, DRAG_SELECTION_MAX_TOTAL_SAMPLE_POINTS, DRAG_SELECTION_EDGE_INSET_PX, MAX_ARROW_NAVIGATION_HISTORY, MAX_MEMORY_SESSIONS, MAX_TRANSFORM_ANCESTOR_DEPTH, TRANSFORM_EARLY_BAIL_DEPTH, ELEMENT_POSITION_CACHE_DISTANCE_THRESHOLD_PX, ELEMENT_POSITION_THROTTLE_MS, POINTER_EVENTS_RESUME_DEBOUNCE_MS, VISIBILITY_CACHE_TTL_MS, ZOOM_DETECTION_THRESHOLD, MOUNT_ROOT_RECHECK_DELAY_MS, MAX_HISTORY_ITEMS, MAX_SESSION_STORAGE_SIZE_BYTES, DROPDOWN_ANIMATION_DURATION_MS, DROPDOWN_HOVER_OPEN_DELAY_MS, DROPDOWN_VIEWPORT_PADDING_PX, DROPDOWN_ANCHOR_GAP_PX, SAFE_POLYGON_BUFFER_PX, DROPDOWN_ICON_SIZE_PX, DROPDOWN_MIN_WIDTH_PX, DROPDOWN_MAX_WIDTH_PX, TOOLBAR_MENU_MIN_WIDTH_PX, PANEL_STYLES, DROPDOWN_OFFSCREEN_POSITION, DROPDOWN_EDGE_TRANSFORM_ORIGIN, LOGO_SVG, NEXTJS_REVALIDATION_DELAY_MS, IME_COMPOSING_KEY_CODE, SELECTION_LABEL_OFFSCREEN_PX, RELEVANT_CSS_PROPERTIES;
|
|
2152
2152
|
var init_constants = __esm({
|
|
2153
2153
|
"src/constants.ts"() {
|
|
2154
2154
|
"use strict";
|
|
2155
|
-
VERSION = "0.1.
|
|
2155
|
+
VERSION = "0.1.20";
|
|
2156
2156
|
VIEWPORT_MARGIN_PX = 8;
|
|
2157
2157
|
OFFSCREEN_POSITION = -1e3;
|
|
2158
2158
|
SELECTION_LERP_FACTOR = 0.95;
|
|
@@ -2174,6 +2174,7 @@ var init_constants = __esm({
|
|
|
2174
2174
|
ACTION_CYCLE_IDLE_TRIGGER_MS = 600;
|
|
2175
2175
|
DRAG_THRESHOLD_PX = 2;
|
|
2176
2176
|
ELEMENT_DETECTION_THROTTLE_MS = 32;
|
|
2177
|
+
PENDING_DETECTION_STALENESS_MS = 200;
|
|
2177
2178
|
COMPONENT_NAME_DEBOUNCE_MS = 100;
|
|
2178
2179
|
DRAG_PREVIEW_DEBOUNCE_MS = 32;
|
|
2179
2180
|
BOUNDS_CACHE_TTL_MS = 16;
|
|
@@ -2257,6 +2258,7 @@ var init_constants = __esm({
|
|
|
2257
2258
|
TRANSFORM_EARLY_BAIL_DEPTH = 3;
|
|
2258
2259
|
ELEMENT_POSITION_CACHE_DISTANCE_THRESHOLD_PX = 2;
|
|
2259
2260
|
ELEMENT_POSITION_THROTTLE_MS = 16;
|
|
2261
|
+
POINTER_EVENTS_RESUME_DEBOUNCE_MS = 100;
|
|
2260
2262
|
VISIBILITY_CACHE_TTL_MS = 50;
|
|
2261
2263
|
ZOOM_DETECTION_THRESHOLD = 0.01;
|
|
2262
2264
|
MOUNT_ROOT_RECHECK_DELAY_MS = 1e3;
|
|
@@ -3174,6 +3176,29 @@ var init_mount_root = __esm({
|
|
|
3174
3176
|
}
|
|
3175
3177
|
});
|
|
3176
3178
|
|
|
3179
|
+
// src/utils/native-raf.ts
|
|
3180
|
+
var isClientSide, noopAnimationFrame, noopCancelFrame, nativeRequestAnimationFrame, nativeCancelAnimationFrame, waitUntilNextFrame;
|
|
3181
|
+
var init_native_raf = __esm({
|
|
3182
|
+
"src/utils/native-raf.ts"() {
|
|
3183
|
+
"use strict";
|
|
3184
|
+
isClientSide = typeof window !== "undefined";
|
|
3185
|
+
noopAnimationFrame = (_callback) => 0;
|
|
3186
|
+
noopCancelFrame = (_id) => {
|
|
3187
|
+
};
|
|
3188
|
+
nativeRequestAnimationFrame = isClientSide ? (Object.getOwnPropertyDescriptor(
|
|
3189
|
+
Window.prototype,
|
|
3190
|
+
"requestAnimationFrame"
|
|
3191
|
+
)?.value ?? window.requestAnimationFrame).bind(window) : noopAnimationFrame;
|
|
3192
|
+
nativeCancelAnimationFrame = isClientSide ? (Object.getOwnPropertyDescriptor(
|
|
3193
|
+
Window.prototype,
|
|
3194
|
+
"cancelAnimationFrame"
|
|
3195
|
+
)?.value ?? window.cancelAnimationFrame).bind(window) : noopCancelFrame;
|
|
3196
|
+
waitUntilNextFrame = () => isClientSide ? new Promise(
|
|
3197
|
+
(resolve) => nativeRequestAnimationFrame(() => resolve())
|
|
3198
|
+
) : Promise.resolve();
|
|
3199
|
+
}
|
|
3200
|
+
});
|
|
3201
|
+
|
|
3177
3202
|
// ../../node_modules/.pnpm/bippy@0.5.30_@types+react@19.2.11_react@19.2.3/node_modules/bippy/dist/source.js
|
|
3178
3203
|
var g3, _3, v2, y2, b2, x2, S2, ee2, C2, w2, te2, T2, ne2, E, re2, ie2, D, ae2, oe2, se2, O2, k2, A2, j2, M2, fe2, I2, L2, pe2, me2, R, z2, B2, he2, V2, H2, ge2, _e2, ve2, U2, W2, G2, K, q, ye2, J, Y, be2, X2, Z, xe2, Se2, Ce2, we2, Te2, Ee2, De2, Oe, Q, $2, je2, Me2, Ne2, Pe2;
|
|
3179
3204
|
var init_source = __esm({
|
|
@@ -4357,6 +4382,7 @@ var init_overlay_canvas = __esm({
|
|
|
4357
4382
|
init_solid();
|
|
4358
4383
|
init_lerp();
|
|
4359
4384
|
init_constants();
|
|
4385
|
+
init_native_raf();
|
|
4360
4386
|
_tmpl$ = /* @__PURE__ */ template(`<canvas data-react-grab-overlay-canvas style=position:fixed;top:0;left:0;pointer-events:none>`);
|
|
4361
4387
|
LAYER_STYLES = {
|
|
4362
4388
|
drag: {
|
|
@@ -4650,14 +4676,14 @@ var init_overlay_canvas = __esm({
|
|
|
4650
4676
|
}
|
|
4651
4677
|
compositeAllLayers();
|
|
4652
4678
|
if (shouldContinueAnimating) {
|
|
4653
|
-
animationFrameId =
|
|
4679
|
+
animationFrameId = nativeRequestAnimationFrame(runAnimationFrame);
|
|
4654
4680
|
} else {
|
|
4655
4681
|
animationFrameId = null;
|
|
4656
4682
|
}
|
|
4657
4683
|
};
|
|
4658
4684
|
const scheduleAnimationFrame = () => {
|
|
4659
4685
|
if (animationFrameId !== null) return;
|
|
4660
|
-
animationFrameId =
|
|
4686
|
+
animationFrameId = nativeRequestAnimationFrame(runAnimationFrame);
|
|
4661
4687
|
};
|
|
4662
4688
|
const handleWindowResize = () => {
|
|
4663
4689
|
initializeCanvas();
|
|
@@ -4817,7 +4843,7 @@ var init_overlay_canvas = __esm({
|
|
|
4817
4843
|
currentDprMediaQuery.removeEventListener("change", handleDevicePixelRatioChange);
|
|
4818
4844
|
}
|
|
4819
4845
|
if (animationFrameId !== null) {
|
|
4820
|
-
|
|
4846
|
+
nativeCancelAnimationFrame(animationFrameId);
|
|
4821
4847
|
}
|
|
4822
4848
|
});
|
|
4823
4849
|
});
|
|
@@ -8344,16 +8370,7 @@ var init_selection_label = __esm({
|
|
|
8344
8370
|
}
|
|
8345
8371
|
return false;
|
|
8346
8372
|
};
|
|
8347
|
-
|
|
8348
|
-
if (containerRef && !isTagCurrentlyHovered) {
|
|
8349
|
-
const rect = containerRef.getBoundingClientRect();
|
|
8350
|
-
setMeasuredWidth(rect.width);
|
|
8351
|
-
setMeasuredHeight(rect.height);
|
|
8352
|
-
}
|
|
8353
|
-
if (panelRef) {
|
|
8354
|
-
setPanelWidth(panelRef.getBoundingClientRect().width);
|
|
8355
|
-
}
|
|
8356
|
-
};
|
|
8373
|
+
let resizeObserver;
|
|
8357
8374
|
const handleTagHoverChange = (hovered) => {
|
|
8358
8375
|
isTagCurrentlyHovered = hovered;
|
|
8359
8376
|
};
|
|
@@ -8377,7 +8394,27 @@ var init_selection_label = __esm({
|
|
|
8377
8394
|
}
|
|
8378
8395
|
};
|
|
8379
8396
|
onMount(() => {
|
|
8380
|
-
|
|
8397
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
8398
|
+
for (const entry of entries) {
|
|
8399
|
+
const rect = entry.target.getBoundingClientRect();
|
|
8400
|
+
if (entry.target === containerRef && !isTagCurrentlyHovered) {
|
|
8401
|
+
setMeasuredWidth(rect.width);
|
|
8402
|
+
setMeasuredHeight(rect.height);
|
|
8403
|
+
} else if (entry.target === panelRef) {
|
|
8404
|
+
setPanelWidth(rect.width);
|
|
8405
|
+
}
|
|
8406
|
+
}
|
|
8407
|
+
});
|
|
8408
|
+
if (containerRef) {
|
|
8409
|
+
const rect = containerRef.getBoundingClientRect();
|
|
8410
|
+
setMeasuredWidth(rect.width);
|
|
8411
|
+
setMeasuredHeight(rect.height);
|
|
8412
|
+
resizeObserver.observe(containerRef);
|
|
8413
|
+
}
|
|
8414
|
+
if (panelRef) {
|
|
8415
|
+
setPanelWidth(panelRef.getBoundingClientRect().width);
|
|
8416
|
+
resizeObserver.observe(panelRef);
|
|
8417
|
+
}
|
|
8381
8418
|
window.addEventListener("scroll", handleViewportChange, true);
|
|
8382
8419
|
window.addEventListener("resize", handleViewportChange);
|
|
8383
8420
|
window.addEventListener("keydown", handleGlobalKeyDown, {
|
|
@@ -8385,6 +8422,7 @@ var init_selection_label = __esm({
|
|
|
8385
8422
|
});
|
|
8386
8423
|
});
|
|
8387
8424
|
onCleanup(() => {
|
|
8425
|
+
resizeObserver?.disconnect();
|
|
8388
8426
|
window.removeEventListener("scroll", handleViewportChange, true);
|
|
8389
8427
|
window.removeEventListener("resize", handleViewportChange);
|
|
8390
8428
|
window.removeEventListener("keydown", handleGlobalKeyDown, {
|
|
@@ -8398,11 +8436,6 @@ var init_selection_label = __esm({
|
|
|
8398
8436
|
lastValidPosition = null;
|
|
8399
8437
|
}
|
|
8400
8438
|
});
|
|
8401
|
-
const sizeAffectingSignature = createMemo(() => [props.tagName, props.componentName, props.elementsCount, props.statusText, props.inputValue, props.hasAgent, props.isPromptMode, props.isPendingDismiss, props.error, props.isPendingAbort, props.visible, props.status, props.actionCycleState?.items, props.actionCycleState?.activeIndex, props.actionCycleState?.isVisible]);
|
|
8402
|
-
createEffect(() => {
|
|
8403
|
-
void sizeAffectingSignature();
|
|
8404
|
-
queueMicrotask(measureContainer);
|
|
8405
|
-
});
|
|
8406
8439
|
createEffect(() => {
|
|
8407
8440
|
if (props.isPromptMode && inputRef && props.onSubmit) {
|
|
8408
8441
|
const focusTimeout = setTimeout(() => {
|
|
@@ -8605,9 +8638,6 @@ var init_selection_label = __esm({
|
|
|
8605
8638
|
get onFollowUpSubmit() {
|
|
8606
8639
|
return props.onFollowUpSubmit;
|
|
8607
8640
|
},
|
|
8608
|
-
onCopyStateChange: () => {
|
|
8609
|
-
queueMicrotask(measureContainer);
|
|
8610
|
-
},
|
|
8611
8641
|
onFadingChange: setIsInternalFading,
|
|
8612
8642
|
get onShowContextMenu() {
|
|
8613
8643
|
return props.onShowContextMenu;
|
|
@@ -9526,6 +9556,96 @@ var init_create_style_element = __esm({
|
|
|
9526
9556
|
}
|
|
9527
9557
|
});
|
|
9528
9558
|
|
|
9559
|
+
// src/utils/freeze-gsap.ts
|
|
9560
|
+
var isRafFrozen, pendingRafCallbacks, nextFakeRafId, knownAnimationCallbacks, nativeIdToHeldId, replayedFakeToNativeId, isAnimationLibraryCallback, freezeGsap, unfreezeGsap;
|
|
9561
|
+
var init_freeze_gsap = __esm({
|
|
9562
|
+
"src/utils/freeze-gsap.ts"() {
|
|
9563
|
+
"use strict";
|
|
9564
|
+
init_native_raf();
|
|
9565
|
+
isRafFrozen = false;
|
|
9566
|
+
pendingRafCallbacks = /* @__PURE__ */ new Map();
|
|
9567
|
+
nextFakeRafId = -1;
|
|
9568
|
+
knownAnimationCallbacks = /* @__PURE__ */ new WeakSet();
|
|
9569
|
+
nativeIdToHeldId = /* @__PURE__ */ new Map();
|
|
9570
|
+
replayedFakeToNativeId = /* @__PURE__ */ new Map();
|
|
9571
|
+
isAnimationLibraryCallback = (callback) => {
|
|
9572
|
+
if (knownAnimationCallbacks.has(callback)) return true;
|
|
9573
|
+
if (!isRafFrozen || !("gsapVersions" in window)) return false;
|
|
9574
|
+
const stack = new Error().stack ?? "";
|
|
9575
|
+
if (!stack.includes("_tick")) return false;
|
|
9576
|
+
knownAnimationCallbacks.add(callback);
|
|
9577
|
+
return true;
|
|
9578
|
+
};
|
|
9579
|
+
if (typeof window !== "undefined") {
|
|
9580
|
+
window.requestAnimationFrame = (callback) => {
|
|
9581
|
+
if (!isAnimationLibraryCallback(callback)) {
|
|
9582
|
+
return nativeRequestAnimationFrame(callback);
|
|
9583
|
+
}
|
|
9584
|
+
if (isRafFrozen) {
|
|
9585
|
+
const identifier = nextFakeRafId--;
|
|
9586
|
+
pendingRafCallbacks.set(identifier, callback);
|
|
9587
|
+
return identifier;
|
|
9588
|
+
}
|
|
9589
|
+
const nativeId = nativeRequestAnimationFrame(
|
|
9590
|
+
(timestamp) => {
|
|
9591
|
+
if (isRafFrozen) {
|
|
9592
|
+
const identifier = nextFakeRafId--;
|
|
9593
|
+
pendingRafCallbacks.set(identifier, callback);
|
|
9594
|
+
nativeIdToHeldId.set(nativeId, identifier);
|
|
9595
|
+
return;
|
|
9596
|
+
}
|
|
9597
|
+
callback(timestamp);
|
|
9598
|
+
}
|
|
9599
|
+
);
|
|
9600
|
+
return nativeId;
|
|
9601
|
+
};
|
|
9602
|
+
window.cancelAnimationFrame = (identifier) => {
|
|
9603
|
+
if (pendingRafCallbacks.has(identifier)) {
|
|
9604
|
+
pendingRafCallbacks.delete(identifier);
|
|
9605
|
+
return;
|
|
9606
|
+
}
|
|
9607
|
+
const replayed = replayedFakeToNativeId.get(identifier);
|
|
9608
|
+
if (replayed !== void 0) {
|
|
9609
|
+
nativeCancelAnimationFrame(replayed.nativeId);
|
|
9610
|
+
replayedFakeToNativeId.delete(identifier);
|
|
9611
|
+
return;
|
|
9612
|
+
}
|
|
9613
|
+
const heldId = nativeIdToHeldId.get(identifier);
|
|
9614
|
+
if (heldId !== void 0) {
|
|
9615
|
+
pendingRafCallbacks.delete(heldId);
|
|
9616
|
+
nativeIdToHeldId.delete(identifier);
|
|
9617
|
+
return;
|
|
9618
|
+
}
|
|
9619
|
+
nativeCancelAnimationFrame(identifier);
|
|
9620
|
+
};
|
|
9621
|
+
}
|
|
9622
|
+
freezeGsap = () => {
|
|
9623
|
+
if (isRafFrozen) return;
|
|
9624
|
+
isRafFrozen = true;
|
|
9625
|
+
pendingRafCallbacks.clear();
|
|
9626
|
+
nativeIdToHeldId.clear();
|
|
9627
|
+
for (const [fakeId, { nativeId, callback }] of replayedFakeToNativeId) {
|
|
9628
|
+
nativeCancelAnimationFrame(nativeId);
|
|
9629
|
+
pendingRafCallbacks.set(fakeId, callback);
|
|
9630
|
+
}
|
|
9631
|
+
replayedFakeToNativeId.clear();
|
|
9632
|
+
};
|
|
9633
|
+
unfreezeGsap = () => {
|
|
9634
|
+
if (!isRafFrozen) return;
|
|
9635
|
+
isRafFrozen = false;
|
|
9636
|
+
for (const [fakeId, callback] of pendingRafCallbacks.entries()) {
|
|
9637
|
+
const nativeId = nativeRequestAnimationFrame((timestamp) => {
|
|
9638
|
+
replayedFakeToNativeId.delete(fakeId);
|
|
9639
|
+
callback(timestamp);
|
|
9640
|
+
});
|
|
9641
|
+
replayedFakeToNativeId.set(fakeId, { nativeId, callback });
|
|
9642
|
+
}
|
|
9643
|
+
pendingRafCallbacks.clear();
|
|
9644
|
+
nativeIdToHeldId.clear();
|
|
9645
|
+
};
|
|
9646
|
+
}
|
|
9647
|
+
});
|
|
9648
|
+
|
|
9529
9649
|
// src/utils/freeze-animations.ts
|
|
9530
9650
|
var FROZEN_STYLES, GLOBAL_FREEZE_STYLES, styleElement, frozenElements, lastInputElements, globalAnimationStyleElement, ensureStylesInjected, areElementsSame, freezeAllAnimations, unfreezeAllAnimations, freezeAnimations, freezeGlobalAnimations, unfreezeGlobalAnimations;
|
|
9531
9651
|
var init_freeze_animations = __esm({
|
|
@@ -9533,6 +9653,7 @@ var init_freeze_animations = __esm({
|
|
|
9533
9653
|
"use strict";
|
|
9534
9654
|
init_constants();
|
|
9535
9655
|
init_create_style_element();
|
|
9656
|
+
init_freeze_gsap();
|
|
9536
9657
|
FROZEN_STYLES = `
|
|
9537
9658
|
[${FROZEN_ELEMENT_ATTRIBUTE}],
|
|
9538
9659
|
[${FROZEN_ELEMENT_ATTRIBUTE}] * {
|
|
@@ -9561,8 +9682,8 @@ var init_freeze_animations = __esm({
|
|
|
9561
9682
|
freezeAllAnimations = (elements) => {
|
|
9562
9683
|
if (elements.length === 0) return;
|
|
9563
9684
|
if (areElementsSame(elements, lastInputElements)) return;
|
|
9564
|
-
lastInputElements = [...elements];
|
|
9565
9685
|
unfreezeAllAnimations();
|
|
9686
|
+
lastInputElements = [...elements];
|
|
9566
9687
|
ensureStylesInjected();
|
|
9567
9688
|
frozenElements = elements;
|
|
9568
9689
|
for (const element of frozenElements) {
|
|
@@ -9592,6 +9713,7 @@ var init_freeze_animations = __esm({
|
|
|
9592
9713
|
"data-react-grab-global-freeze",
|
|
9593
9714
|
GLOBAL_FREEZE_STYLES
|
|
9594
9715
|
);
|
|
9716
|
+
freezeGsap();
|
|
9595
9717
|
};
|
|
9596
9718
|
unfreezeGlobalAnimations = () => {
|
|
9597
9719
|
if (!globalAnimationStyleElement) return;
|
|
@@ -9617,6 +9739,7 @@ var init_freeze_animations = __esm({
|
|
|
9617
9739
|
}
|
|
9618
9740
|
globalAnimationStyleElement.remove();
|
|
9619
9741
|
globalAnimationStyleElement = null;
|
|
9742
|
+
unfreezeGsap();
|
|
9620
9743
|
};
|
|
9621
9744
|
}
|
|
9622
9745
|
});
|
|
@@ -9701,37 +9824,62 @@ var init_is_valid_grabbable_element = __esm({
|
|
|
9701
9824
|
return cached.isVisible;
|
|
9702
9825
|
}
|
|
9703
9826
|
const computedStyle = window.getComputedStyle(element);
|
|
9704
|
-
|
|
9827
|
+
const isVisible = isElementVisible(element, computedStyle);
|
|
9828
|
+
if (!isVisible) {
|
|
9829
|
+
visibilityCache.set(element, { isVisible: false, timestamp: now });
|
|
9705
9830
|
return false;
|
|
9706
9831
|
}
|
|
9707
|
-
|
|
9708
|
-
|
|
9832
|
+
const couldBeOverlay = element.clientWidth / window.innerWidth >= VIEWPORT_COVERAGE_THRESHOLD && element.clientHeight / window.innerHeight >= VIEWPORT_COVERAGE_THRESHOLD;
|
|
9833
|
+
if (couldBeOverlay) {
|
|
9834
|
+
if (isDevToolsOverlay(computedStyle)) {
|
|
9835
|
+
return false;
|
|
9836
|
+
}
|
|
9837
|
+
if (isFullViewportOverlay(element, computedStyle)) {
|
|
9838
|
+
return false;
|
|
9839
|
+
}
|
|
9709
9840
|
}
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
return isVisible;
|
|
9841
|
+
visibilityCache.set(element, { isVisible: true, timestamp: now });
|
|
9842
|
+
return true;
|
|
9713
9843
|
};
|
|
9714
9844
|
}
|
|
9715
9845
|
});
|
|
9716
9846
|
|
|
9717
9847
|
// src/utils/get-element-at-position.ts
|
|
9718
|
-
var cache, isWithinThreshold, getElementsAtPoint, getElementAtPosition, clearElementPositionCache;
|
|
9848
|
+
var cache, resumeTimerId, scheduleResume, cancelScheduledResume, isWithinThreshold, getElementsAtPoint, getElementAtPosition, clearElementPositionCache;
|
|
9719
9849
|
var init_get_element_at_position = __esm({
|
|
9720
9850
|
"src/utils/get-element-at-position.ts"() {
|
|
9721
9851
|
"use strict";
|
|
9722
9852
|
init_is_valid_grabbable_element();
|
|
9723
9853
|
init_constants();
|
|
9724
9854
|
init_freeze_pseudo_states();
|
|
9855
|
+
init_create_element_bounds();
|
|
9725
9856
|
cache = null;
|
|
9857
|
+
resumeTimerId = null;
|
|
9858
|
+
scheduleResume = () => {
|
|
9859
|
+
if (resumeTimerId !== null) {
|
|
9860
|
+
clearTimeout(resumeTimerId);
|
|
9861
|
+
}
|
|
9862
|
+
resumeTimerId = setTimeout(() => {
|
|
9863
|
+
resumeTimerId = null;
|
|
9864
|
+
resumePointerEventsFreeze();
|
|
9865
|
+
}, POINTER_EVENTS_RESUME_DEBOUNCE_MS);
|
|
9866
|
+
};
|
|
9867
|
+
cancelScheduledResume = () => {
|
|
9868
|
+
if (resumeTimerId !== null) {
|
|
9869
|
+
clearTimeout(resumeTimerId);
|
|
9870
|
+
resumeTimerId = null;
|
|
9871
|
+
}
|
|
9872
|
+
};
|
|
9726
9873
|
isWithinThreshold = (x1, y1, x22, y22) => {
|
|
9727
9874
|
const deltaX = Math.abs(x1 - x22);
|
|
9728
9875
|
const deltaY = Math.abs(y1 - y22);
|
|
9729
9876
|
return deltaX <= ELEMENT_POSITION_CACHE_DISTANCE_THRESHOLD_PX && deltaY <= ELEMENT_POSITION_CACHE_DISTANCE_THRESHOLD_PX;
|
|
9730
9877
|
};
|
|
9731
9878
|
getElementsAtPoint = (clientX, clientY) => {
|
|
9879
|
+
cancelScheduledResume();
|
|
9732
9880
|
suspendPointerEventsFreeze();
|
|
9733
9881
|
const elements = document.elementsFromPoint(clientX, clientY);
|
|
9734
|
-
|
|
9882
|
+
scheduleResume();
|
|
9735
9883
|
return elements;
|
|
9736
9884
|
};
|
|
9737
9885
|
getElementAtPosition = (clientX, clientY) => {
|
|
@@ -9748,18 +9896,31 @@ var init_get_element_at_position = __esm({
|
|
|
9748
9896
|
return cache.element;
|
|
9749
9897
|
}
|
|
9750
9898
|
}
|
|
9751
|
-
|
|
9899
|
+
cancelScheduledResume();
|
|
9900
|
+
suspendPointerEventsFreeze();
|
|
9752
9901
|
let result = null;
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
|
|
9902
|
+
const topElement = document.elementFromPoint(clientX, clientY);
|
|
9903
|
+
if (topElement && isValidGrabbableElement(topElement)) {
|
|
9904
|
+
result = topElement;
|
|
9905
|
+
} else {
|
|
9906
|
+
const elementsAtPoint = document.elementsFromPoint(clientX, clientY);
|
|
9907
|
+
for (const candidateElement of elementsAtPoint) {
|
|
9908
|
+
if (candidateElement !== topElement && isValidGrabbableElement(candidateElement)) {
|
|
9909
|
+
result = candidateElement;
|
|
9910
|
+
break;
|
|
9911
|
+
}
|
|
9757
9912
|
}
|
|
9758
9913
|
}
|
|
9914
|
+
if (result) {
|
|
9915
|
+
createElementBounds(result);
|
|
9916
|
+
}
|
|
9917
|
+
scheduleResume();
|
|
9759
9918
|
cache = { clientX, clientY, element: result, timestamp: now };
|
|
9760
9919
|
return result;
|
|
9761
9920
|
};
|
|
9762
9921
|
clearElementPositionCache = () => {
|
|
9922
|
+
cancelScheduledResume();
|
|
9923
|
+
resumePointerEventsFreeze();
|
|
9763
9924
|
cache = null;
|
|
9764
9925
|
};
|
|
9765
9926
|
}
|
|
@@ -10046,6 +10207,7 @@ var init_toolbar = __esm({
|
|
|
10046
10207
|
init_freeze_pseudo_states();
|
|
10047
10208
|
init_tooltip();
|
|
10048
10209
|
init_toolbar_layout();
|
|
10210
|
+
init_native_raf();
|
|
10049
10211
|
_tmpl$27 = /* @__PURE__ */ template(`<span data-react-grab-unread-indicator class="absolute -top-0.5 -right-0.5 w-1.5 h-1.5 rounded-full bg-[#404040]">`);
|
|
10050
10212
|
_tmpl$28 = /* @__PURE__ */ template(`<div style=z-index:2147483647>Enable to continue`);
|
|
10051
10213
|
_tmpl$35 = /* @__PURE__ */ template(`<div data-react-grab-ignore-events data-react-grab-toolbar style=z-index:2147483647><div><div><div><div><div><div><button data-react-grab-ignore-events data-react-grab-toolbar-toggle></button></div></div><div><div><button data-react-grab-ignore-events data-react-grab-toolbar-history><span class="inline-flex relative"></span></button></div></div><div><div><button data-react-grab-ignore-events data-react-grab-toolbar-copy-all></button></div></div><div><div><button data-react-grab-ignore-events data-react-grab-toolbar-menu></button></div></div></div><div class="relative shrink-0 overflow-visible"><button data-react-grab-ignore-events data-react-grab-toolbar-enabled><div><div></div></div></button></div></div></div><button data-react-grab-ignore-events data-react-grab-toolbar-collapse class="contain-layout shrink-0 flex items-center justify-center cursor-pointer interactive-scale">`);
|
|
@@ -10255,8 +10417,8 @@ var init_toolbar = __esm({
|
|
|
10255
10417
|
const didPositionChange = clampedX !== currentPos.x || clampedY !== currentPos.y;
|
|
10256
10418
|
if (didPositionChange) {
|
|
10257
10419
|
setIsCollapseAnimating(true);
|
|
10258
|
-
|
|
10259
|
-
|
|
10420
|
+
nativeRequestAnimationFrame(() => {
|
|
10421
|
+
nativeRequestAnimationFrame(() => {
|
|
10260
10422
|
setPosition({
|
|
10261
10423
|
x: clampedX,
|
|
10262
10424
|
y: clampedY
|
|
@@ -10564,7 +10726,7 @@ var init_toolbar = __esm({
|
|
|
10564
10726
|
};
|
|
10565
10727
|
};
|
|
10566
10728
|
if (toggleAnimationRafId !== void 0) {
|
|
10567
|
-
|
|
10729
|
+
nativeCancelAnimationFrame(toggleAnimationRafId);
|
|
10568
10730
|
}
|
|
10569
10731
|
if (isRapidRetoggle()) {
|
|
10570
10732
|
const finalExpandDimension = isCurrentlyEnabled ? 0 : expandableDimension;
|
|
@@ -10582,14 +10744,14 @@ var init_toolbar = __esm({
|
|
|
10582
10744
|
const currentExpandDimension = isVerticalEdge ? expandableButtonsRef.getBoundingClientRect().height : expandableButtonsRef.getBoundingClientRect().width;
|
|
10583
10745
|
setPosition(computeClampedPosition(currentExpandDimension));
|
|
10584
10746
|
}
|
|
10585
|
-
toggleAnimationRafId =
|
|
10747
|
+
toggleAnimationRafId = nativeRequestAnimationFrame(syncPositionWithGrid);
|
|
10586
10748
|
};
|
|
10587
|
-
toggleAnimationRafId =
|
|
10749
|
+
toggleAnimationRafId = nativeRequestAnimationFrame(syncPositionWithGrid);
|
|
10588
10750
|
}
|
|
10589
10751
|
clearTimeout(toggleAnimationTimeout);
|
|
10590
10752
|
toggleAnimationTimeout = setTimeout(() => {
|
|
10591
10753
|
if (toggleAnimationRafId !== void 0) {
|
|
10592
|
-
|
|
10754
|
+
nativeCancelAnimationFrame(toggleAnimationRafId);
|
|
10593
10755
|
toggleAnimationRafId = void 0;
|
|
10594
10756
|
}
|
|
10595
10757
|
const finalExpandDimension = isCurrentlyEnabled ? 0 : expandableDimension;
|
|
@@ -10705,7 +10867,7 @@ var init_toolbar = __esm({
|
|
|
10705
10867
|
setSnapEdge(snap.edge);
|
|
10706
10868
|
setPositionRatio(ratio);
|
|
10707
10869
|
setIsSnapping(true);
|
|
10708
|
-
|
|
10870
|
+
nativeRequestAnimationFrame(() => {
|
|
10709
10871
|
const postRenderRect = containerRef?.getBoundingClientRect();
|
|
10710
10872
|
if (postRenderRect) {
|
|
10711
10873
|
expandedDimensions = {
|
|
@@ -10713,7 +10875,7 @@ var init_toolbar = __esm({
|
|
|
10713
10875
|
height: postRenderRect.height
|
|
10714
10876
|
};
|
|
10715
10877
|
}
|
|
10716
|
-
|
|
10878
|
+
nativeRequestAnimationFrame(() => {
|
|
10717
10879
|
const snappedPosition = getPositionFromEdgeAndRatio(snap.edge, ratio, expandedDimensions.width, expandedDimensions.height);
|
|
10718
10880
|
setPosition(snappedPosition);
|
|
10719
10881
|
saveAndNotify({
|
|
@@ -10939,7 +11101,7 @@ var init_toolbar = __esm({
|
|
|
10939
11101
|
clearTimeout(toggleAnimationTimeout);
|
|
10940
11102
|
clearTimeout(historyItemCountTimeout);
|
|
10941
11103
|
if (toggleAnimationRafId !== void 0) {
|
|
10942
|
-
|
|
11104
|
+
nativeCancelAnimationFrame(toggleAnimationRafId);
|
|
10943
11105
|
}
|
|
10944
11106
|
unfreezeUpdatesCallback?.();
|
|
10945
11107
|
safePolygonTracker.stop();
|
|
@@ -11318,6 +11480,7 @@ var init_toolbar_menu = __esm({
|
|
|
11318
11480
|
init_format_shortcut();
|
|
11319
11481
|
init_is_event_from_overlay();
|
|
11320
11482
|
init_resolve_action_enabled();
|
|
11483
|
+
init_native_raf();
|
|
11321
11484
|
_tmpl$29 = /* @__PURE__ */ template(`<div data-react-grab-ignore-events data-react-grab-toolbar-menu class="fixed font-sans text-[13px] antialiased filter-[drop-shadow(0px_1px_2px_#51515140)] select-none transition-[opacity,transform] duration-100 ease-out will-change-[opacity,transform]"style=z-index:2147483647><div><div class="flex flex-col py-1">`);
|
|
11322
11485
|
_tmpl$210 = /* @__PURE__ */ template(`<div><div>`);
|
|
11323
11486
|
_tmpl$36 = /* @__PURE__ */ template(`<button data-react-grab-ignore-events class="contain-layout flex items-center justify-between w-full px-2 py-1 cursor-pointer transition-colors hover:bg-black/5 text-left border-none bg-transparent disabled:opacity-40 disabled:cursor-default disabled:hover:bg-transparent"><span class="text-[13px] leading-4 font-sans font-medium text-black">`);
|
|
@@ -11344,14 +11507,14 @@ var init_toolbar_menu = __esm({
|
|
|
11344
11507
|
setLastAnchorEdge(anchor.edge);
|
|
11345
11508
|
clearTimeout(exitAnimationTimeout);
|
|
11346
11509
|
setShouldMount(true);
|
|
11347
|
-
if (enterAnimationFrameId !== void 0)
|
|
11348
|
-
enterAnimationFrameId =
|
|
11510
|
+
if (enterAnimationFrameId !== void 0) nativeCancelAnimationFrame(enterAnimationFrameId);
|
|
11511
|
+
enterAnimationFrameId = nativeRequestAnimationFrame(() => {
|
|
11349
11512
|
measureContainer();
|
|
11350
11513
|
void containerRef?.offsetHeight;
|
|
11351
11514
|
setIsAnimatedIn(true);
|
|
11352
11515
|
});
|
|
11353
11516
|
} else {
|
|
11354
|
-
if (enterAnimationFrameId !== void 0)
|
|
11517
|
+
if (enterAnimationFrameId !== void 0) nativeCancelAnimationFrame(enterAnimationFrameId);
|
|
11355
11518
|
setIsAnimatedIn(false);
|
|
11356
11519
|
exitAnimationTimeout = setTimeout(() => {
|
|
11357
11520
|
setShouldMount(false);
|
|
@@ -11419,7 +11582,7 @@ var init_toolbar_menu = __esm({
|
|
|
11419
11582
|
props.onDismiss();
|
|
11420
11583
|
}
|
|
11421
11584
|
};
|
|
11422
|
-
const frameId =
|
|
11585
|
+
const frameId = nativeRequestAnimationFrame(() => {
|
|
11423
11586
|
window.addEventListener("mousedown", handleClickOutside, {
|
|
11424
11587
|
capture: true
|
|
11425
11588
|
});
|
|
@@ -11431,9 +11594,9 @@ var init_toolbar_menu = __esm({
|
|
|
11431
11594
|
capture: true
|
|
11432
11595
|
});
|
|
11433
11596
|
onCleanup(() => {
|
|
11434
|
-
|
|
11597
|
+
nativeCancelAnimationFrame(frameId);
|
|
11435
11598
|
clearTimeout(exitAnimationTimeout);
|
|
11436
|
-
if (enterAnimationFrameId !== void 0)
|
|
11599
|
+
if (enterAnimationFrameId !== void 0) nativeCancelAnimationFrame(enterAnimationFrameId);
|
|
11437
11600
|
window.removeEventListener("mousedown", handleClickOutside, {
|
|
11438
11601
|
capture: true
|
|
11439
11602
|
});
|
|
@@ -11566,6 +11729,7 @@ var init_context_menu = __esm({
|
|
|
11566
11729
|
init_get_tag_display();
|
|
11567
11730
|
init_resolve_action_enabled();
|
|
11568
11731
|
init_is_event_from_overlay();
|
|
11732
|
+
init_native_raf();
|
|
11569
11733
|
_tmpl$30 = /* @__PURE__ */ template(`<div class="flex flex-col w-[calc(100%+16px)] -mx-2 -my-1.5">`);
|
|
11570
11734
|
_tmpl$211 = /* @__PURE__ */ template(`<div data-react-grab-ignore-events data-react-grab-context-menu class="fixed font-sans text-[13px] antialiased filter-[drop-shadow(0px_1px_2px_#51515140)] select-none"style=z-index:2147483647;pointer-events:auto><div><div class="contain-layout shrink-0 flex items-center gap-1 pt-1.5 pb-1 w-fit h-fit px-2">`);
|
|
11571
11735
|
_tmpl$37 = /* @__PURE__ */ template(`<span class="text-[11px] font-sans text-black/50 ml-4">`);
|
|
@@ -11588,7 +11752,7 @@ var init_context_menu = __esm({
|
|
|
11588
11752
|
};
|
|
11589
11753
|
createEffect(() => {
|
|
11590
11754
|
if (isVisible()) {
|
|
11591
|
-
|
|
11755
|
+
nativeRequestAnimationFrame(measureContainer);
|
|
11592
11756
|
}
|
|
11593
11757
|
});
|
|
11594
11758
|
const computedPosition = () => {
|
|
@@ -11697,7 +11861,7 @@ var init_context_menu = __esm({
|
|
|
11697
11861
|
runActionIfAllowed(modifierAction);
|
|
11698
11862
|
}
|
|
11699
11863
|
};
|
|
11700
|
-
const frameId =
|
|
11864
|
+
const frameId = nativeRequestAnimationFrame(() => {
|
|
11701
11865
|
window.addEventListener("mousedown", handleClickOutside, {
|
|
11702
11866
|
capture: true
|
|
11703
11867
|
});
|
|
@@ -11709,7 +11873,7 @@ var init_context_menu = __esm({
|
|
|
11709
11873
|
capture: true
|
|
11710
11874
|
});
|
|
11711
11875
|
onCleanup(() => {
|
|
11712
|
-
|
|
11876
|
+
nativeCancelAnimationFrame(frameId);
|
|
11713
11877
|
window.removeEventListener("mousedown", handleClickOutside, {
|
|
11714
11878
|
capture: true
|
|
11715
11879
|
});
|
|
@@ -11873,6 +12037,7 @@ var init_history_dropdown = __esm({
|
|
|
11873
12037
|
init_icon_copy();
|
|
11874
12038
|
init_icon_check();
|
|
11875
12039
|
init_tooltip();
|
|
12040
|
+
init_native_raf();
|
|
11876
12041
|
_tmpl$38 = /* @__PURE__ */ template(`<div class="flex items-center gap-[5px]"><div class=relative><button data-react-grab-ignore-events data-react-grab-history-clear class="contain-layout shrink-0 flex items-center justify-center px-[3px] py-px rounded-sm bg-[#FEF2F2] cursor-pointer transition-all hover:bg-[#FEE2E2] press-scale h-[17px] text-[#B91C1C]"></button></div><div class=relative><button data-react-grab-ignore-events data-react-grab-history-copy-all class="contain-layout shrink-0 flex items-center justify-center gap-1 px-[3px] py-px rounded-sm bg-white [border-width:0.5px] border-solid border-[#B3B3B3] cursor-pointer transition-all hover:bg-[#F5F5F5] press-scale h-[17px] text-black/60">`);
|
|
11877
12042
|
_tmpl$212 = /* @__PURE__ */ template(`<div data-react-grab-ignore-events data-react-grab-history-dropdown class="fixed font-sans text-[13px] antialiased filter-[drop-shadow(0px_1px_2px_#51515140)] select-none transition-[opacity,transform] duration-100 ease-out will-change-[opacity,transform]"style=z-index:2147483647><div><div class="contain-layout shrink-0 flex items-center justify-between px-2 pt-1.5 pb-1"><span class="text-[11px] font-medium text-black/40">History</span></div><div class="min-h-0 [border-top-width:0.5px] border-t-solid border-t-[#D9D9D9] px-2 py-1.5"><div class="flex flex-col max-h-[240px] overflow-y-auto -mx-2 -my-1.5"style="scrollbar-color:rgba(0,0,0,0.15) transparent">`);
|
|
11878
12043
|
_tmpl$39 = /* @__PURE__ */ template(`<span class="text-[11px] leading-3 font-sans text-black/40 truncate mt-0.5">`);
|
|
@@ -11933,14 +12098,14 @@ var init_history_dropdown = __esm({
|
|
|
11933
12098
|
if (props.position) setLastAnchorEdge(props.position.edge);
|
|
11934
12099
|
clearTimeout(exitAnimationTimeout);
|
|
11935
12100
|
setShouldMount(true);
|
|
11936
|
-
if (enterAnimationFrameId !== void 0)
|
|
11937
|
-
enterAnimationFrameId =
|
|
12101
|
+
if (enterAnimationFrameId !== void 0) nativeCancelAnimationFrame(enterAnimationFrameId);
|
|
12102
|
+
enterAnimationFrameId = nativeRequestAnimationFrame(() => {
|
|
11938
12103
|
measureContainer();
|
|
11939
12104
|
void containerRef?.offsetHeight;
|
|
11940
12105
|
setIsAnimatedIn(true);
|
|
11941
12106
|
});
|
|
11942
12107
|
} else {
|
|
11943
|
-
if (enterAnimationFrameId !== void 0)
|
|
12108
|
+
if (enterAnimationFrameId !== void 0) nativeCancelAnimationFrame(enterAnimationFrameId);
|
|
11944
12109
|
setIsAnimatedIn(false);
|
|
11945
12110
|
exitAnimationTimeout = setTimeout(() => {
|
|
11946
12111
|
setShouldMount(false);
|
|
@@ -12011,7 +12176,7 @@ var init_history_dropdown = __esm({
|
|
|
12011
12176
|
clearTimeout(copyAllFeedbackTimeout);
|
|
12012
12177
|
clearTimeout(copyItemFeedbackTimeout);
|
|
12013
12178
|
clearTimeout(exitAnimationTimeout);
|
|
12014
|
-
if (enterAnimationFrameId !== void 0)
|
|
12179
|
+
if (enterAnimationFrameId !== void 0) nativeCancelAnimationFrame(enterAnimationFrameId);
|
|
12015
12180
|
window.removeEventListener("keydown", handleKeyDown, {
|
|
12016
12181
|
capture: true
|
|
12017
12182
|
});
|
|
@@ -12256,6 +12421,7 @@ var init_clear_history_prompt = __esm({
|
|
|
12256
12421
|
init_is_event_from_overlay();
|
|
12257
12422
|
init_is_keyboard_event_triggered_by_input();
|
|
12258
12423
|
init_discard_prompt();
|
|
12424
|
+
init_native_raf();
|
|
12259
12425
|
_tmpl$40 = /* @__PURE__ */ template(`<div data-react-grab-ignore-events data-react-grab-clear-history-prompt class="fixed font-sans text-[13px] antialiased filter-[drop-shadow(0px_1px_2px_#51515140)] select-none transition-[opacity,transform] duration-100 ease-out will-change-[opacity,transform]"style=z-index:2147483647><div>`);
|
|
12260
12426
|
ClearHistoryPrompt = (props) => {
|
|
12261
12427
|
let containerRef;
|
|
@@ -12278,14 +12444,14 @@ var init_clear_history_prompt = __esm({
|
|
|
12278
12444
|
setLastAnchorEdge(anchor.edge);
|
|
12279
12445
|
clearTimeout(exitAnimationTimeout);
|
|
12280
12446
|
setShouldMount(true);
|
|
12281
|
-
if (enterAnimationFrameId !== void 0)
|
|
12282
|
-
enterAnimationFrameId =
|
|
12447
|
+
if (enterAnimationFrameId !== void 0) nativeCancelAnimationFrame(enterAnimationFrameId);
|
|
12448
|
+
enterAnimationFrameId = nativeRequestAnimationFrame(() => {
|
|
12283
12449
|
measureContainer();
|
|
12284
12450
|
void containerRef?.offsetHeight;
|
|
12285
12451
|
setIsAnimatedIn(true);
|
|
12286
12452
|
});
|
|
12287
12453
|
} else {
|
|
12288
|
-
if (enterAnimationFrameId !== void 0)
|
|
12454
|
+
if (enterAnimationFrameId !== void 0) nativeCancelAnimationFrame(enterAnimationFrameId);
|
|
12289
12455
|
setIsAnimatedIn(false);
|
|
12290
12456
|
exitAnimationTimeout = setTimeout(() => {
|
|
12291
12457
|
setShouldMount(false);
|
|
@@ -12354,7 +12520,7 @@ var init_clear_history_prompt = __esm({
|
|
|
12354
12520
|
if (!props.position || isEventFromOverlay(event, "data-react-grab-ignore-events")) return;
|
|
12355
12521
|
props.onCancel();
|
|
12356
12522
|
};
|
|
12357
|
-
const frameId =
|
|
12523
|
+
const frameId = nativeRequestAnimationFrame(() => {
|
|
12358
12524
|
window.addEventListener("mousedown", handleClickOutside, {
|
|
12359
12525
|
capture: true
|
|
12360
12526
|
});
|
|
@@ -12363,9 +12529,9 @@ var init_clear_history_prompt = __esm({
|
|
|
12363
12529
|
});
|
|
12364
12530
|
});
|
|
12365
12531
|
onCleanup(() => {
|
|
12366
|
-
|
|
12532
|
+
nativeCancelAnimationFrame(frameId);
|
|
12367
12533
|
clearTimeout(exitAnimationTimeout);
|
|
12368
|
-
if (enterAnimationFrameId !== void 0)
|
|
12534
|
+
if (enterAnimationFrameId !== void 0) nativeCancelAnimationFrame(enterAnimationFrameId);
|
|
12369
12535
|
window.removeEventListener("keydown", handleKeyDown, {
|
|
12370
12536
|
capture: true
|
|
12371
12537
|
});
|
|
@@ -14835,6 +15001,7 @@ var init_auto_scroll = __esm({
|
|
|
14835
15001
|
"src/core/auto-scroll.ts"() {
|
|
14836
15002
|
"use strict";
|
|
14837
15003
|
init_constants();
|
|
15004
|
+
init_native_raf();
|
|
14838
15005
|
getAutoScrollDirection = (clientX, clientY) => {
|
|
14839
15006
|
return {
|
|
14840
15007
|
top: clientY < AUTO_SCROLL_EDGE_THRESHOLD_PX,
|
|
@@ -14857,7 +15024,7 @@ var init_auto_scroll = __esm({
|
|
|
14857
15024
|
if (direction.left) window.scrollBy(-AUTO_SCROLL_SPEED_PX, 0);
|
|
14858
15025
|
if (direction.right) window.scrollBy(AUTO_SCROLL_SPEED_PX, 0);
|
|
14859
15026
|
if (direction.top || direction.bottom || direction.left || direction.right) {
|
|
14860
|
-
animationId =
|
|
15027
|
+
animationId = nativeRequestAnimationFrame(scroll);
|
|
14861
15028
|
} else {
|
|
14862
15029
|
animationId = null;
|
|
14863
15030
|
}
|
|
@@ -14867,7 +15034,7 @@ var init_auto_scroll = __esm({
|
|
|
14867
15034
|
};
|
|
14868
15035
|
const stop2 = () => {
|
|
14869
15036
|
if (animationId !== null) {
|
|
14870
|
-
|
|
15037
|
+
nativeCancelAnimationFrame(animationId);
|
|
14871
15038
|
animationId = null;
|
|
14872
15039
|
}
|
|
14873
15040
|
};
|
|
@@ -14902,7 +15069,7 @@ var init_log_intro = __esm({
|
|
|
14902
15069
|
init_is_extension_context();
|
|
14903
15070
|
logIntro = () => {
|
|
14904
15071
|
try {
|
|
14905
|
-
const version = "0.1.
|
|
15072
|
+
const version = "0.1.20";
|
|
14906
15073
|
const logoDataUri = `data:image/svg+xml;base64,${btoa(LOGO_SVG)}`;
|
|
14907
15074
|
console.log(
|
|
14908
15075
|
`%cReact Grab${version ? ` v${version}` : ""}%c
|
|
@@ -15258,16 +15425,16 @@ ${cssBlock}`;
|
|
|
15258
15425
|
}
|
|
15259
15426
|
});
|
|
15260
15427
|
|
|
15261
|
-
// src/core/plugins/copy-
|
|
15262
|
-
var
|
|
15263
|
-
var
|
|
15264
|
-
"src/core/plugins/copy-
|
|
15428
|
+
// src/core/plugins/copy-styles.ts
|
|
15429
|
+
var copyStylesPlugin;
|
|
15430
|
+
var init_copy_styles = __esm({
|
|
15431
|
+
"src/core/plugins/copy-styles.ts"() {
|
|
15265
15432
|
"use strict";
|
|
15266
15433
|
init_append_stack_context();
|
|
15267
15434
|
init_copy_content();
|
|
15268
15435
|
init_extract_element_css();
|
|
15269
|
-
|
|
15270
|
-
name: "copy-
|
|
15436
|
+
copyStylesPlugin = {
|
|
15437
|
+
name: "copy-styles",
|
|
15271
15438
|
setup: (api) => {
|
|
15272
15439
|
let isPendingSelection = false;
|
|
15273
15440
|
return {
|
|
@@ -15291,8 +15458,8 @@ var init_copy_css = __esm({
|
|
|
15291
15458
|
},
|
|
15292
15459
|
actions: [
|
|
15293
15460
|
{
|
|
15294
|
-
id: "copy-
|
|
15295
|
-
label: "Copy
|
|
15461
|
+
id: "copy-styles",
|
|
15462
|
+
label: "Copy styles",
|
|
15296
15463
|
onAction: async (context) => {
|
|
15297
15464
|
await context.performWithFeedback(async () => {
|
|
15298
15465
|
const combinedCss = context.elements.map(extractElementCss).join("\n\n");
|
|
@@ -15308,8 +15475,8 @@ var init_copy_css = __esm({
|
|
|
15308
15475
|
}
|
|
15309
15476
|
},
|
|
15310
15477
|
{
|
|
15311
|
-
id: "copy-
|
|
15312
|
-
label: "Copy
|
|
15478
|
+
id: "copy-styles-toolbar",
|
|
15479
|
+
label: "Copy styles",
|
|
15313
15480
|
target: "toolbar",
|
|
15314
15481
|
onAction: () => {
|
|
15315
15482
|
isPendingSelection = true;
|
|
@@ -15414,6 +15581,7 @@ var init_core = __esm({
|
|
|
15414
15581
|
init_store2();
|
|
15415
15582
|
init_is_keyboard_event_triggered_by_input();
|
|
15416
15583
|
init_mount_root();
|
|
15584
|
+
init_native_raf();
|
|
15417
15585
|
init_renderer();
|
|
15418
15586
|
init_context();
|
|
15419
15587
|
init_source();
|
|
@@ -15455,7 +15623,7 @@ var init_core = __esm({
|
|
|
15455
15623
|
init_comment();
|
|
15456
15624
|
init_open();
|
|
15457
15625
|
init_copy_html();
|
|
15458
|
-
|
|
15626
|
+
init_copy_styles();
|
|
15459
15627
|
init_freeze_animations();
|
|
15460
15628
|
init_freeze_pseudo_states();
|
|
15461
15629
|
init_freeze_updates();
|
|
@@ -15467,7 +15635,7 @@ var init_core = __esm({
|
|
|
15467
15635
|
init_theme();
|
|
15468
15636
|
init_generate_snippet();
|
|
15469
15637
|
init_copy_content();
|
|
15470
|
-
builtInPlugins = [copyPlugin, commentPlugin, copyHtmlPlugin,
|
|
15638
|
+
builtInPlugins = [copyPlugin, commentPlugin, copyHtmlPlugin, copyStylesPlugin, openPlugin];
|
|
15471
15639
|
hasInited = false;
|
|
15472
15640
|
toolbarStateChangeCallbacks = /* @__PURE__ */ new Set();
|
|
15473
15641
|
init = (rawOptions) => {
|
|
@@ -15671,6 +15839,9 @@ var init_core = __esm({
|
|
|
15671
15839
|
return createElementBounds(element);
|
|
15672
15840
|
};
|
|
15673
15841
|
let lastElementDetectionTime = 0;
|
|
15842
|
+
let pendingDetectionScheduledAt = 0;
|
|
15843
|
+
let latestDetectionX = 0;
|
|
15844
|
+
let latestDetectionY = 0;
|
|
15674
15845
|
let dragPreviewDebounceTimerId = null;
|
|
15675
15846
|
const [debouncedDragPointer, setDebouncedDragPointer] = createSignal(null);
|
|
15676
15847
|
const scheduleDragPreviewUpdate = (clientX, clientY) => {
|
|
@@ -15969,7 +16140,7 @@ var init_core = __esm({
|
|
|
15969
16140
|
showTemporaryGrabbedBox(createElementBounds(element), element);
|
|
15970
16141
|
}
|
|
15971
16142
|
}
|
|
15972
|
-
await
|
|
16143
|
+
await waitUntilNextFrame();
|
|
15973
16144
|
if (unhandledElements.length > 0) {
|
|
15974
16145
|
await copyWithFallback(unhandledElements, extraPrompt, resolvedComponentName2);
|
|
15975
16146
|
} else if (pendingResults.length > 0) {
|
|
@@ -16590,12 +16761,19 @@ var init_core = __esm({
|
|
|
16590
16761
|
x: clientX,
|
|
16591
16762
|
y: clientY
|
|
16592
16763
|
});
|
|
16764
|
+
latestDetectionX = clientX;
|
|
16765
|
+
latestDetectionY = clientY;
|
|
16593
16766
|
const now = performance.now();
|
|
16594
|
-
|
|
16767
|
+
const isDetectionPending = pendingDetectionScheduledAt > 0 && now - pendingDetectionScheduledAt < PENDING_DETECTION_STALENESS_MS;
|
|
16768
|
+
if (now - lastElementDetectionTime >= ELEMENT_DETECTION_THROTTLE_MS && !isDetectionPending) {
|
|
16595
16769
|
lastElementDetectionTime = now;
|
|
16770
|
+
pendingDetectionScheduledAt = now;
|
|
16596
16771
|
onIdle(() => {
|
|
16597
|
-
const candidate = getElementAtPosition(
|
|
16598
|
-
|
|
16772
|
+
const candidate = getElementAtPosition(latestDetectionX, latestDetectionY);
|
|
16773
|
+
if (candidate !== store.detectedElement) {
|
|
16774
|
+
actions.setDetectedElement(candidate);
|
|
16775
|
+
}
|
|
16776
|
+
pendingDetectionScheduledAt = 0;
|
|
16599
16777
|
});
|
|
16600
16778
|
}
|
|
16601
16779
|
if (isDragging()) {
|
|
@@ -17367,7 +17545,7 @@ var init_core = __esm({
|
|
|
17367
17545
|
if (shouldRunInterval && boundsRecalcIntervalId === null) {
|
|
17368
17546
|
boundsRecalcIntervalId = window.setInterval(() => {
|
|
17369
17547
|
if (viewportChangeFrameId !== null) return;
|
|
17370
|
-
viewportChangeFrameId =
|
|
17548
|
+
viewportChangeFrameId = nativeRequestAnimationFrame(() => {
|
|
17371
17549
|
viewportChangeFrameId = null;
|
|
17372
17550
|
actions.incrementViewportVersion();
|
|
17373
17551
|
actions.updateSessionBounds();
|
|
@@ -17377,7 +17555,7 @@ var init_core = __esm({
|
|
|
17377
17555
|
window.clearInterval(boundsRecalcIntervalId);
|
|
17378
17556
|
boundsRecalcIntervalId = null;
|
|
17379
17557
|
if (viewportChangeFrameId !== null) {
|
|
17380
|
-
|
|
17558
|
+
nativeCancelAnimationFrame(viewportChangeFrameId);
|
|
17381
17559
|
viewportChangeFrameId = null;
|
|
17382
17560
|
}
|
|
17383
17561
|
}
|
|
@@ -17396,7 +17574,7 @@ var init_core = __esm({
|
|
|
17396
17574
|
window.clearInterval(boundsRecalcIntervalId);
|
|
17397
17575
|
}
|
|
17398
17576
|
if (viewportChangeFrameId !== null) {
|
|
17399
|
-
|
|
17577
|
+
nativeCancelAnimationFrame(viewportChangeFrameId);
|
|
17400
17578
|
}
|
|
17401
17579
|
});
|
|
17402
17580
|
eventListenerManager.addDocumentListener("copy", (event) => {
|
|
@@ -17420,7 +17598,7 @@ var init_core = __esm({
|
|
|
17420
17598
|
window.clearTimeout(actionCycleIdleTimeoutId);
|
|
17421
17599
|
}
|
|
17422
17600
|
if (dropdownTrackingFrameId !== null) {
|
|
17423
|
-
|
|
17601
|
+
nativeCancelAnimationFrame(dropdownTrackingFrameId);
|
|
17424
17602
|
}
|
|
17425
17603
|
grabbedBoxTimeouts.forEach((timeoutId) => window.clearTimeout(timeoutId));
|
|
17426
17604
|
grabbedBoxTimeouts.clear();
|
|
@@ -17777,7 +17955,7 @@ var init_core = __esm({
|
|
|
17777
17955
|
};
|
|
17778
17956
|
const stopTrackingDropdownPosition = () => {
|
|
17779
17957
|
if (dropdownTrackingFrameId !== null) {
|
|
17780
|
-
|
|
17958
|
+
nativeCancelAnimationFrame(dropdownTrackingFrameId);
|
|
17781
17959
|
dropdownTrackingFrameId = null;
|
|
17782
17960
|
}
|
|
17783
17961
|
};
|
|
@@ -17785,7 +17963,7 @@ var init_core = __esm({
|
|
|
17785
17963
|
stopTrackingDropdownPosition();
|
|
17786
17964
|
const updatePosition = () => {
|
|
17787
17965
|
computePosition();
|
|
17788
|
-
dropdownTrackingFrameId =
|
|
17966
|
+
dropdownTrackingFrameId = nativeRequestAnimationFrame(updatePosition);
|
|
17789
17967
|
};
|
|
17790
17968
|
updatePosition();
|
|
17791
17969
|
};
|
|
@@ -17913,7 +18091,7 @@ var init_core = __esm({
|
|
|
17913
18091
|
const element = getFirstConnectedHistoryElement(item);
|
|
17914
18092
|
if (!element) return;
|
|
17915
18093
|
actions.clearLabelInstances();
|
|
17916
|
-
|
|
18094
|
+
nativeRequestAnimationFrame(() => {
|
|
17917
18095
|
if (!isElementConnected(element)) return;
|
|
17918
18096
|
const bounds = createElementBounds(element);
|
|
17919
18097
|
const instanceId = createLabelInstance(bounds, item.tagName, item.componentName, "copied", {
|
|
@@ -17970,7 +18148,7 @@ var init_core = __esm({
|
|
|
17970
18148
|
});
|
|
17971
18149
|
showClearPrompt();
|
|
17972
18150
|
actions.clearLabelInstances();
|
|
17973
|
-
|
|
18151
|
+
nativeRequestAnimationFrame(() => {
|
|
17974
18152
|
batch(() => {
|
|
17975
18153
|
for (const historyItem of currentHistoryItems) {
|
|
17976
18154
|
const connectedElements = getConnectedHistoryElements(historyItem);
|