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