@novnc/novnc 1.2.0 → 1.3.0-g65d6357
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/LICENSE.txt +0 -6
- package/README.md +9 -4
- package/core/decoders/copyrect.js +5 -0
- package/core/decoders/hextile.js +57 -3
- package/core/decoders/raw.js +12 -2
- package/core/decoders/tight.js +24 -8
- package/core/decoders/zrle.js +185 -0
- package/core/display.js +9 -151
- package/core/encodings.js +2 -0
- package/core/input/domkeytable.js +25 -21
- package/core/input/keyboard.js +12 -127
- package/core/input/util.js +18 -35
- package/core/input/vkeys.js +0 -1
- package/core/input/xtscancodes.js +5 -3
- package/core/rfb.js +119 -109
- package/core/util/browser.js +0 -17
- package/core/util/cursor.js +1 -11
- package/core/util/events.js +0 -4
- package/core/websock.js +76 -17
- package/docs/API.md +10 -3
- package/docs/LIBRARY.md +3 -7
- package/lib/base64.js +4 -4
- package/lib/decoders/copyrect.js +7 -2
- package/lib/decoders/hextile.js +63 -7
- package/lib/decoders/raw.js +13 -4
- package/lib/decoders/rre.js +2 -2
- package/lib/decoders/tight.js +38 -20
- package/lib/decoders/tightpng.js +8 -8
- package/lib/decoders/zrle.js +234 -0
- package/lib/deflator.js +4 -4
- package/lib/des.js +2 -2
- package/lib/display.js +45 -212
- package/lib/encodings.js +4 -0
- package/lib/inflator.js +4 -4
- package/lib/input/domkeytable.js +197 -194
- package/lib/input/fixedkeys.js +2 -2
- package/lib/input/gesturehandler.js +2 -2
- package/lib/input/keyboard.js +38 -158
- package/lib/input/keysym.js +2 -2
- package/lib/input/keysymdef.js +2 -2
- package/lib/input/util.js +34 -79
- package/lib/input/vkeys.js +2 -4
- package/lib/input/xtscancodes.js +11 -5
- package/lib/rfb.js +295 -285
- package/lib/util/browser.js +8 -26
- package/lib/util/cursor.js +4 -16
- package/lib/util/events.js +3 -5
- package/lib/util/eventtarget.js +3 -3
- package/lib/util/int.js +1 -1
- package/lib/util/logging.js +2 -2
- package/lib/vendor/pako/lib/utils/common.js +2 -2
- package/lib/vendor/pako/lib/zlib/adler32.js +1 -1
- package/lib/vendor/pako/lib/zlib/constants.js +2 -2
- package/lib/vendor/pako/lib/zlib/crc32.js +1 -1
- package/lib/vendor/pako/lib/zlib/deflate.js +113 -112
- package/lib/vendor/pako/lib/zlib/gzheader.js +1 -1
- package/lib/vendor/pako/lib/zlib/inffast.js +5 -5
- package/lib/vendor/pako/lib/zlib/inflate.js +50 -48
- package/lib/vendor/pako/lib/zlib/inftrees.js +3 -3
- package/lib/vendor/pako/lib/zlib/messages.js +2 -2
- package/lib/vendor/pako/lib/zlib/trees.js +4 -4
- package/lib/vendor/pako/lib/zlib/zstream.js +1 -1
- package/lib/websock.js +105 -44
- package/package.json +2 -7
- package/core/util/polyfill.js +0 -61
- package/lib/util/polyfill.js +0 -72
- package/lib/vendor/promise.js +0 -255
package/lib/base64.js
CHANGED
|
@@ -5,13 +5,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports
|
|
8
|
+
exports["default"] = void 0;
|
|
9
9
|
|
|
10
10
|
var Log = _interopRequireWildcard(require("./util/logging.js"));
|
|
11
11
|
|
|
12
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
13
|
|
|
14
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
|
|
16
16
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
17
17
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
@@ -112,4 +112,4 @@ var _default = {
|
|
|
112
112
|
};
|
|
113
113
|
/* End of Base64 namespace */
|
|
114
114
|
|
|
115
|
-
exports
|
|
115
|
+
exports["default"] = _default;
|
package/lib/decoders/copyrect.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports["default"] = void 0;
|
|
7
7
|
|
|
8
8
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
9
|
|
|
@@ -33,6 +33,11 @@ var CopyRectDecoder = /*#__PURE__*/function () {
|
|
|
33
33
|
|
|
34
34
|
var deltaX = sock.rQshift16();
|
|
35
35
|
var deltaY = sock.rQshift16();
|
|
36
|
+
|
|
37
|
+
if (width === 0 || height === 0) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
36
41
|
display.copyImage(deltaX, deltaY, x, y, width, height);
|
|
37
42
|
return true;
|
|
38
43
|
}
|
|
@@ -41,4 +46,4 @@ var CopyRectDecoder = /*#__PURE__*/function () {
|
|
|
41
46
|
return CopyRectDecoder;
|
|
42
47
|
}();
|
|
43
48
|
|
|
44
|
-
exports
|
|
49
|
+
exports["default"] = CopyRectDecoder;
|
package/lib/decoders/hextile.js
CHANGED
|
@@ -5,13 +5,13 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports
|
|
8
|
+
exports["default"] = void 0;
|
|
9
9
|
|
|
10
10
|
var Log = _interopRequireWildcard(require("../util/logging.js"));
|
|
11
11
|
|
|
12
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
13
|
|
|
14
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
|
|
16
16
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
17
|
|
|
@@ -25,6 +25,7 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
25
25
|
|
|
26
26
|
this._tiles = 0;
|
|
27
27
|
this._lastsubencoding = 0;
|
|
28
|
+
this._tileBuffer = new Uint8Array(16 * 16 * 4);
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
_createClass(HextileDecoder, [{
|
|
@@ -110,6 +111,12 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
110
111
|
}
|
|
111
112
|
} else if (subencoding & 0x01) {
|
|
112
113
|
// Raw
|
|
114
|
+
var pixels = tw * th; // Max sure the image is fully opaque
|
|
115
|
+
|
|
116
|
+
for (var i = 0; i < pixels; i++) {
|
|
117
|
+
rQ[rQi + i * 4 + 3] = 255;
|
|
118
|
+
}
|
|
119
|
+
|
|
113
120
|
display.blitImage(tx, ty, tw, th, rQ, rQi);
|
|
114
121
|
rQi += bytes - 1;
|
|
115
122
|
} else {
|
|
@@ -125,7 +132,7 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
125
132
|
rQi += 4;
|
|
126
133
|
}
|
|
127
134
|
|
|
128
|
-
|
|
135
|
+
this._startTile(tx, ty, tw, th, this._background);
|
|
129
136
|
|
|
130
137
|
if (subencoding & 0x08) {
|
|
131
138
|
// AnySubrects
|
|
@@ -151,11 +158,12 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
151
158
|
rQi++;
|
|
152
159
|
var sw = (wh >> 4) + 1;
|
|
153
160
|
var sh = (wh & 0x0f) + 1;
|
|
154
|
-
|
|
161
|
+
|
|
162
|
+
this._subTile(sx, sy, sw, sh, color);
|
|
155
163
|
}
|
|
156
164
|
}
|
|
157
165
|
|
|
158
|
-
|
|
166
|
+
this._finishTile(display);
|
|
159
167
|
}
|
|
160
168
|
|
|
161
169
|
sock.rQi = rQi;
|
|
@@ -164,10 +172,58 @@ var HextileDecoder = /*#__PURE__*/function () {
|
|
|
164
172
|
}
|
|
165
173
|
|
|
166
174
|
return true;
|
|
175
|
+
} // start updating a tile
|
|
176
|
+
|
|
177
|
+
}, {
|
|
178
|
+
key: "_startTile",
|
|
179
|
+
value: function _startTile(x, y, width, height, color) {
|
|
180
|
+
this._tileX = x;
|
|
181
|
+
this._tileY = y;
|
|
182
|
+
this._tileW = width;
|
|
183
|
+
this._tileH = height;
|
|
184
|
+
var red = color[0];
|
|
185
|
+
var green = color[1];
|
|
186
|
+
var blue = color[2];
|
|
187
|
+
var data = this._tileBuffer;
|
|
188
|
+
|
|
189
|
+
for (var i = 0; i < width * height * 4; i += 4) {
|
|
190
|
+
data[i] = red;
|
|
191
|
+
data[i + 1] = green;
|
|
192
|
+
data[i + 2] = blue;
|
|
193
|
+
data[i + 3] = 255;
|
|
194
|
+
}
|
|
195
|
+
} // update sub-rectangle of the current tile
|
|
196
|
+
|
|
197
|
+
}, {
|
|
198
|
+
key: "_subTile",
|
|
199
|
+
value: function _subTile(x, y, w, h, color) {
|
|
200
|
+
var red = color[0];
|
|
201
|
+
var green = color[1];
|
|
202
|
+
var blue = color[2];
|
|
203
|
+
var xend = x + w;
|
|
204
|
+
var yend = y + h;
|
|
205
|
+
var data = this._tileBuffer;
|
|
206
|
+
var width = this._tileW;
|
|
207
|
+
|
|
208
|
+
for (var j = y; j < yend; j++) {
|
|
209
|
+
for (var i = x; i < xend; i++) {
|
|
210
|
+
var p = (i + j * width) * 4;
|
|
211
|
+
data[p] = red;
|
|
212
|
+
data[p + 1] = green;
|
|
213
|
+
data[p + 2] = blue;
|
|
214
|
+
data[p + 3] = 255;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
} // draw the current tile to the screen
|
|
218
|
+
|
|
219
|
+
}, {
|
|
220
|
+
key: "_finishTile",
|
|
221
|
+
value: function _finishTile(display) {
|
|
222
|
+
display.blitImage(this._tileX, this._tileY, this._tileW, this._tileH, this._tileBuffer, 0);
|
|
167
223
|
}
|
|
168
224
|
}]);
|
|
169
225
|
|
|
170
226
|
return HextileDecoder;
|
|
171
227
|
}();
|
|
172
228
|
|
|
173
|
-
exports
|
|
229
|
+
exports["default"] = HextileDecoder;
|
package/lib/decoders/raw.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports["default"] = void 0;
|
|
7
7
|
|
|
8
8
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
9
|
|
|
@@ -29,6 +29,10 @@ var RawDecoder = /*#__PURE__*/function () {
|
|
|
29
29
|
_createClass(RawDecoder, [{
|
|
30
30
|
key: "decodeRect",
|
|
31
31
|
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
32
|
+
if (width === 0 || height === 0) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
if (this._lines === 0) {
|
|
33
37
|
this._lines = height;
|
|
34
38
|
}
|
|
@@ -42,22 +46,27 @@ var RawDecoder = /*#__PURE__*/function () {
|
|
|
42
46
|
|
|
43
47
|
var curY = y + (height - this._lines);
|
|
44
48
|
var currHeight = Math.min(this._lines, Math.floor(sock.rQlen / bytesPerLine));
|
|
49
|
+
var pixels = width * currHeight;
|
|
45
50
|
var data = sock.rQ;
|
|
46
51
|
var index = sock.rQi; // Convert data if needed
|
|
47
52
|
|
|
48
53
|
if (depth == 8) {
|
|
49
|
-
var pixels = width * currHeight;
|
|
50
54
|
var newdata = new Uint8Array(pixels * 4);
|
|
51
55
|
|
|
52
56
|
for (var i = 0; i < pixels; i++) {
|
|
53
57
|
newdata[i * 4 + 0] = (data[index + i] >> 0 & 0x3) * 255 / 3;
|
|
54
58
|
newdata[i * 4 + 1] = (data[index + i] >> 2 & 0x3) * 255 / 3;
|
|
55
59
|
newdata[i * 4 + 2] = (data[index + i] >> 4 & 0x3) * 255 / 3;
|
|
56
|
-
newdata[i * 4 +
|
|
60
|
+
newdata[i * 4 + 3] = 255;
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
data = newdata;
|
|
60
64
|
index = 0;
|
|
65
|
+
} // Max sure the image is fully opaque
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
for (var _i = 0; _i < pixels; _i++) {
|
|
69
|
+
data[_i * 4 + 3] = 255;
|
|
61
70
|
}
|
|
62
71
|
|
|
63
72
|
display.blitImage(x, curY, width, currHeight, data, index);
|
|
@@ -75,4 +84,4 @@ var RawDecoder = /*#__PURE__*/function () {
|
|
|
75
84
|
return RawDecoder;
|
|
76
85
|
}();
|
|
77
86
|
|
|
78
|
-
exports
|
|
87
|
+
exports["default"] = RawDecoder;
|
package/lib/decoders/rre.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports["default"] = void 0;
|
|
7
7
|
|
|
8
8
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
9
|
|
|
@@ -62,4 +62,4 @@ var RREDecoder = /*#__PURE__*/function () {
|
|
|
62
62
|
return RREDecoder;
|
|
63
63
|
}();
|
|
64
64
|
|
|
65
|
-
exports
|
|
65
|
+
exports["default"] = RREDecoder;
|
package/lib/decoders/tight.js
CHANGED
|
@@ -5,17 +5,17 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports
|
|
8
|
+
exports["default"] = void 0;
|
|
9
9
|
|
|
10
10
|
var Log = _interopRequireWildcard(require("../util/logging.js"));
|
|
11
11
|
|
|
12
12
|
var _inflator = _interopRequireDefault(require("../inflator.js"));
|
|
13
13
|
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
15
|
|
|
16
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
17
|
|
|
18
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
19
|
|
|
20
20
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
21
|
|
|
@@ -36,7 +36,7 @@ var TightDecoder = /*#__PURE__*/function () {
|
|
|
36
36
|
this._zlibs = [];
|
|
37
37
|
|
|
38
38
|
for (var i = 0; i < 4; i++) {
|
|
39
|
-
this._zlibs[i] = new _inflator
|
|
39
|
+
this._zlibs[i] = new _inflator["default"]();
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -70,7 +70,7 @@ var TightDecoder = /*#__PURE__*/function () {
|
|
|
70
70
|
ret = this._jpegRect(x, y, width, height, sock, display, depth);
|
|
71
71
|
} else if (this._ctl === 0x0A) {
|
|
72
72
|
ret = this._pngRect(x, y, width, height, sock, display, depth);
|
|
73
|
-
} else if ((this._ctl &
|
|
73
|
+
} else if ((this._ctl & 0x08) == 0) {
|
|
74
74
|
ret = this._basicRect(this._ctl, x, y, width, height, sock, display, depth);
|
|
75
75
|
} else {
|
|
76
76
|
throw new Error("Illegal tight compression received (ctl: " + this._ctl + ")");
|
|
@@ -91,7 +91,7 @@ var TightDecoder = /*#__PURE__*/function () {
|
|
|
91
91
|
|
|
92
92
|
var rQi = sock.rQi;
|
|
93
93
|
var rQ = sock.rQ;
|
|
94
|
-
display.fillRect(x, y, width, height, [rQ[rQi
|
|
94
|
+
display.fillRect(x, y, width, height, [rQ[rQi], rQ[rQi + 1], rQ[rQi + 2]], false);
|
|
95
95
|
sock.rQskipBytes(3);
|
|
96
96
|
return true;
|
|
97
97
|
}
|
|
@@ -163,6 +163,10 @@ var TightDecoder = /*#__PURE__*/function () {
|
|
|
163
163
|
var uncompressedSize = width * height * 3;
|
|
164
164
|
var data;
|
|
165
165
|
|
|
166
|
+
if (uncompressedSize === 0) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
|
|
166
170
|
if (uncompressedSize < 12) {
|
|
167
171
|
if (sock.rQwait("TIGHT", uncompressedSize)) {
|
|
168
172
|
return false;
|
|
@@ -183,7 +187,16 @@ var TightDecoder = /*#__PURE__*/function () {
|
|
|
183
187
|
this._zlibs[streamId].setInput(null);
|
|
184
188
|
}
|
|
185
189
|
|
|
186
|
-
|
|
190
|
+
var rgbx = new Uint8Array(width * height * 4);
|
|
191
|
+
|
|
192
|
+
for (var i = 0, j = 0; i < width * height * 4; i += 4, j += 3) {
|
|
193
|
+
rgbx[i] = data[j];
|
|
194
|
+
rgbx[i + 1] = data[j + 1];
|
|
195
|
+
rgbx[i + 2] = data[j + 2];
|
|
196
|
+
rgbx[i + 3] = 255; // Alpha
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
display.blitImage(x, y, width, height, rgbx, 0, false);
|
|
187
200
|
return true;
|
|
188
201
|
}
|
|
189
202
|
}, {
|
|
@@ -211,6 +224,10 @@ var TightDecoder = /*#__PURE__*/function () {
|
|
|
211
224
|
var uncompressedSize = rowSize * height;
|
|
212
225
|
var data;
|
|
213
226
|
|
|
227
|
+
if (uncompressedSize === 0) {
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
|
|
214
231
|
if (uncompressedSize < 12) {
|
|
215
232
|
if (sock.rQwait("TIGHT", uncompressedSize)) {
|
|
216
233
|
return false;
|
|
@@ -277,7 +294,7 @@ var TightDecoder = /*#__PURE__*/function () {
|
|
|
277
294
|
}
|
|
278
295
|
}
|
|
279
296
|
|
|
280
|
-
display.
|
|
297
|
+
display.blitImage(x, y, width, height, dest, 0, false);
|
|
281
298
|
}
|
|
282
299
|
}, {
|
|
283
300
|
key: "_paletteRect",
|
|
@@ -295,7 +312,7 @@ var TightDecoder = /*#__PURE__*/function () {
|
|
|
295
312
|
dest[i + 3] = 255;
|
|
296
313
|
}
|
|
297
314
|
|
|
298
|
-
display.
|
|
315
|
+
display.blitImage(x, y, width, height, dest, 0, false);
|
|
299
316
|
}
|
|
300
317
|
}, {
|
|
301
318
|
key: "_gradientFilter",
|
|
@@ -310,17 +327,18 @@ var TightDecoder = /*#__PURE__*/function () {
|
|
|
310
327
|
return null;
|
|
311
328
|
}
|
|
312
329
|
|
|
313
|
-
var
|
|
314
|
-
|
|
315
|
-
|
|
330
|
+
var _byte;
|
|
331
|
+
|
|
332
|
+
_byte = sock.rQshift8();
|
|
333
|
+
this._len = _byte & 0x7f;
|
|
316
334
|
|
|
317
|
-
if (
|
|
318
|
-
|
|
319
|
-
this._len |= (
|
|
335
|
+
if (_byte & 0x80) {
|
|
336
|
+
_byte = sock.rQshift8();
|
|
337
|
+
this._len |= (_byte & 0x7f) << 7;
|
|
320
338
|
|
|
321
|
-
if (
|
|
322
|
-
|
|
323
|
-
this._len |=
|
|
339
|
+
if (_byte & 0x80) {
|
|
340
|
+
_byte = sock.rQshift8();
|
|
341
|
+
this._len |= _byte << 14;
|
|
324
342
|
}
|
|
325
343
|
}
|
|
326
344
|
}
|
|
@@ -347,4 +365,4 @@ var TightDecoder = /*#__PURE__*/function () {
|
|
|
347
365
|
return TightDecoder;
|
|
348
366
|
}();
|
|
349
367
|
|
|
350
|
-
exports
|
|
368
|
+
exports["default"] = TightDecoder;
|
package/lib/decoders/tightpng.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports
|
|
8
|
+
exports["default"] = void 0;
|
|
7
9
|
|
|
8
10
|
var _tight = _interopRequireDefault(require("./tight.js"));
|
|
9
11
|
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
13
|
|
|
14
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
15
|
|
|
@@ -23,11 +23,11 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
|
|
|
23
23
|
|
|
24
24
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
25
25
|
|
|
26
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
26
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
27
27
|
|
|
28
28
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
29
29
|
|
|
30
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
30
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
31
31
|
|
|
32
32
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
33
33
|
|
|
@@ -62,6 +62,6 @@ var TightPNGDecoder = /*#__PURE__*/function (_TightDecoder) {
|
|
|
62
62
|
}]);
|
|
63
63
|
|
|
64
64
|
return TightPNGDecoder;
|
|
65
|
-
}(_tight
|
|
65
|
+
}(_tight["default"]);
|
|
66
66
|
|
|
67
|
-
exports
|
|
67
|
+
exports["default"] = TightPNGDecoder;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _inflator = _interopRequireDefault(require("../inflator.js"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
+
|
|
12
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
+
|
|
14
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
15
|
+
|
|
16
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
17
|
+
|
|
18
|
+
var ZRLE_TILE_WIDTH = 64;
|
|
19
|
+
var ZRLE_TILE_HEIGHT = 64;
|
|
20
|
+
|
|
21
|
+
var ZRLEDecoder = /*#__PURE__*/function () {
|
|
22
|
+
function ZRLEDecoder() {
|
|
23
|
+
_classCallCheck(this, ZRLEDecoder);
|
|
24
|
+
|
|
25
|
+
this._length = 0;
|
|
26
|
+
this._inflator = new _inflator["default"]();
|
|
27
|
+
this._pixelBuffer = new Uint8Array(ZRLE_TILE_WIDTH * ZRLE_TILE_HEIGHT * 4);
|
|
28
|
+
this._tileBuffer = new Uint8Array(ZRLE_TILE_WIDTH * ZRLE_TILE_HEIGHT * 4);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_createClass(ZRLEDecoder, [{
|
|
32
|
+
key: "decodeRect",
|
|
33
|
+
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
34
|
+
if (this._length === 0) {
|
|
35
|
+
if (sock.rQwait("ZLib data length", 4)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this._length = sock.rQshift32();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (sock.rQwait("Zlib data", this._length)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var data = sock.rQshiftBytes(this._length);
|
|
47
|
+
|
|
48
|
+
this._inflator.setInput(data);
|
|
49
|
+
|
|
50
|
+
for (var ty = y; ty < y + height; ty += ZRLE_TILE_HEIGHT) {
|
|
51
|
+
var th = Math.min(ZRLE_TILE_HEIGHT, y + height - ty);
|
|
52
|
+
|
|
53
|
+
for (var tx = x; tx < x + width; tx += ZRLE_TILE_WIDTH) {
|
|
54
|
+
var tw = Math.min(ZRLE_TILE_WIDTH, x + width - tx);
|
|
55
|
+
var tileSize = tw * th;
|
|
56
|
+
|
|
57
|
+
var subencoding = this._inflator.inflate(1)[0];
|
|
58
|
+
|
|
59
|
+
if (subencoding === 0) {
|
|
60
|
+
// raw data
|
|
61
|
+
var _data = this._readPixels(tileSize);
|
|
62
|
+
|
|
63
|
+
display.blitImage(tx, ty, tw, th, _data, 0, false);
|
|
64
|
+
} else if (subencoding === 1) {
|
|
65
|
+
// solid
|
|
66
|
+
var background = this._readPixels(1);
|
|
67
|
+
|
|
68
|
+
display.fillRect(tx, ty, tw, th, [background[0], background[1], background[2]]);
|
|
69
|
+
} else if (subencoding >= 2 && subencoding <= 16) {
|
|
70
|
+
var _data2 = this._decodePaletteTile(subencoding, tileSize, tw, th);
|
|
71
|
+
|
|
72
|
+
display.blitImage(tx, ty, tw, th, _data2, 0, false);
|
|
73
|
+
} else if (subencoding === 128) {
|
|
74
|
+
var _data3 = this._decodeRLETile(tileSize);
|
|
75
|
+
|
|
76
|
+
display.blitImage(tx, ty, tw, th, _data3, 0, false);
|
|
77
|
+
} else if (subencoding >= 130 && subencoding <= 255) {
|
|
78
|
+
var _data4 = this._decodeRLEPaletteTile(subencoding - 128, tileSize);
|
|
79
|
+
|
|
80
|
+
display.blitImage(tx, ty, tw, th, _data4, 0, false);
|
|
81
|
+
} else {
|
|
82
|
+
throw new Error('Unknown subencoding: ' + subencoding);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
this._length = 0;
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "_getBitsPerPixelInPalette",
|
|
92
|
+
value: function _getBitsPerPixelInPalette(paletteSize) {
|
|
93
|
+
if (paletteSize <= 2) {
|
|
94
|
+
return 1;
|
|
95
|
+
} else if (paletteSize <= 4) {
|
|
96
|
+
return 2;
|
|
97
|
+
} else if (paletteSize <= 16) {
|
|
98
|
+
return 4;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "_readPixels",
|
|
103
|
+
value: function _readPixels(pixels) {
|
|
104
|
+
var data = this._pixelBuffer;
|
|
105
|
+
|
|
106
|
+
var buffer = this._inflator.inflate(3 * pixels);
|
|
107
|
+
|
|
108
|
+
for (var i = 0, j = 0; i < pixels * 4; i += 4, j += 3) {
|
|
109
|
+
data[i] = buffer[j];
|
|
110
|
+
data[i + 1] = buffer[j + 1];
|
|
111
|
+
data[i + 2] = buffer[j + 2];
|
|
112
|
+
data[i + 3] = 255; // Add the Alpha
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return data;
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "_decodePaletteTile",
|
|
119
|
+
value: function _decodePaletteTile(paletteSize, tileSize, tilew, tileh) {
|
|
120
|
+
var data = this._tileBuffer;
|
|
121
|
+
|
|
122
|
+
var palette = this._readPixels(paletteSize);
|
|
123
|
+
|
|
124
|
+
var bitsPerPixel = this._getBitsPerPixelInPalette(paletteSize);
|
|
125
|
+
|
|
126
|
+
var mask = (1 << bitsPerPixel) - 1;
|
|
127
|
+
var offset = 0;
|
|
128
|
+
|
|
129
|
+
var encoded = this._inflator.inflate(1)[0];
|
|
130
|
+
|
|
131
|
+
for (var y = 0; y < tileh; y++) {
|
|
132
|
+
var shift = 8 - bitsPerPixel;
|
|
133
|
+
|
|
134
|
+
for (var x = 0; x < tilew; x++) {
|
|
135
|
+
if (shift < 0) {
|
|
136
|
+
shift = 8 - bitsPerPixel;
|
|
137
|
+
encoded = this._inflator.inflate(1)[0];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
var indexInPalette = encoded >> shift & mask;
|
|
141
|
+
data[offset] = palette[indexInPalette * 4];
|
|
142
|
+
data[offset + 1] = palette[indexInPalette * 4 + 1];
|
|
143
|
+
data[offset + 2] = palette[indexInPalette * 4 + 2];
|
|
144
|
+
data[offset + 3] = palette[indexInPalette * 4 + 3];
|
|
145
|
+
offset += 4;
|
|
146
|
+
shift -= bitsPerPixel;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (shift < 8 - bitsPerPixel && y < tileh - 1) {
|
|
150
|
+
encoded = this._inflator.inflate(1)[0];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return data;
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "_decodeRLETile",
|
|
158
|
+
value: function _decodeRLETile(tileSize) {
|
|
159
|
+
var data = this._tileBuffer;
|
|
160
|
+
var i = 0;
|
|
161
|
+
|
|
162
|
+
while (i < tileSize) {
|
|
163
|
+
var pixel = this._readPixels(1);
|
|
164
|
+
|
|
165
|
+
var length = this._readRLELength();
|
|
166
|
+
|
|
167
|
+
for (var j = 0; j < length; j++) {
|
|
168
|
+
data[i * 4] = pixel[0];
|
|
169
|
+
data[i * 4 + 1] = pixel[1];
|
|
170
|
+
data[i * 4 + 2] = pixel[2];
|
|
171
|
+
data[i * 4 + 3] = pixel[3];
|
|
172
|
+
i++;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return data;
|
|
177
|
+
}
|
|
178
|
+
}, {
|
|
179
|
+
key: "_decodeRLEPaletteTile",
|
|
180
|
+
value: function _decodeRLEPaletteTile(paletteSize, tileSize) {
|
|
181
|
+
var data = this._tileBuffer; // palette
|
|
182
|
+
|
|
183
|
+
var palette = this._readPixels(paletteSize);
|
|
184
|
+
|
|
185
|
+
var offset = 0;
|
|
186
|
+
|
|
187
|
+
while (offset < tileSize) {
|
|
188
|
+
var indexInPalette = this._inflator.inflate(1)[0];
|
|
189
|
+
|
|
190
|
+
var length = 1;
|
|
191
|
+
|
|
192
|
+
if (indexInPalette >= 128) {
|
|
193
|
+
indexInPalette -= 128;
|
|
194
|
+
length = this._readRLELength();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (indexInPalette > paletteSize) {
|
|
198
|
+
throw new Error('Too big index in palette: ' + indexInPalette + ', palette size: ' + paletteSize);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (offset + length > tileSize) {
|
|
202
|
+
throw new Error('Too big rle length in palette mode: ' + length + ', allowed length is: ' + (tileSize - offset));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
for (var j = 0; j < length; j++) {
|
|
206
|
+
data[offset * 4] = palette[indexInPalette * 4];
|
|
207
|
+
data[offset * 4 + 1] = palette[indexInPalette * 4 + 1];
|
|
208
|
+
data[offset * 4 + 2] = palette[indexInPalette * 4 + 2];
|
|
209
|
+
data[offset * 4 + 3] = palette[indexInPalette * 4 + 3];
|
|
210
|
+
offset++;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return data;
|
|
215
|
+
}
|
|
216
|
+
}, {
|
|
217
|
+
key: "_readRLELength",
|
|
218
|
+
value: function _readRLELength() {
|
|
219
|
+
var length = 0;
|
|
220
|
+
var current = 0;
|
|
221
|
+
|
|
222
|
+
do {
|
|
223
|
+
current = this._inflator.inflate(1)[0];
|
|
224
|
+
length += current;
|
|
225
|
+
} while (current === 255);
|
|
226
|
+
|
|
227
|
+
return length + 1;
|
|
228
|
+
}
|
|
229
|
+
}]);
|
|
230
|
+
|
|
231
|
+
return ZRLEDecoder;
|
|
232
|
+
}();
|
|
233
|
+
|
|
234
|
+
exports["default"] = ZRLEDecoder;
|