@lensmcp/vite-plugin 1.18.14 → 1.19.0
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 o of
|
|
1
|
+
"use strict";var k=Object.defineProperty;var c=(e,n)=>k(e,"name",{value:n,configurable:!0});var $=Object.defineProperty,l=c((e,n)=>$(e,"name",{value:n,configurable:!0}),"c"),h=Object.defineProperty,d=l((e,n)=>h(e,"name",{value:n,configurable:!0}),"u"),T=Object.defineProperty,m=d((e,n)=>T(e,"name",{value:n,configurable:!0}),"u"),E=Object.defineProperty,v=m((e,n)=>E(e,"name",{value:n,configurable:!0}),"u"),O=Object.defineProperty,f=v((e,n)=>O(e,"name",{value:n,configurable:!0}),"u"),P=Object.defineProperty,p=f((e,n)=>P(e,"name",{value:n,configurable:!0}),"o"),x=Object.defineProperty,g=p((e,n)=>x(e,"name",{value:n,configurable:!0}),"o"),S=Object.defineProperty,y=g((e,n)=>S(e,"name",{value:n,configurable:!0}),"o"),U=Object.defineProperty,b=y((e,n)=>U(e,"name",{value:n,configurable:!0}),"o"),R=Object.defineProperty,I=b((e,n)=>R(e,"name",{value:n,configurable:!0}),"o"),A=Object.defineProperty,w=I((e,n)=>A(e,"name",{value:n,configurable:!0}),"o");import{fingerprint as a,ulid as u}from"@lensmcp/core";const C="pending";export function envelopeToEvent(e,n=C){const o=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,...o},fingerprint:a({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,...o},fingerprint:a({kind:"runtime",identity:`unhandledrejection:${e.reason.slice(0,80)}`}),title:"Unhandled promise rejection",message:e.reason,raw:e};case"console":{const s=e.level==="error"?"error":e.level==="warn"?"warning":"info",j=e.args.map(i).join(" ");return{id:u(),sessionId:n,timestamp:e.at,source:"client-runtime",category:"runtime",severity:s,context:{sessionId:n,...o},fingerprint:a({kind:"runtime",identity:`console:${e.level}:${j.slice(0,80)}`}),title:`console.${e.level}`,message:j,raw:e}}case"fetch":{const s=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:s?"error":"info",context:{sessionId:n,...o},fingerprint:a({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,...o},fingerprint:a({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,...o},fingerprint:a({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,...o,...e.context??{}},fingerprint:e.fingerprint??a({kind:"publish",identity:e.title}),title:e.title,message:e.message,raw:e.raw}}}c(envelopeToEvent,"envelopeToEvent"),l(envelopeToEvent,"envelopeToEvent"),d(envelopeToEvent,"envelopeToEvent"),m(envelopeToEvent,"envelopeToEvent"),v(envelopeToEvent,"envelopeToEvent"),f(envelopeToEvent,"envelopeToEvent"),p(envelopeToEvent,"envelopeToEvent"),g(envelopeToEvent,"envelopeToEvent"),y(envelopeToEvent,"envelopeToEvent"),b(envelopeToEvent,"envelopeToEvent"),I(envelopeToEvent,"envelopeToEvent"),w(envelopeToEvent,"envelopeToEvent");function t(e){if(!e)return"unknown";const n=e.split(`
|
|
2
|
+
`).slice(0,2);for(const o of n){const s=o.match(/at\s+(\S+)/);if(s&&s[1])return s[1]}return"unknown"}c(t,"n"),l(t,"n"),d(t,"r"),m(t,"n"),v(t,"o"),f(t,"a"),p(t,"l"),g(t,"l"),y(t,"c"),b(t,"c"),I(t,"s"),w(t,"normaliseStackTopFrame");function r(e){try{return`${new URL(e,"http://x").pathname}`}catch{return e}}c(r,"r"),l(r,"r"),d(r,"i"),m(r,"i"),v(r,"a"),f(r,"c"),p(r,"d"),g(r,"d"),y(r,"l"),b(r,"l"),I(r,"m"),w(r,"normaliseUrl");function i(e){if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}c(i,"i"),l(i,"i"),d(i,"o"),m(i,"o"),v(i,"c"),f(i,"u"),p(i,"m"),g(i,"m"),y(i,"d"),b(i,"d"),I(i,"d"),w(i,"stringify");
|
package/lib/plugin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var F=Object.defineProperty;var l=(e,t)=>F(e,"name",{value:t,configurable:!0});var N=Object.defineProperty,d=l((e,t)=>N(e,"name",{value:t,configurable:!0}),"l");import{fingerprint as S,ulid as _}from"@lensmcp/core";import{createBridgeServer as x,makePublisher as k,handleClientEnvelope as P}from"@lensmcp/bridge";const E="/@lensmcp/client-runtime",I="\0lensmcp-client-runtime",j="/__lensmcp/watcher-health";export function lensmcpVitePlugin(e={},t={}){const o=e.enabled??!0,p=e.wsHost??"127.0.0.1",s=e.injectClient??!0;let y,f;const v=k(t),O=e.aliasValtio??!0,A=e.transformSource??!0;return{name:"@lensmcp/vite-plugin",apply:o?void 0:()=>!1,enforce:"pre",wsPort:d(()=>y,"wsPort"),config(){if(!(!o||!O))return{resolve:{alias:[{find:/^valtio$/,replacement:"@lensmcp/valtio-instrumentation"}]}}},async configureServer(n){if(!o)return;f=await x({host:p,port:e.wsPort??0,bus:t.bus,sessionId:t.sessionId}),y=f.port,n.ws.on("vite:error",m=>{v(L(m,t.sessionId))});let a=0,r=0;const i=d(()=>{a=Date.now(),r+=1},"stampFsSetEvent");n.watcher.on("add",i),n.watcher.on("addDir",i),n.watcher.on("unlink",i),n.watcher.on("unlinkDir",i),n.middlewares.use(j,(m,h)=>{h.setHeader("content-type","application/json"),h.setHeader("cache-control","no-store"),h.end(JSON.stringify({lastFsSetEventAt:a,fsSetEvents:r,now:Date.now()}))})},resolveId(n){return n===E?I:null},load(n){if(n!==I)return null;const a=y??e.wsPort??0;return R({host:p,port:a})},async transform(n,a){if(!o||!A)return null;const r=a.split("?")[0]??a;if(r.includes("/node_modules/")||!/\.[jt]sx$/.test(r))return null;const i=await T(n,r);return i?{code:i.code,map:i.map}:null},transformIndexHtml(){if(!(!s||!o))return[{tag:"script",attrs:{type:"module",src:E},injectTo:"head-prepend"}]},handleHotUpdate(n){if(!o)return;const a=n.modules.map(r=>r.file??r.id??null).filter(r=>!!r);v({id:_(),sessionId:t.sessionId??"pending",timestamp:Date.now(),source:"vite",category:"build",severity:"info",context:{sessionId:t.sessionId??"pending"},fingerprint:S({kind:"hmr",identity:n.file}),title:`HMR ${n.file}`,location:{file:n.file},relatedFiles:a,raw:{kind:"hmr",file:n.file}})},generateBundle(n,a){if(!o)return;const r=[];let i=0;for(const h of Object.values(a)){const u=h,B=u.fileName;let g;if(u.type==="chunk")g=(u.code??"").length;else{const c=u.source;g=typeof c=="string"?c.length:c instanceof Uint8Array?c.byteLength:0}i+=g;const b=[];if(u.type==="chunk"&&u.modules){for(const[c,w]of Object.entries(u.modules)){const D=w.renderedLength??w.originalLength??0;b.push({id:c,sizeBytes:D})}b.sort((c,w)=>w.sizeBytes-c.sizeBytes)}r.push({name:B,sizeBytes:g,modules:b})}const m={timestamp:Date.now(),totalBytes:i,chunks:r};v({id:_(),sessionId:t.sessionId??"pending",timestamp:Date.now(),source:"rollup",category:"build",severity:"info",context:{sessionId:t.sessionId??"pending"},fingerprint:S({kind:"bundle",identity:"report"}),title:`Bundle report: ${r.length} chunks, ${i} bytes`,raw:{kind:"bundle-report",report:m}})},async closeBundle(){f&&(await f.close(),f=void 0)}}}l(lensmcpVitePlugin,"lensmcpVitePlugin"),d(lensmcpVitePlugin,"lensmcpVitePlugin");async function T(e,t){try{const[{transformSync:o},{lensmcpBabelPlugin:p}]=await Promise.all([import("@babel/core"),import("@lensmcp/react-instrumentation")]),s=o(e,{filename:t,babelrc:!1,configFile:!1,sourceMaps:!0,parserOpts:{plugins:["jsx","typescript"]},plugins:[[p,{rootDir:process.cwd(),production:!1}]],code:!0});return s?.code?{code:s.code,map:s.map}:null}catch{return null}}l(T,"B"),d(T,"runLensmcpBabel");export function handleClientEnvelope(e,t){P(e,k(t),t.sessionId)}l(handleClientEnvelope,"handleClientEnvelope"),d(handleClientEnvelope,"handleClientEnvelope");function C(e){const t=e?.loc?.file??e?.id;return typeof t!="string"||t.length===0?void 0:{file:t.split("?")[0]||t,...typeof e?.loc?.line=="number"?{line:e.loc.line}:{},...typeof e?.loc?.column=="number"?{column:e.loc.column}:{}}}l(C,"N"),d(C,"errorLocation");function L(e,t){const o=e.err?.message??"Vite error",p=e.err?.stack,s=C(e.err);return{id:_(),sessionId:t??"pending",timestamp:Date.now(),source:"vite",category:"build",severity:"error",context:{sessionId:t??"pending"},fingerprint:S({kind:"vite",identity:e.type??o,...s?{file:s.file}:{}}),title:o,message:p,...s?{location:s}:{},raw:{kind:"build-diagnostic",...s?{file:s.file}:{},...e.err?.plugin?{plugin:e.err.plugin}:{}}}}l(L,"F"),d(L,"viteErrorToEvent");function R(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;
|
|
@@ -221,4 +221,4 @@
|
|
|
221
221
|
try { return JSON.parse(JSON.stringify(v)); } catch { return String(v); }
|
|
222
222
|
}
|
|
223
223
|
})();
|
|
224
|
-
`}
|
|
224
|
+
`}l(R,"P"),d(R,"buildInlineClientRuntime");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lensmcp/vite-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
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.
|
|
19
|
-
"@lensmcp/core": "1.
|
|
20
|
-
"@lensmcp/protocol-types": "1.
|
|
21
|
-
"@lensmcp/react-instrumentation": "1.
|
|
22
|
-
"@lensmcp/valtio-instrumentation": "1.
|
|
18
|
+
"@lensmcp/bridge": "1.19.0",
|
|
19
|
+
"@lensmcp/core": "1.19.0",
|
|
20
|
+
"@lensmcp/protocol-types": "1.19.0",
|
|
21
|
+
"@lensmcp/react-instrumentation": "1.19.0",
|
|
22
|
+
"@lensmcp/valtio-instrumentation": "1.19.0",
|
|
23
23
|
"tslib": "^2.3.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|