@lensmcp/client-runtime 1.18.2 → 1.18.4

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/auto.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export { installLensmcp, resolveLensmcpWsUrl, type AutoInstallOptions } from './lib/auto.js';
2
- //# sourceMappingURL=auto.d.ts.map
package/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export { installClientRuntime, type InstallOptions } from './lib/install.js';
2
2
  export { installLensmcp, resolveLensmcpWsUrl, type AutoInstallOptions, } from './lib/auto.js';
3
- //# sourceMappingURL=index.d.ts.map
package/lib/auto.d.ts CHANGED
@@ -13,4 +13,3 @@ export declare function resolveLensmcpWsUrl(override?: string): string;
13
13
  * idempotent (the underlying runtime guards against double-install).
14
14
  */
15
15
  export declare function installLensmcp(opts?: AutoInstallOptions): void;
16
- //# sourceMappingURL=auto.d.ts.map
package/lib/install.d.ts CHANGED
@@ -32,4 +32,3 @@ declare global {
32
32
  }
33
33
  export declare function installClientRuntime(opts: InstallOptions): void;
34
34
  export {};
35
- //# sourceMappingURL=install.d.ts.map
package/lib/install.js CHANGED
@@ -75,10 +75,27 @@ export function installClientRuntime(opts) {
75
75
  };
76
76
  // Errors
77
77
  window.addEventListener('error', (e) => {
78
+ // Registered in the CAPTURE phase, so this also receives subresource
79
+ // load failures (<img>, <script>, <link>, <video>). Those are a plain
80
+ // Event, not an ErrorEvent — no message, no filename, no lineno; the
81
+ // only identity is the target element and its URL. Reading just the
82
+ // ErrorEvent fields (as this did) reduced every one of them to a bare
83
+ // `{ kind: 'error', at, tabId }` with nothing to diagnose.
84
+ const target = e.target;
85
+ if (target && target !== window && target.tagName && !e.message) {
86
+ send({
87
+ kind: 'resource-error',
88
+ tagName: target.tagName.toLowerCase(),
89
+ url: target.currentSrc || target.src || target.href || undefined,
90
+ });
91
+ return;
92
+ }
93
+ const err = e.error;
78
94
  send({
79
95
  kind: 'error',
80
96
  message: e.message,
81
- stack: e.error?.stack,
97
+ name: err?.name,
98
+ stack: clipStack(err?.stack),
82
99
  source: e.filename,
83
100
  lineno: e.lineno,
84
101
  colno: e.colno,
@@ -86,10 +103,12 @@ export function installClientRuntime(opts) {
86
103
  }, true);
87
104
  window.addEventListener('unhandledrejection', (e) => {
88
105
  const reason = e.reason;
89
- const text = typeof reason === 'object' && reason
90
- ? reason.stack ?? reason.message ?? String(reason)
91
- : String(reason);
92
- send({ kind: 'unhandledrejection', reason: text });
106
+ send({
107
+ kind: 'unhandledrejection',
108
+ reason: clipStack(describeReason(reason)),
109
+ name: typeof reason === 'object' && reason ? reason.name : undefined,
110
+ stack: typeof reason === 'object' && reason ? clipStack(reason.stack) : undefined,
111
+ });
93
112
  });
94
113
  const levels = ['log', 'info', 'warn', 'error', 'debug'];
95
114
  for (const level of levels) {
@@ -115,7 +134,15 @@ export function installClientRuntime(opts) {
115
134
  const start = Date.now();
116
135
  try {
117
136
  const res = await origFetch(input, init);
118
- send({ kind: 'fetch', method, url, status: res.status, ok: res.ok, durationMs: Date.now() - start });
137
+ send({
138
+ kind: 'fetch',
139
+ method,
140
+ url,
141
+ status: res.status,
142
+ statusText: res.statusText,
143
+ ok: res.ok,
144
+ durationMs: Date.now() - start,
145
+ });
119
146
  return res;
120
147
  }
121
148
  catch (err) {
@@ -142,6 +169,40 @@ export function installClientRuntime(opts) {
142
169
  };
143
170
  window.addEventListener('popstate', () => notify());
144
171
  }
172
+ /**
173
+ * Bound a stack at CAPTURE so a deep React tree can't push a multi-hundred-KB
174
+ * frame down the socket. The bridge bounds again (it must — a hand-rolled
175
+ * client is not obliged to do this), and the marker matches the one
176
+ * `@lensmcp/storage` uses for `raw`, so both truncations read the same.
177
+ */
178
+ const MAX_STACK_CHARS = 4096;
179
+ function clipStack(value) {
180
+ if (value === undefined || value.length <= MAX_STACK_CHARS)
181
+ return value;
182
+ return `${value.slice(0, MAX_STACK_CHARS)}…[lensmcp truncated: ${value.length - MAX_STACK_CHARS} more chars]`;
183
+ }
184
+ /**
185
+ * A rejected non-Error — `{ status: 401 }`, a `Response` — used to be
186
+ * flattened by `String(reason)` into `"[object Object]"`: captured, and
187
+ * completely uninformative.
188
+ */
189
+ function describeReason(reason) {
190
+ if (reason === null || reason === undefined)
191
+ return String(reason);
192
+ if (typeof reason === 'string')
193
+ return reason;
194
+ if (typeof reason.message === 'string' && reason.message)
195
+ return reason.message;
196
+ try {
197
+ const json = JSON.stringify(reason);
198
+ if (json && json !== '{}' && json !== 'null')
199
+ return json;
200
+ }
201
+ catch {
202
+ /* circular / non-serialisable — fall through */
203
+ }
204
+ return String(reason);
205
+ }
145
206
  function safe(v) {
146
207
  if (v === null)
147
208
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/client-runtime",
3
- "version": "1.18.2",
3
+ "version": "1.18.4",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
package/auto.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto.d.ts","sourceRoot":"","sources":["../src/auto.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC"}
package/index.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAC"}
package/lib/auto.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto.d.ts","sourceRoot":"","sources":["../../src/lib/auto.ts"],"names":[],"mappings":"AAyBA,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,qEAAqE;AACrE,wBAAgB,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAwB7D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,GAAE,kBAAuB,GAAG,IAAI,CAOlE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/lib/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,cAAc;IAC7B,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAQD,QAAA,MAAM,IAAI,uBAAuB,CAAC;AAElC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC;KAClB;CACF;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CA+H/D"}