@lensmcp/client-runtime 1.25.76 → 1.25.78
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/lib/replay/anchors.js +1 -1
- package/lib/replay/blobs.js +1 -1
- package/lib/replay/recorder.js +1 -1
- package/lib/replay/start.js +1 -1
- package/lib/replay/target.js +1 -1
- package/lib/replay/uploader.js +1 -1
- package/package.json +2 -2
- package/replay-source.js +1 -1
- package/replay.bundle.js +4 -4
- package/replay.js +1 -1
package/lib/auto.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var _=Object.defineProperty;var r=(t,e)=>_(t,"name",{value:e,configurable:!0});var h=Object.defineProperty,s=r((t,e)=>h(t,"name",{value:e,configurable:!0}),"r");import{installClientRuntime as g}from"./install.js";const y=5747,w="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 o=i("lensmcp-ws");if(o)return o;const l=e.__LENSMCP_WS_PORT__,a=typeof l=="number"||typeof l=="string"?String(l):i("lensmcp-ws-port")??String(y),c=e.__LENSMCP_WS_HOST__;return`ws://${typeof c=="string"&&c.length>0?c:i("lensmcp-ws-host")??(typeof location<"u"&&location.hostname?location.hostname:w)}:${a}`}r(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:i("lensmcp-ws-token")}r(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);const o=typeof window.fetch=="function"?window.fetch.bind(window):void 0;g(e),replayWanted(t.replay)&&p(e.wsUrl,n,o)}r(installLensmcp,"installLensmcp"),s(installLensmcp,"installLensmcp");export function replayWanted(t){if(t===!1||globalThis.__LENSMCP_REPLAY__===!1)return!1;const e=i("lensmcp-replay")?.toLowerCase();return e!=="off"&&e!=="false"&&e!=="0"}r(replayWanted,"replayWanted"),s(replayWanted,"replayWanted");function p(t,e,n){const o=replayEndpoint(t,e);if(!o)return;const{endpoint:l,token:a}=o,c=n;import("../replay.js").then(({startReplay:f})=>f({endpoint:l,...a?{token:a}:{},tabId:u(),...c?{env:{fetch:s((m,d)=>c(m,d),"fetch")}}:{}})).catch(()=>{})}r(p,"m"),s(p,"startNoBuildReplay");export function replayEndpoint(t,e){try{const n=new URL(t),o=e??n.searchParams.get("token")??void 0;return{endpoint:`${n.protocol==="wss:"?"https:":"http:"}//${n.host}`,...o?{token:o}:{}}}catch{return}}r(replayEndpoint,"replayEndpoint"),s(replayEndpoint,"replayEndpoint");function u(){try{let t=sessionStorage.getItem("lensmcp:tabId");return t||(t=`tab-${Math.random().toString(36).slice(2,10)}`,sessionStorage.setItem("lensmcp:tabId",t)),t}catch{return`tab-${Math.random().toString(36).slice(2,10)}`}}r(u,"g"),s(u,"noBuildTabId");function i(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}}r(i,"i"),s(i,"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");
|
package/lib/replay/anchors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var s=(r,t)=>c(r,"name",{value:t,configurable:!0});var p=Object.defineProperty,n=s((r,t)=>p(r,"name",{value:t,configurable:!0}),"t");import{redactUrl as d}from"@lensmcp/core/redact";export const LENS_TAGS=["lens/session","lens/flow","lens/target","lens/request","lens/response","lens/visit","lens/nav","lens/hmr","lens/error","lens/gap","lens/stall"];const y=new Set(LENS_TAGS);export function isLensTag(r){return typeof r=="string"&&y.has(r)}s(isLensTag,"isLensTag"),n(isLensTag,"isLensTag");const a=512,v=20,g=3,I=new Set(["url","to","from"]);export function sanitizeAnchor(r,t){if(!(!isLensTag(r)||!t||typeof t!="object"||Array.isArray(t)))return o(t,0,void 0)}s(sanitizeAnchor,"sanitizeAnchor"),n(sanitizeAnchor,"sanitizeAnchor");function o(r,t,i){if(r===null||typeof r=="boolean")return r;if(typeof r=="number")return Number.isFinite(r)?r:void 0;if(typeof r=="string"){const e=i&&I.has(i)?d(r):r;return e.length>a?`${e.slice(0,a-1)}\u2026`:e}if(typeof r!="object"||t>=g)return;if(Array.isArray(r))return r.slice(0,v).map(e=>o(e,t+1,void 0));const l={};for(const[e,u]of Object.entries(r)){const f=o(u,t+1,e);f!==void 0&&(l[e]=f)}return l}s(o,"s"),n(o,"walk");export function anchorIds(r,t){return r==="lens/flow"&&typeof t.flowId=="string"?[`f:${t.flowId}`]:(r==="lens/request"||r==="lens/response")&&typeof t.requestId=="string"?[`r:${t.requestId}`]:r==="lens/visit"&&typeof t.visitId=="string"?[`v:${t.visitId}`]:[]}s(anchorIds,"anchorIds"),n(anchorIds,"anchorIds");
|
package/lib/replay/blobs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var S=Object.defineProperty;var c=(e,t)=>S(e,"name",{value:t,configurable:!0});var m=Object.defineProperty,h=c((e,t)=>m(e,"name",{value:t,configurable:!0}),"f");export const BLOB_PREFIX="\0lens-blob:";const O=2,v=3;export async function sha256Hex(e,t){const s=await e.digest("SHA-256",new TextEncoder().encode(t));let r="";for(const i of new Uint8Array(s))r+=i.toString(16).padStart(2,"0");return r}c(sha256Hex,"sha256Hex"),h(sha256Hex,"sha256Hex");export async function serializeChunk(e,t){const s=[],r=new Map;let i,n=0;for(const a of e){let o=t.perf();if(!t.subtle||a.type!==2&&a.type!==3){s.push(JSON.stringify(a)),n+=t.perf()-o;continue}if(a.type===2&&t.isBase(a)){const d=a.data,g=JSON.stringify(d.node);n+=t.perf()-o;const y=await sha256Hex(t.subtle,g);o=t.perf(),r.set(y,g),i=y,s.push(u(a,JSON.stringify({...d,node:BLOB_PREFIX+y}))),n+=t.perf()-o;continue}const p=JSON.stringify(a.data);if(p.length<t.blobMinChars){s.push(u(a,p)),n+=t.perf()-o;continue}n+=t.perf()-o;const l=await sha256Hex(t.subtle,p);o=t.perf(),r.set(l,p),s.push(u(a,JSON.stringify(BLOB_PREFIX+l))),n+=t.perf()-o}const f=t.perf(),b=`[${s.join(",")}]`;return n+=t.perf()-f,{json:b,blobs:r,...i?{base:i}:{},ms:n}}c(serializeChunk,"serializeChunk"),h(serializeChunk,"serializeChunk");function u(e,t){const s=e.delay;return`{"type":${e.type},"data":${t},"timestamp":${e.timestamp}${s!==void 0?`,"delay":${s}`:""}}`}c(u,"d"),h(u,"eventJson");export function rehydrate(e,t){if(typeof e=="string"){if(!e.startsWith(BLOB_PREFIX))return e;const s=t(e.slice(BLOB_PREFIX.length));return s===void 0?e:rehydrate(JSON.parse(s),t)}if(Array.isArray(e))return e.map(s=>rehydrate(s,t));if(e&&typeof e=="object"){const s={};for(const[r,i]of Object.entries(e))s[r]=rehydrate(i,t);return s}return e}c(rehydrate,"rehydrate"),h(rehydrate,"rehydrate");export class KnownHashes{static{c(this,"KnownHashes")}static{h(this,"KnownHashes")}constructor(t,s,r="lensmcp:replay:blobs"){this.max=t,this.storage=s,this.key=r,this.set=new Set;try{const i=s?.getItem(r),n=i?JSON.parse(i):[];if(Array.isArray(n))for(const f of n.slice(-t))typeof f=="string"&&/^[0-9a-f]{64}$/.test(f)&&this.set.add(f)}catch{}}has(t){return this.set.has(t)}add(t){for(this.set.delete(t),this.set.add(t);this.set.size>this.max;)this.set.delete(this.set.values().next().value);this.save()}forget(t){this.set.delete(t)&&this.save()}save(){try{this.storage?.setItem(this.key,JSON.stringify([...this.set]))}catch{}}}
|
package/lib/replay/recorder.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var a=(i,t)=>f(i,"name",{value:t,configurable:!0});var m=Object.defineProperty,r=a((i,t)=>m(i,"name",{value:t,configurable:!0}),"i");import{anchorIds as g,sanitizeAnchor as b}from"./anchors.js";import{KnownHashes as v,serializeChunk as y}from"./blobs.js";import{describeTarget as k}from"./target.js";import{gzip as S,Uploader as w}from"./uploader.js";import{DEFAULT_LIMITS as I,DEV_PRIVACY as C,REPLAY_WIRE_VERSION as M,RRWEB_VERSION as R}from"./types.js";const c=2,A=3,u=4,E=5,q=0;function l(i){if(i.type===c)return 64*1024;if(i.type===A){const t=i.data;if(t.source===q)return 64+160*(t.adds?.length??0)+60*(t.attributes?.length??0)+80*(t.texts?.length??0)+24*(t.removes?.length??0)}return 120}a(l,"E"),r(l,"estimateChars");const O=r(()=>`load-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,"newLoadId");export class ReplayRecorder{static{a(this,"ReplayRecorder")}static{r(this,"ReplayRecorder")}constructor(t,s){this.cfg=t,this.env=s,this.loadId=O(),this.state="idle",this.seq=0,this.buffer=[],this.bufferChars=0,this.bufferAnchors=[],this.awaitingCheckout=!1,this.checkoutPending=!1,this.processing=Promise.resolve(),this.costWindowStart=0,this.costSpent=0,this.overSeconds=0,this.limits={...I,...t.limits},this.privacy={...C,...t.privacy},this.record=t.record,this.uploader=new w({endpoint:t.endpoint.replace(/\/+$/,""),...t.token?{token:t.token}:{},tabId:t.tabId,loadId:this.loadId,...t.app?{app:t.app}:{},env:s,known:new v(this.limits.knownHashes,s.storage),retryMaxMs:this.limits.retryMaxMs,noChannelAfter:this.limits.noChannelAfter,beaconMaxBytes:this.limits.beaconMaxBytes,onOutcome:r((e,h)=>this.onOutcome(e,h),"onOutcome")})}get status(){return this.state}start(){this.state==="idle"&&(this.state="recording",this.costWindowStart=this.env.perf(),this.begin(),this.mark("lens/session",{tabId:this.cfg.tabId,loadId:this.loadId,...this.cfg.app?{app:this.cfg.app}:{},url:this.env.href(),wire:M,rrweb:R,viewport:this.env.viewport()}))}mark(t,s){if(t==="lens/nav"&&this.state==="paused"&&this.resume(),this.state!=="recording")return;const e=b(t,s);if(e)try{this.record.addCustomEvent(t,e)}catch{}}target(t,s){if(this.state!=="recording")return;const e=k(t,s,h=>this.record.mirror.getId(h));e&&this.mark("lens/target",e)}checkpoint(){this.state!=="recording"||this.checkoutPending||this.awaitingCheckout||(this.checkoutPending=!0,this.env.idle(()=>{this.checkoutPending=!1,this.checkoutNow()||this.env.idle(()=>this.checkoutNow())}))}pagehide(){if(this.state!=="recording"&&this.state!=="paused"||(this.timer!==void 0&&(this.env.clearTimeout(this.timer),this.timer=void 0),this.uploader.beaconQueued(),!this.buffer.length||this.awaitingCheckout))return;const t=this.buffer,s=this.takeSummary(t);try{this.uploader.beacon(s,JSON.stringify(t),"identity")}catch{}}stop(){this.state!=="stopped"&&(this.state==="recording"&&this.cut(),this.halt())}begin(){const t=this.privacy;try{this.stopRecord=this.record({emit:r(s=>this.onEmit(s),"emit"),checkoutEveryNms:this.limits.checkoutEveryMs,maskAllInputs:t.maskAllInputs,...t.maskAllInputs?{}:{maskInputOptions:{password:!1}},...t.maskTextSelector?{maskTextSelector:t.maskTextSelector}:{},...t.blockSelector?{blockSelector:t.blockSelector}:{},slimDOMOptions:"all",sampling:{mousemove:50,scroll:150,media:800,input:"last"},recordCanvas:!1,collectFonts:!1,errorHandler:r(()=>!0,"errorHandler")})}catch{this.halt()}}onEmit(t){if(this.state!=="recording"||this.awaitingCheckout)return;const s=this.env.perf();if(t.type===u&&this.buffer.length&&this.cut(),t.type===c&&!this.base&&(this.base=t),this.buffer.push(t),this.bufferChars+=l(t),t.type===E){const e=t.data;typeof e.tag=="string"&&e.payload&&typeof e.payload=="object"&&this.bufferAnchors.push(...g(e.tag,e.payload))}this.buffer.length>=this.limits.flushEvents||this.bufferChars>=this.limits.flushChars?this.cut():this.timer===void 0&&(this.timer=this.env.setTimeout(()=>{this.timer=void 0,this.cut()},this.limits.flushMs)),this.spend(this.env.perf()-s)}takeSummary(t){const s={seq:this.seq++,t0:t[0]?.timestamp??0,t1:t[t.length-1]?.timestamp??0,n:t.length,full:t[0]?.type===u&&t.some(e=>e.type===c),anchors:[...new Set(this.bufferAnchors)]};return this.buffer=[],this.bufferChars=0,this.bufferAnchors=[],s}cut(){if(this.timer!==void 0&&(this.env.clearTimeout(this.timer),this.timer=void 0),!this.buffer.length)return;const t=this.buffer,s=this.takeSummary(t);this.processing=this.processing.then(()=>this.prepare(s,t)).catch(()=>{})}async prepare(t,s){if(this.uploader.disabled||this.state==="stopped")return;const e=await y(s,{...this.env.subtle?{subtle:this.env.subtle}:{},blobMinChars:this.limits.blobMinChars,isBase:r(n=>n===this.base,"isBase"),perf:r(()=>this.env.perf(),"perf")});this.spend(e.ms);const h=await S(e.json),o=h??e.json;let d=typeof o=="string"?o.length:o.byteLength;for(const n of e.blobs.values())d+=n.length;const p={summary:e.base?{...t,base:e.base}:t,body:o,enc:h?"gzip":"identity",blobs:e.blobs,size:d};this.uploader.enqueue(p),this.uploader.pendingSize>this.limits.pendingChars&&this.gap("overflow")}onOutcome(t,s){if(s==="refused"){this.halt();return}if(s==="too-big"){this.gap("too-big",t.summary.seq);return}this.awaitingCheckout&&(this.awaitingCheckout=!1,this.checkoutNow())}gap(t,s){if(this.state!=="recording"||this.awaitingCheckout)return;const e=this.uploader.drop();this.buffer=[],this.bufferChars=0,this.bufferAnchors=[],this.mark("lens/gap",{fromSeq:s??e??this.seq,reason:t}),this.cut(),this.awaitingCheckout=!0,this.publish("replay-gap",`session replay lost a stretch of this page (${t})`,{reason:t,fromSeq:s??e??this.seq})}checkoutNow(){if(this.state!=="recording")return!0;const t=this.env.perf();try{return this.record.takeFullSnapshot(!0),!0}catch{return!1}finally{this.spend(this.env.perf()-t)}}spend(t){const s=this.env.perf();if(s-this.costWindowStart>=1e3&&(this.overSeconds=this.costSpent>this.limits.budgetMsPerSecond?this.overSeconds+1:0,this.costSpent=0,this.costWindowStart=s,this.overSeconds>=this.limits.budgetSeconds)){this.pause();return}this.costSpent+=t}pause(){if(this.state==="recording"){this.mark("lens/gap",{fromSeq:this.seq,reason:"budget"}),this.cut();try{this.stopRecord?.()}catch{}this.stopRecord=void 0,this.state="paused",this.overSeconds=0,this.publish("replay-paused",`session replay paused: its own work stayed over ${this.limits.budgetMsPerSecond} ms a second for ${this.limits.budgetSeconds} s`,{})}}resume(){this.state==="paused"&&(this.state="recording",this.costWindowStart=this.env.perf(),this.costSpent=0,this.begin())}halt(){this.state="stopped",this.timer!==void 0&&(this.env.clearTimeout(this.timer),this.timer=void 0);try{this.stopRecord?.()}catch{}this.stopRecord=void 0,this.uploader.drop(),this.buffer=[]}publish(t,s,e){try{this.env.publish?.({source:"client-runtime",category:"runtime",severity:"info",title:s,fingerprint:`replay:${t}:${this.loadId}`,raw:{kind:t,loadId:this.loadId,tabId:this.cfg.tabId,...e}})}catch{}}}
|
package/lib/replay/start.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var s=(
|
|
1
|
+
"use strict";var u=Object.defineProperty;var s=(a,e)=>u(a,"name",{value:e,configurable:!0});var p=Object.defineProperty,o=s((a,e)=>p(a,"name",{value:e,configurable:!0}),"n");import{ReplayRecorder as f}from"./recorder.js";export const REPLAY_HANDLE="__LENSMCP_REPLAY__";const d=["click","submit","change"];export function startReplay(a){if(typeof window>"u"||typeof document>"u")return;const e=globalThis;if(e[REPLAY_HANDLE]===!1)return;const c=e[REPLAY_HANDLE];if(c)return c;const r=new f(a,pageEnv(a.env)),i={loadId:r.loadId,mark:o((t,n)=>r.mark(t,n),"mark"),checkpoint:o(()=>r.checkpoint(),"checkpoint"),stop:o(()=>r.stop(),"stop")};e[REPLAY_HANDLE]=i,r.start();for(const t of d)document.addEventListener(t,n=>r.target(n.target,t),{capture:!0,passive:!0});return window.addEventListener("pagehide",()=>r.pagehide()),i}s(startReplay,"startReplay"),o(startReplay,"startReplay");export function pageEnv(a={}){const e=window;let c;try{c=e.localStorage}catch{}const r=e.isSecureContext&&e.crypto?.subtle?e.crypto.subtle:void 0,i=typeof e.fetch=="function"?e.fetch.bind(e):void 0;return{fetch:o((t,n)=>i?i(t,n):Promise.reject(new Error("no fetch")),"fetch"),...typeof navigator<"u"&&typeof navigator.sendBeacon=="function"?{sendBeacon:o((t,n)=>navigator.sendBeacon(t,n),"sendBeacon")}:{},now:o(()=>Date.now(),"now"),perf:o(()=>typeof performance<"u"?performance.now():Date.now(),"perf"),setTimeout:o((t,n)=>e.setTimeout(t,n),"setTimeout"),clearTimeout:o(t=>e.clearTimeout(t),"clearTimeout"),idle:o(t=>{typeof e.requestIdleCallback=="function"?e.requestIdleCallback(t,{timeout:2e3}):e.setTimeout(t,50)},"idle"),...c?{storage:c}:{},...r?{subtle:r}:{},href:o(()=>e.location.href,"href"),viewport:o(()=>({width:e.innerWidth,height:e.innerHeight}),"viewport"),publish:o(t=>{const n=e.__LENSMCP_PUBLISH__;typeof n=="function"&&n(t)},"publish"),...a}}s(pageEnv,"pageEnv"),o(pageEnv,"pageEnv");
|
package/lib/replay/target.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var x=Object.defineProperty;var r=(t,n)=>x(t,"name",{value:n,configurable:!0});var A=Object.defineProperty,s=r((t,n)=>A(t,"name",{value:n,configurable:!0}),"c");const T="a,button,input,select,textarea,label,summary,option,[role],[data-testid],[onclick],[tabindex]",k=80,N=s(t=>!!t&&typeof t.closest=="function"&&typeof t.getAttribute=="function"&&typeof t.tagName=="string","isElement");export function describeTarget(t,n,m){if(!N(t))return;const o=t.closest(T)??t,e=s(v=>o.getAttribute(v)??void 0,"attr"),c=(o.textContent??"").replace(/\s+/g," ").trim(),f=o.closest("[data-agent-source]"),y=o.closest("[data-agent-component]");let i=-1;try{i=m(o)}catch{}const a={kind:n,id:i,tag:o.tagName.toLowerCase()},l=e("role");l&&(a.role=l),c&&(a.text=c.length>80?`${c.slice(0,79)}\u2026`:c);const d=e("aria-label")??e("title")??e("placeholder")??e("name")??e("alt");d&&(a.label=d);const u=e("data-testid")??e("data-test")??e("data-cy");u&&(a.testId=u);const g=o.tagName==="INPUT"?e("type"):void 0;g&&(a.inputType=g);const p=f?.getAttribute("data-agent-source");p&&(a.source=p);const b=y?.getAttribute("data-agent-component");return b&&(a.component=b),a}r(describeTarget,"describeTarget"),s(describeTarget,"describeTarget");
|
package/lib/replay/uploader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var a=(n,t)=>d(n,"name",{value:t,configurable:!0});var y=Object.defineProperty,u=a((n,t)=>y(n,"name",{value:t,configurable:!0}),"a");import{REPLAY_WIRE_VERSION as b}from"./types.js";const g=4e3;export async function gzip(n){if(!(typeof CompressionStream!="function"||typeof Blob!="function"||typeof Response!="function"))try{const t=new Blob([n]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response(t).arrayBuffer())}catch{return}}a(gzip,"gzip"),u(gzip,"gzip");export class Uploader{static{a(this,"Uploader")}static{u(this,"Uploader")}constructor(t){this.o=t,this.queue=[],this.busy=!1,this.queued=0,this.answered=!1,this.networkFailures=0,this.disabled=!1}get pendingSize(){return this.queued}enqueue(t){this.disabled||(this.queue.push(t),this.queued+=t.size,this.pump())}drop(){const t=this.queue[0]?.summary.seq;for(const e of this.queue.splice(0))this.queued-=e.size;return t}beaconQueued(){for(const t of this.queue.splice(0))this.queued-=t.size,[...t.blobs.keys()].every(e=>this.o.known.has(e))&&this.beacon(t.summary,t.body,t.enc)}beacon(t,e,s){const i=this.o.env.sendBeacon,o=typeof e=="string"?e.length:e.byteLength;if(this.disabled||!i||o>this.o.beaconMaxBytes)return!1;try{return i(this.url("/replay",this.params(t,s,[])),new Blob([e],{type:"text/plain"}))}catch{return!1}}async pump(){if(!this.busy){this.busy=!0;try{for(;!this.disabled&&this.queue.length;){const t=this.queue.shift(),e=await this.send(t);this.queued-=t.size,e==="refused"&&(this.disabled=!0),this.o.onOutcome(t,e)}}finally{this.busy=!1}}}async send(t){for(let e=0;!this.disabled;e++){e>0&&await this.sleep(Math.min(this.o.retryMaxMs,500*2**(e-1)));try{for(const[o,r]of t.blobs){if(this.o.known.has(o))continue;const f=await gzip(r),h=await this.post("/replay/blob",{sha:o,enc:f?"gzip":"identity"},f??r);if(h.status>=200&&h.status<300){this.o.known.add(o);continue}const l=c(h.status);if(l)return l;throw new Error(`blob ${h.status}`)}const s=await this.post("/replay",this.params(t.summary,t.enc,[...t.blobs.keys()]),t.body);if(s.status>=200&&s.status<300)return this.answered=!0,"ok";if(s.status===409){const o=await p(s);for(const r of o.length?o:t.blobs.keys())this.o.known.forget(r);continue}const i=c(s.status);if(i)return i}catch{if(!this.answered&&++this.networkFailures>=this.o.noChannelAfter)return"refused"}}return"refused"}params(t,e,s){const i={v:String(b),load:this.o.loadId,tab:this.o.tabId,seq:String(t.seq),t0:String(t.t0),t1:String(t.t1),n:String(t.n),full:t.full?"1":"0",enc:e};if(this.o.app&&(i.app=this.o.app),t.base&&(i.base=t.base),t.anchors.length){let o="";for(const r of t.anchors){if(o.length+r.length+1>g){i.am="1";break}o+=(o?",":"")+r}i.a=o}return s.length&&(i.b=s.join(",")),i}url(t,e){const s=new URLSearchParams(this.o.token?{token:this.o.token,...e}:e);return`${this.o.endpoint}${t}?${s.toString()}`}async post(t,e,s){const i=await this.o.env.fetch(this.url(t,e),{method:"POST",headers:{"content-type":"text/plain"},body:s,credentials:"omit",keepalive:(typeof s=="string"?s.length:s.byteLength)<=this.o.beaconMaxBytes}),o=await i.text().catch(()=>"");return{status:i.status,text:u(async()=>o,"text")}}sleep(t){return new Promise(e=>this.o.env.setTimeout(e,t))}}function c(n){if(n===413)return"too-big";if(n===400||n===401||n===403||n===404||n===405||n===426)return"refused"}a(c,"c"),u(c,"verdictOf");async function p(n){try{const t=JSON.parse(await n.text());return Array.isArray(t.missing)?t.missing.filter(e=>typeof e=="string"):[]}catch{return[]}}a(p,"y"),u(p,"missingOf");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lensmcp/client-runtime",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.78",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@lensmcp/core": "1.25.
|
|
37
|
+
"@lensmcp/core": "1.25.78",
|
|
38
38
|
"@rrweb/record": "2.1.7",
|
|
39
39
|
"@rrweb/types": "2.1.7",
|
|
40
40
|
"tslib": "^2.3.0"
|