@lensmcp/react-instrumentation 1.25.68 → 1.25.70
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/loop-monitor.d.ts +5 -0
- package/lib/loop-monitor.js +1 -1
- package/package.json +2 -2
package/lib/loop-monitor.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { EventLoopIdentity } from '@lensmcp/protocol-types';
|
|
2
|
+
/**
|
|
3
|
+
* This page's event loop, for every event the browser publishes. Never throws (issues/closed/test-infra-16): `publish`
|
|
4
|
+
* stamps it on each event, and a `location` the host does not have — a test renderer, an embedded webview — made every
|
|
5
|
+
* publish throw, which turned the React render walk off for the session: it recorded nothing.
|
|
6
|
+
*/
|
|
2
7
|
export declare function browserLoopIdentity(): EventLoopIdentity | undefined;
|
|
3
8
|
/** Observer callbacks run after the long task: stamping the currently active flow would blame the wrong action. */
|
|
4
9
|
export declare function publishLoopStall(entry: Record<string, unknown>, mechanism: 'long-animation-frame' | 'longtask', timeOrigin: number): void;
|
package/lib/loop-monitor.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _=Object.defineProperty;var
|
|
1
|
+
"use strict";var _=Object.defineProperty;var c=(e,r)=>_(e,"name",{value:r,configurable:!0});var y=Object.defineProperty,n=c((e,r)=>y(e,"name",{value:r,configurable:!0}),"n");import{publish as m}from"./publish.js";import{replayMark as w}from"./replay-anchors.js";const h="__LENSMCP_LOOP_IDENTITY__";export function browserLoopIdentity(){if(typeof window>"u"||typeof performance>"u")return;const e=globalThis;let r=e[h];if(!r){let t;try{t=sessionStorage.getItem("lensmcp:tabId")??void 0}catch{}const o=t??Math.random().toString(36).slice(2),s=typeof location<"u"&&typeof location.host=="string"?location.host:"";r={id:`browser:${o}:${performance.timeOrigin}`,runtime:"browser",project:typeof e.__LENSMCP_APP__=="string"?e.__LENSMCP_APP__:s||"app",...t?{tabId:t}:{}},e[h]=r}const i=e.__LENSMCP_REPLAY__;return i?.loadId?{...r,loadId:i.loadId}:r}c(browserLoopIdentity,"browserLoopIdentity"),n(browserLoopIdentity,"browserLoopIdentity");const p=n(e=>typeof e=="number"&&Number.isFinite(e)?Math.max(0,e):0,"finite"),b=n((e,r=200)=>typeof e=="string"&&e?e.slice(0,r):void 0,"short"),v=n(e=>{if(!(typeof e!="string"||!e))try{const r=new URL(e,location.href);return r.username="",r.password="",r.search="",r.hash="",r.href.slice(0,512)}catch{return}},"scriptUrl");export function publishLoopStall(e,r,i){const t=browserLoopIdentity(),o=p(e.duration);if(!t||o<50)return;const s=i+p(e.startTime),u=Array.isArray(e.scripts)?e.scripts:[],g=u.slice(0,8).flatMap(l=>{if(!l||typeof l!="object")return[];const a=l,f=v(a.sourceURL);return f?[{url:f,functionName:b(a.sourceFunctionName),invoker:b(a.invoker),startAt:i+p(a.startTime),durationMs:p(a.duration)}]:[]}),d=`${t.id}:${r}:${s}`;m({source:"react",category:"performance",severity:o>=1e3?"error":"warning",detached:!0,title:`Main thread blocked for ${o.toFixed(1)}ms`,fingerprint:"perf:browser-event-loop-stall",raw:{kind:"event-loop-stall",incidentId:d,loop:t,mechanism:r,state:"recovered",startedAt:s,durationMs:o,scripts:g,scriptsTruncated:u.length>8}}),w("lens/stall",{incidentId:d,startedAt:s,durationMs:o})}c(publishLoopStall,"publishLoopStall"),n(publishLoopStall,"publishLoopStall");export function publishLoopCoverage(e){const r=browserLoopIdentity();r&&m({source:"react",category:"performance",detached:!0,title:"Browser loop monitoring",fingerprint:"perf:browser-loop-status",raw:{kind:"event-loop-status",loop:r,coverage:e?`${e}; browser main thread only. Permanent hangs and browser workers are not measured.`:"Long-task APIs unavailable in this browser."}})}c(publishLoopCoverage,"publishLoopCoverage"),n(publishLoopCoverage,"publishLoopCoverage");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lensmcp/react-instrumentation",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.70",
|
|
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.25.
|
|
22
|
+
"@lensmcp/protocol-types": "1.25.70",
|
|
23
23
|
"tslib": "^2.3.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|