react-vnc-display
Version:
React component to connect and display a remote VNC connection
2 lines • 4.6 kB
JavaScript
(function(a,b){'object'==typeof exports&&'object'==typeof module?module.exports=b():'function'==typeof define&&define.amd?define('VncDisplay',[],b):'object'==typeof exports?exports.VncDisplay=b():a.VncDisplay=b()})('undefined'==typeof self?this:self,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={i:d,l:!1,exports:{}};return a[d].call(e.exports,e,e.exports,b),e.l=!0,e.exports}var c={};return b.m=a,b.c=c,b.d=function(a,c,d){b.o(a,c)||Object.defineProperty(a,c,{configurable:!1,enumerable:!0,get:d})},b.n=function(a){var c=a&&a.__esModule?function(){return a['default']}:function(){return a};return b.d(c,'a',c),c},b.o=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)},b.p='./',b(b.s=4)}([function(a){a.exports=require('react')},function(a,b,c){'use strict';function d(a,b){var c={};for(var d in a)0<=b.indexOf(d)||Object.prototype.hasOwnProperty.call(a,d)&&(c[d]=a[d]);return c}function e(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}function f(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a}function g(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}Object.defineProperty(b,'__esModule',{value:!0}),c.d(b,'default',function(){return r});var h,i,j=c(0),k=c.n(j),l=c(2),m=c.n(l),n=c(3),o=c.n(n),p=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},q=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),r=(i=h=function(a){function b(){var a,c,g,h;e(this,b);for(var i=arguments.length,j=Array(i),k=0;k<i;k++)j[k]=arguments[k];return h=(c=(g=f(this,(a=b.__proto__||Object.getPrototypeOf(b)).call.apply(a,[this].concat(j))),g),Object.defineProperty(g,'disconnect',{enumerable:!0,writable:!0,value:function(){g.rfb&&(g.rfb.disconnect(),g.rfb=null)}}),Object.defineProperty(g,'connect',{enumerable:!0,writable:!0,value:function(){if(g.disconnect(),!!g.canvas){var a=g.props,b=a.name,c=a.connectTimeout,e=a.url,f=a.width,h=a.height,i=a.encrypt,j=d(a,['name','connectTimeout','url','width','height','encrypt']);g.rfb=new n.RFB(p({},j,{encrypt:null===i?e.startsWith('wss:'):i,target:g.canvas})),g.rfb.connect(e)}}}),Object.defineProperty(g,'registerChild',{enumerable:!0,writable:!0,value:function(a){g.canvas=a}}),Object.defineProperty(g,'handleMouseEnter',{enumerable:!0,writable:!0,value:function(){g.rfb&&(document.activeElement&&document.activeElement.blur(),g.rfb.get_keyboard().grab(),g.rfb.get_mouse().grab())}}),Object.defineProperty(g,'handleMouseLeave',{enumerable:!0,writable:!0,value:function(){g.rfb&&(g.rfb.get_keyboard().ungrab(),g.rfb.get_mouse().ungrab())}}),c),f(g,h)}return g(b,a),q(b,[{key:'componentDidMount',value:function(){this.connect()}},{key:'componentWillUnmount',value:function(){this.disconnect()}},{key:'componentWillReceiveProps',value:function(a){this.rfb&&(a.scale===this.props.scale||(this.rfb.get_display().set_scale(a.scale||1),this.get_mouse().set_scale(a.scale||1)))}},{key:'render',value:function(){return Object(j.createElement)('canvas',{style:this.props.style,ref:this.registerChild,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave})}}]),b}(j.Component),Object.defineProperty(h,'propTypes',{enumerable:!0,writable:!0,value:{url:l.string.isRequired,style:l.object,width:l.number,height:l.number,encrypt:l.bool,wsProtocols:Object(l.arrayOf)(l.string),onClipboard:l.func,onUpdateState:l.func,onPasswordRequired:l.func,onBell:l.func,onDesktopName:l.func,connectTimeout:l.number,disconnectTimeout:l.number,shared:l.bool}}),Object.defineProperty(h,'defaultProps',{enumerable:!0,writable:!0,value:{style:null,encrypt:null,wsProtocols:['binary'],trueColor:!0,localCursor:!0,connectTimeout:5,disconnectTimeout:5,width:1280,height:720,onClipboard:null,onUpdateState:null,onPasswordRequired:null,onBell:null,onDesktopName:null,shared:!1}}),i)},function(a){a.exports=require('prop-types')},function(a){a.exports=require('novnc-node')},function(a,b,c){a.exports=c(1)}])});
//# sourceMappingURL=VncDisplay.js.map