@novnc/novnc 1.3.0-beta → 1.3.0-g6710410
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/README.md +6 -1
- package/core/decoders/jpeg.js +141 -0
- package/core/decoders/zrle.js +185 -0
- package/core/encodings.js +4 -0
- package/core/rfb.js +9 -3
- package/docs/API.md +8 -1
- package/lib/decoders/jpeg.js +188 -0
- package/lib/decoders/zrle.js +234 -0
- package/lib/encodings.js +8 -0
- package/lib/input/util.js +1 -1
- package/lib/rfb.js +14 -4
- package/lib/util/browser.js +9 -5
- package/lib/util/events.js +2 -2
- 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/deflate.js +5 -4
- package/lib/vendor/pako/lib/zlib/inffast.js +6 -2
- package/lib/vendor/pako/lib/zlib/inflate.js +40 -17
- package/lib/vendor/pako/lib/zlib/trees.js +2 -2
- package/package.json +1 -3
package/README.md
CHANGED
|
@@ -113,8 +113,13 @@ proxy.
|
|
|
113
113
|
used to specify the location of a running VNC server:
|
|
114
114
|
|
|
115
115
|
`./utils/novnc_proxy --vnc localhost:5901`
|
|
116
|
+
|
|
117
|
+
* If you don't need to expose the web server to public internet, you can
|
|
118
|
+
bind to localhost:
|
|
119
|
+
|
|
120
|
+
`./utils/novnc_proxy --vnc localhost:5901 --listen localhost:6081`
|
|
116
121
|
|
|
117
|
-
* Point your browser to the cut-and-paste URL that is output by the `
|
|
122
|
+
* Point your browser to the cut-and-paste URL that is output by the `novnc_proxy`
|
|
118
123
|
script. Hit the Connect button, enter a password if the VNC server has one
|
|
119
124
|
configured, and enjoy!
|
|
120
125
|
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* noVNC: HTML5 VNC client
|
|
3
|
+
* Copyright (C) 2019 The noVNC Authors
|
|
4
|
+
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
5
|
+
*
|
|
6
|
+
* See README.md for usage and integration instructions.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export default class JPEGDecoder {
|
|
11
|
+
constructor() {
|
|
12
|
+
// RealVNC will reuse the quantization tables
|
|
13
|
+
// and Huffman tables, so we need to cache them.
|
|
14
|
+
this._quantTables = [];
|
|
15
|
+
this._huffmanTables = [];
|
|
16
|
+
this._cachedQuantTables = [];
|
|
17
|
+
this._cachedHuffmanTables = [];
|
|
18
|
+
|
|
19
|
+
this._jpegLength = 0;
|
|
20
|
+
this._segments = [];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
decodeRect(x, y, width, height, sock, display, depth) {
|
|
24
|
+
// A rect of JPEG encodings is simply a JPEG file
|
|
25
|
+
if (!this._parseJPEG(sock.rQslice(0))) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const data = sock.rQshiftBytes(this._jpegLength);
|
|
29
|
+
if (this._quantTables.length != 0 && this._huffmanTables.length != 0) {
|
|
30
|
+
// If there are quantization tables and Huffman tables in the JPEG
|
|
31
|
+
// image, we can directly render it.
|
|
32
|
+
display.imageRect(x, y, width, height, "image/jpeg", data);
|
|
33
|
+
return true;
|
|
34
|
+
} else {
|
|
35
|
+
// Otherwise we need to insert cached tables.
|
|
36
|
+
const sofIndex = this._segments.findIndex(
|
|
37
|
+
x => x[1] == 0xC0 || x[1] == 0xC2
|
|
38
|
+
);
|
|
39
|
+
if (sofIndex == -1) {
|
|
40
|
+
throw new Error("Illegal JPEG image without SOF");
|
|
41
|
+
}
|
|
42
|
+
let segments = this._segments.slice(0, sofIndex);
|
|
43
|
+
segments = segments.concat(this._quantTables.length ?
|
|
44
|
+
this._quantTables :
|
|
45
|
+
this._cachedQuantTables);
|
|
46
|
+
segments.push(this._segments[sofIndex]);
|
|
47
|
+
segments = segments.concat(this._huffmanTables.length ?
|
|
48
|
+
this._huffmanTables :
|
|
49
|
+
this._cachedHuffmanTables,
|
|
50
|
+
this._segments.slice(sofIndex + 1));
|
|
51
|
+
let length = 0;
|
|
52
|
+
for (let i = 0; i < segments.length; i++) {
|
|
53
|
+
length += segments[i].length;
|
|
54
|
+
}
|
|
55
|
+
const data = new Uint8Array(length);
|
|
56
|
+
length = 0;
|
|
57
|
+
for (let i = 0; i < segments.length; i++) {
|
|
58
|
+
data.set(segments[i], length);
|
|
59
|
+
length += segments[i].length;
|
|
60
|
+
}
|
|
61
|
+
display.imageRect(x, y, width, height, "image/jpeg", data);
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
_parseJPEG(buffer) {
|
|
67
|
+
if (this._quantTables.length != 0) {
|
|
68
|
+
this._cachedQuantTables = this._quantTables;
|
|
69
|
+
}
|
|
70
|
+
if (this._huffmanTables.length != 0) {
|
|
71
|
+
this._cachedHuffmanTables = this._huffmanTables;
|
|
72
|
+
}
|
|
73
|
+
this._quantTables = [];
|
|
74
|
+
this._huffmanTables = [];
|
|
75
|
+
this._segments = [];
|
|
76
|
+
let i = 0;
|
|
77
|
+
let bufferLength = buffer.length;
|
|
78
|
+
while (true) {
|
|
79
|
+
let j = i;
|
|
80
|
+
if (j + 2 > bufferLength) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (buffer[j] != 0xFF) {
|
|
84
|
+
throw new Error("Illegal JPEG marker received (byte: " +
|
|
85
|
+
buffer[j] + ")");
|
|
86
|
+
}
|
|
87
|
+
const type = buffer[j+1];
|
|
88
|
+
j += 2;
|
|
89
|
+
if (type == 0xD9) {
|
|
90
|
+
this._jpegLength = j;
|
|
91
|
+
this._segments.push(buffer.slice(i, j));
|
|
92
|
+
return true;
|
|
93
|
+
} else if (type == 0xDA) {
|
|
94
|
+
// start of scan
|
|
95
|
+
let hasFoundEndOfScan = false;
|
|
96
|
+
for (let k = j + 3; k + 1 < bufferLength; k++) {
|
|
97
|
+
if (buffer[k] == 0xFF && buffer[k+1] != 0x00 &&
|
|
98
|
+
!(buffer[k+1] >= 0xD0 && buffer[k+1] <= 0xD7)) {
|
|
99
|
+
j = k;
|
|
100
|
+
hasFoundEndOfScan = true;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!hasFoundEndOfScan) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
this._segments.push(buffer.slice(i, j));
|
|
108
|
+
i = j;
|
|
109
|
+
continue;
|
|
110
|
+
} else if (type >= 0xD0 && type < 0xD9 || type == 0x01) {
|
|
111
|
+
// No length after marker
|
|
112
|
+
this._segments.push(buffer.slice(i, j));
|
|
113
|
+
i = j;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (j + 2 > bufferLength) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
const length = (buffer[j] << 8) + buffer[j+1] - 2;
|
|
120
|
+
if (length < 0) {
|
|
121
|
+
throw new Error("Illegal JPEG length received (length: " +
|
|
122
|
+
length + ")");
|
|
123
|
+
}
|
|
124
|
+
j += 2;
|
|
125
|
+
if (j + length > bufferLength) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
j += length;
|
|
129
|
+
const segment = buffer.slice(i, j);
|
|
130
|
+
if (type == 0xC4) {
|
|
131
|
+
// Huffman tables
|
|
132
|
+
this._huffmanTables.push(segment);
|
|
133
|
+
} else if (type == 0xDB) {
|
|
134
|
+
// Quantization tables
|
|
135
|
+
this._quantTables.push(segment);
|
|
136
|
+
}
|
|
137
|
+
this._segments.push(segment);
|
|
138
|
+
i = j;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* noVNC: HTML5 VNC client
|
|
3
|
+
* Copyright (C) 2021 The noVNC Authors
|
|
4
|
+
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
5
|
+
*
|
|
6
|
+
* See README.md for usage and integration instructions.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import Inflate from "../inflator.js";
|
|
11
|
+
|
|
12
|
+
const ZRLE_TILE_WIDTH = 64;
|
|
13
|
+
const ZRLE_TILE_HEIGHT = 64;
|
|
14
|
+
|
|
15
|
+
export default class ZRLEDecoder {
|
|
16
|
+
constructor() {
|
|
17
|
+
this._length = 0;
|
|
18
|
+
this._inflator = new Inflate();
|
|
19
|
+
|
|
20
|
+
this._pixelBuffer = new Uint8Array(ZRLE_TILE_WIDTH * ZRLE_TILE_HEIGHT * 4);
|
|
21
|
+
this._tileBuffer = new Uint8Array(ZRLE_TILE_WIDTH * ZRLE_TILE_HEIGHT * 4);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
decodeRect(x, y, width, height, sock, display, depth) {
|
|
25
|
+
if (this._length === 0) {
|
|
26
|
+
if (sock.rQwait("ZLib data length", 4)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
this._length = sock.rQshift32();
|
|
30
|
+
}
|
|
31
|
+
if (sock.rQwait("Zlib data", this._length)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const data = sock.rQshiftBytes(this._length);
|
|
36
|
+
|
|
37
|
+
this._inflator.setInput(data);
|
|
38
|
+
|
|
39
|
+
for (let ty = y; ty < y + height; ty += ZRLE_TILE_HEIGHT) {
|
|
40
|
+
let th = Math.min(ZRLE_TILE_HEIGHT, y + height - ty);
|
|
41
|
+
|
|
42
|
+
for (let tx = x; tx < x + width; tx += ZRLE_TILE_WIDTH) {
|
|
43
|
+
let tw = Math.min(ZRLE_TILE_WIDTH, x + width - tx);
|
|
44
|
+
|
|
45
|
+
const tileSize = tw * th;
|
|
46
|
+
const subencoding = this._inflator.inflate(1)[0];
|
|
47
|
+
if (subencoding === 0) {
|
|
48
|
+
// raw data
|
|
49
|
+
const data = this._readPixels(tileSize);
|
|
50
|
+
display.blitImage(tx, ty, tw, th, data, 0, false);
|
|
51
|
+
} else if (subencoding === 1) {
|
|
52
|
+
// solid
|
|
53
|
+
const background = this._readPixels(1);
|
|
54
|
+
display.fillRect(tx, ty, tw, th, [background[0], background[1], background[2]]);
|
|
55
|
+
} else if (subencoding >= 2 && subencoding <= 16) {
|
|
56
|
+
const data = this._decodePaletteTile(subencoding, tileSize, tw, th);
|
|
57
|
+
display.blitImage(tx, ty, tw, th, data, 0, false);
|
|
58
|
+
} else if (subencoding === 128) {
|
|
59
|
+
const data = this._decodeRLETile(tileSize);
|
|
60
|
+
display.blitImage(tx, ty, tw, th, data, 0, false);
|
|
61
|
+
} else if (subencoding >= 130 && subencoding <= 255) {
|
|
62
|
+
const data = this._decodeRLEPaletteTile(subencoding - 128, tileSize);
|
|
63
|
+
display.blitImage(tx, ty, tw, th, data, 0, false);
|
|
64
|
+
} else {
|
|
65
|
+
throw new Error('Unknown subencoding: ' + subencoding);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
this._length = 0;
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
_getBitsPerPixelInPalette(paletteSize) {
|
|
74
|
+
if (paletteSize <= 2) {
|
|
75
|
+
return 1;
|
|
76
|
+
} else if (paletteSize <= 4) {
|
|
77
|
+
return 2;
|
|
78
|
+
} else if (paletteSize <= 16) {
|
|
79
|
+
return 4;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
_readPixels(pixels) {
|
|
84
|
+
let data = this._pixelBuffer;
|
|
85
|
+
const buffer = this._inflator.inflate(3*pixels);
|
|
86
|
+
for (let i = 0, j = 0; i < pixels*4; i += 4, j += 3) {
|
|
87
|
+
data[i] = buffer[j];
|
|
88
|
+
data[i + 1] = buffer[j + 1];
|
|
89
|
+
data[i + 2] = buffer[j + 2];
|
|
90
|
+
data[i + 3] = 255; // Add the Alpha
|
|
91
|
+
}
|
|
92
|
+
return data;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
_decodePaletteTile(paletteSize, tileSize, tilew, tileh) {
|
|
96
|
+
const data = this._tileBuffer;
|
|
97
|
+
const palette = this._readPixels(paletteSize);
|
|
98
|
+
const bitsPerPixel = this._getBitsPerPixelInPalette(paletteSize);
|
|
99
|
+
const mask = (1 << bitsPerPixel) - 1;
|
|
100
|
+
|
|
101
|
+
let offset = 0;
|
|
102
|
+
let encoded = this._inflator.inflate(1)[0];
|
|
103
|
+
|
|
104
|
+
for (let y=0; y<tileh; y++) {
|
|
105
|
+
let shift = 8-bitsPerPixel;
|
|
106
|
+
for (let x=0; x<tilew; x++) {
|
|
107
|
+
if (shift<0) {
|
|
108
|
+
shift=8-bitsPerPixel;
|
|
109
|
+
encoded = this._inflator.inflate(1)[0];
|
|
110
|
+
}
|
|
111
|
+
let indexInPalette = (encoded>>shift) & mask;
|
|
112
|
+
|
|
113
|
+
data[offset] = palette[indexInPalette * 4];
|
|
114
|
+
data[offset + 1] = palette[indexInPalette * 4 + 1];
|
|
115
|
+
data[offset + 2] = palette[indexInPalette * 4 + 2];
|
|
116
|
+
data[offset + 3] = palette[indexInPalette * 4 + 3];
|
|
117
|
+
offset += 4;
|
|
118
|
+
shift-=bitsPerPixel;
|
|
119
|
+
}
|
|
120
|
+
if (shift<8-bitsPerPixel && y<tileh-1) {
|
|
121
|
+
encoded = this._inflator.inflate(1)[0];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return data;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
_decodeRLETile(tileSize) {
|
|
128
|
+
const data = this._tileBuffer;
|
|
129
|
+
let i = 0;
|
|
130
|
+
while (i < tileSize) {
|
|
131
|
+
const pixel = this._readPixels(1);
|
|
132
|
+
const length = this._readRLELength();
|
|
133
|
+
for (let j = 0; j < length; j++) {
|
|
134
|
+
data[i * 4] = pixel[0];
|
|
135
|
+
data[i * 4 + 1] = pixel[1];
|
|
136
|
+
data[i * 4 + 2] = pixel[2];
|
|
137
|
+
data[i * 4 + 3] = pixel[3];
|
|
138
|
+
i++;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return data;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
_decodeRLEPaletteTile(paletteSize, tileSize) {
|
|
145
|
+
const data = this._tileBuffer;
|
|
146
|
+
|
|
147
|
+
// palette
|
|
148
|
+
const palette = this._readPixels(paletteSize);
|
|
149
|
+
|
|
150
|
+
let offset = 0;
|
|
151
|
+
while (offset < tileSize) {
|
|
152
|
+
let indexInPalette = this._inflator.inflate(1)[0];
|
|
153
|
+
let length = 1;
|
|
154
|
+
if (indexInPalette >= 128) {
|
|
155
|
+
indexInPalette -= 128;
|
|
156
|
+
length = this._readRLELength();
|
|
157
|
+
}
|
|
158
|
+
if (indexInPalette > paletteSize) {
|
|
159
|
+
throw new Error('Too big index in palette: ' + indexInPalette + ', palette size: ' + paletteSize);
|
|
160
|
+
}
|
|
161
|
+
if (offset + length > tileSize) {
|
|
162
|
+
throw new Error('Too big rle length in palette mode: ' + length + ', allowed length is: ' + (tileSize - offset));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
for (let j = 0; j < length; j++) {
|
|
166
|
+
data[offset * 4] = palette[indexInPalette * 4];
|
|
167
|
+
data[offset * 4 + 1] = palette[indexInPalette * 4 + 1];
|
|
168
|
+
data[offset * 4 + 2] = palette[indexInPalette * 4 + 2];
|
|
169
|
+
data[offset * 4 + 3] = palette[indexInPalette * 4 + 3];
|
|
170
|
+
offset++;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return data;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
_readRLELength() {
|
|
177
|
+
let length = 0;
|
|
178
|
+
let current = 0;
|
|
179
|
+
do {
|
|
180
|
+
current = this._inflator.inflate(1)[0];
|
|
181
|
+
length += current;
|
|
182
|
+
} while (current === 255);
|
|
183
|
+
return length + 1;
|
|
184
|
+
}
|
|
185
|
+
}
|
package/core/encodings.js
CHANGED
|
@@ -12,7 +12,9 @@ export const encodings = {
|
|
|
12
12
|
encodingRRE: 2,
|
|
13
13
|
encodingHextile: 5,
|
|
14
14
|
encodingTight: 7,
|
|
15
|
+
encodingZRLE: 16,
|
|
15
16
|
encodingTightPNG: -260,
|
|
17
|
+
encodingJPEG: 21,
|
|
16
18
|
|
|
17
19
|
pseudoEncodingQualityLevel9: -23,
|
|
18
20
|
pseudoEncodingQualityLevel0: -32,
|
|
@@ -38,7 +40,9 @@ export function encodingName(num) {
|
|
|
38
40
|
case encodings.encodingRRE: return "RRE";
|
|
39
41
|
case encodings.encodingHextile: return "Hextile";
|
|
40
42
|
case encodings.encodingTight: return "Tight";
|
|
43
|
+
case encodings.encodingZRLE: return "ZRLE";
|
|
41
44
|
case encodings.encodingTightPNG: return "TightPNG";
|
|
45
|
+
case encodings.encodingJPEG: return "JPEG";
|
|
42
46
|
default: return "[unknown encoding " + num + "]";
|
|
43
47
|
}
|
|
44
48
|
}
|
package/core/rfb.js
CHANGED
|
@@ -32,6 +32,8 @@ import RREDecoder from "./decoders/rre.js";
|
|
|
32
32
|
import HextileDecoder from "./decoders/hextile.js";
|
|
33
33
|
import TightDecoder from "./decoders/tight.js";
|
|
34
34
|
import TightPNGDecoder from "./decoders/tightpng.js";
|
|
35
|
+
import ZRLEDecoder from "./decoders/zrle.js";
|
|
36
|
+
import JPEGDecoder from "./decoders/jpeg.js";
|
|
35
37
|
|
|
36
38
|
// How many seconds to wait for a disconnect to finish
|
|
37
39
|
const DISCONNECT_TIMEOUT = 3;
|
|
@@ -218,6 +220,8 @@ export default class RFB extends EventTargetMixin {
|
|
|
218
220
|
this._decoders[encodings.encodingHextile] = new HextileDecoder();
|
|
219
221
|
this._decoders[encodings.encodingTight] = new TightDecoder();
|
|
220
222
|
this._decoders[encodings.encodingTightPNG] = new TightPNGDecoder();
|
|
223
|
+
this._decoders[encodings.encodingZRLE] = new ZRLEDecoder();
|
|
224
|
+
this._decoders[encodings.encodingJPEG] = new JPEGDecoder();
|
|
221
225
|
|
|
222
226
|
// NB: nothing that needs explicit teardown should be done
|
|
223
227
|
// before this point, since this can throw an exception
|
|
@@ -432,8 +436,8 @@ export default class RFB extends EventTargetMixin {
|
|
|
432
436
|
}
|
|
433
437
|
}
|
|
434
438
|
|
|
435
|
-
focus() {
|
|
436
|
-
this._canvas.focus();
|
|
439
|
+
focus(options) {
|
|
440
|
+
this._canvas.focus(options);
|
|
437
441
|
}
|
|
438
442
|
|
|
439
443
|
blur() {
|
|
@@ -609,7 +613,7 @@ export default class RFB extends EventTargetMixin {
|
|
|
609
613
|
return;
|
|
610
614
|
}
|
|
611
615
|
|
|
612
|
-
this.focus();
|
|
616
|
+
this.focus({ preventScroll: true });
|
|
613
617
|
}
|
|
614
618
|
|
|
615
619
|
_setDesktopName(name) {
|
|
@@ -1772,6 +1776,8 @@ export default class RFB extends EventTargetMixin {
|
|
|
1772
1776
|
if (this._fbDepth == 24) {
|
|
1773
1777
|
encs.push(encodings.encodingTight);
|
|
1774
1778
|
encs.push(encodings.encodingTightPNG);
|
|
1779
|
+
encs.push(encodings.encodingZRLE);
|
|
1780
|
+
encs.push(encodings.encodingJPEG);
|
|
1775
1781
|
encs.push(encodings.encodingHextile);
|
|
1776
1782
|
encs.push(encodings.encodingRRE);
|
|
1777
1783
|
}
|
package/docs/API.md
CHANGED
|
@@ -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
|
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
|
|
10
|
+
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); } }
|
|
11
|
+
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* noVNC: HTML5 VNC client
|
|
16
|
+
* Copyright (C) 2019 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 JPEGDecoder = /*#__PURE__*/function () {
|
|
23
|
+
function JPEGDecoder() {
|
|
24
|
+
_classCallCheck(this, JPEGDecoder);
|
|
25
|
+
|
|
26
|
+
// RealVNC will reuse the quantization tables
|
|
27
|
+
// and Huffman tables, so we need to cache them.
|
|
28
|
+
this._quantTables = [];
|
|
29
|
+
this._huffmanTables = [];
|
|
30
|
+
this._cachedQuantTables = [];
|
|
31
|
+
this._cachedHuffmanTables = [];
|
|
32
|
+
this._jpegLength = 0;
|
|
33
|
+
this._segments = [];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
_createClass(JPEGDecoder, [{
|
|
37
|
+
key: "decodeRect",
|
|
38
|
+
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
39
|
+
// A rect of JPEG encodings is simply a JPEG file
|
|
40
|
+
if (!this._parseJPEG(sock.rQslice(0))) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var data = sock.rQshiftBytes(this._jpegLength);
|
|
45
|
+
|
|
46
|
+
if (this._quantTables.length != 0 && this._huffmanTables.length != 0) {
|
|
47
|
+
// If there are quantization tables and Huffman tables in the JPEG
|
|
48
|
+
// image, we can directly render it.
|
|
49
|
+
display.imageRect(x, y, width, height, "image/jpeg", data);
|
|
50
|
+
return true;
|
|
51
|
+
} else {
|
|
52
|
+
// Otherwise we need to insert cached tables.
|
|
53
|
+
var sofIndex = this._segments.findIndex(function (x) {
|
|
54
|
+
return x[1] == 0xC0 || x[1] == 0xC2;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (sofIndex == -1) {
|
|
58
|
+
throw new Error("Illegal JPEG image without SOF");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var segments = this._segments.slice(0, sofIndex);
|
|
62
|
+
|
|
63
|
+
segments = segments.concat(this._quantTables.length ? this._quantTables : this._cachedQuantTables);
|
|
64
|
+
segments.push(this._segments[sofIndex]);
|
|
65
|
+
segments = segments.concat(this._huffmanTables.length ? this._huffmanTables : this._cachedHuffmanTables, this._segments.slice(sofIndex + 1));
|
|
66
|
+
var length = 0;
|
|
67
|
+
|
|
68
|
+
for (var i = 0; i < segments.length; i++) {
|
|
69
|
+
length += segments[i].length;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
var _data = new Uint8Array(length);
|
|
73
|
+
|
|
74
|
+
length = 0;
|
|
75
|
+
|
|
76
|
+
for (var _i = 0; _i < segments.length; _i++) {
|
|
77
|
+
_data.set(segments[_i], length);
|
|
78
|
+
|
|
79
|
+
length += segments[_i].length;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
display.imageRect(x, y, width, height, "image/jpeg", _data);
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "_parseJPEG",
|
|
88
|
+
value: function _parseJPEG(buffer) {
|
|
89
|
+
if (this._quantTables.length != 0) {
|
|
90
|
+
this._cachedQuantTables = this._quantTables;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (this._huffmanTables.length != 0) {
|
|
94
|
+
this._cachedHuffmanTables = this._huffmanTables;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this._quantTables = [];
|
|
98
|
+
this._huffmanTables = [];
|
|
99
|
+
this._segments = [];
|
|
100
|
+
var i = 0;
|
|
101
|
+
var bufferLength = buffer.length;
|
|
102
|
+
|
|
103
|
+
while (true) {
|
|
104
|
+
var j = i;
|
|
105
|
+
|
|
106
|
+
if (j + 2 > bufferLength) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (buffer[j] != 0xFF) {
|
|
111
|
+
throw new Error("Illegal JPEG marker received (byte: " + buffer[j] + ")");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
var type = buffer[j + 1];
|
|
115
|
+
j += 2;
|
|
116
|
+
|
|
117
|
+
if (type == 0xD9) {
|
|
118
|
+
this._jpegLength = j;
|
|
119
|
+
|
|
120
|
+
this._segments.push(buffer.slice(i, j));
|
|
121
|
+
|
|
122
|
+
return true;
|
|
123
|
+
} else if (type == 0xDA) {
|
|
124
|
+
// start of scan
|
|
125
|
+
var hasFoundEndOfScan = false;
|
|
126
|
+
|
|
127
|
+
for (var k = j + 3; k + 1 < bufferLength; k++) {
|
|
128
|
+
if (buffer[k] == 0xFF && buffer[k + 1] != 0x00 && !(buffer[k + 1] >= 0xD0 && buffer[k + 1] <= 0xD7)) {
|
|
129
|
+
j = k;
|
|
130
|
+
hasFoundEndOfScan = true;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (!hasFoundEndOfScan) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
this._segments.push(buffer.slice(i, j));
|
|
140
|
+
|
|
141
|
+
i = j;
|
|
142
|
+
continue;
|
|
143
|
+
} else if (type >= 0xD0 && type < 0xD9 || type == 0x01) {
|
|
144
|
+
// No length after marker
|
|
145
|
+
this._segments.push(buffer.slice(i, j));
|
|
146
|
+
|
|
147
|
+
i = j;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (j + 2 > bufferLength) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
var length = (buffer[j] << 8) + buffer[j + 1] - 2;
|
|
156
|
+
|
|
157
|
+
if (length < 0) {
|
|
158
|
+
throw new Error("Illegal JPEG length received (length: " + length + ")");
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
j += 2;
|
|
162
|
+
|
|
163
|
+
if (j + length > bufferLength) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
j += length;
|
|
168
|
+
var segment = buffer.slice(i, j);
|
|
169
|
+
|
|
170
|
+
if (type == 0xC4) {
|
|
171
|
+
// Huffman tables
|
|
172
|
+
this._huffmanTables.push(segment);
|
|
173
|
+
} else if (type == 0xDB) {
|
|
174
|
+
// Quantization tables
|
|
175
|
+
this._quantTables.push(segment);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
this._segments.push(segment);
|
|
179
|
+
|
|
180
|
+
i = j;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}]);
|
|
184
|
+
|
|
185
|
+
return JPEGDecoder;
|
|
186
|
+
}();
|
|
187
|
+
|
|
188
|
+
exports["default"] = JPEGDecoder;
|
|
@@ -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;
|
package/lib/encodings.js
CHANGED
|
@@ -19,7 +19,9 @@ var encodings = {
|
|
|
19
19
|
encodingRRE: 2,
|
|
20
20
|
encodingHextile: 5,
|
|
21
21
|
encodingTight: 7,
|
|
22
|
+
encodingZRLE: 16,
|
|
22
23
|
encodingTightPNG: -260,
|
|
24
|
+
encodingJPEG: 21,
|
|
23
25
|
pseudoEncodingQualityLevel9: -23,
|
|
24
26
|
pseudoEncodingQualityLevel0: -32,
|
|
25
27
|
pseudoEncodingDesktopSize: -223,
|
|
@@ -55,9 +57,15 @@ function encodingName(num) {
|
|
|
55
57
|
case encodings.encodingTight:
|
|
56
58
|
return "Tight";
|
|
57
59
|
|
|
60
|
+
case encodings.encodingZRLE:
|
|
61
|
+
return "ZRLE";
|
|
62
|
+
|
|
58
63
|
case encodings.encodingTightPNG:
|
|
59
64
|
return "TightPNG";
|
|
60
65
|
|
|
66
|
+
case encodings.encodingJPEG:
|
|
67
|
+
return "JPEG";
|
|
68
|
+
|
|
61
69
|
default:
|
|
62
70
|
return "[unknown encoding " + num + "]";
|
|
63
71
|
}
|
package/lib/input/util.js
CHANGED
|
@@ -5,8 +5,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.getKeycode = getKeycode;
|
|
9
8
|
exports.getKey = getKey;
|
|
9
|
+
exports.getKeycode = getKeycode;
|
|
10
10
|
exports.getKeysym = getKeysym;
|
|
11
11
|
|
|
12
12
|
var _keysym = _interopRequireDefault(require("./keysym.js"));
|
package/lib/rfb.js
CHANGED
|
@@ -55,6 +55,10 @@ var _tight = _interopRequireDefault(require("./decoders/tight.js"));
|
|
|
55
55
|
|
|
56
56
|
var _tightpng = _interopRequireDefault(require("./decoders/tightpng.js"));
|
|
57
57
|
|
|
58
|
+
var _zrle = _interopRequireDefault(require("./decoders/zrle.js"));
|
|
59
|
+
|
|
60
|
+
var _jpeg = _interopRequireDefault(require("./decoders/jpeg.js"));
|
|
61
|
+
|
|
58
62
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
59
63
|
|
|
60
64
|
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); }
|
|
@@ -262,7 +266,9 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
262
266
|
_this._decoders[_encodings.encodings.encodingRRE] = new _rre["default"]();
|
|
263
267
|
_this._decoders[_encodings.encodings.encodingHextile] = new _hextile["default"]();
|
|
264
268
|
_this._decoders[_encodings.encodings.encodingTight] = new _tight["default"]();
|
|
265
|
-
_this._decoders[_encodings.encodings.encodingTightPNG] = new _tightpng["default"]();
|
|
269
|
+
_this._decoders[_encodings.encodings.encodingTightPNG] = new _tightpng["default"]();
|
|
270
|
+
_this._decoders[_encodings.encodings.encodingZRLE] = new _zrle["default"]();
|
|
271
|
+
_this._decoders[_encodings.encodings.encodingJPEG] = new _jpeg["default"](); // NB: nothing that needs explicit teardown should be done
|
|
266
272
|
// before this point, since this can throw an exception
|
|
267
273
|
|
|
268
274
|
try {
|
|
@@ -522,8 +528,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
522
528
|
}
|
|
523
529
|
}, {
|
|
524
530
|
key: "focus",
|
|
525
|
-
value: function focus() {
|
|
526
|
-
this._canvas.focus();
|
|
531
|
+
value: function focus(options) {
|
|
532
|
+
this._canvas.focus(options);
|
|
527
533
|
}
|
|
528
534
|
}, {
|
|
529
535
|
key: "blur",
|
|
@@ -746,7 +752,9 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
746
752
|
return;
|
|
747
753
|
}
|
|
748
754
|
|
|
749
|
-
this.focus(
|
|
755
|
+
this.focus({
|
|
756
|
+
preventScroll: true
|
|
757
|
+
});
|
|
750
758
|
}
|
|
751
759
|
}, {
|
|
752
760
|
key: "_setDesktopName",
|
|
@@ -2150,6 +2158,8 @@ var RFB = /*#__PURE__*/function (_EventTargetMixin) {
|
|
|
2150
2158
|
if (this._fbDepth == 24) {
|
|
2151
2159
|
encs.push(_encodings.encodings.encodingTight);
|
|
2152
2160
|
encs.push(_encodings.encodings.encodingTightPNG);
|
|
2161
|
+
encs.push(_encodings.encodings.encodingZRLE);
|
|
2162
|
+
encs.push(_encodings.encodings.encodingJPEG);
|
|
2153
2163
|
encs.push(_encodings.encodings.encodingHextile);
|
|
2154
2164
|
encs.push(_encodings.encodings.encodingRRE);
|
|
2155
2165
|
}
|
package/lib/util/browser.js
CHANGED
|
@@ -5,12 +5,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
8
|
+
exports.hasScrollbarGutter = exports.dragThreshold = void 0;
|
|
9
|
+
exports.isFirefox = isFirefox;
|
|
10
10
|
exports.isIOS = isIOS;
|
|
11
|
+
exports.isMac = isMac;
|
|
11
12
|
exports.isSafari = isSafari;
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
13
|
+
exports.isTouchDevice = void 0;
|
|
14
|
+
exports.isWindows = isWindows;
|
|
15
|
+
exports.supportsCursorURIs = void 0;
|
|
14
16
|
|
|
15
17
|
var Log = _interopRequireWildcard(require("./logging.js"));
|
|
16
18
|
|
|
@@ -28,7 +30,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
28
30
|
* Browser feature support detection
|
|
29
31
|
*/
|
|
30
32
|
// Touch detection
|
|
31
|
-
var isTouchDevice = 'ontouchstart' in document.documentElement ||
|
|
33
|
+
var isTouchDevice = 'ontouchstart' in document.documentElement || // requried for Chrome debugger
|
|
34
|
+
document.ontouchstart !== undefined || // required for MS Surface
|
|
35
|
+
navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
|
|
32
36
|
exports.isTouchDevice = isTouchDevice;
|
|
33
37
|
window.addEventListener('touchstart', function onFirstTouch() {
|
|
34
38
|
exports.isTouchDevice = isTouchDevice = true;
|
package/lib/util/events.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getPointerEvent = getPointerEvent;
|
|
7
|
-
exports.stopEvent = stopEvent;
|
|
8
|
-
exports.setCapture = setCapture;
|
|
9
7
|
exports.releaseCapture = releaseCapture;
|
|
8
|
+
exports.setCapture = setCapture;
|
|
9
|
+
exports.stopEvent = stopEvent;
|
|
10
10
|
|
|
11
11
|
/*
|
|
12
12
|
* noVNC: HTML5 VNC client
|
package/lib/util/int.js
CHANGED
package/lib/util/logging.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.Warn = exports.Info = exports.Error = exports.Debug = void 0;
|
|
7
7
|
exports.getLogging = getLogging;
|
|
8
|
-
exports.
|
|
8
|
+
exports.initLogging = initLogging;
|
|
9
9
|
|
|
10
10
|
/*
|
|
11
11
|
* noVNC: HTML5 VNC client
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.Buf8 = exports.Buf32 = exports.Buf16 = void 0;
|
|
7
7
|
exports.arraySet = arraySet;
|
|
8
8
|
exports.flattenChunks = flattenChunks;
|
|
9
|
-
exports.
|
|
9
|
+
exports.shrinkBuf = shrinkBuf;
|
|
10
10
|
|
|
11
11
|
// reduce buffer size, avoiding mem copy
|
|
12
12
|
function shrinkBuf(buf, size) {
|
|
@@ -5,15 +5,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.Z_UNKNOWN = exports.Z_STREAM_ERROR = exports.Z_STREAM_END = exports.Z_RLE = exports.Z_PARTIAL_FLUSH = exports.Z_OK = exports.Z_NO_FLUSH = exports.Z_HUFFMAN_ONLY = exports.Z_FULL_FLUSH = exports.Z_FIXED = exports.Z_FINISH = exports.Z_FILTERED = exports.Z_DEFLATED = exports.Z_DEFAULT_STRATEGY = exports.Z_DEFAULT_COMPRESSION = exports.Z_DATA_ERROR = exports.Z_BUF_ERROR = exports.Z_BLOCK = void 0;
|
|
9
|
+
exports.deflate = deflate;
|
|
10
|
+
exports.deflateEnd = deflateEnd;
|
|
11
|
+
exports.deflateInfo = void 0;
|
|
8
12
|
exports.deflateInit = deflateInit;
|
|
9
13
|
exports.deflateInit2 = deflateInit2;
|
|
10
14
|
exports.deflateReset = deflateReset;
|
|
11
15
|
exports.deflateResetKeep = deflateResetKeep;
|
|
12
|
-
exports.deflateSetHeader = deflateSetHeader;
|
|
13
|
-
exports.deflate = deflate;
|
|
14
|
-
exports.deflateEnd = deflateEnd;
|
|
15
16
|
exports.deflateSetDictionary = deflateSetDictionary;
|
|
16
|
-
exports.
|
|
17
|
+
exports.deflateSetHeader = deflateSetHeader;
|
|
17
18
|
|
|
18
19
|
var utils = _interopRequireWildcard(require("../utils/common.js"));
|
|
19
20
|
|
|
@@ -392,7 +392,9 @@ function inflate_fast(strm, start) {
|
|
|
392
392
|
}
|
|
393
393
|
} else if ((op & 64) === 0) {
|
|
394
394
|
/* 2nd level distance code */
|
|
395
|
-
here = dcode[(here & 0xffff
|
|
395
|
+
here = dcode[(here & 0xffff
|
|
396
|
+
/*here.val*/
|
|
397
|
+
) + (hold & (1 << op) - 1)];
|
|
396
398
|
continue dodist;
|
|
397
399
|
} else {
|
|
398
400
|
strm.msg = 'invalid distance code';
|
|
@@ -404,7 +406,9 @@ function inflate_fast(strm, start) {
|
|
|
404
406
|
}
|
|
405
407
|
} else if ((op & 64) === 0) {
|
|
406
408
|
/* 2nd level length code */
|
|
407
|
-
here = lcode[(here & 0xffff
|
|
409
|
+
here = lcode[(here & 0xffff
|
|
410
|
+
/*here.val*/
|
|
411
|
+
) + (hold & (1 << op) - 1)];
|
|
408
412
|
continue dolen;
|
|
409
413
|
} else if (op & 32) {
|
|
410
414
|
/* end-of-block */
|
|
@@ -5,16 +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.
|
|
9
|
-
exports.inflateReset2 = inflateReset2;
|
|
10
|
-
exports.inflateResetKeep = inflateResetKeep;
|
|
11
|
-
exports.inflateInit = inflateInit;
|
|
12
|
-
exports.inflateInit2 = inflateInit2;
|
|
8
|
+
exports.Z_TREES = exports.Z_STREAM_ERROR = exports.Z_STREAM_END = exports.Z_OK = exports.Z_NEED_DICT = exports.Z_MEM_ERROR = exports.Z_FINISH = exports.Z_DEFLATED = exports.Z_DATA_ERROR = exports.Z_BUF_ERROR = exports.Z_BLOCK = void 0;
|
|
13
9
|
exports.inflate = inflate;
|
|
14
10
|
exports.inflateEnd = inflateEnd;
|
|
15
11
|
exports.inflateGetHeader = inflateGetHeader;
|
|
12
|
+
exports.inflateInfo = void 0;
|
|
13
|
+
exports.inflateInit = inflateInit;
|
|
14
|
+
exports.inflateInit2 = inflateInit2;
|
|
15
|
+
exports.inflateReset = inflateReset;
|
|
16
|
+
exports.inflateReset2 = inflateReset2;
|
|
17
|
+
exports.inflateResetKeep = inflateResetKeep;
|
|
16
18
|
exports.inflateSetDictionary = inflateSetDictionary;
|
|
17
|
-
exports.inflateInfo = exports.Z_DEFLATED = exports.Z_BUF_ERROR = exports.Z_MEM_ERROR = exports.Z_DATA_ERROR = exports.Z_STREAM_ERROR = exports.Z_NEED_DICT = exports.Z_STREAM_END = exports.Z_OK = exports.Z_TREES = exports.Z_BLOCK = exports.Z_FINISH = void 0;
|
|
18
19
|
|
|
19
20
|
var utils = _interopRequireWildcard(require("../utils/common.js"));
|
|
20
21
|
|
|
@@ -693,13 +694,17 @@ function inflate(strm, flush) {
|
|
|
693
694
|
|
|
694
695
|
if (!(state.wrap & 1) ||
|
|
695
696
|
/* check if zlib header allowed */
|
|
696
|
-
(((hold & 0xff
|
|
697
|
+
(((hold & 0xff
|
|
698
|
+
/*BITS(8)*/
|
|
699
|
+
) << 8) + (hold >> 8)) % 31) {
|
|
697
700
|
strm.msg = 'incorrect header check';
|
|
698
701
|
state.mode = BAD;
|
|
699
702
|
break;
|
|
700
703
|
}
|
|
701
704
|
|
|
702
|
-
if ((hold & 0x0f
|
|
705
|
+
if ((hold & 0x0f
|
|
706
|
+
/*BITS(4)*/
|
|
707
|
+
) !== Z_DEFLATED) {
|
|
703
708
|
strm.msg = 'unknown compression method';
|
|
704
709
|
state.mode = BAD;
|
|
705
710
|
break;
|
|
@@ -709,7 +714,9 @@ function inflate(strm, flush) {
|
|
|
709
714
|
hold >>>= 4;
|
|
710
715
|
bits -= 4; //---//
|
|
711
716
|
|
|
712
|
-
len = (hold & 0x0f
|
|
717
|
+
len = (hold & 0x0f
|
|
718
|
+
/*BITS(4)*/
|
|
719
|
+
) + 8;
|
|
713
720
|
|
|
714
721
|
if (state.wbits === 0) {
|
|
715
722
|
state.wbits = len;
|
|
@@ -1117,7 +1124,9 @@ function inflate(strm, flush) {
|
|
|
1117
1124
|
hold >>>= 1;
|
|
1118
1125
|
bits -= 1; //---//
|
|
1119
1126
|
|
|
1120
|
-
switch (hold & 0x03
|
|
1127
|
+
switch (hold & 0x03
|
|
1128
|
+
/*BITS(2)*/
|
|
1129
|
+
) {
|
|
1121
1130
|
case 0:
|
|
1122
1131
|
/* stored block */
|
|
1123
1132
|
//Tracev((stderr, "inflate: stored block%s\n",
|
|
@@ -1248,17 +1257,23 @@ function inflate(strm, flush) {
|
|
|
1248
1257
|
} //===//
|
|
1249
1258
|
|
|
1250
1259
|
|
|
1251
|
-
state.nlen = (hold & 0x1f
|
|
1260
|
+
state.nlen = (hold & 0x1f
|
|
1261
|
+
/*BITS(5)*/
|
|
1262
|
+
) + 257; //--- DROPBITS(5) ---//
|
|
1252
1263
|
|
|
1253
1264
|
hold >>>= 5;
|
|
1254
1265
|
bits -= 5; //---//
|
|
1255
1266
|
|
|
1256
|
-
state.ndist = (hold & 0x1f
|
|
1267
|
+
state.ndist = (hold & 0x1f
|
|
1268
|
+
/*BITS(5)*/
|
|
1269
|
+
) + 1; //--- DROPBITS(5) ---//
|
|
1257
1270
|
|
|
1258
1271
|
hold >>>= 5;
|
|
1259
1272
|
bits -= 5; //---//
|
|
1260
1273
|
|
|
1261
|
-
state.ncode = (hold & 0x0f
|
|
1274
|
+
state.ncode = (hold & 0x0f
|
|
1275
|
+
/*BITS(4)*/
|
|
1276
|
+
) + 4; //--- DROPBITS(4) ---//
|
|
1262
1277
|
|
|
1263
1278
|
hold >>>= 4;
|
|
1264
1279
|
bits -= 4; //---//
|
|
@@ -1575,7 +1590,9 @@ function inflate(strm, flush) {
|
|
|
1575
1590
|
last_val = here_val;
|
|
1576
1591
|
|
|
1577
1592
|
for (;;) {
|
|
1578
|
-
here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1
|
|
1593
|
+
here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1
|
|
1594
|
+
/*BITS(last.bits + last.op)*/
|
|
1595
|
+
) >> last_bits)];
|
|
1579
1596
|
here_bits = here >>> 24;
|
|
1580
1597
|
here_op = here >>> 16 & 0xff;
|
|
1581
1598
|
here_val = here & 0xffff;
|
|
@@ -1695,7 +1712,9 @@ function inflate(strm, flush) {
|
|
|
1695
1712
|
last_val = here_val;
|
|
1696
1713
|
|
|
1697
1714
|
for (;;) {
|
|
1698
|
-
here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1
|
|
1715
|
+
here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1
|
|
1716
|
+
/*BITS(last.bits + last.op)*/
|
|
1717
|
+
) >> last_bits)];
|
|
1699
1718
|
here_bits = here >>> 24;
|
|
1700
1719
|
here_op = here >>> 16 & 0xff;
|
|
1701
1720
|
here_val = here & 0xffff;
|
|
@@ -1878,7 +1897,9 @@ function inflate(strm, flush) {
|
|
|
1878
1897
|
state.total += _out;
|
|
1879
1898
|
|
|
1880
1899
|
if (_out) {
|
|
1881
|
-
strm.adler = state.check =
|
|
1900
|
+
strm.adler = state.check =
|
|
1901
|
+
/*UPDATE(state.check, put - _out, _out);*/
|
|
1902
|
+
state.flags ? (0, _crc["default"])(state.check, output, _out, put - _out) : (0, _adler["default"])(state.check, output, _out, put - _out);
|
|
1882
1903
|
}
|
|
1883
1904
|
|
|
1884
1905
|
_out = left; // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
|
|
@@ -1978,7 +1999,9 @@ function inflate(strm, flush) {
|
|
|
1978
1999
|
state.total += _out;
|
|
1979
2000
|
|
|
1980
2001
|
if (state.wrap && _out) {
|
|
1981
|
-
strm.adler = state.check =
|
|
2002
|
+
strm.adler = state.check =
|
|
2003
|
+
/*UPDATE(state.check, strm.next_out - _out, _out);*/
|
|
2004
|
+
state.flags ? (0, _crc["default"])(state.check, output, _out, strm.next_out - _out) : (0, _adler["default"])(state.check, output, _out, strm.next_out - _out);
|
|
1982
2005
|
}
|
|
1983
2006
|
|
|
1984
2007
|
strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
|
|
@@ -5,11 +5,11 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports._tr_align = _tr_align;
|
|
9
|
+
exports._tr_flush_block = _tr_flush_block;
|
|
8
10
|
exports._tr_init = _tr_init;
|
|
9
11
|
exports._tr_stored_block = _tr_stored_block;
|
|
10
|
-
exports._tr_flush_block = _tr_flush_block;
|
|
11
12
|
exports._tr_tally = _tr_tally;
|
|
12
|
-
exports._tr_align = _tr_align;
|
|
13
13
|
|
|
14
14
|
var utils = _interopRequireWildcard(require("../utils/common.js"));
|
|
15
15
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novnc/novnc",
|
|
3
|
-
"version": "1.3.0-
|
|
3
|
+
"version": "1.3.0-g6710410",
|
|
4
4
|
"description": "An HTML5 VNC client",
|
|
5
5
|
"browser": "lib/rfb",
|
|
6
6
|
"directories": {
|
|
@@ -29,8 +29,6 @@
|
|
|
29
29
|
},
|
|
30
30
|
"author": "Joel Martin <github@martintribe.org> (https://github.com/kanaka)",
|
|
31
31
|
"contributors": [
|
|
32
|
-
"Solly Ross <sross@redhat.com> (https://github.com/directxman12)",
|
|
33
|
-
"Peter Åstrand <astrand@cendio.se> (https://github.com/astrand)",
|
|
34
32
|
"Samuel Mannehed <samuel@cendio.se> (https://github.com/samhed)",
|
|
35
33
|
"Pierre Ossman <ossman@cendio.se> (https://github.com/CendioOssman)"
|
|
36
34
|
],
|