@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.js
CHANGED
|
@@ -289,17 +289,18 @@ function getAvailableLocales() {
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
// src/styles.ts
|
|
292
|
-
function getWidgetStyles(theme) {
|
|
292
|
+
function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
293
293
|
const isDark = theme === "dark";
|
|
294
294
|
const paper = isDark ? "#0F0E0C" : "#F8F4ED";
|
|
295
295
|
const ink = isDark ? "#F2EBDD" : "#0E0D0B";
|
|
296
296
|
const inkMuted = isDark ? "#928B7E" : "#5C5852";
|
|
297
297
|
const inkFaint = isDark ? "#5A5650" : "#9A9489";
|
|
298
|
+
const inkDim = isDark ? "#7A7268" : "#6E6760";
|
|
298
299
|
const rule = isDark ? "rgba(242,235,221,0.10)" : "rgba(14,13,11,0.10)";
|
|
299
300
|
const ruleStrong = isDark ? "rgba(242,235,221,0.18)" : "rgba(14,13,11,0.16)";
|
|
300
|
-
const widgetAccent = isDark ? "#FF5A47" : "#E03C2C";
|
|
301
|
-
const widgetAccentWash = isDark ?
|
|
302
|
-
const widgetAccentInk = isDark ? "#FFE5E0" : "#7A1F15";
|
|
301
|
+
const widgetAccent = accent || (isDark ? "#FF5A47" : "#E03C2C");
|
|
302
|
+
const widgetAccentWash = isDark ? `${widgetAccent}1F` : `${widgetAccent}14`;
|
|
303
|
+
const widgetAccentInk = accentText || (isDark ? "#FFE5E0" : "#7A1F15");
|
|
303
304
|
const fontDisplay = `'Iowan Old Style', 'Palatino Linotype', 'Palatino', 'Book Antiqua', 'Cambria', Georgia, 'Times New Roman', serif`;
|
|
304
305
|
const fontBody = `system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI Variable Display', 'Segoe UI', sans-serif`;
|
|
305
306
|
const fontMono = `ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, 'Liberation Mono', monospace`;
|
|
@@ -446,6 +447,33 @@ function getWidgetStyles(theme) {
|
|
|
446
447
|
transform: scale(0.92);
|
|
447
448
|
}
|
|
448
449
|
|
|
450
|
+
/* \u2500\u2500 Draggable FAB \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
451
|
+
When draggable is enabled the trigger uses CSS translate to apply the
|
|
452
|
+
drag offset ON TOP of the existing inset positioning, so snapping and
|
|
453
|
+
safe-area clamp still work correctly via the inset vars.
|
|
454
|
+
--mushi-drag-active 0|1 gates the transform so non-draggable FABs are
|
|
455
|
+
completely unaffected. touch-action: none prevents browser pan/scroll
|
|
456
|
+
from racing the pointer capture. */
|
|
457
|
+
.mushi-trigger {
|
|
458
|
+
touch-action: none;
|
|
459
|
+
translate:
|
|
460
|
+
calc(var(--mushi-drag-active, 0) * var(--mushi-drag-x, 0px))
|
|
461
|
+
calc(var(--mushi-drag-active, 0) * var(--mushi-drag-y, 0px));
|
|
462
|
+
}
|
|
463
|
+
.mushi-trigger.dragging {
|
|
464
|
+
cursor: grabbing !important;
|
|
465
|
+
z-index: calc(var(--z, 99999) + 2);
|
|
466
|
+
transition: none !important;
|
|
467
|
+
box-shadow:
|
|
468
|
+
0 1px 0 ${rule},
|
|
469
|
+
0 20px 40px -12px rgba(14,13,11,0.55),
|
|
470
|
+
inset 0 -3px 0 ${widgetAccent};
|
|
471
|
+
opacity: 0.92;
|
|
472
|
+
}
|
|
473
|
+
@media (prefers-reduced-motion: reduce) {
|
|
474
|
+
.mushi-trigger { transition: none !important; }
|
|
475
|
+
}
|
|
476
|
+
|
|
449
477
|
@keyframes mushi-pulse {
|
|
450
478
|
0% { box-shadow: 0 0 0 0 ${widgetAccent}; opacity: 1; }
|
|
451
479
|
70% { box-shadow: 0 0 0 8px rgba(224,60,44,0); opacity: 0.5; }
|
|
@@ -456,7 +484,7 @@ function getWidgetStyles(theme) {
|
|
|
456
484
|
position: fixed;
|
|
457
485
|
width: 384px;
|
|
458
486
|
max-width: calc(100vw - 32px);
|
|
459
|
-
max-height: min(640px, calc(
|
|
487
|
+
max-height: min(640px, calc(100dvh - 120px - var(--mushi-keyboard-inset, 0px)));
|
|
460
488
|
background: ${paper};
|
|
461
489
|
border: 1px solid ${ruleStrong};
|
|
462
490
|
border-radius: 6px;
|
|
@@ -468,6 +496,26 @@ function getWidgetStyles(theme) {
|
|
|
468
496
|
display: flex;
|
|
469
497
|
flex-direction: column;
|
|
470
498
|
transform-origin: var(--mushi-origin, bottom right);
|
|
499
|
+
transition: bottom 120ms ease, top 120ms ease, max-height 120ms ease;
|
|
500
|
+
}
|
|
501
|
+
/* Keyboard-safe: on narrow viewports lift above the keyboard */
|
|
502
|
+
.mushi-panel.keyboard-open {
|
|
503
|
+
bottom: calc(var(--mushi-keyboard-inset, 0px) + 8px) !important;
|
|
504
|
+
}
|
|
505
|
+
/* On narrow mobile, fill the width as a bottom sheet */
|
|
506
|
+
@media (max-width: 480px) {
|
|
507
|
+
.mushi-panel {
|
|
508
|
+
left: 0 !important;
|
|
509
|
+
right: 0 !important;
|
|
510
|
+
width: 100% !important;
|
|
511
|
+
max-width: 100% !important;
|
|
512
|
+
border-bottom-left-radius: 0;
|
|
513
|
+
border-bottom-right-radius: 0;
|
|
514
|
+
bottom: var(--mushi-keyboard-inset, 0px) !important;
|
|
515
|
+
}
|
|
516
|
+
.mushi-panel.keyboard-open {
|
|
517
|
+
bottom: calc(var(--mushi-keyboard-inset, 0px) + 4px) !important;
|
|
518
|
+
}
|
|
471
519
|
}
|
|
472
520
|
.mushi-panel.open { animation: mushi-stamp-in 320ms ${easeStamp} both; }
|
|
473
521
|
.mushi-panel.closed { display: none; }
|
|
@@ -1496,7 +1544,7 @@ function getWidgetStyles(theme) {
|
|
|
1496
1544
|
}
|
|
1497
1545
|
|
|
1498
1546
|
.mushi-beta-perks li {
|
|
1499
|
-
font-size:
|
|
1547
|
+
font-size: 12px;
|
|
1500
1548
|
color: ${widgetAccentInk};
|
|
1501
1549
|
font-weight: 500;
|
|
1502
1550
|
}
|
|
@@ -1508,8 +1556,8 @@ function getWidgetStyles(theme) {
|
|
|
1508
1556
|
}
|
|
1509
1557
|
|
|
1510
1558
|
.mushi-changelog-summary {
|
|
1511
|
-
font-size:
|
|
1512
|
-
color:
|
|
1559
|
+
font-size: 11px;
|
|
1560
|
+
color: ${inkDim};
|
|
1513
1561
|
cursor: pointer;
|
|
1514
1562
|
list-style: none;
|
|
1515
1563
|
display: flex;
|
|
@@ -1539,8 +1587,8 @@ function getWidgetStyles(theme) {
|
|
|
1539
1587
|
}
|
|
1540
1588
|
|
|
1541
1589
|
.mushi-changelog-list li {
|
|
1542
|
-
font-size:
|
|
1543
|
-
color:
|
|
1590
|
+
font-size: 11px;
|
|
1591
|
+
color: ${inkDim};
|
|
1544
1592
|
line-height: 1.5;
|
|
1545
1593
|
}
|
|
1546
1594
|
|
|
@@ -1559,14 +1607,14 @@ function getWidgetStyles(theme) {
|
|
|
1559
1607
|
}
|
|
1560
1608
|
|
|
1561
1609
|
.mushi-beta-success-line {
|
|
1562
|
-
font-size:
|
|
1563
|
-
color:
|
|
1610
|
+
font-size: 12px;
|
|
1611
|
+
color: ${widgetAccentInk};
|
|
1564
1612
|
line-height: 1.5;
|
|
1565
1613
|
}
|
|
1566
1614
|
|
|
1567
1615
|
.mushi-beta-success-dim {
|
|
1568
1616
|
opacity: 0.65;
|
|
1569
|
-
font-size:
|
|
1617
|
+
font-size: 12px;
|
|
1570
1618
|
}
|
|
1571
1619
|
|
|
1572
1620
|
/* \u2500\u2500\u2500 Banner launcher (trigger: 'banner') \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
@@ -1582,7 +1630,7 @@ function getWidgetStyles(theme) {
|
|
|
1582
1630
|
gap: 10px;
|
|
1583
1631
|
padding: 0 16px;
|
|
1584
1632
|
font-family: ${fontMono};
|
|
1585
|
-
font-size:
|
|
1633
|
+
font-size: 12px;
|
|
1586
1634
|
letter-spacing: 0.04em;
|
|
1587
1635
|
white-space: nowrap;
|
|
1588
1636
|
overflow: hidden;
|
|
@@ -1710,7 +1758,7 @@ function getWidgetStyles(theme) {
|
|
|
1710
1758
|
overflow: hidden;
|
|
1711
1759
|
text-overflow: ellipsis;
|
|
1712
1760
|
white-space: nowrap;
|
|
1713
|
-
font-size:
|
|
1761
|
+
font-size: 12px;
|
|
1714
1762
|
font-weight: 500;
|
|
1715
1763
|
line-height: 1.3;
|
|
1716
1764
|
opacity: 0.9;
|
|
@@ -1826,6 +1874,23 @@ function getWidgetStyles(theme) {
|
|
|
1826
1874
|
.mushi-success-stamp-label { opacity: 1; }
|
|
1827
1875
|
.mushi-success-pts-award { opacity: 1; }
|
|
1828
1876
|
}
|
|
1877
|
+
|
|
1878
|
+
.mushi-community-footer{display:flex;align-items:center;gap:8px;padding:10px 0 2px;border-top:1px solid ${isDark ? "rgba(255,255,255,0.07)" : "rgba(0,0,0,0.07)"};margin-top:8px;flex-wrap:wrap}
|
|
1879
|
+
.mushi-community-btn{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
1880
|
+
.mushi-link-btn{background:none;border:none;padding:4px 2px;cursor:pointer;color:${widgetAccent};font-size:12px;font-family:${fontMono};text-decoration:underline;text-underline-offset:2px}
|
|
1881
|
+
.mushi-link-btn:hover{opacity:0.8}
|
|
1882
|
+
.mushi-link-btn:focus-visible,.mushi-nav-item:focus-visible{outline:2px solid ${widgetAccent};outline-offset:2px;border-radius:2px}
|
|
1883
|
+
.mushi-nav-item{display:block;width:100%;text-align:left;background:${isDark ? "rgba(255,255,255,0.05)" : "rgba(0,0,0,0.04)"};border:1px solid ${isDark ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.08)"};border-radius:8px;padding:10px 14px;margin-bottom:8px;cursor:pointer;font-size:13px;color:${ink};transition:background .15s,border-color .15s}
|
|
1884
|
+
.mushi-nav-item:hover{background:${isDark ? "rgba(255,255,255,0.09)" : "rgba(0,0,0,0.07)"}}
|
|
1885
|
+
.mushi-account-card{display:flex;align-items:center;gap:12px;background:${isDark ? "rgba(255,255,255,0.06)" : "rgba(0,0,0,0.04)"};border-radius:10px;padding:12px 14px;margin-bottom:14px}
|
|
1886
|
+
.mushi-account-avatar{width:40px;height:40px;border-radius:50%;background:${widgetAccentWash};color:${widgetAccentInk};display:flex;align-items:center;justify-content:center;font-size:16px;font-weight:700;flex-shrink:0}
|
|
1887
|
+
.mushi-account-info{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
1888
|
+
.mushi-account-info strong{font:700 14px/1.3 inherit;color:${ink}}
|
|
1889
|
+
.mushi-account-rank,.mushi-xapp-app-name,.mushi-label{font-size:12px;color:${inkDim};font-family:${fontMono}}
|
|
1890
|
+
.mushi-account-rank{display:block}
|
|
1891
|
+
.mushi-xapp-app-name{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;margin:0 0 6px}
|
|
1892
|
+
.mushi-xapp-group{margin-bottom:14px}
|
|
1893
|
+
.mushi-label{display:block;font-weight:600;margin-bottom:6px}
|
|
1829
1894
|
`;
|
|
1830
1895
|
}
|
|
1831
1896
|
|
|
@@ -1988,7 +2053,9 @@ var MushiWidget = class _MushiWidget {
|
|
|
1988
2053
|
featureRequestLabel: config.featureRequestLabel ?? "",
|
|
1989
2054
|
featureRequestDescription: config.featureRequestDescription ?? "",
|
|
1990
2055
|
avoidSelectors: config.avoidSelectors ?? [],
|
|
1991
|
-
categories: config.categories ?? []
|
|
2056
|
+
categories: config.categories ?? [],
|
|
2057
|
+
accent: config.accent ?? "",
|
|
2058
|
+
accentText: config.accentText ?? ""
|
|
1992
2059
|
};
|
|
1993
2060
|
this.callbacks = callbacks;
|
|
1994
2061
|
this.locale = getLocale(this.config.locale === "auto" ? void 0 : this.config.locale);
|
|
@@ -2071,6 +2138,26 @@ var MushiWidget = class _MushiWidget {
|
|
|
2071
2138
|
lastSubmitQueuedOffline = false;
|
|
2072
2139
|
/** Whether the user has clicked ✕ on the header banner this session. */
|
|
2073
2140
|
bannerDismissed = false;
|
|
2141
|
+
/** Persisted FAB position when draggable is enabled. */
|
|
2142
|
+
fabPos = null;
|
|
2143
|
+
/** Cleanup fn for visualViewport keyboard listener. */
|
|
2144
|
+
vvCleanup = null;
|
|
2145
|
+
/** Mushi tester session JWT — set after in-widget sign-in or by mushi.ts. */
|
|
2146
|
+
testerJwt = null;
|
|
2147
|
+
/** Tester identity (public_handle, display_name). */
|
|
2148
|
+
testerInfo = null;
|
|
2149
|
+
/** Cross-app reports for the signed-in tester. */
|
|
2150
|
+
crossAppReports = null;
|
|
2151
|
+
crossAppLoading = false;
|
|
2152
|
+
/** Global leaderboard entries (from mushi_testers, not org-scoped). */
|
|
2153
|
+
globalLeaderboard = null;
|
|
2154
|
+
globalLeaderboardLoading = false;
|
|
2155
|
+
/** Reputation for the signed-in tester. */
|
|
2156
|
+
testerReputation = null;
|
|
2157
|
+
/** Whether an in-widget magic-link email was just sent. */
|
|
2158
|
+
magicLinkSent = false;
|
|
2159
|
+
magicLinkEmail = "";
|
|
2160
|
+
magicLinkError = "";
|
|
2074
2161
|
mount() {
|
|
2075
2162
|
if (this.host.isConnected) return;
|
|
2076
2163
|
this.syncHostChromeState();
|
|
@@ -2366,6 +2453,26 @@ var MushiWidget = class _MushiWidget {
|
|
|
2366
2453
|
this.leaderboardLoading = loading;
|
|
2367
2454
|
if (this.isOpen && this.step === "leaderboard") this.render();
|
|
2368
2455
|
}
|
|
2456
|
+
// ── Community public setters (called by mushi.ts after API calls) ──────────
|
|
2457
|
+
setTesterSession(jwt, info) {
|
|
2458
|
+
this.testerJwt = jwt;
|
|
2459
|
+
this.testerInfo = info;
|
|
2460
|
+
if (this.isOpen) this.render();
|
|
2461
|
+
}
|
|
2462
|
+
setGlobalLeaderboard(entries, loading = false) {
|
|
2463
|
+
this.globalLeaderboard = entries;
|
|
2464
|
+
this.globalLeaderboardLoading = loading;
|
|
2465
|
+
if (this.isOpen && (this.step === "leaderboard" || this.step === "account")) this.render();
|
|
2466
|
+
}
|
|
2467
|
+
setCrossAppReports(reports, loading = false) {
|
|
2468
|
+
this.crossAppReports = reports;
|
|
2469
|
+
this.crossAppLoading = loading;
|
|
2470
|
+
if (this.isOpen && this.step === "cross-app-reports") this.render();
|
|
2471
|
+
}
|
|
2472
|
+
setTesterReputation(rep) {
|
|
2473
|
+
this.testerReputation = rep;
|
|
2474
|
+
if (this.isOpen && (this.step === "account" || this.step === "leaderboard")) this.render();
|
|
2475
|
+
}
|
|
2369
2476
|
destroy() {
|
|
2370
2477
|
if (this.successTimer !== null) {
|
|
2371
2478
|
clearTimeout(this.successTimer);
|
|
@@ -2381,6 +2488,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
2381
2488
|
}
|
|
2382
2489
|
this.smartHideCleanup?.();
|
|
2383
2490
|
this.smartHideCleanup = null;
|
|
2491
|
+
this.teardownViewportHandlers();
|
|
2384
2492
|
this.attachedLaunchers.forEach((cleanup) => cleanup());
|
|
2385
2493
|
this.attachedLaunchers = [];
|
|
2386
2494
|
this.removeSelectorHint();
|
|
@@ -2658,7 +2766,25 @@ var MushiWidget = class _MushiWidget {
|
|
|
2658
2766
|
return this.config.hideOnRoutes.some((route) => location.pathname.includes(route));
|
|
2659
2767
|
}
|
|
2660
2768
|
getTheme() {
|
|
2661
|
-
|
|
2769
|
+
const t = this.config.theme;
|
|
2770
|
+
if (t === "light" || t === "dark") return t;
|
|
2771
|
+
if (t === "inherit") {
|
|
2772
|
+
const root = document.documentElement;
|
|
2773
|
+
const colorScheme = root.getAttribute("data-color-scheme") || root.getAttribute("data-theme") || root.getAttribute("color-scheme") || "";
|
|
2774
|
+
if (/dark/i.test(colorScheme)) return "dark";
|
|
2775
|
+
if (/light/i.test(colorScheme)) return "light";
|
|
2776
|
+
if (root.classList.contains("dark")) return "dark";
|
|
2777
|
+
if (root.classList.contains("light")) return "light";
|
|
2778
|
+
try {
|
|
2779
|
+
const bg = getComputedStyle(root).backgroundColor;
|
|
2780
|
+
const m = bg.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
2781
|
+
if (m) {
|
|
2782
|
+
const L = 0.299 * +m[1] + 0.587 * +m[2] + 0.114 * +m[3];
|
|
2783
|
+
return L < 128 ? "dark" : "light";
|
|
2784
|
+
}
|
|
2785
|
+
} catch {
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2662
2788
|
if (typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
2663
2789
|
return "dark";
|
|
2664
2790
|
}
|
|
@@ -2670,7 +2796,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
2670
2796
|
const t = this.locale;
|
|
2671
2797
|
this.shadow.innerHTML = "";
|
|
2672
2798
|
const style = document.createElement("style");
|
|
2673
|
-
style.textContent = getWidgetStyles(theme);
|
|
2799
|
+
style.textContent = getWidgetStyles(theme, this.config.accent ?? "", this.config.accentText ?? "");
|
|
2674
2800
|
this.shadow.appendChild(style);
|
|
2675
2801
|
this.renderBanner();
|
|
2676
2802
|
if (this.shouldRenderTrigger()) {
|
|
@@ -2683,6 +2809,11 @@ var MushiWidget = class _MushiWidget {
|
|
|
2683
2809
|
trigger.setAttribute("aria-expanded", String(this.isOpen));
|
|
2684
2810
|
trigger.style.zIndex = String(this.config.zIndex);
|
|
2685
2811
|
this.applyInsetVars(trigger);
|
|
2812
|
+
if (this.fabPos) {
|
|
2813
|
+
trigger.style.setProperty("--mushi-drag-x", `${this.fabPos.x}px`);
|
|
2814
|
+
trigger.style.setProperty("--mushi-drag-y", `${this.fabPos.y}px`);
|
|
2815
|
+
trigger.style.setProperty("--mushi-drag-active", "1");
|
|
2816
|
+
}
|
|
2686
2817
|
trigger.addEventListener("click", () => {
|
|
2687
2818
|
this.removeNudge();
|
|
2688
2819
|
if (this.isOpen) this.close();
|
|
@@ -2700,6 +2831,29 @@ var MushiWidget = class _MushiWidget {
|
|
|
2700
2831
|
this.nudgeTimer = setTimeout(() => this.removeNudge(), 2e3);
|
|
2701
2832
|
}
|
|
2702
2833
|
});
|
|
2834
|
+
trigger.addEventListener("keydown", (e) => {
|
|
2835
|
+
const draggableConfig = this.config.draggable;
|
|
2836
|
+
if (!draggableConfig) return;
|
|
2837
|
+
const STEP = 8;
|
|
2838
|
+
const axis = typeof draggableConfig === "object" ? draggableConfig.axis ?? "both" : "both";
|
|
2839
|
+
let dx = 0, dy = 0;
|
|
2840
|
+
if (axis !== "y") {
|
|
2841
|
+
if (e.key === "ArrowLeft") dx = -STEP;
|
|
2842
|
+
else if (e.key === "ArrowRight") dx = STEP;
|
|
2843
|
+
}
|
|
2844
|
+
if (axis !== "x") {
|
|
2845
|
+
if (e.key === "ArrowUp") dy = -STEP;
|
|
2846
|
+
else if (e.key === "ArrowDown") dy = STEP;
|
|
2847
|
+
}
|
|
2848
|
+
if (dx !== 0 || dy !== 0) {
|
|
2849
|
+
e.preventDefault();
|
|
2850
|
+
const cur = this.fabPos ?? { x: 0, y: 0 };
|
|
2851
|
+
this.moveFab(trigger, cur.x + dx, cur.y + dy, false);
|
|
2852
|
+
}
|
|
2853
|
+
});
|
|
2854
|
+
if (this.config.draggable) {
|
|
2855
|
+
this.attachDragHandlers(trigger);
|
|
2856
|
+
}
|
|
2703
2857
|
this.shadow.appendChild(trigger);
|
|
2704
2858
|
}
|
|
2705
2859
|
const panel = document.createElement("div");
|
|
@@ -2714,6 +2868,9 @@ var MushiWidget = class _MushiWidget {
|
|
|
2714
2868
|
this.shadow.appendChild(panel);
|
|
2715
2869
|
this.attachHandlers(panel);
|
|
2716
2870
|
this.trapFocus(panel);
|
|
2871
|
+
this.attachViewportHandlers(panel);
|
|
2872
|
+
} else {
|
|
2873
|
+
this.teardownViewportHandlers();
|
|
2717
2874
|
}
|
|
2718
2875
|
}
|
|
2719
2876
|
/**
|
|
@@ -2772,6 +2929,171 @@ var MushiWidget = class _MushiWidget {
|
|
|
2772
2929
|
}
|
|
2773
2930
|
}
|
|
2774
2931
|
}
|
|
2932
|
+
// ─── Draggable FAB ──────────────────────────────────────────────────────────
|
|
2933
|
+
/** Storage key for the FAB position, scoped to projectId when available. */
|
|
2934
|
+
fabStorageKey() {
|
|
2935
|
+
const id = this.config["projectId"] ?? "";
|
|
2936
|
+
return `mushi_fab_pos${id ? `_${id}` : ""}`;
|
|
2937
|
+
}
|
|
2938
|
+
/** Move the FAB to the given translated offset (relative to the inset origin),
|
|
2939
|
+
* clamping inside viewport safe area, and optionally snap to nearest edge.
|
|
2940
|
+
*
|
|
2941
|
+
* The FAB's CSS anchor can be any corner (bottom-right, bottom-left, …) so we
|
|
2942
|
+
* must derive the *base* position (CSS anchor with zero drag offset) to compute
|
|
2943
|
+
* correct clamp bounds and snap targets. We do this by subtracting the
|
|
2944
|
+
* already-applied drag offset from the live getBoundingClientRect() value. */
|
|
2945
|
+
moveFab(trigger, x, y, snap) {
|
|
2946
|
+
const axis = (() => {
|
|
2947
|
+
const d2 = this.config.draggable;
|
|
2948
|
+
if (!d2) return "both";
|
|
2949
|
+
return typeof d2 === "object" ? d2.axis ?? "both" : "both";
|
|
2950
|
+
})();
|
|
2951
|
+
const W = window.innerWidth;
|
|
2952
|
+
const H = window.innerHeight;
|
|
2953
|
+
const btnW = trigger.offsetWidth || 52;
|
|
2954
|
+
const btnH = trigger.offsetHeight || 52;
|
|
2955
|
+
const safeL = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--sai-left") || "0") || 0;
|
|
2956
|
+
const safeR = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--sai-right") || "0") || 0;
|
|
2957
|
+
const safeT = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--sai-top") || "0") || 0;
|
|
2958
|
+
const safeB = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--sai-bottom") || "0") || 0;
|
|
2959
|
+
const margin = 8;
|
|
2960
|
+
const rect = trigger.getBoundingClientRect();
|
|
2961
|
+
const prevDragX = this.fabPos?.x ?? 0;
|
|
2962
|
+
const prevDragY = this.fabPos?.y ?? 0;
|
|
2963
|
+
const baseLeft = rect.left - prevDragX;
|
|
2964
|
+
const baseTop = rect.top - prevDragY;
|
|
2965
|
+
const minX = safeL + margin - baseLeft;
|
|
2966
|
+
const maxX = W - safeR - margin - btnW - baseLeft;
|
|
2967
|
+
const minY = safeT + margin - baseTop;
|
|
2968
|
+
const maxY = H - safeB - margin - btnH - baseTop;
|
|
2969
|
+
const newX = axis === "y" ? 0 : Math.max(minX, Math.min(maxX, x));
|
|
2970
|
+
const newY = axis === "x" ? 0 : Math.max(minY, Math.min(maxY, y));
|
|
2971
|
+
let finalX = newX;
|
|
2972
|
+
if (snap) {
|
|
2973
|
+
const d2 = this.config.draggable;
|
|
2974
|
+
const shouldSnap = d2 === true || typeof d2 === "object" && (d2.snapToEdge ?? true);
|
|
2975
|
+
if (shouldSnap && axis !== "y") {
|
|
2976
|
+
const center = rect.left + btnW / 2;
|
|
2977
|
+
finalX = center < W / 2 ? safeL + margin - baseLeft : W - safeR - margin - btnW - baseLeft;
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
this.fabPos = { x: finalX, y: newY };
|
|
2981
|
+
trigger.style.setProperty("--mushi-drag-x", `${finalX}px`);
|
|
2982
|
+
trigger.style.setProperty("--mushi-drag-y", `${newY}px`);
|
|
2983
|
+
trigger.style.setProperty("--mushi-drag-active", "1");
|
|
2984
|
+
const d = this.config.draggable;
|
|
2985
|
+
const shouldPersist = d === true || typeof d === "object" && (d.persist ?? true);
|
|
2986
|
+
if (shouldPersist) {
|
|
2987
|
+
try {
|
|
2988
|
+
localStorage.setItem(this.fabStorageKey(), JSON.stringify(this.fabPos));
|
|
2989
|
+
} catch {
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
/** Load previously persisted FAB position. */
|
|
2994
|
+
loadFabPos() {
|
|
2995
|
+
const d = this.config.draggable;
|
|
2996
|
+
if (!d) return;
|
|
2997
|
+
const shouldPersist = d === true || typeof d === "object" && (d.persist ?? true);
|
|
2998
|
+
if (!shouldPersist) return;
|
|
2999
|
+
try {
|
|
3000
|
+
const raw = localStorage.getItem(this.fabStorageKey());
|
|
3001
|
+
if (raw) {
|
|
3002
|
+
const parsed = JSON.parse(raw);
|
|
3003
|
+
if (typeof parsed?.x === "number" && typeof parsed?.y === "number") {
|
|
3004
|
+
this.fabPos = parsed;
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
} catch {
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
/** Attach Pointer Events-based drag to the trigger element. */
|
|
3011
|
+
attachDragHandlers(trigger) {
|
|
3012
|
+
if (this.fabPos === null) this.loadFabPos();
|
|
3013
|
+
let startX = 0, startY = 0;
|
|
3014
|
+
let originX = 0, originY = 0;
|
|
3015
|
+
let dragging = false;
|
|
3016
|
+
let moved = false;
|
|
3017
|
+
const onPointerDown = (e) => {
|
|
3018
|
+
if (e.button !== 0 && e.pointerType !== "touch") return;
|
|
3019
|
+
trigger.setPointerCapture(e.pointerId);
|
|
3020
|
+
startX = e.clientX;
|
|
3021
|
+
startY = e.clientY;
|
|
3022
|
+
const cur = this.fabPos ?? { x: 0, y: 0 };
|
|
3023
|
+
originX = cur.x;
|
|
3024
|
+
originY = cur.y;
|
|
3025
|
+
dragging = true;
|
|
3026
|
+
moved = false;
|
|
3027
|
+
};
|
|
3028
|
+
const DRAG_THRESHOLD = 6;
|
|
3029
|
+
const onPointerMove = (e) => {
|
|
3030
|
+
if (!dragging) return;
|
|
3031
|
+
const dx = e.clientX - startX;
|
|
3032
|
+
const dy = e.clientY - startY;
|
|
3033
|
+
if (!moved && Math.hypot(dx, dy) > DRAG_THRESHOLD) {
|
|
3034
|
+
moved = true;
|
|
3035
|
+
trigger.classList.add("dragging");
|
|
3036
|
+
trigger.setAttribute("aria-grabbed", "true");
|
|
3037
|
+
}
|
|
3038
|
+
if (moved) {
|
|
3039
|
+
e.preventDefault();
|
|
3040
|
+
this.moveFab(trigger, originX + dx, originY + dy, false);
|
|
3041
|
+
}
|
|
3042
|
+
};
|
|
3043
|
+
const onPointerUp = (e) => {
|
|
3044
|
+
if (!dragging) return;
|
|
3045
|
+
dragging = false;
|
|
3046
|
+
trigger.classList.remove("dragging");
|
|
3047
|
+
trigger.removeAttribute("aria-grabbed");
|
|
3048
|
+
if (moved) {
|
|
3049
|
+
const dx = e.clientX - startX;
|
|
3050
|
+
const dy = e.clientY - startY;
|
|
3051
|
+
this.moveFab(trigger, originX + dx, originY + dy, true);
|
|
3052
|
+
const suppressClick = (ev) => {
|
|
3053
|
+
ev.stopImmediatePropagation();
|
|
3054
|
+
trigger.removeEventListener("click", suppressClick, { capture: true });
|
|
3055
|
+
};
|
|
3056
|
+
trigger.addEventListener("click", suppressClick, { capture: true });
|
|
3057
|
+
}
|
|
3058
|
+
moved = false;
|
|
3059
|
+
};
|
|
3060
|
+
trigger.addEventListener("pointerdown", onPointerDown);
|
|
3061
|
+
trigger.addEventListener("pointermove", onPointerMove);
|
|
3062
|
+
trigger.addEventListener("pointerup", onPointerUp);
|
|
3063
|
+
trigger.addEventListener("pointercancel", onPointerUp);
|
|
3064
|
+
}
|
|
3065
|
+
// ─── Keyboard / visualViewport ──────────────────────────────────────────────
|
|
3066
|
+
/** Lift the panel above the software keyboard using visualViewport. */
|
|
3067
|
+
attachViewportHandlers(panel) {
|
|
3068
|
+
this.teardownViewportHandlers();
|
|
3069
|
+
const vv = window.visualViewport;
|
|
3070
|
+
if (!vv) return;
|
|
3071
|
+
const update = () => {
|
|
3072
|
+
const keyboardInset = window.innerHeight - vv.height - vv.offsetTop;
|
|
3073
|
+
if (keyboardInset > 50) {
|
|
3074
|
+
panel.style.setProperty("--mushi-keyboard-inset", `${Math.round(keyboardInset)}px`);
|
|
3075
|
+
panel.classList.add("keyboard-open");
|
|
3076
|
+
const ta = panel.querySelector('textarea, input[type="text"]');
|
|
3077
|
+
ta?.scrollIntoView({ block: "nearest", behavior: "smooth" });
|
|
3078
|
+
} else {
|
|
3079
|
+
panel.style.setProperty("--mushi-keyboard-inset", "0px");
|
|
3080
|
+
panel.classList.remove("keyboard-open");
|
|
3081
|
+
}
|
|
3082
|
+
};
|
|
3083
|
+
vv.addEventListener("resize", update, { passive: true });
|
|
3084
|
+
vv.addEventListener("scroll", update, { passive: true });
|
|
3085
|
+
const onFocus = () => requestAnimationFrame(update);
|
|
3086
|
+
panel.addEventListener("focusin", onFocus);
|
|
3087
|
+
this.vvCleanup = () => {
|
|
3088
|
+
vv.removeEventListener("resize", update);
|
|
3089
|
+
vv.removeEventListener("scroll", update);
|
|
3090
|
+
panel.removeEventListener("focusin", onFocus);
|
|
3091
|
+
};
|
|
3092
|
+
}
|
|
3093
|
+
teardownViewportHandlers() {
|
|
3094
|
+
this.vvCleanup?.();
|
|
3095
|
+
this.vvCleanup = null;
|
|
3096
|
+
}
|
|
2775
3097
|
renderStep() {
|
|
2776
3098
|
switch (this.step) {
|
|
2777
3099
|
case "category":
|
|
@@ -2790,6 +3112,10 @@ var MushiWidget = class _MushiWidget {
|
|
|
2790
3112
|
return this.renderLeaderboardStep();
|
|
2791
3113
|
case "roadmap":
|
|
2792
3114
|
return this.renderRoadmapStep();
|
|
3115
|
+
case "account":
|
|
3116
|
+
return this.renderAccountStep();
|
|
3117
|
+
case "cross-app-reports":
|
|
3118
|
+
return this.renderCrossAppReportsStep();
|
|
2793
3119
|
}
|
|
2794
3120
|
}
|
|
2795
3121
|
renderOutdatedBanner() {
|
|
@@ -2899,6 +3225,12 @@ var MushiWidget = class _MushiWidget {
|
|
|
2899
3225
|
</button>` : ""}
|
|
2900
3226
|
${categories}
|
|
2901
3227
|
${this.rewardsState ? this.renderRewardsNudge() : ""}
|
|
3228
|
+
<div class="mushi-community-footer">
|
|
3229
|
+
<button type="button" class="mushi-link-btn mushi-community-btn" data-action="open-account">
|
|
3230
|
+
${this.testerInfo ? `\u{1F464} ${escapeHtml(this.testerInfo.public_handle ?? this.testerInfo.display_name ?? "My account")}` : "\u{1F310} Join community \xB7 Track reports across apps"}
|
|
3231
|
+
</button>
|
|
3232
|
+
${this.rewardsState ? `<button type="button" class="mushi-link-btn" data-action="open-leaderboard">\u{1F3C6} Leaderboard</button>` : ""}
|
|
3233
|
+
</div>
|
|
2902
3234
|
</div>
|
|
2903
3235
|
${this.renderStepIndicator(STEP_NUMBER.category)}
|
|
2904
3236
|
`;
|
|
@@ -3040,23 +3372,126 @@ var MushiWidget = class _MushiWidget {
|
|
|
3040
3372
|
`;
|
|
3041
3373
|
}
|
|
3042
3374
|
renderLeaderboardStep() {
|
|
3043
|
-
const
|
|
3044
|
-
const
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3375
|
+
const isGlobal = this.globalLeaderboard !== null || this.globalLeaderboardLoading;
|
|
3376
|
+
const entries = isGlobal ? this.globalLeaderboard ?? [] : (this.leaderboardEntries ?? []).map((e) => ({
|
|
3377
|
+
tester_id: "",
|
|
3378
|
+
public_handle: null,
|
|
3379
|
+
display_name: e.display_name,
|
|
3380
|
+
rank: 0,
|
|
3381
|
+
points_30d: e.points_30d,
|
|
3382
|
+
total_points: e.total_points
|
|
3383
|
+
}));
|
|
3384
|
+
const loading = isGlobal ? this.globalLeaderboardLoading : this.leaderboardLoading;
|
|
3385
|
+
const myRank = this.testerReputation?.rank ?? null;
|
|
3386
|
+
const rows = entries.map((e, i) => {
|
|
3387
|
+
const rank = e.rank || i + 1;
|
|
3388
|
+
const isMe = this.testerReputation && e.tester_id === this.testerReputation.tester_id;
|
|
3389
|
+
return `
|
|
3390
|
+
<div class="mushi-lb-row ${rank === 1 ? "mushi-lb-top" : ""}${isMe ? " mushi-lb-me" : ""}">
|
|
3391
|
+
<span class="mushi-lb-rank">#${rank}</span>
|
|
3392
|
+
<span class="mushi-lb-name">${escapeHtml(e.public_handle ?? e.display_name ?? "Anon")}</span>
|
|
3393
|
+
<span class="mushi-lb-pts">${(e.points_30d ?? e.total_points).toLocaleString()} pts</span>
|
|
3394
|
+
</div>
|
|
3395
|
+
`;
|
|
3396
|
+
}).join("");
|
|
3397
|
+
const myRankBadge = myRank ? `<div class="mushi-lb-myrank">You are ranked <strong>#${myRank}</strong> this month</div>` : !this.testerJwt ? `<button type="button" class="mushi-link-btn" data-action="open-account">Sign in to see your rank \u2192</button>` : "";
|
|
3398
|
+
return `
|
|
3399
|
+
${this.renderHeader({ title: "\u{1F3C6} Global Leaderboard", showBack: true, eyebrow: "Mushi \xB7 Community" })}
|
|
3400
|
+
<div class="mushi-body">
|
|
3401
|
+
${loading ? '<p class="mushi-muted">Loading leaderboard\u2026</p>' : ""}
|
|
3402
|
+
${!loading && !entries.length ? '<p class="mushi-muted">No contributors yet \u2014 be the first!</p>' : ""}
|
|
3403
|
+
<div class="mushi-lb-list">${rows}</div>
|
|
3404
|
+
${myRankBadge}
|
|
3405
|
+
<p class="mushi-lb-note">Global contributors this month \xB7 Points refresh monthly</p>
|
|
3406
|
+
</div>
|
|
3407
|
+
`;
|
|
3408
|
+
}
|
|
3409
|
+
renderAccountStep() {
|
|
3410
|
+
const tester = this.testerInfo;
|
|
3411
|
+
if (tester) {
|
|
3412
|
+
const handle = tester.public_handle ?? tester.display_name ?? "Tester";
|
|
3413
|
+
const rep = this.testerReputation;
|
|
3414
|
+
return `
|
|
3415
|
+
${this.renderHeader({ title: "\u866B Mushi Account", showBack: true, eyebrow: "Mushi \xB7 Identity" })}
|
|
3416
|
+
<div class="mushi-body">
|
|
3417
|
+
<div class="mushi-account-card">
|
|
3418
|
+
<div class="mushi-account-avatar">${escapeHtml(handle.charAt(0).toUpperCase())}</div>
|
|
3419
|
+
<div class="mushi-account-info">
|
|
3420
|
+
<strong>${escapeHtml(handle)}</strong>
|
|
3421
|
+
${rep ? `<span class="mushi-account-rank">Rank #${rep.rank ?? "\u2014"} \xB7 ${(rep.points_30d ?? 0).toLocaleString()} pts this month</span>` : ""}
|
|
3422
|
+
</div>
|
|
3423
|
+
</div>
|
|
3424
|
+
<button type="button" class="mushi-nav-item" data-action="open-cross-app-reports">
|
|
3425
|
+
My reports across all apps \u2192
|
|
3426
|
+
</button>
|
|
3427
|
+
<button type="button" class="mushi-nav-item" data-action="open-global-leaderboard">
|
|
3428
|
+
View global leaderboard \u2192
|
|
3429
|
+
</button>
|
|
3430
|
+
<button type="button" class="mushi-link-btn" data-action="sign-out-tester">Sign out</button>
|
|
3431
|
+
</div>
|
|
3432
|
+
`;
|
|
3433
|
+
}
|
|
3434
|
+
if (this.magicLinkSent) {
|
|
3435
|
+
return `
|
|
3436
|
+
${this.renderHeader({ title: "\u866B Check your email", showBack: true, eyebrow: "Mushi \xB7 Sign in" })}
|
|
3437
|
+
<div class="mushi-body">
|
|
3438
|
+
<p class="mushi-muted">We sent a sign-in link to <strong>${escapeHtml(this.magicLinkEmail)}</strong>. Click it to connect your reports across apps and join the community.</p>
|
|
3439
|
+
<button type="button" class="mushi-link-btn" data-action="resend-magic-link">Resend email</button>
|
|
3440
|
+
${this.magicLinkError ? `<p class="mushi-error">${escapeHtml(this.magicLinkError)}</p>` : ""}
|
|
3441
|
+
</div>
|
|
3442
|
+
`;
|
|
3443
|
+
}
|
|
3444
|
+
return `
|
|
3445
|
+
${this.renderHeader({ title: "\u866B Join the community", showBack: true, eyebrow: "Mushi \xB7 Sign in" })}
|
|
3446
|
+
<div class="mushi-body">
|
|
3447
|
+
<p class="mushi-muted">Sign in to see your reports across all apps and climb the global leaderboard. No password needed.</p>
|
|
3448
|
+
<label class="mushi-label" for="mushi-email-input">Email address</label>
|
|
3449
|
+
<input
|
|
3450
|
+
id="mushi-email-input"
|
|
3451
|
+
type="email"
|
|
3452
|
+
class="mushi-textarea"
|
|
3453
|
+
data-role="magic-link-email"
|
|
3454
|
+
placeholder="you@example.com"
|
|
3455
|
+
autocomplete="email"
|
|
3456
|
+
value="${escapeHtml(this.magicLinkEmail)}"
|
|
3457
|
+
style="padding: 10px 12px; height: auto; resize: none;"
|
|
3458
|
+
/>
|
|
3459
|
+
${this.magicLinkError ? `<p class="mushi-error">${escapeHtml(this.magicLinkError)}</p>` : ""}
|
|
3460
|
+
<button type="button" class="mushi-submit" data-action="send-magic-link">
|
|
3461
|
+
<span>Send sign-in link</span><span class="mushi-submit-arrow" aria-hidden="true">\u2192</span>
|
|
3462
|
+
</button>
|
|
3463
|
+
</div>
|
|
3464
|
+
`;
|
|
3465
|
+
}
|
|
3466
|
+
renderCrossAppReportsStep() {
|
|
3467
|
+
const reports = this.crossAppReports ?? [];
|
|
3468
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
3469
|
+
for (const r of reports) {
|
|
3470
|
+
const key = r.project_id ?? "unknown";
|
|
3471
|
+
if (!grouped.has(key)) grouped.set(key, { name: r.app_name ?? "Unknown App", reports: [] });
|
|
3472
|
+
grouped.get(key).reports.push(r);
|
|
3473
|
+
}
|
|
3474
|
+
const rows = [...grouped.entries()].map(([, group]) => `
|
|
3475
|
+
<div class="mushi-xapp-group">
|
|
3476
|
+
<h4 class="mushi-xapp-app-name">${escapeHtml(group.name)}</h4>
|
|
3477
|
+
${group.reports.map((r) => {
|
|
3478
|
+
const tone = reporterStatusTone(r.status);
|
|
3479
|
+
return `
|
|
3480
|
+
<div class="mushi-report-row" data-report-id="${escapeHtml(r.id)}" tabindex="0" role="button">
|
|
3481
|
+
<span class="mushi-report-status mushi-status-${tone}">${escapeHtml(reporterStatusShort(r.status))}</span>
|
|
3482
|
+
<span class="mushi-report-title">${escapeHtml(r.title ?? r.category)}</span>
|
|
3483
|
+
<span class="mushi-report-when">${escapeHtml(formatRelativeTime(r.created_at))}</span>
|
|
3484
|
+
</div>
|
|
3485
|
+
`;
|
|
3486
|
+
}).join("")}
|
|
3050
3487
|
</div>
|
|
3051
3488
|
`).join("");
|
|
3052
3489
|
return `
|
|
3053
|
-
${this.renderHeader({ title: "
|
|
3490
|
+
${this.renderHeader({ title: "My reports", showBack: true, eyebrow: "Mushi \xB7 All apps" })}
|
|
3054
3491
|
<div class="mushi-body">
|
|
3055
|
-
${this.
|
|
3056
|
-
${!this.
|
|
3057
|
-
|
|
3058
|
-
${myRank > 0 ? `<p class="mushi-lb-myrank">You are ranked #${myRank}</p>` : ""}
|
|
3059
|
-
<p class="mushi-lb-note">Top contributors this month \xB7 Points refresh monthly</p>
|
|
3492
|
+
${this.crossAppLoading ? '<p class="mushi-muted">Loading your reports\u2026</p>' : ""}
|
|
3493
|
+
${!this.crossAppLoading && !reports.length ? '<p class="mushi-muted">No reports filed yet.</p>' : ""}
|
|
3494
|
+
${rows}
|
|
3060
3495
|
</div>
|
|
3061
3496
|
`;
|
|
3062
3497
|
}
|
|
@@ -3431,6 +3866,41 @@ var MushiWidget = class _MushiWidget {
|
|
|
3431
3866
|
panel.querySelector('[data-action="open-leaderboard"]')?.addEventListener("click", () => {
|
|
3432
3867
|
this.step = "leaderboard";
|
|
3433
3868
|
this.callbacks.onLeaderboardOpen?.();
|
|
3869
|
+
this.callbacks.onGlobalLeaderboardOpen?.();
|
|
3870
|
+
this.render();
|
|
3871
|
+
});
|
|
3872
|
+
panel.querySelector('[data-action="open-account"]')?.addEventListener("click", () => {
|
|
3873
|
+
this.step = "account";
|
|
3874
|
+
this.render();
|
|
3875
|
+
});
|
|
3876
|
+
panel.querySelector('[data-action="open-cross-app-reports"]')?.addEventListener("click", () => {
|
|
3877
|
+
this.step = "cross-app-reports";
|
|
3878
|
+
this.crossAppLoading = true;
|
|
3879
|
+
this.crossAppReports = null;
|
|
3880
|
+
this.render();
|
|
3881
|
+
this.callbacks.onCrossAppReportsOpen?.();
|
|
3882
|
+
});
|
|
3883
|
+
panel.querySelector('[data-action="open-global-leaderboard"]')?.addEventListener("click", () => {
|
|
3884
|
+
this.step = "leaderboard";
|
|
3885
|
+
this.callbacks.onGlobalLeaderboardOpen?.();
|
|
3886
|
+
this.render();
|
|
3887
|
+
});
|
|
3888
|
+
panel.querySelector('[data-action="send-magic-link"]')?.addEventListener("click", () => {
|
|
3889
|
+
void this.handleMagicLinkSend(panel);
|
|
3890
|
+
});
|
|
3891
|
+
panel.querySelector('[data-action="resend-magic-link"]')?.addEventListener("click", () => {
|
|
3892
|
+
this.magicLinkSent = false;
|
|
3893
|
+
this.magicLinkError = "";
|
|
3894
|
+
this.render();
|
|
3895
|
+
});
|
|
3896
|
+
panel.querySelector('[data-action="sign-out-tester"]')?.addEventListener("click", () => {
|
|
3897
|
+
this.testerJwt = null;
|
|
3898
|
+
this.testerInfo = null;
|
|
3899
|
+
this.testerReputation = null;
|
|
3900
|
+
this.crossAppReports = null;
|
|
3901
|
+
this.magicLinkSent = false;
|
|
3902
|
+
this.magicLinkEmail = "";
|
|
3903
|
+
this.step = "category";
|
|
3434
3904
|
this.render();
|
|
3435
3905
|
});
|
|
3436
3906
|
panel.querySelector('[data-action="reporter-reply"]')?.addEventListener("click", () => {
|
|
@@ -3716,6 +4186,27 @@ var MushiWidget = class _MushiWidget {
|
|
|
3716
4186
|
this.render();
|
|
3717
4187
|
}
|
|
3718
4188
|
}
|
|
4189
|
+
/* ── Community: magic-link sign-in ───────────────────────────────── */
|
|
4190
|
+
async handleMagicLinkSend(panel) {
|
|
4191
|
+
const emailInput = panel.querySelector('[data-role="magic-link-email"]');
|
|
4192
|
+
const email = (emailInput?.value ?? this.magicLinkEmail).trim();
|
|
4193
|
+
if (!email || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
|
4194
|
+
this.magicLinkError = "Please enter a valid email address.";
|
|
4195
|
+
this.render();
|
|
4196
|
+
return;
|
|
4197
|
+
}
|
|
4198
|
+
this.magicLinkEmail = email;
|
|
4199
|
+
this.magicLinkError = "";
|
|
4200
|
+
this.render();
|
|
4201
|
+
try {
|
|
4202
|
+
await this.callbacks.onMushiSignIn?.(email);
|
|
4203
|
+
this.magicLinkSent = true;
|
|
4204
|
+
this.render();
|
|
4205
|
+
} catch (err) {
|
|
4206
|
+
this.magicLinkError = err instanceof Error ? err.message : "Could not send sign-in link. Try again.";
|
|
4207
|
+
this.render();
|
|
4208
|
+
}
|
|
4209
|
+
}
|
|
3719
4210
|
/* ── Marketing / Playwright recorder (debug GIF capture) ─────────── */
|
|
3720
4211
|
getRecorderStep() {
|
|
3721
4212
|
return this.step;
|
|
@@ -5800,7 +6291,7 @@ function createProactiveManager(config = {}) {
|
|
|
5800
6291
|
|
|
5801
6292
|
// src/version.ts
|
|
5802
6293
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
5803
|
-
var MUSHI_SDK_VERSION = "1.
|
|
6294
|
+
var MUSHI_SDK_VERSION = "1.14.0" ;
|
|
5804
6295
|
|
|
5805
6296
|
// src/mushi.ts
|
|
5806
6297
|
var instance = null;
|
|
@@ -5882,6 +6373,42 @@ function createInstance(config) {
|
|
|
5882
6373
|
let replayCap = null;
|
|
5883
6374
|
let replayGeneration = 0;
|
|
5884
6375
|
let widget;
|
|
6376
|
+
const TESTER_JWT_KEY = `mushi:tester-jwt:${bootstrapConfig.projectId}`;
|
|
6377
|
+
function readTesterJwt() {
|
|
6378
|
+
try {
|
|
6379
|
+
return typeof localStorage !== "undefined" ? localStorage.getItem(TESTER_JWT_KEY) : null;
|
|
6380
|
+
} catch {
|
|
6381
|
+
return null;
|
|
6382
|
+
}
|
|
6383
|
+
}
|
|
6384
|
+
function clearTesterJwt() {
|
|
6385
|
+
try {
|
|
6386
|
+
if (typeof localStorage !== "undefined") localStorage.removeItem(TESTER_JWT_KEY);
|
|
6387
|
+
} catch {
|
|
6388
|
+
}
|
|
6389
|
+
}
|
|
6390
|
+
async function loadTesterSession(jwt) {
|
|
6391
|
+
const statusResult = await apiClient2.getTesterStatus(jwt);
|
|
6392
|
+
if (!statusResult.ok || !statusResult.data) {
|
|
6393
|
+
clearTesterJwt();
|
|
6394
|
+
return;
|
|
6395
|
+
}
|
|
6396
|
+
const status = statusResult.data;
|
|
6397
|
+
if (!status.is_tester) {
|
|
6398
|
+
clearTesterJwt();
|
|
6399
|
+
return;
|
|
6400
|
+
}
|
|
6401
|
+
widget.setTesterSession(jwt, {
|
|
6402
|
+
id: jwt.substring(0, 16),
|
|
6403
|
+
public_handle: status.public_handle ?? null,
|
|
6404
|
+
display_name: status.display_name ?? null
|
|
6405
|
+
});
|
|
6406
|
+
const repResult = await apiClient2.getMyReputation(jwt);
|
|
6407
|
+
if (repResult.ok && repResult.data) {
|
|
6408
|
+
const repData = repResult.data;
|
|
6409
|
+
if (repData.reputation) widget.setTesterReputation(repData.reputation);
|
|
6410
|
+
}
|
|
6411
|
+
}
|
|
5885
6412
|
function syncCaptureModules() {
|
|
5886
6413
|
if (activeConfig.capture?.console !== false) {
|
|
5887
6414
|
consoleCap ??= createConsoleCapture();
|
|
@@ -6175,6 +6702,45 @@ function createInstance(config) {
|
|
|
6175
6702
|
void fetchLeaderboard(10).then((entries) => {
|
|
6176
6703
|
widget.setLeaderboard(entries, false);
|
|
6177
6704
|
});
|
|
6705
|
+
},
|
|
6706
|
+
// ── Community callbacks ──────────────────────────────────────────────
|
|
6707
|
+
async onMushiSignIn(email) {
|
|
6708
|
+
const res = await apiClient2.sendMagicLink(email);
|
|
6709
|
+
if (!res.ok) throw new Error(res.error?.message ?? "Could not send sign-in link");
|
|
6710
|
+
return { ok: true };
|
|
6711
|
+
},
|
|
6712
|
+
async onGlobalLeaderboardOpen() {
|
|
6713
|
+
widget.setGlobalLeaderboard(null, true);
|
|
6714
|
+
const jwt = readTesterJwt();
|
|
6715
|
+
const res = await apiClient2.getPublicLeaderboard(50);
|
|
6716
|
+
const rawEntries = res.ok ? res.data?.leaderboard ?? [] : [];
|
|
6717
|
+
const entries = rawEntries.map((e) => ({
|
|
6718
|
+
tester_id: e.tester_id,
|
|
6719
|
+
rank: e.rank,
|
|
6720
|
+
public_handle: e.public_handle,
|
|
6721
|
+
display_name: e.display_name,
|
|
6722
|
+
points_30d: e.points_30d,
|
|
6723
|
+
total_points: e.total_points ?? 0,
|
|
6724
|
+
badge: e.badge_slug
|
|
6725
|
+
}));
|
|
6726
|
+
widget.setGlobalLeaderboard(entries, false);
|
|
6727
|
+
if (jwt) {
|
|
6728
|
+
const repRes = await apiClient2.getMyReputation(jwt);
|
|
6729
|
+
if (repRes.ok && repRes.data) {
|
|
6730
|
+
const repData = repRes.data;
|
|
6731
|
+
if (repData.reputation) widget.setTesterReputation(repData.reputation);
|
|
6732
|
+
}
|
|
6733
|
+
}
|
|
6734
|
+
},
|
|
6735
|
+
async onCrossAppReportsOpen() {
|
|
6736
|
+
const jwt = readTesterJwt();
|
|
6737
|
+
if (!jwt) {
|
|
6738
|
+
widget.setCrossAppReports([], false);
|
|
6739
|
+
return;
|
|
6740
|
+
}
|
|
6741
|
+
const res = await apiClient2.getCrossAppReports(jwt);
|
|
6742
|
+
const reports = res.ok ? res.data?.reports ?? [] : [];
|
|
6743
|
+
widget.setCrossAppReports(reports, false);
|
|
6178
6744
|
}
|
|
6179
6745
|
}, MUSHI_SDK_VERSION);
|
|
6180
6746
|
syncCaptureModules();
|
|
@@ -6185,6 +6751,10 @@ function createInstance(config) {
|
|
|
6185
6751
|
widget.mount();
|
|
6186
6752
|
}
|
|
6187
6753
|
}
|
|
6754
|
+
const cachedJwt = readTesterJwt();
|
|
6755
|
+
if (cachedJwt) {
|
|
6756
|
+
void loadTesterSession(cachedJwt).catch(() => clearTesterJwt());
|
|
6757
|
+
}
|
|
6188
6758
|
let proactiveTriggers = null;
|
|
6189
6759
|
let proactiveManager = null;
|
|
6190
6760
|
const proactiveCfg = activeConfig.proactive;
|