@lensmcp/client-runtime 1.25.16 → 1.25.17

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