@lensmcp/core 1.18.11 → 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-bus.js CHANGED
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var n=(e,t)=>o(e,"name",{value:t,configurable:!0});var c=Object.defineProperty,h=n((e,t)=>c(e,"name",{value:t,configurable:!0}),"e");export class EventBus{static{n(this,"EventBus")}static{h(this,"EventBus")}constructor(t={}){this.subs=new Set,this.dropped=0,this.capacity=t.capacity??1e4,this.onDrop=t.onDrop,this.transform=t.transform}publish(t){if(this.subs.size>this.capacity){this.dropped++,this.onDrop?.(1);return}let s=t;if(this.transform)try{s=this.transform(t)??t}catch{s=t}for(const r of this.subs)if(!(r.filter&&!r.filter(s)))try{const i=r.handler(s);i&&typeof i.then=="function"&&i.catch(()=>{})}catch{}}subscribe(t,s){const r={handler:t,filter:s};return this.subs.add(r),()=>{this.subs.delete(r)}}droppedCount(){return this.dropped}subscriberCount(){return this.subs.size}}
1
+ "use strict";var c=Object.defineProperty;var n=(s,t)=>c(s,"name",{value:t,configurable:!0});var a=Object.defineProperty,o=n((s,t)=>a(s,"name",{value:t,configurable:!0}),"n"),h=Object.defineProperty,u=o((s,t)=>h(s,"name",{value:t,configurable:!0}),"e");export class EventBus{static{n(this,"EventBus")}static{o(this,"EventBus")}static{u(this,"EventBus")}constructor(t={}){this.subs=new Set,this.dropped=0,this.capacity=t.capacity??1e4,this.onDrop=t.onDrop,this.transform=t.transform}publish(t){if(this.subs.size>this.capacity){this.dropped++,this.onDrop?.(1);return}let r=t;if(this.transform)try{r=this.transform(t)??t}catch{r=t}for(const e of this.subs)if(!(e.filter&&!e.filter(r)))try{const i=e.handler(r);i&&typeof i.then=="function"&&i.catch(()=>{})}catch{}}subscribe(t,r){const e={handler:t,filter:r};return this.subs.add(e),()=>{this.subs.delete(e)}}droppedCount(){return this.dropped}subscriberCount(){return this.subs.size}}
@@ -1 +1 @@
1
- "use strict";var a=Object.defineProperty;var r=(n,e)=>a(n,"name",{value:e,configurable:!0});var f=Object.defineProperty,i=r((n,e)=>f(n,"name",{value:e,configurable:!0}),"e");const l=2166136261,u=16777619;function o(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return(e>>>0).toString(16).padStart(8,"0")}r(o,"i"),i(o,"fnv1a32");export function fingerprint(n){const e=[n.kind,n.identity,n.file??"",n.detail??""];return`${n.kind}:${o(e.join("|"))}`}r(fingerprint,"fingerprint"),i(fingerprint,"fingerprint");
1
+ "use strict";var f=Object.defineProperty;var r=(e,t)=>f(e,"name",{value:t,configurable:!0});var l=Object.defineProperty,n=r((e,t)=>l(e,"name",{value:t,configurable:!0}),"r"),u=Object.defineProperty,o=n((e,t)=>u(e,"name",{value:t,configurable:!0}),"e");const d=2166136261,g=16777619;function a(e){let t=2166136261;for(let i=0;i<e.length;i++)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}r(a,"o"),n(a,"i"),o(a,"fnv1a32");export function fingerprint(e){const t=[e.kind,e.identity,e.file??"",e.detail??""];return`${e.kind}:${a(t.join("|"))}`}r(fingerprint,"fingerprint"),n(fingerprint,"fingerprint"),o(fingerprint,"fingerprint");
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var u=(t,r)=>g(t,"name",{value:r,configurable:!0});var I=Object.defineProperty,l=u((t,r)=>I(t,"name",{value:r,configurable:!0}),"u");function m(t){const r=t.raw??null,c=r?.kind,s=t.context,a={id:t.id,parentTraceNodeId:s.causedByNodeId??s.originNodeId,lifecycle:"completed",context:s,startTime:t.timestamp,attributes:{...r??{}}};if(t.source==="react"&&c==="render"){const n=r;return{parentAxis:"render",node:{...a,type:"render",logicalId:n.render?.componentLogicalId,instanceId:n.render?.componentInstanceId,name:`render ${n.render?.componentName??"?"}`,durationMs:n.render?.actualDurationMs}}}if(t.source==="valtio"&&c==="state-update"){const n=r;return{parentAxis:"state",node:{...a,type:"state-update",logicalId:n.update?.storeId,name:`${n.update?.storeId??"?"}.${n.update?.path??"?"}`}}}if(t.source==="nestjs"&&c==="server-request"){const n=r;return{parentAxis:"backend",node:{...a,type:"server-request",name:`${n.request?.method??"?"} ${n.request?.route??"?"}`,durationMs:n.request?.durationMs}}}if(c==="loop")return{parentAxis:"performance",node:{...a,type:"loop",name:"loop",durationMs:r.loop?.durationMs}};if(t.source==="client-runtime"&&c==="user-action"){const n=r;return{parentAxis:"caused",node:{...a,type:"ui-event",logicalId:n.origin?.nodeId,name:n.origin?.label??t.title}}}}u(m,"f"),l(m,"eventToNode");export function buildGraphFromEvents(t,r){const c=[...r].sort((o,e)=>o.timestamp-e.timestamp),s=[];for(const o of c){const e=m(o);e&&(t.addNode(e.node),s.push(e))}let a=0;const n=l((o,e,d,i)=>{const f={id:`${d}:${o}->${e}`,from:o,to:e,axis:d,type:i,timestamp:t.getNode(e)?.startTime??0};t.addEdge(f),a++},"addEdge");for(const o of s){const e=o.node.context.causedByNodeId;e&&t.getNode(e)&&n(e,o.node.id,o.parentAxis??"caused","caused-by")}const p=new Map;for(const o of s){const e=o.node.context.flowId;if(!e)continue;let d=p.get(e);d||(d=[],p.set(e,d)),d.push(o)}for(const o of p.values())for(let e=1;e<o.length;e++){const d=o[e-1].node,i=o[e].node;i.context.causedByNodeId!==d.id&&n(d.id,i.id,"caused","flow-sequence")}return{nodeCount:s.length,edgeCount:a}}u(buildGraphFromEvents,"buildGraphFromEvents"),l(buildGraphFromEvents,"buildGraphFromEvents");
1
+ "use strict";var I=Object.defineProperty;var u=(t,r)=>I(t,"name",{value:r,configurable:!0});var v=Object.defineProperty,l=u((t,r)=>v(t,"name",{value:r,configurable:!0}),"u"),x=Object.defineProperty,m=l((t,r)=>x(t,"name",{value:r,configurable:!0}),"u");function f(t){const r=t.raw??null,i=r?.kind,a=t.context,s={id:t.id,parentTraceNodeId:a.causedByNodeId??a.originNodeId,lifecycle:"completed",context:a,startTime:t.timestamp,attributes:{...r??{}}};if(t.source==="react"&&i==="render"){const n=r;return{parentAxis:"render",node:{...s,type:"render",logicalId:n.render?.componentLogicalId,instanceId:n.render?.componentInstanceId,name:`render ${n.render?.componentName??"?"}`,durationMs:n.render?.actualDurationMs}}}if(t.source==="valtio"&&i==="state-update"){const n=r;return{parentAxis:"state",node:{...s,type:"state-update",logicalId:n.update?.storeId,name:`${n.update?.storeId??"?"}.${n.update?.path??"?"}`}}}if(t.source==="nestjs"&&i==="server-request"){const n=r;return{parentAxis:"backend",node:{...s,type:"server-request",name:`${n.request?.method??"?"} ${n.request?.route??"?"}`,durationMs:n.request?.durationMs}}}if(i==="loop")return{parentAxis:"performance",node:{...s,type:"loop",name:"loop",durationMs:r.loop?.durationMs}};if(t.source==="client-runtime"&&i==="user-action"){const n=r;return{parentAxis:"caused",node:{...s,type:"ui-event",logicalId:n.origin?.nodeId,name:n.origin?.label??t.title}}}}u(f,"m"),l(f,"f"),m(f,"eventToNode");export function buildGraphFromEvents(t,r){const i=[...r].sort((o,e)=>o.timestamp-e.timestamp),a=[];for(const o of i){const e=f(o);e&&(t.addNode(e.node),a.push(e))}let s=0;const n=m((o,e,d,c)=>{const g={id:`${d}:${o}->${e}`,from:o,to:e,axis:d,type:c,timestamp:t.getNode(e)?.startTime??0};t.addEdge(g),s++},"addEdge");for(const o of a){const e=o.node.context.causedByNodeId;e&&t.getNode(e)&&n(e,o.node.id,o.parentAxis??"caused","caused-by")}const p=new Map;for(const o of a){const e=o.node.context.flowId;if(!e)continue;let d=p.get(e);d||(d=[],p.set(e,d)),d.push(o)}for(const o of p.values())for(let e=1;e<o.length;e++){const d=o[e-1].node,c=o[e].node;c.context.causedByNodeId!==d.id&&n(d.id,c.id,"caused","flow-sequence")}return{nodeCount:a.length,edgeCount:s}}u(buildGraphFromEvents,"buildGraphFromEvents"),l(buildGraphFromEvents,"buildGraphFromEvents"),m(buildGraphFromEvents,"buildGraphFromEvents");
@@ -1 +1 @@
1
- "use strict";var w=Object.defineProperty;var l=(h,e)=>w(h,"name",{value:e,configurable:!0});var p=Object.defineProperty,I=l((h,e)=>p(h,"name",{value:e,configurable:!0}),"l");const m=4,N=1e3;export class GraphStore{static{l(this,"GraphStore")}static{I(this,"GraphStore")}constructor(){this.nodes=new Map,this.edges=new Map,this.byParent=new Map,this.byFlow=new Map,this.byLogical=new Map,this.byInstance=new Map,this.byRequest=new Map,this.outByAxis=new Map,this.inByAxis=new Map}addNode(e){this.nodes.set(e.id,e),e.parentTraceNodeId&&this.addToIndex(this.byParent,e.parentTraceNodeId,e.id),e.context.flowId&&this.addToIndex(this.byFlow,e.context.flowId,e.id),e.logicalId&&this.addToIndex(this.byLogical,e.logicalId,e.id),e.instanceId&&this.addToIndex(this.byInstance,e.instanceId,e.id),e.context.requestId&&this.addToIndex(this.byRequest,e.context.requestId,e.id)}updateNode(e,s){const i=this.nodes.get(e);if(!i)throw new Error(`Unknown node: ${e}`);const t={...i,...s,id:i.id};return this.nodes.set(e,t),t}getNode(e){return this.nodes.get(e)}addEdge(e){this.edges.set(e.id,e);let s=this.outByAxis.get(e.axis);s||(s=new Map,this.outByAxis.set(e.axis,s)),this.addToIndex(s,e.from,e.id);let i=this.inByAxis.get(e.axis);i||(i=new Map,this.inByAxis.set(e.axis,i)),this.addToIndex(i,e.to,e.id)}getEdge(e){return this.edges.get(e)}childrenOf(e){return this.materialiseNodes(this.byParent.get(e))}nodesInFlow(e){return this.materialiseNodes(this.byFlow.get(e))}nodesByLogical(e){return this.materialiseNodes(this.byLogical.get(e))}nodesByInstance(e){return this.materialiseNodes(this.byInstance.get(e))}nodesByRequest(e){return this.materialiseNodes(this.byRequest.get(e))}traverse(e){const s=this.nodes.get(e.from);if(!s)return{nodes:[],edges:[]};const i=Array.isArray(e.lens)?e.lens:[e.lens],t=e.direction??"both",f=e.depth??4,x=e.maxNodes??1e3,n=new Set,g=new Set,c=[{id:s.id,d:0}];for(;c.length&&!(n.size>=x);){const{id:d,d:u}=c.shift();if(!n.has(d)&&(n.add(d),!(u>=f)))for(const y of i){if(t==="out"||t==="both"){const o=this.outByAxis.get(y)?.get(d);if(o)for(const a of o){g.add(a);const r=this.edges.get(a);n.has(r.to)||c.push({id:r.to,d:u+1})}}if(t==="in"||t==="both"){const o=this.inByAxis.get(y)?.get(d);if(o)for(const a of o){g.add(a);const r=this.edges.get(a);n.has(r.from)||c.push({id:r.from,d:u+1})}}}}return{nodes:this.materialiseNodes(n),edges:[...g].map(d=>this.edges.get(d)).filter(d=>!!d)}}nodeCount(){return this.nodes.size}edgeCount(){return this.edges.size}addToIndex(e,s,i){let t=e.get(s);t||(t=new Set,e.set(s,t)),t.add(i)}materialiseNodes(e){if(!e)return[];const s=[];for(const i of e){const t=this.nodes.get(i);t&&s.push(t)}return s}}
1
+ "use strict";var w=Object.defineProperty;var l=(d,t)=>w(d,"name",{value:t,configurable:!0});var I=Object.defineProperty,y=l((d,t)=>I(d,"name",{value:t,configurable:!0}),"l"),b=Object.defineProperty,m=y((d,t)=>b(d,"name",{value:t,configurable:!0}),"l");const B=4,M=1e3;export class GraphStore{static{l(this,"GraphStore")}static{y(this,"GraphStore")}static{m(this,"GraphStore")}constructor(){this.nodes=new Map,this.edges=new Map,this.byParent=new Map,this.byFlow=new Map,this.byLogical=new Map,this.byInstance=new Map,this.byRequest=new Map,this.outByAxis=new Map,this.inByAxis=new Map}addNode(t){this.nodes.set(t.id,t),t.parentTraceNodeId&&this.addToIndex(this.byParent,t.parentTraceNodeId,t.id),t.context.flowId&&this.addToIndex(this.byFlow,t.context.flowId,t.id),t.logicalId&&this.addToIndex(this.byLogical,t.logicalId,t.id),t.instanceId&&this.addToIndex(this.byInstance,t.instanceId,t.id),t.context.requestId&&this.addToIndex(this.byRequest,t.context.requestId,t.id)}updateNode(t,e){const i=this.nodes.get(t);if(!i)throw new Error(`Unknown node: ${t}`);const s={...i,...e,id:i.id};return this.nodes.set(t,s),s}getNode(t){return this.nodes.get(t)}addEdge(t){this.edges.set(t.id,t);let e=this.outByAxis.get(t.axis);e||(e=new Map,this.outByAxis.set(t.axis,e)),this.addToIndex(e,t.from,t.id);let i=this.inByAxis.get(t.axis);i||(i=new Map,this.inByAxis.set(t.axis,i)),this.addToIndex(i,t.to,t.id)}getEdge(t){return this.edges.get(t)}childrenOf(t){return this.materialiseNodes(this.byParent.get(t))}nodesInFlow(t){return this.materialiseNodes(this.byFlow.get(t))}nodesByLogical(t){return this.materialiseNodes(this.byLogical.get(t))}nodesByInstance(t){return this.materialiseNodes(this.byInstance.get(t))}nodesByRequest(t){return this.materialiseNodes(this.byRequest.get(t))}traverse(t){const e=this.nodes.get(t.from);if(!e)return{nodes:[],edges:[]};const i=Array.isArray(t.lens)?t.lens:[t.lens],s=t.direction??"both",x=t.depth??4,p=t.maxNodes??1e3,o=new Set,g=new Set,c=[{id:e.id,d:0}];for(;c.length&&!(o.size>=p);){const{id:n,d:u}=c.shift();if(!o.has(n)&&(o.add(n),!(u>=x)))for(const f of i){if(s==="out"||s==="both"){const a=this.outByAxis.get(f)?.get(n);if(a)for(const r of a){g.add(r);const h=this.edges.get(r);o.has(h.to)||c.push({id:h.to,d:u+1})}}if(s==="in"||s==="both"){const a=this.inByAxis.get(f)?.get(n);if(a)for(const r of a){g.add(r);const h=this.edges.get(r);o.has(h.from)||c.push({id:h.from,d:u+1})}}}}return{nodes:this.materialiseNodes(o),edges:[...g].map(n=>this.edges.get(n)).filter(n=>!!n)}}nodeCount(){return this.nodes.size}edgeCount(){return this.edges.size}addToIndex(t,e,i){let s=t.get(e);s||(s=new Set,t.set(e,s)),s.add(i)}materialiseNodes(t){if(!t)return[];const e=[];for(const i of t){const s=this.nodes.get(i);s&&e.push(s)}return e}}
package/lib/patterns.js CHANGED
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var p=(c,a)=>g(c,"name",{value:a,configurable:!0});var M=Object.defineProperty,f=p((c,a)=>M(c,"name",{value:a,configurable:!0}),"p");export function detectDbInLoop(c,a={}){const d=a.threshold??5,i=[];for(const s of c){const n=s.raw??null;if(n?.kind!=="loop"||!n.loop)continue;const e=n.loop.dbCallsInsideLoop??0;e>d&&i.push({kind:"db-in-loop",severity:"warning",title:`${e} DB calls inside a loop (${n.loop.iterations??"?"} iterations)`,evidence:[s.id],details:{dbCallsInsideLoop:e,iterations:n.loop.iterations,durationMs:n.loop.durationMs,threshold:d},detectedAt:s.timestamp})}return i}p(detectDbInLoop,"detectDbInLoop"),f(detectDbInLoop,"detectDbInLoop");export function detectNPlusOne(c,a={}){const d=a.threshold??3,i=new Map;for(const n of c){const e=n.raw??null;if(e?.kind!=="db-query"||!e.query?.signature)continue;const t=e.query.signature;let o=i.get(t);o||(o=[],i.set(t,o)),o.push(n)}const s=[];for(const[n,e]of i)e.length>=d&&s.push({kind:"n+1-query",severity:"warning",title:`Query repeated ${e.length}\xD7 \u2014 likely N+1`,evidence:e.map(t=>t.id),details:{signature:n,count:e.length,threshold:d},detectedAt:e[e.length-1].timestamp});return s}p(detectNPlusOne,"detectNPlusOne"),f(detectNPlusOne,"detectNPlusOne");export function detectRenderStorm(c,a={}){const d=a.threshold??5,i=a.windowMs??250,s=new Map;for(const e of c){if(e.source!=="react")continue;const t=e.raw??null;if(t?.kind!=="render"||!t.render?.componentInstanceId)continue;const o=t.render.componentInstanceId;let r=s.get(o);r||(r=[],s.set(o,r)),r.push(e)}const n=[];for(const[e,t]of s){t.sort((r,u)=>r.timestamp-u.timestamp);let o=0;for(let r=0;r<t.length;r++){for(;t[r].timestamp-t[o].timestamp>i;)o++;const u=r-o+1;if(u>d){const l=t.slice(o,r+1),h=l[0].raw.render?.componentName??e;n.push({kind:"render-storm",severity:"warning",title:`${h} rendered ${u}\xD7 in ${i}ms`,evidence:l.map(m=>m.id),details:{componentInstanceId:e,count:u,windowMs:i,threshold:d},detectedAt:l[l.length-1].timestamp});break}}}return n}p(detectRenderStorm,"detectRenderStorm"),f(detectRenderStorm,"detectRenderStorm");export function findSlowPath(c,a,d){const i=new Map,s=new Set;function n(t){const o=i.get(t);if(o)return o;if(s.has(t))return{path:[t],totalDurationMs:d(t)};s.add(t);const r=d(t),u=a.get(t)??[];let l;for(const m of u){const w=n(m);(!l||w.totalDurationMs>l.totalDurationMs)&&(l=w)}s.delete(t);const h=l?{path:[t,...l.path],totalDurationMs:r+l.totalDurationMs}:{path:[t],totalDurationMs:r};return i.set(t,h),h}p(n,"o"),f(n,"best");let e={path:[],totalDurationMs:0};for(const t of c){const o=n(t);o.totalDurationMs>e.totalDurationMs&&(e=o)}return e}p(findSlowPath,"findSlowPath"),f(findSlowPath,"findSlowPath");
1
+ "use strict";var M=Object.defineProperty;var p=(a,s)=>M(a,"name",{value:s,configurable:!0});var D=Object.defineProperty,f=p((a,s)=>D(a,"name",{value:s,configurable:!0}),"p"),b=Object.defineProperty,h=f((a,s)=>b(a,"name",{value:s,configurable:!0}),"p");export function detectDbInLoop(a,s={}){const l=s.threshold??5,d=[];for(const i of a){const n=i.raw??null;if(n?.kind!=="loop"||!n.loop)continue;const e=n.loop.dbCallsInsideLoop??0;e>l&&d.push({kind:"db-in-loop",severity:"warning",title:`${e} DB calls inside a loop (${n.loop.iterations??"?"} iterations)`,evidence:[i.id],details:{dbCallsInsideLoop:e,iterations:n.loop.iterations,durationMs:n.loop.durationMs,threshold:l},detectedAt:i.timestamp})}return d}p(detectDbInLoop,"detectDbInLoop"),f(detectDbInLoop,"detectDbInLoop"),h(detectDbInLoop,"detectDbInLoop");export function detectNPlusOne(a,s={}){const l=s.threshold??3,d=new Map;for(const n of a){const e=n.raw??null;if(e?.kind!=="db-query"||!e.query?.signature)continue;const t=e.query.signature;let o=d.get(t);o||(o=[],d.set(t,o)),o.push(n)}const i=[];for(const[n,e]of d)e.length>=l&&i.push({kind:"n+1-query",severity:"warning",title:`Query repeated ${e.length}\xD7 \u2014 likely N+1`,evidence:e.map(t=>t.id),details:{signature:n,count:e.length,threshold:l},detectedAt:e[e.length-1].timestamp});return i}p(detectNPlusOne,"detectNPlusOne"),f(detectNPlusOne,"detectNPlusOne"),h(detectNPlusOne,"detectNPlusOne");export function detectRenderStorm(a,s={}){const l=s.threshold??5,d=s.windowMs??250,i=new Map;for(const e of a){if(e.source!=="react")continue;const t=e.raw??null;if(t?.kind!=="render"||!t.render?.componentInstanceId)continue;const o=t.render.componentInstanceId;let r=i.get(o);r||(r=[],i.set(o,r)),r.push(e)}const n=[];for(const[e,t]of i){t.sort((r,u)=>r.timestamp-u.timestamp);let o=0;for(let r=0;r<t.length;r++){for(;t[r].timestamp-t[o].timestamp>d;)o++;const u=r-o+1;if(u>l){const c=t.slice(o,r+1),m=c[0].raw.render?.componentName??e;n.push({kind:"render-storm",severity:"warning",title:`${m} rendered ${u}\xD7 in ${d}ms`,evidence:c.map(g=>g.id),details:{componentInstanceId:e,count:u,windowMs:d,threshold:l},detectedAt:c[c.length-1].timestamp});break}}}return n}p(detectRenderStorm,"detectRenderStorm"),f(detectRenderStorm,"detectRenderStorm"),h(detectRenderStorm,"detectRenderStorm");export function findSlowPath(a,s,l){const d=new Map,i=new Set;function n(t){const o=d.get(t);if(o)return o;if(i.has(t))return{path:[t],totalDurationMs:l(t)};i.add(t);const r=l(t),u=s.get(t)??[];let c;for(const g of u){const w=n(g);(!c||w.totalDurationMs>c.totalDurationMs)&&(c=w)}i.delete(t);const m=c?{path:[t,...c.path],totalDurationMs:r+c.totalDurationMs}:{path:[t],totalDurationMs:r};return d.set(t,m),m}p(n,"n"),f(n,"o"),h(n,"best");let e={path:[],totalDurationMs:0};for(const t of a){const o=n(t);o.totalDurationMs>e.totalDurationMs&&(e=o)}return e}p(findSlowPath,"findSlowPath"),f(findSlowPath,"findSlowPath"),h(findSlowPath,"findSlowPath");
package/lib/redact.js CHANGED
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var o=(e,r)=>f(e,"name",{value:r,configurable:!0});var l=Object.defineProperty,a=o((e,r)=>l(e,"name",{value:r,configurable:!0}),"o");export const REDACTED="REDACTED",MAX_TITLE_CHARS=300,MAX_MESSAGE_CHARS=4096,MAX_URL_CHARS=1024;const d=["token","secret","password","passwd","apikey","credential","assertion","signature"],x=new Set(["key","auth","authorization","jwt","code","sig","pwd","pass","session","sid","bearer","otp","cookie","set-cookie"]);export function isSecretParam(e){const r=e.toLowerCase();if(d.some(t=>r.includes(t)))return!0;for(const t of r.split(/[-_.]+/))if(t&&x.has(t))return!0;return!1}o(isSecretParam,"isSecretParam"),a(isSecretParam,"isSecretParam");const A=/^([a-z][a-z0-9+.-]*:\/\/)[^/?#@\s]*@/i,$=/([?&#])([^=&#\s]+)=([^&#\s]*)/g;export function redactUrlParams(e){return e&&e.replace(A,`$1${REDACTED}@`).replace($,(r,t,s)=>isSecretParam(s)?`${t}${s}=${REDACTED}`:r)}o(redactUrlParams,"redactUrlParams"),a(redactUrlParams,"redactUrlParams");export function redactUrl(e){return e&&clip(redactUrlParams(e),1024)}o(redactUrl,"redactUrl"),a(redactUrl,"redactUrl");const _=/\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]*/g,b=/\b(bearer|basic)\s+[A-Za-z0-9._~+/=-]{8,}/gi,y=/\b(authorization|x-api-key|api-key|cookie|set-cookie|proxy-authorization)\b(\s*[:=]\s*)(["']?)([^\s"',;]{4,})\3/gi;export function redactText(e){return redactUrlParams(e).replace(y,(r,t,s,n)=>`${t}${s}${n}${REDACTED}${n}`).replace(_,REDACTED).replace(b,(r,t)=>`${t} ${REDACTED}`)}o(redactText,"redactText"),a(redactText,"redactText");export function clip(e,r){return e.length<=r?e:`${e.slice(0,r)}\u2026[lensmcp truncated: ${e.length-r} more chars]`}o(clip,"clip"),a(clip,"clip");export function safeText(e,r=4096){if(e!==void 0)return clip(redactText(e),r)}o(safeText,"safeText"),a(safeText,"safeText");export function safeTitle(e){return clip(redactText(e),300)}o(safeTitle,"safeTitle"),a(safeTitle,"safeTitle");const T=6,g=64;export function redactDeep(e,r=0){if(typeof e=="string")return redactText(e);if(e===null||typeof e!="object"||r>=T)return e;if(Array.isArray(e)){let n=!1;const i=e.map((c,p)=>{if(p>=g)return c;const u=redactDeep(c,r+1);return u!==c&&(n=!0),u});return n?i:e}let t=!1;const s={};for(const[n,i]of Object.entries(e)){const c=isSecretParam(n)&&i!==void 0&&i!==null?REDACTED:redactDeep(i,r+1);c!==i&&(t=!0),s[n]=c}return t?s:e}o(redactDeep,"redactDeep"),a(redactDeep,"redactDeep");
1
+ "use strict";var f=Object.defineProperty;var a=(e,t)=>f(e,"name",{value:t,configurable:!0});var d=Object.defineProperty,o=a((e,t)=>d(e,"name",{value:t,configurable:!0}),"o"),x=Object.defineProperty,c=o((e,t)=>x(e,"name",{value:t,configurable:!0}),"o");export const REDACTED="REDACTED",MAX_TITLE_CHARS=300,MAX_MESSAGE_CHARS=4096,MAX_URL_CHARS=1024;const A=["token","secret","password","passwd","apikey","credential","assertion","signature"],$=new Set(["key","auth","authorization","jwt","code","sig","pwd","pass","session","sid","bearer","otp","cookie","set-cookie"]);export function isSecretParam(e){const t=e.toLowerCase();if(A.some(r=>t.includes(r)))return!0;for(const r of t.split(/[-_.]+/))if(r&&$.has(r))return!0;return!1}a(isSecretParam,"isSecretParam"),o(isSecretParam,"isSecretParam"),c(isSecretParam,"isSecretParam");const b=/^([a-z][a-z0-9+.-]*:\/\/)[^/?#@\s]*@/i,T=/([?&#])([^=&#\s]+)=([^&#\s]*)/g;export function redactUrlParams(e){return e&&e.replace(b,`$1${REDACTED}@`).replace(T,(t,r,i)=>isSecretParam(i)?`${r}${i}=${REDACTED}`:t)}a(redactUrlParams,"redactUrlParams"),o(redactUrlParams,"redactUrlParams"),c(redactUrlParams,"redactUrlParams");export function redactUrl(e){return e&&clip(redactUrlParams(e),1024)}a(redactUrl,"redactUrl"),o(redactUrl,"redactUrl"),c(redactUrl,"redactUrl");const y=/\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]*/g,g=/\b(bearer|basic)\s+[A-Za-z0-9._~+/=-]{8,}/gi,m=/\b(authorization|x-api-key|api-key|cookie|set-cookie|proxy-authorization)\b(\s*[:=]\s*)(["']?)([^\s"',;]{4,})\3/gi;export function redactText(e){return redactUrlParams(e).replace(m,(t,r,i,n)=>`${r}${i}${n}${REDACTED}${n}`).replace(y,REDACTED).replace(g,(t,r)=>`${r} ${REDACTED}`)}a(redactText,"redactText"),o(redactText,"redactText"),c(redactText,"redactText");export function clip(e,t){return e.length<=t?e:`${e.slice(0,t)}\u2026[lensmcp truncated: ${e.length-t} more chars]`}a(clip,"clip"),o(clip,"clip"),c(clip,"clip");export function safeText(e,t=4096){if(e!==void 0)return clip(redactText(e),t)}a(safeText,"safeText"),o(safeText,"safeText"),c(safeText,"safeText");export function safeTitle(e){return clip(redactText(e),300)}a(safeTitle,"safeTitle"),o(safeTitle,"safeTitle"),c(safeTitle,"safeTitle");const _=6,k=64;export function redactDeep(e,t=0){if(typeof e=="string")return redactText(e);if(e===null||typeof e!="object"||t>=_)return e;if(Array.isArray(e)){let n=!1;const s=e.map((u,l)=>{if(l>=k)return u;const p=redactDeep(u,t+1);return p!==u&&(n=!0),p});return n?s:e}let r=!1;const i={};for(const[n,s]of Object.entries(e)){const u=isSecretParam(n)&&s!==void 0&&s!==null?REDACTED:redactDeep(s,t+1);u!==s&&(r=!0),i[n]=u}return r?i:e}a(redactDeep,"redactDeep"),o(redactDeep,"redactDeep"),c(redactDeep,"redactDeep");
@@ -1 +1 @@
1
- "use strict";var i=Object.defineProperty;var c=(t,e)=>i(t,"name",{value:e,configurable:!0});var u=Object.defineProperty,a=c((t,e)=>u(t,"name",{value:e,configurable:!0}),"c");export class ReducerRegistry{static{c(this,"ReducerRegistry")}static{a(this,"ReducerRegistry")}constructor(){this.reducers=[]}register(e,s){if(this.reducers.some(r=>r.name===e))throw new Error(`Reducer already registered: ${e}`);this.reducers.push({name:e,reducer:s})}list(){return this.reducers}async dispatch(e){for(const{reducer:s}of this.reducers)try{const r=s(e);r&&typeof r.then=="function"&&await r}catch{}}}
1
+ "use strict";var a=Object.defineProperty;var c=(r,e)=>a(r,"name",{value:e,configurable:!0});var u=Object.defineProperty,i=c((r,e)=>u(r,"name",{value:e,configurable:!0}),"c"),n=Object.defineProperty,d=i((r,e)=>n(r,"name",{value:e,configurable:!0}),"c");export class ReducerRegistry{static{c(this,"ReducerRegistry")}static{i(this,"ReducerRegistry")}static{d(this,"ReducerRegistry")}constructor(){this.reducers=[]}register(e,s){if(this.reducers.some(t=>t.name===e))throw new Error(`Reducer already registered: ${e}`);this.reducers.push({name:e,reducer:s})}list(){return this.reducers}async dispatch(e){for(const{reducer:s}of this.reducers)try{const t=s(e);t&&typeof t.then=="function"&&await t}catch{}}}
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var i=(r,e)=>u(r,"name",{value:e,configurable:!0});var a=Object.defineProperty,h=i((r,e)=>a(r,"name",{value:e,configurable:!0}),"o");export class ResourceStore{static{i(this,"ResourceStore")}static{h(this,"ResourceStore")}constructor(){this.entries=new Map,this.subs=new Map}register(e,t){if(this.entries.has(e))throw new Error(`Resource already registered: ${e}`);return this.entries.set(e,{uri:e,produce:t,revision:0}),()=>{this.entries.delete(e),this.subs.delete(e)}}async read(e){const t=this.entries.get(e);if(!t)throw new Error(`Unknown resource: ${e}`);return t.produce()}list(){return[...this.entries.keys()]}async markDirty(e){const t=this.entries.get(e);if(!t)return;const s=await t.produce(),n=JSON.stringify(s);if(n===t.lastJson)return;t.lastJson=n,t.revision+=1;const o=this.subs.get(e);if(o)for(const c of o)try{c(e,t.revision)}catch{}}revision(e){return this.entries.get(e)?.revision}subscribe(e,t){let s=this.subs.get(e);return s||(s=new Set,this.subs.set(e,s)),s.add(t),()=>{s?.delete(t)}}}
1
+ "use strict";var a=Object.defineProperty;var i=(s,e)=>a(s,"name",{value:e,configurable:!0});var h=Object.defineProperty,c=i((s,e)=>h(s,"name",{value:e,configurable:!0}),"i"),d=Object.defineProperty,l=c((s,e)=>d(s,"name",{value:e,configurable:!0}),"o");export class ResourceStore{static{i(this,"ResourceStore")}static{c(this,"ResourceStore")}static{l(this,"ResourceStore")}constructor(){this.entries=new Map,this.subs=new Map}register(e,t){if(this.entries.has(e))throw new Error(`Resource already registered: ${e}`);return this.entries.set(e,{uri:e,produce:t,revision:0}),()=>{this.entries.delete(e),this.subs.delete(e)}}async read(e){const t=this.entries.get(e);if(!t)throw new Error(`Unknown resource: ${e}`);return t.produce()}list(){return[...this.entries.keys()]}async markDirty(e){const t=this.entries.get(e);if(!t)return;const r=await t.produce(),n=JSON.stringify(r);if(n===t.lastJson)return;t.lastJson=n,t.revision+=1;const o=this.subs.get(e);if(o)for(const u of o)try{u(e,t.revision)}catch{}}revision(e){return this.entries.get(e)?.revision}subscribe(e,t){let r=this.subs.get(e);return r||(r=new Set,this.subs.set(e,r)),r.add(t),()=>{r?.delete(t)}}}
package/lib/story.js CHANGED
@@ -1 +1 @@
1
- "use strict";var w=Object.defineProperty;var u=(e,n)=>w(e,"name",{value:n,configurable:!0});var I=Object.defineProperty,m=u((e,n)=>I(e,"name",{value:n,configurable:!0}),"c");export function groupByFlow(e){const n=new Map;for(const t of e){const o=t.context.flowId;if(!o)continue;let s=n.get(o);s||(s=[],n.set(o,s)),s.push(t)}return n}u(groupByFlow,"groupByFlow"),m(groupByFlow,"groupByFlow");export function compileStory(e,n={}){let t,o;if(n.flowId)o=n.flowId,t=e.filter(r=>r.context.flowId===o);else{const r=e.find(i=>i.context.flowId);if(!r)return;o=r.context.flowId,t=e.filter(i=>i.context.flowId===o)}if(t.length===0)return;t.sort((r,i)=>r.timestamp-i.timestamp);const s=1e3;t.length>s&&(t=[t[0],...t.slice(t.length-(s-1))]);const c=t[0],d=[];let l,p;for(const r of t){const i=f(r);if(i){if(d.push(i),i.kind==="render"||i.kind==="final-render"){const a=r.raw;a?.render&&(l={id:a.render.id,page:a.render.page,route:a.render.route,componentName:a.render.componentName})}else if(r.source==="visual"&&i.kind==="visual-violation"){const a=r.raw;a?.frame&&(p=a.frame.id)}}}for(let r=d.length-1;r>=0;r--)if(d[r].kind==="render"){d[r]={...d[r],kind:"final-render"};break}const v=t[0].timestamp,g=t[t.length-1].timestamp;return{flowId:o,origin:{type:c.context.originType,nodeId:c.context.originNodeId,at:c.timestamp},phases:d,finalState:l?{page:l.page,route:l.route,componentName:l.componentName,renderId:l.id,visualFrameId:p}:void 0,startedAt:v,endedAt:g,eventCount:t.length}}u(compileStory,"compileStory"),m(compileStory,"compileStory");function f(e){const n=(e.raw??null)?.kind;if(n==="flow-origin"||e.source==="client-runtime"&&n==="user-action"){const t=e.raw;return{kind:"user-action",at:e.timestamp,label:t?.origin?.label??e.title,eventIds:[e.id]}}if(e.source==="react"&&n==="render"){const t=e.raw;return{kind:"render",at:e.timestamp,label:`render ${t?.render?.componentName??"?"}`,eventIds:[e.id],details:t?.render?{componentName:t.render.componentName,durationMs:t.render.actualDurationMs}:void 0}}if(e.source==="react"&&n==="slot-content-changed"){const t=e.raw,o=t?.slot?.toComponent??"?";return{kind:/spinner|loader|loading/i.test(o)?"loading-ui":"idle-ui",at:e.timestamp,label:`slot ${t?.slot?.slotLogicalId??""} \u2192 ${o}`,eventIds:[e.id]}}if(e.source==="client-runtime"&&n==="route"){const t=e.raw;return{kind:"route-transition",at:e.timestamp,label:`route ${t?.from??""} \u2192 ${t?.url??""}`,eventIds:[e.id]}}if(e.source==="valtio"&&n==="state-update"){const t=e.raw;return{kind:"state-update",at:e.timestamp,label:`${t?.update?.storeId??"?"}.${t?.update?.path??"?"}`,eventIds:[e.id],details:t?.update}}if(e.source==="nestjs"&&n==="server-request"){const t=e.raw;return{kind:"backend-request",at:e.timestamp,label:`${t?.request?.method??"?"} ${t?.request?.route??"?"} \u2192 ${t?.request?.status??"?"}`,eventIds:[e.id],details:t?.request}}if(e.source==="chrome"&&e.category==="network")return{kind:"backend-request",at:e.timestamp,label:e.title,eventIds:[e.id]};if(e.source==="visual"&&n==="visual-violation"){const t=e.raw;return{kind:"visual-violation",at:e.timestamp,label:`${t?.violation?.ruleType??"rule"} ${t?.violation?.ruleId??""}`,eventIds:[e.id]}}}u(f,"g"),m(f,"classifyEvent");
1
+ "use strict";var I=Object.defineProperty;var u=(t,n)=>I(t,"name",{value:n,configurable:!0});var k=Object.defineProperty,c=u((t,n)=>k(t,"name",{value:n,configurable:!0}),"u"),b=Object.defineProperty,p=c((t,n)=>b(t,"name",{value:n,configurable:!0}),"c");export function groupByFlow(t){const n=new Map;for(const e of t){const o=e.context.flowId;if(!o)continue;let s=n.get(o);s||(s=[],n.set(o,s)),s.push(e)}return n}u(groupByFlow,"groupByFlow"),c(groupByFlow,"groupByFlow"),p(groupByFlow,"groupByFlow");export function compileStory(t,n={}){let e,o;if(n.flowId)o=n.flowId,e=t.filter(r=>r.context.flowId===o);else{const r=t.find(i=>i.context.flowId);if(!r)return;o=r.context.flowId,e=t.filter(i=>i.context.flowId===o)}if(e.length===0)return;e.sort((r,i)=>r.timestamp-i.timestamp);const s=1e3;e.length>s&&(e=[e[0],...e.slice(e.length-(s-1))]);const m=e[0],d=[];let l,v;for(const r of e){const i=f(r);if(i){if(d.push(i),i.kind==="render"||i.kind==="final-render"){const a=r.raw;a?.render&&(l={id:a.render.id,page:a.render.page,route:a.render.route,componentName:a.render.componentName})}else if(r.source==="visual"&&i.kind==="visual-violation"){const a=r.raw;a?.frame&&(v=a.frame.id)}}}for(let r=d.length-1;r>=0;r--)if(d[r].kind==="render"){d[r]={...d[r],kind:"final-render"};break}const g=e[0].timestamp,w=e[e.length-1].timestamp;return{flowId:o,origin:{type:m.context.originType,nodeId:m.context.originNodeId,at:m.timestamp},phases:d,finalState:l?{page:l.page,route:l.route,componentName:l.componentName,renderId:l.id,visualFrameId:v}:void 0,startedAt:g,endedAt:w,eventCount:e.length}}u(compileStory,"compileStory"),c(compileStory,"compileStory"),p(compileStory,"compileStory");function f(t){const n=(t.raw??null)?.kind;if(n==="flow-origin"||t.source==="client-runtime"&&n==="user-action"){const e=t.raw;return{kind:"user-action",at:t.timestamp,label:e?.origin?.label??t.title,eventIds:[t.id]}}if(t.source==="react"&&n==="render"){const e=t.raw;return{kind:"render",at:t.timestamp,label:`render ${e?.render?.componentName??"?"}`,eventIds:[t.id],details:e?.render?{componentName:e.render.componentName,durationMs:e.render.actualDurationMs}:void 0}}if(t.source==="react"&&n==="slot-content-changed"){const e=t.raw,o=e?.slot?.toComponent??"?";return{kind:/spinner|loader|loading/i.test(o)?"loading-ui":"idle-ui",at:t.timestamp,label:`slot ${e?.slot?.slotLogicalId??""} \u2192 ${o}`,eventIds:[t.id]}}if(t.source==="client-runtime"&&n==="route"){const e=t.raw;return{kind:"route-transition",at:t.timestamp,label:`route ${e?.from??""} \u2192 ${e?.url??""}`,eventIds:[t.id]}}if(t.source==="valtio"&&n==="state-update"){const e=t.raw;return{kind:"state-update",at:t.timestamp,label:`${e?.update?.storeId??"?"}.${e?.update?.path??"?"}`,eventIds:[t.id],details:e?.update}}if(t.source==="nestjs"&&n==="server-request"){const e=t.raw;return{kind:"backend-request",at:t.timestamp,label:`${e?.request?.method??"?"} ${e?.request?.route??"?"} \u2192 ${e?.request?.status??"?"}`,eventIds:[t.id],details:e?.request}}if(t.source==="chrome"&&t.category==="network")return{kind:"backend-request",at:t.timestamp,label:t.title,eventIds:[t.id]};if(t.source==="visual"&&n==="visual-violation"){const e=t.raw;return{kind:"visual-violation",at:t.timestamp,label:`${e?.violation?.ruleType??"rule"} ${e?.violation?.ruleId??""}`,eventIds:[t.id]}}}u(f,"f"),c(f,"g"),p(f,"classifyEvent");
package/lib/thresholds.js CHANGED
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty;var s=(e,r)=>t(e,"name",{value:r,configurable:!0});var l=Object.defineProperty,u=s((e,r)=>l(e,"name",{value:r,configurable:!0}),"t");export const DEFAULT_THRESHOLDS={dbInLoop:5,nPlusOne:3,renderStorm:5,slowRouteMs:500,slowRenderMs:16,slowQueryMs:100};export function resolveThresholds(e){const r={...DEFAULT_THRESHOLDS};if(e)for(const n of Object.keys(DEFAULT_THRESHOLDS)){const o=e[n];typeof o=="number"&&Number.isFinite(o)&&o>=0&&(r[n]=o)}return r}s(resolveThresholds,"resolveThresholds"),u(resolveThresholds,"resolveThresholds");
1
+ "use strict";var l=Object.defineProperty;var s=(e,r)=>l(e,"name",{value:r,configurable:!0});var u=Object.defineProperty,t=s((e,r)=>u(e,"name",{value:r,configurable:!0}),"s"),c=Object.defineProperty,i=t((e,r)=>c(e,"name",{value:r,configurable:!0}),"t");export const DEFAULT_THRESHOLDS={dbInLoop:5,nPlusOne:3,renderStorm:5,slowRouteMs:500,slowRenderMs:16,slowQueryMs:100};export function resolveThresholds(e){const r={...DEFAULT_THRESHOLDS};if(e)for(const n of Object.keys(DEFAULT_THRESHOLDS)){const o=e[n];typeof o=="number"&&Number.isFinite(o)&&o>=0&&(r[n]=o)}return r}s(resolveThresholds,"resolveThresholds"),t(resolveThresholds,"resolveThresholds"),i(resolveThresholds,"resolveThresholds");
package/lib/ulid.js CHANGED
@@ -1 +1 @@
1
- "use strict";var d=Object.defineProperty;var r=(e,n)=>d(e,"name",{value:n,configurable:!0});var f=Object.defineProperty,c=r((e,n)=>f(e,"name",{value:n,configurable:!0}),"r");const i="0123456789ABCDEFGHJKMNPQRSTVWXYZ",b=16;function l(e,n){let o="",t=e;for(let u=n-1;u>=0;u--){const a=t%32;o=i[a]+o,t=(t-a)/32}return o}r(l,"s"),c(l,"encodeTime");function s(e){const n=new Uint8Array(e);globalThis.crypto.getRandomValues(n);let o="";for(let t=0;t<e;t++)o+=i[(n[t]??0)&31];return o}r(s,"a"),c(s,"encodeRandom");export function ulid(e=Date.now()){return l(e,10)+s(16)}r(ulid,"ulid"),c(ulid,"ulid");
1
+ "use strict";var s=Object.defineProperty;var o=(e,n)=>s(e,"name",{value:n,configurable:!0});var b=Object.defineProperty,a=o((e,n)=>b(e,"name",{value:n,configurable:!0}),"r"),m=Object.defineProperty,u=a((e,n)=>m(e,"name",{value:n,configurable:!0}),"r");const f="0123456789ABCDEFGHJKMNPQRSTVWXYZ",g=16;function c(e,n){let r="",t=e;for(let l=n-1;l>=0;l--){const d=t%32;r=f[d]+r,t=(t-d)/32}return r}o(c,"l"),a(c,"s"),u(c,"encodeTime");function i(e){const n=new Uint8Array(e);globalThis.crypto.getRandomValues(n);let r="";for(let t=0;t<e;t++)r+=f[(n[t]??0)&31];return r}o(i,"s"),a(i,"a"),u(i,"encodeRandom");export function ulid(e=Date.now()){return c(e,10)+i(16)}o(ulid,"ulid"),a(ulid,"ulid"),u(ulid,"ulid");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/core",
3
- "version": "1.18.11",
3
+ "version": "1.18.14",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -19,7 +19,7 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@lensmcp/protocol-types": "1.18.11",
22
+ "@lensmcp/protocol-types": "1.18.14",
23
23
  "tslib": "^2.3.0"
24
24
  },
25
25
  "license": "Apache-2.0",