@lensmcp/vite-plugin 1.16.33 → 1.17.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.
Files changed (2) hide show
  1. package/lib/plugin.js +44 -2
  2. package/package.json +6 -6
package/lib/plugin.js CHANGED
@@ -256,6 +256,44 @@ function buildInlineClientRuntime(opts) {
256
256
  if (window.__LENSMCP_CLIENT__) return;
257
257
  window.__LENSMCP_CLIENT__ = true;
258
258
 
259
+ // React DevTools hook shim/patch — this script is the FIRST module script in
260
+ // the document, so it runs BEFORE react-dom evaluates. react-dom only calls
261
+ // onCommitFiberRoot when a hook exists at its module init, so installing (or
262
+ // patching) it here is what gives @lensmcp/react-instrumentation per-commit
263
+ // fiber roots for per-component render attribution. When another hook is
264
+ // already present (React DevTools extension, react-refresh preamble) we
265
+ // CHAIN its onCommitFiberRoot — never replace it.
266
+ (() => {
267
+ try {
268
+ const subs = new Set();
269
+ window.__LENSMCP_FIBER__ = { subscribe(fn) { subs.add(fn); return () => subs.delete(fn); } };
270
+ const notify = (id, root) => { for (const fn of subs) { try { fn(id, root); } catch (e) {} } };
271
+ const existing = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
272
+ if (existing) {
273
+ const orig = typeof existing.onCommitFiberRoot === 'function' ? existing.onCommitFiberRoot.bind(existing) : null;
274
+ existing.onCommitFiberRoot = function(id, root, prio, didError) {
275
+ notify(id, root);
276
+ if (orig) return orig(id, root, prio, didError);
277
+ };
278
+ } else {
279
+ let nextRendererId = 1;
280
+ window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = {
281
+ renderers: new Map(),
282
+ supportsFiber: true,
283
+ isDisabled: false,
284
+ inject(renderer) { const id = nextRendererId++; this.renderers.set(id, renderer); return id; },
285
+ on() {}, off() {}, sub() { return () => {}; }, emit() {},
286
+ checkDCE() {},
287
+ onScheduleFiberRoot() {},
288
+ onCommitFiberRoot(id, root) { notify(id, root); },
289
+ onCommitFiberUnmount() {},
290
+ onPostCommitFiberRoot() {},
291
+ setStrictMode() {},
292
+ };
293
+ }
294
+ } catch (e) { /* strictly passive — never break the host page */ }
295
+ })();
296
+
259
297
  const WS_URL = 'ws://${opts.host}:${opts.port}';
260
298
  let ws = null;
261
299
  let queue = [];
@@ -343,12 +381,16 @@ function buildInlineClientRuntime(opts) {
343
381
  const method = (init && init.method) || (input && input.method) || 'GET';
344
382
  const url = typeof input === 'string' ? input : (input && (input.url || String(input)));
345
383
  const start = Date.now();
384
+ // flow-fetch (@lensmcp/react-instrumentation) wraps fetch OUTSIDE this
385
+ // wrapper and publishes flow-correlated network events for the same
386
+ // request — sending ours too double-counts every fetch in the timeline.
387
+ const flowFetchActive = !!window.__LENSMCP_FLOW_FETCH__;
346
388
  try {
347
389
  const res = await origFetch(input, init);
348
- send({ kind: 'fetch', method, url, status: res.status, ok: res.ok, durationMs: Date.now() - start });
390
+ if (!flowFetchActive) send({ kind: 'fetch', method, url, status: res.status, ok: res.ok, durationMs: Date.now() - start });
349
391
  return res;
350
392
  } catch (err) {
351
- send({ kind: 'fetch', method, url, error: err && (err.message || String(err)), durationMs: Date.now() - start });
393
+ if (!flowFetchActive) send({ kind: 'fetch', method, url, error: err && (err.message || String(err)), durationMs: Date.now() - start });
352
394
  throw err;
353
395
  }
354
396
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/vite-plugin",
3
- "version": "1.16.33",
3
+ "version": "1.17.1",
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.16.33",
19
- "@lensmcp/core": "1.16.33",
20
- "@lensmcp/protocol-types": "1.16.33",
21
- "@lensmcp/react-instrumentation": "1.16.33",
22
- "@lensmcp/valtio-instrumentation": "1.16.33",
18
+ "@lensmcp/bridge": "1.17.1",
19
+ "@lensmcp/core": "1.17.1",
20
+ "@lensmcp/protocol-types": "1.17.1",
21
+ "@lensmcp/react-instrumentation": "1.17.1",
22
+ "@lensmcp/valtio-instrumentation": "1.17.1",
23
23
  "tslib": "^2.3.0"
24
24
  },
25
25
  "peerDependencies": {