@lensmcp/react-instrumentation 1.22.1 → 1.22.3
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/lib/lensmcp-root.js +1 -1
- package/package.json +2 -2
package/lib/fiber-renders.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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");
|
package/lib/lensmcp-root.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var y=Object.defineProperty;var i=(e,r)=>y(e,"name",{value:r,configurable:!0});var R=Object.defineProperty,p=i((e,r)=>R(e,"name",{value:r,configurable:!0}),"c");import{jsx as u}from"react/jsx-runtime";import{Profiler as M,useMemo as $,useRef as s}from"react";import{LensmcpContext as L}from"./context.js";import{publish as x}from"./publish.js";import{makeInstanceId as P}from"./identity.js";import{installFiberRenderPublisher as j}from"./fiber-renders.js";typeof window<"u"&&j();export function LensmcpRoot(e){const r=e.rendererId??"lensmcp-root",l=$(()=>({rendererId:r,page:e.page,route:e.route}),[r,e.page,e.route]),f=s(new Map),d=s(new Map),c=s(void 0),I=p((t,m,g,v,b,h)=>{const a=`render:${r}:${t}`,{instanceId:n}=P(a);let o=d.current.get(t);o===void 0&&(o=n,d.current.set(t,o));const w={id:n,parentRenderId:c.current,componentInstanceId:o,componentLogicalId:a,componentName:t,page:e.page,route:e.route,rendererId:r,phase:m==="mount"?"mount":"update",actualDurationMs:g,baseDurationMs:v,startTime:b,commitTime:h,why:[{type:"force",reason:"profiler-onrender"}]};c.current=n,f.current.set(t,n),x({source:"react",category:"render",severity:"info",title:`render ${t} (${m})`,fingerprint:`react-render:${a}`,raw:{kind:"render",render:w}})},"onRender");return u(L.Provider,{value:l,children:u(M,{id:r,onRender:I,children:e.children})})}i(LensmcpRoot,"LensmcpRoot"),p(LensmcpRoot,"LensmcpRoot");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lensmcp/react-instrumentation",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.3",
|
|
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.
|
|
22
|
+
"@lensmcp/protocol-types": "1.22.3",
|
|
23
23
|
"tslib": "^2.3.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|