Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

imean-inspector-sdk

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imean-inspector-sdk - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

2

dist/sdk/lib/es/index.d.ts

@@ -31,5 +31,7 @@ import { EventCallback } from '@imean/event';

private metadata;
private scrollDirection;
version: string;
constructor(url: string, viewContainer: HTMLDivElement, disconnectDelay?: number);
static getModifiersForEvent(event: MouseEvent): number;
private detectScrollDirection;
private handleStartScreencast;

@@ -36,0 +38,0 @@ private canvasDrawImage;

114

dist/sdk/lib/es/index.js
var f = Object.defineProperty;
var g = (a, i, e) => i in a ? f(a, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[i] = e;
var n = (a, i, e) => g(a, typeof i != "symbol" ? i + "" : i, e);
var b = Object.defineProperty, E = (a, i, e) => i in a ? b(a, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[i] = e, k = (a, i, e) => (E(a, i + "", e), e), C = (a, i, e) => new Promise((s, t) => {
var E = Object.defineProperty, b = (a, i, e) => i in a ? E(a, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[i] = e, k = (a, i, e) => (b(a, i + "", e), e), C = (a, i, e) => new Promise((t, s) => {
var o = (r) => {
try {
c(e.next(r));
} catch (d) {
t(d);
} catch (h) {
s(h);
}
}, h = (r) => {
}, d = (r) => {
try {
c(e.throw(r));
} catch (d) {
t(d);
} catch (h) {
s(h);
}
}, c = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(o, h);
}, c = (r) => r.done ? t(r.value) : Promise.resolve(r.value).then(o, d);
c((e = e.apply(a, i)).next());

@@ -35,4 +35,4 @@ }), K = class w {

on(i, e) {
var s;
return this.callbackMap[i] || (this.callbackMap[i] = []), (s = this.callbackMap[i]) == null || s.push(e), e;
var t;
return this.callbackMap[i] || (this.callbackMap[i] = []), (t = this.callbackMap[i]) == null || t.push(e), e;
}

@@ -45,5 +45,5 @@ /**

off(i, e) {
var s;
this.callbackMap[i] && (this.callbackMap[i] = (s = this == null ? void 0 : this.callbackMap[i]) == null ? void 0 : s.filter(
(t) => t !== e
var t;
this.callbackMap[i] && (this.callbackMap[i] = (t = this == null ? void 0 : this.callbackMap[i]) == null ? void 0 : t.filter(
(s) => s !== e
));

@@ -57,6 +57,6 @@ }

once(i, e) {
const s = (...t) => {
this.off(i, s), e(...t);
const t = (...s) => {
this.off(i, t), e(...s);
};
return this.on(i, s);
return this.on(i, t);
}

@@ -72,4 +72,4 @@ /**

return;
const s = this.callbackMap[i];
s && (yield Promise.all(s.map((t) => t(...e))));
const t = this.callbackMap[i];
t && (yield Promise.all(t.map((s) => s(...e))));
});

@@ -80,8 +80,8 @@ }

let e;
return function(...s) {
clearTimeout(e), e = setTimeout(() => a.apply(this, s), i);
return function(...t) {
clearTimeout(e), e = setTimeout(() => a.apply(this, t), i);
};
}
class p extends K {
constructor(e, s, t) {
constructor(e, t, s) {
super();

@@ -98,3 +98,13 @@ n(this, "url");

n(this, "metadata", null);
n(this, "version", "1.2.1");
n(this, "scrollDirection", 1);
n(this, "version", "1.2.2");
n(this, "detectScrollDirection", () => {
const e = (t) => {
t.deltaY !== 0 && (this.scrollDirection = t.deltaY > 0 ? 1 : -1, window.removeEventListener("wheel", e));
};
window.addEventListener("wheel", e, {
passive: !0,
once: !0
});
});
n(this, "handleStartScreencast", () => {

@@ -107,5 +117,5 @@ const e = document.createElement("canvas");

if (!e || !this.metadata) return;
const { width: s, height: t } = this.viewContainer.getBoundingClientRect();
const { width: t, height: s } = this.viewContainer.getBoundingClientRect();
this.canvas.style.display = "inline";
const o = s || this.metadata.deviceWidth, h = t || this.metadata.deviceHeight, c = this.metadata.deviceWidth, r = this.metadata.deviceHeight, d = o / c, l = h / r, u = Math.min(d, l);
const o = t || this.metadata.deviceWidth, d = s || this.metadata.deviceHeight, c = this.metadata.deviceWidth, r = this.metadata.deviceHeight, h = o / c, l = d / r, u = Math.min(h, l);
this.zoom = u;

@@ -116,8 +126,8 @@ const v = c * u, y = r * u;

n(this, "handleScreencastFrame", (e) => {
const { data: s, metadata: t } = e;
this.metadata = t;
const { data: t, metadata: s } = e;
this.metadata = s;
try {
this.img.onload = () => {
this.canvasDrawImage(), this.emit("drawComplete", { status: !0 });
}, this.img.src = "data:image/jpeg;base64," + s;
}, this.img.src = "data:image/jpeg;base64," + t;
} catch {

@@ -128,3 +138,3 @@ this.emit("drawComplete", { status: !1 });

n(this, "emitMouse", (e) => {
const s = { 0: "none", 1: "left", 2: "middle", 3: "right" }, t = e.type === "mousewheel" && window.event || e, o = {
const t = { 0: "none", 1: "left", 2: "middle", 3: "right" }, s = e.type === "mousewheel" && window.event || e, o = {
mousedown: "mousePressed",

@@ -138,13 +148,13 @@ mouseup: "mouseReleased",

};
if (!(t.type in o) || t.type !== "mousewheel" && s[t.which] === "none" && t.type !== "mousemove")
if (!(s.type in o) || s.type !== "mousewheel" && t[s.which] === "none" && s.type !== "mousemove")
return;
const c = o[t.type].indexOf("wheel") !== -1, r = (c ? t.clientX : t.offsetX) * (1 / this.zoom), d = (c ? t.clientY : t.offsetY) * (1 / this.zoom), l = {
type: o[t.type],
const c = o[s.type].indexOf("wheel") !== -1, r = (c ? s.clientX : s.offsetX) * (1 / this.zoom), h = (c ? s.clientY : s.offsetY) * (1 / this.zoom), l = {
type: o[s.type],
x: r,
y: d,
modifiers: p.getModifiersForEvent(t),
button: t.type === "mousewheel" ? "none" : s[t.which],
y: h,
modifiers: p.getModifiersForEvent(s),
button: s.type === "mousewheel" ? "none" : t[s.which],
clickCount: 1
};
t.type === "mousewheel" && (l.deltaX = (t.wheelDeltaX || 0) * (1 / this.zoom), l.deltaY = (t.wheelDeltaY || t.wheelDelta) * (1 / this.zoom)), this.ws.send(
s.type === "mousewheel" && (l.deltaX = (s.deltaX || 0) * (1 / this.zoom) * this.scrollDirection, l.deltaY = (s.deltaY || s.wheelDelta || 0) * (1 / this.zoom) * this.scrollDirection), this.ws.send(
JSON.stringify({

@@ -158,12 +168,12 @@ id: ++this.messageId,

n(this, "emitKeyEvent", (e) => {
let s;
let t;
switch (e.keyCode === 8 && e.preventDefault(), e.type) {
case "keydown":
s = m.KeyDown;
t = m.KeyDown;
break;
case "keyup":
s = m.KeyUp;
t = m.KeyUp;
break;
case "keypress":
s = m.Char;
t = m.Char;
break;

@@ -173,6 +183,6 @@ default:

}
const t = s === "char" ? String.fromCharCode(e.charCode) : void 0, o = {
type: s,
text: t,
unmodifiedText: t ? t.toLowerCase() : void 0,
const s = t === "char" ? String.fromCharCode(e.charCode) : void 0, o = {
type: t,
text: s,
unmodifiedText: s ? s.toLowerCase() : void 0,
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -208,5 +218,5 @@ keyIdentifier: e.keyIdentifier,

n(this, "deleteCanvasElement", () => {
var s;
var t;
const e = document.querySelector("#inspectorSDK-canvas");
(s = e == null ? void 0 : e.parentElement) == null || s.removeChild(e);
(t = e == null ? void 0 : e.parentElement) == null || t.removeChild(e);
});

@@ -224,3 +234,3 @@ n(this, "onResizeViewContainer", () => {

});
n(this, "connect", (e = !1) => (this.ws = new WebSocket(this.url), new Promise((s, t) => {
n(this, "connect", (e = !1) => (this.ws = new WebSocket(this.url), new Promise((t, s) => {
this.ws.onopen = () => {

@@ -240,7 +250,7 @@ console.log("WebSocket connection opened"), this.ws.send(

this.handleVisibilityChange
), s();
), t();
}, this.ws.onmessage = (o) => {
const h = JSON.parse(o.data);
if (h.method === "Page.screencastFrame") {
const c = h.params;
const d = JSON.parse(o.data);
if (d.method === "Page.screencastFrame") {
const c = d.params;
this.handleScreencastFrame(c), this.ws.send(

@@ -251,3 +261,3 @@ JSON.stringify({

params: {
sessionId: h.params.sessionId
sessionId: d.params.sessionId
}

@@ -263,6 +273,6 @@ })

}, this.ws.onerror = (o) => {
console.error("WebSocket error:", o), t(o);
console.error("WebSocket error:", o), s(o);
};
})));
this.url = e, this.messageId = 0, this.viewContainer = s, this.disconnectTimeout = null, this.disconnectDelay = t ?? 6e4 * 5;
this.url = e, this.messageId = 0, this.viewContainer = t, this.disconnectTimeout = null, this.disconnectDelay = s ?? 6e4 * 5, this.detectScrollDirection();
}

@@ -269,0 +279,0 @@ static getModifiersForEvent(e) {

@@ -31,5 +31,7 @@ import { EventCallback } from '@imean/event';

private metadata;
private scrollDirection;
version: string;
constructor(url: string, viewContainer: HTMLDivElement, disconnectDelay?: number);
static getModifiersForEvent(event: MouseEvent): number;
private detectScrollDirection;
private handleStartScreencast;

@@ -36,0 +38,0 @@ private canvasDrawImage;

@@ -1,1 +0,1 @@

(function(r,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(r=typeof globalThis<"u"?globalThis:r||self,c(r.InspectorSDK={}))})(this,function(r){"use strict";var S=Object.defineProperty;var L=(r,c,u)=>c in r?S(r,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):r[c]=u;var n=(r,c,u)=>L(r,typeof c!="symbol"?c+"":c,u);var c=Object.defineProperty,u=(a,i,e)=>i in a?c(a,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[i]=e,E=(a,i,e)=>(u(a,i+"",e),e),k=(a,i,e)=>new Promise((s,t)=>{var o=d=>{try{h(e.next(d))}catch(m){t(m)}},l=d=>{try{h(e.throw(d))}catch(m){t(m)}},h=d=>d.done?s(d.value):Promise.resolve(d.value).then(o,l);h((e=e.apply(a,i)).next())}),C=class b{constructor(){E(this,"callbackMap",{})}static createEvent(){return new b}on(i,e){var s;return this.callbackMap[i]||(this.callbackMap[i]=[]),(s=this.callbackMap[i])==null||s.push(e),e}off(i,e){var s;this.callbackMap[i]&&(this.callbackMap[i]=(s=this==null?void 0:this.callbackMap[i])==null?void 0:s.filter(t=>t!==e))}once(i,e){const s=(...t)=>{this.off(i,s),e(...t)};return this.on(i,s)}emit(i,...e){return k(this,null,function*(){if(!this.callbackMap[i])return;const s=this.callbackMap[i];s&&(yield Promise.all(s.map(t=>t(...e))))})}},v=(a=>(a.KeyDown="keyDown",a.KeyUp="keyUp",a.RawKeyDown="rawKeyDown",a.Char="char",a))(v||{});function K(a,i){let e;return function(...s){clearTimeout(e),e=setTimeout(()=>a.apply(this,s),i)}}class p extends C{constructor(e,s,t){super();n(this,"url");n(this,"ws");n(this,"messageId");n(this,"img");n(this,"canvas");n(this,"viewContainer");n(this,"zoom",devicePixelRatio);n(this,"disconnectTimeout");n(this,"disconnectDelay");n(this,"metadata",null);n(this,"version","1.2.1");n(this,"handleStartScreencast",()=>{const e=document.createElement("canvas");e.id="inspectorSDK-canvas",this.canvas=e,this.img=new Image,this.canvas.style.display="none",this.viewContainer.appendChild(this.canvas)});n(this,"canvasDrawImage",()=>{const e=this.canvas.getContext("2d");if(!e||!this.metadata)return;const{width:s,height:t}=this.viewContainer.getBoundingClientRect();this.canvas.style.display="inline";const o=s||this.metadata.deviceWidth,l=t||this.metadata.deviceHeight,h=this.metadata.deviceWidth,d=this.metadata.deviceHeight,m=o/h,y=l/d,f=Math.min(m,y);this.zoom=f;const w=h*f,g=d*f;this.canvas.width=w*devicePixelRatio,this.canvas.height=g*devicePixelRatio,this.canvas.style.width=`${w}px`,this.canvas.style.height=`${g}px`,e.scale(devicePixelRatio,devicePixelRatio),e.drawImage(this.img,0,0,w,g)});n(this,"handleScreencastFrame",e=>{const{data:s,metadata:t}=e;this.metadata=t;try{this.img.onload=()=>{this.canvasDrawImage(),this.emit("drawComplete",{status:!0})},this.img.src="data:image/jpeg;base64,"+s}catch{this.emit("drawComplete",{status:!1})}});n(this,"emitMouse",e=>{const s={0:"none",1:"left",2:"middle",3:"right"},t=e.type==="mousewheel"&&window.event||e,o={mousedown:"mousePressed",mouseup:"mouseReleased",mousewheel:"mouseWheel",touchstart:"mousePressed",touchend:"mouseReleased",touchmove:"mouseWheel",mousemove:"mouseMoved"};if(!(t.type in o)||t.type!=="mousewheel"&&s[t.which]==="none"&&t.type!=="mousemove")return;const h=o[t.type].indexOf("wheel")!==-1,d=(h?t.clientX:t.offsetX)*(1/this.zoom),m=(h?t.clientY:t.offsetY)*(1/this.zoom),y={type:o[t.type],x:d,y:m,modifiers:p.getModifiersForEvent(t),button:t.type==="mousewheel"?"none":s[t.which],clickCount:1};t.type==="mousewheel"&&(y.deltaX=(t.wheelDeltaX||0)*(1/this.zoom),y.deltaY=(t.wheelDeltaY||t.wheelDelta)*(1/this.zoom)),this.ws.send(JSON.stringify({id:++this.messageId,method:"Input.dispatchMouseEvent",params:y}))});n(this,"emitKeyEvent",e=>{let s;switch(e.keyCode===8&&e.preventDefault(),e.type){case"keydown":s=v.KeyDown;break;case"keyup":s=v.KeyUp;break;case"keypress":s=v.Char;break;default:return}const t=s==="char"?String.fromCharCode(e.charCode):void 0,o={type:s,text:t,unmodifiedText:t?t.toLowerCase():void 0,keyIdentifier:e.keyIdentifier,code:e.code,key:e.key,windowsVirtualKeyCode:e.keyCode,nativeVirtualKeyCode:e.keyCode,autoRepeat:!1,isKeypad:!1,isSystemKey:!1};this.ws.send(JSON.stringify({id:++this.messageId,method:"Input.dispatchKeyEvent",params:o}))});n(this,"bindKeyEvents",()=>{document.body.addEventListener("keydown",this.emitKeyEvent,!0),document.body.addEventListener("keyup",this.emitKeyEvent,!0),document.body.addEventListener("keypress",this.emitKeyEvent,!0)});n(this,"unbindKeyEvents",()=>{document.body.removeEventListener("keydown",this.emitKeyEvent,!0),document.body.removeEventListener("keyup",this.emitKeyEvent,!0),document.body.removeEventListener("keypress",this.emitKeyEvent,!0)});n(this,"handleVisibilityChange",()=>{document.visibilityState==="hidden"?this.disconnectTimeout=window.setTimeout(()=>{this.close()},this.disconnectDelay):this.disconnectTimeout&&(clearTimeout(this.disconnectTimeout),this.disconnectTimeout=null)});n(this,"deleteCanvasElement",()=>{var s;const e=document.querySelector("#inspectorSDK-canvas");(s=e==null?void 0:e.parentElement)==null||s.removeChild(e)});n(this,"onResizeViewContainer",()=>{const e=new ResizeObserver(K(()=>{this.canvasDrawImage(),this.emit("drawComplete",{status:!0})},16.666666666666668));this.viewContainer&&e.observe(this.viewContainer)});n(this,"removeEventListeners",()=>{this.canvas.removeEventListener("mousedown",this.emitMouse,!1),this.canvas.removeEventListener("mouseup",this.emitMouse,!1),this.canvas.removeEventListener("mousewheel",this.emitMouse,!1),this.canvas.removeEventListener("mousemove",this.emitMouse,!1),this.canvas.removeEventListener("mouseenter",this.bindKeyEvents,!1),this.canvas.removeEventListener("mouseleave",this.unbindKeyEvents,!1)});n(this,"connect",(e=!1)=>(this.ws=new WebSocket(this.url),new Promise((s,t)=>{this.ws.onopen=()=>{console.log("WebSocket connection opened"),this.ws.send(JSON.stringify({id:1,method:"Page.startScreencast",params:{format:"jpeg",quality:80,everyNthFrame:1}})),this.handleStartScreencast(),this.onResizeViewContainer(),e&&this.addEventListeners(),document.addEventListener("visibilitychange",this.handleVisibilityChange),s()},this.ws.onmessage=o=>{const l=JSON.parse(o.data);if(l.method==="Page.screencastFrame"){const h=l.params;this.handleScreencastFrame(h),this.ws.send(JSON.stringify({id:++this.messageId,method:"Page.screencastFrameAck",params:{sessionId:l.params.sessionId}}))}},this.ws.onclose=()=>{console.log("WebSocket connection closed"),document.removeEventListener("visibilitychange",this.handleVisibilityChange),this.emit("close"),this.close()},this.ws.onerror=o=>{console.error("WebSocket error:",o),t(o)}})));this.url=e,this.messageId=0,this.viewContainer=s,this.disconnectTimeout=null,this.disconnectDelay=t??6e4*5}static getModifiersForEvent(e){return(e.altKey?1:0)|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}addEventListeners(){this.canvas.addEventListener("mousedown",this.emitMouse,!1),this.canvas.addEventListener("mouseup",this.emitMouse,!1),this.canvas.addEventListener("mousewheel",this.emitMouse,!1),this.canvas.addEventListener("mousemove",this.emitMouse,!1),this.canvas.addEventListener("mouseenter",this.bindKeyEvents,!1),this.canvas.addEventListener("mouseleave",this.unbindKeyEvents,!1)}close(){this.ws.close(),this.removeEventListeners(),this.deleteCanvasElement()}}r.DispatchKeyEventRequestType=v,r.default=p,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
(function(r,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(r=typeof globalThis<"u"?globalThis:r||self,c(r.InspectorSDK={}))})(this,function(r){"use strict";var S=Object.defineProperty;var L=(r,c,u)=>c in r?S(r,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):r[c]=u;var i=(r,c,u)=>L(r,typeof c!="symbol"?c+"":c,u);var c=Object.defineProperty,u=(a,n,e)=>n in a?c(a,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[n]=e,E=(a,n,e)=>(u(a,n+"",e),e),k=(a,n,e)=>new Promise((t,s)=>{var o=d=>{try{h(e.next(d))}catch(m){s(m)}},l=d=>{try{h(e.throw(d))}catch(m){s(m)}},h=d=>d.done?t(d.value):Promise.resolve(d.value).then(o,l);h((e=e.apply(a,n)).next())}),C=class b{constructor(){E(this,"callbackMap",{})}static createEvent(){return new b}on(n,e){var t;return this.callbackMap[n]||(this.callbackMap[n]=[]),(t=this.callbackMap[n])==null||t.push(e),e}off(n,e){var t;this.callbackMap[n]&&(this.callbackMap[n]=(t=this==null?void 0:this.callbackMap[n])==null?void 0:t.filter(s=>s!==e))}once(n,e){const t=(...s)=>{this.off(n,t),e(...s)};return this.on(n,t)}emit(n,...e){return k(this,null,function*(){if(!this.callbackMap[n])return;const t=this.callbackMap[n];t&&(yield Promise.all(t.map(s=>s(...e))))})}},v=(a=>(a.KeyDown="keyDown",a.KeyUp="keyUp",a.RawKeyDown="rawKeyDown",a.Char="char",a))(v||{});function K(a,n){let e;return function(...t){clearTimeout(e),e=setTimeout(()=>a.apply(this,t),n)}}class p extends C{constructor(e,t,s){super();i(this,"url");i(this,"ws");i(this,"messageId");i(this,"img");i(this,"canvas");i(this,"viewContainer");i(this,"zoom",devicePixelRatio);i(this,"disconnectTimeout");i(this,"disconnectDelay");i(this,"metadata",null);i(this,"scrollDirection",1);i(this,"version","1.2.2");i(this,"detectScrollDirection",()=>{const e=t=>{t.deltaY!==0&&(this.scrollDirection=t.deltaY>0?1:-1,window.removeEventListener("wheel",e))};window.addEventListener("wheel",e,{passive:!0,once:!0})});i(this,"handleStartScreencast",()=>{const e=document.createElement("canvas");e.id="inspectorSDK-canvas",this.canvas=e,this.img=new Image,this.canvas.style.display="none",this.viewContainer.appendChild(this.canvas)});i(this,"canvasDrawImage",()=>{const e=this.canvas.getContext("2d");if(!e||!this.metadata)return;const{width:t,height:s}=this.viewContainer.getBoundingClientRect();this.canvas.style.display="inline";const o=t||this.metadata.deviceWidth,l=s||this.metadata.deviceHeight,h=this.metadata.deviceWidth,d=this.metadata.deviceHeight,m=o/h,y=l/d,f=Math.min(m,y);this.zoom=f;const w=h*f,g=d*f;this.canvas.width=w*devicePixelRatio,this.canvas.height=g*devicePixelRatio,this.canvas.style.width=`${w}px`,this.canvas.style.height=`${g}px`,e.scale(devicePixelRatio,devicePixelRatio),e.drawImage(this.img,0,0,w,g)});i(this,"handleScreencastFrame",e=>{const{data:t,metadata:s}=e;this.metadata=s;try{this.img.onload=()=>{this.canvasDrawImage(),this.emit("drawComplete",{status:!0})},this.img.src="data:image/jpeg;base64,"+t}catch{this.emit("drawComplete",{status:!1})}});i(this,"emitMouse",e=>{const t={0:"none",1:"left",2:"middle",3:"right"},s=e.type==="mousewheel"&&window.event||e,o={mousedown:"mousePressed",mouseup:"mouseReleased",mousewheel:"mouseWheel",touchstart:"mousePressed",touchend:"mouseReleased",touchmove:"mouseWheel",mousemove:"mouseMoved"};if(!(s.type in o)||s.type!=="mousewheel"&&t[s.which]==="none"&&s.type!=="mousemove")return;const h=o[s.type].indexOf("wheel")!==-1,d=(h?s.clientX:s.offsetX)*(1/this.zoom),m=(h?s.clientY:s.offsetY)*(1/this.zoom),y={type:o[s.type],x:d,y:m,modifiers:p.getModifiersForEvent(s),button:s.type==="mousewheel"?"none":t[s.which],clickCount:1};s.type==="mousewheel"&&(y.deltaX=(s.deltaX||0)*(1/this.zoom)*this.scrollDirection,y.deltaY=(s.deltaY||s.wheelDelta||0)*(1/this.zoom)*this.scrollDirection),this.ws.send(JSON.stringify({id:++this.messageId,method:"Input.dispatchMouseEvent",params:y}))});i(this,"emitKeyEvent",e=>{let t;switch(e.keyCode===8&&e.preventDefault(),e.type){case"keydown":t=v.KeyDown;break;case"keyup":t=v.KeyUp;break;case"keypress":t=v.Char;break;default:return}const s=t==="char"?String.fromCharCode(e.charCode):void 0,o={type:t,text:s,unmodifiedText:s?s.toLowerCase():void 0,keyIdentifier:e.keyIdentifier,code:e.code,key:e.key,windowsVirtualKeyCode:e.keyCode,nativeVirtualKeyCode:e.keyCode,autoRepeat:!1,isKeypad:!1,isSystemKey:!1};this.ws.send(JSON.stringify({id:++this.messageId,method:"Input.dispatchKeyEvent",params:o}))});i(this,"bindKeyEvents",()=>{document.body.addEventListener("keydown",this.emitKeyEvent,!0),document.body.addEventListener("keyup",this.emitKeyEvent,!0),document.body.addEventListener("keypress",this.emitKeyEvent,!0)});i(this,"unbindKeyEvents",()=>{document.body.removeEventListener("keydown",this.emitKeyEvent,!0),document.body.removeEventListener("keyup",this.emitKeyEvent,!0),document.body.removeEventListener("keypress",this.emitKeyEvent,!0)});i(this,"handleVisibilityChange",()=>{document.visibilityState==="hidden"?this.disconnectTimeout=window.setTimeout(()=>{this.close()},this.disconnectDelay):this.disconnectTimeout&&(clearTimeout(this.disconnectTimeout),this.disconnectTimeout=null)});i(this,"deleteCanvasElement",()=>{var t;const e=document.querySelector("#inspectorSDK-canvas");(t=e==null?void 0:e.parentElement)==null||t.removeChild(e)});i(this,"onResizeViewContainer",()=>{const e=new ResizeObserver(K(()=>{this.canvasDrawImage(),this.emit("drawComplete",{status:!0})},16.666666666666668));this.viewContainer&&e.observe(this.viewContainer)});i(this,"removeEventListeners",()=>{this.canvas.removeEventListener("mousedown",this.emitMouse,!1),this.canvas.removeEventListener("mouseup",this.emitMouse,!1),this.canvas.removeEventListener("mousewheel",this.emitMouse,!1),this.canvas.removeEventListener("mousemove",this.emitMouse,!1),this.canvas.removeEventListener("mouseenter",this.bindKeyEvents,!1),this.canvas.removeEventListener("mouseleave",this.unbindKeyEvents,!1)});i(this,"connect",(e=!1)=>(this.ws=new WebSocket(this.url),new Promise((t,s)=>{this.ws.onopen=()=>{console.log("WebSocket connection opened"),this.ws.send(JSON.stringify({id:1,method:"Page.startScreencast",params:{format:"jpeg",quality:80,everyNthFrame:1}})),this.handleStartScreencast(),this.onResizeViewContainer(),e&&this.addEventListeners(),document.addEventListener("visibilitychange",this.handleVisibilityChange),t()},this.ws.onmessage=o=>{const l=JSON.parse(o.data);if(l.method==="Page.screencastFrame"){const h=l.params;this.handleScreencastFrame(h),this.ws.send(JSON.stringify({id:++this.messageId,method:"Page.screencastFrameAck",params:{sessionId:l.params.sessionId}}))}},this.ws.onclose=()=>{console.log("WebSocket connection closed"),document.removeEventListener("visibilitychange",this.handleVisibilityChange),this.emit("close"),this.close()},this.ws.onerror=o=>{console.error("WebSocket error:",o),s(o)}})));this.url=e,this.messageId=0,this.viewContainer=t,this.disconnectTimeout=null,this.disconnectDelay=s??6e4*5,this.detectScrollDirection()}static getModifiersForEvent(e){return(e.altKey?1:0)|(e.ctrlKey?2:0)|(e.metaKey?4:0)|(e.shiftKey?8:0)}addEventListeners(){this.canvas.addEventListener("mousedown",this.emitMouse,!1),this.canvas.addEventListener("mouseup",this.emitMouse,!1),this.canvas.addEventListener("mousewheel",this.emitMouse,!1),this.canvas.addEventListener("mousemove",this.emitMouse,!1),this.canvas.addEventListener("mouseenter",this.bindKeyEvents,!1),this.canvas.addEventListener("mouseleave",this.unbindKeyEvents,!1)}close(){this.ws.close(),this.removeEventListeners(),this.deleteCanvasElement()}}r.DispatchKeyEventRequestType=v,r.default=p,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
{
"name": "imean-inspector-sdk",
"private": false,
"version": "1.2.2",
"version": "1.2.3",
"description": "iMean inspector sdk",

@@ -6,0 +6,0 @@ "repository": "https://git.imean.tech/imean/inspector-sdk.git",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc