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