@mushi-mushi/web 1.14.1 → 1.17.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/CONTRIBUTING.md +50 -9
- package/README.md +4 -1
- package/dist/index.cjs +403 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -4
- package/dist/index.d.ts +41 -4
- package/dist/index.js +404 -68
- package/dist/index.js.map +1 -1
- package/dist/mushi.loader.global.js +2172 -0
- package/dist/mushi.loader.global.js.map +1 -0
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -481,8 +481,8 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
481
481
|
|
|
482
482
|
@keyframes mushi-pulse {
|
|
483
483
|
0% { box-shadow: 0 0 0 0 ${widgetAccent}; opacity: 1; }
|
|
484
|
-
70% { box-shadow: 0 0 0 8px
|
|
485
|
-
100% { box-shadow: 0 0 0 0
|
|
484
|
+
70% { box-shadow: 0 0 0 8px ${widgetAccent}00; opacity: 0.5; }
|
|
485
|
+
100% { box-shadow: 0 0 0 0 ${widgetAccent}00; opacity: 1; }
|
|
486
486
|
}
|
|
487
487
|
|
|
488
488
|
.mushi-panel {
|
|
@@ -1370,6 +1370,20 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1370
1370
|
.mushi-success-receipt-warn {
|
|
1371
1371
|
color: ${widgetAccent};
|
|
1372
1372
|
}
|
|
1373
|
+
.mushi-success-my-reports {
|
|
1374
|
+
display: block;
|
|
1375
|
+
margin: 12px auto 0;
|
|
1376
|
+
font-size: 12px;
|
|
1377
|
+
font-family: ${fontMono};
|
|
1378
|
+
color: ${widgetAccent};
|
|
1379
|
+
text-decoration: underline;
|
|
1380
|
+
text-underline-offset: 2px;
|
|
1381
|
+
background: none;
|
|
1382
|
+
border: none;
|
|
1383
|
+
cursor: pointer;
|
|
1384
|
+
padding: 4px 2px;
|
|
1385
|
+
}
|
|
1386
|
+
.mushi-success-my-reports:hover { opacity: 0.75; }
|
|
1373
1387
|
.mushi-success-sla {
|
|
1374
1388
|
margin-top: 2px;
|
|
1375
1389
|
font-family: ${fontDisplay};
|
|
@@ -1628,12 +1642,18 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1628
1642
|
position: fixed;
|
|
1629
1643
|
left: 0;
|
|
1630
1644
|
right: 0;
|
|
1631
|
-
height
|
|
1645
|
+
/* min-height (not fixed height) + border-box so the safe-area padding
|
|
1646
|
+
below extends the bar into the notch/home-indicator zone instead of
|
|
1647
|
+
letting content bleed under the status bar (mobile safe-area bleed
|
|
1648
|
+
fix \u2014 Workstream C). Horizontal padding also clears the left/right
|
|
1649
|
+
insets for landscape notches. */
|
|
1650
|
+
box-sizing: border-box;
|
|
1651
|
+
min-height: 36px;
|
|
1632
1652
|
display: flex;
|
|
1633
1653
|
align-items: center;
|
|
1634
1654
|
justify-content: center;
|
|
1635
1655
|
gap: 10px;
|
|
1636
|
-
padding: 0 16px;
|
|
1656
|
+
padding: 0 calc(16px + env(safe-area-inset-right, 0px)) 0 calc(16px + env(safe-area-inset-left, 0px));
|
|
1637
1657
|
font-family: ${fontMono};
|
|
1638
1658
|
font-size: 12px;
|
|
1639
1659
|
letter-spacing: 0.04em;
|
|
@@ -1643,8 +1663,8 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1643
1663
|
animation: mushi-banner-slide-in 0.3s ${easeStamp} both;
|
|
1644
1664
|
}
|
|
1645
1665
|
|
|
1646
|
-
.mushi-banner.top { top: 0; }
|
|
1647
|
-
.mushi-banner.bottom { bottom: 0; }
|
|
1666
|
+
.mushi-banner.top { top: 0; padding-top: env(safe-area-inset-top, 0px); }
|
|
1667
|
+
.mushi-banner.bottom { bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
|
|
1648
1668
|
|
|
1649
1669
|
/* --- neon variant (electric lime \u2014 dev / beta tool aesthetic) --- */
|
|
1650
1670
|
.mushi-banner.neon {
|
|
@@ -1855,6 +1875,28 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1855
1875
|
}
|
|
1856
1876
|
.mushi-banner.neon .mushi-banner-dismiss:hover { background: rgba(0,0,0,0.18) !important; }
|
|
1857
1877
|
|
|
1878
|
+
/* "My reports" link in the simple (non-rich) banner layout */
|
|
1879
|
+
.mushi-banner-my-reports {
|
|
1880
|
+
background: transparent;
|
|
1881
|
+
border: none;
|
|
1882
|
+
cursor: pointer;
|
|
1883
|
+
font-size: 11px;
|
|
1884
|
+
font-family: ${fontMono};
|
|
1885
|
+
opacity: 0.75;
|
|
1886
|
+
color: inherit;
|
|
1887
|
+
padding: 2px 6px;
|
|
1888
|
+
border-radius: 3px;
|
|
1889
|
+
white-space: nowrap;
|
|
1890
|
+
flex-shrink: 0;
|
|
1891
|
+
transition: opacity 0.15s, background 0.15s;
|
|
1892
|
+
margin-left: 4px;
|
|
1893
|
+
}
|
|
1894
|
+
.mushi-banner-my-reports:hover {
|
|
1895
|
+
opacity: 1;
|
|
1896
|
+
background: rgba(0,0,0,0.10);
|
|
1897
|
+
}
|
|
1898
|
+
.mushi-banner.neon .mushi-banner-my-reports:hover { background: rgba(0,0,0,0.18); }
|
|
1899
|
+
|
|
1858
1900
|
@keyframes mushi-banner-slide-in {
|
|
1859
1901
|
from { transform: translateY(calc(-1 * 100%)); opacity: 0.5; }
|
|
1860
1902
|
to { transform: translateY(0); opacity: 1; }
|
|
@@ -1896,12 +1938,33 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1896
1938
|
.mushi-xapp-app-name{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;margin:0 0 6px}
|
|
1897
1939
|
.mushi-xapp-group{margin-bottom:14px}
|
|
1898
1940
|
.mushi-label{display:block;font-weight:600;margin-bottom:6px}
|
|
1941
|
+
|
|
1942
|
+
/* \u2500\u2500 Assistant tab (P5) \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 */
|
|
1943
|
+
.mushi-assistant{display:flex;flex-direction:column;height:100%;min-height:0;max-height:60vh}
|
|
1944
|
+
.mushi-assistant-log{flex:1;min-height:120px;overflow-y:auto;display:flex;flex-direction:column;gap:8px;padding:4px 2px 8px}
|
|
1945
|
+
.mushi-assistant-greeting{font:400 14px/1.5 ${fontBody};color:${inkMuted};padding:6px 2px}
|
|
1946
|
+
.mushi-assistant-suggestions{display:flex;flex-wrap:wrap;gap:6px;margin-top:4px}
|
|
1947
|
+
.mushi-assistant-chip{background:${widgetAccentWash};color:${widgetAccentInk};border:1px solid ${ruleStrong};border-radius:999px;padding:5px 12px;font-size:12px;cursor:pointer;font-family:${fontBody};transition:background .15s}
|
|
1948
|
+
.mushi-assistant-chip:hover{background:${isDark ? "rgba(255,90,71,0.22)" : "rgba(224,60,44,0.14)"}}
|
|
1949
|
+
.mushi-assistant-chip:focus-visible{outline:2px solid ${widgetAccent};outline-offset:2px}
|
|
1950
|
+
.mushi-assistant-msg{max-width:85%;padding:8px 12px;border-radius:12px;font:400 14px/1.45 ${fontBody};white-space:pre-wrap;word-break:break-word}
|
|
1951
|
+
.mushi-assistant-msg-user{align-self:flex-end;background:${widgetAccent};color:#fff;border-bottom-right-radius:4px}
|
|
1952
|
+
.mushi-assistant-msg-bot{align-self:flex-start;background:${isDark ? "rgba(255,255,255,0.06)" : "rgba(0,0,0,0.05)"};color:${ink};border-bottom-left-radius:4px}
|
|
1953
|
+
.mushi-assistant-thinking{opacity:0.6;font-size:18px;letter-spacing:2px}
|
|
1954
|
+
.mushi-assistant-error{align-self:flex-start;color:${isDark ? "#F87171" : "#DC2626"};font-size:12px;padding:4px 2px}
|
|
1955
|
+
.mushi-assistant-form{display:flex;align-items:flex-end;gap:8px;border-top:1px solid ${rule};padding-top:8px}
|
|
1956
|
+
.mushi-assistant-input{flex:1;resize:none;max-height:120px;border:1px solid ${ruleStrong};border-radius:10px;padding:8px 12px;font:400 14px/1.4 ${fontBody};background:${paper};color:${ink}}
|
|
1957
|
+
.mushi-assistant-input:focus-visible{outline:2px solid ${widgetAccent};outline-offset:1px}
|
|
1958
|
+
.mushi-assistant-submit{flex-shrink:0;width:36px;height:36px;border:none;border-radius:50%;background:${widgetAccent};color:#fff;font-size:18px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:transform .15s,opacity .15s}
|
|
1959
|
+
.mushi-assistant-submit:hover{transform:translateY(-1px)}
|
|
1960
|
+
.mushi-assistant-submit:disabled{opacity:0.5;cursor:default;transform:none}
|
|
1961
|
+
.mushi-assistant-submit:focus-visible{outline:2px solid ${widgetAccent};outline-offset:2px}
|
|
1899
1962
|
`;
|
|
1900
1963
|
}
|
|
1901
1964
|
|
|
1902
1965
|
// src/version.ts
|
|
1903
1966
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
1904
|
-
var MUSHI_SDK_VERSION = "1.
|
|
1967
|
+
var MUSHI_SDK_VERSION = "1.17.0" ;
|
|
1905
1968
|
|
|
1906
1969
|
// src/widget-helpers.ts
|
|
1907
1970
|
var CATEGORY_ICONS = {
|
|
@@ -2047,8 +2110,43 @@ function renderStep(ctx) {
|
|
|
2047
2110
|
return renderAccountStep(ctx);
|
|
2048
2111
|
case "cross-app-reports":
|
|
2049
2112
|
return renderCrossAppReportsStep(ctx);
|
|
2113
|
+
case "assistant":
|
|
2114
|
+
return renderAssistantStep(ctx);
|
|
2050
2115
|
}
|
|
2051
2116
|
}
|
|
2117
|
+
function renderAssistantStep(ctx) {
|
|
2118
|
+
const label = ctx.callbacks.assistantLabel || "Ask";
|
|
2119
|
+
const greeting = ctx.callbacks.assistantGreeting || "Ask me anything about this app.";
|
|
2120
|
+
const suggestions = ctx.callbacks.assistantSuggestions ?? [];
|
|
2121
|
+
const empty = ctx.assistantTurns.length === 0;
|
|
2122
|
+
const transcript = empty ? `<div class="mushi-assistant-greeting">${escapeHtml(greeting)}</div>
|
|
2123
|
+
${suggestions.length ? `<div class="mushi-assistant-suggestions">${suggestions.map((s) => `<button type="button" class="mushi-assistant-chip" data-action="assistant-suggest" data-value="${escapeHtml(s)}">${escapeHtml(s)}</button>`).join("")}</div>` : ""}` : ctx.assistantTurns.map((turn) => {
|
|
2124
|
+
const cls = turn.role === "user" ? "mushi-assistant-msg-user" : "mushi-assistant-msg-bot";
|
|
2125
|
+
const opts = turn.options && turn.options.length ? `<div class="mushi-assistant-suggestions">${turn.options.map((o) => `<button type="button" class="mushi-assistant-chip" data-action="assistant-suggest" data-value="${escapeHtml(o)}">${escapeHtml(o)}</button>`).join("")}</div>` : "";
|
|
2126
|
+
return `<div class="mushi-assistant-msg ${cls}">${escapeHtml(turn.text)}</div>${opts}`;
|
|
2127
|
+
}).join("");
|
|
2128
|
+
const thinking = ctx.assistantSending ? `<div class="mushi-assistant-msg mushi-assistant-msg-bot mushi-assistant-thinking">\u2026</div>` : "";
|
|
2129
|
+
const error = ctx.assistantError ? `<div class="mushi-assistant-error" role="alert">${escapeHtml(ctx.assistantError)}</div>` : "";
|
|
2130
|
+
return `
|
|
2131
|
+
${renderHeader(ctx, { title: label, showBack: true })}
|
|
2132
|
+
<div class="mushi-assistant">
|
|
2133
|
+
<div class="mushi-assistant-log">
|
|
2134
|
+
${transcript}
|
|
2135
|
+
${thinking}
|
|
2136
|
+
${error}
|
|
2137
|
+
</div>
|
|
2138
|
+
<form class="mushi-assistant-form" data-action="assistant-send">
|
|
2139
|
+
<textarea
|
|
2140
|
+
class="mushi-assistant-input"
|
|
2141
|
+
rows="1"
|
|
2142
|
+
placeholder="Type your question\u2026"
|
|
2143
|
+
${ctx.assistantSending ? "disabled" : ""}
|
|
2144
|
+
></textarea>
|
|
2145
|
+
<button type="submit" class="mushi-assistant-submit" ${ctx.assistantSending ? "disabled" : ""} aria-label="Send">\u2191</button>
|
|
2146
|
+
</form>
|
|
2147
|
+
</div>
|
|
2148
|
+
`;
|
|
2149
|
+
}
|
|
2052
2150
|
function renderOutdatedBanner(ctx) {
|
|
2053
2151
|
if (!ctx.sdkFreshness) return "";
|
|
2054
2152
|
if (ctx.config.outdatedBanner === "off" || ctx.config.outdatedBanner === "console-only") return "";
|
|
@@ -2538,6 +2636,9 @@ function renderSuccessStep(ctx) {
|
|
|
2538
2636
|
${renderSuccessReceipt(ctx)}
|
|
2539
2637
|
${ctx.rewardsState ? renderSuccessRewards(ctx) : ""}
|
|
2540
2638
|
${ctx.config.betaMode?.enabled ? renderBetaSuccessFooter(ctx) : ""}
|
|
2639
|
+
<button type="button" class="mushi-link-btn mushi-success-my-reports" data-action="view-my-reports">
|
|
2640
|
+
\u{1F4EC} Track this report ›
|
|
2641
|
+
</button>
|
|
2541
2642
|
</div>
|
|
2542
2643
|
</div>
|
|
2543
2644
|
`;
|
|
@@ -2668,7 +2769,6 @@ function renderSuccessRewards(ctx) {
|
|
|
2668
2769
|
|
|
2669
2770
|
// src/widget.ts
|
|
2670
2771
|
var MushiWidget = class _MushiWidget {
|
|
2671
|
-
// double-submit guard
|
|
2672
2772
|
constructor(config = {}, callbacks, sdkVersion = MUSHI_SDK_VERSION) {
|
|
2673
2773
|
this.sdkVersion = sdkVersion;
|
|
2674
2774
|
this.config = {
|
|
@@ -2792,6 +2892,7 @@ var MushiWidget = class _MushiWidget {
|
|
|
2792
2892
|
lastSubmitQueuedOffline = false;
|
|
2793
2893
|
/** Whether the user has clicked ✕ on the header banner this session. */
|
|
2794
2894
|
bannerDismissed = false;
|
|
2895
|
+
bannerResizeObserver = null;
|
|
2795
2896
|
/** Persisted FAB position when draggable is enabled. */
|
|
2796
2897
|
fabPos = null;
|
|
2797
2898
|
/** Cleanup fn for visualViewport keyboard listener. */
|
|
@@ -2813,6 +2914,12 @@ var MushiWidget = class _MushiWidget {
|
|
|
2813
2914
|
magicLinkEmail = "";
|
|
2814
2915
|
magicLinkError = "";
|
|
2815
2916
|
magicLinkSending = false;
|
|
2917
|
+
// double-submit guard
|
|
2918
|
+
// ─── Assistant tab (P5) ──────────────────────────────────────────
|
|
2919
|
+
assistantTurns = [];
|
|
2920
|
+
assistantThreadId = null;
|
|
2921
|
+
assistantSending = false;
|
|
2922
|
+
assistantError = null;
|
|
2816
2923
|
mount() {
|
|
2817
2924
|
if (this.host.isConnected) return;
|
|
2818
2925
|
this.syncHostChromeState();
|
|
@@ -2916,10 +3023,18 @@ var MushiWidget = class _MushiWidget {
|
|
|
2916
3023
|
this.viaFeatureRequest = true;
|
|
2917
3024
|
this.step = "details";
|
|
2918
3025
|
} else if (options?.category) {
|
|
2919
|
-
this.selectedCategory = options.category;
|
|
2920
|
-
this.selectedIntent = null;
|
|
2921
3026
|
const custom = this.resolveCustomCategory(options.category);
|
|
2922
|
-
|
|
3027
|
+
const builtIn = ["bug", "slow", "visual", "confusing", "other"];
|
|
3028
|
+
const isKnown = builtIn.includes(options.category) || custom !== void 0;
|
|
3029
|
+
if (!isKnown) {
|
|
3030
|
+
this.selectedCategory = null;
|
|
3031
|
+
this.selectedIntent = null;
|
|
3032
|
+
this.step = "category";
|
|
3033
|
+
} else {
|
|
3034
|
+
this.selectedCategory = options.category;
|
|
3035
|
+
this.selectedIntent = null;
|
|
3036
|
+
this.step = custom && (!custom.intents || custom.intents.length === 0) ? "details" : "intent";
|
|
3037
|
+
}
|
|
2923
3038
|
} else {
|
|
2924
3039
|
this.selectedCategory = null;
|
|
2925
3040
|
this.selectedIntent = null;
|
|
@@ -2934,6 +3049,58 @@ var MushiWidget = class _MushiWidget {
|
|
|
2934
3049
|
this.render();
|
|
2935
3050
|
this.callbacks.onClose();
|
|
2936
3051
|
}
|
|
3052
|
+
/** Open the panel directly on the assistant ("Ask") tab. */
|
|
3053
|
+
openAssistantTab() {
|
|
3054
|
+
if (!this.callbacks.assistantEnabled) {
|
|
3055
|
+
this.open();
|
|
3056
|
+
return;
|
|
3057
|
+
}
|
|
3058
|
+
if (!this.isOpen) {
|
|
3059
|
+
this.isOpen = true;
|
|
3060
|
+
this.callbacks.onOpen();
|
|
3061
|
+
}
|
|
3062
|
+
this.step = "assistant";
|
|
3063
|
+
this.assistantError = null;
|
|
3064
|
+
this.render();
|
|
3065
|
+
setTimeout(() => {
|
|
3066
|
+
this.shadow.querySelector(".mushi-assistant-input")?.focus();
|
|
3067
|
+
}, 0);
|
|
3068
|
+
}
|
|
3069
|
+
/** Send one assistant turn and re-render as the reply streams back. */
|
|
3070
|
+
async sendAssistantMessage(message) {
|
|
3071
|
+
const text = message.trim();
|
|
3072
|
+
if (!text || this.assistantSending || !this.callbacks.onAssistantAsk) return;
|
|
3073
|
+
this.assistantSending = true;
|
|
3074
|
+
this.assistantError = null;
|
|
3075
|
+
this.assistantTurns.push({ role: "user", text });
|
|
3076
|
+
this.render();
|
|
3077
|
+
try {
|
|
3078
|
+
const reply = await this.callbacks.onAssistantAsk(text, this.assistantThreadId);
|
|
3079
|
+
if (reply) {
|
|
3080
|
+
if (reply.threadId) this.assistantThreadId = reply.threadId;
|
|
3081
|
+
if (reply.kind === "clarify") {
|
|
3082
|
+
this.assistantTurns.push({
|
|
3083
|
+
role: "assistant",
|
|
3084
|
+
text: reply.question ?? "Could you tell me a bit more?",
|
|
3085
|
+
...reply.options && reply.options.length ? { options: reply.options } : {}
|
|
3086
|
+
});
|
|
3087
|
+
} else {
|
|
3088
|
+
this.assistantTurns.push({ role: "assistant", text: reply.text ?? "\u2026" });
|
|
3089
|
+
}
|
|
3090
|
+
} else {
|
|
3091
|
+
this.assistantError = "No response \u2014 please try again.";
|
|
3092
|
+
}
|
|
3093
|
+
} catch {
|
|
3094
|
+
this.assistantError = "Something went wrong. Please try again.";
|
|
3095
|
+
} finally {
|
|
3096
|
+
this.assistantSending = false;
|
|
3097
|
+
this.render();
|
|
3098
|
+
setTimeout(() => {
|
|
3099
|
+
const log = this.shadow.querySelector(".mushi-assistant-log");
|
|
3100
|
+
if (log) log.scrollTop = log.scrollHeight;
|
|
3101
|
+
}, 0);
|
|
3102
|
+
}
|
|
3103
|
+
}
|
|
2937
3104
|
/**
|
|
2938
3105
|
* Briefly highlight the trigger button (a soft pulse + tooltip) without
|
|
2939
3106
|
* opening the full reporter panel. Use for first-session welcome nudges
|
|
@@ -3248,27 +3415,49 @@ var MushiWidget = class _MushiWidget {
|
|
|
3248
3415
|
const action = this.config.environments[this.detectEnvironment()];
|
|
3249
3416
|
return action !== "never" && action !== "manual";
|
|
3250
3417
|
}
|
|
3251
|
-
/** Height of the banner in px —
|
|
3418
|
+
/** Height of the banner in px — used as a fallback before first layout. */
|
|
3252
3419
|
static BANNER_HEIGHT = 36;
|
|
3253
|
-
/** CSS property applied to
|
|
3420
|
+
/** CSS property applied to documentElement so host-app content doesn't slide under the banner. */
|
|
3254
3421
|
static BODY_NUDGE_PROP = "--mushi-banner-offset";
|
|
3255
|
-
applyBodyNudge(position) {
|
|
3256
|
-
const h = `${
|
|
3422
|
+
applyBodyNudge(position, heightPx = _MushiWidget.BANNER_HEIGHT) {
|
|
3423
|
+
const h = `${heightPx}px`;
|
|
3424
|
+
document.documentElement.style.setProperty(_MushiWidget.BODY_NUDGE_PROP, h);
|
|
3257
3425
|
if (position === "top") {
|
|
3258
|
-
document.
|
|
3259
|
-
|
|
3426
|
+
if (document.body.dataset.mushiBannerNudged === "top") {
|
|
3427
|
+
document.body.style.paddingTop = h;
|
|
3428
|
+
} else if (!document.body.style.paddingTop) {
|
|
3260
3429
|
document.body.style.paddingTop = h;
|
|
3261
3430
|
document.body.dataset.mushiBannerNudged = "top";
|
|
3262
3431
|
}
|
|
3263
3432
|
} else {
|
|
3264
|
-
document.
|
|
3265
|
-
|
|
3433
|
+
if (document.body.dataset.mushiBannerNudged === "bottom") {
|
|
3434
|
+
document.body.style.paddingBottom = h;
|
|
3435
|
+
} else if (!document.body.style.paddingBottom) {
|
|
3266
3436
|
document.body.style.paddingBottom = h;
|
|
3267
3437
|
document.body.dataset.mushiBannerNudged = "bottom";
|
|
3268
3438
|
}
|
|
3269
3439
|
}
|
|
3270
3440
|
}
|
|
3441
|
+
/**
|
|
3442
|
+
* Schedule a height measurement after the next paint and set up a ResizeObserver
|
|
3443
|
+
* so --mushi-banner-offset always tracks the actual rendered banner height
|
|
3444
|
+
* (which can exceed BANNER_HEIGHT when safe-area-inset-top is in play on iOS,
|
|
3445
|
+
* or when rich-layout text wraps on narrow viewports).
|
|
3446
|
+
*/
|
|
3447
|
+
trackBannerHeight(banner, position) {
|
|
3448
|
+
const update = () => {
|
|
3449
|
+
const h = banner.getBoundingClientRect().height;
|
|
3450
|
+
if (h > 0) this.applyBodyNudge(position, h);
|
|
3451
|
+
};
|
|
3452
|
+
requestAnimationFrame(update);
|
|
3453
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
3454
|
+
this.bannerResizeObserver = new ResizeObserver(update);
|
|
3455
|
+
this.bannerResizeObserver.observe(banner);
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3271
3458
|
removeBodyNudge() {
|
|
3459
|
+
this.bannerResizeObserver?.disconnect();
|
|
3460
|
+
this.bannerResizeObserver = null;
|
|
3272
3461
|
document.documentElement.style.removeProperty(_MushiWidget.BODY_NUDGE_PROP);
|
|
3273
3462
|
const nudged = document.body.dataset.mushiBannerNudged;
|
|
3274
3463
|
if (nudged === "top") {
|
|
@@ -3377,6 +3566,8 @@ var MushiWidget = class _MushiWidget {
|
|
|
3377
3566
|
}, true);
|
|
3378
3567
|
}
|
|
3379
3568
|
}
|
|
3569
|
+
appendDivider(true);
|
|
3570
|
+
appendAction("\u{1F4EC} My reports", () => this.openReporter(), true);
|
|
3380
3571
|
banner.appendChild(nav);
|
|
3381
3572
|
banner.appendChild(dismissBtn);
|
|
3382
3573
|
} else {
|
|
@@ -3392,10 +3583,17 @@ var MushiWidget = class _MushiWidget {
|
|
|
3392
3583
|
featBtn.addEventListener("click", () => this.open({ featureRequest: true }));
|
|
3393
3584
|
banner.appendChild(featBtn);
|
|
3394
3585
|
}
|
|
3586
|
+
const myReportsBtn = document.createElement("button");
|
|
3587
|
+
myReportsBtn.className = "mushi-banner-my-reports";
|
|
3588
|
+
myReportsBtn.textContent = "\u{1F4EC} My reports";
|
|
3589
|
+
myReportsBtn.setAttribute("aria-label", "View my submitted reports");
|
|
3590
|
+
myReportsBtn.addEventListener("click", () => this.openReporter());
|
|
3591
|
+
banner.appendChild(myReportsBtn);
|
|
3395
3592
|
banner.appendChild(dismissBtn);
|
|
3396
3593
|
}
|
|
3397
3594
|
this.shadow.appendChild(banner);
|
|
3398
3595
|
this.applyBodyNudge(position);
|
|
3596
|
+
this.trackBannerHeight(banner, position);
|
|
3399
3597
|
}
|
|
3400
3598
|
effectiveTrigger() {
|
|
3401
3599
|
if (!this.config.smartHide || typeof window === "undefined") return this.config.trigger;
|
|
@@ -3449,6 +3647,8 @@ var MushiWidget = class _MushiWidget {
|
|
|
3449
3647
|
const theme = this.getTheme();
|
|
3450
3648
|
const pos = this.config.position;
|
|
3451
3649
|
const t = this.locale;
|
|
3650
|
+
this.bannerResizeObserver?.disconnect();
|
|
3651
|
+
this.bannerResizeObserver = null;
|
|
3452
3652
|
this.shadow.innerHTML = "";
|
|
3453
3653
|
const style = document.createElement("style");
|
|
3454
3654
|
style.textContent = getWidgetStyles(theme, this.config.accent ?? "", this.config.accentText ?? "");
|
|
@@ -3555,6 +3755,28 @@ var MushiWidget = class _MushiWidget {
|
|
|
3555
3755
|
}
|
|
3556
3756
|
return maxBottom > 0 ? Math.ceil(maxBottom) + gap : null;
|
|
3557
3757
|
}
|
|
3758
|
+
/**
|
|
3759
|
+
* Minimum bottom-offset in px so a bottom-anchored trigger clears avoided
|
|
3760
|
+
* elements (tab bars, fixed CTAs). Mirrors {@link computeAvoidTopPx}.
|
|
3761
|
+
*/
|
|
3762
|
+
computeAvoidBottomPx(gap = 8) {
|
|
3763
|
+
const sels = this.config.avoidSelectors;
|
|
3764
|
+
if (!sels?.length) return null;
|
|
3765
|
+
let maxClearance = 0;
|
|
3766
|
+
for (const sel of sels) {
|
|
3767
|
+
try {
|
|
3768
|
+
const el = document.querySelector(sel);
|
|
3769
|
+
if (!el) continue;
|
|
3770
|
+
const r = el.getBoundingClientRect();
|
|
3771
|
+
if (r.width > 0 && r.height > 0) {
|
|
3772
|
+
const clearance = window.innerHeight - r.top + gap;
|
|
3773
|
+
if (clearance > maxClearance) maxClearance = clearance;
|
|
3774
|
+
}
|
|
3775
|
+
} catch {
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
return maxClearance > 0 ? Math.ceil(maxClearance) : null;
|
|
3779
|
+
}
|
|
3558
3780
|
applyInsetVars(el) {
|
|
3559
3781
|
const { anchor } = this.config;
|
|
3560
3782
|
if (anchor && Object.keys(anchor).length > 0) {
|
|
@@ -3577,13 +3799,20 @@ var MushiWidget = class _MushiWidget {
|
|
|
3577
3799
|
});
|
|
3578
3800
|
el.style.setProperty("--mushi-safe-area", this.config.respectSafeArea ? "1" : "0");
|
|
3579
3801
|
}
|
|
3580
|
-
const isTopAnchored = anchor?.top !== void 0 || this.config.position?.startsWith("top")
|
|
3802
|
+
const isTopAnchored = anchor?.top !== void 0 || this.config.position?.startsWith("top");
|
|
3803
|
+
const isBottomAnchored = anchor?.bottom !== void 0 || this.config.position?.startsWith("bottom") || !this.config.position;
|
|
3581
3804
|
if (isTopAnchored) {
|
|
3582
3805
|
const avoidPx = this.computeAvoidTopPx();
|
|
3583
3806
|
if (avoidPx !== null) {
|
|
3584
3807
|
el.style.setProperty("--mushi-top", `${avoidPx}px`);
|
|
3585
3808
|
}
|
|
3586
3809
|
}
|
|
3810
|
+
if (isBottomAnchored) {
|
|
3811
|
+
const avoidBottomPx = this.computeAvoidBottomPx();
|
|
3812
|
+
if (avoidBottomPx !== null) {
|
|
3813
|
+
el.style.setProperty("--mushi-bottom", `${avoidBottomPx}px`);
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3587
3816
|
}
|
|
3588
3817
|
// ─── Draggable FAB ──────────────────────────────────────────────────────────
|
|
3589
3818
|
/** Storage key for the FAB position, scoped to projectId when available. */
|
|
@@ -3820,7 +4049,10 @@ var MushiWidget = class _MushiWidget {
|
|
|
3820
4049
|
resolveCustomCategory: (id) => this.resolveCustomCategory(id),
|
|
3821
4050
|
effectiveMinLength: () => this.effectiveMinLength(),
|
|
3822
4051
|
categoryLabel: (id) => this.categoryLabel(id),
|
|
3823
|
-
categoryIcon: (id) => this.categoryIcon(id)
|
|
4052
|
+
categoryIcon: (id) => this.categoryIcon(id),
|
|
4053
|
+
assistantTurns: this.assistantTurns,
|
|
4054
|
+
assistantSending: this.assistantSending,
|
|
4055
|
+
assistantError: this.assistantError
|
|
3824
4056
|
};
|
|
3825
4057
|
}
|
|
3826
4058
|
attachHandlers(panel) {
|
|
@@ -3849,9 +4081,38 @@ var MushiWidget = class _MushiWidget {
|
|
|
3849
4081
|
this.step = "reports";
|
|
3850
4082
|
} else if (this.step === "roadmap") {
|
|
3851
4083
|
this.step = "category";
|
|
4084
|
+
} else if (this.step === "assistant") {
|
|
4085
|
+
this.step = "category";
|
|
3852
4086
|
}
|
|
3853
4087
|
this.render();
|
|
3854
4088
|
});
|
|
4089
|
+
panel.querySelector('[data-action="assistant"]')?.addEventListener("click", () => {
|
|
4090
|
+
this.openAssistantTab();
|
|
4091
|
+
});
|
|
4092
|
+
panel.querySelectorAll('[data-action="assistant-suggest"]').forEach((btn) => {
|
|
4093
|
+
btn.addEventListener("click", () => {
|
|
4094
|
+
const value = btn.dataset.value;
|
|
4095
|
+
if (value) void this.sendAssistantMessage(value);
|
|
4096
|
+
});
|
|
4097
|
+
});
|
|
4098
|
+
{
|
|
4099
|
+
const form = panel.querySelector('[data-action="assistant-send"]');
|
|
4100
|
+
if (form) {
|
|
4101
|
+
const input = form.querySelector(".mushi-assistant-input");
|
|
4102
|
+
form.addEventListener("submit", (e) => {
|
|
4103
|
+
e.preventDefault();
|
|
4104
|
+
const value = input?.value ?? "";
|
|
4105
|
+
if (input) input.value = "";
|
|
4106
|
+
void this.sendAssistantMessage(value);
|
|
4107
|
+
});
|
|
4108
|
+
input?.addEventListener("keydown", (e) => {
|
|
4109
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
4110
|
+
e.preventDefault();
|
|
4111
|
+
form.requestSubmit();
|
|
4112
|
+
}
|
|
4113
|
+
});
|
|
4114
|
+
}
|
|
4115
|
+
}
|
|
3855
4116
|
panel.querySelector('[data-action="reports"]')?.addEventListener("click", () => {
|
|
3856
4117
|
void this.loadReporterReports();
|
|
3857
4118
|
});
|
|
@@ -3941,6 +4202,9 @@ var MushiWidget = class _MushiWidget {
|
|
|
3941
4202
|
panel.querySelector('[data-action="reporter-not-fixed"]')?.addEventListener("click", () => {
|
|
3942
4203
|
void this.submitReporterReopen();
|
|
3943
4204
|
});
|
|
4205
|
+
panel.querySelector('[data-action="view-my-reports"]')?.addEventListener("click", () => {
|
|
4206
|
+
void this.loadReporterReports();
|
|
4207
|
+
});
|
|
3944
4208
|
panel.querySelector('[data-action="copy-report-id"]')?.addEventListener("click", (e) => {
|
|
3945
4209
|
const btn = e.currentTarget;
|
|
3946
4210
|
const id = btn.dataset.copyId;
|
|
@@ -4261,6 +4525,18 @@ var MushiWidget = class _MushiWidget {
|
|
|
4261
4525
|
if (this.isOpen) this.close();
|
|
4262
4526
|
this.open();
|
|
4263
4527
|
}
|
|
4528
|
+
/**
|
|
4529
|
+
* Open the widget directly to the reporter's "My reports" history view.
|
|
4530
|
+
* Can be called from host apps via `sdk.openReporter()` or triggered by
|
|
4531
|
+
* the banner's "My reports" link button.
|
|
4532
|
+
*/
|
|
4533
|
+
openReporter() {
|
|
4534
|
+
if (!this.isOpen) {
|
|
4535
|
+
this.isOpen = true;
|
|
4536
|
+
this.render();
|
|
4537
|
+
}
|
|
4538
|
+
void this.loadReporterReports();
|
|
4539
|
+
}
|
|
4264
4540
|
recorderSelectCategory(category) {
|
|
4265
4541
|
if (!this.isOpen) this.open();
|
|
4266
4542
|
if (this.step !== "category") {
|
|
@@ -4739,16 +5015,10 @@ function matchesUrl(url, matcher) {
|
|
|
4739
5015
|
}
|
|
4740
5016
|
function normalizeUrlPrefix(url) {
|
|
4741
5017
|
if (!url) return null;
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
try {
|
|
4747
|
-
const parsed = new URL(url);
|
|
4748
|
-
return parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1" || parsed.hostname === "::1" || parsed.hostname.endsWith(".localhost");
|
|
4749
|
-
} catch {
|
|
4750
|
-
return /\blocalhost\b|127\.0\.0\.1/.test(url);
|
|
4751
|
-
}
|
|
5018
|
+
const normalized = normalizeComparableUrl(url);
|
|
5019
|
+
let end = normalized.length;
|
|
5020
|
+
while (end > 0 && normalized.charCodeAt(end - 1) === 47) end--;
|
|
5021
|
+
return normalized.slice(0, end);
|
|
4752
5022
|
}
|
|
4753
5023
|
function normalizeComparableUrl(url) {
|
|
4754
5024
|
try {
|
|
@@ -4913,19 +5183,26 @@ function createScreenshotCapture(options = {}) {
|
|
|
4913
5183
|
try {
|
|
4914
5184
|
ctx.drawImage(img, 0, 0, width, height);
|
|
4915
5185
|
URL.revokeObjectURL(url);
|
|
4916
|
-
|
|
5186
|
+
const dataUrl = canvas.toDataURL("image/jpeg", 0.7);
|
|
5187
|
+
resolve(dataUrl);
|
|
4917
5188
|
} catch {
|
|
4918
5189
|
URL.revokeObjectURL(url);
|
|
4919
|
-
|
|
5190
|
+
activeOptions.onFailed?.("taint");
|
|
5191
|
+
emitScreenshotFailed("taint");
|
|
5192
|
+
resolve(null);
|
|
4920
5193
|
}
|
|
4921
5194
|
};
|
|
4922
5195
|
img.onerror = () => {
|
|
4923
5196
|
URL.revokeObjectURL(url);
|
|
4924
|
-
|
|
5197
|
+
activeOptions.onFailed?.("error");
|
|
5198
|
+
emitScreenshotFailed("error");
|
|
5199
|
+
resolve(null);
|
|
4925
5200
|
};
|
|
4926
5201
|
img.src = url;
|
|
4927
5202
|
});
|
|
4928
5203
|
} catch {
|
|
5204
|
+
activeOptions.onFailed?.("error");
|
|
5205
|
+
emitScreenshotFailed("error");
|
|
4929
5206
|
return null;
|
|
4930
5207
|
}
|
|
4931
5208
|
}
|
|
@@ -4936,6 +5213,12 @@ function createScreenshotCapture(options = {}) {
|
|
|
4936
5213
|
}
|
|
4937
5214
|
};
|
|
4938
5215
|
}
|
|
5216
|
+
function emitScreenshotFailed(reason) {
|
|
5217
|
+
try {
|
|
5218
|
+
document.dispatchEvent(new CustomEvent("mushi:screenshot_failed", { detail: { reason }, bubbles: false }));
|
|
5219
|
+
} catch {
|
|
5220
|
+
}
|
|
5221
|
+
}
|
|
4939
5222
|
var DEFAULT_REDACT_SELECTORS = [
|
|
4940
5223
|
'input[type="password"]',
|
|
4941
5224
|
"[data-mushi-redact]"
|
|
@@ -4991,10 +5274,28 @@ function stripTaintSources(root) {
|
|
|
4991
5274
|
const href = link.getAttribute("href");
|
|
4992
5275
|
if (!href || isCrossOriginUrl(href, pageOrigin)) link.remove();
|
|
4993
5276
|
}
|
|
5277
|
+
for (const styleEl of root.querySelectorAll("style")) {
|
|
5278
|
+
const cleaned = stripCssUrlRefs(styleEl.textContent ?? "", pageOrigin);
|
|
5279
|
+
if (cleaned !== styleEl.textContent) styleEl.textContent = cleaned;
|
|
5280
|
+
}
|
|
5281
|
+
for (const el of root.querySelectorAll("[style]")) {
|
|
5282
|
+
const s = el.getAttribute("style");
|
|
5283
|
+
if (!s) continue;
|
|
5284
|
+
const cleaned = stripCssUrlRefs(s, pageOrigin);
|
|
5285
|
+
if (cleaned !== s) el.setAttribute("style", cleaned);
|
|
5286
|
+
}
|
|
4994
5287
|
for (const script of root.querySelectorAll("script")) {
|
|
4995
5288
|
script.remove();
|
|
4996
5289
|
}
|
|
4997
5290
|
}
|
|
5291
|
+
function stripCssUrlRefs(css, pageOrigin) {
|
|
5292
|
+
return css.replace(/url\(\s*(['"]?)([^)'"]+)\1\s*\)/gi, (_match, _q, href) => {
|
|
5293
|
+
const trimmed = href.trim();
|
|
5294
|
+
if (!trimmed || trimmed.startsWith("data:") || trimmed.startsWith("#")) return _match;
|
|
5295
|
+
if (isCrossOriginUrl(trimmed, pageOrigin)) return "none";
|
|
5296
|
+
return _match;
|
|
5297
|
+
});
|
|
5298
|
+
}
|
|
4998
5299
|
function isCrossOriginUrl(raw, pageOrigin) {
|
|
4999
5300
|
if (!raw || raw.startsWith("data:") || raw.startsWith("blob:")) return false;
|
|
5000
5301
|
try {
|
|
@@ -5004,24 +5305,6 @@ function isCrossOriginUrl(raw, pageOrigin) {
|
|
|
5004
5305
|
return true;
|
|
5005
5306
|
}
|
|
5006
5307
|
}
|
|
5007
|
-
function buildDegradedScreenshot(width, height) {
|
|
5008
|
-
const canvas = document.createElement("canvas");
|
|
5009
|
-
const ctx = canvas.getContext("2d");
|
|
5010
|
-
if (!ctx) return null;
|
|
5011
|
-
canvas.width = width;
|
|
5012
|
-
canvas.height = height;
|
|
5013
|
-
ctx.fillStyle = "#111827";
|
|
5014
|
-
ctx.fillRect(0, 0, width, height);
|
|
5015
|
-
ctx.fillStyle = "#e5e7eb";
|
|
5016
|
-
ctx.font = "13px system-ui, sans-serif";
|
|
5017
|
-
ctx.fillText("Screenshot: layout captured (external media stripped)", 16, 28);
|
|
5018
|
-
ctx.fillText(`${width}\xD7${height}px`, 16, 48);
|
|
5019
|
-
try {
|
|
5020
|
-
return canvas.toDataURL("image/jpeg", 0.7);
|
|
5021
|
-
} catch {
|
|
5022
|
-
return null;
|
|
5023
|
-
}
|
|
5024
|
-
}
|
|
5025
5308
|
function maskElement(el) {
|
|
5026
5309
|
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
5027
5310
|
el.value = "";
|
|
@@ -6331,16 +6614,17 @@ var Mushi = class {
|
|
|
6331
6614
|
core.createLogger({ scope: "mushi", level: "warn", format: "pretty" }).warn("Already initialized \u2014 call destroy() first to reinitialize");
|
|
6332
6615
|
return instance;
|
|
6333
6616
|
}
|
|
6334
|
-
|
|
6335
|
-
|
|
6617
|
+
const resolved = { ...core.resolveEnvConfig(), ...config };
|
|
6618
|
+
if (!resolved.projectId) {
|
|
6619
|
+
throw new Error("[mushi] projectId is required \u2014 set NEXT_PUBLIC_MUSHI_PROJECT_ID / VITE_MUSHI_PROJECT_ID / MUSHI_PROJECT_ID or pass it explicitly");
|
|
6336
6620
|
}
|
|
6337
|
-
if (!
|
|
6338
|
-
throw new Error("[mushi] apiKey is required");
|
|
6621
|
+
if (!resolved.apiKey) {
|
|
6622
|
+
throw new Error("[mushi] apiKey is required \u2014 set NEXT_PUBLIC_MUSHI_API_KEY / VITE_MUSHI_API_KEY / MUSHI_API_KEY or pass it explicitly");
|
|
6339
6623
|
}
|
|
6340
|
-
if (
|
|
6624
|
+
if (resolved.enabled === false) {
|
|
6341
6625
|
return createNoopInstance();
|
|
6342
6626
|
}
|
|
6343
|
-
instance = createInstance(
|
|
6627
|
+
instance = createInstance(resolved);
|
|
6344
6628
|
return instance;
|
|
6345
6629
|
}
|
|
6346
6630
|
static getInstance() {
|
|
@@ -6358,10 +6642,15 @@ function createInstance(config) {
|
|
|
6358
6642
|
const bootstrapConfig = applyPresetConfig(config);
|
|
6359
6643
|
let activeConfig = bootstrapConfig;
|
|
6360
6644
|
const log = config.debug ?? false ? core.createLogger({ scope: "mushi", level: "debug", format: "pretty" }) : core.noopLogger;
|
|
6645
|
+
let userToken = null;
|
|
6646
|
+
let currentPageContext = null;
|
|
6361
6647
|
const apiClient2 = core.createApiClient({
|
|
6362
6648
|
projectId: bootstrapConfig.projectId,
|
|
6363
6649
|
apiKey: bootstrapConfig.apiKey,
|
|
6364
|
-
...bootstrapConfig.apiEndpoint ? { apiEndpoint: bootstrapConfig.apiEndpoint } : {}
|
|
6650
|
+
...bootstrapConfig.apiEndpoint ? { apiEndpoint: bootstrapConfig.apiEndpoint } : {},
|
|
6651
|
+
getUserToken: () => userToken,
|
|
6652
|
+
sdkPackage: MUSHI_SDK_PACKAGE,
|
|
6653
|
+
sdkVersion: MUSHI_SDK_VERSION
|
|
6365
6654
|
});
|
|
6366
6655
|
const preFilter = core.createPreFilter(bootstrapConfig.preFilter);
|
|
6367
6656
|
const offlineQueue = core.createOfflineQueue(bootstrapConfig.offline);
|
|
@@ -6422,12 +6711,12 @@ function createInstance(config) {
|
|
|
6422
6711
|
return;
|
|
6423
6712
|
}
|
|
6424
6713
|
const status = statusResult.data;
|
|
6425
|
-
if (!status.is_tester) {
|
|
6714
|
+
if (!status.is_tester || !status.tester_id) {
|
|
6426
6715
|
clearTesterJwt();
|
|
6427
6716
|
return;
|
|
6428
6717
|
}
|
|
6429
6718
|
widget.setTesterSession(jwt, {
|
|
6430
|
-
id:
|
|
6719
|
+
id: status.tester_id,
|
|
6431
6720
|
public_handle: status.public_handle ?? null,
|
|
6432
6721
|
display_name: status.display_name ?? null
|
|
6433
6722
|
});
|
|
@@ -6780,6 +7069,19 @@ function createInstance(config) {
|
|
|
6780
7069
|
},
|
|
6781
7070
|
onTesterSignOut() {
|
|
6782
7071
|
clearTesterJwt();
|
|
7072
|
+
},
|
|
7073
|
+
// ── Assistant tab (P5) ───────────────────────────────────────────────
|
|
7074
|
+
assistantEnabled: bootstrapConfig.assistant?.enabled === true,
|
|
7075
|
+
...bootstrapConfig.assistant?.label ? { assistantLabel: bootstrapConfig.assistant.label } : {},
|
|
7076
|
+
...bootstrapConfig.assistant?.greeting ? { assistantGreeting: bootstrapConfig.assistant.greeting } : {},
|
|
7077
|
+
...bootstrapConfig.assistant?.suggestions ? { assistantSuggestions: bootstrapConfig.assistant.suggestions } : {},
|
|
7078
|
+
async onAssistantAsk(message, threadId) {
|
|
7079
|
+
const res = await apiClient2.askAssistant({
|
|
7080
|
+
message,
|
|
7081
|
+
threadId,
|
|
7082
|
+
context: currentPageContext
|
|
7083
|
+
});
|
|
7084
|
+
return res.ok ? res.data ?? null : null;
|
|
6783
7085
|
}
|
|
6784
7086
|
}, MUSHI_SDK_VERSION);
|
|
6785
7087
|
syncCaptureModules();
|
|
@@ -6869,8 +7171,8 @@ function createInstance(config) {
|
|
|
6869
7171
|
}).catch((err) => {
|
|
6870
7172
|
log.debug("Runtime SDK config fetch failed", { error: err instanceof Error ? err.message : String(err) });
|
|
6871
7173
|
});
|
|
6872
|
-
} else
|
|
6873
|
-
log.debug("Runtime SDK config
|
|
7174
|
+
} else {
|
|
7175
|
+
log.debug("Runtime SDK config disabled via runtimeConfig:false; using static bootstrap config");
|
|
6874
7176
|
}
|
|
6875
7177
|
void checkSdkFreshness();
|
|
6876
7178
|
log.info("Initialized", { projectId: config.projectId });
|
|
@@ -7156,6 +7458,9 @@ function createInstance(config) {
|
|
|
7156
7458
|
setTrigger(trigger) {
|
|
7157
7459
|
widget.setTrigger(trigger);
|
|
7158
7460
|
},
|
|
7461
|
+
openReporter() {
|
|
7462
|
+
widget.openReporter();
|
|
7463
|
+
},
|
|
7159
7464
|
close() {
|
|
7160
7465
|
widget.close();
|
|
7161
7466
|
},
|
|
@@ -7325,6 +7630,28 @@ function createInstance(config) {
|
|
|
7325
7630
|
}
|
|
7326
7631
|
}
|
|
7327
7632
|
},
|
|
7633
|
+
identifyWithToken(token) {
|
|
7634
|
+
userToken = token && typeof token === "string" ? token : null;
|
|
7635
|
+
if (userToken) {
|
|
7636
|
+
const claims = core.parseIdentityToken(userToken);
|
|
7637
|
+
if (claims?.sub) {
|
|
7638
|
+
userInfo = {
|
|
7639
|
+
id: claims.sub,
|
|
7640
|
+
...claims.email ? { email: claims.email } : {},
|
|
7641
|
+
...claims.name ? { name: claims.name } : {}
|
|
7642
|
+
};
|
|
7643
|
+
}
|
|
7644
|
+
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken()" });
|
|
7645
|
+
} else {
|
|
7646
|
+
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken(null)" });
|
|
7647
|
+
}
|
|
7648
|
+
},
|
|
7649
|
+
publishPageContext(context) {
|
|
7650
|
+
currentPageContext = context && context.route ? context : null;
|
|
7651
|
+
},
|
|
7652
|
+
openAssistant() {
|
|
7653
|
+
widget.openAssistantTab();
|
|
7654
|
+
},
|
|
7328
7655
|
addBreadcrumb(crumb) {
|
|
7329
7656
|
breadcrumbs.add(crumb);
|
|
7330
7657
|
},
|
|
@@ -7448,6 +7775,9 @@ function mergeRuntimeConfig(config, runtime) {
|
|
|
7448
7775
|
const nativeTrigger = runtime.native?.triggerMode;
|
|
7449
7776
|
const runtimeLauncher = runtime.widget?.launcher;
|
|
7450
7777
|
const widgetTrigger = runtimeLauncher ?? runtime.widget?.trigger ?? (nativeTrigger === "none" || nativeTrigger === "shake" ? "manual" : void 0);
|
|
7778
|
+
const explicitHidden = runtimeLauncher === "hidden" || runtime.widget?.trigger === "hidden";
|
|
7779
|
+
const hostTrigger = config.widget?.trigger;
|
|
7780
|
+
const safeWidgetTrigger = widgetTrigger === "hidden" && !explicitHidden && hostTrigger && hostTrigger !== "hidden" ? hostTrigger : widgetTrigger;
|
|
7451
7781
|
const runtimeWidget = runtime.widget;
|
|
7452
7782
|
const runtimeBannerVariant = runtimeWidget?.bannerVariant;
|
|
7453
7783
|
const runtimeBannerPosition = runtimeWidget?.bannerPosition;
|
|
@@ -7471,7 +7801,7 @@ function mergeRuntimeConfig(config, runtime) {
|
|
|
7471
7801
|
widget: {
|
|
7472
7802
|
...config.widget,
|
|
7473
7803
|
...runtime.widget,
|
|
7474
|
-
...
|
|
7804
|
+
...safeWidgetTrigger ? { trigger: safeWidgetTrigger } : {},
|
|
7475
7805
|
...derivedBannerConfig ? { bannerConfig: derivedBannerConfig } : {},
|
|
7476
7806
|
// betaMode is local-only: set by the host app, not the dashboard.
|
|
7477
7807
|
// Restore it after the runtime spread so it is never silently cleared.
|
|
@@ -7547,9 +7877,7 @@ function resolveApiEndpoint(config) {
|
|
|
7547
7877
|
return config.apiEndpoint ?? core.DEFAULT_API_ENDPOINT;
|
|
7548
7878
|
}
|
|
7549
7879
|
function shouldUseRuntimeConfig(config) {
|
|
7550
|
-
|
|
7551
|
-
if (config.runtimeConfig === true) return true;
|
|
7552
|
-
return !isLocalhostEndpoint(resolveApiEndpoint(config));
|
|
7880
|
+
return config.runtimeConfig !== false;
|
|
7553
7881
|
}
|
|
7554
7882
|
async function runDiagnostics(options) {
|
|
7555
7883
|
const endpoint = await probeApiEndpoint(options.apiEndpoint);
|
|
@@ -7704,6 +8032,8 @@ function createNoopInstance() {
|
|
|
7704
8032
|
},
|
|
7705
8033
|
setTrigger: () => {
|
|
7706
8034
|
},
|
|
8035
|
+
openReporter: () => {
|
|
8036
|
+
},
|
|
7707
8037
|
destroy: () => {
|
|
7708
8038
|
instance = null;
|
|
7709
8039
|
},
|
|
@@ -7711,6 +8041,12 @@ function createNoopInstance() {
|
|
|
7711
8041
|
captureException: async () => null,
|
|
7712
8042
|
identify: () => {
|
|
7713
8043
|
},
|
|
8044
|
+
identifyWithToken: () => {
|
|
8045
|
+
},
|
|
8046
|
+
publishPageContext: () => {
|
|
8047
|
+
},
|
|
8048
|
+
openAssistant: () => {
|
|
8049
|
+
},
|
|
7714
8050
|
addBreadcrumb: () => {
|
|
7715
8051
|
},
|
|
7716
8052
|
getBreadcrumbs: () => [],
|