@githumbi/grabby 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/angular/index.d.ts +22 -1
- package/dist/angular/index.js +608 -63
- package/dist/angular/index.js.map +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/core/index.cjs +723 -178
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +608 -63
- package/dist/core/index.js.map +1 -1
- package/dist/export/index.cjs +19 -1
- package/dist/export/index.cjs.map +1 -1
- package/dist/export/index.d.cts +23 -2
- package/dist/export/index.d.ts +23 -2
- package/dist/export/index.js +19 -1
- package/dist/export/index.js.map +1 -1
- package/dist/grabby.global.js +177 -137
- package/dist/live/index.d.cts +1 -1
- package/dist/live/index.d.ts +1 -1
- package/dist/react/index.d.ts +22 -1
- package/dist/react/index.js +608 -63
- package/dist/react/index.js.map +1 -1
- package/dist/{types-BQDEG-Gl.d.cts → types-DOAcZ0U6.d.cts} +23 -2
- package/dist/{types-BQDEG-Gl.d.ts → types-DOAcZ0U6.d.ts} +23 -2
- package/package.json +1 -1
package/dist/core/index.cjs
CHANGED
|
@@ -507,6 +507,20 @@ function describeTarget(target) {
|
|
|
507
507
|
const name = facts.label || facts.heading || facts.text || facts.alt || "";
|
|
508
508
|
return quoted(noun, name);
|
|
509
509
|
}
|
|
510
|
+
var GROUP_NAMED = 3;
|
|
511
|
+
function describeGroup(labels) {
|
|
512
|
+
const named = labels.slice(0, GROUP_NAMED).join(", ");
|
|
513
|
+
const more = labels.length > GROUP_NAMED ? ` and ${labels.length - GROUP_NAMED} more` : "";
|
|
514
|
+
return `${labels.length} elements: ${named}${more}`;
|
|
515
|
+
}
|
|
516
|
+
function describeArea(around) {
|
|
517
|
+
return `Area in ${around}`;
|
|
518
|
+
}
|
|
519
|
+
function describeComment(c) {
|
|
520
|
+
if (_optionalChain([c, 'access', _13 => _13.members, 'optionalAccess', _14 => _14.length])) return describeGroup(c.members.map((m) => m.label));
|
|
521
|
+
if (c.area) return describeArea(describeTarget(c.target));
|
|
522
|
+
return describeTarget(c.target);
|
|
523
|
+
}
|
|
510
524
|
|
|
511
525
|
// src/core/overlay/overlay-renderer.ts
|
|
512
526
|
var OVERLAY_ID = "__grabby-overlay__";
|
|
@@ -661,8 +675,8 @@ function createOverlayRenderer(options = {}) {
|
|
|
661
675
|
currentComponentName = null;
|
|
662
676
|
currentSourcePath = null;
|
|
663
677
|
currentCssClasses = [];
|
|
664
|
-
_optionalChain([overlay, 'optionalAccess',
|
|
665
|
-
_optionalChain([label, 'optionalAccess',
|
|
678
|
+
_optionalChain([overlay, 'optionalAccess', _15 => _15.remove, 'call', _16 => _16()]);
|
|
679
|
+
_optionalChain([label, 'optionalAccess', _17 => _17.remove, 'call', _18 => _18()]);
|
|
666
680
|
removeStyles(STYLE_ID);
|
|
667
681
|
overlay = null;
|
|
668
682
|
label = null;
|
|
@@ -759,8 +773,8 @@ function createCrosshair() {
|
|
|
759
773
|
dispose() {
|
|
760
774
|
this.hold(false);
|
|
761
775
|
this.deactivate();
|
|
762
|
-
_optionalChain([hLine, 'optionalAccess',
|
|
763
|
-
_optionalChain([vLine, 'optionalAccess',
|
|
776
|
+
_optionalChain([hLine, 'optionalAccess', _19 => _19.remove, 'call', _20 => _20()]);
|
|
777
|
+
_optionalChain([vLine, 'optionalAccess', _21 => _21.remove, 'call', _22 => _22()]);
|
|
764
778
|
removeStyles(CROSSHAIR_STYLE_ID);
|
|
765
779
|
removeStyles(CURSOR_STYLE_ID);
|
|
766
780
|
hLine = null;
|
|
@@ -977,7 +991,7 @@ function injectToastStyles() {
|
|
|
977
991
|
}
|
|
978
992
|
var toastEl = null;
|
|
979
993
|
function getOrCreateToast() {
|
|
980
|
-
if (_optionalChain([toastEl, 'optionalAccess',
|
|
994
|
+
if (_optionalChain([toastEl, 'optionalAccess', _23 => _23.isConnected])) return toastEl;
|
|
981
995
|
injectToastStyles();
|
|
982
996
|
toastEl = h("div", { id: TOAST_ID, role: "status", "aria-live": "polite" });
|
|
983
997
|
getUiRoot().appendChild(toastEl);
|
|
@@ -1000,7 +1014,7 @@ function row(label, value) {
|
|
|
1000
1014
|
function showToast(message, opts = {}) {
|
|
1001
1015
|
const toast = getOrCreateToast();
|
|
1002
1016
|
const { detail, actions } = opts;
|
|
1003
|
-
const durationMs = _nullishCoalesce(opts.duration, () => ( (_optionalChain([actions, 'optionalAccess',
|
|
1017
|
+
const durationMs = _nullishCoalesce(opts.duration, () => ( (_optionalChain([actions, 'optionalAccess', _24 => _24.length]) ? 8e3 : 3500)));
|
|
1004
1018
|
const children = [
|
|
1005
1019
|
h(
|
|
1006
1020
|
"div",
|
|
@@ -1025,7 +1039,7 @@ function showToast(message, opts = {}) {
|
|
|
1025
1039
|
}
|
|
1026
1040
|
children.push(details);
|
|
1027
1041
|
}
|
|
1028
|
-
if (_optionalChain([actions, 'optionalAccess',
|
|
1042
|
+
if (_optionalChain([actions, 'optionalAccess', _25 => _25.length])) {
|
|
1029
1043
|
children[0].appendChild(h(
|
|
1030
1044
|
"span",
|
|
1031
1045
|
{ class: "grabby-toast-actions" },
|
|
@@ -1058,14 +1072,14 @@ function hideToast() {
|
|
|
1058
1072
|
clearTimeout(activeTimer);
|
|
1059
1073
|
activeTimer = null;
|
|
1060
1074
|
}
|
|
1061
|
-
_optionalChain([toastEl, 'optionalAccess',
|
|
1075
|
+
_optionalChain([toastEl, 'optionalAccess', _26 => _26.classList, 'access', _27 => _27.remove, 'call', _28 => _28("grabby-toast-visible")]);
|
|
1062
1076
|
}
|
|
1063
1077
|
function disposeToast() {
|
|
1064
1078
|
if (activeTimer) {
|
|
1065
1079
|
clearTimeout(activeTimer);
|
|
1066
1080
|
activeTimer = null;
|
|
1067
1081
|
}
|
|
1068
|
-
_optionalChain([toastEl, 'optionalAccess',
|
|
1082
|
+
_optionalChain([toastEl, 'optionalAccess', _29 => _29.remove, 'call', _30 => _30()]);
|
|
1069
1083
|
toastEl = null;
|
|
1070
1084
|
removeStyles(TOAST_STYLE_ID);
|
|
1071
1085
|
}
|
|
@@ -1157,22 +1171,125 @@ function buildUniqueSelector(el) {
|
|
|
1157
1171
|
return steps.join(" > ");
|
|
1158
1172
|
}
|
|
1159
1173
|
|
|
1174
|
+
// src/core/picker/region.ts
|
|
1175
|
+
var MAX_MEMBERS = 20;
|
|
1176
|
+
var INSIDE_RATIO = 0.85;
|
|
1177
|
+
var MIN_SIDE = 4;
|
|
1178
|
+
var MAX_VISITS = 4e3;
|
|
1179
|
+
var SKIP_TAGS = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "TEMPLATE", "NOSCRIPT", "HEAD", "META", "LINK", "BR", "WBR"]);
|
|
1180
|
+
function boxFromPoints(a, b) {
|
|
1181
|
+
return { left: Math.min(a.x, b.x), top: Math.min(a.y, b.y), right: Math.max(a.x, b.x), bottom: Math.max(a.y, b.y) };
|
|
1182
|
+
}
|
|
1183
|
+
function overlapArea(r, box) {
|
|
1184
|
+
const w = Math.min(r.right, box.right) - Math.max(r.left, box.left);
|
|
1185
|
+
const h2 = Math.min(r.bottom, box.bottom) - Math.max(r.top, box.top);
|
|
1186
|
+
return w > 0 && h2 > 0 ? w * h2 : 0;
|
|
1187
|
+
}
|
|
1188
|
+
function contains(r, box) {
|
|
1189
|
+
return r.left <= box.left && r.top <= box.top && r.right >= box.right && r.bottom >= box.bottom;
|
|
1190
|
+
}
|
|
1191
|
+
function isHidden(el) {
|
|
1192
|
+
const style = getComputedStyle(el);
|
|
1193
|
+
return style.visibility === "hidden" || style.opacity === "0";
|
|
1194
|
+
}
|
|
1195
|
+
function elementsInBox(box, isUiNode2, root2 = document.body) {
|
|
1196
|
+
const found = [];
|
|
1197
|
+
let visits = 0;
|
|
1198
|
+
const visit = (el) => {
|
|
1199
|
+
if (found.length >= MAX_MEMBERS || ++visits > MAX_VISITS) return;
|
|
1200
|
+
if (SKIP_TAGS.has(el.tagName) || isUiNode2(el) || el.hasAttribute(IGNORE_ATTR)) return;
|
|
1201
|
+
const r = el.getBoundingClientRect();
|
|
1202
|
+
const boxless = r.width === 0 && r.height === 0;
|
|
1203
|
+
if (!boxless && overlapArea(r, box) === 0) return;
|
|
1204
|
+
if (!boxless && r.width >= MIN_SIDE && r.height >= MIN_SIDE) {
|
|
1205
|
+
const inside = overlapArea(r, box) / (r.width * r.height);
|
|
1206
|
+
if (inside >= INSIDE_RATIO && detectKind(el) !== "section" && !isHidden(el)) {
|
|
1207
|
+
found.push(el);
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
for (const child of Array.from(el.children)) visit(child);
|
|
1212
|
+
};
|
|
1213
|
+
for (const child of Array.from(root2.children)) visit(child);
|
|
1214
|
+
return found;
|
|
1215
|
+
}
|
|
1216
|
+
function commonContainer(elements) {
|
|
1217
|
+
if (elements.length === 0) return document.body;
|
|
1218
|
+
let candidate = _nullishCoalesce(elements[0].parentElement, () => ( document.body));
|
|
1219
|
+
while (candidate && !elements.every((el) => candidate.contains(el))) candidate = candidate.parentElement;
|
|
1220
|
+
return _nullishCoalesce(candidate, () => ( document.body));
|
|
1221
|
+
}
|
|
1222
|
+
function containerForBox(box, isUiNode2) {
|
|
1223
|
+
const cx = (box.left + box.right) / 2;
|
|
1224
|
+
const cy = (box.top + box.bottom) / 2;
|
|
1225
|
+
const stack = typeof document.elementsFromPoint === "function" ? document.elementsFromPoint(cx, cy) : [];
|
|
1226
|
+
for (const el of stack) {
|
|
1227
|
+
if (isUiNode2(el) || el.closest(`[${IGNORE_ATTR}]`)) continue;
|
|
1228
|
+
for (let cur = el; cur; cur = cur.parentElement) {
|
|
1229
|
+
if (contains(cur.getBoundingClientRect(), box)) return cur;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
return document.body;
|
|
1233
|
+
}
|
|
1234
|
+
var frac = (v) => Math.round(Math.min(1, Math.max(0, v)) * 1e3) / 1e3;
|
|
1235
|
+
function areaWithin(el, box) {
|
|
1236
|
+
const r = el.getBoundingClientRect();
|
|
1237
|
+
const w = r.width || 1;
|
|
1238
|
+
const h2 = r.height || 1;
|
|
1239
|
+
return {
|
|
1240
|
+
x: frac((box.left - r.left) / w),
|
|
1241
|
+
y: frac((box.top - r.top) / h2),
|
|
1242
|
+
w: frac((box.right - box.left) / w),
|
|
1243
|
+
h: frac((box.bottom - box.top) / h2)
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
function areaToBox(el, area) {
|
|
1247
|
+
const r = el.getBoundingClientRect();
|
|
1248
|
+
return {
|
|
1249
|
+
left: r.left + area.x * r.width,
|
|
1250
|
+
top: r.top + area.y * r.height,
|
|
1251
|
+
right: r.left + (area.x + area.w) * r.width,
|
|
1252
|
+
bottom: r.top + (area.y + area.h) * r.height
|
|
1253
|
+
};
|
|
1254
|
+
}
|
|
1255
|
+
function unionBox(elements) {
|
|
1256
|
+
let out = null;
|
|
1257
|
+
for (const el of elements) {
|
|
1258
|
+
const r = el.getBoundingClientRect();
|
|
1259
|
+
if (r.width === 0 && r.height === 0) continue;
|
|
1260
|
+
out = out ? { left: Math.min(out.left, r.left), top: Math.min(out.top, r.top), right: Math.max(out.right, r.right), bottom: Math.max(out.bottom, r.bottom) } : { left: r.left, top: r.top, right: r.right, bottom: r.bottom };
|
|
1261
|
+
}
|
|
1262
|
+
return out;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1160
1265
|
// src/core/picker/element-picker.ts
|
|
1266
|
+
var DRAG_PX = 6;
|
|
1267
|
+
var IS_MAC = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
|
|
1268
|
+
var PRESS_EVENTS = ["pointerdown", "mousedown", "pointerup", "mouseup", "touchstart"];
|
|
1269
|
+
function addKey(e) {
|
|
1270
|
+
return IS_MAC ? e.metaKey : e.ctrlKey;
|
|
1271
|
+
}
|
|
1161
1272
|
function createElementPicker(deps) {
|
|
1162
1273
|
let hoveredElement = null;
|
|
1163
1274
|
let heldElement = null;
|
|
1164
1275
|
let listening = false;
|
|
1276
|
+
let press = null;
|
|
1277
|
+
let dragBox = null;
|
|
1278
|
+
let dragFrame = null;
|
|
1279
|
+
let lastPoint = { x: 0, y: 0 };
|
|
1280
|
+
let swallowNextClick = false;
|
|
1281
|
+
let collected = [];
|
|
1165
1282
|
function resolveComponentName(el) {
|
|
1166
1283
|
const resolver = deps.getComponentResolver();
|
|
1167
1284
|
if (!resolver) return null;
|
|
1168
1285
|
const result = resolver(el);
|
|
1169
|
-
return _nullishCoalesce(_optionalChain([result, 'optionalAccess',
|
|
1286
|
+
return _nullishCoalesce(_optionalChain([result, 'optionalAccess', _31 => _31.name]), () => ( null));
|
|
1170
1287
|
}
|
|
1171
1288
|
function resolveSourcePath(el) {
|
|
1172
1289
|
const resolver = deps.getSourceResolver();
|
|
1173
1290
|
if (!resolver) return null;
|
|
1174
1291
|
const result = resolver(el);
|
|
1175
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
1292
|
+
if (!_optionalChain([result, 'optionalAccess', _32 => _32.filePath])) return null;
|
|
1176
1293
|
let path = result.filePath;
|
|
1177
1294
|
if (result.line != null) {
|
|
1178
1295
|
path += `:${result.line}`;
|
|
@@ -1180,7 +1297,7 @@ function createElementPicker(deps) {
|
|
|
1180
1297
|
return path;
|
|
1181
1298
|
}
|
|
1182
1299
|
function rawElementAtPoint(x, y) {
|
|
1183
|
-
const freezeEl = _optionalChain([deps, 'access',
|
|
1300
|
+
const freezeEl = _optionalChain([deps, 'access', _33 => _33.getFreezeElement, 'optionalCall', _34 => _34()]);
|
|
1184
1301
|
if (freezeEl) freezeEl.style.pointerEvents = "none";
|
|
1185
1302
|
const target = document.elementFromPoint(x, y);
|
|
1186
1303
|
if (freezeEl) freezeEl.style.pointerEvents = "auto";
|
|
@@ -1188,21 +1305,100 @@ function createElementPicker(deps) {
|
|
|
1188
1305
|
}
|
|
1189
1306
|
function elementAtPoint(x, y, exact) {
|
|
1190
1307
|
const raw = rawElementAtPoint(x, y);
|
|
1191
|
-
if (!raw || raw.closest(`[${IGNORE_ATTR}]`)) return raw && _optionalChain([deps, 'access',
|
|
1308
|
+
if (!raw || raw.closest(`[${IGNORE_ATTR}]`)) return raw && _optionalChain([deps, 'access', _35 => _35.isToolbarElement, 'optionalCall', _36 => _36(raw)]) ? raw : null;
|
|
1192
1309
|
return exact ? raw : promoteTarget(raw);
|
|
1193
1310
|
}
|
|
1311
|
+
function isOurs(el) {
|
|
1312
|
+
return !!_optionalChain([deps, 'access', _37 => _37.isToolbarElement, 'optionalCall', _38 => _38(el)]) || deps.overlay.isOverlayElement(el) || deps.crosshair.isCrosshairElement(el);
|
|
1313
|
+
}
|
|
1194
1314
|
function showOverlay(target) {
|
|
1195
1315
|
const componentName = resolveComponentName(target);
|
|
1196
1316
|
const sourcePath = resolveSourcePath(target);
|
|
1197
1317
|
const cssClasses = filterAngularClasses(target.classList);
|
|
1198
1318
|
deps.overlay.show(target, componentName, sourcePath, cssClasses);
|
|
1199
1319
|
}
|
|
1320
|
+
const countLabel = (n) => `${n} element${n === 1 ? "" : "s"}`;
|
|
1321
|
+
function showCollected() {
|
|
1322
|
+
if (collected.length) {
|
|
1323
|
+
deps.groupOutline.show({ elements: collected }, `${countLabel(collected.length)} \xB7 release ${IS_MAC ? "\u2318" : "Ctrl"} to comment`);
|
|
1324
|
+
} else {
|
|
1325
|
+
deps.groupOutline.hide();
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
function clearCollected() {
|
|
1329
|
+
if (!collected.length) return;
|
|
1330
|
+
collected = [];
|
|
1331
|
+
deps.groupOutline.hide();
|
|
1332
|
+
}
|
|
1333
|
+
function previewDrag() {
|
|
1334
|
+
dragFrame = null;
|
|
1335
|
+
if (!dragBox) return;
|
|
1336
|
+
deps.groupOutline.marquee(dragBox);
|
|
1337
|
+
const found = elementsInBox(dragBox, isOurs);
|
|
1338
|
+
if (found.length) deps.groupOutline.show({ elements: found }, countLabel(found.length));
|
|
1339
|
+
else deps.groupOutline.hide();
|
|
1340
|
+
}
|
|
1341
|
+
function endDrag() {
|
|
1342
|
+
dragBox = null;
|
|
1343
|
+
if (dragFrame !== null) cancelAnimationFrame(dragFrame);
|
|
1344
|
+
dragFrame = null;
|
|
1345
|
+
deps.groupOutline.marquee(null);
|
|
1346
|
+
deps.groupOutline.hide();
|
|
1347
|
+
}
|
|
1348
|
+
function finishDrag(point) {
|
|
1349
|
+
const box = dragBox;
|
|
1350
|
+
endDrag();
|
|
1351
|
+
const found = elementsInBox(box, isOurs);
|
|
1352
|
+
if (found.length === 1) {
|
|
1353
|
+
hoveredElement = found[0];
|
|
1354
|
+
deps.onSelect(found[0], point);
|
|
1355
|
+
} else if (found.length > 1) {
|
|
1356
|
+
deps.onSelectGroup(found, point);
|
|
1357
|
+
} else {
|
|
1358
|
+
const container = containerForBox(box, isOurs);
|
|
1359
|
+
deps.onSelectArea(container, areaWithin(container, box), point);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
function handlePress(e) {
|
|
1363
|
+
const origin = eventTarget(e);
|
|
1364
|
+
if (origin && _optionalChain([deps, 'access', _39 => _39.isToolbarElement, 'optionalCall', _40 => _40(origin)])) return;
|
|
1365
|
+
e.stopPropagation();
|
|
1366
|
+
if (e.type === "mousedown" || e.type === "touchstart") e.preventDefault();
|
|
1367
|
+
if (heldElement) return;
|
|
1368
|
+
const m = e;
|
|
1369
|
+
const down = e.type === "pointerdown" || e.type === "mousedown";
|
|
1370
|
+
if (down && m.button === 0 && !press) {
|
|
1371
|
+
press = { x: m.clientX, y: m.clientY };
|
|
1372
|
+
swallowNextClick = false;
|
|
1373
|
+
} else if (!down && e.type !== "touchstart" && press) {
|
|
1374
|
+
const point = { x: m.clientX, y: m.clientY };
|
|
1375
|
+
const start = press;
|
|
1376
|
+
press = null;
|
|
1377
|
+
if (dragBox) {
|
|
1378
|
+
dragBox = boxFromPoints(start, point);
|
|
1379
|
+
swallowNextClick = true;
|
|
1380
|
+
finishDrag(point);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1200
1384
|
function handleMouseMove(e) {
|
|
1201
1385
|
if (heldElement) return;
|
|
1386
|
+
lastPoint = { x: e.clientX, y: e.clientY };
|
|
1387
|
+
if (press) {
|
|
1388
|
+
if (!dragBox && Math.hypot(e.clientX - press.x, e.clientY - press.y) < DRAG_PX) return;
|
|
1389
|
+
if (!dragBox) {
|
|
1390
|
+
clearCollected();
|
|
1391
|
+
deps.overlay.hide();
|
|
1392
|
+
hoveredElement = null;
|
|
1393
|
+
}
|
|
1394
|
+
dragBox = boxFromPoints(press, lastPoint);
|
|
1395
|
+
if (dragFrame === null) dragFrame = requestAnimationFrame(previewDrag);
|
|
1396
|
+
return;
|
|
1397
|
+
}
|
|
1202
1398
|
const target = elementAtPoint(e.clientX, e.clientY, e.shiftKey);
|
|
1203
1399
|
if (!target || deps.overlay.isOverlayElement(target)) return;
|
|
1204
1400
|
if (deps.crosshair.isCrosshairElement(target)) return;
|
|
1205
|
-
if (_optionalChain([deps, 'access',
|
|
1401
|
+
if (_optionalChain([deps, 'access', _41 => _41.isToolbarElement, 'optionalCall', _42 => _42(target)])) return;
|
|
1206
1402
|
if (target === hoveredElement) return;
|
|
1207
1403
|
hoveredElement = target;
|
|
1208
1404
|
showOverlay(target);
|
|
@@ -1210,14 +1406,38 @@ function createElementPicker(deps) {
|
|
|
1210
1406
|
}
|
|
1211
1407
|
function handleClick(e) {
|
|
1212
1408
|
const origin = eventTarget(e);
|
|
1213
|
-
if (origin && _optionalChain([deps, 'access',
|
|
1409
|
+
if (origin && _optionalChain([deps, 'access', _43 => _43.isToolbarElement, 'optionalCall', _44 => _44(origin)])) return;
|
|
1214
1410
|
const target = rawElementAtPoint(e.clientX, e.clientY);
|
|
1215
|
-
if (target && (_optionalChain([deps, 'access',
|
|
1411
|
+
if (target && (_optionalChain([deps, 'access', _45 => _45.isToolbarElement, 'optionalCall', _46 => _46(target)]) || deps.crosshair.isCrosshairElement(target))) return;
|
|
1216
1412
|
e.preventDefault();
|
|
1217
1413
|
e.stopPropagation();
|
|
1218
1414
|
if (heldElement) return;
|
|
1219
|
-
if (
|
|
1220
|
-
|
|
1415
|
+
if (swallowNextClick) {
|
|
1416
|
+
swallowNextClick = false;
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1419
|
+
if (!hoveredElement) return;
|
|
1420
|
+
lastPoint = { x: e.clientX, y: e.clientY };
|
|
1421
|
+
if (addKey(e)) {
|
|
1422
|
+
const at = collected.indexOf(hoveredElement);
|
|
1423
|
+
if (at >= 0) collected.splice(at, 1);
|
|
1424
|
+
else if (collected.length < MAX_MEMBERS) collected.push(hoveredElement);
|
|
1425
|
+
showCollected();
|
|
1426
|
+
return;
|
|
1427
|
+
}
|
|
1428
|
+
clearCollected();
|
|
1429
|
+
deps.onSelect(hoveredElement, lastPoint);
|
|
1430
|
+
}
|
|
1431
|
+
function handleKeyUp(e) {
|
|
1432
|
+
if (e.key !== (IS_MAC ? "Meta" : "Control") || !collected.length || heldElement) return;
|
|
1433
|
+
const elements = collected;
|
|
1434
|
+
collected = [];
|
|
1435
|
+
deps.groupOutline.hide();
|
|
1436
|
+
if (elements.length === 1) {
|
|
1437
|
+
hoveredElement = elements[0];
|
|
1438
|
+
deps.onSelect(elements[0], lastPoint);
|
|
1439
|
+
} else {
|
|
1440
|
+
deps.onSelectGroup(elements, lastPoint);
|
|
1221
1441
|
}
|
|
1222
1442
|
}
|
|
1223
1443
|
return {
|
|
@@ -1225,31 +1445,46 @@ function createElementPicker(deps) {
|
|
|
1225
1445
|
if (listening) return;
|
|
1226
1446
|
listening = true;
|
|
1227
1447
|
deps.crosshair.activate();
|
|
1448
|
+
for (const type of PRESS_EVENTS) window.addEventListener(type, handlePress, { capture: true, passive: false });
|
|
1228
1449
|
document.addEventListener("mousemove", handleMouseMove, true);
|
|
1229
1450
|
document.addEventListener("click", handleClick, true);
|
|
1451
|
+
window.addEventListener("keyup", handleKeyUp, true);
|
|
1230
1452
|
},
|
|
1231
1453
|
deactivate() {
|
|
1232
1454
|
if (!listening) return;
|
|
1233
1455
|
listening = false;
|
|
1234
1456
|
hoveredElement = null;
|
|
1235
1457
|
heldElement = null;
|
|
1458
|
+
press = null;
|
|
1459
|
+
swallowNextClick = false;
|
|
1460
|
+
collected = [];
|
|
1461
|
+
endDrag();
|
|
1236
1462
|
deps.crosshair.hold(false);
|
|
1237
1463
|
deps.crosshair.deactivate();
|
|
1464
|
+
for (const type of PRESS_EVENTS) window.removeEventListener(type, handlePress, true);
|
|
1238
1465
|
document.removeEventListener("mousemove", handleMouseMove, true);
|
|
1239
1466
|
document.removeEventListener("click", handleClick, true);
|
|
1467
|
+
window.removeEventListener("keyup", handleKeyUp, true);
|
|
1240
1468
|
deps.overlay.hide();
|
|
1241
1469
|
deps.onHover(null);
|
|
1242
1470
|
},
|
|
1243
|
-
hold(element) {
|
|
1471
|
+
hold(element, group) {
|
|
1244
1472
|
if (!listening) return;
|
|
1245
1473
|
heldElement = element;
|
|
1246
1474
|
hoveredElement = element;
|
|
1475
|
+
press = null;
|
|
1247
1476
|
deps.crosshair.hold(true);
|
|
1248
|
-
|
|
1477
|
+
if (group) {
|
|
1478
|
+
deps.overlay.hide();
|
|
1479
|
+
deps.groupOutline.show(group.spec, group.label);
|
|
1480
|
+
} else {
|
|
1481
|
+
showOverlay(element);
|
|
1482
|
+
}
|
|
1249
1483
|
},
|
|
1250
1484
|
release() {
|
|
1251
1485
|
if (!heldElement) return;
|
|
1252
1486
|
heldElement = null;
|
|
1487
|
+
deps.groupOutline.hide();
|
|
1253
1488
|
deps.crosshair.hold(false);
|
|
1254
1489
|
},
|
|
1255
1490
|
isHolding() {
|
|
@@ -1408,7 +1643,7 @@ function createPluginRegistry() {
|
|
|
1408
1643
|
},
|
|
1409
1644
|
callHook(hookName, ...args) {
|
|
1410
1645
|
for (const plugin of plugins.values()) {
|
|
1411
|
-
const hook = _optionalChain([plugin, 'access',
|
|
1646
|
+
const hook = _optionalChain([plugin, 'access', _47 => _47.hooks, 'optionalAccess', _48 => _48[hookName]]);
|
|
1412
1647
|
if (hook) {
|
|
1413
1648
|
try {
|
|
1414
1649
|
hook(...args);
|
|
@@ -1421,7 +1656,7 @@ function createPluginRegistry() {
|
|
|
1421
1656
|
callTransformHook(text, comments) {
|
|
1422
1657
|
let result = text;
|
|
1423
1658
|
for (const plugin of plugins.values()) {
|
|
1424
|
-
const transform = _optionalChain([plugin, 'access',
|
|
1659
|
+
const transform = _optionalChain([plugin, 'access', _49 => _49.hooks, 'optionalAccess', _50 => _50.transformCopyContent]);
|
|
1425
1660
|
if (transform) {
|
|
1426
1661
|
try {
|
|
1427
1662
|
result = transform(result, comments);
|
|
@@ -1807,7 +2042,7 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1807
2042
|
buttons.history.appendChild(badge);
|
|
1808
2043
|
buttons.enable = createButton("enable", ICON_POWER, "Enable/Disable", callbacks.onEnableToggle);
|
|
1809
2044
|
buttons.dismiss = createButton("dismiss", ICON_DISMISS, _nullishCoalesce(options.dismissLabel, () => ( "Dismiss toolbar")), callbacks.onDismiss);
|
|
1810
|
-
buttons.expand = createButton("expand", ICON_GRAB, _nullishCoalesce(options.expandLabel, () => ( "Open Grabby toolbar")), () => _optionalChain([callbacks, 'access',
|
|
2045
|
+
buttons.expand = createButton("expand", ICON_GRAB, _nullishCoalesce(options.expandLabel, () => ( "Open Grabby toolbar")), () => _optionalChain([callbacks, 'access', _51 => _51.onExpand, 'optionalCall', _52 => _52()]));
|
|
1811
2046
|
buttons.expand.classList.add("grabby-btn-expand");
|
|
1812
2047
|
expandBadge = document.createElement("span");
|
|
1813
2048
|
expandBadge.className = "grabby-badge";
|
|
@@ -1837,7 +2072,7 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1837
2072
|
buttons.finish.addEventListener("click", (e) => {
|
|
1838
2073
|
e.preventDefault();
|
|
1839
2074
|
e.stopPropagation();
|
|
1840
|
-
_optionalChain([callbacks, 'access',
|
|
2075
|
+
_optionalChain([callbacks, 'access', _53 => _53.onFinish, 'optionalCall', _54 => _54()]);
|
|
1841
2076
|
});
|
|
1842
2077
|
content.appendChild(status);
|
|
1843
2078
|
content.appendChild(buttons.finish);
|
|
@@ -1887,16 +2122,16 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1887
2122
|
if (status && buttons.finish) {
|
|
1888
2123
|
const summary = syncSummary(state.toolbar.comments);
|
|
1889
2124
|
status.hidden = !summary;
|
|
1890
|
-
status.textContent = _nullishCoalesce(_optionalChain([summary, 'optionalAccess',
|
|
1891
|
-
status.dataset.tone = _nullishCoalesce(_optionalChain([summary, 'optionalAccess',
|
|
2125
|
+
status.textContent = _nullishCoalesce(_optionalChain([summary, 'optionalAccess', _55 => _55.text]), () => ( ""));
|
|
2126
|
+
status.dataset.tone = _nullishCoalesce(_optionalChain([summary, 'optionalAccess', _56 => _56.tone]), () => ( ""));
|
|
1892
2127
|
buttons.finish.hidden = count === 0;
|
|
1893
2128
|
}
|
|
1894
2129
|
if (state.options.enabled) {
|
|
1895
2130
|
buttons.enable.classList.add("grabby-btn-active");
|
|
1896
|
-
_optionalChain([leftGroup, 'optionalAccess',
|
|
2131
|
+
_optionalChain([leftGroup, 'optionalAccess', _57 => _57.classList, 'access', _58 => _58.remove, 'call', _59 => _59("grabby-toolbar-left-hidden")]);
|
|
1897
2132
|
} else {
|
|
1898
2133
|
buttons.enable.classList.remove("grabby-btn-active");
|
|
1899
|
-
_optionalChain([leftGroup, 'optionalAccess',
|
|
2134
|
+
_optionalChain([leftGroup, 'optionalAccess', _60 => _60.classList, 'access', _61 => _61.add, 'call', _62 => _62("grabby-toolbar-left-hidden")]);
|
|
1900
2135
|
}
|
|
1901
2136
|
},
|
|
1902
2137
|
collapse() {
|
|
@@ -1917,7 +2152,7 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1917
2152
|
container.classList.remove("grabby-toolbar-collapsed");
|
|
1918
2153
|
const cs = getComputedStyle(container);
|
|
1919
2154
|
const chrome = ["paddingLeft", "paddingRight", "borderLeftWidth", "borderRightWidth"].reduce((sum, k) => sum + (parseFloat(cs[k]) || 0), 0);
|
|
1920
|
-
container.style.width = `${(_nullishCoalesce(_optionalChain([content, 'optionalAccess',
|
|
2155
|
+
container.style.width = `${(_nullishCoalesce(_optionalChain([content, 'optionalAccess', _63 => _63.offsetWidth]), () => ( 0))) + chrome}px`;
|
|
1921
2156
|
morphTimer = setTimeout(() => {
|
|
1922
2157
|
morphTimer = null;
|
|
1923
2158
|
if (!collapsed && container) container.style.width = "";
|
|
@@ -1938,7 +2173,7 @@ function createToolbarRenderer(callbacks, options = {}) {
|
|
|
1938
2173
|
},
|
|
1939
2174
|
dispose() {
|
|
1940
2175
|
clearMorph();
|
|
1941
|
-
_optionalChain([container, 'optionalAccess',
|
|
2176
|
+
_optionalChain([container, 'optionalAccess', _64 => _64.remove, 'call', _65 => _65()]);
|
|
1942
2177
|
removeStyles(STYLE_ID3);
|
|
1943
2178
|
container = null;
|
|
1944
2179
|
leftGroup = null;
|
|
@@ -1990,7 +2225,7 @@ function header(comments, env, ctx) {
|
|
|
1990
2225
|
if (frameworks.length) meta.push(frameworks.join(", "));
|
|
1991
2226
|
const routes = uniq(comments.map((c) => c.page.route));
|
|
1992
2227
|
if (!ctx.showRoutes && routes.length === 1) meta.push(`page ${routes[0]}`);
|
|
1993
|
-
const vp = _optionalChain([comments, 'access',
|
|
2228
|
+
const vp = _optionalChain([comments, 'access', _66 => _66[0], 'optionalAccess', _67 => _67.page, 'access', _68 => _68.viewport]);
|
|
1994
2229
|
if (vp) meta.push(`${vp[0]}\xD7${vp[1]}`);
|
|
1995
2230
|
meta.push((_nullishCoalesce(env.now, () => ( /* @__PURE__ */ new Date()))).toISOString().slice(0, 10));
|
|
1996
2231
|
lines.push(meta.join(" \xB7 "));
|
|
@@ -2000,10 +2235,15 @@ function header(comments, env, ctx) {
|
|
|
2000
2235
|
}
|
|
2001
2236
|
return lines;
|
|
2002
2237
|
}
|
|
2238
|
+
var pct = (v) => `${Math.round(v * 100)}%`;
|
|
2239
|
+
function memberRefs(c, full) {
|
|
2240
|
+
return (_nullishCoalesce(c.members, () => ( []))).map((m) => m.source ? location2(m.source.file, m.source.line, full) : m.selector).join(", ");
|
|
2241
|
+
}
|
|
2003
2242
|
function compactLine(c, i, ctx) {
|
|
2004
2243
|
const t = c.target;
|
|
2005
2244
|
const where = t.source ? location2(t.source.file, t.source.line, true) : t.selector;
|
|
2006
|
-
const
|
|
2245
|
+
const own = [where, t.component, `<${t.tag}>`].filter(Boolean).join(" ");
|
|
2246
|
+
const parts = _optionalChain([c, 'access', _69 => _69.members, 'optionalAccess', _70 => _70.length]) ? `[${c.members.length} elements] ${memberRefs(c, true)}` : c.area ? `[area] in ${own}` : own;
|
|
2007
2247
|
const who = ctx.showAuthors ? ` (${authorLabel(c.author)})` : "";
|
|
2008
2248
|
const route = ctx.showRoutes ? ` [${c.page.route}]` : "";
|
|
2009
2249
|
const id = ctx.showIds ? ` [id ${c.id}]` : "";
|
|
@@ -2016,11 +2256,24 @@ function detailBlock(c, i, ctx, groupHasSource, headedComponent) {
|
|
|
2016
2256
|
const b = (text) => lines.push(` - ${text}`);
|
|
2017
2257
|
const where = [`\`${t.preview}\``, `(${t.kind})`];
|
|
2018
2258
|
if (t.component && t.component !== headedComponent) {
|
|
2019
|
-
where.push(_optionalChain([t, 'access',
|
|
2020
|
-
} else if (_optionalChain([t, 'access',
|
|
2259
|
+
where.push(_optionalChain([t, 'access', _71 => _71.source, 'optionalAccess', _72 => _72.line]) != null && groupHasSource ? `${t.component} line ${t.source.line}` : t.component);
|
|
2260
|
+
} else if (_optionalChain([t, 'access', _73 => _73.source, 'optionalAccess', _74 => _74.line]) != null && groupHasSource) {
|
|
2021
2261
|
where.push(`line ${t.source.line}`);
|
|
2022
2262
|
}
|
|
2263
|
+
if (_optionalChain([c, 'access', _75 => _75.members, 'optionalAccess', _76 => _76.length])) where.unshift("in");
|
|
2264
|
+
if (c.area) where.unshift("area in");
|
|
2023
2265
|
b(where.join(" "));
|
|
2266
|
+
if (c.area) {
|
|
2267
|
+
const a = c.area;
|
|
2268
|
+
b(`region: ${pct(a.x)} from left, ${pct(a.y)} from top, ${pct(a.w)} wide, ${pct(a.h)} tall`);
|
|
2269
|
+
}
|
|
2270
|
+
if (_optionalChain([c, 'access', _77 => _77.members, 'optionalAccess', _78 => _78.length])) {
|
|
2271
|
+
b(`${c.members.length} elements:`);
|
|
2272
|
+
for (const m of c.members) {
|
|
2273
|
+
const at = m.source ? location2(m.source.file, m.source.line, full) : `selector \`${m.selector}\``;
|
|
2274
|
+
lines.push(` - \`${m.preview}\` (${m.kind})${m.component && m.component !== t.component ? ` ${m.component}` : ""} ${at}`);
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2024
2277
|
if (!t.source || full) b(`selector: \`${t.selector}\``);
|
|
2025
2278
|
const plain = Object.entries(t.facts).filter(([k, v]) => !STYLE_FACTS.has(k) && !(PREVIEW_FACTS.has(k) && !full && inPreview(t.preview, v)));
|
|
2026
2279
|
if (plain.length) b(plain.map(([k, v]) => `${k}: ${v}`).join(" \xB7 "));
|
|
@@ -2033,7 +2286,7 @@ function detailBlock(c, i, ctx, groupHasSource, headedComponent) {
|
|
|
2033
2286
|
for (const [k, v] of Object.entries(t.extra)) b(`${k}: ${v}`);
|
|
2034
2287
|
b(`viewport: ${c.page.viewport[0]}\xD7${c.page.viewport[1]}`);
|
|
2035
2288
|
}
|
|
2036
|
-
if (_optionalChain([c, 'access',
|
|
2289
|
+
if (_optionalChain([c, 'access', _79 => _79.screenshot, 'optionalAccess', _80 => _80.url])) b(`screenshot: ${c.screenshot.url}`);
|
|
2037
2290
|
const meta = [];
|
|
2038
2291
|
if (ctx.showAuthors) meta.push(`by ${authorLabel(c.author)}`);
|
|
2039
2292
|
if (ctx.showRoutes) meta.push(`on ${c.page.route}`);
|
|
@@ -2059,7 +2312,7 @@ function formatExport(comments, level = "standard", env = {}) {
|
|
|
2059
2312
|
}
|
|
2060
2313
|
const groups = /* @__PURE__ */ new Map();
|
|
2061
2314
|
for (const c of ordered) {
|
|
2062
|
-
const key = _nullishCoalesce(_optionalChain([c, 'access',
|
|
2315
|
+
const key = _nullishCoalesce(_optionalChain([c, 'access', _81 => _81.target, 'access', _82 => _82.source, 'optionalAccess', _83 => _83.file]), () => ( ""));
|
|
2063
2316
|
const list = groups.get(key);
|
|
2064
2317
|
if (list) list.push(c);
|
|
2065
2318
|
else groups.set(key, [c]);
|
|
@@ -2069,7 +2322,7 @@ function formatExport(comments, level = "standard", env = {}) {
|
|
|
2069
2322
|
out.push("");
|
|
2070
2323
|
const components = uniq(list.map((c) => c.target.component));
|
|
2071
2324
|
const headed = file && components.length === 1 ? components[0] : null;
|
|
2072
|
-
const lines = uniq(list.map((c) => _nullishCoalesce(_optionalChain([c, 'access',
|
|
2325
|
+
const lines = uniq(list.map((c) => _nullishCoalesce(_optionalChain([c, 'access', _84 => _84.target, 'access', _85 => _85.source, 'optionalAccess', _86 => _86.line]), () => ( null))));
|
|
2073
2326
|
if (file) {
|
|
2074
2327
|
const loc = lines.length === 1 ? location2(file, lines[0], true) : file;
|
|
2075
2328
|
out.push(`## ${loc}${headed ? ` \xB7 ${headed}` : ""}`);
|
|
@@ -2254,7 +2507,7 @@ function createCommentsPanel(callbacks, options = {}) {
|
|
|
2254
2507
|
let visible = false;
|
|
2255
2508
|
let objectUrls = [];
|
|
2256
2509
|
function ensurePanel() {
|
|
2257
|
-
if (_optionalChain([panel, 'optionalAccess',
|
|
2510
|
+
if (_optionalChain([panel, 'optionalAccess', _87 => _87.isConnected])) return panel;
|
|
2258
2511
|
addStyles(STYLE_ID4, CSS2);
|
|
2259
2512
|
panel = h("div", { id: PANEL_ID, role: "dialog", "aria-label": "Comments" });
|
|
2260
2513
|
getUiRoot().appendChild(panel);
|
|
@@ -2265,7 +2518,7 @@ function createCommentsPanel(callbacks, options = {}) {
|
|
|
2265
2518
|
objectUrls = [];
|
|
2266
2519
|
}
|
|
2267
2520
|
function thumbnail(comment) {
|
|
2268
|
-
const localId = _optionalChain([comment, 'access',
|
|
2521
|
+
const localId = _optionalChain([comment, 'access', _88 => _88.screenshot, 'optionalAccess', _89 => _89.localId]);
|
|
2269
2522
|
if (!localId) return null;
|
|
2270
2523
|
const img = h("img", { class: "grabby-thumb", alt: "", loading: "lazy" });
|
|
2271
2524
|
img.addEventListener("error", () => img.remove(), { once: true });
|
|
@@ -2282,7 +2535,8 @@ function createCommentsPanel(callbacks, options = {}) {
|
|
|
2282
2535
|
}
|
|
2283
2536
|
function row2(comment, showAuthors) {
|
|
2284
2537
|
const t = comment.target;
|
|
2285
|
-
const
|
|
2538
|
+
const group = _optionalChain([comment, 'access', _90 => _90.members, 'optionalAccess', _91 => _91.length]) ? `${comment.members.length} elements` : comment.area ? "area" : null;
|
|
2539
|
+
const meta = live ? [document.createTextNode(`${describeComment(comment)} `)] : [h("span", { class: "grabby-kind" }, _nullishCoalesce(group, () => ( t.kind)))];
|
|
2286
2540
|
if (!live) {
|
|
2287
2541
|
if (t.component) meta.push(document.createTextNode(`${t.component} `));
|
|
2288
2542
|
if (t.source) {
|
|
@@ -2374,7 +2628,7 @@ function createCommentsPanel(callbacks, options = {}) {
|
|
|
2374
2628
|
h("strong", null, live ? "Nothing sent yet" : "No comments yet"),
|
|
2375
2629
|
live ? "Click Comment, then click the part of the page you want to talk about." : "Click the hand icon (or press Alt+G), then click anything on the page to comment on it."
|
|
2376
2630
|
) : h("div", { class: "grabby-panel-list" }, ...comments.map((c) => row2(c, showAuthors)));
|
|
2377
|
-
const who = _nullishCoalesce(_optionalChain([options, 'access',
|
|
2631
|
+
const who = _nullishCoalesce(_optionalChain([options, 'access', _92 => _92.identityLabel, 'optionalCall', _93 => _93()]), () => ( null));
|
|
2378
2632
|
let footer = null;
|
|
2379
2633
|
if (live && who) {
|
|
2380
2634
|
footer = h(
|
|
@@ -2387,7 +2641,7 @@ function createCommentsPanel(callbacks, options = {}) {
|
|
|
2387
2641
|
"data-grabby-change-identity": "",
|
|
2388
2642
|
onclick: (e) => {
|
|
2389
2643
|
e.stopPropagation();
|
|
2390
|
-
_optionalChain([callbacks, 'access',
|
|
2644
|
+
_optionalChain([callbacks, 'access', _94 => _94.onChangeIdentity, 'optionalCall', _95 => _95()]);
|
|
2391
2645
|
}
|
|
2392
2646
|
}, "Change")
|
|
2393
2647
|
);
|
|
@@ -2421,7 +2675,7 @@ function createCommentsPanel(callbacks, options = {}) {
|
|
|
2421
2675
|
},
|
|
2422
2676
|
hide() {
|
|
2423
2677
|
visible = false;
|
|
2424
|
-
_optionalChain([panel, 'optionalAccess',
|
|
2678
|
+
_optionalChain([panel, 'optionalAccess', _96 => _96.classList, 'access', _97 => _97.remove, 'call', _98 => _98("grabby-popover-visible")]);
|
|
2425
2679
|
},
|
|
2426
2680
|
isVisible() {
|
|
2427
2681
|
return visible;
|
|
@@ -2431,7 +2685,7 @@ function createCommentsPanel(callbacks, options = {}) {
|
|
|
2431
2685
|
},
|
|
2432
2686
|
dispose() {
|
|
2433
2687
|
revokeThumbs();
|
|
2434
|
-
_optionalChain([panel, 'optionalAccess',
|
|
2688
|
+
_optionalChain([panel, 'optionalAccess', _99 => _99.remove, 'call', _100 => _100()]);
|
|
2435
2689
|
removeStyles(STYLE_ID4);
|
|
2436
2690
|
panel = null;
|
|
2437
2691
|
visible = false;
|
|
@@ -2512,6 +2766,13 @@ function createCommentPopover(callbacks) {
|
|
|
2512
2766
|
font: 500 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding: 8px 4px; border: none;
|
|
2513
2767
|
background: transparent; color: var(--grabby-text-muted, #64748b); cursor: pointer; text-decoration: underline;
|
|
2514
2768
|
}
|
|
2769
|
+
#${POPOVER_ID} .grabby-cp-heading {
|
|
2770
|
+
font: 600 12px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
2771
|
+
color: #15803d;
|
|
2772
|
+
overflow: hidden;
|
|
2773
|
+
text-overflow: ellipsis;
|
|
2774
|
+
white-space: nowrap;
|
|
2775
|
+
}
|
|
2515
2776
|
#${POPOVER_ID} .grabby-cp-edit-actions { display: flex; align-items: center; gap: 6px; }
|
|
2516
2777
|
#${POPOVER_ID} .grabby-cp-edit-actions .grabby-cp-spacer { flex: 1; }
|
|
2517
2778
|
#${POPOVER_ID} .grabby-cp-delete {
|
|
@@ -2550,18 +2811,18 @@ function createCommentPopover(callbacks) {
|
|
|
2550
2811
|
getUiRoot().appendChild(popover);
|
|
2551
2812
|
return popover;
|
|
2552
2813
|
}
|
|
2553
|
-
function position(el, anchor) {
|
|
2814
|
+
function position(el, anchor, box) {
|
|
2554
2815
|
const vw = window.innerWidth;
|
|
2555
2816
|
const vh = window.innerHeight;
|
|
2556
2817
|
const fW = 300;
|
|
2557
2818
|
const fH = 120;
|
|
2558
|
-
if (!anchor) {
|
|
2819
|
+
if (!anchor && !box) {
|
|
2559
2820
|
el.style.left = "50%";
|
|
2560
2821
|
el.style.top = "24px";
|
|
2561
2822
|
el.style.transform = "translateX(-50%)";
|
|
2562
2823
|
return;
|
|
2563
2824
|
}
|
|
2564
|
-
const rect = anchor.getBoundingClientRect();
|
|
2825
|
+
const rect = box ? { ...box, width: box.right - box.left, height: box.bottom - box.top } : anchor.getBoundingClientRect();
|
|
2565
2826
|
let left;
|
|
2566
2827
|
let top;
|
|
2567
2828
|
if (rect.right + 16 + fW <= vw) {
|
|
@@ -2586,7 +2847,7 @@ function createCommentPopover(callbacks) {
|
|
|
2586
2847
|
return !!el && el !== textarea && el !== nameInput && isEditableElement(el);
|
|
2587
2848
|
}
|
|
2588
2849
|
function save() {
|
|
2589
|
-
const v = _optionalChain([textarea, 'optionalAccess',
|
|
2850
|
+
const v = _optionalChain([textarea, 'optionalAccess', _101 => _101.value, 'access', _102 => _102.trim, 'call', _103 => _103()]);
|
|
2590
2851
|
if (!v) return;
|
|
2591
2852
|
pendingValue = v;
|
|
2592
2853
|
if (askIdentity) showIdentityStep();
|
|
@@ -2605,7 +2866,7 @@ function createCommentPopover(callbacks) {
|
|
|
2605
2866
|
const del = () => {
|
|
2606
2867
|
const ctx = currentCtx;
|
|
2607
2868
|
doHide();
|
|
2608
|
-
_optionalChain([callbacks, 'access',
|
|
2869
|
+
_optionalChain([callbacks, 'access', _104 => _104.onDelete, 'optionalCall', _105 => _105(ctx)]);
|
|
2609
2870
|
};
|
|
2610
2871
|
return h(
|
|
2611
2872
|
"div",
|
|
@@ -2634,7 +2895,7 @@ function createCommentPopover(callbacks) {
|
|
|
2634
2895
|
autocomplete: "name",
|
|
2635
2896
|
"aria-label": "Your name"
|
|
2636
2897
|
});
|
|
2637
|
-
const post = () => finish({ name: _optionalChain([nameInput, 'optionalAccess',
|
|
2898
|
+
const post = () => finish({ name: _optionalChain([nameInput, 'optionalAccess', _106 => _106.value, 'access', _107 => _107.trim, 'call', _108 => _108()]) || null });
|
|
2638
2899
|
popover.replaceChildren(
|
|
2639
2900
|
h("div", { class: "grabby-cp-title" }, "Thanks! Who is this from?"),
|
|
2640
2901
|
h("div", { class: "grabby-cp-sub" }, "Your name helps the team follow up. It's remembered in this browser."),
|
|
@@ -2668,7 +2929,7 @@ function createCommentPopover(callbacks) {
|
|
|
2668
2929
|
} else if (e.key === "Enter" && deepActiveElement() === nameInput) {
|
|
2669
2930
|
e.preventDefault();
|
|
2670
2931
|
e.stopImmediatePropagation();
|
|
2671
|
-
finish({ name: _optionalChain([nameInput, 'optionalAccess',
|
|
2932
|
+
finish({ name: _optionalChain([nameInput, 'optionalAccess', _109 => _109.value, 'access', _110 => _110.trim, 'call', _111 => _111()]) || null });
|
|
2672
2933
|
}
|
|
2673
2934
|
return;
|
|
2674
2935
|
}
|
|
@@ -2699,7 +2960,7 @@ function createCommentPopover(callbacks) {
|
|
|
2699
2960
|
}
|
|
2700
2961
|
function doHide() {
|
|
2701
2962
|
visible = false;
|
|
2702
|
-
_optionalChain([popover, 'optionalAccess',
|
|
2963
|
+
_optionalChain([popover, 'optionalAccess', _112 => _112.remove, 'call', _113 => _113()]);
|
|
2703
2964
|
popover = null;
|
|
2704
2965
|
textarea = null;
|
|
2705
2966
|
nameInput = null;
|
|
@@ -2715,11 +2976,15 @@ function createCommentPopover(callbacks) {
|
|
|
2715
2976
|
currentCtx = { mode: opts.mode, entryId: opts.entryId };
|
|
2716
2977
|
askIdentity = opts.askIdentity === true && opts.mode === "new";
|
|
2717
2978
|
visible = true;
|
|
2979
|
+
textarea.placeholder = _nullishCoalesce(opts.placeholder, () => ( "What should change here?"));
|
|
2980
|
+
if (opts.heading) {
|
|
2981
|
+
el.prepend(h("div", { class: "grabby-cp-heading", title: opts.heading }, opts.heading));
|
|
2982
|
+
}
|
|
2718
2983
|
if (opts.mode === "edit") el.appendChild(editActions());
|
|
2719
|
-
position(el, opts.anchor);
|
|
2984
|
+
position(el, opts.anchor, opts.anchorBox);
|
|
2720
2985
|
attachKey();
|
|
2721
|
-
_optionalChain([textarea, 'optionalAccess',
|
|
2722
|
-
requestAnimationFrame(() => _optionalChain([textarea, 'optionalAccess',
|
|
2986
|
+
_optionalChain([textarea, 'optionalAccess', _114 => _114.focus, 'call', _115 => _115()]);
|
|
2987
|
+
requestAnimationFrame(() => _optionalChain([textarea, 'optionalAccess', _116 => _116.focus, 'call', _117 => _117()]));
|
|
2723
2988
|
},
|
|
2724
2989
|
hide() {
|
|
2725
2990
|
if (!visible) return;
|
|
@@ -2731,7 +2996,7 @@ function createCommentPopover(callbacks) {
|
|
|
2731
2996
|
hasDraft() {
|
|
2732
2997
|
if (!visible) return false;
|
|
2733
2998
|
if (stage === "identity") return true;
|
|
2734
|
-
const v = _nullishCoalesce(_optionalChain([textarea, 'optionalAccess',
|
|
2999
|
+
const v = _nullishCoalesce(_optionalChain([textarea, 'optionalAccess', _118 => _118.value, 'access', _119 => _119.trim, 'call', _120 => _120()]), () => ( ""));
|
|
2735
3000
|
return v !== "" && v !== initialValue.trim();
|
|
2736
3001
|
},
|
|
2737
3002
|
isPopoverElement(el) {
|
|
@@ -2820,7 +3085,7 @@ function createCopySheet(callbacks) {
|
|
|
2820
3085
|
document.removeEventListener("keydown", keyHandler, true);
|
|
2821
3086
|
keyHandler = null;
|
|
2822
3087
|
}
|
|
2823
|
-
_optionalChain([callbacks, 'access',
|
|
3088
|
+
_optionalChain([callbacks, 'access', _121 => _121.onClose, 'optionalCall', _122 => _122()]);
|
|
2824
3089
|
}
|
|
2825
3090
|
function open(options) {
|
|
2826
3091
|
close();
|
|
@@ -2842,12 +3107,12 @@ function createCopySheet(callbacks) {
|
|
|
2842
3107
|
level = next;
|
|
2843
3108
|
edited = false;
|
|
2844
3109
|
textarea.value = options.render(level);
|
|
2845
|
-
hint.textContent = _nullishCoalesce(_optionalChain([LEVELS, 'access',
|
|
3110
|
+
hint.textContent = _nullishCoalesce(_optionalChain([LEVELS, 'access', _123 => _123.find, 'call', _124 => _124((l) => l.id === level), 'optionalAccess', _125 => _125.hint]), () => ( ""));
|
|
2846
3111
|
for (const [id, btn] of segButtons) btn.setAttribute("aria-checked", String(id === level));
|
|
2847
3112
|
status.classList.remove("grabby-error");
|
|
2848
3113
|
status.textContent = discarded ? "Your edits were replaced by the new detail level." : "";
|
|
2849
3114
|
updateTokens();
|
|
2850
|
-
_optionalChain([callbacks, 'access',
|
|
3115
|
+
_optionalChain([callbacks, 'access', _126 => _126.onLevelChange, 'optionalCall', _127 => _127(level)]);
|
|
2851
3116
|
}
|
|
2852
3117
|
const seg = h(
|
|
2853
3118
|
"div",
|
|
@@ -2925,7 +3190,7 @@ function createCopySheet(callbacks) {
|
|
|
2925
3190
|
document.addEventListener("keydown", keyHandler, true);
|
|
2926
3191
|
getUiRoot().appendChild(sheet);
|
|
2927
3192
|
setLevel(level, true);
|
|
2928
|
-
_optionalChain([sheet, 'access',
|
|
3193
|
+
_optionalChain([sheet, 'access', _128 => _128.querySelector, 'call', _129 => _129("[data-grabby-copy-clear]"), 'optionalAccess', _130 => _130.focus, 'call', _131 => _131()]);
|
|
2929
3194
|
}
|
|
2930
3195
|
return {
|
|
2931
3196
|
open,
|
|
@@ -3073,7 +3338,7 @@ function createFinishSheet(callbacks) {
|
|
|
3073
3338
|
...note ? [h("div", { class: "grabby-finish-note" }, note)] : [],
|
|
3074
3339
|
h("div", { class: "grabby-finish-actions" }, ...actions)
|
|
3075
3340
|
);
|
|
3076
|
-
_optionalChain([sheet, 'access',
|
|
3341
|
+
_optionalChain([sheet, 'access', _132 => _132.querySelector, 'call', _133 => _133(".grabby-btn-primary:not([disabled])"), 'optionalAccess', _134 => _134.focus, 'call', _135 => _135()]);
|
|
3077
3342
|
}
|
|
3078
3343
|
return {
|
|
3079
3344
|
open(next) {
|
|
@@ -3157,7 +3422,7 @@ function createCoachMark() {
|
|
|
3157
3422
|
let el = null;
|
|
3158
3423
|
function dismiss() {
|
|
3159
3424
|
markSeen();
|
|
3160
|
-
_optionalChain([el, 'optionalAccess',
|
|
3425
|
+
_optionalChain([el, 'optionalAccess', _136 => _136.remove, 'call', _137 => _137()]);
|
|
3161
3426
|
el = null;
|
|
3162
3427
|
}
|
|
3163
3428
|
return {
|
|
@@ -3189,7 +3454,7 @@ function createCoachMark() {
|
|
|
3189
3454
|
},
|
|
3190
3455
|
dismiss,
|
|
3191
3456
|
dispose() {
|
|
3192
|
-
_optionalChain([el, 'optionalAccess',
|
|
3457
|
+
_optionalChain([el, 'optionalAccess', _138 => _138.remove, 'call', _139 => _139()]);
|
|
3193
3458
|
el = null;
|
|
3194
3459
|
removeStyles(STYLE_ID8);
|
|
3195
3460
|
}
|
|
@@ -3284,14 +3549,14 @@ function createOutbox(deps) {
|
|
|
3284
3549
|
if (job.kind === "comment") {
|
|
3285
3550
|
const res2 = await postComment(comment);
|
|
3286
3551
|
if (res2.ok) {
|
|
3287
|
-
if (_optionalChain([deps, 'access',
|
|
3552
|
+
if (_optionalChain([deps, 'access', _140 => _140.getComment, 'call', _141 => _141(job.id), 'optionalAccess', _142 => _142.screenshot, 'optionalAccess', _143 => _143.localId])) add(job.id, "shot");
|
|
3288
3553
|
return "done";
|
|
3289
3554
|
}
|
|
3290
3555
|
if (res2.status === 429 || res2.status >= 500) return "retry";
|
|
3291
3556
|
deps.onState(job.id, "failed", await res2.text().catch(() => String(res2.status)));
|
|
3292
3557
|
return "drop";
|
|
3293
3558
|
}
|
|
3294
|
-
const localId = _optionalChain([comment, 'access',
|
|
3559
|
+
const localId = _optionalChain([comment, 'access', _144 => _144.screenshot, 'optionalAccess', _145 => _145.localId]);
|
|
3295
3560
|
const blob = localId ? await deps.getScreenshot(localId) : null;
|
|
3296
3561
|
if (!blob) return "drop";
|
|
3297
3562
|
const { width, height } = comment.screenshot;
|
|
@@ -3552,7 +3817,7 @@ function createFreezeOverlay() {
|
|
|
3552
3817
|
removeHoverRules();
|
|
3553
3818
|
unfreezeAnimations();
|
|
3554
3819
|
unblockEvents();
|
|
3555
|
-
_optionalChain([overlay, 'optionalAccess',
|
|
3820
|
+
_optionalChain([overlay, 'optionalAccess', _146 => _146.remove, 'call', _147 => _147()]);
|
|
3556
3821
|
removeStyles(FREEZE_STYLE_ID);
|
|
3557
3822
|
overlay = null;
|
|
3558
3823
|
visible = false;
|
|
@@ -3562,6 +3827,8 @@ function createFreezeOverlay() {
|
|
|
3562
3827
|
|
|
3563
3828
|
// src/core/overlay/markers.ts
|
|
3564
3829
|
var LAYER_ID = "__grabby-markers__";
|
|
3830
|
+
var DOC_LAYER_ID = "__grabby-markers-doc__";
|
|
3831
|
+
var CONTEXT_CHECK_MS = 1e3;
|
|
3565
3832
|
var TIP_ID = "__grabby-marker-tip__";
|
|
3566
3833
|
var STYLE_ID9 = "__grabby-marker-styles__";
|
|
3567
3834
|
var SIZE = 22;
|
|
@@ -3573,8 +3840,18 @@ var ICON_EDIT = {
|
|
|
3573
3840
|
size: 12,
|
|
3574
3841
|
shapes: paths("M10.5 2.5l3 3L6 13H3v-3z", "M9 4l3 3")
|
|
3575
3842
|
};
|
|
3843
|
+
function scrollContextOf(el) {
|
|
3844
|
+
for (let cur = el.parentElement; cur && cur !== document.body && cur !== document.documentElement; cur = cur.parentElement) {
|
|
3845
|
+
const style = getComputedStyle(cur);
|
|
3846
|
+
if (style.position === "fixed" || style.position === "sticky") return "screen";
|
|
3847
|
+
if (/(auto|scroll|overlay)/.test(style.overflowY + style.overflowX)) return "screen";
|
|
3848
|
+
}
|
|
3849
|
+
const own = getComputedStyle(el).position;
|
|
3850
|
+
return own === "fixed" || own === "sticky" ? "screen" : "page";
|
|
3851
|
+
}
|
|
3576
3852
|
function createMarkers(deps) {
|
|
3577
3853
|
let layer = null;
|
|
3854
|
+
let docLayer = null;
|
|
3578
3855
|
let tip = null;
|
|
3579
3856
|
let visible = false;
|
|
3580
3857
|
let route = "";
|
|
@@ -3585,13 +3862,27 @@ function createMarkers(deps) {
|
|
|
3585
3862
|
function injectStyles2() {
|
|
3586
3863
|
if (hasStyles(STYLE_ID9)) return;
|
|
3587
3864
|
addStyles(STYLE_ID9, `
|
|
3865
|
+
/*
|
|
3866
|
+
* Page coordinates: the browser moves these with the page as it
|
|
3867
|
+
* scrolls, so they never trail behind their element. (A fixed layer
|
|
3868
|
+
* repositioned from script lags a frame behind fast scrolling.)
|
|
3869
|
+
*/
|
|
3870
|
+
#${DOC_LAYER_ID} {
|
|
3871
|
+
position: absolute;
|
|
3872
|
+
left: 0;
|
|
3873
|
+
top: 0;
|
|
3874
|
+
width: 0;
|
|
3875
|
+
height: 0;
|
|
3876
|
+
pointer-events: none;
|
|
3877
|
+
z-index: ${Z_INDEX_CROSSHAIR};
|
|
3878
|
+
}
|
|
3588
3879
|
#${LAYER_ID} {
|
|
3589
3880
|
position: fixed;
|
|
3590
3881
|
inset: 0;
|
|
3591
3882
|
pointer-events: none;
|
|
3592
3883
|
z-index: ${Z_INDEX_CROSSHAIR};
|
|
3593
3884
|
}
|
|
3594
|
-
|
|
3885
|
+
.grabby-markers-layer .grabby-marker {
|
|
3595
3886
|
position: absolute;
|
|
3596
3887
|
left: 0;
|
|
3597
3888
|
top: 0;
|
|
@@ -3612,22 +3903,24 @@ function createMarkers(deps) {
|
|
|
3612
3903
|
pointer-events: auto;
|
|
3613
3904
|
transition: transform 0.12s ease, box-shadow 0.15s ease;
|
|
3614
3905
|
}
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3906
|
+
.grabby-markers-layer .grabby-marker[hidden] { display: none; }
|
|
3907
|
+
/* Several elements or an area: a green square, like the outline it shows. */
|
|
3908
|
+
.grabby-markers-layer .grabby-marker.grabby-marker-group { border-radius: 6px; background: #16a34a; }
|
|
3909
|
+
.grabby-markers-layer .grabby-marker:hover,
|
|
3910
|
+
.grabby-markers-layer .grabby-marker:focus-visible {
|
|
3618
3911
|
z-index: 1;
|
|
3619
3912
|
outline: none;
|
|
3620
3913
|
box-shadow: 0 0 0 2px #fff, 0 0 0 5px color-mix(in srgb, var(--grabby-accent, #2563eb) 35%, transparent), 0 2px 6px rgba(0, 0, 0, 0.25);
|
|
3621
3914
|
}
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3915
|
+
.grabby-markers-layer .grabby-marker-edit { display: none; }
|
|
3916
|
+
.grabby-markers-layer .grabby-marker:hover .grabby-marker-num,
|
|
3917
|
+
.grabby-markers-layer .grabby-marker:focus-visible .grabby-marker-num { display: none; }
|
|
3918
|
+
.grabby-markers-layer .grabby-marker:hover .grabby-marker-edit,
|
|
3919
|
+
.grabby-markers-layer .grabby-marker:focus-visible .grabby-marker-edit { display: block; }
|
|
3920
|
+
.grabby-markers-layer .grabby-marker-in {
|
|
3628
3921
|
animation: grabby-marker-in 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
3629
3922
|
}
|
|
3630
|
-
|
|
3923
|
+
.grabby-markers-layer .grabby-marker-out {
|
|
3631
3924
|
animation: grabby-marker-out 0.2s ease-out both;
|
|
3632
3925
|
pointer-events: none;
|
|
3633
3926
|
}
|
|
@@ -3661,7 +3954,7 @@ function createMarkers(deps) {
|
|
|
3661
3954
|
to { opacity: 1; transform: none; }
|
|
3662
3955
|
}
|
|
3663
3956
|
@media (prefers-reduced-motion: reduce) {
|
|
3664
|
-
|
|
3957
|
+
.grabby-markers-layer .grabby-marker-in, .grabby-markers-layer .grabby-marker-out, #${TIP_ID} { animation: none; }
|
|
3665
3958
|
}
|
|
3666
3959
|
`);
|
|
3667
3960
|
}
|
|
@@ -3670,11 +3963,15 @@ function createMarkers(deps) {
|
|
|
3670
3963
|
injectStyles2();
|
|
3671
3964
|
layer = document.createElement("div");
|
|
3672
3965
|
layer.id = LAYER_ID;
|
|
3966
|
+
layer.className = "grabby-markers-layer";
|
|
3967
|
+
docLayer = document.createElement("div");
|
|
3968
|
+
docLayer.id = DOC_LAYER_ID;
|
|
3969
|
+
docLayer.className = "grabby-markers-layer";
|
|
3673
3970
|
tip = document.createElement("div");
|
|
3674
3971
|
tip.id = TIP_ID;
|
|
3675
3972
|
tip.hidden = true;
|
|
3676
3973
|
tip.setAttribute("role", "tooltip");
|
|
3677
|
-
getUiRoot().append(layer, tip);
|
|
3974
|
+
getUiRoot().append(docLayer, layer, tip);
|
|
3678
3975
|
return layer;
|
|
3679
3976
|
}
|
|
3680
3977
|
function pageComments() {
|
|
@@ -3692,7 +3989,7 @@ function createMarkers(deps) {
|
|
|
3692
3989
|
button.className = "grabby-marker";
|
|
3693
3990
|
button.dataset.grabbyMarker = comment.id;
|
|
3694
3991
|
button.append(number, svgIcon(ICON_EDIT, "grabby-marker-edit"));
|
|
3695
|
-
const entry = { comment, button, number, element: null, lastLookup: 0 };
|
|
3992
|
+
const entry = { comment, button, number, element: null, lastLookup: 0, context: "page", contextCheckedAt: -Infinity };
|
|
3696
3993
|
button.addEventListener("click", (e) => {
|
|
3697
3994
|
e.preventDefault();
|
|
3698
3995
|
e.stopPropagation();
|
|
@@ -3773,6 +4070,7 @@ function createMarkers(deps) {
|
|
|
3773
4070
|
host2.appendChild(entry.button);
|
|
3774
4071
|
}
|
|
3775
4072
|
entry.comment = comment;
|
|
4073
|
+
entry.button.classList.toggle("grabby-marker-group", !!(_optionalChain([comment, 'access', _148 => _148.members, 'optionalAccess', _149 => _149.length]) || comment.area));
|
|
3776
4074
|
const n = String(i + 1);
|
|
3777
4075
|
entry.number.textContent = n;
|
|
3778
4076
|
entry.button.setAttribute("aria-label", `Comment ${n}: ${preview(comment.comment)}. Click to edit.`);
|
|
@@ -3784,21 +4082,32 @@ function createMarkers(deps) {
|
|
|
3784
4082
|
}
|
|
3785
4083
|
function position(now) {
|
|
3786
4084
|
for (const entry of entries.values()) {
|
|
3787
|
-
if (!_optionalChain([entry, 'access',
|
|
4085
|
+
if (!_optionalChain([entry, 'access', _150 => _150.element, 'optionalAccess', _151 => _151.isConnected])) {
|
|
3788
4086
|
entry.element = null;
|
|
3789
4087
|
if (now - entry.lastLookup >= LOOKUP_RETRY_MS) {
|
|
3790
4088
|
entry.lastLookup = now;
|
|
3791
4089
|
entry.element = deps.findElement(entry.comment);
|
|
3792
4090
|
}
|
|
3793
4091
|
}
|
|
3794
|
-
const rect = _optionalChain([entry, 'access',
|
|
4092
|
+
const rect = _optionalChain([entry, 'access', _152 => _152.element, 'optionalAccess', _153 => _153.getBoundingClientRect, 'call', _154 => _154()]);
|
|
3795
4093
|
if (!rect || rect.width === 0 && rect.height === 0) {
|
|
3796
4094
|
entry.button.hidden = true;
|
|
3797
4095
|
continue;
|
|
3798
4096
|
}
|
|
4097
|
+
if (now - entry.contextCheckedAt >= CONTEXT_CHECK_MS) {
|
|
4098
|
+
entry.contextCheckedAt = now;
|
|
4099
|
+
entry.context = scrollContextOf(entry.element);
|
|
4100
|
+
const home = entry.context === "page" ? docLayer : layer;
|
|
4101
|
+
if (home && entry.button.parentElement !== home) home.appendChild(entry.button);
|
|
4102
|
+
}
|
|
3799
4103
|
const pin = _nullishCoalesce(entry.comment.pin, () => ( { x: 1, y: 0 }));
|
|
3800
|
-
const
|
|
3801
|
-
|
|
4104
|
+
const maxX = (document.documentElement.clientWidth || window.innerWidth) - SIZE;
|
|
4105
|
+
let x = Math.max(0, Math.min(rect.left + pin.x * rect.width - SIZE / 2, maxX));
|
|
4106
|
+
let y = rect.top + pin.y * rect.height - SIZE / 2;
|
|
4107
|
+
if (entry.context === "page") {
|
|
4108
|
+
x += window.scrollX;
|
|
4109
|
+
y = Math.max(0, y + window.scrollY);
|
|
4110
|
+
}
|
|
3802
4111
|
entry.button.hidden = false;
|
|
3803
4112
|
entry.button.style.transform = `translate(${Math.round(x)}px, ${Math.round(y)}px)`;
|
|
3804
4113
|
}
|
|
@@ -3828,6 +4137,9 @@ function createMarkers(deps) {
|
|
|
3828
4137
|
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
3829
4138
|
rafId = null;
|
|
3830
4139
|
}
|
|
4140
|
+
function handleScroll() {
|
|
4141
|
+
if (visible && entries.size) position(performance.now());
|
|
4142
|
+
}
|
|
3831
4143
|
return {
|
|
3832
4144
|
setVisible(next) {
|
|
3833
4145
|
if (next === visible) return;
|
|
@@ -3835,8 +4147,10 @@ function createMarkers(deps) {
|
|
|
3835
4147
|
if (next) {
|
|
3836
4148
|
route = deps.currentRoute();
|
|
3837
4149
|
lastRouteCheck = performance.now();
|
|
4150
|
+
document.addEventListener("scroll", handleScroll, { capture: true, passive: true });
|
|
3838
4151
|
sync(true);
|
|
3839
4152
|
} else {
|
|
4153
|
+
document.removeEventListener("scroll", handleScroll, true);
|
|
3840
4154
|
stop();
|
|
3841
4155
|
hideTip();
|
|
3842
4156
|
if (hovered) endHover(hovered);
|
|
@@ -3847,13 +4161,16 @@ function createMarkers(deps) {
|
|
|
3847
4161
|
sync(false);
|
|
3848
4162
|
},
|
|
3849
4163
|
isMarkerElement(el) {
|
|
3850
|
-
return
|
|
4164
|
+
return [layer, docLayer].some((l) => !!l && (l === el || l.contains(el)));
|
|
3851
4165
|
},
|
|
3852
4166
|
dispose() {
|
|
3853
4167
|
stop();
|
|
4168
|
+
document.removeEventListener("scroll", handleScroll, true);
|
|
3854
4169
|
entries.clear();
|
|
3855
|
-
_optionalChain([layer, 'optionalAccess',
|
|
3856
|
-
_optionalChain([
|
|
4170
|
+
_optionalChain([layer, 'optionalAccess', _155 => _155.remove, 'call', _156 => _156()]);
|
|
4171
|
+
_optionalChain([docLayer, 'optionalAccess', _157 => _157.remove, 'call', _158 => _158()]);
|
|
4172
|
+
docLayer = null;
|
|
4173
|
+
_optionalChain([tip, 'optionalAccess', _159 => _159.remove, 'call', _160 => _160()]);
|
|
3857
4174
|
layer = null;
|
|
3858
4175
|
tip = null;
|
|
3859
4176
|
hovered = null;
|
|
@@ -3863,11 +4180,141 @@ function createMarkers(deps) {
|
|
|
3863
4180
|
};
|
|
3864
4181
|
}
|
|
3865
4182
|
|
|
4183
|
+
// src/core/overlay/group-outline.ts
|
|
4184
|
+
var LAYER_ID2 = "__grabby-group__";
|
|
4185
|
+
var STYLE_ID10 = "__grabby-group-styles__";
|
|
4186
|
+
var GREEN = "#16a34a";
|
|
4187
|
+
function createGroupOutline() {
|
|
4188
|
+
let layer = null;
|
|
4189
|
+
let marqueeEl = null;
|
|
4190
|
+
let labelEl = null;
|
|
4191
|
+
let boxes = [];
|
|
4192
|
+
let spec = null;
|
|
4193
|
+
let rafId = null;
|
|
4194
|
+
function ensureLayer() {
|
|
4195
|
+
if (layer) return layer;
|
|
4196
|
+
if (!hasStyles(STYLE_ID10)) {
|
|
4197
|
+
addStyles(STYLE_ID10, `
|
|
4198
|
+
#${LAYER_ID2} { position: fixed; inset: 0; pointer-events: none; z-index: ${Z_INDEX_OVERLAY}; }
|
|
4199
|
+
#${LAYER_ID2} .grabby-group-box {
|
|
4200
|
+
position: absolute; left: 0; top: 0; box-sizing: border-box;
|
|
4201
|
+
border: 2px dashed ${GREEN}; border-radius: 4px; background: rgba(22, 163, 74, 0.08);
|
|
4202
|
+
}
|
|
4203
|
+
#${LAYER_ID2} .grabby-group-marquee {
|
|
4204
|
+
position: absolute; left: 0; top: 0; box-sizing: border-box;
|
|
4205
|
+
border: 1px solid var(--grabby-accent, #2563eb); border-radius: 2px;
|
|
4206
|
+
background: color-mix(in srgb, var(--grabby-accent, #2563eb) 8%, transparent);
|
|
4207
|
+
}
|
|
4208
|
+
#${LAYER_ID2} .grabby-group-label {
|
|
4209
|
+
position: absolute; left: 0; top: 0; padding: 2px 6px; border-radius: 3px;
|
|
4210
|
+
background: ${GREEN}; color: #fff; white-space: nowrap;
|
|
4211
|
+
font: 600 11px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
4212
|
+
}
|
|
4213
|
+
#${LAYER_ID2} [hidden] { display: none; }
|
|
4214
|
+
`);
|
|
4215
|
+
}
|
|
4216
|
+
layer = document.createElement("div");
|
|
4217
|
+
layer.id = LAYER_ID2;
|
|
4218
|
+
getUiRoot().appendChild(layer);
|
|
4219
|
+
return layer;
|
|
4220
|
+
}
|
|
4221
|
+
function place(el, b) {
|
|
4222
|
+
el.style.transform = `translate(${Math.round(b.left)}px, ${Math.round(b.top)}px)`;
|
|
4223
|
+
el.style.width = `${Math.max(0, Math.round(b.right - b.left))}px`;
|
|
4224
|
+
el.style.height = `${Math.max(0, Math.round(b.bottom - b.top))}px`;
|
|
4225
|
+
}
|
|
4226
|
+
function currentBoxes() {
|
|
4227
|
+
if (!spec) return [];
|
|
4228
|
+
if ("area" in spec) return spec.element.isConnected ? [areaToBox(spec.element, spec.area)] : [];
|
|
4229
|
+
return spec.elements.flatMap((el) => {
|
|
4230
|
+
if (!el.isConnected) return [];
|
|
4231
|
+
const r = el.getBoundingClientRect();
|
|
4232
|
+
return r.width === 0 && r.height === 0 ? [] : [{ left: r.left, top: r.top, right: r.right, bottom: r.bottom }];
|
|
4233
|
+
});
|
|
4234
|
+
}
|
|
4235
|
+
function render() {
|
|
4236
|
+
const host2 = ensureLayer();
|
|
4237
|
+
const list = currentBoxes();
|
|
4238
|
+
while (boxes.length < list.length) {
|
|
4239
|
+
const b = document.createElement("div");
|
|
4240
|
+
b.className = "grabby-group-box";
|
|
4241
|
+
host2.insertBefore(b, labelEl);
|
|
4242
|
+
boxes.push(b);
|
|
4243
|
+
}
|
|
4244
|
+
boxes.forEach((b, i) => {
|
|
4245
|
+
b.hidden = i >= list.length;
|
|
4246
|
+
if (i < list.length) place(b, list[i]);
|
|
4247
|
+
});
|
|
4248
|
+
if (labelEl && !labelEl.hidden) {
|
|
4249
|
+
const u = spec && "elements" in spec ? unionBox(spec.elements) : _nullishCoalesce(list[0], () => ( null));
|
|
4250
|
+
if (u) labelEl.style.transform = `translate(${Math.round(u.left)}px, ${Math.round(Math.max(0, u.top - 20))}px)`;
|
|
4251
|
+
}
|
|
4252
|
+
}
|
|
4253
|
+
function track() {
|
|
4254
|
+
rafId = null;
|
|
4255
|
+
if (!spec) return;
|
|
4256
|
+
render();
|
|
4257
|
+
rafId = requestAnimationFrame(track);
|
|
4258
|
+
}
|
|
4259
|
+
function stop() {
|
|
4260
|
+
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
4261
|
+
rafId = null;
|
|
4262
|
+
}
|
|
4263
|
+
return {
|
|
4264
|
+
marquee(box) {
|
|
4265
|
+
if (!box) {
|
|
4266
|
+
if (marqueeEl) marqueeEl.hidden = true;
|
|
4267
|
+
return;
|
|
4268
|
+
}
|
|
4269
|
+
const host2 = ensureLayer();
|
|
4270
|
+
if (!marqueeEl) {
|
|
4271
|
+
marqueeEl = document.createElement("div");
|
|
4272
|
+
marqueeEl.className = "grabby-group-marquee";
|
|
4273
|
+
host2.appendChild(marqueeEl);
|
|
4274
|
+
}
|
|
4275
|
+
marqueeEl.hidden = false;
|
|
4276
|
+
place(marqueeEl, box);
|
|
4277
|
+
},
|
|
4278
|
+
show(next, label) {
|
|
4279
|
+
spec = next;
|
|
4280
|
+
const host2 = ensureLayer();
|
|
4281
|
+
if (!labelEl) {
|
|
4282
|
+
labelEl = document.createElement("div");
|
|
4283
|
+
labelEl.className = "grabby-group-label";
|
|
4284
|
+
host2.appendChild(labelEl);
|
|
4285
|
+
}
|
|
4286
|
+
labelEl.hidden = !label;
|
|
4287
|
+
labelEl.textContent = _nullishCoalesce(label, () => ( ""));
|
|
4288
|
+
stop();
|
|
4289
|
+
track();
|
|
4290
|
+
},
|
|
4291
|
+
hide() {
|
|
4292
|
+
spec = null;
|
|
4293
|
+
stop();
|
|
4294
|
+
for (const b of boxes) b.hidden = true;
|
|
4295
|
+
if (labelEl) labelEl.hidden = true;
|
|
4296
|
+
},
|
|
4297
|
+
isVisible() {
|
|
4298
|
+
return spec !== null;
|
|
4299
|
+
},
|
|
4300
|
+
dispose() {
|
|
4301
|
+
stop();
|
|
4302
|
+
_optionalChain([layer, 'optionalAccess', _161 => _161.remove, 'call', _162 => _162()]);
|
|
4303
|
+
layer = null;
|
|
4304
|
+
marqueeEl = null;
|
|
4305
|
+
labelEl = null;
|
|
4306
|
+
boxes = [];
|
|
4307
|
+
spec = null;
|
|
4308
|
+
removeStyles(STYLE_ID10);
|
|
4309
|
+
}
|
|
4310
|
+
};
|
|
4311
|
+
}
|
|
4312
|
+
|
|
3866
4313
|
// src/core/overlay/select-feedback.ts
|
|
3867
|
-
var
|
|
4314
|
+
var STYLE_ID11 = "__grabby-feedback-styles__";
|
|
3868
4315
|
function injectStyles() {
|
|
3869
|
-
if (hasStyles(
|
|
3870
|
-
addStyles(
|
|
4316
|
+
if (hasStyles(STYLE_ID11)) return;
|
|
4317
|
+
addStyles(STYLE_ID11, `
|
|
3871
4318
|
@keyframes grabby-flash {
|
|
3872
4319
|
0% { opacity: 1; }
|
|
3873
4320
|
100% { opacity: 0; transform: scale(1.02); }
|
|
@@ -3946,7 +4393,7 @@ function showSelectFeedback(element, label = "Selected") {
|
|
|
3946
4393
|
setTimeout(cleanup, 1200);
|
|
3947
4394
|
}
|
|
3948
4395
|
function disposeFeedbackStyles() {
|
|
3949
|
-
removeStyles(
|
|
4396
|
+
removeStyles(STYLE_ID11);
|
|
3950
4397
|
}
|
|
3951
4398
|
|
|
3952
4399
|
// src/core/storage/history-persistence.ts
|
|
@@ -4037,7 +4484,7 @@ function clearPersistedHistory() {
|
|
|
4037
4484
|
var baselineFrame = null;
|
|
4038
4485
|
var baselineCache = /* @__PURE__ */ new Map();
|
|
4039
4486
|
function baselineDoc() {
|
|
4040
|
-
if (_optionalChain([baselineFrame, 'optionalAccess',
|
|
4487
|
+
if (_optionalChain([baselineFrame, 'optionalAccess', _163 => _163.isConnected]) && baselineFrame.contentDocument) return baselineFrame.contentDocument;
|
|
4041
4488
|
try {
|
|
4042
4489
|
baselineFrame = document.createElement("iframe");
|
|
4043
4490
|
baselineFrame.setAttribute("aria-hidden", "true");
|
|
@@ -4067,8 +4514,8 @@ function baselineFor(tag, type, props) {
|
|
|
4067
4514
|
const missing = props.filter((p) => !cached.has(p));
|
|
4068
4515
|
if (missing.length > 0) {
|
|
4069
4516
|
const doc = baselineDoc();
|
|
4070
|
-
const view = _optionalChain([doc, 'optionalAccess',
|
|
4071
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
4517
|
+
const view = _optionalChain([doc, 'optionalAccess', _164 => _164.defaultView]);
|
|
4518
|
+
if (_optionalChain([doc, 'optionalAccess', _165 => _165.body]) && view) {
|
|
4072
4519
|
const probe = doc.createElement(tag);
|
|
4073
4520
|
if (type) probe.setAttribute("type", type);
|
|
4074
4521
|
doc.body.appendChild(probe);
|
|
@@ -4082,7 +4529,7 @@ function baselineFor(tag, type, props) {
|
|
|
4082
4529
|
return cached;
|
|
4083
4530
|
}
|
|
4084
4531
|
function disposeStyleBaseline() {
|
|
4085
|
-
_optionalChain([baselineFrame, 'optionalAccess',
|
|
4532
|
+
_optionalChain([baselineFrame, 'optionalAccess', _166 => _166.remove, 'call', _167 => _167()]);
|
|
4086
4533
|
baselineFrame = null;
|
|
4087
4534
|
baselineCache.clear();
|
|
4088
4535
|
}
|
|
@@ -4184,7 +4631,7 @@ function states(el) {
|
|
|
4184
4631
|
}
|
|
4185
4632
|
function actionFacts(el) {
|
|
4186
4633
|
const f = {};
|
|
4187
|
-
const imgAlt = _nullishCoalesce(_optionalChain([el, 'access',
|
|
4634
|
+
const imgAlt = _nullishCoalesce(_optionalChain([el, 'access', _168 => _168.querySelector, 'call', _169 => _169("img[alt]"), 'optionalAccess', _170 => _170.getAttribute, 'call', _171 => _171("alt")]), () => ( ""));
|
|
4188
4635
|
put(f, "label", accessibleLabel(el) || textOf(el, 80) || redact(_nullishCoalesce(el.getAttribute("title"), () => ( ""))) || redact(imgAlt));
|
|
4189
4636
|
if (el.tagName === "A") put(f, "href", sanitizeUrl(_nullishCoalesce(el.getAttribute("href"), () => ( ""))));
|
|
4190
4637
|
else if (el.tagName === "BUTTON" || el.tagName === "INPUT") put(f, "type", _nullishCoalesce(el.getAttribute("type"), () => ( (el.tagName === "BUTTON" ? "submit" : ""))));
|
|
@@ -4233,7 +4680,7 @@ function mediaFacts(el) {
|
|
|
4233
4680
|
put(f, "label", accessibleLabel(el) || textOf(_nullishCoalesce(el.querySelector("title"), () => ( el)), 40));
|
|
4234
4681
|
put(f, "viewBox", _nullishCoalesce(el.getAttribute("viewBox"), () => ( "")));
|
|
4235
4682
|
} else if (el.tagName === "VIDEO" || el.tagName === "AUDIO" || el.tagName === "IFRAME") {
|
|
4236
|
-
put(f, "src", basename3(_nullishCoalesce(_nullishCoalesce(el.getAttribute("src"), () => ( _optionalChain([el, 'access',
|
|
4683
|
+
put(f, "src", basename3(_nullishCoalesce(_nullishCoalesce(el.getAttribute("src"), () => ( _optionalChain([el, 'access', _172 => _172.querySelector, 'call', _173 => _173("source"), 'optionalAccess', _174 => _174.getAttribute, 'call', _175 => _175("src")]))), () => ( ""))));
|
|
4237
4684
|
put(f, "title", redact(_nullishCoalesce(el.getAttribute("title"), () => ( ""))));
|
|
4238
4685
|
}
|
|
4239
4686
|
put(f, "size", size(el));
|
|
@@ -4241,8 +4688,8 @@ function mediaFacts(el) {
|
|
|
4241
4688
|
return f;
|
|
4242
4689
|
}
|
|
4243
4690
|
function childLabel(child, resolver) {
|
|
4244
|
-
const resolved = _optionalChain([resolver, 'optionalCall',
|
|
4245
|
-
if (_optionalChain([resolved, 'optionalAccess',
|
|
4691
|
+
const resolved = _optionalChain([resolver, 'optionalCall', _176 => _176(child)]);
|
|
4692
|
+
if (_optionalChain([resolved, 'optionalAccess', _177 => _177.name]) && resolved.hostElement === child) return resolved.name;
|
|
4246
4693
|
const tag = child.tagName.toLowerCase();
|
|
4247
4694
|
if (/^h[1-6]$/.test(tag)) return "heading";
|
|
4248
4695
|
if (tag === "a") return "link";
|
|
@@ -4277,7 +4724,7 @@ function sectionFacts(el, resolver) {
|
|
|
4277
4724
|
const f = {};
|
|
4278
4725
|
put(f, "title", redact(el.ownerDocument.title));
|
|
4279
4726
|
put(f, "viewport", `${window.innerWidth}\xD7${window.innerHeight}`);
|
|
4280
|
-
const regions = Array.from(el.querySelectorAll('header, nav, main, aside, footer, section, [role="region"]')).filter((r) => !_optionalChain([r, 'access',
|
|
4727
|
+
const regions = Array.from(el.querySelectorAll('header, nav, main, aside, footer, section, [role="region"]')).filter((r) => !_optionalChain([r, 'access', _178 => _178.parentElement, 'optionalAccess', _179 => _179.closest, 'call', _180 => _180('header, nav, main, aside, footer, section, [role="region"]')]) || r.parentElement === el).slice(0, 8).map((r) => {
|
|
4281
4728
|
const heading = firstHeading2(r);
|
|
4282
4729
|
return heading ? `${r.tagName.toLowerCase()} "${truncate(heading, 30)}"` : r.tagName.toLowerCase();
|
|
4283
4730
|
});
|
|
@@ -4334,22 +4781,22 @@ function isAppFile(file) {
|
|
|
4334
4781
|
return !!file && !/(^|[\\/])node_modules[\\/]/.test(file);
|
|
4335
4782
|
}
|
|
4336
4783
|
function resolveStack(el, deps) {
|
|
4337
|
-
const comp = _nullishCoalesce(_optionalChain([deps, 'access',
|
|
4784
|
+
const comp = _nullishCoalesce(_optionalChain([deps, 'access', _181 => _181.componentResolver, 'optionalCall', _182 => _182(el)]), () => ( null));
|
|
4338
4785
|
const frames = [];
|
|
4339
4786
|
const named = [];
|
|
4340
|
-
for (const entry of _nullishCoalesce(_optionalChain([comp, 'optionalAccess',
|
|
4787
|
+
for (const entry of _nullishCoalesce(_optionalChain([comp, 'optionalAccess', _183 => _183.stack]), () => ( []))) {
|
|
4341
4788
|
const src = entry.filePath !== void 0 ? { filePath: entry.filePath, line: _nullishCoalesce(entry.line, () => ( null)) } : entry.hostElement && deps.sourceResolver ? deps.sourceResolver(entry.hostElement) : null;
|
|
4342
|
-
const frame = { name: entry.name, file: _nullishCoalesce(_optionalChain([src, 'optionalAccess',
|
|
4789
|
+
const frame = { name: entry.name, file: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _184 => _184.filePath]), () => ( null)), line: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _185 => _185.line]), () => ( null)) };
|
|
4343
4790
|
named.push(frame);
|
|
4344
4791
|
if (isAppFile(frame.file) && frames.length < MAX_STACK) frames.push(frame);
|
|
4345
4792
|
}
|
|
4346
|
-
return { component: _nullishCoalesce(_optionalChain([comp, 'optionalAccess',
|
|
4793
|
+
return { component: _nullishCoalesce(_optionalChain([comp, 'optionalAccess', _186 => _186.name]), () => ( null)), frames: frames.length > 0 ? frames : named.slice(0, 2) };
|
|
4347
4794
|
}
|
|
4348
4795
|
function resolveSource(el, deps, frames) {
|
|
4349
|
-
const own = _optionalChain([deps, 'access',
|
|
4796
|
+
const own = _optionalChain([deps, 'access', _187 => _187.sourceResolver, 'optionalCall', _188 => _188(el)]);
|
|
4350
4797
|
if (own && isAppFile(own.filePath)) return { file: own.filePath, line: own.line, column: own.column };
|
|
4351
4798
|
const first = frames.find((f) => isAppFile(f.file));
|
|
4352
|
-
return _optionalChain([first, 'optionalAccess',
|
|
4799
|
+
return _optionalChain([first, 'optionalAccess', _189 => _189.file]) ? { file: first.file, line: first.line, column: null } : null;
|
|
4353
4800
|
}
|
|
4354
4801
|
function captureTarget(el, deps) {
|
|
4355
4802
|
const cleanClasses = _nullishCoalesce(deps.cleanClasses, () => ( ((list) => list.filter((c) => !isNoiseClass(c)))));
|
|
@@ -4369,6 +4816,21 @@ function captureTarget(el, deps) {
|
|
|
4369
4816
|
extra
|
|
4370
4817
|
};
|
|
4371
4818
|
}
|
|
4819
|
+
var MEMBER_PREVIEW = 120;
|
|
4820
|
+
function captureMember(el, deps) {
|
|
4821
|
+
const cleanClasses = _nullishCoalesce(deps.cleanClasses, () => ( ((list) => list.filter((c) => !isNoiseClass(c)))));
|
|
4822
|
+
const kind = detectKind(el);
|
|
4823
|
+
const { component, frames } = resolveStack(el, deps);
|
|
4824
|
+
return {
|
|
4825
|
+
kind,
|
|
4826
|
+
tag: el.tagName.toLowerCase(),
|
|
4827
|
+
component,
|
|
4828
|
+
source: resolveSource(el, deps, frames),
|
|
4829
|
+
selector: buildUniqueSelector(el),
|
|
4830
|
+
preview: kind === "section" ? `<${el.tagName.toLowerCase()}>` : truncate(buildPreview(el, cleanClasses), MEMBER_PREVIEW),
|
|
4831
|
+
label: describeElement(el)
|
|
4832
|
+
};
|
|
4833
|
+
}
|
|
4372
4834
|
|
|
4373
4835
|
// src/core/capture/screenshot.ts
|
|
4374
4836
|
var MAX_SIDE = 1200;
|
|
@@ -4400,7 +4862,7 @@ function sandboxHtml() {
|
|
|
4400
4862
|
return policy ? policy.createHTML(SANDBOX_HTML) : null;
|
|
4401
4863
|
}
|
|
4402
4864
|
async function getSandbox() {
|
|
4403
|
-
if (_optionalChain([sandbox, 'optionalAccess',
|
|
4865
|
+
if (_optionalChain([sandbox, 'optionalAccess', _190 => _190.isConnected])) return sandbox;
|
|
4404
4866
|
const frame = document.createElement("iframe");
|
|
4405
4867
|
frame.setAttribute("aria-hidden", "true");
|
|
4406
4868
|
frame.setAttribute("tabindex", "-1");
|
|
@@ -4424,7 +4886,7 @@ async function getSandbox() {
|
|
|
4424
4886
|
return frame;
|
|
4425
4887
|
}
|
|
4426
4888
|
function disposeScreenshotSandbox() {
|
|
4427
|
-
_optionalChain([sandbox, 'optionalAccess',
|
|
4889
|
+
_optionalChain([sandbox, 'optionalAccess', _191 => _191.remove, 'call', _192 => _192()]);
|
|
4428
4890
|
sandbox = null;
|
|
4429
4891
|
}
|
|
4430
4892
|
function withTimeout(promise, ms) {
|
|
@@ -4442,16 +4904,28 @@ function withTimeout(promise, ms) {
|
|
|
4442
4904
|
);
|
|
4443
4905
|
});
|
|
4444
4906
|
}
|
|
4445
|
-
|
|
4907
|
+
var MAX_CLIP_DEPTH = 4e3;
|
|
4908
|
+
var clamp = (v, max) => Math.min(Math.max(v, 0), max);
|
|
4909
|
+
async function captureScreenshot(el, clip) {
|
|
4446
4910
|
if (typeof window === "undefined" || !el.isConnected) return null;
|
|
4447
4911
|
const rect = el.getBoundingClientRect();
|
|
4448
4912
|
if (rect.width < 1 || rect.height < 1) return null;
|
|
4449
|
-
const
|
|
4450
|
-
const
|
|
4913
|
+
const fullWidth = Math.min(rect.width, document.documentElement.scrollWidth || rect.width);
|
|
4914
|
+
const region = clip ? {
|
|
4915
|
+
x: clamp(clip.left - rect.left, fullWidth),
|
|
4916
|
+
y: clamp(clip.top - rect.top, rect.height),
|
|
4917
|
+
right: clamp(clip.right - rect.left, fullWidth),
|
|
4918
|
+
bottom: clamp(clip.bottom - rect.top, rect.height)
|
|
4919
|
+
} : null;
|
|
4920
|
+
if (region && (region.right - region.x < 1 || region.bottom - region.y < 1 || region.bottom > MAX_CLIP_DEPTH)) return null;
|
|
4921
|
+
const cssWidth = fullWidth;
|
|
4922
|
+
const cssHeight = region ? region.bottom : Math.min(rect.height, MAX_CSS_HEIGHT);
|
|
4923
|
+
const outWidth = region ? region.right - region.x : cssWidth;
|
|
4924
|
+
const outHeight = region ? Math.min(region.bottom - region.y, MAX_CSS_HEIGHT) : cssHeight;
|
|
4451
4925
|
const dpr = window.devicePixelRatio || 1;
|
|
4452
|
-
const scale = Math.min(dpr, MAX_SIDE / Math.max(
|
|
4926
|
+
const scale = Math.min(dpr, MAX_SIDE / Math.max(outWidth, outHeight));
|
|
4453
4927
|
const render = async () => {
|
|
4454
|
-
const { createContext, destroyContext, domToBlob } = await Promise.resolve().then(() => _interopRequireWildcard(require("modern-screenshot")));
|
|
4928
|
+
const { createContext, destroyContext, domToBlob, domToCanvas } = await Promise.resolve().then(() => _interopRequireWildcard(require("modern-screenshot")));
|
|
4455
4929
|
const context = await createContext(el, {
|
|
4456
4930
|
width: cssWidth,
|
|
4457
4931
|
height: cssHeight,
|
|
@@ -4468,13 +4942,22 @@ async function captureScreenshot(el) {
|
|
|
4468
4942
|
context.sandbox = await getSandbox();
|
|
4469
4943
|
let blob;
|
|
4470
4944
|
try {
|
|
4471
|
-
|
|
4945
|
+
if (region) {
|
|
4946
|
+
const full = await domToCanvas(context);
|
|
4947
|
+
const crop = document.createElement("canvas");
|
|
4948
|
+
crop.width = Math.max(1, Math.round(outWidth * scale));
|
|
4949
|
+
crop.height = Math.max(1, Math.round(outHeight * scale));
|
|
4950
|
+
_optionalChain([crop, 'access', _193 => _193.getContext, 'call', _194 => _194("2d"), 'optionalAccess', _195 => _195.drawImage, 'call', _196 => _196(full, region.x * scale, region.y * scale, outWidth * scale, outHeight * scale, 0, 0, crop.width, crop.height)]);
|
|
4951
|
+
blob = await new Promise((resolve) => crop.toBlob(resolve, "image/webp", 0.8));
|
|
4952
|
+
} else {
|
|
4953
|
+
blob = await domToBlob(context);
|
|
4954
|
+
}
|
|
4472
4955
|
} finally {
|
|
4473
4956
|
context.sandbox = void 0;
|
|
4474
4957
|
destroyContext(context);
|
|
4475
4958
|
}
|
|
4476
4959
|
if (!blob) return null;
|
|
4477
|
-
return { blob, width: Math.round(
|
|
4960
|
+
return { blob, width: Math.round(outWidth * scale), height: Math.round(outHeight * scale) };
|
|
4478
4961
|
};
|
|
4479
4962
|
return withTimeout(render(), TIMEOUT_MS + 1e3);
|
|
4480
4963
|
}
|
|
@@ -4584,7 +5067,7 @@ function resolveComponent(element) {
|
|
|
4584
5067
|
name: cleanComponentName(owning.constructor.name),
|
|
4585
5068
|
hostElement: _nullishCoalesce(host2, () => ( walk.parentElement))
|
|
4586
5069
|
});
|
|
4587
|
-
current = _nullishCoalesce(_nullishCoalesce(_optionalChain([host2, 'optionalAccess',
|
|
5070
|
+
current = _nullishCoalesce(_nullishCoalesce(_optionalChain([host2, 'optionalAccess', _197 => _197.parentElement]), () => ( _optionalChain([walk, 'access', _198 => _198.parentElement, 'optionalAccess', _199 => _199.parentElement]))), () => ( null));
|
|
4588
5071
|
while (current) {
|
|
4589
5072
|
const comp = ng.getComponent(current);
|
|
4590
5073
|
if (comp && !seen2.has(comp)) {
|
|
@@ -4718,14 +5201,14 @@ function resolveComponent2(element) {
|
|
|
4718
5201
|
let current = fiber;
|
|
4719
5202
|
while (current && stack.length < MAX_STACK2) {
|
|
4720
5203
|
const name = getComponentName(current.type);
|
|
4721
|
-
if (name && !isNoise(name) && _optionalChain([stack, 'access',
|
|
5204
|
+
if (name && !isNoise(name) && _optionalChain([stack, 'access', _200 => _200[stack.length - 1], 'optionalAccess', _201 => _201.name]) !== name) {
|
|
4722
5205
|
stack.push({ name, hostElement: findHostElement(current) });
|
|
4723
5206
|
}
|
|
4724
5207
|
current = current.return;
|
|
4725
5208
|
}
|
|
4726
5209
|
return {
|
|
4727
|
-
name: _nullishCoalesce(_optionalChain([stack, 'access',
|
|
4728
|
-
hostElement: _nullishCoalesce(_optionalChain([stack, 'access',
|
|
5210
|
+
name: _nullishCoalesce(_optionalChain([stack, 'access', _202 => _202[0], 'optionalAccess', _203 => _203.name]), () => ( null)),
|
|
5211
|
+
hostElement: _nullishCoalesce(_optionalChain([stack, 'access', _204 => _204[0], 'optionalAccess', _205 => _205.hostElement]), () => ( null)),
|
|
4729
5212
|
stack
|
|
4730
5213
|
};
|
|
4731
5214
|
}
|
|
@@ -4736,7 +5219,7 @@ var LOCATION = /^(.*?):(\d+):(\d+)(?::([A-Za-z_$][\w$.]*))?$/;
|
|
|
4736
5219
|
function resolveSource3(element) {
|
|
4737
5220
|
let current = element;
|
|
4738
5221
|
while (current) {
|
|
4739
|
-
const raw = _optionalChain([current, 'access',
|
|
5222
|
+
const raw = _optionalChain([current, 'access', _206 => _206.getAttribute, 'optionalCall', _207 => _207(SOURCE_ATTRIBUTE)]);
|
|
4740
5223
|
if (raw) return parseLocation(raw);
|
|
4741
5224
|
current = current.parentElement;
|
|
4742
5225
|
}
|
|
@@ -4748,7 +5231,7 @@ function parseLocation(raw) {
|
|
|
4748
5231
|
return { filePath: match[1], line: Number(match[2]), column: Number(match[3]) };
|
|
4749
5232
|
}
|
|
4750
5233
|
function ownStamp(element) {
|
|
4751
|
-
const raw = _optionalChain([element, 'optionalAccess',
|
|
5234
|
+
const raw = _optionalChain([element, 'optionalAccess', _208 => _208.getAttribute, 'optionalCall', _209 => _209(SOURCE_ATTRIBUTE)]);
|
|
4752
5235
|
if (!raw) return null;
|
|
4753
5236
|
const match = LOCATION.exec(raw);
|
|
4754
5237
|
if (!match) return { file: raw, line: null, column: null, name: null };
|
|
@@ -4763,8 +5246,8 @@ function nameFromStamps(result) {
|
|
|
4763
5246
|
const stack = [];
|
|
4764
5247
|
for (const entry of result.stack) {
|
|
4765
5248
|
const stamp = ownStamp(entry.hostElement);
|
|
4766
|
-
const name = _nullishCoalesce(_optionalChain([stamp, 'optionalAccess',
|
|
4767
|
-
if (name && _optionalChain([stack, 'access',
|
|
5249
|
+
const name = _nullishCoalesce(_optionalChain([stamp, 'optionalAccess', _210 => _210.name]), () => ( (stamp ? baseName(stamp.file) : null)));
|
|
5250
|
+
if (name && _optionalChain([stack, 'access', _211 => _211[stack.length - 1], 'optionalAccess', _212 => _212.name]) !== name) stack.push({ name, hostElement: entry.hostElement });
|
|
4768
5251
|
}
|
|
4769
5252
|
return stack[0] ? { name: stack[0].name, hostElement: stack[0].hostElement, stack } : null;
|
|
4770
5253
|
}
|
|
@@ -4800,7 +5283,7 @@ function vue3Name(inst) {
|
|
|
4800
5283
|
return t.__name || t.name || t.displayName || (t.__file ? baseName(t.__file) : null);
|
|
4801
5284
|
}
|
|
4802
5285
|
function vue3Host(inst) {
|
|
4803
|
-
return firstElement(_nullishCoalesce(_optionalChain([inst, 'access',
|
|
5286
|
+
return firstElement(_nullishCoalesce(_optionalChain([inst, 'access', _213 => _213.subTree, 'optionalAccess', _214 => _214.el]), () => ( _optionalChain([inst, 'access', _215 => _215.vnode, 'optionalAccess', _216 => _216.el]))));
|
|
4804
5287
|
}
|
|
4805
5288
|
function vue2Owner(el) {
|
|
4806
5289
|
let current = el;
|
|
@@ -4840,7 +5323,7 @@ function resolveVueComponent(el) {
|
|
|
4840
5323
|
}
|
|
4841
5324
|
function resolveVueSource(el) {
|
|
4842
5325
|
const inst3 = vue3Owner(el);
|
|
4843
|
-
const file = _nullishCoalesce(_optionalChain([inst3, 'optionalAccess',
|
|
5326
|
+
const file = _nullishCoalesce(_optionalChain([inst3, 'optionalAccess', _217 => _217.type, 'optionalAccess', _218 => _218.__file]), () => ( _optionalChain([vue2Owner, 'call', _219 => _219(el), 'optionalAccess', _220 => _220.$options, 'optionalAccess', _221 => _221.__file])));
|
|
4844
5327
|
return file ? { filePath: relativizePath(file), line: null, column: null } : NO_SOURCE;
|
|
4845
5328
|
}
|
|
4846
5329
|
var vueAdapter = {
|
|
@@ -4856,19 +5339,19 @@ function metaOf(el) {
|
|
|
4856
5339
|
let current = el;
|
|
4857
5340
|
while (current) {
|
|
4858
5341
|
const meta = current.__svelte_meta;
|
|
4859
|
-
if (_optionalChain([meta, 'optionalAccess',
|
|
5342
|
+
if (_optionalChain([meta, 'optionalAccess', _222 => _222.loc])) return { meta, el: current };
|
|
4860
5343
|
current = current.parentElement;
|
|
4861
5344
|
}
|
|
4862
5345
|
return null;
|
|
4863
5346
|
}
|
|
4864
5347
|
function lineOf(meta) {
|
|
4865
|
-
const line = _optionalChain([meta, 'access',
|
|
5348
|
+
const line = _optionalChain([meta, 'access', _223 => _223.loc, 'optionalAccess', _224 => _224.line]);
|
|
4866
5349
|
if (typeof line !== "number") return null;
|
|
4867
5350
|
return "parent" in meta ? line : line + 1;
|
|
4868
5351
|
}
|
|
4869
5352
|
function resolveSvelteComponent(el) {
|
|
4870
5353
|
const found = metaOf(el);
|
|
4871
|
-
if (!_optionalChain([found, 'optionalAccess',
|
|
5354
|
+
if (!_optionalChain([found, 'optionalAccess', _225 => _225.meta, 'access', _226 => _226.loc, 'optionalAccess', _227 => _227.file])) return null;
|
|
4872
5355
|
const { meta } = found;
|
|
4873
5356
|
const own = baseName(meta.loc.file);
|
|
4874
5357
|
const stack = [{ name: own, hostElement: found.el }];
|
|
@@ -4882,9 +5365,9 @@ function resolveSvelteComponent(el) {
|
|
|
4882
5365
|
}
|
|
4883
5366
|
function resolveSvelteSource(el) {
|
|
4884
5367
|
const found = metaOf(el);
|
|
4885
|
-
const file = _optionalChain([found, 'optionalAccess',
|
|
5368
|
+
const file = _optionalChain([found, 'optionalAccess', _228 => _228.meta, 'access', _229 => _229.loc, 'optionalAccess', _230 => _230.file]);
|
|
4886
5369
|
if (!found || !file) return NO_SOURCE;
|
|
4887
|
-
const column = _optionalChain([found, 'access',
|
|
5370
|
+
const column = _optionalChain([found, 'access', _231 => _231.meta, 'access', _232 => _232.loc, 'optionalAccess', _233 => _233.column]);
|
|
4888
5371
|
return {
|
|
4889
5372
|
filePath: relativizePath(file),
|
|
4890
5373
|
line: lineOf(found.meta),
|
|
@@ -4904,10 +5387,10 @@ var domAdapter = {
|
|
|
4904
5387
|
name: "HTML",
|
|
4905
5388
|
resolveComponent: (el) => {
|
|
4906
5389
|
const host2 = el.closest("[data-component]");
|
|
4907
|
-
const name = _optionalChain([host2, 'optionalAccess',
|
|
5390
|
+
const name = _optionalChain([host2, 'optionalAccess', _234 => _234.getAttribute, 'call', _235 => _235("data-component")]);
|
|
4908
5391
|
if (!host2 || !name) return null;
|
|
4909
5392
|
const stack = [];
|
|
4910
|
-
for (let h2 = host2; h2; h2 = _nullishCoalesce(_optionalChain([h2, 'access',
|
|
5393
|
+
for (let h2 = host2; h2; h2 = _nullishCoalesce(_optionalChain([h2, 'access', _236 => _236.parentElement, 'optionalAccess', _237 => _237.closest, 'call', _238 => _238("[data-component]")]), () => ( null))) {
|
|
4911
5394
|
const n = h2.getAttribute("data-component");
|
|
4912
5395
|
if (n) stack.push({ name: n, hostElement: h2 });
|
|
4913
5396
|
if (stack.length >= 12) break;
|
|
@@ -4929,7 +5412,7 @@ function composeAdapters(adapters = DEFAULT_ADAPTERS) {
|
|
|
4929
5412
|
for (const adapter of adapters) {
|
|
4930
5413
|
try {
|
|
4931
5414
|
const result = adapter.resolveComponent(el);
|
|
4932
|
-
if (_optionalChain([result, 'optionalAccess',
|
|
5415
|
+
if (_optionalChain([result, 'optionalAccess', _239 => _239.name])) return { adapter, result };
|
|
4933
5416
|
} catch (e30) {
|
|
4934
5417
|
}
|
|
4935
5418
|
}
|
|
@@ -4937,7 +5420,7 @@ function composeAdapters(adapters = DEFAULT_ADAPTERS) {
|
|
|
4937
5420
|
}
|
|
4938
5421
|
return {
|
|
4939
5422
|
resolveComponent(el) {
|
|
4940
|
-
return _nullishCoalesce(_optionalChain([owner, 'call',
|
|
5423
|
+
return _nullishCoalesce(_optionalChain([owner, 'call', _240 => _240(el), 'optionalAccess', _241 => _241.result]), () => ( null));
|
|
4941
5424
|
},
|
|
4942
5425
|
resolveSource(el) {
|
|
4943
5426
|
const stamped = resolveSource3(el);
|
|
@@ -4946,15 +5429,15 @@ function composeAdapters(adapters = DEFAULT_ADAPTERS) {
|
|
|
4946
5429
|
const ordered = found ? [found.adapter, ...adapters.filter((a) => a !== found.adapter)] : adapters;
|
|
4947
5430
|
for (const adapter of ordered) {
|
|
4948
5431
|
try {
|
|
4949
|
-
const src = _optionalChain([adapter, 'access',
|
|
4950
|
-
if (_optionalChain([src, 'optionalAccess',
|
|
5432
|
+
const src = _optionalChain([adapter, 'access', _242 => _242.resolveSource, 'optionalCall', _243 => _243(el)]);
|
|
5433
|
+
if (_optionalChain([src, 'optionalAccess', _244 => _244.filePath])) return src;
|
|
4951
5434
|
} catch (e31) {
|
|
4952
5435
|
}
|
|
4953
5436
|
}
|
|
4954
5437
|
return null;
|
|
4955
5438
|
},
|
|
4956
5439
|
frameworkFor(el) {
|
|
4957
|
-
return _nullishCoalesce(_optionalChain([owner, 'call',
|
|
5440
|
+
return _nullishCoalesce(_optionalChain([owner, 'call', _245 => _245(el), 'optionalAccess', _246 => _246.adapter, 'access', _247 => _247.name]), () => ( "HTML"));
|
|
4958
5441
|
},
|
|
4959
5442
|
cleanClasses(classes) {
|
|
4960
5443
|
return adapters.reduce((list, a) => a.cleanClasses ? a.cleanClasses(list) : list, classes);
|
|
@@ -4986,7 +5469,7 @@ function getDefaultOptions() {
|
|
|
4986
5469
|
};
|
|
4987
5470
|
}
|
|
4988
5471
|
function init(options) {
|
|
4989
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5472
|
+
if (_optionalChain([options, 'optionalAccess', _248 => _248.mode]) === "live" && !_chunk6CBIOKZVcjs.consumeFeedbackLink.call(void 0, options.projectKey)) {
|
|
4990
5473
|
return createDormantApi(options);
|
|
4991
5474
|
}
|
|
4992
5475
|
return createGrabInstance(options);
|
|
@@ -5012,7 +5495,7 @@ function createDormantApi(options) {
|
|
|
5012
5495
|
real.show();
|
|
5013
5496
|
return;
|
|
5014
5497
|
}
|
|
5015
|
-
_optionalChain([flusher, 'optionalAccess',
|
|
5498
|
+
_optionalChain([flusher, 'optionalAccess', _249 => _249.dispose, 'call', _250 => _250()]);
|
|
5016
5499
|
_chunk6CBIOKZVcjs.startFeedbackSession.call(void 0, );
|
|
5017
5500
|
real = createGrabInstance(options);
|
|
5018
5501
|
for (const fn of queued.splice(0)) fn(real);
|
|
@@ -5123,6 +5606,7 @@ function createGrabInstance(options) {
|
|
|
5123
5606
|
}
|
|
5124
5607
|
}
|
|
5125
5608
|
const overlay = createOverlayRenderer({ plainLabels: live });
|
|
5609
|
+
const groupOutline = createGroupOutline();
|
|
5126
5610
|
const crosshair = createCrosshair();
|
|
5127
5611
|
const freezeOverlay = createFreezeOverlay();
|
|
5128
5612
|
const pluginRegistry = createPluginRegistry();
|
|
@@ -5135,6 +5619,9 @@ function createGrabInstance(options) {
|
|
|
5135
5619
|
const cleanClasses = (list) => adapters.cleanClasses(list.filter((c) => !isNoiseClass(c)));
|
|
5136
5620
|
let selectedElement = null;
|
|
5137
5621
|
let selectedPin;
|
|
5622
|
+
let selectedMembers = null;
|
|
5623
|
+
let selectedArea = null;
|
|
5624
|
+
const commentedMembers = /* @__PURE__ */ new Map();
|
|
5138
5625
|
let pendingShot = null;
|
|
5139
5626
|
const commentedElements = /* @__PURE__ */ new Map();
|
|
5140
5627
|
let editingFromMarker = false;
|
|
@@ -5191,12 +5678,14 @@ function createGrabInstance(options) {
|
|
|
5191
5678
|
function toastDetail(c) {
|
|
5192
5679
|
return {
|
|
5193
5680
|
componentName: c.target.component,
|
|
5194
|
-
filePath: _nullishCoalesce(_optionalChain([c, 'access',
|
|
5195
|
-
line: _nullishCoalesce(_optionalChain([c, 'access',
|
|
5196
|
-
column: _nullishCoalesce(_optionalChain([c, 'access',
|
|
5681
|
+
filePath: _nullishCoalesce(_optionalChain([c, 'access', _251 => _251.target, 'access', _252 => _252.source, 'optionalAccess', _253 => _253.file]), () => ( null)),
|
|
5682
|
+
line: _nullishCoalesce(_optionalChain([c, 'access', _254 => _254.target, 'access', _255 => _255.source, 'optionalAccess', _256 => _256.line]), () => ( null)),
|
|
5683
|
+
column: _nullishCoalesce(_optionalChain([c, 'access', _257 => _257.target, 'access', _258 => _258.source, 'optionalAccess', _259 => _259.column]), () => ( null))
|
|
5197
5684
|
};
|
|
5198
5685
|
}
|
|
5199
|
-
function saveComment(element, text, shot,
|
|
5686
|
+
function saveComment(element, text, shot, extras = {}) {
|
|
5687
|
+
const { pin, members, area } = extras;
|
|
5688
|
+
const deps = { componentResolver, sourceResolver, cleanClasses };
|
|
5200
5689
|
const now = Date.now();
|
|
5201
5690
|
const comment = {
|
|
5202
5691
|
id: randomId(),
|
|
@@ -5210,16 +5699,19 @@ function createGrabInstance(options) {
|
|
|
5210
5699
|
title: document.title,
|
|
5211
5700
|
viewport: [window.innerWidth, window.innerHeight]
|
|
5212
5701
|
},
|
|
5213
|
-
target: captureTarget(element,
|
|
5702
|
+
target: captureTarget(element, deps),
|
|
5214
5703
|
screenshot: null,
|
|
5215
5704
|
framework: adapters.frameworkFor(element),
|
|
5216
5705
|
...outbox ? { sync: "pending" } : {},
|
|
5217
|
-
...pin ? { pin } : {}
|
|
5706
|
+
...pin ? { pin } : {},
|
|
5707
|
+
..._optionalChain([members, 'optionalAccess', _260 => _260.length]) ? { members: members.map((el) => captureMember(el, deps)) } : {},
|
|
5708
|
+
...area ? { area } : {}
|
|
5218
5709
|
};
|
|
5219
5710
|
commentedElements.set(comment.id, element);
|
|
5711
|
+
if (_optionalChain([members, 'optionalAccess', _261 => _261.length])) commentedMembers.set(comment.id, members);
|
|
5220
5712
|
setComments([comment, ...comments()].slice(0, MAX_COMMENTS));
|
|
5221
5713
|
pluginRegistry.callHook("onComment", comment, element);
|
|
5222
|
-
_optionalChain([outbox, 'optionalAccess',
|
|
5714
|
+
_optionalChain([outbox, 'optionalAccess', _262 => _262.send, 'call', _263 => _263(comment.id)]);
|
|
5223
5715
|
if (shot) void attachScreenshot(comment.id, shot);
|
|
5224
5716
|
const count = comments().length;
|
|
5225
5717
|
if (live) {
|
|
@@ -5254,19 +5746,22 @@ function createGrabInstance(options) {
|
|
|
5254
5746
|
const updated = { ...current, screenshot: { localId: id, width: result.width, height: result.height } };
|
|
5255
5747
|
setComments(comments().map((c) => c.id === id ? updated : c));
|
|
5256
5748
|
pluginRegistry.callHook("onScreenshot", updated, result.blob);
|
|
5257
|
-
_optionalChain([outbox, 'optionalAccess',
|
|
5749
|
+
_optionalChain([outbox, 'optionalAccess', _264 => _264.sendScreenshot, 'call', _265 => _265(id)]);
|
|
5258
5750
|
}
|
|
5259
5751
|
function removeComments(ids, message, withdraw = false) {
|
|
5260
5752
|
if (ids.length === 0) return;
|
|
5261
5753
|
const idSet = new Set(ids);
|
|
5262
5754
|
const before = comments();
|
|
5263
5755
|
const removed = before.filter((c) => idSet.has(c.id));
|
|
5264
|
-
for (const id of ids)
|
|
5756
|
+
for (const id of ids) {
|
|
5757
|
+
commentedElements.delete(id);
|
|
5758
|
+
commentedMembers.delete(id);
|
|
5759
|
+
}
|
|
5265
5760
|
setComments(before.filter((c) => !idSet.has(c.id)));
|
|
5266
5761
|
const withdrawn = withdraw && outbox ? removed.filter((c) => c.sync !== void 0) : [];
|
|
5267
5762
|
const hadQueued = new Set(withdrawn.filter((c) => outbox.isQueued(c.id)).map((c) => c.id));
|
|
5268
5763
|
for (const c of withdrawn) outbox.remove(c.id, c.author.sessionId, message ? UNDO_MS + 500 : 0);
|
|
5269
|
-
const shotIds = removed.flatMap((c) => _optionalChain([c, 'access',
|
|
5764
|
+
const shotIds = removed.flatMap((c) => _optionalChain([c, 'access', _266 => _266.screenshot, 'optionalAccess', _267 => _267.localId]) ? [c.screenshot.localId] : []);
|
|
5270
5765
|
const key = randomId();
|
|
5271
5766
|
pendingShotDeletes.set(key, setTimeout(() => {
|
|
5272
5767
|
pendingShotDeletes.delete(key);
|
|
@@ -5285,7 +5780,7 @@ function createGrabInstance(options) {
|
|
|
5285
5780
|
const back = removed.filter((c) => !present.has(c.id)).map((c) => resend.has(c.id) ? { ...c, sync: "pending" } : c);
|
|
5286
5781
|
const restored = [...back, ...comments()].sort((a, b) => b.createdAt - a.createdAt);
|
|
5287
5782
|
setComments(restored);
|
|
5288
|
-
for (const id of resend) _optionalChain([outbox, 'optionalAccess',
|
|
5783
|
+
for (const id of resend) _optionalChain([outbox, 'optionalAccess', _268 => _268.send, 'call', _269 => _269(id)]);
|
|
5289
5784
|
showToast(`Restored ${removed.length} comment${removed.length === 1 ? "" : "s"}`);
|
|
5290
5785
|
}
|
|
5291
5786
|
}]
|
|
@@ -5320,16 +5815,52 @@ function createGrabInstance(options) {
|
|
|
5320
5815
|
commentPopover.hide();
|
|
5321
5816
|
endMarkerEdit();
|
|
5322
5817
|
if (picker.isHolding()) {
|
|
5323
|
-
|
|
5324
|
-
selectedPin = void 0;
|
|
5325
|
-
pendingShot = null;
|
|
5818
|
+
clearSelection();
|
|
5326
5819
|
picker.release();
|
|
5327
5820
|
}
|
|
5328
5821
|
}
|
|
5822
|
+
function clearSelection() {
|
|
5823
|
+
selectedElement = null;
|
|
5824
|
+
selectedPin = void 0;
|
|
5825
|
+
selectedMembers = null;
|
|
5826
|
+
selectedArea = null;
|
|
5827
|
+
pendingShot = null;
|
|
5828
|
+
}
|
|
5329
5829
|
function endMarkerEdit() {
|
|
5330
5830
|
if (!editingFromMarker) return;
|
|
5331
5831
|
editingFromMarker = false;
|
|
5332
5832
|
overlay.hide();
|
|
5833
|
+
groupOutline.hide();
|
|
5834
|
+
}
|
|
5835
|
+
function pinIn(el, point) {
|
|
5836
|
+
const rect = el.getBoundingClientRect();
|
|
5837
|
+
const frac2 = (v, start, size2) => size2 > 0 ? Math.min(1, Math.max(0, (v - start) / size2)) : 0.5;
|
|
5838
|
+
return {
|
|
5839
|
+
x: Math.round(frac2(point.x, rect.left, rect.width) * 1e3) / 1e3,
|
|
5840
|
+
y: Math.round(frac2(point.y, rect.top, rect.height) * 1e3) / 1e3
|
|
5841
|
+
};
|
|
5842
|
+
}
|
|
5843
|
+
function groupSpecFor(comment, element) {
|
|
5844
|
+
if (comment.area && element) return { spec: { element, area: comment.area }, label: "Area" };
|
|
5845
|
+
if (!_optionalChain([comment, 'access', _270 => _270.members, 'optionalAccess', _271 => _271.length])) return null;
|
|
5846
|
+
const known = _optionalChain([commentedMembers, 'access', _272 => _272.get, 'call', _273 => _273(comment.id), 'optionalAccess', _274 => _274.filter, 'call', _275 => _275((el) => el.isConnected)]);
|
|
5847
|
+
const elements = _optionalChain([known, 'optionalAccess', _276 => _276.length]) ? known : comment.members.flatMap((m) => _nullishCoalesce(safeQuery(m.selector), () => ( [])));
|
|
5848
|
+
return elements.length ? { spec: { elements }, label: `${comment.members.length} elements` } : null;
|
|
5849
|
+
}
|
|
5850
|
+
function beginGroupComment(container, point, spec, heading, label, clip) {
|
|
5851
|
+
selectedElement = container;
|
|
5852
|
+
selectedPin = pinIn(container, point);
|
|
5853
|
+
pendingShot = store.state.options.screenshots ? captureScreenshot(container, _nullishCoalesce(clip, () => ( void 0))) : null;
|
|
5854
|
+
coachMark.dismiss();
|
|
5855
|
+
picker.hold(container, { spec, label });
|
|
5856
|
+
commentPopover.show({
|
|
5857
|
+
anchor: container,
|
|
5858
|
+
anchorBox: clip,
|
|
5859
|
+
mode: "new",
|
|
5860
|
+
askIdentity: shouldAskIdentity(),
|
|
5861
|
+
heading,
|
|
5862
|
+
placeholder: "What should change here?"
|
|
5863
|
+
});
|
|
5333
5864
|
}
|
|
5334
5865
|
function closeAllPopovers() {
|
|
5335
5866
|
commentsPanel.hide();
|
|
@@ -5357,6 +5888,7 @@ function createGrabInstance(options) {
|
|
|
5357
5888
|
const picker = createElementPicker({
|
|
5358
5889
|
overlay,
|
|
5359
5890
|
crosshair,
|
|
5891
|
+
groupOutline,
|
|
5360
5892
|
getComponentResolver: () => componentResolver,
|
|
5361
5893
|
getSourceResolver: () => sourceResolver,
|
|
5362
5894
|
isToolbarElement: isAnyToolbarElement,
|
|
@@ -5369,18 +5901,24 @@ function createGrabInstance(options) {
|
|
|
5369
5901
|
},
|
|
5370
5902
|
onSelect(element, point) {
|
|
5371
5903
|
selectedElement = element;
|
|
5372
|
-
|
|
5373
|
-
const frac = (v, start, size2) => size2 > 0 ? Math.min(1, Math.max(0, (v - start) / size2)) : 0.5;
|
|
5374
|
-
selectedPin = {
|
|
5375
|
-
x: Math.round(frac(point.x, rect.left, rect.width) * 1e3) / 1e3,
|
|
5376
|
-
y: Math.round(frac(point.y, rect.top, rect.height) * 1e3) / 1e3
|
|
5377
|
-
};
|
|
5904
|
+
selectedPin = pinIn(element, point);
|
|
5378
5905
|
pendingShot = store.state.options.screenshots ? captureScreenshot(element) : null;
|
|
5379
5906
|
pluginRegistry.callHook("onElementSelect", element);
|
|
5380
5907
|
coachMark.dismiss();
|
|
5381
5908
|
showSelectFeedback(element);
|
|
5382
5909
|
picker.hold(element);
|
|
5383
5910
|
commentPopover.show({ anchor: element, mode: "new", askIdentity: shouldAskIdentity() });
|
|
5911
|
+
},
|
|
5912
|
+
onSelectGroup(elements, point) {
|
|
5913
|
+
selectedMembers = elements;
|
|
5914
|
+
const heading = describeGroup(elements.map(describeElement));
|
|
5915
|
+
for (const el of elements) pluginRegistry.callHook("onElementSelect", el);
|
|
5916
|
+
beginGroupComment(commonContainer(elements), point, { elements }, heading, `${elements.length} elements`, unionBox(elements));
|
|
5917
|
+
},
|
|
5918
|
+
onSelectArea(container, area, point) {
|
|
5919
|
+
selectedArea = area;
|
|
5920
|
+
pluginRegistry.callHook("onElementSelect", container);
|
|
5921
|
+
beginGroupComment(container, point, { element: container, area }, describeArea(describeElement(container)), "Area", areaToBox(container, area));
|
|
5384
5922
|
}
|
|
5385
5923
|
});
|
|
5386
5924
|
const markers = createMarkers({
|
|
@@ -5388,25 +5926,35 @@ function createGrabInstance(options) {
|
|
|
5388
5926
|
currentRoute: () => sanitizeRoute(location, store.state.options.captureQueryParams),
|
|
5389
5927
|
findElement(comment) {
|
|
5390
5928
|
const known = commentedElements.get(comment.id);
|
|
5391
|
-
if (_optionalChain([known, 'optionalAccess',
|
|
5929
|
+
if (_optionalChain([known, 'optionalAccess', _277 => _277.isConnected])) return known;
|
|
5392
5930
|
return safeQuery(comment.target.selector);
|
|
5393
5931
|
},
|
|
5394
5932
|
onHover(comment, element) {
|
|
5395
5933
|
if (picker.isHolding() || editingFromMarker || commentPopover.isVisible()) return;
|
|
5396
|
-
|
|
5397
|
-
|
|
5934
|
+
const group = comment ? groupSpecFor(comment, element) : null;
|
|
5935
|
+
if (group) groupOutline.show(group.spec, group.label);
|
|
5936
|
+
else if (comment && element) overlay.show(element, comment.target.component, null, []);
|
|
5937
|
+
else {
|
|
5938
|
+
overlay.hide();
|
|
5939
|
+
groupOutline.hide();
|
|
5940
|
+
}
|
|
5398
5941
|
},
|
|
5399
5942
|
onOpen(comment, element, marker) {
|
|
5400
5943
|
if (picker.isHolding()) return;
|
|
5401
5944
|
closeAllPopovers();
|
|
5402
5945
|
doDeactivate(true);
|
|
5403
5946
|
editingFromMarker = true;
|
|
5404
|
-
|
|
5947
|
+
const group = groupSpecFor(comment, element);
|
|
5948
|
+
if (group) groupOutline.show(group.spec, group.label);
|
|
5949
|
+
else if (element) overlay.show(element, comment.target.component, null, []);
|
|
5950
|
+
const spec = _optionalChain([group, 'optionalAccess', _278 => _278.spec]);
|
|
5405
5951
|
commentPopover.show({
|
|
5406
5952
|
anchor: _nullishCoalesce(element, () => ( marker)),
|
|
5953
|
+
anchorBox: spec ? "area" in spec ? areaToBox(spec.element, spec.area) : unionBox(spec.elements) : null,
|
|
5407
5954
|
initialValue: comment.comment,
|
|
5408
5955
|
mode: "edit",
|
|
5409
|
-
entryId: comment.id
|
|
5956
|
+
entryId: comment.id,
|
|
5957
|
+
heading: _optionalChain([comment, 'access', _279 => _279.members, 'optionalAccess', _280 => _280.length]) || comment.area ? describeComment(comment) : void 0
|
|
5410
5958
|
});
|
|
5411
5959
|
}
|
|
5412
5960
|
});
|
|
@@ -5557,7 +6105,7 @@ function createGrabInstance(options) {
|
|
|
5557
6105
|
});
|
|
5558
6106
|
const finishSheet = createFinishSheet({
|
|
5559
6107
|
onDone() {
|
|
5560
|
-
const done = comments().filter((c) => c.sync === "sent" && !_optionalChain([outbox, 'optionalAccess',
|
|
6108
|
+
const done = comments().filter((c) => c.sync === "sent" && !_optionalChain([outbox, 'optionalAccess', _281 => _281.isQueued, 'call', _282 => _282(c.id)])).map((c) => c.id);
|
|
5561
6109
|
if (!comments().length) {
|
|
5562
6110
|
exitFeedbackMode();
|
|
5563
6111
|
return;
|
|
@@ -5571,9 +6119,9 @@ function createGrabInstance(options) {
|
|
|
5571
6119
|
if (failed.length) {
|
|
5572
6120
|
const ids = new Set(failed.map((c) => c.id));
|
|
5573
6121
|
setComments(comments().map((c) => ids.has(c.id) ? { ...c, sync: "pending" } : c));
|
|
5574
|
-
for (const id of ids) _optionalChain([outbox, 'optionalAccess',
|
|
6122
|
+
for (const id of ids) _optionalChain([outbox, 'optionalAccess', _283 => _283.send, 'call', _284 => _284(id)]);
|
|
5575
6123
|
}
|
|
5576
|
-
_optionalChain([outbox, 'optionalAccess',
|
|
6124
|
+
_optionalChain([outbox, 'optionalAccess', _285 => _285.flush, 'call', _286 => _286()]);
|
|
5577
6125
|
}
|
|
5578
6126
|
});
|
|
5579
6127
|
const commentPopover = createCommentPopover({
|
|
@@ -5581,12 +6129,10 @@ function createGrabInstance(options) {
|
|
|
5581
6129
|
if (identity) saveIdentity({ name: identity.name, anonymous: !identity.name });
|
|
5582
6130
|
if (ctx.mode === "new") {
|
|
5583
6131
|
const element = selectedElement;
|
|
6132
|
+
const extras = { pin: selectedPin, members: selectedMembers, area: selectedArea };
|
|
5584
6133
|
const shot = pendingShot;
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
selectedPin = void 0;
|
|
5588
|
-
pendingShot = null;
|
|
5589
|
-
if (element) saveComment(element, value, shot, pin);
|
|
6134
|
+
clearSelection();
|
|
6135
|
+
if (element) saveComment(element, value, shot, extras);
|
|
5590
6136
|
doDeactivate(true);
|
|
5591
6137
|
return;
|
|
5592
6138
|
}
|
|
@@ -5595,16 +6141,14 @@ function createGrabInstance(options) {
|
|
|
5595
6141
|
(c) => c.id === ctx.entryId ? { ...c, comment: value, updatedAt: Date.now(), ...outbox ? { sync: "pending" } : {} } : c
|
|
5596
6142
|
);
|
|
5597
6143
|
setComments(updated);
|
|
5598
|
-
_optionalChain([outbox, 'optionalAccess',
|
|
6144
|
+
_optionalChain([outbox, 'optionalAccess', _287 => _287.send, 'call', _288 => _288(ctx.entryId)]);
|
|
5599
6145
|
showToast("Comment updated");
|
|
5600
6146
|
if (editingFromMarker) endMarkerEdit();
|
|
5601
6147
|
else commentsPanel.show([...updated]);
|
|
5602
6148
|
},
|
|
5603
6149
|
onCancel(ctx) {
|
|
5604
6150
|
if (ctx.mode === "new") {
|
|
5605
|
-
|
|
5606
|
-
selectedPin = void 0;
|
|
5607
|
-
pendingShot = null;
|
|
6151
|
+
clearSelection();
|
|
5608
6152
|
doDeactivate(true);
|
|
5609
6153
|
return;
|
|
5610
6154
|
}
|
|
@@ -5627,7 +6171,7 @@ function createGrabInstance(options) {
|
|
|
5627
6171
|
document.addEventListener("click", handleDocumentClick);
|
|
5628
6172
|
function handlePageHide() {
|
|
5629
6173
|
flushPendingWrite();
|
|
5630
|
-
_optionalChain([outbox, 'optionalAccess',
|
|
6174
|
+
_optionalChain([outbox, 'optionalAccess', _289 => _289.flushOnExit, 'call', _290 => _290()]);
|
|
5631
6175
|
}
|
|
5632
6176
|
function handleVisibilityChange() {
|
|
5633
6177
|
if (document.visibilityState === "hidden") flushPendingWrite();
|
|
@@ -5770,6 +6314,7 @@ function createGrabInstance(options) {
|
|
|
5770
6314
|
crosshair.dispose();
|
|
5771
6315
|
freezeOverlay.dispose();
|
|
5772
6316
|
markers.dispose();
|
|
6317
|
+
groupOutline.dispose();
|
|
5773
6318
|
disposeToast();
|
|
5774
6319
|
disposeFeedbackStyles();
|
|
5775
6320
|
pluginRegistry.dispose();
|
|
@@ -5780,7 +6325,7 @@ function createGrabInstance(options) {
|
|
|
5780
6325
|
copySheet.dispose();
|
|
5781
6326
|
finishSheet.dispose();
|
|
5782
6327
|
coachMark.dispose();
|
|
5783
|
-
_optionalChain([outbox, 'optionalAccess',
|
|
6328
|
+
_optionalChain([outbox, 'optionalAccess', _291 => _291.dispose, 'call', _292 => _292()]);
|
|
5784
6329
|
themeManager.dispose();
|
|
5785
6330
|
disposeStyleBaseline();
|
|
5786
6331
|
disposeScreenshotSandbox();
|