@lensmcp/react-instrumentation 1.24.5 → 1.25.1

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 +1 @@
1
- "use strict";var C=Object.defineProperty;var l=(o,e)=>C(o,"name",{value:e,configurable:!0});var L=Object.defineProperty,c=l((o,e)=>L(o,"name",{value:e,configurable:!0}),"a");const $=4;export function displaySourcePath(o,e){const n=c(p=>p.replace(/\\/g,"/").replace(/\/+$/,"").split("/"),"segments"),t=n(o),i=n(e);let r=0;for(;r<t.length&&r<i.length&&t[r]===i[r];)r++;const a=i.length-r;if(r===0||a>4)return`<external>/${t[t.length-1]??"unknown"}`;const s=t.slice(r);return s.length===0?"<external>/unknown":[...new Array(a).fill(".."),...s].join("/")}l(displaySourcePath,"displaySourcePath"),c(displaySourcePath,"displaySourcePath");const x="@lensmcp/react-instrumentation",y=new Map([["useEffect","tracedUseEffect"],["useMemo","tracedUseMemo"],["useCallback","tracedUseCallback"]]),J=new Set(y.values());function m(o){return`useLensmcp_${o}`}l(m,"S"),c(m,"tracedHookLocalName");function f(o){return J.has(o)?m(o):o}l(f,"b"),c(f,"helperLocalName");const R=["onClick","onDoubleClick","onContextMenu","onSubmit","onChange"],P=new Map([["onSubmit","form-submit"],["onChange","input-change"]]);export default function j(o){const e=o.types;return{name:"@lensmcp/react-instrumentation/babel-plugin",visitor:{Program:{enter(n,t){if(t.needHelpers=new Set,t.needRoot=!1,t.hookIndex=0,t.flowEvents=new Set(t.opts.flowEvents??R),t.rootVars=new Set,t.opts.production??process.env.NODE_ENV==="production"){t.fileIgnored=!0;return}(n.node.body[0]?.leadingComments??n.node.directives.flatMap(r=>r.leadingComments??[])??[]).some(r=>r.value.includes("@lensmcp-ignore"))&&(t.fileIgnored=!0);const i=t.file?.opts?.filename;i&&(t.relativePath=displaySourcePath(i,t.opts.rootDir??process.cwd()))},exit(n,t){if(t.fileIgnored)return;const i=[...t.needHelpers??[]];if(t.needRoot&&i.push("LensmcpRoot","installFlowFetch"),i.length===0)return;const r=I(n.node.body,x,e),a=i.filter(s=>r.get(f(s))!==s);if(a.length>0&&n.node.body.unshift(e.importDeclaration(a.map(s=>e.importSpecifier(e.identifier(f(s)),e.identifier(s))),e.stringLiteral(x))),t.needRoot){const s=n.node.body.findIndex(d=>!e.isImportDeclaration(d)),p=e.expressionStatement(e.callExpression(e.identifier("installFlowFetch"),[]));n.node.body.splice(s<0?n.node.body.length:s,0,p)}}},VariableDeclarator(n,t){t.fileIgnored||t.opts.autoWrapRoot!==!1&&e.isIdentifier(n.node.id)&&n.node.init&&h(n.node.init,e)&&t.rootVars.add(n.node.id.name)},CallExpression(n,t){if(t.fileIgnored)return;const i=n.node.callee,r=t.opts.autoWrapHooks!==!1&&e.isIdentifier(i)?y.get(i.name):void 0;if(r){const a=`${t.relativePath??"(anon)"}:${n.node.loc?.start.line??0}:${t.hookIndex++}`;n.node.callee=e.identifier(m(r)),n.node.arguments.unshift(e.stringLiteral(a)),t.needHelpers.add(r);return}if(t.opts.autoWrapRoot!==!1&&e.isMemberExpression(i)&&e.isIdentifier(i.property,{name:"render"})&&(h(i.object,e)||e.isIdentifier(i.object)&&t.rootVars?.has(i.object.name))&&n.node.arguments.length>=1){const a=n.node.arguments[0];a&&!E(a,e)&&(n.node.arguments[0]=e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("LensmcpRoot"),[],!1),e.jsxClosingElement(e.jsxIdentifier("LensmcpRoot")),[e.jsxExpressionContainer(a)],!1),t.needRoot=!0)}},JSXOpeningElement(n,t){if(t.fileIgnored)return;const i=n.node.attributes;if(g(i,"data-agent-component")||g(i,"data-lensmcp-ignore")||(n.parent.leadingComments??n.node.leadingComments??[]).some(s=>s.value.includes("@lensmcp-ignore")))return;if(t.opts.autoFlowHandlers!==!1){const s=n.node.loc?.start.line??0,p=t.relativePath??"(anon)";for(const d of n.node.attributes){if(d.type!=="JSXAttribute"||d.name.type!=="JSXIdentifier"||!t.flowEvents.has(d.name.name)||!d.value||d.value.type!=="JSXExpressionContainer")continue;const u=d.value.expression;if(u.type==="JSXEmptyExpression"||S(u,e))continue;const b=d.name.name;d.value.expression=e.callExpression(e.identifier("withFlow"),[u,e.objectExpression([e.objectProperty(e.identifier("originType"),e.stringLiteral(P.get(b)??"user-click")),e.objectProperty(e.identifier("originNodeId"),e.stringLiteral(`ui:${p}:${s}:${b}`))])]),t.needHelpers.add("withFlow")}}const r=v(n.node.name);if(!r||w(r))return;const a=[e.jsxAttribute(e.jsxIdentifier("data-agent-component"),e.stringLiteral(r))];if(t.opts.includeSource!==!1){const s=n.node.loc?.start.line??0,p=t.relativePath??"(anon)";a.push(e.jsxAttribute(e.jsxIdentifier("data-agent-source"),e.stringLiteral(`${p}:${s}`)))}n.node.attributes.push(...a)}}}}l(j,"v"),c(j,"lensmcpBabelPlugin");function g(o,e){return o.some(n=>n.type==="JSXAttribute"&&n.name.type==="JSXIdentifier"&&n.name.name===e)}l(g,"x"),c(g,"hasAttr");function I(o,e,n){const t=new Map;for(const i of o)if(n.isImportDeclaration(i)&&i.source.value===e)for(const r of i.specifiers)n.isImportSpecifier(r)&&n.isIdentifier(r.imported)&&t.set(r.local.name,r.imported.name);return t}l(I,"L"),c(I,"collectImported");function h(o,e){if(!e.isCallExpression(o))return!1;const n=o.callee,t=new Set(["createRoot","hydrateRoot"]);return e.isIdentifier(n)?t.has(n.name):e.isMemberExpression(n)&&e.isIdentifier(n.property)?t.has(n.property.name):!1}l(h,"I"),c(h,"isRootFactoryCall");function S(o,e){return e.isCallExpression(o)&&e.isIdentifier(o.callee,{name:"withFlow"})}l(S,"j"),c(S,"isAlreadyWithFlow");function E(o,e){return e.isJSXElement(o)&&e.isJSXIdentifier(o.openingElement.name,{name:"LensmcpRoot"})}l(E,"A"),c(E,"isAlreadyLensmcpRoot");const X=new Set(["Fragment","StrictMode","Suspense","SuspenseList","Profiler"]);function w(o){const e=o.split(".").pop()??o;return X.has(e)?!0:e.endsWith("Provider")||e.endsWith("Consumer")}l(w,"P"),c(w,"isUnstampableElement");function v(o){switch(o.type){case"JSXIdentifier":return o.name;case"JSXMemberExpression":{const e=[];let n=o;for(;n.type==="JSXMemberExpression";)e.unshift(n.property.name),n=n.object;return n.type==="JSXIdentifier"&&e.unshift(n.name),e.join(".")}case"JSXNamespacedName":return`${o.namespace.name}:${o.name.name}`;default:return}}l(v,"R"),c(v,"describeElementName");
1
+ "use strict";var L=Object.defineProperty;var l=(o,e)=>L(o,"name",{value:e,configurable:!0});var P=Object.defineProperty,c=l((o,e)=>P(o,"name",{value:e,configurable:!0}),"l"),R=Object.defineProperty,d=c((o,e)=>R(o,"name",{value:e,configurable:!0}),"a");const F=4;export function displaySourcePath(o,e){const n=d(u=>u.replace(/\\/g,"/").replace(/\/+$/,"").split("/"),"segments"),t=n(o),r=n(e);let i=0;for(;i<t.length&&i<r.length&&t[i]===r[i];)i++;const a=r.length-i;if(i===0||a>4)return`<external>/${t[t.length-1]??"unknown"}`;const s=t.slice(i);return s.length===0?"<external>/unknown":[...new Array(a).fill(".."),...s].join("/")}l(displaySourcePath,"displaySourcePath"),c(displaySourcePath,"displaySourcePath"),d(displaySourcePath,"displaySourcePath");const j="@lensmcp/react-instrumentation",C=new Map([["useEffect","tracedUseEffect"],["useMemo","tracedUseMemo"],["useCallback","tracedUseCallback"]]),J=new Set(C.values());function m(o){return`useLensmcp_${o}`}l(m,"m"),c(m,"S"),d(m,"tracedHookLocalName");function f(o){return J.has(o)?m(o):o}l(f,"f"),c(f,"b"),d(f,"helperLocalName");const X=["onClick","onDoubleClick","onContextMenu","onSubmit","onChange"],$=new Map([["onSubmit","form-submit"],["onChange","input-change"]]);export default function w(o){const e=o.types;return{name:"@lensmcp/react-instrumentation/babel-plugin",visitor:{Program:{enter(n,t){if(t.needHelpers=new Set,t.needRoot=!1,t.hookIndex=0,t.flowEvents=new Set(t.opts.flowEvents??X),t.rootVars=new Set,t.opts.production??process.env.NODE_ENV==="production"){t.fileIgnored=!0;return}(n.node.body[0]?.leadingComments??n.node.directives.flatMap(i=>i.leadingComments??[])??[]).some(i=>i.value.includes("@lensmcp-ignore"))&&(t.fileIgnored=!0);const r=t.file?.opts?.filename;r&&(t.relativePath=displaySourcePath(r,t.opts.rootDir??process.cwd()))},exit(n,t){if(t.fileIgnored)return;const r=[...t.needHelpers??[]];if(t.needRoot&&r.push("LensmcpRoot","installFlowFetch"),r.length===0)return;const i=x(n.node.body,j,e),a=r.filter(s=>i.get(f(s))!==s);if(a.length>0&&n.node.body.unshift(e.importDeclaration(a.map(s=>e.importSpecifier(e.identifier(f(s)),e.identifier(s))),e.stringLiteral(j))),t.needRoot){const s=n.node.body.findIndex(p=>!e.isImportDeclaration(p)),u=e.expressionStatement(e.callExpression(e.identifier("installFlowFetch"),[]));n.node.body.splice(s<0?n.node.body.length:s,0,u)}}},VariableDeclarator(n,t){t.fileIgnored||t.opts.autoWrapRoot!==!1&&e.isIdentifier(n.node.id)&&n.node.init&&h(n.node.init,e)&&t.rootVars.add(n.node.id.name)},CallExpression(n,t){if(t.fileIgnored)return;const r=n.node.callee,i=t.opts.autoWrapHooks!==!1&&e.isIdentifier(r)?C.get(r.name):void 0;if(i){const a=`${t.relativePath??"(anon)"}:${n.node.loc?.start.line??0}:${t.hookIndex++}`;n.node.callee=e.identifier(m(i)),n.node.arguments.unshift(e.stringLiteral(a)),t.needHelpers.add(i);return}if(t.opts.autoWrapRoot!==!1&&e.isMemberExpression(r)&&e.isIdentifier(r.property,{name:"render"})&&(h(r.object,e)||e.isIdentifier(r.object)&&t.rootVars?.has(r.object.name))&&n.node.arguments.length>=1){const a=n.node.arguments[0];a&&!S(a,e)&&(n.node.arguments[0]=e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("LensmcpRoot"),[],!1),e.jsxClosingElement(e.jsxIdentifier("LensmcpRoot")),[e.jsxExpressionContainer(a)],!1),t.needRoot=!0)}},JSXOpeningElement(n,t){if(t.fileIgnored)return;const r=n.node.attributes;if(g(r,"data-agent-component")||g(r,"data-lensmcp-ignore")||(n.parent.leadingComments??n.node.leadingComments??[]).some(s=>s.value.includes("@lensmcp-ignore")))return;if(t.opts.autoFlowHandlers!==!1){const s=n.node.loc?.start.line??0,u=t.relativePath??"(anon)";for(const p of n.node.attributes){if(p.type!=="JSXAttribute"||p.name.type!=="JSXIdentifier"||!t.flowEvents.has(p.name.name)||!p.value||p.value.type!=="JSXExpressionContainer")continue;const b=p.value.expression;if(b.type==="JSXEmptyExpression"||y(b,e))continue;const v=p.name.name;p.value.expression=e.callExpression(e.identifier("withFlow"),[b,e.objectExpression([e.objectProperty(e.identifier("originType"),e.stringLiteral($.get(v)??"user-click")),e.objectProperty(e.identifier("originNodeId"),e.stringLiteral(`ui:${u}:${s}:${v}`))])]),t.needHelpers.add("withFlow")}}const i=E(n.node.name);if(!i||I(i))return;const a=[e.jsxAttribute(e.jsxIdentifier("data-agent-component"),e.stringLiteral(i))];if(t.opts.includeSource!==!1){const s=n.node.loc?.start.line??0,u=t.relativePath??"(anon)";a.push(e.jsxAttribute(e.jsxIdentifier("data-agent-source"),e.stringLiteral(`${u}:${s}`)))}n.node.attributes.push(...a)}}}}l(w,"j"),c(w,"v"),d(w,"lensmcpBabelPlugin");function g(o,e){return o.some(n=>n.type==="JSXAttribute"&&n.name.type==="JSXIdentifier"&&n.name.name===e)}l(g,"g"),c(g,"x"),d(g,"hasAttr");function x(o,e,n){const t=new Map;for(const r of o)if(n.isImportDeclaration(r)&&r.source.value===e)for(const i of r.specifiers)n.isImportSpecifier(i)&&n.isIdentifier(i.imported)&&t.set(i.local.name,i.imported.name);return t}l(x,"I"),c(x,"L"),d(x,"collectImported");function h(o,e){if(!e.isCallExpression(o))return!1;const n=o.callee,t=new Set(["createRoot","hydrateRoot"]);return e.isIdentifier(n)?t.has(n.name):e.isMemberExpression(n)&&e.isIdentifier(n.property)?t.has(n.property.name):!1}l(h,"h"),c(h,"I"),d(h,"isRootFactoryCall");function y(o,e){return e.isCallExpression(o)&&e.isIdentifier(o.callee,{name:"withFlow"})}l(y,"S"),c(y,"j"),d(y,"isAlreadyWithFlow");function S(o,e){return e.isJSXElement(o)&&e.isJSXIdentifier(o.openingElement.name,{name:"LensmcpRoot"})}l(S,"E"),c(S,"A"),d(S,"isAlreadyLensmcpRoot");const M=new Set(["Fragment","StrictMode","Suspense","SuspenseList","Profiler"]);function I(o){const e=o.split(".").pop()??o;return M.has(e)?!0:e.endsWith("Provider")||e.endsWith("Consumer")}l(I,"w"),c(I,"P"),d(I,"isUnstampableElement");function E(o){switch(o.type){case"JSXIdentifier":return o.name;case"JSXMemberExpression":{const e=[];let n=o;for(;n.type==="JSXMemberExpression";)e.unshift(n.property.name),n=n.object;return n.type==="JSXIdentifier"&&e.unshift(n.name),e.join(".")}case"JSXNamespacedName":return`${o.namespace.name}:${o.name.name}`;default:return}}l(E,"v"),c(E,"R"),d(E,"describeElementName");
@@ -1 +1 @@
1
- "use strict";var a=Object.defineProperty;var t=(n,e)=>a(n,"name",{value:e,configurable:!0});var _=Object.defineProperty,o=t((n,e)=>_(n,"name",{value:e,configurable:!0}),"r");import{useId as p,useRef as m}from"react";export function readOwnerName(n){try{if(!n)return;const e=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;if(!e)return;const u=e.A,r=((typeof u?.getOwner=="function"?u.getOwner():null)??e.owner??e.ReactCurrentOwner?.current)?.type;if(!r)return;if(typeof r=="string")return r;const c=r.displayName??r.name;return typeof c=="string"&&c.length>0?c:void 0}catch{return}}t(readOwnerName,"readOwnerName"),o(readOwnerName,"readOwnerName");export function composeComponentIdentity(n,e){return{componentInstanceId:`react:component:${e??"fn"}${n}`,...e?{componentLogicalId:`react:component:${e}`,componentName:e}:{}}}t(composeComponentIdentity,"composeComponentIdentity"),o(composeComponentIdentity,"composeComponentIdentity");function i(){try{return readOwnerName(require("react"))}catch{return}}t(i,"f"),o(i,"currentOwnerName");export function useComponentIdentity(){const n=p(),e=m(void 0);return e.current||(e.current=composeComponentIdentity(n,i())),e.current}t(useComponentIdentity,"useComponentIdentity"),o(useComponentIdentity,"useComponentIdentity");
1
+ "use strict";var m=Object.defineProperty;var t=(n,e)=>m(n,"name",{value:e,configurable:!0});var p=Object.defineProperty,o=t((n,e)=>p(n,"name",{value:e,configurable:!0}),"t"),_=Object.defineProperty,c=o((n,e)=>_(n,"name",{value:e,configurable:!0}),"r");import{useId as f,useRef as s}from"react";export function readOwnerName(n){try{if(!n)return;const e=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;if(!e)return;const i=e.A,r=((typeof i?.getOwner=="function"?i.getOwner():null)??e.owner??e.ReactCurrentOwner?.current)?.type;if(!r)return;if(typeof r=="string")return r;const u=r.displayName??r.name;return typeof u=="string"&&u.length>0?u:void 0}catch{return}}t(readOwnerName,"readOwnerName"),o(readOwnerName,"readOwnerName"),c(readOwnerName,"readOwnerName");export function composeComponentIdentity(n,e){return{componentInstanceId:`react:component:${e??"fn"}${n}`,...e?{componentLogicalId:`react:component:${e}`,componentName:e}:{}}}t(composeComponentIdentity,"composeComponentIdentity"),o(composeComponentIdentity,"composeComponentIdentity"),c(composeComponentIdentity,"composeComponentIdentity");function a(){try{return readOwnerName(require("react"))}catch{return}}t(a,"i"),o(a,"f"),c(a,"currentOwnerName");export function useComponentIdentity(){const n=f(),e=s(void 0);return e.current||(e.current=composeComponentIdentity(n,a())),e.current}t(useComponentIdentity,"useComponentIdentity"),o(useComponentIdentity,"useComponentIdentity"),c(useComponentIdentity,"useComponentIdentity");
package/lib/context.js CHANGED
@@ -1 +1 @@
1
- "use strict";var r=Object.defineProperty;var n=(e,t)=>r(e,"name",{value:t,configurable:!0});var o=Object.defineProperty,s=n((e,t)=>o(e,"name",{value:t,configurable:!0}),"t");import{createContext as c,useContext as a}from"react";const p={rendererId:"lensmcp-root"};export const LensmcpContext=c(p);export function useLensmcpContext(){return a(LensmcpContext)}n(useLensmcpContext,"useLensmcpContext"),s(useLensmcpContext,"useLensmcpContext");
1
+ "use strict";var o=Object.defineProperty;var n=(e,t)=>o(e,"name",{value:t,configurable:!0});var s=Object.defineProperty,r=n((e,t)=>s(e,"name",{value:t,configurable:!0}),"n"),c=Object.defineProperty,a=r((e,t)=>c(e,"name",{value:t,configurable:!0}),"t");import{createContext as p,useContext as u}from"react";const m={rendererId:"lensmcp-root"};export const LensmcpContext=p(m);export function useLensmcpContext(){return u(LensmcpContext)}n(useLensmcpContext,"useLensmcpContext"),r(useLensmcpContext,"useLensmcpContext"),a(useLensmcpContext,"useLensmcpContext");
@@ -1 +1 @@
1
- "use strict";var x=Object.defineProperty;var u=(e,n)=>x(e,"name",{value:n,configurable:!0});var L=Object.defineProperty,d=u((e,n)=>L(e,"name",{value:n,configurable:!0}),"a");import{makeInstanceId as y}from"./identity.js";import{publish as I}from"./publish.js";const j=1,A=0,O=1,z=11,P=14,W=15,w=15e3,M=25,C=15,G=8,E=(typeof process<"u"?process.env?.LENSMCP_RENDER_INCLUDE_INTERNALS:void 0)==="1",K=new Set(["Insertion","EmotionGlobal","EmotionCssPropInternal","GlobalStyles","ThemeProvider","CacheProvider"]);function v(e){return!!(K.has(e)||e.startsWith("Styled(")&&/^Styled\([a-z][a-zA-Z0-9-]*\)$/.test(e)||e==="lensmcp-root"||e.startsWith("Lensmcp"))}u(v,"T"),d(v,"isInternalRender");let g=!1,h=!1;function $(e){const n=e.type;if(!(n==null||typeof n=="string"))switch(e.tag){case A:case O:return n.displayName||n.name||void 0;case z:return n.displayName||n.render?.displayName||n.render?.name||void 0;case P:case W:return n.displayName||n.type?.displayName||n.type?.name||n.name||void 0;default:return}}u($,"$"),d($,"componentNameOf");function S(e){const n=e.alternate?.memoizedProps,i=e.memoizedProps;if(!n||!i||n===i)return[];const r=[];for(const o of Object.keys(i))if(o!=="children"&&!Object.is(n[o],i[o])&&(r.push(o),r.length>=G))break;return r}u(S,"F"),d(S,"changedPropKeys");const b=new WeakMap;function D(e,n){const i=b.get(e);if(i)return i;const r=e.alternate,o=(r?b.get(r):void 0)??y(n).instanceId;return b.set(e,o),r&&b.set(r,o),o}u(D,"x"),d(D,"stableInstanceId");const N=d(e=>e.alternate==null||e.child!==e.alternate.child,"childrenChanged");function _(e){const n=[];let i=0,r=!1;const o=[],c=d((t,s,l)=>{for(let a=t.child;a;a=a.sibling)o.push({node:a,parentName:s,...l?{wrapperName:l}:{}})},"pushChildren");for(N(e.current)&&c(e.current,void 0);o.length>0;){const{node:t,parentName:s,wrapperName:l}=o.pop();if(i+=1,i>w){r=!0;break}let a=s;if(t.tag===P){N(t)&&c(t,s,$(t));continue}const m=$(t)??l,p=(t.flags&j)!==0;if(m&&p){const R=t.alternate==null,f=[];if(!R){const k=S(t);k.length>0&&f.push({type:"props",changedKeys:k}),s&&f.push({type:"parent-render",parentRenderId:s}),f.length===0&&f.push({type:"react-state",hookIndex:-1})}n.push({name:m,instanceId:D(t,`react:component:(fiber):${m}`),phase:R?"mount":"update",durationMs:typeof t.actualDuration=="number"?t.actualDuration:0,why:f,parentName:s}),a=m}N(t)&&c(t,a)}return{renders:n,cut:r}}u(_,"W"),d(_,"collectCommitRenders");let F;export function activeCommitId(){return F}u(activeCommitId,"activeCommitId"),d(activeCommitId,"activeCommitId");export function fiberRendersActive(){return g&&!h}u(fiberRendersActive,"fiberRendersActive"),d(fiberRendersActive,"fiberRendersActive");function T(e,n,i=!1){const r=E?e:e.filter(t=>!v(t.name));if(r.length===0)return;const o=y("react:commit").instanceId;F=o;const c=r.length>M?[...r].sort((t,s)=>s.durationMs-t.durationMs).slice(0,M):r;for(const t of c){const s=`react:component:(fiber):${t.name}`,{instanceId:l}=y(s),a={id:l,commitId:o,componentInstanceId:t.instanceId,componentLogicalId:s,componentName:t.name,rendererId:"fiber",phase:t.phase,actualDurationMs:t.durationMs,baseDurationMs:t.durationMs,startTime:n,commitTime:n,why:t.why};I({source:"react",category:"render",severity:"info",title:`render ${t.name} (${t.phase})`,fingerprint:`react-render:${s}`,raw:{kind:"render",render:a}})}if(r.length>c.length||i){const t=i?`at least ${r.length}`:String(r.length);I({source:"react",category:"render",severity:"debug",title:i?`render commit truncated: the walk stopped at ${w} fibers \u2014 ${t} renders, ${c.length} recorded`:`render commit truncated: ${r.length-c.length} of ${r.length} renders dropped (per-commit cap)`,fingerprint:"react-render:commit-truncated",raw:{kind:"render-commit-truncated",commitId:o,total:r.length,published:c.length,...i?{walkStoppedAt:w}:{}}})}}u(T,"j"),d(T,"publishRecords");export function installFiberRenderPublisher(){if(g||h||typeof window>"u")return;const e=window.__LENSMCP_FIBER__;if(!e||typeof e.subscribe!="function")return;g=!0;let n=C,i=0;const r=new Map;let o=0,c;const t=d(()=>{if(c=void 0,n=C,i===0)return;const s=[...r.entries()].sort((m,p)=>p[1]-m[1]).slice(0,5),l=s.length>0?`top: ${s.map(([m,p])=>`${m}\xD7${p}`).join(", ")}`:"no product component in the commits \u2014 all framework-internal",a=o>0?` (+${o} framework-internal)`:"";I({source:"react",category:"render",severity:"warning",title:`render storm: ${i} commits/s over budget \u2014 ${l}${a}`,fingerprint:"react-render:storm",raw:{kind:"render-storm",commits:i,components:Object.fromEntries(s),internalRenders:o}}),i=0,o=0,r.clear()},"flushStorm");e.subscribe((s,l)=>{if(!h)try{if(!l||!l.current)return;const{renders:a,cut:m}=_(l);if(a.length===0)return;if(n>0)n-=1,T(a,Date.now(),m);else{i+=1;for(const p of a){if(!E&&v(p.name)){o+=1;continue}r.set(p.name,(r.get(p.name)??0)+1)}}c||(c=setTimeout(t,1e3))}catch{h=!0}})}u(installFiberRenderPublisher,"installFiberRenderPublisher"),d(installFiberRenderPublisher,"installFiberRenderPublisher");export function resetFiberRenderPublisherForTests(){g=!1,h=!1}u(resetFiberRenderPublisherForTests,"resetFiberRenderPublisherForTests"),d(resetFiberRenderPublisherForTests,"resetFiberRenderPublisherForTests");
1
+ "use strict";var x=Object.defineProperty;var u=(e,t)=>x(e,"name",{value:t,configurable:!0});var A=Object.defineProperty,m=u((e,t)=>A(e,"name",{value:t,configurable:!0}),"u"),L=Object.defineProperty,d=m((e,t)=>L(e,"name",{value:t,configurable:!0}),"a");import{makeInstanceId as w}from"./identity.js";import{publish as $}from"./publish.js";const O=1,z=0,W=1,G=11,S=14,K=15,N=15e3,T=25,D=15,B=8,_=(typeof process<"u"?process.env?.LENSMCP_RENDER_INCLUDE_INTERNALS:void 0)==="1",U=new Set(["Insertion","EmotionGlobal","EmotionCssPropInternal","GlobalStyles","ThemeProvider","CacheProvider"]);function g(e){return!!(U.has(e)||e.startsWith("Styled(")&&/^Styled\([a-z][a-zA-Z0-9-]*\)$/.test(e)||e==="lensmcp-root"||e.startsWith("Lensmcp"))}u(g,"v"),m(g,"T"),d(g,"isInternalRender");let y=!1,b=!1;function I(e){const t=e.type;if(!(t==null||typeof t=="string"))switch(e.tag){case z:case W:return t.displayName||t.name||void 0;case G:return t.displayName||t.render?.displayName||t.render?.name||void 0;case S:case K:return t.displayName||t.type?.displayName||t.type?.name||t.name||void 0;default:return}}u(I,"$"),m(I,"$"),d(I,"componentNameOf");function R(e){const t=e.alternate?.memoizedProps,i=e.memoizedProps;if(!t||!i||t===i)return[];const r=[];for(const o of Object.keys(i))if(o!=="children"&&!Object.is(t[o],i[o])&&(r.push(o),r.length>=B))break;return r}u(R,"S"),m(R,"F"),d(R,"changedPropKeys");const v=new WeakMap;function P(e,t){const i=v.get(e);if(i)return i;const r=e.alternate,o=(r?v.get(r):void 0)??w(t).instanceId;return v.set(e,o),r&&v.set(r,o),o}u(P,"D"),m(P,"x"),d(P,"stableInstanceId");const k=d(e=>e.alternate==null||e.child!==e.alternate.child,"childrenChanged");function C(e){const t=[];let i=0,r=!1;const o=[],c=d((n,a,l)=>{for(let s=n.child;s;s=s.sibling)o.push({node:s,parentName:a,...l?{wrapperName:l}:{}})},"pushChildren");for(k(e.current)&&c(e.current,void 0);o.length>0;){const{node:n,parentName:a,wrapperName:l}=o.pop();if(i+=1,i>N){r=!0;break}let s=a;if(n.tag===S){k(n)&&c(n,a,I(n));continue}const p=I(n)??l,f=(n.flags&O)!==0;if(p&&f){const M=n.alternate==null,h=[];if(!M){const E=R(n);E.length>0&&h.push({type:"props",changedKeys:E}),a&&h.push({type:"parent-render",parentRenderId:a}),h.length===0&&h.push({type:"react-state",hookIndex:-1})}t.push({name:p,instanceId:P(n,`react:component:(fiber):${p}`),phase:M?"mount":"update",durationMs:typeof n.actualDuration=="number"?n.actualDuration:0,why:h,parentName:a}),s=p}k(n)&&c(n,s)}return{renders:t,cut:r}}u(C,"_"),m(C,"W"),d(C,"collectCommitRenders");let j;export function activeCommitId(){return j}u(activeCommitId,"activeCommitId"),m(activeCommitId,"activeCommitId"),d(activeCommitId,"activeCommitId");export function fiberRendersActive(){return y&&!b}u(fiberRendersActive,"fiberRendersActive"),m(fiberRendersActive,"fiberRendersActive"),d(fiberRendersActive,"fiberRendersActive");function F(e,t,i=!1){const r=_?e:e.filter(n=>!g(n.name));if(r.length===0)return;const o=w("react:commit").instanceId;j=o;const c=r.length>T?[...r].sort((n,a)=>a.durationMs-n.durationMs).slice(0,T):r;for(const n of c){const a=`react:component:(fiber):${n.name}`,{instanceId:l}=w(a),s={id:l,commitId:o,componentInstanceId:n.instanceId,componentLogicalId:a,componentName:n.name,rendererId:"fiber",phase:n.phase,actualDurationMs:n.durationMs,baseDurationMs:n.durationMs,startTime:t,commitTime:t,why:n.why};$({source:"react",category:"render",severity:"info",title:`render ${n.name} (${n.phase})`,fingerprint:`react-render:${a}`,raw:{kind:"render",render:s}})}if(r.length>c.length||i){const n=i?`at least ${r.length}`:String(r.length);$({source:"react",category:"render",severity:"debug",title:i?`render commit truncated: the walk stopped at ${N} fibers \u2014 ${n} renders, ${c.length} recorded`:`render commit truncated: ${r.length-c.length} of ${r.length} renders dropped (per-commit cap)`,fingerprint:"react-render:commit-truncated",raw:{kind:"render-commit-truncated",commitId:o,total:r.length,published:c.length,...i?{walkStoppedAt:N}:{}}})}}u(F,"T"),m(F,"j"),d(F,"publishRecords");export function installFiberRenderPublisher(){if(y||b||typeof window>"u")return;const e=window.__LENSMCP_FIBER__;if(!e||typeof e.subscribe!="function")return;y=!0;let t=D,i=0;const r=new Map;let o=0,c;const n=d(()=>{if(c=void 0,t=D,i===0)return;const a=[...r.entries()].sort((p,f)=>f[1]-p[1]).slice(0,5),l=a.length>0?`top: ${a.map(([p,f])=>`${p}\xD7${f}`).join(", ")}`:"no product component in the commits \u2014 all framework-internal",s=o>0?` (+${o} framework-internal)`:"";$({source:"react",category:"render",severity:"warning",title:`render storm: ${i} commits/s over budget \u2014 ${l}${s}`,fingerprint:"react-render:storm",raw:{kind:"render-storm",commits:i,components:Object.fromEntries(a),internalRenders:o}}),i=0,o=0,r.clear()},"flushStorm");e.subscribe((a,l)=>{if(!b)try{if(!l||!l.current)return;const{renders:s,cut:p}=C(l);if(s.length===0)return;if(t>0)t-=1,F(s,Date.now(),p);else{i+=1;for(const f of s){if(!_&&g(f.name)){o+=1;continue}r.set(f.name,(r.get(f.name)??0)+1)}}c||(c=setTimeout(n,1e3))}catch{b=!0}})}u(installFiberRenderPublisher,"installFiberRenderPublisher"),m(installFiberRenderPublisher,"installFiberRenderPublisher"),d(installFiberRenderPublisher,"installFiberRenderPublisher");export function resetFiberRenderPublisherForTests(){y=!1,b=!1}u(resetFiberRenderPublisherForTests,"resetFiberRenderPublisherForTests"),m(resetFiberRenderPublisherForTests,"resetFiberRenderPublisherForTests"),d(resetFiberRenderPublisherForTests,"resetFiberRenderPublisherForTests");
package/lib/flow-fetch.js CHANGED
@@ -1 +1 @@
1
- "use strict";var R=Object.defineProperty;var c=(t,e)=>R(t,"name",{value:e,configurable:!0});var A=Object.defineProperty,f=c((t,e)=>A(t,"name",{value:e,configurable:!0}),"s");import{beginBackgroundFlow as E,extendFlowWindow as I,flowForNewActivity as H,publish as p}from"./publish.js";import{installRouteFlows as P}from"./route-flows.js";export function mayPropagateTo(t,e=[]){const d=typeof location<"u"?location.href:void 0;let l;try{l=new URL(t,d)}catch{return!1}if(typeof location<"u"&&l.origin===location.origin||x(l.hostname))return!0;for(const i of e){let r;try{r=new URL(i).origin}catch{continue}if(r===l.origin)return!0}return!1}c(mayPropagateTo,"mayPropagateTo"),f(mayPropagateTo,"mayPropagateTo");const q=new Set(["localhost","[::1]","::1"]);function x(t){const e=t.toLowerCase();return q.has(e)||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(e)}c(x,"O"),f(x,"isLoopbackHost");function F(){const t=globalThis.__LENSMCP_FLOW_PROPAGATE__;return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(Boolean):[]}c(F,"N"),f(F,"globalPropagateList");function k(){return Date.now().toString(36)+Math.random().toString(36).slice(2,12)}c(k,"A"),f(k,"newRequestId");function w(t){return typeof t=="string"?t:t instanceof URL?t.href:t.url??String(t)}c(w,"p"),f(w,"urlOf");const L=Symbol.for("lensmcp.flow-fetch"),_=Symbol.for("lensmcp.flow-fetch.recorded-leg");function y(t){return{...t,[_]:!0}}c(y,"L"),f(y,"markRecorded");let v=!1;export function installFlowFetch(t={}){const e=globalThis;if(typeof e.fetch!="function")return()=>{};if(e.fetch[L])return()=>{};!v&&typeof location<"u"&&typeof document<"u"&&(v=!0,E({originType:"page-load",originNodeId:`page:${location.pathname}`}));const d=t.flowHeader??"x-lensmcp-flow-id",l=t.originHeader??"x-lensmcp-origin-node-id",i=t.requestHeader??"x-request-id",r=t.propagateTo??[],s=e.fetch.bind(globalThis);globalThis.__LENSMCP_FLOW_FETCH__=!0;const a=f(((n,o)=>{if(o?.[_])return s(n,o);const g=H();if(!g?.flowId)return s(n,o);if(!mayPropagateTo(w(n),[...r,...F()])){const b=s(n,y(o));return m(g,n,o,b,void 0),b}const S=typeof n=="object"&&n!==null&&"headers"in n?n.headers:void 0,u=new Headers(o?.headers??S??void 0);u.has(d)||u.set(d,g.flowId),g.originNodeId&&!u.has(l)&&u.set(l,g.originNodeId);const T=u.get(i)??k();u.has(i)||u.set(i,T);const $=s(n,{...y(o),headers:u});return m(g,n,o,$,T),$}),"patched");a[L]=!0,e.fetch=a;const h=t.routeFlows===!1?()=>{}:P();return()=>{h(),e.fetch=s}}c(installFlowFetch,"installFlowFetch"),f(installFlowFetch,"installFlowFetch");function N(t){const e=typeof location<"u"?location.href:void 0;try{return new URL(t,e).href}catch{return}}c(N,"C"),f(N,"absoluteHref");function m(t,e,d,l,i){const r=w(e),s=N(r),a=d?.method??(typeof e=="object"&&e!==null&&"method"in e?e.method??"GET":"GET"),h=Date.now(),n={flowId:t.flowId,...t.originType?{originType:t.originType}:{},...t.originNodeId?{originNodeId:t.originNodeId}:{},...i?{requestId:i}:{}};p({source:"react",category:"network",severity:"info",title:`fetch ${a} ${r}`,fingerprint:`flow-fetch:${a}:${r}`,context:n,raw:{kind:"fetch-start",url:r,method:a,...s?{href:s}:{},...i?{requestId:i}:{}}}),l.then(o=>{I(t),p({source:"react",category:"network",severity:o.ok||o.status===304?"info":"error",title:`fetch ${a} ${r} \u2192 ${o.status}${o.statusText?` ${o.statusText}`:""}`,fingerprint:`flow-fetch:${a}:${r}:${o.status}`,context:n,raw:{kind:"fetch-done",url:r,...s?{href:s}:{},...i?{requestId:i}:{},method:a,status:o.status,statusText:o.statusText,ok:o.ok,startedAt:h,durationMs:Date.now()-h}})},o=>{I(t),p({source:"react",category:"network",severity:"error",title:`fetch ${a} ${r} failed`,message:o instanceof Error?o.message:String(o),fingerprint:`flow-fetch:${a}:${r}:error`,context:n,raw:{kind:"fetch-error",url:r,...s?{href:s}:{},...i?{requestId:i}:{},method:a,startedAt:h,durationMs:Date.now()-h}})})}c(m,"x"),f(m,"publishFetchLeg");
1
+ "use strict";var A=Object.defineProperty;var c=(e,t)=>A(e,"name",{value:t,configurable:!0});var R=Object.defineProperty,f=c((e,t)=>R(e,"name",{value:t,configurable:!0}),"c"),q=Object.defineProperty,l=f((e,t)=>q(e,"name",{value:t,configurable:!0}),"s");import{beginBackgroundFlow as E,extendFlowWindow as k,flowForNewActivity as H,publish as T}from"./publish.js";import{installRouteFlows as O}from"./route-flows.js";export function mayPropagateTo(e,t=[]){const h=typeof location<"u"?location.href:void 0;let u;try{u=new URL(e,h)}catch{return!1}if(typeof location<"u"&&u.origin===location.origin||b(u.hostname))return!0;for(const i of t){let r;try{r=new URL(i).origin}catch{continue}if(r===u.origin)return!0}return!1}c(mayPropagateTo,"mayPropagateTo"),f(mayPropagateTo,"mayPropagateTo"),l(mayPropagateTo,"mayPropagateTo");const C=new Set(["localhost","[::1]","::1"]);function b(e){const t=e.toLowerCase();return C.has(t)||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}c(b,"x"),f(b,"O"),l(b,"isLoopbackHost");function $(){const e=globalThis.__LENSMCP_FLOW_PROPAGATE__;return Array.isArray(e)?e.filter(t=>typeof t=="string"):typeof e=="string"?e.split(",").map(t=>t.trim()).filter(Boolean):[]}c($,"F"),f($,"N"),l($,"globalPropagateList");function F(){return Date.now().toString(36)+Math.random().toString(36).slice(2,12)}c(F,"k"),f(F,"A"),l(F,"newRequestId");function w(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url??String(e)}c(w,"w"),f(w,"p"),l(w,"urlOf");const _=Symbol.for("lensmcp.flow-fetch"),N=Symbol.for("lensmcp.flow-fetch.recorded-leg");function y(e){return{...e,[N]:!0}}c(y,"y"),f(y,"L"),l(y,"markRecorded");let P=!1;export function installFlowFetch(e={}){const t=globalThis;if(typeof t.fetch!="function")return()=>{};if(t.fetch[_])return()=>{};!P&&typeof location<"u"&&typeof document<"u"&&(P=!0,E({originType:"page-load",originNodeId:`page:${location.pathname}`}));const h=e.flowHeader??"x-lensmcp-flow-id",u=e.originHeader??"x-lensmcp-origin-node-id",i=e.requestHeader??"x-request-id",r=e.propagateTo??[],a=t.fetch.bind(globalThis);globalThis.__LENSMCP_FLOW_FETCH__=!0;const s=l(((n,o)=>{if(o?.[N])return a(n,o);const p=H();if(!p?.flowId)return a(n,o);if(!mayPropagateTo(w(n),[...r,...$()])){const L=a(n,y(o));return m(p,n,o,L,void 0),L}const S=typeof n=="object"&&n!==null&&"headers"in n?n.headers:void 0,d=new Headers(o?.headers??S??void 0);d.has(h)||d.set(h,p.flowId),p.originNodeId&&!d.has(u)&&d.set(u,p.originNodeId);const v=d.get(i)??F();d.has(i)||d.set(i,v);const x=a(n,{...y(o),headers:d});return m(p,n,o,x,v),x}),"patched");s[_]=!0,t.fetch=s;const g=e.routeFlows===!1?()=>{}:O();return()=>{g(),t.fetch=a}}c(installFlowFetch,"installFlowFetch"),f(installFlowFetch,"installFlowFetch"),l(installFlowFetch,"installFlowFetch");function I(e){const t=typeof location<"u"?location.href:void 0;try{return new URL(e,t).href}catch{return}}c(I,"N"),f(I,"C"),l(I,"absoluteHref");function m(e,t,h,u,i){const r=w(t),a=I(r),s=h?.method??(typeof t=="object"&&t!==null&&"method"in t?t.method??"GET":"GET"),g=Date.now(),n={flowId:e.flowId,...e.originType?{originType:e.originType}:{},...e.originNodeId?{originNodeId:e.originNodeId}:{},...i?{requestId:i}:{}};T({source:"react",category:"network",severity:"info",title:`fetch ${s} ${r}`,fingerprint:`flow-fetch:${s}:${r}`,context:n,raw:{kind:"fetch-start",url:r,method:s,...a?{href:a}:{},...i?{requestId:i}:{}}}),u.then(o=>{k(e),T({source:"react",category:"network",severity:o.ok||o.status===304?"info":"error",title:`fetch ${s} ${r} \u2192 ${o.status}${o.statusText?` ${o.statusText}`:""}`,fingerprint:`flow-fetch:${s}:${r}:${o.status}`,context:n,raw:{kind:"fetch-done",url:r,...a?{href:a}:{},...i?{requestId:i}:{},method:s,status:o.status,statusText:o.statusText,ok:o.ok,startedAt:g,durationMs:Date.now()-g}})},o=>{k(e),T({source:"react",category:"network",severity:"error",title:`fetch ${s} ${r} failed`,message:o instanceof Error?o.message:String(o),fingerprint:`flow-fetch:${s}:${r}:error`,context:n,raw:{kind:"fetch-error",url:r,...a?{href:a}:{},...i?{requestId:i}:{},method:s,startedAt:g,durationMs:Date.now()-g}})})}c(m,"m"),f(m,"x"),l(m,"publishFetchLeg");
package/lib/hoc.js CHANGED
@@ -1 +1 @@
1
- "use strict";var I=Object.defineProperty;var o=(e,n)=>I(e,"name",{value:n,configurable:!0});var T=Object.defineProperty,i=o((e,n)=>T(e,"name",{value:n,configurable:!0}),"t");import{jsx as d}from"react/jsx-runtime";import{Profiler as w}from"react";import{publish as $}from"./publish.js";import{makeInstanceId as g}from"./identity.js";export function withTraceComponent(e,n={}){const r=n.componentName??e.displayName??e.name??"TracedComponent",t=`react:component:${n.source??"(unknown)"}:${r}`;function a(p){let m;return d(w,{id:t,onRender:i((b,s,u,f,l,h)=>{const{instanceId:c}=g(t),y={id:c,parentRenderId:m,componentInstanceId:c,componentLogicalId:t,componentName:r,phase:s==="mount"?"mount":"update",actualDurationMs:u,baseDurationMs:f,startTime:l,commitTime:h,why:[{type:"force",reason:"withTraceComponent"}]};m=c,$({source:"react",category:"render",severity:"info",title:`render ${r} (${s})`,fingerprint:`react-render:${t}`,raw:{kind:"render",render:y}})},"onRender"),children:d(e,{...p})})}return o(a,"a"),i(a,"Traced"),a.displayName=`Traced(${r})`,a}o(withTraceComponent,"withTraceComponent"),i(withTraceComponent,"withTraceComponent");
1
+ "use strict";var w=Object.defineProperty;var a=(e,n)=>w(e,"name",{value:n,configurable:!0});var I=Object.defineProperty,i=a((e,n)=>I(e,"name",{value:n,configurable:!0}),"o"),b=Object.defineProperty,m=i((e,n)=>b(e,"name",{value:n,configurable:!0}),"t");import{jsx as s}from"react/jsx-runtime";import{Profiler as $}from"react";import{publish as g}from"./publish.js";import{makeInstanceId as v}from"./identity.js";export function withTraceComponent(e,n={}){const r=n.componentName??e.displayName??e.name??"TracedComponent",t=`react:component:${n.source??"(unknown)"}:${r}`;function o(u){let d;return s($,{id:t,onRender:m((C,p,f,l,T,y)=>{const{instanceId:c}=v(t),h={id:c,parentRenderId:d,componentInstanceId:c,componentLogicalId:t,componentName:r,phase:p==="mount"?"mount":"update",actualDurationMs:f,baseDurationMs:l,startTime:T,commitTime:y,why:[{type:"force",reason:"withTraceComponent"}]};d=c,g({source:"react",category:"render",severity:"info",title:`render ${r} (${p})`,fingerprint:`react-render:${t}`,raw:{kind:"render",render:h}})},"onRender"),children:s(e,{...u})})}return a(o,"a"),i(o,"a"),m(o,"Traced"),o.displayName=`Traced(${r})`,o}a(withTraceComponent,"withTraceComponent"),i(withTraceComponent,"withTraceComponent"),m(withTraceComponent,"withTraceComponent");
package/lib/identity.js CHANGED
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var e=(n,t)=>f(n,"name",{value:t,configurable:!0});var p=Object.defineProperty,o=e((n,t)=>p(n,"name",{value:t,configurable:!0}),"n");const s=new Map;let i=0;export function nextGeneration(n){const t=(s.get(n)??0)+1;return s.set(n,t),t}e(nextGeneration,"nextGeneration"),o(nextGeneration,"nextGeneration");export function shortHash(){return i=(i+1)%4294967295,(Date.now()&4095^i).toString(36).slice(-4)}e(shortHash,"shortHash"),o(shortHash,"shortHash");export function componentLogicalId(n,t){return`react:component:${n}:${t}`}e(componentLogicalId,"componentLogicalId"),o(componentLogicalId,"componentLogicalId");export function hookLogicalId(n,t,a,r){return`react:hook:${n}:${t}:${a}:${r}`}e(hookLogicalId,"hookLogicalId"),o(hookLogicalId,"hookLogicalId");export function slotLogicalId(n,t,a){return`react:slot:${n}:${t}:${a}`}e(slotLogicalId,"slotLogicalId"),o(slotLogicalId,"slotLogicalId");export function makeInstanceId(n){const t=nextGeneration(n);return{instanceId:`${n}#${t}#${shortHash()}`,generation:t}}e(makeInstanceId,"makeInstanceId"),o(makeInstanceId,"makeInstanceId");export function depsHash(n){if(!n)return"no-deps";let t=5381;const a=o(r=>{for(let c=0;c<r.length;c++)t=t*33^r.charCodeAt(c);t=t*33^59},"mix");for(const r of n){if(r===null){a("null");continue}const c=typeof r;a(c==="object"||c==="function"?`ref:${l(r)}`:`${c}:${String(r)}`)}return(t>>>0).toString(36)}e(depsHash,"depsHash"),o(depsHash,"depsHash");const u=new WeakMap;let d=1;function l(n){let t=u.get(n);return t===void 0&&(t=d++,u.set(n,t)),t}e(l,"p"),o(l,"refId");export function resetIdentityState(){s.clear(),i=0}e(resetIdentityState,"resetIdentityState"),o(resetIdentityState,"resetIdentityState");
1
+ "use strict";var f=Object.defineProperty;var n=(e,t)=>f(e,"name",{value:t,configurable:!0});var p=Object.defineProperty,o=n((e,t)=>p(e,"name",{value:t,configurable:!0}),"e"),I=Object.defineProperty,r=o((e,t)=>I(e,"name",{value:t,configurable:!0}),"n");const l=new Map;let s=0;export function nextGeneration(e){const t=(l.get(e)??0)+1;return l.set(e,t),t}n(nextGeneration,"nextGeneration"),o(nextGeneration,"nextGeneration"),r(nextGeneration,"nextGeneration");export function shortHash(){return s=(s+1)%4294967295,(Date.now()&4095^s).toString(36).slice(-4)}n(shortHash,"shortHash"),o(shortHash,"shortHash"),r(shortHash,"shortHash");export function componentLogicalId(e,t){return`react:component:${e}:${t}`}n(componentLogicalId,"componentLogicalId"),o(componentLogicalId,"componentLogicalId"),r(componentLogicalId,"componentLogicalId");export function hookLogicalId(e,t,i,c){return`react:hook:${e}:${t}:${i}:${c}`}n(hookLogicalId,"hookLogicalId"),o(hookLogicalId,"hookLogicalId"),r(hookLogicalId,"hookLogicalId");export function slotLogicalId(e,t,i){return`react:slot:${e}:${t}:${i}`}n(slotLogicalId,"slotLogicalId"),o(slotLogicalId,"slotLogicalId"),r(slotLogicalId,"slotLogicalId");export function makeInstanceId(e){const t=nextGeneration(e);return{instanceId:`${e}#${t}#${shortHash()}`,generation:t}}n(makeInstanceId,"makeInstanceId"),o(makeInstanceId,"makeInstanceId"),r(makeInstanceId,"makeInstanceId");export function depsHash(e){if(!e)return"no-deps";let t=5381;const i=r(c=>{for(let a=0;a<c.length;a++)t=t*33^c.charCodeAt(a);t=t*33^59},"mix");for(const c of e){if(c===null){i("null");continue}const a=typeof c;i(a==="object"||a==="function"?`ref:${u(c)}`:`${a}:${String(c)}`)}return(t>>>0).toString(36)}n(depsHash,"depsHash"),o(depsHash,"depsHash"),r(depsHash,"depsHash");const d=new WeakMap;let g=1;function u(e){let t=d.get(e);return t===void 0&&(t=g++,d.set(e,t)),t}n(u,"l"),o(u,"p"),r(u,"refId");export function resetIdentityState(){l.clear(),s=0}n(resetIdentityState,"resetIdentityState"),o(resetIdentityState,"resetIdentityState"),r(resetIdentityState,"resetIdentityState");
@@ -1 +1 @@
1
- "use strict";var w=Object.defineProperty;var i=(e,r)=>w(e,"name",{value:r,configurable:!0});var y=Object.defineProperty,p=i((e,r)=>y(e,"name",{value:r,configurable:!0}),"c");import{jsx as u}from"react/jsx-runtime";import{Profiler as M,useMemo as $,useRef as s}from"react";import{LensmcpContext as L}from"./context.js";import{publish as P}from"./publish.js";import{makeInstanceId as x}from"./identity.js";import{fiberRendersActive as j,installFiberRenderPublisher as k}from"./fiber-renders.js";typeof window<"u"&&k();export function LensmcpRoot(e){const r=e.rendererId??"lensmcp-root",f=$(()=>({rendererId:r,page:e.page,route:e.route}),[r,e.page,e.route]),l=s(new Map),d=s(new Map),c=s(void 0),I=p((t,m,g,v,b,R)=>{const a=`render:${r}:${t}`,{instanceId:n}=x(a);let o=d.current.get(t);o===void 0&&(o=n,d.current.set(t,o));const h={id:n,parentRenderId:c.current,componentInstanceId:o,componentLogicalId:a,componentName:t,page:e.page,route:e.route,rendererId:r,phase:m==="mount"?"mount":"update",actualDurationMs:g,baseDurationMs:v,startTime:b,commitTime:R,why:[{type:"force",reason:"profiler-onrender"}]};c.current=n,l.current.set(t,n),!j()&&P({source:"react",category:"render",severity:"info",title:`render ${t} (${m})`,fingerprint:`react-render:${a}`,raw:{kind:"render",render:h}})},"onRender");return u(L.Provider,{value:f,children:u(M,{id:r,onRender:I,children:e.children})})}i(LensmcpRoot,"LensmcpRoot"),p(LensmcpRoot,"LensmcpRoot");
1
+ "use strict";var w=Object.defineProperty;var i=(e,r)=>w(e,"name",{value:r,configurable:!0});var L=Object.defineProperty,u=i((e,r)=>L(e,"name",{value:r,configurable:!0}),"i"),M=Object.defineProperty,m=u((e,r)=>M(e,"name",{value:r,configurable:!0}),"c");import{jsx as f}from"react/jsx-runtime";import{Profiler as P,useMemo as $,useRef as s}from"react";import{LensmcpContext as j}from"./context.js";import{publish as x}from"./publish.js";import{makeInstanceId as k}from"./identity.js";import{fiberRendersActive as D,installFiberRenderPublisher as O}from"./fiber-renders.js";typeof window<"u"&&O();export function LensmcpRoot(e){const r=e.rendererId??"lensmcp-root",l=$(()=>({rendererId:r,page:e.page,route:e.route}),[r,e.page,e.route]),g=s(new Map),c=s(new Map),d=s(void 0),v=m((n,p,I,b,R,h)=>{const a=`render:${r}:${n}`,{instanceId:o}=k(a);let t=c.current.get(n);t===void 0&&(t=o,c.current.set(n,t));const y={id:o,parentRenderId:d.current,componentInstanceId:t,componentLogicalId:a,componentName:n,page:e.page,route:e.route,rendererId:r,phase:p==="mount"?"mount":"update",actualDurationMs:I,baseDurationMs:b,startTime:R,commitTime:h,why:[{type:"force",reason:"profiler-onrender"}]};d.current=o,g.current.set(n,o),!D()&&x({source:"react",category:"render",severity:"info",title:`render ${n} (${p})`,fingerprint:`react-render:${a}`,raw:{kind:"render",render:y}})},"onRender");return f(j.Provider,{value:l,children:f(P,{id:r,onRender:v,children:e.children})})}i(LensmcpRoot,"LensmcpRoot"),u(LensmcpRoot,"LensmcpRoot"),m(LensmcpRoot,"LensmcpRoot");
package/lib/publish.js CHANGED
@@ -1 +1 @@
1
- "use strict";var C=Object.defineProperty;var t=(e,o)=>C(e,"name",{value:o,configurable:!0});var O=Object.defineProperty,n=t((e,o)=>O(e,"name",{value:o,configurable:!0}),"t");import{createEventFloodGuard as W,estimateJsonBytes as U}from"@lensmcp/protocol-types";const u=[],$=200,v=(()=>{const e=typeof process<"u"?process.env?.LENSMCP_PUBLISH_QUEUE_BYTES:void 0,o=Number(e);return Number.isFinite(o)&&o>0?Math.floor(o):1024*1024})(),I=[];let s=0;function M(e){const o=U(e,v);for(u.push(e),I.push(o),s+=o;u.length>$||s>v&&u.length>1;)u.shift(),s-=I.shift()??0;u.length===0&&(s=0)}t(M,"W"),n(M,"enqueue");function S(){const e=u.shift();return s-=I.shift()??0,u.length===0&&(s=0),e}t(S,"k"),n(S,"dequeue");export function queuedByteCount(){return s}t(queuedByteCount,"queuedByteCount"),n(queuedByteCount,"queuedByteCount");const p=[],F=4e3;let c;export const DEFAULT_AMBIENT_FLOW_MAX_MS=3e4;let y;function N(e){if(e==="off"||e==="Infinity")return 1/0;const o=typeof e=="string"&&e.trim()!==""?Number(e):e;if(!(typeof o!="number"||Number.isNaN(o)||o<0))return o===0||o===1/0?1/0:o}t(N,"_"),n(N,"parseMaxLifetime");function L(){if(y!==void 0)return y;const e=N(globalThis.__LENSMCP_AMBIENT_FLOW_MAX_MS__);return e!==void 0?e:N(typeof process<"u"?process.env?.LENSMCP_AMBIENT_FLOW_MAX_MS:void 0)??DEFAULT_AMBIENT_FLOW_MAX_MS}t(L,"D"),n(L,"ambientMaxMs");export function configureAmbientFlows(e){y=e.maxLifetimeMs===void 0?void 0:N(e.maxLifetimeMs)}t(configureAmbientFlows,"configureAmbientFlows"),n(configureAmbientFlows,"configureAmbientFlows");const l=new Map,X=16;function E(e){for(l.set(e,{bornAt:Date.now()});l.size>X;)l.delete(l.keys().next().value)}t(E,"C"),n(E,"trackAmbient");function b(e){const o=l.get(e.flowId);if(!o)return!1;const i=L();return i!==1/0&&Date.now()-o.bornAt>=i}t(b,"x"),n(b,"ambientExhausted");export function extendFlowWindow(e){const o=e??currentFlow()??c?.spec;o&&(b(o)||(c={spec:o,until:Date.now()+F}))}t(extendFlowWindow,"extendFlowWindow"),n(extendFlowWindow,"extendFlowWindow");function a(){return c&&Date.now()<c.until?c.spec:void 0}t(a,"g"),n(a,"windowedFlow");export function activeFlow(){return currentFlow()??a()}t(activeFlow,"activeFlow"),n(activeFlow,"activeFlow");export function beginBackgroundFlow(e){const o={flowId:h(),originType:e.originType,...e.originNodeId?{originNodeId:e.originNodeId}:{}};return c={spec:o,until:Date.now()+F},E(o.flowId),publish({source:"react",category:"runtime",severity:"info",title:e.originType,fingerprint:_(e.originNodeId??e.originType,o.flowId),raw:{kind:"flow-origin",originNodeId:e.originNodeId,...e.continuesFlowId?{continuesFlowId:e.continuesFlowId}:{}}}),o}t(beginBackgroundFlow,"beginBackgroundFlow"),n(beginBackgroundFlow,"beginBackgroundFlow");export function flowForNewActivity(){const e=currentFlow();if(e)return e;const o=a();if(o)return b(o)?beginBackgroundFlow({originType:"timer",originNodeId:typeof location<"u"?`ambient:${location.pathname}`:"ambient",continuesFlowId:o.flowId}):o}t(flowForNewActivity,"flowForNewActivity"),n(flowForNewActivity,"flowForNewActivity");export const FLOW_ORIGIN_FINGERPRINT_PREFIX="flow-origin:";function _(e,o){return`${FLOW_ORIGIN_FINGERPRINT_PREFIX}${e}:${o}`}t(_,"M"),n(_,"originFingerprint");export function setPublisher(e){if(globalThis.__LENSMCP_PUBLISH__=e,e)for(;u.length;){const o=S();if(o)try{e(o)}catch{}}}t(setPublisher,"setPublisher"),n(setPublisher,"setPublisher");export function runInFlow(e,o){p.push(e),c={spec:e,until:Date.now()+F};try{return o()}finally{p.pop()}}t(runInFlow,"runInFlow"),n(runInFlow,"runInFlow");export function currentFlow(){return p[p.length-1]}t(currentFlow,"currentFlow"),n(currentFlow,"currentFlow");const B=Symbol.for("lensmcp.flowed"),A=2e3,f=new Map;function P(e){if(e==null||typeof e!="object")return;const o=e,i=o.nativeEvent;if(i!=null&&typeof i=="object"){const r=i.isTrusted;if(typeof r=="boolean")return r}if(typeof o.isTrusted=="boolean")return o.isTrusted}t(P,"v"),n(P,"eventTrust");function k(e){if(!(f.size<=64))for(const[o,i]of f)e>=i.until&&f.delete(o)}t(k,"X"),n(k,"pruneInputBursts");export function withFlow(e,o={}){if(typeof e!="function"||e[B])return e;const i=n(()=>{publish({source:"react",category:"runtime",severity:"info",title:o.originType??"user-click",fingerprint:_(o.originNodeId??"unknown",currentFlow()?.flowId??""),raw:{kind:"flow-origin",originNodeId:o.originNodeId}})},"publishOrigin"),r=n(function(...d){if(o.originType==="input-change"){if(P(d[0])===!1)return currentFlow()==null&&a()!=null&&extendFlowWindow(),e(...d);const T=o.originNodeId??"input",w=Date.now(),g=f.get(T);if(g&&w<g.until)return g.until=w+A,runInFlow(g.spec,()=>e(...d));const x={flowId:h(),originType:"input-change",originNodeId:o.originNodeId};return f.set(T,{spec:x,until:w+A}),k(w),runInFlow(x,()=>(i(),e(...d)))}const D=h();return runInFlow({flowId:D,originType:o.originType??"user-click",originNodeId:o.originNodeId},()=>(i(),e(...d)))},"flowed");return r[B]=!0,r}t(withFlow,"withFlow"),n(withFlow,"withFlow");let m=0;function h(){return m=(m+1)%65535,`flow:${Date.now().toString(36)}:${m.toString(36)}`}t(h,"E"),n(h,"newFlowId");export function publish(e){const o=currentFlow()??(e.context?.flowId?void 0:a()),i=o==null?e:{...e,context:{...o.flowId?{flowId:o.flowId}:{},...o.originType?{originType:o.originType}:{},...o.originNodeId?{originNodeId:o.originNodeId}:{},...o.causedByNodeId?{causedByNodeId:o.causedByNodeId}:{},...e.context}},r=globalThis.__LENSMCP_PUBLISH__;if(r)try{r(i);return}catch{}M(i)}t(publish,"publish"),n(publish,"publish");const j=W({burst:30,perSec:5});export function publishLazy(e,o){const i=e.startsWith(FLOW_ORIGIN_FINGERPRINT_PREFIX)?{ok:!0,suppressed:0}:j.admit(e);if(!i.ok)return;const r=o();if(i.suppressed>0&&r.raw!==null&&typeof r.raw=="object"){publish({...r,raw:{...r.raw,floodSuppressed:i.suppressed}});return}publish(r)}t(publishLazy,"publishLazy"),n(publishLazy,"publishLazy");export function resetFlowStateForTests(){p.length=0,c=void 0,l.clear(),f.clear(),y=void 0}t(resetFlowStateForTests,"resetFlowStateForTests"),n(resetFlowStateForTests,"resetFlowStateForTests");export function drainQueue(){return I.length=0,s=0,u.splice(0,u.length)}t(drainQueue,"drainQueue"),n(drainQueue,"drainQueue");
1
+ "use strict";var W=Object.defineProperty;var e=(o,n)=>W(o,"name",{value:n,configurable:!0});var O=Object.defineProperty,i=e((o,n)=>O(o,"name",{value:n,configurable:!0}),"t"),U=Object.defineProperty,t=i((o,n)=>U(o,"name",{value:n,configurable:!0}),"t");import{createEventFloodGuard as $,estimateJsonBytes as j}from"@lensmcp/protocol-types";const s=[],X=200,P=(()=>{const o=typeof process<"u"?process.env?.LENSMCP_PUBLISH_QUEUE_BYTES:void 0,n=Number(o);return Number.isFinite(n)&&n>0?Math.floor(n):1024*1024})(),b=[];let c=0;function m(o){const n=j(o,P);for(s.push(o),b.push(n),c+=n;s.length>X||c>P&&s.length>1;)s.shift(),c-=b.shift()??0;s.length===0&&(c=0)}e(m,"M"),i(m,"W"),t(m,"enqueue");function v(){const o=s.shift();return c-=b.shift()??0,s.length===0&&(c=0),o}e(v,"S"),i(v,"k"),t(v,"dequeue");export function queuedByteCount(){return c}e(queuedByteCount,"queuedByteCount"),i(queuedByteCount,"queuedByteCount"),t(queuedByteCount,"queuedByteCount");const w=[],x=4e3;let l;export const DEFAULT_AMBIENT_FLOW_MAX_MS=3e4;let N;function g(o){if(o==="off"||o==="Infinity")return 1/0;const n=typeof o=="string"&&o.trim()!==""?Number(o):o;if(!(typeof n!="number"||Number.isNaN(n)||n<0))return n===0||n===1/0?1/0:n}e(g,"N"),i(g,"_"),t(g,"parseMaxLifetime");function T(){if(N!==void 0)return N;const o=g(globalThis.__LENSMCP_AMBIENT_FLOW_MAX_MS__);return o!==void 0?o:g(typeof process<"u"?process.env?.LENSMCP_AMBIENT_FLOW_MAX_MS:void 0)??DEFAULT_AMBIENT_FLOW_MAX_MS}e(T,"L"),i(T,"D"),t(T,"ambientMaxMs");export function configureAmbientFlows(o){N=o.maxLifetimeMs===void 0?void 0:g(o.maxLifetimeMs)}e(configureAmbientFlows,"configureAmbientFlows"),i(configureAmbientFlows,"configureAmbientFlows"),t(configureAmbientFlows,"configureAmbientFlows");const f=new Map,q=16;function M(o){for(f.set(o,{bornAt:Date.now()});f.size>q;)f.delete(f.keys().next().value)}e(M,"E"),i(M,"C"),t(M,"trackAmbient");function h(o){const n=f.get(o.flowId);if(!n)return!1;const r=T();return r!==1/0&&Date.now()-n.bornAt>=r}e(h,"b"),i(h,"x"),t(h,"ambientExhausted");export function extendFlowWindow(o){const n=o??currentFlow()??l?.spec;n&&(h(n)||(l={spec:n,until:Date.now()+x}))}e(extendFlowWindow,"extendFlowWindow"),i(extendFlowWindow,"extendFlowWindow"),t(extendFlowWindow,"extendFlowWindow");function d(){return l&&Date.now()<l.until?l.spec:void 0}e(d,"a"),i(d,"g"),t(d,"windowedFlow");export function activeFlow(){return currentFlow()??d()}e(activeFlow,"activeFlow"),i(activeFlow,"activeFlow"),t(activeFlow,"activeFlow");export function beginBackgroundFlow(o){const n={flowId:I(),originType:o.originType,...o.originNodeId?{originNodeId:o.originNodeId}:{}};return l={spec:n,until:Date.now()+x},M(n.flowId),publish({source:"react",category:"runtime",severity:"info",title:o.originType,fingerprint:_(o.originNodeId??o.originType,n.flowId),raw:{kind:"flow-origin",originNodeId:o.originNodeId,...o.continuesFlowId?{continuesFlowId:o.continuesFlowId}:{}}}),n}e(beginBackgroundFlow,"beginBackgroundFlow"),i(beginBackgroundFlow,"beginBackgroundFlow"),t(beginBackgroundFlow,"beginBackgroundFlow");export function flowForNewActivity(){const o=currentFlow();if(o)return o;const n=d();if(n)return h(n)?beginBackgroundFlow({originType:"timer",originNodeId:typeof location<"u"?`ambient:${location.pathname}`:"ambient",continuesFlowId:n.flowId}):n}e(flowForNewActivity,"flowForNewActivity"),i(flowForNewActivity,"flowForNewActivity"),t(flowForNewActivity,"flowForNewActivity");export const FLOW_ORIGIN_FINGERPRINT_PREFIX="flow-origin:";function _(o,n){return`${FLOW_ORIGIN_FINGERPRINT_PREFIX}${o}:${n}`}e(_,"_"),i(_,"M"),t(_,"originFingerprint");export function setPublisher(o){if(globalThis.__LENSMCP_PUBLISH__=o,o)for(;s.length;){const n=v();if(n)try{o(n)}catch{}}}e(setPublisher,"setPublisher"),i(setPublisher,"setPublisher"),t(setPublisher,"setPublisher");export function runInFlow(o,n){w.push(o),l={spec:o,until:Date.now()+x};try{return n()}finally{w.pop()}}e(runInFlow,"runInFlow"),i(runInFlow,"runInFlow"),t(runInFlow,"runInFlow");export function currentFlow(){return w[w.length-1]}e(currentFlow,"currentFlow"),i(currentFlow,"currentFlow"),t(currentFlow,"currentFlow");const k=Symbol.for("lensmcp.flowed"),D=2e3,p=new Map;function S(o){if(o==null||typeof o!="object")return;const n=o,r=n.nativeEvent;if(r!=null&&typeof r=="object"){const u=r.isTrusted;if(typeof u=="boolean")return u}if(typeof n.isTrusted=="boolean")return n.isTrusted}e(S,"P"),i(S,"v"),t(S,"eventTrust");function L(o){if(!(p.size<=64))for(const[n,r]of p)o>=r.until&&p.delete(n)}e(L,"k"),i(L,"X"),t(L,"pruneInputBursts");export function withFlow(o,n={}){if(typeof o!="function"||o[k])return o;const r=t(()=>{publish({source:"react",category:"runtime",severity:"info",title:n.originType??"user-click",fingerprint:_(n.originNodeId??"unknown",currentFlow()?.flowId??""),raw:{kind:"flow-origin",originNodeId:n.originNodeId}})},"publishOrigin"),u=t(function(...a){if(n.originType==="input-change"){if(S(a[0])===!1)return currentFlow()==null&&d()!=null&&extendFlowWindow(),o(...a);const E=n.originNodeId??"input",y=Date.now(),F=p.get(E);if(F&&y<F.until)return F.until=y+D,runInFlow(F.spec,()=>o(...a));const A={flowId:I(),originType:"input-change",originNodeId:n.originNodeId};return p.set(E,{spec:A,until:y+D}),L(y),runInFlow(A,()=>(r(),o(...a)))}const C=I();return runInFlow({flowId:C,originType:n.originType??"user-click",originNodeId:n.originNodeId},()=>(r(),o(...a)))},"flowed");return u[k]=!0,u}e(withFlow,"withFlow"),i(withFlow,"withFlow"),t(withFlow,"withFlow");let B=0;function I(){return B=(B+1)%65535,`flow:${Date.now().toString(36)}:${B.toString(36)}`}e(I,"h"),i(I,"E"),t(I,"newFlowId");export function publish(o){const n=currentFlow()??(o.context?.flowId?void 0:d()),r=n==null?o:{...o,context:{...n.flowId?{flowId:n.flowId}:{},...n.originType?{originType:n.originType}:{},...n.originNodeId?{originNodeId:n.originNodeId}:{},...n.causedByNodeId?{causedByNodeId:n.causedByNodeId}:{},...o.context}},u=globalThis.__LENSMCP_PUBLISH__;if(u)try{u(r);return}catch{}m(r)}e(publish,"publish"),i(publish,"publish"),t(publish,"publish");const z=$({burst:30,perSec:5});export function publishLazy(o,n){const r=o.startsWith(FLOW_ORIGIN_FINGERPRINT_PREFIX)?{ok:!0,suppressed:0}:z.admit(o);if(!r.ok)return;const u=n();if(r.suppressed>0&&u.raw!==null&&typeof u.raw=="object"){publish({...u,raw:{...u.raw,floodSuppressed:r.suppressed}});return}publish(u)}e(publishLazy,"publishLazy"),i(publishLazy,"publishLazy"),t(publishLazy,"publishLazy");export function resetFlowStateForTests(){w.length=0,l=void 0,f.clear(),p.clear(),N=void 0}e(resetFlowStateForTests,"resetFlowStateForTests"),i(resetFlowStateForTests,"resetFlowStateForTests"),t(resetFlowStateForTests,"resetFlowStateForTests");export function drainQueue(){return b.length=0,c=0,s.splice(0,s.length)}e(drainQueue,"drainQueue"),i(drainQueue,"drainQueue"),t(drainQueue,"drainQueue");
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var n=(e,o)=>g(e,"name",{value:o,configurable:!0});var S=Object.defineProperty,t=n((e,o)=>S(e,"name",{value:o,configurable:!0}),"e");import{activeFlow as m,beginBackgroundFlow as E}from"./publish.js";const f=200;function y(){const e=globalThis.window;if(!(!e?.history||!e.location||typeof e.addEventListener!="function"||typeof e.removeEventListener!="function"))return e}n(y,"E"),t(y,"browserEnvironment");export function routeNodeId(e){return`route:${e.length>f?e.slice(0,f):e}`}n(routeNodeId,"routeNodeId"),t(routeNodeId,"routeNodeId");let a;export function installRouteFlows(e=y()){if(!e)return()=>{};if(a)return()=>{};let o=e.location.pathname,s=!0;const i=t(()=>{if(!s)return;const r=e.location.pathname;r!==o&&(o=r,!m()&&E({originType:"route-load",originNodeId:routeNodeId(r)}))},"navigated"),u=t(r=>t(function(...v){const w=r.apply(this,v);try{i()}catch{}return w},"wrapped"),"wrap"),c=e.history.pushState,l=e.history.replaceState,p=u(c),h=u(l);e.history.pushState=p,e.history.replaceState=h,e.addEventListener("popstate",i);const d=t(()=>{s=!1,e.removeEventListener("popstate",i),e.history.pushState===p&&(e.history.pushState=c),e.history.replaceState===h&&(e.history.replaceState=l),a=void 0},"uninstall");return a=d,d}n(installRouteFlows,"installRouteFlows"),t(installRouteFlows,"installRouteFlows");
1
+ "use strict";var m=Object.defineProperty;var n=(t,e)=>m(t,"name",{value:e,configurable:!0});var S=Object.defineProperty,i=n((t,e)=>S(t,"name",{value:e,configurable:!0}),"n"),b=Object.defineProperty,o=i((t,e)=>b(t,"name",{value:e,configurable:!0}),"e");import{activeFlow as E,beginBackgroundFlow as F}from"./publish.js";const v=200;function s(){const t=globalThis.window;if(!(!t?.history||!t.location||typeof t.addEventListener!="function"||typeof t.removeEventListener!="function"))return t}n(s,"y"),i(s,"E"),o(s,"browserEnvironment");export function routeNodeId(t){return`route:${t.length>v?t.slice(0,v):t}`}n(routeNodeId,"routeNodeId"),i(routeNodeId,"routeNodeId"),o(routeNodeId,"routeNodeId");let l;export function installRouteFlows(t=s()){if(!t)return()=>{};if(l)return()=>{};let e=t.location.pathname,u=!0;const a=o(()=>{if(!u)return;const r=t.location.pathname;r!==e&&(e=r,!E()&&F({originType:"route-load",originNodeId:routeNodeId(r)}))},"navigated"),c=o(r=>o(function(...w){const g=r.apply(this,w);try{a()}catch{}return g},"wrapped"),"wrap"),p=t.history.pushState,d=t.history.replaceState,h=c(p),f=c(d);t.history.pushState=h,t.history.replaceState=f,t.addEventListener("popstate",a);const y=o(()=>{u=!1,t.removeEventListener("popstate",a),t.history.pushState===h&&(t.history.pushState=p),t.history.replaceState===f&&(t.history.replaceState=d),l=void 0},"uninstall");return l=y,y}n(installRouteFlows,"installRouteFlows"),i(installRouteFlows,"installRouteFlows"),o(installRouteFlows,"installRouteFlows");
package/lib/trace-slot.js CHANGED
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var o=(e,n)=>m(e,"name",{value:n,configurable:!0});var p=Object.defineProperty,a=o((e,n)=>p(e,"name",{value:n,configurable:!0}),"c");import{jsx as d}from"react/jsx-runtime";import{Children as l,Fragment as y,useEffect as I,useRef as u}from"react";import{publish as g}from"./publish.js";import{makeInstanceId as b}from"./identity.js";import{useLensmcpContext as h}from"./context.js";export function TraceSlot(e){const n=h(),t=u(void 0),c=u(void 0);c.current||(c.current=b(`react:slot:${e.id}`).instanceId);const i=c.current,r=f(e.children);return I(()=>{if(t.current!==r){const s=t.current;t.current=r,g({source:"react",category:"render",severity:"info",title:`slot ${e.id}: ${s??"(none)"} \u2192 ${r}`,fingerprint:`slot-change:${e.id}`,raw:{kind:"slot-content-changed",slot:{slotLogicalId:`react:slot:${e.id}`,slotInstanceId:i,fromComponent:s,toComponent:r,componentInstanceId:n.componentInstanceId}}})}},[r,e.id,i,n.componentInstanceId]),d(y,{children:e.children})}o(TraceSlot,"TraceSlot"),a(TraceSlot,"TraceSlot");function f(e){const n=l.toArray(e)[0];if(!n)return"(empty)";if(typeof n=="string"||typeof n=="number")return"(text)";if(typeof n=="boolean")return"(boolean)";if(Array.isArray(n))return"(array)";if(typeof n=="object"&&n&&"type"in n){const t=n.type;return typeof t=="string"?t:typeof t=="function"?t.displayName??t.name??"AnonymousComponent":"unknown"}return"unknown"}o(f,"g"),a(f,"describeChild");
1
+ "use strict";var p=Object.defineProperty;var o=(t,n)=>p(t,"name",{value:n,configurable:!0});var d=Object.defineProperty,a=o((t,n)=>d(t,"name",{value:n,configurable:!0}),"o"),l=Object.defineProperty,f=a((t,n)=>l(t,"name",{value:n,configurable:!0}),"c");import{jsx as y}from"react/jsx-runtime";import{Children as I,Fragment as g,useEffect as b,useRef as m}from"react";import{publish as h}from"./publish.js";import{makeInstanceId as v}from"./identity.js";import{useLensmcpContext as C}from"./context.js";export function TraceSlot(t){const n=C(),e=m(void 0),c=m(void 0);c.current||(c.current=v(`react:slot:${t.id}`).instanceId);const s=c.current,r=i(t.children);return b(()=>{if(e.current!==r){const u=e.current;e.current=r,h({source:"react",category:"render",severity:"info",title:`slot ${t.id}: ${u??"(none)"} \u2192 ${r}`,fingerprint:`slot-change:${t.id}`,raw:{kind:"slot-content-changed",slot:{slotLogicalId:`react:slot:${t.id}`,slotInstanceId:s,fromComponent:u,toComponent:r,componentInstanceId:n.componentInstanceId}}})}},[r,t.id,s,n.componentInstanceId]),y(g,{children:t.children})}o(TraceSlot,"TraceSlot"),a(TraceSlot,"TraceSlot"),f(TraceSlot,"TraceSlot");function i(t){const n=I.toArray(t)[0];if(!n)return"(empty)";if(typeof n=="string"||typeof n=="number")return"(text)";if(typeof n=="boolean")return"(boolean)";if(Array.isArray(n))return"(array)";if(typeof n=="object"&&n&&"type"in n){const e=n.type;return typeof e=="string"?e:typeof e=="function"?e.displayName??e.name??"AnonymousComponent":"unknown"}return"unknown"}o(i,"f"),a(i,"g"),f(i,"describeChild");
@@ -1 +1 @@
1
- "use strict";var b=Object.defineProperty;var p=(e,n)=>b(e,"name",{value:n,configurable:!0});var w=Object.defineProperty,f=p((e,n)=>w(e,"name",{value:n,configurable:!0}),"p");import{useCallback as $,useEffect as H,useMemo as M,useRef as i}from"react";import{useComponentIdentity as k}from"./component-identity.js";import{useLensmcpContext as y}from"./context.js";import{depsHash as v}from"./identity.js";import{publish as m}from"./publish.js";import{activeCommitId as I}from"./fiber-renders.js";export function tracedUseEffect(e,n,r){const a=y(),s=k(),u=l(e),o=i(void 0);H(()=>{const t=typeof performance<"u"&&performance.now?performance.now():Date.now(),c=v(r),d=o.current;o.current=c;let h;try{h=n()}finally{const g=typeof performance<"u"&&performance.now?performance.now():Date.now();m({source:"react",category:"render",severity:"info",title:`effect-run ${e}`,fingerprint:`effect-run:${e}`,raw:{kind:"effect-run",effect:{...I()?{commitId:I()}:{},hookInstanceId:u,hookLogicalId:e,componentInstanceId:a.componentInstanceId??s.componentInstanceId,depsHash:c,prevDepsHash:d,durationMs:Math.max(0,g-t)}}})}return()=>{typeof h=="function"&&h(),m({source:"react",category:"render",severity:"info",title:`effect-cleanup ${e}`,fingerprint:`effect-cleanup:${e}`,raw:{kind:"effect-run",effect:{...I()?{commitId:I()}:{},hookInstanceId:u,hookLogicalId:e,componentInstanceId:a.componentInstanceId??s.componentInstanceId,depsHash:o.current??c,durationMs:0,cleanupRan:!0}}})}},r)}p(tracedUseEffect,"tracedUseEffect"),f(tracedUseEffect,"tracedUseEffect");export function tracedUseMemo(e,n,r){const a=y(),s=k(),u=l(e),o=i(void 0),t=v(r),c=t!==o.current,d=M(n,r??[]);return c&&m({source:"react",category:"render",severity:"debug",title:`useMemo recomputed ${e}`,fingerprint:`hook-run:${e}`,raw:{kind:"hook-run",hook:{hookInstanceId:u,hookLogicalId:e,componentInstanceId:a.componentInstanceId??s.componentInstanceId,hookType:"useMemo",depsHash:t,prevDepsHash:o.current,recomputed:!0}}}),o.current=t,d}p(tracedUseMemo,"tracedUseMemo"),f(tracedUseMemo,"tracedUseMemo");export function tracedUseCallback(e,n,r){const a=y(),s=k(),u=l(e),o=i(void 0),t=v(r),c=t!==o.current,d=$(n,r??[]);return c&&m({source:"react",category:"render",severity:"debug",title:`useCallback recomputed ${e}`,fingerprint:`hook-run:${e}`,raw:{kind:"hook-run",hook:{hookInstanceId:u,hookLogicalId:e,componentInstanceId:a.componentInstanceId??s.componentInstanceId,hookType:"useCallback",depsHash:t,prevDepsHash:o.current,recomputed:!0}}}),o.current=t,d}p(tracedUseCallback,"tracedUseCallback"),f(tracedUseCallback,"tracedUseCallback");function l(e){const n=i(void 0);return n.current||(n.current=`${e}#${Math.random()*1e9|0}`),n.current}p(l,"H"),f(l,"useStableHookInstance");
1
+ "use strict";var w=Object.defineProperty;var d=(e,n)=>w(e,"name",{value:n,configurable:!0});var H=Object.defineProperty,f=d((e,n)=>H(e,"name",{value:n,configurable:!0}),"p"),M=Object.defineProperty,m=f((e,n)=>M(e,"name",{value:n,configurable:!0}),"p");import{useCallback as $,useEffect as C,useMemo as U,useRef as I}from"react";import{useComponentIdentity as y}from"./component-identity.js";import{useLensmcpContext as v}from"./context.js";import{depsHash as g}from"./identity.js";import{publish as l}from"./publish.js";import{activeCommitId as h}from"./fiber-renders.js";export function tracedUseEffect(e,n,r){const a=v(),s=y(),u=i(e),t=I(void 0);C(()=>{const o=typeof performance<"u"&&performance.now?performance.now():Date.now(),c=g(r),p=t.current;t.current=c;let k;try{k=n()}finally{const b=typeof performance<"u"&&performance.now?performance.now():Date.now();l({source:"react",category:"render",severity:"info",title:`effect-run ${e}`,fingerprint:`effect-run:${e}`,raw:{kind:"effect-run",effect:{...h()?{commitId:h()}:{},hookInstanceId:u,hookLogicalId:e,componentInstanceId:a.componentInstanceId??s.componentInstanceId,depsHash:c,prevDepsHash:p,durationMs:Math.max(0,b-o)}}})}return()=>{typeof k=="function"&&k(),l({source:"react",category:"render",severity:"info",title:`effect-cleanup ${e}`,fingerprint:`effect-cleanup:${e}`,raw:{kind:"effect-run",effect:{...h()?{commitId:h()}:{},hookInstanceId:u,hookLogicalId:e,componentInstanceId:a.componentInstanceId??s.componentInstanceId,depsHash:t.current??c,durationMs:0,cleanupRan:!0}}})}},r)}d(tracedUseEffect,"tracedUseEffect"),f(tracedUseEffect,"tracedUseEffect"),m(tracedUseEffect,"tracedUseEffect");export function tracedUseMemo(e,n,r){const a=v(),s=y(),u=i(e),t=I(void 0),o=g(r),c=o!==t.current,p=U(n,r??[]);return c&&l({source:"react",category:"render",severity:"debug",title:`useMemo recomputed ${e}`,fingerprint:`hook-run:${e}`,raw:{kind:"hook-run",hook:{hookInstanceId:u,hookLogicalId:e,componentInstanceId:a.componentInstanceId??s.componentInstanceId,hookType:"useMemo",depsHash:o,prevDepsHash:t.current,recomputed:!0}}}),t.current=o,p}d(tracedUseMemo,"tracedUseMemo"),f(tracedUseMemo,"tracedUseMemo"),m(tracedUseMemo,"tracedUseMemo");export function tracedUseCallback(e,n,r){const a=v(),s=y(),u=i(e),t=I(void 0),o=g(r),c=o!==t.current,p=$(n,r??[]);return c&&l({source:"react",category:"render",severity:"debug",title:`useCallback recomputed ${e}`,fingerprint:`hook-run:${e}`,raw:{kind:"hook-run",hook:{hookInstanceId:u,hookLogicalId:e,componentInstanceId:a.componentInstanceId??s.componentInstanceId,hookType:"useCallback",depsHash:o,prevDepsHash:t.current,recomputed:!0}}}),t.current=o,p}d(tracedUseCallback,"tracedUseCallback"),f(tracedUseCallback,"tracedUseCallback"),m(tracedUseCallback,"tracedUseCallback");function i(e){const n=I(void 0);return n.current||(n.current=`${e}#${Math.random()*1e9|0}`),n.current}d(i,"l"),f(i,"H"),m(i,"useStableHookInstance");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/react-instrumentation",
3
- "version": "1.24.5",
3
+ "version": "1.25.1",
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.24.5",
22
+ "@lensmcp/protocol-types": "1.25.1",
23
23
  "tslib": "^2.3.0"
24
24
  },
25
25
  "peerDependencies": {