@campfire-interactive/shell-header 0.15.1 → 0.15.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 +31 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -843,8 +843,13 @@ async function captureTabScreenshot() {
|
|
|
843
843
|
var MAX_ENTRIES = 50;
|
|
844
844
|
var MAX_MESSAGE_CHARS = 500;
|
|
845
845
|
var consoleBuffer = [];
|
|
846
|
-
var
|
|
846
|
+
var networkFailureBuffer = [];
|
|
847
|
+
var networkSuccessBuffer = [];
|
|
847
848
|
var installed = false;
|
|
849
|
+
function stripQuery(url) {
|
|
850
|
+
const i = url.indexOf("?");
|
|
851
|
+
return i === -1 ? url : url.slice(0, i);
|
|
852
|
+
}
|
|
848
853
|
function push(buffer, entry) {
|
|
849
854
|
buffer.push(entry);
|
|
850
855
|
if (buffer.length > MAX_ENTRIES) buffer.shift();
|
|
@@ -893,7 +898,7 @@ function installBugReportCapture() {
|
|
|
893
898
|
try {
|
|
894
899
|
const res = await originalFetch(input, init);
|
|
895
900
|
if (!res.ok) {
|
|
896
|
-
push(
|
|
901
|
+
push(networkFailureBuffer, {
|
|
897
902
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
898
903
|
method: method.toUpperCase(),
|
|
899
904
|
url,
|
|
@@ -901,10 +906,19 @@ function installBugReportCapture() {
|
|
|
901
906
|
durationMs: Math.round(performance.now() - started),
|
|
902
907
|
requestId: res.headers.get("x-request-id") ?? void 0
|
|
903
908
|
});
|
|
909
|
+
} else {
|
|
910
|
+
push(networkSuccessBuffer, {
|
|
911
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
912
|
+
method: method.toUpperCase(),
|
|
913
|
+
url: stripQuery(url),
|
|
914
|
+
status: res.status,
|
|
915
|
+
durationMs: Math.round(performance.now() - started),
|
|
916
|
+
requestId: res.headers.get("x-request-id") ?? void 0
|
|
917
|
+
});
|
|
904
918
|
}
|
|
905
919
|
return res;
|
|
906
920
|
} catch (err) {
|
|
907
|
-
push(
|
|
921
|
+
push(networkFailureBuffer, {
|
|
908
922
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
909
923
|
method: method.toUpperCase(),
|
|
910
924
|
url,
|
|
@@ -916,7 +930,10 @@ function installBugReportCapture() {
|
|
|
916
930
|
};
|
|
917
931
|
}
|
|
918
932
|
function snapshotBugReportCapture() {
|
|
919
|
-
|
|
933
|
+
const network = [...networkFailureBuffer, ...networkSuccessBuffer].sort(
|
|
934
|
+
(a, b) => a.at.localeCompare(b.at)
|
|
935
|
+
);
|
|
936
|
+
return { console: [...consoleBuffer], network };
|
|
920
937
|
}
|
|
921
938
|
|
|
922
939
|
// src/BugReportModal.tsx
|
|
@@ -1394,14 +1411,16 @@ function useBugReportShortcut(enabled, onShortcut) {
|
|
|
1394
1411
|
function handleKeyDown(e) {
|
|
1395
1412
|
const platformMod = e.ctrlKey || e.metaKey;
|
|
1396
1413
|
if (!platformMod || !e.altKey || e.shiftKey) return;
|
|
1397
|
-
|
|
1414
|
+
const isB = e.code === "KeyB" || e.key.toLowerCase() === "b";
|
|
1415
|
+
const isS = e.code === "KeyS" || e.key.toLowerCase() === "s";
|
|
1416
|
+
if (!isB && !isS) return;
|
|
1398
1417
|
const target = e.target;
|
|
1399
1418
|
if (target) {
|
|
1400
1419
|
const tag = target.tagName;
|
|
1401
1420
|
if (tag === "INPUT" || tag === "TEXTAREA" || target.isContentEditable) return;
|
|
1402
1421
|
}
|
|
1403
1422
|
e.preventDefault();
|
|
1404
|
-
handlerRef.current();
|
|
1423
|
+
handlerRef.current(isS ? "screenshot" : "plain");
|
|
1405
1424
|
}
|
|
1406
1425
|
document.addEventListener("keydown", handleKeyDown);
|
|
1407
1426
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
@@ -1450,12 +1469,17 @@ function ShellHeader({
|
|
|
1450
1469
|
const [bugOpen, setBugOpen] = useState7(false);
|
|
1451
1470
|
const [bugShot, setBugShot] = useState7(null);
|
|
1452
1471
|
const bugCaptureBusy = useRef6(false);
|
|
1453
|
-
useBugReportShortcut(bugReport !== void 0, () => {
|
|
1472
|
+
useBugReportShortcut(bugReport !== void 0, (variant) => {
|
|
1454
1473
|
if (bugOpen) {
|
|
1455
1474
|
setBugOpen(false);
|
|
1456
1475
|
return;
|
|
1457
1476
|
}
|
|
1458
1477
|
if (bugCaptureBusy.current) return;
|
|
1478
|
+
if (variant === "plain") {
|
|
1479
|
+
setBugShot(null);
|
|
1480
|
+
setBugOpen(true);
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1459
1483
|
bugCaptureBusy.current = true;
|
|
1460
1484
|
captureTabScreenshot().then((shot) => setBugShot(shot)).catch(() => setBugShot(null)).finally(() => {
|
|
1461
1485
|
bugCaptureBusy.current = false;
|