@lensmcp/react-instrumentation 1.22.3 → 1.22.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.
@@ -1 +1 @@
1
- "use strict";var E=Object.defineProperty;var i=(r,t)=>E(r,"name",{value:t,configurable:!0});var k=Object.defineProperty,d=i((r,t)=>k(r,"name",{value:t,configurable:!0}),"c");import{makeInstanceId as y}from"./identity.js";import{publish as h}from"./publish.js";const D=1,S=0,_=1,T=11,C=14,F=15,L=15e3,I=25,N=15,O=8,j=(typeof process<"u"?process.env?.LENSMCP_RENDER_INCLUDE_INTERNALS:void 0)==="1",x=new Set(["Insertion","EmotionGlobal","EmotionCssPropInternal","GlobalStyles","ThemeProvider","CacheProvider"]);function v(r){return!!(x.has(r)||r.startsWith("Styled(")&&/^Styled\([a-z][a-zA-Z0-9-]*\)$/.test(r)||r==="lensmcp-root"||r.startsWith("Lensmcp"))}i(v,"k"),d(v,"isInternalRender");let g=!1,m=!1;function w(r){const t=r.type;if(!(t==null||typeof t=="string"))switch(r.tag){case S:case _:return t.displayName||t.name||void 0;case T:return t.displayName||t.render?.displayName||t.render?.name||void 0;case C:case F:return t.displayName||t.type?.displayName||t.type?.name||t.name||void 0;default:return}}i(w,"A"),d(w,"componentNameOf");function P(r){const t=r.alternate?.memoizedProps,n=r.memoizedProps;if(!t||!n||t===n)return[];const s=[];for(const e of Object.keys(n))if(e!=="children"&&!Object.is(t[e],n[e])&&(s.push(e),s.length>=O))break;return s}i(P,"O"),d(P,"changedPropKeys");const f=new WeakMap;function R(r,t){const n=f.get(r);if(n)return n;const s=r.alternate,e=(s?f.get(s):void 0)??y(t).instanceId;return f.set(r,e),s&&f.set(s,e),e}i(R,"$"),d(R,"stableInstanceId");function $(r){const t=[];let n=0;const s=[];for(r.current.child&&s.push({node:r.current.child,parentName:void 0});s.length>0;){const{node:e,parentName:a}=s.pop();if(n+=1,n>L)break;let l=a;const o=w(e),c=(e.flags&D)!==0;if(o&&c){const u=e.alternate==null,p=[];if(!u){const b=P(e);b.length>0&&p.push({type:"props",changedKeys:b}),a&&p.push({type:"parent-render",parentRenderId:a}),p.length===0&&p.push({type:"react-state",hookIndex:-1})}t.push({name:o,instanceId:R(e,`react:component:(fiber):${o}`),phase:u?"mount":"update",durationMs:typeof e.actualDuration=="number"?e.actualDuration:0,why:p,parentName:a}),l=o}e.sibling&&s.push({node:e.sibling,parentName:a}),e.child&&s.push({node:e.child,parentName:l})}return t}i($,"L"),d($,"collectCommitRenders");function M(r,t){const n=j?r:r.filter(e=>!v(e.name));if(n.length===0)return;const s=n.length>I?[...n].sort((e,a)=>a.durationMs-e.durationMs).slice(0,I):n;for(const e of s){const a=`react:component:(fiber):${e.name}`,{instanceId:l}=y(a),o={id:l,componentInstanceId:e.instanceId,componentLogicalId:a,componentName:e.name,rendererId:"fiber",phase:e.phase,actualDurationMs:e.durationMs,baseDurationMs:e.durationMs,startTime:t,commitTime:t,why:e.why};h({source:"react",category:"render",severity:"info",title:`render ${e.name} (${e.phase})`,fingerprint:`react-render:${a}`,raw:{kind:"render",render:o}})}n.length>s.length&&h({source:"react",category:"render",severity:"debug",title:`render commit truncated: ${n.length-s.length} of ${n.length} renders dropped (per-commit cap)`,fingerprint:"react-render:commit-truncated",raw:{kind:"render-commit-truncated",total:n.length,published:s.length}})}i(M,"v"),d(M,"publishRecords");export function installFiberRenderPublisher(){if(g||m||typeof window>"u")return;const r=window.__LENSMCP_FIBER__;if(!r||typeof r.subscribe!="function")return;g=!0;let t=N,n=0;const s=new Map;let e;const a=d(()=>{if(e=void 0,t=N,n===0)return;const l=[...s.entries()].sort((o,c)=>c[1]-o[1]).slice(0,5);h({source:"react",category:"render",severity:"warning",title:`render storm: ${n} commits/s over budget \u2014 top: ${l.map(([o,c])=>`${o}\xD7${c}`).join(", ")}`,fingerprint:"react-render:storm",raw:{kind:"render-storm",commits:n,components:Object.fromEntries(l)}}),n=0,s.clear()},"flushStorm");r.subscribe((l,o)=>{if(!m)try{if(!o||!o.current)return;const c=$(o);if(c.length===0)return;if(t>0)t-=1,M(c,Date.now());else{n+=1;for(const u of c)s.set(u.name,(s.get(u.name)??0)+1)}e||(e=setTimeout(a,1e3))}catch{m=!0}})}i(installFiberRenderPublisher,"installFiberRenderPublisher"),d(installFiberRenderPublisher,"installFiberRenderPublisher");export function resetFiberRenderPublisherForTests(){g=!1,m=!1}i(resetFiberRenderPublisherForTests,"resetFiberRenderPublisherForTests"),d(resetFiberRenderPublisherForTests,"resetFiberRenderPublisherForTests");
1
+ "use strict";var E=Object.defineProperty;var c=(t,n)=>E(t,"name",{value:n,configurable:!0});var D=Object.defineProperty,d=c((t,n)=>D(t,"name",{value:n,configurable:!0}),"c");import{makeInstanceId as I}from"./identity.js";import{publish as g}from"./publish.js";const S=1,_=0,T=1,C=11,F=14,L=15,O=15e3,w=25,N=15,j=8,v=(typeof process<"u"?process.env?.LENSMCP_RENDER_INCLUDE_INTERNALS:void 0)==="1",x=new Set(["Insertion","EmotionGlobal","EmotionCssPropInternal","GlobalStyles","ThemeProvider","CacheProvider"]);function b(t){return!!(x.has(t)||t.startsWith("Styled(")&&/^Styled\([a-z][a-zA-Z0-9-]*\)$/.test(t)||t==="lensmcp-root"||t.startsWith("Lensmcp"))}c(b,"b"),d(b,"isInternalRender");let y=!1,f=!1;function $(t){const n=t.type;if(!(n==null||typeof n=="string"))switch(t.tag){case _:case T:return n.displayName||n.name||void 0;case C:return n.displayName||n.render?.displayName||n.render?.name||void 0;case F:case L:return n.displayName||n.type?.displayName||n.type?.name||n.name||void 0;default:return}}c($,"A"),d($,"componentNameOf");function P(t){const n=t.alternate?.memoizedProps,r=t.memoizedProps;if(!n||!r||n===r)return[];const o=[];for(const e of Object.keys(r))if(e!=="children"&&!Object.is(n[e],r[e])&&(o.push(e),o.length>=j))break;return o}c(P,"O"),d(P,"changedPropKeys");const h=new WeakMap;function R(t,n){const r=h.get(t);if(r)return r;const o=t.alternate,e=(o?h.get(o):void 0)??I(n).instanceId;return h.set(t,e),o&&h.set(o,e),e}c(R,"$"),d(R,"stableInstanceId");function k(t){const n=[];let r=0;const o=[];for(t.current.child&&o.push({node:t.current.child,parentName:void 0});o.length>0;){const{node:e,parentName:s}=o.pop();if(r+=1,r>O)break;let m=s;const i=$(e),u=(e.flags&S)!==0;if(i&&u){const l=e.alternate==null,a=[];if(!l){const p=P(e);p.length>0&&a.push({type:"props",changedKeys:p}),s&&a.push({type:"parent-render",parentRenderId:s}),a.length===0&&a.push({type:"react-state",hookIndex:-1})}n.push({name:i,instanceId:R(e,`react:component:(fiber):${i}`),phase:l?"mount":"update",durationMs:typeof e.actualDuration=="number"?e.actualDuration:0,why:a,parentName:s}),m=i}e.sibling&&o.push({node:e.sibling,parentName:s}),e.child&&o.push({node:e.child,parentName:m})}return n}c(k,"L"),d(k,"collectCommitRenders");function M(t,n){const r=v?t:t.filter(e=>!b(e.name));if(r.length===0)return;const o=r.length>w?[...r].sort((e,s)=>s.durationMs-e.durationMs).slice(0,w):r;for(const e of o){const s=`react:component:(fiber):${e.name}`,{instanceId:m}=I(s),i={id:m,componentInstanceId:e.instanceId,componentLogicalId:s,componentName:e.name,rendererId:"fiber",phase:e.phase,actualDurationMs:e.durationMs,baseDurationMs:e.durationMs,startTime:n,commitTime:n,why:e.why};g({source:"react",category:"render",severity:"info",title:`render ${e.name} (${e.phase})`,fingerprint:`react-render:${s}`,raw:{kind:"render",render:i}})}r.length>o.length&&g({source:"react",category:"render",severity:"debug",title:`render commit truncated: ${r.length-o.length} of ${r.length} renders dropped (per-commit cap)`,fingerprint:"react-render:commit-truncated",raw:{kind:"render-commit-truncated",total:r.length,published:o.length}})}c(M,"v"),d(M,"publishRecords");export function installFiberRenderPublisher(){if(y||f||typeof window>"u")return;const t=window.__LENSMCP_FIBER__;if(!t||typeof t.subscribe!="function")return;y=!0;let n=N,r=0;const o=new Map;let e=0,s;const m=d(()=>{if(s=void 0,n=N,r===0)return;const i=[...o.entries()].sort((a,p)=>p[1]-a[1]).slice(0,5),u=i.length>0?`top: ${i.map(([a,p])=>`${a}\xD7${p}`).join(", ")}`:"no product component in the commits \u2014 all framework-internal",l=e>0?` (+${e} framework-internal)`:"";g({source:"react",category:"render",severity:"warning",title:`render storm: ${r} commits/s over budget \u2014 ${u}${l}`,fingerprint:"react-render:storm",raw:{kind:"render-storm",commits:r,components:Object.fromEntries(i),internalRenders:e}}),r=0,e=0,o.clear()},"flushStorm");t.subscribe((i,u)=>{if(!f)try{if(!u||!u.current)return;const l=k(u);if(l.length===0)return;if(n>0)n-=1,M(l,Date.now());else{r+=1;for(const a of l){if(!v&&b(a.name)){e+=1;continue}o.set(a.name,(o.get(a.name)??0)+1)}}s||(s=setTimeout(m,1e3))}catch{f=!0}})}c(installFiberRenderPublisher,"installFiberRenderPublisher"),d(installFiberRenderPublisher,"installFiberRenderPublisher");export function resetFiberRenderPublisherForTests(){y=!1,f=!1}c(resetFiberRenderPublisherForTests,"resetFiberRenderPublisherForTests"),d(resetFiberRenderPublisherForTests,"resetFiberRenderPublisherForTests");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/react-instrumentation",
3
- "version": "1.22.3",
3
+ "version": "1.22.4",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -19,7 +19,7 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@lensmcp/protocol-types": "1.22.3",
22
+ "@lensmcp/protocol-types": "1.22.4",
23
23
  "tslib": "^2.3.0"
24
24
  },
25
25
  "peerDependencies": {