glitchgrab 1.27.0 → 1.28.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/README.md CHANGED
@@ -158,6 +158,19 @@ Once `GlitchgrabProvider` is mounted, these shortcuts work globally:
158
158
 
159
159
  No configuration needed — shortcuts are active as long as the provider is in the tree.
160
160
 
161
+ ### Showing the shortcut in your own UI
162
+
163
+ The report dialog shows the shortcut on its first step. To advertise it elsewhere — a support menu, a sidebar hint — read `shortcutLabel` instead of hardcoding the string. It resolves to `⌘⇧G` on Mac and `Ctrl+Shift+G` everywhere else, and stays in sync with the handler:
164
+
165
+ ```tsx
166
+ function SupportHint() {
167
+ const { shortcutLabel } = useGlitchgrab();
168
+ return <p>Found a bug? Press {shortcutLabel} anywhere to report it.</p>;
169
+ }
170
+ ```
171
+
172
+ It is SSR-safe: it renders `Ctrl+Shift+G` on the server and corrects to the platform label after mount.
173
+
161
174
  ## How do I fetch reports by user?
162
175
 
163
176
  ### React hook (recommended)
package/dist/index.d.mts CHANGED
@@ -127,6 +127,12 @@ interface UseGlitchgrabReturn {
127
127
  * Returns the polished text, or the original text on any failure (never throws).
128
128
  */
129
129
  enhanceText: (text: string, screenshot?: string | null) => Promise<string>;
130
+ /**
131
+ * OS-aware label for the shortcut that opens the report dialog —
132
+ * `⌘⇧G` on Mac, `Ctrl+Shift+G` elsewhere. Render this instead of
133
+ * hardcoding the shortcut, so the hint stays in sync with the handler.
134
+ */
135
+ shortcutLabel: string;
130
136
  /** The token being used */
131
137
  token: string;
132
138
  /** The base URL of the Glitchgrab API */
@@ -298,6 +304,24 @@ declare function addBreadcrumb(type: BreadcrumbType, message: string, data?: Rec
298
304
  declare function getBreadcrumbs(): Breadcrumb[];
299
305
  declare function clearBreadcrumbs(): void;
300
306
 
307
+ /**
308
+ * The global keyboard shortcut that opens the Glitchgrab report dialog.
309
+ * Single source of truth — the provider's keydown handler and every label
310
+ * rendered anywhere (SDK dialog, host app UI) derive from this.
311
+ */
312
+ /** Server-safe label. Used during SSR and as the non-Mac label. */
313
+ declare const GLITCHGRAB_SHORTCUT = "Ctrl+Shift+G";
314
+ /** Mac label, using the platform's modifier glyphs. */
315
+ declare const GLITCHGRAB_SHORTCUT_MAC = "\u2318\u21E7G";
316
+ /**
317
+ * OS-aware label for the report-dialog shortcut — `⌘⇧G` on Mac,
318
+ * `Ctrl+Shift+G` elsewhere. Returns the non-Mac label on the server, so
319
+ * render it client-side (or after mount) to avoid a hydration mismatch.
320
+ */
321
+ declare function getShortcutLabel(): string;
322
+ /** True when the keyboard event matches the report-dialog shortcut. */
323
+ declare function matchesShortcut(e: KeyboardEvent): boolean;
324
+
301
325
  declare function sanitizeUrl(url: string): string;
302
326
  declare function captureDeviceInfo(): DeviceInfo | null;
303
327
  declare function captureContext(visitedPages: string[]): CapturedContext;
@@ -329,4 +353,4 @@ declare function computeSignature(params: {
329
353
  declare function shouldSkipDuplicate(signature: string, windowMs?: number, now?: number): boolean;
330
354
  declare function clearDedupCache(): void;
331
355
 
332
- export { type Breadcrumb, type BreadcrumbType, type CapturedContext, type DeviceInfo, type GlitchgrabConfig, GlitchgrabErrorBoundary, GlitchgrabProvider, type GlitchgrabProviderProps, type GlitchgrabReport, type GlitchgrabSession, ReportButton, type ReportButtonProps, type ReportPayload, type ReportResult, type ReportSeverity, type ReportType, type UseGlitchgrabReturn, addBreadcrumb, captureContext, captureDeviceInfo, clearBreadcrumbs, clearDedupCache, computeSignature, enhanceText, fetchGlitchgrabReports, getBreadcrumbs, initBreadcrumbs, sanitizeUrl, sendReport, shouldSkipDuplicate, useGlitchgrab, useGlitchgrabActions, useGlitchgrabReports };
356
+ export { type Breadcrumb, type BreadcrumbType, type CapturedContext, type DeviceInfo, GLITCHGRAB_SHORTCUT, GLITCHGRAB_SHORTCUT_MAC, type GlitchgrabConfig, GlitchgrabErrorBoundary, GlitchgrabProvider, type GlitchgrabProviderProps, type GlitchgrabReport, type GlitchgrabSession, ReportButton, type ReportButtonProps, type ReportPayload, type ReportResult, type ReportSeverity, type ReportType, type UseGlitchgrabReturn, addBreadcrumb, captureContext, captureDeviceInfo, clearBreadcrumbs, clearDedupCache, computeSignature, enhanceText, fetchGlitchgrabReports, getBreadcrumbs, getShortcutLabel, initBreadcrumbs, matchesShortcut, sanitizeUrl, sendReport, shouldSkipDuplicate, useGlitchgrab, useGlitchgrabActions, useGlitchgrabReports };
package/dist/index.d.ts CHANGED
@@ -127,6 +127,12 @@ interface UseGlitchgrabReturn {
127
127
  * Returns the polished text, or the original text on any failure (never throws).
128
128
  */
129
129
  enhanceText: (text: string, screenshot?: string | null) => Promise<string>;
130
+ /**
131
+ * OS-aware label for the shortcut that opens the report dialog —
132
+ * `⌘⇧G` on Mac, `Ctrl+Shift+G` elsewhere. Render this instead of
133
+ * hardcoding the shortcut, so the hint stays in sync with the handler.
134
+ */
135
+ shortcutLabel: string;
130
136
  /** The token being used */
131
137
  token: string;
132
138
  /** The base URL of the Glitchgrab API */
@@ -298,6 +304,24 @@ declare function addBreadcrumb(type: BreadcrumbType, message: string, data?: Rec
298
304
  declare function getBreadcrumbs(): Breadcrumb[];
299
305
  declare function clearBreadcrumbs(): void;
300
306
 
307
+ /**
308
+ * The global keyboard shortcut that opens the Glitchgrab report dialog.
309
+ * Single source of truth — the provider's keydown handler and every label
310
+ * rendered anywhere (SDK dialog, host app UI) derive from this.
311
+ */
312
+ /** Server-safe label. Used during SSR and as the non-Mac label. */
313
+ declare const GLITCHGRAB_SHORTCUT = "Ctrl+Shift+G";
314
+ /** Mac label, using the platform's modifier glyphs. */
315
+ declare const GLITCHGRAB_SHORTCUT_MAC = "\u2318\u21E7G";
316
+ /**
317
+ * OS-aware label for the report-dialog shortcut — `⌘⇧G` on Mac,
318
+ * `Ctrl+Shift+G` elsewhere. Returns the non-Mac label on the server, so
319
+ * render it client-side (or after mount) to avoid a hydration mismatch.
320
+ */
321
+ declare function getShortcutLabel(): string;
322
+ /** True when the keyboard event matches the report-dialog shortcut. */
323
+ declare function matchesShortcut(e: KeyboardEvent): boolean;
324
+
301
325
  declare function sanitizeUrl(url: string): string;
302
326
  declare function captureDeviceInfo(): DeviceInfo | null;
303
327
  declare function captureContext(visitedPages: string[]): CapturedContext;
@@ -329,4 +353,4 @@ declare function computeSignature(params: {
329
353
  declare function shouldSkipDuplicate(signature: string, windowMs?: number, now?: number): boolean;
330
354
  declare function clearDedupCache(): void;
331
355
 
332
- export { type Breadcrumb, type BreadcrumbType, type CapturedContext, type DeviceInfo, type GlitchgrabConfig, GlitchgrabErrorBoundary, GlitchgrabProvider, type GlitchgrabProviderProps, type GlitchgrabReport, type GlitchgrabSession, ReportButton, type ReportButtonProps, type ReportPayload, type ReportResult, type ReportSeverity, type ReportType, type UseGlitchgrabReturn, addBreadcrumb, captureContext, captureDeviceInfo, clearBreadcrumbs, clearDedupCache, computeSignature, enhanceText, fetchGlitchgrabReports, getBreadcrumbs, initBreadcrumbs, sanitizeUrl, sendReport, shouldSkipDuplicate, useGlitchgrab, useGlitchgrabActions, useGlitchgrabReports };
356
+ export { type Breadcrumb, type BreadcrumbType, type CapturedContext, type DeviceInfo, GLITCHGRAB_SHORTCUT, GLITCHGRAB_SHORTCUT_MAC, type GlitchgrabConfig, GlitchgrabErrorBoundary, GlitchgrabProvider, type GlitchgrabProviderProps, type GlitchgrabReport, type GlitchgrabSession, ReportButton, type ReportButtonProps, type ReportPayload, type ReportResult, type ReportSeverity, type ReportType, type UseGlitchgrabReturn, addBreadcrumb, captureContext, captureDeviceInfo, clearBreadcrumbs, clearDedupCache, computeSignature, enhanceText, fetchGlitchgrabReports, getBreadcrumbs, getShortcutLabel, initBreadcrumbs, matchesShortcut, sanitizeUrl, sendReport, shouldSkipDuplicate, useGlitchgrab, useGlitchgrabActions, useGlitchgrabReports };
package/dist/index.js CHANGED
@@ -31,6 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/index.ts
32
32
  var index_exports = {};
33
33
  __export(index_exports, {
34
+ GLITCHGRAB_SHORTCUT: () => GLITCHGRAB_SHORTCUT,
35
+ GLITCHGRAB_SHORTCUT_MAC: () => GLITCHGRAB_SHORTCUT_MAC,
34
36
  GlitchgrabErrorBoundary: () => GlitchgrabErrorBoundary,
35
37
  GlitchgrabProvider: () => GlitchgrabProvider,
36
38
  ReportButton: () => ReportButton,
@@ -43,7 +45,9 @@ __export(index_exports, {
43
45
  enhanceText: () => enhanceText,
44
46
  fetchGlitchgrabReports: () => fetchGlitchgrabReports,
45
47
  getBreadcrumbs: () => getBreadcrumbs,
48
+ getShortcutLabel: () => getShortcutLabel,
46
49
  initBreadcrumbs: () => initBreadcrumbs,
50
+ matchesShortcut: () => matchesShortcut,
47
51
  sanitizeUrl: () => sanitizeUrl,
48
52
  sendReport: () => sendReport,
49
53
  shouldSkipDuplicate: () => shouldSkipDuplicate,
@@ -781,6 +785,24 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
781
785
  );
782
786
  }
783
787
 
788
+ // src/shortcut.ts
789
+ var GLITCHGRAB_SHORTCUT = "Ctrl+Shift+G";
790
+ var GLITCHGRAB_SHORTCUT_MAC = "\u2318\u21E7G";
791
+ function isMac() {
792
+ try {
793
+ if (typeof navigator === "undefined") return false;
794
+ return /Mac|iPhone|iPad|iPod/i.test(navigator.platform || navigator.userAgent);
795
+ } catch (e) {
796
+ return false;
797
+ }
798
+ }
799
+ function getShortcutLabel() {
800
+ return isMac() ? GLITCHGRAB_SHORTCUT_MAC : GLITCHGRAB_SHORTCUT;
801
+ }
802
+ function matchesShortcut(e) {
803
+ return (e.metaKey || e.ctrlKey) && e.shiftKey && e.key.toLowerCase() === "g";
804
+ }
805
+
784
806
  // src/report-dialog.tsx
785
807
  var import_jsx_runtime2 = require("react/jsx-runtime");
786
808
  function useIsDark() {
@@ -1490,6 +1512,24 @@ function ReportDialog({
1490
1512
  },
1491
1513
  children: step === 1 ? "What's on your mind?" : "Tell us more"
1492
1514
  }
1515
+ ),
1516
+ step === 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1517
+ "span",
1518
+ {
1519
+ title: "Press this anywhere to open Glitchgrab",
1520
+ style: {
1521
+ fontSize: "10px",
1522
+ fontWeight: 600,
1523
+ lineHeight: 1,
1524
+ padding: "3px 6px",
1525
+ borderRadius: "4px",
1526
+ border: `1px solid ${t.inputBorder}`,
1527
+ background: t.inputBg,
1528
+ color: t.textMuted,
1529
+ whiteSpace: "nowrap"
1530
+ },
1531
+ children: getShortcutLabel()
1532
+ }
1493
1533
  )
1494
1534
  ]
1495
1535
  }
@@ -2985,7 +3025,7 @@ function GlitchgrabProviderInner({
2985
3025
  try {
2986
3026
  if (typeof window === "undefined") return;
2987
3027
  const handleKeyDown = (e) => {
2988
- if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key.toLowerCase() === "g") {
3028
+ if (matchesShortcut(e)) {
2989
3029
  e.preventDefault();
2990
3030
  openReportDialog();
2991
3031
  }
@@ -2995,6 +3035,10 @@ function GlitchgrabProviderInner({
2995
3035
  } catch (e) {
2996
3036
  }
2997
3037
  }, [openReportDialog]);
3038
+ const [shortcutLabel, setShortcutLabel] = (0, import_react3.useState)(GLITCHGRAB_SHORTCUT);
3039
+ (0, import_react3.useEffect)(() => {
3040
+ setShortcutLabel(getShortcutLabel());
3041
+ }, []);
2998
3042
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
2999
3043
  GlitchgrabContext.Provider,
3000
3044
  {
@@ -3005,7 +3049,8 @@ function GlitchgrabProviderInner({
3005
3049
  report,
3006
3050
  addBreadcrumb: addBreadcrumb2,
3007
3051
  openReportDialog,
3008
- enhanceText: enhance
3052
+ enhanceText: enhance,
3053
+ shortcutLabel
3009
3054
  },
3010
3055
  children: [
3011
3056
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -3237,6 +3282,8 @@ function useGlitchgrabActions({
3237
3282
  }
3238
3283
  // Annotate the CommonJS export names for ESM import in node:
3239
3284
  0 && (module.exports = {
3285
+ GLITCHGRAB_SHORTCUT,
3286
+ GLITCHGRAB_SHORTCUT_MAC,
3240
3287
  GlitchgrabErrorBoundary,
3241
3288
  GlitchgrabProvider,
3242
3289
  ReportButton,
@@ -3249,7 +3296,9 @@ function useGlitchgrabActions({
3249
3296
  enhanceText,
3250
3297
  fetchGlitchgrabReports,
3251
3298
  getBreadcrumbs,
3299
+ getShortcutLabel,
3252
3300
  initBreadcrumbs,
3301
+ matchesShortcut,
3253
3302
  sanitizeUrl,
3254
3303
  sendReport,
3255
3304
  shouldSkipDuplicate,