@lensmcp/vite-plugin 1.22.5 → 1.22.6

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 H=Object.defineProperty;var u=(e,n)=>H(e,"name",{value:n,configurable:!0});var K=Object.defineProperty,s=u((e,n)=>K(e,"name",{value:n,configurable:!0}),"u"),M=Object.defineProperty,v=s((e,n)=>M(e,"name",{value:n,configurable:!0}),"u"),Q=Object.defineProperty,d=v((e,n)=>Q(e,"name",{value:n,configurable:!0}),"u"),V=Object.defineProperty,f=d((e,n)=>V(e,"name",{value:n,configurable:!0}),"s"),W=Object.defineProperty,p=f((e,n)=>W(e,"name",{value:n,configurable:!0}),"s"),X=Object.defineProperty,m=p((e,n)=>X(e,"name",{value:n,configurable:!0}),"s"),Y=Object.defineProperty,b=m((e,n)=>Y(e,"name",{value:n,configurable:!0}),"c"),Z=Object.defineProperty,g=b((e,n)=>Z(e,"name",{value:n,configurable:!0}),"c"),_=Object.defineProperty,y=g((e,n)=>_(e,"name",{value:n,configurable:!0}),"c"),ee=Object.defineProperty,j=y((e,n)=>ee(e,"name",{value:n,configurable:!0}),"c"),ne=Object.defineProperty,T=j((e,n)=>ne(e,"name",{value:n,configurable:!0}),"c"),te=Object.defineProperty,E=T((e,n)=>te(e,"name",{value:n,configurable:!0}),"c"),re=Object.defineProperty,O=E((e,n)=>re(e,"name",{value:n,configurable:!0}),"l"),oe=Object.defineProperty,P=O((e,n)=>oe(e,"name",{value:n,configurable:!0}),"l"),ie=Object.defineProperty,I=P((e,n)=>ie(e,"name",{value:n,configurable:!0}),"c"),ae=Object.defineProperty,w=I((e,n)=>ae(e,"name",{value:n,configurable:!0}),"c"),le=Object.defineProperty,k=w((e,n)=>le(e,"name",{value:n,configurable:!0}),"c"),ce=Object.defineProperty,$=k((e,n)=>ce(e,"name",{value:n,configurable:!0}),"u"),ue=Object.defineProperty,h=$((e,n)=>ue(e,"name",{value:n,configurable:!0}),"u"),se=Object.defineProperty,x=h((e,n)=>se(e,"name",{value:n,configurable:!0}),"u"),ve=Object.defineProperty,S=x((e,n)=>ve(e,"name",{value:n,configurable:!0}),"c"),de=Object.defineProperty,U=S((e,n)=>de(e,"name",{value:n,configurable:!0}),"c"),fe=Object.defineProperty,R=U((e,n)=>fe(e,"name",{value:n,configurable:!0}),"c"),pe=Object.defineProperty,A=R((e,n)=>pe(e,"name",{value:n,configurable:!0}),"u"),me=Object.defineProperty,C=A((e,n)=>me(e,"name",{value:n,configurable:!0}),"u"),be=Object.defineProperty,F=C((e,n)=>be(e,"name",{value:n,configurable:!0}),"u"),ge=Object.defineProperty,J=F((e,n)=>ge(e,"name",{value:n,configurable:!0}),"u"),ye=Object.defineProperty,L=J((e,n)=>ye(e,"name",{value:n,configurable:!0}),"o"),je=Object.defineProperty,N=L((e,n)=>je(e,"name",{value:n,configurable:!0}),"o"),Te=Object.defineProperty,q=N((e,n)=>Te(e,"name",{value:n,configurable:!0}),"o"),Ee=Object.defineProperty,z=q((e,n)=>Ee(e,"name",{value:n,configurable:!0}),"o"),Oe=Object.defineProperty,B=z((e,n)=>Oe(e,"name",{value:n,configurable:!0}),"o"),Pe=Object.defineProperty,D=B((e,n)=>Pe(e,"name",{value:n,configurable:!0}),"o");import{fingerprint as l,ulid as c}from"@lensmcp/core";const Ie="pending";export function envelopeToEvent(e,n=Ie){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",G=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}:${G.slice(0,80)}`}),title:`console.${e.level}`,message:G,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"),d(envelopeToEvent,"envelopeToEvent"),f(envelopeToEvent,"envelopeToEvent"),p(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");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"),d(t,"t"),f(t,"t"),p(t,"t"),m(t,"t"),b(t,"t"),g(t,"t"),y(t,"t"),j(t,"n"),T(t,"t"),E(t,"n"),O(t,"t"),P(t,"n"),I(t,"t"),w(t,"n"),k(t,"t"),$(t,"r"),h(t,"t"),x(t,"r"),S(t,"t"),U(t,"n"),R(t,"n"),A(t,"r"),C(t,"n"),F(t,"o"),J(t,"a"),L(t,"l"),N(t,"l"),q(t,"c"),z(t,"c"),B(t,"s"),D(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"),d(r,"r"),f(r,"r"),p(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,"n"),h(r,"r"),x(r,"n"),S(r,"r"),U(r,"r"),R(r,"r"),A(r,"i"),C(r,"i"),F(r,"a"),J(r,"c"),L(r,"d"),N(r,"d"),q(r,"l"),z(r,"l"),B(r,"m"),D(r,"normaliseUrl");function o(e){if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}u(o,"i"),s(o,"o"),v(o,"i"),d(o,"i"),f(o,"i"),p(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,"o"),C(o,"o"),F(o,"c"),J(o,"u"),L(o,"m"),N(o,"m"),q(o,"d"),z(o,"d"),B(o,"d"),D(o,"stringify");
1
+ "use strict";var M=Object.defineProperty;var u=(e,n)=>M(e,"name",{value:n,configurable:!0});var Q=Object.defineProperty,s=u((e,n)=>Q(e,"name",{value:n,configurable:!0}),"u"),V=Object.defineProperty,v=s((e,n)=>V(e,"name",{value:n,configurable:!0}),"u"),W=Object.defineProperty,f=v((e,n)=>W(e,"name",{value:n,configurable:!0}),"u"),X=Object.defineProperty,p=f((e,n)=>X(e,"name",{value:n,configurable:!0}),"u"),Y=Object.defineProperty,d=p((e,n)=>Y(e,"name",{value:n,configurable:!0}),"u"),Z=Object.defineProperty,m=d((e,n)=>Z(e,"name",{value:n,configurable:!0}),"s"),_=Object.defineProperty,b=m((e,n)=>_(e,"name",{value:n,configurable:!0}),"s"),ee=Object.defineProperty,g=b((e,n)=>ee(e,"name",{value:n,configurable:!0}),"s"),ne=Object.defineProperty,y=g((e,n)=>ne(e,"name",{value:n,configurable:!0}),"c"),te=Object.defineProperty,j=y((e,n)=>te(e,"name",{value:n,configurable:!0}),"c"),re=Object.defineProperty,T=j((e,n)=>re(e,"name",{value:n,configurable:!0}),"c"),oe=Object.defineProperty,E=T((e,n)=>oe(e,"name",{value:n,configurable:!0}),"c"),ie=Object.defineProperty,O=E((e,n)=>ie(e,"name",{value:n,configurable:!0}),"c"),ae=Object.defineProperty,P=O((e,n)=>ae(e,"name",{value:n,configurable:!0}),"c"),le=Object.defineProperty,I=P((e,n)=>le(e,"name",{value:n,configurable:!0}),"l"),ce=Object.defineProperty,w=I((e,n)=>ce(e,"name",{value:n,configurable:!0}),"l"),ue=Object.defineProperty,k=w((e,n)=>ue(e,"name",{value:n,configurable:!0}),"c"),se=Object.defineProperty,$=k((e,n)=>se(e,"name",{value:n,configurable:!0}),"c"),ve=Object.defineProperty,h=$((e,n)=>ve(e,"name",{value:n,configurable:!0}),"c"),fe=Object.defineProperty,x=h((e,n)=>fe(e,"name",{value:n,configurable:!0}),"u"),pe=Object.defineProperty,S=x((e,n)=>pe(e,"name",{value:n,configurable:!0}),"u"),de=Object.defineProperty,U=S((e,n)=>de(e,"name",{value:n,configurable:!0}),"u"),me=Object.defineProperty,R=U((e,n)=>me(e,"name",{value:n,configurable:!0}),"c"),be=Object.defineProperty,A=R((e,n)=>be(e,"name",{value:n,configurable:!0}),"c"),ge=Object.defineProperty,C=A((e,n)=>ge(e,"name",{value:n,configurable:!0}),"c"),ye=Object.defineProperty,F=C((e,n)=>ye(e,"name",{value:n,configurable:!0}),"u"),je=Object.defineProperty,J=F((e,n)=>je(e,"name",{value:n,configurable:!0}),"u"),Te=Object.defineProperty,L=J((e,n)=>Te(e,"name",{value:n,configurable:!0}),"u"),Ee=Object.defineProperty,N=L((e,n)=>Ee(e,"name",{value:n,configurable:!0}),"u"),Oe=Object.defineProperty,q=N((e,n)=>Oe(e,"name",{value:n,configurable:!0}),"o"),Pe=Object.defineProperty,z=q((e,n)=>Pe(e,"name",{value:n,configurable:!0}),"o"),Ie=Object.defineProperty,B=z((e,n)=>Ie(e,"name",{value:n,configurable:!0}),"o"),we=Object.defineProperty,D=B((e,n)=>we(e,"name",{value:n,configurable:!0}),"o"),ke=Object.defineProperty,G=D((e,n)=>ke(e,"name",{value:n,configurable:!0}),"o"),$e=Object.defineProperty,H=G((e,n)=>$e(e,"name",{value:n,configurable:!0}),"o");import{fingerprint as l,ulid as c}from"@lensmcp/core";const he="pending";export function envelopeToEvent(e,n=he){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",K=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}:${K.slice(0,80)}`}),title:`console.${e.level}`,message:K,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");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,"n"),O(t,"t"),P(t,"n"),I(t,"t"),w(t,"n"),k(t,"t"),$(t,"n"),h(t,"t"),x(t,"r"),S(t,"t"),U(t,"r"),R(t,"t"),A(t,"n"),C(t,"n"),F(t,"r"),J(t,"n"),L(t,"o"),N(t,"a"),q(t,"l"),z(t,"l"),B(t,"c"),D(t,"c"),G(t,"s"),H(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,"n"),S(r,"r"),U(r,"n"),R(r,"r"),A(r,"r"),C(r,"r"),F(r,"i"),J(r,"i"),L(r,"a"),N(r,"c"),q(r,"d"),z(r,"d"),B(r,"l"),D(r,"l"),G(r,"m"),H(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,"i"),f(o,"o"),p(o,"i"),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,"o"),J(o,"o"),L(o,"c"),N(o,"u"),q(o,"m"),z(o,"m"),B(o,"d"),D(o,"d"),G(o,"d"),H(o,"stringify");
package/lib/plugin.d.ts CHANGED
@@ -48,6 +48,73 @@ interface BoundDeps {
48
48
  * The plugin is *passive*: it never mutates app state or behaviour.
49
49
  */
50
50
  export declare function lensmcpVitePlugin(options?: LensmcpViteOptions, deps?: BoundDeps): Plugin & LensmcpViteRuntime;
51
+ /**
52
+ * Run the LensMCP Babel transform on one module's source. Lazily loads
53
+ * `@babel/core` + the plugin so they're only touched in dev when a
54
+ * `.jsx`/`.tsx` file is transformed. Returns null on parse error (let
55
+ * Vite proceed with the untransformed source).
56
+ */
57
+ /**
58
+ * A module as Vite's HMR graph holds it — the three fields propagation actually reads.
59
+ *
60
+ * Structural rather than imported from `vite`: this plugin is loaded by whatever Vite the host app
61
+ * pins, and a nominal type import would couple the diagnostic to one major version of a shape that
62
+ * has been stable since HMR existed.
63
+ */
64
+ interface HmrNode {
65
+ readonly file?: string | null;
66
+ readonly id?: string | null;
67
+ readonly isSelfAccepting?: boolean;
68
+ readonly importers?: Iterable<HmrNode>;
69
+ readonly acceptedHmrDeps?: {
70
+ has(node: HmrNode): boolean;
71
+ };
72
+ }
73
+ /** Why an edit reloads the page instead of hot-updating it. */
74
+ export interface HmrReloadCause {
75
+ /** Whether Vite will full-reload for this change. */
76
+ readonly willFullReload: boolean;
77
+ /**
78
+ * The module the walk stopped at — a file nothing imports and which accepts nothing, so there is
79
+ * no boundary above it to hand the update to. This is the answer to "why did it reload?".
80
+ */
81
+ readonly deadEnd: string | null;
82
+ /** The import chain from the edited file up to the dead end, newest last. Bounded. */
83
+ readonly chain: readonly string[];
84
+ /** The boundaries that DID accept, when some did — the half that hot-updated. */
85
+ readonly boundaries: readonly string[];
86
+ }
87
+ /**
88
+ * Why Vite is about to reload the page, computed the way Vite computes it.
89
+ *
90
+ * ## The gap this closes
91
+ *
92
+ * A full page reload during development is the single event a developer pays for most often and can
93
+ * explain least: the terminal prints `page reload <file>` and stops there. Vite's own client event
94
+ * carries `triggeredBy` — the file it could not hot-update — and that names the SYMPTOM. The
95
+ * question is always the next one, and nothing answered it: *which importer refused, and why?*
96
+ *
97
+ * Measured on a real workspace (foodguard, 2026-09-19): three `.ts` modules — a logic file, a
98
+ * contracts barrel and a locale catalogue — reloaded the dashboard on every edit, forty times over
99
+ * during one agent's edit sweep. Establishing merely that the lens was not the cause took 45
100
+ * minutes of reading plugin source, and the actual propagation path was still unknown at the end of
101
+ * it, because nothing in the toolchain will say it.
102
+ *
103
+ * ## What it reports, and what it deliberately does not
104
+ *
105
+ * It mirrors Vite's `propagateUpdate`: a self-accepting module is a boundary; an importer that
106
+ * accepts this module as a dependency is a boundary; a module with NO importers and no boundary is
107
+ * the dead end, and a dead end anywhere means a full reload. The FIRST such dead end is named,
108
+ * because that is the one a developer can act on.
109
+ *
110
+ * It does not judge. A `.ts` module of pure functions has no React Fast Refresh boundary and a full
111
+ * reload for it is usually CORRECT — consumers hold the imported binding, so swapping the module
112
+ * without re-running them would leave them calling stale functions. Naming the dead end tells a
113
+ * developer which of the two they are looking at: a module that genuinely cannot be hot-swapped, or
114
+ * an importer that should have been a boundary and is not (a barrel, a warmed dead-end, a spec
115
+ * pinned into the browser graph).
116
+ */
117
+ export declare function hmrReloadCause(changed: readonly HmrNode[]): HmrReloadCause;
51
118
  /** Tests only. */
52
119
  export declare function resetTransformFailuresForTests(): void;
53
120
  /**
package/lib/plugin.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var X=Object.defineProperty;var p=(e,t)=>X(e,"name",{value:t,configurable:!0});var U=Object.defineProperty,d=p((e,t)=>U(e,"name",{value:t,configurable:!0}),"d");import{existsSync as V,readdirSync as $,statSync as J}from"node:fs";import{delimiter as q,join as F,relative as A,resolve as T,sep as C}from"node:path";import{fingerprint as I,ulid as R}from"@lensmcp/core";import{createBridgeServer as K,makePublisher as B,handleClientEnvelope as G}from"@lensmcp/bridge";const L="/@lensmcp/client-runtime",O="\0lensmcp-client-runtime",Y="/__lensmcp/watcher-health",D=256,z=64,Z=new Set(["node_modules",".git","dist","tmp","coverage","build","out","target",".nx",".lensmcp"]);export function resolveExtraWatchRoots(e,t){if(!e)return[];const o=T(t),m=d((u,g)=>{const l=A(g,u);return l!==""&&!l.startsWith("..")&&!l.startsWith(C)&&!/^[A-Za-z]:/.test(l)},"inside"),a=[],y=d(u=>{a.length<z&&!a.includes(u)&&a.push(u)},"push");for(const u of e.split(q)){const g=u.trim();if(!g)continue;const l=T(g);let b;try{b=V(l)&&J(l).isDirectory()}catch{b=!1}if(b&&!(l===o||m(l,o))){if(m(o,l)){const E=A(l,o).split(C).filter(Boolean);let n=l;for(const i of E){let s;try{s=$(n,{withFileTypes:!0})}catch{s=[]}for(const c of s)!c.isDirectory()||c.name===i||c.name.startsWith(".")||Z.has(c.name)||y(F(n,c.name));n=F(n,i)}continue}y(l)}}return a}p(resolveExtraWatchRoots,"resolveExtraWatchRoots"),d(resolveExtraWatchRoots,"resolveExtraWatchRoots");export function lensmcpVitePlugin(e={},t={}){const o=e.enabled??!0,m=e.wsHost??"127.0.0.1",a=e.injectClient??!0;let y,u;const g=B(t),l=e.aliasValtio??!0,b=e.transformSource??!0,E=e.applyOnBuild??process.env.LENSMCP_VITE_APPLY_ON_BUILD==="1";return{name:"@lensmcp/vite-plugin",apply:d((n,i)=>o&&(i.command==="serve"||E),"apply"),enforce:"pre",wsPort:d(()=>y,"wsPort"),config(){if(!(!o||!l))return{resolve:{alias:[{find:/^valtio$/,replacement:"@lensmcp/valtio-instrumentation"}]}}},async configureServer(n){if(!o)return;u=await K({host:m,port:e.wsPort??0,bus:t.bus,sessionId:t.sessionId}),y=u.port,n.ws.on("vite:error",r=>{g(j(r,t.sessionId))});const i=resolveExtraWatchRoots(process.env.LENSMCP_WATCH_DIRS,n.config?.root??process.cwd());if(i.length>0&&typeof n.watcher?.add=="function")try{n.watcher.add(i),console.log(`[lensmcp] watching ${i.length} extra source root(s) for set changes: ${i.map(r=>A(n.config?.root??process.cwd(),r)||r).join(", ")}`)}catch(r){console.warn(`[lensmcp] could not widen the watcher: ${r?.message??String(r)}`)}let s=0,c=0,S=0;const w=[],h=d((r,f)=>{s=Date.now(),c+=1,S+=1,w.push({sequence:S,kind:r,path:T(f),at:s}),w.length>D&&w.splice(0,w.length-D)},"stampFsSetEvent");n.watcher.on("add",r=>h("add",r)),n.watcher.on("addDir",r=>h("addDir",r)),n.watcher.on("unlink",r=>h("unlink",r)),n.watcher.on("unlinkDir",r=>h("unlinkDir",r)),n.middlewares.use(Y,(r,f)=>{f.setHeader("content-type","application/json"),f.setHeader("cache-control","no-store"),f.end(JSON.stringify({schemaVersion:2,ready:!0,sequence:S,lastFsSetEventAt:s,fsSetEvents:c,recentEvents:w,extraWatchRoots:i,now:Date.now()}))})},resolveId(n){return n===L?O:null},load(n){if(n!==O)return null;const i=y??e.wsPort??0;return H({host:m,port:i})},async transform(n,i){if(!o||!b)return null;const s=i.split("?")[0]??i;if(s.includes("/node_modules/")||!/\.[jt]sx$/.test(s))return null;const c=await N(n,s);return c?{code:c.code,map:c.map}:null},transformIndexHtml(){if(!(!a||!o))return[{tag:"script",attrs:{type:"module",src:L},injectTo:"head-prepend"}]},handleHotUpdate(n){if(!o)return;const i=n.modules.map(s=>s.file??s.id??null).filter(s=>!!s);g({id:R(),sessionId:t.sessionId??"pending",timestamp:Date.now(),source:"vite",category:"build",severity:"info",context:{sessionId:t.sessionId??"pending"},fingerprint:I({kind:"hmr",identity:n.file}),title:`HMR ${n.file}`,location:{file:n.file},relatedFiles:i,raw:{kind:"hmr",file:n.file}})},generateBundle(n,i){if(!o)return;const s=[];let c=0;for(const w of Object.values(i)){const h=w,r=h.fileName;let f;if(h.type==="chunk")f=(h.code??"").length;else{const v=h.source;f=typeof v=="string"?v.length:v instanceof Uint8Array?v.byteLength:0}c+=f;const k=[];if(h.type==="chunk"&&h.modules){for(const[v,_]of Object.entries(h.modules)){const W=_.renderedLength??_.originalLength??0;k.push({id:v,sizeBytes:W})}k.sort((v,_)=>_.sizeBytes-v.sizeBytes)}s.push({name:r,sizeBytes:f,modules:k})}const S={timestamp:Date.now(),totalBytes:c,chunks:s};g({id:R(),sessionId:t.sessionId??"pending",timestamp:Date.now(),source:"rollup",category:"build",severity:"info",context:{sessionId:t.sessionId??"pending"},fingerprint:I({kind:"bundle",identity:"report"}),title:`Bundle report: ${s.length} chunks, ${c} bytes`,raw:{kind:"bundle-report",report:S}})},async closeBundle(){u&&(await u.close(),u=void 0)}}}p(lensmcpVitePlugin,"lensmcpVitePlugin"),d(lensmcpVitePlugin,"lensmcpVitePlugin");async function N(e,t){try{const[{transformSync:o},{lensmcpBabelPlugin:m}]=await Promise.all([import("@babel/core"),import("@lensmcp/react-instrumentation")]),a=o(e,{filename:t,babelrc:!1,configFile:!1,sourceMaps:!0,parserOpts:{plugins:["jsx","typescript"]},plugins:[[m,{rootDir:process.cwd()}]],code:!0});return a?.code?{code:a.code,map:a.map}:null}catch(o){return x(t,o),null}}p(N,"q"),d(N,"runLensmcpBabel");const M=new Set;function x(e,t){M.has(e)||(M.add(e),console.warn(`[lensmcp] could not instrument ${e}: ${t?.message??t}. The file still builds, but its renders, effects and hooks will be MISSING from react://renders/*, react://effects/recent and react://hooks/recent.`))}p(x,"J"),d(x,"warnTransformFailed");export function resetTransformFailuresForTests(){M.clear()}p(resetTransformFailuresForTests,"resetTransformFailuresForTests"),d(resetTransformFailuresForTests,"resetTransformFailuresForTests");export function handleClientEnvelope(e,t){G(e,B(t),t.sessionId)}p(handleClientEnvelope,"handleClientEnvelope"),d(handleClientEnvelope,"handleClientEnvelope");function P(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}:{}}}p(P,"K"),d(P,"errorLocation");function j(e,t){const o=e.err?.message??"Vite error",m=e.err?.stack,a=P(e.err);return{id:R(),sessionId:t??"pending",timestamp:Date.now(),source:"vite",category:"build",severity:"error",context:{sessionId:t??"pending"},fingerprint:I({kind:"vite",identity:e.type??o,...a?{file:a.file}:{}}),title:o,message:m,...a?{location:a}:{},raw:{kind:"build-diagnostic",...a?{file:a.file}:{},...e.err?.plugin?{plugin:e.err.plugin}:{}}}}p(j,"G"),d(j,"viteErrorToEvent");function H(e){return`// @lensmcp/client-runtime (inlined by @lensmcp/vite-plugin)
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)
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
- `}p(H,"Y"),d(H,"buildInlineClientRuntime");
316
+ `}d(z,"buildInlineClientRuntime");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/vite-plugin",
3
- "version": "1.22.5",
3
+ "version": "1.22.6",
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.22.5",
19
- "@lensmcp/core": "1.22.5",
20
- "@lensmcp/protocol-types": "1.22.5",
21
- "@lensmcp/react-instrumentation": "1.22.5",
22
- "@lensmcp/valtio-instrumentation": "1.22.5",
18
+ "@lensmcp/bridge": "1.22.6",
19
+ "@lensmcp/core": "1.22.6",
20
+ "@lensmcp/protocol-types": "1.22.6",
21
+ "@lensmcp/react-instrumentation": "1.22.6",
22
+ "@lensmcp/valtio-instrumentation": "1.22.6",
23
23
  "tslib": "^2.3.0"
24
24
  },
25
25
  "peerDependencies": {