@lensmcp/vite-plugin 1.23.1 → 1.23.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/event-mappers.js +2 -2
- package/lib/plugin.js +28 -7
- package/package.json +6 -6
package/lib/event-mappers.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`).slice(0,2);for(const i of n){const a=i.match(/at\s+(\S+)/);if(a&&a[1])return a[1]}return"unknown"}
|
|
1
|
+
"use strict";var X=Object.defineProperty;var c=(e,n)=>X(e,"name",{value:n,configurable:!0});var Y=Object.defineProperty,s=c((e,n)=>Y(e,"name",{value:n,configurable:!0}),"u"),Z=Object.defineProperty,v=s((e,n)=>Z(e,"name",{value:n,configurable:!0}),"u"),_=Object.defineProperty,f=v((e,n)=>_(e,"name",{value:n,configurable:!0}),"u"),ee=Object.defineProperty,p=f((e,n)=>ee(e,"name",{value:n,configurable:!0}),"u"),ne=Object.defineProperty,d=p((e,n)=>ne(e,"name",{value:n,configurable:!0}),"u"),te=Object.defineProperty,m=d((e,n)=>te(e,"name",{value:n,configurable:!0}),"u"),re=Object.defineProperty,b=m((e,n)=>re(e,"name",{value:n,configurable:!0}),"u"),oe=Object.defineProperty,g=b((e,n)=>oe(e,"name",{value:n,configurable:!0}),"u"),ie=Object.defineProperty,y=g((e,n)=>ie(e,"name",{value:n,configurable:!0}),"u"),ae=Object.defineProperty,j=y((e,n)=>ae(e,"name",{value:n,configurable:!0}),"s"),le=Object.defineProperty,T=j((e,n)=>le(e,"name",{value:n,configurable:!0}),"s"),ue=Object.defineProperty,E=T((e,n)=>ue(e,"name",{value:n,configurable:!0}),"s"),ce=Object.defineProperty,O=E((e,n)=>ce(e,"name",{value:n,configurable:!0}),"c"),se=Object.defineProperty,P=O((e,n)=>se(e,"name",{value:n,configurable:!0}),"c"),ve=Object.defineProperty,I=P((e,n)=>ve(e,"name",{value:n,configurable:!0}),"c"),fe=Object.defineProperty,w=I((e,n)=>fe(e,"name",{value:n,configurable:!0}),"c"),pe=Object.defineProperty,k=w((e,n)=>pe(e,"name",{value:n,configurable:!0}),"c"),de=Object.defineProperty,$=k((e,n)=>de(e,"name",{value:n,configurable:!0}),"c"),me=Object.defineProperty,h=$((e,n)=>me(e,"name",{value:n,configurable:!0}),"l"),be=Object.defineProperty,x=h((e,n)=>be(e,"name",{value:n,configurable:!0}),"l"),ge=Object.defineProperty,S=x((e,n)=>ge(e,"name",{value:n,configurable:!0}),"c"),ye=Object.defineProperty,U=S((e,n)=>ye(e,"name",{value:n,configurable:!0}),"c"),je=Object.defineProperty,R=U((e,n)=>je(e,"name",{value:n,configurable:!0}),"c"),Te=Object.defineProperty,A=R((e,n)=>Te(e,"name",{value:n,configurable:!0}),"u"),Ee=Object.defineProperty,C=A((e,n)=>Ee(e,"name",{value:n,configurable:!0}),"u"),Oe=Object.defineProperty,F=C((e,n)=>Oe(e,"name",{value:n,configurable:!0}),"u"),Pe=Object.defineProperty,J=F((e,n)=>Pe(e,"name",{value:n,configurable:!0}),"c"),Ie=Object.defineProperty,L=J((e,n)=>Ie(e,"name",{value:n,configurable:!0}),"c"),we=Object.defineProperty,N=L((e,n)=>we(e,"name",{value:n,configurable:!0}),"c"),ke=Object.defineProperty,q=N((e,n)=>ke(e,"name",{value:n,configurable:!0}),"u"),$e=Object.defineProperty,z=q((e,n)=>$e(e,"name",{value:n,configurable:!0}),"u"),he=Object.defineProperty,B=z((e,n)=>he(e,"name",{value:n,configurable:!0}),"u"),xe=Object.defineProperty,D=B((e,n)=>xe(e,"name",{value:n,configurable:!0}),"u"),Se=Object.defineProperty,G=D((e,n)=>Se(e,"name",{value:n,configurable:!0}),"o"),Ue=Object.defineProperty,H=G((e,n)=>Ue(e,"name",{value:n,configurable:!0}),"o"),Re=Object.defineProperty,K=H((e,n)=>Re(e,"name",{value:n,configurable:!0}),"o"),Ae=Object.defineProperty,M=K((e,n)=>Ae(e,"name",{value:n,configurable:!0}),"o"),Ce=Object.defineProperty,Q=M((e,n)=>Ce(e,"name",{value:n,configurable:!0}),"o"),Fe=Object.defineProperty,V=Q((e,n)=>Fe(e,"name",{value:n,configurable:!0}),"o");import{fingerprint as l,ulid as u}from"@lensmcp/core";const Je="pending";export function envelopeToEvent(e,n=Je){const i=e.tabId?{tabId:e.tabId}:{};switch(e.kind){case"error":return{id:u(),sessionId:n,timestamp:e.at,source:"client-runtime",category:"runtime",severity:"error",context:{sessionId:n,...i},fingerprint:l({kind:"runtime",identity:`error:${t(e.stack)}`,file:e.source,detail:e.message}),title:e.message,message:e.stack??e.message,location:e.source?{file:e.source,line:e.lineno,column:e.colno}:void 0,raw:e};case"unhandledrejection":return{id:u(),sessionId:n,timestamp:e.at,source:"client-runtime",category:"runtime",severity:"error",context:{sessionId:n,...i},fingerprint:l({kind:"runtime",identity:`unhandledrejection:${e.reason.slice(0,80)}`}),title:"Unhandled promise rejection",message:e.reason,raw:e};case"console":{const a=e.level==="error"?"error":e.level==="warn"?"warning":"info",W=e.args.map(o).join(" ");return{id:u(),sessionId:n,timestamp:e.at,source:"client-runtime",category:"runtime",severity:a,context:{sessionId:n,...i},fingerprint:l({kind:"runtime",identity:`console:${e.level}:${W.slice(0,80)}`}),title:`console.${e.level}`,message:W,raw:e}}case"fetch":{const a=e.error!==void 0||e.status!==void 0&&e.status>=400;return{id:u(),sessionId:n,timestamp:e.at,source:"client-runtime",category:"network",severity:a?"error":"info",context:{sessionId:n,...i},fingerprint:l({kind:"network",identity:`${e.method}:${r(e.url)}:${e.status??"err"}`}),title:`${e.method} ${e.url}${e.status!==void 0?` \u2192 ${e.status}`:""}`,message:e.error,relatedUrls:[e.url],raw:e}}case"route":return{id:u(),sessionId:n,timestamp:e.at,source:"client-runtime",category:"runtime",severity:"info",context:{sessionId:n,url:e.url,...i},fingerprint:l({kind:"runtime",identity:`route:${e.url}`}),title:`Route \u2192 ${e.url}`,raw:e};case"ready":return{id:u(),sessionId:n,timestamp:e.at,source:"client-runtime",category:"runtime",severity:"info",context:{sessionId:n,url:e.url,...i},fingerprint:l({kind:"runtime",identity:"client-ready"}),title:"Client runtime ready",message:e.userAgent,raw:e};case"publish":return{id:u(),sessionId:n,timestamp:e.at,source:e.source,category:e.category,severity:e.severity??"info",context:{sessionId:n,...i,...e.context??{}},fingerprint:e.fingerprint??l({kind:"publish",identity:e.title}),title:e.title,message:e.message,raw:e.raw}}}c(envelopeToEvent,"envelopeToEvent"),s(envelopeToEvent,"envelopeToEvent"),v(envelopeToEvent,"envelopeToEvent"),f(envelopeToEvent,"envelopeToEvent"),p(envelopeToEvent,"envelopeToEvent"),d(envelopeToEvent,"envelopeToEvent"),m(envelopeToEvent,"envelopeToEvent"),b(envelopeToEvent,"envelopeToEvent"),g(envelopeToEvent,"envelopeToEvent"),y(envelopeToEvent,"envelopeToEvent"),j(envelopeToEvent,"envelopeToEvent"),T(envelopeToEvent,"envelopeToEvent"),E(envelopeToEvent,"envelopeToEvent"),O(envelopeToEvent,"envelopeToEvent"),P(envelopeToEvent,"envelopeToEvent"),I(envelopeToEvent,"envelopeToEvent"),w(envelopeToEvent,"envelopeToEvent"),k(envelopeToEvent,"envelopeToEvent"),$(envelopeToEvent,"envelopeToEvent"),h(envelopeToEvent,"envelopeToEvent"),x(envelopeToEvent,"envelopeToEvent"),S(envelopeToEvent,"envelopeToEvent"),U(envelopeToEvent,"envelopeToEvent"),R(envelopeToEvent,"envelopeToEvent"),A(envelopeToEvent,"envelopeToEvent"),C(envelopeToEvent,"envelopeToEvent"),F(envelopeToEvent,"envelopeToEvent"),J(envelopeToEvent,"envelopeToEvent"),L(envelopeToEvent,"envelopeToEvent"),N(envelopeToEvent,"envelopeToEvent"),q(envelopeToEvent,"envelopeToEvent"),z(envelopeToEvent,"envelopeToEvent"),B(envelopeToEvent,"envelopeToEvent"),D(envelopeToEvent,"envelopeToEvent"),G(envelopeToEvent,"envelopeToEvent"),H(envelopeToEvent,"envelopeToEvent"),K(envelopeToEvent,"envelopeToEvent"),M(envelopeToEvent,"envelopeToEvent"),Q(envelopeToEvent,"envelopeToEvent"),V(envelopeToEvent,"envelopeToEvent");function t(e){if(!e)return"unknown";const n=e.split(`
|
|
2
|
+
`).slice(0,2);for(const i of n){const a=i.match(/at\s+(\S+)/);if(a&&a[1])return a[1]}return"unknown"}c(t,"t"),s(t,"t"),v(t,"t"),f(t,"t"),p(t,"t"),d(t,"t"),m(t,"t"),b(t,"t"),g(t,"t"),y(t,"t"),j(t,"t"),T(t,"t"),E(t,"t"),O(t,"t"),P(t,"t"),I(t,"t"),w(t,"n"),k(t,"t"),$(t,"n"),h(t,"t"),x(t,"n"),S(t,"t"),U(t,"n"),R(t,"t"),A(t,"r"),C(t,"t"),F(t,"r"),J(t,"t"),L(t,"n"),N(t,"n"),q(t,"r"),z(t,"n"),B(t,"o"),D(t,"a"),G(t,"l"),H(t,"l"),K(t,"c"),M(t,"c"),Q(t,"s"),V(t,"normaliseStackTopFrame");function r(e){try{return`${new URL(e,"http://x").pathname}`}catch{return e}}c(r,"r"),s(r,"r"),v(r,"r"),f(r,"r"),p(r,"r"),d(r,"r"),m(r,"r"),b(r,"r"),g(r,"r"),y(r,"r"),j(r,"r"),T(r,"r"),E(r,"r"),O(r,"r"),P(r,"r"),I(r,"r"),w(r,"r"),k(r,"r"),$(r,"r"),h(r,"r"),x(r,"r"),S(r,"r"),U(r,"r"),R(r,"r"),A(r,"n"),C(r,"r"),F(r,"n"),J(r,"r"),L(r,"r"),N(r,"r"),q(r,"i"),z(r,"i"),B(r,"a"),D(r,"c"),G(r,"d"),H(r,"d"),K(r,"l"),M(r,"l"),Q(r,"m"),V(r,"normaliseUrl");function o(e){if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}c(o,"o"),s(o,"o"),v(o,"o"),f(o,"o"),p(o,"o"),d(o,"o"),m(o,"i"),b(o,"o"),g(o,"i"),y(o,"i"),j(o,"i"),T(o,"i"),E(o,"i"),O(o,"i"),P(o,"i"),I(o,"i"),w(o,"i"),k(o,"i"),$(o,"i"),h(o,"i"),x(o,"i"),S(o,"i"),U(o,"i"),R(o,"i"),A(o,"i"),C(o,"i"),F(o,"i"),J(o,"i"),L(o,"i"),N(o,"i"),q(o,"o"),z(o,"o"),B(o,"c"),D(o,"u"),G(o,"m"),H(o,"m"),K(o,"d"),M(o,"d"),Q(o,"d"),V(o,"stringify");
|
package/lib/plugin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var U=Object.defineProperty;var g=(e,n)=>U(e,"name",{value:n,configurable:!0});var V=Object.defineProperty,u=g((e,n)=>V(e,"name",{value:n,configurable:!0}),"d");import{existsSync as $,readdirSync as J,statSync as q}from"node:fs";import{delimiter as K,join as C,relative as A,resolve as T,sep as B}from"node:path";import{fingerprint as R,ulid as I}from"@lensmcp/core";import{createBridgeServer as
|
|
1
|
+
"use strict";var U=Object.defineProperty;var g=(e,n)=>U(e,"name",{value:n,configurable:!0});var V=Object.defineProperty,u=g((e,n)=>V(e,"name",{value:n,configurable:!0}),"d");import{existsSync as $,readdirSync as J,statSync as q}from"node:fs";import{delimiter as K,join as C,relative as A,resolve as T,sep as B}from"node:path";import{fingerprint as R,ulid as I}from"@lensmcp/core";import{createBridgeServer as Y,makePublisher as O,handleClientEnvelope as z}from"@lensmcp/bridge";const D="/@lensmcp/client-runtime",L="\0lensmcp-client-runtime",G="/__lensmcp/watcher-health",N=256,Z=64,Q=new Set(["node_modules",".git","dist","tmp","coverage","build","out","target",".nx",".lensmcp"]);export function resolveExtraWatchRoots(e,n){if(!e)return[];const s=T(n),p=u((h,r)=>{const d=A(r,h);return d!==""&&!d.startsWith("..")&&!d.startsWith(B)&&!/^[A-Za-z]:/.test(d)},"inside"),i=[],f=u(h=>{i.length<Z&&!i.includes(h)&&i.push(h)},"push");for(const h of e.split(K)){const r=h.trim();if(!r)continue;const d=T(r);let w;try{w=$(d)&&q(d).isDirectory()}catch{w=!1}if(w&&!(d===s||p(d,s))){if(p(s,d)){const S=A(d,s).split(B).filter(Boolean);let t=d;for(const c of S){let o;try{o=J(t,{withFileTypes:!0})}catch{o=[]}for(const a of o)!a.isDirectory()||a.name===c||a.name.startsWith(".")||Q.has(a.name)||f(C(t,a.name));t=C(t,c)}continue}f(d)}}return i}g(resolveExtraWatchRoots,"resolveExtraWatchRoots"),u(resolveExtraWatchRoots,"resolveExtraWatchRoots");export function lensmcpVitePlugin(e={},n={}){const s=e.enabled??!0,p=e.wsHost??"127.0.0.1",i=e.injectClient??!0;let f,h;const r=O(n),d=e.aliasValtio??!0,w=e.transformSource??!0,S=e.applyOnBuild??process.env.LENSMCP_VITE_APPLY_ON_BUILD==="1";return{name:"@lensmcp/vite-plugin",apply:u((t,c)=>s&&(c.command==="serve"||S),"apply"),enforce:"pre",wsPort:u(()=>f,"wsPort"),config(){if(!(!s||!d))return{resolve:{alias:[{find:/^valtio$/,replacement:"@lensmcp/valtio-instrumentation"}]}}},async configureServer(t){if(!s)return;h=await Y({host:p,port:e.wsPort??0,bus:n.bus,sessionId:n.sessionId}),f=h.port,t.ws.on("vite:error",l=>{r(H(l,n.sessionId))});const c=resolveExtraWatchRoots(process.env.LENSMCP_WATCH_DIRS,t.config?.root??process.cwd());if(c.length>0&&typeof t.watcher?.add=="function")try{t.watcher.add(c),console.log(`[lensmcp] watching ${c.length} extra source root(s) for set changes: ${c.map(l=>A(t.config?.root??process.cwd(),l)||l).join(", ")}`)}catch(l){console.warn(`[lensmcp] could not widen the watcher: ${l?.message??String(l)}`)}let o=0,a=0,_=0;const b=[],m=u((l,v)=>{o=Date.now(),a+=1,_+=1,b.push({sequence:_,kind:l,path:T(v),at:o}),b.length>N&&b.splice(0,b.length-N)},"stampFsSetEvent");t.watcher.on("add",l=>m("add",l)),t.watcher.on("addDir",l=>m("addDir",l)),t.watcher.on("unlink",l=>m("unlink",l)),t.watcher.on("unlinkDir",l=>m("unlinkDir",l)),t.middlewares.use(G,(l,v)=>{v.setHeader("content-type","application/json"),v.setHeader("cache-control","no-store"),v.end(JSON.stringify({schemaVersion:2,ready:!0,sequence:_,lastFsSetEventAt:o,fsSetEvents:a,recentEvents:b,extraWatchRoots:c,now:Date.now()}))})},resolveId(t){return t===D?L:null},load(t){if(t!==L)return null;const c=f??e.wsPort??0;return W({host:p,port:c})},async transform(t,c){if(!s||!w)return null;const o=c.split("?")[0]??c;if(o.includes("/node_modules/")||!/\.[jt]sx$/.test(o))return null;const a=await x(t,o);return a?{code:a.code,map:a.map}:null},transformIndexHtml(){if(!(!i||!s))return[{tag:"script",attrs:{type:"module",src:D},injectTo:"head-prepend"}]},handleHotUpdate(t){if(!s)return;const c=t.modules.map(a=>a.file??a.id??null).filter(a=>!!a),o=hmrReloadCause(t.modules);r({id:I(),sessionId:n.sessionId??"pending",timestamp:Date.now(),source:"vite",category:"build",severity:o.willFullReload?"warning":"info",context:{sessionId:n.sessionId??"pending"},fingerprint:R({kind:"hmr",identity:t.file}),title:o.willFullReload?`HMR ${t.file} \u2014 FULL RELOAD (no boundary above ${o.deadEnd??"it"})`:`HMR ${t.file}`,location:{file:t.file},relatedFiles:c,raw:{kind:"hmr",file:t.file,willFullReload:o.willFullReload,deadEnd:o.deadEnd,chain:o.chain,acceptedBy:o.boundaries}})},generateBundle(t,c){if(!s)return;const o=[];let a=0;for(const b of Object.values(c)){const m=b,l=m.fileName;let v;if(m.type==="chunk")v=(m.code??"").length;else{const y=m.source;v=typeof y=="string"?y.length:y instanceof Uint8Array?y.byteLength:0}a+=v;const k=[];if(m.type==="chunk"&&m.modules){for(const[y,E]of Object.entries(m.modules)){const X=E.renderedLength??E.originalLength??0;k.push({id:y,sizeBytes:X})}k.sort((y,E)=>E.sizeBytes-y.sizeBytes)}o.push({name:l,sizeBytes:v,modules:k})}const _={timestamp:Date.now(),totalBytes:a,chunks:o};r({id:I(),sessionId:n.sessionId??"pending",timestamp:Date.now(),source:"rollup",category:"build",severity:"info",context:{sessionId:n.sessionId??"pending"},fingerprint:R({kind:"bundle",identity:"report"}),title:`Bundle report: ${o.length} chunks, ${a} bytes`,raw:{kind:"bundle-report",report:_}})},async closeBundle(){h&&(await h.close(),h=void 0)}}}g(lensmcpVitePlugin,"lensmcpVitePlugin"),u(lensmcpVitePlugin,"lensmcpVitePlugin");const F=12;export function hmrReloadCause(e){const n=[],s=[],p=new Set;let i=null;const f=u(r=>r.file??r.id??"(anonymous module)","nameOf"),h=u((r,d)=>{if(p.has(r))return!1;if(p.add(r),r.isSelfAccepting===!0)return s.length<F&&s.push(f(r)),!1;const w=[...r.importers??[]];if(w.length===0)return i===null&&(i=f(r),n.push(...d.slice(-F),f(r))),!0;let S=!1;for(const t of w){if(t.acceptedHmrDeps?.has(r)){s.length<F&&s.push(f(t));continue}h(t,[...d,f(r)])&&(S=!0)}return S},"walk");return{willFullReload:e.map(r=>h(r,[])).some(Boolean),deadEnd:i,chain:n,boundaries:s}}g(hmrReloadCause,"hmrReloadCause"),u(hmrReloadCause,"hmrReloadCause");async function x(e,n){try{const[{transformSync:s},{lensmcpBabelPlugin:p}]=await Promise.all([import("@babel/core"),import("@lensmcp/react-instrumentation")]),i=s(e,{filename:n,babelrc:!1,configFile:!1,sourceMaps:!0,parserOpts:{plugins:["jsx","typescript"]},plugins:[[p,{rootDir:process.cwd()}]],code:!0});return i?.code?{code:i.code,map:i.map}:null}catch(s){return j(n,s),null}}g(x,"q"),u(x,"runLensmcpBabel");const M=new Set;function j(e,n){M.has(e)||(M.add(e),console.warn(`[lensmcp] could not instrument ${e}: ${n?.message??n}. The file still builds, but its renders, effects and hooks will be MISSING from react://renders/*, react://effects/recent and react://hooks/recent.`))}g(j,"K"),u(j,"warnTransformFailed");export function resetTransformFailuresForTests(){M.clear()}g(resetTransformFailuresForTests,"resetTransformFailuresForTests"),u(resetTransformFailuresForTests,"resetTransformFailuresForTests");export function handleClientEnvelope(e,n){z(e,O(n),n.sessionId)}g(handleClientEnvelope,"handleClientEnvelope"),u(handleClientEnvelope,"handleClientEnvelope");function P(e){const n=e?.loc?.file??e?.id;return typeof n!="string"||n.length===0?void 0:{file:n.split("?")[0]||n,...typeof e?.loc?.line=="number"?{line:e.loc.line}:{},...typeof e?.loc?.column=="number"?{column:e.loc.column}:{}}}g(P,"Y"),u(P,"errorLocation");function H(e,n){const s=e.err?.message??"Vite error",p=e.err?.stack,i=P(e.err);return{id:I(),sessionId:n??"pending",timestamp:Date.now(),source:"vite",category:"build",severity:"error",context:{sessionId:n??"pending"},fingerprint:R({kind:"vite",identity:e.type??s,...i?{file:i.file}:{}}),title:s,message:p,...i?{location:i}:{},raw:{kind:"build-diagnostic",...i?{file:i.file}:{},...e.err?.plugin?{plugin:e.err.plugin}:{}}}}g(H,"z"),u(H,"viteErrorToEvent");function W(e){return`// @lensmcp/client-runtime (inlined by @lensmcp/vite-plugin)
|
|
2
2
|
(() => {
|
|
3
3
|
if (typeof window === 'undefined') return;
|
|
4
4
|
if (window.__LENSMCP_CLIENT__) return;
|
|
@@ -81,6 +81,10 @@
|
|
|
81
81
|
// record. (Server-side caps: @lensmcp/bridge MAX_FRAME_BYTES / MAX_BATCH_EVENTS.)
|
|
82
82
|
const FRAME_EVENTS = 200;
|
|
83
83
|
const MAX_FRAMES_PER_FLUSH = 8;
|
|
84
|
+
// A frame is bounded in BYTES as well as events: 200 events of large bodies still passed the
|
|
85
|
+
// bridge's 1 MiB cap and its 1009 close killed the dev server (issues/foodguard/18). Measured in
|
|
86
|
+
// UTF-16 units and sized so even 3 bytes per unit stays under 1 MiB on the wire.
|
|
87
|
+
const FRAME_CHARS = 300000;
|
|
84
88
|
function flushBatch() {
|
|
85
89
|
flushScheduled = false;
|
|
86
90
|
if (!batch.length) return;
|
|
@@ -88,12 +92,29 @@
|
|
|
88
92
|
batch = [];
|
|
89
93
|
if (ws && ws.readyState === 1) {
|
|
90
94
|
try {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
let frames = 0;
|
|
96
|
+
let sentCount = 0;
|
|
97
|
+
let i = 0;
|
|
98
|
+
while (i < events.length && frames < MAX_FRAMES_PER_FLUSH) {
|
|
99
|
+
const parts = [];
|
|
100
|
+
let chars = 0;
|
|
101
|
+
while (i < events.length && parts.length < FRAME_EVENTS) {
|
|
102
|
+
let json = JSON.stringify(events[i]);
|
|
103
|
+
if (json.length > FRAME_CHARS) {
|
|
104
|
+
// One event that alone cannot fit: say so instead of building a frame the bridge refuses.
|
|
105
|
+
json = JSON.stringify({ kind: 'console', level: 'warn', at: Date.now(), tabId: TAB_ID, truncated: true,
|
|
106
|
+
args: ['[lensmcp] dropped an oversized ' + String(events[i] && events[i].kind) + ' event (' + json.length + ' chars)'] });
|
|
107
|
+
}
|
|
108
|
+
if (parts.length && chars + json.length > FRAME_CHARS) break;
|
|
109
|
+
parts.push(json);
|
|
110
|
+
chars += json.length + 1;
|
|
111
|
+
i += 1;
|
|
112
|
+
}
|
|
113
|
+
ws.send(parts.length === 1 ? parts[0] : '{"kind":"batch","at":' + Date.now() + ',"tabId":' + JSON.stringify(TAB_ID) + ',"events":[' + parts.join(',') + ']}');
|
|
114
|
+
sentCount += parts.length;
|
|
115
|
+
frames += 1;
|
|
96
116
|
}
|
|
117
|
+
const dropped = events.length - sentCount;
|
|
97
118
|
if (dropped > 0) {
|
|
98
119
|
ws.send(JSON.stringify({ kind: 'console', level: 'warn', at: Date.now(), tabId: TAB_ID,
|
|
99
120
|
args: ['[lensmcp] event flood: ' + dropped + ' browser event(s) dropped in one frame budget \u2014 the counts below undercount.'] }));
|
|
@@ -313,4 +334,4 @@
|
|
|
313
334
|
try { return safeWalk(v, 0, { left: SAFE_MAX_BYTES }); } catch (e) { return String(v); }
|
|
314
335
|
}
|
|
315
336
|
})();
|
|
316
|
-
`}g(W,"
|
|
337
|
+
`}g(W,"G"),u(W,"buildInlineClientRuntime");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lensmcp/vite-plugin",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.3",
|
|
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.23.
|
|
19
|
-
"@lensmcp/core": "1.23.
|
|
20
|
-
"@lensmcp/protocol-types": "1.23.
|
|
21
|
-
"@lensmcp/react-instrumentation": "1.23.
|
|
22
|
-
"@lensmcp/valtio-instrumentation": "1.23.
|
|
18
|
+
"@lensmcp/bridge": "1.23.3",
|
|
19
|
+
"@lensmcp/core": "1.23.3",
|
|
20
|
+
"@lensmcp/protocol-types": "1.23.3",
|
|
21
|
+
"@lensmcp/react-instrumentation": "1.23.3",
|
|
22
|
+
"@lensmcp/valtio-instrumentation": "1.23.3",
|
|
23
23
|
"tslib": "^2.3.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|