@novnc/novnc 1.5.0 → 1.6.0-beta-gb45f35c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +1 -1
- package/README.md +26 -25
- package/docs/LIBRARY.md +1 -1
- package/lib/crypto/aes.js +12 -12
- package/lib/crypto/md5.js +2 -2
- package/lib/crypto/rsa.js +7 -7
- package/lib/decoders/copyrect.js +1 -1
- package/lib/decoders/h264.js +349 -0
- package/lib/decoders/hextile.js +1 -1
- package/lib/decoders/jpeg.js +1 -1
- package/lib/decoders/raw.js +1 -1
- package/lib/decoders/rre.js +1 -1
- package/lib/decoders/tight.js +1 -1
- package/lib/decoders/tightpng.js +1 -1
- package/lib/decoders/zlib.js +57 -0
- package/lib/decoders/zrle.js +1 -1
- package/lib/deflator.js +1 -1
- package/lib/display.js +98 -37
- package/lib/encodings.js +8 -1
- package/lib/inflator.js +1 -1
- package/lib/input/domkeytable.js +1 -1
- package/lib/input/fixedkeys.js +1 -1
- package/lib/input/gesturehandler.js +1 -1
- package/lib/input/keyboard.js +13 -12
- package/lib/input/vkeys.js +1 -1
- package/lib/ra2.js +4 -4
- package/lib/rfb.js +278 -105
- package/lib/util/browser.js +98 -6
- package/lib/util/cursor.js +1 -1
- package/lib/util/element.js +1 -1
- package/lib/util/events.js +1 -1
- package/lib/util/eventtarget.js +1 -1
- package/lib/util/int.js +1 -1
- package/lib/util/logging.js +1 -1
- package/lib/util/strings.js +1 -1
- package/lib/websock.js +7 -7
- package/package.json +2 -4
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.H264Parser = exports.H264Context = void 0;
|
|
7
|
+
var Log = _interopRequireWildcard(require("../util/logging.js"));
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
10
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
17
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
18
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
19
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
20
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
21
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
|
22
|
+
* noVNC: HTML5 VNC client
|
|
23
|
+
* Copyright (C) 2024 The noVNC authors
|
|
24
|
+
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
25
|
+
*
|
|
26
|
+
* See README.md for usage and integration instructions.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
var H264Parser = exports.H264Parser = /*#__PURE__*/function () {
|
|
30
|
+
function H264Parser(data) {
|
|
31
|
+
_classCallCheck(this, H264Parser);
|
|
32
|
+
this._data = data;
|
|
33
|
+
this._index = 0;
|
|
34
|
+
this.profileIdc = null;
|
|
35
|
+
this.constraintSet = null;
|
|
36
|
+
this.levelIdc = null;
|
|
37
|
+
}
|
|
38
|
+
return _createClass(H264Parser, [{
|
|
39
|
+
key: "_getStartSequenceLen",
|
|
40
|
+
value: function _getStartSequenceLen(index) {
|
|
41
|
+
var data = this._data;
|
|
42
|
+
if (data[index + 0] == 0 && data[index + 1] == 0 && data[index + 2] == 0 && data[index + 3] == 1) {
|
|
43
|
+
return 4;
|
|
44
|
+
}
|
|
45
|
+
if (data[index + 0] == 0 && data[index + 1] == 0 && data[index + 2] == 1) {
|
|
46
|
+
return 3;
|
|
47
|
+
}
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
key: "_indexOfNextNalUnit",
|
|
52
|
+
value: function _indexOfNextNalUnit(index) {
|
|
53
|
+
var data = this._data;
|
|
54
|
+
for (var i = index; i < data.length; ++i) {
|
|
55
|
+
if (this._getStartSequenceLen(i) != 0) {
|
|
56
|
+
return i;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return -1;
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "_parseSps",
|
|
63
|
+
value: function _parseSps(index) {
|
|
64
|
+
this.profileIdc = this._data[index];
|
|
65
|
+
this.constraintSet = this._data[index + 1];
|
|
66
|
+
this.levelIdc = this._data[index + 2];
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "_parseNalUnit",
|
|
70
|
+
value: function _parseNalUnit(index) {
|
|
71
|
+
var firstByte = this._data[index];
|
|
72
|
+
if (firstByte & 0x80) {
|
|
73
|
+
throw new Error('H264 parsing sanity check failed, forbidden zero bit is set');
|
|
74
|
+
}
|
|
75
|
+
var unitType = firstByte & 0x1f;
|
|
76
|
+
switch (unitType) {
|
|
77
|
+
case 1:
|
|
78
|
+
// coded slice, non-idr
|
|
79
|
+
return {
|
|
80
|
+
slice: true
|
|
81
|
+
};
|
|
82
|
+
case 5:
|
|
83
|
+
// coded slice, idr
|
|
84
|
+
return {
|
|
85
|
+
slice: true,
|
|
86
|
+
key: true
|
|
87
|
+
};
|
|
88
|
+
case 6:
|
|
89
|
+
// sei
|
|
90
|
+
return {};
|
|
91
|
+
case 7:
|
|
92
|
+
// sps
|
|
93
|
+
this._parseSps(index + 1);
|
|
94
|
+
return {};
|
|
95
|
+
case 8:
|
|
96
|
+
// pps
|
|
97
|
+
return {};
|
|
98
|
+
default:
|
|
99
|
+
Log.Warn("Unhandled unit type: ", unitType);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
return {};
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "parse",
|
|
106
|
+
value: function parse() {
|
|
107
|
+
var startIndex = this._index;
|
|
108
|
+
var isKey = false;
|
|
109
|
+
while (this._index < this._data.length) {
|
|
110
|
+
var startSequenceLen = this._getStartSequenceLen(this._index);
|
|
111
|
+
if (startSequenceLen == 0) {
|
|
112
|
+
throw new Error('Invalid start sequence in bit stream');
|
|
113
|
+
}
|
|
114
|
+
var _this$_parseNalUnit = this._parseNalUnit(this._index + startSequenceLen),
|
|
115
|
+
slice = _this$_parseNalUnit.slice,
|
|
116
|
+
key = _this$_parseNalUnit.key;
|
|
117
|
+
var nextIndex = this._indexOfNextNalUnit(this._index + startSequenceLen);
|
|
118
|
+
if (nextIndex == -1) {
|
|
119
|
+
this._index = this._data.length;
|
|
120
|
+
} else {
|
|
121
|
+
this._index = nextIndex;
|
|
122
|
+
}
|
|
123
|
+
if (key) {
|
|
124
|
+
isKey = true;
|
|
125
|
+
}
|
|
126
|
+
if (slice) {
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (startIndex === this._index) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
frame: this._data.subarray(startIndex, this._index),
|
|
135
|
+
key: isKey
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}]);
|
|
139
|
+
}();
|
|
140
|
+
var H264Context = exports.H264Context = /*#__PURE__*/function () {
|
|
141
|
+
function H264Context(width, height) {
|
|
142
|
+
_classCallCheck(this, H264Context);
|
|
143
|
+
this.lastUsed = 0;
|
|
144
|
+
this._width = width;
|
|
145
|
+
this._height = height;
|
|
146
|
+
this._profileIdc = null;
|
|
147
|
+
this._constraintSet = null;
|
|
148
|
+
this._levelIdc = null;
|
|
149
|
+
this._decoder = null;
|
|
150
|
+
this._pendingFrames = [];
|
|
151
|
+
}
|
|
152
|
+
return _createClass(H264Context, [{
|
|
153
|
+
key: "_handleFrame",
|
|
154
|
+
value: function _handleFrame(frame) {
|
|
155
|
+
var pending = this._pendingFrames.shift();
|
|
156
|
+
if (pending === undefined) {
|
|
157
|
+
throw new Error("Pending frame queue empty when receiving frame from decoder");
|
|
158
|
+
}
|
|
159
|
+
if (pending.timestamp != frame.timestamp) {
|
|
160
|
+
throw new Error("Video frame timestamp mismatch. Expected " + frame.timestamp + " but but got " + pending.timestamp);
|
|
161
|
+
}
|
|
162
|
+
pending.frame = frame;
|
|
163
|
+
pending.ready = true;
|
|
164
|
+
pending.resolve();
|
|
165
|
+
if (!pending.keep) {
|
|
166
|
+
frame.close();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}, {
|
|
170
|
+
key: "_handleError",
|
|
171
|
+
value: function _handleError(e) {
|
|
172
|
+
throw new Error("Failed to decode frame: " + e.message);
|
|
173
|
+
}
|
|
174
|
+
}, {
|
|
175
|
+
key: "_configureDecoder",
|
|
176
|
+
value: function _configureDecoder(profileIdc, constraintSet, levelIdc) {
|
|
177
|
+
var _this = this;
|
|
178
|
+
if (this._decoder === null || this._decoder.state === 'closed') {
|
|
179
|
+
this._decoder = new VideoDecoder({
|
|
180
|
+
output: function output(frame) {
|
|
181
|
+
return _this._handleFrame(frame);
|
|
182
|
+
},
|
|
183
|
+
error: function error(e) {
|
|
184
|
+
return _this._handleError(e);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
var codec = 'avc1.' + profileIdc.toString(16).padStart(2, '0') + constraintSet.toString(16).padStart(2, '0') + levelIdc.toString(16).padStart(2, '0');
|
|
189
|
+
this._decoder.configure({
|
|
190
|
+
codec: codec,
|
|
191
|
+
codedWidth: this._width,
|
|
192
|
+
codedHeight: this._height,
|
|
193
|
+
optimizeForLatency: true
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}, {
|
|
197
|
+
key: "_preparePendingFrame",
|
|
198
|
+
value: function _preparePendingFrame(timestamp) {
|
|
199
|
+
var pending = {
|
|
200
|
+
timestamp: timestamp,
|
|
201
|
+
promise: null,
|
|
202
|
+
resolve: null,
|
|
203
|
+
frame: null,
|
|
204
|
+
ready: false,
|
|
205
|
+
keep: false
|
|
206
|
+
};
|
|
207
|
+
pending.promise = new Promise(function (resolve) {
|
|
208
|
+
pending.resolve = resolve;
|
|
209
|
+
});
|
|
210
|
+
this._pendingFrames.push(pending);
|
|
211
|
+
return pending;
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
key: "decode",
|
|
215
|
+
value: function decode(payload) {
|
|
216
|
+
var parser = new H264Parser(payload);
|
|
217
|
+
var result = null;
|
|
218
|
+
|
|
219
|
+
// Ideally, this timestamp should come from the server, but we'll just
|
|
220
|
+
// approximate it instead.
|
|
221
|
+
var timestamp = Math.round(window.performance.now() * 1e3);
|
|
222
|
+
while (true) {
|
|
223
|
+
var encodedFrame = parser.parse();
|
|
224
|
+
if (encodedFrame === null) {
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
if (parser.profileIdc !== null) {
|
|
228
|
+
self._profileIdc = parser.profileIdc;
|
|
229
|
+
self._constraintSet = parser.constraintSet;
|
|
230
|
+
self._levelIdc = parser.levelIdc;
|
|
231
|
+
}
|
|
232
|
+
if (this._decoder === null || this._decoder.state !== 'configured') {
|
|
233
|
+
if (!encodedFrame.key) {
|
|
234
|
+
Log.Warn("Missing key frame. Can't decode until one arrives");
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (self._profileIdc === null) {
|
|
238
|
+
Log.Warn('Cannot config decoder. Have not received SPS and PPS yet.');
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
this._configureDecoder(self._profileIdc, self._constraintSet, self._levelIdc);
|
|
242
|
+
}
|
|
243
|
+
result = this._preparePendingFrame(timestamp);
|
|
244
|
+
var chunk = new EncodedVideoChunk({
|
|
245
|
+
timestamp: timestamp,
|
|
246
|
+
type: encodedFrame.key ? 'key' : 'delta',
|
|
247
|
+
data: encodedFrame.frame
|
|
248
|
+
});
|
|
249
|
+
try {
|
|
250
|
+
this._decoder.decode(chunk);
|
|
251
|
+
} catch (e) {
|
|
252
|
+
Log.Warn("Failed to decode:", e);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// We only keep last frame of each payload
|
|
257
|
+
if (result !== null) {
|
|
258
|
+
result.keep = true;
|
|
259
|
+
}
|
|
260
|
+
return result;
|
|
261
|
+
}
|
|
262
|
+
}]);
|
|
263
|
+
}();
|
|
264
|
+
var H264Decoder = exports["default"] = /*#__PURE__*/function () {
|
|
265
|
+
function H264Decoder() {
|
|
266
|
+
_classCallCheck(this, H264Decoder);
|
|
267
|
+
this._tick = 0;
|
|
268
|
+
this._contexts = {};
|
|
269
|
+
}
|
|
270
|
+
return _createClass(H264Decoder, [{
|
|
271
|
+
key: "_contextId",
|
|
272
|
+
value: function _contextId(x, y, width, height) {
|
|
273
|
+
return [x, y, width, height].join(',');
|
|
274
|
+
}
|
|
275
|
+
}, {
|
|
276
|
+
key: "_findOldestContextId",
|
|
277
|
+
value: function _findOldestContextId() {
|
|
278
|
+
var oldestTick = Number.MAX_VALUE;
|
|
279
|
+
var oldestKey = undefined;
|
|
280
|
+
for (var _i = 0, _Object$entries = Object.entries(this._contexts); _i < _Object$entries.length; _i++) {
|
|
281
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
282
|
+
key = _Object$entries$_i[0],
|
|
283
|
+
value = _Object$entries$_i[1];
|
|
284
|
+
if (value.lastUsed < oldestTick) {
|
|
285
|
+
oldestTick = value.lastUsed;
|
|
286
|
+
oldestKey = key;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return oldestKey;
|
|
290
|
+
}
|
|
291
|
+
}, {
|
|
292
|
+
key: "_createContext",
|
|
293
|
+
value: function _createContext(x, y, width, height) {
|
|
294
|
+
var maxContexts = 64;
|
|
295
|
+
if (Object.keys(this._contexts).length >= maxContexts) {
|
|
296
|
+
var oldestContextId = this._findOldestContextId();
|
|
297
|
+
delete this._contexts[oldestContextId];
|
|
298
|
+
}
|
|
299
|
+
var context = new H264Context(width, height);
|
|
300
|
+
this._contexts[this._contextId(x, y, width, height)] = context;
|
|
301
|
+
return context;
|
|
302
|
+
}
|
|
303
|
+
}, {
|
|
304
|
+
key: "_getContext",
|
|
305
|
+
value: function _getContext(x, y, width, height) {
|
|
306
|
+
var context = this._contexts[this._contextId(x, y, width, height)];
|
|
307
|
+
return context !== undefined ? context : this._createContext(x, y, width, height);
|
|
308
|
+
}
|
|
309
|
+
}, {
|
|
310
|
+
key: "_resetContext",
|
|
311
|
+
value: function _resetContext(x, y, width, height) {
|
|
312
|
+
delete this._contexts[this._contextId(x, y, width, height)];
|
|
313
|
+
}
|
|
314
|
+
}, {
|
|
315
|
+
key: "_resetAllContexts",
|
|
316
|
+
value: function _resetAllContexts() {
|
|
317
|
+
this._contexts = {};
|
|
318
|
+
}
|
|
319
|
+
}, {
|
|
320
|
+
key: "decodeRect",
|
|
321
|
+
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
322
|
+
var resetContextFlag = 1;
|
|
323
|
+
var resetAllContextsFlag = 2;
|
|
324
|
+
if (sock.rQwait("h264 header", 8)) {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
var length = sock.rQshift32();
|
|
328
|
+
var flags = sock.rQshift32();
|
|
329
|
+
if (sock.rQwait("h264 payload", length, 8)) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
if (flags & resetAllContextsFlag) {
|
|
333
|
+
this._resetAllContexts();
|
|
334
|
+
} else if (flags & resetContextFlag) {
|
|
335
|
+
this._resetContext(x, y, width, height);
|
|
336
|
+
}
|
|
337
|
+
var context = this._getContext(x, y, width, height);
|
|
338
|
+
context.lastUsed = this._tick++;
|
|
339
|
+
if (length !== 0) {
|
|
340
|
+
var payload = sock.rQshiftBytes(length, false);
|
|
341
|
+
var frame = context.decode(payload);
|
|
342
|
+
if (frame !== null) {
|
|
343
|
+
display.videoFrame(x, y, width, height, frame);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
}]);
|
|
349
|
+
}();
|
package/lib/decoders/hextile.js
CHANGED
|
@@ -14,7 +14,7 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
|
|
|
14
14
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
15
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
|
16
16
|
* noVNC: HTML5 VNC client
|
|
17
|
-
* Copyright (C) 2019 The noVNC
|
|
17
|
+
* Copyright (C) 2019 The noVNC authors
|
|
18
18
|
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
19
19
|
*
|
|
20
20
|
* See README.md for usage and integration instructions.
|
package/lib/decoders/jpeg.js
CHANGED
|
@@ -19,7 +19,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
19
19
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
20
|
/*
|
|
21
21
|
* noVNC: HTML5 VNC client
|
|
22
|
-
* Copyright (C) 2019 The noVNC
|
|
22
|
+
* Copyright (C) 2019 The noVNC authors
|
|
23
23
|
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
24
24
|
*
|
|
25
25
|
* See README.md for usage and integration instructions.
|
package/lib/decoders/raw.js
CHANGED
|
@@ -12,7 +12,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
12
12
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
13
|
/*
|
|
14
14
|
* noVNC: HTML5 VNC client
|
|
15
|
-
* Copyright (C) 2019 The noVNC
|
|
15
|
+
* Copyright (C) 2019 The noVNC authors
|
|
16
16
|
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
17
17
|
*
|
|
18
18
|
* See README.md for usage and integration instructions.
|
package/lib/decoders/rre.js
CHANGED
|
@@ -12,7 +12,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
12
12
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
13
|
/*
|
|
14
14
|
* noVNC: HTML5 VNC client
|
|
15
|
-
* Copyright (C) 2019 The noVNC
|
|
15
|
+
* Copyright (C) 2019 The noVNC authors
|
|
16
16
|
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
17
17
|
*
|
|
18
18
|
* See README.md for usage and integration instructions.
|
package/lib/decoders/tight.js
CHANGED
|
@@ -16,7 +16,7 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
|
|
|
16
16
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
17
17
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
|
18
18
|
* noVNC: HTML5 VNC client
|
|
19
|
-
* Copyright (C) 2019 The noVNC
|
|
19
|
+
* Copyright (C) 2019 The noVNC authors
|
|
20
20
|
* (c) 2012 Michael Tinglof, Joe Balaz, Les Piech (Mercuri.ca)
|
|
21
21
|
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
22
22
|
*
|
package/lib/decoders/tightpng.js
CHANGED
|
@@ -20,7 +20,7 @@ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? O
|
|
|
20
20
|
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
21
21
|
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } /*
|
|
22
22
|
* noVNC: HTML5 VNC client
|
|
23
|
-
* Copyright (C) 2019 The noVNC
|
|
23
|
+
* Copyright (C) 2019 The noVNC authors
|
|
24
24
|
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
25
25
|
*
|
|
26
26
|
* See README.md for usage and integration instructions.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _inflator = _interopRequireDefault(require("../inflator.js"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
10
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
11
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
12
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
|
15
|
+
* noVNC: HTML5 VNC client
|
|
16
|
+
* Copyright (C) 2024 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 ZlibDecoder = exports["default"] = /*#__PURE__*/function () {
|
|
23
|
+
function ZlibDecoder() {
|
|
24
|
+
_classCallCheck(this, ZlibDecoder);
|
|
25
|
+
this._zlib = new _inflator["default"]();
|
|
26
|
+
this._length = 0;
|
|
27
|
+
}
|
|
28
|
+
return _createClass(ZlibDecoder, [{
|
|
29
|
+
key: "decodeRect",
|
|
30
|
+
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
31
|
+
if (width === 0 || height === 0) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
if (this._length === 0) {
|
|
35
|
+
if (sock.rQwait("ZLIB", 4)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
this._length = sock.rQshift32();
|
|
39
|
+
}
|
|
40
|
+
if (sock.rQwait("ZLIB", this._length)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
var data = new Uint8Array(sock.rQshiftBytes(this._length, false));
|
|
44
|
+
this._length = 0;
|
|
45
|
+
this._zlib.setInput(data);
|
|
46
|
+
data = this._zlib.inflate(width * height * 4);
|
|
47
|
+
this._zlib.setInput(null);
|
|
48
|
+
|
|
49
|
+
// Max sure the image is fully opaque
|
|
50
|
+
for (var i = 0; i < width * height; i++) {
|
|
51
|
+
data[i * 4 + 3] = 255;
|
|
52
|
+
}
|
|
53
|
+
display.blitImage(x, y, width, height, data, 0);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
}]);
|
|
57
|
+
}();
|
package/lib/decoders/zrle.js
CHANGED
|
@@ -13,7 +13,7 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
|
|
|
13
13
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
14
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
|
15
15
|
* noVNC: HTML5 VNC client
|
|
16
|
-
* Copyright (C) 2021 The noVNC
|
|
16
|
+
* Copyright (C) 2021 The noVNC authors
|
|
17
17
|
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
18
18
|
*
|
|
19
19
|
* See README.md for usage and integration instructions.
|
package/lib/deflator.js
CHANGED
|
@@ -14,7 +14,7 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
|
|
|
14
14
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
15
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
|
16
16
|
* noVNC: HTML5 VNC client
|
|
17
|
-
* Copyright (C) 2020 The noVNC
|
|
17
|
+
* Copyright (C) 2020 The noVNC authors
|
|
18
18
|
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
19
19
|
*
|
|
20
20
|
* See README.md for usage and integration instructions.
|
package/lib/display.js
CHANGED
|
@@ -17,7 +17,7 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
|
|
|
17
17
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
18
18
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
|
19
19
|
* noVNC: HTML5 VNC client
|
|
20
|
-
* Copyright (C) 2019 The noVNC
|
|
20
|
+
* Copyright (C) 2019 The noVNC authors
|
|
21
21
|
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
22
22
|
*
|
|
23
23
|
* See README.md for usage and integration instructions.
|
|
@@ -383,6 +383,18 @@ var Display = exports["default"] = /*#__PURE__*/function () {
|
|
|
383
383
|
'height': height
|
|
384
384
|
});
|
|
385
385
|
}
|
|
386
|
+
}, {
|
|
387
|
+
key: "videoFrame",
|
|
388
|
+
value: function videoFrame(x, y, width, height, frame) {
|
|
389
|
+
this._renderQPush({
|
|
390
|
+
'type': 'frame',
|
|
391
|
+
'frame': frame,
|
|
392
|
+
'x': x,
|
|
393
|
+
'y': y,
|
|
394
|
+
'width': width,
|
|
395
|
+
'height': height
|
|
396
|
+
});
|
|
397
|
+
}
|
|
386
398
|
}, {
|
|
387
399
|
key: "blitImage",
|
|
388
400
|
value: function blitImage(x, y, width, height, arr, offset, fromQueue) {
|
|
@@ -410,9 +422,23 @@ var Display = exports["default"] = /*#__PURE__*/function () {
|
|
|
410
422
|
}
|
|
411
423
|
}, {
|
|
412
424
|
key: "drawImage",
|
|
413
|
-
value: function drawImage(img
|
|
414
|
-
|
|
415
|
-
|
|
425
|
+
value: function drawImage(img) {
|
|
426
|
+
var _this$_drawCtx;
|
|
427
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
428
|
+
args[_key - 1] = arguments[_key];
|
|
429
|
+
}
|
|
430
|
+
(_this$_drawCtx = this._drawCtx).drawImage.apply(_this$_drawCtx, [img].concat(args));
|
|
431
|
+
if (args.length <= 4) {
|
|
432
|
+
var x = args[0],
|
|
433
|
+
y = args[1];
|
|
434
|
+
this._damage(x, y, img.width, img.height);
|
|
435
|
+
} else {
|
|
436
|
+
var sw = args[2],
|
|
437
|
+
sh = args[3],
|
|
438
|
+
dx = args[4],
|
|
439
|
+
dy = args[5];
|
|
440
|
+
this._damage(dx, dy, sw, sh);
|
|
441
|
+
}
|
|
416
442
|
}
|
|
417
443
|
}, {
|
|
418
444
|
key: "autoscale",
|
|
@@ -481,41 +507,76 @@ var Display = exports["default"] = /*#__PURE__*/function () {
|
|
|
481
507
|
}, {
|
|
482
508
|
key: "_scanRenderQ",
|
|
483
509
|
value: function _scanRenderQ() {
|
|
510
|
+
var _this2 = this;
|
|
484
511
|
var ready = true;
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
512
|
+
var _loop = function _loop() {
|
|
513
|
+
var a = _this2._renderQ[0];
|
|
514
|
+
switch (a.type) {
|
|
515
|
+
case 'flip':
|
|
516
|
+
_this2.flip(true);
|
|
517
|
+
break;
|
|
518
|
+
case 'copy':
|
|
519
|
+
_this2.copyImage(a.oldX, a.oldY, a.x, a.y, a.width, a.height, true);
|
|
520
|
+
break;
|
|
521
|
+
case 'fill':
|
|
522
|
+
_this2.fillRect(a.x, a.y, a.width, a.height, a.color, true);
|
|
523
|
+
break;
|
|
524
|
+
case 'blit':
|
|
525
|
+
_this2.blitImage(a.x, a.y, a.width, a.height, a.data, 0, true);
|
|
526
|
+
break;
|
|
527
|
+
case 'img':
|
|
528
|
+
if (a.img.complete) {
|
|
529
|
+
if (a.img.width !== a.width || a.img.height !== a.height) {
|
|
530
|
+
Log.Error("Decoded image has incorrect dimensions. Got " + a.img.width + "x" + a.img.height + ". Expected " + a.width + "x" + a.height + ".");
|
|
531
|
+
return {
|
|
532
|
+
v: void 0
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
_this2.drawImage(a.img, a.x, a.y);
|
|
536
|
+
} else {
|
|
537
|
+
a.img._noVNCDisplay = _this2;
|
|
538
|
+
a.img.addEventListener('load', _this2._resumeRenderQ);
|
|
539
|
+
// We need to wait for this image to 'load'
|
|
540
|
+
// to keep things in-order
|
|
541
|
+
ready = false;
|
|
505
542
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
a.
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
543
|
+
break;
|
|
544
|
+
case 'frame':
|
|
545
|
+
if (a.frame.ready) {
|
|
546
|
+
// The encoded frame may be larger than the rect due to
|
|
547
|
+
// limitations of the encoder, so we need to crop the
|
|
548
|
+
// frame.
|
|
549
|
+
var frame = a.frame.frame;
|
|
550
|
+
if (frame.codedWidth < a.width || frame.codedHeight < a.height) {
|
|
551
|
+
Log.Warn("Decoded video frame does not cover its full rectangle area. Expecting at least " + a.width + "x" + a.height + " but got " + frame.codedWidth + "x" + frame.codedHeight);
|
|
552
|
+
}
|
|
553
|
+
var sx = 0;
|
|
554
|
+
var sy = 0;
|
|
555
|
+
var sw = a.width;
|
|
556
|
+
var sh = a.height;
|
|
557
|
+
var dx = a.x;
|
|
558
|
+
var dy = a.y;
|
|
559
|
+
var dw = sw;
|
|
560
|
+
var dh = sh;
|
|
561
|
+
_this2.drawImage(frame, sx, sy, sw, sh, dx, dy, dw, dh);
|
|
562
|
+
frame.close();
|
|
563
|
+
} else {
|
|
564
|
+
var display = _this2;
|
|
565
|
+
a.frame.promise.then(function () {
|
|
566
|
+
display._scanRenderQ();
|
|
567
|
+
});
|
|
568
|
+
ready = false;
|
|
569
|
+
}
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
572
|
+
if (ready) {
|
|
573
|
+
_this2._renderQ.shift();
|
|
574
|
+
}
|
|
575
|
+
},
|
|
576
|
+
_ret;
|
|
577
|
+
while (ready && this._renderQ.length > 0) {
|
|
578
|
+
_ret = _loop();
|
|
579
|
+
if (_ret) return _ret.v;
|
|
519
580
|
}
|
|
520
581
|
if (this._renderQ.length === 0 && this._flushPromise !== null) {
|
|
521
582
|
this._flushResolve();
|