@novnc/novnc 1.2.0-test → 1.3.0-g7ad4e60
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 +4 -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/display.js +9 -151
- 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 +116 -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/deflator.js +4 -4
- package/lib/des.js +2 -2
- package/lib/display.js +45 -212
- 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 +292 -286
- 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/core/util/browser.js
CHANGED
|
@@ -45,15 +45,6 @@ try {
|
|
|
45
45
|
|
|
46
46
|
export const supportsCursorURIs = _supportsCursorURIs;
|
|
47
47
|
|
|
48
|
-
let _supportsImageMetadata = false;
|
|
49
|
-
try {
|
|
50
|
-
new ImageData(new Uint8ClampedArray(4), 1, 1);
|
|
51
|
-
_supportsImageMetadata = true;
|
|
52
|
-
} catch (ex) {
|
|
53
|
-
// ignore failure
|
|
54
|
-
}
|
|
55
|
-
export const supportsImageMetadata = _supportsImageMetadata;
|
|
56
|
-
|
|
57
48
|
let _hasScrollbarGutter = true;
|
|
58
49
|
try {
|
|
59
50
|
// Create invisible container
|
|
@@ -106,14 +97,6 @@ export function isSafari() {
|
|
|
106
97
|
navigator.userAgent.indexOf('Chrome') === -1);
|
|
107
98
|
}
|
|
108
99
|
|
|
109
|
-
export function isIE() {
|
|
110
|
-
return navigator && !!(/trident/i).exec(navigator.userAgent);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export function isEdge() {
|
|
114
|
-
return navigator && !!(/edge/i).exec(navigator.userAgent);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
100
|
export function isFirefox() {
|
|
118
101
|
return navigator && !!(/firefox/i).exec(navigator.userAgent);
|
|
119
102
|
}
|
package/core/util/cursor.js
CHANGED
|
@@ -43,9 +43,6 @@ export default class Cursor {
|
|
|
43
43
|
if (useFallback) {
|
|
44
44
|
document.body.appendChild(this._canvas);
|
|
45
45
|
|
|
46
|
-
// FIXME: These don't fire properly except for mouse
|
|
47
|
-
/// movement in IE. We want to also capture element
|
|
48
|
-
// movement, size changes, visibility, etc.
|
|
49
46
|
const options = { capture: true, passive: true };
|
|
50
47
|
this._target.addEventListener('mouseover', this._eventHandlers.mouseover, options);
|
|
51
48
|
this._target.addEventListener('mouseleave', this._eventHandlers.mouseleave, options);
|
|
@@ -90,14 +87,7 @@ export default class Cursor {
|
|
|
90
87
|
this._canvas.width = w;
|
|
91
88
|
this._canvas.height = h;
|
|
92
89
|
|
|
93
|
-
let img;
|
|
94
|
-
try {
|
|
95
|
-
// IE doesn't support this
|
|
96
|
-
img = new ImageData(new Uint8ClampedArray(rgba), w, h);
|
|
97
|
-
} catch (ex) {
|
|
98
|
-
img = ctx.createImageData(w, h);
|
|
99
|
-
img.data.set(new Uint8ClampedArray(rgba));
|
|
100
|
-
}
|
|
90
|
+
let img = new ImageData(new Uint8ClampedArray(rgba), w, h);
|
|
101
91
|
ctx.clearRect(0, 0, w, h);
|
|
102
92
|
ctx.putImageData(img, 0, 0);
|
|
103
93
|
|
package/core/util/events.js
CHANGED
|
@@ -65,10 +65,6 @@ export function setCapture(target) {
|
|
|
65
65
|
|
|
66
66
|
target.setCapture();
|
|
67
67
|
document.captureElement = target;
|
|
68
|
-
|
|
69
|
-
// IE releases capture on 'click' events which might not trigger
|
|
70
|
-
target.addEventListener('mouseup', releaseCapture);
|
|
71
|
-
|
|
72
68
|
} else {
|
|
73
69
|
// Release any existing capture in case this method is
|
|
74
70
|
// called multiple times without coordination
|
package/core/websock.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Websock: high-performance
|
|
2
|
+
* Websock: high-performance buffering wrapper
|
|
3
3
|
* Copyright (C) 2019 The noVNC Authors
|
|
4
4
|
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
5
5
|
*
|
|
6
|
-
* Websock is similar to the standard WebSocket
|
|
7
|
-
* buffer handling.
|
|
6
|
+
* Websock is similar to the standard WebSocket / RTCDataChannel object
|
|
7
|
+
* but with extra buffer handling.
|
|
8
8
|
*
|
|
9
9
|
* Websock has built-in receive queue buffering; the message event
|
|
10
10
|
* does not contain actual data but is simply a notification that
|
|
@@ -17,14 +17,39 @@ import * as Log from './util/logging.js';
|
|
|
17
17
|
// this has performance issues in some versions Chromium, and
|
|
18
18
|
// doesn't gain a tremendous amount of performance increase in Firefox
|
|
19
19
|
// at the moment. It may be valuable to turn it on in the future.
|
|
20
|
-
// Also copyWithin() for TypedArrays is not supported in IE 11 or
|
|
21
|
-
// Safari 13 (at the moment we want to support Safari 11).
|
|
22
|
-
const ENABLE_COPYWITHIN = false;
|
|
23
20
|
const MAX_RQ_GROW_SIZE = 40 * 1024 * 1024; // 40 MiB
|
|
24
21
|
|
|
22
|
+
// Constants pulled from RTCDataChannelState enum
|
|
23
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/readyState#RTCDataChannelState_enum
|
|
24
|
+
const DataChannel = {
|
|
25
|
+
CONNECTING: "connecting",
|
|
26
|
+
OPEN: "open",
|
|
27
|
+
CLOSING: "closing",
|
|
28
|
+
CLOSED: "closed"
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const ReadyStates = {
|
|
32
|
+
CONNECTING: [WebSocket.CONNECTING, DataChannel.CONNECTING],
|
|
33
|
+
OPEN: [WebSocket.OPEN, DataChannel.OPEN],
|
|
34
|
+
CLOSING: [WebSocket.CLOSING, DataChannel.CLOSING],
|
|
35
|
+
CLOSED: [WebSocket.CLOSED, DataChannel.CLOSED],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Properties a raw channel must have, WebSocket and RTCDataChannel are two examples
|
|
39
|
+
const rawChannelProps = [
|
|
40
|
+
"send",
|
|
41
|
+
"close",
|
|
42
|
+
"binaryType",
|
|
43
|
+
"onerror",
|
|
44
|
+
"onmessage",
|
|
45
|
+
"onopen",
|
|
46
|
+
"protocol",
|
|
47
|
+
"readyState",
|
|
48
|
+
];
|
|
49
|
+
|
|
25
50
|
export default class Websock {
|
|
26
51
|
constructor() {
|
|
27
|
-
this._websocket = null; // WebSocket object
|
|
52
|
+
this._websocket = null; // WebSocket or RTCDataChannel object
|
|
28
53
|
|
|
29
54
|
this._rQi = 0; // Receive queue index
|
|
30
55
|
this._rQlen = 0; // Next write position in the receive queue
|
|
@@ -46,6 +71,29 @@ export default class Websock {
|
|
|
46
71
|
}
|
|
47
72
|
|
|
48
73
|
// Getters and Setters
|
|
74
|
+
|
|
75
|
+
get readyState() {
|
|
76
|
+
let subState;
|
|
77
|
+
|
|
78
|
+
if (this._websocket === null) {
|
|
79
|
+
return "unused";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
subState = this._websocket.readyState;
|
|
83
|
+
|
|
84
|
+
if (ReadyStates.CONNECTING.includes(subState)) {
|
|
85
|
+
return "connecting";
|
|
86
|
+
} else if (ReadyStates.OPEN.includes(subState)) {
|
|
87
|
+
return "open";
|
|
88
|
+
} else if (ReadyStates.CLOSING.includes(subState)) {
|
|
89
|
+
return "closing";
|
|
90
|
+
} else if (ReadyStates.CLOSED.includes(subState)) {
|
|
91
|
+
return "closed";
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return "unknown";
|
|
95
|
+
}
|
|
96
|
+
|
|
49
97
|
get sQ() {
|
|
50
98
|
return this._sQ;
|
|
51
99
|
}
|
|
@@ -143,7 +191,7 @@ export default class Websock {
|
|
|
143
191
|
// Send Queue
|
|
144
192
|
|
|
145
193
|
flush() {
|
|
146
|
-
if (this._sQlen > 0 && this.
|
|
194
|
+
if (this._sQlen > 0 && this.readyState === 'open') {
|
|
147
195
|
this._websocket.send(this._encodeMessage());
|
|
148
196
|
this._sQlen = 0;
|
|
149
197
|
}
|
|
@@ -180,12 +228,25 @@ export default class Websock {
|
|
|
180
228
|
}
|
|
181
229
|
|
|
182
230
|
open(uri, protocols) {
|
|
231
|
+
this.attach(new WebSocket(uri, protocols));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
attach(rawChannel) {
|
|
183
235
|
this.init();
|
|
184
236
|
|
|
185
|
-
|
|
186
|
-
|
|
237
|
+
// Must get object and class methods to be compatible with the tests.
|
|
238
|
+
const channelProps = [...Object.keys(rawChannel), ...Object.getOwnPropertyNames(Object.getPrototypeOf(rawChannel))];
|
|
239
|
+
for (let i = 0; i < rawChannelProps.length; i++) {
|
|
240
|
+
const prop = rawChannelProps[i];
|
|
241
|
+
if (channelProps.indexOf(prop) < 0) {
|
|
242
|
+
throw new Error('Raw channel missing property: ' + prop);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
187
245
|
|
|
246
|
+
this._websocket = rawChannel;
|
|
247
|
+
this._websocket.binaryType = "arraybuffer";
|
|
188
248
|
this._websocket.onmessage = this._recvMessage.bind(this);
|
|
249
|
+
|
|
189
250
|
this._websocket.onopen = () => {
|
|
190
251
|
Log.Debug('>> WebSock.onopen');
|
|
191
252
|
if (this._websocket.protocol) {
|
|
@@ -195,11 +256,13 @@ export default class Websock {
|
|
|
195
256
|
this._eventHandlers.open();
|
|
196
257
|
Log.Debug("<< WebSock.onopen");
|
|
197
258
|
};
|
|
259
|
+
|
|
198
260
|
this._websocket.onclose = (e) => {
|
|
199
261
|
Log.Debug(">> WebSock.onclose");
|
|
200
262
|
this._eventHandlers.close(e);
|
|
201
263
|
Log.Debug("<< WebSock.onclose");
|
|
202
264
|
};
|
|
265
|
+
|
|
203
266
|
this._websocket.onerror = (e) => {
|
|
204
267
|
Log.Debug(">> WebSock.onerror: " + e);
|
|
205
268
|
this._eventHandlers.error(e);
|
|
@@ -209,8 +272,8 @@ export default class Websock {
|
|
|
209
272
|
|
|
210
273
|
close() {
|
|
211
274
|
if (this._websocket) {
|
|
212
|
-
if (
|
|
213
|
-
|
|
275
|
+
if (this.readyState === 'connecting' ||
|
|
276
|
+
this.readyState === 'open') {
|
|
214
277
|
Log.Info("Closing WebSocket connection");
|
|
215
278
|
this._websocket.close();
|
|
216
279
|
}
|
|
@@ -256,11 +319,7 @@ export default class Websock {
|
|
|
256
319
|
this._rQ = new Uint8Array(this._rQbufferSize);
|
|
257
320
|
this._rQ.set(new Uint8Array(oldRQbuffer, this._rQi, this._rQlen - this._rQi));
|
|
258
321
|
} else {
|
|
259
|
-
|
|
260
|
-
this._rQ.copyWithin(0, this._rQi, this._rQlen);
|
|
261
|
-
} else {
|
|
262
|
-
this._rQ.set(new Uint8Array(this._rQ.buffer, this._rQi, this._rQlen - this._rQi));
|
|
263
|
-
}
|
|
322
|
+
this._rQ.copyWithin(0, this._rQi, this._rQlen);
|
|
264
323
|
}
|
|
265
324
|
|
|
266
325
|
this._rQlen = this._rQlen - this._rQi;
|
package/docs/API.md
CHANGED
|
@@ -165,9 +165,9 @@ connection to a specified VNC server.
|
|
|
165
165
|
existing contents of the `HTMLElement` will be untouched, but new
|
|
166
166
|
elements will be added during the lifetime of the `RFB` object.
|
|
167
167
|
|
|
168
|
-
**`
|
|
168
|
+
**`urlOrDataChannel`**
|
|
169
169
|
- A `DOMString` specifying the VNC server to connect to. This must be
|
|
170
|
-
a valid WebSocket URL.
|
|
170
|
+
a valid WebSocket URL. This can also be a `WebSocket` or `RTCDataChannel`.
|
|
171
171
|
|
|
172
172
|
**`options`** *Optional*
|
|
173
173
|
- An `Object` specifying extra details about how the connection
|
|
@@ -328,7 +328,14 @@ Keyboard events will be sent to the remote server after this point.
|
|
|
328
328
|
|
|
329
329
|
##### Syntax
|
|
330
330
|
|
|
331
|
-
RFB.focus( );
|
|
331
|
+
RFB.focus( [options] );
|
|
332
|
+
|
|
333
|
+
###### Parameters
|
|
334
|
+
|
|
335
|
+
**`options`** *Optional*
|
|
336
|
+
- A `object` providing options to control how the focus will be
|
|
337
|
+
performed. Please see [`HTMLElement.focus()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus)
|
|
338
|
+
for available options.
|
|
332
339
|
|
|
333
340
|
#### RFB.blur()
|
|
334
341
|
|
package/docs/LIBRARY.md
CHANGED
|
@@ -18,18 +18,14 @@ do things.
|
|
|
18
18
|
|
|
19
19
|
## Conversion of Modules
|
|
20
20
|
|
|
21
|
-
noVNC is written using ECMAScript 6 modules.
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
noVNC is written using ECMAScript 6 modules. This is not supported by older
|
|
22
|
+
versions of Node.js. To use noVNC with those older versions of Node.js the
|
|
23
|
+
library must first be converted.
|
|
24
24
|
|
|
25
25
|
Fortunately noVNC includes a script to handle this conversion. Please follow
|
|
26
26
|
the following steps:
|
|
27
27
|
|
|
28
28
|
1. Install Node.js
|
|
29
29
|
2. Run `npm install` in the noVNC directory
|
|
30
|
-
3. Run `./utils/use_require.js --as <module format>`
|
|
31
|
-
|
|
32
|
-
Several module formats are available. Please run
|
|
33
|
-
`./utils/use_require.js --help` to see them all.
|
|
34
30
|
|
|
35
31
|
The result of the conversion is available in the `lib/` directory.
|
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;
|