@mushi-mushi/web 1.29.0 → 1.31.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/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiAssistantReply, MushiWidgetConfig, MushiLeaderboardEntry, MushiCrossAppReport, MushiTesterReputation, MushiApiCascadeConfig, MushiErrorFilter } from '@mushi-mushi/core';
1
+ import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiPrivacyConfig, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiReporterTimelineItem, MushiAssistantReply, MushiWidgetConfig, MushiLeaderboardEntry, MushiCrossAppReport, MushiTesterReputation, MushiReporterUpdates, MushiConsoleEntry, MushiNetworkEntry, MushiUrlMatcher, MushiTracePropagationConfig, MushiPerformanceMetrics, MushiSelectedElement, MushiTimelineEntry, MushiApiCascadeConfig, MushiErrorFilter } from '@mushi-mushi/core';
2
2
  export { MushiApiCascadeConfig, MushiConfig, MushiConsoleEntry, MushiDiagnosticsResult, MushiEnvironment, MushiEventHandler, MushiEventType, MushiNetworkEntry, MushiPerformanceMetrics, MushiReport, MushiReportCategory, MushiSDKInstance, MushiTimelineEntry, MushiTimelineKind, MushiUrlMatcher, MushiWidgetConfig } from '@mushi-mushi/core';
3
- export { C as ConsoleCapture, E as ElementSelector, N as NetworkCapture, P as PerformanceCapture, S as ScreenshotCapture, T as TimelineCapture, c as createConsoleCapture, a as createElementSelector, b as createNetworkCapture, d as createPerformanceCapture, e as createScreenshotCapture, f as createTimelineCapture } from './timeline-BuqAn2FH.js';
4
- export { MushiLocale, getAvailableLocales, getLocale } from './i18n/index.js';
5
3
 
6
4
  declare class Mushi {
7
5
  private constructor();
@@ -11,6 +9,27 @@ declare class Mushi {
11
9
  static diagnose(): Promise<MushiDiagnosticsResult>;
12
10
  }
13
11
 
12
+ interface ScreenshotCapture {
13
+ take(): Promise<string | null>;
14
+ updateOptions(options: ScreenshotCaptureOptions): void;
15
+ }
16
+ interface ScreenshotCaptureOptions {
17
+ privacy?: MushiPrivacyConfig;
18
+ /** Callback invoked when capture fails (taint, security policy, etc.). */
19
+ onFailed?: (reason: ScreenshotFailureReason) => void;
20
+ }
21
+ /**
22
+ * Why a capture produced no image. Also the `detail.reason` of the
23
+ * `mushi:screenshot_failed` document event.
24
+ * - taint: cross-origin content made the canvas unreadable
25
+ * - timeout: the SVG never loaded or errored within 5 s
26
+ * - unsupported: no 2D canvas, or the engine rasterised nothing (WebKit)
27
+ * - csp: the host's Content-Security-Policy img-src blocks data: images
28
+ * - error: anything else
29
+ */
30
+ type ScreenshotFailureReason = 'taint' | 'timeout' | 'unsupported' | 'csp' | 'error';
31
+ declare function createScreenshotCapture(options?: ScreenshotCaptureOptions): ScreenshotCapture;
32
+
14
33
  /**
15
34
  * FILE: packages/web/src/widget-helpers.ts
16
35
  * PURPOSE: Stateless helpers, constants, and shared types for the bug-capture
@@ -18,11 +37,10 @@ declare class Mushi {
18
37
  * on the MushiWidget class (DOM structure, state, lifecycle).
19
38
  *
20
39
  * OVERVIEW:
21
- * - Pure functions: reporter-status copy mappers, relative-time formatting,
22
- * the step-number padder, the submit-shortcut detector, and HTML escaping.
23
- * - Constants: category icon map, the feature-request intent wire string, the
24
- * total step count, and the per-step ledger number.
25
- * - Shared types: WidgetStep, the reporter status tone union, and the public
40
+ * - Pure functions: relative-time formatting, the submit-shortcut detector,
41
+ * HTML escaping, the reporter timeline builder.
42
+ * - Constants: the feature-request intent wire string, read deadlines.
43
+ * - Shared types: WidgetStep, PendingReply, and the public
26
44
  * WidgetRewardsState / WidgetSubmitOutcome / WidgetCallbacks contracts (these
27
45
  * three are re-exported from widget.ts so existing `./widget` import sites and
28
46
  * the package barrel keep working unchanged).
@@ -38,7 +56,11 @@ declare class Mushi {
38
56
  * - Behaviour-preserving move: bodies are identical to the pre-split widget.ts.
39
57
  */
40
58
 
41
- type WidgetStep = 'category' | 'intent' | 'details' | 'success' | 'reports' | 'report-detail' | 'leaderboard' | 'roadmap' | 'account' | 'cross-app-reports' | 'assistant';
59
+ type WidgetStep = 'report' | 'success' | 'reports' | 'report-detail' | 'leaderboard' | 'roadmap' | 'account' | 'cross-app-reports' | 'assistant';
60
+ /** One timeline row from GET /v1/reporter/reports/:id (core's shape). */
61
+ type WidgetTimelineEvent = MushiReporterTimelineItem;
62
+ /** Capture failure reasons plus 'permission' (a host screenshotProvider was denied). */
63
+ type ScreenshotErrorReason = ScreenshotFailureReason | 'permission';
42
64
  interface WidgetRewardsState {
43
65
  tier: {
44
66
  slug: string;
@@ -96,6 +118,11 @@ interface WidgetCallbacks {
96
118
  onBrandFooterImpression?(): void;
97
119
  onBrandFooterClick?(): void;
98
120
  onScreenshotRequest(): void;
121
+ /**
122
+ * Present only when the browser supports getDisplayMedia. Must start the
123
+ * capture synchronously (the picker needs the click's user activation).
124
+ */
125
+ onScreenshotShareTabRequest?(): void;
99
126
  onScreenshotRemove?(): void;
100
127
  /** Optional markup pass (highlight / blur / arrow) before submit. */
101
128
  onScreenshotAnnotateRequest?(container: HTMLElement): void | Promise<void>;
@@ -105,6 +132,17 @@ interface WidgetCallbacks {
105
132
  onReporterReply?(reportId: string, body: string): Promise<void>;
106
133
  onReporterFeedback?(reportId: string, signal: string, note?: string): Promise<Record<string, unknown> | null>;
107
134
  onReporterReopen?(reportId: string, note?: string): Promise<Record<string, unknown> | null>;
135
+ /** Header card + merged timeline for one report (newer servers); falls back to the comments call. */
136
+ onReporterReportRequest?(reportId: string): Promise<{
137
+ report?: Partial<MushiReporterReport>;
138
+ timeline?: WidgetTimelineEvent[] | null;
139
+ } | null>;
140
+ /** Mark a report's updates read when its thread opens; resolves with the new unread total when known. */
141
+ onReporterMarkRead?(reportId: string): Promise<number | null | void>;
142
+ /** Save an email for status updates on this device's reports (explicit opt-in). */
143
+ onReporterEmailOptIn?(email: string): Promise<void>;
144
+ /** Ask for browser notification permission and register a push subscription. */
145
+ onReporterPushSubscribe?(): Promise<void>;
108
146
  onFeatureBoardRequest?(): Promise<Array<Record<string, unknown>>>;
109
147
  onFeatureBoardVote?(requestId: string): Promise<{
110
148
  voted: boolean;
@@ -134,7 +172,6 @@ interface WidgetCallbacks {
134
172
  }
135
173
 
136
174
  declare class MushiWidget {
137
- private readonly sdkVersion;
138
175
  private host;
139
176
  private shadow;
140
177
  /** Re-inject styles when OS light/dark flips while theme=auto|inherit. */
@@ -143,51 +180,46 @@ declare class MushiWidget {
143
180
  private config;
144
181
  private callbacks;
145
182
  private locale;
183
+ private rc;
184
+ private lang;
146
185
  private isOpen;
147
186
  private step;
148
- /**
149
- * The selected category id. May be a built-in `MushiReportCategory` or a
150
- * custom id from `config.categories`. Cast to `MushiReportCategory` only
151
- * after resolving through `resolveBaseCategory()`.
152
- */
153
- private selectedCategory;
154
- private selectedIntent;
155
- /**
156
- * True when the user took the "Feature request" shortcut. We track this
157
- * separately from `selectedCategory='other'` so the Back button on the
158
- * details step jumps straight back to the category picker instead of
159
- * landing on the intent picker the user explicitly skipped.
160
- */
161
- private viaFeatureRequest;
162
- /** Whether the category list is fully expanded (progressive disclosure). */
187
+ private readonly styleEl;
188
+ private styleKey;
189
+ private readonly panel;
190
+ private readonly scroller;
191
+ private readonly regionEls;
192
+ private regionHtml;
193
+ private readonly live;
194
+ private renderedStep;
195
+ private triggerEl;
196
+ private triggerKey;
197
+ private bannerEl;
198
+ private bannerKey;
199
+ private toastEl;
200
+ /** Element focused before open; focus returns here on close (APG dialog). */
201
+ private opener;
202
+ /** Selected type chip: built-in id, `idea`, a custom category id, or null (none picked). */
203
+ private chip;
204
+ private intent;
205
+ /** Host custom categories revealed under "More…". */
163
206
  private showAllCategories;
164
- /** Secondary hub nav (inbox, assistant, community) collapsed under "More". */
207
+ /** Header overflow menu. */
165
208
  private showMoreNav;
166
209
  private screenshotAttached;
167
210
  private screenshotCapturing;
168
211
  private screenshotError;
212
+ /** Why the last capture failed; drives the actionable hint under the tools. */
213
+ private screenshotErrorReason;
214
+ /** The reporter asked for (or marked up) the screenshot — an auto-capture on open doesn't count as saying something. */
215
+ private screenshotByUser;
216
+ private previewOpen;
169
217
  private allowScreenshotRemove;
170
- /**
171
- * Whether the screenshot / element-select tools are actually usable
172
- * (capture module present + not disabled by config). Unavailable tools are
173
- * hidden from the details step — a rendered button whose handler silently
174
- * no-ops reads as a bug to the reporter.
175
- */
218
+ /** Unusable tools are hidden — a button whose handler no-ops reads as a bug. */
176
219
  private screenshotAvailable;
177
220
  private elementAvailable;
178
- /**
179
- * In-progress form input preserved across full shadow-DOM re-renders.
180
- * render() rebuilds the panel with `innerHTML = ''`, which used to destroy
181
- * whatever the reporter had typed whenever a background refresh (60s inbox
182
- * poll, visibilitychange refetch, screenshot attach) fired mid-typing.
183
- * Captured from the live DOM right before teardown, replayed right after.
184
- */
185
- private draftDescription;
186
- private draftEmail;
187
- private draftReply;
188
- private draftFocus;
189
- private draftSelStart;
190
- private draftSelEnd;
221
+ /** Field values survive region patches and are the source of truth for validation. */
222
+ private drafts;
191
223
  /** Data URL of the attached screenshot, rendered as a visible preview. */
192
224
  private screenshotPreview;
193
225
  private elementSelected;
@@ -199,11 +231,6 @@ declare class MushiWidget {
199
231
  private triggerVisible;
200
232
  private triggerShrunk;
201
233
  private triggerHiddenByScroll;
202
- /** Milliseconds since mount — used for the 30s first-time nudge gate. */
203
- private mountedAt;
204
- private nudgeShown;
205
- private nudgeEl;
206
- private nudgeTimer;
207
234
  private sdkFreshness;
208
235
  /** Brand-footer ref (SDK sets it once hashed) + once-per-instance impression latch. */
209
236
  private brandRef;
@@ -211,35 +238,44 @@ declare class MushiWidget {
211
238
  private reporterReports;
212
239
  private featureBoard;
213
240
  private reporterComments;
241
+ /** Server timeline for the open report, when the host SDK can fetch it. */
242
+ private timeline;
243
+ private pendingReplies;
244
+ private replySeq;
214
245
  private selectedReportId;
215
- private reporterLoading;
246
+ /** One flag per surface: a reply never blanks the thread it was posted from. */
247
+ private listLoading;
248
+ private threadLoading;
249
+ private actionPending;
216
250
  private reporterError;
251
+ private threadError;
252
+ private actionError;
253
+ /** Reporter channels the host enabled and the server has configured (§4.1). */
254
+ private channels;
255
+ private emailOptInOpen;
256
+ private emailState;
257
+ private pushState;
217
258
  private attachedLaunchers;
218
259
  private smartHideCleanup;
219
260
  private smartHideTimer;
220
- /** Captured at the moment of submit so the success ledger metadata
221
- * ("REPORT · 14:23:07 JST") doesn't drift while the success step
222
- * is on screen. */
261
+ /** Captured at submit so the receipt time doesn't drift while it is on screen. */
223
262
  private submittedAt;
224
- /** Pending success-state + auto-close timers. Tracked so destroy()
225
- * can clear them — otherwise a host that unmounts mid-submit leaks
226
- * this MushiWidget reference (and re-renders into a detached shadow
227
- * root) for up to ~3.3s after destroy. */
263
+ /** Pending success-state timer, cleared by destroy(). */
228
264
  private successTimer;
229
- private autoCloseTimer;
265
+ /**
266
+ * Set on pointerdown inside the panel. A background patch that lands
267
+ * between pointerdown and click replaces the button under the pointer and
268
+ * the browser drops the click. render() defers while this is set (bounded,
269
+ * so a lost pointerup can't freeze the panel).
270
+ */
271
+ private pointerDownAt;
272
+ private renderDeferred;
273
+ private readonly onPointerRelease;
230
274
  private rewardsState;
231
275
  private leaderboardEntries;
232
276
  private leaderboardLoading;
233
- /** Server-confirmed id for the just-submitted report. Surfaces in
234
- * the success step as a copyable receipt + optional deep link to
235
- * the Mushi console (when `dashboardUrl` is configured). Cleared
236
- * on every new `open()` so a re-opened widget never reuses a
237
- * stale id from the previous session. */
277
+ /** Server-confirmed id for the just-submitted report (receipt + Track it). */
238
278
  private lastReportId;
239
- /** True when the just-submitted report was queued offline (no
240
- * network, or the API errored and went into the retry queue).
241
- * Drives a different success copy so the user knows the report
242
- * hasn't actually reached the console yet. */
243
279
  private lastSubmitQueuedOffline;
244
280
  private lastSubmitFailureKind;
245
281
  private lastSubmitScreenshotDropped;
@@ -250,26 +286,16 @@ declare class MushiWidget {
250
286
  private fabPos;
251
287
  /** Cleanup fn for visualViewport keyboard listener. */
252
288
  private vvCleanup;
253
- /**
254
- * Host-app user identity forwarded via `Mushi.identify()` or
255
- * `Mushi.identifyWithToken()`. Used to show "Reporting as <name>"
256
- * in the details step so logged-in users know their report is linked.
257
- * Independent of the Mushi tester magic-link session below.
258
- */
289
+ /** Host-app user identity from `identify()` — shown as "Reporting as <name>". */
259
290
  private identifiedUser;
260
291
  /** Mushi tester session JWT — set after in-widget sign-in or by mushi.ts. */
261
292
  private testerJwt;
262
- /** Tester identity (public_handle, display_name). */
263
293
  private testerInfo;
264
- /** Cross-app reports for the signed-in tester. */
265
294
  private crossAppReports;
266
295
  private crossAppLoading;
267
- /** Global leaderboard entries (from mushi_testers, not org-scoped). */
268
296
  private globalLeaderboard;
269
297
  private globalLeaderboardLoading;
270
- /** Reputation for the signed-in tester. */
271
298
  private testerReputation;
272
- /** Whether an in-widget magic-link email was just sent. */
273
299
  private magicLinkSent;
274
300
  private magicLinkEmail;
275
301
  private magicLinkError;
@@ -278,42 +304,31 @@ declare class MushiWidget {
278
304
  private assistantThreadId;
279
305
  private assistantSending;
280
306
  private assistantError;
281
- constructor(config: MushiWidgetConfig | undefined, callbacks: WidgetCallbacks, sdkVersion?: string);
307
+ constructor(config: MushiWidgetConfig | undefined, callbacks: WidgetCallbacks);
308
+ /** Locale code for core's reporter copy; 'auto' resolves through the browser. */
309
+ private resolveCopy;
282
310
  mount(): void;
283
311
  getIsMounted(): boolean;
284
312
  updateConfig(config?: MushiWidgetConfig): void;
285
313
  /** Find a custom category entry by id. Returns undefined for built-in ids. */
286
314
  private resolveCustomCategory;
287
- /**
288
- * Map a (possibly custom) category id to the built-in `MushiReportCategory`
289
- * used for the report wire format. Falls back to `'other'`.
290
- */
291
- private resolveBaseCategory;
292
- /** Icon for the selected category — custom entry's icon or built-in emoji. */
293
- private categoryIcon;
294
- /** Label for the selected category — custom entry label or built-in i18n string. */
295
- private categoryLabel;
296
315
  open(options?: {
297
316
  category?: MushiReportCategory | string;
298
317
  featureRequest?: boolean;
299
318
  }): void;
300
319
  close(): void;
301
- /** Open the panel directly on the assistant ("Ask") tab. */
320
+ /** Open the panel directly on the assistant ("Ask") view. */
302
321
  openAssistantTab(): void;
303
- /** Send one assistant turn and re-render as the reply streams back. */
322
+ private ensureOpen;
323
+ /** Send one assistant turn and re-render as the reply arrives. */
304
324
  sendAssistantMessage(message: string): Promise<void>;
305
325
  /** Persist Ask turns for same-tab reload survival (UX only). */
306
326
  private persistAssistantSession;
307
327
  /** Clear Ask transcript (e.g. host reset). Keeps Ask login-free. */
308
328
  clearAssistantTranscript(): void;
309
- /** Escape hatch from Ask → report category picker (no login required). */
310
- private openReportFromAssistant;
311
329
  /**
312
- * Briefly highlight the trigger button (a soft pulse + tooltip) without
313
- * opening the full reporter panel. Use for first-session welcome nudges
314
- * and other "by the way, this exists" prompts where forcing the panel
315
- * open would feel aggressive. Honours `position: 'none'` (no-op when
316
- * the trigger button is hidden).
330
+ * Briefly highlight the trigger (a soft pulse) without opening the panel.
331
+ * No-op when the trigger isn't rendered.
317
332
  */
318
333
  pulseTrigger(): void;
319
334
  getIsOpen(): boolean;
@@ -324,12 +339,7 @@ declare class MushiWidget {
324
339
  setScreenshotAttached(attached: boolean): void;
325
340
  /** Provide the captured screenshot data URL so the widget can preview it. */
326
341
  setScreenshotPreview(dataUrl: string | null): void;
327
- /**
328
- * Resolve the privacy caption shown beside the screenshot preview from the
329
- * `screenshotSensitiveHint` widget config (kept in sync via updateConfig, so
330
- * it honours console/runtime config): `false` → hidden, a non-empty string →
331
- * that copy, anything else (`true`/unset) → the localized default.
332
- */
342
+ /** Privacy caption beside the preview: `false` hides it, a string replaces it, else the localized default. */
333
343
  private resolveScreenshotHint;
334
344
  setAllowScreenshotRemove(allow: boolean): void;
335
345
  /** Show/hide the attachment tools based on what the SDK can actually do. */
@@ -341,17 +351,17 @@ declare class MushiWidget {
341
351
  /** Surface a failed/cancelled element-selection attempt (mirrors setScreenshotError). */
342
352
  setElementError(failed: boolean): void;
343
353
  setScreenshotCapturing(capturing: boolean): void;
344
- setScreenshotError(failed: boolean): void;
354
+ /**
355
+ * Flag (or clear) a failed capture. A call without a reason keeps the more
356
+ * specific one an earlier call recorded for the same attempt.
357
+ */
358
+ setScreenshotError(failed: boolean, reason?: ScreenshotErrorReason): void;
345
359
  setElementCapturing(capturing: boolean): void;
346
- /** Hide the widget panel (but keep the host element) during element selection
347
- * so the user can click any element on the page without the panel
348
- * intercepting the event. */
360
+ /** Hide the panel (keep the host) during element selection so page clicks reach the page. */
349
361
  hidePanel(): void;
350
362
  showPanel(): void;
351
363
  private showSelectorHint;
352
364
  private removeSelectorHint;
353
- private showNudge;
354
- private removeNudge;
355
365
  setSdkFreshness(info: {
356
366
  latest: string | null;
357
367
  current: string;
@@ -366,6 +376,15 @@ declare class MushiWidget {
366
376
  total_points: number;
367
377
  points_30d: number;
368
378
  }> | null, loading?: boolean): void;
379
+ /**
380
+ * Which opt-in channels to offer (§4.1). The SDK passes the intersection of
381
+ * the host's `notifications` config and the server's configured channels.
382
+ */
383
+ setReporterChannels(channels: {
384
+ email?: boolean;
385
+ push?: boolean;
386
+ emailPrefill?: string;
387
+ }): void;
369
388
  setIdentifiedUser(user: {
370
389
  name?: string;
371
390
  email?: string;
@@ -382,25 +401,10 @@ declare class MushiWidget {
382
401
  /** Live-restyle when OS prefers-color-scheme changes (theme auto/inherit only). */
383
402
  private bindColorSchemeListener;
384
403
  private unbindColorSchemeListener;
385
- /**
386
- * Apply the SDK-owned pass-through layout to the host element so it is
387
- * always zero-sized and click/touch-transparent. Only the shadow-root
388
- * internals (`.mushi-trigger`, `.mushi-banner`, `.mushi-panel`) opt back
389
- * into pointer events. This is idempotent and safe to call repeatedly.
390
- */
391
404
  private syncHostChromeState;
392
- /**
393
- * Returns true when a DOM element matching `hideOnSelector` is currently
394
- * present in the host document. Used by both the trigger and the banner
395
- * so a single selector consistently hides ALL SDK-injected launcher
396
- * surfaces. Invalid selectors are swallowed silently (non-fatal).
397
- */
405
+ /** True when an element matching `hideOnSelector` is in the host document (invalid selectors are ignored). */
398
406
  private isSuppressedByHost;
399
- /**
400
- * Returns a snapshot of the widget's host-layer health for use in
401
- * `Mushi.diagnose()`. Callers check this to know whether the widget
402
- * could ever block host-app UI without opening a browser devtools.
403
- */
407
+ /** Host-layer health snapshot for `Mushi.diagnose()`. */
404
408
  getWidgetDiagnostics(): {
405
409
  widgetHostPointerSafe: boolean;
406
410
  widgetHostBounds: {
@@ -418,51 +422,51 @@ declare class MushiWidget {
418
422
  /** CSS property applied to documentElement so host-app content doesn't slide under the banner. */
419
423
  private static readonly BODY_NUDGE_PROP;
420
424
  private applyBodyNudge;
421
- /**
422
- * Schedule a height measurement after the next paint and set up a ResizeObserver
423
- * so --mushi-banner-offset always tracks the actual rendered banner height
424
- * (which can exceed BANNER_HEIGHT when safe-area-inset-top is in play on iOS,
425
- * or when rich-layout text wraps on narrow viewports).
426
- */
425
+ /** Track the real banner height (safe-area insets, wrapped text) into --mushi-banner-offset. */
427
426
  private trackBannerHeight;
428
427
  private removeBodyNudge;
428
+ /** Rebuild the banner only when something it shows changed. */
429
+ private syncBanner;
429
430
  private renderBanner;
430
431
  private effectiveTrigger;
431
432
  private isMobileSmartHidden;
432
433
  private detectEnvironment;
433
434
  private isRouteHidden;
434
435
  private getTheme;
435
- /** Snapshot in-progress form input from the live DOM before teardown. */
436
- private captureFormDrafts;
437
- /** Replay captured drafts (value + focus + caret) into a freshly built panel. */
438
- private restoreFormDrafts;
439
- private clearFormDrafts;
440
- private render;
436
+ /** Parse any CSS colour the browser understands into [r, g, b] (null when it can't). */
437
+ private probeRgb;
441
438
  /**
442
- * Queries each `avoidSelectors` element in the host document and returns
443
- * the minimum top-offset in px so that a top-anchored element clears all
444
- * of them by `gap` pixels. Returns `null` when no selectors are provided
445
- * or no matching elements have a non-zero bounding rect.
446
- *
447
- * Runs in the host document (not shadow DOM) so it can reach fixed headers,
448
- * sticky nav bars, and sign-in CTAs.
439
+ * Accent resolution (Plan 018 §1.4, first match wins): `widget.accent` →
440
+ * the host's `--mushi-accent` on :root → `accent-color` of <html> →
441
+ * `<meta name="theme-color">` → the foreground ink (''). Page-sourced values
442
+ * must parse as a colour and keep 3:1 against the panel background, or the
443
+ * Send button could vanish into a page-coloured accent.
449
444
  */
445
+ private resolveAccent;
446
+ /** Style + banner + trigger. Each rebuilds only when its inputs changed. */
447
+ private syncChrome;
448
+ private syncTrigger;
449
+ private buildTrigger;
450
+ private render;
451
+ private renderPanel;
452
+ /** On a new surface: the report textarea, else the title, so screen readers announce where they are. */
453
+ private focusView;
454
+ /** Snapshot field values + caret from the live DOM before a patch. */
455
+ private captureFormDrafts;
456
+ /** Replay values (and focus + caret) into fields a patch just created. */
457
+ private restoreFormDrafts;
458
+ /** Queries `avoidSelectors` and returns a top offset clearing all of them, or null. */
450
459
  private computeAvoidTopPx;
451
- /**
452
- * Minimum bottom-offset in px so a bottom-anchored trigger clears avoided
453
- * elements (tab bars, fixed CTAs). Mirrors {@link computeAvoidTopPx}.
454
- */
460
+ /** Bottom offset so a bottom-anchored trigger clears avoided elements (tab bars, fixed CTAs). */
455
461
  private computeAvoidBottomPx;
456
462
  private applyInsetVars;
457
463
  /** Storage key for the FAB position, scoped to projectId when available. */
458
464
  private fabStorageKey;
459
- /** Move the FAB to the given translated offset (relative to the inset origin),
460
- * clamping inside viewport safe area, and optionally snap to nearest edge.
461
- *
462
- * The FAB's CSS anchor can be any corner (bottom-right, bottom-left, …) so we
463
- * must derive the *base* position (CSS anchor with zero drag offset) to compute
464
- * correct clamp bounds and snap targets. We do this by subtracting the
465
- * already-applied drag offset from the live getBoundingClientRect() value. */
465
+ /**
466
+ * Move the FAB to a translated offset (relative to its CSS anchor), clamped
467
+ * inside the viewport safe area, optionally snapping to the nearest edge.
468
+ * The base position is derived by subtracting the applied drag offset.
469
+ */
466
470
  private moveFab;
467
471
  /** Load previously persisted FAB position. */
468
472
  private loadFabPos;
@@ -472,36 +476,78 @@ declare class MushiWidget {
472
476
  private attachViewportHandlers;
473
477
  private teardownViewportHandlers;
474
478
  /**
475
- * Minimum description length, lowered for CJK locales where each character
476
- * carries more meaning. Used by both the view layer (via renderCtx) and the
477
- * details-step input validation in attachHandlers.
479
+ * Minimum description length (default 8, Plan 018 §1.1), halved for CJK
480
+ * locales where each character carries more meaning.
478
481
  */
479
482
  private effectiveMinLength;
480
- /** Tier accent colour for the rewards UI. */
481
- private tierColor;
482
- /**
483
- * Build the read-only snapshot + bound helper closures the stateless view
484
- * layer (widget-render.ts) renders from. Rebuilt once per render() pass so
485
- * the HTML always reflects current state.
486
- */
487
- private renderCtx;
488
- private attachHandlers;
489
- private trapFocus;
483
+ /** Enough words, or something the reporter attached on purpose. */
484
+ private canSend;
490
485
  private unreadCount;
486
+ /** Read-only snapshot + helper closures for the stateless view layer. */
487
+ private renderCtx;
488
+ private bindPanelEvents;
489
+ private onKeydown;
490
+ /** Keep Tab inside the open dialog (APG modal pattern). */
491
+ private trapTab;
492
+ private handleAction;
493
+ private goBack;
494
+ private submitReport;
491
495
  private loadFeatureBoard;
492
496
  private voteFeatureBoard;
497
+ /**
498
+ * Run a thread action (feedback / reopen) without leaving or blanking the
499
+ * thread: the action buttons disable, then status + timeline refresh in place.
500
+ */
501
+ private runThreadAction;
493
502
  private submitReporterReopen;
494
- /** Refresh My Reports data for unread badges without opening the inbox panel. */
503
+ private submitReporterFeedback;
504
+ /** Refresh "Your reports" quietly (badge + list + open row); never disturbs what the reporter is typing. */
495
505
  refreshReporterInboxQuiet(): Promise<void>;
496
- /** Patch the "Your reports (N new)" nav label in place, if it is rendered. */
497
- private updateReportsBadgeText;
498
506
  private loadReporterReports;
499
- private loadReporterComments;
500
- private submitReporterFeedback;
507
+ /** "Track it" on the receipt → that report's thread. */
508
+ private openTrackedReport;
509
+ /**
510
+ * Open (or refresh) a thread. The card paints at once from the list row;
511
+ * only the timeline shows a skeleton. `quiet` keeps what is on screen.
512
+ */
513
+ private openThread;
514
+ /** Opening a thread marks its updates read so the badge goes down (§2.3). */
515
+ private markRead;
516
+ /** Optimistic reply: the bubble shows at once as "Sending…", then lands or offers Retry. */
501
517
  private submitReporterReply;
518
+ private sendPendingReply;
519
+ private saveEmailOptIn;
520
+ private subscribePush;
521
+ /**
522
+ * One toast near the launcher: "The developer replied to your report",
523
+ * "Fixed in v1.4", "3 updates on your reports". Suppressed wherever the
524
+ * launcher is (hidden routes, hideOnSelector, hide()). View opens the thread.
525
+ */
526
+ showUpdatesToast(reports: MushiReporterReport[]): Promise<boolean>;
527
+ /**
528
+ * Fetch the on-demand views chunk ahead of need (the SDK calls this at idle
529
+ * on a device that has filed a report, so Your reports opens instantly).
530
+ * Devices that never filed one never download it. Never rejects.
531
+ */
532
+ preloadViews(): Promise<void>;
533
+ /** The toast from GET /v1/reporter/updates (core's wording), naming the report when there is one. */
534
+ showUpdatesFeedToast(updates: MushiReporterUpdates, reports: MushiReporterReport[]): boolean;
535
+ showUpdateToast(update: {
536
+ text: string;
537
+ reportId?: string | null;
538
+ detail?: string;
539
+ }): boolean;
540
+ private removeToast;
541
+ private rememberOpener;
542
+ /** Return focus to whatever opened the dialog; the trigger may have been rebuilt meanwhile. */
543
+ private restoreOpenerFocus;
544
+ /** Polite screen-reader announcement ("Sent", "Reply sent", errors). */
545
+ private announce;
502
546
  private handleMagicLinkSend;
547
+ /** Open the widget on "Your reports" (`sdk.openReporter()`, the banner's link, a toast). */
548
+ openReporter(): void;
503
549
  getRecorderStep(): WidgetStep;
504
- /** QA / Playwright: category-step IA without piercing closed shadow from page JS. */
550
+ /** QA / Playwright: report-screen IA without piercing the shadow root. */
505
551
  getRecorderCategoryStepIA(): {
506
552
  sectionLabel: string;
507
553
  moreToggle: boolean;
@@ -512,12 +558,6 @@ declare class MushiWidget {
512
558
  getRecorderIntentButton(label: string): Element | null;
513
559
  getRecorderSubmitButton(): Element | null;
514
560
  recorderClickTrigger(): void;
515
- /**
516
- * Open the widget directly to the reporter's "My reports" history view.
517
- * Can be called from host apps via `sdk.openReporter()` or triggered by
518
- * the banner's "My reports" link button.
519
- */
520
- openReporter(): void;
521
561
  recorderSelectCategory(category: MushiReportCategory): void;
522
562
  recorderSelectIntent(label: string): void;
523
563
  recorderFocusDescription(): void;
@@ -525,6 +565,324 @@ declare class MushiWidget {
525
565
  recorderOpenMyReports(): void;
526
566
  }
527
567
 
568
+ interface ConsoleCapture {
569
+ getEntries(): MushiConsoleEntry[];
570
+ clear(): void;
571
+ destroy(): void;
572
+ }
573
+ declare function createConsoleCapture(): ConsoleCapture;
574
+
575
+ interface NetworkCapture {
576
+ getEntries(): MushiNetworkEntry[];
577
+ clear(): void;
578
+ updateOptions(options: NetworkCaptureOptions): void;
579
+ destroy(): void;
580
+ }
581
+ interface NetworkCaptureOptions {
582
+ apiEndpoint?: string;
583
+ ignoreUrls?: MushiUrlMatcher[];
584
+ tracePropagation?: MushiTracePropagationConfig;
585
+ sessionId?: string;
586
+ }
587
+ declare function createNetworkCapture(options?: NetworkCaptureOptions): NetworkCapture;
588
+
589
+ interface PerformanceCapture {
590
+ getMetrics(): MushiPerformanceMetrics;
591
+ destroy(): void;
592
+ }
593
+ declare function createPerformanceCapture(): PerformanceCapture;
594
+
595
+ interface ElementSelector {
596
+ activate(): Promise<MushiSelectedElement | null>;
597
+ deactivate(): void;
598
+ isActive(): boolean;
599
+ }
600
+ declare function createElementSelector(): ElementSelector;
601
+
602
+ interface TimelineCapture {
603
+ setScreen(screen: {
604
+ name: string;
605
+ route?: string;
606
+ feature?: string;
607
+ }): void;
608
+ getEntries(input?: {
609
+ consoleLogs?: MushiConsoleEntry[] | null;
610
+ networkLogs?: MushiNetworkEntry[] | null;
611
+ }): MushiTimelineEntry[];
612
+ clear(): void;
613
+ destroy(): void;
614
+ }
615
+ declare function createTimelineCapture(): TimelineCapture;
616
+
617
+ interface MushiLocale {
618
+ widget: {
619
+ trigger: string;
620
+ title: string;
621
+ close: string;
622
+ back: string;
623
+ submit: string;
624
+ submitting: string;
625
+ submitted: string;
626
+ error: string;
627
+ };
628
+ step1: {
629
+ /** @deprecated The 3-step flow is retired (Plan 018); unused since 1.30. */
630
+ heading?: string;
631
+ /** @deprecated Unused since 1.30. */
632
+ reportSectionLabel?: string;
633
+ /** @deprecated Unused since 1.30. */
634
+ moreNavLabel?: string;
635
+ /** Labels of the header overflow menu. */
636
+ moreNav: {
637
+ /** @deprecated Unused since 1.30 — see `panel.yourReports`. */
638
+ yourReports?: string;
639
+ /** @deprecated Unused since 1.30. */
640
+ yourReportsDesc?: string;
641
+ /** @deprecated Unused since 1.30. */
642
+ unreadNew?: string;
643
+ communityIdeas: string;
644
+ /** @deprecated Unused since 1.30. */
645
+ communityIdeasDesc?: string;
646
+ leaderboard: string;
647
+ joinCommunity: string;
648
+ myAccount: string;
649
+ };
650
+ categories: Record<MushiReportCategory, string>;
651
+ /** @deprecated Unused since 1.30. */
652
+ categoryDescriptions?: Record<MushiReportCategory, string>;
653
+ /** @deprecated Unused since 1.30. */
654
+ moreCategoriesLabel?: string;
655
+ /** @deprecated Unused since 1.30. */
656
+ moreCategoriesCount?: string;
657
+ };
658
+ step2: {
659
+ /** @deprecated Unused since 1.30. */
660
+ heading?: string;
661
+ /** Optional sub-chips shown after a type is picked (the first four, minus "Other"). */
662
+ intents: Record<MushiReportCategory, string[]>;
663
+ };
664
+ step3: {
665
+ /** @deprecated Unused since 1.30. */
666
+ heading?: string;
667
+ /** Placeholder of the one-screen report textarea. */
668
+ descriptionPlaceholder: string;
669
+ /** Placeholder when the Idea chip is picked. */
670
+ featurePlaceholder: string;
671
+ /** @deprecated Unused since 1.30. */
672
+ featureExamples?: string[];
673
+ /** @deprecated Unused since 1.30. */
674
+ otherPlaceholder?: string;
675
+ /** Footer shortcut hint; `{key}` is ⌘ on Apple platforms, Ctrl elsewhere. */
676
+ submitHint: string;
677
+ /** @deprecated Unused since 1.30 — the hint is "Add a few words". */
678
+ charsNeeded?: string;
679
+ screenshotButton: string;
680
+ screenshotAttached: string;
681
+ screenshotCapturing: string;
682
+ /** @deprecated The web widget now shows `screenshotRetry` + `screenshotErrors`; kept for type compatibility. */
683
+ screenshotFailed?: string;
684
+ /** Screenshot button label after a failed capture. */
685
+ screenshotRetry: string;
686
+ /** Offered after a failed capture: user-consented tab share (getDisplayMedia). */
687
+ screenshotShareTab: string;
688
+ /** Why the last capture failed, shown under the attachment row. */
689
+ screenshotErrors: {
690
+ permission: string;
691
+ unsupported: string;
692
+ taint: string;
693
+ timeout: string;
694
+ csp: string;
695
+ error: string;
696
+ };
697
+ /** Alt text for the attached-screenshot preview image. */
698
+ screenshotPreviewAlt: string;
699
+ /** Default privacy caption shown beside the screenshot preview. */
700
+ screenshotSensitiveHint: string;
701
+ elementButton: string;
702
+ elementSelected: string;
703
+ elementCapturing: string;
704
+ elementFailed: string;
705
+ elementSelectorHint: string;
706
+ /** @deprecated Unused since 1.30. */
707
+ optional?: string;
708
+ /** @deprecated Unused since 1.30 — core `reporterCopy().ui.addWords`. */
709
+ tooShort?: string;
710
+ /** @deprecated Unused since 1.30. */
711
+ examplePrompts?: string[];
712
+ };
713
+ /** One-screen report, header and notification copy (Plan 018 §1). */
714
+ panel: {
715
+ /** Report screen title. */
716
+ title: string;
717
+ /** "More…" chip: reveals the host's own categories. */
718
+ more: string;
719
+ /** Element picker button. */
720
+ pointAt: string;
721
+ remove: string;
722
+ markUp: string;
723
+ /** Privacy line under the attachments. */
724
+ privacy: string;
725
+ send: string;
726
+ /** Header pill that opens "Your reports". */
727
+ yourReports: string;
728
+ /** Badge text on the pill; `{n}` placeholder. */
729
+ newCount: string;
730
+ /** Header overflow menu button label. */
731
+ moreOptions: string;
732
+ /** Title of the report detail view. */
733
+ reportTitle: string;
734
+ /** Web push opt-in button. */
735
+ notifyMe: string;
736
+ notifyOn: string;
737
+ };
738
+ assistant: {
739
+ defaultLabel: string;
740
+ defaultGreeting: string;
741
+ inputPlaceholder: string;
742
+ sendAriaLabel: string;
743
+ hubDescription: string;
744
+ thinking: string;
745
+ /** Primary recovery CTA when Ask cannot resolve (clarify / error). */
746
+ fileReportCta: string;
747
+ /** Softer footer escape when the thread already has turns. */
748
+ stillStuckCta: string;
749
+ errors: {
750
+ noResponse: string;
751
+ generic: string;
752
+ };
753
+ };
754
+ flows: {
755
+ /** @deprecated Unused since 1.30 (no brand eyebrow in the header). */
756
+ eyebrows?: {
757
+ inbox: string;
758
+ roadmap: string;
759
+ community: string;
760
+ identity: string;
761
+ signIn: string;
762
+ allApps: string;
763
+ receipt: string;
764
+ thread: string;
765
+ };
766
+ reports: {
767
+ title: string;
768
+ loading: string;
769
+ /** @deprecated Unused since 1.30 — core `ui.empty`. */
770
+ empty?: string;
771
+ /** @deprecated Unused since 1.30. */
772
+ leaderboardLink?: string;
773
+ };
774
+ roadmap: {
775
+ title: string;
776
+ loading: string;
777
+ empty: string;
778
+ shipped: string;
779
+ vote: string;
780
+ voted: string;
781
+ voteCount: string;
782
+ untitled: string;
783
+ };
784
+ leaderboard: {
785
+ title: string;
786
+ loading: string;
787
+ empty: string;
788
+ signInPrompt: string;
789
+ myRank: string;
790
+ footer: string;
791
+ anon: string;
792
+ };
793
+ account: {
794
+ title: string;
795
+ checkEmailTitle: string;
796
+ joinTitle: string;
797
+ emailLabel: string;
798
+ emailPlaceholder: string;
799
+ signInPrompt: string;
800
+ magicLinkSent: string;
801
+ resendEmail: string;
802
+ sendLink: string;
803
+ sending: string;
804
+ crossAppReports: string;
805
+ viewLeaderboard: string;
806
+ signOut: string;
807
+ rankSummary: string;
808
+ };
809
+ crossApp: {
810
+ title: string;
811
+ loading: string;
812
+ empty: string;
813
+ unknownApp: string;
814
+ };
815
+ thread: {
816
+ /** @deprecated Unused since 1.30 — see `panel.reportTitle`. */
817
+ title?: string;
818
+ loading: string;
819
+ /** @deprecated Unused since 1.30 — core `ui.noReplies`. */
820
+ empty?: string;
821
+ /** @deprecated Unused since 1.30 — core `ui.yes`. */
822
+ confirmFixed?: string;
823
+ /** @deprecated Unused since 1.30 — core `ui.notYet`. */
824
+ notFixed?: string;
825
+ replyPlaceholder: string;
826
+ /** @deprecated Unused since 1.30 — see `panel.send`. */
827
+ send?: string;
828
+ /** @deprecated Unused since 1.30 — core `ui.loadError`. */
829
+ loadFailed?: string;
830
+ /** @deprecated Unused since 1.30 — core `ui.retry`. */
831
+ retry?: string;
832
+ };
833
+ success: {
834
+ /** @deprecated Unused since 1.30 — the receipt title is core `ui.sent`. */
835
+ title?: string;
836
+ /** Closes the panel from the success step. */
837
+ done: string;
838
+ trackReport: string;
839
+ receipt: string;
840
+ delivering: string;
841
+ queuedOffline: string;
842
+ queuedHint: string;
843
+ rateLimited: string;
844
+ rateLimitedHint: string;
845
+ quotaBlocked: string;
846
+ quotaBlockedHint: string;
847
+ permanentFailed: string;
848
+ permanentFailedHint: string;
849
+ retrying: string;
850
+ retryingHint: string;
851
+ trackOnMushi: string;
852
+ slaDefault: string;
853
+ screenshotDropped: string;
854
+ };
855
+ featureRequest: {
856
+ label: string;
857
+ /** @deprecated Unused since 1.30. */
858
+ description?: string;
859
+ };
860
+ /** Beta-mode strip on the category step. */
861
+ betaStrip: {
862
+ /** Default status line when the host sets no message; `{appName}` placeholder. */
863
+ defaultMessage: string;
864
+ /** Optional contact line, rendered as a mailto link; `{email}` placeholder. Nothing is emailed. */
865
+ contactHint: string;
866
+ /** Who sees the report; `{appName}` placeholder. */
867
+ teamSees: string;
868
+ /** Same, when the host gave no app name. */
869
+ teamSeesGeneric: string;
870
+ /** aria-label for the strip. */
871
+ ariaLabel: string;
872
+ };
873
+ /** Collapsible changelog row (beta mode). */
874
+ changelog: {
875
+ /** `{version}` placeholder. */
876
+ whatsNew: string;
877
+ };
878
+ /** Link text of the "Bug reports by Mushi" mark (widget.brandFooter). No placeholders. */
879
+ poweredBy: string;
880
+ };
881
+ }
882
+
883
+ declare function getLocale(code?: string): MushiLocale;
884
+ declare function getAvailableLocales(): string[];
885
+
528
886
  /**
529
887
  * FILE: packages/web/src/build-widget-theme.ts
530
888
  * PURPOSE: Resolve Shadow-DOM CSS variables from @mushi-mushi/core tokens.
@@ -697,4 +1055,4 @@ interface ProactiveTriggerCleanup {
697
1055
  }
698
1056
  declare function setupProactiveTriggers(callbacks: ProactiveTriggerCallbacks, config?: ProactiveTriggerConfig): ProactiveTriggerCleanup;
699
1057
 
700
- export { Mushi, MushiWidget, type ProactiveConfig, type ProactiveManager, type ProactiveTriggerCallbacks, type ProactiveTriggerCleanup, type WidgetThemeVars, createProactiveManager, getWidgetPreviewTokens, getWidgetThemeVars, setupProactiveTriggers };
1058
+ export { type ConsoleCapture, type ElementSelector, Mushi, type MushiLocale, MushiWidget, type NetworkCapture, type PerformanceCapture, type ProactiveConfig, type ProactiveManager, type ProactiveTriggerCallbacks, type ProactiveTriggerCleanup, type ScreenshotCapture, type TimelineCapture, type WidgetThemeVars, createConsoleCapture, createElementSelector, createNetworkCapture, createPerformanceCapture, createProactiveManager, createScreenshotCapture, createTimelineCapture, getAvailableLocales, getLocale, getWidgetPreviewTokens, getWidgetThemeVars, setupProactiveTriggers };