@lensmcp/vite-plugin 1.23.0 → 1.23.2

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 Q=Object.defineProperty;var u=(e,n)=>Q(e,"name",{value:n,configurable:!0});var V=Object.defineProperty,s=u((e,n)=>V(e,"name",{value:n,configurable:!0}),"u"),W=Object.defineProperty,v=s((e,n)=>W(e,"name",{value:n,configurable:!0}),"u"),X=Object.defineProperty,f=v((e,n)=>X(e,"name",{value:n,configurable:!0}),"u"),Y=Object.defineProperty,p=f((e,n)=>Y(e,"name",{value:n,configurable:!0}),"u"),Z=Object.defineProperty,d=p((e,n)=>Z(e,"name",{value:n,configurable:!0}),"u"),_=Object.defineProperty,m=d((e,n)=>_(e,"name",{value:n,configurable:!0}),"u"),ee=Object.defineProperty,b=m((e,n)=>ee(e,"name",{value:n,configurable:!0}),"s"),ne=Object.defineProperty,g=b((e,n)=>ne(e,"name",{value:n,configurable:!0}),"s"),te=Object.defineProperty,y=g((e,n)=>te(e,"name",{value:n,configurable:!0}),"s"),re=Object.defineProperty,j=y((e,n)=>re(e,"name",{value:n,configurable:!0}),"c"),oe=Object.defineProperty,T=j((e,n)=>oe(e,"name",{value:n,configurable:!0}),"c"),ie=Object.defineProperty,E=T((e,n)=>ie(e,"name",{value:n,configurable:!0}),"c"),ae=Object.defineProperty,O=E((e,n)=>ae(e,"name",{value:n,configurable:!0}),"c"),le=Object.defineProperty,P=O((e,n)=>le(e,"name",{value:n,configurable:!0}),"c"),ce=Object.defineProperty,I=P((e,n)=>ce(e,"name",{value:n,configurable:!0}),"c"),ue=Object.defineProperty,w=I((e,n)=>ue(e,"name",{value:n,configurable:!0}),"l"),se=Object.defineProperty,k=w((e,n)=>se(e,"name",{value:n,configurable:!0}),"l"),ve=Object.defineProperty,$=k((e,n)=>ve(e,"name",{value:n,configurable:!0}),"c"),fe=Object.defineProperty,h=$((e,n)=>fe(e,"name",{value:n,configurable:!0}),"c"),pe=Object.defineProperty,x=h((e,n)=>pe(e,"name",{value:n,configurable:!0}),"c"),de=Object.defineProperty,S=x((e,n)=>de(e,"name",{value:n,configurable:!0}),"u"),me=Object.defineProperty,U=S((e,n)=>me(e,"name",{value:n,configurable:!0}),"u"),be=Object.defineProperty,R=U((e,n)=>be(e,"name",{value:n,configurable:!0}),"u"),ge=Object.defineProperty,A=R((e,n)=>ge(e,"name",{value:n,configurable:!0}),"c"),ye=Object.defineProperty,C=A((e,n)=>ye(e,"name",{value:n,configurable:!0}),"c"),je=Object.defineProperty,F=C((e,n)=>je(e,"name",{value:n,configurable:!0}),"c"),Te=Object.defineProperty,J=F((e,n)=>Te(e,"name",{value:n,configurable:!0}),"u"),Ee=Object.defineProperty,L=J((e,n)=>Ee(e,"name",{value:n,configurable:!0}),"u"),Oe=Object.defineProperty,N=L((e,n)=>Oe(e,"name",{value:n,configurable:!0}),"u"),Pe=Object.defineProperty,q=N((e,n)=>Pe(e,"name",{value:n,configurable:!0}),"u"),Ie=Object.defineProperty,z=q((e,n)=>Ie(e,"name",{value:n,configurable:!0}),"o"),we=Object.defineProperty,B=z((e,n)=>we(e,"name",{value:n,configurable:!0}),"o"),ke=Object.defineProperty,D=B((e,n)=>ke(e,"name",{value:n,configurable:!0}),"o"),$e=Object.defineProperty,G=D((e,n)=>$e(e,"name",{value:n,configurable:!0}),"o"),he=Object.defineProperty,H=G((e,n)=>he(e,"name",{value:n,configurable:!0}),"o"),xe=Object.defineProperty,K=H((e,n)=>xe(e,"name",{value:n,configurable:!0}),"o");import{fingerprint as l,ulid as c}from"@lensmcp/core";const Se="pending";export function envelopeToEvent(e,n=Se){const i=e.tabId?{tabId:e.tabId}:{};switch(e.kind){case"error":return{id:c(),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:c(),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",M=e.args.map(o).join(" ");return{id:c(),sessionId:n,timestamp:e.at,source:"client-runtime",category:"runtime",severity:a,context:{sessionId:n,...i},fingerprint:l({kind:"runtime",identity:`console:${e.level}:${M.slice(0,80)}`}),title:`console.${e.level}`,message:M,raw:e}}case"fetch":{const a=e.error!==void 0||e.status!==void 0&&e.status>=400;return{id:c(),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:c(),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:c(),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:c(),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}}}u(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");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"}u(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,"n"),P(t,"t"),I(t,"n"),w(t,"t"),k(t,"n"),$(t,"t"),h(t,"n"),x(t,"t"),S(t,"r"),U(t,"t"),R(t,"r"),A(t,"t"),C(t,"n"),F(t,"n"),J(t,"r"),L(t,"n"),N(t,"o"),q(t,"a"),z(t,"l"),B(t,"l"),D(t,"c"),G(t,"c"),H(t,"s"),K(t,"normaliseStackTopFrame");function r(e){try{return`${new URL(e,"http://x").pathname}`}catch{return e}}u(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,"n"),U(r,"r"),R(r,"n"),A(r,"r"),C(r,"r"),F(r,"r"),J(r,"i"),L(r,"i"),N(r,"a"),q(r,"c"),z(r,"d"),B(r,"d"),D(r,"l"),G(r,"l"),H(r,"m"),K(r,"normaliseUrl");function o(e){if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}u(o,"o"),s(o,"o"),v(o,"o"),f(o,"i"),p(o,"o"),d(o,"i"),m(o,"i"),b(o,"i"),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,"o"),L(o,"o"),N(o,"c"),q(o,"u"),z(o,"m"),B(o,"m"),D(o,"d"),G(o,"d"),H(o,"d"),K(o,"stringify");
1
+ "use strict";var V=Object.defineProperty;var u=(e,n)=>V(e,"name",{value:n,configurable:!0});var W=Object.defineProperty,s=u((e,n)=>W(e,"name",{value:n,configurable:!0}),"u"),X=Object.defineProperty,v=s((e,n)=>X(e,"name",{value:n,configurable:!0}),"u"),Y=Object.defineProperty,f=v((e,n)=>Y(e,"name",{value:n,configurable:!0}),"u"),Z=Object.defineProperty,p=f((e,n)=>Z(e,"name",{value:n,configurable:!0}),"u"),_=Object.defineProperty,d=p((e,n)=>_(e,"name",{value:n,configurable:!0}),"u"),ee=Object.defineProperty,m=d((e,n)=>ee(e,"name",{value:n,configurable:!0}),"u"),ne=Object.defineProperty,b=m((e,n)=>ne(e,"name",{value:n,configurable:!0}),"u"),te=Object.defineProperty,g=b((e,n)=>te(e,"name",{value:n,configurable:!0}),"s"),re=Object.defineProperty,y=g((e,n)=>re(e,"name",{value:n,configurable:!0}),"s"),oe=Object.defineProperty,j=y((e,n)=>oe(e,"name",{value:n,configurable:!0}),"s"),ie=Object.defineProperty,T=j((e,n)=>ie(e,"name",{value:n,configurable:!0}),"c"),ae=Object.defineProperty,E=T((e,n)=>ae(e,"name",{value:n,configurable:!0}),"c"),le=Object.defineProperty,O=E((e,n)=>le(e,"name",{value:n,configurable:!0}),"c"),ce=Object.defineProperty,P=O((e,n)=>ce(e,"name",{value:n,configurable:!0}),"c"),ue=Object.defineProperty,I=P((e,n)=>ue(e,"name",{value:n,configurable:!0}),"c"),se=Object.defineProperty,w=I((e,n)=>se(e,"name",{value:n,configurable:!0}),"c"),ve=Object.defineProperty,k=w((e,n)=>ve(e,"name",{value:n,configurable:!0}),"l"),fe=Object.defineProperty,$=k((e,n)=>fe(e,"name",{value:n,configurable:!0}),"l"),pe=Object.defineProperty,h=$((e,n)=>pe(e,"name",{value:n,configurable:!0}),"c"),de=Object.defineProperty,x=h((e,n)=>de(e,"name",{value:n,configurable:!0}),"c"),me=Object.defineProperty,S=x((e,n)=>me(e,"name",{value:n,configurable:!0}),"c"),be=Object.defineProperty,U=S((e,n)=>be(e,"name",{value:n,configurable:!0}),"u"),ge=Object.defineProperty,R=U((e,n)=>ge(e,"name",{value:n,configurable:!0}),"u"),ye=Object.defineProperty,A=R((e,n)=>ye(e,"name",{value:n,configurable:!0}),"u"),je=Object.defineProperty,C=A((e,n)=>je(e,"name",{value:n,configurable:!0}),"c"),Te=Object.defineProperty,F=C((e,n)=>Te(e,"name",{value:n,configurable:!0}),"c"),Ee=Object.defineProperty,J=F((e,n)=>Ee(e,"name",{value:n,configurable:!0}),"c"),Oe=Object.defineProperty,L=J((e,n)=>Oe(e,"name",{value:n,configurable:!0}),"u"),Pe=Object.defineProperty,N=L((e,n)=>Pe(e,"name",{value:n,configurable:!0}),"u"),Ie=Object.defineProperty,q=N((e,n)=>Ie(e,"name",{value:n,configurable:!0}),"u"),we=Object.defineProperty,z=q((e,n)=>we(e,"name",{value:n,configurable:!0}),"u"),ke=Object.defineProperty,B=z((e,n)=>ke(e,"name",{value:n,configurable:!0}),"o"),$e=Object.defineProperty,D=B((e,n)=>$e(e,"name",{value:n,configurable:!0}),"o"),he=Object.defineProperty,G=D((e,n)=>he(e,"name",{value:n,configurable:!0}),"o"),xe=Object.defineProperty,H=G((e,n)=>xe(e,"name",{value:n,configurable:!0}),"o"),Se=Object.defineProperty,K=H((e,n)=>Se(e,"name",{value:n,configurable:!0}),"o"),Ue=Object.defineProperty,M=K((e,n)=>Ue(e,"name",{value:n,configurable:!0}),"o");import{fingerprint as l,ulid as c}from"@lensmcp/core";const Re="pending";export function envelopeToEvent(e,n=Re){const i=e.tabId?{tabId:e.tabId}:{};switch(e.kind){case"error":return{id:c(),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:c(),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",Q=e.args.map(o).join(" ");return{id:c(),sessionId:n,timestamp:e.at,source:"client-runtime",category:"runtime",severity:a,context:{sessionId:n,...i},fingerprint:l({kind:"runtime",identity:`console:${e.level}:${Q.slice(0,80)}`}),title:`console.${e.level}`,message:Q,raw:e}}case"fetch":{const a=e.error!==void 0||e.status!==void 0&&e.status>=400;return{id:c(),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:c(),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:c(),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:c(),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}}}u(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");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"}u(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,"n"),I(t,"t"),w(t,"n"),k(t,"t"),$(t,"n"),h(t,"t"),x(t,"n"),S(t,"t"),U(t,"r"),R(t,"t"),A(t,"r"),C(t,"t"),F(t,"n"),J(t,"n"),L(t,"r"),N(t,"n"),q(t,"o"),z(t,"a"),B(t,"l"),D(t,"l"),G(t,"c"),H(t,"c"),K(t,"s"),M(t,"normaliseStackTopFrame");function r(e){try{return`${new URL(e,"http://x").pathname}`}catch{return e}}u(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,"n"),R(r,"r"),A(r,"n"),C(r,"r"),F(r,"r"),J(r,"r"),L(r,"i"),N(r,"i"),q(r,"a"),z(r,"c"),B(r,"d"),D(r,"d"),G(r,"l"),H(r,"l"),K(r,"m"),M(r,"normaliseUrl");function o(e){if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}u(o,"o"),s(o,"o"),v(o,"o"),f(o,"o"),p(o,"i"),d(o,"o"),m(o,"i"),b(o,"i"),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,"o"),N(o,"o"),q(o,"c"),z(o,"u"),B(o,"m"),D(o,"m"),G(o,"d"),H(o,"d"),K(o,"d"),M(o,"stringify");
package/lib/plugin.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var P=Object.defineProperty;var d=(e,n)=>P(e,"name",{value:n,configurable:!0});import{existsSync as H,readdirSync as x,statSync as j}from"node:fs";import{delimiter as W,join as C,relative as A,resolve as k,sep as M}from"node:path";import{fingerprint as T,ulid as R}from"@lensmcp/core";import{createBridgeServer as X,makePublisher as L,handleClientEnvelope as U}from"@lensmcp/bridge";const B="/@lensmcp/client-runtime",D="\0lensmcp-client-runtime",V="/__lensmcp/watcher-health",N=256,$=64,q=new Set(["node_modules",".git","dist","tmp","coverage","build","out","target",".nx",".lensmcp"]);export function resolveExtraWatchRoots(e,n){if(!e)return[];const r=k(n),h=d((u,g)=>{const s=A(g,u);return s!==""&&!s.startsWith("..")&&!s.startsWith(M)&&!/^[A-Za-z]:/.test(s)},"inside"),a=[],p=d(u=>{a.length<$&&!a.includes(u)&&a.push(u)},"push");for(const u of e.split(W)){const g=u.trim();if(!g)continue;const s=k(g);let w;try{w=H(s)&&j(s).isDirectory()}catch{w=!1}if(w&&!(s===r||h(s,r))){if(h(r,s)){const v=A(s,r).split(M).filter(Boolean);let t=s;for(const o of v){let i;try{i=x(t,{withFileTypes:!0})}catch{i=[]}for(const c of i)!c.isDirectory()||c.name===o||c.name.startsWith(".")||q.has(c.name)||p(C(t,c.name));t=C(t,o)}continue}p(s)}}return a}d(resolveExtraWatchRoots,"resolveExtraWatchRoots");export function lensmcpVitePlugin(e={},n={}){const r=e.enabled??!0,h=e.wsHost??"127.0.0.1",a=e.injectClient??!0;let p,u;const g=L(n),s=e.aliasValtio??!0,w=e.transformSource??!0,v=e.applyOnBuild??process.env.LENSMCP_VITE_APPLY_ON_BUILD==="1";return{name:"@lensmcp/vite-plugin",apply:d((t,o)=>r&&(o.command==="serve"||v),"apply"),enforce:"pre",wsPort:d(()=>p,"wsPort"),config(){if(!(!r||!s))return{resolve:{alias:[{find:/^valtio$/,replacement:"@lensmcp/valtio-instrumentation"}]}}},async configureServer(t){if(!r)return;u=await X({host:h,port:e.wsPort??0,bus:n.bus,sessionId:n.sessionId}),p=u.port,t.ws.on("vite:error",l=>{g(Y(l,n.sessionId))});const o=resolveExtraWatchRoots(process.env.LENSMCP_WATCH_DIRS,t.config?.root??process.cwd());if(o.length>0&&typeof t.watcher?.add=="function")try{t.watcher.add(o),console.log(`[lensmcp] watching ${o.length} extra source root(s) for set changes: ${o.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 i=0,c=0,S=0;const b=[],f=d((l,m)=>{i=Date.now(),c+=1,S+=1,b.push({sequence:S,kind:l,path:k(m),at:i}),b.length>N&&b.splice(0,b.length-N)},"stampFsSetEvent");t.watcher.on("add",l=>f("add",l)),t.watcher.on("addDir",l=>f("addDir",l)),t.watcher.on("unlink",l=>f("unlink",l)),t.watcher.on("unlinkDir",l=>f("unlinkDir",l)),t.middlewares.use(V,(l,m)=>{m.setHeader("content-type","application/json"),m.setHeader("cache-control","no-store"),m.end(JSON.stringify({schemaVersion:2,ready:!0,sequence:S,lastFsSetEventAt:i,fsSetEvents:c,recentEvents:b,extraWatchRoots:o,now:Date.now()}))})},resolveId(t){return t===B?D:null},load(t){if(t!==D)return null;const o=p??e.wsPort??0;return z({host:h,port:o})},async transform(t,o){if(!r||!w)return null;const i=o.split("?")[0]??o;if(i.includes("/node_modules/")||!/\.[jt]sx$/.test(i))return null;const c=await J(t,i);return c?{code:c.code,map:c.map}:null},transformIndexHtml(){if(!(!a||!r))return[{tag:"script",attrs:{type:"module",src:B},injectTo:"head-prepend"}]},handleHotUpdate(t){if(!r)return;const o=t.modules.map(c=>c.file??c.id??null).filter(c=>!!c),i=hmrReloadCause(t.modules);g({id:R(),sessionId:n.sessionId??"pending",timestamp:Date.now(),source:"vite",category:"build",severity:i.willFullReload?"warning":"info",context:{sessionId:n.sessionId??"pending"},fingerprint:T({kind:"hmr",identity:t.file}),title:i.willFullReload?`HMR ${t.file} \u2014 FULL RELOAD (no boundary above ${i.deadEnd??"it"})`:`HMR ${t.file}`,location:{file:t.file},relatedFiles:o,raw:{kind:"hmr",file:t.file,willFullReload:i.willFullReload,deadEnd:i.deadEnd,chain:i.chain,acceptedBy:i.boundaries}})},generateBundle(t,o){if(!r)return;const i=[];let c=0;for(const b of Object.values(o)){const f=b,l=f.fileName;let m;if(f.type==="chunk")m=(f.code??"").length;else{const y=f.source;m=typeof y=="string"?y.length:y instanceof Uint8Array?y.byteLength:0}c+=m;const E=[];if(f.type==="chunk"&&f.modules){for(const[y,_]of Object.entries(f.modules)){const O=_.renderedLength??_.originalLength??0;E.push({id:y,sizeBytes:O})}E.sort((y,_)=>_.sizeBytes-y.sizeBytes)}i.push({name:l,sizeBytes:m,modules:E})}const S={timestamp:Date.now(),totalBytes:c,chunks:i};g({id:R(),sessionId:n.sessionId??"pending",timestamp:Date.now(),source:"rollup",category:"build",severity:"info",context:{sessionId:n.sessionId??"pending"},fingerprint:T({kind:"bundle",identity:"report"}),title:`Bundle report: ${i.length} chunks, ${c} bytes`,raw:{kind:"bundle-report",report:S}})},async closeBundle(){u&&(await u.close(),u=void 0)}}}d(lensmcpVitePlugin,"lensmcpVitePlugin");const I=12;export function hmrReloadCause(e){const n=[],r=[],h=new Set;let a=null;const p=d(s=>s.file??s.id??"(anonymous module)","nameOf"),u=d((s,w)=>{if(h.has(s))return!1;if(h.add(s),s.isSelfAccepting===!0)return r.length<I&&r.push(p(s)),!1;const v=[...s.importers??[]];if(v.length===0)return a===null&&(a=p(s),n.push(...w.slice(-I),p(s))),!0;let t=!1;for(const o of v){if(o.acceptedHmrDeps?.has(s)){r.length<I&&r.push(p(o));continue}u(o,[...w,p(s)])&&(t=!0)}return t},"walk");return{willFullReload:e.map(s=>u(s,[])).some(Boolean),deadEnd:a,chain:n,boundaries:r}}d(hmrReloadCause,"hmrReloadCause");async function J(e,n){try{const[{transformSync:r},{lensmcpBabelPlugin:h}]=await Promise.all([import("@babel/core"),import("@lensmcp/react-instrumentation")]),a=r(e,{filename:n,babelrc:!1,configFile:!1,sourceMaps:!0,parserOpts:{plugins:["jsx","typescript"]},plugins:[[h,{rootDir:process.cwd()}]],code:!0});return a?.code?{code:a.code,map:a.map}:null}catch(r){return K(n,r),null}}d(J,"runLensmcpBabel");const F=new Set;function K(e,n){F.has(e)||(F.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.`))}d(K,"warnTransformFailed");export function resetTransformFailuresForTests(){F.clear()}d(resetTransformFailuresForTests,"resetTransformFailuresForTests");export function handleClientEnvelope(e,n){U(e,L(n),n.sessionId)}d(handleClientEnvelope,"handleClientEnvelope");function G(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}:{}}}d(G,"errorLocation");function Y(e,n){const r=e.err?.message??"Vite error",h=e.err?.stack,a=G(e.err);return{id:R(),sessionId:n??"pending",timestamp:Date.now(),source:"vite",category:"build",severity:"error",context:{sessionId:n??"pending"},fingerprint:T({kind:"vite",identity:e.type??r,...a?{file:a.file}:{}}),title:r,message:h,...a?{location:a}:{},raw:{kind:"build-diagnostic",...a?{file:a.file}:{},...e.err?.plugin?{plugin:e.err.plugin}:{}}}}d(Y,"viteErrorToEvent");function z(e){return`// @lensmcp/client-runtime (inlined by @lensmcp/vite-plugin)
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 G,makePublisher as L,handleClientEnvelope as Y}from"@lensmcp/bridge";const O="/@lensmcp/client-runtime",D="\0lensmcp-client-runtime",z="/__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,o)=>{const d=A(o,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 o=h.trim();if(!o)continue;const d=T(o);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(B).filter(Boolean);let t=d;for(const l of S){let r;try{r=J(t,{withFileTypes:!0})}catch{r=[]}for(const a of r)!a.isDirectory()||a.name===l||a.name.startsWith(".")||Q.has(a.name)||f(C(t,a.name));t=C(t,l)}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 o=L(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,l)=>s&&(l.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 G({host:p,port:e.wsPort??0,bus:n.bus,sessionId:n.sessionId}),f=h.port,t.ws.on("vite:error",c=>{o(H(c,n.sessionId))});const l=resolveExtraWatchRoots(process.env.LENSMCP_WATCH_DIRS,t.config?.root??process.cwd());if(l.length>0&&typeof t.watcher?.add=="function")try{t.watcher.add(l),console.log(`[lensmcp] watching ${l.length} extra source root(s) for set changes: ${l.map(c=>A(t.config?.root??process.cwd(),c)||c).join(", ")}`)}catch(c){console.warn(`[lensmcp] could not widen the watcher: ${c?.message??String(c)}`)}let r=0,a=0,E=0;const b=[],m=u((c,w)=>{r=Date.now(),a+=1,E+=1,b.push({sequence:E,kind:c,path:T(w),at:r}),b.length>N&&b.splice(0,b.length-N)},"stampFsSetEvent");t.watcher.on("add",c=>m("add",c)),t.watcher.on("addDir",c=>m("addDir",c)),t.watcher.on("unlink",c=>m("unlink",c)),t.watcher.on("unlinkDir",c=>m("unlinkDir",c)),t.middlewares.use(z,(c,w)=>{w.setHeader("content-type","application/json"),w.setHeader("cache-control","no-store"),w.end(JSON.stringify({schemaVersion:2,ready:!0,sequence:E,lastFsSetEventAt:r,fsSetEvents:a,recentEvents:b,extraWatchRoots:l,now:Date.now()}))})},resolveId(t){return t===O?D:null},load(t){if(t!==D)return null;const l=f??e.wsPort??0;return W({host:p,port:l})},async transform(t,l){if(!s||!v)return null;const r=l.split("?")[0]??l;if(r.includes("/node_modules/")||!/\.[jt]sx$/.test(r))return null;const a=await x(t,r);return a?{code:a.code,map:a.map}:null},transformIndexHtml(){if(!(!i||!s))return[{tag:"script",attrs:{type:"module",src:O},injectTo:"head-prepend"}]},handleHotUpdate(t){if(!s)return;const l=t.modules.map(a=>a.file??a.id??null).filter(a=>!!a),r=hmrReloadCause(t.modules);o({id:I(),sessionId:n.sessionId??"pending",timestamp:Date.now(),source:"vite",category:"build",severity:r.willFullReload?"warning":"info",context:{sessionId:n.sessionId??"pending"},fingerprint:R({kind:"hmr",identity:t.file}),title:r.willFullReload?`HMR ${t.file} \u2014 FULL RELOAD (no boundary above ${r.deadEnd??"it"})`:`HMR ${t.file}`,location:{file:t.file},relatedFiles:l,raw:{kind:"hmr",file:t.file,willFullReload:r.willFullReload,deadEnd:r.deadEnd,chain:r.chain,acceptedBy:r.boundaries}})},generateBundle(t,l){if(!s)return;const r=[];let a=0;for(const b of Object.values(l)){const m=b,c=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,_]of Object.entries(m.modules)){const X=_.renderedLength??_.originalLength??0;k.push({id:y,sizeBytes:X})}k.sort((y,_)=>_.sizeBytes-y.sizeBytes)}r.push({name:c,sizeBytes:w,modules:k})}const E={timestamp:Date.now(),totalBytes:a,chunks:r};o({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: ${r.length} chunks, ${a} bytes`,raw:{kind:"bundle-report",report:E}})},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(o=>o.file??o.id??"(anonymous module)","nameOf"),h=u((o,d)=>{if(p.has(o))return!1;if(p.add(o),o.isSelfAccepting===!0)return s.length<F&&s.push(f(o)),!1;const v=[...o.importers??[]];if(v.length===0)return i===null&&(i=f(o),n.push(...d.slice(-F),f(o))),!0;let S=!1;for(const t of v){if(t.acceptedHmrDeps?.has(o)){s.length<F&&s.push(f(t));continue}h(t,[...d,f(o)])&&(S=!0)}return S},"walk");return{willFullReload:e.map(o=>h(o,[])).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 P(n,s),null}}g(x,"J"),u(x,"runLensmcpBabel");const M=new Set;function P(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(P,"K"),u(P,"warnTransformFailed");export function resetTransformFailuresForTests(){M.clear()}g(resetTransformFailuresForTests,"resetTransformFailuresForTests"),u(resetTransformFailuresForTests,"resetTransformFailuresForTests");export function handleClientEnvelope(e,n){Y(e,L(n),n.sessionId)}g(handleClientEnvelope,"handleClientEnvelope"),u(handleClientEnvelope,"handleClientEnvelope");function j(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(j,"G"),u(j,"errorLocation");function H(e,n){const s=e.err?.message??"Vite error",p=e.err?.stack,i=j(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,"Y"),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;
@@ -313,4 +313,4 @@
313
313
  try { return safeWalk(v, 0, { left: SAFE_MAX_BYTES }); } catch (e) { return String(v); }
314
314
  }
315
315
  })();
316
- `}d(z,"buildInlineClientRuntime");
316
+ `}g(W,"z"),u(W,"buildInlineClientRuntime");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/vite-plugin",
3
- "version": "1.23.0",
3
+ "version": "1.23.2",
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.0",
19
- "@lensmcp/core": "1.23.0",
20
- "@lensmcp/protocol-types": "1.23.0",
21
- "@lensmcp/react-instrumentation": "1.23.0",
22
- "@lensmcp/valtio-instrumentation": "1.23.0",
18
+ "@lensmcp/bridge": "1.23.2",
19
+ "@lensmcp/core": "1.23.2",
20
+ "@lensmcp/protocol-types": "1.23.2",
21
+ "@lensmcp/react-instrumentation": "1.23.2",
22
+ "@lensmcp/valtio-instrumentation": "1.23.2",
23
23
  "tslib": "^2.3.0"
24
24
  },
25
25
  "peerDependencies": {