@lensmcp/react-instrumentation 1.23.10 → 1.23.11

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 j=Object.defineProperty;var a=(i,e)=>j(i,"name",{value:e,configurable:!0});var C=Object.defineProperty,d=a((i,e)=>C(i,"name",{value:e,configurable:!0}),"a"),P=Object.defineProperty,p=d((i,e)=>P(i,"name",{value:e,configurable:!0}),"c");const $=4;export function displaySourcePath(i,e){const n=p(u=>u.replace(/\\/g,"/").replace(/\/+$/,"").split("/"),"segments"),t=n(i),r=n(e);let o=0;for(;o<t.length&&o<r.length&&t[o]===r[o];)o++;const l=r.length-o;if(o===0||l>4)return`<external>/${t[t.length-1]??"unknown"}`;const s=t.slice(o);return s.length===0?"<external>/unknown":[...new Array(l).fill(".."),...s].join("/")}a(displaySourcePath,"displaySourcePath"),d(displaySourcePath,"displaySourcePath"),p(displaySourcePath,"displaySourcePath");const w="@lensmcp/react-instrumentation",v={useEffect:"tracedUseEffect",useMemo:"tracedUseMemo",useCallback:"tracedUseCallback"},J=["onClick","onDoubleClick","onContextMenu","onSubmit","onChange"],R={onSubmit:"form-submit",onChange:"input-change"};export default function I(i){const e=i.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??J),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(o=>o.leadingComments??[])??[]).some(o=>o.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 o=h(n.node.body,w,e),l=r.filter(s=>!o.has(s));if(l.length>0&&n.node.body.unshift(e.importDeclaration(l.map(s=>e.importSpecifier(e.identifier(s),e.identifier(s))),e.stringLiteral(w))),t.needRoot){const s=n.node.body.findIndex(c=>!e.isImportDeclaration(c)),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&&f(n.node.init,e)&&t.rootVars.add(n.node.id.name)},CallExpression(n,t){if(t.fileIgnored)return;const r=n.node.callee;if(t.opts.autoWrapHooks!==!1&&e.isIdentifier(r)&&v[r.name]){const o=v[r.name],l=`${t.relativePath??"(anon)"}:${n.node.loc?.start.line??0}:${t.hookIndex++}`;n.node.callee=e.identifier(o),n.node.arguments.unshift(e.stringLiteral(l)),t.needHelpers.add(o);return}if(t.opts.autoWrapRoot!==!1&&e.isMemberExpression(r)&&e.isIdentifier(r.property,{name:"render"})&&(f(r.object,e)||e.isIdentifier(r.object)&&t.rootVars?.has(r.object.name))&&n.node.arguments.length>=1){const o=n.node.arguments[0];o&&!x(o,e)&&(n.node.arguments[0]=e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("LensmcpRoot"),[],!1),e.jsxClosingElement(e.jsxIdentifier("LensmcpRoot")),[e.jsxExpressionContainer(o)],!1),t.needRoot=!0)}},JSXOpeningElement(n,t){if(t.fileIgnored)return;const r=n.node.attributes;if(m(r,"data-agent-component")||m(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 c of n.node.attributes){if(c.type!=="JSXAttribute"||c.name.type!=="JSXIdentifier"||!t.flowEvents.has(c.name.name)||!c.value||c.value.type!=="JSXExpressionContainer")continue;const g=c.value.expression;if(g.type==="JSXEmptyExpression"||b(g,e))continue;const E=c.name.name;c.value.expression=e.callExpression(e.identifier("withFlow"),[g,e.objectExpression([e.objectProperty(e.identifier("originType"),e.stringLiteral(R[E]??"user-click")),e.objectProperty(e.identifier("originNodeId"),e.stringLiteral(`ui:${u}:${s}:${E}`))])]),t.needHelpers.add("withFlow")}}const o=S(n.node.name);if(!o||y(o))return;const l=[e.jsxAttribute(e.jsxIdentifier("data-agent-component"),e.stringLiteral(o))];if(t.opts.includeSource!==!1){const s=n.node.loc?.start.line??0,u=t.relativePath??"(anon)";l.push(e.jsxAttribute(e.jsxIdentifier("data-agent-source"),e.stringLiteral(`${u}:${s}`)))}n.node.attributes.push(...l)}}}}a(I,"w"),d(I,"y"),p(I,"lensmcpBabelPlugin");function m(i,e){return i.some(n=>n.type==="JSXAttribute"&&n.name.type==="JSXIdentifier"&&n.name.name===e)}a(m,"m"),d(m,"S"),p(m,"hasAttr");function h(i,e,n){const t=new Set;for(const r of i)if(n.isImportDeclaration(r)&&r.source.value===e)for(const o of r.specifiers)n.isImportSpecifier(o)&&n.isIdentifier(o.imported)&&t.add(o.imported.name);return t}a(h,"x"),d(h,"h"),p(h,"collectImported");function f(i,e){if(!e.isCallExpression(i))return!1;const n=i.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}a(f,"f"),d(f,"b"),p(f,"isRootFactoryCall");function b(i,e){return e.isCallExpression(i)&&e.isIdentifier(i.callee,{name:"withFlow"})}a(b,"y"),d(b,"C"),p(b,"isAlreadyWithFlow");function x(i,e){return e.isJSXElement(i)&&e.isJSXIdentifier(i.openingElement.name,{name:"LensmcpRoot"})}a(x,"I"),d(x,"j"),p(x,"isAlreadyLensmcpRoot");const X=new Set(["Fragment","StrictMode","Suspense","SuspenseList","Profiler"]);function y(i){const e=i.split(".").pop()??i;return X.has(e)?!0:e.endsWith("Provider")||e.endsWith("Consumer")}a(y,"S"),d(y,"P"),p(y,"isUnstampableElement");function S(i){switch(i.type){case"JSXIdentifier":return i.name;case"JSXMemberExpression":{const e=[];let n=i;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`${i.namespace.name}:${i.name.name}`;default:return}}a(S,"E"),d(S,"A"),p(S,"describeElementName");
1
+ "use strict";var v=Object.defineProperty;var a=(o,e)=>v(o,"name",{value:e,configurable:!0});var j=Object.defineProperty,d=a((o,e)=>j(o,"name",{value:e,configurable:!0}),"c");const X=4;export function displaySourcePath(o,e){const n=d(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 l=i.length-r;if(r===0||l>4)return`<external>/${t[t.length-1]??"unknown"}`;const s=t.slice(r);return s.length===0?"<external>/unknown":[...new Array(l).fill(".."),...s].join("/")}a(displaySourcePath,"displaySourcePath"),d(displaySourcePath,"displaySourcePath");const h="@lensmcp/react-instrumentation",b={useEffect:"tracedUseEffect",useMemo:"tracedUseMemo",useCallback:"tracedUseCallback"},C=["onClick","onDoubleClick","onContextMenu","onSubmit","onChange"],R={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??C),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=x(n.node.body,h,e),l=i.filter(s=>!r.has(s));if(l.length>0&&n.node.body.unshift(e.importDeclaration(l.map(s=>e.importSpecifier(e.identifier(s),e.identifier(s))),e.stringLiteral(h))),t.needRoot){const s=n.node.body.findIndex(c=>!e.isImportDeclaration(c)),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&&f(n.node.init,e)&&t.rootVars.add(n.node.id.name)},CallExpression(n,t){if(t.fileIgnored)return;const i=n.node.callee;if(t.opts.autoWrapHooks!==!1&&e.isIdentifier(i)&&b[i.name]){const r=b[i.name],l=`${t.relativePath??"(anon)"}:${n.node.loc?.start.line??0}:${t.hookIndex++}`;n.node.callee=e.identifier(r),n.node.arguments.unshift(e.stringLiteral(l)),t.needHelpers.add(r);return}if(t.opts.autoWrapRoot!==!1&&e.isMemberExpression(i)&&e.isIdentifier(i.property,{name:"render"})&&(f(i.object,e)||e.isIdentifier(i.object)&&t.rootVars?.has(i.object.name))&&n.node.arguments.length>=1){const r=n.node.arguments[0];r&&!I(r,e)&&(n.node.arguments[0]=e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("LensmcpRoot"),[],!1),e.jsxClosingElement(e.jsxIdentifier("LensmcpRoot")),[e.jsxExpressionContainer(r)],!1),t.needRoot=!0)}},JSXOpeningElement(n,t){if(t.fileIgnored)return;const i=n.node.attributes;if(m(i,"data-agent-component")||m(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 c of n.node.attributes){if(c.type!=="JSXAttribute"||c.name.type!=="JSXIdentifier"||!t.flowEvents.has(c.name.name)||!c.value||c.value.type!=="JSXExpressionContainer")continue;const u=c.value.expression;if(u.type==="JSXEmptyExpression"||y(u,e))continue;const g=c.name.name;c.value.expression=e.callExpression(e.identifier("withFlow"),[u,e.objectExpression([e.objectProperty(e.identifier("originType"),e.stringLiteral(R[g]??"user-click")),e.objectProperty(e.identifier("originNodeId"),e.stringLiteral(`ui:${p}:${s}:${g}`))])]),t.needHelpers.add("withFlow")}}const r=E(n.node.name);if(!r||S(r))return;const l=[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)";l.push(e.jsxAttribute(e.jsxIdentifier("data-agent-source"),e.stringLiteral(`${p}:${s}`)))}n.node.attributes.push(...l)}}}}a(w,"y"),d(w,"lensmcpBabelPlugin");function m(o,e){return o.some(n=>n.type==="JSXAttribute"&&n.name.type==="JSXIdentifier"&&n.name.name===e)}a(m,"S"),d(m,"hasAttr");function x(o,e,n){const t=new Set;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.add(r.imported.name);return t}a(x,"h"),d(x,"collectImported");function f(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}a(f,"b"),d(f,"isRootFactoryCall");function y(o,e){return e.isCallExpression(o)&&e.isIdentifier(o.callee,{name:"withFlow"})}a(y,"C"),d(y,"isAlreadyWithFlow");function I(o,e){return e.isJSXElement(o)&&e.isJSXIdentifier(o.openingElement.name,{name:"LensmcpRoot"})}a(I,"j"),d(I,"isAlreadyLensmcpRoot");const J=new Set(["Fragment","StrictMode","Suspense","SuspenseList","Profiler"]);function S(o){const e=o.split(".").pop()??o;return J.has(e)?!0:e.endsWith("Provider")||e.endsWith("Consumer")}a(S,"P"),d(S,"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}}a(E,"A"),d(E,"describeElementName");
@@ -1 +1 @@
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");
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");
package/lib/context.js CHANGED
@@ -1 +1 @@
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
+ "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 +1 @@
1
- "use strict";var C=Object.defineProperty;var a=(t,e)=>C(t,"name",{value:e,configurable:!0});var D=Object.defineProperty,d=a((t,e)=>D(t,"name",{value:e,configurable:!0}),"a"),S=Object.defineProperty,l=d((t,e)=>S(t,"name",{value:e,configurable:!0}),"c");import{makeInstanceId as v}from"./identity.js";import{publish as I}from"./publish.js";const T=1,_=0,L=1,O=11,j=14,x=15,A=15e3,k=25,M=15,z=8,E=(typeof process<"u"?process.env?.LENSMCP_RENDER_INCLUDE_INTERNALS:void 0)==="1",G=new Set(["Insertion","EmotionGlobal","EmotionCssPropInternal","GlobalStyles","ThemeProvider","CacheProvider"]);function b(t){return!!(G.has(t)||t.startsWith("Styled(")&&/^Styled\([a-z][a-zA-Z0-9-]*\)$/.test(t)||t==="lensmcp-root"||t.startsWith("Lensmcp"))}a(b,"I"),d(b,"b"),l(b,"isInternalRender");let g=!1,h=!1;function w(t){const e=t.type;if(!(e==null||typeof e=="string"))switch(t.tag){case _:case L:return e.displayName||e.name||void 0;case O:return e.displayName||e.render?.displayName||e.render?.name||void 0;case j:case x:return e.displayName||e.type?.displayName||e.type?.name||e.name||void 0;default:return}}a(w,"R"),d(w,"O"),l(w,"componentNameOf");function N(t){const e=t.alternate?.memoizedProps,n=t.memoizedProps;if(!e||!n||e===n)return[];const o=[];for(const r of Object.keys(n))if(r!=="children"&&!Object.is(e[r],n[r])&&(o.push(r),o.length>=z))break;return o}a(N,"$"),d(N,"$"),l(N,"changedPropKeys");const y=new WeakMap;function R(t,e){const n=y.get(t);if(n)return n;const o=t.alternate,r=(o?y.get(o):void 0)??v(e).instanceId;return y.set(t,r),o&&y.set(o,r),r}a(R,"P"),d(R,"v"),l(R,"stableInstanceId");function P(t){const e=[];let n=0;const o=[];for(t.current.child&&o.push({node:t.current.child,parentName:void 0});o.length>0;){const{node:r,parentName:i}=o.pop();if(n+=1,n>A)break;let u=i;const c=w(r),m=(r.flags&T)!==0;if(c&&m){const p=r.alternate==null,s=[];if(!p){const f=N(r);f.length>0&&s.push({type:"props",changedKeys:f}),i&&s.push({type:"parent-render",parentRenderId:i}),s.length===0&&s.push({type:"react-state",hookIndex:-1})}e.push({name:c,instanceId:R(r,`react:component:(fiber):${c}`),phase:p?"mount":"update",durationMs:typeof r.actualDuration=="number"?r.actualDuration:0,why:s,parentName:i}),u=c}r.sibling&&o.push({node:r.sibling,parentName:i}),r.child&&o.push({node:r.child,parentName:u})}return e}a(P,"k"),d(P,"L"),l(P,"collectCommitRenders");let F;export function activeCommitId(){return F}a(activeCommitId,"activeCommitId"),d(activeCommitId,"activeCommitId"),l(activeCommitId,"activeCommitId");export function fiberRendersActive(){return g&&!h}a(fiberRendersActive,"fiberRendersActive"),d(fiberRendersActive,"fiberRendersActive"),l(fiberRendersActive,"fiberRendersActive");function $(t,e){const n=E?t:t.filter(i=>!b(i.name));if(n.length===0)return;const o=v("react:commit").instanceId;F=o;const r=n.length>k?[...n].sort((i,u)=>u.durationMs-i.durationMs).slice(0,k):n;for(const i of r){const u=`react:component:(fiber):${i.name}`,{instanceId:c}=v(u),m={id:c,commitId:o,componentInstanceId:i.instanceId,componentLogicalId:u,componentName:i.name,rendererId:"fiber",phase:i.phase,actualDurationMs:i.durationMs,baseDurationMs:i.durationMs,startTime:e,commitTime:e,why:i.why};I({source:"react",category:"render",severity:"info",title:`render ${i.name} (${i.phase})`,fingerprint:`react-render:${u}`,raw:{kind:"render",render:m}})}n.length>r.length&&I({source:"react",category:"render",severity:"debug",title:`render commit truncated: ${n.length-r.length} of ${n.length} renders dropped (per-commit cap)`,fingerprint:"react-render:commit-truncated",raw:{kind:"render-commit-truncated",commitId:o,total:n.length,published:r.length}})}a($,"E"),d($,"G"),l($,"publishRecords");export function installFiberRenderPublisher(){if(g||h||typeof window>"u")return;const t=window.__LENSMCP_FIBER__;if(!t||typeof t.subscribe!="function")return;g=!0;let e=M,n=0;const o=new Map;let r=0,i;const u=l(()=>{if(i=void 0,e=M,n===0)return;const c=[...o.entries()].sort((s,f)=>f[1]-s[1]).slice(0,5),m=c.length>0?`top: ${c.map(([s,f])=>`${s}\xD7${f}`).join(", ")}`:"no product component in the commits \u2014 all framework-internal",p=r>0?` (+${r} framework-internal)`:"";I({source:"react",category:"render",severity:"warning",title:`render storm: ${n} commits/s over budget \u2014 ${m}${p}`,fingerprint:"react-render:storm",raw:{kind:"render-storm",commits:n,components:Object.fromEntries(c),internalRenders:r}}),n=0,r=0,o.clear()},"flushStorm");t.subscribe((c,m)=>{if(!h)try{if(!m||!m.current)return;const p=P(m);if(p.length===0)return;if(e>0)e-=1,$(p,Date.now());else{n+=1;for(const s of p){if(!E&&b(s.name)){r+=1;continue}o.set(s.name,(o.get(s.name)??0)+1)}}i||(i=setTimeout(u,1e3))}catch{h=!0}})}a(installFiberRenderPublisher,"installFiberRenderPublisher"),d(installFiberRenderPublisher,"installFiberRenderPublisher"),l(installFiberRenderPublisher,"installFiberRenderPublisher");export function resetFiberRenderPublisherForTests(){g=!1,h=!1}a(resetFiberRenderPublisherForTests,"resetFiberRenderPublisherForTests"),d(resetFiberRenderPublisherForTests,"resetFiberRenderPublisherForTests"),l(resetFiberRenderPublisherForTests,"resetFiberRenderPublisherForTests");
1
+ "use strict";var C=Object.defineProperty;var a=(n,e)=>C(n,"name",{value:e,configurable:!0});var D=Object.defineProperty,d=a((n,e)=>D(n,"name",{value:e,configurable:!0}),"c");import{makeInstanceId as g}from"./identity.js";import{publish as y}from"./publish.js";const S=1,_=0,T=1,F=11,L=14,x=15,O=15e3,v=25,w=15,j=8,N=(typeof process<"u"?process.env?.LENSMCP_RENDER_INCLUDE_INTERNALS:void 0)==="1",A=new Set(["Insertion","EmotionGlobal","EmotionCssPropInternal","GlobalStyles","ThemeProvider","CacheProvider"]);function I(n){return!!(A.has(n)||n.startsWith("Styled(")&&/^Styled\([a-z][a-zA-Z0-9-]*\)$/.test(n)||n==="lensmcp-root"||n.startsWith("Lensmcp"))}a(I,"b"),d(I,"isInternalRender");let h=!1,f=!1;function R(n){const e=n.type;if(!(e==null||typeof e=="string"))switch(n.tag){case _:case T:return e.displayName||e.name||void 0;case F:return e.displayName||e.render?.displayName||e.render?.name||void 0;case L:case x:return e.displayName||e.type?.displayName||e.type?.name||e.name||void 0;default:return}}a(R,"O"),d(R,"componentNameOf");function $(n){const e=n.alternate?.memoizedProps,r=n.memoizedProps;if(!e||!r||e===r)return[];const o=[];for(const t of Object.keys(r))if(t!=="children"&&!Object.is(e[t],r[t])&&(o.push(t),o.length>=j))break;return o}a($,"$"),d($,"changedPropKeys");const b=new WeakMap;function P(n,e){const r=b.get(n);if(r)return r;const o=n.alternate,t=(o?b.get(o):void 0)??g(e).instanceId;return b.set(n,t),o&&b.set(o,t),t}a(P,"v"),d(P,"stableInstanceId");function k(n){const e=[];let r=0;const o=[];for(n.current.child&&o.push({node:n.current.child,parentName:void 0});o.length>0;){const{node:t,parentName:i}=o.pop();if(r+=1,r>O)break;let l=i;const c=R(t),m=(t.flags&S)!==0;if(c&&m){const u=t.alternate==null,s=[];if(!u){const p=$(t);p.length>0&&s.push({type:"props",changedKeys:p}),i&&s.push({type:"parent-render",parentRenderId:i}),s.length===0&&s.push({type:"react-state",hookIndex:-1})}e.push({name:c,instanceId:P(t,`react:component:(fiber):${c}`),phase:u?"mount":"update",durationMs:typeof t.actualDuration=="number"?t.actualDuration:0,why:s,parentName:i}),l=c}t.sibling&&o.push({node:t.sibling,parentName:i}),t.child&&o.push({node:t.child,parentName:l})}return e}a(k,"L"),d(k,"collectCommitRenders");let M;export function activeCommitId(){return M}a(activeCommitId,"activeCommitId"),d(activeCommitId,"activeCommitId");export function fiberRendersActive(){return h&&!f}a(fiberRendersActive,"fiberRendersActive"),d(fiberRendersActive,"fiberRendersActive");function E(n,e){const r=N?n:n.filter(i=>!I(i.name));if(r.length===0)return;const o=g("react:commit").instanceId;M=o;const t=r.length>v?[...r].sort((i,l)=>l.durationMs-i.durationMs).slice(0,v):r;for(const i of t){const l=`react:component:(fiber):${i.name}`,{instanceId:c}=g(l),m={id:c,commitId:o,componentInstanceId:i.instanceId,componentLogicalId:l,componentName:i.name,rendererId:"fiber",phase:i.phase,actualDurationMs:i.durationMs,baseDurationMs:i.durationMs,startTime:e,commitTime:e,why:i.why};y({source:"react",category:"render",severity:"info",title:`render ${i.name} (${i.phase})`,fingerprint:`react-render:${l}`,raw:{kind:"render",render:m}})}r.length>t.length&&y({source:"react",category:"render",severity:"debug",title:`render commit truncated: ${r.length-t.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:t.length}})}a(E,"G"),d(E,"publishRecords");export function installFiberRenderPublisher(){if(h||f||typeof window>"u")return;const n=window.__LENSMCP_FIBER__;if(!n||typeof n.subscribe!="function")return;h=!0;let e=w,r=0;const o=new Map;let t=0,i;const l=d(()=>{if(i=void 0,e=w,r===0)return;const c=[...o.entries()].sort((s,p)=>p[1]-s[1]).slice(0,5),m=c.length>0?`top: ${c.map(([s,p])=>`${s}\xD7${p}`).join(", ")}`:"no product component in the commits \u2014 all framework-internal",u=t>0?` (+${t} framework-internal)`:"";y({source:"react",category:"render",severity:"warning",title:`render storm: ${r} commits/s over budget \u2014 ${m}${u}`,fingerprint:"react-render:storm",raw:{kind:"render-storm",commits:r,components:Object.fromEntries(c),internalRenders:t}}),r=0,t=0,o.clear()},"flushStorm");n.subscribe((c,m)=>{if(!f)try{if(!m||!m.current)return;const u=k(m);if(u.length===0)return;if(e>0)e-=1,E(u,Date.now());else{r+=1;for(const s of u){if(!N&&I(s.name)){t+=1;continue}o.set(s.name,(o.get(s.name)??0)+1)}}i||(i=setTimeout(l,1e3))}catch{f=!0}})}a(installFiberRenderPublisher,"installFiberRenderPublisher"),d(installFiberRenderPublisher,"installFiberRenderPublisher");export function resetFiberRenderPublisherForTests(){h=!1,f=!1}a(resetFiberRenderPublisherForTests,"resetFiberRenderPublisherForTests"),d(resetFiberRenderPublisherForTests,"resetFiberRenderPublisherForTests");
package/lib/flow-fetch.js CHANGED
@@ -1 +1 @@
1
- "use strict";var N=Object.defineProperty;var c=(e,t)=>N(e,"name",{value:t,configurable:!0});var P=Object.defineProperty,l=c((e,t)=>P(e,"name",{value:t,configurable:!0}),"c"),R=Object.defineProperty,u=l((e,t)=>R(e,"name",{value:t,configurable:!0}),"f");import{beginBackgroundFlow as S,extendFlowWindow as L,flowForNewActivity as H,publish as m}from"./publish.js";import{installRouteFlows as q}from"./route-flows.js";export function mayPropagateTo(e,t=[]){const h=typeof location<"u"?location.href:void 0;let f;try{f=new URL(e,h)}catch{return!1}if(typeof location<"u"&&f.origin===location.origin||T(f.hostname))return!0;for(const n of t){let r;try{r=new URL(n).origin}catch{continue}if(r===f.origin)return!0}return!1}c(mayPropagateTo,"mayPropagateTo"),l(mayPropagateTo,"mayPropagateTo"),u(mayPropagateTo,"mayPropagateTo");const A=new Set(["localhost","[::1]","::1"]);function T(e){const t=e.toLowerCase();return A.has(t)||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}c(T,"I"),l(T,"S"),u(T,"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($,"x"),l($,"N"),u($,"globalPropagateList");function b(){return Date.now().toString(36)+Math.random().toString(36).slice(2,12)}c(b,"F"),l(b,"O"),u(b,"newRequestId");function w(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url??String(e)}c(w,"w"),l(w,"$"),u(w,"urlOf");let _=!1;export function installFlowFetch(e={}){const t=globalThis;if(typeof t.fetch!="function")return()=>{};!_&&typeof location<"u"&&typeof document<"u"&&(_=!0,S({originType:"page-load",originNodeId:`page:${location.pathname}`}));const h=e.flowHeader??"x-lensmcp-flow-id",f=e.originHeader??"x-lensmcp-origin-node-id",n=e.requestHeader??"x-request-id",r=e.propagateTo??[],a=t.fetch.bind(globalThis);globalThis.__LENSMCP_FLOW_FETCH__=!0;const s=u(((i,o)=>{const p=H();if(!p?.flowId)return a(i,o);if(!mayPropagateTo(w(i),[...r,...$()])){const x=a(i,o);return y(p,i,o,x,void 0),x}const k=typeof i=="object"&&i!==null&&"headers"in i?i.headers:void 0,d=new Headers(o?.headers??k??void 0);d.has(h)||d.set(h,p.flowId),p.originNodeId&&!d.has(f)&&d.set(f,p.originNodeId);const I=d.get(n)??b();d.has(n)||d.set(n,I);const v=a(i,{...o,headers:d});return y(p,i,o,v,I),v}),"patched");t.fetch=s;const g=e.routeFlows===!1?()=>{}:q();return()=>{g(),t.fetch=a}}c(installFlowFetch,"installFlowFetch"),l(installFlowFetch,"installFlowFetch"),u(installFlowFetch,"installFlowFetch");function F(e){const t=typeof location<"u"?location.href:void 0;try{return new URL(e,t).href}catch{return}}c(F,"_"),l(F,"R"),u(F,"absoluteHref");function y(e,t,h,f,n){const r=w(t),a=F(r),s=h?.method??(typeof t=="object"&&t!==null&&"method"in t?t.method??"GET":"GET"),g=Date.now(),i={flowId:e.flowId,...e.originType?{originType:e.originType}:{},...e.originNodeId?{originNodeId:e.originNodeId}:{},...n?{requestId:n}:{}};m({source:"react",category:"network",severity:"info",title:`fetch ${s} ${r}`,fingerprint:`flow-fetch:${s}:${r}`,context:i,raw:{kind:"fetch-start",url:r,method:s,...a?{href:a}:{},...n?{requestId:n}:{}}}),f.then(o=>{L(e),m({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:i,raw:{kind:"fetch-done",url:r,...a?{href:a}:{},...n?{requestId:n}:{},method:s,status:o.status,statusText:o.statusText,ok:o.ok,startedAt:g,durationMs:Date.now()-g}})},o=>{L(e),m({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:i,raw:{kind:"fetch-error",url:r,...a?{href:a}:{},...n?{requestId:n}:{},method:s,startedAt:g,durationMs:Date.now()-g}})})}c(y,"y"),l(y,"b"),u(y,"publishFetchLeg");
1
+ "use strict";var v=Object.defineProperty;var c=(t,e)=>v(t,"name",{value:e,configurable:!0});var N=Object.defineProperty,l=c((t,e)=>N(t,"name",{value:e,configurable:!0}),"f");import{beginBackgroundFlow as H,extendFlowWindow as b,flowForNewActivity as P,publish as p}from"./publish.js";import{installRouteFlows as R}from"./route-flows.js";export function mayPropagateTo(t,e=[]){const d=typeof location<"u"?location.href:void 0;let f;try{f=new URL(t,d)}catch{return!1}if(typeof location<"u"&&f.origin===location.origin||I(f.hostname))return!0;for(const n of e){let r;try{r=new URL(n).origin}catch{continue}if(r===f.origin)return!0}return!1}c(mayPropagateTo,"mayPropagateTo"),l(mayPropagateTo,"mayPropagateTo");const S=new Set(["localhost","[::1]","::1"]);function I(t){const e=t.toLowerCase();return S.has(e)||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(e)}c(I,"S"),l(I,"isLoopbackHost");function x(){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(x,"N"),l(x,"globalPropagateList");function F(){return Date.now().toString(36)+Math.random().toString(36).slice(2,12)}c(F,"O"),l(F,"newRequestId");function w(t){return typeof t=="string"?t:t instanceof URL?t.href:t.url??String(t)}c(w,"$"),l(w,"urlOf");let L=!1;export function installFlowFetch(t={}){const e=globalThis;if(typeof e.fetch!="function")return()=>{};!L&&typeof location<"u"&&typeof document<"u"&&(L=!0,H({originType:"page-load",originNodeId:`page:${location.pathname}`}));const d=t.flowHeader??"x-lensmcp-flow-id",f=t.originHeader??"x-lensmcp-origin-node-id",n=t.requestHeader??"x-request-id",r=t.propagateTo??[],s=e.fetch.bind(globalThis);globalThis.__LENSMCP_FLOW_FETCH__=!0;const a=l(((i,o)=>{const g=P();if(!g?.flowId)return s(i,o);if(!mayPropagateTo(w(i),[...r,...x()])){const $=s(i,o);return y(g,i,o,$,void 0),$}const k=typeof i=="object"&&i!==null&&"headers"in i?i.headers:void 0,u=new Headers(o?.headers??k??void 0);u.has(d)||u.set(d,g.flowId),g.originNodeId&&!u.has(f)&&u.set(f,g.originNodeId);const m=u.get(n)??F();u.has(n)||u.set(n,m);const T=s(i,{...o,headers:u});return y(g,i,o,T,m),T}),"patched");e.fetch=a;const h=t.routeFlows===!1?()=>{}:R();return()=>{h(),e.fetch=s}}c(installFlowFetch,"installFlowFetch"),l(installFlowFetch,"installFlowFetch");function _(t){const e=typeof location<"u"?location.href:void 0;try{return new URL(t,e).href}catch{return}}c(_,"R"),l(_,"absoluteHref");function y(t,e,d,f,n){const r=w(e),s=_(r),a=d?.method??(typeof e=="object"&&e!==null&&"method"in e?e.method??"GET":"GET"),h=Date.now(),i={flowId:t.flowId,...t.originType?{originType:t.originType}:{},...t.originNodeId?{originNodeId:t.originNodeId}:{},...n?{requestId:n}:{}};p({source:"react",category:"network",severity:"info",title:`fetch ${a} ${r}`,fingerprint:`flow-fetch:${a}:${r}`,context:i,raw:{kind:"fetch-start",url:r,method:a,...s?{href:s}:{},...n?{requestId:n}:{}}}),f.then(o=>{b(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:i,raw:{kind:"fetch-done",url:r,...s?{href:s}:{},...n?{requestId:n}:{},method:a,status:o.status,statusText:o.statusText,ok:o.ok,startedAt:h,durationMs:Date.now()-h}})},o=>{b(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:i,raw:{kind:"fetch-error",url:r,...s?{href:s}:{},...n?{requestId:n}:{},method:a,startedAt:h,durationMs:Date.now()-h}})})}c(y,"b"),l(y,"publishFetchLeg");
package/lib/hoc.js CHANGED
@@ -1 +1 @@
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");
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");
package/lib/identity.js CHANGED
@@ -1 +1 @@
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
+ "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 +1 @@
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");
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");
package/lib/publish.js CHANGED
@@ -1 +1 @@
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
+ "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 +1 @@
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");
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");
package/lib/trace-slot.js CHANGED
@@ -1 +1 @@
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
+ "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 +1 @@
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");
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");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/react-instrumentation",
3
- "version": "1.23.10",
3
+ "version": "1.23.11",
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.23.10",
22
+ "@lensmcp/protocol-types": "1.23.11",
23
23
  "tslib": "^2.3.0"
24
24
  },
25
25
  "peerDependencies": {