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