@mushi-mushi/web 1.12.1 → 1.14.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 +1 -1
- package/dist/index.cjs +680 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -3
- package/dist/index.d.ts +78 -3
- package/dist/index.js +680 -52
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -289,17 +289,18 @@ function getAvailableLocales() {
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
// src/styles.ts
|
|
292
|
-
function getWidgetStyles(theme) {
|
|
292
|
+
function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
293
293
|
const isDark = theme === "dark";
|
|
294
294
|
const paper = isDark ? "#0F0E0C" : "#F8F4ED";
|
|
295
295
|
const ink = isDark ? "#F2EBDD" : "#0E0D0B";
|
|
296
296
|
const inkMuted = isDark ? "#928B7E" : "#5C5852";
|
|
297
297
|
const inkFaint = isDark ? "#5A5650" : "#9A9489";
|
|
298
|
+
const inkDim = isDark ? "#7A7268" : "#6E6760";
|
|
298
299
|
const rule = isDark ? "rgba(242,235,221,0.10)" : "rgba(14,13,11,0.10)";
|
|
299
300
|
const ruleStrong = isDark ? "rgba(242,235,221,0.18)" : "rgba(14,13,11,0.16)";
|
|
300
|
-
const widgetAccent = isDark ? "#FF5A47" : "#E03C2C";
|
|
301
|
-
const widgetAccentWash = isDark ?
|
|
302
|
-
const widgetAccentInk = isDark ? "#FFE5E0" : "#7A1F15";
|
|
301
|
+
const widgetAccent = accent || (isDark ? "#FF5A47" : "#E03C2C");
|
|
302
|
+
const widgetAccentWash = isDark ? `${widgetAccent}1F` : `${widgetAccent}14`;
|
|
303
|
+
const widgetAccentInk = accentText || (isDark ? "#FFE5E0" : "#7A1F15");
|
|
303
304
|
const fontDisplay = `'Iowan Old Style', 'Palatino Linotype', 'Palatino', 'Book Antiqua', 'Cambria', Georgia, 'Times New Roman', serif`;
|
|
304
305
|
const fontBody = `system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI Variable Display', 'Segoe UI', sans-serif`;
|
|
305
306
|
const fontMono = `ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, 'Liberation Mono', monospace`;
|
|
@@ -446,6 +447,33 @@ function getWidgetStyles(theme) {
|
|
|
446
447
|
transform: scale(0.92);
|
|
447
448
|
}
|
|
448
449
|
|
|
450
|
+
/* \u2500\u2500 Draggable FAB \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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
451
|
+
When draggable is enabled the trigger uses CSS translate to apply the
|
|
452
|
+
drag offset ON TOP of the existing inset positioning, so snapping and
|
|
453
|
+
safe-area clamp still work correctly via the inset vars.
|
|
454
|
+
--mushi-drag-active 0|1 gates the transform so non-draggable FABs are
|
|
455
|
+
completely unaffected. touch-action: none prevents browser pan/scroll
|
|
456
|
+
from racing the pointer capture. */
|
|
457
|
+
.mushi-trigger {
|
|
458
|
+
touch-action: none;
|
|
459
|
+
translate:
|
|
460
|
+
calc(var(--mushi-drag-active, 0) * var(--mushi-drag-x, 0px))
|
|
461
|
+
calc(var(--mushi-drag-active, 0) * var(--mushi-drag-y, 0px));
|
|
462
|
+
}
|
|
463
|
+
.mushi-trigger.dragging {
|
|
464
|
+
cursor: grabbing !important;
|
|
465
|
+
z-index: calc(var(--z, 99999) + 2);
|
|
466
|
+
transition: none !important;
|
|
467
|
+
box-shadow:
|
|
468
|
+
0 1px 0 ${rule},
|
|
469
|
+
0 20px 40px -12px rgba(14,13,11,0.55),
|
|
470
|
+
inset 0 -3px 0 ${widgetAccent};
|
|
471
|
+
opacity: 0.92;
|
|
472
|
+
}
|
|
473
|
+
@media (prefers-reduced-motion: reduce) {
|
|
474
|
+
.mushi-trigger { transition: none !important; }
|
|
475
|
+
}
|
|
476
|
+
|
|
449
477
|
@keyframes mushi-pulse {
|
|
450
478
|
0% { box-shadow: 0 0 0 0 ${widgetAccent}; opacity: 1; }
|
|
451
479
|
70% { box-shadow: 0 0 0 8px rgba(224,60,44,0); opacity: 0.5; }
|
|
@@ -456,7 +484,7 @@ function getWidgetStyles(theme) {
|
|
|
456
484
|
position: fixed;
|
|
457
485
|
width: 384px;
|
|
458
486
|
max-width: calc(100vw - 32px);
|
|
459
|
-
max-height: min(640px, calc(
|
|
487
|
+
max-height: min(640px, calc(100dvh - 120px - var(--mushi-keyboard-inset, 0px)));
|
|
460
488
|
background: ${paper};
|
|
461
489
|
border: 1px solid ${ruleStrong};
|
|
462
490
|
border-radius: 6px;
|
|
@@ -468,6 +496,26 @@ function getWidgetStyles(theme) {
|
|
|
468
496
|
display: flex;
|
|
469
497
|
flex-direction: column;
|
|
470
498
|
transform-origin: var(--mushi-origin, bottom right);
|
|
499
|
+
transition: bottom 120ms ease, top 120ms ease, max-height 120ms ease;
|
|
500
|
+
}
|
|
501
|
+
/* Keyboard-safe: on narrow viewports lift above the keyboard */
|
|
502
|
+
.mushi-panel.keyboard-open {
|
|
503
|
+
bottom: calc(var(--mushi-keyboard-inset, 0px) + 8px) !important;
|
|
504
|
+
}
|
|
505
|
+
/* On narrow mobile, fill the width as a bottom sheet */
|
|
506
|
+
@media (max-width: 480px) {
|
|
507
|
+
.mushi-panel {
|
|
508
|
+
left: 0 !important;
|
|
509
|
+
right: 0 !important;
|
|
510
|
+
width: 100% !important;
|
|
511
|
+
max-width: 100% !important;
|
|
512
|
+
border-bottom-left-radius: 0;
|
|
513
|
+
border-bottom-right-radius: 0;
|
|
514
|
+
bottom: var(--mushi-keyboard-inset, 0px) !important;
|
|
515
|
+
}
|
|
516
|
+
.mushi-panel.keyboard-open {
|
|
517
|
+
bottom: calc(var(--mushi-keyboard-inset, 0px) + 4px) !important;
|
|
518
|
+
}
|
|
471
519
|
}
|
|
472
520
|
.mushi-panel.open { animation: mushi-stamp-in 320ms ${easeStamp} both; }
|
|
473
521
|
.mushi-panel.closed { display: none; }
|
|
@@ -1496,7 +1544,7 @@ function getWidgetStyles(theme) {
|
|
|
1496
1544
|
}
|
|
1497
1545
|
|
|
1498
1546
|
.mushi-beta-perks li {
|
|
1499
|
-
font-size:
|
|
1547
|
+
font-size: 12px;
|
|
1500
1548
|
color: ${widgetAccentInk};
|
|
1501
1549
|
font-weight: 500;
|
|
1502
1550
|
}
|
|
@@ -1508,8 +1556,8 @@ function getWidgetStyles(theme) {
|
|
|
1508
1556
|
}
|
|
1509
1557
|
|
|
1510
1558
|
.mushi-changelog-summary {
|
|
1511
|
-
font-size:
|
|
1512
|
-
color:
|
|
1559
|
+
font-size: 11px;
|
|
1560
|
+
color: ${inkDim};
|
|
1513
1561
|
cursor: pointer;
|
|
1514
1562
|
list-style: none;
|
|
1515
1563
|
display: flex;
|
|
@@ -1539,8 +1587,8 @@ function getWidgetStyles(theme) {
|
|
|
1539
1587
|
}
|
|
1540
1588
|
|
|
1541
1589
|
.mushi-changelog-list li {
|
|
1542
|
-
font-size:
|
|
1543
|
-
color:
|
|
1590
|
+
font-size: 11px;
|
|
1591
|
+
color: ${inkDim};
|
|
1544
1592
|
line-height: 1.5;
|
|
1545
1593
|
}
|
|
1546
1594
|
|
|
@@ -1559,14 +1607,14 @@ function getWidgetStyles(theme) {
|
|
|
1559
1607
|
}
|
|
1560
1608
|
|
|
1561
1609
|
.mushi-beta-success-line {
|
|
1562
|
-
font-size:
|
|
1563
|
-
color:
|
|
1610
|
+
font-size: 12px;
|
|
1611
|
+
color: ${widgetAccentInk};
|
|
1564
1612
|
line-height: 1.5;
|
|
1565
1613
|
}
|
|
1566
1614
|
|
|
1567
1615
|
.mushi-beta-success-dim {
|
|
1568
1616
|
opacity: 0.65;
|
|
1569
|
-
font-size:
|
|
1617
|
+
font-size: 12px;
|
|
1570
1618
|
}
|
|
1571
1619
|
|
|
1572
1620
|
/* \u2500\u2500\u2500 Banner launcher (trigger: 'banner') \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 */
|
|
@@ -1582,7 +1630,7 @@ function getWidgetStyles(theme) {
|
|
|
1582
1630
|
gap: 10px;
|
|
1583
1631
|
padding: 0 16px;
|
|
1584
1632
|
font-family: ${fontMono};
|
|
1585
|
-
font-size:
|
|
1633
|
+
font-size: 12px;
|
|
1586
1634
|
letter-spacing: 0.04em;
|
|
1587
1635
|
white-space: nowrap;
|
|
1588
1636
|
overflow: hidden;
|
|
@@ -1710,7 +1758,7 @@ function getWidgetStyles(theme) {
|
|
|
1710
1758
|
overflow: hidden;
|
|
1711
1759
|
text-overflow: ellipsis;
|
|
1712
1760
|
white-space: nowrap;
|
|
1713
|
-
font-size:
|
|
1761
|
+
font-size: 12px;
|
|
1714
1762
|
font-weight: 500;
|
|
1715
1763
|
line-height: 1.3;
|
|
1716
1764
|
opacity: 0.9;
|
|
@@ -1826,6 +1874,23 @@ function getWidgetStyles(theme) {
|
|
|
1826
1874
|
.mushi-success-stamp-label { opacity: 1; }
|
|
1827
1875
|
.mushi-success-pts-award { opacity: 1; }
|
|
1828
1876
|
}
|
|
1877
|
+
|
|
1878
|
+
.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}
|
|
1879
|
+
.mushi-community-btn{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
1880
|
+
.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}
|
|
1881
|
+
.mushi-link-btn:hover{opacity:0.8}
|
|
1882
|
+
.mushi-link-btn:focus-visible,.mushi-nav-item:focus-visible{outline:2px solid ${widgetAccent};outline-offset:2px;border-radius:2px}
|
|
1883
|
+
.mushi-nav-item{display:block;width:100%;text-align:left;background:${isDark ? "rgba(255,255,255,0.05)" : "rgba(0,0,0,0.04)"};border:1px solid ${isDark ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.08)"};border-radius:8px;padding:10px 14px;margin-bottom:8px;cursor:pointer;font-size:13px;color:${ink};transition:background .15s,border-color .15s}
|
|
1884
|
+
.mushi-nav-item:hover{background:${isDark ? "rgba(255,255,255,0.09)" : "rgba(0,0,0,0.07)"}}
|
|
1885
|
+
.mushi-account-card{display:flex;align-items:center;gap:12px;background:${isDark ? "rgba(255,255,255,0.06)" : "rgba(0,0,0,0.04)"};border-radius:10px;padding:12px 14px;margin-bottom:14px}
|
|
1886
|
+
.mushi-account-avatar{width:40px;height:40px;border-radius:50%;background:${widgetAccentWash};color:${widgetAccentInk};display:flex;align-items:center;justify-content:center;font-size:16px;font-weight:700;flex-shrink:0}
|
|
1887
|
+
.mushi-account-info{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
1888
|
+
.mushi-account-info strong{font:700 14px/1.3 inherit;color:${ink}}
|
|
1889
|
+
.mushi-account-rank,.mushi-xapp-app-name,.mushi-label{font-size:12px;color:${inkDim};font-family:${fontMono}}
|
|
1890
|
+
.mushi-account-rank{display:block}
|
|
1891
|
+
.mushi-xapp-app-name{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;margin:0 0 6px}
|
|
1892
|
+
.mushi-xapp-group{margin-bottom:14px}
|
|
1893
|
+
.mushi-label{display:block;font-weight:600;margin-bottom:6px}
|
|
1829
1894
|
`;
|
|
1830
1895
|
}
|
|
1831
1896
|
|
|
@@ -1987,7 +2052,10 @@ var MushiWidget = class _MushiWidget {
|
|
|
1987
2052
|
featureRequestCard: config.featureRequestCard ?? true,
|
|
1988
2053
|
featureRequestLabel: config.featureRequestLabel ?? "",
|
|
1989
2054
|
featureRequestDescription: config.featureRequestDescription ?? "",
|
|
1990
|
-
avoidSelectors: config.avoidSelectors ?? []
|
|
2055
|
+
avoidSelectors: config.avoidSelectors ?? [],
|
|
2056
|
+
categories: config.categories ?? [],
|
|
2057
|
+
accent: config.accent ?? "",
|
|
2058
|
+
accentText: config.accentText ?? ""
|
|
1991
2059
|
};
|
|
1992
2060
|
this.callbacks = callbacks;
|
|
1993
2061
|
this.locale = getLocale(this.config.locale === "auto" ? void 0 : this.config.locale);
|
|
@@ -2003,6 +2071,11 @@ var MushiWidget = class _MushiWidget {
|
|
|
2003
2071
|
locale;
|
|
2004
2072
|
isOpen = false;
|
|
2005
2073
|
step = "category";
|
|
2074
|
+
/**
|
|
2075
|
+
* The selected category id. May be a built-in `MushiReportCategory` or a
|
|
2076
|
+
* custom id from `config.categories`. Cast to `MushiReportCategory` only
|
|
2077
|
+
* after resolving through `resolveBaseCategory()`.
|
|
2078
|
+
*/
|
|
2006
2079
|
selectedCategory = null;
|
|
2007
2080
|
selectedIntent = null;
|
|
2008
2081
|
/**
|
|
@@ -2065,6 +2138,26 @@ var MushiWidget = class _MushiWidget {
|
|
|
2065
2138
|
lastSubmitQueuedOffline = false;
|
|
2066
2139
|
/** Whether the user has clicked ✕ on the header banner this session. */
|
|
2067
2140
|
bannerDismissed = false;
|
|
2141
|
+
/** Persisted FAB position when draggable is enabled. */
|
|
2142
|
+
fabPos = null;
|
|
2143
|
+
/** Cleanup fn for visualViewport keyboard listener. */
|
|
2144
|
+
vvCleanup = null;
|
|
2145
|
+
/** Mushi tester session JWT — set after in-widget sign-in or by mushi.ts. */
|
|
2146
|
+
testerJwt = null;
|
|
2147
|
+
/** Tester identity (public_handle, display_name). */
|
|
2148
|
+
testerInfo = null;
|
|
2149
|
+
/** Cross-app reports for the signed-in tester. */
|
|
2150
|
+
crossAppReports = null;
|
|
2151
|
+
crossAppLoading = false;
|
|
2152
|
+
/** Global leaderboard entries (from mushi_testers, not org-scoped). */
|
|
2153
|
+
globalLeaderboard = null;
|
|
2154
|
+
globalLeaderboardLoading = false;
|
|
2155
|
+
/** Reputation for the signed-in tester. */
|
|
2156
|
+
testerReputation = null;
|
|
2157
|
+
/** Whether an in-widget magic-link email was just sent. */
|
|
2158
|
+
magicLinkSent = false;
|
|
2159
|
+
magicLinkEmail = "";
|
|
2160
|
+
magicLinkError = "";
|
|
2068
2161
|
mount() {
|
|
2069
2162
|
if (this.host.isConnected) return;
|
|
2070
2163
|
this.syncHostChromeState();
|
|
@@ -2110,7 +2203,8 @@ var MushiWidget = class _MushiWidget {
|
|
|
2110
2203
|
// mergeRuntimeConfig → bannerConfig. The widget is constructed before
|
|
2111
2204
|
// that fetch resolves, so this pass-through is what makes server-driven
|
|
2112
2205
|
// banner copy actually render.
|
|
2113
|
-
...config.bannerConfig !== void 0 ? { bannerConfig: config.bannerConfig } : {}
|
|
2206
|
+
...config.bannerConfig !== void 0 ? { bannerConfig: config.bannerConfig } : {},
|
|
2207
|
+
...config.categories !== void 0 ? { categories: config.categories } : {}
|
|
2114
2208
|
};
|
|
2115
2209
|
this.locale = getLocale(this.config.locale === "auto" ? void 0 : this.config.locale);
|
|
2116
2210
|
if (this.host.isConnected) this.syncHostChromeState();
|
|
@@ -2118,6 +2212,35 @@ var MushiWidget = class _MushiWidget {
|
|
|
2118
2212
|
this.syncSmartHide();
|
|
2119
2213
|
this.render();
|
|
2120
2214
|
}
|
|
2215
|
+
// ─── Custom category helpers ──────────────────────────────────────────────
|
|
2216
|
+
/** Find a custom category entry by id. Returns undefined for built-in ids. */
|
|
2217
|
+
resolveCustomCategory(id) {
|
|
2218
|
+
return this.config.categories?.find((c) => c.id === id);
|
|
2219
|
+
}
|
|
2220
|
+
/**
|
|
2221
|
+
* Map a (possibly custom) category id to the built-in `MushiReportCategory`
|
|
2222
|
+
* used for the report wire format. Falls back to `'other'`.
|
|
2223
|
+
*/
|
|
2224
|
+
resolveBaseCategory(id) {
|
|
2225
|
+
const BUILTIN = ["bug", "slow", "visual", "confusing", "other"];
|
|
2226
|
+
if (BUILTIN.includes(id)) return id;
|
|
2227
|
+
const custom = this.resolveCustomCategory(id);
|
|
2228
|
+
return custom?.baseCategory ?? "other";
|
|
2229
|
+
}
|
|
2230
|
+
/** Icon for the selected category — custom entry's icon or built-in emoji. */
|
|
2231
|
+
categoryIcon(id) {
|
|
2232
|
+
const custom = this.resolveCustomCategory(id);
|
|
2233
|
+
if (custom?.icon) return custom.icon;
|
|
2234
|
+
return CATEGORY_ICONS[id] ?? "\u{1F4AC}";
|
|
2235
|
+
}
|
|
2236
|
+
/** Label for the selected category — custom entry label or built-in i18n string. */
|
|
2237
|
+
categoryLabel(id) {
|
|
2238
|
+
const custom = this.resolveCustomCategory(id);
|
|
2239
|
+
if (custom) return custom.label;
|
|
2240
|
+
const t = this.locale;
|
|
2241
|
+
return t.step1.categories[id] ?? id;
|
|
2242
|
+
}
|
|
2243
|
+
// ─── Open / close ─────────────────────────────────────────────────────────
|
|
2121
2244
|
open(options) {
|
|
2122
2245
|
if (this.isOpen) return;
|
|
2123
2246
|
this.isOpen = true;
|
|
@@ -2140,7 +2263,8 @@ var MushiWidget = class _MushiWidget {
|
|
|
2140
2263
|
} else if (options?.category) {
|
|
2141
2264
|
this.selectedCategory = options.category;
|
|
2142
2265
|
this.selectedIntent = null;
|
|
2143
|
-
|
|
2266
|
+
const custom = this.resolveCustomCategory(options.category);
|
|
2267
|
+
this.step = custom && (!custom.intents || custom.intents.length === 0) ? "details" : "intent";
|
|
2144
2268
|
} else {
|
|
2145
2269
|
this.selectedCategory = null;
|
|
2146
2270
|
this.selectedIntent = null;
|
|
@@ -2329,6 +2453,26 @@ var MushiWidget = class _MushiWidget {
|
|
|
2329
2453
|
this.leaderboardLoading = loading;
|
|
2330
2454
|
if (this.isOpen && this.step === "leaderboard") this.render();
|
|
2331
2455
|
}
|
|
2456
|
+
// ── Community public setters (called by mushi.ts after API calls) ──────────
|
|
2457
|
+
setTesterSession(jwt, info) {
|
|
2458
|
+
this.testerJwt = jwt;
|
|
2459
|
+
this.testerInfo = info;
|
|
2460
|
+
if (this.isOpen) this.render();
|
|
2461
|
+
}
|
|
2462
|
+
setGlobalLeaderboard(entries, loading = false) {
|
|
2463
|
+
this.globalLeaderboard = entries;
|
|
2464
|
+
this.globalLeaderboardLoading = loading;
|
|
2465
|
+
if (this.isOpen && (this.step === "leaderboard" || this.step === "account")) this.render();
|
|
2466
|
+
}
|
|
2467
|
+
setCrossAppReports(reports, loading = false) {
|
|
2468
|
+
this.crossAppReports = reports;
|
|
2469
|
+
this.crossAppLoading = loading;
|
|
2470
|
+
if (this.isOpen && this.step === "cross-app-reports") this.render();
|
|
2471
|
+
}
|
|
2472
|
+
setTesterReputation(rep) {
|
|
2473
|
+
this.testerReputation = rep;
|
|
2474
|
+
if (this.isOpen && (this.step === "account" || this.step === "leaderboard")) this.render();
|
|
2475
|
+
}
|
|
2332
2476
|
destroy() {
|
|
2333
2477
|
if (this.successTimer !== null) {
|
|
2334
2478
|
clearTimeout(this.successTimer);
|
|
@@ -2344,6 +2488,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
2344
2488
|
}
|
|
2345
2489
|
this.smartHideCleanup?.();
|
|
2346
2490
|
this.smartHideCleanup = null;
|
|
2491
|
+
this.teardownViewportHandlers();
|
|
2347
2492
|
this.attachedLaunchers.forEach((cleanup) => cleanup());
|
|
2348
2493
|
this.attachedLaunchers = [];
|
|
2349
2494
|
this.removeSelectorHint();
|
|
@@ -2621,7 +2766,25 @@ var MushiWidget = class _MushiWidget {
|
|
|
2621
2766
|
return this.config.hideOnRoutes.some((route) => location.pathname.includes(route));
|
|
2622
2767
|
}
|
|
2623
2768
|
getTheme() {
|
|
2624
|
-
|
|
2769
|
+
const t = this.config.theme;
|
|
2770
|
+
if (t === "light" || t === "dark") return t;
|
|
2771
|
+
if (t === "inherit") {
|
|
2772
|
+
const root = document.documentElement;
|
|
2773
|
+
const colorScheme = root.getAttribute("data-color-scheme") || root.getAttribute("data-theme") || root.getAttribute("color-scheme") || "";
|
|
2774
|
+
if (/dark/i.test(colorScheme)) return "dark";
|
|
2775
|
+
if (/light/i.test(colorScheme)) return "light";
|
|
2776
|
+
if (root.classList.contains("dark")) return "dark";
|
|
2777
|
+
if (root.classList.contains("light")) return "light";
|
|
2778
|
+
try {
|
|
2779
|
+
const bg = getComputedStyle(root).backgroundColor;
|
|
2780
|
+
const m = bg.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
2781
|
+
if (m) {
|
|
2782
|
+
const L = 0.299 * +m[1] + 0.587 * +m[2] + 0.114 * +m[3];
|
|
2783
|
+
return L < 128 ? "dark" : "light";
|
|
2784
|
+
}
|
|
2785
|
+
} catch {
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2625
2788
|
if (typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
2626
2789
|
return "dark";
|
|
2627
2790
|
}
|
|
@@ -2633,7 +2796,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
2633
2796
|
const t = this.locale;
|
|
2634
2797
|
this.shadow.innerHTML = "";
|
|
2635
2798
|
const style = document.createElement("style");
|
|
2636
|
-
style.textContent = getWidgetStyles(theme);
|
|
2799
|
+
style.textContent = getWidgetStyles(theme, this.config.accent ?? "", this.config.accentText ?? "");
|
|
2637
2800
|
this.shadow.appendChild(style);
|
|
2638
2801
|
this.renderBanner();
|
|
2639
2802
|
if (this.shouldRenderTrigger()) {
|
|
@@ -2646,6 +2809,11 @@ var MushiWidget = class _MushiWidget {
|
|
|
2646
2809
|
trigger.setAttribute("aria-expanded", String(this.isOpen));
|
|
2647
2810
|
trigger.style.zIndex = String(this.config.zIndex);
|
|
2648
2811
|
this.applyInsetVars(trigger);
|
|
2812
|
+
if (this.fabPos) {
|
|
2813
|
+
trigger.style.setProperty("--mushi-drag-x", `${this.fabPos.x}px`);
|
|
2814
|
+
trigger.style.setProperty("--mushi-drag-y", `${this.fabPos.y}px`);
|
|
2815
|
+
trigger.style.setProperty("--mushi-drag-active", "1");
|
|
2816
|
+
}
|
|
2649
2817
|
trigger.addEventListener("click", () => {
|
|
2650
2818
|
this.removeNudge();
|
|
2651
2819
|
if (this.isOpen) this.close();
|
|
@@ -2663,6 +2831,29 @@ var MushiWidget = class _MushiWidget {
|
|
|
2663
2831
|
this.nudgeTimer = setTimeout(() => this.removeNudge(), 2e3);
|
|
2664
2832
|
}
|
|
2665
2833
|
});
|
|
2834
|
+
trigger.addEventListener("keydown", (e) => {
|
|
2835
|
+
const draggableConfig = this.config.draggable;
|
|
2836
|
+
if (!draggableConfig) return;
|
|
2837
|
+
const STEP = 8;
|
|
2838
|
+
const axis = typeof draggableConfig === "object" ? draggableConfig.axis ?? "both" : "both";
|
|
2839
|
+
let dx = 0, dy = 0;
|
|
2840
|
+
if (axis !== "y") {
|
|
2841
|
+
if (e.key === "ArrowLeft") dx = -STEP;
|
|
2842
|
+
else if (e.key === "ArrowRight") dx = STEP;
|
|
2843
|
+
}
|
|
2844
|
+
if (axis !== "x") {
|
|
2845
|
+
if (e.key === "ArrowUp") dy = -STEP;
|
|
2846
|
+
else if (e.key === "ArrowDown") dy = STEP;
|
|
2847
|
+
}
|
|
2848
|
+
if (dx !== 0 || dy !== 0) {
|
|
2849
|
+
e.preventDefault();
|
|
2850
|
+
const cur = this.fabPos ?? { x: 0, y: 0 };
|
|
2851
|
+
this.moveFab(trigger, cur.x + dx, cur.y + dy, false);
|
|
2852
|
+
}
|
|
2853
|
+
});
|
|
2854
|
+
if (this.config.draggable) {
|
|
2855
|
+
this.attachDragHandlers(trigger);
|
|
2856
|
+
}
|
|
2666
2857
|
this.shadow.appendChild(trigger);
|
|
2667
2858
|
}
|
|
2668
2859
|
const panel = document.createElement("div");
|
|
@@ -2677,6 +2868,9 @@ var MushiWidget = class _MushiWidget {
|
|
|
2677
2868
|
this.shadow.appendChild(panel);
|
|
2678
2869
|
this.attachHandlers(panel);
|
|
2679
2870
|
this.trapFocus(panel);
|
|
2871
|
+
this.attachViewportHandlers(panel);
|
|
2872
|
+
} else {
|
|
2873
|
+
this.teardownViewportHandlers();
|
|
2680
2874
|
}
|
|
2681
2875
|
}
|
|
2682
2876
|
/**
|
|
@@ -2735,6 +2929,171 @@ var MushiWidget = class _MushiWidget {
|
|
|
2735
2929
|
}
|
|
2736
2930
|
}
|
|
2737
2931
|
}
|
|
2932
|
+
// ─── Draggable FAB ──────────────────────────────────────────────────────────
|
|
2933
|
+
/** Storage key for the FAB position, scoped to projectId when available. */
|
|
2934
|
+
fabStorageKey() {
|
|
2935
|
+
const id = this.config["projectId"] ?? "";
|
|
2936
|
+
return `mushi_fab_pos${id ? `_${id}` : ""}`;
|
|
2937
|
+
}
|
|
2938
|
+
/** Move the FAB to the given translated offset (relative to the inset origin),
|
|
2939
|
+
* clamping inside viewport safe area, and optionally snap to nearest edge.
|
|
2940
|
+
*
|
|
2941
|
+
* The FAB's CSS anchor can be any corner (bottom-right, bottom-left, …) so we
|
|
2942
|
+
* must derive the *base* position (CSS anchor with zero drag offset) to compute
|
|
2943
|
+
* correct clamp bounds and snap targets. We do this by subtracting the
|
|
2944
|
+
* already-applied drag offset from the live getBoundingClientRect() value. */
|
|
2945
|
+
moveFab(trigger, x, y, snap) {
|
|
2946
|
+
const axis = (() => {
|
|
2947
|
+
const d2 = this.config.draggable;
|
|
2948
|
+
if (!d2) return "both";
|
|
2949
|
+
return typeof d2 === "object" ? d2.axis ?? "both" : "both";
|
|
2950
|
+
})();
|
|
2951
|
+
const W = window.innerWidth;
|
|
2952
|
+
const H = window.innerHeight;
|
|
2953
|
+
const btnW = trigger.offsetWidth || 52;
|
|
2954
|
+
const btnH = trigger.offsetHeight || 52;
|
|
2955
|
+
const safeL = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--sai-left") || "0") || 0;
|
|
2956
|
+
const safeR = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--sai-right") || "0") || 0;
|
|
2957
|
+
const safeT = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--sai-top") || "0") || 0;
|
|
2958
|
+
const safeB = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--sai-bottom") || "0") || 0;
|
|
2959
|
+
const margin = 8;
|
|
2960
|
+
const rect = trigger.getBoundingClientRect();
|
|
2961
|
+
const prevDragX = this.fabPos?.x ?? 0;
|
|
2962
|
+
const prevDragY = this.fabPos?.y ?? 0;
|
|
2963
|
+
const baseLeft = rect.left - prevDragX;
|
|
2964
|
+
const baseTop = rect.top - prevDragY;
|
|
2965
|
+
const minX = safeL + margin - baseLeft;
|
|
2966
|
+
const maxX = W - safeR - margin - btnW - baseLeft;
|
|
2967
|
+
const minY = safeT + margin - baseTop;
|
|
2968
|
+
const maxY = H - safeB - margin - btnH - baseTop;
|
|
2969
|
+
const newX = axis === "y" ? 0 : Math.max(minX, Math.min(maxX, x));
|
|
2970
|
+
const newY = axis === "x" ? 0 : Math.max(minY, Math.min(maxY, y));
|
|
2971
|
+
let finalX = newX;
|
|
2972
|
+
if (snap) {
|
|
2973
|
+
const d2 = this.config.draggable;
|
|
2974
|
+
const shouldSnap = d2 === true || typeof d2 === "object" && (d2.snapToEdge ?? true);
|
|
2975
|
+
if (shouldSnap && axis !== "y") {
|
|
2976
|
+
const center = rect.left + btnW / 2;
|
|
2977
|
+
finalX = center < W / 2 ? safeL + margin - baseLeft : W - safeR - margin - btnW - baseLeft;
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
this.fabPos = { x: finalX, y: newY };
|
|
2981
|
+
trigger.style.setProperty("--mushi-drag-x", `${finalX}px`);
|
|
2982
|
+
trigger.style.setProperty("--mushi-drag-y", `${newY}px`);
|
|
2983
|
+
trigger.style.setProperty("--mushi-drag-active", "1");
|
|
2984
|
+
const d = this.config.draggable;
|
|
2985
|
+
const shouldPersist = d === true || typeof d === "object" && (d.persist ?? true);
|
|
2986
|
+
if (shouldPersist) {
|
|
2987
|
+
try {
|
|
2988
|
+
localStorage.setItem(this.fabStorageKey(), JSON.stringify(this.fabPos));
|
|
2989
|
+
} catch {
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
/** Load previously persisted FAB position. */
|
|
2994
|
+
loadFabPos() {
|
|
2995
|
+
const d = this.config.draggable;
|
|
2996
|
+
if (!d) return;
|
|
2997
|
+
const shouldPersist = d === true || typeof d === "object" && (d.persist ?? true);
|
|
2998
|
+
if (!shouldPersist) return;
|
|
2999
|
+
try {
|
|
3000
|
+
const raw = localStorage.getItem(this.fabStorageKey());
|
|
3001
|
+
if (raw) {
|
|
3002
|
+
const parsed = JSON.parse(raw);
|
|
3003
|
+
if (typeof parsed?.x === "number" && typeof parsed?.y === "number") {
|
|
3004
|
+
this.fabPos = parsed;
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
} catch {
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
/** Attach Pointer Events-based drag to the trigger element. */
|
|
3011
|
+
attachDragHandlers(trigger) {
|
|
3012
|
+
if (this.fabPos === null) this.loadFabPos();
|
|
3013
|
+
let startX = 0, startY = 0;
|
|
3014
|
+
let originX = 0, originY = 0;
|
|
3015
|
+
let dragging = false;
|
|
3016
|
+
let moved = false;
|
|
3017
|
+
const onPointerDown = (e) => {
|
|
3018
|
+
if (e.button !== 0 && e.pointerType !== "touch") return;
|
|
3019
|
+
trigger.setPointerCapture(e.pointerId);
|
|
3020
|
+
startX = e.clientX;
|
|
3021
|
+
startY = e.clientY;
|
|
3022
|
+
const cur = this.fabPos ?? { x: 0, y: 0 };
|
|
3023
|
+
originX = cur.x;
|
|
3024
|
+
originY = cur.y;
|
|
3025
|
+
dragging = true;
|
|
3026
|
+
moved = false;
|
|
3027
|
+
};
|
|
3028
|
+
const DRAG_THRESHOLD = 6;
|
|
3029
|
+
const onPointerMove = (e) => {
|
|
3030
|
+
if (!dragging) return;
|
|
3031
|
+
const dx = e.clientX - startX;
|
|
3032
|
+
const dy = e.clientY - startY;
|
|
3033
|
+
if (!moved && Math.hypot(dx, dy) > DRAG_THRESHOLD) {
|
|
3034
|
+
moved = true;
|
|
3035
|
+
trigger.classList.add("dragging");
|
|
3036
|
+
trigger.setAttribute("aria-grabbed", "true");
|
|
3037
|
+
}
|
|
3038
|
+
if (moved) {
|
|
3039
|
+
e.preventDefault();
|
|
3040
|
+
this.moveFab(trigger, originX + dx, originY + dy, false);
|
|
3041
|
+
}
|
|
3042
|
+
};
|
|
3043
|
+
const onPointerUp = (e) => {
|
|
3044
|
+
if (!dragging) return;
|
|
3045
|
+
dragging = false;
|
|
3046
|
+
trigger.classList.remove("dragging");
|
|
3047
|
+
trigger.removeAttribute("aria-grabbed");
|
|
3048
|
+
if (moved) {
|
|
3049
|
+
const dx = e.clientX - startX;
|
|
3050
|
+
const dy = e.clientY - startY;
|
|
3051
|
+
this.moveFab(trigger, originX + dx, originY + dy, true);
|
|
3052
|
+
const suppressClick = (ev) => {
|
|
3053
|
+
ev.stopImmediatePropagation();
|
|
3054
|
+
trigger.removeEventListener("click", suppressClick, { capture: true });
|
|
3055
|
+
};
|
|
3056
|
+
trigger.addEventListener("click", suppressClick, { capture: true });
|
|
3057
|
+
}
|
|
3058
|
+
moved = false;
|
|
3059
|
+
};
|
|
3060
|
+
trigger.addEventListener("pointerdown", onPointerDown);
|
|
3061
|
+
trigger.addEventListener("pointermove", onPointerMove);
|
|
3062
|
+
trigger.addEventListener("pointerup", onPointerUp);
|
|
3063
|
+
trigger.addEventListener("pointercancel", onPointerUp);
|
|
3064
|
+
}
|
|
3065
|
+
// ─── Keyboard / visualViewport ──────────────────────────────────────────────
|
|
3066
|
+
/** Lift the panel above the software keyboard using visualViewport. */
|
|
3067
|
+
attachViewportHandlers(panel) {
|
|
3068
|
+
this.teardownViewportHandlers();
|
|
3069
|
+
const vv = window.visualViewport;
|
|
3070
|
+
if (!vv) return;
|
|
3071
|
+
const update = () => {
|
|
3072
|
+
const keyboardInset = window.innerHeight - vv.height - vv.offsetTop;
|
|
3073
|
+
if (keyboardInset > 50) {
|
|
3074
|
+
panel.style.setProperty("--mushi-keyboard-inset", `${Math.round(keyboardInset)}px`);
|
|
3075
|
+
panel.classList.add("keyboard-open");
|
|
3076
|
+
const ta = panel.querySelector('textarea, input[type="text"]');
|
|
3077
|
+
ta?.scrollIntoView({ block: "nearest", behavior: "smooth" });
|
|
3078
|
+
} else {
|
|
3079
|
+
panel.style.setProperty("--mushi-keyboard-inset", "0px");
|
|
3080
|
+
panel.classList.remove("keyboard-open");
|
|
3081
|
+
}
|
|
3082
|
+
};
|
|
3083
|
+
vv.addEventListener("resize", update, { passive: true });
|
|
3084
|
+
vv.addEventListener("scroll", update, { passive: true });
|
|
3085
|
+
const onFocus = () => requestAnimationFrame(update);
|
|
3086
|
+
panel.addEventListener("focusin", onFocus);
|
|
3087
|
+
this.vvCleanup = () => {
|
|
3088
|
+
vv.removeEventListener("resize", update);
|
|
3089
|
+
vv.removeEventListener("scroll", update);
|
|
3090
|
+
panel.removeEventListener("focusin", onFocus);
|
|
3091
|
+
};
|
|
3092
|
+
}
|
|
3093
|
+
teardownViewportHandlers() {
|
|
3094
|
+
this.vvCleanup?.();
|
|
3095
|
+
this.vvCleanup = null;
|
|
3096
|
+
}
|
|
2738
3097
|
renderStep() {
|
|
2739
3098
|
switch (this.step) {
|
|
2740
3099
|
case "category":
|
|
@@ -2753,6 +3112,10 @@ var MushiWidget = class _MushiWidget {
|
|
|
2753
3112
|
return this.renderLeaderboardStep();
|
|
2754
3113
|
case "roadmap":
|
|
2755
3114
|
return this.renderRoadmapStep();
|
|
3115
|
+
case "account":
|
|
3116
|
+
return this.renderAccountStep();
|
|
3117
|
+
case "cross-app-reports":
|
|
3118
|
+
return this.renderCrossAppReportsStep();
|
|
2756
3119
|
}
|
|
2757
3120
|
}
|
|
2758
3121
|
renderOutdatedBanner() {
|
|
@@ -2817,12 +3180,23 @@ var MushiWidget = class _MushiWidget {
|
|
|
2817
3180
|
}
|
|
2818
3181
|
renderCategoryStep() {
|
|
2819
3182
|
const t = this.locale;
|
|
2820
|
-
const
|
|
2821
|
-
|
|
2822
|
-
|
|
3183
|
+
const categoryEntries = this.config.categories && this.config.categories.length > 0 ? this.config.categories.map((c) => ({
|
|
3184
|
+
id: c.id,
|
|
3185
|
+
icon: c.icon ?? "\u{1F4AC}",
|
|
3186
|
+
label: c.label,
|
|
3187
|
+
desc: c.description ?? ""
|
|
3188
|
+
})) : ["bug", "slow", "visual", "confusing", "other"].map((id) => ({
|
|
3189
|
+
id,
|
|
3190
|
+
icon: CATEGORY_ICONS[id],
|
|
3191
|
+
label: t.step1.categories[id],
|
|
3192
|
+
desc: t.step1.categoryDescriptions[id]
|
|
3193
|
+
}));
|
|
3194
|
+
const categories = categoryEntries.map(({ id, icon, label, desc }) => `
|
|
3195
|
+
<button type="button" class="mushi-option-btn" data-category="${escapeHtml(id)}" role="radio" aria-checked="false">
|
|
3196
|
+
<span class="mushi-option-icon" aria-hidden="true">${escapeHtml(icon)}</span>
|
|
2823
3197
|
<div class="mushi-option-text">
|
|
2824
|
-
<span class="mushi-option-label">${
|
|
2825
|
-
|
|
3198
|
+
<span class="mushi-option-label">${escapeHtml(label)}</span>
|
|
3199
|
+
${desc ? `<span class="mushi-option-desc">${escapeHtml(desc)}</span>` : ""}
|
|
2826
3200
|
</div>
|
|
2827
3201
|
<span class="mushi-option-arrow" aria-hidden="true">\u2192</span>
|
|
2828
3202
|
</button>
|
|
@@ -2851,6 +3225,12 @@ var MushiWidget = class _MushiWidget {
|
|
|
2851
3225
|
</button>` : ""}
|
|
2852
3226
|
${categories}
|
|
2853
3227
|
${this.rewardsState ? this.renderRewardsNudge() : ""}
|
|
3228
|
+
<div class="mushi-community-footer">
|
|
3229
|
+
<button type="button" class="mushi-link-btn mushi-community-btn" data-action="open-account">
|
|
3230
|
+
${this.testerInfo ? `\u{1F464} ${escapeHtml(this.testerInfo.public_handle ?? this.testerInfo.display_name ?? "My account")}` : "\u{1F310} Join community \xB7 Track reports across apps"}
|
|
3231
|
+
</button>
|
|
3232
|
+
${this.rewardsState ? `<button type="button" class="mushi-link-btn" data-action="open-leaderboard">\u{1F3C6} Leaderboard</button>` : ""}
|
|
3233
|
+
</div>
|
|
2854
3234
|
</div>
|
|
2855
3235
|
${this.renderStepIndicator(STEP_NUMBER.category)}
|
|
2856
3236
|
`;
|
|
@@ -2992,23 +3372,126 @@ var MushiWidget = class _MushiWidget {
|
|
|
2992
3372
|
`;
|
|
2993
3373
|
}
|
|
2994
3374
|
renderLeaderboardStep() {
|
|
2995
|
-
const
|
|
2996
|
-
const
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3375
|
+
const isGlobal = this.globalLeaderboard !== null || this.globalLeaderboardLoading;
|
|
3376
|
+
const entries = isGlobal ? this.globalLeaderboard ?? [] : (this.leaderboardEntries ?? []).map((e) => ({
|
|
3377
|
+
tester_id: "",
|
|
3378
|
+
public_handle: null,
|
|
3379
|
+
display_name: e.display_name,
|
|
3380
|
+
rank: 0,
|
|
3381
|
+
points_30d: e.points_30d,
|
|
3382
|
+
total_points: e.total_points
|
|
3383
|
+
}));
|
|
3384
|
+
const loading = isGlobal ? this.globalLeaderboardLoading : this.leaderboardLoading;
|
|
3385
|
+
const myRank = this.testerReputation?.rank ?? null;
|
|
3386
|
+
const rows = entries.map((e, i) => {
|
|
3387
|
+
const rank = e.rank || i + 1;
|
|
3388
|
+
const isMe = this.testerReputation && e.tester_id === this.testerReputation.tester_id;
|
|
3389
|
+
return `
|
|
3390
|
+
<div class="mushi-lb-row ${rank === 1 ? "mushi-lb-top" : ""}${isMe ? " mushi-lb-me" : ""}">
|
|
3391
|
+
<span class="mushi-lb-rank">#${rank}</span>
|
|
3392
|
+
<span class="mushi-lb-name">${escapeHtml(e.public_handle ?? e.display_name ?? "Anon")}</span>
|
|
3393
|
+
<span class="mushi-lb-pts">${(e.points_30d ?? e.total_points).toLocaleString()} pts</span>
|
|
3394
|
+
</div>
|
|
3395
|
+
`;
|
|
3396
|
+
}).join("");
|
|
3397
|
+
const myRankBadge = myRank ? `<div class="mushi-lb-myrank">You are ranked <strong>#${myRank}</strong> this month</div>` : !this.testerJwt ? `<button type="button" class="mushi-link-btn" data-action="open-account">Sign in to see your rank \u2192</button>` : "";
|
|
3398
|
+
return `
|
|
3399
|
+
${this.renderHeader({ title: "\u{1F3C6} Global Leaderboard", showBack: true, eyebrow: "Mushi \xB7 Community" })}
|
|
3400
|
+
<div class="mushi-body">
|
|
3401
|
+
${loading ? '<p class="mushi-muted">Loading leaderboard\u2026</p>' : ""}
|
|
3402
|
+
${!loading && !entries.length ? '<p class="mushi-muted">No contributors yet \u2014 be the first!</p>' : ""}
|
|
3403
|
+
<div class="mushi-lb-list">${rows}</div>
|
|
3404
|
+
${myRankBadge}
|
|
3405
|
+
<p class="mushi-lb-note">Global contributors this month \xB7 Points refresh monthly</p>
|
|
3406
|
+
</div>
|
|
3407
|
+
`;
|
|
3408
|
+
}
|
|
3409
|
+
renderAccountStep() {
|
|
3410
|
+
const tester = this.testerInfo;
|
|
3411
|
+
if (tester) {
|
|
3412
|
+
const handle = tester.public_handle ?? tester.display_name ?? "Tester";
|
|
3413
|
+
const rep = this.testerReputation;
|
|
3414
|
+
return `
|
|
3415
|
+
${this.renderHeader({ title: "\u866B Mushi Account", showBack: true, eyebrow: "Mushi \xB7 Identity" })}
|
|
3416
|
+
<div class="mushi-body">
|
|
3417
|
+
<div class="mushi-account-card">
|
|
3418
|
+
<div class="mushi-account-avatar">${escapeHtml(handle.charAt(0).toUpperCase())}</div>
|
|
3419
|
+
<div class="mushi-account-info">
|
|
3420
|
+
<strong>${escapeHtml(handle)}</strong>
|
|
3421
|
+
${rep ? `<span class="mushi-account-rank">Rank #${rep.rank ?? "\u2014"} \xB7 ${(rep.points_30d ?? 0).toLocaleString()} pts this month</span>` : ""}
|
|
3422
|
+
</div>
|
|
3423
|
+
</div>
|
|
3424
|
+
<button type="button" class="mushi-nav-item" data-action="open-cross-app-reports">
|
|
3425
|
+
My reports across all apps \u2192
|
|
3426
|
+
</button>
|
|
3427
|
+
<button type="button" class="mushi-nav-item" data-action="open-global-leaderboard">
|
|
3428
|
+
View global leaderboard \u2192
|
|
3429
|
+
</button>
|
|
3430
|
+
<button type="button" class="mushi-link-btn" data-action="sign-out-tester">Sign out</button>
|
|
3431
|
+
</div>
|
|
3432
|
+
`;
|
|
3433
|
+
}
|
|
3434
|
+
if (this.magicLinkSent) {
|
|
3435
|
+
return `
|
|
3436
|
+
${this.renderHeader({ title: "\u866B Check your email", showBack: true, eyebrow: "Mushi \xB7 Sign in" })}
|
|
3437
|
+
<div class="mushi-body">
|
|
3438
|
+
<p class="mushi-muted">We sent a sign-in link to <strong>${escapeHtml(this.magicLinkEmail)}</strong>. Click it to connect your reports across apps and join the community.</p>
|
|
3439
|
+
<button type="button" class="mushi-link-btn" data-action="resend-magic-link">Resend email</button>
|
|
3440
|
+
${this.magicLinkError ? `<p class="mushi-error">${escapeHtml(this.magicLinkError)}</p>` : ""}
|
|
3441
|
+
</div>
|
|
3442
|
+
`;
|
|
3443
|
+
}
|
|
3444
|
+
return `
|
|
3445
|
+
${this.renderHeader({ title: "\u866B Join the community", showBack: true, eyebrow: "Mushi \xB7 Sign in" })}
|
|
3446
|
+
<div class="mushi-body">
|
|
3447
|
+
<p class="mushi-muted">Sign in to see your reports across all apps and climb the global leaderboard. No password needed.</p>
|
|
3448
|
+
<label class="mushi-label" for="mushi-email-input">Email address</label>
|
|
3449
|
+
<input
|
|
3450
|
+
id="mushi-email-input"
|
|
3451
|
+
type="email"
|
|
3452
|
+
class="mushi-textarea"
|
|
3453
|
+
data-role="magic-link-email"
|
|
3454
|
+
placeholder="you@example.com"
|
|
3455
|
+
autocomplete="email"
|
|
3456
|
+
value="${escapeHtml(this.magicLinkEmail)}"
|
|
3457
|
+
style="padding: 10px 12px; height: auto; resize: none;"
|
|
3458
|
+
/>
|
|
3459
|
+
${this.magicLinkError ? `<p class="mushi-error">${escapeHtml(this.magicLinkError)}</p>` : ""}
|
|
3460
|
+
<button type="button" class="mushi-submit" data-action="send-magic-link">
|
|
3461
|
+
<span>Send sign-in link</span><span class="mushi-submit-arrow" aria-hidden="true">\u2192</span>
|
|
3462
|
+
</button>
|
|
3463
|
+
</div>
|
|
3464
|
+
`;
|
|
3465
|
+
}
|
|
3466
|
+
renderCrossAppReportsStep() {
|
|
3467
|
+
const reports = this.crossAppReports ?? [];
|
|
3468
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
3469
|
+
for (const r of reports) {
|
|
3470
|
+
const key = r.project_id ?? "unknown";
|
|
3471
|
+
if (!grouped.has(key)) grouped.set(key, { name: r.app_name ?? "Unknown App", reports: [] });
|
|
3472
|
+
grouped.get(key).reports.push(r);
|
|
3473
|
+
}
|
|
3474
|
+
const rows = [...grouped.entries()].map(([, group]) => `
|
|
3475
|
+
<div class="mushi-xapp-group">
|
|
3476
|
+
<h4 class="mushi-xapp-app-name">${escapeHtml(group.name)}</h4>
|
|
3477
|
+
${group.reports.map((r) => {
|
|
3478
|
+
const tone = reporterStatusTone(r.status);
|
|
3479
|
+
return `
|
|
3480
|
+
<div class="mushi-report-row" data-report-id="${escapeHtml(r.id)}" tabindex="0" role="button">
|
|
3481
|
+
<span class="mushi-report-status mushi-status-${tone}">${escapeHtml(reporterStatusShort(r.status))}</span>
|
|
3482
|
+
<span class="mushi-report-title">${escapeHtml(r.title ?? r.category)}</span>
|
|
3483
|
+
<span class="mushi-report-when">${escapeHtml(formatRelativeTime(r.created_at))}</span>
|
|
3484
|
+
</div>
|
|
3485
|
+
`;
|
|
3486
|
+
}).join("")}
|
|
3002
3487
|
</div>
|
|
3003
3488
|
`).join("");
|
|
3004
3489
|
return `
|
|
3005
|
-
${this.renderHeader({ title: "
|
|
3490
|
+
${this.renderHeader({ title: "My reports", showBack: true, eyebrow: "Mushi \xB7 All apps" })}
|
|
3006
3491
|
<div class="mushi-body">
|
|
3007
|
-
${this.
|
|
3008
|
-
${!this.
|
|
3009
|
-
|
|
3010
|
-
${myRank > 0 ? `<p class="mushi-lb-myrank">You are ranked #${myRank}</p>` : ""}
|
|
3011
|
-
<p class="mushi-lb-note">Top contributors this month \xB7 Points refresh monthly</p>
|
|
3492
|
+
${this.crossAppLoading ? '<p class="mushi-muted">Loading your reports\u2026</p>' : ""}
|
|
3493
|
+
${!this.crossAppLoading && !reports.length ? '<p class="mushi-muted">No reports filed yet.</p>' : ""}
|
|
3494
|
+
${rows}
|
|
3012
3495
|
</div>
|
|
3013
3496
|
`;
|
|
3014
3497
|
}
|
|
@@ -3051,19 +3534,22 @@ var MushiWidget = class _MushiWidget {
|
|
|
3051
3534
|
}
|
|
3052
3535
|
renderIntentStep() {
|
|
3053
3536
|
const t = this.locale;
|
|
3054
|
-
const
|
|
3055
|
-
const
|
|
3537
|
+
const catId = this.selectedCategory;
|
|
3538
|
+
const customEntry = this.resolveCustomCategory(catId);
|
|
3539
|
+
const intents = customEntry?.intents ?? (t.step2.intents[catId] || []);
|
|
3056
3540
|
const options = intents.map((intent) => `
|
|
3057
|
-
<button type="button" class="mushi-intent-btn" data-intent="${intent}">
|
|
3058
|
-
${intent}
|
|
3541
|
+
<button type="button" class="mushi-intent-btn" data-intent="${escapeHtml(intent)}">
|
|
3542
|
+
${escapeHtml(intent)}
|
|
3059
3543
|
</button>
|
|
3060
3544
|
`).join("");
|
|
3545
|
+
const icon = this.categoryIcon(catId);
|
|
3546
|
+
const label = this.categoryLabel(catId);
|
|
3061
3547
|
return `
|
|
3062
3548
|
${this.renderHeader({ title: t.step2.heading, showBack: true, step: STEP_NUMBER.intent })}
|
|
3063
3549
|
<div class="mushi-body">
|
|
3064
3550
|
<div class="mushi-selected-category">
|
|
3065
|
-
<span aria-hidden="true">${
|
|
3066
|
-
<span>${
|
|
3551
|
+
<span aria-hidden="true">${escapeHtml(icon)}</span>
|
|
3552
|
+
<span>${escapeHtml(label)}</span>
|
|
3067
3553
|
</div>
|
|
3068
3554
|
<div class="mushi-intents">
|
|
3069
3555
|
${options}
|
|
@@ -3380,6 +3866,41 @@ var MushiWidget = class _MushiWidget {
|
|
|
3380
3866
|
panel.querySelector('[data-action="open-leaderboard"]')?.addEventListener("click", () => {
|
|
3381
3867
|
this.step = "leaderboard";
|
|
3382
3868
|
this.callbacks.onLeaderboardOpen?.();
|
|
3869
|
+
this.callbacks.onGlobalLeaderboardOpen?.();
|
|
3870
|
+
this.render();
|
|
3871
|
+
});
|
|
3872
|
+
panel.querySelector('[data-action="open-account"]')?.addEventListener("click", () => {
|
|
3873
|
+
this.step = "account";
|
|
3874
|
+
this.render();
|
|
3875
|
+
});
|
|
3876
|
+
panel.querySelector('[data-action="open-cross-app-reports"]')?.addEventListener("click", () => {
|
|
3877
|
+
this.step = "cross-app-reports";
|
|
3878
|
+
this.crossAppLoading = true;
|
|
3879
|
+
this.crossAppReports = null;
|
|
3880
|
+
this.render();
|
|
3881
|
+
this.callbacks.onCrossAppReportsOpen?.();
|
|
3882
|
+
});
|
|
3883
|
+
panel.querySelector('[data-action="open-global-leaderboard"]')?.addEventListener("click", () => {
|
|
3884
|
+
this.step = "leaderboard";
|
|
3885
|
+
this.callbacks.onGlobalLeaderboardOpen?.();
|
|
3886
|
+
this.render();
|
|
3887
|
+
});
|
|
3888
|
+
panel.querySelector('[data-action="send-magic-link"]')?.addEventListener("click", () => {
|
|
3889
|
+
void this.handleMagicLinkSend(panel);
|
|
3890
|
+
});
|
|
3891
|
+
panel.querySelector('[data-action="resend-magic-link"]')?.addEventListener("click", () => {
|
|
3892
|
+
this.magicLinkSent = false;
|
|
3893
|
+
this.magicLinkError = "";
|
|
3894
|
+
this.render();
|
|
3895
|
+
});
|
|
3896
|
+
panel.querySelector('[data-action="sign-out-tester"]')?.addEventListener("click", () => {
|
|
3897
|
+
this.testerJwt = null;
|
|
3898
|
+
this.testerInfo = null;
|
|
3899
|
+
this.testerReputation = null;
|
|
3900
|
+
this.crossAppReports = null;
|
|
3901
|
+
this.magicLinkSent = false;
|
|
3902
|
+
this.magicLinkEmail = "";
|
|
3903
|
+
this.step = "category";
|
|
3383
3904
|
this.render();
|
|
3384
3905
|
});
|
|
3385
3906
|
panel.querySelector('[data-action="reporter-reply"]')?.addEventListener("click", () => {
|
|
@@ -3414,8 +3935,10 @@ var MushiWidget = class _MushiWidget {
|
|
|
3414
3935
|
});
|
|
3415
3936
|
panel.querySelectorAll("[data-category]").forEach((btn) => {
|
|
3416
3937
|
btn.addEventListener("click", () => {
|
|
3417
|
-
|
|
3418
|
-
this.
|
|
3938
|
+
const catId = btn.dataset.category ?? "other";
|
|
3939
|
+
this.selectedCategory = catId;
|
|
3940
|
+
const custom = this.resolveCustomCategory(catId);
|
|
3941
|
+
this.step = custom && (!custom.intents || custom.intents.length === 0) ? "details" : "intent";
|
|
3419
3942
|
this.render();
|
|
3420
3943
|
});
|
|
3421
3944
|
});
|
|
@@ -3486,8 +4009,12 @@ var MushiWidget = class _MushiWidget {
|
|
|
3486
4009
|
this.render();
|
|
3487
4010
|
const outcomeP = (async () => {
|
|
3488
4011
|
try {
|
|
4012
|
+
const catId = this.selectedCategory;
|
|
4013
|
+
const baseCategory = this.resolveBaseCategory(catId);
|
|
4014
|
+
const isCustomCat = this.config.categories && this.config.categories.length > 0;
|
|
3489
4015
|
const ret = this.callbacks.onSubmit({
|
|
3490
|
-
category:
|
|
4016
|
+
category: baseCategory,
|
|
4017
|
+
...isCustomCat ? { userCategory: catId } : {},
|
|
3491
4018
|
description,
|
|
3492
4019
|
intent: this.selectedIntent ?? void 0
|
|
3493
4020
|
});
|
|
@@ -3659,6 +4186,27 @@ var MushiWidget = class _MushiWidget {
|
|
|
3659
4186
|
this.render();
|
|
3660
4187
|
}
|
|
3661
4188
|
}
|
|
4189
|
+
/* ── Community: magic-link sign-in ───────────────────────────────── */
|
|
4190
|
+
async handleMagicLinkSend(panel) {
|
|
4191
|
+
const emailInput = panel.querySelector('[data-role="magic-link-email"]');
|
|
4192
|
+
const email = (emailInput?.value ?? this.magicLinkEmail).trim();
|
|
4193
|
+
if (!email || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
|
4194
|
+
this.magicLinkError = "Please enter a valid email address.";
|
|
4195
|
+
this.render();
|
|
4196
|
+
return;
|
|
4197
|
+
}
|
|
4198
|
+
this.magicLinkEmail = email;
|
|
4199
|
+
this.magicLinkError = "";
|
|
4200
|
+
this.render();
|
|
4201
|
+
try {
|
|
4202
|
+
await this.callbacks.onMushiSignIn?.(email);
|
|
4203
|
+
this.magicLinkSent = true;
|
|
4204
|
+
this.render();
|
|
4205
|
+
} catch (err) {
|
|
4206
|
+
this.magicLinkError = err instanceof Error ? err.message : "Could not send sign-in link. Try again.";
|
|
4207
|
+
this.render();
|
|
4208
|
+
}
|
|
4209
|
+
}
|
|
3662
4210
|
/* ── Marketing / Playwright recorder (debug GIF capture) ─────────── */
|
|
3663
4211
|
getRecorderStep() {
|
|
3664
4212
|
return this.step;
|
|
@@ -5743,7 +6291,7 @@ function createProactiveManager(config = {}) {
|
|
|
5743
6291
|
|
|
5744
6292
|
// src/version.ts
|
|
5745
6293
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
5746
|
-
var MUSHI_SDK_VERSION = "1.
|
|
6294
|
+
var MUSHI_SDK_VERSION = "1.14.0" ;
|
|
5747
6295
|
|
|
5748
6296
|
// src/mushi.ts
|
|
5749
6297
|
var instance = null;
|
|
@@ -5825,6 +6373,42 @@ function createInstance(config) {
|
|
|
5825
6373
|
let replayCap = null;
|
|
5826
6374
|
let replayGeneration = 0;
|
|
5827
6375
|
let widget;
|
|
6376
|
+
const TESTER_JWT_KEY = `mushi:tester-jwt:${bootstrapConfig.projectId}`;
|
|
6377
|
+
function readTesterJwt() {
|
|
6378
|
+
try {
|
|
6379
|
+
return typeof localStorage !== "undefined" ? localStorage.getItem(TESTER_JWT_KEY) : null;
|
|
6380
|
+
} catch {
|
|
6381
|
+
return null;
|
|
6382
|
+
}
|
|
6383
|
+
}
|
|
6384
|
+
function clearTesterJwt() {
|
|
6385
|
+
try {
|
|
6386
|
+
if (typeof localStorage !== "undefined") localStorage.removeItem(TESTER_JWT_KEY);
|
|
6387
|
+
} catch {
|
|
6388
|
+
}
|
|
6389
|
+
}
|
|
6390
|
+
async function loadTesterSession(jwt) {
|
|
6391
|
+
const statusResult = await apiClient2.getTesterStatus(jwt);
|
|
6392
|
+
if (!statusResult.ok || !statusResult.data) {
|
|
6393
|
+
clearTesterJwt();
|
|
6394
|
+
return;
|
|
6395
|
+
}
|
|
6396
|
+
const status = statusResult.data;
|
|
6397
|
+
if (!status.is_tester) {
|
|
6398
|
+
clearTesterJwt();
|
|
6399
|
+
return;
|
|
6400
|
+
}
|
|
6401
|
+
widget.setTesterSession(jwt, {
|
|
6402
|
+
id: jwt.substring(0, 16),
|
|
6403
|
+
public_handle: status.public_handle ?? null,
|
|
6404
|
+
display_name: status.display_name ?? null
|
|
6405
|
+
});
|
|
6406
|
+
const repResult = await apiClient2.getMyReputation(jwt);
|
|
6407
|
+
if (repResult.ok && repResult.data) {
|
|
6408
|
+
const repData = repResult.data;
|
|
6409
|
+
if (repData.reputation) widget.setTesterReputation(repData.reputation);
|
|
6410
|
+
}
|
|
6411
|
+
}
|
|
5828
6412
|
function syncCaptureModules() {
|
|
5829
6413
|
if (activeConfig.capture?.console !== false) {
|
|
5830
6414
|
consoleCap ??= createConsoleCapture();
|
|
@@ -5977,11 +6561,11 @@ function createInstance(config) {
|
|
|
5977
6561
|
widget.setScreenshotAttached(pendingScreenshot !== null);
|
|
5978
6562
|
}
|
|
5979
6563
|
widget = new MushiWidget(bootstrapConfig.widget, {
|
|
5980
|
-
onSubmit: async ({ category, description, intent }) => {
|
|
5981
|
-
log.info("Report submitted", { category, intent });
|
|
6564
|
+
onSubmit: async ({ category, userCategory, description, intent }) => {
|
|
6565
|
+
log.info("Report submitted", { category, userCategory, intent });
|
|
5982
6566
|
proactiveManager?.recordSubmission();
|
|
5983
6567
|
await autoCaptureScreenshot("submit");
|
|
5984
|
-
const outcome = await submitReport(category, description, intent);
|
|
6568
|
+
const outcome = await submitReport(category, description, intent, userCategory);
|
|
5985
6569
|
return outcome ?? { reportId: null, queuedOffline: true };
|
|
5986
6570
|
},
|
|
5987
6571
|
onOpen: () => {
|
|
@@ -6118,6 +6702,45 @@ function createInstance(config) {
|
|
|
6118
6702
|
void fetchLeaderboard(10).then((entries) => {
|
|
6119
6703
|
widget.setLeaderboard(entries, false);
|
|
6120
6704
|
});
|
|
6705
|
+
},
|
|
6706
|
+
// ── Community callbacks ──────────────────────────────────────────────
|
|
6707
|
+
async onMushiSignIn(email) {
|
|
6708
|
+
const res = await apiClient2.sendMagicLink(email);
|
|
6709
|
+
if (!res.ok) throw new Error(res.error?.message ?? "Could not send sign-in link");
|
|
6710
|
+
return { ok: true };
|
|
6711
|
+
},
|
|
6712
|
+
async onGlobalLeaderboardOpen() {
|
|
6713
|
+
widget.setGlobalLeaderboard(null, true);
|
|
6714
|
+
const jwt = readTesterJwt();
|
|
6715
|
+
const res = await apiClient2.getPublicLeaderboard(50);
|
|
6716
|
+
const rawEntries = res.ok ? res.data?.leaderboard ?? [] : [];
|
|
6717
|
+
const entries = rawEntries.map((e) => ({
|
|
6718
|
+
tester_id: e.tester_id,
|
|
6719
|
+
rank: e.rank,
|
|
6720
|
+
public_handle: e.public_handle,
|
|
6721
|
+
display_name: e.display_name,
|
|
6722
|
+
points_30d: e.points_30d,
|
|
6723
|
+
total_points: e.total_points ?? 0,
|
|
6724
|
+
badge: e.badge_slug
|
|
6725
|
+
}));
|
|
6726
|
+
widget.setGlobalLeaderboard(entries, false);
|
|
6727
|
+
if (jwt) {
|
|
6728
|
+
const repRes = await apiClient2.getMyReputation(jwt);
|
|
6729
|
+
if (repRes.ok && repRes.data) {
|
|
6730
|
+
const repData = repRes.data;
|
|
6731
|
+
if (repData.reputation) widget.setTesterReputation(repData.reputation);
|
|
6732
|
+
}
|
|
6733
|
+
}
|
|
6734
|
+
},
|
|
6735
|
+
async onCrossAppReportsOpen() {
|
|
6736
|
+
const jwt = readTesterJwt();
|
|
6737
|
+
if (!jwt) {
|
|
6738
|
+
widget.setCrossAppReports([], false);
|
|
6739
|
+
return;
|
|
6740
|
+
}
|
|
6741
|
+
const res = await apiClient2.getCrossAppReports(jwt);
|
|
6742
|
+
const reports = res.ok ? res.data?.reports ?? [] : [];
|
|
6743
|
+
widget.setCrossAppReports(reports, false);
|
|
6121
6744
|
}
|
|
6122
6745
|
}, MUSHI_SDK_VERSION);
|
|
6123
6746
|
syncCaptureModules();
|
|
@@ -6128,6 +6751,10 @@ function createInstance(config) {
|
|
|
6128
6751
|
widget.mount();
|
|
6129
6752
|
}
|
|
6130
6753
|
}
|
|
6754
|
+
const cachedJwt = readTesterJwt();
|
|
6755
|
+
if (cachedJwt) {
|
|
6756
|
+
void loadTesterSession(cachedJwt).catch(() => clearTesterJwt());
|
|
6757
|
+
}
|
|
6131
6758
|
let proactiveTriggers = null;
|
|
6132
6759
|
let proactiveManager = null;
|
|
6133
6760
|
const proactiveCfg = activeConfig.proactive;
|
|
@@ -6238,7 +6865,7 @@ function createInstance(config) {
|
|
|
6238
6865
|
});
|
|
6239
6866
|
}
|
|
6240
6867
|
}
|
|
6241
|
-
async function submitReport(category, description, intent) {
|
|
6868
|
+
async function submitReport(category, description, intent, userCategory) {
|
|
6242
6869
|
const filterResult = preFilter.check(description);
|
|
6243
6870
|
if (!filterResult.passed) {
|
|
6244
6871
|
log.info("Report blocked by pre-filter", { reason: filterResult.reason });
|
|
@@ -6298,6 +6925,7 @@ function createInstance(config) {
|
|
|
6298
6925
|
id: newUuid(),
|
|
6299
6926
|
projectId: config.projectId,
|
|
6300
6927
|
category,
|
|
6928
|
+
...userCategory ? { userCategory } : {},
|
|
6301
6929
|
description: scrubbedDescription,
|
|
6302
6930
|
userIntent: intent,
|
|
6303
6931
|
environment: captureEnvironment(),
|