@inspecto-dev/core 0.3.5 → 0.3.6
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/index.cjs
CHANGED
|
@@ -3119,7 +3119,7 @@ function createBadge(ctx) {
|
|
|
3119
3119
|
const state = asLauncherContext(ctx);
|
|
3120
3120
|
const btn = document.createElement("div");
|
|
3121
3121
|
btn.className = badgeClass;
|
|
3122
|
-
btn.style.
|
|
3122
|
+
btn.style.visibility = "hidden";
|
|
3123
3123
|
const indicator = document.createElement("span");
|
|
3124
3124
|
indicator.className = `${badgeClass}-indicator`;
|
|
3125
3125
|
indicator.dataset.inspectoLauncherIndicator = "true";
|
|
@@ -3204,14 +3204,85 @@ function createBadge(ctx) {
|
|
|
3204
3204
|
titleBlock.append(titleSpan, stateSpan);
|
|
3205
3205
|
content.append(indicator, titleBlock);
|
|
3206
3206
|
btn.append(content, eyes, panel);
|
|
3207
|
+
let isDragging = false;
|
|
3208
|
+
let dragStartX = 0;
|
|
3209
|
+
let dragStartY = 0;
|
|
3210
|
+
let initialBadgeX = 0;
|
|
3211
|
+
let initialBadgeY = 0;
|
|
3212
|
+
const handleDragStart = (e) => {
|
|
3213
|
+
const target = e.target;
|
|
3214
|
+
if (target.closest(`.${badgeClass}-panel`) || target.closest(`[data-inspecto-launcher-action]`)) {
|
|
3215
|
+
return;
|
|
3216
|
+
}
|
|
3217
|
+
if (e.type === "mousedown" && e.button !== 0) return;
|
|
3218
|
+
const clientX = e.type === "touchstart" ? e.touches[0].clientX : e.clientX;
|
|
3219
|
+
const clientY = e.type === "touchstart" ? e.touches[0].clientY : e.clientY;
|
|
3220
|
+
dragStartX = clientX;
|
|
3221
|
+
dragStartY = clientY;
|
|
3222
|
+
const rect = btn.getBoundingClientRect();
|
|
3223
|
+
initialBadgeX = rect.left;
|
|
3224
|
+
initialBadgeY = rect.top;
|
|
3225
|
+
isDragging = false;
|
|
3226
|
+
document.addEventListener("mousemove", handleDragMove, { passive: false });
|
|
3227
|
+
document.addEventListener("mouseup", handleDragEnd);
|
|
3228
|
+
document.addEventListener("touchmove", handleDragMove, { passive: false });
|
|
3229
|
+
document.addEventListener("touchend", handleDragEnd);
|
|
3230
|
+
};
|
|
3231
|
+
const handleDragMove = (e) => {
|
|
3232
|
+
const clientX = e.type === "touchmove" ? e.touches[0].clientX : e.clientX;
|
|
3233
|
+
const clientY = e.type === "touchmove" ? e.touches[0].clientY : e.clientY;
|
|
3234
|
+
const dx = clientX - dragStartX;
|
|
3235
|
+
const dy = clientY - dragStartY;
|
|
3236
|
+
if (!isDragging && Math.hypot(dx, dy) > 5) {
|
|
3237
|
+
isDragging = true;
|
|
3238
|
+
btn.style.transition = "none";
|
|
3239
|
+
}
|
|
3240
|
+
if (isDragging) {
|
|
3241
|
+
e.preventDefault();
|
|
3242
|
+
const maxX = window.innerWidth - btn.offsetWidth;
|
|
3243
|
+
const maxY = window.innerHeight - btn.offsetHeight;
|
|
3244
|
+
let newX = initialBadgeX + dx;
|
|
3245
|
+
let newY = initialBadgeY + dy;
|
|
3246
|
+
newX = Math.max(0, Math.min(newX, maxX));
|
|
3247
|
+
newY = Math.max(0, Math.min(newY, maxY));
|
|
3248
|
+
btn.style.bottom = "auto";
|
|
3249
|
+
btn.style.right = "auto";
|
|
3250
|
+
btn.style.left = `${newX}px`;
|
|
3251
|
+
btn.style.top = `${newY}px`;
|
|
3252
|
+
}
|
|
3253
|
+
};
|
|
3254
|
+
const handleDragEnd = () => {
|
|
3255
|
+
document.removeEventListener("mousemove", handleDragMove);
|
|
3256
|
+
document.removeEventListener("mouseup", handleDragEnd);
|
|
3257
|
+
document.removeEventListener("touchmove", handleDragMove);
|
|
3258
|
+
document.removeEventListener("touchend", handleDragEnd);
|
|
3259
|
+
if (isDragging) {
|
|
3260
|
+
btn.style.transition = "";
|
|
3261
|
+
setTimeout(() => {
|
|
3262
|
+
isDragging = false;
|
|
3263
|
+
}, 0);
|
|
3264
|
+
}
|
|
3265
|
+
};
|
|
3266
|
+
btn.addEventListener("mousedown", handleDragStart);
|
|
3267
|
+
btn.addEventListener("touchstart", handleDragStart, { passive: false });
|
|
3207
3268
|
btn.addEventListener("click", (event) => {
|
|
3208
3269
|
var _a2, _b;
|
|
3270
|
+
if (isDragging) {
|
|
3271
|
+
event.preventDefault();
|
|
3272
|
+
event.stopPropagation();
|
|
3273
|
+
return;
|
|
3274
|
+
}
|
|
3209
3275
|
if ((_b = (_a2 = event.target).closest) == null ? void 0 : _b.call(_a2, `[data-inspecto-launcher-action]`)) return;
|
|
3210
3276
|
state.launcherPanelOpen = !state.launcherPanelOpen;
|
|
3211
3277
|
state.updateBadgeContent();
|
|
3212
3278
|
});
|
|
3213
3279
|
state.shadowRootEl.appendChild(btn);
|
|
3214
3280
|
updateLauncherEye(state);
|
|
3281
|
+
requestAnimationFrame(() => {
|
|
3282
|
+
requestAnimationFrame(() => {
|
|
3283
|
+
btn.style.visibility = "";
|
|
3284
|
+
});
|
|
3285
|
+
});
|
|
3215
3286
|
return btn;
|
|
3216
3287
|
}
|
|
3217
3288
|
function setPaused(ctx, value) {
|
|
@@ -4105,6 +4176,14 @@ function showIntentMenu(shadowRoot, location, clickX, clickY, options, onClose,
|
|
|
4105
4176
|
menu.style.visibility = "visible";
|
|
4106
4177
|
setTimeout(() => input.focus(), 0);
|
|
4107
4178
|
const onDocClick = (e) => {
|
|
4179
|
+
const eventTarget = e.target;
|
|
4180
|
+
if (eventTarget) {
|
|
4181
|
+
if (eventTarget.closest(
|
|
4182
|
+
'[role="dialog"], [role="menu"], [role="tooltip"], [role="presentation"], [role="listbox"], [data-radix-popper-content-wrapper], [data-radix-focus-guard]'
|
|
4183
|
+
)) {
|
|
4184
|
+
return;
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4108
4187
|
const path = e.composedPath();
|
|
4109
4188
|
if (path.includes(menu)) return;
|
|
4110
4189
|
cleanup();
|
|
@@ -4967,6 +5046,14 @@ function handleMouseMove(ctx, event) {
|
|
|
4967
5046
|
state.lastPointerY = event.clientY;
|
|
4968
5047
|
state.updateLauncherEye();
|
|
4969
5048
|
if (state.cleanupMenu !== null) {
|
|
5049
|
+
const eventTarget = event.target;
|
|
5050
|
+
if (eventTarget) {
|
|
5051
|
+
if (eventTarget.closest(
|
|
5052
|
+
'[role="dialog"], [role="menu"], [role="tooltip"], [role="presentation"], [role="listbox"], [data-radix-popper-content-wrapper], [data-radix-focus-guard]'
|
|
5053
|
+
)) {
|
|
5054
|
+
return;
|
|
5055
|
+
}
|
|
5056
|
+
}
|
|
4970
5057
|
state.overlay.hide();
|
|
4971
5058
|
return;
|
|
4972
5059
|
}
|
|
@@ -4992,7 +5079,17 @@ function handleMouseMove(ctx, event) {
|
|
|
4992
5079
|
}
|
|
4993
5080
|
function handleTrigger(ctx, event) {
|
|
4994
5081
|
const state = asInteractionContext(ctx);
|
|
4995
|
-
if (state.cleanupMenu !== null)
|
|
5082
|
+
if (state.cleanupMenu !== null) {
|
|
5083
|
+
const eventTarget = event.target;
|
|
5084
|
+
if (eventTarget) {
|
|
5085
|
+
if (eventTarget.closest(
|
|
5086
|
+
'[role="dialog"], [role="menu"], [role="tooltip"], [role="presentation"], [role="listbox"], [data-radix-popper-content-wrapper], [data-radix-focus-guard]'
|
|
5087
|
+
)) {
|
|
5088
|
+
return;
|
|
5089
|
+
}
|
|
5090
|
+
}
|
|
5091
|
+
return;
|
|
5092
|
+
}
|
|
4996
5093
|
if (!state.isInspectorActive(event)) return;
|
|
4997
5094
|
const target = findInspectable(event.target);
|
|
4998
5095
|
if (!target) return;
|
|
@@ -6116,6 +6213,7 @@ function createOverlay(shadowRoot) {
|
|
|
6116
6213
|
overlay.style.display = "none";
|
|
6117
6214
|
const tooltip = document.createElement("div");
|
|
6118
6215
|
tooltip.className = tooltipClass;
|
|
6216
|
+
tooltip.style.display = "none";
|
|
6119
6217
|
const tagSpan = document.createElement("span");
|
|
6120
6218
|
tagSpan.className = tagClass;
|
|
6121
6219
|
const idSpan = document.createElement("span");
|