JavaScript 65.5%
Python 17.8%
CSS 13%
HTML 3.7%
1"use strict";23Object.defineProperty(exports, "__esModule", {4 value: true5});6exports["default"] = void 0;7var Log = _interopRequireWildcard(require("../util/logging.js"));8function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }9function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }10function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }11function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }12function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }13function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }14function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }15function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*16 * noVNC: HTML5 VNC client17 * Copyright (C) 2019 The noVNC authors18 * Licensed under MPL 2.0 (see LICENSE.txt)19 *20 * See README.md for usage and integration instructions.21 *22 */23var HextileDecoder = exports["default"] = /*#__PURE__*/function () {24 function HextileDecoder() {25 _classCallCheck(this, HextileDecoder);26 this._tiles = 0;27 this._lastsubencoding = 0;28 this._tileBuffer = new Uint8Array(16 * 16 * 4);29 }30 return _createClass(HextileDecoder, [{31 key: "decodeRect",32 value: function decodeRect(x, y, width, height, sock, display, depth) {33 if (this._tiles === 0) {34 this._tilesX = Math.ceil(width / 16);35 this._tilesY = Math.ceil(height / 16);36 this._totalTiles = this._tilesX * this._tilesY;37 this._tiles = this._totalTiles;38 }39 while (this._tiles > 0) {40 var bytes = 1;41 if (sock.rQwait("HEXTILE", bytes)) {42 return false;43 }44 var subencoding = sock.rQpeek8();45 if (subencoding > 30) {46 // Raw47 throw new Error("Illegal hextile subencoding (subencoding: " + subencoding + ")");48 }49 var currTile = this._totalTiles - this._tiles;50 var tileX = currTile % this._tilesX;51 var tileY = Math.floor(currTile / this._tilesX);52 var tx = x + tileX * 16;53 var ty = y + tileY * 16;54 var tw = Math.min(16, x + width - tx);55 var th = Math.min(16, y + height - ty);5657 // Figure out how much we are expecting58 if (subencoding & 0x01) {59 // Raw60 bytes += tw * th * 4;61 } else {62 if (subencoding & 0x02) {63 // Background64 bytes += 4;65 }66 if (subencoding & 0x04) {67 // Foreground68 bytes += 4;69 }70 if (subencoding & 0x08) {71 // AnySubrects72 bytes++; // Since we aren't shifting it off7374 if (sock.rQwait("HEXTILE", bytes)) {75 return false;76 }77 var subrects = sock.rQpeekBytes(bytes).at(-1);78 if (subencoding & 0x10) {79 // SubrectsColoured80 bytes += subrects * (4 + 2);81 } else {82 bytes += subrects * 2;83 }84 }85 }86 if (sock.rQwait("HEXTILE", bytes)) {87 return false;88 }8990 // We know the encoding and have a whole tile91 sock.rQshift8();92 if (subencoding === 0) {93 if (this._lastsubencoding & 0x01) {94 // Weird: ignore blanks are RAW95 Log.Debug(" Ignoring blank after RAW");96 } else {97 display.fillRect(tx, ty, tw, th, this._background);98 }99 } else if (subencoding & 0x01) {100 // Raw101 var pixels = tw * th;102 var data = sock.rQshiftBytes(pixels * 4, false);103 // Max sure the image is fully opaque104 for (var i = 0; i < pixels; i++) {105 data[i * 4 + 3] = 255;106 }107 display.blitImage(tx, ty, tw, th, data, 0);108 } else {109 if (subencoding & 0x02) {110 // Background111 this._background = new Uint8Array(sock.rQshiftBytes(4));112 }113 if (subencoding & 0x04) {114 // Foreground115 this._foreground = new Uint8Array(sock.rQshiftBytes(4));116 }117 this._startTile(tx, ty, tw, th, this._background);118 if (subencoding & 0x08) {119 // AnySubrects120 var _subrects = sock.rQshift8();121 for (var s = 0; s < _subrects; s++) {122 var color = void 0;123 if (subencoding & 0x10) {124 // SubrectsColoured125 color = sock.rQshiftBytes(4);126 } else {127 color = this._foreground;128 }129 var xy = sock.rQshift8();130 var sx = xy >> 4;131 var sy = xy & 0x0f;132 var wh = sock.rQshift8();133 var sw = (wh >> 4) + 1;134 var sh = (wh & 0x0f) + 1;135 this._subTile(sx, sy, sw, sh, color);136 }137 }138 this._finishTile(display);139 }140 this._lastsubencoding = subencoding;141 this._tiles--;142 }143 return true;144 }145146 // start updating a tile147 }, {148 key: "_startTile",149 value: function _startTile(x, y, width, height, color) {150 this._tileX = x;151 this._tileY = y;152 this._tileW = width;153 this._tileH = height;154 var red = color[0];155 var green = color[1];156 var blue = color[2];157 var data = this._tileBuffer;158 for (var i = 0; i < width * height * 4; i += 4) {159 data[i] = red;160 data[i + 1] = green;161 data[i + 2] = blue;162 data[i + 3] = 255;163 }164 }165166 // update sub-rectangle of the current tile167 }, {168 key: "_subTile",169 value: function _subTile(x, y, w, h, color) {170 var red = color[0];171 var green = color[1];172 var blue = color[2];173 var xend = x + w;174 var yend = y + h;175 var data = this._tileBuffer;176 var width = this._tileW;177 for (var j = y; j < yend; j++) {178 for (var i = x; i < xend; i++) {179 var p = (i + j * width) * 4;180 data[p] = red;181 data[p + 1] = green;182 data[p + 2] = blue;183 data[p + 3] = 255;184 }185 }186 }187188 // draw the current tile to the screen189 }, {190 key: "_finishTile",191 value: function _finishTile(display) {192 display.blitImage(this._tileX, this._tileY, this._tileW, this._tileH, this._tileBuffer, 0);193 }194 }]);195}();