glitchgrab 1.61.0 → 1.61.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +274 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +274 -41
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
// src/origin.ts
|
|
4
|
+
var EXTENSION_RE = /\b(?:chrome|safari|moz|edge)-extension:\/\//;
|
|
5
|
+
var FRAME_RE = /^\s*at\s+(?:.*?\s+\()?(.+?):(\d+):(\d+)\)?\s*$/;
|
|
6
|
+
var MAX_FRAMES = 10;
|
|
7
|
+
function sameOriginAs(file, pageOrigin) {
|
|
8
|
+
if (file.startsWith("/")) return true;
|
|
9
|
+
try {
|
|
10
|
+
return new URL(file).origin === pageOrigin;
|
|
11
|
+
} catch (e) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function parseFrames(stack, pageOrigin) {
|
|
16
|
+
if (!stack) return [];
|
|
17
|
+
const frames = [];
|
|
18
|
+
for (const raw of stack.split("\n")) {
|
|
19
|
+
const m = FRAME_RE.exec(raw);
|
|
20
|
+
if (!m) continue;
|
|
21
|
+
const file = m[1].replace(/^eval at .*?, /, "");
|
|
22
|
+
frames.push({
|
|
23
|
+
file,
|
|
24
|
+
line: Number(m[2]),
|
|
25
|
+
column: Number(m[3]),
|
|
26
|
+
sameOrigin: sameOriginAs(file, pageOrigin)
|
|
27
|
+
});
|
|
28
|
+
if (frames.length >= MAX_FRAMES) break;
|
|
29
|
+
}
|
|
30
|
+
return frames;
|
|
31
|
+
}
|
|
32
|
+
function classifyOrigin(stack, filename, pageOrigin) {
|
|
33
|
+
var _a, _b, _c;
|
|
34
|
+
const frames = parseFrames(stack, pageOrigin);
|
|
35
|
+
const top = (_c = (_b = (_a = frames[0]) == null ? void 0 : _a.file) != null ? _b : filename) != null ? _c : "";
|
|
36
|
+
const hasExtensionFrame = EXTENSION_RE.test(stack != null ? stack : "") || EXTENSION_RE.test(filename != null ? filename : "");
|
|
37
|
+
let origin;
|
|
38
|
+
if (hasExtensionFrame) origin = "extension";
|
|
39
|
+
else if (!top) origin = "unknown";
|
|
40
|
+
else if (top === "<anonymous>" || /\beval\b/.test(top)) origin = "eval";
|
|
41
|
+
else if (/^(?:blob|data):/.test(top)) origin = "injected";
|
|
42
|
+
else if (!sameOriginAs(top, pageOrigin)) origin = "injected";
|
|
43
|
+
else origin = "app";
|
|
44
|
+
return { origin, frames };
|
|
45
|
+
}
|
|
46
|
+
function originMetadata(stack, filename) {
|
|
47
|
+
try {
|
|
48
|
+
const { origin, frames } = classifyOrigin(stack, filename, window.location.origin);
|
|
49
|
+
return {
|
|
50
|
+
codeOrigin: origin,
|
|
51
|
+
...frames.length ? { frames: JSON.stringify(frames) } : {}
|
|
52
|
+
};
|
|
53
|
+
} catch (e) {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
3
58
|
// src/provider.tsx
|
|
4
59
|
import {
|
|
5
60
|
createContext,
|
|
@@ -1248,6 +1303,7 @@ function buildCapturedErrorPayload(error, options, cfg, capturedBy = "captureErr
|
|
|
1248
1303
|
...contextMetadata(context),
|
|
1249
1304
|
...(options == null ? void 0 : options.boundary) ? { boundary: options.boundary } : {},
|
|
1250
1305
|
...digest ? { digest } : {},
|
|
1306
|
+
...originMetadata(err == null ? void 0 : err.stack),
|
|
1251
1307
|
...sessionMetadata(cfg.session),
|
|
1252
1308
|
...options == null ? void 0 : options.metadata
|
|
1253
1309
|
}
|
|
@@ -1414,24 +1470,102 @@ async function encodeImageFile(file, maxLength = MAX_SCREENSHOT_DATA_URL_LENGTH)
|
|
|
1414
1470
|
}
|
|
1415
1471
|
return readAsDataUrl(file);
|
|
1416
1472
|
}
|
|
1417
|
-
var PALETTE = ["#ef4444", "#
|
|
1473
|
+
var PALETTE = ["#ef4444", "#facc15", "#22c55e", "#3b82f6", "#a855f7", "#ffffff"];
|
|
1474
|
+
var TOOL_DEFAULTS = {
|
|
1475
|
+
pen: { color: PALETTE[0], width: 4 },
|
|
1476
|
+
highlighter: { color: "#facc15", width: 22 },
|
|
1477
|
+
rect: { color: PALETTE[0], width: 4 },
|
|
1478
|
+
circle: { color: PALETTE[0], width: 4 },
|
|
1479
|
+
arrow: { color: PALETTE[0], width: 4 }
|
|
1480
|
+
};
|
|
1481
|
+
var WIDTH_RANGE = {
|
|
1482
|
+
pen: { min: 2, max: 12 },
|
|
1483
|
+
highlighter: { min: 10, max: 40 },
|
|
1484
|
+
rect: { min: 2, max: 12 },
|
|
1485
|
+
circle: { min: 2, max: 12 },
|
|
1486
|
+
arrow: { min: 2, max: 12 }
|
|
1487
|
+
};
|
|
1488
|
+
var HIGHLIGHT_ALPHA = 0.45;
|
|
1489
|
+
var HIGHLIGHT_WASH_ALPHA = 0.22;
|
|
1490
|
+
var MIN_RECT_SIZE = 3;
|
|
1491
|
+
function normalizeRect(r) {
|
|
1492
|
+
return {
|
|
1493
|
+
...r,
|
|
1494
|
+
x: r.w < 0 ? r.x + r.w : r.x,
|
|
1495
|
+
y: r.h < 0 ? r.y + r.h : r.y,
|
|
1496
|
+
w: Math.abs(r.w),
|
|
1497
|
+
h: Math.abs(r.h)
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
function hitTestRect(strokes, p, tolerance, selected) {
|
|
1501
|
+
if (selected !== null) {
|
|
1502
|
+
const s = strokes[selected];
|
|
1503
|
+
if ((s == null ? void 0 : s.type) === "rect") {
|
|
1504
|
+
const corners = [
|
|
1505
|
+
["nw", s.x, s.y],
|
|
1506
|
+
["ne", s.x + s.w, s.y],
|
|
1507
|
+
["sw", s.x, s.y + s.h],
|
|
1508
|
+
["se", s.x + s.w, s.y + s.h]
|
|
1509
|
+
];
|
|
1510
|
+
for (const [handle, cx, cy] of corners) {
|
|
1511
|
+
if (Math.abs(p.x - cx) <= tolerance && Math.abs(p.y - cy) <= tolerance) {
|
|
1512
|
+
return { index: selected, handle };
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
if (insideRect(s, p, tolerance)) return { index: selected, handle: "move" };
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
for (let i = strokes.length - 1; i >= 0; i--) {
|
|
1519
|
+
const s = strokes[i];
|
|
1520
|
+
if (s.type !== "rect" || i === selected) continue;
|
|
1521
|
+
const band = tolerance + s.width / 2;
|
|
1522
|
+
if (insideRect(s, p, band) && !insideRect(s, p, -band)) return { index: i, handle: "move" };
|
|
1523
|
+
}
|
|
1524
|
+
return null;
|
|
1525
|
+
}
|
|
1526
|
+
function insideRect(r, p, pad) {
|
|
1527
|
+
return p.x >= r.x - pad && p.x <= r.x + r.w + pad && p.y >= r.y - pad && p.y <= r.y + r.h + pad;
|
|
1528
|
+
}
|
|
1529
|
+
function dragRect(orig, handle, dx, dy) {
|
|
1530
|
+
if (handle === "move") return { ...orig, x: orig.x + dx, y: orig.y + dy };
|
|
1531
|
+
const left = handle === "nw" || handle === "sw" ? orig.x + dx : orig.x;
|
|
1532
|
+
const right = handle === "ne" || handle === "se" ? orig.x + orig.w + dx : orig.x + orig.w;
|
|
1533
|
+
const top = handle === "nw" || handle === "ne" ? orig.y + dy : orig.y;
|
|
1534
|
+
const bottom = handle === "sw" || handle === "se" ? orig.y + orig.h + dy : orig.y + orig.h;
|
|
1535
|
+
return normalizeRect({ ...orig, x: left, y: top, w: right - left, h: bottom - top });
|
|
1536
|
+
}
|
|
1537
|
+
function strokePath(ctx, points) {
|
|
1538
|
+
ctx.beginPath();
|
|
1539
|
+
ctx.moveTo(points[0].x, points[0].y);
|
|
1540
|
+
for (let i = 1; i < points.length; i++) ctx.lineTo(points[i].x, points[i].y);
|
|
1541
|
+
ctx.stroke();
|
|
1542
|
+
}
|
|
1418
1543
|
function drawStroke(ctx, s) {
|
|
1544
|
+
ctx.save();
|
|
1419
1545
|
ctx.strokeStyle = s.color;
|
|
1420
1546
|
ctx.lineWidth = s.width;
|
|
1421
1547
|
ctx.lineCap = "round";
|
|
1422
1548
|
ctx.lineJoin = "round";
|
|
1423
1549
|
if (s.type === "freehand") {
|
|
1424
|
-
if (s.points.length
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1550
|
+
if (s.points.length >= 2) strokePath(ctx, s.points);
|
|
1551
|
+
} else if (s.type === "highlight") {
|
|
1552
|
+
if (s.points.length >= 2) {
|
|
1553
|
+
ctx.lineCap = "butt";
|
|
1554
|
+
ctx.globalCompositeOperation = "multiply";
|
|
1555
|
+
ctx.globalAlpha = HIGHLIGHT_ALPHA;
|
|
1556
|
+
strokePath(ctx, s.points);
|
|
1557
|
+
ctx.globalCompositeOperation = "source-over";
|
|
1558
|
+
ctx.globalAlpha = HIGHLIGHT_WASH_ALPHA;
|
|
1559
|
+
strokePath(ctx, s.points);
|
|
1560
|
+
}
|
|
1561
|
+
} else if (s.type === "rect") {
|
|
1562
|
+
ctx.lineJoin = "miter";
|
|
1563
|
+
ctx.strokeRect(s.x, s.y, s.w, s.h);
|
|
1429
1564
|
} else if (s.type === "circle") {
|
|
1430
1565
|
ctx.beginPath();
|
|
1431
1566
|
ctx.arc(s.cx, s.cy, s.r, 0, Math.PI * 2);
|
|
1432
1567
|
ctx.stroke();
|
|
1433
|
-
} else {
|
|
1434
|
-
if (Math.hypot(s.x2 - s.x1, s.y2 - s.y1) < 3) return;
|
|
1568
|
+
} else if (Math.hypot(s.x2 - s.x1, s.y2 - s.y1) >= 3) {
|
|
1435
1569
|
const angle = Math.atan2(s.y2 - s.y1, s.x2 - s.x1);
|
|
1436
1570
|
const head = Math.max(14, s.width * 4);
|
|
1437
1571
|
ctx.beginPath();
|
|
@@ -1442,16 +1576,57 @@ function drawStroke(ctx, s) {
|
|
|
1442
1576
|
ctx.lineTo(s.x2 - head * Math.cos(angle + Math.PI / 6), s.y2 - head * Math.sin(angle + Math.PI / 6));
|
|
1443
1577
|
ctx.stroke();
|
|
1444
1578
|
}
|
|
1579
|
+
ctx.restore();
|
|
1580
|
+
}
|
|
1581
|
+
function paintOrder(strokes) {
|
|
1582
|
+
return [...strokes.filter((s) => s.type === "highlight"), ...strokes.filter((s) => s.type !== "highlight")];
|
|
1583
|
+
}
|
|
1584
|
+
function drawSelection(ctx, r, scale) {
|
|
1585
|
+
const pad = r.width / 2 + 3 * scale;
|
|
1586
|
+
const size = 9 * scale;
|
|
1587
|
+
ctx.save();
|
|
1588
|
+
ctx.strokeStyle = "#22d3ee";
|
|
1589
|
+
ctx.lineWidth = 1.5 * scale;
|
|
1590
|
+
ctx.setLineDash([5 * scale, 4 * scale]);
|
|
1591
|
+
ctx.strokeRect(r.x - pad, r.y - pad, r.w + pad * 2, r.h + pad * 2);
|
|
1592
|
+
ctx.setLineDash([]);
|
|
1593
|
+
ctx.fillStyle = "#ffffff";
|
|
1594
|
+
for (const [cx, cy] of [
|
|
1595
|
+
[r.x, r.y],
|
|
1596
|
+
[r.x + r.w, r.y],
|
|
1597
|
+
[r.x, r.y + r.h],
|
|
1598
|
+
[r.x + r.w, r.y + r.h]
|
|
1599
|
+
]) {
|
|
1600
|
+
ctx.fillRect(cx - size / 2, cy - size / 2, size, size);
|
|
1601
|
+
ctx.strokeRect(cx - size / 2, cy - size / 2, size, size);
|
|
1602
|
+
}
|
|
1603
|
+
ctx.restore();
|
|
1604
|
+
}
|
|
1605
|
+
function paintAnnotations(ctx, img, strokes, current, selected, scale) {
|
|
1606
|
+
const { width, height } = ctx.canvas;
|
|
1607
|
+
ctx.clearRect(0, 0, width, height);
|
|
1608
|
+
ctx.drawImage(img, 0, 0, width, height);
|
|
1609
|
+
for (const s of paintOrder(current ? [...strokes, current] : strokes)) drawStroke(ctx, s);
|
|
1610
|
+
const sel = selected !== null ? strokes[selected] : void 0;
|
|
1611
|
+
if ((sel == null ? void 0 : sel.type) === "rect") drawSelection(ctx, sel, scale);
|
|
1612
|
+
}
|
|
1613
|
+
function cursorFor(handle) {
|
|
1614
|
+
if (handle === "move") return "move";
|
|
1615
|
+
if (handle === "nw" || handle === "se") return "nwse-resize";
|
|
1616
|
+
if (handle === "ne" || handle === "sw") return "nesw-resize";
|
|
1617
|
+
return "crosshair";
|
|
1445
1618
|
}
|
|
1446
1619
|
function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
|
|
1447
1620
|
const canvasRef = useRef(null);
|
|
1448
1621
|
const imgRef = useRef(null);
|
|
1622
|
+
const dragRef = useRef(null);
|
|
1449
1623
|
const [ready, setReady] = useState(false);
|
|
1450
1624
|
const [tool, setTool] = useState("pen");
|
|
1451
|
-
const [
|
|
1452
|
-
const [strokeWidth, setStrokeWidth] = useState(4);
|
|
1625
|
+
const [settings, setSettings] = useState(TOOL_DEFAULTS);
|
|
1453
1626
|
const [strokes, setStrokes] = useState([]);
|
|
1454
1627
|
const [currentStroke, setCurrentStroke] = useState(null);
|
|
1628
|
+
const [selected, setSelected] = useState(null);
|
|
1629
|
+
const { color, width: strokeWidth } = settings[tool];
|
|
1455
1630
|
useEffect(() => {
|
|
1456
1631
|
const img = new Image();
|
|
1457
1632
|
img.onload = () => {
|
|
@@ -1465,18 +1640,21 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
|
|
|
1465
1640
|
};
|
|
1466
1641
|
img.src = imageSrc;
|
|
1467
1642
|
}, [imageSrc]);
|
|
1468
|
-
|
|
1469
|
-
|
|
1643
|
+
const displayScale = (canvas) => {
|
|
1644
|
+
const w = canvas.getBoundingClientRect().width;
|
|
1645
|
+
return w > 0 ? canvas.width / w : 1;
|
|
1646
|
+
};
|
|
1647
|
+
const paint = (showSelection) => {
|
|
1470
1648
|
const canvas = canvasRef.current;
|
|
1471
1649
|
const img = imgRef.current;
|
|
1472
1650
|
if (!canvas || !img) return;
|
|
1473
1651
|
const ctx = canvas.getContext("2d");
|
|
1474
1652
|
if (!ctx) return;
|
|
1475
|
-
ctx
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
if (
|
|
1479
|
-
}
|
|
1653
|
+
paintAnnotations(ctx, img, strokes, currentStroke, showSelection ? selected : null, displayScale(canvas));
|
|
1654
|
+
};
|
|
1655
|
+
useEffect(() => {
|
|
1656
|
+
if (ready) paint(true);
|
|
1657
|
+
});
|
|
1480
1658
|
const getPos = (e) => {
|
|
1481
1659
|
const canvas = e.currentTarget;
|
|
1482
1660
|
const rect = canvas.getBoundingClientRect();
|
|
@@ -1485,32 +1663,76 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
|
|
|
1485
1663
|
y: (e.clientY - rect.top) * canvas.height / rect.height
|
|
1486
1664
|
};
|
|
1487
1665
|
};
|
|
1666
|
+
const hitAt = (canvas, p, pointerType) => tool === "rect" ? hitTestRect(strokes, p, (pointerType === "mouse" ? 8 : 16) * displayScale(canvas), selected) : null;
|
|
1488
1667
|
const handlePointerDown = (e) => {
|
|
1489
1668
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1490
|
-
const
|
|
1669
|
+
const p = getPos(e);
|
|
1670
|
+
const hit = hitAt(e.currentTarget, p, e.pointerType);
|
|
1671
|
+
if (hit) {
|
|
1672
|
+
setSelected(hit.index);
|
|
1673
|
+
dragRef.current = { index: hit.index, handle: hit.handle, start: p, orig: strokes[hit.index] };
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
setSelected(null);
|
|
1677
|
+
const { x, y } = p;
|
|
1678
|
+
const base = { color, width: strokeWidth };
|
|
1491
1679
|
setCurrentStroke(
|
|
1492
|
-
tool === "pen" ? { type: "freehand",
|
|
1680
|
+
tool === "pen" ? { type: "freehand", ...base, points: [p] } : tool === "highlighter" ? { type: "highlight", ...base, points: [p] } : tool === "rect" ? { type: "rect", ...base, x, y, w: 0, h: 0 } : tool === "circle" ? { type: "circle", ...base, cx: x, cy: y, r: 0 } : { type: "arrow", ...base, x1: x, y1: y, x2: x, y2: y }
|
|
1493
1681
|
);
|
|
1494
1682
|
};
|
|
1495
1683
|
const handlePointerMove = (e) => {
|
|
1496
|
-
|
|
1497
|
-
const
|
|
1684
|
+
var _a;
|
|
1685
|
+
const p = getPos(e);
|
|
1686
|
+
const drag = dragRef.current;
|
|
1687
|
+
if (drag) {
|
|
1688
|
+
const next = dragRect(drag.orig, drag.handle, p.x - drag.start.x, p.y - drag.start.y);
|
|
1689
|
+
setStrokes((s) => s.map((st, i) => i === drag.index ? next : st));
|
|
1690
|
+
return;
|
|
1691
|
+
}
|
|
1692
|
+
if (!currentStroke) {
|
|
1693
|
+
e.currentTarget.style.cursor = cursorFor((_a = hitAt(e.currentTarget, p, e.pointerType)) == null ? void 0 : _a.handle);
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
const { x, y } = p;
|
|
1498
1697
|
setCurrentStroke((prev) => {
|
|
1499
1698
|
if (!prev) return prev;
|
|
1500
|
-
if (prev.type === "freehand") return { ...prev, points: [...prev.points,
|
|
1699
|
+
if (prev.type === "freehand" || prev.type === "highlight") return { ...prev, points: [...prev.points, p] };
|
|
1700
|
+
if (prev.type === "rect") return { ...prev, w: x - prev.x, h: y - prev.y };
|
|
1501
1701
|
if (prev.type === "arrow") return { ...prev, x2: x, y2: y };
|
|
1502
1702
|
return { ...prev, r: Math.hypot(x - prev.cx, y - prev.cy) };
|
|
1503
1703
|
});
|
|
1504
1704
|
};
|
|
1505
1705
|
const handlePointerUp = () => {
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
return
|
|
1509
|
-
}
|
|
1706
|
+
if (dragRef.current) {
|
|
1707
|
+
dragRef.current = null;
|
|
1708
|
+
return;
|
|
1709
|
+
}
|
|
1710
|
+
const done = currentStroke;
|
|
1711
|
+
setCurrentStroke(null);
|
|
1712
|
+
if (!done) return;
|
|
1713
|
+
if (done.type === "rect") {
|
|
1714
|
+
const r = normalizeRect(done);
|
|
1715
|
+
if (r.w < MIN_RECT_SIZE || r.h < MIN_RECT_SIZE) return;
|
|
1716
|
+
setStrokes((s) => [...s, r]);
|
|
1717
|
+
setSelected(strokes.length);
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
setStrokes((s) => [...s, done]);
|
|
1721
|
+
};
|
|
1722
|
+
const applySetting = (patch) => {
|
|
1723
|
+
setSettings((s) => ({ ...s, [tool]: { ...s[tool], ...patch } }));
|
|
1724
|
+
if (selected !== null) {
|
|
1725
|
+
setStrokes((s) => s.map((st, i) => i === selected && st.type === "rect" ? { ...st, ...patch } : st));
|
|
1726
|
+
}
|
|
1727
|
+
};
|
|
1728
|
+
const chooseTool = (t) => {
|
|
1729
|
+
setTool(t);
|
|
1730
|
+
setSelected(null);
|
|
1510
1731
|
};
|
|
1511
1732
|
const handleSave = () => {
|
|
1512
1733
|
const canvas = canvasRef.current;
|
|
1513
1734
|
if (!canvas) return;
|
|
1735
|
+
paint(false);
|
|
1514
1736
|
onSave(encodeScreenshot(canvas));
|
|
1515
1737
|
};
|
|
1516
1738
|
const iconBtn = (active = false) => ({
|
|
@@ -1554,6 +1776,7 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
|
|
|
1554
1776
|
onPointerDown: handlePointerDown,
|
|
1555
1777
|
onPointerMove: handlePointerMove,
|
|
1556
1778
|
onPointerUp: handlePointerUp,
|
|
1779
|
+
onPointerCancel: handlePointerUp,
|
|
1557
1780
|
style: {
|
|
1558
1781
|
maxWidth: "100%",
|
|
1559
1782
|
maxHeight: "calc(100vh - 140px)",
|
|
@@ -1577,15 +1800,17 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
|
|
|
1577
1800
|
maxWidth: "100%"
|
|
1578
1801
|
},
|
|
1579
1802
|
children: [
|
|
1580
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: () =>
|
|
1581
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: () =>
|
|
1582
|
-
/* @__PURE__ */ jsx("button", { type: "button", onClick: () =>
|
|
1803
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => chooseTool("pen"), style: iconBtn(tool === "pen"), title: "Freehand", "aria-label": "Freehand tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M12 20h9M16.5 3.5a2.12 2.12 0 013 3L7 19l-4 1 1-4L16.5 3.5z", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
|
|
1804
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => chooseTool("highlighter"), style: iconBtn(tool === "highlighter"), title: "Highlighter", "aria-label": "Highlighter tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M9 11l-6 6v3h9l3-3M22 12l-4.6 4.6a2 2 0 01-2.8 0l-5.2-5.2a2 2 0 010-2.8L14 4", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
|
|
1805
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => chooseTool("rect"), style: iconBtn(tool === "rect"), title: "Rectangle \u2014 drag to draw, then drag it or its corners to adjust", "aria-label": "Rectangle tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("rect", { x: "4", y: "5", width: "16", height: "14", rx: "1.5", stroke: "currentColor", strokeWidth: "1.8" }) }) }),
|
|
1806
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => chooseTool("circle"), style: iconBtn(tool === "circle"), title: "Circle", "aria-label": "Circle tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "8", stroke: "currentColor", strokeWidth: "1.8" }) }) }),
|
|
1807
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => chooseTool("arrow"), style: iconBtn(tool === "arrow"), title: "Arrow", "aria-label": "Arrow tool", children: /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M5 19L19 5M19 5h-8M19 5v8", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
|
|
1583
1808
|
/* @__PURE__ */ jsx("div", { style: { width: "1px", height: "20px", background: "rgba(255,255,255,0.15)" } }),
|
|
1584
1809
|
PALETTE.map((c) => /* @__PURE__ */ jsx(
|
|
1585
1810
|
"button",
|
|
1586
1811
|
{
|
|
1587
1812
|
type: "button",
|
|
1588
|
-
onClick: () =>
|
|
1813
|
+
onClick: () => applySetting({ color: c }),
|
|
1589
1814
|
"aria-label": `Color ${c}`,
|
|
1590
1815
|
style: {
|
|
1591
1816
|
width: "22px",
|
|
@@ -1604,7 +1829,7 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
|
|
|
1604
1829
|
{
|
|
1605
1830
|
type: "color",
|
|
1606
1831
|
value: color,
|
|
1607
|
-
onChange: (e) =>
|
|
1832
|
+
onChange: (e) => applySetting({ color: e.target.value }),
|
|
1608
1833
|
title: "Custom color",
|
|
1609
1834
|
"aria-label": "Custom color",
|
|
1610
1835
|
style: {
|
|
@@ -1622,11 +1847,11 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
|
|
|
1622
1847
|
"input",
|
|
1623
1848
|
{
|
|
1624
1849
|
type: "range",
|
|
1625
|
-
min:
|
|
1626
|
-
max:
|
|
1850
|
+
min: WIDTH_RANGE[tool].min,
|
|
1851
|
+
max: WIDTH_RANGE[tool].max,
|
|
1627
1852
|
value: strokeWidth,
|
|
1628
|
-
onChange: (e) =>
|
|
1629
|
-
title: "Stroke width",
|
|
1853
|
+
onChange: (e) => applySetting({ width: Number(e.target.value) }),
|
|
1854
|
+
title: tool === "rect" ? "Border thickness" : "Stroke width",
|
|
1630
1855
|
"aria-label": "Stroke width",
|
|
1631
1856
|
style: { width: "70px" }
|
|
1632
1857
|
}
|
|
@@ -1636,7 +1861,10 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
|
|
|
1636
1861
|
"button",
|
|
1637
1862
|
{
|
|
1638
1863
|
type: "button",
|
|
1639
|
-
onClick: () =>
|
|
1864
|
+
onClick: () => {
|
|
1865
|
+
setStrokes((s) => s.slice(0, -1));
|
|
1866
|
+
setSelected(null);
|
|
1867
|
+
},
|
|
1640
1868
|
disabled: strokes.length === 0,
|
|
1641
1869
|
style: { ...iconBtn(), opacity: strokes.length === 0 ? 0.35 : 1 },
|
|
1642
1870
|
title: "Undo",
|
|
@@ -1648,7 +1876,10 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
|
|
|
1648
1876
|
"button",
|
|
1649
1877
|
{
|
|
1650
1878
|
type: "button",
|
|
1651
|
-
onClick: () =>
|
|
1879
|
+
onClick: () => {
|
|
1880
|
+
setStrokes([]);
|
|
1881
|
+
setSelected(null);
|
|
1882
|
+
},
|
|
1652
1883
|
disabled: strokes.length === 0,
|
|
1653
1884
|
style: { ...iconBtn(), opacity: strokes.length === 0 ? 0.35 : 1 },
|
|
1654
1885
|
title: "Clear all",
|
|
@@ -10267,7 +10498,7 @@ function GlitchgrabProviderInner({
|
|
|
10267
10498
|
return matchesIgnorePatterns(message, ignoreErrors);
|
|
10268
10499
|
};
|
|
10269
10500
|
const handleError = (event) => {
|
|
10270
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
10501
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
10271
10502
|
try {
|
|
10272
10503
|
const isOpaqueCrossOrigin = event.message === "Script error." || event.message === "Script error" || !event.error && !event.filename;
|
|
10273
10504
|
if (isOpaqueCrossOrigin) {
|
|
@@ -10306,11 +10537,12 @@ function GlitchgrabProviderInner({
|
|
|
10306
10537
|
visitedPages: JSON.stringify(context.visitedPages),
|
|
10307
10538
|
...contextMetadata(context),
|
|
10308
10539
|
filename: (_e = event.filename) != null ? _e : "",
|
|
10309
|
-
|
|
10310
|
-
|
|
10540
|
+
...originMetadata((_f = event.error) == null ? void 0 : _f.stack, event.filename),
|
|
10541
|
+
lineno: String((_g = event.lineno) != null ? _g : ""),
|
|
10542
|
+
colno: String((_h = event.colno) != null ? _h : ""),
|
|
10311
10543
|
// The root patch could not attach (React internals moved, or a
|
|
10312
10544
|
// root it does not know): still label it and send the DOM context.
|
|
10313
|
-
...isHydrationError((
|
|
10545
|
+
...isHydrationError((_i = event.error) != null ? _i : event.message) ? hydrationMetadata((_j = event.error) != null ? _j : event.message) : {},
|
|
10314
10546
|
...(session == null ? void 0 : session.userId) ? { sessionUserId: session.userId } : {},
|
|
10315
10547
|
...(session == null ? void 0 : session.name) ? { sessionUserName: String(session.name) } : {},
|
|
10316
10548
|
...(session == null ? void 0 : session.email) ? { sessionUserEmail: String(session.email) } : {},
|
|
@@ -10362,6 +10594,7 @@ function GlitchgrabProviderInner({
|
|
|
10362
10594
|
visitedPages: JSON.stringify(context.visitedPages),
|
|
10363
10595
|
...contextMetadata(context),
|
|
10364
10596
|
type: "unhandledrejection",
|
|
10597
|
+
...originMetadata(errStack),
|
|
10365
10598
|
...description.details ? { rejectionReason: description.details } : {},
|
|
10366
10599
|
...(session == null ? void 0 : session.userId) ? { sessionUserId: session.userId } : {},
|
|
10367
10600
|
...(session == null ? void 0 : session.name) ? { sessionUserName: String(session.name) } : {},
|