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.0 to 1.2.1

4

dist/sdk/lib/es/index.js

@@ -93,3 +93,3 @@ var f = Object.defineProperty;

n(this, "metadata", null);
n(this, "version", "1.1.0");
n(this, "version", "1.2.0");
n(this, "handleStartScreencast", () => {

@@ -205,3 +205,3 @@ const e = document.createElement("canvas");

this.canvasDrawImage(), this.emit("drawComplete", { status: !0 });
}, 200)
}, 16.666666666666668)
);

@@ -208,0 +208,0 @@ this.viewContainer && e.observe(this.viewContainer);

@@ -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.1.0");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})},200));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.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 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.0");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.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"}})});
{
"name": "imean-inspector-sdk",
"private": false,
"version": "1.2.0",
"version": "1.2.1",
"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