glitchgrab 1.32.0 → 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.mjs CHANGED
@@ -1455,7 +1455,9 @@ function ReportDialog({
1455
1455
  types,
1456
1456
  showSeverity = true,
1457
1457
  captureScreenshot = captureViaHtml2Canvas,
1458
- reporter
1458
+ reporter,
1459
+ onClose,
1460
+ headerSlot
1459
1461
  }) {
1460
1462
  const [isEnhancing, setIsEnhancing] = useState2(false);
1461
1463
  const [isEnhanced, setIsEnhanced] = useState2(false);
@@ -1796,6 +1798,7 @@ function ReportDialog({
1796
1798
  const handleClose = () => {
1797
1799
  stopVoice();
1798
1800
  setIsOpen(false);
1801
+ onClose == null ? void 0 : onClose();
1799
1802
  closePreview();
1800
1803
  setAnnotatingIndex(null);
1801
1804
  setStep(1);
@@ -2304,6 +2307,7 @@ function ReportDialog({
2304
2307
  ]
2305
2308
  }
2306
2309
  ) : /* @__PURE__ */ jsxs2(Fragment, { children: [
2310
+ step === 1 && headerSlot ? /* @__PURE__ */ jsx2("div", { style: { marginBottom: "14px" }, children: headerSlot }) : null,
2307
2311
  step === 1 && sendFeedback2 && /* @__PURE__ */ jsxs2(
2308
2312
  "div",
2309
2313
  {
@@ -4237,6 +4241,29 @@ function GlitchgrabProviderInner({
4237
4241
  window.dispatchEvent(new CustomEvent("glitchgrab:open-report", { detail: options }));
4238
4242
  }
4239
4243
  }, []);
4244
+ useEffect3(() => {
4245
+ try {
4246
+ if (typeof document === "undefined") return;
4247
+ document.documentElement.setAttribute("data-glitchgrab-sdk", "1");
4248
+ return () => document.documentElement.removeAttribute("data-glitchgrab-sdk");
4249
+ } catch (e) {
4250
+ }
4251
+ }, []);
4252
+ const [projectName, setProjectName] = useState3(null);
4253
+ useEffect3(() => {
4254
+ let cancelled = false;
4255
+ fetch(`${baseUrl}/api/v1/sdk/project`, {
4256
+ headers: { Authorization: `Bearer ${token}` }
4257
+ }).then((r) => r.ok ? r.json() : null).then((json) => {
4258
+ var _a;
4259
+ if (cancelled || !(json == null ? void 0 : json.success) || !((_a = json.data) == null ? void 0 : _a.name)) return;
4260
+ setProjectName(json.data.name);
4261
+ }).catch(() => {
4262
+ });
4263
+ return () => {
4264
+ cancelled = true;
4265
+ };
4266
+ }, [baseUrl, token]);
4240
4267
  useEffect3(() => {
4241
4268
  try {
4242
4269
  if (typeof window === "undefined") return;
@@ -4296,7 +4323,22 @@ function GlitchgrabProviderInner({
4296
4323
  children
4297
4324
  }
4298
4325
  ),
4299
- /* @__PURE__ */ jsx3(ReportDialog, { report, sendFeedback: feedback, enhanceText: enhance, transcribeAudio: transcribe, types, showSeverity, reporter })
4326
+ /* @__PURE__ */ jsx3(
4327
+ ReportDialog,
4328
+ {
4329
+ report,
4330
+ sendFeedback: feedback,
4331
+ enhanceText: enhance,
4332
+ transcribeAudio: transcribe,
4333
+ types,
4334
+ showSeverity,
4335
+ reporter,
4336
+ headerSlot: projectName ? /* @__PURE__ */ jsxs3("div", { style: { fontSize: 11, color: "#9aa0a6" }, children: [
4337
+ "Reporting to ",
4338
+ /* @__PURE__ */ jsx3("strong", { style: { color: "#e5e5e5" }, children: projectName })
4339
+ ] }) : null
4340
+ }
4341
+ )
4300
4342
  ]
4301
4343
  }
4302
4344
  );