@novnc/novnc 1.3.0-beta → 1.3.0-g0ef7582
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 +13 -3
- package/core/decoders/jpeg.js +141 -0
- package/core/decoders/raw.js +1 -1
- package/core/decoders/zrle.js +185 -0
- package/core/display.js +12 -0
- package/core/encodings.js +4 -0
- package/core/input/keyboard.js +10 -0
- package/core/ra2.js +567 -0
- package/core/rfb.js +393 -84
- package/core/util/md5.js +79 -0
- package/docs/API.md +105 -4
- package/lib/base64.js +20 -34
- package/lib/decoders/copyrect.js +1 -11
- package/lib/decoders/hextile.js +14 -46
- package/lib/decoders/jpeg.js +146 -0
- package/lib/decoders/raw.js +6 -22
- package/lib/decoders/rre.js +1 -15
- package/lib/decoders/tight.js +10 -78
- package/lib/decoders/tightpng.js +5 -27
- package/lib/decoders/zrle.js +185 -0
- package/lib/deflator.js +5 -22
- package/lib/des.js +20 -36
- package/lib/display.js +59 -107
- package/lib/encodings.js +7 -8
- package/lib/inflator.js +2 -18
- package/lib/input/domkeytable.js +77 -48
- package/lib/input/fixedkeys.js +8 -3
- package/lib/input/gesturehandler.js +82 -152
- package/lib/input/keyboard.js +59 -90
- package/lib/input/keysym.js +14 -270
- package/lib/input/keysymdef.js +5 -7
- package/lib/input/util.js +44 -86
- package/lib/input/vkeys.js +0 -3
- package/lib/input/xtscancodes.js +1 -168
- package/lib/ra2.js +1033 -0
- package/lib/rfb.js +716 -922
- package/lib/util/browser.js +24 -29
- package/lib/util/cursor.js +21 -65
- package/lib/util/element.js +3 -5
- package/lib/util/events.js +25 -32
- package/lib/util/eventtarget.js +1 -13
- package/lib/util/int.js +2 -3
- package/lib/util/logging.js +3 -21
- package/lib/util/md5.js +83 -0
- package/lib/util/strings.js +3 -5
- package/lib/vendor/pako/lib/utils/common.js +10 -19
- package/lib/vendor/pako/lib/zlib/adler32.js +3 -7
- package/lib/vendor/pako/lib/zlib/constants.js +2 -5
- package/lib/vendor/pako/lib/zlib/crc32.js +5 -12
- package/lib/vendor/pako/lib/zlib/deflate.js +218 -622
- package/lib/vendor/pako/lib/zlib/gzheader.js +1 -13
- package/lib/vendor/pako/lib/zlib/inffast.js +60 -172
- package/lib/vendor/pako/lib/zlib/inflate.js +407 -874
- package/lib/vendor/pako/lib/zlib/inftrees.js +63 -169
- package/lib/vendor/pako/lib/zlib/messages.js +1 -11
- package/lib/vendor/pako/lib/zlib/trees.js +248 -590
- package/lib/vendor/pako/lib/zlib/zstream.js +2 -18
- package/lib/websock.js +33 -86
- package/package.json +2 -7
package/lib/display.js
CHANGED
|
@@ -1,67 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
4
|
-
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var Log = _interopRequireWildcard(require("./util/logging.js"));
|
|
11
|
-
|
|
12
9
|
var _base = _interopRequireDefault(require("./base64.js"));
|
|
13
|
-
|
|
14
10
|
var _int = require("./util/int.js");
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
-
|
|
18
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); }
|
|
19
|
-
|
|
20
13
|
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; }
|
|
21
|
-
|
|
22
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
|
-
|
|
24
15
|
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); } }
|
|
25
|
-
|
|
26
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
27
|
-
|
|
16
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
28
17
|
var Display = /*#__PURE__*/function () {
|
|
29
18
|
function Display(target) {
|
|
30
19
|
_classCallCheck(this, Display);
|
|
31
|
-
|
|
32
20
|
this._drawCtx = null;
|
|
33
21
|
this._renderQ = []; // queue drawing actions for in-oder rendering
|
|
22
|
+
this._flushing = false;
|
|
34
23
|
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
// the full frame buffer (logical canvas) size
|
|
37
25
|
this._fbWidth = 0;
|
|
38
26
|
this._fbHeight = 0;
|
|
39
27
|
this._prevDrawStyle = "";
|
|
40
|
-
Log.Debug(">> Display.constructor");
|
|
28
|
+
Log.Debug(">> Display.constructor");
|
|
41
29
|
|
|
30
|
+
// The visible canvas
|
|
42
31
|
this._target = target;
|
|
43
|
-
|
|
44
32
|
if (!this._target) {
|
|
45
33
|
throw new Error("Target must be set");
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
if (typeof this._target === 'string') {
|
|
49
36
|
throw new Error('target must be a DOM element');
|
|
50
37
|
}
|
|
51
|
-
|
|
52
38
|
if (!this._target.getContext) {
|
|
53
39
|
throw new Error("no getContext method");
|
|
54
40
|
}
|
|
41
|
+
this._targetCtx = this._target.getContext('2d');
|
|
55
42
|
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
// the visible canvas viewport (i.e. what actually gets seen)
|
|
58
44
|
this._viewportLoc = {
|
|
59
45
|
'x': 0,
|
|
60
46
|
'y': 0,
|
|
61
47
|
'w': this._target.width,
|
|
62
48
|
'h': this._target.height
|
|
63
|
-
};
|
|
49
|
+
};
|
|
64
50
|
|
|
51
|
+
// The hidden canvas, where we do the actual rendering
|
|
65
52
|
this._backbuffer = document.createElement('canvas');
|
|
66
53
|
this._drawCtx = this._backbuffer.getContext('2d');
|
|
67
54
|
this._damageBounds = {
|
|
@@ -71,16 +58,19 @@ var Display = /*#__PURE__*/function () {
|
|
|
71
58
|
bottom: this._backbuffer.height
|
|
72
59
|
};
|
|
73
60
|
Log.Debug("User Agent: " + navigator.userAgent);
|
|
74
|
-
Log.Debug("<< Display.constructor");
|
|
61
|
+
Log.Debug("<< Display.constructor");
|
|
75
62
|
|
|
76
|
-
|
|
77
|
-
this._clipViewport = false; // ===== EVENT HANDLERS =====
|
|
63
|
+
// ===== PROPERTIES =====
|
|
78
64
|
|
|
79
|
-
this.
|
|
65
|
+
this._scale = 1.0;
|
|
66
|
+
this._clipViewport = false;
|
|
80
67
|
|
|
81
|
-
|
|
68
|
+
// ===== EVENT HANDLERS =====
|
|
82
69
|
|
|
70
|
+
this.onflush = function () {}; // A flush request has finished
|
|
71
|
+
}
|
|
83
72
|
|
|
73
|
+
// ===== PROPERTIES =====
|
|
84
74
|
_createClass(Display, [{
|
|
85
75
|
key: "scale",
|
|
86
76
|
get: function get() {
|
|
@@ -95,8 +85,8 @@ var Display = /*#__PURE__*/function () {
|
|
|
95
85
|
return this._clipViewport;
|
|
96
86
|
},
|
|
97
87
|
set: function set(viewport) {
|
|
98
|
-
this._clipViewport = viewport;
|
|
99
|
-
|
|
88
|
+
this._clipViewport = viewport;
|
|
89
|
+
// May need to readjust the viewport dimensions
|
|
100
90
|
var vp = this._viewportLoc;
|
|
101
91
|
this.viewportChangeSize(vp.w, vp.h);
|
|
102
92
|
this.viewportChangePos(0, 0);
|
|
@@ -110,50 +100,43 @@ var Display = /*#__PURE__*/function () {
|
|
|
110
100
|
key: "height",
|
|
111
101
|
get: function get() {
|
|
112
102
|
return this._fbHeight;
|
|
113
|
-
}
|
|
103
|
+
}
|
|
114
104
|
|
|
105
|
+
// ===== PUBLIC METHODS =====
|
|
115
106
|
}, {
|
|
116
107
|
key: "viewportChangePos",
|
|
117
108
|
value: function viewportChangePos(deltaX, deltaY) {
|
|
118
109
|
var vp = this._viewportLoc;
|
|
119
110
|
deltaX = Math.floor(deltaX);
|
|
120
111
|
deltaY = Math.floor(deltaY);
|
|
121
|
-
|
|
122
112
|
if (!this._clipViewport) {
|
|
123
113
|
deltaX = -vp.w; // clamped later of out of bounds
|
|
124
|
-
|
|
125
114
|
deltaY = -vp.h;
|
|
126
115
|
}
|
|
127
|
-
|
|
128
116
|
var vx2 = vp.x + vp.w - 1;
|
|
129
|
-
var vy2 = vp.y + vp.h - 1;
|
|
117
|
+
var vy2 = vp.y + vp.h - 1;
|
|
118
|
+
|
|
119
|
+
// Position change
|
|
130
120
|
|
|
131
121
|
if (deltaX < 0 && vp.x + deltaX < 0) {
|
|
132
122
|
deltaX = -vp.x;
|
|
133
123
|
}
|
|
134
|
-
|
|
135
124
|
if (vx2 + deltaX >= this._fbWidth) {
|
|
136
125
|
deltaX -= vx2 + deltaX - this._fbWidth + 1;
|
|
137
126
|
}
|
|
138
|
-
|
|
139
127
|
if (vp.y + deltaY < 0) {
|
|
140
128
|
deltaY = -vp.y;
|
|
141
129
|
}
|
|
142
|
-
|
|
143
130
|
if (vy2 + deltaY >= this._fbHeight) {
|
|
144
131
|
deltaY -= vy2 + deltaY - this._fbHeight + 1;
|
|
145
132
|
}
|
|
146
|
-
|
|
147
133
|
if (deltaX === 0 && deltaY === 0) {
|
|
148
134
|
return;
|
|
149
135
|
}
|
|
150
|
-
|
|
151
136
|
Log.Debug("viewportChange deltaX: " + deltaX + ", deltaY: " + deltaY);
|
|
152
137
|
vp.x += deltaX;
|
|
153
138
|
vp.y += deltaY;
|
|
154
|
-
|
|
155
139
|
this._damage(vp.x, vp.y, vp.w, vp.h);
|
|
156
|
-
|
|
157
140
|
this.flip();
|
|
158
141
|
}
|
|
159
142
|
}, {
|
|
@@ -164,33 +147,28 @@ var Display = /*#__PURE__*/function () {
|
|
|
164
147
|
width = this._fbWidth;
|
|
165
148
|
height = this._fbHeight;
|
|
166
149
|
}
|
|
167
|
-
|
|
168
150
|
width = Math.floor(width);
|
|
169
151
|
height = Math.floor(height);
|
|
170
|
-
|
|
171
152
|
if (width > this._fbWidth) {
|
|
172
153
|
width = this._fbWidth;
|
|
173
154
|
}
|
|
174
|
-
|
|
175
155
|
if (height > this._fbHeight) {
|
|
176
156
|
height = this._fbHeight;
|
|
177
157
|
}
|
|
178
|
-
|
|
179
158
|
var vp = this._viewportLoc;
|
|
180
|
-
|
|
181
159
|
if (vp.w !== width || vp.h !== height) {
|
|
182
160
|
vp.w = width;
|
|
183
161
|
vp.h = height;
|
|
184
162
|
var canvas = this._target;
|
|
185
163
|
canvas.width = width;
|
|
186
|
-
canvas.height = height;
|
|
164
|
+
canvas.height = height;
|
|
187
165
|
|
|
166
|
+
// The position might need to be updated if we've grown
|
|
188
167
|
this.viewportChangePos(0, 0);
|
|
189
|
-
|
|
190
168
|
this._damage(vp.x, vp.y, vp.w, vp.h);
|
|
169
|
+
this.flip();
|
|
191
170
|
|
|
192
|
-
|
|
193
|
-
|
|
171
|
+
// Update the visible size of the target canvas
|
|
194
172
|
this._rescale(this._scale);
|
|
195
173
|
}
|
|
196
174
|
}
|
|
@@ -200,7 +178,6 @@ var Display = /*#__PURE__*/function () {
|
|
|
200
178
|
if (this._scale === 0) {
|
|
201
179
|
return 0;
|
|
202
180
|
}
|
|
203
|
-
|
|
204
181
|
return (0, _int.toSigned32bit)(x / this._scale + this._viewportLoc.x);
|
|
205
182
|
}
|
|
206
183
|
}, {
|
|
@@ -209,7 +186,6 @@ var Display = /*#__PURE__*/function () {
|
|
|
209
186
|
if (this._scale === 0) {
|
|
210
187
|
return 0;
|
|
211
188
|
}
|
|
212
|
-
|
|
213
189
|
return (0, _int.toSigned32bit)(y / this._scale + this._viewportLoc.y);
|
|
214
190
|
}
|
|
215
191
|
}, {
|
|
@@ -219,56 +195,65 @@ var Display = /*#__PURE__*/function () {
|
|
|
219
195
|
this._fbWidth = width;
|
|
220
196
|
this._fbHeight = height;
|
|
221
197
|
var canvas = this._backbuffer;
|
|
222
|
-
|
|
223
198
|
if (canvas.width !== width || canvas.height !== height) {
|
|
224
199
|
// We have to save the canvas data since changing the size will clear it
|
|
225
200
|
var saveImg = null;
|
|
226
|
-
|
|
227
201
|
if (canvas.width > 0 && canvas.height > 0) {
|
|
228
202
|
saveImg = this._drawCtx.getImageData(0, 0, canvas.width, canvas.height);
|
|
229
203
|
}
|
|
230
|
-
|
|
231
204
|
if (canvas.width !== width) {
|
|
232
205
|
canvas.width = width;
|
|
233
206
|
}
|
|
234
|
-
|
|
235
207
|
if (canvas.height !== height) {
|
|
236
208
|
canvas.height = height;
|
|
237
209
|
}
|
|
238
|
-
|
|
239
210
|
if (saveImg) {
|
|
240
211
|
this._drawCtx.putImageData(saveImg, 0, 0);
|
|
241
212
|
}
|
|
242
|
-
}
|
|
243
|
-
// and positioned
|
|
244
|
-
|
|
213
|
+
}
|
|
245
214
|
|
|
215
|
+
// Readjust the viewport as it may be incorrectly sized
|
|
216
|
+
// and positioned
|
|
246
217
|
var vp = this._viewportLoc;
|
|
247
218
|
this.viewportChangeSize(vp.w, vp.h);
|
|
248
219
|
this.viewportChangePos(0, 0);
|
|
249
|
-
}
|
|
220
|
+
}
|
|
221
|
+
}, {
|
|
222
|
+
key: "getImageData",
|
|
223
|
+
value: function getImageData() {
|
|
224
|
+
return this._drawCtx.getImageData(0, 0, this.width, this.height);
|
|
225
|
+
}
|
|
226
|
+
}, {
|
|
227
|
+
key: "toDataURL",
|
|
228
|
+
value: function toDataURL(type, encoderOptions) {
|
|
229
|
+
return this._backbuffer.toDataURL(type, encoderOptions);
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
232
|
+
key: "toBlob",
|
|
233
|
+
value: function toBlob(callback, type, quality) {
|
|
234
|
+
return this._backbuffer.toBlob(callback, type, quality);
|
|
235
|
+
}
|
|
250
236
|
|
|
237
|
+
// Track what parts of the visible canvas that need updating
|
|
251
238
|
}, {
|
|
252
239
|
key: "_damage",
|
|
253
240
|
value: function _damage(x, y, w, h) {
|
|
254
241
|
if (x < this._damageBounds.left) {
|
|
255
242
|
this._damageBounds.left = x;
|
|
256
243
|
}
|
|
257
|
-
|
|
258
244
|
if (y < this._damageBounds.top) {
|
|
259
245
|
this._damageBounds.top = y;
|
|
260
246
|
}
|
|
261
|
-
|
|
262
247
|
if (x + w > this._damageBounds.right) {
|
|
263
248
|
this._damageBounds.right = x + w;
|
|
264
249
|
}
|
|
265
|
-
|
|
266
250
|
if (y + h > this._damageBounds.bottom) {
|
|
267
251
|
this._damageBounds.bottom = y + h;
|
|
268
252
|
}
|
|
269
|
-
}
|
|
270
|
-
// rendering canvas
|
|
253
|
+
}
|
|
271
254
|
|
|
255
|
+
// Update the visible canvas with the contents of the
|
|
256
|
+
// rendering canvas
|
|
272
257
|
}, {
|
|
273
258
|
key: "flip",
|
|
274
259
|
value: function flip(fromQueue) {
|
|
@@ -283,34 +268,28 @@ var Display = /*#__PURE__*/function () {
|
|
|
283
268
|
var h = this._damageBounds.bottom - y;
|
|
284
269
|
var vx = x - this._viewportLoc.x;
|
|
285
270
|
var vy = y - this._viewportLoc.y;
|
|
286
|
-
|
|
287
271
|
if (vx < 0) {
|
|
288
272
|
w += vx;
|
|
289
273
|
x -= vx;
|
|
290
274
|
vx = 0;
|
|
291
275
|
}
|
|
292
|
-
|
|
293
276
|
if (vy < 0) {
|
|
294
277
|
h += vy;
|
|
295
278
|
y -= vy;
|
|
296
279
|
vy = 0;
|
|
297
280
|
}
|
|
298
|
-
|
|
299
281
|
if (vx + w > this._viewportLoc.w) {
|
|
300
282
|
w = this._viewportLoc.w - vx;
|
|
301
283
|
}
|
|
302
|
-
|
|
303
284
|
if (vy + h > this._viewportLoc.h) {
|
|
304
285
|
h = this._viewportLoc.h - vy;
|
|
305
286
|
}
|
|
306
|
-
|
|
307
287
|
if (w > 0 && h > 0) {
|
|
308
288
|
// FIXME: We may need to disable image smoothing here
|
|
309
289
|
// as well (see copyImage()), but we haven't
|
|
310
290
|
// noticed any problem yet.
|
|
311
291
|
this._targetCtx.drawImage(this._backbuffer, x, y, w, h, vx, vy, w, h);
|
|
312
292
|
}
|
|
313
|
-
|
|
314
293
|
this._damageBounds.left = this._damageBounds.top = 65535;
|
|
315
294
|
this._damageBounds.right = this._damageBounds.bottom = 0;
|
|
316
295
|
}
|
|
@@ -343,9 +322,7 @@ var Display = /*#__PURE__*/function () {
|
|
|
343
322
|
});
|
|
344
323
|
} else {
|
|
345
324
|
this._setFillColor(color);
|
|
346
|
-
|
|
347
325
|
this._drawCtx.fillRect(x, y, width, height);
|
|
348
|
-
|
|
349
326
|
this._damage(x, y, width, height);
|
|
350
327
|
}
|
|
351
328
|
}
|
|
@@ -374,9 +351,7 @@ var Display = /*#__PURE__*/function () {
|
|
|
374
351
|
this._drawCtx.webkitImageSmoothingEnabled = false;
|
|
375
352
|
this._drawCtx.msImageSmoothingEnabled = false;
|
|
376
353
|
this._drawCtx.imageSmoothingEnabled = false;
|
|
377
|
-
|
|
378
354
|
this._drawCtx.drawImage(this._backbuffer, oldX, oldY, w, h, newX, newY, w, h);
|
|
379
|
-
|
|
380
355
|
this._damage(newX, newY, w, h);
|
|
381
356
|
}
|
|
382
357
|
}
|
|
@@ -387,10 +362,8 @@ var Display = /*#__PURE__*/function () {
|
|
|
387
362
|
if (width === 0 || height === 0) {
|
|
388
363
|
return;
|
|
389
364
|
}
|
|
390
|
-
|
|
391
365
|
var img = new Image();
|
|
392
366
|
img.src = "data: " + mime + ";base64," + _base["default"].encode(arr);
|
|
393
|
-
|
|
394
367
|
this._renderQPush({
|
|
395
368
|
'type': 'img',
|
|
396
369
|
'img': img,
|
|
@@ -409,7 +382,6 @@ var Display = /*#__PURE__*/function () {
|
|
|
409
382
|
// this probably isn't getting called *nearly* as much
|
|
410
383
|
var newArr = new Uint8Array(width * height * 4);
|
|
411
384
|
newArr.set(new Uint8Array(arr.buffer, 0, newArr.length));
|
|
412
|
-
|
|
413
385
|
this._renderQPush({
|
|
414
386
|
'type': 'blit',
|
|
415
387
|
'data': newArr,
|
|
@@ -422,9 +394,7 @@ var Display = /*#__PURE__*/function () {
|
|
|
422
394
|
// NB(directxman12): arr must be an Type Array view
|
|
423
395
|
var data = new Uint8ClampedArray(arr.buffer, arr.byteOffset + offset, width * height * 4);
|
|
424
396
|
var img = new ImageData(data, width, height);
|
|
425
|
-
|
|
426
397
|
this._drawCtx.putImageData(img, x, y);
|
|
427
|
-
|
|
428
398
|
this._damage(x, y, width, height);
|
|
429
399
|
}
|
|
430
400
|
}
|
|
@@ -432,43 +402,40 @@ var Display = /*#__PURE__*/function () {
|
|
|
432
402
|
key: "drawImage",
|
|
433
403
|
value: function drawImage(img, x, y) {
|
|
434
404
|
this._drawCtx.drawImage(img, x, y);
|
|
435
|
-
|
|
436
405
|
this._damage(x, y, img.width, img.height);
|
|
437
406
|
}
|
|
438
407
|
}, {
|
|
439
408
|
key: "autoscale",
|
|
440
409
|
value: function autoscale(containerWidth, containerHeight) {
|
|
441
410
|
var scaleRatio;
|
|
442
|
-
|
|
443
411
|
if (containerWidth === 0 || containerHeight === 0) {
|
|
444
412
|
scaleRatio = 0;
|
|
445
413
|
} else {
|
|
446
414
|
var vp = this._viewportLoc;
|
|
447
415
|
var targetAspectRatio = containerWidth / containerHeight;
|
|
448
416
|
var fbAspectRatio = vp.w / vp.h;
|
|
449
|
-
|
|
450
417
|
if (fbAspectRatio >= targetAspectRatio) {
|
|
451
418
|
scaleRatio = containerWidth / vp.w;
|
|
452
419
|
} else {
|
|
453
420
|
scaleRatio = containerHeight / vp.h;
|
|
454
421
|
}
|
|
455
422
|
}
|
|
456
|
-
|
|
457
423
|
this._rescale(scaleRatio);
|
|
458
|
-
}
|
|
424
|
+
}
|
|
459
425
|
|
|
426
|
+
// ===== PRIVATE METHODS =====
|
|
460
427
|
}, {
|
|
461
428
|
key: "_rescale",
|
|
462
429
|
value: function _rescale(factor) {
|
|
463
430
|
this._scale = factor;
|
|
464
|
-
var vp = this._viewportLoc;
|
|
431
|
+
var vp = this._viewportLoc;
|
|
432
|
+
|
|
433
|
+
// NB(directxman12): If you set the width directly, or set the
|
|
465
434
|
// style width to a number, the canvas is cleared.
|
|
466
435
|
// However, if you set the style width to a string
|
|
467
436
|
// ('NNNpx'), the canvas is scaled without clearing.
|
|
468
|
-
|
|
469
437
|
var width = factor * vp.w + 'px';
|
|
470
438
|
var height = factor * vp.h + 'px';
|
|
471
|
-
|
|
472
439
|
if (this._target.style.width !== width || this._target.style.height !== height) {
|
|
473
440
|
this._target.style.width = width;
|
|
474
441
|
this._target.style.height = height;
|
|
@@ -478,7 +445,6 @@ var Display = /*#__PURE__*/function () {
|
|
|
478
445
|
key: "_setFillColor",
|
|
479
446
|
value: function _setFillColor(color) {
|
|
480
447
|
var newStyle = 'rgb(' + color[0] + ',' + color[1] + ',' + color[2] + ')';
|
|
481
|
-
|
|
482
448
|
if (newStyle !== this._prevDrawStyle) {
|
|
483
449
|
this._drawCtx.fillStyle = newStyle;
|
|
484
450
|
this._prevDrawStyle = newStyle;
|
|
@@ -488,7 +454,6 @@ var Display = /*#__PURE__*/function () {
|
|
|
488
454
|
key: "_renderQPush",
|
|
489
455
|
value: function _renderQPush(action) {
|
|
490
456
|
this._renderQ.push(action);
|
|
491
|
-
|
|
492
457
|
if (this._renderQ.length === 1) {
|
|
493
458
|
// If this can be rendered immediately it will be, otherwise
|
|
494
459
|
// the scanner will wait for the relevant event
|
|
@@ -501,66 +466,53 @@ var Display = /*#__PURE__*/function () {
|
|
|
501
466
|
// "this" is the object that is ready, not the
|
|
502
467
|
// display object
|
|
503
468
|
this.removeEventListener('load', this._noVNCDisplay._resumeRenderQ);
|
|
504
|
-
|
|
505
469
|
this._noVNCDisplay._scanRenderQ();
|
|
506
470
|
}
|
|
507
471
|
}, {
|
|
508
472
|
key: "_scanRenderQ",
|
|
509
473
|
value: function _scanRenderQ() {
|
|
510
474
|
var ready = true;
|
|
511
|
-
|
|
512
475
|
while (ready && this._renderQ.length > 0) {
|
|
513
476
|
var a = this._renderQ[0];
|
|
514
|
-
|
|
515
477
|
switch (a.type) {
|
|
516
478
|
case 'flip':
|
|
517
479
|
this.flip(true);
|
|
518
480
|
break;
|
|
519
|
-
|
|
520
481
|
case 'copy':
|
|
521
482
|
this.copyImage(a.oldX, a.oldY, a.x, a.y, a.width, a.height, true);
|
|
522
483
|
break;
|
|
523
|
-
|
|
524
484
|
case 'fill':
|
|
525
485
|
this.fillRect(a.x, a.y, a.width, a.height, a.color, true);
|
|
526
486
|
break;
|
|
527
|
-
|
|
528
487
|
case 'blit':
|
|
529
488
|
this.blitImage(a.x, a.y, a.width, a.height, a.data, 0, true);
|
|
530
489
|
break;
|
|
531
|
-
|
|
532
490
|
case 'img':
|
|
533
491
|
if (a.img.complete) {
|
|
534
492
|
if (a.img.width !== a.width || a.img.height !== a.height) {
|
|
535
493
|
Log.Error("Decoded image has incorrect dimensions. Got " + a.img.width + "x" + a.img.height + ". Expected " + a.width + "x" + a.height + ".");
|
|
536
494
|
return;
|
|
537
495
|
}
|
|
538
|
-
|
|
539
496
|
this.drawImage(a.img, a.x, a.y);
|
|
540
497
|
} else {
|
|
541
498
|
a.img._noVNCDisplay = this;
|
|
542
|
-
a.img.addEventListener('load', this._resumeRenderQ);
|
|
499
|
+
a.img.addEventListener('load', this._resumeRenderQ);
|
|
500
|
+
// We need to wait for this image to 'load'
|
|
543
501
|
// to keep things in-order
|
|
544
|
-
|
|
545
502
|
ready = false;
|
|
546
503
|
}
|
|
547
|
-
|
|
548
504
|
break;
|
|
549
505
|
}
|
|
550
|
-
|
|
551
506
|
if (ready) {
|
|
552
507
|
this._renderQ.shift();
|
|
553
508
|
}
|
|
554
509
|
}
|
|
555
|
-
|
|
556
510
|
if (this._renderQ.length === 0 && this._flushing) {
|
|
557
511
|
this._flushing = false;
|
|
558
512
|
this.onflush();
|
|
559
513
|
}
|
|
560
514
|
}
|
|
561
515
|
}]);
|
|
562
|
-
|
|
563
516
|
return Display;
|
|
564
517
|
}();
|
|
565
|
-
|
|
566
518
|
exports["default"] = Display;
|
package/lib/encodings.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.encodingName = encodingName;
|
|
7
7
|
exports.encodings = void 0;
|
|
8
|
-
|
|
9
8
|
/*
|
|
10
9
|
* noVNC: HTML5 VNC client
|
|
11
10
|
* Copyright (C) 2019 The noVNC Authors
|
|
@@ -13,13 +12,16 @@ exports.encodings = void 0;
|
|
|
13
12
|
*
|
|
14
13
|
* See README.md for usage and integration instructions.
|
|
15
14
|
*/
|
|
15
|
+
|
|
16
16
|
var encodings = {
|
|
17
17
|
encodingRaw: 0,
|
|
18
18
|
encodingCopyRect: 1,
|
|
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,
|
|
@@ -37,27 +39,24 @@ var encodings = {
|
|
|
37
39
|
pseudoEncodingExtendedClipboard: 0xc0a1e5ce
|
|
38
40
|
};
|
|
39
41
|
exports.encodings = encodings;
|
|
40
|
-
|
|
41
42
|
function encodingName(num) {
|
|
42
43
|
switch (num) {
|
|
43
44
|
case encodings.encodingRaw:
|
|
44
45
|
return "Raw";
|
|
45
|
-
|
|
46
46
|
case encodings.encodingCopyRect:
|
|
47
47
|
return "CopyRect";
|
|
48
|
-
|
|
49
48
|
case encodings.encodingRRE:
|
|
50
49
|
return "RRE";
|
|
51
|
-
|
|
52
50
|
case encodings.encodingHextile:
|
|
53
51
|
return "Hextile";
|
|
54
|
-
|
|
55
52
|
case encodings.encodingTight:
|
|
56
53
|
return "Tight";
|
|
57
|
-
|
|
54
|
+
case encodings.encodingZRLE:
|
|
55
|
+
return "ZRLE";
|
|
58
56
|
case encodings.encodingTightPNG:
|
|
59
57
|
return "TightPNG";
|
|
60
|
-
|
|
58
|
+
case encodings.encodingJPEG:
|
|
59
|
+
return "JPEG";
|
|
61
60
|
default:
|
|
62
61
|
return "[unknown encoding " + num + "]";
|
|
63
62
|
}
|
package/lib/inflator.js
CHANGED
|
@@ -4,36 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _inflate2 = require("../lib/vendor/pako/lib/zlib/inflate.js");
|
|
9
|
-
|
|
10
8
|
var _zstream = _interopRequireDefault(require("../lib/vendor/pako/lib/zlib/zstream.js"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
-
|
|
16
11
|
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); } }
|
|
17
|
-
|
|
18
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
19
|
-
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
13
|
var Inflate = /*#__PURE__*/function () {
|
|
21
14
|
function Inflate() {
|
|
22
15
|
_classCallCheck(this, Inflate);
|
|
23
|
-
|
|
24
16
|
this.strm = new _zstream["default"]();
|
|
25
17
|
this.chunkSize = 1024 * 10 * 10;
|
|
26
18
|
this.strm.output = new Uint8Array(this.chunkSize);
|
|
27
19
|
this.windowBits = 5;
|
|
28
20
|
(0, _inflate2.inflateInit)(this.strm, this.windowBits);
|
|
29
21
|
}
|
|
30
|
-
|
|
31
22
|
_createClass(Inflate, [{
|
|
32
23
|
key: "setInput",
|
|
33
24
|
value: function setInput(data) {
|
|
34
25
|
if (!data) {
|
|
35
26
|
//FIXME: flush remaining data.
|
|
36
|
-
|
|
37
27
|
/* eslint-disable camelcase */
|
|
38
28
|
this.strm.input = null;
|
|
39
29
|
this.strm.avail_in = 0;
|
|
@@ -55,23 +45,19 @@ var Inflate = /*#__PURE__*/function () {
|
|
|
55
45
|
this.chunkSize = expected;
|
|
56
46
|
this.strm.output = new Uint8Array(this.chunkSize);
|
|
57
47
|
}
|
|
58
|
-
/* eslint-disable camelcase */
|
|
59
|
-
|
|
60
48
|
|
|
49
|
+
/* eslint-disable camelcase */
|
|
61
50
|
this.strm.next_out = 0;
|
|
62
51
|
this.strm.avail_out = expected;
|
|
63
52
|
/* eslint-enable camelcase */
|
|
64
53
|
|
|
65
54
|
var ret = (0, _inflate2.inflate)(this.strm, 0); // Flush argument not used.
|
|
66
|
-
|
|
67
55
|
if (ret < 0) {
|
|
68
56
|
throw new Error("zlib inflate failed");
|
|
69
57
|
}
|
|
70
|
-
|
|
71
58
|
if (this.strm.next_out != expected) {
|
|
72
59
|
throw new Error("Incomplete zlib block");
|
|
73
60
|
}
|
|
74
|
-
|
|
75
61
|
return new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
|
|
76
62
|
}
|
|
77
63
|
}, {
|
|
@@ -80,8 +66,6 @@ var Inflate = /*#__PURE__*/function () {
|
|
|
80
66
|
(0, _inflate2.inflateReset)(this.strm);
|
|
81
67
|
}
|
|
82
68
|
}]);
|
|
83
|
-
|
|
84
69
|
return Inflate;
|
|
85
70
|
}();
|
|
86
|
-
|
|
87
71
|
exports["default"] = Inflate;
|