@mushi-mushi/web 1.13.0 → 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 +602 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -2
- package/dist/index.d.ts +59 -2
- package/dist/index.js +602 -32
- 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
|
|
|
@@ -1990,7 +2055,9 @@ var MushiWidget = class _MushiWidget {
|
|
|
1990
2055
|
featureRequestLabel: config.featureRequestLabel ?? "",
|
|
1991
2056
|
featureRequestDescription: config.featureRequestDescription ?? "",
|
|
1992
2057
|
avoidSelectors: config.avoidSelectors ?? [],
|
|
1993
|
-
categories: config.categories ?? []
|
|
2058
|
+
categories: config.categories ?? [],
|
|
2059
|
+
accent: config.accent ?? "",
|
|
2060
|
+
accentText: config.accentText ?? ""
|
|
1994
2061
|
};
|
|
1995
2062
|
this.callbacks = callbacks;
|
|
1996
2063
|
this.locale = getLocale(this.config.locale === "auto" ? void 0 : this.config.locale);
|
|
@@ -2073,6 +2140,26 @@ var MushiWidget = class _MushiWidget {
|
|
|
2073
2140
|
lastSubmitQueuedOffline = false;
|
|
2074
2141
|
/** Whether the user has clicked ✕ on the header banner this session. */
|
|
2075
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 = "";
|
|
2076
2163
|
mount() {
|
|
2077
2164
|
if (this.host.isConnected) return;
|
|
2078
2165
|
this.syncHostChromeState();
|
|
@@ -2368,6 +2455,26 @@ var MushiWidget = class _MushiWidget {
|
|
|
2368
2455
|
this.leaderboardLoading = loading;
|
|
2369
2456
|
if (this.isOpen && this.step === "leaderboard") this.render();
|
|
2370
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
|
+
}
|
|
2371
2478
|
destroy() {
|
|
2372
2479
|
if (this.successTimer !== null) {
|
|
2373
2480
|
clearTimeout(this.successTimer);
|
|
@@ -2383,6 +2490,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
2383
2490
|
}
|
|
2384
2491
|
this.smartHideCleanup?.();
|
|
2385
2492
|
this.smartHideCleanup = null;
|
|
2493
|
+
this.teardownViewportHandlers();
|
|
2386
2494
|
this.attachedLaunchers.forEach((cleanup) => cleanup());
|
|
2387
2495
|
this.attachedLaunchers = [];
|
|
2388
2496
|
this.removeSelectorHint();
|
|
@@ -2660,7 +2768,25 @@ var MushiWidget = class _MushiWidget {
|
|
|
2660
2768
|
return this.config.hideOnRoutes.some((route) => location.pathname.includes(route));
|
|
2661
2769
|
}
|
|
2662
2770
|
getTheme() {
|
|
2663
|
-
|
|
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
|
+
}
|
|
2664
2790
|
if (typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
2665
2791
|
return "dark";
|
|
2666
2792
|
}
|
|
@@ -2672,7 +2798,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
2672
2798
|
const t = this.locale;
|
|
2673
2799
|
this.shadow.innerHTML = "";
|
|
2674
2800
|
const style = document.createElement("style");
|
|
2675
|
-
style.textContent = getWidgetStyles(theme);
|
|
2801
|
+
style.textContent = getWidgetStyles(theme, this.config.accent ?? "", this.config.accentText ?? "");
|
|
2676
2802
|
this.shadow.appendChild(style);
|
|
2677
2803
|
this.renderBanner();
|
|
2678
2804
|
if (this.shouldRenderTrigger()) {
|
|
@@ -2685,6 +2811,11 @@ var MushiWidget = class _MushiWidget {
|
|
|
2685
2811
|
trigger.setAttribute("aria-expanded", String(this.isOpen));
|
|
2686
2812
|
trigger.style.zIndex = String(this.config.zIndex);
|
|
2687
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
|
+
}
|
|
2688
2819
|
trigger.addEventListener("click", () => {
|
|
2689
2820
|
this.removeNudge();
|
|
2690
2821
|
if (this.isOpen) this.close();
|
|
@@ -2702,6 +2833,29 @@ var MushiWidget = class _MushiWidget {
|
|
|
2702
2833
|
this.nudgeTimer = setTimeout(() => this.removeNudge(), 2e3);
|
|
2703
2834
|
}
|
|
2704
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
|
+
}
|
|
2705
2859
|
this.shadow.appendChild(trigger);
|
|
2706
2860
|
}
|
|
2707
2861
|
const panel = document.createElement("div");
|
|
@@ -2716,6 +2870,9 @@ var MushiWidget = class _MushiWidget {
|
|
|
2716
2870
|
this.shadow.appendChild(panel);
|
|
2717
2871
|
this.attachHandlers(panel);
|
|
2718
2872
|
this.trapFocus(panel);
|
|
2873
|
+
this.attachViewportHandlers(panel);
|
|
2874
|
+
} else {
|
|
2875
|
+
this.teardownViewportHandlers();
|
|
2719
2876
|
}
|
|
2720
2877
|
}
|
|
2721
2878
|
/**
|
|
@@ -2774,6 +2931,171 @@ var MushiWidget = class _MushiWidget {
|
|
|
2774
2931
|
}
|
|
2775
2932
|
}
|
|
2776
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
|
+
}
|
|
2777
3099
|
renderStep() {
|
|
2778
3100
|
switch (this.step) {
|
|
2779
3101
|
case "category":
|
|
@@ -2792,6 +3114,10 @@ var MushiWidget = class _MushiWidget {
|
|
|
2792
3114
|
return this.renderLeaderboardStep();
|
|
2793
3115
|
case "roadmap":
|
|
2794
3116
|
return this.renderRoadmapStep();
|
|
3117
|
+
case "account":
|
|
3118
|
+
return this.renderAccountStep();
|
|
3119
|
+
case "cross-app-reports":
|
|
3120
|
+
return this.renderCrossAppReportsStep();
|
|
2795
3121
|
}
|
|
2796
3122
|
}
|
|
2797
3123
|
renderOutdatedBanner() {
|
|
@@ -2901,6 +3227,12 @@ var MushiWidget = class _MushiWidget {
|
|
|
2901
3227
|
</button>` : ""}
|
|
2902
3228
|
${categories}
|
|
2903
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>
|
|
2904
3236
|
</div>
|
|
2905
3237
|
${this.renderStepIndicator(STEP_NUMBER.category)}
|
|
2906
3238
|
`;
|
|
@@ -3042,23 +3374,126 @@ var MushiWidget = class _MushiWidget {
|
|
|
3042
3374
|
`;
|
|
3043
3375
|
}
|
|
3044
3376
|
renderLeaderboardStep() {
|
|
3045
|
-
const
|
|
3046
|
-
const
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
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("")}
|
|
3052
3489
|
</div>
|
|
3053
3490
|
`).join("");
|
|
3054
3491
|
return `
|
|
3055
|
-
${this.renderHeader({ title: "
|
|
3492
|
+
${this.renderHeader({ title: "My reports", showBack: true, eyebrow: "Mushi \xB7 All apps" })}
|
|
3056
3493
|
<div class="mushi-body">
|
|
3057
|
-
${this.
|
|
3058
|
-
${!this.
|
|
3059
|
-
|
|
3060
|
-
${myRank > 0 ? `<p class="mushi-lb-myrank">You are ranked #${myRank}</p>` : ""}
|
|
3061
|
-
<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}
|
|
3062
3497
|
</div>
|
|
3063
3498
|
`;
|
|
3064
3499
|
}
|
|
@@ -3433,6 +3868,41 @@ var MushiWidget = class _MushiWidget {
|
|
|
3433
3868
|
panel.querySelector('[data-action="open-leaderboard"]')?.addEventListener("click", () => {
|
|
3434
3869
|
this.step = "leaderboard";
|
|
3435
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";
|
|
3436
3906
|
this.render();
|
|
3437
3907
|
});
|
|
3438
3908
|
panel.querySelector('[data-action="reporter-reply"]')?.addEventListener("click", () => {
|
|
@@ -3718,6 +4188,27 @@ var MushiWidget = class _MushiWidget {
|
|
|
3718
4188
|
this.render();
|
|
3719
4189
|
}
|
|
3720
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
|
+
}
|
|
3721
4212
|
/* ── Marketing / Playwright recorder (debug GIF capture) ─────────── */
|
|
3722
4213
|
getRecorderStep() {
|
|
3723
4214
|
return this.step;
|
|
@@ -5802,7 +6293,7 @@ function createProactiveManager(config = {}) {
|
|
|
5802
6293
|
|
|
5803
6294
|
// src/version.ts
|
|
5804
6295
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
5805
|
-
var MUSHI_SDK_VERSION = "1.
|
|
6296
|
+
var MUSHI_SDK_VERSION = "1.14.0" ;
|
|
5806
6297
|
|
|
5807
6298
|
// src/mushi.ts
|
|
5808
6299
|
var instance = null;
|
|
@@ -5884,6 +6375,42 @@ function createInstance(config) {
|
|
|
5884
6375
|
let replayCap = null;
|
|
5885
6376
|
let replayGeneration = 0;
|
|
5886
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
|
+
}
|
|
5887
6414
|
function syncCaptureModules() {
|
|
5888
6415
|
if (activeConfig.capture?.console !== false) {
|
|
5889
6416
|
consoleCap ??= createConsoleCapture();
|
|
@@ -6177,6 +6704,45 @@ function createInstance(config) {
|
|
|
6177
6704
|
void fetchLeaderboard(10).then((entries) => {
|
|
6178
6705
|
widget.setLeaderboard(entries, false);
|
|
6179
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);
|
|
6180
6746
|
}
|
|
6181
6747
|
}, MUSHI_SDK_VERSION);
|
|
6182
6748
|
syncCaptureModules();
|
|
@@ -6187,6 +6753,10 @@ function createInstance(config) {
|
|
|
6187
6753
|
widget.mount();
|
|
6188
6754
|
}
|
|
6189
6755
|
}
|
|
6756
|
+
const cachedJwt = readTesterJwt();
|
|
6757
|
+
if (cachedJwt) {
|
|
6758
|
+
void loadTesterSession(cachedJwt).catch(() => clearTesterJwt());
|
|
6759
|
+
}
|
|
6190
6760
|
let proactiveTriggers = null;
|
|
6191
6761
|
let proactiveManager = null;
|
|
6192
6762
|
const proactiveCfg = activeConfig.proactive;
|