@mushi-mushi/web 1.16.0 → 1.18.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.cjs +247 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +247 -54
- package/dist/index.js.map +1 -1
- package/dist/mushi.loader.global.js +348 -249
- package/dist/mushi.loader.global.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -487,9 +487,9 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
487
487
|
|
|
488
488
|
.mushi-panel {
|
|
489
489
|
position: fixed;
|
|
490
|
-
width:
|
|
490
|
+
width: 360px;
|
|
491
491
|
max-width: calc(100vw - 32px);
|
|
492
|
-
max-height: min(
|
|
492
|
+
max-height: min(480px, calc(100dvh - 120px - var(--mushi-keyboard-inset, 0px)));
|
|
493
493
|
background: ${paper};
|
|
494
494
|
border: 1px solid ${ruleStrong};
|
|
495
495
|
border-radius: 6px;
|
|
@@ -575,12 +575,12 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
575
575
|
}
|
|
576
576
|
|
|
577
577
|
.mushi-header {
|
|
578
|
-
padding: 18px
|
|
578
|
+
padding: 13px 18px 10px;
|
|
579
579
|
border-bottom: 1px solid ${rule};
|
|
580
580
|
display: grid;
|
|
581
581
|
grid-template-columns: auto 1fr auto;
|
|
582
582
|
align-items: end;
|
|
583
|
-
gap:
|
|
583
|
+
gap: 10px;
|
|
584
584
|
}
|
|
585
585
|
.mushi-header-mark {
|
|
586
586
|
display: inline-flex;
|
|
@@ -655,17 +655,22 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
655
655
|
background: none;
|
|
656
656
|
border: none;
|
|
657
657
|
cursor: pointer;
|
|
658
|
-
padding: 0;
|
|
658
|
+
padding: 3px 0;
|
|
659
659
|
margin: 0 0 2px;
|
|
660
|
+
min-height: 22px;
|
|
660
661
|
color: ${inkMuted};
|
|
661
662
|
font-family: ${fontMono};
|
|
662
|
-
font-size:
|
|
663
|
+
font-size: 11px;
|
|
663
664
|
font-weight: 500;
|
|
664
|
-
letter-spacing: 0.
|
|
665
|
+
letter-spacing: 0.06em;
|
|
665
666
|
text-transform: uppercase;
|
|
666
667
|
line-height: 1.2;
|
|
667
668
|
border-radius: 0;
|
|
669
|
+
display: inline-flex;
|
|
670
|
+
align-items: center;
|
|
671
|
+
gap: 4px;
|
|
668
672
|
transition: color 150ms ${easeStamp};
|
|
673
|
+
white-space: nowrap;
|
|
669
674
|
}
|
|
670
675
|
.mushi-close:hover { color: ${widgetAccent}; }
|
|
671
676
|
.mushi-back:hover { color: ${ink}; }
|
|
@@ -698,9 +703,9 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
698
703
|
display: grid;
|
|
699
704
|
grid-template-columns: auto 1fr auto;
|
|
700
705
|
align-items: center;
|
|
701
|
-
gap:
|
|
706
|
+
gap: 12px;
|
|
702
707
|
width: 100%;
|
|
703
|
-
padding:
|
|
708
|
+
padding: 11px 0;
|
|
704
709
|
border: none;
|
|
705
710
|
border-bottom: 1px solid ${rule};
|
|
706
711
|
background: transparent;
|
|
@@ -1370,6 +1375,20 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1370
1375
|
.mushi-success-receipt-warn {
|
|
1371
1376
|
color: ${widgetAccent};
|
|
1372
1377
|
}
|
|
1378
|
+
.mushi-success-my-reports {
|
|
1379
|
+
display: block;
|
|
1380
|
+
margin: 12px auto 0;
|
|
1381
|
+
font-size: 12px;
|
|
1382
|
+
font-family: ${fontMono};
|
|
1383
|
+
color: ${widgetAccent};
|
|
1384
|
+
text-decoration: underline;
|
|
1385
|
+
text-underline-offset: 2px;
|
|
1386
|
+
background: none;
|
|
1387
|
+
border: none;
|
|
1388
|
+
cursor: pointer;
|
|
1389
|
+
padding: 4px 2px;
|
|
1390
|
+
}
|
|
1391
|
+
.mushi-success-my-reports:hover { opacity: 0.75; }
|
|
1373
1392
|
.mushi-success-sla {
|
|
1374
1393
|
margin-top: 2px;
|
|
1375
1394
|
font-family: ${fontDisplay};
|
|
@@ -1861,6 +1880,28 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1861
1880
|
}
|
|
1862
1881
|
.mushi-banner.neon .mushi-banner-dismiss:hover { background: rgba(0,0,0,0.18) !important; }
|
|
1863
1882
|
|
|
1883
|
+
/* "My reports" link in the simple (non-rich) banner layout */
|
|
1884
|
+
.mushi-banner-my-reports {
|
|
1885
|
+
background: transparent;
|
|
1886
|
+
border: none;
|
|
1887
|
+
cursor: pointer;
|
|
1888
|
+
font-size: 11px;
|
|
1889
|
+
font-family: ${fontMono};
|
|
1890
|
+
opacity: 0.75;
|
|
1891
|
+
color: inherit;
|
|
1892
|
+
padding: 2px 6px;
|
|
1893
|
+
border-radius: 3px;
|
|
1894
|
+
white-space: nowrap;
|
|
1895
|
+
flex-shrink: 0;
|
|
1896
|
+
transition: opacity 0.15s, background 0.15s;
|
|
1897
|
+
margin-left: 4px;
|
|
1898
|
+
}
|
|
1899
|
+
.mushi-banner-my-reports:hover {
|
|
1900
|
+
opacity: 1;
|
|
1901
|
+
background: rgba(0,0,0,0.10);
|
|
1902
|
+
}
|
|
1903
|
+
.mushi-banner.neon .mushi-banner-my-reports:hover { background: rgba(0,0,0,0.18); }
|
|
1904
|
+
|
|
1864
1905
|
@keyframes mushi-banner-slide-in {
|
|
1865
1906
|
from { transform: translateY(calc(-1 * 100%)); opacity: 0.5; }
|
|
1866
1907
|
to { transform: translateY(0); opacity: 1; }
|
|
@@ -1888,6 +1929,56 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1888
1929
|
|
|
1889
1930
|
.mushi-community-footer{display:flex;align-items:center;gap:8px;padding:10px 0 2px;border-top:1px solid ${isDark ? "rgba(255,255,255,0.07)" : "rgba(0,0,0,0.07)"};margin-top:8px;flex-wrap:wrap}
|
|
1890
1931
|
.mushi-community-btn{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
1932
|
+
/* \u2500\u2500 "More issue types \u2192" toggle (progressive disclosure) \u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
1933
|
+
.mushi-more-toggle {
|
|
1934
|
+
display: flex;
|
|
1935
|
+
align-items: center;
|
|
1936
|
+
gap: 8px;
|
|
1937
|
+
width: 100%;
|
|
1938
|
+
padding: 11px 0;
|
|
1939
|
+
border: none;
|
|
1940
|
+
border-top: 1px dashed ${rule};
|
|
1941
|
+
background: transparent;
|
|
1942
|
+
cursor: pointer;
|
|
1943
|
+
color: ${inkMuted};
|
|
1944
|
+
font-family: ${fontBody};
|
|
1945
|
+
font-size: 13px;
|
|
1946
|
+
text-align: left;
|
|
1947
|
+
transition: color 180ms ${easeStamp};
|
|
1948
|
+
}
|
|
1949
|
+
.mushi-more-toggle:hover { color: ${widgetAccent}; }
|
|
1950
|
+
.mushi-more-toggle:hover .mushi-more-toggle-arrow { transform: translateX(3px); }
|
|
1951
|
+
.mushi-more-toggle-text { flex: 1; }
|
|
1952
|
+
.mushi-more-toggle-count {
|
|
1953
|
+
font-family: ${fontMono};
|
|
1954
|
+
font-size: 10px;
|
|
1955
|
+
letter-spacing: 0.08em;
|
|
1956
|
+
text-transform: uppercase;
|
|
1957
|
+
color: ${inkFaint};
|
|
1958
|
+
background: ${isDark ? "rgba(255,255,255,0.07)" : "rgba(0,0,0,0.06)"};
|
|
1959
|
+
padding: 2px 6px;
|
|
1960
|
+
border-radius: 10px;
|
|
1961
|
+
}
|
|
1962
|
+
.mushi-more-toggle-arrow {
|
|
1963
|
+
font-size: 14px;
|
|
1964
|
+
opacity: 0.5;
|
|
1965
|
+
transition: transform 180ms ${easeStamp};
|
|
1966
|
+
}
|
|
1967
|
+
/* \u2500\u2500 Step slide-in \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
1968
|
+
@keyframes mushi-step-in {
|
|
1969
|
+
0% { opacity: 0; transform: translateX(8px); }
|
|
1970
|
+
100% { opacity: 1; transform: translateX(0); }
|
|
1971
|
+
}
|
|
1972
|
+
.mushi-body {
|
|
1973
|
+
animation: mushi-step-in 160ms ease both;
|
|
1974
|
+
}
|
|
1975
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1976
|
+
.mushi-body { animation: none; }
|
|
1977
|
+
}
|
|
1978
|
+
/* Expanded secondary categories animate in */
|
|
1979
|
+
.mushi-categories-expanded {
|
|
1980
|
+
animation: mushi-step-in 180ms ease both;
|
|
1981
|
+
}
|
|
1891
1982
|
.mushi-link-btn{background:none;border:none;padding:4px 2px;cursor:pointer;color:${widgetAccent};font-size:12px;font-family:${fontMono};text-decoration:underline;text-underline-offset:2px}
|
|
1892
1983
|
.mushi-link-btn:hover{opacity:0.8}
|
|
1893
1984
|
.mushi-link-btn:focus-visible,.mushi-nav-item:focus-visible{outline:2px solid ${widgetAccent};outline-offset:2px;border-radius:2px}
|
|
@@ -1928,7 +2019,7 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1928
2019
|
|
|
1929
2020
|
// src/version.ts
|
|
1930
2021
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
1931
|
-
var MUSHI_SDK_VERSION = "1.
|
|
2022
|
+
var MUSHI_SDK_VERSION = "1.18.0" ;
|
|
1932
2023
|
|
|
1933
2024
|
// src/widget-helpers.ts
|
|
1934
2025
|
var CATEGORY_ICONS = {
|
|
@@ -2131,7 +2222,7 @@ function renderBrandFooter(ctx) {
|
|
|
2131
2222
|
function renderHeader(ctx, opts) {
|
|
2132
2223
|
const t = ctx.locale;
|
|
2133
2224
|
const { title, showBack = false, step, eyebrow } = opts;
|
|
2134
|
-
const eyebrowHtml = showBack ? `<button type="button" class="mushi-back" data-action="back" aria-label="${t.widget.back}">\u2190</button>` : `<span class="mushi-header-eyebrow">${eyebrow ?? "Mushi \xB7 Report"}</span>`;
|
|
2225
|
+
const eyebrowHtml = showBack ? `<button type="button" class="mushi-back" data-action="back" aria-label="${t.widget.back}">\u2190 ${escapeHtml(t.widget.back)}</button>` : `<span class="mushi-header-eyebrow">${eyebrow ?? "Mushi \xB7 Report"}</span>`;
|
|
2135
2226
|
const counterHtml = step ? `<span class="mushi-step-counter" aria-label="Step ${step} of ${TOTAL_STEPS}"><b>${pad2(step)}</b> / ${pad2(TOTAL_STEPS)}</span>` : "";
|
|
2136
2227
|
return `
|
|
2137
2228
|
<div class="mushi-header">
|
|
@@ -2169,16 +2260,28 @@ function renderCategoryStep(ctx) {
|
|
|
2169
2260
|
label: t.step1.categories[id],
|
|
2170
2261
|
desc: t.step1.categoryDescriptions[id]
|
|
2171
2262
|
}));
|
|
2172
|
-
const
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2263
|
+
const renderEntry = ({ id, icon, label, desc }) => `
|
|
2264
|
+
<button type="button" class="mushi-option-btn" data-category="${escapeHtml(id)}" role="radio" aria-checked="false">
|
|
2265
|
+
<span class="mushi-option-icon" aria-hidden="true">${escapeHtml(icon)}</span>
|
|
2266
|
+
<div class="mushi-option-text">
|
|
2267
|
+
<span class="mushi-option-label">${escapeHtml(label)}</span>
|
|
2268
|
+
${desc ? `<span class="mushi-option-desc">${escapeHtml(desc)}</span>` : ""}
|
|
2269
|
+
</div>
|
|
2270
|
+
<span class="mushi-option-arrow" aria-hidden="true">\u2192</span>
|
|
2271
|
+
</button>
|
|
2272
|
+
`;
|
|
2273
|
+
const isCustom = ctx.config.categories && ctx.config.categories.length > 0;
|
|
2274
|
+
const PRIMARY_LIMIT = 1;
|
|
2275
|
+
const primaryEntries = isCustom ? categoryEntries : categoryEntries.slice(0, PRIMARY_LIMIT);
|
|
2276
|
+
const secondaryEntries = isCustom ? [] : categoryEntries.slice(PRIMARY_LIMIT);
|
|
2277
|
+
const hasMore = secondaryEntries.length > 0;
|
|
2278
|
+
const primaryCategories = primaryEntries.map(renderEntry).join("");
|
|
2279
|
+
const secondaryCategories = secondaryEntries.map(renderEntry).join("");
|
|
2280
|
+
const secondaryHtml = hasMore ? ctx.showAllCategories ? `<div class="mushi-categories-expanded">${secondaryCategories}</div>` : `<button type="button" class="mushi-more-toggle" data-action="show-all-categories">
|
|
2281
|
+
<span class="mushi-more-toggle-text">More issue types</span>
|
|
2282
|
+
<span class="mushi-more-toggle-count">${secondaryEntries.length} more</span>
|
|
2283
|
+
<span class="mushi-more-toggle-arrow" aria-hidden="true">\u2192</span>
|
|
2284
|
+
</button>` : "";
|
|
2182
2285
|
return `
|
|
2183
2286
|
${renderHeader(ctx, { title: t.step1.heading, step: STEP_NUMBER.category })}
|
|
2184
2287
|
${ctx.config.betaMode?.enabled ? renderBetaStrip(ctx) : ""}
|
|
@@ -2201,7 +2304,8 @@ function renderCategoryStep(ctx) {
|
|
|
2201
2304
|
</div>
|
|
2202
2305
|
<span class="mushi-option-arrow" aria-hidden="true">\u2192</span>
|
|
2203
2306
|
</button>` : ""}
|
|
2204
|
-
${
|
|
2307
|
+
${primaryCategories}
|
|
2308
|
+
${secondaryHtml}
|
|
2205
2309
|
${ctx.rewardsState ? renderRewardsNudge(ctx) : ""}
|
|
2206
2310
|
<div class="mushi-community-footer">
|
|
2207
2311
|
<button type="button" class="mushi-link-btn mushi-community-btn" data-action="open-account">
|
|
@@ -2588,7 +2692,7 @@ function renderSuccessStep(ctx) {
|
|
|
2588
2692
|
const stamp = ctx.submittedAt ?? /* @__PURE__ */ new Date();
|
|
2589
2693
|
const time = stamp.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit", second: "2-digit", hour12: false });
|
|
2590
2694
|
return `
|
|
2591
|
-
${renderHeader(ctx, { title: t.widget.title, eyebrow: "Mushi \xB7 Receipt" })}
|
|
2695
|
+
${renderHeader(ctx, { title: t.widget.title, showBack: true, eyebrow: "Mushi \xB7 Receipt" })}
|
|
2592
2696
|
<div class="mushi-body">
|
|
2593
2697
|
<div class="mushi-success">
|
|
2594
2698
|
<div class="mushi-success-stamp" aria-hidden="true">
|
|
@@ -2600,6 +2704,9 @@ function renderSuccessStep(ctx) {
|
|
|
2600
2704
|
${renderSuccessReceipt(ctx)}
|
|
2601
2705
|
${ctx.rewardsState ? renderSuccessRewards(ctx) : ""}
|
|
2602
2706
|
${ctx.config.betaMode?.enabled ? renderBetaSuccessFooter(ctx) : ""}
|
|
2707
|
+
<button type="button" class="mushi-link-btn mushi-success-my-reports" data-action="view-my-reports">
|
|
2708
|
+
\u{1F4EC} Track this report ›
|
|
2709
|
+
</button>
|
|
2603
2710
|
</div>
|
|
2604
2711
|
</div>
|
|
2605
2712
|
`;
|
|
@@ -2800,6 +2907,8 @@ var MushiWidget = class _MushiWidget {
|
|
|
2800
2907
|
* landing on the intent picker the user explicitly skipped.
|
|
2801
2908
|
*/
|
|
2802
2909
|
viaFeatureRequest = false;
|
|
2910
|
+
/** Whether the category list is fully expanded (progressive disclosure). */
|
|
2911
|
+
showAllCategories = false;
|
|
2803
2912
|
screenshotAttached = false;
|
|
2804
2913
|
screenshotCapturing = false;
|
|
2805
2914
|
screenshotError = false;
|
|
@@ -2853,6 +2962,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
2853
2962
|
lastSubmitQueuedOffline = false;
|
|
2854
2963
|
/** Whether the user has clicked ✕ on the header banner this session. */
|
|
2855
2964
|
bannerDismissed = false;
|
|
2965
|
+
bannerResizeObserver = null;
|
|
2856
2966
|
/** Persisted FAB position when draggable is enabled. */
|
|
2857
2967
|
fabPos = null;
|
|
2858
2968
|
/** Cleanup fn for visualViewport keyboard listener. */
|
|
@@ -3006,6 +3116,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
3006
3116
|
close() {
|
|
3007
3117
|
if (!this.isOpen) return;
|
|
3008
3118
|
this.isOpen = false;
|
|
3119
|
+
this.showAllCategories = false;
|
|
3009
3120
|
this.render();
|
|
3010
3121
|
this.callbacks.onClose();
|
|
3011
3122
|
}
|
|
@@ -3375,27 +3486,49 @@ var MushiWidget = class _MushiWidget {
|
|
|
3375
3486
|
const action = this.config.environments[this.detectEnvironment()];
|
|
3376
3487
|
return action !== "never" && action !== "manual";
|
|
3377
3488
|
}
|
|
3378
|
-
/** Height of the banner in px —
|
|
3489
|
+
/** Height of the banner in px — used as a fallback before first layout. */
|
|
3379
3490
|
static BANNER_HEIGHT = 36;
|
|
3380
|
-
/** CSS property applied to
|
|
3491
|
+
/** CSS property applied to documentElement so host-app content doesn't slide under the banner. */
|
|
3381
3492
|
static BODY_NUDGE_PROP = "--mushi-banner-offset";
|
|
3382
|
-
applyBodyNudge(position) {
|
|
3383
|
-
const h = `${
|
|
3493
|
+
applyBodyNudge(position, heightPx = _MushiWidget.BANNER_HEIGHT) {
|
|
3494
|
+
const h = `${heightPx}px`;
|
|
3495
|
+
document.documentElement.style.setProperty(_MushiWidget.BODY_NUDGE_PROP, h);
|
|
3384
3496
|
if (position === "top") {
|
|
3385
|
-
document.
|
|
3386
|
-
|
|
3497
|
+
if (document.body.dataset.mushiBannerNudged === "top") {
|
|
3498
|
+
document.body.style.paddingTop = h;
|
|
3499
|
+
} else if (!document.body.style.paddingTop) {
|
|
3387
3500
|
document.body.style.paddingTop = h;
|
|
3388
3501
|
document.body.dataset.mushiBannerNudged = "top";
|
|
3389
3502
|
}
|
|
3390
3503
|
} else {
|
|
3391
|
-
document.
|
|
3392
|
-
|
|
3504
|
+
if (document.body.dataset.mushiBannerNudged === "bottom") {
|
|
3505
|
+
document.body.style.paddingBottom = h;
|
|
3506
|
+
} else if (!document.body.style.paddingBottom) {
|
|
3393
3507
|
document.body.style.paddingBottom = h;
|
|
3394
3508
|
document.body.dataset.mushiBannerNudged = "bottom";
|
|
3395
3509
|
}
|
|
3396
3510
|
}
|
|
3397
3511
|
}
|
|
3512
|
+
/**
|
|
3513
|
+
* Schedule a height measurement after the next paint and set up a ResizeObserver
|
|
3514
|
+
* so --mushi-banner-offset always tracks the actual rendered banner height
|
|
3515
|
+
* (which can exceed BANNER_HEIGHT when safe-area-inset-top is in play on iOS,
|
|
3516
|
+
* or when rich-layout text wraps on narrow viewports).
|
|
3517
|
+
*/
|
|
3518
|
+
trackBannerHeight(banner, position) {
|
|
3519
|
+
const update = () => {
|
|
3520
|
+
const h = banner.getBoundingClientRect().height;
|
|
3521
|
+
if (h > 0) this.applyBodyNudge(position, h);
|
|
3522
|
+
};
|
|
3523
|
+
requestAnimationFrame(update);
|
|
3524
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
3525
|
+
this.bannerResizeObserver = new ResizeObserver(update);
|
|
3526
|
+
this.bannerResizeObserver.observe(banner);
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3398
3529
|
removeBodyNudge() {
|
|
3530
|
+
this.bannerResizeObserver?.disconnect();
|
|
3531
|
+
this.bannerResizeObserver = null;
|
|
3399
3532
|
document.documentElement.style.removeProperty(_MushiWidget.BODY_NUDGE_PROP);
|
|
3400
3533
|
const nudged = document.body.dataset.mushiBannerNudged;
|
|
3401
3534
|
if (nudged === "top") {
|
|
@@ -3504,6 +3637,8 @@ var MushiWidget = class _MushiWidget {
|
|
|
3504
3637
|
}, true);
|
|
3505
3638
|
}
|
|
3506
3639
|
}
|
|
3640
|
+
appendDivider(true);
|
|
3641
|
+
appendAction("\u{1F4EC} My reports", () => this.openReporter(), true);
|
|
3507
3642
|
banner.appendChild(nav);
|
|
3508
3643
|
banner.appendChild(dismissBtn);
|
|
3509
3644
|
} else {
|
|
@@ -3519,10 +3654,17 @@ var MushiWidget = class _MushiWidget {
|
|
|
3519
3654
|
featBtn.addEventListener("click", () => this.open({ featureRequest: true }));
|
|
3520
3655
|
banner.appendChild(featBtn);
|
|
3521
3656
|
}
|
|
3657
|
+
const myReportsBtn = document.createElement("button");
|
|
3658
|
+
myReportsBtn.className = "mushi-banner-my-reports";
|
|
3659
|
+
myReportsBtn.textContent = "\u{1F4EC} My reports";
|
|
3660
|
+
myReportsBtn.setAttribute("aria-label", "View my submitted reports");
|
|
3661
|
+
myReportsBtn.addEventListener("click", () => this.openReporter());
|
|
3662
|
+
banner.appendChild(myReportsBtn);
|
|
3522
3663
|
banner.appendChild(dismissBtn);
|
|
3523
3664
|
}
|
|
3524
3665
|
this.shadow.appendChild(banner);
|
|
3525
3666
|
this.applyBodyNudge(position);
|
|
3667
|
+
this.trackBannerHeight(banner, position);
|
|
3526
3668
|
}
|
|
3527
3669
|
effectiveTrigger() {
|
|
3528
3670
|
if (!this.config.smartHide || typeof window === "undefined") return this.config.trigger;
|
|
@@ -3576,6 +3718,8 @@ var MushiWidget = class _MushiWidget {
|
|
|
3576
3718
|
const theme = this.getTheme();
|
|
3577
3719
|
const pos = this.config.position;
|
|
3578
3720
|
const t = this.locale;
|
|
3721
|
+
this.bannerResizeObserver?.disconnect();
|
|
3722
|
+
this.bannerResizeObserver = null;
|
|
3579
3723
|
this.shadow.innerHTML = "";
|
|
3580
3724
|
const style = document.createElement("style");
|
|
3581
3725
|
style.textContent = getWidgetStyles(theme, this.config.accent ?? "", this.config.accentText ?? "");
|
|
@@ -3979,7 +4123,8 @@ var MushiWidget = class _MushiWidget {
|
|
|
3979
4123
|
categoryIcon: (id) => this.categoryIcon(id),
|
|
3980
4124
|
assistantTurns: this.assistantTurns,
|
|
3981
4125
|
assistantSending: this.assistantSending,
|
|
3982
|
-
assistantError: this.assistantError
|
|
4126
|
+
assistantError: this.assistantError,
|
|
4127
|
+
showAllCategories: this.showAllCategories
|
|
3983
4128
|
};
|
|
3984
4129
|
}
|
|
3985
4130
|
attachHandlers(panel) {
|
|
@@ -4010,9 +4155,22 @@ var MushiWidget = class _MushiWidget {
|
|
|
4010
4155
|
this.step = "category";
|
|
4011
4156
|
} else if (this.step === "assistant") {
|
|
4012
4157
|
this.step = "category";
|
|
4158
|
+
} else if (this.step === "account") {
|
|
4159
|
+
this.step = "category";
|
|
4160
|
+
} else if (this.step === "cross-app-reports") {
|
|
4161
|
+
this.step = "account";
|
|
4162
|
+
} else if (this.step === "success") {
|
|
4163
|
+
this.step = "category";
|
|
4164
|
+
this.selectedCategory = null;
|
|
4165
|
+
this.selectedIntent = null;
|
|
4166
|
+
this.viaFeatureRequest = false;
|
|
4013
4167
|
}
|
|
4014
4168
|
this.render();
|
|
4015
4169
|
});
|
|
4170
|
+
panel.querySelector('[data-action="show-all-categories"]')?.addEventListener("click", () => {
|
|
4171
|
+
this.showAllCategories = true;
|
|
4172
|
+
this.render();
|
|
4173
|
+
});
|
|
4016
4174
|
panel.querySelector('[data-action="assistant"]')?.addEventListener("click", () => {
|
|
4017
4175
|
this.openAssistantTab();
|
|
4018
4176
|
});
|
|
@@ -4129,6 +4287,9 @@ var MushiWidget = class _MushiWidget {
|
|
|
4129
4287
|
panel.querySelector('[data-action="reporter-not-fixed"]')?.addEventListener("click", () => {
|
|
4130
4288
|
void this.submitReporterReopen();
|
|
4131
4289
|
});
|
|
4290
|
+
panel.querySelector('[data-action="view-my-reports"]')?.addEventListener("click", () => {
|
|
4291
|
+
void this.loadReporterReports();
|
|
4292
|
+
});
|
|
4132
4293
|
panel.querySelector('[data-action="copy-report-id"]')?.addEventListener("click", (e) => {
|
|
4133
4294
|
const btn = e.currentTarget;
|
|
4134
4295
|
const id = btn.dataset.copyId;
|
|
@@ -4449,6 +4610,18 @@ var MushiWidget = class _MushiWidget {
|
|
|
4449
4610
|
if (this.isOpen) this.close();
|
|
4450
4611
|
this.open();
|
|
4451
4612
|
}
|
|
4613
|
+
/**
|
|
4614
|
+
* Open the widget directly to the reporter's "My reports" history view.
|
|
4615
|
+
* Can be called from host apps via `sdk.openReporter()` or triggered by
|
|
4616
|
+
* the banner's "My reports" link button.
|
|
4617
|
+
*/
|
|
4618
|
+
openReporter() {
|
|
4619
|
+
if (!this.isOpen) {
|
|
4620
|
+
this.isOpen = true;
|
|
4621
|
+
this.render();
|
|
4622
|
+
}
|
|
4623
|
+
void this.loadReporterReports();
|
|
4624
|
+
}
|
|
4452
4625
|
recorderSelectCategory(category) {
|
|
4453
4626
|
if (!this.isOpen) this.open();
|
|
4454
4627
|
if (this.step !== "category") {
|
|
@@ -5095,19 +5268,26 @@ function createScreenshotCapture(options = {}) {
|
|
|
5095
5268
|
try {
|
|
5096
5269
|
ctx.drawImage(img, 0, 0, width, height);
|
|
5097
5270
|
URL.revokeObjectURL(url);
|
|
5098
|
-
|
|
5271
|
+
const dataUrl = canvas.toDataURL("image/jpeg", 0.7);
|
|
5272
|
+
resolve(dataUrl);
|
|
5099
5273
|
} catch {
|
|
5100
5274
|
URL.revokeObjectURL(url);
|
|
5101
|
-
|
|
5275
|
+
activeOptions.onFailed?.("taint");
|
|
5276
|
+
emitScreenshotFailed("taint");
|
|
5277
|
+
resolve(null);
|
|
5102
5278
|
}
|
|
5103
5279
|
};
|
|
5104
5280
|
img.onerror = () => {
|
|
5105
5281
|
URL.revokeObjectURL(url);
|
|
5106
|
-
|
|
5282
|
+
activeOptions.onFailed?.("error");
|
|
5283
|
+
emitScreenshotFailed("error");
|
|
5284
|
+
resolve(null);
|
|
5107
5285
|
};
|
|
5108
5286
|
img.src = url;
|
|
5109
5287
|
});
|
|
5110
5288
|
} catch {
|
|
5289
|
+
activeOptions.onFailed?.("error");
|
|
5290
|
+
emitScreenshotFailed("error");
|
|
5111
5291
|
return null;
|
|
5112
5292
|
}
|
|
5113
5293
|
}
|
|
@@ -5118,6 +5298,12 @@ function createScreenshotCapture(options = {}) {
|
|
|
5118
5298
|
}
|
|
5119
5299
|
};
|
|
5120
5300
|
}
|
|
5301
|
+
function emitScreenshotFailed(reason) {
|
|
5302
|
+
try {
|
|
5303
|
+
document.dispatchEvent(new CustomEvent("mushi:screenshot_failed", { detail: { reason }, bubbles: false }));
|
|
5304
|
+
} catch {
|
|
5305
|
+
}
|
|
5306
|
+
}
|
|
5121
5307
|
var DEFAULT_REDACT_SELECTORS = [
|
|
5122
5308
|
'input[type="password"]',
|
|
5123
5309
|
"[data-mushi-redact]"
|
|
@@ -5173,10 +5359,28 @@ function stripTaintSources(root) {
|
|
|
5173
5359
|
const href = link.getAttribute("href");
|
|
5174
5360
|
if (!href || isCrossOriginUrl(href, pageOrigin)) link.remove();
|
|
5175
5361
|
}
|
|
5362
|
+
for (const styleEl of root.querySelectorAll("style")) {
|
|
5363
|
+
const cleaned = stripCssUrlRefs(styleEl.textContent ?? "", pageOrigin);
|
|
5364
|
+
if (cleaned !== styleEl.textContent) styleEl.textContent = cleaned;
|
|
5365
|
+
}
|
|
5366
|
+
for (const el of root.querySelectorAll("[style]")) {
|
|
5367
|
+
const s = el.getAttribute("style");
|
|
5368
|
+
if (!s) continue;
|
|
5369
|
+
const cleaned = stripCssUrlRefs(s, pageOrigin);
|
|
5370
|
+
if (cleaned !== s) el.setAttribute("style", cleaned);
|
|
5371
|
+
}
|
|
5176
5372
|
for (const script of root.querySelectorAll("script")) {
|
|
5177
5373
|
script.remove();
|
|
5178
5374
|
}
|
|
5179
5375
|
}
|
|
5376
|
+
function stripCssUrlRefs(css, pageOrigin) {
|
|
5377
|
+
return css.replace(/url\(\s*(['"]?)([^)'"]+)\1\s*\)/gi, (_match, _q, href) => {
|
|
5378
|
+
const trimmed = href.trim();
|
|
5379
|
+
if (!trimmed || trimmed.startsWith("data:") || trimmed.startsWith("#")) return _match;
|
|
5380
|
+
if (isCrossOriginUrl(trimmed, pageOrigin)) return "none";
|
|
5381
|
+
return _match;
|
|
5382
|
+
});
|
|
5383
|
+
}
|
|
5180
5384
|
function isCrossOriginUrl(raw, pageOrigin) {
|
|
5181
5385
|
if (!raw || raw.startsWith("data:") || raw.startsWith("blob:")) return false;
|
|
5182
5386
|
try {
|
|
@@ -5186,24 +5390,6 @@ function isCrossOriginUrl(raw, pageOrigin) {
|
|
|
5186
5390
|
return true;
|
|
5187
5391
|
}
|
|
5188
5392
|
}
|
|
5189
|
-
function buildDegradedScreenshot(width, height) {
|
|
5190
|
-
const canvas = document.createElement("canvas");
|
|
5191
|
-
const ctx = canvas.getContext("2d");
|
|
5192
|
-
if (!ctx) return null;
|
|
5193
|
-
canvas.width = width;
|
|
5194
|
-
canvas.height = height;
|
|
5195
|
-
ctx.fillStyle = "#111827";
|
|
5196
|
-
ctx.fillRect(0, 0, width, height);
|
|
5197
|
-
ctx.fillStyle = "#e5e7eb";
|
|
5198
|
-
ctx.font = "13px system-ui, sans-serif";
|
|
5199
|
-
ctx.fillText("Screenshot: layout captured (external media stripped)", 16, 28);
|
|
5200
|
-
ctx.fillText(`${width}\xD7${height}px`, 16, 48);
|
|
5201
|
-
try {
|
|
5202
|
-
return canvas.toDataURL("image/jpeg", 0.7);
|
|
5203
|
-
} catch {
|
|
5204
|
-
return null;
|
|
5205
|
-
}
|
|
5206
|
-
}
|
|
5207
5393
|
function maskElement(el) {
|
|
5208
5394
|
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
5209
5395
|
el.value = "";
|
|
@@ -6547,7 +6733,9 @@ function createInstance(config) {
|
|
|
6547
6733
|
projectId: bootstrapConfig.projectId,
|
|
6548
6734
|
apiKey: bootstrapConfig.apiKey,
|
|
6549
6735
|
...bootstrapConfig.apiEndpoint ? { apiEndpoint: bootstrapConfig.apiEndpoint } : {},
|
|
6550
|
-
getUserToken: () => userToken
|
|
6736
|
+
getUserToken: () => userToken,
|
|
6737
|
+
sdkPackage: MUSHI_SDK_PACKAGE,
|
|
6738
|
+
sdkVersion: MUSHI_SDK_VERSION
|
|
6551
6739
|
});
|
|
6552
6740
|
const preFilter = core.createPreFilter(bootstrapConfig.preFilter);
|
|
6553
6741
|
const offlineQueue = core.createOfflineQueue(bootstrapConfig.offline);
|
|
@@ -7355,6 +7543,9 @@ function createInstance(config) {
|
|
|
7355
7543
|
setTrigger(trigger) {
|
|
7356
7544
|
widget.setTrigger(trigger);
|
|
7357
7545
|
},
|
|
7546
|
+
openReporter() {
|
|
7547
|
+
widget.openReporter();
|
|
7548
|
+
},
|
|
7358
7549
|
close() {
|
|
7359
7550
|
widget.close();
|
|
7360
7551
|
},
|
|
@@ -7926,6 +8117,8 @@ function createNoopInstance() {
|
|
|
7926
8117
|
},
|
|
7927
8118
|
setTrigger: () => {
|
|
7928
8119
|
},
|
|
8120
|
+
openReporter: () => {
|
|
8121
|
+
},
|
|
7929
8122
|
destroy: () => {
|
|
7930
8123
|
instance = null;
|
|
7931
8124
|
},
|