@lensmcp/vite-plugin 1.23.4 → 1.23.7

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,2 +1,2 @@
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");
1
+ "use strict";var re=Object.defineProperty;var c=(e,n)=>re(e,"name",{value:n,configurable:!0});var oe=Object.defineProperty,v=c((e,n)=>oe(e,"name",{value:n,configurable:!0}),"c"),ie=Object.defineProperty,s=v((e,n)=>ie(e,"name",{value:n,configurable:!0}),"u"),ae=Object.defineProperty,f=s((e,n)=>ae(e,"name",{value:n,configurable:!0}),"u"),le=Object.defineProperty,p=f((e,n)=>le(e,"name",{value:n,configurable:!0}),"u"),ue=Object.defineProperty,d=p((e,n)=>ue(e,"name",{value:n,configurable:!0}),"c"),ce=Object.defineProperty,m=d((e,n)=>ce(e,"name",{value:n,configurable:!0}),"c"),ve=Object.defineProperty,b=m((e,n)=>ve(e,"name",{value:n,configurable:!0}),"c"),se=Object.defineProperty,g=b((e,n)=>se(e,"name",{value:n,configurable:!0}),"u"),fe=Object.defineProperty,y=g((e,n)=>fe(e,"name",{value:n,configurable:!0}),"u"),pe=Object.defineProperty,j=y((e,n)=>pe(e,"name",{value:n,configurable:!0}),"u"),de=Object.defineProperty,T=j((e,n)=>de(e,"name",{value:n,configurable:!0}),"u"),me=Object.defineProperty,E=T((e,n)=>me(e,"name",{value:n,configurable:!0}),"u"),be=Object.defineProperty,O=E((e,n)=>be(e,"name",{value:n,configurable:!0}),"u"),ge=Object.defineProperty,P=O((e,n)=>ge(e,"name",{value:n,configurable:!0}),"u"),ye=Object.defineProperty,I=P((e,n)=>ye(e,"name",{value:n,configurable:!0}),"u"),je=Object.defineProperty,w=I((e,n)=>je(e,"name",{value:n,configurable:!0}),"u"),Te=Object.defineProperty,k=w((e,n)=>Te(e,"name",{value:n,configurable:!0}),"s"),Ee=Object.defineProperty,$=k((e,n)=>Ee(e,"name",{value:n,configurable:!0}),"s"),Oe=Object.defineProperty,h=$((e,n)=>Oe(e,"name",{value:n,configurable:!0}),"s"),Pe=Object.defineProperty,x=h((e,n)=>Pe(e,"name",{value:n,configurable:!0}),"c"),Ie=Object.defineProperty,S=x((e,n)=>Ie(e,"name",{value:n,configurable:!0}),"c"),we=Object.defineProperty,U=S((e,n)=>we(e,"name",{value:n,configurable:!0}),"c"),ke=Object.defineProperty,R=U((e,n)=>ke(e,"name",{value:n,configurable:!0}),"c"),$e=Object.defineProperty,A=R((e,n)=>$e(e,"name",{value:n,configurable:!0}),"c"),he=Object.defineProperty,C=A((e,n)=>he(e,"name",{value:n,configurable:!0}),"c"),xe=Object.defineProperty,F=C((e,n)=>xe(e,"name",{value:n,configurable:!0}),"l"),Se=Object.defineProperty,J=F((e,n)=>Se(e,"name",{value:n,configurable:!0}),"l"),Ue=Object.defineProperty,L=J((e,n)=>Ue(e,"name",{value:n,configurable:!0}),"c"),Re=Object.defineProperty,N=L((e,n)=>Re(e,"name",{value:n,configurable:!0}),"c"),Ae=Object.defineProperty,q=N((e,n)=>Ae(e,"name",{value:n,configurable:!0}),"c"),Ce=Object.defineProperty,z=q((e,n)=>Ce(e,"name",{value:n,configurable:!0}),"u"),Fe=Object.defineProperty,B=z((e,n)=>Fe(e,"name",{value:n,configurable:!0}),"u"),Je=Object.defineProperty,D=B((e,n)=>Je(e,"name",{value:n,configurable:!0}),"u"),Le=Object.defineProperty,G=D((e,n)=>Le(e,"name",{value:n,configurable:!0}),"c"),Ne=Object.defineProperty,H=G((e,n)=>Ne(e,"name",{value:n,configurable:!0}),"c"),qe=Object.defineProperty,K=H((e,n)=>qe(e,"name",{value:n,configurable:!0}),"c"),ze=Object.defineProperty,M=K((e,n)=>ze(e,"name",{value:n,configurable:!0}),"u"),Be=Object.defineProperty,Q=M((e,n)=>Be(e,"name",{value:n,configurable:!0}),"u"),De=Object.defineProperty,V=Q((e,n)=>De(e,"name",{value:n,configurable:!0}),"u"),Ge=Object.defineProperty,W=V((e,n)=>Ge(e,"name",{value:n,configurable:!0}),"u"),He=Object.defineProperty,X=W((e,n)=>He(e,"name",{value:n,configurable:!0}),"o"),Ke=Object.defineProperty,Y=X((e,n)=>Ke(e,"name",{value:n,configurable:!0}),"o"),Me=Object.defineProperty,Z=Y((e,n)=>Me(e,"name",{value:n,configurable:!0}),"o"),Qe=Object.defineProperty,_=Z((e,n)=>Qe(e,"name",{value:n,configurable:!0}),"o"),Ve=Object.defineProperty,ee=_((e,n)=>Ve(e,"name",{value:n,configurable:!0}),"o"),We=Object.defineProperty,ne=ee((e,n)=>We(e,"name",{value:n,configurable:!0}),"o");import{fingerprint as l,ulid as u}from"@lensmcp/core";const Xe="pending";export function envelopeToEvent(e,n=Xe){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",te=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}:${te.slice(0,80)}`}),title:`console.${e.level}`,message:te,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"),v(envelopeToEvent,"envelopeToEvent"),s(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"),W(envelopeToEvent,"envelopeToEvent"),X(envelopeToEvent,"envelopeToEvent"),Y(envelopeToEvent,"envelopeToEvent"),Z(envelopeToEvent,"envelopeToEvent"),_(envelopeToEvent,"envelopeToEvent"),ee(envelopeToEvent,"envelopeToEvent"),ne(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"),v(t,"t"),s(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,"t"),k(t,"t"),$(t,"t"),h(t,"t"),x(t,"t"),S(t,"t"),U(t,"t"),R(t,"n"),A(t,"t"),C(t,"n"),F(t,"t"),J(t,"n"),L(t,"t"),N(t,"n"),q(t,"t"),z(t,"r"),B(t,"t"),D(t,"r"),G(t,"t"),H(t,"n"),K(t,"n"),M(t,"r"),Q(t,"n"),V(t,"o"),W(t,"a"),X(t,"l"),Y(t,"l"),Z(t,"c"),_(t,"c"),ee(t,"s"),ne(t,"normaliseStackTopFrame");function r(e){try{return`${new URL(e,"http://x").pathname}`}catch{return e}}c(r,"r"),v(r,"r"),s(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,"r"),C(r,"r"),F(r,"r"),J(r,"r"),L(r,"r"),N(r,"r"),q(r,"r"),z(r,"n"),B(r,"r"),D(r,"n"),G(r,"r"),H(r,"r"),K(r,"r"),M(r,"i"),Q(r,"i"),V(r,"a"),W(r,"c"),X(r,"d"),Y(r,"d"),Z(r,"l"),_(r,"l"),ee(r,"m"),ne(r,"normaliseUrl");function o(e){if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}c(o,"o"),v(o,"o"),s(o,"o"),f(o,"o"),p(o,"o"),d(o,"o"),m(o,"o"),b(o,"o"),g(o,"o"),y(o,"o"),j(o,"o"),T(o,"o"),E(o,"o"),O(o,"i"),P(o,"o"),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,"i"),z(o,"i"),B(o,"i"),D(o,"i"),G(o,"i"),H(o,"i"),K(o,"i"),M(o,"o"),Q(o,"o"),V(o,"c"),W(o,"u"),X(o,"m"),Y(o,"m"),Z(o,"d"),_(o,"d"),ee(o,"d"),ne(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 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)
1
+ "use strict";var W=Object.defineProperty;var g=(e,n)=>W(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 B,relative as A,resolve as T,sep as C}from"node:path";import{fingerprint as R,ulid as F}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(C)&&!/^[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 v;try{v=$(d)&&q(d).isDirectory()}catch{v=!1}if(v&&!(d===s||p(d,s))){if(p(s,d)){const S=A(d,s).split(C).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(B(t,a.name));t=B(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,v=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,w)=>{o=Date.now(),a+=1,_+=1,b.push({sequence:_,kind:l,path:T(w),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,w)=>{w.setHeader("content-type","application/json"),w.setHeader("cache-control","no-store"),w.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 U({host:p,port:c})},async transform(t,c){if(!s||!v)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:F(),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 w;if(m.type==="chunk")w=(m.code??"").length;else{const y=m.source;w=typeof y=="string"?y.length:y instanceof Uint8Array?y.byteLength:0}a+=w;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:w,modules:k})}const _={timestamp:Date.now(),totalBytes:a,chunks:o};r({id:F(),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 I=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<I&&s.push(f(r)),!1;const v=[...r.importers??[]];if(v.length===0)return i===null&&(i=f(r),n.push(...d.slice(-I),f(r))),!0;let S=!1;for(const t of v){if(t.acceptedHmrDeps?.has(r)){s.length<I&&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:F(),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 U(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;
@@ -85,6 +85,39 @@
85
85
  // bridge's 1 MiB cap and its 1009 close killed the dev server (issues/foodguard/18). Measured in
86
86
  // UTF-16 units and sized so even 3 bytes per unit stays under 1 MiB on the wire.
87
87
  const FRAME_CHARS = 300000;
88
+ // What the frame budget may NOT drop: the events that say where a flow, or a document, begins. A flow
89
+ // exists in the reducer because of its first event, and \`flow-origin\` is the one that names what
90
+ // started it; lose it to a render storm and the flow is a pile of effects with no cause. They are rare
91
+ // (one per flow), so keeping them costs one more frame at most \u2014 MAX_BOUNDARIES_PER_FLUSH is what
92
+ // stops a producer that mints them in a loop from turning that guarantee into the flood.
93
+ const MAX_BOUNDARIES_PER_FLUSH = FRAME_EVENTS;
94
+ function isBoundary(ev) {
95
+ if (!ev) return false;
96
+ if (ev.kind === 'ready') return true;
97
+ if (ev.kind === 'hmr') return ev.event === 'full-reload';
98
+ return ev.kind === 'publish' && !!ev.raw && ev.raw.kind === 'flow-origin';
99
+ }
100
+ // One frame out of list[from..): as many events as fit both bounds, always at least one. Returns the
101
+ // wire payload and how far it got.
102
+ function frameFrom(list, from) {
103
+ const parts = [];
104
+ let chars = 0;
105
+ let i = from;
106
+ while (i < list.length && parts.length < FRAME_EVENTS) {
107
+ let json = JSON.stringify(list[i]);
108
+ if (json.length > FRAME_CHARS) {
109
+ // One event that alone cannot fit: say so instead of building a frame the bridge refuses.
110
+ json = JSON.stringify({ kind: 'console', level: 'warn', at: Date.now(), tabId: TAB_ID, truncated: true,
111
+ args: ['[lensmcp] dropped an oversized ' + String(list[i] && list[i].kind) + ' event (' + json.length + ' chars)'] });
112
+ }
113
+ if (parts.length && chars + json.length > FRAME_CHARS) break;
114
+ parts.push(json);
115
+ chars += json.length + 1;
116
+ i += 1;
117
+ }
118
+ const payload = parts.length === 1 ? parts[0] : '{"kind":"batch","at":' + Date.now() + ',"tabId":' + JSON.stringify(TAB_ID) + ',"events":[' + parts.join(',') + ']}';
119
+ return { payload, next: i, count: parts.length };
120
+ }
88
121
  function flushBatch() {
89
122
  flushScheduled = false;
90
123
  if (!batch.length) return;
@@ -96,24 +129,27 @@
96
129
  let sentCount = 0;
97
130
  let i = 0;
98
131
  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;
132
+ const f = frameFrom(events, i);
133
+ ws.send(f.payload);
134
+ sentCount += f.count;
135
+ i = f.next;
115
136
  frames += 1;
116
137
  }
138
+ // Past the budget the surplus is dropped \u2014 except the boundaries in it, which go out in the
139
+ // order they happened (their own timestamps place them; the frame is only the carrier).
140
+ if (i < events.length) {
141
+ const boundaries = [];
142
+ for (let j = i; j < events.length && boundaries.length < MAX_BOUNDARIES_PER_FLUSH; j += 1) {
143
+ if (isBoundary(events[j])) boundaries.push(events[j]);
144
+ }
145
+ let k = 0;
146
+ while (k < boundaries.length) {
147
+ const f = frameFrom(boundaries, k);
148
+ ws.send(f.payload);
149
+ sentCount += f.count;
150
+ k = f.next;
151
+ }
152
+ }
117
153
  const dropped = events.length - sentCount;
118
154
  if (dropped > 0) {
119
155
  ws.send(JSON.stringify({ kind: 'console', level: 'warn', at: Date.now(), tabId: TAB_ID,
@@ -334,4 +370,4 @@
334
370
  try { return safeWalk(v, 0, { left: SAFE_MAX_BYTES }); } catch (e) { return String(v); }
335
371
  }
336
372
  })();
337
- `}g(W,"G"),u(W,"buildInlineClientRuntime");
373
+ `}g(U,"G"),u(U,"buildInlineClientRuntime");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/vite-plugin",
3
- "version": "1.23.4",
3
+ "version": "1.23.7",
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.4",
19
- "@lensmcp/core": "1.23.4",
20
- "@lensmcp/protocol-types": "1.23.4",
21
- "@lensmcp/react-instrumentation": "1.23.4",
22
- "@lensmcp/valtio-instrumentation": "1.23.4",
18
+ "@lensmcp/bridge": "1.23.7",
19
+ "@lensmcp/core": "1.23.7",
20
+ "@lensmcp/protocol-types": "1.23.7",
21
+ "@lensmcp/react-instrumentation": "1.23.7",
22
+ "@lensmcp/valtio-instrumentation": "1.23.7",
23
23
  "tslib": "^2.3.0"
24
24
  },
25
25
  "peerDependencies": {