@lensmcp/client-runtime 1.25.11 → 1.25.12
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 +1 -1
- package/lib/install.js +1 -1
- package/package.json +1 -1
package/lib/auto.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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");
|
package/lib/install.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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");
|