@mushi-mushi/web 1.14.0 → 1.14.1

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.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiWidgetConfig, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiLeaderboardEntry, MushiCrossAppReport, MushiTesterReputation, MushiConsoleEntry, MushiNetworkEntry, MushiUrlMatcher, MushiTracePropagationConfig, MushiPrivacyConfig, MushiPerformanceMetrics, MushiSelectedElement, MushiTimelineEntry, MushiApiCascadeConfig } from '@mushi-mushi/core';
1
+ import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiWidgetConfig, MushiLeaderboardEntry, MushiCrossAppReport, MushiTesterReputation, MushiConsoleEntry, MushiNetworkEntry, MushiUrlMatcher, MushiTracePropagationConfig, MushiPrivacyConfig, MushiPerformanceMetrics, MushiSelectedElement, MushiTimelineEntry, MushiApiCascadeConfig } 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
3
 
4
4
  declare class Mushi {
@@ -10,15 +10,30 @@ declare class Mushi {
10
10
  }
11
11
 
12
12
  /**
13
- * FILE: packages/web/src/widget.ts
14
- * PURPOSE: The bug-capture widget — floating trigger + multi-step report
15
- * panel — that mounts into a customer's app via `Mushi.init()`.
13
+ * FILE: packages/web/src/widget-helpers.ts
14
+ * PURPOSE: Stateless helpers, constants, and shared types for the bug-capture
15
+ * widget. Extracted verbatim from widget.ts to keep that file focused
16
+ * on the MushiWidget class (DOM structure, state, lifecycle).
16
17
  *
17
- * DESIGN: Visual styling lives in `./styles.ts` ("Mushi Mushi Editorial":
18
- * paper + sumi ink + 朱 vermillion, serif display + monospace
19
- * metadata, ledger-style step counter, hanko stamp animation on
20
- * success). This file owns the DOM structure, state, and all
21
- * user-facing ARIA / keyboard wiring.
18
+ * OVERVIEW:
19
+ * - Pure functions: reporter-status copy mappers, relative-time formatting,
20
+ * the step-number padder, the submit-shortcut detector, and HTML escaping.
21
+ * - Constants: category icon map, the feature-request intent wire string, the
22
+ * total step count, and the per-step ledger number.
23
+ * - Shared types: WidgetStep, the reporter status tone union, and the public
24
+ * WidgetRewardsState / WidgetSubmitOutcome / WidgetCallbacks contracts (these
25
+ * three are re-exported from widget.ts so existing `./widget` import sites and
26
+ * the package barrel keep working unchanged).
27
+ *
28
+ * DEPENDENCIES:
29
+ * - @mushi-mushi/core — report / reporter wire types referenced by the contracts.
30
+ *
31
+ * USAGE:
32
+ * - Imported by widget.ts (the MushiWidget class) and widget-render.ts (the
33
+ * stateless view layer). No DOM/browser state lives here.
34
+ *
35
+ * NOTES:
36
+ * - Behaviour-preserving move: bodies are identical to the pre-split widget.ts.
22
37
  */
23
38
 
24
39
  type WidgetStep = 'category' | 'intent' | 'details' | 'success' | 'reports' | 'report-detail' | 'leaderboard' | 'roadmap' | 'account' | 'cross-app-reports';
@@ -86,7 +101,11 @@ interface WidgetCallbacks {
86
101
  onGlobalLeaderboardOpen?(): void;
87
102
  /** Fetch cross-app reports for the signed-in tester. */
88
103
  onCrossAppReportsOpen?(): void;
104
+ /** Called when the user signs out of the in-widget community session.
105
+ * Host should clear any persisted tester JWT. */
106
+ onTesterSignOut?(): void;
89
107
  }
108
+
90
109
  declare class MushiWidget {
91
110
  private readonly sdkVersion;
92
111
  private host;
@@ -183,6 +202,7 @@ declare class MushiWidget {
183
202
  private magicLinkSent;
184
203
  private magicLinkEmail;
185
204
  private magicLinkError;
205
+ private magicLinkSending;
186
206
  constructor(config: MushiWidgetConfig | undefined, callbacks: WidgetCallbacks, sdkVersion?: string);
187
207
  mount(): void;
188
208
  getIsMounted(): boolean;
@@ -325,91 +345,20 @@ declare class MushiWidget {
325
345
  /** Lift the panel above the software keyboard using visualViewport. */
326
346
  private attachViewportHandlers;
327
347
  private teardownViewportHandlers;
328
- private renderStep;
329
- private renderOutdatedBanner;
330
- private renderBrandFooter;
331
- /**
332
- * Editorial masthead. Always carries:
333
- * • the brand mark (虫 kanji on vermillion, "MUSHI" in mono above)
334
- * • the page title (serif display)
335
- * • the close affordance
336
- *
337
- * On sub-steps it additionally renders a back button (replacing the
338
- * "MUSHI" eyebrow with a "← BACK" mono link) and a step counter
339
- * ledger ("02 / 03") on the far right.
340
- */
341
- private renderHeader;
342
- /**
343
- * Numeral step indicator: "01 — 02 — 03", with the active step in
344
- * vermillion serif and completed steps struck through in mono.
345
- * Replaces the original three-dot indicator (a generic SaaS pattern).
346
- */
347
- private renderStepIndicator;
348
- private renderCategoryStep;
349
348
  /**
350
- * First-class "Feature request" entry rendered at the top of the
351
- * category step. Beta apps consistently get more useful signal when
352
- * the user has a no-friction path to say "I wish this did X" — burying
353
- * it as an intent under the "Other" category drops feature submissions
354
- * by ~40% in industry studies (Userpilot, Usersnap 2025).
355
- *
356
- * Wire format: still routes through the standard `other` category with
357
- * a `user_category = 'Feature request'` stamp, so we don't need a DB
358
- * migration. The admin console filters on that string to surface the
359
- * Feature-request swimlane.
360
- */
361
- private renderFeatureRequestEntry;
362
- /** Collapsible "What's new" changelog row. Closes the reporter feedback loop. */
363
- private renderBetaChangelog;
364
- /**
365
- * Discreet beta status strip: communicates "work in progress", invites
366
- * feedback, and sets expectations — reducing user frustration while
367
- * nudging the reciprocity instinct ("your reports help us build this").
349
+ * Minimum description length, lowered for CJK locales where each character
350
+ * carries more meaning. Used by both the view layer (via renderCtx) and the
351
+ * details-step input validation in attachHandlers.
368
352
  */
369
- private renderBetaStrip;
370
- private renderReportsStep;
371
- private renderRoadmapStep;
372
- private renderLeaderboardStep;
373
- private renderAccountStep;
374
- private renderCrossAppReportsStep;
375
- private renderReportDetailStep;
376
- private renderIntentStep;
377
353
  private effectiveMinLength;
378
- private renderDetailsStep;
379
- /**
380
- * Editorial success state: 朱印-style red stamp ring with the kanji
381
- * 受 ("received") at its centre, the localised "thank you" string
382
- * in serif below, and a mono ledger receipt ("REPORT · HH:MM:SS").
383
- * The ring + label animations are defined in styles.ts so this stays
384
- * pure markup and `prefers-reduced-motion` flips them to the final
385
- * frame instantly.
386
- */
387
- private renderSuccessStep;
388
- /**
389
- * Two-way receipt block. Until the host's `onSubmit` resolves with a
390
- * server-confirmed report id, we show a discreet "delivering..." pill so
391
- * the user knows their submission is still in flight. Once we have the
392
- * id, we surface a short monospaced id + a copy button + an optional
393
- * "Track on Mushi" deep link to `dashboardUrl/reports/<id>` so the user
394
- * can watch the status walk through queued -> classified -> fixed in
395
- * real time (Peak-End rule: the last impression sticks). If we never
396
- * get an id (offline retry queue), we say so explicitly rather than
397
- * pretending everything is fine.
398
- */
399
- private renderSuccessReceipt;
400
- private renderSlaLine;
354
+ /** Tier accent colour for the rewards UI. */
355
+ private tierColor;
401
356
  /**
402
- * Reciprocity footer on the success step: closes the feedback loop by
403
- * attributing where the report goes, sets a response expectation, and
404
- * reinforces the "beta tester" identity (Peak-End Rule — the last thing
405
- * the user sees shapes their entire impression of the interaction).
357
+ * Build the read-only snapshot + bound helper closures the stateless view
358
+ * layer (widget-render.ts) renders from. Rebuilt once per render() pass so
359
+ * the HTML always reflects current state.
406
360
  */
407
- private renderBetaSuccessFooter;
408
- private tierColor;
409
- /** Compact rewards nudge rendered at the bottom of the category-step body. */
410
- private renderRewardsNudge;
411
- /** Points earned + tier progress shown on the success step. */
412
- private renderSuccessRewards;
361
+ private renderCtx;
413
362
  private attachHandlers;
414
363
  private trapFocus;
415
364
  private unreadCount;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiWidgetConfig, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiLeaderboardEntry, MushiCrossAppReport, MushiTesterReputation, MushiConsoleEntry, MushiNetworkEntry, MushiUrlMatcher, MushiTracePropagationConfig, MushiPrivacyConfig, MushiPerformanceMetrics, MushiSelectedElement, MushiTimelineEntry, MushiApiCascadeConfig } from '@mushi-mushi/core';
1
+ import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiWidgetConfig, MushiLeaderboardEntry, MushiCrossAppReport, MushiTesterReputation, MushiConsoleEntry, MushiNetworkEntry, MushiUrlMatcher, MushiTracePropagationConfig, MushiPrivacyConfig, MushiPerformanceMetrics, MushiSelectedElement, MushiTimelineEntry, MushiApiCascadeConfig } 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
3
 
4
4
  declare class Mushi {
@@ -10,15 +10,30 @@ declare class Mushi {
10
10
  }
11
11
 
12
12
  /**
13
- * FILE: packages/web/src/widget.ts
14
- * PURPOSE: The bug-capture widget — floating trigger + multi-step report
15
- * panel — that mounts into a customer's app via `Mushi.init()`.
13
+ * FILE: packages/web/src/widget-helpers.ts
14
+ * PURPOSE: Stateless helpers, constants, and shared types for the bug-capture
15
+ * widget. Extracted verbatim from widget.ts to keep that file focused
16
+ * on the MushiWidget class (DOM structure, state, lifecycle).
16
17
  *
17
- * DESIGN: Visual styling lives in `./styles.ts` ("Mushi Mushi Editorial":
18
- * paper + sumi ink + 朱 vermillion, serif display + monospace
19
- * metadata, ledger-style step counter, hanko stamp animation on
20
- * success). This file owns the DOM structure, state, and all
21
- * user-facing ARIA / keyboard wiring.
18
+ * OVERVIEW:
19
+ * - Pure functions: reporter-status copy mappers, relative-time formatting,
20
+ * the step-number padder, the submit-shortcut detector, and HTML escaping.
21
+ * - Constants: category icon map, the feature-request intent wire string, the
22
+ * total step count, and the per-step ledger number.
23
+ * - Shared types: WidgetStep, the reporter status tone union, and the public
24
+ * WidgetRewardsState / WidgetSubmitOutcome / WidgetCallbacks contracts (these
25
+ * three are re-exported from widget.ts so existing `./widget` import sites and
26
+ * the package barrel keep working unchanged).
27
+ *
28
+ * DEPENDENCIES:
29
+ * - @mushi-mushi/core — report / reporter wire types referenced by the contracts.
30
+ *
31
+ * USAGE:
32
+ * - Imported by widget.ts (the MushiWidget class) and widget-render.ts (the
33
+ * stateless view layer). No DOM/browser state lives here.
34
+ *
35
+ * NOTES:
36
+ * - Behaviour-preserving move: bodies are identical to the pre-split widget.ts.
22
37
  */
23
38
 
24
39
  type WidgetStep = 'category' | 'intent' | 'details' | 'success' | 'reports' | 'report-detail' | 'leaderboard' | 'roadmap' | 'account' | 'cross-app-reports';
@@ -86,7 +101,11 @@ interface WidgetCallbacks {
86
101
  onGlobalLeaderboardOpen?(): void;
87
102
  /** Fetch cross-app reports for the signed-in tester. */
88
103
  onCrossAppReportsOpen?(): void;
104
+ /** Called when the user signs out of the in-widget community session.
105
+ * Host should clear any persisted tester JWT. */
106
+ onTesterSignOut?(): void;
89
107
  }
108
+
90
109
  declare class MushiWidget {
91
110
  private readonly sdkVersion;
92
111
  private host;
@@ -183,6 +202,7 @@ declare class MushiWidget {
183
202
  private magicLinkSent;
184
203
  private magicLinkEmail;
185
204
  private magicLinkError;
205
+ private magicLinkSending;
186
206
  constructor(config: MushiWidgetConfig | undefined, callbacks: WidgetCallbacks, sdkVersion?: string);
187
207
  mount(): void;
188
208
  getIsMounted(): boolean;
@@ -325,91 +345,20 @@ declare class MushiWidget {
325
345
  /** Lift the panel above the software keyboard using visualViewport. */
326
346
  private attachViewportHandlers;
327
347
  private teardownViewportHandlers;
328
- private renderStep;
329
- private renderOutdatedBanner;
330
- private renderBrandFooter;
331
- /**
332
- * Editorial masthead. Always carries:
333
- * • the brand mark (虫 kanji on vermillion, "MUSHI" in mono above)
334
- * • the page title (serif display)
335
- * • the close affordance
336
- *
337
- * On sub-steps it additionally renders a back button (replacing the
338
- * "MUSHI" eyebrow with a "← BACK" mono link) and a step counter
339
- * ledger ("02 / 03") on the far right.
340
- */
341
- private renderHeader;
342
- /**
343
- * Numeral step indicator: "01 — 02 — 03", with the active step in
344
- * vermillion serif and completed steps struck through in mono.
345
- * Replaces the original three-dot indicator (a generic SaaS pattern).
346
- */
347
- private renderStepIndicator;
348
- private renderCategoryStep;
349
348
  /**
350
- * First-class "Feature request" entry rendered at the top of the
351
- * category step. Beta apps consistently get more useful signal when
352
- * the user has a no-friction path to say "I wish this did X" — burying
353
- * it as an intent under the "Other" category drops feature submissions
354
- * by ~40% in industry studies (Userpilot, Usersnap 2025).
355
- *
356
- * Wire format: still routes through the standard `other` category with
357
- * a `user_category = 'Feature request'` stamp, so we don't need a DB
358
- * migration. The admin console filters on that string to surface the
359
- * Feature-request swimlane.
360
- */
361
- private renderFeatureRequestEntry;
362
- /** Collapsible "What's new" changelog row. Closes the reporter feedback loop. */
363
- private renderBetaChangelog;
364
- /**
365
- * Discreet beta status strip: communicates "work in progress", invites
366
- * feedback, and sets expectations — reducing user frustration while
367
- * nudging the reciprocity instinct ("your reports help us build this").
349
+ * Minimum description length, lowered for CJK locales where each character
350
+ * carries more meaning. Used by both the view layer (via renderCtx) and the
351
+ * details-step input validation in attachHandlers.
368
352
  */
369
- private renderBetaStrip;
370
- private renderReportsStep;
371
- private renderRoadmapStep;
372
- private renderLeaderboardStep;
373
- private renderAccountStep;
374
- private renderCrossAppReportsStep;
375
- private renderReportDetailStep;
376
- private renderIntentStep;
377
353
  private effectiveMinLength;
378
- private renderDetailsStep;
379
- /**
380
- * Editorial success state: 朱印-style red stamp ring with the kanji
381
- * 受 ("received") at its centre, the localised "thank you" string
382
- * in serif below, and a mono ledger receipt ("REPORT · HH:MM:SS").
383
- * The ring + label animations are defined in styles.ts so this stays
384
- * pure markup and `prefers-reduced-motion` flips them to the final
385
- * frame instantly.
386
- */
387
- private renderSuccessStep;
388
- /**
389
- * Two-way receipt block. Until the host's `onSubmit` resolves with a
390
- * server-confirmed report id, we show a discreet "delivering..." pill so
391
- * the user knows their submission is still in flight. Once we have the
392
- * id, we surface a short monospaced id + a copy button + an optional
393
- * "Track on Mushi" deep link to `dashboardUrl/reports/<id>` so the user
394
- * can watch the status walk through queued -> classified -> fixed in
395
- * real time (Peak-End rule: the last impression sticks). If we never
396
- * get an id (offline retry queue), we say so explicitly rather than
397
- * pretending everything is fine.
398
- */
399
- private renderSuccessReceipt;
400
- private renderSlaLine;
354
+ /** Tier accent colour for the rewards UI. */
355
+ private tierColor;
401
356
  /**
402
- * Reciprocity footer on the success step: closes the feedback loop by
403
- * attributing where the report goes, sets a response expectation, and
404
- * reinforces the "beta tester" identity (Peak-End Rule — the last thing
405
- * the user sees shapes their entire impression of the interaction).
357
+ * Build the read-only snapshot + bound helper closures the stateless view
358
+ * layer (widget-render.ts) renders from. Rebuilt once per render() pass so
359
+ * the HTML always reflects current state.
406
360
  */
407
- private renderBetaSuccessFooter;
408
- private tierColor;
409
- /** Compact rewards nudge rendered at the bottom of the category-step body. */
410
- private renderRewardsNudge;
411
- /** Points earned + tier progress shown on the success step. */
412
- private renderSuccessRewards;
361
+ private renderCtx;
413
362
  private attachHandlers;
414
363
  private trapFocus;
415
364
  private unreadCount;