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