@novnc/novnc 1.6.0 → 1.7.0
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/core/base64.js +104 -0
- package/core/crypto/aes.js +178 -0
- package/core/crypto/bigint.js +34 -0
- package/core/crypto/crypto.js +90 -0
- package/core/crypto/des.js +330 -0
- package/core/crypto/dh.js +55 -0
- package/core/crypto/md5.js +82 -0
- package/core/crypto/rsa.js +132 -0
- package/core/decoders/copyrect.js +27 -0
- package/core/decoders/h264.js +321 -0
- package/core/decoders/hextile.js +181 -0
- package/core/decoders/jpeg.js +161 -0
- package/core/decoders/raw.js +59 -0
- package/core/decoders/rre.js +44 -0
- package/core/decoders/tight.js +393 -0
- package/core/decoders/tightpng.js +27 -0
- package/core/decoders/zlib.js +51 -0
- package/core/decoders/zrle.js +185 -0
- package/core/deflator.js +84 -0
- package/core/display.js +578 -0
- package/core/encodings.js +54 -0
- package/core/inflator.js +65 -0
- package/core/input/domkeytable.js +311 -0
- package/core/input/fixedkeys.js +129 -0
- package/core/input/gesturehandler.js +567 -0
- package/core/input/keyboard.js +294 -0
- package/core/input/keysym.js +616 -0
- package/core/input/keysymdef.js +688 -0
- package/core/input/util.js +191 -0
- package/core/input/vkeys.js +116 -0
- package/core/input/xtscancodes.js +173 -0
- package/core/ra2.js +312 -0
- package/core/rfb.js +3411 -0
- package/core/util/browser.js +233 -0
- package/core/util/cursor.js +249 -0
- package/core/util/element.js +32 -0
- package/core/util/events.js +138 -0
- package/core/util/eventtarget.js +35 -0
- package/core/util/int.js +15 -0
- package/core/util/logging.js +56 -0
- package/core/util/strings.js +28 -0
- package/core/websock.js +369 -0
- package/docs/API.md +0 -5
- package/package.json +6 -10
- package/vendor/pako/LICENSE +21 -0
- package/vendor/pako/README.md +6 -0
- package/{lib/vendor → vendor}/pako/lib/utils/common.js +13 -23
- package/{lib/vendor → vendor}/pako/lib/zlib/adler32.js +12 -14
- package/vendor/pako/lib/zlib/constants.js +47 -0
- package/{lib/vendor → vendor}/pako/lib/zlib/crc32.js +15 -14
- package/{lib/vendor → vendor}/pako/lib/zlib/deflate.js +459 -334
- package/{lib/vendor → vendor}/pako/lib/zlib/gzheader.js +13 -19
- package/{lib/vendor → vendor}/pako/lib/zlib/inffast.js +116 -119
- package/vendor/pako/lib/zlib/inflate.js +1527 -0
- package/{lib/vendor → vendor}/pako/lib/zlib/inftrees.js +103 -91
- package/vendor/pako/lib/zlib/messages.js +11 -0
- package/{lib/vendor → vendor}/pako/lib/zlib/trees.js +313 -268
- package/{lib/vendor → vendor}/pako/lib/zlib/zstream.js +4 -10
- package/lib/base64.js +0 -100
- package/lib/crypto/aes.js +0 -481
- package/lib/crypto/bigint.js +0 -41
- package/lib/crypto/crypto.js +0 -109
- package/lib/crypto/des.js +0 -374
- package/lib/crypto/dh.js +0 -81
- package/lib/crypto/md5.js +0 -97
- package/lib/crypto/rsa.js +0 -312
- package/lib/decoders/copyrect.js +0 -40
- package/lib/decoders/h264.js +0 -349
- package/lib/decoders/hextile.js +0 -195
- package/lib/decoders/jpeg.js +0 -175
- package/lib/decoders/raw.js +0 -66
- package/lib/decoders/rre.js +0 -52
- package/lib/decoders/tight.js +0 -363
- package/lib/decoders/tightpng.js +0 -51
- package/lib/decoders/zlib.js +0 -57
- package/lib/decoders/zrle.js +0 -192
- package/lib/deflator.js +0 -88
- package/lib/display.js +0 -588
- package/lib/encodings.js +0 -70
- package/lib/inflator.js +0 -77
- package/lib/input/domkeytable.js +0 -313
- package/lib/input/fixedkeys.js +0 -127
- package/lib/input/gesturehandler.js +0 -573
- package/lib/input/keyboard.js +0 -293
- package/lib/input/keysym.js +0 -878
- package/lib/input/keysymdef.js +0 -1351
- package/lib/input/util.js +0 -217
- package/lib/input/vkeys.js +0 -121
- package/lib/input/xtscancodes.js +0 -343
- package/lib/ra2.js +0 -535
- package/lib/rfb.js +0 -3398
- package/lib/util/browser.js +0 -239
- package/lib/util/cursor.js +0 -269
- package/lib/util/element.js +0 -41
- package/lib/util/events.js +0 -133
- package/lib/util/eventtarget.js +0 -53
- package/lib/util/int.js +0 -21
- package/lib/util/logging.js +0 -56
- package/lib/util/strings.js +0 -36
- package/lib/vendor/pako/lib/zlib/constants.js +0 -47
- package/lib/vendor/pako/lib/zlib/inflate.js +0 -1602
- package/lib/vendor/pako/lib/zlib/messages.js +0 -25
- package/lib/websock.js +0 -395
package/lib/decoders/tightpng.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _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); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports["default"] = void 0;
|
|
8
|
-
var _tight = _interopRequireDefault(require("./tight.js"));
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
11
|
-
function _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); } }
|
|
12
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
-
function _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); }
|
|
15
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
16
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
17
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
18
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
19
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
20
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
21
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } /*
|
|
22
|
-
* noVNC: HTML5 VNC client
|
|
23
|
-
* Copyright (C) 2019 The noVNC authors
|
|
24
|
-
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
25
|
-
*
|
|
26
|
-
* See README.md for usage and integration instructions.
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
var TightPNGDecoder = exports["default"] = /*#__PURE__*/function (_TightDecoder) {
|
|
30
|
-
function TightPNGDecoder() {
|
|
31
|
-
_classCallCheck(this, TightPNGDecoder);
|
|
32
|
-
return _callSuper(this, TightPNGDecoder, arguments);
|
|
33
|
-
}
|
|
34
|
-
_inherits(TightPNGDecoder, _TightDecoder);
|
|
35
|
-
return _createClass(TightPNGDecoder, [{
|
|
36
|
-
key: "_pngRect",
|
|
37
|
-
value: function _pngRect(x, y, width, height, sock, display, depth) {
|
|
38
|
-
var data = this._readData(sock);
|
|
39
|
-
if (data === null) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
display.imageRect(x, y, width, height, "image/png", data);
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
}, {
|
|
46
|
-
key: "_basicRect",
|
|
47
|
-
value: function _basicRect(ctl, x, y, width, height, sock, display, depth) {
|
|
48
|
-
throw new Error("BasicCompression received in TightPNG rect");
|
|
49
|
-
}
|
|
50
|
-
}]);
|
|
51
|
-
}(_tight["default"]);
|
package/lib/decoders/zlib.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _inflator = _interopRequireDefault(require("../inflator.js"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
-
function _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); }
|
|
10
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
11
|
-
function _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); } }
|
|
12
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
-
function _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); } /*
|
|
15
|
-
* noVNC: HTML5 VNC client
|
|
16
|
-
* Copyright (C) 2024 The noVNC authors
|
|
17
|
-
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
18
|
-
*
|
|
19
|
-
* See README.md for usage and integration instructions.
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
var ZlibDecoder = exports["default"] = /*#__PURE__*/function () {
|
|
23
|
-
function ZlibDecoder() {
|
|
24
|
-
_classCallCheck(this, ZlibDecoder);
|
|
25
|
-
this._zlib = new _inflator["default"]();
|
|
26
|
-
this._length = 0;
|
|
27
|
-
}
|
|
28
|
-
return _createClass(ZlibDecoder, [{
|
|
29
|
-
key: "decodeRect",
|
|
30
|
-
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
31
|
-
if (width === 0 || height === 0) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
if (this._length === 0) {
|
|
35
|
-
if (sock.rQwait("ZLIB", 4)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
this._length = sock.rQshift32();
|
|
39
|
-
}
|
|
40
|
-
if (sock.rQwait("ZLIB", this._length)) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
var data = new Uint8Array(sock.rQshiftBytes(this._length, false));
|
|
44
|
-
this._length = 0;
|
|
45
|
-
this._zlib.setInput(data);
|
|
46
|
-
data = this._zlib.inflate(width * height * 4);
|
|
47
|
-
this._zlib.setInput(null);
|
|
48
|
-
|
|
49
|
-
// Max sure the image is fully opaque
|
|
50
|
-
for (var i = 0; i < width * height; i++) {
|
|
51
|
-
data[i * 4 + 3] = 255;
|
|
52
|
-
}
|
|
53
|
-
display.blitImage(x, y, width, height, data, 0);
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
}]);
|
|
57
|
-
}();
|
package/lib/decoders/zrle.js
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _inflator = _interopRequireDefault(require("../inflator.js"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
-
function _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); }
|
|
10
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
11
|
-
function _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); } }
|
|
12
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
-
function _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); } /*
|
|
15
|
-
* noVNC: HTML5 VNC client
|
|
16
|
-
* Copyright (C) 2021 The noVNC authors
|
|
17
|
-
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
18
|
-
*
|
|
19
|
-
* See README.md for usage and integration instructions.
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
var ZRLE_TILE_WIDTH = 64;
|
|
23
|
-
var ZRLE_TILE_HEIGHT = 64;
|
|
24
|
-
var ZRLEDecoder = exports["default"] = /*#__PURE__*/function () {
|
|
25
|
-
function ZRLEDecoder() {
|
|
26
|
-
_classCallCheck(this, ZRLEDecoder);
|
|
27
|
-
this._length = 0;
|
|
28
|
-
this._inflator = new _inflator["default"]();
|
|
29
|
-
this._pixelBuffer = new Uint8Array(ZRLE_TILE_WIDTH * ZRLE_TILE_HEIGHT * 4);
|
|
30
|
-
this._tileBuffer = new Uint8Array(ZRLE_TILE_WIDTH * ZRLE_TILE_HEIGHT * 4);
|
|
31
|
-
}
|
|
32
|
-
return _createClass(ZRLEDecoder, [{
|
|
33
|
-
key: "decodeRect",
|
|
34
|
-
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
35
|
-
if (this._length === 0) {
|
|
36
|
-
if (sock.rQwait("ZLib data length", 4)) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
this._length = sock.rQshift32();
|
|
40
|
-
}
|
|
41
|
-
if (sock.rQwait("Zlib data", this._length)) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
var data = sock.rQshiftBytes(this._length, false);
|
|
45
|
-
this._inflator.setInput(data);
|
|
46
|
-
for (var ty = y; ty < y + height; ty += ZRLE_TILE_HEIGHT) {
|
|
47
|
-
var th = Math.min(ZRLE_TILE_HEIGHT, y + height - ty);
|
|
48
|
-
for (var tx = x; tx < x + width; tx += ZRLE_TILE_WIDTH) {
|
|
49
|
-
var tw = Math.min(ZRLE_TILE_WIDTH, x + width - tx);
|
|
50
|
-
var tileSize = tw * th;
|
|
51
|
-
var subencoding = this._inflator.inflate(1)[0];
|
|
52
|
-
if (subencoding === 0) {
|
|
53
|
-
// raw data
|
|
54
|
-
var _data = this._readPixels(tileSize);
|
|
55
|
-
display.blitImage(tx, ty, tw, th, _data, 0, false);
|
|
56
|
-
} else if (subencoding === 1) {
|
|
57
|
-
// solid
|
|
58
|
-
var background = this._readPixels(1);
|
|
59
|
-
display.fillRect(tx, ty, tw, th, [background[0], background[1], background[2]]);
|
|
60
|
-
} else if (subencoding >= 2 && subencoding <= 16) {
|
|
61
|
-
var _data2 = this._decodePaletteTile(subencoding, tileSize, tw, th);
|
|
62
|
-
display.blitImage(tx, ty, tw, th, _data2, 0, false);
|
|
63
|
-
} else if (subencoding === 128) {
|
|
64
|
-
var _data3 = this._decodeRLETile(tileSize);
|
|
65
|
-
display.blitImage(tx, ty, tw, th, _data3, 0, false);
|
|
66
|
-
} else if (subencoding >= 130 && subencoding <= 255) {
|
|
67
|
-
var _data4 = this._decodeRLEPaletteTile(subencoding - 128, tileSize);
|
|
68
|
-
display.blitImage(tx, ty, tw, th, _data4, 0, false);
|
|
69
|
-
} else {
|
|
70
|
-
throw new Error('Unknown subencoding: ' + subencoding);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
this._length = 0;
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
}, {
|
|
78
|
-
key: "_getBitsPerPixelInPalette",
|
|
79
|
-
value: function _getBitsPerPixelInPalette(paletteSize) {
|
|
80
|
-
if (paletteSize <= 2) {
|
|
81
|
-
return 1;
|
|
82
|
-
} else if (paletteSize <= 4) {
|
|
83
|
-
return 2;
|
|
84
|
-
} else if (paletteSize <= 16) {
|
|
85
|
-
return 4;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}, {
|
|
89
|
-
key: "_readPixels",
|
|
90
|
-
value: function _readPixels(pixels) {
|
|
91
|
-
var data = this._pixelBuffer;
|
|
92
|
-
var buffer = this._inflator.inflate(3 * pixels);
|
|
93
|
-
for (var i = 0, j = 0; i < pixels * 4; i += 4, j += 3) {
|
|
94
|
-
data[i] = buffer[j];
|
|
95
|
-
data[i + 1] = buffer[j + 1];
|
|
96
|
-
data[i + 2] = buffer[j + 2];
|
|
97
|
-
data[i + 3] = 255; // Add the Alpha
|
|
98
|
-
}
|
|
99
|
-
return data;
|
|
100
|
-
}
|
|
101
|
-
}, {
|
|
102
|
-
key: "_decodePaletteTile",
|
|
103
|
-
value: function _decodePaletteTile(paletteSize, tileSize, tilew, tileh) {
|
|
104
|
-
var data = this._tileBuffer;
|
|
105
|
-
var palette = this._readPixels(paletteSize);
|
|
106
|
-
var bitsPerPixel = this._getBitsPerPixelInPalette(paletteSize);
|
|
107
|
-
var mask = (1 << bitsPerPixel) - 1;
|
|
108
|
-
var offset = 0;
|
|
109
|
-
var encoded = this._inflator.inflate(1)[0];
|
|
110
|
-
for (var y = 0; y < tileh; y++) {
|
|
111
|
-
var shift = 8 - bitsPerPixel;
|
|
112
|
-
for (var x = 0; x < tilew; x++) {
|
|
113
|
-
if (shift < 0) {
|
|
114
|
-
shift = 8 - bitsPerPixel;
|
|
115
|
-
encoded = this._inflator.inflate(1)[0];
|
|
116
|
-
}
|
|
117
|
-
var indexInPalette = encoded >> shift & mask;
|
|
118
|
-
data[offset] = palette[indexInPalette * 4];
|
|
119
|
-
data[offset + 1] = palette[indexInPalette * 4 + 1];
|
|
120
|
-
data[offset + 2] = palette[indexInPalette * 4 + 2];
|
|
121
|
-
data[offset + 3] = palette[indexInPalette * 4 + 3];
|
|
122
|
-
offset += 4;
|
|
123
|
-
shift -= bitsPerPixel;
|
|
124
|
-
}
|
|
125
|
-
if (shift < 8 - bitsPerPixel && y < tileh - 1) {
|
|
126
|
-
encoded = this._inflator.inflate(1)[0];
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return data;
|
|
130
|
-
}
|
|
131
|
-
}, {
|
|
132
|
-
key: "_decodeRLETile",
|
|
133
|
-
value: function _decodeRLETile(tileSize) {
|
|
134
|
-
var data = this._tileBuffer;
|
|
135
|
-
var i = 0;
|
|
136
|
-
while (i < tileSize) {
|
|
137
|
-
var pixel = this._readPixels(1);
|
|
138
|
-
var length = this._readRLELength();
|
|
139
|
-
for (var j = 0; j < length; j++) {
|
|
140
|
-
data[i * 4] = pixel[0];
|
|
141
|
-
data[i * 4 + 1] = pixel[1];
|
|
142
|
-
data[i * 4 + 2] = pixel[2];
|
|
143
|
-
data[i * 4 + 3] = pixel[3];
|
|
144
|
-
i++;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return data;
|
|
148
|
-
}
|
|
149
|
-
}, {
|
|
150
|
-
key: "_decodeRLEPaletteTile",
|
|
151
|
-
value: function _decodeRLEPaletteTile(paletteSize, tileSize) {
|
|
152
|
-
var data = this._tileBuffer;
|
|
153
|
-
|
|
154
|
-
// palette
|
|
155
|
-
var palette = this._readPixels(paletteSize);
|
|
156
|
-
var offset = 0;
|
|
157
|
-
while (offset < tileSize) {
|
|
158
|
-
var indexInPalette = this._inflator.inflate(1)[0];
|
|
159
|
-
var length = 1;
|
|
160
|
-
if (indexInPalette >= 128) {
|
|
161
|
-
indexInPalette -= 128;
|
|
162
|
-
length = this._readRLELength();
|
|
163
|
-
}
|
|
164
|
-
if (indexInPalette > paletteSize) {
|
|
165
|
-
throw new Error('Too big index in palette: ' + indexInPalette + ', palette size: ' + paletteSize);
|
|
166
|
-
}
|
|
167
|
-
if (offset + length > tileSize) {
|
|
168
|
-
throw new Error('Too big rle length in palette mode: ' + length + ', allowed length is: ' + (tileSize - offset));
|
|
169
|
-
}
|
|
170
|
-
for (var j = 0; j < length; j++) {
|
|
171
|
-
data[offset * 4] = palette[indexInPalette * 4];
|
|
172
|
-
data[offset * 4 + 1] = palette[indexInPalette * 4 + 1];
|
|
173
|
-
data[offset * 4 + 2] = palette[indexInPalette * 4 + 2];
|
|
174
|
-
data[offset * 4 + 3] = palette[indexInPalette * 4 + 3];
|
|
175
|
-
offset++;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return data;
|
|
179
|
-
}
|
|
180
|
-
}, {
|
|
181
|
-
key: "_readRLELength",
|
|
182
|
-
value: function _readRLELength() {
|
|
183
|
-
var length = 0;
|
|
184
|
-
var current = 0;
|
|
185
|
-
do {
|
|
186
|
-
current = this._inflator.inflate(1)[0];
|
|
187
|
-
length += current;
|
|
188
|
-
} while (current === 255);
|
|
189
|
-
return length + 1;
|
|
190
|
-
}
|
|
191
|
-
}]);
|
|
192
|
-
}();
|
package/lib/deflator.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _deflate2 = require("../lib/vendor/pako/lib/zlib/deflate.js");
|
|
8
|
-
var _zstream = _interopRequireDefault(require("../lib/vendor/pako/lib/zlib/zstream.js"));
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
-
function _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); }
|
|
11
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
12
|
-
function _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); } }
|
|
13
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
14
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
-
function _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 client
|
|
17
|
-
* Copyright (C) 2020 The noVNC authors
|
|
18
|
-
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
19
|
-
*
|
|
20
|
-
* See README.md for usage and integration instructions.
|
|
21
|
-
*/
|
|
22
|
-
var Deflator = exports["default"] = /*#__PURE__*/function () {
|
|
23
|
-
function Deflator() {
|
|
24
|
-
_classCallCheck(this, Deflator);
|
|
25
|
-
this.strm = new _zstream["default"]();
|
|
26
|
-
this.chunkSize = 1024 * 10 * 10;
|
|
27
|
-
this.outputBuffer = new Uint8Array(this.chunkSize);
|
|
28
|
-
(0, _deflate2.deflateInit)(this.strm, _deflate2.Z_DEFAULT_COMPRESSION);
|
|
29
|
-
}
|
|
30
|
-
return _createClass(Deflator, [{
|
|
31
|
-
key: "deflate",
|
|
32
|
-
value: function deflate(inData) {
|
|
33
|
-
/* eslint-disable camelcase */
|
|
34
|
-
this.strm.input = inData;
|
|
35
|
-
this.strm.avail_in = this.strm.input.length;
|
|
36
|
-
this.strm.next_in = 0;
|
|
37
|
-
this.strm.output = this.outputBuffer;
|
|
38
|
-
this.strm.avail_out = this.chunkSize;
|
|
39
|
-
this.strm.next_out = 0;
|
|
40
|
-
/* eslint-enable camelcase */
|
|
41
|
-
|
|
42
|
-
var lastRet = (0, _deflate2.deflate)(this.strm, _deflate2.Z_FULL_FLUSH);
|
|
43
|
-
var outData = new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
|
|
44
|
-
if (lastRet < 0) {
|
|
45
|
-
throw new Error("zlib deflate failed");
|
|
46
|
-
}
|
|
47
|
-
if (this.strm.avail_in > 0) {
|
|
48
|
-
// Read chunks until done
|
|
49
|
-
|
|
50
|
-
var chunks = [outData];
|
|
51
|
-
var totalLen = outData.length;
|
|
52
|
-
do {
|
|
53
|
-
/* eslint-disable camelcase */
|
|
54
|
-
this.strm.output = new Uint8Array(this.chunkSize);
|
|
55
|
-
this.strm.next_out = 0;
|
|
56
|
-
this.strm.avail_out = this.chunkSize;
|
|
57
|
-
/* eslint-enable camelcase */
|
|
58
|
-
|
|
59
|
-
lastRet = (0, _deflate2.deflate)(this.strm, _deflate2.Z_FULL_FLUSH);
|
|
60
|
-
if (lastRet < 0) {
|
|
61
|
-
throw new Error("zlib deflate failed");
|
|
62
|
-
}
|
|
63
|
-
var chunk = new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
|
|
64
|
-
totalLen += chunk.length;
|
|
65
|
-
chunks.push(chunk);
|
|
66
|
-
} while (this.strm.avail_in > 0);
|
|
67
|
-
|
|
68
|
-
// Combine chunks into a single data
|
|
69
|
-
|
|
70
|
-
var newData = new Uint8Array(totalLen);
|
|
71
|
-
var offset = 0;
|
|
72
|
-
for (var i = 0; i < chunks.length; i++) {
|
|
73
|
-
newData.set(chunks[i], offset);
|
|
74
|
-
offset += chunks[i].length;
|
|
75
|
-
}
|
|
76
|
-
outData = newData;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/* eslint-disable camelcase */
|
|
80
|
-
this.strm.input = null;
|
|
81
|
-
this.strm.avail_in = 0;
|
|
82
|
-
this.strm.next_in = 0;
|
|
83
|
-
/* eslint-enable camelcase */
|
|
84
|
-
|
|
85
|
-
return outData;
|
|
86
|
-
}
|
|
87
|
-
}]);
|
|
88
|
-
}();
|