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