@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.
- package/lib/event-mappers.js +2 -2
- package/lib/plugin.js +2 -2
- 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"}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,"
|
|
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
|
|
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
|
-
`}
|
|
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.
|
|
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.
|
|
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.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": {
|