@mushi-mushi/web 1.19.2 → 1.20.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 CHANGED
@@ -81,6 +81,18 @@ tooling/
81
81
  tsconfig/ Shared TypeScript configs
82
82
  ```
83
83
 
84
+ ## What we don't accept
85
+
86
+ Knowing this upfront saves everyone time.
87
+
88
+ - **Automated / bulk / AI-slop PRs** — any PR that was opened by a script, an LLM agent acting without meaningful human review, or as part of a parallel bounty-farming sweep is closed on sight. The commit history, branch name, or helper scripts included in the PR make this obvious.
89
+ - **PRs that target the wrong base** — all PRs must branch from and target `master`. PRs targeting `main` or any other branch are closed (and will show an inflated diff that is not your work).
90
+ - **One PR per issue, one issue per PR** — splitting or duplicating work just to collect acknowledgements isn't welcome.
91
+ - **Good-first-issues without claiming first** — comment on the issue to claim it before starting. If two people open PRs for the same issue, the one that commented first is prioritised.
92
+ - **Documentation-only PRs that merely duplicate existing content** — if the information already exists (e.g. in another file in this repo), adding a redundant copy adds noise without value.
93
+
94
+ If a PR violates these policies it will be closed with a brief explanation. No hard feelings — a genuine contribution on the same issue is always welcome.
95
+
84
96
  ## Making Changes
85
97
 
86
98
  1. Create a feature branch from `master`
package/README.md CHANGED
@@ -89,7 +89,7 @@ Each trigger respects its config flag — set `rageClick: false` to disable rage
89
89
 
90
90
  ## Bundle Size
91
91
 
92
- ~7 KB brotli, enforced at **72 KB gzipped** (105 KB uncompressed) via `size-limit` in CI — budget raised for the 2026 editorial widget refresh + screenshot preview/consent surface. Requires `@mushi-mushi/core` as a dependency (not bundled inline). The `./test-utils` entry is a separate artifact and is never pulled into production bundles.
92
+ ~7 KB brotli, enforced at **74 KB gzipped** (105 KB uncompressed) via `size-limit` in CI — budget raised for the 2026 editorial widget refresh + screenshot preview/consent surface + verified-identity display and `screenshotProvider` hook. Requires `@mushi-mushi/core` as a dependency (not bundled inline). The `./test-utils` entry is a separate artifact and is never pulled into production bundles.
93
93
 
94
94
  ## Quick Start
95
95
 
package/dist/index.cjs CHANGED
@@ -1134,6 +1134,16 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
1134
1134
  line-height: 1.4;
1135
1135
  letter-spacing: 0.02em;
1136
1136
  }
1137
+ .mushi-identified-user {
1138
+ margin: 8px 0 0;
1139
+ font-size: 11.5px;
1140
+ color: ${inkMuted};
1141
+ line-height: 1.4;
1142
+ }
1143
+ .mushi-identified-user strong {
1144
+ color: ${ink};
1145
+ font-weight: 600;
1146
+ }
1137
1147
  .mushi-annotate-toolbar {
1138
1148
  display: flex;
1139
1149
  flex-wrap: wrap;
@@ -2057,7 +2067,7 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
2057
2067
 
2058
2068
  // src/version.ts
2059
2069
  var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
2060
- var MUSHI_SDK_VERSION = "1.19.2" ;
2070
+ var MUSHI_SDK_VERSION = "1.20.0" ;
2061
2071
  var CATEGORY_ICONS = {
2062
2072
  bug: "\u26A0\uFE0F",
2063
2073
  slow: "\u{1F40C}",
@@ -2784,6 +2794,7 @@ function renderDetailsStep(ctx) {
2784
2794
  ${ctx.screenshotHint ? `<figcaption class="mushi-screenshot-hint">\u26A0 ${escapeHtml(ctx.screenshotHint)}</figcaption>` : ""}
2785
2795
  </figure>` : ""}
2786
2796
  <div class="mushi-error" style="display:none" role="alert"></div>
2797
+ ${ctx.identifiedUser ? `<p class="mushi-identified-user" aria-label="Reporting as ${escapeHtml(ctx.identifiedUser.name ?? ctx.identifiedUser.email ?? "")}">\u{1F464} Reporting as <strong>${escapeHtml(ctx.identifiedUser.name ?? ctx.identifiedUser.email ?? "you")}</strong></p>` : ""}
2787
2798
  </div>
2788
2799
  <div class="mushi-footer">
2789
2800
  <span class="mushi-footer-hint" aria-hidden="true">\u2318 + ENTER \u2192 send</span>
@@ -3078,6 +3089,13 @@ var MushiWidget = class _MushiWidget {
3078
3089
  fabPos = null;
3079
3090
  /** Cleanup fn for visualViewport keyboard listener. */
3080
3091
  vvCleanup = null;
3092
+ /**
3093
+ * Host-app user identity forwarded via `Mushi.identify()` or
3094
+ * `Mushi.identifyWithToken()`. Used to show "Reporting as <name>"
3095
+ * in the details step so logged-in users know their report is linked.
3096
+ * Independent of the Mushi tester magic-link session below.
3097
+ */
3098
+ identifiedUser = null;
3081
3099
  /** Mushi tester session JWT — set after in-widget sign-in or by mushi.ts. */
3082
3100
  testerJwt = null;
3083
3101
  /** Tester identity (public_handle, display_name). */
@@ -3478,6 +3496,10 @@ var MushiWidget = class _MushiWidget {
3478
3496
  if (this.isOpen && this.step === "leaderboard") this.render();
3479
3497
  }
3480
3498
  // ── Community public setters (called by mushi.ts after API calls) ──────────
3499
+ setIdentifiedUser(user) {
3500
+ this.identifiedUser = user;
3501
+ if (this.isOpen) this.render();
3502
+ }
3481
3503
  setTesterSession(jwt, info) {
3482
3504
  this.testerJwt = jwt;
3483
3505
  this.testerInfo = info;
@@ -4214,6 +4236,7 @@ var MushiWidget = class _MushiWidget {
4214
4236
  lastReportId: this.lastReportId,
4215
4237
  reporterLoading: this.reporterLoading,
4216
4238
  locale: this.locale,
4239
+ identifiedUser: this.identifiedUser,
4217
4240
  testerReputation: this.testerReputation,
4218
4241
  testerInfo: this.testerInfo,
4219
4242
  screenshotCapturing: this.screenshotCapturing,
@@ -6976,7 +6999,9 @@ function createInstance(config) {
6976
6999
  }
6977
7000
  if (activeConfig.capture?.screenshot !== "off") {
6978
7001
  const screenshotOptions = { privacy: activeConfig.privacy };
6979
- if (screenshotCap) {
7002
+ if (activeConfig.capture?.screenshotProvider) {
7003
+ screenshotCap = null;
7004
+ } else if (screenshotCap) {
6980
7005
  screenshotCap.updateOptions(screenshotOptions);
6981
7006
  } else {
6982
7007
  screenshotCap = createScreenshotCapture(screenshotOptions);
@@ -6984,7 +7009,7 @@ function createInstance(config) {
6984
7009
  } else {
6985
7010
  screenshotCap = null;
6986
7011
  }
6987
- if (!screenshotCap) pendingScreenshot = null;
7012
+ if (!screenshotCap && !activeConfig.capture?.screenshotProvider) pendingScreenshot = null;
6988
7013
  widget.setAllowScreenshotRemove(activeConfig.privacy?.allowUserRemoveScreenshot !== false);
6989
7014
  if (activeConfig.capture?.elementSelector !== false) {
6990
7015
  elementSelector ??= createElementSelector();
@@ -7069,7 +7094,22 @@ function createInstance(config) {
7069
7094
  detachAutoBreadcrumbs = installAutoBreadcrumbs(breadcrumbs);
7070
7095
  let screenshotCaptureInFlight = false;
7071
7096
  async function takeScreenshotWithoutChrome() {
7072
- if (!screenshotCap || screenshotCaptureInFlight) return null;
7097
+ if (screenshotCaptureInFlight) return null;
7098
+ const provider = activeConfig.capture?.screenshotProvider;
7099
+ if (provider) {
7100
+ screenshotCaptureInFlight = true;
7101
+ try {
7102
+ const result = await provider();
7103
+ return result ?? null;
7104
+ } catch (err) {
7105
+ log.warn("screenshotProvider threw, falling back to built-in capturer", {
7106
+ error: err instanceof Error ? err.message : String(err)
7107
+ });
7108
+ } finally {
7109
+ screenshotCaptureInFlight = false;
7110
+ }
7111
+ }
7112
+ if (!screenshotCap) return null;
7073
7113
  screenshotCaptureInFlight = true;
7074
7114
  const panelWasVisible = widget.getIsOpen();
7075
7115
  if (panelWasVisible) widget.hidePanel();
@@ -7089,7 +7129,8 @@ function createInstance(config) {
7089
7129
  }
7090
7130
  async function autoCaptureScreenshot(when) {
7091
7131
  const mode = activeConfig.capture?.screenshot;
7092
- if (!screenshotCap || mode === "off" || pendingScreenshot) return;
7132
+ const hasCapture = !!screenshotCap || !!activeConfig.capture?.screenshotProvider;
7133
+ if (!hasCapture || mode === "off" || pendingScreenshot) return;
7093
7134
  if (when === "open" && mode !== "auto") return;
7094
7135
  if (when === "submit" && mode !== "on-report" && mode !== "auto") return;
7095
7136
  log.debug("Auto-capturing screenshot", { when, mode });
@@ -7123,7 +7164,8 @@ function createInstance(config) {
7123
7164
  emit("widget:closed");
7124
7165
  },
7125
7166
  onScreenshotRequest: async () => {
7126
- if (!screenshotCap || activeConfig.capture?.screenshot === "off") return;
7167
+ const hasCapture = !!screenshotCap || !!activeConfig.capture?.screenshotProvider;
7168
+ if (!hasCapture || activeConfig.capture?.screenshot === "off") return;
7127
7169
  log.debug("Taking screenshot");
7128
7170
  pendingScreenshot = await takeScreenshotWithoutChrome();
7129
7171
  widget.setScreenshotAttached(pendingScreenshot !== null);
@@ -7814,6 +7856,9 @@ function createInstance(config) {
7814
7856
  },
7815
7857
  identify(userId, traits) {
7816
7858
  userInfo = { id: userId, ...traits?.email ? { email: traits.email } : {}, ...traits?.name ? { name: traits.name } : {} };
7859
+ widget.setIdentifiedUser(
7860
+ userInfo.name || userInfo.email ? { name: userInfo.name, email: userInfo.email } : null
7861
+ );
7817
7862
  if (traits) {
7818
7863
  for (const [k, v] of Object.entries(traits)) {
7819
7864
  if (k !== "email" && k !== "name") customMetadata[`user.${k}`] = v;
@@ -7862,9 +7907,14 @@ function createInstance(config) {
7862
7907
  ...claims.email ? { email: claims.email } : {},
7863
7908
  ...claims.name ? { name: claims.name } : {}
7864
7909
  };
7910
+ widget.setIdentifiedUser(
7911
+ userInfo.name || userInfo.email ? { name: userInfo.name, email: userInfo.email } : null
7912
+ );
7865
7913
  }
7866
7914
  breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken()" });
7867
7915
  } else {
7916
+ userInfo = null;
7917
+ widget.setIdentifiedUser(null);
7868
7918
  breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken(null)" });
7869
7919
  }
7870
7920
  },