glitchgrab 1.31.1 → 1.33.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/dist/index.js +79 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -989,6 +989,7 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
|
|
|
989
989
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
990
990
|
"div",
|
|
991
991
|
{
|
|
992
|
+
"data-glitchgrab-layer": "",
|
|
992
993
|
style: {
|
|
993
994
|
position: "fixed",
|
|
994
995
|
inset: 0,
|
|
@@ -1508,7 +1509,9 @@ function ReportDialog({
|
|
|
1508
1509
|
types,
|
|
1509
1510
|
showSeverity = true,
|
|
1510
1511
|
captureScreenshot = captureViaHtml2Canvas,
|
|
1511
|
-
reporter
|
|
1512
|
+
reporter,
|
|
1513
|
+
onClose,
|
|
1514
|
+
headerSlot
|
|
1512
1515
|
}) {
|
|
1513
1516
|
const [isEnhancing, setIsEnhancing] = (0, import_react.useState)(false);
|
|
1514
1517
|
const [isEnhanced, setIsEnhanced] = (0, import_react.useState)(false);
|
|
@@ -1565,13 +1568,29 @@ function ReportDialog({
|
|
|
1565
1568
|
const isPushToTalkRef = (0, import_react.useRef)(false);
|
|
1566
1569
|
(0, import_react.useEffect)(() => {
|
|
1567
1570
|
if (!isOpen) return;
|
|
1568
|
-
const
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
)
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1571
|
+
const HOST_LAYERS = '[role="dialog"],[role="alertdialog"],[role="menu"],[role="listbox"]';
|
|
1572
|
+
const inerted = /* @__PURE__ */ new Set();
|
|
1573
|
+
const applyInert = () => {
|
|
1574
|
+
document.querySelectorAll(HOST_LAYERS).forEach((el) => {
|
|
1575
|
+
if (el.closest("[data-glitchgrab-layer]")) return;
|
|
1576
|
+
if (el.querySelector("[data-glitchgrab-layer]")) return;
|
|
1577
|
+
if (inerted.has(el) || el.hasAttribute("inert")) return;
|
|
1578
|
+
el.setAttribute("inert", "");
|
|
1579
|
+
inerted.add(el);
|
|
1580
|
+
});
|
|
1581
|
+
};
|
|
1582
|
+
applyInert();
|
|
1583
|
+
const observer = new MutationObserver((mutations) => {
|
|
1584
|
+
const structural = mutations.some(
|
|
1585
|
+
(m) => m.addedNodes.length > 0 || m.removedNodes.length > 0
|
|
1586
|
+
);
|
|
1587
|
+
if (structural) applyInert();
|
|
1588
|
+
});
|
|
1589
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
1590
|
+
return () => {
|
|
1591
|
+
observer.disconnect();
|
|
1592
|
+
inerted.forEach((el) => el.removeAttribute("inert"));
|
|
1593
|
+
};
|
|
1575
1594
|
}, [isOpen]);
|
|
1576
1595
|
const [step, setStep] = (0, import_react.useState)(1);
|
|
1577
1596
|
const [reportType, setReportType] = (0, import_react.useState)("BUG");
|
|
@@ -1662,6 +1681,8 @@ function ReportDialog({
|
|
|
1662
1681
|
};
|
|
1663
1682
|
const handleOpen = async () => {
|
|
1664
1683
|
setSubmitted(false);
|
|
1684
|
+
closePreview();
|
|
1685
|
+
setAnnotatingIndex(null);
|
|
1665
1686
|
if (availableTypes.length === 1) {
|
|
1666
1687
|
setReportType(availableTypes[0]);
|
|
1667
1688
|
setStep(2);
|
|
@@ -1688,14 +1709,15 @@ function ReportDialog({
|
|
|
1688
1709
|
if (!isOpen) return;
|
|
1689
1710
|
const handleEsc = (e) => {
|
|
1690
1711
|
if (e.key === "Escape") {
|
|
1691
|
-
if (
|
|
1712
|
+
if (annotatingIndex !== null) setAnnotatingIndex(null);
|
|
1713
|
+
else if (previewZoomed) setPreviewZoomed(false);
|
|
1692
1714
|
else if (previewIndex !== null) closePreview();
|
|
1693
1715
|
else handleClose();
|
|
1694
1716
|
}
|
|
1695
1717
|
};
|
|
1696
1718
|
document.addEventListener("keydown", handleEsc);
|
|
1697
1719
|
return () => document.removeEventListener("keydown", handleEsc);
|
|
1698
|
-
}, [isOpen, previewIndex, previewZoomed]);
|
|
1720
|
+
}, [isOpen, previewIndex, previewZoomed, annotatingIndex]);
|
|
1699
1721
|
(0, import_react.useEffect)(() => {
|
|
1700
1722
|
if (previewIndex === null || annotatingIndex !== null) return;
|
|
1701
1723
|
const handlePointerDown = (e) => {
|
|
@@ -1830,6 +1852,9 @@ function ReportDialog({
|
|
|
1830
1852
|
const handleClose = () => {
|
|
1831
1853
|
stopVoice();
|
|
1832
1854
|
setIsOpen(false);
|
|
1855
|
+
onClose == null ? void 0 : onClose();
|
|
1856
|
+
closePreview();
|
|
1857
|
+
setAnnotatingIndex(null);
|
|
1833
1858
|
setStep(1);
|
|
1834
1859
|
setRating(0);
|
|
1835
1860
|
setHoveredStar(0);
|
|
@@ -2080,6 +2105,7 @@ function ReportDialog({
|
|
|
2080
2105
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2081
2106
|
"div",
|
|
2082
2107
|
{
|
|
2108
|
+
"data-glitchgrab-layer": "",
|
|
2083
2109
|
style: {
|
|
2084
2110
|
position: "fixed",
|
|
2085
2111
|
inset: 0,
|
|
@@ -2335,6 +2361,7 @@ function ReportDialog({
|
|
|
2335
2361
|
]
|
|
2336
2362
|
}
|
|
2337
2363
|
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
2364
|
+
step === 1 && headerSlot ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { marginBottom: "14px" }, children: headerSlot }) : null,
|
|
2338
2365
|
step === 1 && sendFeedback2 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
2339
2366
|
"div",
|
|
2340
2367
|
{
|
|
@@ -3505,10 +3532,11 @@ function ReportDialog({
|
|
|
3505
3532
|
style: { display: "none" }
|
|
3506
3533
|
}
|
|
3507
3534
|
),
|
|
3508
|
-
previewIndex !== null && screenshots[previewIndex] && (0, import_react_dom.createPortal)(
|
|
3535
|
+
isOpen && previewIndex !== null && screenshots[previewIndex] && (0, import_react_dom.createPortal)(
|
|
3509
3536
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
3510
3537
|
"div",
|
|
3511
3538
|
{
|
|
3539
|
+
"data-glitchgrab-layer": "",
|
|
3512
3540
|
style: {
|
|
3513
3541
|
position: "fixed",
|
|
3514
3542
|
inset: 0,
|
|
@@ -3661,7 +3689,7 @@ function ReportDialog({
|
|
|
3661
3689
|
),
|
|
3662
3690
|
document.body
|
|
3663
3691
|
),
|
|
3664
|
-
annotatingIndex !== null && screenshots[annotatingIndex] && (0, import_react_dom.createPortal)(
|
|
3692
|
+
isOpen && annotatingIndex !== null && screenshots[annotatingIndex] && (0, import_react_dom.createPortal)(
|
|
3665
3693
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
3666
3694
|
AnnotationCanvas,
|
|
3667
3695
|
{
|
|
@@ -4267,6 +4295,29 @@ function GlitchgrabProviderInner({
|
|
|
4267
4295
|
window.dispatchEvent(new CustomEvent("glitchgrab:open-report", { detail: options }));
|
|
4268
4296
|
}
|
|
4269
4297
|
}, []);
|
|
4298
|
+
(0, import_react3.useEffect)(() => {
|
|
4299
|
+
try {
|
|
4300
|
+
if (typeof document === "undefined") return;
|
|
4301
|
+
document.documentElement.setAttribute("data-glitchgrab-sdk", "1");
|
|
4302
|
+
return () => document.documentElement.removeAttribute("data-glitchgrab-sdk");
|
|
4303
|
+
} catch (e) {
|
|
4304
|
+
}
|
|
4305
|
+
}, []);
|
|
4306
|
+
const [projectName, setProjectName] = (0, import_react3.useState)(null);
|
|
4307
|
+
(0, import_react3.useEffect)(() => {
|
|
4308
|
+
let cancelled = false;
|
|
4309
|
+
fetch(`${baseUrl}/api/v1/sdk/project`, {
|
|
4310
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
4311
|
+
}).then((r) => r.ok ? r.json() : null).then((json) => {
|
|
4312
|
+
var _a;
|
|
4313
|
+
if (cancelled || !(json == null ? void 0 : json.success) || !((_a = json.data) == null ? void 0 : _a.name)) return;
|
|
4314
|
+
setProjectName(json.data.name);
|
|
4315
|
+
}).catch(() => {
|
|
4316
|
+
});
|
|
4317
|
+
return () => {
|
|
4318
|
+
cancelled = true;
|
|
4319
|
+
};
|
|
4320
|
+
}, [baseUrl, token]);
|
|
4270
4321
|
(0, import_react3.useEffect)(() => {
|
|
4271
4322
|
try {
|
|
4272
4323
|
if (typeof window === "undefined") return;
|
|
@@ -4326,7 +4377,22 @@ function GlitchgrabProviderInner({
|
|
|
4326
4377
|
children
|
|
4327
4378
|
}
|
|
4328
4379
|
),
|
|
4329
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
4380
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
4381
|
+
ReportDialog,
|
|
4382
|
+
{
|
|
4383
|
+
report,
|
|
4384
|
+
sendFeedback: feedback,
|
|
4385
|
+
enhanceText: enhance,
|
|
4386
|
+
transcribeAudio: transcribe,
|
|
4387
|
+
types,
|
|
4388
|
+
showSeverity,
|
|
4389
|
+
reporter,
|
|
4390
|
+
headerSlot: projectName ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { fontSize: 11, color: "#9aa0a6" }, children: [
|
|
4391
|
+
"Reporting to ",
|
|
4392
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { style: { color: "#e5e5e5" }, children: projectName })
|
|
4393
|
+
] }) : null
|
|
4394
|
+
}
|
|
4395
|
+
)
|
|
4330
4396
|
]
|
|
4331
4397
|
}
|
|
4332
4398
|
);
|