@lensmcp/client-runtime 1.23.1 → 1.23.3

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.
Files changed (2) hide show
  1. package/lib/install.js +1 -1
  2. package/package.json +1 -1
package/lib/install.js CHANGED
@@ -1 +1 @@
1
- "use strict";var D=Object.defineProperty;var u=(n,o)=>D(n,"name",{value:o,configurable:!0});var O=Object.defineProperty,a=u((n,o)=>O(n,"name",{value:o,configurable:!0}),"c");const L="__LENSMCP_CLIENT__";export function installClientRuntime(n){if(typeof window>"u"||window[L])return;window[L]=!0;const o=n.wsUrl,y=n.reconnectIntervalMs??1e3;let i=null,p=!1;const f=[];let d=[],h=!1;const S=a(()=>{if(h=!1,!d.length)return;const t=d;if(d=[],i&&i.readyState===1)try{i.send(JSON.stringify(t.length===1?t[0]:{kind:"batch",at:Date.now(),events:t}));return}catch{}for(const e of t)f.push(e)},"flushBatch"),s=a(t=>{t.at=Date.now(),d.push(t),h||(h=!0,setTimeout(S,0))},"send");window.addEventListener("pagehide",S);const g=a(()=>{try{i=new WebSocket(o)}catch{setTimeout(g,y);return}i.addEventListener("open",()=>{for(p=!0;f.length;){const t=f.splice(0,200);try{i.send(JSON.stringify(t.length===1?t[0]:{kind:"batch",at:Date.now(),events:t}))}catch{}}s({kind:"ready",userAgent:navigator.userAgent,url:location.href})}),i.addEventListener("close",()=>{p&&setTimeout(g,y)}),i.addEventListener("error",()=>{})},"open");g(),window.__LENSMCP_PUBLISH__=t=>{s({kind:"publish",...t})},window.addEventListener("error",t=>{const e=t.target;if(e&&e!==window&&e.tagName&&!t.message){s({kind:"resource-error",tagName:e.tagName.toLowerCase(),url:e.currentSrc||e.src||e.href||void 0});return}const r=t.error;s({kind:"error",message:t.message,name:r?.name,stack:l(r?.stack),source:t.filename,lineno:t.lineno,colno:t.colno})},!0),window.addEventListener("unhandledrejection",t=>{const e=t.reason;s({kind:"unhandledrejection",reason:l(E(e)),name:typeof e=="object"&&e?e.name:void 0,stack:typeof e=="object"&&e?l(e.stack):void 0})});const _=["log","info","warn","error","debug"];for(const t of _){const e=console[t];console[t]=function(...r){try{s({kind:"console",level:t,args:r.map(N)})}catch{}e.apply(console,r)}}const T=window.fetch.bind(window);window.fetch=async function(t,e){const r=e?.method??(typeof t=="object"&&t&&"method"in t?t.method:"GET"),k=typeof t=="string"?t:t instanceof URL?t.toString():t.url,v=Date.now();try{const c=await T(t,e);return s({kind:"fetch",method:r,url:k,status:c.status,statusText:c.statusText,ok:c.ok,durationMs:Date.now()-v}),c}catch(c){const b=c;throw s({kind:"fetch",method:r,url:k,error:b.message??String(b),durationMs:Date.now()-v}),c}};const j=history.pushState.bind(history),C=history.replaceState.bind(history),w=a(t=>s({kind:"route",url:location.href,from:t}),"notify");history.pushState=function(...t){const e=location.href,r=j(...t);return w(e),r},history.replaceState=function(...t){const e=location.href,r=C(...t);return w(e),r},window.addEventListener("popstate",()=>w())}u(installClientRuntime,"installClientRuntime"),a(installClientRuntime,"installClientRuntime");const m=4096;function l(n){return n===void 0||n.length<=m?n:`${n.slice(0,m)}\u2026[lensmcp truncated: ${n.length-m} more chars]`}u(l,"w"),a(l,"clipStack");function E(n){if(n==null)return String(n);if(typeof n=="string")return n;if(typeof n.message=="string"&&n.message)return n.message;try{const o=JSON.stringify(n);if(o&&o!=="{}"&&o!=="null")return o}catch{}return String(n)}u(E,"j"),a(E,"describeReason");function N(n){if(n===null)return null;const o=typeof n;if(o==="string"||o==="number"||o==="boolean")return n;try{return JSON.parse(JSON.stringify(n))}catch{return String(n)}}u(N,"A"),a(N,"safe");
1
+ "use strict";var O=Object.defineProperty;var u=(t,o)=>O(t,"name",{value:o,configurable:!0});var T=Object.defineProperty,c=u((t,o)=>T(t,"name",{value:o,configurable:!0}),"l");const L="__LENSMCP_CLIENT__";export function installClientRuntime(t){if(typeof window>"u"||window[L])return;window[L]=!0;const o=t.wsUrl,S=t.reconnectIntervalMs??1e3;let a=null,k=!1;const g=[];let f=[],w=!1;const v=c(()=>{if(w=!1,!f.length)return;const n=f;if(f=[],a&&a.readyState===1)try{let e=0;for(;e<n.length;){const r=[];let d=0;for(;e<n.length&&r.length<200;){let i=JSON.stringify(n[e]);if(i.length>3e5&&(i=JSON.stringify({kind:"console",level:"warn",at:Date.now(),truncated:!0,args:[`[lensmcp] dropped an oversized ${String(n[e]?.kind)} event (${i.length} chars)`]})),r.length&&d+i.length>3e5)break;r.push(i),d+=i.length+1,e+=1}a.send(r.length===1?r[0]:`{"kind":"batch","at":${Date.now()},"events":[${r.join(",")}]}`)}return}catch{}for(const e of n)g.push(e)},"flushBatch"),s=c(n=>{n.at=Date.now(),f.push(n),w||(w=!0,setTimeout(v,0))},"send");window.addEventListener("pagehide",v);const p=c(()=>{try{a=new WebSocket(o)}catch{setTimeout(p,S);return}a.addEventListener("open",()=>{for(k=!0;g.length;){const n=g.splice(0,200);try{a.send(JSON.stringify(n.length===1?n[0]:{kind:"batch",at:Date.now(),events:n}))}catch{}}s({kind:"ready",userAgent:navigator.userAgent,url:location.href})}),a.addEventListener("close",()=>{k&&setTimeout(p,S)}),a.addEventListener("error",()=>{})},"open");p(),window.__LENSMCP_PUBLISH__=n=>{s({kind:"publish",...n})},window.addEventListener("error",n=>{const e=n.target;if(e&&e!==window&&e.tagName&&!n.message){s({kind:"resource-error",tagName:e.tagName.toLowerCase(),url:e.currentSrc||e.src||e.href||void 0});return}const r=n.error;s({kind:"error",message:n.message,name:r?.name,stack:h(r?.stack),source:n.filename,lineno:n.lineno,colno:n.colno})},!0),window.addEventListener("unhandledrejection",n=>{const e=n.reason;s({kind:"unhandledrejection",reason:h(N(e)),name:typeof e=="object"&&e?e.name:void 0,stack:typeof e=="object"&&e?h(e.stack):void 0})});const _=["log","info","warn","error","debug"];for(const n of _){const e=console[n];console[n]=function(...r){try{s({kind:"console",level:n,args:r.map(E)})}catch{}e.apply(console,r)}}const j=window.fetch.bind(window);window.fetch=async function(n,e){const r=e?.method??(typeof n=="object"&&n&&"method"in n?n.method:"GET"),d=typeof n=="string"?n:n instanceof URL?n.toString():n.url,i=Date.now();try{const l=await j(n,e);return s({kind:"fetch",method:r,url:d,status:l.status,statusText:l.statusText,ok:l.ok,durationMs:Date.now()-i}),l}catch(l){const b=l;throw s({kind:"fetch",method:r,url:d,error:b.message??String(b),durationMs:Date.now()-i}),l}};const C=history.pushState.bind(history),D=history.replaceState.bind(history),m=c(n=>s({kind:"route",url:location.href,from:n}),"notify");history.pushState=function(...n){const e=location.href,r=C(...n);return m(e),r},history.replaceState=function(...n){const e=location.href,r=D(...n);return m(e),r},window.addEventListener("popstate",()=>m())}u(installClientRuntime,"installClientRuntime"),c(installClientRuntime,"installClientRuntime");const y=4096;function h(t){return t===void 0||t.length<=y?t:`${t.slice(0,y)}\u2026[lensmcp truncated: ${t.length-y} more chars]`}u(h,"m"),c(h,"clipStack");function N(t){if(t==null)return String(t);if(typeof t=="string")return t;if(typeof t.message=="string"&&t.message)return t.message;try{const o=JSON.stringify(t);if(o&&o!=="{}"&&o!=="null")return o}catch{}return String(t)}u(N,"M"),c(N,"describeReason");function E(t){if(t===null)return null;const o=typeof t;if(o==="string"||o==="number"||o==="boolean")return t;try{return JSON.parse(JSON.stringify(t))}catch{return String(t)}}u(E,"C"),c(E,"safe");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/client-runtime",
3
- "version": "1.23.1",
3
+ "version": "1.23.3",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",