@novnc/novnc 1.5.0-beta → 1.5.0-g047531e

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 CHANGED
@@ -66,7 +66,7 @@ profits such as:
66
66
  RSA-AES, Tight, VeNCrypt Plain, XVP, Apple's Diffie-Hellman,
67
67
  UltraVNC's MSLogonII
68
68
  * Supported VNC encodings: raw, copyrect, rre, hextile, tight, tightPNG,
69
- ZRLE, JPEG
69
+ ZRLE, JPEG, Zlib
70
70
  * Supports scaling, clipping and resizing the desktop
71
71
  * Local cursor rendering
72
72
  * Clipboard copy/paste with full Unicode support
package/lib/crypto/aes.js CHANGED
@@ -28,7 +28,7 @@ var AESECBCipher = exports.AESECBCipher = /*#__PURE__*/function () {
28
28
  }, {
29
29
  key: "_importKey",
30
30
  value: function () {
31
- var _importKey2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, extractable, keyUsages) {
31
+ var _importKey2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, extractable, keyUsages) {
32
32
  return _regeneratorRuntime().wrap(function _callee$(_context) {
33
33
  while (1) switch (_context.prev = _context.next) {
34
34
  case 0:
@@ -52,7 +52,7 @@ var AESECBCipher = exports.AESECBCipher = /*#__PURE__*/function () {
52
52
  }, {
53
53
  key: "encrypt",
54
54
  value: function () {
55
- var _encrypt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_algorithm, plaintext) {
55
+ var _encrypt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_algorithm, plaintext) {
56
56
  var x, n, i, y;
57
57
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
58
58
  while (1) switch (_context2.prev = _context2.next) {
@@ -101,7 +101,7 @@ var AESECBCipher = exports.AESECBCipher = /*#__PURE__*/function () {
101
101
  }], [{
102
102
  key: "importKey",
103
103
  value: function () {
104
- var _importKey3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, _algorithm, extractable, keyUsages) {
104
+ var _importKey3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, _algorithm, extractable, keyUsages) {
105
105
  var cipher;
106
106
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
107
107
  while (1) switch (_context3.prev = _context3.next) {
@@ -145,7 +145,7 @@ var AESEAXCipher = exports.AESEAXCipher = /*#__PURE__*/function () {
145
145
  }, {
146
146
  key: "_encryptBlock",
147
147
  value: function () {
148
- var _encryptBlock2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(block) {
148
+ var _encryptBlock2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(block) {
149
149
  var encrypted;
150
150
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
151
151
  while (1) switch (_context4.prev = _context4.next) {
@@ -172,7 +172,7 @@ var AESEAXCipher = exports.AESEAXCipher = /*#__PURE__*/function () {
172
172
  }, {
173
173
  key: "_initCMAC",
174
174
  value: function () {
175
- var _initCMAC2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
175
+ var _initCMAC2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
176
176
  var k1, k2, v, i, lut;
177
177
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
178
178
  while (1) switch (_context5.prev = _context5.next) {
@@ -207,7 +207,7 @@ var AESEAXCipher = exports.AESEAXCipher = /*#__PURE__*/function () {
207
207
  }, {
208
208
  key: "_encryptCTR",
209
209
  value: function () {
210
- var _encryptCTR2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(data, counter) {
210
+ var _encryptCTR2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(data, counter) {
211
211
  var encrypted;
212
212
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
213
213
  while (1) switch (_context6.prev = _context6.next) {
@@ -235,7 +235,7 @@ var AESEAXCipher = exports.AESEAXCipher = /*#__PURE__*/function () {
235
235
  }, {
236
236
  key: "_decryptCTR",
237
237
  value: function () {
238
- var _decryptCTR2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(data, counter) {
238
+ var _decryptCTR2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(data, counter) {
239
239
  var decrypted;
240
240
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
241
241
  while (1) switch (_context7.prev = _context7.next) {
@@ -263,7 +263,7 @@ var AESEAXCipher = exports.AESEAXCipher = /*#__PURE__*/function () {
263
263
  }, {
264
264
  key: "_computeCMAC",
265
265
  value: function () {
266
- var _computeCMAC2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(data, prefixBlock) {
266
+ var _computeCMAC2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(data, prefixBlock) {
267
267
  var n, m, r, cbcData, i, _i, cbcEncrypted, mac;
268
268
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
269
269
  while (1) switch (_context8.prev = _context8.next) {
@@ -314,7 +314,7 @@ var AESEAXCipher = exports.AESEAXCipher = /*#__PURE__*/function () {
314
314
  }, {
315
315
  key: "_importKey",
316
316
  value: function () {
317
- var _importKey4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(key) {
317
+ var _importKey4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(key) {
318
318
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
319
319
  while (1) switch (_context9.prev = _context9.next) {
320
320
  case 0:
@@ -347,7 +347,7 @@ var AESEAXCipher = exports.AESEAXCipher = /*#__PURE__*/function () {
347
347
  }, {
348
348
  key: "encrypt",
349
349
  value: function () {
350
- var _encrypt2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(algorithm, message) {
350
+ var _encrypt2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(algorithm, message) {
351
351
  var ad, nonce, nCMAC, encrypted, adCMAC, mac, i, res;
352
352
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
353
353
  while (1) switch (_context10.prev = _context10.next) {
@@ -391,7 +391,7 @@ var AESEAXCipher = exports.AESEAXCipher = /*#__PURE__*/function () {
391
391
  }, {
392
392
  key: "decrypt",
393
393
  value: function () {
394
- var _decrypt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(algorithm, data) {
394
+ var _decrypt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(algorithm, data) {
395
395
  var encrypted, ad, nonce, mac, nCMAC, adCMAC, computedMac, i, _i2, res;
396
396
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
397
397
  while (1) switch (_context11.prev = _context11.next) {
@@ -456,7 +456,7 @@ var AESEAXCipher = exports.AESEAXCipher = /*#__PURE__*/function () {
456
456
  }], [{
457
457
  key: "importKey",
458
458
  value: function () {
459
- var _importKey5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(key, _algorithm, _extractable, _keyUsages) {
459
+ var _importKey5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(key, _algorithm, _extractable, _keyUsages) {
460
460
  var cipher;
461
461
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
462
462
  while (1) switch (_context12.prev = _context12.next) {
package/lib/crypto/md5.js CHANGED
@@ -22,7 +22,7 @@ function MD5(_x) {
22
22
  return _MD.apply(this, arguments);
23
23
  }
24
24
  function _MD() {
25
- _MD = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(d) {
25
+ _MD = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(d) {
26
26
  var s, i;
27
27
  return _regeneratorRuntime().wrap(function _callee$(_context) {
28
28
  while (1) switch (_context.prev = _context.next) {
package/lib/crypto/rsa.js CHANGED
@@ -53,7 +53,7 @@ var RSACipher = exports.RSACipher = /*#__PURE__*/function () {
53
53
  }, {
54
54
  key: "_generateKey",
55
55
  value: function () {
56
- var _generateKey2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(algorithm, extractable) {
56
+ var _generateKey2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(algorithm, extractable) {
57
57
  var key, privateKey;
58
58
  return _regeneratorRuntime().wrap(function _callee$(_context) {
59
59
  while (1) switch (_context.prev = _context.next) {
@@ -96,7 +96,7 @@ var RSACipher = exports.RSACipher = /*#__PURE__*/function () {
96
96
  }, {
97
97
  key: "_importKey",
98
98
  value: function () {
99
- var _importKey2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, extractable) {
99
+ var _importKey2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, extractable) {
100
100
  var n, e;
101
101
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
102
102
  while (1) switch (_context2.prev = _context2.next) {
@@ -132,7 +132,7 @@ var RSACipher = exports.RSACipher = /*#__PURE__*/function () {
132
132
  }, {
133
133
  key: "encrypt",
134
134
  value: function () {
135
- var _encrypt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_algorithm, message) {
135
+ var _encrypt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_algorithm, message) {
136
136
  var ps, i, em, emBigInt, c;
137
137
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
138
138
  while (1) switch (_context3.prev = _context3.next) {
@@ -169,7 +169,7 @@ var RSACipher = exports.RSACipher = /*#__PURE__*/function () {
169
169
  }, {
170
170
  key: "decrypt",
171
171
  value: function () {
172
- var _decrypt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_algorithm, message) {
172
+ var _decrypt = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_algorithm, message) {
173
173
  var msgBigInt, emBigInt, em, i;
174
174
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
175
175
  while (1) switch (_context4.prev = _context4.next) {
@@ -226,7 +226,7 @@ var RSACipher = exports.RSACipher = /*#__PURE__*/function () {
226
226
  }, {
227
227
  key: "exportKey",
228
228
  value: function () {
229
- var _exportKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
229
+ var _exportKey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
230
230
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
231
231
  while (1) switch (_context5.prev = _context5.next) {
232
232
  case 0:
@@ -255,7 +255,7 @@ var RSACipher = exports.RSACipher = /*#__PURE__*/function () {
255
255
  }], [{
256
256
  key: "generateKey",
257
257
  value: function () {
258
- var _generateKey3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(algorithm, extractable, _keyUsages) {
258
+ var _generateKey3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(algorithm, extractable, _keyUsages) {
259
259
  var cipher;
260
260
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
261
261
  while (1) switch (_context6.prev = _context6.next) {
@@ -281,7 +281,7 @@ var RSACipher = exports.RSACipher = /*#__PURE__*/function () {
281
281
  }, {
282
282
  key: "importKey",
283
283
  value: function () {
284
- var _importKey3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(key, _algorithm, extractable, keyUsages) {
284
+ var _importKey3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(key, _algorithm, extractable, keyUsages) {
285
285
  var cipher;
286
286
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
287
287
  while (1) switch (_context7.prev = _context7.next) {
@@ -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
+ }();
@@ -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/display.js CHANGED
@@ -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, x, y) {
414
- this._drawCtx.drawImage(img, x, y);
415
- this._damage(x, y, img.width, img.height);
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
- while (ready && this._renderQ.length > 0) {
486
- var a = this._renderQ[0];
487
- switch (a.type) {
488
- case 'flip':
489
- this.flip(true);
490
- break;
491
- case 'copy':
492
- this.copyImage(a.oldX, a.oldY, a.x, a.y, a.width, a.height, true);
493
- break;
494
- case 'fill':
495
- this.fillRect(a.x, a.y, a.width, a.height, a.color, true);
496
- break;
497
- case 'blit':
498
- this.blitImage(a.x, a.y, a.width, a.height, a.data, 0, true);
499
- break;
500
- case 'img':
501
- if (a.img.complete) {
502
- if (a.img.width !== a.width || a.img.height !== a.height) {
503
- Log.Error("Decoded image has incorrect dimensions. Got " + a.img.width + "x" + a.img.height + ". Expected " + a.width + "x" + a.height + ".");
504
- return;
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
- this.drawImage(a.img, a.x, a.y);
507
- } else {
508
- a.img._noVNCDisplay = this;
509
- a.img.addEventListener('load', this._resumeRenderQ);
510
- // We need to wait for this image to 'load'
511
- // to keep things in-order
512
- ready = false;
513
- }
514
- break;
515
- }
516
- if (ready) {
517
- this._renderQ.shift();
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();
package/lib/encodings.js CHANGED
@@ -18,10 +18,12 @@ var encodings = exports.encodings = {
18
18
  encodingCopyRect: 1,
19
19
  encodingRRE: 2,
20
20
  encodingHextile: 5,
21
+ encodingZlib: 6,
21
22
  encodingTight: 7,
22
23
  encodingZRLE: 16,
23
24
  encodingTightPNG: -260,
24
25
  encodingJPEG: 21,
26
+ encodingH264: 50,
25
27
  pseudoEncodingQualityLevel9: -23,
26
28
  pseudoEncodingQualityLevel0: -32,
27
29
  pseudoEncodingDesktopSize: -223,
@@ -49,6 +51,8 @@ function encodingName(num) {
49
51
  return "RRE";
50
52
  case encodings.encodingHextile:
51
53
  return "Hextile";
54
+ case encodings.encodingZlib:
55
+ return "Zlib";
52
56
  case encodings.encodingTight:
53
57
  return "Tight";
54
58
  case encodings.encodingZRLE:
@@ -57,6 +61,8 @@ function encodingName(num) {
57
61
  return "TightPNG";
58
62
  case encodings.encodingJPEG:
59
63
  return "JPEG";
64
+ case encodings.encodingH264:
65
+ return "H.264";
60
66
  default:
61
67
  return "[unknown encoding " + num + "]";
62
68
  }
@@ -203,7 +203,7 @@ var Keyboard = exports["default"] = /*#__PURE__*/function () {
203
203
  // Possible start of AltGr sequence? (see above)
204
204
  if (code === "ControlLeft" && browser.isWindows() && !("ControlLeft" in this._keyDownList)) {
205
205
  this._altGrArmed = true;
206
- this._altGrTimeout = setTimeout(this._handleAltGrTimeout.bind(this), 100);
206
+ this._altGrTimeout = setTimeout(this._interruptAltGrSequence.bind(this), 100);
207
207
  this._altGrCtrlTime = e.timeStamp;
208
208
  return;
209
209
  }
@@ -217,11 +217,7 @@ var Keyboard = exports["default"] = /*#__PURE__*/function () {
217
217
 
218
218
  // We can't get a release in the middle of an AltGr sequence, so
219
219
  // abort that detection
220
- if (this._altGrArmed) {
221
- this._altGrArmed = false;
222
- clearTimeout(this._altGrTimeout);
223
- this._sendKeyEvent(_keysym["default"].XK_Control_L, "ControlLeft", true);
224
- }
220
+ this._interruptAltGrSequence();
225
221
 
226
222
  // See comment in _handleKeyDown()
227
223
  if ((browser.isMac() || browser.isIOS()) && code === 'CapsLock') {
@@ -244,16 +240,21 @@ var Keyboard = exports["default"] = /*#__PURE__*/function () {
244
240
  }
245
241
  }
246
242
  }, {
247
- key: "_handleAltGrTimeout",
248
- value: function _handleAltGrTimeout() {
249
- this._altGrArmed = false;
250
- clearTimeout(this._altGrTimeout);
251
- this._sendKeyEvent(_keysym["default"].XK_Control_L, "ControlLeft", true);
243
+ key: "_interruptAltGrSequence",
244
+ value: function _interruptAltGrSequence() {
245
+ if (this._altGrArmed) {
246
+ this._altGrArmed = false;
247
+ clearTimeout(this._altGrTimeout);
248
+ this._sendKeyEvent(_keysym["default"].XK_Control_L, "ControlLeft", true);
249
+ }
252
250
  }
253
251
  }, {
254
252
  key: "_allKeysUp",
255
253
  value: function _allKeysUp() {
256
254
  Log.Debug(">> Keyboard.allKeysUp");
255
+
256
+ // Prevent control key being processed after losing focus.
257
+ this._interruptAltGrSequence();
257
258
  for (var code in this._keyDownList) {
258
259
  this._sendKeyEvent(this._keyDownList[code], code, false);
259
260
  }
package/lib/ra2.js CHANGED
@@ -33,7 +33,7 @@ var RA2Cipher = /*#__PURE__*/function () {
33
33
  return _createClass(RA2Cipher, [{
34
34
  key: "setKey",
35
35
  value: function () {
36
- var _setKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key) {
36
+ var _setKey = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(key) {
37
37
  return _regeneratorRuntime().wrap(function _callee$(_context) {
38
38
  while (1) switch (_context.prev = _context.next) {
39
39
  case 0:
@@ -57,7 +57,7 @@ var RA2Cipher = /*#__PURE__*/function () {
57
57
  }, {
58
58
  key: "makeMessage",
59
59
  value: function () {
60
- var _makeMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(message) {
60
+ var _makeMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(message) {
61
61
  var ad, encrypted, i, res;
62
62
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
63
63
  while (1) switch (_context2.prev = _context2.next) {
@@ -90,7 +90,7 @@ var RA2Cipher = /*#__PURE__*/function () {
90
90
  }, {
91
91
  key: "receiveMessage",
92
92
  value: function () {
93
- var _receiveMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(length, encrypted) {
93
+ var _receiveMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(length, encrypted) {
94
94
  var ad, res, i;
95
95
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
96
96
  while (1) switch (_context3.prev = _context3.next) {
@@ -231,7 +231,7 @@ var RSAAESAuthenticationState = exports["default"] = /*#__PURE__*/function (_Eve
231
231
  }, {
232
232
  key: "negotiateRA2neAuthAsync",
233
233
  value: function () {
234
- var _negotiateRA2neAuthAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
234
+ var _negotiateRA2neAuthAsync = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
235
235
  var serverKeyLengthBuffer, serverKeyLength, serverKeyBytes, serverN, serverE, serverRSACipher, serverPublickey, approveKey, clientKeyLength, clientKeyBytes, clientRSACipher, clientExportedRSAKey, clientN, clientE, clientPublicKey, clientRandom, clientEncryptedRandom, clientRandomMessage, serverEncryptedRandom, serverRandom, clientSessionKey, serverSessionKey, clientCipher, serverCipher, serverHash, clientHash, serverHashReceived, i, subtype, waitCredentials, username, password, credentials, _i, _i2;
236
236
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
237
237
  while (1) switch (_context4.prev = _context4.next) {
package/lib/rfb.js CHANGED
@@ -28,10 +28,12 @@ var _raw = _interopRequireDefault(require("./decoders/raw.js"));
28
28
  var _copyrect = _interopRequireDefault(require("./decoders/copyrect.js"));
29
29
  var _rre = _interopRequireDefault(require("./decoders/rre.js"));
30
30
  var _hextile = _interopRequireDefault(require("./decoders/hextile.js"));
31
+ var _zlib = _interopRequireDefault(require("./decoders/zlib.js"));
31
32
  var _tight = _interopRequireDefault(require("./decoders/tight.js"));
32
33
  var _tightpng = _interopRequireDefault(require("./decoders/tightpng.js"));
33
34
  var _zrle = _interopRequireDefault(require("./decoders/zrle.js"));
34
35
  var _jpeg = _interopRequireDefault(require("./decoders/jpeg.js"));
36
+ var _h = _interopRequireDefault(require("./decoders/h264.js"));
35
37
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
36
38
  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); }
37
39
  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; }
@@ -263,10 +265,12 @@ var RFB = exports["default"] = /*#__PURE__*/function (_EventTargetMixin) {
263
265
  _this._decoders[_encodings.encodings.encodingCopyRect] = new _copyrect["default"]();
264
266
  _this._decoders[_encodings.encodings.encodingRRE] = new _rre["default"]();
265
267
  _this._decoders[_encodings.encodings.encodingHextile] = new _hextile["default"]();
268
+ _this._decoders[_encodings.encodings.encodingZlib] = new _zlib["default"]();
266
269
  _this._decoders[_encodings.encodings.encodingTight] = new _tight["default"]();
267
270
  _this._decoders[_encodings.encodings.encodingTightPNG] = new _tightpng["default"]();
268
271
  _this._decoders[_encodings.encodings.encodingZRLE] = new _zrle["default"]();
269
272
  _this._decoders[_encodings.encodings.encodingJPEG] = new _jpeg["default"]();
273
+ _this._decoders[_encodings.encodings.encodingH264] = new _h["default"]();
270
274
 
271
275
  // NB: nothing that needs explicit teardown should be done
272
276
  // before this point, since this can throw an exception
@@ -1774,7 +1778,7 @@ var RFB = exports["default"] = /*#__PURE__*/function (_EventTargetMixin) {
1774
1778
  }, {
1775
1779
  key: "_negotiateARDAuthAsync",
1776
1780
  value: function () {
1777
- var _negotiateARDAuthAsync2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(keyLength, serverPublicKey, clientKey) {
1781
+ var _negotiateARDAuthAsync2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(keyLength, serverPublicKey, clientKey) {
1778
1782
  var clientPublicKey, sharedKey, username, password, credentials, i, _i2, key, cipher, encrypted;
1779
1783
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1780
1784
  while (1) switch (_context.prev = _context.next) {
@@ -2207,12 +2211,16 @@ var RFB = exports["default"] = /*#__PURE__*/function (_EventTargetMixin) {
2207
2211
  encs.push(_encodings.encodings.encodingCopyRect);
2208
2212
  // Only supported with full depth support
2209
2213
  if (this._fbDepth == 24) {
2214
+ if (_browser.supportsWebCodecsH264Decode) {
2215
+ encs.push(_encodings.encodings.encodingH264);
2216
+ }
2210
2217
  encs.push(_encodings.encodings.encodingTight);
2211
2218
  encs.push(_encodings.encodings.encodingTightPNG);
2212
2219
  encs.push(_encodings.encodings.encodingZRLE);
2213
2220
  encs.push(_encodings.encodings.encodingJPEG);
2214
2221
  encs.push(_encodings.encodings.encodingHextile);
2215
2222
  encs.push(_encodings.encodings.encodingRRE);
2223
+ encs.push(_encodings.encodings.encodingZlib);
2216
2224
  }
2217
2225
  encs.push(_encodings.encodings.encodingRaw);
2218
2226
 
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- 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); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -20,11 +19,14 @@ exports.isSafari = isSafari;
20
19
  exports.isTouchDevice = void 0;
21
20
  exports.isWebKit = isWebKit;
22
21
  exports.isWindows = isWindows;
23
- exports.supportsCursorURIs = void 0;
22
+ exports.supportsWebCodecsH264Decode = exports.supportsCursorURIs = void 0;
24
23
  var Log = _interopRequireWildcard(require("./logging.js"));
25
24
  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); }
26
25
  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; }
27
- /*
26
+ 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); }
27
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
28
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
29
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } /*
28
30
  * noVNC: HTML5 VNC client
29
31
  * Copyright (C) 2019 The noVNC Authors
30
32
  * Licensed under MPL 2.0 (see LICENSE.txt)
@@ -33,7 +35,6 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
33
35
  *
34
36
  * Browser feature support detection
35
37
  */
36
-
37
38
  // Touch detection
38
39
  var isTouchDevice = exports.isTouchDevice = 'ontouchstart' in document.documentElement ||
39
40
  // requried for Chrome debugger
@@ -85,6 +86,43 @@ try {
85
86
  Log.Error("Scrollbar test exception: " + exc);
86
87
  }
87
88
  var hasScrollbarGutter = exports.hasScrollbarGutter = _hasScrollbarGutter;
89
+ var supportsWebCodecsH264Decode = exports.supportsWebCodecsH264Decode = false;
90
+ function _checkWebCodecsH264DecodeSupport() {
91
+ return _checkWebCodecsH264DecodeSupport2.apply(this, arguments);
92
+ }
93
+ function _checkWebCodecsH264DecodeSupport2() {
94
+ _checkWebCodecsH264DecodeSupport2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
95
+ var config, result;
96
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
97
+ while (1) switch (_context.prev = _context.next) {
98
+ case 0:
99
+ if ('VideoDecoder' in window) {
100
+ _context.next = 2;
101
+ break;
102
+ }
103
+ return _context.abrupt("return");
104
+ case 2:
105
+ // We'll need to make do with some placeholders here
106
+ config = {
107
+ codec: 'avc1.42401f',
108
+ codedWidth: 1920,
109
+ codedHeight: 1080,
110
+ optimizeForLatency: true
111
+ };
112
+ _context.next = 5;
113
+ return VideoDecoder.isConfigSupported(config);
114
+ case 5:
115
+ result = _context.sent;
116
+ exports.supportsWebCodecsH264Decode = supportsWebCodecsH264Decode = result.supported;
117
+ case 7:
118
+ case "end":
119
+ return _context.stop();
120
+ }
121
+ }, _callee);
122
+ }));
123
+ return _checkWebCodecsH264DecodeSupport2.apply(this, arguments);
124
+ }
125
+ _checkWebCodecsH264DecodeSupport();
88
126
 
89
127
  /*
90
128
  * The functions for detection of platforms and browsers below are exported
package/lib/websock.js CHANGED
@@ -233,7 +233,7 @@ var Websock = exports["default"] = /*#__PURE__*/function () {
233
233
  if (chunkSize > bytes.length - offset) {
234
234
  chunkSize = bytes.length - offset;
235
235
  }
236
- this._sQ.set(bytes.subarray(offset, chunkSize), this._sQlen);
236
+ this._sQ.set(bytes.subarray(offset, offset + chunkSize), this._sQlen);
237
237
  this._sQlen += chunkSize;
238
238
  offset += chunkSize;
239
239
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novnc/novnc",
3
- "version": "1.5.0-beta",
3
+ "version": "1.5.0-g047531e",
4
4
  "description": "An HTML5 VNC client",
5
5
  "browser": "lib/rfb",
6
6
  "directories": {
@@ -55,7 +55,6 @@
55
55
  "karma-mocha-reporter": "latest",
56
56
  "karma-safari-launcher": "latest",
57
57
  "karma-script-launcher": "latest",
58
- "karma-sinon-chai": "latest",
59
58
  "mocha": "latest",
60
59
  "node-getopt": "latest",
61
60
  "po2json": "latest",