@lensmcp/vite-plugin 1.18.3 → 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/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export { lensmcpVitePlugin, handleClientEnvelope } from './lib/plugin.js';
2
2
  export type { LensmcpViteOptions, LensmcpViteRuntime, ClientEnvelope } from './lib/types.js';
3
3
  export { envelopeToEvent } from '@lensmcp/bridge';
4
- //# sourceMappingURL=index.d.ts.map
@@ -7,4 +7,3 @@ import type { ClientEnvelope } from './types.js';
7
7
  * `runtime://browser/*` resources.
8
8
  */
9
9
  export declare function envelopeToEvent(env: ClientEnvelope, sessionId?: string): BaseEvent;
10
- //# sourceMappingURL=event-mappers.d.ts.map
package/lib/plugin.d.ts CHANGED
@@ -39,4 +39,3 @@ export declare function lensmcpVitePlugin(options?: LensmcpViteOptions, deps?: B
39
39
  */
40
40
  export declare function handleClientEnvelope(raw: string, deps: BoundDeps): void;
41
41
  export {};
42
- //# sourceMappingURL=plugin.d.ts.map
package/lib/plugin.js CHANGED
@@ -388,20 +388,58 @@ function buildInlineClientRuntime(opts) {
388
388
  };
389
389
 
390
390
  // Errors
391
+ //
392
+ // Bounded at capture so a deep React stack can't push a multi-hundred-KB
393
+ // frame down the socket; the bridge bounds again for anything hand-rolled.
394
+ const MAX_STACK = 4096;
395
+ function clipStr(s, n) {
396
+ if (typeof s !== 'string' || s.length <= n) return s;
397
+ return s.slice(0, n) + '…[lensmcp truncated: ' + (s.length - n) + ' more chars]';
398
+ }
399
+ // A rejected non-Error ({ status: 401 }, a Response) used to be flattened by
400
+ // String(reason) into "[object Object]" — the reason was captured and told
401
+ // you nothing.
402
+ function describeReason(r) {
403
+ if (r === null || r === undefined) return String(r);
404
+ if (typeof r === 'string') return r;
405
+ if (typeof r.message === 'string' && r.message) return r.message;
406
+ try { const j = JSON.stringify(r); if (j && j !== '{}' && j !== 'null') return j; } catch (err) {}
407
+ return String(r);
408
+ }
391
409
  window.addEventListener('error', (e) => {
410
+ // This listener is registered in the CAPTURE phase, which means it also
411
+ // receives subresource load failures (<img>, <script>, <link>, <video>).
412
+ // Those arrive as a plain Event, NOT an ErrorEvent: no message, no
413
+ // filename, no lineno — the only identity is the target element and its
414
+ // URL. Reading only the ErrorEvent fields (as this did) serialised every
415
+ // one of them to a bare { kind:'error', at, tabId } and lost the lot.
416
+ const t = e.target;
417
+ if (t && t !== window && t.tagName && !e.message) {
418
+ send({
419
+ kind: 'resource-error',
420
+ tagName: String(t.tagName).toLowerCase(),
421
+ url: t.currentSrc || t.src || t.href || undefined,
422
+ });
423
+ return;
424
+ }
425
+ const err = e.error;
392
426
  send({
393
427
  kind: 'error',
394
428
  message: e.message,
395
- stack: e.error && e.error.stack,
429
+ name: err && err.name,
430
+ stack: clipStr(err && err.stack, MAX_STACK),
396
431
  source: e.filename,
397
432
  lineno: e.lineno,
398
433
  colno: e.colno,
399
434
  });
400
435
  }, true);
401
436
  window.addEventListener('unhandledrejection', (e) => {
437
+ const r = e.reason;
402
438
  send({
403
439
  kind: 'unhandledrejection',
404
- reason: e.reason && (e.reason.stack || e.reason.message || String(e.reason)),
440
+ reason: clipStr(describeReason(r), MAX_STACK),
441
+ name: r && r.name,
442
+ stack: clipStr(r && r.stack, MAX_STACK),
405
443
  });
406
444
  });
407
445
 
@@ -426,7 +464,7 @@ function buildInlineClientRuntime(opts) {
426
464
  const flowFetchActive = !!window.__LENSMCP_FLOW_FETCH__;
427
465
  try {
428
466
  const res = await origFetch(input, init);
429
- if (!flowFetchActive) send({ kind: 'fetch', method, url, status: res.status, ok: res.ok, durationMs: Date.now() - start });
467
+ if (!flowFetchActive) send({ kind: 'fetch', method, url, status: res.status, statusText: res.statusText, ok: res.ok, durationMs: Date.now() - start });
430
468
  return res;
431
469
  } catch (err) {
432
470
  if (!flowFetchActive) send({ kind: 'fetch', method, url, error: err && (err.message || String(err)), durationMs: Date.now() - start });
package/lib/types.d.ts CHANGED
@@ -26,4 +26,3 @@ export interface LensmcpViteRuntime {
26
26
  */
27
27
  wsPort(): number | undefined;
28
28
  }
29
- //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/vite-plugin",
3
- "version": "1.18.3",
3
+ "version": "1.18.4",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -15,11 +15,11 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@babel/core": "^7.0.0",
18
- "@lensmcp/bridge": "1.18.3",
19
- "@lensmcp/core": "1.18.3",
20
- "@lensmcp/protocol-types": "1.18.3",
21
- "@lensmcp/react-instrumentation": "1.18.3",
22
- "@lensmcp/valtio-instrumentation": "1.18.3",
18
+ "@lensmcp/bridge": "1.18.4",
19
+ "@lensmcp/core": "1.18.4",
20
+ "@lensmcp/protocol-types": "1.18.4",
21
+ "@lensmcp/react-instrumentation": "1.18.4",
22
+ "@lensmcp/valtio-instrumentation": "1.18.4",
23
23
  "tslib": "^2.3.0"
24
24
  },
25
25
  "peerDependencies": {
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,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAG7F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-mappers.d.ts","sourceRoot":"","sources":["../../src/lib/event-mappers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIjD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,cAAc,EAAE,SAAS,SAAyB,GAAG,SAAS,CAuIlG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/lib/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAElD,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAOjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAKzE,UAAU,SAAS;IACjB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,kBAAuB,EAChC,IAAI,GAAE,SAAc,GACnB,MAAM,GAAG,kBAAkB,CAwL7B;AAqCD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,CAEvE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,sEAAsE;IACtE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oFAAoF;IACpF,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,MAAM,IAAI,MAAM,GAAG,SAAS,CAAC;CAC9B"}