@mushi-mushi/web 1.22.4 → 1.23.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 +13 -3
- package/dist/i18n/index.cjs +4 -0
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +1 -0
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/index.js +4 -0
- package/dist/i18n/index.js.map +1 -1
- package/dist/index.cjs +238 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +239 -120
- package/dist/index.js.map +1 -1
- package/dist/mushi.loader.global.js +221 -220
- package/dist/mushi.loader.global.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -101,6 +101,7 @@ var en = {
|
|
|
101
101
|
elementButton: "Select Element",
|
|
102
102
|
elementSelected: "Element selected \u2713",
|
|
103
103
|
elementCapturing: "Click anything on the page\u2026",
|
|
104
|
+
elementFailed: "Couldn't select \u2014 describe it instead",
|
|
104
105
|
elementSelectorHint: "Click any element \xB7 Esc to cancel",
|
|
105
106
|
optional: "(optional)",
|
|
106
107
|
tooShort: "A bit more detail helps us fix it faster",
|
|
@@ -269,6 +270,7 @@ var ja = {
|
|
|
269
270
|
elementButton: "\u8981\u7D20\u3092\u9078\u629E",
|
|
270
271
|
elementSelected: "\u8981\u7D20\u9078\u629E\u6E08\u307F \u2713",
|
|
271
272
|
elementCapturing: "\u30DA\u30FC\u30B8\u4E0A\u306E\u8981\u7D20\u3092\u30AF\u30EA\u30C3\u30AF\u2026",
|
|
273
|
+
elementFailed: "\u9078\u629E\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F \u2014 \u6587\u5B57\u3067\u6559\u3048\u3066\u304F\u3060\u3055\u3044",
|
|
272
274
|
elementSelectorHint: "\u8981\u7D20\u3092\u30AF\u30EA\u30C3\u30AF \xB7 Esc \u3067\u30AD\u30E3\u30F3\u30BB\u30EB",
|
|
273
275
|
optional: "\uFF08\u4EFB\u610F\uFF09",
|
|
274
276
|
tooShort: "\u3082\u3046\u5C11\u3057\u8A73\u3057\u304F\u6559\u3048\u3066\u304F\u3060\u3055\u3044",
|
|
@@ -437,6 +439,7 @@ var th = {
|
|
|
437
439
|
elementButton: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A",
|
|
438
440
|
elementSelected: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E41\u0E25\u0E49\u0E27 \u2713",
|
|
439
441
|
elementCapturing: "\u0E04\u0E25\u0E34\u0E01\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E1A\u0E19\u0E2B\u0E19\u0E49\u0E32\u2026",
|
|
442
|
+
elementFailed: "\u0E44\u0E21\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E14\u0E49 \u2014 \u0E42\u0E1B\u0E23\u0E14\u0E2D\u0E18\u0E34\u0E1A\u0E32\u0E22\u0E41\u0E17\u0E19",
|
|
440
443
|
elementSelectorHint: "\u0E04\u0E25\u0E34\u0E01\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E43\u0E14\u0E01\u0E47\u0E44\u0E14\u0E49 \xB7 Esc \u0E40\u0E1E\u0E37\u0E48\u0E2D\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01",
|
|
441
444
|
optional: "(\u0E44\u0E21\u0E48\u0E1A\u0E31\u0E07\u0E04\u0E31\u0E1A)",
|
|
442
445
|
tooShort: "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E43\u0E2B\u0E49\u0E23\u0E32\u0E22\u0E25\u0E30\u0E40\u0E2D\u0E35\u0E22\u0E14\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21",
|
|
@@ -605,6 +608,7 @@ var es = {
|
|
|
605
608
|
elementButton: "Seleccionar elemento",
|
|
606
609
|
elementSelected: "Elemento seleccionado \u2713",
|
|
607
610
|
elementCapturing: "Haz clic en cualquier elemento\u2026",
|
|
611
|
+
elementFailed: "No se pudo seleccionar \u2014 descr\xEDbelo en su lugar",
|
|
608
612
|
elementSelectorHint: "Clic en cualquier elemento \xB7 Esc para cancelar",
|
|
609
613
|
optional: "(opcional)",
|
|
610
614
|
tooShort: "Un poco m\xE1s de detalle nos ayuda a resolverlo",
|
|
@@ -2553,7 +2557,7 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
2553
2557
|
|
|
2554
2558
|
// src/version.ts
|
|
2555
2559
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
2556
|
-
var MUSHI_SDK_VERSION = "1.
|
|
2560
|
+
var MUSHI_SDK_VERSION = "1.23.0" ;
|
|
2557
2561
|
var CATEGORY_ICONS = {
|
|
2558
2562
|
bug: "\u26A0\uFE0F",
|
|
2559
2563
|
slow: "\u{1F40C}",
|
|
@@ -3282,10 +3286,11 @@ function renderDetailsStep(ctx) {
|
|
|
3282
3286
|
ctx.screenshotError ? "error" : "",
|
|
3283
3287
|
ctx.screenshotCapturing ? "loading" : ""
|
|
3284
3288
|
].filter(Boolean).join(" ");
|
|
3285
|
-
const elementLabel = ctx.elementCapturing ? t.step3.elementCapturing : ctx.elementSelected ? t.step3.elementSelected : t.step3.elementButton;
|
|
3289
|
+
const elementLabel = ctx.elementCapturing ? t.step3.elementCapturing : ctx.elementError ? t.step3.elementFailed : ctx.elementSelected ? t.step3.elementSelected : t.step3.elementButton;
|
|
3286
3290
|
const elementClass = [
|
|
3287
3291
|
"mushi-attach-btn",
|
|
3288
3292
|
ctx.elementSelected ? "active" : "",
|
|
3293
|
+
ctx.elementError ? "error" : "",
|
|
3289
3294
|
ctx.elementCapturing ? "loading" : ""
|
|
3290
3295
|
].filter(Boolean).join(" ");
|
|
3291
3296
|
const exampleChips = t.step3.examplePrompts.map((p) => `<button type="button" class="mushi-example-chip" data-example="${escapeHtml(p)}">${escapeHtml(p)}</button>`).join("");
|
|
@@ -3306,24 +3311,24 @@ function renderDetailsStep(ctx) {
|
|
|
3306
3311
|
</div>
|
|
3307
3312
|
</div>
|
|
3308
3313
|
<div class="mushi-attachments">
|
|
3309
|
-
|
|
3314
|
+
${ctx.screenshotAvailable ? `<button type="button" class="${screenshotClass}"
|
|
3310
3315
|
data-action="screenshot"
|
|
3311
3316
|
${ctx.screenshotCapturing ? "disabled" : ""}
|
|
3312
3317
|
aria-label="${escapeHtml(screenshotLabel)}"
|
|
3313
3318
|
>
|
|
3314
3319
|
${ctx.screenshotCapturing ? '<span class="mushi-spinner" aria-hidden="true"></span>' : "\u{1F4F8}"}
|
|
3315
3320
|
${escapeHtml(screenshotLabel)}
|
|
3316
|
-
</button
|
|
3321
|
+
</button>` : ""}
|
|
3317
3322
|
${ctx.screenshotAttached && ctx.allowScreenshotRemove ? '<button type="button" class="mushi-attach-btn danger" data-action="remove-screenshot" aria-label="Remove screenshot">\u2715 Remove</button>' : ""}
|
|
3318
3323
|
${ctx.screenshotAttached ? '<button type="button" class="mushi-attach-btn" data-action="annotate-screenshot" aria-label="Mark up screenshot">\u270F Mark up</button><div class="mushi-annotate-host" data-role="annotate-host"></div>' : ""}
|
|
3319
|
-
|
|
3324
|
+
${ctx.elementAvailable ? `<button type="button" class="${elementClass}"
|
|
3320
3325
|
data-action="element"
|
|
3321
3326
|
${ctx.elementCapturing ? "disabled" : ""}
|
|
3322
3327
|
aria-label="${escapeHtml(elementLabel)}"
|
|
3323
3328
|
>
|
|
3324
3329
|
${ctx.elementCapturing ? '<span class="mushi-spinner" aria-hidden="true"></span>' : "\u{1F3AF}"}
|
|
3325
3330
|
${escapeHtml(elementLabel)}
|
|
3326
|
-
</button
|
|
3331
|
+
</button>` : ""}
|
|
3327
3332
|
</div>
|
|
3328
3333
|
${ctx.screenshotAttached && ctx.screenshotPreview ? `<figure class="mushi-screenshot-preview">
|
|
3329
3334
|
<img src="${escapeHtml(ctx.screenshotPreview)}" alt="${escapeHtml(t.step3.screenshotPreviewAlt)}" />
|
|
@@ -3570,10 +3575,32 @@ var MushiWidget = class _MushiWidget {
|
|
|
3570
3575
|
screenshotCapturing = false;
|
|
3571
3576
|
screenshotError = false;
|
|
3572
3577
|
allowScreenshotRemove = true;
|
|
3578
|
+
/**
|
|
3579
|
+
* Whether the screenshot / element-select tools are actually usable
|
|
3580
|
+
* (capture module present + not disabled by config). Unavailable tools are
|
|
3581
|
+
* hidden from the details step — a rendered button whose handler silently
|
|
3582
|
+
* no-ops reads as a bug to the reporter.
|
|
3583
|
+
*/
|
|
3584
|
+
screenshotAvailable = true;
|
|
3585
|
+
elementAvailable = true;
|
|
3586
|
+
/**
|
|
3587
|
+
* In-progress form input preserved across full shadow-DOM re-renders.
|
|
3588
|
+
* render() rebuilds the panel with `innerHTML = ''`, which used to destroy
|
|
3589
|
+
* whatever the reporter had typed whenever a background refresh (60s inbox
|
|
3590
|
+
* poll, visibilitychange refetch, screenshot attach) fired mid-typing.
|
|
3591
|
+
* Captured from the live DOM right before teardown, replayed right after.
|
|
3592
|
+
*/
|
|
3593
|
+
draftDescription = "";
|
|
3594
|
+
draftEmail = "";
|
|
3595
|
+
draftReply = "";
|
|
3596
|
+
draftFocus = null;
|
|
3597
|
+
draftSelStart = 0;
|
|
3598
|
+
draftSelEnd = 0;
|
|
3573
3599
|
/** Data URL of the attached screenshot, rendered as a visible preview. */
|
|
3574
3600
|
screenshotPreview = null;
|
|
3575
3601
|
elementSelected = false;
|
|
3576
3602
|
elementCapturing = false;
|
|
3603
|
+
elementError = false;
|
|
3577
3604
|
submitting = false;
|
|
3578
3605
|
/** Hint element injected outside the shadow DOM during element selection. */
|
|
3579
3606
|
selectorHint = null;
|
|
@@ -3756,12 +3783,14 @@ var MushiWidget = class _MushiWidget {
|
|
|
3756
3783
|
this.screenshotPreview = null;
|
|
3757
3784
|
this.elementSelected = false;
|
|
3758
3785
|
this.elementCapturing = false;
|
|
3786
|
+
this.elementError = false;
|
|
3759
3787
|
this.submitting = false;
|
|
3760
3788
|
this.submittedAt = null;
|
|
3761
3789
|
this.removeSelectorHint();
|
|
3762
3790
|
this.lastReportId = null;
|
|
3763
3791
|
this.lastSubmitQueuedOffline = false;
|
|
3764
3792
|
this.viaFeatureRequest = false;
|
|
3793
|
+
this.clearFormDrafts();
|
|
3765
3794
|
if (options?.featureRequest) {
|
|
3766
3795
|
this.selectedCategory = "other";
|
|
3767
3796
|
this.selectedIntent = FEATURE_REQUEST_INTENT;
|
|
@@ -3893,6 +3922,8 @@ var MushiWidget = class _MushiWidget {
|
|
|
3893
3922
|
}
|
|
3894
3923
|
setScreenshotAttached(attached) {
|
|
3895
3924
|
this.screenshotAttached = attached;
|
|
3925
|
+
this.screenshotCapturing = false;
|
|
3926
|
+
if (attached) this.screenshotError = false;
|
|
3896
3927
|
if (!attached) this.screenshotPreview = null;
|
|
3897
3928
|
if (this.isOpen) this.render();
|
|
3898
3929
|
}
|
|
@@ -3917,9 +3948,26 @@ var MushiWidget = class _MushiWidget {
|
|
|
3917
3948
|
this.allowScreenshotRemove = allow;
|
|
3918
3949
|
if (this.isOpen) this.render();
|
|
3919
3950
|
}
|
|
3951
|
+
/** Show/hide the attachment tools based on what the SDK can actually do. */
|
|
3952
|
+
setCaptureAvailability(availability) {
|
|
3953
|
+
const nextScreenshot = availability.screenshot ?? this.screenshotAvailable;
|
|
3954
|
+
const nextElement = availability.element ?? this.elementAvailable;
|
|
3955
|
+
if (nextScreenshot === this.screenshotAvailable && nextElement === this.elementAvailable) return;
|
|
3956
|
+
this.screenshotAvailable = nextScreenshot;
|
|
3957
|
+
this.elementAvailable = nextElement;
|
|
3958
|
+
if (this.isOpen) this.render();
|
|
3959
|
+
}
|
|
3920
3960
|
setElementSelected(selected) {
|
|
3921
3961
|
this.elementSelected = selected;
|
|
3922
3962
|
this.elementCapturing = false;
|
|
3963
|
+
if (selected) this.elementError = false;
|
|
3964
|
+
this.removeSelectorHint();
|
|
3965
|
+
if (this.isOpen) this.render();
|
|
3966
|
+
}
|
|
3967
|
+
/** Surface a failed/cancelled element-selection attempt (mirrors setScreenshotError). */
|
|
3968
|
+
setElementError(failed) {
|
|
3969
|
+
this.elementError = failed;
|
|
3970
|
+
this.elementCapturing = false;
|
|
3923
3971
|
this.removeSelectorHint();
|
|
3924
3972
|
if (this.isOpen) this.render();
|
|
3925
3973
|
}
|
|
@@ -3936,6 +3984,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
3936
3984
|
setElementCapturing(capturing) {
|
|
3937
3985
|
this.elementCapturing = capturing;
|
|
3938
3986
|
if (capturing) {
|
|
3987
|
+
this.elementError = false;
|
|
3939
3988
|
this.showSelectorHint();
|
|
3940
3989
|
} else {
|
|
3941
3990
|
this.removeSelectorHint();
|
|
@@ -4412,10 +4461,70 @@ var MushiWidget = class _MushiWidget {
|
|
|
4412
4461
|
}
|
|
4413
4462
|
return "light";
|
|
4414
4463
|
}
|
|
4464
|
+
/** Snapshot in-progress form input from the live DOM before teardown. */
|
|
4465
|
+
captureFormDrafts() {
|
|
4466
|
+
const desc = this.shadow.querySelector(
|
|
4467
|
+
'textarea.mushi-textarea:not([data-role="reporter-reply"])'
|
|
4468
|
+
);
|
|
4469
|
+
const email = this.shadow.querySelector('[data-role="magic-link-email"]');
|
|
4470
|
+
const reply = this.shadow.querySelector(
|
|
4471
|
+
'textarea[data-role="reporter-reply"]'
|
|
4472
|
+
);
|
|
4473
|
+
if (desc) this.draftDescription = desc.value;
|
|
4474
|
+
if (email) this.draftEmail = email.value;
|
|
4475
|
+
if (reply) this.draftReply = reply.value;
|
|
4476
|
+
const active = this.shadow.activeElement;
|
|
4477
|
+
this.draftFocus = active && active === desc ? "description" : active && active === email ? "email" : active && active === reply ? "reply" : null;
|
|
4478
|
+
if (this.draftFocus && active) {
|
|
4479
|
+
const el = active;
|
|
4480
|
+
this.draftSelStart = el.selectionStart ?? el.value.length;
|
|
4481
|
+
this.draftSelEnd = el.selectionEnd ?? el.value.length;
|
|
4482
|
+
}
|
|
4483
|
+
}
|
|
4484
|
+
/** Replay captured drafts (value + focus + caret) into a freshly built panel. */
|
|
4485
|
+
restoreFormDrafts(panel) {
|
|
4486
|
+
const fields = [
|
|
4487
|
+
{
|
|
4488
|
+
selector: 'textarea.mushi-textarea:not([data-role="reporter-reply"])',
|
|
4489
|
+
value: this.draftDescription,
|
|
4490
|
+
key: "description"
|
|
4491
|
+
},
|
|
4492
|
+
{ selector: '[data-role="magic-link-email"]', value: this.draftEmail, key: "email" },
|
|
4493
|
+
{ selector: 'textarea[data-role="reporter-reply"]', value: this.draftReply, key: "reply" }
|
|
4494
|
+
];
|
|
4495
|
+
for (const field of fields) {
|
|
4496
|
+
const el = panel.querySelector(field.selector);
|
|
4497
|
+
if (!el) continue;
|
|
4498
|
+
if (field.value && el.value !== field.value) {
|
|
4499
|
+
el.value = field.value;
|
|
4500
|
+
el.dispatchEvent(new Event("input"));
|
|
4501
|
+
}
|
|
4502
|
+
if (this.draftFocus === field.key) {
|
|
4503
|
+
const applyFocus = () => {
|
|
4504
|
+
el.focus();
|
|
4505
|
+
try {
|
|
4506
|
+
el.setSelectionRange(this.draftSelStart, this.draftSelEnd);
|
|
4507
|
+
} catch {
|
|
4508
|
+
}
|
|
4509
|
+
};
|
|
4510
|
+
if (typeof requestAnimationFrame === "function") requestAnimationFrame(applyFocus);
|
|
4511
|
+
else applyFocus();
|
|
4512
|
+
}
|
|
4513
|
+
}
|
|
4514
|
+
}
|
|
4515
|
+
clearFormDrafts() {
|
|
4516
|
+
this.draftDescription = "";
|
|
4517
|
+
this.draftEmail = "";
|
|
4518
|
+
this.draftReply = "";
|
|
4519
|
+
this.draftFocus = null;
|
|
4520
|
+
this.draftSelStart = 0;
|
|
4521
|
+
this.draftSelEnd = 0;
|
|
4522
|
+
}
|
|
4415
4523
|
render() {
|
|
4416
4524
|
const theme = this.getTheme();
|
|
4417
4525
|
const pos = this.config.position;
|
|
4418
4526
|
const t = this.locale;
|
|
4527
|
+
if (this.isOpen) this.captureFormDrafts();
|
|
4419
4528
|
this.bannerResizeObserver?.disconnect();
|
|
4420
4529
|
this.bannerResizeObserver = null;
|
|
4421
4530
|
this.shadow.innerHTML = "";
|
|
@@ -4493,6 +4602,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
4493
4602
|
this.shadow.appendChild(panel);
|
|
4494
4603
|
this.attachHandlers(panel);
|
|
4495
4604
|
this.trapFocus(panel);
|
|
4605
|
+
this.restoreFormDrafts(panel);
|
|
4496
4606
|
this.attachViewportHandlers(panel);
|
|
4497
4607
|
} else {
|
|
4498
4608
|
this.teardownViewportHandlers();
|
|
@@ -4783,6 +4893,8 @@ var MushiWidget = class _MushiWidget {
|
|
|
4783
4893
|
screenshotAttached: this.screenshotAttached,
|
|
4784
4894
|
screenshotPreview: this.screenshotPreview,
|
|
4785
4895
|
screenshotHint: this.resolveScreenshotHint(),
|
|
4896
|
+
screenshotAvailable: this.screenshotAvailable,
|
|
4897
|
+
elementAvailable: this.elementAvailable,
|
|
4786
4898
|
reporterError: this.reporterError,
|
|
4787
4899
|
magicLinkError: this.magicLinkError,
|
|
4788
4900
|
elementCapturing: this.elementCapturing,
|
|
@@ -4795,6 +4907,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
4795
4907
|
globalLeaderboardLoading: this.globalLeaderboardLoading,
|
|
4796
4908
|
globalLeaderboard: this.globalLeaderboard,
|
|
4797
4909
|
elementSelected: this.elementSelected,
|
|
4910
|
+
elementError: this.elementError,
|
|
4798
4911
|
crossAppLoading: this.crossAppLoading,
|
|
4799
4912
|
callbacks: this.callbacks,
|
|
4800
4913
|
testerJwt: this.testerJwt,
|
|
@@ -5117,6 +5230,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
5117
5230
|
this.submitting = false;
|
|
5118
5231
|
this.step = "success";
|
|
5119
5232
|
this.render();
|
|
5233
|
+
this.draftDescription = "";
|
|
5120
5234
|
void outcomeP.then((outcome) => {
|
|
5121
5235
|
if (this.step !== "success") return;
|
|
5122
5236
|
if (outcome) {
|
|
@@ -5212,10 +5326,23 @@ var MushiWidget = class _MushiWidget {
|
|
|
5212
5326
|
async refreshReporterInboxQuiet() {
|
|
5213
5327
|
try {
|
|
5214
5328
|
this.reporterReports = await this.callbacks.onReporterReportsRequest?.() ?? [];
|
|
5215
|
-
if (this.isOpen)
|
|
5329
|
+
if (!this.isOpen) return;
|
|
5330
|
+
if (this.step === "reports") {
|
|
5331
|
+
this.render();
|
|
5332
|
+
} else {
|
|
5333
|
+
this.updateReportsBadgeText();
|
|
5334
|
+
}
|
|
5216
5335
|
} catch {
|
|
5217
5336
|
}
|
|
5218
5337
|
}
|
|
5338
|
+
/** Patch the "Your reports (N new)" nav label in place, if it is rendered. */
|
|
5339
|
+
updateReportsBadgeText() {
|
|
5340
|
+
const label = this.shadow.querySelector(".mushi-reports-entry .mushi-option-label");
|
|
5341
|
+
if (!label) return;
|
|
5342
|
+
const mn = this.locale.step1.moreNav;
|
|
5343
|
+
const unread = this.unreadCount();
|
|
5344
|
+
label.textContent = unread ? `${mn.yourReports} (${unread} ${mn.unreadNew})` : mn.yourReports;
|
|
5345
|
+
}
|
|
5219
5346
|
async loadReporterReports() {
|
|
5220
5347
|
this.step = "reports";
|
|
5221
5348
|
this.reporterLoading = true;
|
|
@@ -5231,6 +5358,9 @@ var MushiWidget = class _MushiWidget {
|
|
|
5231
5358
|
}
|
|
5232
5359
|
}
|
|
5233
5360
|
async loadReporterComments(reportId) {
|
|
5361
|
+
if (this.selectedReportId !== reportId) {
|
|
5362
|
+
this.draftReply = "";
|
|
5363
|
+
}
|
|
5234
5364
|
this.selectedReportId = reportId;
|
|
5235
5365
|
this.step = "report-detail";
|
|
5236
5366
|
this.reporterLoading = true;
|
|
@@ -5272,6 +5402,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
5272
5402
|
try {
|
|
5273
5403
|
await this.callbacks.onReporterReply?.(reportId, body);
|
|
5274
5404
|
if (textarea) textarea.value = "";
|
|
5405
|
+
this.draftReply = "";
|
|
5275
5406
|
await this.loadReporterComments(reportId);
|
|
5276
5407
|
} catch (err) {
|
|
5277
5408
|
this.reporterError = err instanceof Error ? err.message : "Could not send reply.";
|
|
@@ -5377,6 +5508,64 @@ var MushiWidget = class _MushiWidget {
|
|
|
5377
5508
|
}
|
|
5378
5509
|
};
|
|
5379
5510
|
|
|
5511
|
+
// src/runtime-merge.ts
|
|
5512
|
+
function mergeRuntimeCapture(host, runtime) {
|
|
5513
|
+
const merged = { ...host };
|
|
5514
|
+
if (runtime) {
|
|
5515
|
+
for (const [key, value] of Object.entries(runtime)) {
|
|
5516
|
+
if (value !== void 0) merged[key] = value;
|
|
5517
|
+
}
|
|
5518
|
+
}
|
|
5519
|
+
return merged;
|
|
5520
|
+
}
|
|
5521
|
+
function mergeRuntimeConfig(config, runtime) {
|
|
5522
|
+
const nativeTrigger = runtime.native?.triggerMode;
|
|
5523
|
+
const runtimeLauncher = runtime.widget?.launcher;
|
|
5524
|
+
const hostTrigger = config.widget?.trigger;
|
|
5525
|
+
const rawRuntimeTrigger = runtimeLauncher ?? runtime.widget?.trigger;
|
|
5526
|
+
const runtimeTrigger = rawRuntimeTrigger === "auto" && hostTrigger && hostTrigger !== "auto" ? void 0 : rawRuntimeTrigger;
|
|
5527
|
+
const widgetTrigger = runtimeTrigger ?? (nativeTrigger === "none" || nativeTrigger === "shake" ? "manual" : void 0);
|
|
5528
|
+
const explicitHidden = runtimeLauncher === "hidden" || runtime.widget?.trigger === "hidden";
|
|
5529
|
+
const safeWidgetTrigger = widgetTrigger === "hidden" && !explicitHidden && hostTrigger && hostTrigger !== "hidden" ? hostTrigger : widgetTrigger;
|
|
5530
|
+
const runtimeWidget = runtime.widget;
|
|
5531
|
+
const runtimeBannerVariant = runtimeWidget?.bannerVariant;
|
|
5532
|
+
const runtimeBannerPosition = runtimeWidget?.bannerPosition;
|
|
5533
|
+
const runtimeBannerMessage = runtimeWidget?.bannerMessage;
|
|
5534
|
+
const runtimeBannerLabel = runtimeWidget?.bannerLabel;
|
|
5535
|
+
const runtimeBannerBugCta = runtimeWidget?.bannerBugCta;
|
|
5536
|
+
const runtimeBannerFeatureCta = runtimeWidget?.bannerFeatureCta;
|
|
5537
|
+
const derivedBannerConfig = runtimeBannerVariant || runtimeBannerPosition || runtimeBannerMessage != null || runtimeBannerLabel != null || runtimeBannerBugCta != null || runtimeBannerFeatureCta != null ? {
|
|
5538
|
+
...config.widget?.bannerConfig ?? {},
|
|
5539
|
+
...runtimeBannerVariant ? { variant: runtimeBannerVariant } : {},
|
|
5540
|
+
...runtimeBannerPosition ? { position: runtimeBannerPosition } : {},
|
|
5541
|
+
...runtimeBannerMessage != null ? { message: runtimeBannerMessage } : {},
|
|
5542
|
+
...runtimeBannerLabel != null ? { label: runtimeBannerLabel === "" ? false : runtimeBannerLabel } : {},
|
|
5543
|
+
...runtimeBannerBugCta != null ? { bugCta: runtimeBannerBugCta ?? void 0 } : {},
|
|
5544
|
+
...runtimeBannerFeatureCta != null ? { featureCta: runtimeBannerFeatureCta } : {}
|
|
5545
|
+
} : void 0;
|
|
5546
|
+
const definedRuntimeWidget = {};
|
|
5547
|
+
if (runtime.widget) {
|
|
5548
|
+
for (const [key, value] of Object.entries(runtime.widget)) {
|
|
5549
|
+
if (key === "trigger" || key === "launcher") continue;
|
|
5550
|
+
if (value !== void 0 && value !== null) definedRuntimeWidget[key] = value;
|
|
5551
|
+
}
|
|
5552
|
+
}
|
|
5553
|
+
return {
|
|
5554
|
+
...config,
|
|
5555
|
+
widget: {
|
|
5556
|
+
...config.widget,
|
|
5557
|
+
...definedRuntimeWidget,
|
|
5558
|
+
...safeWidgetTrigger ? { trigger: safeWidgetTrigger } : {},
|
|
5559
|
+
...derivedBannerConfig ? { bannerConfig: derivedBannerConfig } : {},
|
|
5560
|
+
...config.widget?.betaMode ? { betaMode: config.widget.betaMode } : {}
|
|
5561
|
+
},
|
|
5562
|
+
capture: mergeRuntimeCapture(config.capture, runtime.capture),
|
|
5563
|
+
privacy: {
|
|
5564
|
+
...config.privacy
|
|
5565
|
+
}
|
|
5566
|
+
};
|
|
5567
|
+
}
|
|
5568
|
+
|
|
5380
5569
|
// src/marketing-recorder.ts
|
|
5381
5570
|
function centerOf(el) {
|
|
5382
5571
|
if (!el) return null;
|
|
@@ -7525,11 +7714,11 @@ var Mushi = class {
|
|
|
7525
7714
|
return createNoopInstance();
|
|
7526
7715
|
}
|
|
7527
7716
|
const resolved = { ...core.resolveEnvConfig(), ...config };
|
|
7528
|
-
if (!resolved.projectId) {
|
|
7529
|
-
|
|
7530
|
-
|
|
7531
|
-
|
|
7532
|
-
|
|
7717
|
+
if (!resolved.projectId || !resolved.apiKey) {
|
|
7718
|
+
const diagnostics = core.diagnoseEnvConfig();
|
|
7719
|
+
throw new Error(
|
|
7720
|
+
diagnostics.message ?? "[mushi] projectId and apiKey are required \u2014 set NEXT_PUBLIC_MUSHI_* / VITE_MUSHI_* / MUSHI_* or pass them explicitly"
|
|
7721
|
+
);
|
|
7533
7722
|
}
|
|
7534
7723
|
if (resolved.enabled === false) {
|
|
7535
7724
|
return createNoopInstance();
|
|
@@ -7549,7 +7738,8 @@ var Mushi = class {
|
|
|
7549
7738
|
}
|
|
7550
7739
|
};
|
|
7551
7740
|
function createInstance(config) {
|
|
7552
|
-
|
|
7741
|
+
core.validateConfig(config);
|
|
7742
|
+
const bootstrapConfig = core.expandPreset(config);
|
|
7553
7743
|
const projectId = bootstrapConfig.projectId;
|
|
7554
7744
|
const reporterTokenForProject = () => core.getReporterToken(projectId);
|
|
7555
7745
|
let activeConfig = bootstrapConfig;
|
|
@@ -7671,7 +7861,12 @@ function createInstance(config) {
|
|
|
7671
7861
|
perfCap = null;
|
|
7672
7862
|
}
|
|
7673
7863
|
if (activeConfig.capture?.screenshot !== "off") {
|
|
7674
|
-
const screenshotOptions = {
|
|
7864
|
+
const screenshotOptions = {
|
|
7865
|
+
privacy: activeConfig.privacy,
|
|
7866
|
+
// Surface capture failures (canvas taint, CSP) in the widget UI —
|
|
7867
|
+
// an invisible failure looks identical to a broken button.
|
|
7868
|
+
onFailed: () => widget.setScreenshotError(true)
|
|
7869
|
+
};
|
|
7675
7870
|
if (activeConfig.capture?.screenshotProvider) {
|
|
7676
7871
|
screenshotCap = null;
|
|
7677
7872
|
} else if (screenshotCap) {
|
|
@@ -7691,6 +7886,10 @@ function createInstance(config) {
|
|
|
7691
7886
|
elementSelector = null;
|
|
7692
7887
|
pendingElement = null;
|
|
7693
7888
|
}
|
|
7889
|
+
widget.setCaptureAvailability({
|
|
7890
|
+
screenshot: (!!screenshotCap || !!activeConfig.capture?.screenshotProvider) && activeConfig.capture?.screenshot !== "off",
|
|
7891
|
+
element: !!elementSelector
|
|
7892
|
+
});
|
|
7694
7893
|
const discoveryRaw = activeConfig.capture?.discoverInventory;
|
|
7695
7894
|
const discoveryConfig = discoveryRaw === true ? {} : discoveryRaw && typeof discoveryRaw === "object" ? discoveryRaw : null;
|
|
7696
7895
|
const discoveryEnabled = discoveryConfig != null && discoveryConfig.enabled !== false;
|
|
@@ -7895,11 +8094,24 @@ function createInstance(config) {
|
|
|
7895
8094
|
},
|
|
7896
8095
|
onScreenshotRequest: async () => {
|
|
7897
8096
|
const hasCapture = !!screenshotCap || !!activeConfig.capture?.screenshotProvider;
|
|
7898
|
-
if (!hasCapture || activeConfig.capture?.screenshot === "off")
|
|
8097
|
+
if (!hasCapture || activeConfig.capture?.screenshot === "off") {
|
|
8098
|
+
log.warn("Screenshot requested but capture is disabled");
|
|
8099
|
+
widget.setScreenshotError(true);
|
|
8100
|
+
return;
|
|
8101
|
+
}
|
|
7899
8102
|
log.debug("Taking screenshot");
|
|
7900
|
-
|
|
8103
|
+
widget.setScreenshotCapturing(true);
|
|
8104
|
+
try {
|
|
8105
|
+
pendingScreenshot = await takeScreenshotWithoutChrome();
|
|
8106
|
+
} catch (err) {
|
|
8107
|
+
log.warn("Screenshot capture threw", {
|
|
8108
|
+
error: err instanceof Error ? err.message : String(err)
|
|
8109
|
+
});
|
|
8110
|
+
pendingScreenshot = null;
|
|
8111
|
+
}
|
|
7901
8112
|
widget.setScreenshotAttached(pendingScreenshot !== null);
|
|
7902
8113
|
widget.setScreenshotPreview(pendingScreenshot);
|
|
8114
|
+
if (pendingScreenshot === null) widget.setScreenshotError(true);
|
|
7903
8115
|
},
|
|
7904
8116
|
onScreenshotRemove: () => {
|
|
7905
8117
|
log.debug("Screenshot attachment removed");
|
|
@@ -7957,7 +8169,11 @@ function createInstance(config) {
|
|
|
7957
8169
|
container.insertBefore(toolbar, container.firstChild);
|
|
7958
8170
|
},
|
|
7959
8171
|
onElementSelectorRequest: async () => {
|
|
7960
|
-
if (!elementSelector || activeConfig.capture?.elementSelector === false)
|
|
8172
|
+
if (!elementSelector || activeConfig.capture?.elementSelector === false) {
|
|
8173
|
+
log.warn("Element selector requested but it is disabled/unavailable");
|
|
8174
|
+
widget.setElementError(true);
|
|
8175
|
+
return;
|
|
8176
|
+
}
|
|
7961
8177
|
log.debug("Element selector activated");
|
|
7962
8178
|
widget.setElementCapturing(true);
|
|
7963
8179
|
widget.hidePanel();
|
|
@@ -7970,6 +8186,11 @@ function createInstance(config) {
|
|
|
7970
8186
|
} else {
|
|
7971
8187
|
widget.setElementCapturing(false);
|
|
7972
8188
|
}
|
|
8189
|
+
} catch (err) {
|
|
8190
|
+
log.warn("Element selector threw", {
|
|
8191
|
+
error: err instanceof Error ? err.message : String(err)
|
|
8192
|
+
});
|
|
8193
|
+
widget.setElementError(true);
|
|
7973
8194
|
} finally {
|
|
7974
8195
|
widget.showPanel();
|
|
7975
8196
|
}
|
|
@@ -8848,108 +9069,6 @@ function createInstance(config) {
|
|
|
8848
9069
|
});
|
|
8849
9070
|
return isolatePublicApi(sdk);
|
|
8850
9071
|
}
|
|
8851
|
-
function mergeRuntimeConfig(config, runtime) {
|
|
8852
|
-
const nativeTrigger = runtime.native?.triggerMode;
|
|
8853
|
-
const runtimeLauncher = runtime.widget?.launcher;
|
|
8854
|
-
const widgetTrigger = runtimeLauncher ?? runtime.widget?.trigger ?? (nativeTrigger === "none" || nativeTrigger === "shake" ? "manual" : void 0);
|
|
8855
|
-
const explicitHidden = runtimeLauncher === "hidden" || runtime.widget?.trigger === "hidden";
|
|
8856
|
-
const hostTrigger = config.widget?.trigger;
|
|
8857
|
-
const safeWidgetTrigger = widgetTrigger === "hidden" && !explicitHidden && hostTrigger && hostTrigger !== "hidden" ? hostTrigger : widgetTrigger;
|
|
8858
|
-
const runtimeWidget = runtime.widget;
|
|
8859
|
-
const runtimeBannerVariant = runtimeWidget?.bannerVariant;
|
|
8860
|
-
const runtimeBannerPosition = runtimeWidget?.bannerPosition;
|
|
8861
|
-
const runtimeBannerMessage = runtimeWidget?.bannerMessage;
|
|
8862
|
-
const runtimeBannerLabel = runtimeWidget?.bannerLabel;
|
|
8863
|
-
const runtimeBannerBugCta = runtimeWidget?.bannerBugCta;
|
|
8864
|
-
const runtimeBannerFeatureCta = runtimeWidget?.bannerFeatureCta;
|
|
8865
|
-
const derivedBannerConfig = runtimeBannerVariant || runtimeBannerPosition || runtimeBannerMessage != null || runtimeBannerLabel != null || runtimeBannerBugCta != null || runtimeBannerFeatureCta != null ? {
|
|
8866
|
-
...config.widget?.bannerConfig ?? {},
|
|
8867
|
-
...runtimeBannerVariant ? { variant: runtimeBannerVariant } : {},
|
|
8868
|
-
...runtimeBannerPosition ? { position: runtimeBannerPosition } : {},
|
|
8869
|
-
...runtimeBannerMessage != null ? { message: runtimeBannerMessage } : {},
|
|
8870
|
-
// Dashboard sends an empty string to hide the pill (the runtime
|
|
8871
|
-
// payload has no way to express the local-config `label: false`).
|
|
8872
|
-
...runtimeBannerLabel != null ? { label: runtimeBannerLabel === "" ? false : runtimeBannerLabel } : {},
|
|
8873
|
-
...runtimeBannerBugCta != null ? { bugCta: runtimeBannerBugCta ?? void 0 } : {},
|
|
8874
|
-
...runtimeBannerFeatureCta != null ? { featureCta: runtimeBannerFeatureCta } : {}
|
|
8875
|
-
} : void 0;
|
|
8876
|
-
return {
|
|
8877
|
-
...config,
|
|
8878
|
-
widget: {
|
|
8879
|
-
...config.widget,
|
|
8880
|
-
...runtime.widget,
|
|
8881
|
-
...safeWidgetTrigger ? { trigger: safeWidgetTrigger } : {},
|
|
8882
|
-
...derivedBannerConfig ? { bannerConfig: derivedBannerConfig } : {},
|
|
8883
|
-
// betaMode is local-only: set by the host app, not the dashboard.
|
|
8884
|
-
// Restore it after the runtime spread so it is never silently cleared.
|
|
8885
|
-
...config.widget?.betaMode ? { betaMode: config.widget.betaMode } : {}
|
|
8886
|
-
},
|
|
8887
|
-
capture: {
|
|
8888
|
-
...config.capture,
|
|
8889
|
-
...runtime.capture
|
|
8890
|
-
},
|
|
8891
|
-
privacy: {
|
|
8892
|
-
...config.privacy
|
|
8893
|
-
}
|
|
8894
|
-
};
|
|
8895
|
-
}
|
|
8896
|
-
function applyPresetConfig(config) {
|
|
8897
|
-
if (!config.preset) return config;
|
|
8898
|
-
const preset = presetDefaults(config.preset);
|
|
8899
|
-
return {
|
|
8900
|
-
...config,
|
|
8901
|
-
widget: {
|
|
8902
|
-
...preset.widget,
|
|
8903
|
-
...config.widget
|
|
8904
|
-
},
|
|
8905
|
-
capture: {
|
|
8906
|
-
...preset.capture,
|
|
8907
|
-
...config.capture
|
|
8908
|
-
},
|
|
8909
|
-
proactive: {
|
|
8910
|
-
...preset.proactive,
|
|
8911
|
-
...config.proactive,
|
|
8912
|
-
cooldown: {
|
|
8913
|
-
...preset.proactive?.cooldown,
|
|
8914
|
-
...config.proactive?.cooldown
|
|
8915
|
-
}
|
|
8916
|
-
}
|
|
8917
|
-
};
|
|
8918
|
-
}
|
|
8919
|
-
function presetDefaults(preset) {
|
|
8920
|
-
switch (preset) {
|
|
8921
|
-
case "manual-only":
|
|
8922
|
-
return {
|
|
8923
|
-
widget: { trigger: "manual", outdatedBanner: "console-only" },
|
|
8924
|
-
capture: { console: true, network: true, performance: false, screenshot: "on-report", elementSelector: false },
|
|
8925
|
-
proactive: { rageClick: false, longTask: false, apiCascade: false, errorBoundary: false }
|
|
8926
|
-
};
|
|
8927
|
-
case "beta-loud":
|
|
8928
|
-
return {
|
|
8929
|
-
widget: { trigger: "auto", outdatedBanner: "banner" },
|
|
8930
|
-
capture: { console: true, network: true, performance: true, screenshot: "auto", elementSelector: true },
|
|
8931
|
-
proactive: { rageClick: true, longTask: true, apiCascade: true, errorBoundary: true }
|
|
8932
|
-
};
|
|
8933
|
-
case "internal-debug":
|
|
8934
|
-
return {
|
|
8935
|
-
widget: { trigger: "auto", outdatedBanner: "banner", brandFooter: true },
|
|
8936
|
-
capture: { console: true, network: true, performance: true, screenshot: "auto", elementSelector: true },
|
|
8937
|
-
proactive: {
|
|
8938
|
-
rageClick: true,
|
|
8939
|
-
longTask: true,
|
|
8940
|
-
apiCascade: true,
|
|
8941
|
-
errorBoundary: true,
|
|
8942
|
-
cooldown: { maxProactivePerSession: 10, dismissCooldownHours: 0, suppressAfterDismissals: 99 }
|
|
8943
|
-
}
|
|
8944
|
-
};
|
|
8945
|
-
case "production-calm":
|
|
8946
|
-
return {
|
|
8947
|
-
widget: { trigger: "auto", outdatedBanner: "console-only" },
|
|
8948
|
-
capture: { console: true, network: true, performance: false, screenshot: "on-report", elementSelector: false },
|
|
8949
|
-
proactive: { rageClick: false, longTask: false, apiCascade: false, errorBoundary: false }
|
|
8950
|
-
};
|
|
8951
|
-
}
|
|
8952
|
-
}
|
|
8953
9072
|
function resolveApiEndpoint(config) {
|
|
8954
9073
|
return config.apiEndpoint ?? core.DEFAULT_API_ENDPOINT;
|
|
8955
9074
|
}
|