@lensmcp/react-instrumentation 1.18.7 → 1.18.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/identity.d.ts CHANGED
@@ -16,6 +16,15 @@ export declare function makeInstanceId(logicalId: string): {
16
16
  * Cheap deterministic hash over an array of dependency values. Used by
17
17
  * the traced hooks to compute `depsHash` so the reducer can decide
18
18
  * whether a hook re-ran because of a dep change.
19
+ *
20
+ * IDENTITY semantics, deliberately: objects and functions hash by a stable
21
+ * per-reference id (a WeakMap registry), primitives by value — which is
22
+ * exactly how React itself compares deps (`Object.is` per slot). The old
23
+ * value hash (`JSON.stringify` per object dep, `fn.toString()` per function
24
+ * dep, per hook, per render) was BOTH the profiler's top self-time in commit
25
+ * storms AND less truthful: a re-created dep with equal content hashed
26
+ * "unchanged", hiding precisely the referential instability that makes a
27
+ * hook re-run — the thing this field exists to expose.
19
28
  */
20
29
  export declare function depsHash(deps: readonly unknown[] | undefined): string;
21
30
  /** Test hook to reset generation counters between smoke iterations. */
package/lib/identity.js CHANGED
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var e=(t,n)=>f(t,"name",{value:n,configurable:!0});var l=Object.defineProperty,o=e((t,n)=>l(t,"name",{value:n,configurable:!0}),"e");const u=new Map;let c=0;export function nextGeneration(t){const n=(u.get(t)??0)+1;return u.set(t,n),n}e(nextGeneration,"nextGeneration"),o(nextGeneration,"nextGeneration");export function shortHash(){return c=(c+1)%4294967295,(Date.now()&4095^c).toString(36).slice(-4)}e(shortHash,"shortHash"),o(shortHash,"shortHash");export function componentLogicalId(t,n){return`react:component:${t}:${n}`}e(componentLogicalId,"componentLogicalId"),o(componentLogicalId,"componentLogicalId");export function hookLogicalId(t,n,r,i){return`react:hook:${t}:${n}:${r}:${i}`}e(hookLogicalId,"hookLogicalId"),o(hookLogicalId,"hookLogicalId");export function slotLogicalId(t,n,r){return`react:slot:${t}:${n}:${r}`}e(slotLogicalId,"slotLogicalId"),o(slotLogicalId,"slotLogicalId");export function makeInstanceId(t){const n=nextGeneration(t);return{instanceId:`${t}#${n}#${shortHash()}`,generation:n}}e(makeInstanceId,"makeInstanceId"),o(makeInstanceId,"makeInstanceId");export function depsHash(t){if(!t)return"no-deps";let n=5381;for(const r of t){const i=s(r);for(let a=0;a<i.length;a++)n=n*33^i.charCodeAt(a)}return(n>>>0).toString(36)}e(depsHash,"depsHash"),o(depsHash,"depsHash");function s(t){if(t===null)return"null";if(t===void 0)return"undefined";const n=typeof t;if(n==="string"||n==="number"||n==="boolean"||n==="bigint")return`${n}:${String(t)}`;if(n==="function")return`fn:${t.name??"anonymous"}:${t.toString().length}`;try{return`obj:${JSON.stringify(t)}`}catch{return"obj:circular"}}e(s,"a"),o(s,"canonical");export function resetIdentityState(){u.clear(),c=0}e(resetIdentityState,"resetIdentityState"),o(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");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/react-instrumentation",
3
- "version": "1.18.7",
3
+ "version": "1.18.8",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -19,7 +19,7 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@lensmcp/protocol-types": "1.18.7",
22
+ "@lensmcp/protocol-types": "1.18.8",
23
23
  "tslib": "^2.3.0"
24
24
  },
25
25
  "peerDependencies": {